Search is not available for this dataset
text
string
meta
dict
{-# OPTIONS --safe #-} module Cubical.Data.FinData.Order where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function import Cubical.Data.Empty as ⊥ open import Cubical.Data.Nat using (ℕ) open import Cubical.Data.Nat.Order open import Cubical.Data.Bool.Base open import Cubical.Relation.Nullary open import Cubical.Relation.Binary open import Cubical.Data.FinData.Base open import Cubical.Data.FinData.Properties private variable ℓ : Level -- Order relation: _≤Fin_ : {n : ℕ} → Fin n → Fin n → Type i ≤Fin j = (toℕ i) ≤ (toℕ j) _<Fin_ : {n : ℕ} → Fin n → Fin n → Type i <Fin j = (suc i) ≤Fin (weakenFin j) open BinaryRelation ≤FinIsPropValued : ∀ {n : ℕ} → isPropValued (_≤Fin_ {n}) ≤FinIsPropValued _ _ = isProp≤ -- inductive version _≤'Fin_ : {n : ℕ} → Fin n → Fin n → Type i ≤'Fin j = (toℕ i) ≤' (toℕ j) _<'Fin_ : {n : ℕ} → Fin n → Fin n → Type i <'Fin j = (suc i) ≤'Fin (weakenFin j) open BinaryRelation ≤'FinIsPropValued : ∀ {n : ℕ} → isPropValued (_≤'Fin_ {n}) ≤'FinIsPropValued _ _ = ≤'IsPropValued _ _
{ "alphanum_fraction": 0.6796208531, "avg_line_length": 23.4444444444, "ext": "agda", "hexsha": "08aa61c5785ffa475ec997794dd70030c569aad6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Data/FinData/Order.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Data/FinData/Order.agda", "max_line_length": 58, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Data/FinData/Order.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 381, "size": 1055 }
------------------------------------------------------------------------ -- Equivalence of declarative and canonical kinding of Fω with -- interval kinds ------------------------------------------------------------------------ {-# OPTIONS --safe --without-K #-} module FOmegaInt.Kinding.Canonical.Equivalence where open import Data.Fin using (zero) open import Data.Fin.Substitution using (module VarSubst) open import Data.Fin.Substitution.Typed open import Data.Product as Prod using (_,_; proj₁; proj₂) open import Data.Vec using ([]) open import Function using (_∘_) open import Relation.Binary.PropositionalEquality hiding ([_]) open import FOmegaInt.Syntax open import FOmegaInt.Syntax.HereditarySubstitution open import FOmegaInt.Syntax.Normalization open import FOmegaInt.Syntax.WeakEquality import FOmegaInt.Typing as Original import FOmegaInt.Typing.Validity as OriginalValidity import FOmegaInt.Kinding.Declarative as Extended import FOmegaInt.Kinding.Declarative.Validity as ExtendedValidity import FOmegaInt.Kinding.Declarative.Equivalence as ExtendedEquiv import FOmegaInt.Kinding.Declarative.Normalization as OriginalNorm open import FOmegaInt.Kinding.Canonical as Canonical open import FOmegaInt.Kinding.Canonical.Validity open import FOmegaInt.Kinding.Canonical.WeakEquality import FOmegaInt.Kinding.Simple as SimpKind import FOmegaInt.Kinding.Simple.EtaExpansion as SimpEtaExp open import FOmegaInt.Kinding.Simple.Normalization private -- Original declarative rules and lemmas. module O where open Original public open Typing public open TermCtx public open TypedSubstitution public open OriginalValidity public open OriginalNorm public -- Extended declarative rules and lemmas. module E where open Extended public open Extended.Kinding public open TermCtx public open KindedSubstitution public open ExtendedValidity public open ExtendedEquiv public -- Canonical rules and lemmas. module C where open Canonical public open Kinding public open ElimCtx public open Syntax open Substitution using (_Kind[_]) open ElimCtx open SimpleCtx using (kd) open ContextConversions open WeakEqNormalization open Kinding open KindedRenaming open ContextNarrowing open Original.Typing hiding (_ctx; _⊢_wf; _⊢_kd; _⊢_<∷_; _⊢_<:_∈_; _⊢_≅_) open Extended.Kinding hiding (_ctx; _⊢_wf; _⊢_kd; _⊢_<∷_; _⊢_<:_∈_; _⊢_≅_) ------------------------------------------------------------------------ -- Soundness of canonical (sub)kinding w.r.t. declarative (sub)kinding mutual sound-wf : ∀ {n} {Γ : Ctx n} {a} → Γ ⊢ a wf → ⌞ Γ ⌟Ctx O.⊢ ⌞ a ⌟Asc wf sound-wf (wf-kd k-kd) = wf-kd (sound-kd k-kd) sound-wf (wf-tp a⇉a⋯a) = wf-tp (O.Tp∈-⋯-* (sound-Nf⇉ a⇉a⋯a)) sound-ctx : ∀ {n} {Γ : Ctx n} → Γ ctx → ⌞ Γ ⌟Ctx O.ctx sound-ctx C.[] = O.[] sound-ctx (a-wf C.∷ Γ-ctx) = sound-wf a-wf O.∷ sound-ctx Γ-ctx sound-kd : ∀ {n} {Γ : Ctx n} {k} → Γ ⊢ k kd → ⌞ Γ ⌟Ctx O.⊢ ⌞ k ⌟Kd kd sound-kd (kd-⋯ a⇉a⋯a b⇉b⋯b) = kd-⋯ (O.Tp∈-⋯-* (sound-Nf⇉ a⇉a⋯a)) (O.Tp∈-⋯-* (sound-Nf⇉ b⇉b⋯b)) sound-kd (kd-Π j-kd k-kd) = kd-Π (sound-kd j-kd) (sound-kd k-kd) sound-Nf⇉ : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Nf a ⇉ k → ⌞ Γ ⌟Ctx O.⊢Tp ⌞ a ⌟ ∈ ⌞ k ⌟Kd sound-Nf⇉ (⇉-⊥-f Γ-ctx) = ∈-s-i (∈-⊥-f (sound-ctx Γ-ctx)) sound-Nf⇉ (⇉-⊤-f Γ-ctx) = ∈-s-i (∈-⊤-f (sound-ctx Γ-ctx)) sound-Nf⇉ (⇉-∀-f k-kd a⇉a⋯a) = ∈-s-i (∈-∀-f (sound-kd k-kd) (O.Tp∈-⋯-* (sound-Nf⇉ a⇉a⋯a))) sound-Nf⇉ (⇉-→-f a⇉a⋯a b⇉b⋯b) = ∈-s-i (∈-→-f (O.Tp∈-⋯-* (sound-Nf⇉ a⇉a⋯a)) (O.Tp∈-⋯-* (sound-Nf⇉ b⇉b⋯b))) sound-Nf⇉ (⇉-Π-i j-kd a⇉k) = let ⌞a⌟∈⌞k⌟ = sound-Nf⇉ a⇉k in ∈-Π-i (sound-kd j-kd) ⌞a⌟∈⌞k⌟ sound-Nf⇉ (⇉-s-i a⇉b⋯c) = ∈-s-i (sound-Ne∈ a⇉b⋯c) sound-Ne∈ : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Ne a ∈ k → ⌞ Γ ⌟Ctx O.⊢Tp ⌞ a ⌟ ∈ ⌞ k ⌟Kd sound-Ne∈ (∈-∙ x∈j j⇉as⇉k) = sound-Sp⇉ (sound-Var∈ x∈j) j⇉as⇉k sound-Sp⇉ : ∀ {n} {Γ : Ctx n} {a bs j k} → ⌞ Γ ⌟Ctx O.⊢Tp a ∈ ⌞ j ⌟Kd → Γ ⊢ j ⇉∙ bs ⇉ k → ⌞ Γ ⌟Ctx O.⊢Tp a ⌞∙⌟ ⌞ bs ⌟Sp ∈ ⌞ k ⌟Kd sound-Sp⇉ a∈⌞j⌟ ⇉-[] = a∈⌞j⌟ sound-Sp⇉ a∈⌞Πjk⌟ (⇉-∷ b⇇j j-kd k[b]⇉bs⇉l) with O.Tp∈-valid a∈⌞Πjk⌟ ... | (kd-Π ⌞j⌟-kd ⌞k⌟-kd) = let ⌞b⌟∈⌞j⌟ = sound-Nf⇇ b⇇j in sound-Sp⇉ (∈-⇑ (∈-Π-e a∈⌞Πjk⌟ ⌞b⌟∈⌞j⌟) (O.≅⇒<∷ (O.kd-⌞⌟-[]-≅ ⌞k⌟-kd ⌞b⌟∈⌞j⌟))) k[b]⇉bs⇉l sound-Nf⇇ : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Nf a ⇇ k → ⌞ Γ ⌟Ctx O.⊢Tp ⌞ a ⌟ ∈ ⌞ k ⌟Kd sound-Nf⇇ (⇇-⇑ a⇉j j<∷k) = ∈-⇑ (sound-Nf⇉ a⇉j) (sound-<∷ j<∷k) sound-Var∈ : ∀ {n} {Γ : Ctx n} {x k} → Γ ⊢Var x ∈ k → ⌞ Γ ⌟Ctx O.⊢Tp var x ∈ ⌞ k ⌟Kd sound-Var∈ {_} {Γ} (⇉-var {k} x Γ-ctx Γ[x]≡kd-k) = ∈-var x (sound-ctx Γ-ctx) (begin TermCtx.lookup ⌞ Γ ⌟Ctx x ≡⟨ ⌞⌟Asc-lookup Γ x ⟩ ⌞ lookup Γ x ⌟Asc ≡⟨ cong ⌞_⌟Asc Γ[x]≡kd-k ⟩ kd ⌞ k ⌟Kd ∎) where open ≡-Reasoning open Substitution using (⌞⌟Asc-weaken) sound-Var∈ (⇇-⇑ x∈j j<∷k k-kd) = ∈-⇑ (sound-Var∈ x∈j) (sound-<∷ j<∷k) sound-<∷ : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j <∷ k → ⌞ Γ ⌟Ctx O.⊢ ⌞ j ⌟Kd <∷ ⌞ k ⌟Kd sound-<∷ (<∷-⋯ a₂<:a₁ b₁<:b₂) = <∷-⋯ (sound-<: a₂<:a₁) (sound-<: b₁<:b₂) sound-<∷ (<∷-Π j₂<∷j₁ k₁<∷k₂ Πj₁k₁-kd) = <∷-Π (sound-<∷ j₂<∷j₁) (sound-<∷ k₁<∷k₂) (sound-kd Πj₁k₁-kd) sound-<: : ∀ {n} {Γ : Ctx n} {a b} → Γ ⊢ a <: b → ⌞ Γ ⌟Ctx O.⊢ ⌞ a ⌟ <: ⌞ b ⌟ ∈ * sound-<: (<:-trans a<:b b<:c) = <:-trans (sound-<: a<:b) (sound-<: b<:c) sound-<: (<:-⊥ a⇉a⋯a) = <:-⊥ (O.Tp∈-⋯-* (sound-Nf⇉ a⇉a⋯a)) sound-<: (<:-⊤ a⇉a⋯a) = <:-⊤ (O.Tp∈-⋯-* (sound-Nf⇉ a⇉a⋯a)) sound-<: (<:-∀ k₂<∷k₁ a₁<:a₂ Πk₁a₁⇉Πk₁a₁⋯Πk₁a₁) = <:-∀ (sound-<∷ k₂<∷k₁) (sound-<: a₁<:a₂) (O.Tp∈-⋯-* (sound-Nf⇉ Πk₁a₁⇉Πk₁a₁⋯Πk₁a₁)) sound-<: (<:-→ a₂<:a₁ b₁<:b₂) = <:-→ (sound-<: a₂<:a₁) (sound-<: b₁<:b₂) sound-<: (<:-∙ x∈j j⇉as⇉k) = O.<:-⋯-* (sound-<:-∙-≃ (<:-refl (sound-Var∈ x∈j)) j⇉as⇉k) sound-<: (<:-⟨| a∈b⋯c) = <:-⟨| (sound-Ne∈ a∈b⋯c) sound-<: (<:-|⟩ a∈b⋯c) = <:-|⟩ (sound-Ne∈ a∈b⋯c) sound-<:⇇ : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a <: b ⇇ k → ⌞ Γ ⌟Ctx O.⊢ ⌞ a ⌟ <: ⌞ b ⌟ ∈ ⌞ k ⌟Kd sound-<:⇇ (<:-⇇ (⇇-⇑ a₁⇉c₁⋯d₁ (<∷-⋯ c₁<:c d<:d₁)) (⇇-⇑ a₂⇉c₂⋯d₂ (<∷-⋯ c₂<:c d<:d₂)) a<:b) with Nf⇉-≡ a₁⇉c₁⋯d₁ | Nf⇉-≡ a₂⇉c₂⋯d₂ sound-<:⇇ (<:-⇇ (⇇-⇑ a₁⇉a₁⋯a₁ (<∷-⋯ c<:a₁ _)) (⇇-⇑ a₂⇉a₂⋯a₂ (<∷-⋯ _ a₂<:d)) a<:b) | refl , refl | refl , refl = <:-⇑ (<:-⋯-i (sound-<: a<:b)) (<∷-⋯ (sound-<: c<:a₁) (sound-<: a₂<:d)) sound-<:⇇ (<:-λ a₁<:a₂⇇k Λj₁a₁⇇Πjk Λj₂a₂⇇Πjk) = <:-λ (sound-<:⇇ a₁<:a₂⇇k) (sound-Nf⇇ Λj₁a₁⇇Πjk) (sound-Nf⇇ Λj₂a₂⇇Πjk) sound-≅ : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j ≅ k → ⌞ Γ ⌟Ctx O.⊢ ⌞ j ⌟Kd ≅ ⌞ k ⌟Kd sound-≅ (<∷-antisym _ _ j<∷k k<∷j) = <∷-antisym (sound-<∷ j<∷k) (sound-<∷ k<∷j) sound-≃ : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a ≃ b ⇇ k → ⌞ Γ ⌟Ctx O.⊢ ⌞ a ⌟ ≃ ⌞ b ⌟ ∈ ⌞ k ⌟Kd sound-≃ (<:-antisym k-kd a<:b⇇k b<:a⇇k) = <:-antisym (sound-<:⇇ a<:b⇇k) (sound-<:⇇ b<:a⇇k) sound-<:-∙-≃ : ∀ {n} {Γ : Ctx n} {a b as bs j k} → ⌞ Γ ⌟Ctx O.⊢ a <: b ∈ ⌞ j ⌟Kd → Γ ⊢ j ⇉∙ as ≃ bs ⇉ k → ⌞ Γ ⌟Ctx O.⊢ a ⌞∙⌟ ⌞ as ⌟Sp <: b ⌞∙⌟ ⌞ bs ⌟Sp ∈ ⌞ k ⌟Kd sound-<:-∙-≃ a<:b∈⌞j⌟ ≃-[] = a<:b∈⌞j⌟ sound-<:-∙-≃ a<:b∈⌞Πjk⌟ (≃-∷ c≃d⇇j k[c]⇉cs≃ds⇉l) with O.<:-valid-kd a<:b∈⌞Πjk⌟ ... | (kd-Π ⌞j⌟-kd ⌞k⌟-kd) = let ⌞c⌟≃⌞d⌟∈⌞j⌟ = sound-≃ c≃d⇇j ⌞c⌟∈⌞j⌟ , _ = O.≃-valid ⌞c⌟≃⌞d⌟∈⌞j⌟ in sound-<:-∙-≃ (<:-⇑ (<:-· a<:b∈⌞Πjk⌟ ⌞c⌟≃⌞d⌟∈⌞j⌟) (O.≅⇒<∷ (O.kd-⌞⌟-[]-≅ ⌞k⌟-kd ⌞c⌟∈⌞j⌟))) k[c]⇉cs≃ds⇉l ------------------------------------------------------------------------ -- Completeness of canonical (sub)kinding w.r.t. declarative -- (sub)kinding open Substitution hiding (subst) module TrackSimpleKindsCanonicalEtaExp where open RenamingCommutes open SimpHSubstLemmas private module V = VarSubst module TK = TrackSimpleKindsEtaExp module TKE = SimpEtaExp.TrackSimpleKindsKindedEtaExp -- Hereditary substitutions of a variable by its well-kinded -- η-expansion in well-formed kinds vanish. -- -- NOTE. We will strengthen this lemma below, once we have proven -- that η-expansion preserves canonical kinding. kd-[]-η-var : ∀ {k n} {Γ : Ctx n} {j l} → Γ ⊢ j kd → kd j ∷ Γ ⊢ l kd → let j′ = weakenKind′ j in (hyp : ⌊ j′ ⌋≡ k) → let η-z = TK.η-exp j′ hyp (var∙ zero) in kd j ∷ Γ ⊢Nf η-z ⇇ j′ → kd j ∷ Γ ⊢ (l Kind′/Var V.wk V.↑) Kind[ η-z ∈ ⌊ j′ ⌋ ] ≅ l kd-[]-η-var j-kd l-kd hyp η-z⇇j = let open TypedVarSubst typedVarSubst open SimpKind.Kinding using (_⊢_kds) open SimpleCtx using (kd) j-wf = wf-kd j-kd j-kd′ = kd-weaken j-wf j-kd ⌊j⌋≡k = trans (sym (⌊⌋-Kind′/Var _)) (⌊⌋≡⇒⌊⌋-≡ hyp) η-z = TK.η-exp _ hyp (var∙ zero) j-kds′ = subst (λ k → kd k ∷ _ ⊢ _ kds) ⌊j⌋≡k (kd-kds j-kd′) l-kds = subst (λ k → kd k ∷ _ ⊢ _ kds) ⌊j⌋≡k (kd-kds l-kd) l[z]≋l = TKE.kds-[]-η-var [] hyp j-kds′ l-kds wk↑∈j∷Γ = ∈-↑′ j-kd′ (∈-wk j-wf) l[z]-kd = kd-[] (kd-/Var l-kd wk↑∈j∷Γ) η-z⇇j in ≋-≅ l[z]-kd l-kd (subst (λ l → _ Kind[ η-z ∈ l ] ≋ _) (sym (⌊⌋≡⇒⌊⌋-≡ hyp)) l[z]≋l) -- NOTE. The definition of the function η-exp-Ne∈ below is -- structurally recursive in the *shape* parameter k, but *not* in -- the kind j because we need to weaken the domain j₁ of the -- dependent kind (j = Π j₁ j₂) in the arrow case. The additional -- hypothesis ⌊ j ⌋≡ k ensures that k is indeed the shape of the -- kind j. -- η-expansion preserves canonical kinding of neutral types. η-exp-Ne∈ : ∀ {n} {Γ : Ctx n} {a j k l} (hyp : ⌊ j ⌋≡ k) → Γ ⊢ j kd → Γ ⊢Ne a ∈ l → Γ ⊢ l <∷ j → Γ ⊢Nf TK.η-exp j hyp a ⇇ j η-exp-Ne∈ is-★ b₂⋯c₂-kd a∈b₁⋯c₁ (<∷-⋯ b₂<:b₁ c₁<:c₂) = Nf⇇-⇑ (Nf⇇-ne a∈b₁⋯c₁) (<∷-⋯ b₂<:b₁ c₁<:c₂) η-exp-Ne∈ (is-⇒ ⌊j₁⌋≡k₁ ⌊j₂⌋≡k₂) (kd-Π j₁-kd j₂-kd) (∈-∙ {x} {_} {_} {as} x∈l l⇉as∈Πl₁l₂) (<∷-Π j₁<∷l₁ l₂<∷j₂ (kd-Π l₁-kd l₂-kd)) = Nf⇇-Π-i j₁-kd (η-exp-Ne∈ ⌊j₂⌋≡k₂ j₂-kd x∙as·z∈l₂[z] l₂[z]<∷j₂) where open TypedVarSubst typedVarSubst j₁-wf = wf-kd j₁-kd j₁∷Γ-ctx = j₁-wf C.∷ Var∈-ctx x∈l j₁-kd′ = kd-weaken j₁-wf j₁-kd l₁-kd′ = kd-weaken j₁-wf l₁-kd ⌊j₁′⌋≡k₁ = ⌊⌋≡-weaken ⌊j₁⌋≡k₁ η-z = TK.η-exp _ ⌊j₁′⌋≡k₁ (var∙ zero) z⇇j₁ = η-exp-Ne∈ ⌊j₁′⌋≡k₁ j₁-kd′ (∈-∙ (⇉-var zero j₁∷Γ-ctx refl) ⇉-[]) (<∷-refl j₁-kd′) z⇇l₁ = Nf⇇-⇑ z⇇j₁ (<∷-weaken j₁-wf j₁<∷l₁) wk↑∈j₁∷Γ = ∈-↑′ j₁-kd′ (∈-wk j₁-wf) j₂[z]<∷j₂ = ≅⇒<∷ (kd-[]-η-var j₁-kd j₂-kd ⌊j₁′⌋≡k₁ z⇇j₁) l₂[z]<∷j₂[z] = <∷-[≃] (<∷-/Var l₂<∷j₂ wk↑∈j₁∷Γ) (≃-reflNf⇇ z⇇j₁ j₁-kd′) l₂[z]<∷j₂ = subst (λ l → _ ⊢ _ Kind[ η-z ∈ l ] <∷ _) (<∷-⌊⌋ (<∷-weaken j₁-wf j₁<∷l₁)) (<∷-trans l₂[z]<∷j₂[z] j₂[z]<∷j₂) x∙as·z∈l₂[z] = (∈-∙ (Var∈-weaken j₁-wf x∈l) (⇉-∷ʳ (Sp⇉-weaken j₁-wf l⇉as∈Πl₁l₂) z⇇l₁ l₁-kd′)) private module TK = TrackSimpleKindsCanonicalEtaExp -- η-expansion preserves canonical kinding of neutral types. η-exp-Ne∈ : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢ k kd → Γ ⊢Ne a ∈ k → Γ ⊢Nf η-exp k a ⇇ k η-exp-Ne∈ k-kd a∈k = TK.η-exp-Ne∈ (⌊⌋-⌊⌋≡ _) k-kd a∈k (<∷-refl k-kd) η-exp-Var∈ : ∀ {n} {Γ : Ctx n} {x k} → Γ ⊢ k kd → Γ ⊢Var x ∈ k → Γ ⊢Nf η-exp k (var∙ x) ⇇ k η-exp-Var∈ k-kd x∈k = η-exp-Ne∈ k-kd (∈-∙ x∈k ⇉-[]) -- Hereditary substitutions in well-formed kinds of a variable by its -- η-expansion vanish. kd-[]-η-var : ∀ {n} {Γ : Ctx n} {j l} → Γ ⊢ j kd → kd j ∷ Γ ⊢ l kd → let j′ = weakenKind′ j l′ = l Kind′/Var VarSubst.wk VarSubst.↑ in kd j ∷ Γ ⊢ l′ Kind[ η-exp j′ (var∙ zero) ∈ ⌊ j′ ⌋ ] ≅ l kd-[]-η-var j-kd l-kd = let j-kd′ = kd-weaken (wf-kd j-kd) j-kd in TK.kd-[]-η-var j-kd l-kd (⌊⌋-⌊⌋≡ _) (η-exp-Var∈ j-kd′ (⇉-var zero (kd-ctx j-kd′) refl)) open RenamingCommutesNorm -- Completeness of canonical (sub)kinding w.r.t. extended declarative -- (sub)kinding module CompletenessExtended where mutual complete-wf : ∀ {n} {Γ : E.Ctx n} {a} → Γ E.⊢ a wf → nfCtx Γ ⊢ nfAsc (nfCtx Γ) a wf complete-wf (wf-kd k-kd) = wf-kd (complete-kd k-kd) complete-wf (wf-tp a∈*) = wf-tp (Nf⇇-s-i (complete-Tp∈ a∈*)) complete-ctx : ∀ {n} {Γ : E.Ctx n} → Γ E.ctx → nfCtx Γ ctx complete-ctx E.[] = C.[] complete-ctx (a-wf E.∷ Γ-ctx) = complete-wf a-wf C.∷ complete-ctx Γ-ctx complete-kd : ∀ {n} {Γ : E.Ctx n} {k} → Γ E.⊢ k kd → nfCtx Γ ⊢ nfKind (nfCtx Γ) k kd complete-kd (kd-⋯ a∈* b∈*) = kd-⋯ (Nf⇇-s-i (complete-Tp∈ a∈*)) (Nf⇇-s-i (complete-Tp∈ b∈*)) complete-kd (kd-Π j-kd k-kd) = kd-Π (complete-kd j-kd) (complete-kd k-kd) complete-Tp∈ : ∀ {n} {Γ : E.Ctx n} {a k} → Γ E.⊢Tp a ∈ k → nfCtx Γ ⊢Nf nf (nfCtx Γ) a ⇇ nfKind (nfCtx Γ) k complete-Tp∈ {_} {Γ} (∈-var x Γ-ctx Γ[x]≡kd-k) with C.lookup (nfCtx Γ) x | nfCtx-lookup-kd x Γ Γ[x]≡kd-k complete-Tp∈ {_} {Γ} (∈-var x Γ-ctx Γ[x]≡kd-k) | kd ._ | refl = η-exp-Var∈ (WfCtxOps.lookup-kd x nf-Γ-ctx nf-Γ[x]≡kd-nf-k) (⇉-var x nf-Γ-ctx nf-Γ[x]≡kd-nf-k) where nf-Γ-ctx = complete-ctx Γ-ctx nf-Γ[x]≡kd-nf-k = nfCtx-lookup-kd x Γ Γ[x]≡kd-k complete-Tp∈ (∈-⊥-f Γ-ctx) = Nf⇉-⋯-* (⇉-⊥-f (complete-ctx Γ-ctx)) complete-Tp∈ (∈-⊤-f Γ-ctx) = Nf⇉-⋯-* (⇉-⊤-f (complete-ctx Γ-ctx)) complete-Tp∈ (∈-∀-f k-kd a∈*) = Nf⇇-∀-f (complete-kd k-kd) (complete-Tp∈ a∈*) complete-Tp∈ (∈-→-f a∈* b∈*) = Nf⇇-→-f (complete-Tp∈ a∈*) (complete-Tp∈ b∈*) complete-Tp∈ (∈-Π-i j-kd a∈k k-kd) = Nf⇇-Π-i (complete-kd j-kd) (complete-Tp∈ a∈k) complete-Tp∈ (∈-Π-e {a} {b} a∈Πjk b∈j k-kd k[a]-kd) = Nf⇇-⇑ (Nf⇇-Π-e′ (complete-Tp∈ a∈Πjk) (complete-Tp∈ b∈j)) (≅⇒<∷ (≅-nfKind-[] k-kd b∈j k[a]-kd)) complete-Tp∈ (∈-s-i a∈b⋯c) = let nf-a⇉a⋯a = Nf⇇-s-i (complete-Tp∈ a∈b⋯c) in ⇇-⇑ nf-a⇉a⋯a (<∷-⋯ (<:-reflNf⇉ nf-a⇉a⋯a) (<:-reflNf⇉ nf-a⇉a⋯a)) complete-Tp∈ (∈-⇑ a∈j j<∷k) = Nf⇇-⇑ (complete-Tp∈ a∈j) (complete-<∷ j<∷k) complete-<∷ : ∀ {n} {Γ : E.Ctx n} {j k} → Γ E.⊢ j <∷ k → nfCtx Γ ⊢ nfKind (nfCtx Γ) j <∷ nfKind (nfCtx Γ) k complete-<∷ (<∷-⋯ a₂<:a₁ b₁<:b₂) = <∷-⋯ (complete-<:-⋯ a₂<:a₁) (complete-<:-⋯ b₁<:b₂) complete-<∷ (<∷-Π j₂<∷j₁ k₁<∷k₂ Πj₁k₁-kd) with complete-kd Πj₁k₁-kd ... | kd-Π nf-j₁-kd nf-k₁-kd = let nf-j₂<∷j₁ = complete-<∷ j₂<∷j₁ nf-k₁′<∷k₂ = complete-<∷ k₁<∷k₂ ⌊nf-j₁∷Γ⌋≡⌊nf-j₂∷Γ⌋ = cong (λ k → kd k ∷ _) (sym (<∷-⌊⌋ nf-j₂<∷j₁)) nf-k₁≋k₁′ = ≋-nfKind ⌊nf-j₁∷Γ⌋≡⌊nf-j₂∷Γ⌋ _ nf-j₂-kd = proj₁ (<∷-valid nf-j₂<∷j₁) nf-k₁′-kd = proj₁ (<∷-valid nf-k₁′<∷k₂) nf-k₁<∷k₁′ = ≋-<∷ (⇓-kd nf-j₂-kd nf-j₂<∷j₁ nf-k₁-kd) nf-k₁′-kd nf-k₁≋k₁′ nf-k₁<∷k₂ = <∷-trans nf-k₁<∷k₁′ nf-k₁′<∷k₂ in <∷-Π nf-j₂<∷j₁ nf-k₁<∷k₂ (kd-Π nf-j₁-kd nf-k₁-kd) complete-<:-⋯ : ∀ {n} {Γ : E.Ctx n} {a b c d} → Γ E.⊢ a <: b ∈ c ⋯ d → nfCtx Γ ⊢ nf (nfCtx Γ) a <: nf (nfCtx Γ) b complete-<:-⋯ a<:b∈c⋯d with complete-<: a<:b∈c⋯d complete-<:-⋯ a<:b∈c⋯d | <:-⇇ _ _ a<:b = a<:b complete-<: : ∀ {n} {Γ : E.Ctx n} {a b k} → Γ E.⊢ a <: b ∈ k → nfCtx Γ ⊢ nf (nfCtx Γ) a <: nf (nfCtx Γ) b ⇇ nfKind (nfCtx Γ) k complete-<: (<:-refl a∈k) = let nf-a∈k = complete-Tp∈ a∈k in <:⇇-reflNf⇇ nf-a∈k (Nf⇇-valid nf-a∈k) complete-<: (<:-trans a<:b b<:c) = <:⇇-trans (complete-<: a<:b) (complete-<: b<:c) complete-<: (<:-β₁ a∈k b∈j a[b]∈k[b] k-kd k[b]-kd) = ≃⇒<: (≃-β-nf a∈k b∈j k-kd a[b]∈k[b] k[b]-kd) complete-<: (<:-β₂ a∈k b∈j a[b]∈k[b] k-kd k[b]-kd) = ≃⇒<: (≃-sym (≃-β-nf a∈k b∈j k-kd a[b]∈k[b] k[b]-kd)) complete-<: (<:-η₁ a∈Πjk) = ≃⇒<: (≃-η-nf a∈Πjk) complete-<: (<:-η₂ a∈Πjk) = ≃⇒<: (≃-sym (≃-η-nf a∈Πjk)) complete-<: (<:-⊥ a∈b⋯c) = <:-⋯-* (<:-⊥ (Nf⇇-s-i (complete-Tp∈ a∈b⋯c))) complete-<: (<:-⊤ a∈b⋯c) = <:-⋯-* (<:-⊤ (Nf⇇-s-i (complete-Tp∈ a∈b⋯c))) complete-<: (<:-∀ {a₁ = a₁} k₂<∷k₁ a₁<:a₂ Πk₁a₁∈*) with complete-Tp∈ Πk₁a₁∈* ... | (⇇-⇑ (⇉-∀-f nf-k₁-kd nf-a₁⇉a₁⋯a₁) _) = let nf-k₂<∷k₁ = complete-<∷ k₂<∷k₁ nf-a₁′<:a₂ = complete-<:-⋯ a₁<:a₂ ⌊nf-k₁∷Γ⌋≡⌊nf-k₂∷Γ⌋ = cong (λ k → kd k ∷ _) (sym (<∷-⌊⌋ nf-k₂<∷k₁)) nf-a₁≈a₁′ = ≈-nf ⌊nf-k₁∷Γ⌋≡⌊nf-k₂∷Γ⌋ a₁ nf-k₂-kd = proj₁ (<∷-valid nf-k₂<∷k₁) nf-a₁⇉a₁⋯a₁′ = proj₁ (<:-valid nf-a₁′<:a₂) nf-a₁<:a₁′ = ≈-<: (⇓-Nf⇉ nf-k₂-kd nf-k₂<∷k₁ nf-a₁⇉a₁⋯a₁) nf-a₁⇉a₁⋯a₁′ nf-a₁≈a₁′ nf-a₁<:a₂ = <:-trans nf-a₁<:a₁′ nf-a₁′<:a₂ in <:-⋯-* (<:-∀ nf-k₂<∷k₁ nf-a₁<:a₂ (⇉-∀-f nf-k₁-kd nf-a₁⇉a₁⋯a₁)) ... | (⇇-⇑ (⇉-s-i ()) _) complete-<: (<:-→ a₂<:a₁ b₁<:b₂) = <:-⋯-* (<:-→ (complete-<:-⋯ a₂<:a₁) (complete-<:-⋯ b₁<:b₂)) complete-<: (<:-λ {a₁ = a₁} {a₂} a₁<:a₂∈k Λj₁a₁∈Πjk Λj₂a₂∈Πjk) with complete-Tp∈ Λj₁a₁∈Πjk | complete-Tp∈ Λj₂a₂∈Πjk ... | ⇇-⇑ (⇉-Π-i nf-j₁-kd nf-a₁⇉k₁) (<∷-Π nf-j<∷j₁ nf-k₁<∷k Πj₁k₁-kd) | ⇇-⇑ (⇉-Π-i nf-j₂-kd nf-a₂⇉k₂) (<∷-Π nf-j<∷j₂ nf-k₂<∷k Πj₂k₂-kd) = let nf-a₁′<:a₂′⇇k = complete-<: a₁<:a₂∈k nf-a₁′⇇k , nf-a₂′⇇k = <:⇇-valid nf-a₁′<:a₂′⇇k j-kd = proj₁ (<∷-valid nf-j<∷j₁) k-kd = proj₂ (<∷-valid nf-k₁<∷k) ⌊nf-j₁∷Γ⌋≡⌊nf-j∷Γ⌋ = cong (λ k → kd k ∷ _) (sym (<∷-⌊⌋ nf-j<∷j₁)) ⌊nf-j∷Γ⌋≡⌊nf-j₂∷Γ⌋ = cong (λ k → kd k ∷ _) (<∷-⌊⌋ nf-j<∷j₂) nf-a₁≈a₁′ = ≈-nf ⌊nf-j₁∷Γ⌋≡⌊nf-j∷Γ⌋ a₁ nf-a₂′≈a₂ = ≈-nf ⌊nf-j∷Γ⌋≡⌊nf-j₂∷Γ⌋ a₂ nf-a₁<:a₁′⇇k = ≈-<:⇇ k-kd (⇇-⇑ (⇓-Nf⇉ j-kd nf-j<∷j₁ nf-a₁⇉k₁) nf-k₁<∷k) nf-a₁′⇇k nf-a₁≈a₁′ nf-a₂′<:a₂⇇k = ≈-<:⇇ k-kd nf-a₂′⇇k (⇇-⇑ (⇓-Nf⇉ j-kd nf-j<∷j₂ nf-a₂⇉k₂) nf-k₂<∷k) nf-a₂′≈a₂ nf-a₁<:a₂⇇k = <:⇇-trans (<:⇇-trans nf-a₁<:a₁′⇇k nf-a₁′<:a₂′⇇k) nf-a₂′<:a₂⇇k in <:-λ nf-a₁<:a₂⇇k (⇇-⇑ (⇉-Π-i nf-j₁-kd nf-a₁⇉k₁) (<∷-Π nf-j<∷j₁ nf-k₁<∷k Πj₁k₁-kd)) (⇇-⇑ (⇉-Π-i nf-j₂-kd nf-a₂⇉k₂) (<∷-Π nf-j<∷j₂ nf-k₂<∷k Πj₂k₂-kd)) ... | ⇇-⇑ (⇉-Π-i _ _) _ | ⇇-⇑ (⇉-s-i ()) _ ... | ⇇-⇑ (⇉-s-i ()) _ | _ complete-<: (<:-· {a₁} {a₂} {b₁} {b₂} a₁<:a₂∈Πjk b₁≃b₂∈j b₁∈j k-kd k[b₁]-kd) = let nf-a₁<:a₂⇇Πjk = complete-<: a₁<:a₂∈Πjk nf-a₁⇇Πjk , nf-a₂⇇Πjk = <:⇇-valid nf-a₁<:a₂⇇Πjk in <:⇇-⇑ (<:-↓⌜·⌝ nf-a₁<:a₂⇇Πjk (complete-≃ b₁≃b₂∈j)) (≅⇒<∷ (≅-nfKind-[] k-kd b₁∈j k[b₁]-kd)) (complete-kd k[b₁]-kd) complete-<: (<:-⟨| a∈b⋯c) = <:-⋯-* (<:-⟨|-Nf⇇ (complete-Tp∈ a∈b⋯c)) complete-<: (<:-|⟩ a∈b⋯c) = <:-⋯-* (<:-|⟩-Nf⇇ (complete-Tp∈ a∈b⋯c)) complete-<: (<:-⋯-i a<:b) = <:⇇-⋯-i (complete-<: a<:b) complete-<: (<:-⇑ a<:b∈j j<∷k) = let nf-j<∷k = complete-<∷ j<∷k in <:⇇-⇑ (complete-<: a<:b∈j) nf-j<∷k (proj₂ (<∷-valid nf-j<∷k)) complete-≅ : ∀ {n} {Γ : E.Ctx n} {j k} → Γ E.⊢ j ≅ k → nfCtx Γ ⊢ nfKind (nfCtx Γ) j ≅ nfKind (nfCtx Γ) k complete-≅ (<∷-antisym j<∷k k<∷j) = let nf-j<∷k = complete-<∷ j<∷k nf-j-kd , nf-k-kd = <∷-valid nf-j<∷k in <∷-antisym nf-j-kd nf-k-kd nf-j<∷k (complete-<∷ k<∷j) complete-≃ : ∀ {n} {Γ : E.Ctx n} {a b k} → Γ E.⊢ a ≃ b ∈ k → nfCtx Γ ⊢ nf (nfCtx Γ) a ≃ nf (nfCtx Γ) b ⇇ nfKind (nfCtx Γ) k complete-≃ (<:-antisym a<:b∈k b<:a∈k) = let nf-a<:b⇇k = complete-<: a<:b∈k in <:-antisym (<:⇇-valid-kd nf-a<:b⇇k) nf-a<:b⇇k (complete-<: b<:a∈k) -- η-expansion of normal forms is admissible in canonical kinding. ≃-η-nf : ∀ {n} {Γ : E.Ctx n} {a j k} → Γ E.⊢Tp a ∈ Π j k → nfCtx Γ ⊢ nf (nfCtx Γ) (Λ j (weaken a · var zero)) ≃ nf (nfCtx Γ) a ⇇ nfKind (nfCtx Γ) (Π j k) ≃-η-nf a∈Πjk with complete-Tp∈ a∈Πjk ≃-η-nf {_} {Γ} {a} {j} a∈Πjk | nf-a⇇Πjk with Nf⇇-valid nf-a⇇Πjk ... | (kd-Π nf-j-kd nf-k-kd) = let nf-Γ = nfCtx Γ nf-j = nfKind nf-Γ j nf-j-wf = wf-kd nf-j-kd nf-j-kd′ = kd-weaken nf-j-wf nf-j-kd nf-a⇇Πjk′ = subst (kd nf-j ∷ nf-Γ ⊢Nf_⇇ _) (nf-weaken (kd nf-j) a) (Nf⇇-weaken nf-j-wf nf-a⇇Πjk) η-z⇇j′ = η-exp-Var∈ nf-j-kd′ (⇉-var zero (kd-ctx nf-j-kd′) refl) nf-a·z⇇k[z] = Nf⇇-Π-e′ nf-a⇇Πjk′ η-z⇇j′ nf-a·z⇇k = Nf⇇-⇑ nf-a·z⇇k[z] (≅⇒<∷ (kd-[]-η-var nf-j-kd nf-k-kd)) in ≈-≃ (kd-Π nf-j-kd nf-k-kd) (Nf⇇-Π-i nf-j-kd nf-a·z⇇k) nf-a⇇Πjk (≈-η-nf a∈Πjk) -- Substitution in well-formed kinds commutes with normalization. ≅-nfKind-[] : ∀ {n} {Γ : E.Ctx n} {a j k} → kd k ∷ Γ E.⊢ j kd → Γ E.⊢Tp a ∈ k → Γ E.⊢ j Kind[ a ] kd → nfCtx Γ ⊢ (nfKind (nfCtx (kd k ∷ Γ)) j) Kind[ nf (nfCtx Γ) a ∈ ⌊ nfKind (nfCtx Γ) k ⌋ ] ≅ nfKind (nfCtx Γ) (j Kind[ a ]) ≅-nfKind-[] {_} {Γ} {a} {j} {k} j-kd a∈k j[a]-kd = let nf-Γ = nfCtx Γ nf-k = nfKind nf-Γ k nf-a = nf nf-Γ a nf-k∷Γ = kd nf-k ∷ nf-Γ nf-j = nfKind (nf-k∷Γ) j ⌊k⌋≡⌊nf-k⌋ = sym (⌊⌋-nf {_} {nf-Γ} k) nf-j-kd = complete-kd j-kd nf-a⇇k = complete-Tp∈ a∈k nf-j[a]-kd = complete-kd j[a]-kd nf-j[a∈⌊k⌋]-kd = kd-[] nf-j-kd nf-a⇇k nf-j[a∈⌊k⌋]≋j[a] = subst (λ l → nf-j Kind[ nf-a ∈ l ] ≋ _) ⌊k⌋≡⌊nf-k⌋ (≋-sym (nfKind-[] j-kd a∈k)) in ≋-≅ nf-j[a∈⌊k⌋]-kd nf-j[a]-kd nf-j[a∈⌊k⌋]≋j[a] -- β-reduction of normal forms is admissible in canonical kinding. ≃-β-nf : ∀ {n} {Γ : E.Ctx n} {a b j k} → kd j ∷ Γ E.⊢Tp a ∈ k → Γ E.⊢Tp b ∈ j → kd j ∷ Γ E.⊢ k kd → Γ E.⊢Tp a [ b ] ∈ k Kind[ b ] → Γ E.⊢ k Kind[ b ] kd → nfCtx Γ ⊢ nf (nfCtx Γ) ((Λ j a) · b) ≃ nf (nfCtx Γ) (a [ b ]) ⇇ nfKind (nfCtx Γ) (k Kind[ b ]) ≃-β-nf {_} {Γ} {a} {b} {j} {k} a∈k b∈j k-kd a[b]∈k[b] k[b]-kd = let nf-Γ = nfCtx Γ nf-j = nfKind nf-Γ j nf-b = nf nf-Γ b nf-j∷Γ = kd nf-j ∷ nf-Γ nf-a = nf (nf-j∷Γ) a ⌊j⌋≡⌊nf-j⌋ = sym (⌊⌋-nf {_} {nf-Γ} j) nf-a⇇k = complete-Tp∈ a∈k nf-b⇇j = complete-Tp∈ b∈j nf-a[b]⇇k[b] = complete-Tp∈ a[b]∈k[b] nf-k[b]-kd = complete-kd k[b]-kd nf-a[b∈⌊j⌋]⇇k[b∈⌊j⌋] = Nf⇇-[] nf-a⇇k nf-b⇇j nf-k[b∈⌊j⌋]<∷k[b] = ≅⇒<∷ (≅-nfKind-[] k-kd b∈j k[b]-kd) nf-a[b∈⌊j⌋]⇇k[b] = Nf⇇-⇑ nf-a[b∈⌊j⌋]⇇k[b∈⌊j⌋] nf-k[b∈⌊j⌋]<∷k[b] nf-a[b∈⌊j⌋]≈a[b] = subst (λ l → nf-a [ nf-b ∈ l ] ≈ _) ⌊j⌋≡⌊nf-j⌋ (≈-sym (nf-[] a∈k b∈j)) in ≈-≃ nf-k[b]-kd nf-a[b∈⌊j⌋]⇇k[b] nf-a[b]⇇k[b] nf-a[b∈⌊j⌋]≈a[b] -- Completeness of canonical subkinding and subtyping -- w.r.t. declarative subkinding and subtyping complete-<:-⋯ : ∀ {n} {Γ : E.Ctx n} {a b c d} → Γ O.⊢ a <: b ∈ c ⋯ d → nfCtx Γ ⊢ nf (nfCtx Γ) a <: nf (nfCtx Γ) b complete-<:-⋯ = CompletenessExtended.complete-<:-⋯ ∘ E.complete-<: complete-<: : ∀ {n} {Γ : E.Ctx n} {a b k} → Γ O.⊢ a <: b ∈ k → nfCtx Γ ⊢ nf (nfCtx Γ) a <: nf (nfCtx Γ) b ⇇ nfKind (nfCtx Γ) k complete-<: = CompletenessExtended.complete-<: ∘ E.complete-<: complete-<∷ : ∀ {n} {Γ : E.Ctx n} {j k} → Γ O.⊢ j <∷ k → nfCtx Γ ⊢ nfKind (nfCtx Γ) j <∷ nfKind (nfCtx Γ) k complete-<∷ = CompletenessExtended.complete-<∷ ∘ E.complete-<∷
{ "alphanum_fraction": 0.4527256183, "avg_line_length": 45.9657794677, "ext": "agda", "hexsha": "8b92a9abd738adc9212e8f429c20ede9ff547d08", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-05-14T10:25:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-05-13T22:29:48.000Z", "max_forks_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Blaisorblade/f-omega-int-agda", "max_forks_repo_path": "src/FOmegaInt/Kinding/Canonical/Equivalence.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_issues_repo_issues_event_max_datetime": "2021-05-14T08:54:39.000Z", "max_issues_repo_issues_event_min_datetime": "2021-05-14T08:09:40.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Blaisorblade/f-omega-int-agda", "max_issues_repo_path": "src/FOmegaInt/Kinding/Canonical/Equivalence.agda", "max_line_length": 81, "max_stars_count": 12, "max_stars_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Blaisorblade/f-omega-int-agda", "max_stars_repo_path": "src/FOmegaInt/Kinding/Canonical/Equivalence.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-27T05:53:06.000Z", "max_stars_repo_stars_event_min_datetime": "2017-06-13T16:05:35.000Z", "num_tokens": 13382, "size": 24178 }
module Prelude where open import Data.Unit using (⊤) public open import Data.Empty using (⊥) public open import Function using (id; const; flip) public open import Data.Sum using (_⊎_; inj₁; inj₂) public open import Data.Product using (Σ; proj₁; proj₂; _,_; _×_) public open import Data.Maybe using (Maybe; nothing; just) public open import Data.Nat using (ℕ; _+_; zero; suc) public open import Data.Fin using (Fin; zero; suc; toℕ; fromℕ) public open import Data.Vec using (Vec; _∷_; []) public open import Data.String using (String) public open import Data.Float using (Float) renaming (show to primShowFloat) public open import Agda.Builtin.Float variable S T A B C D S' T' A' B' : Set -- redefine Bool to avoid COMPILE JS pragma on std-lib's Bool data Bool : Set where false true : Bool not : Bool → Bool not true = false not false = true if_then_else_ : Bool → A → A → A if true then a else b = a if false then a else b = b _==_ : Bool → Bool → Bool true == false = false true == true = true false == false = true false == true = false maybe : B → (A → B) → Maybe A → B maybe b f nothing = b maybe b f (just x) = f x mapMaybe : (A → B) → Maybe A → Maybe B mapMaybe f = maybe nothing λ a → just (f a) data _⊍_ (A B : Set) : Set where inj₁ : A → A ⊍ B inj₂ : B → A ⊍ B both : A → B → A ⊍ B variable n : ℕ postulate showNat : ℕ → String primStringAppend : String → String → String primParseFloat : String → Float isNaN : Float → Bool {-# COMPILE JS showNat = a=>JSON.stringify(a) #-} {-# COMPILE JS primStringAppend = a=>b=>a+b #-} {-# COMPILE JS primParseFloat = a=>Number(a) #-} {-# COMPILE JS isNaN = a=>b=>b[isNaN(a)?1:0]() #-} Iso = λ (S T A B : Set) → (S → A) × (B → T) Lens = λ (S T A B : Set) → S → A × (B → T) Prism = λ (S T A B : Set) → (S → A ⊎ T) × (B → T) plusIso : Float → Iso Float Float Float Float plusIso x = primFloatPlus x , λ y → primFloatMinus y x mulIso : Float → Iso Float Float Float Float mulIso x = primFloatTimes x , λ y → primFloatDiv y x prismToLens : Prism S T A B → Lens (Maybe S) (Maybe T) (Maybe A) (Maybe B) prismToLens (p1 , p2) nothing = nothing , mapMaybe p2 prismToLens (p1 , p2) (just s) with p1 s ... | inj₁ a = just a , mapMaybe p2 ... | inj₂ t = nothing , const (just t) floatPrism : Prism String (Maybe String) Float Float floatPrism = parse , (λ x → just (primShowFloat x)) where parse : String → _ parse s = if isNaN p then inj₂ nothing else inj₁ p where p = primParseFloat s
{ "alphanum_fraction": 0.6338194718, "avg_line_length": 29.8470588235, "ext": "agda", "hexsha": "fe5041048c58bdbd19c815a0cb88fb6cf9ec36e8", "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": "ac7e1758c86b48ff5d38797b61078b3085a4389d", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "divipp/frp_agda", "max_forks_repo_path": "Prelude.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ac7e1758c86b48ff5d38797b61078b3085a4389d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "divipp/frp_agda", "max_issues_repo_path": "Prelude.agda", "max_line_length": 76, "max_stars_count": 21, "max_stars_repo_head_hexsha": "ac7e1758c86b48ff5d38797b61078b3085a4389d", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "divipp/frp_agda", "max_stars_repo_path": "Prelude.agda", "max_stars_repo_stars_event_max_datetime": "2020-11-28T05:32:32.000Z", "max_stars_repo_stars_event_min_datetime": "2018-11-08T08:51:59.000Z", "num_tokens": 837, "size": 2537 }
open import AEff open import EffectAnnotations open import Types hiding (``) open import Relation.Binary.PropositionalEquality hiding ([_] ; Extensionality) module Renamings where -- SET OF RENAMINGS BETWEEN CONTEXTS data Ren : Ctx → Ctx → Set where ⟨_,_⟩ : {Γ Γ' : Ctx} {X : VType} → Ren Γ Γ' → X ∈ Γ' → -------------------------- Ren (Γ ∷ X) Γ' ε : {Γ' : Ctx} → ------------ Ren [] Γ' π : {Γ Γ' : Ctx} {X : VType} → Ren Γ Γ' → -------------------------- Ren Γ (Γ' ∷ X) φ : {Γ Γ' : Ctx} → Ren Γ Γ' → ---------------- Ren (Γ ■) (Γ' ■) -- RENAMING VARIABLES ren-var : {Γ Γ' : Ctx} {X : VType} → Ren Γ Γ' → X ∈ Γ → -------------------------- X ∈ Γ' ren-var ⟨ f , x ⟩ Hd = x ren-var (π f) Hd = Tl-v (ren-var f Hd) ren-var ⟨ f , y ⟩ (Tl-v x) = ren-var f x ren-var (π f) (Tl-v x) = Tl-v (ren-var f (Tl-v x)) ren-var (π f) (Tl-■ p x) = Tl-v (ren-var f (Tl-■ p x)) ren-var (φ f) (Tl-■ p x) = Tl-■ p (ren-var f x) -- IDENTITY RENAMING ren-id : {Γ : Ctx} → ----------- Ren Γ Γ ren-id {[]} = ε ren-id {Γ ∷ X} = ⟨ π ren-id , Hd ⟩ ren-id {Γ ■} = φ ren-id -- EXCHANGE RENAMING ren-exch : {Γ : Ctx} {X Y : VType} → --------------------------- Ren (Γ ∷ X ∷ Y) (Γ ∷ Y ∷ X) ren-exch {Γ} = ⟨ ⟨ π (π ren-id) , Hd ⟩ , Tl-v Hd ⟩ -- COMPOSITION OF RENAMINGS ren-comp : {Γ Γ' Γ'' : Ctx} → Ren Γ' Γ'' → Ren Γ Γ' → ------------------ Ren Γ Γ'' ren-comp g ⟨ f , x ⟩ = ⟨ ren-comp g f , ren-var g x ⟩ ren-comp g ε = ε ren-comp ⟨ g , x ⟩ (π f) = ren-comp g f ren-comp (π g) (π f) = π (ren-comp g (π f)) ren-comp (π g) (φ f) = π (ren-comp g (φ f)) ren-comp (φ g) (φ f) = φ (ren-comp g f) -- WEAKENING OF RENAMINGS ren-wk : {Γ : Ctx} {X : VType} → ----------------------- Ren Γ (Γ ∷ X) ren-wk = π ren-id -- CONGRUENCE OF RENAMINGS ren-cong : {Γ Γ' : Ctx} {X : VType} → Ren Γ Γ' → -------------------------- Ren (Γ ∷ X) (Γ' ∷ X) ren-cong f = ⟨ π f , Hd ⟩ -- ACTION OF RENAMING ON WELL-TYPED VALUES AND COMPUTATIONS mutual V-rename : {X : VType} {Γ Γ' : Ctx} → Ren Γ Γ' → Γ ⊢V⦂ X → -------------------------- Γ' ⊢V⦂ X V-rename f (` x) = ` ren-var f x V-rename f (´ c) = ´ c V-rename f ⋆ = ⋆ V-rename f (ƛ M) = ƛ (C-rename (ren-cong f) M) V-rename f ⟨ V ⟩ = ⟨ V-rename f V ⟩ V-rename f (□ V) = □ (V-rename (φ f) V) C-rename : {C : CType} {Γ Γ' : Ctx} → Ren Γ Γ' → Γ ⊢C⦂ C → -------------------------- Γ' ⊢C⦂ C C-rename f (return V) = return (V-rename f V) C-rename f (let= M `in N) = let= C-rename f M `in C-rename (ren-cong f) N C-rename f (V · W) = V-rename f V · V-rename f W C-rename f (↑ op p V M) = ↑ op p (V-rename f V) (C-rename f M) C-rename f (↓ op V M) = ↓ op (V-rename f V) (C-rename f M) C-rename f (promise op ∣ p ↦ M `in N) = promise op ∣ p ↦ C-rename (ren-cong (ren-cong f)) M `in C-rename (ren-cong f) N C-rename f (await V until M) = await (V-rename f V) until (C-rename (ren-cong f) M) C-rename f (unbox V `in M) = unbox (V-rename f V) `in (C-rename (ren-cong f) M) C-rename f (spawn M N) = spawn (C-rename (φ f) M) (C-rename f N) C-rename f (coerce p q M) = coerce p q (C-rename f M) -- ACTION OF RENAMING ON WELL-TYPED PROCESSES P-rename : {o : O} {PP : PType o} {Γ Γ' : Ctx} → Ren Γ Γ' → Γ ⊢P⦂ PP → Γ' ⊢P⦂ PP P-rename f (run M) = run (C-rename f M) P-rename f (P ∥ Q) = P-rename f P ∥ P-rename f Q P-rename f (↑ op p V P) = ↑ op p (V-rename f V) (P-rename f P) P-rename f (↓ op V P) = ↓ op (V-rename f V) (P-rename f P)
{ "alphanum_fraction": 0.4203007519, "avg_line_length": 21.6847826087, "ext": "agda", "hexsha": "c07cc60140111d67162f82791b5cb797b3da16ee", "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": "b41df71f4456666aab4bd14e13d285c31af80ff6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "danelahman/modal-aeff-agda", "max_forks_repo_path": "Renamings.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b41df71f4456666aab4bd14e13d285c31af80ff6", "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": "danelahman/modal-aeff-agda", "max_issues_repo_path": "Renamings.agda", "max_line_length": 83, "max_stars_count": 2, "max_stars_repo_head_hexsha": "b41df71f4456666aab4bd14e13d285c31af80ff6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "danelahman/higher-order-aeff-agda", "max_stars_repo_path": "Renamings.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T18:50:26.000Z", "max_stars_repo_stars_event_min_datetime": "2021-08-17T15:00:34.000Z", "num_tokens": 1565, "size": 3990 }
{-# OPTIONS --rewriting --without-K #-} open import Agda.Primitive open import Prelude open import GSeTT.Syntax {- Typing Rules and basic syntactic properties for the type theory for globular sets -} module GSeTT.Rules where {- Well-formedness statements ≡ inference rules -} data _⊢C : Pre-Ctx → Set₁ data _⊢T_ : Pre-Ctx → Pre-Ty → Set₁ data _⊢t_#_ : Pre-Ctx → Pre-Tm → Pre-Ty → Set₁ data _⊢S_>_ : Pre-Ctx → Pre-Sub → Pre-Ctx → Set₁ data _⊢C where ec : nil ⊢C cc : ∀ {Γ x A} → Γ ⊢C → Γ ⊢T A → x == length Γ → (Γ :: (x , A)) ⊢C data _⊢T_ where ob : ∀ {Γ} → Γ ⊢C → Γ ⊢T ∗ ar : ∀ {Γ A t u} → Γ ⊢t t # A → Γ ⊢t u # A → Γ ⊢T ⇒ A t u data _⊢t_#_ where var : ∀ {Γ x A} → Γ ⊢C → x # A ∈ Γ → Γ ⊢t (Var x) # A data _⊢S_>_ where es : ∀ {Δ} → Δ ⊢C → Δ ⊢S nil > nil sc : ∀ {Δ Γ γ x y A t} → Δ ⊢S γ > Γ → (Γ :: (x , A)) ⊢C → (Δ ⊢t t # (A [ γ ]Pre-Ty)) → x == y → Δ ⊢S (γ :: (y , t)) > (Γ :: (x , A)) {- Weakening admissibility -} wkT : ∀ {Γ A y B} → Γ ⊢T A → (Γ :: (y , B)) ⊢C → (Γ :: (y , B)) ⊢T A wkt : ∀ {Γ A t y B} → Γ ⊢t t # A → (Γ :: (y , B)) ⊢C → (Γ :: (y , B)) ⊢t t # A wkT (ob _) Γ,y:B⊢ = ob Γ,y:B⊢ wkT (ar Γ⊢t:A Γ⊢u:A) Γ,y:B⊢ = ar (wkt Γ⊢t:A Γ,y:B⊢) (wkt Γ⊢u:A Γ,y:B⊢) wkt (var Γ⊢C x∈Γ) Γ,y:B⊢ = var Γ,y:B⊢ (inl x∈Γ) wkS : ∀ {Δ Γ γ y B} → Δ ⊢S γ > Γ → (Δ :: (y , B)) ⊢C → (Δ :: (y , B)) ⊢S γ > Γ wkS (es _) Δ,y:B⊢ = es Δ,y:B⊢ wkS (sc Δ⊢γ:Γ Γ,x:A⊢ Δ⊢t:A[γ] idp) Δ,y:B⊢ = sc (wkS Δ⊢γ:Γ Δ,y:B⊢) Γ,x:A⊢ (wkt Δ⊢t:A[γ] Δ,y:B⊢) idp {- Consistency : all objects appearing in derivable judgments are derivable -} Γ⊢A→Γ⊢ : ∀ {Γ A} → Γ ⊢T A → Γ ⊢C Γ⊢t:A→Γ⊢ : ∀ {Γ A t} → Γ ⊢t t # A → Γ ⊢C Γ⊢A→Γ⊢ (ob Γ⊢) = Γ⊢ Γ⊢A→Γ⊢ (ar Γ⊢t:A Γ⊢u:A) = Γ⊢t:A→Γ⊢ Γ⊢t:A Γ⊢t:A→Γ⊢ (var Γ⊢ _) = Γ⊢ Δ⊢γ:Γ→Γ⊢ : ∀ {Δ Γ γ} → Δ ⊢S γ > Γ → Γ ⊢C Δ⊢γ:Γ→Γ⊢ (es Δ⊢) = ec Δ⊢γ:Γ→Γ⊢ (sc Δ⊢γ:Γ Γ,x:A⊢ Δ⊢t:A[γ] idp) = Γ,x:A⊢ Δ⊢γ:Γ→Δ⊢ : ∀ {Δ Γ γ} → Δ ⊢S γ > Γ → Δ ⊢C Δ⊢γ:Γ→Δ⊢ (es Δ⊢) = Δ⊢ Δ⊢γ:Γ→Δ⊢ (sc Δ⊢γ:Γ Γ,x:A⊢ Δ⊢t:A[γ] idp) = Δ⊢γ:Γ→Δ⊢ Δ⊢γ:Γ Γ,x:A⊢→Γ,x:A⊢A : ∀ {Γ x A} → (Γ :: (x , A)) ⊢C → (Γ :: (x , A)) ⊢T A Γ,x:A⊢→Γ,x:A⊢A Γ,x:A⊢@(cc Γ⊢ Γ⊢A idp) = wkT Γ⊢A Γ,x:A⊢ Γ,x:A⊢→Γ,x:A⊢x:A : ∀ {Γ x A} → (Γ :: (x , A)) ⊢C → (Γ :: (x , A)) ⊢t (Var x) # A Γ,x:A⊢→Γ,x:A⊢x:A Γ,x:A⊢ = var Γ,x:A⊢ (inr (idp , idp)) Γ,x:A⊢→Γ⊢ : ∀ {Γ x A} → (Γ :: (x , A)) ⊢C → Γ ⊢C Γ,x:A⊢→Γ⊢ (cc Γ⊢ _ _) = Γ⊢ Γ⊢t:A→Γ⊢A : ∀ {Γ A t} → Γ ⊢t t # A → Γ ⊢T A Γ⊢t:A→Γ⊢A (var Γ,x:A⊢@(cc Γ⊢ Γ⊢A idp) (inl y∈Γ)) = wkT (Γ⊢t:A→Γ⊢A (var Γ⊢ y∈Γ)) Γ,x:A⊢ Γ⊢t:A→Γ⊢A (var Γ,x:A⊢@(cc _ _ idp) (inr (idp , idp))) = Γ,x:A⊢→Γ,x:A⊢A Γ,x:A⊢ Γ⊢src : ∀ {Γ A t u} → Γ ⊢T ⇒ A t u → Γ ⊢t t # A Γ⊢src (ar Γ⊢t Γ⊢u) = Γ⊢t Γ⊢tgt : ∀ {Γ A t u} → Γ ⊢T ⇒ A t u → Γ ⊢t u # A Γ⊢tgt (ar Γ⊢t Γ⊢u) = Γ⊢u {- Cut-admissibility -} -- notational shortcut : if A = B a term of type A is also of type B trT : ∀ {Γ A B t} → A == B → Γ ⊢t t # A → Γ ⊢t t # B trT idp Γ⊢t:A = Γ⊢t:A n∉Γ : ∀ {Γ A n} → Γ ⊢C → (length Γ ≤ n) → ¬ (n # A ∈ Γ) n∉Γ (cc Γ⊢ _ _) l+1≤n (inl n∈Γ) = n∉Γ Γ⊢ (Sn≤m→n≤m l+1≤n) n∈Γ n∉Γ (cc Γ⊢ _ idp) Sn≤n (inr (idp , idp)) = Sn≰n _ Sn≤n lΓ∉Γ : ∀ {Γ A} → Γ ⊢C → ¬ ((length Γ) # A ∈ Γ) lΓ∉Γ Γ⊢ = n∉Γ Γ⊢ (n≤n _) Γ+⊢l : ∀ {Γ x A} → (Γ :: (x , A)) ⊢C → x == length Γ Γ+⊢l (cc _ _ idp) = idp {- action on weakened types and terms -} wk[]T : ∀ {Γ Δ γ x u A B} → Γ ⊢T A → Δ ⊢S (γ :: (x , u)) > (Γ :: (x , B)) → (A [ (γ :: (x , u)) ]Pre-Ty) == (A [ γ ]Pre-Ty) wk[]t : ∀ {Γ Δ γ x u A t B} → Γ ⊢t t # A → Δ ⊢S (γ :: (x , u)) > (Γ :: (x , B)) → (t [ (γ :: (x , u)) ]Pre-Tm) == (t [ γ ]Pre-Tm) wk[]T (ob Γ⊢) _ = idp wk[]T (ar Γ⊢t:A Γ⊢u:A) Δ⊢γ+:Γ+ = ⇒= (wk[]T (Γ⊢t:A→Γ⊢A Γ⊢t:A) Δ⊢γ+:Γ+) (wk[]t Γ⊢t:A Δ⊢γ+:Γ+) (wk[]t Γ⊢u:A Δ⊢γ+:Γ+) wk[]t {x = x} (var {x = y} Γ⊢ y∈Γ) Δ⊢γ+:Γ+ with (eqdecℕ y x) wk[]t {x = x} (var {x = y} Γ⊢ y∈Γ) Δ⊢γ+:Γ+ | inr _ = idp wk[]t (var {Γ = Γ} Γ⊢ x∈Γ) Δ⊢γ+:Γ+ | inl idp = ⊥-elim (lΓ∉Γ Γ⊢ (transport {B = λ n → n # _ ∈ Γ} (Γ+⊢l (Δ⊢γ:Γ→Γ⊢ Δ⊢γ+:Γ+)) x∈Γ)) dim[] : ∀ (A : Pre-Ty) (γ : Pre-Sub) → dim (A [ γ ]Pre-Ty) == dim A dim[] ∗ γ = idp dim[] (⇒ A x x₁) γ = S= (dim[] A γ)
{ "alphanum_fraction": 0.4229064039, "avg_line_length": 37.247706422, "ext": "agda", "hexsha": "1dc933b43e2ab6d8fcd7f4f35c22045a194272d9", "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": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thibautbenjamin/catt-formalization", "max_forks_repo_path": "GSeTT/Rules.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "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": "thibautbenjamin/catt-formalization", "max_issues_repo_path": "GSeTT/Rules.agda", "max_line_length": 136, "max_stars_count": null, "max_stars_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thibautbenjamin/catt-formalization", "max_stars_repo_path": "GSeTT/Rules.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2680, "size": 4060 }
{-# OPTIONS --without-K #-} module common-utilities where open import common lift-≟-1 : ∀ {ℓ ℓ′} {A : Set ℓ} {B : Set ℓ′} → (f : A → B) → {x : A} → {y : A} → Maybe (x ≡ y) → Maybe (f x ≡ f y) lift-≟-1 f (just refl) = just refl lift-≟-1 f nothing = nothing lift-≟-1-refl : ∀ {ℓ ℓ′} {A : Set ℓ} {B : Set ℓ′} f {x} p → p ≡ just refl → lift-≟-1 {ℓ} {ℓ′} {A} {B} f {x} {x} p ≡ just refl lift-≟-1-refl f ._ refl = refl lift-≟-2-helper : ∀ {A : Set} {B : A → Set} {C : Set} {f : (x : A) → B x → C} {x : A} {y y' : B x} → Maybe (y ≡ y') → Maybe (f x y ≡ f x y') lift-≟-2-helper (just refl) = just refl lift-≟-2-helper nothing = nothing lift-≟-2 : ∀ {A} {B : A → Set} {C} → (f : (x : A) → B x → C) → {x x' : A} → {y : B x} → {y' : B x'} → Maybe (x ≡ x') → ((p : x ≡ x') → Maybe (transport B p y ≡ y')) → Maybe (f x y ≡ f x' y') lift-≟-2 {A} {B} {C} f {x} {.x} {y} {y'} (just refl) p = lift-≟-2-helper {A} {B} {C} {f} {x} {y} {y'} (p refl) lift-≟-2 f nothing _ = nothing lift-≟-2-helper-refl : ∀ {A B C f x y p} → p ≡ just refl → lift-≟-2-helper {A} {B} {C} {f} {x} {y} {y} p ≡ just refl lift-≟-2-helper-refl refl = refl lift-≟-2-refl : ∀ {A B C} f {x} {y} p q → p ≡ just refl → q refl ≡ just refl → lift-≟-2 {A} {B} {C} f {x} {x} {y} {y} p q ≡ just refl lift-≟-2-refl {A} {B} {C} f {x} {y} ._ q refl q' = lift-≟-2-helper-refl {A} {B} {C} {f} {x} {y} {q refl} q' lift-≟-3-helper : ∀ {A : Set} {B : A → Set} {C D} → {f : (x : A) → (y : B x) → C x y → D} → {x : A} → {y y' : B x} → {z : C x y} → {z' : C x y'} → Maybe (y ≡ y') → ((q : y ≡ y') → Maybe (transport2 C refl q z ≡ z')) → Maybe (f x y z ≡ f x y' z') lift-≟-3-helper {A} {B} {C} {D} {f} {x} {y} {.y} {z} {z'} (just refl) q = lift-≟-2-helper {B x} {C x} {D} {f x} {y} {z} {z'} (q refl) lift-≟-3-helper nothing q = nothing lift-≟-3 : ∀ {A B C D} → (f : (x : A) → (y : B x) → C x y → D) → {x x' : A} → {y : B x} → {y' : B x'} → {z : C x y} → {z' : C x' y'} → Maybe (x ≡ x') → ((p : x ≡ x') → Maybe (transport B p y ≡ y')) → ((p : x ≡ x') → (q : transport B p y ≡ y') → Maybe (transport2 C p q z ≡ z')) → Maybe (f x y z ≡ f x' y' z') lift-≟-3 {A} {B} {C} {D} f {x} {.x} {y} {y'} {z} {z'} (just refl) q r = lift-≟-3-helper {A} {B} {C} {D} {f} {x} {y} {y'} {z} {z'} (q refl) (r refl) lift-≟-3 f nothing q r = nothing lift-≟-3-helper-refl : ∀ {A B C D f x y z p q} → p ≡ just refl → q refl ≡ just refl → lift-≟-3-helper {A} {B} {C} {D} {f} {x} {y} {y} {z} {z} p q ≡ just refl lift-≟-3-helper-refl {A} {B} {C} {D} {f} {x} {y} {z} {._} {q} refl q' = lift-≟-2-helper-refl {B x} {C x} {D} {f x} {y} {z} {q refl} q' lift-≟-3-refl : ∀ {A B C D} f {x y z} p q r → p ≡ just refl → q refl ≡ just refl → r refl refl ≡ just refl → lift-≟-3 {A} {B} {C} {D} f {x} {x} {y} {y} {z} {z} p q r ≡ just refl lift-≟-3-refl {A} {B} {C} {D} f {x} {y} {z} ._ q r refl q' r' = lift-≟-3-helper-refl {A} {B} {C} {D} {f} {x} {y} {z} {q refl} {r refl} q' r' lift-≟-4-helper : ∀ {A : Set} {B : A → Set} {C : (x : A) → B x → Set} {D : (x : A) → (y : B x) → C x y → Set} {E} → {f : (x : A) → (y : B x) → (z : C x y) → (w : D x y z) → E} → {x : A} → {y y' : B x} → {z : C x y} → {z' : C x y'} → {w : D x y z} → {w' : D x y' z'} → Maybe (y ≡ y') → ((q : y ≡ y') → Maybe (transport2 C refl q z ≡ z')) → ((q : y ≡ y') → (r : transport2 C refl q z ≡ z') → Maybe (transport3 D refl q r w ≡ w')) → Maybe (f x y z w ≡ f x y' z' w') lift-≟-4-helper {A} {B} {C} {D} {E} {f} {x} {y} {.y} {z} {z'} {w} {w'} (just refl) q r = lift-≟-3-helper {B x} {C x} {D x} {E} {f x} {y} {z} {z'} {w} {w'} (q refl) (r refl) lift-≟-4-helper nothing q r = nothing lift-≟-4 : ∀ {A B C D E} → (f : (x : A) → (y : B x) → (z : C x y) → (w : D x y z) → E) → {x x' : A} → {y : B x} → {y' : B x'} → {z : C x y} → {z' : C x' y'} → {w : D x y z} → {w' : D x' y' z'} → Maybe (x ≡ x') → ((p : x ≡ x') → Maybe (transport B p y ≡ y')) → ((p : x ≡ x') → (q : transport B p y ≡ y') → Maybe (transport2 C p q z ≡ z')) → ((p : x ≡ x') → (q : transport B p y ≡ y') → (r : transport2 C p q z ≡ z') → Maybe (transport3 D p q r w ≡ w')) → Maybe (f x y z w ≡ f x' y' z' w') lift-≟-4 {A} {B} {C} {D} {E} f {x} {.x} {y} {y'} {z} {z'} {w} {w'} (just refl) q r s = lift-≟-4-helper {A} {B} {C} {D} {E} {f} {x} {y} {y'} {z} {z'} {w} {w'} (q refl) (r refl) (s refl) lift-≟-4 f nothing q r s = nothing lift-≟-5-helper : ∀ {A : Set} {B : A → Set} {C : (x : A) → B x → Set} {D : (x : A) → (y : B x) → C x y → Set} {E F} → {f : (x : A) → (y : B x) → (z : C x y) → (w : D x y z) → (v : E x y z w) → F} → {x : A} → {y y' : B x} → {z : C x y} → {z' : C x y'} → {w : D x y z} → {w' : D x y' z'} → {v : E x y z w} → {v' : E x y' z' w'} → Maybe (y ≡ y') → ((q : y ≡ y') → Maybe (transport2 C refl q z ≡ z')) → ((q : y ≡ y') → (r : transport2 C refl q z ≡ z') → Maybe (transport3 D refl q r w ≡ w')) → ((q : y ≡ y') → (r : transport2 C refl q z ≡ z') → (s : transport3 D refl q r w ≡ w') → Maybe (transport4 E refl q r s v ≡ v')) → Maybe (f x y z w v ≡ f x y' z' w' v') lift-≟-5-helper {A} {B} {C} {D} {E} {F} {f} {x} {y} {.y} {z} {z'} {w} {w'} {v} {v'} (just refl) q r s = lift-≟-4-helper {B x} {C x} {D x} {E x} {F} {f x} {y} {z} {z'} {w} {w'} {v} {v'} (q refl) (r refl) (s refl) lift-≟-5-helper nothing q r s = nothing lift-≟-5 : ∀ {A B C D E F} → (f : (x : A) → (y : B x) → (z : C x y) → (w : D x y z) → (v : E x y z w) → F) → {x x' : A} → {y : B x} → {y' : B x'} → {z : C x y} → {z' : C x' y'} → {w : D x y z} → {w' : D x' y' z'} → {v : E x y z w} → {v' : E x' y' z' w'} → Maybe (x ≡ x') → ((p : x ≡ x') → Maybe (transport B p y ≡ y')) → ((p : x ≡ x') → (q : transport B p y ≡ y') → Maybe (transport2 C p q z ≡ z')) → ((p : x ≡ x') → (q : transport B p y ≡ y') → (r : transport2 C p q z ≡ z') → Maybe (transport3 D p q r w ≡ w')) → ((p : x ≡ x') → (q : transport B p y ≡ y') → (r : transport2 C p q z ≡ z') → (s : transport3 D p q r w ≡ w') → Maybe (transport4 E p q r s v ≡ v')) → Maybe (f x y z w v ≡ f x' y' z' w' v') lift-≟-5 {A} {B} {C} {D} {E} {F} f {x} {.x} {y} {y'} {z} {z'} {w} {w'} {v} {v'} (just refl) q r s t = lift-≟-5-helper {A} {B} {C} {D} {E} {F} {f} {x} {y} {y'} {z} {z'} {w} {w'} {v} {v'} (q refl) (r refl) (s refl) (t refl) lift-≟-5 f nothing q r s t = nothing lift-≟-4-helper-refl : ∀ {A B C D E f x y z w p q r} → p ≡ just refl → q refl ≡ just refl → r refl refl ≡ just refl → lift-≟-4-helper {A} {B} {C} {D} {E} {f} {x} {y} {y} {z} {z} {w} {w} p q r ≡ just refl lift-≟-4-helper-refl {A} {B} {C} {D} {E} {f} {x} {y} {z} {w} {._} {q} {r} refl q' r' = lift-≟-3-helper-refl {B x} {C x} {D x} {E} {f x} {y} {z} {w} {q refl} {r refl} q' r' lift-≟-4-refl : ∀ {A B C D E} f {x y z w} p q r s → p ≡ just refl → q refl ≡ just refl → r refl refl ≡ just refl → s refl refl refl ≡ just refl → lift-≟-4 {A} {B} {C} {D} {E} f {x} {x} {y} {y} {z} {z} {w} {w} p q r s ≡ just refl lift-≟-4-refl {A} {B} {C} {D} {E} f {x} {y} {z} {w} ._ q r s refl q' r' s' = lift-≟-4-helper-refl {A} {B} {C} {D} {E} {f} {x} {y} {z} {w} {q refl} {r refl} {s refl} q' r' s' lift-≟-5-helper-refl : ∀ {A B C D E F f x y z w v p q r s} → p ≡ just refl → q refl ≡ just refl → r refl refl ≡ just refl → s refl refl refl ≡ just refl → lift-≟-5-helper {A} {B} {C} {D} {E} {F} {f} {x} {y} {y} {z} {z} {w} {w} {v} {v} p q r s ≡ just refl lift-≟-5-helper-refl {A} {B} {C} {D} {E} {F} {f} {x} {y} {z} {w} {v} {._} {q} {r} {s} refl q' r' s' = lift-≟-4-helper-refl {B x} {C x} {D x} {E x} {F} {f x} {y} {z} {w} {v} {q refl} {r refl} {s refl} q' r' s' lift-≟-5-refl : ∀ {A B C D E F} f {x y z w v} p q r s t → p ≡ just refl → q refl ≡ just refl → r refl refl ≡ just refl → s refl refl refl ≡ just refl → t refl refl refl refl ≡ just refl → lift-≟-5 {A} {B} {C} {D} {E} {F} f {x} {x} {y} {y} {z} {z} {w} {w} {v} {v} p q r s t ≡ just refl lift-≟-5-refl {A} {B} {C} {D} {E} {F} f {x} {y} {z} {w} {v} ._ q r s t refl q' r' s' t' = lift-≟-5-helper-refl {A} {B} {C} {D} {E} {F} {f} {x} {y} {z} {w} {v} {q refl} {r refl} {s refl} {t refl} q' r' s' t'
{ "alphanum_fraction": 0.4218923933, "avg_line_length": 103.6538461538, "ext": "agda", "hexsha": "e3798c180fdd2f790531275b514d3c2ba80bd6cf", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-07-17T18:53:37.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-17T18:53:37.000Z", "max_forks_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JasonGross/lob", "max_forks_repo_path": "internal/common-utilities.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_issues_repo_issues_event_max_datetime": "2015-07-17T20:20:43.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-17T20:20:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JasonGross/lob", "max_issues_repo_path": "internal/common-utilities.agda", "max_line_length": 703, "max_stars_count": 19, "max_stars_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JasonGross/lob", "max_stars_repo_path": "internal/common-utilities.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-17T14:04:53.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-17T17:53:30.000Z", "num_tokens": 4126, "size": 8085 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Types and functions which are used to keep track of height -- invariants in AVL Trees ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.AVL.Height where open import Data.Nat.Base open import Data.Fin using (Fin; zero; suc) ℕ₂ = Fin 2 pattern 0# = zero pattern 1# = suc zero pattern ## = suc (suc ()) -- Addition. infixl 6 _⊕_ _⊕_ : ℕ₂ → ℕ → ℕ 0# ⊕ n = n 1# ⊕ n = 1 + n ## ⊕ n -- pred[ i ⊕ n ] = pred (i ⊕ n). pred[_⊕_] : ℕ₂ → ℕ → ℕ pred[ i ⊕ zero ] = 0 pred[ i ⊕ suc n ] = i ⊕ n infix 4 _∼_⊔_ -- If i ∼ j ⊔ m, then the difference between i and j is at most 1, -- and the maximum of i and j is m. _∼_⊔_ is used to record the -- balance factor of the AVL trees, and also to ensure that the -- absolute value of the balance factor is never more than 1. data _∼_⊔_ : ℕ → ℕ → ℕ → Set where ∼+ : ∀ {n} → n ∼ 1 + n ⊔ 1 + n ∼0 : ∀ {n} → n ∼ n ⊔ n ∼- : ∀ {n} → 1 + n ∼ n ⊔ 1 + n -- Some lemmas. max∼ : ∀ {i j m} → i ∼ j ⊔ m → m ∼ i ⊔ m max∼ ∼+ = ∼- max∼ ∼0 = ∼0 max∼ ∼- = ∼0 ∼max : ∀ {i j m} → i ∼ j ⊔ m → j ∼ m ⊔ m ∼max ∼+ = ∼0 ∼max ∼0 = ∼0 ∼max ∼- = ∼+
{ "alphanum_fraction": 0.4667194929, "avg_line_length": 21.7586206897, "ext": "agda", "hexsha": "5e7516e0ac1cea734740ded9386701173ad014bb", "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/Height.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/Height.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/Height.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 506, "size": 1262 }
open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; subst; cong) open import Syntax import Renaming import Substitution module Instantiation where module _ {𝕊 : Signature} where open Expression 𝕊 open Substitution open Renaming open Equality -- the set of instantiations infix 5 _→ⁱ_∥_ _→ⁱ_∥_ : MShape → MShape → VShape → Set 𝕄 →ⁱ 𝕂 ∥ γ = ∀ {clᴹ γᴹ} (M : [ clᴹ , γᴹ ]∈ 𝕄) → Arg clᴹ 𝕂 γ γᴹ -- equality of instantiations infix 4 _≈ⁱ_ _≈ⁱ_ : ∀ {𝕂 𝕄} {γ} (I J : 𝕂 →ⁱ 𝕄 ∥ γ) → Set I ≈ⁱ J = ∀ {clᴹ γᴹ} (M : [ clᴹ , γᴹ ]∈ _) → I M ≈ J M -- equality of instaniations is an equivalence relation ≈ⁱ-refl : ∀ {𝕂 𝕄} {γ} {I : 𝕂 →ⁱ 𝕄 ∥ γ} → I ≈ⁱ I ≈ⁱ-refl M = ≈-refl ≈ⁱ-sym : ∀ {𝕂 𝕄} {γ} {I J : 𝕂 →ⁱ 𝕄 ∥ γ} → I ≈ⁱ J → J ≈ⁱ I ≈ⁱ-sym ξ M = ≈-sym (ξ M) ≈ⁱ-trans : ∀ {𝕂 𝕄} {γ} {I J K : 𝕂 →ⁱ 𝕄 ∥ γ} → I ≈ⁱ J → J ≈ⁱ K → I ≈ⁱ K ≈ⁱ-trans ζ ξ M = ≈-trans (ζ M) (ξ M) -- identity instantiation 𝟙ⁱ : ∀ {𝕄 γ} → 𝕄 →ⁱ 𝕄 ∥ γ 𝟙ⁱ M = expr-meta-generic M -- instantiation extension ⇑ⁱ : ∀ {𝕂 𝕄 γ δ} → 𝕂 →ⁱ 𝕄 ∥ γ → 𝕂 →ⁱ 𝕄 ∥ γ ⊕ δ ⇑ⁱ I M = [ ⇑ʳ var-left ]ʳ (I M) -- extension respects equality ⇑ⁱ-resp-≈ⁱ : ∀ {𝕂 𝕄} {γ δ} → {I J : 𝕂 →ⁱ 𝕄 ∥ γ} → I ≈ⁱ J → ⇑ⁱ {δ = δ} I ≈ⁱ ⇑ⁱ J ⇑ⁱ-resp-≈ⁱ ξ M = []ʳ-resp-≈ (⇑ʳ var-left) (ξ M) -- the action of an instantiation on an expression infix 6 [_]ⁱ_ [_]ⁱ_ : ∀ {cl 𝕂 𝕄} {γ} → (𝕂 →ⁱ 𝕄 ∥ γ) → Expr cl 𝕂 γ → Expr cl 𝕄 γ [ I ]ⁱ (expr-var x) = expr-var x [ I ]ⁱ (expr-symb S es) = expr-symb S (λ i → [ ⇑ⁱ I ]ⁱ es i) [ I ]ⁱ (expr-meta M ts) = [ [ 𝟙ˢ , (λ i → [ I ]ⁱ ts i) ]ˢ ]ˢ I M [ I ]ⁱ expr-eqty = expr-eqty [ I ]ⁱ expr-eqtm = expr-eqtm -- instantiations respects equality []ⁱ-resp-≈ : ∀ {cl} {𝕂 𝕄} {γ} (I : 𝕂 →ⁱ 𝕄 ∥ γ) {t u : Expr cl 𝕂 γ} → t ≈ u → [ I ]ⁱ t ≈ [ I ]ⁱ u []ⁱ-resp-≈ I (≈-≡ ξ) = ≈-≡ (cong [ I ]ⁱ_ ξ) []ⁱ-resp-≈ I (≈-symb ξ) = ≈-symb (λ i → []ⁱ-resp-≈ (⇑ⁱ I) (ξ i)) []ⁱ-resp-≈ I (≈-meta ξ) = []ˢ-resp-≈ˢ ([,]ˢ-resp-≈ˢ ≈ˢ-refl (λ i → []ⁱ-resp-≈ I (ξ i))) (I _) []ⁱ-resp-≈ⁱ : ∀ {cl} {𝕂 𝕄} {γ} {I J : 𝕂 →ⁱ 𝕄 ∥ γ} (t : Expr cl 𝕂 γ) → I ≈ⁱ J → [ I ]ⁱ t ≈ [ J ]ⁱ t []ⁱ-resp-≈ⁱ (expr-var x) ξ = ≈-refl []ⁱ-resp-≈ⁱ (expr-symb S es) ξ = ≈-symb (λ i → []ⁱ-resp-≈ⁱ (es i) (⇑ⁱ-resp-≈ⁱ ξ)) []ⁱ-resp-≈ⁱ (expr-meta M ts) ξ = []ˢ-resp-≈ˢ-≈ ([,]ˢ-resp-≈ˢ ≈ˢ-refl (λ i → []ⁱ-resp-≈ⁱ (ts i) ξ)) (ξ M) []ⁱ-resp-≈ⁱ expr-eqty ξ = ≈-eqty []ⁱ-resp-≈ⁱ expr-eqtm ξ = ≈-eqtm []ⁱ-resp-≈ⁱ-≈ : ∀ {cl} {𝕂 𝕄} {γ} {I J : 𝕂 →ⁱ 𝕄 ∥ γ} {t u : Expr cl 𝕂 γ} → I ≈ⁱ J → t ≈ u → [ I ]ⁱ t ≈ [ J ]ⁱ u []ⁱ-resp-≈ⁱ-≈ {J = J} {t = t} ζ ξ = ≈-trans ([]ⁱ-resp-≈ⁱ t ζ) ([]ⁱ-resp-≈ J ξ) -- composition of instantiations infixl 7 _∘ⁱ_ _∘ⁱ_ : ∀ {𝕂 𝕃 𝕄} {γ} → 𝕃 →ⁱ 𝕄 ∥ γ → 𝕂 →ⁱ 𝕃 ∥ γ → 𝕂 →ⁱ 𝕄 ∥ γ (J ∘ⁱ I) M = [ ⇑ⁱ J ]ⁱ I M -- composition of a renaming and instantiation infixr 7 _ʳ∘ⁱ_ _ʳ∘ⁱ_ : ∀ {𝕂 𝕄} {γ δ} → (ρ : γ →ʳ δ) → (I : 𝕂 →ⁱ 𝕄 ∥ γ) → 𝕂 →ⁱ 𝕄 ∥ δ (ρ ʳ∘ⁱ I) M = [ ⇑ʳ ρ ]ʳ I M ⇑ⁱ-resp-ʳ∘ⁱ : ∀ {𝕂 𝕄} {γ δ η} {ρ : γ →ʳ δ} → {I : 𝕂 →ⁱ 𝕄 ∥ γ} → ⇑ⁱ {δ = η} (ρ ʳ∘ⁱ I) ≈ⁱ ⇑ʳ ρ ʳ∘ⁱ ⇑ⁱ I ⇑ⁱ-resp-ʳ∘ⁱ {I = I} M = ≈-trans (≈-trans (≈-sym ([∘ʳ] (I M))) ([]ʳ-resp-≡ʳ (I M) (λ {(var-left x) → refl ; (var-right y) → refl}))) ([∘ʳ] (I M)) [ʳ∘ⁱ] : ∀ {cl 𝕂 𝕄} {γ δ} {ρ : γ →ʳ δ} {I : 𝕂 →ⁱ 𝕄 ∥ γ} (t : Expr cl 𝕂 γ) → [ ρ ]ʳ ([ I ]ⁱ t) ≈ [ ρ ʳ∘ⁱ I ]ⁱ [ ρ ]ʳ t [ʳ∘ⁱ] (expr-var x) = ≈-refl [ʳ∘ⁱ] {ρ = ρ} {I = I} (expr-symb S es) = ≈-symb (λ i → ≈-trans ([ʳ∘ⁱ] (es i)) ([]ⁱ-resp-≈ⁱ ([ ⇑ʳ ρ ]ʳ es i) (≈ⁱ-sym (⇑ⁱ-resp-ʳ∘ⁱ {I = I})))) [ʳ∘ⁱ] {ρ = ρ} {I = I} (expr-meta M ts) = ≈-trans (≈-sym ([ʳ∘ˢ] (I M))) (≈-trans ([]ˢ-resp-≈ˢ (λ { (var-left x) → ≈-refl ; (var-right y) → [ʳ∘ⁱ] (ts y)}) (I M)) ([ˢ∘ʳ] (I M))) [ʳ∘ⁱ] expr-eqty = ≈-eqty [ʳ∘ⁱ] expr-eqtm = ≈-eqtm -- composition of an instantiation and substitution infixr 7 _ⁱ∘ˢ_ _ⁱ∘ˢ_ : ∀ {𝕂 𝕄} {γ δ} (I : 𝕂 →ⁱ 𝕄 ∥ δ) (σ : 𝕂 ∥ γ →ˢ δ) → (𝕄 ∥ γ →ˢ δ) (I ⁱ∘ˢ σ) x = [ I ]ⁱ σ x -- extension respects identity ⇑ⁱ-resp-𝟙ⁱ : ∀ {𝕄 γ δ} → ⇑ⁱ {δ = δ} 𝟙ⁱ ≈ⁱ 𝟙ⁱ {𝕄 = 𝕄} {γ = γ ⊕ δ} ⇑ⁱ-resp-𝟙ⁱ {clᴹ = obj _} M = ≈-refl ⇑ⁱ-resp-𝟙ⁱ {clᴹ = EqTy} M = ≈-eqty ⇑ⁱ-resp-𝟙ⁱ {clᴹ = EqTm} M = ≈-eqtm -- extension respects composition ⇑ⁱ-resp-∘ⁱ : ∀ {𝕂 𝕃 𝕄 γ δ} {I : 𝕂 →ⁱ 𝕃 ∥ γ} {J : 𝕃 →ⁱ 𝕄 ∥ γ} → ⇑ⁱ {δ = δ} (J ∘ⁱ I) ≈ⁱ ⇑ⁱ J ∘ⁱ ⇑ⁱ I ⇑ⁱ-resp-∘ⁱ {I = I} {J = J} M = ≈-trans ([ʳ∘ⁱ] (I M)) ([]ⁱ-resp-≈ⁱ ([ ⇑ʳ var-left ]ʳ I M) λ N → ≈-trans (≈-sym ([∘ʳ] (J N))) (≈-trans ([]ʳ-resp-≡ʳ (J N) λ {(var-left x) → refl ; (var-right y) → refl}) ([∘ʳ] (J N)))) ⇑ⁱ-resp-ⁱ∘ˢ : ∀ {𝕂 𝕄} {γ δ η} {I : 𝕂 →ⁱ 𝕄 ∥ δ} {σ : 𝕂 ∥ γ →ˢ δ} → ⇑ˢ {η = η} (I ⁱ∘ˢ σ ) ≈ˢ ⇑ⁱ I ⁱ∘ˢ ⇑ˢ σ ⇑ⁱ-resp-ⁱ∘ˢ {σ = σ}(var-left x) = ≈-trans ([ʳ∘ⁱ] (σ x)) ([]ⁱ-resp-≈ⁱ ([ var-left ]ʳ σ x) (λ _ → ≈-refl)) ⇑ⁱ-resp-ⁱ∘ˢ (var-right y) = ≈-refl -- the action of an instantiation on a generic metavariable application []ⁱ-meta-generic : ∀ {𝕂 𝕄} {γ} {I : 𝕂 →ⁱ 𝕄 ∥ γ} {clᴹ γᴹ} {M : [ clᴹ , γᴹ ]∈ 𝕂} → [ ⇑ⁱ I ]ⁱ (expr-meta-generic {γ = γ} M) ≈ I M []ⁱ-meta-generic {I = I} {clᴹ = obj _} {M = M} = ≈-trans (≈-sym ([ˢ∘ʳ] (I M))) ([]ˢ-id (λ { (var-left _) → ≈-refl ; (var-right _) → ≈-refl})) []ⁱ-meta-generic {clᴹ = EqTy} = ≈-eqty []ⁱ-meta-generic {clᴹ = EqTm} = ≈-eqtm -- action of the identity [𝟙ⁱ] : ∀ {cl 𝕄 γ} (t : Expr cl 𝕄 γ) → [ 𝟙ⁱ ]ⁱ t ≈ t [𝟙ⁱ] (expr-var x) = ≈-refl [𝟙ⁱ] (expr-symb S es) = ≈-symb (λ i → ≈-trans ([]ⁱ-resp-≈ⁱ (es i) ⇑ⁱ-resp-𝟙ⁱ) ([𝟙ⁱ] (es i))) [𝟙ⁱ] (expr-meta M ts) = ≈-meta (λ i → [𝟙ⁱ] (ts i)) [𝟙ⁱ] (expr-eqty) = ≈-eqty [𝟙ⁱ] (expr-eqtm) = ≈-eqtm -- interaction of instantiation, substitution and renaming []ⁱ-[]ˢ : ∀ {cl 𝕂 𝕄 γ δ} {I : 𝕂 →ⁱ 𝕄 ∥ δ} {σ : 𝕂 ∥ γ →ˢ δ} {ρ : δ →ʳ γ} (t : Expr cl 𝕂 γ) → σ ˢ∘ʳ ρ ≈ˢ 𝟙ˢ → ([ I ]ⁱ ([ σ ]ˢ t)) ≈ ([ I ⁱ∘ˢ σ ]ˢ [ ρ ʳ∘ⁱ I ]ⁱ t) []ⁱ-[]ˢ (expr-var x) ξ = ≈-refl []ⁱ-[]ˢ {I = I} {σ = σ} {ρ = ρ} (expr-symb S es) ξ = ≈-symb (λ i → ≈-trans ([]ⁱ-[]ˢ {ρ = ⇑ʳ ρ} (es i) λ where (var-left x) → []ʳ-resp-≈ var-left (ξ x) (var-right x) → ≈-refl) (≈-sym ([]ˢ-resp-≈ˢ-≈ (⇑ⁱ-resp-ⁱ∘ˢ) (([]ⁱ-resp-≈ⁱ (es i) (⇑ⁱ-resp-ʳ∘ⁱ {I = I})))))) []ⁱ-[]ˢ {I = I} {σ = σ} (expr-meta M ts) ξ = ≈-trans (≈-trans ([]ˢ-resp-≈ˢ (λ where (var-left x) → ≈-sym ([]ⁱ-resp-≈ I (ξ x)) (var-right x) → []ⁱ-[]ˢ (ts x) ξ) (I M)) ([∘ˢ] (I M))) (≈-sym ([]ˢ-resp-≈ (I ⁱ∘ˢ σ) (≈-sym ([ˢ∘ʳ] (I M))) )) []ⁱ-[]ˢ expr-eqty _ = ≈-eqty []ⁱ-[]ˢ expr-eqtm _ = ≈-eqtm _ˢ∘ⁱ_ : ∀ {𝕂 𝕄 γ δ} → 𝕊 % 𝕄 ∥ γ →ˢ δ → 𝕂 →ⁱ 𝕄 ∥ γ → 𝕂 →ⁱ 𝕄 ∥ δ (σ ˢ∘ⁱ I) M = [ ⇑ˢ σ ]ˢ I M ⇑ⁱ-resp-ˢ∘ⁱ : ∀ {𝕂 𝕄 γ δ η} {σ : 𝕊 % 𝕄 ∥ γ →ˢ δ} {I : 𝕂 →ⁱ 𝕄 ∥ γ} → ⇑ⁱ {δ = η} (σ ˢ∘ⁱ I) ≈ⁱ ⇑ˢ σ ˢ∘ⁱ ⇑ⁱ I ⇑ⁱ-resp-ˢ∘ⁱ {I = I} M = ≈-trans (≈-sym ([ʳ∘ˢ] (I M))) (≈-trans ([]ˢ-resp-≈ˢ (≈ˢ-sym ⇑ˢ-resp-ʳ∘ˢ) (I M)) (≈-trans ([]ˢ-resp-≈ˢ (λ { (var-left x) → ≈-refl ; (var-right y) → ≈-refl}) (I M)) ([ˢ∘ʳ] (I M)))) []ˢ-[]ⁱ : ∀ {cl 𝕂 𝕄 γ δ η} {I : 𝕂 →ⁱ 𝕄 ∥ γ} {σ : 𝕊 % 𝕄 ∥ γ →ˢ δ} {ρ : η →ʳ δ} {τ : η →ʳ γ} (t : Expr cl 𝕂 η) → (∀ x → σ (τ x) ≈ expr-var (ρ x)) → [ σ ]ˢ ([ I ]ⁱ ([ τ ]ʳ t)) ≈ [ σ ˢ∘ⁱ I ]ⁱ ([ ρ ]ʳ t) []ˢ-[]ⁱ (expr-var x) ξ = ξ x []ˢ-[]ⁱ {I = I} {σ = σ} {ρ = ρ} (expr-symb S es) ξ = ≈-symb (λ i → ≈-trans ([]ˢ-[]ⁱ {I = ⇑ⁱ I} {σ = ⇑ˢ σ} {ρ = ⇑ʳ ρ} (es i) (λ { (var-left x) → []ʳ-resp-≈ var-left (ξ x) ; (var-right x) → ≈-refl})) ([]ⁱ-resp-≈ⁱ ([ ⇑ʳ ρ ]ʳ es i) (≈ⁱ-sym (⇑ⁱ-resp-ˢ∘ⁱ {σ = σ} {I = I})))) []ˢ-[]ⁱ {I = I} {σ = σ} (expr-meta M ts) ξ = ≈-trans (≈-sym ([∘ˢ] (I M))) (≈-trans ([]ˢ-resp-≈ˢ (λ { (var-left x) → ≈-trans (≈-sym ([𝟙ˢ] (σ x))) ([ˢ∘ʳ] (σ x)) ; (var-right j) → []ˢ-[]ⁱ (ts j) ξ}) (I M)) ([∘ˢ] (I M))) []ˢ-[]ⁱ expr-eqty ξ = ≈-eqty []ˢ-[]ⁱ expr-eqtm ξ = ≈-eqtm -- action of composition [∘ⁱ] : ∀ {cl 𝕂 𝕃 𝕄 γ} {I : 𝕂 →ⁱ 𝕃 ∥ γ} {J : 𝕃 →ⁱ 𝕄 ∥ γ} (t : Expr cl 𝕂 γ) → [ J ∘ⁱ I ]ⁱ t ≈ [ J ]ⁱ [ I ]ⁱ t [∘ⁱ] (expr-var _) = ≈-refl [∘ⁱ] {I = I} {J = J} (expr-symb S es) = ≈-symb (λ i → ≈-trans ([]ⁱ-resp-≈ⁱ (es i) (⇑ⁱ-resp-∘ⁱ {I = I})) ([∘ⁱ] (es i))) [∘ⁱ] {I = I} {J = J} (expr-meta M ts) = ≈-sym (≈-trans ([]ⁱ-[]ˢ {I = J} {ρ = var-left} (I M) λ _ → ≈-refl) ([]ˢ-resp-≈ˢ (λ { (var-left x) → ≈-refl ; (var-right x) → ≈-sym ([∘ⁱ] (ts x))}) ([ ⇑ⁱ J ]ⁱ (I M)))) [∘ⁱ] expr-eqty = ≈-eqty [∘ⁱ] expr-eqtm = ≈-eqtm -- Notation for working with multiple signatures infix 5 _%_→ⁱ_∥_ _%_→ⁱ_∥_ : ∀ (𝕊 : Signature) → MShape → MShape → VShape → Set _%_→ⁱ_∥_ 𝕊 = _→ⁱ_∥_ {𝕊 = 𝕊}
{ "alphanum_fraction": 0.3972440521, "avg_line_length": 36.1439688716, "ext": "agda", "hexsha": "3b3ec17f5423c024b13824bbf52e6f85576acc54", "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/Instantiation.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/Instantiation.agda", "max_line_length": 130, "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/Instantiation.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": 5453, "size": 9289 }
-- Construction of the four functions SST, SK, SK⃗, and αₖ from -- "Extending Homotopy Type Theory with Strict Equality" by Thorsten -- Altenkirch, Paolo Capriotti, Nicolai Kraus (2016) -- (https://arxiv.org/abs/1604.03799). {-# OPTIONS --cubical-compatible --two-level --rewriting #-} open import Agda.Primitive open import Agda.Builtin.Nat open import Agda.Builtin.Equality open import Agda.Builtin.Sigma variable ℓ ℓ′ ℓ₁ ℓ₂ ℓ₃ : Level A B C : Set ℓ x y z : A infix 4 _≡ₛ_ _≡ₛₛ_ data _≡ₛ_ {A : Set ℓ} (x : A) : A → SSet ℓ where instance refl : x ≡ₛ x data _≡ₛₛ_ {A : SSet ℓ} (x : A) : A → SSet ℓ where instance refl : x ≡ₛₛ x UIPₛ : {A : Set ℓ} {x y : A} {e₁ e₂ : x ≡ₛ y} → e₁ ≡ₛₛ e₂ UIPₛ {e₁ = refl} {e₂ = refl} = refl {-# BUILTIN REWRITE _≡ₛₛ_ #-} sym : x ≡ₛ y → y ≡ₛ x sym refl = refl trans : x ≡ₛ y → y ≡ₛ z → x ≡ₛ z trans refl refl = refl infixr 10 _≡⟨_⟩ₛ_ _≡⟨_⟩ₛ_ : {A : Set ℓ} (x : A) {y z : A} → x ≡ₛ y → y ≡ₛ z → x ≡ₛ z x ≡⟨ refl ⟩ₛ refl = refl infix 15 _∎ₛ _∎ₛ : {A : Set ℓ} (x : A) → x ≡ₛ x x ∎ₛ = refl transport : {A : Set ℓ} (P : A → Set ℓ′) {x y : A} → x ≡ₛ y → P x → P y transport P refl p = p transport-merge : {A : Set ℓ} {P : A → Set ℓ′} {x y z : A} {e₁ : x ≡ₛ y} {e₂ : y ≡ₛ z} {p : P x} → transport P e₂ (transport P e₁ p) ≡ₛ transport P (trans e₁ e₂) p transport-merge {e₁ = refl} {e₂ = refl} = refl transport-pi : {A : Set ℓ₁} {B : Set ℓ₂} {C : A → B → Set ℓ₃} → {x₁ x₂ : A} {e : x₁ ≡ₛ x₂} {f : (y : B) → C x₁ y} {y : B} → transport (λ x → (y : B) → C x y) e f y ≡ₛ transport (λ x → C x y) e (f y) transport-pi {e = refl} = refl cong : (f : A → B) {x₁ x₂ : A} → x₁ ≡ₛ x₂ → f x₁ ≡ₛ f x₂ cong f refl = refl cong₂ : {A : Set ℓ} {B : A → Set ℓ′} (f : (x : A) → B x → C) → {x₁ x₂ : A} {y₁ : B x₁} {y₂ : B x₂} → (p : x₁ ≡ₛ x₂) (q : transport B p y₁ ≡ₛ y₂) → f x₁ y₁ ≡ₛ f x₂ y₂ cong₂ f refl refl = refl transport-cong : {f : A → B} {P : B → Set ℓ} {x₁ x₂ : A} {e : x₁ ≡ₛ x₂} {p : P (f x₁)} → transport (λ x → P (f x)) e p ≡ₛ transport P (cong f e) p transport-cong {e = refl} = refl cong-transport : {A : Set ℓ} {P : A → Set ℓ′} {x y : A} {e₁ e₂ : x ≡ₛ y} {p : P x} → e₁ ≡ₛₛ e₂ → transport P e₁ p ≡ₛ transport P e₂ p cong-transport refl = refl postulate funextₛ : {A : Set ℓ} {B : A → Set ℓ′} {f g : (x : A) → B x} → (∀ x → f x ≡ₛ g x) → f ≡ₛ g data sNat : SSet lzero where zero : sNat suc : sNat → sNat variable k l m n : sNat postulate Nat→sNat : Nat → sNat zero→szero : Nat→sNat zero ≡ₛₛ zero suc→ssuc : ∀ n → Nat→sNat (suc n) ≡ₛₛ suc (Nat→sNat n) {-# REWRITE zero→szero #-} {-# REWRITE suc→ssuc #-} data ⊥ {ℓ} : Set ℓ where record ⊤ {ℓ} : Set ℓ where constructor ∗ data _⊎_ (A B : Set ℓ) : Set ℓ where inl : A → A ⊎ B inr : B → A ⊎ B {-# NO_UNIVERSE_CHECK #-} data Fin : sNat → Set where fzero : Fin (suc n) fsuc : Fin n → Fin (suc n) {-# NO_UNIVERSE_CHECK #-} data _<ⁿ_ : Fin n → Fin n → Set where z<s : fzero <ⁿ fsuc x s<s : x <ⁿ y → fsuc x <ⁿ fsuc y isIncr : (Fin k → Fin l) → Set isIncr f = ∀ {x} {y} → x <ⁿ y → f x <ⁿ f y Δ₊ : (i j : sNat) → Set Δ₊ i j = Σ (Fin i → Fin j) isIncr _∘_ : Δ₊ l m → Δ₊ k l → Δ₊ k m (f , f-incr) ∘ (g , g-incr) = (λ x → f (g x)) , λ p → f-incr (g-incr p) ∘-assoc : ∀ {k l m n} {f : Δ₊ k l} {g : Δ₊ l m} {h : Δ₊ m n} → (h ∘ g) ∘ f ≡ₛ h ∘ (g ∘ f) ∘-assoc = refl SST : sNat → Set₁ SK : (k : sNat) → SST k → sNat → Set SK⃗ : (k : sNat) (X : SST k) {m n : sNat} (f : Δ₊ m n) → SK k X n → SK k X m α : (k : sNat) {l m n : sNat} (X : SST k) (f : Δ₊ l m) (g : Δ₊ m n) → (x : SK k X n) → SK⃗ k X (g ∘ f) x ≡ₛ SK⃗ k X f (SK⃗ k X g x) SST zero = ⊤ SST (suc k) = Σ (SST k) λ X → (SK k X (suc k) → Set) SK zero X n = ⊤ SK (suc k) (X , Y) n = Σ (SK k X n) λ x → (f : Δ₊ (suc k) n) → Y (SK⃗ k X f x) SK⃗ zero X f = λ x → x SK⃗ (suc k) (X , Y) f (x , h) = SK⃗ k X f x , λ g → let h[f∘g] : Y (SK⃗ k X (f ∘ g) x) h[f∘g] = h (f ∘ g) αₖ : SK⃗ k X (f ∘ g) x ≡ₛ SK⃗ k X g (SK⃗ k X f x) αₖ = α k X g f x in transport Y αₖ h[f∘g] α zero X f g x = refl α (suc k) {l} {m} {n} (X , Y) f g (x , y) = cong₂ _,_ (α k X f g x) (funextₛ λ h → transport (λ z → (f′ : Δ₊ (suc k) l) → Y (SK⃗ k X f′ z)) (α k X f g x) (λ g′ → transport Y (α k X g′ (g ∘ f) x) (y ((g ∘ f) ∘ g′))) h ≡⟨ transport-pi {B = Δ₊ (suc k) l} {C = λ z f′ → Y (SK⃗ k X f′ z)} {e = α k X f g x} ⟩ₛ transport (λ z → Y (SK⃗ k X h z)) (α k X f g x) (transport Y (α k X h (g ∘ f) x) (y ((g ∘ f) ∘ h))) ≡⟨ transport-cong {f = SK⃗ k X h} {P = Y} {e = α k X f g x} ⟩ₛ transport Y (cong (SK⃗ k X h) (α k X f g x)) (transport Y (α k X h (g ∘ f) x) (y ((g ∘ f) ∘ h))) ≡⟨ transport-merge {P = Y} {e₂ = cong (SK⃗ k X h) (α k X f g x)} {p = y ((g ∘ f) ∘ h)} ⟩ₛ transport Y (trans (α k X h (g ∘ f) x) (cong (SK⃗ k X h) (α k X f g x))) (y ((g ∘ f) ∘ h)) ≡⟨ cong-transport {P = Y} {e₁ = trans (α k X h (g ∘ f) x) (cong (SK⃗ k X h) (α k X f g x))} {e₂ = trans (α k X (f ∘ h) g x) (α k X h f (SK⃗ k X g x))} {p = y (g ∘ (f ∘ h))} UIPₛ ⟩ₛ transport Y (trans (α k X (f ∘ h) g x) (α k X h f (SK⃗ k X g x))) (y (g ∘ (f ∘ h))) ≡⟨ sym (transport-merge {e₁ = α k X (f ∘ h) g x} {e₂ = α k X h f (SK⃗ k X g x)} {p = y (g ∘ (f ∘ h))}) ⟩ₛ transport Y (α k X h f (SK⃗ k X g x)) (transport Y (α k X (f ∘ h) g x) (y (g ∘ (f ∘ h)))) ∎ₛ )
{ "alphanum_fraction": 0.4745327959, "avg_line_length": 30.1546961326, "ext": "agda", "hexsha": "92a627179e5c997e988c03180b241fa27c5ae197", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Succeed/SST.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Succeed/SST.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Succeed/SST.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2792, "size": 5458 }
open import Agda.Primitive using (lzero; lsuc; _⊔_) open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong; subst) import SecondOrder.Arity import SecondOrder.Signature import SecondOrder.Metavariable import SecondOrder.VRenaming import SecondOrder.MRenaming import SecondOrder.Term import SecondOrder.Substitution import SecondOrder.RelativeMonadMorphism module SecondOrder.Instantiation {ℓ} {𝔸 : SecondOrder.Arity.Arity} (Σ : SecondOrder.Signature.Signature ℓ 𝔸) where open SecondOrder.Signature.Signature Σ open SecondOrder.Metavariable Σ open SecondOrder.Term Σ open SecondOrder.VRenaming Σ open SecondOrder.MRenaming Σ open SecondOrder.Substitution Σ open import SecondOrder.RelativeMonadMorphism -- metavariable instantiation _⇒ⁱ_⊕_ : MContext → MContext → VContext → Set ℓ Θ ⇒ⁱ Ξ ⊕ Γ = ∀ {Γᴹ Aᴹ} (M : [ Γᴹ , Aᴹ ]∈ Θ) → Term Ξ (Γ ,, Γᴹ) Aᴹ -- syntactic equality of instantiations infix 5 _≈ⁱ_ _≈ⁱ_ : ∀ {Θ Ψ Γ} (I J : Θ ⇒ⁱ Ψ ⊕ Γ) → Set ℓ _≈ⁱ_ {Θ} I J = ∀ {Γᴹ Aᴹ} (M : [ Γᴹ , Aᴹ ]∈ Θ) → I M ≈ J M -- equality of instantiations is an equivalence relation ≈ⁱ-refl : ∀ {Θ Ψ Γ} {I : Θ ⇒ⁱ Ψ ⊕ Γ} → I ≈ⁱ I ≈ⁱ-refl M = ≈-refl ≈ⁱ-sym : ∀ {Θ Ψ Γ} {I J : Θ ⇒ⁱ Ψ ⊕ Γ} → I ≈ⁱ J → J ≈ⁱ I ≈ⁱ-sym ξ M = ≈-sym (ξ M) ≈ⁱ-trans : ∀ {Θ Ψ Γ} {I J K : Θ ⇒ⁱ Ψ ⊕ Γ} → I ≈ⁱ J → J ≈ⁱ K → I ≈ⁱ K ≈ⁱ-trans ζ ξ M = ≈-trans (ζ M) (ξ M) -- extension of an instantiation ⇑ⁱ : ∀ {Θ Ψ Γ Δ} → Θ ⇒ⁱ Ψ ⊕ Γ → Θ ⇒ⁱ Ψ ⊕ (Γ ,, Δ) ⇑ⁱ I M = [ ⇑ᵛ var-inl ]ᵛ I M -- extension of instantiations preserve equality of instantiations ⇑ⁱ-resp-≈ⁱ : ∀ {Θ Ψ Γ Δ} (I J : Θ ⇒ⁱ Ψ ⊕ Γ) → (I ≈ⁱ J) → (⇑ⁱ {Δ = Δ} I ≈ⁱ ⇑ⁱ J) ⇑ⁱ-resp-≈ⁱ I J ξ M = []ᵛ-resp-≈ (ξ M) -- action of a metavariable instantiation on terms infixr 6 [_]ⁱ_ [_]ⁱ_ : ∀ {Θ ψ Γ} → ψ ⇒ⁱ Θ ⊕ Γ → ∀ {A} → Term ψ Γ A → Term Θ Γ A [ I ]ⁱ (tm-var x) = tm-var x [ I ]ⁱ (tm-meta M ts) = [ [ idˢ , (λ i → [ I ]ⁱ ts i) ]ˢ ]ˢ (I M) [ I ]ⁱ (tm-oper f es) = tm-oper f λ i → [ ⇑ⁱ I ]ⁱ es i -- instantiation preserves equality of terms []ⁱ-resp-≈ : ∀ {Θ Ξ Γ} (I : Ξ ⇒ⁱ Θ ⊕ Γ) → ∀ {A} {t u : Term Ξ Γ A} → t ≈ u → [ I ]ⁱ t ≈ [ I ]ⁱ u []ⁱ-resp-≈ I (≈-≡ refl) = ≈-refl []ⁱ-resp-≈ I (≈-meta {M = M} ξ) = []ˢ-resp-≈ˢ (I M) ([,]ˢ-resp-≈ˢ (λ x → ≈-refl) λ i → []ⁱ-resp-≈ I (ξ i)) []ⁱ-resp-≈ I (≈-oper ξ) = ≈-oper λ i → []ⁱ-resp-≈ (⇑ⁱ I) (ξ i) -- action preserves equality of instantiation []ⁱ-resp-≈ⁱ : ∀ {Θ Ξ Γ} {I J : Ξ ⇒ⁱ Θ ⊕ Γ} → ∀ {A} (t : Term Ξ Γ A) → I ≈ⁱ J → [ I ]ⁱ t ≈ [ J ]ⁱ t []ⁱ-resp-≈ⁱ (tm-var x) ξ = ≈-refl []ⁱ-resp-≈ⁱ (tm-meta M ts) ξ = []ˢ-resp-≈ˢ-≈ ([,]ˢ-resp-≈ˢ (λ x → ≈-refl) λ i → []ⁱ-resp-≈ⁱ (ts i) ξ) (ξ M) []ⁱ-resp-≈ⁱ {I = I} {J = J} (tm-oper f es) ξ = ≈-oper λ i → []ⁱ-resp-≈ⁱ (es i) (⇑ⁱ-resp-≈ⁱ I J ξ) -- generically applied metavariable tm-meta-generic : ∀ {Θ} {Γ} {Γᴹ Aᴹ} (M : [ Γᴹ , Aᴹ ]∈ Θ) → Term Θ (Γ ,, Γᴹ) Aᴹ tm-meta-generic M = tm-meta M λ i → tm-var (var-inr i) -- the action of an instantiation on a generically applied metavariable []ⁱ-generic : ∀ {Θ Ξ} {Γ} {I : Θ ⇒ⁱ Ξ ⊕ Γ} {Γᴹ Aᴹ} {M : [ Γᴹ , Aᴹ ]∈ Θ} → [ ⇑ⁱ {Δ = Γᴹ} I ]ⁱ tm-meta-generic M ≈ I M []ⁱ-generic {Θ = Θ} {Ξ = Ξ} {Γ = Γ} {I = I} {Γᴹ = Γᴹ} {M = M} = ≈-trans (≈-sym ([ˢ∘ᵛ] (I M))) (≈ˢ-idˢ-[]ˢ (λ { (var-inl _) → ≈-refl ; (var-inr _) → ≈-refl})) -- Interactions involving instantiations -- the identity metavariable instantiation idⁱ : ∀ {Θ Γ} → Θ ⇒ⁱ Θ ⊕ Γ idⁱ M = tm-meta-generic M -- composition of metavariable instantiations infixl 6 _∘ⁱ_ _∘ⁱ_ : ∀ {Θ Ξ Ω Γ} → Ξ ⇒ⁱ Ω ⊕ Γ → Θ ⇒ⁱ Ξ ⊕ Γ → (Θ ⇒ⁱ Ω ⊕ Γ) (I ∘ⁱ J) M = [ ⇑ⁱ I ]ⁱ J M -- composition of a renaming and an instantiation _ᵛ∘ⁱ_ : ∀ {Θ ψ Γ Δ} → Γ ⇒ᵛ Δ → Θ ⇒ⁱ ψ ⊕ Γ → Θ ⇒ⁱ ψ ⊕ Δ (ρ ᵛ∘ⁱ I) M = [ ⇑ᵛ ρ ]ᵛ I M -- composition of a substitution and an instantiation _ˢ∘ⁱ_ : ∀ {Θ ψ Γ Δ} → ψ ⊕ Γ ⇒ˢ Δ → Θ ⇒ⁱ ψ ⊕ Γ → Θ ⇒ⁱ ψ ⊕ Δ (σ ˢ∘ⁱ I) M = [ ⇑ˢ σ ]ˢ I M -- composition of an instantiation and a substitution _ⁱ∘ˢ_ : ∀ {Θ ψ Γ Δ} → Θ ⇒ⁱ ψ ⊕ Δ → Θ ⊕ Γ ⇒ˢ Δ → ψ ⊕ Γ ⇒ˢ Δ (I ⁱ∘ˢ σ) x = [ I ]ⁱ σ x -- composition of a renaming and an instantiation preerve equality of instantiations [ᵛ∘ⁱ]-resp-≈ⁱ : ∀ {Θ ψ Γ Δ} (ρ : Γ ⇒ᵛ Δ) (I J : Θ ⇒ⁱ ψ ⊕ Γ) → (I ≈ⁱ J) → (ρ ᵛ∘ⁱ I) ≈ⁱ (ρ ᵛ∘ⁱ J) [ᵛ∘ⁱ]-resp-≈ⁱ σ I J ξ M = []ᵛ-resp-≈ (ξ M) -- composition of a renaming and an instantiation preserve equality of instantiations [ˢ∘ⁱ]-resp-≈ⁱ : ∀ {Θ ψ Γ Δ} (σ : ψ ⊕ Γ ⇒ˢ Δ) (I J : Θ ⇒ⁱ ψ ⊕ Γ) → (I ≈ⁱ J) → (σ ˢ∘ⁱ I) ≈ⁱ (σ ˢ∘ⁱ J) [ˢ∘ⁱ]-resp-≈ⁱ σ I J ξ M = []ˢ-resp-≈ (⇑ˢ σ) (ξ M) -- Actions correspondig to the interactions -- the action of the identity [idⁱ] : ∀ {Θ Γ A Δ} {t : Term Θ (Γ ,, Δ) A} → [ idⁱ ]ⁱ t ≈ t [idⁱ] {t = tm-var x} = ≈-refl [idⁱ] {t = tm-meta M ts} = ≈-meta (λ i → [idⁱ]) [idⁱ] {t = tm-oper f es} = ≈-oper (λ i → [idⁱ]) -- extension commutes with composition of renaming and substitution ⇑ⁱ-resp-ᵛ∘ⁱ : ∀ {Θ ψ} {Γ Δ Ξ} {I : Θ ⇒ⁱ ψ ⊕ Γ} {ρ : Γ ⇒ᵛ Δ} → ⇑ⁱ {Δ = Ξ} (ρ ᵛ∘ⁱ I) ≈ⁱ ⇑ᵛ ρ ᵛ∘ⁱ ⇑ⁱ I ⇑ⁱ-resp-ᵛ∘ⁱ {ρ = ρ} M = ≈-trans (≈-sym [∘ᵛ]) (≈-trans ([]ᵛ-resp-≡ᵛ λ {(var-inl _) → refl ; (var-inr x) → refl}) [∘ᵛ]) -- the action of the composition of an instantiation and a renaming [ᵛ∘ⁱ] : ∀ {Θ Ψ Γ Δ A} {ρ : Γ ⇒ᵛ Δ} {I : Θ ⇒ⁱ Ψ ⊕ Γ} (t : Term Θ Γ A) → [ ρ ]ᵛ [ I ]ⁱ t ≈ [ ρ ᵛ∘ⁱ I ]ⁱ [ ρ ]ᵛ t [ᵛ∘ⁱ] (tm-var x) = ≈-refl [ᵛ∘ⁱ] {I = I} (tm-meta M ts) = ≈-trans (≈-sym ([ᵛ∘ˢ] (I M))) (≈-trans ([]ˢ-resp-≈ˢ (I M) (λ { (var-inl _) → ≈-refl ; (var-inr j) → [ᵛ∘ⁱ] (ts j)})) ([ˢ∘ᵛ] (I M))) [ᵛ∘ⁱ] {ρ = ρ} {I = I} (tm-oper f es) = ≈-oper λ i → ≈-trans ([ᵛ∘ⁱ] (es i)) ([]ⁱ-resp-≈ⁱ ([ ⇑ᵛ ρ ]ᵛ es i) (≈ⁱ-sym (⇑ⁱ-resp-ᵛ∘ⁱ {I = I}))) -- extension commutes with composition ⇑ⁱ-resp-∘ⁱ : ∀ {Θ Ξ Ω} {Γ Δ} {I : Θ ⇒ⁱ Ξ ⊕ Γ} {J : Ξ ⇒ⁱ Ω ⊕ Γ} → ⇑ⁱ {Δ = Δ} (J ∘ⁱ I) ≈ⁱ ⇑ⁱ J ∘ⁱ ⇑ⁱ I ⇑ⁱ-resp-∘ⁱ {I = I} {J = J} M = ≈-trans ([ᵛ∘ⁱ] (I M)) ([]ⁱ-resp-≈ⁱ ([ ⇑ᵛ var-inl ]ᵛ I M) (λ N → ≈-trans (≈-sym [∘ᵛ]) (≈-trans ([]ᵛ-resp-≡ᵛ (λ { (var-inl x) → refl ; (var-inr x) → refl })) [∘ᵛ]))) ⇑ˢ-resp-ⁱ∘ˢ : ∀ {Θ ψ Γ Δ Ξ} → {I : Θ ⇒ⁱ ψ ⊕ Δ} → {σ : Θ ⊕ Γ ⇒ˢ Δ} → ⇑ˢ {Ξ = Ξ} (I ⁱ∘ˢ σ) ≈ˢ ⇑ⁱ I ⁱ∘ˢ ⇑ˢ σ ⇑ˢ-resp-ⁱ∘ˢ {σ = σ} (var-inl x) = [ᵛ∘ⁱ] (σ x) ⇑ˢ-resp-ⁱ∘ˢ (var-inr x) = ≈-refl -- interaction lemma []ⁱ-[]ˢ : ∀ {Θ Ψ Γ Δ A} {I : Θ ⇒ⁱ Ψ ⊕ Δ} {σ : Θ ⊕ Γ ⇒ˢ Δ} {ρ : Δ ⇒ᵛ Γ} (t : Term Θ Γ A) → σ ˢ∘ᵛ ρ ≈ˢ idˢ → ([ I ]ⁱ ([ σ ]ˢ t)) ≈ ([ I ⁱ∘ˢ σ ]ˢ [ ρ ᵛ∘ⁱ I ]ⁱ t) []ⁱ-[]ˢ (tm-var x) ξ = ≈-refl []ⁱ-[]ˢ {I = I} {σ = σ} {ρ = ρ} (tm-meta M ts) ξ = ≈-trans ([]ˢ-resp-≈ˢ (I M) (λ { (var-inl i) → []ⁱ-resp-≈ I (≈-sym (ξ i)) ; (var-inr j) → []ⁱ-[]ˢ (ts j) ξ})) (≈-trans ([ˢ∘ᵛ] (I M)) ([∘ˢ] ((ρ ᵛ∘ⁱ I) M))) []ⁱ-[]ˢ {I = I} {σ = σ} {ρ = ρ} (tm-oper f es) ξ = ≈-oper λ i → ≈-trans ([]ⁱ-[]ˢ {σ = ⇑ˢ σ} {ρ = ⇑ᵛ ρ} (es i) (≈ˢ-trans (≈ˢ-sym (⇑ˢ-resp-ˢ∘ᵛ {ρ = ρ} {σ = σ})) (≈ˢ-trans (⇑ˢ-resp-≈ˢ ξ) ⇑ˢ-resp-idˢ))) ([]ˢ-resp-≈ˢ-≈ {σ = ⇑ⁱ I ⁱ∘ˢ ⇑ˢ σ } {τ = ⇑ˢ (I ⁱ∘ˢ σ)} {t = ([ ⇑ᵛ ρ ᵛ∘ⁱ ⇑ⁱ I ]ⁱ es i)} {u = ([ ⇑ⁱ (ρ ᵛ∘ⁱ I) ]ⁱ es i)} (≈ˢ-sym ⇑ˢ-resp-ⁱ∘ˢ) ([]ⁱ-resp-≈ⁱ (es i) (≈ⁱ-sym (⇑ⁱ-resp-ᵛ∘ⁱ {I = I})))) -- the action of a composition [∘ⁱ] : ∀ {Θ Ξ Ω Γ} → {I : Θ ⇒ⁱ Ξ ⊕ Γ} → {J : Ξ ⇒ⁱ Ω ⊕ Γ} → ∀ {A} → ∀ (t : Term Θ Γ A) → [ J ∘ⁱ I ]ⁱ t ≈ [ J ]ⁱ [ I ]ⁱ t [∘ⁱ] (tm-var x) = ≈-refl [∘ⁱ] {Θ = Θ} {Ξ = Ξ} {Γ = Γ} {I = I} {J = J} (tm-meta {Γᴹ = Γᴹ} M ts) = ≈-trans ([]ˢ-resp-≈ˢ ([ ⇑ⁱ J ]ⁱ (I M)) ([,]ˢ-resp-≈ˢ (λ x → ≈-refl) (λ i → [∘ⁱ] {I = I} {J = J} (ts i)))) (≈-trans ([]ˢ-resp-≈ˢ {τ = λ i → [ J ]ⁱ var-or-ts i} ([ ⇑ⁱ J ]ⁱ (I M)) λ {(var-inl x) → ≈-refl ; (var-inr y) → ≈-refl}) (≈-trans (≈-sym ([]ⁱ-[]ˢ {I = J} {σ = var-or-ts} {ρ = var-inl} (I M) λ x → ≈-refl)) ([]ⁱ-resp-≈ J ([]ˢ-resp-≈ˢ (I M) λ { (var-inl x) → ≈-refl ; (var-inr x) → ≈-refl})))) where var-or-ts : ∀ {A} → A ∈ (Γ ,, Γᴹ) → Term Ξ Γ A var-or-ts (var-inl x) = tm-var x var-or-ts (var-inr y) = [ I ]ⁱ ts y [∘ⁱ] {I = I} {J = J} (tm-oper f es) = ≈-oper (λ i → ≈-trans ([]ⁱ-resp-≈ⁱ (es i) (⇑ⁱ-resp-∘ⁱ {I = I})) ([∘ⁱ] (es i)))
{ "alphanum_fraction": 0.4575728846, "avg_line_length": 35.1583333333, "ext": "agda", "hexsha": "b6e90250138fa75343820750302a95e5c74f01ec", "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": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/formaltt", "max_forks_repo_path": "src/SecondOrder/Instantiation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "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/formaltt", "max_issues_repo_path": "src/SecondOrder/Instantiation.agda", "max_line_length": 119, "max_stars_count": 1, "max_stars_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andrejbauer/formal", "max_stars_repo_path": "src/SecondOrder/Instantiation.agda", "max_stars_repo_stars_event_max_datetime": "2021-04-18T18:21:00.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-18T18:21:00.000Z", "num_tokens": 4761, "size": 8438 }
-- Example by Sandro Stucki on the Agda mailing list. -- If higher-dimensional unification fails and --without-K is not -- enabled, we should still apply injectivity. open import Agda.Builtin.Nat postulate Fin : Nat → Set data Indexed : Nat → Nat → Set where con : ∀ m {n} (i : Fin n) → Indexed (m + n) (m + suc n) data RelIndexed : ∀ {m n} → Indexed m n → Indexed m n → Set where relIdx : ∀ {m n} (i : Fin n) (j : Fin n) → RelIndexed (con m i) (con m j) test1 : ∀ {m n} {a b : Indexed m n} → RelIndexed a b → Indexed m n test1 (relIdx {m} i _) = con m i test2 : ∀ {m n} {a : Indexed m n} → RelIndexed a a → Indexed m n test2 (relIdx {m} i _) = con m i
{ "alphanum_fraction": 0.622556391, "avg_line_length": 30.2272727273, "ext": "agda", "hexsha": "49bf6833de05ee2fa8efb8f364911b8e2c971bf3", "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/HDUfallback.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/HDUfallback.agda", "max_line_length": 75, "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/HDUfallback.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 230, "size": 665 }
------------------------------------------------------------------------ -- The Agda standard library -- -- A categorical view of Maybe ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Maybe.Categorical where open import Data.Maybe.Base open import Category.Functor open import Category.Applicative open import Category.Monad import Function.Identity.Categorical as Id open import Function ------------------------------------------------------------------------ -- Maybe applicative functor functor : ∀ {f} → RawFunctor {f} Maybe functor = record { _<$>_ = map } applicative : ∀ {f} → RawApplicative {f} Maybe applicative = record { pure = just ; _⊛_ = maybe map (const nothing) } applicativeZero : ∀ {f} → RawApplicativeZero {f} Maybe applicativeZero = record { applicative = applicative ; ∅ = nothing } alternative : ∀ {f} → RawAlternative {f} Maybe alternative = record { applicativeZero = applicativeZero ; _∣_ = _<∣>_ } ------------------------------------------------------------------------ -- Maybe monad transformer monadT : ∀ {f} → RawMonadT {f} (_∘′ Maybe) monadT M = record { return = M.return ∘ just ; _>>=_ = λ m f → m M.>>= maybe f (M.return nothing) } where module M = RawMonad M ------------------------------------------------------------------------ -- Maybe monad monad : ∀ {f} → RawMonad {f} Maybe monad = monadT Id.monad monadZero : ∀ {f} → RawMonadZero {f} Maybe monadZero = record { monad = monad ; applicativeZero = applicativeZero } monadPlus : ∀ {f} → RawMonadPlus {f} Maybe monadPlus {f} = record { monad = monad ; alternative = alternative } ------------------------------------------------------------------------ -- Get access to other monadic functions module _ {f F} (App : RawApplicative {f} F) where open RawApplicative App sequenceA : ∀ {A} → Maybe (F A) → F (Maybe A) sequenceA nothing = pure nothing sequenceA (just x) = just <$> x mapA : ∀ {a} {A : Set a} {B} → (A → F B) → Maybe A → F (Maybe B) mapA f = sequenceA ∘ map f forA : ∀ {a} {A : Set a} {B} → Maybe A → (A → F B) → F (Maybe B) forA = flip mapA module _ {m M} (Mon : RawMonad {m} M) where private App = RawMonad.rawIApplicative Mon sequenceM = sequenceA App mapM = mapA App forM = forA App
{ "alphanum_fraction": 0.5194479297, "avg_line_length": 24.90625, "ext": "agda", "hexsha": "9e963f58ea364f723528efb6ae9fbf7414eb33ec", "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/Maybe/Categorical.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/Maybe/Categorical.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/Maybe/Categorical.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 656, "size": 2391 }
module _ where record ⊤ : Set where constructor tt f : {{u : ⊤}} → ⊤ f = _ foo : (x : ⊤) → ⊤ foo x = f
{ "alphanum_fraction": 0.4770642202, "avg_line_length": 9.0833333333, "ext": "agda", "hexsha": "ba2ef0796157d196ae919bf23e48e49002e2fb3b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/SingletonInstance.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Succeed/SingletonInstance.agda", "max_line_length": 20, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/SingletonInstance.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": 48, "size": 109 }
postulate A : Set P : A → Set record ΣAP : Set where no-eta-equality field fst : A snd : P fst open ΣAP test : (x : ΣAP) → P (fst x) test x = snd {!!}
{ "alphanum_fraction": 0.5411764706, "avg_line_length": 11.3333333333, "ext": "agda", "hexsha": "9607f6c75b60899e27a00c8207bef09c49593206", "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/Issue3606.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/Issue3606.agda", "max_line_length": 28, "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/Issue3606.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": 71, "size": 170 }
{-# OPTIONS --safe #-} module Cubical.Algebra.Group.Instances.Unit where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Structure open import Cubical.Foundations.HLevels open import Cubical.Foundations.Equiv open import Cubical.Data.Unit open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Group.DirProd open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Algebra.Group.GroupPath open GroupStr open IsGroupHom private variable ℓ : Level UnitGroup₀ : Group₀ fst UnitGroup₀ = Unit 1g (snd UnitGroup₀) = tt _·_ (snd UnitGroup₀) = λ _ _ → tt inv (snd UnitGroup₀) = λ _ → tt isGroup (snd UnitGroup₀) = makeIsGroup isSetUnit (λ _ _ _ → refl) (λ _ → refl) (λ _ → refl) (λ _ → refl) (λ _ → refl) UnitGroup : Group ℓ fst UnitGroup = Unit* 1g (snd UnitGroup) = tt* _·_ (snd UnitGroup) = λ _ _ → tt* inv (snd UnitGroup) = λ _ → tt* isGroup (snd UnitGroup) = makeIsGroup (isOfHLevelUnit* 2) (λ _ _ _ → refl) (λ _ → refl) (λ _ → refl) (λ _ → refl) (λ _ → refl) open Iso -- The trivial group is a unit. lUnitGroupIso : {G : Group ℓ} → GroupIso (DirProd UnitGroup₀ G) G fun (fst lUnitGroupIso) = snd inv (fst lUnitGroupIso) g = tt , g rightInv (fst lUnitGroupIso) _ = refl leftInv (fst lUnitGroupIso) _ = refl snd lUnitGroupIso = makeIsGroupHom λ _ _ → refl rUnitGroupIso : {G : Group ℓ} → GroupIso (DirProd G UnitGroup₀) G fun (fst rUnitGroupIso) = fst inv (fst rUnitGroupIso) g = g , tt rightInv (fst rUnitGroupIso) _ = refl leftInv (fst rUnitGroupIso) _ = refl snd rUnitGroupIso = makeIsGroupHom λ _ _ → refl lUnitGroupEquiv : {G : Group ℓ} → GroupEquiv (DirProd UnitGroup₀ G) G lUnitGroupEquiv = GroupIso→GroupEquiv lUnitGroupIso rUnitGroupEquiv : ∀ {ℓ} {G : Group ℓ} → GroupEquiv (DirProd G UnitGroup₀) G rUnitGroupEquiv = GroupIso→GroupEquiv rUnitGroupIso contrGroupIsoUnit : {G : Group ℓ} → isContr ⟨ G ⟩ → GroupIso G UnitGroup₀ fun (fst (contrGroupIsoUnit contr)) _ = tt inv (fst (contrGroupIsoUnit contr)) _ = fst contr rightInv (fst (contrGroupIsoUnit contr)) _ = refl leftInv (fst (contrGroupIsoUnit contr)) x = snd contr x snd (contrGroupIsoUnit contr) = makeIsGroupHom λ _ _ → refl contrGroupEquivUnit : {G : Group ℓ} → isContr ⟨ G ⟩ → GroupEquiv G UnitGroup₀ contrGroupEquivUnit contr = GroupIso→GroupEquiv (contrGroupIsoUnit contr) isContr→≡UnitGroup : {G : Group ℓ-zero} → isContr (fst G) → UnitGroup₀ ≡ G isContr→≡UnitGroup c = fst (GroupPath _ _) (invGroupEquiv ((isContr→≃Unit c) , (makeIsGroupHom (λ _ _ → refl)))) GroupIsoUnitGroup→isContr : {G : Group ℓ-zero} → GroupIso UnitGroup₀ G → isContr (fst G) GroupIsoUnitGroup→isContr is = isOfHLevelRetractFromIso 0 (invIso (fst is)) isContrUnit →UnitHom : ∀ {ℓ} (G : Group ℓ) → GroupHom G UnitGroup₀ fst (→UnitHom G) _ = tt snd (→UnitHom G) = makeIsGroupHom λ _ _ → refl
{ "alphanum_fraction": 0.7073901465, "avg_line_length": 33.010989011, "ext": "agda", "hexsha": "e0a237cf5abf359524f1482bc8fbac588573c6af", "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/Instances/Unit.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/Instances/Unit.agda", "max_line_length": 77, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/Group/Instances/Unit.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 991, "size": 3004 }
-- Reported by matteo.acerbi, AIMXX, 2014-10-21 -- The following is accepted. {-# OPTIONS --guardedness #-} {-# OPTIONS --cubical-compatible #-} -- {-# OPTIONS -v term:30 #-} record X : Set where coinductive constructor ↑_ field ↓_ : X open X record Y (x1 x2 : X) : Set where coinductive field ]_[ : Y (↑ x1) (↑ x2) open Y trivial-Y : ∀ {x1 x2} → Y x1 x2 ] trivial-Y [ = trivial-Y -- Should termination check.
{ "alphanum_fraction": 0.6009070295, "avg_line_length": 16.9615384615, "ext": "agda", "hexsha": "0d24f2c1b67ead5335fe1aac5220d03568dc27ae", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Succeed/Issue1320.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Succeed/Issue1320.agda", "max_line_length": 47, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Succeed/Issue1320.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 148, "size": 441 }
module _ where open import Agda.Builtin.List open import Agda.Builtin.Reflection open import Agda.Builtin.Unit record Id (A : Set) : Set where field id : A → A open Id {{...}} postulate T : {A : Set} → A → Set cong : ∀ {A B : Set} (f : A → B) {x} → T x → T (f x) X : Set lem : (x : X) → T x instance IdX : Id X IdX .id n = n macro follows-from : Term → Term → TC ⊤ follows-from prf hole = do typeError (termErr prf ∷ []) loops : (x : X) → T x loops x = follows-from (cong id (lem x))
{ "alphanum_fraction": 0.5700575816, "avg_line_length": 16.28125, "ext": "agda", "hexsha": "0031e5b1bcb5acc43b694026414220ca2d462b47", "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/Issue3461.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/Issue3461.agda", "max_line_length": 54, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue3461.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": 194, "size": 521 }
{- OPTIONS --without-K -} module Base where open import Agda.Primitive public using (lzero) renaming (Level to ULevel; lsuc to lsucc; _⊔_ to lmax) Type : (i : ULevel) → Set (lsucc i) Type i = Set i Type₀ = Type lzero Type0 = Type lzero Type₁ = Type (lsucc lzero) Type1 = Type (lsucc lzero) {- Naturals -} data ℕ : Type₀ where O : ℕ S : (n : ℕ) → ℕ {-# BUILTIN NATURAL ℕ #-} Nat = ℕ infix 3 _==_ data _==_ {i} {A : Type i} (a : A) : A → Type i where idp : a == a Path = _==_ {-# BUILTIN EQUALITY _==_ #-} {-# BUILTIN REFL idp #-} {- Free path induction, or as close as I could get, written in Section 1.12.1 as ind=A : ∏ ∏(x:A)C(x,x,reflx) → ∏ ∏ C(x,y,p) (C:∏(x,y:A)(x=Ay)→U) (x,y:A) (p:x=Ay) ind=A (C, c, x, x, reflx) :≡ c(x) -} ind== : ∀ {i j} {A : Type i} (D : (x y : A) → x == y → Type j) (d : (x : A) → D x x idp) {x y : A} (p : x == y) → D x y p ind== D d {x} idp = d x -- slight concern: what rules govern the implicit {x} and {y} -- converging on the single {x} parameter here? I don't know Agda -- well enough to answer this yet. Depending upon what -- they are, this rule may be a duplicate of one of the based -- path induction rules below. {- Based path induction, or the J rule in HoTT-Agda lib -} ind=' : ∀ {i j} {A : Type i} {a : A} (D : (x : A) (p : a == x) → Type j) (d : D a idp) {x : A} (p : a == x) → D x p ind=' D d idp = d {- Right-based path induction, or J' in the HoTT-Agda lib -} ind'= : ∀ {i j} {A : Type i} {a : A} (D : (x : A) (p : x == a) → Type j) (d : D a idp) {x : A} (p : x == a) → D x p ind'= D d idp = d ind==2 : ∀ {i j} {A : Type i} (D : {x y : A} → x == y → Type j) (d : {x : A} → D {x} {x} idp) {x y : A} (p : x == y) → D p ind==2 D d idp = d -- slight concern: what rules govern the implicit {x} and {y} -- {- Alternative based path induction as a specialized free path induction -} -- ind='2 : ∀ {i j} {A : Type i} {a : A} (D : {x : A} (p : a == x) → Type j) (d : D idp) -- {x : A} (p : a == x) → D p -- ind='2 D d = ind==2 {!!} {!!} -- Christine Paulin-Mohring’s version of the J rule is based path induction ind=' J : ∀ {i j} {A : Type i} {a : A} (D : {x : A} → a == x → Type j) → D idp → {x : A} (p : a == x) → D p J D d idp = d {- Unit type The unit type is defined as record so that we also get the η-rule definitionally. -} record Unit : Type₀ where constructor unit {- Dependent paths The notion of dependent path is a very important notion. If you have a dependent type [B] over [A], a path [p : x == y] in [A] and two points [u : B x] and [v : B y], there is a type [u == v [ B ↓ p ]] of paths from [u] to [v] lying over the path [p]. By definition, if [p] is a constant path, then [u == v [ B ↓ p ]] is just an ordinary path in the fiber. -} PathOver : ∀ {i j} {A : Type i} (B : A → Type j) {x y : A} (p : x == y) (u : B x) (v : B y) → Type j PathOver B idp u v = (u == v) syntax PathOver B p u v = u == v [ B ↓ p ] {- Ap, coe and transport Given two fibrations over a type [A], a fiberwise map between the two fibrations can be applied to any dependent path in the first fibration ([ap↓]). As a special case, when [A] is [Unit], we find the familiar [ap] ([ap] is defined in terms of [ap↓] because it shouldn’t change anything for the user and this is helpful in some rare cases) -} ap : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {x y : A} → (x == y → f x == f y) ap f idp = idp ap↓ : ∀ {i j k} {A : Type i} {B : A → Type j} {C : A → Type k} (g : {a : A} → B a → C a) {x y : A} {p : x == y} {u : B x} {v : B y} → (u == v [ B ↓ p ] → g u == g v [ C ↓ p ]) ap↓ g {p = idp} p = ap g p {- [apd↓] is defined in lib.PathOver. Unlike [ap↓] and [ap], [apd] is not definitionally a special case of [apd↓] -} apd : ∀ {i j} {A : Type i} {B : A → Type j} (f : (a : A) → B a) {x y : A} → (p : x == y) → f x == f y [ B ↓ p ] apd f idp = idp {- An equality between types gives two maps back and forth -} coe : ∀ {i} {A B : Type i} (p : A == B) → A → B coe idp x = x coe! : ∀ {i} {A B : Type i} (p : A == B) → B → A coe! idp x = x {- The operations of transport forward and backward are defined in terms of [ap] and [coe], because this is more convenient in practice. -} transport : ∀ {i j} {A : Type i} (B : A → Type j) {x y : A} (p : x == y) → (B x → B y) transport B p = coe (ap B p) transport! : ∀ {i j} {A : Type i} (B : A → Type j) {x y : A} (p : x == y) → (B y → B x) transport! B p = coe! (ap B p) {- Equational reasoning Equational reasoning is a way to write readable chains of equalities. The idea is that you can write the following: t : a == e t = a =⟨ p ⟩ b =⟨ q ⟩ c =⟨ r ⟩ d =⟨ s ⟩ e ∎ where [p] is a path from [a] to [b], [q] is a path from [b] to [c], and so on. You often have to apply some equality in some context, for instance [p] could be [ap ctx thm] where [thm] is the interesting theorem used to prove that [a] is equal to [b], and [ctx] is the context. In such cases, you can use instead [thm |in-ctx ctx]. The advantage is that [ctx] is usually boring whereas the first word of [thm] is the most interesting part. _=⟨_⟩ is not definitionally the same thing as concatenation of paths _∙_ because we haven’t defined concatenation of paths yet, and also you probably shouldn’t reason on paths constructed with equational reasoning. If you do want to reason on paths constructed with equational reasoning, check out lib.types.PathSeq instead. -} infix 2 _∎ infixr 2 _=⟨_⟩_ _=⟨_⟩_ : ∀ {i} {A : Type i} (x : A) {y z : A} → x == y → y == z → x == z _ =⟨ idp ⟩ idp = idp _∎ : ∀ {i} {A : Type i} (x : A) → x == x _ ∎ = idp syntax ap f p = p |in-ctx f {- Truncation levels The type of truncation levels is isomorphic to the type of natural numbers but "starts at -2". -} data TLevel : Type₀ where ⟨-2⟩ : TLevel succT : (n : TLevel) → TLevel ℕ₋₂ = TLevel ⟨-1⟩ : TLevel ⟨-1⟩ = succT ⟨-2⟩ ⟨0⟩ : TLevel ⟨0⟩ = succT ⟨-1⟩ {- Coproducts and case analysis -} data Coprod {i j} (A : Type i) (B : Type j) : Type (lmax i j) where inl : A → Coprod A B inr : B → Coprod A B {- Σ-types Σ-types are defined as a record so that we have definitional η. -} infix 1 _,_ record Σ {i j} (A : Type i) (B : A → Type j) : Type (lmax i j) where constructor _,_ field fst : A snd : B fst open Σ public pair= : ∀ {i j} {A : Type i} {B : A → Type j} {a a' : A} (p : a == a') {b : B a} {b' : B a'} (q : b == b' [ B ↓ p ]) → (a , b) == (a' , b') pair= idp q = ap (_,_ _) q pair×= : ∀ {i j} {A : Type i} {B : Type j} {a a' : A} (p : a == a') {b b' : B} (q : b == b') → (a , b) == (a' , b') pair×= idp q = pair= idp q {- Empty type We define the eliminator of the empty type using an absurd pattern. Given that absurd patterns are not consistent with HIT, we will not use empty patterns anymore after that. -} data Empty : Type₀ where Empty-elim : ∀ {i} {A : Empty → Type i} → ((x : Empty) → A x) Empty-elim () {- Negation and disequality -} ¬ : ∀ {i} (A : Type i) → Type i ¬ A = A → Empty _≠_ : ∀ {i} {A : Type i} → (A → A → Type i) x ≠ y = ¬ (x == y) -- Cartesian product _×_ : ∀ {i j} (A : Type i) (B : Type j) → Type _ A × B = Σ A (λ _ → B) ⊥ = Empty {- Π-types Shorter notation for Π-types. -} Π : ∀ {i j} (A : Type i) (P : A → Type j) → Type _ Π A P = (x : A) → P x {- Bool type -} data Bool : Type₀ where true : Bool false : Bool {- Equivalences -} module _ {i} {j} {A : Type i} {B : Type j} where record is-equiv (f : A → B) : Type (lmax i j) where field g : B → A f-g : (b : B) → f (g b) == b g-f : (a : A) → g (f a) == a adj : (a : A) → ap f (g-f a) == f-g (f a) {- Definition of contractible types and truncation levels -} module _ {i} where is-contr : Type i → Type i is-contr A = Σ A (λ a → ((x : A) → a == x)) has-level : ℕ₋₂ → (Type i → Type i) has-level ⟨-2⟩ A = is-contr A has-level (succT n) A = (x y : A) → has-level n (x == y) is-prop = has-level ⟨-1⟩ is-set = has-level ⟨0⟩
{ "alphanum_fraction": 0.5412459985, "avg_line_length": 26.5424836601, "ext": "agda", "hexsha": "7b66bae95454cba30bb630c8bc0474e45cdffb91", "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": "f8b6b11fb7ee0c54ce91a19338c5069a69a51dc7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "aerskine/hott-ex", "max_forks_repo_path": "Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f8b6b11fb7ee0c54ce91a19338c5069a69a51dc7", "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": "aerskine/hott-ex", "max_issues_repo_path": "Base.agda", "max_line_length": 93, "max_stars_count": null, "max_stars_repo_head_hexsha": "f8b6b11fb7ee0c54ce91a19338c5069a69a51dc7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "aerskine/hott-ex", "max_stars_repo_path": "Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3100, "size": 8122 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} open import Cubical.Core.Everything open import Cubical.Relation.Binary.Raw module Cubical.Relation.Binary.Reasoning.StrictPartialOrder {a ℓ} {A : Type a} (S : StrictPartialOrder A ℓ) where open StrictPartialOrder S import Cubical.Relation.Binary.Raw.Construct.StrictToNonStrict _<_ as NonStrict ------------------------------------------------------------------------ -- Publicly re-export the contents of the base module open import Cubical.Relation.Binary.Reasoning.Base.Double (NonStrict.isPreorder transitive) transitive NonStrict.<⇒≤ (NonStrict.<-≤-trans transitive) public
{ "alphanum_fraction": 0.6882716049, "avg_line_length": 30.8571428571, "ext": "agda", "hexsha": "38d01f8a3d08504ce80b05fa6eaee101a70ec1d0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Relation/Binary/Reasoning/StrictPartialOrder.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Relation/Binary/Reasoning/StrictPartialOrder.agda", "max_line_length": 79, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Relation/Binary/Reasoning/StrictPartialOrder.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 161, "size": 648 }
{-# OPTIONS --allow-exec #-} module ExecAgda where open import Agda.Builtin.Equality open import Agda.Builtin.List open import Agda.Builtin.Nat open import Agda.Builtin.Unit open import Agda.Builtin.Sigma open import Agda.Builtin.String open import Agda.Builtin.Reflection renaming (bindTC to _>>=_) open import Agda.Builtin.Reflection.External macro test : Term → TC ⊤ test hole = execTC "agda" ("-v0" ∷ "-i" ∷ "test/Succeed" ∷ "test/Succeed/exec-tc/empty.agda" ∷ []) "" >>= λ{(exitCode , (stdOut , stdErr)) → unify hole (lit (string stdOut))} _ : test ≡ "" _ = refl
{ "alphanum_fraction": 0.6945392491, "avg_line_length": 27.9047619048, "ext": "agda", "hexsha": "5ba187c9542ac041df1cc93c3f4ff5f04ecc7061", "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/ExecAgda.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/ExecAgda.agda", "max_line_length": 103, "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/ExecAgda.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 179, "size": 586 }
module Issue623.B where S : Set S = S
{ "alphanum_fraction": 0.6666666667, "avg_line_length": 7.8, "ext": "agda", "hexsha": "b3b5df767fa1b2d5b5bddd745ca37031d329bd60", "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/Issue623/B.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/Issue623/B.agda", "max_line_length": 23, "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/Issue623/B.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 14, "size": 39 }
module Options-in-right-order where data Unit : Set where unit : Unit postulate IO : Set → Set {-# COMPILED_TYPE IO IO #-} {-# BUILTIN IO IO #-} postulate return : {A : Set} → A → IO A {-# COMPILED return (\_ -> return) #-} main = return unit
{ "alphanum_fraction": 0.6156862745, "avg_line_length": 14.1666666667, "ext": "agda", "hexsha": "3c22218906118f340e2299d5cd9559a7f4d63bd8", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/Options-in-right-order.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/Options-in-right-order.agda", "max_line_length": 38, "max_stars_count": 1, "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/Options-in-right-order.agda", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "num_tokens": 75, "size": 255 }
module Numeral.Natural.Combinatorics.Proofs where open import Functional import Lvl open import Logic open import Logic.Propositional open import Numeral.Natural open import Numeral.Natural.Combinatorics open import Numeral.Natural.Oper open import Numeral.Natural.Oper.Proofs open import Numeral.Natural.Oper.Proofs.Multiplication open import Numeral.Natural.Relation open import Numeral.Natural.Relation.Order open import Numeral.Natural.Relation.Order.Proofs open import Relator.Equals open import Relator.Equals.Proofs open import Relator.Equals.Proofs.Equiv open import Structure.Setoid hiding (_≡_ ; _≢_) open import Structure.Function.Domain open import Structure.Function open import Structure.Operator.Proofs.Util open import Structure.Operator.Properties open import Structure.Operator open import Structure.Relator.Properties open import Syntax.Function open import Syntax.Transitivity open import Type factorial-non-zero : ∀{n} → ((n !) ≢ 𝟎) factorial-non-zero {𝟎} () factorial-non-zero {𝐒 n} p with [⋅]-product-is-0 {a = 𝐒 n}{b = n !} p ... | [∨]-introᵣ n!0 = factorial-non-zero {n} n!0 instance factorial-positive : ∀{n} → Positive(n !) factorial-positive {n} = non-zero-positive(factorial-non-zero {n}) -- Also called: Pascals's identity 𝑐𝐶-step : ∀{n k} → (𝑐𝐶 (𝐒(n)) (𝐒(k)) ≡ 𝑐𝐶 n k + 𝑐𝐶 n (𝐒(k))) 𝑐𝐶-step = [≡]-intro 𝑐𝐶-empty-subsets : ∀{n} → (𝑐𝐶 n 𝟎 ≡ 𝐒(𝟎)) 𝑐𝐶-empty-subsets {𝟎} = [≡]-intro 𝑐𝐶-empty-subsets {𝐒 n} = [≡]-intro 𝑐𝐶-singleton-subsets : ∀{n} → (𝑐𝐶 n (𝐒 𝟎) ≡ n) 𝑐𝐶-singleton-subsets {𝟎} = [≡]-intro 𝑐𝐶-singleton-subsets {𝐒 n} = congruence₁(𝐒) (𝑐𝐶-singleton-subsets {n}) {-# REWRITE 𝑐𝐶-singleton-subsets #-} 𝑐𝐶-larger-subsets : ∀{n k} → (n < k) → (𝑐𝐶 n k ≡ 𝟎) 𝑐𝐶-larger-subsets {𝟎} (succ _) = [≡]-intro 𝑐𝐶-larger-subsets {𝐒 n} {𝐒 k} (succ p) rewrite 𝑐𝐶-larger-subsets {n} {k} p rewrite 𝑐𝐶-larger-subsets {n} {𝐒 k} ([≤]-successor p) = [≡]-intro 𝑐𝐶-full-subsets : ∀{n} → (𝑐𝐶 n n ≡ 𝐒(𝟎)) 𝑐𝐶-full-subsets {𝟎} = [≡]-intro 𝑐𝐶-full-subsets {𝐒 n} rewrite 𝑐𝐶-full-subsets {n} rewrite 𝑐𝐶-larger-subsets {n}{𝐒 n} (reflexivity(_≤_)) = [≡]-intro 𝑐𝐶-excluding-single-subsets : ∀{n} → (𝑐𝐶 (𝐒 n) n ≡ 𝐒(n)) 𝑐𝐶-excluding-single-subsets {𝟎} = [≡]-intro 𝑐𝐶-excluding-single-subsets {𝐒 n} rewrite 𝑐𝐶-excluding-single-subsets {n} rewrite 𝑐𝐶-full-subsets {n} rewrite 𝑐𝐶-larger-subsets {n}{𝐒 n} (reflexivity(_≤_)) = [≡]-intro {- 𝑐𝐶-test2 : ∀{k₁ k₂} → (𝑐𝐶 (𝐒(k₁ + k₂)) k₁ + 𝑐𝐶 (k₁ + k₂) (𝐒 k₁) ≡ 𝑐𝐶 (𝐒(k₁ + k₂)) k₂ + 𝑐𝐶 (k₁ + k₂) (𝐒 k₂)) 𝑐𝐶-test2 {𝟎} {𝟎} = [≡]-intro 𝑐𝐶-test2 {𝟎} {𝐒 k₂} rewrite 𝑐𝐶-full-subsets {k₂} rewrite 𝑐𝐶-larger-subsets {k₂} (reflexivity(_≤_)) rewrite 𝑐𝐶-larger-subsets {k₂} ([≤]-successor(reflexivity(_≤_))) rewrite 𝑐𝐶-excluding-single-subsets {k₂} = [≡]-intro 𝑐𝐶-test2 {𝐒 k₁} {𝟎} rewrite 𝑐𝐶-full-subsets {k₁} rewrite 𝑐𝐶-larger-subsets {k₁} (reflexivity(_≤_)) rewrite 𝑐𝐶-larger-subsets {k₁} ([≤]-successor(reflexivity(_≤_))) rewrite 𝑐𝐶-excluding-single-subsets {k₁} = [≡]-intro 𝑐𝐶-test2 {𝐒 k₁} {𝐒 k₂} -- rewrite test2 {k₁ + k₂} {k₁} {k₂} [≡]-intro -- rewrite test2 {𝐒(k₁ + k₂)} {𝐒 k₁} {k₂} [≡]-intro -- rewrite test2 {𝐒(k₁ + k₂)} {k₁} {𝐒 k₂} [≡]-intro = {!!} 𝑐𝐶-symmetric : ∀{n k₁ k₂} → (k₁ + k₂ ≡ n) → (𝑐𝐶 n k₁ ≡ 𝑐𝐶 n k₂) 𝑐𝐶-symmetric {𝟎} {𝟎} {𝟎} x = [≡]-intro 𝑐𝐶-symmetric {𝐒 n} {𝟎} {𝐒 .n} [≡]-intro rewrite 𝑐𝐶-full-subsets {n} rewrite 𝑐𝐶-larger-subsets {n} (reflexivity(_≤_)) = [≡]-intro 𝑐𝐶-symmetric {𝐒 n} {𝐒 .n} {𝟎} [≡]-intro rewrite 𝑐𝐶-full-subsets {n} rewrite 𝑐𝐶-larger-subsets {n} (reflexivity(_≤_)) = [≡]-intro 𝑐𝐶-symmetric {𝐒 .(𝐒(k₁ + k₂))} {𝐒 k₁} {𝐒 k₂} [≡]-intro = 𝑐𝐶 (𝐒(𝐒(k₁ + k₂))) (𝐒 k₁) 🝖[ _≡_ ]-[] 𝑐𝐶 (𝐒(k₁ + k₂)) k₁ + 𝑐𝐶 (𝐒(k₁ + k₂)) (𝐒 k₁) 🝖[ _≡_ ]-[] 𝑐𝐶 (𝐒(k₁ + k₂)) k₁ + (𝑐𝐶 (k₁ + k₂) k₁ + 𝑐𝐶 (k₁ + k₂) (𝐒 k₁)) 🝖[ _≡_ ]-[ One.commuteₗ-assocᵣ {_▫_ = _+_}{a = 𝑐𝐶 (𝐒(k₁ + k₂)) k₁}{b = 𝑐𝐶 (k₁ + k₂) k₁}{c = 𝑐𝐶 (k₁ + k₂) (𝐒 k₁)} ] 𝑐𝐶 (k₁ + k₂) k₁ + (𝑐𝐶 (𝐒(k₁ + k₂)) k₁ + 𝑐𝐶 (k₁ + k₂) (𝐒 k₁)) 🝖[ _≡_ ]-[ congruence₂(_+_) (𝑐𝐶-symmetric {k₁ + k₂} {k₁} {k₂} [≡]-intro) (𝑐𝐶-test2 {k₁}{k₂}) ] 𝑐𝐶 (k₁ + k₂) k₂ + (𝑐𝐶 (𝐒(k₁ + k₂)) k₂ + 𝑐𝐶 (k₁ + k₂) (𝐒 k₂)) 🝖[ _≡_ ]-[ One.commuteₗ-assocᵣ {_▫_ = _+_}{a = 𝑐𝐶 (𝐒(k₁ + k₂)) k₂}{b = 𝑐𝐶 (k₁ + k₂) k₂}{c = 𝑐𝐶 (k₁ + k₂) (𝐒 k₂)} ]-sym 𝑐𝐶 (𝐒(k₁ + k₂)) k₂ + (𝑐𝐶 (k₁ + k₂) k₂ + 𝑐𝐶 (k₁ + k₂) (𝐒 k₂)) 🝖[ _≡_ ]-[] 𝑐𝐶 (𝐒(k₁ + k₂)) k₂ + 𝑐𝐶 (𝐒(k₁ + k₂)) (𝐒 k₂) 🝖[ _≡_ ]-[] 𝑐𝐶 (𝐒(𝐒(k₁ + k₂))) (𝐒 k₂) 🝖-end -} -- ∀{n k} → 𝑐𝐶 n k ≡ 𝑐𝐶 n (n−k) -- ∀{n k} → 𝑐𝐶 (𝐒 n) (𝐒 k) ≡ 𝑐𝐶 n k ⋅ (𝐒 n) / (𝐒 k) -- ∀{n} → (∑(𝟎 ‥ n) (𝑐𝐶 n) ≡ 2 ^ n) -- ∀{n k} → (𝑐𝐶 (𝐒 n) (𝐒 k) ≡ ∑(0 ‥ n) (i ↦ 𝑐𝐶 i k) = ∑(k ‥ n) (i ↦ 𝑐𝐶 i k)) 𝑐𝑃-empty : ∀{n} → (𝑐𝑃 n 𝟎 ≡ 𝐒(𝟎)) 𝑐𝑃-empty {𝟎} = [≡]-intro 𝑐𝑃-empty {𝐒 n} = [≡]-intro 𝑐𝑃-singleton : ∀{n} → (𝑐𝑃 n (𝐒 𝟎) ≡ n) 𝑐𝑃-singleton {𝟎} = [≡]-intro 𝑐𝑃-singleton {𝐒 n} = [≡]-intro {-# REWRITE 𝑐𝑃-singleton #-} 𝑐𝑃-step-diff : ∀{n k} → (𝑐𝑃 n k ⋅ n ≡ 𝑐𝑃 n k ⋅ k + 𝑐𝑃 n (𝐒 k)) -- TODO: Prove this for 𝑐𝐶 by using 𝑐𝐶-permutations-is-𝑐𝑃 𝑐𝑃-step-diff {𝟎} {𝟎} = [≡]-intro 𝑐𝑃-step-diff {𝟎} {𝐒 k} = [≡]-intro 𝑐𝑃-step-diff {𝐒 n} {𝟎} = [≡]-intro 𝑐𝑃-step-diff {𝐒 n} {𝐒 k} = 𝑐𝑃 (𝐒 n) (𝐒 k) ⋅ (𝐒 n) 🝖[ _≡_ ]-[] (𝑐𝑃 n k ⋅ (𝐒 n)) ⋅ (𝐒 n) 🝖[ _≡_ ]-[] (𝑐𝑃 n k + 𝑐𝑃 n k ⋅ n) ⋅ (𝐒 n) 🝖[ _≡_ ]-[ distributivityᵣ(_⋅_)(_+_) {x = 𝑐𝑃 n k}{y = 𝑐𝑃 n k ⋅ n}{z = 𝐒 n} ] (𝑐𝑃 n k ⋅ (𝐒 n)) + ((𝑐𝑃 n k ⋅ n) ⋅ (𝐒 n)) 🝖[ _≡_ ]-[ congruence₂(_+_) (reflexivity(_≡_) {x = 𝑐𝑃 (𝐒 n) (𝐒 k)}) proof1 ] 𝑐𝑃 (𝐒 n) (𝐒 k) + ((𝑐𝑃 (𝐒 n) (𝐒 k) ⋅ k) + 𝑐𝑃 (𝐒 n) (𝐒(𝐒 k))) 🝖[ _≡_ ]-[ associativity(_+_) {x = 𝑐𝑃 (𝐒 n) (𝐒 k)}{y = 𝑐𝑃 (𝐒 n) (𝐒 k) ⋅ k}{z = 𝑐𝑃 (𝐒 n) (𝐒(𝐒 k))} ]-sym (𝑐𝑃 (𝐒 n) (𝐒 k) + (𝑐𝑃 (𝐒 n) (𝐒 k) ⋅ k)) + 𝑐𝑃 (𝐒 n) (𝐒(𝐒 k)) 🝖[ _≡_ ]-[] (𝑐𝑃 (𝐒 n) (𝐒 k) ⋅ 𝐒 k) + 𝑐𝑃 (𝐒 n) (𝐒(𝐒 k)) 🝖-end where proof2 = (𝑐𝑃 n k ⋅ k) ⋅ (𝐒 n) 🝖[ _≡_ ]-[ One.commuteᵣ-assocₗ {_▫_ = _⋅_}{a = 𝑐𝑃 n k}{b = k}{c = 𝐒 n} ] (𝑐𝑃 n k ⋅ (𝐒 n)) ⋅ k 🝖[ _≡_ ]-[] 𝑐𝑃 (𝐒 n) (𝐒 k) ⋅ k 🝖-end proof1 = (𝑐𝑃 n k ⋅ n) ⋅ (𝐒 n) 🝖[ _≡_ ]-[ congruence₂ₗ(_⋅_)(𝐒 n) (𝑐𝑃-step-diff {n}{k}) ] (𝑐𝑃 n k ⋅ k + 𝑐𝑃 n (𝐒 k)) ⋅ (𝐒 n) 🝖[ _≡_ ]-[ distributivityᵣ(_⋅_)(_+_) {x = 𝑐𝑃 n k ⋅ k}{y = 𝑐𝑃 n (𝐒 k)}{z = 𝐒 n} ] ((𝑐𝑃 n k ⋅ k) ⋅ (𝐒 n)) + (𝑐𝑃 n (𝐒 k) ⋅ (𝐒 n)) 🝖[ _≡_ ]-[ congruence₂(_+_) proof2 (reflexivity(_≡_)) ] (𝑐𝑃 (𝐒 n) (𝐒 k) ⋅ k) + 𝑐𝑃 (𝐒 n) (𝐒(𝐒 k)) 🝖-end 𝑐𝑃-step-alt : ∀{n k} → (𝑐𝑃 (𝐒 n) (𝐒 k) ≡ (𝑐𝑃 n k ⋅ 𝐒 k) + 𝑐𝑃 n (𝐒 k)) 𝑐𝑃-step-alt {n}{k} rewrite 𝑐𝑃-step-diff {n}{k} = symmetry(_≡_) (associativity(_+_) {x = 𝑐𝑃 n k}{y = 𝑐𝑃 n k ⋅ k}{z = 𝑐𝑃 n (𝐒 k)}) 𝑐𝐶-permutations-is-𝑐𝑃 : ∀{n k} → (𝑐𝐶 n k ⋅ (k !) ≡ 𝑐𝑃 n k) 𝑐𝐶-permutations-is-𝑐𝑃 {𝟎} {𝟎} = [≡]-intro 𝑐𝐶-permutations-is-𝑐𝑃 {𝟎} {𝐒 k} = [≡]-intro 𝑐𝐶-permutations-is-𝑐𝑃 {𝐒 n} {𝟎} = [≡]-intro 𝑐𝐶-permutations-is-𝑐𝑃 {𝐒 n} {𝐒 k} = (𝑐𝐶 n k + 𝑐𝐶 n (𝐒 k)) ⋅ (𝐒 k ⋅ (k !)) 🝖-[ distributivityᵣ(_⋅_)(_+_) {x = 𝑐𝐶 n k}{y = 𝑐𝐶 n (𝐒 k)}{z = 𝐒 k ⋅ (k !)} ] (𝑐𝐶 n k ⋅ (𝐒 k ⋅ (k !))) + (𝑐𝐶 n (𝐒 k) ⋅ (𝐒 k ⋅ (k !))) 🝖-[ congruence₂(_+_) l r ] (𝑐𝑃 n k ⋅ 𝐒 k) + 𝑐𝑃 n (𝐒 k) 🝖-[ 𝑐𝑃-step-alt {n}{k} ]-sym 𝑐𝑃 n k ⋅ 𝐒 n 🝖-end where l = 𝑐𝐶 n k ⋅ (𝐒 k ⋅ (k !)) 🝖-[ congruence₂ᵣ(_⋅_)(𝑐𝐶 n k) (commutativity(_⋅_) {𝐒 k}{k !}) ] 𝑐𝐶 n k ⋅ ((k !) ⋅ 𝐒 k) 🝖-[ associativity(_⋅_) {x = 𝑐𝐶 n k}{y = k !}{z = 𝐒 k} ]-sym (𝑐𝐶 n k ⋅ (k !)) ⋅ 𝐒 k 🝖-[ congruence₂ₗ(_⋅_)(𝐒 k) (𝑐𝐶-permutations-is-𝑐𝑃 {n} {k}) ] 𝑐𝑃 n k ⋅ 𝐒 k 🝖-end r = 𝑐𝐶 n (𝐒 k) ⋅ (𝐒 k ⋅ (k !)) 🝖[ _≡_ ]-[] 𝑐𝐶 n (𝐒 k) ⋅ ((𝐒 k)!) 🝖[ _≡_ ]-[ 𝑐𝐶-permutations-is-𝑐𝑃 {n} {𝐒 k} ] 𝑐𝑃 n (𝐒 k) 🝖-end 𝑐𝑃-full : ∀{n} → (𝑐𝑃 n n ≡ n !) 𝑐𝑃-full {n} = 𝑐𝑃 n n 🝖[ _≡_ ]-[ 𝑐𝐶-permutations-is-𝑐𝑃 {n}{n} ]-sym 𝑐𝐶 n n ⋅ (n !) 🝖[ _≡_ ]-[ congruence₂ₗ(_⋅_)(n !) (𝑐𝐶-full-subsets {n}) ] 𝐒(𝟎) ⋅ (n !) 🝖[ _≡_ ]-[] n ! 🝖-end 𝑐𝐶-step-diff : ∀{n k} → (𝑐𝐶 n k ⋅ n ≡ (𝑐𝐶 n k ⋅ k) + (𝑐𝐶 n (𝐒 k) ⋅ (𝐒 k))) 𝑐𝐶-step-diff {n}{k} = [⋅]-cancellationᵣ {x = k !} ⦃ factorial-positive {k} ⦄ $ (𝑐𝐶 n k ⋅ n) ⋅ (k !) 🝖[ _≡_ ]-[ One.commuteᵣ-assocₗ {_▫_ = _⋅_}{a = 𝑐𝐶 n k}{b = n}{c = k !} ] (𝑐𝐶 n k ⋅ (k !)) ⋅ n 🝖[ _≡_ ]-[ congruence₁(_⋅ n) (𝑐𝐶-permutations-is-𝑐𝑃 {n}{k}) ] 𝑐𝑃 n k ⋅ n 🝖[ _≡_ ]-[ 𝑐𝑃-step-diff {n}{k} ] 𝑐𝑃 n k ⋅ k + 𝑐𝑃 n (𝐒 k) 🝖[ _≡_ ]-[ congruence₂(_+_) (congruence₁(_⋅ k) (symmetry(_≡_) (𝑐𝐶-permutations-is-𝑐𝑃 {n}{k}))) (symmetry(_≡_) (𝑐𝐶-permutations-is-𝑐𝑃 {n}{𝐒 k})) ] (𝑐𝐶 n k ⋅ (k !)) ⋅ k + (𝑐𝐶 n (𝐒 k) ⋅ ((𝐒 k) !)) 🝖[ _≡_ ]-[] (𝑐𝐶 n k ⋅ (k !)) ⋅ k + (𝑐𝐶 n (𝐒 k) ⋅ ((𝐒 k) ⋅ (k !))) 🝖[ _≡_ ]-[ congruence₂(_+_) (One.commuteᵣ-assocₗ {_▫_ = _⋅_}{a = 𝑐𝐶 n k}{b = k !}{c = k}) (symmetry(_≡_) (associativity(_⋅_) {x = 𝑐𝐶 n (𝐒 k)}{y = 𝐒 k}{z = k !})) ] (𝑐𝐶 n k ⋅ k) ⋅ (k !) + ((𝑐𝐶 n (𝐒 k) ⋅ (𝐒 k)) ⋅ (k !)) 🝖[ _≡_ ]-[ distributivityᵣ(_⋅_)(_+_) {x = 𝑐𝐶 n k ⋅ k}{y = 𝑐𝐶 n (𝐒 k) ⋅ (𝐒 k)}{z = k !} ]-sym ((𝑐𝐶 n k ⋅ k) + (𝑐𝐶 n (𝐒 k) ⋅ (𝐒 k))) ⋅ (k !) 🝖-end {- -- Note: This is a variant of the usual definition of 𝑐𝐶 (The usual one: 𝑐𝐶 n k = (n !) / ((k !) ⋅ (n − k)!)). factorial-of-[+] : ∀{k₁ k₂} → ((k₁ + k₂)! ≡ (k₁ !) ⋅ (k₂ !) ⋅ 𝑐𝐶 (k₁ + k₂) k₁) factorial-of-[+] {𝟎} {k₂} = [≡]-intro factorial-of-[+] {𝐒 k₁} {k₂} = ((𝐒(k₁) + k₂) !) 🝖[ _≡_ ]-[] (𝐒(k₁ + k₂) !) 🝖[ _≡_ ]-[] 𝐒(k₁ + k₂) ⋅ ((k₁ + k₂) !) 🝖[ _≡_ ]-[ congruence₂ᵣ(_⋅_)(𝐒(k₁ + k₂)) (factorial-of-[+] {k₁} {k₂}) ] 𝐒(k₁ + k₂) ⋅ ((k₁ !) ⋅ (k₂ !) ⋅ 𝑐𝐶 (k₁ + k₂) k₁) 🝖[ _≡_ ]-[] (𝐒(k₁) + k₂) ⋅ ((k₁ !) ⋅ (k₂ !) ⋅ 𝑐𝐶 (k₁ + k₂) k₁) 🝖[ _≡_ ]-[ {!!} ] ((𝐒(k₁) + k₂) ⋅ (k₁ !)) ⋅ ((k₂ !) ⋅ 𝑐𝐶 (k₁ + k₂) k₁) 🝖[ _≡_ ]-[ {!!} ] ((𝐒(k₁) ⋅ (k₁ !)) + (k₂ ⋅ (k₁ !))) ⋅ ((k₂ !) ⋅ 𝑐𝐶 (k₁ + k₂) k₁) 🝖[ _≡_ ]-[ {!!} ] ((𝐒(k₁) !) + (k₂ ⋅ (k₁ !))) ⋅ ((k₂ !) ⋅ 𝑐𝐶 (k₁ + k₂) k₁) 🝖[ _≡_ ]-[ {!!} ] (𝐒(k₁) !) ⋅ (k₂ !) ⋅ 𝑐𝐶(𝐒(k₁) + k₂) (𝐒(k₁)) 🝖-end 𝐒 k₁ ⋅ (k₁ !) ⋅ (k₂ !) ⋅ (𝑐𝐶 (k₁ + k₂) k₁ + 𝑐𝐶 (k₁ + k₂) (𝐒 k₁)) -} {-factorial-of-[+] {𝟎} {𝟎} = [≡]-intro factorial-of-[+] {𝟎} {𝐒 k₂} = [≡]-intro factorial-of-[+] {𝐒 k₁} {𝟎} rewrite 𝑐𝐶-full-subsets {k₁} rewrite 𝑐𝐶-larger-subsets {k₁} {𝐒 k₁} (reflexivity(_≤_)) = [≡]-intro factorial-of-[+] {𝐒 k₁} {𝐒 k₂} = {!!} 𝐒(𝐒(k₁ + k₂)) ⋅ (𝐒(k₁ + k₂) ⋅ ((k₁ + k₂)!)) 𝐒(𝐒(k₁ + k₂)) ⋅ (𝐒(k₁ + k₂) ⋅ ((k₁ !) ⋅ (k₂ !) ⋅ 𝑐𝐶 (k₁ + k₂) k₁)) 𝐒(k₁) ⋅ (k₁ !) ⋅ (𝐒 k₂ ⋅ (k₂ !)) ⋅ (𝑐𝐶 (𝐒(k₁ + k₂)) k₁ + (𝑐𝐶 (k₁ + k₂) k₁ + 𝑐𝐶 (k₁ + k₂) (𝐒 k₁))) -} {- -- Note: This is a variant of the usual definition of 𝑐𝑃 (The usual one: 𝑐𝑃 n k = (n !) / ((n − k)!)). factorial-of-[+]-𝑐𝑃 : ∀{k₁ k₂} → ((k₁ + k₂)! ≡ 𝑐𝑃 (k₁ + k₂) k₂ ⋅ (k₁ !)) factorial-of-[+]-𝑐𝑃 {𝟎} {𝟎} = [≡]-intro factorial-of-[+]-𝑐𝑃 {𝟎} {𝐒 k₂} rewrite 𝑐𝑃-full {k₂} = 𝐒 k₂ ⋅ (k₂ !) 🝖[ _≡_ ]-[ commutativity(_⋅_) {𝐒 k₂}{k₂ !} ] (k₂ !) ⋅ 𝐒 k₂ 🝖[ _≡_ ]-[] (k₂ !) + (k₂ !) ⋅ k₂ 🝖-end factorial-of-[+]-𝑐𝑃 {𝐒 k₁} {𝟎} = [≡]-intro factorial-of-[+]-𝑐𝑃 {𝐒 k₁} {𝐒 k₂} = {!!} 𝐒(𝐒(k₁ + k₂)) ⋅ (𝐒(k₁ + k₂) ⋅ ((k₁ + k₂)!)) 𝐒(𝐒(k₁ + k₂)) ⋅ (𝐒(k₁ + k₂) ⋅ (𝑐𝑃 (k₁ + k₂) k₂ ⋅ (k₁ !))) (𝑐𝑃 (𝐒(k₁ + k₂)) k₂ + (𝑐𝑃 (𝐒(k₁ + k₂)) k₂ + 𝑐𝑃 (𝐒(k₁ + k₂)) k₂ ⋅ (k₁ + k₂))) ⋅ (𝐒 k₁ ⋅ (k₁ !)) -}
{ "alphanum_fraction": 0.4684929109, "avg_line_length": 47.2148760331, "ext": "agda", "hexsha": "24a1edddf0939af1ea60eedf5985dff0f9aac1ae", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Numeral/Natural/Combinatorics/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/Combinatorics/Proofs.agda", "max_line_length": 219, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Numeral/Natural/Combinatorics/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": 7177, "size": 11426 }
------------------------------------------------------------------------ -- Parallel substitutions (defined as functions) ------------------------------------------------------------------------ open import Data.Universe.Indexed module deBruijn.Substitution.Function.Basics {i u e} {Uni : IndexedUniverse i u e} where import Axiom.Extensionality.Propositional as E import deBruijn.Context; open deBruijn.Context Uni open import Function using (id; _∘_; _$_) open import Level using (_⊔_) open import Relation.Binary.PropositionalEquality as P using (_≡_) open P.≡-Reasoning -- Substitutions, represented as functions from variables to terms. Sub : ∀ {t} (T : Term-like t) {Γ Δ : Ctxt} → Γ ⇨̂ Δ → Set _ Sub T = [ Var ⟶ T ] private module Dummy {t} {T : Term-like t} where open Term-like T -- Interpretation of substitutions: context morphisms. ⟦_⟧⇨ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} → Sub T ρ̂ → Γ ⇨̂ Δ ⟦_⟧⇨ {ρ̂ = ρ̂} _ = ρ̂ -- Application of substitutions to types. infixl 8 _/I_ _/_ _/I_ : ∀ {Γ Δ i} {ρ̂ : Γ ⇨̂ Δ} → IType Γ i → Sub T ρ̂ → IType Δ i σ /I ρ = σ /̂I ⟦ ρ ⟧⇨ _/_ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} → Type Γ → Sub T ρ̂ → Type Δ σ / ρ = σ /̂ ⟦ ρ ⟧⇨ -- Application of substitutions to values. infixl 8 _/Val_ _/Val_ : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} → Value Γ σ → Sub T ρ̂ → Value Δ (σ /̂ ρ̂) v /Val ρ = v /̂Val ⟦ ρ ⟧⇨ -- Application of substitutions to context extensions. infixl 8 _/⁺_ _/₊_ _/⁺_ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} → Ctxt⁺ Γ → Sub T ρ̂ → Ctxt⁺ Δ Γ⁺ /⁺ ρ = Γ⁺ /̂⁺ ⟦ ρ ⟧⇨ _/₊_ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} → Ctxt₊ Γ → Sub T ρ̂ → Ctxt₊ Δ Γ₊ /₊ ρ = Γ₊ /̂₊ ⟦ ρ ⟧⇨ -- Application of substitutions to variables. infixl 8 _/∋_ _/∋-lemma_ _/∋_ : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} → Γ ∋ σ → (ρ : Sub T ρ̂) → Δ ⊢ σ / ρ x /∋ ρ = ρ · x _/∋-lemma_ : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} (x : Γ ∋ σ) (ρ : Sub T ρ̂) → x /̂∋ ⟦ ρ ⟧⇨ ≅-Value ⟦ x /∋ ρ ⟧ x /∋-lemma ρ = corresponds ρ x app∋ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} → Sub T ρ̂ → [ Var ⟶ T ] ρ̂ app∋ ρ = record { function = λ _ x → x /∋ ρ ; corresponds = λ _ x → x /∋-lemma ρ } -- Empty substitution. ε⇨ : ∀ {Δ} → Sub T ε̂[ Δ ] ε⇨ = record { function = λ _ (); corresponds = λ _ () } ε⇨[_] : ∀ Δ → Sub T ε̂[ Δ ] ε⇨[ _ ] = ε⇨ -- Extends a substitution with another term. private -- This function is not local to _▻⇨[_]_ because a proof below -- fails to type check if the function depends on the proof -- component of the substitution. fun : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} → (∀ {τ} → Γ ∋ τ → Δ ⊢ τ /̂ ρ̂) → (t : Δ ⊢ σ /̂ ρ̂) → ∀ {τ} → Γ ▻ σ ∋ τ → Δ ⊢ τ /̂ (ρ̂ ▻̂ ⟦ t ⟧) fun f t zero = t fun f t (suc x) = f x infixl 5 _▻⇨_ _▻⇨[_]_ _▻⇨[_]_ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} (ρ : Sub T ρ̂) σ (t : Δ ⊢ σ / ρ) → Sub T (ρ̂ ▻̂[ σ ] ⟦ t ⟧) _▻⇨[_]_ {Γ} {Δ} {ρ̂} ρ σ t = record { function = λ _ → fun (_·_ ρ) t; corresponds = λ _ → corr } where abstract corr : ∀ {τ} (x : Γ ▻ σ ∋ τ) → x /̂∋ (ρ̂ ▻̂ ⟦ t ⟧) ≅-Value ⟦ fun (_·_ ρ) t x ⟧ corr zero = P.refl corr (suc x) = x /∋-lemma ρ _▻⇨_ : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} (ρ : Sub T ρ̂) (t : Δ ⊢ σ / ρ) → Sub T (ρ̂ ▻̂[ σ ] ⟦ t ⟧) ρ ▻⇨ t = ρ ▻⇨[ _ ] t -- The tail of a nonempty substitution. tail : ∀ {Γ Δ σ} {ρ̂ : Γ ▻ σ ⇨̂ Δ} → Sub T ρ̂ → Sub T (t̂ail ρ̂) tail ρ = ρ [∘] weaken∋ -- The head of a nonempty substitution. head : ∀ {Γ Δ σ} {ρ̂ : Γ ▻ σ ⇨̂ Δ} (ρ : Sub T ρ̂) → Δ ⊢ σ / tail ρ head ρ = zero /∋ ρ head-lemma : ∀ {Γ Δ σ} {ρ̂ : Γ ▻ σ ⇨̂ Δ} (ρ : Sub T ρ̂) → ĥead ⟦ ρ ⟧⇨ ≅-Value ⟦ head ρ ⟧ head-lemma ρ = zero /∋-lemma ρ -- Equality of substitutions. infix 4 _≅-⇨_ _≅-⇨_ : ∀ {Γ₁ Δ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} (ρ₁ : Sub T ρ̂₁) {Γ₂ Δ₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} (ρ₂ : Sub T ρ̂₂) → Set _ _≅-⇨_ = _≅-⟶_ -- Certain uses of substitutivity can be removed. drop-subst-Sub : ∀ {a} {A : Set a} {x₁ x₂ : A} {Γ Δ} (f : A → Γ ⇨̂ Δ) {ρ} (eq : x₁ ≡ x₂) → P.subst (λ x → Sub T (f x)) eq ρ ≅-⇨ ρ drop-subst-Sub f P.refl = [ P.refl ] -- Some congruence lemmas. ε⇨-cong : ∀ {Δ₁ Δ₂} → Δ₁ ≅-Ctxt Δ₂ → ε⇨[ Δ₁ ] ≅-⇨ ε⇨[ Δ₂ ] ε⇨-cong P.refl = [ P.refl ] ▻⇨-cong : ∀ {Γ₁ Δ₁ σ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρ₁ : Sub T ρ̂₁} {t₁ : Δ₁ ⊢ σ₁ / ρ₁} {Γ₂ Δ₂ σ₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρ₂ : Sub T ρ̂₂} {t₂ : Δ₂ ⊢ σ₂ / ρ₂} → σ₁ ≅-Type σ₂ → ρ₁ ≅-⇨ ρ₂ → t₁ ≅-⊢ t₂ → ρ₁ ▻⇨[ σ₁ ] t₁ ≅-⇨ ρ₂ ▻⇨[ σ₂ ] t₂ ▻⇨-cong {ρ₁ = _ , _} {ρ₂ = ._ , _} P.refl [ P.refl ] P.refl = [ P.refl ] ⟦⟧⇨-cong : ∀ {Γ₁ Δ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρ₁ : Sub T ρ̂₁} {Γ₂ Δ₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρ₂ : Sub T ρ̂₂} → ρ₁ ≅-⇨ ρ₂ → ⟦ ρ₁ ⟧⇨ ≅-⇨̂ ⟦ ρ₂ ⟧⇨ ⟦⟧⇨-cong {ρ₁ = _ , _} {ρ₂ = ._ , _} [ P.refl ] = P.refl /I-cong : ∀ {i} {Γ₁ Δ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {σ₁ : IType Γ₁ i} {ρ₁ : Sub T ρ̂₁} {Γ₂ Δ₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {σ₂ : IType Γ₂ i} {ρ₂ : Sub T ρ̂₂} → σ₁ ≅-IType σ₂ → ρ₁ ≅-⇨ ρ₂ → σ₁ /I ρ₁ ≅-IType σ₂ /I ρ₂ /I-cong {ρ₁ = _ , _} {ρ₂ = ._ , _} P.refl [ P.refl ] = P.refl /-cong : ∀ {Γ₁ Δ₁ σ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρ₁ : Sub T ρ̂₁} {Γ₂ Δ₂ σ₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρ₂ : Sub T ρ̂₂} → σ₁ ≅-Type σ₂ → ρ₁ ≅-⇨ ρ₂ → σ₁ / ρ₁ ≅-Type σ₂ / ρ₂ /-cong {ρ₁ = _ , _} {ρ₂ = ._ , _} P.refl [ P.refl ] = P.refl /⁺-cong : ∀ {Γ₁ Δ₁ Γ⁺₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρ₁ : Sub T ρ̂₁} {Γ₂ Δ₂ Γ⁺₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρ₂ : Sub T ρ̂₂} → Γ⁺₁ ≅-Ctxt⁺ Γ⁺₂ → ρ₁ ≅-⇨ ρ₂ → Γ⁺₁ /⁺ ρ₁ ≅-Ctxt⁺ Γ⁺₂ /⁺ ρ₂ /⁺-cong {ρ₁ = _ , _} {ρ₂ = ._ , _} P.refl [ P.refl ] = P.refl /₊-cong : ∀ {Γ₁ Δ₁ Γ₊₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρ₁ : Sub T ρ̂₁} {Γ₂ Δ₂ Γ₊₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρ₂ : Sub T ρ̂₂} → Γ₊₁ ≅-Ctxt₊ Γ₊₂ → ρ₁ ≅-⇨ ρ₂ → Γ₊₁ /₊ ρ₁ ≅-Ctxt₊ Γ₊₂ /₊ ρ₂ /₊-cong {ρ₁ = _ , _} {ρ₂ = ._ , _} P.refl [ P.refl ] = P.refl /∋-cong : ∀ {Γ₁ Δ₁ σ₁} {x₁ : Γ₁ ∋ σ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρ₁ : Sub T ρ̂₁} {Γ₂ Δ₂ σ₂} {x₂ : Γ₂ ∋ σ₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρ₂ : Sub T ρ̂₂} → x₁ ≅-∋ x₂ → ρ₁ ≅-⇨ ρ₂ → x₁ /∋ ρ₁ ≅-⊢ x₂ /∋ ρ₂ /∋-cong {ρ₁ = _ , _} {ρ₂ = ._ , _} P.refl [ P.refl ] = P.refl tail-cong : ∀ {Γ₁ Δ₁ σ₁} {ρ̂₁ : Γ₁ ▻ σ₁ ⇨̂ Δ₁} {ρ₁ : Sub T ρ̂₁} {Γ₂ Δ₂ σ₂} {ρ̂₂ : Γ₂ ▻ σ₂ ⇨̂ Δ₂} {ρ₂ : Sub T ρ̂₂} → ρ₁ ≅-⇨ ρ₂ → tail ρ₁ ≅-⇨ tail ρ₂ tail-cong {ρ₁ = _ , _} {ρ₂ = ._ , _} [ P.refl ] = [ P.refl ] head-cong : ∀ {Γ₁ Δ₁ σ₁} {ρ̂₁ : Γ₁ ▻ σ₁ ⇨̂ Δ₁} {ρ₁ : Sub T ρ̂₁} {Γ₂ Δ₂ σ₂} {ρ̂₂ : Γ₂ ▻ σ₂ ⇨̂ Δ₂} {ρ₂ : Sub T ρ̂₂} → ρ₁ ≅-⇨ ρ₂ → head ρ₁ ≅-⊢ head ρ₂ head-cong {ρ₁ = _ , _} {ρ₂ = ._ , _} [ P.refl ] = P.refl abstract -- Some eta-laws, based on the assumption of extensionality. -- Eta in empty contexts. ηε : E.Extensionality (i ⊔ u ⊔ e) (i ⊔ u ⊔ e ⊔ t) → ∀ {Δ} {ρ̂ : ε ⇨̂ Δ} (ρ : Sub T ρ̂) → ρ ≅-⇨ ε⇨[ Δ ] ηε ext ρ = extensional-equality₁ ext P.refl (λ ()) -- Eta in non-empty contexts. η▻ : E.Extensionality (i ⊔ u ⊔ e) (i ⊔ u ⊔ e ⊔ t) → ∀ {Γ Δ σ} {ρ̂ : Γ ▻ σ ⇨̂ Δ} (ρ : Sub T ρ̂) → ρ ≅-⇨ tail ρ ▻⇨[ σ ] head ρ η▻ ext {Γ} {σ = σ} {ρ̂} ρ = extensional-equality₂ ext lemma₁ lemma₂ where open Term-like Var using () renaming (_≅-⊢_ to _≅-∋′_) lemma₁ : ρ̂ ≅-⇨̂ t̂ail ρ̂ ▻̂[ σ ] ⟦ head ρ ⟧ lemma₁ = begin [ ρ̂ ] ≡⟨ P.refl ⟩ [ t̂ail ρ̂ ▻̂ ĥead ρ̂ ] ≡⟨ ▻̂-cong P.refl P.refl (head-lemma ρ) ⟩ [ t̂ail ρ̂ ▻̂ ⟦ head ρ ⟧ ] ∎ lemma₂′ : ∀ {τ} (x : Γ ▻ σ ∋ τ) → x /∋ ρ ≅-⊢ x /∋ (tail ρ ▻⇨[ σ ] head ρ) lemma₂′ zero = P.refl lemma₂′ (suc x) = P.refl lemma₂ : ∀ {τ₁} {x₁ : Γ ▻ σ ∋ τ₁} {τ₂} {x₂ : Γ ▻ σ ∋ τ₂} → x₁ ≅-∋′ x₂ → x₁ /∋ ρ ≅-⊢ x₂ /∋ (tail ρ ▻⇨[ σ ] head ρ) lemma₂ {x₁ = x} P.refl = lemma₂′ x -- Two substitutions are equal if their indices are equal and -- their projections are pairwise equal (assuming extensionality). extensionality : E.Extensionality (i ⊔ u ⊔ e) (i ⊔ u ⊔ e ⊔ t) → ∀ {Γ Δ₁} {ρ̂₁ : Γ ⇨̂ Δ₁} {ρ₁ : Sub T ρ̂₁} {Δ₂} {ρ̂₂ : Γ ⇨̂ Δ₂} {ρ₂ : Sub T ρ̂₂} → Δ₁ ≅-Ctxt Δ₂ → (∀ {σ} (x : Γ ∋ σ) → x /∋ ρ₁ ≅-⊢ x /∋ ρ₂) → ρ₁ ≅-⇨ ρ₂ extensionality ext {ε} {ρ₁ = ρ₁} {ρ₂ = ρ₂} P.refl hyp = ρ₁ ≅-⟶⟨ ηε ext ρ₁ ⟩ ε⇨ ≅-⟶⟨ sym-⟶ $ ηε ext ρ₂ ⟩ ρ₂ ∎-⟶ extensionality ext {Γ ▻ σ} {ρ₁ = ρ₁} {ρ₂ = ρ₂} P.refl hyp = ρ₁ ≅-⟶⟨ η▻ ext ρ₁ ⟩ tail ρ₁ ▻⇨ head ρ₁ ≅-⟶⟨ ▻⇨-cong P.refl (extensionality ext P.refl (hyp ∘ suc)) (hyp zero) ⟩ tail ρ₂ ▻⇨ head ρ₂ ≅-⟶⟨ sym-⟶ $ η▻ ext ρ₂ ⟩ ρ₂ ∎-⟶ open Dummy public
{ "alphanum_fraction": 0.4266357846, "avg_line_length": 33.2115384615, "ext": "agda", "hexsha": "3ff52182765ffc8be9c56c840cb7280ab9a45856", "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": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/dependently-typed-syntax", "max_forks_repo_path": "deBruijn/Substitution/Function/Basics.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "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/dependently-typed-syntax", "max_issues_repo_path": "deBruijn/Substitution/Function/Basics.agda", "max_line_length": 79, "max_stars_count": 5, "max_stars_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/dependently-typed-syntax", "max_stars_repo_path": "deBruijn/Substitution/Function/Basics.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-08T22:51:36.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T12:14:44.000Z", "num_tokens": 4694, "size": 8635 }
{- Type system of the language. -} module Syntax.Types where -- Abstract syntax of types for the language. data Type : Set where -- Unit type Unit : Type -- Product type _&_ : Type -> Type -> Type -- Sum type _+_ : Type -> Type -> Type -- Function type _=>_ : Type -> Type -> Type -- Event type Event : Type -> Type -- Signal type Signal : Type -> Type infixr 65 _=>_ infixl 68 _+_ infixl 70 _&_
{ "alphanum_fraction": 0.5689277899, "avg_line_length": 20.7727272727, "ext": "agda", "hexsha": "624e711fb414a1e4dfaae95b14744fad7f1fd1bd", "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": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DimaSamoz/temporal-type-systems", "max_forks_repo_path": "src/Syntax/Types.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "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": "DimaSamoz/temporal-type-systems", "max_issues_repo_path": "src/Syntax/Types.agda", "max_line_length": 45, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DimaSamoz/temporal-type-systems", "max_stars_repo_path": "src/Syntax/Types.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z", "max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z", "num_tokens": 139, "size": 457 }
-- Andreas, 2019-10-21, issue #4142, reported and test case by Jason Hu -- When the record-expression-to-copattern-translation is revisited -- after positivity checking, the defCopatternLHS flag needs to be -- updated as well! -- {-# OPTIONS -v tc.cc.record:20 #-} -- {-# OPTIONS -v tc.conv:30 #-} open import Agda.Builtin.Equality record WrapSet : Set1 where constructor wrap -- eta-equality -- WAS: needed for test field Wrapped : Set eta : WrapSet eta .Wrapped = Wrapped pack : WrapSet pack = record { Wrapped = Wrapped } -- The positivity check makes WrapSet an eta-record after the fact. -- Thus, the record-expression-to-copattern-translation is run again for pack. open WrapSet -- Make sure eta was inferred correctly for WrapSet hasEta : (w : WrapSet) → w ≡ record{ Wrapped = Wrapped w } hasEta w = refl -- When we have a definition by copattern matching it works. works : (w : WrapSet) → w ≡ eta w works w = refl -- Should also work for pack. test : (w : WrapSet) → w ≡ pack w test w = refl
{ "alphanum_fraction": 0.6957364341, "avg_line_length": 24, "ext": "agda", "hexsha": "dc072c78f0fa5072ca7c198acc3a1275acd55486", "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/Issue4142.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/Issue4142.agda", "max_line_length": 78, "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/Issue4142.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": 285, "size": 1032 }
module Setoid where open import Logic.Base record Setoid : Set1 where field A : Set _==_ : A -> A -> Prop refl : {x : A} -> x == x sym : {x y : A} -> x == y -> y == x trans : {x y z : A} -> x == y -> y == z -> x == z module Set-Ar where !_! : (S : Setoid) -> Set ! S ! = Setoid.A S record SetoidArrow (S₁ S₂ : Setoid) : Set where field map : ! S₁ ! -> ! S₂ ! stab : {x y : Setoid.A S₁} -> Setoid._==_ S₁ x y -> Setoid._==_ S₂ (map x) (map y) _∘_ : {S₁ S₂ S₃ : Setoid} -> SetoidArrow S₂ S₃ -> SetoidArrow S₁ S₂ -> SetoidArrow S₁ S₃ _∘_ {S₁} F₁ F₂ = record { map = \x -> SetoidArrow.map F₁ (SetoidArrow.map F₂ x) ; stab = \{x y : ! S₁ !}(p : Setoid._==_ S₁ x y) -> SetoidArrow.stab F₁ (SetoidArrow.stab F₂ p) } id : {S : Setoid} -> SetoidArrow S S id = record { map = \x -> x ; stab = \p -> p } _==→_ : {S₁ S₂ : Setoid} -> SetoidArrow S₁ S₂ -> SetoidArrow S₁ S₂ -> Set _==→_ {_} {S₂} F₁ F₂ = (forall x -> Setoid._==_ S₂ (SetoidArrow.map F₁ x) (SetoidArrow.map F₂ x)) -> True module Set-Fam where open Set-Ar record SetoidFam (S : Setoid) : Set1 where field index : ! S ! -> Setoid reindex : {x x' : ! S !} -> Setoid._==_ S x x' -> SetoidArrow (index x) (index x') id-coh : {x : ! S !} -> (reindex (Setoid.refl S)) ==→ id {index x} sym-coh-l : {x y : ! S !}(p : Setoid._==_ S x y) -> ((reindex (Setoid.sym S p)) ∘ (reindex p)) ==→ id sym-coh-r : {x y : ! S !}(p : Setoid._==_ S x y) -> ((reindex p) ∘ (reindex (Setoid.sym S p))) ==→ id trans-coh : {x y z : ! S !}(p : Setoid._==_ S x y)(p' : Setoid._==_ S y z) -> (reindex (Setoid.trans S p p')) ==→ ((reindex p') ∘ (reindex p)) module Set-Fam-Ar where open Set-Ar open Set-Fam record SetoidFamArrow {S₁ S₂ : Setoid}(F₁ : SetoidFam S₁)(F₂ : SetoidFam S₂) : Set where field indexingmap : SetoidArrow S₁ S₂ indexmap : (x : ! S₁ !) -> SetoidArrow (SetoidFam.index F₁ x) (SetoidFam.index F₂ (SetoidArrow.map indexingmap x)) reindexmap : (x x' : ! S₁ !)(p : Setoid._==_ S₁ x' x) -> ((indexmap x) ∘ (SetoidFam.reindex F₁ p)) ==→ ((SetoidFam.reindex F₂ (SetoidArrow.stab indexingmap p)) ∘ (indexmap x'))
{ "alphanum_fraction": 0.514604811, "avg_line_length": 32.3333333333, "ext": "agda", "hexsha": "f835de72097c1829d74c8bcda7f9fc3257cdf589", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/Setoid.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/AIM6/Cat/Setoid.agda", "max_line_length": 107, "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/AIM6/Cat/Setoid.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": 921, "size": 2328 }
-- Term matching. module Tactic.Reflection.Match where open import Prelude open import Builtin.Reflection open import Tactic.Reflection.Equality open import Control.Monad.Zero open import Control.Monad.State open import Container.Traversable private M : Nat → Set → Set M n = StateT (Vec (Maybe Term) n) Maybe fN : ∀ {n} (i : Nat) → IsTrue (lessNat i n) → Fin n fN i lt = fromNat i {{lt}} patVar : ∀ {n} → Nat → Nat → Maybe (Fin n) patVar {n} zero i with lessNat i n | fN {n} i ... | true | toFin = just (toFin true) ... | false | _ = nothing patVar (suc k) zero = nothing patVar (suc k) (suc i) = patVar k i upd : ∀ {a} {A : Set a} {n} → Fin n → A → Vec A n → Vec A n upd zero x (_ ∷ xs) = x ∷ xs upd (suc i) x (y ∷ xs) = y ∷ upd i x xs matchVar : ∀ {n} → Fin n → Term → M n ⊤ matchVar i v = caseM flip indexVec i <$> get of λ { (just u) → guard (u == v) (pure _) ; nothing → _ <$ modify (upd i (just v)) } MatchFun : Set → Set MatchFun A = ∀ {n} → Nat → A → A → M n ⊤ matchTerm matchTerm′ : MatchFun Term matchArgs : MatchFun (List (Arg Term)) matchArg : MatchFun (Arg Term) matchAbs : MatchFun (Abs Term) matchTerm k (var i []) v with patVar k i ... | just x = matchVar x v ... | nothing = matchTerm′ k (var i []) v matchTerm k p v = matchTerm′ k p v matchTerm′ {n} k (var i args) (var j args₁) = guard! (j <? k && isYes (i == j) || j ≥? k && isYes (j + n == i)) (matchArgs k args args₁) matchTerm′ k (con c args) (con c₁ args₁) = guard (c == c₁) (matchArgs k args args₁) matchTerm′ k (def f args) (def g args₁) = guard (f == g) (matchArgs k args args₁) matchTerm′ k (lam h p) (lam h₁ v) = guard (h == h₁) (matchAbs k p v) matchTerm′ k (pat-lam cs args) v = empty -- todo matchTerm′ k (pi a b) (pi a₁ b₁) = matchArg k a a₁ >> matchAbs k b b₁ matchTerm′ k (lit l) (lit l₁) = guard (l == l₁) (pure _) matchTerm′ k (agda-sort _) _ = pure _ -- ignore sorts matchTerm′ k (meta _ _) _ = pure _ matchTerm′ k unknown _ = pure _ matchTerm′ k p v = empty matchArgs k (x ∷ xs) (y ∷ ys) = matchArg k x y >> matchArgs k xs ys matchArgs k [] [] = pure _ matchArgs k _ _ = empty matchAbs k (abs _ x) (abs _ y) = matchTerm (suc k) x y matchArg k (arg i x) (arg j y) = guard (i == j) (matchTerm k x y) -- match |Δ| p v = just σ -- where Γ, Δ ⊢ p -- Γ ⊢ v -- Γ ⊢ σ : Δ -- p σ ≡ v match : (n : Nat) → Term → Term → Maybe (Vec Term n) match n pat v = do env ← snd <$> runStateT (matchTerm 0 pat v) (pure nothing ofType Vec (Maybe Term) n) traverse id env
{ "alphanum_fraction": 0.5770705521, "avg_line_length": 33.0126582278, "ext": "agda", "hexsha": "60ec7600b3a96927ebdce1a20e9ba540a8ace2ca", "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/Tactic/Reflection/Match.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/Tactic/Reflection/Match.agda", "max_line_length": 86, "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/Tactic/Reflection/Match.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": 963, "size": 2608 }
module _ where open import Common.Bool private unused = true used = true private module Private where not-in-scope = true in-scope = used -- History: -- -- * Ulf, 2015-20-12 c823aa9a0e84816d3e36ea86e04e9f9caa536c4a -- [ deadcode ] local private things are not in scope at top-level -- but imported things should be -- The previous restriction of the top level scope (7f47d51c) was a -- bit draconian and removed not only local private definitions but -- all imported things from the scope. This is fixed by this commit. -- -- * Andreas, 2021-05-18, used as testcase for issue #4647
{ "alphanum_fraction": 0.7103559871, "avg_line_length": 23.7692307692, "ext": "agda", "hexsha": "b51624dbf5fc733a6ed3efab651dea5e7da14e76", "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/interaction/TopScope.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/interaction/TopScope.agda", "max_line_length": 70, "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/interaction/TopScope.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": 183, "size": 618 }
module Issue857 where -- From the Agda mailing list, 2013-05-24, question raised by Martin Escardo. -- 2013-05-24 reported by Martin Escardo, test case by Andrea Vezzosi {- The crucial point is that λ() is not equal to λ(), so e.g. the ones appearing in the body of main-closed-ground' don't match the ones in its own type. To be concrete we can use a simplified version of what happens in main-closed-ground': -} data ⊥ : Set where postulate X : Set P : (⊥ → X) → Set lemma : (f : ⊥ → X) → P f -- Given the context above we attempt to feed agda code using λ(): main : P λ() main = lemma λ() {- Before we can check the type of main we have to translate λ() away into toplevel definitions, because internally only those are allowed pattern-matching. But each use of λ() is translated separately, so we get: absurd1 : ⊥ → X absurd1 () absurd2 : ⊥ → X absurd2 () main : P absurd1 main = lemma absurd2 Now we can proceed typechecking and find that (lemma absurd2 : P absurd2), i.e. applications of lemma only care about the type of its argument, but for main to typecheck we need the type of the body (P absurd2) to equal the declared type (P absurd1), and so we'd need absurd2 = absurd1 which unfortunately we can't deduce because those are different definitions. -} -- 2013-05-24 example by Martin Escardo open import Common.Equality absurd-equality : _≡_ {A = ⊥ → ⊥} (λ()) λ() absurd-equality = refl -- λ() is not translated as λ() → () (identity with variable name ()) -- thus, these examples should type check now.
{ "alphanum_fraction": 0.7069857697, "avg_line_length": 27.6071428571, "ext": "agda", "hexsha": "9d29d0baaaddeb6a4bc5a8047223490440acc17c", "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/Issue857.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/Issue857.agda", "max_line_length": 77, "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/Issue857.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": 441, "size": 1546 }
------------------------------------------------------------------------ -- The stream container ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality module Container.Stream {c⁺} (eq : ∀ {a p} → Equality-with-J a p c⁺) where open Derived-definitions-and-properties eq open import Logical-equivalence using (_⇔_) open import Prelude hiding (id; List; []; _∷_) open import Bijection eq using (_↔_; module _↔_) open import Container eq open import Container.List eq as L hiding (_∷_; _++_; Any-∷; Any-++) open import Function-universe eq hiding (_∘_) ------------------------------------------------------------------------ -- Streams Stream : Container lzero Stream = ⊤ ▷ const ℕ ------------------------------------------------------------------------ -- Operations -- Cons. infixr 5 _∷_ _∷_ : {A : Type} → A → ⟦ Stream ⟧ A → ⟦ Stream ⟧ A x ∷ (tt , lkup) = tt , λ { zero → x; (suc n) → lkup n } -- The head of a stream. head : {A : Type} → ⟦ Stream ⟧ A → A head (tt , lkup) = lkup 0 -- The tail of a stream. tail : {A : Type} → ⟦ Stream ⟧ A → ⟦ Stream ⟧ A tail (tt , lkup) = (tt , lkup ∘ suc) -- Appending a stream to a list. infixr 5 _++_ _++_ : {A : Type} → ⟦ List ⟧ A → ⟦ Stream ⟧ A → ⟦ Stream ⟧ A xs ++ ys = fold ys (λ z _ zs → z ∷ zs) xs -- Taking the first n elements from a stream. take : {A : Type} → ℕ → ⟦ Stream ⟧ A → ⟦ List ⟧ A take zero xs = [] take (suc n) xs = L._∷_ (head xs) (take n (tail xs)) -- Dropping the first n elements from a stream. drop : {A : Type} → ℕ → ⟦ Stream ⟧ A → ⟦ Stream ⟧ A drop zero xs = xs drop (suc n) xs = drop n (tail xs) ------------------------------------------------------------------------ -- Any lemmas -- Any lemma for head/tail. Any-head-tail : ∀ {A : Type} (P : A → Type) {xs} → Any P xs ↔ P (head xs) ⊎ Any P (tail xs) Any-head-tail P = record { surjection = record { logical-equivalence = record { to = λ { (zero , p) → inj₁ p ; (suc n , p) → inj₂ (n , p) } ; from = λ { (inj₁ p) → (zero , p) ; (inj₂ (n , p)) → (suc n , p) } } ; right-inverse-of = λ { (inj₁ p) → refl _ ; (inj₂ (n , p)) → refl _ } } ; left-inverse-of = λ { (zero , p) → refl _ ; (suc n , p) → refl _ } } -- Any lemma for cons. Any-∷ : ∀ {A : Type} (P : A → Type) {x xs} → Any P (x ∷ xs) ↔ P x ⊎ Any P xs Any-∷ P = Any-head-tail P -- Any lemma for append. -- -- (TODO: Generalise. The definitions of _++_ and Any-++ in this -- module are almost identical to those in Container.List.) Any-++ : ∀ {A : Type} (P : A → Type) (xs : ⟦ List ⟧ A) ys → Any P (xs ++ ys) ↔ Any P xs ⊎ Any P ys Any-++ P xs ys = fold-lemma (λ xs xs++ys → Any P xs++ys ↔ Any P xs ⊎ Any P ys) (λ us vs us≈vs us++ys hyp → Any P us++ys ↔⟨ hyp ⟩ Any P us ⊎ Any P ys ↔⟨ _⇔_.to (∼⇔∼″ us vs) us≈vs P ⊎-cong id ⟩ Any P vs ⊎ Any P ys □) (Any P ys ↔⟨ inverse ⊎-left-identity ⟩ ⊥ ⊎ Any P ys ↔⟨ inverse (Any-[] P) ⊎-cong id ⟩ Any P [] ⊎ Any P ys □) (λ x xs xs++ys ih → Any P (x ∷ xs++ys) ↔⟨ Any-∷ P ⟩ P x ⊎ Any P xs++ys ↔⟨ id ⊎-cong ih ⟩ P x ⊎ Any P xs ⊎ Any P ys ↔⟨ ⊎-assoc ⟩ (P x ⊎ Any P xs) ⊎ Any P ys ↔⟨ inverse $ L.Any-∷ P ⊎-cong id ⟩ Any P (L._∷_ x xs) ⊎ Any P ys □) xs -- Any lemma for take/drop. Any-take-drop : ∀ {A : Type} (P : A → Type) n {xs} → Any P xs ↔ Any P (take n xs) ⊎ Any P (drop n xs) Any-take-drop P zero {xs} = Any P xs ↔⟨ inverse ⊎-left-identity ⟩ ⊥ ⊎ Any P xs ↔⟨ inverse (Any-[] P) ⊎-cong id ⟩ Any P [] ⊎ Any P xs □ Any-take-drop P (suc n) {xs} = Any P xs ↔⟨ Any-head-tail P ⟩ P (head xs) ⊎ Any P (tail xs) ↔⟨ id ⊎-cong Any-take-drop P n ⟩ P (head xs) ⊎ (Any P (take n (tail xs)) ⊎ Any P (drop n (tail xs))) ↔⟨ ⊎-assoc ⟩ (P (head xs) ⊎ Any P (take n (tail xs))) ⊎ Any P (drop n (tail xs)) ↔⟨ inverse $ L.Any-∷ P ⊎-cong id ⟩ Any P (L._∷_ (head xs) (take n (tail xs))) ⊎ Any P (drop n (tail xs)) □
{ "alphanum_fraction": 0.438952164, "avg_line_length": 30.4861111111, "ext": "agda", "hexsha": "de144c4c3054409f2f898fc06609d6ec9b141bbc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Container/Stream.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Container/Stream.agda", "max_line_length": 93, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Container/Stream.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 1514, "size": 4390 }
---------------------------------------------------------------------------------- -- Types for parse trees ---------------------------------------------------------------------------------- module huffman-types where open import lib open import parse-tree posinfo = string character = string character-bar-3 = string character-bar-4 = string character-bar-5 = string character-bar-6 = string character-bar-7 = string character-range-1 = string character-range-2 = string word = string mutual data bvlit : Set where BvlitCons : digit → bvlit → bvlit BvlitStart : digit → bvlit data cmd : Set where Decode : codes → bvlit → cmd Encode : words → cmd data code : Set where Code : word → bvlit → code data codes : Set where CodesNext : code → codes → codes CodesStart : code → codes data digit : Set where One : digit Zero : digit data start : Set where File : cmd → start data words : Set where WordsNext : word → words → words WordsStart : word → words -- embedded types: data ParseTreeT : Set where parsed-bvlit : bvlit → ParseTreeT parsed-cmd : cmd → ParseTreeT parsed-code : code → ParseTreeT parsed-codes : codes → ParseTreeT parsed-digit : digit → ParseTreeT parsed-start : start → ParseTreeT parsed-words : words → ParseTreeT parsed-posinfo : posinfo → ParseTreeT parsed-character : character → ParseTreeT parsed-character-bar-3 : character-bar-3 → ParseTreeT parsed-character-bar-4 : character-bar-4 → ParseTreeT parsed-character-bar-5 : character-bar-5 → ParseTreeT parsed-character-bar-6 : character-bar-6 → ParseTreeT parsed-character-bar-7 : character-bar-7 → ParseTreeT parsed-character-range-1 : character-range-1 → ParseTreeT parsed-character-range-2 : character-range-2 → ParseTreeT parsed-word : word → ParseTreeT parsed-aws : ParseTreeT parsed-aws-bar-8 : ParseTreeT parsed-aws-bar-9 : ParseTreeT parsed-ows : ParseTreeT parsed-ows-star-11 : ParseTreeT parsed-ws : ParseTreeT parsed-ws-plus-10 : ParseTreeT ------------------------------------------ -- Parse tree printing functions ------------------------------------------ posinfoToString : posinfo → string posinfoToString x = "(posinfo " ^ x ^ ")" characterToString : character → string characterToString x = "(character " ^ x ^ ")" character-bar-3ToString : character-bar-3 → string character-bar-3ToString x = "(character-bar-3 " ^ x ^ ")" character-bar-4ToString : character-bar-4 → string character-bar-4ToString x = "(character-bar-4 " ^ x ^ ")" character-bar-5ToString : character-bar-5 → string character-bar-5ToString x = "(character-bar-5 " ^ x ^ ")" character-bar-6ToString : character-bar-6 → string character-bar-6ToString x = "(character-bar-6 " ^ x ^ ")" character-bar-7ToString : character-bar-7 → string character-bar-7ToString x = "(character-bar-7 " ^ x ^ ")" character-range-1ToString : character-range-1 → string character-range-1ToString x = "(character-range-1 " ^ x ^ ")" character-range-2ToString : character-range-2 → string character-range-2ToString x = "(character-range-2 " ^ x ^ ")" wordToString : word → string wordToString x = "(word " ^ x ^ ")" mutual bvlitToString : bvlit → string bvlitToString (BvlitCons x0 x1) = "(BvlitCons" ^ " " ^ (digitToString x0) ^ " " ^ (bvlitToString x1) ^ ")" bvlitToString (BvlitStart x0) = "(BvlitStart" ^ " " ^ (digitToString x0) ^ ")" cmdToString : cmd → string cmdToString (Decode x0 x1) = "(Decode" ^ " " ^ (codesToString x0) ^ " " ^ (bvlitToString x1) ^ ")" cmdToString (Encode x0) = "(Encode" ^ " " ^ (wordsToString x0) ^ ")" codeToString : code → string codeToString (Code x0 x1) = "(Code" ^ " " ^ (wordToString x0) ^ " " ^ (bvlitToString x1) ^ ")" codesToString : codes → string codesToString (CodesNext x0 x1) = "(CodesNext" ^ " " ^ (codeToString x0) ^ " " ^ (codesToString x1) ^ ")" codesToString (CodesStart x0) = "(CodesStart" ^ " " ^ (codeToString x0) ^ ")" digitToString : digit → string digitToString (One) = "One" ^ "" digitToString (Zero) = "Zero" ^ "" startToString : start → string startToString (File x0) = "(File" ^ " " ^ (cmdToString x0) ^ ")" wordsToString : words → string wordsToString (WordsNext x0 x1) = "(WordsNext" ^ " " ^ (wordToString x0) ^ " " ^ (wordsToString x1) ^ ")" wordsToString (WordsStart x0) = "(WordsStart" ^ " " ^ (wordToString x0) ^ ")" ParseTreeToString : ParseTreeT → string ParseTreeToString (parsed-bvlit t) = bvlitToString t ParseTreeToString (parsed-cmd t) = cmdToString t ParseTreeToString (parsed-code t) = codeToString t ParseTreeToString (parsed-codes t) = codesToString t ParseTreeToString (parsed-digit t) = digitToString t ParseTreeToString (parsed-start t) = startToString t ParseTreeToString (parsed-words t) = wordsToString t ParseTreeToString (parsed-posinfo t) = posinfoToString t ParseTreeToString (parsed-character t) = characterToString t ParseTreeToString (parsed-character-bar-3 t) = character-bar-3ToString t ParseTreeToString (parsed-character-bar-4 t) = character-bar-4ToString t ParseTreeToString (parsed-character-bar-5 t) = character-bar-5ToString t ParseTreeToString (parsed-character-bar-6 t) = character-bar-6ToString t ParseTreeToString (parsed-character-bar-7 t) = character-bar-7ToString t ParseTreeToString (parsed-character-range-1 t) = character-range-1ToString t ParseTreeToString (parsed-character-range-2 t) = character-range-2ToString t ParseTreeToString (parsed-word t) = wordToString t ParseTreeToString parsed-aws = "[aws]" ParseTreeToString parsed-aws-bar-8 = "[aws-bar-8]" ParseTreeToString parsed-aws-bar-9 = "[aws-bar-9]" ParseTreeToString parsed-ows = "[ows]" ParseTreeToString parsed-ows-star-11 = "[ows-star-11]" ParseTreeToString parsed-ws = "[ws]" ParseTreeToString parsed-ws-plus-10 = "[ws-plus-10]" ------------------------------------------ -- Reorganizing rules ------------------------------------------ mutual {-# NO_TERMINATION_CHECK #-} norm-words : (x : words) → words norm-words x = x {-# NO_TERMINATION_CHECK #-} norm-start : (x : start) → start norm-start x = x {-# NO_TERMINATION_CHECK #-} norm-posinfo : (x : posinfo) → posinfo norm-posinfo x = x {-# NO_TERMINATION_CHECK #-} norm-digit : (x : digit) → digit norm-digit x = x {-# NO_TERMINATION_CHECK #-} norm-codes : (x : codes) → codes norm-codes x = x {-# NO_TERMINATION_CHECK #-} norm-code : (x : code) → code norm-code x = x {-# NO_TERMINATION_CHECK #-} norm-cmd : (x : cmd) → cmd norm-cmd x = x {-# NO_TERMINATION_CHECK #-} norm-bvlit : (x : bvlit) → bvlit norm-bvlit x = x isParseTree : ParseTreeT → 𝕃 char → string → Set isParseTree p l s = ⊤ {- this will be ignored since we are using simply typed runs -} ptr : ParseTreeRec ptr = record { ParseTreeT = ParseTreeT ; isParseTree = isParseTree ; ParseTreeToString = ParseTreeToString }
{ "alphanum_fraction": 0.6600756034, "avg_line_length": 34.5628140704, "ext": "agda", "hexsha": "1577bfdc15e147f8b561c7fb8544f9ea0902e8f8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "heades/AUGL", "max_forks_repo_path": "huffman/huffman-types.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "heades/AUGL", "max_issues_repo_path": "huffman/huffman-types.agda", "max_line_length": 108, "max_stars_count": null, "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "heades/AUGL", "max_stars_repo_path": "huffman/huffman-types.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1959, "size": 6878 }
{- Functions building UARels and DUARels on propositions / propositional families -} {-# OPTIONS --no-exact-split --safe #-} module Cubical.Displayed.Prop where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.Data.Unit open import Cubical.Displayed.Base private variable ℓA ℓ≅A ℓB ℓ≅B ℓP : Level 𝒮-prop : (P : hProp ℓP) → UARel (P .fst) ℓ-zero 𝒮-prop P .UARel._≅_ _ _ = Unit 𝒮-prop P .UARel.ua _ _ = invEquiv (isContr→≃Unit (isOfHLevelPath' 0 (P .snd) _ _)) 𝒮ᴰ-prop : {A : Type ℓA} (𝒮-A : UARel A ℓ≅A) (P : A → hProp ℓP) → DUARel 𝒮-A (λ a → P a .fst) ℓ-zero 𝒮ᴰ-prop 𝒮-A P .DUARel._≅ᴰ⟨_⟩_ _ _ _ = Unit 𝒮ᴰ-prop 𝒮-A P .DUARel.uaᴰ _ _ _ = invEquiv (isContr→≃Unit (isOfHLevelPathP' 0 (P _ .snd) _ _)) 𝒮-subtype : {A : Type ℓA} (𝒮-A : UARel A ℓ≅A) {P : A → Type ℓP} → (∀ a → isProp (P a)) → UARel (Σ A P) ℓ≅A 𝒮-subtype 𝒮-A propP .UARel._≅_ (a , _) (a' , _) = 𝒮-A .UARel._≅_ a a' 𝒮-subtype 𝒮-A propP .UARel.ua (a , _) (a' , _) = compEquiv (𝒮-A .UARel.ua a a') (Σ≡PropEquiv propP) 𝒮ᴰ-subtype : {A : Type ℓA} {𝒮-A : UARel A ℓ≅A} {B : A → Type ℓB} (𝒮ᴰ-B : DUARel 𝒮-A B ℓ≅B) {P : (a : A) → B a → Type ℓP} → (∀ a b → isProp (P a b)) → DUARel 𝒮-A (λ a → Σ[ b ∈ B a ] (P a b)) ℓ≅B 𝒮ᴰ-subtype 𝒮ᴰ-B propP .DUARel._≅ᴰ⟨_⟩_ (b , _) p (b' , _) = 𝒮ᴰ-B .DUARel._≅ᴰ⟨_⟩_ b p b' 𝒮ᴰ-subtype 𝒮ᴰ-B propP .DUARel.uaᴰ (b , _) p (b' , _) = compEquiv (𝒮ᴰ-B .DUARel.uaᴰ b p b') (compEquiv (invEquiv (Σ-contractSnd λ _ → isOfHLevelPathP' 0 (propP _ b') _ _)) ΣPath≃PathΣ)
{ "alphanum_fraction": 0.6156626506, "avg_line_length": 31.320754717, "ext": "agda", "hexsha": "d57a0d5e2a2c41c5d261b253951b29800140847b", "lang": "Agda", "max_forks_count": 134, "max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z", "max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z", "max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "marcinjangrzybowski/cubical", "max_forks_repo_path": "Cubical/Displayed/Prop.agda", "max_issues_count": 584, "max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z", "max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "marcinjangrzybowski/cubical", "max_issues_repo_path": "Cubical/Displayed/Prop.agda", "max_line_length": 86, "max_stars_count": 301, "max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "marcinjangrzybowski/cubical", "max_stars_repo_path": "Cubical/Displayed/Prop.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z", "num_tokens": 845, "size": 1660 }
open import Relation.Binary using (Setoid) module Data.Vec.Any.Membership {a ℓ} (S : Setoid a ℓ) where open import Level using (_⊔_) open Setoid S renaming (Carrier to A; refl to ≈-refl; trans to ≈-trans ) open import Relation.Nullary open import Relation.Binary open import Data.Fin open import Data.Nat as ℕ hiding (_⊔_) open import Data.Product as Prod hiding (map) open import Data.Vec as Vec hiding (map) open import Data.Vec.Equality open import Data.Vec.Any as Any open import Function using (_∘_; id; flip) open Equality S renaming (_≈_ to _≋_; trans to ≋-trans) infix 4 _∈′_ _∉′_ _∈′_ : ∀ {n} → A → Vec A n → Set (a ⊔ ℓ) x ∈′ xs = Any (x ≈_) xs _∉′_ : ∀ {n} → A → Vec A n → Set (a ⊔ ℓ) x ∉′ xs = ¬ (x ∈′ xs) infix 4 _⊆_ _⊈_ _⊆_ : ∀ {n m} → Vec A n → Vec A m → Set _ xs ⊆ ys = ∀ {x} → x ∈′ xs → x ∈′ ys _⊈_ : ∀ {n m} → Vec A n → Vec A m → Set _ xs ⊈ ys = ¬ (xs ⊆ ys) -- A variant of Vec.map. map-with-∈′ : ∀ {n b} {B : Set b} (xs : Vec A n) → (∀ {x} → x ∈′ xs → B) → Vec B n map-with-∈′ [] f = [] map-with-∈′ (x ∷ xs) f = f (here ≈-refl) ∷ map-with-∈′ xs (f ∘ there) -- Finds an element satisfying the predicate. find′ : ∀ {p n} {P : A → Set p} {xs : Vec A n} → Any P xs → ∃ λ x → x ∈′ xs × P x find′ (here px) = , here ≈-refl , px find′ (there pxs) = Prod.map id (Prod.map there id) (find′ pxs) lose′ : ∀ {p n} {P : A → Set p} {x}{xs : Vec A n} → P Respects _≈_ → x ∈′ xs → P x → Any P xs lose′ resp x∈′xs px = map (flip resp px) x∈′xs
{ "alphanum_fraction": 0.534647171, "avg_line_length": 30.25, "ext": "agda", "hexsha": "c0079c6d30d8a29a4d8ca3df8be94de33aa3f3d8", "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": "1a60f72b9ea1dd61845311ee97dc380aa542b874", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "tizmd/agda-vector-any", "max_forks_repo_path": "src/Data/Vec/Any/Membership.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1a60f72b9ea1dd61845311ee97dc380aa542b874", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "tizmd/agda-vector-any", "max_issues_repo_path": "src/Data/Vec/Any/Membership.agda", "max_line_length": 74, "max_stars_count": null, "max_stars_repo_head_hexsha": "1a60f72b9ea1dd61845311ee97dc380aa542b874", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "tizmd/agda-vector-any", "max_stars_repo_path": "src/Data/Vec/Any/Membership.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 647, "size": 1573 }
module CTL.Modalities.AU where open import CTL.Modalities.AN open import FStream.Core open import Library data _AU'_ {ℓ₁ ℓ₂} {C : Container ℓ₁} (props₁ props₂ : FStream' C (Set ℓ₂)) : Set (ℓ₁ ⊔ ℓ₂) where finallyA : head props₁ → props₁ AU' props₂ _untilA_ : head props₂ → AN'ₛ props₁ AU' AN'ₛ props₂ → props₁ AU' props₂ -- TODO Implement with Applicative AU : ∀ {ℓ₁ ℓ₂} {C : Container ℓ₁} → FStream C (Set ℓ₂) → FStream C (Set ℓ₂) → Set (ℓ₁ ⊔ ℓ₂) AU s₁ s₂ = {! !} mutual AUₛ' : ∀ {i : Size} {ℓ₁ ℓ₂} {C : Container ℓ₁} → FStream' C (Set ℓ₂) → FStream' C (Set ℓ₂) → FStream' {i} C (Set (ℓ₁ ⊔ ℓ₂)) AUₛ' = {! !} AUₛ : ∀ {i : Size} {ℓ₁ ℓ₂} {C : Container ℓ₁} → FStream C (Set ℓ₂) → FStream C (Set ℓ₂) → FStream {i} C (Set (ℓ₁ ⊔ ℓ₂)) AUₛ = {! !}
{ "alphanum_fraction": 0.5898089172, "avg_line_length": 30.1923076923, "ext": "agda", "hexsha": "0762d37c54f0319af70c4e784686105972fc2dfe", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-12-13T15:56:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-12-13T15:56:38.000Z", "max_forks_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "zimbatm/condatis", "max_forks_repo_path": "CTL/Modalities/AU.agda", "max_issues_count": 5, "max_issues_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_issues_repo_issues_event_max_datetime": "2020-09-01T16:52:07.000Z", "max_issues_repo_issues_event_min_datetime": "2017-06-03T20:02:22.000Z", "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "zimbatm/condatis", "max_issues_repo_path": "CTL/Modalities/AU.agda", "max_line_length": 74, "max_stars_count": 1, "max_stars_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "Aerate/condatis", "max_stars_repo_path": "CTL/Modalities/AU.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-13T16:52:28.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-13T16:52:28.000Z", "num_tokens": 355, "size": 785 }
{-# OPTIONS --cubical-compatible #-} module Common.List where open import Agda.Builtin.List public open import Common.Nat infixr 5 _++_ _++_ : ∀ {a} {A : Set a} → List A → List A → List A [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ (xs ++ ys) map : ∀ {a b} {A : Set a} {B : Set b} → (A → B) → List A → List B map _ [] = [] map f (x ∷ xs) = f x ∷ map f xs length : ∀ {a} {A : Set a} → List A → Nat length [] = 0 length (x ∷ xs) = 1 + length xs
{ "alphanum_fraction": 0.5076586433, "avg_line_length": 22.85, "ext": "agda", "hexsha": "66b402208f3b1cb52be52550a6831598c50acaa4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Common/List.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Common/List.agda", "max_line_length": 65, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Common/List.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 177, "size": 457 }
{-# OPTIONS --without-K --exact-split --cubical #-} -- This is unfortunate, but Arch doesn't have the cubical stuff -- in the stdlib package it comes with (and cabal on Arch is -- significantly worse). open import Agda.Builtin.Cubical.Id open import Agda.Builtin.Cubical.Path -- Other builtins open import Agda.Builtin.List open import Agda.Builtin.Bool open import Axiom.Extensionality.Propositional -- I understand it better calling stuff "UU" from Egbert's notes. open import 00-preamble -- Same for + types -- too lazy to find the builtin open import 04-inductive-types -- https://dl.acm.org/doi/pdf/10.1145/3341691 page 11 -- set quotient (truncate the quotient) -- ≡ is from Agda.Builtin.Id data Quot {i : Level} (A : UU i) (R : A → A → UU i): UU i where cls : A → Quot A R eq : (a b : A) → (r : R a b) → (cls a) ≡ (cls b) trunc : (x y : Quot A R) → (p q : x ≡ y) → p ≡ q -- First definition of a group: List(A + A) / R. Some oddity: -- 1) f : A → A → Bool is an equality predicate (Eq in Haskell), but I'm not sure how to -- insist that (f a₁ a₂ = true) ≅ (a₁ = a₂) or just say "if the identity type is -- inhabited." Also encode-decode seems to use information from the type, so defining -- f should be a reasonable requirement (it's just code, but using true for 𝟙 and false -- for 𝟘). -- 2) I promise it terminates. Otherwise it insists that the first recursive call is -- uncertain but the list is clearly one element shorter. -- 3) I think the warning isn't all that important (but I'm a programmer, don't trust me). -- My understanding is that the warning means "the definitional equalities Agda has can -- be surprising" but I don't see how it's bad yet. {-# TERMINATING #-} cancelList : {i : Level} {A : UU i} (eq : A → A → Bool) (l : List (coprod A A)) → List (coprod A A) cancelList e [] = [] cancelList e ((inl a₁) ∷ (inr a₂) ∷ xs) with e a₁ a₂ ... | true = cancelList e xs ... | false = (inl a₁) ∷ (cancelList e ((inr a₂) ∷ xs)) cancelList e ((inr a₁) ∷ (inl a₂) ∷ xs) with e a₁ a₂ ... | true = cancelList e xs ... | false = (inr a₁) ∷ (cancelList e ((inl a₂) ∷ xs)) cancelList e (x ∷ xs) = x ∷ (cancelList e xs) -- Proof that cancel list is idempotent (done on sets bc why the #$%^ does the built-in -- funext need a #$%^ing level as an explicit param?) -- Note that oddity 1 from above is relevant -- I'm just going to be lazy and prove for all -- equality-like things. cancelList-idempotent : {A : UU (lsuc lzero)} (e : A → A → Bool) → ((λ x → cancelList e (cancelList e x)) ≡ (cancelList e)) cancelList-idempotent e =
{ "alphanum_fraction": 0.6219068413, "avg_line_length": 48.2105263158, "ext": "agda", "hexsha": "6b5a0aae2ee2790fe585cc2e07b6659390ae7232", "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": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "hemangandhi/HoTT-Intro", "max_forks_repo_path": "Agda/univalent-hott/6-higher-inductive.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "hemangandhi/HoTT-Intro", "max_issues_repo_path": "Agda/univalent-hott/6-higher-inductive.agda", "max_line_length": 99, "max_stars_count": null, "max_stars_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "hemangandhi/HoTT-Intro", "max_stars_repo_path": "Agda/univalent-hott/6-higher-inductive.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 832, "size": 2748 }
-- Andreas, 2012-09-13 respect irrelevance at meta-var creation -- {-# OPTIONS -v tc.conv.irr:20 #-} module Issue168-irrelevant where data Nat : Set where zero : Nat suc : Nat → Nat module Id .(A : Set) where id : Nat → Nat id zero = zero id (suc xs) = suc (id xs) open Id Nat postulate P : Nat → Set lemma : ∀ n → P (id n) foo : P zero foo = lemma _
{ "alphanum_fraction": 0.614973262, "avg_line_length": 17.8095238095, "ext": "agda", "hexsha": "40fe307803443ca25c3eaa1de90af6ec19a0e27b", "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/Issue168-irrelevant.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/Issue168-irrelevant.agda", "max_line_length": 63, "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/Issue168-irrelevant.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 129, "size": 374 }
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- We can use a propositional equality parametrized on Set instead of -- using two "different" equalities on D and M. module LogicalFramework.SetEquality where -- We add 3 to the fixities of the Agda standard library 0.8.1 (see -- Relation/Binary/Core.agda). infix 7 _≡D_ _≡M_ ------------------------------------------------------------------------------ -- Domain universe D postulate D : Set -- Propositional equality on D. data _≡D_ (x : D) : D → Set where refl : x ≡D x ≡D-thm : ∀ {d e} → d ≡D e → e ≡D d ≡D-thm refl = refl ------------------------------------------------------------------------------ -- Domain universe M data M : Set where zero : M succ : M → M -- Propositional equality on M. data _≡M_ (n : M) : M → Set where refl : n ≡M n ≡M-thm : ∀ {m n} → m ≡M n → n ≡M m ≡M-thm refl = refl ------------------------------------------------------------------------------ -- Propositional equality on Set. data _≡_ {A : Set}(a : A) : A → Set where refl : a ≡ a ≡-thm₁ : ∀ {d e : D} → d ≡ e → e ≡ d ≡-thm₁ refl = refl ≡-thm₂ : ∀ {m n : M} → m ≡ n → n ≡ m ≡-thm₂ refl = refl
{ "alphanum_fraction": 0.4688958009, "avg_line_length": 24.7307692308, "ext": "agda", "hexsha": "1126e2c20fa17217dfd892fb5ad2bdb5037a2d7b", "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/thesis/report/LogicalFramework/SetEquality.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/thesis/report/LogicalFramework/SetEquality.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/thesis/report/LogicalFramework/SetEquality.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": 394, "size": 1286 }
module L.Base.Coproduct.Properties where -- There are no properties yet.
{ "alphanum_fraction": 0.7837837838, "avg_line_length": 18.5, "ext": "agda", "hexsha": "eedb29dc3a3996588516ef960b84933026a09ff6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "borszag/smallib", "max_forks_repo_path": "src/L/Base/Coproduct/Properties.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_issues_repo_issues_event_max_datetime": "2020-11-09T16:40:39.000Z", "max_issues_repo_issues_event_min_datetime": "2020-10-19T10:13:16.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "borszag/smallib", "max_issues_repo_path": "src/L/Base/Coproduct/Properties.agda", "max_line_length": 40, "max_stars_count": null, "max_stars_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "borszag/smallib", "max_stars_repo_path": "src/L/Base/Coproduct/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 16, "size": 74 }
postulate I : Set U : I → Set El : ∀ {i} → U i → Set infixr 4 _,_ record Σ (A : Set) (B : A → Set) : Set where constructor _,_ field proj₁ : A proj₂ : B proj₁ open Σ ∃ : ∀ {A : Set} → (A → Set) → Set ∃ = Σ _ mutual infixl 5 _▻_ data Ctxt : Set where _▻_ : (Γ : Ctxt) → Type Γ → Ctxt Type : Ctxt → Set Type Γ = ∃ λ i → Env Γ → U i Env : Ctxt → Set Env (Γ ▻ σ) = Σ (Env Γ) λ γ → El (proj₂ σ γ) mutual data Ctxt⁺ (Γ : Ctxt) : Set where _▻_ : (Γ⁺ : Ctxt⁺ Γ) → Type (Γ ++ Γ⁺) → Ctxt⁺ Γ infixl 5 _++_ _++_ : (Γ : Ctxt) → Ctxt⁺ Γ → Ctxt Γ ++ (Γ⁺ ▻ σ) = (Γ ++ Γ⁺) ▻ σ data P : (Γ : Ctxt) → Type Γ → Set where c : ∀ {Γ σ τ} → P (Γ ▻ σ) τ f : ∀ {Γ} → Ctxt⁺ Γ → Set₁ f {Γ} (Γ⁺ ▻ σ) = Set where g : ∀ τ → P (Γ ++ Γ⁺ ▻ σ) τ → Set₁ g _ c = Set
{ "alphanum_fraction": 0.4513715711, "avg_line_length": 15.7254901961, "ext": "agda", "hexsha": "eedd92e6e2602dca7130495e9e8ca912aef72c5e", "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/Issue3063.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/Issue3063.agda", "max_line_length": 51, "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/Issue3063.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": 418, "size": 802 }
{- FP Lunch, Nottingham July 27, 2007 Conor McBride -} module Binary where data Bit : Set where O : Bit I : Bit infixl 80 _<<_ data Pos : Set where <<I : Pos _<<_ : Pos -> Bit -> Pos bsuc : Pos -> Pos bsuc <<I = <<I << O bsuc (n << O) = n << I bsuc (n << I) = bsuc n << O data Peano : Pos -> Set where pI : Peano <<I psuc : {n : Pos} -> Peano n -> Peano (bsuc n) pdouble : {n : Pos} -> Peano n -> Peano (n << O) pdouble pI = psuc pI pdouble (psuc p) = psuc (psuc (pdouble p)) peano : (n : Pos) -> Peano n peano <<I = pI peano (n << O) = pdouble (peano n) peano (n << I) = psuc (pdouble (peano n)) -- Slow addition (yay!) _+_ : Pos -> Pos -> Pos _+_ n m = peano n <+> m where _<+>_ : {n : Pos} -> Peano n -> Pos -> Pos pI <+> m = bsuc m psuc p <+> m = bsuc (p <+> m) infixl 60 _+_ infix 40 _==_ data _==_ {A : Set}(x : A) : A -> Set where refl : x == x {- test : (<<I << I << O << O << O) == (<<I << I << O << I) + (<<I << O << I << I) test = refl -} {- simple : (<<I << O) == (<<I) + (<<I) simple = refl -} {- t : Peano _ t = peano (<<I) -} {- t : Pos t = bsuc (<<I) -} {- t : Pos t = peano (<<I << O) <+> (<<I << I) -- t = psuc pI <+> (<<I) where _<+>_ : {n : Pos} -> Peano n -> Pos -> Pos pI <+> m = bsuc m psuc p <+> m = bsuc (p <+> m) -} t1 : Pos t1 = (<<I << O) + (<<I << O) t2 : (<<I) + (<<I) == (<<I) + (<<I) t2 = refl
{ "alphanum_fraction": 0.4389044944, "avg_line_length": 16.367816092, "ext": "agda", "hexsha": "91f279aca8a193febe6f9c30042dd91ac92acbb8", "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": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_path": "tests/beyond/Binary.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "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": "andrejtokarcik/agda-semantics", "max_issues_repo_path": "tests/beyond/Binary.agda", "max_line_length": 79, "max_stars_count": 3, "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_path": "tests/beyond/Binary.agda", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "num_tokens": 627, "size": 1424 }
-- Sets represented by unary predicates (Like restricted comprehension) -- Similiar to BoolSet, but instead using the builtin constructive logic with levels. module Sets.PredicateSet where import Lvl open import Data hiding (Empty) open import Data.Boolean open import Data.Boolean.Stmt open import Functional open import Function.Proofs open import Logic open import Logic.Propositional open import Logic.Propositional.Theorems open import Logic.Predicate -- open import Relator.Equals.Proofs.Equiv open import Structure.Setoid using (Equiv) renaming (_≡_ to _≡ₛ_) open import Data.Any open import Structure.Function.Domain open import Type module _ where -- A set of objects of a certain type. -- This is represented by a predicate. -- Note: This is only a "set" within a certain type, so everything PredSet(T) is actually a subset of T (if T were a set (the set of all objects with type T)). Or in other words: PredSet(T) is supposed to represent the set {x. x: T}, and then (S ∈ PredSet(T)) essentially means that S when interpreted as a set of objects is a subset of {x. x: T}. PredSet : ∀{ℓ ℓₒ} → Type{ℓₒ} → Type{Lvl.𝐒(ℓ) Lvl.⊔ ℓₒ} PredSet{ℓ}{ℓₒ} (T) = (T → Stmt{ℓ}) private variable ℓ ℓ₁ ℓ₂ ℓ₃ ℓ₄ ℓₒ ℓₑ : Lvl.Level private variable T A B : Type{ℓₒ} -- The statement of whether an element is in a set -- TODO: Maybe define this using a equivalence relation instead? (Alternatively a Setoid: x ∈ S = ∃(y ↦ (x ≡_T y) ∧ S(y))) _∈_ : T → PredSet{ℓ}(T) → Stmt _∈_ = apply -- (x ∈ S) = S(x) _∉_ : T → PredSet{ℓ}(T) → Stmt _∉_ = (¬_) ∘₂ (_∈_) -- (x ∉ S) = ¬(x ∈ S) _∋_ : PredSet{ℓ}(T) → T → Stmt _∋_ = swap(_∈_) -- (S ∋ x) = (x ∈ S) _∌_ : PredSet{ℓ}(T) → T → Stmt _∌_ = (¬_) ∘₂ (_∋_) -- (S ∌ x) = ¬(S ∋ x) module BoundedQuantifiers {T : Type{ℓₒ}} where ∀ₛ : PredSet{ℓ}(T) → (T → Stmt{ℓ₁}) → Stmt{ℓ Lvl.⊔ ℓ₁ Lvl.⊔ ℓₒ} ∀ₛ(S) P = ∀{elem : T} → (elem ∈ S) → P(elem) ∃ₛ : PredSet{ℓ}(T) → (T → Stmt{ℓ₁}) → Stmt{ℓ Lvl.⊔ ℓ₁ Lvl.⊔ ℓₒ} ∃ₛ(S) P = ∃(elem ↦ (elem ∈ S) ∧ P(elem)) -- An empty set ∅ : PredSet{ℓ}(T) ∅ = const(Data.Empty) -- An universal set -- Note: It is only within a certain type, so 𝐔{T} is not actually a subset of everything. It is the greatest subset of subsets of T. 𝐔 : PredSet{ℓ}(T) 𝐔 = const(Unit) -- A singleton set (a set with only one element) •_ : ⦃ Equiv{ℓₑ}(T) ⦄ → T → PredSet(T) •_ = (_≡ₛ_) -- An union of two sets _∪_ : PredSet{ℓ₁}(T) → PredSet{ℓ₂}(T) → PredSet(T) _∪_ S₁ S₂ x = (S₁(x) ∨ S₂(x)) -- An union of a set and a singleton set _∪•_ : ∀{ℓ}{T : Type{ℓ}} → PredSet{ℓ₁}(T) → Type{ℓ} → PredSet(T) _∪•_ S P x = (S(x) ∨ P) -- An intersection of two sets _∩_ : PredSet{ℓ₁}(T) → PredSet{ℓ₂}(T) → PredSet(T) _∩_ S₁ S₂ x = (S₁(x) ∧ S₂(x)) -- A complement of a set ∁_ : PredSet{ℓ}(T) → PredSet(T) ∁_ = (¬_) ∘_ -- ∁_ S x = (¬ S(x)) _∖_ : PredSet{ℓ₁}(T) → PredSet{ℓ₂}(T) → PredSet(T) _∖_ S₁ S₂ = (S₁ ∩ (∁ S₂)) filter : (T → Bool) → PredSet{ℓ}(T) → PredSet(T) filter f S x = (S(x) ∧ IsTrue(f(x))) -- TODO: Maybe move these to a separate "Relations" file? -- A statement of whether a set is a subset of a set _⊆_ : PredSet{ℓ₁}(T) → PredSet{ℓ₂}(T) → Stmt _⊆_ S₁ S₂ = (∀{x} → (x ∈ S₁) → (x ∈ S₂)) -- A statement of whether a set is a superset of a set _⊇_ : PredSet{ℓ₁}(T) → PredSet{ℓ₂}(T) → Stmt _⊇_ S₁ S₂ = (∀{x} → (x ∈ S₁) ← (x ∈ S₂)) -- A statement of whether a set is equivalent to a set _≡_ : PredSet{ℓ₁}(T) → PredSet{ℓ₂}(T) → Stmt _≡_ S₁ S₂ = (∀{x} → (x ∈ S₁) ↔ (x ∈ S₂)) Empty : PredSet{ℓ}(T) → Stmt Empty(S) = ∀{x} → ¬(x ∈ S) NonEmpty : PredSet{ℓ}(T) → Stmt NonEmpty(S) = ∃(_∈ S) Disjoint : PredSet{ℓ₁}(T) → PredSet{ℓ₂}(T) → Stmt Disjoint S₁ S₂ = ((S₁ ∩ S₂) ⊆ (∅ {Lvl.𝟎})) Overlapping : PredSet{ℓ₁}(T) → PredSet{ℓ₂}(T) → Stmt Overlapping S₁ S₂ = ∃(S₁ ∩ S₂) ⋃_ : PredSet{ℓ₁}(PredSet{ℓ₂}(T)) → PredSet(T) ⋃_ S x = ∃(s ↦ (s ∈ S) ∧ (x ∈ s)) ⋂_ : PredSet{ℓ₁}(PredSet{ℓ₂}(T)) → PredSet(T) ⋂_ S x = ∀{s} → (s ∈ S) → (x ∈ s) ℘ : PredSet{ℓ₁}(T) → PredSet(PredSet{ℓ₁}(T)) ℘ S x = x ⊆ S unapply : ⦃ Equiv{ℓₑ}(B) ⦄ → (f : A → B) → B → PredSet(A) unapply f(y) x = f(x) ≡ₛ y map : ⦃ Equiv{ℓₑ}(B) ⦄ → (f : A → B) → PredSet{ℓ}(A) → PredSet(B) map f(S) y = Overlapping(S)(unapply f(y)) unmap : (f : A → B) → PredSet{ℓ}(B) → PredSet(A) unmap f(y) x = f(x) ∈ y ⊶ : ⦃ Equiv{ℓₑ}(B) ⦄ → (f : A → B) → PredSet(B) ⊶ f y = ∃(unapply f(y)) module _ where -- TODO: These proofs should be generalized somewhere else? open import Structure.Relator.Equivalence open import Structure.Relator.Properties private variable S a b c a₁ a₂ b₁ b₂ : PredSet{ℓ}(T) private variable S₁ : PredSet{ℓ₁}(T) private variable S₂ : PredSet{ℓ₂}(T) instance [≡]-reflexivity : Reflexivity(_≡_ {ℓ₁}{ℓ₂}{T}) Reflexivity.proof [≡]-reflexivity = [↔]-reflexivity instance [≡]-symmetry : Symmetry(_≡_ {ℓ₁}{ℓ₂}{T}) Symmetry.proof [≡]-symmetry {x} {y} xy = [↔]-symmetry xy instance [≡]-transitivity : Transitivity(_≡_ {ℓ₁}{ℓ₂}{T}) Transitivity.proof [≡]-transitivity {x} {y} {z} xy yz = [↔]-transitivity xy yz instance [≡]-equivalence : Equivalence(_≡_ {ℓ₁}{ℓ₂}{T}) [≡]-equivalence = intro {- TODO: Cannot be an instance of Equiv because of level issues, but see a solution in ExtensionalPredicateSet instance [≡]-equiv : Equiv(PredSet{ℓ}(T)) Equiv._≡_ [≡]-equiv = {!_≡_!} Equiv.equivalence [≡]-equiv = {![≡]-equivalence!} -} [≡]-to-[⊆] : (S₁ ≡ S₂) → (S₁ ⊆ S₂) [≡]-to-[⊆] S₁S₂ {x} = [↔]-to-[→] (S₁S₂{x}) [≡]-to-[⊇] : (S₁ ≡ S₂) → (S₁ ⊇ S₂) [≡]-to-[⊇] S₁S₂ {x} = [↔]-to-[←] (S₁S₂{x}) [⊆]-of-[∪]ₗ : (S₁ ⊆ (S₁ ∪ S₂)) [⊆]-of-[∪]ₗ = [∨]-introₗ [⊆]-of-[∪]ᵣ : (S₂ ⊆ (S₁ ∪ S₂)) [⊆]-of-[∪]ᵣ = [∨]-introᵣ [∪]-of-subset : (S₁ ⊆ S₂) → ((S₁ ∪ S₂) ≡ S₂) [∪]-of-subset S₁S₂ = [↔]-intro [∨]-introᵣ ([∨]-elim S₁S₂ id) [⊆]-min : (∅ {ℓ} ⊆ S) [⊆]-min = empty [⊆]-max : (S ⊆ 𝐔 {ℓ}) [⊆]-max = const <> [∅]-containment : ∀{x : T} → ¬(x ∈ ∅ {ℓ}) [∅]-containment = empty [𝐔]-containment : ∀{x : T} → (x ∈ 𝐔 {ℓ}) [𝐔]-containment = <> map-containmentₗ : ⦃ equiv-B : Equiv{ℓₑ}(B) ⦄ → ∀{x : A}{f : A → B} → (f(x) ∈ map ⦃ equiv-B ⦄ f(S)) ← (x ∈ S) map-containmentₗ {x = x} = (xS ↦ [∃]-intro x ⦃ [↔]-intro xS (reflexivity(_≡ₛ_)) ⦄) -- map-containmentᵣ : ⦃ _ : Relation(S) ⦄ → ∀{f : A → B} → ⦃ _ : Injective(f) ⦄ → ∀{x : A} → (f(x) ∈ map f(S)) → (x ∈ S) -- map-containmentᵣ {x = x} = ([∃]-intro a ⦃ [∧]-intro p q ⦄) ↦ {!!} [⋂]-of-[∅] : ((⋂_ {ℓ₁}{ℓ₂} ∅) ≡ 𝐔 {ℓ₃}{ℓ₄}{T}) [⋂]-of-[∅] = [↔]-intro (const empty) (const <>) [⋂]-of-[𝐔] : ((⋂_ {ℓ₁}{ℓ₂} 𝐔) ≡ ∅ {ℓ₂}{ℓ₃}{T}) [⋂]-of-[𝐔] {ℓ₁}{ℓ₂}{ℓ₃}{T} = [↔]-intro empty (inters ↦ inters([𝐔]-containment{x = ∅ {ℓ₂}{ℓ₃}{T}})) [⋃]-of-[∅] : ((⋃_ {ℓ₁}{ℓ₂} ∅) ≡ ∅ {ℓ₁}{ℓ₃}{T}) [⋃]-of-[∅] = [↔]-intro empty (([∃]-intro s ⦃ [∧]-intro p _ ⦄) ↦ p) [⋃]-of-[𝐔] : ((⋃_ {ℓ₁}{ℓ₂} 𝐔) ≡ 𝐔 {ℓ₃}{ℓ₄}{T}) [⋃]-of-[𝐔] {ℓ₁}{ℓ₂}{ℓ₃}{T} = [↔]-intro (const ([∃]-intro 𝐔 ⦃ [↔]-intro <> <> ⦄)) (const <>) LvlUp-set-equality : (Lvl.Up{ℓ} ∘ S ≡ S) LvlUp-set-equality = [↔]-intro Lvl.up Lvl.Up.obj -- Disjoint-irreflexivity : ⦃ _ : NonEmpty(_) ⦄ → Irreflexivity(Disjoint{ℓ₁}{ℓ₂}{T}) -- Irreflexivity.proof Disjoint-irreflexivity p = {!!} -- TODO: Duplicated in SetLike -- SetType : PredSet{ℓ}(T) → Stmt -- SetType(s) = ∃(_∈ s) {- choice : ∀{S : PredSet{ℓ₁}(PredSet{ℓ₂}(T))} → ∃{Obj = SetType(S) → SetType(⋃ S)}(f ↦ ∀{([∃]-intro x) : SetType(S)} → ([∃]-witness(f([∃]-intro x)) ∈ x)) ∃.witness (∃.witness (choice {S = S}) ([∃]-intro f ⦃ proof ⦄)) = {!!} ∃.proof (∃.witness (choice {S = S}) ([∃]-intro f ⦃ proof ⦄)) = {!!} ∃.proof (choice {S = S}) {[∃]-intro f ⦃ proof ⦄} = {!!} -} [∪]-subset : (a ⊆ c) → (b ⊆ c) → ((a ∪ b) ⊆ c) [∪]-subset ac bc = [∨]-elim ac bc [∪]-subset2 : (a₁ ⊆ a₂) → (b₁ ⊆ b₂) → ((a₁ ∪ b₁) ⊆ (a₂ ∪ b₂)) [∪]-subset2 aa bb = [∨]-elim2 aa bb [∖][∪]-is-[∪]ᵣ : (((a ∖ b) ∪ b) ⊆ (a ∪ b)) [∖][∪]-is-[∪]ᵣ {a = A}{b = B}{x = x} = [∨]-elim ([∨]-introₗ ∘ [∧]-elimₗ) [∨]-introᵣ open import Logic.Classical [∖][∪]-is-[∪] : ⦃ ∀{x} → Classical(b(x)) ⦄ → (((a ∖ b) ∪ b) ≡ (a ∪ b)) [∖][∪]-is-[∪] {b = B}{a = A}{x = x} = [↔]-intro ([∨]-elim (Ax ↦ [∨]-elim2 ([∧]-intro Ax) id ([∨]-symmetry(excluded-middle(B(x))))) [∨]-introᵣ) ([∖][∪]-is-[∪]ᵣ {a = A}{b = B}) [∪][∖]-invertᵣ-[⊆] : (a ⊆ (b ∪ c)) → ((a ∖ c) ⊆ b) [∪][∖]-invertᵣ-[⊆] abc ([∧]-intro a nc) = [∨]-elim id ([⊥]-elim ∘ nc) (abc a)
{ "alphanum_fraction": 0.5178530026, "avg_line_length": 35.3524590164, "ext": "agda", "hexsha": "0f8cf1e8dacd16565ef2b813df68d96d06b215a8", "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": "Sets/PredicateSet.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": "Sets/PredicateSet.agda", "max_line_length": 349, "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": "Sets/PredicateSet.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": 4149, "size": 8626 }
{-# OPTIONS --cubical --no-import-sorts #-} open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero) module Number.Structures where private variable ℓ ℓ' : Level open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Relation.Nullary.Base -- ¬_ open import Cubical.Relation.Binary.Base -- Rel -- open import Data.Nat.Base using (ℕ) renaming (_≤_ to _≤ₙ_) open import Cubical.Data.Nat using (ℕ; zero; suc) renaming (_+_ to _+ₙ_) open import Cubical.Data.Nat.Order renaming (zero-≤ to z≤n; suc-≤-suc to s≤s; _≤_ to _≤ₙ_; _<_ to _<ₙ_) open import Cubical.Data.Unit.Base -- Unit open import Cubical.Data.Empty -- ⊥ open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_) open import Cubical.Data.Sigma.Base renaming (_×_ to infixr 4 _×_) open import Cubical.Data.Empty renaming (elim to ⊥-elim) -- `⊥` and `elim` open import Cubical.Data.Maybe.Base import MoreAlgebra open MoreAlgebra.Definitions import Algebra.Structures -- ℕ ℤ ℚ ℝ ℂ and ℚ₀⁺ ℝ₀⁺ ... -- ring without additive inverse -- see Algebra.Structures.IsCommutativeSemiring record IsRCommSemiring {F : Type ℓ} (_#_ : Rel F F ℓ') (0f 1f : F) (_+_ _·_ : F → F → F) : Type (ℓ-max ℓ ℓ') where field isApartnessRel : IsApartnessRel _#_ -- TODO: properties open IsApartnessRel isApartnessRel public renaming ( isIrrefl to #-irrefl ; isSym to #-sym ; isCotrans to #-cotrans ) -- ℤ ℚ ℝ ℂ -- see Algebra.Structures.IsCommutativeRing record IsRCommRing {F : Type ℓ} (_#_ : Rel F F ℓ') (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) : Type (ℓ-max ℓ ℓ') where field isRCommSemiring : IsRCommSemiring _#_ 0f 1f _+_ _·_ open IsRCommSemiring isRCommSemiring public -- ℚ ℝ ℂ record IsRField {F : Type ℓ} (_#_ : Rel F F ℓ') (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_⁻¹ : (x : F) → {{ x # 0f }} → F) : Type (ℓ-max ℓ ℓ') where field isRCommRing : IsRCommRing _#_ 0f 1f _+_ _·_ -_ +-assoc : ∀ x y z → (x + y) + z ≡ x + (y + z) +-comm : ∀ x y → x + y ≡ y + x distrib : ∀ x y z → (x + y) · z ≡ (x · z) + (y · z) ⁻¹-preserves-#0 : ∀ x → (p : x # 0f) → _⁻¹ x {{p}} # 0f -preserves-# : ∀ x y → x # y → (- x) # (- y) -preserves-#0 : ∀ x → x # 0f → (- x) # 0f ·-#0-#0-implies-#0 : ∀ a b → a # 0f → b # 0f → (a · b) # 0f 1#0 : 1f # 0f -- TODO: properties open IsRCommRing isRCommRing public -- Finₖ ℕ ℤ ℚ ℝ and ℚ₀⁺ ℚ⁺ ℝ₀⁺ ℝ⁺ ... record IsRLattice {F : Type ℓ} (_<_ _≤_ _#_ : Rel F F ℓ') (min max : F → F → F) : Type (ℓ-max ℓ ℓ') where field isPartialOrder : IsPartialOrder _≤_ glb : ∀ x y z → z ≤ min x y → z ≤ x × z ≤ y glb-back : ∀ x y z → z ≤ x × z ≤ y → z ≤ min x y lub : ∀ x y z → max x y ≤ z → x ≤ z × y ≤ z lub-back : ∀ x y z → x ≤ z × y ≤ z → max x y ≤ z -- TODO: derived properties <-implies-# : ∀ x y → x < y → x # y ≤-#-implies-< : ∀ x y → x ≤ y → x # y → x < y #-sym : ∀ x y → x # y → y # x max-sym : ∀ x y → max x y ≡ max y x max-id : ∀ x → max x x ≡ x open IsPartialOrder isPartialOrder public -- ℕ ℤ ℚ ℝ and ℚ₀⁺ ℚ⁺ ℝ₀⁺ ℝ⁺ ... -- ring without additive inverse record IsROrderedCommSemiring {F : Type ℓ} (_<_ _≤_ _#_ : Rel F F ℓ') (min max : F → F → F) (0f 1f : F) (_+_ _·_ : F → F → F) : Type (ℓ-max ℓ ℓ') where field isRLattice : IsRLattice _<_ _≤_ _#_ min max isRCommSemiring : IsRCommSemiring _#_ 0f 1f _+_ _·_ -- TODO: properties -- TODO: the following can be derived 0<1 : 0f < 1f +-0<-0<-implies-0< : ∀ a b → 0f < a → 0f < b → 0f < (a + b) +-0<-0≤-implies-0< : ∀ a b → 0f < a → 0f ≤ b → 0f < (a + b) +-0≤-0<-implies-0< : ∀ a b → 0f ≤ a → 0f < b → 0f < (a + b) +-0≤-0≤-implies-0≤ : ∀ a b → 0f ≤ a → 0f ≤ b → 0f ≤ (a + b) +-<0-<0-implies-<0 : ∀ a b → a < 0f → b < 0f → (a + b) < 0f +-<0-≤0-implies-<0 : ∀ a b → a < 0f → b ≤ 0f → (a + b) < 0f +-≤0-<0-implies-<0 : ∀ a b → a ≤ 0f → b < 0f → (a + b) < 0f +-≤0-≤0-implies-≤0 : ∀ a b → a ≤ 0f → b ≤ 0f → (a + b) ≤ 0f ·-#0-#0-implies-#0 : ∀ a b → a # 0f → b # 0f → (a · b) # 0f ·-#0-0<-implies-#0 : ∀ a b → a # 0f → 0f < b → (a · b) # 0f ·-#0-<0-implies-#0 : ∀ a b → a # 0f → b < 0f → (a · b) # 0f ·-0≤-0≤-implies-0≤ : ∀ a b → 0f ≤ a → 0f ≤ b → 0f ≤ (a · b) ·-0≤-0<-implies-0≤ : ∀ a b → 0f ≤ a → 0f < b → 0f ≤ (a · b) ·-0≤-<0-implies-≤0 : ∀ a b → 0f ≤ a → b < 0f → (a · b) ≤ 0f ·-0≤-≤0-implies-≤0 : ∀ a b → 0f ≤ a → b ≤ 0f → (a · b) ≤ 0f ·-0<-#0-implies-#0 : ∀ a b → 0f < a → b # 0f → (a · b) # 0f ·-0<-0≤-implies-0≤ : ∀ a b → 0f < a → 0f ≤ b → 0f ≤ (a · b) ·-0<-0<-implies-0< : ∀ a b → 0f < a → 0f < b → 0f < (a · b) ·-0<-<0-implies-<0 : ∀ a b → 0f < a → b < 0f → (a · b) < 0f ·-0<-≤0-implies-≤0 : ∀ a b → 0f < a → b ≤ 0f → (a · b) ≤ 0f ·-<0-#0-implies-#0 : ∀ a b → a < 0f → b # 0f → (a · b) # 0f ·-<0-0≤-implies-≤0 : ∀ a b → a < 0f → 0f ≤ b → (a · b) ≤ 0f ·-<0-0<-implies-<0 : ∀ a b → a < 0f → 0f < b → (a · b) < 0f ·-<0-<0-implies-0< : ∀ a b → a < 0f → b < 0f → 0f < (a · b) ·-<0-≤0-implies-0≤ : ∀ a b → a < 0f → b ≤ 0f → 0f ≤ (a · b) ·-≤0-0≤-implies-≤0 : ∀ a b → a ≤ 0f → 0f ≤ b → (a · b) ≤ 0f ·-≤0-0<-implies-≤0 : ∀ a b → a ≤ 0f → 0f < b → (a · b) ≤ 0f ·-≤0-<0-implies-0≤ : ∀ a b → a ≤ 0f → b < 0f → 0f ≤ (a · b) ·-≤0-≤0-implies-0≤ : ∀ a b → a ≤ 0f → b ≤ 0f → 0f ≤ (a · b) 0≤-#0-implies-0< : ∀ x → 0f ≤ x → x # 0f → 0f < x {- ·-#0-#0-implies-#0 : ∀ a b → a # 0f → b # 0f → (a · b) # 0f ·-#0-0<-implies-#0 : ∀ a b → a # 0f → 0f < b → (a · b) # 0f ·-0≤-0≤-implies-0≤ : ∀ a b → 0f ≤ a → 0f ≤ b → 0f ≤ (a · b) ·-0≤-0<-implies-0≤ : ∀ a b → 0f ≤ a → 0f < b → 0f ≤ (a · b) ·-0≤-≤0-implies-≤0 : ∀ a b → 0f ≤ a → b ≤ 0f → (a · b) ≤ 0f ·-0<-#0-implies-#0 : ∀ a b → 0f < a → b # 0f → (a · b) # 0f ·-0<-0≤-implies-0≤ : ∀ a b → 0f < a → 0f ≤ b → 0f ≤ (a · b) ·-0<-0<-implies-0< : ∀ a b → 0f < a → 0f < b → 0f < (a · b) ·-0<-≤0-implies-≤0 : ∀ a b → 0f < a → b ≤ 0f → (a · b) ≤ 0f ·-≤0-0≤-implies-≤0 : ∀ a b → a ≤ 0f → 0f ≤ b → (a · b) ≤ 0f ·-≤0-0<-implies-≤0 : ∀ a b → a ≤ 0f → 0f < b → (a · b) ≤ 0f ·-≤0-≤0-implies-0≤ : ∀ a b → a ≤ 0f → b ≤ 0f → 0f ≤ (a · b) -} open IsRLattice isRLattice public -- ℤ ℚ ℝ record IsROrderedCommRing {F : Type ℓ} (_<_ _≤_ _#_ : Rel F F ℓ') (min max : F → F → F) (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) : Type (ℓ-max ℓ ℓ') where field isROrderedCommSemiring : IsROrderedCommSemiring _<_ _≤_ _#_ min max 0f 1f _+_ _·_ isRCommRing : IsRCommRing _#_ 0f 1f _+_ _·_ -_ 0≡-0 : 0f ≡ - 0f -flips-< : ∀ x y → x < y → (- y) < (- x) -flips-<0 : ∀ x → x < 0f → 0f < (- x) -flips-0< : ∀ x → 0f < x → (- x) < 0f -flips-≤ : ∀ x y → x ≤ y → (- y) ≤ (- x) -flips-≤0 : ∀ x → x ≤ 0f → 0f ≤ (- x) -flips-0≤ : ∀ x → 0f ≤ x → (- x) ≤ 0f -preserves-# : ∀ x y → x # y → (- x) # (- y) -preserves-#0 : ∀ x → x # 0f → (- x) # 0f -- TODO: properties open IsROrderedCommSemiring isROrderedCommSemiring public -- Remark 6.7.7. As we define absolute values by | x | = max(x, -x), as is common in constructive analysis, -- if x has a locator, then so does | x |, and we use this fact in the proof of the above theorem. -- Remark 4.1.9. -- -- 1. From the fact that (A, ≤, min, max) is a lattice, it does not follow that -- for every x and y, -- -- max(x, y) = x ∨ max(x, y) = y, -- -- which would hold in a linear order. -- However, in Lemma 6.7.1 we characterize max as -- -- z < max(x, y) ⇔ z < x ∨ z < y, -- -- and similarly for min. {- from: https://isabelle.in.tum.de/doc/tutorial.pdf "8.4.5 The Numeric Type Classes" Absolute Value. The absolute value function `abs` is available for all ordered rings, including types int, rat and real. It satisfies many properties, such as the following: | x * y | ≡ | x | * | y | (abs_mult) | a | ≤ b ⇔ (a ≤ b) ∧ (- a) ≤ b (abs_le_iff) | a + b | ≤ | a | + | b | (abs_triangle_ineq) -} -- also see https://en.wikipedia.org/wiki/Ordered_ring#Basic_properties record IsAbsOrderedCommRing {F : Type ℓ} (_<_ _≤_ _#_ : Rel F F ℓ') (min max : F → F → F) (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (abs : F → F) : Type (ℓ-max ℓ ℓ') where field abs0≡0 : abs 0f ≡ 0f abs-preserves-· : ∀ x y → abs (x · y) ≡ abs x · abs y triangle-ineq : ∀ x y → abs (x + y) ≤ (abs x + abs y) -- -trichotomy : ∀ x → (x ≡ 0f) ⊎ (0f < x) ⊎ (0f < (- x)) abs-≤ : ∀ x y → abs x ≤ y → (x ≤ y) × ((- x) ≤ y) abs-≤-back : ∀ x y → (x ≤ y) × ((- x) ≤ y) → abs x ≤ y 0≤abs : ∀ x → 0f ≤ abs x -- ℚ ℝ record IsROrderedField {F : Type ℓ} (_<_ _≤_ _#_ : Rel F F ℓ') (min max : F → F → F) (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_⁻¹ : (x : F) → {{ x # 0f }} → F) : Type (ℓ-max ℓ ℓ') where field isROrderedCommRing : IsROrderedCommRing _<_ _≤_ _#_ min max 0f 1f _+_ _·_ -_ isRField : IsRField _#_ 0f 1f _+_ _·_ -_ _⁻¹ -- TODO: properties open IsROrderedCommRing isROrderedCommRing hiding ( -preserves-# ; -preserves-#0 ) public open IsRField isRField hiding ( ·-#0-#0-implies-#0 ) public field ⁻¹-preserves-<0 : ∀ x → (x < 0f) → (p : x # 0f) → _⁻¹ x {{p}} < 0f ⁻¹-preserves-0< : ∀ x → (0f < x) → (p : x # 0f) → 0f < _⁻¹ x {{p}} -- ℚ₀⁺ ℚ₀⁻ ℝ₀⁺ ℝ₀⁻ {- record IsROrderedSemifield {F : Type ℓ} (_<_ _≤_ _#_ : Rel F F ℓ') (min max : F → F → F) (0f 1f : F) (_+_ _·_ : F → F → F) (_⁻¹ : (x : F) → {{ x < 0f }} → F) : Type (ℓ-max ℓ ℓ') where field isROrderedCommSemiring : IsROrderedCommSemiring _<_ _≤_ _#_ min max 0f 1f _+_ _·_ -- TODO: properties #0-implies-0< : ∀ x → 0f # x → 0f < x positivity : ∀ x → 0f ≤ x open IsROrderedCommSemiring isROrderedCommSemiring public -} -- ℚ⁺ ℚ⁻ ℝ⁺ ℝ⁻ {- record IsROrderedSemifieldWithoutZero {F : Type ℓ} (_<_ _≤_ _#_ : Rel F F ℓ') (min max : F → F → F) (0f 1f : F) (_+_ _·_ : F → F → F) (_⁻¹ : (x : F) → F) : Type (ℓ-max ℓ ℓ') where field isRLattice : IsRLattice _<_ _≤_ _#_ min max -- isGroup : IsGroup 1f _·_ _⁻¹ +-assoc : ∀ x y z → (x + y) + z ≡ x + (y + z) +-comm : ∀ x y → x + y ≡ y + x distrib : ∀ x y z → (x + y) · z ≡ (x · z) + (y · z) -- TODO: properties open IsRLattice isRLattice public -}
{ "alphanum_fraction": 0.4782731643, "avg_line_length": 42.2669322709, "ext": "agda", "hexsha": "226a9c8a8579c9ddab26adf4cff388bc0a4ee083", "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": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "agda/Number/Structures.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "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": "mchristianl/synthetic-reals", "max_issues_repo_path": "agda/Number/Structures.agda", "max_line_length": 192, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "agda/Number/Structures.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 5179, "size": 10609 }
{-# OPTIONS --without-K #-} module Chapter3.Formalization where -- Sets and n-types -- ---------------- open import Data.Unit open import Data.Empty open import Data.Nat open import Data.Sum open import Relation.Nullary using (¬_) open import Data.Bool open import Data.Product open import Basics open import Relation.Equivalence.Univalence open import Relation.Equality open import Relation.Equality.Extensionality open import Relation.Path.Operation isSet : ∀ {a} → Set a → Set a isSet A = (x y : A) (p q : x ≡ y) → p ≡ q -- The only possible inhabitants of ⊤ is tt which means everything -- is reflexivity. is-1-set : isSet ⊤ is-1-set tt tt refl refl = refl -- Ex falso quodlibet strikes again is-0-set : isSet ⊥ is-0-set () hasDecEq : ∀ {i} → Set i → Set i hasDecEq A = (x y : A) → (x ≡ y) ⊎ ¬ (x ≡ y) decEqIsSet : ∀ {i}{A : Set i} → hasDecEq A → isSet A decEqIsSet {A} d x y = {! !} -- TBD: Hedberg's Theorem -- Natural numbers are also a set because every equality type is decidable. -- Boy, it's a pain in the ass proving that, though. is-ℕ-set : isSet ℕ is-ℕ-set = decEqIsSet hasDecEq-ℕ where hasDecEq-ℕ : hasDecEq ℕ hasDecEq-ℕ zero zero = inj₁ refl hasDecEq-ℕ zero (suc y) = inj₂ (λ ()) hasDecEq-ℕ (suc x) zero = inj₂ (λ ()) hasDecEq-ℕ (suc x) (suc y) with hasDecEq-ℕ x y hasDecEq-ℕ (suc x) (suc y) | inj₁ x₁ = inj₁ (ap {f = suc} x₁) hasDecEq-ℕ (suc x) (suc y) | inj₂ pnot = inj₂ (λ p → pnot (ap {f = remark} p)) where remark : ℕ → ℕ remark zero = 42 remark (suc n) = n is-×-set : ∀ {a b}{A : Set a}{B : Set b} → isSet A → isSet B → isSet (A × B) is-×-set SA SB x y p q = {! !} is-1-type : ∀ {a} → Set a → Set a is-1-type A = (x y : A) → (p q : x ≡ y) → (r s : p ≡ q) → r ≡ s 3-1-8 : ∀ {a}{A : Set a} → isSet A → is-1-type A 3-1-8 f x y p q r s = {! apd r !} where g : (q : x ≡ y) → (p ≡ q) g q = f x y p q 3-1-9 : ¬ (isSet Set) 3-1-9 x = {! !} where f : Bool → Bool f false = true f true = false contra : ¬ (false ≡ true) contra () lem : IsEquiv f lem = record { from = f ; iso₁ = λ x → mlem {x} ; iso₂ = λ x → mlem {x} } where mlem : ∀ {x : Bool} → f (f x) ≡ x mlem {false} = refl mlem {true} = refl not-double-neg : ∀ {A : Set} → (¬ (¬ A) → A) → ⊥ not-double-neg f = {! !} where e : Bool ≃ Bool e = e-equiv , record { from = e-equiv ; iso₁ = λ x → helper {x} ; iso₂ = λ x → helper {x} } where e-equiv : Bool → Bool e-equiv true = false e-equiv false = true helper : ∀ {x : Bool} → e-equiv (e-equiv x) ≡ x helper {true} = refl helper {false} = refl -- 3-2-4 : (x : Bool) → ¬ (e x ≡ x) -- 3-2-4 = ? p : Bool ≡ Bool p = {! ua e !} not-lem : ∀ {A : Set} → ¬ (A ⊎ (¬ A)) not-lem {A} (inj₁ x) = not-double-neg (λ _ → x) not-lem {A} (inj₂ w) = not-double-neg (λ x → ⊥-elim (x w)) -- This defines "mere propositions" -- If all elements of P are connected by a path, then p contains no -- higher homotopy. -- -- "The adjective “mere” emphasizes that although any type may be regarded as a -- proposition (which we prove by giving an inhabitant of it), a type that is a -- mere proposition cannot usefully be regarded as any more than a proposition: -- there is no additional information contained in a witness of its truth." isProp : ∀ {a} → Set a → Set a isProp P = (x y : P) → (x ≡ y) top-is-prop : isProp ⊤ top-is-prop tt tt = refl 3-3-3 : ∀ {a b}{P : Set a}{Q : Set b} → (p : isProp P)(q : isProp Q) → (f : P → Q) → (g : Q → P) → P ≃ Q 3-3-3 p q f g = f , record { from = g ; iso₁ = λ x → p (g (f x)) x ; iso₂ = λ y → q (f (g y)) y } 3-3-2 : ∀ {a}{P : Set a} → (p : isProp P) → (x₀ : P) → P ≃ ⊤ 3-3-2 {_}{P} p x₀ = 3-3-3 p (top-is-prop) f g where f : P → ⊤ f x = tt g : ⊤ → P g u = x₀ isProp-isSet : ∀ {a}{A : Set a} → isProp A → isSet A isProp-isSet {_}{A} f x y p q = lem p ∙ lem q ⁻¹ where g : (y : A) → x ≡ y g y = f x y -- Read bottom-to-top lem : (p : x ≡ y) → p ≡ (g x ⁻¹ ∙ g y) lem p = (ap {f = (λ z → z ∙ p)} (back-and-there-again {p = (g x)}) ⁻¹) -- we have p = g(x)−1 g(y) = q. ∙ (assoc (g x ⁻¹) (g x) p ⁻¹) -- and after a little convincing ∙ ap {f = (λ z → (g x ⁻¹) ∙ z)} -- which is to say that p = g(y)⁻¹ ∙ g(z) ( (2-11-2 x p (g x) ⁻¹) -- Hence by Lemma 2.11.2, we have g(y) ∙ p = g(z) ∙ (apd {f = g} p) -- we have apd(p) : p(g(y)) = g(z). ) -- Then for any y,z : A and p : y = z isProp-is-prop : ∀ {a}{A : Set a} → isProp (isProp A) isProp-is-prop f g = funext λ x → funext λ y → isProp-isSet f _ _ (f x y) (g x y) isSet-is-prop : ∀ {a}{A : Set a} → isProp (isSet A) isSet-is-prop f g = funext λ x → funext λ y → funext λ p → funext λ q → isProp-isSet (f x y) _ _ (f x y p q) (g x y p q) 3-5-1 : ∀ {a}{A : Set a} → (P : A → Set) → ({x : A} → isProp (P x)) → (u v : Σ[ x ∈ A ] P x) → (proj₁ u ≡ proj₁ v) → u ≡ v 3-5-1 P x u v p = {! !} 3-6-1 : ∀ {a b}{A : Set a}{B : Set b} → (isProp A) → (isProp B) → isProp (A × B) 3-6-1 PA PB px py = {! !} 3-6-2 : ∀ {a b}{A : Set a}{B : A → Set b}{x : A} → (isProp (B x)) → isProp ((x : A) → B x) 3-6-2 PPI f g = funext λ x → {! f x ≡ g x !}
{ "alphanum_fraction": 0.5192598187, "avg_line_length": 31.3372781065, "ext": "agda", "hexsha": "39115d30831d7d1ea9dba4096d9dd27b3937a031", "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": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CodaFi/HoTT-Exercises", "max_forks_repo_path": "Chapter3/Formalization.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "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": "CodaFi/HoTT-Exercises", "max_issues_repo_path": "Chapter3/Formalization.agda", "max_line_length": 122, "max_stars_count": null, "max_stars_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CodaFi/HoTT-Exercises", "max_stars_repo_path": "Chapter3/Formalization.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2146, "size": 5296 }
{-# OPTIONS --rewriting #-} open import Agda.Builtin.Bool open import Agda.Builtin.Equality {-# BUILTIN REWRITE _≡_ #-} data D (A : Set) : Set where c c' : D A postulate rew : c {Bool} ≡ c' {Bool} {-# REWRITE rew #-}
{ "alphanum_fraction": 0.6233183857, "avg_line_length": 17.1538461538, "ext": "agda", "hexsha": "39aa050e2aee60fa568df23914c3818d193f3bae", "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/RewriteConstructorParsNotGeneral.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/RewriteConstructorParsNotGeneral.agda", "max_line_length": 36, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/RewriteConstructorParsNotGeneral.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 72, "size": 223 }
open import Relation.Binary.PropositionalEquality record Group : Set₁ where field X : Set _·_ : X → X → X e : X i : X → X assoc : (x y z : X) → (x · y) · z ≡ x · (y · z) unit-l : (x : X) → e · x ≡ x unit-r : (x : X) → x · e ≡ x inv-l : (x : X) → i x · x ≡ e inv-r : (x : X) → x · i x ≡ e inv-u-l : {G : Group} → (x x' y : Group.X) → (x Group.· y) ≡ Group.e → (x' Group.· y) ≡ Group.e → x ≡ x' inv-u-l x x' y p q = ?
{ "alphanum_fraction": 0.4291938998, "avg_line_length": 27, "ext": "agda", "hexsha": "f3a80c6c1581d4108374eceeb3b08536c9096c49", "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": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "erwinkn/program-eq-proof", "max_forks_repo_path": "TD6/Group.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "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": "erwinkn/program-eq-proof", "max_issues_repo_path": "TD6/Group.agda", "max_line_length": 104, "max_stars_count": null, "max_stars_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "erwinkn/program-eq-proof", "max_stars_repo_path": "TD6/Group.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 208, "size": 459 }
{-# OPTIONS --safe #-} module Cubical.Algebra.Direct-Sum.Properties where open import Cubical.Foundations.Prelude open import Cubical.Algebra.Group open import Cubical.Algebra.AbGroup open import Cubical.Algebra.Direct-Sum.Base private variable ℓ ℓ' : Level module _ (Idx : Type ℓ) (P : Idx → Type ℓ') (AGP : (r : Idx) → AbGroupStr (P r)) where inv : ⊕ Idx P AGP → ⊕ Idx P AGP inv = DS-Rec-Set.f Idx P AGP (⊕ Idx P AGP) trunc -- elements neutral (λ r a → base r (AbGroupStr.-_ (AGP r) a)) (λ xs ys → xs add ys) -- eq group (λ xs ys zs → addAssoc xs ys zs) (λ xs → addRid xs) (λ xs ys → addComm xs ys) -- eq base (λ r → let open AbGroupStr (AGP r) in let open GroupTheory (P r , AbGroupStr→GroupStr (AGP r)) in (cong (base r) inv1g) ∙ (base-neutral r)) (λ r a b → let open AbGroupStr (AGP r) in let open GroupTheory (P r , AbGroupStr→GroupStr (AGP r)) in ((base r (- a) add base r (- b)) ≡⟨ (base-add r (- a) (- b)) ⟩ base r ((- a) + (- b)) ≡⟨ (cong (base r) (sym (invDistr b a))) ⟩ base r (- (b + a)) ≡⟨ cong (base r) (cong (-_) (comm b a)) ⟩ base r (- (a + b)) ∎)) rinv : (z : ⊕ Idx P AGP) → z add (inv z) ≡ neutral rinv = DS-Ind-Prop.f Idx P AGP (λ z → z add (inv z) ≡ neutral) (λ _ → trunc _ _) -- elements (addRid neutral) (λ r a → let open AbGroupStr (AGP r) in ((base r a add base r (- a)) ≡⟨ base-add r a (- a) ⟩ base r (a + - a) ≡⟨ cong (base r) (invr a) ⟩ base r 0g ≡⟨ base-neutral r ⟩ neutral ∎)) (λ {x} {y} p q → (((x add y) add ((inv x) add (inv y))) ≡⟨ cong (λ X → X add ((inv x) add (inv y))) (addComm x y) ⟩ ((y add x) add (inv x add inv y)) ≡⟨ sym (addAssoc y x (inv x add inv y)) ⟩ (y add (x add (inv x add inv y))) ≡⟨ cong (λ X → y add X) (addAssoc x (inv x) (inv y)) ⟩ (y add ((x add inv x) add inv y)) ≡⟨ cong (λ X → y add (X add (inv y))) (p) ⟩ (y add (neutral add inv y)) ≡⟨ cong (λ X → y add X) (addComm neutral (inv y)) ⟩ (y add (inv y add neutral)) ≡⟨ cong (λ X → y add X) (addRid (inv y)) ⟩ (y add inv y) ≡⟨ q ⟩ neutral ∎))
{ "alphanum_fraction": 0.424556213, "avg_line_length": 47.4385964912, "ext": "agda", "hexsha": "68beece6538f4db7a118a959f54728fe86281000", "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/Direct-Sum/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_path": "Cubical/Algebra/Direct-Sum/Properties.agda", "max_line_length": 124, "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/Direct-Sum/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 875, "size": 2704 }
module Structure.Setoid.Uniqueness.Proofs where import Lvl open import Functional open import Logic.Propositional open import Logic.Predicate open import Structure.Setoid.Uniqueness open import Structure.Setoid open import Structure.Function.Domain open import Structure.Relator.Properties open import Syntax.Transitivity open import Type private variable ℓ ℓₑ₁ ℓₑ₂ : Lvl.Level private variable A B : Type{ℓ} private variable P : A → Type{ℓ} module _ ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄ ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ {f : A → B} where Uniqueness-Injectivity : (∀{y : B} → Unique(x ↦ y ≡ f(x))) ↔ Injective(f) Uniqueness-Injectivity = [↔]-intro l r where l : (∀{y : B} → Unique(x ↦ y ≡ f(x))) ← Injective(f) l inj {y} {x₁}{x₂} (y≡fx₁) (y≡fx₂) = injective _ ⦃ inj ⦄ {x₁}{x₂} (symmetry(_≡_) (y≡fx₁) 🝖 (y≡fx₂)) r : (∀{y : B} → Unique(x ↦ y ≡ f(x))) → Injective(f) Injective.proof(r unique) {x₁}{x₂} (fx₁≡fx₂) = unique {f(x₁)}{x₁}{x₂} (reflexivity(_≡_)) (fx₁≡fx₂)
{ "alphanum_fraction": 0.6646216769, "avg_line_length": 37.6153846154, "ext": "agda", "hexsha": "333061a284c9ae9b32f4cbc4a5cac4ca9c75ba50", "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/Setoid/Uniqueness/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": "Structure/Setoid/Uniqueness/Proofs.agda", "max_line_length": 103, "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/Setoid/Uniqueness/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": 384, "size": 978 }
{-# OPTIONS --without-K #-} open import lib.Basics open import lib.types.Coproduct open import lib.types.Pointed open import lib.types.Pushout open import lib.types.PushoutFlattening open import lib.types.Span open import lib.types.Unit -- Wedge of two pointed types is defined as a particular case of pushout module lib.types.Wedge where module _ {i j} (X : Ptd i) (Y : Ptd j) where wedge-span : Span wedge-span = span (fst X) (fst Y) Unit (λ _ → snd X) (λ _ → snd Y) Wedge : Type (lmax i j) Wedge = Pushout wedge-span _∨_ = Wedge module _ {i j} {X : Ptd i} {Y : Ptd j} where winl : fst X → X ∨ Y winl x = left x winr : fst Y → X ∨ Y winr y = right y wglue : winl (snd X) == winr (snd Y) wglue = glue tt module _ {i j} (X : Ptd i) (Y : Ptd j) where ⊙Wedge : Ptd (lmax i j) ⊙Wedge = ⊙[ Wedge X Y , winl (snd X) ] _⊙∨_ = ⊙Wedge module _ {i j} {X : Ptd i} {Y : Ptd j} where ⊙winl : fst (X ⊙→ X ⊙∨ Y) ⊙winl = (winl , idp) ⊙winr : fst (Y ⊙→ X ⊙∨ Y) ⊙winr = (winr , ! wglue) module _ {i j} {X : Ptd i} {Y : Ptd j} where module WedgeElim {k} {P : X ∨ Y → Type k} (winl* : (x : fst X) → P (winl x)) (winr* : (y : fst Y) → P (winr y)) (wglue* : winl* (snd X) == winr* (snd Y) [ P ↓ wglue ]) where private module M = PushoutElim winl* winr* (λ _ → wglue*) f = M.f glue-β = M.glue-β unit open WedgeElim public using () renaming (f to Wedge-elim) module WedgeRec {k} {C : Type k} (winl* : fst X → C) (winr* : fst Y → C) (wglue* : winl* (snd X) == winr* (snd Y)) where private module M = PushoutRec {d = wedge-span X Y} winl* winr* (λ _ → wglue*) f = M.f glue-β = M.glue-β unit add-wglue : ∀ {i j} {X : Ptd i} {Y : Ptd j} → fst (X ⊙⊔ Y) → X ∨ Y add-wglue (inl x) = winl x add-wglue (inr y) = winr y ⊙add-wglue : ∀ {i j} {X : Ptd i} {Y : Ptd j} → fst (X ⊙⊔ Y ⊙→ X ⊙∨ Y) ⊙add-wglue = (add-wglue , idp) module Fold {i} {X : Ptd i} = WedgeRec {X = X} {Y = X} (λ x → x) (λ x → x) idp fold = Fold.f ⊙fold : ∀ {i} {X : Ptd i} → fst (X ⊙∨ X ⊙→ X) ⊙fold = (fold , idp)
{ "alphanum_fraction": 0.550794415, "avg_line_length": 22.3333333333, "ext": "agda", "hexsha": "4981d6c47a71a96d6f4ee3438cc1249f5e14da1d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "danbornside/HoTT-Agda", "max_forks_repo_path": "lib/types/Wedge.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "danbornside/HoTT-Agda", "max_issues_repo_path": "lib/types/Wedge.agda", "max_line_length": 75, "max_stars_count": null, "max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "danbornside/HoTT-Agda", "max_stars_repo_path": "lib/types/Wedge.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 911, "size": 2077 }
-- {-# OPTIONS -v impossible:100 -v tc.lhs.imp:100 #-} -- {-# OPTIONS -v impossible:100 -v tc.cover:20 #-} -- {-# OPTIONS --copatterns #-} -- Andreas, 2015-08-26 on by default. module Issue957 where open import Common.Equality record _×_ (A B : Set) : Set where constructor _,_ field fst : A snd : B open _×_ pair : {A B : Set} → A → B → A × B fst (pair a b) = ? snd (pair a b) = ? swap : {A B : Set} → A × B → B × A fst (swap p) = ? snd (swap p) = ? swap3 : {A B C : Set} → A × (B × C) → C × (B × A) fst (swap3 t) = ? fst (snd (swap3 t)) = ? snd (snd (swap3 t)) = ? -- should also work if we shuffle the clauses swap4 : {A B C D : Set} → A × (B × (C × D)) → D × (C × (B × A)) fst (snd (swap4 t)) = ? snd (snd (snd (swap4 t))) = ? fst (swap4 t) = ? fst (snd (snd (swap4 t))) = ? -- multiple clauses with abstractions fswap3 : {A B C X : Set} → (X → A) × ((X → B) × C) → (X → C) × (X → (B × A)) fst (fswap3 t) x = ? fst (snd (fswap3 t) y) = ? snd (snd (fswap3 t) z) = ? -- State monad example -- The State newtype record State (S A : Set) : Set where constructor state field runState : S → A × S open State -- The Monad type class record Monad (M : Set → Set) : Set1 where constructor monad field return : {A : Set} → A → M A _>>=_ : {A B : Set} → M A → (A → M B) → M B module InstanceArgument where open Monad {{...}} -- State is an instance of Monad instance stateMonad : {S : Set} → Monad (State S) runState (return {{stateMonad}} a ) s = ? runState (_>>=_ {{stateMonad}} m k) s₀ = ?
{ "alphanum_fraction": 0.5308176101, "avg_line_length": 22.3943661972, "ext": "agda", "hexsha": "2b4486b0ee5db533fce371beb611accc42720f71", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/interaction/Issue957.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/interaction/Issue957.agda", "max_line_length": 76, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/interaction/Issue957.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 582, "size": 1590 }
module Logic where open import Type renaming (Type to Stmt ; Typeω to Stmtω) public
{ "alphanum_fraction": 0.7764705882, "avg_line_length": 21.25, "ext": "agda", "hexsha": "9e4a4b88a7d64d12ca6c1c3fd67f837cd0c3a9f1", "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": "Logic.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": "Logic.agda", "max_line_length": 64, "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": "Logic.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": 21, "size": 85 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use -- Data.List.Relation.Binary.Equality.Setoid directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary using (Setoid) module Data.List.Relation.Equality.Setoid {a ℓ} (S : Setoid a ℓ) where open import Data.List.Relation.Binary.Equality.Setoid S public
{ "alphanum_fraction": 0.5224489796, "avg_line_length": 32.6666666667, "ext": "agda", "hexsha": "a9cce71633d7335d590d936a7ee7239877c47999", "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/Relation/Equality/Setoid.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/Relation/Equality/Setoid.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/List/Relation/Equality/Setoid.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 90, "size": 490 }
------------------------------------------------------------------------ -- A variant of Coherently with an erased field ------------------------------------------------------------------------ {-# OPTIONS --cubical --guardedness #-} import Equality.Path as P module Lens.Non-dependent.Higher.Coherently.Coinductive.Erased {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq import Equality.Path.Univalence as EPU open import Logical-equivalence using (_⇔_) open import Prelude open import Bijection equality-with-J as B using (_↔_) import Bijection P.equality-with-J as PB open import Equality.Path.Isomorphisms eq open import Equivalence equality-with-J as Eq using (_≃_) import Equivalence P.equality-with-J as PEq open import Equivalence.Erased equality-with-J as EEq using (_≃ᴱ_) open import Function-universe equality-with-J hiding (_∘_) import Function-universe P.equality-with-J as PF open import H-level.Truncation.Propositional.One-step eq as O using (∥_∥¹; ∥∥¹ᴱ→∥∥¹) open import H-level.Truncation.Propositional.One-step.Erased eq as OE using (∥_∥¹ᴱ) open import Univalence-axiom equality-with-J import Univalence-axiom P.equality-with-J as PU open import Lens.Non-dependent.Higher.Coherently.Coinductive eq as C using (Coherently) private variable a b ℓ p p₁ p₂ : Level A A₁ A₂ B C : Type a x y : A f : A → B -- A variant of -- Lens.Non-dependent.Higher.Coherently.Coinductive.Coherently with an -- erased "coherent" field. record Coherentlyᴱ {A : Type a} {B : Type b} (P : {A : Type a} → (A → B) → Type p) (@0 step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ᴱ → B) (f : A → B) : Type p where coinductive field property : P f @0 coherent : Coherentlyᴱ P step (step f property) open Coherentlyᴱ public -- A preservation lemma for Coherentlyᴱ. (See also Coherentlyᴱ-cong -- below.) @0 Coherentlyᴱ-cong′ : {P : {A : Type a} → (A → B) → Type p} {step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ᴱ → B} → Univalence a → (A₁≃A₂ : A₁ ≃ A₂) → Coherentlyᴱ P step (f ∘ _≃_.to A₁≃A₂) ≃ Coherentlyᴱ P step f Coherentlyᴱ-cong′ {f = f} {P = P} {step = step} univ A₁≃A₂ = ≃-elim₁ univ (λ A₁≃A₂ → Coherentlyᴱ P step (f ∘ _≃_.to A₁≃A₂) ≃ Coherentlyᴱ P step f) Eq.id A₁≃A₂ -- Coherently can be converted to Coherentlyᴱ in a certain way -- (assuming univalence). Coherently→Coherentlyᴱ : {P : {A : Type a} → (A → B) → Type p} {step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ → B} → @0 Univalence a → Coherently P step f → Coherentlyᴱ P (λ f p → step f p ∘ ∥∥¹ᴱ→∥∥¹) f Coherently→Coherentlyᴱ _ c .property = c .C.property Coherently→Coherentlyᴱ univ c .coherent = Coherently→Coherentlyᴱ univ (_≃_.from (C.Coherently-cong′ univ O.∥∥¹ᴱ≃∥∥¹) (c .C.coherent)) -- In erased contexts Coherently and Coherentlyᴱ are, in a certain -- sense, logically equivalent (assuming univalence). @0 Coherentlyᴱ⇔Coherently : {P : {A : Type a} → (A → B) → Type p} {step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ → B} → Univalence a → Coherentlyᴱ P (λ f p → step f p ∘ ∥∥¹ᴱ→∥∥¹) f ⇔ Coherently P step f Coherentlyᴱ⇔Coherently univ ._⇔_.from = Coherently→Coherentlyᴱ univ Coherentlyᴱ⇔Coherently univ ._⇔_.to c .C.property = c .property Coherentlyᴱ⇔Coherently univ ._⇔_.to c .C.coherent = Coherentlyᴱ⇔Coherently univ ._⇔_.to (_≃_.to (Coherentlyᴱ-cong′ univ O.∥∥¹ᴱ≃∥∥¹) (c .coherent)) private -- A preservation lemma for Coherentlyᴱ. -- -- The lemma does not use the univalence argument, instead it uses -- EPU.univ (and EPU.≃⇒≡) directly. Coherentlyᴱ-cong-≡ : Block "Coherentlyᴱ-cong-≡" → {A : Type a} {P₁ P₂ : {A : Type a} → (A → B) → Type p} {step₁ : {A : Type a} (f : A → B) → P₁ f → ∥ A ∥¹ᴱ → B} {step₂ : {A : Type a} (f : A → B) → P₂ f → ∥ A ∥¹ᴱ → B} {f : A → B} → Univalence p → (P₁≃P₂ : {A : Type a} (f : A → B) → P₁ f ≃ P₂ f) → ({A : Type a} (f : A → B) (x : P₂ f) → step₁ f (_≃_.from (P₁≃P₂ f) x) ≡ step₂ f x) → Coherentlyᴱ P₁ step₁ f P.≡ Coherentlyᴱ P₂ step₂ f Coherentlyᴱ-cong-≡ {a = a} {B = B} {p = p} ⊠ {P₁ = P₁} {P₂ = P₂} {step₁ = step₁} {step₂ = step₂} {f = f} _ P₁≃P₂′ step₁≡step₂ = P.cong (λ ((P , step) : ∃ λ (P : (A : Type a) → (A → B) → Type p) → {A : Type a} (f : A → B) → P A f → ∥ A ∥¹ᴱ → B) → Coherentlyᴱ (P _) step f) $ Σ-≡,≡→≡′ (P.⟨ext⟩ λ A → P.⟨ext⟩ λ (f : A → B) → EPU.≃⇒≡ (P₁≃P₂ f)) (P.implicit-extensionality P.ext λ A → P.⟨ext⟩ λ f → P.subst (λ P → {A : Type a} (f : A → B) → P A f → ∥ A ∥¹ᴱ → B) (P.⟨ext⟩ λ A → P.⟨ext⟩ λ (f : A → B) → EPU.≃⇒≡ (P₁≃P₂ f)) step₁ f P.≡⟨ P.trans (P.cong (_$ f) $ P.sym $ P.push-subst-implicit-application (P.⟨ext⟩ λ A → P.⟨ext⟩ λ (f : A → B) → EPU.≃⇒≡ (P₁≃P₂ f)) (λ P A → (f : A → B) → P A f → ∥ A ∥¹ᴱ → B) {f = const _} {g = step₁}) $ P.sym $ P.push-subst-application (P.⟨ext⟩ λ A → P.⟨ext⟩ λ (f : A → B) → EPU.≃⇒≡ (P₁≃P₂ f)) (λ P f → P A f → ∥ A ∥¹ᴱ → B) {f = const f} {g = step₁} ⟩ P.subst (λ P → P A f → ∥ A ∥¹ᴱ → B) (P.⟨ext⟩ λ A → P.⟨ext⟩ λ (f : A → B) → EPU.≃⇒≡ (P₁≃P₂ f)) (step₁ f) P.≡⟨⟩ P.subst (λ P → P → ∥ A ∥¹ᴱ → B) (EPU.≃⇒≡ (P₁≃P₂ f)) (step₁ f) P.≡⟨ P.sym $ PU.transport-theorem (λ P → P → ∥ A ∥¹ᴱ → B) (PF.→-cong₁ _) (λ _ → P.refl) EPU.univ (P₁≃P₂ f) (step₁ f) ⟩ PF.→-cong₁ _ (P₁≃P₂ f) (step₁ f) P.≡⟨⟩ step₁ f ∘ PEq._≃_.from (P₁≃P₂ f) P.≡⟨ P.⟨ext⟩ (_↔_.to ≡↔≡ ∘ step₁≡step₂ f) ⟩∎ step₂ f ∎) where P₁≃P₂ : {A : Type a} (f : A → B) → P₁ f PEq.≃ P₂ f P₁≃P₂ f = _↔_.to ≃↔≃ (P₁≃P₂′ f) Σ-≡,≡→≡′ : {P : A → Type b} {p₁ p₂ : Σ A P} → (p : proj₁ p₁ P.≡ proj₁ p₂) → P.subst P p (proj₂ p₁) P.≡ proj₂ p₂ → p₁ P.≡ p₂ Σ-≡,≡→≡′ {P = P} {p₁ = _ , y₁} {p₂ = _ , y₂} p q i = p i , lemma i where lemma : P.[ (λ i → P (p i)) ] y₁ ≡ y₂ lemma = PB._↔_.from (P.heterogeneous↔homogeneous _) q -- A "computation rule". to-Coherentlyᴱ-cong-≡-property : (bl : Block "Coherentlyᴱ-cong-≡") {A : Type a} {B : Type b} {P₁ P₂ : {A : Type a} → (A → B) → Type p} {step₁ : {A : Type a} (f : A → B) → P₁ f → ∥ A ∥¹ᴱ → B} {step₂ : {A : Type a} (f : A → B) → P₂ f → ∥ A ∥¹ᴱ → B} {f : A → B} (univ : Univalence p) (P₁≃P₂ : {A : Type a} (f : A → B) → P₁ f ≃ P₂ f) (step₁≡step₂ : {A : Type a} (f : A → B) (x : P₂ f) → step₁ f (_≃_.from (P₁≃P₂ f) x) ≡ step₂ f x) (c : Coherentlyᴱ P₁ step₁ f) → PU.≡⇒→ (Coherentlyᴱ-cong-≡ bl univ P₁≃P₂ step₁≡step₂) c .property P.≡ _≃_.to (P₁≃P₂ f) (c .property) to-Coherentlyᴱ-cong-≡-property ⊠ {P₁ = P₁} {P₂ = P₂} {f = f} _ P₁≃P₂ step₁≡step₂ c = P.transport (λ _ → P₂ f) P.0̲ (_≃_.to (P₁≃P₂ f) (P.transport (λ _ → P₁ f) P.0̲ (c .property))) P.≡⟨ P.cong (_$ _≃_.to (P₁≃P₂ f) (P.transport (λ _ → P₁ f) P.0̲ (c .property))) $ P.transport-refl P.0̲ ⟩ _≃_.to (P₁≃P₂ f) (P.transport (λ _ → P₁ f) P.0̲ (c .property)) P.≡⟨ P.cong (λ g → _≃_.to (P₁≃P₂ f) (g (c .property))) $ P.transport-refl P.0̲ ⟩∎ _≃_.to (P₁≃P₂ f) (c .property) ∎ -- Another "computation rule". from-Coherentlyᴱ-cong-≡-property : (bl : Block "Coherentlyᴱ-cong-≡") {A : Type a} {B : Type b} {P₁ P₂ : {A : Type a} → (A → B) → Type p} {step₁ : {A : Type a} (f : A → B) → P₁ f → ∥ A ∥¹ᴱ → B} {step₂ : {A : Type a} (f : A → B) → P₂ f → ∥ A ∥¹ᴱ → B} {f : A → B} (univ : Univalence p) (P₁≃P₂ : {A : Type a} (f : A → B) → P₁ f ≃ P₂ f) (step₁≡step₂ : {A : Type a} (f : A → B) (x : P₂ f) → step₁ f (_≃_.from (P₁≃P₂ f) x) ≡ step₂ f x) (c : Coherentlyᴱ P₂ step₂ f) → PEq._≃_.from (PU.≡⇒≃ (Coherentlyᴱ-cong-≡ bl {step₁ = step₁} univ P₁≃P₂ step₁≡step₂)) c .property P.≡ _≃_.from (P₁≃P₂ f) (c .property) from-Coherentlyᴱ-cong-≡-property ⊠ {P₁ = P₁} {P₂ = P₂} {f = f} _ P₁≃P₂ step₁≡step₂ c = P.transport (λ _ → P₁ f) P.0̲ (_≃_.from (P₁≃P₂ f) (P.transport (λ _ → P₂ f) P.0̲ (c .property))) P.≡⟨ P.cong (_$ _≃_.from (P₁≃P₂ f) (P.transport (λ _ → P₂ f) P.0̲ (c .property))) $ P.transport-refl P.0̲ ⟩ _≃_.from (P₁≃P₂ f) (P.transport (λ _ → P₂ f) P.0̲ (c .property)) P.≡⟨ P.cong (λ g → _≃_.from (P₁≃P₂ f) (g (c .property))) $ P.transport-refl P.0̲ ⟩∎ _≃_.from (P₁≃P₂ f) (c .property) ∎ -- A preservation lemma for Coherentlyᴱ. -- -- The two directions of this equivalence compute the property -- fields in certain ways, see the "unit tests" below. -- -- Note that P₁ and P₂ have to target the same universe. A more -- general result is given below (Coherentlyᴱ-cong). Coherentlyᴱ-cong-≃ᴱ : {A : Type a} {P₁ P₂ : {A : Type a} → (A → B) → Type p} {@0 step₁ : {A : Type a} (f : A → B) → P₁ f → ∥ A ∥¹ᴱ → B} {@0 step₂ : {A : Type a} (f : A → B) → P₂ f → ∥ A ∥¹ᴱ → B} {f : A → B} → @0 Univalence p → (P₁≃P₂ : {A : Type a} (f : A → B) → P₁ f ≃ᴱ P₂ f) → @0 ({A : Type a} (f : A → B) (x : P₂ f) → step₁ f (_≃ᴱ_.from (P₁≃P₂ f) x) ≡ step₂ f x) → Coherentlyᴱ P₁ step₁ f ≃ᴱ Coherentlyᴱ P₂ step₂ f Coherentlyᴱ-cong-≃ᴱ {P₁ = P₁} {P₂ = P₂} {step₁ = step₁} {step₂ = step₂} {f = f} univ P₁≃P₂ step₁≡step₂ = block λ bl → EEq.[≃]→≃ᴱ (EEq.[proofs] (Eq.with-other-inverse (Eq.with-other-function (equiv bl) (to bl) (_↔_.from ≡↔≡ ∘ ≡to bl)) (from bl) (_↔_.from ≡↔≡ ∘ ≡from bl))) where @0 equiv : Block "Coherentlyᴱ-cong-≡" → Coherentlyᴱ P₁ step₁ f ≃ Coherentlyᴱ P₂ step₂ f equiv bl = _↔_.from ≃↔≃ $ PU.≡⇒≃ $ Coherentlyᴱ-cong-≡ bl univ (EEq.≃ᴱ→≃ ∘ P₁≃P₂) step₁≡step₂ to : Block "Coherentlyᴱ-cong-≡" → Coherentlyᴱ P₁ step₁ f → Coherentlyᴱ P₂ step₂ f to _ c .property = _≃ᴱ_.to (P₁≃P₂ f) (c .property) to bl c .coherent = P.subst (Coherentlyᴱ P₂ step₂) (P.cong (step₂ f) $ to-Coherentlyᴱ-cong-≡-property bl univ (EEq.≃ᴱ→≃ ∘ P₁≃P₂) step₁≡step₂ c) $ _≃_.to (equiv bl) c .coherent @0 ≡to : ∀ bl c → _≃_.to (equiv bl) c P.≡ to bl c ≡to bl c i .property = to-Coherentlyᴱ-cong-≡-property bl univ (EEq.≃ᴱ→≃ ∘ P₁≃P₂) step₁≡step₂ c i ≡to bl c i .coherent = lemma i where lemma : P.[ (λ i → Coherentlyᴱ P₂ step₂ (step₂ f (to-Coherentlyᴱ-cong-≡-property bl univ (EEq.≃ᴱ→≃ ∘ P₁≃P₂) step₁≡step₂ c i))) ] _≃_.to (equiv bl) c .coherent ≡ P.subst (Coherentlyᴱ P₂ step₂) (P.cong (step₂ f) $ to-Coherentlyᴱ-cong-≡-property bl univ (EEq.≃ᴱ→≃ ∘ P₁≃P₂) step₁≡step₂ c) (_≃_.to (equiv bl) c .coherent) lemma = PB._↔_.from (P.heterogeneous↔homogeneous _) P.refl from : Block "Coherentlyᴱ-cong-≡" → Coherentlyᴱ P₂ step₂ f → Coherentlyᴱ P₁ step₁ f from _ c .property = _≃ᴱ_.from (P₁≃P₂ f) (c .property) from bl c .coherent = P.subst (Coherentlyᴱ P₁ step₁) (P.cong (step₁ f) $ from-Coherentlyᴱ-cong-≡-property bl univ (EEq.≃ᴱ→≃ ∘ P₁≃P₂) step₁≡step₂ c) $ _≃_.from (equiv bl) c .coherent @0 ≡from : ∀ bl c → _≃_.from (equiv bl) c P.≡ from bl c ≡from bl c i .property = from-Coherentlyᴱ-cong-≡-property bl univ (EEq.≃ᴱ→≃ ∘ P₁≃P₂) step₁≡step₂ c i ≡from bl c i .coherent = lemma i where lemma : P.[ (λ i → Coherentlyᴱ P₁ step₁ (step₁ f (from-Coherentlyᴱ-cong-≡-property bl univ (EEq.≃ᴱ→≃ ∘ P₁≃P₂) step₁≡step₂ c i))) ] _≃_.from (equiv bl) c .coherent ≡ P.subst (Coherentlyᴱ P₁ step₁) (P.cong (step₁ f) $ from-Coherentlyᴱ-cong-≡-property bl univ (EEq.≃ᴱ→≃ ∘ P₁≃P₂) step₁≡step₂ c) (_≃_.from (equiv bl) c .coherent) lemma = PB._↔_.from (P.heterogeneous↔homogeneous _) P.refl -- Unit tests that ensure that Coherentlyᴱ-cong-≃ᴱ computes the -- property fields in certain ways. module _ {A : Type a} {P₁ P₂ : {A : Type a} → (A → B) → Type p} {@0 step₁ : {A : Type a} (f : A → B) → P₁ f → ∥ A ∥¹ᴱ → B} {@0 step₂ : {A : Type a} (f : A → B) → P₂ f → ∥ A ∥¹ᴱ → B} {f : A → B} {@0 univ : Univalence p} {P₁≃P₂ : {A : Type a} (f : A → B) → P₁ f ≃ᴱ P₂ f} {@0 step₁≡step₂ : {A : Type a} (f : A → B) (x : P₂ f) → step₁ f (_≃ᴱ_.from (P₁≃P₂ f) x) ≡ step₂ f x} where _ : {c : Coherentlyᴱ P₁ step₁ f} → _≃ᴱ_.to (Coherentlyᴱ-cong-≃ᴱ univ P₁≃P₂ step₁≡step₂) c .property ≡ _≃ᴱ_.to (P₁≃P₂ f) (c .property) _ = refl _ _ : {c : Coherentlyᴱ P₂ step₂ f} → _≃ᴱ_.from (Coherentlyᴱ-cong-≃ᴱ {step₁ = step₁} univ P₁≃P₂ step₁≡step₂) c .property ≡ _≃ᴱ_.from (P₁≃P₂ f) (c .property) _ = refl _ -- A lemma involving Coherentlyᴱ and ↑. Coherentlyᴱ-↑ : {A : Type a} {P : {A : Type a} → (A → B) → Type p} {@0 step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ᴱ → B} {f : A → B} → Coherentlyᴱ (↑ ℓ ∘ P) ((_∘ lower) ∘ step) f ≃ Coherentlyᴱ P step f Coherentlyᴱ-↑ {ℓ = ℓ} {P = P} {step = step} = Eq.↔→≃ to from (_↔_.from ≡↔≡ ∘ to-from) (_↔_.from ≡↔≡ ∘ from-to) where to : Coherentlyᴱ (↑ ℓ ∘ P) ((_∘ lower) ∘ step) f → Coherentlyᴱ P step f to c .property = lower (c .property) to c .coherent = to (c .coherent) from : Coherentlyᴱ P step f → Coherentlyᴱ (↑ ℓ ∘ P) ((_∘ lower) ∘ step) f from c .property = lift (c .property) from c .coherent = from (c .coherent) to-from : (c : Coherentlyᴱ P step f) → to (from c) P.≡ c to-from c i .property = c .property to-from c i .coherent = to-from (c .coherent) i from-to : (c : Coherentlyᴱ (↑ ℓ ∘ P) ((_∘ lower) ∘ step) f) → from (to c) P.≡ c from-to c i .property = c .property from-to c i .coherent = from-to (c .coherent) i -- A preservation lemma for Coherentlyᴱ. -- -- The two directions of this equivalence compute the property -- fields in certain ways, see the "unit tests" below. Coherentlyᴱ-cong : {A : Type a} {P₁ : {A : Type a} → (A → B) → Type p₁} {P₂ : {A : Type a} → (A → B) → Type p₂} {@0 step₁ : {A : Type a} (f : A → B) → P₁ f → ∥ A ∥¹ᴱ → B} {@0 step₂ : {A : Type a} (f : A → B) → P₂ f → ∥ A ∥¹ᴱ → B} {f : A → B} → @0 Univalence (p₁ ⊔ p₂) → (P₁≃P₂ : {A : Type a} (f : A → B) → P₁ f ≃ᴱ P₂ f) → @0 ({A : Type a} (f : A → B) (x : P₂ f) → step₁ f (_≃ᴱ_.from (P₁≃P₂ f) x) ≡ step₂ f x) → Coherentlyᴱ P₁ step₁ f ≃ᴱ Coherentlyᴱ P₂ step₂ f Coherentlyᴱ-cong {p₁ = p₁} {p₂ = p₂} {P₁ = P₁} {P₂ = P₂} {step₁ = step₁} {step₂ = step₂} {f = f} univ P₁≃P₂ step₁≡step₂ = Coherentlyᴱ P₁ step₁ f ↔⟨ inverse Coherentlyᴱ-↑ ⟩ Coherentlyᴱ (↑ p₂ ∘ P₁) ((_∘ lower) ∘ step₁) f ↝⟨ Coherentlyᴱ-cong-≃ᴱ univ (λ f → ↑ p₂ (P₁ f) ↔⟨ B.↑↔ ⟩ P₁ f ↝⟨ P₁≃P₂ f ⟩ P₂ f ↔⟨ inverse B.↑↔ ⟩□ ↑ p₁ (P₂ f) □) ((_∘ lower) ∘ step₁≡step₂) ⟩ Coherentlyᴱ (↑ p₁ ∘ P₂) ((_∘ lower) ∘ step₂) f ↔⟨ Coherentlyᴱ-↑ ⟩□ Coherentlyᴱ P₂ step₂ f □ -- Unit tests that ensure that Coherentlyᴱ-cong computes the property -- fields in certain ways. module _ {A : Type a} {P₁ : {A : Type a} → (A → B) → Type p₁} {P₂ : {A : Type a} → (A → B) → Type p₂} {@0 step₁ : {A : Type a} (f : A → B) → P₁ f → ∥ A ∥¹ᴱ → B} {@0 step₂ : {A : Type a} (f : A → B) → P₂ f → ∥ A ∥¹ᴱ → B} {f : A → B} {@0 univ : Univalence (p₁ ⊔ p₂)} {P₁≃P₂ : {A : Type a} (f : A → B) → P₁ f ≃ᴱ P₂ f} {@0 step₁≡step₂ : {A : Type a} (f : A → B) (x : P₂ f) → step₁ f (_≃ᴱ_.from (P₁≃P₂ f) x) ≡ step₂ f x} where _ : {c : Coherentlyᴱ P₁ step₁ f} → _≃ᴱ_.to (Coherentlyᴱ-cong univ P₁≃P₂ step₁≡step₂) c .property ≡ _≃ᴱ_.to (P₁≃P₂ f) (c .property) _ = refl _ _ : {c : Coherentlyᴱ P₂ step₂ f} → _≃ᴱ_.from (Coherentlyᴱ-cong {step₁ = step₁} univ P₁≃P₂ step₁≡step₂) c .property ≡ _≃ᴱ_.from (P₁≃P₂ f) (c .property) _ = refl _ -- A "computation rule". subst-Coherentlyᴱ-property : ∀ {B : Type b} {P : C → {A : Type a} → (A → B) → Type p} {@0 step : (c : C) {A : Type a} (f : A → B) → P c f → ∥ A ∥¹ᴱ → B} {f : C → A → B} {eq : x ≡ y} {c} → subst (λ x → Coherentlyᴱ (P x) (step x) (f x)) eq c .property ≡ subst (λ x → P x (f x)) eq (c .property) subst-Coherentlyᴱ-property {P = P} {step = step} {f = f} {eq = eq} {c = c} = elim¹ (λ eq → subst (λ x → Coherentlyᴱ (P x) (step x) (f x)) eq c .property ≡ subst (λ x → P x (f x)) eq (c .property)) (subst (λ x → Coherentlyᴱ (P x) (step x) (f x)) (refl _) c .property ≡⟨ cong property $ subst-refl _ _ ⟩ c .property ≡⟨ sym $ subst-refl _ _ ⟩∎ subst (λ x → P x (f x)) (refl _) (c .property) ∎) eq
{ "alphanum_fraction": 0.4442417794, "avg_line_length": 38.548828125, "ext": "agda", "hexsha": "79c6cd1d34b3fb56e47c3f12ed2ddd58e30c992d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-07-01T14:33:26.000Z", "max_forks_repo_forks_event_min_datetime": "2020-07-01T14:33:26.000Z", "max_forks_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/dependent-lenses", "max_forks_repo_path": "src/Lens/Non-dependent/Higher/Coherently/Coinductive/Erased.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "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/dependent-lenses", "max_issues_repo_path": "src/Lens/Non-dependent/Higher/Coherently/Coinductive/Erased.agda", "max_line_length": 146, "max_stars_count": 3, "max_stars_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/dependent-lenses", "max_stars_repo_path": "src/Lens/Non-dependent/Higher/Coherently/Coinductive/Erased.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:55:52.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T12:10:46.000Z", "num_tokens": 8013, "size": 19737 }
postulate F : (Set → Set) → Set !_ : Set → Set !_,_ : Set → Set → Set X : Set syntax F (λ X → A) = X , A infix 1 F infix 2 !_ Foo : Set Foo = ! X , X -- This expression can be parsed in exactly one way. However, Agda -- rejects it: -- -- Expected variable name in binding position -- -- The error is thrown from pure code in rebuildBinding, and this -- action circumvents the parser logic. -- -- The error was introduced in the fix for Issue 1129, and the problem -- raised in Issue 1129 was introduced in a fix for Issue 1108 -- ("Operator parser performance").
{ "alphanum_fraction": 0.6564102564, "avg_line_length": 22.5, "ext": "agda", "hexsha": "319696614f10c369f4d3a87d64609b941dc95686", "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/Issue1450.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/Issue1450.agda", "max_line_length": 70, "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/Issue1450.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": 173, "size": 585 }
{-# OPTIONS --cubical --safe #-} open import Algebra open import Prelude open import HITs.PropositionalTruncation open import HITs.PropositionalTruncation.Sugar module Algebra.Construct.Cayley {a} (mon : Monoid a) where open Monoid mon 𝒞 : Type a 𝒞 = Σ[ f ⦂ (𝑆 → 𝑆) ] × ∀ x → ∥ f ε ∙ x ≡ f x ∥ ⟦_⇓⟧ : 𝒞 → 𝑆 ⟦ x ⇓⟧ = x .fst ε ⟦_⇑⟧ : 𝑆 → 𝒞 ⟦ x ⇑⟧ .fst y = x ∙ y ⟦ x ⇑⟧ .snd y = ∣ cong (_∙ y) (∙ε x) ∣ ⓔ : 𝒞 ⓔ .fst x = x ⓔ .snd x = ∣ ε∙ x ∣ open import Relation.Binary open import HITs.PropositionalTruncation.Equivalence open import Relation.Binary.Equivalence.Reasoning (trunc-equivalence (≡-equivalence {A = 𝑆})) _⊙_ : 𝒞 → 𝒞 → 𝒞 (x ⊙ y) .fst z = x .fst (y .fst z) (x ⊙ y) .snd z = x .fst (y .fst ε) ∙ z ≋˘⟨ cong (_∙ z) ∥$∥ (x .snd (y .fst ε)) ⟩ x .fst ε ∙ y .fst ε ∙ z ≡⟨ assoc (x .fst ε) (y .fst ε) z ⟩ x .fst ε ∙ (y .fst ε ∙ z) ≋⟨ cong (x .fst ε ∙_) ∥$∥ (y .snd z) ⟩ x .fst ε ∙ y .fst z ≋⟨ x .snd (y .fst z) ⟩ x .fst (y .fst z) ∎ ⊙-assoc : Associative _⊙_ ⊙-assoc x y z i .fst k = x .fst (y .fst (z .fst k)) ⊙-assoc x y z i .snd k = squash (((x ⊙ y) ⊙ z) .snd k) ((x ⊙ (y ⊙ z)) .snd k) i ⓔ⊙ : ∀ x → ⓔ ⊙ x ≡ x ⓔ⊙ x i .fst y = x .fst y ⓔ⊙ x i .snd y = squash ((ⓔ ⊙ x) .snd y) (x .snd y) i ⊙ⓔ : ∀ x → x ⊙ ⓔ ≡ x ⊙ⓔ x i .fst y = x .fst y ⊙ⓔ x i .snd y = squash ((x ⊙ ⓔ) .snd y) (x .snd y) i cayleyMonoid : Monoid a Monoid.𝑆 cayleyMonoid = 𝒞 Monoid._∙_ cayleyMonoid = _⊙_ Monoid.ε cayleyMonoid = ⓔ Monoid.assoc cayleyMonoid = ⊙-assoc Monoid.ε∙ cayleyMonoid = ⓔ⊙ Monoid.∙ε cayleyMonoid = ⊙ⓔ open import Data.Sigma.Properties module _ (sIsSet : isSet 𝑆) where 𝒞-leftInv-fst : ∀ x y → ⟦ ⟦ x ⇓⟧ ⇑⟧ .fst y ≡ x .fst y 𝒞-leftInv-fst x y = rec (sIsSet (x .fst ε ∙ y) (x .fst y)) id (x .snd y) 𝒞-leftInv : ∀ x → ⟦ ⟦ x ⇓⟧ ⇑⟧ ≡ x 𝒞-leftInv x = Σ≡Prop (λ f xs ys → funExt λ x → squash (xs x) (ys x)) (funExt (𝒞-leftInv-fst x)) 𝒞-iso : 𝒞 ⇔ 𝑆 fun 𝒞-iso = ⟦_⇓⟧ inv 𝒞-iso = ⟦_⇑⟧ rightInv 𝒞-iso = ∙ε leftInv 𝒞-iso = 𝒞-leftInv
{ "alphanum_fraction": 0.5412423625, "avg_line_length": 26.5405405405, "ext": "agda", "hexsha": "a05a7848e29db3363ead95e9f1210553e3a2163c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Algebra/Construct/Cayley.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Algebra/Construct/Cayley.agda", "max_line_length": 97, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Algebra/Construct/Cayley.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": 1069, "size": 1964 }
-- Agda program using the Iowa Agda library {-# OPTIONS --termination-depth=2 #-} module PROOF-gamelength where open import eq open import bool open import nat open import nat-thms open import list open import nondet open import nondet-thms --------------------------------------------------------------------------- -- Translated Curry operations: data Move : Set where L : Move R : Move solve2 : ℕ → ℕ → ND (𝕃 Move) solve2 zero zero = Val [] solve2 (suc x) zero = mapND (_::_ L) (solve2 x zero) solve2 zero (suc y) = mapND (_::_ R) (solve2 zero y) solve2 (suc z) (suc u) = (mapND (_::_ L) (solve2 z (suc u))) ?? (mapND (_::_ R) (solve2 (suc z) u)) len : {a : Set} → 𝕃 a → ℕ len [] = zero len (x :: y) = suc (len y) --------------------------------------------------------------------------- -- Theorem: the length of every solution is the sum of the input arguments gamelength : (x : ℕ) → (y : ℕ) → (solve2 x y) satisfy (λ xs → length xs =ℕ x + y) ≡ tt gamelength zero zero = refl gamelength zero (suc y) rewrite satisfy-mapND (_::_ R) (solve2 zero y) (λ xs → length xs =ℕ zero + suc y) | gamelength zero y = refl gamelength (suc x) zero rewrite satisfy-mapND (_::_ L) (solve2 x zero) (λ xs → length xs =ℕ suc x + zero) | gamelength x zero = refl gamelength (suc x) (suc y) rewrite satisfy-mapND (_::_ L) (solve2 x (suc y)) (λ xs → length xs =ℕ suc x + suc y) | satisfy-mapND (_::_ R) (solve2 (suc x) y) (λ xs → length xs =ℕ suc x + suc y) | gamelength x (suc y) | +suc x y | gamelength (suc x) y = refl ---------------------------------------------------------------------------
{ "alphanum_fraction": 0.528177458, "avg_line_length": 29.2631578947, "ext": "agda", "hexsha": "4bca6e9f711b6b7980bf55d4e6a01c95f84f26fb", "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": "7905bc4f625a94a725f9f6d8a2de1140bea5e471", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "phlummox/curry-tools", "max_forks_repo_path": "currypp/.cpm/packages/verify/examples/PROOF-gamelength.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7905bc4f625a94a725f9f6d8a2de1140bea5e471", "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": "phlummox/curry-tools", "max_issues_repo_path": "currypp/.cpm/packages/verify/examples/PROOF-gamelength.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "7905bc4f625a94a725f9f6d8a2de1140bea5e471", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "phlummox/curry-tools", "max_stars_repo_path": "currypp/.cpm/packages/verify/examples/PROOF-gamelength.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 513, "size": 1668 }
module Equality where open import Function using (_∘_) open import Relation.Binary.PropositionalEquality using (_≡_) open import Data.Product using (_×_; _,_; ∃-syntax; proj₁; proj₂) open import Data.Bool using (Bool; true; false) open import Data.Nat using (ℕ) -- -- Relation -- record Relation (R : Set → Set) (A : Set) : Set where field relate : A × A → Bool to-witness : ∀ x → relate x ≡ true → R A from-witness : R A → ∃[ x ] (relate x ≡ true) to-from-witness : ∀ x d → x ≡ (proj₁ ∘ from-witness) (to-witness x d) Related : A × A → Set Related (x , y) = R A × relate (x , y) ≡ true -- Properties IsReflexive : ∀ R A (rel : Relation R A) → Set IsReflexive R A rel = ∀ x → Related (x , x) where open Relation rel IsSymmetric : ∀ R A (rel : Relation R A) → Set IsSymmetric R A rel = ∀ x y → Related (x , y) → Related (y , x) where open Relation rel IsTransitive : ∀ R A (rel : Relation R A) → Set IsTransitive R A rel = ∀ x y z → Related (x , y) → Related (y , z) → Related (x , z) where open Relation rel -- -- Equality -- record Equality (E : Set → Set) (A : Set) : Set where field rel : Relation E A isReflexive : IsReflexive E A rel isSymmetric : IsSymmetric E A rel isTransitive : IsTransitive E A rel -- -- SMT Equality -- postulate -- datatype EqualitySMT : ∀ A → A → A → Set -- instances equalitySMT-Bool : Equality EqualitySMT Bool equalitySMT-ℕ : Equality EqualitySMT ℕ -- eq-smt : (A : Set) (x y : A) → Bool -- -- Propositional Equality -- postulate eq-prop : ∀ (A : Set) (x y : A) → Bool data EqualityProp : ∀ A → A → A → Set where injection-SMT : ∀ (A : Set) (equ : Equality EqualitySMT A) x y → Relation.Related EqualitySMT (x , y) → Relation.Related EqualityProp (x , y) -- extensional : -- ∀ (A B : Set) f g → -- (∀ x → EqualityProp
{ "alphanum_fraction": 0.6038236856, "avg_line_length": 22.4166666667, "ext": "agda", "hexsha": "4d173c6ca7f5eee294dcaf24d565acc211b0d0e8", "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": "525a3d42431bf5dc6837939441f389ea5cead937", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Riib11/monadic-equality", "max_forks_repo_path": "proto/agda/Equality.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "525a3d42431bf5dc6837939441f389ea5cead937", "max_issues_repo_issues_event_max_datetime": "2021-02-25T15:49:12.000Z", "max_issues_repo_issues_event_min_datetime": "2021-02-25T15:49:12.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "Riib11/monadic-equality", "max_issues_repo_path": "proto/agda/Equality.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "525a3d42431bf5dc6837939441f389ea5cead937", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "Riib11/monadic-equality", "max_stars_repo_path": "proto/agda/Equality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 624, "size": 1883 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Basic definitions for Characters ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Char.Base where ------------------------------------------------------------------------ -- Re-export the type, and renamed primitives open import Agda.Builtin.Char public using ( Char ) renaming -- testing ( primIsLower to isLower ; primIsDigit to isDigit ; primIsAlpha to isAlpha ; primIsSpace to isSpace ; primIsAscii to isAscii ; primIsLatin1 to isLatin1 ; primIsPrint to isPrint ; primIsHexDigit to isHexDigit -- transforming ; primToUpper to toUpper ; primToLower to toLower -- converting ; primCharToNat to toNat ; primNatToChar to fromNat ) open import Agda.Builtin.String public using () renaming ( primShowChar to show )
{ "alphanum_fraction": 0.5445960126, "avg_line_length": 27.2285714286, "ext": "agda", "hexsha": "8cc4035ce4799e6f1cb1179ee82ee805bb9cb222", "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/Char/Base.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/Char/Base.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/Char/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 211, "size": 953 }
open import Nat open import Prelude open import List open import core open import contexts module lemmas-freevars where mutual -- if e successfully type-checks via analysis, under a context which -- can only bind x in the final position, then the free vars of e, with -- the context's last binder removed, cannot contain x. rff-lemma-ana : ∀{Γ x x' e τ₁ τ₂} → x # Γ → (Γ ,, (x' , τ₁)) ⊢ e <= τ₂ → x inList remove-from-free' x' e → ⊥ rff-lemma-ana {_} {x} {x'} {e} h₁ h₂ h₃ with natEQ x x' rff-lemma-ana {Γ} {x} {x'} {e} h₁ h₂ h₃ | Inl x==x' = remove-all-not-in natEQ (free-vars e) x' (tr ( λ y → y inList remove-all natEQ (free-vars e) x') x==x' h₃) rff-lemma-ana {Γ} {x} {x'} {e} {τ₁} h₁ h₂ h₃ | Inr x≠x' = a∉l→a∉remove-all-l-a' natEQ (fv-lemma-ana (lem-none-union {Γ = Γ} {τ₁} (flip x≠x') h₁) h₂) h₃ -- as above rff-lemma-syn : ∀{Γ x x' e τ₁ τ₂} → x # Γ → (Γ ,, (x' , τ₁)) ⊢ e => τ₂ → x inList remove-from-free' x' e → ⊥ rff-lemma-syn {Γ} {x} {x'} {e} h₁ h₂ h₃ with natEQ x x' rff-lemma-syn {Γ} {x} {x'} {e} h₁ h₂ h₃ | Inl x==x' = remove-all-not-in natEQ (free-vars e) x' (tr ( λ y → y inList remove-all natEQ (free-vars e) x') x==x' h₃) rff-lemma-syn {Γ} {x} {x'} {e} {τ₁} h₁ h₂ h₃ | Inr x≠x' = a∉l→a∉remove-all-l-a' natEQ (fv-lemma-syn (lem-none-union {Γ = Γ} {τ₁} (flip x≠x') h₁) h₂) h₃ -- if e analysizes against type under a context that doesn't mention x, -- x is not in free vars of e fv-lemma-ana : ∀{Γ x e τ} → x # Γ → Γ ⊢ e <= τ → x inList (free-vars e) → ⊥ fv-lemma-ana h₁ (ASubsume x₁ x₂) = fv-lemma-syn h₁ x₁ fv-lemma-ana {Γ} h₁ (ALam x₂ x₃ h₂) = rff-lemma-ana {Γ} h₁ h₂ -- if e synthesizes a type under a context that doesn't mention x, x is -- not in free vars of e fv-lemma-syn : ∀{Γ x e τ} → x # Γ → Γ ⊢ e => τ → x inList (free-vars e) → ⊥ fv-lemma-syn apt SConst () fv-lemma-syn apt (SAsc x₁) = fv-lemma-ana apt x₁ fv-lemma-syn apt (SVar x₂) InH = somenotnone (! x₂ · apt) fv-lemma-syn apt (SVar x₂) (InT ()) fv-lemma-syn apt (SAp {e1 = e1} x₁ wt x₂ x₃) xin with inList++ {l1 = free-vars e1} natEQ xin ... | Inl x₄ = fv-lemma-syn apt wt x₄ ... | Inr x₄ = fv-lemma-ana apt x₃ x₄ fv-lemma-syn apt SEHole () fv-lemma-syn apt (SNEHole x₁ wt) = fv-lemma-syn apt wt fv-lemma-syn {Γ} apt (SLam x₂ wt) xin = rff-lemma-syn {Γ} apt wt xin fv-lemma-syn apt (SFst wt x₁) = fv-lemma-syn apt wt fv-lemma-syn apt (SSnd wt x₁) = fv-lemma-syn apt wt fv-lemma-syn apt (SPair {e1 = e1} x₁ wt wt₁) xin with inList++ {l1 = free-vars e1} natEQ xin ... | Inl y = fv-lemma-syn apt wt y ... | Inr y = fv-lemma-syn apt wt₁ y
{ "alphanum_fraction": 0.5826538176, "avg_line_length": 53.96, "ext": "agda", "hexsha": "6dc9e4b0be8648d93c324316e4172ba428f3a6ed", "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": "lemmas-freevars.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": "lemmas-freevars.agda", "max_line_length": 170, "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": "lemmas-freevars.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": 1174, "size": 2698 }
------------------------------------------------------------------------ -- A definitional interpreter that is instrumented with information -- about the stack size of the compiled program ------------------------------------------------------------------------ open import Prelude import Lambda.Syntax module Lambda.Interpreter.Stack-sizes {Name : Type} (open Lambda.Syntax Name) (def : Name → Tm 1) where import Equality.Propositional as E open import Logical-equivalence using (_⇔_) open import Prelude.Size open import Colist E.equality-with-J as C open import Conat E.equality-with-J as Conat using (infinity) open import Function-universe E.equality-with-J hiding (id; _∘_) open import Monad E.equality-with-J open import Nat E.equality-with-J open import Vec.Data E.equality-with-J open import Delay-monad open import Delay-monad.Bisimilarity as D using (later; force) open import Upper-bounds open import Lambda.Compiler def open import Lambda.Delay-crash as DC hiding (crash) open import Lambda.Delay-crash-trace as DCT hiding (tell) import Lambda.Interpreter def as I open Closure Tm open Delay-crash-trace using (tell) ------------------------------------------------------------------------ -- The interpreter -- A stack size change function used in the interpreter's call case. δ : In-tail-context → ℕ → ℕ δ tc = if tc then pred else id infix 10 [_,_]_∙_ mutual -- The semantics instrumented with stack size changes (functions of -- type ℕ → ℕ). The semantics takes an argument of type -- In-tail-context, so that it can produce annotations matching -- those produced by the compiler + virtual machine. ⟦_⟧ : ∀ {i n} → Tm n → Env n → In-tail-context → Delay-crash-trace (ℕ → ℕ) Value i ⟦ var x ⟧ ρ _ = tell suc (return (index ρ x)) ⟦ lam t ⟧ ρ _ = tell suc (return (lam t ρ)) ⟦ t₁ · t₂ ⟧ ρ _ = do v₁ ← ⟦ t₁ ⟧ ρ false v₂ ← ⟦ t₂ ⟧ ρ false [ pred , pred ] v₁ ∙ v₂ ⟦ call f t ⟧ ρ tc = do v ← ⟦ t ⟧ ρ false [ δ tc , δ (not tc) ] lam (def f) [] ∙ v ⟦ con b ⟧ ρ _ = tell suc (return (con b)) ⟦ if t₁ t₂ t₃ ⟧ ρ tc = do v₁ ← ⟦ t₁ ⟧ ρ false ⟦if⟧ v₁ t₂ t₃ ρ tc [_,_]_∙_ : ∀ {i} → (ℕ → ℕ) → (ℕ → ℕ) → Value → Value → Delay-crash-trace (ℕ → ℕ) Value i [ f₁ , f₂ ] lam t₁ ρ ∙ v₂ = later f₁ λ { .force → do v ← ⟦ t₁ ⟧ (v₂ ∷ ρ) true tell f₂ (return v) } [ _ , _ ] con _ ∙ _ = crash ⟦if⟧ : ∀ {i n} → Value → Tm n → Tm n → Env n → In-tail-context → Delay-crash-trace (ℕ → ℕ) Value i ⟦if⟧ (lam _ _) _ _ _ _ = crash ⟦if⟧ (con true) t₂ t₃ ρ tc = tell pred (⟦ t₂ ⟧ ρ tc) ⟦if⟧ (con false) t₂ t₃ ρ tc = tell pred (⟦ t₃ ⟧ ρ tc) -- The numbers produced by a given computation, for a given initial -- number. The initial number is the first element in the output. numbers : ∀ {A i} → Delay-crash-trace (ℕ → ℕ) A i → ℕ → Colist ℕ i numbers x n = scanl (λ m f → f m) n (trace x) -- The stack sizes, for an empty initial stack, with false as the -- In-tail-context argument. -- -- Note that this colist is not guaranteed to match the one generated -- by the virtual machine exactly. However, they are guaranteed to -- have the same least upper bound. stack-sizes : ∀ {i} → Tm 0 → Colist ℕ i stack-sizes t = numbers (⟦ t ⟧ [] false) 0 ------------------------------------------------------------------------ -- The semantics given above gives the same (uninstrumented) result as -- the one in Lambda.Interpreter mutual -- The instrumented and the uninstrumented semantics yield strongly -- bisimilar results. ⟦⟧∼⟦⟧ : ∀ {i n} (t : Tm n) {ρ : Env n} tc → D.[ i ] delay-crash (⟦ t ⟧ ρ tc) ∼ I.⟦ t ⟧ ρ ⟦⟧∼⟦⟧ (var x) _ = D.reflexive _ ⟦⟧∼⟦⟧ (lam t) _ = D.reflexive _ ⟦⟧∼⟦⟧ (t₁ · t₂) {ρ} _ = delay-crash (⟦ t₁ ⟧ ρ false >>= λ v₁ → ⟦ t₂ ⟧ ρ false >>= λ v₂ → [ pred , pred ] v₁ ∙ v₂) D.∼⟨ delay-crash->>= (⟦ t₁ ⟧ _ _) ⟩ (delay-crash (⟦ t₁ ⟧ ρ false) >>= λ v₁ → delay-crash (⟦ t₂ ⟧ ρ false >>= λ v₂ → [ pred , pred ] v₁ ∙ v₂)) D.∼⟨ ((delay-crash (⟦ t₁ ⟧ _ _) D.∎) DC.>>=-cong λ _ → delay-crash->>= (⟦ t₂ ⟧ _ _)) ⟩ (delay-crash (⟦ t₁ ⟧ ρ false) >>= λ v₁ → delay-crash (⟦ t₂ ⟧ ρ false) >>= λ v₂ → delay-crash ([ pred , pred ] v₁ ∙ v₂)) D.∼⟨ (⟦⟧∼⟦⟧ t₁ _ DC.>>=-cong λ v₁ → ⟦⟧∼⟦⟧ t₂ _ DC.>>=-cong λ _ → ∙∼∙ pred v₁) ⟩∼ (I.⟦ t₁ ⟧ ρ >>= λ v₁ → I.⟦ t₂ ⟧ ρ >>= λ v₂ → v₁ I.∙ v₂) D.∎ ⟦⟧∼⟦⟧ (call f t) {ρ} tc = delay-crash (⟦ t ⟧ ρ false >>= λ v → [ _ , _ ] lam (def f) [] ∙ v) D.∼⟨ delay-crash->>= (⟦ t ⟧ _ _) ⟩ (delay-crash (⟦ t ⟧ ρ false) >>= λ v → delay-crash ([ δ tc , _ ] lam (def f) [] ∙ v)) D.∼⟨ (⟦⟧∼⟦⟧ t _ DC.>>=-cong λ _ → ∙∼∙ (δ tc) (lam (def f) [])) ⟩∼ (I.⟦ t ⟧ ρ >>= λ v → lam (def f) [] I.∙ v) D.∎ ⟦⟧∼⟦⟧ (con b) _ = D.reflexive _ ⟦⟧∼⟦⟧ (if t₁ t₂ t₃) {ρ} tc = (delay-crash (⟦ t₁ ⟧ ρ false >>= λ v₁ → ⟦if⟧ v₁ t₂ t₃ ρ tc)) D.∼⟨ delay-crash->>= (⟦ t₁ ⟧ _ _) ⟩ (delay-crash (⟦ t₁ ⟧ ρ false) >>= λ v₁ → delay-crash (⟦if⟧ v₁ t₂ t₃ ρ tc)) D.∼⟨ (⟦⟧∼⟦⟧ t₁ _ DC.>>=-cong λ v₁ → ⟦if⟧∼⟦if⟧ v₁ t₂ t₃ _) ⟩∼ (I.⟦ t₁ ⟧ ρ >>= λ v₁ → I.⟦if⟧ v₁ t₂ t₃ ρ) D.∎ ∙∼∙ : ∀ {i} f₁ {f₂} (v₁ {v₂} : Value) → D.[ i ] delay-crash ([ f₁ , f₂ ] v₁ ∙ v₂) ∼ v₁ I.∙ v₂ ∙∼∙ f₁ {f₂} (lam t₁ ρ) {v₂} = later λ { .force → delay-crash (⟦ t₁ ⟧ (v₂ ∷ ρ) true >>= tell f₂ ∘ return) D.∼⟨ delay-crash->>= (⟦ t₁ ⟧ _ _) ⟩ delay-crash (⟦ t₁ ⟧ (v₂ ∷ ρ) true) >>= delay-crash ∘ tell f₂ ∘ return D.∼⟨ ((delay-crash (⟦ t₁ ⟧ _ _) D.∎) DC.>>=-cong λ _ → D.reflexive _) ⟩ delay-crash (⟦ t₁ ⟧ (v₂ ∷ ρ) true) >>= return D.∼⟨ DC.right-identity _ ⟩ delay-crash (⟦ t₁ ⟧ (v₂ ∷ ρ) true) D.∼⟨ ⟦⟧∼⟦⟧ t₁ _ ⟩∼ I.⟦ t₁ ⟧ (v₂ ∷ ρ) D.∎ } ∙∼∙ _ (con _) = D.reflexive _ ⟦if⟧∼⟦if⟧ : ∀ {i n} v₁ (t₂ t₃ : Tm n) {ρ} tc → D.[ i ] delay-crash (⟦if⟧ v₁ t₂ t₃ ρ tc) ∼ I.⟦if⟧ v₁ t₂ t₃ ρ ⟦if⟧∼⟦if⟧ (lam _ _) _ _ _ = D.reflexive _ ⟦if⟧∼⟦if⟧ (con true) t₂ t₃ _ = ⟦⟧∼⟦⟧ t₂ _ ⟦if⟧∼⟦if⟧ (con false) t₂ t₃ _ = ⟦⟧∼⟦⟧ t₃ _ ------------------------------------------------------------------------ -- A lemma -- The function numbers preserves strong bisimilarity. numbers-cong : ∀ {i A} {x y : Delay-crash-trace (ℕ → ℕ) A ∞} {n} → DCT.[ i ] x ∼ y → C.[ i ] numbers x n ∼ numbers y n numbers-cong = scanl-cong ∘ trace-cong ------------------------------------------------------------------------ -- An example: An analysis of the semantics of Ω -- The semantics of Ω is the non-terminating computation never. Ω-loops : ∀ {i} → D.[ i ] delay-crash (⟦ Ω ⟧ [] false) ∼ never Ω-loops = delay-crash (⟦ Ω ⟧ [] false) D.∼⟨ ⟦⟧∼⟦⟧ Ω false ⟩ I.⟦ Ω ⟧ [] D.∼⟨ I.Ω-loops ⟩ never D.∎ -- A colist used in an analysis of the stack space usage of Ω. Ω-sizes : ∀ {i} → ℕ → Colist ℕ i Ω-sizes n = n ∷′ 1 + n ∷′ 2 + n ∷ λ { .force → Ω-sizes (1 + n) } private -- An abbreviation. cong₃ : ∀ {i x y z} {xs ys : Colist′ ℕ ∞} → C.[ i ] force xs ∼′ force ys → C.[ i ] x ∷′ y ∷′ z ∷ xs ∼ x ∷′ y ∷′ z ∷ ys cong₃ p = E.refl ∷ λ { .force → E.refl ∷ λ { .force → E.refl ∷ p }} -- The colist Ω-sizes n has the same upper bounds as nats-from n. Ω-sizes≂nats-from : ∀ {i} n → [ i ] Ω-sizes n ≂ nats-from n Ω-sizes≂nats-from n = Ω-sizes n ∼⟨ (cong₃ λ { .force → C.reflexive-∼ _ }) ⟩≂ n ∷′ 1 + n ∷′ 2 + n ∷′ Ω-sizes (suc n) ≂⟨ cons′-≂ (_⇔_.from ≂′⇔≂″ λ { .force → consˡ-≂ (inj₁ (here ≤-refl)) ( consˡ-≂ (inj₁ (there (here ≤-refl))) ( Ω-sizes≂nats-from (suc n))) }) ⟩∼ n ∷′ nats-from (suc n) C.∼⟨ C.symmetric-∼ ∷∼∷′ ⟩ nats-from n C.∎ -- The least upper bound of Ω-sizes 0 is infinity. lub-Ω-sizes-0-infinity : LUB (Ω-sizes 0) infinity lub-Ω-sizes-0-infinity = $⟨ lub-nats-infinity ⟩ LUB nats infinity ↝⟨ LUB-∼ nats∼nats-from-0 (Conat.reflexive-∼ _) ⟩ LUB (nats-from 0) infinity ↝⟨ LUB-≂ (symmetric-≂ (Ω-sizes≂nats-from 0)) ⟩□ LUB (Ω-sizes 0) infinity □ -- When Ω is interpreted (starting with an empty stack) the stack -- sizes that are encountered match the sizes in the colist Ω-sizes 0. stack-sizes-Ω∼Ω-sizes-0 : ∀ {i} → C.[ i ] stack-sizes Ω ∼ Ω-sizes 0 stack-sizes-Ω∼Ω-sizes-0 = stack-sizes Ω C.∼⟨⟩ numbers (⟦ Ω ⟧ [] false) 0 C.∼⟨ (E.refl ∷ λ { .force → E.refl ∷ λ { .force → E.refl ∷ λ { .force → C.reflexive-∼ _ }}}) ⟩ 0 ∷′ 1 ∷′ 2 ∷′ numbers (⟦ ω-body ⟧ (lam ω-body [] ∷ []) true >>= tell pred ∘ return) 1 C.∼⟨ (cong₃ λ { .force → lemma 1 }) ⟩ 0 ∷′ 1 ∷′ 2 ∷′ Ω-sizes 1 C.∼⟨ (cong₃ λ { .force → C.reflexive-∼ _ }) ⟩ Ω-sizes 0 C.∎ where lemma : ∀ {i} n {k : Value → Delay-crash-trace (ℕ → ℕ) Value ∞} → C.[ i ] numbers (⟦ ω-body ⟧ (lam ω-body [] ∷ []) true >>= k) n ∼ Ω-sizes n lemma n {k} = numbers (⟦ ω-body ⟧ (lam ω-body [] ∷ []) true >>= k) n C.∼⟨⟩ numbers (tell suc (tell suc ([ pred , pred ] lam ω-body [] ∙ lam ω-body []) >>= k)) n C.∼⟨ (E.refl ∷ λ { .force → E.refl ∷ λ { .force → E.refl ∷ λ { .force → C.reflexive-∼ _ }}}) ⟩ n ∷′ 1 + n ∷′ 2 + n ∷′ numbers (⟦ ω-body ⟧ (lam ω-body [] ∷ []) true >>= tell pred ∘ return >>= k) (1 + n) C.∼⟨ (cong₃ λ { .force → C.symmetric-∼ $ numbers-cong $ DCT.associativity (⟦ ω-body ⟧ (lam _ _ ∷ []) true) _ _ }) ⟩ n ∷′ 1 + n ∷′ 2 + n ∷′ numbers (⟦ ω-body ⟧ (lam ω-body [] ∷ []) true >>= λ v → tell pred (return v) >>= k) (1 + n) C.∼⟨ (cong₃ λ { .force → lemma (1 + n) }) ⟩ n ∷′ 1 + n ∷′ 2 + n ∷′ Ω-sizes (1 + n) C.∼⟨ (cong₃ λ { .force → C.reflexive-∼ _ }) ⟩ Ω-sizes n C.∎ -- The computation Ω requires unbounded space. Ω-requires-unbounded-space : LUB (stack-sizes Ω) infinity Ω-requires-unbounded-space = LUB-∼ (C.symmetric-∼ stack-sizes-Ω∼Ω-sizes-0) (Conat.reflexive-∼ _) lub-Ω-sizes-0-infinity
{ "alphanum_fraction": 0.4553125851, "avg_line_length": 38.9434628975, "ext": "agda", "hexsha": "af6b0dc218cbec9d15d5a3fc6a2832dacdf6dbc0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "dec8cd2d2851340840de25acb0feb78f7b5ffe96", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/definitional-interpreters", "max_forks_repo_path": "src/Lambda/Interpreter/Stack-sizes.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "dec8cd2d2851340840de25acb0feb78f7b5ffe96", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/definitional-interpreters", "max_issues_repo_path": "src/Lambda/Interpreter/Stack-sizes.agda", "max_line_length": 145, "max_stars_count": null, "max_stars_repo_head_hexsha": "dec8cd2d2851340840de25acb0feb78f7b5ffe96", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/definitional-interpreters", "max_stars_repo_path": "src/Lambda/Interpreter/Stack-sizes.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4284, "size": 11021 }
------------------------------------------------------------------------------ -- The FOTC natural numbers type ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- N.B. This module is re-exported by FOTC.Data.Nat. module FOTC.Data.Nat.Type where open import FOTC.Base ------------------------------------------------------------------------------ -- The FOTC natural numbers type (inductive predicate for the total -- natural numbers). data N : D → Set where nzero : N zero nsucc : ∀ {n} → N n → N (succ₁ n) {-# ATP axioms nzero nsucc #-} -- Induction principle. N-ind : (A : D → Set) → A zero → (∀ {n} → A n → A (succ₁ n)) → ∀ {n} → N n → A n N-ind A A0 h nzero = A0 N-ind A A0 h (nsucc Nn) = h (N-ind A A0 h Nn)
{ "alphanum_fraction": 0.4188481675, "avg_line_length": 30.8064516129, "ext": "agda", "hexsha": "9c8575c597263f92baab50cf0ab40596026af6aa", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Data/Nat/Type.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Data/Nat/Type.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Data/Nat/Type.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": 233, "size": 955 }
{-# OPTIONS --type-in-type #-} -- yes, there will be some cheating in this lecture module Lec3Start where open import Lec1Done open import Lec2Done postulate extensionality : {S : Set}{T : S -> Set} (f g : (x : S) -> T x) -> ((x : S) -> f x == g x) -> f == g record Category : Set where field -- two types of thing Obj : Set -- "objects" _~>_ : Obj -> Obj -> Set -- "arrows" or "morphisms" -- or "homomorphisms" -- two operations id~> : {T : Obj} -> T ~> T _>~>_ : {R S T : Obj} -> R ~> S -> S ~> T -> R ~> T -- three laws law-id~>>~> : {S T : Obj} (f : S ~> T) -> (id~> >~> f) == f law->~>id~> : {S T : Obj} (f : S ~> T) -> (f >~> id~>) == f law->~>>~> : {Q R S T : Obj} (f : Q ~> R)(g : R ~> S)(h : S ~> T) -> ((f >~> g) >~> h) == (f >~> (g >~> h)) -- Sets and functions are the classic example of a category. {-+} SET : Category SET = {!!} {+-} -- A PREORDER is a category where there is at most one arrow between -- any two objects. (So arrows are unique.) {-+} NAT->= : Category NAT->= = {!!} where unique : (m n : Nat)(p q : m >= n) -> p == q unique m n p q = {!!} {+-} -- A MONOID is a category with Obj = One. -- The values in the monoid are the *arrows*. {-+} ONE-Nat : Category ONE-Nat = {!!} {+-} {-+} eqUnique : {X : Set}{x y : X}(p q : x == y) -> p == q eqUnique p q = {!!} -- A DISCRETE category is one where the only arrows are the identities. DISCRETE : (X : Set) -> Category DISCRETE X = {!!} {+-} module FUNCTOR where open Category record _=>_ (C D : Category) : Set where -- "Functor from C to D" field -- two actions F-Obj : Obj C -> Obj D F-map : {S T : Obj C} -> _~>_ C S T -> _~>_ D (F-Obj S) (F-Obj T) -- two laws F-map-id~> : {T : Obj C} -> F-map (id~> C {T}) == id~> D {F-Obj T} F-map->~> : {R S T : Obj C}(f : _~>_ C R S)(g : _~>_ C S T) -> F-map (_>~>_ C f g) == _>~>_ D (F-map f) (F-map g) open FUNCTOR {-+} VEC : Nat -> SET => SET VEC n = {!!} {+-} {-+} VTAKE : Set -> NAT->= => SET VTAKE X = {!!} {+-} {-+} ADD : Nat -> NAT->= => NAT->= ADD d = {!!} {+-} {-+} CATEGORY : Category CATEGORY = {!!} {+-}
{ "alphanum_fraction": 0.4338912134, "avg_line_length": 23.431372549, "ext": "agda", "hexsha": "07a8247a654bd67e776ca366e83f206d9784a17d", "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/course/2017-conor_mcbride_cs410/CS410-17-master/nowyoutry/Lec3Start.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/course/2017-conor_mcbride_cs410/CS410-17-master/nowyoutry/Lec3Start.agda", "max_line_length": 83, "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/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec3Start.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": 840, "size": 2390 }
module Stack where open import Data.Bool using (Bool; true; false) open import Data.Nat using (ℕ; zero; suc) import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; cong) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎; step-≡) module V1 where {- This first version introduces the Stack abstract data type. -} data Stack (A : Set) : Set where ∅ : Stack A _>>_ : A → Stack A → Stack A infixr 50 _>>_ push : ∀ {A} → A → Stack A → Stack A push a s = a >> s peek : ∀ {A} → (S : Stack A) → A -- May be absurd can be used here but how? peek (a >> _) = a pop : ∀ {A} → (S : Stack A) → Stack A -- May be absurd can be used here but how? pop (a >> s) = s module Example where _ : Stack Bool _ = true >> false >> ∅ module Laws where law1 : ∀ {A} (a : A) (s : Stack A) -> peek (push a s) ≡ a law1 a s = begin peek (push a s) ≡⟨⟩ peek (a >> s) ≡⟨⟩ a ∎ law2 : ∀ {A} {a : A} {s : Stack A} → pop (push a s) ≡ s law2 = refl module V2 where {- This second version introduces the expression as constraint in the type definition. This prevents incomplete pattern matching for peek and pop. For this purpose we first design empty? predicate and then we use it in the type definition of peek and pop. -} data Stack (A : Set) : Set where ∅ : Stack A _>>_ : A → Stack A → Stack A infixr 50 _>>_ empty? : ∀ {A} → Stack A → Bool empty? ∅ = true empty? _ = false push : ∀ {A} → A → Stack A → Stack A push a s = a >> s peek : ∀ {A} → (S : Stack A) -> {empty? S ≡ false} → A peek (a >> _) = a pop : ∀ {A} → (S : Stack A) -> {empty? S ≡ false} → Stack A pop (a >> s) = s module Example where _ : Stack Bool _ = pop (push true ∅) {refl} module Laws where law1 : ∀ {A} {a : A} {s : Stack A} → peek (push a s) {refl} ≡ a law1 = refl law2 : ∀ {A} {a : A} {s : Stack A} → pop (push a s) {refl} ≡ s law2 = refl module V3 where {- In this third version we use a GADT for the Stack data representation. A Kind then is design on purpose and a phantom type is used for the association between the stack and the kind. -} data Kind : Set where Empty : Kind NotEmpty : Kind data Stack (A : Set) : Kind → Set where ∅ : Stack A Empty _>>_ : ∀ {B} → A → Stack A B → Stack A NotEmpty infixr 50 _>>_ push : ∀ {A B} → A → Stack A B → Stack A NotEmpty push a s = a >> s peek : ∀ {A} → Stack A NotEmpty → A peek (a >> _) = a {- B is in the ouput only! => No constraint with the input. Writing such pop function is impossible as is. pop : ∀ {A B} → Stack A NotEmpty → Stack A B pop (_ >> s) = s -} module Example where _ : Stack Bool NotEmpty _ = push true ∅ module Laws where law1 : ∀ {A B} {a : A} {s : Stack A B} → peek (push a s) ≡ a law1 = refl -- law2 cannot be expressed ... module V4 where {- In this fourth version we slightly review the NotEmpty construction. This opens the opportunity to express the pop function since a dependency can by modeled in the corresponding type definition. -} data Kind : Set where Empty : Kind NotEmpty : Kind → Kind data Stack (A : Set) : Kind → Set where ∅ : Stack A Empty _>>_ : ∀ {B} → A → Stack A B → Stack A (NotEmpty B) infixr 50 _>>_ push : ∀ {A B} → A → Stack A B → Stack A (NotEmpty B) push a s = a >> s peek : ∀ {A B} → Stack A (NotEmpty B) → A peek (a >> _) = a pop : ∀ {A B} → Stack A (NotEmpty B) → Stack A B pop (_ >> s) = s module Example where _ : Stack Bool (NotEmpty Empty) _ = push true ∅ module Laws where law1 : ∀ {A B} {a : A} {s : Stack A B} → peek (push a s) ≡ a law1 = refl law2 : ∀ {A B} {a : A} {s : Stack A B} → pop (push a s) ≡ s law2 = refl module V5 where {- In this last version we show that previous Kind definiton is isomorphic with the Natural. -} data Stack (A : Set) : ℕ → Set where ∅ : Stack A 0 _>>_ : ∀ {B} → A → Stack A B → Stack A (suc B) infixr 50 _>>_ push : ∀ {A B} → A → Stack A B → Stack A (suc B) push a s = a >> s peek : ∀ {A B} → Stack A (suc B) → A peek (a >> _) = a pop : ∀ {A B} → Stack A (suc B) → Stack A B pop (_ >> s) = s module Example where _ : Stack Bool 1 _ = push true ∅ module Laws where law1 : ∀ {A B} {a : A} {s : Stack A B} → peek (push a s) ≡ a law1 = refl law2 : ∀ {A B} {a : A} {s : Stack A B} → pop (push a s) ≡ s law2 = refl
{ "alphanum_fraction": 0.5102988691, "avg_line_length": 25.1370558376, "ext": "agda", "hexsha": "500c028baa3002d38b1cd69b3b8c22e8010a6675", "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": "a81447af3ab2ba898bb7d57be71369abbba12d81", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "d-plaindoux/colca", "max_forks_repo_path": "src/exercices/stack.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a81447af3ab2ba898bb7d57be71369abbba12d81", "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": "d-plaindoux/colca", "max_issues_repo_path": "src/exercices/stack.agda", "max_line_length": 95, "max_stars_count": 2, "max_stars_repo_head_hexsha": "a81447af3ab2ba898bb7d57be71369abbba12d81", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "d-plaindoux/colca", "max_stars_repo_path": "src/exercices/stack.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-04T09:35:36.000Z", "max_stars_repo_stars_event_min_datetime": "2021-03-12T18:31:14.000Z", "num_tokens": 1618, "size": 4952 }
{-# OPTIONS --cubical --no-import-sorts --guardedness --safe #-} module Cubical.Codata.M.AsLimit.M.Properties where open import Cubical.Data.Unit open import Cubical.Data.Prod open import Cubical.Data.Nat as ℕ using (ℕ ; suc ; _+_ ) open import Cubical.Data.Sum open import Cubical.Data.Sigma open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv using (_≃_) open import Cubical.Foundations.Function using (_∘_) open import Cubical.Foundations.Transport open import Cubical.Foundations.Univalence open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Functions.Embedding open import Cubical.Codata.M.AsLimit.helper open import Cubical.Codata.M.AsLimit.M.Base open import Cubical.Codata.M.AsLimit.Container -- in-fun and out-fun are inverse open Iso in-inverse-out : ∀ {ℓ} {S : Container ℓ} → (in-fun {S = S} ∘ out-fun {S = S}) ≡ idfun (M S) in-inverse-out {S = S} = subst (λ inv → in-fun {S = S} ∘ inv ≡ idfun (M S)) idpath def where -- substituting refl makes type-checking work a lot faster, but introduces a transport -- TODO (2020-05-23): revisit this at some point to see if it's still needed in future versions of agda def : (in-fun {S = S} ∘ inv (shift-iso S)) ≡ idfun (M S) def = funExt (rightInv (shift-iso S)) idpath : inv (shift-iso S) ≡ out-fun {S = S} idpath = refl out-inverse-in : ∀ {ℓ} {S : Container ℓ} → (out-fun {S = S} ∘ in-fun {S = S}) ≡ idfun (P₀ S (M S)) out-inverse-in {S = S} = subst (λ fun → out-fun {S = S} ∘ fun ≡ idfun (P₀ S (M S))) idpath def where def : (out-fun {S = S} ∘ fun (shift-iso S)) ≡ idfun (P₀ S (M S)) def = funExt (leftInv (shift-iso S)) idpath : fun (shift-iso S) ≡ in-fun {S = S} idpath = refl in-out-id : ∀ {ℓ} {S : Container ℓ} -> ∀ {x y : M S} → (in-fun (out-fun x) ≡ in-fun (out-fun y)) ≡ (x ≡ y) in-out-id {x = x} {y} i = (in-inverse-out i x) ≡ (in-inverse-out i y) -- constructor properties in-inj : ∀ {ℓ} {S : Container ℓ} {Z : Type ℓ} → ∀ {f g : Z → P₀ S (M S)} → (in-fun ∘ f ≡ in-fun ∘ g) ≡ (f ≡ g) in-inj {ℓ} {S = S} {Z = Z} {f = f} {g = g} = iso→fun-Injection-Path {ℓ = ℓ} {A = P₀ S (M S)} {B = M S} {C = Z} (shift-iso S) {f = f} {g = g} out-inj : ∀ {ℓ} {S : Container ℓ} {Z : Type ℓ} → ∀ {f g : Z → M S} → (out-fun ∘ f ≡ out-fun ∘ g) ≡ (f ≡ g) out-inj {ℓ} {S = S} {Z = Z} {f = f} {g = g} = iso→inv-Injection-Path {ℓ = ℓ} {A = P₀ S (M S)} {B = M S} {C = Z} (shift-iso S) {f = f} {g = g} in-inj-x : ∀ {ℓ} {S : Container ℓ} → ∀ {x y : P₀ S (M S)} → (in-fun x ≡ in-fun y) ≡ (x ≡ y) in-inj-x {ℓ} {S = S} {x = x} {y} = iso→fun-Injection-Path-x (shift-iso S) {x} {y} out-inj-x : ∀ {ℓ} {S : Container ℓ} → ∀ {x y : M S} → (out-fun x ≡ out-fun y) ≡ (x ≡ y) out-inj-x {ℓ} {S = S} {x = x} {y} = iso→inv-Injection-Path-x (shift-iso S) {x} {y}
{ "alphanum_fraction": 0.6078984485, "avg_line_length": 45.7419354839, "ext": "agda", "hexsha": "1cc3ce4f061a7fd8f8a810e2926b49111a7037a2", "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/Codata/M/AsLimit/M/Properties.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/Codata/M/AsLimit/M/Properties.agda", "max_line_length": 141, "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/Codata/M/AsLimit/M/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1136, "size": 2836 }
{-# OPTIONS --safe #-} module Cubical.Algebra.Ring.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.Transport open import Cubical.Foundations.SIP open import Cubical.Data.Sigma open import Cubical.Structures.Axioms open import Cubical.Structures.Auto open import Cubical.Structures.Macro open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open import Cubical.Algebra.AbGroup open import Cubical.Algebra.Ring.Base private variable ℓ : Level {- some basic calculations (used for example in QuotientRing.agda), that should become obsolete or subject to change once we have a ring solver (see https://github.com/agda/cubical/issues/297) -} module RingTheory (R' : Ring ℓ) where open RingStr (snd R') private R = ⟨ R' ⟩ implicitInverse : (x y : R) → x + y ≡ 0r → y ≡ - x implicitInverse x y p = y ≡⟨ sym (+Lid y) ⟩ 0r + y ≡⟨ cong (λ u → u + y) (sym (+Linv x)) ⟩ (- x + x) + y ≡⟨ sym (+Assoc _ _ _) ⟩ (- x) + (x + y) ≡⟨ cong (λ u → (- x) + u) p ⟩ (- x) + 0r ≡⟨ +Rid _ ⟩ - x ∎ equalByDifference : (x y : R) → x - y ≡ 0r → x ≡ y equalByDifference x y p = x ≡⟨ sym (+Rid _) ⟩ x + 0r ≡⟨ cong (λ u → x + u) (sym (+Linv y)) ⟩ x + ((- y) + y) ≡⟨ +Assoc _ _ _ ⟩ (x - y) + y ≡⟨ cong (λ u → u + y) p ⟩ 0r + y ≡⟨ +Lid _ ⟩ y ∎ 0Selfinverse : - 0r ≡ 0r 0Selfinverse = sym (implicitInverse _ _ (+Rid 0r)) 0Idempotent : 0r + 0r ≡ 0r 0Idempotent = +Lid 0r +Idempotency→0 : (x : R) → x ≡ x + x → x ≡ 0r +Idempotency→0 x p = x ≡⟨ sym (+Rid x) ⟩ x + 0r ≡⟨ cong (λ u → x + u) (sym (+Rinv _)) ⟩ x + (x + (- x)) ≡⟨ +Assoc _ _ _ ⟩ (x + x) + (- x) ≡⟨ cong (λ u → u + (- x)) (sym p) ⟩ x + (- x) ≡⟨ +Rinv _ ⟩ 0r ∎ -Idempotent : (x : R) → -(- x) ≡ x -Idempotent x = - (- x) ≡⟨ sym (implicitInverse (- x) x (+Linv _)) ⟩ x ∎ 0RightAnnihilates : (x : R) → x · 0r ≡ 0r 0RightAnnihilates x = let x·0-is-idempotent : x · 0r ≡ x · 0r + x · 0r x·0-is-idempotent = x · 0r ≡⟨ cong (λ u → x · u) (sym 0Idempotent) ⟩ x · (0r + 0r) ≡⟨ ·Rdist+ _ _ _ ⟩ (x · 0r) + (x · 0r) ∎ in (+Idempotency→0 _ x·0-is-idempotent) 0LeftAnnihilates : (x : R) → 0r · x ≡ 0r 0LeftAnnihilates x = let 0·x-is-idempotent : 0r · x ≡ 0r · x + 0r · x 0·x-is-idempotent = 0r · x ≡⟨ cong (λ u → u · x) (sym 0Idempotent) ⟩ (0r + 0r) · x ≡⟨ ·Ldist+ _ _ _ ⟩ (0r · x) + (0r · x) ∎ in +Idempotency→0 _ 0·x-is-idempotent -DistR· : (x y : R) → x · (- y) ≡ - (x · y) -DistR· x y = implicitInverse (x · y) (x · (- y)) (x · y + x · (- y) ≡⟨ sym (·Rdist+ _ _ _) ⟩ x · (y + (- y)) ≡⟨ cong (λ u → x · u) (+Rinv y) ⟩ x · 0r ≡⟨ 0RightAnnihilates x ⟩ 0r ∎) -DistL· : (x y : R) → (- x) · y ≡ - (x · y) -DistL· x y = implicitInverse (x · y) ((- x) · y) (x · y + (- x) · y ≡⟨ sym (·Ldist+ _ _ _) ⟩ (x - x) · y ≡⟨ cong (λ u → u · y) (+Rinv x) ⟩ 0r · y ≡⟨ 0LeftAnnihilates y ⟩ 0r ∎) -Swap· : (x y : R) → (- x) · y ≡ x · (- y) -Swap· _ _ = -DistL· _ _ ∙ sym (-DistR· _ _) -IsMult-1 : (x : R) → - x ≡ (- 1r) · x -IsMult-1 _ = sym (·Lid _) ∙ sym (-Swap· _ _) -Dist : (x y : R) → (- x) + (- y) ≡ - (x + y) -Dist x y = implicitInverse _ _ ((x + y) + ((- x) + (- y)) ≡⟨ sym (+Assoc _ _ _) ⟩ x + (y + ((- x) + (- y))) ≡⟨ cong (λ u → x + (y + u)) (+Comm _ _) ⟩ x + (y + ((- y) + (- x))) ≡⟨ cong (λ u → x + u) (+Assoc _ _ _) ⟩ x + ((y + (- y)) + (- x)) ≡⟨ cong (λ u → x + (u + (- x))) (+Rinv _) ⟩ x + (0r + (- x)) ≡⟨ cong (λ u → x + u) (+Lid _) ⟩ x + (- x) ≡⟨ +Rinv _ ⟩ 0r ∎) translatedDifference : (x a b : R) → a - b ≡ (x + a) - (x + b) translatedDifference x a b = a - b ≡⟨ cong (λ u → a + u) (sym (+Lid _)) ⟩ (a + (0r + (- b))) ≡⟨ cong (λ u → a + (u + (- b))) (sym (+Rinv _)) ⟩ (a + ((x + (- x)) + (- b))) ≡⟨ cong (λ u → a + u) (sym (+Assoc _ _ _)) ⟩ (a + (x + ((- x) + (- b)))) ≡⟨ (+Assoc _ _ _) ⟩ ((a + x) + ((- x) + (- b))) ≡⟨ cong (λ u → u + ((- x) + (- b))) (+Comm _ _) ⟩ ((x + a) + ((- x) + (- b))) ≡⟨ cong (λ u → (x + a) + u) (-Dist _ _) ⟩ ((x + a) - (x + b)) ∎ +Assoc-comm1 : (x y z : R) → x + (y + z) ≡ y + (x + z) +Assoc-comm1 x y z = +Assoc x y z ∙∙ cong (λ x → x + z) (+Comm x y) ∙∙ sym (+Assoc y x z) +Assoc-comm2 : (x y z : R) → x + (y + z) ≡ z + (y + x) +Assoc-comm2 x y z = +Assoc-comm1 x y z ∙∙ cong (λ x → y + x) (+Comm x z) ∙∙ +Assoc-comm1 y z x +ShufflePairs : (a b c d : R) → (a + b) + (c + d) ≡ (a + c) + (b + d) +ShufflePairs a b c d = (a + b) + (c + d) ≡⟨ +Assoc _ _ _ ⟩ ((a + b) + c) + d ≡⟨ cong (λ u → u + d) (sym (+Assoc _ _ _)) ⟩ (a + (b + c)) + d ≡⟨ cong (λ u → (a + u) + d) (+Comm _ _) ⟩ (a + (c + b)) + d ≡⟨ cong (λ u → u + d) (+Assoc _ _ _) ⟩ ((a + c) + b) + d ≡⟨ sym (+Assoc _ _ _) ⟩ (a + c) + (b + d) ∎ ·-assoc2 : (x y z w : R) → (x · y) · (z · w) ≡ x · (y · z) · w ·-assoc2 x y z w = ·Assoc (x · y) z w ∙ cong (_· w) (sym (·Assoc x y z)) module RingHoms where open IsRingHom idRingHom : (R : Ring ℓ) → RingHom R R fst (idRingHom R) = idfun (fst R) snd (idRingHom R) = makeIsRingHom refl (λ _ _ → refl) (λ _ _ → refl) compRingHom : {R S T : Ring ℓ} → RingHom R S → RingHom S T → RingHom R T fst (compRingHom f g) x = g .fst (f .fst x) snd (compRingHom f g) = makeIsRingHom (cong (g .fst) (pres1 (snd f)) ∙ pres1 (snd g)) (λ x y → cong (g .fst) (pres+ (snd f) _ _) ∙ pres+ (snd g) _ _) (λ x y → cong (g .fst) (pres· (snd f) _ _) ∙ pres· (snd g) _ _) compIdRingHom : {R S : Ring ℓ} (φ : RingHom R S) → compRingHom (idRingHom R) φ ≡ φ compIdRingHom φ = RingHom≡ refl idCompRingHom : {R S : Ring ℓ} (φ : RingHom R S) → compRingHom φ (idRingHom S) ≡ φ idCompRingHom φ = RingHom≡ refl compAssocRingHom : {R S T U : Ring ℓ} (φ : RingHom R S) (ψ : RingHom S T) (χ : RingHom T U) → compRingHom (compRingHom φ ψ) χ ≡ compRingHom φ (compRingHom ψ χ) compAssocRingHom _ _ _ = RingHom≡ refl module RingHomTheory {R S : Ring ℓ} (φ : RingHom R S) where open RingTheory ⦃...⦄ open RingStr ⦃...⦄ open IsRingHom (φ .snd) private instance _ = R _ = S _ = snd R _ = snd S f = fst φ ker≡0→inj : ({x : ⟨ R ⟩} → f x ≡ 0r → x ≡ 0r) → ({x y : ⟨ R ⟩} → f x ≡ f y → x ≡ y) ker≡0→inj ker≡0 {x} {y} p = equalByDifference _ _ (ker≡0 path) where path : f (x - y) ≡ 0r path = f (x - y) ≡⟨ pres+ _ _ ⟩ f x + f (- y) ≡⟨ cong (f x +_) (pres- _) ⟩ f x - f y ≡⟨ cong (_- f y) p ⟩ f y - f y ≡⟨ +Rinv _ ⟩ 0r ∎
{ "alphanum_fraction": 0.4057247259, "avg_line_length": 38.544600939, "ext": "agda", "hexsha": "5fffe6744ad97a548f2ef4a00b16ec19afb9367c", "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": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lpw25/cubical", "max_forks_repo_path": "Cubical/Algebra/Ring/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "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": "lpw25/cubical", "max_issues_repo_path": "Cubical/Algebra/Ring/Properties.agda", "max_line_length": 103, "max_stars_count": null, "max_stars_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lpw25/cubical", "max_stars_repo_path": "Cubical/Algebra/Ring/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3219, "size": 8210 }
module Issue3295.Incomplete2 where open import Agda.Builtin.Nat {-# NON_COVERING #-} g : Nat → Nat g zero = zero
{ "alphanum_fraction": 0.7217391304, "avg_line_length": 14.375, "ext": "agda", "hexsha": "ff27c1ce3a61ef845d7e6dce9a64c180bfcfaaf0", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/Issue3295/Incomplete2.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/Issue3295/Incomplete2.agda", "max_line_length": 34, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue3295/Incomplete2.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": 35, "size": 115 }
-- WARNING: This file was generated automatically by Vehicle -- and should not be modified manually! -- Metadata -- - Agda version: 2.6.2 -- - AISEC version: 0.1.0.1 -- - Time generated: ??? {-# OPTIONS --allow-exec #-} open import Vehicle open import Vehicle.Data.Tensor open import Data.Product open import Data.Sum open import Data.Integer as ℤ using (ℤ) open import Data.Rational as ℝ using () renaming (ℚ to ℝ) open import Data.Fin as Fin using (#_) open import Data.List module property6-output where private VEHICLE_PROJECT_FILE = "TODO_projectFile" pi : ℝ pi = ℤ.+ 392699 ℝ./ 125000 InputVector : Set InputVector = Tensor ℝ (5 ∷ []) OutputVector : Set OutputVector = Tensor ℝ (5 ∷ []) acasXu : InputVector → OutputVector acasXu = evaluate record { projectFile = VEHICLE_PROJECT_FILE ; networkUUID = "TODO_networkUUID" } distanceToIntruder : InputVector → ℝ distanceToIntruder x = x (# 0) angleToIntruder : InputVector → ℝ angleToIntruder x = x (# 1) intruderHeading : InputVector → ℝ intruderHeading x = x (# 2) speed : InputVector → ℝ speed x = x (# 3) intruderSpeed : InputVector → ℝ intruderSpeed x = x (# 4) clearOfConflictScore : InputVector → ℝ clearOfConflictScore x = acasXu x (# 0) IntruderFarAway : InputVector → Set IntruderFarAway x = (ℝ.- pi ℝ.≤ angleToIntruder x × angleToIntruder x ℝ.≤ ℝ.- (ℤ.+ 7 ℝ./ 10) ⊎ ℤ.+ 7 ℝ./ 10 ℝ.≤ angleToIntruder x × angleToIntruder x ℝ.≤ pi) × ((ℤ.+ 12000 ℝ./ 1 ℝ.≤ distanceToIntruder x × distanceToIntruder x ℝ.≤ ℤ.+ 62000 ℝ./ 1) × ((ℝ.- pi ℝ.≤ intruderHeading x × intruderHeading x ℝ.≤ ℝ.- pi ℝ.+ ℤ.+ 1 ℝ./ 200) × ((ℤ.+ 100 ℝ./ 1 ℝ.≤ speed x × speed x ℝ.≤ ℤ.+ 1200 ℝ./ 1) × (ℤ.+ 0 ℝ./ 1 ℝ.≤ intruderSpeed x × intruderSpeed x ℝ.≤ ℤ.+ 1200 ℝ./ 1)))) AdvisesClearOfConflict : InputVector → Set AdvisesClearOfConflict x = let y = acasXu x in y (# 0) ℝ.> y (# 1) × (y (# 0) ℝ.> y (# 2) × (y (# 0) ℝ.> y (# 3) × y (# 0) ℝ.> y (# 4))) abstract property6 : ∀ (x : Tensor ℝ (5 ∷ [])) → IntruderFarAway x → AdvisesClearOfConflict x property6 = checkProperty record { projectFile = VEHICLE_PROJECT_FILE ; propertyUUID = "TODO_propertyUUID" }
{ "alphanum_fraction": 0.6682330827, "avg_line_length": 31.2941176471, "ext": "agda", "hexsha": "630e97d1d75729c5a8b30b4697dc9240f16c14c2", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2021-11-16T14:30:47.000Z", "max_forks_repo_forks_event_min_datetime": "2021-03-15T15:22:31.000Z", "max_forks_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "wenkokke/vehicle", "max_forks_repo_path": "examples/network/acasXu/property6/property6-output.agda", "max_issues_count": 53, "max_issues_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674", "max_issues_repo_issues_event_max_datetime": "2021-12-15T22:42:01.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-16T07:26:42.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "wenkokke/vehicle", "max_issues_repo_path": "examples/network/acasXu/property6/property6-output.agda", "max_line_length": 465, "max_stars_count": 11, "max_stars_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "wenkokke/vehicle", "max_stars_repo_path": "examples/network/acasXu/property6/property6-output.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T01:35:39.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-24T05:55:15.000Z", "num_tokens": 756, "size": 2128 }
module JamesChapman where infixr 50 _⟶_ data Ty : Set where ι : Ty _⟶_ : Ty -> Ty -> Ty data Tm : Ty -> Set where _$_ : {σ τ : Ty} -> Tm (σ ⟶ τ) -> Tm σ -> Tm τ data Nf : Ty -> Set where data _↓_ : {σ : Ty} -> Tm σ -> Nf σ -> Set where r$ : {σ τ : Ty} -> {t : Tm (σ ⟶ τ)} -> {f : Nf (σ ⟶ τ)} -> t ↓ f -> {u : Tm σ} -> {a : Nf σ} -> u ↓ a -> {v : Nf τ} -> t $ u ↓ v nf* : {σ : Ty} -> (t : Tm σ) -> {n : Nf σ} -> t ↓ n -> Set nf* .{τ} (_$_ {σ} {τ} t u) {v} (r$ {f = f} p q) with nf* {σ ⟶ τ} t {f} p nf* (t $ u) (r$ p q) | _ = Ty
{ "alphanum_fraction": 0.3888888889, "avg_line_length": 25.3636363636, "ext": "agda", "hexsha": "663d2e08e28bd651fc58c2ad1df223be6a5ed54a", "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/Termination/simplified-comb.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/Termination/simplified-comb.agda", "max_line_length": 72, "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/Termination/simplified-comb.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": 280, "size": 558 }
{-# OPTIONS --without-K #-} module sets.vec where open import sets.vec.core public open import sets.vec.properties public open import sets.vec.dependent public
{ "alphanum_fraction": 0.7763975155, "avg_line_length": 23, "ext": "agda", "hexsha": "731cd42bbf5a87686bd4e0af93a394183d6d01fc", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_path": "src/sets/vec.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/sets/vec.agda", "max_line_length": 38, "max_stars_count": 20, "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_path": "src/sets/vec.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "num_tokens": 33, "size": 161 }
{-# OPTIONS --without-K --exact-split --allow-unsolved-metas #-} module 06-universes where import 05-identity-types open 05-identity-types public -- Section 4.1 Type theoretic universes {- Because of Agda's design we already had to introduce universes in the very first file. What is left to do here is to formalize the examples of structured types. -} -- Pointed types UU-pt : (i : Level) → UU (lsuc i) UU-pt i = Σ (UU i) (λ X → X) -- Graphs Gph : (i : Level) → UU (lsuc i) Gph i = Σ (UU i) (λ X → (X → X → (UU i))) -- Reflexive graphs rGph : (i : Level) → UU (lsuc i) rGph i = Σ (UU i) (λ X → Σ (X → X → (UU i)) (λ R → (x : X) → R x x)) -- Section 4.2 Defining families and relations using a universe -- Finite sets Fin : ℕ → UU lzero Fin zero-ℕ = empty Fin (succ-ℕ n) = coprod (Fin n) unit -- Observational equality on the natural numbers Eq-ℕ : ℕ → (ℕ → UU lzero) Eq-ℕ zero-ℕ zero-ℕ = 𝟙 Eq-ℕ zero-ℕ (succ-ℕ n) = 𝟘 Eq-ℕ (succ-ℕ m) zero-ℕ = 𝟘 Eq-ℕ (succ-ℕ m) (succ-ℕ n) = Eq-ℕ m n -- Exercises -- Exercise 3.1 {- In this exercise we were asked to show that (A + ¬A) implies (¬¬A → A). In other words, we get double negation elimination for the types that are decidable. -} is-decidable : {l : Level} (A : UU l) → UU l is-decidable A = coprod A (¬ A) double-negation-elim-is-decidable : {i : Level} (A : UU i) → is-decidable A → (¬ (¬ A) → A) double-negation-elim-is-decidable A (inl x) p = x double-negation-elim-is-decidable A (inr x) p = ind-empty (p x) -- Exercise 3.3 {- In this exercise we were asked to show that the observational equality on ℕ is an equivalence relation. -} refl-Eq-ℕ : (n : ℕ) → Eq-ℕ n n refl-Eq-ℕ zero-ℕ = star refl-Eq-ℕ (succ-ℕ n) = refl-Eq-ℕ n symmetric-Eq-ℕ : (m n : ℕ) → Eq-ℕ m n → Eq-ℕ n m symmetric-Eq-ℕ zero-ℕ zero-ℕ t = t symmetric-Eq-ℕ zero-ℕ (succ-ℕ n) t = t symmetric-Eq-ℕ (succ-ℕ n) zero-ℕ t = t symmetric-Eq-ℕ (succ-ℕ m) (succ-ℕ n) t = symmetric-Eq-ℕ m n t transitive-Eq-ℕ : (l m n : ℕ) → Eq-ℕ l m → Eq-ℕ m n → Eq-ℕ l n transitive-Eq-ℕ zero-ℕ zero-ℕ zero-ℕ s t = star transitive-Eq-ℕ (succ-ℕ n) zero-ℕ zero-ℕ s t = ind-empty s transitive-Eq-ℕ zero-ℕ (succ-ℕ n) zero-ℕ s t = ind-empty s transitive-Eq-ℕ zero-ℕ zero-ℕ (succ-ℕ n) s t = ind-empty t transitive-Eq-ℕ (succ-ℕ l) (succ-ℕ m) zero-ℕ s t = ind-empty t transitive-Eq-ℕ (succ-ℕ l) zero-ℕ (succ-ℕ n) s t = ind-empty s transitive-Eq-ℕ zero-ℕ (succ-ℕ m) (succ-ℕ n) s t = ind-empty s transitive-Eq-ℕ (succ-ℕ l) (succ-ℕ m) (succ-ℕ n) s t = transitive-Eq-ℕ l m n s t -- Exercise 3.4 {- In this exercise we were asked to show that observational equality on the natural numbers is the least reflexive relation, in the sense that it implies all other reflexive relation. As we will see once we introduce the identity type, it follows that observationally equal natural numbers can be identified. -} succ-relation-ℕ : {i : Level} (R : ℕ → ℕ → UU i) → ℕ → ℕ → UU i succ-relation-ℕ R m n = R (succ-ℕ m) (succ-ℕ n) succ-reflexivity-ℕ : {i : Level} (R : ℕ → ℕ → UU i) (ρ : (n : ℕ) → R n n) → (n : ℕ) → succ-relation-ℕ R n n succ-reflexivity-ℕ R ρ n = ρ (succ-ℕ n) {- In the book we suggest that first the order of the variables should be swapped, in order to make the inductive hypothesis stronger. Agda's pattern matching mechanism allows us to bypass this step and give a more direct construction. -} least-reflexive-Eq-ℕ : {i : Level} (R : ℕ → ℕ → UU i) (ρ : (n : ℕ) → R n n) → (m n : ℕ) → Eq-ℕ m n → R m n least-reflexive-Eq-ℕ R ρ zero-ℕ zero-ℕ star = ρ zero-ℕ least-reflexive-Eq-ℕ R ρ zero-ℕ (succ-ℕ n) () least-reflexive-Eq-ℕ R ρ (succ-ℕ m) zero-ℕ () least-reflexive-Eq-ℕ R ρ (succ-ℕ m) (succ-ℕ n) e = least-reflexive-Eq-ℕ (succ-relation-ℕ R) (succ-reflexivity-ℕ R ρ) m n e -- Exercise 3.5 {- In this exercise we were asked to show that any function on the natural numbers preserves observational equality. The quick solution uses the fact that observational equality is the least reflexive relation. -} preserve_Eq-ℕ : (f : ℕ → ℕ) (n m : ℕ) → (Eq-ℕ n m) → (Eq-ℕ (f n) (f m)) preserve_Eq-ℕ f = least-reflexive-Eq-ℕ ( λ x y → Eq-ℕ (f x) (f y)) ( λ x → refl-Eq-ℕ (f x)) -- Exercise 3.6 {- In this exercise we were asked to construct the relations ≤ and < on the natural numbers, and show basic properties about them. -} -- The definition of ≤ leq-ℕ : ℕ → ℕ → UU lzero leq-ℕ zero-ℕ m = unit leq-ℕ (succ-ℕ n) zero-ℕ = empty leq-ℕ (succ-ℕ n) (succ-ℕ m) = leq-ℕ n m _≤_ = leq-ℕ leq-zero-ℕ : (n : ℕ) → leq-ℕ zero-ℕ n leq-zero-ℕ zero-ℕ = star leq-zero-ℕ (succ-ℕ n) = star -- The definition of < le-ℕ : ℕ → ℕ → UU lzero le-ℕ m zero-ℕ = empty le-ℕ zero-ℕ (succ-ℕ m) = unit le-ℕ (succ-ℕ n) (succ-ℕ m) = le-ℕ n m _<_ = le-ℕ reflexive-leq-ℕ : (n : ℕ) → n ≤ n reflexive-leq-ℕ zero-ℕ = star reflexive-leq-ℕ (succ-ℕ n) = reflexive-leq-ℕ n anti-reflexive-le-ℕ : (n : ℕ) → ¬ (n < n) anti-reflexive-le-ℕ zero-ℕ = ind-empty anti-reflexive-le-ℕ (succ-ℕ n) = anti-reflexive-le-ℕ n transitive-leq-ℕ : (n m l : ℕ) → (n ≤ m) → (m ≤ l) → (n ≤ l) transitive-leq-ℕ zero-ℕ m l p q = star transitive-leq-ℕ (succ-ℕ n) (succ-ℕ m) (succ-ℕ l) p q = transitive-leq-ℕ n m l p q transitive-le-ℕ : (n m l : ℕ) → (le-ℕ n m) → (le-ℕ m l) → (le-ℕ n l) transitive-le-ℕ zero-ℕ (succ-ℕ m) (succ-ℕ l) p q = star transitive-le-ℕ (succ-ℕ n) (succ-ℕ m) (succ-ℕ l) p q = transitive-le-ℕ n m l p q succ-le-ℕ : (n : ℕ) → le-ℕ n (succ-ℕ n) succ-le-ℕ zero-ℕ = star succ-le-ℕ (succ-ℕ n) = succ-le-ℕ n -- Exercise 3.7 {- With the construction of the divisibility relation we open the door to basic number theory. -} divides : (d n : ℕ) → UU lzero divides d n = Σ ℕ (λ m → Eq-ℕ (mul-ℕ d m) n) -- Exercise 3.8 {- In this exercise we were asked to construct observational equality on the booleans. This construction is analogous to, but simpler than, the construction of observational equality on the natural numbers. -} Eq-𝟚 : bool → bool → UU lzero Eq-𝟚 true true = unit Eq-𝟚 true false = empty Eq-𝟚 false true = empty Eq-𝟚 false false = unit reflexive-Eq-𝟚 : (x : bool) → Eq-𝟚 x x reflexive-Eq-𝟚 true = star reflexive-Eq-𝟚 false = star least-reflexive-Eq-𝟚 : {i : Level} (R : bool → bool → UU i) (ρ : (x : bool) → R x x) (x y : bool) → Eq-𝟚 x y → R x y least-reflexive-Eq-𝟚 R ρ true true p = ρ true least-reflexive-Eq-𝟚 R ρ true false p = ind-empty p least-reflexive-Eq-𝟚 R ρ false true p = ind-empty p least-reflexive-Eq-𝟚 R ρ false false p = ρ false -- Exercise 3.10 {- In this exercise we were asked to define the relations ≤ and < on the integers. As a criterion of correctness, we were then also asked to show that the type of all integers l satisfying k ≤ l satisfy the induction principle of the natural numbers. -} is-non-negative-ℤ : ℤ → UU lzero is-non-negative-ℤ (inl x) = empty is-non-negative-ℤ (inr k) = unit diff-ℤ : ℤ → ℤ → ℤ diff-ℤ k l = add-ℤ (neg-ℤ k) l leq-ℤ : ℤ → ℤ → UU lzero leq-ℤ k l = is-non-negative-ℤ (diff-ℤ k l) reflexive-leq-ℤ : (k : ℤ) → leq-ℤ k k reflexive-leq-ℤ k = tr is-non-negative-ℤ (inv (left-inverse-law-add-ℤ k)) star is-non-negative-succ-ℤ : (k : ℤ) → is-non-negative-ℤ k → is-non-negative-ℤ (succ-ℤ k) is-non-negative-succ-ℤ (inr (inl star)) p = star is-non-negative-succ-ℤ (inr (inr x)) p = star is-non-negative-add-ℤ : (k l : ℤ) → is-non-negative-ℤ k → is-non-negative-ℤ l → is-non-negative-ℤ (add-ℤ k l) is-non-negative-add-ℤ (inr (inl star)) (inr (inl star)) p q = star is-non-negative-add-ℤ (inr (inl star)) (inr (inr n)) p q = star is-non-negative-add-ℤ (inr (inr zero-ℕ)) (inr (inl star)) p q = star is-non-negative-add-ℤ (inr (inr (succ-ℕ n))) (inr (inl star)) star star = is-non-negative-succ-ℤ ( add-ℤ (inr (inr n)) (inr (inl star))) ( is-non-negative-add-ℤ (inr (inr n)) (inr (inl star)) star star) is-non-negative-add-ℤ (inr (inr zero-ℕ)) (inr (inr m)) star star = star is-non-negative-add-ℤ (inr (inr (succ-ℕ n))) (inr (inr m)) star star = is-non-negative-succ-ℤ ( add-ℤ (inr (inr n)) (inr (inr m))) ( is-non-negative-add-ℤ (inr (inr n)) (inr (inr m)) star star) triangle-diff-ℤ : (k l m : ℤ) → Id (add-ℤ (diff-ℤ k l) (diff-ℤ l m)) (diff-ℤ k m) triangle-diff-ℤ k l m = ( associative-add-ℤ (neg-ℤ k) l (diff-ℤ l m)) ∙ ( ap ( add-ℤ (neg-ℤ k)) ( ( inv (associative-add-ℤ l (neg-ℤ l) m)) ∙ ( ( ap (λ x → add-ℤ x m) (right-inverse-law-add-ℤ l)) ∙ ( left-unit-law-add-ℤ m)))) transitive-leq-ℤ : (k l m : ℤ) → leq-ℤ k l → leq-ℤ l m → leq-ℤ k m transitive-leq-ℤ k l m p q = tr is-non-negative-ℤ ( triangle-diff-ℤ k l m) ( is-non-negative-add-ℤ ( add-ℤ (neg-ℤ k) l) ( add-ℤ (neg-ℤ l) m) ( p) ( q)) succ-leq-ℤ : (k : ℤ) → leq-ℤ k (succ-ℤ k) succ-leq-ℤ k = tr is-non-negative-ℤ ( inv ( ( right-successor-law-add-ℤ (neg-ℤ k) k) ∙ ( ap succ-ℤ (left-inverse-law-add-ℤ k)))) ( star) leq-ℤ-succ-leq-ℤ : (k l : ℤ) → leq-ℤ k l → leq-ℤ k (succ-ℤ l) leq-ℤ-succ-leq-ℤ k l p = transitive-leq-ℤ k l (succ-ℤ l) p (succ-leq-ℤ l) is-positive-ℤ : ℤ → UU lzero is-positive-ℤ k = is-non-negative-ℤ (pred-ℤ k) le-ℤ : ℤ → ℤ → UU lzero le-ℤ (inl zero-ℕ) (inl x) = empty le-ℤ (inl zero-ℕ) (inr y) = unit le-ℤ (inl (succ-ℕ x)) (inl zero-ℕ) = unit le-ℤ (inl (succ-ℕ x)) (inl (succ-ℕ y)) = le-ℤ (inl x) (inl y) le-ℤ (inl (succ-ℕ x)) (inr y) = unit le-ℤ (inr x) (inl y) = empty le-ℤ (inr (inl star)) (inr (inl star)) = empty le-ℤ (inr (inl star)) (inr (inr x)) = unit le-ℤ (inr (inr x)) (inr (inl star)) = empty le-ℤ (inr (inr zero-ℕ)) (inr (inr zero-ℕ)) = empty le-ℤ (inr (inr zero-ℕ)) (inr (inr (succ-ℕ y))) = unit le-ℤ (inr (inr (succ-ℕ x))) (inr (inr zero-ℕ)) = empty le-ℤ (inr (inr (succ-ℕ x))) (inr (inr (succ-ℕ y))) = le-ℤ (inr (inr x)) (inr (inr y)) -- We prove that the induction principle for ℕ implies strong induction. zero-ℕ-leq-ℕ : (n : ℕ) → leq-ℕ zero-ℕ n zero-ℕ-leq-ℕ n = star fam-strong-ind-ℕ : { l : Level} → (ℕ → UU l) → ℕ → UU l fam-strong-ind-ℕ P n = (m : ℕ) → (leq-ℕ m n) → P m zero-strong-ind-ℕ : { l : Level} (P : ℕ → UU l) → P zero-ℕ → fam-strong-ind-ℕ P zero-ℕ zero-strong-ind-ℕ P p0 zero-ℕ t = p0 zero-strong-ind-ℕ P p0 (succ-ℕ m) () succ-strong-ind-ℕ : { l : Level} (P : ℕ → UU l) → ( (k : ℕ) → (fam-strong-ind-ℕ P k) → P (succ-ℕ k)) → ( k : ℕ) → (fam-strong-ind-ℕ P k) → (fam-strong-ind-ℕ P (succ-ℕ k)) succ-strong-ind-ℕ P pS k f zero-ℕ t = f zero-ℕ (zero-ℕ-leq-ℕ k) succ-strong-ind-ℕ P pS k f (succ-ℕ m) t = pS m (λ m' t' → f m' (transitive-leq-ℕ m' m k t' t)) conclusion-strong-ind-ℕ : { l : Level} (P : ℕ → UU l) → ( ( n : ℕ) → fam-strong-ind-ℕ P n) → (n : ℕ) → P n conclusion-strong-ind-ℕ P f n = f n n (reflexive-leq-ℕ n) induction-strong-ind-ℕ : { l : Level} (P : ℕ → UU l) → ( fam-strong-ind-ℕ P zero-ℕ) → ( (k : ℕ) → (fam-strong-ind-ℕ P k) → (fam-strong-ind-ℕ P (succ-ℕ k))) → ( n : ℕ) → fam-strong-ind-ℕ P n induction-strong-ind-ℕ P q0 qS zero-ℕ = q0 induction-strong-ind-ℕ P q0 qS (succ-ℕ n) = qS n ( induction-strong-ind-ℕ P q0 qS n) strong-ind-ℕ : { l : Level} → (P : ℕ → UU l) (p0 : P zero-ℕ) → ( pS : (k : ℕ) → (fam-strong-ind-ℕ P k) → P (succ-ℕ k)) → ( n : ℕ) → P n strong-ind-ℕ P p0 pS = conclusion-strong-ind-ℕ P ( induction-strong-ind-ℕ P ( zero-strong-ind-ℕ P p0) ( succ-strong-ind-ℕ P pS)) -- We show that induction on ℕ implies ordinal induction. fam-ordinal-ind-ℕ : { l : Level} → (ℕ → UU l) → ℕ → UU l fam-ordinal-ind-ℕ P n = (m : ℕ) → (le-ℕ m n) → P m le-zero-ℕ : (m : ℕ) → (le-ℕ m zero-ℕ) → empty le-zero-ℕ zero-ℕ () le-zero-ℕ (succ-ℕ m) () zero-ordinal-ind-ℕ : { l : Level} (P : ℕ → UU l) → fam-ordinal-ind-ℕ P zero-ℕ zero-ordinal-ind-ℕ P m t = ind-empty (le-zero-ℕ m t) le-one-ℕ : (n : ℕ) → le-ℕ (succ-ℕ n) one-ℕ → empty le-one-ℕ zero-ℕ () le-one-ℕ (succ-ℕ n) () transitive-le-ℕ' : (k l m : ℕ) → (le-ℕ k l) → (le-ℕ l (succ-ℕ m)) → le-ℕ k m transitive-le-ℕ' zero-ℕ zero-ℕ m () s transitive-le-ℕ' (succ-ℕ k) zero-ℕ m () s transitive-le-ℕ' zero-ℕ (succ-ℕ l) zero-ℕ star s = ind-empty (le-one-ℕ l s) transitive-le-ℕ' (succ-ℕ k) (succ-ℕ l) zero-ℕ t s = ind-empty (le-one-ℕ l s) transitive-le-ℕ' zero-ℕ (succ-ℕ l) (succ-ℕ m) star s = star transitive-le-ℕ' (succ-ℕ k) (succ-ℕ l) (succ-ℕ m) t s = transitive-le-ℕ' k l m t s succ-ordinal-ind-ℕ : { l : Level} (P : ℕ → UU l) → ( (n : ℕ) → (fam-ordinal-ind-ℕ P n) → P n) → ( k : ℕ) → fam-ordinal-ind-ℕ P k → fam-ordinal-ind-ℕ P (succ-ℕ k) succ-ordinal-ind-ℕ P f k g m t = f m (λ m' t' → g m' (transitive-le-ℕ' m' m k t' t)) induction-ordinal-ind-ℕ : { l : Level} (P : ℕ → UU l) → ( qS : (k : ℕ) → fam-ordinal-ind-ℕ P k → fam-ordinal-ind-ℕ P (succ-ℕ k)) ( n : ℕ) → fam-ordinal-ind-ℕ P n induction-ordinal-ind-ℕ P qS zero-ℕ = zero-ordinal-ind-ℕ P induction-ordinal-ind-ℕ P qS (succ-ℕ n) = qS n (induction-ordinal-ind-ℕ P qS n) conclusion-ordinal-ind-ℕ : { l : Level} (P : ℕ → UU l) → (( n : ℕ) → fam-ordinal-ind-ℕ P n) → (n : ℕ) → P n conclusion-ordinal-ind-ℕ P f n = f (succ-ℕ n) n (succ-le-ℕ n) ordinal-ind-ℕ : { l : Level} (P : ℕ → UU l) → ( (n : ℕ) → (fam-ordinal-ind-ℕ P n) → P n) → ( n : ℕ) → P n ordinal-ind-ℕ P f = conclusion-ordinal-ind-ℕ P ( induction-ordinal-ind-ℕ P (succ-ordinal-ind-ℕ P f)) -- Extra material -- We show that ℕ is an ordered semi-ring leq-eq-ℕ : {m m' n n' : ℕ} → Id m m' → Id n n' → leq-ℕ m n → leq-ℕ m' n' leq-eq-ℕ refl refl = id right-law-leq-add-ℕ : (k m n : ℕ) → leq-ℕ m n → leq-ℕ (add-ℕ k m) (add-ℕ k n) right-law-leq-add-ℕ zero-ℕ m n = id right-law-leq-add-ℕ (succ-ℕ k) m n H = right-law-leq-add-ℕ k m n H left-law-leq-add-ℕ : (k m n : ℕ) → leq-ℕ m n → leq-ℕ (add-ℕ m k) (add-ℕ n k) left-law-leq-add-ℕ k m n H = leq-eq-ℕ ( commutative-add-ℕ k m) ( commutative-add-ℕ k n) ( right-law-leq-add-ℕ k m n H) preserves-leq-add-ℕ : {m m' n n' : ℕ} → leq-ℕ m m' → leq-ℕ n n' → leq-ℕ (add-ℕ m n) (add-ℕ m' n') preserves-leq-add-ℕ {m} {m'} {n} {n'} H K = transitive-leq-ℕ ( add-ℕ m n) ( add-ℕ m' n) ( add-ℕ m' n') ( left-law-leq-add-ℕ n m m' H) ( right-law-leq-add-ℕ m' n n' K) right-law-leq-mul-ℕ : (k m n : ℕ) → leq-ℕ m n → leq-ℕ (mul-ℕ k m) (mul-ℕ k n) right-law-leq-mul-ℕ zero-ℕ m n H = star right-law-leq-mul-ℕ (succ-ℕ k) m n H = preserves-leq-add-ℕ { m = mul-ℕ k m} { m' = mul-ℕ k n} ( right-law-leq-mul-ℕ k m n H) H left-law-leq-mul-ℕ : (k m n : ℕ) → leq-ℕ m n → leq-ℕ (mul-ℕ m k) (mul-ℕ n k) left-law-leq-mul-ℕ k m n H = leq-eq-ℕ ( commutative-mul-ℕ k m) ( commutative-mul-ℕ k n) ( right-law-leq-mul-ℕ k m n H) -- We show that ℤ is an ordered ring {- leq-add-ℤ : (m k l : ℤ) → leq-ℤ k l → leq-ℤ (add-ℤ m k) (add-ℤ m l) leq-add-ℤ (inl zero-ℕ) k l H = {!!} leq-add-ℤ (inl (succ-ℕ x)) k l H = {!!} leq-add-ℤ (inr m) k l H = {!!} -} -- Section 5.5 Identity systems succ-fam-Eq-ℕ : {i : Level} (R : (m n : ℕ) → Eq-ℕ m n → UU i) → (m n : ℕ) → Eq-ℕ m n → UU i succ-fam-Eq-ℕ R m n e = R (succ-ℕ m) (succ-ℕ n) e succ-refl-fam-Eq-ℕ : {i : Level} (R : (m n : ℕ) → Eq-ℕ m n → UU i) (ρ : (n : ℕ) → R n n (refl-Eq-ℕ n)) → (n : ℕ) → (succ-fam-Eq-ℕ R n n (refl-Eq-ℕ n)) succ-refl-fam-Eq-ℕ R ρ n = ρ (succ-ℕ n) path-ind-Eq-ℕ : {i : Level} (R : (m n : ℕ) → Eq-ℕ m n → UU i) ( ρ : (n : ℕ) → R n n (refl-Eq-ℕ n)) → ( m n : ℕ) (e : Eq-ℕ m n) → R m n e path-ind-Eq-ℕ R ρ zero-ℕ zero-ℕ star = ρ zero-ℕ path-ind-Eq-ℕ R ρ zero-ℕ (succ-ℕ n) () path-ind-Eq-ℕ R ρ (succ-ℕ m) zero-ℕ () path-ind-Eq-ℕ R ρ (succ-ℕ m) (succ-ℕ n) e = path-ind-Eq-ℕ (succ-fam-Eq-ℕ R) (succ-refl-fam-Eq-ℕ R ρ) m n e comp-path-ind-Eq-ℕ : {i : Level} (R : (m n : ℕ) → Eq-ℕ m n → UU i) ( ρ : (n : ℕ) → R n n (refl-Eq-ℕ n)) → ( n : ℕ) → Id (path-ind-Eq-ℕ R ρ n n (refl-Eq-ℕ n)) (ρ n) comp-path-ind-Eq-ℕ R ρ zero-ℕ = refl comp-path-ind-Eq-ℕ R ρ (succ-ℕ n) = comp-path-ind-Eq-ℕ (succ-fam-Eq-ℕ R) (succ-refl-fam-Eq-ℕ R ρ) n
{ "alphanum_fraction": 0.5914019403, "avg_line_length": 32.450617284, "ext": "agda", "hexsha": "24501bb5ff866ae1c44e3ca9e768720b9607c188", "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": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "tadejpetric/HoTT-Intro", "max_forks_repo_path": "Agda/06-universes.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "tadejpetric/HoTT-Intro", "max_issues_repo_path": "Agda/06-universes.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "tadejpetric/HoTT-Intro", "max_stars_repo_path": "Agda/06-universes.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 7292, "size": 15771 }
{-# OPTIONS --cubical #-} module Cubical.Categories.NaturalTransformation where open import Cubical.Foundations.Prelude open import Cubical.Categories.Category open import Cubical.Categories.Functor private variable ℓ𝒞 ℓ𝒞' ℓ𝒟 ℓ𝒟' : Level module _ {𝒞 : Precategory ℓ𝒞 ℓ𝒞'} {𝒟 : Precategory ℓ𝒟 ℓ𝒟'} where record NatTrans (F G : Functor 𝒞 𝒟) : Type (ℓ-max (ℓ-max ℓ𝒞 ℓ𝒞') (ℓ-max ℓ𝒟 ℓ𝒟')) where open Precategory open Functor field N-ob : (x : 𝒞 .ob) → 𝒟 .hom (F .F-ob x) (G .F-ob x) N-hom : {x y : 𝒞 .ob} (f : 𝒞 .hom x y) → 𝒟 .seq (F .F-hom f) (N-ob y) ≡ 𝒟 .seq (N-ob x) (G .F-hom f) open Precategory open Functor open NatTrans id-trans : (F : Functor 𝒞 𝒟) → NatTrans F F id-trans F .N-ob x = 𝒟 .idn (F .F-ob x) id-trans F .N-hom f = 𝒟 .seq (F .F-hom f) (id-trans F .N-ob _) ≡⟨ 𝒟 .seq-ρ _ ⟩ F .F-hom f ≡⟨ sym (𝒟 .seq-λ _) ⟩ 𝒟 .seq (𝒟 .idn (F .F-ob _)) (F .F-hom f) ∎ seq-trans : {F G H : Functor 𝒞 𝒟} (α : NatTrans F G) (β : NatTrans G H) → NatTrans F H seq-trans α β .N-ob x = 𝒟 .seq (α .N-ob x) (β .N-ob x) seq-trans {F} {G} {H} α β .N-hom f = 𝒟 .seq (F .F-hom f) (𝒟 .seq (α .N-ob _) (β .N-ob _)) ≡⟨ sym (𝒟 .seq-α _ _ _) ⟩ 𝒟 .seq (𝒟 .seq (F .F-hom f) (α .N-ob _)) (β .N-ob _) ≡[ i ]⟨ 𝒟 .seq (α .N-hom f i) (β .N-ob _) ⟩ 𝒟 .seq (𝒟 .seq (α .N-ob _) (G .F-hom f)) (β .N-ob _) ≡⟨ 𝒟 .seq-α _ _ _ ⟩ 𝒟 .seq (α .N-ob _) (𝒟 .seq (G .F-hom f) (β .N-ob _)) ≡[ i ]⟨ 𝒟 .seq (α .N-ob _) (β .N-hom f i) ⟩ 𝒟 .seq (α .N-ob _) (𝒟 .seq (β .N-ob _) (H .F-hom f)) ≡⟨ sym (𝒟 .seq-α _ _ _) ⟩ 𝒟 .seq (𝒟 .seq (α .N-ob _) (β .N-ob _)) (H .F-hom f) ∎ module _ ⦃ 𝒟-category : isCategory 𝒟 ⦄ {F G : Functor 𝒞 𝒟} {α β : NatTrans F G} where open Precategory open Functor open NatTrans make-nat-trans-path : α .N-ob ≡ β .N-ob → α ≡ β make-nat-trans-path p i .N-ob = p i make-nat-trans-path p i .N-hom f = rem i where rem : PathP (λ i → 𝒟 .seq (F .F-hom f) (p i _) ≡ 𝒟 .seq (p i _) (G .F-hom f)) (α .N-hom f) (β .N-hom f) rem = toPathP (𝒟-category .homIsSet _ _ _ _) module _ (𝒞 : Precategory ℓ𝒞 ℓ𝒞') (𝒟 : Precategory ℓ𝒟 ℓ𝒟') ⦃ _ : isCategory 𝒟 ⦄ where open Precategory open NatTrans open Functor FUNCTOR : Precategory (ℓ-max (ℓ-max ℓ𝒞 ℓ𝒞') (ℓ-max ℓ𝒟 ℓ𝒟')) (ℓ-max (ℓ-max ℓ𝒞 ℓ𝒞') (ℓ-max ℓ𝒟 ℓ𝒟')) FUNCTOR .ob = Functor 𝒞 𝒟 FUNCTOR .hom = NatTrans FUNCTOR .idn = id-trans FUNCTOR .seq = seq-trans FUNCTOR .seq-λ α = make-nat-trans-path λ i x → 𝒟 .seq-λ (α .N-ob x) i FUNCTOR .seq-ρ α = make-nat-trans-path λ i x → 𝒟 .seq-ρ (α .N-ob x) i FUNCTOR .seq-α α β γ = make-nat-trans-path λ i x → 𝒟 .seq-α (α .N-ob x) (β .N-ob x) (γ .N-ob x) i
{ "alphanum_fraction": 0.538856305, "avg_line_length": 34.1, "ext": "agda", "hexsha": "ada608a85b5fe4e6ab027665dedb75fab42f9b32", "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": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "borsiemir/cubical", "max_forks_repo_path": "Cubical/Categories/NaturalTransformation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "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": "borsiemir/cubical", "max_issues_repo_path": "Cubical/Categories/NaturalTransformation.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "borsiemir/cubical", "max_stars_repo_path": "Cubical/Categories/NaturalTransformation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1348, "size": 2728 }
-- {-# OPTIONS -v tc.with:40 #-} id : (A : Set) → A → A id A = {!id′!} -- C-c C-h produces: id′ : ∀ {A} → A -- when it should produce: id′ : ∀ {A} → A → A
{ "alphanum_fraction": 0.4207317073, "avg_line_length": 23.4285714286, "ext": "agda", "hexsha": "150032ea26ab1c138095f8f6156c5cfc96ed0625", "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/interaction/Issue1130.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/interaction/Issue1130.agda", "max_line_length": 47, "max_stars_count": 1, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/interaction/Issue1130.agda", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "num_tokens": 67, "size": 164 }
-- Andreas, 2016-01-23, issue 1796 -- Need to run size constraint solver before with-abstraction open import Common.Size postulate anything : ∀{A : Set} → A mutual record IO i : Set where coinductive field force : ∀{j : Size< i} → IO' j data IO' i : Set where cons : IO i → IO' i mutual record All i (s : IO ∞) : Set where field force : ∀{j : Size< i} → All' j (IO.force s) data All' i : (s : IO' ∞) → Set where always : ∀ e → All' i (cons e) runIO : ∀{i} (s : IO ∞) → IO i IO.force (runIO s) with IO.force s ... | cons e = cons e -- With abstraction fails when _ in IO.force s {_} -- has not been solved to ∞. test : ∀ i s → All i (runIO s) All.force (test i s) with IO.force s -- works with {∞} added All.force (test i s) | cons e = always e -- cons e != IO.force (runIO {∞} s) {∞} | IO.force s of type IO' ∞ -- when checking that the expression always e has type -- All' .j (IO.force (runIO {∞} s) {∞} | IO.force s)
{ "alphanum_fraction": 0.5908618899, "avg_line_length": 24.075, "ext": "agda", "hexsha": "06ce802cafd4077083cef06084dd7c463ea48fd2", "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/Issue1796.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/Issue1796.agda", "max_line_length": 66, "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/Issue1796.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 345, "size": 963 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Functions.Definition module Sets.EquivalenceRelations where Reflexive : {a b : _} {A : Set a} (r : Rel {a} {b} A) → Set (a ⊔ b) Reflexive {A = A} r = {x : A} → r x x Symmetric : {a b : _} {A : Set a} (r : Rel {a} {b} A) → Set (a ⊔ b) Symmetric {A = A} r = {x y : A} → r x y → r y x Transitive : {a b : _} {A : Set a} (r : Rel {a} {b} A) → Set (a ⊔ b) Transitive {A = A} r = {x y z : A} → r x y → r y z → r x z record Equivalence {a b : _} {A : Set a} (r : Rel {a} {b} A) : Set (a ⊔ lsuc b) where field reflexive : Reflexive r symmetric : Symmetric r transitive : Transitive r -- See https://lists.chalmers.se/pipermail/agda/2016/009090.html transitive' : {x y z : A} → r y z → r x y → r x z transitive' p2 p1 = transitive p1 p2
{ "alphanum_fraction": 0.5711035267, "avg_line_length": 33.8076923077, "ext": "agda", "hexsha": "ff2cc44ae29a6f282d8915139697aa90660c5a92", "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": "Sets/EquivalenceRelations.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": "Sets/EquivalenceRelations.agda", "max_line_length": 85, "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": "Sets/EquivalenceRelations.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": 356, "size": 879 }
{-# OPTIONS --warning=error --safe --without-K #-} open import LogicalFormulae open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Numbers.Naturals.Semiring open import Numbers.Naturals.Order open import Lists.Lists open import Numbers.Primes.PrimeNumbers open import Decidable.Relations open import Numbers.BinaryNaturals.Definition open import Numbers.BinaryNaturals.Addition module ProjectEuler.Problem1 where numbers<N : (N : ℕ) → List ℕ numbers<N zero = [] numbers<N (succ N) = N :: numbers<N N filtered : (N : ℕ) → List ℕ filtered N = filter' (orDecidable (divisionDecidable 3) (divisionDecidable 5)) (numbers<N N) ans : ℕ → ℕ ans n = binNatToN (fold _+B_ (NToBinNat 0) (map NToBinNat (filtered n))) t : ans 10 ≡ 23 t = refl --q : ans 1000 ≡ {!233168!} -- takes about 15secs for me to reduce the term that fills this hole --q = refl
{ "alphanum_fraction": 0.7329479769, "avg_line_length": 28.8333333333, "ext": "agda", "hexsha": "7bbf63104bbb1f0c8e6d1c6ff58105400e3c3c4c", "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": "ProjectEuler/Problem1.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": "ProjectEuler/Problem1.agda", "max_line_length": 96, "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": "ProjectEuler/Problem1.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": 264, "size": 865 }
{-# OPTIONS --without-K #-} module equality.inspect where open import level open import equality.core data _of_is_ {i j}{A : Set i}{B : A → Set j} (f : (x : A) → B x)(x : A)(y : B x) : Set (i ⊔ j) where [_] : f x ≡ y → f of x is y inspect : ∀ {i j}{A : Set i}{B : A → Set j} → (f : (x : A)→ B x)(x : A) → f of x is f x inspect f x = [ refl ]
{ "alphanum_fraction": 0.4813829787, "avg_line_length": 25.0666666667, "ext": "agda", "hexsha": "14517928f33c3d436b351866e494723d2a77165f", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z", "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "HoTT/M-types", "max_forks_repo_path": "equality/inspect.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_issues_repo_issues_event_max_datetime": "2015-02-11T15:20:34.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-11T11:14:59.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "HoTT/M-types", "max_issues_repo_path": "equality/inspect.agda", "max_line_length": 67, "max_stars_count": 27, "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_path": "equality/inspect.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "num_tokens": 143, "size": 376 }
------------------------------------------------------------------------ -- Equivalence relations ------------------------------------------------------------------------ module Eq where infix 4 _≡_ ------------------------------------------------------------------------ -- Definition record Equiv {a : Set} (_≈_ : a -> a -> Set) : Set where field refl : forall x -> x ≈ x sym : forall {x y} -> x ≈ y -> y ≈ x _`trans`_ : forall {x y z} -> x ≈ y -> y ≈ z -> x ≈ z ------------------------------------------------------------------------ -- Propositional equality data _≡_ {a : Set} (x : a) : a -> Set where refl : x ≡ x subst : forall {a x y} -> (P : a -> Set) -> x ≡ y -> P x -> P y subst _ refl p = p cong : forall {a b x y} -> (f : a -> b) -> x ≡ y -> f x ≡ f y cong _ refl = refl Equiv-≡ : forall {a} -> Equiv {a} _≡_ Equiv-≡ {a} = record { refl = \_ -> refl ; sym = sym ; _`trans`_ = _`trans`_ } where sym : {x y : a} -> x ≡ y -> y ≡ x sym refl = refl _`trans`_ : {x y z : a} -> x ≡ y -> y ≡ z -> x ≡ z refl `trans` refl = refl
{ "alphanum_fraction": 0.3336275375, "avg_line_length": 25.75, "ext": "agda", "hexsha": "a4783ca3829bc756767ffacc0c256562a56d3671", "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": "examples/AIM6/RegExp/talk/Eq.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": "examples/AIM6/RegExp/talk/Eq.agda", "max_line_length": 72, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "examples/AIM6/RegExp/talk/Eq.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": 356, "size": 1133 }
{-# OPTIONS --without-K #-} module Explore.Examples where open import Type open import Level.NP open import Data.Maybe.NP open import Data.List open import Data.Zero open import Data.One open import Data.Two open import Data.Product open import Data.Sum.NP open import HoTT using (UA) open import Function.NP open import Function.Extensionality using (FunExt) open import Relation.Binary.PropositionalEquality hiding ([_]) open import Explore.Core open import Explore.Explorable open import Explore.Universe.Type {𝟘} open import Explore.Universe.Base open import Explore.Monad {₀} ₀ public renaming (map to map-explore) open import Explore.Two open import Explore.Product open Explore.Product.Operators module E where open FromExplore public module M {Msg Digest : ★} (_==_ : Digest → Digest → 𝟚) (H : Msg → Digest) (exploreMsg : ∀ {ℓ} → Explore ℓ Msg) (d : Digest) where module V1 where list-H⁻¹ : List Msg list-H⁻¹ = exploreMsg [] _++_ (λ m → [0: [] 1: [ m ] ] (H m == d)) module ExploreMsg = FromExplore {A = Msg} exploreMsg module V2 where first-H⁻¹ : Maybe Msg first-H⁻¹ = ExploreMsg.findKey (λ m → H m == d) module V3 where explore-H⁻¹ : Explore ₀ Msg explore-H⁻¹ ε _⊕_ f = exploreMsg ε _⊕_ (λ m → [0: ε 1: f m ] (H m == d)) module V4 where explore-H⁻¹ : Explore ₀ Msg explore-H⁻¹ = exploreMsg >>= λ m → [0: empty-explore 1: point-explore m ] (H m == d) module V5 where explore-H⁻¹ : ∀ {ℓ} → Explore ℓ Msg explore-H⁻¹ = filter-explore (λ m → H m == d) exploreMsg list-H⁻¹ : List Msg list-H⁻¹ = E.list explore-H⁻¹ first-H⁻¹ : Maybe Msg first-H⁻¹ = E.first explore-H⁻¹ module V6 where explore-H⁻¹ : ∀ {ℓ} → Explore ℓ Msg explore-H⁻¹ = explore-endo (filter-explore (λ m → H m == d) exploreMsg) list-H⁻¹ : List Msg list-H⁻¹ = E.list explore-H⁻¹ first-H⁻¹ : Maybe Msg first-H⁻¹ = E.first explore-H⁻¹ last-H⁻¹ : Maybe Msg last-H⁻¹ = E.last explore-H⁻¹ Msg = 𝟚 × 𝟚 Digest = 𝟚 -- _==_ : Digest → Digest → 𝟚 H : Msg → Digest H (x , y) = x xor y Msgᵉ : ∀ {ℓ} → Explore ℓ Msg Msgᵉ = 𝟚ᵉ ×ᵉ 𝟚ᵉ module N5 = M.V5 _==_ H Msgᵉ module N6 = M.V6 _==_ H Msgᵉ test5 = N5.list-H⁻¹ test6-list : N6.list-H⁻¹ 0₂ ≡ (0₂ , 0₂) ∷ (1₂ , 1₂) ∷ [] test6-list = refl test6-rev-list : E.list (E.backward (N6.explore-H⁻¹ 0₂)) ≡ (1₂ , 1₂) ∷ (0₂ , 0₂) ∷ [] test6-rev-list = refl test6-first : N6.first-H⁻¹ 0₂ ≡ just (0₂ , 0₂) test6-first = refl test6-last : N6.last-H⁻¹ 0₂ ≡ just (1₂ , 1₂) test6-last = refl -- -} 𝟛ᵁ : U 𝟛ᵁ = 𝟙ᵁ ⊎ᵁ 𝟚ᵁ prop-∧-comm : 𝟚 × 𝟚 → 𝟚 prop-∧-comm (x , y) = x ∧ y == y ∧ x module _ {{_ : UA}}{{_ : FunExt}} where check-∧-comm : ∀ x y → ✓ (x ∧ y == y ∧ x) check-∧-comm x y = check! (𝟚ᵁ ×ᵁ 𝟚ᵁ) prop-∧-comm (x , y) prop-∧-∨-distr : 𝟚 × 𝟚 × 𝟚 → 𝟚 prop-∧-∨-distr (x , y , z) = x ∧ (y ∨ z) == x ∧ y ∨ x ∧ z module _ {{_ : UA}}{{_ : FunExt}} where check-∧-∨-distr : ∀ x y z → ✓ (x ∧ (y ∨ z) == x ∧ y ∨ x ∧ z) check-∧-∨-distr x y z = check! (𝟚ᵁ ×ᵁ 𝟚ᵁ ×ᵁ 𝟚ᵁ) prop-∧-∨-distr (x , y , z) list22 = list (𝟚ᵁ →ᵁ 𝟚ᵁ) list33 = list (𝟛ᵁ →ᵁ 𝟛ᵁ) {- module _ {{_ : UA}}{{_ : FunExt}} where module _ (fᵁ : El (𝟚ᵁ →ᵁ 𝟚ᵁ)) x where f = →ᵁ→→ 𝟚ᵁ 𝟚ᵁ fᵁ check22 : ✓ (f x == f (f (f x))) check22 = check! ((𝟚ᵁ →ᵁ 𝟚ᵁ) ×ᵁ 𝟚ᵁ) (λ { (f , x) → let f' = →ᵁ→→ 𝟚ᵁ 𝟚ᵁ f in f' x == f' (f' (f' x)) }) {{!!}} ((f 0₂ , f 1₂) , x) {- check22 : ∀ (f : 𝟚 → 𝟚) x → ✓ (f x == f (f (f x))) check22 f x = let k = check! ((𝟚ᵁ →ᵁ 𝟚ᵁ) ×ᵁ 𝟚ᵁ) (λ { (f , x) → let f' = →ᵁ→→ 𝟚ᵁ 𝟚ᵁ f in f' x == f' (f' (f' x)) }) {{!!}} ((f 0₂ , f 1₂) , x) in {!k!} -- -} -- -} -- -} -- -}
{ "alphanum_fraction": 0.5672676838, "avg_line_length": 27.3106060606, "ext": "agda", "hexsha": "5a7ea1b35c03dac349d4f041f492ab22484a1155", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "crypto-agda/explore", "max_forks_repo_path": "lib/Explore/Examples.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "crypto-agda/explore", "max_issues_repo_path": "lib/Explore/Examples.agda", "max_line_length": 151, "max_stars_count": 2, "max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "crypto-agda/explore", "max_stars_repo_path": "lib/Explore/Examples.agda", "max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z", "num_tokens": 1699, "size": 3605 }
module Esterel.Context.Properties where open import Esterel.Lang open import Esterel.Environment as Env using (Env ; Θ ; _←_ ; module SigMap ; module ShrMap ; module VarMap) open import Esterel.Context using (EvaluationContext ; EvaluationContext1 ; _⟦_⟧e ; _≐_⟦_⟧e ; Context ; Context1 ; _⟦_⟧c ; _≐_⟦_⟧c) open import Esterel.Variable.Signal as Signal using (Signal) open import Esterel.Variable.Shared as SharedVar using (SharedVar) open import Esterel.Variable.Sequential as SeqVar using (SeqVar) open import Data.List using (List ; _∷_ ; [] ; map ; _++_) open import Data.Product using (Σ-syntax ; Σ ; _,_ ; proj₁ ; proj₂ ; _×_ ; _,′_) open import Data.Sum using (_⊎_ ; inj₁ ; inj₂) open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; sym ; cong ; subst ; trans) open _≐_⟦_⟧e open _≐_⟦_⟧c open EvaluationContext1 open Context1 plug : ∀{p E q} → E ⟦ q ⟧e ≡ p → p ≐ E ⟦ q ⟧e plug {E = []} refl = dehole plug {E = epar₁ q ∷ E} refl = depar₁ (plug {E = E} refl) plug {E = epar₂ p₁ ∷ E} refl = depar₂ (plug {E = E} refl) plug {E = eseq q ∷ E} refl = deseq (plug {E = E} refl) plug {E = eloopˢ q ∷ E} refl = deloopˢ (plug {E = E} refl) plug {E = esuspend S ∷ E} refl = desuspend (plug {E = E} refl) plug {E = etrap ∷ E} refl = detrap (plug {E = E} refl) unplug : ∀{p E q} → p ≐ E ⟦ q ⟧e → E ⟦ q ⟧e ≡ p unplug dehole = refl unplug (depar₁ eq) rewrite unplug eq = refl unplug (depar₂ eq) rewrite unplug eq = refl unplug (deseq eq) rewrite unplug eq = refl unplug (deloopˢ eq) rewrite unplug eq = refl unplug (desuspend eq) rewrite unplug eq = refl unplug (detrap eq) rewrite unplug eq = refl plugc : ∀ {C q p} → C ⟦ q ⟧c ≡ p → p ≐ C ⟦ q ⟧c plugc {[]} refl = dchole plugc {ceval (epar₁ q) ∷ C} refl = dcpar₁ (plugc {C} refl) plugc {ceval (epar₂ p) ∷ C} refl = dcpar₂ (plugc {C} refl) plugc {ceval (eseq q) ∷ C} refl = dcseq₁ (plugc {C} refl) plugc {ceval (eloopˢ q) ∷ C} refl = dcloopˢ₁ (plugc {C} refl) plugc {ceval (esuspend S) ∷ C} refl = dcsuspend (plugc {C} refl) plugc {ceval etrap ∷ C} refl = dctrap (plugc {C} refl) plugc {csignl S ∷ C} refl = dcsignl (plugc {C} refl) plugc {cpresent₁ S q ∷ C} refl = dcpresent₁ (plugc {C} refl) plugc {cpresent₂ S p ∷ C} refl = dcpresent₂ (plugc {C} refl) plugc {cloop ∷ C} refl = dcloop (plugc {C} refl) plugc {cloopˢ₂ p ∷ C} refl = dcloopˢ₂ (plugc {C} refl) plugc {cseq₂ p ∷ C} refl = dcseq₂ (plugc {C} refl) plugc {cshared s e ∷ C} refl = dcshared (plugc {C} refl) plugc {cvar x e ∷ C} refl = dcvar (plugc {C} refl) plugc {cif₁ x q ∷ C} refl = dcif₁ (plugc {C} refl) plugc {cif₂ x p ∷ C} refl = dcif₂ (plugc {C} refl) plugc {cenv θ A ∷ C} refl = dcenv (plugc {C} refl) unplugc : ∀{p C q} → p ≐ C ⟦ q ⟧c → C ⟦ q ⟧c ≡ p unplugc dchole = refl unplugc (dcpar₁ eq) rewrite unplugc eq = refl unplugc (dcpar₂ eq) rewrite unplugc eq = refl unplugc (dcseq₁ eq) rewrite unplugc eq = refl unplugc (dcseq₂ eq) rewrite unplugc eq = refl unplugc (dcsuspend eq) rewrite unplugc eq = refl unplugc (dctrap eq) rewrite unplugc eq = refl unplugc (dcsignl eq) rewrite unplugc eq = refl unplugc (dcpresent₁ eq) rewrite unplugc eq = refl unplugc (dcpresent₂ eq) rewrite unplugc eq = refl unplugc (dcloop eq) rewrite unplugc eq = refl unplugc (dcloopˢ₁ eq) rewrite unplugc eq = refl unplugc (dcloopˢ₂ eq) rewrite unplugc eq = refl unplugc (dcshared eq) rewrite unplugc eq = refl unplugc (dcvar eq) rewrite unplugc eq = refl unplugc (dcif₁ eq) rewrite unplugc eq = refl unplugc (dcif₂ eq) rewrite unplugc eq = refl unplugc (dcenv eq) rewrite unplugc eq = refl plug-sym : ∀{E E' p q} → E ⟦ p ⟧e ≐ E' ⟦ q ⟧e → E' ⟦ q ⟧e ≐ E ⟦ p ⟧e plug-sym eq = plug (sym (unplug eq)) unplug-eq : ∀{p q r E} → p ≐ E ⟦ q ⟧e → p ≐ E ⟦ r ⟧e → q ≡ r unplug-eq dehole dehole = refl unplug-eq (depar₁ qeq) (depar₁ req) = unplug-eq qeq req unplug-eq (depar₂ qeq) (depar₂ req) = unplug-eq qeq req unplug-eq (deseq qeq) (deseq req) = unplug-eq qeq req unplug-eq (deloopˢ qeq) (deloopˢ req) = unplug-eq qeq req unplug-eq (desuspend qeq) (desuspend req) = unplug-eq qeq req unplug-eq (detrap qeq) (detrap req) = unplug-eq qeq req plug-eq : ∀{p q r E} → p ≐ E ⟦ r ⟧e → q ≐ E ⟦ r ⟧e → p ≡ q plug-eq peq qeq = trans (sym (unplug peq)) (unplug qeq) Erefl : ∀{E p} → E ⟦ p ⟧e ≐ E ⟦ p ⟧e Erefl = plug refl Crefl : ∀{C p} → C ⟦ p ⟧c ≐ C ⟦ p ⟧c Crefl = plugc refl ⟦⟧e-to-⟦⟧c : ∀ {E p q} -> p ≐ E ⟦ q ⟧e -> p ≐ (map ceval E) ⟦ q ⟧c ⟦⟧e-to-⟦⟧c dehole = dchole ⟦⟧e-to-⟦⟧c (depar₁ decomp) = dcpar₁ (⟦⟧e-to-⟦⟧c decomp) ⟦⟧e-to-⟦⟧c (depar₂ decomp) = dcpar₂ (⟦⟧e-to-⟦⟧c decomp) ⟦⟧e-to-⟦⟧c (deseq decomp) = dcseq₁ (⟦⟧e-to-⟦⟧c decomp) ⟦⟧e-to-⟦⟧c (deloopˢ decomp) = dcloopˢ₁ (⟦⟧e-to-⟦⟧c decomp) ⟦⟧e-to-⟦⟧c (desuspend decomp) = dcsuspend (⟦⟧e-to-⟦⟧c decomp) ⟦⟧e-to-⟦⟧c (detrap decomp) = dctrap (⟦⟧e-to-⟦⟧c decomp) ⟦⟧c-to-⟦⟧e : ∀ {E p q} → p ≐ (map ceval E) ⟦ q ⟧c → p ≐ E ⟦ q ⟧e ⟦⟧c-to-⟦⟧e {[]} dchole = dehole ⟦⟧c-to-⟦⟧e {_ ∷ _} (dcpar₁ p≐E⟦q⟧) = depar₁ (⟦⟧c-to-⟦⟧e p≐E⟦q⟧) ⟦⟧c-to-⟦⟧e {_ ∷ _} (dcpar₂ p≐E⟦q⟧) = depar₂ (⟦⟧c-to-⟦⟧e p≐E⟦q⟧) ⟦⟧c-to-⟦⟧e {_ ∷ _} (dcseq₁ p≐E⟦q⟧) = deseq (⟦⟧c-to-⟦⟧e p≐E⟦q⟧) ⟦⟧c-to-⟦⟧e {_ ∷ _} (dcloopˢ₁ p≐E⟦q⟧) = deloopˢ (⟦⟧c-to-⟦⟧e p≐E⟦q⟧) ⟦⟧c-to-⟦⟧e {_ ∷ _} (dcsuspend p≐E⟦q⟧) = desuspend (⟦⟧c-to-⟦⟧e p≐E⟦q⟧) ⟦⟧c-to-⟦⟧e {_ ∷ _} (dctrap p≐E⟦q⟧) = detrap (⟦⟧c-to-⟦⟧e p≐E⟦q⟧) C++ : ∀ {C1 C2 p1 p2 p3} -> p1 ≐ C1 ⟦ p2 ⟧c -> p2 ≐ C2 ⟦ p3 ⟧c -> p1 ≐ C1 ++ C2 ⟦ p3 ⟧c C++ dchole p2C = p2C C++ (dcpar₁ p1C) p2C = dcpar₁ (C++ p1C p2C) C++ (dcpar₂ p1C) p2C = dcpar₂ (C++ p1C p2C) C++ (dcseq₁ p1C) p2C = dcseq₁ (C++ p1C p2C) C++ (dcseq₂ p1C) p2C = dcseq₂ (C++ p1C p2C) C++ (dcsuspend p1C) p2C = dcsuspend (C++ p1C p2C) C++ (dctrap p1C) p2C = dctrap (C++ p1C p2C) C++ (dcsignl p1C) p2C = dcsignl (C++ p1C p2C) C++ (dcpresent₁ p1C) p2C = dcpresent₁ (C++ p1C p2C) C++ (dcpresent₂ p1C) p2C = dcpresent₂ (C++ p1C p2C) C++ (dcloop p1C) p2C = dcloop (C++ p1C p2C) C++ (dcloopˢ₁ p1C) p2C = dcloopˢ₁ (C++ p1C p2C) C++ (dcloopˢ₂ p1C) p2C = dcloopˢ₂ (C++ p1C p2C) C++ (dcshared p1C) p2C = dcshared (C++ p1C p2C) C++ (dcvar p1C) p2C = dcvar (C++ p1C p2C) C++ (dcif₁ p1C) p2C = dcif₁ (C++ p1C p2C) C++ (dcif₂ p1C) p2C = dcif₂ (C++ p1C p2C) C++ (dcenv p1C) p2C = dcenv (C++ p1C p2C) ++-is-nesting : ∀ C′ C q -> (C′ ++ C) ⟦ q ⟧c ≐ C′ ⟦ C ⟦ q ⟧c ⟧c ++-is-nesting [] C q = dchole ++-is-nesting (ceval (epar₁ q) ∷ C′) C q₁ = dcpar₁ (++-is-nesting C′ C q₁) ++-is-nesting (ceval (epar₂ p) ∷ C′) C q = dcpar₂ (++-is-nesting C′ C q) ++-is-nesting (ceval (eseq q) ∷ C′) C q₁ = dcseq₁ (++-is-nesting C′ C q₁) ++-is-nesting (ceval (eloopˢ q) ∷ C′) C q₁ = dcloopˢ₁ (++-is-nesting C′ C q₁) ++-is-nesting (ceval (esuspend S) ∷ C′) C q = dcsuspend (++-is-nesting C′ C q) ++-is-nesting (ceval etrap ∷ C′) C q = dctrap (++-is-nesting C′ C q) ++-is-nesting (csignl S ∷ C′) C q = dcsignl (++-is-nesting C′ C q) ++-is-nesting (cpresent₁ S q ∷ C′) C q₁ = dcpresent₁ (++-is-nesting C′ C q₁) ++-is-nesting (cpresent₂ S p ∷ C′) C q = dcpresent₂ (++-is-nesting C′ C q) ++-is-nesting (cloop ∷ C′) C q = dcloop (++-is-nesting C′ C q) ++-is-nesting (cloopˢ₂ p ∷ C′) C q = dcloopˢ₂ (++-is-nesting C′ C q) ++-is-nesting (cseq₂ p ∷ C′) C q = dcseq₂ (++-is-nesting C′ C q) ++-is-nesting (cshared s e ∷ C′) C q = dcshared (++-is-nesting C′ C q) ++-is-nesting (cvar x e ∷ C′) C q = dcvar (++-is-nesting C′ C q) ++-is-nesting (cif₁ x q ∷ C′) C q₁ = dcif₁ (++-is-nesting C′ C q₁) ++-is-nesting (cif₂ x p ∷ C′) C q = dcif₂ (++-is-nesting C′ C q) ++-is-nesting (cenv θ A ∷ C′) C q = dcenv (++-is-nesting C′ C q)
{ "alphanum_fraction": 0.5704171934, "avg_line_length": 46.2573099415, "ext": "agda", "hexsha": "9700a25c1ca4891be7dd93545b3bcb71344dc6c2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_path": "agda/Esterel/Context/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "florence/esterel-calculus", "max_issues_repo_path": "agda/Esterel/Context/Properties.agda", "max_line_length": 78, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_path": "agda/Esterel/Context/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "num_tokens": 3794, "size": 7910 }
module RMonads.Modules where open import Library open import Categories open import Functors open import RMonads record Mod {a}{b}{c}{d}{C : Cat {a}{b}}{D : Cat {c}{d}}{J : Fun C D} (RM : RMonad J) : Set (a ⊔ c ⊔ d) where constructor mod open Cat open Fun open RMonad RM field M : Obj C → Obj D mbind : ∀ {X Y} → Hom D (OMap J X) (T Y) → Hom D (M X) (M Y) laweta : ∀{X} → mbind (η {X}) ≅ iden D {M X} lawbind : ∀{X Y Z} {f : Hom D (OMap J X) (T Y)}{g : Hom D (OMap J Y) (T Z)} → mbind (comp D (bind g) f) ≅ comp D (mbind g) (mbind f) -- any rel. monad is trivially a module over its J. ModJ : forall {a}{b}{c}{d}{C : Cat {a}{b}}{D : Cat {c}{d}} {J : Fun C D} (RM : RMonad J) -> Mod (trivRM J) ModJ {D = D}{J = J} RM = mod T (\ f -> bind (comp η f)) (trans (cong bind idr) law1) (trans (cong bind (trans (trans (sym ass) (cong (\ g -> comp g _) (sym law2))) ass)) law3) where open Fun J; open RMonad RM; open Cat D open import Functors.FullyFaithful open import Isomorphism -- if J is fully faithful then any suitably typed functor is a module for trivial rel monad given by J ModF : forall {a}{b}{c}{d}{C : Cat {a}{b}}{D : Cat {c}{d}} {J : Fun C D} → Full J → Faithful J → (F : Fun C D) -> Mod (trivRM J) ModF {C = C}{D = D}{J = J} P Q F = mod (OMap F) (λ f → HMap F (fst (P f))) (trans (cong (HMap F) (Q (trans (snd (P (Cat.iden D))) (sym $ fid J)))) (fid F)) (trans (cong (HMap F) (Q (trans (snd (P _)) (trans (cong₂ (Cat.comp D) (sym $ snd (P _)) (sym $ snd (P _))) (sym $ fcomp J))))) (fcomp F)) where open Fun -- any rel. monad is trivially a module over itself, 'tautalogical module' ModRM : forall {a}{b}{c}{d}{C : Cat {a}{b}}{D : Cat {c}{d}} {J : Fun C D} (RM : RMonad J) -> Mod RM ModRM RM = mod T bind law1 law3 where open RMonad RM
{ "alphanum_fraction": 0.4830311483, "avg_line_length": 36.4576271186, "ext": "agda", "hexsha": "4b7dc773e29b02dcc1d1738a7d123474c51097e7", "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": "RMonads/Modules.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": "RMonads/Modules.agda", "max_line_length": 102, "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": "RMonads/Modules.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": 749, "size": 2151 }
open import Nat open import Prelude open import List open import contexts open import core open import results-checks open import preservation module finality where finality : ∀{Δ Σ' Γ E e r k τ} → E env-final → Δ , Σ' , Γ ⊢ E → Δ , Σ' , Γ ⊢ e :: τ → E ⊢ e ⇒ r ⊣ k → r final finality E-final ctxcons (TAFix _) EFix = FFix E-final finality (EF E-fin) ctxcons (TAVar _) (EVar h) = E-fin h finality E-final ctxcons (TAApp _ ta-f ta-arg) (EAppFix {Ef = Ef} {f} {x} {ef} {r2 = r2} CF∞ h2 eval-f eval-arg eval-ef) rewrite h2 with preservation ctxcons ta-f eval-f ... | TAFix ctxcons-Ef (TAFix ta-ef) = finality (EF new-Ef+-final) new-ctxcons ta-ef eval-ef where new-ctxcons = EnvInd (EnvInd ctxcons-Ef (preservation ctxcons ta-f eval-f)) (preservation ctxcons ta-arg eval-arg) new-Ef-final : ∀{x' rx'} → (x' , rx') ∈ (Ef ,, (f , [ Ef ]fix f ⦇·λ x => ef ·⦈)) → rx' final new-Ef-final {x'} {rx'} h with ctx-split {Γ = Ef} h new-Ef-final {x'} {rx'} h | Inl (_ , x'∈Ef) with finality E-final ctxcons ta-f eval-f ... | FFix (EF Ef-fin) = Ef-fin x'∈Ef new-Ef-final {x'} {rx'} h | Inr (_ , rx'==r2) rewrite rx'==r2 = finality E-final ctxcons ta-f eval-f new-Ef+-final : ∀{x' rx'} → (x' , rx') ∈ (Ef ,, (f , [ Ef ]fix f ⦇·λ x => ef ·⦈) ,, (x , r2)) → rx' final new-Ef+-final {x'} {rx'} h with ctx-split {Γ = Ef ,, (f , [ Ef ]fix f ⦇·λ x => ef ·⦈)} h new-Ef+-final {x'} {rx'} h | Inl (_ , x'∈Ef+) = new-Ef-final x'∈Ef+ new-Ef+-final {x'} {rx'} h | Inr (_ , rx'==r2) rewrite rx'==r2 = finality E-final ctxcons ta-arg eval-arg finality E-final ctxcons (TAApp h ta-f ta-arg) (EAppUnfinished eval-f h2 eval-arg) = FAp (finality E-final ctxcons ta-f eval-f) (finality E-final ctxcons ta-arg eval-arg) h2 finality E-final ctxcons TAUnit EUnit = FUnit finality E-final ctxcons (TAPair _ ta1 ta2) (EPair eval1 eval2) = FPair (finality E-final ctxcons ta1 eval1) (finality E-final ctxcons ta2 eval2) finality E-final ctxcons (TAFst ta) (EFst eval) with finality E-final ctxcons ta eval ... | FPair fin _ = fin finality E-final ctxcons (TAFst ta) (EFstUnfinished eval ne) = FFst (finality E-final ctxcons ta eval) ne finality E-final ctxcons (TASnd ta) (ESnd eval) with finality E-final ctxcons ta eval ... | FPair _ fin = fin finality E-final ctxcons (TASnd ta) (ESndUnfinished eval ne) = FSnd (finality E-final ctxcons ta eval) ne finality E-final ctxcons (TACtor h h2 ta) (ECtor eval) = FCon (finality E-final ctxcons ta eval) finality {Σ' = Σ'} (EF E-fin) ctxcons (TACase d∈Σ'1 ta h1 h2) (EMatch {E = E} {xc = xc} {r' = r'} CF∞ form eval eval-ec) with h2 form ... | _ , _ , _ , c∈cctx1 , ta-ec with preservation ctxcons ta eval ... | TACtor {cctx = cctx} d∈Σ' c∈cctx ta-r' rewrite ctxunicity {Γ = π1 Σ'} d∈Σ'1 d∈Σ' | ctxunicity {Γ = cctx} c∈cctx1 c∈cctx = finality (EF new-E-final) (EnvInd ctxcons ta-r') ta-ec eval-ec where new-E-final : ∀{x' rx'} → (x' , rx') ∈ (E ,, (xc , r')) → rx' final new-E-final {x'} {rx'} x'∈E+ with ctx-split {Γ = E} x'∈E+ ... | Inl (_ , x'∈E) = E-fin x'∈E ... | Inr (_ , rx'==r') rewrite rx'==r' with finality (EF E-fin) ctxcons ta eval ... | FCon r'-fin = r'-fin finality E-final ctxcons (TACase h ta h2 h3) (EMatchUnfinished eval h4) = FCase (finality E-final ctxcons ta eval) h4 E-final finality E-final ctxcons (TAHole _) EHole = FHole E-final finality E-final ctxcons (TAAsrt _ _ _) (EAsrt _ _ _) = FUnit
{ "alphanum_fraction": 0.5935769657, "avg_line_length": 53.1176470588, "ext": "agda", "hexsha": "9e5b6d4e5b2ccbbdfc3a4f0a899c6c4acf2e0b21", "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": "finality.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": "finality.agda", "max_line_length": 127, "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": "finality.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": 1391, "size": 3612 }
{-# OPTIONS --no-positivity-check #-} -- Formalization of OPLSS: Computational Type Theory (Robert Harper), 2018. module CTT where open import Function using (_$_) open import Level using (Level) open import Relation.Nullary open import Relation.Nullary.Negation open import Relation.Binary open import Relation.Binary.PropositionalEquality using (_≡_; refl) open import Data.Product renaming (_×_ to _∧_) private variable ℓ : Level Deterministic : {A B : Set} (_⇒_ : REL A B ℓ) → Set ℓ Deterministic {A = A} {B = B} _⇒_ = {M : A} {M'₁ M'₂ : B} → M ⇒ M'₁ → M ⇒ M'₂ → M'₁ ≡ M'₂ record Language : Set₁ where field exp : Set _val : exp → Set _↦_ : exp → exp → Set val-↦-exclusive : {M : exp} → ¬ (M val ∧ ∃ λ M' → M ↦ M') ↦-deterministic : Deterministic _↦_ per-refl : {A : Set} {_≈_ : Rel A ℓ} {M M' : A} → IsPartialEquivalence _≈_ → M ≈ M' → M ≈ M per-refl record { sym = sym ; trans = trans } h = trans h (sym h) module MultiStep (L : Language) where open Language L data _↦*_ : exp → exp → Set where here : {M : exp} → M ↦* M step : {M M' M'' : exp} → M ↦ M' → M' ↦* M'' → M ↦* M'' ↦*-append : {M M' M'' : exp} → M ↦* M' → M' ↦* M'' → M ↦* M'' ↦*-append here M↦*M'' = M↦*M'' ↦*-append (step M↦M''' M'''↦*M') M'↦*M'' = step M↦M''' (↦*-append M'''↦*M' M'↦*M'') stepʳ : {M M' M'' : exp} → M ↦* M' → M' ↦ M'' → M ↦* M'' stepʳ M↦*M' M'↦M'' = ↦*-append M↦*M' (step M'↦M'' here) lift-principal : (f : exp → exp) → ({M M' : exp} → M ↦ M' → f M ↦ f M') → {M M' : exp} → M ↦* M' → f M ↦* f M' lift-principal f h here = here lift-principal f h (step M↦M'' M''↦*M') = step (h M↦M'') (lift-principal f h M''↦*M') record _⇓_ (M M' : exp) : Set where constructor _and_ field M↦*M' : M ↦* M' M'val : M' val step⇓ : {M M' M'' : exp} → M ↦ M' → M' ⇓ M'' → M ⇓ M'' step⇓ M↦*M' (M'↦*M'' and M''val) = step M↦*M' M'↦*M'' and M''val step*⇓ : {M M' M'' : exp} → M ↦* M' → M' ⇓ M'' → M ⇓ M'' step*⇓ M↦*M' (M'↦*M'' and M''val) = ↦*-append M↦*M' M'↦*M'' and M''val val⇓ : {M : exp} → M val → M ⇓ M val⇓ Mval = here and Mval ⇓-deterministic : Deterministic _⇓_ ⇓-deterministic (M↦*M'₁ and M'₁val) (M↦*M'₂ and M'val₂) = aux M↦*M'₁ M↦*M'₂ M'₁val M'val₂ where aux : {M : exp} {M'₁ M'₂ : exp} → M ↦* M'₁ → M ↦* M'₂ → M'₁ val → M'₂ val → M'₁ ≡ M'₂ aux here here _ _ = refl aux here (step M↦M' _) Mval _ = contradiction (Mval , -, M↦M') val-↦-exclusive aux (step M↦M' _) here _ Mval = contradiction (Mval , -, M↦M') val-↦-exclusive aux (step M↦M'₁ M'₁↦*M''₁) (step M↦M'₂ M'₂↦*M'') M''₁val M''₂val with ↦-deterministic M↦M'₁ M↦M'₂ ... | refl = aux M'₁↦*M''₁ M'₂↦*M'' M''₁val M''₂val val⇓val : {M M' : exp} → M val → M ⇓ M' → M' ≡ M val⇓val Mval M⇓M' with ⇓-deterministic (val⇓ Mval) M⇓M' ... | refl = refl module Example1 where -- Language data exp : Set where Bool : exp tt ff : exp if : exp → exp → exp → exp Nat : exp zero : exp succ : exp → exp rec : exp → (exp → exp → exp) → exp → exp _×_ : exp → exp → exp ⟨_,_⟩ : exp → exp → exp _·1 : exp → exp _·2 : exp → exp Eq : exp → exp → exp → exp refl : exp data _val : exp → Set where Bool : Bool val tt : tt val ff : ff val Nat : Nat val zero : zero val succ : {M : exp} → succ M val _×_ : {A₁ A₂ : exp} → A₁ val → A₂ val → (A₁ × A₂) val ⟨_,_⟩ : {M₁ M₂ : exp} → ⟨ M₁ , M₂ ⟩ val Eq : {A M₁ M₂ : exp} → Eq A M₁ M₂ val refl : refl val infix 3 _↦_ data _↦_ : exp → exp → Set where if/principal : {M M' M₁ M₀ : exp} → M ↦ M' → if M M₁ M₀ ↦ if M' M₁ M₀ if/tt : {M₁ M₀ : exp} → if tt M₁ M₀ ↦ M₁ if/ff : {M₁ M₀ : exp} → if ff M₁ M₀ ↦ M₀ rec/principal : ∀ {M M' M₀ M₁} → M ↦ M' → rec M₀ M₁ M ↦ rec M₀ M₁ M' rec/zero : ∀ {M₀ M₁} → rec M₀ M₁ zero ↦ M₀ rec/succ : ∀ {M M₀ M₁} → rec M₀ M₁ (succ M) ↦ M₁ M (rec M₀ M₁ M) _·1/principal : {M M' : exp} → M ↦ M' → M ·1 ↦ M' ·1 _·1 : {M₁ M₂ : exp} → ⟨ M₁ , M₂ ⟩ ·1 ↦ M₁ _·2/principal : {M M' : exp} → M ↦ M' → M ·2 ↦ M' ·2 _·2 : {M₁ M₂ : exp} → ⟨ M₁ , M₂ ⟩ ·2 ↦ M₂ ↦-deterministic : Deterministic _↦_ ↦-deterministic (if/principal h) (if/principal h') with ↦-deterministic h h' ... | refl = refl ↦-deterministic if/tt if/tt = refl ↦-deterministic if/ff if/ff = refl ↦-deterministic (rec/principal h) (rec/principal h') with ↦-deterministic h h' ... | refl = refl ↦-deterministic rec/zero rec/zero = refl ↦-deterministic rec/succ rec/succ = refl ↦-deterministic (h ·1/principal) (h' ·1/principal) with ↦-deterministic h h' ... | refl = refl ↦-deterministic _·1 _·1 = refl ↦-deterministic (h ·2/principal) (h' ·2/principal) with ↦-deterministic h h' ... | refl = refl ↦-deterministic _·2 _·2 = refl val-↦-exclusive : {M : exp} → ¬ ((M val) ∧ ∃ (_↦_ M)) val-↦-exclusive (Bool , _ , ()) val-↦-exclusive (tt , _ , ()) val-↦-exclusive (ff , _ , ()) val-↦-exclusive (_ × _ , _ , ()) val-↦-exclusive (⟨_,_⟩ , _ , ()) open MultiStep record { exp = exp ; _val = _val ; _↦_ = _↦_ ; val-↦-exclusive = val-↦-exclusive ; ↦-deterministic = ↦-deterministic } -- Type Signatures data _≐_typeᵒ : exp → exp → Set record _≐_type (A A' : exp) : Set ≐typeᵒ-sym : Symmetric _≐_typeᵒ ≐typeᵒ-trans : Transitive _≐_typeᵒ ≐typeᵒ-isPartialEquivalence : IsPartialEquivalence (_≐_typeᵒ) ≐type-sym : Symmetric _≐_type ≐type-trans : Transitive _≐_type ≐type-isPartialEquivalence : IsPartialEquivalence (_≐_type) data _∋ᵒ_≐_ : (A : exp) → exp → exp → Set record _∋_≐_ (A : exp) (M M' : exp) : Set A∋ᵒ≐-sym : {A : exp} → Symmetric (A ∋ᵒ_≐_) A∋ᵒ≐-trans : {A : exp} → Transitive (A ∋ᵒ_≐_) A∋ᵒ≐-isPartialEquivalence : (A : exp) → IsPartialEquivalence (A ∋ᵒ_≐_) A∋≐-sym : {A : exp} → Symmetric (A ∋_≐_) A∋≐-trans : {A : exp} → Transitive (A ∋_≐_) A∋≐-isPartialEquivalence : (A : exp) → IsPartialEquivalence (A ∋_≐_) lemma/moveᵒ : {A A' M₁ M₂ : exp} → A ≐ A' typeᵒ → A' ∋ᵒ M₁ ≐ M₂ → A ∋ᵒ M₁ ≐ M₂ lemma/move : {A A' M₁ M₂ : exp} → A ≐ A' type → A' ∋ M₁ ≐ M₂ → A ∋ M₁ ≐ M₂ -- Implementations data _≐_typeᵒ where Bool : Bool ≐ Bool typeᵒ Nat : Nat ≐ Nat typeᵒ _×_ : {A₁ A₁' A₂ A₂' : exp} → A₁ ≐ A₁' typeᵒ → A₂ ≐ A₂' typeᵒ → (A₁ × A₂) ≐ (A₁' × A₂') typeᵒ Eq : {A A' M₁ M₁' M₂ M₂' : exp} → A ≐ A' type → A ∋ M₁ ≐ M₁' → A ∋ M₂ ≐ M₂' → Eq A M₁ M₂ ≐ Eq A' M₁' M₂' typeᵒ _typeᵒ : exp → Set A typeᵒ = A ≐ A typeᵒ record _≐_type A A' where constructor ⇓_,⇓_,_ pattern inductive field {Aᵒ} : exp A⇓Aᵒ : A ⇓ Aᵒ {A'ᵒ} : exp A'⇓A'ᵒ : A' ⇓ A'ᵒ Aᵒ≐A'ᵒtypeᵒ : Aᵒ ≐ A'ᵒ typeᵒ _type : exp → Set A type = A ≐ A type ⇓_,⇓-,_ : {A Aᵒ : exp} (A⇓Aᵒ : A ⇓ Aᵒ) (Aᵒtypeᵒ : Aᵒ typeᵒ) → A type ⇓ A⇓Aᵒ ,⇓-, Aᵒtypeᵒ = ⇓ A⇓Aᵒ ,⇓ A⇓Aᵒ , Aᵒtypeᵒ ≐typeᵒ-sym Bool = Bool ≐typeᵒ-sym Nat = Nat ≐typeᵒ-sym (h₁ × h₂) = ≐typeᵒ-sym h₁ × ≐typeᵒ-sym h₂ ≐typeᵒ-sym (Eq h h₁ h₂) = Eq (≐type-sym h) (A∋≐-sym (lemma/move (≐type-sym h) h₁)) (A∋≐-sym (lemma/move (≐type-sym h) h₂)) ≐typeᵒ-trans Bool Bool = Bool ≐typeᵒ-trans Nat Nat = Nat ≐typeᵒ-trans (h₁ × h₂) (h₁' × h₂') = ≐typeᵒ-trans h₁ h₁' × ≐typeᵒ-trans h₂ h₂' ≐typeᵒ-trans (Eq h h₁ h₂) (Eq h' h₁' h₂') = Eq (≐type-trans h h') (A∋≐-trans h₁ (lemma/move h h₁')) (A∋≐-trans h₂ (lemma/move h h₂')) ≐typeᵒ-isPartialEquivalence = record { sym = ≐typeᵒ-sym ; trans = ≐typeᵒ-trans } ≐type-sym (⇓ A⇓Aᵒ ,⇓ A'⇓A'ᵒ , Aᵒ≐A'ᵒtypeᵒ) = ⇓ A'⇓A'ᵒ ,⇓ A⇓Aᵒ , (≐typeᵒ-sym Aᵒ≐A'ᵒtypeᵒ) ≐type-trans {A₀} {A₁} {A₂} (⇓ A₀⇓ ,⇓ A₁⇓ , Aᵒ≐A'ᵒtypeᵒ) (⇓ A₁⇓' ,⇓ A₂⇓ , Aᵒ₁≐A'ᵒ₁typeᵒ) with ⇓-deterministic A₁⇓ A₁⇓' ... | refl = ⇓ A₀⇓ ,⇓ A₂⇓ , ≐typeᵒ-trans Aᵒ≐A'ᵒtypeᵒ Aᵒ₁≐A'ᵒ₁typeᵒ ≐type-isPartialEquivalence = record { sym = ≐type-sym ; trans = ≐type-trans } typeᵒ-val : {A A' : exp} → A ≐ A' typeᵒ → A val typeᵒ-val Bool = Bool typeᵒ-val Nat = Nat typeᵒ-val (h₁ × h₂) = typeᵒ-val h₁ × typeᵒ-val h₂ typeᵒ-val (Eq h h₁ h₂) = Eq typeᵒ-val' : {A A' : exp} → A ≐ A' typeᵒ → A' val typeᵒ-val' Bool = Bool typeᵒ-val' Nat = Nat typeᵒ-val' (h₁ × h₂) = typeᵒ-val' h₁ × typeᵒ-val' h₂ typeᵒ-val' (Eq h h₁ h₂) = Eq typeᵒ-type : {A A' : exp} → A ≐ A' typeᵒ → A ≐ A' type typeᵒ-type A≐A'typeᵒ = ⇓ (val⇓ (typeᵒ-val A≐A'typeᵒ)) ,⇓ (val⇓ (typeᵒ-val' A≐A'typeᵒ)) , A≐A'typeᵒ data R/Bool : exp → exp → Set where tt : {M M' : exp} → M ⇓ tt → M' ⇓ tt → R/Bool M M' ff : {M M' : exp} → M ⇓ ff → M' ⇓ ff → R/Bool M M' R/Bool-sym : Symmetric R/Bool R/Bool-sym (tt h h') = tt h' h R/Bool-sym (ff h h') = ff h' h R/Bool-trans : Transitive R/Bool R/Bool-trans (tt h _) (tt _ h') = tt h h' R/Bool-trans (tt _ h) (ff h' _) with ⇓-deterministic h h' ... | () R/Bool-trans (ff _ h) (tt h' _) with ⇓-deterministic h h' ... | () R/Bool-trans (ff h _) (ff _ h') = ff h h' R/Bool-isPartialEquivalence : IsPartialEquivalence R/Bool R/Bool-isPartialEquivalence = record { sym = R/Bool-sym ; trans = R/Bool-trans } data R/Nat : exp → exp → Set where zero : {M M' : exp} → M ⇓ zero → M' ⇓ zero → R/Nat M M' succ : {M M' N N' : exp} → M ⇓ succ N → M' ⇓ succ N' → R/Nat N N' → R/Nat M M' R/Nat-sym : Symmetric R/Nat R/Nat-sym (zero h h') = zero h' h R/Nat-sym (succ h h' r) = succ h' h (R/Nat-sym r) R/Nat-trans : Transitive R/Nat R/Nat-trans (zero h _) (zero _ h') = zero h h' R/Nat-trans (zero _ h₁) (succ h₁' _ _) with ⇓-deterministic h₁ h₁' ... | () R/Nat-trans (succ _ h₁ _) (zero h₁' _) with ⇓-deterministic h₁ h₁' ... | () R/Nat-trans (succ h h₁ r) (succ h₁' h' r') with ⇓-deterministic h₁ h₁' ... | refl = succ h h' (R/Nat-trans r r') R/Nat-isPartialEquivalence : IsPartialEquivalence R/Nat R/Nat-isPartialEquivalence = record { sym = R/Nat-sym ; trans = R/Nat-trans } data R/Eq : exp → exp → Set where refl : {M M' : exp} → M ⇓ refl → M' ⇓ refl → R/Eq M M' R/Eq-sym : Symmetric R/Eq R/Eq-sym (refl h h') = refl h' h R/Eq-trans : Transitive R/Eq R/Eq-trans (refl h₁ h₁') (refl h₂ h₂') = refl h₁ h₂' R/Eq-isPartialEquivalence : IsPartialEquivalence R/Eq R/Eq-isPartialEquivalence = record { sym = R/Eq-sym ; trans = R/Eq-trans } data _∋ᵒ_≐_ where Bool : {M M' : exp} → R/Bool M M' → Bool ∋ᵒ M ≐ M' Nat : {M M' : exp} → R/Nat M M' → Nat ∋ᵒ M ≐ M' _×_ : {A₁ A₂ M₁ M₂ M₁' M₂' : exp} → A₁ ∋ M₁ ≐ M₁' → A₂ ∋ M₂ ≐ M₂' → (A₁ × A₂) ∋ᵒ ⟨ M₁ , M₂ ⟩ ≐ ⟨ M₁' , M₂' ⟩ Eq : {A M₁ M₂ M M' : exp} → R/Eq M M' → A ∋ M₁ ≐ M₂ → Eq A M₁ M₂ ∋ᵒ M ≐ M' _∋ᵒ_ : (A : exp) → exp → Set A ∋ᵒ M = A ∋ᵒ M ≐ M A∋ᵒ≐-sym (Bool h) = Bool (R/Bool-sym h) A∋ᵒ≐-sym (Nat h) = Nat (R/Nat-sym h) A∋ᵒ≐-sym (h₁ × h₂) = A∋≐-sym h₁ × A∋≐-sym h₂ A∋ᵒ≐-sym (Eq h h≐) = Eq (R/Eq-sym h) h≐ A∋ᵒ≐-trans (Bool h) (Bool h') = Bool (R/Bool-trans h h') A∋ᵒ≐-trans (Nat h) (Nat h') = Nat (R/Nat-trans h h') A∋ᵒ≐-trans (h₁ × h₂) (h₁' × h₂') = A∋≐-trans h₁ h₁' × A∋≐-trans h₂ h₂' A∋ᵒ≐-trans (Eq h h≐) (Eq h' h≐') = Eq (R/Eq-trans h h') h≐ A∋ᵒ≐-isPartialEquivalence A = record { sym = A∋ᵒ≐-sym ; trans = A∋ᵒ≐-trans } record _∋_≐_ A M M' where constructor ⇓_,⇓_,⇓_,_ pattern inductive field {Aᵒ} : exp A⇓Aᵒ : A ⇓ Aᵒ {Mᵒ} : exp M⇓Mᵒ : M ⇓ Mᵒ {M'ᵒ} : exp M'⇓M'ᵒ : M' ⇓ M'ᵒ Aᵒ∋ᵒMᵒ≐M'ᵒ : Aᵒ ∋ᵒ Mᵒ ≐ M'ᵒ _∋_ : (A : exp) → exp → Set A ∋ M = A ∋ M ≐ M ⇓_,⇓_,⇓-,_ : {A Aᵒ M Mᵒ : exp} (A⇓Aᵒ : A ⇓ Aᵒ) (M⇓Mᵒ : M ⇓ Mᵒ) (Aᵒ∋ᵒMᵒ : Aᵒ ∋ᵒ Mᵒ) → A ∋ M ⇓ A⇓Aᵒ ,⇓ M⇓Mᵒ ,⇓-, Aᵒ∋ᵒMᵒ = ⇓ A⇓Aᵒ ,⇓ M⇓Mᵒ ,⇓ M⇓Mᵒ , Aᵒ∋ᵒMᵒ A∋≐-sym {A} (⇓ A⇓Aᵒ ,⇓ M⇓Mᵒ ,⇓ M'⇓M'ᵒ , A∋ᵒMᵒ≐M'ᵒ) = ⇓ A⇓Aᵒ ,⇓ M'⇓M'ᵒ ,⇓ M⇓Mᵒ , A∋ᵒ≐-sym A∋ᵒMᵒ≐M'ᵒ A∋≐-trans {A} {M₀} {M₁} {M₂} (⇓ A⇓ ,⇓ M₀⇓ ,⇓ M₁⇓ , A∋ᵒMᵒ≐M'ᵒ₁) (⇓ A⇓' ,⇓ M₁⇓' ,⇓ M₂⇓ , A∋ᵒM'ᵒ₁≐M'ᵒ) with ⇓-deterministic A⇓ A⇓' | ⇓-deterministic M₁⇓ M₁⇓' ... | refl | refl = ⇓ A⇓ ,⇓ M₀⇓ ,⇓ M₂⇓ , A∋ᵒ≐-trans A∋ᵒMᵒ≐M'ᵒ₁ A∋ᵒM'ᵒ₁≐M'ᵒ A∋≐-isPartialEquivalence A = record { sym = A∋≐-sym ; trans = A∋≐-trans } -- Lemmas lemma/moveᵒ Bool A'∋ᵒM₁≐M₂ = A'∋ᵒM₁≐M₂ lemma/moveᵒ Nat A'∋ᵒM₁≐M₂ = A'∋ᵒM₁≐M₂ lemma/moveᵒ (A₁≐A₁'typeᵒ × A₂≐A₂'typeᵒ) (A₁'∋ᵒM₁≐M₁' × A₂'∋ᵒM₂≐M₂') = lemma/move (typeᵒ-type A₁≐A₁'typeᵒ) A₁'∋ᵒM₁≐M₁' × lemma/move (typeᵒ-type A₂≐A₂'typeᵒ) A₂'∋ᵒM₂≐M₂' lemma/moveᵒ (Eq A≐A'type A∋M₁≐M₁' A∋M₂≐M₂') (Eq h h≐) = Eq h (A∋≐-trans A∋M₁≐M₁' (A∋≐-trans (lemma/move A≐A'type h≐) (A∋≐-sym A∋M₂≐M₂'))) lemma/move (⇓ A⇓Aᵒ ,⇓ A'⇓A'ᵒ₁ , Aᵒ≐A'ᵒtypeᵒ) (⇓ A'⇓A'ᵒ ,⇓ M₁⇓M₁ᵒ ,⇓ M₂⇓M₂ᵒ , A'ᵒ∋ᵒM₁ᵒ≐M₂ᵒ) with ⇓-deterministic A'⇓A'ᵒ₁ A'⇓A'ᵒ ... | refl = ⇓ A⇓Aᵒ ,⇓ M₁⇓M₁ᵒ ,⇓ M₂⇓M₂ᵒ , lemma/moveᵒ Aᵒ≐A'ᵒtypeᵒ A'ᵒ∋ᵒM₁ᵒ≐M₂ᵒ rev-closure-A : {A A' M₁ M₂ : exp} → A ↦ A' → A' ∋ M₁ ≐ M₂ → A ∋ M₁ ≐ M₂ rev-closure-A A↦A' (⇓ A⇓Aᵒ ,⇓ M₁⇓M₁ᵒ ,⇓ M₂⇓M₂ᵒ , Aᵒ∋ᵒM₁ᵒ≐M₂ᵒ) = ⇓ step⇓ A↦A' A⇓Aᵒ ,⇓ M₁⇓M₁ᵒ ,⇓ M₂⇓M₂ᵒ , Aᵒ∋ᵒM₁ᵒ≐M₂ᵒ rev-closure-A* : {A A' M₁ M₂ : exp} → A ↦* A' → A' ∋ M₁ ≐ M₂ → A ∋ M₁ ≐ M₂ rev-closure-A* here A'∋M₁≐M₂ = A'∋M₁≐M₂ rev-closure-A* (step A↦A'' A''↦*A') A'∋M₁≐M₂ = rev-closure-A A↦A'' (rev-closure-A* A''↦*A' A'∋M₁≐M₂) rev-closure-M : {A M M' : exp} → M ↦ M' → A ∋ M' → A ∋ M rev-closure-M M↦M' (⇓ A⇓Aᵒ ,⇓ M'⇓Mᵒ ,⇓ M'⇓M'ᵒ , A∋ᵒMᵒ≐M'ᵒ) = ⇓ A⇓Aᵒ ,⇓ step⇓ M↦M' M'⇓Mᵒ ,⇓ step⇓ M↦M' M'⇓M'ᵒ , A∋ᵒMᵒ≐M'ᵒ rev-closure-M* : {A M M' : exp} → M ↦* M' → A ∋ M' → A ∋ M rev-closure-M* here A∋M' = A∋M' rev-closure-M* (step M↦M'' M''↦*M') A∋M' = rev-closure-M M↦M'' (rev-closure-M* M''↦*M' A∋M') rev-closure-M*₂ : {A M₁ M₁' M₂ M₂' : exp} → M₁ ↦* M₁' → M₂ ↦* M₂' → A ∋ M₁' ≐ M₂' → A ∋ M₁ ≐ M₂ rev-closure-M*₂ M₁↦*M₁' M₂↦*M₂' (⇓ A⇓Aᵒ ,⇓ M₁'⇓M₁'ᵒ ,⇓ M₂'⇓M₂'ᵒ , Aᵒ∋ᵒMᵒ≐M'ᵒ) = ⇓ A⇓Aᵒ ,⇓ ((↦*-append M₁↦*M₁' (_⇓_.M↦*M' M₁'⇓M₁'ᵒ)) and _⇓_.M'val M₁'⇓M₁'ᵒ) ,⇓ ((↦*-append M₂↦*M₂' (_⇓_.M↦*M' M₂'⇓M₂'ᵒ)) and _⇓_.M'val M₂'⇓M₂'ᵒ) , Aᵒ∋ᵒMᵒ≐M'ᵒ -- Hypotheticals _>>_ : (A : exp) → (exp → exp → Set) → Set A >> J = {a a' : exp} → A ∋ a ≐ a' → J a a' _>>_≐_type : (A : exp) (B B' : exp → exp) → Set A >> B ≐ B' type = A >> λ a a' → B a ≐ B' a' type _>>_type : (A : exp) (B : exp → exp) → Set A >> B type = A >> B ≐ B type _>>_∋_≐_ : (A : exp) (B N N' : exp → exp) → Set A >> B ∋ N ≐ N' = A >> λ a a' → B a ∋ N a ≐ N' a' _>>_∋_ : (A : exp) (B N : exp → exp) → Set A >> B ∋ N = A >> B ∋ N ≐ N -- Facts fact/if : {A M M₁ M₀ M₁' M₀' : exp} → Bool ∋ M → A ∋ M₁ → A ∋ M₀ → A ∋ if M M₁ M₀ fact/if {M₁ = M₁} {M₀ = M₀} (⇓ A⇓Aᵒ ,⇓ M⇓Mᵒ ,⇓ M'⇓M'ᵒ , Aᵒ∋ᵒMᵒ≐M'ᵒ) h₁ h₀ with val⇓val Bool A⇓Aᵒ fact/if {M₁ = M₁} {M₀ = M₀} (⇓ A⇓Aᵒ ,⇓ M⇓Mᵒ ,⇓ M'⇓M'ᵒ , Bool (tt Mᵒ⇓tt _)) h₁ h₀ | refl = let step-principal M₁ M₀ = lift-principal (λ M → if M M₁ M₀) if/principal (↦*-append (_⇓_.M↦*M' M⇓Mᵒ) (_⇓_.M↦*M' Mᵒ⇓tt)) in rev-closure-M* (stepʳ (step-principal M₁ M₀) if/tt) h₁ fact/if {M₁ = M₁} {M₀ = M₀} (⇓ A⇓Aᵒ ,⇓ M⇓Mᵒ ,⇓ M'⇓M'ᵒ , Bool (ff Mᵒ⇓ff _)) h₁ h₀ | refl = let step-principal M₁ M₀ = lift-principal (λ M → if M M₁ M₀) if/principal (↦*-append (_⇓_.M↦*M' M⇓Mᵒ) (_⇓_.M↦*M' Mᵒ⇓ff)) in rev-closure-M* (stepʳ (step-principal M₁ M₀) if/ff) h₀ fact/if' : {M A₁ A₀ M₁ M₀ : exp} → Bool ∋ M → A₁ ∋ M₁ → A₀ ∋ M₀ → if M A₁ A₀ ∋ if M M₁ M₀ fact/if' {A₁ = A₁} {A₀ = A₀} {M₁ = M₁} {M₀ = M₀} (⇓ A⇓Aᵒ ,⇓ M⇓Mᵒ ,⇓ M'⇓M'ᵒ , Aᵒ∋ᵒMᵒ≐M'ᵒ) h₁ h₀ with val⇓val Bool A⇓Aᵒ fact/if' {A₁ = A₁} {A₀ = A₀} {M₁ = M₁} {M₀ = M₀} (⇓ A⇓Aᵒ ,⇓ M⇓Mᵒ ,⇓ M'⇓M'ᵒ , Bool (tt Mᵒ⇓tt _)) h₁ h₀ | refl = let step-principal M₁ M₀ = lift-principal (λ M → if M M₁ M₀) if/principal (↦*-append (_⇓_.M↦*M' M⇓Mᵒ) (_⇓_.M↦*M' Mᵒ⇓tt)) in rev-closure-A* (stepʳ (step-principal A₁ A₀) if/tt) $ rev-closure-M* (stepʳ (step-principal M₁ M₀) if/tt) $ h₁ fact/if' {A₁ = A₁} {A₀ = A₀} {M₁ = M₁} {M₀ = M₀} (⇓ A⇓Aᵒ ,⇓ M⇓Mᵒ ,⇓ M'⇓M'ᵒ , Bool (ff Mᵒ⇓ff _)) h₁ h₀ | refl = let step-principal M₁ M₀ = lift-principal (λ M → if M M₁ M₀) if/principal (↦*-append (_⇓_.M↦*M' M⇓Mᵒ) (_⇓_.M↦*M' Mᵒ⇓ff)) in rev-closure-A* (stepʳ (step-principal A₁ A₀) if/ff) $ rev-closure-M* (stepʳ (step-principal M₁ M₀) if/ff) $ h₀ R/Nat⇒Nat∋≐ : {N N' : exp} → R/Nat N N' → Nat ∋ N ≐ N' R/Nat⇒Nat∋≐ (zero h h') = ⇓ here and Nat ,⇓ h ,⇓ h' , Nat (zero (here and _⇓_.M'val h) (here and _⇓_.M'val h')) R/Nat⇒Nat∋≐ (succ h h' r) = ⇓ here and Nat ,⇓ h ,⇓ h' , Nat (succ (here and _⇓_.M'val h) (here and _⇓_.M'val h') r) fact/rec : ∀ {B M₀ M₁ M} → Nat >> B type → B zero ∋ M₀ → Nat >> (λ a a' → B a >> λ b b' → B (succ a) ∋ M₁ a b ≐ M₁ a' b') → Nat ∋ M → B M ∋ rec M₀ M₁ M fact/rec Nat>>Btype h₀ h₁ (⇓ A⇓Aᵒ ,⇓ M⇓Mᵒ ,⇓ M⇓M'ᵒ , Aᵒ∋ᵒMᵒ≐M'ᵒ) with val⇓val Nat A⇓Aᵒ fact/rec {B} {M₀} {M₁} Nat>>Btype h₀ h₁ (⇓ A⇓Nat ,⇓ M⇓Mᵒ ,⇓ M⇓M'ᵒ , Nat r) | refl = induction (_⇓_.M↦*M' M⇓Mᵒ) r where induction : {M Mᵒ M'ᵒ : exp} → M ↦* Mᵒ → R/Nat Mᵒ M'ᵒ → B M ∋ rec M₀ M₁ M induction M↦*Mᵒ (zero Mᵒ⇓zero Mᵒ⇓zero') = let step-principal = lift-principal (rec M₀ M₁) rec/principal (↦*-append M↦*Mᵒ (_⇓_.M↦*M' Mᵒ⇓zero)) in rev-closure-M* (stepʳ step-principal rec/zero) $ lemma/move (Nat>>Btype (⇓ A⇓Nat ,⇓ step*⇓ M↦*Mᵒ Mᵒ⇓zero ,⇓ val⇓ zero , Nat (zero (val⇓ zero) (val⇓ zero)))) $ h₀ induction M↦*Mᵒ (succ Mᵒ⇓succN Mᵒ⇓succN' r) = let step-principal = lift-principal (rec M₀ M₁) rec/principal (↦*-append M↦*Mᵒ (_⇓_.M↦*M' Mᵒ⇓succN)) in rev-closure-M* (stepʳ step-principal rec/succ) $ lemma/move (Nat>>Btype (⇓ A⇓Nat ,⇓ step*⇓ M↦*Mᵒ Mᵒ⇓succN ,⇓ val⇓ succ , Nat (succ (val⇓ succ) (val⇓ succ) (per-refl R/Nat-isPartialEquivalence r)))) $ h₁ (per-refl (A∋≐-isPartialEquivalence Nat) (R/Nat⇒Nat∋≐ r)) (induction here r) fact/·1 : {A₁ A₂ M : exp} → A₁ val → A₂ val → (A₁ × A₂) ∋ M → A₁ ∋ (M ·1) fact/·1 {A₁ = A₁} A₁val A₂val (⇓ A⇓Aᵒ ,⇓ M⇓⟨M₁,M₂⟩ ,⇓ M⇓⟨M₁',M₂'⟩ , Aᵒ∋ᵒMᵒ≐M'ᵒ) with val⇓val (A₁val × A₂val) A⇓Aᵒ fact/·1 {A₁ = A₁} A₁val A₂val (⇓ A⇓Aᵒ ,⇓ M⇓⟨M₁,M₂⟩ ,⇓ M⇓⟨M₁',M₂'⟩ , (A₁∋M₁≐M₁' × A₂∋M₂≐M₂')) | refl = rev-closure-M* (stepʳ (lift-principal _·1 _·1/principal (_⇓_.M↦*M' M⇓⟨M₁,M₂⟩)) _·1) (per-refl (A∋≐-isPartialEquivalence A₁) A₁∋M₁≐M₁') fact/⟨,⟩·1 : {A₁ M₁ M₂ : exp} → A₁ ∋ M₁ → A₁ ∋ ⟨ M₁ , M₂ ⟩ ·1 ≐ M₁ fact/⟨,⟩·1 (⇓ A⇓Aᵒ ,⇓ M₁⇓Mᵒ ,⇓ M₁⇓M'ᵒ , A₁∋ᵒMᵒ≐M'ᵒ) = ⇓ A⇓Aᵒ ,⇓ step⇓ _·1 M₁⇓Mᵒ ,⇓ M₁⇓M'ᵒ , A₁∋ᵒMᵒ≐M'ᵒ fact/eq/inhabited : Eq Nat (succ zero) (succ zero) ∋ refl fact/eq/inhabited = ⇓ val⇓ Eq ,⇓ val⇓ refl ,⇓-, Eq (refl (val⇓ refl) (val⇓ refl)) ( ⇓ val⇓ Nat ,⇓ val⇓ succ ,⇓-, ( Nat (succ (val⇓ succ) (val⇓ succ) (zero (val⇓ zero) (val⇓ zero))) ) ) fact/eq/reflexive : {A M : exp} → A ∋ M → Eq A M M ∋ refl fact/eq/reflexive A∋M = ⇓ val⇓ Eq ,⇓ val⇓ refl ,⇓-, Eq (refl (val⇓ refl) (val⇓ refl)) A∋M
{ "alphanum_fraction": 0.5210020516, "avg_line_length": 39.4925373134, "ext": "agda", "hexsha": "d5f4f1635d6b842d12b3957d8851a547c8cb8c1d", "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": "b140aabd0ce35d926093dcfe0b5f18a95d757e24", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "HarrisonGrodin/computational-type-theory-2021", "max_forks_repo_path": "ctt/CTT.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b140aabd0ce35d926093dcfe0b5f18a95d757e24", "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": "HarrisonGrodin/computational-type-theory-2021", "max_issues_repo_path": "ctt/CTT.agda", "max_line_length": 169, "max_stars_count": 2, "max_stars_repo_head_hexsha": "b140aabd0ce35d926093dcfe0b5f18a95d757e24", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "HarrisonGrodin/computational-type-theory-2021", "max_stars_repo_path": "ctt/CTT.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-03T18:24:39.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-08T12:27:39.000Z", "num_tokens": 10769, "size": 18522 }
-- There was a bug where f (suc n) didn't reduce for neutral n. module Issue26 where data Nat : Set where zero : Nat suc : Nat -> Nat {-# BUILTIN NATURAL Nat #-} {-# BUILTIN ZERO zero #-} {-# BUILTIN SUC suc #-} f : Nat -> Nat f 0 = 0 f (suc n) = f n data _==_ {A : Set}(x : A) : A -> Set where refl : x == x lem : (n : Nat) -> f (suc n) == f n lem n = refl
{ "alphanum_fraction": 0.5284974093, "avg_line_length": 17.5454545455, "ext": "agda", "hexsha": "e3ae17a782ee8f889e9dc6a08f5d4582a74f999e", "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": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_path": "test/succeed/Issue26.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "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": "np/agda-git-experiment", "max_issues_repo_path": "test/succeed/Issue26.agda", "max_line_length": 63, "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/succeed/Issue26.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": 140, "size": 386 }
data D : _ where D : _
{ "alphanum_fraction": 0.5652173913, "avg_line_length": 7.6666666667, "ext": "agda", "hexsha": "0b73e4b7836da7cc0aca3b16bb39b2dafcce8b17", "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": "2fa8ede09451d43647f918dbfb24ff7b27c52edc", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "phadej/agda", "max_forks_repo_path": "test/Fail/Issue3448.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc", "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": "phadej/agda", "max_issues_repo_path": "test/Fail/Issue3448.agda", "max_line_length": 16, "max_stars_count": null, "max_stars_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "phadej/agda", "max_stars_repo_path": "test/Fail/Issue3448.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 9, "size": 23 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Automatic solvers for equations over integers ------------------------------------------------------------------------ -- See README.Integer for examples of how to use this solver {-# OPTIONS --without-K --safe #-} module Data.Integer.Solver where import Algebra.Solver.Ring.Simple as Solver import Algebra.Solver.Ring.AlmostCommutativeRing as ACR open import Data.Integer using (_≟_) open import Data.Integer.Properties using (+-*-commutativeRing) ------------------------------------------------------------------------ -- A module for automatically solving propositional equivalences -- containing _+_ and _*_ -- A module for automatically solving propositional equivalences module +-*-Solver = Solver (ACR.fromCommutativeRing +-*-commutativeRing) _≟_
{ "alphanum_fraction": 0.579793341, "avg_line_length": 34.84, "ext": "agda", "hexsha": "476d98af73533e73a56a0561bb2c7c14cff3cc1f", "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/Integer/Solver.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/Integer/Solver.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/Integer/Solver.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 155, "size": 871 }
{-# OPTIONS --allow-unsolved-metas #-} module Issue107 where data Bool : Set where true : Bool false : Bool data False : Set where record True : Set where T : Bool -> Set T false = False T _ = True foo : ((a : Bool) -> T a) -> True foo f = f _
{ "alphanum_fraction": 0.6205533597, "avg_line_length": 14.8823529412, "ext": "agda", "hexsha": "37c70cc119766e8b9438f40d442643d409ab5927", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue107.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/Succeed/Issue107.agda", "max_line_length": 38, "max_stars_count": 3, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Succeed/Issue107.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": 79, "size": 253 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.ZCohomology.Properties where open import Cubical.ZCohomology.Base open import Cubical.HITs.S1 open import Cubical.HITs.Sn open import Cubical.Foundations.HLevels open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.Prelude open import Cubical.Foundations.Pointed open import Cubical.Foundations.Transport open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Univalence open import Cubical.Data.Empty open import Cubical.Data.Sigma hiding (_×_) open import Cubical.HITs.Susp open import Cubical.HITs.Wedge open import Cubical.HITs.SetTruncation renaming (rec to sRec ; rec2 to sRec2 ; elim to sElim ; elim2 to sElim2 ; setTruncIsSet to §) open import Cubical.Data.Int renaming (_+_ to _ℤ+_) open import Cubical.Data.Nat open import Cubical.HITs.Truncation renaming (elim to trElim ; map to trMap ; rec to trRec ; elim3 to trElim3) open import Cubical.Homotopy.Loopspace open import Cubical.Homotopy.Connected open import Cubical.Homotopy.Freudenthal open import Cubical.Algebra.Group open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Data.NatMinusOne open import Cubical.HITs.Pushout open import Cubical.Data.Sum.Base open import Cubical.Data.HomotopyGroup open import Cubical.ZCohomology.KcompPrelims open Iso renaming (inv to inv') private variable ℓ ℓ' : Level A : Type ℓ B : Type ℓ' A' : Pointed ℓ infixr 34 _+ₖ_ infixr 34 _+ₕ_ is2ConnectedKn : (n : ℕ) → isConnected 2 (coHomK (suc n)) is2ConnectedKn zero = ∣ ∣ base ∣ ∣ , trElim (λ _ → isOfHLevelPath 2 (isOfHLevelTrunc 2) _ _) (trElim (λ _ → isOfHLevelPath 3 (isOfHLevelSuc 2 (isOfHLevelTrunc 2)) _ _) (toPropElim (λ _ → isOfHLevelTrunc 2 _ _) refl)) is2ConnectedKn (suc n) = ∣ ∣ north ∣ ∣ , trElim (λ _ → isOfHLevelPath 2 (isOfHLevelTrunc 2) _ _) (trElim (λ _ → isProp→isOfHLevelSuc (3 + n) (isOfHLevelTrunc 2 _ _)) (suspToPropElim (ptSn (suc n)) (λ _ → isOfHLevelTrunc 2 _ _) refl)) isConnectedKn : (n : ℕ) → isConnected (2 + n) (coHomK (suc n)) isConnectedKn n = isOfHLevelRetractFromIso 0 (invIso (truncOfTruncIso (2 + n) 1)) (sphereConnected (suc n)) -- Induction principles for cohomology groups -- If we want to show a proposition about some x : Hⁿ(A), it suffices to show it under the -- assumption that x = ∣f∣₂ and that f is pointed coHomPointedElim : {A : Type ℓ} (n : ℕ) (a : A) {B : coHom (suc n) A → Type ℓ'} → ((x : coHom (suc n) A) → isProp (B x)) → ((f : A → coHomK (suc n)) → f a ≡ coHom-pt (suc n) → B ∣ f ∣₂) → (x : coHom (suc n) A) → B x coHomPointedElim {ℓ' = ℓ'} {A = A} n a isprop indp = sElim (λ _ → isOfHLevelSuc 1 (isprop _)) λ f → helper n isprop indp f (f a) refl where helper : (n : ℕ) {B : coHom (suc n) A → Type ℓ'} → ((x : coHom (suc n) A) → isProp (B x)) → ((f : A → coHomK (suc n)) → f a ≡ coHom-pt (suc n) → B ∣ f ∣₂) → (f : A → coHomK (suc n)) → (x : coHomK (suc n)) → f a ≡ x → B ∣ f ∣₂ -- pattern matching a bit extra to avoid isOfHLevelPlus' helper zero isprop ind f = trElim (λ _ → isOfHLevelPlus {n = 1} 2 (isPropΠ λ _ → isprop _)) (toPropElim (λ _ → isPropΠ λ _ → isprop _) (ind f)) helper (suc zero) isprop ind f = trElim (λ _ → isOfHLevelPlus {n = 1} 3 (isPropΠ λ _ → isprop _)) (suspToPropElim base (λ _ → isPropΠ λ _ → isprop _) (ind f)) helper (suc (suc zero)) isprop ind f = trElim (λ _ → isOfHLevelPlus {n = 1} 4 (isPropΠ λ _ → isprop _)) (suspToPropElim north (λ _ → isPropΠ λ _ → isprop _) (ind f)) helper (suc (suc (suc n))) isprop ind f = trElim (λ _ → isOfHLevelPlus' {n = 5 + n} 1 (isPropΠ λ _ → isprop _)) (suspToPropElim north (λ _ → isPropΠ λ _ → isprop _) (ind f)) coHomPointedElim2 : {A : Type ℓ} (n : ℕ) (a : A) {B : coHom (suc n) A → coHom (suc n) A → Type ℓ'} → ((x y : coHom (suc n) A) → isProp (B x y)) → ((f g : A → coHomK (suc n)) → f a ≡ coHom-pt (suc n) → g a ≡ coHom-pt (suc n) → B ∣ f ∣₂ ∣ g ∣₂) → (x y : coHom (suc n) A) → B x y coHomPointedElim2 {ℓ' = ℓ'} {A = A} n a isprop indp = sElim2 (λ _ _ → isOfHLevelSuc 1 (isprop _ _)) λ f g → helper n a isprop indp f g (f a) (g a) refl refl where helper : (n : ℕ) (a : A) {B : coHom (suc n) A → coHom (suc n) A → Type ℓ'} → ((x y : coHom (suc n) A) → isProp (B x y)) → ((f g : A → coHomK (suc n)) → f a ≡ coHom-pt (suc n) → g a ≡ coHom-pt (suc n) → B ∣ f ∣₂ ∣ g ∣₂) → (f g : A → coHomK (suc n)) → (x y : coHomK (suc n)) → f a ≡ x → g a ≡ y → B ∣ f ∣₂ ∣ g ∣₂ helper zero a isprop indp f g = elim2 (λ _ _ → isOfHLevelPlus {n = 1} 2 (isPropΠ2 λ _ _ → isprop _ _)) (toPropElim2 (λ _ _ → isPropΠ2 λ _ _ → isprop _ _) (indp f g)) helper (suc zero) a isprop indp f g = elim2 (λ _ _ → isOfHLevelPlus {n = 1} 3 (isPropΠ2 λ _ _ → isprop _ _)) (suspToPropElim2 base (λ _ _ → isPropΠ2 λ _ _ → isprop _ _) (indp f g)) helper (suc (suc zero)) a isprop indp f g = elim2 (λ _ _ → isOfHLevelPlus {n = 1} 4 (isPropΠ2 λ _ _ → isprop _ _)) (suspToPropElim2 north (λ _ _ → isPropΠ2 λ _ _ → isprop _ _) (indp f g)) helper (suc (suc (suc n))) a isprop indp f g = elim2 (λ _ _ → isOfHLevelPlus' {n = 5 + n} 1 (isPropΠ2 λ _ _ → isprop _ _)) (suspToPropElim2 north (λ _ _ → isPropΠ2 λ _ _ → isprop _ _) (indp f g)) {- Equivalence between cohomology of A and reduced cohomology of (A + 1) -} coHomRed+1Equiv : (n : ℕ) → (A : Type ℓ) → (coHom n A) ≡ (coHomRed n ((A ⊎ Unit , inr (tt)))) coHomRed+1Equiv zero A i = ∥ helpLemma {C = (Int , pos 0)} i ∥₂ module coHomRed+1 where helpLemma : {C : Pointed ℓ} → ( (A → (typ C)) ≡ ((((A ⊎ Unit) , inr (tt)) →∙ C))) helpLemma {C = C} = isoToPath (iso map1 map2 (λ b → linvPf b) (λ _ → refl)) where map1 : (A → typ C) → ((((A ⊎ Unit) , inr (tt)) →∙ C)) map1 f = map1' , refl module helpmap where map1' : A ⊎ Unit → fst C map1' (inl x) = f x map1' (inr x) = pt C map2 : ((((A ⊎ Unit) , inr (tt)) →∙ C)) → (A → typ C) map2 (g , pf) x = g (inl x) linvPf : (b :((((A ⊎ Unit) , inr (tt)) →∙ C))) → map1 (map2 b) ≡ b linvPf (f , snd) i = (λ x → helper x i) , λ j → snd ((~ i) ∨ j) where helper : (x : A ⊎ Unit) → ((helpmap.map1') (map2 (f , snd)) x) ≡ f x helper (inl x) = refl helper (inr tt) = sym snd coHomRed+1Equiv (suc zero) A i = ∥ coHomRed+1.helpLemma A i {C = (coHomK 1 , ∣ base ∣)} i ∥₂ coHomRed+1Equiv (suc (suc n)) A i = ∥ coHomRed+1.helpLemma A i {C = (coHomK (2 + n) , ∣ north ∣)} i ∥₂ ----------- Kn→ΩKn+1 : (n : ℕ) → coHomK n → typ (Ω (coHomK-ptd (suc n))) Kn→ΩKn+1 n = Iso.fun (Iso-Kn-ΩKn+1 n) ΩKn+1→Kn : (n : ℕ) → typ (Ω (coHomK-ptd (suc n))) → coHomK n ΩKn+1→Kn n = Iso.inv (Iso-Kn-ΩKn+1 n) Kn≃ΩKn+1 : {n : ℕ} → coHomK n ≃ typ (Ω (coHomK-ptd (suc n))) Kn≃ΩKn+1 {n = n} = isoToEquiv (Iso-Kn-ΩKn+1 n) ---------- Algebra/Group stuff -------- 0ₖ : (n : ℕ) → coHomK n 0ₖ = coHom-pt _+ₖ_ : {n : ℕ} → coHomK n → coHomK n → coHomK n _+ₖ_ {n = n} x y = ΩKn+1→Kn n (Kn→ΩKn+1 n x ∙ Kn→ΩKn+1 n y) -ₖ_ : {n : ℕ} → coHomK n → coHomK n -ₖ_ {n = n} x = ΩKn+1→Kn n (sym (Kn→ΩKn+1 n x)) -- subtraction as a binary operator _-ₖ_ : {n : ℕ} → coHomK n → coHomK n → coHomK n _-ₖ_ {n = n} x y = ΩKn+1→Kn n (Kn→ΩKn+1 n x ∙ sym (Kn→ΩKn+1 n y)) +ₖ-syntax : (n : ℕ) → coHomK n → coHomK n → coHomK n +ₖ-syntax n = _+ₖ_ {n = n} -ₖ-syntax : (n : ℕ) → coHomK n → coHomK n -ₖ-syntax n = -ₖ_ {n = n} -'ₖ-syntax : (n : ℕ) → coHomK n → coHomK n → coHomK n -'ₖ-syntax n = _-ₖ_ {n = n} syntax +ₖ-syntax n x y = x +[ n ]ₖ y syntax -ₖ-syntax n x = -[ n ]ₖ x syntax -'ₖ-syntax n x y = x -[ n ]ₖ y Kn→ΩKn+10ₖ : (n : ℕ) → Kn→ΩKn+1 n (0ₖ n) ≡ refl Kn→ΩKn+10ₖ zero = sym (rUnit refl) Kn→ΩKn+10ₖ (suc zero) i j = ∣ (rCancel (merid base) i j) ∣ Kn→ΩKn+10ₖ (suc (suc n)) i j = ∣ (rCancel (merid north) i j) ∣ ΩKn+1→Kn-refl : (n : ℕ) → ΩKn+1→Kn n refl ≡ 0ₖ n ΩKn+1→Kn-refl zero = refl ΩKn+1→Kn-refl (suc zero) = refl ΩKn+1→Kn-refl (suc (suc zero)) = refl ΩKn+1→Kn-refl (suc (suc (suc zero))) = refl ΩKn+1→Kn-refl (suc (suc (suc (suc zero)))) = refl ΩKn+1→Kn-refl (suc (suc (suc (suc (suc n))))) = refl -0ₖ : {n : ℕ} → -[ n ]ₖ (0ₖ n) ≡ (0ₖ n) -0ₖ {n = n} = (λ i → ΩKn+1→Kn n (sym (Kn→ΩKn+10ₖ n i))) ∙∙ (λ i → ΩKn+1→Kn n (Kn→ΩKn+10ₖ n (~ i))) ∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 n) (0ₖ n) +ₖ→∙ : (n : ℕ) (a b : coHomK n) → Kn→ΩKn+1 n (a +[ n ]ₖ b) ≡ Kn→ΩKn+1 n a ∙ Kn→ΩKn+1 n b +ₖ→∙ n a b = Iso.rightInv (Iso-Kn-ΩKn+1 n) (Kn→ΩKn+1 n a ∙ Kn→ΩKn+1 n b) lUnitₖ : (n : ℕ) (x : coHomK n) → (0ₖ n) +[ n ]ₖ x ≡ x lUnitₖ 0 x = Iso.leftInv (Iso-Kn-ΩKn+1 zero) x lUnitₖ (suc zero) = trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) λ x → Iso.leftInv (Iso-Kn-ΩKn+1 1) ∣ x ∣ lUnitₖ (suc (suc n)) x = (λ i → ΩKn+1→Kn (2 + n) (Kn→ΩKn+10ₖ (2 + n) i ∙ Kn→ΩKn+1 (2 + n) x)) ∙∙ (cong (ΩKn+1→Kn (2 + n)) (sym (lUnit (Kn→ΩKn+1 (2 + n) x)))) ∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 (2 + n)) x rUnitₖ : (n : ℕ) (x : coHomK n) → x +[ n ]ₖ (0ₖ n) ≡ x rUnitₖ 0 x = Iso.leftInv (Iso-Kn-ΩKn+1 zero) x rUnitₖ (suc zero) = trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) λ x → Iso.leftInv (Iso-Kn-ΩKn+1 1) ∣ x ∣ rUnitₖ (suc (suc n)) x = (λ i → ΩKn+1→Kn (2 + n) (Kn→ΩKn+1 (2 + n) x ∙ Kn→ΩKn+10ₖ (2 + n) i)) ∙∙ (cong (ΩKn+1→Kn (2 + n)) (sym (rUnit (Kn→ΩKn+1 (2 + n) x)))) ∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 (2 + n)) x rCancelₖ : (n : ℕ) (x : coHomK n) → x +[ n ]ₖ (-[ n ]ₖ x) ≡ (0ₖ n) rCancelₖ zero x = (λ i → ΩKn+1→Kn 0 (Kn→ΩKn+1 zero x ∙ Iso.rightInv (Iso-Kn-ΩKn+1 zero) (sym (Kn→ΩKn+1 zero x)) i)) ∙ cong (ΩKn+1→Kn 0) (rCancel (Kn→ΩKn+1 zero x)) rCancelₖ (suc n) x = (λ i → ΩKn+1→Kn (suc n) (Kn→ΩKn+1 (1 + n) x ∙ Iso.rightInv (Iso-Kn-ΩKn+1 (1 + n)) (sym (Kn→ΩKn+1 (1 + n) x)) i)) ∙ cong (ΩKn+1→Kn (suc n)) (rCancel (Kn→ΩKn+1 (1 + n) x)) ∙ (λ i → ΩKn+1→Kn (suc n) (Kn→ΩKn+10ₖ (suc n) (~ i))) ∙ Iso.leftInv (Iso-Kn-ΩKn+1 (suc n)) (0ₖ (suc n)) lCancelₖ : (n : ℕ) (x : coHomK n) → (-[ n ]ₖ x) +[ n ]ₖ x ≡ (0ₖ n) lCancelₖ 0 x = (λ i → ΩKn+1→Kn 0 (Iso.rightInv (Iso-Kn-ΩKn+1 zero) (sym (Kn→ΩKn+1 zero x)) i ∙ Kn→ΩKn+1 zero x)) ∙ cong (ΩKn+1→Kn 0) (lCancel (Kn→ΩKn+1 zero x)) lCancelₖ (suc n) x = (λ i → ΩKn+1→Kn (suc n) (Iso.rightInv (Iso-Kn-ΩKn+1 (1 + n)) (sym (Kn→ΩKn+1 (1 + n) x)) i ∙ Kn→ΩKn+1 (1 + n) x)) ∙ cong (ΩKn+1→Kn (suc n)) (lCancel (Kn→ΩKn+1 (1 + n) x)) ∙ (λ i → (ΩKn+1→Kn (suc n)) (Kn→ΩKn+10ₖ (suc n) (~ i))) ∙ Iso.leftInv (Iso-Kn-ΩKn+1 (suc n)) (0ₖ (suc n)) assocₖ : (n : ℕ) (x y z : coHomK n) → ((x +[ n ]ₖ y) +[ n ]ₖ z) ≡ (x +[ n ]ₖ (y +[ n ]ₖ z)) assocₖ n x y z = ((λ i → ΩKn+1→Kn n (Kn→ΩKn+1 n (ΩKn+1→Kn n (Kn→ΩKn+1 n x ∙ Kn→ΩKn+1 n y)) ∙ Kn→ΩKn+1 n z)) ∙∙ (λ i → ΩKn+1→Kn n (Iso.rightInv (Iso-Kn-ΩKn+1 n) (Kn→ΩKn+1 n x ∙ Kn→ΩKn+1 n y) i ∙ Kn→ΩKn+1 n z)) ∙∙ (λ i → ΩKn+1→Kn n (assoc (Kn→ΩKn+1 n x) (Kn→ΩKn+1 n y) (Kn→ΩKn+1 n z) (~ i)))) ∙ (λ i → ΩKn+1→Kn n ((Kn→ΩKn+1 n x) ∙ Iso.rightInv (Iso-Kn-ΩKn+1 n) ((Kn→ΩKn+1 n y ∙ Kn→ΩKn+1 n z)) (~ i))) cancelₖ : (n : ℕ) (x : coHomK n) → x -[ n ]ₖ x ≡ (0ₖ n) cancelₖ zero x = cong (ΩKn+1→Kn 0) (rCancel (Kn→ΩKn+1 zero x)) cancelₖ (suc zero) x = cong (ΩKn+1→Kn 1) (rCancel (Kn→ΩKn+1 1 x)) cancelₖ (suc (suc zero)) x = cong (ΩKn+1→Kn 2) (rCancel (Kn→ΩKn+1 2 x)) cancelₖ (suc (suc (suc zero))) x = cong (ΩKn+1→Kn 3) (rCancel (Kn→ΩKn+1 3 x)) cancelₖ (suc (suc (suc (suc zero)))) x = cong (ΩKn+1→Kn 4) (rCancel (Kn→ΩKn+1 4 x)) cancelₖ (suc (suc (suc (suc (suc n))))) x = cong (ΩKn+1→Kn (5 + n)) (rCancel (Kn→ΩKn+1 (5 + n) x)) -rUnitₖ : (n : ℕ) (x : coHomK n) → x -[ n ]ₖ 0ₖ n ≡ x -rUnitₖ zero x = rUnitₖ zero x -rUnitₖ (suc n) x = cong (λ y → ΩKn+1→Kn (suc n) (Kn→ΩKn+1 (suc n) x ∙ sym y)) (Kn→ΩKn+10ₖ (suc n)) ∙∙ cong (ΩKn+1→Kn (suc n)) (sym (rUnit (Kn→ΩKn+1 (suc n) x))) ∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 (suc n)) x isComm∙ : ∀ {ℓ} (A : Pointed ℓ) → Type ℓ isComm∙ A = (p q : typ (Ω A)) → p ∙ q ≡ q ∙ p abstract isCommA→isCommTrunc : ∀ {ℓ} {A : Pointed ℓ} (n : ℕ) → isComm∙ A → isOfHLevel (suc n) (typ A) → isComm∙ (∥ typ A ∥ (suc n) , ∣ pt A ∣) isCommA→isCommTrunc {A = (A , a)} n comm hlev p q = ((λ i j → (Iso.leftInv (truncIdempotentIso (suc n) hlev) ((p ∙ q) j) (~ i))) ∙∙ (λ i → cong {B = λ _ → ∥ A ∥ (suc n) } (λ x → ∣ x ∣) (cong (trRec hlev (λ x → x)) (p ∙ q))) ∙∙ (λ i → cong {B = λ _ → ∥ A ∥ (suc n) } (λ x → ∣ x ∣) (congFunct {A = ∥ A ∥ (suc n)} {B = A} (trRec hlev (λ x → x)) p q i))) ∙ ((λ i → cong {B = λ _ → ∥ A ∥ (suc n) } (λ x → ∣ x ∣) (comm (cong (trRec hlev (λ x → x)) p) (cong (trRec hlev (λ x → x)) q) i)) ∙∙ (λ i → cong {B = λ _ → ∥ A ∥ (suc n) } (λ x → ∣ x ∣) (congFunct {A = ∥ A ∥ (suc n)} {B = A} (trRec hlev (λ x → x)) q p (~ i))) ∙∙ (λ i j → (Iso.leftInv (truncIdempotentIso (suc n) hlev) ((q ∙ p) j) i))) isCommΩK1 : (n : ℕ) → isComm∙ ((Ω^ n) (coHomK-ptd 1)) isCommΩK1 zero = isCommA→isCommTrunc 2 comm-ΩS¹ isGroupoidS¹ isCommΩK1 (suc n) = Eckmann-Hilton n open Iso renaming (inv to inv') ptdIso→comm : ∀ {ℓ ℓ'} {A : Pointed ℓ} {B : Type ℓ'} (e : Iso (typ A) B) → isComm∙ A → isComm∙ (B , Iso.fun e (pt A)) ptdIso→comm {A = (A , a)} {B = B} e comm p q = sym (rightInv (congIso e) (p ∙ q)) ∙∙ (cong (fun (congIso e)) ((invCongFunct e p q) ∙∙ (comm (inv' (congIso e) p) (inv' (congIso e) q)) ∙∙ (sym (invCongFunct e q p)))) ∙∙ rightInv (congIso e) (q ∙ p) isCommΩK : (n : ℕ) → isComm∙ (coHomK-ptd n) isCommΩK zero p q = isSetInt _ _ (p ∙ q) (q ∙ p) isCommΩK (suc zero) = isCommA→isCommTrunc 2 comm-ΩS¹ isGroupoidS¹ isCommΩK (suc (suc n)) = subst isComm∙ (λ i → coHomK (2 + n) , ΩKn+1→Kn-refl (2 + n) i) (ptdIso→comm {A = (_ , _)} (invIso (Iso-Kn-ΩKn+1 (2 + n))) (Eckmann-Hilton 0)) commₖ : (n : ℕ) (x y : coHomK n) → (x +[ n ]ₖ y) ≡ (y +[ n ]ₖ x) commₖ 0 x y i = ΩKn+1→Kn 0 (isCommΩK1 0 (Kn→ΩKn+1 0 x) (Kn→ΩKn+1 0 y) i) commₖ 1 x y i = ΩKn+1→Kn 1 (ptdIso→comm {A = ((∣ north ∣ ≡ ∣ north ∣) , snd ((Ω^ 1) (coHomK 3 , ∣ north ∣)))} {B = coHomK 2} (invIso (Iso-Kn-ΩKn+1 2)) (Eckmann-Hilton 0) (Kn→ΩKn+1 1 x) (Kn→ΩKn+1 1 y) i) commₖ 2 x y i = ΩKn+1→Kn 2 (ptdIso→comm {A = (∣ north ∣ ≡ ∣ north ∣) , snd ((Ω^ 1) (coHomK 4 , ∣ north ∣))} {B = coHomK 3} (invIso (Iso-Kn-ΩKn+1 3)) (Eckmann-Hilton 0) (Kn→ΩKn+1 2 x) (Kn→ΩKn+1 2 y) i) commₖ 3 x y i = ΩKn+1→Kn 3 (ptdIso→comm {A = (∣ north ∣ ≡ ∣ north ∣) , snd ((Ω^ 1) (coHomK 5 , ∣ north ∣))} {B = coHomK 4} (invIso (Iso-Kn-ΩKn+1 4)) (Eckmann-Hilton 0) (Kn→ΩKn+1 3 x) (Kn→ΩKn+1 3 y) i) commₖ (suc (suc (suc (suc n)))) x y i = ΩKn+1→Kn (4 + n) (ptdIso→comm {A = (∣ north ∣ ≡ ∣ north ∣) , snd ((Ω^ 1) (coHomK (6 + n) , ∣ north ∣))} {B = coHomK (5 + n)} (invIso (Iso-Kn-ΩKn+1 (5 + n))) (Eckmann-Hilton 0) (Kn→ΩKn+1 (4 + n) x) (Kn→ΩKn+1 (4 + n) y) i) rUnitₖ' : (n : ℕ) (x : coHomK n) → x +[ n ]ₖ (0ₖ n) ≡ x rUnitₖ' n x = commₖ n x (0ₖ n) ∙ lUnitₖ n x -distrₖ : (n : ℕ) (x y : coHomK n) → -[ n ]ₖ (x +[ n ]ₖ y) ≡ (-[ n ]ₖ x) +[ n ]ₖ (-[ n ]ₖ y) -distrₖ n x y = ((λ i → ΩKn+1→Kn n (sym (Kn→ΩKn+1 n (ΩKn+1→Kn n (Kn→ΩKn+1 n x ∙ Kn→ΩKn+1 n y))))) ∙∙ (λ i → ΩKn+1→Kn n (sym (Iso.rightInv (Iso-Kn-ΩKn+1 n) (Kn→ΩKn+1 n x ∙ Kn→ΩKn+1 n y) i))) ∙∙ (λ i → ΩKn+1→Kn n (symDistr (Kn→ΩKn+1 n x) (Kn→ΩKn+1 n y) i))) ∙∙ (λ i → ΩKn+1→Kn n (Iso.rightInv (Iso-Kn-ΩKn+1 n) (sym (Kn→ΩKn+1 n y)) (~ i) ∙ (Iso.rightInv (Iso-Kn-ΩKn+1 n) (sym (Kn→ΩKn+1 n x)) (~ i)))) ∙∙ commₖ n (-[ n ]ₖ y) (-[ n ]ₖ x) private rCancelLem : (n : ℕ) (x : coHomK n) → ΩKn+1→Kn n ((Kn→ΩKn+1 n x) ∙ refl) ≡ ΩKn+1→Kn n (Kn→ΩKn+1 n x) rCancelLem zero x = refl rCancelLem (suc n) x = cong (ΩKn+1→Kn (suc n)) (sym (rUnit (Kn→ΩKn+1 (suc n) x))) lCancelLem : (n : ℕ) (x : coHomK n) → ΩKn+1→Kn n (refl ∙ (Kn→ΩKn+1 n x)) ≡ ΩKn+1→Kn n (Kn→ΩKn+1 n x) lCancelLem zero x = refl lCancelLem (suc n) x = cong (ΩKn+1→Kn (suc n)) (sym (lUnit (Kn→ΩKn+1 (suc n) x))) -cancelRₖ : (n : ℕ) (x y : coHomK n) → (y +[ n ]ₖ x) -[ n ]ₖ x ≡ y -cancelRₖ n x y = (cong (ΩKn+1→Kn n) ((cong (_∙ sym (Kn→ΩKn+1 n x)) (+ₖ→∙ n y x)) ∙∙ sym (assoc _ _ _) ∙∙ cong (Kn→ΩKn+1 n y ∙_) (rCancel _))) ∙∙ rCancelLem n y ∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 n) y -cancelLₖ : (n : ℕ) (x y : coHomK n) → (x +[ n ]ₖ y) -[ n ]ₖ x ≡ y -cancelLₖ n x y = cong (λ z → z -[ n ]ₖ x) (commₖ n x y) ∙ -cancelRₖ n x y -+cancelₖ : (n : ℕ) (x y : coHomK n) → (x -[ n ]ₖ y) +[ n ]ₖ y ≡ x -+cancelₖ n x y = (cong (ΩKn+1→Kn n) ((cong (_∙ (Kn→ΩKn+1 n y)) (Iso.rightInv (Iso-Kn-ΩKn+1 n) (Kn→ΩKn+1 n x ∙ sym (Kn→ΩKn+1 n y)))) ∙∙ sym (assoc _ _ _) ∙∙ cong (Kn→ΩKn+1 n x ∙_) (lCancel _))) ∙∙ rCancelLem n x ∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 n) x ---- Group structure of cohomology groups --- _+ₕ_ : {n : ℕ} → coHom n A → coHom n A → coHom n A _+ₕ_ {n = n} = sRec2 § λ a b → ∣ (λ x → a x +[ n ]ₖ b x) ∣₂ -ₕ_ : {n : ℕ} → coHom n A → coHom n A -ₕ_ {n = n} = sRec § λ a → ∣ (λ x → -[ n ]ₖ a x) ∣₂ _-ₕ_ : {n : ℕ} → coHom n A → coHom n A → coHom n A _-ₕ_ {n = n} = sRec2 § λ a b → ∣ (λ x → a x -[ n ]ₖ b x) ∣₂ +ₕ-syntax : (n : ℕ) → coHom n A → coHom n A → coHom n A +ₕ-syntax n = _+ₕ_ {n = n} -ₕ-syntax : (n : ℕ) → coHom n A → coHom n A -ₕ-syntax n = -ₕ_ {n = n} -ₕ'-syntax : (n : ℕ) → coHom n A → coHom n A → coHom n A -ₕ'-syntax n = _-ₕ_ {n = n} syntax +ₕ-syntax n x y = x +[ n ]ₕ y syntax -ₕ-syntax n x = -[ n ]ₕ x syntax -ₕ'-syntax n x y = x -[ n ]ₕ y 0ₕ : (n : ℕ) → coHom n A 0ₕ n = ∣ (λ _ → (0ₖ n)) ∣₂ rUnitₕ : (n : ℕ) (x : coHom n A) → x +[ n ]ₕ (0ₕ n) ≡ x rUnitₕ n = sElim (λ _ → isOfHLevelPath 1 (§ _ _)) λ a i → ∣ funExt (λ x → rUnitₖ n (a x)) i ∣₂ lUnitₕ : (n : ℕ) (x : coHom n A) → (0ₕ n) +[ n ]ₕ x ≡ x lUnitₕ n = sElim (λ _ → isOfHLevelPath 1 (§ _ _)) λ a i → ∣ funExt (λ x → lUnitₖ n (a x)) i ∣₂ rCancelₕ : (n : ℕ) (x : coHom n A) → x +[ n ]ₕ (-[ n ]ₕ x) ≡ 0ₕ n rCancelₕ n = sElim (λ _ → isOfHLevelPath 1 (§ _ _)) λ a i → ∣ funExt (λ x → rCancelₖ n (a x)) i ∣₂ lCancelₕ : (n : ℕ) (x : coHom n A) → (-[ n ]ₕ x) +[ n ]ₕ x ≡ 0ₕ n lCancelₕ n = sElim (λ _ → isOfHLevelPath 1 (§ _ _)) λ a i → ∣ funExt (λ x → lCancelₖ n (a x)) i ∣₂ assocₕ : (n : ℕ) (x y z : coHom n A) → ((x +[ n ]ₕ y) +[ n ]ₕ z) ≡ (x +[ n ]ₕ (y +[ n ]ₕ z)) assocₕ n = elim3 (λ _ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b c i → ∣ funExt (λ x → assocₖ n (a x) (b x) (c x)) i ∣₂ commₕ : (n : ℕ) (x y : coHom n A) → (x +[ n ]ₕ y) ≡ (y +[ n ]ₕ x) commₕ n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b i → ∣ funExt (λ x → commₖ n (a x) (b x)) i ∣₂ cancelₕ : (n : ℕ) (x : coHom n A) → x -[ n ]ₕ x ≡ 0ₕ n cancelₕ n = sElim (λ _ → isOfHLevelPath 1 (§ _ _)) λ a i → ∣ funExt (λ x → cancelₖ n (a x)) i ∣₂ -ₖ-ₖ : (n : ℕ) (x : coHomK n) → (-[ n ]ₖ (-[ n ]ₖ x)) ≡ x -ₖ-ₖ n x = cong ((ΩKn+1→Kn n) ∘ sym) (Iso.rightInv (Iso-Kn-ΩKn+1 n) (sym (Kn→ΩKn+1 n x))) ∙ Iso.leftInv (Iso-Kn-ΩKn+1 n) x -- Proof that rUnitₖ and lUnitₖ agree on 0ₖ. Needed for Mayer-Vietoris. private rUnitlUnitGen : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} {b : B} (e : Iso A (b ≡ b)) (0A : A) (0fun : fun e 0A ≡ refl) → Path (inv' e (fun e 0A ∙ fun e 0A) ≡ 0A) (cong (inv' e) (cong (_∙ fun e 0A) 0fun) ∙∙ cong (inv' e) (sym (lUnit (fun e 0A))) ∙∙ Iso.leftInv e 0A) (cong (inv' e) (cong (fun e 0A ∙_) 0fun) ∙∙ cong (inv' e) (sym (rUnit (fun e 0A))) ∙∙ Iso.leftInv e 0A) rUnitlUnitGen e 0A 0fun = (λ i → cong (inv' e) (cong (_∙ fun e 0A) 0fun) ∙∙ rUnit (cong (inv' e) (sym (lUnit (fun e 0A)))) i ∙∙ Iso.leftInv e 0A) ∙ ((λ i → (λ j → inv' e (0fun (~ i ∧ j) ∙ 0fun (j ∧ i))) ∙∙ ((λ j → inv' e (0fun (~ i ∨ j) ∙ 0fun i)) ∙∙ cong (inv' e) (sym (lUnit (0fun i))) ∙∙ λ j → inv' e (0fun (i ∧ (~ j)))) ∙∙ Iso.leftInv e 0A) ∙∙ (λ i → (λ j → inv' e (fun e 0A ∙ 0fun j)) ∙∙ (λ j → inv' e (0fun (j ∧ ~ i) ∙ refl)) ∙∙ cong (inv' e) (sym (rUnit (0fun (~ i)))) ∙∙ (λ j → inv' e (0fun (~ i ∧ ~ j))) ∙∙ Iso.leftInv e 0A) ∙∙ λ i → cong (inv' e) (cong (fun e 0A ∙_) 0fun) ∙∙ rUnit (cong (inv' e) (sym (rUnit (fun e 0A)))) (~ i) ∙∙ Iso.leftInv e 0A) rUnitlUnit0 : (n : ℕ) → rUnitₖ n (0ₖ n) ≡ lUnitₖ n (0ₖ n) rUnitlUnit0 0 = refl rUnitlUnit0 (suc zero) = refl rUnitlUnit0 (suc (suc n)) = sym (rUnitlUnitGen (Iso-Kn-ΩKn+1 (2 + n)) (0ₖ (2 + n)) (Kn→ΩKn+10ₖ (2 + n))) -cancelLₕ : (n : ℕ) (x y : coHom n A) → (x +[ n ]ₕ y) -[ n ]ₕ x ≡ y -cancelLₕ n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b i → ∣ (λ x → -cancelLₖ n (a x) (b x) i) ∣₂ -cancelRₕ : (n : ℕ) (x y : coHom n A) → (y +[ n ]ₕ x) -[ n ]ₕ x ≡ y -cancelRₕ n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b i → ∣ (λ x → -cancelRₖ n (a x) (b x) i) ∣₂ -+cancelₕ : (n : ℕ) (x y : coHom n A) → (x -[ n ]ₕ y) +[ n ]ₕ y ≡ x -+cancelₕ n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b i → ∣ (λ x → -+cancelₖ n (a x) (b x) i) ∣₂ -- Group structure of reduced cohomology groups (in progress - might need K to compute properly first) --- +ₕ∙ : {A : Pointed ℓ} (n : ℕ) → coHomRed n A → coHomRed n A → coHomRed n A +ₕ∙ zero = sRec2 § λ { (a , pa) (b , pb) → ∣ (λ x → a x +[ zero ]ₖ b x) , (λ i → (pa i +[ zero ]ₖ pb i)) ∣₂ } +ₕ∙ (suc zero) = sRec2 § λ { (a , pa) (b , pb) → ∣ (λ x → a x +[ 1 ]ₖ b x) , (λ i → pa i +[ 1 ]ₖ pb i) ∙ lUnitₖ 1 (0ₖ 1) ∣₂ } +ₕ∙ (suc (suc n)) = sRec2 § λ { (a , pa) (b , pb) → ∣ (λ x → a x +[ (2 + n) ]ₖ b x) , (λ i → pa i +[ (2 + n) ]ₖ pb i) ∙ lUnitₖ (2 + n) (0ₖ (2 + n)) ∣₂ } open IsSemigroup open IsMonoid open GroupStr open GroupHom coHomGr : ∀ {ℓ} (n : ℕ) (A : Type ℓ) → Group {ℓ} coHomGr n A = coHom n A , coHomGrnA where coHomGrnA : GroupStr (coHom n A) 0g coHomGrnA = 0ₕ n GroupStr._+_ coHomGrnA = λ x y → x +[ n ]ₕ y - coHomGrnA = λ x → -[ n ]ₕ x isGroup coHomGrnA = helper where abstract helper : IsGroup (0ₕ n) (λ x y → x +[ n ]ₕ y) (λ x → -[ n ]ₕ x) helper = makeIsGroup § (λ x y z → sym (assocₕ n x y z)) (rUnitₕ n) (lUnitₕ n) (rCancelₕ n) (lCancelₕ n) ×coHomGr : (n : ℕ) (A : Type ℓ) (B : Type ℓ') → Group ×coHomGr n A B = dirProd (coHomGr n A) (coHomGr n B) coHomFun : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (n : ℕ) (f : A → B) → coHom n B → coHom n A coHomFun n f = sRec § λ β → ∣ β ∘ f ∣₂ -distrLemma : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (n m : ℕ) (f : GroupHom (coHomGr n A) (coHomGr m B)) (x y : coHom n A) → fun f (x -[ n ]ₕ y) ≡ fun f x -[ m ]ₕ fun f y -distrLemma n m f' x y = sym (-cancelRₕ m (f y) (f (x -[ n ]ₕ y))) ∙∙ cong (λ x → x -[ m ]ₕ f y) (sym (isHom f' (x -[ n ]ₕ y) y)) ∙∙ cong (λ x → x -[ m ]ₕ f y) ( cong f (-+cancelₕ n _ _)) where f = fun f' --- the loopspace of Kₙ is commutative regardless of base addIso : (n : ℕ) (x : coHomK n) → Iso (coHomK n) (coHomK n) fun (addIso n x) y = y +[ n ]ₖ x inv' (addIso n x) y = y -[ n ]ₖ x rightInv (addIso n x) y = -+cancelₖ n y x leftInv (addIso n x) y = -cancelRₖ n x y isCommΩK-based : (n : ℕ) (x : coHomK n) → isComm∙ (coHomK n , x) isCommΩK-based zero x p q = isSetInt _ _ (p ∙ q) (q ∙ p) isCommΩK-based (suc zero) x = subst isComm∙ (λ i → coHomK 1 , lUnitₖ 1 x i) (ptdIso→comm {A = (_ , 0ₖ 1)} (addIso 1 x) (isCommΩK 1)) isCommΩK-based (suc (suc n)) x = subst isComm∙ (λ i → coHomK (suc (suc n)) , lUnitₖ (suc (suc n)) x i) (ptdIso→comm {A = (_ , 0ₖ (suc (suc n)))} (addIso (suc (suc n)) x) (isCommΩK (suc (suc n)))) addLemma : (a b : Int) → a +[ 0 ]ₖ b ≡ (a ℤ+ b) addLemma a b = (cong (ΩKn+1→Kn 0) (sym (congFunct ∣_∣ (intLoop a) (intLoop b)))) ∙∙ (λ i → ΩKn+1→Kn 0 (cong ∣_∣ (intLoop-hom a b i))) ∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 0) (a ℤ+ b) --- -- hidden versions of cohom stuff using the "lock" hack. The locked versions can be used when proving things. -- Swapping "key" for "tt*" will then give computing functions. Unit' : Type₀ Unit' = lockUnit {ℓ-zero} lock : ∀ {ℓ} {A : Type ℓ} → Unit' → A → A lock unlock = λ x → x module lockedCohom (key : Unit') where +K : (n : ℕ) → coHomK n → coHomK n → coHomK n +K n = lock key (_+ₖ_ {n = n}) -K : (n : ℕ) → coHomK n → coHomK n -K n = lock key (-ₖ_ {n = n}) -Kbin : (n : ℕ) → coHomK n → coHomK n → coHomK n -Kbin n = lock key (_-ₖ_ {n = n}) rUnitK : (n : ℕ) (x : coHomK n) → +K n x (0ₖ n) ≡ x rUnitK n x = pm key where pm : (t : Unit') → lock t (_+ₖ_ {n = n}) x (0ₖ n) ≡ x pm unlock = rUnitₖ n x lUnitK : (n : ℕ) (x : coHomK n) → +K n (0ₖ n) x ≡ x lUnitK n x = pm key where pm : (t : Unit') → lock t (_+ₖ_ {n = n}) (0ₖ n) x ≡ x pm unlock = lUnitₖ n x rCancelK : (n : ℕ) (x : coHomK n) → +K n x (-K n x) ≡ 0ₖ n rCancelK n x = pm key where pm : (t : Unit') → lock t (_+ₖ_ {n = n}) x (lock t (-ₖ_ {n = n}) x) ≡ 0ₖ n pm unlock = rCancelₖ n x lCancelK : (n : ℕ) (x : coHomK n) → +K n (-K n x) x ≡ 0ₖ n lCancelK n x = pm key where pm : (t : Unit') → lock t (_+ₖ_ {n = n}) (lock t (-ₖ_ {n = n}) x) x ≡ 0ₖ n pm unlock = lCancelₖ n x -cancelRK : (n : ℕ) (x y : coHomK n) → -Kbin n (+K n y x) x ≡ y -cancelRK n x y = pm key where pm : (t : Unit') → lock t (_-ₖ_ {n = n}) (lock t (_+ₖ_ {n = n}) y x) x ≡ y pm unlock = -cancelRₖ n x y -cancelLK : (n : ℕ) (x y : coHomK n) → -Kbin n (+K n x y) x ≡ y -cancelLK n x y = pm key where pm : (t : Unit') → lock t (_-ₖ_ {n = n}) (lock t (_+ₖ_ {n = n}) x y) x ≡ y pm unlock = -cancelLₖ n x y -+cancelK : (n : ℕ) (x y : coHomK n) → +K n (-Kbin n x y) y ≡ x -+cancelK n x y = pm key where pm : (t : Unit') → lock t (_+ₖ_ {n = n}) (lock t (_-ₖ_ {n = n}) x y) y ≡ x pm unlock = -+cancelₖ n x y cancelK : (n : ℕ) (x : coHomK n) → -Kbin n x x ≡ 0ₖ n cancelK n x = pm key where pm : (t : Unit') → (lock t (_-ₖ_ {n = n}) x x) ≡ 0ₖ n pm unlock = cancelₖ n x assocK : (n : ℕ) (x y z : coHomK n) → +K n (+K n x y) z ≡ +K n x (+K n y z) assocK n x y z = pm key where pm : (t : Unit') → lock t (_+ₖ_ {n = n}) (lock t (_+ₖ_ {n = n}) x y) z ≡ lock t (_+ₖ_ {n = n}) x (lock t (_+ₖ_ {n = n}) y z) pm unlock = assocₖ n x y z commK : (n : ℕ) (x y : coHomK n) → +K n x y ≡ +K n y x commK n x y = pm key where pm : (t : Unit') → lock t (_+ₖ_ {n = n}) x y ≡ lock t (_+ₖ_ {n = n}) y x pm unlock = commₖ n x y -- cohom +H : (n : ℕ) (x y : coHom n A) → coHom n A +H n = sRec2 § λ a b → ∣ (λ x → +K n (a x) (b x)) ∣₂ -H : (n : ℕ) (x : coHom n A) → coHom n A -H n = sRec § λ a → ∣ (λ x → -K n (a x)) ∣₂ -Hbin : (n : ℕ) → coHom n A → coHom n A → coHom n A -Hbin n = sRec2 § λ a b → ∣ (λ x → -Kbin n (a x) (b x)) ∣₂ rUnitH : (n : ℕ) (x : coHom n A) → +H n x (0ₕ n) ≡ x rUnitH n = sElim (λ _ → isOfHLevelPath 1 (§ _ _)) λ a i → ∣ funExt (λ x → rUnitK n (a x)) i ∣₂ lUnitH : (n : ℕ) (x : coHom n A) → +H n (0ₕ n) x ≡ x lUnitH n = sElim (λ _ → isOfHLevelPath 1 (§ _ _)) λ a i → ∣ funExt (λ x → lUnitK n (a x)) i ∣₂ rCancelH : (n : ℕ) (x : coHom n A) → +H n x (-H n x) ≡ 0ₕ n rCancelH n = sElim (λ _ → isOfHLevelPath 1 (§ _ _)) λ a i → ∣ funExt (λ x → rCancelK n (a x)) i ∣₂ lCancelH : (n : ℕ) (x : coHom n A) → +H n (-H n x) x ≡ 0ₕ n lCancelH n = sElim (λ _ → isOfHLevelPath 1 (§ _ _)) λ a i → ∣ funExt (λ x → lCancelK n (a x)) i ∣₂ assocH : (n : ℕ) (x y z : coHom n A) → (+H n (+H n x y) z) ≡ (+H n x (+H n y z)) assocH n = elim3 (λ _ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b c i → ∣ funExt (λ x → assocK n (a x) (b x) (c x)) i ∣₂ commH : (n : ℕ) (x y : coHom n A) → (+H n x y) ≡ (+H n y x) commH n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b i → ∣ funExt (λ x → commK n (a x) (b x)) i ∣₂ -cancelRH : (n : ℕ) (x y : coHom n A) → -Hbin n (+H n y x) x ≡ y -cancelRH n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b i → ∣ (λ x → -cancelRK n (a x) (b x) i) ∣₂ -cancelLH : (n : ℕ) (x y : coHom n A) → -Hbin n (+H n x y) x ≡ y -cancelLH n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b i → ∣ (λ x → -cancelLK n (a x) (b x) i) ∣₂ -+cancelH : (n : ℕ) (x y : coHom n A) → +H n (-Hbin n x y) y ≡ x -+cancelH n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b i → ∣ (λ x → -+cancelK n (a x) (b x) i) ∣₂ +K→∙ : (key : Unit') (n : ℕ) (a b : coHomK n) → Kn→ΩKn+1 n (lockedCohom.+K key n a b) ≡ Kn→ΩKn+1 n a ∙ Kn→ΩKn+1 n b +K→∙ unlock = +ₖ→∙ +H≡+ₕ : (key : Unit') (n : ℕ) → lockedCohom.+H key {A = A} n ≡ _+ₕ_ {n = n} +H≡+ₕ unlock _ = refl rUnitlUnit0K : (key : Unit') (n : ℕ) → lockedCohom.rUnitK key n (0ₖ n) ≡ lockedCohom.lUnitK key n (0ₖ n) rUnitlUnit0K unlock = rUnitlUnit0
{ "alphanum_fraction": 0.4939441811, "avg_line_length": 46.6012269939, "ext": "agda", "hexsha": "22953af969acc076bd6e4659d2e37795bd4f98dc", "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/ZCohomology/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "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": "ayberkt/cubical", "max_issues_repo_path": "Cubical/ZCohomology/Properties.agda", "max_line_length": 168, "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/ZCohomology/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 14445, "size": 30384 }
module FunctorComposition where open import Functor as F compose : {F₁ F₂ : Setoid → Setoid} → Functor F₁ → Functor F₂ → Functor (λ A → F₁ (F₂ A)) compose {F₁} {F₂} FF₁ FF₂ = record { map = map FF₁ ∘ map FF₂ ; identity = λ {A} → trans (F₁ (F₂ A) ⇨ F₁ (F₂ A)) {i = map FF₁ ⟨$⟩ (map FF₂ ⟨$⟩ id)} {j = map FF₁ ⟨$⟩ id} {k = id} (cong (map FF₁) (identity FF₂)) (identity FF₁) ; composition = λ {A B C} f g → trans (F₁ (F₂ A) ⇨ F₁ (F₂ C)) {i = map FF₁ ⟨$⟩ (map FF₂ ⟨$⟩ (f ∘ g))} {j = map FF₁ ⟨$⟩ ((map FF₂ ⟨$⟩ f) ∘ (map FF₂ ⟨$⟩ g))} {k = (map FF₁ ⟨$⟩ (map FF₂ ⟨$⟩ f)) ∘ (map FF₁ ⟨$⟩ (map FF₂ ⟨$⟩ g))} (cong (map FF₁) (composition FF₂ f g)) (composition FF₁ (map FF₂ ⟨$⟩ f) (map FF₂ ⟨$⟩ g)) } where open Setoid open F.Functor
{ "alphanum_fraction": 0.447163515, "avg_line_length": 32.1071428571, "ext": "agda", "hexsha": "857ca2f31d7d46dfd6622ead7e21399607d6cb1e", "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": "benchmark/misc/FunctorComposition.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": "benchmark/misc/FunctorComposition.agda", "max_line_length": 65, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "benchmark/misc/FunctorComposition.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": 346, "size": 899 }
module Pi.Properties where open import Data.Empty open import Data.Unit open import Data.Sum open import Data.Product open import Relation.Binary.PropositionalEquality open import Pi.Syntax open import Pi.Opsem open import Pi.NoRepeat open import Pi.Invariants open import Pi.Eval open import Pi.Interp -- Forward evaluation is deterministic deterministic-eval : ∀ {A B} → (c : A ↔ B) (v : ⟦ A ⟧) (v₁ v₂ : ⟦ B ⟧) → ⟨ c ∣ v ∣ ☐ ⟩ ↦* [ c ∣ v₁ ∣ ☐ ] → ⟨ c ∣ v ∣ ☐ ⟩ ↦* [ c ∣ v₂ ∣ ☐ ] → v₁ ≡ v₂ deterministic-eval c v v₁ v₂ ↦*₁ ↦*₂ with deterministic* ↦*₁ ↦*₂ (λ ()) (λ ()) ... | refl = refl -- Backward evaluation is deterministic deterministic-evalᵣₑᵥ : ∀ {A B} → (c : A ↔ B) (v : ⟦ B ⟧) (v₁ v₂ : ⟦ A ⟧) → [ c ∣ v ∣ ☐ ] ↦ᵣₑᵥ* ⟨ c ∣ v₁ ∣ ☐ ⟩ → [ c ∣ v ∣ ☐ ] ↦ᵣₑᵥ* ⟨ c ∣ v₂ ∣ ☐ ⟩ → v₁ ≡ v₂ deterministic-evalᵣₑᵥ c v v₁ v₂ ↦ᵣₑᵥ*₁ ↦ᵣₑᵥ*₂ with deterministicᵣₑᵥ* ↦ᵣₑᵥ*₁ ↦ᵣₑᵥ*₂ (λ ()) (λ ()) ... | refl = refl -- Forward evaluator is reversible evalIsRev : ∀ {A B} → (c : A ↔ B) (v₁ : ⟦ A ⟧) (v₂ : ⟦ B ⟧) → eval c v₁ ≡ v₂ → evalᵣₑᵥ c v₂ ≡ v₁ evalIsRev c v₁ v₂ eq with ev {κ = ☐} c v₁ ... | v₂' , c↦* with eq ... | refl with evᵣₑᵥ {κ = ☐} c v₂ ... | v₁' , c↦*ᵣₑᵥ with deterministicᵣₑᵥ* c↦*ᵣₑᵥ (Rev↦ c↦*) (λ ()) (λ ()) ... | refl = refl -- Backward evaluator is reversible evalᵣₑᵥIsRev : ∀ {A B} → (c : A ↔ B) (v₁ : ⟦ B ⟧) (v₂ : ⟦ A ⟧) → evalᵣₑᵥ c v₁ ≡ v₂ → eval c v₂ ≡ v₁ evalᵣₑᵥIsRev c v₁ v₂ eq with evᵣₑᵥ {κ = ☐} c v₁ ... | v₂' , c↦ᵣₑᵥ* with eq ... | refl with ev {κ = ☐} c v₂ ... | v₁' , c↦* with deterministic* c↦* (Rev↦ᵣₑᵥ c↦ᵣₑᵥ*) (λ ()) (λ ()) ... | refl = refl -- The abstract machine semantics is equivalent to the big-step semantics eval≡interp : ∀ {A B} → (c : A ↔ B) → (v : ⟦ A ⟧) → eval c v ≡ interp c v eval≡interp unite₊l (inj₂ y) = refl eval≡interp uniti₊l v = refl eval≡interp swap₊ (inj₁ x) = refl eval≡interp swap₊ (inj₂ y) = refl eval≡interp assocl₊ (inj₁ x) = refl eval≡interp assocl₊ (inj₂ (inj₁ y)) = refl eval≡interp assocl₊ (inj₂ (inj₂ z)) = refl eval≡interp assocr₊ (inj₁ (inj₁ x)) = refl eval≡interp assocr₊ (inj₁ (inj₂ y)) = refl eval≡interp assocr₊ (inj₂ z) = refl eval≡interp unite⋆l (tt , v) = refl eval≡interp uniti⋆l v = refl eval≡interp swap⋆ (x , y) = refl eval≡interp assocl⋆ (x , (y , z)) = refl eval≡interp assocr⋆ ((x , y) , z) = refl eval≡interp dist (inj₁ x , z) = refl eval≡interp dist (inj₂ y , z) = refl eval≡interp factor (inj₁ (x , z)) = refl eval≡interp factor (inj₂ (y , z)) = refl eval≡interp id↔ v = refl eval≡interp (c₁ ⨾ c₂) v with ev {κ = ☐} c₁ v | inspect (ev {κ = ☐} c₁) v ... | (v' , rs) | [ eq ] with ev {κ = ☐} c₂ v' | inspect (ev {κ = ☐} c₂) v' ... | (v'' , rs') | [ eq' ] with ev {κ = ☐} (c₁ ⨾ c₂) v | inspect (ev {κ = ☐} (c₁ ⨾ c₂)) v ... | (u , rs'') | [ refl ] rewrite (sym (eval≡interp c₁ v)) | eq | (sym (eval≡interp c₂ v')) | eq' with deterministic* ((↦₃ ∷ ◾) ++↦ appendκ↦* rs refl (☐⨾ c₂ • ☐) ++↦ (↦₇ ∷ ◾) ++↦ appendκ↦* rs' refl (c₁ ⨾☐• ☐) ++↦ (↦₁₀ ∷ ◾)) rs'' (λ ()) (λ ()) ... | refl = refl eval≡interp (c₁ ⊕ c₂) (inj₁ x) with ev {κ = ☐} c₁ x | inspect (ev {κ = ☐} c₁) x ... | (x' , rs) | [ eq ] with ev {κ = ☐} (c₁ ⊕ c₂) (inj₁ x) | inspect (ev {κ = ☐} (c₁ ⊕ c₂)) (inj₁ x) ... | (v , rs') | [ refl ] rewrite (sym (eval≡interp c₁ x)) | eq with deterministic* ((↦₄ ∷ ◾) ++↦ appendκ↦* rs refl (☐⊕ c₂ • ☐) ++↦ (↦₁₁ ∷ ◾)) rs' (λ ()) (λ ()) ... | refl = refl eval≡interp (c₁ ⊕ c₂) (inj₂ y) with ev {κ = ☐} c₂ y | inspect (ev {κ = ☐} c₂) y ... | (x' , rs) | [ eq ] with ev {κ = ☐} (c₁ ⊕ c₂) (inj₂ y) | inspect (ev {κ = ☐} (c₁ ⊕ c₂)) (inj₂ y) ... | (v , rs') | [ refl ] rewrite (sym (eval≡interp c₂ y)) | eq with deterministic* ((↦₅ ∷ ◾) ++↦ appendκ↦* rs refl (c₁ ⊕☐• ☐) ++↦ (↦₁₂ ∷ ◾)) rs' (λ ()) (λ ()) ... | refl = refl eval≡interp (c₁ ⊗ c₂) (x , y) with ev {κ = ☐} c₁ x | inspect (ev {κ = ☐} c₁) x ... | (x' , rs) | [ eq ] with ev {κ = ☐} c₂ y | inspect (ev {κ = ☐} c₂) y ... | (y' , rs') | [ eq' ] with ev {κ = ☐} (c₁ ⊗ c₂) (x , y) | inspect (ev {κ = ☐} (c₁ ⊗ c₂)) (x , y) ... | (_ , rs'') | [ refl ] rewrite (sym (eval≡interp c₁ x)) | eq | (sym (eval≡interp c₂ y)) | eq' with deterministic* (((↦₆ ∷ ◾) ++↦ appendκ↦* rs refl (☐⊗[ c₂ , y ]• ☐)) ++↦ (↦₈ ∷ ◾) ++↦ appendκ↦* rs' refl ([ c₁ , x' ]⊗☐• ☐) ++↦ (↦₉ ∷ ◾)) rs'' (λ ()) (λ ()) ... | refl = refl c⨾!c≡id↔ : ∀ {A B} (c : A ↔ B) → (x : ⟦ A ⟧) → interp (c ⨾ ! c) x ≡ interp id↔ x c⨾!c≡id↔ unite₊l (inj₂ y) = refl c⨾!c≡id↔ uniti₊l x = refl c⨾!c≡id↔ swap₊ (inj₁ x) = refl c⨾!c≡id↔ swap₊ (inj₂ y) = refl c⨾!c≡id↔ assocl₊ (inj₁ x) = refl c⨾!c≡id↔ assocl₊ (inj₂ (inj₁ y)) = refl c⨾!c≡id↔ assocl₊ (inj₂ (inj₂ z)) = refl c⨾!c≡id↔ assocr₊ (inj₁ (inj₁ x)) = refl c⨾!c≡id↔ assocr₊ (inj₁ (inj₂ y)) = refl c⨾!c≡id↔ assocr₊ (inj₂ z) = refl c⨾!c≡id↔ unite⋆l (tt , x) = refl c⨾!c≡id↔ uniti⋆l x = refl c⨾!c≡id↔ swap⋆ (x , y) = refl c⨾!c≡id↔ assocl⋆ (x , (y , z)) = refl c⨾!c≡id↔ assocr⋆ ((x , y) , z) = refl c⨾!c≡id↔ dist (inj₁ x , z) = refl c⨾!c≡id↔ dist (inj₂ y , z) = refl c⨾!c≡id↔ factor (inj₁ (x , z)) = refl c⨾!c≡id↔ factor (inj₂ (y , z)) = refl c⨾!c≡id↔ id↔ x = refl c⨾!c≡id↔ (c₁ ⨾ c₂) x rewrite c⨾!c≡id↔ c₂ (interp c₁ x) = c⨾!c≡id↔ c₁ x c⨾!c≡id↔ (c₁ ⊕ c₂) (inj₁ x) rewrite c⨾!c≡id↔ c₁ x = refl c⨾!c≡id↔ (c₁ ⊕ c₂) (inj₂ y) rewrite c⨾!c≡id↔ c₂ y = refl c⨾!c≡id↔ (c₁ ⊗ c₂) (x , y) rewrite c⨾!c≡id↔ c₁ x | c⨾!c≡id↔ c₂ y = refl !!c≡c : ∀ {A B} (c : A ↔ B) → ! (! c) ≡ c !!c≡c unite₊l = refl !!c≡c uniti₊l = refl !!c≡c swap₊ = refl !!c≡c assocl₊ = refl !!c≡c assocr₊ = refl !!c≡c unite⋆l = refl !!c≡c uniti⋆l = refl !!c≡c swap⋆ = refl !!c≡c assocl⋆ = refl !!c≡c assocr⋆ = refl !!c≡c absorbr = refl !!c≡c factorzl = refl !!c≡c dist = refl !!c≡c factor = refl !!c≡c id↔ = refl !!c≡c (c₁ ⨾ c₂) rewrite !!c≡c c₁ | !!c≡c c₂ = refl !!c≡c (c₁ ⊕ c₂) rewrite !!c≡c c₁ | !!c≡c c₂ = refl !!c≡c (c₁ ⊗ c₂) rewrite !!c≡c c₁ | !!c≡c c₂ = refl !c⨾c≡id↔ : ∀ {A B} (c : A ↔ B) → (x : ⟦ B ⟧) → interp (! c ⨾ c) x ≡ interp id↔ x !c⨾c≡id↔ c x = trans (cong (λ c' → interp c' (interp (! c) x)) (sym (!!c≡c c))) (c⨾!c≡id↔ (! c) x)
{ "alphanum_fraction": 0.5037866315, "avg_line_length": 44.0144927536, "ext": "agda", "hexsha": "eb99044491c69e510b481f2a40981cf3e480b132", "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": "Pi/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "Pi/Properties.agda", "max_line_length": 258, "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": "Pi/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 3326, "size": 6074 }
module Propositional where open import Data.Nat open import Relation.Binary.PropositionalEquality open import Holes.Term using (⌞_⌟) open import Holes.Cong.Propositional open ≡-Reasoning -------------------------------------------------------------------------------- -- Some easy lemmas -------------------------------------------------------------------------------- +-zero : ∀ a → a + zero ≡ a +-zero zero = refl +-zero (suc a) rewrite +-zero a = refl +-suc : ∀ a b → a + suc b ≡ suc (a + b) +-suc zero b = refl +-suc (suc a) b rewrite +-suc a b = refl +-assoc : ∀ a b c → a + b + c ≡ a + (b + c) +-assoc zero b c = refl +-assoc (suc a) b c rewrite +-assoc a b c = refl -------------------------------------------------------------------------------- -- Proofs by equational reasoning -------------------------------------------------------------------------------- -- commutativity of addition proved traditionally +-comm₁ : ∀ a b → a + b ≡ b + a +-comm₁ zero b = sym (+-zero b) +-comm₁ (suc a) b = suc ⌞ a + b ⌟ ≡⟨ cong suc (+-comm₁ a b) ⟩ suc (b + a) ≡⟨ sym (+-suc b a) ⟩ b + suc a ∎ -- commutativity of addition proved with holes +-comm : ∀ a b → a + b ≡ b + a +-comm zero b = sym (+-zero b) +-comm (suc a) b = suc ⌞ a + b ⌟ ≡⟨ cong! (+-comm a b) ⟩ suc (b + a) ≡⟨ cong! (+-suc b a) ⟩ b + suc a ∎ -- distributivity of multiplication over addition proved traditionally *-distrib-+₁ : ∀ a b c → a * (b + c) ≡ a * b + a * c *-distrib-+₁ zero b c = refl *-distrib-+₁ (suc a) b c = b + c + a * (b + c) ≡⟨ cong (λ h → b + c + h) (*-distrib-+₁ a b c) ⟩ (b + c) + (a * b + a * c) ≡⟨ sym (+-assoc (b + c) (a * b) (a * c)) ⟩ ((b + c) + a * b) + a * c ≡⟨ cong (λ h → h + a * c) (+-assoc b c (a * b)) ⟩ (b + (c + a * b)) + a * c ≡⟨ cong (λ h → (b + h) + a * c) (+-comm c (a * b)) ⟩ (b + (a * b + c)) + a * c ≡⟨ cong (λ h → h + a * c) (sym (+-assoc b (a * b) c)) ⟩ ((b + a * b) + c) + a * c ≡⟨ +-assoc (b + a * b) c (a * c) ⟩ (b + a * b) + (c + a * c) ∎ -- distributivity of multiplication over addition proved with holes *-distrib-+ : ∀ a b c → a * (b + c) ≡ a * b + a * c *-distrib-+ zero b c = refl *-distrib-+ (suc a) b c = b + c + ⌞ a * (b + c) ⌟ ≡⟨ cong! (*-distrib-+ a b c) ⟩ ⌞ (b + c) + (a * b + a * c) ⌟ ≡⟨ cong! (+-assoc (b + c) (a * b) (a * c)) ⟩ ⌞ (b + c) + a * b ⌟ + a * c ≡⟨ cong! (+-assoc b c (a * b)) ⟩ (b + ⌞ c + a * b ⌟) + a * c ≡⟨ cong! (+-comm c (a * b)) ⟩ ⌞ b + (a * b + c) ⌟ + a * c ≡⟨ cong! (+-assoc b (a * b) c) ⟩ ⌞ ((b + a * b) + c) + a * c ⌟ ≡⟨ cong! (+-assoc (b + a * b) c (a * c)) ⟩ (b + a * b) + (c + a * c) ∎
{ "alphanum_fraction": 0.3951492537, "avg_line_length": 35.2631578947, "ext": "agda", "hexsha": "7a55279f54c33240e607a76205f40cc61845bf9f", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-02-02T18:57:17.000Z", "max_forks_repo_forks_event_min_datetime": "2017-01-27T14:57:39.000Z", "max_forks_repo_head_hexsha": "b5537c29e69febd7e89580398fac38d619aab3b4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bch29/agda-holes", "max_forks_repo_path": "examples/Propositional.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "b5537c29e69febd7e89580398fac38d619aab3b4", "max_issues_repo_issues_event_max_datetime": "2020-08-31T20:58:33.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-16T10:47:58.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bch29/agda-holes", "max_issues_repo_path": "examples/Propositional.agda", "max_line_length": 88, "max_stars_count": 24, "max_stars_repo_head_hexsha": "b5537c29e69febd7e89580398fac38d619aab3b4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bch29/agda-holes", "max_stars_repo_path": "examples/Propositional.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-03T15:02:41.000Z", "max_stars_repo_stars_event_min_datetime": "2017-01-28T10:56:46.000Z", "num_tokens": 1103, "size": 2680 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Printf ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Text.Printf where open import Level using (0ℓ; Lift) open import Data.List.Base as List using (List; []; _∷_) open import Data.Nat.Base using (ℕ) open import Data.Product open import Data.Product.Nary.NonDependent open import Data.String.Base open import Data.Sum.Base using (_⊎_; inj₁; inj₂) open import Data.Unit using (⊤) open import Function.Nary.NonDependent open import Function open import Strict import Data.Char.Base as Cₛ import Data.Integer as ℤₛ import Data.Float as Fₛ import Data.Nat.Show as ℕₛ open import Text.Format as Format hiding (Error) assemble : ∀ fmt → Product⊤ _ ⟦ fmt ⟧ → List String assemble [] vs = [] assemble (`ℕ ∷ fmt) (n , vs) = ℕₛ.show n ∷ assemble fmt vs assemble (`ℤ ∷ fmt) (z , vs) = ℤₛ.show z ∷ assemble fmt vs assemble (`Float ∷ fmt) (f , vs) = Fₛ.show f ∷ assemble fmt vs assemble (`Char ∷ fmt) (c , vs) = fromChar c ∷ assemble fmt vs assemble (`String ∷ fmt) (s , vs) = s ∷ assemble fmt vs assemble (Raw str ∷ fmt) vs = str ∷ assemble fmt vs record Error (e : Format.Error) : Set where private Size : Format.Error ⊎ Format → ℕ Size (inj₁ err) = 0 Size (inj₂ fmt) = size fmt Printf : ∀ pr → Set (⨆ (Size pr) 0ℓs) Printf (inj₁ err) = Error err Printf (inj₂ fmt) = Arrows _ ⟦ fmt ⟧ String printf' : ∀ pr → Printf pr printf' (inj₁ err) = _ printf' (inj₂ fmt) = curry⊤ₙ _ (concat ∘′ assemble fmt) printf : (input : String) → Printf (lexer input) printf input = printf' (lexer input)
{ "alphanum_fraction": 0.5982708934, "avg_line_length": 30.4385964912, "ext": "agda", "hexsha": "f2a628614ad3685b6877a3bc68ec8c90ef547063", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Text/Printf.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Text/Printf.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Text/Printf.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": 518, "size": 1735 }
{-# OPTIONS --cubical --safe #-} module Cubical.Data.Strict2Group.Categorical where open import Cubical.Foundations.Prelude open import Cubical.Categories.InternalCategory open import Cubical.Categories.Groups {-- Formalization of strict 2-groups as internal categories of the 1-category Grp of Groups. --} Strict2GroupInternalCat : (ℓ : Level) → Type (ℓ-suc ℓ) Strict2GroupInternalCat ℓ = InternalCategory (1BGROUP ℓ)
{ "alphanum_fraction": 0.7872340426, "avg_line_length": 28.2, "ext": "agda", "hexsha": "1cfb7ccbfcb8f79b823114f1abeddfcf04a31be9", "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": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_path": "Cubical/Data/Strict2Group/Categorical.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "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": "Schippmunk/cubical", "max_issues_repo_path": "Cubical/Data/Strict2Group/Categorical.agda", "max_line_length": 56, "max_stars_count": null, "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_path": "Cubical/Data/Strict2Group/Categorical.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 110, "size": 423 }
{-# OPTIONS --cumulativity #-} open import Agda.Primitive -- Defaulting of level metas does not apply to interaction metas, so -- the type of test₁ should be `Set ?0`, not `Set`. test₁ : Set {!!} test₁ = {!!} postulate F : ∀ a (A : Set a) → A → Set -- In this example, t first argument of F should not default to lzero -- because it occurs in the type of another meta. test₂ : F _ _ _ test₂ = {!!}
{ "alphanum_fraction": 0.6559405941, "avg_line_length": 23.7647058824, "ext": "agda", "hexsha": "d4838904d87e6dc840634fa0e3765a0bc915936b", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/CumulDontDefaultInteraction.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/CumulDontDefaultInteraction.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/interaction/CumulDontDefaultInteraction.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 118, "size": 404 }
module examplesPaperJFP.loadAllOOAgdaPart1 where -- This file loads the files containing the code examples in the ooAgda paper -- ordered by sections -- The code is divided into files -- loadAllOOAgdaPart1.agda and loadAllOOAgdaPart2.agda -- loadAllOOAgdaPart1.agda loads code from Sect. 1 - 7 -- loadAllOOAgdaPart2.agda loads code from Sect. 8 - 12 -- -- The reason for splitting it into two files is that because of some -- Builtin the code from the first file cannot be loaded at the same -- time as the code from the second one. -- The difference is loading NativeIOSafe.agda vs NativeIO.agda -- -- Important changes due to updating it to current agda -- #################################################### -- * do is now a keyword and therefore replaced by exec -- * some other small changes mainly because of changes in the -- standard library have been made -- -- Files from the Library -- ######################### -- loadAllOOAgdaFilesAsInLibrary.agda -- loads corresponding code from the library which is slightly different -- from how it is represented in the paper -- Source of paper, presentations, slides -- ####################################### -- Andreas Abel, Stephan Adelsberger, Anton Setzer: -- Interactive Programming in Agda - Objects and Graphical User Interfaces -- Journal of Functional Programming, 27, 2017 -- doi: http://dx.doi.org/10.1145/2976022.2976032 -- authors copy: http://www.cs.swan.ac.uk/~csetzer/articles/ooAgda.pdf -- bibtex: http://www.cs.swan.ac.uk/~csetzer/articles/ooAgda.bib -- 1. Introdution -- 2. Introduction to Agda import examplesPaperJFP.finn import examplesPaperJFP.exampleFinFun import examplesPaperJFP.Equality -- 3. Coalgebras in Agda -- 3.1. Coalgebra by example: Colists import examplesPaperJFP.Colists import examplesPaperJFP.Collatz -- 3.2. Coalgebras in General import examplesPaperJFP.Coalgebra -- 4. Interactive Programs in Agda -- 4.1. Interaction interfaces import examplesPaperJFP.NativeIOSafe import examplesPaperJFP.BasicIO import examplesPaperJFP.triangleRightOperator import examplesPaperJFP.ConsoleInterface -- 4.2. Interaction trees import examplesPaperJFP.Console import examplesPaperJFP.CatNonTerm import examplesPaperJFP.CatTerm -- 4.3. Running interactive programs import examplesPaperJFP.IOExampleConsole -- 5. Objects in Agda -- code as in paper adapted to new Agda import examplesPaperJFP.Object -- code as in library see loadAllOOAgdaFilesAsInLibrary.agda -- open import SizedIO.Object -- 6. Sized Coinductive Types import examplesPaperJFP.Sized -- 7. Interface Extension and Delegation -- code as in paper adapted to new Agda import examplesPaperJFP.CounterCell -- code as in library see loadAllOOAgdaFilesAsInLibrary.agda -- open import Sized.CounterCell -- *** Code from Sect 8 - 12 can be found in loadAllOOAgdaPart2.agda ***
{ "alphanum_fraction": 0.7394170715, "avg_line_length": 30.9892473118, "ext": "agda", "hexsha": "8d101359271e38e3de550076bcdda16acf8e595e", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "examples/examplesPaperJFP/loadAllOOAgdaPart1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "examples/examplesPaperJFP/loadAllOOAgdaPart1.agda", "max_line_length": 77, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "examples/examplesPaperJFP/loadAllOOAgdaPart1.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 759, "size": 2882 }
{-# OPTIONS --without-K --safe #-} -- verbatim dual of Categories.Category.Construction.Properties.EilenbergMoore module Categories.Category.Construction.Properties.CoEilenbergMoore where open import Level import Relation.Binary.PropositionalEquality.Core as ≡ open import Categories.Adjoint open import Categories.Adjoint.Properties open import Categories.Category open import Categories.Functor using (Functor; _∘F_) open import Categories.Functor.Equivalence open import Categories.Comonad open import Categories.NaturalTransformation.Core renaming (id to idN) open import Categories.Morphism.HeterogeneousIdentity open import Categories.Morphism.Reasoning open import Categories.Adjoint.Construction.CoEilenbergMoore open import Categories.Category.Construction.CoEilenbergMoore private variable o ℓ e : Level 𝒞 𝒟 : Category o ℓ e module _ {F : Functor 𝒟 𝒞} {G : Functor 𝒞 𝒟} (F⊣G : Adjoint F G) where private T : Comonad 𝒞 T = adjoint⇒comonad F⊣G coEM𝒞 : Category _ _ _ coEM𝒞 = CoEilenbergMoore T module 𝒞 = Category 𝒞 module 𝒟 = Category 𝒟 module coEM𝒞 = Category coEM𝒞 open 𝒞.HomReasoning module T = Comonad T module F = Functor F module G = Functor G module FG = Functor (F ∘F G) open Adjoint F⊣G open NaturalTransformation open Category.Equiv -- Maclane's Comparison Functor ComparisonF : Functor 𝒟 coEM𝒞 ComparisonF = record { F₀ = λ X → record { A = F.F₀ X ; coaction = F.F₁ (unit.η X) ; commute = commute-obj ; identity = zig } ; F₁ = λ {A} {B} f → record { arr = F.F₁ f ; commute = commute-mor } ; identity = F.identity ; homomorphism = F.homomorphism ; F-resp-≈ = F.F-resp-≈ } where commute-obj : {X : Category.Obj 𝒟} → T.F.F₁ (F.F₁ (unit.η X)) 𝒞.∘ F.F₁ (unit.η X) 𝒞.≈ T.δ.η (F.F₀ X) 𝒞.∘ F.F₁ (unit.η X) commute-obj {X} = begin F.F₁ (G.F₁ (F.F₁ (unit.η X))) 𝒞.∘ F.F₁ (unit.η X) ≈⟨ sym 𝒞 (F.homomorphism) ⟩ F.F₁ (G.F₁ (F.F₁ (unit.η X)) 𝒟.∘ unit.η X) ≈⟨ Functor.F-resp-≈ F (unit.sym-commute (unit.η X)) ⟩ F.F₁ (unit.η (G.F₀ (F.F₀ X)) 𝒟.∘ unit.η X) ≈⟨ F.homomorphism ⟩ T.δ.η (F.F₀ X) 𝒞.∘ F.F₁ (unit.η X) ∎ commute-mor : {A B : Category.Obj 𝒟} {f : 𝒟 [ A , B ]} → F.F₁ (unit.η B) 𝒞.∘ F.F₁ f 𝒞.≈ T.F.F₁ (F.F₁ f) 𝒞.∘ F.F₁ (unit.η A) commute-mor {A} {B} {f} = begin F.F₁ (unit.η B) 𝒞.∘ F.F₁ f ≈⟨ sym 𝒞 (F.homomorphism) ⟩ F.F₁ (unit.η B 𝒟.∘ f) ≈⟨ Functor.F-resp-≈ F (unit.commute f) ⟩ F.F₁ (G.F₁ (F.F₁ f) 𝒟.∘ unit.η A) ≈⟨ F.homomorphism ⟩ T.F.F₁ (F.F₁ f) 𝒞.∘ F.F₁ (unit.η A) ∎ Comparison∘F≡Free : (ComparisonF ∘F G) ≡F Cofree T Comparison∘F≡Free = record { eq₀ = λ X → ≡.refl ; eq₁ = λ f → id-comm-sym 𝒞 } Forgetful∘ComparisonF≡G : (Forgetful T ∘F ComparisonF) ≡F F Forgetful∘ComparisonF≡G = record { eq₀ = λ X → ≡.refl ; eq₁ = λ f → id-comm-sym 𝒞 }
{ "alphanum_fraction": 0.6234693878, "avg_line_length": 32.3076923077, "ext": "agda", "hexsha": "512231851f960e360819d8798ffdc2529238d5b8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Category/Construction/Properties/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/Category/Construction/Properties/CoEilenbergMoore.agda", "max_line_length": 127, "max_stars_count": 5, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Category/Construction/Properties/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": 1182, "size": 2940 }
open import Prelude open import Data.Nat.Properties.Simple using (+-comm; +-right-identity; +-assoc) open import RW.Language.RTerm open import Relation.Binary.PropositionalEquality open import RW.Strategy.PropEq open import RW.RW (≡-strat ∷ []) module PropEqTransitivityTest where open ≡-Reasoning -- This is pretty slow... test2 : (x y : ℕ) → (x + y) + 0 ≡ y + (x + 0) test2 x y = begin (x + y) + 0 ≡⟨ (tactic (by*-≡ (quote +-comm ∷ quote +-assoc ∷ []))) ⟩ y + (x + 0) ∎ {- Using a max height of 2 in the goal guesser. Finished RWTestingTrans. 46,981,963,256 bytes allocated in the heap 7,318,699,728 bytes copied during GC 387,537,960 bytes maximum residency (20 sample(s)) 8,253,392 bytes maximum slop 1042 MB total memory in use (0 MB lost due to fragmentation) Tot time (elapsed) Avg pause Max pause Gen 0 90092 colls, 0 par 17.25s 17.25s 0.0002s 0.0030s Gen 1 20 colls, 0 par 5.15s 5.17s 0.2587s 0.6522s INIT time 0.00s ( 0.00s elapsed) MUT time 241.64s (241.88s elapsed) GC time 22.40s ( 22.42s elapsed) EXIT time 0.09s ( 0.09s elapsed) Total time 264.12s (264.40s elapsed) %GC time 8.5% (8.5% elapsed) Alloc rate 194,432,035 bytes per MUT second Productivity 91.5% of total user, 91.4% of total elapsed -} {- Using a height of 1 Finished RWTestingTrans. 31,222,657,544 bytes allocated in the heap 5,109,928,984 bytes copied during GC 355,162,768 bytes maximum residency (18 sample(s)) 7,579,240 bytes maximum slop 952 MB total memory in use (0 MB lost due to fragmentation) Tot time (elapsed) Avg pause Max pause Gen 0 59723 colls, 0 par 12.21s 12.22s 0.0002s 0.0036s Gen 1 18 colls, 0 par 3.91s 3.92s 0.2179s 0.6516s INIT time 0.00s ( 0.00s elapsed) MUT time 154.42s (154.57s elapsed) GC time 16.12s ( 16.14s elapsed) EXIT time 0.09s ( 0.09s elapsed) Total time 170.63s (170.80s elapsed) %GC time 9.5% (9.5% elapsed) Alloc rate 202,197,812 bytes per MUT second Productivity 90.5% of total user, 90.5% of total elapsed -}
{ "alphanum_fraction": 0.5891047297, "avg_line_length": 29.2345679012, "ext": "agda", "hexsha": "fe26cc83ca2be13fe8868ab6e1d234005df8f90a", "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": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "VictorCMiraldo/agda-rw", "max_forks_repo_path": "Testing/PropEqTransitivityTest.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_issues_repo_issues_event_max_datetime": "2015-05-28T14:48:03.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-06T15:03:33.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "VictorCMiraldo/agda-rw", "max_issues_repo_path": "Testing/PropEqTransitivityTest.agda", "max_line_length": 76, "max_stars_count": 16, "max_stars_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "VictorCMiraldo/agda-rw", "max_stars_repo_path": "Testing/PropEqTransitivityTest.agda", "max_stars_repo_stars_event_max_datetime": "2019-10-24T17:38:20.000Z", "max_stars_repo_stars_event_min_datetime": "2015-02-09T15:43:38.000Z", "num_tokens": 867, "size": 2368 }
{-# OPTIONS --type-in-type --no-termination-check #-} module Data where _-_ : {A : Set}{B : A -> Set}{C : (a : A) -> B a -> Set} -> ({a : A}(b : B a) -> C a b) -> (f : (a : A) -> B a) -> (a : A) -> C a (f a) f - g = \ x -> f (g x) id : {X : Set} -> X -> X id x = x konst : {S : Set}{T : S -> Set} -> ({x : S} -> T x) -> (x : S) -> T x konst c x = c data Zero : Set where record One : Set where record Sig (S : Set)(T : S -> Set) : Set where field fst : S snd : T fst open module Sig' {S : Set}{T : S -> Set} = Sig {S}{T} _,_ : forall {S T}(s : S) -> T s -> Sig S T s , t = record {fst = s; snd = t} infixr 40 _,_ _*_ : Set -> Set -> Set S * T = Sig S \ _ -> T sig : forall {S T}{P : Sig S T -> Set} -> ((s : S)(t : T s) -> P (s , t)) -> (st : Sig S T) -> P st sig f st = f (fst st) (snd st) data Two : Set where tt : Two ff : Two cond : {S : Two -> Set} -> S tt -> S ff -> (b : Two) -> S b cond t f tt = t cond t f ff = f _+_ : Set -> Set -> Set S + T = Sig Two (cond S T) [_,_] : {S T : Set}{P : S + T -> Set} -> ((s : S) -> P (tt , s)) -> ((t : T) -> P (ff , t)) -> (x : S + T) -> P x [ f , g ] = sig (cond f g) data PROP : Set where Absu : PROP Triv : PROP _/\_ : PROP -> PROP -> PROP All : (S : Set) -> (S -> PROP) -> PROP Prf : PROP -> Set Prf Absu = Zero Prf Triv = One Prf (P /\ Q) = Prf P * Prf Q Prf (All S P) = (x : S) -> Prf (P x) data CON (I : Set) : Set where ?? : I -> CON I PrfC : PROP -> CON I _*C_ : CON I -> CON I -> CON I PiC : (S : Set) -> (S -> CON I) -> CON I SiC : (S : Set) -> (S -> CON I) -> CON I MuC : (O : Set) -> (O -> CON (I + O)) -> O -> CON I NuC : (O : Set) -> (O -> CON (I + O)) -> O -> CON I mutual [|_|] : {I : Set} -> CON I -> (I -> Set) -> Set [| ?? i |] X = X i [| PrfC P |] X = Prf P [| C *C D |] X = [| C |] X * [| D |] X [| PiC S C |] X = (s : S) -> [| C s |] X [| SiC S C |] X = Sig S \ s -> [| C s |] X [| MuC O C o |] X = Mu C X o [| NuC O C o |] X = Nu C X o data Mu {I O : Set}(C : O -> CON (I + O))(X : I -> Set)(o : O) : Set where con : [| C o |] [ X , Mu C X ] -> Mu C X o codata Nu {I O : Set}(C : O -> CON (I + O))(X : I -> Set)(o : O) : Set where con : [| C o |] [ X , Nu C X ] -> Nu C X o noc : {I O : Set}{C : O -> CON (I + O)}{X : I -> Set}{o : O} -> Nu C X o -> [| C o |] [ X , Nu C X ] noc (con xs) = xs mutual map : {I : Set}{X Y : I -> Set} -> (C : CON I) -> ((i : I) -> X i -> Y i) -> [| C |] X -> [| C |] Y map (?? i) f = f i map (PrfC P) f = id map (C *C D) f = sig \ c d -> map C f c , map D f d map (PiC S C) f = \ c s -> map (C s) f (c s) map (SiC S C) f = sig \ s c -> s , map (C s) f c map (MuC O C o) f = fold C (Mu C _) (\ o xs -> con (map (C o) [ f , konst id ] xs)) o map (NuC O C o) f = unfold C (Nu C _) (\ o ss -> map (C o) [ f , konst id ] (noc ss)) o fold : {I O : Set}(C : O -> CON (I + O)){X : I -> Set}(Y : O -> Set) -> ((o : O) -> [| C o |] [ X , Y ] -> Y o) -> (o : O) -> Mu C X o -> Y o fold C Y f o (con xs) = f o (map (C o) [ konst id , fold C Y f ] xs) unfold : {I O : Set}(C : O -> CON (I + O)){X : I -> Set}(Y : O -> Set) -> ((o : O) -> Y o -> [| C o |] [ X , Y ]) -> (o : O) -> Y o -> Nu C X o unfold C Y f o y = con (map (C o) [ konst id , unfold C Y f ] (f o y)) induction : {I O : Set}(C : O -> CON (I + O)){X : I -> Set} (P : (o : O) -> Mu C X o -> Set) -> ((o : O)(xyps : [| C o |] [ X , (\ o -> Sig (Mu C X o) (P o)) ]) -> P o (con (map (C o) [ konst id , konst fst ] xyps))) -> (o : O)(y : Mu C X o) -> P o y induction C P p o (con xys) = p o (map (C o) [ konst id , (\ o y -> (y , induction C P p o y)) ] xys) moo : {I O : Set}(C : O -> CON (I + O)){X : I -> Set}(o : O) (W : (o : O) -> Mu C X o -> Set)(w : (o : O)(y : Mu C X o) -> W o y) (P : (io : I + O) -> [| ?? io |] [ X , Mu C X ] -> Set) (io : I + O)(xy : [| ?? io |] [ X , Mu C X ]) -> P io xy -> let g : (io : I + O) -> [| ?? io |] [ X , Mu C X ] -> [| ?? io |] [ X , (\ o -> Sig (Mu C X o) (W o)) ] g = [ konst id , (\ o y -> (y , w o y)) ] f : (io : I + O) -> [| ?? io |] [ X , (\ o -> Sig (Mu C X o) (W o)) ] -> [| ?? io |] [ X , Mu C X ] f = [ konst id , konst fst ] in P io (f io (g io xy)) moo C o W w P io xy p = {!p!}
{ "alphanum_fraction": 0.3720982143, "avg_line_length": 32.4637681159, "ext": "agda", "hexsha": "c90ca72a7a60408bf15cfdf525465509e27ff17b", "lang": "Agda", "max_forks_count": 12, "max_forks_repo_forks_event_max_datetime": "2022-02-11T01:57:40.000Z", "max_forks_repo_forks_event_min_datetime": "2016-08-14T21:36:35.000Z", "max_forks_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mietek/epigram", "max_forks_repo_path": "models/Data.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mietek/epigram", "max_issues_repo_path": "models/Data.agda", "max_line_length": 93, "max_stars_count": 48, "max_stars_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mietek/epigram", "max_stars_repo_path": "models/Data.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-11T01:55:28.000Z", "max_stars_repo_stars_event_min_datetime": "2016-01-09T17:36:19.000Z", "num_tokens": 1918, "size": 4480 }
{- small library for MGS 2021 -} {- products and sums -} infix 10 _×_ record _×_ (A B : Set) : Set where constructor _,_ field proj₁ : A proj₂ : B open _×_ public variable A B C M : Set curry : (A × B → C) → (A → B → C) curry f a b = f (a , b) -- C-c C-, uncurry : (A → B → C) → (A × B → C) uncurry f (a , b) = f a b infix 5 _⊎_ data _⊎_(A B : Set) : Set where inj₁ : A → A ⊎ B inj₂ : B → A ⊎ B case : (A → C) → (B → C) → (A ⊎ B → C) case f g (inj₁ a) = f a case f g (inj₂ b) = g b uncase : (A ⊎ B → C) → (A → C) × (B → C) uncase f = (λ a → f (inj₁ a)) , λ b → f (inj₂ b) --case' : (A → C) × (B → C) → (A ⊎ B → C) --case' = uncurry case record ⊤ : Set where constructor tt open ⊤ public data ⊥ : Set where case⊥ : ⊥ → A case⊥ () data Bool : Set where true : Bool false : Bool if_then_else_ : Bool → A → A → A if true then x else y = x if false then x else y = y {- bool logic -} _&_ : Bool → Bool → Bool true & y = y false & y = false {- ∣ = \mid -} _∣_ : Bool → Bool → Bool true ∣ y = true false ∣ y = y !_ : Bool → Bool ! true = false ! false = true _⇒b_ : Bool → Bool → Bool true ⇒b y = y false ⇒b y = true {- prop logic -} prop = Set variable P Q R : prop infix 3 _∧_ _∧_ : prop → prop → prop P ∧ Q = P × Q infix 2 _∨_ _∨_ : prop → prop → prop P ∨ Q = P ⊎ Q infixr 1 _⇒_ _⇒_ : prop → prop → prop P ⇒ Q = P → Q False : prop False = ⊥ True : prop True = ⊤ ¬_ : prop → prop ¬ P = P ⇒ False infix 0 _⇔_ _⇔_ : prop → prop → prop P ⇔ Q = (P ⇒ Q) ∧ (Q ⇒ P) efq : False ⇒ P efq = case⊥ {- classical principles -} TND : prop → prop TND P = P ∨ ¬ P RAA : prop → prop RAA P = ¬ ¬ P ⇒ P tnd⇒raa : TND P ⇒ RAA P tnd⇒raa (inj₁ p) nnp = p tnd⇒raa (inj₂ np) nnp = efq (nnp np) nnpnp : ¬ ¬ (P ∨ ¬ P) nnpnp h = h (inj₂ (λ p → h (inj₁ p))) raa⇒tnd : RAA (P ∨ ¬ P) ⇒ TND P raa⇒tnd raa = raa nnpnp {- natural numbers -} data ℕ : Set where zero : ℕ suc : ℕ → ℕ {-# BUILTIN NATURAL ℕ #-} infixl 6 _+_ _+_ : ℕ → ℕ → ℕ zero + n = n suc m + n = suc (m + n) infixl 7 _*_ _*_ : ℕ → ℕ → ℕ zero * n = zero suc m * n = n + m * n {- Lists -} infixr 5 _∷_ data List (A : Set) : Set where [] : List A _∷_ : A → List A → List A -- \:: _++_ : List A → List A → List A [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ (xs ++ ys) {- Streams -} record Stream (A : Set) : Set where constructor _∷_ coinductive field head : A tail : Stream A open Stream public mapS : (A → B) → Stream A → Stream B head (mapS f as) = f (head as) tail (mapS f as) = mapS f (tail as) {- conatural numbers -} data Maybe (A : Set) : Set where nothing : Maybe A just : A → Maybe A record ℕ∞ : Set where coinductive field pred∞ : Maybe ℕ∞ open ℕ∞ public zero∞ : ℕ∞ pred∞ zero∞ = nothing suc∞ : ℕ∞ → ℕ∞ pred∞ (suc∞ n) = just n ∞ : ℕ∞ pred∞ ∞ = just ∞ _+∞_ : ℕ∞ → ℕ∞ → ℕ∞ pred∞ (m +∞ n) with pred∞ m ... | nothing = pred∞ n ... | just m' = just (m' +∞ n) {- Vectors and Fin -} variable i j k m n : ℕ data Vec (A : Set) : ℕ → Set where [] : Vec A 0 _∷_ : {n : ℕ} → A → Vec A n → Vec A (suc n) _++v_ : Vec A m → Vec A n → Vec A (m + n) [] ++v ys = ys (x ∷ xs) ++v ys = x ∷ (xs ++v ys) data Fin : ℕ → Set where zero : Fin (suc n) suc : Fin n → Fin (suc n) _!!v_ : Vec A n → Fin n → A (x ∷ xs) !!v zero = x (x ∷ xs) !!v suc i = xs !!v i
{ "alphanum_fraction": 0.5115361263, "avg_line_length": 14.9049773756, "ext": "agda", "hexsha": "b61f6d7895659303a226e46cc7d9e7865e165b0d", "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": "f328e596d98a7d052b34144447dd14de0f57e534", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "FoxySeta/mgs-2021", "max_forks_repo_path": "Type Theory/mylib.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534", "max_issues_repo_issues_event_max_datetime": "2021-07-14T20:35:48.000Z", "max_issues_repo_issues_event_min_datetime": "2021-07-14T20:34:53.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "FoxySeta/mgs-2021", "max_issues_repo_path": "Type Theory/mylib.agda", "max_line_length": 48, "max_stars_count": null, "max_stars_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "FoxySeta/mgs-2021", "max_stars_repo_path": "Type Theory/mylib.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1486, "size": 3294 }
{-# OPTIONS --cubical --no-import-sorts #-} module Number.Prelude.Nat where open import Cubical.Data.Nat.Order public using () renaming ( _<_ to _<ⁿᵗ_ ; <-trans to <ⁿ-trans -- TODO: use different version ; _≟_ to _≟ⁿ_ ; lt to ltⁿ ; gt to gtⁿ ; eq to eqⁿ ; ¬-<-zero to ¬-<ⁿ-zero ) open import Data.Nat public using () renaming ( _⊔_ to maxⁿ ; _⊓_ to minⁿ ; _+_ to _+ⁿ_ ; _*_ to _·ⁿ_ ; pred to predⁿ ) open import Cubical.Data.Nat public using (suc; zero; ℕ; HasFromNat) renaming ( +-comm to +ⁿ-comm ; +-assoc to +ⁿ-assoc ; *-comm to ·ⁿ-comm ; *-suc to ·ⁿ-suc ; *-assoc to ·ⁿ-assoc ; +-suc to +ⁿ-suc ; *-distribˡ to ·ⁿ-distribˡ ; *-distribʳ to ·ⁿ-distribʳ ; *-identityʳ to ·ⁿ-identityʳ ; *-identityˡ to ·ⁿ-identityˡ ; snotz to snotzⁿ ; injSuc to injSucⁿ ; isSetℕ to is-setⁿ ; inj-m+ to +ⁿ-preserves-≡ˡ ; inj-+m to +ⁿ-preserves-≡ʳ ; inj-sm* to ·ⁿ-reflects-≡ˡ' ; inj-*sm to ·ⁿ-reflects-≡ʳ' ) open import Number.Instances.Nat as Nat public using () renaming ( bundle to ℕbundle ; _<_ to _<ⁿ_ ; 0<suc to 0<ⁿsuc ; ·-nullifiesˡ to ·ⁿ-nullifiesˡ ; ·-nullifiesʳ to ·ⁿ-nullifiesʳ ; <-irrefl to <ⁿ-irrefl ; suc-creates-< to sucⁿ-creates-<ⁿ ; <-cotrans to <ⁿ-cotrans ; ¬suc<0 to ¬suc<ⁿ0 ; ·-reflects-< to ·ⁿ-reflects-<ⁿ ; ·-preserves-< to ·ⁿ-preserves-<ⁿ ; +-createsʳ-< to +ⁿ-createsʳ-<ⁿ ; +-createsˡ-< to +ⁿ-createsˡ-<ⁿ ; min-comm to minⁿ-comm ; min-tightˡ to minⁿ-tightˡ ; min-tightʳ to minⁿ-tightʳ ; min-identity to minⁿ-identity ; max-comm to maxⁿ-comm ; max-tightˡ to maxⁿ-tightˡ ; max-tightʳ to maxⁿ-tightʳ ; max-identity to maxⁿ-identity ; MinTrichtotomy to MinTrichtotomyⁿ ; MaxTrichtotomy to MaxTrichtotomyⁿ ; min-trichotomy to minⁿ-trichotomy ; max-trichotomy to maxⁿ-trichotomy ; is-min to is-minⁿ ; is-max to is-maxⁿ ; +-<-ext to +ⁿ-<ⁿ-ext ; ·-reflects-≡ʳ to ·ⁿ-reflects-≡ʳ ; ·-reflects-≡ˡ to ·ⁿ-reflects-≡ˡ ) open import MorePropAlgebra.Definitions open import MorePropAlgebra.Structures open import Number.Structures2 open IsMonoid Nat.+-Monoid public using () renaming (is-identity to +ⁿ-identity) open IsMonoid Nat.·-Monoid public using () renaming (is-identity to ·ⁿ-identity) open IsSemiring Nat.is-Semiring public using () renaming (is-dist to is-distⁿ) open IsStrictLinearOrder Nat.<-StrictLinearOrder public using () renaming (is-tricho to is-trichoⁿ) -- <-StrictLinearOrder .IsStrictLinearOrder.is-trans a b c = <-trans {a} {b} {c}
{ "alphanum_fraction": 0.5937047757, "avg_line_length": 33.7073170732, "ext": "agda", "hexsha": "9a43f9819c2756b83cd32fed7fae0743b6e69748", "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": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "agda/Number/Prelude/Nat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "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": "mchristianl/synthetic-reals", "max_issues_repo_path": "agda/Number/Prelude/Nat.agda", "max_line_length": 102, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "agda/Number/Prelude/Nat.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 1127, "size": 2764 }