Search is not available for this dataset
text
string
meta
dict
module Data.Fin.Subset.Cardinality where open import Data.Fin.Subset _∖_ : ∀ {n} → Subset n → Subset n → Subset n _∖_ {n} a b = a ∩ ∁ b
{ "alphanum_fraction": 0.6180555556, "avg_line_length": 20.5714285714, "ext": "agda", "hexsha": "8fd27d365414e403aeba8325d7f090e07df63f07", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "tizmd/agda-finitary", "max_forks_repo_path": "src/Data/Fin/Subset/Cardinality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "tizmd/agda-finitary", "max_issues_repo_path": "src/Data/Fin/Subset/Cardinality.agda", "max_line_length": 46, "max_stars_count": null, "max_stars_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "tizmd/agda-finitary", "max_stars_repo_path": "src/Data/Fin/Subset/Cardinality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 57, "size": 144 }
------------------------------------------------------------------------------ -- Properties related with lists ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.List.PropertiesATP where open import FOTC.Base open import FOTC.Base.List open import FOTC.Data.Conat open import FOTC.Data.List open import FOTC.Data.Nat.Type ------------------------------------------------------------------------------ -- Congruence properties postulate ++-leftCong : ∀ {xs ys zs} → xs ≡ ys → xs ++ zs ≡ ys ++ zs {-# ATP prove ++-leftCong #-} postulate mapCong₂ : ∀ {f xs ys} → xs ≡ ys → map f xs ≡ map f ys {-# ATP prove mapCong₂ #-} ------------------------------------------------------------------------------ -- Totality properties ++-List : ∀ {xs ys} → List xs → List ys → List (xs ++ ys) ++-List {ys = ys} lnil Lys = prf where postulate prf : List ([] ++ ys) {-# ATP prove prf #-} ++-List {ys = ys} (lcons x {xs} Lxs) Lys = prf (++-List Lxs Lys) where postulate prf : List (xs ++ ys) → List ((x ∷ xs) ++ ys) {-# ATP prove prf #-} map-List : ∀ f {xs} → List xs → List (map f xs) map-List f lnil = prf where postulate prf : List (map f []) {-# ATP prove prf #-} map-List f (lcons x {xs} Lxs) = prf (map-List f Lxs) where postulate prf : List (map f xs) → List (map f (x ∷ xs)) {-# ATP prove prf #-} rev-List : ∀ {xs ys} → List xs → List ys → List (rev xs ys) rev-List {ys = ys} lnil Lys = prf where postulate prf : List (rev [] ys) {-# ATP prove prf #-} rev-List {ys = ys} (lcons x {xs} Lxs) Lys = prf (rev-List Lxs (lcons x Lys)) where postulate prf : List (rev xs (x ∷ ys)) → List (rev (x ∷ xs) ys) {-# ATP prove prf #-} postulate reverse-List : ∀ {xs} → List xs → List (reverse xs) {-# ATP prove reverse-List rev-List #-} -- Length properties length-replicate : ∀ x {n} → N n → length (replicate n x) ≡ n length-replicate x nzero = prf where postulate prf : length (replicate zero x) ≡ zero {-# ATP prove prf #-} length-replicate x (nsucc {n} Nn) = prf (length-replicate x Nn) where postulate prf : length (replicate n x) ≡ n → length (replicate (succ₁ n) x) ≡ succ₁ n {-# ATP prove prf #-} postulate lg-xs≡∞→lg-x∷xs≡∞ : ∀ x xs → length xs ≡ ∞ → length (x ∷ xs) ≡ ∞ {-# ATP prove lg-xs≡∞→lg-x∷xs≡∞ #-} -- Append properties ++-leftIdentity : ∀ xs → [] ++ xs ≡ xs ++-leftIdentity = ++-[] ++-rightIdentity : ∀ {xs} → List xs → xs ++ [] ≡ xs ++-rightIdentity lnil = prf where postulate prf : [] ++ [] ≡ [] {-# ATP prove prf #-} ++-rightIdentity (lcons x {xs} Lxs) = prf (++-rightIdentity Lxs) where postulate prf : xs ++ [] ≡ xs → (x ∷ xs) ++ [] ≡ x ∷ xs {-# ATP prove prf #-} ++-assoc : ∀ {xs} → List xs → ∀ ys zs → (xs ++ ys) ++ zs ≡ xs ++ (ys ++ zs) ++-assoc .{[]} lnil ys zs = prf where postulate prf : ([] ++ ys) ++ zs ≡ [] ++ ys ++ zs {-# ATP prove prf #-} ++-assoc .{x ∷ xs} (lcons x {xs} Lxs) ys zs = prf (++-assoc Lxs ys zs) where postulate prf : (xs ++ ys) ++ zs ≡ xs ++ ys ++ zs → ((x ∷ xs) ++ ys) ++ zs ≡ (x ∷ xs) ++ ys ++ zs {-# ATP prove prf #-} -- Map properties map-++ : ∀ f {xs} → List xs → ∀ ys → map f (xs ++ ys) ≡ map f xs ++ map f ys map-++ f lnil ys = prf where postulate prf : map f ([] ++ ys) ≡ map f [] ++ map f ys {-# ATP prove prf #-} map-++ f (lcons x {xs} Lxs) ys = prf (map-++ f Lxs ys) where postulate prf : map f (xs ++ ys) ≡ map f xs ++ map f ys → map f ((x ∷ xs) ++ ys) ≡ map f (x ∷ xs) ++ map f ys {-# ATP prove prf #-} -- Reverse properties postulate reverse-[x]≡[x] : ∀ x → reverse (x ∷ []) ≡ x ∷ [] {-# ATP prove reverse-[x]≡[x] #-} rev-++ : ∀ {xs} → List xs → ∀ ys → rev xs ys ≡ rev xs [] ++ ys rev-++ lnil ys = prf where postulate prf : rev [] ys ≡ rev [] [] ++ ys {-# ATP prove prf #-} rev-++ (lcons x {xs} Lxs) ys = prf (rev-++ Lxs (x ∷ ys)) (rev-++ Lxs (x ∷ [])) where postulate prf : rev xs (x ∷ ys) ≡ rev xs [] ++ x ∷ ys → rev xs (x ∷ []) ≡ rev xs [] ++ x ∷ [] → rev (x ∷ xs) ys ≡ rev (x ∷ xs) [] ++ ys {-# ATP prove prf ++-assoc rev-List #-} reverse-++ : ∀ {xs ys} → List xs → List ys → reverse (xs ++ ys) ≡ reverse ys ++ reverse xs reverse-++ {ys = ys} lnil Lys = prf where postulate prf : reverse ([] ++ ys) ≡ reverse ys ++ reverse [] {-# ATP prove prf ++-rightIdentity reverse-List #-} reverse-++ (lcons x {xs} Lxs) lnil = prf where postulate prf : reverse ((x ∷ xs) ++ []) ≡ reverse [] ++ reverse (x ∷ xs) {-# ATP prove prf ++-rightIdentity #-} reverse-++ (lcons x {xs} Lxs) (lcons y {ys} Lys) = prf (reverse-++ Lxs (lcons y Lys)) where postulate prf : reverse (xs ++ y ∷ ys) ≡ reverse (y ∷ ys) ++ reverse xs → reverse ((x ∷ xs) ++ y ∷ ys) ≡ reverse (y ∷ ys) ++ reverse (x ∷ xs) {-# ATP prove prf reverse-List ++-List rev-++ ++-assoc #-} reverse-∷ : ∀ x {ys} → List ys → reverse (x ∷ ys) ≡ reverse ys ++ (x ∷ []) reverse-∷ x lnil = prf where postulate prf : reverse (x ∷ []) ≡ reverse [] ++ x ∷ [] {-# ATP prove prf #-} reverse-∷ x (lcons y {ys} Lys) = prf where postulate prf : reverse (x ∷ y ∷ ys) ≡ reverse (y ∷ ys) ++ x ∷ [] {-# ATP prove prf reverse-[x]≡[x] reverse-++ #-} reverse-involutive : ∀ {xs} → List xs → reverse (reverse xs) ≡ xs reverse-involutive lnil = prf where postulate prf : reverse (reverse []) ≡ [] {-# ATP prove prf #-} reverse-involutive (lcons x {xs} Lxs) = prf (reverse-involutive Lxs) where postulate prf : reverse (reverse xs) ≡ xs → reverse (reverse (x ∷ xs)) ≡ x ∷ xs {-# ATP prove prf rev-List reverse-++ ++-List ++-rightIdentity #-}
{ "alphanum_fraction": 0.4891681826, "avg_line_length": 37.0981595092, "ext": "agda", "hexsha": "562c86d8191452126c2973401973875b76465dbf", "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/List/PropertiesATP.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/List/PropertiesATP.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/List/PropertiesATP.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": 2015, "size": 6047 }
module Issue3188.Issue3188a where postulate String : Set {-# BUILTIN STRING String #-}
{ "alphanum_fraction": 0.7613636364, "avg_line_length": 17.6, "ext": "agda", "hexsha": "33963200bfb5712ba4931b8a41344ce9716b1c6a", "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/Issue3188/Issue3188a.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/Issue3188/Issue3188a.agda", "max_line_length": 33, "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/Issue3188/Issue3188a.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 23, "size": 88 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Substitution.Reducibility {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Untyped.Properties open import Definition.Typed open import Definition.LogicalRelation open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.Substitution open import Definition.LogicalRelation.Substitution.Properties open import Tools.Product -- Valid types are reducible. reducibleᵛ : ∀ {A Γ l} ([Γ] : ⊩ᵛ Γ) → Γ ⊩ᵛ⟨ l ⟩ A / [Γ] → Γ ⊩⟨ l ⟩ A reducibleᵛ [Γ] [A] = let ⊢Γ = soundContext [Γ] [id] = idSubstS [Γ] in irrelevance′ (subst-id _) (proj₁ ([A] ⊢Γ [id])) -- Valid type equality is reducible. reducibleEqᵛ : ∀ {A B Γ l} ([Γ] : ⊩ᵛ Γ) ([A] : Γ ⊩ᵛ⟨ l ⟩ A / [Γ]) → Γ ⊩ᵛ⟨ l ⟩ A ≡ B / [Γ] / [A] → Γ ⊩⟨ l ⟩ A ≡ B / reducibleᵛ [Γ] [A] reducibleEqᵛ {A = A} [Γ] [A] [A≡B] = let [σA] = reducibleᵛ {A = A} [Γ] [A] ⊢Γ = soundContext [Γ] [id] = idSubstS [Γ] in irrelevanceEq″ (subst-id _) (subst-id _) (proj₁ ([A] ⊢Γ [id])) [σA] ([A≡B] ⊢Γ [id]) -- Valid terms are reducible. reducibleTermᵛ : ∀ {t A Γ l} ([Γ] : ⊩ᵛ Γ) ([A] : Γ ⊩ᵛ⟨ l ⟩ A / [Γ]) → Γ ⊩ᵛ⟨ l ⟩ t ∷ A / [Γ] / [A] → Γ ⊩⟨ l ⟩ t ∷ A / reducibleᵛ [Γ] [A] reducibleTermᵛ {A = A} [Γ] [A] [t] = let [σA] = reducibleᵛ {A = A} [Γ] [A] ⊢Γ = soundContext [Γ] [id] = idSubstS [Γ] in irrelevanceTerm″ (subst-id _) (subst-id _) (proj₁ ([A] ⊢Γ [id])) [σA] (proj₁ ([t] ⊢Γ [id])) -- Valid term equality is reducible. reducibleEqTermᵛ : ∀ {t u A Γ l} ([Γ] : ⊩ᵛ Γ) ([A] : Γ ⊩ᵛ⟨ l ⟩ A / [Γ]) → Γ ⊩ᵛ⟨ l ⟩ t ≡ u ∷ A / [Γ] / [A] → Γ ⊩⟨ l ⟩ t ≡ u ∷ A / reducibleᵛ [Γ] [A] reducibleEqTermᵛ {A = A} [Γ] [A] [t≡u] = let [σA] = reducibleᵛ {A = A} [Γ] [A] ⊢Γ = soundContext [Γ] [id] = idSubstS [Γ] in irrelevanceEqTerm″ (subst-id _) (subst-id _) (subst-id _) (proj₁ ([A] ⊢Γ [id])) [σA] ([t≡u] ⊢Γ [id])
{ "alphanum_fraction": 0.5006599208, "avg_line_length": 33.9253731343, "ext": "agda", "hexsha": "a9c36a3cd8abe864094347be1a83df7672f1ab6d", "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": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Vtec234/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Substitution/Reducibility.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "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": "Vtec234/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Substitution/Reducibility.agda", "max_line_length": 86, "max_stars_count": null, "max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Vtec234/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Substitution/Reducibility.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 943, "size": 2273 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.DunceCap where open import Cubical.HITs.DunceCap.Base public open import Cubical.HITs.DunceCap.Properties public
{ "alphanum_fraction": 0.7795698925, "avg_line_length": 26.5714285714, "ext": "agda", "hexsha": "8efd882a7c00e8342321be846950a3e3b076da13", "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/HITs/DunceCap.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/HITs/DunceCap.agda", "max_line_length": 51, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/HITs/DunceCap.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 51, "size": 186 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Substitution.Introductions.Snd {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped as U hiding (wk) open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.Weakening as T hiding (wk; wkTerm; wkEqTerm) open import Definition.Typed.RedSteps open import Definition.LogicalRelation open import Definition.LogicalRelation.ShapeView open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.Weakening open import Definition.LogicalRelation.Properties open import Definition.LogicalRelation.Application open import Definition.LogicalRelation.Substitution open import Definition.LogicalRelation.Substitution.Properties open import Definition.LogicalRelation.Substitution.Introductions.Pi open import Definition.LogicalRelation.Substitution.Introductions.SingleSubst open import Definition.LogicalRelation.Substitution.Introductions.Fst open import Tools.Product import Tools.PropositionalEquality as PE snd-subst*′ : ∀ {Γ l l′ F G t t′} ([F] : Γ ⊩⟨ l ⟩ F) ([ΣFG] : Γ ⊩⟨ l′ ⟩B⟨ BΣ ⟩ Σ F ▹ G) ([t′] : Γ ⊩⟨ l′ ⟩ t′ ∷ Σ F ▹ G / B-intr BΣ [ΣFG]) → Γ ⊢ t ⇒* t′ ∷ Σ F ▹ G → Γ ⊢ snd t ⇒* snd t′ ∷ G [ fst t ] snd-subst*′ [F] (noemb (Bᵣ F G D ⊢F ⊢G A≡A [F]₁ [G] G-ext)) _ (id x) with B-PE-injectivity BΣ (whnfRed* (red D) Σₙ) ... | PE.refl , PE.refl = id (sndⱼ ⊢F ⊢G x) snd-subst*′ {Γ = Γ} {F = F} {G = G} {t = t} {t′ = t″} [F] [ΣFG]₀@(noemb (Bᵣ F₁ G₁ D ⊢F ⊢G A≡A [F]₁ [G] G-ext)) [t″] t⇒*t″@(_⇨_ {t′ = t′} t⇒t′ t′⇒*t″) with B-PE-injectivity BΣ (whnfRed* (red D) Σₙ) ... | PE.refl , PE.refl = let [ΣFG] = B-intr BΣ [ΣFG]₀ [t] , _ = redSubst*Term t⇒*t″ [ΣFG] [t″] [t′] , _ = redSubst*Term t′⇒*t″ [ΣFG] [t″] [t≡t′] : Γ ⊩⟨ _ ⟩ t ≡ t′ ∷ Σ F ▹ G / [ΣFG] [t≡t′] = proj₂ (redSubstTerm t⇒t′ [ΣFG] [t′]) [fstt] : Γ ⊩⟨ _ ⟩ fst t ∷ F / [F] [fstt] = fst″ [F] [ΣFG] [t] [fstt′] : Γ ⊩⟨ _ ⟩ fst t′ ∷ F / [F] [fstt′] = fst″ [F] [ΣFG] [t′] [Gfstt] : Γ ⊩⟨ _ ⟩ G [ fst t ] [Gfstt] = substSΠ₁ BΣ [ΣFG] [F] [fstt] [Gfstt′] : Γ ⊩⟨ _ ⟩ G [ fst t′ ] [Gfstt′] = substSΠ₁ BΣ [ΣFG] [F] [fstt′] [fstt′≡fstt] : Γ ⊩⟨ _ ⟩ fst t′ ≡ fst t ∷ F / [F] [fstt′≡fstt] = symEqTerm [F] (fst-cong″ [F] [ΣFG] [t≡t′]) [Gfstt′≡Gfstt] : Γ ⊩⟨ _ ⟩ G [ fst t′ ] ≡ G [ fst t ] / [Gfstt′] [Gfstt′≡Gfstt] = substSΠ₂ BΣ [ΣFG] (reflEq [ΣFG]) [F] [F] [fstt′] [fstt] [fstt′≡fstt] [Gfstt′] [Gfstt] in snd-subst ⊢F ⊢G t⇒t′ ⇨ conv* (snd-subst*′ [F] [ΣFG]₀ [t″] t′⇒*t″) (≅-eq (escapeEq [Gfstt′] [Gfstt′≡Gfstt])) snd-subst*′ [F] (emb 0<1 x) = snd-subst*′ [F] x -- NOTE this has a horrible interface (and implementation) snd-subst* : ∀ {Γ l l′ F G t t′} ([F] : Γ ⊩⟨ l ⟩ F) ([ΣFG] : Γ ⊩⟨ l′ ⟩ Σ F ▹ G) ([t′] : Γ ⊩⟨ l′ ⟩ t′ ∷ Σ F ▹ G / [ΣFG]) → Γ ⊢ t ⇒* t′ ∷ Σ F ▹ G → Γ ⊢ snd t ⇒* snd t′ ∷ G [ fst t ] snd-subst* [F] [ΣFG] [t′] t⇒*t′ = let [t′]′ = irrelevanceTerm [ΣFG] (B-intr BΣ (B-elim BΣ [ΣFG])) [t′] in snd-subst*′ [F] (B-elim BΣ [ΣFG]) [t′]′ t⇒*t′ snd′ : ∀ {F G t Γ l l′} ([ΣFG] : Γ ⊩⟨ l ⟩B⟨ BΣ ⟩ Σ F ▹ G) ([t] : Γ ⊩⟨ l ⟩ t ∷ Σ F ▹ G / B-intr BΣ [ΣFG]) ([Gfst] : Γ ⊩⟨ l′ ⟩ G [ fst t ]) → Γ ⊩⟨ l′ ⟩ snd t ∷ G [ fst t ] / [Gfst] snd′ {F = F} {G = G} {t = t} {Γ = Γ} {l = l} {l′ = l′} [ΣFG]@(noemb (Bᵣ F' G' D ⊢F ⊢G A≡A [F'] [G'] G-ext)) [t]@(Σₜ p d pProd p≅p [fstp] [sndp]) [Gfst] with B-PE-injectivity BΣ (whnfRed* (red D) Σₙ) ... | PE.refl , PE.refl = let ⊢Γ = wf ⊢F [p] = Σₜ p (idRedTerm:*: (⊢u-redₜ d)) pProd p≅p [fstp] [sndp] [fstt] , [fstt≡fstp] = redSubst*Term (PE.subst (λ x → Γ ⊢ fst t ⇒* fst p ∷ x) (PE.sym (wk-id F)) (fst-subst* ⊢F ⊢G (redₜ d))) ([F'] id ⊢Γ) [fstp] [Gfstt] = [G'] id ⊢Γ [fstt] [Gfstp] = [G'] id ⊢Γ [fstp] [Gfstt≡Gfstp] = G-ext id ⊢Γ [fstt] [fstp] [fstt≡fstp] [sndp] = convTerm₂ [Gfstt] [Gfstp] [Gfstt≡Gfstp] [sndp] [sndp] : Γ ⊩⟨ l′ ⟩ snd p ∷ G [ fst t ] / [Gfst] [sndp] = irrelevanceTerm′ (PE.cong (λ x → x [ fst t ]) (wk-lift-id G)) [Gfstt] [Gfst] [sndp] in proj₁ (redSubst*Term (snd-subst* (PE.subst (λ x → Γ ⊩⟨ l ⟩ x) (wk-id F) ([F'] id ⊢Γ)) (B-intr BΣ [ΣFG]) [p] (redₜ d)) [Gfst] [sndp]) snd′ (emb 0<1 x) = snd′ x snd″ : ∀ {F G t Γ l l′} ([ΣFG] : Γ ⊩⟨ l ⟩ Σ F ▹ G) ([t] : Γ ⊩⟨ l ⟩ t ∷ Σ F ▹ G / [ΣFG]) ([Gfst] : Γ ⊩⟨ l′ ⟩ G [ fst t ]) → Γ ⊩⟨ l′ ⟩ snd t ∷ G [ fst t ] / [Gfst] snd″ {t = t} {Γ = Γ} {l = l} [ΣFG] [t] [Gfst] = let [t]′ = irrelevanceTerm [ΣFG] (B-intr BΣ (Σ-elim [ΣFG])) [t] in snd′ (Σ-elim [ΣFG]) [t]′ [Gfst] snd-cong′ : ∀ {F G t t′ Γ l l′} ([ΣFG] : Γ ⊩⟨ l ⟩B⟨ BΣ ⟩ Σ F ▹ G) ([t] : Γ ⊩⟨ l ⟩ t ∷ Σ F ▹ G / B-intr BΣ [ΣFG]) ([t′] : Γ ⊩⟨ l ⟩ t′ ∷ Σ F ▹ G / B-intr BΣ [ΣFG]) ([t≡t′] : Γ ⊩⟨ l ⟩ t ≡ t′ ∷ Σ F ▹ G / B-intr BΣ [ΣFG]) ([Gfst] : Γ ⊩⟨ l′ ⟩ G [ fst t ]) → Γ ⊩⟨ l′ ⟩ snd t ≡ snd t′ ∷ G [ fst t ] / [Gfst] snd-cong′ {F} {G} {t} {t′} {Γ} {l} {l′} [ΣFG]@(noemb (Bᵣ F' G' D ⊢F ⊢G A≡A [F] [G] G-ext)) [t]@(Σₜ p d pProd p≅p [fstp] [sndp]) [t′]@(Σₜ p′ d′ pProd′ p′≅p′ [fstp′] [sndp′]) [t≡t′]@(Σₜ₌ p₁ p′₁ d₁ d′₁ pProd₁ pProd′₁ p≅p′ [t]₁ [t′]₁ [fstp]₁ [fstp′]₁ [fst≡] [snd≡]) [Gfst] with B-PE-injectivity BΣ (whnfRed* (red D) Σₙ) | whrDet*Term (redₜ d , productWhnf pProd) (redₜ d₁ , productWhnf pProd₁) | whrDet*Term (redₜ d′ , productWhnf pProd′) (redₜ d′₁ , productWhnf pProd′₁) ... | PE.refl , PE.refl | PE.refl | PE.refl = let ⊢Γ = wf ⊢F [p] : Γ ⊩⟨ l ⟩ p ∷ Σ F ▹ G / B-intr BΣ [ΣFG] [p] = Σₜ p (idRedTerm:*: (⊢u-redₜ d)) pProd p≅p [fstp] [sndp] [p′] : Γ ⊩⟨ l ⟩ p′ ∷ Σ F ▹ G / B-intr BΣ [ΣFG] [p′] = Σₜ p′ (idRedTerm:*: (⊢u-redₜ d′)) pProd′ p′≅p′ [fstp′] [sndp′] [F]′ = irrelevance′ (wk-id F) ([F] id ⊢Γ) [fstt] , [fstt≡fstp] = redSubst*Term (PE.subst (λ x → Γ ⊢ fst t ⇒* fst p ∷ x) (PE.sym (wk-id F)) (fst-subst* ⊢F ⊢G (redₜ d))) ([F] id ⊢Γ) [fstp] [Gfstt≡Gfstp] = G-ext id ⊢Γ [fstt] [fstp] [fstt≡fstp] [sndp]′ : Γ ⊩⟨ l ⟩ snd p ∷ U.wk (lift id) G [ fst t ] / [G] id ⊢Γ [fstt] [sndp]′ = convTerm₂ ([G] id ⊢Γ [fstt]) ([G] id ⊢Γ [fstp]) [Gfstt≡Gfstp] [sndp] sndt⇒*sndp = snd-subst* [F]′ (B-intr BΣ [ΣFG]) [p] (redₜ d) [sndp]″ = irrelevanceTerm′ (PE.cong (λ x → x [ fst t ]) (wk-lift-id G)) ([G] id ⊢Γ [fstt]) [Gfst] [sndp]′ [sndt≡sndp] : Γ ⊩⟨ l′ ⟩ snd t ≡ snd p ∷ G [ fst t ] / [Gfst] [sndt≡sndp] = proj₂ (redSubst*Term sndt⇒*sndp [Gfst] [sndp]″) [snd≡]′ = convEqTerm₂ ([G] id ⊢Γ [fstt]) ([G] id ⊢Γ [fstp]₁) [Gfstt≡Gfstp] [snd≡] [sndp≡sndp′] : Γ ⊩⟨ l′ ⟩ snd p ≡ snd p′ ∷ G [ fst t ] / [Gfst] [sndp≡sndp′] = irrelevanceEqTerm′ (PE.cong (λ x → x [ fst t ]) (wk-lift-id G)) ([G] id ⊢Γ [fstt]) [Gfst] [snd≡]′ [fstt′] , [fstt′≡fstp′] = redSubst*Term (PE.subst (λ x → Γ ⊢ fst t′ ⇒* fst p′ ∷ x) (PE.sym (wk-id F)) (fst-subst* ⊢F ⊢G (redₜ d′))) ([F] id ⊢Γ) [fstp′] [fstt≡fstt′] = irrelevanceEqTerm′ (PE.sym (wk-id F)) [F]′ ([F] id ⊢Γ) (fst-cong′ [F]′ [ΣFG] [t≡t′]) [fstt≡fstp′] = transEqTerm ([F] id ⊢Γ) [fstt≡fstt′] [fstt′≡fstp′] [Gfstt≡Gfstp′] = G-ext id ⊢Γ [fstt] [fstp′] [fstt≡fstp′] [sndp′]′ : Γ ⊩⟨ l ⟩ snd p′ ∷ U.wk (lift id) G [ fst t ] / [G] id ⊢Γ [fstt] [sndp′]′ = convTerm₂ ([G] id ⊢Γ [fstt]) ([G] id ⊢Γ [fstp′]) [Gfstt≡Gfstp′] [sndp′] [sndp′]″ = irrelevanceTerm′ (PE.cong (λ x → x [ fst t ]) (wk-lift-id G)) ([G] id ⊢Γ [fstt]) [Gfst] [sndp′]′ [Gfstt]′ = irrelevance′ (PE.cong (λ x → x [ fst t ]) (wk-lift-id G)) ([G] id ⊢Γ [fstt]) [Gfstt≡Gfstt′] = irrelevanceEq″ (PE.cong (λ x → x [ fst t ]) (wk-lift-id G)) (PE.cong (λ x → x [ fst t′ ]) (wk-lift-id G)) ([G] id ⊢Γ [fstt]) [Gfstt]′ (G-ext id ⊢Γ [fstt] [fstt′] [fstt≡fstt′]) sndt′⇒*sndp′ : Γ ⊢ snd t′ ⇒* snd p′ ∷ G [ fst t ] sndt′⇒*sndp′ = conv* (snd-subst* [F]′ (B-intr BΣ [ΣFG]) [p′] (redₜ d′)) (≅-eq (≅-sym (escapeEq [Gfstt]′ [Gfstt≡Gfstt′]))) [sndt′≡sndp′] : Γ ⊩⟨ l′ ⟩ snd t′ ≡ snd p′ ∷ G [ fst t ] / [Gfst] [sndt′≡sndp′] = proj₂ (redSubst*Term sndt′⇒*sndp′ [Gfst] [sndp′]″) in transEqTerm [Gfst] [sndt≡sndp] (transEqTerm [Gfst] [sndp≡sndp′] (symEqTerm [Gfst] [sndt′≡sndp′])) snd-cong′ {F} {G} (emb 0<1 x) = snd-cong′ x snd-cong″ : ∀ {F G t t′ Γ l l′} ([ΣFG] : Γ ⊩⟨ l ⟩ Σ F ▹ G) ([t] : Γ ⊩⟨ l ⟩ t ∷ Σ F ▹ G / [ΣFG]) ([t′] : Γ ⊩⟨ l ⟩ t′ ∷ Σ F ▹ G / [ΣFG]) ([t≡t′] : Γ ⊩⟨ l ⟩ t ≡ t′ ∷ Σ F ▹ G / [ΣFG]) ([Gfst] : Γ ⊩⟨ l′ ⟩ G [ fst t ]) → Γ ⊩⟨ l′ ⟩ snd t ≡ snd t′ ∷ G [ fst t ] / [Gfst] snd-cong″ {F} {G} [ΣFG] [t] [t′] [t≡t′] [Gfst] = let [t] = irrelevanceTerm [ΣFG] (B-intr BΣ (Σ-elim [ΣFG])) [t] [t′] = irrelevanceTerm [ΣFG] (B-intr BΣ (Σ-elim [ΣFG])) [t′] [t≡t′] = irrelevanceEqTerm [ΣFG] (B-intr BΣ (Σ-elim [ΣFG])) [t≡t′] in snd-cong′ (B-elim BΣ [ΣFG]) [t] [t′] [t≡t′] [Gfst] snd-congᵛ : ∀ {F G t t′ Γ l} ([Γ] : ⊩ᵛ Γ) ([F] : Γ ⊩ᵛ⟨ l ⟩ F / [Γ]) ([G] : Γ ∙ F ⊩ᵛ⟨ l ⟩ G / [Γ] ∙ [F]) ([t] : Γ ⊩ᵛ⟨ l ⟩ t ∷ Σ F ▹ G / [Γ] / Σᵛ {F} {G} [Γ] [F] [G]) ([t′] : Γ ⊩ᵛ⟨ l ⟩ t′ ∷ Σ F ▹ G / [Γ] / Σᵛ {F} {G} [Γ] [F] [G]) ([t≡t′] : Γ ⊩ᵛ⟨ l ⟩ t ≡ t′ ∷ Σ F ▹ G / [Γ] / Σᵛ {F} {G} [Γ] [F] [G]) → Γ ⊩ᵛ⟨ l ⟩ snd t ≡ snd t′ ∷ G [ fst t ] / [Γ] / substS {F} {G} [Γ] [F] [G] (fstᵛ {F} {G} {t} [Γ] [F] [G] [t]) snd-congᵛ {F} {G} {t} {t′} {Γ} {l} [Γ] [F] [G] [t] [t′] [t≡t′] {Δ} {σ} ⊢Δ [σ] = let [ΣFG] = Σᵛ {F} {G} [Γ] [F] [G] [fst] = fstᵛ {F} {G} {t} [Γ] [F] [G] [t] [Gfst] = substS {F} {G} [Γ] [F] [G] [fst] ⊩σΣFG = proj₁ ([ΣFG] ⊢Δ [σ]) ⊩σt = proj₁ ([t] ⊢Δ [σ]) ⊩σt′ = proj₁ ([t′] ⊢Δ [σ]) σt≡σt′ = [t≡t′] ⊢Δ [σ] ⊩σGfst₁ = proj₁ ([Gfst] ⊢Δ [σ]) ⊩σGfst = irrelevance′ (singleSubstLift G (fst t)) ⊩σGfst₁ σsnd≡₁ = snd-cong″ ⊩σΣFG ⊩σt ⊩σt′ σt≡σt′ ⊩σGfst σsnd≡ = irrelevanceEqTerm′ (PE.sym (singleSubstLift G (fst t))) ⊩σGfst ⊩σGfst₁ σsnd≡₁ in σsnd≡ -- Validity of second projection sndᵛ : ∀ {F G t Γ l} ([Γ] : ⊩ᵛ Γ) ([F] : Γ ⊩ᵛ⟨ l ⟩ F / [Γ]) ([G] : Γ ∙ F ⊩ᵛ⟨ l ⟩ G / [Γ] ∙ [F]) ([t] : Γ ⊩ᵛ⟨ l ⟩ t ∷ Σ F ▹ G / [Γ] / Σᵛ {F} {G} [Γ] [F] [G]) → Γ ⊩ᵛ⟨ l ⟩ snd t ∷ G [ fst t ] / [Γ] / substS {F} {G} [Γ] [F] [G] (fstᵛ {F} {G} {t} [Γ] [F] [G] [t]) sndᵛ {F} {G} {t} {Γ} {l} [Γ] [F] [G] [t] {Δ = Δ} {σ = σ} ⊢Δ [σ] = let [ΣFG] = Σᵛ {F} {G} [Γ] [F] [G] [Gfst] : Γ ⊩ᵛ⟨ l ⟩ G [ fst t ] / [Γ] [Gfst] = substS {F} {G} [Γ] [F] [G] (fstᵛ {F} {G} {t} [Γ] [F] [G] [t]) σsnd : ∀ {Δ σ} (⊢Δ : ⊢ Δ) ([σ] : Δ ⊩ˢ σ ∷ Γ / [Γ] / ⊢Δ) → Δ ⊩⟨ l ⟩ subst σ (snd t) ∷ subst σ (G [ fst t ]) / proj₁ ([Gfst] ⊢Δ [σ]) σsnd {Δ} {σ} ⊢Δ [σ] = let ⊩σΣFG = proj₁ ([ΣFG] ⊢Δ [σ]) ⊩σt = proj₁ ([t] ⊢Δ [σ]) ⊩σGfstt = proj₁ ([Gfst] ⊢Δ [σ]) ⊩σGfstt′ = PE.subst (λ x → Δ ⊩⟨ l ⟩ x) (singleSubstLift G (fst t)) ⊩σGfstt ⊩σsnd = snd″ ⊩σΣFG ⊩σt ⊩σGfstt′ in irrelevanceTerm′ (PE.sym (singleSubstLift G (fst t))) ⊩σGfstt′ ⊩σGfstt ⊩σsnd in σsnd ⊢Δ [σ] , (λ {σ′} [σ′] [σ≡σ′] → let [σF] = proj₁ ([F] ⊢Δ [σ]) [σΣFG] = proj₁ ([ΣFG] ⊢Δ [σ]) [σ′ΣFG] = proj₁ ([ΣFG] ⊢Δ [σ′]) [σΣFG≡σ′ΣFG] = proj₂ ([ΣFG] ⊢Δ [σ]) [σ′] [σ≡σ′] [σt] = proj₁ ([t] ⊢Δ [σ]) [σ′t] = proj₁ ([t] ⊢Δ [σ′]) [σ′t] : Δ ⊩⟨ l ⟩ subst σ′ t ∷ subst σ (Σ F ▹ G) / [σΣFG] [σ′t] = convTerm₂ [σΣFG] [σ′ΣFG] [σΣFG≡σ′ΣFG] [σ′t] [σt≡σ′t] = proj₂ ([t] ⊢Δ [σ]) [σ′] [σ≡σ′] [σGfstt] = proj₁ ([Gfst] ⊢Δ [σ]) [σGfstt]′ = PE.subst (λ x → _ ⊩⟨ l ⟩ x) (singleSubstLift G (fst t)) [σGfstt] [sndt≡sndt′] = snd-cong″ [σΣFG] [σt] [σ′t] [σt≡σ′t] [σGfstt]′ in irrelevanceEqTerm′ (PE.sym (singleSubstLift G (fst t))) [σGfstt]′ [σGfstt] [sndt≡sndt′])
{ "alphanum_fraction": 0.4149855908, "avg_line_length": 49.0326086957, "ext": "agda", "hexsha": "65d1cb5936f25692ab6cebcb257ff6f20d646a46", "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": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Vtec234/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Snd.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "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": "Vtec234/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Snd.agda", "max_line_length": 120, "max_stars_count": null, "max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Vtec234/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Snd.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6538, "size": 13533 }
{-# OPTIONS --universe-polymorphism #-} module Issue333 where open import Common.Level data Σ a b (A : Set a) (B : A → Set b) : Set (a ⊔ b) where _,_ : (x : A) → B x → Σ a b A B P : ∀ a b (A : Set a) (B : Set b) → Set (a ⊔ b) P a b A B = Σ a b A (λ _ → B) postulate A B : Set foo : Σ lzero lzero A λ (y : A) → P lzero lzero A B bar : Set₁ bar = helper foo where helper : (Σ _ _ A λ (y : A) → P _ _ _ _) → Set₁ helper (y , (x⇓ , fy⇑)) = Set
{ "alphanum_fraction": 0.5240174672, "avg_line_length": 20.8181818182, "ext": "agda", "hexsha": "dc59f927a824f6ace91198525199a1459ab1b264", "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/Issue333.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/Issue333.agda", "max_line_length": 58, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue333.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": 201, "size": 458 }
{-# OPTIONS --rewriting #-} open import Common.Prelude open import Common.Equality {-# BUILTIN REWRITE _≡_ #-} postulate f : Bool → Bool boolTrivial : ∀ (b c : Bool) → f b ≡ c {-# REWRITE boolTrivial #-} -- Should trigger an error that c is not bound on the lhs.
{ "alphanum_fraction": 0.6544117647, "avg_line_length": 18.1333333333, "ext": "agda", "hexsha": "48501a2e4afd8739e2bfdecdb4a282ed1b9c9fe0", "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/RewriteRuleUnboundVars.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/RewriteRuleUnboundVars.agda", "max_line_length": 58, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/RewriteRuleUnboundVars.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": 78, "size": 272 }
module L.Base.Nat where -- Reexport definitions open import L.Base.Nat.Core public -- Functions on Nats pred : Nat → Nat pred = ind (λ _ → Nat) zero (λ x _ → x) infixl 6 _+_ infixl 7 _*_ _+_ : Nat → Nat → Nat zero + y = y succ x + y = succ (x + y) {-# BUILTIN NATPLUS _+_ #-} _*_ : Nat → Nat → Nat zero * y = zero succ x * y = y + x * y {-# BUILTIN NATTIMES _*_ #-}
{ "alphanum_fraction": 0.5835543767, "avg_line_length": 15.7083333333, "ext": "agda", "hexsha": "abd25bb12d24e2d1a8764649984bdba47e730053", "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/Nat.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/Nat.agda", "max_line_length": 39, "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/Nat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 137, "size": 377 }
{-# OPTIONS --without-K #-} module sets.nat.solver where open import decidable open import equality open import function.core hiding (const) open import sets.nat.core open import sets.nat.properties open import sets.nat.ordering open import sets.fin.core hiding (_≟_) open import sets.vec.core open import sets.vec.dependent data Exp (n : ℕ) : Set where var : Fin n → Exp n const : ℕ → Exp n _:+_ : Exp n → Exp n → Exp n infixl 6 _:+_ eval : ∀ {n} → (Fin n → ℕ) → Exp n → ℕ eval env (var i) = env i eval env (const x) = x eval env (e₁ :+ e₂) = eval env e₁ + eval env e₂ NF : ℕ → Set NF n = Vec ℕ n evalNF' : ∀ {n} → (Fin n → ℕ) → NF n → ℕ evalNF' _ [] = 0 evalNF' env (x ∷ xs) = x * env zero + evalNF' (env ∘' suc) xs evalNF : ∀ {n} → (Fin n → ℕ) → NF (suc n) → ℕ evalNF env xs = evalNF' (1 ∷∷ env) xs decNF : ∀ {n}(xs ys : NF n) → Dec (xs ≡ ys) decNF [] [] = yes refl decNF (x ∷ xs) (y ∷ ys) with x ≟ y | decNF xs ys decNF (x ∷ xs) (y ∷ ys) | _ | no u = no λ p → u (ap tail p) decNF (x ∷ xs) (y ∷ ys) | no u | _ = no λ p → u (ap head p) decNF (x ∷ xs) (y ∷ ys) | yes p | yes q = yes (ap₂ _∷_ p q) emptyNF : ∀ {n} → NF n emptyNF {zero} = [] emptyNF {suc n} = 0 ∷ emptyNF eval-emptyNF : ∀ {n}(env : Fin n → ℕ) → evalNF' env emptyNF ≡ 0 eval-emptyNF {zero} env = refl eval-emptyNF {suc n} env = eval-emptyNF {n} (env ∘' suc) δ : ∀ {n} → Fin n → ℕ → NF n δ zero val = val ∷ emptyNF δ (suc i) val = 0 ∷ δ i val eval-δ : ∀ {n}(i : Fin n)(val : ℕ) → (env : Fin n → ℕ) → evalNF' env (δ i val) ≡ val * env i eval-δ zero val env = ap (_+_ (val * env zero)) (eval-emptyNF env) · +-right-unit _ eval-δ (suc i) val env = eval-δ i val (env ∘' suc) _+NF_ : ∀ {n} → NF n → NF n → NF n [] +NF [] = [] (x ∷ xs) +NF (y ∷ ys) = (x + y) ∷ (xs +NF ys) eval+NF : ∀ {n}(xs ys : NF n)(env : Fin n → ℕ) → evalNF' env (xs +NF ys) ≡ evalNF' env xs + evalNF' env ys eval+NF [] [] env = refl eval+NF (x ∷ xs) (y ∷ ys) env = ap₂ _+_ (right-distr x y (env zero)) (eval+NF xs ys (env ∘' suc)) · lem (x * env zero) (y * env zero) (evalNF' (env ∘' suc) xs) (evalNF' (env ∘' suc) ys) where lem : ∀ a b c d → (a + b) + (c + d) ≡ (a + c) + (b + d) lem a b c d = +-associativity a b (c + d) · ap (_+_ a) (sym (+-associativity b c d)) · ap (λ z → a + (z + d)) (+-commutativity b c) · ap (_+_ a) (+-associativity c b d) · sym (+-associativity a c (b + d)) nf : ∀ {n} → Exp n → NF (suc n) nf (var i) = δ (suc i) 1 nf (const k) = δ zero k nf (e₁ :+ e₂) = nf e₁ +NF nf e₂ nf-sound : ∀ {n}(env : Fin n → ℕ)(e : Exp n) → evalNF env (nf e) ≡ eval env e nf-sound env (var i) = eval-δ i 1 env · +-right-unit (env i) nf-sound env (const x) = ap (_+_ (x * 1)) (eval-emptyNF env) · +-right-unit (x * 1) · *-right-unit x nf-sound env (e₁ :+ e₂) = eval+NF (nf e₁) (nf e₂) (1 ∷∷ env) · ap₂ _+_ (nf-sound env e₁) (nf-sound env e₂) HOTerm : ℕ → ℕ → Set HOTerm n zero = Exp n HOTerm n (suc i) = Exp n → HOTerm n i private exp' : (n i : ℕ) → i ≤ n → HOTerm n i → (Fin i → Exp n) → Exp n exp' _ zero _ e _ = e exp' zero (suc i) () e f exp' (suc n) (suc i) p e f = exp' (suc n) i (trans≤ suc≤ p) (e (f zero)) (f ∘' suc) exp : ∀ {n} → HOTerm n n → Exp n exp {n} e = exp' n n refl≤ e var solve : ∀ n (e₁ e₂ : Exp n){t : True (decNF (nf e₁) (nf e₂))} → (env : Fin n → ℕ) → eval env e₁ ≡ eval env e₂ solve n e₁ e₂ {t} env = sym (nf-sound env e₁) · ap (evalNF env) (witness t) · nf-sound env e₂
{ "alphanum_fraction": 0.5120934112, "avg_line_length": 31.0086206897, "ext": "agda", "hexsha": "330252dc868d52c520a7b23322f0f6d21105b54b", "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/nat/solver.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/nat/solver.agda", "max_line_length": 89, "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/nat/solver.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": 1482, "size": 3597 }
{- This module defines the basic opens of the Zariski lattice and proves that they're a basis of the lattice. It also contains the construction of the structure presheaf and a proof of the sheaf property on basic opens, using the theory developed in the module PreSheafFromUniversalProp and its toSheaf.lemma. Note that the structure sheaf is a functor into R-algebras and not just commutative rings. -} {-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.ZariskiLattice.StructureSheaf where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.HLevels open import Cubical.Foundations.Transport open import Cubical.Foundations.Powerset using (ℙ ; ⊆-refl-consequence) renaming (_∈_ to _∈ₚ_ ; subst-∈ to subst-∈ₚ) import Cubical.Data.Empty as ⊥ open import Cubical.Data.Bool open import Cubical.Data.Nat renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_ ; _^_ to _^ℕ_ ; +-comm to +ℕ-comm ; +-assoc to +ℕ-assoc ; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm ; ·-identityʳ to ·ℕ-rid) open import Cubical.Data.Sigma.Base open import Cubical.Data.Sigma.Properties open import Cubical.Data.FinData open import Cubical.Data.Unit open import Cubical.Relation.Nullary open import Cubical.Relation.Binary open import Cubical.Relation.Binary.Poset open import Cubical.Algebra.Ring open import Cubical.Algebra.Ring.Properties open import Cubical.Algebra.Ring.BigOps open import Cubical.Algebra.Algebra open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.BinomialThm open import Cubical.Algebra.CommRing.Ideal open import Cubical.Algebra.CommRing.FGIdeal open import Cubical.Algebra.CommRing.RadicalIdeal open import Cubical.Algebra.CommRing.Localisation.Base open import Cubical.Algebra.CommRing.Localisation.UniversalProperty open import Cubical.Algebra.CommRing.Localisation.InvertingElements open import Cubical.Algebra.CommRing.Localisation.PullbackSquare open import Cubical.Algebra.CommAlgebra.Base open import Cubical.Algebra.CommAlgebra.Properties open import Cubical.Algebra.CommAlgebra.Localisation open import Cubical.Algebra.CommAlgebra.Instances.Unit open import Cubical.Algebra.RingSolver.Reflection open import Cubical.Algebra.Semilattice open import Cubical.Algebra.Lattice open import Cubical.Algebra.DistLattice open import Cubical.Algebra.DistLattice.Basis open import Cubical.Algebra.DistLattice.BigOps open import Cubical.Algebra.ZariskiLattice.Base open import Cubical.Algebra.ZariskiLattice.UniversalProperty open import Cubical.Categories.Category.Base hiding (_[_,_]) open import Cubical.Categories.Functor open import Cubical.Categories.Limits.Pullback open import Cubical.Categories.Instances.CommAlgebras open import Cubical.Categories.Instances.DistLattice open import Cubical.Categories.Instances.Semilattice open import Cubical.Categories.DistLatticeSheaf open import Cubical.HITs.SetQuotients as SQ open import Cubical.HITs.PropositionalTruncation as PT open Iso open BinaryRelation open isEquivRel private variable ℓ ℓ' : Level module _ (R' : CommRing ℓ) where open CommRingStr ⦃...⦄ open RingTheory (CommRing→Ring R') open CommIdeal R' open isCommIdeal open ZarLat R' open ZarLatUniversalProp R' open IsZarMap open Join ZariskiLattice open JoinSemilattice (Lattice→JoinSemilattice (DistLattice→Lattice ZariskiLattice)) open IsBasis private R = fst R' instance _ = snd R' ⟨_⟩ : R → CommIdeal ⟨ f ⟩ = ⟨ replicateFinVec 1 f ⟩[ R' ] ⟨_⟩ₚ : R × R → CommIdeal -- p is for pair ⟨ f , g ⟩ₚ = ⟨ replicateFinVec 1 f ++Fin replicateFinVec 1 g ⟩[ R' ] BasicOpens : ℙ ZL BasicOpens 𝔞 = (∃[ f ∈ R ] (D f ≡ 𝔞)) , isPropPropTrunc BO : Type (ℓ-suc ℓ) BO = Σ[ 𝔞 ∈ ZL ] (𝔞 ∈ₚ BasicOpens) basicOpensAreBasis : IsBasis ZariskiLattice BasicOpens contains1 basicOpensAreBasis = ∣ 1r , isZarMapD .pres1 ∣ ∧lClosed basicOpensAreBasis 𝔞 𝔟 = map2 λ (f , Df≡𝔞) (g , Dg≡𝔟) → (f · g) , isZarMapD .·≡∧ f g ∙ cong₂ (_∧z_) Df≡𝔞 Dg≡𝔟 ⋁Basis basicOpensAreBasis = elimProp (λ _ → isPropPropTrunc) Σhelper where Σhelper : (a : Σ[ n ∈ ℕ ] FinVec R n) → ∃[ n ∈ ℕ ] Σ[ α ∈ FinVec ZL n ] (∀ i → α i ∈ₚ BasicOpens) × (⋁ α ≡ [ a ]) Σhelper (n , α) = ∣ n , (D ∘ α) , (λ i → ∣ α i , refl ∣) , path ∣ where path : ⋁ (D ∘ α) ≡ [ n , α ] path = funExt⁻ (cong fst ZLUniversalPropCorollary) _ -- The structure presheaf on BO ZariskiCat = DistLatticeCategory ZariskiLattice BOCat : Category (ℓ-suc ℓ) (ℓ-suc ℓ) BOCat = ΣPropCat ZariskiCat BasicOpens private P : ZL → Type _ P 𝔞 = Σ[ f ∈ R ] (D f ≡ 𝔞) -- the untruncated defining property 𝓕 : Σ ZL P → CommAlgebra R' _ 𝓕 (_ , f , _) = R[1/ f ]AsCommAlgebra -- D(f) ↦ R[1/f] uniqueHom : ∀ (x y : Σ ZL P) → (fst x) ≤ (fst y) → isContr (CommAlgebraHom (𝓕 y) (𝓕 x)) uniqueHom (𝔞 , f , p) (𝔟 , g , q) = contrHoms 𝔞 𝔟 f g p q where open InvertingElementsBase R' contrHoms : (𝔞 𝔟 : ZL) (f g : R) (p : D f ≡ 𝔞) (q : D g ≡ 𝔟) → 𝔞 ≤ 𝔟 → isContr (CommAlgebraHom R[1/ g ]AsCommAlgebra R[1/ f ]AsCommAlgebra) contrHoms 𝔞 𝔟 f g p q 𝔞≤𝔟 = R[1/g]HasAlgUniversalProp R[1/ f ]AsCommAlgebra λ s s∈[gⁿ|n≥0] → subst-∈ₚ (R[1/ f ]AsCommRing ˣ) (sym (·Rid (s /1))) --can't apply the lemma directly as we get mult with 1 somewhere (RadicalLemma.toUnit R' f g f∈√⟨g⟩ s s∈[gⁿ|n≥0]) where open AlgLoc R' [ g ⁿ|n≥0] (powersFormMultClosedSubset g) renaming (S⁻¹RHasAlgUniversalProp to R[1/g]HasAlgUniversalProp) open S⁻¹RUniversalProp R' [ f ⁿ|n≥0] (powersFormMultClosedSubset f) using (_/1) open RadicalIdeal R' private instance _ = snd R[1/ f ]AsCommRing Df≤Dg : D f ≤ D g Df≤Dg = subst2 _≤_ (sym p) (sym q) 𝔞≤𝔟 radicalHelper : √ ⟨ f , g ⟩ₚ ≡ √ ⟨ g ⟩ radicalHelper = isEquivRel→effectiveIso (λ _ _ → isSetCommIdeal _ _) ∼EquivRel _ _ .fun Df≤Dg f∈√⟨g⟩ : f ∈ √ ⟨ g ⟩ f∈√⟨g⟩ = subst (f ∈_) radicalHelper (∈→∈√ _ _ (indInIdeal _ _ zero)) open PreSheafFromUniversalProp ZariskiCat P 𝓕 uniqueHom BasisStructurePShf : Functor (BOCat ^op) (CommAlgebrasCategory R') BasisStructurePShf = universalPShf -- now prove the sheaf properties open SheafOnBasis ZariskiLattice (CommAlgebrasCategory R' {ℓ' = ℓ}) (TerminalCommAlgebra R') BasicOpens basicOpensAreBasis isSheafBasisStructurePShf : isDLBasisSheaf BasisStructurePShf fst isSheafBasisStructurePShf 0∈BO = transport (λ i → F-ob (0z , canonical0∈BO≡0∈BO i) ≡ UnitCommAlgebra R') R[1/0]≡0 where open Functor ⦃...⦄ instance _ = BasisStructurePShf canonical0∈BO : 0z ∈ₚ BasicOpens canonical0∈BO = ∣ 0r , isZarMapD .pres0 ∣ canonical0∈BO≡0∈BO : canonical0∈BO ≡ 0∈BO canonical0∈BO≡0∈BO = BasicOpens 0z .snd _ _ R[1/0]≡0 : R[1/ 0r ]AsCommAlgebra ≡ UnitCommAlgebra R' R[1/0]≡0 = uaCommAlgebra (e , eIsRHom) where open InvertingElementsBase R' using (isContrR[1/0]) open IsAlgebraHom e : R[1/ 0r ]AsCommAlgebra .fst ≃ UnitCommAlgebra R' .fst e = isContr→Equiv isContrR[1/0] isContrUnit* eIsRHom : IsCommAlgebraEquiv (R[1/ 0r ]AsCommAlgebra .snd) e (UnitCommAlgebra R' .snd) pres0 eIsRHom = refl pres1 eIsRHom = refl pres+ eIsRHom _ _ = refl pres· eIsRHom _ _ = refl pres- eIsRHom _ = refl pres⋆ eIsRHom _ _ = refl snd isSheafBasisStructurePShf (𝔞 , 𝔞∈BO) (𝔟 , 𝔟∈BO) 𝔞∨𝔟∈BO = curriedHelper 𝔞 𝔟 𝔞∈BO 𝔟∈BO 𝔞∨𝔟∈BO where open condSquare {- here: BFsq (𝔞 , 𝔞∈BO) (𝔟 , 𝔟∈BO) 𝔞∨𝔟∈BO BasisStructurePShf = 𝓞 (𝔞∨𝔟) → 𝓞 (𝔞) ↓ ↓ 𝓞 (𝔟) → 𝓞 (𝔞∧𝔟) -} curriedHelper : (𝔞 𝔟 : ZL) (𝔞∈BO : 𝔞 ∈ₚ BasicOpens) (𝔟∈BO : 𝔟 ∈ₚ BasicOpens) (𝔞∨𝔟∈BO : 𝔞 ∨z 𝔟 ∈ₚ BasicOpens) → isPullback (CommAlgebrasCategory R') _ _ _ (BFsq (𝔞 , 𝔞∈BO) (𝔟 , 𝔟∈BO) 𝔞∨𝔟∈BO BasisStructurePShf) curriedHelper 𝔞 𝔟 = elim3 (λ 𝔞∈BO 𝔟∈BO 𝔞∨𝔟∈BO → isPropIsPullback _ _ _ _ (BFsq (𝔞 , 𝔞∈BO) (𝔟 , 𝔟∈BO) 𝔞∨𝔟∈BO BasisStructurePShf)) Σhelper where -- write everything explicitly so things can type-check thePShfCospan : (a : Σ[ f ∈ R ] D f ≡ 𝔞) (b : Σ[ g ∈ R ] D g ≡ 𝔟) → Cospan (CommAlgebrasCategory R') Cospan.l (thePShfCospan (f , Df≡𝔞) (g , Dg≡𝔟)) = BasisStructurePShf .Functor.F-ob (𝔟 , ∣ g , Dg≡𝔟 ∣) Cospan.m (thePShfCospan (f , Df≡𝔞) (g , Dg≡𝔟)) = BasisStructurePShf .Functor.F-ob (𝔞 ∧z 𝔟 , basicOpensAreBasis .∧lClosed 𝔞 𝔟 ∣ f , Df≡𝔞 ∣ ∣ g , Dg≡𝔟 ∣) Cospan.r (thePShfCospan (f , Df≡𝔞) (g , Dg≡𝔟)) = BasisStructurePShf .Functor.F-ob (𝔞 , ∣ f , Df≡𝔞 ∣) Cospan.s₁ (thePShfCospan (f , Df≡𝔞) (g , Dg≡𝔟)) = BasisStructurePShf .Functor.F-hom {x = (𝔟 , ∣ g , Dg≡𝔟 ∣)} {y = (𝔞 ∧z 𝔟 , basicOpensAreBasis .∧lClosed 𝔞 𝔟 ∣ f , Df≡𝔞 ∣ ∣ g , Dg≡𝔟 ∣)} (hom-∧₂ ZariskiLattice (CommAlgebrasCategory R' {ℓ' = ℓ}) (TerminalCommAlgebra R') 𝔞 𝔟) Cospan.s₂ (thePShfCospan (f , Df≡𝔞) (g , Dg≡𝔟)) = BasisStructurePShf .Functor.F-hom {x = (𝔞 , ∣ f , Df≡𝔞 ∣)} {y = (𝔞 ∧z 𝔟 , basicOpensAreBasis .∧lClosed 𝔞 𝔟 ∣ f , Df≡𝔞 ∣ ∣ g , Dg≡𝔟 ∣)} (hom-∧₁ ZariskiLattice (CommAlgebrasCategory R' {ℓ' = ℓ}) (TerminalCommAlgebra R') 𝔞 𝔟) Σhelper : (a : Σ[ f ∈ R ] D f ≡ 𝔞) (b : Σ[ g ∈ R ] D g ≡ 𝔟) (c : Σ[ h ∈ R ] D h ≡ 𝔞 ∨z 𝔟) → isPullback (CommAlgebrasCategory R') (thePShfCospan a b) _ _ (BFsq (𝔞 , ∣ a ∣) (𝔟 , ∣ b ∣) ∣ c ∣ BasisStructurePShf) Σhelper (f , Df≡𝔞) (g , Dg≡𝔟) (h , Dh≡𝔞∨𝔟) = toSheaf.lemma (𝔞 ∨z 𝔟 , ∣ h , Dh≡𝔞∨𝔟 ∣) (𝔞 , ∣ f , Df≡𝔞 ∣) (𝔟 , ∣ g , Dg≡𝔟 ∣) (𝔞 ∧z 𝔟 , basicOpensAreBasis .∧lClosed 𝔞 𝔟 ∣ f , Df≡𝔞 ∣ ∣ g , Dg≡𝔟 ∣) (Bsq (𝔞 , ∣ f , Df≡𝔞 ∣) (𝔟 , ∣ g , Dg≡𝔟 ∣) ∣ h , Dh≡𝔞∨𝔟 ∣) theAlgebraCospan theAlgebraPullback refl gPath fPath fgPath where open Exponentiation R' open RadicalIdeal R' open InvertingElementsBase R' open DoubleLoc R' h open S⁻¹RUniversalProp R' [ h ⁿ|n≥0] (powersFormMultClosedSubset h) open CommIdeal R[1/ h ]AsCommRing using () renaming (CommIdeal to CommIdealₕ ; _∈_ to _∈ₕ_) instance _ = snd R[1/ h ]AsCommRing ⟨_⟩ₕ : R[1/ h ] × R[1/ h ] → CommIdealₕ ⟨ x , y ⟩ₕ = ⟨ replicateFinVec 1 x ++Fin replicateFinVec 1 y ⟩[ R[1/ h ]AsCommRing ] -- the crucial algebraic fact: radicalPath : √ ⟨ h ⟩ ≡ √ ⟨ f , g ⟩ₚ radicalPath = isEquivRel→effectiveIso (λ _ _ → isSetCommIdeal _ _) ∼EquivRel _ _ .fun DHelper where DHelper : D h ≡ D f ∨z D g DHelper = Dh≡𝔞∨𝔟 ∙ cong₂ (_∨z_) (sym Df≡𝔞) (sym Dg≡𝔟) f∈√⟨h⟩ : f ∈ √ ⟨ h ⟩ f∈√⟨h⟩ = subst (f ∈_) (sym radicalPath) (∈→∈√ _ _ (indInIdeal _ _ zero)) g∈√⟨h⟩ : g ∈ √ ⟨ h ⟩ g∈√⟨h⟩ = subst (g ∈_) (sym radicalPath) (∈→∈√ _ _ (indInIdeal _ _ (suc zero))) fg∈√⟨h⟩ : (f · g) ∈ √ ⟨ h ⟩ fg∈√⟨h⟩ = √ ⟨ h ⟩ .snd .·Closed f g∈√⟨h⟩ 1∈fgIdeal : 1r ∈ₕ ⟨ (f /1) , (g /1) ⟩ₕ 1∈fgIdeal = helper1 (subst (h ∈_) radicalPath (∈→∈√ _ _ (indInIdeal _ _ zero))) where helper1 : h ∈ √ ⟨ f , g ⟩ₚ → 1r ∈ₕ ⟨ (f /1) , (g /1) ⟩ₕ helper1 = PT.rec isPropPropTrunc (uncurry helper2) where helper2 : (n : ℕ) → h ^ n ∈ ⟨ f , g ⟩ₚ → 1r ∈ₕ ⟨ (f /1) , (g /1) ⟩ₕ helper2 n = map helper3 where helper3 : Σ[ α ∈ FinVec R 2 ] h ^ n ≡ linearCombination R' α (λ { zero → f ; (suc zero) → g }) → Σ[ β ∈ FinVec R[1/ h ] 2 ] 1r ≡ linearCombination R[1/ h ]AsCommRing β λ { zero → f /1 ; (suc zero) → g /1 } helper3 (α , p) = β , path where β : FinVec R[1/ h ] 2 β zero = [ α zero , h ^ n , ∣ n , refl ∣ ] β (suc zero) = [ α (suc zero) , h ^ n , ∣ n , refl ∣ ] path : 1r ≡ linearCombination R[1/ h ]AsCommRing β λ { zero → f /1 ; (suc zero) → g /1 } path = eq/ _ _ ((1r , ∣ 0 , refl ∣) , bigPath) ∙ cong (β zero · (f /1) +_) (sym (+Rid (β (suc zero) · (g /1)))) where useSolver1 : ∀ hn → 1r · 1r · ((hn · 1r) · (hn · 1r)) ≡ hn · hn useSolver1 = solve R' useSolver2 : ∀ az f hn as g → hn · (az · f + (as · g + 0r)) ≡ 1r · (az · f · (hn · 1r) + as · g · (hn · 1r)) · 1r useSolver2 = solve R' bigPath : 1r · 1r · ((h ^ n · 1r) · (h ^ n · 1r)) ≡ 1r · (α zero · f · (h ^ n · 1r) + α (suc zero) · g · (h ^ n · 1r)) · 1r bigPath = useSolver1 (h ^ n) ∙ cong (h ^ n ·_) p ∙ useSolver2 _ _ _ _ _ {- We get the following pullback square in CommRings R[1/h] → R[1/h][1/f] ⌟ ↓ ↓ R[1/h][1/g] → R[1/h][1/fg] this lifts to a pullback in R-Algebras using PullbackFromCommRing as all for rings have canonical morphisms coming from R and all the triangles commute. Then using toSheaf.lemma we get the desired square R[1/h] → R[1/f] ⌟ ↓ ↓ R[1/g] → R[1/fg] by only providing paths between the corresponding vertices of the square. These paths are constructed using S⁻¹RAlgCharEquiv, which gives an equivalent characterization of the universal property of localization that can be found in e.g. Cor 3.2 of Atiyah-MacDonald -} theRingCospan = fgCospan R[1/ h ]AsCommRing (f /1) (g /1) theRingPullback = fgPullback R[1/ h ]AsCommRing (f /1) (g /1) 1∈fgIdeal R[1/h][1/f] = InvertingElementsBase.R[1/_] R[1/ h ]AsCommRing (f /1) R[1/h][1/f]AsCommRing = InvertingElementsBase.R[1/_]AsCommRing R[1/ h ]AsCommRing (f /1) R[1/h][1/g] = InvertingElementsBase.R[1/_] R[1/ h ]AsCommRing (g /1) R[1/h][1/g]AsCommRing = InvertingElementsBase.R[1/_]AsCommRing R[1/ h ]AsCommRing (g /1) R[1/h][1/fg] = InvertingElementsBase.R[1/_] R[1/ h ]AsCommRing ((f /1) · (g /1)) R[1/h][1/fg]AsCommRing = InvertingElementsBase.R[1/_]AsCommRing R[1/ h ]AsCommRing ((f /1) · (g /1)) open IsRingHom /1/1AsCommRingHomFG : CommRingHom R' R[1/h][1/fg]AsCommRing fst /1/1AsCommRingHomFG r = [ [ r , 1r , ∣ 0 , refl ∣ ] , 1r , ∣ 0 , refl ∣ ] pres0 (snd /1/1AsCommRingHomFG) = refl pres1 (snd /1/1AsCommRingHomFG) = refl pres+ (snd /1/1AsCommRingHomFG) x y = cong [_] (≡-× (cong [_] (≡-× (cong₂ _+_ (useSolver x) (useSolver y)) (Σ≡Prop (λ _ → isPropPropTrunc) (useSolver 1r)))) (Σ≡Prop (λ _ → isPropPropTrunc) (sym (·Rid 1r)))) where useSolver : ∀ a → a ≡ a · 1r · (1r · 1r) useSolver = solve R' pres· (snd /1/1AsCommRingHomFG) x y = cong [_] (≡-× (cong [_] (≡-× refl (Σ≡Prop (λ _ → isPropPropTrunc) (sym (·Rid 1r))))) (Σ≡Prop (λ _ → isPropPropTrunc) (sym (·Rid 1r)))) pres- (snd /1/1AsCommRingHomFG) x = refl open Cospan open Pullback open RingHoms isRHomR[1/h]→R[1/h][1/f] : theRingPullback .pbPr₂ ∘r /1AsCommRingHom ≡ /1/1AsCommRingHom f isRHomR[1/h]→R[1/h][1/f] = RingHom≡ (funExt (λ x → refl)) isRHomR[1/h]→R[1/h][1/g] : theRingPullback .pbPr₁ ∘r /1AsCommRingHom ≡ /1/1AsCommRingHom g isRHomR[1/h]→R[1/h][1/g] = RingHom≡ (funExt (λ x → refl)) isRHomR[1/h][1/f]→R[1/h][1/fg] : theRingCospan .s₂ ∘r /1/1AsCommRingHom f ≡ /1/1AsCommRingHomFG isRHomR[1/h][1/f]→R[1/h][1/fg] = RingHom≡ (funExt (λ x → cong [_] (≡-× (cong [_] (≡-× (cong (x ·_) (transportRefl 1r) ∙ ·Rid x) (Σ≡Prop (λ _ → isPropPropTrunc) (cong (1r ·_) (transportRefl 1r) ∙ ·Rid 1r)))) (Σ≡Prop (λ _ → isPropPropTrunc) (cong (1r ·_) (transportRefl 1r) ∙ ·Rid 1r))))) isRHomR[1/h][1/g]→R[1/h][1/fg] : theRingCospan .s₁ ∘r /1/1AsCommRingHom g ≡ /1/1AsCommRingHomFG isRHomR[1/h][1/g]→R[1/h][1/fg] = RingHom≡ (funExt (λ x → cong [_] (≡-× (cong [_] (≡-× (cong (x ·_) (transportRefl 1r) ∙ ·Rid x) (Σ≡Prop (λ _ → isPropPropTrunc) (cong (1r ·_) (transportRefl 1r) ∙ ·Rid 1r)))) (Σ≡Prop (λ _ → isPropPropTrunc) (cong (1r ·_) (transportRefl 1r) ∙ ·Rid 1r))))) open PullbackFromCommRing R' theRingCospan theRingPullback /1AsCommRingHom (/1/1AsCommRingHom f) (/1/1AsCommRingHom g) /1/1AsCommRingHomFG theAlgebraCospan = algCospan isRHomR[1/h]→R[1/h][1/f] isRHomR[1/h]→R[1/h][1/g] isRHomR[1/h][1/f]→R[1/h][1/fg] isRHomR[1/h][1/g]→R[1/h][1/fg] theAlgebraPullback = algPullback isRHomR[1/h]→R[1/h][1/f] isRHomR[1/h]→R[1/h][1/g] isRHomR[1/h][1/f]→R[1/h][1/fg] isRHomR[1/h][1/g]→R[1/h][1/fg] --and the three remaining paths fPath : theAlgebraCospan .r ≡ R[1/ f ]AsCommAlgebra fPath = doubleLocCancel f∈√⟨h⟩ where open DoubleAlgLoc R' h f gPath : theAlgebraCospan .l ≡ R[1/ g ]AsCommAlgebra gPath = doubleLocCancel g∈√⟨h⟩ where open DoubleAlgLoc R' h g fgPath : theAlgebraCospan .m ≡ R[1/ (f · g) ]AsCommAlgebra fgPath = path ∙ doubleLocCancel fg∈√⟨h⟩ where open DoubleAlgLoc R' h (f · g) open CommAlgChar R' R[1/h][1/fg]AsCommRing' = InvertingElementsBase.R[1/_]AsCommRing R[1/ h ]AsCommRing ((f · g) /1) path : toCommAlg (R[1/h][1/fg]AsCommRing , /1/1AsCommRingHomFG) ≡ toCommAlg (R[1/h][1/fg]AsCommRing' , /1/1AsCommRingHom (f · g)) path = cong toCommAlg (ΣPathP (p , q)) where eqInR[1/h] : (f /1) · (g /1) ≡ (f · g) /1 eqInR[1/h] = sym (/1AsCommRingHom .snd .pres· f g) p : R[1/h][1/fg]AsCommRing ≡ R[1/h][1/fg]AsCommRing' p i = InvertingElementsBase.R[1/_]AsCommRing R[1/ h ]AsCommRing (eqInR[1/h] i) q : PathP (λ i → CommRingHom R' (p i)) /1/1AsCommRingHomFG (/1/1AsCommRingHom (f · g)) q = toPathP (RingHom≡ (funExt ( λ x → cong [_] (≡-× (cong [_] (≡-× (transportRefl _ ∙ transportRefl x) (Σ≡Prop (λ _ → isPropPropTrunc) (transportRefl 1r)))) (Σ≡Prop (λ _ → isPropPropTrunc) (transportRefl 1r))))))
{ "alphanum_fraction": 0.5867431758, "avg_line_length": 40.8925438596, "ext": "agda", "hexsha": "93df73cade1af8fc31aa2bc4f4a6ce77efa00674", "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/ZariskiLattice/StructureSheaf.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/ZariskiLattice/StructureSheaf.agda", "max_line_length": 112, "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/ZariskiLattice/StructureSheaf.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 7603, "size": 18647 }
{-# OPTIONS --erased-cubical #-} open import Agda.Builtin.Cubical.Path -- Higher constructors must be erased when --erased-cubical is used. data ∥_∥ (A : Set) : Set where ∣_∣ : A → ∥ A ∥ trivial : (x y : ∥ A ∥) → x ≡ y
{ "alphanum_fraction": 0.5956521739, "avg_line_length": 23, "ext": "agda", "hexsha": "fd00f8150e5f6ad2a145714a5efc7e9049219010", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Erased-cubical-Higher-constructor.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "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": "cruhland/agda", "max_issues_repo_path": "test/Fail/Erased-cubical-Higher-constructor.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Erased-cubical-Higher-constructor.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 86, "size": 230 }
------------------------------------------------------------------------ -- Lemmas related to application of substitutions ------------------------------------------------------------------------ -- The record below allows the application operation to be -- "heterogeneous", applying substitutions containing one kind of term -- to another kind of term. TODO: This results in some extra -- complication—is it worth it? open import Data.Universe.Indexed module deBruijn.Substitution.Data.Application.Application21 {i u e} {Uni : IndexedUniverse i u e} where import deBruijn.Context; open deBruijn.Context Uni open import deBruijn.Substitution.Data.Application.Application open import deBruijn.Substitution.Data.Basics open import deBruijn.Substitution.Data.Map open import deBruijn.Substitution.Data.Simple open import Function using (_$_) open import Level using (_⊔_) import Relation.Binary.PropositionalEquality as P open P.≡-Reasoning -- Lemmas and definitions related to application. record Application₂₁ {t₁} {T₁ : Term-like t₁} {t₂} {T₂ : Term-like t₂} -- Simple substitutions for the first kind of terms. (simple₁ : Simple T₁) -- Simple substitutions for the second kind of terms. (simple₂ : Simple T₂) -- A translation from the first to the second kind of terms. (trans : [ T₁ ⟶⁼ T₂ ]) : Set (i ⊔ u ⊔ e ⊔ t₁ ⊔ t₂) where open Term-like T₁ using () renaming (_⊢_ to _⊢₁_; _≅-⊢_ to _≅-⊢₁_) open Term-like T₂ using ([_]) renaming (_⊢_ to _⊢₂_; _≅-⊢_ to _≅-⊢₂_) open Simple simple₁ using () renaming ( id to id₁; sub to sub₁; var to var₁ ; weaken[_] to weaken₁[_]; wk to wk₁ ; wk-subst to wk-subst₁; wk-subst[_] to wk-subst₁[_] ; _↑ to _↑₁; _↑_ to _↑₁_; _↑⁺_ to _↑⁺₁_; _↑₊_ to _↑₊₁_ ; _↑⋆_ to _↑⋆₁_; _↑⁺⋆_ to _↑⁺⋆₁_; _↑₊⋆_ to _↑₊⋆₁_ ) open Simple simple₂ using () renaming ( id to id₂; id[_] to id₂[_]; var to var₂ ; weaken to weaken₂; weaken[_] to weaken₂[_]; wk to wk₂ ; wk-subst to wk-subst₂; wk-subst[_] to wk-subst₂[_] ; _↑ to _↑₂; _↑_ to _↑₂_ ) field application : Application T₁ T₂ open Application application field -- The two weakening functions coincide. trans-weaken : ∀ {Γ σ τ} (t : Γ ⊢₁ τ) → trans · (weaken₁[ σ ] · t) ≅-⊢₂ weaken₂[ σ ] · (trans · t) -- The two variable inclusion functions coincide. trans-var : ∀ {Γ σ} (x : Γ ∋ σ) → trans · (var₁ · x) ≅-⊢₂ var₂ · x -- _/⊢_ and _/∋₁_ coincide for variables. var-/⊢ : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} (x : Γ ∋ σ) (ρ : Sub T₁ ρ̂) → var₂ · x /⊢ ρ ≅-⊢₂ trans · (x /∋ ρ) -- Application of multiple substitutions to variables. -- -- TODO: Remove? app∋⋆ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} → Subs T₁ ρ̂ → [ Var ⟶ T₂ ] ρ̂ app∋⋆ ε = var₂ app∋⋆ (ε ▻ ρ) = trans [∘] app∋ ρ app∋⋆ (ρs ▻ ρ) = app ρ [∘] app∋⋆ ρs infixl 8 _/∋⋆_ _/∋⋆_ : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} → Γ ∋ σ → Subs T₁ ρ̂ → Δ ⊢₂ σ /̂ ρ̂ x /∋⋆ ρs = app∋⋆ ρs · x -- Composition of multiple substitutions. -- -- TODO: Remove? ∘⋆ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} → Subs T₁ ρ̂ → Sub T₂ ρ̂ ∘⋆ ε = id₂ ∘⋆ (ρs ▻ ρ) = ∘⋆ ρs ∘ ρ -- Some congruence lemmas. trans-cong : ∀ {Γ₁ σ₁} {t₁ : Γ₁ ⊢₁ σ₁} {Γ₂ σ₂} {t₂ : Γ₂ ⊢₁ σ₂} → t₁ ≅-⊢₁ t₂ → trans · t₁ ≅-⊢₂ trans · t₂ trans-cong P.refl = P.refl app∋⋆-cong : ∀ {Γ₁ Δ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρs₁ : Subs T₁ ρ̂₁} {Γ₂ Δ₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρs₂ : Subs T₁ ρ̂₂} → ρs₁ ≅-⇨⋆ ρs₂ → app∋⋆ ρs₁ ≅-⟶ app∋⋆ ρs₂ app∋⋆-cong P.refl = [ P.refl ] /∋⋆-cong : ∀ {Γ₁ Δ₁ σ₁} {x₁ : Γ₁ ∋ σ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρs₁ : Subs T₁ ρ̂₁} {Γ₂ Δ₂ σ₂} {x₂ : Γ₂ ∋ σ₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρs₂ : Subs T₁ ρ̂₂} → x₁ ≅-∋ x₂ → ρs₁ ≅-⇨⋆ ρs₂ → x₁ /∋⋆ ρs₁ ≅-⊢₂ x₂ /∋⋆ ρs₂ /∋⋆-cong P.refl P.refl = P.refl ∘⋆-cong : ∀ {Γ₁ Δ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρs₁ : Subs T₁ ρ̂₁} {Γ₂ Δ₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρs₂ : Subs T₁ ρ̂₂} → ρs₁ ≅-⇨⋆ ρs₂ → ∘⋆ ρs₁ ≅-⇨ ∘⋆ ρs₂ ∘⋆-cong P.refl = P.refl abstract -- Applying a composed substitution to a variable is equivalent to -- applying all the substitutions one after another. -- -- TODO: Remove this lemma? /∋-∘⋆ : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} (x : Γ ∋ σ) (ρs : Subs T₁ ρ̂) → x /∋ ∘⋆ ρs ≅-⊢₂ var₂ · x /⊢⋆ ρs /∋-∘⋆ x ε = begin [ x /∋ id₂ ] ≡⟨ Simple./∋-id simple₂ x ⟩ [ var₂ · x ] ∎ /∋-∘⋆ x (ρs ▻ ρ) = begin [ x /∋ ∘⋆ ρs ∘ ρ ] ≡⟨ /∋-∘ x (∘⋆ ρs) ρ ⟩ [ x /∋ ∘⋆ ρs /⊢ ρ ] ≡⟨ /⊢-cong (/∋-∘⋆ x ρs) P.refl ⟩ [ var₂ · x /⊢⋆ ρs /⊢ ρ ] ∎ -- x /∋⋆ ρs is synonymous with var₂ · x /⊢⋆ ρs. -- -- TODO: Remove? var-/⊢⋆ : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} (x : Γ ∋ σ) (ρs : Subs T₁ ρ̂) → var₂ · x /⊢⋆ ρs ≅-⊢₂ x /∋⋆ ρs var-/⊢⋆ x ε = P.refl var-/⊢⋆ x (ε ▻ ρ) = begin [ var₂ · x /⊢ ρ ] ≡⟨ var-/⊢ x ρ ⟩ [ trans · (x /∋ ρ) ] ∎ var-/⊢⋆ x (ρs ▻ ρ₁ ▻ ρ₂) = begin [ var₂ · x /⊢⋆ (ρs ▻ ρ₁) /⊢ ρ₂ ] ≡⟨ /⊢-cong (var-/⊢⋆ x (ρs ▻ ρ₁)) P.refl ⟩ [ x /∋⋆ (ρs ▻ ρ₁) /⊢ ρ₂ ] ∎ -- A helper lemma. /∋-≅-⊢-var : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} (x : Γ ∋ σ) (ρ : Sub T₁ ρ̂) {y : Δ ∋ σ / ρ} → x /∋ ρ ≅-⊢₁ var₁ · y → var₂ · x /⊢ ρ ≅-⊢₂ var₂ · y /∋-≅-⊢-var x ρ {y} hyp = begin [ var₂ · x /⊢ ρ ] ≡⟨ var-/⊢ x ρ ⟩ [ trans · (x /∋ ρ) ] ≡⟨ trans-cong hyp ⟩ [ trans · (var₁ · y) ] ≡⟨ trans-var y ⟩ [ var₂ · y ] ∎ -- A variant of /∋-id. var-/⊢-id : ∀ {Γ σ} (x : Γ ∋ σ) → var₂ · x /⊢ id₁ ≅-⊢₂ var₂ · x var-/⊢-id x = /∋-≅-⊢-var x id₁ (Simple./∋-id simple₁ x) -- A variant of /∋-wk-↑⁺. var-/⊢-wk-↑⁺ : ∀ {Γ σ} Γ⁺ {τ} (x : Γ ++⁺ Γ⁺ ∋ τ) → var₂ · x /⊢ wk₁ {σ = σ} ↑⁺₁ Γ⁺ ≅-⊢₂ var₂ · (lift weaken∋[ σ ] Γ⁺ · x) var-/⊢-wk-↑⁺ Γ⁺ x = /∋-≅-⊢-var x (wk₁ ↑⁺₁ Γ⁺) (Simple./∋-wk-↑⁺ simple₁ Γ⁺ x) -- A variant of /∋-wk-↑⁺-↑⁺. var-/⊢-wk-↑⁺-↑⁺ : ∀ {Γ σ} Γ⁺ Γ⁺⁺ {τ} (x : Γ ++⁺ Γ⁺ ++⁺ Γ⁺⁺ ∋ τ) → var₂ · x /⊢ wk₁ {σ = σ} ↑⁺₁ Γ⁺ ↑⁺₁ Γ⁺⁺ ≅-⊢₂ var₂ · (lift (lift weaken∋[ σ ] Γ⁺) Γ⁺⁺ · x) var-/⊢-wk-↑⁺-↑⁺ Γ⁺ Γ⁺⁺ x = /∋-≅-⊢-var x (wk₁ ↑⁺₁ Γ⁺ ↑⁺₁ Γ⁺⁺) (Simple./∋-wk-↑⁺-↑⁺ simple₁ Γ⁺ Γ⁺⁺ x) -- Variants of zero-/∋-↑. zero-/⊢-↑ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} σ (ρ : Sub T₁ ρ̂) → var₂ · zero /⊢ ρ ↑₁ σ ≅-⊢₂ var₂ · zero[ σ / ρ ] zero-/⊢-↑ σ ρ = /∋-≅-⊢-var zero (ρ ↑₁ σ) (Simple.zero-/∋-↑ simple₁ σ ρ) zero-/⊢⋆-↑⋆ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} σ (ρs : Subs T₁ ρ̂) → var₂ · zero /⊢⋆ ρs ↑⋆₁ σ ≅-⊢₂ var₂ · zero[ σ /⋆ ρs ] zero-/⊢⋆-↑⋆ σ ε = P.refl zero-/⊢⋆-↑⋆ σ (ρs ▻ ρ) = begin [ var₂ · zero /⊢⋆ ρs ↑⋆₁ σ /⊢ ρ ↑₁ ] ≡⟨ /⊢-cong (zero-/⊢⋆-↑⋆ σ ρs) (P.refl {x = [ ρ ↑₁ (σ /⋆ ρs) ]}) ⟩ [ var₂ · zero /⊢ ρ ↑₁ (σ /⋆ ρs) ] ≡⟨ zero-/⊢-↑ (σ /⋆ ρs) ρ ⟩ [ var₂ · zero ] ∎ -- Corollaries of ε-↑⁺⋆ and ε-↑₊⋆. /⊢⋆-ε-↑⁺⋆ : ∀ {Γ} Γ⁺ {σ} (t : Γ ++⁺ Γ⁺ ⊢₂ σ) → t /⊢⋆ ε ↑⁺⋆₁ Γ⁺ ≅-⊢₂ t /⊢⋆-ε-↑⁺⋆ Γ⁺ t = begin [ t /⊢⋆ ε ↑⁺⋆₁ Γ⁺ ] ≡⟨ /⊢⋆-cong (P.refl {x = [ t ]}) (Simple.ε-↑⁺⋆ simple₁ Γ⁺) ⟩ [ t /⊢⋆ ε ] ≡⟨ P.refl ⟩ [ t ] ∎ /⊢⋆-ε-↑₊⋆ : ∀ {Γ} Γ₊ {σ} (t : Γ ++₊ Γ₊ ⊢₂ σ) → t /⊢⋆ ε ↑₊⋆₁ Γ₊ ≅-⊢₂ t /⊢⋆-ε-↑₊⋆ Γ₊ t = begin [ t /⊢⋆ ε ↑₊⋆₁ Γ₊ ] ≡⟨ /⊢⋆-cong (P.refl {x = [ t ]}) (Simple.ε-↑₊⋆ simple₁ Γ₊) ⟩ [ t /⊢⋆ ε ] ≡⟨ P.refl ⟩ [ t ] ∎ -- Corollaries of ▻-↑⁺⋆ and ▻-↑₊⋆. /⊢⋆-▻-↑⁺⋆ : ∀ {Γ Δ Ε} {ρ̂₁ : Γ ⇨̂ Δ} {ρ̂₂ : Δ ⇨̂ Ε} Γ⁺ {σ} (t : Γ ++⁺ Γ⁺ ⊢₂ σ) (ρs : Subs T₁ ρ̂₁) (ρ : Sub T₁ ρ̂₂) → t /⊢⋆ (ρs ▻ ρ) ↑⁺⋆₁ Γ⁺ ≅-⊢₂ t /⊢⋆ ρs ↑⁺⋆₁ Γ⁺ /⊢ ρ ↑⁺₁ (Γ⁺ /⁺⋆ ρs) /⊢⋆-▻-↑⁺⋆ Γ⁺ t ρs ρ = /⊢⋆-cong (P.refl {x = [ t ]}) (Simple.▻-↑⁺⋆ simple₁ ρs ρ Γ⁺) /⊢⋆-▻-↑₊⋆ : ∀ {Γ Δ Ε} {ρ̂₁ : Γ ⇨̂ Δ} {ρ̂₂ : Δ ⇨̂ Ε} Γ₊ {σ} (t : Γ ++₊ Γ₊ ⊢₂ σ) (ρs : Subs T₁ ρ̂₁) (ρ : Sub T₁ ρ̂₂) → t /⊢⋆ (ρs ▻ ρ) ↑₊⋆₁ Γ₊ ≅-⊢₂ t /⊢⋆ ρs ↑₊⋆₁ Γ₊ /⊢ ρ ↑₊₁ (Γ₊ /₊⋆ ρs) /⊢⋆-▻-↑₊⋆ Γ₊ t ρs ρ = /⊢⋆-cong (P.refl {x = [ t ]}) (Simple.▻-↑₊⋆ simple₁ ρs ρ Γ₊) -- Corollaries of ε-↑⁺⋆/ε-↑₊⋆ and ▻-↑⁺⋆/▻-↑₊⋆. /⊢⋆-ε-▻-↑⁺⋆ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} Γ⁺ {σ} (t : Γ ++⁺ Γ⁺ ⊢₂ σ) (ρ : Sub T₁ ρ̂) → t /⊢⋆ (ε ▻ ρ) ↑⁺⋆₁ Γ⁺ ≅-⊢₂ t /⊢ ρ ↑⁺₁ Γ⁺ /⊢⋆-ε-▻-↑⁺⋆ Γ⁺ t ρ = begin [ t /⊢⋆ (ε ▻ ρ) ↑⁺⋆₁ Γ⁺ ] ≡⟨ /⊢⋆-cong (P.refl {x = [ t ]}) (Simple.▻-↑⁺⋆ simple₁ ε ρ Γ⁺) ⟩ [ t /⊢⋆ ε ↑⁺⋆₁ Γ⁺ /⊢ ρ ↑⁺₁ (Γ⁺ /̂⁺ îd) ] ≡⟨ /⊢-cong (/⊢⋆-ε-↑⁺⋆ Γ⁺ t) (Simple.↑⁺-cong simple₁ P.refl (/̂⁺-îd Γ⁺)) ⟩ [ t /⊢ ρ ↑⁺₁ Γ⁺ ] ∎ /⊢⋆-ε-▻-▻-↑⁺⋆ : ∀ {Γ Δ Ε} {ρ̂₁ : Γ ⇨̂ Δ} {ρ̂₂ : Δ ⇨̂ Ε} Γ⁺ {σ} (t : Γ ++⁺ Γ⁺ ⊢₂ σ) (ρ₁ : Sub T₁ ρ̂₁) (ρ₂ : Sub T₁ ρ̂₂) → t /⊢⋆ (ε ▻ ρ₁ ▻ ρ₂) ↑⁺⋆₁ Γ⁺ ≅-⊢₂ t /⊢ ρ₁ ↑⁺₁ Γ⁺ /⊢ ρ₂ ↑⁺₁ (Γ⁺ /⁺ ρ₁) /⊢⋆-ε-▻-▻-↑⁺⋆ Γ⁺ t ρ₁ ρ₂ = begin [ t /⊢⋆ (ε ▻ ρ₁ ▻ ρ₂) ↑⁺⋆₁ Γ⁺ ] ≡⟨ /⊢⋆-cong (P.refl {x = [ t ]}) (Simple.▻-↑⁺⋆ simple₁ (ε ▻ ρ₁) ρ₂ Γ⁺) ⟩ [ t /⊢⋆ (ε ▻ ρ₁) ↑⁺⋆₁ Γ⁺ /⊢ ρ₂ ↑⁺₁ (Γ⁺ /⁺ ρ₁) ] ≡⟨ /⊢-cong (/⊢⋆-ε-▻-↑⁺⋆ Γ⁺ t ρ₁) P.refl ⟩ [ t /⊢ ρ₁ ↑⁺₁ Γ⁺ /⊢ ρ₂ ↑⁺₁ (Γ⁺ /⁺ ρ₁) ] ∎ /⊢⋆-ε-▻-↑₊⋆ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} Γ₊ {σ} (t : Γ ++₊ Γ₊ ⊢₂ σ) (ρ : Sub T₁ ρ̂) → t /⊢⋆ (ε ▻ ρ) ↑₊⋆₁ Γ₊ ≅-⊢₂ t /⊢ ρ ↑₊₁ Γ₊ /⊢⋆-ε-▻-↑₊⋆ Γ₊ t ρ = begin [ t /⊢⋆ (ε ▻ ρ) ↑₊⋆₁ Γ₊ ] ≡⟨ /⊢⋆-cong (P.refl {x = [ t ]}) (Simple.▻-↑₊⋆ simple₁ ε ρ Γ₊) ⟩ [ t /⊢⋆ ε ↑₊⋆₁ Γ₊ /⊢ ρ ↑₊₁ (Γ₊ /̂₊ îd) ] ≡⟨ /⊢-cong (/⊢⋆-ε-↑₊⋆ Γ₊ t) (Simple.↑₊-cong simple₁ P.refl (/̂₊-îd Γ₊)) ⟩ [ t /⊢ ρ ↑₊₁ Γ₊ ] ∎ /⊢⋆-ε-▻-▻-↑₊⋆ : ∀ {Γ Δ Ε} {ρ̂₁ : Γ ⇨̂ Δ} {ρ̂₂ : Δ ⇨̂ Ε} Γ₊ {σ} (t : Γ ++₊ Γ₊ ⊢₂ σ) (ρ₁ : Sub T₁ ρ̂₁) (ρ₂ : Sub T₁ ρ̂₂) → t /⊢⋆ (ε ▻ ρ₁ ▻ ρ₂) ↑₊⋆₁ Γ₊ ≅-⊢₂ t /⊢ ρ₁ ↑₊₁ Γ₊ /⊢ ρ₂ ↑₊₁ (Γ₊ /₊ ρ₁) /⊢⋆-ε-▻-▻-↑₊⋆ Γ₊ t ρ₁ ρ₂ = begin [ t /⊢⋆ (ε ▻ ρ₁ ▻ ρ₂) ↑₊⋆₁ Γ₊ ] ≡⟨ /⊢⋆-cong (P.refl {x = [ t ]}) (Simple.▻-↑₊⋆ simple₁ (ε ▻ ρ₁) ρ₂ Γ₊) ⟩ [ t /⊢⋆ (ε ▻ ρ₁) ↑₊⋆₁ Γ₊ /⊢ ρ₂ ↑₊₁ (Γ₊ /₊ ρ₁) ] ≡⟨ /⊢-cong (/⊢⋆-ε-▻-↑₊⋆ Γ₊ t ρ₁) P.refl ⟩ [ t /⊢ ρ₁ ↑₊₁ Γ₊ /⊢ ρ₂ ↑₊₁ (Γ₊ /₊ ρ₁) ] ∎ -- Application of sub cancels one occurrence of suc. suc-/⊢-sub : ∀ {Γ σ τ} (x : Γ ∋ σ) (t : Γ ⊢₁ τ) → var₂ · suc x /⊢ sub₁ t ≅-⊢₂ var₂ · x suc-/⊢-sub x t = begin [ var₂ · suc x /⊢ sub₁ t ] ≡⟨ var-/⊢ (suc x) (sub₁ t) ⟩ [ trans · (suc x /∋ sub₁ t) ] ≡⟨ P.refl ⟩ [ trans · (x /∋ id₁) ] ≡⟨ trans-cong (Simple./∋-id simple₁ x) ⟩ [ trans · (var₁ · x) ] ≡⟨ trans-var x ⟩ [ var₂ · x ] ∎ -- First weakening and then substituting something for the first -- variable is equivalent to doing nothing. wk-∘-sub : ∀ {Γ σ} (t : Γ ⊢₁ σ) → wk₂ ∘ sub₁ t ≅-⇨ id₂[ Γ ] wk-∘-sub t = extensionality P.refl λ x → begin [ x /∋ wk₂ ∘ sub₁ t ] ≡⟨ /∋-∘ x wk₂ (sub₁ t) ⟩ [ x /∋ wk₂ /⊢ sub₁ t ] ≡⟨ /⊢-cong (Simple./∋-wk simple₂ x) P.refl ⟩ [ var₂ · suc x /⊢ sub₁ t ] ≡⟨ suc-/⊢-sub x t ⟩ [ var₂ · x ] ≡⟨ P.sym $ Simple./∋-id simple₂ x ⟩ [ x /∋ id₂ ] ∎ -- id is a left identity of _∘_ (more or less). id-∘ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} (ρ : Sub T₁ ρ̂) → id₂ ∘ ρ ≅-⇨ map trans ρ id-∘ ρ = extensionality P.refl λ x → begin [ x /∋ id₂ ∘ ρ ] ≡⟨ /∋-∘ x id₂ ρ ⟩ [ x /∋ id₂ /⊢ ρ ] ≡⟨ /⊢-cong (Simple./∋-id simple₂ x) (P.refl {x = [ ρ ]}) ⟩ [ var₂ · x /⊢ ρ ] ≡⟨ var-/⊢ x ρ ⟩ [ trans · (x /∋ ρ) ] ≡⟨ P.sym $ /∋-map x trans ρ ⟩ [ x /∋ map trans ρ ] ∎ -- One can translate a substitution either before or after -- weakening it. map-trans-wk-subst : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} (ρ : Sub T₁ ρ̂) → map trans (wk-subst₁[ σ ] ρ) ≅-⇨ wk-subst₂[ σ ] (map trans ρ) map-trans-wk-subst {σ = σ} ρ = begin [ map trans (wk-subst₁[ σ ] ρ) ] ≡⟨ P.sym $ map-[∘] trans weaken₁[ σ ] ρ ⟩ [ map (trans [∘] weaken₁[ σ ]) ρ ] ≡⟨ map-cong-ext₁ P.refl trans-weaken (P.refl {x = [ ρ ]}) ⟩ [ map (weaken₂ [∘] trans) ρ ] ≡⟨ map-[∘] weaken₂ trans ρ ⟩ [ wk-subst₂ (map trans ρ) ] ∎ -- One can translate a substitution either before or after lifting -- it. map-trans-↑ : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} (ρ : Sub T₁ ρ̂) → map trans (ρ ↑₁ σ) ≅-⇨ map trans ρ ↑₂ σ map-trans-↑ {σ = σ} ρ = begin [ map trans (ρ ↑₁ σ) ] ≡⟨ map-cong (trans ∎-⟶) (Simple.unfold-↑ simple₁ ρ) ⟩ [ map trans (wk-subst₁[ σ / ρ ] ρ ▻ var₁ · zero) ] ≡⟨ map-▻ trans (wk-subst₁ ρ) _ ⟩ [ map trans (wk-subst₁[ σ / ρ ] ρ) ▻ trans · (var₁ · zero) ] ≡⟨ ▻⇨-cong P.refl (map-trans-wk-subst ρ) (trans-var zero) ⟩ [ wk-subst₂ (map trans ρ) ▻ var₂ · zero ] ≡⟨ P.sym $ Simple.unfold-↑ simple₂ (map trans ρ) ⟩ [ map trans ρ ↑₂ ] ∎ open Application application public
{ "alphanum_fraction": 0.3970966279, "avg_line_length": 39.9577039275, "ext": "agda", "hexsha": "411320c8e95a335abf466a9d4bc5ea54ad79d20b", "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/Data/Application/Application21.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/Data/Application/Application21.agda", "max_line_length": 127, "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/Data/Application/Application21.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": 7551, "size": 13226 }
module Abstract where data Bool : Set where true false : Bool not : Bool → Bool not true = false not false = true abstract Answer : Set Answer = Bool yes : Answer yes = true no : Answer no = false contradict : Answer → Answer contradict x = not x counter-contradict : Answer → Answer counter-contradict x = contradict (contradict x) no-way : Answer no-way = contradict yes data Answers : Set where one-answer : Answer → Answers more-answers : Answer → Answers → Answers yes-or-no : Answers yes-or-no = more-answers yes (one-answer no)
{ "alphanum_fraction": 0.6882661996, "avg_line_length": 15.8611111111, "ext": "agda", "hexsha": "1ffc265ef4ad255db51db3f99cc56cee129d81ec", "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": "4383a3d20328a6c43689161496cee8eb479aca08", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dagit/agda", "max_forks_repo_path": "test/succeed/Abstract.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "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": "dagit/agda", "max_issues_repo_path": "test/succeed/Abstract.agda", "max_line_length": 48, "max_stars_count": 1, "max_stars_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dagit/agda", "max_stars_repo_path": "test/succeed/Abstract.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T07:26:06.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T07:26:06.000Z", "num_tokens": 160, "size": 571 }
------------------------------------------------------------------------ -- Excluded middle ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality module Excluded-middle {e⁺} (eq : ∀ {a p} → Equality-with-J a p e⁺) where open Derived-definitions-and-properties eq open import Prelude open import H-level.Closure eq -- Excluded middle (roughly as stated in the HoTT book). Excluded-middle : (ℓ : Level) → Type (lsuc ℓ) Excluded-middle p = {P : Type p} → Is-proposition P → Dec P -- Excluded middle is pointwise propositional (assuming -- extensionality). Excluded-middle-propositional : ∀ {ℓ} → Extensionality (lsuc ℓ) ℓ → Is-proposition (Excluded-middle ℓ) Excluded-middle-propositional ext = implicit-Π-closure ext 1 λ _ → Π-closure (lower-extensionality _ lzero ext) 1 λ P-prop → Dec-closure-propositional (lower-extensionality _ _ ext) P-prop
{ "alphanum_fraction": 0.6027542373, "avg_line_length": 27.7647058824, "ext": "agda", "hexsha": "0d166e0f0ddb588e9b399d8d17ede26c6cd81472", "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/Excluded-middle.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/Excluded-middle.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Excluded-middle.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": 241, "size": 944 }
------------------------------------------------------------------------------ -- Lists examples ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Data.List.Examples where open import FOTC.Base open import FOTC.Base.List open import FOTC.Data.Nat.UnaryNumbers open import FOTC.Data.List.Type ------------------------------------------------------------------------------ l₁ : List (true ∷ false ∷ []) l₁ = lcons true (lcons false lnil) l₂ : List (zero ∷ 1' ∷ 2' ∷ []) l₂ = lcons zero (lcons 1' (lcons 2' lnil))
{ "alphanum_fraction": 0.4155313351, "avg_line_length": 30.5833333333, "ext": "agda", "hexsha": "790fcc3121ec15315e7f0de68914869eaa4d569f", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Data/List/Examples.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Data/List/Examples.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Data/List/Examples.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": 155, "size": 734 }
{-# OPTIONS --cubical --no-import-sorts #-} open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) import Cubical.Algebra.Semigroup as Std open import MorePropAlgebra.Bundles module MorePropAlgebra.Properties.Semigroup {ℓ} (assumptions : Semigroup {ℓ}) where open Semigroup assumptions renaming (Carrier to G) stdIsSemigroup : Std.IsSemigroup _·_ stdIsSemigroup .Std.IsSemigroup.is-set = is-set stdIsSemigroup .Std.IsSemigroup.assoc = is-assoc stdSemigroup : Std.Semigroup {ℓ} stdSemigroup = record { Semigroup assumptions ; isSemigroup = stdIsSemigroup }
{ "alphanum_fraction": 0.7807757167, "avg_line_length": 37.0625, "ext": "agda", "hexsha": "bcfa66c769259c2745556546a8b8c2b17694ec92", "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/MorePropAlgebra/Properties/Semigroup.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/MorePropAlgebra/Properties/Semigroup.agda", "max_line_length": 83, "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/MorePropAlgebra/Properties/Semigroup.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": 177, "size": 593 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Lexicographic ordering of lists ------------------------------------------------------------------------ -- The definition of lexicographic ordering used here is suitable if -- the argument order is a (non-strict) partial order. The -- lexicographic ordering itself can be either strict or non-strict, -- depending on the value of a parameter. module Relation.Binary.List.NonStrictLex where open import Data.Empty open import Function open import Data.Unit using (⊤; tt) open import Data.Product open import Data.List open import Level open import Relation.Nullary open import Relation.Binary import Relation.Binary.NonStrictToStrict as Conv import Relation.Binary.List.StrictLex as Strict open import Relation.Binary.List.Pointwise as Pointwise using ([]) module _ {A : Set} where Lex : (P : Set) → (_≈_ _≤_ : Rel A zero) → Rel (List A) zero Lex P _≈_ _≤_ = Strict.Lex P _≈_ (Conv._<_ _≈_ _≤_) -- Strict lexicographic ordering. Lex-< : (_≈_ _≤_ : Rel A zero) → Rel (List A) zero Lex-< = Lex ⊥ -- Non-strict lexicographic ordering. Lex-≤ : (_≈_ _≤_ : Rel A zero) → Rel (List A) zero Lex-≤ = Lex ⊤ ------------------------------------------------------------------------ -- Properties ≤-reflexive : ∀ _≈_ _≤_ → Pointwise.Rel _≈_ ⇒ Lex-≤ _≈_ _≤_ ≤-reflexive _≈_ _≤_ = Strict.≤-reflexive _≈_ (Conv._<_ _≈_ _≤_) <-irreflexive : ∀ {_≈_ _≤_} → Irreflexive (Pointwise.Rel _≈_) (Lex-< _≈_ _≤_) <-irreflexive {_≈_} {_≤_} = Strict.<-irreflexive {_<_ = Conv._<_ _≈_ _≤_} (Conv.irrefl _≈_ _≤_) transitive : ∀ {P _≈_ _≤_} → IsPartialOrder _≈_ _≤_ → Transitive (Lex P _≈_ _≤_) transitive po = Strict.transitive isEquivalence (Conv.<-resp-≈ _ _ isEquivalence ≤-resp-≈) (Conv.trans _ _ po) where open IsPartialOrder po antisymmetric : ∀ {P _≈_ _≤_} → Symmetric _≈_ → Antisymmetric _≈_ _≤_ → Antisymmetric (Pointwise.Rel _≈_) (Lex P _≈_ _≤_) antisymmetric {_≈_ = _≈_} {_≤_} sym antisym = Strict.antisymmetric sym (Conv.irrefl _≈_ _≤_) (Conv.antisym⟶asym _≈_ _ antisym) <-asymmetric : ∀ {_≈_ _≤_} → IsEquivalence _≈_ → _≤_ Respects₂ _≈_ → Antisymmetric _≈_ _≤_ → Asymmetric (Lex-< _≈_ _≤_) <-asymmetric {_≈_} eq resp antisym = Strict.<-asymmetric sym (Conv.<-resp-≈ _ _ eq resp) (Conv.antisym⟶asym _≈_ _ antisym) where open IsEquivalence eq respects₂ : ∀ {P _≈_ _≤_} → IsEquivalence _≈_ → _≤_ Respects₂ _≈_ → Lex P _≈_ _≤_ Respects₂ Pointwise.Rel _≈_ respects₂ eq resp = Strict.respects₂ eq (Conv.<-resp-≈ _ _ eq resp) decidable : ∀ {P _≈_ _≤_} → Dec P → Decidable _≈_ → Decidable _≤_ → Decidable (Lex P _≈_ _≤_) decidable dec-P dec-≈ dec-≤ = Strict.decidable dec-P dec-≈ (Conv.decidable _ _ dec-≈ dec-≤) <-decidable : ∀ {_≈_ _≤_} → Decidable _≈_ → Decidable _≤_ → Decidable (Lex-< _≈_ _≤_) <-decidable = decidable (no id) ≤-decidable : ∀ {_≈_ _≤_} → Decidable _≈_ → Decidable _≤_ → Decidable (Lex-≤ _≈_ _≤_) ≤-decidable = decidable (yes tt) ≤-total : ∀ {_≈_ _≤_} → Symmetric _≈_ → Decidable _≈_ → Antisymmetric _≈_ _≤_ → Total _≤_ → Total (Lex-≤ _≈_ _≤_) ≤-total sym dec-≈ antisym tot = Strict.≤-total sym (Conv.trichotomous _ _ sym dec-≈ antisym tot) <-compare : ∀ {_≈_ _≤_} → Symmetric _≈_ → Decidable _≈_ → Antisymmetric _≈_ _≤_ → Total _≤_ → Trichotomous (Pointwise.Rel _≈_) (Lex-< _≈_ _≤_) <-compare sym dec-≈ antisym tot = Strict.<-compare sym (Conv.trichotomous _ _ sym dec-≈ antisym tot) -- Some collections of properties which are preserved by Lex-≤ or -- Lex-<. ≤-isPreorder : ∀ {_≈_ _≤_} → IsPartialOrder _≈_ _≤_ → IsPreorder (Pointwise.Rel _≈_) (Lex-≤ _≈_ _≤_) ≤-isPreorder po = Strict.≤-isPreorder isEquivalence (Conv.trans _ _ po) (Conv.<-resp-≈ _ _ isEquivalence ≤-resp-≈) where open IsPartialOrder po ≤-isPartialOrder : ∀ {_≈_ _≤_} → IsPartialOrder _≈_ _≤_ → IsPartialOrder (Pointwise.Rel _≈_) (Lex-≤ _≈_ _≤_) ≤-isPartialOrder po = Strict.≤-isPartialOrder (Conv.isPartialOrder⟶isStrictPartialOrder _ _ po) ≤-isTotalOrder : ∀ {_≈_ _≤_} → Decidable _≈_ → IsTotalOrder _≈_ _≤_ → IsTotalOrder (Pointwise.Rel _≈_) (Lex-≤ _≈_ _≤_) ≤-isTotalOrder dec tot = Strict.≤-isTotalOrder (Conv.isTotalOrder⟶isStrictTotalOrder _ _ dec tot) ≤-isDecTotalOrder : ∀ {_≈_ _≤_} → IsDecTotalOrder _≈_ _≤_ → IsDecTotalOrder (Pointwise.Rel _≈_) (Lex-≤ _≈_ _≤_) ≤-isDecTotalOrder dtot = Strict.≤-isDecTotalOrder (Conv.isDecTotalOrder⟶isStrictTotalOrder _ _ dtot) <-isStrictPartialOrder : ∀ {_≈_ _≤_} → IsPartialOrder _≈_ _≤_ → IsStrictPartialOrder (Pointwise.Rel _≈_) (Lex-< _≈_ _≤_) <-isStrictPartialOrder po = Strict.<-isStrictPartialOrder (Conv.isPartialOrder⟶isStrictPartialOrder _ _ po) <-isStrictTotalOrder : ∀ {_≈_ _≤_} → Decidable _≈_ → IsTotalOrder _≈_ _≤_ → IsStrictTotalOrder (Pointwise.Rel _≈_) (Lex-< _≈_ _≤_) <-isStrictTotalOrder dec tot = Strict.<-isStrictTotalOrder (Conv.isTotalOrder⟶isStrictTotalOrder _ _ dec tot) -- "Packages" (e.g. preorders) can also be handled. ≤-preorder : Poset _ _ _ → Preorder _ _ _ ≤-preorder po = record { isPreorder = ≤-isPreorder isPartialOrder } where open Poset po ≤-partialOrder : Poset _ _ _ → Poset _ _ _ ≤-partialOrder po = record { isPartialOrder = ≤-isPartialOrder isPartialOrder } where open Poset po ≤-decTotalOrder : DecTotalOrder _ _ _ → DecTotalOrder _ _ _ ≤-decTotalOrder dtot = record { isDecTotalOrder = ≤-isDecTotalOrder isDecTotalOrder } where open DecTotalOrder dtot <-strictPartialOrder : Poset _ _ _ → StrictPartialOrder _ _ _ <-strictPartialOrder po = record { isStrictPartialOrder = <-isStrictPartialOrder isPartialOrder } where open Poset po <-strictTotalOrder : DecTotalOrder _ _ _ → StrictTotalOrder _ _ _ <-strictTotalOrder dtot = record { isStrictTotalOrder = <-isStrictTotalOrder _≟_ isTotalOrder } where open IsDecTotalOrder (DecTotalOrder.isDecTotalOrder dtot)
{ "alphanum_fraction": 0.6077942323, "avg_line_length": 34.6756756757, "ext": "agda", "hexsha": "7e76485f30a69c24062f76f8be70a6cf6c1c2b2d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Relation/Binary/List/NonStrictLex.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Relation/Binary/List/NonStrictLex.agda", "max_line_length": 74, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Relation/Binary/List/NonStrictLex.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 2272, "size": 6415 }
------------------------------------------------------------------------ -- Some definitions related to and properties of the Maybe type ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality module Maybe {reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where open import Prelude open import Bijection eq using (_↔_) open Derived-definitions-and-properties eq open import Monad eq -- A dependent eliminator. maybe : ∀ {a b} {A : Type a} {B : Maybe A → Type b} → ((x : A) → B (just x)) → B nothing → (x : Maybe A) → B x maybe j n (just x) = j x maybe j n nothing = n -- Is the value just something? is-just : ∀ {a} {A : Type a} → Maybe A → Bool is-just = maybe (const true) false -- Is the value nothing? is-nothing : ∀ {a} {A : Type a} → Maybe A → Bool is-nothing = not ∘ is-just -- Is-just x is a proposition that is inhabited iff x is -- just something. Is-just : ∀ {a} {A : Type a} → Maybe A → Type Is-just = T ∘ is-just -- Is-nothing x is a proposition that is inhabited iff x is nothing. Is-nothing : ∀ {a} {A : Type a} → Maybe A → Type Is-nothing = T ∘ is-nothing -- Is-just and Is-nothing are mutually exclusive. not-both-just-and-nothing : ∀ {a} {A : Type a} (x : Maybe A) → Is-just x → Is-nothing x → ⊥₀ not-both-just-and-nothing (just _) _ () not-both-just-and-nothing nothing () _ -- A universe-polymorphic variant of bind. infixl 5 _>>=′_ _>>=′_ : ∀ {a b} {A : Type a} {B : Type b} → Maybe A → (A → Maybe B) → Maybe B x >>=′ f = maybe f nothing x instance -- The maybe monad. raw-monad : ∀ {ℓ} → Raw-monad (Maybe {a = ℓ}) Raw-monad.return raw-monad x = just x Raw-monad._>>=_ raw-monad = _>>=′_ monad : ∀ {ℓ} → Monad (Maybe {a = ℓ}) Monad.raw-monad monad = raw-monad Monad.left-identity monad x f = refl (f x) Monad.right-identity monad nothing = refl nothing Monad.right-identity monad (just x) = refl (just x) Monad.associativity monad nothing f g = refl nothing Monad.associativity monad (just x) f g = refl (f x >>= g) -- The maybe monad transformer. record MaybeT {d c} (M : Type d → Type c) (A : Type d) : Type c where constructor wrap field run : M (Maybe A) open MaybeT public -- Failure. fail : ∀ {d c} {M : Type d → Type c} ⦃ is-monad : Raw-monad M ⦄ {A} → MaybeT M A run fail = return nothing -- MaybeT id is pointwise isomorphic to Maybe. MaybeT-id↔Maybe : ∀ {a} {A : Type a} → MaybeT id A ↔ Maybe A MaybeT-id↔Maybe = record { surjection = record { logical-equivalence = record { to = run; from = wrap } ; right-inverse-of = refl } ; left-inverse-of = refl } instance -- MaybeT is a "raw monad" transformer. raw-monad-transformer : ∀ {d c} → Raw-monad-transformer (MaybeT {d = d} {c = c}) run (Raw-monad.return (Raw-monad-transformer.transform raw-monad-transformer) x) = return (just x) run (Raw-monad._>>=_ (Raw-monad-transformer.transform raw-monad-transformer) x f) = run x >>= maybe (run ∘ f) (return nothing) run (Raw-monad-transformer.liftʳ raw-monad-transformer m) = map just m transform : ∀ {d c} {M : Type d → Type c} ⦃ is-raw-monad : Raw-monad M ⦄ → Raw-monad (MaybeT M) transform = Raw-monad-transformer.transform raw-monad-transformer -- MaybeT is a monad transformer (assuming extensionality). monad-transformer : ∀ {d c} → Extensionality d c → Monad-transformer (MaybeT {d = d} {c = c}) Monad.raw-monad (Monad-transformer.transform (monad-transformer _)) = Raw-monad-transformer.transform raw-monad-transformer Monad.left-identity (Monad-transformer.transform (monad-transformer _)) x f = cong wrap ( return (just x) >>= maybe (run ∘ f) (return nothing) ≡⟨ left-identity (just x) (maybe (run ∘ f) (return nothing)) ⟩∎ run (f x) ∎) Monad.right-identity (Monad-transformer.transform (monad-transformer ext)) x = cong wrap ( run x >>= maybe (return ∘ just) (return nothing) ≡⟨ cong (run x >>=_) (apply-ext ext (maybe (λ _ → refl _) (refl _))) ⟩ run x >>= return ≡⟨ right-identity _ ⟩∎ run x ∎) Monad.associativity (Monad-transformer.transform (monad-transformer ext)) x f g = cong wrap ( run x >>= (maybe (λ x → run (f x) >>= maybe (run ∘ g) (return nothing)) (return nothing)) ≡⟨ cong (run x >>=_) (apply-ext ext (maybe (λ _ → refl _) ( return nothing ≡⟨ sym $ left-identity _ _ ⟩∎ return nothing >>= maybe (run ∘ g) (return nothing) ∎))) ⟩ run x >>= (λ x → maybe (run ∘ f) (return nothing) x >>= maybe (run ∘ g) (return nothing)) ≡⟨ associativity _ _ _ ⟩∎ (run x >>= maybe (run ∘ f) (return nothing)) >>= maybe (run ∘ g) (return nothing) ∎) Monad-transformer.liftᵐ (monad-transformer _) = liftʳ Monad-transformer.lift-return (monad-transformer _) x = cong wrap ( map just (return x) ≡⟨ map-return just x ⟩∎ return (just x) ∎) Monad-transformer.lift->>= (monad-transformer ext) x f = cong wrap ( map just (x >>= f) ≡⟨ map->>= _ _ _ ⟩ x >>= map just ∘ f ≡⟨ sym $ >>=-map ext _ _ _ ⟩∎ map just x >>= maybe (map just ∘ f) (return nothing) ∎)
{ "alphanum_fraction": 0.556231003, "avg_line_length": 32.3294797688, "ext": "agda", "hexsha": "72a18c1ac19ff37992932d860afb45d17bcc30f0", "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/Maybe.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/Maybe.agda", "max_line_length": 128, "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/Maybe.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": 1683, "size": 5593 }
{-# OPTIONS --without-K --safe #-} open import Level module Categories.Category.Instance.SimplicialSet.Properties (o ℓ : Level) where open import Function using (_$_) open import Data.Empty.Polymorphic using (⊥; ⊥-elim) open import Data.Nat using (ℕ) open import Data.Fin using (Fin) open import Data.Product using (proj₁) import Relation.Binary.PropositionalEquality as Eq open import Categories.Category using (Category; _[_,_]; _[_∘_]; _[_≈_]) open import Categories.Category.Instance.SimplicialSet using (SimplicialSet) open import Categories.Category.Instance.Simplex using (Δ; face; degeneracy) open import Categories.Functor using (Functor; _∘F_) open import Categories.Functor.Construction.Constant using (const) open import Categories.Functor.Construction.LiftSetoids using (LiftSetoids) open import Categories.NaturalTransformation using (ntHelper) open import Categories.Yoneda private module Y = Functor (Yoneda.embed Δ) -- Some useful notation for a simplicial set ΔSet : Set (suc o ⊔ suc ℓ) ΔSet = Category.Obj (SimplicialSet o ℓ ) -- The standard n-simplex. Δ[_] : ℕ → ΔSet Δ[_] n = LiftSetoids o ℓ ∘F Y.F₀ n -------------------------------------------------------------------------------- -- Boundaries of the Standard Simplicies -- -- The basic idea here is that we will build up boundary of 'Δ[ n ]' by considering -- all of the morphisms 'Δ[ m , n ]' that factor through some face map 'face i : Δ[ n - 1 , n ]' -- The indexing here is a bit tricky, but this is the price we pay to avoid 'pred' -- A 'Boundary m n' represents some set of maps into 'Δ[ ℕ.suc n ]' that factor through -- a face map. To make this indexing more obvious, we use the suggestively named variable 'n-1'. record Boundary (m n-1 : ℕ) : Set where -- To avoid the (somewhat confusion) pattern of 'ℕ.suc n-1', let's define -- a bit of helpful local notation. private n : ℕ n = ℕ.suc n-1 field hom : Δ [ m , n ] factor : Δ [ m , n-1 ] factor-dim : Fin n factor-face : Δ [ hom ≈ Δ [ face factor-dim ∘ factor ] ] -- Lift morphisms in Δ to maps between boundary sets on 'Δ[ n ]' boundary-map : ∀ {x y n} → Δ [ x , y ] → Boundary y n → Boundary x n boundary-map {n = n} f b = record { hom = hom b ∘ f ; factor = factor b ∘ f ; factor-dim = factor-dim b ; factor-face = λ x → factor-face b (proj₁ f x) } where open Category Δ open Boundary -- The boundary of an n-simplex ∂Δ[_] : ℕ → ΔSet ∂Δ[_] ℕ.zero = const record { Carrier = ⊥ ; _≈_ = λ () ; isEquivalence = record { refl = λ { {()} } ; sym = λ { {()} } ; trans = λ { {()} } } } ∂Δ[_] (ℕ.suc n) = record { F₀ = λ m → record { Carrier = Lift o (Boundary m n) -- Unwinding the equality by hand here leads to less unsolved metavariables down the line ; _≈_ = λ (lift b) (lift b′) → ∀ x → Lift ℓ (proj₁ (hom b) x ≡ proj₁ (hom b′) x) ; isEquivalence = record { refl = λ x → lift refl ; sym = λ eq x → lift (sym (lower (eq x))) ; trans = λ eq₁ eq₂ x → lift (trans (lower (eq₁ x)) (lower (eq₂ x))) } } ; F₁ = λ f → record { _⟨$⟩_ = λ (lift b) → lift (boundary-map f b) ; cong = λ eq x → eq (proj₁ f x) } ; identity = λ eq → eq ; homomorphism = λ {_} {_} {_} {f} {g} eq x → eq (proj₁ f (proj₁ g x)) ; F-resp-≈ = λ {_} {_} {f} {g} f≈g {b} {b′} eq x → lift $ begin proj₁ (hom (lower b)) (proj₁ f x) ≡⟨ lower (eq (proj₁ f x)) ⟩ proj₁ (hom (lower b′)) (proj₁ f x) ≡⟨ cong (proj₁ (hom (lower b′))) (f≈g x) ⟩ proj₁ (hom (lower b′)) (proj₁ g x) ∎ } where open Boundary open Eq open ≡-Reasoning -------------------------------------------------------------------------------- -- Horns -- -- The idea here is essentially the same as the boundaries, but we exclude the kth -- face map as a possible factor. record Horn (m n-1 : ℕ) (k : Fin (ℕ.suc n-1)) : Set where field horn : Boundary m n-1 open Boundary horn public field is-horn : factor-dim Eq.≢ k Λ[_,_] : (n : ℕ) → Fin n → ΔSet Λ[ ℕ.suc n , k ] = record { F₀ = λ m → record { Carrier = Lift o (Horn m n k) ; _≈_ = λ (lift b) (lift b′) → ∀ x → Lift ℓ (proj₁ (hom b) x ≡ proj₁ (hom b′) x) ; isEquivalence = record { refl = λ x → lift refl ; sym = λ eq x → lift (sym (lower (eq x))) ; trans = λ eq₁ eq₂ x → lift (trans (lower (eq₁ x)) (lower (eq₂ x))) } } ; F₁ = λ f → record { _⟨$⟩_ = λ (lift h) → lift $ record { horn = boundary-map f (horn h) ; is-horn = is-horn h } ; cong = λ eq x → eq (proj₁ f x) } ; identity = λ eq → eq ; homomorphism = λ {_} {_} {_} {f} {g} eq x → eq (proj₁ f (proj₁ g x)) ; F-resp-≈ = λ {_} {_} {f} {g} f≈g {b} {b′} eq x → lift $ begin proj₁ (hom (lower b)) (proj₁ f x) ≡⟨ lower (eq (proj₁ f x)) ⟩ proj₁ (hom (lower b′)) (proj₁ f x) ≡⟨ cong (proj₁ (hom (lower b′))) (f≈g x) ⟩ proj₁ (hom (lower b′)) (proj₁ g x) ∎ } where open Horn open Eq open ≡-Reasoning -------------------------------------------------------------------------------- -- Morphims between simplicial sets module _ where open Category (SimplicialSet o ℓ) -- Inclusion of boundaries ∂Δ-inj : ∀ {n} → ∂Δ[ n ] ⇒ Δ[ n ] ∂Δ-inj {ℕ.zero} = ntHelper record { η = λ X → record { _⟨$⟩_ = ⊥-elim ; cong = λ { {()} } } ; commute = λ { _ {()} _ } } ∂Δ-inj {ℕ.suc n} = ntHelper record { η = λ X → record { _⟨$⟩_ = λ (lift b) → lift (hom b) ; cong = λ eq → lift (λ x → lower (eq x)) } ; commute = λ f eq → lift (λ x → lower (eq (proj₁ f x))) } where open Boundary -- Inclusion of n-horns into n-simplicies Λ-inj : ∀ {n} → (k : Fin n) → Λ[ n , k ] ⇒ Δ[ n ] Λ-inj {n = ℕ.suc n} k = ntHelper record { η = λ X → record { _⟨$⟩_ = λ (lift h) → lift (hom h) ; cong = λ eq → lift (λ x → lower (eq x)) } ; commute = λ f eq → lift (λ x → lower (eq (proj₁ f x))) } where open Horn
{ "alphanum_fraction": 0.5531950485, "avg_line_length": 30.9740932642, "ext": "agda", "hexsha": "ba5127780c0645192fad5623ae0f3abf47f12227", "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": "a4053cf700bcefdf73b857c3352f1eae29382a60", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jaykru/agda-categories", "max_forks_repo_path": "src/Categories/Category/Instance/SimplicialSet/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a4053cf700bcefdf73b857c3352f1eae29382a60", "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": "jaykru/agda-categories", "max_issues_repo_path": "src/Categories/Category/Instance/SimplicialSet/Properties.agda", "max_line_length": 96, "max_stars_count": null, "max_stars_repo_head_hexsha": "a4053cf700bcefdf73b857c3352f1eae29382a60", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jaykru/agda-categories", "max_stars_repo_path": "src/Categories/Category/Instance/SimplicialSet/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2088, "size": 5978 }
module PLRTree.Equality.Correctness {A : Set} where open import BTree.Equality {A} open import PLRTree {A} open import PLRTree.Equality {A} renaming (_≃_ to _≃'_) lemma-≃'-≃ : {l r : PLRTree} → l ≃' r → forget l ≃ forget r lemma-≃'-≃ ≃lf = ≃lf lemma-≃'-≃ (≃nd x x' l≃'r l'≃'r' l≃'l') = ≃nd x x' (lemma-≃'-≃ l≃'r) (lemma-≃'-≃ l≃'l') (lemma-≃'-≃ l'≃'r')
{ "alphanum_fraction": 0.5690140845, "avg_line_length": 35.5, "ext": "agda", "hexsha": "67fc9cbffbad4be918fb6019ad0038cae8c9a270", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/PLRTree/Equality/Correctness.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/PLRTree/Equality/Correctness.agda", "max_line_length": 107, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/PLRTree/Equality/Correctness.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 182, "size": 355 }
-- Andreas, 2019-07-15, issue #3901, requested by msuperdock -- -- Allow function spaces {A} → B and {{A}} → B. postulate A B : Set foo : {{A}} → B bar : {A} → B -- Original feature request: open import Agda.Builtin.Unit using (⊤; tt) data ⊥ : Set where data Nat : Set where zero : Nat suc : Nat → Nat _≤_ : Nat → Nat → Set zero ≤ _ = ⊤ suc m ≤ zero = ⊥ suc m ≤ suc n = m ≤ n data SList (bound : Nat) : Set where [] : SList bound scons : (head : Nat) → {head ≤ bound} -- here: anonymous binding → (tail : SList head) → SList bound xs : SList zero xs = scons zero []
{ "alphanum_fraction": 0.5499207607, "avg_line_length": 18.5588235294, "ext": "agda", "hexsha": "24ce98700ee5257f9dec3229083b29ad6bd96f4a", "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/Issue3901.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/Issue3901.agda", "max_line_length": 60, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue3901.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": 225, "size": 631 }
-- Jesper, 2018-11-23: Unsolved metas are turned into postulates -- when --allow-unsolved-metas is enabled, but there was no internal -- representation of postulated sorts. module Issue3256 where open import Issue3256.B -- WAS: -- An internal error has occurred. Please report this as a bug. -- Location of the error: src/full/Agda/TypeChecking/Reduce.hs:149
{ "alphanum_fraction": 0.7624309392, "avg_line_length": 30.1666666667, "ext": "agda", "hexsha": "ca97d042c76a59dd304d9f6d3a0054b7ed37d574", "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/Issue3256.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/Issue3256.agda", "max_line_length": 68, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue3256.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 97, "size": 362 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Graphs where open import Categories.Category hiding (module Heterogeneous) open import Data.Product open import Level open import Relation.Binary renaming (_⇒_ to _⊆_) open import Relation.Binary.PropositionalEquality using () renaming (_≡_ to _≣_; refl to ≣-refl) open import Graphs.Graph open import Graphs.GraphMorphism Graphs : ∀ o ℓ e → Category (suc (o ⊔ ℓ ⊔ e)) (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e) Graphs o ℓ e = record { Obj = Obj ; _⇒_ = _⇒_ ; _≡_ = _≈_ ; id = id ; _∘_ = _∘_ ; equiv = isEquivalence ; assoc = λ {A}{B}{C}{D}{f}{g}{h} → assoc {A}{B}{C}{D}{f}{g}{h} ; identityˡ = λ {A}{B}{f : A ⇒ B} → IsEquivalence.refl (isEquivalence {A = A}{B}) {x = f} ; identityʳ = λ {A}{B}{f : A ⇒ B} → IsEquivalence.refl (isEquivalence {A = A}{B}) {x = f} ; ∘-resp-≡ = λ {_}{_}{_}{f}{h}{g}{i} → ∘-resp-≈ {F = f}{h}{g}{i} } where Obj : Set (suc (o ⊔ ℓ ⊔ e)) Obj = Graph o ℓ e _⇒_ : Obj → Obj → Set _ _⇒_ = GraphMorphism .assoc : ∀ {A B C D} {f : A ⇒ B} {g : B ⇒ C} {h : C ⇒ D} → ((h ∘ g) ∘ f) ≈ (h ∘ (g ∘ f)) assoc {f = f}{g}{h} = (λ x → ≣-refl) , (λ f → refl) where open Heterogeneous _
{ "alphanum_fraction": 0.5285140562, "avg_line_length": 31.125, "ext": "agda", "hexsha": "2ddbefe20db34b71c3ac3ae6951b0bf4f06c3ed7", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Graphs.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Graphs.agda", "max_line_length": 92, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Graphs.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 522, "size": 1245 }
{-# OPTIONS --cubical-compatible #-} module WithoutK1 where -- Equality defined with one index. data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x K : {A : Set} (P : {x : A} → x ≡ x → Set) → (∀ x → P (refl {x = x})) → ∀ {x} (x≡x : x ≡ x) → P x≡x K P p refl = p _
{ "alphanum_fraction": 0.4822695035, "avg_line_length": 20.1428571429, "ext": "agda", "hexsha": "f04d31a8574a91f1fb3fffa78090d2f42c501e02", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Fail/WithoutK1.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Fail/WithoutK1.agda", "max_line_length": 43, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Fail/WithoutK1.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 121, "size": 282 }
postulate U V W X Y Z : Set u : U v : V w : W x : X y : Y z : Z module Top (u : U) where module A (v : V) where module M (w : W) where module O (x : X) where postulate O : X postulate O : X module B (y : Y) where open A public module Test0 where module C = Top.B u y module D = C.M.O v w x O₁ : X O₁ = C.M.O v w O₂ : X O₂ = C.O v module Test1 where module C (i g n o r i n g m e : Z) = Top.B u y module D = C.M.O z z z z z z z z z z v w x O : X O = C.M.O z z z z z z z z z z v w module Test2 where module C (y : Y) = Top.B u y module D = C.M.O y v w x O : X O = C.M.O y v w module Test3 where module C (z : Z) = Top.B u y module D = C.M.O z v w x
{ "alphanum_fraction": 0.5158184319, "avg_line_length": 16.9069767442, "ext": "agda", "hexsha": "425a65592fee4edb4fd0d986025ae7c9f5a61d65", "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/Issue1726.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/Issue1726.agda", "max_line_length": 48, "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/Issue1726.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": 317, "size": 727 }
-- 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.Rational as ℚ using (ℚ) open import Data.List open import Relation.Binary.PropositionalEquality module autoencoderError-temp-output where postulate encode : Tensor ℚ (5 ∷ []) → Tensor ℚ (2 ∷ []) postulate decode : Tensor ℚ (2 ∷ []) → Tensor ℚ (5 ∷ []) abstract identity : ∀ (x : Tensor ℚ (5 ∷ [])) → decode (encode x) ≡ x identity = checkSpecification record { proofCache = "/home/matthew/Code/AISEC/vehicle/proofcache.vclp" }
{ "alphanum_fraction": 0.6842818428, "avg_line_length": 28.3846153846, "ext": "agda", "hexsha": "d2572d721719354278bbd8d0e3bf12d022391ad7", "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": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "vehicle-lang/vehicle", "max_forks_repo_path": "test/Test/Compile/Golden/autoencoderError/autoencoderError-output.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_issues_repo_issues_event_max_datetime": "2022-03-31T20:49:39.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-07T14:09:13.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "vehicle-lang/vehicle", "max_issues_repo_path": "test/Test/Compile/Golden/autoencoderError/autoencoderError-output.agda", "max_line_length": 71, "max_stars_count": 9, "max_stars_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "vehicle-lang/vehicle", "max_stars_repo_path": "test/Test/Compile/Golden/autoencoderError/autoencoderError-output.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-17T18:51:05.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-10T12:56:42.000Z", "num_tokens": 215, "size": 738 }
module Data.List.Kleene.Relation.Unary.All where open import Data.List.Kleene.Base open import Relation.Unary open import Relation.Nullary open import Level using (_⊔_) open import Function mutual record All⁺ {a p} {A : Set a} (P : Pred A p) (xs : A ⁺) : Set (a ⊔ p) where constructor P⟨_&_⟩ inductive field P⟨head⟩ : P (head xs) P⟨tail⟩ : All⋆ P (tail xs) data All⋆ {a p} {A : Set a} (P : Pred A p) : Pred (A ⋆) (a ⊔ p) where P⟨[]⟩ : All⋆ P [] P⟨∹_⟩ : ∀ {xs} → All⁺ P xs → All⋆ P (∹ xs) open All⁺ public module _ {a p} {A : Set a} {P : Pred A p} where mutual all⋆ : Decidable P → Decidable (All⋆ P) all⋆ p? [] = yes P⟨[]⟩ all⋆ p? (∹ xs) with all⁺ p? xs all⋆ p? (∹ xs) | yes p = yes P⟨∹ p ⟩ all⋆ p? (∹ xs) | no ¬p = no λ { P⟨∹ x ⟩ → ¬p x } all⁺ : Decidable P → Decidable (All⁺ P) all⁺ p? xs with p? (head xs) | all⋆ p? (tail xs) all⁺ p? xs | no ¬p | ys = no (¬p ∘ P⟨head⟩) all⁺ p? xs | yes p | yes ps = yes P⟨ p & ps ⟩ all⁺ p? xs | yes p | no ¬p = no (¬p ∘ P⟨tail⟩)
{ "alphanum_fraction": 0.5223596575, "avg_line_length": 28.4054054054, "ext": "agda", "hexsha": "18e96ad59586e3e8040cd85b580ac8a3e4a0ed28", "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": "a7e99bc288e12e83440c891dbd3e5077d9b1657e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-kleene-lists", "max_forks_repo_path": "Data/List/Kleene/Relation/Unary/All.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a7e99bc288e12e83440c891dbd3e5077d9b1657e", "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-kleene-lists", "max_issues_repo_path": "Data/List/Kleene/Relation/Unary/All.agda", "max_line_length": 77, "max_stars_count": null, "max_stars_repo_head_hexsha": "a7e99bc288e12e83440c891dbd3e5077d9b1657e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-kleene-lists", "max_stars_repo_path": "Data/List/Kleene/Relation/Unary/All.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 475, "size": 1051 }
open import Data.List using (List; _∷_; []) open import Data.Product using (_×_; _,_; Σ) open import Data.Unit using (⊤; tt) open import Relation.Binary.PropositionalEquality using (_≡_) module SystemT where {- de Bruijn indices are represented as proofs that an element is in a list -} data _∈_ {A : Set} : (x : A) (l : List A) → Set where -- type \in i0 : {x : A} {xs : List A} → x ∈ (x ∷ xs) iS : {x y : A} {xs : List A} → x ∈ xs → x ∈ (y ∷ xs) {- types of the STLC -} data TType : Set where b : TType -- uninterpreted base type _⇒_ : TType → TType → TType -- type \=> {- contexts are lists of TType's -} Ctx = List _,,_ : ∀ {A} → Ctx A → TType → Ctx A Γ ,, τ = τ ∷ Γ infixr 10 _⇒_ infixr 9 _,,_ infixr 8 _⊢_ -- type \entails {- Γ ⊢ τ represents a term of type τ in context Γ -} data _⊢_ (Γ : Ctx) : TType → Set where c : Γ ⊢ b -- some constant of the base type v : {τ : TType} → τ ∈ Γ → Γ ⊢ τ lam : {τ1 τ2 : TType} → Γ ,, τ1 ⊢ τ2 → Γ ⊢ τ1 ⇒ τ2 app : {τ1 τ2 : TType} → Γ ⊢ τ1 ⇒ τ2 → Γ ⊢ τ1 → Γ ⊢ τ2 module Examples where i : [] ⊢ b ⇒ b i = lam (v i0) -- \ x -> x k : [] ⊢ b ⇒ b ⇒ b k = lam (lam (v (iS i0))) -- \ x -> \ y -> x {- TASK 1: Define a term representing \ x -> \ y -> y -} k' : [] ⊢ b ⇒ b ⇒ b k' = {!!} {- The following proof is like a "0-ary" logical relation. It gives a semantics of the STLC in Agda. This shows that the STLC is sound, relative to Agda. -} module Semantics (B : Set) (elB : B) where -- works for any interpretation of the base type b -- function mapping STLC types to Agda types ⟦_⟧t : TType → Set -- type \(0 and \)0 ⟦ b ⟧t = B ⟦ τ1 ⇒ τ2 ⟧t = ⟦ τ1 ⟧t → ⟦ τ2 ⟧t -- function mapping STLC contexts to Agda types ⟦_⟧c : Ctx → Set ⟦ [] ⟧c = ⊤ ⟦ τ ∷ Γ ⟧c = ⟦ Γ ⟧c × ⟦ τ ⟧t {- TASK 2 : Define the interpretation of terms -} ⟦_⟧ : {Γ : Ctx} {τ : TType} → Γ ⊢ τ → ⟦ Γ ⟧c → ⟦ τ ⟧t ⟦ e ⟧ γ = {!!} {- the following test should pass test : ⟦ Examples.k ⟧ == \ γ x y → x test = Refl -} {- you can ignore the implementation of this module. the interface for the components you need is listed below -} module RenamingAndSubstitution where -- renamings = variable for variable substitutions infix 9 _⊇_ _⊇_ : Ctx → Ctx → Set -- type \sup= Γ' ⊇ [] = ⊤ Γ' ⊇ (τ ∷ Γ) = (Γ' ⊇ Γ) × (τ ∈ Γ') extend⊇ : {Γ : Ctx} (Γ' : Ctx) {τ : TType} → Γ ⊇ Γ' → (Γ ,, τ) ⊇ Γ' extend⊇ [] ren = tt extend⊇ (τ ∷ Γ') (ρ , x) = extend⊇ Γ' ρ , iS x open import Data.List using (_++_) extend⊇* : {Γ : Ctx} (Γ' : Ctx) (Γ'' : Ctx) → Γ ⊇ Γ' → (Γ'' ++ Γ) ⊇ Γ' extend⊇* Γ' [] ρ = ρ extend⊇* Γ' (x ∷ Γ'') ρ = extend⊇ _ (extend⊇* Γ' Γ'' ρ) shift : {Γ : Ctx} {τ : TType} (Γ' : Ctx) (i : τ ∈ Γ) → τ ∈ (Γ' ++ Γ) shift [] i = i shift (τ ∷ Γ) i = iS (shift Γ i) ⊇-id : (Γ : Ctx) → Γ ⊇ Γ ⊇-id [] = tt ⊇-id (τ ∷ Γ) = extend⊇ Γ (⊇-id Γ) , i0 ⊇-single : {Γ : Ctx} {τ : TType} → (Γ ,, (τ ⊇ Γ)) ⊇-single = extend⊇ _ (⊇-id _) -- you can rename a term rename : {Γ Γ' : Ctx} {τ : TType} → Γ' ⊇ Γ → Γ ⊢ τ → Γ' ⊢ τ rename ρ c = c rename (_ , x') (v i0) = v x' rename (ρ , _) (v (iS x)) = rename ρ (v x) rename ρ (lam e) = lam (rename (extend⊇ _ ρ , i0) e) rename ρ (app e e') = app (rename ρ e) (rename ρ e') -- expression-for-variable substitutions _⊢c_ : Ctx → Ctx → Set Γ' ⊢c [] = tt Γ' ⊢c (τ ∷ Γ) = (Γ' ⊢c Γ) × (Γ' ⊢ τ) rename-subst : {Γ1 Γ2 Γ3 : Ctx} → Γ1 ⊇ Γ2 → Γ2 ⊢c Γ3 → Γ1 ⊢c Γ3 rename-subst {Γ1} {Γ2} {[]} ρ θ = tt rename-subst {Γ1} {Γ2} {τ3 ∷ Γ3} ρ (θ , e) = rename-subst ρ θ , rename ρ e addvar : {Γ Γ' : Ctx} {τ : TType} → Γ ⊢c Γ' → (Γ ,, τ) ⊢c (Γ' ,, τ) addvar θ = rename-subst ⊇-single θ , v i0 id-subst : {Γ : Ctx} → Γ ⊢c Γ id-subst {[]} = tt id-subst {τ ∷ Γ} = rename-subst ⊇-single (id-subst {Γ}) , v i0 subst : {Γ Γ' : Ctx}{τ : TType} → Γ ⊢c Γ' → Γ' ⊢ τ → Γ ⊢ τ subst θ c = c subst (θ , e) (v i0) = e subst (θ , e) (v (iS x)) = subst θ (v x) subst θ (lam e) = lam (subst (addvar θ) e) subst θ (app e e') = app (subst θ e) (subst θ e') subst1 : {τ τ0 : TType} → [] ⊢ τ0 → ([] ,, τ0) ⊢ τ → [] ⊢ τ subst1 e0 e = subst (tt , e0) e -- these are not tasks (unless you really want); I didn't get to prove them; sorry! compose : {τ1 τ2 : TType} {Γ : Ctx} (θ : [] ⊢c Γ) (e' : [] ⊢ τ1) (e : Γ ,, τ1 ⊢ τ2) → subst (θ , e') e ≡ subst1 e' (subst (addvar θ) e) compose = {!!} ident : {Γ : Ctx} {τ : TType} {e : Γ ⊢ τ} → e ≡ subst (id-subst) e ident = {!!} open RenamingAndSubstitution using (subst1 ; _⊢c_ ; subst ; ident ; compose) {- θ : Γ ⊢c Γ' means θ is a substitution for Γ' in terms of Γ. It is defined as follows: _⊢c_ : Ctx → Ctx → Set Γ' ⊢c [] = Unit Γ' ⊢c (τ ∷ Γ) = (Γ' ⊢c Γ) × (Γ' ⊢ τ) -- apply a substitution to a term subst : {Γ Γ' : Ctx}{τ : TType} → Γ ⊢c Γ' → Γ' ⊢ τ → Γ ⊢ τ -- substitution for a single variable subst1 : {τ τ0 : TType} → [] ⊢ τ0 → ([] ,, τ0) ⊢ τ → [] ⊢ τ -- you will need these two properties: compose : {τ1 τ2 : TType} {Γ : Ctx} (θ : [] ⊢c Γ) (e' : [] ⊢ τ1) (e : Γ ,, τ1 ⊢ τ2) → subst (θ , e') e == subst1 e' (subst (addvar θ) e) ident : {Γ : Ctx} {τ : TType} {e : Γ ⊢ τ} → e == subst (id-subst) e -} module OpSem where -- step relation data _↦_ : {τ : TType} → [] ⊢ τ → [] ⊢ τ → Set where Step/app :{τ1 τ2 : TType} {e e' : [] ⊢ τ1 ⇒ τ2} {e1 : [] ⊢ τ1} → e ↦ e' → (app e e1) ↦ (app e' e1) Step/β : {τ1 τ2 : TType} {e : [] ,, τ1 ⊢ τ2} {e1 : [] ⊢ τ1} → (app (lam e) e1) ↦ subst1 e1 e -- reflexive/transitive closure data _↦*_ : {τ : TType} → [] ⊢ τ → [] ⊢ τ → Set where Done : {τ : TType} {e : [] ⊢ τ} → e ↦* e Step : {τ : TType} {e1 e2 e3 : [] ⊢ τ} → e1 ↦ e2 → e2 ↦* e3 → e1 ↦* e3 open OpSem {- Next, you will prove "very weak normalization". The theorem is that any closed term *of base type b* evaluates to the constant c. No claims are made about terms of function type. -} module VeryWeakNormalization where WN : (τ : TType) → [] ⊢ τ → Set -- WN_τ(e) iff e ↦* c WN b e = e ↦* c -- WN_τ(e) iff for all e1 : τ1, if WN_τ1(e1) then WN_τ2(e e1) WN (τ1 ⇒ τ2) e = (e1 : [] ⊢ τ1) → WN τ1 e1 → WN τ2 (app e e1) -- extend WN to contexts and substitutions WNc : (Γ : Ctx) → [] ⊢c Γ → Set WNc [] θ = tt WNc (τ ∷ Γ) (θ , e) = WNc Γ θ × WN τ e {- TASK 3 : show that the relation is closed under head expansion: -} head-expand : (τ : TType) {e e' : [] ⊢ τ} → e ↦ e' → WN τ e' → WN τ e head-expand = {!!} {- TASK 4 : prove the fundamental theorem Hint: you may find it helpful to use transport : {A : Set} (B : A → Set) {a1 a2 : A} → a1 == a2 → (B a1 → B a2) to coerce by a propositional equality. -} fund : {Γ : Ctx} {τ : TType} {θ : [] ⊢c Γ} → (e : Γ ⊢ τ) → WNc Γ θ → WN τ (subst θ e) fund = {!!} {- TASK 5 : conclude weak normalization at base type -} corollary : (e : [] ⊢ b) → e ↦* c corollary = {!!} {- TASK 6 : change the definition of the logical relation so that you also can conclude normalization at function type. -} module WeakNormalization where open RenamingAndSubstitution using (addvar) --- you will want to use -- addvar : {Γ Γ' : Ctx} {τ : TType} → Γ ⊢c Γ' → (Γ ,, τ) ⊢c (Γ' ,, τ) -- Hint: you will need a couple of lemmas about ↦* that we didn't need above -- (I used three of them) {- TASK 6a -} corollary1 : (e : [] ⊢ b) → e ↦* c corollary1 e = {!!} {- TASK 6b -} corollary2 : {τ1 τ2 : TType} (e : [] ⊢ τ1 ⇒ τ2) → Σ \(e' : _) → e ↦* (lam e') corollary2 e = {!!}
{ "alphanum_fraction": 0.4865171371, "avg_line_length": 32, "ext": "agda", "hexsha": "26efbd3e203e7bcb6784114f0f06b1fb8615b8fd", "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": "785c3d1f93ce2dac7801504b806abfd59f3875f6", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "ayberkt/system-t-normalization", "max_forks_repo_path": "SystemT-original.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "785c3d1f93ce2dac7801504b806abfd59f3875f6", "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": "ayberkt/system-t-normalization", "max_issues_repo_path": "SystemT-original.agda", "max_line_length": 103, "max_stars_count": 3, "max_stars_repo_head_hexsha": "785c3d1f93ce2dac7801504b806abfd59f3875f6", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "ayberkt/system-t-normalization", "max_stars_repo_path": "SystemT-original.agda", "max_stars_repo_stars_event_max_datetime": "2016-06-25T03:40:58.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-24T14:36:42.000Z", "num_tokens": 3350, "size": 7936 }
{-# OPTIONS --universe-polymorphism #-} open import Categories.Category open import Categories.Object.BinaryProducts open import Categories.Object.Exponentiating module Categories.Object.Exponentiating.Functor {o ℓ e} (C : Category o ℓ e) (binary : BinaryProducts C) (Σ : Category.Obj C) (exponentiating : Exponentiating C binary Σ) where open Category C open BinaryProducts binary open Exponentiating exponentiating open Equiv open HomReasoning import Categories.Object.Product.Morphisms open Categories.Object.Product.Morphisms C open import Categories.Functor using (Functor; Contravariant) renaming (_∘_ to _∘F_) Σ↑-Functor : Contravariant C C Σ↑-Functor = record { F₀ = Σ↑_ ; F₁ = [Σ↑_] ; identity = identity ; homomorphism = homomorphism ; F-resp-≡ = F-resp-≡ } where .identity : ∀ {A} → [Σ↑ id {A} ] ≡ id identity {A} = begin λ-abs A (eval ∘ second id) ↓⟨ λ-cong (∘-resp-≡ refl (id⁂id product)) ⟩ λ-abs A (eval ∘ id) ↓⟨ λ-cong identityʳ ⟩ λ-abs A eval ↓⟨ λ-η-id ⟩ id ∎ .homomorphism : ∀ {X Y Z} {f : X ⇒ Y} {g : Y ⇒ Z} → [Σ↑ (g ∘ f) ] ≡ [Σ↑ f ] ∘ [Σ↑ g ] homomorphism {X}{Y}{Z}{f}{g} = begin λ-abs X (eval ∘ second (g ∘ f)) ↑⟨ λ-cong (refl ⟩∘⟨ second∘second) ⟩ λ-abs X (eval ∘ second g ∘ second f) ↑⟨ λ-cong assoc ⟩ λ-abs X ((eval ∘ second g) ∘ second f) ↓⟨ λ-distrib ⟩ λ-abs X (eval ∘ second f) ∘ λ-abs Y (eval ∘ second g) ∎ .F-resp-≡ : ∀ {A B}{f g : A ⇒ B } → f ≡ g → [Σ↑ f ] ≡ [Σ↑ g ] F-resp-≡ {A}{B}{f}{g} f≡g = begin λ-abs A (eval ∘ second f) ↓⟨ λ-cong (refl ⟩∘⟨ ⟨⟩-cong₂ refl (f≡g ⟩∘⟨ refl)) ⟩ λ-abs A (eval ∘ second g) ∎ Σ²-Functor : Functor C C Σ²-Functor = Σ↑-Functor ∘F Functor.op Σ↑-Functor
{ "alphanum_fraction": 0.4825986079, "avg_line_length": 29.1216216216, "ext": "agda", "hexsha": "822b26e09155a31eab2ff87d62b1d7dd7146dc22", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Object/Exponentiating/Functor.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Object/Exponentiating/Functor.agda", "max_line_length": 63, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Object/Exponentiating/Functor.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 727, "size": 2155 }
-- Module shadowing using generated modules for records and datatypes module Issue260c where record R : Set where module R where
{ "alphanum_fraction": 0.8076923077, "avg_line_length": 21.6666666667, "ext": "agda", "hexsha": "421592933c4dbfff688ac8af389c9db06edcf61d", "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/Issue260c.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/Issue260c.agda", "max_line_length": 69, "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/Issue260c.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": 29, "size": 130 }
open import Structure.Setoid open import Structure.Category open import Type module Structure.Category.Monad.ExtensionSystem {ℓₒ ℓₘ ℓₑ} {cat : CategoryObject{ℓₒ}{ℓₘ}{ℓₑ}} where import Data.Tuple as Tuple import Function.Equals open Function.Equals.Dependent open import Functional.Dependent using () renaming (_∘_ to _∘ᶠⁿ_) import Lvl open import Logic.Predicate open import Structure.Category.Functor open import Structure.Category.Functor.Functors as Functors open import Structure.Category.Monad{cat = cat} open import Structure.Category.NaturalTransformation open import Structure.Category.NaturalTransformation.NaturalTransformations as NaturalTransformations open import Structure.Category.Proofs open import Structure.Categorical.Properties open import Structure.Function open import Structure.Operator open import Structure.Relator.Equivalence open import Structure.Relator.Properties open import Syntax.Transitivity open CategoryObject(cat) open Category.ArrowNotation(category) open Category(category) open NaturalTransformations.Raw(cat)(cat) private open module MorphismEquiv {x}{y} = Equivalence (Equiv-equivalence ⦃ morphism-equiv{x}{y} ⦄) using () record ExtensionSystem (T : Object → Object) : Type{Lvl.of(Type.of(cat))} where field η : (x : Object) → (x ⟶ T(x)) ext : ∀{x y} → (x ⟶ T(y)) → (T(x) ⟶ T(y)) μ : (x : Object) → (T(T(x)) ⟶ T(x)) μ(x) = ext(id{x = T(x)}) field ⦃ ext-function ⦄ : ∀{x y} → Function(ext{x}{y}) ext-inverse : ∀{x} → (ext(η(x)) ≡ id) -- ext ∘ᶠⁿ η ⊜ idᴺᵀ ext-identity : ∀{x y}{f : x ⟶ T(y)} → (ext(f) ∘ η(x) ≡ f) ext-distribute : ∀{x y z}{f : y ⟶ T(z)}{g : x ⟶ T(y)} → (ext(ext(f) ∘ g) ≡ ext(f) ∘ ext(g)) functor : Functor(category)(category)(T) Functor.map functor {x} {y} f = ext(η(y) ∘ f) Function.congruence (Functor.map-function functor) xy = congruence₁(ext) (congruence₂ᵣ(_∘_)(_) xy) Functor.op-preserving functor {x} {y} {z} {f} {g} = ext(η(z) ∘ f ∘ g) 🝖-[ congruence₁(ext) (Morphism.associativity(_∘_)) ]-sym ext((η(z) ∘ f) ∘ g) 🝖-[ congruence₁(ext) (congruence₂ₗ(_∘_)(g) (symmetry(_≡_) ext-identity)) ] ext((ext(η(z) ∘ f) ∘ η(y)) ∘ g) 🝖-[ congruence₁(ext) (Morphism.associativity(_∘_)) ] ext(ext(η(z) ∘ f) ∘ (η(y) ∘ g)) 🝖-[ ext-distribute ] ext(η(z) ∘ f) ∘ ext(η(y) ∘ g) 🝖-end Functor.id-preserving functor {x} = ext(η(x) ∘ id) 🝖-[ congruence₁(ext) (Morphism.identityᵣ(_∘_)(id)) ] ext(η(x)) 🝖-[ ext-inverse ] id 🝖-end open Functor(functor) monad : Monad(T) ⦃ functor ⦄ ∃.witness (Monad.Η monad) = η NaturalTransformation.natural (∃.proof (Monad.Η monad)) = symmetry(_≡_) ext-identity ∃.witness (Monad.Μ monad) = μ NaturalTransformation.natural (∃.proof (Monad.Μ monad)) {x} {y} {f} = μ(y) ∘ ext(η(T(y)) ∘ ext(η(y) ∘ f)) 🝖[ _≡_ ]-[] ext(id) ∘ ext(η(T(y)) ∘ ext(η(y) ∘ f)) 🝖-[ ext-distribute ]-sym ext(ext(id) ∘ (η(T(y)) ∘ ext(η(y) ∘ f))) 🝖-[ congruence₁(ext) (symmetry(_≡_) (Morphism.associativity(_∘_))) ] ext((ext(id) ∘ η(T(y))) ∘ ext(η(y) ∘ f)) 🝖-[ congruence₁(ext) (congruence₂ₗ(_∘_)(_) ext-identity) ] ext(id ∘ ext(η(y) ∘ f)) 🝖-[ congruence₁(ext) (Morphism.identityₗ(_∘_)(id)) ] ext(ext(η(y) ∘ f)) 🝖-[ congruence₁(ext) (Morphism.identityᵣ(_∘_)(id)) ]-sym ext(ext(η(y) ∘ f) ∘ id) 🝖-[ ext-distribute ] ext(η(y) ∘ f) ∘ ext(id) 🝖[ _≡_ ]-[] ext(η(y) ∘ f) ∘ μ(x) 🝖-end _⊜_.proof (Monad.μ-functor-[∘]-commutativity monad) {x} = -- TODO: Same as above? μ(x) ∘ map(μ(x)) 🝖[ _≡_ ]-[] ext(id) ∘ map(ext(id)) 🝖[ _≡_ ]-[] ext(id) ∘ ext(η(T(x)) ∘ ext(id)) 🝖-[ ext-distribute ]-sym ext(ext(id) ∘ (η(T(x)) ∘ ext(id))) 🝖-[ congruence₁(ext) (symmetry(_≡_) (Morphism.associativity(_∘_))) ] ext((ext(id) ∘ η(T(x))) ∘ ext(id)) 🝖-[ congruence₁(ext) (congruence₂ₗ(_∘_)(_) ext-identity) ] ext(id ∘ ext(id)) 🝖-[ congruence₁(ext) (Morphism.identityₗ(_∘_)(id)) ] ext(ext(id)) 🝖-[ congruence₁(ext) (Morphism.identityᵣ(_∘_)(id)) ]-sym ext(ext(id) ∘ id) 🝖-[ ext-distribute ] ext(id) ∘ ext(id) 🝖[ _≡_ ]-[] μ(x) ∘ μ(T(x)) 🝖-end _⊜_.proof (Monad.μ-functor-[∘]-identityₗ monad) {x} = μ(x) ∘ ext(η(T(x)) ∘ η(x)) 🝖[ _≡_ ]-[] ext(id) ∘ ext(η(T(x)) ∘ η(x)) 🝖[ _≡_ ]-[ ext-distribute ]-sym ext(ext(id) ∘ (η(T(x)) ∘ η(x))) 🝖[ _≡_ ]-[ congruence₁(ext) (symmetry(_≡_) (Morphism.associativity(_∘_))) ] ext((ext(id) ∘ η(T(x))) ∘ η(x)) 🝖[ _≡_ ]-[ congruence₁(ext) (congruence₂ₗ(_∘_)(_) ext-identity) ] ext(id ∘ η(x)) 🝖[ _≡_ ]-[ congruence₁(ext) (Morphism.identityₗ(_∘_)(id)) ] ext(η(x)) 🝖[ _≡_ ]-[ ext-inverse ] id 🝖[ _≡_ ]-end _⊜_.proof (Monad.μ-functor-[∘]-identityᵣ monad) {x} = μ(x) ∘ η(T(x)) 🝖[ _≡_ ]-[] ext(id) ∘ η(T(x)) 🝖[ _≡_ ]-[ ext-identity ] id 🝖[ _≡_ ]-end -- Also called: Kleisli composition. _∘ₑₓₜ_ : ∀{x y z} → (y ⟶ T(z)) → (x ⟶ T(y)) → (x ⟶ T(z)) f ∘ₑₓₜ g = ext(f) ∘ g idₑₓₜ : ∀{x} → (x ⟶ T(x)) idₑₓₜ{x} = η(x) module FunctionalNames where -- Name sources: -- https://wiki.haskell.org/Lifting -- Also called: unit. lift : ∀{x} → (x ⟶ T(x)) lift{x} = η(x) -- Name sources: -- Javascript: Array.prototype.flat -- Scala: scala.collection.IterableOnceOps.flatten flatten : ∀{x} → (T(T(x)) ⟶ T(x)) flatten{x} = μ(x) -- Name sources: -- Javascript: Array.prototype.flatMap -- Java: Stream.flatMap -- Scala: scala.collection.IterableOnceOps.flatMap flatMap : ∀{x y} → (x ⟶ T(y)) → (T(x) ⟶ T(y)) flatMap = ext module HaskellNames where return = FunctionalNames.lift join = FunctionalNames.flatten bind = FunctionalNames.flatMap module _ where open Functor ⦃ … ⦄ open Monad ⦃ … ⦄ monad-to-extensionSystem : ∀{T : Object → Object} → ⦃ functor : Functor(category)(category)(T) ⦄ → ⦃ monad : Monad(T) ⦄ → ExtensionSystem(T) ExtensionSystem.η (monad-to-extensionSystem ⦃ functor ⦄ ⦃ monad ⦄) = η ExtensionSystem.ext (monad-to-extensionSystem ⦃ functor ⦄ ⦃ monad ⦄) = ext Function.congruence (ExtensionSystem.ext-function monad-to-extensionSystem {x} {y}) {f} {g} fg = ((μ(y) ∘_) ∘ᶠⁿ map) f 🝖[ _≡_ ]-[] μ(y) ∘ map f 🝖[ _≡_ ]-[ congruence₂ᵣ(_∘_) _ (congruence₁(map) fg) ] μ(y) ∘ map g 🝖[ _≡_ ]-[] ((μ(y) ∘_) ∘ᶠⁿ map) g 🝖[ _≡_ ]-end ExtensionSystem.ext-inverse monad-to-extensionSystem {x} = ((μ(x) ∘_) ∘ᶠⁿ map)(η(x)) 🝖[ _≡_ ]-[] μ(x) ∘ map(η(x)) 🝖[ _≡_ ]-[ _⊜_.proof μ-functor-[∘]-identityₗ ] id 🝖[ _≡_ ]-end ExtensionSystem.ext-identity (monad-to-extensionSystem {T = T}) {x} {y} {f} = ((μ(y) ∘_) ∘ᶠⁿ map)(f) ∘ η(x) 🝖[ _≡_ ]-[] (μ(y) ∘ (map f)) ∘ η(x) 🝖[ _≡_ ]-[ Morphism.associativity(_∘_) ] μ(y) ∘ ((map f) ∘ η(x)) 🝖[ _≡_ ]-[ congruence₂ᵣ(_∘_) _ η-natural ]-sym μ(y) ∘ (η(T(y)) ∘ f) 🝖[ _≡_ ]-[ Morphism.associativity(_∘_) ]-sym (μ(y) ∘ η(T(y))) ∘ f 🝖[ _≡_ ]-[ congruence₂ₗ(_∘_) _ (_⊜_.proof μ-functor-[∘]-identityᵣ) ] id ∘ f 🝖[ _≡_ ]-[ Morphism.identityₗ(_∘_)(id) ] f 🝖[ _≡_ ]-end ExtensionSystem.ext-distribute (monad-to-extensionSystem {T = T}) {x} {y} {z} {f} {g} = ((μ(z) ∘_) ∘ᶠⁿ map)(((μ(z) ∘_) ∘ᶠⁿ map)(f) ∘ g) 🝖[ _≡_ ]-[] μ(z) ∘ map((μ(z) ∘ (map f)) ∘ g) 🝖[ _≡_ ]-[ congruence₂ᵣ(_∘_) _ op-preserving ] μ(z) ∘ (map(μ(z) ∘ (map f)) ∘ (map g)) 🝖[ _≡_ ]-[ congruence₂ᵣ(_∘_) _ (congruence₂ₗ(_∘_) _ op-preserving) ] μ(z) ∘ ((map(μ(z)) ∘ map(map f)) ∘ (map g)) 🝖[ _≡_ ]-[ associate4-231-121 category ] (μ(z) ∘ map(μ(z))) ∘ (map(map f) ∘ (map g)) 🝖[ _≡_ ]-[ congruence₂ₗ(_∘_) _ (_⊜_.proof μ-functor-[∘]-commutativity) ] (μ(z) ∘ μ(T(z))) ∘ (map(map f) ∘ (map g)) 🝖[ _≡_ ]-[ associate4-213-121 category ]-sym (μ(z) ∘ (μ(T(z)) ∘ map(map f))) ∘ (map g) 🝖[ _≡_ ]-[ congruence₂ₗ(_∘_) _ (congruence₂ᵣ(_∘_) _ μ-natural) ] (μ(z) ∘ ((map f) ∘ μ(y))) ∘ (map g) 🝖[ _≡_ ]-[ associate4-213-121 category ] (μ(z) ∘ (map f)) ∘ (μ(y) ∘ (map g)) 🝖[ _≡_ ]-[] ((μ(z) ∘_) ∘ᶠⁿ map)(f) ∘ ((μ(y) ∘_) ∘ᶠⁿ map)(g) 🝖[ _≡_ ]-end
{ "alphanum_fraction": 0.5346803734, "avg_line_length": 50.0769230769, "ext": "agda", "hexsha": "7ecf1db84546053f3afa63104c753758eaac47d1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Category/Monad/ExtensionSystem.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Category/Monad/ExtensionSystem.agda", "max_line_length": 142, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Category/Monad/ExtensionSystem.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": 3542, "size": 8463 }
{-# OPTIONS --without-K --safe #-} open import Level open import Categories.Category open import Categories.Monad module Categories.Monad.Idempotent {o ℓ e} {C : Category o ℓ e} (M : Monad C) where open import Categories.NaturalTransformation open import Categories.NaturalTransformation.Equivalence open import Categories.Functor private module M = Monad M open NaturalTransformation record Idempotent : Set (o ⊔ ℓ ⊔ e) where field Fη≡ηF : ∀ X → C [ η (M.F ∘ˡ M.η) X ≈ η (M.η ∘ʳ M.F) X ]
{ "alphanum_fraction": 0.7196819085, "avg_line_length": 23.9523809524, "ext": "agda", "hexsha": "a3425405e6325b53442e9d52132ea8493fb9b307", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Monad/Idempotent.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Monad/Idempotent.agda", "max_line_length": 83, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Monad/Idempotent.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 153, "size": 503 }
{- Formal verification of authenticated append-only skiplists in Agda, version 1.0. Copyright (c) 2021 Victor C Miraldo and Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import Data.Unit.NonEta open import Data.Empty open import Data.Sum open import Data.Product open import Data.Product.Properties open import Data.Fin hiding (_<_; _≤_) open import Data.Fin.Properties using () renaming (_≟_ to _≟Fin_) open import Data.Nat renaming (_≟_ to _≟ℕ_; _≤?_ to _≤?ℕ_) open import Data.Nat.Properties open import Data.List renaming (map to List-map) open import Data.List.Properties using (∷-injective; length-map) open import Data.List.Relation.Unary.Any renaming (map to Any-map) open import Data.List.Relation.Unary.All renaming (lookup to All-lookup; map to All-map) open import Data.List.Relation.Unary.All.Properties hiding (All-map) open import Data.List.Relation.Unary.Any.Properties renaming (map⁺ to Any-map⁺) open import Data.List.Relation.Binary.Pointwise using (decidable-≡) open import Data.Bool hiding (_<_; _≤_) open import Data.Maybe renaming (map to Maybe-map) open import Function open import Relation.Binary.PropositionalEquality open import Relation.Binary.Definitions open import Relation.Nullary open import AAOSL.Lemmas open import AAOSL.Abstract.Hash open import AAOSL.Abstract.DepRel module AAOSL.Abstract.EvoCR -- A Hash function maps a bytestring into a hash. (hash : ByteString → Hash) -- And is collision resistant (hash-cr : ∀{x y} → hash x ≡ hash y → Collision hash x y ⊎ x ≡ y) -- Indexes can be encoded in an injective way (encodeI : ℕ → ByteString) (encodeI-inj : (m n : ℕ) → encodeI m ≡ encodeI n → m ≡ n) (dep : DepRel) where open WithCryptoHash hash hash-cr open import AAOSL.Abstract.Advancement hash hash-cr encodeI encodeI-inj dep open DepRel dep -- Returns the last element on path a that is smaller than k last-bef : ∀{j i k}(a : AdvPath j i)(i<k : i < k)(k≤j : k ≤′ j) → ℕ last-bef {j} a i<k ≤′-refl = j -- TODO-1 : The same or similar proof is repeated numerous times below; refactor for clarity last-bef AdvDone i<k (≤′-step k≤j) = ⊥-elim (1+n≰n (≤-unstep (≤-trans i<k (≤′⇒≤ k≤j)))) last-bef {k = k} (AdvThere d h a) i<k (≤′-step k≤j) with hop-tgt h ≤?ℕ k ...| yes th≤k = hop-tgt h ...| no th>k = last-bef a i<k (≤⇒≤′ (≰⇒≥ th>k)) last-bef-correct : ∀{j i k}(a : AdvPath j i)(i<k : i < k)(k≤j : k ≤′ j) → last-bef a i<k k≤j ∈AP a last-bef-correct {j} a i<k ≤′-refl = ∈AP-src last-bef-correct AdvDone i<k (≤′-step k≤j) = ⊥-elim (1+n≰n (≤-unstep (≤-trans i<k (≤′⇒≤ k≤j)))) last-bef-correct {k = k} (AdvThere d h a) i<k (≤′-step k≤j) with hop-tgt h ≤?ℕ k ...| yes th≤k = step (<⇒≢ (hop-< h)) ∈AP-src ...| no th>k with last-bef-correct a i<k (≤⇒≤′ (≰⇒≥ th>k)) ...| ind = step (<⇒≢ (≤-trans (s≤s (∈AP-≤ ind)) (hop-< h))) ind lemma5-hop : ∀{j i}(a : AdvPath j i) → ∀{k} → j < k → (h : HopFrom k) → hop-tgt h ≤ j → i ≤ hop-tgt h → hop-tgt h ∈AP a lemma5-hop {j} a j<k h th≤j i≤th with hop-tgt h ≟ℕ j ...| yes th≡j rewrite th≡j = ∈AP-src ...| no th≢j with a ...| AdvDone rewrite ≤-antisym th≤j i≤th = hereTgtDone ...| (AdvThere x h' a') with hop-tgt h' ≟ℕ hop-tgt h ...| yes th'≡th rewrite sym th'≡th = step (<⇒≢ (hop-< h')) ∈AP-src ...| no th'≢th with hop-tgt h' ≤?ℕ hop-tgt h ...| yes th'≤th = ⊥-elim (1+n≰n (≤-trans j<k (hops-nested-or-nonoverlapping (≤∧≢⇒< th'≤th th'≢th) (≤∧≢⇒< th≤j th≢j)))) ...| no th'>th = step th≢j (lemma5-hop a' (≤-trans (hop-< h') (≤-unstep j<k)) h (≰⇒≥ th'>th) i≤th) lemma5 : ∀{j i k}(a : AdvPath j i)(i<k : i < k)(k≤j : k ≤′ j) → ∀{i₀}(b : AdvPath k i₀) → i₀ ≤ i → last-bef a i<k k≤j ∈AP b lemma5 a i<k ≤′-refl b i₀≤i = ∈AP-src lemma5 AdvDone i<k (≤′-step k≤j) b i₀≤i = ⊥-elim (1+n≰n (≤-unstep (≤-trans i<k (≤′⇒≤ k≤j)))) lemma5 {k = k} (AdvThere d h a) i<k (≤′-step k≤j) b i₀≤i with hop-tgt h ≤?ℕ k ...| yes th≤k = lemma5-hop b (s≤s (≤′⇒≤ k≤j)) h th≤k (≤-trans i₀≤i (lemma1 a)) ...| no th>k = lemma5 a i<k (≤⇒≤′ (≰⇒≥ th>k)) b i₀≤i -- returns the first element on path a that is greather than k first-aft : ∀{j i k}(a : AdvPath j i)(i≤k : i ≤′ k)(k<j : k < j) → ℕ first-aft {i = i} a ≤′-refl k<j = i first-aft AdvDone (≤′-step i≤k) k<j = ⊥-elim (1+n≰n (≤-unstep (≤-trans k<j (≤′⇒≤ i≤k)))) first-aft {j} {i} {k} (AdvThere d h a) (≤′-step i≤k) k<j with hop-tgt h ≟ℕ k ...| yes _ = k ...| no th≢k with hop-tgt h ≤?ℕ k ...| yes th≤k = j ...| no th≥k = first-aft a (≤′-step i≤k) (≰⇒> th≥k) first-aft-correct : ∀{j i k}(a : AdvPath j i)(i≤k : i ≤′ k)(k<j : k < j) → first-aft a i≤k k<j ∈AP a first-aft-correct a ≤′-refl k<j = ∈AP-tgt first-aft-correct AdvDone (≤′-step i≤k) k<j = ⊥-elim (1+n≰n (≤-unstep (≤-trans k<j (≤′⇒≤ i≤k)))) first-aft-correct {j} {i} {k} (AdvThere d h a) (≤′-step i≤k) k<j with hop-tgt h ≟ℕ k ...| yes th≡k rewrite sym th≡k = step (<⇒≢ k<j) ∈AP-src ...| no th≢k with hop-tgt h ≤?ℕ k ...| yes th≤k = ∈AP-src ...| no th≥k with first-aft-correct a (≤′-step i≤k) (≰⇒> th≥k) ...| ind = step (<⇒≢ (≤-trans (s≤s (∈AP-≤ ind)) (hop-< h))) ind lemma5'-hop : ∀{j j₁ k}(h : HopFrom j) → hop-tgt h < k → k < j → (b : AdvPath j₁ k) → j ≤ j₁ → j ∈AP b lemma5'-hop {j} {j₁} h th<k k≤j b j≤j₁ with j ≟ℕ j₁ ...| yes refl = ∈AP-src ...| no j≢j₁ with b ...| AdvDone = ⊥-elim (1+n≰n (≤-trans k≤j j≤j₁)) ...| (AdvThere x hb b') with hop-tgt hb ≟ℕ j ...| yes refl = step (<⇒≢ (hop-< hb)) ∈AP-src ...| no tb≢j with hop-tgt hb ≤?ℕ j ...| no tb≰j = step j≢j₁ (lemma5'-hop h th<k k≤j b' (≰⇒≥ tb≰j)) ...| yes tb≤j with hops-nested-or-nonoverlapping (≤-trans th<k (lemma1 b')) (≤∧≢⇒< tb≤j tb≢j) ...| j₁≤j rewrite ≤-antisym j≤j₁ j₁≤j = ∈AP-src lemma5' : ∀{j i k}(a : AdvPath j i)(i≤k : i ≤′ k)(k<j : k < j) → ∀{j₁}(b : AdvPath j₁ k) → j ≤ j₁ → first-aft a i≤k k<j ∈AP b lemma5' a ≤′-refl k<j b j≤j₁ = ∈AP-tgt lemma5' AdvDone (≤′-step i≤k) k<j b j≤j₁ = ⊥-elim (1+n≰n (≤-unstep (≤-trans k<j (≤′⇒≤ i≤k)))) lemma5' {j} {i} {k} (AdvThere d h a) (≤′-step i≤k) k<j b j≤j₁ with hop-tgt h ≟ℕ k ...| yes _ = ∈AP-tgt ...| no th≢k with hop-tgt h ≤?ℕ k ...| yes th≤k = lemma5'-hop h (≤∧≢⇒< th≤k th≢k) k<j b j≤j₁ ...| no th≥k = lemma5' a (≤′-step i≤k) (≰⇒> th≥k) b (≤-unstep (≤-trans (hop-< h) j≤j₁)) ∈AP-⊕-intro-l : ∀{j k i m} → {a₂ : AdvPath j k}{a₁ : AdvPath k i} → m ∈AP a₂ → m ∈AP (a₂ ⊕ a₁) ∈AP-⊕-intro-l hereTgtThere = hereTgtThere ∈AP-⊕-intro-l (step prog m∈a) = step prog (∈AP-⊕-intro-l m∈a) ∈AP-⊕-intro-l {a₁ = AdvDone} hereTgtDone = hereTgtDone ∈AP-⊕-intro-l {a₁ = AdvThere d h a} hereTgtDone = hereTgtThere ∈AP-⊕-intro-r : ∀{j k i m} → {a₂ : AdvPath j k}{a₁ : AdvPath k i} → m ∈AP a₁ → m ∈AP (a₂ ⊕ a₁) ∈AP-⊕-intro-r {a₂ = AdvDone} hyp = hyp ∈AP-⊕-intro-r {k = k} {a₂ = AdvThere d h a} hyp = step (<⇒≢ (≤-trans (s≤s (∈AP-≤ hyp)) (≤-trans (s≤s (lemma1 a)) (hop-< h)))) (∈AP-⊕-intro-r {a₂ = a} hyp) ∈AP-⊕-≤-r : ∀{j k i m}{a₂ : AdvPath j k}{a₁ : AdvPath k i} → m ∈AP (a₂ ⊕ a₁) → m ≤ k → m ∈AP a₁ ∈AP-⊕-≤-r {a₂ = AdvDone} m∈a12 m≤k = m∈a12 ∈AP-⊕-≤-r {a₂ = AdvThere d h a₂} hereTgtThere m≤k = ⊥-elim (1+n≰n (≤-trans (≤-trans (s≤s (lemma1 a₂)) (hop-< h)) m≤k)) ∈AP-⊕-≤-r {a₂ = AdvThere d h a₂} (step x m∈a12) m≤k = ∈AP-⊕-≤-r m∈a12 m≤k findM : ∀ {j i₂ s₁ s₂ tgt} → (a₁₁ : AdvPath j s₁) → (a₂₁ : AdvPath j s₂) → (a₂₂ : AdvPath s₂ i₂) → (m₂ : MembershipProof s₂ tgt) → i₂ ≤ s₁ → tgt ≤ s₁ → s₁ ≤ s₂ → ∃[ M ] (M ∈AP a₂₂ × M ∈AP mbr-proof m₂ × M ∈AP a₁₁) findM {s₁ = s₁} {s₂} a₁₁ a₂₁ a₂₂ m₂ i₂≤s₁ t≤s₁ s₁≤s₂ with <-cmp s₁ s₂ ...| tri> _ _ s₂<s₁ = ⊥-elim (<⇒≢ s₂<s₁ (sym (≤-antisym s₁≤s₂ (≤-unstep s₂<s₁)))) ...| tri≈ _ refl _ = s₁ , ∈AP-src , ∈AP-src , ∈AP-tgt ...| tri< s₁<s₂ _ _ = last-bef a₁₁ s₁<s₂ (≤⇒≤′ (lemma1 a₂₁)) , lemma5 a₁₁ s₁<s₂ (≤⇒≤′ (lemma1 a₂₁)) a₂₂ i₂≤s₁ , lemma5 a₁₁ s₁<s₂ (≤⇒≤′ (lemma1 a₂₁)) (mbr-proof m₂) t≤s₁ , last-bef-correct a₁₁ s₁<s₂ (≤⇒≤′ (lemma1 a₂₁)) findR : ∀{j i₁ s₁ s₂ tgt} → (a₁₁ : AdvPath j s₁) → (a₁₂ : AdvPath s₁ i₁) → (a₂₁ : AdvPath j s₂) → (m₁ : MembershipProof s₁ tgt)(m₂ : MembershipProof s₂ tgt) → i₁ ≤ tgt → tgt ≤ s₁ → s₁ ≤ s₂ -- wlog → ∃[ R ] (R ∈AP mbr-proof m₁ × R ∈AP mbr-proof m₂ × R ∈AP a₁₂) findR {s₁ = s₁} {tgt = tgt} a₁₁ a₁₂ a₂₁ m₁ m₂ i₁≤t t≤s₁ s₁≤s₂ with <-cmp tgt s₁ ...| tri> _ _ s₁<t = ⊥-elim (<⇒≢ s₁<t (sym (≤-antisym t≤s₁ (≤-unstep s₁<t)))) ...| tri≈ _ refl _ = s₁ , ∈AP-src , ∈AP-tgt , ∈AP-src ...| tri< t<s₁ _ _ = first-aft a₁₂ (≤⇒≤′ i₁≤t) t<s₁ , lemma5' a₁₂ (≤⇒≤′ i₁≤t) t<s₁ (mbr-proof m₁) ≤-refl , lemma5' a₁₂ (≤⇒≤′ i₁≤t) t<s₁ (mbr-proof m₂) s₁≤s₂ , first-aft-correct a₁₂ (≤⇒≤′ i₁≤t) t<s₁ -- check Figure 4 (page 12) in: https://arxiv.org/pdf/cs/0302010.pdf -- -- a₁ is dashed black line -- a₂ is dashed gray line -- m₁ is thick black line -- m₂ is thick gray line -- s₁ is j -- s₂ is k -- j is n -- tgt is i evo-cr : ∀{j i₁ i₂}{t₁ t₂ : View} → (a₁ : AdvPath j i₁) → (a₂ : AdvPath j i₂) → rebuild a₁ t₁ j ≡ rebuild a₂ t₂ j → ∀{s₁ s₂ tgt}{u₁ u₂ : View} → (m₁ : MembershipProof s₁ tgt)(m₂ : MembershipProof s₂ tgt) → s₁ ∈AP a₁ → s₂ ∈AP a₂ → s₁ ≤ s₂ -- wlog → i₁ ≤ tgt → i₂ ≤ tgt → rebuildMP m₁ u₁ s₁ ≡ rebuild a₁ t₁ s₁ → rebuildMP m₂ u₂ s₂ ≡ rebuild a₂ t₂ s₂ → HashBroke ⊎ (mbr-datum m₁ ≡ mbr-datum m₂) evo-cr {t₁ = t₁} {t₂} a₁ a₂ hyp {s₁} {s₂} {tgt} {u₁} {u₂} m₁ m₂ s₁∈a₁ s₂∈a₂ s₁≤s₂ i₁≤t i₂≤t c₁ c₂ with ∈AP-cut a₁ s₁∈a₁ | ∈AP-cut a₂ s₂∈a₂ ...| ((a₁₁ , a₁₂) , refl) | ((a₂₁ , a₂₂) , refl) with lemma1 (mbr-proof m₁) ...| t≤s₁ -- The first part of the proof is find some points common to three -- of the provided proofs. This is given in Figure 4 of Maniatis and Baker, -- and they are called M and R too, to help make it at least a little clear. -- First we find a point that belongs in a₂, m₁ and a₁. with findM a₁₁ a₂₁ a₂₂ m₂ (≤-trans i₂≤t t≤s₁) t≤s₁ s₁≤s₂ ...| M , M∈a₂₂ , M∈m₂ , M∈a₁₁ -- Next, we find a point that belongs in m₁, m₂ and a₁. with findR a₁₁ a₁₂ a₂₁ m₁ m₂ i₁≤t t≤s₁ s₁≤s₂ ...| R , R∈m₁ , R∈m₂ , R∈a₁₂ -- Now, since a₁ and a₂ rebuild to the same hash and M belongs -- to both these proofs, the hash for M is the same. with AgreeOnCommon a₁ a₂ hyp (∈AP-⊕-intro-l M∈a₁₁) (∈AP-⊕-intro-r M∈a₂₂) ...| inj₁ hb = inj₁ hb ...| inj₂ M-a1a2 -- Similarly, for a₂₂ and m₂ with AgreeOnCommon a₂₂ (mbr-proof m₂) (trans (sym (rebuild-⊕ a₂₁ a₂₂ ∈AP-src)) (sym c₂)) M∈a₂₂ M∈m₂ ...| inj₁ hb = inj₁ hb ...| inj₂ M-a22m2 -- Which brings us to: rebuild a1 M == rebuild m2 M with trans (trans M-a1a2 (rebuild-⊕ a₂₁ a₂₂ M∈a₂₂)) M-a22m2 ...| M-a1m2 -- If a1 and m2 agree on one point, they agree on all points. In particular, they -- agree on R! with ∈AP-cut (mbr-proof m₂) M∈m₂ ...| ((m₂₁ , m₂₂) , refl) with trans M-a1m2 (rebuild-⊕ m₂₁ m₂₂ ∈AP-src) ...| M-a1m22 with AgreeOnCommon-∈ a₁ m₂₂ (∈AP-⊕-intro-l M∈a₁₁) M-a1m22 (∈AP-⊕-intro-r R∈a₁₂) (∈AP-⊕-≤-r R∈m₂ (≤-trans (∈AP-≤ R∈a₁₂) (∈AP-≥ M∈a₁₁))) ...| inj₁ hb = inj₁ hb ...| inj₂ R-a1m22 with AgreeOnCommon a₁₂ (mbr-proof m₁) (trans (sym (rebuild-⊕ a₁₁ a₁₂ ∈AP-src)) (sym c₁)) R∈a₁₂ R∈m₁ ...| inj₁ hb = inj₁ hb ...| inj₂ R-a12m1 -- Which finally lets us argue that m1 and m2 also agree on R. Similarly, if they agree -- on one point they agree on all points. with ∈AP-cut (mbr-proof m₁) R∈m₁ ...| ((m₁₁ , m₁₂) , refl) with trans (trans (trans (sym R-a1m22) (rebuild-⊕ a₁₁ a₁₂ R∈a₁₂)) R-a12m1) (rebuild-⊕ m₁₁ m₁₂ ∈AP-src) ...| R-m22m12 with AgreeOnCommon-∈ m₂₂ m₁₂ (∈AP-⊕-≤-r R∈m₂ (≤-trans (∈AP-≤ R∈a₁₂) (∈AP-≥ M∈a₁₁))) R-m22m12 ∈AP-tgt ∈AP-tgt ...| inj₁ hb = inj₁ hb ...| inj₂ tgt-m22m12 with trans (rebuild-⊕ m₂₁ m₂₂ ∈AP-tgt) (trans tgt-m22m12 (sym (rebuild-⊕ m₁₁ m₁₂ ∈AP-tgt))) ...| tgt-m1m2 with rebuild-tgt-lemma (mbr-proof m₁) {u₁ ∪₁ (tgt , auth tgt (mbr-datum m₁) u₁) } | rebuild-tgt-lemma (mbr-proof m₂) {u₂ ∪₁ (tgt , auth tgt (mbr-datum m₂) u₂) } ...| l1 | l2 with trans (sym l1) (trans (sym tgt-m1m2) l2) ...| auths≡ rewrite ≟ℕ-refl tgt = auth-inj-1 {tgt} {mbr-datum m₁} {mbr-datum m₂} (mbr-not-init m₁) auths≡
{ "alphanum_fraction": 0.5411637264, "avg_line_length": 42.6534653465, "ext": "agda", "hexsha": "d7ea480a5df721e1faeee7a788164c66ba49fc61", "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": "356489da3a99c66807606eca8dd235dc6140649c", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "cwjnkins/aaosl-agda", "max_forks_repo_path": "AAOSL/Abstract/EvoCR.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "356489da3a99c66807606eca8dd235dc6140649c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "cwjnkins/aaosl-agda", "max_issues_repo_path": "AAOSL/Abstract/EvoCR.agda", "max_line_length": 120, "max_stars_count": null, "max_stars_repo_head_hexsha": "356489da3a99c66807606eca8dd235dc6140649c", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "cwjnkins/aaosl-agda", "max_stars_repo_path": "AAOSL/Abstract/EvoCR.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5987, "size": 12924 }
-- | Examples for SDE. module SDE-Example where open import Size import Level open import Function open import Relation.Binary open import Relation.Binary.PropositionalEquality as P hiding ([_]) open ≡-Reasoning open import Data.Product as Prod renaming (Σ to ⨿) open import Data.Nat as Nat open import Data.Sum as Sum open import Data.Fin hiding (_+_) open import Streams open import SDE -- Example: Basic operations over streams over naturals [_] : ∀{i} → ℕ → Stream {i} ℕ hd [ n ] = n tl [ n ] = [ 0 ] _⊕_ : ∀ {i} → Stream {i} ℕ → Stream {i} ℕ → Stream {i} ℕ hd (x ⊕ y) = hd x + hd y tl (x ⊕ y) = tl x ⊕ tl y _⊗_ : ∀{i} → Stream {i} ℕ → Stream {i} ℕ → Stream {i} ℕ hd (x ⊗ y) = hd x * hd y tl (_⊗_ {i} x y) {j} = (tl x ⊗ y) ⊕ ([ hd x ] ⊗ (tl y)) _•_ : ∀{i} → Stream {i} ℕ → Stream {i} ℕ → Stream {i} ℕ hd (x • y) = hd x tl (x • y) = tl y ⊗ (tl x • y) --------- Example for syntactic SDE. -- We define symbols iₙ (n ∈ ℕ), p and c through SDEs for streams -- over natural numbers. Here, iₙ is the injection of the number n into streams -- and corresponds to [n], p is stream addition, and c is the convolution -- product. The SDEs are the usual ones: -- (iₙ)(0) = n -- (iₙ)' = i₀ -- (p s t)(0) = s(0) + t(0) -- (p s t)' = p s' t' -- (c s t)(0) = s(0) * t(0) -- (c s t)' = p (c s' t) (c i_{s(0)} t') -- First, we define the signature, which has ℕ-many symbols for the iₙ of -- arity 0 and two symbols (p and c) of arity 2. Σ : Sig Σ = record { ∥_∥ = ℕ ⊎ Fin 2 ; ar = ar-Σ } where ar-Σ : ℕ ⊎ Fin 2 → Set ar-Σ (inj₁ _) = Fin 0 ar-Σ (inj₂ zero) = Fin 2 ar-Σ (inj₂ (suc _)) = Fin 2 -- Short-hand notations for the symbols. -- | Injections iₙ i : ℕ → ∥ Σ ∥ i n = inj₁ n -- | Plus p : ∥ Σ ∥ p = inj₂ (# 0) -- | Convolution product c : ∥ Σ ∥ c = inj₂ (# 1) -- | We are going to define the SDEs by means of two variabls, later called x -- and y. X : Set X = Fin 2 open Terms Σ public open SDE-Impl Σ X public -- | Short-hand names for variables and the variables denoting the corresponding -- derivatives. x y x' y' : V x = inj₁ (# 0) y = inj₁ (# 1) x' = inj₂ (# 0) y' = inj₂ (# 1) -- Term constructors i₁ : ℕ → T V i₁ n = sup (inj₁ (i n , (λ ()))) p₁ : T V → T V → T V p₁ t s = sup (inj₁ (p , α)) where α : Fin 2 → T V α zero = t α (suc _) = s c₁ : T V → T V → T V c₁ t s = sup (inj₁ (c , α)) where α : Fin 2 → T V α zero = t α (suc _) = s -- | SDEs describing iₙ, ⊕ and ⊗ E : SDE ℕ E (inj₁ n) = (λ _ → n) , (λ _ → sup (inj₁ (i 0 , (λ ())))) E (inj₂ zero) = out , step where out : (Fin 2 → ℕ) → ℕ out r = r (# 0) + r (# 1) step : (Fin 2 → ℕ) → T V step _ = p₁ (η x') (η y') E (inj₂ (suc _)) = out , step where out : (Fin 2 → ℕ) → ℕ out r = r (# 0) * r (# 1) step : (Fin 2 → ℕ) → T V step o = p₁ (c₁ (η x') (η y)) (c₁ (i₁ (o (# 0))) (η y')) -- | Assignment of variables to positions of the symbols of our SDEs vars : (f : ∥ Σ ∥) → ar Σ f → X vars (inj₁ x) () vars (inj₂ zero) x = x vars (inj₂ (suc _)) x = x -- | Standard variable assignment. put : ∀ {i} → Stream {i} ℕ → Stream {i} ℕ → (X → Stream {i} ℕ) put s t zero = s put s t (suc _) = t -- | Dummy stream for unused variables dummy : Stream ℕ hd dummy = 0 tl dummy = dummy -- | Define injection [_] from SDE [_]' : ℕ → Stream ℕ [ n ]' = ⟦ E ⟧ vars (i n) (put dummy dummy) -- | The addition of the streams s and t can be given by the interpretation -- of the symbol p of the SDE above with variable assignment (x ↦ s, y ↦ t). _⊕'_ : ∀ {i} → Stream {i} ℕ → Stream {i} ℕ → Stream {i} ℕ s ⊕' t = ⟦ E ⟧ vars p (put s t) _⊗'_ : ∀ {i} → Stream {i} ℕ → Stream {i} ℕ → Stream {i} ℕ s ⊗' t = ⟦ E ⟧ vars c (put s t) ------ Correctness for the examples -- We cheat a bit for now postulate ext : Extensionality Level.zero Level.zero -- | The interpretation of the SDE for stream addition has indeed the -- same behaviour as the direct implemenentation. correct-⊕ : ∀ {s t} → (s ⊕ t) ~ (s ⊕' t) correct-⊕ = ex-bisimulation→bisim is-bisim rel where -- Bisimulation relating s ⊕ t and the interpretation of p with -- variable assignment (x ↦ s, y ↦ t). _R_ : Rel (Stream ℕ) _ x R y = ∃ λ s → ∃ λ t → x ≡ s ⊕ t × y ≡ ⟦ E ⟧ vars p (put s t) -- Recall that we have s ⊕' t = ⟦ E ⟧ vars p (put s t), which allows -- us to prove the following. rel : ∀{s t} → (s ⊕ t) R (s ⊕' t) rel {s} {t} = (s , t , refl , refl) lem : ∀{x y} (z : X) → tl (put x y z) ≡ put (tl x) (tl y) z lem zero = refl lem (suc z) = refl is-bisim : Is-Bisim _R_ is-bisim x y (s , t , x=⊕ , y=E) = hd-≡ , tl-R where hd-≡ : hd x ≡ hd y hd-≡ = begin hd x ≡⟨ cong hd x=⊕ ⟩ hd (s ⊕ t) ≡⟨ refl ⟩ hd (⟦ E ⟧ vars p (put s t)) ≡⟨ cong hd (sym y=E) ⟩ hd y ∎ tl-R : (tl x) R (tl y) tl-R = (tl s , tl t , u' , v) where u' : tl x ≡ tl s ⊕ tl t u' = begin tl x ≡⟨ cong (λ x → tl x {∞}) x=⊕ ⟩ tl (s ⊕ t) ≡⟨ refl ⟩ tl s ⊕ tl t ∎ -- This uses, for now, extensionality v : tl y ≡ ⟦ E ⟧ vars p (put (tl s) (tl t)) v = begin tl y ≡⟨ cong (λ x₁ → tl x₁ {∞}) y=E ⟩ tl (⟦ E ⟧ vars p (put s t)) ≡⟨ refl ⟩ ⟦ E ⟧₁ vars (p₁ (sup (inj₂ x')) (sup (inj₂ y'))) (put s t) ≡⟨ refl ⟩ ⟦ E ⟧ vars p (λ x → tl ((put s t) x)) ≡⟨ cong (⟦ E ⟧ vars p) (ext lem) ⟩ ⟦ E ⟧ vars p (put (tl s) (tl t)) ∎ -- Conjecture. correct-⊗ : ∀ {s t} → (s ⊗ t) ~ (s ⊗' t) correct-⊗ = {!!}
{ "alphanum_fraction": 0.4849770837, "avg_line_length": 25.7248908297, "ext": "agda", "hexsha": "9007d8330e47152c049f9e9e35103ec71c7125a7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hbasold/Sandbox", "max_forks_repo_path": "Streams/SDE-Example.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hbasold/Sandbox", "max_issues_repo_path": "Streams/SDE-Example.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hbasold/Sandbox", "max_stars_repo_path": "Streams/SDE-Example.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2326, "size": 5891 }
-- Basic intuitionistic modal logic S4, without ∨, ⊥, or ◇. -- Tarski-style semantics with contexts as concrete worlds, and glueing for α, ▻, and □. -- Gentzen-style syntax. module BasicIS4.Semantics.TarskiOvergluedGentzen where open import BasicIS4.Syntax.Common public open import Common.Semantics public -- Intuitionistic Tarski models. record Model : Set₁ where infix 3 _⊩ᵅ_ _[⊢]_ _[⊢⋆]_ field -- Forcing for atomic propositions; monotonic. _⊩ᵅ_ : Cx Ty → Atom → Set mono⊩ᵅ : ∀ {P Γ Γ′} → Γ ⊆ Γ′ → Γ ⊩ᵅ P → Γ′ ⊩ᵅ P -- Gentzen-style syntax representation; monotonic. _[⊢]_ : Cx Ty → Ty → Set _[⊢⋆]_ : Cx Ty → Cx Ty → Set mono[⊢] : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ [⊢] A → Γ′ [⊢] A [var] : ∀ {A Γ} → A ∈ Γ → Γ [⊢] A [lam] : ∀ {A B Γ} → Γ , A [⊢] B → Γ [⊢] A ▻ B [app] : ∀ {A B Γ} → Γ [⊢] A ▻ B → Γ [⊢] A → Γ [⊢] B [multibox] : ∀ {A Δ Γ} → Γ [⊢⋆] □⋆ Δ → □⋆ Δ [⊢] A → Γ [⊢] □ A [down] : ∀ {A Γ} → Γ [⊢] □ A → Γ [⊢] A [pair] : ∀ {A B Γ} → Γ [⊢] A → Γ [⊢] B → Γ [⊢] A ∧ B [fst] : ∀ {A B Γ} → Γ [⊢] A ∧ B → Γ [⊢] A [snd] : ∀ {A B Γ} → Γ [⊢] A ∧ B → Γ [⊢] B [unit] : ∀ {Γ} → Γ [⊢] ⊤ -- TODO: Workarounds for Agda bug #2143. top[⊢⋆] : ∀ {Γ} → (Γ [⊢⋆] ∅) ≡ 𝟙 pop[⊢⋆] : ∀ {Ξ A Γ} → (Γ [⊢⋆] Ξ , A) ≡ (Γ [⊢⋆] Ξ × Γ [⊢] A) infix 3 _[⊢]⋆_ _[⊢]⋆_ : Cx Ty → Cx Ty → Set Γ [⊢]⋆ ∅ = 𝟙 Γ [⊢]⋆ Ξ , A = Γ [⊢]⋆ Ξ × Γ [⊢] A [⊢⋆]→[⊢]⋆ : ∀ {Ξ Γ} → Γ [⊢⋆] Ξ → Γ [⊢]⋆ Ξ [⊢⋆]→[⊢]⋆ {∅} {Γ} ts = ∙ [⊢⋆]→[⊢]⋆ {Ξ , A} {Γ} ts rewrite pop[⊢⋆] {Ξ} {A} {Γ} = [⊢⋆]→[⊢]⋆ (π₁ ts) , π₂ ts [⊢]⋆→[⊢⋆] : ∀ {Ξ Γ} → Γ [⊢]⋆ Ξ → Γ [⊢⋆] Ξ [⊢]⋆→[⊢⋆] {∅} {Γ} ∙ rewrite top[⊢⋆] {Γ} = ∙ [⊢]⋆→[⊢⋆] {Ξ , A} {Γ} (ts , t) rewrite pop[⊢⋆] {Ξ} {A} {Γ} = [⊢]⋆→[⊢⋆] ts , t open Model {{…}} public -- Forcing in a particular model. module _ {{_ : Model}} where infix 3 _⊩_ _⊩_ : Cx Ty → Ty → Set Γ ⊩ α P = Glue (Γ [⊢] α P) (Γ ⊩ᵅ P) Γ ⊩ A ▻ B = ∀ {Γ′} → Γ ⊆ Γ′ → Glue (Γ′ [⊢] A ▻ B) (Γ′ ⊩ A → Γ′ ⊩ B) Γ ⊩ □ A = ∀ {Γ′} → Γ ⊆ Γ′ → Glue (Γ′ [⊢] □ A) (Γ′ ⊩ A) Γ ⊩ A ∧ B = Γ ⊩ A × Γ ⊩ B Γ ⊩ ⊤ = 𝟙 infix 3 _⊩⋆_ _⊩⋆_ : Cx Ty → Cx Ty → Set Γ ⊩⋆ ∅ = 𝟙 Γ ⊩⋆ Ξ , A = Γ ⊩⋆ Ξ × Γ ⊩ A -- Monotonicity with respect to context inclusion. module _ {{_ : Model}} where mono⊩ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊩ A → Γ′ ⊩ A mono⊩ {α P} η s = mono[⊢] η (syn s) ⅋ mono⊩ᵅ η (sem s) mono⊩ {A ▻ B} η s = λ η′ → s (trans⊆ η η′) mono⊩ {□ A} η s = λ η′ → s (trans⊆ η η′) mono⊩ {A ∧ B} η s = mono⊩ {A} η (π₁ s) , mono⊩ {B} η (π₂ s) mono⊩ {⊤} η s = ∙ mono⊩⋆ : ∀ {Ξ Γ Γ′} → Γ ⊆ Γ′ → Γ ⊩⋆ Ξ → Γ′ ⊩⋆ Ξ mono⊩⋆ {∅} η ∙ = ∙ mono⊩⋆ {Ξ , A} η (ts , t) = mono⊩⋆ {Ξ} η ts , mono⊩ {A} η t -- Extraction of syntax representation in a particular model. module _ {{_ : Model}} where reifyʳ : ∀ {A Γ} → Γ ⊩ A → Γ [⊢] A reifyʳ {α P} s = syn s reifyʳ {A ▻ B} s = syn (s refl⊆) reifyʳ {□ A} s = syn (s refl⊆) reifyʳ {A ∧ B} s = [pair] (reifyʳ {A} (π₁ s)) (reifyʳ {B} (π₂ s)) reifyʳ {⊤} s = [unit] reifyʳ⋆ : ∀ {Ξ Γ} → Γ ⊩⋆ Ξ → Γ [⊢]⋆ Ξ reifyʳ⋆ {∅} ∙ = ∙ reifyʳ⋆ {Ξ , A} (ts , t) = reifyʳ⋆ ts , reifyʳ t -- Shorthand for variables. module _ {{_ : Model}} where [v₀] : ∀ {A Γ} → Γ , A [⊢] A [v₀] = [var] i₀ [v₁] : ∀ {A B Γ} → Γ , A , B [⊢] A [v₁] = [var] i₁ [v₂] : ∀ {A B C Γ} → Γ , A , B , C [⊢] A [v₂] = [var] i₂ -- Useful theorems in functional form. module _ {{_ : Model}} where [multicut] : ∀ {Ξ A Γ} → Γ [⊢]⋆ Ξ → Ξ [⊢] A → Γ [⊢] A [multicut] {∅} ∙ u = mono[⊢] bot⊆ u [multicut] {Ξ , B} (ts , t) u = [app] ([multicut] ts ([lam] u)) t [dist] : ∀ {A B Γ} → Γ [⊢] □ (A ▻ B) → Γ [⊢] □ A → Γ [⊢] □ B [dist] t u = [multibox] ([⊢]⋆→[⊢⋆] ((∙ , t) , u)) ([app] ([down] [v₁]) ([down] [v₀])) [up] : ∀ {A Γ} → Γ [⊢] □ A → Γ [⊢] □ □ A [up] t = [multibox] ([⊢]⋆→[⊢⋆] ((∙ , t))) [v₀] -- Useful theorems in combinatory form. module _ {{_ : Model}} where [ci] : ∀ {A Γ} → Γ [⊢] A ▻ A [ci] = [lam] [v₀] [ck] : ∀ {A B Γ} → Γ [⊢] A ▻ B ▻ A [ck] = [lam] ([lam] [v₁]) [cs] : ∀ {A B C Γ} → Γ [⊢] (A ▻ B ▻ C) ▻ (A ▻ B) ▻ A ▻ C [cs] = [lam] ([lam] ([lam] ([app] ([app] [v₂] [v₀]) ([app] [v₁] [v₀])))) [cdist] : ∀ {A B Γ} → Γ [⊢] □ (A ▻ B) ▻ □ A ▻ □ B [cdist] = [lam] ([lam] ([dist] [v₁] [v₀])) [cup] : ∀ {A Γ} → Γ [⊢] □ A ▻ □ □ A [cup] = [lam] ([up] [v₀]) [cdown] : ∀ {A Γ} → Γ [⊢] □ A ▻ A [cdown] = [lam] ([down] [v₀]) [box] : ∀ {A Γ} → ∅ [⊢] A → Γ [⊢] □ A [box] t = [multibox] ([⊢]⋆→[⊢⋆] ∙) t [cpair] : ∀ {A B Γ} → Γ [⊢] A ▻ B ▻ A ∧ B [cpair] = [lam] ([lam] ([pair] [v₁] [v₀])) [cfst] : ∀ {A B Γ} → Γ [⊢] A ∧ B ▻ A [cfst] = [lam] ([fst] [v₀]) [csnd] : ∀ {A B Γ} → Γ [⊢] A ∧ B ▻ B [csnd] = [lam] ([snd] [v₀]) -- Additional useful equipment. module _ {{_ : Model}} where _⟪$⟫_ : ∀ {A B Γ} → Γ ⊩ A ▻ B → Γ ⊩ A → Γ ⊩ B s ⟪$⟫ a = sem (s refl⊆) a ⟪K⟫ : ∀ {A B Γ} → Γ ⊩ A → Γ ⊩ B ▻ A ⟪K⟫ {A} a η = let a′ = mono⊩ {A} η a in [app] [ck] (reifyʳ a′) ⅋ K a′ ⟪S⟫ : ∀ {A B C Γ} → Γ ⊩ A ▻ B ▻ C → Γ ⊩ A ▻ B → Γ ⊩ A → Γ ⊩ C ⟪S⟫ s₁ s₂ a = (s₁ ⟪$⟫ a) ⟪$⟫ (s₂ ⟪$⟫ a) ⟪S⟫′ : ∀ {A B C Γ} → Γ ⊩ A ▻ B ▻ C → Γ ⊩ (A ▻ B) ▻ A ▻ C ⟪S⟫′ {A} {B} {C} s₁ η = let s₁′ = mono⊩ {A ▻ B ▻ C} η s₁ t = syn (s₁′ refl⊆) in [app] [cs] t ⅋ λ s₂ η′ → let s₁″ = mono⊩ {A ▻ B ▻ C} (trans⊆ η η′) s₁ s₂′ = mono⊩ {A ▻ B} η′ s₂ t′ = syn (s₁″ refl⊆) u = syn (s₂′ refl⊆) in [app] ([app] [cs] t′) u ⅋ ⟪S⟫ s₁″ s₂′ _⟪D⟫_ : ∀ {A B Γ} → Γ ⊩ □ (A ▻ B) → Γ ⊩ □ A → Γ ⊩ □ B (s₁ ⟪D⟫ s₂) η = let t ⅋ s₁′ = s₁ η u ⅋ a = s₂ η in [app] ([app] [cdist] t) u ⅋ s₁′ ⟪$⟫ a _⟪D⟫′_ : ∀ {A B Γ} → Γ ⊩ □ (A ▻ B) → Γ ⊩ □ A ▻ □ B _⟪D⟫′_ {A} {B} s₁ η = let s₁′ = mono⊩ {□ (A ▻ B)} η s₁ in [app] [cdist] (reifyʳ (λ {_} η′ → s₁′ η′ )) ⅋ _⟪D⟫_ s₁′ ⟪↑⟫ : ∀ {A Γ} → Γ ⊩ □ A → Γ ⊩ □ □ A ⟪↑⟫ s η = [app] [cup] (syn (s η)) ⅋ λ η′ → s (trans⊆ η η′) ⟪↓⟫ : ∀ {A Γ} → Γ ⊩ □ A → Γ ⊩ A ⟪↓⟫ s = sem (s refl⊆) _⟪,⟫′_ : ∀ {A B Γ} → Γ ⊩ A → Γ ⊩ B ▻ A ∧ B _⟪,⟫′_ {A} a η = let a′ = mono⊩ {A} η a in [app] [cpair] (reifyʳ a′) ⅋ _,_ a′ -- Forcing in a particular world of a particular model, for sequents. module _ {{_ : Model}} where infix 3 _⊩_⇒_ _⊩_⇒_ : Cx Ty → Cx Ty → Ty → Set w ⊩ Γ ⇒ A = w ⊩⋆ Γ → w ⊩ A infix 3 _⊩_⇒⋆_ _⊩_⇒⋆_ : Cx Ty → Cx Ty → Cx Ty → Set w ⊩ Γ ⇒⋆ Ξ = w ⊩⋆ Γ → w ⊩⋆ Ξ -- Entailment, or forcing in all worlds of all models, for sequents. infix 3 _⊨_ _⊨_ : Cx Ty → Ty → Set₁ Γ ⊨ A = ∀ {{_ : Model}} {w : Cx Ty} → w ⊩ Γ ⇒ A infix 3 _⊨⋆_ _⊨⋆_ : Cx Ty → Cx Ty → Set₁ Γ ⊨⋆ Ξ = ∀ {{_ : Model}} {w : Cx Ty} → w ⊩ Γ ⇒⋆ Ξ -- Additional useful equipment, for sequents. module _ {{_ : Model}} where lookup : ∀ {A Γ w} → A ∈ Γ → w ⊩ Γ ⇒ A lookup top (γ , a) = a lookup (pop i) (γ , b) = lookup i γ _⟦$⟧_ : ∀ {A B Γ w} → w ⊩ Γ ⇒ A ▻ B → w ⊩ Γ ⇒ A → w ⊩ Γ ⇒ B (s₁ ⟦$⟧ s₂) γ = s₁ γ ⟪$⟫ s₂ γ ⟦K⟧ : ∀ {A B Γ w} → w ⊩ Γ ⇒ A → w ⊩ Γ ⇒ B ▻ A ⟦K⟧ {A} {B} a γ = ⟪K⟫ {A} {B} (a γ) ⟦S⟧ : ∀ {A B C Γ w} → w ⊩ Γ ⇒ A ▻ B ▻ C → w ⊩ Γ ⇒ A ▻ B → w ⊩ Γ ⇒ A → w ⊩ Γ ⇒ C ⟦S⟧ s₁ s₂ a γ = ⟪S⟫ (s₁ γ) (s₂ γ) (a γ) _⟦D⟧_ : ∀ {A B Γ w} → w ⊩ Γ ⇒ □ (A ▻ B) → w ⊩ Γ ⇒ □ A → w ⊩ Γ ⇒ □ B (s₁ ⟦D⟧ s₂) γ = (s₁ γ) ⟪D⟫ (s₂ γ) ⟦↑⟧ : ∀ {A Γ w} → w ⊩ Γ ⇒ □ A → w ⊩ Γ ⇒ □ □ A ⟦↑⟧ s γ = ⟪↑⟫ (s γ) ⟦↓⟧ : ∀ {A Γ w} → w ⊩ Γ ⇒ □ A → w ⊩ Γ ⇒ A ⟦↓⟧ s γ = ⟪↓⟫ (s γ) _⟦,⟧_ : ∀ {A B Γ w} → w ⊩ Γ ⇒ A → w ⊩ Γ ⇒ B → w ⊩ Γ ⇒ A ∧ B (a ⟦,⟧ b) γ = a γ , b γ ⟦π₁⟧ : ∀ {A B Γ w} → w ⊩ Γ ⇒ A ∧ B → w ⊩ Γ ⇒ A ⟦π₁⟧ s γ = π₁ (s γ) ⟦π₂⟧ : ∀ {A B Γ w} → w ⊩ Γ ⇒ A ∧ B → w ⊩ Γ ⇒ B ⟦π₂⟧ s γ = π₂ (s γ)
{ "alphanum_fraction": 0.3656281662, "avg_line_length": 30.2528735632, "ext": "agda", "hexsha": "18292a25e75ea67dc06ee6bd4f88251132ab9b26", "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": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/hilbert-gentzen", "max_forks_repo_path": "BasicIS4/Semantics/TarskiOvergluedGentzen.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/hilbert-gentzen", "max_issues_repo_path": "BasicIS4/Semantics/TarskiOvergluedGentzen.agda", "max_line_length": 88, "max_stars_count": 29, "max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/hilbert-gentzen", "max_stars_repo_path": "BasicIS4/Semantics/TarskiOvergluedGentzen.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z", "num_tokens": 4755, "size": 7896 }
{-# OPTIONS --cubical --without-K --safe #-} module Cubical.Relation.Binary.Converse where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Data.Prod hiding (map) open import Cubical.HITs.PropositionalTruncation open import Cubical.Relation.Binary ------------------------------------------------------------------------ -- Properties module _ {a ℓ} {A : Type a} (∼ : Rel A ℓ) where reflexive : Reflexive ∼ → Reflexive (flip ∼) reflexive r = r irrefl : Irreflexive ∼ → Irreflexive (flip ∼) irrefl i = i symmetric : Symmetric ∼ → Symmetric (flip ∼) symmetric s = s transitive : Transitive ∼ → Transitive (flip ∼) transitive t = flip t asym : Asymmetric ∼ → Asymmetric (flip ∼) asym a = a rawtotal : RawTotal ∼ → RawTotal (flip ∼) rawtotal t x y = t y x total : Total ∼ → Total (flip ∼) total t x y = t y x resp : ∀ {p} (P : A → hProp p) → Symmetric ∼ → P Respects ∼ → P Respects (flip ∼) resp _ sym resp ∼ = resp (sym ∼) max : ∀ {⊥} → Minimum ∼ ⊥ → Maximum (flip ∼) ⊥ max min = min min : ∀ {⊤} → Maximum ∼ ⊤ → Minimum (flip ∼) ⊤ min max = max fromEq : FromEq ∼ → FromEq (flip ∼) fromEq impl = impl ∘ map sym toNotEq : ToNotEq ∼ → ToNotEq (flip ∼) toNotEq tne y∼x x≡y = tne y∼x (map sym x≡y) antisym : Antisymmetric ∼ → Antisymmetric (flip ∼) antisym ans = flip ans compare : Trichotomous ∼ → Trichotomous (flip ∼) compare cmp x y with cmp x y ... | tri< x<y x≡y y≮x = tri> y≮x x≡y x<y ... | tri≡ x≮y x≡y y≮x = tri≡ y≮x x≡y x≮y ... | tri> x≮y x≡y y<x = tri< y<x x≡y x≮y module _ {a ℓ₁ ℓ₂} {A : Type a} (∼₁ : Rel A ℓ₁) (∼₂ : Rel A ℓ₂) where resp₂ : ∼₁ Respects₂ ∼₂ → (flip ∼₁) Respects₂ ∼₂ resp₂ (resp₁ , resp₂) = resp₂ , resp₁ module _ {a b ℓ} {A : Type a} {B : Type b} (∼ : REL A B ℓ) where dec : Decidable ∼ → Decidable (flip ∼) dec dec = flip dec ------------------------------------------------------------------------ -- Structures module _ {a ℓ} {A : Type a} {≈ : Rel A ℓ} where isPartialEquivalence : IsPartialEquivalence ≈ → IsPartialEquivalence (flip ≈) isPartialEquivalence eq = record { symmetric = symmetric ≈ Eq.symmetric ; transitive = transitive ≈ Eq.transitive } where module Eq = IsPartialEquivalence eq isEquivalence : IsEquivalence ≈ → IsEquivalence (flip ≈) isEquivalence eq = record { isPartialEquivalence = isPartialEquivalence Eq.isPartialEquivalence ; reflexive = reflexive ≈ Eq.reflexive } where module Eq = IsEquivalence eq isDecEquivalence : IsDecEquivalence ≈ → IsDecEquivalence (flip ≈) isDecEquivalence eq = record { isEquivalence = isEquivalence Dec.isEquivalence ; _≟_ = dec ≈ Dec._≟_ } where module Dec = IsDecEquivalence eq module _ {a ℓ} {A : Set a} {∼ : Rel A ℓ} where isPreorder : IsPreorder ∼ → IsPreorder (flip ∼) isPreorder O = record { reflexive = reflexive ∼ O.reflexive ; transitive = transitive ∼ O.transitive } where module O = IsPreorder O isPartialOrder : IsPartialOrder ∼ → IsPartialOrder (flip ∼) isPartialOrder O = record { isPreorder = isPreorder O.isPreorder ; antisym = antisym ∼ O.antisym } where module O = IsPartialOrder O isTotalOrder : IsTotalOrder ∼ → IsTotalOrder (flip ∼) isTotalOrder O = record { isPartialOrder = isPartialOrder O.isPartialOrder ; total = total ∼ O.total } where module O = IsTotalOrder O isDecTotalOrder : IsDecTotalOrder ∼ → IsDecTotalOrder (flip ∼) isDecTotalOrder O = record { isTotalOrder = isTotalOrder O.isTotalOrder ; _≤?_ = dec ∼ O._≤?_ } where module O = IsDecTotalOrder O isStrictPartialOrder : IsStrictPartialOrder ∼ → IsStrictPartialOrder (flip ∼) isStrictPartialOrder O = record { irrefl = irrefl ∼ O.irrefl ; transitive = transitive ∼ O.transitive } where module O = IsStrictPartialOrder O isStrictTotalOrder : IsStrictTotalOrder ∼ → IsStrictTotalOrder (flip ∼) isStrictTotalOrder O = record { transitive = transitive ∼ O.transitive ; compare = compare ∼ O.compare } where module O = IsStrictTotalOrder O module _ {a ℓ} {A : Type a} where equivalence : Equivalence A ℓ → Equivalence A ℓ equivalence S = record { isEquivalence = isEquivalence S.isEquivalence } where module S = Equivalence S decEquivalence : DecEquivalence A ℓ → DecEquivalence A ℓ decEquivalence S = record { isDecEquivalence = isDecEquivalence S.isDecEquivalence } where module S = DecEquivalence S module _ {a ℓ} {A : Type a} where preorder : Preorder A ℓ → Preorder A ℓ preorder O = record { isPreorder = isPreorder O.isPreorder } where module O = Preorder O partialOrder : PartialOrder A ℓ → PartialOrder A ℓ partialOrder O = record { isPartialOrder = isPartialOrder O.isPartialOrder } where module O = PartialOrder O totalOrder : TotalOrder A ℓ → TotalOrder A ℓ totalOrder O = record { isTotalOrder = isTotalOrder O.isTotalOrder } where module O = TotalOrder O decTotalOrder : DecTotalOrder A ℓ → DecTotalOrder A ℓ decTotalOrder O = record { isDecTotalOrder = isDecTotalOrder O.isDecTotalOrder } where module O = DecTotalOrder O strictPartialOrder : StrictPartialOrder A ℓ → StrictPartialOrder A ℓ strictPartialOrder O = record { isStrictPartialOrder = isStrictPartialOrder O.isStrictPartialOrder } where module O = StrictPartialOrder O strictTotalOrder : StrictTotalOrder A ℓ → StrictTotalOrder A ℓ strictTotalOrder O = record { isStrictTotalOrder = isStrictTotalOrder O.isStrictTotalOrder } where module O = StrictTotalOrder O
{ "alphanum_fraction": 0.6384103701, "avg_line_length": 29.6111111111, "ext": "agda", "hexsha": "011d781c7eabf7d092c18853cbad8d2185c0a097", "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/Converse.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/Converse.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/Converse.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1889, "size": 5863 }
module 4-the-natural-numbers where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; cong; sym) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎) open import Data.Nat using (ℕ; zero; suc; _+_; _*_; ⌊_/2⌋) -- 4) --sum-to-n : ℕ → ℕ --sum-to-n n = sum (upTo (suc n)) open import Data.Nat.Properties using (*-comm; *-distribʳ-+; +-suc; +-comm; *-distribˡ-+) 1+⋯+n : ℕ → ℕ 1+⋯+n zero = zero 1+⋯+n (suc n) = suc n + 1+⋯+n n n≡[n*2]/2 : ∀ (n : ℕ) → n ≡ ⌊ n * 2 /2⌋ n≡[n*2]/2 zero = refl n≡[n*2]/2 (suc n) = begin suc n ≡⟨ cong suc (n≡[n*2]/2 n) ⟩ suc ⌊ n * 2 /2⌋ ≡⟨⟩ 1 + ⌊ n * 2 /2⌋ ≡⟨⟩ ⌊ 2 + n * 2 /2⌋ ≡⟨⟩ ⌊ suc n * 2 /2⌋ ∎ data IsEven : ℕ → Set where even : (k : ℕ) → IsEven (k * 2) rearrange-lemma : ∀ n → suc (suc n) * suc n ≡ suc n * 2 + suc n * n rearrange-lemma n = begin suc (suc n) * suc n ≡⟨⟩ suc (1 + n) * (1 + n) ≡⟨⟩ (2 + n) * (1 + n) ≡⟨ *-distribʳ-+ (1 + n) 2 n ⟩ 2 * (1 + n) + n * (1 + n) ≡⟨ cong (2 * (1 + n) +_) (*-comm n (1 + n)) ⟩ 2 * (1 + n) + (1 + n) * n ≡⟨⟩ 2 * suc n + suc n * n ≡⟨ cong (_+ suc n * n) (*-comm 2 (suc n)) ⟩ suc n * 2 + suc n * n ∎ even+even≡even : ∀ {m n : ℕ} → IsEven m → IsEven n → IsEven (m + n) even+even≡even (even k) (even i) rewrite (sym (*-distribʳ-+ 2 k i)) = even (k + i) [1+n]*n≡even : ∀ (n : ℕ) → IsEven (suc n * n) [1+n]*n≡even zero = even 0 [1+n]*n≡even (suc n) rewrite rearrange-lemma n = even+even≡even (even (suc n)) ([1+n]*n≡even n) even/2+even/2≡[even+even]/2 : ∀ {m n : ℕ} → IsEven m → IsEven n → ⌊ m /2⌋ + ⌊ n /2⌋ ≡ ⌊ m + n /2⌋ even/2+even/2≡[even+even]/2 (even k) (even i) = begin ⌊ k * 2 /2⌋ + ⌊ i * 2 /2⌋ ≡⟨ cong (_+ ⌊ i * 2 /2⌋) (sym (n≡[n*2]/2 k)) ⟩ k + ⌊ i * 2 /2⌋ ≡⟨ cong (k +_) (sym (n≡[n*2]/2 i)) ⟩ k + i ≡⟨ n≡[n*2]/2 (k + i) ⟩ ⌊ (k + i) * 2 /2⌋ ≡⟨ cong ⌊_/2⌋ (*-distribʳ-+ 2 k i) ⟩ ⌊ k * 2 + i * 2 /2⌋ ∎ gaussian-sum : ∀ (n : ℕ) → 1+⋯+n n ≡ ⌊ n * (n + 1) /2⌋ gaussian-sum zero = refl gaussian-sum (suc n) = begin 1+⋯+n (suc n) ≡⟨⟩ suc n + 1+⋯+n n ≡⟨ cong (suc n +_) (gaussian-sum n)⟩ suc n + ⌊ n * (n + 1) /2⌋ ≡⟨ cong (_+ ⌊ n * (n + 1) /2⌋) (n≡[n*2]/2 (suc n)) ⟩ ⌊ suc n * 2 /2⌋ + ⌊ n * (n + 1) /2⌋ ≡⟨ cong (λ {term → ⌊ suc n * 2 /2⌋ + ⌊ n * term /2⌋}) (+-comm n 1) ⟩ ⌊ suc n * 2 /2⌋ + ⌊ n * (1 + n) /2⌋ ≡⟨⟩ ⌊ suc n * 2 /2⌋ + ⌊ n * suc n /2⌋ ≡⟨ cong (λ {term → ⌊ suc n * 2 /2⌋ + ⌊ term /2⌋}) (*-comm n (suc n)) ⟩ ⌊ suc n * 2 /2⌋ + ⌊ suc n * n /2⌋ ≡⟨ even/2+even/2≡[even+even]/2 (even (suc n)) ([1+n]*n≡even n) ⟩ ⌊ suc n * 2 + suc n * n /2⌋ ≡⟨ cong (⌊_/2⌋) (sym (*-distribˡ-+ (1 + n) 2 n)) ⟩ ⌊ suc n * (2 + n) /2⌋ ≡⟨ cong (λ {term → ⌊ suc n * term /2⌋}) (+-comm 2 n) ⟩ ⌊ suc n * (n + 2) /2⌋ ≡⟨ cong (λ {term → ⌊ suc n * term /2⌋}) (+-suc n 1) ⟩ ⌊ suc n * (suc n + 1) /2⌋ ∎
{ "alphanum_fraction": 0.4291695743, "avg_line_length": 28.66, "ext": "agda", "hexsha": "9b276b8075b006d417158ae81780b45aebad533e", "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": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "aronerben/agda-playground", "max_forks_repo_path": "algebra/4-the-natural-numbers.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "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": "aronerben/agda-playground", "max_issues_repo_path": "algebra/4-the-natural-numbers.agda", "max_line_length": 97, "max_stars_count": null, "max_stars_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "aronerben/agda-playground", "max_stars_repo_path": "algebra/4-the-natural-numbers.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1723, "size": 2866 }
-- Source: https://raw.githubusercontent.com/gallais/potpourri/master/agda/poc/dimensions/dimensions.agda -- Author: Original by gallais, modified for test suite by P. Hausmann -- (Later edited by others.) {-# OPTIONS --guardedness #-} module dimensions where open import Data.Nat as ℕ using (ℕ; NonZero) open import Data.Nat.LCM open import Data.Nat.DivMod hiding (_/_) open import Data.Integer as ℤ using (ℤ ; +_) open import Data.Unit.Polymorphic using (⊤) open import Function open import Relation.Nullary.Decidable ------------------------------------------------ -- DIMENSIONS -- record { kilogram = x ; meter = y ; second = z } -- corresponds to the dimension: kg^x * m^y * s^z module Dimension where record dimension : Set where field kilogram : ℤ meter : ℤ second : ℤ open dimension public _*_ : (d e : dimension) → dimension d * e = record { kilogram = kilogram d ℤ.+ kilogram e ; meter = meter d ℤ.+ meter e ; second = second d ℤ.+ second e } _/_ : (d e : dimension) → dimension d / e = record { kilogram = kilogram d ℤ.- kilogram e ; meter = meter d ℤ.- meter e ; second = second d ℤ.- second e } open Dimension using (dimension ; kilogram ; meter ; second) kgram met sec : dimension kgram = record { kilogram = + 1 ; meter = + 0 ; second = + 0 } met = record { kilogram = + 0 ; meter = + 1 ; second = + 0 } sec = record { kilogram = + 0 ; meter = + 0 ; second = + 1 } ≠0-mult : (m n : ℕ) (hm : NonZero m) (hn : NonZero n) → NonZero (m ℕ.* n) ≠0-mult ℕ.zero n () hn ≠0-mult m 0 hm () ≠0-mult (ℕ.suc m) (ℕ.suc n) hm hn = _ ------------------------------------------------ -- UNITS -- A unit is a dimension together with a coefficient -- 60 , _ # sec represents a minute (60 seconds) module Unit where infix 1 _,_#_ data unit : Set where _,_#_ : (n : ℕ) (hn : NonZero n) (d : dimension) → unit coeff : (u : unit) → ℕ coeff (k , _ # _) = k coeff≠0 : (u : unit) → NonZero (coeff u) coeff≠0 (k , hk # _) = hk _*_ : (u v : unit) → unit (k , hk # d) * (l , hl # e) = ( k ℕ.* l ) , (≠0-mult k l hk hl) # (d Dimension.* e) _/_ : (u v : unit) ⦃ ≠0 : NonZero (((coeff u) div (coeff v)) ⦃ coeff≠0 v ⦄) ⦄ → unit _/_ (k , hk # d) (l , hl # e) ⦃ ≠0 ⦄ = (k div l) ⦃ hl ⦄ , ≠0 # (d Dimension./ e) open Unit using (unit ; _,_#_ ; coeff ; coeff≠0) ------------------------------------------------ -- VALUES -- Finally, values are natural numbers repackaged -- with a unit module Values where data [_] : (d : unit) → Set where ⟨_∶_⟩ : (value : ℕ) (d : unit) → [ d ] val : ∀ {d} → [ d ] → ℕ val ⟨ m ∶ _ ⟩ = m infix 3 _+_ infix 4 _*_ _/_ _+_ : ∀ {k hk l hl m hm} {d : dimension} (v₁ : [ k , hk # d ]) (v₂ : [ l , hl # d ]) → [ m , hm # d ] _+_ {k} {hk} {l} {hl} {m} {hm} ⟨ v₁ ∶ ._ ⟩ ⟨ v₂ ∶ ._ ⟩ = ⟨ ((k ℕ.* v₁ ℕ.+ l ℕ.* v₂) div m) ⦃ hm ⦄ ∶ _ ⟩ _:+_ : ∀ {k hk l hl} {d : dimension} (v₁ : [ k , hk # d ]) (v₂ : [ l , hl # d ]) → [ 1 , _ # d ] _:+_ = _+_ _*_ : ∀ {k hk l hl m hm} {d e : dimension} (vd : [ k , hk # d ]) (ve : [ l , hl # e ]) → [ m , hm # (d Dimension.* e) ] _*_ {k} {hk} {l} {hl} {m} {hm} ⟨ vd ∶ ._ ⟩ ⟨ ve ∶ ._ ⟩ = ⟨ ((k ℕ.* vd ℕ.* l ℕ.* ve) div m) ⦃ hm ⦄ ∶ _ ⟩ _:*_ : ∀ {k hk l hl} {d e : dimension} (vd : [ k , hk # d ]) (ve : [ l , hl # e ]) → [ 1 , _ # (d Dimension.* e) ] _:*_ = _*_ _/_ : ∀ {k hk l hl m hm} {d e : dimension} (vd : [ k , hk # d ]) (ve : [ l , hl # e ]) {≠0 : NonZero (val ve)} → [ m , hm # (d Dimension./ e) ] _/_ {k} {hk} {l} {hl} {m} {hm} ⟨ vd ∶ ._ ⟩ ⟨ ve ∶ ._ ⟩ {≠0} = ⟨ ((k ℕ.* vd) div (l ℕ.* ve ℕ.* m)) ⦃ ≠0-mult _ _ (≠0-mult _ _ hl ≠0) hm ⦄ ∶ _ ⟩ ↑ : ∀ {k hk l hl d} → [ k , hk # d ] → [ l , hl # d ] ↑ {k} {hk} {l} {hl} ⟨ v ∶ ._ ⟩ = ⟨ ((k ℕ.* v) div l) ⦃ hl ⦄ ∶ _ ⟩ open Values ------------------------------------------------ -- SI PREFIXES -- They are simply unit-modifying functions. infix 5 _**_ _**_ : (k : ℕ) {hk : NonZero k} (d : dimension) → unit _**_ k {hk} d = k , hk # d centi : (u : unit) {≠0 : NonZero (coeff u div 100)} → unit centi (k , hk # d) {≠0} = _ , ≠0 # d deci : (u : unit) {≠0 : NonZero (coeff u div 10)} → unit deci (k , hk # d) {≠0} = _ , ≠0 # d deca hecto kilo : unit → unit deca (k , hk # d) = 10 ℕ.* k , ≠0-mult 10 k _ hk # d hecto (k , hk # d) = 100 ℕ.* k , ≠0-mult 100 k _ hk # d kilo (k , hk # d) = 1000 ℕ.* k , ≠0-mult 1000 k _ hk # d cst : unit cst = let dcst = record { kilogram = + 0 ; meter = + 0 ; second = + 0 } in 1 , _ # dcst infix 3 κ_ κ_ : (n : ℕ) → [ cst ] κ n = ⟨ n ∶ cst ⟩ ------------------------------------------------ -- EXAMPLES s min hr : unit s = 1 ** sec min = 60 ** sec hr = 60 ℕ.* 60 ** sec m : unit m = 1 ** met 1s : [ s ] 1s = ⟨ 1 ∶ s ⟩ 1min : [ min ] 1min = ⟨ 1 ∶ min ⟩ 1hr 2hr : [ min ] 1hr = ⟨ 60 ∶ min ⟩ 2hr = 1hr + 1hr 1min² : [ s Unit.* s ] 1min² = 1min * 1min 60km : [ kilo m ] 60km = ⟨ 60 ∶ kilo m ⟩ 60hm : [ hecto m ] 60hm = ⟨ 60 ∶ hecto m ⟩ 60hm/min : [ deca m Unit./ s ] 60hm/min = ⟨ 60 ∶ hecto m ⟩ / ⟨ 1 ∶ min ⟩ acc : unit acc = m Unit./ (s Unit.* s) spd : unit spd = m Unit./ s ------------------------------------------------ -- APPLICATION: -- free fall of a ball with an initial horizontal speed. record point : Set where field accx accy : [ acc ] vx vy : [ spd ] x y : [ m ] open point public g : [ acc ] g = ⟨ 10 ∶ _ ⟩ newton : ∀ (dt : [ s ]) (p : point) → point newton dt p = record { accx = accx p ; accy = accy p + g ; vx = vx p + (accx p :* dt) ; vy = vy p + (accy p :* dt) ; x = x p + (vx p :* dt) ; y = y p + (vy p :* dt) } ------------------------------------------------ -- TRACING -- the initial condition a point is in base : point base = record { accx = ⟨ 0 ∶ _ ⟩ ; accy = ⟨ 0 ∶ _ ⟩ ; vx = ⟨ 45 ∶ _ ⟩ ; vy = ⟨ 0 ∶ _ ⟩ ; x = ⟨ 0 ∶ _ ⟩ ; y = ⟨ 0 ∶ _ ⟩ } -- the consecutive steps of its fall open import Data.Vec as V using (Vec) throw : (n : ℕ) (dt : [ s ]) → point → Vec point (ℕ.suc n) throw ℕ.zero dt p = p V.∷ V.[] throw (ℕ.suc n) dt p = p V.∷ throw n dt (newton dt p) -- the display function generating the output open import Data.String renaming (_++_ to _+s+_) open import IO import IO.Primitive open import Codata.Musical.Colist open import Data.Nat.Show as Nat open import Level using (0ℓ) printPoint : point → IO {0ℓ} ⊤ printPoint p = putStrLn ((Nat.show (val (x p))) +s+ ";" +s+ Nat.show (val (y p))) main : IO.Primitive.IO ⊤ main = run (Colist.mapM printPoint (Codata.Musical.Colist.fromList trace) >> return _) where trace = V.toList $ throw 15 ⟨ 1 ∶ s ⟩ base
{ "alphanum_fraction": 0.4593944539, "avg_line_length": 26.2750929368, "ext": "agda", "hexsha": "d2f7ac410aa10fea3446f37fa0178e5a09fd1fed", "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/Compiler/with-stdlib/dimensions.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Compiler/with-stdlib/dimensions.agda", "max_line_length": 105, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Compiler/with-stdlib/dimensions.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2656, "size": 7068 }
{-# OPTIONS --experimental-irrelevance #-} -- {-# OPTIONS -v tc.univ:100 -v tc.meta:100 #-} -- {-# OPTIONS -v tc.rec:100 #-} -- Andreas, 2011-04-27 universe levels can be made irrelevant -- Ulf 2011-10-03. No they can't. How is that even consistent? -- Andreas, 2011-10-03. Yes, they can! -- .(i : Level)(A : Set i) does not mean that Set i = Set j for all i,j -- but nl i A = nl j A for all i,j. module IrrelevantLevel where open import Common.Level postulate Lst : .(i : Level)(A : Set i) -> Set i nl : .(i : Level)(A : Set i) -> Lst i A cns : .(i : Level)(A : Set i) -> A -> Lst i A -> Lst i A data List .(i : Level)(A : Set i) : Set i where nil : List i A cons : A -> List i A -> List i A singleton : .{i : Level}{A : Set i}(a : A) -> List i A singleton a = cons a nil record Wrap .(i : Level)(A : Set i) : Set i where field wrap : A module M .(i : Level)(A : Set i) where data Li : Set i where ni : Li co : A -> Li -> Li
{ "alphanum_fraction": 0.5754132231, "avg_line_length": 26.8888888889, "ext": "agda", "hexsha": "d4c399bdc4c4461a980c9d41df3a008d4aa7c122", "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/IrrelevantLevel.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/IrrelevantLevel.agda", "max_line_length": 75, "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/IrrelevantLevel.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": 349, "size": 968 }
{-# OPTIONS --copatterns --sized-types #-} open import Level as Level using (zero) open import Size open import Function open import Relation.Binary open import Relation.Binary.PropositionalEquality as P open ≡-Reasoning open import Data.List using (List; module List; []; _∷_; _++_; length) open import Data.Nat using (ℕ; zero; suc) open import Data.Product renaming (map to pmap) open import Relations -- Sized streams via head/tail. record Stream {i : Size} (A : Set) : Set where coinductive constructor _∷_ field hd : A tl : ∀ {j : Size< i} → Stream {j} A open Stream public -- Shorthand Str = Stream tl' : ∀ {A} → Str A → Str A tl' s = tl s {∞} -- Constructor scons : ∀{A} → A → Str A → Str A hd (scons a s) = a tl (scons a s) = s -- | Corecursion corec : ∀ {X A : Set} → (X → A) → (X → X) → (X → Str A) hd (corec h s x) = h x tl (corec h s x) = corec h s (s x) -- Functoriality. map : ∀ {i A B} (f : A → B) (s : Stream {i} A) → Stream {i} B hd (map f s) = f (hd s) tl (map {i} f s) {j} = map {j} f (tl s {j}) -- Derivative δ : ∀{A} → ℕ → Stream A → Stream A δ 0 s = s δ (suc n) s = δ n (tl s) -- Indexing _at_ : ∀{A} → Stream A → ℕ → A s at n = hd (δ n s) fromStr = _at_ -- | Inverse for at toStr : ∀ {A} → (ℕ → A) → Str A hd (toStr f) = f 0 tl (toStr f) = toStr (λ n → f (suc n)) module Bisim (S : Setoid Level.zero Level.zero) where infix 2 _∼_ open Setoid S renaming (Carrier to A; isEquivalence to S-equiv) module SE = IsEquivalence S-equiv -- Stream equality is bisimilarity record _∼_ {i : Size} (s t : Stream A) : Set where coinductive field hd≈ : hd s ≈ hd t tl∼ : ∀ {j : Size< i} → _∼_ {j} (tl s) (tl t) open _∼_ public _∼[_]_ : Stream A → Size → Stream A → Set s ∼[ i ] t = _∼_ {i} s t s-bisim-refl : ∀ {i} {s : Stream A} → s ∼[ i ] s hd≈ s-bisim-refl = SE.refl tl∼ (s-bisim-refl {_} {s}) {j} = s-bisim-refl {j} {tl s} s-bisim-sym : ∀ {i} {s t : Stream A} → s ∼[ i ] t → t ∼[ i ] s hd≈ (s-bisim-sym p) = SE.sym (hd≈ p) tl∼ (s-bisim-sym {_} {s} {t} p) {j} = s-bisim-sym {j} {tl s} {tl t} (tl∼ p) s-bisim-trans : ∀ {i} {r s t : Stream A} → r ∼[ i ] s → s ∼[ i ] t → r ∼[ i ] t hd≈ (s-bisim-trans p q) = SE.trans (hd≈ p) (hd≈ q) tl∼ (s-bisim-trans {_} {r} {s} {t} p q) {j} = s-bisim-trans {j} {tl r} {tl s} {tl t} (tl∼ p) (tl∼ q) stream-setoid : Setoid _ _ stream-setoid = record { Carrier = Stream A ; _≈_ = _∼_ ; isEquivalence = record { refl = s-bisim-refl ; sym = s-bisim-sym ; trans = s-bisim-trans } } import Relation.Binary.EqReasoning as EqR module ∼-Reasoning where module _ where open EqR (stream-setoid) public hiding (_≡⟨_⟩_) renaming (_≈⟨_⟩_ to _∼⟨_⟩_; begin_ to begin_; _∎ to _∎) -- | As usual, bisimilarity implies equality at every index. bisim→ext-≡ : ∀ {s t : Stream A} → s ∼ t → ∀ {n} → s at n ≈ t at n bisim→ext-≡ p {zero} = hd≈ p bisim→ext-≡ p {suc n} = bisim→ext-≡ (tl∼ p) {n} -- | Definition of bisimulation isBisim : Rel (Str A) Level.zero → Set isBisim R = (s t : Str A) → R s t → (hd s ≈ hd t) × R (tl s) (tl t) -- | Bisimulation proof principle ∃-bisim→∼ : ∀ {R} → isBisim R → (s t : Str A) → R s t → s ∼ t hd≈ (∃-bisim→∼ R-isBisim s t q) = proj₁ (R-isBisim s t q) tl∼ (∃-bisim→∼ R-isBisim s t q) = ∃-bisim→∼ R-isBisim (tl s) (tl t) (proj₂ (R-isBisim s t q)) StrRel : Set₁ StrRel = Rel (Str A) Level.zero -- | Relation transformer that characterises bisimulations Φ : Rel (Str A) Level.zero → Rel (Str A) Level.zero Φ R s t = (hd s ≈ hd t) × R (tl s) (tl t) isBisim' : Rel (Str A) Level.zero → Set isBisim' R = R ⇒ Φ R isBisim'→isBisim : ∀ {R} → isBisim' R → isBisim R isBisim'→isBisim p s t q = p q Φ-compat : RelTrans (Str A) → Set₁ Φ-compat F = Monotone F × (∀ {R} → F (Φ R) ⇒ Φ (F R)) isBisim-upto : RelTrans (Str A) → Rel (Str A) Level.zero → Set isBisim-upto F R = R ⇒ Φ (F R) Φ-compat-pres-upto : {F : RelTrans (Str A)} (P : Φ-compat F) {R : StrRel} → isBisim-upto F R → isBisim-upto F (F R) Φ-compat-pres-upto (M , P) p = P ∘ (M p) iterTrans : RelTrans (Str A) → ℕ → StrRel → StrRel iterTrans F zero R = R iterTrans F (suc n) R = iterTrans F n (F R) -- Closure of up-to technique, which will be the the bisimulation we generate from it bisimCls : RelTrans (Str A) → StrRel → StrRel bisimCls F R s t = ∃ λ n → iterTrans F n R s t clsIsBisim : {F : RelTrans (Str A)} (P : Φ-compat F) {R : StrRel} → isBisim-upto F R → isBisim' (bisimCls F R) clsIsBisim P p {s} {t} (zero , sRt) = (proj₁ (p sRt) , 1 , proj₂ (p sRt)) clsIsBisim {F} (M , P) {R} p {s} {t} (suc n , inFIter) = let foo = clsIsBisim (M , P) {F R} (Φ-compat-pres-upto (M , P) p) (n , inFIter) in (proj₁ foo , (pmap suc id) (proj₂ foo)) -- Compatible up-to techniques are sound compat-sound : {F : RelTrans (Str A)} (P : Φ-compat F) {R : StrRel} → isBisim-upto F R → (s t : Str A) → R s t → s ∼ t compat-sound {F} P {R} p s t sRt = ∃-bisim→∼ (isBisim'→isBisim {bisimCls F R} (clsIsBisim P p)) s t (0 , sRt) -- | Useful general up-to technique: the equivalence closure is Φ-compatible. equivCls-compat : Φ-compat EquivCls equivCls-compat = equivCls-monotone , compat where compat : {R : StrRel} → EquivCls (Φ R) ⇒ Φ (EquivCls R) compat (cls-incl (h≈ , tR)) = (h≈ , cls-incl tR) compat cls-refl = (SE.refl , cls-refl) compat {R} (cls-sym p) = let (h≈ , tR) = compat {R} p in (SE.sym h≈ , cls-sym tR) compat {R} (cls-trans p q) = let (hx≈hy , txRty) = compat {R} p (hy≈hz , tyRtz) = compat {R} q in (SE.trans hx≈hy hy≈hz , cls-trans txRty tyRtz) -- | Element repetition repeat : ∀{A} → A → Stream A hd (repeat a) = a tl (repeat a) = repeat a -- Streams and lists. -- Prepending a list to a stream. _++ˢ_ : ∀ {A} → List A → Stream A → Stream A [] ++ˢ s = s (a ∷ as) ++ˢ s = a ∷ (as ++ˢ s) -- Taking an initial segment of a stream. takeˢ : ∀ {A} (n : ℕ) (s : Stream A) → List A takeˢ 0 s = [] takeˢ (suc n) s = hd s ∷ takeˢ n (tl s) _↓_ : ∀ {A} (s : Stream A) (n : ℕ) → List A s ↓ n = takeˢ n s
{ "alphanum_fraction": 0.5460702473, "avg_line_length": 29.6682242991, "ext": "agda", "hexsha": "0e905285b1628b873b394f7585c4df4e70aaaff8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hbasold/Sandbox", "max_forks_repo_path": "Languages/Stream.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hbasold/Sandbox", "max_issues_repo_path": "Languages/Stream.agda", "max_line_length": 87, "max_stars_count": null, "max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hbasold/Sandbox", "max_stars_repo_path": "Languages/Stream.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2654, "size": 6349 }
module instances where open import lib public renaming (return to returnᵢₒ; _>>_ to _>>ᵢₒ_; _>>=_ to _>>=ᵢₒ_) open import functions public record functor {ℓ ℓ'} (F : Set ℓ → Set ℓ') : Set (lsuc (ℓ ⊔ ℓ')) where infixl 2 _<$>_ _<$_ field fmap : ∀ {A B : Set ℓ} → (A → B) → F A → F B {-functor-identity-law : ∀ {A} (fa : F A) → fmap id fa ≡ fa functor-composition-law : ∀ {A B C} (f : B → C) (g : A → B) (fa : F A) → fmap (f ∘ g) fa ≡ fmap f (fmap g fa)-} _<$>_ = fmap _<$_ : ∀ {A B : Set ℓ} → A → F B → F A a <$ fb = (λ _ → a) <$> fb open functor ⦃...⦄ public record applicative {ℓ ℓ'} (F : Set ℓ → Set ℓ') : Set (lsuc (ℓ ⊔ ℓ')) where infixl 2 _<*>_ _<*_ _*>_ field pure : ∀ {A : Set ℓ} → A → F A _<*>_ : ∀ {A B : Set ℓ} → F (A → B) → F A → F B ⦃ functorF ⦄ : functor F {-applicative-identity-law : ∀ {A} (v : F A) → pure id <*> v ≡ v applicative-composition-law : ∀ {A B C} (u : F (B → C)) (v : F (A → B)) (w : F A) → pure _∘_ <*> u <*> v <*> w ≡ u <*> (v <*> w) applicative-homomorphism-law : ∀ {A B} (f : A → B) (x : A) → pure f <*> pure x ≡ pure (f x) applicative-interchange-law : ∀ {A B} (u : F (A → B)) (y : A) → u <*> pure y ≡ pure (_$ y) <*> u-} _<*_ : ∀ {A B : Set ℓ} → F A → F B → F A fa <* fb = (λ a b → a) <$> fa <*> fb _*>_ : ∀ {A B : Set ℓ} → F A → F B → F B fa *> fb = (λ a b → b) <$> fa <*> fb liftA : ∀ {A B : Set ℓ} → (A → B) → F A → F B liftA g fa = pure g <*> fa liftA2 : ∀ {A B C : Set ℓ} → (A → B → C) → F A → F B → F C liftA2 g fa fb = pure g <*> fa <*> fb sequenceA : ∀ {A : Set ℓ} → 𝕃 (F A) → F (𝕃 A) sequenceA = foldr (liftA2 _::_) (pure []) open applicative ⦃...⦄ public record monad {ℓ ℓ'} (F : Set ℓ → Set ℓ') : Set (lsuc (ℓ ⊔ ℓ')) where infixr 2 _>>_ _>>=_ _=<<_ _>=>_ _>>=c_ _>>c_ _>>=?_ _>>=m_ _>>=s_ _>>=e_ _>>≠_ _>≯_ _>>=r_ _>>r_ field return : ∀{A : Set ℓ} → A → F A _>>=_ : ∀{A B : Set ℓ} → F A → (A → F B) → F B {-monad-left-identity-law : ∀ {A B} (a : A) (k : A → F B) → return a >>= k ≡ k a monad-right-identity-law : ∀ {A} (m : F A) → m >>= return ≡ m monad-associativity-law : ∀ {A B C} (m : F A) (k : A → F B) (h : B → F C) → m >>= (λ x → k x >>= h) ≡ (m >>= k) >>= h-} _>>_ : ∀ {A B : Set ℓ} → F A → F B → F B fa >> fb = fa >>= λ _ → fb _=<<_ : ∀ {A B : Set ℓ} → (A → F B) → F A → F B fab =<< fa = fa >>= fab _>=>_ : ∀ {A B C : Set ℓ} → (A → F B) → (B → F C) → (A → F C) fab >=> fbc = λ a → fab a >>= fbc _>>=c_ : ∀ {A B C : Set ℓ} → F (A × B) → (A → B → F C) → F C p >>=c f = p >>= λ {(a , b) → f a b} _>>c_ : ∀ {A B : Set ℓ} → F A → F B → F (A × B) fa >>c fb = fa >>= λ a → fb >>= λ b → return (a , b) _>>=?_ : ∀ {A B : Set ℓ} → maybe (F A) → (maybe A → F B) → F B nothing >>=? f = f nothing (just a) >>=? f = a >>= (f ∘ just) _>>=s_ : ∀ {A B E : Set ℓ} → F (E ⊎ A) → (A → F (E ⊎ B)) → F (E ⊎ B) s >>=s f = s >>= λ {(inj₁ e) → return (inj₁ e); (inj₂ a) → f a} _>>=e_ : ∀ {A B : Set ℓ} → F (error-t A) → (A → F (error-t B)) → F (error-t B) fe? >>=e f = fe? >>= λ {(no-error a) → f a; (yes-error e) → return (yes-error e)} _>>=m_ : ∀{A B : Set ℓ} → F (maybe A) → (A → F (maybe B)) → F (maybe B) m >>=m f = m >>= λ {(just a) → f a; nothing → return nothing} _>>≠_ : ∀{A B : Set ℓ} → F A → (A → F B) → F A (f₁ >>≠ f₂) = f₁ >>= λ result → f₂ result >> return result _>≯_ : ∀{A B : Set ℓ} → F A → F B → F A (f₁ >≯ f₂) = f₁ >>= λ result → f₂ >> return result _>>=r_ : ∀{A B : Set ℓ} → F A → (A → B) → F B a >>=r f = a >>= (return ∘ f) _>>r_ : ∀{A B : Set ℓ} → F A → B → F B a >>r b = a >> return b _on-fail_>>=m_ : ∀ {A B : Set ℓ} → F (maybe A) → F B → (A → F B) → F B fa? on-fail fb >>=m fab = fa? >>= λ {(just a) → fab a; nothing → fb} _on-fail_>>=s_ : ∀ {A B E : Set ℓ} → F (E ⊎ A) → (E → F B) → (A → F B) → F B fa+e on-fail feb >>=s fab = fa+e >>= λ {(inj₁ e) → feb e; (inj₂ a) → fab a} return2 : ∀ {A B : Set ℓ} → A → B → F (A × B) return2 a b = return (a , b) foldrM : ∀ {A B} → (A → F B → F B) → F B → 𝕃 (F A) → F B foldrM c n [] = n foldrM c n (fa :: fas) = fa >>= λ a → c a (foldrM c n fas) foldlM : ∀ {A B} → (A → F B → F B) → F B → 𝕃 (F A) → F B foldlM c n [] = n foldlM c n (fa :: fas) = fa >>= λ a → foldlM c (c a n) fas forM_init_use_ : ∀ {A B} → 𝕃 (F A) → F B → (A → F B → F B) → F B forM as init b use f = foldrM f b as open monad ⦃...⦄ public join : ∀ {ℓ}{F : Set ℓ → Set ℓ}{A : Set ℓ} ⦃ _ : monad F ⦄ → F (F A) → F A join ffa = ffa >>= id infixr 2 _>>∘_ _>>∘_ : ∀{ℓ}{F : Set ℓ → Set ℓ}{A B : Set ℓ} ⦃ _ : monad F ⦄ → F A → F (A → F B) → F B a >>∘ f = a >>= λ a → f >>= λ f → f a --========== Id ==========-- -- Using "id" itself causes Agda to hang when resolving instances, I suspect due -- to something like endlessly embedding (id (id (id (...)))). So instead we must -- use a "newtype" for id. record Id (A : Set) : Set where constructor id-in field id-out : A open Id public instance id-functor : functor Id id-applicative : applicative Id id-monad : monad Id fmap ⦃ id-functor ⦄ f = id-in ∘ (f ∘ id-out) pure ⦃ id-applicative ⦄ = id-in _<*>_ ⦃ id-applicative ⦄ fab fa = id-in (id-out fab (id-out fa)) return ⦃ id-monad ⦄ = id-in _>>=_ ⦃ id-monad ⦄ a f = f (id-out a) --========== IO ==========-- instance IO-functor : functor IO IO-applicative : applicative IO IO-monad : monad IO {- postulate IO-functor-identity-law : ∀ {A} → fmap ⦃ IO-functor ⦄ {A} id ≡ id IO-functor-composition-law : ∀ {A B C} (f : B → C) (g : A → B) → fmap (f ∘ g) ≡ fmap f ∘ fmap g IO-applicative-identity-law : ∀ {A} (v : IO A) → pure ⦃ IO-applicative ⦄ id <*> v ≡ v IO-applicative-composition-law : ∀ {A B C} (u : IO (B → C)) (v : IO (A → B)) (w : IO A) → pure ⦃ IO-applicative ⦄ _∘_ <*> u <*> v <*> w ≡ u <*> (v <*> w) IO-applicative-homomorphism-law : ∀ {A B} (f : A → B) (x : A) → pure ⦃ IO-applicative ⦄ f <*> pure x ≡ pure (f x) IO-applicative-interchange-law : ∀ {A B} (u : IO (A → B)) (y : A) → u <*> pure y ≡ pure ⦃ IO-applicative ⦄ (_$ y) <*> u IO-monad-left-identity-law : ∀ {A B} (a : A) (k : A → IO B) → (return a >>= k) ≡ k a IO-monad-right-identity-law : ∀ {A} (m : IO A) → (m >>= return) ≡ m IO-monad-associativity-law : ∀ {A B C} (m : IO A) (k : A → IO B) (h : B → IO C) → (m >>= (λ x → k x >>= h)) ≡ ((m >>= k) >>= h) -} fmap ⦃ IO-functor ⦄ g fa = fa >>=ᵢₒ λ a → returnᵢₒ (g a) pure ⦃ IO-applicative ⦄ = returnᵢₒ _<*>_ ⦃ IO-applicative ⦄ fab fa = fab >>=ᵢₒ λ ab → fa >>=ᵢₒ λ a → returnᵢₒ (ab a) return ⦃ IO-monad ⦄ = returnᵢₒ _>>=_ ⦃ IO-monad ⦄ = _>>=ᵢₒ_ --========== ⊎ ==========-- instance sum-functor : ∀ {ℓ ℓ'} {E : Set ℓ} → functor {ℓ'} {ℓ ⊔ ℓ'} (E ⊎_) sum-applicative : ∀ {ℓ ℓ'} {E : Set ℓ} → applicative {ℓ'} {ℓ ⊔ ℓ'} (E ⊎_) sum-monad : ∀ {ℓ ℓ'} {E : Set ℓ} → monad {ℓ'} {ℓ ⊔ ℓ'} (E ⊎_) fmap ⦃ sum-functor ⦄ f (inj₁ e) = inj₁ e fmap ⦃ sum-functor ⦄ f (inj₂ a) = inj₂ (f a) pure ⦃ sum-applicative ⦄ = inj₂ _<*>_ ⦃ sum-applicative ⦄ sf sa = sf >>= λ f → sa >>= λ a → return (f a) return ⦃ sum-monad ⦄ = inj₂ _>>=_ ⦃ sum-monad ⦄ (inj₁ e) f = inj₁ e _>>=_ ⦃ sum-monad ⦄ (inj₂ a) f = f a --========== maybe ==========-- instance maybe-functor : ∀ {ℓ} → functor {ℓ} maybe maybe-applicative : ∀ {ℓ} → applicative {ℓ} maybe maybe-monad : ∀ {ℓ} → monad {ℓ} maybe fmap ⦃ maybe-functor ⦄ = maybe-map pure ⦃ maybe-applicative ⦄ = just _<*>_ ⦃ maybe-applicative ⦄ f? a? = f? ≫=maybe λ f → a? ≫=maybe (just ∘ f) return ⦃ maybe-monad ⦄ = just _>>=_ ⦃ maybe-monad ⦄ = _≫=maybe_ --========== 𝕃 ==========-- instance list-functor : ∀ {ℓ} → functor {ℓ} 𝕃 list-applicative : ∀ {ℓ} → applicative {ℓ} 𝕃 list-monad : ∀ {ℓ} → monad {ℓ} 𝕃 fmap ⦃ list-functor ⦄ = map pure ⦃ list-applicative ⦄ = [_] _<*>_ ⦃ list-applicative ⦄ fs as = map (λ {(f , a) → f a}) (zip fs as) return ⦃ list-monad ⦄ = [_] _>>=_ ⦃ list-monad ⦄ as f = concat (map f as)
{ "alphanum_fraction": 0.452195122, "avg_line_length": 29.7101449275, "ext": "agda", "hexsha": "26c16a04f46f50783cd32051ae309b17e8a2e0ce", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9df4b85b55b57f97466242fdbb499adbd3bca893", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "zmthy/cedille", "max_forks_repo_path": "src/instances.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9df4b85b55b57f97466242fdbb499adbd3bca893", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "zmthy/cedille", "max_issues_repo_path": "src/instances.agda", "max_line_length": 98, "max_stars_count": null, "max_stars_repo_head_hexsha": "9df4b85b55b57f97466242fdbb499adbd3bca893", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "zmthy/cedille", "max_stars_repo_path": "src/instances.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3751, "size": 8200 }
{-# OPTIONS --without-K --safe #-} open import Relation.Binary using (Rel; Setoid; IsEquivalence) module Structures {a ℓ} {A : Set a} -- The underlying set (_≈_ : Rel A ℓ) -- The underlying equality relation where open import Algebra.Core open import Level using (_⊔_) open import Data.Product using (_,_; proj₁; proj₂) open import Algebra.Definitions _≈_ open import Algebra.Structures _≈_ open import Definitions _≈_ record IsInverseSemigroup (∙ : Op₂ A) : Set (a ⊔ ℓ) where field isSemigroup : IsSemigroup ∙ pseudoInverse : PseudoInverse ∙ open IsSemigroup isSemigroup public record IsRng (+ * : Op₂ A) (-_ : Op₁ A) (0# : A) : Set (a ⊔ ℓ) where field +-isAbelianGroup : IsAbelianGroup + 0# -_ *-isSemigroup : IsSemigroup * distrib : * DistributesOver + zero : Zero 0# * open IsAbelianGroup +-isAbelianGroup public renaming ( assoc to +-assoc ; ∙-cong to +-cong ; ∙-congˡ to +-congˡ ; ∙-congʳ to +-congʳ ; identity to +-identity ; identityˡ to +-identityˡ ; identityʳ to +-identityʳ ; inverse to -‿inverse ; inverseˡ to -‿inverseˡ ; inverseʳ to -‿inverseʳ ; ⁻¹-cong to -‿cong ; comm to +-comm ; isMagma to +-isMagma ; isSemigroup to +-isSemigroup ; isMonoid to +-isMonoid ; isUnitalMagma to +-isUnitalMagma ; isCommutativeMagma to +-isCommutativeMagma ; isCommutativeMonoid to +-isCommutativeMonoid ; isCommutativeSemigroup to +-isCommutativeSemigroup ; isInvertibleMagma to +-isInvertibleMagma ; isInvertibleUnitalMagma to +-isInvertibleUnitalMagma ; isGroup to +-isGroup ) open IsSemigroup *-isSemigroup public using () renaming ( assoc to *-assoc ; ∙-cong to *-cong ; ∙-congˡ to *-congˡ ; ∙-congʳ to *-congʳ ; isMagma to *-isMagma ) record IsNonAssociativeRing (+ * : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Set (a ⊔ ℓ) where field +-isAbelianGroup : IsAbelianGroup + 0# -_ *-isUnitalMagma : IsUnitalMagma * 1# distrib : * DistributesOver + zero : Zero 0# * open IsAbelianGroup +-isAbelianGroup public renaming ( assoc to +-assoc ; ∙-cong to +-cong ; ∙-congˡ to +-congˡ ; ∙-congʳ to +-congʳ ; identity to +-identity ; identityˡ to +-identityˡ ; identityʳ to +-identityʳ ; inverse to -‿inverse ; inverseˡ to -‿inverseˡ ; inverseʳ to -‿inverseʳ ; ⁻¹-cong to -‿cong ; comm to +-comm ; isMagma to +-isMagma ; isSemigroup to +-isSemigroup ; isMonoid to +-isMonoid ; isUnitalMagma to +-isUnitalMagma ; isCommutativeMagma to +-isCommutativeMagma ; isCommutativeMonoid to +-isCommutativeMonoid ; isCommutativeSemigroup to +-isCommutativeSemigroup ; isInvertibleMagma to +-isInvertibleMagma ; isInvertibleUnitalMagma to +-isInvertibleUnitalMagma ; isGroup to +-isGroup ) open IsUnitalMagma *-isUnitalMagma public using () renaming ( ∙-cong to *-cong ; ∙-congˡ to *-congˡ ; ∙-congʳ to *-congʳ ; isMagma to *-isMagma )
{ "alphanum_fraction": 0.5393043002, "avg_line_length": 34.4433962264, "ext": "agda", "hexsha": "028035c812d37bce9544bbcfe492ac7e86eef750", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "443e831e536b756acbd1afd0d6bae7bc0d288048", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra", "max_forks_repo_path": "src/Structures.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "443e831e536b756acbd1afd0d6bae7bc0d288048", "max_issues_repo_issues_event_max_datetime": "2021-10-09T08:24:56.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-04T05:30:30.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra", "max_issues_repo_path": "src/Structures.agda", "max_line_length": 86, "max_stars_count": 2, "max_stars_repo_head_hexsha": "443e831e536b756acbd1afd0d6bae7bc0d288048", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra", "max_stars_repo_path": "src/Structures.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-17T09:14:03.000Z", "max_stars_repo_stars_event_min_datetime": "2021-08-15T06:16:13.000Z", "num_tokens": 1177, "size": 3651 }
------------------------------------------------------------------------ -- Code related to the paper "Logical properties of a modality for -- erasure" -- -- Nils Anders Danielsson ------------------------------------------------------------------------ -- Note that the code does not follow the paper exactly. For instance, -- some definitions use bijections (functions with quasi-inverses) -- instead of equivalences. Some other differences are mentioned -- below. -- This file is not checked using --safe, because some parts use -- --cubical, and some parts use --with-K. However, all files -- imported below use --safe. {-# OPTIONS --cubical --with-K #-} module README.Erased where import Agda.Builtin.Equality import Agda.Builtin.Cubical.Id import Agda.Builtin.Cubical.Path import Embedding import Equality import Equality.Id import Equality.Instances-related import Equality.Path import Equality.Propositional import Equivalence import Erased import Erased.Cubical import Erased.With-K import Function-universe import H-level import Nat.Wrapper import Nat.Wrapper.Cubical import Prelude import Queue.Truncated import Quotient ------------------------------------------------------------------------ -- 3: Erased -- Erased. Erased = Erased.Erased ------------------------------------------------------------------------ -- 3.1: Erased is a monad -- Bind. bind = Erased._>>=′_ -- Erased is a monad. erased-monad = Erased.monad -- Lemma 3. Lemma-3 = Erased.Erased-Erased↔Erased ------------------------------------------------------------------------ -- 3.2: The relationship between @0 and Erased -- Lemma 4 and Lemma 5. Lemmas-4-and-5 = Erased.Π-Erased≃Π0[] -- The equality type family, defined as an inductive family. Equality-defined-as-an-inductive-family = Agda.Builtin.Equality._≡_ -- Cubical Agda paths. Path = Agda.Builtin.Cubical.Path._≡_ -- The Cubical Agda identity type family. Id = Agda.Builtin.Cubical.Id.Id -- The code uses an axiomatisation of "equality with J". The -- axiomatisation is a little convoluted in order to support using -- equality at all universe levels. Furthermore the axiomatisation -- supports choosing specific definitions for other functions, like -- cong, to make the code more usable when it is instantiated with -- Cubical Agda paths (for which the canonical definition of cong -- computes in a different way than typical definitions obtained -- using J). -- Equality and reflexivity. ≡-refl = Equality.Reflexive-relation -- The J rule and its computation rule. J-J-refl = Equality.Equality-with-J₀ -- Extended variants of the two definitions above. Equivalence-relation⁺ = Equality.Equivalence-relation⁺ Equality-with-J = Equality.Equality-with-J -- To see how the code is axiomatised, see the module header of, say, -- Erased. module See-the-module-header-of = Erased -- The equality type family defined as an inductive family, Cubical -- Agda paths and the Cubical Agda identity type family can all be -- used to instantiate the axioms. Equality-with-J-for-equality-defined-as-an-inductive-family = Equality.Propositional.equality-with-J Equality-with-J-for-Path = Equality.Path.equality-with-J Equality-with-J-for-Id = Equality.Id.equality-with-J -- Lemma 7 in Cubical Agda. Lemma-7-cubical = Erased.Cubical.Π-Erased≃Π0[] -- Lemma 7 in traditional Agda. Lemma-7-traditional = Erased.With-K.Π-Erased≃Π0[] ------------------------------------------------------------------------ -- 3.3: Erased commutes -- Some lemmas. Lemma-8 = Erased.Erased-⊤↔⊤ Lemma-9 = Erased.Erased-⊥↔⊥ Lemma-10 = Erased.Erased-Π↔Π Lemma-11 = Erased.Erased-Π↔Π-Erased Lemma-12 = Erased.Erased-Σ↔Σ -- W-types. W = Prelude.W -- Lemma 14 (Erased commutes with W-types up to logical equivalence). Lemma-14 = Erased.Erased-W⇔W -- Erased commutes with W-types, assuming extensionality for functions -- and []-cong. -- -- The code uses a universe of "function formers" which makes it -- possible to prove a single statement that can be instantiated both -- as a logical equivalence that does not rely on extensionality, as -- well as an equivalence that does rely on extensionality (and in -- other ways). This lemma, and several others, are stated in that -- way. Lemma-14′ = Erased.Erased-W↔W ------------------------------------------------------------------------ -- 3.4: The []-cong property -- []-cong, proved in traditional Agda. []-cong-traditional = Erased.With-K.[]-cong -- []-cong, proved in Cubical Agda for paths. []-cong-cubical-paths = Erased.Cubical.[]-cong-Path -- Every family of equality types satisfying the axiomatisation -- discussed above is in pointwise bijective correspondence with every -- other, with the bijections mapping reflexivity to reflexivity. Families-equivalent = Equality.Instances-related.all-equality-types-isomorphic -- []-cong, proved in Cubical Agda for an arbitrary equality type -- family satisfying the axiomatisation discussed above. []-cong-cubical = Erased.Cubical.[]-cong -- Lemmas 17 and 18 in traditional Agda. Lemma-17-traditional = Erased.With-K.[]-cong-equivalence Lemma-18-traditional = Erased.With-K.[]-cong-[refl] -- Lemmas 17 and 18 in Cubical Agda, with paths. Lemma-17-cubical-paths = Erased.Cubical.[]-cong-Path-equivalence Lemma-18-cubical-paths = Erased.Cubical.[]-cong-Path-[refl] -- Lemmas 17 and 18 in Cubical Agda, with an arbitrary family of -- equality types satisfying the axiomatisation discussed above. Lemma-17-cubical = Erased.Cubical.[]-cong-equivalence Lemma-18-cubical = Erased.Cubical.[]-cong-[refl] ------------------------------------------------------------------------ -- 3.5: H-levels -- H-level, For-iterated-equality and Contractible. H-level = H-level.H-level′ For-iterated-equality = H-level.For-iterated-equality Contractible = Equality.Reflexive-relation′.Contractible -- Sometimes the code uses the following definition of h-levels -- instead of the one used in the paper. Other-definition-of-h-levels = H-level.H-level -- The two definitions are pointwise logically equivalent, and -- pointwise equivalent if equality is extensional for functions. H-level≃H-level′ = Function-universe.H-level↔H-level′ -- There is a single statement for Lemmas 22 and 23. Lemmas-22-and-23 = Erased.Erased-H-level′↔H-level′ ------------------------------------------------------------------------ -- 3.6: Erased is a modality -- Some lemmas. Lemma-24 = Erased.uniquely-eliminating-modality Lemma-25 = Erased.lex-modality -- The map function. map = Erased.map -- Erased is a Σ-closed reflective subuniverse. Σ-closed-reflective-subuniverse = Erased.Erased-Σ-closed-reflective-subuniverse -- Another lemma. Lemma-27 = Erased.Erased-connected↔Erased-Is-equivalence ------------------------------------------------------------------------ -- 3.7: Is [_] an embedding? -- The function cong is unique up to pointwise equality if it is -- required to map the canonical proof of reflexivity to the canonical -- proof of reflexivity. cong-canonical = Equality.Derived-definitions-and-properties.cong-canonical -- Is-embedding. Is-embedding = Embedding.Is-embedding -- Embeddings are injective. embeddings-are-injective = Embedding.injective -- Some lemmas. Lemma-29 = Erased.Is-proposition→Is-embedding-[] Lemma-30 = Erased.With-K.Injective-[] Lemma-31 = Erased.With-K.Is-embedding-[] Lemma-32 = Erased.With-K.Is-proposition-Erased→Is-proposition ------------------------------------------------------------------------ -- 3.8: More commutation properties -- There is a single statement for Lemmas 33–38 (and more). Lemmas-33-to-38 = Erased.Erased-↝↔↝ -- There is also a single statement for the variants of Lemmas 33–38, -- stated as logical equivalences instead of equivalences, that can be -- proved without using extensionality. Lemmas-33-to-38-with-⇔ = Erased.Erased-↝↝↝ -- Some lemmas. Lemma-39 = Erased.Erased-cong-≃ Lemma-40 = Erased.Erased-Is-equivalence↔Is-equivalence -- A generalisation of Lemma 41. Lemma-41 = Function-universe.Σ-cong -- More lemmas. Lemma-42 = Erased.Erased-Split-surjective↔Split-surjective Lemma-43 = Erased.Erased-Has-quasi-inverse↔Has-quasi-inverse Lemma-44 = Erased.Erased-Injective↔Injective Lemma-45 = Erased.Erased-Is-embedding↔Is-embedding Lemma-46 = Erased.map-cong≡cong-map -- There is a single statement for Lemmas 47–52 (and more). Lemmas-47-to-52 = Erased.Erased-cong -- The map function is functorial. map-id = Erased.map-id map-∘ = Erased.map-∘ -- All preservation lemmas (47–52) map identity to identity (assuming -- extensionality, except for logical equivalences). Erased-cong-id = Erased.Erased-cong-id -- All preservation lemmas (47–52) commute with composition (assuming -- extensionality, except for logical equivalences). Erased-cong-∘ = Erased.Erased-cong-∘ ------------------------------------------------------------------------ -- 4.1: Stable types -- Stable. Stable = Erased.Stable -- Some lemmas. Lemma-54 = Erased.¬¬-stable→Stable Lemma-55 = Erased.Erased→¬¬ Lemma-56 = Erased.Dec→Stable ------------------------------------------------------------------------ -- 4.2: Very stable types -- Very-stable. Very-stable = Erased.Very-stable -- A generalisation of Very-stable′. Very-stable′ = Erased.Stable-[_] -- Very stable types are stable (and Very-stable A implies -- Very-stable′ A, and more). Very-stable→Stable = Erased.Very-stable→Stable -- [_] is an embedding for very stable types. Very-stable→Is-embedding-[] = Erased.Very-stable→Is-embedding-[] -- Some lemmas. Lemma-59 = Erased.Stable→Left-inverse→Very-stable Lemma-60 = Erased.Stable-proposition→Very-stable Lemma-61 = Erased.Very-stable-Erased -- It is not the case that every very stable type is a proposition. ¬-Very-stable→Is-proposition = Erased.¬-Very-stable→Is-proposition -- More lemmas. Lemma-62 = Erased.Very-stable-∃-Very-stable Lemma-63 = Erased.Stable-∃-Very-stable ------------------------------------------------------------------------ -- 4.3: Stability for equality types -- Stable-≡ and Very-stable-≡. Stable-≡ = Erased.Stable-≡ Very-stable-≡ = Erased.Very-stable-≡ -- Some lemmas. Lemma-66 = Erased.Stable→H-level-suc→Very-stable Lemma-67 = Erased.Decidable-equality→Very-stable-≡ Lemma-68 = Erased.H-level→Very-stable -- Lemmas 69 and 70, stated both as logical equivalences, and as -- equivalences depending on extensionality. Lemma-69 = Erased.Stable-≡↔Injective-[] Lemma-70 = Erased.Very-stable-≡↔Is-embedding-[] -- Equality is always very stable in traditional Agda. Very-stable-≡-trivial = Erased.With-K.Very-stable-≡-trivial ------------------------------------------------------------------------ -- 4.4: Map-like functions -- Lemma 71. Lemma-71 = Erased.Stable-map-⇔ -- There is a single statement for Lemmas 72 and 73. Lemmas-72-and-73 = Erased.Very-stable-cong -- Lemma 74. Lemma-74 = Erased.Very-stable-Erased↝Erased -- Lemma 74, with Stable instead of Very-stable, and no assumption of -- extensionality. Lemma-74-Stable = Erased.Stable-Erased↝Erased ------------------------------------------------------------------------ -- 4.5: Closure properties -- Lots of lemmas. Lemmas-75-and-76 = Erased.Very-stable→Very-stable-≡ Lemma-77 = Erased.Very-stable-⊤ Lemma-78 = Erased.Very-stable-⊥ Lemma-79 = Erased.Stable-Π Lemma-80 = Erased.Very-stable-Π Lemma-81 = Erased.Very-stable-Stable-Σ Lemma-82 = Erased.Very-stable-Σ Lemma-83 = Erased.Stable-× Lemma-84 = Erased.Very-stable-× Lemma-85 = Erased.Very-stable-W Lemmas-86-and-87 = Erased.Stable-H-level′ Lemmas-88-and-89 = Erased.Very-stable-H-level′ Lemma-90 = Erased.Stable-≡-⊎ Lemma-91 = Erased.Very-stable-≡-⊎ Lemma-92 = Erased.Stable-≡-List Lemma-93 = Erased.Very-stable-≡-List Lemma-94 = Quotient.Very-stable-≡-/ ------------------------------------------------------------------------ -- 4.6: []‐cong can be proved using extensionality -- The proof has been changed. Lemmas 95 and 97 have been removed. -- A lemma. Lemma-96 = Equivalence.≃-≡ -- []-cong, proved using extensionality, along with proofs showing -- that it is an equivalence and that it satisfies the computation -- rule of []-cong. Extensionality→[]-cong = Erased.Extensionality→[]-cong-axiomatisation ------------------------------------------------------------------------ -- 5.1: Singleton types with erased equality proofs -- Some lemmas. Lemma-99 = Erased.erased-singleton-contractible Lemma-100 = Erased.erased-singleton-with-erased-center-propositional -- The generalisation of Lemma 82 used in the proof of Lemma 100. Lemma-82-generalised = Erased.Very-stable-Σⁿ -- Another lemma. Lemma-101 = Erased.Σ-Erased-Erased-singleton↔ ------------------------------------------------------------------------ -- 5.2: Efficient natural numbers -- An implementation of natural numbers as lists of bits with the -- least significant bit first and an erased invariant that ensures -- that there are no trailing zeros. import Nat.Binary -- Nat-[_]. Nat-[_] = Nat.Wrapper.Nat-[_] -- A lemma. Lemma-103 = Nat.Wrapper.[]-cong.Nat-[]-propositional -- Nat. Nat = Nat.Wrapper.Nat -- ⌊_⌋. @0 ⌊_⌋ : _ ⌊_⌋ = Nat.Wrapper.⌊_⌋ -- Another lemma. Lemma-106 = Nat.Wrapper.[]-cong.≡-for-indices↔≡ ------------------------------------------------------------------------ -- 5.2.1: Arithmetic -- The functions unary-[] and unary. unary-[] = Nat.Wrapper.unary-[] unary = Nat.Wrapper.unary -- Similar functions for arbitrary arities. n-ary-[] = Nat.Wrapper.n-ary-[] n-ary = Nat.Wrapper.n-ary ------------------------------------------------------------------------ -- 5.2.2: Converting Nat to ℕ -- Some lemmas. Lemma-109 = Nat.Wrapper.Nat-[]↔Σℕ Lemma-110 = Nat.Wrapper.[]-cong.Nat↔ℕ -- The function Nat→ℕ. Nat→ℕ = Nat.Wrapper.Nat→ℕ -- Some lemmas. @0 Lemma-111 : _ Lemma-111 = Nat.Wrapper.≡⌊⌋ Lemma-112 = Nat.Wrapper.unary-correct -- A variant of Lemma 112 for n-ary. Lemma-112-for-n-ary = Nat.Wrapper.n-ary-correct ------------------------------------------------------------------------ -- 5.2.3: Decidable equality -- Some lemmas. Lemma-113 = Nat.Wrapper.Operations-for-Nat._≟_ Lemma-114 = Nat.Wrapper.Operations-for-Nat-[]._≟_ ------------------------------------------------------------------------ -- 5.3: Queues -- The implementation of queues (parametrised by an underlying queue -- implementation). module Queue = Queue.Truncated -- The functions enqueue and dequeue. enqueue = Queue.Truncated.Non-indexed.enqueue dequeue = Queue.Truncated.Non-indexed.dequeue ------------------------------------------------------------------------ -- 6: Discussion and related work -- Nat-[_]′. Nat-[_]′ = Nat.Wrapper.Cubical.Nat-[_]′ -- An alternative implementation of Nat. Alternative-Nat = Nat.Wrapper.Cubical.Nat-with-∥∥ -- The alternative implementation of Nat is isomorphic to the unit -- type. Alternative-Nat-isomorphic-to-⊤ = Nat.Wrapper.Cubical.Nat-with-∥∥↔⊤ -- The alternative implementation of Nat is not isomorphic to the -- natural numbers. Alternative-Nat-not-isomorphic-to-ℕ = Nat.Wrapper.Cubical.¬-Nat-with-∥∥↔ℕ
{ "alphanum_fraction": 0.6443072071, "avg_line_length": 26.7504393673, "ext": "agda", "hexsha": "55aa1eaa97d7cc2e771ea1fb5c2c7eb88ebc2b65", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "README/Erased.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "README/Erased.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "README/Erased.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": 4206, "size": 15221 }
module Prelude.Nat where open import Prelude.Bool data Nat : Set where Z : Nat S : Nat -> Nat {-# BUILTIN NATURAL Nat #-} infixl 30 _+_ _+_ : Nat -> Nat -> Nat Z + m = m S n + m = S (n + m) {-# BUILTIN NATPLUS _+_ #-} _*_ : Nat -> Nat -> Nat Z * m = Z S n * m = (n * m) + m {-# BUILTIN NATTIMES _*_ #-} _-_ : Nat -> Nat -> Nat n - Z = n (S n) - (S m) = n - m Z - _ = Z {-# BUILTIN NATMINUS _-_ #-} _<_ : Nat -> Nat -> Bool _ < Z = false Z < S _ = true S n < S m = n < m -- {-# BUILTIN NATLESS _<_ #-} Nid : Nat -> Bool -> Bool Nid Z true = true Nid Z false = false Nid (S n) m = (Nid n ( m)) -- {-# BUILTIN NATEQUALS __ #-}
{ "alphanum_fraction": 0.4765395894, "avg_line_length": 15.1555555556, "ext": "agda", "hexsha": "943ae290a83b17a53b60723a9caeb04ca91bbbbb", "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/epic/Prelude/Nat.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/epic/Prelude/Nat.agda", "max_line_length": 31, "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/epic/Prelude/Nat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 262, "size": 682 }
{-# OPTIONS --warning=error --safe --without-K #-} open import LogicalFormulae open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Functions.Definition open import Setoids.Setoids open import Setoids.Subset open import Graphs.Definition open import Sets.FinSet.Definition open import Sets.FinSet.Lemmas open import Numbers.Naturals.Semiring open import Numbers.Naturals.Order open import Sets.EquivalenceRelations open import Graphs.PathGraph module Graphs.CycleGraph where CycleGraph : (n : ℕ) → .(2 <N n) → Graph _ (reflSetoid (FinSet n)) Graph._<->_ (CycleGraph n _) x y = ((toNat x ≡ succ (toNat y)) || (toNat y ≡ succ (toNat x))) || (((toNat x ≡ 0) && (toNat y ≡ n)) || ((toNat y ≡ 0) && (toNat x ≡ n))) Graph.noSelfRelation (CycleGraph n _) y (inl (inl x)) = nNotSucc x Graph.noSelfRelation (CycleGraph n _) y (inl (inr x)) = nNotSucc x Graph.noSelfRelation (CycleGraph (succ n) _) y (inr (inl (fst ,, snd))) = naughtE (transitivity (equalityCommutative fst) snd) Graph.noSelfRelation (CycleGraph (succ n) _) y (inr (inr (fst ,, snd))) = naughtE (transitivity (equalityCommutative fst) snd) Graph.symmetric (CycleGraph n _) (inl (inl x)) = inl (inr x) Graph.symmetric (CycleGraph n _) (inl (inr x)) = inl (inl x) Graph.symmetric (CycleGraph n _) (inr (inl x)) = inr (inr x) Graph.symmetric (CycleGraph n _) (inr (inr x)) = inr (inl x) Graph.wellDefined (CycleGraph n _) refl refl i = i
{ "alphanum_fraction": 0.7100424328, "avg_line_length": 48.7586206897, "ext": "agda", "hexsha": "ab6bb90441421228a1089b1a7ec059e882402852", "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": "Graphs/CycleGraph.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": "Graphs/CycleGraph.agda", "max_line_length": 167, "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": "Graphs/CycleGraph.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": 467, "size": 1414 }
{-# OPTIONS --without-K --safe #-} module Data.Fin.Indexed where open import Data.Fin.Indexed.Base public
{ "alphanum_fraction": 0.7222222222, "avg_line_length": 18, "ext": "agda", "hexsha": "f1a52ed81e59378f4d84835b88f19007217f5ab6", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Data/Fin/Indexed.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Data/Fin/Indexed.agda", "max_line_length": 40, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Data/Fin/Indexed.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": 26, "size": 108 }
{-# OPTIONS --copatterns #-} open import Common.Nat open import Common.IO open import Common.Unit record Test : Set where field a b c : Nat f : Test -> Nat f r = a + b + c where open Test r open Test r1 : Test a r1 = 100 b r1 = 120 c r1 = 140 r2 : Test c r2 = 400 a r2 = 200 b r2 = 300 g : Nat g = f r1 + a m + b m + c m where m = r2 main : IO Unit main = printNat g -- Expected Output: 1260
{ "alphanum_fraction": 0.6058394161, "avg_line_length": 11.7428571429, "ext": "agda", "hexsha": "f7c5477214332af6d2e09298c85efdc030ae344d", "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/Compiler/simple/CopatternRecord.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/Compiler/simple/CopatternRecord.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/Compiler/simple/CopatternRecord.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 160, "size": 411 }
------------------------------------------------------------------------ -- Lists parameterised on things in Set₁ ------------------------------------------------------------------------ -- I want universe polymorphism. module Data.List1 where open import Data.List as List using (List; []; _∷_) open import Data.Nat infixr 5 _∷_ _++_ data List₁ (a : Set₁) : Set₁ where [] : List₁ a _∷_ : (x : a) (xs : List₁ a) → List₁ a _++_ : ∀ {a} → List₁ a → List₁ a → List₁ a [] ++ bs = bs (a ∷ as) ++ bs = a ∷ (as ++ bs) map₀₁ : ∀ {a b} → (a → b) → List a → List₁ b map₀₁ f [] = [] map₀₁ f (x ∷ xs) = f x ∷ map₀₁ f xs map₁₁ : ∀ {a b} → (a → b) → List₁ a → List₁ b map₁₁ f [] = [] map₁₁ f (x ∷ xs) = f x ∷ map₁₁ f xs replicate : ∀ {a} → (n : ℕ) → a → List₁ a replicate zero x = [] replicate (suc n) x = x ∷ replicate n x foldr₁₀ : {a : Set₁} {b : Set} → (a → b → b) → b → List₁ a → b foldr₁₀ c n [] = n foldr₁₀ c n (x ∷ xs) = c x (foldr₁₀ c n xs) foldr₁₁ : {a b : Set₁} → (a → b → b) → b → List₁ a → b foldr₁₁ c n [] = n foldr₁₁ c n (x ∷ xs) = c x (foldr₁₁ c n xs) length : ∀ {A} → List₁ A → ℕ length [] = zero length (x ∷ xs) = suc (length xs)
{ "alphanum_fraction": 0.4512605042, "avg_line_length": 26.4444444444, "ext": "agda", "hexsha": "fc9cc736987648593f784b068738d0d2a8bd6b3c", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Data/List1.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Data/List1.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Data/List1.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 461, "size": 1190 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Extensive where -- https://ncatlab.org/nlab/show/extensive+category open import Level open import Categories.Category.Core open import Categories.Diagram.Pullback open import Categories.Category.Cocartesian open import Categories.Object.Coproduct open import Categories.Morphism record Extensive {o ℓ e : Level} (𝒞 : Category o ℓ e) : Set (suc (o ⊔ ℓ ⊔ e)) where open Category 𝒞 open Pullback field cocartesian : Cocartesian 𝒞 module CC = Cocartesian cocartesian open CC using (_+_; i₁; i₂; ¡) field pullback₁ : {A B C : Obj} (f : A ⇒ B + C) → Pullback 𝒞 f i₁ pullback₂ : {A B C : Obj} (f : A ⇒ B + C) → Pullback 𝒞 f i₂ pullback-of-cp-is-cp : {A B C : Obj} (f : A ⇒ _+_ B C) → IsCoproduct 𝒞 (p₁ (pullback₁ f)) (p₁ (pullback₂ f)) pullback₁-is-mono : ∀ {A B : Obj} → Mono 𝒞 (i₁ {A = A}{B = B}) pullback₂-is-mono : ∀ {A B : Obj} → Mono 𝒞 (i₂ {A = A}{B = B}) disjoint : ∀ {A B : Obj} → IsPullback 𝒞 ¡ ¡ (i₁ {A = A}{B = B}) i₂
{ "alphanum_fraction": 0.6244041945, "avg_line_length": 23.3111111111, "ext": "agda", "hexsha": "d8c2c3eecf439e893d67a8c09f668ef3235ab517", "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": "e2d7596549e7840b521576f48746ac3c4560f126", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "sergey-goncharov/agda-categories", "max_forks_repo_path": "src/Categories/Category/Extensive.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e2d7596549e7840b521576f48746ac3c4560f126", "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": "sergey-goncharov/agda-categories", "max_issues_repo_path": "src/Categories/Category/Extensive.agda", "max_line_length": 112, "max_stars_count": null, "max_stars_repo_head_hexsha": "e2d7596549e7840b521576f48746ac3c4560f126", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "sergey-goncharov/agda-categories", "max_stars_repo_path": "src/Categories/Category/Extensive.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 380, "size": 1049 }
{-# OPTIONS --without-K --exact-split --safe #-} module Fragment.Equational.Structures where import Fragment.Equational.Theory.Laws as L open import Fragment.Equational.Theory open import Fragment.Equational.Theory.Bundles open import Fragment.Equational.Model open import Fragment.Algebra.Algebra open import Level using (Level) open import Data.Fin using (Fin; #_; suc; zero) open import Data.Vec using ([]; _∷_) open import Data.Vec.Relation.Binary.Pointwise.Inductive using ([]; _∷_) open import Relation.Binary using (Setoid; Rel) open import Algebra.Core private variable a ℓ : Level module _ {A : Set a} {_≈_ : Rel A ℓ} where open import Algebra.Definitions _≈_ open import Algebra.Structures _≈_ module _ {_•_ : Op₂ A} where module _ (isMagma : IsMagma _•_) where open IsMagma isMagma magma→setoid : Setoid a ℓ magma→setoid = record { Carrier = A ; _≈_ = _≈_ ; isEquivalence = isEquivalence } private magma→⟦⟧ : Interpretation Σ-magma magma→setoid magma→⟦⟧ MagmaOp.• (x ∷ y ∷ []) = _•_ x y magma→⟦⟧-cong : Congruent₂ _•_ → Congruence Σ-magma magma→setoid magma→⟦⟧ magma→⟦⟧-cong c MagmaOp.• (x₁≈x₂ ∷ y₁≈y₂ ∷ []) = c x₁≈x₂ y₁≈y₂ magma→isAlgebra : IsAlgebra Σ-magma magma→setoid magma→isAlgebra = record { ⟦_⟧ = magma→⟦⟧ ; ⟦⟧-cong = magma→⟦⟧-cong ∙-cong } magma→algebra : Algebra Σ-magma magma→algebra = record { ∥_∥/≈ = magma→setoid ; ∥_∥/≈-isAlgebra = magma→isAlgebra } private magma→models : Models Θ-magma magma→algebra magma→models () magma→isModel : IsModel Θ-magma magma→setoid magma→isModel = record { isAlgebra = magma→isAlgebra ; models = magma→models } magma→model : Model Θ-magma magma→model = record { ∥_∥/≈ = magma→setoid ; isModel = magma→isModel } module _ (isSemigroup : IsSemigroup _•_) where private open IsSemigroup isSemigroup renaming (assoc to •-assoc) semigroup→models : Models Θ-semigroup (magma→algebra isMagma) semigroup→models assoc θ = •-assoc (θ (# 0)) (θ (# 1)) (θ (# 2)) semigroup→isModel : IsModel Θ-semigroup (magma→setoid isMagma) semigroup→isModel = record { isAlgebra = magma→isAlgebra isMagma ; models = semigroup→models } semigroup→model : Model Θ-semigroup semigroup→model = record { ∥_∥/≈ = magma→setoid isMagma ; isModel = semigroup→isModel } module _ (isCSemigroup : IsCommutativeSemigroup _•_) where private open IsCommutativeSemigroup isCSemigroup renaming (comm to •-comm; assoc to •-assoc) csemigroup→models : Models Θ-csemigroup (magma→algebra isMagma) csemigroup→models comm θ = •-comm (θ (# 0)) (θ (# 1)) csemigroup→models assoc θ = •-assoc (θ (# 0)) (θ (# 1)) (θ (# 2)) csemigroup→isModel : IsModel Θ-csemigroup (magma→setoid isMagma) csemigroup→isModel = record { isAlgebra = magma→isAlgebra isMagma ; models = csemigroup→models } csemigroup→model : Model Θ-csemigroup csemigroup→model = record { ∥_∥/≈ = magma→setoid isMagma ; isModel = csemigroup→isModel }
{ "alphanum_fraction": 0.5453580902, "avg_line_length": 33.3628318584, "ext": "agda", "hexsha": "64f3a1c66f0abcc31b4697f326f06fda8a9bd375", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z", "max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z", "max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "yallop/agda-fragment", "max_forks_repo_path": "src/Fragment/Equational/Structures.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z", "max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "yallop/agda-fragment", "max_issues_repo_path": "src/Fragment/Equational/Structures.agda", "max_line_length": 81, "max_stars_count": 18, "max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yallop/agda-fragment", "max_stars_repo_path": "src/Fragment/Equational/Structures.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z", "num_tokens": 1092, "size": 3770 }
{-# OPTIONS --without-K --safe #-} module Util.HoTT.Equiv where open import Util.HoTT.Equiv.Core public open import Relation.Binary using (Setoid ; IsEquivalence) open import Util.Data.Product using (map₂) open import Util.HoTT.HLevel.Core using (IsContr ; IsProp) open import Util.HoTT.Section open import Util.HoTT.Singleton using (IsContr-Singleton) open import Util.Prelude open import Util.Relation.Binary.PropositionalEquality using ( Σ-≡⁻ ; Σ-≡⁺ ; trans-symʳ ; trans-unassoc ) private variable α β γ : Level A B C : Set α IsIso→HasSection-forth : {f : A → B} → IsIso f → HasSection f IsIso→HasSection-forth i = record { section = i .IsIso.back ; isSection = i .IsIso.forth∘back } IsIso→HasSection-back : {f : A → B} → (i : IsIso f) → HasSection (i .IsIso.back) IsIso→HasSection-back {f = f} i = record { section = f ; isSection = i .IsIso.back∘forth } IsIso→Injective : {f : A → B} → IsIso f → Injective f IsIso→Injective f-iso fx≡fy = trans (sym (f-iso .IsIso.back∘forth _)) (trans (cong (f-iso .IsIso.back) fx≡fy) (f-iso .IsIso.back∘forth _)) IsEquiv→IsIso : {f : A → B} → IsEquiv f → IsIso f IsEquiv→IsIso {A = A} {B = B} {forth} equiv = record { back = back′ ; back∘forth = back∘forth′ ; forth∘back = forth∘back′ } where back′ : B → A back′ b with equiv b ... | (a , _) , _ = a back∘forth′ : ∀ x → back′ (forth x) ≡ x back∘forth′ a with equiv (forth a) ... | (a′ , fortha′≡fortha) , unique = proj₁ (Σ-≡⁻ (unique (a , refl))) forth∘back′ : ∀ x → forth (back′ x) ≡ x forth∘back′ b with equiv b ... | (a , fortha≡b) , _ = fortha≡b IsEquiv→Injective : {f : A → B} → IsEquiv f → Injective f IsEquiv→Injective = IsIso→Injective ∘ IsEquiv→IsIso -- This proof follows Martin Escardó's lecture notes -- (https://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html#fibersandequivalences). IsIso→IsEquiv : {f : A → B} → IsIso f → IsEquiv f IsIso→IsEquiv {A = A} {B = B} {forth} iso b = ◁-pres-IsContr (◁-trans ii iii) IsContr-Singleton where module I = IsIso iso A◁B : A ◁ B A◁B = record { retraction = I.back ; hasSection = IsIso→HasSection-back iso } i : ∀ b′ → (forth (I.back b′) ≡ b) ◁ (b′ ≡ b) i b′ = record { retraction = λ b′≡b → trans (I.forth∘back b′) b′≡b ; hasSection = record { section = λ eq → trans (sym (I.forth∘back b′)) eq ; isSection = λ x → let open ≡-Reasoning in begin trans (I.forth∘back b′) (trans (sym (I.forth∘back b′)) x) ≡⟨ trans-unassoc (I.forth∘back b′) ⟩ trans (trans (I.forth∘back b′) (sym (I.forth∘back b′))) x ≡⟨ cong (λ p → trans p x) (trans-symʳ (I.forth∘back b′)) ⟩ x ∎ } } ii : ∃[ a ] (forth a ≡ b) ◁ ∃[ b′ ] (forth (I.back b′) ≡ b) ii = Σ-◁-reindexing A◁B iii : ∃[ b′ ] (forth (I.back b′) ≡ b) ◁ ∃[ b′ ] (b′ ≡ b) -- aka Singleton b iii = Σ-◁ i ≅-refl : A ≅ A ≅-refl .forth x = x ≅-refl .isIso .IsIso.back x = x ≅-refl .isIso .IsIso.forth∘back x = refl ≅-refl .isIso .IsIso.back∘forth x = refl ≅-sym : A ≅ B → B ≅ A ≅-sym A≅B .forth = A≅B .back ≅-sym A≅B .isIso .IsIso.back = A≅B .forth ≅-sym A≅B .isIso .IsIso.back∘forth = A≅B .forth∘back ≅-sym A≅B .isIso .IsIso.forth∘back = A≅B .back∘forth ≅-trans : A ≅ B → B ≅ C → A ≅ C ≅-trans A≅B B≅C .forth = B≅C .forth ∘ A≅B .forth ≅-trans A≅B B≅C .isIso .IsIso.back = A≅B .back ∘ B≅C .back ≅-trans A≅B B≅C .isIso .IsIso.back∘forth x = trans (cong (A≅B .back) (B≅C .back∘forth _)) (A≅B .back∘forth _) ≅-trans A≅B B≅C .isIso .IsIso.forth∘back x = trans (cong (B≅C .forth) (A≅B .forth∘back _)) (B≅C .forth∘back _) ≅-isEquivalence : IsEquivalence (_≅_ {α}) ≅-isEquivalence .IsEquivalence.refl = ≅-refl ≅-isEquivalence .IsEquivalence.sym = ≅-sym ≅-isEquivalence .IsEquivalence.trans = ≅-trans ≅-setoid : ∀ α → Setoid (lsuc α) α ≅-setoid α .Setoid.Carrier = Set α ≅-setoid α .Setoid._≈_ = _≅_ ≅-setoid α .Setoid.isEquivalence = ≅-isEquivalence ≅-reflexive : A ≡ B → A ≅ B ≅-reflexive refl = ≅-refl ≡→≅ = ≅-reflexive ≅-Injective : (i : A ≅ B) → Injective (i .forth) ≅-Injective i = IsIso→Injective (i .isIso) ≅→◁ : A ≅ B → A ◁ B ≅→◁ A≅B = record { retraction = A≅B .back ; hasSection = IsIso→HasSection-back (A≅B .isIso) } ≅→▷ : A ≅ B → B ◁ A ≅→▷ A≅B = record { retraction = A≅B .forth ; hasSection = IsIso→HasSection-forth (A≅B .isIso) } ≃→≅ : A ≃ B → A ≅ B ≃→≅ A≃B .forth = A≃B .forth ≃→≅ A≃B .isIso = IsEquiv→IsIso (A≃B .isEquiv) ≅→≃ : A ≅ B → A ≃ B ≅→≃ A≅B .forth = A≅B .forth ≅→≃ A≅B .isEquiv = IsIso→IsEquiv (A≅B .isIso) id-IsEquiv : IsEquiv (id {A = A}) id-IsEquiv a = (a , refl) , λ { (b , refl) → refl } ≃-refl : A ≃ A ≃-refl = record { forth = id ; isEquiv = id-IsEquiv } ≃-reflexive : A ≡ B → A ≃ B ≃-reflexive refl = ≃-refl ≡→≃ = ≃-reflexive ≃-sym : A ≃ B → B ≃ A ≃-sym = ≅→≃ ∘ ≅-sym ∘ ≃→≅ ≃-trans : A ≃ B → B ≃ C → A ≃ C ≃-trans A≃B B≃C = ≅→≃ (≅-trans (≃→≅ A≃B) (≃→≅ B≃C)) ≃-isEquivalence : IsEquivalence (_≃_ {α}) ≃-isEquivalence .IsEquivalence.refl = ≃-refl ≃-isEquivalence .IsEquivalence.sym = ≃-sym ≃-isEquivalence .IsEquivalence.trans = ≃-trans ≃-setoid : ∀ α → Setoid (lsuc α) α ≃-setoid α .Setoid.Carrier = Set α ≃-setoid α .Setoid._≈_ = _≃_ ≃-setoid α .Setoid.isEquivalence = ≃-isEquivalence ≃-Injective : (e : A ≃ B) → Injective (e .forth) ≃-Injective = ≅-Injective ∘ ≃→≅ ≃→◁ : A ≃ B → A ◁ B ≃→◁ = ≅→◁ ∘ ≃→≅ ≃→▷ : A ≃ B → B ◁ A ≃→▷ = ≅→▷ ∘ ≃→≅ -- Special cases of ≃-pres-IsOfHLevel (in Util.HoTT.HLevel), but proven -- directly. This means that A and B can be at different levels. ≅-pres-IsContr : A ≅ B → IsContr A → IsContr B ≅-pres-IsContr A≅B (a , canon) = A≅B .forth a , λ a′ → trans (cong (A≅B .forth) (canon (A≅B .back a′))) (A≅B .forth∘back _) ≃-pres-IsContr : A ≃ B → IsContr A → IsContr B ≃-pres-IsContr A≃B = ≅-pres-IsContr (≃→≅ A≃B) ≅-pres-IsProp : A ≅ B → IsProp A → IsProp B ≅-pres-IsProp A≅B A-prop x y = trans (sym (A≅B .forth∘back x)) (sym (trans (sym (A≅B .forth∘back y)) (cong (A≅B .forth) (A-prop _ _)))) ≃-pres-IsProp : A ≃ B → IsProp A → IsProp B ≃-pres-IsProp A≃B = ≅-pres-IsProp (≃→≅ A≃B) Σ-≅⁺ : {A : Set α} {B : A → Set β} {C : A → Set γ} → (∀ a → B a ≅ C a) → Σ A B ≅ Σ A C Σ-≅⁺ eq = record { forth = λ { (a , b) → a , eq a .forth b } ; isIso = record { back = λ { (a , c) → a , eq a .back c } ; back∘forth = λ { (a , b) → Σ-≡⁺ (refl , eq a .back∘forth b) } ; forth∘back = λ { (a , c) → Σ-≡⁺ (refl , eq a .forth∘back c) } } } Σ-≃⁺ : {A : Set α} {B : A → Set β} {C : A → Set γ} → (∀ a → B a ≃ C a) → Σ A B ≃ Σ A C Σ-≃⁺ eq = ≅→≃ (Σ-≅⁺ λ a → ≃→≅ (eq a)) map₂-fiber-≃ : {A : Set α} {B : A → Set β} {C : A → Set γ} → (f : ∀ a → B a → C a) → ∀ a (c : C a) → ∃[ b ] (f a b ≡ c) ≃ ∃[ p ] (map₂ f p ≡ (a , c)) map₂-fiber-≃ f a c = ≅→≃ record { forth = λ { (b , refl) → (a , b) , refl } ; isIso = record { back = λ { ((.a , b) , refl) → b , refl } ; back∘forth = λ { (b , refl) → refl } ; forth∘back = λ { ((.a , b) , refl) → refl } } } IsEquiv-map₂-f→IsEquiv-f : {A : Set α} {B : A → Set β} {C : A → Set γ} → (f : ∀ a → B a → C a) → IsEquiv (map₂ f) → ∀ a → IsEquiv (f a) IsEquiv-map₂-f→IsEquiv-f {A = A} {B} {C} f equiv a c = ≃-pres-IsContr (≃-sym (map₂-fiber-≃ f a c)) (equiv (a , c)) sym-≅ : {x y : A} → (x ≡ y) ≅ (y ≡ x) sym-≅ = record { forth = sym ; isIso = record { back = sym ; back∘forth = λ { refl → refl } ; forth∘back = λ { refl → refl } } } sym-≃ : {x y : A} → (x ≡ y) ≃ (y ≡ x) sym-≃ = ≅→≃ sym-≅ IsContr→IsIso : IsContr A → IsContr B → (f : A → B) → IsIso f IsContr→IsIso (a , a-uniq) (b , b-uniq) f = record { back = λ _ → a ; back∘forth = λ _ → a-uniq _ ; forth∘back = λ b′ → trans (sym (b-uniq (f a))) (b-uniq b′) } IsContr→IsEquiv : IsContr A → IsContr B → (f : A → B) → IsEquiv f IsContr→IsEquiv A-contr B-contr f = IsIso→IsEquiv (IsContr→IsIso A-contr B-contr f) proj₁-IsIso : {A : Set α} {B : A → Set β} → (∀ a → IsContr (B a)) → IsIso (proj₁ {A = A} {B}) proj₁-IsIso B-contr = record { back = λ a → (a , B-contr a .proj₁) ; back∘forth = λ { (a , b) → Σ-≡⁺ (refl , (B-contr a .proj₂ b)) } ; forth∘back = λ _ → refl } proj₁-IsEquiv : {A : Set α} {B : A → Set β} → (∀ a → IsContr (B a)) → IsEquiv (proj₁ {A = A} {B}) proj₁-IsEquiv B-contr = IsIso→IsEquiv (proj₁-IsIso B-contr) Π-distr-Σ-≅ : (A : Set α) (B : A → Set β) (C : ∀ a → B a → Set γ) → (∀ a → Σ[ b ∈ B a ] (C a b)) ≅ (Σ[ f ∈ (∀ a → B a) ] (∀ a → C a (f a))) Π-distr-Σ-≅ A B C = record { forth = λ f → (λ a → f a .proj₁) , (λ a → f a .proj₂) ; isIso = record { back = λ { (f , g) → λ a → f a , g a } ; back∘forth = λ _ → refl ; forth∘back = λ _ → refl } }
{ "alphanum_fraction": 0.5352560463, "avg_line_length": 25.9793510324, "ext": "agda", "hexsha": "c8544899496a5115bfc1693fd941bf5df61a6299", "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": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JLimperg/msc-thesis-code", "max_forks_repo_path": "src/Util/HoTT/Equiv.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JLimperg/msc-thesis-code", "max_issues_repo_path": "src/Util/HoTT/Equiv.agda", "max_line_length": 106, "max_stars_count": 5, "max_stars_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JLimperg/msc-thesis-code", "max_stars_repo_path": "src/Util/HoTT/Equiv.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-26T06:37:31.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-13T21:31:17.000Z", "num_tokens": 4115, "size": 8807 }
------------------------------------------------------------------------ -- INCREMENTAL λ-CALCULUS -- -- Postulate extensionality of functions. -- -- Justification on Agda mailing list: -- http://permalink.gmane.org/gmane.comp.lang.agda/2343 ------------------------------------------------------------------------ module Postulate.Extensionality where open import Relation.Binary.PropositionalEquality postulate ext : ∀ {a b} → Extensionality a b -- Convenience of using extensionality 3 times in a row -- (using it twice in a row is moderately tolerable) ext³ : ∀ {A : Set} {B : A → Set} {C : (a : A) → B a → Set } {D : (a : A) → (b : B a) → C a b → Set} {f g : (a : A) → (b : B a) → (c : C a b) → D a b c} → ((a : A) (b : B a) (c : C a b) → f a b c ≡ g a b c) → f ≡ g ext³ fabc=gabc = ext (λ a → ext (λ b → ext (λ c → fabc=gabc a b c)))
{ "alphanum_fraction": 0.493006993, "avg_line_length": 30.6428571429, "ext": "agda", "hexsha": "56069262c6c6cc86afd689294d1cd50213f696e5", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_path": "Postulate/Extensionality.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_path": "Postulate/Extensionality.agda", "max_line_length": 72, "max_stars_count": 10, "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_path": "Postulate/Extensionality.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "num_tokens": 267, "size": 858 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} open import Cubical.Core.Everything open import Cubical.Algebra.Group module Cubical.Algebra.Group.Construct.Opposite {ℓ} (G : Group ℓ) where open import Cubical.Foundations.Prelude open import Cubical.Data.Prod using (_,_) open Group G import Cubical.Algebra.Monoid.Construct.Opposite monoid as OpMonoid open OpMonoid public hiding (Op-isMonoid; Mᵒᵖ) •ᵒᵖ-inverseˡ : LeftInverse ε _⁻¹ _•ᵒᵖ_ •ᵒᵖ-inverseˡ _ = inverseʳ _ •ᵒᵖ-inverseʳ : RightInverse ε _⁻¹ _•ᵒᵖ_ •ᵒᵖ-inverseʳ _ = inverseˡ _ •ᵒᵖ-inverse : Inverse ε _⁻¹ _•ᵒᵖ_ •ᵒᵖ-inverse = •ᵒᵖ-inverseˡ , •ᵒᵖ-inverseʳ Op-isGroup : IsGroup Carrier _•ᵒᵖ_ ε _⁻¹ Op-isGroup = record { isMonoid = OpMonoid.Op-isMonoid ; inverse = •ᵒᵖ-inverse } Gᵒᵖ : Group ℓ Gᵒᵖ = record { isGroup = Op-isGroup }
{ "alphanum_fraction": 0.7316770186, "avg_line_length": 23.6764705882, "ext": "agda", "hexsha": "39a83afcba2dcdff06467b325c8b02fd87f4f6f7", "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/Algebra/Group/Construct/Opposite.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/Algebra/Group/Construct/Opposite.agda", "max_line_length": 71, "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/Algebra/Group/Construct/Opposite.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 348, "size": 805 }
module Issue2224 where -- This is a placeholder to ensure that the test case is run. -- The file of interest is `Issue2224.sh`, and the associated file -- Issue2224WrongExtension.agda.tex
{ "alphanum_fraction": 0.7765957447, "avg_line_length": 37.6, "ext": "agda", "hexsha": "46c7bb293296600151b19ac80231808c0e1408fd", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue2224.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue2224.agda", "max_line_length": 66, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue2224.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": 47, "size": 188 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.RingSolver.IntAsRawRing where open import Cubical.Data.Nat hiding (_+_; _·_) open import Cubical.Data.Int open import Cubical.Data.Int.Base renaming (Int to ℤ) public open import Cubical.Foundations.Prelude open import Cubical.Algebra.RingSolver.RawRing ℤAsRawRing : RawRing {ℓ-zero} ℤAsRawRing = rawring ℤ (pos zero) (pos (suc zero)) _+_ _·_ (λ k → - k) +Ridℤ : (k : ℤ) → (pos zero) + k ≡ k +Ridℤ k = sym (pos0+ k)
{ "alphanum_fraction": 0.7125506073, "avg_line_length": 30.875, "ext": "agda", "hexsha": "92d5c91c25161f0216c9d47df3e532b42e57e2db", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Algebra/RingSolver/IntAsRawRing.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Algebra/RingSolver/IntAsRawRing.agda", "max_line_length": 70, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Algebra/RingSolver/IntAsRawRing.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 170, "size": 494 }
open import Type -- The relation (_⟶_) should be interpreted as "a term reduces/rewritten to another term". -- Also called: Abstract reduction system, abstract rewriting system, rewriting system. module ReductionSystem {ℓ₁ ℓ₂} {Term : Type{ℓ₁}} (_⟶_ : Term → Term → Type{ℓ₂}) where open import Functional open import Graph.Properties open import Graph.Walk open import Graph.Walk.Proofs open import Lang.Instance import Lvl open import Logic open import Logic.Propositional open import Logic.Predicate open import Relator.Converse open import Relator.Equals open import Relator.Equals.Proofs.Equiv open import Relator.ReflexiveTransitiveClosure open import Structure.Setoid.Uniqueness open import Structure.Relator.Equivalence open import Structure.Relator.Ordering open import Structure.Relator.Properties open import Syntax.Function open import Syntax.Transitivity open Graph.Properties using (intro) public -- The relation (_⟶_) is a function on the left argument. -- In terms of paths, it means that there are no forks on any paths. Deterministic = ∀{a} → Unique(a ⟶_) -- A term is reducible when there is a term it can reduce to. -- In terms of paths, it means that one can go somewhere else from this point. Reducible : Term → Stmt Reducible(a) = ∃(a ⟶_) -- A term is in normal form when it is irreducible (cannot be reduced any further). -- Also called: Irreducible term -- In terms of paths, it means that this point is a dead-end. NormalForm : Term → Stmt NormalForm = FinalVertex(_⟶_) module NormalForm = FinalVertex -- "a normalizes to b" means that "a" reduces to the normal form "b". -- In terms of paths, this means that the dead end of one path from "a" is "b". record _normalizes-to_ (a : Term) (b : Term) : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where constructor intro field reduction : Walk(_⟶_) a b ⦃ normalForm ⦄ : NormalForm(b) -- In terms of paths, this means that there is a path which leads to a dead-end. WeaklyNormalizes : Term → Stmt WeaklyNormalizes a = ∃(a normalizes-to_) -- A reduction system is weakly normalizing when all terms in the language have a normal form. -- In terms of paths, this means that all points have a path whch eventually lead to a dead-end. WeaklyNormalizing = ∀ₗ(WeaklyNormalizes) StronglyNormalizes : Term → Stmt StronglyNormalizes = Strict.Properties.Accessibleₗ(Converse(_⟶_)) -- Every term reduces to a normal form. -- Also called: Terminating. StronglyNormalizing : Stmt StronglyNormalizing = Strict.Properties.WellFounded(Converse(_⟶_)) -- Both a and b reduce to c in zero or more steps. -- Also called: _⟶*_*⟵_ CommonReduct : Term → Term → Term → Stmt CommonReduct c a b = (Walk(_⟶_) a c) ∧ (Walk(_⟶_) b c) -- Both a and b reduce to the same term in zero or more steps. -- In terms of paths, this means that paths starting from the two points are able to eventually meet. -- Also called: Joinable, _⟶*_*⟵_ _↓_. Joinable : Term → Term → Stmt Joinable a b = ∃(c ↦ CommonReduct c a b) module Names where import Structure.Relator.Names as Names EverywhereCommonReduct = Names.Subrelation (Walk(_⟶_)) Joinable module _ (a : Term) where Confluent = ∀{b c} → (Walk(_⟶_) a b) → (Walk(_⟶_) a c) → Joinable b c Semiconfluent = ∀{b c} → (a ⟶ b) → (Walk(_⟶_) a c) → Joinable b c LocallyConfluent = ∀{b c} → (a ⟶ b) → (a ⟶ c) → Joinable b c StronglyConfluent = ∀{b c} → (a ⟶ b) → (a ⟶ c) → ∃(d ↦ (ReflexiveClosure(_⟶_) b d) ∧ (Walk(_⟶_) c d)) DiamondProperty = ∀{b c} → (a ⟶ b) → (a ⟶ c) → ∃(d ↦ (b ⟶ d) ∧ (c ⟶ d)) Confluence = ∀ₗ(Confluent) -- Also called: The Church-Rosser property EverywhereCommonReduct = (Walk(_⟶_)) ⊆₂ Joinable module _ (a : Term) where -- A term is confluent when all its reducts have a common reduct. -- In terms of paths, this means that paths starting from this point will always eventually meet. record Confluent : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where constructor intro field proof : Names.Confluent(a) confluent = inst-fn Confluent.proof record Semiconfluent : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where constructor intro field proof : Names.Semiconfluent(a) semiconfluent = inst-fn Semiconfluent.proof record LocallyConfluent : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where constructor intro field proof : Names.LocallyConfluent(a) locally-confluent = inst-fn LocallyConfluent.proof record StronglyConfluent : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where constructor intro field proof : Names.StronglyConfluent(a) strongly-confluent = inst-fn StronglyConfluent.proof record DiamondProperty : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where constructor intro field proof : Names.DiamondProperty(a) diamond-property = inst-fn DiamondProperty.proof -- All terms are confluent. -- In terms of paths, this means that parts starting from the same point can always eventually meet. Confluence = ∀ₗ(Confluent) Semiconfluence = ∀ₗ(Semiconfluent) LocalConfluence = ∀ₗ(LocallyConfluent) StrongConfluence = ∀ₗ(StronglyConfluent) record Convergent : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where constructor intro field ⦃ confluence ⦄ : Confluence ⦃ strongly-normalizing ⦄ : StronglyNormalizing -- Evaluable = ∃(f ↦ ) -- All paths from a dead-end results in going nowhere. Normal-unique-Path : ∀{a} → ⦃ _ : NormalForm(a) ⦄ → ∀{b} → Walk(_⟶_) a b → (a ≡ b) Normal-unique-Path at = [≡]-intro Normal-unique-Path ⦃ intro na ⦄ (prepend ab1 sb1b) = [⊥]-elim(na ab1) instance -- A term reduces to itself in zero steps. -- In terms of paths, this means that two paths starting from the same point can reach this same point. Joinable-reflexivity : Reflexivity(Joinable) ∃.witness (Reflexivity.proof Joinable-reflexivity {x}) = x ∃.proof (Reflexivity.proof Joinable-reflexivity {x}) = [∧]-intro Walk.at Walk.at instance -- When one reduces to the same term as the other, the other also reduces to the same term as the first one. Joinable-symmetry : Symmetry(Joinable) ∃.witness (Symmetry.proof Joinable-symmetry {x} {y} xy) = [∃]-witness xy ∃.proof (Symmetry.proof Joinable-symmetry {x} {y} xy) = [∧]-intro ([∧]-elimᵣ(∃.proof xy)) (([∧]-elimₗ(∃.proof xy))) instance -- When one reduces to the same term as the other, the other also reduces to the same term as the first one. Walk-Joinable-subrelation : Walk(_⟶_) ⊆₂ Joinable ∃.witness (_⊆₂_.proof Walk-Joinable-subrelation {y = y} ab) = y ∃.proof (_⊆₂_.proof Walk-Joinable-subrelation ab) = [∧]-intro ab (reflexivity(Walk(_⟶_))) module _ ⦃ confl : Confluence ⦄ where import Structure.Relator.Names as Names instance Confluence-to-Joinable-transitivity : Transitivity(Joinable) Confluence-to-Joinable-transitivity = intro proof where proof : Names.Transitivity(Joinable) proof {x}{y}{z} ([∃]-intro obj-xy ⦃ [∧]-intro pxxy pyxy ⦄) ([∃]-intro obj-yz ⦃ [∧]-intro pyyz pzyz ⦄) = [∃]-intro obj ⦃ [∧]-intro l r ⦄ where objxy-objyz-common-reduct : Joinable obj-xy obj-yz objxy-objyz-common-reduct = confluent(y) pyxy pyyz obj : Term obj = [∃]-witness objxy-objyz-common-reduct l : Walk(_⟶_) x obj l = transitivity(Walk(_⟶_)) pxxy ([∧]-elimₗ ([∃]-proof objxy-objyz-common-reduct)) r : Walk(_⟶_) z obj r = transitivity(Walk(_⟶_)) pzyz ([∧]-elimᵣ ([∃]-proof objxy-objyz-common-reduct)) instance Confluence-to-Joinable-equivalence : Equivalence(Joinable) Confluence-to-Joinable-equivalence = intro module _ (det : Deterministic) where -- Frege thing deterministic-dichotomy : ∀{a b c} → (Walk(_⟶_) a b) → (Walk(_⟶_) a c) → (Walk(_⟶_) b c) ∨ (Walk(_⟶_) c b) deterministic-dichotomy at ac = [∨]-introₗ ac deterministic-dichotomy (ab @ (prepend _ _)) at = [∨]-introᵣ ab deterministic-dichotomy (prepend ab2 b) (prepend ab3 ac) with det ab2 ab3 ... | [≡]-intro = deterministic-dichotomy b ac deterministic-step : ∀{a b c} → (a ⟶ b) → (Walk(_⟶_) a c) → ((a ≡ c) ∨ (Walk(_⟶_) b c)) deterministic-step ab at = [∨]-introₗ [≡]-intro deterministic-step ab (prepend ab₁ ac) rewrite det ab ab₁ = [∨]-introᵣ ac instance deterministic-confluence : Confluence deterministic-confluence = intro proof where proof : Names.Confluence proof {c = c} at ac = [∃]-intro c ⦃ [∧]-intro ac at ⦄ {-# CATCHALL #-} proof {b = b} ab at = [∃]-intro b ⦃ [∧]-intro at ab ⦄ proof (prepend ab1 ab) (prepend ab2 ac) rewrite det ab1 ab2 = proof ab ac deterministic-unique-normalizes-to : ∀{a} → Unique(a normalizes-to_) deterministic-unique-normalizes-to (intro ax) (intro ay) = proof ax ay where proof : ∀{a b c} → ⦃ _ : NormalForm(b) ⦄ → ⦃ _ : NormalForm(c) ⦄ → Walk(_⟶_) a b → Walk(_⟶_) a c → (b ≡ c) proof at at = [≡]-intro proof ⦃ intro normal-x ⦄ ⦃ _ ⦄ at (prepend ab by) = [⊥]-elim(normal-x ab) proof ⦃ _ ⦄ ⦃ intro normal-y ⦄ (prepend ab bx) at = [⊥]-elim(normal-y ab) proof (prepend ab₁ b₁x) (prepend ab₂ b₂y) rewrite det ab₁ ab₂ = proof b₁x b₂y confluence-semiconfluence : Confluence ↔ Semiconfluence confluence-semiconfluence = [↔]-intro (semiconfl ↦ intro(l(semiconfl))) r where l : Names.Confluence ← Semiconfluence l semiconfl at xc = sub₂(Walk(_⟶_))(Joinable) xc l semiconfl (prepend xb₁ b₁b) xc with Semiconfluent.proof semiconfl xb₁ xc ... | [∃]-intro d ⦃ [∧]-intro b₁d c₁d ⦄ with l semiconfl b₁b b₁d ... | [∃]-intro e ⦃ [∧]-intro be de ⦄ = [∃]-intro e ⦃ [∧]-intro be (transitivity(Walk(_⟶_)) c₁d de) ⦄ r : Confluence → Semiconfluence Semiconfluent.proof (r confl) xb xc = Confluent.proof confl (sub₂(_⟶_)(Walk(_⟶_)) xb) xc -- TODO: Not sure, but maybe? {-# TERMINATING #-} strong-confluence-confluence : StrongConfluence → Confluence strong-confluence-confluence strconfl = intro(proof strconfl) where proof : StrongConfluence → Names.Confluence proof strconfl {x} at at = reflexivity(Joinable) proof strconfl {x} at (prepend xb bc) = sub₂(Walk(_⟶_))(Joinable) (prepend xb bc) proof strconfl {x} (prepend xb₁ b₁b) at = symmetry(Joinable) (sub₂(Walk(_⟶_))(Joinable) (prepend xb₁ b₁b)) proof strconfl {x} {b}{c} (prepend xb₁ b₁b) (prepend xb₂ b₂c) with StronglyConfluent.proof strconfl xb₁ xb₂ proof strconfl {x} {b}{c} (prepend xd db) (prepend xb₁ b₁c) | [∃]-intro d ⦃ [∧]-intro refl b₁d ⦄ with proof strconfl b₁c b₁d ... | [∃]-intro e ⦃ [∧]-intro ce de ⦄ with proof strconfl db de ... | [∃]-intro f ⦃ [∧]-intro bf ef ⦄ = [∃]-intro f ⦃ [∧]-intro bf (transitivity(Walk(_⟶_)) ce ef) ⦄ proof strconfl {x} {b}{c} (prepend xb₁ b₁b) (prepend xb₂ b₂c) | [∃]-intro d ⦃ [∧]-intro (super b₁d) b₂d ⦄ with proof strconfl b₁b (sub₂(_⟶_)(Walk(_⟶_)) b₁d) ... | [∃]-intro e ⦃ [∧]-intro be de ⦄ with proof strconfl b₂c b₂d ... | [∃]-intro f ⦃ [∧]-intro cf df ⦄ with proof strconfl de df ... | [∃]-intro g ⦃ [∧]-intro eg fg ⦄ = [∃]-intro g ⦃ [∧]-intro (transitivity(Walk(_⟶_)) be eg) (transitivity(Walk(_⟶_)) cf fg) ⦄ semiconfluence-everywhere-common-reduct : ⦃ _ : Semiconfluence ⦄ → EverywhereCommonReduct semiconfluence-everywhere-common-reduct ⦃ semiconfl ⦄ = intro proof where instance confl : Confluence confl = [↔]-to-[←] confluence-semiconfluence semiconfl proof : Names.EverywhereCommonReduct proof at = reflexivity(Joinable) proof {a}{c} (prepend {b = b} ab bc) = transitivity(Joinable) (sub₂(Walk(_⟶_))(Joinable) (sub₂(_⟶_)(Walk(_⟶_)) ab)) (proof bc) diamond-property-locally-confluent : ⦃ _ : ∀ₗ(DiamondProperty) ⦄ → LocalConfluence LocallyConfluent.proof (diamond-property-locally-confluent {x}) xb xc = [∃]-map-proof ([∧]-map (sub₂(_⟶_)(Walk(_⟶_))) (sub₂(_⟶_)(Walk(_⟶_)))) (diamond-property _ xb xc) -- locally-confluent-diamond-property : ⦃ LocalConfluence ⦄ → ∀ₗ(DiamondProperty) -- DiamondProperty.proof locally-confluent-diamond-property xb xc = {!locally-confluent _ xb xc!} -- Terminating ↔ LocalConfluence (TODO: See Newman's lemma) -- Convergent → ∀{a} → Unique(a normalizes-to_) -- Confluence → (Walk(_⟶_) x y) → NormalForm(y) → (ReflexiveClosure(_⟶_) x y) -- Confluence → (Walk(_⟶_) x y) → Unique(NormalForm) -- Confluence → ∀{a} → Unique(a normalizes-to_)
{ "alphanum_fraction": 0.6741674909, "avg_line_length": 44.6029411765, "ext": "agda", "hexsha": "6c609177f06d66f8efc3ae60ea294457d23b4c94", "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": "ReductionSystem.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": "ReductionSystem.agda", "max_line_length": 168, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "ReductionSystem.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": 4133, "size": 12132 }
-- Andreas, 2016-07-01 issue #2078 -- Holes in postponed type-checking problems cannot be worked on. -- {-# OPTIONS -v interaction:30 #-} -- {-# OPTIONS -v tc.term.exlam:30 -v tc:5 #-} test : Set → Set test A = (λ{ B → {!B!}}) A -- splitting on B gives -- No type nor action available for hole ?0
{ "alphanum_fraction": 0.6333333333, "avg_line_length": 25, "ext": "agda", "hexsha": "ffc996c8e2785fa1cbb4fef1568a9acad16f41ac", "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/Issue2078.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/Issue2078.agda", "max_line_length": 65, "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/Issue2078.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 95, "size": 300 }
module Issue475 where data Box (A : Set) : Set where box : A → Box A postulate T : {A : Set} → A → Set unbox : {A : Set} → Box A → A data BoxT {A : Set}(b : Box A) : Set where boxT : T (unbox b) → BoxT b -- Can't be projection-like since we've already used it in BoxT unbox (box x) = x postulate A : Set b : Box A unboxT : BoxT b → T (unbox b) unboxT (boxT p) = p
{ "alphanum_fraction": 0.5890052356, "avg_line_length": 15.9166666667, "ext": "agda", "hexsha": "73721c7fe576b506cda6a0777ebdb06a88e7202f", "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/Issue475.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/Issue475.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/Issue475.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 151, "size": 382 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import Haskell.Modules.RWS open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.Interface.Output open import LibraBFT.ImplShared.Util.Dijkstra.All open import Util.Prelude ------------------------------------------------------------------------------ open import Data.String using (String) module LibraBFT.Impl.OBM.Logging.Logging where -- NOTE: Logging operations change the structure of the program, and proofs about peer -- operations are sensitive to this structure. Therefore, we add a "skeleton" of -- logging operations so that future refinements do not break existing proofs. -- In the future, we may wish to model and reason about errors and logging in more detail. postulate -- TODO-1 : errText : Note, the existing Agda ErrLog constructors do not contain text. errText : ErrLog → List String errText' : ErrLog → String logErr : ErrLog → LBFT Unit logErr x = tell (LogErr x ∷ []) logInfo : InfoLog → LBFT Unit logInfo x = tell (LogInfo x ∷ []) logEE : ∀ {A} → List String → LBFT A → LBFT A logEE _ f = logInfo fakeInfo >> f >>= λ r → logInfo fakeInfo >> pure r withErrCtx : List String → ErrLog → ErrLog withErrCtx _ = id withErrCtx' : ∀ {A} → List String → Either ErrLog A → Either ErrLog A withErrCtx' ctx = λ where (Left e) → Left (withErrCtx ctx e) (Right b) → pure b withErrCtxD' : ∀ {ℓ} {E : Set → Set → Set ℓ} ⦃ _ : EitherLike E ⦄ → ∀ {A : Set} → List String → E ErrLog A → EitherD ErrLog A withErrCtxD' ctx e = case toEither e of λ where (Left e) → fromEither $ Left (withErrCtx ctx e) (Right b) → fromEither $ Right b lcheck : ∀ {ℓ} {B : Set ℓ} ⦃ _ : ToBool B ⦄ → B → List String → Either ErrLog Unit lcheck b t = case check (toBool b) t of λ where (Left e) → Left fakeErr -- (ErrL [e]) (Right r) → Right r lcheckInfo : ∀ {ℓ} {B : Set ℓ} ⦃ _ : ToBool B ⦄ → B → List String → Either ErrLog Unit lcheckInfo b t = case check (toBool b) t of λ where (Left _) → Left (ErrInfo fakeInfo {-InfoL [e]-}) (Right r) → Right r
{ "alphanum_fraction": 0.6624343257, "avg_line_length": 38.0666666667, "ext": "agda", "hexsha": "0bf316a6aa6d83c6f0357c1cafd373325ebb80a0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_forks_repo_path": "src/LibraBFT/Impl/OBM/Logging/Logging.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_issues_repo_path": "src/LibraBFT/Impl/OBM/Logging/Logging.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_stars_repo_path": "src/LibraBFT/Impl/OBM/Logging/Logging.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 688, "size": 2284 }
{-# OPTIONS --without-K --safe #-} -- The category of Cats is Monoidal module Categories.Category.Monoidal.Instance.StrictCats where open import Level open import Data.Product using (Σ; _×_; _,_; proj₁; proj₂; uncurry) open import Relation.Binary.PropositionalEquality as ≡ using (_≡_; refl; cong₂; sym; module ≡-Reasoning; subst₂; cong) open import Function using (_$_) open import Data.Unit using (⊤; tt) open import Categories.Category open import Categories.Functor using (Functor; _∘F_) renaming (id to idF) open import Categories.Category.Instance.StrictCats open import Categories.Category.Instance.One using (One) open import Categories.Category.Monoidal open import Categories.Functor.Bifunctor open import Categories.Functor.Construction.Constant open import Categories.Functor.Equivalence open import Categories.Category.Product open import Categories.Category.Product.Properties import Categories.Category.Cartesian as Cartesian import Categories.Morphism.HeterogeneousIdentity as HId import Categories.Morphism.HeterogeneousIdentity.Properties as HIdProps import Categories.Morphism.Reasoning as MR open import Categories.Object.Terminal open import Categories.Utils.Product using (zipWith) open import Categories.Utils.EqReasoning -- (Strict) Cats is a (strict) Monoidal Category with Product as Bifunctor module Product {o ℓ e : Level} where private C = Cats o ℓ e open Cartesian C open _≡F_ Cats-has-all : BinaryProducts Cats-has-all = record { product = λ {A} {B} → record { A×B = Product A B ; π₁ = πˡ ; π₂ = πʳ ; ⟨_,_⟩ = _※_ ; project₁ = record { eq₀ = λ _ → ≡.refl ; eq₁ = λ _ → MR.id-comm-sym A } ; project₂ = record { eq₀ = λ _ → ≡.refl ; eq₁ = λ _ → MR.id-comm-sym B } ; unique = λ {hA} {h} {i} {j} left right → let unique-eq₀ X = cong₂ _,_ (≡.sym $ eq₀ left X) (≡.sym $ eq₀ right X) in record { eq₀ = unique-eq₀ ; eq₁ = λ {a} {b} f → let module A = Category A module B = Category B module C = Category C module A×B = Category (Product A B) open A×B.HomReasoning open HId open HIdProps open Functor leq a = ≡.sym $ eq₀ left a req a = ≡.sym $ eq₀ right a in begin hid (Product A B) (unique-eq₀ b) A×B.∘ F₁ (i ※ j) f ≈˘⟨ A×B.∘-resp-≈ˡ (×-hid A B (leq b) (req b)) ⟩ (hid A (leq b) A.∘ F₁ i f , hid B (req b) B.∘ F₁ j f) ≈⟨ eq₁⁻¹ left f , eq₁⁻¹ right f ⟩ F₁ (πˡ C.∘ h) f A.∘ hid A (leq a) , F₁ (πʳ C.∘ h) f B.∘ hid B (req a) ≈⟨ A×B.∘-resp-≈ʳ (×-hid A B (leq a) (req a)) ⟩ (F₁ h f) A×B.∘ (hid (Product A B) (unique-eq₀ a)) ∎ } } } private unique-One : {l : Level} (x : Lift l ⊤) → lift tt ≡ x unique-One (lift tt) = refl One-⊤ : Terminal C One-⊤ = record { ⊤ = One ; ! = const (lift tt) ; !-unique = λ f → record { eq₀ = λ _ → unique-One _ ; eq₁ = λ _ → lift tt } } Cats-is : Cartesian Cats-is = record { terminal = One-⊤ ; products = Cats-has-all } private module Cart = Cartesian.Cartesian Cats-is Cats-Monoidal : Monoidal C Cats-Monoidal = Cart.monoidal
{ "alphanum_fraction": 0.6078787879, "avg_line_length": 35.1063829787, "ext": "agda", "hexsha": "367511754563ec9c403a496b57ef44096870a8b5", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Category/Monoidal/Instance/StrictCats.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Category/Monoidal/Instance/StrictCats.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Category/Monoidal/Instance/StrictCats.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1054, "size": 3300 }
module Inductive.Examples.List where open import Inductive open import Tuple hiding (_++_) open import Data.Fin open import Data.Product hiding (map) open import Data.List hiding (List; map; foldr; _++_) open import Data.Vec hiding (map; foldr; _++_) List : Set → Set List A = Inductive (([] , []) ∷ (((A ∷ []) , ([] ∷ [])) ∷ [])) nil : {A : Set} → List A nil = construct zero [] [] cons : {A : Set} → A → List A → List A cons x xs = construct (suc zero) (x ∷ []) ((λ _ → xs) ∷ []) map : {A B : Set} → (A → B) → List A → List B map f = rec (nil ∷ ((λ a as ras → cons (f a) ras) ∷ [])) foldr : {A B : Set} → (A → B → B) → B → List A → B foldr f b = rec (b ∷ (λ a as ras → f a ras) ∷ []) _++_ : {A : Set} → List A → List A → List A xs ++ ys = rec (ys ∷ (λ a as ras → cons a ras) ∷ []) xs
{ "alphanum_fraction": 0.5390428212, "avg_line_length": 28.3571428571, "ext": "agda", "hexsha": "6df063436cdecda97b1a4fa91484753c5b33d1d1", "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": "dc157acda597a2c758e82b5637e4fd6717ccec3f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mr-ohman/general-induction", "max_forks_repo_path": "Inductive/Examples/List.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "dc157acda597a2c758e82b5637e4fd6717ccec3f", "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": "mr-ohman/general-induction", "max_issues_repo_path": "Inductive/Examples/List.agda", "max_line_length": 62, "max_stars_count": null, "max_stars_repo_head_hexsha": "dc157acda597a2c758e82b5637e4fd6717ccec3f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mr-ohman/general-induction", "max_stars_repo_path": "Inductive/Examples/List.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 293, "size": 794 }
{-# OPTIONS --without-K #-} module function.isomorphism.remove where open import sum open import equality open import function.isomorphism.core open import function.isomorphism.utils open import function.isomorphism.properties open import function.overloading open import sets.empty _minus_ : ∀ {i}(A : Set i) → A → Set i A minus x = Σ A λ x' → ¬ (x' ≡ x) iso-remove : ∀ {i j}{A : Set i}{B : Set j} → (isom : A ≅ B) → (x : A) → (A minus x) ≅ (B minus (apply isom x)) iso-remove {A = A}{B} isom x = Σ-ap-iso isom λ a → Π-ap-iso (iso≡ isom) λ _ → refl≅
{ "alphanum_fraction": 0.6046128501, "avg_line_length": 25.2916666667, "ext": "agda", "hexsha": "c97647aa98cc953177d791b80bff8b1ceaeedcf9", "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/function/isomorphism/remove.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/function/isomorphism/remove.agda", "max_line_length": 43, "max_stars_count": 27, "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_path": "function/isomorphism/remove.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": 196, "size": 607 }
{-# OPTIONS --without-K #-} module container.w where open import container.w.core public open import container.w.algebra public open import container.w.fibration public
{ "alphanum_fraction": 0.783625731, "avg_line_length": 24.4285714286, "ext": "agda", "hexsha": "4a0e322637153a8f4f828d2ae40e289bd109572d", "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/container/w.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/container/w.agda", "max_line_length": 40, "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/container/w.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": 35, "size": 171 }
module Issue604 where f : (y : Set1) → (x : Set) → Set1 f x = ?
{ "alphanum_fraction": 0.5384615385, "avg_line_length": 13, "ext": "agda", "hexsha": "cb3fb57e1ea5451fd77b8e545d923fe2595aaa45", "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/Issue604.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/Issue604.agda", "max_line_length": 33, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue604.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": 27, "size": 65 }
open import Nat open import Prelude open import contexts open import dynamics-core open import lemmas-matching open import synth-unicity module elaboration-unicity where mutual elaboration-unicity-synth : {Γ : tctx} {e : hexp} {τ1 τ2 : htyp} {d1 d2 : ihexp} {Δ1 Δ2 : hctx} → Γ ⊢ e ⇒ τ1 ~> d1 ⊣ Δ1 → Γ ⊢ e ⇒ τ2 ~> d2 ⊣ Δ2 → τ1 == τ2 × d1 == d2 × Δ1 == Δ2 elaboration-unicity-synth ESNum ESNum = refl , refl , refl elaboration-unicity-synth (ESPlus apt1 dis1 x₁ x₂) (ESPlus apt2 dis2 x₃ x₄) with elaboration-unicity-ana x₁ x₃ | elaboration-unicity-ana x₂ x₄ ... | refl , refl , refl | refl , refl , refl = refl , refl , refl elaboration-unicity-synth (ESAsc x) (ESAsc x₁) with elaboration-unicity-ana x x₁ ... | refl , refl , refl = refl , refl , refl elaboration-unicity-synth (ESVar {Γ = Γ} x₁) (ESVar x₂) = ctxunicity {Γ = Γ} x₁ x₂ , refl , refl elaboration-unicity-synth (ESLam apt1 d1) (ESLam apt2 d2) with elaboration-unicity-synth d1 d2 ... | ih1 , ih2 , ih3 = ap1 _ ih1 , ap1 _ ih2 , ih3 elaboration-unicity-synth (ESAp _ _ x x₁ x₂ x₃) (ESAp _ _ x₄ x₅ x₆ x₇) with synthunicity x x₄ ... | refl with ▸arr-unicity x₁ x₅ ... | refl with elaboration-unicity-ana x₂ x₆ ... | refl , refl , refl with elaboration-unicity-ana x₃ x₇ ... | refl , refl , refl = refl , refl , refl elaboration-unicity-synth ESEHole ESEHole = refl , refl , refl elaboration-unicity-synth (ESNEHole _ d1) (ESNEHole _ d2) with elaboration-unicity-synth d1 d2 ... | ih1 , ih2 , ih3 = refl , ap1 _ ih2 , ap1 _ ih3 elaboration-unicity-synth (ESPair x x₁ wt1 wt2) (ESPair x₂ x₃ wt3 wt4) with elaboration-unicity-synth wt1 wt3 | elaboration-unicity-synth wt2 wt4 ... | refl , refl , refl | refl , refl , refl = refl , refl , refl elaboration-unicity-synth (ESFst wt1 x₁ d1) (ESFst wt2 x₄ d2) with synthunicity wt1 wt2 ... | refl with ▸prod-unicity x₁ x₄ ... | refl with elaboration-unicity-ana d1 d2 ... | refl , refl , refl = refl , refl , refl elaboration-unicity-synth (ESSnd wt1 x₁ d1) (ESSnd wt2 x₄ d2) with synthunicity wt1 wt2 ... | refl with ▸prod-unicity x₁ x₄ ... | refl with elaboration-unicity-ana d1 d2 ... | refl , refl , refl = refl , refl , refl elaboration-unicity-ana : {Γ : tctx} {e : hexp} {τ τ1 τ2 : htyp} {d1 d2 : ihexp} {Δ1 Δ2 : hctx} → Γ ⊢ e ⇐ τ ~> d1 :: τ1 ⊣ Δ1 → Γ ⊢ e ⇐ τ ~> d2 :: τ2 ⊣ Δ2 → d1 == d2 × τ1 == τ2 × Δ1 == Δ2 elaboration-unicity-ana (EALam x₁ m D1) (EALam x₂ m2 D2) with ▸arr-unicity m m2 ... | refl with elaboration-unicity-ana D1 D2 ... | refl , refl , refl = refl , refl , refl elaboration-unicity-ana (EALam x₁ m D1) (EASubsume x₂ x₃ () x₅) elaboration-unicity-ana (EASubsume x₁ x₂ () x₄) (EALam x₅ m D2) elaboration-unicity-ana (EASubsume x x₁ x₂ x₃) (EASubsume x₄ x₅ x₆ x₇) with elaboration-unicity-synth x₂ x₆ ... | refl , refl , refl = refl , refl , refl elaboration-unicity-ana (EASubsume x x₁ () x₃) (EAInl x₄ wt2) elaboration-unicity-ana (EASubsume x x₁ () x₃) (EAInr x₄ wt2) elaboration-unicity-ana (EASubsume x x₁ () x₃) (EACase x₄ x₅ x₆ x₇ x₈ x₉ x₁₀ x₁₁ x₁₂ x₁₃ wt2 wt3) elaboration-unicity-ana (EASubsume x x₁ x₂ x₃) EAEHole = abort (x _ refl) elaboration-unicity-ana (EASubsume x x₁ x₂ x₃) (EANEHole _ x₄) = abort (x₁ _ _ refl) elaboration-unicity-ana (EAInl x x₁) (EAInl y y₁) with ▸sum-unicity x y ... | refl with elaboration-unicity-ana x₁ y₁ ... | refl , refl , refl = refl , refl , refl elaboration-unicity-ana (EAInl x wt1) (EASubsume x₁ x₂ () x₄) elaboration-unicity-ana (EAInr x x₁) (EAInr y y₁) with ▸sum-unicity x y ... | refl with elaboration-unicity-ana x₁ y₁ ... | refl , refl , refl = refl , refl , refl elaboration-unicity-ana (EAInr x wt1) (EASubsume x₁ x₂ () x₄) elaboration-unicity-ana (EACase x x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈ x₉ wt1 wt2) (EASubsume x₁₀ x₁₁ () x₁₃) elaboration-unicity-ana (EACase x x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈ x₉ x₁₀ x₁₁) (EACase y y₁ y₂ y₃ y₄ y₅ y₆ y₇ y₈ y₉ y₁₀ y₁₁) with elaboration-unicity-synth x₈ y₈ ... | refl , refl , refl with ▸sum-unicity x₉ y₉ ... | refl with elaboration-unicity-ana x₁₀ y₁₀ ... | refl , refl , refl with elaboration-unicity-ana x₁₁ y₁₁ ... | refl , refl , refl = refl , refl , refl elaboration-unicity-ana EAEHole (EASubsume x x₁ x₂ x₃) = abort (x _ refl) elaboration-unicity-ana EAEHole EAEHole = refl , refl , refl elaboration-unicity-ana (EANEHole _ x) (EASubsume x₁ x₂ x₃ x₄) = abort (x₂ _ _ refl) elaboration-unicity-ana (EANEHole _ x) (EANEHole _ x₁) with elaboration-unicity-synth x x₁ ... | refl , refl , refl = refl , refl , refl
{ "alphanum_fraction": 0.6192221543, "avg_line_length": 54.5666666667, "ext": "agda", "hexsha": "98d3c91e3b85986163cd296a59c2abcb2dc1a3a6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-agda", "max_forks_repo_path": "elaboration-unicity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnut-agda", "max_issues_repo_path": "elaboration-unicity.agda", "max_line_length": 119, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-agda", "max_stars_repo_path": "elaboration-unicity.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1978, "size": 4911 }
-- Should fail with S i != i module Issue216 where open import Common.Level Foo : {i : Level} → Set i Foo {i} = (R : Set i) → R
{ "alphanum_fraction": 0.6106870229, "avg_line_length": 14.5555555556, "ext": "agda", "hexsha": "df43bde3501cf4582ae0edb2d98581adf0873da0", "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/Issue216.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/Issue216.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/Issue216.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": 45, "size": 131 }
module relations where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; cong) open import Data.Nat using (ℕ; zero; suc; _+_) open import Data.Nat.Properties using (+-comm; +-identityʳ) data _≤_ : ℕ → ℕ → Set where z≤n : ∀ {n : ℕ} → zero ≤ n s≤s : ∀ {m n : ℕ} → m ≤ n → suc m ≤ suc n infix 4 _≤_ foo : 2 ≤ 4 foo = s≤s (s≤s z≤n) inv-s≤s : ∀ {m n : ℕ} → suc m ≤ suc n → m ≤ n inv-s≤s (s≤s m≤n) = m≤n bar : 1 ≤ 3 bar = inv-s≤s foo
{ "alphanum_fraction": 0.5806451613, "avg_line_length": 21.1363636364, "ext": "agda", "hexsha": "99c017d4ec32c8b881ed28606522a50595fc16df", "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": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "aronerben/agda-playground", "max_forks_repo_path": "plfa/relations.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "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": "aronerben/agda-playground", "max_issues_repo_path": "plfa/relations.agda", "max_line_length": 59, "max_stars_count": null, "max_stars_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "aronerben/agda-playground", "max_stars_repo_path": "plfa/relations.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 206, "size": 465 }
module Crash where data N : Set where zero : N suc : N -> N data B : Set where true : B false : B F : B -> Set F true = N F false = B not : B -> B not true = false not false = true h : ((x : F _) -> F (not x)) -> N h g = g zero
{ "alphanum_fraction": 0.5162601626, "avg_line_length": 10.6956521739, "ext": "agda", "hexsha": "f41b8f2144fabf509520244da080ef3f720a6b20", "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/Crash.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/Crash.agda", "max_line_length": 33, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Crash.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": 96, "size": 246 }
{-# OPTIONS --without-K #-} open import HoTT open import lib.cubical.elims.SuspSmash module homotopy.SuspProduct where module SuspProduct {i} {j} (X : Ptd i) (Y : Ptd j) where private {- into -} into-glue : fst (X ⊙× Y) → winl (north _) == winr (winr (north _)) into-glue (x , y) = ap winl (σloop X x) ∙ wglue ∙ ap (winr ∘ winl) (σloop (⊙Smash X Y) (cfcod _ (x , y))) ∙ ap winr wglue ∙ ap (winr ∘ winr) (σloop Y y) into-glue-x : (x : fst X) → into-glue (x , snd Y) == ap winl (σloop X x) ∙ wglue ∙ ap winr wglue into-glue-x x = ap (λ p → ap winl (σloop X x) ∙ wglue ∙ p ∙ ap winr wglue ∙ ap (winr ∘ winr) (σloop Y (snd Y))) (ap (ap (winr ∘ winl) ∘ σloop (⊙Smash X Y)) (! (cfglue _ (winl x))) ∙ ap (ap (winr ∘ winl)) σloop-pt) ∙ ap (λ q → ap winl (σloop X x) ∙ wglue ∙ ap winr wglue ∙ ap (winr ∘ winr) q) σloop-pt ∙ ap (λ q → ap winl (σloop X x) ∙ wglue ∙ q) (∙-unit-r _) into-glue-y : (y : fst Y) → into-glue (snd X , y) == wglue ∙ ap winr wglue ∙ ap (winr ∘ winr) (σloop Y y) into-glue-y y = ap (λ p → ap winl (σloop X (snd X)) ∙ wglue ∙ p ∙ ap winr wglue ∙ ap (winr ∘ winr) (σloop Y y)) (ap (ap (winr ∘ winl) ∘ σloop (⊙Smash X Y)) (! (cfglue _ (winr y))) ∙ ap (ap (winr ∘ winl)) σloop-pt) ∙ ap (λ q → ap winl q ∙ wglue ∙ ap winr wglue ∙ ap (winr ∘ winr) (σloop Y y)) σloop-pt into-glue-0 : into-glue (snd X , snd Y) == wglue ∙ ap winr wglue into-glue-0 = into-glue-x (snd X) ∙ ap (λ p → ap winl p ∙ wglue ∙ ap winr wglue) σloop-pt module Into = SuspensionRec (fst (X ⊙× Y)) {C = fst (⊙Susp X ⊙∨ (⊙Susp (X ⊙∧ Y) ⊙∨ ⊙Susp Y))} (winl (north _)) (winr (winr (north _))) into-glue into = Into.f {- out -} out-× : fst X × fst Y → north _ == north _ out-× (x , y) = merid _ (snd X , snd Y) ∙ ! (merid _ (x , snd Y)) ∙ merid _ (x , y) ∙ ! (merid _ (snd X , y)) expand₁ : ∀ {i} {A : Type i} {x y z : A} (p : x == y) (q : z == y) → idp == p ∙ ! q ∙ q ∙ ! p expand₁ idp idp = idp expand₂ : ∀ {i} {A : Type i} {x y z : A} (p : x == y) (q : x == z) → idp == p ∙ ! p ∙ q ∙ ! q expand₂ idp idp = idp shift : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} → Square p₀₋ p₋₀ p₋₁ p₁₋ → Square p₀₋ idp p₋₁ (p₋₀ ∙ p₁₋) shift ids = ids fill : Σ (idp == idp) (λ p → Square (expand₁ (merid _ (snd X , snd Y)) (merid _ (snd X , snd Y))) p (ap (λ w → out-× (∨-in-× X Y w)) wglue) (expand₂ (merid _ (snd X , snd Y)) (merid _ (snd X , snd Y)))) fill = fill-square-top _ _ _ module OutSmash = SuspensionRec (Smash X Y) (north (fst (X ⊙× Y))) (north _) (CofiberRec.f _ idp out-× (Wedge-elim (λ x → expand₁ (merid _ (snd X , snd Y)) (merid _ (x , snd Y))) (λ y → fst fill ∙ expand₂ (merid _ (snd X , snd Y)) (merid _ (snd X , y))) (↓-cst=app-from-square $ shift (snd fill)))) module OutWinr = WedgeRec {X = ⊙Susp (X ⊙∧ Y)} {Y = ⊙Susp Y} {C = fst (⊙Susp (X ⊙× Y))} OutSmash.f (susp-fmap (λ y → (snd X , y))) idp module Out = WedgeRec {X = ⊙Susp X} {Y = ⊙Susp (X ⊙∧ Y) ⊙∨ ⊙Susp Y} {C = fst (⊙Susp (X ⊙× Y))} (susp-fmap (λ x → (x , snd Y))) OutWinr.f idp out = Out.f {- into-out -} into-out-x : ∀ σx → into (out (winl σx)) == winl σx into-out-x = Suspension-elim _ idp (! (ap winl (! (merid _ (snd X))) ∙ wglue ∙ ap winr wglue)) (λ x → ↓-='-from-square $ (ap-∘ into (out ∘ winl) (merid _ x) ∙ ap (ap into) (SuspFmap.glue-β (λ x → (x , snd Y)) x) ∙ Into.glue-β (x , snd Y) ∙ into-glue-x x ∙ ap (λ p → p ∙ wglue ∙ ap winr wglue) (ap-∙ winl (merid _ x) (! (merid _ (snd X)))) ∙ ∙-assoc (ap winl (merid _ x)) (ap winl (! (merid _ (snd X)))) (wglue ∙ ap winr wglue)) ∙v⊡ (vid-square {p = ap winl (merid _ x)} ⊡h tr-square (ap winl (! (merid _ (snd X))) ∙ wglue ∙ ap winr wglue)) ⊡v∙ ∙-unit-r _) into-out-y : ∀ σy → into (out (winr (winr σy))) == winr (winr σy) into-out-y = Suspension-elim _ (wglue ∙ ap winr wglue) (ap (winr ∘ winr) (merid _ (snd Y))) (λ y → ↓-='-from-square $ (ap-∘ into (out ∘ winr ∘ winr) (merid _ y) ∙ ap (ap into) (SuspFmap.glue-β (λ y → (snd X , y)) y) ∙ Into.glue-β (snd X , y) ∙ into-glue-y y ∙ ap (λ p → wglue ∙ ap winr wglue ∙ p) (ap-∙ (winr ∘ winr) (merid _ y) (! (merid _ (snd Y))) ∙ ap (λ q → ap (winr ∘ winr) (merid _ y) ∙ q) (ap-! (winr ∘ winr) (merid _ (snd Y))))) ∙v⊡ lemma wglue (ap winr wglue) (ap (winr ∘ winr) (merid _ y)) (ap (winr ∘ winr) (merid _ (snd Y)))) where lemma : ∀ {i} {A : Type i} {a₁ a₂ a₃ a₄ : A} (p : a₁ == a₂) (q : a₂ == a₃) (r : a₃ == a₄) (s : a₃ == a₄) → Square (p ∙ q) (p ∙ q ∙ r ∙ ! s) r s lemma idp idp idp s = disc-to-square (! (!-inv-l s)) into-out-s : ∀ σs → into (out (winr (winl σs))) == winr (winl σs) into-out-s = susp-smash-path-elim _ _ wglue (wglue ∙ ap (winr ∘ winl) (merid _ (cfbase _))) (λ {(x , y) → (ap-∘ into (out ∘ winr ∘ winl) (merid _ (cfcod _ (x , y))) ∙ ap (ap into) (OutSmash.glue-β (cfcod _ (x , y))) ∙ lemma₁ into (Into.glue-β (snd X , snd Y) ∙ into-glue-0) (Into.glue-β (x , snd Y) ∙ into-glue-x x) (Into.glue-β (x , y)) (Into.glue-β (snd X , y) ∙ into-glue-y y)) ∙v⊡ lemma₂ wglue (ap winr wglue) (ap winl (σloop X x)) (ap (winr ∘ winl) (σloop (⊙Smash X Y) (cfcod _ (x , y)))) (ap (winr ∘ winr) (σloop Y y)) (ap (winr ∘ winl) (merid _ (cfcod _ (x , y)))) (ap (winr ∘ winl) (merid _ (cfbase _))) (ap-∙ (winr ∘ winl) (merid _ (cfcod _ (x , y))) (! (merid _ (cfbase _))) ∙ ap (λ p → ap (winr ∘ winl) (merid _ (cfcod _ (x , y))) ∙ p) (ap-! (winr ∘ winl) (merid _ (cfbase _))))}) where {- Let's not do these by hand -} lemma₁ : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {a₀ a₁ a₂ a₃ a₄ : A} {p : a₀ == a₁} {q : a₂ == a₁} {r : a₂ == a₃} {s : a₄ == a₃} {p' : f a₀ == f a₁} {q' : f a₂ == f a₁} {r' : f a₂ == f a₃} {s' : f a₄ == f a₃} (α : ap f p == p') (β : ap f q == q') (γ : ap f r == r') (δ : ap f s == s') → ap f (p ∙ ! q ∙ r ∙ ! s) == p' ∙ ! q' ∙ r' ∙ ! s' lemma₁ f {p = idp} {q = idp} {r = idp} {s = idp} idp idp idp idp = idp lemma₂ : ∀ {i} {A : Type i} {a₀ a₁ a₂ a₃ a₄ a₅ : A} (p : a₀ == a₁) (q : a₁ == a₂) (r : a₃ == a₀) (s : a₁ == a₁) (t : a₂ == a₄) (u : a₁ == a₅) (v : a₁ == a₅) → s == u ∙ ! v → Square p ((p ∙ q) ∙ ! (r ∙ p ∙ q) ∙ (r ∙ p ∙ s ∙ q ∙ t) ∙ ! (p ∙ q ∙ t)) u (p ∙ v) lemma₂ idp idp idp ._ idp idp v idp = disc-to-square $ ! (ap (λ w → w ∙ v) (∙-unit-r _ ∙ ∙-unit-r (! v)) ∙ !-inv-l v) into-out-winr : ∀ r → into (out (winr r)) == winr r into-out-winr = Wedge-elim into-out-s into-out-y (↓-='-from-square $ (ap-∘ into (out ∘ winr) wglue ∙ ap (ap into) OutWinr.glue-β) ∙v⊡ disc-to-square idp) into-out : ∀ w → into (out w) == w into-out = Wedge-elim into-out-x into-out-winr (↓-∘=idf-from-square into out $ ap (ap into) Out.glue-β ∙v⊡ connection) out-into-merid : (s : fst (X ⊙× Y)) → idp == merid _ (snd X , snd Y) [ (λ σ → out (into σ) == σ) ↓ merid _ s ] out-into-merid (x , y) = ↓-∘=idf-from-square out into $ (ap (ap out) (Into.glue-β (x , y)) ∙ lemma₁ out (∘-ap out winl (σloop X x) ∙ ap-∙ (out ∘ winl) (merid _ x) (! (merid _ (snd X))) ∙ SuspFmap.glue-β (λ x → (x , snd Y)) x ∙2 (ap-! (out ∘ winl) (merid _ (snd X)) ∙ ap ! (SuspFmap.glue-β (λ x → (x , snd Y)) (snd X)))) Out.glue-β (∘-ap out (winr ∘ winl) (σloop _ (cfcod _ (x , y))) ∙ ap-∙ OutSmash.f (merid _ (cfcod _ (x , y))) (! (merid _ (cfbase _))) ∙ OutSmash.glue-β (cfcod _ (x , y)) ∙2 (ap-! OutSmash.f (merid _ (cfbase _)) ∙ ap ! (OutSmash.glue-β (cfbase _)))) (∘-ap out winr wglue ∙ OutWinr.glue-β) (∘-ap out (winr ∘ winr) (σloop Y y) ∙ ap-∙ (out ∘ winr ∘ winr) (merid _ y) (! (merid _ (snd Y))) ∙ SuspFmap.glue-β (λ y → (snd X , y)) y ∙2 (ap-! (out ∘ winr ∘ winr) (merid _ (snd Y)) ∙ ap ! (SuspFmap.glue-β (λ y → (snd X , y)) (snd Y))))) ∙v⊡ lemma₂ (merid _ (x , snd Y)) (merid _ (snd X , snd Y)) (merid _ (x , y)) (merid _ (snd X , y)) (merid _ (snd X , snd Y)) where lemma₁ : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {a₀ a₁ a₂ a₃ a₄ a₅ : A} {p : a₀ == a₁} {q : a₁ == a₂} {r : a₂ == a₃} {s : a₃ == a₄} {t : a₄ == a₅} {p' : f a₀ == f a₁} {q' : f a₁ == f a₂} {r' : f a₂ == f a₃} {s' : f a₃ == f a₄} {t' : f a₄ == f a₅} (α : ap f p == p') (β : ap f q == q') (γ : ap f r == r') (δ : ap f s == s') (ε : ap f t == t') → ap f (p ∙ q ∙ r ∙ s ∙ t) == p' ∙ q' ∙ r' ∙ s' ∙ t' lemma₁ f {p = idp} {q = idp} {r = idp} {s = idp} {t = idp} idp idp idp idp idp = idp lemma₂ : ∀ {i} {A : Type i} {a₀ a₁ a₂ a₃ a₄ a₅ : A} (p : a₀ == a₁) (q : a₂ == a₁) (r : a₀ == a₃) (s : a₄ == a₃) (t : a₅ == a₃) → Square idp ((p ∙ ! q) ∙ ((q ∙ ! p ∙ r ∙ ! s) ∙ idp) ∙ (s ∙ ! t)) r t lemma₂ idp idp idp idp idp = ids out-into : ∀ σ → out (into σ) == σ out-into = Suspension-elim _ idp (merid _ (snd X , snd Y)) out-into-merid abstract eq : fst (⊙Susp (X ⊙× Y)) ≃ fst (⊙Susp X ⊙∨ (⊙Susp (X ⊙∧ Y) ⊙∨ ⊙Susp Y)) eq = equiv into out into-out out-into ⊙path : ⊙Susp (X ⊙× Y) == ⊙Susp X ⊙∨ (⊙Susp (X ⊙∧ Y) ⊙∨ ⊙Susp Y) ⊙path = ⊙ua eq idp
{ "alphanum_fraction": 0.422548466, "avg_line_length": 39.5018587361, "ext": "agda", "hexsha": "a2fe040b83e432f0bb30b382ca7f2f085e1c5f81", "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": "homotopy/SuspProduct.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": "homotopy/SuspProduct.agda", "max_line_length": 80, "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": "homotopy/SuspProduct.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4584, "size": 10626 }
-- Adapted from an example reported by John Leon -- It seems that the change reported in the issue was caused by the -- commit 344296cf06cedd13736e50bb53e63217d9f19ecf. -- Using `C-c C-,` in the first goal, master and 2.4.2.5 have different -- behaviours. In master, the type of `a` is not normalised -- Goal: n ≡ n + zero -- ———————————————————————————————————————————————————————————— -- a : flip _≡_ (n + zero) n -- n : ℕ -- but in 2.4.2.5, the type of `a` is full normalised -- Goal: n ≡ n + zero -- ———————————————————————————————————————————————————————————— -- a : n ≡ n + 0 -- n : ℕ infix 4 _≡_ data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x cong : ∀ {A B : Set} (f : A → B) {x y} → x ≡ y → f x ≡ f y cong f refl = refl REL : Set → Set → Set₁ REL A B = A → B → Set flip : {A B : Set} {C : A → B → Set₁} → ((x : A) (y : B) → C x y) → ((y : B) (x : A) → C x y) flip f = λ y x → f x y infixr 4 _⇒_ _⇒_ : {A B : Set} → REL A B → REL A B → Set P ⇒ Q = ∀ {i j} → P i j → Q i j Sym : {A B : Set} → REL A B → REL B A → Set Sym P Q = P ⇒ flip Q Symmetric : {A : Set} → REL A A → Set Symmetric _∼_ = Sym _∼_ _∼_ sym : {A : Set} → Symmetric (_≡_ {A = A}) sym refl = refl data ℕ : Set where zero : ℕ suc : (n : ℕ) → ℕ infixl 6 _+_ _+_ : ℕ → ℕ → ℕ zero + m = m suc n + m = suc (n + m) n+0=n : (n : ℕ) → n + zero ≡ n n+0=n zero = refl n+0=n (suc n) = cong suc (n+0=n (n)) m+Sn : (m n : ℕ) → m + suc n ≡ suc (m + n) m+Sn zero n = refl m+Sn (suc m) n = cong suc (m+Sn m n) +comm : (m n : ℕ) → m + n ≡ n + m +comm zero n = let a = sym (n+0=n n) in {!!} +comm (suc m) n = let a = cong suc (+comm m n) b = sym (m+Sn n m) in {!!}
{ "alphanum_fraction": 0.468211527, "avg_line_length": 23.0547945205, "ext": "agda", "hexsha": "def55c08e107c886623f05820186bc7799d76f4a", "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/interaction/Issue1851.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/interaction/Issue1851.agda", "max_line_length": 71, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/interaction/Issue1851.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": 718, "size": 1683 }
{- Interactive Programming with Dependent Types Ulf Norell ICFP 2013, Boston -} module ICFP where open import ICFPPrelude data Type : Set where nat : Type _⇒_ : (a b : Type) → Type infixr 7 _⇒_ data Raw : Set where var : (n : Nat) → Raw app : (e₁ e₂ : Raw) → Raw lam : (a : Type) (e : Raw) → Raw data Cxt : Set where [] : Cxt _,_ : (Γ : Cxt) (a : Type) → Cxt data Var : Cxt → Type → Set where zero : ∀ {Γ a} → Var (Γ , a) a suc : ∀ {Γ a b} → Var Γ a → Var (Γ , b) a data Term : Cxt → Type → Set where var : ∀ {Γ a} → Var Γ a → Term Γ a app : ∀ {Γ a b} (u : Term Γ (a ⇒ b)) (v : Term Γ a) → Term Γ b lam : ∀ {Γ} a {b} (u : Term (Γ , a) b) → Term Γ (a ⇒ b) eraseVar : ∀ {Γ a} → Var Γ a → Nat eraseVar zero = zero eraseVar (suc x) = suc (eraseVar x) erase : ∀ {Γ a} → Term Γ a → Raw erase (var x) = var (eraseVar x) erase (app v v₁) = app (erase v) (erase v₁) erase (lam a v) = lam a (erase v) data _≠_ : Type → Type → Set where nat≠fun : ∀ {a b} → nat ≠ a ⇒ b fun≠nat : ∀ {a b} → a ⇒ b ≠ nat src≠ : ∀ {a a′ b c} → a ≠ a′ → a ⇒ b ≠ a′ ⇒ c tgt≠ : ∀ {a b c c′} → c ≠ c′ → a ⇒ c ≠ b ⇒ c′ sound : ∀ a → a ≠ a → ⊥ sound nat () sound (a ⇒ b) (src≠ x) = sound a x sound (a ⇒ b) (tgt≠ x) = sound b x infix 4 _≠_ _≟_ data _≟_ : Type → Type → Set where equal : ∀ {a} → a ≟ a not-equal : ∀ {a b} → a ≠ b → a ≟ b compareFun : ∀ {a b c d} → a ≟ b → c ≟ d → a ⇒ c ≟ b ⇒ d compareFun equal equal = equal compareFun equal (not-equal x) = not-equal (tgt≠ x) compareFun (not-equal x) q = not-equal (src≠ x) compare : ∀ a b → a ≟ b compare nat nat = equal compare nat (a ⇒ b) = not-equal nat≠fun compare (a ⇒ b) nat = not-equal fun≠nat compare (a ⇒ b) (a₁ ⇒ b₁) = compareFun (compare a a₁) (compare b b₁) data OutOfScope : Cxt → Nat → Set where oops : ∀ {n} → OutOfScope [] n suc : ∀ {Γ a n} → OutOfScope Γ n → OutOfScope (Γ , a) (suc n) data WellScoped? : Cxt → Nat → Set where yes : ∀ {Γ} a (x : Var Γ a) → WellScoped? Γ (eraseVar x) no : ∀ {Γ n} → OutOfScope Γ n → WellScoped? Γ n data TypeError : Cxt → Raw → Set where arg-mismatch : ∀ {a a′ Γ b} {u : Term Γ (a ⇒ b)} {u₁ : Term Γ a′} → a ≠ a′ → TypeError Γ (app (erase u) (erase u₁)) not-fun : ∀ {Γ} {u : Term Γ nat} {a₁} {u₁ : Term Γ a₁} → TypeError Γ (app (erase u) (erase u₁)) bad-arg : ∀ {Γ e₂ e₁} → TypeError Γ e₂ → TypeError Γ (app e₁ e₂) bad-fun : ∀ {Γ e₁ e₂} → TypeError Γ e₁ → TypeError Γ (app e₁ e₂) out-of-scope : ∀ {Γ n} → OutOfScope Γ n → TypeError Γ (var n) lam : ∀ {Γ e} a → TypeError (Γ , a) e → TypeError Γ (lam a e) data WellTyped? : Cxt → Raw → Set where yes : ∀ {Γ} a (u : Term Γ a) → WellTyped? Γ (erase u) no : ∀ {Γ e} (err : TypeError Γ e) → WellTyped? Γ e checkApp : ∀ {Γ e₁ e₂} → WellTyped? Γ e₁ → WellTyped? Γ e₂ → WellTyped? Γ (app e₁ e₂) checkApp (yes nat u) (yes a₁ u₁) = no not-fun checkApp (yes (a ⇒ b) u) (yes a′ u₁) with compare a a′ checkApp (yes (a ⇒ b) u) (yes .a u₁) | equal = yes b (app u u₁) checkApp (yes (a ⇒ b) u) (yes a′ u₁) | not-equal err = no (arg-mismatch err) checkApp (yes a u) (no err) = no (bad-arg err) checkApp (no err) (yes a u) = no (bad-fun err) checkApp (no err) (no err₁) = no (bad-arg err₁) lookupSuc : ∀ {Γ a n} → WellScoped? Γ n → WellScoped? (Γ , a) (suc n) lookupSuc (yes a₁ x) = yes a₁ (suc x) lookupSuc (no x) = no (suc x) lookupVar : ∀ Γ n → WellScoped? Γ n lookupVar [] n = no oops lookupVar (Γ , a) zero = yes a zero lookupVar (Γ , a) (suc n) = lookupSuc (lookupVar Γ n) checkVar : ∀ {Γ n} → WellScoped? Γ n → WellTyped? Γ (var n) checkVar (yes a x) = yes a (var x) checkVar (no x) = no (out-of-scope x) checkLam : ∀ {Γ e} a → WellTyped? (Γ , a) e → WellTyped? Γ (lam a e) checkLam a (yes a₁ u) = yes (a ⇒ a₁) (lam a u) checkLam a (no err) = no (lam a err) check : ∀ Γ e → WellTyped? Γ e check Γ (var n) = checkVar (lookupVar Γ n) check Γ (app e₁ e₂) = checkApp (check Γ e₁) (check Γ e₂) check Γ (lam a e) = checkLam a (check (Γ , a) e)
{ "alphanum_fraction": 0.5460152973, "avg_line_length": 30.9389312977, "ext": "agda", "hexsha": "5d4db149a686a11cded68740dc03c2e212201365", "lang": "Agda", "max_forks_count": 20, "max_forks_repo_forks_event_max_datetime": "2021-07-30T05:37:45.000Z", "max_forks_repo_forks_event_min_datetime": "2017-02-18T20:36:05.000Z", "max_forks_repo_head_hexsha": "6c7561bcc9877c6df9107f12f7e843f4e880189a", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "enlambdment/disco", "max_forks_repo_path": "explore/typecheck/ICFP.agda", "max_issues_count": 282, "max_issues_repo_head_hexsha": "6c7561bcc9877c6df9107f12f7e843f4e880189a", "max_issues_repo_issues_event_max_datetime": "2022-03-28T21:43:15.000Z", "max_issues_repo_issues_event_min_datetime": "2016-11-19T18:05:42.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "enlambdment/disco", "max_issues_repo_path": "explore/typecheck/ICFP.agda", "max_line_length": 76, "max_stars_count": 138, "max_stars_repo_head_hexsha": "6c7561bcc9877c6df9107f12f7e843f4e880189a", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "enlambdment/disco", "max_stars_repo_path": "explore/typecheck/ICFP.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-22T22:56:45.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-10T08:10:03.000Z", "num_tokens": 1693, "size": 4053 }
------------------------------------------------------------------------ -- INCREMENTAL λ-CALCULUS -- -- Simply-typed changes with the Nehemiah plugin. ------------------------------------------------------------------------ module Nehemiah.Change.Type where open import Nehemiah.Syntax.Type import Parametric.Change.Type Base as ChangeType ΔBase : ChangeType.Structure ΔBase base-int = base base-int ΔBase base-bag = base base-bag open ChangeType.Structure ΔBase public
{ "alphanum_fraction": 0.5504201681, "avg_line_length": 26.4444444444, "ext": "agda", "hexsha": "84d79480bde8a579c38d9d46d2143166380f7d62", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_path": "Nehemiah/Change/Type.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_path": "Nehemiah/Change/Type.agda", "max_line_length": 72, "max_stars_count": 10, "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_path": "Nehemiah/Change/Type.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "num_tokens": 91, "size": 476 }
module Class.Functor where open import Category.Functor using () renaming (RawFunctor to Functor) public open Functor {{...}} public
{ "alphanum_fraction": 0.762962963, "avg_line_length": 22.5, "ext": "agda", "hexsha": "577ec28f2c92044f77b32d467385ef9be88304c8", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_path": "stdlib-exts/Class/Functor.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_path": "stdlib-exts/Class/Functor.agda", "max_line_length": 77, "max_stars_count": 35, "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_path": "stdlib-exts/Class/Functor.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "num_tokens": 32, "size": 135 }
-- Andreas, 2019-06-18, LAIM 2019, issue #3855: -- Successful tests for the erasure (@0) modality. module _ where open import Agda.Builtin.Bool open import Agda.Builtin.Nat open import Agda.Builtin.Equality open import Agda.Builtin.Coinduction open import Common.IO module WhereInErasedDeclaration where @0 n : Nat n = 4711 @0 m : Nat m = n' where n' = n module ErasedDeclarationInWhere where F : (G : @0 Set → Set) (@0 A : Set) → Set F G A = G B where @0 B : Set B = A module FlatErasure where @0 resurrect-λ : (A : Set) (@0 x : A) → A resurrect-λ A = λ x → x @0 resurrect-λ-where : (A : Set) (@0 x : A) → A resurrect-λ-where A = λ where x → x @0 resurrect-app : (A : Set) (@0 x : A) → A resurrect-app A x = x module ErasedEquality where -- Should maybe not work --without-K -- should definitely not work in --cubical cast : ∀{A B : Set} → @0 A ≡ B → A → B cast refl x = x J : ∀{A : Set} {a : A} (P : (x : A) → a ≡ x → Set) {b : A} (@0 eq : a ≡ b) → P a refl → P b eq J P refl p = p module ParametersAreErased where test : (@0 A : Set) → A ≡ A test A = refl {x = _} -- TODO: A instead of _ module Records where record R (A : Set) : Set where field el : A Par : Set Par = A -- record module parameters are NOT erased, so, this should be accepted proj : (A : Set) → R A → A -- TODO: @0 A instead of A proj A r = R.el {A = _} r MyPar : (A : Set) → R A → Set MyPar A = R.Par {A = A} record RB (b : Bool) : Set where bPar : Bool bPar = b myBPar : (b : Bool) → RB b → Bool myBPar b r = RB.bPar {b = b} r module CoinductionWithErasure (A : Set) where data Stream : Set where cons : (x : A) (xs : ∞ Stream) → Stream @0 repeat : (@0 a : A) → Stream repeat a = cons a (♯ (repeat a)) main = putStrLn "Hello, world!"
{ "alphanum_fraction": 0.5718113612, "avg_line_length": 20.9662921348, "ext": "agda", "hexsha": "a19764406c331675c9e58b0335dbcfb8042fedb3", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "hborum/agda", "max_forks_repo_path": "test/Succeed/Erasure-succeed-Issue3855.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/Succeed/Erasure-succeed-Issue3855.agda", "max_line_length": 86, "max_stars_count": null, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Succeed/Erasure-succeed-Issue3855.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 682, "size": 1866 }
module PiQ.Interp where open import Data.Empty open import Data.Unit hiding (_≟_) open import Data.Sum open import Data.Product open import Data.Maybe open import Data.Nat hiding (_≟_) open import Data.List as L hiding (_∷_) open import Relation.Binary.Core open import Relation.Binary open import Relation.Nullary open import Relation.Binary.PropositionalEquality open import Function using (_∘_) open import PiQ.Syntax open import PiQ.Opsem open import PiQ.Eval {-# TERMINATING #-} mutual interp : {A B : 𝕌} → (A ↔ B) → Val A B → Maybe (Val B A) -- Forward interp unite₊l (inj₂ y ⃗) = just (y ⃗) interp uniti₊l (v ⃗) = just (inj₂ v ⃗) interp swap₊ (inj₁ x ⃗) = just (inj₂ x ⃗) interp swap₊ (inj₂ y ⃗) = just (inj₁ y ⃗) interp assocl₊ (inj₁ x ⃗) = just (inj₁ (inj₁ x) ⃗) interp assocl₊ (inj₂ (inj₁ y) ⃗) = just (inj₁ (inj₂ y) ⃗) interp assocl₊ (inj₂ (inj₂ z) ⃗) = just (inj₂ z ⃗) interp assocr₊ (inj₁ (inj₁ x) ⃗) = just (inj₁ x ⃗) interp assocr₊ (inj₁ (inj₂ y) ⃗) = just (inj₂ (inj₁ y) ⃗) interp assocr₊ (inj₂ z ⃗) = just (inj₂ (inj₂ z) ⃗) interp unite⋆l ((tt , v) ⃗) = just (v ⃗) interp uniti⋆l (v ⃗) = just ((tt , v) ⃗) interp swap⋆ ((x , y) ⃗) = just ((y , x) ⃗) interp assocl⋆ ((x , (y , z)) ⃗) = just (((x , y) , z) ⃗) interp assocr⋆ (((x , y) , z) ⃗) = just ((x , y , z) ⃗) interp dist ((inj₁ x , z) ⃗) = just (inj₁ (x , z) ⃗) interp dist ((inj₂ y , z) ⃗) = just (inj₂ (y , z) ⃗) interp factor (inj₁ (x , z) ⃗) = just ((inj₁ x , z) ⃗) interp factor (inj₂ (y , z) ⃗) = just ((inj₂ y , z) ⃗) interp id↔ (v ⃗) = just (v ⃗) interp (c₁ ⨾ c₂) (v ⃗) = interp c₁ (v ⃗) >>= λ {(v' ⃖) → just (v' ⃖) ; (v' ⃗) → c₁ ⨾[ v' ⃗]⨾ c₂} interp (c₁ ⊕ c₂) (inj₁ x ⃗) = interp c₁ (x ⃗) >>= λ {(x' ⃗) → just (inj₁ x' ⃗) ; (x' ⃖) → just (inj₁ x' ⃖)} interp (c₁ ⊕ c₂) (inj₂ y ⃗) = interp c₂ (y ⃗) >>= λ {(y' ⃗) → just (inj₂ y' ⃗) ; (y' ⃖) → just (inj₂ y' ⃖)} interp (c₁ ⊗ c₂) ((x , y) ⃗) = interp c₁ (x ⃗) >>= λ {(x' ⃖) → just ((x' , y) ⃖) ; (x' ⃗) → interp c₂ (y ⃗) >>= λ {(y' ⃗) → just ((x' , y') ⃗) ; (y' ⃖) → just ((x , y') ⃖)}} interp ε₊ (inj₁ v ⃗) = just (inj₂ (- v) ⃖) interp ε₊ (inj₂ (- v) ⃗) = just (inj₁ v ⃖) interp (ηₓ v) (tt ⃗) = just ((v , ↻) ⃗) interp (εₓ v) ((v' , ↻) ⃗) with v ≟ v' ... | yes _ = just (tt ⃗) ... | no _ = nothing -- Backward interp unite₊l (v ⃖) = just (inj₂ v ⃖) interp uniti₊l (inj₂ v ⃖) = just (v ⃖) interp swap₊ (inj₁ x ⃖) = just (inj₂ x ⃖) interp swap₊ (inj₂ y ⃖) = just (inj₁ y ⃖) interp assocl₊ (inj₁ (inj₁ x) ⃖) = just (inj₁ x ⃖) interp assocl₊ (inj₁ (inj₂ y) ⃖) = just (inj₂ (inj₁ y) ⃖) interp assocl₊ (inj₂ z ⃖) = just (inj₂ (inj₂ z) ⃖) interp assocr₊ (inj₁ x ⃖) = just (inj₁ (inj₁ x) ⃖) interp assocr₊ (inj₂ (inj₁ y) ⃖) = just (inj₁ (inj₂ y) ⃖) interp assocr₊ (inj₂ (inj₂ z) ⃖) = just (inj₂ z ⃖) interp unite⋆l (v ⃖) = just ((tt , v) ⃖) interp uniti⋆l ((tt , v) ⃖) = just (v ⃖) interp swap⋆ ((x , y) ⃖) = just ((y , x) ⃖) interp assocl⋆ (((x , y) , z) ⃖) = just ((x , (y , z)) ⃖) interp assocr⋆ ((x , (y , z)) ⃖) = just (((x , y) , z) ⃖) interp dist (inj₁ (x , z) ⃖) = just ((inj₁ x , z) ⃖) interp dist (inj₂ (y , z) ⃖) = just ((inj₂ y , z) ⃖) interp factor ((inj₁ x , z) ⃖) = just (inj₁ (x , z) ⃖) interp factor ((inj₂ y , z) ⃖) = just (inj₂ (y , z) ⃖) interp id↔ (v ⃖) = just (v ⃖) interp (c₁ ⨾ c₂) (v ⃖) = interp c₂ (v ⃖) >>= λ {(v' ⃗) → just (v' ⃗) ; (v' ⃖) → c₁ ⨾[ v' ⃖]⨾ c₂} interp (c₁ ⊕ c₂) (inj₁ x ⃖) = interp c₁ (x ⃖) >>= λ {(x' ⃖) → just (inj₁ x' ⃖) ; (x' ⃗) → just (inj₁ x' ⃗)} interp (c₁ ⊕ c₂) (inj₂ y ⃖) = interp c₂ (y ⃖) >>= λ {(y' ⃖) → just (inj₂ y' ⃖) ; (y' ⃗) → just (inj₂ y' ⃗)} interp (c₁ ⊗ c₂) ((x , y) ⃖) = interp c₂ (y ⃖) >>= λ {(y' ⃗) → just ((x , y') ⃗) ; (y' ⃖) → interp c₁ (x ⃖) >>= λ {(x' ⃖) → just ((x' , y') ⃖) ; (x' ⃗) → just ((x' , y) ⃗)}} interp η₊ (inj₁ v ⃖) = just (inj₂ (- v) ⃗) interp η₊ (inj₂ (- v) ⃖) = just (inj₁ v ⃗) interp (εₓ v) (tt ⃖) = just ((v , ↻) ⃖) interp (ηₓ v) ((v' , ↻) ⃖) with v ≟ v' ... | yes _ = just (tt ⃖) ... | no _ = nothing _⨾[_⃗]⨾_ : ∀ {A B C} → (A ↔ B) → ⟦ B ⟧ → (B ↔ C) → Maybe (Val C A) c₁ ⨾[ b ⃗]⨾ c₂ = interp c₂ (b ⃗) >>= λ {(c ⃗) → just (c ⃗) ; (b' ⃖) → c₁ ⨾[ b' ⃖]⨾ c₂} _⨾[_⃖]⨾_ : ∀ {A B C} → (A ↔ B) → ⟦ B ⟧ → (B ↔ C) → Maybe (Val C A) c₁ ⨾[ b ⃖]⨾ c₂ = interp c₁ (b ⃖) >>= λ {(a ⃖) → just (a ⃖) ; (b' ⃗) → c₁ ⨾[ b' ⃗]⨾ c₂}
{ "alphanum_fraction": 0.3874511264, "avg_line_length": 47.5309734513, "ext": "agda", "hexsha": "ca2bc2be07b7de04ed22b447c5aa4452e8823538", "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": "PiQ/Interp.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": "PiQ/Interp.agda", "max_line_length": 76, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "PiQ/Interp.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": 2519, "size": 5371 }
import cedille-options module interactive-cmds (options : cedille-options.options) where open import functions open import cedille-types open import conversion open import constants open import ctxt open import general-util open import spans options {Id} open import subst open import syntax-util open import type-util open import to-string options open import toplevel-state options {IO} open import untyped-spans options {Id} open import parser open import resugar open import rewriting open import rename open import classify options {Id} (λ _ → return triv) import spans options {IO} as io-spans open import datatype-util open import free-vars open import json private elab-typed-err : ∀ {ed} → ctxt → ⟦ ed ⟧' → ⟦ ed ⟧ × 𝔹 elab-typed-err {TERM} Γ t = map-snd spans-have-error $ map-fst fst $ id-out $ check-term Γ t nothing empty-spans elab-typed-err {TYPE} Γ T = map-snd spans-have-error $ map-fst fst $ id-out $ check-type Γ T nothing empty-spans elab-typed-err {KIND} Γ k = map-snd spans-have-error $ id-out $ check-kind Γ k empty-spans elab-typed : ∀ {ed} → ctxt → ⟦ ed ⟧' → ⟦ ed ⟧ elab-typed Γ = fst ∘ elab-typed-err Γ elab-untyped : ∀ {ed} → ctxt → ⟦ ed ⟧' → ⟦ ed ⟧ elab-untyped {TERM} Γ t = fst $ id-out $ untyped-term Γ t empty-spans elab-untyped {TYPE} Γ T = fst $ id-out $ untyped-type Γ T empty-spans elab-untyped {KIND} Γ k = fst $ id-out $ untyped-kind Γ k empty-spans elab-untyped-no-params : ∀ {ed} → ctxt → ⟦ ed ⟧' → ⟦ ed ⟧ elab-untyped-no-params Γ = elab-untyped (record Γ {qual = trie-map (map-snd λ _ → []) (ctxt.qual Γ)}) {- Parsing -} ll-ind : ∀ {X : exprd → Set} → X TERM → X TYPE → X KIND → (ll : exprd) → X ll ll-ind t T k TERM = t ll-ind t T k TYPE = T ll-ind t T k KIND = k ll-ind' : ∀ {X : Σ exprd ⟦_⟧ → Set} → (s : Σ exprd ⟦_⟧) → ((t : term) → X (TERM , t)) → ((T : type) → X (TYPE , T)) → ((k : kind) → X (KIND , k)) → X s ll-ind' (TERM , t) tf Tf kf = tf t ll-ind' (TYPE , T) tf Tf kf = Tf T ll-ind' (KIND , k) tf Tf kf = kf k ll-disambiguate : ctxt → ex-tm → maybe ex-tp ll-disambiguate Γ (ExVar pi x) = ctxt-lookup-type-var Γ x >>= λ _ → just (ExTpVar pi x) ll-disambiguate Γ (ExApp t NotErased t') = ll-disambiguate Γ t >>= λ T → just (ExTpAppt T t') ll-disambiguate Γ (ExAppTp t T') = ll-disambiguate Γ t >>= λ T → just (ExTpApp T T') ll-disambiguate Γ (ExLam pi ff pi' x (just atk) t) = ll-disambiguate (ctxt-tk-decl pi' x (case atk of λ {(ExTkt _) → Tkt (TpHole pi'); (ExTkk _) → Tkk KdStar}) Γ) t >>= λ T → just (ExTpLam pi pi' x atk T) ll-disambiguate Γ (ExParens pi t pi') = ll-disambiguate Γ t ll-disambiguate Γ (ExLet pi _ d t) = ll-disambiguate (Γ' d) t >>= λ T → just (ExTpLet pi d T) where Γ' : ex-def → ctxt Γ' (ExDefTerm pi' x T? t) = ctxt-term-def pi' localScope opacity-open x (just (Hole pi')) (TpHole pi') Γ Γ' (ExDefType pi' x k T) = ctxt-type-def pi' localScope opacity-open x (just (TpHole pi')) KdStar Γ ll-disambiguate Γ t = nothing parse-string : (ll : exprd) → string → maybe ⟦ ll ⟧' parse-string ll s = case ll-ind {λ ll → string → Either string ⟦ ll ⟧'} parseTerm parseType parseKind ll s of λ {(Left e) → nothing; (Right e) → just e} ttk = "term, type, or kind" parse-err-msg : (failed-to-parse : string) → (as-a : string) → string parse-err-msg failed-to-parse "" = "Failed to parse \\\\\"" ^ failed-to-parse ^ "\\\\\"" parse-err-msg failed-to-parse as-a = "Failed to parse \\\\\"" ^ failed-to-parse ^ "\\\\\" as a " ^ as-a infixr 7 _>>nothing_ _-_!_>>parse_ _!_>>error_ _>>nothing_ : ∀{ℓ}{A : Set ℓ} → maybe A → maybe A → maybe A (nothing >>nothing m₂) = m₂ (m₁ >>nothing m₂) = m₁ _-_!_>>parse_ : ∀{A B : Set} → (string → maybe A) → string → (error-msg : string) → (A → string ⊎ B) → string ⊎ B (f - s ! e >>parse f') = maybe-else (inj₁ (parse-err-msg s e)) f' (f s) _!_>>error_ : ∀{E A B : Set} → maybe A → E → (A → E ⊎ B) → E ⊎ B (just a ! e >>error f) = f a (nothing ! e >>error f) = inj₁ e parse-try : ∀ {X : Set} → ctxt → string → maybe (((ll : exprd) → ⟦ ll ⟧' → X) → X) parse-try Γ s = maybe-map (λ t f → maybe-else (f TERM t) (f TYPE) (ll-disambiguate Γ t)) (parse-string TERM s) >>nothing maybe-map (λ T f → f TYPE T) (parse-string TYPE s) >>nothing maybe-map (λ k f → f KIND k) (parse-string KIND s) string-to-𝔹 : string → maybe 𝔹 string-to-𝔹 "tt" = just tt string-to-𝔹 "ff" = just ff string-to-𝔹 _ = nothing parse-ll : string → maybe exprd parse-ll "term" = just TERM parse-ll "type" = just TYPE parse-ll "kind" = just KIND parse-ll _ = nothing {- Local Context -} record lci : Set where constructor mk-lci field ll : string; x : var; t : string; T : string; fn : string; pi : posinfo data 𝕃ₛ {ℓ} (A : Set ℓ) : Set ℓ where [_]ₛ : A → 𝕃ₛ A _::ₛ_ : A → 𝕃ₛ A → 𝕃ₛ A headₛ : ∀ {ℓ} {A : Set ℓ} → 𝕃ₛ A → A headₛ [ a ]ₛ = a headₛ (a ::ₛ as) = a 𝕃ₛ-to-𝕃 : ∀ {ℓ} {A : Set ℓ} → 𝕃ₛ A → 𝕃 A 𝕃ₛ-to-𝕃 [ a ]ₛ = [ a ] 𝕃ₛ-to-𝕃 (a ::ₛ as) = a :: 𝕃ₛ-to-𝕃 as merge-lcis-ctxt-tvs : ctxt → 𝕃 string → ctxt × 𝕃 tagged-val merge-lcis-ctxt-tvs c = foldl merge-lcis-ctxt' (c , []) ∘ (sort-lcis ∘ strings-to-lcis) where strings-to-lcis : 𝕃 string → 𝕃 lci strings-to-lcis ss = strings-to-lcis-h ss [] where strings-to-lcis-h : 𝕃 string → 𝕃 lci → 𝕃 lci strings-to-lcis-h (ll :: x :: t :: T :: fn :: pi :: tl) items = strings-to-lcis-h tl (mk-lci ll x t T fn pi :: items) strings-to-lcis-h _ items = items -- TODO: Local context information does not pass Δ information! -- When users are using BR-explorer to rewrite with the rec function, -- if they call it upon "μ' [SUBTERM] {...}", it won't work unless they say -- "μ'<rec/mu> [SUBTERM] {...}". decl-lci : posinfo → var → ctxt → ctxt decl-lci pi x Γ = record Γ { qual = trie-insert (ctxt.qual Γ) x (pi % x , []) } exprd-type-of : exprd → exprd exprd-type-of TERM = TYPE exprd-type-of _ = KIND merge-lci-ctxt : lci → ctxt × 𝕃 tagged-val → ctxt × 𝕃 tagged-val merge-lci-ctxt (mk-lci ll v t T fn pi) (Γ , tvs) = maybe-else (Γ , tvs) (map-snd (λ tv → tvs ++ [ tv ])) (parse-ll ll >>= λ ll → parse-string (exprd-type-of ll) T >>= h ll (parse-string ll t)) where h : (ll : exprd) → maybe ⟦ ll ⟧' → ⟦ exprd-type-of ll ⟧' → maybe (ctxt × tagged-val) h TERM (just t) T = let t = elab-untyped Γ t T = elab-typed Γ T in return2 (ctxt-term-def pi localScope opacity-open v (just t) T Γ) (binder-data Γ pi v (Tkt T) ff (just t) "0" "0") h TYPE (just T) k = let T = elab-untyped Γ T k = elab-typed Γ k in return2 (ctxt-type-def pi localScope opacity-open v (just T) k Γ) (binder-data Γ pi v (Tkk k) ff (just T) "0" "0") h TERM nothing T = let T = elab-typed Γ T in return2 (ctxt-term-decl pi v T Γ) (binder-data Γ pi v (Tkt T) ff nothing "0" "0") h TYPE nothing k = let k = elab-typed Γ k in return2 (ctxt-type-decl pi v k Γ) (binder-data Γ pi v (Tkk k) ff nothing "0" "0") h _ _ _ = nothing merge-lcis-ctxt' : 𝕃ₛ lci → ctxt × 𝕃 tagged-val → ctxt × 𝕃 tagged-val merge-lcis-ctxt' ls (Γ , tvs) = let ls' = 𝕃ₛ-to-𝕃 ls in foldr merge-lci-ctxt (foldr (λ l → decl-lci (lci.pi l) (lci.x l)) Γ ls' , tvs) ls' sort-eq : ∀ {ℓ} {A : Set ℓ} → (A → A → compare-t) → 𝕃 A → 𝕃 (𝕃ₛ A) sort-eq {_} {A} c = foldr insert [] where insert : A → 𝕃 (𝕃ₛ A) → 𝕃 (𝕃ₛ A) insert n [] = [ [ n ]ₛ ] insert n (a :: as) with c (headₛ a) n ...| compare-eq = n ::ₛ a :: as ...| compare-gt = [ n ]ₛ :: a :: as ...| compare-lt = a :: insert n as sort-lcis : 𝕃 lci → 𝕃 (𝕃ₛ lci) sort-lcis = sort-eq λ l₁ l₂ → compare (posinfo-to-ℕ $ lci.pi l₁) (posinfo-to-ℕ $ lci.pi l₂) {- sort-lcis = list-merge-sort.merge-sort lci λ l l' → posinfo-to-ℕ (lci.pi l) > posinfo-to-ℕ (lci.pi l') where import list-merge-sort -} merge-lcis-ctxt : ctxt → 𝕃 string → ctxt merge-lcis-ctxt Γ ls = fst $ merge-lcis-ctxt-tvs Γ ls get-local-ctxt-tvs : ctxt → (pos : ℕ) → (local-ctxt : 𝕃 string) → ctxt × 𝕃 tagged-val get-local-ctxt-tvs Γ pi = merge-lcis-ctxt-tvs (foldr (flip ctxt-clear-symbol ∘ fst) Γ (flip filter (trie-mappings (ctxt.i Γ)) λ {(x , ci , fn' , pi') → ctxt.fn Γ =string fn' && posinfo-to-ℕ pi' > pi})) get-local-ctxt : ctxt → (pos : ℕ) → (local-ctxt : 𝕃 string) → ctxt get-local-ctxt Γ pi ls = fst (get-local-ctxt-tvs Γ pi ls) {- Helpers -} step-reduce : ∀ {ed : exprd} → ctxt → ⟦ ed ⟧ → ⟦ ed ⟧ step-reduce Γ t = let t' = erase t in maybe-else t' id (step-reduceh Γ t') where step-reduceh : ∀ {ed : exprd} → ctxt → ⟦ ed ⟧ → maybe ⟦ ed ⟧ step-reduceh{TERM} Γ (Var x) = ctxt-lookup-term-var-def Γ x step-reduceh{TYPE} Γ (TpVar x) = ctxt-lookup-type-var-def Γ x step-reduceh{TERM} Γ (App (Lam ff x nothing t) t') = just (subst Γ t' x t) step-reduceh{TYPE} Γ (TpApp (TpLam x (Tkk _) T) (Ttp T')) = just (subst Γ T' x T) step-reduceh{TYPE} Γ (TpApp (TpLam x (Tkt _) T) (Ttm t)) = just (subst Γ t x T) step-reduceh{TERM} Γ (App t t') = step-reduceh Γ t >>= λ t → just (App t t') step-reduceh{TYPE} Γ (TpApp T tT) = step-reduceh Γ T >>= λ T → just (TpApp T tT) step-reduceh{TERM} Γ (Lam ff x nothing t) = step-reduceh (ctxt-var-decl x Γ) t >>= λ t → just (Lam ff x nothing t) step-reduceh{TYPE} Γ (TpLam x atk T) = step-reduceh (ctxt-var-decl x Γ) T >>= λ T → just (TpLam x atk T) step-reduceh{TERM} Γ (LetTm ff x T t' t) = just (subst Γ t' x t) step-reduceh{TERM} Γ t @ (Mu μ s Tₘ f~ ms) with decompose-var-headed s >>=c λ sₕ sₐs → env-lookup Γ sₕ ...| just (ctr-def _ _ _ _ _ , _) = just (hnf Γ unfold-head-no-defs t) ...| _ = step-reduceh Γ s >>= λ s → just (Mu μ s Tₘ f~ ms) step-reduceh Γ t = nothing parse-norm : erased? → string → maybe (∀ {ed : exprd} → ctxt → ⟦ ed ⟧ → ⟦ ed ⟧) parse-norm me "all" = just λ Γ → hnf Γ (record unfold-all {unfold-erase = me}) parse-norm me "head" = just λ Γ → hnf Γ (record unfold-head-elab {unfold-erase = me}) parse-norm me "once" = just λ Γ → step-reduce Γ ∘ erase parse-norm _ _ = nothing parse-norm-err = "normalization method (all, head, once)" {- Command Executors -} normalize-cmd : ctxt → (str ll pi norm : string) → 𝕃 string → string ⊎ tagged-val normalize-cmd Γ str ll pi norm ls = parse-ll - ll ! "language-level" >>parse λ ll' → string-to-ℕ - pi ! "natural number" >>parse λ sp → parse-norm tt - norm ! parse-norm-err >>parse λ norm → parse-string ll' - str ! ll >>parse λ t → let Γ' = get-local-ctxt Γ sp ls in inj₂ (to-string-tag "" Γ' (norm Γ' (elab-untyped Γ' t))) normalize-prompt : ctxt → (str norm : string) → 𝕃 string → string ⊎ tagged-val normalize-prompt Γ str norm ls = parse-norm tt - norm ! parse-norm-err >>parse λ norm → let Γ' = merge-lcis-ctxt Γ ls in parse-try Γ' - str ! ttk >>parse λ f → f λ ll t → inj₂ (to-string-tag "" Γ' (norm Γ' (elab-untyped Γ' t))) erase-cmd : ctxt → (str ll pi : string) → 𝕃 string → string ⊎ tagged-val erase-cmd Γ str ll pi ls = parse-ll - ll ! "language-level" >>parse λ ll' → string-to-ℕ - pi ! "natural number" >>parse λ sp → parse-string ll' - str ! ll >>parse λ t → let Γ' = get-local-ctxt Γ sp ls in inj₂ (to-string-tag "" Γ' (erase (elab-untyped Γ' t))) erase-prompt : ctxt → (str : string) → 𝕃 string → string ⊎ tagged-val erase-prompt Γ str ls = let Γ' = merge-lcis-ctxt Γ ls in parse-try Γ' - str ! ttk >>parse λ f → f λ ll t → inj₂ (to-string-tag "" Γ' (erase (elab-untyped Γ' t))) -- private -- cmds-to-escaped-string : cmds → strM -- cmds-to-escaped-string (c :: cs) = cmd-to-string c $ strAdd "\\n\\n" >>str cmds-to-escaped-string cs -- cmds-to-escaped-string [] = strEmpty -- data-cmd : ctxt → (encoding name ps is cs : string) → string ⊎ tagged-val -- data-cmd Γ encodingₛ x psₛ isₛ csₛ = -- string-to-𝔹 - encodingₛ ! "boolean" >>parse λ encoding → -- parse-string KIND - psₛ ! "kind" >>parse λ psₖ → -- parse-string KIND - isₛ ! "kind" >>parse λ isₖ → -- parse-string KIND - csₛ ! "kind" >>parse λ csₖ → -- let ps = map (λ {(Index x atk) → Decl posinfo-gen posinfo-gen Erased x atk posinfo-gen}) $ kind-to-indices Γ psₖ -- cs = map (λ {(Index x (Tkt T)) → Ctr posinfo-gen x T; (Index x (Tkk k)) → Ctr posinfo-gen x $ mtpvar "ErrorExpectedTypeNotKind"}) $ kind-to-indices empty-ctxt csₖ -- is = kind-to-indices (add-ctrs-to-ctxt cs $ add-params-to-ctxt ps Γ) isₖ -- picked-encoding = if encoding then mendler-encoding else mendler-simple-encoding -- defs = datatype-encoding.mk-defs picked-encoding Γ $ Data x ps is cs in -- inj₂ $ strRunTag "" Γ $ cmds-to-escaped-string $ fst defs -- pretty-cmd : filepath → filepath → IO string -- pretty-cmd src-fn dest-fn = -- readFiniteFile src-fn >>= λ src → -- case parseStart src of λ where -- (Left (Left p)) → return ("Lexical error at position " ^ p) -- (Left (Right p)) → return ("Parse error at position " ^ p) -- (Right file) → writeFile dest-fn "" >> writeRopeToFile dest-fn (to-string.strRun empty-ctxt (to-string.file-to-string file)) >> return "Finished" -- where import to-string (record options {pretty-print = tt}) as to-string {- Commands -} tv-to-json : string ⊎ tagged-val → json tv-to-json (inj₁ s) = json-object [ "error" , json-string s ] -- [[ "{\"error\":\"" ]] ⊹⊹ [[ s ]] ⊹⊹ [[ "\"}" ]] tv-to-json (inj₂ (_ , v , ts)) = tagged-vals-to-json [ "value" , v , ts ] interactive-cmd-h : ctxt → 𝕃 string → string ⊎ tagged-val interactive-cmd-h Γ ("normalize" :: input :: ll :: sp :: norm :: lc) = normalize-cmd Γ input ll sp norm lc interactive-cmd-h Γ ("erase" :: input :: ll :: sp :: lc) = erase-cmd Γ input ll sp lc interactive-cmd-h Γ ("normalizePrompt" :: input :: norm :: lc) = normalize-prompt Γ input norm lc interactive-cmd-h Γ ("erasePrompt" :: input :: lc) = erase-prompt Γ input lc -- interactive-cmd-h Γ ("data" :: encoding :: x :: ps :: is :: cs :: []) = -- data-cmd Γ encoding x ps is cs interactive-cmd-h Γ cs = inj₁ ("Unknown interactive cmd: " ^ 𝕃-to-string (λ s → s) ", " cs) record br-history : Set where inductive constructor mk-br-history field Γ : ctxt t : term Tₗₗ : exprd T : ⟦ Tₗₗ ⟧ Tᵤ : string f : term → 𝕃 (ctr × term) → term Γₗ : 𝕃 tagged-val undo : 𝕃 br-history redo : 𝕃 br-history data br-history2 : Set where br-node : br-history → 𝕃 (ctr × br-history2) → br-history2 br-get-h : br-history2 → br-history br-get-h (br-node h hs) = h br-lookup : 𝕃 ℕ → br-history2 → maybe br-history br-lookup xs h = maybe-map br-get-h $ foldl (λ x h? → h? >>= λ {(br-node h hs) → maybe-map snd $ head2 (nthTail x hs)}) (just h) xs {-# TERMINATING #-} br-cmd2 : ctxt → string → string → string → 𝕃 string → IO ⊤ br-cmd2 Γ Tₛ tₛ sp ls = (string-to-ℕ - sp ! "natural number" >>parse inj₂) >>parseIO λ sp → elim-pair (get-local-ctxt-tvs Γ sp ls) λ Γ Γₗ → (parse-try Γ - Tₛ ! ttk >>parse inj₂) >>parseIO λ Tf → Tf λ Tₗₗ T → (parse-string TERM - tₛ ! "term" >>parse inj₂) >>parseIO λ t → let T = elab-untyped Γ T Tₑ = erase T t = elab-typed Γ t in -- TODO: Probably should switch back to ex-tm so if this doesn't currently check it won't elaborate to a hole! putJson (tv-to-json $ inj₂ $ ts-tag Γ Tₑ) >> await (br-node (mk-br-history Γ t Tₗₗ T (rope-to-string $ ts2.to-string Γ Tₑ) const Γₗ [] []) []) where import to-string (record options {erase-types = ff}) as ts2 import to-string (record options {erase-types = ff; pretty-print = tt}) as pretty2s ts-tag : ∀ {ed} → ctxt → ⟦ ed ⟧ → tagged-val ts-tag = ts2.to-string-tag "" infixr 6 _>>parseIO_ _>>parseIO_ : ∀ {A : Set} → string ⊎ A → (A → IO ⊤) → IO ⊤ inj₁ e >>parseIO f = putJson $ tv-to-json $ inj₁ e inj₂ a >>parseIO f = f a replace-substring : string → string → ℕ → ℕ → string × string replace-substring sₒ sᵣ fm to with string-to-𝕃char sₒ | string-to-𝕃char sᵣ ...| csₒ | csᵣ = 𝕃char-to-string (take fm csₒ ++ csᵣ ++ drop to csₒ) , 𝕃char-to-string (take (to ∸ fm) $ drop fm csₒ) replace : string → string → ℕ → ℕ → string replace sₒ sᵣ fm to = fst $ replace-substring sₒ sᵣ fm to substring : string → ℕ → ℕ → string substring s fm to = snd $ replace-substring s "" fm to escape-rope : rope → rope escape-rope [[ s ]] = [[ escape-string s ]] escape-rope (r₁ ⊹⊹ r₂) = escape-rope r₁ ⊹⊹ escape-rope r₂ parse-path : string → maybe (𝕃 ℕ) parse-path "" = just [] parse-path s with string-split s ' ' | foldr (λ n ns → ns >>= λ ns → string-to-ℕ n >>= λ n → just (n :: ns)) (just []) ...| "" :: ss | f = f ss ...| path | f = f path write-history : 𝕃 ℕ → br-history → br-history2 → br-history2 write-history [] h (br-node _ hs) = br-node h hs write-history (n :: ns) h (br-node hₒ hs) = br-node hₒ $ writeh n hs where writeh : ℕ → 𝕃 (ctr × br-history2) → 𝕃 (ctr × br-history2) writeh _ [] = [] writeh zero ((c , h') :: hs) = (c , write-history ns h h') :: hs writeh (suc n) (h' :: hs) = h' :: writeh n hs write-children : 𝕃 ℕ → 𝕃 (ctr × br-history) → br-history2 → br-history2 write-children [] hs (br-node h _) = br-node h (map (uncurry λ c h → c , br-node h []) hs) write-children (n :: ns) hs (br-node h hsₒ) = br-node h $ writeh n hsₒ where writeh : ℕ → 𝕃 (ctr × br-history2) → 𝕃 (ctr × br-history2) writeh _ [] = [] writeh zero ((c , h') :: hs') = (c , write-children ns hs h') :: hs' writeh (suc n) (h' :: hs) = h' :: writeh n hs outline : br-history2 → term -- outline (br-node (mk-br-history Γ t TYPE T Tₛ f Γₗ undo redo) []) = -- elim-pair (id-out $ check-term Γ t (just T) empty-spans) λ t~ ss → f t~ [] -- outline (br-node (mk-br-history Γ t Tₗₗ T Tₛ f Γₗ undo redo) []) = f (elab-untyped-no-params Γ t) [] -- outline (br-node (mk-br-history Γ t Tₗₗ T Tₛ f Γₗ undo redo) hs) = -- f (elab-typed Γ t) (map (uncurry λ c h → c , outline h) hs) outline (br-node (mk-br-history Γ t Tₗₗ T Tₛ f Γₗ undo redo) hs) = f t (map-snd outline <$> hs) make-case : ctxt → params → term → case-args × term make-case = h [] where h : params → ctxt → params → term → case-args × term h acc Γ (Param me x atk :: ps) (Lam me' x' oc' t') = h (Param me x' atk :: acc) (ctxt-var-decl x' Γ) (substh-params Γ (renamectxt-single x x') empty-trie ps) t' h acc Γ ps (Hole pi) = params-to-case-args (reverse acc ++ ps) , Hole pi h acc Γ ps t = params-to-case-args (reverse acc ++ ps) , params-to-apps ps t await : br-history2 → IO ⊤ awaith : br-history2 → 𝕃 string → IO ⊤ await his = getLine >>= λ input → let input = undo-escape-string input as = string-split input delimiter in awaith his as awaith his as = let put = putJson ∘ tv-to-json err = (_>> await his) ∘' put ∘' inj₁ in case as of λ where -- TODO: for these commands, do not add TYPES/KINDS of local decls to context, as they are probably just bound by foralls/pis/lambdas, not _really_ in scope! ("br" :: path :: as) → maybe-else' (parse-path path) (err ("Could not parse " ^ path ^ " as a list of space-delimited natural numbers")) λ path → let await-with = await ∘ flip (write-history path) his in maybe-else' (br-lookup path his) (err "Beta-reduction pointer does not exist") λ where this @ (mk-br-history Γ t Tₗₗ T Tᵤ f Γₗ undo redo) → case as of λ where ("undo" :: []) → case undo of λ where [] → err "No undo history" (u :: us) → put (inj₂ $ "" , [[ "Undo" ]] , []) >> await-with (record u {undo = us; redo = this :: redo}) --u (await Γ t Tₗₗ T Tᵤ f undo redo :: redo) ("redo" :: []) → case redo of λ where [] → err "No redo history" (r :: rs) → put (inj₂ $ "" , [[ "Redo" ]] , []) >> await-with (record r {undo = this :: undo; redo = rs}) --r ("get" :: []) → put (inj₂ $ "" , [[ Tᵤ ]] , []) >> await his ("parse" :: []) → (_>> await his) $ maybe-else' (parse-string Tₗₗ Tᵤ) (putJson $ spans-to-json $ global-error "Parse error" nothing) λ T → putJson $ spans-to-json $ snd $ id-out $ ll-ind {λ ll → ctxt → ⟦ ll ⟧' → spanM ⟦ ll ⟧} untyped-term untyped-type untyped-kind Tₗₗ (record Γ { fn = "missing" }) T empty-spans ("context" :: []) → putJson (json-object [ "value" , json-array [ tagged-vals-to-json Γₗ ] ]) >> await his ("check" :: t?) → let await-set = maybe-else (await his) λ t → await-with $ record this {t = t; undo = this :: undo; redo = []} in (λ e → either-else' e (uncurry λ t? e → put (inj₁ e) >> await-set t?) (uncurry λ t? m → put (inj₂ $ "value" , [[ m ]] , []) >> await-set t?)) $ ll-ind' {λ T → (maybe term × string) ⊎ (maybe term × string)} (Tₗₗ , T) (λ _ → inj₁ $ nothing , "Expression must be a type, not a term!") (λ T → (case t? of λ where [] → inj₂ nothing (t :: []) → maybe-else' (parse-string TERM t) (inj₁ $ nothing , parse-err-msg t "term") (inj₂ ∘ just) _ → inj₁ $ nothing , "To many arguments given to beta-reduction command 'check'") >>= λ t? → elim-pair (maybe-else' t? (elim-pair (id-out (check-term (qualified-ctxt Γ) (resugar t) (just T) empty-spans)) λ t~ ss → nothing , spans-have-error ss) λ t → elim-pair (id-out (check-term Γ t (just T) empty-spans)) λ t~ ss → just t~ , spans-have-error ss) λ t~? e? → let fail = inj₁ (just (maybe-else' t~? t id) , "Type error") try-β = elim-pair (id-out (check-term Γ (ExBeta pi-gen nothing nothing) (just T) empty-spans)) λ β~ ss → if spans-have-error ss then inj₁ (nothing , "Type error") else inj₂ (just β~ , "Equal by beta") in if e? then if isJust t? then fail else try-β else inj₂ (t~? , "Type inhabited")) (λ _ → inj₁ $ nothing , "Expression must be a type, not a kind!") ("rewrite" :: fm :: to :: eq :: ρ+? :: lc) → let Γ' = merge-lcis-ctxt Γ lc in either-else' (parse-string TERM - eq ! "term" >>parse λ eqₒ → string-to-𝔹 - ρ+? ! "boolean" >>parse λ ρ+? → string-to-ℕ - fm ! "natural number" >>parse λ fm → string-to-ℕ - to ! "natural number" >>parse λ to → parse-try Γ' - substring Tᵤ fm to ! ttk >>parse λ Tf → Tf λ ll Tₗ → elim-pair (id-out (check-term Γ' eqₒ nothing empty-spans)) $ uncurry λ eq Tₑ ss → is-eq-tp? Tₑ ! "Synthesized a non-equational type from the proof" >>error uncurry λ t₁ t₂ → err⊎-guard (spans-have-error ss) "Proof does not type check" >> let Tₑ = TpEq t₁ t₂ x = fresh-var Γ' "x" Tₗ = elab-untyped-no-params Γ' Tₗ in elim-pair (map-snd snd $ rewrite-exprd Tₗ Γ' ρ+? nothing (just eq) t₁ x 0) λ Tᵣ n → err⊎-guard (iszero n) "No rewrites could be performed" >> parse-string Tₗₗ - replace Tᵤ (rope-to-string $ [[ "(" ]] ⊹⊹ ts2.to-string Γ' Tᵣ ⊹⊹ [[ ")" ]]) fm to ! ll-ind "term" "type" "kind" Tₗₗ >>parse λ Tᵤ → let Tᵤ = elab-untyped-no-params (ctxt-var-decl x Γ) Tᵤ in ll-ind' {λ {(ll , T) → ⟦ ll ⟧ → string ⊎ ⟦ ll ⟧ × (term → term)}} (Tₗₗ , Tᵤ) (λ t T → inj₂ $ rewrite-mk-phi x eq T (subst Γ t₂ x t) , id) (λ Tᵤ _ → inj₂ $ post-rewrite (ctxt-var-decl x Γ) x eq t₂ Tᵤ , Rho eq x Tᵤ) (λ k _ → inj₂ $ subst Γ t₂ x k , id) T) err $ uncurry λ T' fₜ → put (inj₂ $ ts-tag Γ $ erase T') >> await-with (record this {T = T'; Tᵤ = rope-to-string $ ts2.to-string Γ $ erase T'; f = f ∘ fₜ; undo = this :: undo; redo = []}) ("normalize" :: fm :: to :: norm :: lc) → either-else' (let Γ' = merge-lcis-ctxt Γ lc in string-to-ℕ - fm ! "natural number" >>parse λ fm → string-to-ℕ - to ! "natural number" >>parse λ to → let tₛ = substring Tᵤ fm to in parse-try Γ' - tₛ ! ttk >>parse λ t → t λ ll t → parse-norm ff - norm ! parse-norm-err >>parse λ norm → let s = norm Γ' $ elab-untyped-no-params Γ' t rs = rope-to-string $ [[ "(" ]] ⊹⊹ ts2.to-string Γ' s ⊹⊹ [[ ")" ]] Tᵤ' = replace Tᵤ rs fm to in parse-string Tₗₗ - Tᵤ' ! ll-ind "term" "type" "kind" Tₗₗ >>parse λ Tᵤ' → let Tᵤ' = elab-untyped-no-params Γ' Tᵤ' in inj₂ Tᵤ') err λ Tᵤ' → put (inj₂ $ ts-tag Γ Tᵤ') >> await-with (record this {T = Tᵤ' {-Checks?-}; Tᵤ = rope-to-string $ ts2.to-string Γ $ erase Tᵤ'; undo = this :: undo; redo = []}) ("conv" :: ll :: fm :: to :: t' :: ls) → let Γ' = merge-lcis-ctxt Γ ls in either-else' (parse-ll - ll ! "language level" >>parse λ ll → string-to-ℕ - fm ! "natural number" >>parse λ fm → string-to-ℕ - to ! "natural number" >>parse λ to → let t = substring Tᵤ fm to in parse-string ll - t ! ll-ind "term" "type" "kind" ll >>parse λ t → parse-string ll - t' ! ll-ind "term" "type" "kind" ll >>parse λ t' → let t = elab-untyped-no-params Γ' t; t' = elab-untyped-no-params Γ' t' in err⊎-guard (~ ll-ind {λ ll → ctxt → ⟦ ll ⟧ → ⟦ ll ⟧ → 𝔹} conv-term conv-type conv-kind ll Γ' t t') "Inconvertible" >> let rs = [[ "(" ]] ⊹⊹ ts2.to-string Γ' (erase t') ⊹⊹ [[ ")" ]] Tᵤ = replace Tᵤ (rope-to-string rs) fm to in parse-string Tₗₗ - Tᵤ ! ll-ind "term" "type" "kind" Tₗₗ >>parse λ Tᵤ → inj₂ (elab-untyped-no-params Γ Tᵤ)) err λ Tᵤ' → put (inj₂ $ ts-tag Γ $ erase Tᵤ') >> await-with (record this {Tᵤ = rope-to-string $ ts2.to-string Γ $ erase Tᵤ'; undo = this :: undo; redo = []}) ("bind" :: xᵤ :: []) → let Γₚᵢ = ℕ-to-string (length Γₗ) in either-else' (ll-ind' {λ {(ll , _) → string ⊎ ctxt × erased? × tpkd × ⟦ ll ⟧ × (term → term)}} (Tₗₗ , T) (λ t' → let R = string ⊎ ctxt × erased? × tpkd × term × (term → term) in (case_of_ {B = (erased? → var → maybe tpkd → term → R) → R} (t' , hnf Γ unfold-head t') $ uncurry λ where (Lam me x oc body) _ f → f me x oc body _ (Lam me x oc body) f → f me x oc body _ _ _ → inj₁ "Not a term abstraction") λ me x oc body → inj₂ $ ctxt-var-decl-loc Γₚᵢ xᵤ Γ , me , maybe-else' oc (Tkt $ TpHole pi-gen) id , rename-var (ctxt-var-decl-loc Γₚᵢ xᵤ Γ) x xᵤ body , Lam me xᵤ oc) (λ T → Γ ⊢ T =β= λ where (TpAbs me x dom cod) → let Γ' = ctxt-tk-decl Γₚᵢ xᵤ dom Γ in inj₂ $ Γ' , me , dom , rename-var Γ' x (Γₚᵢ % xᵤ) cod , Lam me xᵤ (just dom) _ → inj₁ "Not a type abstraction") (λ k → inj₁ "Expression must be a term or a type")) err λ where (Γ' , me , dom , cod , fₜ) → let tv = binder-data Γ' Γₚᵢ xᵤ dom me nothing "0" "0" in -- putJson (json-object [ "value" , json-array (json-array (json-rope (fst (snd tv)) :: json-rope (to-string Γ' $ erase cod) :: []) :: []) ]) >> putJson (json-object [ "value" , json-array [ json-rope (to-string Γ' $ erase cod) ] ]) >> await-with (record this {Γ = Γ' ; T = cod; Tᵤ = rope-to-string $ ts2.to-string Γ' $ erase cod; f = f ∘ fₜ; Γₗ = Γₗ ++ [ tv ]; undo = this :: undo; redo = []}) ("case" :: scrutinee :: rec :: motive?) → -- TODO: Motive? let Γₚᵢ = ℕ-to-string (length Γₗ) in either-else' (parse-string TERM - scrutinee ! "term" >>parse λ scrutinee → elim-pair (id-out (check-term Γ scrutinee nothing empty-spans)) $ uncurry λ tₛ Tₛ ss → if (spans-have-error ss) then inj₁ "Error synthesizing a type from the input term" else let Tₛ = hnf Γ unfold-no-defs Tₛ in case decompose-ctr-type Γ Tₛ of λ where (TpVar Xₛ , [] , as) → ll-ind' {λ T → string ⊎ (term × term × 𝕃 (ctr × type) × type × ctxt × 𝕃 tagged-val × datatype-info)} (Tₗₗ , T) (λ t → inj₁ "Expression must be a type to case split") (λ T → maybe-else' (data-lookup Γ Xₛ as) (inj₁ "The synthesized type of the input term is not a datatype") λ d → let mk-data-info X _ asₚ asᵢ ps kᵢ k cs csₚₛ _ _ = d is' = kind-to-indices (add-params-to-ctxt ps Γ) kᵢ is = drop-last 1 is' Tₘ = refine-motive Γ is' (asᵢ ++ [ Ttm tₛ ]) T sM' = ctxt-mu-decls Γ tₛ is Tₘ d Γₚᵢ "0" "0" rec σ = λ y → inst-ctrs Γ ps asₚ (map-snd (rename-var {TYPE} Γ X y) <$> cs) sM = if rec =string "" then (σ X , const spanMok , Γ , [] , empty-renamectxt , (λ Γ t T → t) , (λ Γ T k → T)) else (σ (Γₚᵢ % mu-Type/ rec) , sM') mu = sigma-build-evidence Xₛ d in case sM of λ where (σ-cs , _ , Γ' , ts , ρ , tf , Tf) → if spans-have-error (snd $ id-out $ check-type (qualified-ctxt Γ) (resugar Tₘ) (just kᵢ) empty-spans) then inj₁ "Computed an ill-typed motive" else inj₂ ( tₛ , mu , map (λ {(Ctr x T) → let T' = hnf Γ' unfold-head-elab T in Ctr x T , (case decompose-ctr-type Γ' T' of λ {(Tₕ , ps' , as) → params-to-alls ps' $ hnf Γ' unfold-head-no-defs (TpApp (recompose-tpapps (drop (length ps) as) Tₘ) (Ttm (recompose-apps (params-to-args ps') $ recompose-apps asₚ (Var x))))})}) σ-cs , Tₘ , Γ' , ts , d)) (λ k → inj₁ "Expression must be a type to case split") (Tₕ , [] , as) → inj₁ "Synthesized a non-datatype from the input term" (Tₕ , ps , as) → inj₁ "Case splitting is currently restricted to datatypes") err $ λ where (scrutinee , mu , cs , Tₘ , Γ , ts , d) → let json = json-object [ "value" , json-array [ json-object (map (λ {(Ctr x _ , T) → unqual-all (ctxt.qual Γ) x , json-rope (to-string Γ (erase T))}) cs) ] ] in -- ) ] ] in putJson json >> let shallow = iszero (string-length rec) mk-cs = map λ where (Ctr x T , t) → let T' = hnf Γ unfold-head-elab T in case decompose-ctr-type Γ T' of λ where (Tₕ , ps , as) → elim-pair (make-case Γ ps t) λ cas t → Case x cas t [] f'' = λ t cs → (if shallow then Mu rec else Sigma (just mu)) t (just Tₘ) d (mk-cs cs) f' = λ t cs → f (f'' t cs) cs mk-hs = map $ map-snd λ T'' → mk-br-history Γ t TYPE T'' (rope-to-string $ to-string Γ $ erase T'') (λ t cs → t) (Γₗ ++ ts) [] [] in await (write-children path (mk-hs cs) $ write-history path (record this {f = f'; Γ = Γ; t = scrutinee; Γₗ = Γₗ ++ ts;-- TODO: Should we really do this? undo = this :: undo; redo = []}) his) ("print" :: tab :: []) → either-else' (string-to-ℕ - tab ! "natural number" >>parse inj₂) err λ tab → putRopeLn (escape-rope (json-to-rope (tv-to-json (inj₂ $ pretty2s.strRunTag "" Γ $ pretty2s.strNest (suc {-left paren-} tab) (pretty2s.to-stringh $ outline his))))) >> await his ("quit" :: []) → put $ inj₂ $ strRunTag "" Γ $ strAdd "Quitting beta-reduction mode..." _ → err $ foldl (λ a s → s ^ char-to-string delimiter ^ a) "Unknown beta-reduction command: " as _ → err "A beta-reduction buffer is still open" interactive-cmd : 𝕃 string → toplevel-state → IO ⊤ interactive-cmd ("br2" :: T :: t :: sp :: lc) ts = br-cmd2 (toplevel-state.Γ ts) T t sp lc --interactive-cmd ("pretty" :: src :: dest :: []) ts = pretty-cmd src dest >>= putStrLn interactive-cmd ls ts = putRopeLn (json-to-rope (tv-to-json (interactive-cmd-h (toplevel-state.Γ ts) ls))) interactive-not-br-cmd-msg = tv-to-json $ inj₁ "Beta-reduction mode has been terminated"
{ "alphanum_fraction": 0.4951240282, "avg_line_length": 50.0729023384, "ext": "agda", "hexsha": "aba190da8c349bf0e1574380f16defa3f1070dab", "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": "bf62d3d338809a30bc21a1affed07936b1ac60ac", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ice1k/cedille", "max_forks_repo_path": "src/interactive-cmds.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bf62d3d338809a30bc21a1affed07936b1ac60ac", "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": "ice1k/cedille", "max_issues_repo_path": "src/interactive-cmds.agda", "max_line_length": 227, "max_stars_count": null, "max_stars_repo_head_hexsha": "bf62d3d338809a30bc21a1affed07936b1ac60ac", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ice1k/cedille", "max_stars_repo_path": "src/interactive-cmds.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 11610, "size": 36403 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use -- Data.List.Relation.Binary.Permutation.Propositional directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Relation.Binary.Permutation.Inductive where {-# WARNING_ON_IMPORT "Data.List.Relation.Binary.Permutation.Inductive was deprecated in v1.1. Use Data.List.Relation.Binary.Permutation.Propositional instead." #-} open import Data.List.Relation.Binary.Permutation.Propositional public
{ "alphanum_fraction": 0.6032258065, "avg_line_length": 34.4444444444, "ext": "agda", "hexsha": "2d559b8973be856e207a3fad708eba4470e85abe", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Permutation/Inductive.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Permutation/Inductive.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Permutation/Inductive.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": 115, "size": 620 }
open import Agda.Primitive open import Agda.Builtin.Equality renaming (_≡_ to _==_) --(( If I want to rename the built-in equality )) module AlgebraFormalization where -- Here is an attempt to translate (part of) the Coq formalization. I did not translate the definition of the free algebra, the proof, and the part concerning the groups yet. I hope I did not do too weird things with the levels. -- ** Formalization of single-sorted algebraic theories ** -- Function extensionality postulate funext : ∀ {X : Set} {Y : X → Set} {f g : ∀ (x : X) → (Y x)} → (∀ (x : X) → ((f x) == (g x))) → (f == g) -- Operation Signature record OpSignature {l : Level} : Set (lsuc l) where field operation : Set l arity : operation → Set l -- I used the things with the levels of the hierachy of types because Agda was unhappy with what I was doing (and I did not want to define it only with Set₀ and Set₁ beacause I wanted to avoid weird things if we then want to define an OpSignature with an operation OpSignature) -- Here is a attempt (partial for the moment) to add context and terms, based on the same principles as in the file "ManySortedAlgebra.agda" -- Contexts record Context {l : Level} (Σ : OpSignature {l}) : Set (lsuc l) where field var : Set l open Context -- Terms on an operation signature data Term {l : Level} {Σ : OpSignature {l}} (Γ : Context Σ) : Set l where tm-var : ∀ (x : var Γ) → Term Γ tm-op : ∀ (f : OpSignature.operation Σ) → (OpSignature.arity Σ f → Term Γ) → Term Γ substitution : ∀ {l : Level} {Σ : OpSignature {l}} (Γ Δ : Context Σ) → Set l substitution Γ Δ = ∀ (x : var Γ) → Term Δ -- the action of a substitution on a term _·_ : ∀ {l : Level} {Σ : OpSignature {l}} {Γ Δ : Context Σ} → substitution Γ Δ → Term Γ → Term Δ σ · (tm-var x) = σ x σ · (tm-op f x) = tm-op f (λ i → σ · x i) infixr 6 _·_ -- composition of substitutions _○_ : ∀ {l : Level} {Σ : OpSignature {l}} {Γ Δ Θ : Context Σ} → substitution Δ Θ → substitution Γ Δ → substitution Γ Θ (σ ○ τ) x = σ · τ x infixl 7 _○_ -- End of the attempt -- Operation Algebra record OpAlgebra {l : Level} (S : OpSignature {l}) : Set (lsuc l) where field carrier : Set l op : ∀ (o : OpSignature.operation S) (f : OpSignature.arity S o → carrier) → carrier -- Homomorphisms record Hom {l : Level} {S : OpSignature {l}} (A : OpAlgebra {l} S) (B : OpAlgebra {l} S) : Set (lsuc l) where field map : (OpAlgebra.carrier A) → (OpAlgebra.carrier B) op-commute : ∀ (o : OpSignature.operation S) (args : OpSignature.arity S o → OpAlgebra.carrier A) → (map (OpAlgebra.op A o args) == OpAlgebra.op B o (λ x → map (args x) )) -- For the moment I skip the translation of the part concerning the free algebra -- Attempt to formalize the Equational theories diffenrently, based on what is done in the file "ManySortedAglebra.agda" -- Equational Theory (equations are seen as "in a context" and not with arities anymore) record EquationalTheory {l : Level} (Σ : OpSignature {l}) : Set (lsuc l) where field eq : Set l eq-ctx : ∀ (ε : eq) → Context {l} Σ eq-lhs : ∀ (ε : eq) → Term (eq-ctx ε) eq-rhs : ∀ (ε : eq) → Term (eq-ctx ε) open EquationalTheory -- Equality of terms infix 4 _≡_ data _≡_ {l : Level} {Σ : OpSignature {l}} {T : EquationalTheory {l} Σ } : {Γ : Context Σ} → Term Γ → Term Γ → Set (lsuc l) where -- general rules eq-refl : ∀ {Γ} {t : Term Γ } → t ≡ t eq-symm : ∀ {Γ} {s t : Term {l} {Σ} Γ } → _≡_ {T = T} s t → t ≡ s eq-tran : ∀ {Γ} {s t u : Term Γ } → _≡_ {T = T} s t → _≡_ {T = T} t u → s ≡ u -- congruence rule eq-congr : ∀ {Γ} {f : OpSignature.operation Σ} (x y : ∀ (i : OpSignature.arity Σ f) → Term Γ) → (∀ i → _≡_ {_} {_} {T} (x i) (y i)) → ((tm-op f x) ≡ (tm-op f y)) -- equational axiom eq-axiom : ∀ (ε : eq T) {Δ : Context {l} Σ} (σ : substitution (eq-ctx T ε) Δ) → ((σ · eq-lhs T ε) ≡ (σ · eq-rhs T ε)) -- composition is functorial subst-○ : ∀ {l : Level} {Σ : OpSignature {l}} {T : EquationalTheory Σ} {Γ Δ Θ : Context Σ} (σ : substitution Δ Θ) (τ : substitution Γ Δ) → ∀ (t : Term Γ ) → _≡_ {T = T} (σ · τ · t) (σ ○ τ · t) subst-○ σ τ (tm-var x) = eq-refl subst-○ σ τ (tm-op f x) = eq-congr (λ i → σ · τ · x i) (λ i → σ ○ τ · x i) λ i → subst-○ σ τ (x i) -- substitution preserves equality eq-subst : ∀ {l : Level} {Σ : OpSignature {l}} {T : EquationalTheory Σ} {Γ Δ : Context Σ} (σ : substitution Γ Δ) {s t : Term Γ} → _≡_ {T = T} s t → _≡_ {T = T} (σ · s) (σ · t) eq-subst σ eq-refl = eq-refl eq-subst σ (eq-symm ξ) = eq-symm (eq-subst σ ξ) eq-subst σ (eq-tran ζ ξ) = eq-tran (eq-subst σ ζ) (eq-subst σ ξ) eq-subst σ (eq-congr x y ξ) = eq-congr (λ i → σ · x i) (λ i → σ · y i) λ i → eq-subst σ (ξ i) eq-subst {T = T} σ (eq-axiom ε τ) = eq-tran (subst-○ σ τ (eq-lhs T ε)) (eq-tran (eq-axiom ε (σ ○ τ)) (eq-symm (subst-○ σ τ (eq-rhs T ε)))) -- End of the attempt -- Equation Signature record EqSignature {l : Level} (S : OpSignature {l}) : Set (lsuc l) where field eq : Set l eq-arity : eq → Set l -- the two sides of the equation lhs : ∀ {A : OpAlgebra {l} S} {e : eq} → ((eq-arity e) → (OpAlgebra.carrier A)) → (OpAlgebra.carrier A) rhs : ∀ {A : OpAlgebra {l} S} {e : eq} → ((eq-arity e) → (OpAlgebra.carrier A)) → (OpAlgebra.carrier A) -- naturality / commutation lhs-natural : ∀ (A B : OpAlgebra {l} S) (f : Hom A B) (e : eq) (args : eq-arity e → OpAlgebra.carrier A) → ( (Hom.map f) (lhs {A} {e} args) == lhs {B} {e} (λ i → (Hom.map f) (args i))) rhs-natural : ∀ (A B : OpAlgebra {l} S) (f : Hom A B) (e : eq) (args : eq-arity e → OpAlgebra.carrier A) → ( (Hom.map f) (rhs {A} {e} args) == rhs {B} {e} (λ i → (Hom.map f) (args i))) -- Algebra record Algebra {l : Level} (S : OpSignature {l}) (E : EqSignature {l} S) : Set (lsuc l) where field alg : OpAlgebra S equations : ∀ (e : EqSignature.eq E) (args : EqSignature.eq-arity E e → OpAlgebra.carrier alg) → (EqSignature.rhs E {alg} {e} args == EqSignature.lhs E {alg} {e} args) -- For the moment, I think that we did not talk about terms in contexts, did we ? Should we generalize the things we did in Lambda.agda (using De Bruijn indices for the variables) ? -> I tried things -- ** Other things ** -- Useful arities data nullary : Set where data unary : Set where only : unary data binary : Set where fst : binary snd : binary -- Definition of groups data GroupOperation : Set where one : GroupOperation mul : GroupOperation inv : GroupOperation GroupArity : (o : GroupOperation) → Set GroupArity one = nullary GroupArity mul = binary GroupArity inv = unary GroupOp : OpSignature GroupOp = record { operation = GroupOperation ; arity = GroupArity}
{ "alphanum_fraction": 0.5912869017, "avg_line_length": 37.7189189189, "ext": "agda", "hexsha": "072e502468e44918a54b125abf6d7354f620e59b", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z", "max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z", "max_forks_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/formaltt", "max_forks_repo_path": "src/Experimental/AlgebraFormalization.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejbauer/formaltt", "max_issues_repo_path": "src/Experimental/AlgebraFormalization.agda", "max_line_length": 279, "max_stars_count": 21, "max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cilinder/formaltt", "max_stars_repo_path": "src/Experimental/AlgebraFormalization.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-19T15:50:08.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-16T14:07:06.000Z", "num_tokens": 2471, "size": 6978 }
module 100-natural where open import 010-false-true open import 020-equivalence record Natural {N : Set} (zero : N) (suc : N -> N) (_==_ : N -> N -> Set) : Set1 where -- axioms field equiv : Equivalence _==_ sucn!=zero : ∀ {r} -> suc r == zero -> False sucinjective : ∀ {r s} -> suc r == suc s -> r == s cong : ∀ {r s} -> r == s -> suc r == suc s induction : (p : N -> Set) -> p zero -> (∀ n -> p n -> p (suc n)) -> (∀ n -> p n) open Equivalence equiv public
{ "alphanum_fraction": 0.5150300601, "avg_line_length": 22.6818181818, "ext": "agda", "hexsha": "5cd1349b216d6f83e1ce26ac5874b4f8768495f9", "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": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mcmtroffaes/agda-proofs", "max_forks_repo_path": "100-natural.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "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": "mcmtroffaes/agda-proofs", "max_issues_repo_path": "100-natural.agda", "max_line_length": 85, "max_stars_count": 2, "max_stars_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mcmtroffaes/agda-proofs", "max_stars_repo_path": "100-natural.agda", "max_stars_repo_stars_event_max_datetime": "2016-08-17T16:15:42.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-09T22:51:55.000Z", "num_tokens": 180, "size": 499 }
module Formalization.LambdaCalculus.Semantics.Reduction where import Lvl open import Data open import Formalization.LambdaCalculus open import Formalization.LambdaCalculus.SyntaxTransformation open import Numeral.Natural open import Numeral.Finite open import Relator.ReflexiveTransitiveClosure open import Syntax.Number open import Type private variable d d₁ d₂ : ℕ private variable f g x y : Term(d) -- β-reduction (beta) with its compatible closure over `Apply`. -- Reduces a term of form `f(x)` to `f[0 ≔ x]`. data _β⇴_ : Term(d₁) → Term(d₂) → Type{1} where β : {f : Term(𝐒(d))}{x : Term(d)} → (Apply(Abstract(f))(x) β⇴ substituteVar0(x)(f)) cong-applyₗ : (f β⇴ g) → (Apply f(x) β⇴ Apply g(x)) -- TODO: cong-applyₗ and cong-applyᵣ can be applied in any order, but many evaluation strategies have a fixed order. How should this be represented? cong-applyᵣ : (x β⇴ y) → (Apply f(x) β⇴ Apply f(y)) cong-abstract : (x β⇴ y) → (Abstract x β⇴ Abstract y) -- TODO: Sometimes this is not included, specifically for the call by value evaluation strategy? But it seems to be required for the encoding of ℕ? -- η-reduction (eta). (TODO: May require more introductions like β have) -- Reduces a term of form `x ↦ f(x)` to `f`. data _η⇴_ : Term(d₁) → Term(d₂) → Type{1} where η : (Abstract(Apply(f)(Var(maximum))) η⇴ f) -- Reduction of expressions (TODO: May require more introductions like β have) data _⇴_ : Term(d₁) → Term(d₂) → Type{1} where β : (Apply(Abstract(f))(x) ⇴ substituteVar0(x)(f)) η : (Abstract(Apply(f)(Var(maximum))) ⇴ f) _β⇴*_ : Term(d) → Term(d) → Type _β⇴*_ = ReflexiveTransitiveClosure(_β⇴_) _β⥈_ : Term(d) → Term(d) → Type _β⥈_ = SymmetricClosure(_β⇴_) _β⥈*_ : Term(d) → Term(d) → Type _β⥈*_ = ReflexiveTransitiveClosure(_β⥈_)
{ "alphanum_fraction": 0.6968325792, "avg_line_length": 42.0952380952, "ext": "agda", "hexsha": "cd714a7f756de2219e5b6de7b847d8af13d7ed54", "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": "Formalization/LambdaCalculus/Semantics/Reduction.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": "Formalization/LambdaCalculus/Semantics/Reduction.agda", "max_line_length": 203, "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": "Formalization/LambdaCalculus/Semantics/Reduction.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": 609, "size": 1768 }
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-} module Cubical.Data.Queue.Base where open import Cubical.Data.Queue.1List public open import Cubical.Data.Queue.Truncated2List public open import Cubical.Data.Queue.Untruncated2List public
{ "alphanum_fraction": 0.7945736434, "avg_line_length": 36.8571428571, "ext": "agda", "hexsha": "946da9559ae96d21272068e349bd63c76bc2dbad", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Data/Queue/Base.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Data/Queue/Base.agda", "max_line_length": 67, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Data/Queue/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 63, "size": 258 }
module dynamic where open import LSsyntax open import static open import Relation.Nullary open import Data.Nat using (ℕ ; _+_) open import Data.Fin using (Fin; toℕ) open import Data.Vec using (Vec ; lookup; _∷_; []) open import Data.Product open import Relation.Binary.PropositionalEquality open import Relation.Nullary open import Data.Bool using (Bool; true ; false) data _⊓ˡ_ : (ℓ₁ ℓ₂ : Label) → Set where ℓ⊓✭ : ∀ ℓ → ℓ ⊓ˡ ✭ ✭⊓ℓ : ∀ ℓ → ✭ ⊓ˡ ℓ idℓ : ∀ ℓ → ℓ ⊓ˡ ℓ _⊓ᵣ_ : ∀ (ℓ₁ ℓ₂ : Label) → Dec (ℓ₁ ⊓ˡ ℓ₂) ⊤ ⊓ᵣ ⊤ = yes (idℓ ⊤) ⊤ ⊓ᵣ ⊥ = no (λ ()) ⊤ ⊓ᵣ ✭ = yes (ℓ⊓✭ ⊤) ⊥ ⊓ᵣ ⊤ = no (λ ()) ⊥ ⊓ᵣ ⊥ = yes (idℓ ⊥) ⊥ ⊓ᵣ ✭ = yes (ℓ⊓✭ ⊥) ✭ ⊓ᵣ ⊤ = yes (✭⊓ℓ ⊤) ✭ ⊓ᵣ ⊥ = yes (✭⊓ℓ ⊥) ✭ ⊓ᵣ ✭ = yes (ℓ⊓✭ ✭) -- note that this is not actually correct. The meet of ⊤ and bottom for example should be undefined, -- but that isn't easy to model directly in Agda. However, if we only call this after induction over -- the proof of _⊓ᵣ_ it (should) be impossible to call one of the incorrect cases. recMeet : ∀ (ℓ₁ ℓ₂ : Label) → Label recMeet ⊤ ⊤ = ⊤ recMeet ⊤ ✭ = ⊤ recMeet ⊥ ⊥ = ⊥ recMeet ⊥ ✭ = ⊥ recMeet ✭ ⊤ = ⊤ recMeet ✭ ⊥ = ⊥ recMeet ✭ ✭ = ✭ recMeet _ _ = ✭ -- fake case _⊓_ : ∀ (t₁ t₂ : GType) → GType bool x ⊓ bool x₁ with x ⊓ᵣ x₁ bool x ⊓ bool x₁ | yes p = bool (recMeet x x₁) bool x ⊓ bool x₁ | no ¬p = err bool x ⊓ _ = err (t₁ ⇒ x) t₂ ⊓ (t₃ ⇒ x₁) t₄ with x ⊓ᵣ x₁ (t₁ ⇒ x) t₂ ⊓ (t₃ ⇒ x₁) t₄ | yes p with (t₁ ⊓ t₃) | (t₂ ⊓ t₄) (t₁ ⇒ x₂) t₂ ⊓ (t₃ ⇒ x₃) t₄ | yes p | (bool x) | (bool x₁) = ((bool x) ⇒ (recMeet x₂ x₃)) (bool x) -- this is probably not correct, but it keeps things simple. (t₁ ⇒ x₂) t₂ ⊓ (t₃ ⇒ x₃) t₄ | yes p | (bool x) | ((d ⇒ x₁) d₁) = err (t₁ ⇒ x₂) t₂ ⊓ (t₃ ⇒ x₃) t₄ | yes p | ((c ⇒ x) c₁) | (bool x₁) = err (t₁ ⇒ x₂) t₂ ⊓ (t₃ ⇒ x₃) t₄ | yes p | ((c ⇒ x) c₁) | ((d ⇒ x₁) d₁) = err (t₁ ⇒ x₁) t₂ ⊓ (t₃ ⇒ x₂) t₄ | yes p | (bool x) | err = err (t₁ ⇒ x₁) t₂ ⊓ (t₃ ⇒ x₂) t₄ | yes p | ((c ⇒ x) c₁) | err = err (t₁ ⇒ x₁) t₂ ⊓ (t₃ ⇒ x₂) t₄ | yes p | err | (bool x) = err (t₁ ⇒ x₁) t₂ ⊓ (t₃ ⇒ x₂) t₄ | yes p | err | ((d ⇒ x) d₁) = err (t₁ ⇒ x) t₂ ⊓ (t₃ ⇒ x₁) t₄ | yes p | err | err = err (t₁ ⇒ x) t₂ ⊓ (t₃ ⇒ x₁) t₄ | no ¬p = err _ ⊓ _ = err I≼ : ∀ (ℓ₁ ℓ₂ : Label) → (Label × Label) I≼ ⊤ ✭ = ⊤ , ⊤ I≼ ✭ ⊤ = ✭ , ⊤ I≼ ✭ ⊥ = ⊥ , ⊥ I≼ ⊥ ✭ = ⊥ , ✭ I≼ ℓ₁ ℓ₂ = ℓ₁ , ℓ₂ Δ≼ : ∀ (triple : Label × Label × Label) → (Label × Label) Δ≼ (ℓ₁ , ⊤ , ⊤) = ℓ₁ , ⊤ Δ≼ (ℓ₁ , ⊤ , ✭) = ℓ₁ , ⊤ Δ≼ (⊥ , ⊥ , ℓ₃) = ⊥ , ℓ₃ Δ≼ (⊥ , ✭ , ℓ₃) = ⊥ , ℓ₃ Δ≼ (ℓ₁ , ✭ , ℓ₃) = ℓ₁ , ℓ₃ Δ≼ (ℓ₁ , ℓ₂ , ℓ₃) = ℓ₁ , ℓ₃ Δ< : ∀ (triple : GType × GType × GType) → (GType × GType) Δ< (bool ℓ₁ , bool ℓ₂ , bool ℓ₃) = let new = Δ≼ (ℓ₁ , ℓ₂ , ℓ₃) in bool (proj₁ new) , bool (proj₂ new) Δ< ((t₁ ⇒ ℓ₁) t′₁ , (t₂ ⇒ ℓ₂) t′₂ , (t₃ ⇒ ℓ₃) t′₃) = let new = Δ≼ (ℓ₁ , ℓ₂ , ℓ₃) in ((t₁ ⇒ (proj₁ new)) t′₁) , ((t₃ ⇒ (proj₂ new)) t′₃) Δ< (_ , _ , _) = err , err interior : ∀ (t : GType) → (GType × GType) interior (bool ℓ) = (bool ℓ) , (bool ℓ) interior ((t ⇒ ℓ) t₁) = let (ℓ₁ , ℓ₂) = I≼ (getLabel t) ℓ in ((setLabel t ℓ₁) ⇒ ℓ₂) t₁ , ((setLabel t ℓ₁) ⇒ ℓ₂) t₁ interior err = err , err _∘<_ : ∀ (t₁ t₂ : (GType × GType)) → (GType × GType) (s₁ , s₂₁) ∘< (s₂₂ , s₃) = Δ< (s₁ , (s₂₁ ⊓ s₂₂) , s₃) dynamicCheck : ∀ {n} (Γ : Ctx n) (t : Term) → Check Γ t -- variables dynamicCheck {n} Γ (var v) with fromℕ n v dynamicCheck {n} Γ (var .(toℕ m)) | yes m = yes (lookup m Γ) (Sx m refl) dynamicCheck {n} Γ (var .(n + m)) | no m = no -- literals dynamicCheck Γ (litBool x ℓ) = yes (bool ℓ) (Sb x ℓ) -- lambda abstraction dynamicCheck Γ (lam x t x₁) with dynamicCheck (x ∷ Γ) t dynamicCheck Γ (lam x .(erase t) ℓ) | yes τ t = yes ((x ⇒ ℓ) τ) (Sλ x ℓ t) dynamicCheck Γ (lam x t x₁) | no = no -- logical and dynamicCheck Γ (t ∧ t₁) with dynamicCheck Γ t | dynamicCheck Γ t₁ dynamicCheck Γ (.(erase t) ∧ .(erase t₁)) | yes τ t | (yes τ₁ t₁) with (interior τ) ∘< (interior τ₁) dynamicCheck Γ (.(erase t) ∧ .(erase t₁)) | yes τ t | (yes τ₁ t₁) | (bool x , bool x₁) = yes (bool (getLabel τ ~⋎~ getLabel τ₁)) (t S∧ t₁) dynamicCheck Γ (.(erase t) ∧ .(erase t₁)) | yes τ t | (yes τ₁ t₁) | (_ , _) = no dynamicCheck Γ (t ∧ t₁) | _ | _ = no -- logical or dynamicCheck Γ (t ∨ t₁) with dynamicCheck Γ t | dynamicCheck Γ t₁ dynamicCheck Γ (.(erase t) ∨ .(erase t₁)) | yes τ t | (yes τ₁ t₁) with (interior τ) ∘< (interior τ₁) dynamicCheck Γ (.(erase t) ∨ .(erase t₁)) | yes τ t | (yes τ₁ t₁) | (bool x , bool x₁) = yes (bool (getLabel τ ~⋎~ getLabel τ₁)) (t S∨ t₁) dynamicCheck Γ (.(erase t) ∨ .(erase t₁)) | yes τ t | (yes τ₁ t₁) | (_ , _) = no dynamicCheck Γ (t ∨ t₁) | _ | _ = no -- application -- this needs to be doublechecked! dynamicCheck Γ (t ∙ t₁) with dynamicCheck Γ t | dynamicCheck Γ t₁ dynamicCheck Γ (.(erase t) ∙ .(erase t₁)) | yes ((τ ⇒ ℓ₁) τ₁) t | yes τ₂ t₁ with (interior ((τ ⇒ ℓ₁) τ₁)) ∘< (interior τ₂) dynamicCheck Γ (.(erase t) ∙ .(erase t₁)) | yes ((τ ⇒ ℓ₁) τ₁) t | (yes τ₂ t₁) | (bool x , bool x₁) = yes (bool (getLabel τ₁ ~⋎~ ℓ₁)) (S∙ t t₁ (yes τ₂ τ)) dynamicCheck Γ (.(erase t) ∙ .(erase t₁)) | yes ((τ ⇒ ℓ₁) τ₁) t | (yes τ₂ t₁) | (bool x , (proj₄ ⇒ x₁) proj₅) = no dynamicCheck Γ (.(erase t) ∙ .(erase t₁)) | yes ((τ ⇒ ℓ₁) τ₁) t | (yes τ₂ t₁) | ((proj₃ ⇒ x) proj₄ , bool x₁) = no dynamicCheck Γ (.(erase t) ∙ .(erase t₁)) | yes ((τ ⇒ ℓ₁) τ₁) t | (yes τ₂ t₁) | ((proj₃ ⇒ x) proj₄ , (proj₅ ⇒ x₁) proj₆) = no dynamicCheck Γ (.(erase t) ∙ .(erase t₁)) | yes ((τ ⇒ ℓ₁) τ₁) t | (yes τ₂ t₁) | (_ , _) = no dynamicCheck Γ (.(erase t) ∙ .(erase t₁)) | yes _ t | (yes _ t₁) = no dynamicCheck Γ (.(erase t) ∙ t₁) | yes τ t | no = no dynamicCheck Γ (t₁ ∙ .(erase t)) | no | yes τ t = no dynamicCheck Γ (t ∙ t₁) | no | no = no -- if then else dynamicCheck Γ (if b then t₁ else t₂) with dynamicCheck Γ b dynamicCheck Γ (if .(erase b) then t₁ else t₂) | yes τ b with dynamicCheck Γ t₁ | dynamicCheck Γ t₂ dynamicCheck Γ (if .(erase b) then .(erase t₁) else .(erase t₂)) | yes τ b | (yes τ₁ t₁) | (yes τ₂ t₂) with (interior τ₁) ∘< (interior τ₂) dynamicCheck Γ (if .(erase b) then .(erase t₁) else .(erase t₂)) | yes τ b | (yes τ₁ t₁) | (yes τ₂ t₂) | (bool ℓ , bool ℓ₁) = yes (bool (getLabel (τ₁ :∨: τ₂) ~⋎~ getLabel τ)) (Sif b t₁ t₂) dynamicCheck Γ (if .(erase b) then .(erase t₁) else .(erase t₂)) | yes τ b | (yes τ₁ t₁) | (yes τ₂ t₂) | (_ , _) = no dynamicCheck Γ (if .(erase b) then t₁ else t₂) | yes τ b | _ | _ = no dynamicCheck Γ (if b then t₁ else t₂) | no = no -- error dynamicCheck Γ error = no
{ "alphanum_fraction": 0.547544573, "avg_line_length": 42.6266666667, "ext": "agda", "hexsha": "cbe41c3079c861fae9c1b24233f3916940c34ee6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "acf5a153e14a7bdc0c9332fa602fa369fe7add46", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "kellino/TypeSystems", "max_forks_repo_path": "Agda/Gradual Security/dynamic.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "acf5a153e14a7bdc0c9332fa602fa369fe7add46", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "kellino/TypeSystems", "max_issues_repo_path": "Agda/Gradual Security/dynamic.agda", "max_line_length": 188, "max_stars_count": 2, "max_stars_repo_head_hexsha": "acf5a153e14a7bdc0c9332fa602fa369fe7add46", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "kellino/TypeSystems", "max_stars_repo_path": "Agda/Gradual Security/dynamic.agda", "max_stars_repo_stars_event_max_datetime": "2017-05-26T23:06:17.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-27T08:05:40.000Z", "num_tokens": 3133, "size": 6394 }
module Numeral.Natural.Sequence where import Lvl open import Data open import Data.Either as Either using (_‖_) open import Data.Tuple as Tuple using (_⨯_ ; _,_) import Data.Tuple.Raise as Tuple open import Functional open import Numeral.Natural open import Numeral.Natural.Oper open import Numeral.Natural.Oper.FlooredDivision open import Type private variable ℓ ℓ₁ ℓ₂ : Lvl.Level private variable n : ℕ private variable A : Type{ℓ} private variable B : Type{ℓ} -- Alternates between the two sides, starting with the left. -- A countable bijection for the Either type. -- Examples: -- alternate₂(0) = Left(0) -- alternate₂(2) = Left(1) -- alternate₂(4) = Left(2) -- alternate₂(6) = Left(3) -- alternate₂(1) = Right(0) -- alternate₂(3) = Right(1) -- alternate₂(5) = Right(2) -- alternate₂(7) = Right(3) alternate₂ : ℕ → (ℕ ‖ ℕ) alternate₂(0) = Either.Left 0 alternate₂(1) = Either.Right 0 alternate₂(𝐒(𝐒(n))) = Either.map 𝐒 𝐒 (alternate₂ n) -- The inverse of `alternate₂`. unalternate₂ : (ℕ ‖ ℕ) → ℕ unalternate₂(Either.Left n) = n ⋅ 2 unalternate₂(Either.Right n) = 𝐒(n ⋅ 2) -- Maps two natural numbers to a single one without overlaps by following the inverse diagonals downwards. -- A countable bijection for the tuple pairing type. -- Alternative forms: -- pairIndexing a b = a + (∑(𝕟(a + b)) (i ↦ 𝕟-to-ℕ(i))) -- pairIndexing a b = a + ((a + b) * (a + b + 1) / 2) -- Example: -- Horizontal axis is `a` starting from 0. -- Vertical axis is `b` starting from 0. -- Cells are `pairIndexing a b`. -- 0, 1, 3, 6,10,15 -- 2, 4, 7,11,16,.. -- 5, 8,12,17, .. -- 9,13,18, .. -- 14,19, .. -- 20,.. .. .. .. .. -- Termination: -- Decreases `a` until 0 while at the same time increases `b` (So `b` is at most `a`). -- Then the arguments is swapped, but using the predecessor of `b`. -- This means that `b` will eventually reach 0. {-# TERMINATING #-} pairIndexing : ℕ → ℕ → ℕ pairIndexing 𝟎 𝟎 = 𝟎 pairIndexing (𝐒 a) 𝟎 = 𝐒(pairIndexing 𝟎 a) {-# CATCHALL #-} pairIndexing a (𝐒 b) = 𝐒(pairIndexing (𝐒 a) b) -- A sequence which fills a discrete two dimensional grid (a space bounded in two directions and infinite in the other two). -- It is the inverse of an uncurried `pairIndexing`. -- Example: -- •-→-• ↗→• ↗→• -- ↙ ↗ ↙ ↗ ↙ -- •→↗ • ↗ • • -- ↙ ↗ ↙ -- •→↗ • • • diagonalFilling : ℕ → (ℕ ⨯ ℕ) diagonalFilling 𝟎 = (𝟎 , 𝟎) diagonalFilling (𝐒(n)) with diagonalFilling n ... | (𝟎 , b) = (𝐒(b) , 0) ... | (𝐒(a) , b) = (a , 𝐒(b)) tupleIndexing : (ℕ Tuple.^ n) → ℕ tupleIndexing {𝟎} <> = 𝟎 tupleIndexing {𝐒(𝟎)} x = x tupleIndexing {𝐒(𝐒(n))} (x , y) = pairIndexing x (tupleIndexing {𝐒(n)} y) spaceFilling : ℕ → (ℕ Tuple.^ n) spaceFilling {𝟎} _ = <> spaceFilling {𝐒(𝟎)} i = i spaceFilling {𝐒(𝐒(n))} i = Tuple.mapRight (spaceFilling {𝐒(n)}) (diagonalFilling i) -- Interleaves two sequences into one, alternating between the elements from each sequence. interleave : (ℕ → A) → (ℕ → B) → (ℕ → (A ‖ B)) interleave af bf = Either.map af bf ∘ alternate₂ pair : (ℕ → A) → (ℕ → B) → (ℕ → (A ⨯ B)) pair af bf = Tuple.map af bf ∘ diagonalFilling
{ "alphanum_fraction": 0.6111979981, "avg_line_length": 32.6224489796, "ext": "agda", "hexsha": "0d80a72c3e331c3d1ecefcfb36b263056abfbb00", "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/Sequence.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/Sequence.agda", "max_line_length": 124, "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/Sequence.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": 1206, "size": 3197 }
module Utils.Exception where {-# IMPORT Utils.Exception #-} open import Utils.HaskellTypes data Either (A : Set) (B : Set) : Set where Left : A → Either A B Right : B → Either A B {-# COMPILED_DATA Either Either Left Right #-} right : ∀{X A : Set} → A → Either X A right x = Right x error : ∀{X A : Set} → X → Either X A error e = Left e _>>=E_ : ∀{X A B : Set} → Either X A → (A → Either X B) → Either X B _>>=E_ (Left x) f = Left x _>>=E_ (Right x) f = f x commExpTriple : {X A B C : Set} → Triple (Either X A) B C → Either X (Triple A B C) commExpTriple (triple (Left e) b c) = error e commExpTriple (triple (Right a) b c) = right (triple a b c) commExpList : {X A : Set} → List (Either X A) → Either X (List A) commExpList [] = right [] commExpList (Left e :: xs) = Left e commExpList (Right y :: xs) = (commExpList xs) >>=E (λ ys → right (y :: ys)) data Exception : Set where IllformedLetPattern : Exception IllformedPromote : Exception VarNotInCtx : Exception Nonlinearity : Exception NonlocallyClosed : Exception NonEmptyCtx : Exception TypeErrorLetNotTop : Exception TypeErrorLetNotTensor : Exception TypeErrorPromoteNotBang : Exception TypeErrorTypesNotEqual : Exception TypeErrorAppNotImp : Exception NonLinearCtx : Exception TypeErrorDuplicatedFreeVar : Exception {-# COMPILED_DATA Exception Utils.Exception.Exception Utils.Exception.IllformedLetPattern Utils.Exception.IllformedPromote Utils.Exception.VarNotInCtx Utils.Exception.Nonlinearity Utils.Exception.NonlocallyClosed Utils.Exception.NonEmptyCtx Utils.Exception.TypeErrorLetNotTop Utils.Exception.TypeErrorLetNotTensor Utils.Exception.TypeErrorPromoteNotBang Utils.Exception.TypeErrorTypesNotEqual Utils.Exception.TypeErrorAppNotImp Utils.Exception.NonLinearCtx Utils.Exception.TypeErrorDuplicatedFreeVar #-}
{ "alphanum_fraction": 0.5426262626, "avg_line_length": 41.9491525424, "ext": "agda", "hexsha": "3b875765450adb0794e47fb5e268b3758fc4a8b1", "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": "c83f5d8201362b26a749138f6dbff2dd509f85b1", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "heades/Agda-LLS", "max_forks_repo_path": "Source/ALL/Utils/Exception.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "c83f5d8201362b26a749138f6dbff2dd509f85b1", "max_issues_repo_issues_event_max_datetime": "2017-04-05T17:30:16.000Z", "max_issues_repo_issues_event_min_datetime": "2017-03-27T14:52:46.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "heades/Agda-LLS", "max_issues_repo_path": "Source/ALL/Utils/Exception.agda", "max_line_length": 100, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c83f5d8201362b26a749138f6dbff2dd509f85b1", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "heades/Agda-LLS", "max_stars_repo_path": "Source/ALL/Utils/Exception.agda", "max_stars_repo_stars_event_max_datetime": "2019-08-02T23:41:23.000Z", "max_stars_repo_stars_event_min_datetime": "2017-04-09T20:53:53.000Z", "num_tokens": 533, "size": 2475 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Categories.Category.Base where open import Cubical.Core.Glue open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Equiv private variable ℓ ℓ' : Level -- Precategories record Precategory ℓ ℓ' : Type (ℓ-suc (ℓ-max ℓ ℓ')) where -- no-eta-equality ; NOTE: need eta equality for `opop` field ob : Type ℓ Hom[_,_] : ob → ob → Type ℓ' id : ∀ x → Hom[ x , x ] _⋆_ : ∀ {x y z} (f : Hom[ x , y ]) (g : Hom[ y , z ]) → Hom[ x , z ] -- TODO: change these to implicit argument ⋆IdL : ∀ {x y : ob} (f : Hom[ x , y ]) → (id x) ⋆ f ≡ f ⋆IdR : ∀ {x y} (f : Hom[ x , y ]) → f ⋆ (id y) ≡ f ⋆Assoc : ∀ {u v w x} (f : Hom[ u , v ]) (g : Hom[ v , w ]) (h : Hom[ w , x ]) → (f ⋆ g) ⋆ h ≡ f ⋆ (g ⋆ h) -- composition: alternative to diagramatic order _∘_ : ∀ {x y z} (g : Hom[ y , z ]) (f : Hom[ x , y ]) → Hom[ x , z ] g ∘ f = f ⋆ g open Precategory -- Helpful syntax/notation _[_,_] : (C : Precategory ℓ ℓ') → (x y : C .ob) → Type ℓ' _[_,_] = Hom[_,_] -- needed to define this in order to be able to make the subsequence syntax declaration seq' : ∀ (C : Precategory ℓ ℓ') {x y z} (f : C [ x , y ]) (g : C [ y , z ]) → C [ x , z ] seq' = _⋆_ infixl 15 seq' syntax seq' C f g = f ⋆⟨ C ⟩ g -- composition comp' : ∀ (C : Precategory ℓ ℓ') {x y z} (g : C [ y , z ]) (f : C [ x , y ]) → C [ x , z ] comp' = _∘_ infixr 16 comp' syntax comp' C g f = g ∘⟨ C ⟩ f -- Categories record isCategory (C : Precategory ℓ ℓ') : Type (ℓ-max ℓ ℓ') where field isSetHom : ∀ {x y} → isSet (C [ x , y ]) -- Isomorphisms and paths in precategories record CatIso {C : Precategory ℓ ℓ'} (x y : C .Precategory.ob) : Type ℓ' where constructor catiso field mor : C [ x , y ] inv : C [ y , x ] sec : inv ⋆⟨ C ⟩ mor ≡ C .id y ret : mor ⋆⟨ C ⟩ inv ≡ C .id x pathToIso : {C : Precategory ℓ ℓ'} (x y : C .ob) (p : x ≡ y) → CatIso {C = C} x y pathToIso {C = C} x y p = J (λ z _ → CatIso x z) (catiso (C .id x) idx (C .⋆IdL idx) (C .⋆IdL idx)) p where idx = C .id x -- Univalent Categories record isUnivalent (C : Precategory ℓ ℓ') : Type (ℓ-max ℓ ℓ') where field univ : (x y : C .ob) → isEquiv (pathToIso {C = C} x y) -- package up the univalence equivalence univEquiv : ∀ (x y : C .ob) → (x ≡ y) ≃ (CatIso x y) univEquiv x y = (pathToIso {C = C} x y) , (univ x y) open isUnivalent public -- Opposite Categories _^op : Precategory ℓ ℓ' → Precategory ℓ ℓ' (C ^op) .ob = C .ob (C ^op) .Hom[_,_] x y = C .Hom[_,_] y x (C ^op) .id = C .id (C ^op) ._⋆_ f g = C ._⋆_ g f (C ^op) .⋆IdL = C .⋆IdR (C ^op) .⋆IdR = C .⋆IdL (C ^op) .⋆Assoc f g h = sym (C .⋆Assoc _ _ _) open isCategory public
{ "alphanum_fraction": 0.5451263538, "avg_line_length": 27.1568627451, "ext": "agda", "hexsha": "2c0716503b0566234eb8567dce98c6634ff11a93", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Categories/Category/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Categories/Category/Base.agda", "max_line_length": 109, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Categories/Category/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1180, "size": 2770 }
-- Partly based on code due to Andrea Vezzosi. open import Common.Prelude data D : Set where run-time : Bool → D @0 compile-time : Bool → D f : D → @0 D → Bool f (run-time x) _ = x f (compile-time x) (run-time y) = x f (compile-time x) (compile-time y) = y main : IO Unit main = putStrLn (if f (run-time true) (compile-time false) then "ok" else "bad")
{ "alphanum_fraction": 0.5728395062, "avg_line_length": 22.5, "ext": "agda", "hexsha": "101e4eb4864a0eb2ce871bbddf11a1d3c40f4460", "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": "cb645fcad38f76a9bf37507583867595b5ce87a1", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "guilhermehas/agda", "max_forks_repo_path": "test/Compiler/simple/Erased-constructors.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cb645fcad38f76a9bf37507583867595b5ce87a1", "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": "guilhermehas/agda", "max_issues_repo_path": "test/Compiler/simple/Erased-constructors.agda", "max_line_length": 53, "max_stars_count": null, "max_stars_repo_head_hexsha": "cb645fcad38f76a9bf37507583867595b5ce87a1", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "guilhermehas/agda", "max_stars_repo_path": "test/Compiler/simple/Erased-constructors.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 127, "size": 405 }
module Structure.Type.Identity where import Lvl open import Lang.Instance open import Logic.Propositional open import Logic open import Structure.Relator.Properties open import Structure.Setoid open import Type open import Type.Properties.MereProposition open import Type.Size module _ {ℓ ℓₑ ℓₚ} {T : Type{ℓ}} (_≡_ : T → T → Stmt{ℓₑ}) where -- When a binary relation is the smallest reflexive relation (in the sense of cardinality of the relation set). -- This is one of many characterizations of equality. MinimalReflexiveRelation : Stmt MinimalReflexiveRelation = ∀{_▫_ : T → T → Stmt{ℓₚ}} → ⦃ refl : Reflexivity(_▫_) ⦄ → ((_≡_) ⊆₂ (_▫_)) -- When a binary relation is able to substitute every unary relation and is satisfied when every unary relation . -- This is one of many characterizations of equality. GlobalSubstitution : Stmt GlobalSubstitution = ∀{x y : T} → ((x ≡ y) ↔ (∀{P : T → Type{ℓₚ}} → P(x) → P(y))) module _ {ℓ ℓₑ ℓₘₑ} (T : Type{ℓ}) ⦃ equiv-T : Equiv{ℓₑ}(T) ⦄ ⦃ equiv-eq : ∀{x y : T} → Equiv{ℓₘₑ}(x ≡ y) ⦄ where -- A proof of identity is unique (there is only one inhabitant of the identity type). -- This is interpreted as saying that all proofs of an identity are equal to each other. -- Also called: Uniqueness of identity proofs (UIP). -- There is an axiom called "axiom UIP" which is a construction of the following type: -- • ∀{T} → UniqueIdentityProofs(T) UniqueIdentityProofs : Stmt UniqueIdentityProofs = ∀{x y : T} → MereProposition(x ≡ y) module Names where module _ {ℓ ℓₑ ℓₚ} {T : Type{ℓ}} (Id : T → T → Stmt{ℓₑ}) ⦃ refl : Reflexivity(Id) ⦄ where -- Elimination rule for identity types. -- Also called J. -- Explanation: -- P{x}{y} (eq-proof) is an arbitrary predicate with possible mentions of an identity proof. -- A value of type (∀{x : T} → P(reflexivity(_≡_) {x})) means: -- reflexivity(_≡_) satisfies P for every pair of equal objects. -- The conclusion of the type (∀{x y : T} → (eq : (x ≡ y)) → P{x}{y}(eq)) means: -- Every identity proof satisfies P for every pair there is. -- In other words, to prove a proposition that depends on an identity proof, one only need to prove it for reflexivity. -- When this is joined by reflexivity, they become another characterization of equality. -- More information: -- • https://homotopytypetheory.org/2011/04/10/just-kidding-understanding-identity-elimination-in-homotopy-type-theory/ -- • https://stackoverflow.com/questions/22580842/non-trivial-negation-in-agda IdentityEliminator : Stmt IdentityEliminator = (P : ∀{x y : T} → (Id x y) → Stmt{ℓₚ}) → (∀{x : T} → P(reflexivity(Id) {x})) → (∀{x y : T} → (eq : (Id x y)) → P(eq)) -- Usage of the trivial equality reflexivity proof can be substituted by any proof of the same type. -- There is an axiom called "axiom K" which is a construction of the following type: -- • ∀{T} → IntroProofSubstitution(T) IntroProofSubstitution : Stmt IntroProofSubstitution = ∀{x : T}{P : (Id x x) → Type{ℓₚ}} → P(reflexivity(Id)) → (∀{eq : (Id x x)} → P(eq)) module _ {ℓ ℓₑ ℓₚ} {T : Type{ℓ}} (Id : T → T → Stmt{ℓₑ}) ⦃ refl : Reflexivity(Id) ⦄ where record IdentityEliminator : Stmt{ℓ Lvl.⊔ ℓₑ Lvl.⊔ Lvl.𝐒(ℓₚ)} where constructor intro field elim : Names.IdentityEliminator{ℓₚ = ℓₚ}(Id) idElim = inst-fn IdentityEliminator.elim module _ {ℓ ℓₘ ℓₑ ℓₘₑ} {T : Type{ℓ}} (Id : T → T → Type{ℓₑ}) ⦃ refl-T : Reflexivity(Id) ⦄ ⦃ identElim-T : IdentityEliminator(Id) ⦄ (_≡_ : ∀{T : Type{ℓₘ}} → T → T → Type{ℓₘₑ}) where open Reflexivity (refl-T) using () renaming (proof to refl) -- Reflexivity is an identity element for the identity elimination operation. record IdentityEliminationOfIntro : Stmt{ℓ Lvl.⊔ Lvl.𝐒 ℓₘ Lvl.⊔ ℓₑ Lvl.⊔ ℓₘₑ} where constructor intro field proof : (P : ∀{x y : T} → (Id x y) → Stmt{ℓₘ}) → (p : ∀{x} → P{x}{x}(refl)) → (∀{x : T} → (idElim(Id)(P) p refl ≡ p{x})) idElimOfIntro = inst-fn IdentityEliminationOfIntro.proof module _ {ℓₑ : Lvl.Level → Lvl.Level} (Id : ∀{ℓ}{T : Type{ℓ}} → T → T → Stmt{ℓₑ(ℓ)}) where record IdentityType : Stmtω where constructor intro field ⦃ identity-intro ⦄ : ∀{ℓₒ}{T : Type{ℓₒ}} → Reflexivity(Id{T = T}) ⦃ identity-elim ⦄ : ∀{ℓₒ ℓₚ}{T : Type{ℓₒ}} → IdentityEliminator{ℓₚ = ℓₚ}(Id{T = T}) ⦃ refl-elim-inverses ⦄ : ∀{ℓ ℓₘ}{T : Type{ℓ}} → IdentityEliminationOfIntro{ℓₘ = ℓₘ}(Id{T = T})(Id)
{ "alphanum_fraction": 0.6524568095, "avg_line_length": 52.4352941176, "ext": "agda", "hexsha": "28150225c8508885240b2007b894874ff77670e6", "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/Type/Identity.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/Type/Identity.agda", "max_line_length": 142, "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/Type/Identity.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": 1581, "size": 4457 }
module PLRTree.Complete.Correctness.Base {A : Set} where open import BTree.Complete.Base {A} open import BTree.Complete.Alternative.Correctness {A} renaming (lemma-complete'-complete to lemma-complete''-complete) open import Function using (_∘_) open import PLRTree {A} open import PLRTree.Complete {A} renaming (Complete to Complete' ; _⋗_ to _⋗'_ ; _⋘_ to _⋘'_ ; _⋙_ to _⋙'_) open import PLRTree.Complete.Correctness.Alternative {A} renaming (lemma-complete'-complete to lemma-complete'-complete'') open import PLRTree.Equality.Correctness {A} lemma-complete'-complete : {t : PLRTree} → Complete' t → Complete (forget t) lemma-complete'-complete = lemma-complete''-complete ∘ lemma-complete'-complete''
{ "alphanum_fraction": 0.7316076294, "avg_line_length": 52.4285714286, "ext": "agda", "hexsha": "cb00f04e827e78a43534a84b9f16a48412cbf8fa", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/PLRTree/Complete/Correctness/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/PLRTree/Complete/Correctness/Base.agda", "max_line_length": 122, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/PLRTree/Complete/Correctness/Base.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 202, "size": 734 }
module Example where open import Logic.Identity open import Base open import Category open import Product open import Terminal open import Unique import Iso infixr 30 _─→_ infixr 90 _∘_ data Name : Set where Zero : Name One : Name Half : Name data Obj : Set1 where obj : Name -> Obj mutual _─→'_ : Name -> Name -> Set x ─→' y = obj x ─→ obj y data _─→_ : Obj -> Obj -> Set where Idle : {A : Name} -> A ─→' A All : Zero ─→' One Start : Zero ─→' Half Turn : Half ─→' Half Back : One ─→' Half End : Half ─→' One id : {A : Obj} -> A ─→ A id {obj x} = Idle _∘_ : {A B C : Obj} -> B ─→ C -> A ─→ B -> A ─→ C f ∘ Idle = f Idle ∘ All = All Idle ∘ Start = Start Turn ∘ Start = Start End ∘ Start = All Idle ∘ Turn = Turn Turn ∘ Turn = Turn End ∘ Turn = End Idle ∘ Back = Back Turn ∘ Back = Back End ∘ Back = Idle Idle ∘ End = End idL : {A B : Obj}{f : A ─→ B} -> id ∘ f ≡ f idL {f = Idle } = refl idL {f = All } = refl idL {f = Start } = refl idL {f = Turn } = refl idL {f = Back } = refl idL {f = End } = refl idR : {A B : Obj}{f : A ─→ B} -> f ∘ id ≡ f idR {obj _} = refl assoc : {A B C D : Obj}{f : C ─→ D}{g : B ─→ C}{h : A ─→ B} -> (f ∘ g) ∘ h ≡ f ∘ (g ∘ h) assoc {f = _ }{g = _ }{h = Idle } = refl assoc {f = _ }{g = Idle}{h = All } = refl assoc {f = _ }{g = Idle}{h = Start} = refl assoc {f = Idle}{g = Turn}{h = Start} = refl assoc {f = Turn}{g = Turn}{h = Start} = refl assoc {f = End }{g = Turn}{h = Start} = refl assoc {f = Idle}{g = End }{h = Start} = refl assoc {f = _ }{g = Idle}{h = Turn } = refl assoc {f = Idle}{g = Turn}{h = Turn } = refl assoc {f = Turn}{g = Turn}{h = Turn } = refl assoc {f = End }{g = Turn}{h = Turn } = refl assoc {f = Idle}{g = End }{h = Turn } = refl assoc {f = _ }{g = Idle}{h = Back } = refl assoc {f = Idle}{g = Turn}{h = Back } = refl assoc {f = Turn}{g = Turn}{h = Back } = refl assoc {f = End }{g = Turn}{h = Back } = refl assoc {f = Idle}{g = End }{h = Back } = refl assoc {f = _ }{g = Idle}{h = End } = refl ℂ : Cat ℂ = cat Obj _─→_ id _∘_ (\{_}{_} -> Equiv) (\{_}{_}{_} -> cong2 _∘_) idL idR assoc open module T = Term ℂ open module I = Init ℂ open module S = Sum ℂ term : Terminal (obj One) term (obj Zero) = ? init : Initial (obj Zero) init = ?
{ "alphanum_fraction": 0.514483355, "avg_line_length": 23.13, "ext": "agda", "hexsha": "6041b5e93060977d6d4bcf80e4b4633eeceb14b8", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/cat/Example.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/cat/Example.agda", "max_line_length": 62, "max_stars_count": null, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "examples/outdated-and-incorrect/cat/Example.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 967, "size": 2313 }
{-# OPTIONS --experimental-irrelevance #-} module ShapeIrrelevantParameterNoBecauseOfRecursion where data ⊥ : Set where record ⊤ : Set where data Bool : Set where true false : Bool True : Bool → Set True false = ⊥ True true = ⊤ data D ..(b : Bool) : Set where c : True b → D b -- should fail fromD : {b : Bool} → D b → True b fromD (c p) = p cast : .(a b : Bool) → D a → D b cast _ _ x = x bot : ⊥ bot = fromD (cast true false (c _))
{ "alphanum_fraction": 0.6183035714, "avg_line_length": 17.2307692308, "ext": "agda", "hexsha": "5336f9f3cffa8e312e6af3044afe7665ac098a15", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/ShapeIrrelevantParameterNoBecauseOfRecursion.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/ShapeIrrelevantParameterNoBecauseOfRecursion.agda", "max_line_length": 57, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Fail/ShapeIrrelevantParameterNoBecauseOfRecursion.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": 155, "size": 448 }
{-# OPTIONS --allow-unsolved-metas #-} module Thesis.ANormalUntyped where open import Agda.Primitive open import Data.Empty open import Data.Unit using (⊤) open import Data.Product open import Data.Nat import Data.Integer.Base as I open I using (ℤ) open import Data.Integer.Base using (ℤ) open import Relation.Binary.PropositionalEquality {- Typed deBruijn indexes for untyped languages. -} -- Using a record gives an eta rule saying that all types are equal. record Type : Set where constructor Uni record DType : Set where constructor DUni open import Base.Syntax.Context Type public import Base.Syntax.Context DType as DC data Term (Γ : Context) : Set where var : (x : Var Γ Uni) → Term Γ lett : (f : Var Γ Uni) → (x : Var Γ Uni) → Term (Uni • Γ) → Term Γ ΔΔ : Context → DC.Context ΔΔ ∅ = ∅ ΔΔ (τ • Γ) = DUni • ΔΔ Γ derive-dvar : ∀ {Δ} → (x : Var Δ Uni) → DC.Var (ΔΔ Δ) DUni derive-dvar this = DC.this derive-dvar (that x) = DC.that (derive-dvar x) data DTerm : (Δ : Context) → Set where dvar : ∀ {Δ} (x : DC.Var (ΔΔ Δ) DUni) → DTerm Δ dlett : ∀ {Δ} → (f : Var Δ Uni) → (x : Var Δ Uni) → (t : Term (Uni • Δ)) → (df : DC.Var (ΔΔ Δ) DUni) → (dx : DC.Var (ΔΔ Δ) DUni) → (dt : DTerm (Uni • Δ)) → DTerm Δ derive-dterm : ∀ {Δ} → (t : Term Δ) → DTerm Δ derive-dterm (var x) = dvar (derive-dvar x) derive-dterm (lett f x t) = dlett f x t (derive-dvar f) (derive-dvar x) (derive-dterm t) {- deriveC Δ (lett f x t) = dlett df x dx -} -- data ΔCTerm (Γ : Context) (τ : Type) (Δ : Context) : Set where -- data ΔCTerm (Γ : Context) (τ : Type) (Δ : Context) : Set where -- cvar : (x : Var Γ τ) Δ → -- ΔCTerm Γ τ Δ -- clett : ∀ {σ τ₁ κ} → (f : Var Γ (σ ⇒ τ₁)) → (x : Var Γ σ) → -- ΔCTerm (τ₁ • Γ) τ (? • Δ) → -- ΔCTerm Γ τ Δ weaken-term : ∀ {Γ₁ Γ₂} → (Γ₁≼Γ₂ : Γ₁ ≼ Γ₂) → Term Γ₁ → Term Γ₂ weaken-term Γ₁≼Γ₂ (var x) = var (weaken-var Γ₁≼Γ₂ x) weaken-term Γ₁≼Γ₂ (lett f x t) = lett (weaken-var Γ₁≼Γ₂ f) (weaken-var Γ₁≼Γ₂ x) (weaken-term (keep _ • Γ₁≼Γ₂) t) -- I don't necessarily recommend having a separate syntactic category for -- functions, but we should prove a fundamental lemma for them too, somehow. -- I'll probably end up with some ANF allowing lambdas to do the semantics. data Fun (Γ : Context) : Set where term : Term Γ → Fun Γ abs : ∀ {σ} → Fun (σ • Γ) → Fun Γ data DFun (Δ : Context) : Set where dterm : DTerm Δ → DFun Δ dabs : DFun (Uni • Δ) → DFun Δ derive-dfun : ∀ {Δ} → (t : Fun Δ) → DFun Δ derive-dfun (term t) = dterm (derive-dterm t) derive-dfun (abs f) = dabs (derive-dfun f) weaken-fun : ∀ {Γ₁ Γ₂} → (Γ₁≼Γ₂ : Γ₁ ≼ Γ₂) → Fun Γ₁ → Fun Γ₂ weaken-fun Γ₁≼Γ₂ (term x) = term (weaken-term Γ₁≼Γ₂ x) weaken-fun Γ₁≼Γ₂ (abs f) = abs (weaken-fun (keep _ • Γ₁≼Γ₂) f) data Val : Type → Set data DVal : DType → Set -- data Val (τ : Type) : Set open import Base.Denotation.Environment Type Val public open import Base.Data.DependentList public import Base.Denotation.Environment DType DVal as D -- data Val (τ : Type) where data Val where closure : ∀ {Γ} → (t : Fun (Uni • Γ)) → (ρ : ⟦ Γ ⟧Context) → Val Uni intV : ∀ (n : ℕ) → Val Uni data DVal where dclosure : ∀ {Γ} → (dt : DFun (Uni • Γ)) → (ρ : ⟦ Γ ⟧Context) → (dρ : D.⟦ ΔΔ Γ ⟧Context) → DVal DUni dintV : ∀ (n : ℤ) → DVal DUni ChΔ : ∀ (Δ : Context) → Set ChΔ Δ = D.⟦ ΔΔ Δ ⟧Context -- ⟦_⟧Term : ∀ {Γ τ} → Term Γ τ → ⟦ Γ ⟧Context → ⟦ τ ⟧Type -- ⟦ var x ⟧Term ρ = ⟦ x ⟧Var ρ -- ⟦ lett f x t ⟧Term ρ = ⟦ t ⟧Term (⟦ f ⟧Var ρ (⟦ x ⟧Var ρ) • ρ) -- XXX separate syntax is a bit dangerous. Also, do I want to be so accurate relative to the original model? data _⊢_↓[_]_ {Γ} (ρ : ⟦ Γ ⟧Context) : Term Γ → ℕ → Val Uni → Set data _F⊢_↓[_]_ {Γ} (ρ : ⟦ Γ ⟧Context) : Fun Γ → ℕ → Val Uni → Set where abs : ∀ {t : Fun (Uni • Γ)} → ρ F⊢ abs t ↓[ 0 ] closure t ρ term : ∀ {v} n (t : Term Γ) → ρ ⊢ t ↓[ n ] v → ρ F⊢ term t ↓[ n ] v data _⊢_↓[_]_ {Γ} (ρ : ⟦ Γ ⟧Context) where var : ∀ (x : Var Γ Uni) → ρ ⊢ var x ↓[ 0 ] (⟦ x ⟧Var ρ) lett : ∀ n1 n2 {Γ' ρ′ v1 v2 v3} {f x t t'} → ρ ⊢ var f ↓[ 0 ] closure {Γ'} t' ρ′ → ρ ⊢ var x ↓[ 0 ] v1 → (v1 • ρ′) F⊢ t' ↓[ n1 ] v2 → (v2 • ρ) ⊢ t ↓[ n2 ] v3 → ρ ⊢ lett f x t ↓[ suc (suc (n1 + n2)) ] v3 -- lit : ∀ n → -- ρ ⊢ const (lit n) ↓[ 0 ] intV n -- data _D_⊢_↓[_]_ {Γ} (ρ : ⟦ Γ ⟧Context) (dρ : D.⟦ ΔΔ Γ ⟧Context) : DTerm Γ → ℕ → DVal DUni → Set where -- dvar : ∀ (x : DC.Var (ΔΔ Γ) DUni) → -- ρ D dρ ⊢ dvar x ↓[ 0 ] (D.⟦ x ⟧Var dρ) -- dlett : ∀ n1 n2 n3 n4 {Γ' ρ′ ρ'' dρ' v1 v2 v3 dv1 dv2 dv3} {f x t df dx dt t' dt'} → -- ρ ⊢ var f ↓[ 0 ] closure {Γ'} t' ρ′ → -- ρ ⊢ var x ↓[ 0 ] v1 → -- (v1 • ρ′) F⊢ t' ↓[ n1 ] v2 → -- (v2 • ρ) ⊢ t ↓[ n2 ] v3 → -- -- With a valid input ρ' and ρ'' coincide? Varies among plausible validity -- -- definitions. -- ρ D dρ ⊢ dvar df ↓[ 0 ] dclosure {Γ'} dt' ρ'' dρ' → -- ρ D dρ ⊢ dvar dx ↓[ 0 ] dv1 → -- (v1 • ρ'') D (dv1 • dρ') F⊢ dt' ↓[ n3 ] dv2 → -- (v2 • ρ) D (dv2 • dρ) ⊢ dt ↓[ n4 ] dv3 → -- ρ D dρ ⊢ dlett f x t df dx dt ↓[ suc (suc (n1 + n2)) ] dv3 -- Do I need to damn count steps here? No. data _D_⊢_↓_ {Γ} (ρ : ⟦ Γ ⟧Context) (dρ : ChΔ Γ) : DTerm Γ → DVal DUni → Set data _D_F⊢_↓_ {Γ} (ρ : ⟦ Γ ⟧Context) (dρ : ChΔ Γ) : DFun Γ → DVal DUni → Set where dabs : ∀ {dt : DFun (Uni • Γ)} → ρ D dρ F⊢ dabs dt ↓ dclosure dt ρ dρ dterm : ∀ {dv} (dt : DTerm Γ) → ρ D dρ ⊢ dt ↓ dv → ρ D dρ F⊢ dterm dt ↓ dv data _D_⊢_↓_ {Γ} (ρ : ⟦ Γ ⟧Context) (dρ : ChΔ Γ) where dvar : ∀ (x : DC.Var (ΔΔ Γ) DUni) → ρ D dρ ⊢ dvar x ↓ (D.⟦ x ⟧Var dρ) dlett : ∀ n1 n2 {Γ' ρ′ ρ'' dρ' v1 v2 v3 dv1 dv2 dv3} {f x t df dx dt t' dt'} → ρ ⊢ var f ↓[ 0 ] closure {Γ'} t' ρ′ → ρ ⊢ var x ↓[ 0 ] v1 → (v1 • ρ′) F⊢ t' ↓[ n1 ] v2 → (v2 • ρ) ⊢ t ↓[ n2 ] v3 → -- With a valid input ρ' and ρ'' coincide? Varies among plausible validity -- definitions. ρ D dρ ⊢ dvar df ↓ dclosure {Γ'} dt' ρ'' dρ' → ρ D dρ ⊢ dvar dx ↓ dv1 → (v1 • ρ'') D (dv1 • dρ') F⊢ dt' ↓ dv2 → (v2 • ρ) D (dv2 • dρ) ⊢ dt ↓ dv3 → ρ D dρ ⊢ dlett f x t df dx dt ↓ dv3 open import Data.Nat.Properties open import Data.Nat.Properties.Simple open import Relation.Binary hiding (_⇒_) suc∸ : ∀ m n → n ≤ m → suc (m ∸ n) ≡ suc m ∸ n suc∸ m zero z≤n = refl suc∸ (suc m) (suc n) (s≤s n≤m) = suc∸ m n n≤m suc∸suc : ∀ m n → n < m → suc (m ∸ suc n) ≡ m ∸ n suc∸suc (suc m) zero (s≤s n<m) = refl suc∸suc (suc m) (suc n) (s≤s n<m) = suc∸suc m n n<m lemlt : ∀ j k → suc j < k → k ∸ suc j < k lemlt j (suc k) (s≤s j<k) = s≤s (∸-mono {k} {k} {j} {0} ≤-refl z≤n) lemlt′ : ∀ j k → suc j <′ k → k ∸ suc j <′ k lemlt′ j k j<′k = ≤⇒≤′ (lemlt j k (≤′⇒≤ j<′k)) open import Induction.WellFounded open import Induction.Nat rrelT3-Type : ℕ → Set₁ rrelT3-Type n = ∀ {Γ} → (t1 : Fun Γ) (dt : DFun Γ) (t2 : Fun Γ) (ρ1 : ⟦ Γ ⟧Context) (dρ : ChΔ Γ) (ρ2 : ⟦ Γ ⟧Context) → Set rrelV3-Type : ℕ → Set₁ rrelV3-Type n = ∀ (v1 : Val Uni) (dv : DVal DUni) (v2 : Val Uni) → Set rrelTV3-Type : ℕ → Set₁ rrelTV3-Type n = rrelT3-Type n × rrelV3-Type n -- The type of the function availalbe for recursive calls. rrelTV3-recSubCallsT : ℕ → Set₁ rrelTV3-recSubCallsT n = (k : ℕ) → k < n → rrelTV3-Type k mutual -- Assemble together rrelTV3-step : ∀ n → rrelTV3-recSubCallsT n → rrelTV3-Type n rrelTV3-step n rec-rrelTV3 = let rrelV3-n = rrelV3-step n rec-rrelTV3 in rrelT3-step n rec-rrelTV3 rrelV3-n , rrelV3-n rrelTV3 = <-rec rrelTV3-Type rrelTV3-step rrelT3 : ∀ n → rrelT3-Type n rrelT3 n = proj₁ (rrelTV3 n) rrelV3 : ∀ n → rrelV3-Type n rrelV3 n = proj₂ (rrelTV3 n) s-rrelV3 : ∀ k → rrelTV3-recSubCallsT k → rrelV3-Type k → ∀ j → j < k → rrelV3-Type (k ∸ j) s-rrelV3 k rec-rrelTV3 rrelV3-k 0 _ = rrelV3-k s-rrelV3 k rec-rrelTV3 rrelV3-k (suc j) sucj<k = proj₂ (rec-rrelTV3 (k ∸ suc j) (lemlt j k sucj<k)) -- Have the same context for t1, dt and t2? Yeah, good, that's what we want in the end... -- Though we might want more flexibility till when we have replacement -- changes. rrelT3-step : ∀ k → rrelTV3-recSubCallsT k → rrelV3-Type k → -- rrelV3-Type n ∀ {Γ} → (t1 : Fun Γ) (dt : DFun Γ) (t2 : Fun Γ) (ρ1 : ⟦ Γ ⟧Context) (dρ : ChΔ Γ) (ρ2 : ⟦ Γ ⟧Context) → Set rrelT3-step k rec-rrelTV3 rrelV3-k = λ t1 dt t2 ρ1 dρ ρ2 → ∀ j (j<k : j < k) n2 → (v1 v2 : Val Uni) → (ρ1⊢t1↓[j]v1 : ρ1 F⊢ t1 ↓[ j ] v1) → (ρ2⊢t2↓[n2]v2 : ρ2 F⊢ t2 ↓[ n2 ] v2) → Σ[ dv ∈ DVal DUni ] Σ[ dn ∈ ℕ ] ρ1 D dρ F⊢ dt ↓ dv × s-rrelV3 k rec-rrelTV3 rrelV3-k j j<k v1 dv v2 -- where -- s-rrelV3 : ∀ j → j <′ k → rrelV3-Type (k ∸ j) -- -- If j = 0, we can't do a recursive call on (k - j) because that's not -- -- well-founded. Luckily, we don't need to, just use relV as defined at -- -- the same level. -- -- Yet, this will be a pain in proofs. -- s-rrelV3 0 _ = rrelV3-k -- s-rrelV3 (suc j) sucj<′k = proj₂ (rec-rrelTV3 (k ∸ suc j) (lemlt′ j k sucj<′k)) rrelV3-step : ∀ n → rrelTV3-recSubCallsT n → -- rrelV3-Type n ∀ (v1 : Val Uni) (dv : DVal DUni) (v2 : Val Uni) → Set rrelV3-step n rec-rrelTV3 (intV v1) (dintV dv) (intV v2) = dv I.+ (I.+ v1) ≡ (I.+ v2) rrelV3-step n rec-rrelTV3 (intV v1) (dintV n₁) (closure t ρ) = ⊥ rrelV3-step n rec-rrelTV3 (intV v1) (dclosure dt ρ dρ) c = ⊥ rrelV3-step n rec-rrelTV3 (closure {Γ1} t1 ρ1) (dclosure {ΔΓ} dt ρ' dρ) (closure {Γ2} t2 ρ2) = -- Require a proof that the two contexts match: Σ ((Γ1 ≡ Γ2) × (Γ1 ≡ ΔΓ)) λ { (refl , refl) → ∀ (k : ℕ) (k<n : k < n) v1 dv v2 → proj₂ (rec-rrelTV3 k k<n) v1 dv v2 → proj₁ (rec-rrelTV3 k k<n) t1 dt t2 (v1 • ρ1) (dv • dρ) (v2 • ρ2) } rrelV3-step n rec-rrelTV3 (closure t ρ) (dclosure dt ρ₁ dρ) (intV n₁) = ⊥ rrelV3-step n rec-rrelTV3 (closure t ρ) (dintV n₁) c = ⊥ open import Postulate.Extensionality mutual rrelT3-equiv : ∀ k {Γ} {t1 : Fun Γ} {dt t2 ρ1 dρ ρ2} → rrelT3 k t1 dt t2 ρ1 dρ ρ2 ≡ ∀ j (j<k : j < k) n2 → ∀ (v1 v2 : Val Uni) → (ρ1⊢t1↓[j]v1 : ρ1 F⊢ t1 ↓[ j ] v1) → (ρ2⊢t2↓[n2]v2 : ρ2 F⊢ t2 ↓[ n2 ] v2) → Σ[ dv ∈ DVal DUni ] Σ[ dn ∈ ℕ ] ρ1 D dρ F⊢ dt ↓ dv × rrelV3 j v1 dv v2 rrelT3-equiv k {Γ} {t1} {dt} {t2} {ρ1} {dρ} {ρ2} = cong (λ □ → ∀ j → □ j) (ext λ { zero -> cong {lsuc lzero} {lsuc lzero} {{!!}} {{!!}} {!!} {{!!}} {{! !}} {!cong!} -- cong {{!!}} {{!!}} -- (λ (□ : zero < k → ∀ (n2 : ℕ) (v1 v2 : Val Uni) (ρ1⊢t1↓[j]v1 : ρ1 F⊢ t1 ↓[ zero ] v1) → {!(ρ2⊢t2↓[n2]v2 : ρ2 F⊢ t2 ↓[ n2 ] v2) → ? !})→ -- ∀ (j<k : zero < k) n2 → -- (v1 v2 : Val Uni) → -- (ρ1⊢t1↓[j]v1 : ρ1 F⊢ t1 ↓[ zero ] v1) → -- (ρ2⊢t2↓[n2]v2 : ρ2 F⊢ t2 ↓[ n2 ] v2) → -- Σ-syntax (DVal DUni) -- λ dv → Σ-syntax ℕ λ dn → (ρ1 D dρ F⊢ dt ↓ dv) × □ j<k n2 v1 v2 ρ1⊢t1↓[j]v1 ρ2⊢t2↓[n2]v2) -- {!!} ; (suc j') -> {!!}}) -- cong (λ □ → -- (j : ℕ) (j<k : j < k) (n2 : ℕ) -- (v1 v2 : Val Uni) → -- (ρ1⊢t1↓[j]v1 : ρ1 F⊢ t1 ↓[ j ] v1) → -- -- (ρ2⊢t2↓[n2]v2 : ρ2 F⊢ t2 ↓[ n2 ] v2) → -- □ j j<k n2 v1 v2 ρ1⊢t1↓[j]v1 -- -- □ j<k n2 v1 v2 ρ1⊢t1↓[j]v1 ρ2⊢t2↓[n2]v2 -- ) (ext³ λ j j<k n2 → {!ext³!}) rrelV3-equiv : ∀ n {Γ1 Γ2 ΔΓ t1 dt t2 ρ1 ρ' dρ ρ2} → rrelV3 n (closure {Γ1} t1 ρ1) (dclosure {ΔΓ} dt ρ' dρ) (closure {Γ2} t2 ρ2) ≡ Σ ((Γ1 ≡ Γ2) × (Γ1 ≡ ΔΓ)) λ { (refl , refl) → ∀ (k : ℕ) (k<n : k <′ n) v1 dv v2 → rrelV3 k v1 dv v2 → rrelT3 k t1 dt t2 (v1 • ρ1) (dv • dρ) (v2 • ρ2) } rrelV3-equiv n = cong (λ □ → Σ (_ ≡ _ × _ ≡ _) □) (ext (λ { (eq1 , eq2) → cong (λ □ → (λ { (refl , refl) → ∀ (k : ℕ) (k<n : k <′ n) v1 dv v2 → □ k k<n v1 dv v2 }) eq1 eq2) (ext (λ x → ext {!!}))})) -- -- cong (λ □ → ∀ k → (k<n : k <′ n) → □ k k<n) -- rrelV3-equiv k rrelρ3 : ℕ → ∀ Γ (ρ1 : ⟦ Γ ⟧Context) (dρ : ChΔ Γ) (ρ2 : ⟦ Γ ⟧Context) → Set rrelρ3 n ∅ ∅ ∅ ∅ = ⊤ rrelρ3 n (Uni • Γ) (v1 • ρ1) (dv • dρ) (v2 • ρ2) = rrelV3 n v1 dv v2 × rrelρ3 n Γ ρ1 dρ ρ2 -- rfundamental3 : ∀ {Γ} (t : Fun Γ) → ∀ k ρ1 dρ ρ2 → (ρρ : rrelρ3 k Γ ρ1 dρ ρ2) → rrelT3 k t (derive-dfun t) t ρ1 dρ ρ2 rfundamental3 (term x) k ρ1 dρ ρ2 ρρ j j<k n2 v1 v2 ρ1⊢t1↓[j]v1 ρ2⊢t2↓[n2]v2 = {!!} rfundamental3 {Γ} (abs t) k ρ1 dρ ρ2 ρρ .0 j<k .0 (closure .t .ρ1) (closure .t .ρ2) abs abs = dclosure (derive-dfun t) ρ1 dρ , 0 , dabs , (refl , refl) , {!body !} where body1 : ∀ k₁ (k₁<k : k₁ <′ k) → (v1 : Val Uni) (dv : DVal DUni) (v2 : Val Uni) → rrelV3 k₁ v1 dv v2 → rrelT3 k₁ t (derive-dfun t) t (v1 • ρ1) (dv • dρ) (v2 • ρ2) body1 = λ k₁ k₁<k v1 dv v2 x v3 v4 j n2 j<k₁ ρ1⊢t1↓[j]v1 ρ2⊢t2↓[n2]v2 → {! rfundamental3 {Uni • Γ} t k₁ (v1 • ρ1) (dv • dρ) (v2 • ρ2) ({!vv!} , {!ρρ!}) v3 v4 0 n2 {!j<k₁ !} {! ρ1⊢t1↓[j]v1 !} ρ2⊢t2↓[n2]v2 !} -- λ -- { k₁ k<n v1 dv v2 vv v3 v4 0 n2 j<k₁ ρ1⊢t1↓[j]v1 ρ2⊢t2↓[n2]v2 → {! -- rfundamental3 {Uni • Γ} t k₁ (v1 • ρ1) (dv • dρ) (v2 • ρ2) ({!vv!} , {!ρρ!}) v3 v4 0 n2 {!j<k₁ !} {! ρ1⊢t1↓[j]v1 !} ρ2⊢t2↓[n2]v2 -- !} -- -- (Some.wfRec-builder rrelTV3-Type rrelTV3-step k₁ -- -- (<-well-founded′ k k₁ k<n)) -- -- All.wfRec-builder <-well-founded _ rrelTV3-Type rrelTV3-step k k₁ k<n : rrelTV3-Type k₁ -- -- -- ; k₁ k<n v1 dv v2 vv v3 v4 (suc j) n2 j<k₁ ρ1⊢t1↓[j]v1 ρ2⊢t2↓[n2]v2 → {! -- !} -- -- rfundamental3 t k₁ (v1 • ρ1) (dv • dρ) (v2 • ρ2) ({!vv!} , {!ρρ!}) v3 v4 {!suc j !} n2 {!j<k₁ !} {! ρ1⊢t1↓[j]v1 !} ρ2⊢t2↓[n2]v2 -- } -- -- ∀ k → rrelTV3-recSubCallsT k → rrelV3-Type k → -- -- ∀ j → j <′ k → rrelV3-Type (k ∸ j) -- foo : s-rrelV3 k -- (All.wfRec-builder <-well-founded _ rrelTV3-Type rrelTV3-step k) -- (rrelV3-step k (All.wfRec-builder <-well-founded _ rrelTV3-Type rrelTV3-step k)) -- j j<k v1 (dclosure (derive-dfun t) ρ1 dρ) v2 -- foo with j -- ... | s = {!!}
{ "alphanum_fraction": 0.5151429179, "avg_line_length": 36.9083769634, "ext": "agda", "hexsha": "ae0b754df96b180ca5fbdc5ef21fa56f8937f3a4", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_path": "Thesis/ANormalUntyped.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_path": "Thesis/ANormalUntyped.agda", "max_line_length": 165, "max_stars_count": 10, "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_path": "Thesis/ANormalUntyped.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "num_tokens": 6904, "size": 14099 }
----------------------------------------------------------------------------- -- Existential elimination ----------------------------------------------------------------------------- {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.Common.FOL.Existential.Elimination where ----------------------------------------------------------------------------- postulate D : Set module ∃₁ where -- Type theoretical version -- We add 3 to the fixities of the Agda standard library 0.8.1 (see -- Data/Product.agda). infixr 7 _,_ -- The existential quantifier type on D. data ∃ (A : D → Set) : Set where _,_ : (x : D) → A x → ∃ A -- Sugar syntax for the existential quantifier. syntax ∃ (λ x → e) = ∃[ x ] e -- The existential proyections. ∃-proj₁ : ∀ {A} → ∃ A → D ∃-proj₁ (x , _) = x ∃-proj₂ : ∀ {A} → (h : ∃ A) → A (∃-proj₁ h) ∃-proj₂ (_ , Ax) = Ax -- Some examples -- The order of quantifiers of the same sort is irrelevant. ∃-ord : {A² : D → D → Set} → (∃[ x ] ∃[ y ] A² x y) → (∃[ y ] ∃[ x ] A² x y) ∃-ord (x , y , h) = y , x , h ----------------------------------------------------------------------------- module ∃₂ where -- First-order logic version -- We add 3 to the fixities of the Agda standard library 0.8.1 (see -- Data/Product.agda). infixr 7 _,_ -- The existential quantifier type on D. data ∃ (A : D → Set) : Set where _,_ : (x : D) → A x → ∃ A -- Sugar syntax for the existential quantifier. syntax ∃ (λ x → e) = ∃[ x ] e -- Existential elimination -- ∃x.A(x) A(x) → B -- ------------------------ -- B -- NB. We do not use the usual type theory elimination with two -- projections because we are working in first-order logic where we -- do need extract a witness from an existence proof. ∃-elim : {A : D → Set}{B : Set} → ∃ A → ((x : D) → A x → B) → B ∃-elim (x , Ax) h = h x Ax -- Some examples -- The order of quantifiers of the same sort is irrelevant. ∃-ord : {A² : D → D → Set} → (∃[ x ] ∃[ y ] A² x y) → (∃[ y ] ∃[ x ] A² x y) ∃-ord h = ∃-elim h (λ x h₁ → ∃-elim h₁ (λ y prf → y , x , prf)) -- A proof non-FOL valid non-FOL : {A : D → Set} → ∃ A → D non-FOL h = ∃-elim h (λ x _ → x) ----------------------------------------------------------------------------- module ∃₃ where -- First-order logic version -- A different version from the existential introduction -- A(x) -- ------------ -- ∃x.A(x) -- The existential quantifier type on D. data ∃ (A : D → Set) : Set where ∃-intro : ((x : D) → A x) → ∃ A -- Sugar syntax for the existential quantifier. syntax ∃ (λ x → e) = ∃[ x ] e postulate d : D -- Existential elimination. -- NB. It is neccesary that D ≢ ∅. ∃-elim : {A : D → Set}{B : Set} → ∃ A → ((x : D) → A x → B) → B ∃-elim (∃-intro h₁) h₂ = h₂ d (h₁ d) -- Some examples -- Impossible -- thm : {A : D → Set} → ∃[ x ] A x → ∃[ y ] A y -- thm h = ∃-elim h (λ x prf → {!!})
{ "alphanum_fraction": 0.4593900482, "avg_line_length": 28.5779816514, "ext": "agda", "hexsha": "032d4de150f454c79483c1ccc5d9d3941476805c", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/Common/FOL/Existential/Elimination.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/Common/FOL/Existential/Elimination.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/Common/FOL/Existential/Elimination.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": 1015, "size": 3115 }
{-# OPTIONS --show-implicit #-} module _ where postulate R : Set module ModuleB where module NotRecordB (r : R) where postulate notfieldB : Set open module NotRecBI {{r : R}} = NotRecordB r public record RecordB : Set₁ where field fieldB : Set open module RecBI {{r : RecordB}} = RecordB r public open module ModBA = ModuleB postulate myRecB : RecordB myR : R test₀ : fieldB {{myRecB}} test₀ = {!!} test₁ : ModuleB.RecordB.fieldB myRecB test₁ = {!!} test₂ : notfieldB {{myR}} test₂ = {!!} test₃ : ModuleB.NotRecordB.notfieldB myR test₃ = {!!}
{ "alphanum_fraction": 0.6524701874, "avg_line_length": 15.4473684211, "ext": "agda", "hexsha": "9145c5c39e94a61ce2ea233c62e324ef6bdf46e7", "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/Issue4857.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/Issue4857.agda", "max_line_length": 54, "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/Issue4857.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 193, "size": 587 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Substitution.Reduction {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.LogicalRelation.Properties open import Definition.LogicalRelation.Substitution open import Definition.Untyped using (Con ; Term) open import Tools.Nat open import Tools.Product private variable n : Nat Γ : Con Term n -- Weak head expansion of valid terms. redSubstTermᵛ : ∀ {A t u l} → ([Γ] : ⊩ᵛ Γ) → Γ ⊩ᵛ t ⇒ u ∷ A / [Γ] → ([A] : Γ ⊩ᵛ⟨ l ⟩ A / [Γ]) → Γ ⊩ᵛ⟨ l ⟩ u ∷ A / [Γ] / [A] → Γ ⊩ᵛ⟨ l ⟩ t ∷ A / [Γ] / [A] × Γ ⊩ᵛ⟨ l ⟩ t ≡ u ∷ A / [Γ] / [A] redSubstTermᵛ [Γ] t⇒u [A] [u] = (λ ⊢Δ [σ] → let [σA] = proj₁ ([A] ⊢Δ [σ]) [σt] , [σt≡σu] = redSubstTerm (t⇒u ⊢Δ [σ]) (proj₁ ([A] ⊢Δ [σ])) (proj₁ ([u] ⊢Δ [σ])) in [σt] , (λ [σ′] [σ≡σ′] → let [σ′A] = proj₁ ([A] ⊢Δ [σ′]) [σA≡σ′A] = proj₂ ([A] ⊢Δ [σ]) [σ′] [σ≡σ′] [σ′t] , [σ′t≡σ′u] = redSubstTerm (t⇒u ⊢Δ [σ′]) (proj₁ ([A] ⊢Δ [σ′])) (proj₁ ([u] ⊢Δ [σ′])) in transEqTerm [σA] [σt≡σu] (transEqTerm [σA] ((proj₂ ([u] ⊢Δ [σ])) [σ′] [σ≡σ′]) (convEqTerm₂ [σA] [σ′A] [σA≡σ′A] (symEqTerm [σ′A] [σ′t≡σ′u]))))) , (λ ⊢Δ [σ] → proj₂ (redSubstTerm (t⇒u ⊢Δ [σ]) (proj₁ ([A] ⊢Δ [σ])) (proj₁ ([u] ⊢Δ [σ]))))
{ "alphanum_fraction": 0.3814547474, "avg_line_length": 37.5208333333, "ext": "agda", "hexsha": "37a13111faf1d338e7616a0c89196be4f8597ccc", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-11-27T15:58:33.000Z", "max_forks_repo_forks_event_min_datetime": "2017-10-18T14:18:20.000Z", "max_forks_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "fhlkfy/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Substitution/Reduction.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391", "max_issues_repo_issues_event_max_datetime": "2021-02-22T10:37:24.000Z", "max_issues_repo_issues_event_min_datetime": "2017-06-22T12:49:23.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "fhlkfy/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Substitution/Reduction.agda", "max_line_length": 85, "max_stars_count": 30, "max_stars_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "fhlkfy/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Substitution/Reduction.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:01:07.000Z", "max_stars_repo_stars_event_min_datetime": "2017-05-20T03:05:21.000Z", "num_tokens": 676, "size": 1801 }
{-# OPTIONS --no-termination-check #-} module PragmasApplyOnlyToCurrentModule where import Imports.NonTerminating
{ "alphanum_fraction": 0.8103448276, "avg_line_length": 19.3333333333, "ext": "agda", "hexsha": "94c05e2d585beaba717a1becb9b31fd2da58c074", "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/PragmasApplyOnlyToCurrentModule.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/PragmasApplyOnlyToCurrentModule.agda", "max_line_length": 44, "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/PragmasApplyOnlyToCurrentModule.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": 25, "size": 116 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.2GroupoidTruncation where open import Cubical.HITs.2GroupoidTruncation.Base public open import Cubical.HITs.2GroupoidTruncation.Properties public
{ "alphanum_fraction": 0.8165137615, "avg_line_length": 36.3333333333, "ext": "agda", "hexsha": "b7d6fcfb081159bf4bb5bff2c94c13235c5e17ed", "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/HITs/2GroupoidTruncation.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/HITs/2GroupoidTruncation.agda", "max_line_length": 62, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/HITs/2GroupoidTruncation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 63, "size": 218 }
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-} module Cubical.Structures.Queue where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Functions.FunExtEquiv open import Cubical.Foundations.Equiv open import Cubical.Foundations.SIP open import Cubical.Structures.Axioms open import Cubical.Structures.Macro open import Cubical.Structures.Auto open import Cubical.Data.Unit open import Cubical.Data.Maybe as Maybe open import Cubical.Data.Sigma open import Cubical.Data.List -- Developing Queues as a standard notion of structure, see -- https://github.com/ecavallo/cubical/blob/queue/Cubical/Experiments/Queue.agda -- for the original development private variable ℓ ℓ' : Level -- We start fixing a set A on which we define what it means for a type Q to have -- a Queue structure (wrt. A) module Queues-on (A : Type ℓ) (Aset : isSet A) where -- A Queue structure has three components, the empty Queue, an enqueue function and a dequeue function -- We first deal with enq and deq as separate structures -- deq as a structure -- First, a few preliminary results that we will need later deqMap : {X Y : Type ℓ} → (X → Y) → Maybe (X × A) → Maybe (Y × A) deqMap = map-Maybe ∘ map-fst deqMapId : {X : Type ℓ} → ∀ r → deqMap (idfun X) r ≡ r deqMapId = map-Maybe-id deqMap-∘ :{B C D : Type ℓ} (g : C → D) (f : B → C) → ∀ r → deqMap {X = C} g (deqMap f r) ≡ deqMap (λ b → g (f b)) r deqMap-∘ g f nothing = refl deqMap-∘ g f (just (b , a)) = refl -- Now we can do Queues: rawQueueDesc = autoDesc (λ (X : Type ℓ) → X × (A → X → X) × (X → Transp[ Maybe (X × A) ])) open Macro ℓ rawQueueDesc public renaming ( structure to RawQueueStructure ; equiv to RawQueueEquivStr ; univalent to rawQueueUnivalentStr ) RawQueue : Type (ℓ-suc ℓ) RawQueue = TypeWithStr ℓ RawQueueStructure returnOrEnq : {Q : Type ℓ} → RawQueueStructure Q → A → Maybe (Q × A) → Q × A returnOrEnq (emp , enq , _) a qr = Maybe.rec (emp , a) (λ {(q , b) → enq a q , b}) qr QueueAxioms : (Q : Type ℓ) → RawQueueStructure Q → Type ℓ QueueAxioms Q S@(emp , enq , deq) = (isSet Q) × (deq emp ≡ nothing) × (∀ a q → deq (enq a q) ≡ just (returnOrEnq S a (deq q))) × (∀ a a' q q' → enq a q ≡ enq a' q' → (a ≡ a') × (q ≡ q')) × (∀ q q' → deq q ≡ deq q' → q ≡ q') isPropQueueAxioms : ∀ Q S → isProp (QueueAxioms Q S) isPropQueueAxioms Q S = isPropΣ isPropIsSet (λ Qset → isProp×3 (isOfHLevelDeq Qset _ _) (isPropΠ2 λ _ _ → isOfHLevelDeq Qset _ _) (isPropΠ3 λ _ _ _ → isPropΠ2 λ _ _ → isProp× (Aset _ _) (Qset _ _)) (isPropΠ3 λ _ _ _ → Qset _ _)) where isOfHLevelDeq : isSet Q → isOfHLevel 2 (Maybe (Q × A)) isOfHLevelDeq Qset = isOfHLevelMaybe 0 (isSet× Qset Aset) QueueStructure : Type ℓ → Type ℓ QueueStructure = AxiomsStructure RawQueueStructure QueueAxioms Queue : Type (ℓ-suc ℓ) Queue = TypeWithStr ℓ QueueStructure QueueEquivStr : StrEquiv QueueStructure ℓ QueueEquivStr = AxiomsEquivStr RawQueueEquivStr QueueAxioms queueUnivalentStr : UnivalentStr QueueStructure QueueEquivStr queueUnivalentStr = axiomsUnivalentStr RawQueueEquivStr isPropQueueAxioms rawQueueUnivalentStr FiniteQueueAxioms : (Q : Type ℓ) → QueueStructure Q → Type ℓ FiniteQueueAxioms Q ((emp , enq , _) , _) = isEquiv (foldr enq emp) isPropFiniteQueueAxioms : ∀ Q S → isProp (FiniteQueueAxioms Q S) isPropFiniteQueueAxioms Q S = isPropIsEquiv _ FiniteQueueStructure : Type ℓ → Type ℓ FiniteQueueStructure = AxiomsStructure QueueStructure FiniteQueueAxioms FiniteQueue : Type (ℓ-suc ℓ) FiniteQueue = TypeWithStr ℓ FiniteQueueStructure FiniteQueueEquivStr : StrEquiv FiniteQueueStructure ℓ FiniteQueueEquivStr = AxiomsEquivStr QueueEquivStr FiniteQueueAxioms finiteQueueUnivalentStr : UnivalentStr FiniteQueueStructure FiniteQueueEquivStr finiteQueueUnivalentStr = axiomsUnivalentStr QueueEquivStr isPropFiniteQueueAxioms queueUnivalentStr
{ "alphanum_fraction": 0.6965550941, "avg_line_length": 35.2844827586, "ext": "agda", "hexsha": "6d788420b95edd6c8e80174107fce6f98b841455", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Structures/Queue.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Structures/Queue.agda", "max_line_length": 103, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Structures/Queue.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1355, "size": 4093 }
{-# OPTIONS --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Substitution.Introductions.Castlemmas {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Properties import Definition.Typed.Weakening as Twk open import Definition.Typed.EqualityRelation open import Definition.Typed.RedSteps open import Definition.LogicalRelation open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.Properties open import Definition.LogicalRelation.Application open import Definition.LogicalRelation.Substitution import Definition.LogicalRelation.Weakening as Lwk open import Definition.LogicalRelation.Substitution.Properties import Definition.LogicalRelation.Substitution.Irrelevance as S open import Definition.LogicalRelation.Substitution.Reflexivity open import Definition.LogicalRelation.Substitution.Weakening -- open import Definition.LogicalRelation.Substitution.Introductions.Nat open import Definition.LogicalRelation.Substitution.Introductions.Empty -- open import Definition.LogicalRelation.Substitution.Introductions.Pi -- open import Definition.LogicalRelation.Substitution.Introductions.SingleSubst open import Definition.LogicalRelation.Substitution.Introductions.Universe open import Definition.LogicalRelation.Substitution.MaybeEmbed open import Tools.Product open import Tools.Empty import Tools.Unit as TU import Tools.PropositionalEquality as PE import Data.Nat as Nat module cast-ΠΠ-lemmas {Γ rF F F₁} (⊢Γ : ⊢ Γ) (⊢F : Γ ⊢ F ^ [ rF , ι ⁰ ]) ([F] : ∀ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ F ^ [ rF , ι ⁰ ]) (⊢F₁ : Γ ⊢ F₁ ^ [ rF , ι ⁰ ]) ([F₁] : ∀ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ F₁ ^ [ rF , ι ⁰ ]) (recursor : ∀ {x e ρ Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([x] : Δ ⊩⟨ ι ⁰ ⟩ x ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) (⊢e : Δ ⊢ e ∷ Id (Univ rF ⁰) (wk ρ F₁) (wk ρ F) ^ [ % , ι ¹ ]) → Δ ⊩⟨ ι ⁰ ⟩ cast ⁰ (wk ρ F₁) (wk ρ F) e x ∷ wk ρ F ^ [ rF , ι ⁰ ] / [F] [ρ] ⊢Δ) (extrecursor : ∀ {ρ Δ x y e e′} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([x] : Δ ⊩⟨ ι ⁰ ⟩ x ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → ([y] : Δ ⊩⟨ ι ⁰ ⟩ y ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → ([x≡y] : Δ ⊩⟨ ι ⁰ ⟩ x ≡ y ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → (⊢e : Δ ⊢ e ∷ Id (Univ rF ⁰) (wk ρ F₁) (wk ρ F) ^ [ % , ι ¹ ]) → (⊢e′ : Δ ⊢ e′ ∷ Id (Univ rF ⁰) (wk ρ F₁) (wk ρ F) ^ [ % , ι ¹ ]) → Δ ⊩⟨ ι ⁰ ⟩ cast ⁰ (wk ρ F₁) (wk ρ F) e x ≡ cast ⁰ (wk ρ F₁) (wk ρ F) e′ y ∷ wk ρ F ^ [ rF , ι ⁰ ] / [F] [ρ] ⊢Δ) where b = λ ρ e x → cast ⁰ (wk ρ F₁) (wk ρ F) (Idsym (Univ rF ⁰) (wk ρ F) (wk ρ F₁) e) x [b] : ∀ {ρ Δ e x} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → (Δ ⊢ e ∷ Id (Univ rF ⁰) (wk ρ F) (wk ρ F₁) ^ [ % , ι ¹ ]) → (Δ ⊩⟨ ι ⁰ ⟩ x ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ b ρ e x ∷ wk ρ F ^ [ rF , ι ⁰ ] / [F] [ρ] ⊢Δ [b] [ρ] ⊢Δ ⊢e [x] = let ⊢e′ = Idsymⱼ (univ 0<1 ⊢Δ) (un-univ (escape ([F] [ρ] ⊢Δ))) (un-univ (escape ([F₁] [ρ] ⊢Δ))) ⊢e in recursor [ρ] ⊢Δ [x] ⊢e′ [bext] : ∀ {ρ Δ e e′ x y} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → (Δ ⊢ e ∷ Id (Univ rF ⁰) (wk ρ F) (wk ρ F₁) ^ [ % , ι ¹ ]) → (Δ ⊢ e′ ∷ Id (Univ rF ⁰) (wk ρ F) (wk ρ F₁) ^ [ % , ι ¹ ]) → (Δ ⊩⟨ ι ⁰ ⟩ x ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → (Δ ⊩⟨ ι ⁰ ⟩ y ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → (Δ ⊩⟨ ι ⁰ ⟩ x ≡ y ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ b ρ e x ≡ b ρ e′ y ∷ wk ρ F ^ [ rF , ι ⁰ ] / [F] [ρ] ⊢Δ [bext] [ρ] ⊢Δ ⊢e ⊢e′ [x] [y] [x≡y] = let ⊢syme = Idsymⱼ (univ 0<1 ⊢Δ) (un-univ (escape ([F] [ρ] ⊢Δ))) (un-univ (escape ([F₁] [ρ] ⊢Δ))) ⊢e ⊢syme′ = Idsymⱼ (univ 0<1 ⊢Δ) (un-univ (escape ([F] [ρ] ⊢Δ))) (un-univ (escape ([F₁] [ρ] ⊢Δ))) ⊢e′ in extrecursor [ρ] ⊢Δ [x] [y] [x≡y] ⊢syme ⊢syme′ module cast-ΠΠ-lemmas-2 {t e f Γ A B F rF G F₁ G₁} (⊢Γ : ⊢ Γ) (⊢A : Γ ⊢ A ^ [ ! , ι ⁰ ]) (⊢ΠFG : Γ ⊢ Π F ^ rF ° ⁰ ▹ G ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (D : Γ ⊢ A ⇒* Π F ^ rF ° ⁰ ▹ G ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (⊢F : Γ ⊢ F ^ [ rF , ι ⁰ ]) (⊢G : (Γ ∙ F ^ [ rF , ι ⁰ ]) ⊢ G ^ [ ! , ι ⁰ ]) (A≡A : Γ ⊢ (Π F ^ rF ° ⁰ ▹ G ° ⁰ ° ⁰) ≅ (Π F ^ rF ° ⁰ ▹ G ° ⁰ ° ⁰) ^ [ ! , ι ⁰ ]) ([F] : ∀ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ F ^ [ rF , ι ⁰ ]) ([G] : ∀ {ρ} {Δ} {a} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F ^ [ rF , ι ⁰ ] / ([F] [ρ] ⊢Δ)) → (Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G [ a ] ^ [ ! , ι ⁰ ])) (G-ext : ∀ {ρ} {Δ} {a} {b} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F ^ [ rF , ι ⁰ ] / ([F] [ρ] ⊢Δ)) ([b] : Δ ⊩⟨ ι ⁰ ⟩ b ∷ wk ρ F ^ [ rF , ι ⁰ ] / ([F] [ρ] ⊢Δ)) ([a≡b] : Δ ⊩⟨ ι ⁰ ⟩ a ≡ b ∷ wk ρ F ^ [ rF , ι ⁰ ] / ([F] [ρ] ⊢Δ)) → (Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G [ a ] ≡ wk (lift ρ) G [ b ] ^ [ ! , ι ⁰ ] / ([G] [ρ] ⊢Δ [a]))) (⊢B : Γ ⊢ B ^ [ ! , ι ⁰ ]) (⊢ΠF₁G₁ : Γ ⊢ Π F₁ ^ rF ° ⁰ ▹ G₁ ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (D₁ : Γ ⊢ B ⇒* Π F₁ ^ rF ° ⁰ ▹ G₁ ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (⊢F₁ : Γ ⊢ F₁ ^ [ rF , ι ⁰ ]) (⊢G₁ : (Γ ∙ F₁ ^ [ rF , ι ⁰ ]) ⊢ G₁ ^ [ ! , ι ⁰ ]) (A₁≡A₁ : Γ ⊢ (Π F₁ ^ rF ° ⁰ ▹ G₁ ° ⁰ ° ⁰) ≅ (Π F₁ ^ rF ° ⁰ ▹ G₁ ° ⁰ ° ⁰) ^ [ ! , ι ⁰ ]) ([F₁] : ∀ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ F₁ ^ [ rF , ι ⁰ ]) ([G₁] : ∀ {ρ} {Δ} {a} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / ([F₁] [ρ] ⊢Δ)) → (Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₁ [ a ] ^ [ ! , ι ⁰ ])) (G₁-ext : ∀ {ρ} {Δ} {a} {b} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / ([F₁] [ρ] ⊢Δ)) ([b] : Δ ⊩⟨ ι ⁰ ⟩ b ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / ([F₁] [ρ] ⊢Δ)) ([a≡b] : Δ ⊩⟨ ι ⁰ ⟩ a ≡ b ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / ([F₁] [ρ] ⊢Δ)) → (Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₁ [ a ] ≡ wk (lift ρ) G₁ [ b ] ^ [ ! , ι ⁰ ] / ([G₁] [ρ] ⊢Δ [a]))) (⊢e : Γ ⊢ e ∷ Id (U ⁰) A B ^ [ % , ι ¹ ]) (recursor : ∀ {ρ Δ x y t e} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([x] : Δ ⊩⟨ ι ⁰ ⟩ x ∷ wk ρ F ^ [ rF , ι ⁰ ] / [F] [ρ] ⊢Δ) ([y] : Δ ⊩⟨ ι ⁰ ⟩ y ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) ([t] : Δ ⊩⟨ ι ⁰ ⟩ t ∷ wk (lift ρ) G [ x ] ^ [ ! , ι ⁰ ] / [G] [ρ] ⊢Δ [x]) (⊢e : Δ ⊢ e ∷ Id (U ⁰) (wk (lift ρ) G [ x ]) (wk (lift ρ) G₁ [ y ]) ^ [ % , ι ¹ ]) → Δ ⊩⟨ ι ⁰ ⟩ cast ⁰ (wk (lift ρ) G [ x ]) (wk (lift ρ) G₁ [ y ]) e t ∷ wk (lift ρ) G₁ [ y ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [y]) (extrecursor : ∀ {ρ Δ x x′ y y′ t t′ e e′} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([x] : Δ ⊩⟨ ι ⁰ ⟩ x ∷ wk ρ F ^ [ rF , ι ⁰ ] / [F] [ρ] ⊢Δ) → ([x′] : Δ ⊩⟨ ι ⁰ ⟩ x′ ∷ wk ρ F ^ [ rF , ι ⁰ ] / [F] [ρ] ⊢Δ) → ([x≡x′] : Δ ⊩⟨ ι ⁰ ⟩ x ≡ x′ ∷ wk ρ F ^ [ rF , ι ⁰ ] / [F] [ρ] ⊢Δ) → ([y] : Δ ⊩⟨ ι ⁰ ⟩ y ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → ([y′] : Δ ⊩⟨ ι ⁰ ⟩ y′ ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → ([y≡y′] : Δ ⊩⟨ ι ⁰ ⟩ y ≡ y′ ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → ([t] : Δ ⊩⟨ ι ⁰ ⟩ t ∷ wk (lift ρ) G [ x ] ^ [ ! , ι ⁰ ] / [G] [ρ] ⊢Δ [x]) → ([t′] : Δ ⊩⟨ ι ⁰ ⟩ t′ ∷ wk (lift ρ) G [ x′ ] ^ [ ! , ι ⁰ ] / [G] [ρ] ⊢Δ [x′]) → ([t≡t′] : Δ ⊩⟨ ι ⁰ ⟩ t ≡ t′ ∷ wk (lift ρ) G [ x ] ^ [ ! , ι ⁰ ] / [G] [ρ] ⊢Δ [x]) → (⊢e : Δ ⊢ e ∷ Id (U ⁰) (wk (lift ρ) G [ x ]) (wk (lift ρ) G₁ [ y ]) ^ [ % , ι ¹ ]) → (⊢e′ : Δ ⊢ e′ ∷ Id (U ⁰) (wk (lift ρ) G [ x′ ]) (wk (lift ρ) G₁ [ y′ ]) ^ [ % , ι ¹ ]) → Δ ⊩⟨ ι ⁰ ⟩ cast ⁰ (wk (lift ρ) G [ x ]) (wk (lift ρ) G₁ [ y ]) e t ≡ cast ⁰ (wk (lift ρ) G [ x′ ]) (wk (lift ρ) G₁ [ y′ ]) e′ t′ ∷ wk (lift ρ) G₁ [ y ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [y]) (⊢t : Γ ⊢ t ∷ Π F ^ rF ° ⁰ ▹ G ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (Df : Γ ⊢ t ⇒* f ∷ Π F ^ rF ° ⁰ ▹ G ° ⁰ ° ⁰ ^ ι ⁰) ([fext] : ∀ {ρ Δ a b} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F ^ [ rF , ι ⁰ ] / [F] [ρ] ⊢Δ) ([b] : Δ ⊩⟨ ι ⁰ ⟩ b ∷ wk ρ F ^ [ rF , ι ⁰ ] / [F] [ρ] ⊢Δ) ([a≡b] : Δ ⊩⟨ ι ⁰ ⟩ a ≡ b ∷ wk ρ F ^ [ rF , ι ⁰ ] / [F] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ f ∘ a ^ ⁰ ≡ wk ρ f ∘ b ^ ⁰ ∷ wk (lift ρ) G [ a ] ^ [ ! , ι ⁰ ] / [G] [ρ] ⊢Δ [a]) ([f] : ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F ^ [ rF , ι ⁰ ] / [F] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ f ∘ a ^ ⁰ ∷ wk (lift ρ) G [ a ] ^ [ ! , ι ⁰ ] / [G] [ρ] ⊢Δ [a]) ([b] : ∀ {ρ Δ e x} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) (⊢e : Δ ⊢ e ∷ Id (Univ rF ⁰) (wk ρ F) (wk ρ F₁) ^ [ % , ι ¹ ]) ([x] : Δ ⊩⟨ ι ⁰ ⟩ x ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ cast ⁰ (wk ρ F₁) (wk ρ F) (Idsym (Univ rF ⁰) (wk ρ F) (wk ρ F₁) e) x ∷ wk ρ F ^ [ rF , ι ⁰ ] / [F] [ρ] ⊢Δ) ([bext] : ∀ {ρ Δ e e′ x y} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → (Δ ⊢ e ∷ Id (Univ rF ⁰) (wk ρ F) (wk ρ F₁) ^ [ % , ι ¹ ]) → (Δ ⊢ e′ ∷ Id (Univ rF ⁰) (wk ρ F) (wk ρ F₁) ^ [ % , ι ¹ ]) → (Δ ⊩⟨ ι ⁰ ⟩ x ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → (Δ ⊩⟨ ι ⁰ ⟩ y ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → (Δ ⊩⟨ ι ⁰ ⟩ x ≡ y ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ cast ⁰ (wk ρ F₁) (wk ρ F) (Idsym (Univ rF ⁰) (wk ρ F) (wk ρ F₁) e) x ≡ cast ⁰ (wk ρ F₁) (wk ρ F) (Idsym (Univ rF ⁰) (wk ρ F) (wk ρ F₁) e′) y ∷ wk ρ F ^ [ rF , ι ⁰ ] / [F] [ρ] ⊢Δ) where b = λ ρ e x → cast ⁰ (wk ρ F₁) (wk ρ F) (Idsym (Univ rF ⁰) (wk ρ F) (wk ρ F₁) e) x ⊢IdFF₁ : Γ ⊢ Id (Univ rF ⁰) F F₁ ^ [ % , ι ¹ ] ⊢IdFF₁ = univ (Idⱼ (univ 0<1 ⊢Γ) (un-univ ⊢F) (un-univ ⊢F₁)) Δ₀ = Γ ∙ Id (Univ rF ⁰) F F₁ ^ [ % , ι ¹ ] ∙ wk1 F₁ ^ [ rF , ι ⁰ ] ρ₀ = (step (step id)) ⊢IdG₁G : Γ ∙ Id (Univ rF ⁰) F F₁ ^ [ % , ι ¹ ] ⊢ Π (wk1 F₁) ^ rF ° ⁰ ▹ Id (U ⁰) ((wk1d G) [ b ρ₀ (var 1) (var 0) ]↑) (wk1d G₁) ° ¹ ° ¹ ^ [ % , ι ¹ ] ⊢IdG₁G = let ⊢Δ₀ : ⊢ Δ₀ ⊢Δ₀ = ⊢Γ ∙ ⊢IdFF₁ ∙ univ (Twk.wkTerm (Twk.step Twk.id) (⊢Γ ∙ ⊢IdFF₁) (un-univ ⊢F₁)) [ρ₀] : ρ₀ Twk.∷ Δ₀ ⊆ Γ [ρ₀] = Twk.step (Twk.step Twk.id) [0] : Δ₀ ⊩⟨ ι ⁰ ⟩ var 0 ∷ wk ρ₀ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ₀] ⊢Δ₀ [0] = let x = (var ⊢Δ₀ (PE.subst (λ X → 0 ∷ X ^ [ rF , ι ⁰ ] ∈ Δ₀) (wk1-wk (step id) F₁) here)) in neuTerm ([F₁] [ρ₀] ⊢Δ₀) (var 0) x (~-var x) ⊢1 : Δ₀ ⊢ (var 1) ∷ Id (Univ rF ⁰) (wk ρ₀ F) (wk ρ₀ F₁) ^ [ % , ι ¹ ] ⊢1 = var ⊢Δ₀ (PE.subst₂ (λ X Y → 1 ∷ Id (Univ rF ⁰) X Y ^ [ % , ι ¹ ] ∈ Δ₀) (wk1-wk (step id) F) (wk1-wk (step id) F₁) (there here)) ⊢G₀ : Δ₀ ⊢ wk (lift ρ₀) G [ b ρ₀ (var 1) (var 0) ] ^ [ ! , ι ⁰ ] ⊢G₀ = escape ([G] [ρ₀] ⊢Δ₀ ([b] [ρ₀] ⊢Δ₀ ⊢1 [0])) ⊢G₀′ = PE.subst (λ X → Δ₀ ⊢ X ^ [ ! , ι ⁰ ]) (PE.sym (cast-subst-lemma2 G (b ρ₀ (var 1) (var 0)))) ⊢G₀ x₀ : Δ₀ ⊢ Id (U ⁰) ((wk1d G) [ b ρ₀ (var 1) (var 0) ]↑) (wk1d G₁) ∷ SProp ¹ ^ [ ! , ∞ ] x₀ = Idⱼ (univ 0<1 ⊢Δ₀) (un-univ ⊢G₀′) (un-univ (Twk.wk (Twk.lift (Twk.step Twk.id)) ⊢Δ₀ ⊢G₁)) x₁ = Πⱼ <is≤ 0<1 ▹ ≡is≤ PE.refl ▹ Twk.wkTerm (Twk.step Twk.id) (⊢Γ ∙ ⊢IdFF₁) (un-univ ⊢F₁) ▹ x₀ in univ x₁ ⊢e′ : Γ ⊢ e ∷ ∃ (Id (Univ rF ⁰) F F₁) ▹ (Π (wk1 F₁) ^ rF ° ⁰ ▹ Id (U ⁰) ((wk1d G) [ b ρ₀ (var 1) (var 0) ]↑) (wk1d G₁) ° ¹ ° ¹) ^ [ % , ι ¹ ] ⊢e′ = let b₀ = cast ⁰ (wk1 (wk1 F₁)) (wk1 (wk1 F)) (Idsym (Univ rF ⁰) (wk1 (wk1 F)) (wk1 (wk1 F₁)) (var 1)) (var 0) b≡b₀ : b ρ₀ (var 1) (var 0) PE.≡ b₀ b≡b₀ = PE.cong₂ (λ X Y → cast ⁰ Y X (Idsym (Univ rF ⁰) X Y (var 1)) (var 0)) (PE.sym (wk1-wk (step id) F)) (PE.sym (wk1-wk (step id) F₁)) x₀ = conv ⊢e (univ (Id-cong (refl (univ 0<1 ⊢Γ)) (un-univ≡ (subset* D)) (un-univ≡ (subset* D₁)))) x₁ = conv x₀ (univ (Id-U-ΠΠ (un-univ ⊢F) (un-univ ⊢G) (un-univ ⊢F₁) (un-univ ⊢G₁))) x₂ = PE.subst (λ X → Γ ⊢ e ∷ ∃ (Id (Univ rF ⁰) F F₁) ▹ (Π (wk1 F₁) ^ rF ° ⁰ ▹ Id (U ⁰) ((wk1d G) [ X ]↑) (wk1d G₁) ° ¹ ° ¹) ^ [ % , ι ¹ ]) (PE.sym b≡b₀) x₁ in x₂ ⊢fste : Γ ⊢ fst e ∷ Id (Univ rF ⁰) F F₁ ^ [ % , ι ¹ ] ⊢fste = fstⱼ (un-univ ⊢IdFF₁) (un-univ ⊢IdG₁G) ⊢e′ ⊢snde : Γ ⊢ snd e ∷ Π F₁ ^ rF ° ⁰ ▹ Id (U ⁰) (wk1d G [ b (step id) (fst (wk1 e)) (var 0) ]) G₁ ° ¹ ° ¹ ^ [ % , ι ¹ ] ⊢snde = let x₀ = sndⱼ (un-univ ⊢IdFF₁) (un-univ ⊢IdG₁G) ⊢e′ x₁ = PE.subst₂ (λ X Y → Γ ⊢ snd e ∷ (Π X ^ rF ° ⁰ ▹ subst _ (Id (U ⁰) Y (wk1d G₁)) ° ¹ ° ¹) ^ [ % , ι ¹ ]) (wk1-singleSubst F₁ (fst e)) (cast-subst-lemma2 G (b ρ₀ (var 1) (var 0))) x₀ x₂ = PE.subst₂ (λ X Y → Γ ⊢ snd e ∷ Π F₁ ^ rF ° ⁰ ▹ Id (U ⁰) X Y ° ¹ ° ¹ ^ [ % , ι ¹ ]) (singleSubstLift (wk (lift ρ₀) G) (b ρ₀ (var 1) (var 0))) (wk1d-singleSubst G₁ (fst e)) x₁ σ = liftSubst (sgSubst (fst e)) b≡b : subst σ (b ρ₀ (var 1) (var 0)) PE.≡ b (step id) (fst (wk1 e)) (var 0) b≡b = PE.trans (PE.cong (λ X → cast ⁰ (subst σ (wk ρ₀ F₁)) (subst σ (wk ρ₀ F)) X (var 0)) (subst-Idsym σ (Univ rF ⁰) (wk ρ₀ F) (wk ρ₀ F₁) (var 1))) (PE.cong₂ (λ X Y → cast ⁰ Y X (Idsym (Univ rF ⁰) X Y (fst (wk1 e))) (var 0)) (cast-subst-lemma5 F (fst e)) (cast-subst-lemma5 F₁ (fst e))) x₃ = PE.subst₂ (λ X Y → Γ ⊢ snd e ∷ Π F₁ ^ rF ° ⁰ ▹ Id (U ⁰) (X [ Y ]) G₁ ° ¹ ° ¹ ^ [ % , ι ¹ ]) (cast-subst-lemma3 G (fst e)) b≡b x₂ in x₃ ⊢snde′ : ∀ {ρ Δ x} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → (⊢x : Δ ⊢ x ∷ wk ρ F₁ ^ [ rF , ι ⁰ ]) → Δ ⊢ snd (wk ρ e) ∘ x ^ ¹ ∷ Id (U ⁰) (wk (lift ρ) G [ b ρ (fst (wk ρ e)) x ]) (wk (lift ρ) G₁ [ x ]) ^ [ % , ι ¹ ] ⊢snde′ {ρ} {Δ} {x} [ρ] ⊢Δ ⊢x = let -- I should probably make some generic lemma about pushing weakening and subst in b y₀ = PE.trans (PE.cong (λ X → X [ x ]) (wk-Idsym (lift ρ) (Univ rF ⁰) (wk1 F) (wk1 F₁) (fst (wk1 e)))) (PE.trans (subst-Idsym (sgSubst x) (Univ rF ⁰) (wk (lift ρ) (wk1 F)) (wk (lift ρ) (wk1 F₁)) (fst (wk (lift ρ) (wk1 e)))) (PE.cong₃ (λ X Y Z → Idsym (Univ rF ⁰) X Y (fst Z)) (irrelevant-subst′ ρ F x) (irrelevant-subst′ ρ F₁ x) (irrelevant-subst′ ρ e x))) y₁ : wk (lift ρ) (b (step id) (fst (wk1 e)) (var 0)) [ x ] PE.≡ b ρ (fst (wk ρ e)) x y₁ = PE.cong₃ (λ X Y Z → cast ⁰ X Y Z x) (irrelevant-subst′ ρ F₁ x) (irrelevant-subst′ ρ F x) y₀ x₀ : Δ ⊢ (wk ρ (snd e)) ∘ x ^ ¹ ∷ Id (U ⁰) (wk (lift ρ) (wk1d G [ b (step id) (fst (wk1 e)) (var 0) ]) [ x ]) (wk (lift ρ) G₁ [ x ]) ^ [ % , ι ¹ ] x₀ = Twk.wkTerm [ρ] ⊢Δ ⊢snde ∘ⱼ ⊢x x₁ = PE.cong₂ (λ X Y → X [ Y ]) (cast-subst-lemma4 ρ x G) y₁ x₂ = PE.trans (singleSubstLift (wk (lift (lift ρ)) (wk1d G)) (wk (lift ρ) (b (step id) (fst (wk1 e)) (var 0)))) x₁ x₃ = PE.trans (PE.cong (λ X → X [ x ]) (wk-β {a = b (step id) (fst (wk1 e)) (var 0)} (wk1d G))) x₂ x₄ = PE.subst (λ X → Δ ⊢ snd (wk ρ e) ∘ x ^ ¹ ∷ Id (U ⁰) X (wk (lift ρ) G₁ [ x ]) ^ [ % , ι ¹ ]) x₃ x₀ in x₄ g = λ ρ x → cast ⁰ (wk (lift ρ) G [ b ρ (fst (wk ρ e)) x ]) (wk (lift ρ) G₁ [ x ]) ((snd (wk ρ e)) ∘ x ^ ¹) ((wk ρ t) ∘ (b ρ (fst (wk ρ e)) x) ^ ⁰) [g] : ∀ {ρ Δ x} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([x] : Δ ⊩⟨ ι ⁰ ⟩ x ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ g ρ x ∷ wk (lift ρ) G₁ [ x ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [x] [g] {ρ} {Δ} {x} [ρ] ⊢Δ [x] = let [b]′ = [b] [ρ] ⊢Δ (Twk.wkTerm [ρ] ⊢Δ ⊢fste) [x] [t] = proj₁ (redSubst*Term (appRed* (escapeTerm ([F] [ρ] ⊢Δ) [b]′) (Twk.wkRed*Term [ρ] ⊢Δ Df)) ([G] [ρ] ⊢Δ [b]′) ([f] [ρ] ⊢Δ [b]′)) in recursor [ρ] ⊢Δ [b]′ [x] [t] (⊢snde′ [ρ] ⊢Δ (escapeTerm ([F₁] [ρ] ⊢Δ) [x])) [gext] : ∀ {ρ Δ x y} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([x] : Δ ⊩⟨ ι ⁰ ⟩ x ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → ([y] : Δ ⊩⟨ ι ⁰ ⟩ y ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → ([x≡y] : Δ ⊩⟨ ι ⁰ ⟩ x ≡ y ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ g ρ x ≡ g ρ y ∷ wk (lift ρ) G₁ [ x ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [x] [gext] {ρ} {Δ} {x} {y} [ρ] ⊢Δ [x] [y] [x≡y] = let [b₁] = [b] [ρ] ⊢Δ (Twk.wkTerm [ρ] ⊢Δ ⊢fste) [x] [b₂] = [b] [ρ] ⊢Δ (Twk.wkTerm [ρ] ⊢Δ ⊢fste) [y] [b₁≡b₂] = [bext] [ρ] ⊢Δ (Twk.wkTerm [ρ] ⊢Δ ⊢fste) (Twk.wkTerm [ρ] ⊢Δ ⊢fste) [x] [y] [x≡y] D₁ = (appRed* (escapeTerm ([F] [ρ] ⊢Δ) [b₁]) (Twk.wkRed*Term [ρ] ⊢Δ Df)) D₂ = (appRed* (escapeTerm ([F] [ρ] ⊢Δ) [b₂]) (Twk.wkRed*Term [ρ] ⊢Δ Df)) [t₁] = proj₁ (redSubst*Term D₁ ([G] [ρ] ⊢Δ [b₁]) ([f] [ρ] ⊢Δ [b₁])) [t₂] = proj₁ (redSubst*Term D₂ ([G] [ρ] ⊢Δ [b₂]) ([f] [ρ] ⊢Δ [b₂])) [t₁≡t₂] = redSubst*EqTerm D₁ D₂ ([G] [ρ] ⊢Δ [b₁]) ([G] [ρ] ⊢Δ [b₂]) (G-ext [ρ] ⊢Δ [b₁] [b₂] [b₁≡b₂]) ([f] [ρ] ⊢Δ [b₁]) ([f] [ρ] ⊢Δ [b₂]) ([fext] [ρ] ⊢Δ [b₁] [b₂] [b₁≡b₂]) in extrecursor [ρ] ⊢Δ [b₁] [b₂] [b₁≡b₂] [x] [y] [x≡y] [t₁] [t₂] [t₁≡t₂] (⊢snde′ [ρ] ⊢Δ (escapeTerm ([F₁] [ρ] ⊢Δ) [x])) (⊢snde′ [ρ] ⊢Δ (escapeTerm ([F₁] [ρ] ⊢Δ) [y])) Δ₁ = Γ ∙ F₁ ^ [ rF , ι ⁰ ] ⊢Δ₁ : ⊢ Δ₁ ⊢Δ₁ = ⊢Γ ∙ ⊢F₁ ρ₁ = (step id) [ρ₁] : ρ₁ Twk.∷ Δ₁ ⊆ Γ [ρ₁] = Twk.step Twk.id [0] : Δ₁ ⊩⟨ ι ⁰ ⟩ var 0 ∷ wk ρ₁ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ₁] ⊢Δ₁ [0] = neuTerm ([F₁] [ρ₁] ⊢Δ₁) (var 0) (var ⊢Δ₁ here) (~-var (var ⊢Δ₁ here)) ⊢g0 = PE.subst (λ X → Δ₁ ⊢ g (step id) (var 0) ∷ X ^ [ ! , ι ⁰ ]) (wkSingleSubstId G₁) (escapeTerm ([G₁] [ρ₁] ⊢Δ₁ [0]) ([g] [ρ₁] ⊢Δ₁ [0])) ⊢λg : Γ ⊢ lam F₁ ▹ g (step id) (var 0) ^ ⁰ ∷ Π F₁ ^ rF ° ⁰ ▹ G₁ ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ] ⊢λg = lamⱼ (≡is≤ PE.refl) (≡is≤ PE.refl) ⊢F₁ ⊢g0 Dg : Γ ⊢ cast ⁰ A B e t :⇒*: (lam F₁ ▹ g (step id) (var 0) ^ ⁰) ∷ Π F₁ ^ rF ° ⁰ ▹ G₁ ° ⁰ ° ⁰ ^ ι ⁰ Dg = let g0 = lam F₁ ▹ cast ⁰ (G [ b (step id) (fst (wk1 e)) (var 0) ]↑) G₁ ((snd (wk1 e)) ∘ (var 0) ^ ¹) ((wk1 t) ∘ (b (step id) (fst (wk1 e)) (var 0)) ^ ⁰) ^ ⁰ g≡g : g0 PE.≡ lam F₁ ▹ g (step id) (var 0) ^ ⁰ g≡g = PE.cong₂ (λ X Y → lam F₁ ▹ cast ⁰ X Y ((snd (wk1 e)) ∘ (var 0) ^ ¹) ((wk1 t) ∘ (b (step id) (fst (wk1 e)) (var 0)) ^ ⁰) ^ ⁰) (wk1d[]-[]↑ G (b (step id) (fst (wk1 e)) (var 0))) (PE.sym (wkSingleSubstId G₁)) ⊢e′ = conv ⊢e (univ (Id-cong (refl (univ 0<1 ⊢Γ)) (un-univ≡ (subset* D)) (refl (un-univ ⊢B)))) ⊢e″ = conv ⊢e (univ (Id-cong (refl (univ 0<1 ⊢Γ)) (un-univ≡ (subset* D)) (un-univ≡ (subset* D₁)))) in [[ conv (castⱼ (un-univ ⊢A) (un-univ ⊢B) ⊢e (conv ⊢t (sym (subset* D)))) (subset* D₁) , ⊢λg , (conv* (CastRed*Term′ ⊢B ⊢e (conv ⊢t (sym (subset* D))) D ⇨∷* castΠRed* ⊢F ⊢G ⊢e′ ⊢t D₁) (subset* D₁)) ⇨∷* (PE.subst (λ X → Γ ⊢ cast ⁰ (Π F ^ rF ° ⁰ ▹ G ° ⁰ ° ⁰) (Π F₁ ^ rF ° ⁰ ▹ G₁ ° ⁰ ° ⁰) e t ⇒ X ∷ Π F₁ ^ rF ° ⁰ ▹ G₁ ° ⁰ ° ⁰ ^ ι ⁰) g≡g (cast-Π (un-univ ⊢F) (un-univ ⊢G) (un-univ ⊢F₁) (un-univ ⊢G₁) ⊢e″ ⊢t) ⇨ (id ⊢λg)) ]] g≡g : Γ ⊢ (lam F₁ ▹ g (step id) (var 0) ^ ⁰) ≅ (lam F₁ ▹ g (step id) (var 0) ^ ⁰) ∷ Π F₁ ^ rF ° ⁰ ▹ G₁ ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ] g≡g = let ⊢F₁′ = Twk.wk (Twk.step Twk.id) ⊢Δ₁ ⊢F₁ ⊢g0 = escapeTerm ([G₁] [ρ₁] ⊢Δ₁ [0]) ([g] [ρ₁] ⊢Δ₁ [0]) ⊢g0′ = (PE.subst (λ X → Δ₁ ⊢ g (step id) (var 0) ∷ X ^ [ ! , ι ⁰ ]) (wkSingleSubstId G₁) ⊢g0) ⊢g0″ = Twk.wkTerm (Twk.lift (Twk.step Twk.id)) (⊢Δ₁ ∙ ⊢F₁′) ⊢g0′ D : Δ₁ ⊢ (lam (wk1 F₁) ▹ wk1d (g (step id) (var 0)) ^ ⁰) ∘ (var 0) ^ ⁰ ⇒* g (step id) (var 0) ∷ wk1d G₁ [ var 0 ] ^ ι ⁰ D = PE.subst (λ X → Δ₁ ⊢ (lam (wk1 F₁) ▹ wk1d (g (step id) (var 0)) ^ ⁰) ∘ (var 0) ^ ⁰ ⇒ X ∷ wk1d G₁ [ var 0 ] ^ ι ⁰) (wkSingleSubstId (g (step id) (var 0))) (β-red (≡is≤ PE.refl) (≡is≤ PE.refl) ⊢F₁′ ⊢g0″ (var ⊢Δ₁ here)) ⇨ id ⊢g0 [g0] : Δ₁ ⊩⟨ ι ⁰ ⟩ (lam (wk1 F₁) ▹ wk1d (g (step id) (var 0)) ^ ⁰) ∘ (var 0) ^ ⁰ ∷ wk1d G₁ [ var 0 ] ^ [ ! , ι ⁰ ] / [G₁] [ρ₁] ⊢Δ₁ [0] [g0] = proj₁ (redSubst*Term D ([G₁] [ρ₁] ⊢Δ₁ [0]) ([g] [ρ₁] ⊢Δ₁ [0])) x₀ = escapeEqReflTerm ([G₁] [ρ₁] ⊢Δ₁ [0]) [g0] x₁ = PE.subst (λ X → Δ₁ ⊢ (lam (wk1 F₁) ▹ wk1d (g (step id) (var 0)) ^ ⁰) ∘ (var 0) ^ ⁰ ≅ (lam (wk1 F₁) ▹ wk1d (g (step id) (var 0)) ^ ⁰) ∘ (var 0) ^ ⁰ ∷ X ^ [ ! , ι ⁰ ]) (wkSingleSubstId G₁) x₀ in ≅-η-eq (≡is≤ PE.refl) (≡is≤ PE.refl) ⊢F₁ ⊢λg ⊢λg lamₙ lamₙ x₁ g∘a≡ga : ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) → (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → Δ ⊢ wk ρ (lam F₁ ▹ g (step id) (var 0) ^ ⁰) ∘ a ^ ⁰ ⇒* g ρ a ∷ wk (lift ρ) G₁ [ a ] ^ ι ⁰ g∘a≡ga {ρ} {Δ} {a} [ρ] ⊢Δ [a] = let ⊢F₁′ = (Twk.wk [ρ] ⊢Δ ⊢F₁) -- this lemma is already in ⊢snde′. maybe refactor? x₀ : wk (lift ρ) (b (step id) (fst (wk1 e)) (var 0)) [ a ] PE.≡ b ρ (fst (wk ρ e)) a x₀ = PE.trans (PE.cong (λ X → cast ⁰ (wk (lift ρ) (wk1 F₁) [ a ]) (wk (lift ρ) (wk1 F) [ a ]) X a) (PE.trans (PE.cong (λ X → X [ a ]) (wk-Idsym (lift ρ) (Univ rF ⁰) (wk1 F) (wk1 F₁) (fst (wk1 e)))) (subst-Idsym (sgSubst a) (Univ rF ⁰) (wk (lift ρ) (wk1 F)) (wk (lift ρ) (wk1 F₁)) (fst (wk (lift ρ) (wk1 e)))))) (PE.cong₃ (λ X Y Z → cast ⁰ Y X (Idsym (Univ rF ⁰) X Y (fst Z)) a) (irrelevant-subst′ ρ F a) (irrelevant-subst′ ρ F₁ a) (irrelevant-subst′ ρ e a)) x₁ : wk (lift ρ) (g (step id) (var 0)) [ a ] PE.≡ g ρ a x₁ = PE.cong₄ (λ X Y Z T → cast ⁰ X Y Z T) (PE.trans (cast-subst-lemma6 ρ G _ a) (PE.cong (λ X → wk (lift ρ) G [ X ]) x₀)) (PE.cong (λ X → wk (lift ρ) X [ a ]) (wkSingleSubstId G₁)) (PE.cong (λ X → snd X ∘ a ^ ¹) (irrelevant-subst′ ρ e a)) (PE.cong₂ (λ X Y → X ∘ Y ^ ⁰) (irrelevant-subst′ ρ t a) x₀) x₂ : Δ ∙ (wk ρ F₁) ^ [ rF , ι ⁰ ] ⊢ wk (lift ρ) (g (step id) (var 0)) ∷ wk (lift ρ) G₁ ^ [ ! , ι ⁰ ] x₂ = Twk.wkTerm (Twk.lift [ρ]) (⊢Δ ∙ ⊢F₁′) ⊢g0 in PE.subst (λ X → Δ ⊢ wk ρ (lam F₁ ▹ g (step id) (var 0) ^ ⁰) ∘ a ^ ⁰ ⇒ X ∷ wk (lift ρ) G₁ [ a ] ^ ι ⁰) x₁ (β-red (≡is≤ PE.refl) (≡is≤ PE.refl) ⊢F₁′ x₂ (escapeTerm ([F₁] [ρ] ⊢Δ) [a])) ⇨ id (escapeTerm ([G₁] [ρ] ⊢Δ [a]) ([g] [ρ] ⊢Δ [a])) [castΠΠ] : Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ A B e t ∷ B ^ [ ! , ι ⁰ ] / (Πᵣ′ rF ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢B , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext) [castΠΠ] = ((lam F₁ ▹ g (step id) (var 0) ^ ⁰) , Dg , lamₙ , g≡g , (λ [ρ] ⊢Δ [a] [a′] [a≡a′] → redSubst*EqTerm (g∘a≡ga [ρ] ⊢Δ [a]) (g∘a≡ga [ρ] ⊢Δ [a′]) ([G₁] [ρ] ⊢Δ [a]) ([G₁] [ρ] ⊢Δ [a′]) (G₁-ext [ρ] ⊢Δ [a] [a′] [a≡a′]) ([g] [ρ] ⊢Δ [a]) ([g] [ρ] ⊢Δ [a′]) ([gext] [ρ] ⊢Δ [a] [a′] [a≡a′])) , (λ [ρ] ⊢Δ [a] → proj₁ (redSubst*Term (g∘a≡ga [ρ] ⊢Δ [a]) ([G₁] [ρ] ⊢Δ [a]) ([g] [ρ] ⊢Δ [a])))) module cast-ΠΠ-lemmas-3 {Γ A₁ A₂ A₃ A₄ F₁ F₂ F₃ F₄ rF G₁ G₂ G₃ G₄ e₁₃ e₂₄ t₁ f₁ t₂ f₂} (⊢Γ : ⊢ Γ) (⊢A₁ : Γ ⊢ A₁ ^ [ ! , ι ⁰ ]) (⊢ΠF₁G₁ : Γ ⊢ Π F₁ ^ rF ° ⁰ ▹ G₁ ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (D₁ : Γ ⊢ A₁ ⇒* Π F₁ ^ rF ° ⁰ ▹ G₁ ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (⊢F₁ : Γ ⊢ F₁ ^ [ rF , ι ⁰ ]) (⊢G₁ : (Γ ∙ F₁ ^ [ rF , ι ⁰ ]) ⊢ G₁ ^ [ ! , ι ⁰ ]) (A₁≡A₁ : Γ ⊢ (Π F₁ ^ rF ° ⁰ ▹ G₁ ° ⁰ ° ⁰) ≅ (Π F₁ ^ rF ° ⁰ ▹ G₁ ° ⁰ ° ⁰) ^ [ ! , ι ⁰ ]) ([F₁] : ∀ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ F₁ ^ [ rF , ι ⁰ ]) ([G₁] : ∀ {ρ} {Δ} {a} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / ([F₁] [ρ] ⊢Δ)) → (Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₁ [ a ] ^ [ ! , ι ⁰ ])) (G₁-ext : ∀ {ρ} {Δ} {a} {b} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / ([F₁] [ρ] ⊢Δ)) ([b] : Δ ⊩⟨ ι ⁰ ⟩ b ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / ([F₁] [ρ] ⊢Δ)) ([a≡b] : Δ ⊩⟨ ι ⁰ ⟩ a ≡ b ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / ([F₁] [ρ] ⊢Δ)) → (Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₁ [ a ] ≡ wk (lift ρ) G₁ [ b ] ^ [ ! , ι ⁰ ] / ([G₁] [ρ] ⊢Δ [a]))) (⊢A₂ : Γ ⊢ A₂ ^ [ ! , ι ⁰ ]) (⊢ΠF₂G₂ : Γ ⊢ Π F₂ ^ rF ° ⁰ ▹ G₂ ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (D₂ : Γ ⊢ A₂ ⇒* Π F₂ ^ rF ° ⁰ ▹ G₂ ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (⊢F₂ : Γ ⊢ F₂ ^ [ rF , ι ⁰ ]) (⊢G₂ : (Γ ∙ F₂ ^ [ rF , ι ⁰ ]) ⊢ G₂ ^ [ ! , ι ⁰ ]) (A₂≡A₂ : Γ ⊢ (Π F₂ ^ rF ° ⁰ ▹ G₂ ° ⁰ ° ⁰) ≅ (Π F₂ ^ rF ° ⁰ ▹ G₂ ° ⁰ ° ⁰) ^ [ ! , ι ⁰ ]) ([F₂] : ∀ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ F₂ ^ [ rF , ι ⁰ ]) ([G₂] : ∀ {ρ} {Δ} {a} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₂ ^ [ rF , ι ⁰ ] / ([F₂] [ρ] ⊢Δ)) → (Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₂ [ a ] ^ [ ! , ι ⁰ ])) (G₂-ext : ∀ {ρ} {Δ} {a} {b} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₂ ^ [ rF , ι ⁰ ] / ([F₂] [ρ] ⊢Δ)) ([b] : Δ ⊩⟨ ι ⁰ ⟩ b ∷ wk ρ F₂ ^ [ rF , ι ⁰ ] / ([F₂] [ρ] ⊢Δ)) ([a≡b] : Δ ⊩⟨ ι ⁰ ⟩ a ≡ b ∷ wk ρ F₂ ^ [ rF , ι ⁰ ] / ([F₂] [ρ] ⊢Δ)) → (Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₂ [ a ] ≡ wk (lift ρ) G₂ [ b ] ^ [ ! , ι ⁰ ] / ([G₂] [ρ] ⊢Δ [a]))) (⊢A₃ : Γ ⊢ A₃ ^ [ ! , ι ⁰ ]) (⊢ΠF₃G₃ : Γ ⊢ Π F₃ ^ rF ° ⁰ ▹ G₃ ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (D₃ : Γ ⊢ A₃ ⇒* Π F₃ ^ rF ° ⁰ ▹ G₃ ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (⊢F₃ : Γ ⊢ F₃ ^ [ rF , ι ⁰ ]) (⊢G₃ : (Γ ∙ F₃ ^ [ rF , ι ⁰ ]) ⊢ G₃ ^ [ ! , ι ⁰ ]) (A₃≡A₃ : Γ ⊢ (Π F₃ ^ rF ° ⁰ ▹ G₃ ° ⁰ ° ⁰) ≅ (Π F₃ ^ rF ° ⁰ ▹ G₃ ° ⁰ ° ⁰) ^ [ ! , ι ⁰ ]) ([F₃] : ∀ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ F₃ ^ [ rF , ι ⁰ ]) ([G₃] : ∀ {ρ} {Δ} {a} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₃ ^ [ rF , ι ⁰ ] / ([F₃] [ρ] ⊢Δ)) → (Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₃ [ a ] ^ [ ! , ι ⁰ ])) (G₃-ext : ∀ {ρ} {Δ} {a} {b} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₃ ^ [ rF , ι ⁰ ] / ([F₃] [ρ] ⊢Δ)) ([b] : Δ ⊩⟨ ι ⁰ ⟩ b ∷ wk ρ F₃ ^ [ rF , ι ⁰ ] / ([F₃] [ρ] ⊢Δ)) ([a≡b] : Δ ⊩⟨ ι ⁰ ⟩ a ≡ b ∷ wk ρ F₃ ^ [ rF , ι ⁰ ] / ([F₃] [ρ] ⊢Δ)) → (Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₃ [ a ] ≡ wk (lift ρ) G₃ [ b ] ^ [ ! , ι ⁰ ] / ([G₃] [ρ] ⊢Δ [a]))) (⊢A₄ : Γ ⊢ A₄ ^ [ ! , ι ⁰ ]) (⊢ΠF₄G₄ : Γ ⊢ Π F₄ ^ rF ° ⁰ ▹ G₄ ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (D₄ : Γ ⊢ A₄ ⇒* Π F₄ ^ rF ° ⁰ ▹ G₄ ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (⊢F₄ : Γ ⊢ F₄ ^ [ rF , ι ⁰ ]) (⊢G₄ : (Γ ∙ F₄ ^ [ rF , ι ⁰ ]) ⊢ G₄ ^ [ ! , ι ⁰ ]) (A₄≡A₄ : Γ ⊢ (Π F₄ ^ rF ° ⁰ ▹ G₄ ° ⁰ ° ⁰) ≅ (Π F₄ ^ rF ° ⁰ ▹ G₄ ° ⁰ ° ⁰) ^ [ ! , ι ⁰ ]) ([F₄] : ∀ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ F₄ ^ [ rF , ι ⁰ ]) ([G₄] : ∀ {ρ} {Δ} {a} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₄ ^ [ rF , ι ⁰ ] / ([F₄] [ρ] ⊢Δ)) → (Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₄ [ a ] ^ [ ! , ι ⁰ ])) (G₄-ext : ∀ {ρ} {Δ} {a} {b} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₄ ^ [ rF , ι ⁰ ] / ([F₄] [ρ] ⊢Δ)) ([b] : Δ ⊩⟨ ι ⁰ ⟩ b ∷ wk ρ F₄ ^ [ rF , ι ⁰ ] / ([F₄] [ρ] ⊢Δ)) ([a≡b] : Δ ⊩⟨ ι ⁰ ⟩ a ≡ b ∷ wk ρ F₄ ^ [ rF , ι ⁰ ] / ([F₄] [ρ] ⊢Δ)) → (Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₄ [ a ] ≡ wk (lift ρ) G₄ [ b ] ^ [ ! , ι ⁰ ] / ([G₄] [ρ] ⊢Δ [a]))) (A₁≡A₂ : Γ ⊢ Π F₁ ^ rF ° ⁰ ▹ G₁ ° ⁰ ° ⁰ ≅ Π F₂ ^ rF ° ⁰ ▹ G₂ ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (A₃≡A₄ : Γ ⊢ Π F₃ ^ rF ° ⁰ ▹ G₃ ° ⁰ ° ⁰ ≅ Π F₄ ^ rF ° ⁰ ▹ G₄ ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) ([F₁≡F₂] : ∀ {ρ Δ} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ F₁ ≡ wk ρ F₂ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) ([F₃≡F₄] : ∀ {ρ Δ} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ F₃ ≡ wk ρ F₄ ^ [ rF , ι ⁰ ] / [F₃] [ρ] ⊢Δ) ([G₁≡G₂] : ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₁ [ a ] ≡ wk (lift ρ) G₂ [ a ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [a]) ([G₃≡G₄] : ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₃ ^ [ rF , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₃ [ a ] ≡ wk (lift ρ) G₄ [ a ] ^ [ ! , ι ⁰ ] / [G₃] [ρ] ⊢Δ [a]) (⊢e₁₃ : Γ ⊢ e₁₃ ∷ Id (U ⁰) A₁ A₃ ^ [ % , ι ¹ ]) (⊢e₂₄ : Γ ⊢ e₂₄ ∷ Id (U ⁰) A₂ A₄ ^ [ % , ι ¹ ]) (⊢t₁ : Γ ⊢ t₁ ∷ Π F₁ ^ rF ° ⁰ ▹ G₁ ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (Df₁ : Γ ⊢ t₁ ⇒* f₁ ∷ Π F₁ ^ rF ° ⁰ ▹ G₁ ° ⁰ ° ⁰ ^ ι ⁰) ([f₁ext] : ∀ {ρ Δ a b} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) ([b] : Δ ⊩⟨ ι ⁰ ⟩ b ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) ([a≡b] : Δ ⊩⟨ ι ⁰ ⟩ a ≡ b ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ f₁ ∘ a ^ ⁰ ≡ wk ρ f₁ ∘ b ^ ⁰ ∷ wk (lift ρ) G₁ [ a ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [a]) ([f₁] : ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ f₁ ∘ a ^ ⁰ ∷ wk (lift ρ) G₁ [ a ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [a]) (⊢t₂ : Γ ⊢ t₂ ∷ Π F₂ ^ rF ° ⁰ ▹ G₂ ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (Df₂ : Γ ⊢ t₂ ⇒* f₂ ∷ Π F₂ ^ rF ° ⁰ ▹ G₂ ° ⁰ ° ⁰ ^ ι ⁰) ([f₂ext] : ∀ {ρ Δ a b} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₂ ^ [ rF , ι ⁰ ] / [F₂] [ρ] ⊢Δ) ([b] : Δ ⊩⟨ ι ⁰ ⟩ b ∷ wk ρ F₂ ^ [ rF , ι ⁰ ] / [F₂] [ρ] ⊢Δ) ([a≡b] : Δ ⊩⟨ ι ⁰ ⟩ a ≡ b ∷ wk ρ F₂ ^ [ rF , ι ⁰ ] / [F₂] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ f₂ ∘ a ^ ⁰ ≡ wk ρ f₂ ∘ b ^ ⁰ ∷ wk (lift ρ) G₂ [ a ] ^ [ ! , ι ⁰ ] / [G₂] [ρ] ⊢Δ [a]) ([f₂] : ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₂ ^ [ rF , ι ⁰ ] / [F₂] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ f₂ ∘ a ^ ⁰ ∷ wk (lift ρ) G₂ [ a ] ^ [ ! , ι ⁰ ] / [G₂] [ρ] ⊢Δ [a]) ([f₁≡f₂] : ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ f₁ ∘ a ^ ⁰ ≡ wk ρ f₂ ∘ a ^ ⁰ ∷ wk (lift ρ) G₁ [ a ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [a]) (recursor₁ : ∀ {ρ Δ x y t e} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([x] : Δ ⊩⟨ ι ⁰ ⟩ x ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) ([y] : Δ ⊩⟨ ι ⁰ ⟩ y ∷ wk ρ F₃ ^ [ rF , ι ⁰ ] / [F₃] [ρ] ⊢Δ) ([t] : Δ ⊩⟨ ι ⁰ ⟩ t ∷ wk (lift ρ) G₁ [ x ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [x]) (⊢e : Δ ⊢ e ∷ Id (U ⁰) (wk (lift ρ) G₁ [ x ]) (wk (lift ρ) G₃ [ y ]) ^ [ % , ι ¹ ]) → Δ ⊩⟨ ι ⁰ ⟩ cast ⁰ (wk (lift ρ) G₁ [ x ]) (wk (lift ρ) G₃ [ y ]) e t ∷ wk (lift ρ) G₃ [ y ] ^ [ ! , ι ⁰ ] / [G₃] [ρ] ⊢Δ [y]) (recursor₂ : ∀ {ρ Δ x y t e} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([x] : Δ ⊩⟨ ι ⁰ ⟩ x ∷ wk ρ F₂ ^ [ rF , ι ⁰ ] / [F₂] [ρ] ⊢Δ) ([y] : Δ ⊩⟨ ι ⁰ ⟩ y ∷ wk ρ F₄ ^ [ rF , ι ⁰ ] / [F₄] [ρ] ⊢Δ) ([t] : Δ ⊩⟨ ι ⁰ ⟩ t ∷ wk (lift ρ) G₂ [ x ] ^ [ ! , ι ⁰ ] / [G₂] [ρ] ⊢Δ [x]) (⊢e : Δ ⊢ e ∷ Id (U ⁰) (wk (lift ρ) G₂ [ x ]) (wk (lift ρ) G₄ [ y ]) ^ [ % , ι ¹ ]) → Δ ⊩⟨ ι ⁰ ⟩ cast ⁰ (wk (lift ρ) G₂ [ x ]) (wk (lift ρ) G₄ [ y ]) e t ∷ wk (lift ρ) G₄ [ y ] ^ [ ! , ι ⁰ ] / [G₄] [ρ] ⊢Δ [y]) (extrecursor₁ : ∀ {ρ Δ x x′ y y′ t t′ e e′} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([x] : Δ ⊩⟨ ι ⁰ ⟩ x ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → ([x′] : Δ ⊩⟨ ι ⁰ ⟩ x′ ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → ([x≡x′] : Δ ⊩⟨ ι ⁰ ⟩ x ≡ x′ ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → ([y] : Δ ⊩⟨ ι ⁰ ⟩ y ∷ wk ρ F₃ ^ [ rF , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → ([y′] : Δ ⊩⟨ ι ⁰ ⟩ y′ ∷ wk ρ F₃ ^ [ rF , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → ([y≡y′] : Δ ⊩⟨ ι ⁰ ⟩ y ≡ y′ ∷ wk ρ F₃ ^ [ rF , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → ([t] : Δ ⊩⟨ ι ⁰ ⟩ t ∷ wk (lift ρ) G₁ [ x ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [x]) → ([t′] : Δ ⊩⟨ ι ⁰ ⟩ t′ ∷ wk (lift ρ) G₁ [ x′ ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [x′]) → ([t≡t′] : Δ ⊩⟨ ι ⁰ ⟩ t ≡ t′ ∷ wk (lift ρ) G₁ [ x ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [x]) → (⊢e : Δ ⊢ e ∷ Id (U ⁰) (wk (lift ρ) G₁ [ x ]) (wk (lift ρ) G₃ [ y ]) ^ [ % , ι ¹ ]) → (⊢e′ : Δ ⊢ e′ ∷ Id (U ⁰) (wk (lift ρ) G₁ [ x′ ]) (wk (lift ρ) G₃ [ y′ ]) ^ [ % , ι ¹ ]) → Δ ⊩⟨ ι ⁰ ⟩ cast ⁰ (wk (lift ρ) G₁ [ x ]) (wk (lift ρ) G₃ [ y ]) e t ≡ cast ⁰ (wk (lift ρ) G₁ [ x′ ]) (wk (lift ρ) G₃ [ y′ ]) e′ t′ ∷ wk (lift ρ) G₃ [ y ] ^ [ ! , ι ⁰ ] / [G₃] [ρ] ⊢Δ [y]) (extrecursor₂ : ∀ {ρ Δ x x′ y y′ t t′ e e′} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([x] : Δ ⊩⟨ ι ⁰ ⟩ x ∷ wk ρ F₂ ^ [ rF , ι ⁰ ] / [F₂] [ρ] ⊢Δ) → ([x′] : Δ ⊩⟨ ι ⁰ ⟩ x′ ∷ wk ρ F₂ ^ [ rF , ι ⁰ ] / [F₂] [ρ] ⊢Δ) → ([x≡x′] : Δ ⊩⟨ ι ⁰ ⟩ x ≡ x′ ∷ wk ρ F₂ ^ [ rF , ι ⁰ ] / [F₂] [ρ] ⊢Δ) → ([y] : Δ ⊩⟨ ι ⁰ ⟩ y ∷ wk ρ F₄ ^ [ rF , ι ⁰ ] / [F₄] [ρ] ⊢Δ) → ([y′] : Δ ⊩⟨ ι ⁰ ⟩ y′ ∷ wk ρ F₄ ^ [ rF , ι ⁰ ] / [F₄] [ρ] ⊢Δ) → ([y≡y′] : Δ ⊩⟨ ι ⁰ ⟩ y ≡ y′ ∷ wk ρ F₄ ^ [ rF , ι ⁰ ] / [F₄] [ρ] ⊢Δ) → ([t] : Δ ⊩⟨ ι ⁰ ⟩ t ∷ wk (lift ρ) G₂ [ x ] ^ [ ! , ι ⁰ ] / [G₂] [ρ] ⊢Δ [x]) → ([t′] : Δ ⊩⟨ ι ⁰ ⟩ t′ ∷ wk (lift ρ) G₂ [ x′ ] ^ [ ! , ι ⁰ ] / [G₂] [ρ] ⊢Δ [x′]) → ([t≡t′] : Δ ⊩⟨ ι ⁰ ⟩ t ≡ t′ ∷ wk (lift ρ) G₂ [ x ] ^ [ ! , ι ⁰ ] / [G₂] [ρ] ⊢Δ [x]) → (⊢e : Δ ⊢ e ∷ Id (U ⁰) (wk (lift ρ) G₂ [ x ]) (wk (lift ρ) G₄ [ y ]) ^ [ % , ι ¹ ]) → (⊢e′ : Δ ⊢ e′ ∷ Id (U ⁰) (wk (lift ρ) G₂ [ x′ ]) (wk (lift ρ) G₄ [ y′ ]) ^ [ % , ι ¹ ]) → Δ ⊩⟨ ι ⁰ ⟩ cast ⁰ (wk (lift ρ) G₂ [ x ]) (wk (lift ρ) G₄ [ y ]) e t ≡ cast ⁰ (wk (lift ρ) G₂ [ x′ ]) (wk (lift ρ) G₄ [ y′ ]) e′ t′ ∷ wk (lift ρ) G₄ [ y ] ^ [ ! , ι ⁰ ] / [G₄] [ρ] ⊢Δ [y]) (eqrecursor : ∀ {ρ Δ x₁ x₂ x₃ x₄ t₁ t₂ e₁₃ e₂₄} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([x₁] : Δ ⊩⟨ ι ⁰ ⟩ x₁ ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → ([x₂] : Δ ⊩⟨ ι ⁰ ⟩ x₂ ∷ wk ρ F₂ ^ [ rF , ι ⁰ ] / [F₂] [ρ] ⊢Δ) → ([G₁x₁≡G₂x₂] : Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₁ [ x₁ ] ≡ wk (lift ρ) G₂ [ x₂ ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [x₁]) → ([x₃] : Δ ⊩⟨ ι ⁰ ⟩ x₃ ∷ wk ρ F₃ ^ [ rF , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → ([x₄] : Δ ⊩⟨ ι ⁰ ⟩ x₄ ∷ wk ρ F₄ ^ [ rF , ι ⁰ ] / [F₄] [ρ] ⊢Δ) → ([G₃x₃≡G₄x₄] : Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₃ [ x₃ ] ≡ wk (lift ρ) G₄ [ x₄ ] ^ [ ! , ι ⁰ ] / [G₃] [ρ] ⊢Δ [x₃]) → ([t₁] : Δ ⊩⟨ ι ⁰ ⟩ t₁ ∷ wk (lift ρ) G₁ [ x₁ ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [x₁]) → ([t₂] : Δ ⊩⟨ ι ⁰ ⟩ t₂ ∷ wk (lift ρ) G₂ [ x₂ ] ^ [ ! , ι ⁰ ] / [G₂] [ρ] ⊢Δ [x₂]) → ([t₁≡t₂] : Δ ⊩⟨ ι ⁰ ⟩ t₁ ≡ t₂ ∷ wk (lift ρ) G₁ [ x₁ ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [x₁]) → (⊢e₁₃ : Δ ⊢ e₁₃ ∷ Id (U ⁰) (wk (lift ρ) G₁ [ x₁ ]) (wk (lift ρ) G₃ [ x₃ ]) ^ [ % , ι ¹ ]) → (⊢e₂₄ : Δ ⊢ e₂₄ ∷ Id (U ⁰) (wk (lift ρ) G₂ [ x₂ ]) (wk (lift ρ) G₄ [ x₄ ]) ^ [ % , ι ¹ ]) → Δ ⊩⟨ ι ⁰ ⟩ cast ⁰ (wk (lift ρ) G₁ [ x₁ ]) (wk (lift ρ) G₃ [ x₃ ]) e₁₃ t₁ ≡ cast ⁰ (wk (lift ρ) G₂ [ x₂ ]) (wk (lift ρ) G₄ [ x₄ ]) e₂₄ t₂ ∷ wk (lift ρ) G₃ [ x₃ ] ^ [ ! , ι ⁰ ] / [G₃] [ρ] ⊢Δ [x₃]) ([b₁] : ∀ {ρ Δ e x} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) (⊢e : Δ ⊢ e ∷ Id (Univ rF ⁰) (wk ρ F₁) (wk ρ F₃) ^ [ % , ι ¹ ]) ([x] : Δ ⊩⟨ ι ⁰ ⟩ x ∷ wk ρ F₃ ^ [ rF , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ cast ⁰ (wk ρ F₃) (wk ρ F₁) (Idsym (Univ rF ⁰) (wk ρ F₁) (wk ρ F₃) e) x ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) ([bext₁] : ∀ {ρ Δ e e′ x y} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → (Δ ⊢ e ∷ Id (Univ rF ⁰) (wk ρ F₁) (wk ρ F₃) ^ [ % , ι ¹ ]) → (Δ ⊢ e′ ∷ Id (Univ rF ⁰) (wk ρ F₁) (wk ρ F₃) ^ [ % , ι ¹ ]) → (Δ ⊩⟨ ι ⁰ ⟩ x ∷ wk ρ F₃ ^ [ rF , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → (Δ ⊩⟨ ι ⁰ ⟩ y ∷ wk ρ F₃ ^ [ rF , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → (Δ ⊩⟨ ι ⁰ ⟩ x ≡ y ∷ wk ρ F₃ ^ [ rF , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ cast ⁰ (wk ρ F₃) (wk ρ F₁) (Idsym (Univ rF ⁰) (wk ρ F₁) (wk ρ F₃) e) x ≡ cast ⁰ (wk ρ F₃) (wk ρ F₁) (Idsym (Univ rF ⁰) (wk ρ F₁) (wk ρ F₃) e′) y ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) ([b₂] : ∀ {ρ Δ e x} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) (⊢e : Δ ⊢ e ∷ Id (Univ rF ⁰) (wk ρ F₂) (wk ρ F₄) ^ [ % , ι ¹ ]) ([x] : Δ ⊩⟨ ι ⁰ ⟩ x ∷ wk ρ F₄ ^ [ rF , ι ⁰ ] / [F₄] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ cast ⁰ (wk ρ F₄) (wk ρ F₂) (Idsym (Univ rF ⁰) (wk ρ F₂) (wk ρ F₄) e) x ∷ wk ρ F₂ ^ [ rF , ι ⁰ ] / [F₂] [ρ] ⊢Δ) ([bext₂] : ∀ {ρ Δ e e′ x y} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → (Δ ⊢ e ∷ Id (Univ rF ⁰) (wk ρ F₂) (wk ρ F₄) ^ [ % , ι ¹ ]) → (Δ ⊢ e′ ∷ Id (Univ rF ⁰) (wk ρ F₂) (wk ρ F₄) ^ [ % , ι ¹ ]) → (Δ ⊩⟨ ι ⁰ ⟩ x ∷ wk ρ F₄ ^ [ rF , ι ⁰ ] / [F₄] [ρ] ⊢Δ) → (Δ ⊩⟨ ι ⁰ ⟩ y ∷ wk ρ F₄ ^ [ rF , ι ⁰ ] / [F₄] [ρ] ⊢Δ) → (Δ ⊩⟨ ι ⁰ ⟩ x ≡ y ∷ wk ρ F₄ ^ [ rF , ι ⁰ ] / [F₄] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ cast ⁰ (wk ρ F₄) (wk ρ F₂) (Idsym (Univ rF ⁰) (wk ρ F₂) (wk ρ F₄) e) x ≡ cast ⁰ (wk ρ F₄) (wk ρ F₂) (Idsym (Univ rF ⁰) (wk ρ F₂) (wk ρ F₄) e′) y ∷ wk ρ F₂ ^ [ rF , ι ⁰ ] / [F₂] [ρ] ⊢Δ) ([b₁≡b₂] : ∀ {ρ Δ e₁₃ e₂₄ x₃ x₄} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → (Δ ⊢ e₁₃ ∷ Id (Univ rF ⁰) (wk ρ F₁) (wk ρ F₃) ^ [ % , ι ¹ ]) → (Δ ⊢ e₂₄ ∷ Id (Univ rF ⁰) (wk ρ F₂) (wk ρ F₄) ^ [ % , ι ¹ ]) → (Δ ⊩⟨ ι ⁰ ⟩ x₃ ∷ wk ρ F₃ ^ [ rF , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → (Δ ⊩⟨ ι ⁰ ⟩ x₄ ∷ wk ρ F₄ ^ [ rF , ι ⁰ ] / [F₄] [ρ] ⊢Δ) → (Δ ⊩⟨ ι ⁰ ⟩ x₃ ≡ x₄ ∷ wk ρ F₃ ^ [ rF , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ cast ⁰ (wk ρ F₃) (wk ρ F₁) (Idsym (Univ rF ⁰) (wk ρ F₁) (wk ρ F₃) e₁₃) x₃ ≡ cast ⁰ (wk ρ F₄) (wk ρ F₂) (Idsym (Univ rF ⁰) (wk ρ F₂) (wk ρ F₄) e₂₄) x₄ ∷ wk ρ F₁ ^ [ rF , ι ⁰ ] / [F₁] [ρ] ⊢Δ) where module g₁ = cast-ΠΠ-lemmas-2 ⊢Γ ⊢A₁ ⊢ΠF₁G₁ D₁ ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext ⊢A₃ ⊢ΠF₃G₃ D₃ ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext ⊢e₁₃ recursor₁ extrecursor₁ ⊢t₁ Df₁ [f₁ext] [f₁] [b₁] [bext₁] module g₂ = cast-ΠΠ-lemmas-2 ⊢Γ ⊢A₂ ⊢ΠF₂G₂ D₂ ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext ⊢A₄ ⊢ΠF₄G₄ D₄ ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext ⊢e₂₄ recursor₂ extrecursor₂ ⊢t₂ Df₂ [f₂ext] [f₂] [b₂] [bext₂] [g₁≡g₂] : ∀ {ρ Δ x₃ x₄} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([x₃] : Δ ⊩⟨ ι ⁰ ⟩ x₃ ∷ wk ρ F₃ ^ [ rF , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → ([x₄] : Δ ⊩⟨ ι ⁰ ⟩ x₄ ∷ wk ρ F₄ ^ [ rF , ι ⁰ ] / [F₄] [ρ] ⊢Δ) → ([x₃≡x₄] : Δ ⊩⟨ ι ⁰ ⟩ x₃ ≡ x₄ ∷ wk ρ F₃ ^ [ rF , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ g₁.g ρ x₃ ≡ g₂.g ρ x₄ ∷ wk (lift ρ) G₃ [ x₃ ] ^ [ ! , ι ⁰ ] / [G₃] [ρ] ⊢Δ [x₃] [g₁≡g₂] {ρ} {Δ} {x₃} {x₄} [ρ] ⊢Δ [x₃] [x₄] [x₃≡x₄] = let [b₁] = [b₁] [ρ] ⊢Δ (Twk.wkTerm [ρ] ⊢Δ g₁.⊢fste) [x₃] [b₂] = [b₂] [ρ] ⊢Δ (Twk.wkTerm [ρ] ⊢Δ g₂.⊢fste) [x₄] [b₁≡b₂]′ = [b₁≡b₂] [ρ] ⊢Δ (Twk.wkTerm [ρ] ⊢Δ g₁.⊢fste) (Twk.wkTerm [ρ] ⊢Δ g₂.⊢fste) [x₃] [x₄] [x₃≡x₄] [b₁:F₂] = convTerm₁ ([F₁] [ρ] ⊢Δ) ([F₂] [ρ] ⊢Δ) ([F₁≡F₂] [ρ] ⊢Δ) [b₁] [b₁≡b₂:F₂] = convEqTerm₁ ([F₁] [ρ] ⊢Δ) ([F₂] [ρ] ⊢Δ) ([F₁≡F₂] [ρ] ⊢Δ) [b₁≡b₂]′ [G₁b₁≡G₂b₂] = transEq ([G₁] [ρ] ⊢Δ [b₁]) ([G₂] [ρ] ⊢Δ [b₁:F₂]) ([G₂] [ρ] ⊢Δ [b₂]) ([G₁≡G₂] [ρ] ⊢Δ [b₁]) (G₂-ext [ρ] ⊢Δ [b₁:F₂] [b₂] [b₁≡b₂:F₂]) [x₃:F₄] = convTerm₁ ([F₃] [ρ] ⊢Δ) ([F₄] [ρ] ⊢Δ) ([F₃≡F₄] [ρ] ⊢Δ) [x₃] [x₃≡x₄:F₄] = convEqTerm₁ ([F₃] [ρ] ⊢Δ) ([F₄] [ρ] ⊢Δ) ([F₃≡F₄] [ρ] ⊢Δ) [x₃≡x₄] [G₃x₃≡G₄x₄] = transEq ([G₃] [ρ] ⊢Δ [x₃]) ([G₄] [ρ] ⊢Δ [x₃:F₄]) ([G₄] [ρ] ⊢Δ [x₄]) ([G₃≡G₄] [ρ] ⊢Δ [x₃]) (G₄-ext [ρ] ⊢Δ [x₃:F₄] [x₄] [x₃≡x₄:F₄]) [t₁] , [t₁≡f₁b₁] = redSubst*Term (appRed* (escapeTerm ([F₁] [ρ] ⊢Δ) [b₁]) (Twk.wkRed*Term [ρ] ⊢Δ Df₁)) ([G₁] [ρ] ⊢Δ [b₁]) ([f₁] [ρ] ⊢Δ [b₁]) [t₂] , [t₂≡f₂b₂] = redSubst*Term (appRed* (escapeTerm ([F₂] [ρ] ⊢Δ) [b₂]) (Twk.wkRed*Term [ρ] ⊢Δ Df₂)) ([G₂] [ρ] ⊢Δ [b₂]) ([f₂] [ρ] ⊢Δ [b₂]) [t₁≡f₂b₁] = transEqTerm ([G₁] [ρ] ⊢Δ [b₁]) [t₁≡f₁b₁] ([f₁≡f₂] [ρ] ⊢Δ [b₁]) [f₂b₁≡t₂] = symEqTerm ([G₂] [ρ] ⊢Δ [b₂]) (transEqTerm ([G₂] [ρ] ⊢Δ [b₂]) [t₂≡f₂b₂] ([f₂ext] [ρ] ⊢Δ [b₂] [b₁:F₂] (symEqTerm ([F₂] [ρ] ⊢Δ) [b₁≡b₂:F₂]))) [t₁≡t₂] = transEqTerm ([G₁] [ρ] ⊢Δ [b₁]) [t₁≡f₂b₁] (convEqTerm₂ ([G₁] [ρ] ⊢Δ [b₁]) ([G₂] [ρ] ⊢Δ [b₂]) [G₁b₁≡G₂b₂] [f₂b₁≡t₂]) x = eqrecursor [ρ] ⊢Δ [b₁] [b₂] [G₁b₁≡G₂b₂] [x₃] [x₄] [G₃x₃≡G₄x₄] [t₁] [t₂] [t₁≡t₂] (g₁.⊢snde′ [ρ] ⊢Δ (escapeTerm ([F₃] [ρ] ⊢Δ) [x₃])) (g₂.⊢snde′ [ρ] ⊢Δ (escapeTerm ([F₄] [ρ] ⊢Δ) [x₄])) in x g₁≡g₂ : Γ ⊢ (lam F₃ ▹ g₁.g (step id) (var 0) ^ ⁰) ≅ (lam F₄ ▹ g₂.g (step id) (var 0) ^ ⁰) ∷ Π F₃ ^ rF ° ⁰ ▹ G₃ ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ] g₁≡g₂ = let Δ₁ = g₁.Δ₁ ⊢Δ₁ = g₁.⊢Δ₁ [ρ₁] = g₁.[ρ₁] ⊢F₃′ = Twk.wk (Twk.step Twk.id) ⊢Δ₁ ⊢F₃ ⊢g₁0 = escapeTerm ([G₃] [ρ₁] ⊢Δ₁ g₁.[0]) (g₁.[g] [ρ₁] ⊢Δ₁ g₁.[0]) ⊢g₁0′ = (PE.subst (λ X → Δ₁ ⊢ g₁.g (step id) (var 0) ∷ X ^ [ ! , ι ⁰ ]) (wkSingleSubstId G₃) ⊢g₁0) ⊢g₁0″ = Twk.wkTerm (Twk.lift (Twk.step Twk.id)) (⊢Δ₁ ∙ ⊢F₃′) ⊢g₁0′ ⊢F₄′ = Twk.wk (Twk.step Twk.id) ⊢Δ₁ ⊢F₄ ⊢g₂0 = escapeTerm ([G₄] g₂.[ρ₁] g₂.⊢Δ₁ g₂.[0]) (g₂.[g] g₂.[ρ₁] g₂.⊢Δ₁ g₂.[0]) ⊢g₂0′ = (PE.subst (λ X → g₂.Δ₁ ⊢ g₂.g (step id) (var 0) ∷ X ^ [ ! , ι ⁰ ]) (wkSingleSubstId G₄) ⊢g₂0) ⊢g₂0″ = Twk.wkTerm (Twk.lift (Twk.step Twk.id)) (⊢Δ₁ ∙ ⊢F₄′) ⊢g₂0′ D₁ : Δ₁ ⊢ (lam (wk1 F₃) ▹ wk1d (g₁.g (step id) (var 0)) ^ ⁰) ∘ (var 0) ^ ⁰ ⇒* g₁.g (step id) (var 0) ∷ wk1d G₃ [ var 0 ] ^ ι ⁰ D₁ = PE.subst (λ X → Δ₁ ⊢ (lam (wk1 F₃) ▹ wk1d (g₁.g (step id) (var 0)) ^ ⁰) ∘ (var 0) ^ ⁰ ⇒ X ∷ wk1d G₃ [ var 0 ] ^ ι ⁰) (wkSingleSubstId (g₁.g (step id) (var 0))) (β-red (≡is≤ PE.refl) (≡is≤ PE.refl) ⊢F₃′ ⊢g₁0″ (var ⊢Δ₁ here)) ⇨ id ⊢g₁0 F₃≡F₄ = escapeEq ([F₃] [ρ₁] ⊢Δ₁) ([F₃≡F₄] [ρ₁] ⊢Δ₁) [0:F₄] : Δ₁ ⊩⟨ ι ⁰ ⟩ var 0 ∷ wk (step id) F₄ ^ [ rF , ι ⁰ ] / [F₄] [ρ₁] ⊢Δ₁ [0:F₄] = neuTerm ([F₄] [ρ₁] ⊢Δ₁) (var 0) (conv (var ⊢Δ₁ here) (≅-eq F₃≡F₄)) (~-var (conv (var ⊢Δ₁ here) (≅-eq F₃≡F₄))) D₂ : Δ₁ ⊢ (lam (wk1 F₄) ▹ wk1d (g₂.g (step id) (var 0)) ^ ⁰) ∘ (var 0) ^ ⁰ ⇒* g₂.g (step id) (var 0) ∷ wk1d G₄ [ var 0 ] ^ ι ⁰ D₂ = PE.subst (λ X → Δ₁ ⊢ (lam (wk1 F₄) ▹ wk1d (g₂.g (step id) (var 0)) ^ ⁰) ∘ (var 0) ^ ⁰ ⇒ X ∷ wk1d G₄ [ var 0 ] ^ ι ⁰) (wkSingleSubstId (g₂.g (step id) (var 0))) (β-red (≡is≤ PE.refl) (≡is≤ PE.refl) ⊢F₄′ ⊢g₂0″ (conv (var ⊢Δ₁ here) (≅-eq F₃≡F₄))) ⇨ id (escapeTerm ([G₄] [ρ₁] ⊢Δ₁ [0:F₄]) (g₂.[g] [ρ₁] ⊢Δ₁ [0:F₄])) [g₁0≡g₁] : Δ₁ ⊩⟨ ι ⁰ ⟩ (lam (wk1 F₃) ▹ wk1d (g₁.g (step id) (var 0)) ^ ⁰) ∘ (var 0) ^ ⁰ ≡ g₁.g (step id) (var 0) ∷ wk1d G₃ [ var 0 ] ^ [ ! , ι ⁰ ] / [G₃] [ρ₁] ⊢Δ₁ g₁.[0] [g₁0≡g₁] = proj₂ (redSubst*Term D₁ ([G₃] [ρ₁] ⊢Δ₁ g₁.[0]) (g₁.[g] [ρ₁] ⊢Δ₁ g₁.[0])) [g₂0≡g₂] : Δ₁ ⊩⟨ ι ⁰ ⟩ (lam (wk1 F₄) ▹ wk1d (g₂.g (step id) (var 0)) ^ ⁰) ∘ (var 0) ^ ⁰ ≡ g₂.g (step id) (var 0) ∷ wk1d G₄ [ var 0 ] ^ [ ! , ι ⁰ ] / [G₄] [ρ₁] ⊢Δ₁ [0:F₄] [g₂0≡g₂] = proj₂ (redSubst*Term D₂ ([G₄] [ρ₁] ⊢Δ₁ [0:F₄]) (g₂.[g] [ρ₁] ⊢Δ₁ [0:F₄])) [g₁≡g₂]′ : Δ₁ ⊩⟨ ι ⁰ ⟩ g₁.g (step id) (var 0) ≡ g₂.g (step id) (var 0) ∷ wk1d G₃ [ var 0 ] ^ [ ! , ι ⁰ ] / [G₃] [ρ₁] ⊢Δ₁ g₁.[0] [g₁≡g₂]′ = [g₁≡g₂] [ρ₁] ⊢Δ₁ g₁.[0] (convTerm₁ ([F₃] [ρ₁] ⊢Δ₁) ([F₄] [ρ₁] ⊢Δ₁) ([F₃≡F₄] [ρ₁] ⊢Δ₁) g₁.[0]) (reflEqTerm ([F₃] [ρ₁] ⊢Δ₁) g₁.[0]) [g₁0≡g₂0] = transEqTerm ([G₃] [ρ₁] ⊢Δ₁ g₁.[0]) (transEqTerm ([G₃] [ρ₁] ⊢Δ₁ g₁.[0]) [g₁0≡g₁] [g₁≡g₂]′) (convEqTerm₂ ([G₃] [ρ₁] ⊢Δ₁ g₁.[0]) ([G₄] [ρ₁] ⊢Δ₁ [0:F₄]) ([G₃≡G₄] [ρ₁] ⊢Δ₁ g₁.[0]) (symEqTerm ([G₄] [ρ₁] ⊢Δ₁ [0:F₄]) [g₂0≡g₂])) x₀ = escapeTermEq ([G₃] [ρ₁] ⊢Δ₁ g₁.[0]) [g₁0≡g₂0] x₁ = PE.subst (λ X → Δ₁ ⊢ (lam (wk1 F₃) ▹ wk1d (g₁.g (step id) (var 0)) ^ ⁰) ∘ (var 0) ^ ⁰ ≅ (lam (wk1 F₄) ▹ wk1d (g₂.g (step id) (var 0)) ^ ⁰) ∘ (var 0) ^ ⁰ ∷ X ^ [ ! , ι ⁰ ]) (wkSingleSubstId G₃) x₀ in ≅-η-eq (≡is≤ PE.refl) (≡is≤ PE.refl) ⊢F₃ g₁.⊢λg (conv g₂.⊢λg (sym (≅-eq A₃≡A₄))) lamₙ lamₙ x₁ [g₁a≡g₂a] : ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₃ ^ [ rF , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → (Δ ⊩⟨ ι ⁰ ⟩ wk ρ (lam F₃ ▹ g₁.g (step id) (var 0) ^ ⁰) ∘ a ^ ⁰ ≡ wk ρ (lam F₄ ▹ g₂.g (step id) (var 0) ^ ⁰) ∘ a ^ ⁰ ∷ wk (lift ρ) G₃ [ a ] ^ [ ! , ι ⁰ ] / [G₃] [ρ] ⊢Δ [a]) [g₁a≡g₂a] [ρ] ⊢Δ [a] = let [a]′ = convTerm₁ ([F₃] [ρ] ⊢Δ) ([F₄] [ρ] ⊢Δ) ([F₃≡F₄] [ρ] ⊢Δ) [a] [a≡a] = reflEqTerm ([F₃] [ρ] ⊢Δ) [a] in redSubst*EqTerm (g₁.g∘a≡ga [ρ] ⊢Δ [a]) (g₂.g∘a≡ga [ρ] ⊢Δ [a]′) ([G₃] [ρ] ⊢Δ [a]) ([G₄] [ρ] ⊢Δ [a]′) ([G₃≡G₄] [ρ] ⊢Δ [a]) (g₁.[g] [ρ] ⊢Δ [a]) (g₂.[g] [ρ] ⊢Δ [a]′) ([g₁≡g₂] [ρ] ⊢Δ [a] [a]′ [a≡a])
{ "alphanum_fraction": 0.3688053197, "avg_line_length": 68.3778801843, "ext": "agda", "hexsha": "978b5fe43714c1cf58d73296650fbce4f0ad753c", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Castlemmas.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Castlemmas.agda", "max_line_length": 208, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Castlemmas.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z", "max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z", "num_tokens": 28018, "size": 44514 }
------------------------------------------------------------------------ -- Universe levels ------------------------------------------------------------------------ module Imports.Level where open import Agda.Primitive using (Level; _⊔_) renaming (lzero to zero; lsuc to suc)
{ "alphanum_fraction": 0.3584229391, "avg_line_length": 31, "ext": "agda", "hexsha": "f8c031d278568f6aad2bc3efc9fac02b675c5653", "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/Imports/Level.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/Imports/Level.agda", "max_line_length": 83, "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/Imports/Level.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": 40, "size": 279 }