Search is not available for this dataset
text
string
meta
dict
{-# OPTIONS --with-K --safe --no-sized-types --no-guardedness --no-subtyping #-} module Agda.Builtin.Equality.Erase where open import Agda.Builtin.Equality primitive primEraseEquality : ∀ {a} {A : Set a} {x y : A} → x ≡ y → x ≡ y
{ "alphanum_fraction": 0.6326530612, "avg_line_length": 27.2222222222, "ext": "agda", "hexsha": "07faadc05bc2366ea29518570900a72dbff738fa", "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": "src/data/lib/prim/Agda/Builtin/Equality/Erase.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2015-09-15T15:49:15.000Z", "max_issues_repo_issues_event_min_datetime": "2015-09-15T15:49:15.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/Equality/Erase.agda", "max_line_length": 73, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/Equality/Erase.agda", "max_stars_repo_stars_event_max_datetime": "2016-05-20T13:58:52.000Z", "max_stars_repo_stars_event_min_datetime": "2016-05-20T13:58:52.000Z", "num_tokens": 76, "size": 245 }
------------------------------------------------------------------------ -- "Reasoning" combinators ------------------------------------------------------------------------ open import Atom module Reasoning (atoms : χ-atoms) where open import Equality.Propositional open import Chi atoms open import Values atoms infix -1 finally-⇓ _■⟨_⟩ _■⟨_⟩⋆ infixr -2 step-≡⇓ step-⇓ _⟶⟨⟩_ modus-ponens-⇓ step-≡⇓ : ∀ e₁ {e₂ e₃} → e₂ ⇓ e₃ → e₁ ≡ e₂ → e₁ ⇓ e₃ step-≡⇓ _ e₂⇓e₃ refl = e₂⇓e₃ syntax step-≡⇓ e₁ e₂⇓e₃ e₁≡e₂ = e₁ ≡⟨ e₁≡e₂ ⟩⟶ e₂⇓e₃ _⟶⟨⟩_ : ∀ e₁ {e₂} → e₁ ⇓ e₂ → e₁ ⇓ e₂ _ ⟶⟨⟩ e₁⇓e₂ = e₁⇓e₂ mutual _■⟨_⟩ : ∀ e → Value e → e ⇓ e _ ■⟨ lambda x e ⟩ = lambda _ ■⟨ const c vs ⟩ = const (_ ■⟨ vs ⟩⋆) _■⟨_⟩⋆ : ∀ es → Values es → es ⇓⋆ es _ ■⟨ [] ⟩⋆ = [] _ ■⟨ v ∷ vs ⟩⋆ = (_ ■⟨ v ⟩) ∷ (_ ■⟨ vs ⟩⋆) finally-⇓ : (e₁ e₂ : Exp) → e₁ ⇓ e₂ → e₁ ⇓ e₂ finally-⇓ _ _ e₁⇓e₂ = e₁⇓e₂ syntax finally-⇓ e₁ e₂ e₁⇓e₂ = e₁ ⇓⟨ e₁⇓e₂ ⟩■ e₂ modus-ponens-⇓ : ∀ e {e′ v} → e′ ⇓ v → (e′ ⇓ v → e ⇓ v) → e ⇓ v modus-ponens-⇓ _ x f = f x syntax modus-ponens-⇓ e x f = e ⟶⟨ f ⟩ x mutual trans-⇓ : ∀ {e₁ e₂ e₃} → e₁ ⇓ e₂ → e₂ ⇓ e₃ → e₁ ⇓ e₃ trans-⇓ (apply p q r) s = apply p q (trans-⇓ r s) trans-⇓ (case p q r s) t = case p q r (trans-⇓ s t) trans-⇓ (rec p) q = rec (trans-⇓ p q) trans-⇓ lambda lambda = lambda trans-⇓ (const ps) (const qs) = const (trans-⇓⋆ ps qs) trans-⇓⋆ : ∀ {es₁ es₂ es₃} → es₁ ⇓⋆ es₂ → es₂ ⇓⋆ es₃ → es₁ ⇓⋆ es₃ trans-⇓⋆ [] [] = [] trans-⇓⋆ (p ∷ ps) (q ∷ qs) = trans-⇓ p q ∷ trans-⇓⋆ ps qs step-⇓ : ∀ e₁ {e₂ e₃} → e₂ ⇓ e₃ → e₁ ⇓ e₂ → e₁ ⇓ e₃ step-⇓ _ e₂⇓e₃ e₁⇓e₂ = trans-⇓ e₁⇓e₂ e₂⇓e₃ syntax step-⇓ e₁ e₂⇓e₃ e₁⇓e₂ = e₁ ⇓⟨ e₁⇓e₂ ⟩ e₂⇓e₃
{ "alphanum_fraction": 0.4489913545, "avg_line_length": 27.9838709677, "ext": "agda", "hexsha": "905b0feb0af406c60287d584ce1d5d1b04c5e34c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/chi", "max_forks_repo_path": "src/Reasoning.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_issues_repo_issues_event_max_datetime": "2020-06-08T11:08:25.000Z", "max_issues_repo_issues_event_min_datetime": "2020-05-21T23:29:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/chi", "max_issues_repo_path": "src/Reasoning.agda", "max_line_length": 72, "max_stars_count": 2, "max_stars_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/chi", "max_stars_repo_path": "src/Reasoning.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-20T16:27:00.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:07.000Z", "num_tokens": 990, "size": 1735 }
test = Prop
{ "alphanum_fraction": 0.6153846154, "avg_line_length": 4.3333333333, "ext": "agda", "hexsha": "3a5e6afa9bcd95f1bdfe42c95b65f7682476720c", "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/default-flags/DefaultFlags.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/default-flags/DefaultFlags.agda", "max_line_length": 11, "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/default-flags/DefaultFlags.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": 5, "size": 13 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Decorated star-lists ------------------------------------------------------------------------ module Data.Star.Decoration where open import Data.Star open import Relation.Binary open import Function open import Data.Unit open import Level -- A predicate on relation "edges" (think of the relation as a graph). EdgePred : {I : Set} → Rel I zero → Set₁ EdgePred T = ∀ {i j} → T i j → Set data NonEmptyEdgePred {I : Set} (T : Rel I zero) (P : EdgePred T) : Set where nonEmptyEdgePred : ∀ {i j} {x : T i j} (p : P x) → NonEmptyEdgePred T P -- Decorating an edge with more information. data DecoratedWith {I : Set} {T : Rel I zero} (P : EdgePred T) : Rel (NonEmpty (Star T)) zero where ↦ : ∀ {i j k} {x : T i j} {xs : Star T j k} (p : P x) → DecoratedWith P (nonEmpty (x ◅ xs)) (nonEmpty xs) edge : ∀ {I} {T : Rel I zero} {P : EdgePred T} {i j} → DecoratedWith {T = T} P i j → NonEmpty T edge (↦ {x = x} p) = nonEmpty x decoration : ∀ {I} {T : Rel I zero} {P : EdgePred T} {i j} → (d : DecoratedWith {T = T} P i j) → P (NonEmpty.proof (edge d)) decoration (↦ p) = p -- Star-lists decorated with extra information. All P xs means that -- all edges in xs satisfy P. All : ∀ {I} {T : Rel I zero} → EdgePred T → EdgePred (Star T) All P {j = j} xs = Star (DecoratedWith P) (nonEmpty xs) (nonEmpty {y = j} ε) -- We can map over decorated vectors. gmapAll : ∀ {I} {T : Rel I zero} {P : EdgePred T} {J} {U : Rel J zero} {Q : EdgePred U} {i j} {xs : Star T i j} (f : I → J) (g : T =[ f ]⇒ U) → (∀ {i j} {x : T i j} → P x → Q (g x)) → All P xs → All {T = U} Q (gmap f g xs) gmapAll f g h ε = ε gmapAll f g h (↦ x ◅ xs) = ↦ (h x) ◅ gmapAll f g h xs -- Since we don't automatically have gmap id id xs ≡ xs it is easier -- to implement mapAll in terms of map than in terms of gmapAll. mapAll : ∀ {I} {T : Rel I zero} {P Q : EdgePred T} {i j} {xs : Star T i j} → (∀ {i j} {x : T i j} → P x → Q x) → All P xs → All Q xs mapAll {P = P} {Q} f ps = map F ps where F : DecoratedWith P ⇒ DecoratedWith Q F (↦ x) = ↦ (f x) -- We can decorate star-lists with universally true predicates. decorate : ∀ {I} {T : Rel I zero} {P : EdgePred T} {i j} → (∀ {i j} (x : T i j) → P x) → (xs : Star T i j) → All P xs decorate f ε = ε decorate f (x ◅ xs) = ↦ (f x) ◅ decorate f xs -- We can append Alls. Unfortunately _◅◅_ does not quite work. infixr 5 _◅◅◅_ _▻▻▻_ _◅◅◅_ : ∀ {I} {T : Rel I zero} {P : EdgePred T} {i j k} {xs : Star T i j} {ys : Star T j k} → All P xs → All P ys → All P (xs ◅◅ ys) ε ◅◅◅ ys = ys (↦ x ◅ xs) ◅◅◅ ys = ↦ x ◅ xs ◅◅◅ ys _▻▻▻_ : ∀ {I} {T : Rel I zero} {P : EdgePred T} {i j k} {xs : Star T j k} {ys : Star T i j} → All P xs → All P ys → All P (xs ▻▻ ys) _▻▻▻_ = flip _◅◅◅_
{ "alphanum_fraction": 0.5003265839, "avg_line_length": 33.2826086957, "ext": "agda", "hexsha": "0e954ccfad75428640cd94d3664ec3b4d36314c5", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Star/Decoration.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Star/Decoration.agda", "max_line_length": 76, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Star/Decoration.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": 1121, "size": 3062 }
module Issue1701.ModParamsToLose where module Param (A : Set) where module R (B : Set) (G : A → B) where F = G private module Tmp (B : Set) (G : A → B) where module r = R B G open Tmp public module Works (A : Set) where module ParamA = Param A open ParamA works : (A → A) → A → A works G = S.F module works where module S = r A G
{ "alphanum_fraction": 0.5860215054, "avg_line_length": 16.1739130435, "ext": "agda", "hexsha": "10c75a554c1efe786a6d1ad13c0734bb7a497375", "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/Issue1701/ModParamsToLose.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/Issue1701/ModParamsToLose.agda", "max_line_length": 41, "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/Issue1701/ModParamsToLose.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": 133, "size": 372 }
{- Basic definitions using Σ-types Σ-types are defined in Core/Primitives as they are needed for Glue types. The file contains: - Non-dependent pair types: A × B - Mere existence: ∃[x ∈ A] B - Unique existence: ∃![x ∈ A] B -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.Sigma.Base where open import Cubical.Core.Primitives public open import Cubical.Foundations.Prelude open import Cubical.HITs.PropositionalTruncation.Base -- Non-dependent pair types _×_ : ∀ {ℓ ℓ'} (A : Type ℓ) (B : Type ℓ') → Type (ℓ-max ℓ ℓ') A × B = Σ A (λ _ → B) infixr 5 _×_ -- Mere existence ∃ : ∀ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') → Type (ℓ-max ℓ ℓ') ∃ A B = ∥ Σ A B ∥ infix 2 ∃-syntax ∃-syntax : ∀ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') → Type (ℓ-max ℓ ℓ') ∃-syntax = ∃ syntax ∃-syntax A (λ x → B) = ∃[ x ∈ A ] B -- Unique existence ∃! : ∀ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') → Type (ℓ-max ℓ ℓ') ∃! A B = isContr (Σ A B) infix 2 ∃!-syntax ∃!-syntax : ∀ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') → Type (ℓ-max ℓ ℓ') ∃!-syntax = ∃! syntax ∃!-syntax A (λ x → B) = ∃![ x ∈ A ] B
{ "alphanum_fraction": 0.5753176044, "avg_line_length": 20.7924528302, "ext": "agda", "hexsha": "13c9745ad8708f1171dd5014975461a78ebec59e", "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/Sigma/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/Sigma/Base.agda", "max_line_length": 73, "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/Sigma/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 463, "size": 1102 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Dagger.Instance.Rels where open import Data.Product open import Function open import Relation.Binary.PropositionalEquality open import Level open import Categories.Category.Dagger open import Categories.Category.Instance.Rels RelsHasDagger : ∀ {o ℓ} → HasDagger (Rels o ℓ) RelsHasDagger = record { _† = flip ; †-identity = λ _ _ → (λ p → lift (sym (lower p))) , λ p → lift (sym (lower p)) ; †-homomorphism = λ _ _ → map₂ swap , map₂ swap ; †-resp-≈ = flip ; †-involutive = λ _ _ _ → id , id } RelsDagger : ∀ o ℓ → DaggerCategory (suc o) (suc (o ⊔ ℓ)) (o ⊔ ℓ) RelsDagger o ℓ = record { C = Rels o ℓ ; hasDagger = RelsHasDagger }
{ "alphanum_fraction": 0.6671348315, "avg_line_length": 27.3846153846, "ext": "agda", "hexsha": "3f35a16c326deb12bf2db3188e8b48ad53792985", "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": "b813fa3e685eb4713bace6204b8084a343d549a3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bolt12/agda-categories", "max_forks_repo_path": "src/Categories/Category/Dagger/Instance/Rels.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b813fa3e685eb4713bace6204b8084a343d549a3", "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": "bolt12/agda-categories", "max_issues_repo_path": "src/Categories/Category/Dagger/Instance/Rels.agda", "max_line_length": 82, "max_stars_count": null, "max_stars_repo_head_hexsha": "b813fa3e685eb4713bace6204b8084a343d549a3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bolt12/agda-categories", "max_stars_repo_path": "src/Categories/Category/Dagger/Instance/Rels.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 247, "size": 712 }
module Categories.Fam where open import Level open import Relation.Binary using (Rel) import Relation.Binary.HeterogeneousEquality as Het open Het using (_≅_) renaming (refl to ≣-refl) open import Categories.Support.PropositionalEquality open import Categories.Category module Fam {a b : Level} where record Fam : Set (suc a ⊔ suc b) where constructor _,_ field U : Set a T : U → Set b open Fam public record Hom (A B : Fam) : Set (a ⊔ b) where constructor _,_ field f : U A → U B φ : (x : U A) → T A x → T B (f x) record _≡Fam_ {X Y} (f g : (Hom X Y)) : Set (a ⊔ b) where constructor _,_ field f≡g : {x : _} → Hom.f f x ≣ Hom.f g x φ≡γ : {x : _} {bx : _} → Hom.φ f x bx ≅ Hom.φ g x bx module Eq = _≡Fam_ Cat : Category (suc a ⊔ suc b) (a ⊔ b) (a ⊔ b) Cat = record { Obj = Fam; _⇒_ = Hom; _≡_ = _≡Fam_; id = id′; _∘_ = _∘′_; assoc = ≣-refl , ≣-refl; identityˡ = ≣-refl , ≣-refl; identityʳ = ≣-refl , ≣-refl; equiv = record { refl = ≣-refl , ≣-refl; sym = \ { (f≡g , φ≡γ) → ≣-sym f≡g , Het.sym φ≡γ }; trans = λ {(f≡g , φ≡γ) (g≡h , γ≡η) → ≣-trans f≡g g≡h , Het.trans φ≡γ γ≡η} }; ∘-resp-≡ = ∘-resp-≡′ } where id′ : {A : Fam} → Hom A A id′ = (\ x → x) , (\ x bx → bx) _∘′_ : {A B C : Fam} → Hom B C → Hom A B → Hom A C _∘′_ (f , φ) (g , γ) = (λ x → f (g x)) , (λ x bx → φ (g x) (γ x bx)) sym′ : ∀ {X Y} → Relation.Binary.Symmetric (_≡Fam_ {X} {Y}) sym′ {Ax , Bx} {Ay , By} {f , φ} {g , γ} (f≡g , φ≡γ) = ≣-sym f≡g , Het.sym φ≡γ ∘-resp-≡′ : {A B C : Fam} {f h : Hom B C} {g i : Hom A B} → f ≡Fam h → g ≡Fam i → (f ∘′ g) ≡Fam (h ∘′ i) ∘-resp-≡′ {f = (f , φ)} {g , γ} {h , η} {i , ι} (f≡g , φ≡γ) (h≡i , η≡ι) = ≣-trans f≡g (≣-cong g h≡i) , Het.trans φ≡γ (Het.cong₂ γ (Het.≡-to-≅ h≡i) η≡ι) open Category Cat public Fam : ∀ a b → Category (suc a ⊔ suc b) (a ⊔ b) (a ⊔ b) Fam a b = Fam.Cat {a} {b}
{ "alphanum_fraction": 0.4443418014, "avg_line_length": 31.8382352941, "ext": "agda", "hexsha": "a02f75789e3792ecf17a8368e8d47a451524d0bf", "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/Fam.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/Fam.agda", "max_line_length": 109, "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/Fam.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": 929, "size": 2165 }
record R (A : Set) : Set where constructor c₂ field f : A → A g : A → A g x = f (f x) open R public _ : (@0 A : Set) → R A → A → A _ = λ A → g {A = A}
{ "alphanum_fraction": 0.4518072289, "avg_line_length": 12.7692307692, "ext": "agda", "hexsha": "c7c5ec08fd2f0126c22189082b069731c493cc8d", "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/Fail/Issue4786a.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/Fail/Issue4786a.agda", "max_line_length": 30, "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/Fail/Issue4786a.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": 73, "size": 166 }
{-# OPTIONS --without-K #-} module SetoidEquiv where open import Level using (Level; _⊔_) open import Function.Equality using (_∘_; _⟶_; _⟨$⟩_) open import Relation.Binary using (Setoid; module Setoid) open import Relation.Binary.PropositionalEquality as P using (setoid) open Setoid infix 4 _≃S_ ------------------------------------------------------------------------------ -- A setoid gives us a set and an equivalence relation on that set. -- A common equivalence relation that is used on setoids is ≡ -- In general, two setoids are equivalent if: record _≃S_ {ℓ₁ ℓ₂ ℓ₃ ℓ₄ : Level} (A : Setoid ℓ₁ ℓ₂) (B : Setoid ℓ₃ ℓ₄) : Set (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) where constructor equiv field f : A ⟶ B g : B ⟶ A α : ∀ {x y} → _≈_ B x y → _≈_ B ((f ∘ g) ⟨$⟩ x) y β : ∀ {x y} → _≈_ A x y → _≈_ A ((g ∘ f) ⟨$⟩ x) y -- Abbreviation for the special case in which the equivalence relation -- is just ≡: _≃S≡_ : ∀ {ℓ₁} → (A B : Set ℓ₁) → Set ℓ₁ A ≃S≡ B = (P.setoid A) ≃S (P.setoid B) -- Two equivalences between setoids are themselves equivalent if record _≋_ {ℓ₁} {A B : Set ℓ₁} (eq₁ eq₂ : A ≃S≡ B) : Set ℓ₁ where constructor equivS field f≡ : ∀ (x : A) → P._≡_ (_≃S_.f eq₁ ⟨$⟩ x) (_≃S_.f eq₂ ⟨$⟩ x) g≡ : ∀ (x : B) → P._≡_ (_≃S_.g eq₁ ⟨$⟩ x) (_≃S_.g eq₂ ⟨$⟩ x) -- note that this appears to be redundant (especially when looking -- at the proofs), but having both f and g is needed for inference -- of other aspects to succeed. id≋ : ∀ {ℓ} {A B : Set ℓ} {x : A ≃S≡ B} → x ≋ x id≋ = record { f≡ = λ x → P.refl ; g≡ = λ x → P.refl } sym≋ : ∀ {ℓ} {A B : Set ℓ} {x y : A ≃S≡ B} → x ≋ y → y ≋ x sym≋ (equivS f≡ g≡) = equivS (λ a → P.sym (f≡ a)) (λ b → P.sym (g≡ b)) trans≋ : ∀ {ℓ} {A B : Set ℓ} {x y z : A ≃S≡ B} → x ≋ y → y ≋ z → x ≋ z trans≋ (equivS f≡ g≡) (equivS h≡ i≡) = equivS (λ a → P.trans (f≡ a) (h≡ a)) (λ b → P.trans (g≡ b) (i≡ b)) -- The set of equivalences between setoids is itself is a setoid -- WARNING: this is not generic, but specific to ≡-Setoids of functions. ≃S-Setoid : ∀ {ℓ₁} → (A B : Set ℓ₁) → Setoid ℓ₁ ℓ₁ ≃S-Setoid {ℓ₁} A B = record { Carrier = AS ≃S BS ; _≈_ = _≋_ ; isEquivalence = record { refl = id≋ ; sym = sym≋ ; trans = trans≋ } } where open _≃S_ AS = P.setoid A BS = P.setoid B ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.513029316, "avg_line_length": 32.7466666667, "ext": "agda", "hexsha": "544972810f8d84e7f1834f170c9d59352d13d202", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/SetoidEquiv.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/SetoidEquiv.agda", "max_line_length": 79, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/SetoidEquiv.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 983, "size": 2456 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Base.Types import LibraBFT.Impl.Consensus.ConsensusTypes.BlockData as BlockData import LibraBFT.Impl.Consensus.ConsensusTypes.QuorumCert as QuorumCert import LibraBFT.Impl.Types.BlockInfo as BlockInfo import LibraBFT.Impl.Types.ValidatorVerifier as ValidatorVerifier open import LibraBFT.Impl.OBM.Crypto open import LibraBFT.Impl.OBM.Logging.Logging open import LibraBFT.ImplShared.Base.Types open import LibraBFT.ImplShared.Consensus.Types open import Optics.All open import Util.Hash open import Util.PKCS open import Util.Prelude ------------------------------------------------------------------------------ open import Data.String using (String) module LibraBFT.Impl.Consensus.ConsensusTypes.Block where genBlockInfo : Block → HashValue → Version → Maybe EpochState → BlockInfo genBlockInfo b executedStateId version nextEpochState = BlockInfo∙new (b ^∙ bEpoch) (b ^∙ bRound) (b ^∙ bId) executedStateId version nextEpochState isGenesisBlock : Block → Bool isGenesisBlock b = BlockData.isGenesisBlock (b ^∙ bBlockData) isNilBlock : Block → Bool isNilBlock b = BlockData.isNilBlock (b ^∙ bBlockData) makeGenesisBlockFromLedgerInfo : LedgerInfo → Either ErrLog Block makeGenesisBlockFromLedgerInfo li = do blockData <- BlockData.newGenesisFromLedgerInfo li pure (Block∙new (hashBD blockData) blockData nothing) newNil : Round → QuorumCert → Block newNil r qc = Block∙new (hashBD blockData) blockData nothing where blockData = BlockData.newNil r qc newProposalFromBlockDataAndSignature : BlockData → Signature → Block newProposalFromBlockDataAndSignature blockData signature = Block∙new (hashBD blockData) blockData (just signature) validateSignature : Block → ValidatorVerifier → Either ErrLog Unit validateSignature self validator = case self ^∙ bBlockData ∙ bdBlockType of λ where Genesis → Left fakeErr -- (ErrL (here' ["do not accept genesis from others"])) NilBlock → QuorumCert.verify (self ^∙ bQuorumCert) validator (Proposal _ author) → do fromMaybeM (Left fakeErr) -- (ErrL (here' ["Missing signature in Proposal"]))) (pure (self ^∙ bSignature)) >>= λ sig -> withErrCtx' (here' []) (ValidatorVerifier.verify validator author (self ^∙ bBlockData) sig) QuorumCert.verify (self ^∙ bQuorumCert) validator where here' : List String → List String here' t = "Block" ∷ "validateSignatures" {-∷ lsB self-} ∷ t verifyWellFormed : Block → Either ErrLog Unit verifyWellFormed self = do lcheck (not (isGenesisBlock self)) (here' ("Do not accept genesis from others" ∷ [])) let parent = self ^∙ bQuorumCert ∙ qcCertifiedBlock lcheck (parent ^∙ biRound <? self ^∙ bRound) (here' ("Block must have a greater round than parent's block" ∷ [])) lcheck (parent ^∙ biEpoch == self ^∙ bEpoch) (here' ("block's parent should be in the same epoch" ∷ [])) lcheck (not (BlockInfo.hasReconfiguration parent) ∨ maybe true payloadIsEmpty (self ^∙ bPayload)) (here' ("Reconfiguration suffix should not carry payload" ∷ [])) -- timestamps go here -- Haskell removed them lcheck (not (self ^∙ bQuorumCert ∙ qcEndsEpoch)) (here' ("Block cannot be proposed in an epoch that has ended" ∷ [])) lcheck (self ^∙ bId == hashBD (self ^∙ bBlockData)) (here' ("Block id hash mismatch" ∷ [])) where here' : List String → List String here' t = "Block" ∷ "verifyWellFormed" {-∷ lsB self-} ∷ t
{ "alphanum_fraction": 0.6985975126, "avg_line_length": 46.0853658537, "ext": "agda", "hexsha": "1c817c0dc3a0bb035e5e2e233ba2dfd44361ef09", "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/Consensus/ConsensusTypes/Block.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/Consensus/ConsensusTypes/Block.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/Consensus/ConsensusTypes/Block.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1033, "size": 3779 }
-- Andreas, 2013-10-21 fixed this issue -- by refactoring Internal to spine syntax. module Issue901 where open import Common.Level record Ls : Set where constructor _,_ field fst : Level snd : Level open Ls record R (ls : Ls) : Set (lsuc (fst ls ⊔ snd ls)) where field A : Set (fst ls) B : Set (snd ls) bad : R _ bad = record { A = Set; B = Set₁ } good : R (_ , _) good = record { A = Set; B = Set₁ } {- PROBLEM WAS: "good" is fine while the body and signature of "bad" are marked in yellow. Both are fine if we change the parameter of R to not contain levels. The meta _1 in R _ is never eta-expanded somehow. I think this problem will vanish if we let whnf eta-expand metas that are projected. E.g. fst _1 will result in _1 := _2,_3 and then reduce to _2 (And that would be easier to implement if Internal was a spine syntax (with post-fix projections)). -}
{ "alphanum_fraction": 0.6740331492, "avg_line_length": 19.6739130435, "ext": "agda", "hexsha": "5a1a257f2e157346e4aabdbc0eb382d80a6167e8", "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/Issue901.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/Issue901.agda", "max_line_length": 74, "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/Issue901.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": 269, "size": 905 }
module halt where open import Level renaming ( zero to Zero ; suc to Suc ) open import Data.Nat open import Data.Maybe open import Data.List hiding ([_]) open import Data.Nat.Properties open import Relation.Nullary open import Data.Empty open import Data.Unit open import Relation.Binary.Core hiding (_⇔_) open import Relation.Binary.Definitions open import Relation.Binary.PropositionalEquality open import logic record HBijection {n m : Level} (R : Set n) (S : Set m) : Set (n Level.⊔ m) where field fun← : S → R fun→ : R → S fiso← : (x : R) → fun← ( fun→ x ) ≡ x -- normal bijection required below, but we don't need this to show the inconsistency -- fiso→ : (x : S ) → fun→ ( fun← x ) ≡ x injection' : {n m : Level} (R : Set n) (S : Set m) (f : R → S ) → Set (n Level.⊔ m) injection' R S f = (x y : R) → f x ≡ f y → x ≡ y open HBijection diag : {S : Set } (b : HBijection ( S → Bool ) S) → S → Bool diag b n = not (fun← b n n) diagonal : { S : Set } → ¬ HBijection ( S → Bool ) S diagonal {S} b = diagn1 (fun→ b (diag b) ) refl where diagn1 : (n : S ) → ¬ (fun→ b (diag b) ≡ n ) diagn1 n dn = ¬t=f (diag b n ) ( begin not (diag b n) ≡⟨⟩ not (not fun← b n n) ≡⟨ cong (λ k → not (k n) ) (sym (fiso← b _)) ⟩ not (fun← b (fun→ b (diag b)) n) ≡⟨ cong (λ k → not (fun← b k n) ) dn ⟩ not (fun← b n n) ≡⟨⟩ diag b n ∎ ) where open ≡-Reasoning record TM : Set where field tm : List Bool → Maybe Bool open TM record UTM : Set where field utm : TM encode : TM → List Bool is-tm : (t : TM) → (x : List Bool) → tm utm (encode t ++ x ) ≡ tm t x open UTM open _∧_ open import Axiom.Extensionality.Propositional postulate f-extensionality : { n : Level} → Axiom.Extensionality.Propositional.Extensionality n n record Halt : Set where field halt : (t : TM ) → (x : List Bool ) → Bool is-halt : (t : TM ) → (x : List Bool ) → (halt t x ≡ true ) ⇔ ( (just true ≡ tm t x ) ∨ (just false ≡ tm t x ) ) is-not-halt : (t : TM ) → (x : List Bool ) → (halt t x ≡ false ) ⇔ ( nothing ≡ tm t x ) open Halt TNL : (halt : Halt ) → (utm : UTM) → HBijection (List Bool → Bool) (List Bool) TNL halt utm = record { fun← = λ tm x → Halt.halt halt (UTM.utm utm) (tm ++ x) ; fun→ = λ h → encode utm record { tm = h1 h } ; fiso← = λ h → f-extensionality (λ y → TN1 h y ) } where open ≡-Reasoning h1 : (h : List Bool → Bool) → (x : List Bool ) → Maybe Bool h1 h x with h x ... | true = just true ... | false = nothing tenc : (h : List Bool → Bool) → (y : List Bool) → List Bool tenc h y = encode utm (record { tm = λ x → h1 h x }) ++ y h-nothing : (h : List Bool → Bool) → (y : List Bool) → h y ≡ false → h1 h y ≡ nothing h-nothing h y eq with h y h-nothing h y refl | false = refl h-just : (h : List Bool → Bool) → (y : List Bool) → h y ≡ true → h1 h y ≡ just true h-just h y eq with h y h-just h y refl | true = refl TN1 : (h : List Bool → Bool) → (y : List Bool ) → Halt.halt halt (UTM.utm utm) (tenc h y) ≡ h y TN1 h y with h y | inspect h y ... | true | record { eq = eq1 } = begin Halt.halt halt (UTM.utm utm) (tenc h y) ≡⟨ proj2 (is-halt halt (UTM.utm utm) (tenc h y) ) (case1 (sym tm-tenc)) ⟩ true ∎ where tm-tenc : tm (UTM.utm utm) (tenc h y) ≡ just true tm-tenc = begin tm (UTM.utm utm) (tenc h y) ≡⟨ is-tm utm _ y ⟩ h1 h y ≡⟨ h-just h y eq1 ⟩ just true ∎ ... | false | record { eq = eq1 } = begin Halt.halt halt (UTM.utm utm) (tenc h y) ≡⟨ proj2 (is-not-halt halt (UTM.utm utm) (tenc h y) ) (sym tm-tenc) ⟩ false ∎ where tm-tenc : tm (UTM.utm utm) (tenc h y) ≡ nothing tm-tenc = begin tm (UTM.utm utm) (tenc h y) ≡⟨ is-tm utm _ y ⟩ h1 h y ≡⟨ h-nothing h y eq1 ⟩ nothing ∎ -- the rest of bijection means encoding is unique -- fiso→ : (y : List Bool ) → encode utm record { tm = λ x → h1 (λ tm → Halt.halt halt (UTM.utm utm) tm ) x } ≡ y TNL1 : UTM → ¬ Halt TNL1 utm halt = diagonal ( TNL halt utm )
{ "alphanum_fraction": 0.5300255043, "avg_line_length": 36.8632478632, "ext": "agda", "hexsha": "cd8a8f386d7cb6cc2d5ead9af22d84f08d35ae34", "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": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/automaton-in-agda", "max_forks_repo_path": "src/halt.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "shinji-kono/automaton-in-agda", "max_issues_repo_path": "src/halt.agda", "max_line_length": 123, "max_stars_count": null, "max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/automaton-in-agda", "max_stars_repo_path": "src/halt.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1609, "size": 4313 }
------------------------------------------------------------------------------ -- Properties of the inequalities ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module LTC-PCF.Data.Nat.Inequalities.Properties where open import Common.FOL.Relation.Binary.EqReasoning open import LTC-PCF.Base open import LTC-PCF.Base.Properties open import LTC-PCF.Data.Nat open import LTC-PCF.Data.Nat.Inequalities open import LTC-PCF.Data.Nat.Inequalities.EliminationProperties open import LTC-PCF.Data.Nat.Inequalities.ConversionRules public open import LTC-PCF.Data.Nat.Properties open import LTC-PCF.Data.Nat.UnaryNumbers ------------------------------------------------------------------------------ -- N.B. The elimination properties are in the module -- LTC.Data.Nat.Inequalities.EliminationProperties. ------------------------------------------------------------------------------ -- Congruence properties ltLeftCong : ∀ {m n o} → m ≡ n → lt m o ≡ lt n o ltLeftCong refl = refl ltRightCong : ∀ {m n o} → n ≡ o → lt m n ≡ lt m o ltRightCong refl = refl ------------------------------------------------------------------------------ 0≯x : ∀ {n} → N n → zero ≯ n 0≯x nzero = lt-00 0≯x (nsucc {n} Nn) = lt-S0 n x≮x : ∀ {n} → N n → n ≮ n x≮x nzero = lt-00 x≮x (nsucc {n} Nn) = trans (lt-SS n n) (x≮x Nn) Sx≰0 : ∀ {n} → N n → succ₁ n ≰ zero Sx≰0 nzero = x≮x (nsucc nzero) Sx≰0 (nsucc {n} Nn) = trans (lt-SS (succ₁ n) zero) (lt-S0 n) x<Sx : ∀ {n} → N n → n < succ₁ n x<Sx nzero = lt-0S zero x<Sx (nsucc {n} Nn) = trans (lt-SS n (succ₁ n)) (x<Sx Nn) x<y→Sx<Sy : ∀ {m n} → m < n → succ₁ m < succ₁ n x<y→Sx<Sy {m} {n} m<n = trans (lt-SS m n) m<n Sx<Sy→x<y : ∀ {m n} → succ₁ m < succ₁ n → m < n Sx<Sy→x<y {m} {n} Sm<Sn = trans (sym (lt-SS m n)) Sm<Sn x≤x : ∀ {n} → N n → n ≤ n x≤x nzero = lt-0S zero x≤x (nsucc {n} Nn) = trans (lt-SS n (succ₁ n)) (x≤x Nn) x≤y→Sx≤Sy : ∀ {m n} → m ≤ n → succ₁ m ≤ succ₁ n x≤y→Sx≤Sy {m} {n} m≤n = trans (lt-SS m (succ₁ n)) m≤n Sx≤Sy→x≤y : ∀ {m n} → succ₁ m ≤ succ₁ n → m ≤ n Sx≤Sy→x≤y {m} {n} Sm≤Sn = trans (sym (lt-SS m (succ₁ n))) Sm≤Sn x≥y→x≮y : ∀ {m n} → N m → N n → m ≥ n → m ≮ n x≥y→x≮y nzero nzero _ = x≮x nzero x≥y→x≮y nzero (nsucc Nn) 0≥Sn = ⊥-elim (0≥S→⊥ Nn 0≥Sn) x≥y→x≮y (nsucc {m} Nm) nzero _ = lt-S0 m x≥y→x≮y (nsucc {m} Nm) (nsucc {n} Nn) Sm≥Sn = trans (lt-SS m n) (x≥y→x≮y Nm Nn (trans (sym (lt-SS n (succ₁ m))) Sm≥Sn)) x≮y→x≥y : ∀ {m n} → N m → N n → m ≮ n → m ≥ n x≮y→x≥y nzero nzero 0≮0 = x≤x nzero x≮y→x≥y nzero (nsucc {n} Nn) 0≮Sn = ⊥-elim (t≢f (trans (sym (lt-0S n)) 0≮Sn)) x≮y→x≥y (nsucc {m} Nm) nzero Sm≮n = lt-0S (succ₁ m) x≮y→x≥y (nsucc {m} Nm) (nsucc {n} Nn) Sm≮Sn = trans (lt-SS n (succ₁ m)) (x≮y→x≥y Nm Nn (trans (sym (lt-SS m n)) Sm≮Sn)) x>y∨x≤y : ∀ {m n} → N m → N n → m > n ∨ m ≤ n x>y∨x≤y {n = n} nzero Nn = inj₂ (lt-0S n) x>y∨x≤y (nsucc {m} Nm) nzero = inj₁ (lt-0S m) x>y∨x≤y (nsucc {m} Nm) (nsucc {n} Nn) = case (λ m>n → inj₁ (trans (lt-SS n m) m>n)) (λ m≤n → inj₂ (trans (lt-SS m (succ₁ n)) m≤n)) (x>y∨x≤y Nm Nn) x≤y→x≯y : ∀ {m n} → N m → N n → m ≤ n → m ≯ n x≤y→x≯y nzero Nn _ = 0≯x Nn x≤y→x≯y (nsucc Nm) nzero Sm≤0 = ⊥-elim (S≤0→⊥ Nm Sm≤0) x≤y→x≯y (nsucc {m} Nm) (nsucc {n} Nn) Sm≤Sn = trans (lt-SS n m) (x≤y→x≯y Nm Nn (trans (sym (lt-SS m (succ₁ n))) Sm≤Sn)) x≯y→x≤y : ∀ {m n} → N m → N n → m ≯ n → m ≤ n x≯y→x≤y {n = n} nzero Nn _ = lt-0S n x≯y→x≤y (nsucc {m} Nm) nzero Sm≯0 = ⊥-elim (t≢f (trans (sym (lt-0S m)) Sm≯0)) x≯y→x≤y (nsucc {m} Nm) (nsucc {n} Nn) Sm≯Sn = trans (lt-SS m (succ₁ n)) (x≯y→x≤y Nm Nn (trans (sym (lt-SS n m)) Sm≯Sn)) x>y∨x≯y : ∀ {m n} → N m → N n → m > n ∨ m ≯ n x>y∨x≯y nzero Nn = inj₂ (0≯x Nn) x>y∨x≯y (nsucc {m} Nm) nzero = inj₁ (lt-0S m) x>y∨x≯y (nsucc {m} Nm) (nsucc {n} Nn) = case (λ h → inj₁ (trans (lt-SS n m) h)) (λ h → inj₂ (trans (lt-SS n m) h)) (x>y∨x≯y Nm Nn) x<y∨x≥y : ∀ {m n} → N m → N n → m < n ∨ m ≥ n x<y∨x≥y Nm Nn = x>y∨x≤y Nn Nm x<y∨x≮y : ∀ {m n} → N m → N n → m < n ∨ m ≮ n x<y∨x≮y Nm Nn = case (λ m<n → inj₁ m<n) (λ m≥n → inj₂ (x≥y→x≮y Nm Nn m≥n)) (x<y∨x≥y Nm Nn) x≡y→x≤y : ∀ {m n} → N m → N n → m ≡ n → m ≤ n x≡y→x≤y Nm _ refl = x≤x Nm x<y→x≤y : ∀ {m n} → N m → N n → m < n → m ≤ n x<y→x≤y Nm nzero m<0 = ⊥-elim (x<0→⊥ Nm m<0) x<y→x≤y nzero (nsucc {n} Nn) _ = lt-0S (succ₁ n) x<y→x≤y (nsucc {m} Nm) (nsucc {n} Nn) Sm<Sn = x≤y→Sx≤Sy (x<y→x≤y Nm Nn (Sx<Sy→x<y Sm<Sn)) x<Sy→x≤y : ∀ {m n} → N m → N n → m < succ₁ n → m ≤ n x<Sy→x≤y {n = n} nzero Nn 0<Sn = lt-0S n x<Sy→x≤y (nsucc Nm) Nn Sm<Sn = Sm<Sn x≤Sx : ∀ {m} → N m → m ≤ succ₁ m x≤Sx Nm = x<y→x≤y Nm (nsucc Nm) (x<Sx Nm) x<y→Sx≤y : ∀ {m n} → N m → N n → m < n → succ₁ m ≤ n x<y→Sx≤y Nm nzero m<0 = ⊥-elim (x<0→⊥ Nm m<0) x<y→Sx≤y nzero (nsucc {n} Nn) _ = x≤y→Sx≤Sy (lt-0S n) x<y→Sx≤y (nsucc {m} Nm) (nsucc {n} Nn) Sm<Sn = trans (lt-SS (succ₁ m) (succ₁ n)) Sm<Sn Sx≤y→x<y : ∀ {m n} → N m → N n → succ₁ m ≤ n → m < n Sx≤y→x<y Nm nzero Sm≤0 = ⊥-elim (S≤0→⊥ Nm Sm≤0) Sx≤y→x<y nzero (nsucc {n} Nn) _ = lt-0S n Sx≤y→x<y (nsucc {m} Nm) (nsucc {n} Nn) SSm≤Sn = x<y→Sx<Sy (Sx≤y→x<y Nm Nn (Sx≤Sy→x≤y SSm≤Sn)) <-trans : ∀ {m n o} → N m → N n → N o → m < n → n < o → m < o <-trans nzero nzero _ 0<0 _ = ⊥-elim (0<0→⊥ 0<0) <-trans nzero (nsucc Nn) nzero _ Sn<0 = ⊥-elim (S<0→⊥ Sn<0) <-trans nzero (nsucc Nn) (nsucc {o} No) _ _ = lt-0S o <-trans (nsucc Nm) Nn nzero _ n<0 = ⊥-elim (x<0→⊥ Nn n<0) <-trans (nsucc Nm) nzero (nsucc No) Sm<0 _ = ⊥-elim (S<0→⊥ Sm<0) <-trans (nsucc {m} Nm) (nsucc {n} Nn) (nsucc {o} No) Sm<Sn Sn<So = x<y→Sx<Sy (<-trans Nm Nn No (Sx<Sy→x<y Sm<Sn) (Sx<Sy→x<y Sn<So)) ≤-trans : ∀ {m n o} → N m → N n → N o → m ≤ n → n ≤ o → m ≤ o ≤-trans {o = o} nzero Nn No _ _ = lt-0S o ≤-trans (nsucc Nm) nzero No Sm≤0 _ = ⊥-elim (S≤0→⊥ Nm Sm≤0) ≤-trans (nsucc Nm) (nsucc Nn) nzero _ Sn≤0 = ⊥-elim (S≤0→⊥ Nn Sn≤0) ≤-trans (nsucc {m} Nm) (nsucc {n} Nn) (nsucc {o} No) Sm≤Sn Sn≤So = x≤y→Sx≤Sy (≤-trans Nm Nn No (Sx≤Sy→x≤y Sm≤Sn) (Sx≤Sy→x≤y Sn≤So)) x≤x+y : ∀ {m n} → N m → N n → m ≤ m + n x≤x+y {n = n} nzero Nn = lt-0S (zero + n) x≤x+y {n = n} (nsucc {m} Nm) Nn = lt (succ₁ m) (succ₁ (succ₁ m + n)) ≡⟨ lt-SS m (succ₁ m + n) ⟩ lt m (succ₁ m + n) ≡⟨ ltRightCong (+-Sx m n) ⟩ lt m (succ₁ (m + n)) ≡⟨ refl ⟩ le m (m + n) ≡⟨ x≤x+y Nm Nn ⟩ true ∎ x∸y<Sx : ∀ {m n} → N m → N n → m ∸ n < succ₁ m x∸y<Sx {m} Nm nzero = lt (m ∸ zero) (succ₁ m) ≡⟨ ltLeftCong (∸-x0 m) ⟩ lt m (succ₁ m) ≡⟨ x<Sx Nm ⟩ true ∎ x∸y<Sx nzero (nsucc {n} Nn) = lt (zero ∸ succ₁ n) [1] ≡⟨ ltLeftCong (0∸x (nsucc Nn)) ⟩ lt zero [1] ≡⟨ lt-0S zero ⟩ true ∎ x∸y<Sx (nsucc {m} Nm) (nsucc {n} Nn) = lt (succ₁ m ∸ succ₁ n) (succ₁ (succ₁ m)) ≡⟨ ltLeftCong (S∸S Nm Nn) ⟩ lt (m ∸ n) (succ₁ (succ₁ m)) ≡⟨ <-trans (∸-N Nm Nn) (nsucc Nm) (nsucc (nsucc Nm)) (x∸y<Sx Nm Nn) (x<Sx (nsucc Nm)) ⟩ true ∎ Sx∸Sy<Sx : ∀ {m n} → N m → N n → succ₁ m ∸ succ₁ n < succ₁ m Sx∸Sy<Sx {m} {n} Nm Nn = lt (succ₁ m ∸ succ₁ n) (succ₁ m) ≡⟨ ltLeftCong (S∸S Nm Nn) ⟩ lt (m ∸ n) (succ₁ m) ≡⟨ x∸y<Sx Nm Nn ⟩ true ∎ x>y→x∸y+y≡x : ∀ {m n} → N m → N n → m > n → (m ∸ n) + n ≡ m x>y→x∸y+y≡x nzero Nn 0>n = ⊥-elim (0>x→⊥ Nn 0>n) x>y→x∸y+y≡x (nsucc {m} Nm) nzero Sm>0 = trans (+-rightIdentity (∸-N (nsucc Nm) nzero)) (∸-x0 (succ₁ m)) x>y→x∸y+y≡x (nsucc {m} Nm) (nsucc {n} Nn) Sm>Sn = (succ₁ m ∸ succ₁ n) + succ₁ n ≡⟨ +-leftCong (S∸S Nm Nn) ⟩ (m ∸ n) + succ₁ n ≡⟨ +-comm (∸-N Nm Nn) (nsucc Nn) ⟩ succ₁ n + (m ∸ n) ≡⟨ +-Sx n (m ∸ n) ⟩ succ₁ (n + (m ∸ n)) ≡⟨ succCong (+-comm Nn (∸-N Nm Nn)) ⟩ succ₁ ((m ∸ n) + n) ≡⟨ succCong (x>y→x∸y+y≡x Nm Nn (trans (sym (lt-SS n m)) Sm>Sn)) ⟩ succ₁ m ∎ x≤y→y∸x+x≡y : ∀ {m n} → N m → N n → m ≤ n → (n ∸ m) + m ≡ n x≤y→y∸x+x≡y {n = n} nzero Nn 0≤n = trans (+-rightIdentity (∸-N Nn nzero)) (∸-x0 n) x≤y→y∸x+x≡y (nsucc Nm) nzero Sm≤0 = ⊥-elim (S≤0→⊥ Nm Sm≤0) x≤y→y∸x+x≡y (nsucc {m} Nm) (nsucc {n} Nn) Sm≤Sn = (succ₁ n ∸ succ₁ m) + succ₁ m ≡⟨ +-leftCong (S∸S Nn Nm) ⟩ (n ∸ m) + succ₁ m ≡⟨ +-comm (∸-N Nn Nm) (nsucc Nm) ⟩ succ₁ m + (n ∸ m) ≡⟨ +-Sx m (n ∸ m) ⟩ succ₁ (m + (n ∸ m)) ≡⟨ succCong (+-comm Nm (∸-N Nn Nm)) ⟩ succ₁ ((n ∸ m) + m) ≡⟨ succCong (x≤y→y∸x+x≡y Nm Nn (trans (sym (lt-SS m (succ₁ n))) Sm≤Sn)) ⟩ succ₁ n ∎ x<y→x<Sy : ∀ {m n} → N m → N n → m < n → m < succ₁ n x<y→x<Sy Nm nzero m<0 = ⊥-elim (x<0→⊥ Nm m<0) x<y→x<Sy nzero (nsucc {n} Nn) 0<Sn = lt-0S (succ₁ n) x<y→x<Sy (nsucc {m} Nm) (nsucc {n} Nn) Sm<Sn = x<y→Sx<Sy (x<y→x<Sy Nm Nn (Sx<Sy→x<y Sm<Sn)) x<Sy→x<y∨x≡y : ∀ {m n} → N m → N n → m < succ₁ n → m < n ∨ m ≡ n x<Sy→x<y∨x≡y nzero nzero 0<S0 = inj₂ refl x<Sy→x<y∨x≡y nzero (nsucc {n} Nn) 0<SSn = inj₁ (lt-0S n) x<Sy→x<y∨x≡y (nsucc {m} Nm) nzero Sm<S0 = ⊥-elim (x<0→⊥ Nm (trans (sym (lt-SS m zero)) Sm<S0)) x<Sy→x<y∨x≡y (nsucc {m} Nm) (nsucc {n} Nn) Sm<SSn = case (λ m<n → inj₁ (trans (lt-SS m n) m<n)) (λ m≡n → inj₂ (succCong m≡n)) m<n∨m≡n where m<n∨m≡n : m < n ∨ m ≡ n m<n∨m≡n = x<Sy→x<y∨x≡y Nm Nn (trans (sym (lt-SS m (succ₁ n))) Sm<SSn) x≤y→x<y∨x≡y : ∀ {m n} → N m → N n → m ≤ n → m < n ∨ m ≡ n x≤y→x<y∨x≡y = x<Sy→x<y∨x≡y x<y→y≡z→x<z : ∀ {m n o} → m < n → n ≡ o → m < o x<y→y≡z→x<z m<n refl = m<n x≡y→y<z→x<z : ∀ {m n o} → m ≡ n → n < o → m < o x≡y→y<z→x<z refl n<o = n<o x≥y→y>0→x∸y<x : ∀ {m n} → N m → N n → m ≥ n → n > zero → m ∸ n < m x≥y→y>0→x∸y<x Nm nzero _ 0>0 = ⊥-elim (x>x→⊥ nzero 0>0) x≥y→y>0→x∸y<x nzero (nsucc Nn) 0≥Sn _ = ⊥-elim (S≤0→⊥ Nn 0≥Sn) x≥y→y>0→x∸y<x (nsucc {m} Nm) (nsucc {n} Nn) Sm≥Sn Sn>0 = lt (succ₁ m ∸ succ₁ n) (succ₁ m) ≡⟨ ltLeftCong (S∸S Nm Nn) ⟩ lt (m ∸ n) (succ₁ m) ≡⟨ x∸y<Sx Nm Nn ⟩ true ∎ ------------------------------------------------------------------------------ -- Properties about LT₂ xy<00→⊥ : ∀ {m n} → N m → N n → ¬ (Lexi m n zero zero) xy<00→⊥ Nm Nn mn<00 = case (λ m<0 → ⊥-elim (x<0→⊥ Nm m<0)) (λ m≡0∧n<0 → ⊥-elim (x<0→⊥ Nn (∧-proj₂ m≡0∧n<0))) mn<00 0Sx<00→⊥ : ∀ {m} → ¬ (Lexi zero (succ₁ m) zero zero) 0Sx<00→⊥ 0Sm<00 = case 0<0→⊥ (λ 0≡0∧Sm<0 → S<0→⊥ (∧-proj₂ 0≡0∧Sm<0)) 0Sm<00 Sxy<0y'→⊥ : ∀ {m n n'} → ¬ (Lexi (succ₁ m) n zero n') Sxy<0y'→⊥ Smn<0n' = case S<0→⊥ (λ Sm≡0∧n<n' → ⊥-elim (0≢S (sym (∧-proj₁ Sm≡0∧n<n')))) Smn<0n' xy<x'0→x<x' : ∀ {m n} → N n → ∀ {m'} → Lexi m n m' zero → m < m' xy<x'0→x<x' Nn mn<m'0 = case (λ m<n → m<n) (λ m≡n∧n<0 → ⊥-elim (x<0→⊥ Nn (∧-proj₂ m≡n∧n<0))) mn<m'0 xy<0y'→x≡0∧y<y' : ∀ {m} → N m → ∀ {n n'} → Lexi m n zero n' → m ≡ zero ∧ n < n' xy<0y'→x≡0∧y<y' Nm mn<0n' = case (λ m<0 → ⊥-elim (x<0→⊥ Nm m<0)) (λ m≡0∧n<n' → m≡0∧n<n') mn<0n' [Sx∸Sy,Sy]<[Sx,Sy] : ∀ {m n} → N m → N n → Lexi (succ₁ m ∸ succ₁ n) (succ₁ n) (succ₁ m) (succ₁ n) [Sx∸Sy,Sy]<[Sx,Sy] Nm Nn = inj₁ (Sx∸Sy<Sx Nm Nn) [Sx,Sy∸Sx]<[Sx,Sy] : ∀ {m n} → N m → N n → Lexi (succ₁ m) (succ₁ n ∸ succ₁ m) (succ₁ m) (succ₁ n) [Sx,Sy∸Sx]<[Sx,Sy] Nm Nn = inj₂ (refl , Sx∸Sy<Sx Nn Nm)
{ "alphanum_fraction": 0.4436590087, "avg_line_length": 38.4563106796, "ext": "agda", "hexsha": "79ed1662475f0bd444bce096f2ecdea54a9ab4e8", "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/LTC-PCF/Data/Nat/Inequalities/Properties.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/LTC-PCF/Data/Nat/Inequalities/Properties.agda", "max_line_length": 87, "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/LTC-PCF/Data/Nat/Inequalities/Properties.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": 6304, "size": 11883 }
open import MLib.Prelude.FromStdlib open import Relation.Binary using (Rel; _Respects₂_; IsStrictTotalOrder) open FE using (Π) module MLib.Prelude.DFS.ViaInjection {v v′ e} (V-setoid : Setoid v v′) (E : Rel (Setoid.Carrier V-setoid) e) (E-subst : E Respects₂ (Setoid._≈_ V-setoid)) {i p} {I : Set i} {_<_ : I → I → Set p} (isStrictTotalOrder : IsStrictTotalOrder _≡_ _<_) (injection : LeftInverse V-setoid (≡.setoid I)) where open import MLib.Prelude.Path import MLib.Prelude.DFS as DFS import Data.AVL isStrictTotalOrder as Tree open Bool using (T) module V = Setoid V-setoid open V using (_≈_) renaming (Carrier to V) open Π (LeftInverse.to injection) hiding (cong) renaming (_⟨$⟩_ to toIx) open Π (LeftInverse.from injection) hiding (cong) renaming (_⟨$⟩_ to fromIx) open LeftInverse using (left-inverse-of) _⇒_ : I → I → Set e i ⇒ j = E (fromIx i) (fromIx j) module BaseDFS = DFS _⇒_ isStrictTotalOrder open BaseDFS public using (Graph) open Tree using (Tree) convertPath : ∀ {i j} → Path _⇒_ i j → Path E (fromIx i) (fromIx j) convertPath (edge e) = edge e convertPath (connect p₁ p₂) = connect (convertPath p₁) (convertPath p₂) PathE-subst : ∀ {x x′ y y′} → x ≈ x′ → y ≈ y′ → Path E x y → Path E x′ y′ PathE-subst x≈x′ y≈y′ (edge e) = edge (proj₂ E-subst x≈x′ (proj₁ E-subst y≈y′ e)) PathE-subst x≈x′ y≈y′ (connect p₁ p₂) = connect (PathE-subst x≈x′ V.refl p₁) (PathE-subst V.refl y≈y′ p₂) mkGraph : List (∃₂ E) → Graph mkGraph = List.foldr step Tree.empty where step : ∃₂ E → Graph → Graph step (x , y , e) = let e′ = proj₂ E-subst (V.sym (left-inverse-of injection x)) (proj₁ E-subst (V.sym (left-inverse-of injection y)) e) in Tree.insertWith (toIx x) ((toIx y , e′) ∷ []) List._++_ allTargetsFrom : Graph → (source : V) → List (∃ (Path E source)) allTargetsFrom graph source = let resI = BaseDFS.allTargetsFrom graph (toIx source) in List.map (uncurry (λ _ p → _ , PathE-subst (left-inverse-of injection _) V.refl (convertPath p))) resI findDest : Graph → ∀ {dest} (isDest : ∀ i → Dec (i ≡ toIx dest)) (source : V) → Maybe (Path E source dest) findDest graph {dest} isDest source = let resI = BaseDFS.findDest graph isDest (toIx source) in Maybe.map (PathE-subst (left-inverse-of injection _) (left-inverse-of injection _) ∘ convertPath) resI findMatching : Graph → (matches : V → Bool) (source : V) → Maybe (∃ λ dest → Path E source dest × T (matches dest)) findMatching graph matches source = let resI = BaseDFS.findMatching graph (matches ∘ fromIx) (toIx source) in Maybe.map (λ {(_ , p , q) → _ , PathE-subst (left-inverse-of injection _) V.refl (convertPath p) , q}) resI
{ "alphanum_fraction": 0.6762589928, "avg_line_length": 41.265625, "ext": "agda", "hexsha": "ac515a216f2dda4c97f3843a830c7c0b46f0e901", "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": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bch29/agda-matrices", "max_forks_repo_path": "src/MLib/DFS/ViaInjection.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "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": "bch29/agda-matrices", "max_issues_repo_path": "src/MLib/DFS/ViaInjection.agda", "max_line_length": 120, "max_stars_count": null, "max_stars_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bch29/agda-matrices", "max_stars_repo_path": "src/MLib/DFS/ViaInjection.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 919, "size": 2641 }
open import FRP.JS.Behaviour using ( Beh ; map ) open import FRP.JS.DOM using ( DOM ; text ; element ) open import FRP.JS.RSet using ( ⟦_⟧ ) open import FRP.JS.Time using ( toUTCString ; every ) open import FRP.JS.Delay using ( _sec ) module FRP.JS.Demo.Clock where main : ∀ {w} → ⟦ Beh (DOM w) ⟧ main = text (map toUTCString (every (1 sec)))
{ "alphanum_fraction": 0.6802325581, "avg_line_length": 34.4, "ext": "agda", "hexsha": "4fb30f8ca4c0d2898cc17718a14aaa4f57b5edb5", "lang": "Agda", "max_forks_count": 7, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z", "max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z", "max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_forks_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_forks_repo_name": "agda/agda-frp-js", "max_forks_repo_path": "demo/agda/FRP/JS/Demo/Clock.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_issues_repo_name": "agda/agda-frp-js", "max_issues_repo_path": "demo/agda/FRP/JS/Demo/Clock.agda", "max_line_length": 53, "max_stars_count": 63, "max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_stars_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_stars_repo_name": "agda/agda-frp-js", "max_stars_repo_path": "demo/agda/FRP/JS/Demo/Clock.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z", "num_tokens": 114, "size": 344 }
open import Type module Graph.Walk {ℓ₁ ℓ₂} {V : Type{ℓ₁}} where import Lvl open import Graph{ℓ₁}{ℓ₂}(V) import Structure.Relator.Names as Names module _ (_⟶_ : Graph) where -- A path is matching directed edges connected to each other in a finite sequence. -- This is essentially a list of edges where the ends match. -- The terminology is that a walk is a sequence of connected edges and it visits all its vertices. -- Note: Walk is a generalized "List" for categories instead of the usual List which is for monoids. -- Note: Walk is equivalent to the reflexive-transitive closure. data Walk : V → V → Type{ℓ₁ Lvl.⊔ ℓ₂} where at : Names.Reflexivity(Walk) prepend : ∀{a b c} → (a ⟶ b) → (Walk b c) → (Walk a c)
{ "alphanum_fraction": 0.6885026738, "avg_line_length": 41.5555555556, "ext": "agda", "hexsha": "2ecbe5323a80add6bb68aeff5884e41ba7dee25d", "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": "Graph/Walk.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": "Graph/Walk.agda", "max_line_length": 102, "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": "Graph/Walk.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": 221, "size": 748 }
open import Prelude module Implicits.Substitutions where import Implicits.Substitutions.Context as CtxSubst open import Implicits.Substitutions.Term module TypeSubst where open import Implicits.Substitutions.Type public open import Implicits.Substitutions.MetaType public open TypeSubst public using (_∙_; stp-weaken) renaming (_simple/_ to _stp/tp_; _/_ to _tp/tp_; _[/_] to _tp[/tp_]; weaken to tp-weaken) open TermTypeSubst public using () renaming (_/_ to _tm/tp_; _[/_] to _tm[/tp_]; weaken to tm-weaken) open TermTermSubst public using () renaming (_/_ to _tm/tm_; _/Var_ to _tm/Var_; _[/_] to _tm[/tm_]; weaken to tmtm-weaken) open CtxSubst public using (ktx-map; ictx-weaken; ctx-weaken) renaming (_/_ to _ktx/_; _/Var_ to _ktx/Var_; weaken to ktx-weaken)
{ "alphanum_fraction": 0.7599486521, "avg_line_length": 37.0952380952, "ext": "agda", "hexsha": "ff534db2074bfd3f03dc4066b826187f9f2a1882", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Implicits/Substitutions.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Implicits/Substitutions.agda", "max_line_length": 91, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Implicits/Substitutions.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 245, "size": 779 }
module v01-02-induction where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; sym) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎) open import v01-01-basics plus-n-O : ∀ (n : nat) → n ≡ n + 0 plus-n-O O = refl plus-n-O (S n) rewrite sym (plus-n-O n) = refl minus-n-n : ∀ (n : nat) → minus n n ≡ 0 minus-n-n O = refl minus-n-n (S n) rewrite sym (minus-n-n n) = refl mult-0-r : ∀ (n : nat) → n * 0 ≡ 0 mult-0-r O = refl mult-0-r (S n) rewrite mult-0-r n = refl plus-n-Sm : ∀ (n m : nat) → S (n + m) ≡ n + (S m) plus-n-Sm O m = refl plus-n-Sm (S n) m rewrite sym (plus-n-Sm n m) = refl plus-comm : ∀ (n m : nat) → n + m ≡ m + n plus-comm n O rewrite sym (plus-n-O n) = refl plus-comm O (S m) rewrite sym (plus-n-O m) = refl plus-comm (S n) (S m) rewrite sym (plus-n-Sm n m) | sym (plus-n-Sm m n) | plus-comm n m = refl plus-assoc : ∀ (n m p : nat) → n + (m + p) ≡ (n + m) + p plus-assoc O m p = refl plus-assoc (S n) m p -- S n + (m + p) ≡ S n + m + p rewrite plus-comm (S n + m) p -- S (plus n (plus m p)) ≡ plus p (S (plus n m)) | sym (plus-n-Sm p (plus n m)) -- S (plus n (plus m p)) ≡ S (plus p (plus n m)) | plus-comm p (plus n m) -- S (plus n (plus m p)) ≡ S (plus (plus n m) p) | plus-assoc n m p -- S (plus (plus n m) p) ≡ S (plus (plus n m) p) = refl double : (n : nat) → nat double O = O double (S n) = S (S (double n)) double-plus : ∀ (n : nat) → double n ≡ n + n double-plus O = refl double-plus (S n) -- double (S n) ≡ S n + S n -- S (S (double n)) ≡ S n + S n rewrite double-plus n -- S (S (plus n n)) ≡ S (plus n (S n)) | plus-n-Sm n n -- S (plus n (S n)) ≡ S (plus n (S n)) = refl {- Inconvenient in evenb def: recursive call on n - 2. Makes inductibe proofs about evenb harder since may need IH about n - 2. Following lemma gives alternative characterization of evenb (S n) that works better with induction. -} evenb-S : ∀ (n : nat) → evenb (S n) ≡ negb (evenb n) evenb-S O = refl evenb-S (S n) -- evenb (S (S n)) ≡ negb (evenb (S n)) -- evenb n ≡ negb (evenb (S n)) rewrite evenb-S n -- evenb n ≡ negb (negb (evenb n)) | negb-involutive (evenb n) -- evenb n ≡ evenb n = refl mult-0-plus' : ∀ (n m : nat) → (0 + n) * m ≡ n * m mult-0-plus' O m = refl mult-0-plus' (S n) m -- (0 + S n) * m ≡ S n * m rewrite plus-O-n {n} -- plus m (mult n m) ≡ plus m (mult n m) = refl plus-rearrange : ∀ (n m p q : nat) → (n + m) + (p + q) ≡ (m + n) + (p + q) plus-rearrange n m p q rewrite plus-comm n m = refl plus-swap : ∀ (n m p : nat) → n + (m + p) ≡ m + (n + p) plus-swap n m p rewrite plus-assoc n m p | plus-comm n m | plus-assoc m n p = refl mult-comm : ∀ (m n : nat) → m * n ≡ n * m mult-comm O n rewrite mult-O-l {n} | *0 n = refl mult-comm (S m) n -- S m * n ≡ n * S m rewrite -- plus n (mult m n) ≡ plus (mult n m) n sym (mult-n-Sm n m) | plus-comm n (mult m n) | mult-comm m n = refl leb-refl : ∀ (n : nat) → true ≡ (n <=? n) leb-refl O = refl leb-refl (S n) = leb-refl n zero-nbeq-S : ∀ (n : nat) → (0 =? (S n)) ≡ false zero-nbeq-S n = refl andb-false-r : ∀ (b : bool) → andb b false ≡ false andb-false-r true = refl andb-false-r false = refl plus-ble-compat-l : ∀ (n m p : nat) → (n <=? m) ≡ true → ((p + n) <=? (p + m)) ≡ true plus-ble-compat-l _ _ O n<=?m = n<=?m plus-ble-compat-l n m (S p) n<=?m = plus-ble-compat-l n m p n<=?m S-nbeq-0 : ∀ (n : nat) → ((S n) =? 0) ≡ false S-nbeq-0 n = refl mult-1-l : ∀ (n : nat) → 1 * n ≡ n mult-1-l O = refl mult-1-l (S n) rewrite mult-1-l n = refl all3-spec : ∀ (b c : bool) → orb (andb b c) (orb (negb b) (negb c)) ≡ true all3-spec true true = refl all3-spec true false = refl all3-spec false true = refl all3-spec false false = refl mult-plus-distr-r : ∀ (n m p : nat) → (n + m) * p ≡ (n * p) + (m * p) mult-plus-distr-r O m p = refl mult-plus-distr-r (S n) m p -- (S n + m) * p -- ≡ S n * p + m * p rewrite mult-comm (S n + m) p -- mult p (S (plus n m)) -- ≡ plus (plus p (mult n p)) (mult m p) | sym (mult-n-Sm p (plus n m)) -- plus (mult p (plus n m)) p -- ≡ plus (plus p (mult n p)) (mult m p) | mult-comm p (plus n m) -- plus (mult (plus n m) p) p -- ≡ plus (plus p (mult n p)) (mult m p) | mult-plus-distr-r n m p -- plus (plus (mult n p) (mult m p)) p -- ≡ plus (plus p (mult n p)) (mult m p) | plus-comm (plus (mult n p) (mult m p)) p -- plus p (plus (mult n p) (mult m p)) -- ≡ plus (plus p (mult n p)) (mult m p) | plus-assoc p (mult n p) (mult m p) -- plus (plus p (mult n p)) (mult m p) -- ≡ plus (plus p (mult n p)) (mult m p) = refl mult-assoc : ∀ (n m p : nat) → n * (m * p) ≡ (n * m) * p mult-assoc O m p = refl mult-assoc (S n) m p -- S n * (m * p) ≡ S n * m * p rewrite mult-plus-distr-r m (mult n m) p -- plus (mult m p) (mult n (mult m p)) ≡ -- plus (mult m p) (mult (mult n m) p) | mult-assoc n m p -- plus (mult m p) (mult (mult n m) p) ≡ -- plus (mult m p) (mult (mult n m) p) = refl eqb-refl : ∀ (n : nat) → true ≡ (n =? n) eqb-refl O = refl eqb-refl (S n) = eqb-refl n plus-swap' : ∀ (n m p : nat) → n + (m + p) ≡ m + (n + p) plus-swap' n m p -- n + (m + p) ≡ m + (n + p) rewrite plus-assoc n m p -- plus (plus n m) p ≡ plus m (plus n p) | plus-comm n m -- plus (plus m n) p ≡ plus m (plus n p) | sym (plus-assoc m n p) -- plus m (plus n p) ≡ plus m (plus n p) = refl {- Exercise: 3 stars, standard, especially useful (binary_commute) Prove this diagram commutes: incr bin ----------------------> bin | | bin_to_nat | | bin_to_nat | | v v nat ----------------------> nat S incrementing a binary number and then converting it to a (unary) natural number yields the same result as first converting it to a natural number and then incrementing -} bin-to-nat' : bin → nat bin-to-nat' Z = 0 bin-to-nat' (B₀ x) = double (bin-to-nat' x) bin-to-nat' (B₁ x) = 1 + (double (bin-to-nat' x)) _ : bin-to-nat' (B₀ (B₁ Z)) ≡ 2 _ = refl _ : bin-to-nat' (incr (B₁ Z)) ≡ 1 + bin-to-nat' (B₁ Z) _ = refl _ : bin-to-nat' (incr (incr (B₁ Z))) ≡ 2 + bin-to-nat' (B₁ Z) _ = refl -- PREServes bin-to-nat-pres-incr : (b : bin) (n : nat) → bin-to-nat' b ≡ n → bin-to-nat' (incr b) ≡ S n bin-to-nat-pres-incr Z n b≡n -- bin-to-nat (incr Z) ≡ S n -- 1 ≡ S n ; b≡n : 0 ≡ n rewrite sym b≡n -- 1 ≡ 1 = refl bin-to-nat-pres-incr (B₀ b) n b≡n -- bin-to-nat' (incr (B₀ b)) ≡ S n -- 1 + double (bin-to-nat' b) ≡ S n rewrite b≡n -- S n ≡ S n = refl bin-to-nat-pres-incr (B₁ b) n b≡n -- bin-to-nat' (incr (B₁ b)) ≡ S n -- double (bin-to-nat' (incr b)) ≡ S n -- b≡n : 1 + double (bin-to-nat' b) ≡ n rewrite sym b≡n -- double (bin-to-nat' (incr b)) ≡ S (S (double (bin-to-nat' b))) -- | bin-to-nat-pres-incr b n b≡n = {!!} nat-to-bin : (n : nat) → bin nat-to-bin n = {!!} {- Prove for any nat, convert it to binary; convert it back, get same nat HINT If def of nat_to_bin uses other functions, might need to prove lemma showing how functions relate to nat_to_bin.) Theorem nat_bin_nat : ∀ n, bin_to_nat (nat_to_bin n) = n. Proof. (* FILL IN HERE *) Admitted. (b) One might naturally expect that we should also prove the opposite direction -- that starting with a binary number, converting to a natural, and then back to binary should yield the same number we started with. However, this is not the case! Explain (in a comment) what the problem is. (* FILL IN HERE *) (c) Define a normalization function -- i.e., a function normalize going directly from bin to bin (i.e., not by converting to nat and back) such that, for any binary number b, converting b to a natural and then back to binary yields (normalize b). Prove it. (Warning: This part is a bit tricky -- you may end up defining several auxiliary lemmas. One good way to find out what you need is to start by trying to prove the main statement, see where you get stuck, and see if you can find a lemma -- perhaps requiring its own inductive proof -- that will allow the main proof to make progress.) Don't define this using nat_to_bin and bin_to_nat! (* FILL IN HERE *) -}
{ "alphanum_fraction": 0.4877893396, "avg_line_length": 36.0842911877, "ext": "agda", "hexsha": "de2a383728d1740efb56e71e03fc6bff19fcf818", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/book/SFHC/v01-02-induction.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/book/SFHC/v01-02-induction.agda", "max_line_length": 641, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/book/SFHC/v01-02-induction.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "num_tokens": 3299, "size": 9418 }
{-# OPTIONS --exact-split #-} open import Agda.Builtin.Nat data IsZero : Nat → Set where isZero : IsZero 0 test : (n m : Nat) → IsZero n → IsZero m → Nat test zero zero _ _ = zero test (suc _) _ () _ test _ (suc _) _ ()
{ "alphanum_fraction": 0.6177777778, "avg_line_length": 18.75, "ext": "agda", "hexsha": "11113ee846883c17648137c2fd932f5c6276ca6a", "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/Issue2629.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/Issue2629.agda", "max_line_length": 46, "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/Issue2629.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": 76, "size": 225 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Bag and set equality ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Relation.Binary.BagAndSetEquality where open import Algebra using (CommutativeSemiring; CommutativeMonoid) open import Algebra.FunctionProperties using (Idempotent) open import Category.Monad using (RawMonad) open import Data.Empty open import Data.Fin open import Data.List open import Data.List.Categorical using (monad; module MonadProperties) import Data.List.Properties as LP open import Data.List.Relation.Unary.Any using (Any; here; there) open import Data.List.Relation.Unary.Any.Properties open import Data.List.Membership.Propositional using (_∈_) open import Data.List.Relation.Binary.Subset.Propositional.Properties using (⊆-preorder) open import Data.Product as Prod hiding (map) import Data.Product.Function.Dependent.Propositional as Σ open import Data.Sum as Sum hiding (map) open import Data.Sum.Properties open import Data.Sum.Function.Propositional using (_⊎-cong_) open import Data.Unit open import Function open import Function.Equality using (_⟨$⟩_) import Function.Equivalence as FE open import Function.Inverse as Inv using (_↔_; Inverse; inverse) open import Function.Related as Related using (↔⇒; ⌊_⌋; ⌊_⌋→; ⇒→; K-refl; SK-sym) open import Function.Related.TypeIsomorphisms open import Level using (Lift) open import Relation.Binary import Relation.Binary.Reasoning.Setoid as EqR import Relation.Binary.Reasoning.Preorder as PreorderReasoning open import Relation.Binary.PropositionalEquality as P using (_≡_; _≢_; _≗_; refl) open import Relation.Nullary open import Data.List.Membership.Propositional.Properties ------------------------------------------------------------------------ -- Definitions open Related public using (Kind; Symmetric-kind) renaming ( implication to subset ; reverse-implication to superset ; equivalence to set ; injection to subbag ; reverse-injection to superbag ; bijection to bag ) [_]-Order : Kind → ∀ {a} → Set a → Preorder _ _ _ [ k ]-Order A = Related.InducedPreorder₂ k {A = A} _∈_ [_]-Equality : Symmetric-kind → ∀ {a} → Set a → Setoid _ _ [ k ]-Equality A = Related.InducedEquivalence₂ k {A = A} _∈_ infix 4 _∼[_]_ _∼[_]_ : ∀ {a} {A : Set a} → List A → Kind → List A → Set _ _∼[_]_ {A = A} xs k ys = Preorder._∼_ ([ k ]-Order A) xs ys private module Eq {k a} {A : Set a} = Setoid ([ k ]-Equality A) module Ord {k a} {A : Set a} = Preorder ([ k ]-Order A) open module ListMonad {ℓ} = RawMonad (monad {ℓ = ℓ}) module MP = MonadProperties ------------------------------------------------------------------------ -- Bag equality implies the other relations. bag-=⇒ : ∀ {k a} {A : Set a} {xs ys : List A} → xs ∼[ bag ] ys → xs ∼[ k ] ys bag-=⇒ xs≈ys = ↔⇒ xs≈ys ------------------------------------------------------------------------ -- "Equational" reasoning for _⊆_ along with an additional relatedness module ⊆-Reasoning where private module PreOrder {a} {A : Set a} = PreorderReasoning (⊆-preorder A) open PreOrder public hiding (_≈⟨_⟩_; _≈˘⟨_⟩_) renaming (_∼⟨_⟩_ to _⊆⟨_⟩_) infixr 2 _∼⟨_⟩_ infix 1 _∈⟨_⟩_ _∈⟨_⟩_ : ∀ {a} {A : Set a} x {xs ys : List A} → x ∈ xs → xs IsRelatedTo ys → x ∈ ys x ∈⟨ x∈xs ⟩ xs⊆ys = (begin xs⊆ys) x∈xs _∼⟨_⟩_ : ∀ {k a} {A : Set a} xs {ys zs : List A} → xs ∼[ ⌊ k ⌋→ ] ys → ys IsRelatedTo zs → xs IsRelatedTo zs xs ∼⟨ xs≈ys ⟩ ys≈zs = xs ⊆⟨ ⇒→ xs≈ys ⟩ ys≈zs ------------------------------------------------------------------------ -- Congruence lemmas ------------------------------------------------------------------------ -- _∷_ module _ {a k} {A : Set a} {x y : A} {xs ys} where ∷-cong : x ≡ y → xs ∼[ k ] ys → x ∷ xs ∼[ k ] y ∷ ys ∷-cong refl xs≈ys {y} = y ∈ x ∷ xs ↔⟨ SK-sym $ ∷↔ (y ≡_) ⟩ (y ≡ x ⊎ y ∈ xs) ∼⟨ (y ≡ x ∎) ⊎-cong xs≈ys ⟩ (y ≡ x ⊎ y ∈ ys) ↔⟨ ∷↔ (y ≡_) ⟩ y ∈ x ∷ ys ∎ where open Related.EquationalReasoning ------------------------------------------------------------------------ -- map module _ {ℓ k} {A B : Set ℓ} {f g : A → B} {xs ys} where map-cong : f ≗ g → xs ∼[ k ] ys → map f xs ∼[ k ] map g ys map-cong f≗g xs≈ys {x} = x ∈ map f xs ↔⟨ SK-sym $ map↔ ⟩ Any (λ y → x ≡ f y) xs ∼⟨ Any-cong (↔⇒ ∘ helper) xs≈ys ⟩ Any (λ y → x ≡ g y) ys ↔⟨ map↔ ⟩ x ∈ map g ys ∎ where open Related.EquationalReasoning helper : ∀ y → x ≡ f y ↔ x ≡ g y helper y = record { to = P.→-to-⟶ (λ x≡fy → P.trans x≡fy ( f≗g y)) ; from = P.→-to-⟶ (λ x≡gy → P.trans x≡gy (P.sym $ f≗g y)) ; inverse-of = record { left-inverse-of = λ { P.refl → P.trans-symʳ (f≗g y) } ; right-inverse-of = λ { P.refl → P.trans-symˡ (f≗g y) } } } ------------------------------------------------------------------------ -- _++_ module _ {a k} {A : Set a} {xs₁ xs₂ ys₁ ys₂ : List A} where ++-cong : xs₁ ∼[ k ] xs₂ → ys₁ ∼[ k ] ys₂ → xs₁ ++ ys₁ ∼[ k ] xs₂ ++ ys₂ ++-cong xs₁≈xs₂ ys₁≈ys₂ {x} = x ∈ xs₁ ++ ys₁ ↔⟨ SK-sym $ ++↔ ⟩ (x ∈ xs₁ ⊎ x ∈ ys₁) ∼⟨ xs₁≈xs₂ ⊎-cong ys₁≈ys₂ ⟩ (x ∈ xs₂ ⊎ x ∈ ys₂) ↔⟨ ++↔ ⟩ x ∈ xs₂ ++ ys₂ ∎ where open Related.EquationalReasoning ------------------------------------------------------------------------ -- concat module _ {a k} {A : Set a} {xss yss : List (List A)} where concat-cong : xss ∼[ k ] yss → concat xss ∼[ k ] concat yss concat-cong xss≈yss {x} = x ∈ concat xss ↔⟨ SK-sym concat↔ ⟩ Any (Any (x ≡_)) xss ∼⟨ Any-cong (λ _ → _ ∎) xss≈yss ⟩ Any (Any (x ≡_)) yss ↔⟨ concat↔ ⟩ x ∈ concat yss ∎ where open Related.EquationalReasoning ------------------------------------------------------------------------ -- _>>=_ module _ {ℓ k} {A B : Set ℓ} {xs ys} {f g : A → List B} where >>=-cong : xs ∼[ k ] ys → (∀ x → f x ∼[ k ] g x) → (xs >>= f) ∼[ k ] (ys >>= g) >>=-cong xs≈ys f≈g {x} = x ∈ (xs >>= f) ↔⟨ SK-sym >>=↔ ⟩ Any (λ y → x ∈ f y) xs ∼⟨ Any-cong (λ x → f≈g x) xs≈ys ⟩ Any (λ y → x ∈ g y) ys ↔⟨ >>=↔ ⟩ x ∈ (ys >>= g) ∎ where open Related.EquationalReasoning ------------------------------------------------------------------------ -- _⊛_ module _ {ℓ k} {A B : Set ℓ} {fs gs : List (A → B)} {xs ys} where ⊛-cong : fs ∼[ k ] gs → xs ∼[ k ] ys → (fs ⊛ xs) ∼[ k ] (gs ⊛ ys) ⊛-cong fs≈gs xs≈ys = >>=-cong fs≈gs λ f → >>=-cong xs≈ys λ x → _ ∎ where open Related.EquationalReasoning ------------------------------------------------------------------------ -- _⊗_ module _ {ℓ k} {A B : Set ℓ} {xs₁ xs₂ : List A} {ys₁ ys₂ : List B} where ⊗-cong : xs₁ ∼[ k ] xs₂ → ys₁ ∼[ k ] ys₂ → (xs₁ ⊗ ys₁) ∼[ k ] (xs₂ ⊗ ys₂) ⊗-cong xs₁≈xs₂ ys₁≈ys₂ = ⊛-cong (⊛-cong (Ord.refl {x = [ _,_ ]}) xs₁≈xs₂) ys₁≈ys₂ ------------------------------------------------------------------------ -- Other properties -- _++_ and [] form a commutative monoid, with either bag or set -- equality as the underlying equality. commutativeMonoid : ∀ {a} → Symmetric-kind → Set a → CommutativeMonoid _ _ commutativeMonoid {a} k A = record { Carrier = List A ; _≈_ = _∼[ ⌊ k ⌋ ]_ ; _∙_ = _++_ ; ε = [] ; isCommutativeMonoid = record { isSemigroup = record { isMagma = record { isEquivalence = Eq.isEquivalence ; ∙-cong = ++-cong } ; assoc = λ xs ys zs → Eq.reflexive (LP.++-assoc xs ys zs) } ; identityˡ = λ xs {x} → x ∈ xs ∎ ; comm = λ xs ys {x} → x ∈ xs ++ ys ↔⟨ ++↔++ xs ys ⟩ x ∈ ys ++ xs ∎ } } where open Related.EquationalReasoning -- The only list which is bag or set equal to the empty list (or a -- subset or subbag of the list) is the empty list itself. empty-unique : ∀ {k a} {A : Set a} {xs : List A} → xs ∼[ ⌊ k ⌋→ ] [] → xs ≡ [] empty-unique {xs = []} _ = refl empty-unique {xs = _ ∷ _} ∷∼[] with ⇒→ ∷∼[] (here refl) ... | () -- _++_ is idempotent (under set equality). ++-idempotent : ∀ {a} {A : Set a} → Idempotent {A = List A} _∼[ set ]_ _++_ ++-idempotent {a} xs {x} = x ∈ xs ++ xs ∼⟨ FE.equivalence ([ id , id ]′ ∘ _⟨$⟩_ (Inverse.from $ ++↔)) (_⟨$⟩_ (Inverse.to $ ++↔) ∘ inj₁) ⟩ x ∈ xs ∎ where open Related.EquationalReasoning -- The list monad's bind distributes from the left over _++_. >>=-left-distributive : ∀ {ℓ} {A B : Set ℓ} (xs : List A) {f g : A → List B} → (xs >>= λ x → f x ++ g x) ∼[ bag ] (xs >>= f) ++ (xs >>= g) >>=-left-distributive {ℓ} xs {f} {g} {y} = y ∈ (xs >>= λ x → f x ++ g x) ↔⟨ SK-sym $ >>=↔ ⟩ Any (λ x → y ∈ f x ++ g x) xs ↔⟨ SK-sym (Any-cong (λ _ → ++↔) (_ ∎)) ⟩ Any (λ x → y ∈ f x ⊎ y ∈ g x) xs ↔⟨ SK-sym $ ⊎↔ ⟩ (Any (λ x → y ∈ f x) xs ⊎ Any (λ x → y ∈ g x) xs) ↔⟨ >>=↔ ⟨ _⊎-cong_ ⟩ >>=↔ ⟩ (y ∈ (xs >>= f) ⊎ y ∈ (xs >>= g)) ↔⟨ ++↔ ⟩ y ∈ (xs >>= f) ++ (xs >>= g) ∎ where open Related.EquationalReasoning -- The same applies to _⊛_. ⊛-left-distributive : ∀ {ℓ} {A B : Set ℓ} (fs : List (A → B)) xs₁ xs₂ → (fs ⊛ (xs₁ ++ xs₂)) ∼[ bag ] (fs ⊛ xs₁) ++ (fs ⊛ xs₂) ⊛-left-distributive {B = B} fs xs₁ xs₂ = begin fs ⊛ (xs₁ ++ xs₂) ≡⟨⟩ (fs >>= λ f → xs₁ ++ xs₂ >>= return ∘ f) ≡⟨ (MP.cong (refl {x = fs}) λ f → MP.right-distributive xs₁ xs₂ (return ∘ f)) ⟩ (fs >>= λ f → (xs₁ >>= return ∘ f) ++ (xs₂ >>= return ∘ f)) ≈⟨ >>=-left-distributive fs ⟩ (fs >>= λ f → xs₁ >>= return ∘ f) ++ (fs >>= λ f → xs₂ >>= return ∘ f) ≡⟨⟩ (fs ⊛ xs₁) ++ (fs ⊛ xs₂) ∎ where open EqR ([ bag ]-Equality B) private -- If x ∷ xs is set equal to x ∷ ys, then xs and ys are not -- necessarily set equal. ¬-drop-cons : ∀ {a} {A : Set a} {x : A} → ¬ (∀ {xs ys} → x ∷ xs ∼[ set ] x ∷ ys → xs ∼[ set ] ys) ¬-drop-cons {x = x} drop-cons with FE.Equivalence.to x∼[] ⟨$⟩ here refl where x,x≈x : (x ∷ x ∷ []) ∼[ set ] [ x ] x,x≈x = ++-idempotent [ x ] x∼[] : [ x ] ∼[ set ] [] x∼[] = drop-cons x,x≈x ... | () -- However, the corresponding property does hold for bag equality. drop-cons : ∀ {a} {A : Set a} {x : A} {xs ys} → x ∷ xs ∼[ bag ] x ∷ ys → xs ∼[ bag ] ys drop-cons {A = A} {x} {xs} {ys} x∷xs≈x∷ys = ⊎-left-cancellative (∼→⊎↔⊎ x∷xs≈x∷ys) (lemma x∷xs≈x∷ys) (lemma (SK-sym x∷xs≈x∷ys)) where -- TODO: Some of the code below could perhaps be exposed to users. -- Finds the element at the given position. index : ∀ {a} {A : Set a} (xs : List A) → Fin (length xs) → A index [] () index (x ∷ xs) zero = x index (x ∷ xs) (suc i) = index xs i -- List membership can be expressed as "there is an index which -- points to the element". ∈-index : ∀ {a} {A : Set a} {z} (xs : List A) → z ∈ xs ↔ ∃ λ i → z ≡ index xs i ∈-index {z = z} [] = z ∈ [] ↔⟨ SK-sym ⊥↔Any[] ⟩ ⊥ ↔⟨ SK-sym $ inverse (λ { (() , _) }) (λ ()) (λ { (() , _) }) (λ ()) ⟩ (∃ λ (i : Fin 0) → z ≡ index [] i) ∎ where open Related.EquationalReasoning ∈-index {z = z} (x ∷ xs) = z ∈ x ∷ xs ↔⟨ SK-sym (∷↔ _) ⟩ (z ≡ x ⊎ z ∈ xs) ↔⟨ K-refl ⊎-cong ∈-index xs ⟩ (z ≡ x ⊎ ∃ λ i → z ≡ index xs i) ↔⟨ SK-sym $ inverse (λ { (zero , p) → inj₁ p; (suc i , p) → inj₂ (i , p) }) (λ { (inj₁ p) → zero , p; (inj₂ (i , p)) → suc i , p }) (λ { (zero , _) → refl; (suc _ , _) → refl }) (λ { (inj₁ _) → refl; (inj₂ _) → refl }) ⟩ (∃ λ i → z ≡ index (x ∷ xs) i) ∎ where open Related.EquationalReasoning -- The index which points to the element. index-of : ∀ {a} {A : Set a} {z} {xs : List A} → z ∈ xs → Fin (length xs) index-of = proj₁ ∘ (Inverse.to (∈-index _) ⟨$⟩_) -- The type ∃ λ z → z ∈ xs is isomorphic to Fin n, where n is the -- length of xs. -- -- Thierry Coquand pointed out that (a variant of) this statement is -- a generalisation of the fact that singletons are contractible. Fin-length : ∀ {a} {A : Set a} (xs : List A) → (∃ λ z → z ∈ xs) ↔ Fin (length xs) Fin-length xs = (∃ λ z → z ∈ xs) ↔⟨ Σ.cong K-refl (∈-index xs) ⟩ (∃ λ z → ∃ λ i → z ≡ index xs i) ↔⟨ ∃∃↔∃∃ _ ⟩ (∃ λ i → ∃ λ z → z ≡ index xs i) ↔⟨ Σ.cong K-refl (inverse _ (λ _ → _ , refl) (λ { (_ , refl) → refl }) (λ _ → refl)) ⟩ (Fin (length xs) × Lift _ ⊤) ↔⟨ ×-identityʳ _ _ ⟩ Fin (length xs) ∎ where open Related.EquationalReasoning -- From this lemma we get that lists which are bag equivalent have -- related lengths. Fin-length-cong : ∀ {a} {A : Set a} {xs ys : List A} → xs ∼[ bag ] ys → Fin (length xs) ↔ Fin (length ys) Fin-length-cong {xs = xs} {ys} xs≈ys = Fin (length xs) ↔⟨ SK-sym $ Fin-length xs ⟩ ∃ (λ z → z ∈ xs) ↔⟨ Σ.cong K-refl xs≈ys ⟩ ∃ (λ z → z ∈ ys) ↔⟨ Fin-length ys ⟩ Fin (length ys) ∎ where open Related.EquationalReasoning -- The index-of function commutes with applications of certain -- inverses. index-of-commutes : ∀ {a} {A : Set a} {z : A} {xs ys} → (xs≈ys : xs ∼[ bag ] ys) (p : z ∈ xs) → index-of (Inverse.to xs≈ys ⟨$⟩ p) ≡ Inverse.to (Fin-length-cong xs≈ys) ⟨$⟩ index-of p index-of-commutes {z = z} {xs} {ys} xs≈ys p = index-of (to xs≈ys ⟨$⟩ p) ≡⟨ lemma z p ⟩ index-of (to xs≈ys ⟨$⟩ proj₂ (from (Fin-length xs) ⟨$⟩ (to (Fin-length xs) ⟨$⟩ (z , p)))) ≡⟨⟩ index-of (proj₂ (Prod.map id (to xs≈ys ⟨$⟩_) (from (Fin-length xs) ⟨$⟩ (to (Fin-length xs) ⟨$⟩ (z , p))))) ≡⟨⟩ to (Fin-length ys) ⟨$⟩ Prod.map id (to xs≈ys ⟨$⟩_) (from (Fin-length xs) ⟨$⟩ index-of p) ≡⟨⟩ to (Fin-length-cong xs≈ys) ⟨$⟩ index-of p ∎ where open P.≡-Reasoning open Inverse lemma : ∀ z p → index-of (to xs≈ys ⟨$⟩ p) ≡ index-of (to xs≈ys ⟨$⟩ proj₂ (from (Fin-length xs) ⟨$⟩ (to (Fin-length xs) ⟨$⟩ (z , p)))) lemma z p with to (Fin-length xs) ⟨$⟩ (z , p) | left-inverse-of (Fin-length xs) (z , p) lemma .(index xs i) .(from (∈-index xs) ⟨$⟩ (i , refl)) | i | refl = refl -- Bag equivalence isomorphisms preserve index equality. Note that -- this means that, even if the underlying equality is proof -- relevant, a bag equivalence isomorphism cannot map two distinct -- proofs, that point to the same position, to different positions. index-equality-preserved : ∀ {a} {A : Set a} {z : A} {xs ys} {p q : z ∈ xs} (xs≈ys : xs ∼[ bag ] ys) → index-of p ≡ index-of q → index-of (Inverse.to xs≈ys ⟨$⟩ p) ≡ index-of (Inverse.to xs≈ys ⟨$⟩ q) index-equality-preserved {p = p} {q} xs≈ys eq = index-of (Inverse.to xs≈ys ⟨$⟩ p) ≡⟨ index-of-commutes xs≈ys p ⟩ Inverse.to (Fin-length-cong xs≈ys) ⟨$⟩ index-of p ≡⟨ P.cong (Inverse.to (Fin-length-cong xs≈ys) ⟨$⟩_) eq ⟩ Inverse.to (Fin-length-cong xs≈ys) ⟨$⟩ index-of q ≡⟨ P.sym $ index-of-commutes xs≈ys q ⟩ index-of (Inverse.to xs≈ys ⟨$⟩ q) ∎ where open P.≡-Reasoning -- The old inspect idiom. inspect : ∀ {a} {A : Set a} (x : A) → ∃ (x ≡_) inspect x = x , refl -- A function is "well-behaved" if any "left" element which is the -- image of a "right" element is in turn not mapped to another -- "left" element. Well-behaved : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} → (A ⊎ B → A ⊎ C) → Set _ Well-behaved f = ∀ {b a a′} → f (inj₂ b) ≡ inj₁ a → f (inj₁ a) ≢ inj₁ a′ -- The type constructor _⊎_ is left cancellative for certain -- well-behaved inverses. ⊎-left-cancellative : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} (f : (A ⊎ B) ↔ (A ⊎ C)) → Well-behaved (Inverse.to f ⟨$⟩_) → Well-behaved (Inverse.from f ⟨$⟩_) → B ↔ C ⊎-left-cancellative {A = A} = λ inv to-hyp from-hyp → inverse (g (to inv ⟨$⟩_) to-hyp) (g (from inv ⟨$⟩_) from-hyp) (g∘g inv to-hyp from-hyp) (g∘g (SK-sym inv) from-hyp to-hyp) where open Inverse module _ {a b c} {A : Set a} {B : Set b} {C : Set c} (f : A ⊎ B → A ⊎ C) (hyp : Well-behaved f) where mutual g : B → C g b = g′ (inspect (f (inj₂ b))) g′ : ∀ {b} → ∃ (f (inj₂ b) ≡_) → C g′ (inj₂ c , _) = c g′ (inj₁ a , eq) = g″ eq (inspect (f (inj₁ a))) g″ : ∀ {a b} → f (inj₂ b) ≡ inj₁ a → ∃ (f (inj₁ a) ≡_) → C g″ _ (inj₂ c , _) = c g″ eq₁ (inj₁ _ , eq₂) = ⊥-elim $ hyp eq₁ eq₂ g∘g : ∀ {b c} {B : Set b} {C : Set c} (f : (A ⊎ B) ↔ (A ⊎ C)) → (to-hyp : Well-behaved (to f ⟨$⟩_)) → (from-hyp : Well-behaved (from f ⟨$⟩_)) → ∀ b → g (from f ⟨$⟩_) from-hyp (g (to f ⟨$⟩_) to-hyp b) ≡ b g∘g f to-hyp from-hyp b = g∘g′ where open P.≡-Reasoning g∘g′ : g (from f ⟨$⟩_) from-hyp (g (to f ⟨$⟩_) to-hyp b) ≡ b g∘g′ with inspect (to f ⟨$⟩ inj₂ b) g∘g′ | inj₂ c , eq₁ with inspect (from f ⟨$⟩ inj₂ c) g∘g′ | inj₂ c , eq₁ | inj₂ b′ , eq₂ = inj₂-injective ( inj₂ b′ ≡⟨ P.sym eq₂ ⟩ from f ⟨$⟩ inj₂ c ≡⟨ to-from f eq₁ ⟩ inj₂ b ∎) g∘g′ | inj₂ c , eq₁ | inj₁ a , eq₂ with inj₁ a ≡⟨ P.sym eq₂ ⟩ from f ⟨$⟩ inj₂ c ≡⟨ to-from f eq₁ ⟩ inj₂ b ∎ ... | () g∘g′ | inj₁ a , eq₁ with inspect (to f ⟨$⟩ inj₁ a) g∘g′ | inj₁ a , eq₁ | inj₁ a′ , eq₂ = ⊥-elim $ to-hyp eq₁ eq₂ g∘g′ | inj₁ a , eq₁ | inj₂ c , eq₂ with inspect (from f ⟨$⟩ inj₂ c) g∘g′ | inj₁ a , eq₁ | inj₂ c , eq₂ | inj₂ b′ , eq₃ with inj₁ a ≡⟨ P.sym $ to-from f eq₂ ⟩ from f ⟨$⟩ inj₂ c ≡⟨ eq₃ ⟩ inj₂ b′ ∎ ... | () g∘g′ | inj₁ a , eq₁ | inj₂ c , eq₂ | inj₁ a′ , eq₃ with inspect (from f ⟨$⟩ inj₁ a′) g∘g′ | inj₁ a , eq₁ | inj₂ c , eq₂ | inj₁ a′ , eq₃ | inj₁ a″ , eq₄ = ⊥-elim $ from-hyp eq₃ eq₄ g∘g′ | inj₁ a , eq₁ | inj₂ c , eq₂ | inj₁ a′ , eq₃ | inj₂ b′ , eq₄ = inj₂-injective ( let lemma = inj₁ a′ ≡⟨ P.sym eq₃ ⟩ from f ⟨$⟩ inj₂ c ≡⟨ to-from f eq₂ ⟩ inj₁ a ∎ in inj₂ b′ ≡⟨ P.sym eq₄ ⟩ from f ⟨$⟩ inj₁ a′ ≡⟨ P.cong ((from f ⟨$⟩_) ∘ inj₁) $ inj₁-injective lemma ⟩ from f ⟨$⟩ inj₁ a ≡⟨ to-from f eq₁ ⟩ inj₂ b ∎) -- Some final lemmas. ∼→⊎↔⊎ : ∀ {x : A} {xs ys} → x ∷ xs ∼[ bag ] x ∷ ys → ∀ {z} → (z ≡ x ⊎ z ∈ xs) ↔ (z ≡ x ⊎ z ∈ ys) ∼→⊎↔⊎ {x} {xs} {ys} x∷xs≈x∷ys {z} = (z ≡ x ⊎ z ∈ xs) ↔⟨ ∷↔ _ ⟩ z ∈ x ∷ xs ↔⟨ x∷xs≈x∷ys ⟩ z ∈ x ∷ ys ↔⟨ SK-sym (∷↔ _) ⟩ (z ≡ x ⊎ z ∈ ys) ∎ where open Related.EquationalReasoning lemma : ∀ {xs ys} (inv : x ∷ xs ∼[ bag ] x ∷ ys) {z} → Well-behaved (Inverse.to (∼→⊎↔⊎ inv {z}) ⟨$⟩_) lemma {xs} inv {b = z∈xs} {a = p} {a′ = q} hyp₁ hyp₂ with zero ≡⟨⟩ index-of {xs = x ∷ xs} (here p) ≡⟨⟩ index-of {xs = x ∷ xs} (to (∷↔ _) ⟨$⟩ inj₁ p) ≡⟨ P.cong (index-of ∘ (to (∷↔ (_ ≡_)) ⟨$⟩_)) $ P.sym $ to-from (∼→⊎↔⊎ inv) {x = inj₁ p} hyp₂ ⟩ index-of {xs = x ∷ xs} (to (∷↔ _) ⟨$⟩ (from (∼→⊎↔⊎ inv) ⟨$⟩ inj₁ q)) ≡⟨ P.cong index-of $ right-inverse-of (∷↔ _) (from inv ⟨$⟩ here q) ⟩ index-of {xs = x ∷ xs} (to (SK-sym inv) ⟨$⟩ here q) ≡⟨ index-equality-preserved (SK-sym inv) refl ⟩ index-of {xs = x ∷ xs} (to (SK-sym inv) ⟨$⟩ here p) ≡⟨ P.cong index-of $ P.sym $ right-inverse-of (∷↔ _) (from inv ⟨$⟩ here p) ⟩ index-of {xs = x ∷ xs} (to (∷↔ _) ⟨$⟩ (from (∼→⊎↔⊎ inv) ⟨$⟩ inj₁ p)) ≡⟨ P.cong (index-of ∘ (to (∷↔ (_ ≡_)) ⟨$⟩_)) $ to-from (∼→⊎↔⊎ inv) {x = inj₂ z∈xs} hyp₁ ⟩ index-of {xs = x ∷ xs} (to (∷↔ _) ⟨$⟩ inj₂ z∈xs) ≡⟨⟩ index-of {xs = x ∷ xs} (there z∈xs) ≡⟨⟩ suc (index-of {xs = xs} z∈xs) ∎ where open Inverse open P.≡-Reasoning ... | ()
{ "alphanum_fraction": 0.447029148, "avg_line_length": 38.0248667851, "ext": "agda", "hexsha": "a2046d7d6ffca246f36d71f90bfced23fdb3f442", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/BagAndSetEquality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/BagAndSetEquality.agda", "max_line_length": 128, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/BagAndSetEquality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 8068, "size": 21408 }
open import Nat open import Prelude open import contexts module core where -- types data htyp : Set where num : htyp ⦇-⦈ : htyp _==>_ : htyp → htyp → htyp _⊕_ : htyp → htyp → htyp _⊠_ : htyp → htyp → htyp -- type constructors bind very tightly infixr 25 _==>_ infixr 25 _⊕_ infixr 25 _⊠_ -- external expressions data hexp : Set where N : Nat → hexp _·+_ : hexp → hexp → hexp _·:_ : hexp → htyp → hexp X : Nat → hexp ·λ : Nat → hexp → hexp ·λ_·[_]_ : Nat → htyp → hexp → hexp _∘_ : hexp → hexp → hexp inl : hexp → hexp inr : hexp → hexp case : hexp → Nat → hexp → Nat → hexp → hexp ⟨_,_⟩ : hexp → hexp → hexp fst : hexp → hexp snd : hexp → hexp ⦇-⦈[_] : Nat → hexp ⦇⌜_⌟⦈[_] : hexp → Nat → hexp -- the type of type contexts, i.e. Γs in the judgements below tctx : Set tctx = htyp ctx -- type consistency data _~_ : (t1 t2 : htyp) → Set where TCRefl : {τ : htyp} → τ ~ τ TCHole1 : {τ : htyp} → τ ~ ⦇-⦈ TCHole2 : {τ : htyp} → ⦇-⦈ ~ τ TCArr : {τ1 τ2 τ1' τ2' : htyp} → τ1 ~ τ1' → τ2 ~ τ2' → τ1 ==> τ2 ~ τ1' ==> τ2' TCSum : {τ1 τ2 τ1' τ2' : htyp} → τ1 ~ τ1' → τ2 ~ τ2' → τ1 ⊕ τ2 ~ τ1' ⊕ τ2' TCProd : {τ1 τ2 τ1' τ2' : htyp} → τ1 ~ τ1' → τ2 ~ τ2' → τ1 ⊠ τ2 ~ τ1' ⊠ τ2' -- type inconsistency _~̸_ : htyp → htyp → Set t1 ~̸ t2 = (t1 ~ t2) → ⊥ -- matching for arrows data _▸arr_ : htyp → htyp → Set where MAHole : ⦇-⦈ ▸arr ⦇-⦈ ==> ⦇-⦈ MAArr : {τ1 τ2 : htyp} → τ1 ==> τ2 ▸arr τ1 ==> τ2 -- matching for sums data _▸sum_ : htyp → htyp → Set where MSHole : ⦇-⦈ ▸sum ⦇-⦈ ⊕ ⦇-⦈ MSSum : {τ1 τ2 : htyp} → τ1 ⊕ τ2 ▸sum τ1 ⊕ τ2 -- matching for sums data _▸prod_ : htyp → htyp → Set where MPHole : ⦇-⦈ ▸prod ⦇-⦈ ⊠ ⦇-⦈ MPProd : {τ1 τ2 : htyp} → τ1 ⊠ τ2 ▸prod τ1 ⊠ τ2 -- the type of hole contexts, i.e. Δs in the judgements hctx : Set hctx = (htyp ctx × htyp) ctx -- bidirectional type checking judgements for hexp mutual -- synthesis data _⊢_=>_ : (Γ : tctx) (e : hexp) (τ : htyp) → Set where SNum : {Γ : tctx} {n : Nat} → Γ ⊢ N n => num SPlus : {Γ : tctx} {e1 e2 : hexp} → Γ ⊢ e1 <= num → Γ ⊢ e2 <= num → Γ ⊢ (e1 ·+ e2) => num SAsc : {Γ : tctx} {e : hexp} {τ : htyp} → Γ ⊢ e <= τ → Γ ⊢ (e ·: τ) => τ SVar : {Γ : tctx} {τ : htyp} {x : Nat} → (x , τ) ∈ Γ → Γ ⊢ X x => τ SLam : {Γ : tctx} {e : hexp} {τ1 τ2 : htyp} {x : Nat} → x # Γ → (Γ ,, (x , τ1)) ⊢ e => τ2 → Γ ⊢ ·λ x ·[ τ1 ] e => τ1 ==> τ2 SAp : {Γ : tctx} {e1 e2 : hexp} {τ τ1 τ2 : htyp} → Γ ⊢ e1 => τ1 → τ1 ▸arr τ2 ==> τ → Γ ⊢ e2 <= τ2 → Γ ⊢ (e1 ∘ e2) => τ SPair : ∀{e1 e2 τ1 τ2 Γ} → Γ ⊢ e1 => τ1 → Γ ⊢ e2 => τ2 → Γ ⊢ ⟨ e1 , e2 ⟩ => τ1 ⊠ τ2 SFst : ∀{e τ τ1 τ2 Γ} → Γ ⊢ e => τ → τ ▸prod τ1 ⊠ τ2 → Γ ⊢ fst e => τ1 SSnd : ∀{e τ τ1 τ2 Γ} → Γ ⊢ e => τ → τ ▸prod τ1 ⊠ τ2 → Γ ⊢ snd e => τ2 SEHole : {Γ : tctx} {u : Nat} → Γ ⊢ ⦇-⦈[ u ] => ⦇-⦈ SNEHole : {Γ : tctx} {e : hexp} {τ : htyp} {u : Nat} → Γ ⊢ e => τ → Γ ⊢ ⦇⌜ e ⌟⦈[ u ] => ⦇-⦈ -- analysis data _⊢_<=_ : (Γ : htyp ctx) (e : hexp) (τ : htyp) → Set where ASubsume : {Γ : tctx} {e : hexp} {τ τ' : htyp} → Γ ⊢ e => τ' → τ ~ τ' → Γ ⊢ e <= τ ALam : {Γ : tctx} {e : hexp} {τ τ1 τ2 : htyp} {x : Nat} → x # Γ → τ ▸arr τ1 ==> τ2 → (Γ ,, (x , τ1)) ⊢ e <= τ2 → Γ ⊢ (·λ x e) <= τ AInl : {Γ : tctx} {e : hexp} {τ+ τ1 τ2 : htyp} → τ+ ▸sum (τ1 ⊕ τ2) → Γ ⊢ e <= τ1 → Γ ⊢ inl e <= τ+ AInr : {Γ : tctx} {e : hexp} {τ+ τ1 τ2 : htyp} → τ+ ▸sum (τ1 ⊕ τ2) → Γ ⊢ e <= τ2 → Γ ⊢ inr e <= τ+ ACase : {Γ : tctx} {e e1 e2 : hexp} {τ τ+ τ1 τ2 : htyp} {x y : Nat} → x # Γ → y # Γ → τ+ ▸sum (τ1 ⊕ τ2) → Γ ⊢ e => τ+ → (Γ ,, (x , τ1)) ⊢ e1 <= τ → (Γ ,, (y , τ2)) ⊢ e2 <= τ → Γ ⊢ case e x e1 y e2 <= τ -- those types without holes data _tcomplete : htyp → Set where TCNum : num tcomplete TCArr : ∀{τ1 τ2} → τ1 tcomplete → τ2 tcomplete → (τ1 ==> τ2) tcomplete TCSum : ∀{τ1 τ2} → τ1 tcomplete → τ2 tcomplete → (τ1 ⊕ τ2) tcomplete TCProd : ∀{τ1 τ2} → τ1 tcomplete → τ2 tcomplete → (τ1 ⊠ τ2) tcomplete -- those external expressions without holes data _ecomplete : hexp → Set where ECNum : ∀{n} → (N n) ecomplete ECPlus : ∀{e1 e2} → e1 ecomplete → e2 ecomplete → (e1 ·+ e2) ecomplete ECAsc : ∀{τ e} → τ tcomplete → e ecomplete → (e ·: τ) ecomplete ECVar : ∀{x} → (X x) ecomplete ECLam1 : ∀{x e} → e ecomplete → (·λ x e) ecomplete ECLam2 : ∀{x e τ} → e ecomplete → τ tcomplete → (·λ x ·[ τ ] e) ecomplete ECAp : ∀{e1 e2} → e1 ecomplete → e2 ecomplete → (e1 ∘ e2) ecomplete ECInl : ∀{e} → e ecomplete → (inl e) ecomplete ECInr : ∀{e} → e ecomplete → (inr e) ecomplete ECCase : ∀{e x e1 y e2} → e ecomplete → e1 ecomplete → e2 ecomplete → (case e x e1 y e2) ecomplete ECPair : ∀{e1 e2} → e1 ecomplete → e2 ecomplete → ⟨ e1 , e2 ⟩ ecomplete ECFst : ∀{e} → e ecomplete → (fst e) ecomplete ECSnd : ∀{e} → e ecomplete → (snd e) ecomplete -- contexts that only produce complete types _gcomplete : tctx → Set Γ gcomplete = (x : Nat) (τ : htyp) → (x , τ) ∈ Γ → τ tcomplete -- ground types data _ground : htyp → Set where GNum : num ground GArrHole : ⦇-⦈ ==> ⦇-⦈ ground GSumHole : ⦇-⦈ ⊕ ⦇-⦈ ground GProdHole : ⦇-⦈ ⊠ ⦇-⦈ ground
{ "alphanum_fraction": 0.384262683, "avg_line_length": 30.8721461187, "ext": "agda", "hexsha": "93fb98b42ac5224a3ae3d6affc36cf9da0ebc507", "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": "core.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": "core.agda", "max_line_length": 78, "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": "core.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2807, "size": 6761 }
module Function.PointwiseStructure where open import Functional using (_∘_) renaming (const to const₁) open import Function.Equals open import Function.Multi.Functions open import Logic.Predicate open import Logic.Propositional import Lvl open import Structure.Function open import Structure.Function.Multi open import Structure.Setoid open import Structure.Operator.Field open import Structure.Operator.Group open import Structure.Operator.Monoid open import Structure.Operator.Properties open import Structure.Operator.Vector open import Structure.Operator open import Structure.Relator.Properties open import Type private variable ℓ ℓₑ ℓₗ ℓₗₑ : Lvl.Level private variable I S T : Type{ℓ} private variable _+_ _⋅_ : S → S → S -- TODO: Possible to generalize to functions with multiple arguments module _ ⦃ equiv : Equiv{ℓₑ}(T) ⦄ where private variable _▫_ _▫₁_ _▫₂_ : T → T → T private variable f inv : T → T private variable id : T -- A component-wise function is a function when its underlying function is a function. pointwiseFunction-function : ⦃ oper : Function(f) ⦄ → Function(pointwise(1)(1) {As = I} (f)) Function.congruence (pointwiseFunction-function {f = f}) (intro p) = intro(congruence₁(f) p) -- A component-wise binary operator is a binary operator when its underlying binary operator is a binary operator. pointwiseFunction-binaryOperator : ⦃ oper : BinaryOperator(_▫_) ⦄ → BinaryOperator(pointwise(1)(2) {As = I} (_▫_)) BinaryOperator.congruence (pointwiseFunction-binaryOperator {_▫_ = _▫_}) (intro p) (intro q) = intro(congruence₂(_▫_) p q) -- A component-wise operator is associative when its underlying operator is associative. pointwiseFunction-associativity : ⦃ assoc : Associativity(_▫_) ⦄ → Associativity(pointwise(1)(2) {As = I} (_▫_)) pointwiseFunction-associativity {_▫_ = _▫_} = intro(intro(associativity(_▫_))) -- A component-wise operator is commutative when its underlying operator is commutative. pointwiseFunction-commutativity : ⦃ comm : Commutativity(_▫_) ⦄ → Commutativity(pointwise(1)(2) {As = I} (_▫_)) pointwiseFunction-commutativity {_▫_ = _▫_} = intro(intro(commutativity(_▫_))) -- A component-wise operator have a left identity of repeated elements when its underlying operator have a left identity. pointwiseFunction-identityₗ : ⦃ identₗ : Identityₗ(_▫_)(id) ⦄ → Identityₗ(pointwise(1)(2) {As = I} (_▫_))(const₁ id) pointwiseFunction-identityₗ {_▫_ = _▫_} {id = id} = intro(intro(identityₗ(_▫_)(id))) -- A component-wise operator have a right identity of repeated elements when its underlying operator have a right identity. pointwiseFunction-identityᵣ : ⦃ identᵣ : Identityᵣ(_▫_)(id) ⦄ → Identityᵣ(pointwise(1)(2) {As = I} (_▫_))(const₁ id) pointwiseFunction-identityᵣ {_▫_ = _▫_} {id = id} = intro(intro(identityᵣ(_▫_)(id))) -- A component-wise operator have an identity of repeated elements when its underlying operator have an identity. pointwiseFunction-identity : ⦃ ident : Identity(_▫_)(id) ⦄ → Identity(pointwise(1)(2) {As = I} (_▫_))(const₁ id) Identity.left pointwiseFunction-identity = pointwiseFunction-identityₗ Identity.right pointwiseFunction-identity = pointwiseFunction-identityᵣ pointwiseFunction-inverseFunctionₗ : ⦃ identₗ : Identityₗ(_▫_)(id) ⦄ ⦃ inverₗ : InverseFunctionₗ(_▫_) ⦃ [∃]-intro(id) ⦄ (inv) ⦄ → InverseFunctionₗ(pointwise(1)(2) {As = I} (_▫_)) ⦃ [∃]-intro _ ⦃ pointwiseFunction-identityₗ ⦄ ⦄ (pointwise(1)(1) {As = I} inv) pointwiseFunction-inverseFunctionₗ {_▫_ = _▫_} {id = id} {inv = inv} = intro(intro(inverseFunctionₗ(_▫_) ⦃ [∃]-intro id ⦄ (inv))) pointwiseFunction-inverseFunctionᵣ : ⦃ identᵣ : Identityᵣ(_▫_)(id) ⦄ ⦃ inverᵣ : InverseFunctionᵣ(_▫_) ⦃ [∃]-intro(id) ⦄ (inv) ⦄ → InverseFunctionᵣ(pointwise(1)(2) {As = I} (_▫_)) ⦃ [∃]-intro _ ⦃ pointwiseFunction-identityᵣ ⦄ ⦄ (pointwise(1)(1) {As = I} inv) pointwiseFunction-inverseFunctionᵣ {_▫_ = _▫_} {id = id} {inv = inv} = intro(intro(inverseFunctionᵣ(_▫_) ⦃ [∃]-intro id ⦄ (inv))) pointwiseFunction-inverseFunction : ⦃ ident : Identity(_▫_)(id) ⦄ ⦃ inver : InverseFunction(_▫_) ⦃ [∃]-intro(id) ⦄ (inv) ⦄ → InverseFunction(pointwise(1)(2) {As = I} (_▫_)) ⦃ [∃]-intro _ ⦃ pointwiseFunction-identity ⦄ ⦄ (pointwise(1)(1) {As = I} inv) InverseFunction.left pointwiseFunction-inverseFunction = pointwiseFunction-inverseFunctionₗ InverseFunction.right pointwiseFunction-inverseFunction = pointwiseFunction-inverseFunctionᵣ -- A component-wise operator is left distributive over another component-wise operator when their underlying operators distribute. pointwiseFunction-distributivityₗ : ⦃ distₗ : Distributivityₗ(_▫₁_)(_▫₂_) ⦄ → Distributivityₗ(pointwise(1)(2) {As = I} (_▫₁_))(pointwise(1)(2) {As = I} (_▫₂_)) pointwiseFunction-distributivityₗ = intro(intro(distributivityₗ _ _)) -- A component-wise operator is right distributive over another component-wise operator when their underlying operators distribute. pointwiseFunction-distributivityᵣ : ⦃ distᵣ : Distributivityᵣ(_▫₁_)(_▫₂_) ⦄ → Distributivityᵣ(pointwise(1)(2) {As = I} (_▫₁_))(pointwise(1)(2) {As = I} (_▫₂_)) pointwiseFunction-distributivityᵣ = intro(intro(distributivityᵣ _ _)) pointwiseFunction-const-preserves : Preserving₂(const₁) (_▫_) (pointwise(1)(2) {As = I} (_▫_)) pointwiseFunction-const-preserves = intro(intro(reflexivity(_≡_))) -- A component-wise operator is a monoid when its underlying operator is a monoid. pointwiseFunction-monoid : ⦃ monoid : Monoid(_▫_) ⦄ → Monoid(pointwise(1)(2) {As = I} (_▫_)) Monoid.binary-operator pointwiseFunction-monoid = pointwiseFunction-binaryOperator Monoid.associativity pointwiseFunction-monoid = pointwiseFunction-associativity Monoid.identity-existence pointwiseFunction-monoid = [∃]-intro _ ⦃ pointwiseFunction-identity ⦄ -- A component-wise operator is a group when its underlying operator is a group. pointwiseFunction-group : ⦃ group : Group(_▫_) ⦄ → Group(pointwise(1)(2) {As = I} (_▫_)) Group.monoid pointwiseFunction-group = pointwiseFunction-monoid Group.inverse-existence pointwiseFunction-group = [∃]-intro _ ⦃ pointwiseFunction-inverseFunction ⦄ Group.inv-function pointwiseFunction-group = pointwiseFunction-function -- A component-wise operator is a commutative group when its underlying operator is a commutative group. pointwiseFunction-commutativeGroup : ⦃ commutativeGroup : CommutativeGroup(_▫_) ⦄ → CommutativeGroup(pointwise(1)(2) {As = I} (_▫_)) CommutativeGroup.group pointwiseFunction-commutativeGroup = pointwiseFunction-group CommutativeGroup.commutativity pointwiseFunction-commutativeGroup = pointwiseFunction-commutativity module _ ⦃ equiv : Equiv{ℓₑ}(S) ⦄ (field-structure : Field{T = S}(_+_)(_⋅_)) where open Field(field-structure) -- Component-wise operators constructs a vector space from a field when using the fields as scalars and coordinate vectors as vectors. pointwiseFunction-vectorSpace : VectorSpace(pointwise(1)(2) {As = I} (_+_))(pointwise(1)(1) ∘ (_⋅_))(_+_)(_⋅_) VectorSpace.scalarField pointwiseFunction-vectorSpace = field-structure VectorSpace.vectorCommutativeGroup pointwiseFunction-vectorSpace = pointwiseFunction-commutativeGroup _⊜_.proof (BinaryOperator.congruence (VectorSpace.[⋅ₛᵥ]-binaryOperator pointwiseFunction-vectorSpace) p (intro q)) = congruence₂(_⋅_) p q _⊜_.proof (VectorSpace.[⋅ₛ][⋅ₛᵥ]-compatibility pointwiseFunction-vectorSpace) = associativity(_⋅_) _⊜_.proof (Identityₗ.proof (VectorSpace.[⋅ₛᵥ]-identity pointwiseFunction-vectorSpace)) = identityₗ(_⋅_)(𝟏) _⊜_.proof (Distributivityₗ.proof (VectorSpace.[⋅ₛᵥ][+ᵥ]-distributivityₗ pointwiseFunction-vectorSpace)) = distributivityₗ(_⋅_)(_+_) _⊜_.proof (VectorSpace.[⋅ₛᵥ][+ₛ][+ᵥ]-distributivityᵣ pointwiseFunction-vectorSpace) = distributivityᵣ(_⋅_)(_+_)
{ "alphanum_fraction": 0.7407265285, "avg_line_length": 69.185840708, "ext": "agda", "hexsha": "75106987b6863745498d691eb74526279f831342", "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": "Function/PointwiseStructure.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": "Function/PointwiseStructure.agda", "max_line_length": 260, "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": "Function/PointwiseStructure.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": 2559, "size": 7818 }
open import Oscar.Prelude open import Oscar.Class module Oscar.Class.Leftstar where module Leftstar {𝔞 𝔟 𝔣 𝔞̇ 𝔟̇} {𝔄 : Ø 𝔞} {𝔅 : Ø 𝔟} {𝔉 : Ø 𝔣} (𝔄̇ : 𝔄 → Ø 𝔞̇) (𝔅̇ : 𝔅 → Ø 𝔟̇) (_◂_ : 𝔉 → 𝔄 → 𝔅) = ℭLASS (_◂_ , 𝔅̇) (∀ {x} f → 𝔄̇ x → 𝔅̇ (f ◂ x)) module _ {𝔞 𝔟 𝔣 𝔞̇ 𝔟̇} {𝔄 : Ø 𝔞} {𝔅 : Ø 𝔟} {𝔉 : Ø 𝔣} {𝔄̇ : 𝔄 → Ø 𝔞̇} {𝔅̇ : 𝔅 → Ø 𝔟̇} {_◂_ : 𝔉 → 𝔄 → 𝔅} where leftstar = Leftstar.method 𝔄̇ 𝔅̇ _◂_ open import Oscar.Class.Surjection open import Oscar.Class.Smap module Leftstar,smaparrow {𝔵₁ 𝔵₂} {𝔛₁ : Ø 𝔵₁} {𝔛₂ : Ø 𝔵₂} (surjection : Surjection.type 𝔛₁ 𝔛₂) {𝔭₁ 𝔭₂} (𝔓₁ : 𝔛₂ → Ø 𝔭₁) (𝔓₂ : 𝔛₂ → Ø 𝔭₂) {𝔯} (ℜ : 𝔛₁ → 𝔛₁ → Ø 𝔯) {𝔭̇₁} (𝔓̇₁ : ∀ {a} → 𝔓₁ (surjection a) → Ø 𝔭̇₁) {𝔭̇₂} (𝔓̇₂ : ∀ {a} → 𝔓₂ (surjection a) → Ø 𝔭̇₂) (smaparrow : Smaparrow.type ℜ 𝔓₁ 𝔓₂ surjection surjection) where class = ∀ {a₁ a₂} → Leftstar.class (𝔓̇₁ {a₁}) (𝔓̇₂ {a₂}) smaparrow type = ∀ {a₁ a₂} → Leftstar.type (𝔓̇₁ {a₁}) (𝔓̇₂ {a₂}) smaparrow module Leftstar,smaparrow! {𝔵₁ 𝔵₂} {𝔛₁ : Ø 𝔵₁} {𝔛₂ : Ø 𝔵₂} ⦃ _ : Surjection.class 𝔛₁ 𝔛₂ ⦄ {𝔭₁ 𝔭₂} (𝔓₁ : 𝔛₂ → Ø 𝔭₁) (𝔓₂ : 𝔛₂ → Ø 𝔭₂) {𝔯} (ℜ : 𝔛₁ → 𝔛₁ → Ø 𝔯) {𝔭̇₁} (𝔓̇₁ : ∀ {a} → 𝔓₁ (surjection a) → Ø 𝔭̇₁) {𝔭̇₂} (𝔓̇₂ : ∀ {a} → 𝔓₂ (surjection a) → Ø 𝔭̇₂) ⦃ _ : Smaparrow!.class ℜ 𝔓₁ 𝔓₂ ⦄ = Leftstar,smaparrow surjection 𝔓₁ 𝔓₂ ℜ 𝔓̇₁ 𝔓̇₂ smaparrow module Leftstar,smaphomarrow {𝔵₁ 𝔵₂} {𝔛₁ : Ø 𝔵₁} {𝔛₂ : Ø 𝔵₂} (surjection : Surjection.type 𝔛₁ 𝔛₂) {𝔭} (𝔓 : 𝔛₂ → Ø 𝔭) {𝔯} (ℜ : 𝔛₁ → 𝔛₁ → Ø 𝔯) {𝔭̇} (𝔓̇ : ∀ {a} → 𝔓 (surjection a) → Ø 𝔭̇) (smaparrow : Smaphomarrow.type ℜ 𝔓 surjection) = Leftstar,smaparrow surjection 𝔓 𝔓 ℜ 𝔓̇ 𝔓̇ smaparrow module Leftstar,smaphomarrow! {𝔵₁ 𝔵₂} {𝔛₁ : Ø 𝔵₁} {𝔛₂ : Ø 𝔵₂} ⦃ _ : Surjection.class 𝔛₁ 𝔛₂ ⦄ {𝔭} (𝔓 : 𝔛₂ → Ø 𝔭) {𝔯} (ℜ : 𝔛₁ → 𝔛₁ → Ø 𝔯) {𝔭̇} (𝔓̇ : ∀ {a} → 𝔓 (surjection a) → Ø 𝔭̇) ⦃ _ : Smaphomarrow!.class ℜ 𝔓 ⦄ = Leftstar,smaphomarrow surjection 𝔓 ℜ 𝔓̇ smaparrow
{ "alphanum_fraction": 0.5385422129, "avg_line_length": 27.2428571429, "ext": "agda", "hexsha": "2592c6f4ea03128ee54f1713a8ee04f0de993074", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Leftstar.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Leftstar.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Leftstar.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1294, "size": 1907 }
module _ where data _==_ {A : Set} (a : A) : A → Set where refl : a == a data ⊥ : Set where data ℕ : Set where zero : ℕ suc : ℕ → ℕ it : ∀ {a} {A : Set a} ⦃ x : A ⦄ → A it ⦃ x ⦄ = x f : (n : ℕ) ⦃ p : ⦃ _ : n == zero ⦄ → ⊥ ⦄ → ℕ f n = n g : (n : ℕ) ⦃ q : ⦃ _ : n == zero ⦄ → ⊥ ⦄ → ℕ g n ⦃ q ⦄ = f n h : (n : ℕ) ⦃ q : ⦃ _ : n == zero ⦄ → ⊥ ⦄ → ℕ h n ⦃ q ⦄ = f n ⦃ it ⦄
{ "alphanum_fraction": 0.3595800525, "avg_line_length": 15.875, "ext": "agda", "hexsha": "a0b38ffa553981b6d9a156b6cf5ebebea9722de3", "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/Issue1322.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/Issue1322.agda", "max_line_length": 45, "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/Issue1322.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": 226, "size": 381 }
------------------------------------------------------------------------------ -- Distributive laws on a binary operation: Task B ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module DistributiveLaws.TaskB-AllStepsATP where open import DistributiveLaws.Base open import Common.FOL.Relation.Binary.EqReasoning ------------------------------------------------------------------------------ -- We prove all the proof steps of DistributiveLaws.TaskB-I using the -- ATPs. prop₂ : ∀ u x y z → (x · y · (z · u)) · ((x · y · (z · u)) · (x · z · (y · u))) ≡ x · z · (y · u) prop₂ u x y z = xy·zu · (xy·zu · xz·yu) ≡⟨ j₁ ⟩ xy·zu · (x·zu · y·zu · xz·yu) ≡⟨ j₂ ⟩ xy·zu · (x·zu · xz·yu · (y·zu · xz·yu)) ≡⟨ j₃ ⟩ xy·zu · (xz·xu · xz·yu · (y·zu · xz·yu)) ≡⟨ j₄ ⟩ xy·zu · (xz · xu·yu · (y·zu · xz·yu)) ≡⟨ j₅ ⟩ xy·zu · (xz · xyu · (y·zu · xz·yu)) ≡⟨ j₆ ⟩ xy·zu · (xz · xyu · (yz·yu · xz·yu)) ≡⟨ j₇ ⟩ xy·zu · (xz · xyu · (yz·xz · yu)) ≡⟨ j₈ ⟩ xy·zu · (xz · xyu · (yxz · yu)) ≡⟨ j₉ ⟩ xy·zu · (xz · xyu · (yx·yu · z·yu)) ≡⟨ j₁₀ ⟩ xy·zu · (xz · xyu · (y·xu · z·yu)) ≡⟨ j₁₁ ⟩ xyz · xyu · (xz · xyu · (y·xu · z·yu)) ≡⟨ j₁₂ ⟩ xz·yz · xyu · (xz · xyu · (y·xu · z·yu)) ≡⟨ j₁₃ ⟩ xz · xyu · (yz · xyu) · (xz · xyu · (y·xu · z·yu)) ≡⟨ j₁₄ ⟩ xz · xyu · (yz · xyu · (y·xu · z·yu)) ≡⟨ j₁₅ ⟩ xz · xyu · (yz · xu·yu · (y·xu · z·yu)) ≡⟨ j₁₆ ⟩ xz · xyu · (y · xu·yu · (z · xu·yu) · (y·xu · z·yu)) ≡⟨ j₁₇ ⟩ xz · xyu · (y · xu·yu · (y·xu · z·yu) · (z · xu·yu · (y·xu · z·yu))) ≡⟨ j₁₈ ⟩ xz · xyu · (y·xu · y·yu · (y·xu · z·yu) · (z · xu·yu · (y·xu · z·yu))) ≡⟨ j₁₉ ⟩ xz · xyu · (y·xu · (y·yu · z·yu) · (z · xu·yu · (y·xu · z·yu))) ≡⟨ j₂₀ ⟩ xz · xyu · (y·xu · yz·yu · (z · xu·yu · (y·xu · z·yu))) ≡⟨ j₂₁ ⟩ xz · xyu · (y·xu · y·zu · (z · xu·yu · (y·xu · z·yu))) ≡⟨ j₂₂ ⟩ xz · xyu · (y · xu·zu · (z · xu·yu · (y·xu · z·yu))) ≡⟨ j₂₃ ⟩ xz · xyu · (y · xu·zu · (z·xu · z·yu · (y·xu · z·yu))) ≡⟨ j₂₄ ⟩ (xz · xyu) · (y · xu·zu · (z·xu · y·xu · z·yu)) ≡⟨ j₂₅ ⟩ xz · xyu · (y · xu·zu · (zy·xu · z·yu)) ≡⟨ j₂₆ ⟩ xz · xyu · (y · xu·zu · (zy·xu · zy·zu)) ≡⟨ j₂₇ ⟩ xz · xyu · (y · xu·zu · (zy · xu·zu)) ≡⟨ j₂₈ ⟩ xz · xyu · (y·zy · xu·zu) ≡⟨ j₂₉ ⟩ xz · xyu · (y·zy · xzu) ≡⟨ j₃₀ ⟩ xz·xy · xzu · (y·zy · xzu) ≡⟨ j₃₁ ⟩ x·zy · xzu · (y·zy · xzu) ≡⟨ j₃₂ ⟩ x·zy · y·zy · xzu ≡⟨ j₃₃ ⟩ xy·zy · xzu ≡⟨ j₃₄ ⟩ xzy · xzu ≡⟨ j₃₅ ⟩ xz·yu ∎ where -- Two variables abbreviations xz = x · z yu = y · u yz = y · z zy = z · y {-# ATP definitions xz yu yz zy #-} -- Three variables abbreviations xyu = x · y · u xyz = x · y · z xzu = x · z · u xzy = x · z · y yxz = y · x · z {-# ATP definitions xyu xyz xzu xzy yxz #-} x·yu = x · (y · u) x·zu = x · (z · u) x·zy = x · (z · y) {-# ATP definitions x·yu x·zu x·zy #-} y·xu = y · (x · u) y·yu = y · (y · u) y·zu = y · (z · u) y·zy = y · (z · y) {-# ATP definitions y·xu y·yu y·zu y·zy #-} z·xu = z · (x · u) z·yu = z · (y · u) {-# ATP definitions z·xu z·yu #-} -- Four variables abbreviations xu·yu = x · u · (y · u) xu·zu = x · u · (z · u) {-# ATP definitions xu·yu xu·zu #-} xy·yz = x · y · (y · z) xy·zu = x · y · (z · u) xy·zy = x · y · (z · y) {-# ATP definitions xy·yz xy·zu xy·zy #-} xz·xu = x · z · (x · u) xz·xy = x · z · (x · y) xz·yu = x · z · (y · u) xz·yz = x · z · (y · z) {-# ATP definitions xz·xu xz·xy xz·yu xz·yz #-} yx·yu = y · x · (y · u) {-# ATP definition yx·yu #-} yz·xz = y · z · (x · z) yz·yu = y · z · (y · u) {-# ATP definitions yz·xz yz·yu #-} zy·xu = z · y · (x · u) zy·zu = z · y · (z · u) {-# ATP definitions zy·xu zy·zu #-} -- Steps justifications postulate j₁ : xy·zu · (xy·zu · xz·yu) ≡ xy·zu · (x·zu · y·zu · xz·yu) {-# ATP prove j₁ #-} postulate j₂ : xy·zu · (x·zu · y·zu · xz·yu) ≡ xy·zu · (x·zu · xz·yu · (y·zu · xz·yu)) {-# ATP prove j₂ #-} postulate j₃ : xy·zu · (x·zu · xz·yu · (y·zu · xz·yu)) ≡ xy·zu · (xz·xu · xz·yu · (y·zu · xz·yu)) {-# ATP prove j₃ #-} postulate j₄ : xy·zu · (xz·xu · xz·yu · (y·zu · xz·yu)) ≡ xy·zu · (xz · xu·yu · (y·zu · xz·yu)) {-# ATP prove j₄ #-} postulate j₅ : xy·zu · (xz · xu·yu · (y·zu · xz·yu)) ≡ xy·zu · (xz · xyu · (y·zu · xz·yu)) {-# ATP prove j₅ #-} postulate j₆ : xy·zu · (xz · xyu · (y·zu · xz·yu)) ≡ xy·zu · (xz · xyu · (yz·yu · xz·yu)) {-# ATP prove j₆ #-} postulate j₇ : xy·zu · (xz · xyu · (yz·yu · xz·yu)) ≡ xy·zu · (xz · xyu · (yz·xz · yu)) {-# ATP prove j₇ #-} postulate j₈ : xy·zu · (xz · xyu · (yz·xz · yu)) ≡ xy·zu · (xz · xyu · (yxz · yu)) {-# ATP prove j₈ #-} postulate j₉ : xy·zu · (xz · xyu · (yxz · yu)) ≡ xy·zu · (xz · xyu · (yx·yu · z·yu)) {-# ATP prove j₉ #-} postulate j₁₀ : xy·zu · (xz · xyu · (yx·yu · z·yu)) ≡ xy·zu · (xz · xyu · (y·xu · z·yu)) {-# ATP prove j₁₀ #-} postulate j₁₁ : xy·zu · (xz · xyu · (y·xu · z·yu)) ≡ xyz · xyu · (xz · xyu · (y·xu · z·yu)) {-# ATP prove j₁₁ #-} postulate j₁₂ : xyz · xyu · (xz · xyu · (y·xu · z·yu)) ≡ xz·yz · xyu · (xz · xyu · (y·xu · z·yu)) {-# ATP prove j₁₂ #-} postulate j₁₃ : xz·yz · xyu · (xz · xyu · (y·xu · z·yu)) ≡ xz · xyu · (yz · xyu) · (xz · xyu · (y·xu · z·yu)) {-# ATP prove j₁₃ #-} postulate j₁₄ : xz · xyu · (yz · xyu) · (xz · xyu · (y·xu · z·yu)) ≡ xz · xyu · (yz · xyu · (y·xu · z·yu)) {-# ATP prove j₁₄ #-} postulate j₁₅ : xz · xyu · (yz · xyu · (y·xu · z·yu)) ≡ xz · xyu · (yz · xu·yu · (y·xu · z·yu)) {-# ATP prove j₁₅ #-} postulate j₁₆ : xz · xyu · (yz · xu·yu · (y·xu · z·yu)) ≡ xz · xyu · (y · xu·yu · (z · xu·yu) · (y·xu · z·yu)) {-# ATP prove j₁₆ #-} postulate j₁₇ : xz · xyu · (y · xu·yu · (z · xu·yu) · (y·xu · z·yu)) ≡ xz · xyu · (y · xu·yu · (y·xu · z·yu) · (z · xu·yu · (y·xu · z·yu))) {-# ATP prove j₁₇ #-} postulate j₁₈ : xz · xyu · (y · xu·yu · (y·xu · z·yu) · (z · xu·yu · (y·xu · z·yu))) ≡ xz · xyu · (y·xu · y·yu · (y·xu · z·yu) · (z · xu·yu · (y·xu · z·yu))) {-# ATP prove j₁₈ #-} postulate j₁₉ : xz · xyu · (y·xu · y·yu · (y·xu · z·yu) · (z · xu·yu · (y·xu · z·yu))) ≡ xz · xyu · (y·xu · (y·yu · z·yu) · (z · xu·yu · (y·xu · z·yu))) {-# ATP prove j₁₉ #-} postulate j₂₀ : xz · xyu · (y·xu · (y·yu · z·yu) · (z · xu·yu · (y·xu · z·yu))) ≡ xz · xyu · (y·xu · yz·yu · (z · xu·yu · (y·xu · z·yu))) {-# ATP prove j₂₀ #-} postulate j₂₁ : xz · xyu · (y·xu · yz·yu · (z · xu·yu · (y·xu · z·yu))) ≡ xz · xyu · (y·xu · y·zu · (z · xu·yu · (y·xu · z·yu))) {-# ATP prove j₂₁ #-} postulate j₂₂ : xz · xyu · (y·xu · y·zu · (z · xu·yu · (y·xu · z·yu))) ≡ xz · xyu · (y · xu·zu · (z · xu·yu · (y·xu · z·yu))) {-# ATP prove j₂₂ #-} postulate j₂₃ : xz · xyu · (y · xu·zu · (z · xu·yu · (y·xu · z·yu))) ≡ xz · xyu · (y · xu·zu · (z·xu · z·yu · (y·xu · z·yu))) {-# ATP prove j₂₃ #-} postulate j₂₄ : xz · xyu · (y · xu·zu · (z·xu · z·yu · (y·xu · z·yu))) ≡ (xz · xyu) · (y · xu·zu · (z·xu · y·xu · z·yu)) {-# ATP prove j₂₄ #-} postulate j₂₅ : (xz · xyu) · (y · xu·zu · (z·xu · y·xu · z·yu)) ≡ xz · xyu · (y · xu·zu · (zy·xu · z·yu)) {-# ATP prove j₂₅ #-} postulate j₂₆ : xz · xyu · (y · xu·zu · (zy·xu · z·yu)) ≡ xz · xyu · (y · xu·zu · (zy·xu · zy·zu)) {-# ATP prove j₂₆ #-} postulate j₂₇ : xz · xyu · (y · xu·zu · (zy·xu · zy·zu)) ≡ xz · xyu · (y · xu·zu · (zy · xu·zu)) {-# ATP prove j₂₇ #-} postulate j₂₈ : xz · xyu · (y · xu·zu · (zy · xu·zu)) ≡ xz · xyu · (y·zy · xu·zu) {-# ATP prove j₂₈ #-} postulate j₂₉ : xz · xyu · (y·zy · xu·zu) ≡ xz · xyu · (y·zy · xzu) {-# ATP prove j₂₉ #-} postulate j₃₀ : xz · xyu · (y·zy · xzu) ≡ xz·xy · xzu · (y·zy · xzu) {-# ATP prove j₃₀ #-} postulate j₃₁ : xz·xy · xzu · (y·zy · xzu) ≡ x·zy · xzu · (y·zy · xzu) {-# ATP prove j₃₁ #-} postulate j₃₂ : x·zy · xzu · (y·zy · xzu) ≡ x·zy · y·zy · xzu {-# ATP prove j₃₂ #-} postulate j₃₃ : x·zy · y·zy · xzu ≡ xy·zy · xzu {-# ATP prove j₃₃ #-} postulate j₃₄ : xy·zy · xzu ≡ xzy · xzu {-# ATP prove j₃₄ #-} postulate j₃₅ : xzy · xzu ≡ xz·yu {-# ATP prove j₃₅ #-}
{ "alphanum_fraction": 0.3692083939, "avg_line_length": 36.1879699248, "ext": "agda", "hexsha": "86a652c853ce303458969b9d34dfa5dd838a3db2", "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/DistributiveLaws/TaskB-AllStepsATP.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/DistributiveLaws/TaskB-AllStepsATP.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/DistributiveLaws/TaskB-AllStepsATP.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": 4345, "size": 9626 }
-- Properties of quicksort {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Algorithms.List.Sort.Quick.Properties {c l₁ l₂} (DTO : DecTotalOrder c l₁ l₂) where -- agda-stdlib open import Level open import Data.List import Data.List.Properties as Listₚ import Data.List.Relation.Binary.Equality.Setoid as EqualitySetoid import Data.List.Relation.Binary.Permutation.Setoid as PermutationSetoid open import Data.Product import Data.Nat as ℕ open import Data.Nat.Induction as Ind open import Relation.Binary as B open import Relation.Unary as U import Relation.Unary.Properties as Uₚ open import Relation.Binary.PropositionalEquality as P using (_≡_) import Relation.Binary.Reasoning.Setoid as SetoidReasoning open import Function.Base open import Induction.WellFounded -- agda-misc open import Algorithms.List.Sort.Common DTO open import Algorithms.List.Sort.Quick open DecTotalOrder DTO renaming (Carrier to A) open Quicksort _≤?_ open PermutationSetoid Eq.setoid open EqualitySetoid Eq.setoid {- sort-acc-cong : ∀ {xs ys rs₁ rs₂} → xs ≋ ys → sort-acc xs rs₁ ≋ sort-acc ys rs₂ sort-acc-cong {[]} {[]} {rs₁} {rs₂} xs≋ys = ≋-refl sort-acc-cong {x ∷ xs} {y ∷ ys} {acc rs₁} {acc rs₂} (x≈y EqualitySetoid.∷ xs≋ys) = ++⁺ (sort-acc-cong {! !}) (++⁺ (x≈y ∷ []) {! !}) -} {- sort-acc-filter : ∀ x xs rs lt₁ lt₂ → sort-acc (x ∷ xs) (acc rs) ≡ sort-acc (filter (_≤? x) xs) (rs _ lt₁) ++ [ x ] ++ sort-acc (filter (Uₚ.∁? (_≤? x)) xs) (rs _ lt₂) sort-acc-filter x xs rs lt₁ lt₂ = begin sort-acc (proj₁ (split x xs)) (rs _ _) ++ [ x ] ++ sort-acc (proj₂ (split x xs)) (rs _ _) ≡⟨ ? ⟩ sort-acc (filter (_≤? x) xs) (rs _ lt₁) ++ [ x ] ++ sort-acc (filter (Uₚ.∁? (_≤? x)) xs) (rs _ lt₂) ∎ sort-acc-permutation : ∀ xs ac → sort-acc xs ac ↭ xs sort-acc-permutation [] ac = ↭-refl sort-acc-permutation (x ∷ xs) (acc rs) = begin sort-acc (x ∷ xs) (acc rs) ≈⟨ {! !} ⟩ x ∷ xs ∎ where open SetoidReasoning ↭-setoid -}
{ "alphanum_fraction": 0.6576846307, "avg_line_length": 32.3225806452, "ext": "agda", "hexsha": "6a3873baf9f25ba76c85e9dafe1336e972487c33", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_path": "Algorithms/List/Sort/Quick/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_path": "Algorithms/List/Sort/Quick/Properties.agda", "max_line_length": 82, "max_stars_count": 3, "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_path": "Algorithms/List/Sort/Quick/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "num_tokens": 708, "size": 2004 }
{-# OPTIONS --without-K --safe #-} -- In this module, we define the usual definition of D<: -- the one having typing and -- subtyping mutually defined. module DsubFull where open import Data.List as List open import Data.List.All as All open import Data.Nat as ℕ open import Data.Maybe as Maybe open import Data.Product open import Data.Sum open import Data.Empty renaming (⊥ to False) open import Data.Vec as Vec renaming (_∷_ to _‼_ ; [] to nil) hiding (_++_) open import Function open import Data.Maybe.Properties as Maybeₚ open import Data.Nat.Properties as ℕₚ open import Relation.Nullary open import Relation.Binary.PropositionalEquality as ≡ open import DsubDef open import Dsub renaming (_⊢_<:_ to _⊢′_<:_) open import Utils infix 4 _⊢_<:_ _⊢_∶_ mutual data _⊢_∶_ : Env → Trm → Typ → Set where var∶ : ∀ {Γ n T} → (T∈Γ : env-lookup Γ n ≡ just T) → Γ ⊢ var n ∶ T Π-I : ∀ {Γ T t U} → Γ ‣ T ! ⊢ t ∶ U → Γ ⊢ val (Λ T ∙ t) ∶ Π T ∙ U Π-E : ∀ {Γ n m S U} → Γ ⊢ var n ∶ Π S ∙ U → Γ ⊢ var m ∶ S → Γ ⊢ n $$ m ∶ U [ m / 0 ] ⟨A⟩-I : ∀ {Γ T} → Γ ⊢ val ⟨A= T ⟩ ∶ ⟨A: T ⋯ T ⟩ ltinn : ∀ {Γ t u T U} → Γ ⊢ t ∶ T → Γ ‣ T ! ⊢ u ∶ U ↑ 0 → Γ ⊢ lt t inn u ∶ U <∶ : ∀ {Γ t S U} → Γ ⊢ t ∶ S → Γ ⊢ S <: U → Γ ⊢ t ∶ U data _⊢_<:_ : Env → Typ → Typ → Set where <:⊤ : ∀ {Γ T} → Γ ⊢ T <: ⊤ ⊥<: : ∀ {Γ T} → Γ ⊢ ⊥ <: T refl : ∀ {Γ T} → Γ ⊢ T <: T tran : ∀ {Γ S U} T → (S<:T : Γ ⊢ S <: T) → (T<:U : Γ ⊢ T <: U) → Γ ⊢ S <: U bnd : ∀ {Γ S U S′ U′} → (S′<:S : Γ ⊢ S′ <: S) → (U<:U′ : Γ ⊢ U <: U′) → Γ ⊢ ⟨A: S ⋯ U ⟩ <: ⟨A: S′ ⋯ U′ ⟩ Π<: : ∀ {Γ S U S′ U′} → (S′<:S : Γ ⊢ S′ <: S) → (U<:U′ : (S′ ∷ Γ) ⊢ U <: U′) → Γ ⊢ Π S ∙ U <: Π S′ ∙ U′ sel₁ : ∀ {Γ n S U} → Γ ⊢ var n ∶ ⟨A: S ⋯ U ⟩ → Γ ⊢ S <: n ∙A sel₂ : ∀ {Γ n S U} → Γ ⊢ var n ∶ ⟨A: S ⋯ U ⟩ → Γ ⊢ n ∙A <: U -- The following function shows that indeed the subtyping defined in Lemma 2 is -- equivalent to the original subtyping. mutual <:⇒<:′ : ∀ {Γ S U} → Γ ⊢ S <: U → Γ ⊢′ S <: U <:⇒<:′ <:⊤ = dtop <:⇒<:′ ⊥<: = dbot <:⇒<:′ refl = drefl <:⇒<:′ (tran T S<:T T<:U) = dtrans T (<:⇒<:′ S<:T) (<:⇒<:′ T<:U) <:⇒<:′ (bnd S′<:S U<:U′) = dbnd (<:⇒<:′ S′<:S) (<:⇒<:′ U<:U′) <:⇒<:′ (Π<: S′<:S U<:U′) = dall (<:⇒<:′ S′<:S) (<:⇒<:′ U<:U′) <:⇒<:′ (sel₁ n∶SU) with var∶⇒<: n∶SU ... | T′ , T′∈Γ , T′<:SU = dsel₁ T′∈Γ (dtrans _ T′<:SU (dbnd drefl dtop)) <:⇒<:′ (sel₂ n∶SU) with var∶⇒<: n∶SU ... | T′ , T′∈Γ , T′<:SU = dsel₂ T′∈Γ (dtrans _ T′<:SU (dbnd dbot drefl)) var∶⇒<: : ∀ {Γ x T} → Γ ⊢ var x ∶ T → ∃ λ T′ → env-lookup Γ x ≡ just T′ × Γ ⊢′ T′ <: T var∶⇒<: (var∶ T∈Γ) = -, T∈Γ , drefl var∶⇒<: (<∶ x∶T T<:U) with var∶⇒<: x∶T ... | T′ , T′∈Γ , T′<:T = T′ , T′∈Γ , dtrans _ T′<:T (<:⇒<:′ T<:U) <:′⇒<: : ∀ {Γ S U} → Γ ⊢′ S <: U → Γ ⊢ S <: U <:′⇒<: dtop = <:⊤ <:′⇒<: dbot = ⊥<: <:′⇒<: drefl = refl <:′⇒<: (dtrans T S<:T T<:U) = tran T (<:′⇒<: S<:T) (<:′⇒<: T<:U) <:′⇒<: (dbnd S′<:S U<:U′) = bnd (<:′⇒<: S′<:S) (<:′⇒<: U<:U′) <:′⇒<: (dall S′<:S U<:U′) = Π<: (<:′⇒<: S′<:S) (<:′⇒<: U<:U′) <:′⇒<: (dsel₁ T∈Γ T<:SU) = sel₁ (<∶ (var∶ T∈Γ) (<:′⇒<: T<:SU)) <:′⇒<: (dsel₂ T∈Γ T<:SU) = sel₂ (<∶ (var∶ T∈Γ) (<:′⇒<: T<:SU))
{ "alphanum_fraction": 0.3984261148, "avg_line_length": 32.3679245283, "ext": "agda", "hexsha": "f99af2e2833cf7d1e419e4f04d234571d1bdc7db", "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": "48214a55ebb484fd06307df4320813d4a002535b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "HuStmpHrrr/popl20-artifact", "max_forks_repo_path": "agda/DsubFull.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "48214a55ebb484fd06307df4320813d4a002535b", "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": "HuStmpHrrr/popl20-artifact", "max_issues_repo_path": "agda/DsubFull.agda", "max_line_length": 88, "max_stars_count": 1, "max_stars_repo_head_hexsha": "48214a55ebb484fd06307df4320813d4a002535b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "HuStmpHrrr/popl20-artifact", "max_stars_repo_path": "agda/DsubFull.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-23T08:40:28.000Z", "max_stars_repo_stars_event_min_datetime": "2021-09-23T08:40:28.000Z", "num_tokens": 1860, "size": 3431 }
module Numeric.Nat where open import Numeric.Nat.BinarySearch public open import Numeric.Nat.Divide.Properties public open import Numeric.Nat.Divide public open import Numeric.Nat.DivMod public open import Numeric.Nat.GCD.Extended public open import Numeric.Nat.GCD.Properties public open import Numeric.Nat.GCD public open import Numeric.Nat.LCM.Properties public open import Numeric.Nat.LCM public open import Numeric.Nat.Modulo public open import Numeric.Nat.Pow public open import Numeric.Nat.Prime.Properties public open import Numeric.Nat.Prime public open import Numeric.Nat.Properties public open import Numeric.Nat.Sqrt public
{ "alphanum_fraction": 0.7047244094, "avg_line_length": 40.1052631579, "ext": "agda", "hexsha": "be4d7de02ace244e53ab2f14190ca463f6c0533b", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "t-more/agda-prelude", "max_forks_repo_path": "src/Numeric/Nat.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "t-more/agda-prelude", "max_issues_repo_path": "src/Numeric/Nat.agda", "max_line_length": 48, "max_stars_count": 111, "max_stars_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "t-more/agda-prelude", "max_stars_repo_path": "src/Numeric/Nat.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 159, "size": 762 }
postulate A : Set data B : Set where x : A → B f : A → A f = {!!} -- C-c C-c yields 'f x = ?', which fails to type check
{ "alphanum_fraction": 0.515625, "avg_line_length": 12.8, "ext": "agda", "hexsha": "91d78e3bd6bc3baaa73cbf2f40378da3dd6d4864", "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/Issue3445.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/Issue3445.agda", "max_line_length": 63, "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/Issue3445.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": 49, "size": 128 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Data.Vec.Any.Membership instantiated with propositional equality, -- along with some additional definitions. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Vec.Membership.Propositional {a} {A : Set a} where open import Data.Vec using (Vec) open import Data.Vec.Relation.Unary.Any using (Any) open import Relation.Binary.PropositionalEquality using (setoid; subst) import Data.Vec.Membership.Setoid as SetoidMembership ------------------------------------------------------------------------ -- Re-export contents of setoid membership open SetoidMembership (setoid A) public hiding (lose) ------------------------------------------------------------------------ -- Other operations lose : ∀ {p} {P : A → Set p} {x n} {xs : Vec A n} → x ∈ xs → P x → Any P xs lose = SetoidMembership.lose (setoid A) (subst _)
{ "alphanum_fraction": 0.515060241, "avg_line_length": 35.5714285714, "ext": "agda", "hexsha": "ae706d4f9f03fe13f7f18a492b460dba37437ec9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/Membership/Propositional.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/Membership/Propositional.agda", "max_line_length": 75, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/Membership/Propositional.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 195, "size": 996 }
module hello where open import IO main = run (putStrLn "Hello, World!")
{ "alphanum_fraction": 0.7260273973, "avg_line_length": 14.6, "ext": "agda", "hexsha": "71bb0120f12ff40c6c90a131fc53ad95f0bb5f80", "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": "22b528084ed234fcabca89cf1ba02a2c347007bc", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nhutnamhcmus/code", "max_forks_repo_path": "Agda/hello.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "22b528084ed234fcabca89cf1ba02a2c347007bc", "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": "nhutnamhcmus/code", "max_issues_repo_path": "Agda/hello.agda", "max_line_length": 37, "max_stars_count": 1, "max_stars_repo_head_hexsha": "22b528084ed234fcabca89cf1ba02a2c347007bc", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nhutnamhcmus/code", "max_stars_repo_path": "Agda/hello.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T18:33:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-12T18:33:22.000Z", "num_tokens": 19, "size": 73 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT module stash.modalities.PushoutProduct {i j k l} {A : Type i} {B : Type j} {A' : Type k} {B' : Type l} where □-span : (f : A → B) (g : A' → B') → Span □-span f g = span (B × A') (A × B') (A × A') (λ { (a , a') → f a , a'}) (λ { (a , a') → a , g a' }) module PshoutProd (f : A → B) (g : A' → B') = PushoutRec {d = □-span f g} (λ { (b , a') → b , g a' }) (λ { (a , b') → f a , b' }) (λ { (a , a') → idp }) _□_ : (f : A → B) (g : A' → B') → Pushout (□-span f g) → B × B' f □ g = PshoutProd.f f g □-glue-β : (f : A → B) (g : A' → B') (a : A) (a' : A') → ap (f □ g) (glue (a , a')) == idp □-glue-β f g a a' = PshoutProd.glue-β f g (a , a') module _ (f : A → B) (g : A' → B') where private abstract ↓-□=cst-out : ∀ {a a' b b'} {p p' : (f a , g a') == (b , b')} → p == p' [ (λ w → (f □ g) w == (b , b')) ↓ glue (a , a') ] → p == p' ↓-□=cst-out {p' = idp} q = ↓-app=cst-out' q ∙ □-glue-β f g _ _ ↓-□=cst-in : ∀ {a a' b b'} {p p' : (f a , g a') == (b , b')} → p == p' → p == p' [ (λ w → (f □ g) w == (b , b')) ↓ glue (a , a') ] ↓-□=cst-in {p' = idp} q = ↓-app=cst-in' (q ∙ ! (□-glue-β f g _ _)) ↓-□=cst-β : ∀ {a a' b b'} {p p' : (f a , g a') == (b , b')} (q : p == p') → ↓-□=cst-out (↓-□=cst-in q) == q ↓-□=cst-β {a} {a'} {p' = idp} idp = {!!} ∙ !-inv-l (□-glue-β f g a a') □-hfiber-to : (b : B) (b' : B') → hfiber (f □ g) (b , b') → hfiber f b * hfiber g b' □-hfiber-to b b' = uncurry $ Pushout-elim (λ { (_ , a') → λ p → right (a' , snd×= p) }) (λ { (a , _) → λ p → left (a , fst×= p) }) {!!} -- -- Here is the main theorem -- □-hfiber : (b : B) (b' : B') → hfiber (f □ g) (b , b') ≃ hfiber f b * hfiber g b' □-hfiber b b' = {!!}
{ "alphanum_fraction": 0.3656030287, "avg_line_length": 29.8225806452, "ext": "agda", "hexsha": "298bf8bb9386e6c32b50edfa4f53c4bed2cea165", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/stash/modalities/PushoutProduct.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/stash/modalities/PushoutProduct.agda", "max_line_length": 90, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/stash/modalities/PushoutProduct.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 901, "size": 1849 }
module DivMod where open import IO open import Data.Nat open import Data.Nat.DivMod open import Coinduction open import Data.String open import Data.Fin g : ℕ g = 7 div 5 k : ℕ k = toℕ (7 mod 5) showNat : ℕ → String showNat zero = "Z" showNat (suc x) = "S (" ++ showNat x ++ ")" main = run (♯ (putStrLn (showNat g)) >> ♯ (putStrLn (showNat k)))
{ "alphanum_fraction": 0.66, "avg_line_length": 16.6666666667, "ext": "agda", "hexsha": "30693668f6ff0ac8a22ff5df17643f35f3d862b0", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "56928ff709dcb931cb9a48c4790e5ed3739e3032", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "andersk/agda", "max_forks_repo_path": "test/Compiler/with-stdlib/DivMod.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "56928ff709dcb931cb9a48c4790e5ed3739e3032", "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": "andersk/agda", "max_issues_repo_path": "test/Compiler/with-stdlib/DivMod.agda", "max_line_length": 65, "max_stars_count": 3, "max_stars_repo_head_hexsha": "04941fb75be06039b0085ab047117625294cbc99", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "andreasabel/agda-with-old-branches", "max_stars_repo_path": "test/Compiler/with-stdlib/DivMod.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": 124, "size": 350 }
{-# OPTIONS --prop #-} True : Prop True = {P : Prop} → P → P -- Current error (incomprehensible): -- Set₁ != Set -- when checking that the expression {P : Prop} → P → P has type Prop
{ "alphanum_fraction": 0.6054054054, "avg_line_length": 20.5555555556, "ext": "agda", "hexsha": "f56cf3e5610875fe2c29b5b107d528074a87a533", "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/Fail/Prop-NoImpredicativity.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/Fail/Prop-NoImpredicativity.agda", "max_line_length": 69, "max_stars_count": null, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Fail/Prop-NoImpredicativity.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 55, "size": 185 }
module README where ------------------------------------------------------------------------ -- The Agda standard library, version 0.9 -- -- Author: Nils Anders Danielsson, with contributions from Andreas -- Abel, Stevan Andjelkovic, Jean-Philippe Bernardy, Peter Berry, -- Joachim Breitner, Samuel Bronson, Daniel Brown, James Chapman, -- Liang-Ting Chen, Dominique Devriese, Dan Doel, Érdi Gergő, Helmut -- Grohne, Simon Foster, Liyang Hu, Patrik Jansson, Alan Jeffrey, -- Pepijn Kokke, Evgeny Kotelnikov, Eric Mertens, Darin Morrison, -- Guilhem Moulin, Shin-Cheng Mu, Ulf Norell, Noriyuki OHKAWA, Nicolas -- Pouillard, Andrés Sicard-Ramírez and Noam Zeilberger. ------------------------------------------------------------------------ -- This version of the library has been tested using Agda 2.4.2.1. -- Note that no guarantees are currently made about forwards or -- backwards compatibility, the library is still at an experimental -- stage. -- To make use of the library, add the path to the library’s root -- directory (src) to the Agda search path, either using the -- --include-path flag or by customising the Emacs mode variable -- agda2-include-dirs (M-x customize-group RET agda2 RET). -- To compile the library using the MAlonzo compiler you first need to -- install some supporting Haskell code, for instance as follows: -- -- cd ffi -- cabal install -- -- Currently the library does not support the Epic or JavaScript -- compiler backends. -- Contributions to this library are welcome (but to avoid wasted work -- it is suggested that you discuss large changes before implementing -- them). Please send contributions in the form of git pull requests, -- patch bundles or ask for commmit rights to the repository. It is -- appreciated if every patch contains a single, complete change, and -- if the coding style used in the library is adhered to. ------------------------------------------------------------------------ -- Module hierarchy ------------------------------------------------------------------------ -- The top-level module names of the library are currently allocated -- as follows: -- -- • Algebra -- Abstract algebra (monoids, groups, rings etc.), along with -- properties needed to specify these structures (associativity, -- commutativity, etc.), and operations on and proofs about the -- structures. -- • Category -- Category theory-inspired idioms used to structure functional -- programs (functors and monads, for instance). -- • Coinduction -- Support for coinduction. -- • Data -- Data types and properties about data types. -- • Function -- Combinators and properties related to functions. -- • Foreign -- Related to the foreign function interface. -- • Induction -- A general framework for induction (includes lexicographic and -- well-founded induction). -- • IO -- Input/output-related functions. -- • Irrelevance -- Definitions related to (proscriptive) irrelevance. -- • Level -- Universe levels. -- • Record -- An encoding of record types with manifest fields and "with". -- • Reflection -- Support for reflection. -- • Relation -- Properties of and proofs about relations (mostly homogeneous -- binary relations). -- • Size -- Sizes used by the sized types mechanism. -- • Universe -- A definition of universes. ------------------------------------------------------------------------ -- A selection of useful library modules ------------------------------------------------------------------------ -- Note that module names in source code are often hyperlinked to the -- corresponding module. In the Emacs mode you can follow these -- hyperlinks by typing M-. or clicking with the middle mouse button. -- • Some data types import Data.Bool -- Booleans. import Data.Char -- Characters. import Data.Empty -- The empty type. import Data.Fin -- Finite sets. import Data.List -- Lists. import Data.Maybe -- The maybe type. import Data.Nat -- Natural numbers. import Data.Product -- Products. import Data.Stream -- Streams. import Data.String -- Strings. import Data.Sum -- Disjoint sums. import Data.Unit -- The unit type. import Data.Vec -- Fixed-length vectors. -- • Some types used to structure computations import Category.Functor -- Functors. import Category.Applicative -- Applicative functors. import Category.Monad -- Monads. -- • Equality -- Propositional equality: import Relation.Binary.PropositionalEquality -- Convenient syntax for "equational reasoning" using a preorder: import Relation.Binary.PreorderReasoning -- Solver for commutative ring or semiring equalities: import Algebra.RingSolver -- • Properties of functions, sets and relations -- Monoids, rings and similar algebraic structures: import Algebra -- Negation, decidability, and similar operations on sets: import Relation.Nullary -- Properties of homogeneous binary relations: import Relation.Binary -- • Induction -- An abstraction of various forms of recursion/induction: import Induction -- Well-founded induction: import Induction.WellFounded -- Various forms of induction for natural numbers: import Induction.Nat -- • Support for coinduction import Coinduction -- • IO import IO ------------------------------------------------------------------------ -- Record hierarchies ------------------------------------------------------------------------ -- When an abstract hierarchy of some sort (for instance semigroup → -- monoid → group) is included in the library the basic approach is to -- specify the properties of every concept in terms of a record -- containing just properties, parameterised on the underlying -- operations, sets etc.: -- -- record IsSemigroup {A} (≈ : Rel A) (∙ : Op₂ A) : Set where -- open FunctionProperties ≈ -- field -- isEquivalence : IsEquivalence ≈ -- assoc : Associative ∙ -- ∙-cong : ∙ Preserves₂ ≈ ⟶ ≈ ⟶ ≈ -- -- More specific concepts are then specified in terms of the simpler -- ones: -- -- record IsMonoid {A} (≈ : Rel A) (∙ : Op₂ A) (ε : A) : Set where -- open FunctionProperties ≈ -- field -- isSemigroup : IsSemigroup ≈ ∙ -- identity : Identity ε ∙ -- -- open IsSemigroup isSemigroup public -- -- Note here that open IsSemigroup isSemigroup public ensures that the -- fields of the isSemigroup record can be accessed directly; this -- technique enables the user of an IsMonoid record to use underlying -- records without having to manually open an entire record hierarchy. -- This is not always possible, though. Consider the following definition -- of preorders: -- -- record IsPreorder {A : Set} -- (_≈_ : Rel A) -- The underlying equality. -- (_∼_ : Rel A) -- The relation. -- : Set where -- field -- isEquivalence : IsEquivalence _≈_ -- -- Reflexivity is expressed in terms of an underlying equality: -- reflexive : _≈_ ⇒ _∼_ -- trans : Transitive _∼_ -- -- module Eq = IsEquivalence isEquivalence -- -- ... -- -- The Eq module in IsPreorder is not opened publicly, because it -- contains some fields which clash with fields or other definitions -- in IsPreorder. -- Records packing up properties with the corresponding operations, -- sets, etc. are sometimes also defined: -- -- record Semigroup : Set₁ where -- infixl 7 _∙_ -- infix 4 _≈_ -- field -- Carrier : Set -- _≈_ : Rel Carrier -- _∙_ : Op₂ Carrier -- isSemigroup : IsSemigroup _≈_ _∙_ -- -- open IsSemigroup isSemigroup public -- -- setoid : Setoid -- setoid = record { isEquivalence = isEquivalence } -- -- record Monoid : Set₁ where -- infixl 7 _∙_ -- infix 4 _≈_ -- field -- Carrier : Set -- _≈_ : Rel Carrier -- _∙_ : Op₂ Carrier -- ε : Carrier -- isMonoid : IsMonoid _≈_ _∙_ ε -- -- open IsMonoid isMonoid public -- -- semigroup : Semigroup -- semigroup = record { isSemigroup = isSemigroup } -- -- open Semigroup semigroup public using (setoid) -- -- Note that the Monoid record does not include a Semigroup field. -- Instead the Monoid /module/ includes a "repackaging function" -- semigroup which converts a Monoid to a Semigroup. -- The above setup may seem a bit complicated, but we think it makes the -- library quite easy to work with, while also providing enough -- flexibility. ------------------------------------------------------------------------ -- More documentation ------------------------------------------------------------------------ -- Some examples showing where the natural numbers/integers and some -- related operations and properties are defined, and how they can be -- used: import README.Nat import README.Integer -- Some examples showing how the AVL tree module can be used. import README.AVL -- An example showing how the Record module can be used. import README.Record -- An example showing how the case expression can be used. import README.Case ------------------------------------------------------------------------ -- Core modules ------------------------------------------------------------------------ -- Some modules have names ending in ".Core". These modules are -- internal, and have (mostly) been created to avoid mutual recursion -- between modules. They should not be imported directly; their -- contents are reexported by other modules. ------------------------------------------------------------------------ -- All library modules ------------------------------------------------------------------------ -- For short descriptions of every library module, see Everything: import Everything -- Note that the Everything module is generated automatically. If you -- have downloaded the library from its Git repository and want to -- type check README then you can (try to) construct Everything by -- running "cabal install && GenerateEverything". -- Note that all library sources are located under src or ffi. The -- modules README, README.* and Everything are not really part of the -- library, so these modules are located in the top-level directory -- instead.
{ "alphanum_fraction": 0.6302994944, "avg_line_length": 34.0529801325, "ext": "agda", "hexsha": "400220cd1e40fb9157e24120ffb12b40b22baecc", "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/README.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/README.agda", "max_line_length": 73, "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/README.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": 2267, "size": 10284 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Example use case for a fresh list: sorted list ------------------------------------------------------------------------ module README.Data.List.Fresh where open import Data.Nat open import Data.List.Base open import Data.List.Fresh open import Data.List.Relation.Unary.AllPairs as AllPairs using (AllPairs) open import Data.Product open import Relation.Nary using (⌊_⌋; fromWitness) -- A sorted list of natural numbers can be seen as a fresh list -- where the notion of freshness is being smaller than all the -- existing entries SortedList : Set SortedList = List# ℕ _<_ _ : SortedList _ = cons 0 (cons 1 (cons 3 (cons 10 [] _) (s≤s (s≤s (s≤s (s≤s z≤n))) , _)) (s≤s (s≤s z≤n) , s≤s (s≤s z≤n) , _)) (s≤s z≤n , s≤s z≤n , s≤s z≤n , _) -- Clearly, writing these by hand can pretty quickly become quite cumbersome -- Luckily, if the notion of freshness we are using is decidable, we can -- make most of the proofs inferrable by using the erasure of the relation -- rather than the relation itself! -- We call this new type *I*SortedList because all the proofs will be implicit. ISortedList : Set ISortedList = List# ℕ ⌊ _<?_ ⌋ -- The same example is now much shorter. It looks pretty much like a normal list -- except that we know for sure that it is well ordered. ins : ISortedList ins = 0 ∷# 1 ∷# 3 ∷# 10 ∷# [] -- Indeed we can extract the support list together with a proof that it -- is ordered thanks to the combined action of toList converting a fresh -- list to a pair of a list and a proof and fromWitness which "unerases" -- a proof. ns : List ℕ ns = proj₁ (toList ins) sorted : AllPairs _<_ ns sorted = AllPairs.map (fromWitness _<_ _<?_) (proj₂ (toList ins)) -- See the following module for an applied use-case of fresh lists open import README.Data.Trie.NonDependent
{ "alphanum_fraction": 0.6563968668, "avg_line_length": 33.0172413793, "ext": "agda", "hexsha": "ef569440613f6381ea4596e06a29021a541ed4f8", "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/README/Data/List/Fresh.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/README/Data/List/Fresh.agda", "max_line_length": 80, "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/README/Data/List/Fresh.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": 534, "size": 1915 }
module IID-Proof where import Logic.ChainReasoning as Chain open import LF open import Identity open import IID open import IIDr open import IID-Proof-Setup open import DefinitionalEquality Ug : {I : Set} -> OPg I -> I -> Set Ug γ i = Ur (ε γ) i introg : {I : Set}(γ : OPg I)(a : Args γ (Ug γ)) -> Ug γ (index γ (Ug γ) a) introg γ a = intror (g→rArgs γ (Ug γ) a) -- The elimination rule. elim-Ug : {I : Set}(γ : OPg I)(C : (i : I) -> Ug γ i -> Set) -> ((a : Args γ (Ug γ)) -> IndHyp γ (Ug γ) C a -> C (index γ (Ug γ) a) (introg γ a)) -> (i : I)(u : Ug γ i) -> C i u elim-Ug {I} γ C m = elim-Ur (ε γ) C step -- eliminate the restricted type where U = Ug γ -- we've got a method to take care of inductive occurrences for general families (m), -- but we need something to handle the restricted encoding. step : (i : I)(a : rArgs (ε γ) U i) -> IndHyp (ε γ i) U C a -> C i (intror a) step i a h = conclusion where -- First convert the argument to a general argument a' : Args γ U a' = r→gArgs γ U i a -- Next convert our induction hypothesis to an hypothesis for a general family h' : IndHyp γ U C a' h' = r→gIndHyp γ U C i a h -- Our method m can be applied to the converted argument and induction -- hypothesis. This gets us almost all the way. lem₁ : C (index γ U a') (intror (g→rArgs γ U a')) lem₁ = m a' h' -- Now we just have to use the fact that the computed index is the same -- as our input index, and that g→rArgs ∘ r→gArgs is the identity. -- r←→gArgs-subst will perform the elimination of the identity proof. conclusion : C i (intror a) conclusion = r←→gArgs-subst γ U (\i a -> C i (intror a)) i a lem₁ open module Chain-≡ = Chain.Poly.Heterogenous _≡_ (\x -> refl-≡) trans-≡ -- What remains is to prove that the reduction behaviour of the elimination -- rule is the correct one. I.e that -- elim-Ug C m (index a) (introg a) ≡ m a (induction C (elim-Ug C m) a) elim-Ug-reduction : {I : Set}(γ : OPg I)(C : (i : I) -> Ug γ i -> Set) (m : (a : Args γ (Ug γ)) -> IndHyp γ (Ug γ) C a -> C (index γ (Ug γ) a) (introg γ a)) (a : Args γ (Ug γ)) -> elim-Ug γ C m (index γ (Ug γ) a) (introg γ a) ≡ m a (induction γ (Ug γ) C (elim-Ug γ C m) a) elim-Ug-reduction γ C m a = chain> elim-Ug γ C m (index γ (Ug γ) a) (introg γ a) -- Unfolding the definition of elim-Ug we get === r←→gArgs-subst γ U C' i ra (m gra (r→gih \hyp -> elim-Ug γ C m (r-ind-index hyp) (r-ind-value hyp))) by refl-≡ -- Now (and this is the key step), since we started with a value in the -- generalised type we know that the identity proof is refl, so -- r←→gArgs-subst is the identity. === m gra (r→gih \hyp -> elim-Ug γ C m (r-ind-index hyp) (r-ind-value hyp)) by r←→gArgs-subst-identity γ U C' a _ -- We use congruence to prove separately that gra ≡ a and that the computed -- induction hypothesis is the one we need. === m a (\hyp -> elim-Ug γ C m (g-ind-index hyp) (g-ind-value hyp)) by cong₂-≡' m (g←→rArgs-identity γ U a) -- The induction hypotheses match (η-≡ \hyp₀ hyp₁ hyp₀=hyp₁ -> chain> r→gih (\hyp -> elim-Ug γ C m (r-ind-index hyp) (r-ind-value hyp)) hyp₀ -- Unfolding the definition of r→gih we get === g→rIndArg-subst γ U C i ra hyp₀ (elim-Ug γ C m (r-ind-index (g→rIndArg γ U i ra hyp₀)) (r-ind-value (g→rIndArg γ U i ra hyp₀)) ) by refl-≡ -- g→rIndArg-subst is definitionally the identity. === elim-Ug γ C m (r-ind-index (g→rIndArg γ U i ra hyp₀)) (r-ind-value (g→rIndArg γ U i ra hyp₀)) by g→rIndArg-subst-identity γ U C i ra hyp₀ _ -- We can turn the restricted inductive occurrence into a -- generalised occurrence. === elim-Ug γ C m (IndIndex γ U gra hyp₀) (Ind γ U gra hyp₀) by g→rIndArg-subst γ U (\j b -> elim-Ug γ C m (r-ind-index (g→rIndArg γ U i ra hyp₀)) (r-ind-value (g→rIndArg γ U i ra hyp₀)) ≡ elim-Ug γ C m j b ) i ra hyp₀ refl-≡ -- Finally we have gra ≡ a and hyp₀ ≡ hyp₁ so we're done. === elim-Ug γ C m (IndIndex γ U a hyp₁) (Ind γ U a hyp₁) by cong₂-≡' (\a hyp -> elim-Ug γ C m (IndIndex γ U a hyp) (Ind γ U a hyp) ) (g←→rArgs-identity γ U a) hyp₀=hyp₁ ) -- Writing it in a nicer way: === m a (induction γ (Ug γ) C (elim-Ug γ C m) a) by refl-≡ where U = Ug γ i = index γ U a ra = g→rArgs γ U a gra = r→gArgs γ U i ra r→gih = r→gIndHyp γ U C i ra r-ind-index = IndIndex (ε γ i) (Ur (ε γ)) ra r-ind-value = Ind (ε γ i) (Ur (ε γ)) ra g-ind-index = IndIndex γ U a g-ind-value = Ind γ U a C' = \i a -> C i (intror a)
{ "alphanum_fraction": 0.5387153115, "avg_line_length": 37.6131386861, "ext": "agda", "hexsha": "a3fbb6687c87a199d942d927736c299f7a03d15a", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/iird/IID-Proof.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/iird/IID-Proof.agda", "max_line_length": 94, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "examples/outdated-and-incorrect/iird/IID-Proof.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": 1703, "size": 5153 }
module CTL.Proof.AG where open import CTL.Modalities.AG open import FStream.Core open import FStream.FVec open import Library -- TODO Maybe beautify syntax here and elsewhere data proofAG' {ℓ₁ ℓ₂} {C : Container ℓ₁} : {n : ℕ} → (props : FVec' C (Set ℓ₂) n) → Set (ℓ₁ ⊔ ℓ₂) where []AG' : proofAG' FNil' _▻AG'_ : ∀ {prop : Set ℓ₂} {n} {props : ⟦ C ⟧ (FVec' C (Set ℓ₂) n)} → prop → A (fmap proofAG' props) → proofAG' (FCons' prop props) _pre⟨_▻AG' : ∀ {i ℓ₁ ℓ₂} {C : Container ℓ₁} {m n} {props : FVec' C (Set ℓ₂) m} {props' : FVec' C (Set ℓ₂) (suc n)} → proofAG' props → proofAG' props' → AG' {i} (props pre⟨ props' ▻⋯') nowA ([]AG' pre⟨ (proof ▻AG' _) ▻AG') = proof laterA ([]AG' pre⟨ (proof ▻AG' proofs) ▻AG') p = (proofs p) pre⟨ (proof ▻AG' proofs) ▻AG' nowA ((proof ▻AG' _) pre⟨ _ ▻AG') = proof laterA ((_ ▻AG' proofs) pre⟨ proofs' ▻AG') p = (proofs p) pre⟨ proofs' ▻AG' ⟨_▻AG' : ∀ {i} {ℓ₁ ℓ₂} {C : Container ℓ₁} {n} {props : FVec' C (Set ℓ₂) (suc n)} → proofAG' props → AG' {i} (FNil' pre⟨ props ▻⋯') ⟨ proofs ▻AG' = []AG' pre⟨ proofs ▻AG' data proofAG {ℓ₁ ℓ₂} {C : Container ℓ₁} : {n : ℕ} → (props : FVec C (Set ℓ₂) n) → Set (ℓ₁ ⊔ ℓ₂) where []AG : proofAG FNil ConsAG : ∀ {n} {props : ⟦ C ⟧ (Set ℓ₂ × FVec C (Set ℓ₂) n)} → A (fmap (λ x → (proj₁ x) × (proofAG (proj₂ x))) props) → proofAG (FCons props) -- TODO This constructor type signature is an abomination and should be somehow rewritten with proofAG, but how?? -- TODO props should be of type FVec C (Set ℓ₂) (suc n) maybe? Or is it easier this way? mapAGlemma : ∀ {i} {ℓ₁ ℓ₂ ℓ₃} {C : Container ℓ₁} {A : Set ℓ₂} {f : A → Set ℓ₃} {m n} → (v : FVec C A m) → (v' : FVec C A (suc n)) → AG {i} ((vmap f v pre⟨ vmap f v' ▻⋯)) → AG {i} (map f (v pre⟨ v' ▻⋯)) nowA (mapAGlemma FNil (FCons x) proofs p) = nowA (proofs p) -- TODO Why can't I join this with the next line? nowA (mapAGlemma (FCons x) v proofs p) = nowA (proofs p) laterA (mapAGlemma FNil (FCons (shape , vals)) proofs p) p₁ = mapAGlemma (proj₂ (vals p)) (FCons (shape , vals)) (laterA (proofs p)) p₁ laterA (mapAGlemma (FCons (shape , vals)) v' proofs p) p₁ = mapAGlemma (proj₂ (vals p)) v' (laterA (proofs p)) p₁ mapAG : ∀ {i} {ℓ₁ ℓ₂ ℓ₃} {C : Container ℓ₁} {A : Set ℓ₂} {f : A → Set ℓ₃} {m n} → {v : FVec C A m} → {v' : FVec C A (suc n)} → AG {i} ((vmap f v pre⟨ vmap f v' ▻⋯)) → AG {i} (map f (v pre⟨ v' ▻⋯)) mapAG {v = v} {v' = v'} = mapAGlemma v v' _pre⟨_▻AG : ∀ {i} {ℓ₁ ℓ₂} {C : Container ℓ₁} {m n} {props : FVec C (Set ℓ₂) m} {props' : FVec C (Set ℓ₂) (suc n)} → proofAG props → proofAG props' → AG {i} (props pre⟨ props' ▻⋯) nowA ( ([]AG pre⟨ (ConsAG proofs) ▻AG) p) = proj₁ (proofs p) laterA ( ([]AG pre⟨ (ConsAG proofs) ▻AG) p) p₁ = (proj₂ (proofs p) pre⟨ ConsAG proofs ▻AG) p₁ nowA ( ((ConsAG proofs) pre⟨ _ ▻AG) p) = proj₁ (proofs p) laterA ( ((ConsAG proofs) pre⟨ proofs' ▻AG) p) p₁ = (proj₂ (proofs p) pre⟨ proofs' ▻AG) p₁ -- The p are the inputs (positions) from the side effects. mapPreCycle : ∀ {i} {ℓ₁ ℓ₂ ℓ₃} {C : Container ℓ₁} {A : Set ℓ₂} {f : A → Set ℓ₃} {m n} → (v : FVec C A m) → (v' : FVec C A (suc n)) → proofAG (vmap f v) → proofAG (vmap f v') → AG {i} (map f (v pre⟨ v' ▻⋯)) nowA (mapPreCycle FNil (FCons x) []AG (ConsAG proofs) p) with proofs p ... | proof , proofs' = proof laterA (mapPreCycle FNil (FCons (shape , vals)) []AG (ConsAG proofs) p) p' with proofs p ... | proof , proofs' with vals p ... | a , v = mapPreCycle v (FCons (shape , vals)) proofs' (ConsAG proofs) p' nowA (mapPreCycle (FCons x) v' (ConsAG proofs) proofs' p) = proj₁ (proofs p) laterA (mapPreCycle (FCons (shape , vals)) (FCons x) (ConsAG proofs) proofs' p) p₁ with proofs p ... | proof , proofs'' with vals p ... | a , v = mapPreCycle v (FCons x) proofs'' proofs' p₁ infixr 5 _▻AG_ infix 6 ⟨_▻AG infix 7 _⟩AG ⟨_▻AG : ∀ {i} {ℓ₁ ℓ₂} {C : Container ℓ₁} {n} → {props : FVec C (Set ℓ₂) (suc n)} → proofAG props → AG {i} (FNil pre⟨ props ▻⋯) ⟨_▻AG = []AG pre⟨_▻AG _⟩AG : ∀ {ℓ₁ ℓ₂} {C : Container ℓ₁} {prop : ⟦ C ⟧ (Set ℓ₂)} → A prop → proofAG (FCons (fmap (_, FNil) prop)) x ⟩AG = ConsAG (λ p → x p , []AG) _▻AG_ : ∀ {ℓ₁ ℓ₂} {C : Container ℓ₁} {prop : ⟦ C ⟧ (Set ℓ₂)} {n} {props : FVec C (Set ℓ₂) n} → A prop → proofAG props → proofAG (FCons (fmap (_, props) prop)) x ▻AG v = ConsAG (λ p → (x p) , v)
{ "alphanum_fraction": 0.5387437945, "avg_line_length": 37.9754098361, "ext": "agda", "hexsha": "a4f211dd8cb2a03ae9200d36aba58163dd0150ce", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-12-13T15:56:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-12-13T15:56:38.000Z", "max_forks_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "zimbatm/condatis", "max_forks_repo_path": "CTL/Proof/AG.agda", "max_issues_count": 5, "max_issues_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_issues_repo_issues_event_max_datetime": "2020-09-01T16:52:07.000Z", "max_issues_repo_issues_event_min_datetime": "2017-06-03T20:02:22.000Z", "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "zimbatm/condatis", "max_issues_repo_path": "CTL/Proof/AG.agda", "max_line_length": 115, "max_stars_count": 1, "max_stars_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "Aerate/condatis", "max_stars_repo_path": "CTL/Proof/AG.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-13T16:52:28.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-13T16:52:28.000Z", "num_tokens": 1983, "size": 4633 }
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module LogicalFramework.Equality where module LF where postulate D : Set _≡_ : D → D → Set refl : ∀ {x} → x ≡ x subst : (A : D → Set) → ∀ {x y} → x ≡ y → A x → A y sym : ∀ {x y} → x ≡ y → y ≡ x sym {x} h = subst (λ t → t ≡ x) h refl trans : ∀ {x y z} → x ≡ y → y ≡ z → x ≡ z trans {x} h₁ h₂ = subst (_≡_ x) h₂ h₁ module Inductive where open import Common.FOL.FOL-Eq open import Common.FOL.Relation.Binary.EqReasoning sym-er : ∀ {x y} → x ≡ y → y ≡ x sym-er {x} h = subst (λ t → t ≡ x) h refl trans-er : ∀ {x y z} → x ≡ y → y ≡ z → x ≡ z trans-er {x} h₁ h₂ = subst (_≡_ x) h₂ h₁ -- NB. The proofs of sym and trans by pattern matching are in the -- module Common.FOL.Relation.Binary.PropositionalEquality.
{ "alphanum_fraction": 0.5310492505, "avg_line_length": 27.4705882353, "ext": "agda", "hexsha": "f896e4ada0c89f08d4e34c498c6359afe26f6e98", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/thesis/report/LogicalFramework/Equality.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/thesis/report/LogicalFramework/Equality.agda", "max_line_length": 67, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/thesis/report/LogicalFramework/Equality.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": 349, "size": 934 }
------------------------------------------------------------------------------ -- Properties for the relation LTC ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.List.WF-Relation.LT-Cons.PropertiesI where open import FOTC.Base open import FOTC.Data.Nat.Inequalities open import FOTC.Data.List open import FOTC.Data.List.PropertiesI open import FOTC.Data.List.WF-Relation.LT-Cons open import FOTC.Data.List.WF-Relation.LT-Length ------------------------------------------------------------------------------ -- LTC ⊆ LTL. LTC→LTL : ∀ {xs ys} → List xs → LTC xs ys → LTL xs ys LTC→LTL Lxs (x , refl) = lg-x<lg-x∷xs x Lxs
{ "alphanum_fraction": 0.478054567, "avg_line_length": 36.652173913, "ext": "agda", "hexsha": "8219f63584a8b80d76ee3f27bd46b5d936d63360", "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/WF-Relation/LT-Cons/PropertiesI.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Data/List/WF-Relation/LT-Cons/PropertiesI.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Data/List/WF-Relation/LT-Cons/PropertiesI.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 187, "size": 843 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use -- Data.List.Relation.Binary.Subset.Setoid.Properties directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Relation.Subset.Setoid.Properties where open import Data.List.Relation.Binary.Subset.Setoid.Properties public {-# WARNING_ON_IMPORT "Data.List.Relation.Subset.Setoid.Properties was deprecated in v1.0. Use Data.List.Relation.Binary.Subset.Setoid.Properties instead." #-}
{ "alphanum_fraction": 0.5911330049, "avg_line_length": 33.8333333333, "ext": "agda", "hexsha": "d0ef874b65a37ec73bb7395508fbed4762b9c004", "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/Subset/Setoid/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/List/Relation/Subset/Setoid/Properties.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/Subset/Setoid/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 108, "size": 609 }
module _ where module M₁ (_ : Set) where postulate A : Set record R : Set₁ where field A : Set module M₂ (r : R) where open M₁ (R.A r) public module Unused (A : Set) (_ : Set) where open M₁ A public postulate r : R open M₂ r postulate P : A → Set data D : Set where c : D F : D → Set F c = A _ : ∀ x → F x → Set _ = λ _ r → P r
{ "alphanum_fraction": 0.5592286501, "avg_line_length": 10.0833333333, "ext": "agda", "hexsha": "c7b55ecd6bacf1fb6d27a0ad1291b4dc1337b30c", "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/Fail/Issue5294.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/Fail/Issue5294.agda", "max_line_length": 39, "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/Fail/Issue5294.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": 142, "size": 363 }
{-# OPTIONS --without-K #-} module PropsAsTypes where data Σ {I : Set} (X : I → Set) : Set where _,_ : (i : I) → X i → Σ X drec-Σ : {I : Set} {X : I → Set} {A : Σ X → Set} → ((i : I) → (x : X i) → A (i , x)) → (u : Σ X) → A u drec-Σ f (i , x) = f i x π₁ : {I : Set} {X : I → Set} → Σ X → I π₁ = drec-Σ (λ i x → i) π₂ : {I : Set} {X : I → Set} → (u : Σ X) → X (π₁ u) π₂ = drec-Σ (λ i x → x) _×_ : Set → Set → Set A × B = Σ {A} λ _ → B Prop = Set Pred : Set → Set₁ Pred A = A → Prop Rel : Set → Set₁ Rel A = A → A → Prop _⊆_ : {A : Set} → Pred A → Pred A → Prop P ⊆ Q = ∀ x → P x → Q x _⊑_ : {A : Set} → Rel A → Rel A → Prop R ⊑ S = ∀ {x y} → R x y → S x y _∧_ : Prop → Prop → Prop A ∧ B = A × B ∧-elim₁ : {A₁ A₂ : Prop} → A₁ ∧ A₂ → A₁ ∧-elim₁ = π₁ ∧-elim₂ : {A₁ A₂ : Prop} → A₁ ∧ A₂ → A₂ ∧-elim₂ = π₂ ∧-intro : {A₁ A₂ : Prop} → A₁ → A₂ → A₁ ∧ A₂ ∧-intro a₁ a₂ = (a₁ , a₂) ∃ : {X : Set} → (A : X → Prop) → Prop ∃ = Σ ∃-syntax : ∀ X → (X → Prop) → Prop ∃-syntax X A = ∃ A syntax ∃-syntax X (λ x → A) = ∃[ x ∈ X ] A ∃-intro : {X : Set} {A : X → Prop} → (x : X) → A x → ∃[ x ∈ X ] (A x) ∃-intro x a = (x , a) ∃-elim : {X : Set} {A : X → Prop} {B : Prop} → ((x : X) → A x → B) → ∃[ x ∈ X ] (A x) → B ∃-elim = drec-Σ ∃₂-elim : {X Y : Set} {A : X → Prop} {B : Y → Prop} {C : Prop} → ((x : X) (y : Y) → A x → B y → C) → ∃[ x ∈ X ] (A x) → ∃[ x ∈ Y ] (B x) → C ∃₂-elim f p q = ∃-elim (λ x p' → ∃-elim (λ y q' → f x y p' q') q) p infix 3 _⇔_ _⇔_ : Prop → Prop → Prop A ⇔ B = (A → B) ∧ (B → A) equivalence : {A B : Prop} → (A → B) → (B → A) → A ⇔ B equivalence = ∧-intro data ⊥ : Prop where absurd : ⊥ → ⊥ ⊥-elim : {A : Prop} → ⊥ → A ⊥-elim (absurd p) = ⊥-elim p ¬ : Prop → Prop ¬ A = A → ⊥ data ⊤ : Prop where ∗ : ⊤ open import Data.Nat open import Relation.Binary.PropositionalEquality as PE IsSuc : ℕ → Set IsSuc zero = ⊥ IsSuc (suc _) = ⊤ zero-not-suc : ∀ n → ¬ (suc n ≡ 0) zero-not-suc n p = subst IsSuc p ∗ -- Easier in Agda with absurd elimination -- suc-injective : ∀ n → ¬ (suc n ≡ n) -- suc-injective n () drec-≡ : {X : Set} → {C : (x y : X) → x ≡ y → Set} → ((x : X) → C x x refl) → ∀ x y → (p : x ≡ y) → C x y p drec-≡ f x .x refl = f x
{ "alphanum_fraction": 0.4320603908, "avg_line_length": 21.2452830189, "ext": "agda", "hexsha": "398b9c03e763fb5106959d89355d8d2e9ea0b5ad", "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": "TypeTheory/Lecture/PropsAsTypes.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": "TypeTheory/Lecture/PropsAsTypes.agda", "max_line_length": 69, "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": "TypeTheory/Lecture/PropsAsTypes.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1112, "size": 2252 }
module RecordUpdateSyntax where data ⊤ : Set where tt : ⊤ record R : Set where field a b : ⊤ test : R test = record {!!} { a = tt }
{ "alphanum_fraction": 0.5804195804, "avg_line_length": 11.9166666667, "ext": "agda", "hexsha": "e1fb82794f4fc06470a0453168ad426419e8bd73", "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/RecordUpdateSyntax.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/RecordUpdateSyntax.agda", "max_line_length": 31, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/RecordUpdateSyntax.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": 49, "size": 143 }
------------------------------------------------------------------------------ -- Distributive laws on a binary operation: Lemma 4 ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module DistributiveLaws.Lemma4-ATP where open import DistributiveLaws.Base ------------------------------------------------------------------------------ postulate lemma-4a : ∀ x y z → ((x · x ) · y) · z ≡ (x · y) · z {-# ATP prove lemma-4a #-} postulate lemma-4b : ∀ x y z → (x · (y · (z · z))) ≡ x · (y · z) {-# ATP prove lemma-4b #-}
{ "alphanum_fraction": 0.3696551724, "avg_line_length": 34.5238095238, "ext": "agda", "hexsha": "bc76ae2784ba92d56c07ec3db90378153af7d5c9", "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/DistributiveLaws/Lemma4-ATP.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/DistributiveLaws/Lemma4-ATP.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/DistributiveLaws/Lemma4-ATP.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": 152, "size": 725 }
module Container.Bag where open import Prelude Bag : Set → Set Bag A = List (Nat × A) FunctorBag : Functor Bag fmap {{FunctorBag}} f b = map (second f) b union : {A : Set} {{OrdA : Ord A}} → Bag A → Bag A → Bag A union a [] = a union [] b = b union ((i , x) ∷ a) ((j , y) ∷ b) with compare x y ... | less _ = (i , x) ∷ union a ((j , y) ∷ b) ... | equal _ = (i + j , x) ∷ union a b ... | greater _ = (j , y) ∷ union ((i , x) ∷ a) b
{ "alphanum_fraction": 0.5124716553, "avg_line_length": 23.2105263158, "ext": "agda", "hexsha": "d9a3616c8a9e0719be7a4ab31c6edcc0cd23475c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_path": "src/Container/Bag.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lclem/agda-prelude", "max_issues_repo_path": "src/Container/Bag.agda", "max_line_length": 58, "max_stars_count": null, "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_path": "src/Container/Bag.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 177, "size": 441 }
{-# OPTIONS --rewriting #-} data _==_ {A : Set} (a : A) : A → Set where idp : a == a {-# BUILTIN REWRITE _==_ #-} ap : {A B : Set} (f : A → B) {x y : A} → x == y → f x == f y ap f idp = idp {- Circle -} postulate Circle : Set base : Circle loop : base == base module _ (P : Set) (base* : P) (loop* : base* == base*) where postulate Circle-rec : Circle → P Circle-base-recβ : Circle-rec base == base* {-# REWRITE Circle-base-recβ #-} f : Circle → Circle f = Circle-rec Circle base loop postulate rewr : ap (λ z → f (f z)) loop == loop {-# REWRITE rewr #-} test : ap (λ z → f (f z)) loop == loop test = idp
{ "alphanum_fraction": 0.5400313972, "avg_line_length": 19.303030303, "ext": "agda", "hexsha": "87be87163d732e23464c8847e20309b0e61c1020", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/Issue1563-6.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Succeed/Issue1563-6.agda", "max_line_length": 61, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/Issue1563-6.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": 229, "size": 637 }
-- Alternating addition (Also called the Calkin-Wilf tree representation of the rationals). -- One bijective representation of ℚ. That is, every rational number is appearing exactly once in this representation (TODO: Some proof would be nice). module Numeral.Rational.AlterAdd where import Lvl open import Data open import Data.Boolean open import Logic.Propositional open import Numeral.Natural as ℕ import Numeral.Natural.Oper as ℕ import Numeral.Natural.Oper.Comparisons as ℕ open import Numeral.PositiveInteger as ℕ₊ open import Numeral.PositiveInteger.Oper as ℕ₊ open import Numeral.Integer using (ℤ) open import Syntax.Number open import Type module Test1 where data Tree : ℕ₊ → ℕ₊ → Type{Lvl.𝟎} where intro : Tree(1)(1) left : ∀{x y} → Tree(x)(y) → Tree(x) (y ℕ₊.+ x) right : ∀{x y} → Tree(x)(y) → Tree(x ℕ₊.+ y) (y) -- Tree-cancellationₗ : ∀{x₁ x₂ y} → (Tree x₁ y ≡ Tree x₂ y) → (x₁ ≡ x₂) {- TODO: Is there an algorithm that determines the path to every rational in this tree? Maybe the division algorithm: R6 (14928,2395) L4 (558,2395) 14928−2395⋅6 = 558 R3 (558,163) 2395−558⋅4 = 163 L2 (69,163) 558−163⋅3 = 69 R2 (69,25) 163−69⋅2 = 25 L1 (19,25) 69−25⋅2 = 19 R3 (19,6) 25-19 = 6 L5 (1,6) 19-6⋅3 = 1 In (1,1) 6−1⋅5 = 1 f(R$R$R$R$R$R $ L$L$L$L $ R$R$R $ L$L $ R$R $ L $ R$R$R $ L$L$L$L$L $ Init) If this is the case, then just represent the tree by: (Tree = List(Bool)) or (Tree = List(Either ℕ ℕ)) or (Tree = List(ℕ)) ?-} {- open import Data.Option Tree-construct : (x : ℕ₊) → (y : ℕ₊) → Tree(x)(y) Tree-construct ℕ₊.𝟏 ℕ₊.𝟏 = intro Tree-construct ℕ₊.𝟏 (𝐒 y) = left(Tree-construct ℕ₊.𝟏 y) Tree-construct (𝐒 x) ℕ₊.𝟏 = right(Tree-construct x ℕ₊.𝟏) Tree-construct(x@(ℕ₊.𝐒 _)) (y@(ℕ₊.𝐒 _)) with (x −₀ y) ... | Some z = {!right(Tree-construct(z)(y))!} ... | None = {!left (Tree-construct(x)(y ℕ.−₀ x))!} -} -- _+_ : Tree(a₁)(b₁) → Tree(a₂)(b₂) → -- _⋅_ : Tree(a₁)(b₁) → Tree(a₂)(b₂) → data ℚ : Type{Lvl.𝟎} where 𝟎 : ℚ _/₋_ : (x : ℕ₊) → (y : ℕ₊) → ⦃ _ : Tree(x)(y) ⦄ → ℚ _/₊_ : (x : ℕ₊) → (y : ℕ₊) → ⦃ _ : Tree(x)(y) ⦄ → ℚ {- _/_ : (x : ℤ) → (y : ℤ) → ℚ _/_ 𝟎 _ = 𝟎 _/_ _ 𝟎 = 𝟎 _/_ (𝐒(x)) (𝐒(y)) with sign(x) ⋅ sign(y) ... | [−] = (x /₋ y) ⦃ Tree-construction-algorithm(x)(y) ⦄ ... | [+] = (x /₊ y) ⦃ Tree-construction-algorithm(x)(y) ⦄ -} {- a₁/(a₁+b₁) (a₂+b₂)/b₂ -} {- from-ℕ : ℕ → ℚ from-ℕ(𝟎) = 𝟎 from-ℕ(𝐒(n)) = (𝐒(n) /₊ 1) where instance f : (n : ℕ) → Tree(𝐒(n))(1) f(𝟎) = Tree-intro f(𝐒(n)) = Tree-right(f(n)) -} {- floor : ℚ → ℕ floor(x / y) = x ℕ.⌊/⌋ y ceil : ℚ → ℕ ceil(x / y) = x ℕ.⌈/⌉ y -} {- module Test2 where open import Data.Tuple as Tuple using (_⨯_ ; _,_) open import Functional data Tree : Type{Lvl.𝟎} where intro : Tree left : Tree → Tree right : Tree → Tree Tree-quotient : Tree → (ℕ ⨯ ℕ) Tree-quotient intro = (1 , 1 ) Tree-quotient (left t) with (x , y) ← Tree-quotient t = (x , x ℕ.+ y) Tree-quotient (right t) with (x , y) ← Tree-quotient t = (x ℕ.+ y , y ) Tree-denominator : Tree → ℕ Tree-denominator = Tuple.right ∘ Tree-quotient Tree-numerator : Tree → ℕ Tree-numerator = Tuple.left ∘ Tree-quotient -}
{ "alphanum_fraction": 0.5493790656, "avg_line_length": 30.4684684685, "ext": "agda", "hexsha": "90dab902a07403a241f20aae53e1e21b38239592", "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/Rational/AlterAdd.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/Rational/AlterAdd.agda", "max_line_length": 151, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Numeral/Rational/AlterAdd.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": 1469, "size": 3382 }
------------------------------------------------------------------------ -- The values that are used by the NBE algorithm ------------------------------------------------------------------------ import Level open import Data.Universe module README.DependentlyTyped.NBE.Value (Uni₀ : Universe Level.zero Level.zero) where import Axiom.Extensionality.Propositional as E open import Data.Product renaming (curry to c; uncurry to uc) open import deBruijn.Substitution.Data open import Function using (id; _ˢ_; _$_) renaming (const to k) import README.DependentlyTyped.NormalForm as NF; open NF Uni₀ import README.DependentlyTyped.NormalForm.Substitution as NFS open NFS Uni₀ import README.DependentlyTyped.Term as Term; open Term Uni₀ open import Relation.Binary.PropositionalEquality as P using (_≡_) import Relation.Binary.PropositionalEquality.WithK as P open P.≡-Reasoning -- A wrapper which is used to make V̌alue "constructor-headed", which -- in turn makes Agda infer more types for us. infix 3 _⊢_⟨ne⟩ record _⊢_⟨ne⟩ (Γ : Ctxt) (σ : Type Γ) : Set where constructor [_]el field t : Γ ⊢ σ ⟨ ne ⟩ mutual -- The values. V̌alue′ : ∀ Γ sp (σ : IType Γ sp) → Set V̌alue′ Γ ⋆ σ = Γ ⊢ ⋆ , σ ⟨ ne ⟩ V̌alue′ Γ el σ = Γ ⊢ el , σ ⟨ne⟩ V̌alue′ Γ (π sp₁ sp₂) σ = Σ (V̌alue-π Γ sp₁ sp₂ σ) (W̌ell-behaved sp₁ sp₂ σ) V̌alue : (Γ : Ctxt) (σ : Type Γ) → Set V̌alue Γ (sp , σ) = V̌alue′ Γ sp σ V̌alue-π : ∀ Γ sp₁ sp₂ → IType Γ (π sp₁ sp₂) → Set V̌alue-π Γ sp₁ sp₂ σ = (Γ₊ : Ctxt₊ Γ) (v : V̌alue′ (Γ ++₊ Γ₊) sp₁ (ifst σ /̂I ŵk₊ Γ₊)) → V̌alue′ (Γ ++₊ Γ₊) sp₂ (isnd σ /̂I ŵk₊ Γ₊ ↑̂ ∘̂ ŝub ⟦̌ v ⟧) -- The use of Ctxt₊ rather than Ctxt⁺ in V̌alue-π is important: it -- seems to make it much easier to define weakening for V̌alue. W̌ell-behaved : ∀ {Γ} sp₁ sp₂ σ → V̌alue-π Γ sp₁ sp₂ σ → Set W̌ell-behaved {Γ} sp₁ sp₂ σ f = ∀ Γ₊ v → (⟦̌ σ ∣ f ⟧-π /̂Val ŵk₊ Γ₊) ˢ ⟦̌ v ⟧ ≅-Value ⟦̌ f Γ₊ v ⟧ -- The semantics of a value. ⟦̌_⟧ : ∀ {Γ sp σ} → V̌alue′ Γ sp σ → Value Γ (sp , σ) ⟦̌ v ⟧ = ⟦ řeify _ v ⟧n ⟦̌_∣_⟧-π : ∀ {Γ sp₁ sp₂} σ → V̌alue-π Γ sp₁ sp₂ σ → Value Γ (π sp₁ sp₂ , σ) ⟦̌ _ ∣ f ⟧-π = ⟦ řeify-π _ _ _ f ⟧n -- Neutral terms can be turned into normal terms using reflection -- followed by reification. ňeutral-to-normal : ∀ {Γ} sp {σ} → Γ ⊢ sp , σ ⟨ ne ⟩ → Γ ⊢ sp , σ ⟨ no ⟩ ňeutral-to-normal sp t = řeify sp (řeflect sp t) -- A normal term corresponding to variable zero. žero : ∀ {Γ} sp σ → Γ ▻ (sp , σ) ⊢ sp , σ /̂I ŵk ⟨ no ⟩ žero sp σ = ňeutral-to-normal sp (var zero[ -, σ ]) -- Reification. řeify : ∀ {Γ} sp {σ} → V̌alue′ Γ sp σ → Γ ⊢ sp , σ ⟨ no ⟩ řeify ⋆ t = ne ⋆ t řeify el [ t ]el = ne el t řeify (π sp₁ sp₂) f = řeify-π sp₁ sp₂ _ (proj₁ f) řeify-π : ∀ {Γ} sp₁ sp₂ σ → V̌alue-π Γ sp₁ sp₂ σ → Γ ⊢ π sp₁ sp₂ , σ ⟨ no ⟩ řeify-π {Γ} sp₁ sp₂ σ f = čast sp₁ σ $ ƛ (řeify sp₂ (f (fst σ ◅ ε) (řeflect sp₁ (var zero)))) čast : ∀ {Γ} sp₁ {sp₂} (σ : IType Γ (π sp₁ sp₂)) → let ρ̂ = ŵk ↑̂ ∘̂ ŝub ⟦ žero sp₁ (ifst σ) ⟧n in Γ ⊢ Type-π (fst σ) (snd σ /̂ ρ̂) ⟨ no ⟩ → Γ ⊢ -, σ ⟨ no ⟩ čast {Γ} sp₁ σ = P.subst (λ σ → Γ ⊢ σ ⟨ no ⟩) (≅-Type-⇒-≡ $ π-fst-snd-ŵk-ŝub-žero sp₁ σ) -- Reflection. řeflect : ∀ {Γ} sp {σ} → Γ ⊢ sp , σ ⟨ ne ⟩ → V̌alue Γ (sp , σ) řeflect ⋆ t = t řeflect el t = [ t ]el řeflect (π sp₁ sp₂) t = (λ Γ₊ v → řeflect sp₂ ((t /⊢n Renaming.wk₊ Γ₊) · řeify sp₁ v)) , řeflect-π-well-behaved sp₁ sp₂ t abstract řeflect-π-well-behaved : ∀ {Γ} sp₁ sp₂ {σ} (t : Γ ⊢ π sp₁ sp₂ , σ ⟨ ne ⟩) Γ₊ v → let t′ = ňeutral-to-normal sp₂ ((t /⊢n Renaming.wk) · žero sp₁ (ifst σ)) in (⟦ čast sp₁ σ (ƛ t′) ⟧n /̂Val ŵk₊ Γ₊) ˢ ⟦̌ v ⟧ ≅-Value ⟦ ňeutral-to-normal sp₂ ((t /⊢n Renaming.wk₊ Γ₊) · řeify sp₁ v) ⟧n řeflect-π-well-behaved sp₁ sp₂ {σ} t Γ₊ v = let t′ = ňeutral-to-normal sp₂ ((t /⊢n Renaming.wk) · žero sp₁ (ifst σ)) v′ = řeify sp₁ v lemma′ = begin [ ⟦ čast sp₁ σ (ƛ t′) ⟧n /̂Val ŵk₊ Γ₊ ] ≡⟨ /̂Val-cong (ňeutral-to-normal-identity-π sp₁ sp₂ t) P.refl ⟩ [ ⟦ t ⟧n /̂Val ŵk₊ Γ₊ ] ≡⟨ t /⊢n-lemma Renaming.wk₊ Γ₊ ⟩ [ ⟦ t /⊢n Renaming.wk₊ Γ₊ ⟧n ] ∎ in begin [ (⟦ čast sp₁ σ (ƛ t′) ⟧n /̂Val ŵk₊ Γ₊) ˢ ⟦ v′ ⟧n ] ≡⟨ ˢ-cong lemma′ P.refl ⟩ [ ⟦ t /⊢n Renaming.wk₊ Γ₊ ⟧n ˢ ⟦ v′ ⟧n ] ≡⟨ P.refl ⟩ [ ⟦ (t /⊢n Renaming.wk₊ Γ₊) · v′ ⟧n ] ≡⟨ P.sym $ ňeutral-to-normal-identity sp₂ _ ⟩ [ ⟦ ňeutral-to-normal sp₂ ((t /⊢n Renaming.wk₊ Γ₊) · v′) ⟧n ] ∎ -- A given context morphism is equal to the identity. ŵk-ŝub-žero : ∀ {Γ} sp₁ {sp₂} (σ : IType Γ (π sp₁ sp₂)) → ŵk ↑̂ fst σ ∘̂ ŝub ⟦ žero sp₁ (ifst σ) ⟧n ≅-⇨̂ îd[ Γ ▻ fst σ ] ŵk-ŝub-žero sp₁ σ = begin [ ŵk ↑̂ ∘̂ ŝub ⟦ žero sp₁ (ifst σ) ⟧n ] ≡⟨ ∘̂-cong (P.refl {x = [ ŵk ↑̂ ]}) (ŝub-cong (ňeutral-to-normal-identity sp₁ (var zero))) ⟩ [ ŵk ↑̂ ∘̂ ŝub ⟦ var zero ⟧n ] ≡⟨ P.refl ⟩ [ îd ] ∎ -- A corollary of the lemma above. π-fst-snd-ŵk-ŝub-žero : ∀ {Γ} sp₁ {sp₂} (σ : IType Γ (π sp₁ sp₂)) → Type-π (fst σ) (snd σ /̂ ŵk ↑̂ ∘̂ ŝub ⟦ žero sp₁ (ifst σ) ⟧n) ≅-Type (-, σ) π-fst-snd-ŵk-ŝub-žero sp₁ σ = begin [ Type-π (fst σ) (snd σ /̂ ŵk ↑̂ ∘̂ ŝub ⟦ žero sp₁ (ifst σ) ⟧n) ] ≡⟨ Type-π-cong $ /̂-cong (P.refl {x = [ snd σ ]}) (ŵk-ŝub-žero sp₁ σ) ⟩ [ Type-π (fst σ) (snd σ) ] ≡⟨ P.refl ⟩ [ -, σ ] ∎ -- In the semantics řeify is a left inverse of řeflect. ňeutral-to-normal-identity : ∀ {Γ} sp {σ} (t : Γ ⊢ sp , σ ⟨ ne ⟩) → ⟦ ňeutral-to-normal sp t ⟧n ≅-Value ⟦ t ⟧n ňeutral-to-normal-identity ⋆ t = P.refl ňeutral-to-normal-identity el t = P.refl ňeutral-to-normal-identity (π sp₁ sp₂) t = ňeutral-to-normal-identity-π sp₁ sp₂ t ňeutral-to-normal-identity-π : ∀ {Γ} sp₁ sp₂ {σ} (t : Γ ⊢ π sp₁ sp₂ , σ ⟨ ne ⟩) → let t′ = ňeutral-to-normal sp₂ ((t /⊢n Renaming.wk) · žero sp₁ (ifst σ)) in ⟦ čast sp₁ σ (ƛ t′) ⟧n ≅-Value ⟦ t ⟧n ňeutral-to-normal-identity-π sp₁ sp₂ {σ} t = let t′ = (t /⊢n Renaming.wk) · žero sp₁ (ifst σ) lemma = begin [ ⟦ ňeutral-to-normal sp₂ t′ ⟧n ] ≡⟨ ňeutral-to-normal-identity sp₂ t′ ⟩ [ ⟦ t′ ⟧n ] ≡⟨ P.refl ⟩ [ ⟦ t /⊢n Renaming.wk ⟧n ˢ ⟦ žero sp₁ (ifst σ) ⟧n ] ≡⟨ ˢ-cong (P.sym $ t /⊢n-lemma Renaming.wk) (ňeutral-to-normal-identity sp₁ (var zero)) ⟩ [ (⟦ t ⟧n /̂Val ŵk) ˢ lookup zero ] ≡⟨ P.refl ⟩ [ uc ⟦ t ⟧n ] ∎ in begin [ ⟦ čast sp₁ σ (ƛ (ňeutral-to-normal sp₂ t′)) ⟧n ] ≡⟨ ⟦⟧n-cong $ drop-subst-⊢n id (≅-Type-⇒-≡ $ π-fst-snd-ŵk-ŝub-žero sp₁ σ) ⟩ [ c ⟦ ňeutral-to-normal sp₂ t′ ⟧n ] ≡⟨ curry-cong lemma ⟩ [ c {C = k El ˢ isnd σ} (uc ⟦ t ⟧n) ] ≡⟨ P.refl ⟩ [ ⟦ t ⟧n ] ∎ -- An immediate consequence of the somewhat roundabout definition -- above. w̌ell-behaved : ∀ {Γ sp₁ sp₂ σ} (f : V̌alue Γ (π sp₁ sp₂ , σ)) → ∀ Γ₊ v → (⟦̌_⟧ {σ = σ} f /̂Val ŵk₊ Γ₊) ˢ ⟦̌ v ⟧ ≅-Value ⟦̌ proj₁ f Γ₊ v ⟧ w̌ell-behaved = proj₂ -- Values are term-like. V̌al : Term-like _ V̌al = record { _⊢_ = V̌alue ; ⟦_⟧ = ⟦̌_⟧ } open Term-like V̌al public using ([_]) renaming ( _≅-⊢_ to _≅-V̌alue_ ; drop-subst-⊢ to drop-subst-V̌alue; ⟦⟧-cong to ⟦̌⟧-cong ) abstract -- Unfolding lemma for ⟦̌_∣_⟧-π. unfold-⟦̌∣⟧-π : ∀ {Γ sp₁ sp₂} σ (f : V̌alue-π Γ sp₁ sp₂ σ) → ⟦̌ σ ∣ f ⟧-π ≅-Value c ⟦̌ f (fst σ ◅ ε) (řeflect sp₁ (var zero)) ⟧ unfold-⟦̌∣⟧-π σ _ = ⟦⟧n-cong $ drop-subst-⊢n id (≅-Type-⇒-≡ $ π-fst-snd-ŵk-ŝub-žero _ σ) -- Some congruence/conversion lemmas. ≅-⊢n-⇒-≅-Value-⋆ : ∀ {Γ₁ σ₁} {t₁ : Γ₁ ⊢ ⋆ , σ₁ ⟨ ne ⟩} {Γ₂ σ₂} {t₂ : Γ₂ ⊢ ⋆ , σ₂ ⟨ ne ⟩} → t₁ ≅-⊢n t₂ → t₁ ≅-V̌alue t₂ ≅-⊢n-⇒-≅-Value-⋆ P.refl = P.refl ≅-Value-⋆-⇒-≅-⊢n : ∀ {Γ₁ σ₁} {t₁ : Γ₁ ⊢ ⋆ , σ₁ ⟨ ne ⟩} {Γ₂ σ₂} {t₂ : Γ₂ ⊢ ⋆ , σ₂ ⟨ ne ⟩} → t₁ ≅-V̌alue t₂ → t₁ ≅-⊢n t₂ ≅-Value-⋆-⇒-≅-⊢n P.refl = P.refl ≅-⊢n-⇒-≅-Value-el : ∀ {Γ₁ σ₁} {t₁ : Γ₁ ⊢ el , σ₁ ⟨ ne ⟩} {Γ₂ σ₂} {t₂ : Γ₂ ⊢ el , σ₂ ⟨ ne ⟩} → t₁ ≅-⊢n t₂ → [ t₁ ]el ≅-V̌alue [ t₂ ]el ≅-⊢n-⇒-≅-Value-el P.refl = P.refl ≅-Value-el-⇒-≅-⊢n : ∀ {Γ₁ σ₁} {t₁ : Γ₁ ⊢ el , σ₁ ⟨ ne ⟩} {Γ₂ σ₂} {t₂ : Γ₂ ⊢ el , σ₂ ⟨ ne ⟩} → [ t₁ ]el ≅-V̌alue [ t₂ ]el → t₁ ≅-⊢n t₂ ≅-Value-el-⇒-≅-⊢n P.refl = P.refl abstract ,-cong : E.Extensionality Level.zero Level.zero → ∀ {Γ sp₁ sp₂ σ} {f₁ f₂ : V̌alue Γ (π sp₁ sp₂ , σ)} → (∀ Γ₊ v → proj₁ f₁ Γ₊ v ≅-V̌alue proj₁ f₂ Γ₊ v) → _≅-V̌alue_ {σ₁ = (π sp₁ sp₂ , σ)} f₁ {σ₂ = (π sp₁ sp₂ , σ)} f₂ ,-cong ext hyp = P.cong (Term-like.[_] {_} {V̌al}) $ ,-cong′ (ext λ Γ₊ → ext λ v → Term-like.≅-⊢-⇒-≡ V̌al $ hyp Γ₊ v) (ext λ _ → ext λ _ → P.≡-irrelevant _ _) where ,-cong′ : {A : Set} {B : A → Set} {x₁ x₂ : A} {y₁ : B x₁} {y₂ : B x₂} → (eq : x₁ ≡ x₂) → P.subst B eq y₁ ≡ y₂ → _≡_ {A = Σ A B} (x₁ , y₁) (x₂ , y₂) ,-cong′ P.refl P.refl = P.refl ňeutral-to-normal-cong : ∀ {Γ₁ σ₁} {t₁ : Γ₁ ⊢ σ₁ ⟨ ne ⟩} {Γ₂ σ₂} {t₂ : Γ₂ ⊢ σ₂ ⟨ ne ⟩} → t₁ ≅-⊢n t₂ → ňeutral-to-normal _ t₁ ≅-⊢n ňeutral-to-normal _ t₂ ňeutral-to-normal-cong P.refl = P.refl žero-cong : ∀ {Γ₁} {σ₁ : Type Γ₁} {Γ₂} {σ₂ : Type Γ₂} → σ₁ ≅-Type σ₂ → žero _ (proj₂ σ₁) ≅-⊢n žero _ (proj₂ σ₂) žero-cong P.refl = P.refl řeify-cong : ∀ {Γ₁ σ₁} {v₁ : V̌alue Γ₁ σ₁} {Γ₂ σ₂} {v₂ : V̌alue Γ₂ σ₂} → v₁ ≅-V̌alue v₂ → řeify _ v₁ ≅-⊢n řeify _ v₂ řeify-cong P.refl = P.refl řeflect-cong : ∀ {Γ₁ σ₁} {t₁ : Γ₁ ⊢ σ₁ ⟨ ne ⟩} {Γ₂ σ₂} {t₂ : Γ₂ ⊢ σ₂ ⟨ ne ⟩} → t₁ ≅-⊢n t₂ → řeflect _ t₁ ≅-V̌alue řeflect _ t₂ řeflect-cong P.refl = P.refl
{ "alphanum_fraction": 0.4542335157, "avg_line_length": 38.2375886525, "ext": "agda", "hexsha": "9348711e4ce4de8e8ebf8cbc51a61d71bd4b07a3", "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": "README/DependentlyTyped/NBE/Value.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": "README/DependentlyTyped/NBE/Value.agda", "max_line_length": 138, "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": "README/DependentlyTyped/NBE/Value.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": 5185, "size": 10783 }
------------------------------------------------------------------------ -- INCREMENTAL λ-CALCULUS -- -- Bags of integers, for Nehemiah plugin. -- -- This module imports postulates about bags of integers -- with negative multiplicities as a group under additive union. ------------------------------------------------------------------------ module Structure.Bag.Nehemiah where open import Postulate.Bag-Nehemiah public open import Relation.Binary.PropositionalEquality open import Algebra using (CommutativeRing) open import Algebra.Structures open import Data.Integer open import Data.Integer.Properties using () renaming (+-*-commutativeRing to ℤ-is-commutativeRing) open import Data.Product infixl 9 _\\_ -- same as Data.Map.(\\) _\\_ : Bag → Bag → Bag d \\ b = d ++ (negateBag b) -- Useful properties of abelian groups commutative : ∀ {A : Set} {f : A → A → A} {z} → IsCommutativeMonoid _≡_ f z → (m n : A) → f m n ≡ f n m commutative = IsCommutativeMonoid.comm associative : ∀ {A : Set} {f : A → A → A} {z} → IsCommutativeMonoid _≡_ f z → (k m n : A) → f (f k m) n ≡ f k (f m n) associative abelian = IsCommutativeMonoid.assoc abelian left-inverse : ∀ {A : Set} {f : A → A → A} {z neg} → IsAbelianGroup _≡_ f z neg → (n : A) → f (neg n) n ≡ z left-inverse abelian = proj₁ (IsAbelianGroup.inverse abelian) right-inverse : ∀ {A : Set} {f : A → A → A} {z neg} → IsAbelianGroup _≡_ f z neg → (n : A) → f n (neg n) ≡ z right-inverse abelian = proj₂ (IsAbelianGroup.inverse abelian) left-identity : ∀ {A : Set} {f : A → A → A} {z neg} → IsAbelianGroup _≡_ f z neg → (n : A) → f z n ≡ n left-identity abelian = proj₁ (IsMonoid.identity (IsGroup.isMonoid (IsAbelianGroup.isGroup abelian))) right-identity : ∀ {A : Set} {f : A → A → A} {z neg} → IsAbelianGroup _≡_ f z neg → (n : A) → f n z ≡ n right-identity abelian = proj₂ (IsMonoid.identity (IsGroup.isMonoid (IsAbelianGroup.isGroup abelian))) instance abelian-int : IsAbelianGroup _≡_ _+_ (+ 0) (-_) abelian-int = CommutativeRing.+-isAbelianGroup ℤ-is-commutativeRing abelian→comm-monoid : ∀ {A : Set} {f : A → A → A} {z neg} → {{abel : IsAbelianGroup _≡_ f z neg}} → IsCommutativeMonoid _≡_ f z abelian→comm-monoid {{abel}} = IsAbelianGroup.isCommutativeMonoid abel comm-monoid-int : IsCommutativeMonoid _≡_ _+_ (+ 0) comm-monoid-int = IsAbelianGroup.isCommutativeMonoid abelian-int comm-monoid-bag : IsCommutativeMonoid _≡_ _++_ emptyBag comm-monoid-bag = IsAbelianGroup.isCommutativeMonoid abelian-bag import Data.Nat as N import Data.Nat.Properties as NP comm-monoid-nat : IsCommutativeMonoid _≡_ N._+_ 0 comm-monoid-nat = IsCommutativeSemiring.+-isCommutativeMonoid NP.isCommutativeSemiring commutative-int : (m n : ℤ) → m + n ≡ n + m commutative-int = commutative comm-monoid-int associative-int : (k m n : ℤ) → (k + m) + n ≡ k + (m + n) associative-int = associative comm-monoid-int right-inv-int : (n : ℤ) → n - n ≡ + 0 right-inv-int = right-inverse abelian-int left-id-int : (n : ℤ) → (+ 0) + n ≡ n left-id-int = left-identity abelian-int right-id-int : (n : ℤ) → n + (+ 0) ≡ n right-id-int = right-identity abelian-int commutative-bag : (a b : Bag) → a ++ b ≡ b ++ a commutative-bag = commutative comm-monoid-bag associative-bag : (a b c : Bag) → (a ++ b) ++ c ≡ a ++ (b ++ c) associative-bag = associative comm-monoid-bag right-inv-bag : (b : Bag) → b \\ b ≡ emptyBag right-inv-bag = right-inverse abelian-bag left-id-bag : (b : Bag) → emptyBag ++ b ≡ b left-id-bag = left-identity abelian-bag right-id-bag : (b : Bag) → b ++ emptyBag ≡ b right-id-bag = right-identity abelian-bag
{ "alphanum_fraction": 0.6456256921, "avg_line_length": 38.8387096774, "ext": "agda", "hexsha": "0ba86bf0e345499cf3caf1883fb0485859edbb68", "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": "Structure/Bag/Nehemiah.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": "Structure/Bag/Nehemiah.agda", "max_line_length": 88, "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": "Structure/Bag/Nehemiah.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": 1250, "size": 3612 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Category.Construction.Properties.Presheaves.Cartesian {o ℓ e} (C : Category o ℓ e) where open import Level open import Data.Unit open import Data.Product using (_,_) open import Data.Product.Relation.Binary.Pointwise.NonDependent open import Function.Equality using (Π) renaming (_∘_ to _∙_) open import Relation.Binary open import Categories.Category.Cartesian open import Categories.Category.Construction.Presheaves open import Categories.Category.Instance.Setoids open import Categories.Functor open import Categories.Functor.Properties open import Categories.Functor.Presheaf open import Categories.NaturalTransformation import Categories.Object.Product as Prod import Categories.Morphism.Reasoning as MR open Π using (_⟨$⟩_) module _ {o′ ℓ′ o″ ℓ″} where Presheaves× : ∀ (A : Presheaf C (Setoids o′ ℓ′)) (A : Presheaf C (Setoids o″ ℓ″)) → Presheaf C (Setoids (o′ ⊔ o″) (ℓ′ ⊔ ℓ″)) Presheaves× A B = record { F₀ = λ X → ×-setoid (A.₀ X) (B.₀ X) ; F₁ = λ f → record { _⟨$⟩_ = λ { (a , b) → A.₁ f ⟨$⟩ a , B.₁ f ⟨$⟩ b } ; cong = λ { (eq₁ , eq₂) → Π.cong (A.₁ f) eq₁ , Π.cong (B.₁ f) eq₂ } } ; identity = λ { (eq₁ , eq₂) → A.identity eq₁ , B.identity eq₂ } ; homomorphism = λ { (eq₁ , eq₂) → A.homomorphism eq₁ , B.homomorphism eq₂ } ; F-resp-≈ = λ { eq (eq₁ , eq₂) → A.F-resp-≈ eq eq₁ , B.F-resp-≈ eq eq₂ } } where module A = Functor A module B = Functor B module IsCartesian o′ ℓ′ where private module C = Category C open C P = Presheaves′ o′ ℓ′ C module P = Category P S = Setoids o′ ℓ′ module S = Category S Presheaves-Cartesian : Cartesian P Presheaves-Cartesian = record { terminal = record { ⊤ = record { F₀ = λ x → record { Carrier = Lift o′ ⊤ ; _≈_ = λ _ _ → Lift ℓ′ ⊤ ; isEquivalence = _ } } ; ! = _ ; !-unique = _ } ; products = record { product = λ {A B} → let module A = Functor A module B = Functor B in record { A×B = Presheaves× A B ; π₁ = ntHelper record { η = λ X → record { _⟨$⟩_ = λ { (fst , _) → fst } ; cong = λ { (eq , _) → eq } } ; commute = λ { f (eq , _) → Π.cong (A.F₁ f) eq } } ; π₂ = ntHelper record { η = λ X → record { _⟨$⟩_ = λ { (_ , snd) → snd } ; cong = λ { (_ , eq) → eq } } ; commute = λ { f (_ , eq) → Π.cong (B.F₁ f) eq } } ; ⟨_,_⟩ = λ {F} α β → let module F = Functor F module α = NaturalTransformation α module β = NaturalTransformation β in ntHelper record { η = λ Y → record { _⟨$⟩_ = λ S → α.η Y ⟨$⟩ S , β.η Y ⟨$⟩ S ; cong = λ eq → Π.cong (α.η Y) eq , Π.cong (β.η Y) eq } ; commute = λ f eq → α.commute f eq , β.commute f eq } ; project₁ = λ {F α β x} eq → let module F = Functor F module α = NaturalTransformation α module β = NaturalTransformation β in Π.cong (α.η x) eq ; project₂ = λ {F α β x} eq → let module F = Functor F module α = NaturalTransformation α module β = NaturalTransformation β in Π.cong (β.η x) eq ; unique = λ {F α β δ} eq₁ eq₂ {x} eq → let module F = Functor F module α = NaturalTransformation α module β = NaturalTransformation β module δ = NaturalTransformation δ in Setoid.sym (A.₀ x) (eq₁ (Setoid.sym (F.₀ x) eq)) , Setoid.sym (B.₀ x) (eq₂ (Setoid.sym (F.₀ x) eq)) } } } module Presheaves-Cartesian = Cartesian Presheaves-Cartesian
{ "alphanum_fraction": 0.5177816464, "avg_line_length": 33.7899159664, "ext": "agda", "hexsha": "cc2c1f2d72e0b55b045dd01ef6e614329dfa3f05", "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/Construction/Properties/Presheaves/Cartesian.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/Construction/Properties/Presheaves/Cartesian.agda", "max_line_length": 126, "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/Construction/Properties/Presheaves/Cartesian.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1264, "size": 4021 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Definitions of algebraic structures like monoids and rings -- (packed in records together with sets, operations, etc.) ------------------------------------------------------------------------ -- The contents of this module should be accessed via `Algebra`. {-# OPTIONS --without-K --safe #-} module Algebra.Bundles where open import Algebra.Core open import Algebra.Structures open import Relation.Binary open import Function.Base open import Level ------------------------------------------------------------------------ -- Bundles with 1 binary operation ------------------------------------------------------------------------ record RawMagma c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier record Magma c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier isMagma : IsMagma _≈_ _∙_ open IsMagma isMagma public rawMagma : RawMagma _ _ rawMagma = record { _≈_ = _≈_; _∙_ = _∙_ } record Semigroup c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier isSemigroup : IsSemigroup _≈_ _∙_ open IsSemigroup isSemigroup public magma : Magma c ℓ magma = record { isMagma = isMagma } open Magma magma public using (rawMagma) record Band c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier isBand : IsBand _≈_ _∙_ open IsBand isBand public semigroup : Semigroup c ℓ semigroup = record { isSemigroup = isSemigroup } open Semigroup semigroup public using (magma; rawMagma) record CommutativeSemigroup c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier isCommutativeSemigroup : IsCommutativeSemigroup _≈_ _∙_ open IsCommutativeSemigroup isCommutativeSemigroup public semigroup : Semigroup c ℓ semigroup = record { isSemigroup = isSemigroup } open Semigroup semigroup public using (magma; rawMagma) record Semilattice c ℓ : Set (suc (c ⊔ ℓ)) where infixr 7 _∧_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∧_ : Op₂ Carrier isSemilattice : IsSemilattice _≈_ _∧_ open IsSemilattice isSemilattice public band : Band c ℓ band = record { isBand = isBand } open Band band public using (rawMagma; magma; semigroup) record SelectiveMagma c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier isSelectiveMagma : IsSelectiveMagma _≈_ _∙_ open IsSelectiveMagma isSelectiveMagma public magma : Magma c ℓ magma = record { isMagma = isMagma } open Magma magma public using (rawMagma) ------------------------------------------------------------------------ -- Bundles with 1 binary operation & 1 element ------------------------------------------------------------------------ -- A raw monoid is a monoid without any laws. record RawMonoid c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier ε : Carrier rawMagma : RawMagma c ℓ rawMagma = record { _≈_ = _≈_ ; _∙_ = _∙_ } record Monoid c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier ε : Carrier isMonoid : IsMonoid _≈_ _∙_ ε open IsMonoid isMonoid public semigroup : Semigroup _ _ semigroup = record { isSemigroup = isSemigroup } rawMonoid : RawMonoid _ _ rawMonoid = record { _≈_ = _≈_; _∙_ = _∙_; ε = ε} open Semigroup semigroup public using (rawMagma; magma) record CommutativeMonoid c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier ε : Carrier isCommutativeMonoid : IsCommutativeMonoid _≈_ _∙_ ε open IsCommutativeMonoid isCommutativeMonoid public monoid : Monoid _ _ monoid = record { isMonoid = isMonoid } commutativeSemigroup : CommutativeSemigroup _ _ commutativeSemigroup = record { isCommutativeSemigroup = isCommutativeSemigroup } open Monoid monoid public using (rawMagma; magma; semigroup; rawMonoid) record IdempotentCommutativeMonoid c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier ε : Carrier isIdempotentCommutativeMonoid : IsIdempotentCommutativeMonoid _≈_ _∙_ ε open IsIdempotentCommutativeMonoid isIdempotentCommutativeMonoid public commutativeMonoid : CommutativeMonoid _ _ commutativeMonoid = record { isCommutativeMonoid = isCommutativeMonoid } open CommutativeMonoid commutativeMonoid public using (rawMagma; magma; semigroup; rawMonoid; monoid) -- Idempotent commutative monoids are also known as bounded lattices. -- Note that the BoundedLattice necessarily uses the notation inherited -- from monoids rather than lattices. BoundedLattice = IdempotentCommutativeMonoid module BoundedLattice {c ℓ} (idemCommMonoid : IdempotentCommutativeMonoid c ℓ) = IdempotentCommutativeMonoid idemCommMonoid ------------------------------------------------------------------------ -- Bundles with 1 binary operation, 1 unary operation & 1 element ------------------------------------------------------------------------ record RawGroup c ℓ : Set (suc (c ⊔ ℓ)) where infix 8 _⁻¹ infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier ε : Carrier _⁻¹ : Op₁ Carrier rawMonoid : RawMonoid c ℓ rawMonoid = record { _≈_ = _≈_ ; _∙_ = _∙_ ; ε = ε } open RawMonoid rawMonoid public using (rawMagma) record Group c ℓ : Set (suc (c ⊔ ℓ)) where infix 8 _⁻¹ infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier ε : Carrier _⁻¹ : Op₁ Carrier isGroup : IsGroup _≈_ _∙_ ε _⁻¹ open IsGroup isGroup public rawGroup : RawGroup _ _ rawGroup = record { _≈_ = _≈_; _∙_ = _∙_; ε = ε; _⁻¹ = _⁻¹} monoid : Monoid _ _ monoid = record { isMonoid = isMonoid } open Monoid monoid public using (rawMagma; magma; semigroup; rawMonoid) record AbelianGroup c ℓ : Set (suc (c ⊔ ℓ)) where infix 8 _⁻¹ infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier ε : Carrier _⁻¹ : Op₁ Carrier isAbelianGroup : IsAbelianGroup _≈_ _∙_ ε _⁻¹ open IsAbelianGroup isAbelianGroup public group : Group _ _ group = record { isGroup = isGroup } open Group group public using (rawMagma; magma; semigroup; monoid; rawMonoid; rawGroup) commutativeMonoid : CommutativeMonoid _ _ commutativeMonoid = record { isCommutativeMonoid = isCommutativeMonoid } ------------------------------------------------------------------------ -- Bundles with 2 binary operations ------------------------------------------------------------------------ record Lattice c ℓ : Set (suc (c ⊔ ℓ)) where infixr 7 _∧_ infixr 6 _∨_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∨_ : Op₂ Carrier _∧_ : Op₂ Carrier isLattice : IsLattice _≈_ _∨_ _∧_ open IsLattice isLattice public setoid : Setoid _ _ setoid = record { isEquivalence = isEquivalence } record DistributiveLattice c ℓ : Set (suc (c ⊔ ℓ)) where infixr 7 _∧_ infixr 6 _∨_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∨_ : Op₂ Carrier _∧_ : Op₂ Carrier isDistributiveLattice : IsDistributiveLattice _≈_ _∨_ _∧_ open IsDistributiveLattice isDistributiveLattice public lattice : Lattice _ _ lattice = record { isLattice = isLattice } open Lattice lattice public using (setoid) ------------------------------------------------------------------------ -- Bundles with 2 binary operations & 1 element ------------------------------------------------------------------------ record NearSemiring c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _*_ infixl 6 _+_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _+_ : Op₂ Carrier _*_ : Op₂ Carrier 0# : Carrier isNearSemiring : IsNearSemiring _≈_ _+_ _*_ 0# open IsNearSemiring isNearSemiring public +-monoid : Monoid _ _ +-monoid = record { isMonoid = +-isMonoid } open Monoid +-monoid public using () renaming ( rawMagma to +-rawMagma ; magma to +-magma ; semigroup to +-semigroup ; rawMonoid to +-rawMonoid ) *-semigroup : Semigroup _ _ *-semigroup = record { isSemigroup = *-isSemigroup } open Semigroup *-semigroup public using () renaming ( rawMagma to *-rawMagma ; magma to *-magma ) record SemiringWithoutOne c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _*_ infixl 6 _+_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _+_ : Op₂ Carrier _*_ : Op₂ Carrier 0# : Carrier isSemiringWithoutOne : IsSemiringWithoutOne _≈_ _+_ _*_ 0# open IsSemiringWithoutOne isSemiringWithoutOne public nearSemiring : NearSemiring _ _ nearSemiring = record { isNearSemiring = isNearSemiring } open NearSemiring nearSemiring public using ( +-rawMagma; +-magma; +-semigroup; +-rawMonoid; +-monoid ; *-rawMagma; *-magma; *-semigroup ) +-commutativeMonoid : CommutativeMonoid _ _ +-commutativeMonoid = record { isCommutativeMonoid = +-isCommutativeMonoid } record CommutativeSemiringWithoutOne c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _*_ infixl 6 _+_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _+_ : Op₂ Carrier _*_ : Op₂ Carrier 0# : Carrier isCommutativeSemiringWithoutOne : IsCommutativeSemiringWithoutOne _≈_ _+_ _*_ 0# open IsCommutativeSemiringWithoutOne isCommutativeSemiringWithoutOne public semiringWithoutOne : SemiringWithoutOne _ _ semiringWithoutOne = record { isSemiringWithoutOne = isSemiringWithoutOne } open SemiringWithoutOne semiringWithoutOne public using ( +-rawMagma; +-magma; +-semigroup ; *-rawMagma; *-magma; *-semigroup ; +-rawMonoid; +-monoid; +-commutativeMonoid ; nearSemiring ) ------------------------------------------------------------------------ -- Bundles with 2 binary operations & 2 elements ------------------------------------------------------------------------ record RawSemiring c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _*_ infixl 6 _+_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _+_ : Op₂ Carrier _*_ : Op₂ Carrier 0# : Carrier 1# : Carrier record SemiringWithoutAnnihilatingZero c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _*_ infixl 6 _+_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _+_ : Op₂ Carrier _*_ : Op₂ Carrier 0# : Carrier 1# : Carrier isSemiringWithoutAnnihilatingZero : IsSemiringWithoutAnnihilatingZero _≈_ _+_ _*_ 0# 1# open IsSemiringWithoutAnnihilatingZero isSemiringWithoutAnnihilatingZero public +-commutativeMonoid : CommutativeMonoid _ _ +-commutativeMonoid = record { isCommutativeMonoid = +-isCommutativeMonoid } open CommutativeMonoid +-commutativeMonoid public using () renaming ( rawMagma to +-rawMagma ; magma to +-magma ; semigroup to +-semigroup ; rawMonoid to +-rawMonoid ; monoid to +-monoid ) *-monoid : Monoid _ _ *-monoid = record { isMonoid = *-isMonoid } open Monoid *-monoid public using () renaming ( rawMagma to *-rawMagma ; magma to *-magma ; semigroup to *-semigroup ; rawMonoid to *-rawMonoid ) record Semiring c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _*_ infixl 6 _+_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _+_ : Op₂ Carrier _*_ : Op₂ Carrier 0# : Carrier 1# : Carrier isSemiring : IsSemiring _≈_ _+_ _*_ 0# 1# open IsSemiring isSemiring public rawSemiring : RawSemiring _ _ rawSemiring = record { _≈_ = _≈_ ; _+_ = _+_ ; _*_ = _*_ ; 0# = 0# ; 1# = 1# } semiringWithoutAnnihilatingZero : SemiringWithoutAnnihilatingZero _ _ semiringWithoutAnnihilatingZero = record { isSemiringWithoutAnnihilatingZero = isSemiringWithoutAnnihilatingZero } open SemiringWithoutAnnihilatingZero semiringWithoutAnnihilatingZero public using ( +-rawMagma; +-magma; +-semigroup ; *-rawMagma; *-magma; *-semigroup ; +-rawMonoid; +-monoid; +-commutativeMonoid ; *-rawMonoid; *-monoid ) semiringWithoutOne : SemiringWithoutOne _ _ semiringWithoutOne = record { isSemiringWithoutOne = isSemiringWithoutOne } open SemiringWithoutOne semiringWithoutOne public using (nearSemiring) record CommutativeSemiring c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _*_ infixl 6 _+_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _+_ : Op₂ Carrier _*_ : Op₂ Carrier 0# : Carrier 1# : Carrier isCommutativeSemiring : IsCommutativeSemiring _≈_ _+_ _*_ 0# 1# open IsCommutativeSemiring isCommutativeSemiring public semiring : Semiring _ _ semiring = record { isSemiring = isSemiring } open Semiring semiring public using ( +-rawMagma; +-magma; +-semigroup ; *-rawMagma; *-magma; *-semigroup ; +-rawMonoid; +-monoid; +-commutativeMonoid ; *-rawMonoid; *-monoid ; nearSemiring; semiringWithoutOne ; semiringWithoutAnnihilatingZero ; rawSemiring ) *-commutativeSemigroup : CommutativeSemigroup _ _ *-commutativeSemigroup = record { isCommutativeSemigroup = *-isCommutativeSemigroup } *-commutativeMonoid : CommutativeMonoid _ _ *-commutativeMonoid = record { isCommutativeMonoid = *-isCommutativeMonoid } commutativeSemiringWithoutOne : CommutativeSemiringWithoutOne _ _ commutativeSemiringWithoutOne = record { isCommutativeSemiringWithoutOne = isCommutativeSemiringWithoutOne } ------------------------------------------------------------------------ -- Bundles with 2 binary operations, 1 unary operation & 2 elements ------------------------------------------------------------------------ -- A raw ring is a ring without any laws. record RawRing c ℓ : Set (suc (c ⊔ ℓ)) where infix 8 -_ infixl 7 _*_ infixl 6 _+_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _+_ : Op₂ Carrier _*_ : Op₂ Carrier -_ : Op₁ Carrier 0# : Carrier 1# : Carrier +-rawGroup : RawGroup c ℓ +-rawGroup = record { _≈_ = _≈_ ; _∙_ = _+_ ; ε = 0# ; _⁻¹ = -_ } *-rawMonoid : RawMonoid c ℓ *-rawMonoid = record { _≈_ = _≈_ ; _∙_ = _*_ ; ε = 1# } record Ring c ℓ : Set (suc (c ⊔ ℓ)) where infix 8 -_ infixl 7 _*_ infixl 6 _+_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _+_ : Op₂ Carrier _*_ : Op₂ Carrier -_ : Op₁ Carrier 0# : Carrier 1# : Carrier isRing : IsRing _≈_ _+_ _*_ -_ 0# 1# open IsRing isRing public +-abelianGroup : AbelianGroup _ _ +-abelianGroup = record { isAbelianGroup = +-isAbelianGroup } semiring : Semiring _ _ semiring = record { isSemiring = isSemiring } open Semiring semiring public using ( +-rawMagma; +-magma; +-semigroup ; *-rawMagma; *-magma; *-semigroup ; +-rawMonoid; +-monoid ; +-commutativeMonoid ; *-rawMonoid; *-monoid ; nearSemiring; semiringWithoutOne ; semiringWithoutAnnihilatingZero ) open AbelianGroup +-abelianGroup public using () renaming (group to +-group) rawRing : RawRing _ _ rawRing = record { _≈_ = _≈_ ; _+_ = _+_ ; _*_ = _*_ ; -_ = -_ ; 0# = 0# ; 1# = 1# } record CommutativeRing c ℓ : Set (suc (c ⊔ ℓ)) where infix 8 -_ infixl 7 _*_ infixl 6 _+_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _+_ : Op₂ Carrier _*_ : Op₂ Carrier -_ : Op₁ Carrier 0# : Carrier 1# : Carrier isCommutativeRing : IsCommutativeRing _≈_ _+_ _*_ -_ 0# 1# open IsCommutativeRing isCommutativeRing public ring : Ring _ _ ring = record { isRing = isRing } commutativeSemiring : CommutativeSemiring _ _ commutativeSemiring = record { isCommutativeSemiring = isCommutativeSemiring } open Ring ring public using (rawRing; +-group; +-abelianGroup) open CommutativeSemiring commutativeSemiring public using ( +-rawMagma; +-magma; +-semigroup ; *-rawMagma; *-magma; *-semigroup ; +-rawMonoid; +-monoid; +-commutativeMonoid ; *-rawMonoid; *-monoid; *-commutativeMonoid ; nearSemiring; semiringWithoutOne ; semiringWithoutAnnihilatingZero; semiring ; commutativeSemiringWithoutOne ) record BooleanAlgebra c ℓ : Set (suc (c ⊔ ℓ)) where infix 8 ¬_ infixr 7 _∧_ infixr 6 _∨_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∨_ : Op₂ Carrier _∧_ : Op₂ Carrier ¬_ : Op₁ Carrier ⊤ : Carrier ⊥ : Carrier isBooleanAlgebra : IsBooleanAlgebra _≈_ _∨_ _∧_ ¬_ ⊤ ⊥ open IsBooleanAlgebra isBooleanAlgebra public distributiveLattice : DistributiveLattice _ _ distributiveLattice = record { isDistributiveLattice = isDistributiveLattice } open DistributiveLattice distributiveLattice public using (setoid; lattice) ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 1.0 RawSemigroup = RawMagma {-# WARNING_ON_USAGE RawSemigroup "Warning: RawSemigroup was deprecated in v1.0. Please use RawMagma instead." #-}
{ "alphanum_fraction": 0.5687403599, "avg_line_length": 26.1424731183, "ext": "agda", "hexsha": "13d39f625c0363b77aff940dcc8bcc8ef6a468f0", "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/Algebra/Bundles.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/Algebra/Bundles.agda", "max_line_length": 83, "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/Algebra/Bundles.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": 6186, "size": 19450 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Groups.Abelian.Definition open import Groups.Homomorphisms.Definition open import Setoids.Setoids open import Sets.EquivalenceRelations open import Rings.Definition open import Lists.Lists open import Rings.Homomorphisms.Definition module Rings.Polynomial.Ring {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) where open Ring R open Setoid S open Equivalence eq open import Groups.Polynomials.Group additiveGroup open import Groups.Polynomials.Definition additiveGroup open import Rings.Polynomial.Multiplication R polyRing : Ring naivePolySetoid _+P_ _*P_ Ring.additiveGroup polyRing = polyGroup Ring.*WellDefined polyRing {a} {b} {c} {d} = *PwellDefined {a} {b} {c} {d} Ring.1R polyRing = 1R :: [] Ring.groupIsAbelian polyRing {x} {y} = AbelianGroup.commutative (abelian (record { commutative = Ring.groupIsAbelian R })) {x} {y} Ring.*Associative polyRing {a} {b} {c} = *Passoc {a} {b} {c} Ring.*Commutative polyRing {a} {b} = p*Commutative {a} {b} Ring.*DistributesOver+ polyRing {a} {b} {c} = *Pdistrib {a} {b} {c} Ring.identIsIdent polyRing {a} = *Pident {a} polyInjectionIsHom : RingHom R polyRing polyInjection RingHom.preserves1 polyInjectionIsHom = reflexive ,, record {} RingHom.ringHom polyInjectionIsHom = reflexive ,, (reflexive ,, record {}) GroupHom.groupHom (RingHom.groupHom polyInjectionIsHom) = reflexive ,, record {} GroupHom.wellDefined (RingHom.groupHom polyInjectionIsHom) = SetoidInjection.wellDefined polyInjectionIsInj
{ "alphanum_fraction": 0.7514231499, "avg_line_length": 42.7297297297, "ext": "agda", "hexsha": "468bf5331bbe275e2fff218275debea9cd3f405a", "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": "Rings/Polynomial/Ring.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": "Rings/Polynomial/Ring.agda", "max_line_length": 130, "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": "Rings/Polynomial/Ring.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": 488, "size": 1581 }
{-# OPTIONS --safe #-} module Cubical.HITs.FreeGroupoid where open import Cubical.HITs.FreeGroupoid.Base public open import Cubical.HITs.FreeGroupoid.GroupoidActions public open import Cubical.HITs.FreeGroupoid.Properties public
{ "alphanum_fraction": 0.8268398268, "avg_line_length": 28.875, "ext": "agda", "hexsha": "e0318c8d04f1668f5f5c4df02cfec1b1b14db8da", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/HITs/FreeGroupoid.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/HITs/FreeGroupoid.agda", "max_line_length": 60, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/HITs/FreeGroupoid.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 57, "size": 231 }
{-# OPTIONS --cubical #-} module _ where open import Agda.Primitive.Cubical renaming (primINeg to ~_; primIMax to _∨_; primIMin to _∧_) open import Agda.Builtin.Cubical.Path open import Agda.Builtin.Cubical.Sub open import Agda.Builtin.Cubical.Sub using () renaming (Sub to _[_↦_]; primSubOut to ouc) open import Agda.Primitive renaming (_⊔_ to ℓ-max) open import Agda.Builtin.Sigma transpFill : ∀ {ℓ} {A' : Set ℓ} (φ : I) (A : (i : I) → Set ℓ [ φ ↦ (\ _ → A') ]) → (u0 : ouc (A i0)) → PathP (λ i → ouc (A i)) u0 (primTransp (λ i → ouc (A i)) φ u0) transpFill φ A u0 i = primTransp (\ j → ouc (A (i ∧ j))) (~ i ∨ φ) u0 -- private -- internalFiber : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B) (y : B) → Set (ℓ-max ℓ ℓ') -- internalFiber {A = A} f y = Σ A \ x → y ≡ f x -- infix 4 _≃_ -- postulate -- _≃_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Set (ℓ-max ℓ ℓ') -- equivFun : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} → A ≃ B → A → B -- equivProof : ∀ {la lt} (T : Set la) (A : Set lt) → (w : T ≃ A) → (a : A) -- → ∀ ψ → (Partial ψ (internalFiber (equivFun w) a)) → internalFiber (equivFun w) a -- {-# BUILTIN EQUIV _≃_ #-} -- {-# BUILTIN EQUIVFUN equivFun #-} -- {-# BUILTIN EQUIVPROOF equivProof #-} -- -- This is a module so we can easily rename the primitives. -- module GluePrims where -- primitive -- primGlue : ∀ {ℓ ℓ'} (A : Set ℓ) {φ : I} -- → (T : Partial φ (Set ℓ')) → (e : PartialP φ (λ o → T o ≃ A)) -- → Set ℓ' -- prim^glue : ∀ {ℓ ℓ'} {A : Set ℓ} {φ : I} -- → {T : Partial φ (Set ℓ')} → {e : PartialP φ (λ o → T o ≃ A)} -- → PartialP φ T → A → primGlue A T e -- prim^unglue : ∀ {ℓ ℓ'} {A : Set ℓ} {φ : I} -- → {T : Partial φ (Set ℓ')} → {e : PartialP φ (λ o → T o ≃ A)} -- → primGlue A T e → A -- -- Needed for transp in Glue. -- primFaceForall : (I → I) → I open import Agda.Builtin.Cubical.Glue public renaming ( prim^glue to glue ; prim^unglue to unglue) -- We uncurry Glue to make it a bit more pleasant to use Glue : ∀ {ℓ ℓ'} (A : Set ℓ) {φ : I} → (Te : Partial φ (Σ (Set ℓ') \ T → T ≃ A)) → Set ℓ' Glue A Te = primGlue A (λ x → Te x .fst) (λ x → Te x .snd) module TestHComp {ℓ ℓ'} (A : Set ℓ) {φ : I} (Te : Partial φ (Σ (Set ℓ') \ T → T ≃ A)) (ψ : I) (u : I → Partial ψ (Glue A Te)) (u0 : Sub (Glue A Te) ψ (u i0) ) where result : Glue A Te result = glue {φ = φ} (\ { (φ = i1) → primHComp {A = Te itIsOne .fst} u (primSubOut u0) }) (primHComp {A = A} (\ i → \ { (ψ = i1) → unglue {φ = φ} (u i itIsOne) ; (φ = i1) → equivFun (Te itIsOne .snd) (primHComp (\ j → \ { (ψ = i1) → u (i ∧ j) itIsOne ; (i = i0) → primSubOut u0 }) (primSubOut u0)) }) (unglue {φ = φ} (primSubOut u0))) test : primHComp {A = Glue A Te} {ψ} u (primSubOut u0) ≡ result test i = primHComp {A = Glue A Te} {ψ} u (primSubOut u0) module TestTransp {ℓ ℓ'} (A : Set ℓ) {φ : I} (Te : Partial φ (Σ (Set ℓ') \ T → T ≃ A)) (u0 : (Glue A Te)) where ψ = i0 a0 = unglue {φ = φ} u0 a1 = primComp (\ _ → A) φ (\ { i (φ = i1) → equivFun (Te itIsOne .snd) (transpFill {A' = Te itIsOne .fst} ψ (\ i → inc (Te itIsOne .fst)) u0 i) }) a0 pair : PartialP φ λ o → Helpers.fiber (Te o .snd .fst) a1 pair o = equivProof (Te o .fst) A (Te o .snd) a1 φ \ { (φ = i1) → _ , Helpers.refl } result : Glue A Te result = glue {φ = φ} (λ o → pair o .fst) (primHComp (\ { j (φ = i1) → pair itIsOne .snd j}) a1) test : primTransp (\ _ → Glue A Te) ψ u0 ≡ result test = Helpers.refl
{ "alphanum_fraction": 0.4687579054, "avg_line_length": 43.4395604396, "ext": "agda", "hexsha": "9e265f7df66723521e48e4b48991e55e9983298e", "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": "98d6f195fe672e54ef0389b4deb62e04e3e98327", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "caryoscelus/agda", "max_forks_repo_path": "test/Succeed/Issue3399.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "98d6f195fe672e54ef0389b4deb62e04e3e98327", "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": "caryoscelus/agda", "max_issues_repo_path": "test/Succeed/Issue3399.agda", "max_line_length": 129, "max_stars_count": null, "max_stars_repo_head_hexsha": "98d6f195fe672e54ef0389b4deb62e04e3e98327", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "caryoscelus/agda", "max_stars_repo_path": "test/Succeed/Issue3399.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1520, "size": 3953 }
module #2 where open import Data.Product open import Data.Sum open import Relation.Binary.PropositionalEquality {- Exercise 1.2. Derive the recursion principle for products recA×B using only the projections, and verify that the definitional equalities are valid. Do the same for Σ-types. -} module Products { a b c }{A : Set a}{B : Set b}{C : Set c}(g : A → B → C) where recₓ : A × B → C recₓ x = g (proj₁ x) (proj₂ x) rec-β : (x : A)(y : B) → recₓ (x , y) ≡ g x y rec-β x y = refl module Sums { a b c }{A : Set a}{B : A → Set b}{C : Set c}(g : (x : A) → B x → C) where rec-Σ : Σ A B → C rec-Σ x = g (proj₁ x) (proj₂ x) rec-Σ-β : (x : A)(y : B x) → rec-Σ (x , y) ≡ g x y rec-Σ-β x y = refl
{ "alphanum_fraction": 0.5905292479, "avg_line_length": 26.5925925926, "ext": "agda", "hexsha": "04468b9c261cb5747e68831bdee00ed4ad1dc9fc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CodaFi/HoTT-Exercises", "max_forks_repo_path": "Chapter1/#2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CodaFi/HoTT-Exercises", "max_issues_repo_path": "Chapter1/#2.agda", "max_line_length": 96, "max_stars_count": null, "max_stars_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CodaFi/HoTT-Exercises", "max_stars_repo_path": "Chapter1/#2.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 289, "size": 718 }
module kiss where open import string open import list open import bool open import relations open import product open import unit data formula : Set where $ : string → formula True : formula Implies : formula → formula → formula And : formula → formula → formula ctxt : Set ctxt = 𝕃 formula data _⊢_ : ctxt → formula → Set where Assume : ∀{Γ f} → (f :: Γ) ⊢ f Weaken : ∀{Γ f f'} → Γ ⊢ f → (f' :: Γ) ⊢ f ImpliesI : ∀{Γ f1 f2} → (f1 :: Γ) ⊢ f2 → Γ ⊢ (Implies f1 f2) ImpliesE : ∀{Γ f1 f2} → Γ ⊢ (Implies f1 f2) → Γ ⊢ f1 → Γ ⊢ f2 TrueI : ∀{Γ} → Γ ⊢ True AndI : ∀{Γ f1 f2} → Γ ⊢ f1 → Γ ⊢ f2 → Γ ⊢ (And f1 f2) AndE : ∀(b : 𝔹){Γ f1 f2} → Γ ⊢ (And f1 f2) → Γ ⊢ (if b then f1 else f2) {- p : formula p = $ "p" f1 : (p :: []) ⊢ p f1 = assume {[]}{p} f2 : (p :: []) ⊢ (And p p) f2 = AndI f1 f1 f3 : [] ⊢ (Implies p (And p p)) f3 = ImpliesI f2 -} record struct : Set1 where field W : Set R : W → W → Set preorderR : preorder R V : W → string → Set monoV : ∀{w w'} → R w w' → ∀{i} → V w i → V w' i reflR : reflexive R reflR = fst preorderR transR : transitive R transR = snd preorderR data world : Set where w0 : world w1 : world w2 : world data rel : world → world → Set where r00 : rel w0 w0 r11 : rel w1 w1 r22 : rel w2 w2 r01 : rel w0 w1 r02 : rel w0 w2 rel-refl : reflexive rel rel-refl {w0} = r00 rel-refl {w1} = r11 rel-refl {w2} = r22 rel-trans : transitive rel rel-trans r00 r00 = r00 rel-trans r00 r01 = r01 rel-trans r00 r02 = r02 rel-trans r11 r11 = r11 rel-trans r22 r22 = r22 rel-trans r01 r11 = r01 rel-trans r02 r22 = r02 data val : world → string → Set where v1p : val w1 "p" v1q : val w1 "q" v2p : val w2 "p" v2q : val w2 "q" mono-val : ∀{w w'} → rel w w' → ∀{i} → val w i → val w' i mono-val r00 p = p mono-val r11 p = p mono-val r22 p = p mono-val r01 () mono-val r02 () k : struct k = record { W = world ; R = rel ; preorderR = (rel-refl , rel-trans) ; V = val ; monoV = mono-val } open struct _,_⊨_ : ∀(k : struct) → W k → formula → Set k , w ⊨ ($ x) = V k w x k , w ⊨ True = ⊤ k , w ⊨ Implies f1 f2 = ∀ {w' : W k} → R k w w' → k , w' ⊨ f1 → k , w' ⊨ f2 k , w ⊨ And f1 f2 = k , w ⊨ f1 ∧ k , w ⊨ f2 pf-test-sem : k , w0 ⊨ Implies ($ "p") ($ "q") pf-test-sem r00 () pf-test-sem r01 p = v1q pf-test-sem r02 p = v2q _,_⊨ctxt_ : ∀(k : struct) → W k → ctxt → Set k , w ⊨ctxt [] = ⊤ k , w ⊨ctxt (f :: Γ) = (k , w ⊨ f) ∧ (k , w ⊨ctxt Γ) mono⊨ : ∀{k : struct}{w1 w2 : W k}{f : formula} → R k w1 w2 → k , w1 ⊨ f → k , w2 ⊨ f mono⊨{k} {f = $ x} r p = monoV k r p mono⊨{k} {f = True} r p = triv mono⊨{k} {f = Implies f1 f2} r p r' p' = p (transR k r r') p' mono⊨{k} {f = And f1 f2} r (p1 , p2) = mono⊨{f = f1} r p1 , mono⊨{f = f2} r p2 mono⊨ctxt : ∀{k : struct}{Γ : ctxt}{w1 w2 : W k} → R k w1 w2 → k , w1 ⊨ctxt Γ → k , w2 ⊨ctxt Γ mono⊨ctxt{k}{[]} _ _ = triv mono⊨ctxt{k}{f :: Γ} r (u , v) = mono⊨{k}{f = f} r u , mono⊨ctxt{k}{Γ} r v _⊩_ : ctxt → formula → Set1 Γ ⊩ f = ∀{k : struct}{w : W k} → k , w ⊨ctxt Γ → k , w ⊨ f Soundness : ∀{Γ : ctxt}{f : formula} → Γ ⊢ f → Γ ⊩ f Soundness Assume g = fst g Soundness (Weaken p) g = Soundness p (snd g) Soundness (ImpliesI p) g r u' = Soundness p (u' , mono⊨ctxt r g) Soundness (ImpliesE p p') {k} g = (Soundness p g) (reflR k) (Soundness p' g) Soundness TrueI g = triv Soundness (AndI p p') g = (Soundness p g , Soundness p' g) Soundness (AndE tt p) g = fst (Soundness p g) Soundness (AndE ff p) g = snd (Soundness p g) data _≼_ : 𝕃 formula → 𝕃 formula → Set where ≼-refl : ∀{Γ} → Γ ≼ Γ ≼-cons : ∀{Γ Γ' f} → Γ ≼ Γ' → Γ ≼ (f :: Γ') ≼-trans : ∀ {Γ Γ' Γ''} → Γ ≼ Γ' → Γ' ≼ Γ'' → Γ ≼ Γ'' ≼-trans u ≼-refl = u ≼-trans u (≼-cons u') = ≼-cons (≼-trans u u') Weaken≼ : ∀ {Γ Γ'}{f : formula} → Γ ≼ Γ' → Γ ⊢ f → Γ' ⊢ f Weaken≼ ≼-refl p = p Weaken≼ (≼-cons d) p = Weaken (Weaken≼ d p) U : struct U = record { W = ctxt ; R = _≼_ ; preorderR = ≼-refl , ≼-trans ; V = λ Γ n → Γ ⊢ $ n ; monoV = λ d p → Weaken≼ d p } CompletenessU : ∀{f : formula}{Γ : W U} → U , Γ ⊨ f → Γ ⊢ f SoundnessU : ∀{f : formula}{Γ : W U} → Γ ⊢ f → U , Γ ⊨ f CompletenessU {$ x} u = u CompletenessU {True} u = TrueI CompletenessU {And f f'} u = AndI (CompletenessU{f} (fst u)) (CompletenessU{f'} (snd u)) CompletenessU {Implies f f'}{Γ} u = ImpliesI (CompletenessU {f'} (u (≼-cons ≼-refl) (SoundnessU {f} (Assume {Γ})))) SoundnessU {$ x} p = p SoundnessU {True} p = triv SoundnessU {And f f'} p = SoundnessU{f} (AndE tt p) , SoundnessU{f'} (AndE ff p) SoundnessU {Implies f f'} p r u = SoundnessU (ImpliesE (Weaken≼ r p) (CompletenessU {f} u)) ctxt-id : ∀{Γ : ctxt} → U , Γ ⊨ctxt Γ ctxt-id{[]} = triv ctxt-id{f :: Γ} = SoundnessU{f} Assume , mono⊨ctxt (≼-cons ≼-refl) (ctxt-id {Γ}) Completeness : ∀{Γ : ctxt}{f : formula} → Γ ⊩ f → Γ ⊢ f Completeness{Γ} p = CompletenessU (p{U}{Γ} (ctxt-id{Γ})) Universality1 : ∀{Γ : ctxt}{f : formula} → Γ ⊩ f → U , Γ ⊨ f Universality1{Γ}{f} p = SoundnessU (Completeness{Γ}{f} p) Universality2 : ∀{Γ : ctxt}{f : formula} → U , Γ ⊨ f → Γ ⊩ f Universality2{Γ}{f} p = Soundness (CompletenessU{f}{Γ} p) nbe : ∀ {Γ f} → Γ ⊢ f → Γ ⊢ f nbe {Γ} p = Completeness (Soundness p)
{ "alphanum_fraction": 0.5185048794, "avg_line_length": 27.9948453608, "ext": "agda", "hexsha": "ef49006e24df309f999cea2dde6bde4c77eea278", "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": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "logicshan/IAL", "max_forks_repo_path": "kiss.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "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": "logicshan/IAL", "max_issues_repo_path": "kiss.agda", "max_line_length": 91, "max_stars_count": null, "max_stars_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "logicshan/IAL", "max_stars_repo_path": "kiss.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2405, "size": 5431 }
{-# OPTIONS --without-K #-} module Main where open import Data.List open import Midi open import Note open import Frog open import Piston main : IO Unit main = let channel = 0 ticksPerBeat = 4 -- 16th notes file = "/tmp/test.mid" -- counterpoint song = cfcpTracks1 -- song = cfcpTracks2 -- harmony -- song = testHTracks in exportTracks file ticksPerBeat (map track→htrack song)
{ "alphanum_fraction": 0.6172566372, "avg_line_length": 18.8333333333, "ext": "agda", "hexsha": "1afd70eb3edd3dc8f8106a2004bd13a0ea23f3f7", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2020-11-10T04:04:40.000Z", "max_forks_repo_forks_event_min_datetime": "2019-01-12T17:02:36.000Z", "max_forks_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "halfaya/MusicTools", "max_forks_repo_path": "doc/icfp20/code/Main.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_issues_repo_issues_event_max_datetime": "2020-11-17T00:58:55.000Z", "max_issues_repo_issues_event_min_datetime": "2020-11-13T01:26:20.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "halfaya/MusicTools", "max_issues_repo_path": "doc/icfp20/code/Main.agda", "max_line_length": 59, "max_stars_count": 28, "max_stars_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "halfaya/MusicTools", "max_stars_repo_path": "doc/icfp20/code/Main.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T18:04:07.000Z", "max_stars_repo_stars_event_min_datetime": "2017-04-21T09:08:52.000Z", "num_tokens": 120, "size": 452 }
module x1-Base where data List (X : Set) : Set where [] : List X _∷_ : X → List X → List X infixr 5 _∷_ foldr : ∀ {A} {B : Set} → (A → B → B) → B → List A → B foldr f b [] = b foldr f b (a ∷ as) = f a (foldr f b as) data Either (A : Set) (B : Set) : Set where left : A → Either A B right : B → Either A B [_,_] : ∀ {A B} {C : Set} → (A → C) → (B → C) → Either A B → C [ f , g ] (left x) = f x [ f , g ] (right x) = g x -- Unhabited type data Empty : Set where absurd : {X : Set} → Empty → X absurd () -- use Empty to define something close to negation in logic: -- e.g., terms of type ¬ (3 > 4) infix 3 ¬_ ¬_ : Set → Set ¬ X = X → Empty -- binary relation on a type X Rel : Set → Set₁ Rel X = X → X → Set -- decidable relations Decidable : ∀ {X} → Rel X → Set Decidable R = ∀ x y → Either (R x y) (¬ (R x y)) -- To sort a list, need two relations on elements of list: -- equality record Equivalence {X} (_≈_ : Rel X) : Set₁ where field refl : ∀ {x} → x ≈ x sym : ∀ {x y} → x ≈ y → y ≈ x trans : ∀ {x y z} → x ≈ y → y ≈ z → x ≈ z -- and ordering record TotalOrder {X} (_≈_ : Rel X) (_≤_ : Rel X) : Set₁ where field antisym : ∀ {x y} → x ≤ y → y ≤ x → x ≈ y trans : ∀ {x y z} → x ≤ y → y ≤ z → x ≤ z total : ∀ x y → Either (x ≤ y) (y ≤ x) reflexive : ∀ {x y} → x ≈ y → x ≤ y equivalence : Equivalence _≈_
{ "alphanum_fraction": 0.4936440678, "avg_line_length": 24.8421052632, "ext": "agda", "hexsha": "5d0bd29ff54962c7131835407ac63a686ec39745", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/topic/order/2013-04-01-sorting-francesco-mazzo/x1-Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/topic/order/2013-04-01-sorting-francesco-mazzo/x1-Base.agda", "max_line_length": 62, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/topic/order/2013-04-01-sorting-francesco-mazzo/x1-Base.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "num_tokens": 573, "size": 1416 }
import Lvl open import Structure.Operator.Vector open import Structure.Setoid open import Type module Structure.Operator.Vector.Subspaces.Span {ℓᵥ ℓₛ ℓᵥₑ ℓₛₑ} {V : Type{ℓᵥ}} ⦃ equiv-V : Equiv{ℓᵥₑ}(V) ⦄ {S : Type{ℓₛ}} ⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄ {_+ᵥ_ : V → V → V} {_⋅ₛᵥ_ : S → V → V} {_+ₛ_ _⋅ₛ_ : S → S → S} ⦃ vectorSpace : VectorSpace(_+ᵥ_)(_⋅ₛᵥ_)(_+ₛ_)(_⋅ₛ_) ⦄ where open VectorSpace(vectorSpace) open import Logic.Predicate open import Numeral.CoordinateVector as Vec using () renaming (Vector to Vec) open import Numeral.Finite open import Numeral.Natural open import Sets.ExtensionalPredicateSet as PredSet using (PredSet ; _∈_ ; [∋]-binaryRelator) open import Structure.Container.SetLike using (SetElement) private open module SetLikeFunctionProperties{ℓ} = Structure.Container.SetLike.FunctionProperties{C = PredSet{ℓ}(V)}{E = V}(_∈_) open import Structure.Function.Multi open import Structure.Operator open import Structure.Operator.Vector.LinearCombination ⦃ vectorSpace = vectorSpace ⦄ open import Structure.Operator.Vector.LinearCombination.Proofs open import Structure.Operator.Vector.Subspace ⦃ vectorSpace = vectorSpace ⦄ open import Structure.Relator.Properties open import Syntax.Function open import Syntax.Transitivity private variable n : ℕ private variable vf : Vec(n)(V) private variable sf : Vec(n)(S) Span : Vec(n)(V) → PredSet(V) Span(vf) = PredSet.⊶(linearCombination(vf)) Span-subspace : ∀{vf} → Subspace(Span{n}(vf)) ∃.witness (_closed-under₂_.proof (Subspace.add-closure (Span-subspace {vf = vf})) ([∃]-intro sf₁) ([∃]-intro sf₂)) = Vec.map₂(_+ₛ_) sf₁ sf₂ ∃.proof (_closed-under₂_.proof (Subspace.add-closure (Span-subspace {vf = vf})) {v₁} {v₂} ([∃]-intro sf₁ ⦃ p₁ ⦄) ([∃]-intro sf₂ ⦃ p₂ ⦄)) = linearCombination vf (Vec.map₂(_+ₛ_) sf₁ sf₂) 🝖[ _≡_ ]-[ preserving₂(linearCombination vf) (Vec.map₂(_+ₛ_)) (_+ᵥ_) ] (linearCombination vf sf₁) +ᵥ (linearCombination vf sf₂) 🝖[ _≡_ ]-[ congruence₂(_+ᵥ_) ⦃ [+ᵥ]-binary-operator ⦄ p₁ p₂ ] v₁ +ᵥ v₂ 🝖-end ∃.witness (_closed-under₁_.proof (Subspace.mul-closure Span-subspace {s}) ([∃]-intro sf)) = Vec.map(s ⋅ₛ_) sf ∃.proof (_closed-under₁_.proof (Subspace.mul-closure (Span-subspace {vf = vf}) {s}) {v} ([∃]-intro sf ⦃ p ⦄)) = linearCombination vf (i ↦ s ⋅ₛ sf(i)) 🝖[ _≡_ ]-[ preserving₁(linearCombination vf) (Vec.map(s ⋅ₛ_)) (s ⋅ₛᵥ_) ] s ⋅ₛᵥ (linearCombination vf sf) 🝖[ _≡_ ]-[ congruence₂ᵣ(_⋅ₛᵥ_)(s) p ] s ⋅ₛᵥ v 🝖-end
{ "alphanum_fraction": 0.66849745, "avg_line_length": 49.0192307692, "ext": "agda", "hexsha": "3afecab506b438071d63829fd855a184b1d385e4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Operator/Vector/Subspaces/Span.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Operator/Vector/Subspaces/Span.agda", "max_line_length": 139, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Operator/Vector/Subspaces/Span.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": 955, "size": 2549 }
module Examples.Effects where open import Prelude open import Effects.Denotational open import Effects.WellTyped EC _ec≟_ open import Effects.Substitutions EC _ec≟_ open import Implicits.Calculus.Types -- value abstraction module ex₁ where f : Term 0 0 0 f = λ' unit (does io) -- a lazy print is pure, but has a latent effect IO ⊢f : [] ⊢ f ∈ unit →[ has io & pure ] unit + pure ⊢f = λ' unit (does io) -- when we apply the above term -- the latent effect pops up f·t : Term 0 0 0 f·t = f · tt ⊢f·t : [] ⊢ f·t ∈ unit + has io & pure ⊢f·t = ⊢f · tt -- effect abstraction module ex₂ where f : Term 0 0 0 f = H (Λ (Λ ( λ' (tvar zero →[ evar zero & pure ] tvar (suc zero)) (λ' (tvar zero) ((var (suc zero)) · (var zero))) ))) wt-f : [] ⊢ f ∈ H (∀' (∀' (( tvar zero →[ evar zero & pure ] tvar (suc zero)) →[ pure ] (tvar zero →[ evar zero & pure ] (tvar (suc zero))) ))) + pure wt-f = H (Λ (Λ (λ' (tvar zero →[ evar zero & pure ] tvar (suc zero)) (λ' (tvar zero) (var (suc zero) · var zero))))) module ex₃ where eff : Effects 0 eff = (has io) & (has read) & pure -- lists of effects transtlate to tuples of Can* test : ⟦ eff , ([] , []) ⟧efs ≡ C.rec (tc CanIO ∷ tc CanRead ∷ []) test = refl module ex₄ where f : Term 0 0 0 f = Λ (λ' unit (does io)) wt-f : [] ⊢ f ∈ (∀' (unit →[ has io & pure ] unit)) + pure wt-f = Λ (λ' unit (does io)) test : ⟦ wt-f , ([] , []) ⟧ ≡ C.Λ (C.λ' (tc unit) ((C.ρ (tc CanIO) ((C.ρ (tc CanIO) (C.new unit)) C.⟨⟩)))) test = refl module ex₅ where open ex₄ tapp : Term 0 0 0 tapp = f [ unit ] wt-tapp : [] ⊢ tapp ∈ (unit →[ has io & pure ] unit) + pure wt-tapp = wt-f [ unit ] app : Term 0 0 0 app = tapp · tt wt-app : [] ⊢ app ∈ unit + has io & pure wt-app = wt-tapp · tt
{ "alphanum_fraction": 0.5441657579, "avg_line_length": 23.2151898734, "ext": "agda", "hexsha": "90c2b4107b3dc44ef02e83cb8c6e68fb105535f9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Examples/Effects.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Examples/Effects.agda", "max_line_length": 80, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Examples/Effects.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 727, "size": 1834 }
{-# OPTIONS --allow-unsolved-metas #-} open import Agda.Builtin.Size mutual data Nat (i : Size) : Set where zero : Nat i suc : Nat′ i → Nat i data Nat′ (i : Size) : Set where [_] : {j : Size< i} → Nat j → Nat′ i size : ∀ {i} → Nat′ i → Size size ([_] {j} _) = {!j!} unbox : ∀ {i} (n : Nat′ i) → Nat (size n) unbox [ n ] = n postulate _ _ _ _ _ _ : Set
{ "alphanum_fraction": 0.5172413793, "avg_line_length": 17.9523809524, "ext": "agda", "hexsha": "93d9170cc805bb21d9a6b3a7d92cc47d332ccd76", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-09-15T14:36:15.000Z", "max_forks_repo_forks_event_min_datetime": "2015-09-15T14:36:15.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue2917.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue2917.agda", "max_line_length": 41, "max_stars_count": 2, "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/Issue2917.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 148, "size": 377 }
{-# OPTIONS --universe-polymorphism #-} module InstanceArguments.09-higherOrderClasses where open import Effect.Applicative open import Effect.Monad open import Effect.Monad.Indexed open import Function lift : ∀ {a b c} {A : Set a} {C : Set c} {B : A → Set b} → ({{x : A}} → B x) → (f : C → A) → {{x : C}} → B (f x) lift m f {{x}} = m {{f x}} monadToApplicative : ∀ {l} {M : Set l → Set l} → RawMonad M → RawApplicative M monadToApplicative = RawIMonad.rawIApplicative liftAToM : ∀ {l} {V : Set l} {M : Set l → Set l} → ({{appM : RawApplicative M}} → M V) → {{monadM : RawMonad M}} → M V liftAToM app {{x}} = lift (λ {{appM}} → app {{appM}}) monadToApplicative {{x}}
{ "alphanum_fraction": 0.6028985507, "avg_line_length": 34.5, "ext": "agda", "hexsha": "433d951b5d1f4a0abedd0f7804fa38a6d10d1436", "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/LibSucceed/InstanceArguments/09-higherOrderClasses.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/LibSucceed/InstanceArguments/09-higherOrderClasses.agda", "max_line_length": 88, "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/LibSucceed/InstanceArguments/09-higherOrderClasses.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 245, "size": 690 }
module Data.Dyck.Sized where open import Prelude open import Data.Nat using (_+_) open import Data.Vec.Iterated using (Vec; _∷_; []; foldlN; head; foldl′) open import Cubical.Foundations.Prelude using (substRefl) open import Cubical.Data.Sigma.Properties using (Σ≡Prop) open import Data.Nat.Properties using (isSetℕ) private variable n m k : ℕ n⊙ m⊙ k⊙ : ℕ → ℕ -------------------------------------------------------------------------------- -- Tree -------------------------------------------------------------------------------- data Tree : Type where ⟨⟩ : Tree _*_ : Tree → Tree → Tree size⊙ : Tree → ℕ → ℕ size⊙ ⟨⟩ = suc size⊙ (xs * ys) = size⊙ xs ∘ size⊙ ys size : Tree → ℕ size t = size⊙ t zero -------------------------------------------------------------------------------- -- Dyck Word -------------------------------------------------------------------------------- infixr 6 ⟨_ ⟩_ data Dyck : ℕ → ℕ → Type where ⟩! : Dyck 1 0 ⟨_ : Dyck (1 + n) m → Dyck n (1 + m) ⟩_ : Dyck (1 + n) m → Dyck (2 + n) m -------------------------------------------------------------------------------- -- Tree to Stack -------------------------------------------------------------------------------- tree→stack⊙ : (t : Tree) → Dyck (suc m) k → Dyck m (size⊙ t k) tree→stack⊙ ⟨⟩ = ⟨_ tree→stack⊙ (xs * ys) = tree→stack⊙ xs ∘ tree→stack⊙ ys ∘ ⟩_ tree→stack : (t : Tree) → Dyck 0 (size t) tree→stack tr = tree→stack⊙ tr ⟩! -------------------------------------------------------------------------------- -- Stack to Tree -------------------------------------------------------------------------------- stack→tree⊙ : Dyck n m → Vec Tree n → Tree stack→tree⊙ ⟩! (v ∷ []) = v stack→tree⊙ (⟨ is) st = stack→tree⊙ is (⟨⟩ ∷ st) stack→tree⊙ (⟩ is) (t₁ ∷ t₂ ∷ st) = stack→tree⊙ is (t₂ * t₁ ∷ st) stack→tree : Dyck 0 n → Tree stack→tree ds = stack→tree⊙ ds [] -------------------------------------------------------------------------------- -- Size lemma -------------------------------------------------------------------------------- stack→tree-size⊙ : {st : Vec Tree n} (is : Dyck n m) → size (stack→tree⊙ is st) ≡ foldl′ size⊙ m st stack→tree-size⊙ ⟩! = refl stack→tree-size⊙ (⟨ is) = stack→tree-size⊙ is stack→tree-size⊙ (⟩ is) = stack→tree-size⊙ is -------------------------------------------------------------------------------- -- Roundtrip -------------------------------------------------------------------------------- tree→stack→tree⊙ : {is : Dyck (1 + n) m} {st : Vec Tree n} (e : Tree) → stack→tree⊙ (tree→stack⊙ e is) st ≡ stack→tree⊙ is (e ∷ st) tree→stack→tree⊙ ⟨⟩ = refl tree→stack→tree⊙ (xs * ys) = tree→stack→tree⊙ xs ; tree→stack→tree⊙ ys foldlNN : ∀ {A : Type a} {p} (P : ℕ → ℕ → Type p) → (f : A → ℕ → ℕ) → (∀ {n m} → (x : A) → P (suc n) m → P n (f x m)) → P n m → (xs : Vec A n) → P zero (foldl′ f m xs) foldlNN {n = zero} P f s b xs = b foldlNN {n = suc n} P f s b (x ∷ xs) = foldlNN P f s (s x b) xs stack→tree→stack⊙ : {st : Vec Tree n} (is : Dyck n m) → subst (Dyck 0) (stack→tree-size⊙ is) (tree→stack (stack→tree⊙ is st)) ≡ foldlNN Dyck size⊙ tree→stack⊙ is st stack→tree→stack⊙ ⟩! = substRefl {B = Dyck 0} _ stack→tree→stack⊙ (⟨ is) = stack→tree→stack⊙ is stack→tree→stack⊙ (⟩ is) = stack→tree→stack⊙ is -------------------------------------------------------------------------------- -- Isomorphism -------------------------------------------------------------------------------- STree : ℕ → Type STree = fiber size tree-stack : STree n ⇔ Dyck 0 n tree-stack .fun (t , n) = subst (Dyck 0) n (tree→stack t) tree-stack .inv st .fst = stack→tree st tree-stack .inv st .snd = stack→tree-size⊙ st tree-stack .leftInv (t , sz≡) = Σ≡Prop (λ _ → isSetℕ _ _) (J (λ n sz≡ → stack→tree (subst (Dyck 0) sz≡ (tree→stack t)) ≡ t) (cong stack→tree (substRefl {B = Dyck 0} (tree→stack t)) ; tree→stack→tree⊙ t) sz≡) tree-stack .rightInv st = stack→tree→stack⊙ st -------------------------------------------------------------------------------- -- Finite -------------------------------------------------------------------------------- open import Data.List support-dyck : ∀ n m → List (Dyck n m) support-dyck = λ n m → sup-k n m id [] module ListDyck where Diff : Type → Type₁ Diff A = ∀ {B : Type} → (A → B) → List B → List B infixr 5 _++′_ _++′_ : Diff A → Diff A → Diff A xs ++′ ys = λ k → xs k ∘ ys k mutual sup-k : ∀ n m → Diff (Dyck n m) sup-k n m = end n m ++′ lefts n m ++′ rights n m lefts : ∀ n m → Diff (Dyck n m) lefts n zero k = id lefts n (suc m) k = sup-k (suc n) m (k ∘ ⟨_) rights : ∀ n m → Diff (Dyck n m) rights (suc (suc n)) m k = sup-k (suc n) m (k ∘ ⟩_) rights _ m k = id end : ∀ n m → Diff (Dyck n m) end 1 0 k xs = k ⟩! ∷ xs end _ _ k = id open import Data.List.Membership open import Data.Fin cover-dyck : (x : Dyck n m) → x ∈ support-dyck n m cover-dyck x = go _ _ x id [] where open ListDyck mutual pushLefts : ∀ n m (k : Dyck n m → B) x xs → x ∈ xs → x ∈ lefts n m k xs pushLefts n (suc m) k = pushSup (suc n) m (λ z → k (⟨ z)) pushLefts _ zero k x xs p = p pushEnd : ∀ n m (k : Dyck n m → B) x xs → x ∈ xs → x ∈ end n m k xs pushEnd 0 m k x xs p = p pushEnd 1 0 k x xs (i , p) = fs i , p pushEnd 1 (suc m) k x xs p = p pushEnd (suc (suc n)) m k x xs p = p pushRights : ∀ n m (k : Dyck n m → B) x xs → x ∈ xs → x ∈ rights n m k xs pushRights (suc (suc n)) m k = pushSup (suc n) m λ z → k (⟩ z) pushRights 1 _ _ _ _ p = p pushRights 0 _ _ _ _ p = p pushSup : ∀ n m (k : Dyck n m → B) x xs → x ∈ xs → x ∈ sup-k n m k xs pushSup n m k x xs p = pushEnd n m k x (lefts n m k (rights n m k xs)) (pushLefts n m k x (rights n m k xs) (pushRights n m k x xs p)) go : ∀ n m → (x : Dyck n m) → (k : Dyck n m → A) → (xs : List A) → k x ∈ sup-k n m k xs go .1 .0 ⟩! k xs = f0 , refl go 0 (suc m) (⟨ x) k xs = go 1 m x (k ∘ ⟨_) xs go 1 (suc m) (⟨ x) k xs = go 2 m x (k ∘ ⟨_) xs go (suc n@(suc _)) (suc m) (⟨ x) k xs = go (suc (suc n)) m x (k ∘ ⟨_) (rights (suc n) (suc m) k xs) go (suc n) m (⟩ x) k xs = let p = go n m x (k ∘ ⟩_) xs in pushEnd (suc n) m k (k (⟩ x)) (lefts (suc n) m k _) (pushLefts (suc n) m k (k (⟩ x)) (rights (suc n) m k xs) p)
{ "alphanum_fraction": 0.4319498825, "avg_line_length": 34.7010869565, "ext": "agda", "hexsha": "644a513ea4fd417e70e63e5120e26071575c6100", "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/Dyck/Sized.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/Dyck/Sized.agda", "max_line_length": 138, "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/Dyck/Sized.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": 2301, "size": 6385 }
module HelpDefs where -- open import Relation.Binary.PropositionalEquality open import StdLibStuff open import Syntax open import FSC open import STT open import DerivedProps m-weak-h : ∀ {n} Γ₁ Γ₂ {t} → {Γ₃ : Ctx n} → Form (Γ₃ ++ Γ₁) t → Form (Γ₃ ++ (Γ₂ r++ Γ₁)) t m-weak-h {n} Γ₁ ε = λ f → f m-weak-h {n} Γ₁ (t' ∷ Γ₂) {t} {Γ₃} = λ f → m-weak-h {n} (t' ∷ Γ₁) Γ₂ {t} {Γ₃} (weak-i Γ₃ Γ₁ f) m-weak2 : ∀ {n Γ₁} Γ₂ → {t : Type n} → Form Γ₁ t → Form (Γ₂ ++ Γ₁) t m-weak2 {n} {Γ₁} ε f = f m-weak2 {n} {Γ₁} (t' ∷ Γ₂) f = weak (m-weak2 {n} {Γ₁} Γ₂ f) hypos-i-h : ∀ {n Γ-t₁ Γ-t₂ Γ-t₃} → FSC-Ctx n Γ-t₁ → Form (Γ-t₃ ++ (Γ-t₂ r++ Γ-t₁)) $o → Form (Γ-t₃ ++ (Γ-t₂ r++ Γ-t₁)) $o hypos-i-h ε = λ f → f hypos-i-h {n} {Γ-t₁} {Γ-t₂} {Γ-t₃} (h ∷h Γ) = λ f → hypos-i-h {n} {Γ-t₁} {Γ-t₂} {Γ-t₃} Γ (m-weak-h Γ-t₁ Γ-t₂ {$o} {Γ-t₃} (m-weak2 Γ-t₃ h) => f) hypos-i-h {n} {.(t ∷ _)} {Γ-t₂} {Γ-t₃} (t ∷ Γ) = hypos-i-h {n} {_} {t ∷ Γ-t₂} {Γ-t₃} Γ m-weak : ∀ {n Γ₁ Γ₂ t} → Form Γ₁ t → Form (Γ₂ r++ Γ₁) t m-weak {n} {Γ₁} {Γ₂} {t} = m-weak-h {n} Γ₁ Γ₂ {t} {ε} hypos-i : ∀ {n Γ-t₁ Γ-t₂} → FSC-Ctx n Γ-t₁ → Form (Γ-t₂ r++ Γ-t₁) $o → Form (Γ-t₂ r++ Γ-t₁) $o hypos-i {n} {Γ-t₁} {Γ-t₂} = hypos-i-h {n} {Γ-t₁} {Γ-t₂} {ε} hypos : ∀ {n Γ-t} → FSC-Ctx n Γ-t → Form Γ-t $o → Form Γ-t $o hypos {n} {Γ-t} = hypos-i {n} {Γ-t} {ε} -- Props eq-1-i : ∀ {n} Γ₁ Γ₂ → (t : Type n) (X₁ : Form (t ∷ Γ₁) $o) (X₂ : Form Γ₁ $o) → X₁ ≡ weak-i {n} {$o} {t} ε Γ₁ X₂ → m-weak-h Γ₁ Γ₂ {$o} {t ∷ ε} X₁ ≡ weak-i {n} {$o} {t} ε (Γ₂ r++ Γ₁) (m-weak-h Γ₁ Γ₂ {$o} {ε} X₂) eq-1-i Γ₁ ε t X₁ X₂ = λ h → h eq-1-i Γ₁ (u ∷ Γ₂) t X₁ X₂ = λ h → eq-1-i (u ∷ Γ₁) Γ₂ t (weak-i {_} {$o} {u} (t ∷ ε) Γ₁ X₁) (weak-i {_} {$o} {u} ε Γ₁ X₂) (trans (cong (weak-i {_} {$o} {u} (t ∷ ε) Γ₁) h) (weak-weak-p-1 Γ₁ t u $o X₂)) eq-1 : ∀ {n} Γ₁ Γ₂ → (t : Type n) (X : Form Γ₁ $o) → m-weak-h Γ₁ Γ₂ {$o} {t ∷ ε} (weak-i {n} {$o} {t} ε Γ₁ X) ≡ weak-i {n} {$o} {t} ε (Γ₂ r++ Γ₁) (m-weak-h Γ₁ Γ₂ {$o} {ε} X) eq-1 Γ₁ Γ₂ t X = eq-1-i Γ₁ Γ₂ t (weak-i {_} {$o} {t} ε Γ₁ X) X refl eq-2-2 : ∀ n → (Γ-t Γ' : Ctx n) → (t : Type n) (X₁ : Form (t ∷ Γ-t) $o) (X₂ : Form Γ-t $o) → weak-i {n} {$o} {t} ε Γ-t X₂ ≡ X₁ → (h₂ : t ∷ (Γ' r++ Γ-t) ≡ (Γ' ++ (t ∷ ε)) r++ Γ-t) → m-weak-h Γ-t (Γ' ++ (t ∷ ε)) {$o} {ε} X₂ ≡ subst (λ z → Form z $o) h₂ (m-weak-h Γ-t Γ' {$o} {t ∷ ε} X₁) eq-2-2 n Γ-t ε t X₁ X₂ h refl = h eq-2-2 n Γ-t (u ∷ Γ') t X₁ X₂ h h₂ = eq-2-2 n (u ∷ Γ-t) Γ' t (weak-i {_} {$o} {u} (t ∷ ε) Γ-t X₁) (weak-i {_} {$o} {u} ε Γ-t X₂) ( trans (sym (weak-weak-p-1 Γ-t t u $o X₂)) (cong (weak-i {_} {$o} {u} (t ∷ ε) Γ-t) h)) h₂ eq-2-1 : ∀ n → (Γ-t Γ' : Ctx n) → (t : Type n) (h : Form Γ-t $o) (F : Form (t ∷ (Γ' r++ Γ-t)) $o) → (Γ'' : Ctx n) (h₁₁ : Γ'' ≡ (Γ' ++ (t ∷ ε)) r++ Γ-t) → (h₁₂ : t ∷ (Γ' r++ Γ-t) ≡ Γ'') → app (app A (app N (m-weak-h Γ-t (Γ' ++ (t ∷ ε)) {$o} {ε} h))) (subst (λ z → Form z $o) h₁₁ (subst (λ z → Form z $o) h₁₂ F)) ≡ subst (λ z → Form z $o) h₁₁ (app (app A (app N (subst (λ z → Form z $o) h₁₂ (m-weak-h Γ-t Γ' {$o} {t ∷ ε} (weak-i ε Γ-t h))))) (subst (λ z → Form z $o) h₁₂ F)) eq-2-1 n Γ-t Γ' t h F .((Γ' ++ (t ∷ ε)) r++ Γ-t) refl h₁₂ = cong (λ z → app (app A (app N z)) (subst (λ z → Form z $o) h₁₂ F)) (eq-2-2 n Γ-t Γ' t (weak-i {_} {$o} {t} ε Γ-t h) h refl h₁₂) eq-2-i : ∀ {n} Γ-t → (t : Type n) (Γ : FSC-Ctx n Γ-t) (Γ' : Ctx n) (F : Form (t ∷ (Γ' r++ Γ-t)) $o) → (h₁ : t ∷ (ε ++ (Γ' r++ Γ-t)) ≡ (Γ' ++ (t ∷ ε)) r++ Γ-t) → hypos-i-h {n} {Γ-t} {Γ' ++ (t ∷ ε)} {ε} Γ (subst (λ z → Form z $o) h₁ F) ≡ subst (λ z → Form z $o) h₁ (hypos-i-h {n} {Γ-t} {Γ'} {t ∷ ε} Γ F) eq-2-i .ε t ε Γ' F h₁ = refl eq-2-i .(u ∷ _) t (u ∷ Γ) Γ' F h₁ = eq-2-i _ t Γ (u ∷ Γ') F h₁ eq-2-i Γ-t t (h ∷h Γ) Γ' F h₁ = trans (cong (hypos-i-h {_} {Γ-t} {Γ' ++ (t ∷ ε)} {ε} Γ) (eq-2-1 _ Γ-t Γ' t h F _ h₁ refl)) (eq-2-i Γ-t t Γ Γ' (app (app A (app N (m-weak-h Γ-t Γ' {$o} {t ∷ ε} (weak-i ε Γ-t h)))) F) h₁) eq-2 : ∀ {n Γ-t} → (t : Type n) (Γ : FSC-Ctx n Γ-t) (F : Form (t ∷ Γ-t) $o) → hypos-i-h {n} {Γ-t} {t ∷ ε} {ε} Γ F ≡ hypos-i-h {n} {Γ-t} {ε} {t ∷ ε} Γ F eq-2 {_} {Γ-t} t Γ F = eq-2-i {_} Γ-t t Γ ε F refl traverse-hypos-i : ∀ {n Γ-t₁ Γ-t₂} → (F G : Form (Γ-t₂ r++ Γ-t₁) $o) (Γ : FSC-Ctx n Γ-t₁) → (⊢ (F => G)) → ⊢ (hypos-i {n} {Γ-t₁} {Γ-t₂} Γ F => hypos-i {n} {Γ-t₁} {Γ-t₂} Γ G) traverse-hypos-i F G ε h = h traverse-hypos-i {n} {Γ-t₁} {Γ-t₂} F G (X ∷h Γ) h = traverse-hypos-i {n} {Γ-t₁} {Γ-t₂} (m-weak {n} {Γ-t₁} {Γ-t₂} X => F) (m-weak {n} {Γ-t₁} {Γ-t₂} X => G) Γ (inf-V ax-4-s h) traverse-hypos-i {n} {.(t ∷ _)} {Γ-t₂} F G (t ∷ Γ) h = traverse-hypos-i {n} {_} {t ∷ Γ-t₂} F G Γ h traverse-hypos : ∀ {n Γ-t} → (F G : Form Γ-t $o) (Γ : FSC-Ctx n Γ-t) → (⊢ (F => G)) → ⊢ (hypos Γ F => hypos Γ G) traverse-hypos {n} {Γ-t} = traverse-hypos-i {n} {Γ-t} {ε} traverse-hypos-pair-I-i : ∀ {n Γ-t₁ Γ-t₂} → (F G : Form (Γ-t₂ r++ Γ-t₁) $o) (Γ : FSC-Ctx n Γ-t₁) → ⊢ (hypos-i {n} {Γ-t₁} {Γ-t₂} Γ F => (hypos-i {n} {Γ-t₁} {Γ-t₂} Γ G => hypos-i {n} {Γ-t₁} {Γ-t₂} Γ (F & G))) traverse-hypos-pair-I-i F G ε = lemb1 F G traverse-hypos-pair-I-i {n} {Γ-t₁} {Γ-t₂} F G (x ∷h Γ) = inf-V (inf-V (ax-4-s {_} {_} {(hypos-i {n} {Γ-t₁} {Γ-t₂} Γ (m-weak {n} {Γ-t₁} {Γ-t₂} x => G) => (hypos-i {n} {Γ-t₁} {Γ-t₂} Γ ((m-weak {n} {Γ-t₁} {Γ-t₂} x => F) & (m-weak {n} {Γ-t₁} {Γ-t₂} x => G))))}) (inf-V (ax-4-s {_} {_} {(hypos-i {n} {Γ-t₁} {Γ-t₂} Γ ((m-weak {n} {Γ-t₁} {Γ-t₂} x => F) & (m-weak {n} {Γ-t₁} {Γ-t₂} x => G)))}) (traverse-hypos-i {n} {Γ-t₁} {Γ-t₂} ((m-weak {n} {Γ-t₁} {Γ-t₂} x => F) & (m-weak {n} {Γ-t₁} {Γ-t₂} x => G)) (m-weak {n} {Γ-t₁} {Γ-t₂} x => (F & G)) Γ (lem2 (m-weak {n} {Γ-t₁} {Γ-t₂} x) F G)))) (traverse-hypos-pair-I-i {n} {Γ-t₁} {Γ-t₂} (m-weak {n} {Γ-t₁} {Γ-t₂} x => F) (m-weak {n} {Γ-t₁} {Γ-t₂} x => G) Γ) traverse-hypos-pair-I-i {n} {.(t ∷ _)} {Γ-t₂} F G (t ∷ Γ) = traverse-hypos-pair-I-i {n} {_} {t ∷ Γ-t₂} F G Γ traverse-hypos-pair-I : ∀ {n Γ-t} → (F G : Form Γ-t $o) (Γ : FSC-Ctx n Γ-t) → ⊢ (hypos Γ F => (hypos Γ G => hypos Γ (F & G))) traverse-hypos-pair-I {n} {Γ-t} = traverse-hypos-pair-I-i {n} {Γ-t} {ε} traverse-hypos-elim-i : ∀ {n Γ-t₁ Γ-t₂} → (F : Form (Γ-t₂ r++ Γ-t₁) $o) (Γ : FSC-Ctx n Γ-t₁) (x : HVar Γ) → ⊢ (hypos-i {n} {Γ-t₁} {Γ-t₂} Γ (m-weak {n} {Γ-t₁} {Γ-t₂} (lookup-hyp Γ x) => F) => hypos-i {n} {Γ-t₁} {Γ-t₂} Γ F) traverse-hypos-elim-i {n} {Γ-t₁} {Γ-t₂} F .(h ∷h Γ) (zero {._} {h} {Γ}) = traverse-hypos-i {n} {Γ-t₁} {Γ-t₂} (m-weak {n} {Γ-t₁} {Γ-t₂} h => (m-weak {n} {Γ-t₁} {Γ-t₂} h => F)) (m-weak {n} {Γ-t₁} {Γ-t₂} h => F) Γ (lem3 (m-weak {n} {Γ-t₁} {Γ-t₂} h) F) traverse-hypos-elim-i {n} {Γ-t₁} {Γ-t₂} F .(h ∷h Γ) (succ {._} {h} {Γ} x) = inf-V ax-3-s (inf-V (inf-V (ax-4-s {_} {_} {~ (hypos-i {n} {Γ-t₁} {Γ-t₂} Γ (m-weak {n} {Γ-t₁} {Γ-t₂} (lookup-hyp Γ x) => (m-weak {n} {Γ-t₁} {Γ-t₂} h => F)))}) (inf-V (lem5 (hypos-i {n} {Γ-t₁} {Γ-t₂} Γ (m-weak {n} {Γ-t₁} {Γ-t₂} h => (m-weak {n} {Γ-t₁} {Γ-t₂} (lookup-hyp Γ x) => F))) (hypos-i {n} {Γ-t₁} {Γ-t₂} Γ (m-weak {n} {Γ-t₁} {Γ-t₂} (lookup-hyp Γ x) => (m-weak {n} {Γ-t₁} {Γ-t₂} h => F)))) (traverse-hypos-i {n} {Γ-t₁} {Γ-t₂} (m-weak {n} {Γ-t₁} {Γ-t₂} h => (m-weak {n} {Γ-t₁} {Γ-t₂} (lookup-hyp Γ x) => F)) (m-weak {n} {Γ-t₁} {Γ-t₂} (lookup-hyp Γ x) => (m-weak {n} {Γ-t₁} {Γ-t₂} h => F)) Γ (lem4 (m-weak {n} {Γ-t₁} {Γ-t₂} h) (m-weak {n} {Γ-t₁} {Γ-t₂} (lookup-hyp Γ x)) F)))) (inf-V ax-3-s (traverse-hypos-elim-i {n} {Γ-t₁} {Γ-t₂} (m-weak {n} {Γ-t₁} {Γ-t₂} h => F) Γ x))) traverse-hypos-elim-i {n} {.(t ∷ _)} {Γ-t₂} F (t ∷ Γ) (skip x) = traverse-hypos-elim-i {n} {_} {t ∷ Γ-t₂} F Γ x traverse-hypos-elim : ∀ {n Γ-t} → (F : Form Γ-t $o) (Γ : FSC-Ctx n Γ-t) (x : HVar Γ) → ⊢ (hypos Γ (lookup-hyp Γ x => F) => hypos Γ F) traverse-hypos-elim {n} {Γ-t} = traverse-hypos-elim-i {n} {Γ-t} {ε} traverse-hypos-use-i : ∀ {n Γ-t₁ Γ-t₂} → (F : Form (Γ-t₂ r++ Γ-t₁) $o) (Γ : FSC-Ctx n Γ-t₁) → ⊢ (F) → ⊢ (hypos-i {n} {Γ-t₁} {Γ-t₂} Γ F) traverse-hypos-use-i F ε h = h traverse-hypos-use-i {n} {Γ-t₁} {Γ-t₂} F (X ∷h Γ) h = traverse-hypos-use-i {n} {Γ-t₁} {Γ-t₂} (m-weak {n} {Γ-t₁} {Γ-t₂} X => F) Γ (inf-V ax-3-s (inf-V ax-2-s h)) traverse-hypos-use-i {n} {.(t ∷ _)} {Γ-t₂} F (t ∷ Γ) h = traverse-hypos-use-i {n} {_} {t ∷ Γ-t₂} F Γ h traverse-hypos-use : ∀ {n Γ-t} → (F : Form Γ-t $o) (Γ : FSC-Ctx n Γ-t) → ⊢ (F) → ⊢ (hypos Γ F) traverse-hypos-use {n} {Γ-t} = traverse-hypos-use-i {n} {Γ-t} {ε} traverse-hypos2-i : ∀ {n Γ-t₁ Γ-t₂} → (F G H : Form (Γ-t₂ r++ Γ-t₁) $o) (Γ : FSC-Ctx n Γ-t₁) → (⊢ (F => (G => H))) → ⊢ (hypos-i {n} {Γ-t₁} {Γ-t₂} Γ F => (hypos-i {n} {Γ-t₁} {Γ-t₂}Γ G => hypos-i {n} {Γ-t₁} {Γ-t₂} Γ H)) traverse-hypos2-i F G H ε imp = imp traverse-hypos2-i {n} {Γ-t₁} {Γ-t₂} F G H (X ∷h Γ) imp = traverse-hypos2-i {n} {Γ-t₁} {Γ-t₂} (m-weak {n} {Γ-t₁} {Γ-t₂} X => F) (m-weak {n} {Γ-t₁} {Γ-t₂} X => G) (m-weak {n} {Γ-t₁} {Γ-t₂} X => H) Γ (inf-V (lem8 (m-weak {n} {Γ-t₁} {Γ-t₂} X) F G H) imp) traverse-hypos2-i {n} {.(t ∷ _)} {Γ-t₂} F G H (t ∷ Γ) imp = traverse-hypos2-i {n} {_} {t ∷ Γ-t₂} F G H Γ imp traverse-hypos2 : ∀ {n Γ-t} → (F G H : Form Γ-t $o) (Γ : FSC-Ctx n Γ-t) → (⊢ (F => (G => H))) → ⊢ (hypos Γ F => (hypos Γ G => hypos Γ H)) traverse-hypos2 {n} {Γ-t} = traverse-hypos2-i {n} {Γ-t} {ε} traverse-hypos3-i : ∀ {n Γ-t₁ Γ-t₂} → (F G H I : Form (Γ-t₂ r++ Γ-t₁) $o) (Γ : FSC-Ctx n Γ-t₁) → (⊢ (F => (G => (H => I)))) → ⊢ (hypos-i {n} {Γ-t₁} {Γ-t₂} Γ F => (hypos-i {n} {Γ-t₁} {Γ-t₂}Γ G => (hypos-i {n} {Γ-t₁} {Γ-t₂} Γ H => hypos-i {n} {Γ-t₁} {Γ-t₂} Γ I))) traverse-hypos3-i F G H I ε imp = imp traverse-hypos3-i {n} {Γ-t₁} {Γ-t₂} F G H I (X ∷h Γ) imp = traverse-hypos3-i {n} {Γ-t₁} {Γ-t₂} (m-weak {n} {Γ-t₁} {Γ-t₂} X => F) (m-weak {n} {Γ-t₁} {Γ-t₂} X => G) (m-weak {n} {Γ-t₁} {Γ-t₂} X => H) (m-weak {n} {Γ-t₁} {Γ-t₂} X => I) Γ (inf-V (lem8-3 (m-weak {n} {Γ-t₁} {Γ-t₂} X) F G H I) imp) traverse-hypos3-i {n} {.(t ∷ _)} {Γ-t₂} F G H I (t ∷ Γ) imp = traverse-hypos3-i {n} {_} {t ∷ Γ-t₂} F G H I Γ imp traverse-hypos3 : ∀ {n Γ-t} → (F G H I : Form Γ-t $o) (Γ : FSC-Ctx n Γ-t) → (⊢ (F => (G => (H => I)))) → ⊢ (hypos Γ F => (hypos Γ G => (hypos Γ H => hypos Γ I))) traverse-hypos3 {n} {Γ-t} = traverse-hypos3-i {n} {Γ-t} {ε} traverse-=>-I-dep-i : ∀ {n Γ-t₁ Γ-t₂} → (t : Type n) (F : Form (t ∷ (Γ-t₂ r++ Γ-t₁)) $o) (Γ : FSC-Ctx n Γ-t₁) → ⊢ (![ t ] hypos-i-h {n} {Γ-t₁} {Γ-t₂} {t ∷ ε} Γ F) → ⊢ (hypos-i {n} {Γ-t₁} {Γ-t₂} Γ (![ t ] F)) traverse-=>-I-dep-i t F ε h = h traverse-=>-I-dep-i {n} {Γ-t₁} {Γ-t₂} t F (X ∷h Γ) h = inf-V (traverse-hypos-i {n} {Γ-t₁} {Γ-t₂} (![ t ] (weak (m-weak {n} {Γ-t₁} {Γ-t₂} X) => F)) (m-weak {n} {Γ-t₁} {Γ-t₂} X => (![ t ] F)) Γ (ax-6-s {_} {_} {_} {~ (m-weak {n} {Γ-t₁} {Γ-t₂} X)} {F})) (traverse-=>-I-dep-i {n} {Γ-t₁} {Γ-t₂} t (weak (m-weak {n} {Γ-t₁} {Γ-t₂} X) => F) Γ (subst (λ z → ⊢_ {n} {_r++_ {n} Γ-t₂ Γ-t₁} (app {n} {_>_ {_} t ($o {_})} {$o {_}} {_r++_ {n} Γ-t₂ Γ-t₁} (Π {n} {t} {_r++_ {n} Γ-t₂ Γ-t₁}) (lam {n} {$o {_}} {_r++_ {n} Γ-t₂ Γ-t₁} t ((hypos-i-h {n} {Γ-t₁} {Γ-t₂} {_∷_ {_} t (ε {_})} Γ (_=>_ {_} {_∷_ {_} t (_r++_ {n} Γ-t₂ Γ-t₁)} z F)))))) (eq-1 {n} Γ-t₁ Γ-t₂ t X) h)) traverse-=>-I-dep-i {n} {.(t' ∷ _)} {Γ-t₂} t F (t' ∷ Γ) h = traverse-=>-I-dep-i {n} {_} {t' ∷ Γ-t₂} t F Γ h traverse-=>-I-dep : ∀ {n Γ-t} → (t : Type n) (F : Form (t ∷ Γ-t) $o) (Γ : FSC-Ctx n Γ-t) → ⊢ (![ t ] hypos (t ∷ Γ) F) → ⊢ (hypos Γ (![ t ] F)) traverse-=>-I-dep {n} {Γ-t} t F Γ h = traverse-=>-I-dep-i {n} {Γ-t} {ε} t F Γ (subst (λ z → ⊢ app Π (lam t (z))) (eq-2 t Γ F) h) traverse-=>-I-dep'-I2 : ∀ {n Γ-t₁ Γ-t₂} → (t : Type n) (F : Form (t ∷ (Γ-t₂ r++ Γ-t₁)) $o) (G : Form (Γ-t₂ r++ Γ-t₁) $o) (Γ : FSC-Ctx n Γ-t₁) → (⊢ (F => weak-i ε (Γ-t₂ r++ Γ-t₁) G)) → ⊢ (hypos-i-h {n} {Γ-t₁} {Γ-t₂} {t ∷ ε} Γ F => weak-i ε (Γ-t₂ r++ Γ-t₁) (hypos-i-h {n} {Γ-t₁} {Γ-t₂} {ε} Γ G)) traverse-=>-I-dep'-I2 t F G ε h = h traverse-=>-I-dep'-I2 {n} {t' ∷ Γ-t₁} {Γ-t₂} t F G (.t' ∷ Γ) h = traverse-=>-I-dep'-I2 {n} {Γ-t₁} {t' ∷ Γ-t₂} t F G Γ h traverse-=>-I-dep'-I2 {n} {Γ-t₁} {Γ-t₂} t F G (X ∷h Γ) h = traverse-=>-I-dep'-I2 {n} {Γ-t₁} {Γ-t₂} t (m-weak-h Γ-t₁ Γ-t₂ {$o} {t ∷ ε} (weak-i ε Γ-t₁ X) => F) (m-weak-h Γ-t₁ Γ-t₂ {$o} {ε} X => G) Γ ( subst (λ z → ⊢ ((m-weak-h Γ-t₁ Γ-t₂ {$o} {t ∷ ε} (weak-i ε Γ-t₁ X) => F) => (z => weak-i ε (Γ-t₂ r++ Γ-t₁) G))) (eq-1 Γ-t₁ Γ-t₂ t X) (inf-V ax-4-s h)) traverse-=>-I-dep'-I : ∀ {n Γ-t} → (t : Type n) (F : Form (t ∷ Γ-t) $o) (G : Form Γ-t $o) (Γ : FSC-Ctx n Γ-t) → (⊢ (F => weak-i ε Γ-t G)) → ⊢ (hypos (t ∷ Γ) F => weak-i ε Γ-t (hypos Γ G)) traverse-=>-I-dep'-I {n} {Γ-t} t F G Γ h = subst (λ z → ⊢ (z => weak-i ε Γ-t (hypos Γ G))) (sym (eq-2 t Γ F)) (traverse-=>-I-dep'-I2 {n} {Γ-t} {ε} t F G Γ h) traverse-=>-I-dep' : ∀ {n Γ-t} → (t : Type n) (F : Form Γ-t (t > $o)) (Γ : FSC-Ctx n Γ-t) → ⊢ hypos (t ∷ Γ) (weak F · $ this {refl}) → ⊢ (hypos Γ (!'[ t ] F)) traverse-=>-I-dep' t F Γ h = extend-context t (inf-V (traverse-=>-I-dep'-I t (weak F · $ this {refl}) (!'[ t ] F) Γ (inf-VI this (occurs-p-2 F) refl)) h) -- ----------------------------------- traverse-hypos-eq-=>-I-i : ∀ {n Γ-t₁ Γ-t₂} → {t : Type n} → (F : Form (t ∷ (Γ-t₂ r++ Γ-t₁)) $o) (G : Form (Γ-t₂ r++ Γ-t₁) $o) (Γ : FSC-Ctx n Γ-t₁) → (⊢ (F => weak G)) → ⊢ hypos-i-h {n} {Γ-t₁} {Γ-t₂} {t ∷ ε} Γ F → ⊢ hypos-i {n} {Γ-t₁} {Γ-t₂} Γ G traverse-hypos-eq-=>-I-i {n} {.ε} {Γ-t₂} {t} F G ε = λ z z' → extend-context t (inf-V z z') traverse-hypos-eq-=>-I-i {n} {Γ-t₁} {Γ-t₂} {t} F G (X ∷h Γ) = λ h → traverse-hypos-eq-=>-I-i {n} {Γ-t₁} {Γ-t₂} {t} (m-weak-h {_} Γ-t₁ Γ-t₂ {_} {t ∷ ε} (m-weak2 (t ∷ ε) X) => F) (m-weak-h {_} Γ-t₁ Γ-t₂ {_} {ε} (m-weak2 ε X) => G) Γ (subst (λ z → ⊢ ((m-weak-h {_} Γ-t₁ Γ-t₂ {_} {t ∷ ε} (m-weak2 (t ∷ ε) X) => F) => (z => weak G))) (eq-1 Γ-t₁ Γ-t₂ t X) (inf-V ax-4-s h)) traverse-hypos-eq-=>-I-i {n} {t₁ ∷ Γ-t₁} {Γ-t₂} {t} F G ((.t₁) ∷ Γ) = traverse-hypos-eq-=>-I-i {n} {Γ-t₁} {t₁ ∷ Γ-t₂} {t} F G Γ traverse-hypos-eq-=>-I'' : ∀ {n Γ-t} → {t : Type n} (F : Form (t ∷ Γ-t) $o) (G : Form Γ-t $o) (Γ : FSC-Ctx n Γ-t) → ⊢ (F => weak G) → ⊢ hypos (t ∷ Γ) F → ⊢ hypos Γ G traverse-hypos-eq-=>-I'' {n} {Γ-t} F G Γ = λ h₁ h₂ → traverse-hypos-eq-=>-I-i {n} {Γ-t} {ε} F G Γ h₁ (subst (λ z → ⊢ z) (eq-2 _ Γ F) h₂) tst3-ε : ∀ {n} → (Γ₁ Γ₂ : Ctx n) (F : Form Γ₁ $o) (eq : Γ₁ ≡ Γ₂) → ⊢_ {n} {Γ₂} (subst (λ z → Form z $o) eq F) → ⊢_ {n} {Γ₁} F tst3-ε .Γ₂ Γ₂ F refl p = p -- rewrite eq = p tst3b : ∀ {n} → {t u : Type n} → (Γ-t₁ Γ-t₂ : Ctx n) (X : Form Γ-t₁ u) → (eq2 : t ∷ (Γ-t₂ r++ Γ-t₁) ≡ (Γ-t₂ ++ (t ∷ ε)) r++ Γ-t₁) → m-weak-h Γ-t₁ (Γ-t₂ ++ (t ∷ ε)) {_} {ε} X ≡ subst (λ z → Form z u) eq2 (weak-i ε (Γ-t₂ r++ Γ-t₁) (m-weak-h Γ-t₁ Γ-t₂ {_} {ε} X)) tst3b Γ-t₁ ε X refl = refl tst3b Γ-t₁ (v ∷ Γ-t₂) X eq2 = tst3b (v ∷ Γ-t₁) Γ-t₂ (weak-i ε Γ-t₁ X) eq2 tst3'-∷h : ∀ {n Γ-t₁ Γ-t₂} → {t : Type n} (F : Form (t ∷ (Γ-t₂ r++ Γ-t₁)) $o) (Γ : FSC-Ctx n Γ-t₁) → (X : Form Γ-t₁ $o) (Γ1 : Ctx n) (eq1 : Γ1 ≡ (Γ-t₂ ++ (t ∷ ε)) r++ Γ-t₁) (eq2 : t ∷ (Γ-t₂ r++ Γ-t₁) ≡ Γ1) (p : ⊢ hypos-i-h {n} {Γ-t₁} {Γ-t₂ ++ (t ∷ ε)} {ε} Γ (app (app A (app N (m-weak-h {n} Γ-t₁ (Γ-t₂ ++ (t ∷ ε)) {$o} {ε} X))) (subst (λ z → Form z $o) eq1 (subst (λ z → Form z $o) eq2 F)))) → ⊢ hypos-i-h {n} {Γ-t₁} {Γ-t₂ ++ (t ∷ ε)} {ε} Γ (subst (λ z → Form z $o) eq1 (app (app A (app N (subst (λ z → Form z $o) eq2 (weak-i ε (Γ-t₂ r++ Γ-t₁) (m-weak-h Γ-t₁ Γ-t₂ {$o} {ε} X))))) (subst (λ z → Form z $o) eq2 F))) tst3'-∷h {n} {Γ-t₁} {Γ-t₂} {t} F Γ X .((Γ-t₂ ++ (t ∷ ε)) r++ Γ-t₁) refl eq2 p = subst (λ z → ⊢ hypos-i-h {n} {Γ-t₁} {Γ-t₂ ++ (t ∷ ε)} {ε} Γ (app (app A (app N z)) (subst (λ z → Form z $o) eq2 F))) (tst3b {n} {t} Γ-t₁ Γ-t₂ X eq2) p tst3' : ∀ {n Γ-t₁ Γ-t₂} → {t : Type n} (F : Form (t ∷ (Γ-t₂ r++ Γ-t₁)) $o) (Γ : FSC-Ctx n Γ-t₁) → (eq : t ∷ (Γ-t₂ r++ Γ-t₁) ≡ (Γ-t₂ ++ (t ∷ ε)) r++ Γ-t₁) → ⊢ hypos-i-h {n} {Γ-t₁} {Γ-t₂ ++ (t ∷ ε)} {ε} Γ (subst (λ z → Form z $o) eq F) → ⊢ hypos-i-h {n} {Γ-t₁} {Γ-t₂} {ε} Γ (![ t ] F) tst3' {n} {ε} {Γ-t₂} {t} F ε eq = λ p → inf-VI-s (tst3-ε {n} (t ∷ (Γ-t₂ r++ ε)) ((Γ-t₂ ++ (t ∷ ε)) r++ ε) F eq p) tst3' {n} {t' ∷ Γ-t₁} {Γ-t₂} F ((.t') ∷ Γ) eq = tst3' {n} {Γ-t₁} {t' ∷ Γ-t₂} F Γ eq tst3' {n} {Γ-t₁} {Γ-t₂} {t} F (X ∷h Γ) eq = λ p → inf-V (traverse-hypos-i {n} {Γ-t₁} {Γ-t₂} (![ t ] (weak (~ (m-weak-h Γ-t₁ Γ-t₂ {_} {ε} X)) || F)) (m-weak-h {n} Γ-t₁ Γ-t₂ {$o} {ε} X => ![ t ] F) Γ (inf-V (inf-V ax-4-s ax-6-s) (lem2h2hb _))) (tst3' {n} {Γ-t₁} {Γ-t₂} {t} (weak (~ (m-weak-h Γ-t₁ Γ-t₂ {_} {ε} X)) || F) Γ eq (tst3'-∷h {n} {Γ-t₁} {Γ-t₂} {t} F Γ X (t ∷ (Γ-t₂ r++ Γ-t₁)) eq refl p)) traverse-hypos-eq-=>-I : ∀ {n Γ-t} → {t₁ t₂ : Type n} (F₁ F₂ : Form (t₁ ∷ Γ-t) t₂) (Γ : FSC-Ctx n Γ-t) → ⊢ hypos (t₁ ∷ Γ) (F₁ == F₂) → ⊢ hypos Γ (lam t₁ F₁ == lam t₁ F₂) traverse-hypos-eq-=>-I {_} {Γ-t} {t₁} {t₂} F₁ F₂ Γ p = inf-V (traverse-hypos (![ t₁ ] (F₁ == F₂)) (lam t₁ F₁ == lam t₁ F₂) Γ ax-10-b-s) (tst3' {_} {Γ-t} {ε} (F₁ == F₂) Γ refl p)
{ "alphanum_fraction": 0.4545291587, "avg_line_length": 76.7706422018, "ext": "agda", "hexsha": "08ba8d1c37ffef5ff908314ac7c7b41c9caaa6fd", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-01-15T11:51:19.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-17T20:28:10.000Z", "max_forks_repo_head_hexsha": "032efd5f42e4b56d436ac8e0c3c0f5127b8dc1f7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "frelindb/agsyHOL", "max_forks_repo_path": "soundness/HelpDefs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "032efd5f42e4b56d436ac8e0c3c0f5127b8dc1f7", "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": "frelindb/agsyHOL", "max_issues_repo_path": "soundness/HelpDefs.agda", "max_line_length": 851, "max_stars_count": 17, "max_stars_repo_head_hexsha": "032efd5f42e4b56d436ac8e0c3c0f5127b8dc1f7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "frelindb/agsyHOL", "max_stars_repo_path": "soundness/HelpDefs.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-19T20:53:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-04T14:38:28.000Z", "num_tokens": 9479, "size": 16736 }
module Bool where data Bool : Set where true : Bool false : Bool if_then_else_ : {A : Set} -> Bool -> A -> A -> A if true then x else y = x if false then x else y = y
{ "alphanum_fraction": 0.6079545455, "avg_line_length": 16, "ext": "agda", "hexsha": "b30044698e04efcdaf162bdaf7047d5e3e31d306", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/Alonzo/Bool.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/Alonzo/Bool.agda", "max_line_length": 48, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "examples/outdated-and-incorrect/Alonzo/Bool.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": 60, "size": 176 }
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.Rational.Base where open import Cubical.Relation.Nullary open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.HITs.Ints.QuoInt open import Cubical.Data.Nat open import Cubical.Data.Empty open import Cubical.Data.Unit data ℚ : Type₀ where con : (u : ℤ) (a : ℤ) → ¬ (a ≡ pos 0) → ℚ path : ∀ u a v b {p q} → (u *ℤ b) ≡ (v *ℤ a) → con u a p ≡ con v b q trunc : isSet ℚ int : ℤ → ℚ int z = con z (pos 1) \ p → snotz (cong abs p)
{ "alphanum_fraction": 0.6691871456, "avg_line_length": 27.8421052632, "ext": "agda", "hexsha": "a2275e2d28fa25c341a896f350cbd6666ee54b60", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/HITs/Rational/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_path": "Cubical/HITs/Rational/Base.agda", "max_line_length": 70, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/HITs/Rational/Base.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-23T23:52:11.000Z", "max_stars_repo_stars_event_min_datetime": "2020-03-23T23:52:11.000Z", "num_tokens": 199, "size": 529 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics module lib.types.Paths where {- ! is an equivalence and works on ≠ -} module _ {i} {A : Type i} {x y : A} where !-equiv : (x == y) ≃ (y == x) !-equiv = equiv ! ! !-! !-! ≠-inv : (x ≠ y) → (y ≠ x) ≠-inv x≠y y=x = x≠y (! y=x) {- Pre- and post- concatenation are equivalences -} module _ {i} {A : Type i} {x y z : A} where pre∙-is-equiv : (p : x == y) → is-equiv (λ (q : y == z) → p ∙ q) pre∙-is-equiv p = is-eq (λ q → p ∙ q) (λ r → ! p ∙ r) f-g g-f where f-g : ∀ r → p ∙ ! p ∙ r == r f-g r = ! (∙-assoc p (! p) r) ∙ ap (λ s → s ∙ r) (!-inv-r p) g-f : ∀ q → ! p ∙ p ∙ q == q g-f q = ! (∙-assoc (! p) p q) ∙ ap (λ s → s ∙ q) (!-inv-l p) pre∙-equiv : (p : x == y) → (y == z) ≃ (x == z) pre∙-equiv p = ((λ q → p ∙ q) , pre∙-is-equiv p) post∙-is-equiv : (p : y == z) → is-equiv (λ (q : x == y) → q ∙ p) post∙-is-equiv p = is-eq (λ q → q ∙ p) (λ r → r ∙ ! p) f-g g-f where f-g : ∀ r → (r ∙ ! p) ∙ p == r f-g r = ∙-assoc r (! p) p ∙ ap (λ s → r ∙ s) (!-inv-l p) ∙ ∙-unit-r r g-f : ∀ q → (q ∙ p) ∙ ! p == q g-f q = ∙-assoc q p (! p) ∙ ap (λ s → q ∙ s) (!-inv-r p) ∙ ∙-unit-r q post∙-equiv : (p : y == z) → (x == y) ≃ (x == z) post∙-equiv p = ((λ q → q ∙ p) , post∙-is-equiv p) pre∙'-is-equiv : (p : x == y) → is-equiv (λ (q : y == z) → p ∙' q) pre∙'-is-equiv p = is-eq (λ q → p ∙' q) (λ r → ! p ∙' r) f-g g-f where f-g : ∀ r → p ∙' ! p ∙' r == r f-g r = ! (∙'-assoc p (! p) r) ∙ ap (λ s → s ∙' r) (!-inv'-r p) ∙ ∙'-unit-l r g-f : ∀ q → ! p ∙' p ∙' q == q g-f q = ! (∙'-assoc (! p) p q) ∙ ap (λ s → s ∙' q) (!-inv'-l p) ∙ ∙'-unit-l q pre∙'-equiv : (p : x == y) → (y == z) ≃ (x == z) pre∙'-equiv p = ((λ q → p ∙' q) , pre∙'-is-equiv p) post∙'-is-equiv : (p : y == z) → is-equiv (λ (q : x == y) → q ∙' p) post∙'-is-equiv p = is-eq (λ q → q ∙' p) (λ r → r ∙' ! p) f-g g-f where f-g : ∀ r → (r ∙' ! p) ∙' p == r f-g r = ∙'-assoc r (! p) p ∙ ap (λ s → r ∙' s) (!-inv'-l p) g-f : ∀ q → (q ∙' p) ∙' ! p == q g-f q = ∙'-assoc q p (! p) ∙ ap (λ s → q ∙' s) (!-inv'-r p) post∙'-equiv : (p : y == z) → (x == y) ≃ (x == z) post∙'-equiv p = ((λ q → q ∙' p) , post∙'-is-equiv p) module _ {i j} {A : Type i} {B : Type j} {f : A → B} {x y : A} {b : B} where ↓-app=cst-in : {p : x == y} {u : f x == b} {v : f y == b} → u == (ap f p ∙ v) → (u == v [ (λ x → f x == b) ↓ p ]) ↓-app=cst-in {p = idp} q = q ↓-app=cst-out : {p : x == y} {u : f x == b} {v : f y == b} → (u == v [ (λ x → f x == b) ↓ p ]) → u == (ap f p ∙ v) ↓-app=cst-out {p = idp} r = r ↓-app=cst-β : {p : x == y} {u : f x == b} {v : f y == b} → (q : u == (ap f p ∙ v)) → ↓-app=cst-out {p = p} (↓-app=cst-in q) == q ↓-app=cst-β {p = idp} q = idp ↓-app=cst-η : {p : x == y} {u : f x == b} {v : f y == b} → (q : u == v [ (λ x → f x == b) ↓ p ]) → ↓-app=cst-in (↓-app=cst-out q) == q ↓-app=cst-η {p = idp} q = idp ↓-app=cst-econv : {p : x == y} {u : f x == b} {v : f y == b} → (u == (ap f p ∙ v)) ≃ (u == v [ (λ x → f x == b) ↓ p ]) ↓-app=cst-econv {p = p} = equiv ↓-app=cst-in ↓-app=cst-out (↓-app=cst-η {p = p}) (↓-app=cst-β {p = p}) ↓-cst=app-in : {p : x == y} {u : b == f x} {v : b == f y} → (u ∙' ap f p) == v → (u == v [ (λ x → b == f x) ↓ p ]) ↓-cst=app-in {p = idp} q = q ↓-cst=app-out : {p : x == y} {u : b == f x} {v : b == f y} → (u == v [ (λ x → b == f x) ↓ p ]) → (u ∙' ap f p) == v ↓-cst=app-out {p = idp} r = r ↓-cst=app-econv : {p : x == y} {u : b == f x} {v : b == f y} → ((u ∙' ap f p) == v) ≃ (u == v [ (λ x → b == f x) ↓ p ]) ↓-cst=app-econv {p = idp} = equiv ↓-cst=app-in ↓-cst=app-out (λ _ → idp) (λ _ → idp) {- alternative versions -} module _ {i j} {A : Type i} {B : Type j} {f : A → B} {x y : A} {b : B} where ↓-app=cst-in' : {p : x == y} {u : f x == b} {v : f y == b} → u == (ap f p ∙' v) → (u == v [ (λ x → f x == b) ↓ p ]) ↓-app=cst-in' {p = idp} {v = idp} q = q ↓-app=cst-out' : {p : x == y} {u : f x == b} {v : f y == b} → (u == v [ (λ x → f x == b) ↓ p ]) → u == (ap f p ∙' v) ↓-app=cst-out' {p = idp} {v = idp} r = r ↓-app=cst-β' : {p : x == y} {u : f x == b} {v : f y == b} → (q : u == (ap f p ∙' v)) → ↓-app=cst-out' {p = p} {v = v} (↓-app=cst-in' q) == q ↓-app=cst-β' {p = idp} {v = idp} q = idp ↓-app=cst-η' : {p : x == y} {u : f x == b} {v : f y == b} → (q : u == v [ (λ x → f x == b) ↓ p ]) → ↓-app=cst-in' (↓-app=cst-out' q) == q ↓-app=cst-η' {p = idp} {v = idp} q = idp ↓-cst=app-in' : {p : x == y} {u : b == f x} {v : b == f y} → (u ∙ ap f p) == v → (u == v [ (λ x → b == f x) ↓ p ]) ↓-cst=app-in' {p = idp} {u = idp} q = q ↓-cst=app-out' : {p : x == y} {u : b == f x} {v : b == f y} → (u == v [ (λ x → b == f x) ↓ p ]) → (u ∙ ap f p) == v ↓-cst=app-out' {p = idp} {u = idp} r = r module _ {i} {A : Type i} where ↓-app=idf-in : {f : A → A} {x y : A} {p : x == y} {u : f x == x} {v : f y == y} → u ∙' p == ap f p ∙ v → u == v [ (λ z → f z == z) ↓ p ] ↓-app=idf-in {p = idp} q = q ↓-app=idf-out : {f : A → A} {x y : A} {p : x == y} {u : f x == x} {v : f y == y} → u == v [ (λ z → f z == z) ↓ p ] → u ∙' p == ap f p ∙ v ↓-app=idf-out {p = idp} q = q ↓-cst=idf-in : {a : A} {x y : A} {p : x == y} {u : a == x} {v : a == y} → (u ∙' p) == v → (u == v [ (λ x → a == x) ↓ p ]) ↓-cst=idf-in {p = idp} q = q ↓-cst=idf-in' : {a : A} {x y : A} {p : x == y} {u : a == x} {v : a == y} → (u ∙ p) == v → (u == v [ (λ x → a == x) ↓ p ]) ↓-cst=idf-in' {p = idp} q = ! (∙-unit-r _) ∙ q ↓-idf=cst-in : {a : A} {x y : A} {p : x == y} {u : x == a} {v : y == a} → u == p ∙ v → (u == v [ (λ x → x == a) ↓ p ]) ↓-idf=cst-in {p = idp} q = q ↓-idf=cst-out : {a : A} {x y : A} {p : x == y} {u : x == a} {v : y == a} → (u == v [ (λ x → x == a) ↓ p ]) → u == p ∙ v ↓-idf=cst-out {p = idp} q = q ↓-idf=cst-in' : {a : A} {x y : A} {p : x == y} {u : x == a} {v : y == a} → u == p ∙' v → (u == v [ (λ x → x == a) ↓ p ]) ↓-idf=cst-in' {p = idp} q = q ∙ ∙'-unit-l _ ↓-idf=idf-in' : {x y : A} {p : x == y} {u : x == x} {v : y == y} → u ∙ p == p ∙' v → (u == v [ (λ x → x == x) ↓ p ]) ↓-idf=idf-in' {p = idp} q = ! (∙-unit-r _) ∙ q ∙ ∙'-unit-l _ ↓-idf=idf-out' : {x y : A} {p : x == y} {u : x == x} {v : y == y} → (u == v [ (λ x → x == x) ↓ p ]) → u ∙ p == p ∙' v ↓-idf=idf-out' {p = idp} q = ∙-unit-r _ ∙ q ∙ ! (∙'-unit-l _) {- Nondependent identity type -} ↓-='-in : ∀ {i j} {A : Type i} {B : Type j} {f g : A → B} {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y} → (u ∙' ap g p) == (ap f p ∙ v) → (u == v [ (λ x → f x == g x) ↓ p ]) ↓-='-in {p = idp} q = q ↓-='-out : ∀ {i j} {A : Type i} {B : Type j} {f g : A → B} {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y} → (u == v [ (λ x → f x == g x) ↓ p ]) → (u ∙' ap g p) == (ap f p ∙ v) ↓-='-out {p = idp} q = q ↓-='-in' : ∀ {i j} {A : Type i} {B : Type j} {f g : A → B} {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y} → (u ∙ ap g p) == (ap f p ∙' v) → (u == v [ (λ x → f x == g x) ↓ p ]) ↓-='-in' {p = idp} q = ! (∙-unit-r _) ∙ q ∙ (∙'-unit-l _) ↓-='-out' : ∀ {i j} {A : Type i} {B : Type j} {f g : A → B} {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y} → (u == v [ (λ x → f x == g x) ↓ p ]) → (u ∙ ap g p) == (ap f p ∙' v) ↓-='-out' {p = idp} q = (∙-unit-r _) ∙ q ∙ ! (∙'-unit-l _) {- Identity type where the type is dependent -} ↓-=-in : ∀ {i j} {A : Type i} {B : A → Type j} {f g : Π A B} {x y : A} {p : x == y} {u : g x == f x} {v : g y == f y} → (u ◃ apd f p) == (apd g p ▹ v) → (u == v [ (λ x → g x == f x) ↓ p ]) ↓-=-in {B = B} {p = idp} {u} {v} q = ! (◃idp {B = B} u) ∙ q ∙ idp▹ {B = B} v ↓-=-out : ∀ {i j} {A : Type i} {B : A → Type j} {f g : Π A B} {x y : A} {p : x == y} {u : g x == f x} {v : g y == f y} → (u == v [ (λ x → g x == f x) ↓ p ]) → (u ◃ apd f p) == (apd g p ▹ v) ↓-=-out {B = B} {p = idp} {u} {v} q = (◃idp {B = B} u) ∙ q ∙ ! (idp▹ {B = B} v) -- Dependent path in a type of the form [λ x → g (f x) == x] module _ {i j} {A : Type i} {B : Type j} (g : B → A) (f : A → B) where ↓-∘=idf-in' : {x y : A} {p : x == y} {u : g (f x) == x} {v : g (f y) == y} → ((ap g (ap f p) ∙' v) == (u ∙ p)) → (u == v [ (λ x → g (f x) == x) ↓ p ]) ↓-∘=idf-in' {p = idp} q = ! (∙-unit-r _) ∙ (! q) ∙ (∙'-unit-l _) -- WIP, derive it from more primitive principles -- ↓-∘=id-in f g {p = p} {u} {v} q = -- ↓-=-in (u ◃ apd (λ x → g (f x)) p =⟨ apd-∘ f g p |in-ctx (λ t → u ◃ t) ⟩ -- u ◃ ↓-apd-out _ f p (apdd g p (apd f p)) =⟨ apdd-cst (λ _ b → g b) p (ap f p) (! (apd-nd f p)) |in-ctx (λ t → u ◃ ↓-apd-out _ f p t) ⟩ -- u ◃ ↓-apd-out _ f p (apd (λ t → g (π₂ t)) (pair= p (apd f p))) =⟨ apd-∘ π₂ g (pair= p (apd f p)) |in-ctx (λ t → u ◃ ↓-apd-out _ f p t) ⟩ -- u ◃ ↓-apd-out _ f p (↓-apd-out _ π₂ (pair= p (apd f p)) (apdd g (pair= p (apd f p)) (apd π₂ (pair= p (apd f p))))) =⟨ {!!} ⟩ -- apd (λ x → x) p ▹ v ∎) -- module _ {i j} {A : Type i} {B : Type j} {x y z : A → B} where -- lhs : -- {a a' : A} {p : a == a'} {q : x a == y a} {q' : x a' == y a'} -- {r : y a == z a} {r' : y a' == z a'} -- (α : q == q' [ (λ a → x a == y a) ↓ p ]) -- (β : r ∙ ap z p == ap y p ∙' r') -- → (q ∙' r) ∙ ap z p == ap x p ∙' q' ∙' r' -- lhs = -- (q ∙' r) ∙ ap z p =⟨ ? ⟩ -- assoc -- q ∙' (r ∙ ap z p) =⟨ ? ⟩ -- β -- q ∙' (ap y p ∙' r') =⟨ ? ⟩ -- assoc -- (q ∙' ap y p) ∙' r' =⟨ ? ⟩ -- ∙ = ∙' -- (q ∙ ap y p) ∙' r' =⟨ ? ⟩ -- α -- (ap x p ∙' q') ∙' r' =⟨ ? ⟩ -- assoc -- ap x p ∙' q' ∙' r' ∎ -- thing : -- {a a' : A} {p : a == a'} {q : x a == y a} {q' : x a' == y a'} -- {r : y a == z a} {r' : y a' == z a'} -- (α : q == q' [ (λ a → x a == y a) ↓ p ]) -- (β : r ∙ ap z p == ap y p ∙' r') -- → (_∙'2ᵈ_ {r = r} {r' = r'} α (↓-='-in' β) == ↓-='-in' {!!}) -- thing = {!!}
{ "alphanum_fraction": 0.3336931985, "avg_line_length": 37.4595588235, "ext": "agda", "hexsha": "12e994adc9b111fdb1c589955d26f81c357e2ce0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "core/lib/types/Paths.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "core/lib/types/Paths.agda", "max_line_length": 147, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "core/lib/types/Paths.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5210, "size": 10189 }
-- {-# OPTIONS -v impossible:100 #-} -- 2013-06-15 Andreas, reported by evancavallo module Issue870 where {- The following fails with An internal error has occurred. Please report this as a bug. Location of the error: src/full/Agda/TypeChecking/Rules/Term.hs:421 in Agda 2.3.3 on Ubuntu. Works fine using Set instead of Type or after tweaking the definition of test into a more sensible form. -} Type = Set data ⊤ : Type where tt : ⊤ record R : Type where field a : ⊤ test : ⊤ → R test t = (λ a → record {a = a}) t -- There was a possible __IMPOSSIBLE__ in the code for -- guessing the record type of record{a = a}. -- The problem was that a defined sort like Type, needs to be -- reduced.
{ "alphanum_fraction": 0.6938202247, "avg_line_length": 24.5517241379, "ext": "agda", "hexsha": "122db3c30618378f18fefc77af3cea668f05528c", "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/Issue870.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/Issue870.agda", "max_line_length": 132, "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/Issue870.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": 210, "size": 712 }
module _ where open import utility open import sn-calculus using (all-ready ; bound-ready) open import Data.Product using (∃ ; Σ ; _,_ ; _×_ ; _,′_ ; proj₁ ; proj₂) open import Relation.Binary.PropositionalEquality using (sym ; inspect ; Reveal_·_is_ ; trans) open import Data.Empty open import Data.Sum using (_⊎_ ; inj₁ ; inj₂) open import Esterel.Lang open import Esterel.Lang.Properties open import Esterel.Context open import Esterel.Environment as Env open import Esterel.Lang.CanFunction using (Canₖ ; module CodeSet ; Canₛ ; Canₛₕ ; Canθₛ ; Canθₛₕ) open import Esterel.Lang.CanFunction.Base using (can-shr-var-irr) open import Esterel.CompletionCode as Code using () renaming (CompletionCode to Code) open import Esterel.Variable.Signal as Signal using (Signal ; _ₛ) renaming (_≟ₛₜ_ to _≟ₛₜₛ_) open import Esterel.Variable.Shared as SharedVar using (SharedVar ; _ₛₕ) renaming (_≟ₛₜ_ to _≟ₛₜₛₕ_) open import Esterel.Variable.Sequential as SeqVar using (SeqVar ; _ᵥ) open import Esterel.Lang.CanFunction using (Canₖ) open import Data.Product using (_,_) open import Relation.Nullary using (Dec ; yes ; no ; ¬_) open import Relation.Nullary.Decidable using (⌊_⌋) open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; trans ; sym) import Data.FiniteMap open import Data.List using (List ; [] ; _∷_ ; [_] ; _++_ ; map ; concatMap ; filter) open import Data.List.Any using (Any ; any ; here ; there) open import Data.List.All using (All ; [] ; _∷_) open import Data.OrderedListMap open all-ready open bound-ready data blocked-s : Env → s/l → Set where bbshr-old : ∀{θ s} → (s∈ : Env.isShr∈ s θ) → Env.shr-stats{s} θ s∈ ≡ SharedVar.old → blocked-s θ (shr-ref s) bbshr-new : ∀{θ s} → (s∈ : Env.isShr∈ s θ) → Env.shr-stats{s} θ s∈ ≡ SharedVar.new → blocked-s θ (shr-ref s) -- Note: θ and e are in the opposite order of all-ready definition. -- We directly used Any here as a synonym. Should all-ready be the same? blocked-e : Env → Expr → Set blocked-e θ (plus operators) = Any (blocked-s θ) operators data blocked : Env → Ctrl → Term → Set where bsig-exists : ∀{θ p q A} S S∈ → (sig-stats{S} θ S∈ ≡ Signal.unknown) → ------------------------ blocked θ A (present S ∣⇒ p ∣⇒ q) bpar-both : ∀{θ p q A} → blocked θ A p → blocked θ A q → blocked θ A (p ∥ q) bpar-left : ∀{θ p q A} → blocked θ A p → done q → blocked θ A (p ∥ q) bpar-right : ∀{θ p q A} → done p → blocked θ A q → blocked θ A (p ∥ q) bseq : ∀{θ p q A} → blocked θ A p → blocked θ A (p >> q) bloopˢ : ∀{θ p q A} → blocked θ A p → blocked θ A (loopˢ p q) bsusp : ∀{θ p S A} → blocked θ A p → blocked θ A (suspend p S) btrap : ∀{θ p A} → blocked θ A p → blocked θ A (trap p) bwset : ∀{θ s e} → blocked θ WAIT (s ⇐ e) bwemit : ∀{θ S} → blocked θ WAIT (emit S) bshared : ∀{θ s e p A} → blocked-e θ e → blocked θ A (shared s ≔ e in: p) bsset : ∀{θ s e A} → blocked-e θ e → blocked θ A (s ⇐ e) bvar : ∀{θ x e p A} → blocked-e θ e → blocked θ A (var x ≔ e in: p) bxset : ∀{θ x e A} → blocked-e θ e → blocked θ A (x ≔ e) data manifests-as-non-constructive : Env → Ctrl → Term → Set where mnc : ∀{p θ A} → (blocked-p : blocked θ A p) -- absent rule cannot fire: unknown signals might be emitted at some point → (θS≡unknown→S∈can-p-θ : ∀ S → (S∈Domθ : Signal.unwrap S ∈ fst (Dom θ)) → (θS≡unknown : sig-stats {S} θ S∈Domθ ≡ Signal.unknown) → Signal.unwrap S ∈ Canθₛ (sig θ) 0 p []env) -- readyness rule cannot fire: unready variables might become ready → (θs≡old⊎θs≡new→s∈can-p-θ : ∀ s → (s∈Domθ : SharedVar.unwrap s ∈ snd (Dom θ)) → (θs≡old⊎θs≡new : shr-stats {s} θ s∈Domθ ≡ SharedVar.old ⊎ shr-stats {s} θ s∈Domθ ≡ SharedVar.new) → SharedVar.unwrap s ∈ Canθₛₕ (sig θ) 0 p []env) → manifests-as-non-constructive θ A p halted-blocked-disjoint : ∀ {θ p A} → halted p → blocked θ A p → ⊥ halted-blocked-disjoint hnothin () halted-blocked-disjoint (hexit n) () paused-blocked-disjoint : ∀ {θ A p} → paused p → blocked θ A p → ⊥ paused-blocked-disjoint ppause () paused-blocked-disjoint (pseq p/paused) (bseq p/blocked) = paused-blocked-disjoint p/paused p/blocked paused-blocked-disjoint (ploopˢ p/paused) (bloopˢ p/blocked) = paused-blocked-disjoint p/paused p/blocked paused-blocked-disjoint (ppar p/paused q/paused) (bpar-both p/blocked q/blocked) = paused-blocked-disjoint q/paused q/blocked paused-blocked-disjoint (ppar p/paused q/paused) (bpar-left p/blocked q/done) = paused-blocked-disjoint p/paused p/blocked paused-blocked-disjoint (ppar p/paused q/paused) (bpar-right p/done q/blocked) = paused-blocked-disjoint q/paused q/blocked paused-blocked-disjoint (psuspend p/paused) (bsusp p/blocked) = paused-blocked-disjoint p/paused p/blocked paused-blocked-disjoint (ptrap p/paused) (btrap p/blocked) = paused-blocked-disjoint p/paused p/blocked done-blocked-disjoint : ∀ {θ A p} → done p → blocked θ A p → ⊥ done-blocked-disjoint (dhalted p/halted) p/blocked = halted-blocked-disjoint p/halted p/blocked done-blocked-disjoint (dpaused p/paused) p/blocked = paused-blocked-disjoint p/paused p/blocked -- An expression cannot be both all-ready and blocked-e, i.e. -- all-ready and blocked-e characterize disjoint subsets of e. all-ready-blocked-disjoint : ∀ {e θ} → ¬ (all-ready e θ × blocked-e θ e) all-ready-blocked-disjoint {θ = θ} (aplus (brshr {s = s} s∈ θs≡ready ∷ e/all-ready) , here (bbshr-old {s = .s} s∈' θs≡old)) with trans (sym θs≡ready) (trans (Env.shr-stats-∈-irr {s} {θ} s∈ s∈') θs≡old) ... | () all-ready-blocked-disjoint {θ = θ} (aplus (brshr {s = s} s∈ θs≡ready ∷ e/all-ready) , here (bbshr-new {s = .s} s∈' θs≡new)) with trans (sym θs≡ready) (trans (Env.shr-stats-∈-irr {s} {θ} s∈ s∈') θs≡new) ... | () all-ready-blocked-disjoint {θ = θ} (aplus (px ∷ e/all-ready) , there e/blocked) = all-ready-blocked-disjoint (aplus e/all-ready ,′ e/blocked) -- A subexpression in the hole in a blocked program must be either blocked or done. blocked-⟦⟧e : ∀ {θ p p' E A} → blocked θ A p → p ≐ E ⟦ p' ⟧e → blocked θ A p' ⊎ done p' blocked-⟦⟧e p/blocked dehole = inj₁ p/blocked blocked-⟦⟧e (bseq p/blocked) (deseq p≐E⟦p'⟧) = blocked-⟦⟧e p/blocked p≐E⟦p'⟧ blocked-⟦⟧e (bloopˢ p/blocked) (deloopˢ p≐E⟦p'⟧) = blocked-⟦⟧e p/blocked p≐E⟦p'⟧ blocked-⟦⟧e (bsusp p/blocked) (desuspend p≐E⟦p'⟧) = blocked-⟦⟧e p/blocked p≐E⟦p'⟧ blocked-⟦⟧e (btrap p/blocked) (detrap p≐E⟦p'⟧) = blocked-⟦⟧e p/blocked p≐E⟦p'⟧ blocked-⟦⟧e (bpar-both p/blocked q/blocked) (depar₁ p≐E⟦p'⟧) = blocked-⟦⟧e p/blocked p≐E⟦p'⟧ blocked-⟦⟧e (bpar-left p/blocked q/done) (depar₁ p≐E⟦p'⟧) = blocked-⟦⟧e p/blocked p≐E⟦p'⟧ blocked-⟦⟧e (bpar-right p/done q/blocked) (depar₁ p≐E⟦p'⟧) = inj₂ (done-⟦⟧e p/done p≐E⟦p'⟧) blocked-⟦⟧e (bpar-both p/blocked q/blocked) (depar₂ q≐E⟦p'⟧) = blocked-⟦⟧e q/blocked q≐E⟦p'⟧ blocked-⟦⟧e (bpar-left p/blocked q/done) (depar₂ q≐E⟦p'⟧) = inj₂ (done-⟦⟧e q/done q≐E⟦p'⟧) blocked-⟦⟧e (bpar-right p/done q/blocked) (depar₂ q≐E⟦p'⟧) = blocked-⟦⟧e q/blocked q≐E⟦p'⟧ blocked-el-dec : ∀ θ l -> Dec (Any (blocked-s θ) l) blocked-el-dec θ [] = no (λ ()) blocked-el-dec θ (num n ∷ l) with blocked-el-dec θ l blocked-el-dec θ (num n ∷ l) | yes p = yes (there p) blocked-el-dec θ (num n ∷ l) | no ¬p = no (λ { (here ()) ; (there x) → ¬p x } ) blocked-el-dec θ (seq-ref x ∷ l) with blocked-el-dec θ l blocked-el-dec θ (seq-ref x ∷ l) | yes p = yes (there p) blocked-el-dec θ (seq-ref x ∷ l) | no ¬p = no (λ { (here ()) ; (there x) → ¬p x }) blocked-el-dec θ (shr-ref s ∷ l) with blocked-el-dec θ l blocked-el-dec θ (shr-ref s ∷ l) | yes p = yes (there p) blocked-el-dec θ (shr-ref s ∷ l) | no ¬p with Env.Shr∈ s θ blocked-el-dec θ (shr-ref s ∷ l) | no ¬p | yes s∈θ with Env.shr-stats{s} θ s∈θ | inspect (Env.shr-stats {s} θ) s∈θ blocked-el-dec θ (shr-ref s ∷ l) | no ¬p | yes s∈θ | SharedVar.ready | Reveal_·_is_.[ eq ] = no (λ { (here (bbshr-old s∈θ₂ eq₂)) → lookup-s-eq θ s s∈θ s∈θ₂ eq eq₂ (λ ()) ; (here (bbshr-new s∈θ₂ eq₂)) → lookup-s-eq θ s s∈θ s∈θ₂ eq eq₂ (λ ()) ; (there x) → ¬p x }) blocked-el-dec θ (shr-ref s ∷ l) | no ¬p | yes s∈θ | SharedVar.new | Reveal_·_is_.[ eq ] = yes (here (bbshr-new s∈θ eq)) blocked-el-dec θ (shr-ref s ∷ l) | no ¬p | yes s∈θ | SharedVar.old | Reveal_·_is_.[ eq ] = yes (here (bbshr-old s∈θ eq)) blocked-el-dec θ (shr-ref s ∷ l) | no ¬p | no ¬s∈θ = no (λ { (here (bbshr-old s∈ x)) → ¬s∈θ s∈ ; (here (bbshr-new s∈ x)) → ¬s∈θ s∈ ; (there x) → ¬p x }) blocked-e-dec : ∀ θ e -> Dec (blocked-e θ e) blocked-e-dec θ (plus l) = blocked-el-dec θ l blocked-dec : ∀ θ A p -> Dec (blocked θ A p) blocked-dec θ A nothin = no (λ ()) blocked-dec θ A pause = no (λ ()) blocked-dec θ A (signl S p) = no (λ ()) blocked-dec θ A (present S ∣⇒ p ∣⇒ q) with Sig∈ S θ blocked-dec θ A (present S ∣⇒ p ∣⇒ q) | yes SigS∈θ with Env.sig-stats{S} θ SigS∈θ | inspect (Env.sig-stats{S} θ) SigS∈θ blocked-dec θ A (present S ∣⇒ p ∣⇒ q) | yes SigS∈θ₁ | Signal.present | Reveal_·_is_.[ eq₁ ] = no (λ { (bsig-exists .S SigS∈θ₂ eq₂) → lookup-S-eq θ S SigS∈θ₁ SigS∈θ₂ eq₁ eq₂ (λ ()) }) blocked-dec θ A (present S ∣⇒ p ∣⇒ q) | yes SigS∈θ₁ | Signal.absent | Reveal_·_is_.[ eq₁ ] = no (λ { (bsig-exists .S SigS∈θ₂ eq₂) → lookup-S-eq θ S SigS∈θ₁ SigS∈θ₂ eq₁ eq₂ (λ ()) } ) blocked-dec θ A (present S ∣⇒ p ∣⇒ q) | yes SigS∈θ | Signal.unknown | Reveal_·_is_.[ eq ] = yes (bsig-exists S SigS∈θ eq) blocked-dec θ A (present S ∣⇒ p ∣⇒ q) | no ¬SigS∈θ = no (λ { (bsig-exists .S S∈ _) → ¬SigS∈θ S∈ }) blocked-dec θ GO (emit S) = no (λ ()) blocked-dec θ WAIT (emit S) = yes bwemit blocked-dec θ A (p ∥ q) with blocked-dec θ A p | blocked-dec θ A q blocked-dec θ A (p ∥ q) | yes blockedp | yes blockedq = yes (bpar-both blockedp blockedq) blocked-dec θ A (p ∥ q) | yes blockedp | no ¬blockedq with done-dec q blocked-dec θ A (p ∥ q) | yes blockedp | no ¬blockedq | yes donep = yes (bpar-left blockedp donep) blocked-dec θ A (p ∥ q) | yes blockedp | no ¬blockedq | no ¬donep = no (λ { (bpar-both _ x) → ¬blockedq x ; (bpar-left _ x) → ¬donep x ; (bpar-right _ x) → ¬blockedq x }) blocked-dec θ A (p ∥ q) | no ¬blockedp | yes blockedq with done-dec p blocked-dec θ A (p ∥ q) | no ¬blockedp | yes blockedq | yes donep = yes (bpar-right donep blockedq) blocked-dec θ A (p ∥ q) | no ¬blockedp | yes blockedq | no ¬donep = no (λ { (bpar-both x _) → ¬blockedp x ; (bpar-left x _) → ¬blockedp x ; (bpar-right x _) → ¬donep x }) blocked-dec θ A (p ∥ q) | no ¬blockedp | no ¬blockedq = no (λ { (bpar-both _ x) → ¬blockedq x ; (bpar-left x _) → ¬blockedp x ; (bpar-right _ x) → ¬blockedq x }) blocked-dec θ A (loop p) = no (λ ()) blocked-dec θ A (p >> q) with blocked-dec θ A p blocked-dec θ A (p >> q) | yes blockedp = yes (bseq blockedp) blocked-dec θ A (p >> q) | no ¬blockedp = no (λ { (bseq x) → ¬blockedp x }) blocked-dec θ A (loopˢ p q) with blocked-dec θ A p blocked-dec θ A (loopˢ p q) | yes blockedp = yes (bloopˢ blockedp) blocked-dec θ A (loopˢ p q) | no ¬blockedp = no (λ { (bloopˢ x) → ¬blockedp x }) blocked-dec θ A (suspend p S) with blocked-dec θ A p blocked-dec θ A (suspend p S) | yes blockedp = yes (bsusp blockedp) blocked-dec θ A (suspend p S) | no ¬blockedp = no (λ { (bsusp x) → ¬blockedp x }) blocked-dec θ A (trap p) with blocked-dec θ A p blocked-dec θ A (trap p) | yes blockedp = yes (btrap blockedp) blocked-dec θ A (trap p) | no ¬blockedp = no (λ { (btrap x) → ¬blockedp x }) blocked-dec θ A (exit x) = no (λ ()) blocked-dec θ A (shared s ≔ e in: p) with blocked-e-dec θ e blocked-dec θ A (shared s ≔ e in: p) | yes blockede = yes (bshared blockede) blocked-dec θ A (shared s ≔ e in: p) | no ¬blockede = no (λ { (bshared x) → ¬blockede x }) blocked-dec θ A (s ⇐ e) with blocked-e-dec θ e blocked-dec θ A (s ⇐ e) | yes p = yes (bsset p) blocked-dec θ GO (s ⇐ e) | no ¬p = no (λ { (bsset x) → ¬p x }) blocked-dec θ WAIT (s ⇐ e) | no ¬p = yes bwset blocked-dec θ A (var x ≔ e in: p) with blocked-e-dec θ e blocked-dec θ A (var x ≔ e in: p₁) | yes p = yes (bvar p) blocked-dec θ A (var x ≔ e in: p) | no ¬p = no (λ { (bvar x₁) → ¬p x₁ }) blocked-dec θ A (x ≔ e) with blocked-e-dec θ e blocked-dec θ A (x ≔ e) | yes p = yes (bxset p) blocked-dec θ A (x ≔ e) | no ¬p = no (λ { (bxset x₁) → ¬p x₁ }) blocked-dec θ A (if x ∣⇒ p ∣⇒ p₁) = no (λ ()) blocked-dec θ A (ρ⟨ θ₁ , A₁ ⟩· p) = no (λ ())
{ "alphanum_fraction": 0.6086067186, "avg_line_length": 49.4591439689, "ext": "agda", "hexsha": "c14dfc5ecbf12ca9a33a5bd8ec0e20c30163804b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_path": "agda/blocked.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "florence/esterel-calculus", "max_issues_repo_path": "agda/blocked.agda", "max_line_length": 122, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_path": "agda/blocked.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "num_tokens": 5173, "size": 12711 }
module Properties.Functions where infixr 5 _∘_ _∘_ : ∀ {A B C : Set} → (B → C) → (A → B) → (A → C) (f ∘ g) x = f (g x)
{ "alphanum_fraction": 0.4876033058, "avg_line_length": 17.2857142857, "ext": "agda", "hexsha": "313b0ff2f91a8d2b56ed9d4907615576452f1165", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "TheGreatSageEqualToHeaven/luau", "max_forks_repo_path": "prototyping/Properties/Functions.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "TheGreatSageEqualToHeaven/luau", "max_issues_repo_path": "prototyping/Properties/Functions.agda", "max_line_length": 51, "max_stars_count": 1, "max_stars_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "TheGreatSageEqualToHeaven/luau", "max_stars_repo_path": "prototyping/Properties/Functions.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-05T21:53:03.000Z", "max_stars_repo_stars_event_min_datetime": "2021-12-05T21:53:03.000Z", "num_tokens": 58, "size": 121 }
module Numeral.Natural.Relation.Divisibility where import Lvl open import Functional open import Logic open import Logic.Propositional open import Numeral.Natural open import Numeral.Natural.Oper open import Type -- Divisibility relation of natural numbers. -- `(y ∣ x)` means that `y` is divisible by `x`. -- In other words: `x/y` is an integer. -- Or: `∃(c: ℕ). x = c⋅y`. -- Note on the definition of Div𝐒: -- The order (y + x) works and depends on rewriting rules of ℕ at the moment (Specifically on the commuted identity and successor rules, I think). -- Without rewriting rules, deconstruction of Div𝐒 seems not working. -- Example: -- div23 : ¬(2 ∣ 3) -- div23(Div𝐒()) -- This is a "valid" proof, but would not type-check because deconstruction from (2 ∣ 3) to (2 ∣ 1) is impossible. -- Seems like the compiler would see (3 = 2+x), but because of definition of (_+_), only (3 = x+2) can be found. -- Defining Div𝐒 with (x + y) inside would work, but then the definition of DivN becomes more complicated because (_⋅_) is defined in this order. -- Note on zero divisors: -- (0 ∣ 0) is true, and it is the only number divisible by 0. -- Example definitions of special cases of the divisibility relation and the divisibility with remainder relation: -- data Even : ℕ → Stmt{Lvl.𝟎} where -- Even0 : Even(𝟎) -- Even𝐒 : ∀{x : ℕ} → Even(x) → Even(𝐒(𝐒(x))) -- data Odd : ℕ → Stmt{Lvl.𝟎} where -- Odd0 : Odd(𝐒(𝟎)) -- Odd𝐒 : ∀{x : ℕ} → Odd(x) → Odd(𝐒(𝐒(x))) data _∣_ : ℕ → ℕ → Stmt{Lvl.𝟎} where Div𝟎 : ∀{y} → (y ∣ 𝟎) Div𝐒 : ∀{y x} → (y ∣ x) → (y ∣ (y + x)) _∤_ : ℕ → ℕ → Stmt y ∤ x = ¬(y ∣ x) -- `Divisor(n)(d)` means that `d` is a divisor of `n`. Divisor = swap(_∣_) -- `Multiple(n)(m)` means that `m` is a multiple of `n`. Multiple = _∣_ -- Elimination rule for (_∣_). divides-elim : ∀{ℓ}{P : ∀{y x} → (y ∣ x) → Type{ℓ}} → (∀{y} → P(Div𝟎{y})) → (∀{y x}{p : y ∣ x} → P(p) → P(Div𝐒 p)) → (∀{y x} → (p : y ∣ x) → P(p)) divides-elim z s Div𝟎 = z divides-elim{P = P} z s (Div𝐒 p) = s(divides-elim{P = P} z s p)
{ "alphanum_fraction": 0.6119402985, "avg_line_length": 41.54, "ext": "agda", "hexsha": "b819a653bc6981dc3d9d6fdb243ddedfcb158cfa", "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/Relation/Divisibility.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/Relation/Divisibility.agda", "max_line_length": 148, "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/Relation/Divisibility.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": 780, "size": 2077 }
-- 2010-10-01 Issue 342 module NonDependentConstructorType where data Wrap : Set1 where wrap : Set -> Wrap bla : Set bla = wrap -- 2010-10-01 error is printed as (_ : Set) -> Wrap !=< Set -- error should be printed as Set -> Wrap !=< Set
{ "alphanum_fraction": 0.6721991701, "avg_line_length": 24.1, "ext": "agda", "hexsha": "f9c5cd541f42a159bde9ae00f5ea5f1e47f79a81", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/NonDependentConstructorType.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/NonDependentConstructorType.agda", "max_line_length": 59, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/fail/NonDependentConstructorType.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 76, "size": 241 }
{-# OPTIONS --without-K #-} open import library.Basics hiding (Type ; Σ) open import library.types.Sigma open import library.types.Bool open import Sec2preliminaries open import Sec4hasConstToSplit module Sec6hasConstToDecEq where -- Lemma 6.1 hasConst-family-dec : {X : Type} → (x₁ x₂ : X) → ((x : X) → hasConst ((x₁ == x) + (x₂ == x))) → (x₁ == x₂) + ¬(x₁ == x₂) hasConst-family-dec {X} x₁ x₂ hasConst-fam = solution where f₋ : (x : X) → (x₁ == x) + (x₂ == x) → (x₁ == x) + (x₂ == x) f₋ x = fst (hasConst-fam x) E₋ : X → Type E₋ x = fix (f₋ x) E : Type E = Σ X λ x → (E₋ x) E-fst-determines-eq : (e₁ e₂ : E) → (fst e₁ == fst e₂) → e₁ == e₂ E-fst-determines-eq e₁ e₂ p = second-comp-triv (λ x → fixed-point (f₋ x) (snd (hasConst-fam x))) _ _ p r : Bool → E r true = x₁ , to-fix (f₋ x₁) (snd (hasConst-fam x₁)) (inl idp) r false = x₂ , to-fix (f₋ x₂) (snd (hasConst-fam x₂)) (inr idp) about-r : (r true == r false) ↔ (x₁ == x₂) about-r = (λ p → ap fst p) , (λ p → E-fst-determines-eq _ _ p) s : E → Bool s (_ , inl _ , _) = true s (_ , inr _ , _) = false s-section-of-r : (e : E) → r(s e) == e s-section-of-r (x , inl p , q) = E-fst-determines-eq _ _ p s-section-of-r (x , inr p , q) = E-fst-determines-eq _ _ p about-s : (e₁ e₂ : E) → (s e₁ == s e₂) ↔ (e₁ == e₂) about-s e₁ e₂ = one , two where one : (s e₁ == s e₂) → (e₁ == e₂) one p = e₁ =⟨ ! (s-section-of-r e₁) ⟩ r(s(e₁)) =⟨ ap r p ⟩ r(s(e₂)) =⟨ s-section-of-r e₂ ⟩ e₂ ∎ two : (e₁ == e₂) → (s e₁ == s e₂) two p = ap s p combine : (s (r true) == s (r false)) ↔ (x₁ == x₂) combine = (about-s _ _) ◎ about-r check-bool : (s (r true) == s (r false)) + ¬(s (r true) == s (r false)) check-bool = Bool-has-dec-eq _ _ solution : (x₁ == x₂) + ¬(x₁ == x₂) solution with check-bool solution | inl p = inl (fst combine p) solution | inr np = inr (λ p → np (snd combine p)) -- Theorem 6.2 all-hasConst→dec-eq : ((X : Type) → hasConst X) → (X : Type) → has-dec-eq X all-hasConst→dec-eq all-hasConst X x₁ x₂ = hasConst-family-dec x₁ x₂ (λ x → all-hasConst _)
{ "alphanum_fraction": 0.5375586854, "avg_line_length": 31.3235294118, "ext": "agda", "hexsha": "52bfdc76e510bce52b4b9de76a2ace6664fe90f7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "nicolai/anonymousExistence/Sec6hasConstToDecEq.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "nicolai/anonymousExistence/Sec6hasConstToDecEq.agda", "max_line_length": 120, "max_stars_count": 1, "max_stars_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nicolaikraus/HoTT-Agda", "max_stars_repo_path": "nicolai/anonymousExistence/Sec6hasConstToDecEq.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "num_tokens": 910, "size": 2130 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.Empty where open import Cubical.Data.Empty.Base public open import Cubical.Data.Empty.Properties public
{ "alphanum_fraction": 0.7683615819, "avg_line_length": 25.2857142857, "ext": "agda", "hexsha": "1c80c98041b06a97e16c185b641aa51e2ebd7854", "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/Empty.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/Empty.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Data/Empty.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 39, "size": 177 }
data D : Set where c_c_ : D → D test : D → D test c x c_ = x
{ "alphanum_fraction": 0.53125, "avg_line_length": 10.6666666667, "ext": "agda", "hexsha": "dd7a51cce077dbb1741d55e3ec274d4f503b1fd1", "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/Sections-3.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/Sections-3.agda", "max_line_length": 18, "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/Sections-3.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": 64 }
-- Andreas, 2017-07-28, issue #657 is fixed -- WAS: display form problem postulate A : Set x : A record R (A : Set) : Set₁ where field P : A → Set module M (r : ∀ A → R A) where open module R′ {A} = R (r A) public postulate r : ∀ A → R A open M r p : P x p = {!!} -- WAS: goal displayed as R.P (r A) x -- Expected: P x
{ "alphanum_fraction": 0.5510204082, "avg_line_length": 12.7037037037, "ext": "agda", "hexsha": "e075b34b1d4b89f0d7b8633001aaabc0bf760637", "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/Issue657.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/Issue657.agda", "max_line_length": 43, "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/Issue657.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 134, "size": 343 }
module UselessPrivateImport where private open import Common.Prelude
{ "alphanum_fraction": 0.8472222222, "avg_line_length": 14.4, "ext": "agda", "hexsha": "6bfa7aad48df252fc31a4a3e0c0b642e5d225a90", "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/UselessPrivateImport.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/UselessPrivateImport.agda", "max_line_length": 33, "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/UselessPrivateImport.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": 16, "size": 72 }
module Oscar.Data.Substitunction {𝔣} (FunctionName : Set 𝔣) where open import Oscar.Data.Equality open import Oscar.Data.Equality.properties open import Oscar.Data.Fin open import Oscar.Data.Nat open import Oscar.Data.Term FunctionName open import Oscar.Data.Vec open import Oscar.Function open import Oscar.Level open import Oscar.Relation -- Substitunction _⊸_ : (m n : Nat) → Set 𝔣 m ⊸ n = Fin m → Term n ▸ : ∀ {m n} → m ⟨ Fin ⟩→ n → m ⊸ n ▸ r = i ∘ r infix 19 _◂_ _◂s_ mutual _◂_ : ∀ {m n} → m ⊸ n → m ⟨ Term ⟩→ n σ̇ ◂ i 𝑥 = σ̇ 𝑥 _ ◂ leaf = leaf σ̇ ◂ (τl fork τr) = (σ̇ ◂ τl) fork (σ̇ ◂ τr) σ̇ ◂ (function fn τs) = function fn (σ̇ ◂s τs) where _◂s_ : ∀ {m n} → m ⊸ n → ∀ {N} → m ⟨ Terms N ⟩→ n -- Vec (Term m) N → Vec (Term n) N f ◂s [] = [] f ◂s (t ∷ ts) = f ◂ t ∷ f ◂s ts _∙_ : ∀ {m n} → m ⊸ n → ∀ {l} → l ⊸ m → l ⊸ n _∙_ f g = (f ◂_) ∘ g mutual ◂-extensionality : ∀ {m n} {f g : m ⊸ n} → f ≡̇ g → f ◂_ ≡̇ g ◂_ ◂-extensionality p (i x) = p x ◂-extensionality p leaf = refl ◂-extensionality p (s fork t) = cong₂ _fork_ (◂-extensionality p s) (◂-extensionality p t) ◂-extensionality p (function fn ts) = cong (function fn) (◂s-extensionality p ts) ◂s-extensionality : ∀ {m n} {f g : m ⊸ n} → f ≡̇ g → ∀ {N} → _◂s_ f {N} ≡̇ _◂s_ g ◂s-extensionality p [] = refl ◂s-extensionality p (t ∷ ts) = cong₂ _∷_ (◂-extensionality p t) (◂s-extensionality p ts) mutual ◂-associativity : ∀ {l m} (f : l ⊸ m) {n} (g : m ⊸ n) → (g ∙ f) ◂_ ≡̇ (g ◂_) ∘ (f ◂_) ◂-associativity _ _ (i _) = refl ◂-associativity _ _ leaf = refl ◂-associativity _ _ (τ₁ fork τ₂) = cong₂ _fork_ (◂-associativity _ _ τ₁) (◂-associativity _ _ τ₂) ◂-associativity f g (function fn ts) = cong (function fn) (◂s-associativity f g ts) ◂s-associativity : ∀ {l m n} (f : l ⊸ m) (g : m ⊸ n) → ∀ {N} → (_◂s_ (g ∙ f) {N}) ≡̇ (g ◂s_) ∘ (f ◂s_) ◂s-associativity _ _ [] = refl ◂s-associativity _ _ (τ ∷ τs) = cong₂ _∷_ (◂-associativity _ _ τ) (◂s-associativity _ _ τs) ∙-associativity : ∀ {k l} (f : k ⊸ l) {m} (g : l ⊸ m) {n} (h : m ⊸ n) → (h ∙ g) ∙ f ≡̇ h ∙ (g ∙ f) ∙-associativity f g h x rewrite ◂-associativity g h (f x) = refl ∙-extensionality : ∀ {l m} {f₁ f₂ : l ⊸ m} → f₁ ≡̇ f₂ → ∀ {n} {g₁ g₂ : m ⊸ n} → g₁ ≡̇ g₂ → g₁ ∙ f₁ ≡̇ g₂ ∙ f₂ ∙-extensionality {f₂ = f₂} f₁≡̇f₂ g₁≡̇g₂ x rewrite f₁≡̇f₂ x = ◂-extensionality g₁≡̇g₂ (f₂ x) ε : ∀ {m} → m ⊸ m ε = i mutual ◂-identity : ∀ {m} (t : Term m) → ε ◂ t ≡ t ◂-identity (i x) = refl ◂-identity leaf = refl ◂-identity (s fork t) = cong₂ _fork_ (◂-identity s) (◂-identity t) ◂-identity (function fn ts) = cong (function fn) (◂s-identity ts) ◂s-identity : ∀ {N m} (t : Vec (Term m) N) → ε ◂s t ≡ t ◂s-identity [] = refl ◂s-identity (t ∷ ts) = cong₂ _∷_ (◂-identity t) (◂s-identity ts) ∙-left-identity : ∀ {m n} (f : m ⊸ n) → ε ∙ f ≡̇ f ∙-left-identity f = ◂-identity ∘ f ∙-right-identity : ∀ {m n} (f : m ⊸ n) → f ∙ ε ≡̇ f ∙-right-identity _ _ = refl open import Oscar.Category semigroupoidSubstitunction : Semigroupoid _⊸_ (λ {m n} → ≡̇-setoid (λ _ → Term n)) Semigroupoid._∙_ semigroupoidSubstitunction = _∙_ Semigroupoid.∙-extensionality semigroupoidSubstitunction = ∙-extensionality Semigroupoid.∙-associativity semigroupoidSubstitunction = ∙-associativity semigroupoidExtensionTerm : Semigroupoid (_⟨ Term ⟩→_) (λ {m n} → ≡̇-setoid (λ _ → Term n)) Semigroupoid._∙_ semigroupoidExtensionTerm g = g ∘_ Semigroupoid.∙-extensionality semigroupoidExtensionTerm {f₂ = f₂} f₁≡̇f₂ g₁≡̇g₂ x rewrite f₁≡̇f₂ x = g₁≡̇g₂ (f₂ x) Semigroupoid.∙-associativity semigroupoidExtensionTerm _ _ _ _ = refl semigroupoidExtensionTerms : ∀ N → Semigroupoid (_⟨ Terms N ⟩→_) (λ {m n} → ≡̇-setoid (λ _ → Terms N n)) Semigroupoid._∙_ (semigroupoidExtensionTerms _) g = g ∘_ Semigroupoid.∙-extensionality (semigroupoidExtensionTerms _) {f₂ = f₂} f₁≡̇f₂ g₁≡̇g₂ x rewrite f₁≡̇f₂ x = g₁≡̇g₂ (f₂ x) Semigroupoid.∙-associativity (semigroupoidExtensionTerms _) _ _ _ _ = refl semifunctorSubstitute : Semifunctor semigroupoidSubstitunction semigroupoidExtensionTerm Semifunctor.μ semifunctorSubstitute = id Semifunctor.𝔣 semifunctorSubstitute = _◂_ Semifunctor.𝔣-extensionality semifunctorSubstitute = ◂-extensionality Semifunctor.𝔣-commutativity semifunctorSubstitute {f = f} {g = g} = ◂-associativity f g semifunctorSubstitutes : ∀ N → Semifunctor semigroupoidSubstitunction (semigroupoidExtensionTerms N) Semifunctor.μ (semifunctorSubstitutes _) = id Semifunctor.𝔣 (semifunctorSubstitutes N) f τs = f ◂s τs Semifunctor.𝔣-extensionality (semifunctorSubstitutes _) f≡̇g = ◂s-extensionality f≡̇g Semifunctor.𝔣-commutativity (semifunctorSubstitutes _) {f = f} {g = g} = ◂s-associativity f g ------------ subfact3 : ∀ {l m n} (f : m ⊸ n) (r : l ⟨ Fin ⟩→ m) → f ◇ (▸ r) ≡ f ∘ r ------------ subfact3 f r = refl -- -- -- -- prop-id : ∀ {m n} {f : _ ⊸ n} {ℓ} {P : ⊸-ExtentionalProperty {ℓ} m} → proj₁ P f → proj₁ P (i ◇ f) -- -- -- -- prop-id {_} {_} {f} {_} {P'} Pf = proj₂ P' (λ x → sym (◃-identity (f x))) Pf -- -- -- -- ≐-cong : ∀ {m n o} {f : m ⊸ n} {g} (h : _ ⊸ o) → f ≐ g → (h ◇ f) ≐ (h ◇ g) -- -- -- -- ≐-cong h f≐g t = cong (h ◃_) (f≐g t) -- -- -- -- -- data AList : ℕ -> ℕ -> Set 𝔣 where -- -- -- -- -- anil : ∀ {n} -> AList n n -- -- -- -- -- _asnoc_/_ : ∀ {m n} (σ : AList m n) (t' : Term m) (x : Fin (suc m)) -- -- -- -- -- -> AList (suc m) n -- -- -- -- -- sub : ∀ {m n} (σ : AList m n) -> Fin m -> Term n -- -- -- -- -- sub anil = i -- -- -- -- -- sub (σ asnoc t' / x) = sub σ ◇ (t' for x) -- -- -- -- -- _++_ : ∀ {l m n} (ρ : AList m n) (σ : AList l m) -> AList l n -- -- -- -- -- ρ ++ anil = ρ -- -- -- -- -- ρ ++ (σ asnoc t' / x) = (ρ ++ σ) asnoc t' / x -- -- -- -- -- ++-assoc : ∀ {l m n o} (ρ : AList l m) (σ : AList n _) (τ : AList o _) -> ρ ++ (σ ++ τ) ≡ (ρ ++ σ) ++ τ -- -- -- -- -- ++-assoc ρ σ anil = refl -- -- -- -- -- ++-assoc ρ σ (τ asnoc t / x) = cong (λ s -> s asnoc t / x) (++-assoc ρ σ τ) -- -- -- -- -- module SubList where -- -- -- -- -- anil-id-l : ∀ {m n} (σ : AList m n) -> anil ++ σ ≡ σ -- -- -- -- -- anil-id-l anil = refl -- -- -- -- -- anil-id-l (σ asnoc t' / x) = cong (λ σ -> σ asnoc t' / x) (anil-id-l σ) -- -- -- -- -- fact1 : ∀ {l m n} (ρ : AList m n) (σ : AList l m) -> sub (ρ ++ σ) ≐ (sub ρ ◇ sub σ) -- -- -- -- -- fact1 ρ anil v = refl -- -- -- -- -- fact1 {suc l} {m} {n} r (s asnoc t' / x) v = trans hyp-on-terms ◃-assoc -- -- -- -- -- where -- -- -- -- -- t = (t' for x) v -- -- -- -- -- hyp-on-terms = ◃-extentionality (fact1 r s) t -- -- -- -- -- ◃-assoc = ◃-associativity t -- -- -- -- -- _∃asnoc_/_ : ∀ {m} (a : ∃ (AList m)) (t' : Term m) (x : Fin (suc m)) -- -- -- -- -- -> ∃ (AList (suc m)) -- -- -- -- -- (n , σ) ∃asnoc t' / x = n , σ asnoc t' / x -- -- -- -- -- open import Data.Maybe using (Maybe; nothing; just) -- -- -- -- -- flexFlex : ∀ {m} (x y : Fin m) -> ∃ (AList m) -- -- -- -- -- flexFlex {suc m} x y with check x y -- -- -- -- -- ... | just y' = m , anil asnoc i y' / x -- -- -- -- -- ... | nothing = suc m , anil -- -- -- -- -- flexFlex {zero} () _ -- -- -- -- -- open import Oscar.Class.ThickAndThin -- -- -- -- -- flexRigid : ∀ {m} (x : Fin m) (t : Term m) -> Maybe (∃(AList m)) -- -- -- -- -- flexRigid {suc m} x t with check x t -- -- -- -- -- ... | just t' = just (m , anil asnoc t' / x) -- -- -- -- -- ... | nothing = nothing -- -- -- -- -- flexRigid {zero} () _ -- -- -- -- -- -- open import Oscar.Data.Fin using (Fin; zero; suc; thick?; Check; check; thin; module Thick) -- -- -- -- -- -- open import Data.Fin using (Fin; suc; zero) -- -- -- -- -- -- open import Data.Nat hiding (_≤_) -- -- -- -- -- -- open import Relation.Binary.PropositionalEquality renaming ([_] to [[_]]) -- -- -- -- -- -- open import Function using (_∘_; id; case_of_; _$_; flip) -- -- -- -- -- -- open import Relation.Nullary -- -- -- -- -- -- open import Data.Product renaming (map to _***_) -- -- -- -- -- -- open import Data.Empty -- -- -- -- -- -- open import Data.Maybe -- -- -- -- -- -- open import Category.Functor -- -- -- -- -- -- open import Category.Monad -- -- -- -- -- -- import Level -- -- -- -- -- -- open RawMonad (Data.Maybe.monad {Level.zero}) -- -- -- -- -- -- open import Data.Sum -- -- -- -- -- -- open import Data.Maybe using (maybe; maybe′; nothing; just; monad; Maybe) -- -- -- -- -- -- open import Data.List renaming (_++_ to _++L_) -- -- -- -- -- -- open ≡-Reasoning -- -- -- -- -- -- open import Data.Vec using (Vec; []; _∷_) renaming (_++_ to _++V_; map to mapV) -- -- -- -- -- -- open import Data.Nat using (ℕ; suc; zero) -- -- -- -- -- -- open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong₂; cong; sym; trans) -- -- -- -- -- -- open import Function using (_∘_; flip) -- -- -- -- -- -- open import Relation.Nullary using (¬_; Dec; yes; no) -- -- -- -- -- -- open import Data.Product using (∃; _,_; _×_) -- -- -- -- -- -- open import Data.Empty using (⊥-elim) -- -- -- -- -- -- open import Data.Vec using (Vec; []; _∷_) -- -- -- -- -- -- Term-function-inj-FunctionName : ∀ {fn₁ fn₂} {n N₁ N₂} {ts₁ : Vec (Term n) N₁} {ts₂ : Vec (Term n) N₂} → Term.function fn₁ ts₁ ≡ Term.function fn₂ ts₂ → fn₁ ≡ fn₂ -- -- -- -- -- -- Term-function-inj-FunctionName refl = refl -- -- -- -- -- -- Term-function-inj-VecSize : ∀ {fn₁ fn₂} {n N₁ N₂} {ts₁ : Vec (Term n) N₁} {ts₂ : Vec (Term n) N₂} → Term.function fn₁ ts₁ ≡ Term.function fn₂ ts₂ → N₁ ≡ N₂ -- -- -- -- -- -- Term-function-inj-VecSize refl = refl -- -- -- -- -- -- Term-function-inj-Vector : ∀ {fn₁ fn₂} {n N} {ts₁ : Vec (Term n) N} {ts₂ : Vec (Term n) N} → Term.function fn₁ ts₁ ≡ Term.function fn₂ ts₂ → ts₁ ≡ ts₂ -- -- -- -- -- -- Term-function-inj-Vector refl = refl -- -- -- -- -- -- Term-fork-inj-left : ∀ {n} {l₁ r₁ l₂ r₂ : Term n} → l₁ fork r₁ ≡ l₂ fork r₂ → l₁ ≡ l₂ -- -- -- -- -- -- Term-fork-inj-left refl = refl -- -- -- -- -- -- Term-fork-inj-right : ∀ {n} {l₁ r₁ l₂ r₂ : Term n} → l₁ fork r₁ ≡ l₂ fork r₂ → r₁ ≡ r₂ -- -- -- -- -- -- Term-fork-inj-right refl = refl -- -- -- -- -- -- open import Relation.Binary.HeterogeneousEquality using (_≅_; refl) -- -- -- -- -- -- Term-function-inj-HetVector : ∀ {fn₁ fn₂} {n N₁ N₂} {ts₁ : Vec (Term n) N₁} {ts₂ : Vec (Term n) N₂} → Term.function fn₁ ts₁ ≡ Term.function fn₂ ts₂ → ts₁ ≅ ts₂ -- -- -- -- -- -- Term-function-inj-HetVector refl = refl -- -- -- -- -- -- _⊸_ : (m n : ℕ) → Set -- -- -- -- -- -- m ⊸ n = Fin m → Term n -- -- -- -- -- -- ▸ : ∀ {m n} → (r : Fin m → Fin n) → Fin m → Term n -- -- -- -- -- -- ▸ r = i ∘ r -- -- -- -- -- -- record Substitution (T : ℕ → Set) : Set where -- -- -- -- -- -- field -- -- -- -- -- -- _◃_ : ∀ {m n} → (f : m ⊸ n) → T m → T n -- -- -- -- -- -- open Substitution ⦃ … ⦄ public -- -- -- -- -- -- {-# DISPLAY Substitution._◃_ _ = _◃_ #-} -- -- -- -- -- -- mutual -- -- -- -- -- -- instance SubstitutionTerm : Substitution Term -- -- -- -- -- -- Substitution._◃_ SubstitutionTerm = _◃′_ where -- -- -- -- -- -- _◃′_ : ∀ {m n} → (f : m ⊸ n) → Term m → Term n -- -- -- -- -- -- f ◃′ i x = f x -- -- -- -- -- -- f ◃′ leaf = leaf -- -- -- -- -- -- f ◃′ (s fork t) = (f ◃ s) fork (f ◃ t) -- -- -- -- -- -- f ◃′ (function fn ts) = function fn (f ◃ ts) -- -- -- -- -- -- instance SubstitutionVecTerm : ∀ {N} → Substitution (flip Vec N ∘ Term ) -- -- -- -- -- -- Substitution._◃_ (SubstitutionVecTerm {N}) = _◃′_ where -- -- -- -- -- -- _◃′_ : ∀ {m n} → (f : m ⊸ n) → Vec (Term m) N → Vec (Term n) N -- -- -- -- -- -- f ◃′ [] = [] -- -- -- -- -- -- f ◃′ (t ∷ ts) = f ◃ t ∷ f ◃ ts -- -- -- -- -- -- _≐_ : {m n : ℕ} → (Fin m → Term n) → (Fin m → Term n) → Set -- -- -- -- -- -- f ≐ g = ∀ x → f x ≡ g x -- -- -- -- -- -- record SubstitutionExtensionality (T : ℕ → Set) ⦃ _ : Substitution T ⦄ : Set₁ where -- -- -- -- -- -- field -- -- -- -- -- -- ◃ext : ∀ {m n} {f g : Fin m → Term n} → f ≐ g → (t : T m) → f ◃ t ≡ g ◃ t -- -- -- -- -- -- open SubstitutionExtensionality ⦃ … ⦄ public -- -- -- -- -- -- mutual -- -- -- -- -- -- instance SubstitutionExtensionalityTerm : SubstitutionExtensionality Term -- -- -- -- -- -- SubstitutionExtensionality.◃ext SubstitutionExtensionalityTerm = ◃ext′ where -- -- -- -- -- -- ◃ext′ : ∀ {m n} {f g : Fin m → Term n} → f ≐ g → ∀ t → f ◃ t ≡ g ◃ t -- -- -- -- -- -- ◃ext′ p (i x) = p x -- -- -- -- -- -- ◃ext′ p leaf = refl -- -- -- -- -- -- ◃ext′ p (s fork t) = cong₂ _fork_ (◃ext p s) (◃ext p t) -- -- -- -- -- -- ◃ext′ p (function fn ts) = cong (function fn) (◃ext p ts) -- -- -- -- -- -- instance SubstitutionExtensionalityVecTerm : ∀ {N} → SubstitutionExtensionality (flip Vec N ∘ Term) -- -- -- -- -- -- SubstitutionExtensionality.◃ext (SubstitutionExtensionalityVecTerm {N}) = λ x → ◃ext′ x where -- -- -- -- -- -- ◃ext′ : ∀ {m n} {f g : Fin m → Term n} → f ≐ g → ∀ {N} (t : Vec (Term m) N) → f ◃ t ≡ g ◃ t -- -- -- -- -- -- ◃ext′ p [] = refl -- -- -- -- -- -- ◃ext′ p (t ∷ ts) = cong₂ _∷_ (◃ext p t) (◃ext p ts) -- -- -- -- -- -- _◇_ : ∀ {l m n : ℕ } → (f : Fin m → Term n) (g : Fin l → Term m) → Fin l → Term n -- -- -- -- -- -- f ◇ g = (f ◃_) ∘ g -- -- -- -- -- -- ≐-cong : ∀ {m n o} {f : m ⊸ n} {g} (h : _ ⊸ o) → f ≐ g → (h ◇ f) ≐ (h ◇ g) -- -- -- -- -- -- ≐-cong h f≐g t = cong (h ◃_) (f≐g t) -- -- -- -- -- -- ≐-sym : ∀ {m n} {f : m ⊸ n} {g} → f ≐ g → g ≐ f -- -- -- -- -- -- ≐-sym f≐g = sym ∘ f≐g -- -- -- -- -- -- module Sub where -- -- -- -- -- -- record Fact1 (T : ℕ → Set) ⦃ _ : Substitution T ⦄ : Set where -- -- -- -- -- -- field -- -- -- -- -- -- fact1 : ∀ {n} → (t : T n) → i ◃ t ≡ t -- -- -- -- -- -- open Fact1 ⦃ … ⦄ public -- -- -- -- -- -- mutual -- -- -- -- -- -- instance Fact1Term : Fact1 Term -- -- -- -- -- -- Fact1.fact1 Fact1Term (i x) = refl -- -- -- -- -- -- Fact1.fact1 Fact1Term leaf = refl -- -- -- -- -- -- Fact1.fact1 Fact1Term (s fork t) = cong₂ _fork_ (fact1 s) (fact1 t) -- -- -- -- -- -- Fact1.fact1 Fact1Term (function fn ts) = cong (function fn) (fact1 ts) -- -- -- -- -- -- instance Fact1TermVec : ∀ {N} → Fact1 (flip Vec N ∘ Term) -- -- -- -- -- -- Fact1.fact1 Fact1TermVec [] = refl -- -- -- -- -- -- Fact1.fact1 Fact1TermVec (t ∷ ts) = cong₂ _∷_ (fact1 t) (fact1 ts) -- -- -- -- -- -- record Fact2 (T : ℕ → Set) ⦃ _ : Substitution T ⦄ : Set where -- -- -- -- -- -- field -- -- -- -- -- -- -- ⦃ s ⦄ : Substitution T -- -- -- -- -- -- fact2 : ∀ {l m n} → {f : Fin m → Term n} {g : _} (t : T l) → (f ◇ g) ◃ t ≡ f ◃ (g ◃ t) -- -- -- -- -- -- open Fact2 ⦃ … ⦄ public -- -- -- -- -- -- mutual -- -- -- -- -- -- instance Fact2Term : Fact2 Term -- -- -- -- -- -- -- Fact2.s Fact2Term = SubstitutionTerm -- -- -- -- -- -- Fact2.fact2 Fact2Term (i x) = refl -- -- -- -- -- -- Fact2.fact2 Fact2Term leaf = refl -- -- -- -- -- -- Fact2.fact2 Fact2Term (s fork t) = cong₂ _fork_ (fact2 s) (fact2 t) -- -- -- -- -- -- Fact2.fact2 Fact2Term {f = f} {g = g} (function fn ts) = cong (function fn) (fact2 {f = f} {g = g} ts) -- fact2 ts -- -- -- -- -- -- instance Fact2TermVec : ∀ {N} → Fact2 (flip Vec N ∘ Term) -- -- -- -- -- -- -- Fact2.s Fact2TermVec = SubstitutionVecTerm -- -- -- -- -- -- Fact2.fact2 Fact2TermVec [] = refl -- -- -- -- -- -- Fact2.fact2 Fact2TermVec (t ∷ ts) = cong₂ _∷_ (fact2 t) (fact2 ts) -- -- -- -- -- -- fact3 : ∀ {l m n} (f : Fin m → Term n) (r : Fin l → Fin m) → (f ◇ (▸ r)) ≡ (f ∘ r) -- -- -- -- -- -- fact3 f r = refl -- -- -- -- -- -- ◃ext' : ∀ {m n o} {f : Fin m → Term n}{g : Fin m → Term o}{h} → f ≐ (h ◇ g) → ∀ (t : Term _) → f ◃ t ≡ h ◃ (g ◃ t) -- -- -- -- -- -- ◃ext' p t = trans (◃ext p t) (Sub.fact2 t) -- -- -- -- -- -- open import Data.Maybe using (Maybe; nothing; just; functor; maybe′; maybe) -- -- -- -- -- -- open import Category.Monad -- -- -- -- -- -- import Level -- -- -- -- -- -- --open RawMonad (Data.Maybe.monad {Level.zero}) -- -- -- -- -- -- open import Data.Nat using (ℕ) -- -- -- -- -- -- _<*>_ = _⊛_ -- -- -- -- -- -- mutual -- -- -- -- -- -- instance CheckTerm : Check Term -- -- -- -- -- -- Check.check CheckTerm x (i y) = i <$> thick? x y -- -- -- -- -- -- Check.check CheckTerm x leaf = just leaf -- -- -- -- -- -- Check.check CheckTerm x (s fork t) = _fork_ <$> check x s ⊛ check x t -- -- -- -- -- -- Check.check CheckTerm x (function fn ts) = ⦇ (function fn) (check x ts) ⦈ -- -- -- -- -- -- instance CheckTermVec : ∀ {N} → Check (flip Vec N ∘ Term) -- -- -- -- -- -- Check.check CheckTermVec x [] = just [] -- -- -- -- -- -- Check.check CheckTermVec x (t ∷ ts) = ⦇ check x t ∷ check x ts ⦈ -- -- -- -- -- -- _for_ : ∀ {n} (t' : Term n) (x : Fin (suc n)) → Fin (suc n) → Term n -- -- -- -- -- -- (t' for x) y = maybe′ i t' (thick? x y) -- -- -- -- -- -- open import Data.Product using () renaming (Σ to Σ₁) -- -- -- -- -- -- open Σ₁ renaming (proj₁ to π₁; proj₂ to π₂) -- -- -- -- -- -- Property⋆ : (m : ℕ) → Set1 -- -- -- -- -- -- Property⋆ m = ∀ {n} → (Fin m → Term n) → Set -- -- -- -- -- -- Extensional : {m : ℕ} → Property⋆ m → Set -- -- -- -- -- -- Extensional P = ∀ {m f g} → f ≐ g → P {m} f → P g -- -- -- -- -- -- Property : (m : ℕ) → Set1 -- -- -- -- -- -- Property m = Σ₁ (Property⋆ m) Extensional -- -- -- -- -- -- prop-id : ∀ {m n} {f : _ ⊸ n} {P : Property m} → π₁ P f → π₁ P (i ◇ f) -- -- -- -- -- -- prop-id {_} {_} {f} {P'} Pf = π₂ P' (λ x → sym (Sub.fact1 (f x))) Pf -- -- -- -- -- -- Unifies⋆ : ∀ {m} (s t : Term m) → Property⋆ m -- -- -- -- -- -- Unifies⋆ s t f = f ◃ s ≡ f ◃ t -- -- -- -- -- -- Unifies⋆V : ∀ {m N} (ss ts : Vec (Term m) N) → Property⋆ m -- -- -- -- -- -- Unifies⋆V ss ts f = f ◃ ss ≡ f ◃ ts -- -- -- -- -- -- open import Relation.Binary.PropositionalEquality renaming ([_] to [[_]]) -- -- -- -- -- -- open ≡-Reasoning -- -- -- -- -- -- Unifies : ∀ {m} (s t : Term m) → Property m -- -- -- -- -- -- Unifies s t = (λ {_} → Unifies⋆ s t) , λ {_} {f} {g} f≐g f◃s=f◃t → -- -- -- -- -- -- begin -- -- -- -- -- -- g ◃ s -- -- -- -- -- -- ≡⟨ sym (◃ext f≐g s) ⟩ -- -- -- -- -- -- f ◃ s -- -- -- -- -- -- ≡⟨ f◃s=f◃t ⟩ -- -- -- -- -- -- f ◃ t -- -- -- -- -- -- ≡⟨ ◃ext f≐g t ⟩ -- -- -- -- -- -- g ◃ t -- -- -- -- -- -- ∎ -- -- -- -- -- -- UnifiesV : ∀ {m} {N} (s t : Vec (Term m) N) → Property m -- -- -- -- -- -- UnifiesV s t = (λ {_} → Unifies⋆V s t) , λ {_} {f} {g} f≐g f◃s=f◃t → -- -- -- -- -- -- begin -- -- -- -- -- -- g ◃ s -- -- -- -- -- -- ≡⟨ sym (◃ext f≐g s) ⟩ -- -- -- -- -- -- f ◃ s -- -- -- -- -- -- ≡⟨ f◃s=f◃t ⟩ -- -- -- -- -- -- f ◃ t -- -- -- -- -- -- ≡⟨ ◃ext f≐g t ⟩ -- -- -- -- -- -- g ◃ t -- -- -- -- -- -- ∎ -- -- -- -- -- -- _∧⋆_ : ∀{m} → (P Q : Property⋆ m) → Property⋆ m -- -- -- -- -- -- P ∧⋆ Q = (λ f → P f × Q f) -- -- -- -- -- -- -- open import Data.Product renaming (map to _***_) -- -- -- -- -- -- open import Data.Product using (Σ) -- -- -- -- -- -- open Σ -- -- -- -- -- -- _∧_ : ∀{m} → (P Q : Property m) → Property m -- -- -- -- -- -- P ∧ Q = (λ {_} f → π₁ P f × π₁ Q f) , λ {_} {_} {_} f≐g Pf×Qf → π₂ P f≐g (proj₁ Pf×Qf) , π₂ Q f≐g (proj₂ Pf×Qf) -- -- -- -- -- -- _⇔⋆_ : ∀{m} → (P Q : Property⋆ m) → Set -- -- -- -- -- -- P ⇔⋆ Q = ∀ {n} f → (P {n} f → Q f) × (Q f → P f) -- -- -- -- -- -- _⇔_ : ∀{m} → (P Q : Property m) → Set -- -- -- -- -- -- P ⇔ Q = ∀ {n} f → (π₁ P {n} f → π₁ Q f) × (π₁ Q f → π₁ P f) -- -- -- -- -- -- switch⋆ : ∀ {m} (P Q : Property⋆ m) → P ⇔⋆ Q → Q ⇔⋆ P -- -- -- -- -- -- switch⋆ _ _ P⇔Q f = proj₂ (P⇔Q f) , proj₁ (P⇔Q f) -- -- -- -- -- -- switch : ∀ {m} (P Q : Property m) → P ⇔ Q → Q ⇔ P -- -- -- -- -- -- switch _ _ P⇔Q f = proj₂ (P⇔Q f) , proj₁ (P⇔Q f) -- -- -- -- -- -- open import Data.Empty -- -- -- -- -- -- Nothing⋆ : ∀{m} → (P : Property⋆ m) → Set -- -- -- -- -- -- Nothing⋆ P = ∀{n} f → P {n} f → ⊥ -- -- -- -- -- -- Nothing : ∀{m} → (P : Property m) → Set -- -- -- -- -- -- Nothing P = ∀{n} f → π₁ P {n} f → ⊥ -- -- -- -- -- -- _[-◇⋆_] : ∀{m n} (P : Property⋆ m) (f : Fin m → Term n) → Property⋆ n -- -- -- -- -- -- (P [-◇⋆ f ]) g = P (g ◇ f) -- -- -- -- -- -- _[-◇_] : ∀{m n} (P : Property m) (f : Fin m → Term n) → Property n -- -- -- -- -- -- P [-◇ f ] = (λ {_} g → π₁ P (g ◇ f)) , λ {_} {f'} {g'} f'≐g' Pf'◇f → π₂ P (◃ext f'≐g' ∘ f) Pf'◇f -- -- -- -- -- -- open import Function using (_∘_; id; case_of_; _$_; flip) -- -- -- -- -- -- open import Data.Product using (curry; uncurry) -- -- -- -- -- -- module Properties where -- -- -- -- -- -- fact1 : ∀ {m} {s t : Term m} → (Unifies s t) ⇔ (Unifies t s) -- -- -- -- -- -- fact1 _ = sym , sym -- -- -- -- -- -- fact1'⋆ : ∀ {m} {s1 s2 t1 t2 : Term m} -- -- -- -- -- -- → Unifies⋆ (s1 fork s2) (t1 fork t2) ⇔⋆ (Unifies⋆ s1 t1 ∧⋆ Unifies⋆ s2 t2) -- -- -- -- -- -- fact1'⋆ f = deconstr _ _ _ _ , uncurry (cong₂ _fork_) -- -- -- -- -- -- where deconstr : ∀ {m} (s1 s2 t1 t2 : Term m) -- -- -- -- -- -- → (s1 fork s2) ≡ (t1 fork t2) -- -- -- -- -- -- → (s1 ≡ t1) × (s2 ≡ t2) -- -- -- -- -- -- deconstr s1 s2 .s1 .s2 refl = refl , refl -- -- -- -- -- -- fact1' : ∀ {m} {s1 s2 t1 t2 : Term m} -- -- -- -- -- -- → Unifies (s1 fork s2) (t1 fork t2) ⇔ (Unifies s1 t1 ∧ Unifies s2 t2) -- -- -- -- -- -- fact1' f = deconstr _ _ _ _ , uncurry (cong₂ _fork_) -- -- -- -- -- -- where deconstr : ∀ {m} (s1 s2 t1 t2 : Term m) -- -- -- -- -- -- → (s1 fork s2) ≡ (t1 fork t2) -- -- -- -- -- -- → (s1 ≡ t1) × (s2 ≡ t2) -- -- -- -- -- -- deconstr s1 s2 .s1 .s2 refl = refl , refl -- -- -- -- -- -- fact1'V : ∀ {m} {t₁ t₂ : Term m} {N} {ts₁ ts₂ : Vec (Term m) N} -- -- -- -- -- -- → UnifiesV (t₁ ∷ ts₁) (t₂ ∷ ts₂) ⇔ (Unifies t₁ t₂ ∧ UnifiesV ts₁ ts₂) -- -- -- -- -- -- fact1'V f = deconstr _ _ _ _ , uncurry (cong₂ _∷_) -- -- -- -- -- -- where deconstr : ∀ {m} (t₁ t₂ : Term m) {N} (ts₁ ts₂ : Vec (Term m) N) -- -- -- -- -- -- → (t₁ Vec.∷ ts₁) ≡ (t₂ ∷ ts₂) -- -- -- -- -- -- → (t₁ ≡ t₂) × (ts₁ ≡ ts₂) -- -- -- -- -- -- deconstr s1 _ s2! _ refl = refl , refl -- refl , refl -- -- -- -- -- -- fact2⋆ : ∀ {m} (P Q : Property⋆ m) → P ⇔⋆ Q → Nothing⋆ P → Nothing⋆ Q -- -- -- -- -- -- fact2⋆ P Q iff notp f q with iff f -- -- -- -- -- -- ... | (p2q , q2p) = notp f (q2p q) -- -- -- -- -- -- fact2 : ∀ {m} (P Q : Property m) → P ⇔ Q → Nothing P → Nothing Q -- -- -- -- -- -- fact2 P Q iff notp f q with iff f -- -- -- -- -- -- ... | (p2q , q2p) = notp f (q2p q) -- -- -- -- -- -- fact3 : ∀ {m} {P : Property m} → P ⇔ (P [-◇ i ]) -- -- -- -- -- -- fact3 f = id , id -- -- -- -- -- -- fact4 : ∀{m n} {P : Property m} (f : _ → Term n) -- -- -- -- -- -- → Nothing P → Nothing (P [-◇ f ]) -- -- -- -- -- -- fact4 f nop g = nop (g ◇ f) -- -- -- -- -- -- fact5⋆ : ∀{m n} (P Q : Property⋆ _) (f : m ⊸ n) → P ⇔⋆ Q → (P [-◇⋆ f ]) ⇔⋆ (Q [-◇⋆ f ]) -- -- -- -- -- -- fact5⋆ _ _ f P⇔Q f' = P⇔Q (f' ◇ f) -- -- -- -- -- -- fact5 : ∀{m n} (P Q : Property _) (f : m ⊸ n) → P ⇔ Q → (P [-◇ f ]) ⇔ (Q [-◇ f ]) -- -- -- -- -- -- fact5 _ _ f P⇔Q f' = P⇔Q (f' ◇ f) -- -- -- -- -- -- fact6 : ∀{m n} P {f g : m ⊸ n} → f ≐ g → (P [-◇ f ]) ⇔ (P [-◇ g ]) -- -- -- -- -- -- fact6 P f≐g h = π₂ P (≐-cong h f≐g) , π₂ P (≐-sym (≐-cong h f≐g)) -- -- -- -- -- -- _≤_ : ∀ {m n n'} (f : Fin m → Term n) (g : Fin m → Term n') → Set -- -- -- -- -- -- f ≤ g = ∃ λ f' → f ≐ (f' ◇ g) -- -- -- -- -- -- module Order where -- -- -- -- -- -- reflex : ∀ {m n} {f : Fin m → Term n} → f ≤ f -- -- -- -- -- -- reflex = i , λ _ → sym (Sub.fact1 _) -- -- -- -- -- -- transitivity : ∀ {l m n o} {f : Fin l → Term m}{g : _ → Term n} -- -- -- -- -- -- {h : _ → Term o} -- -- -- -- -- -- → f ≤ g → g ≤ h → f ≤ h -- -- -- -- -- -- transitivity {l} {_} {_} {_} {f} {g} {h} (fg , pfg) (gh , pgh) = -- -- -- -- -- -- fg ◇ gh , proof -- -- -- -- -- -- where -- -- -- -- -- -- proof : (x : Fin l) → f x ≡ (λ x' → fg ◃ (gh x')) ◃ (h x) -- -- -- -- -- -- proof x = trans z (sym (Sub.fact2 (h x))) -- -- -- -- -- -- where z = trans (pfg x) (cong (fg ◃_) (pgh x)) -- -- -- -- -- -- i-max : ∀ {m n} (f : Fin m → Term n) → f ≤ i -- -- -- -- -- -- i-max f = f , λ _ → refl -- -- -- -- -- -- dist : ∀{l m n o}{f : Fin l → Term m}{g : _ → Term n}(h : Fin o → _) → f ≤ g → (f ◇ h) ≤ (g ◇ h) -- -- -- -- -- -- dist h (fg , pfg) = fg , λ x → trans (◃ext pfg (h x)) (Sub.fact2 (h x)) -- -- -- -- -- -- Max⋆ : ∀ {m} (P : Property⋆ m) → Property⋆ m -- -- -- -- -- -- Max⋆ P f = P f × (∀ {n} f' → P {n} f' → f' ≤ f) -- -- -- -- -- -- Max : ∀ {m} (P : Property m) → Property m -- -- -- -- -- -- Max P' = (λ {_} → Max⋆ P) , λ {_} {_} {_} → lemma1 -- -- -- -- -- -- where -- -- -- -- -- -- open Σ₁ P' renaming (proj₁ to P; proj₂ to Peq) -- -- -- -- -- -- lemma1 : {m : ℕ} {f : Fin _ → Term m} {g : Fin _ → Term m} → -- -- -- -- -- -- f ≐ g → -- -- -- -- -- -- P f × ({n : ℕ} (f' : Fin _ → Term n) → P f' → f' ≤ f) → -- -- -- -- -- -- P g × ({n : ℕ} (f' : Fin _ → Term n) → P f' → f' ≤ g) -- -- -- -- -- -- lemma1 {_} {f} {g} f≐g (Pf , MaxPf) = Peq f≐g Pf , λ {_} → lemma2 -- -- -- -- -- -- where -- -- -- -- -- -- lemma2 : ∀ {n} f' → P {n} f' → ∃ λ f0 → f' ≐ (f0 ◇ g) -- -- -- -- -- -- lemma2 f' Pf' = f0 , λ x → trans (f'≐f0◇f x) (cong (f0 ◃_) (f≐g x)) -- -- -- -- -- -- where -- -- -- -- -- -- f0 = proj₁ (MaxPf f' Pf') -- -- -- -- -- -- f'≐f0◇f = proj₂ (MaxPf f' Pf') -- -- -- -- -- -- module Max where -- -- -- -- -- -- fact : ∀{m}(P Q : Property m) → P ⇔ Q → Max P ⇔ Max Q -- -- -- -- -- -- fact {m} P Q a f = -- -- -- -- -- -- (λ maxp → pq (proj₁ maxp) , λ f' → proj₂ maxp f' ∘ qp) -- -- -- -- -- -- , λ maxq → qp (proj₁ maxq) , λ f' → proj₂ maxq f' ∘ pq -- -- -- -- -- -- where -- -- -- -- -- -- pq : {n : ℕ} {f0 : Fin m → Term n} → (π₁ P f0 → π₁ Q f0) -- -- -- -- -- -- pq {_} {f} = proj₁ (a f) -- -- -- -- -- -- qp : {n : ℕ} {f0 : Fin m → Term n} → (π₁ Q f0 → π₁ P f0) -- -- -- -- -- -- qp {_} {f} = proj₂ (a f) -- -- -- -- -- -- DClosed : ∀{m} (P : Property m) → Set -- -- -- -- -- -- DClosed P = ∀ {n} f {o} g → f ≤ g → π₁ P {o} g → π₁ P {n} f -- -- -- -- -- -- module DClosed where -- -- -- -- -- -- fact1 : ∀ {m} s t → DClosed {m} (Unifies s t) -- -- -- -- -- -- fact1 s t f g (f≤g , p) gs=gt = -- -- -- -- -- -- begin -- -- -- -- -- -- f ◃ s -- -- -- -- -- -- ≡⟨ ◃ext' p s ⟩ -- -- -- -- -- -- f≤g ◃ (g ◃ s) -- -- -- -- -- -- ≡⟨ cong (f≤g ◃_) gs=gt ⟩ -- -- -- -- -- -- f≤g ◃ (g ◃ t) -- -- -- -- -- -- ≡⟨ sym (◃ext' p t) ⟩ -- -- -- -- -- -- f ◃ t -- -- -- -- -- -- ∎ -- -- -- -- -- -- optimist : ∀ {l m n o} (a : Fin _ → Term n) (p : Fin _ → Term o) -- -- -- -- -- -- (q : Fin _ → Term l) (P Q : Property m) -- -- -- -- -- -- → DClosed P → π₁ (Max (P [-◇ a ])) p -- -- -- -- -- -- → π₁ (Max (Q [-◇ (p ◇ a) ])) q -- -- -- -- -- -- → π₁ (Max ((P ∧ Q) [-◇ a ])) (q ◇ p) -- -- -- -- -- -- optimist a p q P' Q' DCP (Ppa , pMax) (Qqpa , qMax) = -- -- -- -- -- -- (Peq (sym ∘ Sub.fact2 ∘ a) (DCP (q ◇ (p ◇ a)) (p ◇ a) (q , λ _ → refl) Ppa) -- -- -- -- -- -- , Qeq (sym ∘ Sub.fact2 ∘ a) Qqpa ) -- -- -- -- -- -- , λ {_} → aux -- -- -- -- -- -- where -- -- -- -- -- -- open Σ₁ P' renaming (proj₁ to P; proj₂ to Peq) -- -- -- -- -- -- open Σ₁ Q' renaming (proj₁ to Q; proj₂ to Qeq) -- -- -- -- -- -- aux : ∀ {n} (f : _ → Term n) → P (f ◇ a) × Q (f ◇ a) → f ≤ (q ◇ p) -- -- -- -- -- -- aux f (Pfa , Qfa) = h , -- -- -- -- -- -- λ x → trans (f≐g◇p x) (◃ext' g≐h◇q (p x)) -- -- -- -- -- -- where -- -- -- -- -- -- one = pMax f Pfa -- -- -- -- -- -- g = proj₁ one -- -- -- -- -- -- f≐g◇p = proj₂ one -- -- -- -- -- -- Qgpa : Q (g ◇ (p ◇ a)) -- -- -- -- -- -- Qgpa = Qeq (λ x → ◃ext' f≐g◇p (a x)) Qfa -- -- -- -- -- -- g≤q = qMax g Qgpa -- -- -- -- -- -- h = proj₁ g≤q -- -- -- -- -- -- g≐h◇q = proj₂ g≤q -- -- -- -- -- -- module failure-propagation where -- -- -- -- -- -- first⋆ : ∀ {m n} (a : _ ⊸ n) (P Q : Property⋆ m) → -- -- -- -- -- -- Nothing⋆ (P [-◇⋆ a ]) → Nothing⋆ ((P ∧⋆ Q) [-◇⋆ a ]) -- -- -- -- -- -- first⋆ a P' Q' noP-a f (Pfa , Qfa) = noP-a f Pfa -- -- -- -- -- -- first : ∀ {m n} (a : _ ⊸ n) (P Q : Property m) → -- -- -- -- -- -- Nothing (P [-◇ a ]) → Nothing ((P ∧ Q) [-◇ a ]) -- -- -- -- -- -- first a P' Q' noP-a f (Pfa , Qfa) = noP-a f Pfa -- -- -- -- -- -- second⋆ : ∀ {m n o} (a : _ ⊸ n) (p : _ ⊸ o)(P : Property⋆ m)(Q : Property m) → -- -- -- -- -- -- (Max⋆ (P [-◇⋆ a ])) p → Nothing⋆ (π₁ Q [-◇⋆ (p ◇ a)]) -- -- -- -- -- -- → Nothing⋆ ((P ∧⋆ π₁ Q) [-◇⋆ a ]) -- -- -- -- -- -- second⋆ a p P' Q' (Ppa , pMax) noQ-p◇a f (Pfa , Qfa) = noQ-p◇a g Qgpa -- -- -- -- -- -- where -- -- -- -- -- -- f≤p = pMax f Pfa -- -- -- -- -- -- g = proj₁ f≤p -- -- -- -- -- -- f≐g◇p = proj₂ f≤p -- -- -- -- -- -- Qgpa : π₁ Q' (g ◇ (p ◇ a)) -- -- -- -- -- -- Qgpa = π₂ Q' (◃ext' f≐g◇p ∘ a) Qfa -- -- -- -- -- -- second : ∀ {m n o} (a : _ ⊸ n) (p : _ ⊸ o)(P Q : Property m) → -- -- -- -- -- -- π₁ (Max (P [-◇ a ])) p → Nothing (Q [-◇ (p ◇ a)]) -- -- -- -- -- -- → Nothing ((P ∧ Q) [-◇ a ]) -- -- -- -- -- -- second a p P' Q' (Ppa , pMax) noQ-p◇a f (Pfa , Qfa) = noQ-p◇a g Qgpa -- -- -- -- -- -- where -- -- -- -- -- -- f≤p = pMax f Pfa -- -- -- -- -- -- g = proj₁ f≤p -- -- -- -- -- -- f≐g◇p = proj₂ f≤p -- -- -- -- -- -- Qgpa : π₁ Q' (g ◇ (p ◇ a)) -- -- -- -- -- -- Qgpa = π₂ Q' (◃ext' f≐g◇p ∘ a) Qfa -- -- -- -- -- -- trivial-problem : ∀ {m n t} {f : m ⊸ n} → (Max⋆ ((Unifies⋆ t t) [-◇⋆ f ])) i -- -- -- -- -- -- trivial-problem = refl , λ f' _ → f' , λ _ → refl -- -- -- -- -- -- trivial-problemV : ∀ {m n N} {t : Vec (Term _) N} {f : m ⊸ n} → (Max⋆ ((Unifies⋆V t t) [-◇⋆ f ])) i -- -- -- -- -- -- trivial-problemV = refl , λ f' _ → f' , λ _ → refl -- -- -- -- -- -- open import Data.Sum -- -- -- -- -- -- var-elim : ∀ {m} (x : Fin (suc m)) (t' : Term _) -- -- -- -- -- -- → π₁ (Max ((Unifies (i x) ((▸ (thin x) ◃_) t')))) (t' for x) -- -- -- -- -- -- var-elim x t' = first , \{_} → second -- -- -- -- -- -- where -- -- -- -- -- -- lemma : ∀{m}(x : Fin (suc m)) t → i ≐ ((t for x) ◇ (▸ (thin x))) -- -- -- -- -- -- lemma x t x' = sym (cong (maybe i t) (Thick.half2 x _ x' refl)) -- -- -- -- -- -- first = begin -- -- -- -- -- -- (t' for x) ◃ (i x) ≡⟨ cong (maybe i t') (Thick.half1 x) ⟩ -- -- -- -- -- -- t' ≡⟨ sym (Sub.fact1 t') ⟩ -- -- -- -- -- -- i ◃ t' ≡⟨ ◃ext' (lemma x t') t' ⟩ -- -- -- -- -- -- (t' for x) ◃ ((▸ (thin x) ◃_) t') ∎ -- -- -- -- -- -- second : ∀ {n} (f : _ ⊸ n) → f x ≡ f ◃ ((▸ (thin x) ◃_) t') → f ≤ (t' for x) -- -- -- -- -- -- second f Unifiesf = (f ∘ thin x) , third -- -- -- -- -- -- where -- -- -- -- -- -- third : ((x' : Fin _) → f x' ≡ (f ∘ thin x) ◃ (maybe′ i t' (thick? x x'))) -- -- -- -- -- -- third x' with thick? x x' | Thick.fact1 x x' (thick? x x') refl -- -- -- -- -- -- third .x | .nothing | inj₁ (refl , refl) = -- -- -- -- -- -- sym (begin -- -- -- -- -- -- (f ∘ thin x) ◃ t' ≡⟨ cong (λ g → (g ◃_) t') (sym (Sub.fact3 f (thin x))) ⟩ -- -- -- -- -- -- (f ◇ (▸ (thin x))) ◃ t' ≡⟨ Sub.fact2 {-f (▸ (thin x))-} t' ⟩ -- -- -- -- -- -- f ◃ ((▸ (thin x) ◃_) t') ≡⟨ sym Unifiesf ⟩ -- -- -- -- -- -- f x ∎) -- -- -- -- -- -- third x' | .(just y) | inj₂ (y , ( thinxy≡x' , refl)) = sym (cong f thinxy≡x') -- -- -- -- -- -- var-elim-i : ∀ {m} (x : Fin (suc m)) (t' : Term _) -- -- -- -- -- -- → π₁ (Max ((Unifies (i x) ((▸ (thin x) ◃_) t')))) (i ◇ (t' for x)) -- -- -- -- -- -- var-elim-i {m} x t = prop-id {_} {_} {t for x} {Max (Unifies (i x) ((▸ (thin x) ◃_) t))} (var-elim {m} x t) -- -- -- -- -- -- var-elim-i-≡ : ∀ {m} {t'} (x : Fin (suc m)) t1 → t1 ≡ (i ∘ thin x) ◃ t' → π₁ (Max (Unifies (i x) t1)) (i ◇ (t' for x)) -- -- -- -- -- -- var-elim-i-≡ {_} {t'} x .((i ∘ thin x) ◃ t') refl = var-elim-i x t' -- -- -- -- -- -- ◇-assoc : ∀ {l m n o} (f : l ⊸ m) (g : n ⊸ _) (h : o ⊸ _) → -- -- -- -- -- -- (f ◇ (g ◇ h)) ≐ ((f ◇ g) ◇ h) -- -- -- -- -- -- ◇-assoc f g h x = sym (Sub.fact2 (h x)) -- -- -- -- -- -- bind-assoc : ∀ {l m n o} (f : l ⊸ m) (g : n ⊸ _) (h : o ⊸ _) t → (f ◇ g) ◃ (h ◃ t) ≡ (f ◇ (g ◇ h)) ◃ t -- -- -- -- -- -- bind-assoc f g h t = sym (begin -- -- -- -- -- -- (f ◇ (g ◇ h)) ◃ t ≡⟨ ◃ext (◇-assoc f g h) t ⟩ -- -- -- -- -- -- ((f ◇ g) ◇ h) ◃ t ≡⟨ Sub.fact2 ⦃ SubstitutionTerm ⦄ ⦃ Sub.Fact2Term ⦄ {f = (f ◇ g)} {g = h} {-(f ◇ g) h-} t ⟩ -- -- -- -- -- -- (f ◇ g) ◃ (h ◃ t) -- -- -- -- -- -- ∎)
{ "alphanum_fraction": 0.3949132256, "avg_line_length": 48.5755813953, "ext": "agda", "hexsha": "55f872d62910d30691f3e087e9c477377066a8eb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-2/Oscar/Data/Substitunction.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-2/Oscar/Data/Substitunction.agda", "max_line_length": 180, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-2/Oscar/Data/Substitunction.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 14084, "size": 33420 }
{-# OPTIONS --no-auto-inline #-} module Haskell.Prelude where open import Agda.Builtin.Unit public open import Agda.Builtin.Nat as Nat public hiding (_==_; _<_; _+_; _*_; _-_) open import Agda.Builtin.List public open import Agda.Builtin.Bool public open import Agda.Builtin.Char public open import Agda.Builtin.FromString public import Agda.Builtin.String as Str open import Agda.Builtin.Strict open import Agda.Builtin.Equality public open import Agda.Builtin.Int using (pos; negsuc) open import Haskell.Prim open Haskell.Prim public using ( TypeError; ⊥; iNumberNat; IsTrue; IsFalse; All; allNil; allCons; NonEmpty; lengthNat; id; _∘_; _$_; flip; const; if_then_else_; case_of_; Number; fromNat; Negative; fromNeg; a; b; c; d; e; f; m; s; t ) open import Haskell.Prim.Absurd public open import Haskell.Prim.Applicative public open import Haskell.Prim.Bool public open import Haskell.Prim.Char public open import Haskell.Prim.Bounded public open import Haskell.RangedSets.Boundaries public open import Haskell.RangedSets.Ranges public open import Haskell.RangedSets.RangedSet public open import Haskell.Prim.Double public open import Haskell.Prim.Either public open import Haskell.Prim.Enum public open import Haskell.Prim.Eq public open import Haskell.Prim.Foldable public open import Haskell.Prim.Functor public open import Haskell.Prim.Int public open import Haskell.Prim.Integer public open import Haskell.Prim.Real public open import Haskell.Prim.List public open import Haskell.Prim.Maybe public open import Haskell.Prim.Monad public open import Haskell.Prim.Monoid public open import Haskell.Prim.Num public open import Haskell.Prim.Ord public open import Haskell.Prim.Show public open import Haskell.Prim.String public open import Haskell.Prim.Traversable public open import Haskell.Prim.Tuple public hiding (first; second; _***_) open import Haskell.Prim.Word public -- Problematic features -- - [Partial]: Could pass implicit/instance arguments to prove totality. -- - [Float]: Or Float (Agda floats are Doubles) -- - [Infinite]: Define colists and map to Haskell lists? -- Missing from the Haskell Prelude: -- -- Float [Float] -- Rational -- -- Real(toRational), -- Integral(quot, rem, div, mod, quotRem, divMod, toInteger), -- Fractional((/), recip, fromRational), -- Floating(pi, exp, log, sqrt, (**), logBase, sin, cos, tan, -- asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh), -- RealFrac(properFraction, truncate, round, ceiling, floor), -- RealFloat(floatRadix, floatDigits, floatRange, decodeFloat, -- encodeFloat, exponent, significand, scaleFloat, isNaN, -- isInfinite, isDenormalized, isIEEE, isNegativeZero, atan2), -- -- subtract, even, odd, gcd, lcm, (^), (^^), -- fromIntegral, realToFrac, -- -- foldr1, foldl1, maximum, minimum [Partial] -- -- until [Partial] -- -- iterate, repeat, cycle [Infinite] -- -- ReadS, Read(readsPrec, readList), -- reads, readParen, read, lex, -- -- IO, putChar, putStr, putStrLn, print, -- getChar, getLine, getContents, interact, -- FilePath, readFile, writeFile, appendFile, readIO, readLn, -- IOError, ioError, userError, -------------------------------------------------- -- Functions infixr 0 _$!_ _$!_ : (a → b) → a → b f $! x = primForce x f seq : a → b → b seq x y = const y $! x asTypeOf : a → a → a asTypeOf x _ = x undefined : {@(tactic absurd) i : ⊥} → a undefined {i = ()} error : {@(tactic absurd) i : ⊥} → String → a error {i = ()} err errorWithoutStackTrace : {@(tactic absurd) i : ⊥} → String → a errorWithoutStackTrace {i = ()} err ------------------------------------------------- -- More List functions -- These uses Eq, Ord, or Foldable, so can't go in Prim.List without -- turning those dependencies around. reverse : List a → List a reverse = foldl (flip _∷_) [] infixl 9 _!!_ _!!ᴺ_ _!!ᴺ_ : (xs : List a) (n : Nat) → ⦃ IsTrue (n < lengthNat xs) ⦄ → a (x ∷ xs) !!ᴺ zero = x (x ∷ xs) !!ᴺ suc n = xs !!ᴺ n _!!_ : (xs : List a) (n : Int) ⦃ nn : IsNonNegativeInt n ⦄ → ⦃ IsTrue (intToNat n < lengthNat xs) ⦄ → a xs !! n = xs !!ᴺ intToNat n lookup : ⦃ Eq a ⦄ → a → List (a × b) → Maybe b lookup x [] = Nothing lookup x ((x₁ , y) ∷ xs) = if x == x₁ then Just y else lookup x xs
{ "alphanum_fraction": 0.6212992545, "avg_line_length": 35.3007518797, "ext": "agda", "hexsha": "e160ea6b3aaab76d847451ee54846f32b2dfdae5", "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": "17cdbeb36af3d0b735c5db83bb811034c39a19cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ioanasv/agda2hs", "max_forks_repo_path": "lib/Haskell/Prelude.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "17cdbeb36af3d0b735c5db83bb811034c39a19cd", "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": "ioanasv/agda2hs", "max_issues_repo_path": "lib/Haskell/Prelude.agda", "max_line_length": 103, "max_stars_count": 1, "max_stars_repo_head_hexsha": "17cdbeb36af3d0b735c5db83bb811034c39a19cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ioanasv/agda2hs", "max_stars_repo_path": "lib/Haskell/Prelude.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-25T09:41:34.000Z", "max_stars_repo_stars_event_min_datetime": "2021-05-25T09:41:34.000Z", "num_tokens": 1297, "size": 4695 }
module Session where open import Data.Bool open import Data.Fin open import Data.Empty open import Data.List open import Data.List.All open import Data.Maybe open import Data.Nat open import Data.Product open import Data.Sum open import Data.Unit open import Function using (_$_) open import Relation.Nullary open import Relation.Binary.PropositionalEquality open import Typing open import Syntax open import Global open import Channel open import Values data Cont (G : SCtx) (φ : TCtx) : (t : Type) → Set where halt : ∀ {t} → Inactive G → (un-t : Unr t) → Cont G φ t bind : ∀ {φ₁ φ₂ G₁ G₂ t t₂} → (ts : Split φ φ₁ φ₂) → (ss : SSplit G G₁ G₂) → (e₂ : Expr (t ∷ φ₁) t₂) → (ϱ₂ : VEnv G₁ φ₁) → (κ₂ : Cont G₂ φ₂ t₂) → Cont G φ t bind-thunk : ∀ {φ₁ φ₂ G₁ G₂ t₂} → (ts : Split φ φ₁ φ₂) → (ss : SSplit G G₁ G₂) → (e₂ : Expr φ₁ t₂) → (ϱ₂ : VEnv G₁ φ₁) → (κ₂ : Cont G₂ φ₂ t₂) → Cont G φ TUnit subsume : ∀ {t t₁} → SubT t t₁ → Cont G φ t₁ → Cont G φ t data Command (G : SCtx) : Set where Fork : ∀ {φ₁ φ₂ G₁ G₂} → (ss : SSplit G G₁ G₂) → (κ₁ : Cont G₁ φ₁ TUnit) → (κ₂ : Cont G₂ φ₂ TUnit) → Command G Ready : ∀ {φ t G₁ G₂} → (ss : SSplit G G₁ G₂) → (v : Val G₁ t) → (κ : Cont G₂ φ t) → Command G Halt : ∀ {t} → Inactive G → Unr t → Val G t → Command G New : ∀ {φ} → (s : SType) → (κ : Cont G φ (TPair (TChan (SType.force s)) (TChan (SType.force (dual s))))) → Command G Close : ∀ {φ G₁ G₂} → (ss : SSplit G G₁ G₂) → (v : Val G₁ (TChan send!)) → (κ : Cont G₂ φ TUnit) → Command G Wait : ∀ {φ G₁ G₂} → (ss : SSplit G G₁ G₂) → (v : Val G₁ (TChan send?)) → (κ : Cont G₂ φ TUnit) → Command G Send : ∀ {φ G₁ G₂ G₁₁ G₁₂ t s} → (ss : SSplit G G₁ G₂) → (ss-args : SSplit G₁ G₁₁ G₁₂) → (vch : Val G₁₁ (TChan (Typing.send t s))) → (v : Val G₁₂ t) → (κ : Cont G₂ φ (TChan (SType.force s))) → Command G Recv : ∀ {φ G₁ G₂ t s} → (ss : SSplit G G₁ G₂) → (vch : Val G₁ (TChan (Typing.recv t s))) → (κ : Cont G₂ φ (TPair (TChan (SType.force s)) t)) → Command G Select : ∀ {φ G₁ G₂ s₁ s₂} → (ss : SSplit G G₁ G₂) → (lab : Selector) → (vch : Val G₁ (TChan (sintern s₁ s₂))) → (κ : Cont G₂ φ (TChan (selection lab (SType.force s₁) (SType.force s₂)))) → Command G Branch : ∀ {φ G₁ G₂ s₁ s₂} → (ss : SSplit G G₁ G₂) → (vch : Val G₁ (TChan (sextern s₁ s₂))) → (dcont : (lab : Selector) → Cont G₂ φ (TChan (selection lab (SType.force s₁) (SType.force s₂)))) → Command G NSelect : ∀ {φ G₁ G₂ m alt} → (ss : SSplit G G₁ G₂) → (lab : Fin m) → (vch : Val G₁ (TChan (sintN m alt))) → (κ : Cont G₂ φ (TChan (SType.force (alt lab)))) → Command G NBranch : ∀ {φ G₁ G₂ m alt} → (ss : SSplit G G₁ G₂) → (vch : Val G₁ (TChan (sextN m alt))) → (dcont : (lab : Fin m) → Cont G₂ φ (TChan (SType.force (alt lab)))) → Command G -- rewrite-helper : ∀ {G G1 G2 G'' φ'} → Inactive G2 → SSplit G G1 G2 → SSplit G G G'' → VEnv G2 φ' → VEnv G'' φ' rewrite-helper ina-G2 ssp-GG1G2 ssp-GGG'' ϱ with inactive-right-ssplit ssp-GG1G2 ina-G2 ... | p with rewrite-ssplit1 (sym p) ssp-GG1G2 ... | ssp rewrite ssplit-function2 ssp ssp-GGG'' = ϱ -- interpret an expression run : ∀ {φ φ₁ φ₂ t G G₁ G₂} → Split φ φ₁ φ₂ → SSplit G G₁ G₂ → Expr φ₁ t → VEnv G₁ φ₁ → Cont G₂ φ₂ t → Command G run{G = G}{G₁ = G₁}{G₂ = G₂} tsp ssp (var x) ϱ κ with access ϱ x ... | Gx , Gϱ , ina , ssp12 , v rewrite inactive-right-ssplit ssp12 ina = Ready ssp v κ run tsp ssp (nat unr-φ i) ϱ κ = Ready ssp (VInt i (unrestricted-venv unr-φ ϱ)) κ run tsp ssp (unit unr-φ) ϱ κ = Ready ssp (VUnit (unrestricted-venv unr-φ ϱ)) κ run{φ}{φ₁}{φ₂} tsp ssp (letbind{φ₁₁}{φ₁₂}{t₁}{t₂} sp e₁ e₂) ϱ κ₂ with split-env sp ϱ | split-rotate tsp sp ... | (G₁ , G₂) , ssp-G1G2 , ϱ₁ , ϱ₂ | φ' , tsp-φ' , φ'-tsp with ssplit-compose ssp ssp-G1G2 ... | Gi , ssp-3i , ssp-42 = run tsp-φ' ssp-3i e₁ ϱ₁ (bind φ'-tsp ssp-42 e₂ ϱ₂ κ₂) run tsp ssp (pair sp x₁ x₂) ϱ κ with split-env sp ϱ ... | (G₁' , G₂') , ss-G1G1'G2' , ϱ₁ , ϱ₂ with access ϱ₁ x₁ | access ϱ₂ x₂ ... | Gv₁ , Gr₁ , ina-Gr₁ , ss-v1r1 , v₁ | Gv₂ , Gr₂ , ina-Gr₂ , ss-v2r2 , v₂ rewrite inactive-right-ssplit ss-v1r1 ina-Gr₁ | inactive-right-ssplit ss-v2r2 ina-Gr₂ = Ready ssp (VPair ss-G1G1'G2' v₁ v₂) κ run tsp ssp (letpair sp p e) ϱ κ with split-env sp ϱ ... | (G₁' , G₂') , ss-G1G1'G2' , ϱ₁ , ϱ₂ with access ϱ₁ p run tsp ssp (letpair sp p e) ϱ κ | (G₁' , G₂') , ss-G1G1'G2' , ϱ₁ , ϱ₂ | Gvp , Gr , ina-Gr , ss-vpr , VPair ss-GG₁G₂ v₁ v₂ with split-rotate tsp sp ... | φ' , ts-φφ1φ' , ts-φ'φ3φ4 rewrite inactive-right-ssplit ss-vpr ina-Gr with ssplit-compose ss-G1G1'G2' ss-GG₁G₂ ... | Gi , ss-G3G1Gi , ss-G1G2G2' = run (left (left ts-φ'φ3φ4)) ssp e (vcons ss-G3G1Gi v₁ (vcons ss-G1G2G2' v₂ ϱ₂)) κ run{φ}{φ₁}{G = G}{G₁ = G₁} tsp ssp (fork e) ϱ κ with ssplit-refl-left G₁ | split-refl-left φ₁ ... | Gi , ss-g1g1g2 | φ' , unr-φ' , sp-φφφ' with split-env sp-φφφ' ϱ ... | (Gp1 , Gp2) , ss-Gp , ϱ₁ , ϱ₂ with unrestricted-venv unr-φ' ϱ₂ ... | ina-Gp2 with inactive-right-ssplit-transform ss-Gp ina-Gp2 ... | ss-Gp' rewrite sym (ssplit-function2 ss-g1g1g2 ss-Gp') = Fork ssp (bind-thunk sp-φφφ' ss-g1g1g2 e ϱ (halt ina-Gp2 UUnit)) κ run tsp ssp (new unr-φ s) ϱ κ with unrestricted-venv unr-φ ϱ ... | ina rewrite inactive-left-ssplit ssp ina = New s κ run tsp ssp (close ch) ϱ κ with access ϱ ch ... | Gch , Gϱ , ina , ssp12 , vch with vch | inactive-right-ssplit ssp12 ina run tsp ssp (close ch) ϱ κ | Gch , Gϱ , ina , ssp12 , vch | vch' | refl = Close ssp vch' κ run tsp ssp (wait ch) ϱ κ with access ϱ ch ... | Gch , Gϱ , ina , ssp12 , vch with vch | inactive-right-ssplit ssp12 ina ... | vch' | refl = Wait ssp vch' κ run tsp ssp (Expr.send sp ch vv) ϱ κ with split-env sp ϱ ... | (G₁ , G₂) , ss-gg , ϱ₁ , ϱ₂ with access ϱ₁ ch ... | G₃ , G₄ , ina-G₄ , ss-g1g3g4 , vch with access ϱ₂ vv ... | G₅ , G₆ , ina-G₆ , ss-g2g5g6 , vvv with ssplit-join ss-gg ss-g1g3g4 ss-g2g5g6 ... | G₁' , G₂' , ss-g1'g2' , ss-g3g5 , ss-g4g6 rewrite sym (inactive-right-ssplit ss-g1g3g4 ina-G₄) | sym (inactive-right-ssplit ss-g2g5g6 ina-G₆) = Send ssp ss-gg vch vvv κ run tsp ssp (Expr.recv ch) ϱ κ with access ϱ ch ... | G₁ , G₂ , ina-G₂ , ss-vi , vch rewrite inactive-right-ssplit ss-vi ina-G₂ = Recv ssp vch κ run tsp ssp (nselect lab ch) ϱ κ with access ϱ ch ... | G₁ , G₂ , ina-G₂ , ss-vi , vch rewrite inactive-right-ssplit ss-vi ina-G₂ = NSelect ssp lab vch κ run tsp ssp (nbranch{m}{alt} sp ch ealts) ϱ κ with split-env sp ϱ ... | (G₁' , G₂') , ss-G1G1'G2' , ϱ₁ , ϱ₂ with access ϱ₁ ch ... | G₁ , G₂ , ina-G₂ , ss-vi , vch with ssplit-compose ssp ss-G1G1'G2' ... | Gi , ss-G-G1'Gi , ss-Gi-G2'-G2 with split-rotate tsp sp ... | φ' , sp-φφ1φ' , sp-φ'φ3φ4 with inactive-right-ssplit ss-vi ina-G₂ ... | refl = NBranch ss-G-G1'Gi vch dcont where dcont : (lab : Fin m) → Cont Gi _ (TChan (SType.force (alt lab))) dcont lab = bind sp-φ'φ3φ4 ss-Gi-G2'-G2 (ealts lab) ϱ₂ κ run tsp ssp (select lab ch) ϱ κ with access ϱ ch ... | G₁ , G₂ , ina-G₂ , ss-vi , vch rewrite inactive-right-ssplit ss-vi ina-G₂ = Select ssp lab vch κ run tsp ssp (branch{s₁}{s₂} sp ch e-left e-rght) ϱ κ with split-env sp ϱ ... | (G₁' , G₂') , ss-G1G1'G2' , ϱ₁ , ϱ₂ with access ϱ₁ ch ... | G₁ , G₂ , ina-G₂ , ss-vi , vch with ssplit-compose ssp ss-G1G1'G2' ... | Gi , ss-G-G1'Gi , ss-Gi-G2'-G2 with split-rotate tsp sp ... | φ' , sp-φφ1φ' , sp-φ'φ3φ4 with inactive-right-ssplit ss-vi ina-G₂ ... | refl = Branch ss-G-G1'Gi vch dcont where dcont : (lab : Selector) → Cont Gi _ (TChan (selection lab (SType.force s₁) (SType.force s₂))) dcont Left = bind sp-φ'φ3φ4 ss-Gi-G2'-G2 e-left ϱ₂ κ dcont Right = bind sp-φ'φ3φ4 ss-Gi-G2'-G2 e-rght ϱ₂ κ run tsp ssp (ulambda sp unr-φ unr-φ₃ ebody) ϱ κ with split-env sp ϱ ... | (G₁' , G₂') , ss-g1-g1'-g2' , ϱ₁ , ϱ₂ with unrestricted-venv unr-φ₃ ϱ₂ ... | ina-G2' with inactive-right-ssplit ss-g1-g1'-g2' ina-G2' ... | refl = Ready ssp (VFun (inj₂ unr-φ) ϱ₁ ebody) κ run tsp ssp (llambda sp unr-φ₂ ebody) ϱ κ with split-env sp ϱ ... | (G₁' , G₂') , ss-g1-g1'-g2' , ϱ₁ , ϱ₂ with unrestricted-venv unr-φ₂ ϱ₂ ... | ina-G2' with inactive-right-ssplit ss-g1-g1'-g2' ina-G2' ... | refl = Ready ssp (VFun (inj₁ refl) ϱ₁ ebody) κ run{φ}{φ₁}{φ₂} tsp ssp e@(rec unr-φ ebody) ϱ κ with unrestricted-venv unr-φ ϱ ... | ina-G2' with inactive-right-ssplit (ssplit-sym ssp) ina-G2' ... | refl = Ready ssp (VFun (inj₂ unr-φ) ϱ (unr-subst UFun (rght (split-all-unr unr-φ)) unr-φ e ebody)) κ run tsp ssp (app sp efun earg) ϱ κ with split-env sp ϱ ... | (G₁ , G₂) , ss-gg , ϱ₁ , ϱ₂ with access ϱ₁ efun ... | G₃ , G₄ , ina-G₄ , ss-g1g3g4 , vfun with access ϱ₂ earg run{φ}{φ₁}{φ₂} tsp ssp (app sp efun earg) ϱ κ | (G₁ , G₂) , ss-gg , ϱ₁ , ϱ₂ | G₃ , G₄ , ina-G₄ , ss-g1g3g4 , VFun{φ'} x ϱ₃ e | G₅ , G₆ , ina-G₆ , ss-g2g5g6 , varg with ssplit-compose4 ss-gg ss-g2g5g6 ... | Gi , ss-g1-g5-gi , ss-gi-g1-g6 with ssplit-compose ssp ss-g1-g5-gi ... | Gi₁ , ss-g-g5-gi1 , ss-gi1-gi-g2 with inactive-right-ssplit ss-g1g3g4 ina-G₄ ... | refl with inactive-right-ssplit ss-gi-g1-g6 ina-G₆ ... | refl with split-from-disjoint φ' φ₂ ... | φ₀ , sp' = Ready ss-g-g5-gi1 varg (bind sp' ss-gi1-gi-g2 e ϱ₃ κ) run tsp ssp (subsume e t≤t') ϱ κ = run tsp ssp e ϱ (subsume t≤t' κ) -- apply a continuation apply-cont : ∀ {G G₁ G₂ t φ} → (ssp : SSplit G G₁ G₂) → (κ : Cont G₂ φ t) → Val G₁ t → Command G apply-cont ssp (halt inG un-t) v with unrestricted-val un-t v ... | inG2 with inactive-right-ssplit ssp inG ... | refl = Halt (ssplit-inactive ssp inG2 inG) un-t v apply-cont ssp (bind ts ss e₂ ϱ₂ κ) v with ssplit-compose3 ssp ss ... | Gi , ss-GGiG4 , ss-GiG1G3 = run (left ts) ss-GGiG4 e₂ (vcons ss-GiG1G3 v ϱ₂) κ apply-cont ssp (bind-thunk ts ss e₂ ϱ₂ κ) v with unrestricted-val UUnit v ... | inG1 with inactive-left-ssplit ssp inG1 ... | refl = run ts ss e₂ ϱ₂ κ apply-cont ssp (subsume t≤t' κ) v = apply-cont ssp κ (coerce v t≤t') extract-inactive-from-cont : ∀ {G t φ} → Unr t → Cont G φ t → ∃ λ G' → Inactive G' × SSplit G G' G extract-inactive-from-cont{G} un-t κ = ssplit-refl-right-inactive G -- lifting through a trivial extension lift-val : ∀ {G t} → Val G t → Val (nothing ∷ G) t lift-venv : ∀ {G φ} → VEnv G φ → VEnv (nothing ∷ G) φ lift-val (VUnit x) = VUnit (::-inactive x) lift-val (VInt i x) = VInt i (::-inactive x) lift-val (VPair x v v₁) = VPair (ss-both x) (lift-val v) (lift-val v₁) lift-val (VChan b vcr) = VChan b (there vcr) lift-val (VFun lu ϱ e) = VFun lu (lift-venv ϱ) e lift-venv (vnil ina) = vnil (::-inactive ina) lift-venv (vcons ssp v ϱ) = vcons (ss-both ssp) (lift-val v) (lift-venv ϱ) lift-cont : ∀ {G t φ} → Cont G φ t → Cont (nothing ∷ G) φ t lift-cont (halt inG un-t) = halt (::-inactive inG) un-t lift-cont (bind ts ss e₂ ϱ₂ κ) = bind ts (ss-both ss) e₂ (lift-venv ϱ₂) (lift-cont κ) lift-cont (bind-thunk ts ss e₂ ϱ₂ κ) = bind-thunk ts (ss-both ss) e₂ (lift-venv ϱ₂) (lift-cont κ) lift-cont (subsume t≤t' κ) = subsume t≤t' (lift-cont κ) lift-command : ∀ {G} → Command G → Command (nothing ∷ G) lift-command (Fork ss κ₁ κ₂) = Fork (ss-both ss) (lift-cont κ₁) (lift-cont κ₂) lift-command (Ready ss v κ) = Ready (ss-both ss) (lift-val v) (lift-cont κ) lift-command (Halt x unr-t v) = Halt (::-inactive x) unr-t (lift-val v) lift-command (New s κ) = New s (lift-cont κ) lift-command (Close ss v κ) = Close (ss-both ss) (lift-val v) (lift-cont κ) lift-command (Wait ss v κ) = Wait (ss-both ss) (lift-val v) (lift-cont κ) lift-command (Send ss ss-args vch v κ) = Send (ss-both ss) (ss-both ss-args) (lift-val vch) (lift-val v) (lift-cont κ) lift-command (Recv ss vch κ) = Recv (ss-both ss) (lift-val vch) (lift-cont κ) lift-command (Select ss lab vch κ) = Select (ss-both ss) lab (lift-val vch) (lift-cont κ) lift-command (Branch ss vch dcont) = Branch (ss-both ss) (lift-val vch) λ lab → lift-cont (dcont lab) lift-command (NSelect ss lab vch κ) = NSelect (ss-both ss) lab (lift-val vch) (lift-cont κ) lift-command (NBranch ss vch dcont) = NBranch (ss-both ss) (lift-val vch) λ lab → lift-cont (dcont lab) -- threads data ThreadPool (G : SCtx) : Set where tnil : (ina : Inactive G) → ThreadPool G tcons : ∀ {G₁ G₂} → (ss : SSplit G G₁ G₂) → (cmd : Command G₁) → (tp : ThreadPool G₂) → ThreadPool G -- tack a task to the end of a thread pool to implement round robin scheduling tsnoc : ∀ {G Gpool Gcmd} → SSplit G Gcmd Gpool → ThreadPool Gpool → Command Gcmd → ThreadPool G tsnoc ss (tnil ina) cmd = tcons ss cmd (tnil ina) tsnoc ss (tcons ss₁ cmd₁ tp) cmd with ssplit-compose2 ss ss₁ ... | Gi , ss-top , ss-rec = tcons (ssplit-sym ss-top) cmd₁ (tsnoc ss-rec tp cmd) -- append thread pools tappend : ∀ {G G1 G2} → SSplit G G1 G2 → ThreadPool G1 → ThreadPool G2 → ThreadPool G tappend ss-top (tnil ina) tp2 rewrite inactive-left-ssplit ss-top ina = tp2 tappend ss-top (tcons ss cmd tp1) tp2 with ssplit-compose ss-top ss ... | Gi , ss-top' , ss-rec = tcons ss-top' cmd (tappend ss-rec tp1 tp2) -- apply the inactive extension to a thread pool lift-threadpool : ∀ {G} → ThreadPool G → ThreadPool (nothing ∷ G) lift-threadpool (tnil ina) = tnil (::-inactive ina) lift-threadpool (tcons ss cmd tp) = tcons (ss-both ss) (lift-command cmd) (lift-threadpool tp) matchWaitAndGo : ∀ {G Gc Gc₁ Gc₂ Gtp Gtpwl Gtpacc φ} → SSplit G Gc Gtp -- close command → SSplit Gc Gc₁ Gc₂ × Val Gc₁ (TChan send!) × Cont Gc₂ φ TUnit -- focused thread pool → SSplit Gtp Gtpwl Gtpacc → ThreadPool Gtpwl → ThreadPool Gtpacc → Maybe (∃ λ G' → ThreadPool G') matchWaitAndGo ss-top cl-info ss-tp (tnil ina) tp-acc = nothing matchWaitAndGo ss-top cl-info ss-tp (tcons ss (Fork ss₁ κ₁ κ₂) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchWaitAndGo ss-top cl-info ss-tp' tp-wl (tcons ss' (Fork ss₁ κ₁ κ₂) tp-acc) matchWaitAndGo ss-top cl-info ss-tp (tcons ss (Ready ss₁ v κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchWaitAndGo ss-top cl-info ss-tp' tp-wl (tcons ss' (Ready ss₁ v κ) tp-acc) matchWaitAndGo ss-top cl-info ss-tp (tcons ss cmd@(Halt x _ _) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchWaitAndGo ss-top cl-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchWaitAndGo ss-top cl-info ss-tp (tcons ss (New s κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchWaitAndGo ss-top cl-info ss-tp' tp-wl (tcons ss' (New s κ) tp-acc) matchWaitAndGo ss-top cl-info ss-tp (tcons ss cmd@(NSelect ss-args lab vch κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchWaitAndGo ss-top cl-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchWaitAndGo ss-top cl-info ss-tp (tcons ss cmd@(Select ss-args lab vch κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchWaitAndGo ss-top cl-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchWaitAndGo ss-top cl-info ss-tp (tcons ss cmd@(NBranch _ _ _) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchWaitAndGo ss-top cl-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchWaitAndGo ss-top cl-info ss-tp (tcons ss cmd@(Branch _ _ _) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchWaitAndGo ss-top cl-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchWaitAndGo ss-top cl-info ss-tp (tcons ss cmd@(Send _ ss-args vch v κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchWaitAndGo ss-top cl-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchWaitAndGo ss-top cl-info ss-tp (tcons ss cmd@(Recv _ vch κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchWaitAndGo ss-top cl-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchWaitAndGo ss-top cl-info ss-tp (tcons ss (Close ss₁ v κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchWaitAndGo ss-top cl-info ss-tp' tp-wl (tcons ss' (Close ss₁ v κ) tp-acc) matchWaitAndGo ss-top (ss-cl , VChan cl-b cl-vcr , cl-κ) ss-tp (tcons ss (Wait ss₁ (VChan w-b w-vcr) κ) tp-wl) tp-acc with ssplit-compose6 ss ss₁ ... | Gi , ss-g3gi , ss-g4g2 with ssplit-compose6 ss-tp ss-g3gi ... | Gi' , ss-g3gi' , ss-gtpacc with ssplit-join ss-top ss-cl ss-g3gi' ... | Gchannels , Gother , ss-top' , ss-channels , ss-others with vcr-match ss-channels cl-vcr w-vcr matchWaitAndGo ss-top (ss-cl , VChan cl-b cl-vcr , cl-κ) ss-tp (tcons ss (Wait ss₁ (VChan w-b w-vcr) κ) tp-wl) tp-acc | Gi , ss-g3gi , ss-g4g2 | Gi' , ss-g3gi' , ss-gtpacc | Gchannels , Gother , ss-top' , ss-channels , ss-others | nothing with ssplit-compose5 ss-tp ss ... | _ , ss-tp' , ss' = matchWaitAndGo ss-top (ss-cl , VChan cl-b cl-vcr , cl-κ) ss-tp' tp-wl (tcons ss' (Wait ss₁ (VChan w-b w-vcr) κ) tp-acc) matchWaitAndGo{Gc₂ = Gc₂} ss-top (ss-cl , VChan cl-b cl-vcr , cl-κ) ss-tp (tcons ss (Wait ss₁ (VChan w-b w-vcr) κ) tp-wl) tp-acc | Gi , ss-g3gi , ss-g4g2 | Gi' , ss-g3gi' , ss-gtpacc | Gchannels , Gother , ss-top' , ss-channels , ss-others | just x with ssplit-refl-right-inactive Gc₂ ... | Gunit , ina-Gunit , ss-stopped with extract-inactive-from-cont UUnit κ ... | Gunit' , ina-Gunit' , ss-stopped' with ssplit-compose ss-gtpacc (ssplit-sym ss-g4g2) ... | Gi'' , ss-int , ss-g2gacc with ssplit-compose2 ss-others ss-int ... | Gi''' , ss-other , ss-outer-cons = just (Gother , tappend (ssplit-sym ss-other) tp-wl (tcons ss-outer-cons (Ready ss-stopped (VUnit ina-Gunit) cl-κ) (tcons ss-g2gacc (Ready ss-stopped' (VUnit ina-Gunit') κ) tp-acc))) matchSendAndGo : ∀ {G Gc Gc₁ Gc₂ Gtp Gtpwl Gtpacc φ t s} → SSplit G Gc Gtp -- read command → SSplit Gc Gc₁ Gc₂ × Val Gc₁ (TChan (Typing.recv t s)) × Cont Gc₂ φ (TPair (TChan (SType.force s)) t) -- focused thread pool → SSplit Gtp Gtpwl Gtpacc → ThreadPool Gtpwl → ThreadPool Gtpacc → Maybe (∃ λ G' → ThreadPool G') matchSendAndGo ss-top recv-info ss-tp (tnil ina) tp-acc = nothing matchSendAndGo ss-top recv-info ss-tp (tcons ss cmd@(Fork ss₁ κ₁ κ₂) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchSendAndGo ss-top recv-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchSendAndGo ss-top recv-info ss-tp (tcons ss cmd@(Ready ss₁ v κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchSendAndGo ss-top recv-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchSendAndGo ss-top recv-info ss-tp (tcons ss cmd@(Halt _ _ _) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchSendAndGo ss-top recv-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchSendAndGo ss-top recv-info ss-tp (tcons ss cmd@(New s κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchSendAndGo ss-top recv-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchSendAndGo ss-top recv-info ss-tp (tcons ss cmd@(NSelect ss-arg lab vch κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchSendAndGo ss-top recv-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchSendAndGo ss-top recv-info ss-tp (tcons ss cmd@(Select ss-arg lab vch κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchSendAndGo ss-top recv-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchSendAndGo ss-top recv-info ss-tp (tcons ss cmd@(NBranch _ _ _) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchSendAndGo ss-top recv-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchSendAndGo ss-top recv-info ss-tp (tcons ss cmd@(Branch _ _ _) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchSendAndGo ss-top recv-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchSendAndGo ss-top recv-info ss-tp (tcons ss cmd@(Close ss₁ v κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchSendAndGo ss-top recv-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchSendAndGo ss-top recv-info ss-tp (tcons ss cmd@(Wait ss₁ v κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchSendAndGo ss-top recv-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchSendAndGo ss-top recv-info ss-tp (tcons ss cmd@(Recv ss₁ vch κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchSendAndGo ss-top recv-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchSendAndGo ss-top recv-info@(ss-rv , VChan b₁ vcr₁ , κ-rv) ss-tp (tcons ss cmd@(Send ss₁ ss-args (VChan b vcr) v κ) tp-wl) tp-acc with ssplit-compose6 ss₁ ss-args ... | Gi , ss-g1g11gi , ss-gig12g3 with ssplit-compose6 ss ss-g1g11gi ... | Gi' , ss-gtpwlg11g2 , ss-gi'gig2 with ssplit-compose6 ss-tp ss-gtpwlg11g2 ... | Gi'' , ss-gtpg11gi'' , ss-gi''gi'gtpacc with ssplit-join ss-top ss-rv ss-gtpg11gi'' ... | G₁' , G₂' , ss-gg1'g2' , ss-g1'gc1g11 , ss-g2'gc2gi'' with vcr-match-2-sr (ssplit2 ss-gg1'g2' ss-g1'gc1g11) vcr₁ vcr ... | just (t≤t1 , ds1≡s , GG , GG1 , GG11 , G12 , ssplit2 ss-out1 ss-out2 , vcr-recv , vcr-send) with ssplit-compose ss-gi''gi'gtpacc ss-gi'gig2 ... | GSi , ss-Gi''GiGi1 , ss-Gi1G2Gtpacc with ssplit-join ss-out1 ss-out2 ss-g2'gc2gi'' ... | GG1' , GG2' , ss-GG-GG1'-GG2' , ss-GG1'-GG11-Gc2 , ss-GG2'-G12-Gi'' with ssplit-rotate ss-GG2'-G12-Gi'' ss-Gi''GiGi1 ss-gig12g3 ... | Gi''+ , Gi+ , ss-GG2-G12-Gi''+ , ss-Gi''+Gi+Gsi , ss-Gi+-G12-G4 with ssplit-join ss-GG-GG1'-GG2' ss-GG1'-GG11-Gc2 ss-GG2-G12-Gi''+ ... | GG1'' , GG2'' , ss-GG-GG1''-GG2'' , ss-GG1''-GG11-G12 , ss-GG2''-Gc2-Gi''+ with ssplit-compose3 ss-GG-GG1''-GG2'' ss-GG2''-Gc2-Gi''+ ... | _ , ss-GG-Gii-Gi''+ , ss-Gii-GG1''-Gc2 = just (GG , (tcons ss-GG-Gii-Gi''+ (Ready ss-Gii-GG1''-Gc2 (VPair ss-GG1''-GG11-G12 (VChan b₁ vcr-recv) (coerce v t≤t1)) κ-rv {-κ-rv-}) (tcons ss-Gi''+Gi+Gsi (Ready ss-Gi+-G12-G4 (VChan b vcr-send) κ) (tappend ss-Gi1G2Gtpacc tp-wl tp-acc)))) matchSendAndGo ss-top recv-info@(ss-rv , VChan b₁ vcr₁ , κ-rv) ss-tp (tcons ss cmd@(Send ss₁ ss-args (VChan b vcr) v κ) tp-wl) tp-acc | Gi , ss-g1g11gi , ss-gig12g3 | Gi' , ss-gtpwlg11g2 , ss-gi'gig2 | Gi'' , ss-gtpg11gi'' , ss-gi''gi'gtpacc | G₁' , G₂' , ss-gg1'g2' , ss-g1'gc1g11 , ss-g2'gc2gi'' | nothing with ssplit-compose5 ss-tp ss ... | Gi0 , ss-tp' , ss' = matchSendAndGo ss-top recv-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchBranchAndGo : ∀ {G Gc Gc₁ Gc₂ Gtp Gtpwl Gtpacc φ s₁ s₂} → SSplit G Gc Gtp -- select command → (SSplit Gc Gc₁ Gc₂ × ∃ λ lab → Val Gc₁ (TChan (sintern s₁ s₂)) × Cont Gc₂ φ (TChan (selection lab (SType.force s₁) (SType.force s₂)))) -- focused thread pool → SSplit Gtp Gtpwl Gtpacc → ThreadPool Gtpwl → ThreadPool Gtpacc → Maybe (∃ λ G' → ThreadPool G') matchBranchAndGo ss-top select-info ss-tp (tnil ina) tp-acc = nothing matchBranchAndGo ss-top select-info ss-tp (tcons ss cmd@(Fork ss₁ κ₁ κ₂) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchBranchAndGo ss-top select-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchBranchAndGo ss-top select-info ss-tp (tcons ss cmd@(Ready ss₁ v κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchBranchAndGo ss-top select-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchBranchAndGo ss-top select-info ss-tp (tcons ss cmd@(Halt _ _ _) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchBranchAndGo ss-top select-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchBranchAndGo ss-top select-info ss-tp (tcons ss cmd@(New s κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchBranchAndGo ss-top select-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchBranchAndGo ss-top select-info ss-tp (tcons ss cmd@(Close ss₁ v κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchBranchAndGo ss-top select-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchBranchAndGo ss-top select-info ss-tp (tcons ss cmd@(Wait ss₁ v κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchBranchAndGo ss-top select-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchBranchAndGo ss-top select-info ss-tp (tcons ss cmd@(Send ss₁ ss-args vch v κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchBranchAndGo ss-top select-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchBranchAndGo ss-top select-info ss-tp (tcons ss cmd@(Recv ss₁ vch κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchBranchAndGo ss-top select-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchBranchAndGo ss-top select-info ss-tp (tcons ss cmd@(NSelect ss₁ lab vch κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchBranchAndGo ss-top select-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchBranchAndGo ss-top select-info ss-tp (tcons ss cmd@(NBranch _ _ _) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchBranchAndGo ss-top select-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchBranchAndGo ss-top select-info ss-tp (tcons ss cmd@(Select ss₁ lab vch κ) tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchBranchAndGo ss-top select-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchBranchAndGo ss-top (ss-vκ , lab , VChan b₁ vcr₁ , κ) ss-tp (tcons ss (Branch ss₁ (VChan b vcr) dcont) tp-wl) tp-acc with ssplit-compose6 ss ss₁ ... | Gi , ss-gtpwl-g3-gi , ss-gi-g4-g2 with ssplit-compose6 ss-tp ss-gtpwl-g3-gi ... | Gi1 , ss-gtp-g3-gi1 , ss-gi1-gi-gtpacc with ssplit-join ss-top ss-vκ ss-gtp-g3-gi1 ... | Gc' , Gtp' , ss-g-gc'-gtp' , ss-gc'-gc1-g1 , ss-gtp'-gc2-gi1 with vcr-match-2-sb (ssplit2 ss-g-gc'-gtp' ss-gc'-gc1-g1) vcr₁ vcr lab matchBranchAndGo ss-top select-info@(ss-vκ , lab , VChan b₁ vcr₁ , κ) ss-tp (tcons ss cmd@(Branch ss₁ (VChan b vcr) dcont) tp-wl) tp-acc | Gi , ss-gtpwl-g3-gi , ss-gi-g4-g2 | Gi1 , ss-gtp-g3-gi1 , ss-gi1-gi-gtpacc | Gc' , Gtp' , ss-g-gc'-gtp' , ss-gc'-gc1-g1 , ss-gtp'-gc2-gi1 | nothing with ssplit-compose5 ss-tp ss ... | Gix , ss-tp' , ss' = matchBranchAndGo ss-top select-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchBranchAndGo ss-top (ss-vκ , lab , VChan b₁ vcr₁ , κ) ss-tp (tcons ss (Branch ss₁ (VChan b vcr) dcont) tp-wl) tp-acc | Gi , ss-gtpwl-g3-gi , ss-gi-g4-g2 | Gi1 , ss-gtp-g3-gi1 , ss-gi1-gi-gtpacc | Gc' , Gtp' , ss-g-gc'-gtp' , ss-gc'-gc1-g1 , ss-gtp'-gc2-gi1 | just (ds3=s1 , ds4=s2 , GG , GG1 , GG11 , GG12 , ssplit2 ss1' ss2' , vcr-sel , vcr-bra) with ssplit-compose ss-gi1-gi-gtpacc ss-gi-g4-g2 ... | Gi2 , ss-gi1-g3-gi2 , ss-gi2-g2-gtpacc with ssplit-join ss1' ss2' ss-gtp'-gc2-gi1 ... | GGG1 , GGG2 , ss-GG-ggg1-ggg2 , ss-ggg1-gc1-gc2 , ss-ggg2-g1-gi1 with ssplit-compose3 ss-ggg2-g1-gi1 ss-gi1-g3-gi2 ... | Gi3 , ss-ggg2-gi3-gi2 , ss-gi3-gg12-g2 = just (GG , tcons ss-GG-ggg1-ggg2 (Ready ss-ggg1-gc1-gc2 (VChan b₁ vcr-sel) κ) (tcons ss-ggg2-gi3-gi2 (Ready ss-gi3-gg12-g2 (VChan b vcr-bra) (dcont lab)) (tappend ss-gi2-g2-gtpacc tp-wl tp-acc))) matchNBranchAndGo : ∀ {G Gc Gc₁ Gc₂ Gtp Gtpwl Gtpacc φ m alt} → SSplit G Gc Gtp -- select command → (SSplit Gc Gc₁ Gc₂ × Σ (Fin m) λ lab → Val Gc₁ (TChan (sintN m alt)) × Cont Gc₂ φ (TChan (SType.force (alt lab)))) -- focused thread pool → SSplit Gtp Gtpwl Gtpacc → ThreadPool Gtpwl → ThreadPool Gtpacc → Maybe (∃ λ G' → ThreadPool G') matchNBranchAndGo ss-top nselect-info ss-tp (tnil ina) tp-acc = nothing matchNBranchAndGo ss-top (ss-vκ , lab , VChan b₁ vcr₁ , κ) ss-tp (tcons ss cmd@(NBranch ss₁ (VChan b vcr) dcont) tp-wl) tp-acc with ssplit-compose6 ss ss₁ ... | Gi , ss-gtpwl-g3-gi , ss-gi-g4-g2 with ssplit-compose6 ss-tp ss-gtpwl-g3-gi ... | Gi1 , ss-gtp-g3-gi1 , ss-gi1-gi-gtpacc with ssplit-join ss-top ss-vκ ss-gtp-g3-gi1 ... | Gc' , Gtp' , ss-g-gc'-gtp' , ss-gc'-gc1-g1 , ss-gtp'-gc2-gi1 with vcr-match-2-nsb (ssplit2 ss-g-gc'-gtp' ss-gc'-gc1-g1) vcr₁ vcr lab matchNBranchAndGo ss-top nselect-info@(ss-vκ , lab , VChan b₁ vcr₁ , κ) ss-tp (tcons ss cmd@(NBranch ss₁ (VChan b vcr) dcont) tp-wl) tp-acc | Gi , ss-gtpwl-g3-gi , ss-gi-g4-g2 | Gi1 , ss-gtp-g3-gi1 , ss-gi1-gi-gtpacc | Gc' , Gtp' , ss-g-gc'-gtp' , ss-gc'-gc1-g1 , ss-gtp'-gc2-gi1 | nothing with ssplit-compose5 ss-tp ss ... | Gix , ss-tp' , ss' = matchNBranchAndGo ss-top nselect-info ss-tp' tp-wl (tcons ss' cmd tp-acc) matchNBranchAndGo ss-top (ss-vκ , lab , VChan b₁ vcr₁ , κ) ss-tp (tcons ss (NBranch ss₁ (VChan b vcr) dcont) tp-wl) tp-acc | Gi , ss-gtpwl-g3-gi , ss-gi-g4-g2 | Gi1 , ss-gtp-g3-gi1 , ss-gi1-gi-gtpacc | Gc' , Gtp' , ss-g-gc'-gtp' , ss-gc'-gc1-g1 , ss-gtp'-gc2-gi1 | just (m1≤m , ds3=s1 , GG , GG1 , GG11 , GG12 , ssplit2 ss1' ss2' , vcr-sel , vcr-bra) with ssplit-compose ss-gi1-gi-gtpacc ss-gi-g4-g2 ... | Gi2 , ss-gi1-g3-gi2 , ss-gi2-g2-gtpacc with ssplit-join ss1' ss2' ss-gtp'-gc2-gi1 ... | GGG1 , GGG2 , ss-GG-ggg1-ggg2 , ss-ggg1-gc1-gc2 , ss-ggg2-g1-gi1 with ssplit-compose3 ss-ggg2-g1-gi1 ss-gi1-g3-gi2 ... | Gi3 , ss-ggg2-gi3-gi2 , ss-gi3-gg12-g2 = just (GG , tcons ss-GG-ggg1-ggg2 (Ready ss-ggg1-gc1-gc2 (VChan b₁ vcr-sel) κ) (tcons ss-ggg2-gi3-gi2 (Ready ss-gi3-gg12-g2 (VChan b vcr-bra) (dcont (inject≤ lab m1≤m))) (tappend ss-gi2-g2-gtpacc tp-wl tp-acc))) matchNBranchAndGo ss-top nselect-info ss-tp (tcons ss cmd tp-wl) tp-acc with ssplit-compose5 ss-tp ss ... | Gi , ss-tp' , ss' = matchNBranchAndGo ss-top nselect-info ss-tp' tp-wl (tcons ss' cmd tp-acc)
{ "alphanum_fraction": 0.6464880171, "avg_line_length": 63.2270742358, "ext": "agda", "hexsha": "e67a8b15a25a2f62fbfd9c794b5d5aa87bcec794", "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": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "peterthiemann/definitional-session", "max_forks_repo_path": "src/Session.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c", "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": "peterthiemann/definitional-session", "max_issues_repo_path": "src/Session.agda", "max_line_length": 400, "max_stars_count": 9, "max_stars_repo_head_hexsha": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "peterthiemann/definitional-session", "max_stars_repo_path": "src/Session.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-18T08:10:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-19T16:33:27.000Z", "num_tokens": 12093, "size": 28958 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Displayed.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.Transport open import Cubical.Functions.FunExtEquiv open import Cubical.Data.Sigma open import Cubical.Relation.Binary private variable ℓ ℓA ℓA' ℓ≅A ℓB ℓB' ℓ≅B ℓC ℓ≅C : Level record UARel (A : Type ℓA) (ℓ≅A : Level) : Type (ℓ-max ℓA (ℓ-suc ℓ≅A)) where no-eta-equality constructor uarel field _≅_ : A → A → Type ℓ≅A ua : (a a' : A) → (a ≅ a') ≃ (a ≡ a') uaIso : (a a' : A) → Iso (a ≅ a') (a ≡ a') uaIso a a' = equivToIso (ua a a') ≅→≡ : {a a' : A} (p : a ≅ a') → a ≡ a' ≅→≡ {a} {a'} = Iso.fun (uaIso a a') ≡→≅ : {a a' : A} (p : a ≡ a') → a ≅ a' ≡→≅ {a} {a'} = Iso.inv (uaIso a a') ρ : (a : A) → a ≅ a ρ a = ≡→≅ refl open BinaryRelation -- another constructor for UARel using contractibility of relational singletons make-𝒮 : {A : Type ℓA} {ℓ≅A : Level} {_≅_ : A → A → Type ℓ≅A} (ρ : isRefl _≅_) (contrTotal : contrRelSingl _≅_) → UARel A ℓ≅A UARel._≅_ (make-𝒮 {_≅_ = _≅_} _ _) = _≅_ UARel.ua (make-𝒮 {_≅_ = _≅_} ρ c) = contrRelSingl→isUnivalent _≅_ ρ c record DUARel {A : Type ℓA} {ℓ≅A : Level} (𝒮-A : UARel A ℓ≅A) (B : A → Type ℓB) (ℓ≅B : Level) : Type (ℓ-max (ℓ-max ℓA ℓB) (ℓ-max ℓ≅A (ℓ-suc ℓ≅B))) where no-eta-equality constructor duarel open UARel 𝒮-A field _≅ᴰ⟨_⟩_ : {a a' : A} → B a → a ≅ a' → B a' → Type ℓ≅B uaᴰ : {a a' : A} (b : B a) (p : a ≅ a') (b' : B a') → (b ≅ᴰ⟨ p ⟩ b') ≃ PathP (λ i → B (≅→≡ p i)) b b' fiberRel : (a : A) → Rel (B a) (B a) ℓ≅B fiberRel a = _≅ᴰ⟨ ρ a ⟩_ uaᴰρ : {a : A} (b b' : B a) → b ≅ᴰ⟨ ρ a ⟩ b' ≃ (b ≡ b') uaᴰρ {a} b b' = compEquiv (uaᴰ b (ρ _) b') (substEquiv (λ q → PathP (λ i → B (q i)) b b') (retEq (ua a a) refl)) ρᴰ : {a : A} → (b : B a) → b ≅ᴰ⟨ ρ a ⟩ b ρᴰ {a} b = invEq (uaᴰρ b b) refl
{ "alphanum_fraction": 0.5463510848, "avg_line_length": 29.8235294118, "ext": "agda", "hexsha": "83904b825c6956f13a10ec31eb03096a2c2a7372", "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/Displayed/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/Displayed/Base.agda", "max_line_length": 105, "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/Displayed/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1013, "size": 2028 }
module Numeric.Nat.Prime.FundamentalTheorem where open import Prelude open import Control.WellFounded open import Container.List open import Container.List.Permutation open import Container.List.Properties open import Numeric.Nat open import Tactic.Nat --- Some lemmas ---------- private primeProd=1-is-empty : ∀ ps → All Prime ps → productR ps ≡ 1 → ps ≡ [] primeProd=1-is-empty [] _ _ = refl primeProd=1-is-empty (p ∷ ps) (prime p>1 _ ∷ _) pps=1 = let p=1 : p ≡ 1 p=1 = mul=1-l p (productR ps) pps=1 in case p=1 of λ where refl → refute p>1 0<1<2 : ∀ {n} ⦃ _ : NonZero n ⦄ → n < 2 → n ≡ 1 0<1<2 {0} ⦃ () ⦄ n<2 0<1<2 {1} n<2 = refl 0<1<2 {suc (suc _)} n<2 = refute n<2 1>0 : ∀ {n} → n > 1 → NonZero n 1>0 {0} n>1 = refute n>1 1>0 {suc _} _ = _ product-deleteIx : ∀ {a} ⦃ _ : NonZero a ⦄ (as : List Nat) (i : a ∈ as) → productR as ≡ a * productR (deleteIx as i) product-deleteIx (a ∷ as) zero! = refl product-deleteIx {a} (b ∷ as) (suc i) = b * productR as ≡⟨ b *_ $≡ product-deleteIx as i ⟩ b * productR (a ∷ deleteIx as i) ≡⟨ auto ⟩ a * productR (b ∷ deleteIx as i) ∎ --- Factorisation --------- record Factorisation (n : Nat) : Set where no-eta-equality constructor mkFactors field factors : List Nat factors-prime : All Prime factors factors-sound : productR factors ≡ n open Factorisation mul-factors : ∀ {a b} → Factorisation a → Factorisation b → Factorisation (a * b) mul-factors {a} {b} (mkFactors ps psP ps=a) (mkFactors qs qsP qs=b) = mkFactors (ps ++ qs) (psP ++All qsP) $ productR (ps ++ qs) ≡⟨ product-++ ps _ ⟩ productR ps * productR qs ≡⟨ _*_ $≡ ps=a *≡ qs=b ⟩ a * b ∎ private factorise′ : ∀ n ⦃ _ : NonZero n ⦄ → Acc _<_ n → Factorisation n factorise′ n (acc wf) = case isPrime n of λ where (yes p) → mkFactors (n ∷ []) (p ∷ []) auto (no (composite a b a>1 b>1 refl)) → let instance _ = 1>0 a>1; _ = 1>0 b>1 in mul-factors (factorise′ a (wf a (less-mul-l a>1 b>1))) (factorise′ b (wf b (less-mul-r a>1 b>1))) (tiny n<2) → mkFactors [] [] (sym (0<1<2 n<2)) find-prime : ∀ p ps → Prime p → All Prime ps → p Divides productR ps → p ∈ ps find-prime p [] isP isPs p|1 = ⊥-elim (prime-divide-coprime p 1 1 isP refl p|1 p|1) find-prime p (q ∷ qs) isP (qP ∷ isPs) p|qqs = case prime-split q (productR qs) isP p|qqs of λ where (left p|q) → zero (prime-divide-prime isP qP p|q) (right p|qs) → suc (find-prime p qs isP isPs p|qs) unique : (ps qs : List Nat) → All Prime ps → All Prime qs → productR ps ≡ productR qs → Permutation ps qs unique [] qs ips iqs ps=qs = case primeProd=1-is-empty qs iqs (sym ps=qs) of λ where refl → [] unique (p ∷ ps) qs (pP ∷ psP) qsP pps=qs = let instance _ = prime-nonzero pP p|qs : p Divides productR qs p|qs = factor (productR ps) (by pps=qs) i : p ∈ qs i = find-prime p qs pP qsP p|qs ps=qs/p : productR ps ≡ productR (deleteIx qs i) ps=qs/p = mul-inj₂ p _ _ (pps=qs ⟨≡⟩ product-deleteIx qs i ) in i ∷ unique ps (deleteIx qs i) psP (deleteAllIx qsP i) ps=qs/p --- The Fundamental Theorem of arithmetic: -- any nonzero natural number can be factored into a product of primes, -- and the factorisation is unique up to permutation. factorise : (n : Nat) ⦃ _ : NonZero n ⦄ → Factorisation n factorise n = factorise′ n (wfNat n) factors-unique : ∀ {n} (f₁ f₂ : Factorisation n) → Permutation (factors f₁) (factors f₂) factors-unique (mkFactors ps psP ps=n) (mkFactors qs qsP qs=n) = unique ps qs psP qsP (ps=n ⟨≡⟩ʳ qs=n)
{ "alphanum_fraction": 0.5923202614, "avg_line_length": 37.4693877551, "ext": "agda", "hexsha": "81935861a328c8408e810d0a20e3220077b0fb44", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_path": "src/Numeric/Nat/Prime/FundamentalTheorem.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lclem/agda-prelude", "max_issues_repo_path": "src/Numeric/Nat/Prime/FundamentalTheorem.agda", "max_line_length": 107, "max_stars_count": null, "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_path": "src/Numeric/Nat/Prime/FundamentalTheorem.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1384, "size": 3672 }
open import Agda.Primitive using (_⊔_) import Categories.Category as Category import Categories.Category.Cartesian as Cartesian import MultiSorted.Interpretation as Interpretation open import MultiSorted.AlgebraicTheory open import MultiSorted.Substitution import MultiSorted.Product as Product module MultiSorted.Model {o ℓ e ℓt} {𝓈 ℴ} {Σ : Signature {𝓈} {ℴ}} (T : Theory ℓt Σ) {𝒞 : Category.Category o ℓ e} {cartesian-𝒞 : Cartesian.Cartesian 𝒞} where -- Model of a theory record Is-Model (I : Interpretation.Interpretation Σ cartesian-𝒞) : Set (ℓt ⊔ o ⊔ ℓ ⊔ e) where open Theory T open Category.Category 𝒞 open Interpretation.Interpretation I open HomReasoning field model-eq : ∀ (ε : ax) → ⊨ ax-eq (ε) -- Soundness of semantics module _ where open Product.Producted interp-ctx -- first we show that substitution preserves validity model-resp-[]s : ∀ {Γ Δ} {A} {u v : Term Γ A} {σ : Δ ⇒s Γ} → interp-term u ≈ interp-term v → interp-term (u [ σ ]s) ≈ interp-term (v [ σ ]s) model-resp-[]s {u = u} {v = v} {σ = σ} ξ = begin interp-term (u [ σ ]s) ≈⟨ interp-[]s {t = u} ⟩ (interp-term u ∘ interp-subst σ) ≈⟨ ξ ⟩∘⟨refl ⟩ (interp-term v ∘ interp-subst σ) ≈˘⟨ interp-[]s {t = v} ⟩ interp-term (v [ σ ]s) ∎ -- the soundness statement ⊢-⊨ : ∀ {ε : Equation Σ} → ⊢ ε → ⊨ ε ⊢-⊨ eq-refl = Equiv.refl ⊢-⊨ (eq-symm ξ) = ⟺ (⊢-⊨ ξ) ⊢-⊨ (eq-tran ξ θ) = ⊢-⊨ ξ ○ ⊢-⊨ θ ⊢-⊨ (eq-congr ξ) = ∘-resp-≈ʳ (unique λ i → project ○ ⟺ (⊢-⊨ (ξ i))) ⊢-⊨ (eq-axiom ε σ) = model-resp-[]s {u = ax-lhs ε} {v = ax-rhs ε} (model-eq ε) -- Every theory has the trivial model, whose carrier is the terminal object Trivial : Is-Model (Interpretation.Trivial Σ cartesian-𝒞) Trivial = let open Cartesian.Cartesian cartesian-𝒞 in record { model-eq = λ ε → !-unique₂ }
{ "alphanum_fraction": 0.5795856493, "avg_line_length": 34.7192982456, "ext": "agda", "hexsha": "7cc22a641c625709108355f373b9b191b82d1d25", "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/MultiSorted/Model.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/MultiSorted/Model.agda", "max_line_length": 102, "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/MultiSorted/Model.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": 733, "size": 1979 }
-- There are no level literals in the concrete syntax. This file tests -- if type errors use level literals. module LevelLiterals where open import Common.Level data ⊥ : Set₁ where DoubleNegated : ∀ {ℓ} → Set ℓ → Set DoubleNegated A = (A → ⊥) → ⊥
{ "alphanum_fraction": 0.7051792829, "avg_line_length": 20.9166666667, "ext": "agda", "hexsha": "1823fe1849ca54fb1136021e49e2043aa1c5c188", "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/LevelLiterals.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/LevelLiterals.agda", "max_line_length": 70, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/LevelLiterals.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": 73, "size": 251 }
{- Agda can check termination of Stream transducer operations. (Created: Andreas Abel, 2008-12-01 at Agda Intensive Meeting 9 in Sendai, Japan. I acknowledge the support by AIST and JST.) Stream transducers have been described in: N. Ghani, P. Hancock, and D. Pattinson, Continuous functions on final coalgebras. In Proc. CMCS 2006, Electr. Notes in Theoret. Comp. Sci., 2006. They have been modelled by mixed equi-(co)inductive sized types in A. Abel, Mixed Inductive/Coinductive Types and Strong Normalization. In APLAS 2007, LNCS 4807. Here we model them by mutual data/codata and mutual recursion/corecursion. -} module StreamProcEat where open import Common.Coinduction data Stream (A : Set) : Set where cons : A -> ∞ (Stream A) -> Stream A -- Stream Transducer: Trans A B -- intended semantics: Stream A -> Stream B mutual data Trans (A B : Set) : Set where 〈_〉 : ∞ (Trans' A B) -> Trans A B data Trans' (A B : Set) : Set where get : (A -> Trans' A B) -> Trans' A B put : B -> Trans A B -> Trans' A B out : forall {A B} -> Trans A B -> Trans' A B out 〈 p 〉 = ♭ p -- evaluating a stream transducer ("stream eating") mutual -- eat is defined by corecursion into Stream B eat : forall {A B} -> Trans A B -> Stream A -> Stream B eat 〈 sp 〉 as = eat' (♭ sp) as -- eat' is defined by a local recursion on Trans' A B eat' : forall {A B} -> Trans' A B -> Stream A -> Stream B eat' (get f) (cons a as) = eat' (f a) (♭ as) eat' (put b sp) as = cons b (♯ eat sp as) -- composing two stream transducers mutual -- comb is defined by corecursion into Trans A B comb : forall {A B C} -> Trans A B -> Trans B C -> Trans A C comb 〈 p1 〉 〈 p2 〉 = 〈 ♯ comb' (♭ p1) (♭ p2) 〉 -- comb' preforms a local lexicographic recursion on (Trans' B C, Trans' A B) comb' : forall {A B C} -> Trans' A B -> Trans' B C -> Trans' A C comb' (put b p1) (get f) = comb' (out p1) (f b) comb' (put b p1) (put c p2) = put c (comb p1 p2) comb' (get f) p2 = get (\ a -> comb' (f a) p2)
{ "alphanum_fraction": 0.6261545941, "avg_line_length": 29.3857142857, "ext": "agda", "hexsha": "4208fafc924538d75c079476fa8839cf19c76d59", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/StreamProcEat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Succeed/StreamProcEat.agda", "max_line_length": 79, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/StreamProcEat.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": 714, "size": 2057 }
{-# OPTIONS --cubical --safe #-} module HLevels where open import Path open import Cubical.Foundations.Everything using (isProp ;isSet ;isContr ;isPropIsContr ;isProp→isSet ;isOfHLevel→isOfHLevelDep ;hProp ;isSetHProp ;isPropIsProp ) public open import Level open import Data.Sigma hSet : ∀ ℓ → Type (ℓsuc ℓ) hSet ℓ = Σ (Type ℓ) isSet
{ "alphanum_fraction": 0.6144578313, "avg_line_length": 17.2916666667, "ext": "agda", "hexsha": "4ab5a541e6bb8825a3cea85a9398212a5a02346b", "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": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/HLevels.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/HLevels.agda", "max_line_length": 42, "max_stars_count": null, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/HLevels.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 138, "size": 415 }
open import Agda.Builtin.Size data D : Size → Set where postulate f : (i : Size) → D i data P : (i : Size) → D i → Set where c : (i j : Size) → P (i ⊔ˢ j) (f _)
{ "alphanum_fraction": 0.5443786982, "avg_line_length": 15.3636363636, "ext": "agda", "hexsha": "7c4e3757ac82559d89f27c474a3e70eff1f1cb30", "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": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/Issue2774.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/Issue2774.agda", "max_line_length": 37, "max_stars_count": 2, "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/Issue2774.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 70, "size": 169 }
open import Functional using (id) import Structure.Logic.Classical.NaturalDeduction module Structure.Logic.Classical.SetTheory {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} ⦃ classicLogic : _ ⦄ (_∈_ : Domain → Domain → Formula) where open Structure.Logic.Classical.NaturalDeduction.ClassicalLogic {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} (classicLogic) import Lvl open import Data.Tuple using () renaming (_⨯_ to _⨯ₘ_ ; _,_ to _,ₘ_) open import Functional using (_∘_) open import Syntax.Function open import Structure.Logic.Classical.SetTheory.SetBoundedQuantification ⦃ classicLogic ⦄ (_∈_) open import Structure.Logic.Classical.SetTheory.Relation ⦃ classicLogic ⦄ (_∈_) open import Structure.Logic.Constructive.Syntax.Algebra ⦃ classicLogic ⦄ open import Syntax.Transitivity open import Type [⊆]-reflexivity : Proof(∀ₗ(s ↦ s ⊆ s)) [⊆]-reflexivity = [∀].intro(\{_} → [∀].intro(\{_} → [→].reflexivity)) [⊆]-transitivity : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ ∀ₗ(c ↦ (a ⊆ b)∧(b ⊆ c) ⟶ (a ⊆ c))))) [⊆]-transitivity = ([∀].intro(\{a} → ([∀].intro(\{b} → ([∀].intro(\{c} → ([→].intro(abbc ↦ ([∀].intro(\{x} → ([→].transitivity ([∀].elim([∧].elimₗ abbc){x}) ([∀].elim([∧].elimᵣ abbc){x}) ) )) )) )) )) )) [⊆]-transitivable : Transitivable(_⊆_) [⊆]-transitivable = Transitivity-to-Transitivable [⊆]-transitivity [⊆][≡ₛ]-antisymmetry : Proof(∀ₗ(x ↦ ∀ₗ(y ↦ ((x ⊇ y) ∧ (x ⊆ y)) ⟶ (x ≡ₛ y)))) [⊆][≡ₛ]-antisymmetry = ([∀].intro(\{a} → ([∀].intro(\{b} → ([→].intro(abba ↦ ([∀].intro(\{x} → ([↔].intro ([→].elim([∀].elim([∧].elimₗ abba){x})) ([→].elim([∀].elim([∧].elimᵣ abba){x})) ) )) )) )) )) [≡ₛ]-to-[⊆] : Proof(∀ₗ(x ↦ ∀ₗ(y ↦ (x ≡ₛ y) ⟶ (x ⊆ y)))) [≡ₛ]-to-[⊆] = ([∀].intro(\{x} → ([∀].intro(\{y} → ([→].intro(x≡y ↦ ([∀].intro(\{a} → [→].intro([↔].elimᵣ([∀].elim x≡y {a})) )) )) )) )) [≡ₛ]-to-[⊇] : Proof(∀ₗ(x ↦ ∀ₗ(y ↦ (x ≡ₛ y) ⟶ (x ⊇ y)))) [≡ₛ]-to-[⊇] = ([∀].intro(\{x} → ([∀].intro(\{y} → ([→].intro(x≡y ↦ ([∀].intro(\{a} → [→].intro([↔].elimₗ([∀].elim x≡y {a})) )) )) )) )) [⊆][≡ₛ]-equivalence : Proof(∀ₗ(x ↦ ∀ₗ(y ↦ ((x ⊇ y) ∧ (x ⊆ y)) ⟷ (x ≡ₛ y)))) [⊆][≡ₛ]-equivalence = ([∀].intro(\{x} → ([∀].intro(\{y} → ([↔].intro (x≡y ↦ ([∧].intro ([→].elim([∀].elim([∀].elim [≡ₛ]-to-[⊇] {x}){y}) (x≡y)) ([→].elim([∀].elim([∀].elim [≡ₛ]-to-[⊆] {x}){y}) (x≡y)) ) ) ([→].elim([∀].elim([∀].elim [⊆][≡ₛ]-antisymmetry{x}){y})) ) )) )) [≡ₛ]-reflexivity : Proof(∀ₗ(s ↦ s ≡ₛ s)) [≡ₛ]-reflexivity = [∀].intro(\{_} → [∀].intro(\{_} → [↔].reflexivity)) [≡ₛ]-transitivity : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ ∀ₗ(c ↦ (a ≡ₛ b)∧(b ≡ₛ c) ⟶ (a ≡ₛ c))))) [≡ₛ]-transitivity = ([∀].intro(\{a} → ([∀].intro(\{b} → ([∀].intro(\{c} → ([→].intro(abbc ↦ ([∀].intro(\{x} → ( ([∀].elim([∧].elimₗ abbc){x}) 🝖 ([∀].elim([∧].elimᵣ abbc){x}) ) )) )) )) )) )) [≡ₛ]-transitivable : Transitivable(_≡ₛ_) [≡ₛ]-transitivable = Transitivity-to-Transitivable [≡ₛ]-transitivity [≡ₛ]-symmetry : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ (a ≡ₛ b) ⟶ (b ≡ₛ a)))) [≡ₛ]-symmetry = ([∀].intro(\{a} → ([∀].intro(\{b} → ([→].intro(ab ↦ ([∀].intro(\{x} → ([↔].commutativity ([∀].elim ab{x}) ) )) )) )) )) [≡ₛ]-from-equiv : ∀{A B : Domain}{Af Bf : Domain → Formula} → Proof(∀ₗ(x ↦ (x ∈ A) ⟷ Af(x))) → Proof(∀ₗ(x ↦ (x ∈ B) ⟷ Bf(x))) → Proof(∀ₗ(x ↦ Af(x) ⟷ Bf(x))) → Proof(A ≡ₛ B) [≡ₛ]-from-equiv aeq beq afbf = ([∀].intro(\{x} → ([↔].transitivity ([↔].transitivity ([∀].elim aeq) ([∀].elim afbf) ) ([↔].commutativity ([∀].elim beq)) ) )) record SetEquality : Type{ℓₘₗ Lvl.⊔ ℓₗ Lvl.⊔ ℓₒ} where constructor intro field extensional : Proof(∀ₗ(s₁ ↦ ∀ₗ(s₂ ↦ (s₁ ≡ₛ s₂) ⟷ (s₁ ≡ s₂)))) extensionalᵣ : ∀{s₁ s₂} → Proof(s₁ ≡ₛ s₂) → Proof(s₁ ≡ s₂) extensionalᵣ{s₁}{s₂} (proof) = [↔].elimᵣ ([∀].elim([∀].elim extensional{s₁}){s₂}) (proof) -- TODO: Use [⊆][≡ₛ]-equivalence [≡]-from-subset : Proof(∀ₗ(x ↦ ∀ₗ(y ↦ ((x ⊇ y) ∧ (x ⊆ y)) ⟷ (x ≡ y)))) [≡]-from-subset = ([∀].intro(\{x} → ([∀].intro(\{y} → ([↔].intro (x≡y ↦ [∧].intro ([→].elim ([∀].elim ([∀].elim ([≡]-implies-when-reflexive [⊆]-reflexivity) {x}) {y}) (x≡y)) ([→].elim ([∀].elim ([∀].elim ([≡]-implies-when-reflexive [⊆]-reflexivity) {x}) {y}) (x≡y)) ) (lr ↦ ([↔].elimᵣ ([∀].elim([∀].elim extensional{x}){y}) ([∀].intro(\{a} → ([↔].intro ([→].elim([∀].elim([∧].elimₗ(lr)){a})) ([→].elim([∀].elim([∧].elimᵣ(lr)){a})) ) )) ) ) ) )) )) where [≡]-implies-when-reflexive : ∀{_▫_ : Domain → Domain → Formula} → Proof(∀ₗ(x ↦ x ▫ x)) → Proof(∀ₗ(x ↦ ∀ₗ(y ↦ (x ≡ y) ⟶ (x ▫ y)))) [≡]-implies-when-reflexive {_▫_} ([▫]-reflexivity) = ([∀].intro(\{x} → ([∀].intro(\{y} → ([→].intro(x≡y ↦ [≡].elimᵣ{x ▫_} (x≡y) ([∀].elim [▫]-reflexivity{x}) )) )) )) -- All sets that are defined using an equivalence of contained elements are unique unique-definition : ∀{φ : Domain → Formula} → Proof(Unique(S ↦ ∀ₗ(x ↦ (x ∈ S) ⟷ φ(x)))) unique-definition{_} = ([∀].intro(\{S₁} → ([∀].intro(\{S₂} → ([→].intro(proof ↦ ([↔].elimᵣ ([∀].elim([∀].elim extensional{S₁}){S₂}) ([∀].intro(\{x} → ([↔].transitivity ([∀].elim([∧].elimₗ(proof)){x}) ([↔].commutativity([∀].elim([∧].elimᵣ(proof)){x})) ) )) ) )) )) )) -- TODO: Use [⊆][≡ₛ]-antisymmetry [⊆]-antisymmetry : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ (b ⊆ a)∧(a ⊆ b) ⟶ (a ≡ b)))) [⊆]-antisymmetry = ([∀].intro(\{a} → ([∀].intro(\{b} → ([→].intro(abba ↦ ([↔].elimᵣ([∀].elim([∀].elim extensional{a}){b})) ([∀].intro(\{x} → ([↔].intro ([→].elim([∀].elim([∧].elimₗ abba){x})) ([→].elim([∀].elim([∧].elimᵣ abba){x})) ) )) )) )) )) -- Empty set -- The set consisting of no elements. record EmptySet : Type{ℓₘₗ Lvl.⊔ ℓₗ Lvl.⊔ ℓₒ} where constructor intro field ∅ : Domain field [∅]-membership : Proof(∀ₗ(x ↦ x ∉ ∅)) [∅]-membership-equiv : Proof(∀ₗ(x ↦ (x ∈ ∅) ⟷ ⊥)) [∅]-membership-equiv = ([∀].intro (\{x} → ([↔].intro ([⊥].elim) ([¬].elim ([∀].elim [∅]-membership{x}) ) ) )) [∅]-subset : Proof(∀ₗ(s ↦ ∅ ⊆ s)) [∅]-subset = ([∀].intro(\{s} → ([∀].intro(\{x} → ([→].intro(xin∅ ↦ [⊥].elim ([↔].elimᵣ([∀].elim [∅]-membership-equiv {x}) (xin∅)) )) )) )) [∅]-subset-is-equal : Proof(∀ₗ(s ↦ (s ⊆ ∅) ⟶ (s ≡ₛ ∅))) [∅]-subset-is-equal = ([∀].intro(\{s} → ([→].intro(s⊆∅ ↦ ([→].elim ([∀].elim([∀].elim [⊆][≡ₛ]-antisymmetry{s}){∅}) ([∧].intro ([∀].elim [∅]-subset{s}) (s⊆∅) ) ) )) )) [⊆]-minimum : Proof(∀ₗ(min ↦ ∀ₗ(s ↦ min ⊆ s) ⟷ (min ≡ₛ ∅))) [⊆]-minimum = ([∀].intro(\{min} → ([↔].intro (min≡∅ ↦ ([∀].intro(\{s} → ([→].elim ([∀].elim([∀].elim([∀].elim [⊆]-transitivity {min}){∅}){s}) ([∧].intro ([→].elim ([∀].elim([∀].elim [≡ₛ]-to-[⊆] {min}){∅}) (min≡∅)) ([∀].elim [∅]-subset {s}) ) ) )) ) (asmin⊆s ↦ ([→].elim ([∀].elim [∅]-subset-is-equal{min}) ([∀].elim asmin⊆s{∅}) ) ) ) )) [⊆]-minima : Proof(∀ₗ(s ↦ ∅ ⊆ s)) [⊆]-minima = [∅]-subset [∃ₛ]-of-[∅] : ∀{P : Domain → Formula} → Proof(¬(∃ₛ ∅ P)) [∃ₛ]-of-[∅] = ([¬].intro(ep ↦ [∃ₛ]-elim(\{x} → x∈∅ ↦ _ ↦ [⊥].elim([¬].elim ([∀].elim [∅]-membership) x∈∅)) ep )) -- Singleton set. -- A set consisting of only a single element. record SingletonSet : Type{ℓₘₗ Lvl.⊔ ℓₗ Lvl.⊔ ℓₒ} where constructor intro field singleton : Domain → Domain field singleton-membership : Proof(∀ₗ(a ↦ ∀ₗ(x ↦ (x ∈ singleton(a)) ⟷ (x ≡ₛ a)))) singleton-contains-self : Proof(∀ₗ(s ↦ s ∈ singleton(s))) singleton-contains-self = ([∀].intro(\{s} → ([↔].elimₗ ([∀].elim([∀].elim singleton-membership{s}){s}) ([∀].elim [≡ₛ]-reflexivity{s}) ) )) -- Subset filtering. -- The subset of the specified set where all elements satisfy the specified formula. record FilterSet : Type{ℓₘₗ Lvl.⊔ ℓₗ Lvl.⊔ ℓₒ} where constructor intro field filter : Domain → (Domain → Formula) → Domain field filter-membership : ∀{φ : Domain → Formula} → Proof(∀ₗ(s ↦ ∀ₗ(x ↦ ((x ∈ filter(s)(φ)) ⟷ ((x ∈ s) ∧ φ(x)))))) filter-subset : ∀{φ} → Proof(∀ₗ(s ↦ filter(s)(φ) ⊆ s)) filter-subset = ([∀].intro(\{s} → ([∀].intro(\{x} → ([→].intro(xinfilter ↦ [∧].elimₗ([↔].elimᵣ([∀].elim([∀].elim filter-membership{s}){x}) (xinfilter)) )) )) )) module _ ⦃ _ : EmptySet ⦄ where open EmptySet ⦃ ... ⦄ filter-of-[∅] : ∀{φ} → Proof(filter(∅)(φ) ≡ₛ ∅) filter-of-[∅] = ([→].elim ([∀].elim([∀].elim [⊆][≡ₛ]-antisymmetry)) ([∧].intro ([∀].elim [∅]-subset) ([∀].elim filter-subset) ) ) filter-property : ∀{φ : Domain → Formula} → Proof(∀ₗ(s ↦ ∀ₛ(filter(s)(φ)) φ)) filter-property = ([∀].intro(\{s} → ([∀].intro(\{x} → ([→].intro(xinfilter ↦ [∧].elimᵣ([↔].elimᵣ([∀].elim([∀].elim filter-membership{s}){x}) (xinfilter)) )) )) )) -- Power set. -- The set of all subsets of the specified set. record PowerSet : Type{ℓₘₗ Lvl.⊔ ℓₗ Lvl.⊔ ℓₒ} where constructor intro field ℘ : Domain → Domain field [℘]-membership : Proof(∀ₗ(s ↦ ∀ₗ(x ↦ (x ∈ ℘(s)) ⟷ (x ⊆ s)))) module _ ⦃ _ : EmptySet ⦄ where open EmptySet ⦃ ... ⦄ [℘]-contains-empty : Proof(∀ₗ(s ↦ ∅ ∈ ℘(s))) [℘]-contains-empty = ([∀].intro(\{s} → ([↔].elimₗ ([∀].elim([∀].elim [℘]-membership{s}){∅}) ([∀].elim [∅]-subset{s}) ) )) module _ ⦃ _ : SingletonSet ⦄ where open SingletonSet ⦃ ... ⦄ postulate [℘]-of-[∅] : Proof(℘(∅) ≡ₛ singleton(∅)) [℘]-contains-self : Proof(∀ₗ(s ↦ s ∈ ℘(s))) [℘]-contains-self = ([∀].intro(\{s} → ([↔].elimₗ ([∀].elim([∀].elim [℘]-membership{s}){s}) ([∀].elim [⊆]-reflexivity{s}) ) )) -- Union over arbitrary sets. -- Constructs a set which consists of elements which are in any of the specified sets. record SetUnionSet : Type{ℓₘₗ Lvl.⊔ ℓₗ Lvl.⊔ ℓₒ} where constructor intro field ⋃ : Domain → Domain field [⋃]-membership : Proof(∀ₗ(ss ↦ ∀ₗ(x ↦ (x ∈ ⋃(ss)) ⟷ ∃ₛ(ss)(s ↦ x ∈ s)))) postulate [⋃]-containing-max : Proof(∀ₗ(s ↦ ∀ₛ(s)(max ↦ ∀ₛ(s)(x ↦ x ⊆ max) ⟶ (⋃(s) ≡ₛ max)))) module _ ⦃ _ : EmptySet ⦄ where open EmptySet ⦃ ... ⦄ postulate [⋃]-of-[∅] : Proof(⋃(∅) ≡ₛ ∅) -- [⋃]-of-[∅] = -- ([⋃]-membership -- ) -- [∃ₛ]-of-[∅] postulate [⋃]-subset : Proof(∀ₗ(s ↦ ∀ₛ(s)(x ↦ x ⊆ ⋃(s)))) -- Union operator. -- Constructs a set which consists of both elements from LHS and RHS. record UnionSet : Type{ℓₘₗ Lvl.⊔ ℓₗ Lvl.⊔ ℓₒ} where constructor intro infixl 3000 _∪_ field _∪_ : Domain → Domain → Domain field [∪]-membership : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ ∀ₗ(x ↦ (x ∈ (a ∪ b)) ⟷ (x ∈ a)∨(x ∈ b))))) [∪]-commutativity : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ a ∪ b ≡ₛ b ∪ a))) [∪]-commutativity = ([∀].intro(\{a} → ([∀].intro(\{b} → ([∀].intro(\{x} → ([↔].intro (([↔].elimₗ ([∀].elim ([∀].elim ([∀].elim [∪]-membership)))) ∘ [∨].commutativity ∘ ([↔].elimᵣ ([∀].elim ([∀].elim ([∀].elim [∪]-membership))))) (([↔].elimₗ ([∀].elim ([∀].elim ([∀].elim [∪]-membership)))) ∘ [∨].commutativity ∘ ([↔].elimᵣ ([∀].elim ([∀].elim ([∀].elim [∪]-membership))))) ) )) )) )) postulate [∪]-associativity : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ ∀ₗ(c ↦ (a ∪ b) ∪ c ≡ₛ a ∪ (b ∪ c))))) module _ ⦃ _ : EmptySet ⦄ where open EmptySet ⦃ ... ⦄ postulate [∪]-identityₗ : Proof(∀ₗ(s ↦ ∅ ∪ s ≡ₛ s)) postulate [∪]-identityᵣ : Proof(∀ₗ(s ↦ s ∪ ∅ ≡ₛ s)) postulate [∪]-subsetₗ : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ a ⊆ a ∪ b))) postulate [∪]-subsetᵣ : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ b ⊆ a ∪ b))) postulate [∪]-of-subsetₗ : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ (b ⊆ a) ⟶ (a ∪ b ≡ₛ a)))) postulate [∪]-of-subsetᵣ : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ (a ⊆ b) ⟶ (a ∪ b ≡ₛ b)))) postulate [∪]-of-self : Proof(∀ₗ(s ↦ s ∪ s ≡ₛ s)) -- Intersection operator. -- Constructs a set which consists of elements which are in both LHS and RHS. record IntersectionSet : Type{ℓₘₗ Lvl.⊔ ℓₗ Lvl.⊔ ℓₒ} where constructor intro infixl 3001 _∩_ field _∩_ : Domain → Domain → Domain field [∩]-membership : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ ∀ₗ(x ↦ (x ∈ (a ∩ b)) ⟷ (x ∈ a)∧(x ∈ b))))) postulate [∩]-commutativity : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ a ∩ b ≡ₛ b ∩ a))) postulate [∩]-associativity : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ ∀ₗ(c ↦ (a ∩ b) ∩ c ≡ₛ a ∩ (b ∩ c))))) module _ ⦃ _ : EmptySet ⦄ where open EmptySet ⦃ ... ⦄ postulate [∩]-annihilatorₗ : Proof(∀ₗ(s ↦ ∅ ∩ s ≡ₛ ∅)) postulate [∩]-annihilatorᵣ : Proof(∀ₗ(s ↦ s ∩ ∅ ≡ₛ s)) postulate [∩]-subsetₗ : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ a ∩ b ⊆ a))) postulate [∩]-subsetᵣ : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ a ∩ b ⊆ b))) postulate [∩]-of-subsetₗ : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ (b ⊆ a) ⟶ (a ∩ b ≡ₛ b)))) postulate [∩]-of-subsetᵣ : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ (a ⊆ b) ⟶ (a ∩ b ≡ₛ a)))) postulate [∩]-of-self : Proof(∀ₗ(s ↦ s ∩ s ≡ₛ s)) -- "Without"-operator. -- Constructs a set which consists of elements which are in LHS, but not RHS. record WithoutSet : Type{ℓₘₗ Lvl.⊔ ℓₗ Lvl.⊔ ℓₒ} where constructor intro infixl 3002 _∖_ field _∖_ : Domain → Domain → Domain field [∖]-membership : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ ∀ₗ(x ↦ (x ∈ (a ∖ b)) ⟷ (x ∈ a)∧(x ∉ b))))) postulate [∖]-of-disjoint : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ ∀ₗ(x ↦ Disjoint(a)(b) ⟶ (a ∖ b ≡ₛ a))))) module _ ⦃ _ : IntersectionSet ⦄ where open IntersectionSet ⦃ ... ⦄ postulate [∖]-of-intersection : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ ∀ₗ(x ↦ a ∖ (a ∩ b) ≡ₛ a ∖ b)))) module _ ⦃ _ : EmptySet ⦄ where open EmptySet ⦃ ... ⦄ postulate [∖]-annihilatorₗ : Proof(∀ₗ(s ↦ ∅ ∖ s ≡ₛ ∅)) postulate [∖]-identityᵣ : Proof(∀ₗ(s ↦ s ∖ ∅ ≡ₛ s)) postulate [∖]-subset : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ ∀ₗ(x ↦ (a ⊆ b) ⟶ (a ∖ b ≡ₛ ∅))))) postulate [∖]-of-self : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ ∀ₗ(x ↦ a ∖ a ≡ₛ ∅)))) module _ ⦃ _ : SingletonSet ⦄ where open SingletonSet ⦃ ... ⦄ postulate [∖]-of-singleton : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ ∀ₗ(x ↦ (x ∈ (a ∖ singleton(b))) ⟷ (x ∈ a)∧(x ≢ b))))) -- Intersection over arbitrary sets. -- Constructs a set which consists of elements which are in all of the specified sets. record SetIntersectionSet : Type{ℓₘₗ Lvl.⊔ ℓₗ Lvl.⊔ ℓₒ} where constructor intro field ⋂ : Domain → Domain field [⋂]-membership : Proof(∀ₗ(ss ↦ ∀ₗ(x ↦ (x ∈ ⋂(ss)) ⟷ ∀ₛ(ss)(s ↦ x ∈ s)))) postulate [⋂]-containing-min : Proof(∀ₗ(s ↦ ∀ₛ(s)(min ↦ ∀ₛ(s)(x ↦ min ⊆ x) ⟶ (⋂(s) ≡ₛ min)))) module _ ⦃ _ : EmptySet ⦄ where open EmptySet ⦃ ... ⦄ postulate [⋂]-containing-disjoint : Proof(∀ₗ(s ↦ ∃ₛ(s)(a ↦ ∃ₛ(s)(b ↦ Disjoint(a)(b))) ⟶ (⋂(s) ≡ₛ ∅))) postulate [⋂]-containing-[∅] : Proof(∀ₗ(s ↦ (∅ ∈ s) ⟶ (⋂(s) ≡ₛ ∅))) postulate [⋂]-subset : Proof(∀ₗ(s ↦ ∀ₛ(s)(x ↦ ⋂(s) ⊆ x))) -- Set of all sets. record UniversalSet : Type{ℓₘₗ Lvl.⊔ ℓₗ Lvl.⊔ ℓₒ} where constructor intro field 𝐔 : Domain field [𝐔]-membership : Proof(∀ₗ(x ↦ (x ∈ 𝐔))) [𝐔]-membership-equiv : Proof(∀ₗ(x ↦ (x ∈ 𝐔) ⟷ ⊤)) [𝐔]-membership-equiv = ([∀].intro(\{x} → ([↔].intro (_ ↦ [∀].elim [𝐔]-membership) (_ ↦ [⊤].intro) ) )) [𝐔]-subset : Proof(∀ₗ(x ↦ x ⊆ 𝐔)) [𝐔]-subset = ([∀].intro(\{x} → ([∀].intro(\{a} → ([→].intro(_ ↦ [∀].elim [𝐔]-membership )) )) )) [𝐔]-superset : Proof(∀ₗ(x ↦ (x ⊇ 𝐔) ⟶ (x ≡ₛ 𝐔))) [𝐔]-superset = ([∀].intro(\{x} → ([→].intro(superset ↦ ([→].elim ([∀].elim ([∀].elim [⊆][≡ₛ]-antisymmetry)) ([∧].intro superset ([∀].elim [𝐔]-subset) ) ) )) )) [𝐔]-contains-self : Proof(𝐔 ∈ 𝐔) [𝐔]-contains-self = [∀].elim [𝐔]-membership [𝐔]-nonempty : Proof(∃ₗ(x ↦ (x ∈ 𝐔))) [𝐔]-nonempty = [∃].intro [𝐔]-contains-self module _ ⦃ _ : FilterSet ⦄ where open FilterSet ⦃ ... ⦄ unrestricted-comprehension-contradiction : Proof(⊥) unrestricted-comprehension-contradiction = ([∨].elim (contains ↦ ([¬].elim ([∧].elimᵣ([↔].elimᵣ ([∀].elim([∀].elim filter-membership{𝐔}){not-in-self}) contains )) contains ) ) (contains-not ↦ ([¬].elim (contains-not) ([↔].elimₗ ([∀].elim([∀].elim filter-membership{𝐔}){not-in-self}) ([∧].intro ([∀].elim [𝐔]-membership {not-in-self}) (contains-not) ) ) ) ) (excluded-middle{not-in-self ∈ not-in-self}) ) where not-in-self : Domain not-in-self = filter(𝐔) (x ↦ (x ∉ x)) record TupleSet : Type{ℓₘₗ Lvl.⊔ ℓₗ Lvl.⊔ ℓₒ} where constructor intro infixl 3002 _⨯_ field -- Set product (Set of tuples) (Cartesian product). _⨯_ : Domain → Domain → Domain -- Tuple value. -- An ordered pair of values. _,_ : Domain → Domain → Domain left : Domain → Domain right : Domain → Domain swap : Domain → Domain swap(x) = (right(x) , left(x)) field [⨯]-membership : Proof(∀ₗ(A ↦ ∀ₗ(B ↦ ∀ₗ(x ↦ (x ∈ (A ⨯ B)) ⟷ ∃ₛ(A)(a ↦ ∃ₛ(B)(b ↦ x ≡ (a , b))))))) -- TODO: Maybe left and right is not neccessary because one can just take the witnesses of this left-equality : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ left(a , b) ≡ a))) right-equality : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ right(a , b) ≡ b))) postulate [⨯]-tuples : Proof(∀ₗ(A ↦ ∀ₗ(B ↦ ∀ₛ(A)(a ↦ ∀ₛ(B)(b ↦ (a , b) ∈ (A ⨯ B)))))) postulate swap-equality : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ swap(a , b) ≡ (b , a)))) postulate left-right-identity : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ (left(a , b) , right(a , b)) ≡ (a , b)))) record QuotientSet : Type{ℓₘₗ Lvl.⊔ ℓₗ Lvl.⊔ ℓₒ} where constructor intro field -- Quotient set. -- The set of equivalence classes. _/_ : Domain → BinaryRelator → Domain -- Equivalence class -- The set of elements which are equivalent to the specified one. [_of_] : Domain → (Domain ⨯ₘ BinaryRelator) → Domain field [/]-membership : ∀{T}{_≅_} → Proof(∀ₗ(x ↦ (x ∈ (T / (_≅_))) ⟷ (∃ₗ(y ↦ x ≡ [ y of (T ,ₘ (_≅_)) ])))) eqClass-membership : ∀{T}{_≅_} → Proof(∀ₗ(a ↦ ∀ₗ(b ↦ (a ∈ [ b of (T ,ₘ (_≅_)) ]) ⟷ (a ≅ b)))) -- module Quotient {T : Domain} {_≅_ : BinaryRelator} ⦃ equivalence : Proof(Structure.Relator.Properties.Equivalence(T)(_≅_)) ⦄ where -- open Structure.Relator.Properties -- postulate [/]-membership : Proof(∀ₗ(x ↦ (x ∈ (T / (_≅_))) ⟷ (∃ₗ(y ↦ x ≡ [ y of T , (_≅_) ])))) -- postulate [/]-pairwise-disjoint : Proof(∀ₗ(x ↦ (x ∈ (T / (_≅_))) ⟷ (∃ₗ(y ↦ x ≡ [ y of T , (_≅_) ])))) -- postulate [/]-not-containing-[∅] : Proof(∀ₗ(x ↦ ∅ ∉ (T / (_≅_)))) -- postulate [/]-cover : Proof(⋃(T / (_≅_)) ≡ T) -- postulate eqClass-membership : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ (a ∈ [ b of T , (_≅_) ]) ⟷ (a ≅ b)))) -- postulate eqClass-containing-self : Proof(∀ₗ(a ↦ a ∈ [ a of T , (_≅_) ])) -- postulate eqClass-nonempty : Proof(∀ₗ(a ↦ NonEmpty([ a of T , (_≅_) ]))) -- postulate eqClass-equal-disjoint : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ ([ a of T , (_≅_) ] ≡ [ b of T , (_≅_) ]) ⟷ ¬ Disjoint([ a of T , (_≅_) ])([ b of T , (_≅_) ])))) -- postulate eqClass-equal-equivalent : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ ([ a of T , (_≅_) ] ≡ [ b of T , (_≅_) ]) ⟷ (a ≅ b)))) -- postulate eqClass-equal-containingₗ : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ ([ a of T , (_≅_) ] ≡ [ b of T , (_≅_) ]) ⟷ (b ∈ [ a of T , (_≅_) ])))) -- postulate eqClass-equal-containingᵣ : Proof(∀ₗ(a ↦ ∀ₗ(b ↦ ([ a of T , (_≅_) ] ≡ [ b of T , (_≅_) ]) ⟷ (a ∈ [ b of T , (_≅_) ]))))
{ "alphanum_fraction": 0.4531613654, "avg_line_length": 30.418879056, "ext": "agda", "hexsha": "5cdb581e21749853c42f6d884d3c490494b4e6c3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "old/Structure/Logic/Classical/SetTheory.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "old/Structure/Logic/Classical/SetTheory.agda", "max_line_length": 197, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "old/Structure/Logic/Classical/SetTheory.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": 9161, "size": 20624 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021 Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} module Dijkstra.All where open import Dijkstra.Syntax public open import Dijkstra.RWS public open import Dijkstra.RWS.Syntax public open import Dijkstra.EitherD public open import Dijkstra.EitherD.Syntax public open import Dijkstra.EitherLike public
{ "alphanum_fraction": 0.806, "avg_line_length": 31.25, "ext": "agda", "hexsha": "afdd55e1bd8e35ef81d5a7bc48cc8b0fba186021", "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/Dijkstra/All.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/Dijkstra/All.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/Dijkstra/All.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 123, "size": 500 }
{-# OPTIONS --without-K --safe #-} module Categories.Functor.Monoidal where open import Level open import Data.Product using (Σ; _,_) open import Categories.Category open import Categories.Category.Product open import Categories.Category.Monoidal open import Categories.Functor hiding (id) open import Categories.NaturalTransformation hiding (id) open import Categories.NaturalTransformation.NaturalIsomorphism import Categories.Morphism as Mor private variable o o′ ℓ ℓ′ e e′ : Level module _ (C : MonoidalCategory o ℓ e) (D : MonoidalCategory o′ ℓ′ e′) where private module C = MonoidalCategory C module D = MonoidalCategory D open Mor D.U -- lax monoidal functor record IsMonoidalFunctor (F : Functor C.U D.U) : Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where open Functor F field ε : D.U [ D.unit , F₀ C.unit ] ⊗-homo : NaturalTransformation (D.⊗ ∘F (F ⁂ F)) (F ∘F C.⊗) module ⊗-homo = NaturalTransformation ⊗-homo -- coherence condition open D open Commutation D.U field associativity : ∀ {X Y Z} → [ (F₀ X ⊗₀ F₀ Y) ⊗₀ F₀ Z ⇒ F₀ (X C.⊗₀ Y C.⊗₀ Z) ]⟨ ⊗-homo.η (X , Y) ⊗₁ id ⇒⟨ F₀ (X C.⊗₀ Y) ⊗₀ F₀ Z ⟩ ⊗-homo.η (X C.⊗₀ Y , Z) ⇒⟨ F₀ ((X C.⊗₀ Y) C.⊗₀ Z) ⟩ F₁ C.associator.from ≈ associator.from ⇒⟨ F₀ X ⊗₀ F₀ Y ⊗₀ F₀ Z ⟩ id ⊗₁ ⊗-homo.η (Y , Z) ⇒⟨ F₀ X ⊗₀ F₀ (Y C.⊗₀ Z) ⟩ ⊗-homo.η (X , Y C.⊗₀ Z) ⟩ unitaryˡ : ∀ {X} → [ unit ⊗₀ F₀ X ⇒ F₀ X ]⟨ ε ⊗₁ id ⇒⟨ F₀ C.unit ⊗₀ F₀ X ⟩ ⊗-homo.η (C.unit , X) ⇒⟨ F₀ (C.unit C.⊗₀ X) ⟩ F₁ C.unitorˡ.from ≈ unitorˡ.from ⟩ unitaryʳ : ∀ {X} → [ F₀ X ⊗₀ unit ⇒ F₀ X ]⟨ id ⊗₁ ε ⇒⟨ F₀ X ⊗₀ F₀ C.unit ⟩ ⊗-homo.η (X , C.unit) ⇒⟨ F₀ (X C.⊗₀ C.unit) ⟩ F₁ C.unitorʳ.from ≈ unitorʳ.from ⟩ record MonoidalFunctor : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where field F : Functor C.U D.U isMonoidal : IsMonoidalFunctor F open Functor F public open IsMonoidalFunctor isMonoidal public -- strong monoidal functor record IsStrongMonoidalFunctor (F : Functor C.U D.U) : Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where open Functor F field ε : D.unit ≅ F₀ C.unit ⊗-homo : D.⊗ ∘F (F ⁂ F) ≃ F ∘F C.⊗ module ε = _≅_ ε module ⊗-homo = NaturalIsomorphism ⊗-homo -- coherence condition open D open Commutation D.U field associativity : ∀ {X Y Z} → [ (F₀ X ⊗₀ F₀ Y) ⊗₀ F₀ Z ⇒ F₀ (X C.⊗₀ Y C.⊗₀ Z) ]⟨ ⊗-homo.⇒.η (X , Y) ⊗₁ id ⇒⟨ F₀ (X C.⊗₀ Y) ⊗₀ F₀ Z ⟩ ⊗-homo.⇒.η (X C.⊗₀ Y , Z) ⇒⟨ F₀ ((X C.⊗₀ Y) C.⊗₀ Z) ⟩ F₁ C.associator.from ≈ associator.from ⇒⟨ F₀ X ⊗₀ F₀ Y ⊗₀ F₀ Z ⟩ id ⊗₁ ⊗-homo.⇒.η (Y , Z) ⇒⟨ F₀ X ⊗₀ F₀ (Y C.⊗₀ Z) ⟩ ⊗-homo.⇒.η (X , Y C.⊗₀ Z) ⟩ unitaryˡ : ∀ {X} → [ unit ⊗₀ F₀ X ⇒ F₀ X ]⟨ ε.from ⊗₁ id ⇒⟨ F₀ C.unit ⊗₀ F₀ X ⟩ ⊗-homo.⇒.η (C.unit , X) ⇒⟨ F₀ (C.unit C.⊗₀ X) ⟩ F₁ C.unitorˡ.from ≈ unitorˡ.from ⟩ unitaryʳ : ∀ {X} → [ F₀ X ⊗₀ unit ⇒ F₀ X ]⟨ id ⊗₁ ε.from ⇒⟨ F₀ X ⊗₀ F₀ C.unit ⟩ ⊗-homo.⇒.η (X , C.unit) ⇒⟨ F₀ (X C.⊗₀ C.unit) ⟩ F₁ C.unitorʳ.from ≈ unitorʳ.from ⟩ isMonoidal : IsMonoidalFunctor F isMonoidal = record { ε = ε.from ; ⊗-homo = ⊗-homo.F⇒G ; associativity = associativity ; unitaryˡ = unitaryˡ ; unitaryʳ = unitaryʳ } record StrongMonoidalFunctor : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where field F : Functor C.U D.U isStrongMonoidal : IsStrongMonoidalFunctor F open Functor F public open IsStrongMonoidalFunctor isStrongMonoidal public monoidalFunctor : MonoidalFunctor monoidalFunctor = record { F = F ; isMonoidal = isMonoidal }
{ "alphanum_fraction": 0.4297451022, "avg_line_length": 35.162962963, "ext": "agda", "hexsha": "43287dfbbdcb28bf67cfc363d73923732b48aae3", "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/Functor/Monoidal.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/Functor/Monoidal.agda", "max_line_length": 98, "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/Functor/Monoidal.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": 1679, "size": 4747 }
module Issue2880 where app : {A : Set} → (A → A) → (A → A) app f x = f x {-# COMPILE GHC app = \ A f x -> f (app A f x) #-} mutual id : {A : Set} → A → A id x = x {-# COMPILE GHC id = id' #-} id' : {A : Set} → A → A id' x = x {-# COMPILE GHC id' = id #-}
{ "alphanum_fraction": 0.4343065693, "avg_line_length": 14.4210526316, "ext": "agda", "hexsha": "33dccc36fb890006b342b2c9d2388644b05c4348", "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/Issue2880.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/Issue2880.agda", "max_line_length": 50, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue2880.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": 116, "size": 274 }
------------------------------------------------------------------------------ ----- ----- ----- Relevant.Abstraction ----- ----- ----- ------------------------------------------------------------------------------ module Relevant.Abstraction where open import Lib.Equality open import Lib.Sigma open import Lib.Bwd open import Thin.Data open import Thin.Thinned module _ {B : Set} where open THIN {B} {- A scoped notion of abstraction brings a newly bound variable into scope at the local end of the context. -} ------------------------------------------------------------------------------ -- relevance-aware abstraction ------------------------------------------------------------------------------ {- CodeBruijn syntax is not necessarily intended to restrict the use of variables more or less than ordinary syntax-with-binding, but it is intended to ensure greater awareness of how variables are used. In particular, we use types Foo ga to mean the type of Foos with support ga, i.e., that the variables from ga not only may but must occur free in the Foo. Now, when we bind a variable to make an abstraction of some sort, there is nobody to tell us whether the bound variable must be used. But we must make our minds up: if we bring it into scope, it must be used; if we do not, it cannot be used. Let us therefore offer the choice of which to do. -} infixr 8 _|-_ data _|-_ (b : B)(T : Scope -> Set)(ga : Scope) : Set where ll : T (ga -, b) -> (b |- T) ga -- two-l llambda, he's a beast kk : T ga -> (b |- T) ga -- two-k kkonstant, he's the least ------------------------------------------------------------------------------ -- smart constructor for thinned abstraction ------------------------------------------------------------------------------ infixr 4 _\\_ _\\_ : forall b {T : Scope -> Set}{ga} -> T :< ga -, b -> (b |- T) :< ga b \\ t ^ th -, .b = ll t ^ th b \\ t ^ th -^ .b = kk t ^ th {- We can tell the support of t by looking at the thinning that it is paired with. We learn which constructor we should then use. -} ------------------------------------------------------------------------------ -- smart destructor for thinned abstraction ------------------------------------------------------------------------------ data Under {b T ga} : (b |- T) :< ga -> Set where un\\ : forall t -> Under (b \\ t) under : forall {b T ga}(x : (b |- T) :< ga) -> Under x under (ll t ^ th) = un\\ (t ^ th -, _) under (kk t ^ th) = un\\ (t ^ th -^ _) under\\ : forall b {T ga}(t : T :< ga -, b) -> under (b \\ t) ~ un\\ t under\\ b (_ ^ th -, .b) = r~ under\\ b (_ ^ th -^ .b) = r~
{ "alphanum_fraction": 0.4493267186, "avg_line_length": 36.1794871795, "ext": "agda", "hexsha": "a5117c6fddeec5cdc9cb4547e637017a4323e952", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-01-06T19:34:26.000Z", "max_forks_repo_forks_event_min_datetime": "2019-11-13T12:44:41.000Z", "max_forks_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ajnavarro/language-dataset", "max_forks_repo_path": "data/github.com/pigworker/TypesWhoSayNi/7015fcde9a76984134691e9176bfb144ebeca7d5/codeb/Relevant/Abstraction.agda", "max_issues_count": 91, "max_issues_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_issues_repo_issues_event_max_datetime": "2022-03-21T04:17:18.000Z", "max_issues_repo_issues_event_min_datetime": "2019-11-11T15:41:26.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "ajnavarro/language-dataset", "max_issues_repo_path": "data/github.com/pigworker/TypesWhoSayNi/7015fcde9a76984134691e9176bfb144ebeca7d5/codeb/Relevant/Abstraction.agda", "max_line_length": 78, "max_stars_count": 9, "max_stars_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ajnavarro/language-dataset", "max_stars_repo_path": "data/github.com/pigworker/TypesWhoSayNi/7015fcde9a76984134691e9176bfb144ebeca7d5/codeb/Relevant/Abstraction.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-11T09:48:45.000Z", "max_stars_repo_stars_event_min_datetime": "2018-08-07T11:54:33.000Z", "num_tokens": 614, "size": 2822 }
module ProofRep where import Prelude import Logic.Relations import Logic.Identity import Data.Nat import Data.Nat.Properties open Prelude open Data.Nat hiding (_==_; _≡_) open Data.Nat.Properties open Logic.Relations module Foo (Var : Set) where data _==_ : (x y : Var) -> Set where cRefl : {x : Var} -> x == x cSym : {x y : Var} -> y == x -> x == y cTrans : {x y z : Var} -> x == z -> z == y -> x == y cAxiom : {x y : Var} -> x == y data Axioms {A : Set}(_≈_ : Rel A)([_] : Var -> A) : Set where noAxioms : Axioms _≈_ [_] anAxiom : (x y : Var) -> [ x ] ≈ [ y ] -> Axioms _≈_ [_] manyAxioms : Axioms _≈_ [_] -> Axioms _≈_ [_] -> Axioms _≈_ [_] refl : {x : Var} -> x == x refl = cRefl sym : {x y : Var} -> x == y -> y == x sym (cRefl xy) = cRefl (Var.sym xy) sym cAxiom = cSym cAxiom sym (cSym p) = p sym (cTrans z p q) = cTrans z (sym q) (sym p) trans : {x y z : Var} -> x == y -> y == z -> x == z trans {x}{y}{z} (cRefl xy) q = Var.subst (\w -> w == z) (Var.sym xy) q trans {x}{y}{z} p (cRefl yz) = Var.subst (\w -> x == w) yz p trans {x}{y}{z} (cTrans w p q) r = cTrans w p (trans q r) trans p q = cTrans _ p q
{ "alphanum_fraction": 0.5040453074, "avg_line_length": 28.7441860465, "ext": "agda", "hexsha": "0134533d1c66a85c7d83018379938f886406f801", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/ProofRep.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/ProofRep.agda", "max_line_length": 76, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/outdated-and-incorrect/ProofRep.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": 504, "size": 1236 }
------------------------------------------------------------------------------ -- The ABP using the Agda standard library ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Program.ABP.ABP-SL where open import Codata.Musical.Notation open import Codata.Musical.Stream open import Data.Bool open import Data.Product open import Relation.Nullary ------------------------------------------------------------------------------ Bit : Set Bit = Bool -- Data type used to model the fair unreliable transmission channel. data Err (A : Set) : Set where ok : (x : A) → Err A error : Err A -- The mutual sender functions. -- TODO (2019-01-04): Agda doesn't accept this definition which was -- accepted by a previous version. {-# TERMINATING #-} sendA : {A : Set} → Bit → Stream A → Stream (Err Bit) → Stream (A × Bool) awaitA : {A : Set} → Bit → Stream A → Stream (Err Bit) → Stream (A × Bit) sendA b (i ∷ is) ds = (i , b) ∷ ♯ awaitA b (i ∷ is) ds awaitA b (i ∷ is) (ok b' ∷ ds) with b ≟ b' ... | yes p = sendA (not b) (♭ is) (♭ ds) ... | no ¬p = (i , b) ∷ ♯ (awaitA b (i ∷ is) (♭ ds)) awaitA b (i ∷ is) (error ∷ ds) = (i , b) ∷ ♯ (awaitA b (i ∷ is) (♭ ds)) -- The receiver functions. -- TODO (2019-01-04): Agda doesn't accept this definition which was -- accepted by a previous version. {-# TERMINATING #-} ackA : {A : Set} → Bit → Stream (Err (A × Bit)) → Stream Bit ackA b (ok (_ , b') ∷ bs) with b ≟ b' ... | yes p = b ∷ ♯ (ackA (not b) (♭ bs)) ... | no ¬p = not b ∷ ♯ (ackA b (♭ bs)) ackA b (error ∷ bs) = not b ∷ ♯ (ackA b (♭ bs)) -- 25 June 2014. Requires the TERMINATING flag when using -- --without-K. See Agda Issue 1214. -- TODO (03 December 2015): Report the issue. {-# TERMINATING #-} outA : {A : Set} → Bit → Stream (Err (A × Bit)) → Stream A outA b (ok (i , b') ∷ bs) with b ≟ b' ... | yes p = i ∷ ♯ (outA (not b) (♭ bs)) ... | no ¬p = outA b (♭ bs) outA b (error ∷ bs) = outA b (♭ bs) -- Model the fair unreliable tranmission channel. -- TODO (2019-01-04): Agda doesn't accept this definition which was -- accepted by a previous version. {-# TERMINATING #-} corruptA : {A : Set} → Stream Bit → Stream A → Stream (Err A) corruptA (true ∷ os) (_ ∷ xs) = error ∷ ♯ (corruptA (♭ os) (♭ xs)) corruptA (false ∷ os) (x ∷ xs) = ok x ∷ ♯ (corruptA (♭ os) (♭ xs)) -- 25 June 2014. Requires the TERMINATING flag when using -- --without-K. See Agda Issue 1214. -- TODO (03 December 2015): Report the issue. -- The ABP transfer function. {-# TERMINATING #-} abpTransA : {A : Set} → Bit → Stream Bit → Stream Bit → Stream A → Stream A abpTransA {A} b os₁ os₂ is = outA b bs where as : Stream (A × Bit) bs : Stream (Err (A × Bit)) cs : Stream Bit ds : Stream (Err Bit) as = sendA b is ds bs = corruptA os₁ as cs = ackA b bs ds = corruptA os₂ cs
{ "alphanum_fraction": 0.547, "avg_line_length": 31.5789473684, "ext": "agda", "hexsha": "2d7c03b1f6b292d13ffc4298f22280110547a6fb", "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/Program/ABP/ABP-SL.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/Program/ABP/ABP-SL.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/Program/ABP/ABP-SL.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": 974, "size": 3000 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.ImplShared.Consensus.Types open import Optics.All open import Util.Encode open import Util.PKCS as PKCS hiding (sign) open import Util.Prelude module LibraBFT.Impl.Types.ValidatorSigner where sign : {C : Set} ⦃ enc : Encoder C ⦄ → ValidatorSigner → C → Signature sign (ValidatorSigner∙new _ sk) c = PKCS.sign-encodable c sk postulate -- TODO-1: publicKey_USE_ONLY_AT_INIT publicKey_USE_ONLY_AT_INIT : ValidatorSigner → PK obmGetValidatorSigner : AuthorName → List ValidatorSigner → Either ErrLog ValidatorSigner obmGetValidatorSigner name vss = case List-filter go vss of λ where (vs ∷ []) → pure vs _ → Left fakeErr -- [ "ValidatorSigner", "obmGetValidatorSigner" -- , name , "not found in" -- , show (fmap (^.vsAuthor.aAuthorName) vss) ] where go : (vs : ValidatorSigner) → Dec (vs ^∙ vsAuthor ≡ name) go (ValidatorSigner∙new _vsAuthor _) = _vsAuthor ≟ name
{ "alphanum_fraction": 0.6879032258, "avg_line_length": 37.5757575758, "ext": "agda", "hexsha": "78946f317d3e1a9d2794908e68a2eb3c106f57fa", "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/Types/ValidatorSigner.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/Types/ValidatorSigner.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/Types/ValidatorSigner.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 344, "size": 1240 }
module JMEq where data _==_ {A : Set}(x : A) : {B : Set}(y : B) -> Set where refl : x == x subst : {A : Set}{x y : A}(P : A -> Set) -> x == y -> P x -> P y subst {A} P refl px = px
{ "alphanum_fraction": 0.4545454545, "avg_line_length": 18.7, "ext": "agda", "hexsha": "b0bc4a33696f485ec99ecc8507b5dc575d7e0634", "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/JMEq.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/JMEq.agda", "max_line_length": 64, "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/JMEq.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": 80, "size": 187 }
-- {-# OPTIONS --without-K #-} module Paths where open import Agda.Prim open import Data.Unit open import Data.Bool open import Data.Nat hiding (_⊔_) open import Data.Sum open import Data.Product open import Function open import Relation.Binary.PropositionalEquality open import PointedTypes --infix 2 _∎ -- equational reasoning --infixr 2 _≡⟨_⟩_ -- equational reasoning ------------------------------------------------------------------------------ -- Paths are pi-combinators data _⇛_ {ℓ : Level} : (A• : Set• ℓ) → (B• : Set• ℓ) → Set (lsuc (lsuc ℓ)) where -- additive structure swap₁₊⇛ : {A B : Set ℓ} {a : A} {b : B} → •[ A ⊎ B , inj₁ a ] ⇛ •[ B ⊎ A , inj₂ a ] id⇛ : {A : Set ℓ} → (a : A) → •[ A , a ] ⇛ •[ A , a ] η⋆⇛ : {A : Set ℓ} {a : A} → •[ A , a ] ⇛ •[ (A → A) , id ] equiv⇛ : {A B : Set ℓ} {a : A} {b : B} → (f : •[ A , a ] →• •[ B , b ]) → (fequiv : isequiv• f) → •[ A , a ] ⇛ •[ B , b ] swap₊ : {ℓ : Level} {A B : Set ℓ} → A ⊎ B → B ⊎ A swap₊ (inj₁ a) = inj₂ a swap₊ (inj₂ b) = inj₁ b eval : {ℓ : Level} {A• B• : Set• ℓ} → A• ⇛ B• → (A• →• B•) eval swap₁₊⇛ = record { fun = swap₊ ; resp• = refl } eval (id⇛ _) = id• eval η⋆⇛ = {!!} eval (equiv⇛ _ _) = {!!} pInversion : {ℓ : Level} {A• B• : Set• ℓ} → (c : A• ⇛ B•) → fun (eval c) (• A•) ≡ • B• pInversion {ℓ} {A•} {B•} c = resp• (eval c) funext : {ℓ : Level} {A• B• : Set• ℓ} {f g : A• →• B•} → (pt f ⇛ pt g) → (f ∼• g) funext = {!!} {-- swap₂₊⇛ : {A• B• : Set• {ℓ}} → (A• ⊎•₂ B•) ⇛ (B• ⊎•₁ A•) assocl₁₊⇛ : {A• B• C• : Set• {ℓ}} → (A• ⊎•₁ (B• ⊎•₁ C•)) ⇛ ((A• ⊎•₁ B•) ⊎•₁ C•) assocl₁₊⇛' : {A• B• C• : Set• {ℓ}} → (A• ⊎•₁ (B• ⊎•₂ C•)) ⇛ ((A• ⊎•₁ B•) ⊎•₁ C•) •[ A ⊎ (B ⊎ C) , inj₁ a ] ⇛ •[ (A ⊎ B) ⊎ C , inj₁ (inj₁ a) ] assocl₂₁₊⇛ : {A B C : Set ℓ} → (b : B) → •[ A ⊎ (B ⊎ C) , inj₂ (inj₁ b) ] ⇛ •[ (A ⊎ B) ⊎ C , inj₁ (inj₂ b) ] assocl₂₂₊⇛ : {A B C : Set ℓ} → (c : C) → •[ A ⊎ (B ⊎ C) , inj₂ (inj₂ c) ] ⇛ •[ (A ⊎ B) ⊎ C , inj₂ c ] assocr₁₁₊⇛ : {A B C : Set ℓ} → (a : A) → •[ (A ⊎ B) ⊎ C , inj₁ (inj₁ a) ] ⇛ •[ A ⊎ (B ⊎ C) , inj₁ a ] assocr₁₂₊⇛ : {A B C : Set ℓ} → (b : B) → •[ (A ⊎ B) ⊎ C , inj₁ (inj₂ b) ] ⇛ •[ A ⊎ (B ⊎ C) , inj₂ (inj₁ b) ] assocr₂₊⇛ : {A B C : Set ℓ} → (c : C) → •[ (A ⊎ B) ⊎ C , inj₂ c ] ⇛ •[ A ⊎ (B ⊎ C) , inj₂ (inj₂ c) ] -- multiplicative structure unite⋆⇛ : {A : Set ℓ} → (a : A) → •[ ⊤ × A , (tt , a) ] ⇛ •[ A , a ] uniti⋆⇛ : {A : Set ℓ} → (a : A) → •[ A , a ] ⇛ •[ ⊤ × A , (tt , a) ] swap⋆⇛ : {A B : Set ℓ} → (a : A) → (b : B) → •[ A × B , (a , b) ] ⇛ •[ B × A , (b , a) ] assocl⋆⇛ : {A B C : Set ℓ} → (a : A) → (b : B) → (c : C) → •[ A × (B × C) , (a , (b , c)) ] ⇛ •[ (A × B) × C , ((a , b) , c) ] assocr⋆⇛ : {A B C : Set ℓ} → (a : A) → (b : B) → (c : C) → •[ (A × B) × C , ((a , b) , c) ] ⇛ •[ A × (B × C) , (a , (b , c)) ] -- distributivity dist₁⇛ : {A B C : Set ℓ} → (a : A) → (c : C) → •[ (A ⊎ B) × C , (inj₁ a , c) ] ⇛ •[ (A × C) ⊎ (B × C) , inj₁ (a , c) ] dist₂⇛ : {A B C : Set ℓ} → (b : B) → (c : C) → •[ (A ⊎ B) × C , (inj₂ b , c) ] ⇛ •[ (A × C) ⊎ (B × C) , inj₂ (b , c) ] factor₁⇛ : {A B C : Set ℓ} → (a : A) → (c : C) → •[ (A × C) ⊎ (B × C) , inj₁ (a , c) ] ⇛ •[ (A ⊎ B) × C , (inj₁ a , c) ] factor₂⇛ : {A B C : Set ℓ} → (b : B) → (c : C) → •[ (A × C) ⊎ (B × C) , inj₂ (b , c) ] ⇛ •[ (A ⊎ B) × C , (inj₂ b , c) ] -- congruence but without sym which is provable id⇛ : {A : Set ℓ} → (a : A) → •[ A , a ] ⇛ •[ A , a ] trans⇛ : {A B C : Set ℓ} {a : A} {b : B} {c : C} → (•[ A , a ] ⇛ •[ B , b ]) → (•[ B , b ] ⇛ •[ C , c ]) → (•[ A , a ] ⇛ •[ C , c ]) plus₁⇛ : {A B C D : Set ℓ} {a : A} {b : B} {c : C} {d : D} → (•[ A , a ] ⇛ •[ C , c ]) → (•[ B , b ] ⇛ •[ D , d ]) → (•[ A ⊎ B , inj₁ a ] ⇛ •[ C ⊎ D , inj₁ c ]) plus₂⇛ : {A B C D : Set ℓ} {a : A} {b : B} {c : C} {d : D} → (•[ A , a ] ⇛ •[ C , c ]) → (•[ B , b ] ⇛ •[ D , d ]) → (•[ A ⊎ B , inj₂ b ] ⇛ •[ C ⊎ D , inj₂ d ]) times⇛ : {A B C D : Set ℓ} {a : A} {b : B} {c : C} {d : D} → (•[ A , a ] ⇛ •[ C , c ]) → (•[ B , b ] ⇛ •[ D , d ]) → (•[ A × B , (a , b) ] ⇛ •[ C × D , (c , d) ]) --} -- Abbreviations and small examples {-- Path : {ℓ : Level} {A B : Set ℓ} → (a : A) → (b : B) → Set (lsuc ℓ) Path {ℓ} {A} {B} a b = •[ A , a ] ⇛ •[ B , b ] 2Path : {ℓ : Level} {A B C D : Set ℓ} {a : A} {b : B} {c : C} {d : D} → (p : Path a b) → (q : Path c d) → Set (lsuc (lsuc ℓ)) 2Path {ℓ} {A} {B} {C} {D} {a} {b} {c} {d} p q = Path p q -- •[ Path a b , p ] ⇛ •[ Path c d , q ] --} {-- _≡⟨_⟩_ : ∀ {ℓ} → {A B C : Set ℓ} (a : A) {b : B} {c : C} → Path a b → Path b c → Path a c _ ≡⟨ p ⟩ q = trans⇛ p q _∎ : ∀ {ℓ} → {A : Set ℓ} (a : A) → Path a a _∎ a = id⇛ a test3 : {A : Set} {a : A} → Set• test3 {A} {a} = •[ Path a a , id⇛ a ] test4 : Set• test4 = •[ Path ℕ ℕ , id⇛ ℕ ] test5 : Set• test5 = •[ Path (ℕ , Bool) (Bool , ℕ) , swap⋆⇛ ℕ Bool ] test6 : Set• test6 = •[ Path (tt , ℕ) ℕ , unite⋆⇛ ℕ ] test7 : {A : Set} {a : A} → Set• test7 {A} {a} = •[ 2Path (id⇛ a) (id⇛ a) , id⇛ (id⇛ a) ] test8 : {A B C D : Set} {a : A} {b : B} {c : C} {d : D} → (p : Path a b) → (q : Path c d) → Set• test8 {A} {B} {C} {D} {a} {b} {c} {d} p q = •[ Path (a , c) (b , d) , times⇛ p q ] -- Propositional equality implies a path ≡Path : {ℓ : Level} {A : Set ℓ} {x y : A} → (x ≡ y) → Path x y ≡Path {ℓ} {A} {x} {.x} refl = id⇛ x --} ------------------------------------------------------------------------------ -- Path induction {-- pathInd : {ℓ ℓ' : Level} → (P : {A• B• : Set• {ℓ}} → (A• ⇛ B•) → Set ℓ') → ({A• B• : Set• {ℓ}} → P (swap₁₊⇛ {ℓ} {A•} {B•})) → pathInd : {ℓ ℓ' : Level} → (P : {A B : Set ℓ} {a : A} {b : B} → (•[ A , a ] ⇛ •[ B , b ]) → Set ℓ') → ({A B : Set ℓ} → (a : A) → P (swap₁₊⇛ {ℓ} {A} {B} a)) → ({A B : Set ℓ} → (b : B) → P (swap₂₊⇛ {ℓ} {A} {B} b)) → ({A B C : Set ℓ} → (a : A) → P (assocl₁₊⇛ {ℓ} {A} {B} {C} a)) → ({A B C : Set ℓ} → (b : B) → P (assocl₂₁₊⇛ {ℓ} {A} {B} {C} b)) → ({A B C : Set ℓ} → (c : C) → P (assocl₂₂₊⇛ {ℓ} {A} {B} {C} c)) → ({A B C : Set ℓ} → (a : A) → P (assocr₁₁₊⇛ {ℓ} {A} {B} {C} a)) → ({A B C : Set ℓ} → (b : B) → P (assocr₁₂₊⇛ {ℓ} {A} {B} {C} b)) → ({A B C : Set ℓ} → (c : C) → P (assocr₂₊⇛ {ℓ} {A} {B} {C} c)) → ({A : Set ℓ} → (a : A) → P (unite⋆⇛ {ℓ} {A} a)) → ({A : Set ℓ} → (a : A) → P (uniti⋆⇛ {ℓ} {A} a)) → ({A B : Set ℓ} → (a : A) → (b : B) → P (swap⋆⇛ {ℓ} {A} {B} a b)) → ({A B C : Set ℓ} → (a : A) → (b : B) → (c : C) → P (assocl⋆⇛ {ℓ} {A} {B} {C} a b c)) → ({A B C : Set ℓ} → (a : A) → (b : B) → (c : C) → P (assocr⋆⇛ {ℓ} {A} {B} {C} a b c)) → ({A B C : Set ℓ} → (a : A) → (c : C) → P (dist₁⇛ {ℓ} {A} {B} {C} a c)) → ({A B C : Set ℓ} → (b : B) → (c : C) → P (dist₂⇛ {ℓ} {A} {B} {C} b c)) → ({A B C : Set ℓ} → (a : A) → (c : C) → P (factor₁⇛ {ℓ} {A} {B} {C} a c)) → ({A B C : Set ℓ} → (b : B) → (c : C) → P (factor₂⇛ {ℓ} {A} {B} {C} b c)) → ({A : Set ℓ} → (a : A) → P (id⇛ {ℓ} {A} a)) → ({A B C : Set ℓ} {a : A} {b : B} {c : C} → (p : (•[ A , a ] ⇛ •[ B , b ])) → (q : (•[ B , b ] ⇛ •[ C , c ])) → P p → P q → P (trans⇛ p q)) → ({A B C D : Set ℓ} {a : A} {b : B} {c : C} {d : D} → (p : (•[ A , a ] ⇛ •[ C , c ])) → (q : (•[ B , b ] ⇛ •[ D , d ])) → P p → P q → P (plus₁⇛ {ℓ} {A} {B} {C} {D} {a} {b} {c} {d} p q)) → ({A B C D : Set ℓ} {a : A} {b : B} {c : C} {d : D} → (p : (•[ A , a ] ⇛ •[ C , c ])) → (q : (•[ B , b ] ⇛ •[ D , d ])) → P p → P q → P (plus₂⇛ {ℓ} {A} {B} {C} {D} {a} {b} {c} {d} p q)) → ({A B C D : Set ℓ} {a : A} {b : B} {c : C} {d : D} → (p : (•[ A , a ] ⇛ •[ C , c ])) → (q : (•[ B , b ] ⇛ •[ D , d ])) → P p → P q → P (times⇛ p q)) → {A B : Set ℓ} {a : A} {b : B} → (p : •[ A , a ] ⇛ •[ B , b ]) → P p {A• B• : Set• {ℓ}} → (p : A• ⇛ B•) → P p pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (swap₁₊⇛ a) = swap₁₊ a pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (swap₂₊⇛ b) = swap₂₊ b pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (assocl₁₊⇛ a) = assocl₁₊ a pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (assocl₂₁₊⇛ b) = assocl₂₁₊ b pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (assocl₂₂₊⇛ c) = assocl₂₂₊ c pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (assocr₁₁₊⇛ a) = assocr₁₁₊ a pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (assocr₁₂₊⇛ b) = assocr₁₂₊ b pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (assocr₂₊⇛ c) = assocr₂₊ c pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (unite⋆⇛ a) = unite⋆ a pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (uniti⋆⇛ a) = uniti⋆ a pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (swap⋆⇛ a b) = swap⋆ a b pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (assocl⋆⇛ a b c) = assocl⋆ a b c pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (assocr⋆⇛ a b c) = assocr⋆ a b c pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (dist₁⇛ a c) = dist₁ a c pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (dist₂⇛ b c) = dist₂ b c pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (factor₁⇛ a c) = factor₁ a c pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (factor₂⇛ b c) = factor₂ b c pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (id⇛ a) = cid a pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (trans⇛ p q) = ctrans p q (pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times p) (pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times q) pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (plus₁⇛ p q) = plus₁ p q (pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times p) (pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times q) pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (plus₂⇛ p q) = plus₂ p q (pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times p) (pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times q) pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times (times⇛ p q) = times p q (pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times p) (pathInd P swap₁₊ swap₂₊ assocl₁₊ assocl₂₁₊ assocl₂₂₊ assocr₁₁₊ assocr₁₂₊ assocr₂₊ unite⋆ uniti⋆ swap⋆ assocl⋆ assocr⋆ dist₁ dist₂ factor₁ factor₂ cid ctrans plus₁ plus₂ times q) pathInd P swap₁₊ swap₁₊⇛ = swap₁₊ --} ------------------------------------------------------------------------------ -- Groupoid structure (emerging...) {-- sym⇛ : {ℓ : Level} {A B : Set ℓ} {a : A} {b : B} → Path a b → Path b a sym⇛ {ℓ} {A} {B} {a} {b} p = (pathInd (λ {A} {B} {a} {b} p → Path b a) swap₂₊⇛ swap₁₊⇛ assocr₁₁₊⇛ assocr₁₂₊⇛ assocr₂₊⇛ assocl₁₊⇛ assocl₂₁₊⇛ assocl₂₂₊⇛ uniti⋆⇛ unite⋆⇛ (λ a b → swap⋆⇛ b a) assocr⋆⇛ assocl⋆⇛ factor₁⇛ factor₂⇛ dist₁⇛ dist₂⇛ id⇛ (λ _ _ p' q' → trans⇛ q' p')) (λ _ _ p' q' → plus₁⇛ p' q') (λ _ _ p' q' → plus₂⇛ p' q') (λ _ _ p' q' → times⇛ p' q') {A} {B} {a} {b} p test9 : {A : Set} {a : A} → Path (a , (tt , a)) ((tt , a) , a) test9 {A} {a} = sym⇛ (times⇛ (unite⋆⇛ a) (uniti⋆⇛ a)) -- evaluates to (times⇛ (uniti⋆⇛ a) (unite⋆⇛ a) --} {-- idright : {ℓ : Level} {A B : Set ℓ} {a : A} {b : B} {p : Path a b} → 2Path (trans⇛ p (id⇛ b)) p idright {ℓ} {A} {B} {a} {b} {p} = (pathInd (λ {A} {B} {a} {b} p → 2Path (trans⇛ p (id⇛ b)) p) (λ {A} {B} a₁ → {!!}) {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!}) {A} {B} {a} {b} p aptransL : {ℓ : Level} {A B C : Set ℓ} {a : A} {b : B} {c : C} → (p q : Path a b) → (r : Path b c) → (α : 2Path p q) → 2Path (trans⇛ p r) (trans⇛ q r) aptransL {ℓ} {A} {B} {C} {a} {b} {c} p q r α = (pathInd (λ {B} {C} {b} {c} r → (A : Set ℓ) → (a : A) → (p q : Path a b) → (α : 2Path p q) → 2Path (trans⇛ p r) (trans⇛ q r)) (λ a₁ A₂ a₂ p₁ q₁ α₁ → {!!}) {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!} {!!}) {B} {C} {b} {c} r A a p q α symsym : {ℓ : Level} {A B : Set ℓ} {a : A} {b : B} → (p : Path a b) → 2Path (sym⇛ (sym⇛ p)) p symsym {ℓ} {A} {B} {a} {b} p = (pathInd (λ {A} {B} {a} {b} p → 2Path (sym⇛ (sym⇛ p)) p) (λ a → id⇛ (swap₁₊⇛ a)) (λ b → id⇛ (swap₂₊⇛ b)) (λ a → id⇛ (assocl₁₊⇛ a)) (λ b → id⇛ (assocl₂₁₊⇛ b)) (λ c → id⇛ (assocl₂₂₊⇛ c)) (λ a → id⇛ (assocr₁₁₊⇛ a)) (λ b → id⇛ (assocr₁₂₊⇛ b)) (λ c → id⇛ (assocr₂₊⇛ c)) (λ a → id⇛ (unite⋆⇛ a)) (λ a → id⇛ (uniti⋆⇛ a)) (λ a b → id⇛ (swap⋆⇛ a b)) (λ a b c → id⇛ (assocl⋆⇛ a b c)) (λ a b c → id⇛ (assocr⋆⇛ a b c)) (λ a c → id⇛ (dist₁⇛ a c)) (λ b c → id⇛ (dist₂⇛ b c)) (λ a c → id⇛ (factor₁⇛ a c)) (λ b c → id⇛ (factor₂⇛ b c)) (λ a → id⇛ (id⇛ a)) (λ p q α β → {!!}) (λ p q α β → {!!}) (λ p q α β → {!!}) (λ p q α β → {!!})) {A} {B} {a} {b} p --} ------------------------------------------------------------------------------ {-- old stuff which we might need again idright : {A B : Set} {a : A} {b : B} {p : •[ A , a ] ⇛ •[ B , b ]} → (trans⇛ p (id⇛ {B} {b})) 2⇛ p idright = 2Path id⇛ id⇛ idleft : {A B : Set} {a : A} {b : B} {p : •[ A , a ] ⇛ •[ B , b ]} → (trans⇛ (id⇛ {A} {a}) p) 2⇛ p idleft = 2Path id⇛ id⇛ assoc : {A B C D : Set} {a : A} {b : B} {c : C} {d : D} {p : •[ A , a ] ⇛ •[ B , b ]} {q : •[ B , b ] ⇛ •[ C , c ]} {r : •[ C , c ] ⇛ •[ D , d ]} → (trans⇛ p (trans⇛ q r)) 2⇛ (trans⇛ (trans⇛ p q) r) assoc = 2Path id⇛ id⇛ bifunctorid⋆ : {A B : Set} {a : A} {b : B} → (times⇛ (id⇛ {A} {a}) (id⇛ {B} {b})) 2⇛ (id⇛ {A × B} {(a , b)}) bifunctorid⋆ = 2Path id⇛ id⇛ bifunctorid₊₁ : {A B : Set} {a : A} → (plus₁⇛ {A} {B} {A} {B} (id⇛ {A} {a})) 2⇛ (id⇛ {A ⊎ B} {inj₁ a}) bifunctorid₊₁ = 2Path id⇛ id⇛ bifunctorid₊₂ : {A B : Set} {b : B} → (plus₂⇛ {A} {B} {A} {B} (id⇛ {B} {b})) 2⇛ (id⇛ {A ⊎ B} {inj₂ b}) bifunctorid₊₂ = 2Path id⇛ id⇛ bifunctorC⋆ : {A B C D E F : Set} {a : A} {b : B} {c : C} {d : D} {e : E} {f : F} {p : •[ A , a ] ⇛ •[ B , b ]} {q : •[ B , b ] ⇛ •[ C , c ]} {r : •[ D , d ] ⇛ •[ E , e ]} {s : •[ E , e ] ⇛ •[ F , f ]} → (trans⇛ (times⇛ p r) (times⇛ q s)) 2⇛ (times⇛ (trans⇛ p q) (trans⇛ r s)) bifunctorC⋆ = 2Path id⇛ id⇛ bifunctorC₊₁₁ : {A B C D E F : Set} {a : A} {b : B} {c : C} {p : •[ A , a ] ⇛ •[ B , b ]} {q : •[ B , b ] ⇛ •[ C , c ]} → (trans⇛ (plus₁⇛ {A} {D} {B} {E} p) (plus₁⇛ {B} {E} {C} {F} q)) 2⇛ (plus₁⇛ {A} {D} {C} {F} (trans⇛ p q)) bifunctorC₊₁₁ = 2Path id⇛ id⇛ bifunctorC₊₂₂ : {A B C D E F : Set} {d : D} {e : E} {f : F} {r : •[ D , d ] ⇛ •[ E , e ]} {s : •[ E , e ] ⇛ •[ F , f ]} → (trans⇛ (plus₂⇛ {A} {D} {B} {E} r) (plus₂⇛ {B} {E} {C} {F} s)) 2⇛ (plus₂⇛ {A} {D} {C} {F} (trans⇛ r s)) bifunctorC₊₂₂ = 2Path id⇛ id⇛ triangle : {A B : Set} {a : A} {b : B} → (trans⇛ (assocr⋆⇛ {A} {⊤} {B} {a} {tt} {b}) (times⇛ id⇛ unite⋆⇛)) 2⇛ (times⇛ (trans⇛ swap⋆⇛ unite⋆⇛) id⇛) triangle = 2Path id⇛ id⇛ -- Now interpret a path (x ⇛ y) as a value of type (1/x , y) Recip : {A : Set} → (x : • A) → Set₁ Recip {A} x = (x ⇛ x) η : {A : Set} {x : • A} → ⊤ → Recip x × • A η {A} {x} tt = (id⇛ x , x) lower : {A : Set} {x : • A} → x ⇛ x -> ⊤ lower c = tt -- The problem here is that we can't assert that y == x. ε : {A : Set} {x : • A} → Recip x × • A → ⊤ ε {A} {x} (rx , y) = lower (id⇛ ( ↑ (fun (ap rx) (focus y)) )) -- makes insufficient sense apr : {A B : Set} {x : • A} {y : • B} → (x ⇛ y) → Recip y → Recip x apr {A} {B} {x} {y} q ry = trans⇛ q (trans⇛ ry (sym⇛ q)) x ≡⟨ q ⟩ y ≡⟨ ry ⟩ y ≡⟨ sym⇛ q ⟩ x ∎ ε : {A B : Set} {x : A} {y : B} → Recip x → Singleton y → x ⇛ y ε rx (singleton y) = rx y pathV : {A B : Set} {x : A} {y : B} → (x ⇛ y) → Recip x × Singleton y pathV unite₊⇛ = {!!} pathV uniti₊⇛ = {!!} -- swap₁₊⇛ : {A B : Set} {x : A} → _⇛_ {A ⊎ B} {B ⊎ A} (inj₁ x) (inj₂ x) pathV (swap₁₊⇛ {A} {B} {x}) = ((λ x' → {!!}) , singleton (inj₂ x)) pathV swap₂₊⇛ = {!!} pathV assocl₁₊⇛ = {!!} pathV assocl₂₁₊⇛ = {!!} pathV assocl₂₂₊⇛ = {!!} pathV assocr₁₁₊⇛ = {!!} pathV assocr₁₂₊⇛ = {!!} pathV assocr₂₊⇛ = {!!} pathV unite⋆⇛ = {!!} pathV uniti⋆⇛ = {!!} pathV swap⋆⇛ = {!!} pathV assocl⋆⇛ = {!!} pathV assocr⋆⇛ = {!!} pathV dist₁⇛ = {!!} pathV dist₂⇛ = {!!} pathV factor₁⇛ = {!!} pathV factor₂⇛ = {!!} pathV dist0⇛ = {!!} pathV factor0⇛ = {!!} pathV {A} {.A} {x} (id⇛ .x) = {!!} pathV (sym⇛ p) = {!!} pathV (trans⇛ p p₁) = {!!} pathV (plus₁⇛ p) = {!!} pathV (plus₂⇛ p) = {!!} pathV (times⇛ p p₁) = {!!} -- these are individual paths so to speak -- should we represent a path like swap+ as a family explicitly: -- swap+ : (x : A) -> x ⇛ swapF x -- I guess we can: swap+ : (x : A) -> case x of inj1 -> swap1 x else swap2 x If A={x0,x1,x2}, 1/A has three values: (x0<-x0, x0<-x1, x0<-x2) (x1<-x0, x1<-x1, x1<-x2) (x2<-x0, x2<-x1, x2<-x2) It is a fake choice between x0, x1, and x2 (some negative information). You base yourself at x0 for example and enforce that any other value can be mapped to x0. So think of a value of type 1/A as an uncertainty about which value of A we have. It could be x0, x1, or x2 but at the end it makes no difference. There is no choice. You can manipulate a value of type 1/A (x0<-x0, x0<-x1, x0<-x2) by with a path to some arbitrary path to b0 for example: (b0<-x0<-x0, b0<-x0<-x1, b0<-x0<-x2) eta_3 will give (x0<-x0, x0<-x1, x0<-x2, x0) for example but any other combination is equivalent. epsilon_3 will take (x0<-x0, x0<-x1, x0<-x2) and one actual xi which is now certain; we can resolve our previous uncertainty by following the path from xi to x0 thus eliminating the fake choice we seemed to have. Explain connection to negative information. Knowing head or tails is 1 bits. Giving you a choice between heads and tails and then cooking this so that heads=tails takes away your choice. -- transp⇛ : {A B : Set} {x y : • A} → -- (f : A → B) → x ⇛ y → ↑ (f (focus x)) ⇛ ↑ (f (focus y)) -- Morphism of pointed space: contains a path! record _⟶_ {A B : Set} (pA : • A) (pB : • B) : Set₁ where field fun : A → B eq : ↑ (fun (focus pA)) ⇛ pB open _⟶_ _○_ : {A B C : Set} {pA : • A} {pB : • B} {pC : • C} → pA ⟶ pB → pB ⟶ pC → pA ⟶ pC f ○ g = record { fun = λ x → (fun g) ((fun f) x) ; eq = trans⇛ (transp⇛ (fun g) (eq f)) (eq g)} mutual ap : {A B : Set} {x : • A} {y : • B} → x ⇛ y → x ⟶ y ap {y = y} unite₊⇛ = record { fun = λ { (inj₁ ()) ; (inj₂ x) → x } ; eq = id⇛ y } ap uniti₊⇛ (singleton x) = singleton (inj₂ x) ap (swap₁₊⇛ {A} {B} {x}) (singleton .(inj₁ x)) = singleton (inj₂ x) ap (swap₂₊⇛ {A} {B} {y}) (singleton .(inj₂ y)) = singleton (inj₁ y) ap (assocl₁₊⇛ {A} {B} {C} {x}) (singleton .(inj₁ x)) = singleton (inj₁ (inj₁ x)) ap (assocl₂₁₊⇛ {A} {B} {C} {y}) (singleton .(inj₂ (inj₁ y))) = singleton (inj₁ (inj₂ y)) ap (assocl₂₂₊⇛ {A} {B} {C} {z}) (singleton .(inj₂ (inj₂ z))) = singleton (inj₂ z) ap (assocr₁₁₊⇛ {A} {B} {C} {x}) (singleton .(inj₁ (inj₁ x))) = singleton (inj₁ x) ap (assocr₁₂₊⇛ {A} {B} {C} {y}) (singleton .(inj₁ (inj₂ y))) = singleton (inj₂ (inj₁ y)) ap (assocr₂₊⇛ {A} {B} {C} {z}) (singleton .(inj₂ z)) = singleton (inj₂ (inj₂ z)) ap {.(⊤ × A)} {A} {.(tt , x)} {x} unite⋆⇛ (singleton .(tt , x)) = singleton x ap uniti⋆⇛ (singleton x) = singleton (tt , x) ap (swap⋆⇛ {A} {B} {x} {y}) (singleton .(x , y)) = singleton (y , x) ap (assocl⋆⇛ {A} {B} {C} {x} {y} {z}) (singleton .(x , (y , z))) = singleton ((x , y) , z) ap (assocr⋆⇛ {A} {B} {C} {x} {y} {z}) (singleton .((x , y) , z)) = singleton (x , (y , z)) ap (dist₁⇛ {A} {B} {C} {x} {z}) (singleton .(inj₁ x , z)) = singleton (inj₁ (x , z)) ap (dist₂⇛ {A} {B} {C} {y} {z}) (singleton .(inj₂ y , z)) = singleton (inj₂ (y , z)) ap (factor₁⇛ {A} {B} {C} {x} {z}) (singleton .(inj₁ (x , z))) = singleton (inj₁ x , z) ap (factor₂⇛ {A} {B} {C} {y} {z}) (singleton .(inj₂ (y , z))) = singleton (inj₂ y , z) ap {.(⊥ × A)} {.⊥} {.(• , x)} {•} (dist0⇛ {A} {.•} {x}) (singleton .(• , x)) = singleton • ap factor0⇛ (singleton ()) ap {x = x} (id⇛ .x) = record { fun = λ x → x; eq = id⇛ x } ap (sym⇛ c) = apI c ap (trans⇛ c₁ c₂) = (ap c₁) ○ (ap c₂) ap (transp⇛ f a) = record { fun = λ x → x; eq = transp⇛ f a } ap (plus₁⇛ {A} {B} {C} {D} {x} {z} c) (singleton .(inj₁ x)) with ap c (singleton x) ... | singleton .z = singleton (inj₁ z) ap (plus₂⇛ {A} {B} {C} {D} {y} {w} c) (singleton .(inj₂ y)) with ap c (singleton y) ... | singleton .w = singleton (inj₂ w) ap (times⇛ {A} {B} {C} {D} {x} {y} {z} {w} c₁ c₂) (singleton .(x , y)) with ap c₁ (singleton x) | ap c₂ (singleton y) ... | singleton .z | singleton .w = singleton (z , w) apI : {A B : Set} {x : • A} {y : • B} → x ⇛ y → y ⟶ x apI {y = y} unite₊⇛ = record { fun = inj₂; eq = id⇛ (↑ (inj₂ (focus y))) } apI {A} {.(⊥ ⊎ A)} {x} uniti₊⇛ (singleton .(inj₂ x)) = singleton x apI (swap₁₊⇛ {A} {B} {x}) (singleton .(inj₂ x)) = singleton (inj₁ x) apI (swap₂₊⇛ {A} {B} {y}) (singleton .(inj₁ y)) = singleton (inj₂ y) apI (assocl₁₊⇛ {A} {B} {C} {x}) (singleton .(inj₁ (inj₁ x))) = singleton (inj₁ x) apI (assocl₂₁₊⇛ {A} {B} {C} {y}) (singleton .(inj₁ (inj₂ y))) = singleton (inj₂ (inj₁ y)) apI (assocl₂₂₊⇛ {A} {B} {C} {z}) (singleton .(inj₂ z)) = singleton (inj₂ (inj₂ z)) apI (assocr₁₁₊⇛ {A} {B} {C} {x}) (singleton .(inj₁ x)) = singleton (inj₁ (inj₁ x)) apI (assocr₁₂₊⇛ {A} {B} {C} {y}) (singleton .(inj₂ (inj₁ y))) = singleton (inj₁ (inj₂ y)) apI (assocr₂₊⇛ {A} {B} {C} {z}) (singleton .(inj₂ (inj₂ z))) = singleton (inj₂ z) apI unite⋆⇛ (singleton x) = singleton (tt , x) apI {A} {.(⊤ × A)} {x} uniti⋆⇛ (singleton .(tt , x)) = singleton x apI (swap⋆⇛ {A} {B} {x} {y}) (singleton .(y , x)) = singleton (x , y) apI (assocl⋆⇛ {A} {B} {C} {x} {y} {z}) (singleton .((x , y) , z)) = singleton (x , (y , z)) apI (assocr⋆⇛ {A} {B} {C} {x} {y} {z}) (singleton .(x , (y , z))) = singleton ((x , y) , z) apI (dist₁⇛ {A} {B} {C} {x} {z}) (singleton .(inj₁ (x , z))) = singleton (inj₁ x , z) apI (dist₂⇛ {A} {B} {C} {y} {z}) (singleton .(inj₂ (y , z))) = singleton (inj₂ y , z) apI (factor₁⇛ {A} {B} {C} {x} {z}) (singleton .(inj₁ x , z)) = singleton (inj₁ (x , z)) apI (factor₂⇛ {A} {B} {C} {y} {z}) (singleton .(inj₂ y , z)) = singleton (inj₂ (y , z)) apI dist0⇛ (singleton ()) apI {.⊥} {.(⊥ × A)} {•} (factor0⇛ {A} {.•} {x}) (singleton .(• , x)) = singleton • apI {x = x} (id⇛ .x) = record { fun = λ x → x; eq = id⇛ x } apI (sym⇛ c) = ap c apI (trans⇛ c₁ c₂) = (apI c₂) ○ (apI c₁) apI (transp⇛ f a) = record { fun = λ x → x; eq = transp⇛ f (sym⇛ a) } apI (plus₁⇛ {A} {B} {C} {D} {x} {z} c) (singleton .(inj₁ z)) with apI c (singleton z) ... | singleton .x = singleton (inj₁ x) apI (plus₂⇛ {A} {B} {C} {D} {y} {w} c) (singleton .(inj₂ w)) with apI c (singleton w) ... | singleton .y = singleton (inj₂ y) apI (times⇛ {A} {B} {C} {D} {x} {y} {z} {w} c₁ c₂) (singleton .(z , w)) with apI c₁ (singleton z) | apI c₂ (singleton w) ... | singleton .x | singleton .y = singleton (x , y) --} --}
{ "alphanum_fraction": 0.4637303852, "avg_line_length": 38.9986091794, "ext": "agda", "hexsha": "00a304048ad64bfbd33f4e06b13c55e2911e9419", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Paths.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Paths.agda", "max_line_length": 95, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Paths.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 14352, "size": 28040 }
module STLC.Coquand.Substitution where open import STLC.Coquand.Renaming public open import Category -------------------------------------------------------------------------------- -- Substitutions infix 3 _⊢⋆_ data _⊢⋆_ : 𝒞 → 𝒞 → Set where ∅ : ∀ {Γ} → Γ ⊢⋆ ∅ _,_ : ∀ {Γ Ξ A} → (σ : Γ ⊢⋆ Ξ) (M : Γ ⊢ A) → Γ ⊢⋆ Ξ , A putₛ : ∀ {Ξ Γ} → (∀ {A} → Ξ ⊢ A → Γ ⊢ A) → Γ ⊢⋆ Ξ putₛ {∅} f = ∅ putₛ {Γ , A} f = putₛ (λ M → f (wk M)) , f 0 getₛ : ∀ {Γ Ξ A} → Γ ⊢⋆ Ξ → Ξ ∋ A → Γ ⊢ A getₛ (σ , M) zero = M getₛ (σ , M) (suc i) = getₛ σ i wkₛ : ∀ {A Γ Ξ} → Γ ⊢⋆ Ξ → Γ , A ⊢⋆ Ξ wkₛ ∅ = ∅ wkₛ (σ , M) = wkₛ σ , wk M liftₛ : ∀ {A Γ Ξ} → Γ ⊢⋆ Ξ → Γ , A ⊢⋆ Ξ , A liftₛ σ = wkₛ σ , 0 idₛ : ∀ {Γ} → Γ ⊢⋆ Γ idₛ {∅} = ∅ idₛ {Γ , A} = liftₛ idₛ sub : ∀ {Γ Ξ A} → Γ ⊢⋆ Ξ → Ξ ⊢ A → Γ ⊢ A sub σ (𝓋 i) = getₛ σ i sub σ (ƛ M) = ƛ (sub (liftₛ σ) M) sub σ (M ∙ N) = sub σ M ∙ sub σ N cut : ∀ {Γ A B} → Γ ⊢ A → Γ , A ⊢ B → Γ ⊢ B cut M N = sub (idₛ , M) N -- NOTE: _●_ = sub⋆ _●_ : ∀ {Γ Ξ Φ} → Γ ⊢⋆ Ξ → Ξ ⊢⋆ Φ → Γ ⊢⋆ Φ σ₁ ● ∅ = ∅ σ₁ ● (σ₂ , M) = σ₁ ● σ₂ , sub σ₁ M -------------------------------------------------------------------------------- -- (wkgetₛ) natgetₛ : ∀ {Γ Ξ A B} → (σ : Γ ⊢⋆ Ξ) (i : Ξ ∋ A) → getₛ (wkₛ {B} σ) i ≡ (wk ∘ getₛ σ) i natgetₛ (σ , M) zero = refl natgetₛ (σ , M) (suc i) = natgetₛ σ i idgetₛ : ∀ {Γ A} → (i : Γ ∋ A) → getₛ idₛ i ≡ 𝓋 i idgetₛ zero = refl idgetₛ (suc i) = natgetₛ idₛ i ⦙ wk & idgetₛ i ⦙ 𝓋 & ( natgetᵣ idᵣ i ⦙ suc & idgetᵣ i ) idsub : ∀ {Γ A} → (M : Γ ⊢ A) → sub idₛ M ≡ M idsub (𝓋 i) = idgetₛ i idsub (ƛ M) = ƛ & idsub M idsub (M ∙ N) = _∙_ & idsub M ⊗ idsub N -------------------------------------------------------------------------------- ⌊_⌋ : ∀ {Γ Γ′} → Γ′ ∋⋆ Γ → Γ′ ⊢⋆ Γ ⌊ ∅ ⌋ = ∅ ⌊ η , i ⌋ = ⌊ η ⌋ , 𝓋 i -- NOTE: _◐_ = getₛ⋆ _◐_ : ∀ {Γ Ξ Ξ′} → Γ ⊢⋆ Ξ′ → Ξ′ ∋⋆ Ξ → Γ ⊢⋆ Ξ σ ◐ η = σ ● ⌊ η ⌋ -- NOTE: _◑_ = ren⋆ _◑_ : ∀ {Γ Γ′ Ξ} → Γ′ ∋⋆ Γ → Γ ⊢⋆ Ξ → Γ′ ⊢⋆ Ξ η ◑ σ = ⌊ η ⌋ ● σ ⌊get⌋ : ∀ {Γ Γ′ A} → (η : Γ′ ∋⋆ Γ) (i : Γ ∋ A) → getₛ ⌊ η ⌋ i ≡ 𝓋 (getᵣ η i) ⌊get⌋ (η , j) zero = refl ⌊get⌋ (η , j) (suc i) = ⌊get⌋ η i ⌊wk⌋ : ∀ {Γ Γ′ A} → (η : Γ′ ∋⋆ Γ) → wkₛ {A} ⌊ η ⌋ ≡ ⌊ wkᵣ η ⌋ ⌊wk⌋ ∅ = refl ⌊wk⌋ (η , i) = (wkₛ ⌊ η ⌋ ,_) & (𝓋 & natgetᵣ idᵣ i) ⦙ _,_ & ⌊wk⌋ η ⊗ 𝓋 ∘ suc & idgetᵣ i ⌊lift⌋ : ∀ {Γ Γ′ A} → (η : Γ′ ∋⋆ Γ) → liftₛ {A} ⌊ η ⌋ ≡ ⌊ liftᵣ η ⌋ ⌊lift⌋ η = (_, 0) & ⌊wk⌋ η ⌊id⌋ : ∀ {Γ} → idₛ {Γ} ≡ ⌊ idᵣ ⌋ ⌊id⌋ {∅} = refl ⌊id⌋ {Γ , A} = (_, 0) & ( wkₛ & ⌊id⌋ ⦙ ⌊wk⌋ idᵣ ) ⌊sub⌋ : ∀ {Γ Γ′ A} → (η : Γ′ ∋⋆ Γ) (M : Γ ⊢ A) → sub ⌊ η ⌋ M ≡ ren η M ⌊sub⌋ η (𝓋 i) = ⌊get⌋ η i ⌊sub⌋ η (ƛ M) = ƛ & ( (λ σ → sub σ M) & ⌊lift⌋ η ⦙ ⌊sub⌋ (liftᵣ η) M ) ⌊sub⌋ η (M ∙ N) = _∙_ & ⌊sub⌋ η M ⊗ ⌊sub⌋ η N ⌊○⌋ : ∀ {Γ Γ′ Γ″} → (η₁ : Γ″ ∋⋆ Γ′) (η₂ : Γ′ ∋⋆ Γ) → ⌊ η₁ ○ η₂ ⌋ ≡ ⌊ η₁ ⌋ ● ⌊ η₂ ⌋ ⌊○⌋ η₁ ∅ = refl ⌊○⌋ η₁ (η₂ , i) = _,_ & ⌊○⌋ η₁ η₂ ⊗ (⌊get⌋ η₁ i ⁻¹) -------------------------------------------------------------------------------- zap◐ : ∀ {Γ Ξ Ξ′ A} → (σ : Γ ⊢⋆ Ξ′) (η : Ξ′ ∋⋆ Ξ) (M : Γ ⊢ A) → (σ , M) ◐ wkᵣ η ≡ σ ◐ η zap◐ σ ∅ M = refl zap◐ σ (η , i) M = (_, getₛ σ i) & zap◐ σ η M rid◐ : ∀ {Γ Ξ} → (σ : Γ ⊢⋆ Ξ) → σ ◐ idᵣ ≡ σ rid◐ ∅ = refl rid◐ (σ , M) = (_, M) & ( zap◐ σ idᵣ M ⦙ rid◐ σ ) -------------------------------------------------------------------------------- get◐ : ∀ {Γ Ξ Ξ′ A} → (σ : Γ ⊢⋆ Ξ′) (η : Ξ′ ∋⋆ Ξ) (i : Ξ ∋ A) → getₛ (σ ◐ η) i ≡ (getₛ σ ∘ getᵣ η) i get◐ σ (η , j) zero = refl get◐ σ (η , j) (suc i) = get◐ σ η i wk◐ : ∀ {Γ Ξ Ξ′ A} → (σ : Γ ⊢⋆ Ξ′) (η : Ξ′ ∋⋆ Ξ) → wkₛ {A} (σ ◐ η) ≡ wkₛ σ ◐ η wk◐ σ ∅ = refl wk◐ σ (η , i) = _,_ & wk◐ σ η ⊗ (natgetₛ σ i ⁻¹) lift◐ : ∀ {Γ Ξ Ξ′ A} → (σ : Γ ⊢⋆ Ξ′) (η : Ξ′ ∋⋆ Ξ) → liftₛ {A} (σ ◐ η) ≡ liftₛ σ ◐ liftᵣ η lift◐ σ η = (_, 0) & ( wk◐ σ η ⦙ zap◐ (wkₛ σ) η 0 ⁻¹ ) wkrid◐ : ∀ {Γ Ξ A} → (σ : Γ ⊢⋆ Ξ) → wkₛ {A} σ ◐ idᵣ ≡ wkₛ σ wkrid◐ σ = wk◐ σ idᵣ ⁻¹ ⦙ wkₛ & rid◐ σ liftwkrid◐ : ∀ {Γ Ξ A} → (σ : Γ ⊢⋆ Ξ) → liftₛ {A} σ ◐ wkᵣ idᵣ ≡ wkₛ σ liftwkrid◐ σ = zap◐ (wkₛ σ) idᵣ 0 ⦙ wkrid◐ σ mutual sub◐ : ∀ {Γ Ξ Ξ′ A} → (σ : Γ ⊢⋆ Ξ′) (η : Ξ′ ∋⋆ Ξ) (M : Ξ ⊢ A) → sub (σ ◐ η) M ≡ (sub σ ∘ ren η) M sub◐ σ η (𝓋 i) = get◐ σ η i sub◐ σ η (ƛ M) = ƛ & sublift◐ σ η M sub◐ σ η (M ∙ N) = _∙_ & sub◐ σ η M ⊗ sub◐ σ η N sublift◐ : ∀ {Γ Ξ Ξ′ A B} → (σ : Γ ⊢⋆ Ξ′) (η : Ξ′ ∋⋆ Ξ) (M : Ξ , B ⊢ A) → sub (liftₛ {B} (σ ◐ η)) M ≡ (sub (liftₛ σ) ∘ ren (liftᵣ η)) M sublift◐ σ η M = (λ σ′ → sub σ′ M) & lift◐ σ η ⦙ sub◐ (liftₛ σ) (liftᵣ η) M subwk◐ : ∀ {Γ Ξ Ξ′ A B} → (σ : Γ ⊢⋆ Ξ′) (η : Ξ′ ∋⋆ Ξ) (M : Ξ ⊢ A) → sub (wkₛ {B} (σ ◐ η)) M ≡ (sub (wkₛ σ) ∘ ren η) M subwk◐ σ η M = (λ σ′ → sub σ′ M) & wk◐ σ η ⦙ sub◐ (wkₛ σ) η M subliftwk◐ : ∀ {Γ Ξ Ξ′ A B} → (σ : Γ ⊢⋆ Ξ′) (η : Ξ′ ∋⋆ Ξ) (M : Ξ ⊢ A) → sub (wkₛ {B} (σ ◐ η)) M ≡ (sub (liftₛ σ) ∘ ren (wkᵣ η)) M subliftwk◐ σ η M = (λ σ′ → sub σ′ M) & ( wk◐ σ η ⦙ zap◐ (wkₛ σ) η 0 ⁻¹ ) ⦙ sub◐ (liftₛ σ) (wkᵣ η) M -------------------------------------------------------------------------------- zap◑ : ∀ {Γ Γ′ Ξ A} → (η : Γ′ ∋⋆ Γ) (σ : Γ ⊢⋆ Ξ) (i : Γ′ ∋ A) → (η , i) ◑ wkₛ σ ≡ η ◑ σ zap◑ η ∅ i = refl zap◑ η (σ , j) i = _,_ & zap◑ η σ i ⊗ ( sub◐ (⌊ η ⌋ , 𝓋 i) (wkᵣ idᵣ) j ⁻¹ ⦙ (λ σ′ → sub σ′ j) & ( zap◐ ⌊ η ⌋ idᵣ (𝓋 i) ⦙ rid◐ ⌊ η ⌋ ) ) lid◑ : ∀ {Γ Ξ} → (σ : Γ ⊢⋆ Ξ) → idᵣ ◑ σ ≡ σ lid◑ ∅ = refl lid◑ (σ , M) = _,_ & lid◑ σ ⊗ ( (λ σ′ → sub σ′ M) & ⌊id⌋ ⁻¹ ⦙ idsub M ) -------------------------------------------------------------------------------- zap● : ∀ {Γ Ξ Φ A} → (σ₁ : Γ ⊢⋆ Ξ) (σ₂ : Ξ ⊢⋆ Φ) (M : Γ ⊢ A) → (σ₁ , M) ● wkₛ σ₂ ≡ σ₁ ● σ₂ zap● σ₁ ∅ M = refl zap● σ₁ (σ₂ , N) M = _,_ & zap● σ₁ σ₂ M ⊗ ( sub◐ (σ₁ , M) (wkᵣ idᵣ) N ⁻¹ ⦙ (λ σ′ → sub σ′ N) & ( zap◐ σ₁ idᵣ M ⦙ rid◐ σ₁ ) ) lid● : ∀ {Γ Ξ} → (σ : Γ ⊢⋆ Ξ) → idₛ ● σ ≡ σ lid● ∅ = refl lid● (σ , M) = _,_ & lid● σ ⊗ idsub M rid● : ∀ {Γ Ξ} → (σ : Γ ⊢⋆ Ξ) → σ ● idₛ ≡ σ rid● σ = (σ ●_) & ⌊id⌋ ⦙ rid◐ σ -------------------------------------------------------------------------------- get◑ : ∀ {Γ Γ′ Ξ A} → (η : Γ′ ∋⋆ Γ) (σ : Γ ⊢⋆ Ξ) (i : Ξ ∋ A) → getₛ (η ◑ σ) i ≡ (ren η ∘ getₛ σ) i get◑ η (σ , M) zero = ⌊sub⌋ η M get◑ η (σ , M) (suc i) = get◑ η σ i wk◑ : ∀ {Γ Γ′ Ξ A} → (η : Γ′ ∋⋆ Γ) (σ : Γ ⊢⋆ Ξ) → wkₛ {A} (η ◑ σ) ≡ wkᵣ η ◑ σ wk◑ η ∅ = refl wk◑ η (σ , M) = _,_ & wk◑ η σ ⊗ ( ren (wkᵣ idᵣ) & ⌊sub⌋ η M ⦙ ren○ (wkᵣ idᵣ) η M ⁻¹ ⦙ (λ η′ → ren η′ M) & wklid○ η ⦙ ⌊sub⌋ (wkᵣ η) M ⁻¹ ) lift◑ : ∀ {Γ Γ′ Ξ A} → (η : Γ′ ∋⋆ Γ) (σ : Γ ⊢⋆ Ξ) → liftₛ {A} (η ◑ σ) ≡ liftᵣ η ◑ liftₛ σ lift◑ η σ = (_, 0) & ( wk◑ η σ ⦙ zap● ⌊ wkᵣ η ⌋ σ 0 ⁻¹ ) wklid◑ : ∀ {Γ Ξ A} → (σ : Γ ⊢⋆ Ξ) → wkᵣ {A} idᵣ ◑ σ ≡ wkₛ σ wklid◑ σ = wk◑ idᵣ σ ⁻¹ ⦙ wkₛ & lid◑ σ liftwklid◑ : ∀ {Γ Ξ A} → (σ : Γ ⊢⋆ Ξ) → (liftᵣ {A} idᵣ ◑ wkₛ σ) ≡ wkₛ σ liftwklid◑ σ = zap◑ (wkᵣ idᵣ) σ 0 ⦙ wklid◑ σ mutual sub◑ : ∀ {Γ Γ′ Ξ A} → (η : Γ′ ∋⋆ Γ) (σ : Γ ⊢⋆ Ξ) (M : Ξ ⊢ A) → sub (η ◑ σ) M ≡ (ren η ∘ sub σ) M sub◑ η σ (𝓋 i) = get◑ η σ i sub◑ η σ (ƛ M) = ƛ & sublift◑ η σ M sub◑ η σ (M ∙ N) = _∙_ & sub◑ η σ M ⊗ sub◑ η σ N sublift◑ : ∀ {Γ Γ′ Ξ A B} → (η : Γ′ ∋⋆ Γ) (σ : Γ ⊢⋆ Ξ) (M : Ξ , B ⊢ A) → sub (liftₛ {B} (η ◑ σ)) M ≡ (ren (liftᵣ η) ∘ sub (liftₛ σ)) M sublift◑ η σ M = (λ σ′ → sub σ′ M) & lift◑ η σ ⦙ sub◑ (liftᵣ η) (liftₛ σ) M subwk◑ : ∀ {Γ Γ′ Ξ A B} → (η : Γ′ ∋⋆ Γ) (σ : Γ ⊢⋆ Ξ) (M : Ξ ⊢ A) → sub (wkₛ {B} (η ◑ σ)) M ≡ (ren (wkᵣ η) ∘ sub σ) M subwk◑ η σ M = (λ σ′ → sub σ′ M) & wk◑ η σ ⦙ sub◑ (wkᵣ η) σ M subliftwk◑ : ∀ {Γ Γ′ Ξ A B} → (η : Γ′ ∋⋆ Γ) (σ : Γ ⊢⋆ Ξ) (M : Ξ ⊢ A) → sub (wkₛ {B} (η ◑ σ)) M ≡ (ren (liftᵣ η) ∘ sub (wkₛ σ)) M subliftwk◑ η σ M = (λ σ′ → sub σ′ M) & ( wk◑ η σ ⦙ zap◑ (wkᵣ η) σ 0 ⁻¹ ) ⦙ sub◑ (liftᵣ η) (wkₛ σ) M -------------------------------------------------------------------------------- get● : ∀ {Γ Ξ Φ A} → (σ₁ : Γ ⊢⋆ Ξ) (σ₂ : Ξ ⊢⋆ Φ) (i : Φ ∋ A) → getₛ (σ₁ ● σ₂) i ≡ (sub σ₁ ∘ getₛ σ₂) i get● σ₁ (σ₂ , M) zero = refl get● σ₁ (σ₂ , M) (suc i) = get● σ₁ σ₂ i wk● : ∀ {Γ Ξ Φ A} → (σ₁ : Γ ⊢⋆ Ξ) (σ₂ : Ξ ⊢⋆ Φ) → wkₛ {A} (σ₁ ● σ₂) ≡ wkₛ σ₁ ● σ₂ wk● σ₁ ∅ = refl wk● σ₁ (σ₂ , M) = _,_ & wk● σ₁ σ₂ ⊗ ( sub◑ (wkᵣ idᵣ) σ₁ M ⁻¹ ⦙ (λ σ′ → sub σ′ M) & wklid◑ σ₁ ) lift● : ∀ {Γ Ξ Φ A} → (σ₁ : Γ ⊢⋆ Ξ) (σ₂ : Ξ ⊢⋆ Φ) → liftₛ {A} (σ₁ ● σ₂) ≡ liftₛ σ₁ ● liftₛ σ₂ lift● σ₁ σ₂ = (_, 0) & ( wk● σ₁ σ₂ ⦙ zap● (wkₛ σ₁) σ₂ 0 ⁻¹ ) wklid● : ∀ {Γ Ξ A} → (σ : Γ ⊢⋆ Ξ) → wkₛ {A} idₛ ● σ ≡ wkₛ σ wklid● σ = wk● idₛ σ ⁻¹ ⦙ wkₛ & lid● σ wkrid● : ∀ {Γ Ξ A} → (σ : Γ ⊢⋆ Ξ) → wkₛ {A} σ ● idₛ ≡ wkₛ σ wkrid● σ = wk● σ idₛ ⁻¹ ⦙ wkₛ & rid● σ liftwkrid● : ∀ {Γ Ξ A} → (σ : Γ ⊢⋆ Ξ) → liftₛ {A} σ ● wkₛ idₛ ≡ wkₛ σ liftwkrid● σ = zap● (wkₛ σ) idₛ 0 ⦙ wkrid● σ mutual sub● : ∀ {Γ Ξ Φ A} → (σ₁ : Γ ⊢⋆ Ξ) (σ₂ : Ξ ⊢⋆ Φ) (M : Φ ⊢ A) → sub (σ₁ ● σ₂) M ≡ (sub σ₁ ∘ sub σ₂) M sub● σ₁ σ₂ (𝓋 i) = get● σ₁ σ₂ i sub● σ₁ σ₂ (ƛ M) = ƛ & sublift● σ₁ σ₂ M sub● σ₁ σ₂ (M ∙ N) = _∙_ & sub● σ₁ σ₂ M ⊗ sub● σ₁ σ₂ N sublift● : ∀ {Γ Ξ Φ A B} → (σ₁ : Γ ⊢⋆ Ξ) (σ₂ : Ξ ⊢⋆ Φ) (M : Φ , B ⊢ A) → sub (liftₛ {B} (σ₁ ● σ₂)) M ≡ (sub (liftₛ σ₁) ∘ sub (liftₛ σ₂)) M sublift● σ₁ σ₂ M = (λ σ′ → sub σ′ M) & lift● σ₁ σ₂ ⦙ sub● (liftₛ σ₁) (liftₛ σ₂) M subwk● : ∀ {Γ Ξ Φ A B} → (σ₁ : Γ ⊢⋆ Ξ) (σ₂ : Ξ ⊢⋆ Φ) (M : Φ ⊢ A) → sub (wkₛ {B} (σ₁ ● σ₂)) M ≡ (sub (wkₛ σ₁) ∘ sub σ₂) M subwk● σ₁ σ₂ M = (λ σ′ → sub σ′ M) & wk● σ₁ σ₂ ⦙ sub● (wkₛ σ₁) σ₂ M subliftwk● : ∀ {Γ Ξ Φ A B} → (σ₁ : Γ ⊢⋆ Ξ) (σ₂ : Ξ ⊢⋆ Φ) (M : Φ ⊢ A) → sub (wkₛ {B} (σ₁ ● σ₂)) M ≡ (sub (liftₛ σ₁) ∘ sub (wkₛ σ₂)) M subliftwk● σ₁ σ₂ M = (λ σ′ → sub σ′ M) & ( wk● σ₁ σ₂ ⦙ zap● (wkₛ σ₁) σ₂ 0 ⁻¹ ) ⦙ sub● (liftₛ σ₁) (wkₛ σ₂) M -------------------------------------------------------------------------------- comp◐○ : ∀ {Γ Ξ Ξ′ Ξ″} → (σ : Γ ⊢⋆ Ξ″) (η₁ : Ξ″ ∋⋆ Ξ′) (η₂ : Ξ′ ∋⋆ Ξ) → σ ◐ (η₁ ○ η₂) ≡ (σ ◐ η₁) ◐ η₂ comp◐○ σ η₁ ∅ = refl comp◐○ σ η₁ (η₂ , i) = _,_ & comp◐○ σ η₁ η₂ ⊗ (get◐ σ η₁ i ⁻¹) comp◑○ : ∀ {Γ Γ′ Γ″ Ξ} → (η₁ : Γ″ ∋⋆ Γ′) (η₂ : Γ′ ∋⋆ Γ) (σ : Γ ⊢⋆ Ξ) → η₁ ◑ (η₂ ◑ σ) ≡ (η₁ ○ η₂) ◑ σ comp◑○ η₁ η₂ ∅ = refl comp◑○ η₁ η₂ (σ , M) = _,_ & comp◑○ η₁ η₂ σ ⊗ ( sub● ⌊ η₁ ⌋ ⌊ η₂ ⌋ M ⁻¹ ⦙ (λ σ′ → sub σ′ M) & ⌊○⌋ η₁ η₂ ⁻¹ ) comp◑◐ : ∀ {Γ Γ′ Ξ Ξ′} → (η₁ : Γ′ ∋⋆ Γ) (σ : Γ ⊢⋆ Ξ′) (η₂ : Ξ′ ∋⋆ Ξ) → η₁ ◑ (σ ◐ η₂) ≡ (η₁ ◑ σ) ◐ η₂ comp◑◐ η₁ σ ∅ = refl comp◑◐ η₁ σ (η₂ , i) = _,_ & comp◑◐ η₁ σ η₂ ⊗ ( ⌊sub⌋ η₁ (getₛ σ i) ⦙ get◑ η₁ σ i ⁻¹ ) comp◑● : ∀ {Γ Γ′ Ξ Φ} → (η : Γ′ ∋⋆ Γ) (σ₁ : Γ ⊢⋆ Ξ) (σ₂ : Ξ ⊢⋆ Φ) → η ◑ (σ₁ ● σ₂) ≡ (η ◑ σ₁) ● σ₂ comp◑● η σ₁ ∅ = refl comp◑● η σ₁ (σ₂ , M) = _,_ & comp◑● η σ₁ σ₂ ⊗ (sub● ⌊ η ⌋ σ₁ M ⁻¹) comp●◐ : ∀ {Γ Ξ Φ Φ′} → (σ₁ : Γ ⊢⋆ Ξ) (σ₂ : Ξ ⊢⋆ Φ′) (η : Φ′ ∋⋆ Φ) → σ₁ ● (σ₂ ◐ η) ≡ (σ₁ ● σ₂) ◐ η comp●◐ σ₁ σ₂ ∅ = refl comp●◐ σ₁ σ₂ (η , i) = _,_ & comp●◐ σ₁ σ₂ η ⊗ (get● σ₁ σ₂ i ⁻¹) comp●◑ : ∀ {Γ Ξ Ξ′ Φ} → (σ₁ : Γ ⊢⋆ Ξ′) (η : Ξ′ ∋⋆ Ξ) (σ₂ : Ξ ⊢⋆ Φ) → σ₁ ● (η ◑ σ₂) ≡ (σ₁ ◐ η) ● σ₂ comp●◑ σ₁ η ∅ = refl comp●◑ σ₁ η (σ₂ , M) = _,_ & comp●◑ σ₁ η σ₂ ⊗ (sub● σ₁ ⌊ η ⌋ M ⁻¹) -------------------------------------------------------------------------------- assoc● : ∀ {Γ Ξ Φ Ψ} → (σ₁ : Γ ⊢⋆ Ξ) (σ₂ : Ξ ⊢⋆ Φ) (σ₃ : Φ ⊢⋆ Ψ) → σ₁ ● (σ₂ ● σ₃) ≡ (σ₁ ● σ₂) ● σ₃ assoc● σ₁ σ₂ ∅ = refl assoc● σ₁ σ₂ (σ₃ , M) = _,_ & assoc● σ₁ σ₂ σ₃ ⊗ (sub● σ₁ σ₂ M ⁻¹) -------------------------------------------------------------------------------- 𝗦𝗧𝗟𝗖 : Category 𝒞 _⊢⋆_ 𝗦𝗧𝗟𝗖 = record { idₓ = idₛ ; _⋄_ = flip _●_ ; lid⋄ = rid● ; rid⋄ = lid● ; assoc⋄ = assoc● } subPsh : 𝒯 → Presheaf₀ 𝗦𝗧𝗟𝗖 subPsh A = record { Fₓ = _⊢ A ; F = sub ; idF = fext! idsub ; F⋄ = λ σ₁ σ₂ → fext! (sub● σ₂ σ₁) } --------------------------------------------------------------------------------
{ "alphanum_fraction": 0.277955489, "avg_line_length": 31.5300429185, "ext": "agda", "hexsha": "374cba69cd7865a07d8118f9a2294b09084d61ab", "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": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/coquand-kovacs", "max_forks_repo_path": "src/STLC/Coquand/Substitution.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/coquand-kovacs", "max_issues_repo_path": "src/STLC/Coquand/Substitution.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/coquand-kovacs", "max_stars_repo_path": "src/STLC/Coquand/Substitution.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 7663, "size": 14693 }