Search is not available for this dataset
text
string
meta
dict
{- reported by Guillaume Brunerie on 2015-09-17 -} {-# OPTIONS --rewriting #-} data _==_ {A : Set} (a : A) : A → Set where idp : a == a {-# BUILTIN REWRITE _==_ #-} postulate A B : Set f g : A → B module M (x : A) where postulate rx : f x == g x {-# REWRITE rx #-} -- This shouldn't work test : (y : A) → f y == g y test y = idp
{ "alphanum_fraction": 0.5211267606, "avg_line_length": 16.1363636364, "ext": "agda", "hexsha": "123c0ad00c7eca54f9ad055ba6cb39860ce69eca", "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/Issue1652.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/Issue1652.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/Fail/Issue1652.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": 135, "size": 355 }
module NF {A : Set} where open import Relation.Binary.PropositionalEquality record Sing (a : A) : Set where field unpack : A eq : unpack ≡ a {-# INLINE Sing.unpack #-} record NF (v : A) : Set where field !! : Sing v {-# INLINE NF.!! #-} open NF {{...}} open import Function.Reasoning nf : (v : A){{nfv : NF v}} -> A nf v = Sing.unpack (!! ∶ Sing v) {-# INLINE nf #-} nf≡ : {v : A}{{nfv : NF v}} -> nf v ≡ v nf≡ = Sing.eq !!
{ "alphanum_fraction": 0.5550561798, "avg_line_length": 16.4814814815, "ext": "agda", "hexsha": "0529ab1028f7dd656462f8a386b6e08e65d89895", "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": "4f037dad109a5d080023557f0869418ed9fc11c1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "yanok/normalize-via-instances", "max_forks_repo_path": "src/NF.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4f037dad109a5d080023557f0869418ed9fc11c1", "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": "yanok/normalize-via-instances", "max_issues_repo_path": "src/NF.agda", "max_line_length": 49, "max_stars_count": null, "max_stars_repo_head_hexsha": "4f037dad109a5d080023557f0869418ed9fc11c1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yanok/normalize-via-instances", "max_stars_repo_path": "src/NF.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 148, "size": 445 }
{-# OPTIONS --without-K --safe #-} module Categories.Functor.Construction.Constant where open import Level open import Categories.Category open import Categories.Category.Instance.One open import Categories.Category.Product open import Categories.Functor renaming (id to idF) open import Categories.NaturalTransformation using (NaturalTransformation; ntHelper) import Categories.Morphism.Reasoning as MR private variable o ℓ e : Level C D : Category o ℓ e const : (d : Category.Obj D) → Functor C D const {D = D} d = record { F₀ = λ _ → d ; F₁ = λ _ → id ; identity = refl ; homomorphism = sym identity² ; F-resp-≈ = λ _ → refl } where open Category D open Equiv const! : (d : Category.Obj D) → Functor (One {0ℓ} {0ℓ} {0ℓ}) D const! = const constˡ : (c : Category.Obj C) → Functor D (Product C D) constˡ c = const c ※ idF constʳ : (c : Category.Obj C) → Functor D (Product D C) constʳ c = idF ※ (const c) constNat : ∀ {A B} → Category._⇒_ D A B → NaturalTransformation (const {D = D} {C = C} A) (const B) constNat {D = D} f = ntHelper record { η = λ _ → f ; commute = λ _ → MR.id-comm D }
{ "alphanum_fraction": 0.6467065868, "avg_line_length": 27.1860465116, "ext": "agda", "hexsha": "288d40ce30e85626b9fd10d6b73f5123bf9178e8", "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/Functor/Construction/Constant.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/Functor/Construction/Constant.agda", "max_line_length": 99, "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/Functor/Construction/Constant.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 365, "size": 1169 }
module Structure.Relator.Equivalence where import Lvl open import Logic open import Logic.Propositional open import Structure.Relator.Properties hiding (reflexivity ; symmetry ; transitivity) open import Type private variable ℓ₁ ℓ₂ : Lvl.Level -- An equivalence relation is a reflexive, symmetric and transitive relation. record Equivalence {T : Type{ℓ₁}} (_≡_ : T → T → Stmt{ℓ₂}) : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where instance constructor intro field instance ⦃ reflexivity ⦄ : Reflexivity (_≡_) instance ⦃ symmetry ⦄ : Symmetry (_≡_) instance ⦃ transitivity ⦄ : Transitivity (_≡_)
{ "alphanum_fraction": 0.7215815486, "avg_line_length": 31.9473684211, "ext": "agda", "hexsha": "7b138d80ed317ddc532ac511f7d6bdf50fb2b9d3", "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/Relator/Equivalence.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/Relator/Equivalence.agda", "max_line_length": 84, "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/Relator/Equivalence.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": 182, "size": 607 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import groups.Exactness open import homotopy.CofiberSequence open import cohomology.Theory {- Finite additivity is provable (and in a stronger form) without using - the additivity axiom. We have Cⁿ(X ∨ Y) == Cⁿ(X) × Cⁿ(Y) - and over this path - ∙ Cⁿ(winl) corresponds to fst : Cⁿ(X) × Cⁿ(Y) → Cⁿ(X), - ∙ Cⁿ(winr) corresponds to snd : Cⁿ(X) × Cⁿ(Y) → Cⁿ(Y), - ∙ Cⁿ(Wedge-rec winl* winr* wglue*) : Cⁿ(Z) → Cⁿ(X ∨ Y) corresponds to Cⁿ(winl*) × Cⁿ(winr*). - ∙ Cⁿ(f) : Cⁿ(X ∨ Y) → Cⁿ(Z) corresponds to Cⁿ(projl ∘ f) + Cⁿ(projr ∘ f) : Cⁿ(X) × Cⁿ(Y) → Cⁿ(Z) -} module cohomology.Wedge {i} (CT : CohomologyTheory i) (n : ℤ) (X Y : Ptd i) where open import homotopy.WedgeCofiber X Y open CohomologyTheory CT open import cohomology.PtdMapSequence CT private abstract βl : ∀ x → CEl-fmap n ⊙winl (CEl-fmap n (⊙projl X Y) x) == x βl = CEl-fmap-inverse n ⊙winl (⊙projl X Y) λ _ → idp βr : ∀ y → CEl-fmap n ⊙winr (CEl-fmap n (⊙projr X Y) y) == y βr = CEl-fmap-inverse n ⊙winr (⊙projr X Y) λ _ → idp C-projr-C-winl-is-exact : is-exact (C-fmap n (⊙projr X Y)) (C-fmap n ⊙winl) C-projr-C-winl-is-exact = equiv-preserves'-exact (C-comm-square n cfcod-winl-projr-comm-sqr) (C-comm-square n $ comm-sqr λ _ → idp) (snd (C-emap n CofWinl.⊙eq)) (C-isemap n (⊙idf _) (idf-is-equiv _)) (C-isemap n (⊙idf _) (idf-is-equiv _)) (C-exact n ⊙winl) C-projl-C-winr-is-exact : is-exact (C-fmap n (⊙projl X Y)) (C-fmap n ⊙winr) C-projl-C-winr-is-exact = equiv-preserves'-exact (C-comm-square n cfcod-winr-projl-comm-sqr) (C-comm-square n $ comm-sqr λ _ → idp) (snd (C-emap n CofWinr.⊙eq)) (C-isemap n (⊙idf _) (idf-is-equiv _)) (C-isemap n (⊙idf _) (idf-is-equiv _)) (C-exact n ⊙winr) import groups.ProductRepr (C-fmap n (⊙projl X Y)) (C-fmap n (⊙projr X Y)) (C-fmap n ⊙winl) (C-fmap n ⊙winr) βl βr C-projl-C-winr-is-exact C-projr-C-winl-is-exact as PR C-Wedge : C n (X ⊙∨ Y) ≃ᴳ C n X ×ᴳ C n Y C-Wedge = PR.iso {- ⊙Wedge-rec-over : {Z : Ptd i} (winl* : X ⊙→ Z) (winr* : Y ⊙→ Z) → CF-hom n (⊙Wedge-rec winl* winr*) == ×ᴳ-fanout (CF-hom n winl*) (CF-hom n (winr*)) [ (λ K → C n Z →ᴳ K) ↓ path ] ⊙Wedge-rec-over winl* winr* = codomain-over-iso $ codomain-over-equiv (CF n R.⊙f) _ ▹ ap2 (λ f g z → (f z , g z)) (ap GroupHom.f $ ! (CF-comp n R.⊙f ⊙winl) ∙ ap (CF-hom n) R.⊙winl-β) (ap GroupHom.f $ ! (CF-comp n R.⊙f ⊙winr) ∙ ap (CF-hom n) R.⊙winr-β) where module R = ⊙WedgeRec winl* winr* Wedge-hom-η : {Z : Ptd i} (φ : C n (⊙Wedge X Y) →ᴳ C n Z) → φ == ×ᴳ-fanin (C-is-abelian n _) (φ ∘ᴳ CF-hom n (⊙projl X Y)) (φ ∘ᴳ CF-hom n (⊙projr X Y)) [ (λ G → G →ᴳ C n Z) ↓ path ] Wedge-hom-η φ = lemma (C-is-abelian n _) (C-is-abelian n _) inl-over inr-over where lemma : {G H K L : Group i} (aG : is-abelian G) (aL : is-abelian L) {p : G == H ×ᴳ K} {φ : H →ᴳ G} {ψ : K →ᴳ G} {χ : G →ᴳ L} → φ == ×ᴳ-inl [ (λ J → H →ᴳ J) ↓ p ] → ψ == ×ᴳ-inr {G = H} [ (λ J → K →ᴳ J) ↓ p ] → χ == ×ᴳ-fanin aL (χ ∘ᴳ φ) (χ ∘ᴳ ψ) [ (λ J → J →ᴳ L) ↓ p ] lemma {H = H} {K = K} aG aL {p = idp} {χ = χ} idp idp = ap (λ α → χ ∘ᴳ α) (×ᴳ-fanin-η H K aG) ∙ ! (×ᴳ-fanin-pre∘ aG aL χ (×ᴳ-inl {G = H}) (×ᴳ-inr {G = H})) Wedge-in-over : {Z : Ptd i} (f : Z ⊙→ ⊙Wedge X Y) → CF-hom n f == ×ᴳ-fanin (C-is-abelian n _) (CF-hom n (⊙projl X Y ⊙∘ f)) (CF-hom n (⊙projr X Y ⊙∘ f)) [ (λ G → G →ᴳ C n Z) ↓ path ] Wedge-in-over f = Wedge-hom-η (CF-hom n f) ▹ ap2 (×ᴳ-fanin (C-is-abelian n _)) (! (CF-comp n (⊙projl X Y) f)) (! (CF-comp n (⊙projr X Y) f)) -}
{ "alphanum_fraction": 0.5125383828, "avg_line_length": 36.8679245283, "ext": "agda", "hexsha": "b77974f2c3b92a391977860d36f45a34192d30a5", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "theorems/cohomology/Wedge.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "theorems/cohomology/Wedge.agda", "max_line_length": 81, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "theorems/cohomology/Wedge.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1796, "size": 3908 }
-- Test case extracted from The Agda standard library -- Properties related to Any {-# OPTIONS --show-implicit #-} module ProjectionNotNormalized where open import Common.Level renaming (lsuc to suc) record Setoid c ℓ : Set (suc (c ⊔ ℓ)) where infix 4 _≈_ field Carrier : Set c _≈_ : Carrier → Carrier → Set ℓ refl : ∀ {x} → x ≈ x open import Common.Equality setoid : ∀ {a} → Set a → Setoid _ _ setoid A = record { Carrier = A ; _≈_ = _≡_ ; refl = refl } infixr 4 _,_ record Σ {a b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where constructor _,_ field proj₁ : A proj₂ : B proj₁ open Σ public ∃ : ∀ {a b} {A : Set a} → (A → Set b) → Set (a ⊔ b) ∃ = Σ _ pmap : ∀ {a b p q} {A : Set a} {B : Set b} {P : A → Set p} {Q : B → Set q} → (f : A → B) → (∀ {x} → P x → Q (f x)) → Σ A P → Σ B Q pmap f g (x , y) = (f x , g y) data List {a} (A : Set a) : Set a where [] : List A _∷_ : (x : A) (xs : List A) → List A -- Any P xs means that at least one element in xs satisfies P. data Any {a p} {A : Set a} (P : A → Set p) : List A → Set (a ⊔ p) where here : ∀ {x xs} (px : P x) → Any P (x ∷ xs) there : ∀ {x xs} (pxs : Any P xs) → Any P (x ∷ xs) -- Map. map : ∀ {a p q} {A : Set a} {P : A → Set p} → {Q : A → Set q} → (∀ {x} → P x → Q x) → ∀ {x} → Any P x → Any Q x map g (here px) = here (g px) map g (there pxs) = there (map g pxs) ------------------------------------------------------------------------ -- List membership and some related definitions module Membership {c ℓ : Level} (S : Setoid c ℓ) where open module S = Setoid S using (_≈_) renaming (Carrier to A) -- List membership. infix 4 _∈_ _∈_ : A → List A → Set _ x ∈ xs = Any (_≈_ x) xs -- Finds an element satisfying the predicate. find : ∀ {p} {P : A → Set p} {xs} → Any P xs → ∃ λ x → Σ (x ∈ xs) λ _ → P x find (here px) = (_ , here S.refl , px) find (there pxs) = pmap (λ x → x) (pmap there (λ x → x)) (find pxs) lose : ∀ {p} {P : A → Set p} {x xs} → (resp : ∀ {x y} → x ≈ y → P x → P y) → x ∈ xs → P x → Any P xs lose resp x∈xs px = map (λ eq → resp eq px) x∈xs -- The code above instantiated (and slightly changed) for -- propositional equality, along with some additional definitions. open module M {a} {A : Set a} = Membership (setoid A) hiding (lose) lose : ∀ {a p} {A : Set a} {P : A → Set p} {x xs} → x ∈ xs → P x → Any P xs lose {P = P} = M.lose (subst P) ------------------------------------------------------------------------ -- Some lemmas related to map, find and lose -- Lemmas relating map and find. find∘map : ∀ {a p q} {A : Set a} {P : A → Set p} {Q : A → Set q} {xs : List A} (p : Any P xs) (f : ∀ {x} → P x → Q x) → find (map f p) ≡ pmap (λ x → x) (pmap (λ x → x) f) (find p) find∘map (here p) f = refl find∘map (there p) f rewrite find∘map p f = refl -- find satisfies a simple equality when the predicate is a -- propositional equality. find-∈ : ∀ {a} {A : Set a} {x : A} {xs : List A} (x∈xs : x ∈ xs) → find x∈xs ≡ (x , x∈xs , refl) find-∈ (here refl) = refl find-∈ (there x∈xs) rewrite find-∈ x∈xs = refl -- find and lose are inverses (more or less). {- find∘lose : ∀ {a p} {A : Set a} (P : A → Set p) {x : {!!}} {xs : List {!!}} (x∈xs : x ∈ xs) (pp : P x) → find {P = P} (lose x∈xs pp) ≡ (x , x∈xs , pp) find∘lose P x∈xs p = {!!} -} find∘lose : ∀ {a p} {A : Set a} (P : A → Set p) {x : _} {xs : _} (x∈xs : x ∈ xs) (pp : P x) → find {P = P} (lose x∈xs pp) ≡ (x , x∈xs , pp) find∘lose P x∈xs p rewrite find∘map x∈xs (λ y → subst P y p) | find-∈ x∈xs = refl {- Problem WAS: applySection new = ProjectionNotNormalized.Membership.S ptel = EmptyTel old = ProjectionNotNormalized.Setoid ts = [[]r{Var 2 []},[]r{Var 1 []},[]r(Var 0 [])] S.refl : {c ℓ : Level} (S : Setoid c ℓ) {x : Setoid.Carrier S} → (S Setoid.≈ x) x is projection like in argument 2 for type ProjectionNotNormalized.Setoid A : {c ℓ : Level} (S : Setoid c ℓ) → Set c is projection like in argument 2 for type ProjectionNotNormalized.Setoid _≈_ : {c ℓ : Level} (S : Setoid c ℓ) → Setoid.Carrier S → Setoid.Carrier S → Set ℓ is projection like in argument 2 for type ProjectionNotNormalized.Setoid applySection new = ProjectionNotNormalized.M ptel = ExtendTel []r{El {getSort = Type (Max [Plus 0 (MetaLevel _224 [])]), unEl = MetaV _225 []}} (Abs "a" ExtendTel []r{El {getSort = Type (Max [Plus 1 (NeutralLevel (Var 0 []))]), unEl = Sort (Type (Max [Plus 0 (NeutralLevel (Var 0 []))]))}} (Abs "A" EmptyTel)) old = ProjectionNotNormalized.Membership ts = [[]r{Var 1 []},[]r{Var 1 []},[]r(Def ProjectionNotNormalized.setoid [Apply []r{Var 1 []},Apply []r(Var 0 [])])] conApp: constructor ProjectionNotNormalized.recCon-NOT-PRINTED with fields [ProjectionNotNormalized.Setoid.Carrier,ProjectionNotNormalized.Setoid._≈_,ProjectionNotNormalized.Setoid.refl] projected by ProjectionNotNormalized.Membership.S.Carrier An internal error has occurred. Please report this as a bug. Location of the error: src/full/Agda/TypeChecking/Substitute.hs:82 -}
{ "alphanum_fraction": 0.5426136364, "avg_line_length": 32.7950310559, "ext": "agda", "hexsha": "f30f292ca62be3f55bd6a56d296a4d8e04f6568c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/ProjectionNotNormalized.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/ProjectionNotNormalized.agda", "max_line_length": 264, "max_stars_count": 1, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/succeed/ProjectionNotNormalized.agda", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "num_tokens": 1921, "size": 5280 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.ImplShared.Consensus.Types.EpochIndep open import Optics.All open import Util.ByteString open import Util.Encode open import Util.Hash open import Util.Lemmas open import Util.PKCS open import Util.Prelude -- This module postulates a collision-resistant cryptographic hash -- function (we call it sha256 for concreteness, but it could be any -- collision-resistant cryptographic hash function), and defines hash -- functions used in (an earlier version of) LibraBFT, properties -- about it, and how Votes and Blocks are signed. module LibraBFT.ImplShared.Util.Crypto where -- Note that this is an abstraction of a hash function. It could be any such hash function, not -- necessarily sha256. We just call it sha256 for "concreteness", to remind ourselves it's -- modeling such a function. postulate -- valid assumption (hash function) sha256 : BitString → Hash -- For two values x and y, if their hashes are equal, then either there is a hash collision, or x -- and y are equal. sha256-cr : ∀{x y} → sha256 x ≡ sha256 y → Collision sha256 x y ⊎ x ≡ y sha256-cr {x} {y} hyp with x ≟BitString y ...| no col = inj₁ (col , hyp) ...| yes refl = inj₂ refl open WithCryptoHash sha256 sha256-cr -- We do not yet have sufficient support to model precisely the hashing used in the Haskell code, -- so it is better that we postulate its intended properties to ensure proofs have the desired -- properties available. Note that a simpler injectivity property such as -- -- hashBD-inj' : ∀ {bd1} {bd2} -- → hashBD bd1 ≡ hashBD bd2 -- → NonInjective-≡ sha256 -- ⊎ bd1 ≡L bd2 -- -- does *not* hold because the input to the hash function used in hashBD does *not* include all -- components of the BlockData being hashed. -- TODO-2: Similarly express other hashing functions and their intended injectivity properties where -- the Agda implementation does not accurately reflect the Haskell implementation. -- TODO-2: Enable support for the hashS function we use in the Haskell code, which hashes tuples -- of serializable types), and then define hashBD using this and prove that it ensures hashBD-inj. -- Note also the TODO below related to HashTags. record _BlockDataInjectivityProps_ (bd1 bd2 : BlockData) : Set where constructor mkBdInjProps field bdInjEpoch : bd1 ≡L bd2 at bdEpoch bdInjRound : bd1 ≡L bd2 at bdRound bdInjVD : bd1 ≡L bd2 at (bdQuorumCert ∙ qcVoteData) bdInjLI : bd1 ≡L bd2 at (bdQuorumCert ∙ qcSignedLedgerInfo ∙ liwsLedgerInfo) bdInjBTNil : bd1 ^∙ bdBlockType ≡ NilBlock → bd2 ^∙ bdBlockType ≡ NilBlock bdInjBTGen : bd1 ^∙ bdBlockType ≡ Genesis → bd2 ^∙ bdBlockType ≡ Genesis bdInjBTProp : ∀ {tx}{auth} → bd1 ^∙ bdBlockType ≡ Proposal tx auth → bd1 ^∙ bdBlockType ≡ bd2 ^∙ bdBlockType open _BlockDataInjectivityProps_ sameBlockData⇒≈ : ∀ {b1 b2} → b1 ^∙ bId ≡ b2 ^∙ bId → (b1 ^∙ bBlockData) BlockDataInjectivityProps (b2 ^∙ bBlockData) → b1 ≈Block b2 sameBlockData⇒≈ {b1} {b2} refl (mkBdInjProps refl refl refl refl nil gen prop) with b1 ^∙ bBlockData ∙ bdBlockType ...| NilBlock rewrite nil refl = refl ...| Genesis rewrite gen refl = refl ...| Proposal tx auth rewrite prop refl = refl BSL : Set BSL = List ByteString _≟-BSL_ : ∀ (bsl1 bsl2 : List ByteString) → Dec (bsl1 ≡ bsl2) _≟-BSL_ = List-≡-dec _≟ByteString_ hashBSL = sha256 ∘ bs-concat postulate -- TODO-2: implement after adding support for "HashTag" (see below) blockData-bsl : BlockData → List ByteString hashBD : BlockData → HashValue hashBD = hashBSL ∘ blockData-bsl Injective-BlockData : Set Injective-BlockData = Injective-int _BlockDataInjectivityProps_ hashBSL blockData-bsl blockData-bsl postulate -- TODO-1: prove it using bs-concat-inj hashBD-inj : Injective-BlockData hashBlock : Block → HashValue hashBlock = hashBD ∘ (_^∙ bBlockData) blockInfoBSList : BlockInfo → List ByteString blockInfoBSList (BlockInfo∙new epoch round id execStId ver mes) = encode epoch ∷ encode round ∷ encode id ∷ encode execStId ∷ encode ver ∷ encode mes ∷ [] hashBI : BlockInfo → HashValue hashBI = sha256 ∘ bs-concat ∘ blockInfoBSList hashBI-inj : ∀ {bi1 bi2} → hashBI bi1 ≡ hashBI bi2 → NonInjective-≡ sha256 ⊎ bi1 ≡ bi2 hashBI-inj {bi1} {bi2} hyp with sha256-cr hyp ...| inj₁ col = inj₁ (_ , col) ...| inj₂ res with bs-concat-inj (blockInfoBSList bi1) (blockInfoBSList bi2) res ...| final = inj₂ (BlockInfo-η (encode-inj (proj₁ (∷-injective final))) (encode-inj (proj₁ (∷-injective (proj₂ (∷-injective final))))) (encode-inj (proj₁ (∷-injective (proj₂ (∷-injective (proj₂ (∷-injective final))))))) (encode-inj (proj₁ (∷-injective (proj₂ (∷-injective (proj₂ (∷-injective (proj₂ (∷-injective final))))))))) (encode-inj (proj₁ (∷-injective (proj₂ (∷-injective (proj₂ (∷-injective (proj₂ (∷-injective (proj₂ (∷-injective final))))))))))) (encode-inj (proj₁ (∷-injective (proj₂ (∷-injective (proj₂ (∷-injective (proj₂ (∷-injective (proj₂ (∷-injective (proj₂ (∷-injective final)))))))))))))) voteDataHashList : VoteData → List Hash voteDataHashList (VoteData∙new proposed parent) = hProposed ∷ hParent ∷ [] where hProposed = hashBI proposed hParent = hashBI parent hashVD : VoteData → HashValue hashVD = hash-concat ∘ voteDataHashList VoteData-≢-eid : ∀ {vd1 vd2 : VoteData} → vd1 ^∙ vdProposed ∙ biEpoch ≢ vd2 ^∙ vdProposed ∙ biEpoch → vd1 ≢ vd2 VoteData-≢-eid neq = λ x → neq (cong (_^∙ vdProposed ∙ biEpoch) x) VoteData-hb : ∀ {vd1 vd2 : VoteData} → vd1 ^∙ vdProposed ∙ biEpoch ≢ vd2 ^∙ vdProposed ∙ biEpoch → hashVD vd1 ≡ hashVD vd2 → NonInjective-≡ sha256 VoteData-hb {vd1} {vd2} neq hvd≡ with hash-concat-inj {voteDataHashList vd1} {voteDataHashList vd2} hvd≡ ...| inj₁ hb = hb ...| inj₂ xxx with cong head xxx ...| yyy with cong tail xxx ...| yyy' with cong head (just-injective yyy') ...| yyy'' with just-injective yyy | just-injective yyy'' ...| zzz | zzz' with hashBI-inj {vd1 ^∙ vdProposed} {vd2 ^∙ vdProposed} zzz | hashBI-inj {vd1 ^∙ vdParent} {vd2 ^∙ vdParent} zzz' ...| inj₁ hb | _ = hb ...| inj₂ _ | inj₁ hb = hb ...| inj₂ aaa | inj₂ aaa' = ⊥-elim (VoteData-≢-eid {vd1} {vd2} neq (VoteData-η aaa aaa')) hashVD-inj : ∀ {vd1 vd2} → hashVD vd1 ≡ hashVD vd2 → NonInjective-≡ sha256 ⊎ vd1 ≡ vd2 hashVD-inj {vd1} {vd2} prf with hash-concat-inj {voteDataHashList vd1} {voteDataHashList vd2} prf ...| inj₁ hb = inj₁ hb ...| inj₂ vdLists≡ with hashBI-inj (proj₁ (∷-injective vdLists≡)) | hashBI-inj (proj₁ (∷-injective (proj₂ (∷-injective vdLists≡)))) ...| inj₁ hb | _ = inj₁ hb ...| inj₂ _ | inj₁ hb = inj₁ hb ...| inj₂ prop≡ | inj₂ par≡ = inj₂ (VoteData-η prop≡ par≡) -- The Haskell implementation includes "HashTag"s when hashing in order to ensure that it is not -- possible (modulo hash collisions) for the encodings of two values of different types (e.g., -- Vote and Block) to yield the same bitstring and thus the same hash (and therefore potentially -- the same signature, where hashes are signed). For example, the Haskell hashLI function is: -- -- hashLI :: LedgerInfo -> HashValue -- hashLI (LedgerInfo commitInfo (HashValue consensusDataHash)) = -- hashS (HLI, biParts commitInfo, consensusDataHash) -- -- Note the HashTag HLI, which is not yet reflected in the Agda implementation. -- TODO-2: include HashTags in hash functions, consistent with the Haskell code. -- -- As an aside, it is not clear whether these HashTags are necessary for all of the "inner" -- hashes. They are needed to ensure that, for example, a dishonest peer cannot notice that the -- bits signed for a Vote happen to decode to a valid Block, and therefore take a Vote signature -- and use it to masquerade as a Block signture. However, the implementation does include -- HashTags at each level, so we should too unless and until that changes. hashLI : LedgerInfo → HashValue hashLI (LedgerInfo∙new commitInfo consensusDataHash) = hash-concat (hashBI commitInfo ∷ consensusDataHash ∷ []) hashLI-inj : ∀ {li1 li2} → hashLI li1 ≡ hashLI li2 → NonInjective-≡ sha256 ⊎ li1 ≡ li2 hashLI-inj {LedgerInfo∙new ci1 cd1} {LedgerInfo∙new ci2 cd2} prf with hash-concat-inj {hashBI ci1 ∷ cd1 ∷ []} {hashBI ci2 ∷ cd2 ∷ []} prf ...| inj₁ hb = inj₁ hb ...| inj₂ li1≡li2 with ∷-injective li1≡li2 ...| ci≡ , rest≡ with ∷-injective rest≡ ...| cdh≡ , _ with hashBI-inj ci≡ ...| inj₁ hb = inj₁ hb ...| inj₂ cis≡ = inj₂ (LedgerInfo-η cis≡ cdh≡) record Ledger2WaypointConverterInjectivityProps (l1 l2 : Ledger2WaypointConverter) : Set where {- TODO-2 : implement Ledger2WaypointConverterInjectivityProps field l2wcInjEpoch : ? l2wcInjRootHash : ? l2wcInjVersion : ? --timestamp l2wcInjNextEpochState : ? -} postulate -- TODO-2: prove after defining Ledger2WaypointConverterInjectivityProps hashL2WC : Ledger2WaypointConverter → HashValue hashL2WC-inj : ∀ {l1 l2} → hashL2WC l1 ≡ hashL2WC l2 → NonInjective-≡ sha256 ⊎ Ledger2WaypointConverterInjectivityProps l1 l2 constructLI : Vote → LedgerInfo constructLI v = LedgerInfo∙new (_liCommitInfo (_vLedgerInfo v)) (hashVD (_vVoteData v)) hashVote : Vote → HashValue hashVote = hashLI ∘ constructLI hashVote-inj1 : ∀ {v1 v2} → hashVote v1 ≡ hashVote v2 → NonInjective-≡ sha256 ⊎ _vVoteData v1 ≡ _vVoteData v2 hashVote-inj1 {v1} {v2} hyp with hashLI-inj {constructLI v1} {constructLI v2} hyp ...| inj₁ hb = inj₁ hb ...| inj₂ ok = hashVD-inj {_vVoteData v1} {_vVoteData v2} (cong _liConsensusDataHash ok) -- A vote is always signed; as seen by the 'Unit' -- in the definition of Signed. instance sig-Vote : WithSig Vote sig-Vote = record { Signed = λ _ → Unit ; Signed-pi = λ _ _ _ → Unit-pi ; isSigned? = λ _ → yes unit ; signature = λ v _ → _vSignature v ; signableFields = encodeH ∘ hashVote } sameSig⇒sameVoteData : ∀ {v1 v2 : Vote} {pk} → WithVerSig pk v1 → WithVerSig pk v2 → v1 ^∙ vSignature ≡ v2 ^∙ vSignature → NonInjective-≡ sha256 ⊎ v2 ^∙ vVoteData ≡ v1 ^∙ vVoteData sameSig⇒sameVoteData {v1} {v2} wvs1 wvs2 refl with verify-bs-inj (verified wvs1) (verified wvs2) -- The signable fields of the votes must be the same (we do not model signature collisions) ...| bs≡ -- Therefore the LedgerInfo is the same for the new vote as for the previous vote = sym <⊎$> (hashVote-inj1 {v1} {v2} (sameBS⇒sameHash bs≡)) -- Captures a proof that a vote was cast by α by recording that 'verify' returns true. VoteSigVerifies : PK → Vote → Set VoteSigVerifies pk v = T (verify (signableFields ⦃ sig-Vote ⦄ v) (_vSignature v) pk) Signed-pi-Blk : (b : Block) → (is1 is2 : (Is-just ∘ _bSignature) b) → is1 ≡ is2 Signed-pi-Blk (Block∙new _ _ .(just _)) (just _) (just _) = cong just refl -- A Block might carry a signature instance sig-Block : WithSig Block sig-Block = record { Signed = Is-just ∘ _bSignature ; Signed-pi = Signed-pi-Blk ; isSigned? = λ b → Maybe-Any-dec (λ _ → yes tt) (b ^∙ bSignature) ; signature = λ { _ prf → to-witness prf } ; signableFields = λ b → concat (encodeH (_bId b) ∷ encode (b ^∙ bBlockData) ∷ []) }
{ "alphanum_fraction": 0.6431879113, "avg_line_length": 44.76, "ext": "agda", "hexsha": "bfdb64ffc7bb8e1de44a719ec8f52c2ac8e8d909", "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/ImplShared/Util/Crypto.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/ImplShared/Util/Crypto.agda", "max_line_length": 184, "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/ImplShared/Util/Crypto.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3972, "size": 12309 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Diagram.Pullback.Properties {o ℓ e} (C : Category o ℓ e) where open import Function using (_$_) open import Categories.Category.BinaryProducts C open import Categories.Category.Cartesian C open import Categories.Diagram.Pullback C open import Categories.Diagram.Equalizer C hiding (up-to-iso) open import Categories.Object.Product C hiding (up-to-iso) open import Categories.Object.Terminal C hiding (up-to-iso) open import Categories.Morphism C open import Categories.Morphism.Reasoning C open import Categories.Category.Complete.Finitely using (FinitelyComplete) open import Data.Product using (∃; _,_) private open Category C variable X Y Z : Obj f g h i : X ⇒ Y open HomReasoning open Equiv -- pullbacks of a monomorphism along itself give us the identity arrow. pullback-self-mono : Mono f → IsPullback id id f f pullback-self-mono mono = record { commute = refl ; universal = λ {X} {h₁} {h₂} eq → h₁ ; unique = λ id∘i≈h₁ _ → ⟺ identityˡ ○ id∘i≈h₁ ; p₁∘universal≈h₁ = identityˡ ; p₂∘universal≈h₂ = λ {X} {h₁} {h₂} {eq} → identityˡ ○ mono h₁ h₂ eq } -- pullback from a terminal object is the same as a product module _ (t : Terminal) where open Terminal t pullback-⊤⇒product : Pullback (! {X}) (! {Y}) → Product X Y pullback-⊤⇒product p = record { A×B = P ; π₁ = p₁ ; π₂ = p₂ ; ⟨_,_⟩ = λ f g → universal (!-unique₂ {f = ! ∘ f} {g = ! ∘ g}) ; project₁ = p₁∘universal≈h₁ ; project₂ = p₂∘universal≈h₂ ; unique = λ eq eq′ → ⟺ (unique eq eq′) } where open Pullback p product⇒pullback-⊤ : Product X Y → Pullback (! {X}) (! {Y}) product⇒pullback-⊤ p = record { p₁ = π₁ ; p₂ = π₂ ; isPullback = record { commute = !-unique₂ ; universal = λ {_ f g} _ → ⟨ f , g ⟩ ; unique = λ eq eq′ → ⟺ (unique eq eq′) ; p₁∘universal≈h₁ = project₁ ; p₂∘universal≈h₂ = project₂ } } where open Product p -- pullbacks respect _≈_ module _ (p : Pullback f g) where open Pullback p pullback-resp-≈ : f ≈ h → g ≈ i → Pullback h i pullback-resp-≈ eq eq′ = record { p₁ = p₁ ; p₂ = p₂ ; isPullback = record { commute = ∘-resp-≈ˡ (⟺ eq) ○ commute ○ ∘-resp-≈ˡ eq′ ; universal = λ eq″ → universal (∘-resp-≈ˡ eq ○ eq″ ○ ∘-resp-≈ˡ (⟺ eq′)) ; unique = unique ; p₁∘universal≈h₁ = p₁∘universal≈h₁ ; p₂∘universal≈h₂ = p₂∘universal≈h₂ } } -- Some facts about pulling back along identity module _ (p : Pullback id f) where open Pullback p -- This is a more subtle way of saying that 'p₂ ≈ id', without involving heterogenous equality. pullback-identity : universal id-comm-sym ∘ p₂ ≈ id pullback-identity = begin universal Basic.id-comm-sym ∘ p₂ ≈⟨ unique ( pullˡ p₁∘universal≈h₁ ) (pullˡ p₂∘universal≈h₂) ⟩ universal eq ≈⟨ universal-resp-≈ (⟺ commute ○ identityˡ) identityˡ ⟩ universal commute ≈˘⟨ Pullback.id-unique p ⟩ id ∎ where eq : id ∘ f ∘ p₂ ≈ f ∘ id ∘ p₂ eq = begin (id ∘ f ∘ p₂) ≈⟨ elimˡ Equiv.refl ⟩ (f ∘ p₂) ≈˘⟨ refl⟩∘⟨ identityˡ ⟩ (f ∘ id ∘ p₂) ∎ -- pullbacks in Cartesian categories create equalizers module _ (pullbacks : ∀ {X Y Z} (f : X ⇒ Z) (g : Y ⇒ Z) → Pullback f g) (cartesian : Cartesian) where open Cartesian cartesian open BinaryProducts products using (⟨_,_⟩; π₁; π₂; ⟨⟩-cong₂; ⟨⟩∘; project₁; project₂) pullback×cartesian⇒equalizer : Equalizer f g pullback×cartesian⇒equalizer {f = f} {g = g} = record { arr = p.p₁ ; isEqualizer = record { equality = equality ; equalize = λ {_ h} eq → p.universal $ begin ⟨ f , g ⟩ ∘ h ≈⟨ ⟨⟩∘ ⟩ ⟨ f ∘ h , g ∘ h ⟩ ≈˘⟨ ⟨⟩-cong₂ identityˡ (identityˡ ○ eq) ⟩ ⟨ id ∘ f ∘ h , id ∘ f ∘ h ⟩ ≈˘⟨ ⟨⟩∘ ⟩ ⟨ id , id ⟩ ∘ f ∘ h ∎ ; universal = ⟺ p.p₁∘universal≈h₁ ; unique = λ eq → p.unique (⟺ eq) (⟺ (pullˡ eq′) ○ ⟺ (∘-resp-≈ʳ eq)) } } where p : Pullback ⟨ f , g ⟩ ⟨ id , id ⟩ p = pullbacks _ _ module p = Pullback p eq : ⟨ f ∘ p.p₁ , g ∘ p.p₁ ⟩ ≈ ⟨ p.p₂ , p.p₂ ⟩ eq = begin ⟨ f ∘ p.p₁ , g ∘ p.p₁ ⟩ ≈˘⟨ ⟨⟩∘ ⟩ ⟨ f , g ⟩ ∘ p.p₁ ≈⟨ p.commute ⟩ ⟨ id , id ⟩ ∘ p.p₂ ≈⟨ ⟨⟩∘ ⟩ ⟨ id ∘ p.p₂ , id ∘ p.p₂ ⟩ ≈⟨ ⟨⟩-cong₂ identityˡ identityˡ ⟩ ⟨ p.p₂ , p.p₂ ⟩ ∎ eq′ : f ∘ p.p₁ ≈ p.p₂ eq′ = begin f ∘ p.p₁ ≈˘⟨ project₁ ⟩ π₁ ∘ ⟨ f ∘ p.p₁ , g ∘ p.p₁ ⟩ ≈⟨ refl⟩∘⟨ eq ⟩ π₁ ∘ ⟨ p.p₂ , p.p₂ ⟩ ≈⟨ project₁ ⟩ p.p₂ ∎ equality : f ∘ p.p₁ ≈ g ∘ p.p₁ equality = begin f ∘ p.p₁ ≈⟨ eq′ ⟩ p.p₂ ≈˘⟨ project₂ ⟩ π₂ ∘ ⟨ p.p₂ , p.p₂ ⟩ ≈˘⟨ refl⟩∘⟨ eq ⟩ π₂ ∘ ⟨ f ∘ p.p₁ , g ∘ p.p₁ ⟩ ≈⟨ project₂ ⟩ g ∘ p.p₁ ∎ -- all pullbacks and a terminal object make a category finitely complete pullback-⊤⇒FinitelyComplete : (∀ {X Y Z} (f : X ⇒ Z) (g : Y ⇒ Z) → Pullback f g) → Terminal → FinitelyComplete C pullback-⊤⇒FinitelyComplete pullbacks ⊤ = record { cartesian = cartesian ; equalizer = λ _ _ → pullback×cartesian⇒equalizer pullbacks cartesian } where open Category hiding (Obj) open Pullback open Terminal ⊤ hiding (⊤) _×_ : (A B : Obj) → Pullback (IsTerminal.! ⊤-is-terminal) (IsTerminal.! ⊤-is-terminal) A × B = pullbacks (IsTerminal.! ⊤-is-terminal) (IsTerminal.! ⊤-is-terminal) cartesian = record { terminal = ⊤ ; products = record { product = λ {A B} → record { A×B = P {A}{_}{B} (A × B) ; π₁ = p₁ (A × B) ; π₂ = p₂ (A × B) ; ⟨_,_⟩ = λ _ _ → universal (A × B) (!-unique₂) ; project₁ = p₁∘universal≈h₁ (A × B) ; project₂ = p₂∘universal≈h₂ (A × B) ; unique = λ eq₁ eq₂ → Equiv.sym C (unique (A × B) eq₁ eq₂) } } } -- extra properties of "up-to-iso" module IsoPb {X Y Z} {f : X ⇒ Z} {g : Y ⇒ Z} (pull₀ pull₁ : Pullback f g) where open Pullback using (P; p₁; p₂; p₁∘universal≈h₁; p₂∘universal≈h₂; commute; universal) P₀≅P₁ : P pull₀ ≅ P pull₁ P₀≅P₁ = up-to-iso pull₀ pull₁ P₀⇒P₁ : P pull₀ ⇒ P pull₁ P₀⇒P₁ = _≅_.from P₀≅P₁ p₁-≈ : p₁ pull₁ ∘ P₀⇒P₁ ≈ p₁ pull₀ p₁-≈ = p₁∘universal≈h₁ pull₁ {eq = commute pull₀} p₂-≈ : p₂ pull₁ ∘ P₀⇒P₁ ≈ p₂ pull₀ p₂-≈ = p₂∘universal≈h₂ pull₁ {eq = commute pull₀}
{ "alphanum_fraction": 0.5178209215, "avg_line_length": 35.9479166667, "ext": "agda", "hexsha": "2460328734a945ac0d117a47546868d6ff55ebcb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Diagram/Pullback/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Diagram/Pullback/Properties.agda", "max_line_length": 112, "max_stars_count": 5, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Diagram/Pullback/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2019-05-22T03:54:24.000Z", "max_stars_repo_stars_event_min_datetime": "2019-05-21T17:07:19.000Z", "num_tokens": 2602, "size": 6902 }
module Sandbox.Pred where open import Data.Num open import Data.Num.Properties open import Data.Nat open import Data.Fin using (Fin; suc; zero; #_) open import Data.Vec open import Relation.Nullary.Decidable using (True; fromWitness) open import Relation.Binary.PropositionalEquality hiding ([_]) -- open import Relation.Binary open ≡-Reasoning data Term : ℕ → Set where var : ∀ {n} → Fin n -- the index of this variable → Term n _∔_ : ∀ {n} → Term n → Term n → Term n data Pred : ℕ → Set where _≣_ : ∀ {n} → Term n → Term n → Pred n _⇒_ : ∀ {n} → Pred n → Pred n → Pred n -- captures 1 free variable in the Pred All : ∀ {n} → Pred (suc n) → Pred n record Signature : Set₁ where constructor signature field carrier : Set _⊕_ : carrier → carrier → carrier _≈_ : carrier → carrier → Set open Signature -- signatures ℕ-sig : Signature ℕ-sig = signature ℕ _+_ _≡_ Num-sig : (b d o : ℕ) → True (Surjective? b d o) → Signature Num-sig b d o surj = signature (Num b d o) (_⊹_ {surj = surj}) _≋_ ⟦_⟧Term : ∀ {n} → Term n → (sig : Signature) → let A = carrier sig in Vec A n → A ⟦ var x ⟧Term sig env = lookup x env ⟦ a ∔ b ⟧Term sig env = let (signature A _⊕_ _≈_) = sig in (⟦ a ⟧Term sig env) ⊕ (⟦ b ⟧Term sig env) ⟦_⟧ : ∀ {n} → Pred n → (sig : Signature) → Vec (carrier sig) n → Set ⟦ p ≣ q ⟧ sig env = let (signature carrier _⊕_ _≈_) = sig in ⟦ p ⟧Term sig env ≈ ⟦ q ⟧Term sig env ⟦ p ⇒ q ⟧ sig env = ⟦ p ⟧ sig env → ⟦ q ⟧ sig env ⟦ All p ⟧ sig env = ∀ x → ⟦ p ⟧ sig (x ∷ env) -- lemma for env lookup-map : ∀ {i j} → {A : Set i} {B : Set j} → (f : A → B) → ∀ {n} → (xs : Vec A n) (i : Fin n) → lookup i (map f xs) ≡ f (lookup i xs) lookup-map f [] () lookup-map f (x ∷ env) zero = refl lookup-map f (x ∷ env) (suc i) = lookup-map f env i toℕ-term-homo : ∀ {b d o} → {surj : True (Surjective? b d o)} → ∀ {n} → (t : Term n) → (env : Vec (Num b d o) n) → ⟦ t ⟧Term ℕ-sig (map toℕ env) ≡ toℕ (⟦ t ⟧Term (Num-sig b d o surj) env ) toℕ-term-homo (var x) env = lookup-map toℕ env x toℕ-term-homo {b} {d} {o} {surj} (s ∔ t) env = begin ⟦ s ∔ t ⟧Term ℕ-sig (map toℕ env) ≡⟨ cong₂ _+_ (toℕ-term-homo {surj = surj} s env) (toℕ-term-homo {surj = surj} t env) ⟩ toℕ (⟦ s ⟧Term _ env) + toℕ (⟦ t ⟧Term _ env) ≡⟨ sym (toℕ-⊹-homo (⟦ s ⟧Term _ env) (⟦ t ⟧Term _ env)) ⟩ toℕ (⟦ s ∔ t ⟧Term (Num-sig b d o surj) env) ∎ mutual toℕ-pred-ℕ⇒Num : ∀ {b d o} → {surj : True (Surjective? b d o)} → ∀ {n} → (p : Pred n) → (env : Vec (Num b d o) n) → ⟦ p ⟧ ℕ-sig (map toℕ env) → ⟦ p ⟧ (Num-sig b d o surj) env -- toℕ-pred-ℕ⇒Num (p ≣ q) env ⟦p≡q⟧ℕ = {! !} toℕ-pred-ℕ⇒Num {b} {d} {o} {surj} (p ≣ q) env a = -- a : ⟦ p ⟧Term ℕ-sig (ℕ-env) ≡ ⟦ q ⟧Term ℕ-sig (ℕ-env) let p' = ⟦ p ⟧Term {! Num-sig b d o surj !} {! !} {! !} temp = toℕ-injective p' {! !} a in {! toℕ-injective !} toℕ-pred-ℕ⇒Num (p ⇒ q) env a = {! !} toℕ-pred-ℕ⇒Num (All p) env a = {! !} toℕ-pred-Num→ℕ : ∀ {b d o} → {surj : True (Surjective? b d o)} → ∀ {n} → (p : Pred n) → (env : Vec (Num b d o) n) → ⟦ p ⟧ (Num-sig b d o surj) env → ⟦ p ⟧ ℕ-sig (map toℕ env) toℕ-pred-Num→ℕ (p ≣ q) env a = {! !} toℕ-pred-Num→ℕ (p ⇒ q) env a = {! !} toℕ-pred-Num→ℕ (All p) env a = {! !} -- begin -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ∎ -- -- toℕ-term-homo : ∀ {b n} -- → (t : Term n) -- → (env : Vec (BijN b) n) -- → ⟦ t ⟧Term ℕ-sig (map toℕ env) ≡ toℕ (⟦ t ⟧Term (BijN-sig b) env) -- toℕ-term-homo (var i) env = ? -- toℕ-term-homo {b} (t₁ ∔ t₂) env = ?
{ "alphanum_fraction": 0.4759615385, "avg_line_length": 28.8467153285, "ext": "agda", "hexsha": "622b3b8c74ebfff9a428ff71bd30d4204814fb7f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_path": "Sandbox/Pred.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "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": "banacorn/numeral", "max_issues_repo_path": "Sandbox/Pred.agda", "max_line_length": 90, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_path": "Sandbox/Pred.agda", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "num_tokens": 1686, "size": 3952 }
{-# OPTIONS --show-implicit #-} {-# OPTIONS --sized-types #-} module Issue298 where postulate Size : Set ↑_ : Size → Size ∞ : Size {-# BUILTIN SIZE Size #-} {-# BUILTIN SIZESUC ↑_ #-} {-# BUILTIN SIZEINF ∞ #-} data BTree : {i : Size} → Set where leaf : ∀ {i} → BTree {↑ i} node : ∀ {i} → BTree {i} → BTree {i} → BTree {↑ i} recId : ∀ {i} → BTree {i} → BTree {i} recId leaf = leaf recId (node l r) = node (recId l) (recId r) deepId : ∀ {i} → BTree {i} → BTree {i} deepId leaf = leaf deepId (node leaf leaf) = node leaf leaf deepId (node leaf (node r1 r2)) = node leaf (node (deepId r1) (deepId r2)) deepId (node (node l1 l2) r) = node (node (deepId l1) (deepId l2)) (deepId r)
{ "alphanum_fraction": 0.5720338983, "avg_line_length": 24.4137931034, "ext": "agda", "hexsha": "0531ec487272e4a9fdb3098b3df9cb0ba20099fd", "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": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/agda-kanso", "max_forks_repo_path": "test/succeed/Issue298.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "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": "asr/agda-kanso", "max_issues_repo_path": "test/succeed/Issue298.agda", "max_line_length": 77, "max_stars_count": null, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/Issue298.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 270, "size": 708 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category -- Reasoning facilities about morphism equivalences (not necessarily 'squares') module Categories.Morphism.Reasoning {o ℓ e} (C : Category o ℓ e) where -- some items are defined in sub-modules open import Categories.Morphism.Reasoning.Core C public open import Categories.Morphism.Reasoning.Iso C public open Category C open Definitions C open HomReasoning -- create a commutative square from an equivalence toSquare : ∀ {A B} {f g : A ⇒ B} → f ≈ g → CommutativeSquare f id id g toSquare {_} {_} {f} {g} f≈g = begin id ∘ f ≈⟨ identityˡ ⟩ f ≈⟨ f≈g ⟩ g ≈˘⟨ identityʳ ⟩ g ∘ id ∎
{ "alphanum_fraction": 0.6700434153, "avg_line_length": 28.7916666667, "ext": "agda", "hexsha": "ab0538caf08aa8273588f2411394977232bea40b", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Morphism/Reasoning.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Morphism/Reasoning.agda", "max_line_length": 79, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Morphism/Reasoning.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": 215, "size": 691 }
module Prelude where data Nat : Set where zero : Nat suc : Nat -> Nat {-# BUILTIN NATURAL Nat #-} data _==_ {A : Set} (x : A) : A → Set where refl : x == x data Vec (A : Set) : Nat -> Set where nil : Vec A 0 cons : forall {n} -> A -> Vec A n -> Vec A (suc n) data List (A : Set) : Set where nil : List A cons : A -> List A -> List A data Empty : Set where data Not (A : Set) : Set where is-absurd : (A -> Empty) -> Not A data Dec (A : Set) : Set where yes : A -> Dec A no : Not A -> Dec A
{ "alphanum_fraction": 0.5454545455, "avg_line_length": 18.4642857143, "ext": "agda", "hexsha": "65d164ab9ffbc17b187a94b0cd57a39edf2c0364", "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": "baf979ef78b5ec0f4783240b03f9547490bc5d42", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "carlostome/martin", "max_forks_repo_path": "data/test-files/Prelude.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "baf979ef78b5ec0f4783240b03f9547490bc5d42", "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": "carlostome/martin", "max_issues_repo_path": "data/test-files/Prelude.agda", "max_line_length": 52, "max_stars_count": null, "max_stars_repo_head_hexsha": "baf979ef78b5ec0f4783240b03f9547490bc5d42", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "carlostome/martin", "max_stars_repo_path": "data/test-files/Prelude.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 185, "size": 517 }
{-# OPTIONS --cubical --safe #-} module Cubical.Data.Everything where open import Cubical.Data.BinNat public open import Cubical.Data.Bool public open import Cubical.Data.Empty public open import Cubical.Data.Fin public open import Cubical.Data.Nat public open import Cubical.Data.Int public renaming (_+_ to _+Int_ ; +-assoc to +Int-assoc; +-comm to +Int-comm) open import Cubical.Data.Sum public open import Cubical.Data.Prod public open import Cubical.Data.Unit public open import Cubical.Data.Sigma public open import Cubical.Data.DiffInt public open import Cubical.Data.Group public hiding (_≃_) open import Cubical.Data.HomotopyGroup public open import Cubical.Data.List public open import Cubical.Data.Graph public
{ "alphanum_fraction": 0.8049792531, "avg_line_length": 38.0526315789, "ext": "agda", "hexsha": "a5fd548693227c98eeba26c6dd57482c089f104f", "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": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cj-xu/cubical", "max_forks_repo_path": "Cubical/Data/Everything.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "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": "cj-xu/cubical", "max_issues_repo_path": "Cubical/Data/Everything.agda", "max_line_length": 105, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cj-xu/cubical", "max_stars_repo_path": "Cubical/Data/Everything.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 176, "size": 723 }
{- This second-order term syntax was created from the following second-order syntax description: syntax Inception | IA type L : 0-ary P : 0-ary A : 0-ary term rec : L P -> A inc : L.A P.A -> A theory (S) p : P a : P.A |> inc (l. rec (l, p[]), x. a[x]) = a[p[]] (E) a : L.A |> k : L |- inc (l. a[l], x. rec(k, x)) = a[k] (W) m : A a : P.A |> inc (l. m[], x. a[x]) = m[] (A) p : (L,L).A a : (L,P).A b : P.A |> inc (l. inc (k. p[l, k], x. a[l,x]), y. b[y]) = inc (k. inc(l. p[l,k], y.b[y]), x. inc(l. a[l,x], y.b[y])) -} module Inception.Syntax where open import SOAS.Common open import SOAS.Context open import SOAS.Variable open import SOAS.Families.Core open import SOAS.Construction.Structure open import SOAS.ContextMaps.Inductive open import SOAS.Metatheory.Syntax open import Inception.Signature private variable Γ Δ Π : Ctx α : IAT 𝔛 : Familyₛ -- Inductive term declaration module IA:Terms (𝔛 : Familyₛ) where data IA : Familyₛ where var : ℐ ⇾̣ IA mvar : 𝔛 α Π → Sub IA Π Γ → IA α Γ rec : IA L Γ → IA P Γ → IA A Γ inc : IA A (L ∙ Γ) → IA A (P ∙ Γ) → IA A Γ open import SOAS.Metatheory.MetaAlgebra ⅀F 𝔛 IAᵃ : MetaAlg IA IAᵃ = record { 𝑎𝑙𝑔 = λ where (recₒ ⋮ a , b) → rec a b (incₒ ⋮ a , b) → inc a b ; 𝑣𝑎𝑟 = var ; 𝑚𝑣𝑎𝑟 = λ 𝔪 mε → mvar 𝔪 (tabulate mε) } module IAᵃ = MetaAlg IAᵃ module _ {𝒜 : Familyₛ}(𝒜ᵃ : MetaAlg 𝒜) where open MetaAlg 𝒜ᵃ 𝕤𝕖𝕞 : IA ⇾̣ 𝒜 𝕊 : Sub IA Π Γ → Π ~[ 𝒜 ]↝ Γ 𝕊 (t ◂ σ) new = 𝕤𝕖𝕞 t 𝕊 (t ◂ σ) (old v) = 𝕊 σ v 𝕤𝕖𝕞 (mvar 𝔪 mε) = 𝑚𝑣𝑎𝑟 𝔪 (𝕊 mε) 𝕤𝕖𝕞 (var v) = 𝑣𝑎𝑟 v 𝕤𝕖𝕞 (rec a b) = 𝑎𝑙𝑔 (recₒ ⋮ 𝕤𝕖𝕞 a , 𝕤𝕖𝕞 b) 𝕤𝕖𝕞 (inc a b) = 𝑎𝑙𝑔 (incₒ ⋮ 𝕤𝕖𝕞 a , 𝕤𝕖𝕞 b) 𝕤𝕖𝕞ᵃ⇒ : MetaAlg⇒ IAᵃ 𝒜ᵃ 𝕤𝕖𝕞 𝕤𝕖𝕞ᵃ⇒ = record { ⟨𝑎𝑙𝑔⟩ = λ{ {t = t} → ⟨𝑎𝑙𝑔⟩ t } ; ⟨𝑣𝑎𝑟⟩ = refl ; ⟨𝑚𝑣𝑎𝑟⟩ = λ{ {𝔪 = 𝔪}{mε} → cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-tab mε)) } } where open ≡-Reasoning ⟨𝑎𝑙𝑔⟩ : (t : ⅀ IA α Γ) → 𝕤𝕖𝕞 (IAᵃ.𝑎𝑙𝑔 t) ≡ 𝑎𝑙𝑔 (⅀₁ 𝕤𝕖𝕞 t) ⟨𝑎𝑙𝑔⟩ (recₒ ⋮ _) = refl ⟨𝑎𝑙𝑔⟩ (incₒ ⋮ _) = refl 𝕊-tab : (mε : Π ~[ IA ]↝ Γ)(v : ℐ α Π) → 𝕊 (tabulate mε) v ≡ 𝕤𝕖𝕞 (mε v) 𝕊-tab mε new = refl 𝕊-tab mε (old v) = 𝕊-tab (mε ∘ old) v module _ (g : IA ⇾̣ 𝒜)(gᵃ⇒ : MetaAlg⇒ IAᵃ 𝒜ᵃ g) where open MetaAlg⇒ gᵃ⇒ 𝕤𝕖𝕞! : (t : IA α Γ) → 𝕤𝕖𝕞 t ≡ g t 𝕊-ix : (mε : Sub IA Π Γ)(v : ℐ α Π) → 𝕊 mε v ≡ g (index mε v) 𝕊-ix (x ◂ mε) new = 𝕤𝕖𝕞! x 𝕊-ix (x ◂ mε) (old v) = 𝕊-ix mε v 𝕤𝕖𝕞! (mvar 𝔪 mε) rewrite cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-ix mε)) = trans (sym ⟨𝑚𝑣𝑎𝑟⟩) (cong (g ∘ mvar 𝔪) (tab∘ix≈id mε)) 𝕤𝕖𝕞! (var v) = sym ⟨𝑣𝑎𝑟⟩ 𝕤𝕖𝕞! (rec a b) rewrite 𝕤𝕖𝕞! a | 𝕤𝕖𝕞! b = sym ⟨𝑎𝑙𝑔⟩ 𝕤𝕖𝕞! (inc a b) rewrite 𝕤𝕖𝕞! a | 𝕤𝕖𝕞! b = sym ⟨𝑎𝑙𝑔⟩ -- Syntax instance for the signature IA:Syn : Syntax IA:Syn = record { ⅀F = ⅀F ; ⅀:CS = ⅀:CompatStr ; mvarᵢ = IA:Terms.mvar ; 𝕋:Init = λ 𝔛 → let open IA:Terms 𝔛 in record { ⊥ = IA ⋉ IAᵃ ; ⊥-is-initial = record { ! = λ{ {𝒜 ⋉ 𝒜ᵃ} → 𝕤𝕖𝕞 𝒜ᵃ ⋉ 𝕤𝕖𝕞ᵃ⇒ 𝒜ᵃ } ; !-unique = λ{ {𝒜 ⋉ 𝒜ᵃ} (f ⋉ fᵃ⇒) {x = t} → 𝕤𝕖𝕞! 𝒜ᵃ f fᵃ⇒ t } } } } -- Instantiation of the syntax and metatheory open Syntax IA:Syn public open IA:Terms public open import SOAS.Families.Build public open import SOAS.Syntax.Shorthands IAᵃ public open import SOAS.Metatheory IA:Syn public
{ "alphanum_fraction": 0.5261418269, "avg_line_length": 26.2047244094, "ext": "agda", "hexsha": "9e863180838ca5686963d0e0c6e75c57848b9ab4", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "out/Inception/Syntax.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "out/Inception/Syntax.agda", "max_line_length": 163, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "out/Inception/Syntax.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 2017, "size": 3328 }
-- The unit type; also used as proposition ``Truth''. {-# OPTIONS --without-K --safe #-} module Tools.Unit where -- We reexport Agda's built-in unit type. open import Agda.Builtin.Unit public using (⊤; tt) open import Agda.Primitive record ⊤′ : Setω where instance constructor tt
{ "alphanum_fraction": 0.7073170732, "avg_line_length": 20.5, "ext": "agda", "hexsha": "7a8b7590c37575ee44f15cedde587c543fe82ef0", "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": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "loic-p/logrel-mltt", "max_forks_repo_path": "Tools/Unit.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "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": "loic-p/logrel-mltt", "max_issues_repo_path": "Tools/Unit.agda", "max_line_length": 53, "max_stars_count": null, "max_stars_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "loic-p/logrel-mltt", "max_stars_repo_path": "Tools/Unit.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 75, "size": 287 }
import Lvl open import Structure.Category open import Structure.Setoid open import Type module Structure.Category.Morphism.Transport {ℓₒ ℓₘ ℓₑ : Lvl.Level} (cat : CategoryObject{ℓₒ}{ℓₘ}{ℓₑ}) where import Functional.Dependent as Fn import Function.Equals open Function.Equals.Dependent open import Logic open import Logic.Propositional open import Logic.Predicate open import Relator.Equals using ([≡]-intro) renaming (_≡_ to _≡ₑ_) open import Relator.Equals.Proofs import Structure.Category.Morphism.IdTransport as IdTransport import Structure.Categorical.Names as Names open import Structure.Categorical.Properties open import Structure.Function open import Structure.Relator.Properties open CategoryObject(cat) open Category(category) open Category.ArrowNotation(category) open Morphism.OperModule ⦃ morphism-equiv ⦄ (\{x} → _∘_ {x}) open Morphism.IdModule ⦃ morphism-equiv ⦄ (\{x} → _∘_ {x})(id) module _ {P : Object → Object} (p : ∀{x} → (x ⟶ P(x))) ⦃ isomorphism : ∀{x} → Isomorphism(p{x}) ⦄ where private variable a b c : Object transport : (a ≡ₑ b) → (P(a) ⟶ P(b)) transport ab = p ∘ IdTransport.transport(cat) ab ∘ inv(p)
{ "alphanum_fraction": 0.7290431837, "avg_line_length": 32.8055555556, "ext": "agda", "hexsha": "b96e7981bcddaa793fe4b338d287e89d38ca01c3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Category/Morphism/Transport.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Category/Morphism/Transport.agda", "max_line_length": 103, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Category/Morphism/Transport.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": 349, "size": 1181 }
module ModuleArityMismatch where module M (A : Set) where postulate A : Set module M′ = M A A
{ "alphanum_fraction": 0.6699029126, "avg_line_length": 11.4444444444, "ext": "agda", "hexsha": "65bba45d0a4466f9aada7393d98648dc075ab532", "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/ModuleArityMismatch.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/ModuleArityMismatch.agda", "max_line_length": 32, "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/ModuleArityMismatch.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": 32, "size": 103 }
module Prelude where -- Function composition _∘_ : ∀ {x y z : Set} -> (y -> z) -> (x -> y) -> (x -> z) (f ∘ g) x = f (g x) -- Product type data _×_ (A B : Set) : Set where _,_ : A -> B -> A × B uncurry : ∀ {x y z : Set} -> (x -> y -> z) -> (x × y) -> z uncurry f (a , b) = f a b -- Lists data List (A : Set) : Set where [] : List A _::_ : A -> List A -> List A infixr 20 _::_ infixr 15 _++_ [_] : ∀ {A} -> A -> List A [ x ] = x :: [] _++_ : ∀ {A} -> List A -> List A -> List A [] ++ l = l (x :: xs) ++ l = x :: (xs ++ l) foldr : ∀ {A B : Set} -> (A -> B -> B) -> B -> List A -> B foldr f b [] = b foldr f b (x :: xs) = f x (foldr f b xs) map : ∀ {A B} -> (A -> B) -> List A -> List B map f [] = [] map f (x :: xs) = f x :: map f xs zip : ∀ {A B} -> List A -> List B -> List (A × B) zip [] _ = [] zip _ [] = [] zip (x :: xs) (y :: ys) = (x , y) :: zip xs ys
{ "alphanum_fraction": 0.3780359029, "avg_line_length": 23.0975609756, "ext": "agda", "hexsha": "ff331ca03a3599d4529474279efda47f48e09a58", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2019-05-09T23:53:28.000Z", "max_forks_repo_forks_event_min_datetime": "2017-12-17T20:48:20.000Z", "max_forks_repo_head_hexsha": "0fdb96c0233d9be83eba637f0434d0fd22aefb1d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "snowleopard/alga-proofs", "max_forks_repo_path": "src/Prelude.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "0fdb96c0233d9be83eba637f0434d0fd22aefb1d", "max_issues_repo_issues_event_max_datetime": "2018-06-23T13:54:02.000Z", "max_issues_repo_issues_event_min_datetime": "2018-04-12T16:25:13.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "snowleopard/alga-proofs", "max_issues_repo_path": "src/Prelude.agda", "max_line_length": 59, "max_stars_count": 60, "max_stars_repo_head_hexsha": "0fdb96c0233d9be83eba637f0434d0fd22aefb1d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "snowleopard/alga-proofs", "max_stars_repo_path": "src/Prelude.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:05:29.000Z", "max_stars_repo_stars_event_min_datetime": "2017-12-27T14:57:04.000Z", "num_tokens": 377, "size": 947 }
module Issue49 where module Dummy {A : Set1} where postulate D : Set T : Set T = Dummy.D {Set} T' : Set T' = Dummy.D {A = Set}
{ "alphanum_fraction": 0.6183206107, "avg_line_length": 13.1, "ext": "agda", "hexsha": "1c46b5174cd33b800fe2484ecffa04fc19065a62", "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/succeed/Issue49.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/Issue49.agda", "max_line_length": 29, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/Issue49.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": 48, "size": 131 }
module NatCat where open import Relation.Binary.PropositionalEquality -- If you can show that a relation only ever has one inhabitant -- you get the category laws for free module EasyCategory (obj : Set) (_⟶_ : obj → obj → Set) (_∘_ : ∀ {x y z} → x ⟶ y → y ⟶ z → x ⟶ z) (id : ∀ x → x ⟶ x) (single-inhabitant : (x y : obj) (r s : x ⟶ y) → r ≡ s) where idʳ : ∀ x y (r : x ⟶ y) → r ∘ id y ≡ r idʳ x y r = single-inhabitant x y (r ∘ id y) r idˡ : ∀ x y (r : x ⟶ y) → id x ∘ r ≡ r idˡ x y r = single-inhabitant x y (id x ∘ r) r ∘-assoc : ∀ w x y z (r : w ⟶ x) (s : x ⟶ y) (t : y ⟶ z) → (r ∘ s) ∘ t ≡ r ∘ (s ∘ t) ∘-assoc w x y z r s t = single-inhabitant w z ((r ∘ s) ∘ t) (r ∘ (s ∘ t)) open import Data.Nat same : (x y : ℕ) (r s : x ≤ y) → r ≡ s same .0 y z≤n z≤n = refl same .(suc m) .(suc n) (s≤s {m} {n} r) (s≤s s) = cong s≤s (same m n r s) ≤-trans : ∀ x y z → x ≤ y → y ≤ z → x ≤ z ≤-trans .0 y z z≤n s = z≤n ≤-trans .(suc m) .(suc n) .(suc n₁) (s≤s {m} {n} r) (s≤s {.n} {n₁} s) = s≤s (≤-trans m n n₁ r s) ≤-refl : ∀ x → x ≤ x ≤-refl zero = z≤n ≤-refl (suc x) = s≤s (≤-refl x) module Nat-EasyCategory = EasyCategory ℕ _≤_ (λ {x}{y}{z} → ≤-trans x y z) ≤-refl same
{ "alphanum_fraction": 0.5008333333, "avg_line_length": 30, "ext": "agda", "hexsha": "7aada27ee452566e1de5dd8dd76591c9cbaf358e", "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": "89fcfb45789f07778ac570e98629a6b767913425", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "alexgracianoarj/detect-languages", "max_forks_repo_path": "samples/Agda/NatCat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "89fcfb45789f07778ac570e98629a6b767913425", "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": "alexgracianoarj/detect-languages", "max_issues_repo_path": "samples/Agda/NatCat.agda", "max_line_length": 96, "max_stars_count": 2, "max_stars_repo_head_hexsha": "89fcfb45789f07778ac570e98629a6b767913425", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "alexgracianoarj/detect-languages", "max_stars_repo_path": "samples/Agda/NatCat.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-23T14:03:52.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-23T13:43:34.000Z", "num_tokens": 607, "size": 1200 }
module Structure.Relator.Properties where open import Functional import Lvl open import Lang.Instance open import Logic import Structure.Relator.Names as Names open import Type private variable ℓ ℓ₁ ℓ₂ ℓ₃ ℓ₄ : Lvl.Level private variable T A B C D E : Type{ℓ} -- Definition of a reflexive binary relation module _ {T : Type{ℓ₁}} (_▫_ : T → T → Stmt{ℓ₂}) where record Reflexivity : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where constructor intro field proof : Names.Reflexivity(_▫_) reflexivity = inst-fn Reflexivity.proof -- Definition of a transitive binary relation module _ {T : Type{ℓ₁}} (_▫_ : T → T → Stmt{ℓ₂}) where record Transitivity : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where constructor intro field proof : Names.Transitivity(_▫_) transitivity = inst-fn Transitivity.proof -- Definition of a antisymmetric binary relation module _ {T : Type{ℓ₁}} (_▫₁_ : T → T → Stmt{ℓ₂}) (_▫₂_ : T → T → Stmt{ℓ₃}) where record Antisymmetry : Stmt{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃} where constructor intro field proof : Names.Antisymmetry(_▫₁_)(_▫₂_) antisymmetry = inst-fn Antisymmetry.proof -- Definition of a irreflexive binary relation module _ {T : Type{ℓ₁}} (_▫_ : T → T → Stmt{ℓ₂}) where record Irreflexivity : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where constructor intro field proof : Names.Irreflexivity(_▫_) irreflexivity = inst-fn Irreflexivity.proof -- Definition of a total binary relation. -- Total in the sense that it, or its converse, holds. module _ {T : Type{ℓ₁}} (_▫_ : T → T → Stmt{ℓ₂}) where record ConverseTotal : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where constructor intro field proof : Names.ConverseTotal(_▫_) converseTotal = inst-fn ConverseTotal.proof -- Definition of a converse dichotomy. -- It or its converse always holds, but never both at the same time. module _ {T : Type{ℓ₁}} (_▫_ : T → T → Stmt{ℓ₂}) where record ConverseDichotomy : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where constructor intro field proof : Names.ConverseDichotomy(_▫_) dichotomy = inst-fn ConverseDichotomy.proof module _ {T : Type{ℓ₁}} (_▫₁_ : T → T → Stmt{ℓ₂}) (_▫₂_ : T → T → Stmt{ℓ₃}) where record ConverseTrichotomy : Stmt{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃} where constructor intro field proof : Names.ConverseTrichotomy(_▫₁_)(_▫₂_) trichotomy = inst-fn ConverseTrichotomy.proof -- Definition of a converse binary operation for a binary operation -- record Converse {T₁ T₂ : Type} (_▫₁_ : T₁ → T₂ → Stmt) (_▫₂_ : T₂ → T₁ → Stmt) : Stmt where -- constructor intro -- -- field -- converseₗ : Names.ConversePattern (_▫₂_) (_▫₁_) -- converseᵣ : Names.ConversePattern (_▫₁_) (_▫₂_) -- open Converse ⦃ ... ⦄ public -- {x : T₁}{y : T₂} → (x ▫₁ y) ↔ (y ▫₂ x) -- Definition of a symmetric binary operation module _ {T : Type{ℓ₁}} (_▫_ : T → T → Stmt{ℓ₂}) where record Symmetry : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where constructor intro field proof : Names.Symmetry(_▫_) symmetry = inst-fn Symmetry.proof -- {x y : T} → (x ▫ y) → (y ▫ x) -- Definition of an asymmetric binary operation module _ {T : Type{ℓ₁}} (_▫_ : T → T → Stmt{ℓ₂}) where record Asymmetry : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where constructor intro field proof : Names.Asymmetry(_▫_) asymmetry = inst-fn Asymmetry.proof -- {x y : T} → (x ▫ y) → ¬(y ▫ x) module _ (_▫₁_ : A → B → Stmt{ℓ₁}) (_▫₂_ : A → B → Stmt{ℓ₂}) where record _⊆₂_ : Stmt{Lvl.of(A) Lvl.⊔ Lvl.of(B) Lvl.⊔ ℓ₁ Lvl.⊔ ℓ₂} where constructor intro field proof : Names.Subrelation(_▫₁_)(_▫₂_) sub₂ = inst-fn _⊆₂_.proof module _ (_▫₁_ : A → B → Stmt{ℓ₁}) (_▫₂_ : A → B → Stmt{ℓ₂}) where _⊇₂_ = (_▫₂_) ⊆₂ (_▫₁_) module _⊇₂_ inst = _⊆₂_ {_▫₁_ = _▫₂_}{_▫₂_ = _▫₁_} inst super₂ = inst-fn _⊇₂_.proof module _ (_▫₁_ : A → B → Stmt{ℓ₁}) (_▫₂_ : A → A → Stmt{ℓ₂}) where record Subtransitivityₗ : Stmt{Lvl.of(A) Lvl.⊔ Lvl.of(B) Lvl.⊔ ℓ₁ Lvl.⊔ ℓ₂} where constructor intro field proof : Names.Subtransitivityₗ(_▫₁_)(_▫₂_) subtransitivityₗ = inst-fn Subtransitivityₗ.proof module _ (_▫₁_ : A → B → Stmt{ℓ₁}) (_▫₂_ : B → B → Stmt{ℓ₂}) where record Subtransitivityᵣ : Stmt{Lvl.of(A) Lvl.⊔ Lvl.of(B) Lvl.⊔ ℓ₁ Lvl.⊔ ℓ₂} where constructor intro field proof : Names.Subtransitivityᵣ(_▫₁_)(_▫₂_) subtransitivityᵣ = inst-fn Subtransitivityᵣ.proof -- Definition of a cotransitive binary relation module _ {T : Type{ℓ₁}} (_▫_ : T → T → Stmt{ℓ₂}) where record CoTransitivity : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where constructor intro field proof : Names.CoTransitivity(_▫_) cotransitivity = inst-fn CoTransitivity.proof
{ "alphanum_fraction": 0.6658432517, "avg_line_length": 37.7372881356, "ext": "agda", "hexsha": "ae363ec0dc0183c076a34ebc8cfc8607418a324c", "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/Relator/Properties.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/Relator/Properties.agda", "max_line_length": 94, "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/Relator/Properties.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": 1748, "size": 4453 }
module Issue2486.ImportB where open import Issue2486.Haskell {-# FOREIGN GHC data BBool = BTrue | BFalse #-} data BBool : Set where BTrue BFalse : BBool {-# COMPILE GHC BBool = data BBool ( BTrue | BFalse ) #-} postulate BList : Set → Set {-# FOREIGN GHC import MAlonzo.Code.Issue2486.Haskell (MyList) #-} {-# COMPILE GHC BList = type MyList #-}
{ "alphanum_fraction": 0.6960227273, "avg_line_length": 25.1428571429, "ext": "agda", "hexsha": "b443d668840482c32c274b2dc4e5b410faba2044", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Compiler/simple/Issue2486/ImportB.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Compiler/simple/Issue2486/ImportB.agda", "max_line_length": 66, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Compiler/simple/Issue2486/ImportB.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": 103, "size": 352 }
{- This is mostly for convenience, when working with ideals (which are defined for general rings) in a commutative ring. -} {-# OPTIONS --safe #-} module Cubical.Algebra.CommRing.Ideal where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Foundations.Powerset open import Cubical.Data.Nat using (ℕ ; zero ; suc) open import Cubical.Data.FinData open import Cubical.Algebra.CommRing.Base open import Cubical.Algebra.Ring.Ideal renaming (IdealsIn to IdealsInRing) open import Cubical.Algebra.Ring.BigOps open import Cubical.Algebra.RingSolver.ReflectionSolving private variable ℓ : Level IdealsIn : (R : CommRing ℓ) → Type _ IdealsIn R = IdealsInRing (CommRing→Ring R) module _ (Ring@(R , str) : CommRing ℓ) where open CommRingStr str makeIdeal : (I : R → hProp ℓ) → (+-closed : {x y : R} → x ∈ I → y ∈ I → (x + y) ∈ I) → (0r-closed : 0r ∈ I) → (·-closedLeft : {x : R} → (r : R) → x ∈ I → r · x ∈ I) → IdealsIn (R , str) makeIdeal I +-closed 0r-closed ·-closedLeft = I , (record { +-closed = +-closed ; -closed = λ x∈I → subst-∈ I (useSolver _) (·-closedLeft (- 1r) x∈I) ; 0r-closed = 0r-closed ; ·-closedLeft = ·-closedLeft ; ·-closedRight = λ r x∈I → subst-∈ I (·-comm r _) (·-closedLeft r x∈I) }) where useSolver : (x : R) → - 1r · x ≡ - x useSolver = solve Ring -- better? module _ (R' : CommRing ℓ) where private R = fst R' open CommRingStr (snd R') open Sum (CommRing→Ring R') record isCommIdeal (I : ℙ R) : Type ℓ where constructor makeIsCommIdeal field +Closed : ∀ {x y : R} → x ∈ I → y ∈ I → (x + y) ∈ I contains0 : 0r ∈ I ·Closed : ∀ {x : R} (r : R) → x ∈ I → r · x ∈ I open isCommIdeal isPropIsCommIdeal : (I : ℙ R) → isProp (isCommIdeal I) +Closed (isPropIsCommIdeal I ici₁ ici₂ i) x∈I y∈I = I _ .snd (ici₁ .+Closed x∈I y∈I) (ici₂ .+Closed x∈I y∈I) i contains0 (isPropIsCommIdeal I ici₁ ici₂ i) = I 0r .snd (ici₁ .contains0) (ici₂ .contains0) i ·Closed (isPropIsCommIdeal I ici₁ ici₂ i) r x∈I = I _ .snd (ici₁ .·Closed r x∈I) (ici₂ .·Closed r x∈I) i CommIdeal : Type _ CommIdeal = Σ[ I ∈ ℙ R ] isCommIdeal I ∑Closed : (I : CommIdeal) {n : ℕ} (V : FinVec R n) → (∀ i → V i ∈ fst I) → ∑ V ∈ fst I ∑Closed I {n = zero} _ _ = I .snd .contains0 ∑Closed I {n = suc n} V h = I .snd .+Closed (h zero) (∑Closed I (V ∘ suc) (h ∘ suc))
{ "alphanum_fraction": 0.5799621928, "avg_line_length": 33.0625, "ext": "agda", "hexsha": "dce7bd56f4cca43a2747d912655f5048d80a8234", "lang": "Agda", "max_forks_count": 134, "max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z", "max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z", "max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "marcinjangrzybowski/cubical", "max_forks_repo_path": "Cubical/Algebra/CommRing/Ideal.agda", "max_issues_count": 584, "max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z", "max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "marcinjangrzybowski/cubical", "max_issues_repo_path": "Cubical/Algebra/CommRing/Ideal.agda", "max_line_length": 94, "max_stars_count": 301, "max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "marcinjangrzybowski/cubical", "max_stars_repo_path": "Cubical/Algebra/CommRing/Ideal.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z", "num_tokens": 930, "size": 2645 }
------------------------------------------------------------------------------ -- Equality reasoning on inductive PA ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- This module only re-export the preorder reasoning instanced on -- the inductive PA propositional equality. module PA.Inductive.Relation.Binary.EqReasoning where open import PA.Inductive.Base import Common.Relation.Binary.PreorderReasoning open module ≡-Reasoning = Common.Relation.Binary.PreorderReasoning _≡_ refl trans public renaming ( _∼⟨_⟩_ to _≡⟨_⟩_ )
{ "alphanum_fraction": 0.5432432432, "avg_line_length": 35.2380952381, "ext": "agda", "hexsha": "93eecd0323b5929f069e2800dd645cec17e44f5d", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/PA/Inductive/Relation/Binary/EqReasoning.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/PA/Inductive/Relation/Binary/EqReasoning.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/PA/Inductive/Relation/Binary/EqReasoning.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": 144, "size": 740 }
------------------------------------------------------------------------ -- One can construct combinators which do not preserve equality ------------------------------------------------------------------------ module TotalParserCombinators.NotACongruence where open import Codata.Musical.Notation open import Data.Bool open import Data.List open import Function open import Function.Equality open import Function.Inverse as Inv open import Relation.Binary.PropositionalEquality using (_≡_; refl) open import Relation.Nullary open import TotalParserCombinators.Congruence using (_≅P_; _∷_) open import TotalParserCombinators.Derivative open import TotalParserCombinators.Laws open import TotalParserCombinators.Lib open import TotalParserCombinators.Parser open import TotalParserCombinators.Semantics as S using (_∈_·_; _≅_) -- It is easy to construct a combinator which does not preserve -- equality. All it takes is to inspect the input combinator's -- structure (or that of its index), and make some suitable decision -- based on this information. Examples: module Example₁ where -- A combinator which removes ambiguity. unambiguous : ∀ {Tok R xs} → Parser Tok R xs → Parser Tok R (take 1 xs) unambiguous {xs = xs} p = token >>= (λ t → ♯ unambiguous (D t p)) ∣ return⋆ (take 1 xs) -- The following two parsers are (parser) equal. p₁ : Parser Bool Bool (true ∷ (false ∷ [])) p₁ = return true ∣ return false p₂ : Parser Bool Bool (false ∷ (true ∷ [])) p₂ = return false ∣ return true equal : p₁ ≅P p₂ equal = AdditiveMonoid.commutative (return true) (return false) -- However, unambiguous does not respect this equality. unambiguous-is-not-a-congruence : ¬ (unambiguous p₁ ≅ unambiguous p₂) unambiguous-is-not-a-congruence eq = case Inverse.to eq ⟨$⟩ S.∣-right [] (S.∣-left S.return) of λ { (S.∣-right .[] (S.∣-left ())) ; (S.∣-right .[] (S.∣-right .([ false ]) ())) ; (S.∣-left []∈) → helper refl []∈ } where helper : ∀ {s} {f : Bool → List Bool} {p : ∀ b → ∞ (Parser Bool Bool (f b))} → s ≡ [] → ¬ (true ∈ token >>= p · s) helper () (S._>>=_ S.token _) module Example₂ where -- A combinator which returns true (without consuming input) if its -- argument is "fail", and false otherwise. is-fail-bag : ∀ {Tok R xs} → Parser Tok R xs → List Bool is-fail-bag fail = [ true ] is-fail-bag _ = [ false ] is-fail : ∀ {Tok R xs} (p : Parser Tok R xs) → Parser Tok Bool (is-fail-bag p) is-fail fail = return true is-fail (return x) = return false is-fail token = return false is-fail (p₁ ∣ p₂) = return false is-fail (f <$> p) = return false is-fail (p₁ ⊛ p₂) = return false is-fail (p₁ >>= p₂) = return false is-fail (nonempty p) = return false is-fail (cast xs₁≈xs₂ p) = return false -- The following parsers are equal, but is-fail treats them -- differently. p₁ : Parser Bool Bool [] p₁ = fail p₂ : Parser Bool Bool [] p₂ = fail ∣ fail equal : p₁ ≅P p₂ equal = Inv.id ∷ λ _ → ♯ equal is-fail-is-not-a-congruence : ¬ (is-fail p₁ ≅ is-fail p₂) is-fail-is-not-a-congruence eq with Inverse.to eq ⟨$⟩ S.return ... | ()
{ "alphanum_fraction": 0.6067008753, "avg_line_length": 32.4803921569, "ext": "agda", "hexsha": "69d4793795bdacf345ae2be205c8ab4a17bf2c20", "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": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "TotalParserCombinators/NotACongruence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "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/parser-combinators", "max_issues_repo_path": "TotalParserCombinators/NotACongruence.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/parser-combinators", "max_stars_repo_path": "TotalParserCombinators/NotACongruence.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z", "num_tokens": 982, "size": 3313 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.AssocList.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Nat using (ℕ; _+_) private variable ℓ : Level A : Type ℓ infixr 5 ⟨_,_⟩∷_ data AssocList (A : Type ℓ) : Type ℓ where ⟨⟩ : AssocList A ⟨_,_⟩∷_ : (a : A) (n : ℕ) (xs : AssocList A) → AssocList A per : ∀ a b xs → ⟨ a , 1 ⟩∷ ⟨ b , 1 ⟩∷ xs ≡ ⟨ b , 1 ⟩∷ ⟨ a , 1 ⟩∷ xs agg : ∀ a m n xs → ⟨ a , m ⟩∷ ⟨ a , n ⟩∷ xs ≡ ⟨ a , m + n ⟩∷ xs del : ∀ a xs → ⟨ a , 0 ⟩∷ xs ≡ xs trunc : isSet (AssocList A) pattern ⟨_⟩ a = ⟨ a , 1 ⟩∷ ⟨⟩ -- Elimination and recursion principle for association lists module Elim {ℓ'} {B : AssocList A → Type ℓ'} (⟨⟩* : B ⟨⟩) (⟨_,_⟩∷*_ : (x : A) (n : ℕ) {xs : AssocList A} → B xs → B (⟨ x , n ⟩∷ xs)) (per* : (x y : A) {xs : AssocList A} (b : B xs) → PathP (λ i → B (per x y xs i)) (⟨ x , 1 ⟩∷* ⟨ y , 1 ⟩∷* b) (⟨ y , 1 ⟩∷* ⟨ x , 1 ⟩∷* b)) (agg* : (x : A) (m n : ℕ) {xs : AssocList A} (b : B xs) → PathP (λ i → B (agg x m n xs i)) (⟨ x , m ⟩∷* ⟨ x , n ⟩∷* b) (⟨ x , m + n ⟩∷* b)) (del* : (x : A) {xs : AssocList A} (b : B xs) → PathP (λ i → B (del x xs i)) (⟨ x , 0 ⟩∷* b) b) (trunc* : (xs : AssocList A) → isSet (B xs)) where f : (xs : AssocList A) → B xs f ⟨⟩ = ⟨⟩* f (⟨ a , n ⟩∷ xs) = ⟨ a , n ⟩∷* f xs f (per a b xs i) = per* a b (f xs) i f (agg a m n xs i) = agg* a m n (f xs) i f (del a xs i) = del* a (f xs) i f (trunc xs ys p q i j) = isOfHLevel→isOfHLevelDep 2 trunc* (f xs) (f ys) (cong f p) (cong f q) (trunc xs ys p q) i j module ElimProp {ℓ'} {B : AssocList A → Type ℓ'} (BProp : {xs : AssocList A} → isProp (B xs)) (⟨⟩* : B ⟨⟩) (⟨_,_⟩∷*_ : (x : A) (n : ℕ) {xs : AssocList A} → B xs → B (⟨ x , n ⟩∷ xs)) where f : (xs : AssocList A) → B xs f = Elim.f ⟨⟩* ⟨_,_⟩∷*_ (λ x y {xs} b → toPathP (BProp (transp (λ i → B (per x y xs i)) i0 (⟨ x , 1 ⟩∷* ⟨ y , 1 ⟩∷* b)) (⟨ y , 1 ⟩∷* ⟨ x , 1 ⟩∷* b))) (λ x m n {xs} b → toPathP (BProp (transp (λ i → B (agg x m n xs i)) i0 (⟨ x , m ⟩∷* ⟨ x , n ⟩∷* b)) (⟨ x , m + n ⟩∷* b))) (λ x {xs} b → toPathP (BProp (transp (λ i → B (del x xs i)) i0 (⟨ x , 0 ⟩∷* b)) b)) (λ xs → isProp→isSet BProp) module Rec {ℓ'} {B : Type ℓ'} (BType : isSet B) (⟨⟩* : B) (⟨_,_⟩∷*_ : (x : A) (n : ℕ) → B → B) (per* : (x y : A) (b : B) → (⟨ x , 1 ⟩∷* ⟨ y , 1 ⟩∷* b) ≡ (⟨ y , 1 ⟩∷* ⟨ x , 1 ⟩∷* b)) (agg* : (x : A) (m n : ℕ) (b : B) → (⟨ x , m ⟩∷* ⟨ x , n ⟩∷* b) ≡ (⟨ x , m + n ⟩∷* b)) (del* : (x : A) (b : B) → (⟨ x , 0 ⟩∷* b) ≡ b) where f : AssocList A → B f = Elim.f ⟨⟩* (λ x n b → ⟨ x , n ⟩∷* b) (λ x y b → per* x y b) (λ x m n b → agg* x m n b) (λ x b → del* x b) (λ _ → BType)
{ "alphanum_fraction": 0.4238900634, "avg_line_length": 40.5428571429, "ext": "agda", "hexsha": "d2d346fe7ac9f38cdb95c8208c364367c7ce91b0", "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/HITs/AssocList/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/HITs/AssocList/Base.agda", "max_line_length": 131, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/HITs/AssocList/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1409, "size": 2838 }
{-# OPTIONS --without-K --safe #-} module Categories.Diagram.Finite where open import Level open import Categories.Category open import Categories.Category.Finite renaming (Finite to FiniteC) open import Categories.Functor private variable o ℓ e : Level J C : Category o ℓ e record Finite (F : Functor J C) : Set (levelOfTerm F) where field finite : FiniteC J open Functor F public open FiniteC finite public
{ "alphanum_fraction": 0.7310344828, "avg_line_length": 19.7727272727, "ext": "agda", "hexsha": "191cc1062204a983c1b2ab00868919a1a6b50168", "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/Diagram/Finite.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/Diagram/Finite.agda", "max_line_length": 67, "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/Diagram/Finite.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 110, "size": 435 }
-- Exercises for session 2 -- -- If unsure which exercises to do start with those marked with * -- {-# OPTIONS --cubical --allow-unsolved-metas #-} module ExerciseSession2 where open import Part1 open import Part2 open import ExerciseSession1 open import Cubical.Foundations.Equiv -- Exercises about Part 2: -- Exercise* 1: prove that the computation rule for J on refl -- holds up to a path. -- (hint: normalize the goal using C-u C-u C-c C-,) JEq : {x : A} (P : (z : A) → x ≡ z → Type ℓ'') (d : P x refl) → J P d refl ≡ d JEq P p d = {!!} -- Exercise* 2: prove that isContr implies isProp isContr→isProp : isContr A → isProp A isContr→isProp = {!!} -- Exercise 3: prove that isProp implies isProp' -- (hint: use isProp→isSet from the Part2) isProp→isProp' : isProp A → isProp' A isProp→isProp' = {!!} -- Exercise 4: prove the following lemma -- (hint: use the solutions to exercises 2 and 3) isContr→isContr≡ : isContr A → (x y : A) → isContr (x ≡ y) isContr→isContr≡ = {!!} -- Exercise 5: use transp to turn a PathP into a transport fromPathP : {A : I → Type ℓ} {x : A i0} {y : A i1} → PathP A x y → transport (λ i → A i) x ≡ y fromPathP {A = A} p i = {!!} -- The converse is harder to prove so we give it: toPathP : {A : I → Type ℓ} {x : A i0} {y : A i1} → transport (λ i → A i) x ≡ y → PathP A x y toPathP {A = A} {x = x} p i = hcomp (λ j → λ { (i = i0) → x ; (i = i1) → p j }) (transp (λ j → A (i ∧ j)) (~ i) x) -- Exercise* 6: prove that two Σ-types where the second component is a -- proposition is equal if the first projections are equal. -- (hint: use ΣPathP and toPathP) Σ≡Prop : {B : A → Type ℓ'} {u v : Σ A B} (h : (x : A) → isProp (B x)) → (p : fst u ≡ fst v) → u ≡ v Σ≡Prop {B = B} {u = u} {v = v} h p = {!!} -- Exercice 7 (harder): prove that being contractible is a proposition. -- (hint: the second component can be given by a suitable higher -- dimensional hcomp) isPropIsContr : isProp (isContr A) isPropIsContr = {!!} -- Exercises about Part 3: -- Exercise* 8: compose sucPathInt with itself n times. Transporting -- along this will be addition, transporting with it backwards will be -- subtraction. open import Cubical.Data.Nat open import Cubical.Data.Int hiding (addEq ; subEq) -- a) Define a path "addEq n" by composing sucPathInt with itself n times. addEq : ℕ → Int ≡ Int addEq n = {!!} -- b) Define another path "subEq n" by composing "sym sucPathInt" with -- itself n times. subEq : ℕ → Int ≡ Int subEq n = {!!} -- c) Define addition on integers by pattern-matching and transporting -- along addEq/subEq appropriately. _+Int_ : Int → Int → Int m +Int n = {!!} -- d) Do some concrete computations using _+Int_ (this would not work -- in HoTT as the transport would be stuck!) -- e) Use isEquivTransport from open import Cubical.Foundations.Transport -- to prove that +Int with a fixed number is an equivalence. -- -- Note that proving this for the usual _+_ function would be a lot -- longer, but now we get it for free as addition is defined using -- transport which we already know is an equivalence. -- Exercise* 9 (harder): prove that hSet is not a set -- Let's import Bool instead so that we get it from the library open import Cubical.Data.Bool renaming (notEq to notPath) -- The empty type ⊥ (written \bot) open import Cubical.Data.Empty -- Just define hSets of level 0 for simplicity hSet : Type₁ hSet = Σ[ A ∈ Type₀ ] isSet A -- Bool is an hSet BoolSet : hSet BoolSet = Bool , isSetBool -- (hint: use a suitable nested transport) notPath≢refl : (notPath ≡ refl) → ⊥ notPath≢refl e = true≢false {!!} -- (hint: use notPath≢refl and define two elements of BoolSet ≡ -- BoolSet, one based on notPath and one based on refl. Σ≡Prop and -- isPropIsSet is probably handy) ¬isSet-hSet : isSet hSet → ⊥ ¬isSet-hSet h = {!!} -- Exercise 10 (more work): prove that FinData and Fin are equivalent -- and hence equal. Transport some functions and proofs between the -- two. -- Orderings on ℕ open import Cubical.Data.Nat.Order data FinData : ℕ → Type₀ where zero : {n : ℕ} → FinData (suc n) suc : {n : ℕ} (i : FinData n) → FinData (suc n) Fin : ℕ → Type₀ Fin n = Σ[ k ∈ ℕ ] k < n
{ "alphanum_fraction": 0.6538188697, "avg_line_length": 28.0066225166, "ext": "agda", "hexsha": "7a02ab01149e022f5d6a4b9ac1029928d357bae1", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-08-02T16:16:34.000Z", "max_forks_repo_forks_event_min_datetime": "2021-08-02T16:16:34.000Z", "max_forks_repo_head_hexsha": "9a510959fb0e6da9bcc6b0faa0dea76a2821bbdb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "EgbertRijke/EPIT-2020", "max_forks_repo_path": "04-cubical-type-theory/material/ExerciseSession2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9a510959fb0e6da9bcc6b0faa0dea76a2821bbdb", "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": "EgbertRijke/EPIT-2020", "max_issues_repo_path": "04-cubical-type-theory/material/ExerciseSession2.agda", "max_line_length": 74, "max_stars_count": 1, "max_stars_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "williamdemeo/EPIT-2020", "max_stars_repo_path": "04-cubical-type-theory/material/ExerciseSession2.agda", "max_stars_repo_stars_event_max_datetime": "2021-04-03T16:28:06.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-03T16:28:06.000Z", "num_tokens": 1353, "size": 4229 }
{-# OPTIONS --cubical --safe #-} module Cubical.Homotopy.PointedFibration where open import Cubical.Core.Everything open import Cubical.Data.Nat open import Cubical.Foundations.Prelude open import Cubical.Foundations.Pointed open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Homotopy.Base open import Cubical.Homotopy.Connected open import Cubical.Homotopy.Loopspace open import Cubical.Data.Nat open import Cubical.Data.Nat.Order open LowerBoundedInduction open import Cubical.Data.Sigma open import Cubical.Data.Unit open import Cubical.Foundations.HLevels' open import Cubical.Foundations.Structure private variable ℓ ℓ' : Level -- Different versions of Theorem 9. We abstract ℓ' again here -- to avoid some issues with implicit arguments. module _ {ℓ' : Level} (X : Pointed ℓ) where -- block of private stuff to reduce redundancy in the proof of the theorem private module _ (n k : ℕ) where -- A, together with its paramenters/context, is just the statement of the theorem. A : Type (ℓ-max ℓ (ℓ-suc ℓ')) A = (isConnX : isConnected (k + 1) (typ X)) → (Y : typ X → Σ[ Yx ∈ Pointed ℓ' ] (isOfHLevel (n + k) (typ Yx))) → isOfHLevel (n) (Π∙ X (λ x → typ (fst (Y x))) (pt (fst (Y (pt X))))) module PointSec (n k : ℕ) (isConnX : isConnected (k + 1) (typ X)) (Y : typ X → Σ[ Yx ∈ Pointed ℓ' ] (isOfHLevel (n + k) (typ Yx))) where -- The type of pointed sections (x : X) →ₚₜ Y x sec∙ : Type (ℓ-max ℓ ℓ') sec∙ = Π∙ X (λ x → typ (fst (Y x))) (pt (fst (Y (pt X)))) -- Note that if isOfHLevel had a uniform interface for n ≥ 1 then this should be a part of the where -- clause in the theorem. module PointSecProps where -- Given s, the type of pointed sections (x : X) →ₚₜ Ω(Y x, s x) sec∙' : (s : sec∙) → Type (ℓ-max ℓ ℓ') sec∙' s = Π∙ X (λ x → s .fst x ≡ s .fst x) refl -- towards sec∙' s ≃ (s ≡ s) secIso : (s : sec∙) → Iso (sec∙' s) (s ∙∼ s) secIso (_ , s₂) = iso (λ (H , p) → H , p ∙ sym (rCancel s₂)) (λ (H , p) → H , p ∙ rCancel s₂) (λ (H , p) → ΣPathP (refl , sym (assoc p (rCancel s₂) (sym (rCancel s₂))) ∙∙ cong (p ∙_) (rCancel (rCancel s₂)) ∙∙ sym (rUnit p))) (λ (H , p) → ΣPathP (refl , sym (assoc p (sym (rCancel s₂)) (rCancel s₂)) ∙∙ cong (p ∙_) (lCancel (rCancel s₂)) ∙∙ sym (rUnit p))) -- compose the equivalences sec≃ : (s : sec∙) → sec∙' s ≃ (s ≡ s) sec≃ = λ (s : sec∙) → compEquiv (isoToEquiv (secIso s)) (funExt∙≃ s s) -- p.9 Theorem 3 of Higher Types in HoTT sec∙Trunc : {n k : ℕ} → A (n + 1) (k) sec∙Trunc {n = 0} {k} isConnX Y = isContr→isProp (s₀ , λ s → funExt∙ (s₀∙∼s s)) where sec∙ : Type (ℓ-max ℓ ℓ') sec∙ = Π∙ X (λ x → typ (fst (Y x))) (pt (fst (Y (pt X)))) module _ where -- trivial section s₀ : sec∙ s₀ = (λ a → pt (fst (Y a))) , refl -- abbreviations s₀₁ = fst s₀ ⋆ = pt X -- the k-connected map 𝟙 → X f : Unit → typ X f tt = ⋆ -- proof that f is k-connected fkconn : isConnectedFun k f fkconn = UnitConnectedFunElim isConnX f -- notation module _ (s : sec∙) where s₁ = fst s s₂ = snd s -- the regular homotopies between the trivial section and s coincide with the -- identity type s₀₁ ⋆ ≡ s₁ ⋆ -- the Unit type will be eliminated in the next step IsoHtpy𝟙Idpt : Iso (s₀₁ ∼ s₁) (Unit → s₀₁ ⋆ ≡ s₁ ⋆) IsoHtpy𝟙Idpt = elim.isIsoPrecompose f k (λ (x : typ X) → (s₀₁ x ≡ s₁ x) , HL← (HL→ (snd (Y x)) (s₀₁ x) (s₁ x))) fkconn IsoHtpyIdpt : Iso (s₀₁ ∼ s₁) (s₀₁ ⋆ ≡ s₁ ⋆) IsoHtpyIdpt = compIso IsoHtpy𝟙Idpt (𝟙-universal (s₀₁ ⋆ ≡ s₁ ⋆)) -- judgementally, -- (s₀ ∙∼ s) ≡ (Σ[ h ∈ (s₀₁ ∼ s₁) ] (h ⋆ ≡ (snd s₀) ∙ s₂ ⁻¹)) -- The right inverse of IsoHtpyIdpt gives such a pointed homotopy s₀∙∼s : s₀ ∙∼ s fst s₀∙∼s = Iso.inv IsoHtpyIdpt (refl ∙ s₂ ⁻¹) snd s₀∙∼s = Iso.inv IsoHtpyIdpt (refl ∙ s₂ ⁻¹) ⋆ ≡⟨ refl ⟩ Iso.fun IsoHtpyIdpt (Iso.inv IsoHtpyIdpt (refl ∙ s₂ ⁻¹)) ≡⟨ Iso.rightInv IsoHtpyIdpt (refl ∙ s₂ ⁻¹) ⟩ refl ∙ s₂ ⁻¹ ∎ sec∙Trunc {n = 1} {k} isConnX Y = truncSelfId→truncId {n = 0} (λ s → EquivPresHLevel {n = 1} (sec≃ s) (sec∙Trunc {n = 0} {k} isConnX λ x → ((s .fst x ≡ s .fst x) , refl) , (snd (Y x) (s .fst x) (s .fst x)))) where open PointSec 2 k isConnX Y open PointSecProps sec∙Trunc {n = suc (suc m)} {k} isConnX Y = -- suffices to show that loop spaces are truncated truncSelfId→truncId -- each self-identity type of a section s is equivalent to a type of sections λ s → EquivPresHLevel (sec≃ s) -- that the induction hypothesis can be applied to (sec∙Trunc {n = suc m} isConnX λ x → ((s .fst x ≡ s .fst x) , refl) , snd (Y x) (s .fst x) (s .fst x)) where open PointSec (suc (suc m) + 1) k isConnX Y open PointSecProps -- alternate version of sec∙Trunc with bound on n instead of adding a bound sec∙Trunc' : {n k : ℕ} (1≤n : 1 ≤ n) → A n k sec∙Trunc' {n = n} {k = k} 1≤n = +Type→≤Type 1 (λ n → A n k) (λ r isConnX Y → sec∙Trunc {n = r} {k = k} isConnX Y) n 1≤n module _ (X : Pointed ℓ) (Y : Pointed ℓ') where pointed-maps-truncated : {n k : ℕ} → 1 ≤ n → isConnected (k + 1) (typ X) → isOfHLevel (n + k) (typ Y) → isOfHLevel (n) (X →∙ Y) pointed-maps-truncated {n = n} 1≤n connX truncY = sec∙Trunc' X 1≤n connX λ _ → Y , truncY
{ "alphanum_fraction": 0.5217117684, "avg_line_length": 40.4840764331, "ext": "agda", "hexsha": "2b37bc3e3eda7e0ba8e6b02b59d83f6514ba057a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_path": "Cubical/Homotopy/PointedFibration.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Schippmunk/cubical", "max_issues_repo_path": "Cubical/Homotopy/PointedFibration.agda", "max_line_length": 209, "max_stars_count": null, "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_path": "Cubical/Homotopy/PointedFibration.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2271, "size": 6356 }
{-# OPTIONS --without-K #-} module Wow-It-is-FV where open import Agda.Builtin.Nat open import Agda.Builtin.Equality open import Agda.Primitive levelEq : lzero ≡ lzero levelEq = refl levelEq′ : lsuc lzero ≡ lsuc lzero levelEq′ = refl trans : {l : Level} {Q : Set l} {a b c : Q} → a ≡ b → b ≡ c → a ≡ c trans refl refl = refl J : {A : Set} (P : (x y : A) → x ≡ y → Set) → ((x : A) → P x x refl) → (x y : A) (xy : x ≡ y) → P x y xy J P p x .x refl = p x cong : {A B : Set} (f : A → B) → {m n : A} → m ≡ n → f m ≡ f n cong f refl = refl sym : {A : Set} {m n : A} → m ≡ n → n ≡ m sym refl = refl theorem : suc zero + suc zero ≡ _ theorem = refl theorem′ : 1 + 1 ≡ 2 theorem′ = refl trivialEq : {a : _} {A : Set a} → A ≡ A trivialEq = refl trivialEq′ : ∀ {a} {A : Set a} → A ≡ A trivialEq′ = refl trivialEq′′ : ∀ a b → a + b ≡ a + b trivialEq′′ a b = refl trans′ : ∀ {a} {A : Set a} (a b c : A) → a ≡ b → b ≡ c → a ≡ c trans′ a .a c refl bc = bc data _<=_ : (a b : Nat) → Set where 0ltn : ∀ {n} → 0 <= n nltm : ∀ {n m} → n <= m → suc n <= suc m 7lt13 : 7 <= 13 7lt13 = nltm (nltm (nltm (nltm (nltm (nltm (nltm 0ltn)))))) abc : ∀ {a b c} → a <= b → b <= c → a <= c abc 0ltn bc = 0ltn abc (nltm ab) (nltm bc) = nltm (abc ab bc) data ⊥ : Set where ridiculous : ⊥ → ⊥ ridiculous a = a ridiculous′ : 1 ≡ 0 → ⊥ ridiculous′ () ⊥-elim : ∀ {a} {A : Set a} → ⊥ → A ⊥-elim () 4lt3 : 4 <= 3 → ⊥ 4lt3 (nltm (nltm (nltm ()))) infix 3 ¬_ ¬_ : ∀ {a} → Set a → Set a ¬ P = P → ⊥ _!=_ : ∀ {a} {A : Set a} → A → A → Set a x != y = ¬ x ≡ y _≡⟨_⟩_ : ∀ {A : Set} (x : A) {y z : A} → x ≡ y → y ≡ z → x ≡ z _ ≡⟨ refl ⟩ c = c _QED : ∀ {A : Set} (x : A) → x ≡ x _ QED = refl lemma₀ : ∀ n → n + 0 ≡ n lemma₀ zero = refl lemma₀ (suc n) = cong suc (lemma₀ n) lemma₁ : ∀ n m → suc (n + m) ≡ n + suc m lemma₁ zero _ = refl lemma₁ (suc n) m = cong suc (lemma₁ n m) comm : ∀ n m → n + m ≡ m + n comm zero n = sym (lemma₀ n) comm (suc n) m = suc n + m ≡⟨ refl ⟩ suc (n + m) ≡⟨ cong suc (comm n m) ⟩ suc (m + n) ≡⟨ lemma₁ m n ⟩ m + suc n QED infixr 2 _≡⟨_⟩_ infix 3 _QED
{ "alphanum_fraction": 0.4923591213, "avg_line_length": 20.1346153846, "ext": "agda", "hexsha": "d1b49b7dde0c2e2908c1430c819d52bc0fca3e27", "lang": "Agda", "max_forks_count": 7, "max_forks_repo_forks_event_max_datetime": "2021-09-24T16:49:13.000Z", "max_forks_repo_forks_event_min_datetime": "2018-10-09T03:41:20.000Z", "max_forks_repo_head_hexsha": "a875d10f9a25d28e8e4f77e6ca32625a1e389227", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ice1000/Books", "max_forks_repo_path": "Wow-FV-zh/Wow-It-is-FV.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "a875d10f9a25d28e8e4f77e6ca32625a1e389227", "max_issues_repo_issues_event_max_datetime": "2018-10-16T19:29:15.000Z", "max_issues_repo_issues_event_min_datetime": "2018-10-09T22:48:45.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "ice1000/Books", "max_issues_repo_path": "Wow-FV-zh/Wow-It-is-FV.agda", "max_line_length": 62, "max_stars_count": 133, "max_stars_repo_head_hexsha": "a875d10f9a25d28e8e4f77e6ca32625a1e389227", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ice1000/Books", "max_stars_repo_path": "Obsolete/Wow-FV-zh/Wow-It-is-FV.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-05T10:37:03.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-08T16:02:07.000Z", "num_tokens": 1013, "size": 2094 }
open import Nat open import Prelude open import List open import contexts open import core module lemmas-general where Coerce-unicity : ∀{r ex1 ex2} → Coerce r := ex1 → Coerce r := ex2 → ex1 == ex2 Coerce-unicity CoerceUnit CoerceUnit = refl Coerce-unicity (CoercePair C1 C2) (CoercePair C3 C4) rewrite Coerce-unicity C1 C3 | Coerce-unicity C2 C4 = refl Coerce-unicity (CoerceCtor C1) (CoerceCtor C2) rewrite Coerce-unicity C1 C2 = refl Fuel-depletion-unicity : ∀{⛽ ⛽↓1 ⛽↓2} → ⛽ ⛽⇓ ⛽↓1 → ⛽ ⛽⇓ ⛽↓2 → ⛽↓1 == ⛽↓2 Fuel-depletion-unicity CF∞ CF∞ = refl Fuel-depletion-unicity CF⛽ CF⛽ = refl
{ "alphanum_fraction": 0.5381630013, "avg_line_length": 28.6296296296, "ext": "agda", "hexsha": "c9c8731243287a64c0b514d7097b37edfe2efa55", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a8f9299090d95f4ef1a6c2f15954c2981c0ee25c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnat-myth-", "max_forks_repo_path": "lemmas-general.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a8f9299090d95f4ef1a6c2f15954c2981c0ee25c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnat-myth-", "max_issues_repo_path": "lemmas-general.agda", "max_line_length": 55, "max_stars_count": 1, "max_stars_repo_head_hexsha": "a8f9299090d95f4ef1a6c2f15954c2981c0ee25c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnat-myth-", "max_stars_repo_path": "lemmas-general.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-19T23:42:31.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-19T23:42:31.000Z", "num_tokens": 278, "size": 773 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Lexicographic ordering of lists ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Relation.Binary.Lex.Core where open import Data.Empty using (⊥; ⊥-elim) open import Data.Unit.Base using (⊤; tt) open import Function using (_∘_; flip; id) open import Data.Product using (_,_; proj₁; proj₂) open import Data.List.Base using (List; []; _∷_) open import Level using (_⊔_) open import Relation.Nullary using (Dec; yes; no; ¬_) open import Relation.Binary open import Data.List.Relation.Binary.Pointwise using (Pointwise; []; _∷_; head; tail) -- The lexicographic ordering itself can be either strict or non-strict, -- depending on whether type P is inhabited. data Lex {a ℓ₁ ℓ₂} {A : Set a} (P : Set) (_≈_ : Rel A ℓ₁) (_≺_ : Rel A ℓ₂) : Rel (List A) (a ⊔ ℓ₁ ⊔ ℓ₂) where base : P → Lex P _≈_ _≺_ [] [] halt : ∀ {y ys} → Lex P _≈_ _≺_ [] (y ∷ ys) this : ∀ {x xs y ys} (x≺y : x ≺ y) → Lex P _≈_ _≺_ (x ∷ xs) (y ∷ ys) next : ∀ {x xs y ys} (x≈y : x ≈ y) (xs<ys : Lex P _≈_ _≺_ xs ys) → Lex P _≈_ _≺_ (x ∷ xs) (y ∷ ys) -- Properties module _ {a ℓ₁ ℓ₂} {A : Set a} {P : Set} {_≈_ : Rel A ℓ₁} {_≺_ : Rel A ℓ₂} where private _≋_ = Pointwise _≈_ _<_ = Lex P _≈_ _≺_ ¬≤-this : ∀ {x y xs ys} → ¬ (x ≈ y) → ¬ (x ≺ y) → ¬ (x ∷ xs) < (y ∷ ys) ¬≤-this x≉y x≮y (this x≺y) = x≮y x≺y ¬≤-this x≉y x≮y (next x≈y xs<ys) = x≉y x≈y ¬≤-next : ∀ {x y xs ys} → ¬ x ≺ y → ¬ xs < ys → ¬ (x ∷ xs) < (y ∷ ys) ¬≤-next x≮y xs≮ys (this x≺y) = x≮y x≺y ¬≤-next x≮y xs≮ys (next _ xs<ys) = xs≮ys xs<ys transitive : IsEquivalence _≈_ → _≺_ Respects₂ _≈_ → Transitive _≺_ → Transitive _<_ transitive eq resp tr = trans where trans : Transitive (Lex P _≈_ _≺_) trans (base p) (base _) = base p trans (base y) halt = halt trans halt (this y≺z) = halt trans halt (next y≈z ys<zs) = halt trans (this x≺y) (this y≺z) = this (tr x≺y y≺z) trans (this x≺y) (next y≈z ys<zs) = this (proj₁ resp y≈z x≺y) trans (next x≈y xs<ys) (this y≺z) = this (proj₂ resp (IsEquivalence.sym eq x≈y) y≺z) trans (next x≈y xs<ys) (next y≈z ys<zs) = next (IsEquivalence.trans eq x≈y y≈z) (trans xs<ys ys<zs) antisymmetric : Symmetric _≈_ → Irreflexive _≈_ _≺_ → Asymmetric _≺_ → Antisymmetric _≋_ _<_ antisymmetric sym ir asym = as where as : Antisymmetric _≋_ _<_ as (base _) (base _) = [] as halt () as (this x≺y) (this y≺x) = ⊥-elim (asym x≺y y≺x) as (this x≺y) (next y≈x ys<xs) = ⊥-elim (ir (sym y≈x) x≺y) as (next x≈y xs<ys) (this y≺x) = ⊥-elim (ir (sym x≈y) y≺x) as (next x≈y xs<ys) (next y≈x ys<xs) = x≈y ∷ as xs<ys ys<xs respects₂ : IsEquivalence _≈_ → _≺_ Respects₂ _≈_ → _<_ Respects₂ _≋_ respects₂ eq (resp₁ , resp₂) = resp¹ , resp² where open IsEquivalence eq using (sym; trans) resp¹ : ∀ {xs} → Lex P _≈_ _≺_ xs Respects _≋_ resp¹ [] xs<[] = xs<[] resp¹ (_ ∷ _) halt = halt resp¹ (x≈y ∷ _) (this z≺x) = this (resp₁ x≈y z≺x) resp¹ (x≈y ∷ xs≋ys) (next z≈x zs<xs) = next (trans z≈x x≈y) (resp¹ xs≋ys zs<xs) resp² : ∀ {ys} → flip (Lex P _≈_ _≺_) ys Respects _≋_ resp² [] []<ys = []<ys resp² (x≈z ∷ _) (this x≺y) = this (resp₂ x≈z x≺y) resp² (x≈z ∷ xs≋zs) (next x≈y xs<ys) = next (trans (sym x≈z) x≈y) (resp² xs≋zs xs<ys) decidable : Dec P → Decidable _≈_ → Decidable _≺_ → Decidable _<_ decidable (yes p) dec-≈ dec-≺ [] [] = yes (base p) decidable (no ¬p) dec-≈ dec-≺ [] [] = no λ{(base p) → ¬p p} decidable dec-P dec-≈ dec-≺ [] (y ∷ ys) = yes halt decidable dec-P dec-≈ dec-≺ (x ∷ xs) [] = no λ() decidable dec-P dec-≈ dec-≺ (x ∷ xs) (y ∷ ys) with dec-≺ x y ... | yes x≺y = yes (this x≺y) ... | no x≮y with dec-≈ x y ... | no x≉y = no (¬≤-this x≉y x≮y) ... | yes x≈y with decidable dec-P dec-≈ dec-≺ xs ys ... | yes xs<ys = yes (next x≈y xs<ys) ... | no xs≮ys = no (¬≤-next x≮y xs≮ys)
{ "alphanum_fraction": 0.4862508384, "avg_line_length": 40.6636363636, "ext": "agda", "hexsha": "1bbd85c1d46a18b17529502206f0399551c663ca", "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/Lex/Core.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/Lex/Core.agda", "max_line_length": 73, "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/Lex/Core.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1854, "size": 4473 }
-- ---------------------------------------------------------------------- -- The Agda σ-library -- -- Substitutions -- ---------------------------------------------------------------------- -- A substitution on T is defined as a mapping from -- indices to T (w/ explicit bounds). -- -- Since the domain is bounded, we may think -- of substitutions as vectors. module Sigma.Subst.Base where open import Data.Nat using (ℕ; suc; zero; _+_) open import Data.Fin using (Fin; zero; suc) open import Function using (_∘_) open import Data.Product using (_×_) renaming ( _,_ to ⟨_,_⟩ ) -- ---------------------------------------------------------------------- -- A subsitution σ : 𝕀ⁿ → T is denoted { i ↦ x : i ∈ 𝕀ⁿ, x ∈ T } Sub : Set → ℕ → Set Sub T m = Fin m → T -- The empty subsitution. -- Note that 𝕀⁰ ≡ ⊥. We note σ : 𝕀⁰ → T by [] -- Intuitively, this mimics an empty vector. [] : ∀ { T } → Sub T 0 [] = λ () infixr 5 _∷_ -- The σ-cons operator ∷ ∶ T → (𝕀ⁿ → T) → (𝕀¹⁺ⁿ → T) -- -- Intuitively, the σ-cons operator mimics the -- semantics of cons operator on vectors. -- -- x ∷ σ = { 0 ↦ x } ∪ { 1 + i ↦ σ i : i ∈ 𝕀ⁿ } _∷_ : ∀ { n } { T } → T → Sub T n → Sub T (1 + n) (x ∷ σ) zero = x (x ∷ σ) (suc n) = σ n [_] : ∀ { T } → T → Sub T 1 [ x ] = x ∷ [] head : ∀ { n } { T } → Sub T (1 + n) → T head σ = σ zero tail : ∀ { n } { T } → Sub T (1 + n) → Sub T n tail σ = σ ∘ suc map : ∀ { n } { T U } → (T → U) → Sub T n → Sub U n map f σ = f ∘ σ uncons : ∀ { n } { T } → Sub T (1 + n) → T × Sub T n  uncons σ = ⟨ head σ , tail σ ⟩ infixr 5 _++_ -- The σ-append operator ++ : (𝕀ᵐ → T) → (𝕀ⁿ → T) → (𝕀ᵐ⁺ⁿ → T) -- -- σ₁ ++ σ₂ = { i ↦ σ₁ i : i ∈ 𝕀ᵐ⁺ⁿ, i < m } ∪ { i ↦ σ₂ i : i ∈ 𝕀ᵐ⁺ⁿ, i ≥ m } _++_ : ∀ { m n } { T } → Sub T m → Sub T n → Sub T (m + n) _++_ {zero} σ₁ σ₂ = σ₂ _++_ {suc m} σ₁ σ₂ = σ₁ zero ∷ (σ₁ ∘ suc) ++ σ₂
{ "alphanum_fraction": 0.4451682953, "avg_line_length": 25.2328767123, "ext": "agda", "hexsha": "ae1d17a6b7e6c6824d2e50be2d9d1fe51c992d63", "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": "bb895fa8a3ccbefbd2c4a135c79744ba06895be7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "johnyob/agda-sigma", "max_forks_repo_path": "src/Sigma/Subst/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bb895fa8a3ccbefbd2c4a135c79744ba06895be7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "johnyob/agda-sigma", "max_issues_repo_path": "src/Sigma/Subst/Base.agda", "max_line_length": 77, "max_stars_count": null, "max_stars_repo_head_hexsha": "bb895fa8a3ccbefbd2c4a135c79744ba06895be7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "johnyob/agda-sigma", "max_stars_repo_path": "src/Sigma/Subst/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 724, "size": 1842 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Relation.Binary where open import Cubical.Relation.Binary.Base public open import Cubical.Relation.Binary.Properties public open import Cubical.Relation.Binary.Fiberwise public
{ "alphanum_fraction": 0.8073770492, "avg_line_length": 34.8571428571, "ext": "agda", "hexsha": "cb9073a270920e25a56454967eee5d54039f6f54", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_path": "Cubical/Relation/Binary.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Schippmunk/cubical", "max_issues_repo_path": "Cubical/Relation/Binary.agda", "max_line_length": 53, "max_stars_count": null, "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_path": "Cubical/Relation/Binary.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 54, "size": 244 }
module RewriteAndWhere where open import Common.Equality data ℕ : Set where zero : ℕ good : (a b : ℕ) → a ≡ b → b ≡ a good a b eq with a | eq ... | .b | refl = foo where foo : b ≡ b foo = refl mutual aux : (a b : ℕ)(w : ℕ) → w ≡ b → b ≡ w aux a b .b refl = foo where foo : b ≡ b foo = refl good₂ : (a b : ℕ) → a ≡ b → b ≡ a good₂ a b eq = aux a b a eq bad : (a b : ℕ) → a ≡ b → b ≡ a bad a b eq rewrite eq = foo where foo : b ≡ b foo rewrite sym eq = bar where bar : a ≡ a bar = refl
{ "alphanum_fraction": 0.4847396768, "avg_line_length": 16.3823529412, "ext": "agda", "hexsha": "717142e7a4c2e750eb2959f2a3f36e834103cc92", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/RewriteAndWhere.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/RewriteAndWhere.agda", "max_line_length": 40, "max_stars_count": 1, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/succeed/RewriteAndWhere.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": 226, "size": 557 }
{-# OPTIONS --cubical --safe #-} module Strict.Properties where open import Path open import Level open import Strict open import Agda.Builtin.Strict open import Function $!-≡ : {A : Type a} {B : A → Type b} → (f : ∀ x → B x) → ∀ x → (f $! x) ≡ f x $!-≡ f x = builtin-eq-to-path (primForceLemma x f) $!≡$ : {A : Type a} {B : A → Type b} → _$!_ {A = A} {B = B} ≡ _$_ {A = A} {B = B} $!≡$ i f x = $!-≡ f x i
{ "alphanum_fraction": 0.5390243902, "avg_line_length": 25.625, "ext": "agda", "hexsha": "f5382905c09cef1c68aa54bb00211da6bdcadb3b", "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": "Strict/Properties.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": "Strict/Properties.agda", "max_line_length": 81, "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": "Strict/Properties.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": 169, "size": 410 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Some derivable properties ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Algebra module Algebra.Properties.Group {g₁ g₂} (G : Group g₁ g₂) where open Group G open import Algebra.FunctionProperties _≈_ open import Relation.Binary.Reasoning.Setoid setoid open import Function open import Data.Product ⁻¹-involutive : ∀ x → x ⁻¹ ⁻¹ ≈ x ⁻¹-involutive x = begin x ⁻¹ ⁻¹ ≈⟨ sym $ identityʳ _ ⟩ x ⁻¹ ⁻¹ ∙ ε ≈⟨ ∙-congˡ $ sym (inverseˡ _) ⟩ x ⁻¹ ⁻¹ ∙ (x ⁻¹ ∙ x) ≈⟨ sym $ assoc _ _ _ ⟩ x ⁻¹ ⁻¹ ∙ x ⁻¹ ∙ x ≈⟨ ∙-congʳ $ inverseˡ _ ⟩ ε ∙ x ≈⟨ identityˡ _ ⟩ x ∎ private left-helper : ∀ x y → x ≈ (x ∙ y) ∙ y ⁻¹ left-helper x y = begin x ≈⟨ sym (identityʳ x) ⟩ x ∙ ε ≈⟨ ∙-congˡ $ sym (inverseʳ y) ⟩ x ∙ (y ∙ y ⁻¹) ≈⟨ sym (assoc x y (y ⁻¹)) ⟩ (x ∙ y) ∙ y ⁻¹ ∎ right-helper : ∀ x y → y ≈ x ⁻¹ ∙ (x ∙ y) right-helper x y = begin y ≈⟨ sym (identityˡ y) ⟩ ε ∙ y ≈⟨ ∙-congʳ $ sym (inverseˡ x) ⟩ (x ⁻¹ ∙ x) ∙ y ≈⟨ assoc (x ⁻¹) x y ⟩ x ⁻¹ ∙ (x ∙ y) ∎ left-identity-unique : ∀ x y → x ∙ y ≈ y → x ≈ ε left-identity-unique x y eq = begin x ≈⟨ left-helper x y ⟩ (x ∙ y) ∙ y ⁻¹ ≈⟨ ∙-congʳ eq ⟩ y ∙ y ⁻¹ ≈⟨ inverseʳ y ⟩ ε ∎ right-identity-unique : ∀ x y → x ∙ y ≈ x → y ≈ ε right-identity-unique x y eq = begin y ≈⟨ right-helper x y ⟩ x ⁻¹ ∙ (x ∙ y) ≈⟨ refl ⟨ ∙-cong ⟩ eq ⟩ x ⁻¹ ∙ x ≈⟨ inverseˡ x ⟩ ε ∎ identity-unique : ∀ {x} → Identity x _∙_ → x ≈ ε identity-unique {x} id = left-identity-unique x x (proj₂ id x) left-inverse-unique : ∀ x y → x ∙ y ≈ ε → x ≈ y ⁻¹ left-inverse-unique x y eq = begin x ≈⟨ left-helper x y ⟩ (x ∙ y) ∙ y ⁻¹ ≈⟨ ∙-congʳ eq ⟩ ε ∙ y ⁻¹ ≈⟨ identityˡ (y ⁻¹) ⟩ y ⁻¹ ∎ right-inverse-unique : ∀ x y → x ∙ y ≈ ε → y ≈ x ⁻¹ right-inverse-unique x y eq = begin y ≈⟨ sym (⁻¹-involutive y) ⟩ y ⁻¹ ⁻¹ ≈⟨ ⁻¹-cong (sym (left-inverse-unique x y eq)) ⟩ x ⁻¹ ∎
{ "alphanum_fraction": 0.4527117884, "avg_line_length": 30.5616438356, "ext": "agda", "hexsha": "b8f9b423bae2f44ce9794d5287f56c425ffa9b3e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Properties/Group.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Properties/Group.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Properties/Group.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 965, "size": 2231 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties related to All ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Vec.Relation.Unary.All.Properties where open import Data.List using ([]; _∷_) open import Data.List.Relation.Unary.All as List using ([]; _∷_) open import Data.Product as Prod using (_×_; _,_; uncurry; uncurry′) open import Data.Vec as Vec open import Data.Vec.Relation.Unary.All as All using (All; []; _∷_) open import Function using (_∘_; id) open import Function.Inverse using (_↔_; inverse) open import Relation.Unary using (Pred) renaming (_⊆_ to _⋐_) open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong; cong₂; →-to-⟶) ------------------------------------------------------------------------ -- map module _ {a b p} {A : Set a} {B : Set b} {P : Pred B p} {f : A → B} where map⁺ : ∀ {n} {xs : Vec A n} → All (P ∘ f) xs → All P (map f xs) map⁺ [] = [] map⁺ (px ∷ pxs) = px ∷ map⁺ pxs map⁻ : ∀ {n} {xs : Vec A n} → All P (map f xs) → All (P ∘ f) xs map⁻ {xs = []} [] = [] map⁻ {xs = _ ∷ _} (px ∷ pxs) = px ∷ map⁻ pxs -- A variant of All.map module _ {a b p q} {A : Set a} {B : Set b} {f : A → B} {P : Pred A p} {Q : Pred B q} where gmap : ∀ {n} → P ⋐ Q ∘ f → All P {n} ⋐ All Q {n} ∘ map f gmap g = map⁺ ∘ All.map g ------------------------------------------------------------------------ -- _++_ module _ {a n p} {A : Set a} {P : Pred A p} where ++⁺ : ∀ {m} {xs : Vec A m} {ys : Vec A n} → All P xs → All P ys → All P (xs ++ ys) ++⁺ [] pys = pys ++⁺ (px ∷ pxs) pys = px ∷ ++⁺ pxs pys ++ˡ⁻ : ∀ {m} (xs : Vec A m) {ys : Vec A n} → All P (xs ++ ys) → All P xs ++ˡ⁻ [] _ = [] ++ˡ⁻ (x ∷ xs) (px ∷ pxs) = px ∷ ++ˡ⁻ xs pxs ++ʳ⁻ : ∀ {m} (xs : Vec A m) {ys : Vec A n} → All P (xs ++ ys) → All P ys ++ʳ⁻ [] pys = pys ++ʳ⁻ (x ∷ xs) (px ∷ pxs) = ++ʳ⁻ xs pxs ++⁻ : ∀ {m} (xs : Vec A m) {ys : Vec A n} → All P (xs ++ ys) → All P xs × All P ys ++⁻ [] p = [] , p ++⁻ (x ∷ xs) (px ∷ pxs) = Prod.map₁ (px ∷_) (++⁻ _ pxs) ++⁺∘++⁻ : ∀ {m} (xs : Vec A m) {ys : Vec A n} → (p : All P (xs ++ ys)) → uncurry′ ++⁺ (++⁻ xs p) ≡ p ++⁺∘++⁻ [] p = refl ++⁺∘++⁻ (x ∷ xs) (px ∷ pxs) = cong (px ∷_) (++⁺∘++⁻ xs pxs) ++⁻∘++⁺ : ∀ {m} {xs : Vec A m} {ys : Vec A n} → (p : All P xs × All P ys) → ++⁻ xs (uncurry ++⁺ p) ≡ p ++⁻∘++⁺ ([] , pys) = refl ++⁻∘++⁺ (px ∷ pxs , pys) rewrite ++⁻∘++⁺ (pxs , pys) = refl ++↔ : ∀ {m} {xs : Vec A m} {ys : Vec A n} → (All P xs × All P ys) ↔ All P (xs ++ ys) ++↔ {xs = xs} = inverse (uncurry ++⁺) (++⁻ xs) ++⁻∘++⁺ (++⁺∘++⁻ xs) ------------------------------------------------------------------------ -- concat module _ {a m p} {A : Set a} {P : Pred A p} where concat⁺ : ∀ {n} {xss : Vec (Vec A m) n} → All (All P) xss → All P (concat xss) concat⁺ [] = [] concat⁺ (pxs ∷ pxss) = ++⁺ pxs (concat⁺ pxss) concat⁻ : ∀ {n} (xss : Vec (Vec A m) n) → All P (concat xss) → All (All P) xss concat⁻ [] [] = [] concat⁻ (xs ∷ xss) pxss = ++ˡ⁻ xs pxss ∷ concat⁻ xss (++ʳ⁻ xs pxss) ------------------------------------------------------------------------ -- toList module _ {a p} {A : Set a} {P : A → Set p} where toList⁺ : ∀ {n} {xs : Vec A n} → All P xs → List.All P (toList xs) toList⁺ [] = [] toList⁺ (px ∷ pxs) = px ∷ toList⁺ pxs toList⁻ : ∀ {n} {xs : Vec A n} → List.All P (toList xs) → All P xs toList⁻ {xs = []} [] = [] toList⁻ {xs = x ∷ xs} (px ∷ pxs) = px ∷ toList⁻ pxs ------------------------------------------------------------------------ -- fromList module _ {a p} {A : Set a} {P : A → Set p} where fromList⁺ : ∀ {xs} → List.All P xs → All P (fromList xs) fromList⁺ [] = [] fromList⁺ (px ∷ pxs) = px ∷ fromList⁺ pxs fromList⁻ : ∀ {xs} → All P (fromList xs) → List.All P xs fromList⁻ {[]} [] = [] fromList⁻ {x ∷ xs} (px ∷ pxs) = px ∷ (fromList⁻ pxs) ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 0.16 All-map = map⁺ {-# WARNING_ON_USAGE All-map "Warning: All-map was deprecated in v0.16. Please use map⁺ instead." #-} map-All = map⁻ {-# WARNING_ON_USAGE map-All "Warning: map-All was deprecated in v0.16. Please use map⁻ instead." #-} All-++⁺ = ++⁺ {-# WARNING_ON_USAGE All-++⁺ "Warning: All-++⁺ was deprecated in v0.16. Please use ++⁺ instead." #-} All-++ˡ⁻ = ++ˡ⁻ {-# WARNING_ON_USAGE All-++ˡ⁻ "Warning: All-++ˡ⁻ was deprecated in v0.16. Please use ++ˡ⁻ instead." #-} All-++ʳ⁻ = ++ʳ⁻ {-# WARNING_ON_USAGE All-++ʳ⁻ "Warning: All-++ʳ⁻ was deprecated in v0.16. Please use ++ʳ⁻ instead." #-} All-++⁻ = ++⁻ {-# WARNING_ON_USAGE All-++⁻ "Warning: All-++⁻ was deprecated in v0.16. Please use ++⁻ instead." #-} All-++⁺∘++⁻ = ++⁺∘++⁻ {-# WARNING_ON_USAGE All-++⁺∘++⁻ "Warning: All-++⁺∘++⁻ was deprecated in v0.16. Please use ++⁺∘++⁻ instead." #-} All-++⁻∘++⁺ = ++⁻∘++⁺ {-# WARNING_ON_USAGE All-++⁻∘++⁺ "Warning: All-++⁻∘++⁺ was deprecated in v0.16. Please use ++⁻∘++⁺ instead." #-} All-concat⁺ = concat⁺ {-# WARNING_ON_USAGE All-concat⁺ "Warning: All-concat⁺ was deprecated in v0.16. Please use concat⁺ instead." #-} All-concat⁻ = concat⁻ {-# WARNING_ON_USAGE All-concat⁻ "Warning: All-concat⁻ was deprecated in v0.16. Please use concat⁻ instead." #-}
{ "alphanum_fraction": 0.4408396947, "avg_line_length": 31.4972677596, "ext": "agda", "hexsha": "ed878b33d9bea7d0dffa3d9860ea55877defb3ac", "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/Relation/Unary/All/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/Relation/Unary/All/Properties.agda", "max_line_length": 73, "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/Relation/Unary/All/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2198, "size": 5764 }
{- 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 -} module Haskell.Modules.RWS.Lens where open import Haskell.Modules.RWS open import Haskell.Prelude open import Optics.All private variable Ev Wr St : Set A B C : Set -- Lens functionality -- -- If we make RWS work for different level State types, we will break use and -- modify because Lens does not support different levels, we define use and -- modify' here for RoundManager. We are ok as long as we can keep -- RoundManager in Set. If we ever need to make RoundManager at some higher -- Level, we will have to consider making Lens level-agnostic. Preliminary -- exploration by @cwjnkins showed this to be somewhat painful in particular -- around composition, so we are not pursuing it for now. use : Lens St A → RWS Ev Wr St A use f = gets (_^∙ f) modifyL : Lens St A → (A → A) → RWS Ev Wr St Unit modifyL l f = modify (over l f) syntax modifyL l f = l %= f setL : Lens St A → A → RWS Ev Wr St Unit setL l x = l %= const x syntax setL l x = l ∙= x setL? : Lens St (Maybe A) → A → RWS Ev Wr St Unit setL? l x = l ∙= just x syntax setL? l x = l ?= x
{ "alphanum_fraction": 0.7083015994, "avg_line_length": 32.0243902439, "ext": "agda", "hexsha": "f6f495f3d72a1cae4d9b873168687fd372852bc0", "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/Haskell/Modules/RWS/Lens.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/Haskell/Modules/RWS/Lens.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/Haskell/Modules/RWS/Lens.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 378, "size": 1313 }
module Nat where open import Base data Nat : Set where zero : Nat suc : Nat -> Nat _=N_ : Nat -> Nat -> Set zero =N zero = True zero =N suc _ = False suc _ =N zero = False suc n =N suc m = n =N m refN : Refl _=N_ refN {zero} = T refN {suc n} = refN {n} symN : Sym _=N_ symN {zero}{zero} p = p symN {suc n}{suc m} p = symN {n}{m} p symN {zero}{suc _} () symN {suc _}{zero} () transN : Trans _=N_ transN {zero }{zero }{zero } p _ = p transN {suc n}{suc m}{suc l} p q = transN {n}{m}{l} p q transN {zero }{zero }{suc _} _ () transN {zero }{suc _}{_ } () _ transN {suc _}{zero }{_ } () _ transN {suc _}{suc _}{zero } _ ()
{ "alphanum_fraction": 0.5605590062, "avg_line_length": 18.9411764706, "ext": "agda", "hexsha": "47a8167d93a174c54e0947c7847749fc9d2c2ad8", "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/univ/Nat.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/univ/Nat.agda", "max_line_length": 55, "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/univ/Nat.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 285, "size": 644 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category -- Power Functors, Exponentials over a Category C -- Mainly categories where the objects are functions (Fin n -> Obj) considered pointwise -- and then upgraded to Functors. module Categories.Functor.Power {o ℓ e} (C : Category o ℓ e) where open Category C open HomReasoning open import Level using (Level; _⊔_) open import Data.Nat using (ℕ; _+_; zero; suc; _<_) open import Data.Product using (_,_) open import Data.Fin using (Fin; inject+; raise; zero; suc; fromℕ<) open import Data.Sum using (_⊎_; inj₁; inj₂; map) renaming ([_,_] to ⟦_,_⟧; [_,_]′ to ⟦_,_⟧′) open import Data.Vec.N-ary hiding (curryⁿ) open import Function as Fun using (flip; _$_) renaming (_∘_ to _∙_; id to idf) open import Categories.Category.Product using (Product; _⁂_) open import Categories.Functor hiding (id) open import Categories.Functor.Bifunctor using (Bifunctor; overlap-×) private variable i j k : Level I I′ J J′ : Set i D E : Category i j k n n′ m m′ : ℕ Exp : Set i → Category _ _ _ Exp I = record { Obj = I → Obj ; _⇒_ = λ x y → ∀ i → x i ⇒ y i ; _≈_ = λ f g → ∀ i → f i ≈ g i ; id = λ _ → id ; _∘_ = λ f g i → f i ∘ g i ; assoc = λ _ → assoc ; sym-assoc = λ _ → sym-assoc ; identityˡ = λ _ → identityˡ ; identityʳ = λ _ → identityʳ ; identity² = λ _ → identity² ; equiv = record { refl = λ _ → refl ; sym = λ eq i → sym $ eq i ; trans = λ eq₁ eq₂ i → trans (eq₁ i) (eq₂ i) } ; ∘-resp-≈ = λ eq₁ eq₂ i → ∘-resp-≈ (eq₁ i) (eq₂ i) } Power : (n : ℕ) → Category o ℓ e Power n = Exp (Fin n) -- Convention: the ′ version is for a general index set, unprimed for a ℕ -- representing Fin n. So Powerfunctor D n is Exp C (Fin n) ⇒ D, i.e. -- essentially C ^ n ⇒ D. Powerfunctor′ : (D : Category o ℓ e) (I : Set i) → Set (i ⊔ e ⊔ ℓ ⊔ o) Powerfunctor′ D I = Functor (Exp I) D Powerfunctor : (D : Category o ℓ e) (n : ℕ) → Set (e ⊔ ℓ ⊔ o) Powerfunctor D n = Powerfunctor′ D (Fin n) -- With C = D, so Powerendo n is C ^ n => C Powerendo′ : (I : Set i) → Set (i ⊔ e ⊔ ℓ ⊔ o) Powerendo′ I = Powerfunctor′ C I Powerendo : (n : ℕ) → Set (e ⊔ ℓ ⊔ o) Powerendo n = Powerfunctor C n -- Hyperendo n m is C ^ n ⇒ C ^ m Hyperendo : (n m : ℕ) → Set (e ⊔ ℓ ⊔ o) Hyperendo n m = Functor (Power n) (Power m) -- Hyperendo′ I J is C ^ I → C ^ J Hyperendo′ : (I : Set i) (J : Set j) → Set (i ⊔ j ⊔ e ⊔ ℓ ⊔ o) Hyperendo′ I J = Functor (Exp I) (Exp J) -- Parallel composition of Hyperendo′ (via disjoint union of index sets) infixr 9 _par_ _par_ : (F : Hyperendo′ I I′) (G : Hyperendo′ J J′) → Hyperendo′ (I ⊎ J) (I′ ⊎ J′) F par G = record { F₀ = λ xs → ⟦ F.F₀ (xs ∙ inj₁) , G.F₀ (xs ∙ inj₂) ⟧′ ; F₁ = λ fs → ⟦ F.F₁ (fs ∙ inj₁) , G.F₁ (fs ∙ inj₂) ⟧ ; identity = ⟦ F.identity , G.identity ⟧ ; homomorphism = ⟦ F.homomorphism , G.homomorphism ⟧ ; F-resp-≈ = λ fs≈gs → ⟦ F.F-resp-≈ (fs≈gs ∙ inj₁) , G.F-resp-≈ (fs≈gs ∙ inj₂) ⟧ } where module F = Functor F module G = Functor G -- "flattening" means going from a general disjoint union of Fin to a single Fin, -- which has the effect of doing from Powerfunctor′ to Powerfunctor flattenP : (F : Powerfunctor′ D (Fin n ⊎ Fin m)) → Powerfunctor D (n + m) flattenP {n = n} {m = m} F = record { F₀ = λ As → F₀ (As ∙ pack) ; F₁ = λ fs → F₁ (fs ∙ pack) ; identity = identity ; homomorphism = homomorphism ; F-resp-≈ = λ fs≈gs → F-resp-≈ (fs≈gs ∙ pack) } where open Functor F pack = ⟦ inject+ m , raise n ⟧′ -- TODO unpackFun (and pack above) should be in stdlib private unpackFin : ∀ n → Fin (n + m) → Fin n ⊎ Fin m unpackFin zero f = inj₂ f unpackFin (suc n) zero = inj₁ zero unpackFin (suc n) (suc f) = map suc idf (unpackFin n f) -- needs a better name? unflattenP : Powerfunctor D (n + m) → Powerfunctor′ D (Fin n ⊎ Fin m) unflattenP {n = n} {m = m} F = record { F₀ = λ As → F₀ (As ∙ unpackFin _) ; F₁ = λ fs → F₁ (fs ∙ unpackFin _) ; identity = identity ; homomorphism = homomorphism ; F-resp-≈ = λ fs≈gs → F-resp-≈ (fs≈gs ∙ unpackFin _) } where open Functor F -- flatten a Hyperendo′ "on the right" when over a union of Fin flattenHʳ : (F : Hyperendo′ I (Fin n ⊎ Fin m)) → Hyperendo′ I (Fin (n + m)) flattenHʳ {n = n} {m = m} F = record { F₀ = λ As → F₀ As ∙ unpackFin n ; F₁ = λ fs → F₁ fs ∙ unpackFin n ; identity = identity ∙ unpackFin n ; homomorphism = homomorphism ∙ unpackFin n ; F-resp-≈ = λ fs≈gs → F-resp-≈ fs≈gs ∙ unpackFin n } where open Functor F -- flatten on both sides. flattenH : (F : Hyperendo′ (Fin n ⊎ Fin m) (Fin n′ ⊎ Fin m′)) → Hyperendo (n + m) (n′ + m′) flattenH = flattenHʳ ∙ flattenP -- Pretty syntax for flattening of parallel composition of Hyperendo infixr 9 _∥_ _∥_ : (F : Hyperendo n n′) (G : Hyperendo m m′) → Hyperendo (n + m) (n′ + m′) F ∥ G = flattenH (F par G) -- split is C ^ (I ⊎ J) to C ^ I × C ^ J, as a Functor split : Functor (Exp (I ⊎ J)) (Product (Exp I) (Exp J)) split = record { F₀ = λ As → As ∙ inj₁ , As ∙ inj₂ ; F₁ = λ fs → fs ∙ inj₁ , fs ∙ inj₂ ; identity = (λ _ → refl) , λ _ → refl ; homomorphism = (λ _ → refl) , λ _ → refl ; F-resp-≈ = λ eq → (λ i → eq (inj₁ i)) , λ i → eq (inj₂ i) } reduce′ : (H : Bifunctor C C C) (F : Powerendo′ I) (G : Powerendo′ J) → Powerendo′ (I ⊎ J) reduce′ H F G = H ∘F (F ⁂ G) ∘F split reduce : ∀ (H : Bifunctor C C C) {n m} (F : Powerendo n) (G : Powerendo m) → Powerendo (n + m) reduce H F G = flattenP $ reduce′ H F G flattenP-assocʳ : ∀ {n₁ n₂ n₃} (F : Powerendo′ (Fin n₁ ⊎ Fin n₂ ⊎ Fin n₃)) → Powerendo (n₁ + n₂ + n₃) flattenP-assocʳ {n₁} {n₂} {n₃} F = record { F₀ = λ As → F.F₀ (As ∙ pack) ; F₁ = λ fs → F.F₁ (fs ∙ pack) ; identity = F.identity ; homomorphism = F.homomorphism ; F-resp-≈ = λ fs≈gs → F.F-resp-≈ (fs≈gs ∙ pack) } where module F = Functor F pack = ⟦ inject+ n₃ ∙ inject+ n₂ , ⟦ inject+ n₃ ∙ raise n₁ , raise (n₁ + n₂) ⟧′ ⟧′ reduce2ʳ : ∀ (G : Bifunctor C C C) {n₁ n₂ n₃} (F₁ : Powerendo n₁) (F₂ : Powerendo n₂) (F₃ : Powerendo n₃) → Powerendo ((n₁ + n₂) + n₃) reduce2ʳ G F₁ F₂ F₃ = flattenP-assocʳ $ reduce′ G F₁ $ reduce′ G F₂ F₃ overlaps : (H : Bifunctor D D E) (F G : Powerfunctor′ D I) → Powerfunctor′ E I overlaps = overlap-× overlap2ʳ : (G : Bifunctor C C C) (F₁ F₂ F₃ : Powerendo n) → Powerendo n overlap2ʳ G F₁ F₂ F₃ = overlaps G F₁ (overlaps G F₂ F₃) -- select′ i always evaluates at i select′ : (i : I) → Powerendo′ I select′ i = record { F₀ = _$ i ; F₁ = _$ i ; identity = refl ; homomorphism = refl ; F-resp-≈ = _$ i } -- select (m < n) is really select′ (Fin n), but only for m < n select : m < n → Powerendo n select m<n = select′ (fromℕ< m<n) triv : (n : ℕ) → Hyperendo n n triv n = record { F₀ = idf ; F₁ = idf ; identity = λ _ → refl ; homomorphism = λ _ → refl ; F-resp-≈ = idf } -- pad a Hyperendo on the left and right by trivial (i.e. identity) endofunctors pad : ∀ (l r : ℕ) (F : Hyperendo n m) → Hyperendo ((l + n) + r) ((l + m) + r) pad l r F = (triv l ∥ F) ∥ triv r padˡ : ∀ (l : ℕ) (F : Hyperendo n m) → Hyperendo (l + n) (l + m) padˡ l F = triv l ∥ F padʳ : ∀ (r : ℕ) (F : Hyperendo n m) → Hyperendo (n + r) (m + r) padʳ r F = F ∥ triv r unary : Endofunctor C → Powerendo 1 unary F = record { F₀ = λ As → F.F₀ (As zero) ; F₁ = λ fs → F.F₁ (fs zero) ; identity = F.identity ; homomorphism = F.homomorphism ; F-resp-≈ = λ fs≈gs → F.F-resp-≈ (fs≈gs zero) } where module F = Functor F unaryH : Endofunctor C → Hyperendo 1 1 unaryH F = record { F₀ = λ As → F.F₀ ∙ As ; F₁ = λ fs → F.F₁ ∙ fs ; identity = λ _ → F.identity ; homomorphism = λ _ → F.homomorphism ; F-resp-≈ = λ fs≈gs → F.F-resp-≈ ∙ fs≈gs } where module F = Functor F -- "constant" nullary : Obj → Powerendo 0 nullary X = record { F₀ = λ _ → X ; F₁ = λ _ → id ; identity = refl ; homomorphism = sym identity² ; F-resp-≈ = λ _ → refl } nullaryH : Obj → Hyperendo 0 1 nullaryH X = record { F₀ = λ _ _ → X ; F₁ = λ _ _ → id ; identity = λ _ → refl ; homomorphism = λ _ → sym identity² ; F-resp-≈ = λ _ _ → refl } binary : Bifunctor C C C → Powerendo 2 binary F = record { F₀ = λ As → F.F₀ (As zero , As (suc zero)) ; F₁ = λ fs → F.F₁ (fs zero , fs (suc zero)) ; identity = F.identity ; homomorphism = F.homomorphism ; F-resp-≈ = λ fs≈gs → F.F-resp-≈ (fs≈gs zero , fs≈gs (suc zero)) } where module F = Functor F binaryH : Bifunctor C C C → Hyperendo 2 1 binaryH F = record { F₀ = λ As _ → F.F₀ (As zero , As (suc zero)) ; F₁ = λ fs _ → F.F₁ (fs zero , fs (suc zero)) ; identity = λ _ → F.identity ; homomorphism = λ _ → F.homomorphism ; F-resp-≈ = λ fs≈gs _ → F.F-resp-≈ (fs≈gs zero , fs≈gs (suc zero)) } where module F = Functor F hyp : Powerendo n → Hyperendo n 1 hyp F = record { F₀ = λ As _ → F.F₀ As ; F₁ = λ fs _ → F.F₁ fs ; identity = λ _ → F.identity ; homomorphism = λ _ → F.homomorphism ; F-resp-≈ = λ fs≈gs _ → F.F-resp-≈ fs≈gs } where module F = Functor F private curryⁿ : ∀ n {a b} {A : Set a} {B : Set b} → ((Fin n → A) → B) → N-ary n A B curryⁿ zero f = f (λ ()) curryⁿ (suc n) {A = A} f = λ x → curryⁿ n (f ∙ addon x) where addon : A → (Fin n → A) → Fin (suc n) → A addon x _ zero = x addon _ g (suc i) = g i plex′ : (J → Powerendo′ I) → Hyperendo′ I J plex′ Fs = record { F₀ = flip (Functor.F₀ ∙ Fs) ; F₁ = flip (λ j → Functor.F₁ (Fs j)) ; identity = λ j → Functor.identity (Fs j) ; homomorphism = λ j → Functor.homomorphism (Fs j) ; F-resp-≈ = flip (λ j → Functor.F-resp-≈ (Fs j)) } plex : N-ary n (Powerendo′ I) (Hyperendo′ I (Fin n)) plex {n = n} = curryⁿ n plex′ -- like pad, but for Powerendo -- on left or right. widenˡ : ∀ (l : ℕ) (F : Powerendo n) → Powerendo (l + n) widenˡ l F = record { F₀ = λ As → F.F₀ (As ∙ pack) ; F₁ = λ {As Bs} fs → F.F₁ (fs ∙ pack) ; identity = F.identity ; homomorphism = F.homomorphism ; F-resp-≈ = λ fs≈gs → F.F-resp-≈ (fs≈gs ∙ pack) } where module F = Functor F pack = raise l widenʳ : ∀ (r : ℕ) (F : Powerendo n) → Powerendo (n + r) widenʳ r F = record { F₀ = λ As → F.F₀ (As ∙ pack) ; F₁ = λ fs → F.F₁ (fs ∙ pack) ; identity = F.identity ; homomorphism = F.homomorphism ; F-resp-≈ = λ fs≈gs → F.F-resp-≈ (fs≈gs ∙ pack) } where module F = Functor F pack = inject+ r
{ "alphanum_fraction": 0.5487670225, "avg_line_length": 33.3374233129, "ext": "agda", "hexsha": "2dc5408365d1c35e80516973248a0a040af5b03c", "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/Functor/Power.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/Functor/Power.agda", "max_line_length": 134, "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/Functor/Power.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4332, "size": 10868 }
------------------------------------------------------------------------ -- Possibly infinite binary trees ------------------------------------------------------------------------ module Tree where open import Codata.Musical.Notation import Relation.Binary.PropositionalEquality as PropEq open PropEq using (_≡_) data Tree (A : Set) : Set where leaf : Tree A node : (l : ∞ (Tree A)) (x : A) (r : ∞ (Tree A)) → Tree A map : ∀ {A B} → (A → B) → Tree A → Tree B map f leaf = leaf map f (node l x r) = node (♯ map f (♭ l)) (f x) (♯ map f (♭ r)) data _≈_ {A : Set} : (t₁ t₂ : Tree A) → Set where leaf : leaf ≈ leaf node : ∀ {l₁ l₂ x₁ x₂ r₁ r₂} (l≈ : ∞ (♭ l₁ ≈ ♭ l₂)) (x≡ : x₁ ≡ x₂) (r≈ : ∞ (♭ r₁ ≈ ♭ r₂)) → node l₁ x₁ r₁ ≈ node l₂ x₂ r₂ refl : ∀ {A} (t : Tree A) → t ≈ t refl leaf = leaf refl (node l x r) = node (♯ refl (♭ l)) PropEq.refl (♯ refl (♭ r)) trans : ∀ {A} {t₁ t₂ t₃ : Tree A} → t₁ ≈ t₂ → t₂ ≈ t₃ → t₁ ≈ t₃ trans leaf leaf = leaf trans (node l≈ x≡ r≈) (node l≈′ x≡′ r≈′) = node (♯ trans (♭ l≈) (♭ l≈′)) (PropEq.trans x≡ x≡′) (♯ trans (♭ r≈) (♭ r≈′)) map-cong : ∀ {A B} (f : A → B) {t₁ t₂ : Tree A} → t₁ ≈ t₂ → map f t₁ ≈ map f t₂ map-cong f leaf = leaf map-cong f (node l≈ x≡ r≈) = node (♯ map-cong f (♭ l≈)) (PropEq.cong f x≡) (♯ map-cong f (♭ r≈))
{ "alphanum_fraction": 0.4333576111, "avg_line_length": 33.487804878, "ext": "agda", "hexsha": "c307109dd6597ed394500885f0687d236ea2e6c4", "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": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/codata", "max_forks_repo_path": "Tree.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "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/codata", "max_issues_repo_path": "Tree.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/codata", "max_stars_repo_path": "Tree.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z", "num_tokens": 577, "size": 1373 }
------------------------------------------------------------------------ -- The Agda standard library -- -- N-ary products ------------------------------------------------------------------------ -- Vectors (as in Data.Vec) also represent n-ary products, so what is -- the point of this module? The n-ary products below are intended to -- be used with a fixed n, in which case the nil constructor can be -- avoided: pairs are represented as pairs (x , y), not as triples -- (x , y , unit). module Data.Product.N-ary where open import Data.Nat open import Data.Product open import Data.Unit open import Data.Vec open import Function.Inverse open import Level using (Lift; lift) open import Relation.Binary.PropositionalEquality as P using (_≡_) -- N-ary product. infix 8 _^_ _^_ : ∀ {ℓ} → Set ℓ → ℕ → Set ℓ A ^ 0 = Lift ⊤ A ^ 1 = A A ^ suc (suc n) = A × A ^ suc n -- Conversions. ↔Vec : ∀ {a} {A : Set a} n → A ^ n ↔ Vec A n ↔Vec n = record { to = P.→-to-⟶ (toVec n) ; from = P.→-to-⟶ fromVec ; inverse-of = record { left-inverse-of = fromVec∘toVec n ; right-inverse-of = toVec∘fromVec } } where toVec : ∀ {a} {A : Set a} n → A ^ n → Vec A n toVec 0 (lift tt) = [] toVec 1 x = [ x ] toVec (suc (suc n)) (x , xs) = x ∷ toVec _ xs fromVec : ∀ {a} {A : Set a} {n} → Vec A n → A ^ n fromVec [] = lift tt fromVec (x ∷ []) = x fromVec (x ∷ y ∷ xs) = (x , fromVec (y ∷ xs)) fromVec∘toVec : ∀ {a} {A : Set a} n (xs : A ^ n) → fromVec (toVec n xs) ≡ xs fromVec∘toVec 0 (lift tt) = P.refl fromVec∘toVec 1 x = P.refl fromVec∘toVec 2 (x , y) = P.refl fromVec∘toVec (suc (suc (suc n))) (x , y , xs) = P.cong (_,_ x) (fromVec∘toVec (suc (suc n)) (y , xs)) toVec∘fromVec : ∀ {a} {A : Set a} {n} (xs : Vec A n) → toVec n (fromVec xs) ≡ xs toVec∘fromVec [] = P.refl toVec∘fromVec (x ∷ []) = P.refl toVec∘fromVec (x ∷ y ∷ xs) = P.cong (_∷_ x) (toVec∘fromVec (y ∷ xs))
{ "alphanum_fraction": 0.4898823529, "avg_line_length": 31.7164179104, "ext": "agda", "hexsha": "b8b4e2815967a178053d0ab56e193b56fa6a26d0", "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/Product/N-ary.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/Product/N-ary.agda", "max_line_length": 72, "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/Product/N-ary.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": 755, "size": 2125 }
module Properties.Equality where open import Agda.Builtin.Equality using (_≡_; refl) open import Properties.Contradiction using (¬) sym : ∀ {A : Set} {a b : A} → (a ≡ b) → (b ≡ a) sym refl = refl trans : ∀ {A : Set} {a b c : A} → (a ≡ b) → (b ≡ c) → (a ≡ c) trans refl refl = refl cong : ∀ {A B : Set} {a b : A} (f : A → B) → (a ≡ b) → (f a ≡ f b) cong f refl = refl subst₁ : ∀ {A : Set} {a b : A} (F : A → Set) → (a ≡ b) → (F a) → (F b) subst₁ F refl x = x subst₂ : ∀ {A B : Set} {a b : A} {c d : B} (F : A → B → Set) → (a ≡ b) → (c ≡ d) → (F a c) → (F b d) subst₂ F refl refl x = x _≢_ : ∀ {A : Set} → A → A → Set (a ≢ b) = ¬(a ≡ b)
{ "alphanum_fraction": 0.4727838258, "avg_line_length": 26.7916666667, "ext": "agda", "hexsha": "c027bee31c81d9894e78646bb3c6610508cf1147", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "XanderYZZ/luau", "max_forks_repo_path": "prototyping/Properties/Equality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "XanderYZZ/luau", "max_issues_repo_path": "prototyping/Properties/Equality.agda", "max_line_length": 100, "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/Equality.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": 296, "size": 643 }
{-# OPTIONS --without-K #-} {- Ribbon is an explicit covering space construction. This construction is given by Daniel Grayson, Favonia and Guillaume Brunerie together. -} open import HoTT -- A is the pointed base space. -- El is intended to be a (group-)set, module homotopy.RibbonCover {i : ULevel} where -- The HIT ribbon---reconstructed covering space private π1 = fundamental-group private module _ (A∙ : Ptd i) {j} (gs : Gset (π1 A∙) j) where private A = fst A∙ a = snd A∙ El = Gset.El gs El-level = Gset.El-level gs _⊙_ = Gset.act gs {- What the following data type definition should be when we have a proof assistant for HoTT: data Ribbon (a₂ : A) : Set where trace : El → a =₀ a₂ → Ribbon a₂ paste : ∀ el loop (p : a =₀ a₂) → trace (el ⊙ loop) p == trace el (loop ∙₀ p) -} data #Ribbon-aux (a₂ : A) : Type (lmax i j) where #trace : El → a =₀ a₂ → #Ribbon-aux a₂ data #Ribbon (a₂ : A) : Type (lmax i j) where #ribbon : #Ribbon-aux a₂ → (Unit → Unit) → #Ribbon a₂ Ribbon : ∀ (A∙ : Ptd i) {j} (gs : Gset (π1 A∙) j) → fst A∙ → Type (lmax i j) Ribbon = #Ribbon module _ {A∙ : Ptd i} {j} {gs : Gset (fundamental-group A∙) j} {a₂ : fst A∙} where private A = fst A∙ a = snd A∙ El = Gset.El gs El-level = Gset.El-level gs _⊙_ = Gset.act gs -- A point in the fiber [a₂]. {- [e] is a point in the [fiber a], and [p] is a path to transport [y] to fiber [a₂]. -} trace : El → a =₀ a₂ → Ribbon A∙ gs a₂ trace el p = #ribbon (#trace el p) _ {- A loop based at [a] can used as a group action or for concatination. Both should be equivalent. -} postulate -- HIT paste : ∀ el loop (p : a =₀ a₂) → trace (el ⊙ loop) p == trace el (loop ∙₀ p) {- Make each fiber a set and cancel all higher structures due to [paste]. -} postulate -- HIT Ribbon-is-set : is-set (Ribbon A∙ gs a₂) Ribbon-level = Ribbon-is-set -- Elimination rules. module RibbonElim {j} {P : Ribbon A∙ gs a₂ → Type j} (P-level : ∀ {r} → is-set (P r)) (trace* : ∀ el p → P (trace el p)) (paste* : ∀ el loop p → trace* (el ⊙ loop) p == trace* el (loop ∙₀ p) [ P ↓ paste el loop p ]) where f : Π (Ribbon A∙ gs a₂) P f = f-aux phantom phantom where f-aux : Phantom trace* → Phantom paste* → Π (Ribbon A∙ gs a₂) P f-aux phantom phantom (#ribbon (#trace el p) _) = trace* el p open RibbonElim public using () renaming (f to Ribbon-elim) module RibbonRec {j} {P : Type j} (P-level : is-set P) (trace* : ∀ el p → P) (paste* : ∀ el loop p → trace* (el ⊙ loop) p == trace* el (loop ∙₀ p)) where private module M = RibbonElim P-level trace* (λ el loop p → ↓-cst-in (paste* el loop p)) f : Ribbon A∙ gs a₂ → P f = M.f open RibbonRec public using () renaming (f to Ribbon-rec) -- This data structure gives a cover. Ribbon-cover : ∀ (A∙ : Ptd i) {j} (gs : Gset (π1 A∙) j) → Cover (fst A∙) (lmax i j) Ribbon-cover A∙ gs = record { Fiber = Ribbon A∙ gs ; Fiber-level = λ a → Ribbon-level } trans-trace : ∀ {A : Type i} {a₁} {j} {gs : Gset (π1 (A , a₁)) j} {a₂} (q : a₁ == a₂) y p → transport (Ribbon (A , a₁) gs) q (trace y p) == trace y (p ∙₀ [ q ]) trans-trace idp y p = ap (trace y) $ ! $ ∙₀-unit-r p
{ "alphanum_fraction": 0.5310498468, "avg_line_length": 28.2755905512, "ext": "agda", "hexsha": "17d6841f64901235ce0a3a529307d93d3e13cc4e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "danbornside/HoTT-Agda", "max_forks_repo_path": "homotopy/RibbonCover.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "danbornside/HoTT-Agda", "max_issues_repo_path": "homotopy/RibbonCover.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "danbornside/HoTT-Agda", "max_stars_repo_path": "homotopy/RibbonCover.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1231, "size": 3591 }
{-# OPTIONS --cubical #-} module Equality where import Algebra.FunctionProperties import Algebra.Structures open import Cubical.Core.Everything public hiding (module Σ) open import Data.Empty open import Data.Nat as ℕ open import Data.Nat.Properties open import Data.Product as Σ open import Data.Unit open import Function open import Quotient open import Relation.Binary open import Relation.Binary.PropositionalEquality as ♥ public using () renaming (refl to ♥) open module FunctionProperties {a} {A : Set a} = Algebra.FunctionProperties {A = A} _≡_ open module Structures {a} {A : Set a} = Algebra.Structures {A = A} _≡_ coe : ∀ {ℓ} {A B : Set ℓ} → A ≡ B → A → B coe = subst id infix 1 _$⃗_ _$⃗_ : ∀ {ℓ} {A B : Set ℓ} → A ≡ B → A → B _$⃗_ = coe infix 1 _$⃖_ _$⃖_ : ∀ {ℓ} {A B : Set ℓ} → A ≡ B → B → A p $⃖ x = sym p $⃗ x ≡-isEquivalence : ∀ {ℓ} {A : Set ℓ} → IsEquivalence {A = A} _≡_ ≡-isEquivalence = record { refl = refl ; sym = sym ; trans = compPath } ≡-isPreorder : ∀ {ℓ} {A : Set ℓ} → IsPreorder {A = A} _≡_ _≡_ ≡-isPreorder = record { isEquivalence = ≡-isEquivalence ; reflexive = id ; trans = compPath } module _ {ℓ} {A : Set ℓ} {a b : A} where ⟨_⟩ : a ♥.≡ b → a ≡ b ⟨ ♥ ⟩ = refl ⟪_⟫ : a ≡ b → a ♥.≡ b ⟪_⟫ = J (λ x _ → _ ♥.≡ x) ♥ infixl 5 _≫_ _≫_ : ∀ {ℓ} {A : Set ℓ} {a b c : A} → a ≡ b → b ≡ c → a ≡ c _≫_ = compPath module _ {ℓ₁ ℓ₂} {A : Set ℓ₁} {B : Set ℓ₂} {f f′ : A → B} where happly : ∀ a → f ≡ f′ → f a ≡ f′ a happly a = cong λ g → g a congApp : ∀ {a a′} → f ≡ f′ → a ≡ a′ → f a ≡ f′ a′ congApp p q = compPath (happly _ p) (cong f′ q) cong₂ : ∀ {ℓ₁ ℓ₂ ℓ₃} {A : Set ℓ₁} {B : Set ℓ₂} {C : Set ℓ₃} {a a′} {b b′} (f : A → B → C) → a ≡ a′ → b ≡ b′ → f a b ≡ f a′ b′ cong₂ f p q = congApp (cong f p) q
{ "alphanum_fraction": 0.5636261261, "avg_line_length": 24, "ext": "agda", "hexsha": "6285edc9a85b5fa42131b4a24ece8bf3b40441ca", "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": "67ea7b96228c592daf79e800ebe4a7c12ed7221e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "kcsmnt0/numbers", "max_forks_repo_path": "src/Equality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "67ea7b96228c592daf79e800ebe4a7c12ed7221e", "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": "kcsmnt0/numbers", "max_issues_repo_path": "src/Equality.agda", "max_line_length": 91, "max_stars_count": 9, "max_stars_repo_head_hexsha": "67ea7b96228c592daf79e800ebe4a7c12ed7221e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "kcsmnt0/numbers", "max_stars_repo_path": "src/Equality.agda", "max_stars_repo_stars_event_max_datetime": "2020-01-16T07:16:26.000Z", "max_stars_repo_stars_event_min_datetime": "2019-05-20T01:29:41.000Z", "num_tokens": 800, "size": 1776 }
open import Level module ordinal where open import logic open import nat open import Data.Nat renaming ( zero to Zero ; suc to Suc ; ℕ to Nat ; _⊔_ to _n⊔_ ) open import Data.Empty open import Relation.Binary.PropositionalEquality open import Relation.Binary.Definitions open import Data.Nat.Properties open import Relation.Nullary open import Relation.Binary.Core ---- -- -- Countable Ordinals -- data OrdinalD {n : Level} : (lv : Nat) → Set n where Φ : (lv : Nat) → OrdinalD lv OSuc : (lv : Nat) → OrdinalD {n} lv → OrdinalD lv record Ordinal {n : Level} : Set n where constructor ordinal field lv : Nat ord : OrdinalD {n} lv data _d<_ {n : Level} : {lx ly : Nat} → OrdinalD {n} lx → OrdinalD {n} ly → Set n where Φ< : {lx : Nat} → {x : OrdinalD {n} lx} → Φ lx d< OSuc lx x s< : {lx : Nat} → {x y : OrdinalD {n} lx} → x d< y → OSuc lx x d< OSuc lx y open Ordinal _o<_ : {n : Level} ( x y : Ordinal ) → Set n _o<_ x y = (lv x < lv y ) ∨ ( ord x d< ord y ) s<refl : {n : Level } {lx : Nat } { x : OrdinalD {n} lx } → x d< OSuc lx x s<refl {n} {lv} {Φ lv} = Φ< s<refl {n} {lv} {OSuc lv x} = s< s<refl trio<> : {n : Level} → {lx : Nat} {x : OrdinalD {n} lx } { y : OrdinalD lx } → y d< x → x d< y → ⊥ trio<> {n} {lx} {.(OSuc lx _)} {.(OSuc lx _)} (s< s) (s< t) = trio<> s t trio<> {n} {lx} {.(OSuc lx _)} {.(Φ lx)} Φ< () d<→lv : {n : Level} {x y : Ordinal {n}} → ord x d< ord y → lv x ≡ lv y d<→lv Φ< = refl d<→lv (s< lt) = refl o∅ : {n : Level} → Ordinal {n} o∅ = record { lv = Zero ; ord = Φ Zero } open import Relation.Binary.HeterogeneousEquality using (_≅_;refl) ordinal-cong : {n : Level} {x y : Ordinal {n}} → lv x ≡ lv y → ord x ≅ ord y → x ≡ y ordinal-cong refl refl = refl ≡→¬d< : {n : Level} → {lv : Nat} → {x : OrdinalD {n} lv } → x d< x → ⊥ ≡→¬d< {n} {lx} {OSuc lx y} (s< t) = ≡→¬d< t trio<≡ : {n : Level} → {lx : Nat} {x : OrdinalD {n} lx } { y : OrdinalD lx } → x ≡ y → x d< y → ⊥ trio<≡ refl = ≡→¬d< trio>≡ : {n : Level} → {lx : Nat} {x : OrdinalD {n} lx } { y : OrdinalD lx } → x ≡ y → y d< x → ⊥ trio>≡ refl = ≡→¬d< triOrdd : {n : Level} → {lx : Nat} → Trichotomous _≡_ ( _d<_ {n} {lx} {lx} ) triOrdd {_} {lv} (Φ lv) (Φ lv) = tri≈ ≡→¬d< refl ≡→¬d< triOrdd {_} {lv} (Φ lv) (OSuc lv y) = tri< Φ< (λ ()) ( λ lt → trio<> lt Φ< ) triOrdd {_} {lv} (OSuc lv x) (Φ lv) = tri> (λ lt → trio<> lt Φ<) (λ ()) Φ< triOrdd {_} {lv} (OSuc lv x) (OSuc lv y) with triOrdd x y triOrdd {_} {lv} (OSuc lv x) (OSuc lv y) | tri< a ¬b ¬c = tri< (s< a) (λ tx=ty → trio<≡ tx=ty (s< a) ) ( λ lt → trio<> lt (s< a) ) triOrdd {_} {lv} (OSuc lv x) (OSuc lv x) | tri≈ ¬a refl ¬c = tri≈ ≡→¬d< refl ≡→¬d< triOrdd {_} {lv} (OSuc lv x) (OSuc lv y) | tri> ¬a ¬b c = tri> ( λ lt → trio<> lt (s< c) ) (λ tx=ty → trio>≡ tx=ty (s< c) ) (s< c) osuc : {n : Level} ( x : Ordinal {n} ) → Ordinal {n} osuc record { lv = lx ; ord = ox } = record { lv = lx ; ord = OSuc lx ox } <-osuc : {n : Level} { x : Ordinal {n} } → x o< osuc x <-osuc {n} {record { lv = lx ; ord = Φ .lx }} = case2 Φ< <-osuc {n} {record { lv = lx ; ord = OSuc .lx ox }} = case2 ( s< s<refl ) o<¬≡ : {n : Level } { ox oy : Ordinal {suc n}} → ox ≡ oy → ox o< oy → ⊥ o<¬≡ {_} {ox} {ox} refl (case1 lt) = =→¬< lt o<¬≡ {_} {ox} {ox} refl (case2 (s< lt)) = trio<≡ refl lt ¬x<0 : {n : Level} → { x : Ordinal {suc n} } → ¬ ( x o< o∅ {suc n} ) ¬x<0 {n} {x} (case1 ()) ¬x<0 {n} {x} (case2 ()) o<> : {n : Level} → {x y : Ordinal {n} } → y o< x → x o< y → ⊥ o<> {n} {x} {y} (case1 x₁) (case1 x₂) = nat-<> x₁ x₂ o<> {n} {x} {y} (case1 x₁) (case2 x₂) = nat-≡< (sym (d<→lv x₂)) x₁ o<> {n} {x} {y} (case2 x₁) (case1 x₂) = nat-≡< (sym (d<→lv x₁)) x₂ o<> {n} {record { lv = lv₁ ; ord = .(OSuc lv₁ _) }} {record { lv = .lv₁ ; ord = .(Φ lv₁) }} (case2 Φ<) (case2 ()) o<> {n} {record { lv = lv₁ ; ord = .(OSuc lv₁ _) }} {record { lv = .lv₁ ; ord = .(OSuc lv₁ _) }} (case2 (s< y<x)) (case2 (s< x<y)) = o<> (case2 y<x) (case2 x<y) orddtrans : {n : Level} {lx : Nat} {x y z : OrdinalD {n} lx } → x d< y → y d< z → x d< z orddtrans {_} {lx} {.(Φ lx)} {.(OSuc lx _)} {.(OSuc lx _)} Φ< (s< y<z) = Φ< orddtrans {_} {lx} {.(OSuc lx _)} {.(OSuc lx _)} {.(OSuc lx _)} (s< x<y) (s< y<z) = s< ( orddtrans x<y y<z ) osuc-≡< : {n : Level} { a x : Ordinal {n} } → x o< osuc a → (x ≡ a ) ∨ (x o< a) osuc-≡< {n} {a} {x} (case1 lt) = case2 (case1 lt) osuc-≡< {n} {record { lv = lv₁ ; ord = Φ .lv₁ }} {record { lv = .lv₁ ; ord = .(Φ lv₁) }} (case2 Φ<) = case1 refl osuc-≡< {n} {record { lv = lv₁ ; ord = OSuc .lv₁ ord₁ }} {record { lv = .lv₁ ; ord = .(Φ lv₁) }} (case2 Φ<) = case2 (case2 Φ<) osuc-≡< {n} {record { lv = lv₁ ; ord = Φ .lv₁ }} {record { lv = .lv₁ ; ord = .(OSuc lv₁ _) }} (case2 (s< ())) osuc-≡< {n} {record { lv = la ; ord = OSuc la oa }} {record { lv = la ; ord = (OSuc la ox) }} (case2 (s< lt)) with osuc-≡< {n} {record { lv = la ; ord = oa }} {record { lv = la ; ord = ox }} (case2 lt ) ... | case1 refl = case1 refl ... | case2 (case2 x) = case2 (case2( s< x) ) ... | case2 (case1 x) = ⊥-elim (¬a≤a x) osuc-< : {n : Level} { x y : Ordinal {n} } → y o< osuc x → x o< y → ⊥ osuc-< {n} {x} {y} y<ox x<y with osuc-≡< y<ox osuc-< {n} {x} {x} y<ox (case1 x₁) | case1 refl = ⊥-elim (¬a≤a x₁) osuc-< {n} {x} {x} (case1 x₂) (case2 x₁) | case1 refl = ⊥-elim (¬a≤a x₂) osuc-< {n} {x} {x} (case2 x₂) (case2 x₁) | case1 refl = ≡→¬d< x₁ osuc-< {n} {x} {y} y<ox (case1 x₂) | case2 (case1 x₁) = nat-<> x₂ x₁ osuc-< {n} {x} {y} y<ox (case1 x₂) | case2 (case2 x₁) = nat-≡< (sym (d<→lv x₁)) x₂ osuc-< {n} {x} {y} y<ox (case2 x<y) | case2 y<x = o<> (case2 x<y) y<x ordtrans : {n : Level} {x y z : Ordinal {n} } → x o< y → y o< z → x o< z ordtrans {n} {x} {y} {z} (case1 x₁) (case1 x₂) = case1 ( <-trans x₁ x₂ ) ordtrans {n} {x} {y} {z} (case1 x₁) (case2 x₂) with d<→lv x₂ ... | refl = case1 x₁ ordtrans {n} {x} {y} {z} (case2 x₁) (case1 x₂) with d<→lv x₁ ... | refl = case1 x₂ ordtrans {n} {x} {y} {z} (case2 x₁) (case2 x₂) with d<→lv x₁ | d<→lv x₂ ... | refl | refl = case2 ( orddtrans x₁ x₂ ) trio< : {n : Level } → Trichotomous {suc n} _≡_ _o<_ trio< a b with <-cmp (lv a) (lv b) trio< a b | tri< a₁ ¬b ¬c = tri< (case1 a₁) (λ refl → ¬b (cong ( λ x → lv x ) refl ) ) lemma1 where lemma1 : ¬ (Suc (lv b) ≤ lv a) ∨ (ord b d< ord a) lemma1 (case1 x) = ¬c x lemma1 (case2 x) = ⊥-elim (nat-≡< (sym ( d<→lv x )) a₁ ) trio< a b | tri> ¬a ¬b c = tri> lemma1 (λ refl → ¬b (cong ( λ x → lv x ) refl ) ) (case1 c) where lemma1 : ¬ (Suc (lv a) ≤ lv b) ∨ (ord a d< ord b) lemma1 (case1 x) = ¬a x lemma1 (case2 x) = ⊥-elim (nat-≡< (sym ( d<→lv x )) c ) trio< a b | tri≈ ¬a refl ¬c with triOrdd ( ord a ) ( ord b ) trio< record { lv = .(lv b) ; ord = x } b | tri≈ ¬a refl ¬c | tri< a ¬b ¬c₁ = tri< (case2 a) (λ refl → ¬b (lemma1 refl )) lemma2 where lemma1 : (record { lv = _ ; ord = x }) ≡ b → x ≡ ord b lemma1 refl = refl lemma2 : ¬ (Suc (lv b) ≤ lv b) ∨ (ord b d< x) lemma2 (case1 x) = ¬a x lemma2 (case2 x) = trio<> x a trio< record { lv = .(lv b) ; ord = x } b | tri≈ ¬a refl ¬c | tri> ¬a₁ ¬b c = tri> lemma2 (λ refl → ¬b (lemma1 refl )) (case2 c) where lemma1 : (record { lv = _ ; ord = x }) ≡ b → x ≡ ord b lemma1 refl = refl lemma2 : ¬ (Suc (lv b) ≤ lv b) ∨ (x d< ord b) lemma2 (case1 x) = ¬a x lemma2 (case2 x) = trio<> x c trio< record { lv = .(lv b) ; ord = x } b | tri≈ ¬a refl ¬c | tri≈ ¬a₁ refl ¬c₁ = tri≈ lemma1 refl lemma1 where lemma1 : ¬ (Suc (lv b) ≤ lv b) ∨ (ord b d< ord b) lemma1 (case1 x) = ¬a x lemma1 (case2 x) = ≡→¬d< x open _∧_ TransFinite : {n m : Level} → { ψ : Ordinal {suc n} → Set m } → ( ∀ (lx : Nat ) → ( (x : Ordinal {suc n} ) → x o< ordinal lx (Φ lx) → ψ x ) → ψ ( record { lv = lx ; ord = Φ lx } ) ) → ( ∀ (lx : Nat ) → (x : OrdinalD lx ) → ( (y : Ordinal {suc n} ) → y o< ordinal lx (OSuc lx x) → ψ y ) → ψ ( record { lv = lx ; ord = OSuc lx x } ) ) → ∀ (x : Ordinal) → ψ x TransFinite {n} {m} {ψ} caseΦ caseOSuc x = proj1 (TransFinite1 (lv x) (ord x) ) where TransFinite1 : (lx : Nat) (ox : OrdinalD lx ) → ψ (ordinal lx ox) ∧ ( ( (x : Ordinal {suc n} ) → x o< ordinal lx ox → ψ x ) ) TransFinite1 Zero (Φ 0) = ⟪ caseΦ Zero lemma , lemma1 ⟫ where lemma : (x : Ordinal) → x o< ordinal Zero (Φ Zero) → ψ x lemma x (case1 ()) lemma x (case2 ()) lemma1 : (x : Ordinal) → x o< ordinal Zero (Φ Zero) → ψ x lemma1 x (case1 ()) lemma1 x (case2 ()) TransFinite1 (Suc lx) (Φ (Suc lx)) = ⟪ caseΦ (Suc lx) (λ x → lemma (lv x) (ord x)) , (λ x → lemma (lv x) (ord x)) ⟫ where lemma0 : (ly : Nat) (oy : OrdinalD ly ) → ordinal ly oy o< ordinal lx (Φ lx) → ψ (ordinal ly oy) lemma0 ly oy lt = proj2 ( TransFinite1 lx (Φ lx) ) (ordinal ly oy) lt lemma : (ly : Nat) (oy : OrdinalD ly ) → ordinal ly oy o< ordinal (Suc lx) (Φ (Suc lx)) → ψ (ordinal ly oy) lemma lx1 ox1 (case1 lt) with <-∨ lt lemma lx (Φ lx) (case1 lt) | case1 refl = proj1 ( TransFinite1 lx (Φ lx) ) lemma lx (Φ lx) (case1 lt) | case2 lt1 = lemma0 lx (Φ lx) (case1 lt1) lemma lx (OSuc lx ox1) (case1 lt) | case1 refl = caseOSuc lx ox1 lemma2 where lemma2 : (y : Ordinal) → (Suc (lv y) ≤ lx) ∨ (ord y d< OSuc lx ox1) → ψ y lemma2 y lt1 with osuc-≡< lt1 lemma2 y lt1 | case1 refl = lemma lx ox1 (case1 a<sa) lemma2 y lt1 | case2 t = proj2 (TransFinite1 lx ox1) y t lemma lx1 (OSuc lx1 ox1) (case1 lt) | case2 lt1 = caseOSuc lx1 ox1 lemma2 where lemma2 : (y : Ordinal) → (Suc (lv y) ≤ lx1) ∨ (ord y d< OSuc lx1 ox1) → ψ y lemma2 y lt2 with osuc-≡< lt2 lemma2 y lt2 | case1 refl = lemma lx1 ox1 (ordtrans lt2 (case1 lt)) lemma2 y lt2 | case2 (case1 lt3) = proj2 (TransFinite1 lx (Φ lx)) y (case1 (<-trans lt3 lt1 )) lemma2 y lt2 | case2 (case2 lt3) with d<→lv lt3 ... | refl = proj2 (TransFinite1 lx (Φ lx)) y (case1 lt1) TransFinite1 lx (OSuc lx ox) = ⟪ caseOSuc lx ox lemma , lemma ⟫ where lemma : (y : Ordinal) → y o< ordinal lx (OSuc lx ox) → ψ y lemma y lt with osuc-≡< lt lemma y lt | case1 refl = proj1 ( TransFinite1 lx ox ) lemma y lt | case2 lt1 = proj2 ( TransFinite1 lx ox ) y lt1 -- record CountableOrdinal {n : Level} : Set (suc (suc n)) where -- field -- ctl→ : Nat → Ordinal {suc n} -- ctl← : Ordinal → Nat -- ctl-iso→ : { x : Ordinal } → ctl→ (ctl← x ) ≡ x -- ctl-iso← : { x : Nat } → ctl← (ctl→ x ) ≡ x -- -- is-C-Ordinal : {n : Level} → CountableOrdinal {n} -- is-C-Ordinal {n} = record { -- ctl→ = {!!} -- ; ctl← = λ x → TransFinite {n} (λ lx lt → Zero ) ctl01 x -- ; ctl-iso→ = {!!} -- ; ctl-iso← = {!!} -- } where -- ctl01 : (lx : Nat) (x : OrdinalD lx) → ((y : Ordinal) → y o< ordinal lx (OSuc lx x) → Nat) → Nat -- ctl01 Zero (Φ Zero) prev = Zero -- ctl01 Zero (OSuc Zero x) prev = Suc ( prev (ordinal Zero x) (ordtrans <-osuc <-osuc )) -- ctl01 (Suc lx) (Φ (Suc lx)) prev = Suc ( prev (ordinal lx {!!}) {!!}) -- ctl01 (Suc lx) (OSuc (Suc lx) x) prev = Suc ( prev (ordinal (Suc lx) x) (ordtrans <-osuc <-osuc )) open import Ordinals C-Ordinal : {n : Level} → Ordinals {suc n} C-Ordinal {n} = record { Ordinal = Ordinal {suc n} ; o∅ = o∅ ; osuc = osuc ; _o<_ = _o<_ ; next = next ; isOrdinal = record { ordtrans = ordtrans ; trio< = trio< ; ¬x<0 = ¬x<0 ; <-osuc = <-osuc ; osuc-≡< = osuc-≡< ; TransFinite = TransFinite2 ; Oprev-p = Oprev-p } ; isNext = record { x<nx = x<nx ; osuc<nx = λ {x} {y} → osuc<nx {x} {y} ; ¬nx<nx = ¬nx<nx } } where next : Ordinal {suc n} → Ordinal {suc n} next (ordinal lv ord) = ordinal (Suc lv) (Φ (Suc lv)) x<nx : { y : Ordinal } → (y o< next y ) x<nx = case1 a<sa osuc<nx : { x y : Ordinal } → x o< next y → osuc x o< next y osuc<nx (case1 lt) = case1 lt ¬nx<nx : {x y : Ordinal} → y o< x → x o< next y → ¬ ((z : Ordinal) → ¬ (x ≡ osuc z)) ¬nx<nx {x} {y} = lemma2 x where lemma2 : (x : Ordinal) → y o< x → x o< next y → ¬ ((z : Ordinal) → ¬ x ≡ osuc z) lemma2 (ordinal Zero (Φ 0)) (case2 ()) (case1 (s≤s z≤n)) not lemma2 (ordinal Zero (OSuc 0 dx)) (case2 Φ<) (case1 (s≤s z≤n)) not = not _ refl lemma2 (ordinal Zero (OSuc 0 dx)) (case2 (s< x)) (case1 (s≤s z≤n)) not = not _ refl lemma2 (ordinal (Suc lx) (OSuc (Suc lx) ox)) y<x (case1 (s≤s (s≤s lt))) not = not _ refl lemma2 (ordinal (Suc lx) (Φ (Suc lx))) (case1 x) (case1 (s≤s (s≤s lt))) not = lemma3 x lt where lemma3 : {n l : Nat} → (Suc (Suc n) ≤ Suc l) → l ≤ n → ⊥ lemma3 (s≤s sn≤l) (s≤s l≤n) = lemma3 sn≤l l≤n open Oprev Oprev-p : (x : Ordinal) → Dec ( Oprev (Ordinal {suc n}) osuc x ) Oprev-p (ordinal lv (Φ lv)) = no (λ not → lemma (oprev not) (oprev=x not) ) where lemma : (x : Ordinal) → osuc x ≡ (ordinal lv (Φ lv)) → ⊥ lemma x () Oprev-p (ordinal lv (OSuc lv ox)) = yes record { oprev = ordinal lv ox ; oprev=x = refl } ord1 : Set (suc n) ord1 = Ordinal {suc n} TransFinite2 : { ψ : ord1 → Set (suc (suc n)) } → ( (x : ord1) → ( (y : ord1 ) → y o< x → ψ y ) → ψ x ) → ∀ (x : ord1) → ψ x TransFinite2 {ψ} lt x = TransFinite {n} {suc (suc n)} {ψ} caseΦ caseOSuc x where caseΦ : (lx : Nat) → ((x₁ : Ordinal) → x₁ o< ordinal lx (Φ lx) → ψ x₁) → ψ (record { lv = lx ; ord = Φ lx }) caseΦ lx prev = lt (ordinal lx (Φ lx) ) prev caseOSuc : (lx : Nat) (x₁ : OrdinalD lx) → ((y : Ordinal) → y o< ordinal lx (OSuc lx x₁) → ψ y) → ψ (record { lv = lx ; ord = OSuc lx x₁ }) caseOSuc lx ox prev = lt (ordinal lx (OSuc lx ox)) prev
{ "alphanum_fraction": 0.5042452151, "avg_line_length": 49.109540636, "ext": "agda", "hexsha": "e190185e8640ef16a1547a379461a39ee2cd0bdf", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/zf-in-agda", "max_forks_repo_path": "src/ordinal.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "shinji-kono/zf-in-agda", "max_issues_repo_path": "src/ordinal.agda", "max_line_length": 155, "max_stars_count": 5, "max_stars_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/zf-in-agda", "max_stars_repo_path": "src/ordinal.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-10T13:27:48.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-02T13:46:23.000Z", "num_tokens": 6174, "size": 13898 }
{-# OPTIONS --sized-types #-} -- {-# OPTIONS -v tc.size.solve:20 -v tc.decl.ax:10 #-} module SizeUnsolvedConstraintsInTypeSignature where open import Common.Size data Nat : (i : Size) -> Set where Z : {i : Size} -> Nat (↑ i) S : {i : Size} -> Nat i → Nat (↑ i) one1 : (i : Size) → Nat (↑ (↑ i)) one1 i = S Z one2 : (i : Size) → Nat (↑ (↑ (↑ i))) one2 i = S Z postulate _≡_ : {A : Set} → A → A → Set works : (i : Size) → one2 i ≡ one1 i bug : (i : Size) → one1 i ≡ one2 i -- bug caused an interal error due to absense of range info -- should not print a proper error message (or better, work!)
{ "alphanum_fraction": 0.567961165, "avg_line_length": 24.72, "ext": "agda", "hexsha": "8bab2a9e7e325e146c3f1f0706d36278344f3f3a", "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/SizeUnsolvedConstraintsInTypeSignature.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/SizeUnsolvedConstraintsInTypeSignature.agda", "max_line_length": 63, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/SizeUnsolvedConstraintsInTypeSignature.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": 224, "size": 618 }
module Section3 where open import Section1 public -- 3. The calculus of proof trees -- ============================== -- -- We define the set of proof trees of implicational logic in the ordinary style à la Church, -- except that we use explicit substitutions. -- 3.1. Definition of types -- ------------------------ -- -- The types we have are base type and function types. The set of types `𝒯 : Set` is introduced -- by: infixr 7 _⊃_ data 𝒯 : Set where • : 𝒯 _⊃_ : 𝒯 → 𝒯 → 𝒯 -- Types are denoted by `A`, `B`. (…) -- -- We write `•` for the base type and `A ⊃ B` for the function type. module _ where inj₁⊃ : ∀ {A A′ B B′} → A ⊃ B ≡ A′ ⊃ B′ → A ≡ A′ inj₁⊃ refl = refl inj₂⊃ : ∀ {A A′ B B′} → A ⊃ B ≡ A′ ⊃ B′ → B ≡ B′ inj₂⊃ refl = refl _≟𝒯_ : (A A′ : 𝒯) → Dec (A ≡ A′) • ≟𝒯 • = yes refl • ≟𝒯 (A′ ⊃ B′) = no λ () (A ⊃ B) ≟𝒯 • = no λ () (A ⊃ B) ≟𝒯 (A′ ⊃ B′) with A ≟𝒯 A′ | B ≟𝒯 B′ … | yes refl | yes refl = yes refl … | yes refl | no B≢B′ = no (λ p → inj₂⊃ p ↯ B≢B′) … | no A≢A′ | _ = no (λ p → inj₁⊃ p ↯ A≢A′) -- 3.2. Definition of contexts -- --------------------------- -- -- Suppose a countably infinite set, `Name`, with names together with a decidable equality on it. -- The set of contexts `𝒞` is mutually defined with a boolean-valued function `fresh` which describes -- when a name is fresh in a context. (…) -- -- Ordinarily, the freshness condition is written as a side-condition, but since we are to -- formalise the proof trees, this information must be represented, too. -- -- We write `[]` for the empty context and `[ Γ , x ∷ A ]` for adding an element to a context, -- hence when we write `[ Γ , x ∷ A ]` -- it is implicit that we also have a proof that `x` is fresh in `Γ` (when `[ Γ , x ∷ A ]` occurs in the -- conclusion of a statement, then it is implicit that `T (fresh x Γ)` is an assumption.) The -- function `fresh` is defined by induction on the context as: mutual data 𝒞 : Set where [] : 𝒞 [_,_∷_] : (Γ : 𝒞) (x : Name) {{_ : T (fresh x Γ)}} → 𝒯 → 𝒞 fresh : Name → 𝒞 → Bool fresh x [] = true fresh x [ Γ , y ∷ A ] = and (x ≠ y) (fresh x Γ) -- We use `Γ`, `Δ` and `Θ` for contexts. -- -- The predicate `Γ ∋ x ∷ A` is true when a name with its type occurs in a context. -- -- The introduction rules are: data _∋_∷_ : 𝒞 → Name → 𝒯 → Set where zero : ∀ {Γ A x} {{_ : T (fresh x Γ)}} → [ Γ , x ∷ A ] ∋ x ∷ A suc : ∀ {Γ A B x y} {{_ : T (fresh y Γ)}} → Γ ∋ x ∷ A → [ Γ , y ∷ B ] ∋ x ∷ A module _ where injsuc : ∀ {Γ A B x y} {{_ : T (fresh y Γ)}} {i i′ : Γ ∋ x ∷ A} → suc {B = B} {y = y} i ≡ suc i′ → i ≡ i′ injsuc refl = refl _≟∋_ : ∀ {Γ A x} → (i i′ : Γ ∋ x ∷ A) → Dec (i ≡ i′) zero ≟∋ zero = yes refl zero ≟∋ suc i′ = no (λ ()) suc i ≟∋ zero = no (λ ()) suc i ≟∋ suc i′ with i ≟∋ i′ … | yes refl = yes refl … | no i≢i′ = no (λ p → injsuc p ↯ i≢i′) module _ where _∌_∷_ : 𝒞 → Name → 𝒯 → Set Γ ∌ x ∷ A = ¬ (Γ ∋ x ∷ A) fresh→∌ : ∀ {x Γ A} {{_ : T (fresh x Γ)}} → Γ ∌ x ∷ A fresh→∌ {x} {{φ}} zero with x ≟ x fresh→∌ {x} {{()}} zero | yes refl fresh→∌ {x} {{φ}} zero | no x≢x = refl ↯ x≢x fresh→∌ {x} {{φ}} (suc {y = y} i) with x ≟ y fresh→∌ {x} {{()}} (suc {y = .x} i) | yes refl fresh→∌ {x} {{φ}} (suc {y = y} i) | no x≢y = i ↯ fresh→∌ freshlem₁ : ∀ {b′} → (x : Name) → ¬ (T (and (x ≠ x) b′)) freshlem₁ x p with x ≟ x … | yes refl = p … | no x≢x = refl ↯ x≢x freshlem₂ : ∀ {b′} → (x {y} : Name) → T (and (x ≠ y) b′) → T b′ freshlem₂ x {y} p with x ≟ y … | yes refl = elim⊥ p … | no x≢y = p -- We also define the relation that describes when a context contains another. -- -- We use the notational convention `Γ ⊇ Δ` for `Γ` being greater than `Δ`. -- The set `_⊇_` has the constructors: infix 3 _⊇_ data _⊇_ : 𝒞 → 𝒞 → Set where done : ∀ {Γ} → Γ ⊇ [] step : ∀ {Γ Δ A x} {{_ : T (fresh x Δ)}} → Γ ⊇ Δ → Γ ∋ x ∷ A → Γ ⊇ [ Δ , x ∷ A ] module _ where inj₁step : ∀ {Γ Δ A x} {{_ : T (fresh x Δ)}} {c c′ : Γ ⊇ Δ} {i i′ : Γ ∋ x ∷ A} → step c i ≡ step c′ i′ → c ≡ c′ inj₁step refl = refl inj₂step : ∀ {Γ Δ A x} {{_ : T (fresh x Δ)}} {c c′ : Γ ⊇ Δ} {i i′ : Γ ∋ x ∷ A} → step c i ≡ step c′ i′ → i ≡ i′ inj₂step refl = refl _≟⊇_ : ∀ {Γ Δ} → (c c′ : Γ ⊇ Δ) → Dec (c ≡ c′) done ≟⊇ done = yes refl step c i ≟⊇ step c′ i′ with c ≟⊇ c′ | i ≟∋ i′ … | yes refl | yes refl = yes refl … | yes refl | no i≢i′ = no (λ p → inj₂step p ↯ i≢i′) … | no c≢c′ | _ = no (λ p → inj₁step p ↯ c≢c′) -- The following lemmas are easy to prove: -- Lemma 1. ext⊇ : ∀ {Δ Γ} → (∀ {A x} → Δ ∋ x ∷ A → Γ ∋ x ∷ A) → Γ ⊇ Δ ext⊇ {[]} f = done ext⊇ {[ Δ , x ∷ A ]} f = step (ext⊇ (λ i → f (suc i))) (f zero) -- Lemma 2. module _ where ↑⟨_⟩∋ : ∀ {Γ Δ A x} → Δ ⊇ Γ → Γ ∋ x ∷ A → Δ ∋ x ∷ A ↑⟨ done ⟩∋ () ↑⟨ step c i ⟩∋ zero = i ↑⟨ step c i ⟩∋ (suc j) = ↑⟨ c ⟩∋ j instance raise∋ : ∀ {A x} → Raiseable (_∋ x ∷ A) raise∋ = record { ↑⟨_⟩ = ↑⟨_⟩∋ } -- Lemma 3. refl⊇ : ∀ {Γ} → Γ ⊇ Γ refl⊇ = ext⊇ id -- Lemma 4. module _ where _○_ : ∀ {Γ Δ Θ} → Γ ⊇ Δ → Θ ⊇ Γ → Θ ⊇ Δ c ○ c′ = ext⊇ (λ i → ↑⟨ c′ ⟩ (↑⟨ c ⟩ i)) trans⊇ : ∀ {Γ Δ Θ} → Θ ⊇ Γ → Γ ⊇ Δ → Θ ⊇ Δ trans⊇ = flip _○_ -- Lemma 5. weak⊇ : ∀ {Γ A x} {{_ : T (fresh x Γ)}} → [ Γ , x ∷ A ] ⊇ Γ weak⊇ = ext⊇ suc -- Lemma 6. uniq∋ : ∀ {Γ A x} → (i i′ : Γ ∋ x ∷ A) → i ≡ i′ uniq∋ zero zero = refl uniq∋ zero (suc i′) = i′ ↯ fresh→∌ uniq∋ (suc i) zero = i ↯ fresh→∌ uniq∋ (suc i) (suc i′) = cong suc (uniq∋ i i′) -- Lemma 7. uniq⊇ : ∀ {Γ Δ} → (c c′ : Γ ⊇ Δ) → c ≡ c′ uniq⊇ done done = refl uniq⊇ (step c i) (step c′ i′) = cong² step (uniq⊇ c c′) (uniq∋ i i′) -- `ext⊇`, `↑⟨_⟩∋` and `uniq⊇` are proven by induction on `Δ` and `uniq∋` is proven by -- induction on `Γ`. `refl⊇` and `weak⊇` are direct consequences of `ext⊇` and for `trans⊇` -- we also use `↑⟨_⟩∋`. (…) -- -- The last two lemmas may seem slightly strange: they are used for guaranteeing independence -- of the proofs of `_∋_∷_` and `_⊇_`. For example, `uniq∋` says that if it can be shown that -- `x ∷ A` occurs in a context `Γ`, then there is a unique proof of this fact. The need to prove -- independence of proofs might point to a problem in using type theory for formalising proofs. On -- the other hand, as we shall see, proof objects can also be useful: the present formalisation -- heavily uses the possibilities to perform case analysis on proof objects, which reduces the -- number of cases to consider. module _ where id₁○ : ∀ {Γ Δ} → (c : Γ ⊇ Γ) (c′ : Δ ⊇ Γ) → c ○ c′ ≡ c′ id₁○ c c′ = uniq⊇ (c ○ c′) c′ id₂○ : ∀ {Γ Δ} → (c : Δ ⊇ Γ) (c′ : Δ ⊇ Δ) → c ○ c′ ≡ c id₂○ c c′ = uniq⊇ (c ○ c′) c assoc○ : ∀ {Γ Δ Θ Ω} → (c : Δ ⊇ Γ) (c′ : Θ ⊇ Δ) (c″ : Ω ⊇ Θ) → c ○ (c′ ○ c″) ≡ (c ○ c′) ○ c″ assoc○ c c′ c″ = uniq⊇ (c ○ (c′ ○ c″)) ((c ○ c′) ○ c″) comp○ : ∀ {Γ Δ Θ} → (c : Δ ⊇ Γ) (c′ : Θ ⊇ Δ) (c″ : Θ ⊇ Γ) → c ○ c′ ≡ c″ comp○ c c′ c″ = uniq⊇ (c ○ c′) c″ -- 3.3. Definition of proof trees -- ------------------------------ -- -- Proof trees and substitutions are mutually inductively defined. (…) -- -- We use the notational convention `Γ ⊢ A` and `Δ ⋙ Γ` for a proof of `A` in context `Γ` and -- a substitution of `Γ` by `Δ`, respectively. -- -- A substitution of type `Δ ⋙ Γ` intuitively is a list that associates to each `x ∷ A` in `Γ` a unique -- proof tree of type `Δ ⊢ A`. -- -- The proof trees are defined by the following rules. -- -- We recall that hidden assumptions in the definition above are implicitly universally defined -- and that the notation `[ Γ , x ∷ A ]` implies that `x` is fresh in `Γ`. (…) -- -- In the definition of variables we can see that a proof of occurrence is part of the proof -- tree. The advantage is that we can do case-analysis on this proof to find out where in the -- context `x ∷ A` occurs. The disadvantage is that we need to prove that two variables are the -- same even if they have two possibly different proofs of occurrence of `x ∷ A` (by Lemma 6 we -- know that the proofs are the same). mutual infix 3 _⊢_ data _⊢_ : 𝒞 → 𝒯 → Set where ν : ∀ {Γ A} → (x : Name) → Γ ∋ x ∷ A → Γ ⊢ A ƛ : ∀ {Γ A B} → (x : Name) {{_ : T (fresh x Γ)}} → [ Γ , x ∷ A ] ⊢ B → Γ ⊢ A ⊃ B _∙_ : ∀ {Γ A B} → Γ ⊢ A ⊃ B → Γ ⊢ A → Γ ⊢ B _▶_ : ∀ {Γ Δ A} → Γ ⊢ A → Δ ⋙ Γ → Δ ⊢ A infix 3 _⋙_ data _⋙_ : 𝒞 → 𝒞 → Set where π⟨_⟩ : ∀ {Γ Δ} → Δ ⊇ Γ → Δ ⋙ Γ _●_ : ∀ {Γ Δ Θ} → Γ ⋙ Δ → Θ ⋙ Γ → Θ ⋙ Δ [_,_≔_] : ∀ {Γ Δ A} → Δ ⋙ Γ → (x : Name) {{_ : T (fresh x Γ)}} → Δ ⊢ A → Δ ⋙ [ Γ , x ∷ A ] -- Explicit substitutions are built from a projection map, update and composition (see below -- for a discussion on the projection map). -- -- We use the following notational conventions: -- -- - `ν x` for referencing the occurrence `x`, where `x : Γ ∋ x ∷ A` -- - `M ▶ γ` for applying the substitution `γ` to the term `M` -- - `ƛ x M` for abstracting the occurrence `x` from the term `M`, where `M : [ Γ , x ∷ A ] ⊢ B` -- - `M ∙ N` for applying the term `M` to the term `N` -- - `π⟨ c ⟩` for projecting the inclusion `c` as a substitution -- - `[ γ , x ≔ M ]` for updating the substitution `γ` with the term `M` for the occurrence `x` -- - `γ ● δ` for composing the substitution `δ` with the substitution `γ` -- -- Proof trees and substitutions are named `M, N` and `γ, δ, θ` respectively. -- -- The substitution `π⟨_⟩` is not a standard primitive for explicit substitutions. Often one rather -- has an identity substitution (in `Γ ⋙ Γ`) [1, 13] or the empty substitution (in `Γ ⋙ []`) [5]. -- Instead we have taken `π⟨_⟩` as primitive. If `c : Γ ⊇ Γ`, then `π⟨ c ⟩` is the identity substitution and -- if `c : Γ ⊇ []`, then `π⟨ c ⟩` is the empty substitution. Abadi et al. [1] use a substitution `↑` that -- corresponds to a shift on substitutions; the same substitution is here defined as `π⟨ c ⟩` where -- `c : [ Γ , x ∷ A ] ⊇ Γ`. In Martin-Löf’s substitution calculus [13, 20] we have as primitives also -- thinning rules (i.e., if a term is well-typed in a given context, then it is also well-typed in a -- larger context and likewise for substitutions.) Here, thinning is achieved using `π⟨_⟩`, since if, -- for example, `M : Γ ⊢ A` and `c : Δ ⊇ Γ`, then `M ▶ π⟨ c ⟩ : Δ ⊢ A`. -- -- The first version of our work used combinators for the thinning rules, since we wanted it to -- be a start for a complete mechanical analysis of Martin-Löf’s substitution calculus [13, 20]. -- The set of conversion rules we obtained using these combinators suggested the use of `π⟨_⟩`, -- which gives fewer conversion rules. There might be other advantages in using `π⟨_⟩`: if a proof -- tree is of the form `M ▶ π⟨_⟩` we know which are the possible free variables of the term `M`, -- information that might be used in a computation. module _ where ↑⟨_⟩⊢ : ∀ {Γ Δ A} → Δ ⊇ Γ → Γ ⊢ A → Δ ⊢ A ↑⟨ c ⟩⊢ M = M ▶ π⟨ c ⟩ ↑⟨_⟩⋙ : ∀ {Γ Δ Θ} → Δ ⊇ Γ → Γ ⋙ Θ → Δ ⋙ Θ ↑⟨ c ⟩⋙ δ = δ ● π⟨ c ⟩ ↓⟨_⟩⋙ : ∀ {Γ Δ Θ} → Δ ⊇ Γ → Θ ⋙ Δ → Θ ⋙ Γ ↓⟨ c ⟩⋙ δ = π⟨ c ⟩ ● δ refl⋙ : ∀ {Γ} → Γ ⋙ Γ refl⋙ = π⟨ refl⊇ ⟩ trans⋙ : ∀ {Γ Δ Θ} → Θ ⋙ Γ → Γ ⋙ Δ → Θ ⋙ Δ trans⋙ = flip _●_ weak⋙ : ∀ {Γ A x} {{_ : T (fresh x Γ)}} → [ Γ , x ∷ A ] ⋙ Γ weak⋙ = π⟨ weak⊇ ⟩ instance raise⊢ : ∀ {A} → Raiseable (_⊢ A) raise⊢ = record { ↑⟨_⟩ = ↑⟨_⟩⊢ } raise⋙ : ∀ {Γ} → Raiseable (_⋙ Γ) raise⋙ = record { ↑⟨_⟩ = ↑⟨_⟩⋙ } lower⋙ : ∀ {Δ} → Lowerable (Δ ⋙_) lower⋙ = record { ↓⟨_⟩ = ↓⟨_⟩⋙ } -- 3.4. Convertibility of proof trees -- ---------------------------------- -- -- The rules for conversion between proof trees and substitutions are inductively defined. -- -- We use the notational convention `M ≅ N` and `γ ≅ₛ δ` for convertibility on proof trees and -- on substitutions respectively. (…) -- -- The conversion rules for proof trees are the reflexivity, symmetry, transitivity, congruence -- rules and the following rules: mutual infix 3 _≅_ data _≅_ : ∀ {Γ A} → Γ ⊢ A → Γ ⊢ A → Set where refl≅ : ∀ {Γ A} {M : Γ ⊢ A} → M ≅ M sym≅ : ∀ {Γ A} {M M′ : Γ ⊢ A} → M ≅ M′ → M′ ≅ M trans≅ : ∀ {Γ A} {M M′ M″ : Γ ⊢ A} → M ≅ M′ → M′ ≅ M″ → M ≅ M″ congƛ≅ : ∀ {Γ A B x} {{_ : T (fresh x Γ)}} {M M′ : [ Γ , x ∷ A ] ⊢ B} → M ≅ M′ → ƛ x M ≅ ƛ x M′ cong∙≅ : ∀ {Γ A B} {M M′ : Γ ⊢ A ⊃ B} {N N′ : Γ ⊢ A} → M ≅ M′ → N ≅ N′ → M ∙ N ≅ M′ ∙ N′ cong▶≅ : ∀ {Γ Δ A} {M M′ : Γ ⊢ A} {γ γ′ : Δ ⋙ Γ} → M ≅ M′ → γ ≅ₛ γ′ → M ▶ γ ≅ M′ ▶ γ′ conv₁≅ : ∀ {Γ Δ A B x} {{_ : T (fresh x Γ)}} → (M : [ Γ , x ∷ A ] ⊢ B) (N : Δ ⊢ A) (γ : Δ ⋙ Γ) → (ƛ x M ▶ γ) ∙ N ≅ M ▶ [ γ , x ≔ N ] conv₂≅ : ∀ {Γ A B x} {{_ : T (fresh x Γ)}} → (c : [ Γ , x ∷ A ] ⊇ Γ) (M : Γ ⊢ A ⊃ B) → M ≅ ƛ x ((M ▶ π⟨ c ⟩) ∙ ν x zero) conv₃≅ : ∀ {Γ Δ A x} {{_ : T (fresh x Γ)}} → (M : Δ ⊢ A) (γ : Δ ⋙ Γ) → ν x zero ▶ [ γ , x ≔ M ] ≅ M conv₄≅ : ∀ {Γ Δ A x} → (c : Δ ⊇ Γ) (i : Γ ∋ x ∷ A) (j : Δ ∋ x ∷ A) → ν x i ▶ π⟨ c ⟩ ≅ ν x j conv₅≅ : ∀ {Γ A} → (c : Γ ⊇ Γ) (M : Γ ⊢ A) → M ▶ π⟨ c ⟩ ≅ M conv₆≅ : ∀ {Γ Δ A B} → (M : Γ ⊢ A ⊃ B) (N : Γ ⊢ A) (γ : Δ ⋙ Γ) → (M ∙ N) ▶ γ ≅ (M ▶ γ) ∙ (N ▶ γ) conv₇≅ : ∀ {Γ Δ Θ A} → (M : Γ ⊢ A) (γ : Δ ⋙ Γ) (δ : Θ ⋙ Δ) → (M ▶ γ) ▶ δ ≅ M ▶ (γ ● δ) infix 3 _≅ₛ_ data _≅ₛ_ : ∀ {Γ Δ} → Δ ⋙ Γ → Δ ⋙ Γ → Set where refl≅ₛ : ∀ {Γ Δ} {γ : Δ ⋙ Γ} → γ ≅ₛ γ sym≅ₛ : ∀ {Γ Δ} {γ γ′ : Δ ⋙ Γ} → γ ≅ₛ γ′ → γ′ ≅ₛ γ trans≅ₛ : ∀ {Γ Δ} {γ γ′ γ″ : Δ ⋙ Γ} → γ ≅ₛ γ′ → γ′ ≅ₛ γ″ → γ ≅ₛ γ″ cong●≅ₛ : ∀ {Γ Δ Θ} {γ γ′ : Δ ⋙ Γ} {δ δ′ : Θ ⋙ Δ} → γ ≅ₛ γ′ → δ ≅ₛ δ′ → γ ● δ ≅ₛ γ′ ● δ′ cong≔≅ₛ : ∀ {Γ Δ A x} {{_ : T (fresh x Γ)}} {γ γ′ : Δ ⋙ Γ} {M M′ : Δ ⊢ A} → γ ≅ₛ γ′ → M ≅ M′ → [ γ , x ≔ M ] ≅ₛ [ γ′ , x ≔ M′ ] conv₁≅ₛ : ∀ {Γ Δ Θ Ω} → (γ : Δ ⋙ Γ) (δ : Θ ⋙ Δ) (θ : Ω ⋙ Θ) → (γ ● δ) ● θ ≅ₛ γ ● (δ ● θ) conv₂≅ₛ : ∀ {Γ Δ Θ A x} {{_ : T (fresh x Γ)}} → (M : Δ ⊢ A) (γ : Δ ⋙ Γ) (δ : Θ ⋙ Δ) → [ γ , x ≔ M ] ● δ ≅ₛ [ γ ● δ , x ≔ M ▶ δ ] conv₃≅ₛ : ∀ {Γ Δ A x} {{_ : T (fresh x Γ)}} → (c : [ Γ , x ∷ A ] ⊇ Γ) (M : Δ ⊢ A) (γ : Δ ⋙ Γ) → π⟨ c ⟩ ● [ γ , x ≔ M ] ≅ₛ γ conv₄≅ₛ : ∀ {Γ Δ Θ} → (c : Θ ⊇ Γ) (c′ : Δ ⊇ Γ) (c″ : Θ ⊇ Δ) → π⟨ c′ ⟩ ● π⟨ c″ ⟩ ≅ₛ π⟨ c ⟩ conv₅≅ₛ : ∀ {Γ Δ} → (c : Δ ⊇ Δ) (γ : Δ ⋙ Γ) → γ ● π⟨ c ⟩ ≅ₛ γ conv₆≅ₛ : ∀ {Γ} → (c : Γ ⊇ []) (γ : Γ ⋙ []) → γ ≅ₛ π⟨ c ⟩ conv₇≅ₛ : ∀ {Γ Δ A x} {{_ : T (fresh x Γ)}} → (c : [ Γ , x ∷ A ] ⊇ Γ) (γ : Δ ⋙ [ Γ , x ∷ A ]) (i : [ Γ , x ∷ A ] ∋ x ∷ A) → γ ≅ₛ [ π⟨ c ⟩ ● γ , x ≔ ν x i ▶ γ ] -- The first two `conv≅` rules correspond to the ordinary β- and η-rules, the next three define the effect -- of substitutions and the last two rules can be seen as the correspondence of the η-rule for -- substitutions. The remaining `conv≅ₛ` rules define how the substitutions distribute. module _ where ≡→≅ : ∀ {Γ A} {M M′ : Γ ⊢ A} → M ≡ M′ → M ≅ M′ ≡→≅ refl = refl≅ module ≅-Reasoning where infix 1 begin_ begin_ : ∀ {Γ A} {M M′ : Γ ⊢ A} → M ≅ M′ → M ≅ M′ begin p = p infixr 2 _≅⟨⟩_ _≅⟨⟩_ : ∀ {Γ A} (M {M′} : Γ ⊢ A) → M ≅ M′ → M ≅ M′ M ≅⟨⟩ p = p infixr 2 _≅⟨_⟩_ _≅⟨_⟩_ : ∀ {Γ A} (M {M′ M″} : Γ ⊢ A) → M ≅ M′ → M′ ≅ M″ → M ≅ M″ M ≅⟨ p ⟩ p′ = trans≅ p p′ infixr 2 _≡⟨⟩_ _≡⟨⟩_ : ∀ {Γ A} (M {M′} : Γ ⊢ A) → M ≅ M′ → M ≅ M′ M ≡⟨⟩ p = p infixr 2 _≡⟨_⟩_ _≡⟨_⟩_ : ∀ {Γ A} (M {M′ M″} : Γ ⊢ A) → M ≡ M′ → M′ ≅ M″ → M ≅ M″ M ≡⟨ p ⟩ p′ = trans≅ (≡→≅ p) p′ infix 3 _∎ _∎ : ∀ {Γ A} (M : Γ ⊢ A) → M ≅ M M ∎ = refl≅ ≡→≅ₛ : ∀ {Γ Δ} {γ γ′ : Δ ⋙ Γ} → γ ≡ γ′ → γ ≅ₛ γ′ ≡→≅ₛ refl = refl≅ₛ module ≅ₛ-Reasoning where infix 1 begin_ begin_ : ∀ {Γ Δ} {γ γ′ : Δ ⋙ Γ} → γ ≅ₛ γ′ → γ ≅ₛ γ′ begin p = p infixr 2 _≅ₛ⟨⟩_ _≅ₛ⟨⟩_ : ∀ {Γ Δ} (γ {γ′} : Δ ⋙ Γ) → γ ≅ₛ γ′ → γ ≅ₛ γ′ γ ≅ₛ⟨⟩ p = p infixr 2 _≅ₛ⟨_⟩_ _≅ₛ⟨_⟩_ : ∀ {Γ Δ} (γ {γ′ γ″} : Δ ⋙ Γ) → γ ≅ₛ γ′ → γ′ ≅ₛ γ″ → γ ≅ₛ γ″ γ ≅ₛ⟨ p ⟩ p′ = trans≅ₛ p p′ infixr 2 _≡⟨⟩_ _≡⟨⟩_ : ∀ {Γ Δ} (γ {γ′} : Δ ⋙ Γ) → γ ≅ₛ γ′ → γ ≅ₛ γ′ γ ≡⟨⟩ p = p infixr 2 _≡⟨_⟩_ _≡⟨_⟩_ : ∀ {Γ Δ} (γ {γ′ γ″} : Δ ⋙ Γ) → γ ≡ γ′ → γ′ ≅ₛ γ″ → γ ≅ₛ γ″ γ ≡⟨ p ⟩ p′ = trans≅ₛ (≡→≅ₛ p) p′ infix 3 _∎ _∎ : ∀ {Γ Δ} (γ : Δ ⋙ Γ) → γ ≅ₛ γ γ ∎ = refl≅ₛ
{ "alphanum_fraction": 0.4464295973, "avg_line_length": 35.6700819672, "ext": "agda", "hexsha": "b124fec5b9f403ca7b2dcc7b6921eb87e8dfda59", "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": "7c000654c4f97024d2939c412702f64dc821d4ec", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/coquand", "max_forks_repo_path": "src/Section3.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec", "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", "max_issues_repo_path": "src/Section3.agda", "max_line_length": 109, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/coquand", "max_stars_repo_path": "src/Section3.agda", "max_stars_repo_stars_event_max_datetime": "2017-09-07T12:44:40.000Z", "max_stars_repo_stars_event_min_datetime": "2017-03-27T01:29:58.000Z", "num_tokens": 7820, "size": 17407 }
-- Andreas, 2015-07-07 Let _ pattern be instantiable by an inaccessible pattern module _ where open import Common.Equality -- These used to work and should still work: transV1 : ∀{A : Set} (a b c : A) → a ≡ b → b ≡ c → a ≡ c transV1 _ ._ ._ refl refl = refl transV2 : ∀{A : Set} (a b c : A) → a ≡ b → b ≡ c → a ≡ c transV2 ._ _ ._ refl refl = refl transV3 : ∀{A : Set} (a b c : A) → a ≡ b → b ≡ c → a ≡ c transV3 ._ ._ _ refl refl = refl transH : ∀{A : Set}{a b c : A} → a ≡ b → b ≡ c → a ≡ c transH refl refl = refl transH1 : ∀{A : Set}{a b c : A} → a ≡ b → b ≡ c → a ≡ c transH1 {a = _}{b = ._}{c = ._} refl refl = refl transH1' : ∀{A : Set}{a b c : A} → a ≡ b → b ≡ c → a ≡ c transH1' {a = _} refl refl = refl -- NEW: the following should also work: transVNew : ∀{A : Set} (a b c : A) → a ≡ b → b ≡ c → a ≡ c transVNew _ _ _ refl refl = refl transHNew : ∀{A : Set}{a b c : A} → a ≡ b → b ≡ c → a ≡ c transHNew {a = _}{b = _}{c = _} refl refl = refl
{ "alphanum_fraction": 0.5321576763, "avg_line_length": 28.3529411765, "ext": "agda", "hexsha": "b7fe33580a69be2e90c0f62272503f6f59d8b2b0", "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/Issue1605.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/Issue1605.agda", "max_line_length": 79, "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/Issue1605.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": 417, "size": 964 }
module PatternShadowsConstructor2 where module A where data A (X : Set) : Set where c : A X → A X x : A X open A using (A; c) f : ∀ {X} → A X → A X → A X f (c y) x = x f A.x _ = A.x
{ "alphanum_fraction": 0.5303030303, "avg_line_length": 14.1428571429, "ext": "agda", "hexsha": "75a872328c15b53dfb06721c193b10f8a96a1c3a", "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/PatternShadowsConstructor2.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/PatternShadowsConstructor2.agda", "max_line_length": 39, "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/PatternShadowsConstructor2.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": 81, "size": 198 }
------------------------------------------------------------------------ -- All library modules, along with short descriptions ------------------------------------------------------------------------ -- Note that core modules are not included. module Everything where -- Definitions of algebraic structures like monoids and rings -- (packed in records together with sets, operations, etc.) import Algebra -- Properties of functions, such as associativity and commutativity import Algebra.FunctionProperties -- Morphisms between algebraic structures import Algebra.Morphism -- Some defined operations (multiplication by natural number and -- exponentiation) import Algebra.Operations -- Some derivable properties import Algebra.Props.AbelianGroup -- Some derivable properties import Algebra.Props.BooleanAlgebra -- Some derivable properties import Algebra.Props.DistributiveLattice -- Some derivable properties import Algebra.Props.Group -- Some derivable properties import Algebra.Props.Lattice -- Some derivable properties import Algebra.Props.Ring -- Solver for commutative ring or semiring equalities import Algebra.RingSolver -- Commutative semirings with some additional structure ("almost" -- commutative rings), used by the ring solver import Algebra.RingSolver.AlmostCommutativeRing -- Some boring lemmas used by the ring solver import Algebra.RingSolver.Lemmas -- Instantiates the ring solver with two copies of the same ring import Algebra.RingSolver.Simple -- Some algebraic structures (not packed up with sets, operations, -- etc.) import Algebra.Structures -- Applicative functors import Category.Applicative -- Indexed applicative functors import Category.Applicative.Indexed -- Functors import Category.Functor -- Monads import Category.Monad -- A delimited continuation monad import Category.Monad.Continuation -- The identity monad import Category.Monad.Identity -- Indexed monads import Category.Monad.Indexed -- The partiality monad import Category.Monad.Partiality -- The state monad import Category.Monad.State -- Types used to make recursive arguments coinductive import Coinduction -- AVL trees import Data.AVL -- Finite maps with indexed keys and values, based on AVL trees import Data.AVL.IndexedMap -- Finite sets, based on AVL trees import Data.AVL.Sets -- A binary representation of natural numbers import Data.Bin -- Booleans import Data.Bool -- A bunch of properties import Data.Bool.Properties -- Showing booleans import Data.Bool.Show -- Bounded vectors import Data.BoundedVec -- Bounded vectors (inefficient, concrete implementation) import Data.BoundedVec.Inefficient -- Characters import Data.Char -- "Finite" sets indexed on coinductive "natural" numbers import Data.Cofin -- Coinductive lists import Data.Colist -- Coinductive "natural" numbers import Data.Conat -- Coinductive vectors import Data.Covec -- Lists with fast append import Data.DifferenceList -- Natural numbers with fast addition (for use together with -- DifferenceVec) import Data.DifferenceNat -- Vectors with fast append import Data.DifferenceVec -- Digits and digit expansions import Data.Digit -- Empty type import Data.Empty -- Empty type (in Set₁) import Data.Empty1 -- Finite sets import Data.Fin -- Decision procedures for finite sets and subsets of finite sets import Data.Fin.Dec -- Properties related to Fin, and operations making use of these -- properties (or other properties not available in Data.Fin) import Data.Fin.Props -- Subsets of finite sets import Data.Fin.Subset -- Some properties about subsets import Data.Fin.Subset.Props -- Substitutions import Data.Fin.Substitution -- An example of how Data.Fin.Substitution can be used: a definition -- of substitution for the untyped λ-calculus, along with some lemmas import Data.Fin.Substitution.Example -- Substitution lemmas import Data.Fin.Substitution.Lemmas -- Application of substitutions to lists, along with various lemmas import Data.Fin.Substitution.List -- Simple combinators working solely on and with functions import Data.Function -- Directed acyclic multigraphs import Data.Graph.Acyclic -- Integers import Data.Integer -- Divisibility and coprimality import Data.Integer.Divisibility -- Some properties about integers import Data.Integer.Properties -- Lists import Data.List -- Lists where all elements satisfy a given property import Data.List.All -- Properties relating All to various list functions import Data.List.All.Properties -- Lists where at least one element satisfies a given property import Data.List.Any -- Properties relating Any to various list functions import Data.List.Any.Properties -- A data structure which keeps track of an upper bound on the number -- of elements /not/ in a given list import Data.List.Countdown -- List equality import Data.List.Equality -- Non-empty lists import Data.List.NonEmpty -- Properties of non-empty lists import Data.List.NonEmpty.Properties -- List-related properties import Data.List.Properties -- Lists parameterised on things in Set₁ import Data.List1 -- Finite maps, i.e. lookup tables (currently only some type -- signatures) import Data.Map -- The Maybe type import Data.Maybe -- Natural numbers import Data.Nat -- Coprimality import Data.Nat.Coprimality -- Integer division import Data.Nat.DivMod -- Divisibility import Data.Nat.Divisibility -- Greatest common divisor import Data.Nat.GCD -- Boring lemmas used in Data.Nat.GCD and Data.Nat.Coprimality import Data.Nat.GCD.Lemmas -- Least common multiple import Data.Nat.LCM -- A bunch of properties about natural number operations import Data.Nat.Properties -- Showing natural numbers import Data.Nat.Show -- Products import Data.Product -- Products implemented using records import Data.Product.Record -- Products (variants for Set₁) import Data.Product1 -- Rational numbers import Data.Rational -- Finite sets (currently only some type signatures) import Data.Sets -- Signs import Data.Sign -- Some properties about signs import Data.Sign.Properties -- The reflexive transitive closures of McBride, Norell and Jansson import Data.Star -- Bounded vectors (inefficient implementation) import Data.Star.BoundedVec -- Decorated star-lists import Data.Star.Decoration -- Environments (heterogeneous collections) import Data.Star.Environment -- Finite sets defined in terms of Data.Star import Data.Star.Fin -- Lists defined in terms of Data.Star import Data.Star.List -- Natural numbers defined in terms of Data.Star import Data.Star.Nat -- Pointers into star-lists import Data.Star.Pointer -- Some properties related to Data.Star import Data.Star.Properties -- Vectors defined in terms of Data.Star import Data.Star.Vec -- Streams import Data.Stream -- Strings import Data.String -- Sums (disjoint unions) import Data.Sum -- The unit type import Data.Unit -- The unit type (in Set₁) import Data.Unit1 -- Vectors import Data.Vec -- Semi-heterogeneous vector equality import Data.Vec.Equality -- Code for converting Vec n A → B to and from n-ary functions import Data.Vec.N-ary -- Code for converting Vec₁ n A → B to and from n-ary functions import Data.Vec.N-ary1 -- Some Vec-related properties import Data.Vec.Properties -- Vectors parameterised on types in Set₁ import Data.Vec1 -- Types used (only) when calling out to Haskell via the FFI import Foreign.Haskell -- IO import IO -- Primitive IO: simple bindings to Haskell types and functions import IO.Primitive -- An abstraction of various forms of recursion/induction import Induction -- Lexicographic induction import Induction.Lexicographic -- Various forms of induction for natural numbers import Induction.Nat -- Well-founded induction import Induction.WellFounded -- A variant of Induction for Set₁ import Induction1 -- One form of induction for natural numbers import Induction1.Nat -- Well-founded induction import Induction1.WellFounded -- Properties of homogeneous binary relations import Relation.Binary -- Some properties imply others import Relation.Binary.Consequences -- Convenient syntax for equational reasoning import Relation.Binary.EqReasoning -- Many properties which hold for _∼_ also hold for flip₁ _∼_ import Relation.Binary.Flip -- Function setoids and related constructions import Relation.Binary.FunctionSetoid -- Heterogeneous equality import Relation.Binary.HeterogeneousEquality -- Conversion of ≤ to <, along with a number of properties import Relation.Binary.NonStrictToStrict -- Many properties which hold for _∼_ also hold for _∼_ on₁ f import Relation.Binary.On -- Order morphisms import Relation.Binary.OrderMorphism -- Convenient syntax for "equational reasoning" using a partial order import Relation.Binary.PartialOrderReasoning -- Convenient syntax for "equational reasoning" using a preorder import Relation.Binary.PreorderReasoning -- Lexicographic products of binary relations import Relation.Binary.Product.NonStrictLex -- Pointwise products of binary relations import Relation.Binary.Product.Pointwise -- Lexicographic products of binary relations import Relation.Binary.Product.StrictLex -- Propositional (intensional) equality import Relation.Binary.PropositionalEquality -- Propositional equality import Relation.Binary.PropositionalEquality1 -- Properties satisfied by decidable total orders import Relation.Binary.Props.DecTotalOrder -- Properties satisfied by posets import Relation.Binary.Props.Poset -- Properties satisfied by strict partial orders import Relation.Binary.Props.StrictPartialOrder -- Properties satisfied by strict partial orders import Relation.Binary.Props.StrictTotalOrder -- Properties satisfied by total orders import Relation.Binary.Props.TotalOrder -- Helpers intended to ease the development of "tactics" which use -- proof by reflection import Relation.Binary.Reflection -- Some simple binary relations import Relation.Binary.Simple -- Convenient syntax for "equational reasoning" using a strict partial -- order import Relation.Binary.StrictPartialOrderReasoning -- Conversion of < to ≤, along with a number of properties import Relation.Binary.StrictToNonStrict -- Sums of binary relations import Relation.Binary.Sum -- Operations on nullary relations (like negation and decidability) import Relation.Nullary -- Operations on and properties of decidable relations import Relation.Nullary.Decidable -- Properties related to negation import Relation.Nullary.Negation -- Products of nullary relations import Relation.Nullary.Product -- Sums of nullary relations import Relation.Nullary.Sum -- A universe of proposition functors, along with some properties import Relation.Nullary.Universe -- Unary relations import Relation.Unary -- Unary relations (variant for Set₁) import Relation.Unary1 -- Sizes for Agda's sized types import Size
{ "alphanum_fraction": 0.7861896839, "avg_line_length": 22.4906444906, "ext": "agda", "hexsha": "3f34b34d54e390728731697d8dad1d8ecf0a9740", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/Everything.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/Everything.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/Everything.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 2391, "size": 10818 }
{-# OPTIONS --sized-types #-} open import Agda.Builtin.Equality open import Agda.Builtin.Size mutual data D (i : Size) : Set where c : D′ i → D i record D′ (i : Size) : Set where coinductive field force : (j : Size< i) → D j data R (i : Size) : D ∞ → D ∞ → Set where c₁ : ∀ x y → R i (c x) (c y) c₂ : ∀ x y → R i (c x) y postulate F : (x : D ∞) (x′ : D′ ∞) → x ≡ c x′ → Set₁ G : Size → Set₁ G i = Set where G′ : (x′ y′ : D ∞) (x y : D′ ∞) → R i (c x) y′ → R i x′ (c y) → x .D′.force _ {- ∞ -} ≡ x′ → Set₁ G′ _ _ _ _ (c₁ x _) (c₂ u _) eq = F _ {- x .D′.force ∞ -} u eq G′ _ _ _ _ (c₂ _ _) _ refl = Set G′ _ _ _ _ _ _ _ = Set
{ "alphanum_fraction": 0.4377622378, "avg_line_length": 20.4285714286, "ext": "agda", "hexsha": "f6cc37aea6299ecac8531f808d7a776734b80254", "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/Bugs/Issue5007-sizedtypes.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/Bugs/Issue5007-sizedtypes.agda", "max_line_length": 66, "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/Bugs/Issue5007-sizedtypes.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": 326, "size": 715 }
{-# OPTIONS --allow-unsolved-metas #-} -- Andreas, 2014-05-17 reported by Fabien Renaud open import Common.Equality data Nat : Set where zero : Nat suc : Nat → Nat {-# BUILTIN NATURAL Nat #-} data List {a} (A : Set a) : Set a where [] : List A _∷_ : A → List A → List A length : ∀{a}{A : Set a} → List A → Nat length [] = zero length (x ∷ xs) = suc (length xs) foldr : ∀{a b}{A : Set a}{B : Set b} → (A → B → B) → B → List A → B foldr c n [] = n foldr c n (x ∷ xs) = c x (foldr c n xs) length-cons : ∀{b} {B : Set b} (L : List B) x → length (x ∷ L) ≡ suc (length L) length-cons [] _ = refl length-cons (x ∷ L) _ = refl suc-foldr-eq : ∀{b} {c} {B : Set b} {C : Set c} (LL : List B) (LA : List C) → suc (foldr (λ _ → suc) 0 LL) ≡ suc (foldr (λ _ → suc) 0 LA) → length LL ≡ length LA suc-foldr-eq [] [] Eq = refl suc-foldr-eq [] (x ∷ LA) () suc-foldr-eq (x ∷ LL) [] () suc-foldr-eq (x ∷ LL) (y ∷ LA) Eq rewrite length-cons LL x = {!!} -- WAS: -- Failed to infer the value of dotted pattern -- when checking that the pattern ._ has type Nat -- NOW: unsolved meta
{ "alphanum_fraction": 0.5541401274, "avg_line_length": 23.3829787234, "ext": "agda", "hexsha": "fb793932d4f9672abe5a6ff865895bbda6678870", "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/Issue1110.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/Issue1110.agda", "max_line_length": 79, "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/Issue1110.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": 428, "size": 1099 }
module _ (A : Set) where data A where
{ "alphanum_fraction": 0.6666666667, "avg_line_length": 9.75, "ext": "agda", "hexsha": "98902766c791e8bbe0e24154e9bc1d60caf1aa31", "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/Issue2576MissingData.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/Issue2576MissingData.agda", "max_line_length": 24, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue2576MissingData.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": 13, "size": 39 }
------------------------------------------------------------------------ -- The classical definition of (strong) bisimilarity ------------------------------------------------------------------------ -- This module is largely based on "Enhancements of the bisimulation -- proof method" by Pous and Sangiorgi. {-# OPTIONS --sized-types #-} open import Labelled-transition-system module Bisimilarity.Classical {ℓ} (lts : LTS ℓ) where open import Equality.Propositional open import Logical-equivalence using (_⇔_) open import Prelude open import Function-universe equality-with-J hiding (id; _∘_) open LTS lts open import Bisimilarity.Step lts _[_]⟶_ _[_]⟶_ as S hiding (⟨_,_⟩) open import Indexed-container hiding (⟨_⟩; Bisimilarity; larger⇔smallest) open import Relation ------------------------------------------------------------------------ -- Progressions, bisimulations and bisimilarity -- Progressions. Progression : ∀ {r s} → Rel₂ r Proc → Rel₂ s Proc → Type (ℓ ⊔ r ⊔ s) Progression R S = R ⊆ Step S module Progression {r s} {R : Rel₂ r Proc} {S : Rel₂ s Proc} (P : Progression R S) where -- Some "projections". left-to-right : ∀ {p p′ q μ} → R (p , q) → p [ μ ]⟶ p′ → ∃ λ q′ → q [ μ ]⟶ q′ × S (p′ , q′) left-to-right pRq = Step.left-to-right (P pRq) right-to-left : ∀ {p q q′ μ} → R (p , q) → q [ μ ]⟶ q′ → ∃ λ p′ → p [ μ ]⟶ p′ × S (p′ , q′) right-to-left pRq = Step.right-to-left (P pRq) open Progression public -- A "constructor" for Progression. ⟪_,_⟫ : ∀ {r s} {R : Rel₂ r Proc} {S : Rel₂ s Proc} → (∀ {p p′ q μ} → R (p , q) → p [ μ ]⟶ p′ → ∃ λ q′ → q [ μ ]⟶ q′ × S (p′ , q′)) → (∀ {p q q′ μ} → R (p , q) → q [ μ ]⟶ q′ → ∃ λ p′ → p [ μ ]⟶ p′ × S (p′ , q′)) → Progression R S ⟪ lr , rl ⟫ = λ pRq → S.⟨ lr pRq , rl pRq ⟩ -- Bisimulations. Bisimulation : ∀ {r} → Rel₂ r Proc → Type (ℓ ⊔ r) Bisimulation R = Progression R R -- Bisimilarity with a level argument. Bisimilarity′ : ∀ ℓ′ → Rel₂ (lsuc (ℓ ⊔ ℓ′)) Proc Bisimilarity′ ℓ′ = gfp ℓ′ StepC -- Bisimilarity′ ℓ′ is pointwise logically equivalent to -- Bisimilarity′ lzero. -- -- For this reason the code below is mostly restricted to -- Bisimilarity′ lzero. larger⇔smallest : ∀ ℓ′ {p} → Bisimilarity′ ℓ′ p ⇔ Bisimilarity′ lzero p larger⇔smallest ℓ′ = Indexed-container.larger⇔smallest ℓ′ -- Bisimilarity. Bisimilarity : Rel₂ (lsuc ℓ) Proc Bisimilarity = Bisimilarity′ lzero infix 4 _∼_ _∼_ : Proc → Proc → Type (lsuc ℓ) p ∼ q = ∃ λ R → R ⊆ ⟦ StepC ⟧ R × R (p , q) private -- The definition of _∼_ could also have been given more indirectly. indirect-∼ : _∼_ ≡ curry Bisimilarity indirect-∼ = refl -- An unfolding lemma for Bisimilarity′. Bisimilarity′↔ : ∀ {k} ℓ′ {pq} → Extensionality? k (ℓ ⊔ ℓ′) (ℓ ⊔ ℓ′) → Bisimilarity′ ℓ′ pq ↝[ k ] ∃ λ (R : Rel₂ (ℓ ⊔ ℓ′) Proc) → Bisimulation R × R pq Bisimilarity′↔ {k} ℓ′ {pq} ext = Bisimilarity′ ℓ′ pq ↔⟨⟩ gfp ℓ′ StepC pq ↔⟨⟩ (∃ λ (R : Rel₂ (ℓ ⊔ ℓ′) Proc) → R ⊆ ⟦ StepC ⟧ R × R pq) ↝⟨ (∃-cong λ _ → ×-cong₁ λ _ → ⊆-congʳ ext $ inverse-ext? Step↔StepC (lower-extensionality? k ℓ′ lzero ext)) ⟩□ (∃ λ (R : Rel₂ (ℓ ⊔ ℓ′) Proc) → Bisimulation R × R pq) □ -- An unfolding lemma for Bisimilarity. Bisimilarity↔ : ∀ {k pq} → Extensionality? k ℓ ℓ → Bisimilarity pq ↝[ k ] ∃ λ (R : Rel₂ ℓ Proc) → Bisimulation R × R pq Bisimilarity↔ = Bisimilarity′↔ lzero -- A "constructor". ⟨_,_,_⟩ : ∀ {p q} → (R : Rel₂ ℓ Proc) → Bisimulation R → R (p , q) → p ∼ q ⟨ R , bisim , pRq ⟩ = _⇔_.from (Bisimilarity↔ _) (R , bisim , pRq) ------------------------------------------------------------------------ -- Bisimilarity is an equivalence relation -- Reflexivity, proved generally for Bisimilarity′. reflexive-∼′ : ∀ ℓ {p} → Bisimilarity′ ℓ (p , p) reflexive-∼′ ℓ = _⇔_.from (Bisimilarity′↔ ℓ _) ( ↑ ℓ ∘ uncurry _≡_ , ⟪ (λ p≡q p⟶p′ → _ , subst (_[ _ ]⟶ _) (lower p≡q) p⟶p′ , lift refl) , (λ p≡q q⟶q′ → _ , subst (_[ _ ]⟶ _) (sym $ lower p≡q) q⟶q′ , lift refl) ⟫ , lift refl ) -- Reflexivity. reflexive-∼ : ∀ {p} → p ∼ p reflexive-∼ = reflexive-∼′ lzero -- Symmetry. symmetric-∼ : ∀ {p q} → p ∼ q → q ∼ p symmetric-∼ p∼q with _⇔_.to (Bisimilarity↔ _) p∼q ... | R , R-is-a-bisimulation , pRq = ⟨ R ⁻¹ , ⟪ right-to-left R-is-a-bisimulation , left-to-right R-is-a-bisimulation ⟫ , pRq ⟩ -- Transitivity. transitive-∼ : ∀ {p q r} → p ∼ q → q ∼ r → p ∼ r transitive-∼ p∼q q∼r with _⇔_.to (Bisimilarity↔ _) p∼q | _⇔_.to (Bisimilarity↔ _) q∼r ... | R₁ , R-is₁ , pR₁q | R₂ , R-is₂ , qR₂r = ⟨ R₁ ⊙ R₂ , ⟪_,_⟫ {R = _ ⊙ _} (λ { (q , pR₁q , qR₂r) p⟶p′ → let q′ , q⟶q′ , p′R₁q′ = left-to-right R-is₁ pR₁q p⟶p′ r′ , r⟶r′ , q′R₂r′ = left-to-right R-is₂ qR₂r q⟶q′ in r′ , r⟶r′ , (q′ , p′R₁q′ , q′R₂r′) }) (λ { (q , pR₁q , qR₂r) r⟶r′ → let q′ , q⟶q′ , q′R₂r′ = right-to-left R-is₂ qR₂r r⟶r′ p′ , p⟶p′ , p′R₁q′ = right-to-left R-is₁ pR₁q q⟶q′ in p′ , p⟶p′ , (q′ , p′R₁q′ , q′R₂r′) }) , (_ , pR₁q , qR₂r) ⟩ -- A function that can be used to aid the instance resolution -- mechanism. infix -2 ∼:_ ∼:_ : ∀ {p q} → p ∼ q → p ∼ q ∼:_ = id ------------------------------------------------------------------------ -- Lemmas relating bisimulations and bisimilarity -- Bisimilarity is a bisimulation. bisimilarity-is-a-bisimulation : Bisimulation Bisimilarity bisimilarity-is-a-bisimulation = Bisimilarity ⊆⟨ gfp-out ℓ ⟩ ⟦ StepC ⟧ Bisimilarity ⊆⟨ _⇔_.from (Step↔StepC _) ⟩∎ Step Bisimilarity ∎ -- Bisimilarity is larger than every bisimulation. bisimulation⊆∼ : ∀ {r} {R : Rel₂ r Proc} → Bisimulation R → R ⊆ Bisimilarity bisimulation⊆∼ {r} {R} R-is-a-bisimulation = R ⊆⟨ gfp-unfold lzero ( R ⊆⟨ R-is-a-bisimulation ⟩ Step R ⊆⟨ Step↔StepC _ ⟩∎ ⟦ StepC ⟧ R ∎) ⟩ Bisimilarity′ r ⊆⟨ _⇔_.to (larger⇔smallest r) ⟩∎ Bisimilarity ∎ ------------------------------------------------------------------------ -- Bisimulations up to bisimilarity -- Bisimulations up to bisimilarity. Bisimulation-up-to-bisimilarity : ∀ {r} → Rel₂ r Proc → Type (lsuc ℓ ⊔ r) Bisimulation-up-to-bisimilarity R = Progression R (Bisimilarity ⊙ R ⊙ Bisimilarity) -- If R is a bisimulation up to bisimilarity, then ∼R∼ is a -- bisimulation. bisimulation-up-to-∼⇒bisimulation : ∀ {r} {R : Rel₂ r Proc} → Bisimulation-up-to-bisimilarity R → Bisimulation (Bisimilarity ⊙ R ⊙ Bisimilarity) bisimulation-up-to-∼⇒bisimulation R-is = ⟪_,_⟫ {R = _ ⊙ _ ⊙ _} (λ { (q , p∼q , r , qRr , r∼s) p⟶p′ → let q′ , q⟶q′ , p′∼q′ = left-to-right bisimilarity-is-a-bisimulation p∼q p⟶p′ r′ , r⟶r′ , (q″ , q′∼q″ , r″ , q″Rr″ , r″∼r′) = left-to-right R-is qRr q⟶q′ s′ , s⟶s′ , r′∼s′ = left-to-right bisimilarity-is-a-bisimulation r∼s r⟶r′ in s′ , s⟶s′ , q″ , transitive-∼ p′∼q′ q′∼q″ , r″ , q″Rr″ , transitive-∼ r″∼r′ r′∼s′ }) (λ { (q , p∼q , r , qRr , r∼s) s⟶s′ → let r′ , r⟶r′ , r′∼s′ = right-to-left bisimilarity-is-a-bisimulation r∼s s⟶s′ q′ , q⟶q′ , (q″ , q′∼q″ , r″ , q″Rr″ , r″∼r′) = right-to-left R-is qRr r⟶r′ p′ , p⟶p′ , p′∼q′ = right-to-left bisimilarity-is-a-bisimulation p∼q q⟶q′ in p′ , p⟶p′ , q″ , transitive-∼ p′∼q′ q′∼q″ , r″ , q″Rr″ , transitive-∼ r″∼r′ r′∼s′ }) -- If R is a bisimulation up to bisimilarity, then R is contained in -- bisimilarity. bisimulation-up-to-∼⊆∼ : ∀ {r} {R : Rel₂ r Proc} → Bisimulation-up-to-bisimilarity R → R ⊆ Bisimilarity bisimulation-up-to-∼⊆∼ {R = R} R-is = R ⊆⟨ (λ { {p , q} pRq → p , reflexive-∼ , q , pRq , reflexive-∼ }) ⟩ Bisimilarity ⊙ R ⊙ Bisimilarity ⊆⟨ bisimulation⊆∼ (bisimulation-up-to-∼⇒bisimulation R-is) ⟩∎ Bisimilarity ∎ ------------------------------------------------------------------------ -- Bisimulations up to union -- Bisimulations up to ∪. Bisimulation-up-to-∪ : ∀ {r} → Rel₂ r Proc → Type (lsuc ℓ ⊔ r) Bisimulation-up-to-∪ R = Progression R (R ∪ Bisimilarity) -- If _R_ is a bisimulation up to ∪, then _R_ ∪ _∼_ is a bisimulation. bisimulation-up-to-∪⇒bisimulation : ∀ {r} {R : Rel₂ r Proc} → Bisimulation-up-to-∪ R → Bisimulation (R ∪ Bisimilarity) bisimulation-up-to-∪⇒bisimulation R-is = ⟪ [ left-to-right R-is , (λ p∼q → Σ-map id (Σ-map id inj₂) ∘ left-to-right bisimilarity-is-a-bisimulation p∼q) ] , [ right-to-left R-is , (λ p∼q → Σ-map id (Σ-map id inj₂) ∘ right-to-left bisimilarity-is-a-bisimulation p∼q) ] ⟫ -- If R is a bisimulation up to ∪, then R is contained in -- bisimilarity. bisimulation-up-to-∪⊆∼ : ∀ {r} {R : Rel₂ r Proc} → Bisimulation-up-to-∪ R → R ⊆ Bisimilarity bisimulation-up-to-∪⊆∼ {R = R} R-is = R ⊆⟨ inj₁ ⟩ R ∪ Bisimilarity ⊆⟨ bisimulation⊆∼ (bisimulation-up-to-∪⇒bisimulation R-is) ⟩∎ Bisimilarity ∎ ------------------------------------------------------------------------ -- Bisimulations up to reflexive transitive closure -- Bisimulations up to reflexive transitive closure. Bisimulation-up-to-* : Rel₂ ℓ Proc → Type ℓ Bisimulation-up-to-* R = Progression R (R *) -- If R is a bisimulation up to reflexive transitive closure, then R * -- is a bisimulation. bisimulation-up-to-*⇒bisimulation : ∀ {R} → Bisimulation-up-to-* R → Bisimulation (R *) bisimulation-up-to-*⇒bisimulation {R} R-is = ⟪ lr , rl ⟫ where lr : ∀ {p p′ q μ} → (R *) (p , q) → p [ μ ]⟶ p′ → ∃ λ q′ → q [ μ ]⟶ q′ × (R *) (p′ , q′) lr (zero , refl) q⟶p′ = _ , q⟶p′ , zero , refl lr (suc n , r , pRr , rRⁿq) p⟶p′ = let r′ , r⟶r′ , p′R*r′ = left-to-right R-is pRr p⟶p′ q′ , q⟶q′ , r′R*q′ = lr (n , rRⁿq) r⟶r′ in q′ , q⟶q′ , *-trans p′R*r′ r′R*q′ rl : ∀ {p q q′ μ} → (R *) (p , q) → q [ μ ]⟶ q′ → ∃ λ p′ → p [ μ ]⟶ p′ × (R *) (p′ , q′) rl (zero , refl) p⟶q′ = _ , p⟶q′ , zero , refl rl (suc n , r , pRr , rRⁿq) q⟶q′ = let r′ , r⟶r′ , r′R*q′ = rl (n , rRⁿq) q⟶q′ p′ , p⟶p′ , p′R*r′ = right-to-left R-is pRr r⟶r′ in p′ , p⟶p′ , *-trans p′R*r′ r′R*q′ -- If R is a bisimulation up to reflexive transitive closure, then R -- is contained in bisimilarity. bisimulation-up-to-*⊆∼ : ∀ {R} → Bisimulation-up-to-* R → R ⊆ Bisimilarity bisimulation-up-to-*⊆∼ {R} R-is = R ⊆⟨ (λ pRq → 1 , _ , pRq , refl) ⟩ (R *) ⊆⟨ bisimulation⊆∼ (bisimulation-up-to-*⇒bisimulation R-is) ⟩∎ Bisimilarity ∎ ------------------------------------------------------------------------ -- Some preservation results -- These results are not taken from "Enhancements of the bisimulation -- proof method". -- Equal processes are bisimilar. ≡⇒∼ : ∀ {p q} → p ≡ q → p ∼ q ≡⇒∼ refl = reflexive-∼ -- Precomposition with the lifting operator preserves the "is a -- bisimulation" relation. ↑-preserves-bisimulations : ∀ {ℓ r} {R : Rel₂ r Proc} → Bisimulation R → Bisimulation (↑ ℓ ∘ R) ↑-preserves-bisimulations R-is = ⟪ (λ pRq → Σ-map id (Σ-map id lift) ∘ left-to-right R-is (lower pRq)) , (λ pRq → Σ-map id (Σ-map id lift) ∘ right-to-left R-is (lower pRq)) ⟫ -- The "times two" operator preserves the "is a bisimulation" -- relation. ×2-preserves-bisimulations : ∀ {r} {R : Rel₂ r Proc} → Bisimulation R → Bisimulation (R ∪ R) ×2-preserves-bisimulations R-is = ⟪ (let f = λ pRq p⟶p′ → Σ-map id (Σ-map id inj₁) (left-to-right R-is pRq p⟶p′) in [ f , f ]) , (let f = λ pRq q⟶q′ → Σ-map id (Σ-map id inj₁) (right-to-left R-is pRq q⟶q′) in [ f , f ]) ⟫
{ "alphanum_fraction": 0.5163797426, "avg_line_length": 30.0653266332, "ext": "agda", "hexsha": "e4660d9505c9937850ad8759c30f5189ae5c5f31", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/up-to", "max_forks_repo_path": "src/Bisimilarity/Classical.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/up-to", "max_issues_repo_path": "src/Bisimilarity/Classical.agda", "max_line_length": 129, "max_stars_count": null, "max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/up-to", "max_stars_repo_path": "src/Bisimilarity/Classical.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4786, "size": 11966 }
{-# OPTIONS --without-K --safe #-} module Data.Binary.Definitions where open import Function open import Data.Binary.Bits public open import Data.List using (_∷_) renaming ([] to 1ᵇ) public open import Data.Maybe open import Data.Product 𝔹⁺ : Set 𝔹⁺ = Data.List.List Bit 𝔹 : Set 𝔹 = Maybe 𝔹⁺ infixr 5 0<_ pattern 0ᵇ = nothing pattern 0<_ x = just x 𝔹± : Set 𝔹± = Maybe (Bit × 𝔹⁺)
{ "alphanum_fraction": 0.6917098446, "avg_line_length": 16.7826086957, "ext": "agda", "hexsha": "5eeff306b293cf74a1b1836a42ed5cdd95c2c312", "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": "92af4d620febd47a9791d466d747278dc4a417aa", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-binary", "max_forks_repo_path": "Data/Binary/Definitions.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "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-binary", "max_issues_repo_path": "Data/Binary/Definitions.agda", "max_line_length": 60, "max_stars_count": 1, "max_stars_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-binary", "max_stars_repo_path": "Data/Binary/Definitions.agda", "max_stars_repo_stars_event_max_datetime": "2019-03-21T21:30:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-03-21T21:30:10.000Z", "num_tokens": 143, "size": 386 }
------------------------------------------------------------------------ -- The delay monad quotiented by weak bisimilarity ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --sized-types #-} module Partiality-monad.Coinductive where open import Equality.Propositional.Cubical open import Prelude hiding (⊥) open import Prelude.Size open import H-level.Truncation.Propositional equality-with-paths open import Quotient equality-with-paths open import Delay-monad open import Delay-monad.Bisimilarity -- The partiality monad, defined as the delay monad quotiented by -- (propositionally truncated) weak bisimilarity. _⊥ : ∀ {a} → Type a → Type a A ⊥ = Delay A ∞ / λ x y → ∥ x ≈ y ∥ -- The partiality monad is a set. ⊥-is-set : ∀ {a} {A : Type a} → Is-set (A ⊥) ⊥-is-set = /-is-set
{ "alphanum_fraction": 0.5957193817, "avg_line_length": 29, "ext": "agda", "hexsha": "9a35e1b8d0e650c28bed051016c6286fa22f13ee", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/partiality-monad", "max_forks_repo_path": "src/Partiality-monad/Coinductive.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/partiality-monad", "max_issues_repo_path": "src/Partiality-monad/Coinductive.agda", "max_line_length": 72, "max_stars_count": 2, "max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/partiality-monad", "max_stars_repo_path": "src/Partiality-monad/Coinductive.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:08.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:59:18.000Z", "num_tokens": 219, "size": 841 }
module _ where record R : Set₁ where constructor c open R {{...}}
{ "alphanum_fraction": 0.6338028169, "avg_line_length": 8.875, "ext": "agda", "hexsha": "5965d4e8a8d274a19bf56e94da7b9c1aa30ec488", "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/Issue2007.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/Issue2007.agda", "max_line_length": 21, "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/Issue2007.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": 21, "size": 71 }
-- Andreas, 2019-10-01, continuing issue #3855 (erasure modality @0) -- Test case by Nisse at https://github.com/agda/agda/issues/3855#issuecomment-527164352 -- Occurs check needs to take erasure status of definitions -- (here: postulates) into account. postulate P : Set → Set p : (A : Set) → P A @0 A : Set -- fails : P A -- fails = p A test : P A test = p _ -- Should fail with error like: -- -- Cannot instantiate the metavariable _2 to solution A -- since (part of) the solution was created in an erased context -- when checking that the expression p _ has type P A
{ "alphanum_fraction": 0.6870748299, "avg_line_length": 25.5652173913, "ext": "agda", "hexsha": "18f29788b940c4eb0211e45645b991954ea25623", "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/Issue3855OccursErasedDefinition.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/Issue3855OccursErasedDefinition.agda", "max_line_length": 88, "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/Issue3855OccursErasedDefinition.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": 174, "size": 588 }
{-# OPTIONS --without-K --safe #-} open import Relation.Binary using (Rel; Setoid; IsEquivalence) module Loop.Structures {a ℓ} {A : Set a} -- The underlying set (_≈_ : Rel A ℓ) -- The underlying equality relation where open import Algebra.Core open import Level using (_⊔_) open import Data.Product using (_,_; proj₁; proj₂) open import Algebra.Definitions _≈_ open import Loop.Definitions _≈_ open import Algebra.Structures _≈_ record IsLeftBolLoop (∙ \\ // : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where field isLoop : IsLoop ∙ \\ // ε leftBol : LeftBol ∙ open IsLoop isLoop public record IsRightBolLoop (∙ \\ // : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where field isLoop : IsLoop ∙ \\ // ε rightBol : RightBol ∙ open IsLoop isLoop public record IsMoufangLoop (∙ \\ // : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where field isLoop : IsLoop ∙ \\ // ε moufangIdentity : MoufangIdentity₁ ∙ moufangIdentity₂ : MoufangIdentity₂ ∙ moufangIdentity₃ : MoufangIdentity₃ ∙ moufangIdentity₄ : MoufangIdentity₄ ∙ open IsLoop isLoop public
{ "alphanum_fraction": 0.6518518519, "avg_line_length": 27.6923076923, "ext": "agda", "hexsha": "6018aaeb192aa2c899b41597faf5f38d09d2c1c3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "443e831e536b756acbd1afd0d6bae7bc0d288048", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra", "max_forks_repo_path": "src/Loop/Structures.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "443e831e536b756acbd1afd0d6bae7bc0d288048", "max_issues_repo_issues_event_max_datetime": "2021-10-09T08:24:56.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-04T05:30:30.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra", "max_issues_repo_path": "src/Loop/Structures.agda", "max_line_length": 67, "max_stars_count": 2, "max_stars_repo_head_hexsha": "443e831e536b756acbd1afd0d6bae7bc0d288048", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra", "max_stars_repo_path": "src/Loop/Structures.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-17T09:14:03.000Z", "max_stars_repo_stars_event_min_datetime": "2021-08-15T06:16:13.000Z", "num_tokens": 369, "size": 1080 }
-- Andreas, 2015-07-21 Issue 1612 -- Error "D is not strictly positive" should appear immediately. -- (There was a performance problem due to the use of Utils.Graph.....allPaths). {-# NON_TERMINATING #-} mutual data D : Set where c0 : A0 → D c1 : A1 → D c2 : A2 → D c3 : A3 → D c4 : A4 → D c5 : A5 → D c6 : A6 → D c7 : A7 → D c8 : A8 → D c9 : A9 → D A0 : Set A0 = B0 B0 : Set B0 = A0 → D A1 : Set A1 = B1 B1 : Set B1 = A1 → D A2 : Set A2 = B2 B2 : Set B2 = A2 → D A3 : Set A3 = B3 B3 : Set B3 = A3 → D A4 : Set A4 = B4 B4 : Set B4 = A4 → D A5 : Set A5 = B5 B5 : Set B5 = A5 → D A6 : Set A6 = B6 B6 : Set B6 = A6 → D A7 : Set A7 = B7 B7 : Set B7 = A7 → D A8 : Set A8 = B8 B8 : Set B8 = A8 → D A9 : Set A9 = B9 B9 : Set B9 = A9 → D
{ "alphanum_fraction": 0.464, "avg_line_length": 10.9375, "ext": "agda", "hexsha": "05807c6460a1a950e165b907daab6f1240c243bf", "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/Issue1612.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/Issue1612.agda", "max_line_length": 80, "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/Issue1612.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": 431, "size": 875 }
open import Relation.Nullary using (Dec; yes; no; ¬_) open import Relation.Nullary.Decidable using (from-yes) open import Relation.Nullary.Negation using (contradiction) open import Relation.Binary using (Tri) open Tri open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; sym; trans) open import Data.Empty using (⊥) open import Data.Sum using (inj₁; inj₂) module AKS.Primality.Properties where open import AKS.Nat using (ℕ; _+_; _≟_; _<_; _>_; _<?_; _≤_) open import AKS.Nat using (<-cmp; <-irrefl; <-trans; 0<1+n; ≤-antisym; 0≤n; suc-injective-≤; <⇒≤; ≢⇒¬≟; <⇒≱; n≤m⇒n<m⊎n≡m; ≤-refl; n<1+n) open import AKS.Nat using (Acc; acc; <-well-founded; _⊂_; Interval; [_,_∣_]; ⊂-well-founded; upward) open import AKS.Nat.GCD using (_∣_; _∤_; _∣?_; gcd; bézout; lemma; Identity; gcd[a,b]∣a; gcd[a,b]∣b; 0∣n⇒n≈0; ∣-respˡ; ∣⇒≤; ∣-trans) renaming (_⊥_ to _coprime_) open import AKS.Primality.Base prime≢0 : ∀ {p} → IsPrime p → p ≢ 0 prime≢0 (IsPrime✓ 1<p _) p≡0 = <-irrefl (sym p≡0) (<-trans 0<1+n 1<p) ¬prime<2 : ∀ p → p < 2 → ¬ (IsPrime p) ¬prime<2 p p<2 (IsPrime✓ 1<p ∀i∣p[i≡p]) = contradiction 1<p (<⇒≱ p<2) exclusive : ∀ {n} → IsPrime n → IsComposite n → ⊥ exclusive {n} (IsPrime✓ 1<n ∀i∣n[i≡n]) (IsComposite✓ p p<n (IsPrime✓ 1<p _) p∣n) = contradiction p<n (<-irrefl (∀i∣n[i≡n] 1<p p∣n)) n<1⇒n≡0 : ∀ {n} → n < 1 → n ≡ 0 n<1⇒n≡0 {n} n<1 = ≤-antisym (suc-injective-≤ n<1) 0≤n n⊥prime : ∀ {p} n {n≢0 : n ≢ 0} → n < p → IsPrime p → n coprime p n⊥prime {p} n {n≢0} n<p (IsPrime✓ 1<p ∀i∣p[i≡p]) with <-cmp 1 (gcd n p) ... | tri> _ _ 1>gcd[n,p] = contradiction (0∣n⇒n≈0 (∣-respˡ (n<1⇒n≡0 1>gcd[n,p]) (gcd[a,b]∣a n p))) n≢0 ... | tri≈ _ 1≡gcd[n,p] _ = sym 1≡gcd[n,p] ... | tri< 1<gcd[n,p] _ _ = contradiction p≤n (<⇒≱ n<p) where gcd[n,p]≡p : gcd n p ≡ p gcd[n,p]≡p = ∀i∣p[i≡p] 1<gcd[n,p] (gcd[a,b]∣b n p) p∣n : p ∣ n p∣n = ∣-respˡ gcd[n,p]≡p (gcd[a,b]∣a n p) p≤n : p ≤ n p≤n = ∣⇒≤ {n≢0 = ≢⇒¬≟ n≢0} p∣n bézout-prime : ∀ x p → x ≢ 0 → x < p → IsPrime p → Identity 1 x p bézout-prime x p x≢0 x<p p-isPrime with bézout x p | n⊥prime x {x≢0} x<p p-isPrime bézout-prime x p x≢0 x<p p-isPrime | lemma d gcd[x,p]≡d ident | gcd[x,p]≡1 with trans (sym gcd[x,p]≡d) gcd[x,p]≡1 bézout-prime x p x≢0 x<p p-isPrime | lemma .1 gcd[x,p]≡d ident | gcd[x,p]≡1 | refl = ident compositionalityⁱ : ∀ n → 1 < n → Acc _<_ n → Compositionality n primalityⁱ : ∀ n → 1 < n → Acc _<_ n → Primality n compositionalityⁱ n 1<n (acc downward) = loop 2 (from-yes (1 <? 2)) 1<n ⊂-well-founded ¬p<2[p∤n] where ¬p<2[p∤n] : ∀ {p} → p < 2 → IsPrime p → p ∤ n ¬p<2[p∤n] {p} p<2 p-isPrime _ = contradiction p-isPrime (¬prime<2 p p<2) cons : ∀ {x} → (IsPrime x → x ∤ n) → (∀ {p} → p < x → IsPrime p → p ∤ n) → (∀ {p} → p < 1 + x → IsPrime p → p ∤ n) cons {x} x-isPrime⇒x∤n ∀p<x[p∤n] {p} p<1+x p-isPrime p∣n with <-cmp p x ... | tri< p<x _ _ = contradiction p∣n (∀p<x[p∤n] p<x p-isPrime) ... | tri≈ _ refl _ = contradiction p∣n (x-isPrime⇒x∤n p-isPrime) ... | tri> _ _ x<p = contradiction (suc-injective-≤ p<1+x) (<⇒≱ x<p) loop : ∀ x → 1 < x → (x≤n : x ≤ n) → Acc _⊂_ [ x , n ∣ x≤n ] → (∀ {p} → p < x → IsPrime p → p ∤ n) → Compositionality n loop x 1<x x≤n (acc next) ∀p<x⇒p∤n with n≤m⇒n<m⊎n≡m x≤n ... | inj₂ refl = Prime✓ ∀p<x⇒p∤n ... | inj₁ x<n with primalityⁱ x 1<x (downward x<n) ... | Composite✓ x-isComposite = loop (1 + x) (<-trans 1<x n<1+n) x<n (next [1+x,n]⊂[x,n]) ∀p<1+x⇒p∤n where [1+x,n]⊂[x,n] : [ 1 + x , n ∣ x<n ] ⊂ [ x , n ∣ x≤n ] [1+x,n]⊂[x,n] = upward n<1+n ≤-refl ∀p<1+x⇒p∤n = cons (λ x-isPrime _ → exclusive x-isPrime x-isComposite) ∀p<x⇒p∤n ... | Prime✓ x-isPrime with x ∣? n ... | yes x∣n = Composite✓ (IsComposite✓ x x<n x-isPrime x∣n) ... | no ¬x∣n = loop (1 + x) (<-trans 1<x n<1+n) x<n (next [1+x,n]⊂[x,n]) ∀p<1+x[p∤n] where [1+x,n]⊂[x,n] : [ 1 + x , n ∣ x<n ] ⊂ [ x , n ∣ x≤n ] [1+x,n]⊂[x,n] = upward n<1+n ≤-refl ∀p<1+x[p∤n] = cons (λ _ x∣n → ¬x∣n x∣n) ∀p<x⇒p∤n primalityⁱ n 1<n wf@(acc downward) with compositionalityⁱ n 1<n wf ... | Composite✓ isComposite = Composite✓ isComposite -- n is a composite so just return the proof of compositionality ... | Prime✓ ∀p<n[p∤n] = Prime✓ (IsPrime✓ 1<n ∀i∣n[i≡n]) -- All prime divisors less then n do not divide n therefore n is prime (#1) where n≢0 : n ≢ 0 n≢0 n≡0 = <-irrefl (sym n≡0) (<-trans 0<1+n 1<n) ∀i∣n[i≡n] : ∀ {i} → 1 < i → i ∣ n → i ≡ n ∀i∣n[i≡n] {i} 1<i i∣n with <-cmp i n ... | tri> _ _ n<i = contradiction (∣⇒≤ {n≢0 = ≢⇒¬≟ n≢0} i∣n) (<⇒≱ n<i) -- i is larger than n so i divides n so i is less then or equal to n ⇒⇐ ... | tri≈ _ i≡n _ = i≡n ... | tri< i<n _ _ with primalityⁱ i 1<i (downward i<n) ... | Prime✓ i-isPrime = contradiction i∣n (∀p<n[p∤n] i<n i-isPrime) -- i is a prime divisor of n (#1) ⇒⇐ ... | Composite✓ (IsComposite✓ p p<i p-isPrime p∣i) = contradiction (∣-trans p∣i i∣n) (∀p<n[p∤n] (<-trans p<i i<n) p-isPrime) -- i is a composite number with a prime divisor therefore there exists a prime divisor of n (#1) ⇒⇐ primality : ∀ n → 1 < n → Primality n primality n 1<n = primalityⁱ n 1<n <-well-founded prime? : ∀ n → Dec (IsPrime n) prime? n with 1 <? n ... | no ¬1<n = no λ { (IsPrime✓ 1<n _) → ¬1<n 1<n } ... | yes 1<n with primality n 1<n ... | Prime✓ isPrime = yes isPrime ... | Composite✓ isComposite = no λ { isPrime → exclusive isPrime isComposite } composite? : ∀ n → Dec (IsComposite n) composite? n with 1 <? n ... | no ¬1<n = no λ { (IsComposite✓ p p<n (IsPrime✓ 1<p _) _) → ¬1<n (<-trans 1<p p<n) } ... | yes 1<n with primality n 1<n ... | Prime✓ isPrime = no λ { isComposite → exclusive isPrime isComposite } ... | Composite✓ isComposite = yes isComposite -- 13-isPrime : IsPrime 13 -- 13-isPrime = from-yes (prime? 13) -- 24-isComposite : IsComposite 24 -- 24-isComposite = from-yes (composite? 24)
{ "alphanum_fraction": 0.5555181129, "avg_line_length": 44.2910447761, "ext": "agda", "hexsha": "4892ab15fdc6f99006ef813a3f11eb14c69d75c6", "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": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mckeankylej/thesis", "max_forks_repo_path": "proofs/AKS/Primality/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "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": "mckeankylej/thesis", "max_issues_repo_path": "proofs/AKS/Primality/Properties.agda", "max_line_length": 136, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mckeankylej/thesis", "max_stars_repo_path": "proofs/AKS/Primality/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-12-01T22:38:27.000Z", "max_stars_repo_stars_event_min_datetime": "2020-12-01T22:38:27.000Z", "num_tokens": 2814, "size": 5935 }
-- Basic intuitionistic modal logic S4, without ∨, ⊥, or ◇. -- Common syntax. module BasicIS4.Syntax.Common where open import Common.ContextPair public -- Types, or propositions. infixr 10 □_ infixl 9 _∧_ infixr 7 _▻_ data Ty : Set where α_ : Atom → Ty _▻_ : Ty → Ty → Ty □_ : Ty → Ty _∧_ : Ty → Ty → Ty ⊤ : Ty -- Additional useful types. infix 7 _▻◅_ _▻◅_ : Ty → Ty → Ty A ▻◅ B = (A ▻ B) ∧ (B ▻ A) infixr 7 _▻⋯▻_ _▻⋯▻_ : Cx Ty → Ty → Ty ∅ ▻⋯▻ B = B (Ξ , A) ▻⋯▻ B = Ξ ▻⋯▻ (A ▻ B) infixr 10 □⋆_ □⋆_ : Cx Ty → Cx Ty □⋆ ∅ = ∅ □⋆ (Ξ , A) = □⋆ Ξ , □ A dist□⋆₁ : ∀ Ξ Ξ′ → □⋆ (Ξ ⧺ Ξ′) ≡ (□⋆ Ξ) ⧺ (□⋆ Ξ′) dist□⋆₁ Ξ ∅ = refl dist□⋆₁ Ξ (Ξ′ , A) = cong² _,_ (dist□⋆₁ Ξ Ξ′) refl lift⊆ : ∀ {Δ Δ′} → Δ ⊆ Δ′ → □⋆ Δ ⊆ □⋆ Δ′ lift⊆ done = done lift⊆ (skip θ) = skip (lift⊆ θ) lift⊆ (keep θ) = keep (lift⊆ θ) -- Inversion principles. invα : ∀ {P P′} → α P ≡ α P′ → P ≡ P′ invα refl = refl inv▻₁ : ∀ {A A′ B B′} → A ▻ B ≡ A′ ▻ B′ → A ≡ A′ inv▻₁ refl = refl inv▻₂ : ∀ {A A′ B B′} → A ▻ B ≡ A′ ▻ B′ → B ≡ B′ inv▻₂ refl = refl inv□ : ∀ {A A′} → □ A ≡ □ A′ → A ≡ A′ inv□ refl = refl inv∧₁ : ∀ {A A′ B B′} → A ∧ B ≡ A′ ∧ B′ → A ≡ A′ inv∧₁ refl = refl inv∧₂ : ∀ {A A′ B B′} → A ∧ B ≡ A′ ∧ B′ → B ≡ B′ inv∧₂ refl = refl -- Decidable equality on types. _≟ᵀ_ : (A A′ : Ty) → Dec (A ≡ A′) (α P) ≟ᵀ (α P′) with P ≟ᵅ P′ (α P) ≟ᵀ (α .P) | yes refl = yes refl (α P) ≟ᵀ (α P′) | no P≢P′ = no (P≢P′ ∘ invα) (α P) ≟ᵀ (A′ ▻ B′) = no λ () (α P) ≟ᵀ (□ A′) = no λ () (α P) ≟ᵀ (A′ ∧ B′) = no λ () (α P) ≟ᵀ ⊤ = no λ () (A ▻ B) ≟ᵀ (α P′) = no λ () (A ▻ B) ≟ᵀ (A′ ▻ B′) with A ≟ᵀ A′ | B ≟ᵀ B′ (A ▻ B) ≟ᵀ (.A ▻ .B) | yes refl | yes refl = yes refl (A ▻ B) ≟ᵀ (A′ ▻ B′) | no A≢A′ | _ = no (A≢A′ ∘ inv▻₁) (A ▻ B) ≟ᵀ (A′ ▻ B′) | _ | no B≢B′ = no (B≢B′ ∘ inv▻₂) (A ▻ B) ≟ᵀ (□ A′) = no λ () (A ▻ B) ≟ᵀ (A′ ∧ B′) = no λ () (A ▻ B) ≟ᵀ ⊤ = no λ () (□ A) ≟ᵀ (α P′) = no λ () (□ A) ≟ᵀ (A′ ▻ B′) = no λ () (□ A) ≟ᵀ (□ A′) with A ≟ᵀ A′ (□ A) ≟ᵀ (□ .A) | yes refl = yes refl (□ A) ≟ᵀ (□ A′) | no A≢A′ = no (A≢A′ ∘ inv□) (□ A) ≟ᵀ (A′ ∧ B′) = no λ () (□ A) ≟ᵀ ⊤ = no λ () (A ∧ B) ≟ᵀ (α P′) = no λ () (A ∧ B) ≟ᵀ (A′ ▻ B′) = no λ () (A ∧ B) ≟ᵀ (□ A′) = no λ () (A ∧ B) ≟ᵀ (A′ ∧ B′) with A ≟ᵀ A′ | B ≟ᵀ B′ (A ∧ B) ≟ᵀ (.A ∧ .B) | yes refl | yes refl = yes refl (A ∧ B) ≟ᵀ (A′ ∧ B′) | no A≢A′ | _ = no (A≢A′ ∘ inv∧₁) (A ∧ B) ≟ᵀ (A′ ∧ B′) | _ | no B≢B′ = no (B≢B′ ∘ inv∧₂) (A ∧ B) ≟ᵀ ⊤ = no λ () ⊤ ≟ᵀ (α P′) = no λ () ⊤ ≟ᵀ (A′ ▻ B′) = no λ () ⊤ ≟ᵀ (□ A′) = no λ () ⊤ ≟ᵀ (A′ ∧ B′) = no λ () ⊤ ≟ᵀ ⊤ = yes refl open ContextEquality (_≟ᵀ_) public
{ "alphanum_fraction": 0.3785185185, "avg_line_length": 24.7706422018, "ext": "agda", "hexsha": "f08ac8e9c92f022935a06d33c745c3effad236b1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/hilbert-gentzen", "max_forks_repo_path": "BasicIS4/Syntax/Common.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/hilbert-gentzen", "max_issues_repo_path": "BasicIS4/Syntax/Common.agda", "max_line_length": 62, "max_stars_count": 29, "max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/hilbert-gentzen", "max_stars_repo_path": "BasicIS4/Syntax/Common.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z", "num_tokens": 1668, "size": 2700 }
-- 2011-09-15 posted by Nisse -- {-# OPTIONS --show-implicit -v tc.lhs.unify:15 #-} module Issue292-16 where data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x postulate A : Set f : A → A data C : A → Set where c : ∀ x → C (f x) record Box : Set where constructor box field a : A b : C a test : ∀ {x₁ x₂} → box (f x₁) (c x₁) ≡ box (f x₂) (c x₂) → x₁ ≡ x₂ test refl = refl -- this failed before because we tried -- -- c x₁ : C (f x₁) =?= c₂ x₂ : C (f x₂) -- -- and did not recognize that -- -- x₁ : A =?= x₂ : A -- -- is homogeneous
{ "alphanum_fraction": 0.538869258, "avg_line_length": 17.6875, "ext": "agda", "hexsha": "ab62339d721393cd48c9808730f6320db7074bd1", "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/succeed/Issue292-16.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/Issue292-16.agda", "max_line_length": 66, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/Issue292-16.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": 232, "size": 566 }
{-# OPTIONS --without-K --safe --overlapping-instances #-} module Interpreter where open import Data.Char hiding (_≤_) open import Data.Bool hiding (_≤_) open import Data.Nat hiding (_≤_) open import Data.Unit import Data.Nat as N open import Data.Product open import Data.Sum open import Relation.Binary.PropositionalEquality as PropEq open import Relation.Nullary import Data.String as Str open import Data.Nat.Show import Data.List as List open import Data.Empty infix 3 _:::_,_ infix 2 _∈_ infix 1 _⊢_ data `Set : Set where `ℕ : `Set `Bool : `Set _`⇨_ : `Set → `Set → `Set `⊤ : `Set _`×_ : `Set → `Set → `Set _`+_ : `Set → `Set → `Set infixr 2 _`⇨_ data Var : Set where x' : Var y' : Var z' : Var -- Inequality proofs on variables data _≠_ : Var → Var → Set where x≠y : x' ≠ y' x≠z : x' ≠ z' y≠x : y' ≠ x' y≠z : y' ≠ z' z≠x : z' ≠ x' z≠y : z' ≠ y' ⟦_⟧ : `Set → Set ⟦ `ℕ ⟧ = ℕ ⟦ `Bool ⟧ = Bool ⟦ (t `⇨ s) ⟧ = ⟦ t ⟧ → ⟦ s ⟧ ⟦ `⊤ ⟧ = ⊤ ⟦ (t `× s) ⟧ = ⟦ t ⟧ × ⟦ s ⟧ ⟦ (t `+ s) ⟧ = ⟦ t ⟧ ⊎ ⟦ s ⟧ data Γ : Set where · : Γ _:::_,_ : Var → `Set → Γ → Γ data _∈_ : Var → Γ → Set where H : ∀ {x Δ t } → x ∈ x ::: t , Δ TH : ∀ {x y Δ t } → ⦃ prf : x ∈ Δ ⦄ → ⦃ neprf : x ≠ y ⦄ → x ∈ y ::: t , Δ !Γ_[_] : ∀ {x} → (Δ : Γ) → x ∈ Δ → `Set !Γ_[_] · () !Γ _ ::: t , Δ [ H ] = t !Γ _ ::: _ , Δ [ TH ⦃ prf = i ⦄ ] = !Γ Δ [ i ] infix 30 `v_ infix 30 `n_ infix 30 `¬_ infix 26 _`+_ infix 27 _`*_ infix 27 _`∧_ infix 26 _`∨_ infix 24 _`≤_ infix 24 _`,_ infixl 22 _`₋_ data _⊢_ : Γ → `Set → Set where `false : ∀ {Δ} → Δ ⊢ `Bool `true : ∀ {Δ} → Δ ⊢ `Bool `n_ : ∀ {Δ} → ℕ → Δ ⊢ `ℕ `v_ : ∀ {Δ} → (x : Var) → ⦃ i : x ∈ Δ ⦄ → Δ ⊢ !Γ Δ [ i ] _`₋_ : ∀ {Δ t s} → Δ ⊢ t `⇨ s → Δ ⊢ t → Δ ⊢ s --application `λ_`:_⇨_ : ∀ {Δ tr} → (x : Var) → (tx : `Set) → x ::: tx , Δ ⊢ tr → Δ ⊢ tx `⇨ tr _`+_ : ∀ {Δ} → Δ ⊢ `ℕ → Δ ⊢ `ℕ → Δ ⊢ `ℕ _`*_ : ∀ {Δ} → Δ ⊢ `ℕ → Δ ⊢ `ℕ → Δ ⊢ `ℕ _`∧_ : ∀ {Δ} → Δ ⊢ `Bool → Δ ⊢ `Bool → Δ ⊢ `Bool _`∨_ : ∀ {Δ} → Δ ⊢ `Bool → Δ ⊢ `Bool → Δ ⊢ `Bool _`≤_ : ∀ {Δ} → Δ ⊢ `ℕ → Δ ⊢ `ℕ → Δ ⊢ `Bool `¬_ : ∀ {Δ} → Δ ⊢ `Bool → Δ ⊢ `Bool _`,_ : ∀ {Δ t s} → Δ ⊢ t → Δ ⊢ s → Δ ⊢ t `× s `fst : ∀ {Δ t s} → Δ ⊢ t `× s → Δ ⊢ t `snd : ∀ {Δ t s} → Δ ⊢ t `× s → Δ ⊢ s `left : ∀ {Δ t s} → Δ ⊢ t → Δ ⊢ t `+ s `right : ∀ {Δ t s} → Δ ⊢ s → Δ ⊢ t `+ s `case_`of_||_ : ∀ {Δ t s u} → Δ ⊢ t `+ s → Δ ⊢ t `⇨ u → Δ ⊢ s `⇨ u → Δ ⊢ u `tt : ∀ {Δ} → Δ ⊢ `⊤ `let_`=_`in_ : ∀ {Δ th tb} → (x : Var) → Δ ⊢ th → x ::: th , Δ ⊢ tb → Δ ⊢ tb `if_`then_`else_ : ∀ {Δ t} → Δ ⊢ `Bool → Δ ⊢ t → Δ ⊢ t → Δ ⊢ t data ⟨_⟩ : Γ → Set₁ where [] : ⟨ · ⟩ _∷_ : ∀ {x t Δ} → ⟦ t ⟧ → ⟨ Δ ⟩ → ⟨ x ::: t , Δ ⟩ !_[_] : ∀ {x Δ} → ⟨ Δ ⟩ → (i : x ∈ Δ) → ⟦ !Γ Δ [ i ] ⟧ !_[_] [] () !_[_] (val ∷ env) H = val !_[_] (val ∷ env) (TH ⦃ prf = i ⦄) = ! env [ i ] interpret : ∀ {t} → · ⊢ t → ⟦ t ⟧ interpret = interpret' [] where interpret' : ∀ {Δ t} → ⟨ Δ ⟩ → Δ ⊢ t → ⟦ t ⟧ interpret' env `true = true interpret' env `false = false interpret' env `tt = tt interpret' env (`n n) = n interpret' env ((`v x) ⦃ i = idx ⦄) = ! env [ idx ] interpret' env (f `₋ x) = (interpret' env f) (interpret' env x) interpret' env (`λ _ `: tx ⇨ body) = λ (x : ⟦ tx ⟧) → interpret' (x ∷ env) body interpret' env (l `+ r) = interpret' env l + interpret' env r interpret' env (l `* r) = interpret' env l * interpret' env r interpret' env (l `∧ r) = interpret' env l ∧ interpret' env r interpret' env (l `∨ r) = interpret' env l ∨ interpret' env r interpret' env (l `≤ r) with interpret' env l N.≤? interpret' env r ... | yes p = true ... | no ¬p = false interpret' env (`¬ x) = not (interpret' env x) interpret' env (f `, s) = interpret' env f ,′ interpret' env s interpret' env (`fst p) with interpret' env p interpret' env (`fst p) | f , s = f interpret' env (`snd p) with interpret' env p interpret' env (`snd p) | f , s = s interpret' env (`left v) = inj₁ (interpret' env v) interpret' env (`right v) = inj₂ (interpret' env v) interpret' env (`case s `of le || re) with interpret' env s interpret' env (`case s `of le || re) | inj₁ l = (interpret' env le) l interpret' env (`case s `of le || re) | inj₂ r = (interpret' env re) r interpret' env (`let _ `= h `in b) = let hval = interpret' env h in interpret' (hval ∷ env) b interpret' env (`if b `then et `else ef) with interpret' env b interpret' env (`if b `then et `else ef) | true = interpret' env et interpret' env (`if b `then et `else ef) | false = interpret' env ef instance v_type₁ : ∀ {x Δ t} → x ∈ x ::: t , Δ v_type₁ = H v_type₂ : ∀ {x y Δ t} → ⦃ prf : x ∈ Δ ⦄ → ⦃ x ≠ y ⦄ → x ∈ y ::: t , Δ v_type₂ = TH instance xy : x' ≠ y' xy = x≠y xz : x' ≠ z' xz = x≠z yx : y' ≠ x' yx = y≠x yz : y' ≠ z' yz = y≠z zx : z' ≠ x' zx = z≠x zy : z' ≠ y' zy = z≠y
{ "alphanum_fraction": 0.4306460622, "avg_line_length": 30.3446327684, "ext": "agda", "hexsha": "988dac4843cabaeafba54ccbcfcffe73358f22c9", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-06-18T12:31:11.000Z", "max_forks_repo_forks_event_min_datetime": "2021-06-18T06:14:18.000Z", "max_forks_repo_head_hexsha": "2a85cc82934be9433648bca0b49b77db18de524c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "sseefried/well-typed-agda-interpreter", "max_forks_repo_path": "Interpreter.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2a85cc82934be9433648bca0b49b77db18de524c", "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": "sseefried/well-typed-agda-interpreter", "max_issues_repo_path": "Interpreter.agda", "max_line_length": 101, "max_stars_count": 3, "max_stars_repo_head_hexsha": "2a85cc82934be9433648bca0b49b77db18de524c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "sseefried/well-typed-agda-interpreter", "max_stars_repo_path": "Interpreter.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-18T12:37:46.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-18T12:06:14.000Z", "num_tokens": 2335, "size": 5371 }
-- Andreas, 2016-10-23 issue #2280: -- Solver throws away meta arguments. -- (Issue discovered by code review.) open import Common.Equality open import Common.Product data Bool : Set where true false : Bool postulate not : Bool → Bool data D (f : Bool → Bool) : Set where c : ∀ x → x ≡ not (f true) → D f test : D {!!} test = c {!!} refl -- C-c C-= says -- ?1 := not (?0 true) -- But C-c C-s solves -- ?1 := not ? -- Ulf says this is fine, since we create a new interaction meta. -- I must agree. data E (p : Bool × Bool) : Set where c : ∀ x → x ≡ not (proj₁ p) → E p test2 : E {!!} test2 = c {!!} refl -- Consequently, C-c C-s should solve the last meta as -- ?3 := not ?
{ "alphanum_fraction": 0.5968208092, "avg_line_length": 18.7027027027, "ext": "agda", "hexsha": "b35b9fdc37024fa0e055cd5d2549baf62966d0e1", "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/Issue2280.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/Issue2280.agda", "max_line_length": 65, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue2280.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": 223, "size": 692 }
module Lib.Prelude where infixr 90 _∘_ infixr 1 _,_ id : {A : Set} -> A -> A id x = x _∘_ : {A : Set}{B : A -> Set}{C : {x : A} -> B x -> Set} (f : {x : A}(y : B x) -> C y)(g : (x : A) -> B x)(x : A) -> C (g x) (f ∘ g) x = f (g x) data Unit : Set where unit : Unit {-# COMPILED_DATA Unit () () #-} postulate String : Set {-# BUILTIN STRING String #-} data _×_ (A B : Set) : Set where _,_ : A -> B -> A × B {-# COMPILED_DATA _×_ (,) (,) #-} fst : {A B : Set} -> A × B -> A fst (x , y) = x snd : {A B : Set} -> A × B -> B snd (x , y) = y
{ "alphanum_fraction": 0.4371681416, "avg_line_length": 16.1428571429, "ext": "agda", "hexsha": "2df62dfa469f25a8ff7b72b33a66b030c0198e87", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "examples/simple-lib/Lib/Prelude.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "examples/simple-lib/Lib/Prelude.agda", "max_line_length": 65, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "examples/simple-lib/Lib/Prelude.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 240, "size": 565 }
------------------------------------------------------------------------ -- Up-to techniques for the delay monad and the alternative -- coinductive definition of weak bisimilarity ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} open import Prelude module Bisimilarity.Weak.Alternative.Up-to.Delay-monad {a} {A : Type a} where open import Delay-monad import Delay-monad.Bisimilarity as B import Delay-monad.Partial-order as P open import Equality.Propositional as Eq open import Logical-equivalence using (_⇔_) open import Prelude.Size open import Excluded-middle equality-with-J open import Function-universe equality-with-J hiding (id) open import H-level equality-with-J import Bisimilarity.Weak.Alternative.Equational-reasoning-instances import Bisimilarity.Weak.Delay-monad as W′ open import Bisimilarity.Weak.Equivalent open import Equational-reasoning open import Labelled-transition-system open import Labelled-transition-system.Delay-monad A open import Relation open import Bisimilarity.Step (weak delay-monad) _[_]⇒̂_ _[_]⇒̂_ open import Bisimilarity.Up-to (weak delay-monad) import Bisimilarity.Weak delay-monad as BW open import Bisimilarity.Weak.Alternative delay-monad -- Everything is an up-to technique for the alternative coinductive -- definition of weak bisimilarity for the delay monad (if A is a set, -- and assuming excluded middle and extensionality). everything-up-to : Excluded-middle a → Eq.Extensionality a a → Is-set A → (F : Trans₂ a (Delay A ∞)) → Up-to-technique F everything-up-to em ext A-set F {R = R} R-prog {x = x , y} = everything-up-to′ x y where lemma : ∀ {x y} {P : Rel₂ a (Delay A ∞)} → (∀ {x′ z} → x [ just z ]⇒̂ x′ → ∃ λ y′ → y [ just z ]⇒̂ y′ × P (x′ , y′)) → (∃ λ z → now z B.≈ x) → x ≈ y lemma {x} {y} hyp = uncurry λ z → now z B.≈ x ↝⟨ _⇔_.to W′.direct⇔alternative ⟩ now z ≈ x ↝⟨ (λ nz≈x → Σ-map id proj₁ $ left-to-right nz≈x (⟶→⇒̂ now)) ⟩ ∃ (x [ just z ]⇒̂_) ↝⟨ (λ x⇒̂ → x⇒̂ , Σ-map id proj₁ (hyp (proj₂ x⇒̂))) ⟩ ∃ (x [ just z ]⇒̂_) × ∃ (y [ just z ]⇒̂_) ↝⟨ (uncurry λ x⇒̂ y⇒̂ → W′.⇒̂-with-equal-labels→≈ id (proj₂ x⇒̂) (proj₂ y⇒̂)) ⟩ x BW.≈ y ↝⟨ ⇒alternative ⟩□ x ≈ y □ everything-up-to′ : ∀ x y → R (x , y) → x ≈ y everything-up-to′ x y Rxy = case P.⇑⊎⇓ em ext A-set x ,′ P.⇑⊎⇓ em ext A-set y of λ where (inj₂ x⇓ , _) → lemma (StepC.left-to-right (R-prog Rxy)) x⇓ (_ , inj₂ y⇓) → symmetric (lemma (StepC.right-to-left (R-prog Rxy)) y⇓) (inj₁ x⇑ , inj₁ y⇑) → x ∼⟨ symmetric (_⇔_.to W′.direct⇔alternative x⇑) ⟩ never ∼⟨ _⇔_.to W′.direct⇔alternative y⇑ ⟩■ y
{ "alphanum_fraction": 0.5603006491, "avg_line_length": 39.0266666667, "ext": "agda", "hexsha": "e00d627a33c62bff867a0317c0decf6258c61109", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/up-to", "max_forks_repo_path": "src/Bisimilarity/Weak/Alternative/Up-to/Delay-monad.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/up-to", "max_issues_repo_path": "src/Bisimilarity/Weak/Alternative/Up-to/Delay-monad.agda", "max_line_length": 126, "max_stars_count": null, "max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/up-to", "max_stars_repo_path": "src/Bisimilarity/Weak/Alternative/Up-to/Delay-monad.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1003, "size": 2927 }
-- TODO -- Gentzen-style formalisation of syntax. -- Simple terms. module BasicT.Syntax.Gentzen where open import BasicT.Syntax.Common public -- Derivations. infix 3 _⊢_ data _⊢_ (Γ : Cx Ty) : Ty → Set where var : ∀ {A} → A ∈ Γ → Γ ⊢ A lam : ∀ {A B} → Γ , A ⊢ B → Γ ⊢ A ▻ B app : ∀ {A B} → Γ ⊢ A ▻ B → Γ ⊢ A → Γ ⊢ B pair : ∀ {A B} → Γ ⊢ A → Γ ⊢ B → Γ ⊢ A ∧ B fst : ∀ {A B} → Γ ⊢ A ∧ B → Γ ⊢ A snd : ∀ {A B} → Γ ⊢ A ∧ B → Γ ⊢ B unit : Γ ⊢ ⊤ true : Γ ⊢ BOOL false : Γ ⊢ BOOL if : ∀ {C} → Γ ⊢ BOOL → Γ ⊢ C → Γ ⊢ C → Γ ⊢ C zero : Γ ⊢ NAT suc : Γ ⊢ NAT → Γ ⊢ NAT it : ∀ {C} → Γ ⊢ NAT → Γ ⊢ C ▻ C → Γ ⊢ C → Γ ⊢ C rec : ∀ {C} → Γ ⊢ NAT → Γ ⊢ NAT ▻ C ▻ C → Γ ⊢ C → Γ ⊢ C infix 3 _⊢⋆_ _⊢⋆_ : Cx Ty → Cx Ty → Set Γ ⊢⋆ ∅ = 𝟙 Γ ⊢⋆ Ξ , A = Γ ⊢⋆ Ξ × Γ ⊢ A -- Monotonicity with respect to context inclusion. mono⊢ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢ A → Γ′ ⊢ A mono⊢ η (var i) = var (mono∈ η i) mono⊢ η (lam t) = lam (mono⊢ (keep η) t) mono⊢ η (app t u) = app (mono⊢ η t) (mono⊢ η u) mono⊢ η (pair t u) = pair (mono⊢ η t) (mono⊢ η u) mono⊢ η (fst t) = fst (mono⊢ η t) mono⊢ η (snd t) = snd (mono⊢ η t) mono⊢ η unit = unit mono⊢ η true = true mono⊢ η false = false mono⊢ η (if t u v) = if (mono⊢ η t) (mono⊢ η u) (mono⊢ η v) mono⊢ η zero = zero mono⊢ η (suc t) = suc (mono⊢ η t) mono⊢ η (it t u v) = it (mono⊢ η t) (mono⊢ η u) (mono⊢ η v) mono⊢ η (rec t u v) = rec (mono⊢ η t) (mono⊢ η u) (mono⊢ η v) mono⊢⋆ : ∀ {Ξ Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢⋆ Ξ → Γ′ ⊢⋆ Ξ mono⊢⋆ {∅} η ∙ = ∙ mono⊢⋆ {Ξ , A} η (ts , t) = mono⊢⋆ η ts , mono⊢ η t -- Shorthand for variables. v₀ : ∀ {A Γ} → Γ , A ⊢ A v₀ = var i₀ v₁ : ∀ {A B Γ} → Γ , A , B ⊢ A v₁ = var i₁ v₂ : ∀ {A B C Γ} → Γ , A , B , C ⊢ A v₂ = var i₂ -- Reflexivity. refl⊢⋆ : ∀ {Γ} → Γ ⊢⋆ Γ refl⊢⋆ {∅} = ∙ refl⊢⋆ {Γ , A} = mono⊢⋆ weak⊆ refl⊢⋆ , v₀ -- Deduction theorem is built-in. lam⋆ : ∀ {Ξ Γ A} → Γ ⧺ Ξ ⊢ A → Γ ⊢ Ξ ▻⋯▻ A lam⋆ {∅} = I lam⋆ {Ξ , B} = lam⋆ {Ξ} ∘ lam lam⋆₀ : ∀ {Γ A} → Γ ⊢ A → ∅ ⊢ Γ ▻⋯▻ A lam⋆₀ {∅} = I lam⋆₀ {Γ , B} = lam⋆₀ ∘ lam -- Detachment theorem. det : ∀ {A B Γ} → Γ ⊢ A ▻ B → Γ , A ⊢ B det t = app (mono⊢ weak⊆ t) v₀ det⋆ : ∀ {Ξ Γ A} → Γ ⊢ Ξ ▻⋯▻ A → Γ ⧺ Ξ ⊢ A det⋆ {∅} = I det⋆ {Ξ , B} = det ∘ det⋆ {Ξ} det⋆₀ : ∀ {Γ A} → ∅ ⊢ Γ ▻⋯▻ A → Γ ⊢ A det⋆₀ {∅} = I det⋆₀ {Γ , B} = det ∘ det⋆₀ -- Cut and multicut. cut : ∀ {A B Γ} → Γ ⊢ A → Γ , A ⊢ B → Γ ⊢ B cut t u = app (lam u) t multicut : ∀ {Ξ A Γ} → Γ ⊢⋆ Ξ → Ξ ⊢ A → Γ ⊢ A multicut {∅} ∙ u = mono⊢ bot⊆ u multicut {Ξ , B} (ts , t) u = app (multicut ts (lam u)) t -- Transitivity. trans⊢⋆ : ∀ {Γ″ Γ′ Γ} → Γ ⊢⋆ Γ′ → Γ′ ⊢⋆ Γ″ → Γ ⊢⋆ Γ″ trans⊢⋆ {∅} ts ∙ = ∙ trans⊢⋆ {Γ″ , A} ts (us , u) = trans⊢⋆ ts us , multicut ts u -- Contraction. ccont : ∀ {A B Γ} → Γ ⊢ (A ▻ A ▻ B) ▻ A ▻ B ccont = lam (lam (app (app v₁ v₀) v₀)) cont : ∀ {A B Γ} → Γ , A , A ⊢ B → Γ , A ⊢ B cont t = det (app ccont (lam (lam t))) -- Exchange, or Schönfinkel’s C combinator. cexch : ∀ {A B C Γ} → Γ ⊢ (A ▻ B ▻ C) ▻ B ▻ A ▻ C cexch = lam (lam (lam (app (app v₂ v₀) v₁))) exch : ∀ {A B C Γ} → Γ , A , B ⊢ C → Γ , B , A ⊢ C exch t = det (det (app cexch (lam (lam t)))) -- Composition, or Schönfinkel’s B combinator. ccomp : ∀ {A B C Γ} → Γ ⊢ (B ▻ C) ▻ (A ▻ B) ▻ A ▻ C ccomp = lam (lam (lam (app v₂ (app v₁ v₀)))) comp : ∀ {A B C Γ} → Γ , B ⊢ C → Γ , A ⊢ B → Γ , A ⊢ C comp t u = det (app (app ccomp (lam t)) (lam u)) -- Useful theorems in combinatory form. ci : ∀ {A Γ} → Γ ⊢ A ▻ A ci = lam v₀ ck : ∀ {A B Γ} → Γ ⊢ A ▻ B ▻ A ck = lam (lam v₁) cs : ∀ {A B C Γ} → Γ ⊢ (A ▻ B ▻ C) ▻ (A ▻ B) ▻ A ▻ C cs = lam (lam (lam (app (app v₂ v₀) (app v₁ v₀)))) cpair : ∀ {A B Γ} → Γ ⊢ A ▻ B ▻ A ∧ B cpair = lam (lam (pair v₁ v₀)) cfst : ∀ {A B Γ} → Γ ⊢ A ∧ B ▻ A cfst = lam (fst v₀) csnd : ∀ {A B Γ} → Γ ⊢ A ∧ B ▻ B csnd = lam (snd v₀) -- Closure under context concatenation. concat : ∀ {A B Γ} Γ′ → Γ , A ⊢ B → Γ′ ⊢ A → Γ ⧺ Γ′ ⊢ B concat Γ′ t u = app (mono⊢ (weak⊆⧺₁ Γ′) (lam t)) (mono⊢ weak⊆⧺₂ u) -- Substitution. [_≔_]_ : ∀ {A B Γ} → (i : A ∈ Γ) → Γ ∖ i ⊢ A → Γ ⊢ B → Γ ∖ i ⊢ B [ i ≔ s ] var j with i ≟∈ j [ i ≔ s ] var .i | same = s [ i ≔ s ] var ._ | diff j = var j [ i ≔ s ] lam t = lam ([ pop i ≔ mono⊢ weak⊆ s ] t) [ i ≔ s ] app t u = app ([ i ≔ s ] t) ([ i ≔ s ] u) [ i ≔ s ] pair t u = pair ([ i ≔ s ] t) ([ i ≔ s ] u) [ i ≔ s ] fst t = fst ([ i ≔ s ] t) [ i ≔ s ] snd t = snd ([ i ≔ s ] t) [ i ≔ s ] unit = unit [ i ≔ s ] true = true [ i ≔ s ] false = false [ i ≔ s ] if t u v = if ([ i ≔ s ] t) ([ i ≔ s ] u) ([ i ≔ s ] v) [ i ≔ s ] zero = zero [ i ≔ s ] suc t = suc ([ i ≔ s ] t) [ i ≔ s ] it t u v = it ([ i ≔ s ] t) ([ i ≔ s ] u) ([ i ≔ s ] v) [ i ≔ s ] rec t u v = rec ([ i ≔ s ] t) ([ i ≔ s ] u) ([ i ≔ s ] v) [_≔_]⋆_ : ∀ {Ξ A Γ} → (i : A ∈ Γ) → Γ ∖ i ⊢ A → Γ ⊢⋆ Ξ → Γ ∖ i ⊢⋆ Ξ [_≔_]⋆_ {∅} i s ∙ = ∙ [_≔_]⋆_ {Ξ , B} i s (ts , t) = [ i ≔ s ]⋆ ts , [ i ≔ s ] t -- Convertibility. data _⋙_ {Γ : Cx Ty} : ∀ {A} → Γ ⊢ A → Γ ⊢ A → Set where refl⋙ : ∀ {A} → {t : Γ ⊢ A} → t ⋙ t trans⋙ : ∀ {A} → {t t′ t″ : Γ ⊢ A} → t ⋙ t′ → t′ ⋙ t″ → t ⋙ t″ sym⋙ : ∀ {A} → {t t′ : Γ ⊢ A} → t ⋙ t′ → t′ ⋙ t conglam⋙ : ∀ {A B} → {t t′ : Γ , A ⊢ B} → t ⋙ t′ → lam t ⋙ lam t′ congapp⋙ : ∀ {A B} → {t t′ : Γ ⊢ A ▻ B} → {u u′ : Γ ⊢ A} → t ⋙ t′ → u ⋙ u′ → app t u ⋙ app t′ u′ congpair⋙ : ∀ {A B} → {t t′ : Γ ⊢ A} → {u u′ : Γ ⊢ B} → t ⋙ t′ → u ⋙ u′ → pair t u ⋙ pair t′ u′ congfst⋙ : ∀ {A B} → {t t′ : Γ ⊢ A ∧ B} → t ⋙ t′ → fst t ⋙ fst t′ congsnd⋙ : ∀ {A B} → {t t′ : Γ ⊢ A ∧ B} → t ⋙ t′ → snd t ⋙ snd t′ congsuc⋙ : ∀ {t t′ : Γ ⊢ NAT} → t ⋙ t′ → suc t ⋙ suc t′ congif⋙ : ∀ {C} → {t t′ : Γ ⊢ BOOL} → {u u′ : Γ ⊢ C} → {v v′ : Γ ⊢ C} → t ⋙ t′ → if t u v ⋙ if t′ u′ v′ congit⋙ : ∀ {C} → {t t′ : Γ ⊢ NAT} → {u u′ : Γ ⊢ C ▻ C} → {v v′ : Γ ⊢ C} → t ⋙ t′ → it t u v ⋙ it t′ u′ v′ congrec⋙ : ∀ {C} → {t t′ : Γ ⊢ NAT} → {u u′ : Γ ⊢ NAT ▻ C ▻ C} → {v v′ : Γ ⊢ C} → t ⋙ t′ → rec t u v ⋙ rec t′ u′ v′ beta▻⋙ : ∀ {A B} → {t : Γ , A ⊢ B} → {u : Γ ⊢ A} → app (lam t) u ⋙ ([ top ≔ u ] t) eta▻⋙ : ∀ {A B} → {t : Γ ⊢ A ▻ B} → t ⋙ lam (app (mono⊢ weak⊆ t) v₀) beta∧₁⋙ : ∀ {A B} → {t : Γ ⊢ A} → {u : Γ ⊢ B} → fst (pair t u) ⋙ t beta∧₂⋙ : ∀ {A B} → {t : Γ ⊢ A} → {u : Γ ⊢ B} → snd (pair t u) ⋙ u eta∧⋙ : ∀ {A B} → {t : Γ ⊢ A ∧ B} → t ⋙ pair (fst t) (snd t) eta⊤⋙ : ∀ {t : Γ ⊢ ⊤} → t ⋙ unit betaBOOL₁⋙ : ∀ {C} → {u v : Γ ⊢ C} → if true u v ⋙ u betaBOOL₂⋙ : ∀ {C} → {u v : Γ ⊢ C} → if false u v ⋙ v betaNATit₁⋙ : ∀ {C} → {u : Γ ⊢ C ▻ C} → {v : Γ ⊢ C} → it zero u v ⋙ v -- TODO: Verify this. betaNATit₂⋙ : ∀ {C} → {t : Γ ⊢ NAT} → {u : Γ ⊢ C ▻ C} → {v : Γ ⊢ C} → it (suc t) u v ⋙ app u (it t u v) betaNATrec₁⋙ : ∀ {C} → {u : Γ ⊢ NAT ▻ C ▻ C} → {v : Γ ⊢ C} → rec zero u v ⋙ v -- TODO: Verify this. betaNATrec₂⋙ : ∀ {C} → {t : Γ ⊢ NAT} → {u : Γ ⊢ NAT ▻ C ▻ C} → {v : Γ ⊢ C} → rec (suc t) u v ⋙ app (app u t) (rec t u v) -- TODO: What about eta for BOOL and NAT?
{ "alphanum_fraction": 0.3533702213, "avg_line_length": 27.901754386, "ext": "agda", "hexsha": "181fdf6f08ad9667f4103a87d30f1aebf89486ae", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/hilbert-gentzen", "max_forks_repo_path": "BasicT/Syntax/Gentzen.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/hilbert-gentzen", "max_issues_repo_path": "BasicT/Syntax/Gentzen.agda", "max_line_length": 85, "max_stars_count": 29, "max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/hilbert-gentzen", "max_stars_repo_path": "BasicT/Syntax/Gentzen.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z", "num_tokens": 4052, "size": 7952 }
-- Andreas, 2015-05-01 -- With clauses for functions with flexible arity. -- {-# OPTIONS -v tc.with:40 #-} open import Common.Prelude open import Common.Equality mutual even : Nat → Bool even 0 = true even (suc n) = odd n odd : Nat → Bool odd 0 = false odd (suc n) = even n NPred : Nat → Set NPred 0 = Bool NPred (suc n) = Nat → NPred n const : Bool → ∀{n} → NPred n const b {0} = b const b {suc n} m = const b {n} allOdd : ∀ n → NPred n allOdd 0 = true allOdd (suc n) m with even m ... | true = const false ... | false = allOdd n test : allOdd 4 1 3 5 7 ≡ true test = refl
{ "alphanum_fraction": 0.5944625407, "avg_line_length": 18.0588235294, "ext": "agda", "hexsha": "d47339a10243c83dc52968e063625e471adc6c9c", "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/WithFlexibleArity.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/WithFlexibleArity.agda", "max_line_length": 50, "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/WithFlexibleArity.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 230, "size": 614 }
module par-swap.dpg where open import par-swap open import par-swap.properties open import par-swap.confluent open import par-swap.dpg-pot open import par-swap.dpg-e-view open import noetherian using (noetherian ; ∥_∥s) open import Esterel.Lang open import Esterel.Lang.Properties open import Esterel.Lang.Binding open import Esterel.Environment as Env open import Esterel.Context open import Data.Product open import Data.Bool open import Data.Empty open import Data.List using ([] ; [_] ; _∷_ ; List ; _++_) open import Data.Sum open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; sym ; subst ; cong ; trans ; module ≡-Reasoning ; cong₂ ; subst₂ ; inspect) open import sn-calculus open import context-properties -- get view, E-views DPG₁ : ∀ {p q r} -> (p ∥ q) sn⟶₁ r -> ∃ \ {(d , d₁) -> (q ∥ p) sn⟶ d₁ × d₁ sn⟶* d × r ∥R* d} DPG₁{p} {q} {r} (rpar-done-right haltedp doneq) = (r , r) , fixup-valuemax₁ doneq haltedp (rcontext [] dchole (rpar-done-left doneq haltedp)) , rrefl , ∥R0 where fixup-valuemax₁ : ∀ {p q} -> (doneq : done q) -> (haltedp : halted p) -> q ∥ p sn⟶ value-max doneq (dhalted haltedp) (inj₂ haltedp) -> q ∥ p sn⟶ value-max (dhalted haltedp) doneq (inj₁ haltedp) fixup-valuemax₁ donep haltedq rewrite value-max-sym donep haltedq = λ z → z DPG₁{p}{q}{r} (rpar-done-left donep haltedq) = (r , r) , fixup-valuemax₂ donep haltedq (rcontext [] dchole (rpar-done-right haltedq donep)) , rrefl , ∥R0 where fixup-valuemax₂ : ∀ {p q} -> (donep : done p) -> (haltedq : halted q) -> q ∥ p sn⟶ value-max (dhalted haltedq) donep (inj₁ haltedq) -> q ∥ p sn⟶ value-max donep (dhalted haltedq) (inj₂ haltedq) fixup-valuemax₂ donep haltedq rewrite sym (value-max-sym donep haltedq) = λ z → z par-not-halted : ∀ {p C q₁ q₂} -> halted p -> p ≐ C ⟦ q₁ ∥ q₂ ⟧c -> ⊥ par-not-halted hnothin () par-not-halted (hexit n) () swap-paused-is-paused : ∀ {p C q₁ q₂} -> paused p -> p ≐ C ⟦ q₁ ∥ q₂ ⟧c -> paused (C ⟦ q₂ ∥ q₁ ⟧c) swap-paused-is-paused ppause () swap-paused-is-paused (pseq pausedp) (dcseq₁ dc) = pseq (swap-paused-is-paused pausedp dc) swap-paused-is-paused (pseq pausedp) (dcseq₂ dc) = pseq pausedp swap-paused-is-paused (ploopˢ pausedp) (dcloopˢ₁ dc) = ploopˢ (swap-paused-is-paused pausedp dc) swap-paused-is-paused (ploopˢ pausedp) (dcloopˢ₂ dc) = ploopˢ pausedp swap-paused-is-paused (ppar pausedp pausedp₁) dchole = ppar pausedp₁ pausedp swap-paused-is-paused (ppar pausedp pausedp₁) (dcpar₁ dc) = ppar (swap-paused-is-paused pausedp dc) pausedp₁ swap-paused-is-paused (ppar pausedp pausedp₁) (dcpar₂ dc) = ppar pausedp (swap-paused-is-paused pausedp₁ dc) swap-paused-is-paused (psuspend pausedp) (dcsuspend dc) = psuspend (swap-paused-is-paused pausedp dc) swap-paused-is-paused (ptrap pausedp) (dctrap dc) = ptrap (swap-paused-is-paused pausedp dc) DPG : ∀ {a b c} -> a ∥R b -> a sn⟶ c -> Σ (Term × Term) λ {(d , d₁) -> b sn⟶ d₁ × d₁ sn⟶* d × c ∥R* d} DPG (∥Rstep dchole) (rcontext _ dchole psn⟶₁p') = DPG₁ psn⟶₁p' DPG (∥Rstep dchole) (rcontext _ (dcpar₁ dcsn⟶) psn⟶₁p') = _ , rcontext _ (dcpar₂ dcsn⟶) psn⟶₁p' , rrefl , ∥Rn (∥Rstep dchole) ∥R0 DPG (∥Rstep dchole) (rcontext _ (dcpar₂ dcsn⟶) psn⟶₁p') = _ , rcontext _ (dcpar₁ dcsn⟶) psn⟶₁p' , rrefl , ∥Rn (∥Rstep dchole) ∥R0 DPG (∥Rstep (dcpar₁ dc∥R)) (rcontext .[] dchole (rpar-done-right haltedp doneq)) = ⊥-elim (par-not-halted haltedp dc∥R) DPG (∥Rstep (dcpar₁ dc∥R)) (rcontext .[] dchole (rpar-done-left (dhalted p/halted) haltedq)) = ⊥-elim (par-not-halted p/halted dc∥R) DPG (∥Rstep (dcpar₁ dc∥R)) (rcontext .[] dchole (rpar-done-left (dpaused p/paused) hnothin)) = _ , rcontext [] dchole (rpar-done-left (dpaused (swap-paused-is-paused p/paused dc∥R)) hnothin) , rrefl , ∥Rn (∥Rstep dc∥R) ∥R0 DPG (∥Rstep (dcpar₁ dc∥R)) (rcontext .[] dchole (rpar-done-left (dpaused p/paused) (hexit n))) = _ , rcontext [] dchole (rpar-done-left (dpaused (swap-paused-is-paused p/paused dc∥R)) (hexit n)) , rrefl , ∥R0 DPG (∥Rstep (dcpar₁ dc∥R)) (rcontext (ceval (epar₁ _) ∷ C) (dcpar₁ dcsn⟶) psn⟶₁p') with DPG (∥Rstep dc∥R) (rcontext C dcsn⟶ psn⟶₁p') ... | _ , sn⟶step , sn⟶*step , ∥R*step = _ , Context1-sn⟶ (ceval (epar₁ _)) sn⟶step , Context1-sn⟶* (ceval (epar₁ _)) sn⟶*step , Context1-∥R* (ceval (epar₁ _)) ∥R*step DPG (∥Rstep (dcpar₁ dc∥R)) (rcontext _ (dcpar₂ dcsn⟶) psn⟶₁p') = _ , rcontext _ (dcpar₂ dcsn⟶) psn⟶₁p' , rrefl , ∥Rn (∥Rstep (dcpar₁ dc∥R)) ∥R0 DPG (∥Rstep (dcpar₂ dc∥R)) (rcontext .[] dchole (rpar-done-right haltedp (dhalted p/halted))) = ⊥-elim (par-not-halted p/halted dc∥R) DPG (∥Rstep (dcpar₂ dc∥R)) (rcontext .[] dchole (rpar-done-right hnothin (dpaused p/paused))) = _ , rcontext [] dchole (rpar-done-right hnothin (dpaused (swap-paused-is-paused p/paused dc∥R))) , rrefl , ∥Rn (∥Rstep dc∥R) ∥R0 DPG (∥Rstep (dcpar₂ dc∥R)) (rcontext .[] dchole (rpar-done-right (hexit n) (dpaused p/paused))) = _ , rcontext [] dchole (rpar-done-right (hexit n) (dpaused (swap-paused-is-paused p/paused dc∥R))) , rrefl , ∥R0 DPG (∥Rstep (dcpar₂ dc∥R)) (rcontext .[] dchole (rpar-done-left donep haltedq)) = ⊥-elim (par-not-halted haltedq dc∥R) DPG (∥Rstep (dcpar₂ dc∥R)) (rcontext _ (dcpar₁ dcsn⟶) psn⟶₁p') = _ , (rcontext _ (dcpar₁ dcsn⟶) psn⟶₁p') , rrefl , ∥Rn (∥Rstep (dcpar₂ dc∥R)) ∥R0 DPG (∥Rstep (dcpar₂ dc∥R)) (rcontext (c ∷ C) (dcpar₂ dcsn⟶) psn⟶₁p') with DPG (∥Rstep dc∥R) (rcontext C dcsn⟶ psn⟶₁p') ... | _ , sn⟶step , sn⟶*step , ∥R*step = _ , Context1-sn⟶ c sn⟶step , Context1-sn⟶* c sn⟶*step , Context1-∥R* c ∥R*step DPG (∥Rstep (dcseq₁ ())) (rcontext .[] dchole rseq-done) DPG (∥Rstep (dcseq₁ ())) (rcontext .[] dchole rseq-exit) DPG (∥Rstep (dcseq₁ dc∥R)) (rcontext (c ∷ C) (dcseq₁ dcsn⟶) psn⟶₁p') with DPG (∥Rstep dc∥R) (rcontext C dcsn⟶ psn⟶₁p') ... | _ , sn⟶step , sn⟶*step , ∥R*step = _ , Context1-sn⟶ c sn⟶step , Context1-sn⟶* c sn⟶*step , Context1-∥R* c ∥R*step DPG (∥Rstep (dcseq₁ dc∥R)) (rcontext _ (dcseq₂ dcsn⟶) psn⟶₁p') = _ , rcontext _ (dcseq₂ dcsn⟶) psn⟶₁p' , rrefl , ∥Rn (∥Rstep (dcseq₁ dc∥R)) ∥R0 DPG (∥Rstep (dcseq₂ dc∥R)) (rcontext .[] dchole rseq-done) = _ , rcontext [] dchole rseq-done , rrefl , ∥Rn (∥Rstep dc∥R) ∥R0 DPG (∥Rstep (dcseq₂ dc∥R)) (rcontext .[] dchole rseq-exit) = _ , rcontext [] dchole rseq-exit , rrefl , ∥R0 DPG (∥Rstep (dcseq₂ dc∥R)) (rcontext _ (dcseq₁ dcsn⟶) psn⟶₁p') = _ , rcontext _ (dcseq₁ dcsn⟶) psn⟶₁p' , rrefl , ∥Rn (∥Rstep (dcseq₂ dc∥R)) ∥R0 DPG (∥Rstep (dcseq₂ dc∥R)) (rcontext (c ∷ C) (dcseq₂ dcsn⟶) psn⟶₁p') with DPG (∥Rstep dc∥R) (rcontext C dcsn⟶ psn⟶₁p') ... | _ , sn⟶step , sn⟶*step , ∥R*step = _ , Context1-sn⟶ c sn⟶step , Context1-sn⟶* c sn⟶*step , Context1-∥R* c ∥R*step DPG (∥Rstep (dcsuspend dc∥R)) (rcontext .[] dchole (rsuspend-done haltedp)) = ⊥-elim (par-not-halted haltedp dc∥R) DPG (∥Rstep (dcsuspend dc∥R)) (rcontext (c ∷ C) (dcsuspend dcsn⟶) psn⟶₁p') with DPG (∥Rstep dc∥R) (rcontext C dcsn⟶ psn⟶₁p') ... | _ , sn⟶step , sn⟶*step , ∥R*step = _ , Context1-sn⟶ c sn⟶step , Context1-sn⟶* c sn⟶*step , Context1-∥R* c ∥R*step DPG (∥Rstep (dctrap dc∥R)) (rcontext .[] dchole (rtrap-done haltedp)) = ⊥-elim (par-not-halted haltedp dc∥R) DPG (∥Rstep (dctrap dc∥R)) (rcontext (c ∷ C) (dctrap dcsn⟶) psn⟶₁p') with DPG (∥Rstep dc∥R) (rcontext C dcsn⟶ psn⟶₁p') ... | _ , sn⟶step , sn⟶*step , ∥R*step = _ , Context1-sn⟶ c sn⟶step , Context1-sn⟶* c sn⟶*step , Context1-∥R* c ∥R*step DPG (∥Rstep (dcsignl dc∥R)) (rcontext .[] dchole rraise-signal) = _ , (rcontext [] dchole rraise-signal) , rrefl , (∥Rn (∥Rstep (dcenv dc∥R)) ∥R0) DPG (∥Rstep (dcsignl dc∥R)) (rcontext (c ∷ C) (dcsignl dcsn⟶) psn⟶₁p') with DPG (∥Rstep dc∥R) (rcontext C dcsn⟶ psn⟶₁p') ... | _ , sn⟶step , sn⟶*step , ∥R*step = _ , Context1-sn⟶ c sn⟶step , Context1-sn⟶* c sn⟶*step , Context1-∥R* c ∥R*step DPG (∥Rstep (dcpresent₁ dc∥R)) (rcontext .[] dchole ()) DPG (∥Rstep (dcpresent₁ dc∥R)) (rcontext (c ∷ C) (dcpresent₁ dcsn⟶) psn⟶₁p') with DPG (∥Rstep dc∥R) (rcontext C dcsn⟶ psn⟶₁p') ... | _ , sn⟶step , sn⟶*step , ∥R*step = _ , Context1-sn⟶ c sn⟶step , Context1-sn⟶* c sn⟶*step , Context1-∥R* c ∥R*step DPG (∥Rstep (dcpresent₁ dc∥R)) (rcontext _ (dcpresent₂ dcsn⟶) psn⟶₁p') = _ , rcontext _ (dcpresent₂ dcsn⟶) psn⟶₁p' , rrefl , ∥Rn (∥Rstep (dcpresent₁ dc∥R)) ∥R0 DPG (∥Rstep (dcpresent₂ dc∥R)) (rcontext .[] dchole ()) DPG (∥Rstep (dcpresent₂ dc∥R)) (rcontext _ (dcpresent₁ dcsn⟶) psn⟶₁p') = _ , rcontext _ (dcpresent₁ dcsn⟶) psn⟶₁p' , rrefl , ∥Rn (∥Rstep (dcpresent₂ dc∥R)) ∥R0 DPG (∥Rstep (dcpresent₂ dc∥R)) (rcontext (c ∷ C) (dcpresent₂ dcsn⟶) psn⟶₁p') with DPG (∥Rstep dc∥R) (rcontext C dcsn⟶ psn⟶₁p') ... | _ , sn⟶step , sn⟶*step , ∥R*step = _ , Context1-sn⟶ c sn⟶step , Context1-sn⟶* c sn⟶*step , Context1-∥R* c ∥R*step DPG (∥Rstep (dcloop dc∥R)) (rcontext .[] dchole rloop-unroll) = _ , (rcontext [] dchole rloop-unroll) , rrefl , ∥Rn (∥Rstep (dcloopˢ₁ dc∥R)) (∥Rn (∥Rstep (dcloopˢ₂ dc∥R)) ∥R0) DPG (∥Rstep (dcloop dc∥R)) (rcontext (c ∷ C) (dcloop dcsn⟶) psn⟶₁p') with DPG (∥Rstep dc∥R) (rcontext C dcsn⟶ psn⟶₁p') ... | _ , sn⟶step , sn⟶*step , ∥R*step = _ , Context1-sn⟶ c sn⟶step , Context1-sn⟶* c sn⟶*step , Context1-∥R* c ∥R*step DPG (∥Rstep (dcloopˢ₁ ())) (rcontext .[] dchole rloopˢ-exit) DPG (∥Rstep (dcloopˢ₁ dc∥R)) (rcontext (c ∷ C) (dcloopˢ₁ dcsn⟶) psn⟶₁p') with DPG (∥Rstep dc∥R) (rcontext C dcsn⟶ psn⟶₁p') ... | _ , sn⟶step , sn⟶*step , ∥R*step = _ , Context1-sn⟶ c sn⟶step , Context1-sn⟶* c sn⟶*step , Context1-∥R* c ∥R*step DPG (∥Rstep (dcloopˢ₁ dc∥R)) (rcontext _ (dcloopˢ₂ dcsn⟶) psn⟶₁p') = _ , rcontext _ (dcloopˢ₂ dcsn⟶) psn⟶₁p' , rrefl , ∥Rn (∥Rstep (dcloopˢ₁ dc∥R)) ∥R0 DPG (∥Rstep (dcloopˢ₂ dc∥R)) (rcontext .[] dchole rloopˢ-exit) = _ , (rcontext [] dchole rloopˢ-exit) , rrefl , ∥R0 DPG (∥Rstep (dcloopˢ₂ dc∥R)) (rcontext _ (dcloopˢ₁ dcsn⟶) psn⟶₁p') = _ , rcontext _ (dcloopˢ₁ dcsn⟶) psn⟶₁p' , rrefl , ∥Rn (∥Rstep (dcloopˢ₂ dc∥R)) ∥R0 DPG (∥Rstep (dcloopˢ₂ dc∥R)) (rcontext (c ∷ C) (dcloopˢ₂ dcsn⟶) psn⟶₁p') with DPG (∥Rstep dc∥R) (rcontext C dcsn⟶ psn⟶₁p') ... | _ , sn⟶step , sn⟶*step , ∥R*step = _ , Context1-sn⟶ c sn⟶step , Context1-sn⟶* c sn⟶*step , Context1-∥R* c ∥R*step DPG (∥Rstep (dcshared dc∥R)) (rcontext .[] dchole ()) DPG (∥Rstep (dcshared dc∥R)) (rcontext (c ∷ C) (dcshared dcsn⟶) psn⟶₁p') with DPG (∥Rstep dc∥R) (rcontext C dcsn⟶ psn⟶₁p') ... | _ , sn⟶step , sn⟶*step , ∥R*step = _ , Context1-sn⟶ c sn⟶step , Context1-sn⟶* c sn⟶*step , Context1-∥R* c ∥R*step DPG (∥Rstep (dcvar dc∥R)) (rcontext .[] dchole ()) DPG (∥Rstep (dcvar dc∥R)) (rcontext (c ∷ C) (dcvar dcsn⟶) psn⟶₁p') with DPG (∥Rstep dc∥R) (rcontext C dcsn⟶ psn⟶₁p') ... | _ , sn⟶step , sn⟶*step , ∥R*step = _ , Context1-sn⟶ c sn⟶step , Context1-sn⟶* c sn⟶*step , Context1-∥R* c ∥R*step DPG (∥Rstep (dcif₁ dc∥R)) (rcontext .[] dchole ()) DPG (∥Rstep (dcif₁ dc∥R)) (rcontext (c ∷ C) (dcif₁ dcsn⟶) psn⟶₁p') with DPG (∥Rstep dc∥R) (rcontext C dcsn⟶ psn⟶₁p') ... | _ , sn⟶step , sn⟶*step , ∥R*step = _ , Context1-sn⟶ c sn⟶step , Context1-sn⟶* c sn⟶*step , Context1-∥R* c ∥R*step DPG (∥Rstep (dcif₁ dc∥R)) (rcontext _ (dcif₂ dcsn⟶) psn⟶₁p') = _ , rcontext _ (dcif₂ dcsn⟶) psn⟶₁p' , rrefl , ∥Rn (∥Rstep (dcif₁ dc∥R)) ∥R0 DPG (∥Rstep (dcif₂ dc∥R)) (rcontext .[] dchole ()) DPG (∥Rstep (dcif₂ dc∥R)) (rcontext _ (dcif₁ dcsn⟶) psn⟶₁p') = _ , rcontext _ (dcif₁ dcsn⟶) psn⟶₁p' , rrefl , ∥Rn (∥Rstep (dcif₂ dc∥R)) ∥R0 DPG (∥Rstep (dcif₂ dc∥R)) (rcontext (c ∷ C) (dcif₂ dcsn⟶) psn⟶₁p') with DPG (∥Rstep dc∥R) (rcontext C dcsn⟶ psn⟶₁p') ... | _ , sn⟶step , sn⟶*step , ∥R*step = _ , Context1-sn⟶ c sn⟶step , Context1-sn⟶* c sn⟶*step , Context1-∥R* c ∥R*step DPG (∥Rstep (dcenv dc∥R)) (rcontext{p' = p'} .[] dchole psn⟶₁p') with ρ-stays-ρ-sn⟶₁ psn⟶₁p' ... | θ' , q , A' , refl with get-view psn⟶₁p' ... | inj₂ (eq , eq2 , pot-view) = DPG-pot-view dc∥R psn⟶₁p' eq eq2 pot-view ... | inj₁ (E , pin , qin , peq , qeq , E-view) with DPG-E-view peq qeq dc∥R psn⟶₁p' E-view ... | (d , sn⟶step , ∥R*-step , _ ) = _ , rcontext [] dchole sn⟶step , rrefl , Context1-∥R* (cenv θ' _) ∥R*-step DPG (∥Rstep (dcenv dc∥R)) (rcontext (c ∷ C) (dcenv dcsn⟶) psn⟶₁p') with DPG (∥Rstep dc∥R) (rcontext C dcsn⟶ psn⟶₁p') ... | _ , sn⟶step , sn⟶*step , ∥R*step = _ , Context1-sn⟶ c sn⟶step , Context1-sn⟶* c sn⟶*step , Context1-∥R* c ∥R*step
{ "alphanum_fraction": 0.6097329001, "avg_line_length": 32.6865284974, "ext": "agda", "hexsha": "8f811f640ac2b5ff504b75304278b40baa06a65e", "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/par-swap/dpg.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/par-swap/dpg.agda", "max_line_length": 100, "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/par-swap/dpg.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": 6047, "size": 12617 }
module UnSizedIO.Console where open import NativeIO open import UnSizedIO.Base hiding (main) data ConsoleCommand : Set where putStrLn : String → ConsoleCommand getLine : ConsoleCommand ConsoleResponse : ConsoleCommand → Set ConsoleResponse (putStrLn s) = Unit ConsoleResponse getLine = String ConsoleInterface : IOInterface Command ConsoleInterface = ConsoleCommand Response ConsoleInterface = ConsoleResponse IOConsole : Set → Set IOConsole = IO ConsoleInterface IOConsole+ : Set → Set IOConsole+ = IO+ ConsoleInterface translateIOConsoleLocal : (c : ConsoleCommand) → NativeIO (ConsoleResponse c) translateIOConsoleLocal (putStrLn s) = nativePutStrLn s translateIOConsoleLocal getLine = nativeGetLine translateIOConsole : {A : Set} → IOConsole A → NativeIO A translateIOConsole = translateIO translateIOConsoleLocal main : NativeIO Unit main = nativePutStrLn "Console"
{ "alphanum_fraction": 0.796875, "avg_line_length": 27.1515151515, "ext": "agda", "hexsha": "16914c3a8448288cf41773f86a25ecac4fc02cf1", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "src/UnSizedIO/Console.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "src/UnSizedIO/Console.agda", "max_line_length": 77, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "src/UnSizedIO/Console.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 215, "size": 896 }
module Base.Free.Instance.Maybe.Properties where open import Relation.Binary.PropositionalEquality using (refl; cong) open import Base.Free using (Free; pure; impure; _>>=_) open import Base.Free.Instance.Maybe using (Just; Nothing) renaming (Maybe to MaybeF) open import Base.Isomorphism using (_≃_) open _≃_ open import Base.Extensionality using (ext) open import Data.Unit using (tt) import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; cong) -- The usual `Maybe` monad representation an the free version are isomorphic. data Maybe (A : Set) : Set where just : A → Maybe A nothing : Maybe A Maybe≃MaybeF : ∀ {A} → Maybe A ≃ MaybeF A to Maybe≃MaybeF (just x) = Just x to Maybe≃MaybeF nothing = Nothing from Maybe≃MaybeF (pure x) = just x from Maybe≃MaybeF (impure tt _) = nothing from∘to Maybe≃MaybeF (just x) = refl from∘to Maybe≃MaybeF nothing = refl to∘from Maybe≃MaybeF (pure x) = refl to∘from Maybe≃MaybeF (impure tt x) = cong (impure tt) (ext λ()) Nothing>>=k≡Nothing : ∀ {A B} → (k : A → MaybeF B) → (Nothing >>= k) ≡ Nothing Nothing>>=k≡Nothing k = cong (impure tt) (ext (λ ()))
{ "alphanum_fraction": 0.612804878, "avg_line_length": 38.5882352941, "ext": "agda", "hexsha": "52405cd380a6f4f2394427efcc097e387287b08d", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-05-14T07:48:41.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-08T11:23:46.000Z", "max_forks_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "FreeProving/free-compiler", "max_forks_repo_path": "base/agda/Base/Free/Instance/Maybe/Properties.agda", "max_issues_count": 120, "max_issues_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9", "max_issues_repo_issues_event_max_datetime": "2020-12-08T07:46:01.000Z", "max_issues_repo_issues_event_min_datetime": "2020-04-09T09:40:39.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "FreeProving/free-compiler", "max_issues_repo_path": "base/agda/Base/Free/Instance/Maybe/Properties.agda", "max_line_length": 110, "max_stars_count": 36, "max_stars_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "FreeProving/free-compiler", "max_stars_repo_path": "base/agda/Base/Free/Instance/Maybe/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-21T13:38:23.000Z", "max_stars_repo_stars_event_min_datetime": "2020-02-06T11:03:34.000Z", "num_tokens": 366, "size": 1312 }
-- MIT License -- Copyright (c) 2021 Luca Ciccone and Luca Padovani -- Permission is hereby granted, free of charge, to any person -- obtaining a copy of this software and associated documentation -- files (the "Software"), to deal in the Software without -- restriction, including without limitation the rights to use, -- copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the -- Software is furnished to do so, subject to the following -- conditions: -- The above copyright notice and this permission notice shall be -- included in all copies or substantial portions of the Software. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -- OTHER DEALINGS IN THE SOFTWARE. {-# OPTIONS --guardedness #-} open import Data.Empty open import Data.Product open import Data.List using ([]; _∷_; _∷ʳ_) open import Relation.Unary using (_∈_) open import Relation.Binary.PropositionalEquality using (_≡_; refl) import Relation.Binary.HeterogeneousEquality as Het open import Common module Transitions {ℙ : Set} (message : Message ℙ) where open import SessionType message open import Trace message data Transition : SessionType -> Action -> SessionType -> Set where inp : ∀{f x} -> Transition (inp f) (I x) (f x .force) out : ∀{f x} (!x : x ∈ dom f) -> Transition (out f) (O x) (f x .force) data Transitions : SessionType -> Trace -> SessionType -> Set where refl : ∀{T} -> Transitions T [] T step : ∀{T α T' φ T''} (t : Transition T α T') (tr : Transitions T' φ T'') -> Transitions T (α ∷ φ) T'' transition->defined : ∀{T a S} -> Transition T a S -> Defined T transition->defined inp = inp transition->defined (out _) = out output-transition->defined : ∀{T x S} -> Transition T (O x) S -> Defined S output-transition->defined (out !x) = !x output-transitions->defined : ∀{T φ x S} -> Transitions T (φ ∷ʳ O x) S -> Defined S output-transitions->defined {_} {[]} (step (out fx) refl) = fx output-transitions->defined {_} {_ ∷ _} (step _ tr) = output-transitions->defined tr unsnoc-transitions : ∀{T φ α S} -> Transitions T (φ ∷ʳ α) S -> ∃[ R ] (Transitions T φ R × Transition R α S) unsnoc-transitions {_} {[]} (step t refl) = _ , refl , t unsnoc-transitions {_} {x ∷ φ} (step t tr) with unsnoc-transitions tr ... | _ , sr , s = _ , step t sr , s transitions+defined->defined : ∀{T as S} -> Transitions T as S -> Defined S -> Defined T transitions+defined->defined refl def = def transitions+defined->defined (step t _) _ = transition->defined t transitions-eq : ∀{T T' T'' φ} (tr : Transitions T φ T') (sr : Transitions T φ T'') -> T' ≡ T'' × tr Het.≅ sr transitions-eq refl refl = refl , Het.refl transitions-eq (step inp tr) (step inp sr) with transitions-eq tr sr ... | refl , Het.refl = refl , Het.refl transitions-eq (step (out fx) tr) (step (out gx) sr) with Defined-eq fx gx | transitions-eq tr sr ... | refl | refl , Het.refl = refl , Het.refl win-reduces-⊥ : ∀{S S' α} → Win S → Transition S α S' → ⊥ win-reduces-⊥ (out e) (out !x) = e _ !x
{ "alphanum_fraction": 0.6841953193, "avg_line_length": 42.2073170732, "ext": "agda", "hexsha": "0af6e1d97ea83d88c44a0b5f686154436b8455da", "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": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "boystrange/FairSubtypingAgda", "max_forks_repo_path": "src/Transitions.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "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": "boystrange/FairSubtypingAgda", "max_issues_repo_path": "src/Transitions.agda", "max_line_length": 108, "max_stars_count": 4, "max_stars_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "boystrange/FairSubtypingAgda", "max_stars_repo_path": "src/Transitions.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-24T14:38:47.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-29T14:32:30.000Z", "num_tokens": 997, "size": 3461 }
{-# OPTIONS --sized-types --show-implicit #-} module WrongSizeAssignment where postulate Size : Set _^ : Size -> Size ∞ : Size {-# BUILTIN SIZE Size #-} {-# BUILTIN SIZESUC _^ #-} {-# BUILTIN SIZEINF ∞ #-} data Empty : Set where data N : {_ : Size} -> Set where zero : N {∞} suc : forall {i} -> N {i ^} -> N {i} lift : forall {i} -> N {i} -> N {i ^} lift zero = zero lift (suc x) = suc (lift x) f : forall {i} -> N {i ^} -> Empty f x = f (suc (lift x))
{ "alphanum_fraction": 0.5301455301, "avg_line_length": 18.5, "ext": "agda", "hexsha": "9bca601399886463edb1ab77b2a99a7a19cd297e", "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/WrongSizeAssignment.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/WrongSizeAssignment.agda", "max_line_length": 45, "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/WrongSizeAssignment.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": 171, "size": 481 }
{-# OPTIONS --cubical --no-import-sorts #-} open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Function.Base using (_∋_; _$_) import Cubical.Algebra.Monoid as Std open import MorePropAlgebra.Bundles module MorePropAlgebra.Properties.Monoid {ℓ} (assumptions : Monoid {ℓ}) where open Monoid assumptions renaming (Carrier to F) import MorePropAlgebra.Properties.Semigroup module Semigroup'Properties = MorePropAlgebra.Properties.Semigroup (record { Monoid assumptions }) module Semigroup' = Semigroup (record { Monoid assumptions }) ( Semigroup') = Semigroup ∋ (record { Monoid assumptions }) stdIsMonoid : Std.IsMonoid ε _·_ stdIsMonoid .Std.IsMonoid.isSemigroup = Semigroup'Properties.stdIsSemigroup stdIsMonoid .Std.IsMonoid.identity = is-identity stdMonoid : Std.Monoid {ℓ} stdMonoid = record { Monoid assumptions ; isMonoid = stdIsMonoid }
{ "alphanum_fraction": 0.7112244898, "avg_line_length": 44.5454545455, "ext": "agda", "hexsha": "8c3ed2466fe57b65049d4ee7a959516dd7a69bcc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "agda/MorePropAlgebra/Properties/Monoid.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mchristianl/synthetic-reals", "max_issues_repo_path": "agda/MorePropAlgebra/Properties/Monoid.agda", "max_line_length": 100, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "agda/MorePropAlgebra/Properties/Monoid.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 261, "size": 980 }
module _ (C Dummy : Set) where data Maybe : Set where nothing : Maybe IfJust : Maybe → Set → Set IfJust nothing P = P postulate qCtx : C inferRes : Maybe -- v-- Implicit is important here inferResBest : IfJust inferRes ({G : Maybe} → C) inferResBest with inferRes inferResBest | nothing = qCtx -- Error: Dummy != C when checking qCtx : C -- Test also with an existing implicit argument inferResBest₁ : {A : Set} → IfJust inferRes ({G : Maybe} → C) inferResBest₁ with inferRes inferResBest₁ | nothing = qCtx -- Error: Dummy != C when checking qCtx : C -- Make sure it does break down on underapplied clauses underapplied : Maybe → C underapplied with inferRes underapplied | nothing = λ _ → qCtx
{ "alphanum_fraction": 0.6760374833, "avg_line_length": 26.6785714286, "ext": "agda", "hexsha": "2eab347236c3aaeb4189029ba24e83a87031c4c5", "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/Issue2827.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/Issue2827.agda", "max_line_length": 77, "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/Issue2827.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": 211, "size": 747 }
{-# OPTIONS --allow-unsolved-metas #-} {-# OPTIONS --no-double-check #-} -- {-# OPTIONS -v impossible:70 #-} -- {-# OPTIONS -v tc.interaction:30 #-} -- {-# OPTIONS -v tc.check.internal:20 #-} open import Agda.Builtin.Sigma record R1 (A : Set) : Set where instance prodR1 : {A : Set} {B : A → Set} → ⦃ {a : A} → R1 (B a) ⦄ → R1 (Σ A B) prodR1 = record {} record R2 (A : Set) ⦃ aR1 : R1 A ⦄ : Set₁ where field f : A → Set open R2 ⦃...⦄ public record R3 (A : Set) (B : A → Set) : Set₁ where instance bR1 : {a : A} → R1 (B a) bR1 = {!!} -- record {} field ⦃ r2 ⦄ : R2 (Σ A B) fab : ∀ {a} {b : B a} → f (a , b)
{ "alphanum_fraction": 0.5109034268, "avg_line_length": 22.9285714286, "ext": "agda", "hexsha": "91129846023dce49dc74e46320812ca753e519ee", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Succeed/Issue5478-orig.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Succeed/Issue5478-orig.agda", "max_line_length": 72, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Succeed/Issue5478-orig.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": 265, "size": 642 }
module DeclSN where open import Data.Sum open import Library open import Terms open import Substitution open import TermShape open import SN open import Reduction -- SN as accessibility data sn {Γ} {a} (t : Tm Γ a) : Set where acc : (∀ {t'} → t ⇒β t' → sn t') → sn t sn⇒β : ∀ {Γ} {a} {t t' : Tm Γ a} → sn t → t ⇒β t' → sn t' sn⇒β (acc h) r = h r varsn : ∀ {Γ} {a} (x : Var Γ a) → sn (var x) varsn x = acc λ { (cong () _ _) } abssn : ∀ {Γ} {a b} {t : Tm (a ∷ Γ) b} → sn t → sn (abs t) abssn (acc f) = acc (λ { {._} (cong abs abs x) → abssn (f x) }) subsn : ∀ {Γ Δ} {a b} {f : Tm Γ a -> Tm Δ b} → (g : ∀ {t t' : Tm Γ a} → t ⇒β t' → f t ⇒β f t') → ∀ {t} → sn (f t) → sn t subsn g (acc ft) = acc λ t⇒ → subsn g (ft (g t⇒)) -- Goal here: prove that sne is closed under application. appsn : ∀ {Γ a b} {t : Tm Γ (a →̂ b)} {u} → sn t → sn u → SNe t → ∀ {r : Tm Γ b} → app t u ⇒β r → sn r appsn (acc 𝒕) 𝒖 𝒏 (cong (appl u) (appl .u) t⇒) = acc (appsn (𝒕 t⇒) 𝒖 (mapβSNe t⇒ 𝒏 )) appsn 𝒕 (acc u) 𝒏 (cong (appr t) (appr .t) t⇒) = acc (appsn 𝒕 (u t⇒) 𝒏) appsn 𝒕 u (elim 𝒏 ()) β elimsn : ∀ {Γ a b}{E : ECxt Γ a b}{t : Tm Γ a}{Et : Tm Γ b} → sn t → PCxt sn Et E t → SNe t → ∀ {Et' : Tm Γ b} → Et ⇒β Et' → sn Et' elimsn 𝒕 (appl 𝒖) 𝒏 t⇒ = appsn 𝒕 𝒖 𝒏 t⇒ substβsn : ∀ {i m vt a Γ} {Δ} {σ ρ : RenSub {m} vt Γ Δ} → (∀ {b} (x : Var Γ b) → vt2tm _ (σ x) ⇒β* vt2tm _ (ρ x)) → (t : Tm Γ a) → SN {i} (subst σ t) → SN {i} (subst ρ t) substβsn f t = mapβ*SN (subst⇒β* f t) antiSubst : ∀ {Γ a b} {t : Tm (a ∷ Γ) b}{u : Tm Γ a} → sn (subst (sgs u) t) → sn t antiSubst {t = t} = subsn (λ x → subst⇒β (sgs _) x) _[_]⇒β : ∀ {Γ} {a b} (E : ECxt Γ a b) {t₁ t₂ : Tm Γ a} → t₁ ⇒β t₂ → E [ t₁ ] ⇒β E [ t₂ ] appl u [ t⇒ ]⇒β = cong (appl u) (appl u) t⇒ _[_]⇒β* : ∀ {Γ} {a b} (E : ECxt* Γ a b) {t₁ t₂ : Tm Γ a} → t₁ ⇒β t₂ → E [ t₁ ]* ⇒β E [ t₂ ]* [] [ t⇒ ]⇒β* = t⇒ (E ∷ Es) [ t⇒ ]⇒β* = Es [ E [ t⇒ ]⇒β ]⇒β* cong*2 : ∀ {Γ a b t t'}(E : ECxt* Γ a b) → (t⇒ : t ⇒β t') → E [ t ]* ⇒β E [ t' ]* cong*2 E t⇒ = E [ t⇒ ]⇒β* subexpsn : ∀ {Γ a b} (E : ECxt* Γ a b) {t : Tm Γ a} → sn (E [ t ]*) -> sn t subexpsn E = subsn (cong*3 E) data _Redex {Γ} : ∀ {a} → Tm Γ a → Set where β : ∀ {a b}{t : Tm (a ∷ Γ) b}{u} → (app (abs t) u) Redex mkHole2 : ∀ {Γ} {a b} (E : ECxt Γ a b) {t : Tm Γ a} → βEhole (E [ t ]) (EC→βEC E) t mkHole2 (appl u) = appl u mkHole3 : ∀ {Γ} {a b c} (E : ECxt Γ a b) {Es : ECxt* Γ _ _} {t : Tm Γ c} → βEhole ((Es ∷r E) [ t ]*) (EC→βEC E) (Es [ t ]*) mkHole3 E {Es} {t} rewrite ≡.sym (lemma {t = t} Es {E = E}) = mkHole2 E {Es [ t ]*} ≡subst⇒β : ∀ {a Γ} {t t1 t' t'1 : Tm Γ a} → t ≡ t1 → t' ≡ t'1 → t ⇒β t' → t1 ⇒β t'1 ≡subst⇒β ≡.refl ≡.refl x = x split : ∀ {Γ} {a b} (E : ECxt* Γ a b) {t₁ : Tm Γ a}{t₂ Et₁ : Tm Γ b} → Ehole* Et₁ E t₁ → t₁ Redex → Et₁ ⇒β t₂ → (∃ λ t₃ → Ehole* t₂ E t₃ × t₁ ⇒β t₃) ⊎ (∃ λ E₁ → Ehole* t₂ E₁ t₁ × (∀ t → E [ t ]* ⇒β E₁ [ t ]*)) split ._ [] r t⇒ = inj₁ (_ , [] , t⇒) split .(appl u ∷ []) (appl u ∷ []) () β split ._ (appl u ∷ (() ∷ eq)) r β split ._ (appl u ∷ eq) r (cong (appl .u) (appl .u) t⇒) with split _ eq r t⇒ split ._ (appl u ∷ eq) r (cong (appl .u) (appl .u) t⇒) | inj₁ (x , eq0 , t⇒') = inj₁ (_ , ((appl u) ∷ eq0) , t⇒') split ._ (_∷_ {Es = Es} (appl u) eq) r (cong (appl .u) (appl .u) t⇒) | inj₂ (Es' , eq0 , f) = inj₂ (_ , ((appl u ∷ eq0) , (λ t → cong (mkHole3 (appl u) {Es}) (mkHole3 (appl u) {Es'}) (f t)))) split ._ (_∷_ {Es = Es} (appl t) eq) r (cong (appr Est) (appr .Est) t⇒) = inj₂ (_ , ((appl _ ∷ eq) , (λ t₁ → ≡subst⇒β (lemma Es {E = appl t}) (lemma Es {E = appl _}) (_⇒β_.cong {E = (appr (Es [ t₁ ]*))} (βEhole.appr (Es [ t₁ ]*)) (appr (Es [ t₁ ]*)) t⇒)))) mutual -- it seems possible to use sn (Es [ subst (sgs u) t ]*) instead of SN {i} (Es [ subst (sgs u) t ]*) ? - bp appsn₃ : ∀ {i a b c Γ} {u : Tm Γ a} {t : Tm (a ∷ Γ) b}{Es : ECxt* Γ b c}{x} → sn (Es [ x ]*) → sn t → SN {i} (Es [ subst (sgs u) t ]*) -- TODO: use sn here? → sn u → sn (Es [ app (abs t) u ]*) appsn₃ {Es = Es} x t t[u] u = acc (λ t⇒ → help {Es = Es} x t t[u] u (mkEhole* Es) t⇒) where help : ∀ {i a b c Γ} {u : Tm Γ a} {t : Tm (a ∷ Γ) b} {t' : Tm Γ c} {x} {z}{Es : ECxt* Γ b c} → sn (Es [ x ]*) → sn t → SN {i} (Es [ subst (u ∷s var) t ]*) → sn u → Ehole* z Es (app (abs t) u) → z ⇒β t' → sn t' help {Es = Es} x t t[u]∈sn u∈sn eq t⇒ with split Es eq β t⇒ help x t₂ t[u]∈sn u∈sn eq t⇒ | inj₁ (._ , a₁ , β) rewrite hole*→≡ a₁ = fromSN t[u]∈sn help {Es = Es} x (acc t₃) t[u]∈sn u∈sn eq t⇒ | inj₁ (._ , a₁ , cong (appl u₁) (appl .u₁) (cong abs abs b₁)) rewrite hole*→≡ a₁ = appsn₃ {Es = Es} x (t₃ b₁) (mapβSN (cong*3 Es (subst⇒β (sgs u₁) b₁)) t[u]∈sn) u∈sn help {t = t} {Es = Es} x t₃ t[u]∈sn (acc u∈sn) eq t⇒ | inj₁ (._ , a₁ , cong (appr ._) (appr ._) b₁) rewrite hole*→≡ a₁ = appsn₃ {Es = Es} x t₃ (mapβ*SN (cong*4 Es (subst⇒β* (λ { {._} zero → b₁ ∷ [] ; (suc n) → [] }) t)) t[u]∈sn) (u∈sn b₁) help {x = x} (acc f) t₂ t[u]∈sn u∈sn eq t⇒ | inj₂ (Es' , a , g) rewrite hole*→≡ a = appsn₃ {Es = Es'} (f (g x)) t₂ (mapβSN (g _) t[u]∈sn) u∈sn helperCxt : ∀ {i j Γ a b} {t th to : Tm Γ a} → (Es : ECxt* Γ a b) → t ⟨ i ⟩⇒ th → SN {j} (Es [ th ]*) → sn (Es [ th ]*) -> t ⇒β to → sn (Es [ to ]*) helperCxt E (β 𝒖) 𝒕h 𝑡h β = 𝑡h helperCxt E (β 𝒖) 𝒕h 𝑡h (cong (appl u) (appl .u) (cong abs abs t⇒)) = appsn₃ {Es = E} 𝑡h (sn⇒β (antiSubst (subexpsn E 𝑡h)) t⇒) (mapβSN (cong*3 E (subst⇒β (sgs u) t⇒)) 𝒕h) (fromSN 𝒖) helperCxt E (β {t = t} 𝒖) 𝒕h 𝑡h (cong (appr ._) (appr ._) t⇒) = appsn₃ {Es = E} 𝑡h (antiSubst (subexpsn E 𝑡h)) (mapβ*SN (cong*4 E (subst⇒β* (λ { zero → t⇒ ∷ [] ; (suc _) → [] }) t)) 𝒕h) (sn⇒β (fromSN 𝒖) t⇒) helperCxt E (cong (appl u) (appl .u) (cong () 𝑬𝒕' th⇒)) 𝒕h 𝑡h β helperCxt E (cong (appl u) (appl .u) th⇒) 𝒕h 𝑡h (cong (appl .u) (appl .u) t⇒) = helperCxt (appl u ∷ E) th⇒ 𝒕h 𝑡h t⇒ helperCxt E (cong (appl u) (appl .u) th⇒) 𝒕h (acc 𝑡h) (cong (appr t) (appr .t) t⇒) = acc (helperCxt [] (E [ cong (appl _) (appl _) th⇒ ]⇒*) (mapβSN t⇒' 𝒕h) (𝑡h t⇒')) where t⇒' = E [ cong (appr _) (appr _) t⇒ ]⇒β* fromSN : ∀ {i} {Γ} {a} {t : Tm Γ a} → SN {i} t → sn t fromSN (ne 𝒏) = fromSNe 𝒏 fromSN (abs t₁) = abssn (fromSN t₁) fromSN (exp t⇒ t₁) = acc (helperCxt [] t⇒ t₁ (fromSN t₁)) fromSNe : ∀ {i Γ a} {t : Tm Γ a} → SNe {i} t → sn t fromSNe (elim 𝒏 E) = acc (elimsn (fromSNe 𝒏) (mapPCxt fromSN E) 𝒏) fromSNe (var x) = varsn x
{ "alphanum_fraction": 0.4496989279, "avg_line_length": 43.9290322581, "ext": "agda", "hexsha": "ba2b50989b0ceb629554a6fe1f7c82ebedcfd7a1", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2018-02-23T18:22:17.000Z", "max_forks_repo_forks_event_min_datetime": "2017-11-10T16:44:52.000Z", "max_forks_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "ryanakca/strong-normalization", "max_forks_repo_path": "agda-aplas14/DeclSN.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2", "max_issues_repo_issues_event_max_datetime": "2018-02-20T14:54:18.000Z", "max_issues_repo_issues_event_min_datetime": "2018-02-14T16:42:36.000Z", "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "ryanakca/strong-normalization", "max_issues_repo_path": "agda-aplas14/DeclSN.agda", "max_line_length": 161, "max_stars_count": 32, "max_stars_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "ryanakca/strong-normalization", "max_stars_repo_path": "agda-aplas14/DeclSN.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-05T12:12:03.000Z", "max_stars_repo_stars_event_min_datetime": "2017-05-22T14:33:27.000Z", "num_tokens": 3547, "size": 6809 }
{-# OPTIONS --safe #-} module Definition.Typed.Consequences.TypeUnicity where open import Definition.Untyped hiding (U≢ℕ; U≢Π; U≢ne; ℕ≢Π; ℕ≢ne; Π≢ne; U≢Empty; ℕ≢Empty; Empty≢Π; Empty≢ne) open import Definition.Untyped.Properties using (subst-Univ-either) open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.Weakening open import Definition.Typed.Consequences.Equality import Definition.Typed.Consequences.Inequality as Ineq open import Definition.Typed.Consequences.Inversion open import Definition.Typed.Consequences.Injectivity open import Definition.Typed.Consequences.NeTypeEq open import Definition.Typed.Consequences.Syntactic open import Definition.Typed.Consequences.PiNorm open import Definition.Typed.Consequences.Substitution open import Definition.Conversion.Stability open import Tools.Product open import Tools.Empty open import Tools.Sum using (_⊎_; inj₁; inj₂) import Tools.PropositionalEquality as PE type-uniq : ∀ {Γ t T₁ T₂ r₁ r₂ l₁ l₂} → Γ ⊢ t ∷ T₁ ^ [ r₁ , l₁ ] → Γ ⊢ t ∷ T₂ ^ [ r₂ , l₂ ] → r₁ PE.≡ r₂ × l₁ PE.≡ l₂ × Γ ⊢ T₁ ≡ T₂ ^ [ r₁ , l₁ ] type-uniq (univ 0<1 x) (univ 0<1 x') = PE.refl , PE.refl , refl (Ugenⱼ x) type-uniq (ℕⱼ x) (ℕⱼ x₁) = PE.refl , PE.refl , refl (Ugenⱼ x) type-uniq (Emptyⱼ x) (Emptyⱼ x₁) = PE.refl , PE.refl , refl (Ugenⱼ x) type-uniq (Πⱼ x ▹ x₁ ▹ X ▹ X₁) (Πⱼ x₂ ▹ x₃ ▹ Y ▹ Y₁) = let _ , _ , eU = type-uniq X₁ Y₁ er , el = Uinjectivity eU in PE.refl , PE.refl , PE.subst (λ r → _ ⊢ _ ≡ Univ r _ ^ _ ) er (refl ((Ugenⱼ (wfTerm Y))) ) type-uniq (∃ⱼ X ▹ X₁) (∃ⱼ Y ▹ Y₁) = let _ , enextl , eU = type-uniq X Y el = next-inj enextl in PE.refl , enextl , PE.subst (λ l → _ ⊢ _ ≡ SProp l ^ _ ) el (refl ((Ugenⱼ (wfTerm Y))) ) type-uniq (var xx x) (var _ y) = let T≡T , e = varTypeEq′ x y er , el = typelevel-injectivity e in er , el , PE.subst (λ A → _ ⊢ _ ≡ A ^ _ ) T≡T (refl (syntacticTerm (var xx x))) type-uniq (lamⱼ x x₁ x₂ X) (lamⱼ y y₁ y₂ Y) = let _ , _ , F≡F = type-uniq (un-univ x₂) (un-univ y₂) erF , elF = Uinjectivity F≡F erG , elG , G≡G = type-uniq X (PE.subst₂ (λ r l → _ ∙ _ ^ [ r , ι l ] ⊢ _ ∷ _ ^ _) (PE.sym erF) (PE.sym elF) Y) in erG , PE.refl , PE.subst₃ (λ rF lF lG → _ ⊢ _ ≡ Π _ ^ rF ° lF ▹ _ ° lG ° _ ^ _) erF elF (ιinj elG) (univ (Π-cong x x₁ x₂ (refl (un-univ x₂)) (un-univ≡ G≡G))) type-uniq (X ∘ⱼ X₁) (Y ∘ⱼ Y₁) = let er , _ , Π≡Π = type-uniq X Y F≡F , erF , elF , elG , G≡G = injectivity Π≡Π in er , PE.cong _ elG , (substitutionEq G≡G (substRefl (singleSubst X₁)) (wfTerm X₁)) type-uniq {Γ} ⦅ x , x₁ , X , X₁ ⦆ⱼ (⦅_,_,_,_⦆ⱼ {F = F} {G = G} y y₁ Y Y₁) = let _ , el , F≡F = type-uniq X Y _ , el' , G≡G = type-uniq (un-univ x₁) (un-univ (stability (reflConEq (wf x) ∙ sym F≡F) (PE.subst (λ l → Γ ∙ F ^ [ % , l ] ⊢ G ^ [ % , l ]) (PE.sym el) y₁))) in PE.refl , el , univ (∃-cong x (un-univ≡ F≡F) (un-univ≡ (refl x₁))) type-uniq (fstⱼ X X₁ X₂) (fstⱼ Y Y₁ Y₂) = let er , el , ∃≡∃ = type-uniq X₂ Y₂ F≡F , _ = ∃injectivity ∃≡∃ in PE.refl , el , F≡F type-uniq (sndⱼ X X₁ X₂) (sndⱼ Y Y₁ Y₂) = let er , el , ∃≡∃ = type-uniq X₂ Y₂ F≡F , G≡G = ∃injectivity ∃≡∃ in PE.refl , el , substitutionEq G≡G (substRefl (singleSubst (fstⱼ X X₁ X₂))) (wfTerm X) type-uniq (zeroⱼ x) (zeroⱼ x₁) = PE.refl , PE.refl , refl (univ (ℕⱼ x)) type-uniq (sucⱼ X) (sucⱼ Y) = PE.refl , PE.refl , refl (univ (ℕⱼ (wfTerm X))) type-uniq (natrecⱼ x X X₁ X₂) (natrecⱼ y Y Y₁ Y₂) = let _ , _ , U≡U = type-uniq (un-univ x) (un-univ y) er , _ = Uinjectivity U≡U in er , PE.refl , refl (substitution x (singleSubst X₂) (wfTerm X) ) type-uniq (Emptyrecⱼ x X) (Emptyrecⱼ y Y) = let _ , _ , U≡U = type-uniq (un-univ x) (un-univ y) er , _ = Uinjectivity U≡U in er , PE.refl , refl x type-uniq (Idⱼ X X₁ X₂) (Idⱼ Y Y₁ Y₂) = let _ , enl , U≡U = type-uniq X Y el = next-inj enl in PE.refl , enl , PE.subst (λ l → _ ⊢ _ ≡ SProp l ^ _) el (refl (Ugenⱼ (wfTerm X))) type-uniq (Idreflⱼ X) (Idreflⱼ Y) = let _ , el , _ = type-uniq X Y in PE.refl , el , refl (syntacticTerm (Idreflⱼ X)) type-uniq (transpⱼ x x₁ X X₁ X₂ X₃) (transpⱼ x₂ x₃ Y Y₁ Y₂ Y₃) = let _ , el , _ = type-uniq X Y in PE.refl , el , refl (substitution x₁ (singleSubst X₂) (wfTerm X)) type-uniq (castⱼ X X₁ X₂ X₃) (castⱼ Y Y₁ Y₂ Y₃) = let er , _ , _ = type-uniq X₃ Y₃ in er , PE.refl , refl (univ X₁) type-uniq (castreflⱼ X X₁) (castreflⱼ Y Y₁) = PE.refl , PE.refl , refl (syntacticTerm (castreflⱼ X X₁)) type-uniq (conv X x) Y = let er , el , eA = type-uniq X Y in er , el , trans (sym x) eA type-uniq X (conv Y y) = let er , el , eA = type-uniq X Y in er , el , trans eA (PE.subst₂ (λ r l → _ ⊢ _ ≡ _ ^ [ r , l ]) (PE.sym er) (PE.sym el) y)
{ "alphanum_fraction": 0.5857288481, "avg_line_length": 52.1808510638, "ext": "agda", "hexsha": "7f42e5440e262d3a32d3b9aa916b7107b42e0e49", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/Typed/Consequences/TypeUnicity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/Typed/Consequences/TypeUnicity.agda", "max_line_length": 126, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/Typed/Consequences/TypeUnicity.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z", "max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z", "num_tokens": 2162, "size": 4905 }
import Data.Empty import Data.Unit import Data.Bool import Data.Nat import Data.Fin module SecondOrder.Arity where -- A notion of arity is given by a set of possible arities, and a mapping which to each arity assings a set of -- argument positions. record Arity : Set₁ where field arity : Set -- the set of permissible arities, e.g., ℕ for finitary arities arg : arity → Set -- every arity gives a set of argument (position), e.g. Fin -- finitary arities arity-finite : Arity arity-finite = record { arity = Data.Nat.ℕ ; arg = Data.Fin.Fin } module Arity012 where -- For example, in algebra we quite often only consider constants, unary and binary -- operations. Thus we would only need three arities. data arity012 : Set where Constant Unary Binary : arity012 arg012 : arity012 → Set arg012 Constant = Data.Empty.⊥ arg012 Unary = Data.Unit.⊤ arg012 Binary = Data.Bool.Bool arity-012 : Arity arity-012 = record { arity = arity012 ; arg = arg012 }
{ "alphanum_fraction": 0.689688716, "avg_line_length": 29.3714285714, "ext": "agda", "hexsha": "3f07926443edf16f4ffb95788ca529228b9da256", "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/SecondOrder/Arity.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/SecondOrder/Arity.agda", "max_line_length": 112, "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/SecondOrder/Arity.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": 280, "size": 1028 }
------------------------------------------------------------------------------ -- Paradoxical combinator properties ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- See (Barendregt 2004, corollary 6.1.3). module FOT.LTC-PCF.Y.Properties where open import Common.FOL.Relation.Binary.EqReasoning open import FOT.LTC-PCF.Y open import LTC-PCF.Base hiding ( fix ; fix-eq ) open import LTC-PCF.Base.Properties ------------------------------------------------------------------------------ -- The conversion rule for Y. Y-eq : ∀ f → Y · f ≡ f · (Y · f) Y-eq f = Y · f ≡⟨ beta helper f ⟩ lamW · lamW ≡⟨ beta W lamW ⟩ W lamW ≡⟨ refl ⟩ f · (lamW · lamW) ≡⟨ ·-rightCong (sym (beta helper f)) ⟩ f · (Y · f) ∎ where helper : D → D helper = λ f → lam (λ x → f · (x · x)) · lam (λ x → f · (x · x)) W : D → D W = λ x → f · (x · x) lamW : D lamW = lam W -- The conversion rule for the higher-order Y₁. Y₁-eq : (f : D → D) → Y₁ f ≡ f (Y₁ f) Y₁-eq f = Y₁ f ≡⟨ refl ⟩ Y · lam f ≡⟨ Y-eq (lam f) ⟩ lam f · (Y · lam f) ≡⟨ ·-rightCong refl ⟩ lam f · Y₁ f ≡⟨ beta f (Y₁ f) ⟩ f (Y₁ f) ∎ ------------------------------------------------------------------------------ -- References -- -- Barendregt, Henk (2004). The Lambda Calculus. Its Syntax and -- Semantics. 2nd ed. Vol. 103. Studies in Logic and the Foundations -- of Mathematics. 6th impression. Elsevier.
{ "alphanum_fraction": 0.4203488372, "avg_line_length": 32.4528301887, "ext": "agda", "hexsha": "096ff44ff7ea3f1e9fd82ee670b4608820adf9d2", "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/LTC-PCF/Y/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": "notes/FOT/LTC-PCF/Y/Properties.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/LTC-PCF/Y/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": 505, "size": 1720 }
-------------------------------------------------------------------------------- -- Strings with markers, used for parsing -------------------------------------------------------------------------------- {-# OPTIONS --type-in-type #-} module Parse.MarkedString where open import Data.String using (fromList; fromChar; toList) open import Prelude data Marker : Set where NonTerminalBracket : Bool → Marker NameDivider : Marker WildcardBracket : Bool → Marker WildcardSeparator : Marker instance Marker-Show : Show Marker Marker-Show = record { show = λ where (NonTerminalBracket true) → "NonTerminalBracket" (NonTerminalBracket false) → "IgnoredNonTerminalBracket" NameDivider → "NameDivider" (WildcardBracket true) → "BlacklistWildcardBracket" (WildcardBracket false) → "WhitelistWildcardBracket" WildcardSeparator → "WildcardSeparator" } Marker-Eq : Eq Marker Marker-Eq = record { _≟_ = λ where (NonTerminalBracket x) (NonTerminalBracket x₁) → case x ≟ x₁ of λ { (yes refl) → yes refl ; (no ¬p) → no (λ { refl → ¬p refl }) } (NonTerminalBracket x) NameDivider → no (λ ()) (NonTerminalBracket x) (WildcardBracket x₁) → no (λ ()) (NonTerminalBracket x) WildcardSeparator → no (λ ()) NameDivider (NonTerminalBracket x) → no (λ ()) NameDivider NameDivider → yes refl NameDivider (WildcardBracket x) → no (λ ()) NameDivider WildcardSeparator → no (λ ()) (WildcardBracket x) (NonTerminalBracket x₁) → no (λ ()) (WildcardBracket x) NameDivider → no (λ ()) (WildcardBracket x) (WildcardBracket x₁) → case x ≟ x₁ of λ { (yes refl) → yes refl ; (no ¬p) → no (λ { refl → ¬p refl }) } (WildcardBracket x) WildcardSeparator → no (λ ()) WildcardSeparator (NonTerminalBracket x) → no (λ ()) WildcardSeparator NameDivider → no (λ ()) WildcardSeparator (WildcardBracket x) → no (λ ()) WildcardSeparator WildcardSeparator → yes refl } Marker-EqB = Eq→EqB {{Marker-Eq}} enumerateMarkers : List Marker enumerateMarkers = NonTerminalBracket true ∷ NonTerminalBracket false ∷ NameDivider ∷ WildcardBracket true ∷ WildcardBracket false ∷ WildcardSeparator ∷ [] markerRepresentation : Marker → Char markerRepresentation (NonTerminalBracket true) = '_' markerRepresentation (NonTerminalBracket false) = '^' markerRepresentation NameDivider = '$' markerRepresentation (WildcardBracket true) = '!' markerRepresentation (WildcardBracket false) = '@' markerRepresentation WildcardSeparator = '&' -- other good candidates: &*#~% escapeMarker = '\\' MarkedChar = Char ⊎ Marker MarkedString = List MarkedChar markedStringToString : MarkedString → String markedStringToString [] = "" markedStringToString (inj₁ x ∷ s) = fromList (decCase x of map (λ x → (x , escapeMarker ∷ [ x ])) $ -- if we find anything in this list, escape it escapeMarker ∷ map markerRepresentation enumerateMarkers default [ x ]) + markedStringToString s markedStringToString (inj₂ x ∷ s) = (fromChar $ markerRepresentation x) + markedStringToString s convertToMarked : String → MarkedString convertToMarked s = helper false (toList s) where -- first argument is whether the current character is escaped helper : Bool → List Char → MarkedString helper _ [] = [] helper false (x ∷ l) = decCase x of (escapeMarker , helper true l) ∷ map (λ y → (markerRepresentation y , inj₂ y ∷ helper false l)) enumerateMarkers default (inj₁ x ∷ helper false l) helper true (x ∷ l) = inj₁ x ∷ helper false l
{ "alphanum_fraction": 0.6441466083, "avg_line_length": 37.306122449, "ext": "agda", "hexsha": "024d4c60f8fc6e1d09ce2370a5bba2be9e25ecc4", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_path": "src/Parse/MarkedString.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_path": "src/Parse/MarkedString.agda", "max_line_length": 96, "max_stars_count": 35, "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_path": "src/Parse/MarkedString.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "num_tokens": 932, "size": 3656 }
{-# OPTIONS --without-K #-} module well-typed-syntax where infixl 2 _▻_ infixl 3 _‘’_ infixl 3 _‘’₁_ infixl 3 _‘’₂_ infixl 3 _‘’₃_ infixl 3 _‘’ₐ_ infixr 1 _‘→’_ infixl 3 _‘‘’’_ infixl 3 _w‘‘’’_ infixr 1 _‘‘→'’’_ infixr 1 _w‘‘→'’’_ mutual data Context : Set where ε : Context _▻_ : (Γ : Context) → Typ Γ → Context data Typ : Context → Set where _‘’_ : ∀ {Γ A} → Typ (Γ ▻ A) → Term {Γ} A → Typ Γ _‘’₁_ : ∀ {Γ A B} → (C : Typ (Γ ▻ A ▻ B)) → (a : Term {Γ} A) → Typ (Γ ▻ B ‘’ a) _‘’₂_ : ∀ {Γ A B C} → (D : Typ (Γ ▻ A ▻ B ▻ C)) → (a : Term {Γ} A) → Typ (Γ ▻ B ‘’ a ▻ C ‘’₁ a) _‘’₃_ : ∀ {Γ A B C D} → (E : Typ (Γ ▻ A ▻ B ▻ C ▻ D)) → (a : Term {Γ} A) → Typ (Γ ▻ B ‘’ a ▻ C ‘’₁ a ▻ D ‘’₂ a) W : ∀ {Γ A} → Typ Γ → Typ (Γ ▻ A) W1 : ∀ {Γ A B} → Typ (Γ ▻ B) → Typ (Γ ▻ A ▻ (W {Γ = Γ} {A = A} B)) W2 : ∀ {Γ A B C} → Typ (Γ ▻ B ▻ C) → Typ (Γ ▻ A ▻ W B ▻ W1 C) _‘→’_ : ∀ {Γ} (A : Typ Γ) → Typ (Γ ▻ A) → Typ Γ ‘Σ’ : ∀ {Γ} (T : Typ Γ) → Typ (Γ ▻ T) → Typ Γ ‘Context’ : ∀ {Γ} → Typ Γ ‘Typ’ : ∀ {Γ} → Typ (Γ ▻ ‘Context’) ‘Term’ : ∀ {Γ} → Typ (Γ ▻ ‘Context’ ▻ ‘Typ’) data Term : ∀ {Γ} → Typ Γ → Set where w : ∀ {Γ A B} → Term {Γ} B → Term {Γ = Γ ▻ A} (W {Γ = Γ} {A = A} B) ‘λ∙’ : ∀ {Γ A B} → Term {Γ = (Γ ▻ A)} B → Term {Γ} (A ‘→’ B) _‘’ₐ_ : ∀ {Γ A B} → (f : Term {Γ} (A ‘→’ B)) → (x : Term {Γ} A) → Term {Γ} (B ‘’ x) ‘VAR₀’ : ∀ {Γ T} → Term {Γ = Γ ▻ T} (W T) ⌜_⌝c : ∀ {Γ} → Context → Term {Γ} ‘Context’ ⌜_⌝T : ∀ {Γ Γ'} → Typ Γ' → Term {Γ} (‘Typ’ ‘’ ⌜ Γ' ⌝c) ⌜_⌝t : ∀ {Γ Γ'} {T : Typ Γ'} → Term T → Term {Γ} (‘Term’ ‘’₁ ⌜ Γ' ⌝c ‘’ ⌜ T ⌝T) ‘quote-term’ : ∀ {Γ Γ'} {A : Typ Γ'} → Term {Γ} (‘Term’ ‘’₁ ⌜ Γ' ⌝c ‘’ ⌜ A ⌝T ‘→’ W (‘Term’ ‘’₁ ⌜ Γ ⌝c ‘’ ⌜ ‘Term’ ‘’₁ ⌜ Γ' ⌝c ‘’ ⌜ A ⌝T ⌝T)) ‘quote-sigma’ : ∀ {Γ Γ'} → Term {Γ} (‘Σ’ ‘Context’ ‘Typ’ ‘→’ W (‘Term’ ‘’₁ ⌜ Γ' ⌝c ‘’ ⌜ ‘Σ’ ‘Context’ ‘Typ’ ⌝T)) {-‘substTyp’ : ∀ {Γ' Γ} {A : Typ Γ} → Term {Γ'} (‘Typ’ ‘’ ⌜ Γ ▻ A ⌝c ‘→’ W (‘Term’ ‘’₁ ⌜ Γ ⌝c ‘’ ⌜ A ⌝T ‘→’ W (‘Typ’ ‘’ ⌜ Γ ⌝c)))-} ‘cast’ : Term {ε} (‘Σ’ ‘Context’ ‘Typ’ ‘→’ W (‘Typ’ ‘’ ⌜ ε ▻ ‘Σ’ ‘Context’ ‘Typ’ ⌝c)) SW : ∀ {Γ A B} {a : Term {Γ} A} → Term {Γ} (W B ‘’ a) → Term {Γ} B weakenTyp-substTyp-tProd : ∀ {Γ T T' A B} {a : Term {Γ} T} → Term {Γ = Γ ▻ T'} (W ((A ‘→’ B) ‘’ a)) → Term {Γ ▻ T'} (W ((A ‘’ a) ‘→’ (B ‘’₁ a))) substTyp-weakenTyp1-VAR₀ : ∀ {Γ A T} → Term {Γ ▻ A} (W1 T ‘’ ‘VAR₀’) → Term {Γ ▻ A} T weakenTyp-tProd : ∀ {Γ A B C} → Term {Γ = Γ ▻ C} (W (A ‘→’ B)) → Term {Γ = Γ ▻ C} (W A ‘→’ W1 B) weakenTyp-tProd-inv : ∀ {Γ A B C} → Term {Γ = Γ ▻ C} (W A ‘→’ W1 B) → Term {Γ = Γ ▻ C} (W (A ‘→’ B)) weakenTyp-weakenTyp-tProd : ∀ {Γ A B C D} → Term {Γ ▻ C ▻ D} (W (W (A ‘→’ B))) → Term {Γ ▻ C ▻ D} (W (W A ‘→’ W1 B)) substTyp1-tProd : ∀ {Γ T T' A B} {a : Term {Γ} T} → Term {Γ ▻ T' ‘’ a} ((A ‘→’ B) ‘’₁ a) → Term {Γ ▻ T' ‘’ a} ((A ‘’₁ a) ‘→’ (B ‘’₂ a)) weakenTyp1-tProd : ∀ {Γ C D A B} → Term {Γ ▻ C ▻ W D} (W1 (A ‘→’ B)) → Term {Γ ▻ C ▻ W D} (W1 A ‘→’ W2 B) substTyp2-tProd : ∀ {Γ T T' T'' A B} {a : Term {Γ} T} → Term {Γ ▻ T' ‘’ a ▻ T'' ‘’₁ a} ((A ‘→’ B) ‘’₂ a) → Term {Γ ▻ T' ‘’ a ▻ T'' ‘’₁ a} ((A ‘’₂ a) ‘→’ (B ‘’₃ a)) substTyp1-substTyp-weakenTyp-inv : ∀ {Γ C T A} {a : Term {Γ} C} {b : Term {Γ} (T ‘’ a)} → Term {Γ} (A ‘’ a) → Term {Γ} (W A ‘’₁ a ‘’ b) substTyp1-substTyp-weakenTyp : ∀ {Γ C T A} {a : Term {Γ} C} {b : Term {Γ} (T ‘’ a)} → Term {Γ} (W A ‘’₁ a ‘’ b) → Term {Γ} (A ‘’ a) weakenTyp-weakenTyp-substTyp1-substTyp-weakenTyp : ∀ {Γ C T A D E} {a : Term {Γ} C} {b : Term {Γ} (T ‘’ a)} → Term {Γ ▻ D ▻ E} (W (W (W A ‘’₁ a ‘’ b))) → Term {Γ ▻ D ▻ E} (W (W (A ‘’ a))) weakenTyp-substTyp2-substTyp1-substTyp-weakenTyp-inv : ∀ {Γ A B C T T'} {a : Term {Γ} A} {b : Term {Γ} (B ‘’ a)} {c : Term {Γ} (C ‘’₁ a ‘’ b)} → Term {Γ ▻ T'} (W (T ‘’₁ a ‘’ b)) → Term {Γ ▻ T'} (W (W T ‘’₂ a ‘’₁ b ‘’ c)) substTyp2-substTyp1-substTyp-weakenTyp : ∀ {Γ A B C T} {a : Term {Γ} A} {b : Term {Γ} (B ‘’ a)} {c : Term {Γ} (C ‘’₁ a ‘’ b)} → Term {Γ} (W T ‘’₂ a ‘’₁ b ‘’ c) → Term {Γ} (T ‘’₁ a ‘’ b) weakenTyp-substTyp2-substTyp1-substTyp-tProd : ∀ {Γ T T' T'' T''' A B} {a : Term {Γ} T} {b : Term {Γ} (T' ‘’ a)} {c : Term {Γ} (T'' ‘’₁ a ‘’ b)} → Term {Γ ▻ T'''} (W ((A ‘→’ B) ‘’₂ a ‘’₁ b ‘’ c)) → Term {Γ ▻ T'''} ((W (A ‘’₂ a ‘’₁ b ‘’ c)) ‘→’ (W1 (B ‘’₃ a ‘’₂ b ‘’₁ c))) weakenTyp2-weakenTyp1 : ∀ {Γ A B C D} → Term {Γ ▻ A ▻ W B ▻ W1 C} (W2 (W D)) → Term {Γ ▻ A ▻ W B ▻ W1 C} (W (W1 D)) weakenTyp1-weakenTyp : ∀ {Γ A B C} → Term {Γ ▻ A ▻ W B} (W1 (W C)) → Term {Γ ▻ A ▻ W B} (W (W C)) weakenTyp1-weakenTyp-inv : ∀ {Γ A B C} → Term {Γ ▻ A ▻ W B} (W (W C)) → Term {Γ ▻ A ▻ W B} (W1 (W C)) weakenTyp1-weakenTyp1-weakenTyp : ∀ {Γ A B C T} → Term {Γ ▻ A ▻ B ▻ W (W C)} (W1 (W1 (W T))) → Term {Γ ▻ A ▻ B ▻ W (W C)} (W1 (W (W T))) substTyp1-weakenTyp1 : ∀ {Γ A B C} {a : Term {Γ} A} → Term {Γ ▻ W B ‘’ a} (W1 C ‘’₁ a) → Term {Γ ▻ B} C weakenTyp1-substTyp-weakenTyp1-inv : ∀ {Γ A T'' T' T} {a : Term {Γ} A} → Term {Γ ▻ T'' ▻ W (T' ‘’ a)} (W1 (W (T ‘’ a))) → Term {Γ ▻ T'' ▻ W (T' ‘’ a)} (W1 (W T ‘’₁ a)) weakenTyp1-substTyp-weakenTyp1 : ∀ {Γ A T'' T' T} {a : Term {Γ} A} → Term {Γ ▻ T'' ▻ W (T' ‘’ a)} (W1 (W T ‘’₁ a)) → Term {Γ ▻ T'' ▻ W (T' ‘’ a)} (W1 (W (T ‘’ a))) weakenTyp-substTyp-substTyp-weakenTyp1 : ∀ {Γ T' B A} {b : Term {Γ} B} {a : Term {Γ ▻ B} (W A)} {T : Typ (Γ ▻ A)} → Term {Γ ▻ T'} (W (W1 T ‘’ a ‘’ b)) → Term {Γ ▻ T'} (W (T ‘’ (SW ((‘λ∙’ a) ‘’ₐ b)))) weakenTyp-substTyp-substTyp-weakenTyp1-inv : ∀ {Γ T' B A} {b : Term {Γ} B} {a : Term {Γ ▻ B} (W A)} {T : Typ (Γ ▻ A)} → Term {Γ ▻ T'} (W (T ‘’ (SW ((‘λ∙’ a) ‘’ₐ b)))) → Term {Γ ▻ T'} (W (W1 T ‘’ a ‘’ b)) substTyp-weakenTyp1-weakenTyp : ∀ {Γ T} {A : Typ Γ} {B : Typ Γ} → {a : Term {Γ = Γ ▻ T} (W {Γ = Γ} {A = T} B)} → Term {Γ = Γ ▻ T} (W1 (W A) ‘’ a) → Term {Γ = Γ ▻ T} (W A) substTyp3-substTyp2-substTyp1-substTyp-weakenTyp : ∀ {Γ A B C D T T'} {a : Term {Γ} A} {b : Term {Γ} (B ‘’ a)} {c : Term {Γ} (C ‘’₁ a ‘’ b)} {d : Term {Γ = (Γ ▻ T')} (W (D ‘’₂ a ‘’₁ b ‘’ c))} → Term {Γ = (Γ ▻ T')} (W1 (W T ‘’₃ a ‘’₂ b ‘’₁ c) ‘’ d) → Term {Γ = (Γ ▻ T')} (W (T ‘’₂ a ‘’₁ b ‘’ c)) weakenTyp-substTyp2-substTyp1-substTyp-weakenTyp1 : ∀ {Γ A B C T T'} {a : Term {Γ} A} {b : Term (B ‘’ a)} {c : Term (C ‘’ a)} → Term {Γ = (Γ ▻ T')} (W (W1 T ‘’₂ a ‘’₁ b ‘’ substTyp1-substTyp-weakenTyp-inv c)) → Term {Γ = (Γ ▻ T')} (W (T ‘’₁ a ‘’ c)) substTyp1-substTyp-tProd : ∀ {Γ T T' A B a b} → Term ((_‘→’_ {Γ = Γ ▻ T ▻ T'} A B) ‘’₁ a ‘’ b) → Term (_‘→’_ {Γ = Γ} (A ‘’₁ a ‘’ b) (B ‘’₂ a ‘’₁ b)) substTyp2-substTyp-substTyp-weakenTyp1-weakenTyp-weakenTyp : ∀ {Γ A} {T : Typ (Γ ▻ A)} {T' C B} {a : Term {Γ} A} {b : Term {Γ = (Γ ▻ C ‘’ a)} (B ‘’₁ a)} {c : Term {Γ = (Γ ▻ T')} (W (C ‘’ a))} → Term {Γ = (Γ ▻ T')} (W1 (W (W T) ‘’₂ a ‘’ b) ‘’ c) → Term {Γ = (Γ ▻ T')} (W (T ‘’ a)) substTyp1-substTyp-weakenTyp2-weakenTyp : ∀ {Γ T' A B T} {a : Term {Γ ▻ T'} (W A)} {b : Term {Γ ▻ T'} (W1 B ‘’ a)} → Term {Γ ▻ T'} (W2 (W T) ‘’₁ a ‘’ b) → Term {Γ ▻ T'} (W1 T ‘’ a) weakenTyp-weakenTyp1-weakenTyp : ∀ {Γ A B C D} → Term {Γ ▻ A ▻ W B ▻ W1 C} (W (W1 (W D))) → Term {Γ ▻ A ▻ W B ▻ W1 C} (W (W (W D))) beta-under-subst : ∀ {Γ A B B'} {g : Term {Γ} (A ‘→’ W B)} {x : Term {Γ} A} → Term (B' ‘’ SW (‘λ∙’ (SW (‘λ∙’ (weakenTyp1-weakenTyp (substTyp-weakenTyp1-VAR₀ (weakenTyp-tProd (w (weakenTyp-tProd (w g))) ‘’ₐ ‘VAR₀’))) ‘’ₐ ‘VAR₀’)) ‘’ₐ x)) → Term (B' ‘’ SW (g ‘’ₐ x)) ‘proj₁'’ : ∀ {Γ} {T : Typ Γ} {P : Typ (Γ ▻ T)} → Term (‘Σ’ T P ‘→’ W T) ‘proj₂'’ : ∀ {Γ} {T : Typ Γ} {P : Typ (Γ ▻ T)} → Term {Γ ▻ ‘Σ’ T P} (W1 P ‘’ SW (‘λ∙’ (weakenTyp1-weakenTyp (substTyp-weakenTyp1-VAR₀ (weakenTyp-tProd (w (weakenTyp-tProd (w ‘proj₁'’))) ‘’ₐ ‘VAR₀’))) ‘’ₐ ‘VAR₀’)) ‘existT’ : ∀ {Γ T P} (x : Term {Γ} T) (p : Term (P ‘’ x)) → Term (‘Σ’ T P) {- these are redundant, but useful for not having to normalize the subsequent ones -} _‘‘’’_ : ∀ {Γ} {A : Typ Γ} → Term {ε} (‘Typ’ ‘’ ⌜ Γ ▻ A ⌝c) → Term {ε} (‘Term’ ‘’₁ ⌜ Γ ⌝c ‘’ ⌜ A ⌝T) → Term {ε} (‘Typ’ ‘’ ⌜ Γ ⌝c) _w‘‘’’_ : ∀ {X Γ} {A : Typ Γ} → Term {ε ▻ X} (W (‘Typ’ ‘’ ⌜ Γ ▻ A ⌝c)) → Term {ε ▻ X} (W (‘Term’ ‘’₁ ⌜ Γ ⌝c ‘’ ⌜ A ⌝T)) → Term {ε ▻ X} (W (‘Typ’ ‘’ ⌜ Γ ⌝c)) _‘‘→'’’_ : ∀ {Γ} → Term {ε} (‘Typ’ ‘’ Γ) → Term {ε} (‘Typ’ ‘’ Γ) → Term {ε} (‘Typ’ ‘’ Γ) _w‘‘→'’’_ : ∀ {X Γ} → Term {ε ▻ X} (W (‘Typ’ ‘’ Γ)) → Term {ε ▻ X} (W (‘Typ’ ‘’ Γ)) → Term {ε ▻ X} (W (‘Typ’ ‘’ Γ)) w→ : ∀ {Γ A B C} → Term (A ‘→’ W B) → Term {Γ = Γ ▻ C} (W A ‘→’ W (W B)) {- things that were postulates, but are no longer -} ‘‘→'’’→w‘‘→'’’ : ∀ {T'} {b : Term {ε} (‘Typ’ ‘’ ⌜ ε ⌝c)} {c : Term {ε ▻ T'} (W (‘Typ’ ‘’ ⌜ ε ⌝c))} {e : Term {ε} T'} → Term {ε} (‘Term’ ‘’₁ ⌜ ε ⌝c ‘’ (SW (‘λ∙’ (c w‘‘→'’’ w b) ‘’ₐ e)) ‘→’ W (‘Term’ ‘’₁ ⌜ ε ⌝c ‘’ (SW (‘λ∙’ c ‘’ₐ e) ‘‘→'’’ b))) w‘‘→'’’→‘‘→'’’ : ∀ {T'} {b : Term {ε} (‘Typ’ ‘’ ⌜ ε ⌝c)} {c : Term {ε ▻ T'} (W (‘Typ’ ‘’ ⌜ ε ⌝c))} {e : Term {ε} T'} → Term {ε} (‘Term’ ‘’₁ ⌜ ε ⌝c ‘’ (SW (‘λ∙’ c ‘’ₐ e) ‘‘→'’’ b) ‘→’ W (‘Term’ ‘’₁ ⌜ ε ⌝c ‘’ (SW (‘λ∙’ (c w‘‘→'’’ w b) ‘’ₐ e)))) ‘tApp-nd’ : ∀ {Γ} {A : Term {ε} (‘Typ’ ‘’ Γ)} {B : Term {ε} (‘Typ’ ‘’ Γ)} → Term {ε} (‘Term’ ‘’₁ Γ ‘’ (A ‘‘→'’’ B) ‘→’ W (‘Term’ ‘’₁ Γ ‘’ A ‘→’ W (‘Term’ ‘’₁ Γ ‘’ B))) ⌜←'⌝ : ∀ {H X} → Term {ε} (‘Term’ ‘’₁ ⌜ ε ⌝c ‘’ (⌜ H ⌝T ‘‘→'’’ ⌜ X ⌝T) ‘→’ W (‘Term’ ‘’₁ ⌜ ε ⌝c ‘’ ⌜ H ‘→’ W X ⌝T)) ⌜→'⌝ : ∀ {H X} → Term {ε} (‘Term’ ‘’₁ ⌜ ε ⌝c ‘’ ⌜ H ‘→’ W X ⌝T ‘→’ W (‘Term’ ‘’₁ ⌜ ε ⌝c ‘’ (⌜ H ⌝T ‘‘→'’’ ⌜ X ⌝T))) ‘‘fcomp-nd’’ : ∀ {A B C} → Term {ε} (‘Term’ ‘’₁ ⌜ ε ⌝c ‘’ (A ‘‘→'’’ C) ‘→’ W (‘Term’ ‘’₁ ⌜ ε ⌝c ‘’ (C ‘‘→'’’ B) ‘→’ W (‘Term’ ‘’₁ ⌜ ε ⌝c ‘’ (A ‘‘→'’’ B)))) ⌜‘’⌝ : ∀ {B A} {b : Term {ε} B} → Term {ε} (‘Term’ ‘’₁ ⌜ ε ⌝c ‘’ (⌜ A ‘’ b ⌝T ‘‘→'’’ ⌜ A ⌝T ‘‘’’ ⌜ b ⌝t)) ⌜‘’⌝' : ∀ {B A} {b : Term {ε} B} → Term {ε} (‘Term’ ‘’₁ ⌜ ε ⌝c ‘’ (⌜ A ⌝T ‘‘’’ ⌜ b ⌝t ‘‘→'’’ ⌜ A ‘’ b ⌝T)) ‘cast-refl’ : ∀ {T : Typ (ε ▻ ‘Σ’ ‘Context’ ‘Typ’)} → Term {ε} (‘Term’ ‘’₁ ⌜ ε ⌝c ‘’ ((⌜ T ‘’ ‘existT’ ⌜ ε ▻ ‘Σ’ ‘Context’ ‘Typ’ ⌝c ⌜ T ⌝T ⌝T) ‘‘→'’’ (SW (‘cast’ ‘’ₐ ‘existT’ ⌜ ε ▻ ‘Σ’ ‘Context’ ‘Typ’ ⌝c ⌜ T ⌝T) ‘‘’’ SW (‘quote-sigma’ ‘’ₐ ‘existT’ ⌜ ε ▻ ‘Σ’ ‘Context’ ‘Typ’ ⌝c ⌜ T ⌝T)))) ‘cast-refl'’ : ∀ {T : Typ (ε ▻ ‘Σ’ ‘Context’ ‘Typ’)} → Term {ε} (‘Term’ ‘’₁ ⌜ ε ⌝c ‘’ ((SW (‘cast’ ‘’ₐ ‘existT’ ⌜ ε ▻ ‘Σ’ ‘Context’ ‘Typ’ ⌝c ⌜ T ⌝T) ‘‘’’ SW (‘quote-sigma’ ‘’ₐ ‘existT’ ⌜ ε ▻ ‘Σ’ ‘Context’ ‘Typ’ ⌝c ⌜ T ⌝T)) ‘‘→'’’ (⌜ T ‘’ ‘existT’ ⌜ ε ▻ ‘Σ’ ‘Context’ ‘Typ’ ⌝c ⌜ T ⌝T ⌝T))) ‘s→→’ : ∀ {T B} {b : Term {ε} (T ‘→’ W (‘Typ’ ‘’ ⌜ ε ▻ B ⌝c))} {c : Term {ε} (T ‘→’ W (‘Term’ ‘’₁ ⌜ ε ⌝c ‘’ ⌜ B ⌝T))} {v : Term {ε} T} → (Term {ε} (‘Term’ ‘’₁ ⌜ ε ⌝c ‘’ ((SW (((‘λ∙’ (SW (w→ b ‘’ₐ ‘VAR₀’) w‘‘’’ SW (w→ c ‘’ₐ ‘VAR₀’)) ‘’ₐ v)))) ‘‘→'’’ (SW (b ‘’ₐ v) ‘‘’’ SW (c ‘’ₐ v))))) ‘s←←’ : ∀ {T B} {b : Term {ε} (T ‘→’ W (‘Typ’ ‘’ ⌜ ε ▻ B ⌝c))} {c : Term {ε} (T ‘→’ W (‘Term’ ‘’₁ ⌜ ε ⌝c ‘’ ⌜ B ⌝T))} {v : Term {ε} T} → (Term {ε} (‘Term’ ‘’₁ ⌜ ε ⌝c ‘’ ((SW (b ‘’ₐ v) ‘‘’’ SW (c ‘’ₐ v)) ‘‘→'’’ (SW (((‘λ∙’ (SW (w→ b ‘’ₐ ‘VAR₀’) w‘‘’’ SW (w→ c ‘’ₐ ‘VAR₀’)) ‘’ₐ v)))))))
{ "alphanum_fraction": 0.3701784197, "avg_line_length": 61.3020833333, "ext": "agda", "hexsha": "b3040b68af1eff366fea9f95fd5444e8d3d020ab", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-07-17T18:53:37.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-17T18:53:37.000Z", "max_forks_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JasonGross/lob", "max_forks_repo_path": "internal/well-typed-syntax.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_issues_repo_issues_event_max_datetime": "2015-07-17T20:20:43.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-17T20:20:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JasonGross/lob", "max_issues_repo_path": "internal/well-typed-syntax.agda", "max_line_length": 216, "max_stars_count": 19, "max_stars_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JasonGross/lob", "max_stars_repo_path": "internal/well-typed-syntax.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-17T14:04:53.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-17T17:53:30.000Z", "num_tokens": 6522, "size": 11770 }
{-# OPTIONS --safe #-} module Cubical.Algebra.CommRing.QuotientRing where open import Cubical.Foundations.Prelude open import Cubical.Data.Nat open import Cubical.Data.FinData open import Cubical.HITs.SetQuotients as SQ renaming (_/_ to _/sq_) open import Cubical.HITs.PropositionalTruncation as PT open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.Ideal open import Cubical.Algebra.CommRing.FGIdeal open import Cubical.Algebra.Ring open import Cubical.Algebra.Ring.QuotientRing renaming (_/_ to _/Ring_) hiding (asRing) private variable ℓ ℓ' : Level _/_ : (R : CommRing ℓ) → (I : IdealsIn R) → CommRing ℓ R / I = fst asRing , commringstr _ _ _ _ _ (iscommring (RingStr.isRing (snd asRing)) (elimProp2 (λ _ _ → squash/ _ _) commEq)) where asRing = (CommRing→Ring R) /Ring (CommIdeal→Ideal I) _·/_ : fst asRing → fst asRing → fst asRing _·/_ = RingStr._·_ (snd asRing) commEq : (x y : fst R) → ([ x ] ·/ [ y ]) ≡ ([ y ] ·/ [ x ]) commEq x y i = [ CommRingStr.·Comm (snd R) x y i ] [_]/ : {R : CommRing ℓ} {I : IdealsIn R} → (a : fst R) → fst (R / I) [ a ]/ = [ a ] -- module Quotient-FGideal-CommRing-Ring (A'@(A , Ar) : CommRing ℓ) (B'@(B , Br) : Ring ℓ') (g'@(g , gr) : RingHom (CommRing→Ring A') B') where open CommRingStr Ar using () renaming ( 0r to 0A ; 1r to 1A ; _+_ to _+A_ ; -_ to -A_ ; _·_ to _·A_ ) open RingStr Br using () renaming ( 0r to 0B ; 1r to 1B ; _+_ to _+B_ ; -_ to -B_ ; _·_ to _·B_ ; +Lid to +BIdL ; is-set to isSetB) open CommRingStr open IsRingHom module _ {n : ℕ} (v : FinVec A n) (gnull : (k : Fin n) → g ( v k) ≡ 0B) where f : RingHom (CommRing→Ring (A' / (generatedIdeal _ v))) B' fst f = SQ.rec (isSetB) g λ a b → PT.rec (isSetB _ _) λ x → g a ≡⟨ cong g (sym (+Rid Ar a)) ⟩ g (a +A 0A) ≡⟨ cong (λ X → g (a +A X)) (sym (snd (+Inv Ar b))) ⟩ g (a +A ((-A b) +A b)) ≡⟨ cong g (+Assoc Ar a (-A b) b) ⟩ g ((a +A -A b) +A b) ≡⟨ pres+ gr (a +A -A b) b ⟩ (g(a +A -A b) +B g b) ≡⟨ cong (λ X → g X +B g b) (snd x) ⟩ (g (linearCombination A' (fst x) v) +B g b) ≡⟨ cong (λ X → X +B g b) (cancelLinearCombination A' B' g' n (fst x) v gnull) ⟩ 0B +B g b ≡⟨ +BIdL (g b) ⟩ g b ∎ snd f = makeIsRingHom (pres1 gr) (elimProp (λ x p q i y j → isSetB _ _ (p y) (q y) i j) λ a → elimProp (λ _ → isSetB _ _) λ a' → pres+ gr a a') (elimProp (λ x p q i y j → isSetB _ _ (p y) (q y) i j) λ a → elimProp (λ _ → isSetB _ _) λ a' → pres· gr a a') module Quotient-FGideal-CommRing-CommRing (A'@(A , Ar) : CommRing ℓ) (B'@(B , Br) : CommRing ℓ') (g'@(g , gr) : CommRingHom A' B') {n : ℕ} (v : FinVec A n) (gnull : (k : Fin n) → g ( v k) ≡ CommRingStr.0r (snd B')) where f : CommRingHom (A' / (generatedIdeal _ v)) B' f = Quotient-FGideal-CommRing-Ring.f A' (CommRing→Ring B') g' v gnull
{ "alphanum_fraction": 0.4683544304, "avg_line_length": 33.2242990654, "ext": "agda", "hexsha": "057300ee3915a28511c57482b620746d9ea9cc0b", "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": "b6fbca9e83e553c5c2e4a16a2df7f9e9039034dc", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "xekoukou/cubical", "max_forks_repo_path": "Cubical/Algebra/CommRing/QuotientRing.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b6fbca9e83e553c5c2e4a16a2df7f9e9039034dc", "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": "xekoukou/cubical", "max_issues_repo_path": "Cubical/Algebra/CommRing/QuotientRing.agda", "max_line_length": 145, "max_stars_count": null, "max_stars_repo_head_hexsha": "b6fbca9e83e553c5c2e4a16a2df7f9e9039034dc", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "xekoukou/cubical", "max_stars_repo_path": "Cubical/Algebra/CommRing/QuotientRing.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1251, "size": 3555 }
{-# OPTIONS --cubical --safe #-} module Cubical.Foundations.Logic where import Cubical.Data.Empty as D import Cubical.Data.Prod as D import Cubical.Data.Sum as D import Cubical.Data.Unit as D open import Cubical.Foundations.Prelude open import Cubical.HITs.PropositionalTruncation open import Cubical.Foundations.HLevels using (hProp; ΣProp≡; isPropIsProp; propPi) public open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Function open import Cubical.Relation.Nullary hiding (¬_) infix 10 ¬_ infixr 8 _⊔_ infixr 8 _⊔′_ infixr 8 _⊓_ infixr 8 _⊓′_ infixr 6 _⇒_ infixr 4 _⇔_ infix 30 _≡ₚ_ infix 30 _≢ₚ_ infix 2 ∃[]-syntax infix 2 ∃[∶]-syntax infix 2 ∀[∶]-syntax infix 2 ∀[]-syntax infix 2 ⇒∶_⇐∶_ infix 2 ⇐∶_⇒∶_ -------------------------------------------------------------------------------- -- The type hProp of mere propositions -- the definition hProp is given in Foundations.HLevels -- hProp {ℓ} = Σ (Type ℓ) isProp private variable ℓ ℓ' ℓ'' : Level P Q R : hProp {ℓ} A B C : Type ℓ [_] : hProp → Type ℓ [_] = fst ∥_∥ₚ : Type ℓ → hProp ∥ A ∥ₚ = ∥ A ∥ , propTruncIsProp _≡ₚ_ : (x y : A) → hProp x ≡ₚ y = ∥ x ≡ y ∥ₚ hProp≡ : [ P ] ≡ [ Q ] → P ≡ Q hProp≡ p = ΣProp≡ (\ _ → isPropIsProp) p -------------------------------------------------------------------------------- -- Logical implication of mere propositions _⇒_ : (A : hProp {ℓ}) → (B : hProp {ℓ'}) → hProp A ⇒ B = ([ A ] → [ B ]) , propPi λ _ → B .snd ⇔toPath : [ P ⇒ Q ] → [ Q ⇒ P ] → P ≡ Q ⇔toPath {P = P} {Q = Q} P⇒Q Q⇒P = hProp≡ (isoToPath (iso P⇒Q Q⇒P (λ b → Q .snd (P⇒Q (Q⇒P b)) b) λ a → P .snd (Q⇒P (P⇒Q a)) a)) pathTo⇒ : P ≡ Q → [ P ⇒ Q ] pathTo⇒ p x = subst fst p x pathTo⇐ : P ≡ Q → [ Q ⇒ P ] pathTo⇐ p x = subst fst (sym p) x substₚ : {x y : A} (B : A → hProp {ℓ}) → [ x ≡ₚ y ⇒ B x ⇒ B y ] substₚ {x = x} {y = y} B = elimPropTrunc (λ _ → propPi λ _ → B y .snd) (subst (fst ∘ B)) -------------------------------------------------------------------------------- -- Mixfix notations for ⇔-toPath -- see ⊔-identityˡ and ⊔-identityʳ for the difference ⇒∶_⇐∶_ : [ P ⇒ Q ] → [ Q ⇒ P ] → P ≡ Q ⇒∶_⇐∶_ = ⇔toPath ⇐∶_⇒∶_ : [ Q ⇒ P ] → [ P ⇒ Q ] → P ≡ Q ⇐∶ g ⇒∶ f = ⇔toPath f g -------------------------------------------------------------------------------- -- False and True ⊥ : hProp ⊥ = D.⊥ , λ () ⊤ : hProp ⊤ = D.Unit , (λ _ _ _ → D.tt) -------------------------------------------------------------------------------- -- Pseudo-complement of mere propositions ¬_ : hProp {ℓ} → hProp ¬ A = ([ A ] → D.⊥) , propPi λ _ → D.isProp⊥ _≢ₚ_ : (x y : A) → hProp x ≢ₚ y = ¬ x ≡ₚ y -------------------------------------------------------------------------------- -- Disjunction of mere propositions _⊔′_ : Type ℓ → Type ℓ' → Type _ A ⊔′ B = ∥ A D.⊎ B ∥ _⊔_ : hProp {ℓ} → hProp {ℓ'} → hProp P ⊔ Q = ∥ [ P ] D.⊎ [ Q ] ∥ₚ inl : A → A ⊔′ B inl x = ∣ D.inl x ∣ inr : B → A ⊔′ B inr x = ∣ D.inr x ∣ ⊔-elim : (P : hProp {ℓ}) (Q : hProp {ℓ'}) (R : [ P ⊔ Q ] → hProp {ℓ''}) → (∀ x → [ R (inl x) ]) → (∀ y → [ R (inr y) ]) → (∀ z → [ R z ]) ⊔-elim _ _ R P⇒R Q⇒R = elimPropTrunc (snd ∘ R) (D.elim-⊎ P⇒R Q⇒R) -------------------------------------------------------------------------------- -- Conjunction of mere propositions _⊓′_ : Type ℓ → Type ℓ' → Type _ A ⊓′ B = A D.× B _⊓_ : hProp {ℓ} → hProp {ℓ'} → hProp A ⊓ B = [ A ] ⊓′ [ B ] , D.hLevelProd 1 (A .snd) (B .snd) ⊓-intro : (P : hProp {ℓ}) (Q : [ P ] → hProp {ℓ'}) (R : [ P ] → hProp {ℓ''}) → (∀ a → [ Q a ]) → (∀ a → [ R a ]) → (∀ (a : [ P ]) → [ Q a ⊓ R a ] ) ⊓-intro _ _ _ = D.intro-× -------------------------------------------------------------------------------- -- Logical bi-implication of mere propositions _⇔_ : hProp {ℓ} → hProp {ℓ'} → hProp A ⇔ B = (A ⇒ B) ⊓ (B ⇒ A) -------------------------------------------------------------------------------- -- Universal Quantifier ∀[∶]-syntax : (A → hProp {ℓ}) → hProp ∀[∶]-syntax {A = A} P = (∀ x → [ P x ]) , propPi (snd ∘ P) ∀[]-syntax : (A → hProp {ℓ}) → hProp ∀[]-syntax {A = A} P = (∀ x → [ P x ]) , propPi (snd ∘ P) syntax ∀[∶]-syntax {A = A} (λ a → P) = ∀[ a ∶ A ] P syntax ∀[]-syntax (λ a → P) = ∀[ a ] P -------------------------------------------------------------------------------- -- Existential Quantifier ∃[]-syntax : (A → hProp {ℓ}) → hProp ∃[]-syntax {A = A} P = ∥ Σ A (fst ∘ P) ∥ₚ ∃[∶]-syntax : (A → hProp {ℓ}) → hProp ∃[∶]-syntax {A = A} P = ∥ Σ A (fst ∘ P) ∥ₚ syntax ∃[]-syntax {A = A} (λ x → P) = ∃[ x ∶ A ] P syntax ∃[∶]-syntax (λ x → P) = ∃[ x ] P -------------------------------------------------------------------------------- -- Decidable mere proposition Decₚ : (P : hProp {ℓ}) → hProp {ℓ} Decₚ P = Dec [ P ] , isPropDec (snd P) -------------------------------------------------------------------------------- -- Negation commutes with truncation ∥¬A∥≡¬∥A∥ : (A : Type ℓ) → ∥ (A → D.⊥) ∥ₚ ≡ (¬ ∥ A ∥ₚ) ∥¬A∥≡¬∥A∥ _ = ⇒∶ (λ ¬A A → elimPropTrunc (λ _ → D.isProp⊥) (elimPropTrunc (λ _ → propPi λ _ → D.isProp⊥) (λ ¬p p → ¬p p) ¬A) A) ⇐∶ λ ¬p → ∣ (λ p → ¬p ∣ p ∣) ∣ -------------------------------------------------------------------------------- -- (hProp, ⊔, ⊥) is a bounded ⊔-semilattice ⊔-assoc : (P : hProp {ℓ}) (Q : hProp {ℓ'}) (R : hProp {ℓ''}) → P ⊔ (Q ⊔ R) ≡ (P ⊔ Q) ⊔ R ⊔-assoc P Q R = ⇒∶ ⊔-elim P (Q ⊔ R) (λ _ → (P ⊔ Q) ⊔ R) (inl ∘ inl) (⊔-elim Q R (λ _ → (P ⊔ Q) ⊔ R) (inl ∘ inr) inr) ⇐∶ assoc2 where assoc2 : (A ⊔′ B) ⊔′ C → A ⊔′ (B ⊔′ C) assoc2 ∣ D.inr a ∣ = ∣ D.inr ∣ D.inr a ∣ ∣ assoc2 ∣ D.inl ∣ D.inr b ∣ ∣ = ∣ D.inr ∣ D.inl b ∣ ∣ assoc2 ∣ D.inl ∣ D.inl c ∣ ∣ = ∣ D.inl c ∣ assoc2 ∣ D.inl (squash x y i) ∣ = propTruncIsProp (assoc2 ∣ D.inl x ∣) (assoc2 ∣ D.inl y ∣) i assoc2 (squash x y i) = propTruncIsProp (assoc2 x) (assoc2 y) i ⊔-idem : (P : hProp {ℓ}) → P ⊔ P ≡ P ⊔-idem P = ⇒∶ (⊔-elim P P (\ _ → P) (\ x → x) (\ x → x)) ⇐∶ inl ⊔-comm : (P : hProp {ℓ}) (Q : hProp {ℓ'}) → P ⊔ Q ≡ Q ⊔ P ⊔-comm P Q = ⇒∶ (⊔-elim P Q (\ _ → (Q ⊔ P)) inr inl) ⇐∶ (⊔-elim Q P (\ _ → (P ⊔ Q)) inr inl) ⊔-identityˡ : (P : hProp {ℓ}) → ⊥ ⊔ P ≡ P ⊔-identityˡ P = ⇒∶ (⊔-elim ⊥ P (λ _ → P) (λ ()) (λ x → x)) ⇐∶ inr ⊔-identityʳ : (P : hProp {ℓ}) → P ⊔ ⊥ ≡ P ⊔-identityʳ P = ⇔toPath (⊔-elim P ⊥ (λ _ → P) (λ x → x) λ ()) inl -------------------------------------------------------------------------------- -- (hProp, ⊓, ⊤) is a bounded ⊓-lattice ⊓-assoc : (P : hProp {ℓ}) (Q : hProp {ℓ'}) (R : hProp {ℓ''}) → P ⊓ Q ⊓ R ≡ (P ⊓ Q) ⊓ R ⊓-assoc _ _ _ = ⇒∶ (λ {(x D., (y D., z)) → (x D., y) D., z}) ⇐∶ (λ {((x D., y) D., z) → x D., (y D., z) }) ⊓-comm : (P : hProp {ℓ}) (Q : hProp {ℓ'}) → P ⊓ Q ≡ Q ⊓ P ⊓-comm _ _ = ⇔toPath D.swap D.swap ⊓-idem : (P : hProp {ℓ}) → P ⊓ P ≡ P ⊓-idem _ = ⇔toPath D.proj₁ (λ x → x D., x) ⊓-identityˡ : (P : hProp {ℓ}) → ⊤ ⊓ P ≡ P ⊓-identityˡ _ = ⇔toPath D.proj₂ λ x → D.tt D., x ⊓-identityʳ : (P : hProp {ℓ}) → P ⊓ ⊤ ≡ P ⊓-identityʳ _ = ⇔toPath D.proj₁ λ x → x D., D.tt -------------------------------------------------------------------------------- -- Distributive laws ⇒-⊓-distrib : (P : hProp {ℓ}) (Q : hProp {ℓ'})(R : hProp {ℓ''}) → P ⇒ (Q ⊓ R) ≡ (P ⇒ Q) ⊓ (P ⇒ R) ⇒-⊓-distrib _ _ _ = ⇒∶ (λ f → (D.proj₁ ∘ f) D., (D.proj₂ ∘ f)) ⇐∶ (λ { (f D., g) x → f x D., g x}) ⊓-⊔-distribˡ : (P : hProp {ℓ}) (Q : hProp {ℓ'})(R : hProp {ℓ''}) → P ⊓ (Q ⊔ R) ≡ (P ⊓ Q) ⊔ (P ⊓ R) ⊓-⊔-distribˡ P Q R = ⇒∶ (λ { (x D., a) → ⊔-elim Q R (λ _ → (P ⊓ Q) ⊔ (P ⊓ R)) (λ y → ∣ D.inl (x D., y) ∣ ) (λ z → ∣ D.inr (x D., z) ∣ ) a }) ⇐∶ ⊔-elim (P ⊓ Q) (P ⊓ R) (λ _ → P ⊓ Q ⊔ R) (λ y → D.proj₁ y D., inl (D.proj₂ y)) (λ z → D.proj₁ z D., inr (D.proj₂ z)) ⊔-⊓-distribˡ : (P : hProp {ℓ}) (Q : hProp {ℓ'})(R : hProp {ℓ''}) → P ⊔ (Q ⊓ R) ≡ (P ⊔ Q) ⊓ (P ⊔ R) ⊔-⊓-distribˡ P Q R = ⇒∶ ⊔-elim P (Q ⊓ R) (λ _ → (P ⊔ Q) ⊓ (P ⊔ R) ) (D.intro-× inl inl) (D.map-× inr inr) ⇐∶ (λ { (x D., y) → ⊔-elim P R (λ _ → P ⊔ Q ⊓ R) inl (λ z → ⊔-elim P Q (λ _ → P ⊔ Q ⊓ R) inl (λ y → inr (y D., z)) x) y }) ⊓-∀-distrib : (P : A → hProp {ℓ}) (Q : A → hProp {ℓ'}) → (∀[ a ∶ A ] P a) ⊓ (∀[ a ∶ A ] Q a) ≡ (∀[ a ∶ A ] (P a ⊓ Q a)) ⊓-∀-distrib P Q = ⇒∶ (λ {(p D., q) a → p a D., q a}) ⇐∶ λ pq → (D.proj₁ ∘ pq ) D., (D.proj₂ ∘ pq)
{ "alphanum_fraction": 0.3973068058, "avg_line_length": 29.865942029, "ext": "agda", "hexsha": "0f62982ab3167c3a167eed2264c64969894356e3", "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": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cj-xu/cubical", "max_forks_repo_path": "Cubical/Foundations/Logic.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "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": "cj-xu/cubical", "max_issues_repo_path": "Cubical/Foundations/Logic.agda", "max_line_length": 97, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cj-xu/cubical", "max_stars_repo_path": "Cubical/Foundations/Logic.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3839, "size": 8243 }
------------------------------------------------------------------------ -- Propositional equality ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Equality.Propositional where open import Equality open import Logical-equivalence hiding (_∘_) open import Prelude ------------------------------------------------------------------------ -- Equality open import Agda.Builtin.Equality public using (_≡_; refl) private refl′ : ∀ {a} {A : Type a} (x : A) → x ≡ x refl′ x = refl elim : ∀ {a p} {A : Type a} {x y} (P : {x y : A} → x ≡ y → Type p) → (∀ x → P (refl′ x)) → (x≡y : x ≡ y) → P x≡y elim P r refl = r _ elim-refl : ∀ {a p} {A : Type a} {x} (P : {x y : A} → x ≡ y → Type p) (r : ∀ x → P (refl′ x)) → elim P r (refl′ x) ≡ r x elim-refl P r = refl ------------------------------------------------------------------------ -- Various derived definitions and properties reflexive-relation : ∀ ℓ → Reflexive-relation ℓ Reflexive-relation._≡_ (reflexive-relation _) = _≡_ Reflexive-relation.refl (reflexive-relation _) = refl′ equality-with-J₀ : ∀ {a p} → Equality-with-J₀ a p reflexive-relation Equality-with-J₀.elim equality-with-J₀ = elim Equality-with-J₀.elim-refl equality-with-J₀ = elim-refl equivalence-relation⁺ : ∀ ℓ → Equivalence-relation⁺ ℓ equivalence-relation⁺ _ = J₀⇒Equivalence-relation⁺ equality-with-J₀ -- The following definition has been expanded in order to ensure that -- it does not reduce (unless a projection is applied to it). equality-with-J : ∀ {a p} → Equality-with-J a p equivalence-relation⁺ equality-with-J .Equality-with-J.equality-with-J₀ = J₀⇒J equality-with-J₀ .Equality-with-J.equality-with-J₀ equality-with-J .Equality-with-J.cong = J₀⇒J equality-with-J₀ .Equality-with-J.cong equality-with-J .Equality-with-J.cong-refl = J₀⇒J equality-with-J₀ .Equality-with-J.cong-refl equality-with-J .Equality-with-J.subst = J₀⇒J equality-with-J₀ .Equality-with-J.subst equality-with-J .Equality-with-J.subst-refl = J₀⇒J equality-with-J₀ .Equality-with-J.subst-refl equality-with-J .Equality-with-J.dcong = J₀⇒J equality-with-J₀ .Equality-with-J.dcong equality-with-J .Equality-with-J.dcong-refl = J₀⇒J equality-with-J₀ .Equality-with-J.dcong-refl open Derived-definitions-and-properties equality-with-J public hiding (_≡_; refl; reflexive-relation; equality-with-J₀)
{ "alphanum_fraction": 0.5850258861, "avg_line_length": 39.8571428571, "ext": "agda", "hexsha": "35fc5ee37c9192e94782d563726ffe6f56668e32", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Equality/Propositional.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Equality/Propositional.agda", "max_line_length": 107, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Equality/Propositional.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 712, "size": 2511 }
-- Andreas, 2011-04-11 -- taken from test/succeed/HereditarilySingletonRecord.agda module FrozenMVar where data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x data ℕ : Set where zero : ℕ suc : (n : ℕ) → ℕ one : ℕ one = _ force : one ≡ suc zero force = refl -- this tries to instantiate the frozen metavar for one
{ "alphanum_fraction": 0.6524390244, "avg_line_length": 18.2222222222, "ext": "agda", "hexsha": "a20d12d2b08fb674beb7fc8cb1da57dc97ce8efe", "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/FrozenMVar.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/FrozenMVar.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/FrozenMVar.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": 113, "size": 328 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT module groups.KernelCstImage {i j k} {G : Group i} {H : Group j} (K : Group k) (φ : G →ᴳ H) (H-ab : is-abelian H) where open import groups.KernelImage {K = K} cst-hom φ H-ab open import groups.Cokernel φ H-ab Ker-cst-quot-Im : Ker/Im ≃ᴳ Coker Ker-cst-quot-Im = ≃-to-≃ᴳ (equiv to from to-from from-to) to-pres-comp where to : Ker/Im.El → Coker.El to = SetQuot-rec SetQuot-level to' quot-rel where to' : Ker.El (cst-hom {G = H} {H = K}) → Coker.El to' ker = q[ fst ker ] from : Coker.El → Ker/Im.El from = SetQuot-rec SetQuot-level from' quot-rel where from' : Group.El H → Ker/Im.El from' h = q[ h , idp ] abstract to-from : ∀ cok → to (from cok) == cok to-from = SetQuot-elim (λ _ → =-preserves-set SetQuot-level) (λ _ → idp) (λ _ → prop-has-all-paths-↓ (SetQuot-level _ _)) from-to : ∀ ker → from (to ker) == ker from-to = SetQuot-elim (λ _ → =-preserves-set SetQuot-level) (λ _ → ap q[_] $ ker-El=-out idp) (λ _ → prop-has-all-paths-↓ (SetQuot-level _ _)) to-pres-comp : preserves-comp Ker/Im.comp Coker.comp to to-pres-comp = SetQuot-elim (λ _ → Π-is-set λ _ → =-preserves-set SetQuot-level) (λ _ → SetQuot-elim (λ _ → =-preserves-set SetQuot-level) (λ _ → idp) (λ _ → prop-has-all-paths-↓ (SetQuot-level _ _))) (λ _ → prop-has-all-paths-↓ (Π-is-prop λ _ → SetQuot-level _ _))
{ "alphanum_fraction": 0.5679579777, "avg_line_length": 35.4186046512, "ext": "agda", "hexsha": "36a67387c4a50b0233de7d289906f0aaf12b63f2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "theorems/groups/KernelCstImage.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "theorems/groups/KernelCstImage.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "theorems/groups/KernelCstImage.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 548, "size": 1523 }
{- Pointed structure: X ↦ X -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Structures.Relational.Pointed where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Structure open import Cubical.Foundations.RelationalStructure open import Cubical.Foundations.Univalence open import Cubical.Relation.ZigZag.Base open import Cubical.HITs.SetQuotients open import Cubical.HITs.PropositionalTruncation open import Cubical.Structures.Pointed private variable ℓ : Level -- Structured relations preservesSetsPointed : preservesSets {ℓ = ℓ} PointedStructure preservesSetsPointed setX = setX PointedRelStr : StrRel PointedStructure ℓ PointedRelStr R = R open SuitableStrRel open isQuasiEquivRel pointedSuitableRel : SuitableStrRel {ℓ = ℓ} PointedStructure PointedRelStr pointedSuitableRel .quo _ _ _ = isContrSingl _ pointedSuitableRel .symmetric _ r = r pointedSuitableRel .transitive _ _ r r' = ∣ _ , r , r' ∣ pointedSuitableRel .prop propR = propR pointedRelMatchesEquiv : StrRelMatchesEquiv {ℓ = ℓ} PointedRelStr PointedEquivStr pointedRelMatchesEquiv _ _ _ = idEquiv _
{ "alphanum_fraction": 0.8077586207, "avg_line_length": 26.976744186, "ext": "agda", "hexsha": "a66de3e188fe26ed40a522d34b6566671a5cb6de", "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": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "RobertHarper/cubical", "max_forks_repo_path": "Cubical/Structures/Relational/Pointed.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "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": "RobertHarper/cubical", "max_issues_repo_path": "Cubical/Structures/Relational/Pointed.agda", "max_line_length": 81, "max_stars_count": null, "max_stars_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "RobertHarper/cubical", "max_stars_repo_path": "Cubical/Structures/Relational/Pointed.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 350, "size": 1160 }
open import Oscar.Prelude open import Oscar.Class open import Oscar.Data.𝟙 module Oscar.Class.Unit where module Unit {𝔞} (𝔄 : Ø 𝔞) = ℭLASS 𝟙 𝔄 module _ {𝔞} {𝔄 : Ø 𝔞} where ‼ = Unit.method 𝔄
{ "alphanum_fraction": 0.6958762887, "avg_line_length": 17.6363636364, "ext": "agda", "hexsha": "5d65c26124af5ef8819ffd9d05c12b26ff041108", "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/Unit.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/Unit.agda", "max_line_length": 46, "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/Unit.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 80, "size": 194 }
------------------------------------------------------------------------ -- A proof of univalence ------------------------------------------------------------------------ -- The code is based on code by Anders Mörtberg from Agda's reference -- manual or the cubical library. {-# OPTIONS --cubical --safe #-} module Equality.Path.Univalence where open import Agda.Builtin.Cubical.Glue as Glue hiding (_≃_) open import Equality.Path open import Prelude open import Equivalence equality-with-J as Eq using (_≃_) import Equivalence.Contractible-preimages equality-with-J as CP import Equivalence.Half-adjoint equality-with-J as HA open import Function-universe equality-with-J hiding (id) open import Preimage equality-with-J open import Univalence-axiom equality-with-J hiding (≃⇒≡) private variable a b ℓ : Level A : Type a private -- Conversions between CP._≃_ and Glue._≃_. ≃-CP⇒≃-Glue : {B : Type b} → A CP.≃ B → A Glue.≃ B ≃-CP⇒≃-Glue = Σ-map id (λ eq → record { equiv-proof = eq }) ≃-Glue⇒≃-CP : {B : Type b} → A Glue.≃ B → A CP.≃ B ≃-Glue⇒≃-CP = Σ-map id Glue.isEquiv.equiv-proof -- Equivalences can be converted to equalities (if the two types live -- in the same universe). ≃-CP⇒≡ : {A B : Type ℓ} → A CP.≃ B → A ≡ B ≃-CP⇒≡ {A = A} {B = B} A≃B = λ i → primGlue B (λ { (i = 0̲) → A ; (i = 1̲) → B }) (λ { (i = 0̲) → ≃-CP⇒≃-Glue A≃B ; (i = 1̲) → ≃-CP⇒≃-Glue CP.id }) -- If ≃-CP⇒≡ is applied to the identity equivalence, then the result -- is equal to CP.id. ≃-CP⇒≡-id : ≃-CP⇒≡ CP.id ≡ refl {x = A} ≃-CP⇒≡-id {A = A} = λ i j → primGlue A {φ = max i (max j (- j))} (λ _ → A) (λ _ → ≃-CP⇒≃-Glue CP.id) -- ≃-CP⇒≡ is a left inverse of CP.≡⇒≃. ≃-CP⇒≡∘≡⇒≃ : {A B : Type ℓ} (A≡B : A ≡ B) → ≃-CP⇒≡ (CP.≡⇒≃ A≡B) ≡ A≡B ≃-CP⇒≡∘≡⇒≃ = elim (λ A≡B → ≃-CP⇒≡ (CP.≡⇒≃ A≡B) ≡ A≡B) (λ A → ≃-CP⇒≡ (CP.≡⇒≃ refl) ≡⟨ cong ≃-CP⇒≡ CP.≡⇒≃-refl ⟩ ≃-CP⇒≡ CP.id ≡⟨ ≃-CP⇒≡-id ⟩∎ refl ∎) -- ≃-CP⇒≡ is a right inverse of CP.≡⇒≃. ≡⇒≃∘≃-CP⇒≡ : {A B : Type ℓ} (A≃B : A CP.≃ B) → CP.≡⇒≃ (≃-CP⇒≡ A≃B) ≡ A≃B ≡⇒≃∘≃-CP⇒≡ {A = A} {B = B} A≃B = Σ-≡,≡→≡ (proj₁ (CP.≡⇒≃ (≃-CP⇒≡ A≃B)) ≡⟨⟩ proj₁ (transport (λ i → A CP.≃ ≃-CP⇒≡ A≃B i) 0̲ CP.id) ≡⟨⟩ transport (λ i → A → ≃-CP⇒≡ A≃B i) 0̲ id ≡⟨⟩ transport (λ _ → A → B) 0̲ (proj₁ A≃B) ≡⟨ cong (_$ proj₁ A≃B) $ transport-refl 0̲ ⟩∎ proj₁ A≃B ∎) (CP.propositional ext _ _ _) -- Univalence for CP._≃_. univ-CP : CP.Univalence ℓ univ-CP = Is-equivalence≃Is-equivalence-CP _ $ _≃_.is-equivalence $ Eq.↔→≃ _ ≃-CP⇒≡ ≡⇒≃∘≃-CP⇒≡ ≃-CP⇒≡∘≡⇒≃ -- Univalence. univ : ∀ {ℓ} → Univalence ℓ univ {A = A} {B = B} = record { univalence = from , proofs } where univ′ : Univalence′ A B univ′ = _≃_.from (Univalence≃Univalence-CP ext) univ-CP from : A ≃ B → A ≡ B from = proj₁ (Univalence′.univalence univ′) abstract proofs : HA.Proofs ≡⇒≃ from proofs = proj₂ (Univalence′.univalence univ′) -- Equivalences can be converted to equalities (if the two types live -- in the same universe). ≃⇒≡ : {A B : Type ℓ} → A ≃ B → A ≡ B ≃⇒≡ = _≃_.from Eq.⟨ _ , Univalence′.univalence univ ⟩ private -- The type primGlue A B f is equivalent to A. primGlue≃-CP : (φ : I) (B : Partial φ (Type ℓ)) (f : PartialP φ (λ x → B x Glue.≃ A)) → primGlue A B f CP.≃ A primGlue≃-CP {A = A} φ B f = prim^unglue {φ = φ} , λ x → ( prim^glue (λ p → CP.inverse (proj₂ (f-CP p)) x) (hcomp (lemma₁ x) x) , (hcomp (lemma₁ x) x ≡⟨ sym $ hfill (lemma₁ x) (inˢ x) ⟩∎ x ∎) ) , λ y i → prim^glue (λ { (φ = 1̲) → proj₁ (lemma₂ is-one y i) }) (hcomp (lemma₃ y i) x) , (hcomp (lemma₃ y i) x ≡⟨ sym $ hfill (lemma₃ y i) (inˢ x) ⟩∎ x ∎) where f-CP : PartialP φ (λ x → B x CP.≃ A) f-CP p = ≃-Glue⇒≃-CP (f p) lemma₁ : A → ∀ i → Partial φ A lemma₁ x i (φ = 1̲) = ( x ≡⟨ sym (CP.right-inverse-of (proj₂ (f-CP is-one)) x) ⟩∎ proj₁ (f-CP _) (CP.inverse (proj₂ (f-CP _)) x) ∎) i lemma₂ : ∀ {x} p (y : proj₁ (f-CP p) ⁻¹ x) → ( CP.inverse (proj₂ (f-CP p)) x , CP.right-inverse-of (proj₂ (f-CP p)) x ) ≡ y lemma₂ {x} p = CP.irrelevance (proj₂ (f-CP p)) x lemma₃ : ∀ {x} → prim^unglue {e = f} ⁻¹ x → ∀ i → I → Partial (max φ (max i (- i))) A lemma₃ y i j (φ = 1̲) = sym (proj₂ (lemma₂ is-one y i)) j lemma₃ {x} _ i j (i = 0̲) = hfill (lemma₁ x) (inˢ x) j lemma₃ y i j (i = 1̲) = sym (proj₂ y) j -- An alternative formulation of univalence. other-univ : Other-univalence ℓ other-univ {ℓ = ℓ} {B = B} = $⟨ other-univ-CP ⟩ Contractible (∃ λ (A : Type ℓ) → A CP.≃ B) ↝⟨ (H-level-cong _ 0 $ ∃-cong λ _ → inverse $ ≃≃≃-CP {k = equivalence} ext) ⦂ (_ → _) ⟩□ Contractible (∃ λ (A : Type ℓ) → A ≃ B) □ where other-univ-CP : Contractible (∃ λ (A : Type ℓ) → A CP.≃ B) other-univ-CP = (B , CP.id) , λ (A , A≃B) i → let C : ∀ i → Partial (max i (- i)) (Type ℓ) C = λ { i (i = 0̲) → B ; i (i = 1̲) → A } f : ∀ i → PartialP (max i (- i)) (λ j → C i j Glue.≃ B) f = λ { i (i = 0̲) → ≃-CP⇒≃-Glue CP.id ; i (i = 1̲) → ≃-CP⇒≃-Glue A≃B } in primGlue _ _ (f i) , primGlue≃-CP _ _ (f i)
{ "alphanum_fraction": 0.447435679, "avg_line_length": 31.0529100529, "ext": "agda", "hexsha": "13a3440b21bb7718db82ade7d4b61136915f3a11", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Equality/Path/Univalence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Equality/Path/Univalence.agda", "max_line_length": 109, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Equality/Path/Univalence.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 2579, "size": 5869 }
-- WARNING: This file was generated automatically by Vehicle -- and should not be modified manually! -- Metadata -- - Agda version: 2.6.2 -- - AISEC version: 0.1.0.1 -- - Time generated: ??? {-# OPTIONS --allow-exec #-} open import Vehicle open import Data.Product open import Data.Integer as ℤ using (ℤ) open import Data.Rational as ℝ using () renaming (ℚ to ℝ) module andGate-output where private VEHICLE_PROJECT_FILE = "TODO_projectFile" andGate : ℝ → (ℝ → ℝ) andGate = evaluate record { projectFile = VEHICLE_PROJECT_FILE ; networkUUID = "TODO_networkUUID" } Truthy : ℝ → Set Truthy x = x ℝ.≥ ℤ.+ 1 ℝ./ 2 Falsey : ℝ → Set Falsey x = x ℝ.≤ ℤ.+ 1 ℝ./ 2 ValidInput : ℝ → Set ValidInput x = ℤ.+ 0 ℝ./ 1 ℝ.≤ x × x ℝ.≤ ℤ.+ 1 ℝ./ 1 CorrectOutput : ℝ → (ℝ → Set) CorrectOutput x1 x2 = let y = andGate x1 x2 in (Truthy x1 × Truthy x2 → Truthy y) × ((Truthy x1 × Falsey x2 → Falsey y) × ((Falsey x1 × Truthy x2 → Falsey y) × (Falsey x1 × Falsey x2 → Falsey y))) abstract andGateCorrect : ∀ (x1 : ℝ) → ∀ (x2 : ℝ) → ValidInput x1 × ValidInput x2 → CorrectOutput x1 x2 andGateCorrect = checkProperty record { projectFile = VEHICLE_PROJECT_FILE ; propertyUUID = "TODO_propertyUUID" }
{ "alphanum_fraction": 0.6614368291, "avg_line_length": 28.1627906977, "ext": "agda", "hexsha": "b054e7623ed95988aa46b56e821d5c4fae9105ac", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2021-11-16T14:30:47.000Z", "max_forks_repo_forks_event_min_datetime": "2021-03-15T15:22:31.000Z", "max_forks_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "wenkokke/vehicle", "max_forks_repo_path": "examples/network/andGate/andGate-output.agda", "max_issues_count": 53, "max_issues_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674", "max_issues_repo_issues_event_max_datetime": "2021-12-15T22:42:01.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-16T07:26:42.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "wenkokke/vehicle", "max_issues_repo_path": "examples/network/andGate/andGate-output.agda", "max_line_length": 196, "max_stars_count": 11, "max_stars_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "wenkokke/vehicle", "max_stars_repo_path": "examples/network/andGate/andGate-output.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T01:35:39.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-24T05:55:15.000Z", "num_tokens": 414, "size": 1211 }
{-# OPTIONS --without-K #-} module VecHelpers where open import Data.Nat import Data.Fin as F open import Data.Vec open import Function renaming (_∘_ to _○_) open import Relation.Binary.PropositionalEquality open ≡-Reasoning infixl 10 _∘̬_ -- vector composition ------------------------------------------------------------------ -- VECTOR LEMMAS AND HELPERS vmap : {n : ℕ} → {A B : Set} → (A → B) → Vec A n → Vec B n vmap f [] = [] vmap f (x ∷ xs) = (f x) ∷ (vmap f xs) -- Syntactic sugar for lookup that's a lot nicer _!!_ : {A : Set} → {n : ℕ} → Vec A n → F.Fin n → A _!!_ v i = lookup i v -- XXX: is this in the right order? _∘̬_ : {m n : ℕ} {A : Set} → Vec (F.Fin n) m → Vec A n → Vec A m v₁ ∘̬ v₂ = tabulate (λ i → v₂ !! (v₁ !! i)) _∘̬′_ : {m n : ℕ} {A : Set} → Vec (F.Fin n) m → Vec A n → Vec A m [] ∘̬′ v₂ = [] (i ∷ is) ∘̬′ v₂ = (v₂ !! i) ∷ (is ∘̬′ v₂) ∘̬≡∘̬′ : {m n : ℕ} {A : Set} (v₁ : Vec (F.Fin n) m) (v₂ : Vec A n) → (v₁ ∘̬ v₂) ≡ (v₁ ∘̬′ v₂) ∘̬≡∘̬′ [] v₂ = refl ∘̬≡∘̬′ (x ∷ v₁) v₂ = cong (_∷_ (v₂ !! x)) (∘̬≡∘̬′ v₁ v₂) ntimes : {A : Set} → ℕ → (f : A → A) → A → A ntimes zero f a = a ntimes (suc n) f a = f (ntimes n f a) ntimesD : {A : Set} → {B : A → Set} → {g : A → A} → (n : ℕ) → (f : {a : A} → B a → B (g a)) → {a : A} → B a → B (ntimes n g a) ntimesD zero f b = b ntimesD {g = g} (suc n) f {a = a} b = f {ntimes n g a} (ntimesD {g = g} n (λ {a} → f {a}) {a = a} b) ntails : {A : Set} → {n k : ℕ} → Vec A (ntimes k suc n) → Vec A n ntails {k = zero} v = v ntails {k = suc n} (x ∷ xs) = ntails {k = n} xs ntails₀ : {A : Set} → {k : ℕ} → (v : Vec A (ntimes k suc zero)) → [] ≡ ntails {k = k} v ntails₀ {k = zero} [] = refl ntails₀ {k = suc k} (x ∷ v) = ntails₀ {k = k} v -- Important lemma about lookup; for some reason it doesn't seem to be in the -- library even though it's in the main agda tutorial, iirc map!! : {n : ℕ} → {A B : Set} → (f : A → B) → (v : Vec A n) → (i : F.Fin n) → (vmap f v) !! i ≡ f (v !! i) map!! {zero} f [] () map!! {suc n} f (x ∷ xs) F.zero = refl map!! {suc n} f (x ∷ xs) (F.suc i) = map!! f xs i lookupTab : {A : Set} {n : ℕ} {f : F.Fin n → A} → (i : F.Fin n) → (tabulate f) !! i ≡ (f i) lookupTab {f = f} F.zero = refl lookupTab (F.suc i) = lookupTab i mapTab : {A B : Set} → {n : ℕ} → (f : A → B) → (g : F.Fin n → A) → vmap f (tabulate g) ≡ tabulate (f ○ g) mapTab {n = zero} f g = refl mapTab {n = suc n} f g = cong (_∷_ (f (g F.zero))) (mapTab {n = n} f (g ○ F.suc)) -- Lemma for proving that two vectors are equal if their tabulates agree -- on all inputs. tabf∼g : {n : ℕ} → {A : Set} → (f g : F.Fin n → A) → (∀ x → f x ≡ g x) → tabulate f ≡ tabulate g tabf∼g {zero} f g p = refl tabf∼g {suc n} f g p with f F.zero | g F.zero | p F.zero tabf∼g {suc n} f g p | x | .x | refl = cong (_∷_ x) (tabf∼g {n} (f ○ F.suc) (g ○ F.suc) (p ○ F.suc)) lookup∼vec : {n : ℕ} → {A : Set} → (v₁ v₂ : Vec A n) → (∀ i → v₁ !! i ≡ v₂ !! i) → v₁ ≡ v₂ lookup∼vec [] [] p = refl lookup∼vec (x ∷ v₁) (x₁ ∷ v₂) p with p F.zero lookup∼vec (x ∷ v₁) (.x ∷ v₂) p | refl = cong (_∷_ x) (lookup∼vec v₁ v₂ (p ○ F.suc)) ∘̬id : {A : Set} → {n : ℕ} → (k : ℕ) → (v : Vec A (ntimes k suc n)) → (tabulate {n} (ntimesD {ℕ} {F.Fin} {suc} k F.suc)) ∘̬ v ≡ (tabulate (λ i → v !! (ntimesD {ℕ} {F.Fin} {suc} k F.suc i))) ∘̬id {n = n} k v = begin (tabulate {n} (ntimesD {ℕ} {F.Fin} {suc} k F.suc)) ∘̬ v ≡⟨ refl ⟩ (tabulate (λ i → v !! (tabulate (ntimesD {ℕ} {F.Fin} {suc} k F.suc) !! i))) ≡⟨ tabf∼g (λ i → v !! (tabulate (ntimesD {ℕ} {F.Fin} {suc} k F.suc) !! i)) (λ i → v !! ntimesD {ℕ} {F.Fin} {suc} k F.suc i) (λ i → cong (_!!_ v) (lookupTab i)) ⟩ (tabulate (λ i → v !! (ntimesD {ℕ} {F.Fin} {suc} k F.suc i))) ∎ map2+id : {m n : ℕ} → (v : Vec (F.Fin n) m) → {x y : F.Fin (suc (suc n))} → (vmap F.suc (vmap F.suc v)) ∘̬′ (x ∷ y ∷ tabulate {n} (F.suc ○ F.suc)) ≡ (vmap F.suc (vmap F.suc v)) map2+id [] = refl map2+id {suc m} {n} (i ∷ v) {x} {y} = begin (vmap F.suc (vmap F.suc (i ∷ v))) ∘̬′ (x ∷ y ∷ tabulate (F.suc ○ F.suc)) ≡⟨ refl ⟩ (tabulate (F.suc ○ F.suc) !! i) ∷ (vmap F.suc (vmap F.suc v)) ∘̬′ (x ∷ y ∷ tabulate (F.suc ○ F.suc)) ≡⟨ cong (λ z → z ∷ ((vmap F.suc (vmap F.suc v))) ∘̬′ (x ∷ y ∷ tabulate (F.suc ○ F.suc))) (lookupTab i) ⟩ F.suc (F.suc i) ∷ (vmap F.suc (vmap F.suc v) ∘̬′ (x ∷ y ∷ tabulate (F.suc ○ F.suc))) ≡⟨ cong (_∷_ (F.suc (F.suc i))) (map2+id v) ⟩ F.suc (F.suc i) ∷ (vmap F.suc (vmap F.suc v)) ≡⟨ refl ⟩ (vmap F.suc (vmap F.suc (i ∷ v))) ∎ head!!0 : {n : ℕ} {A : Set} (v : Vec A (suc n)) → v !! F.zero ≡ head v head!!0 (x ∷ v) = refl headmap : {n : ℕ} {A B : Set} {f : A → B} (v : Vec A (suc n)) → head (vmap f v) ≡ f (head v) headmap (x ∷ v) = refl tailmap : {n : ℕ} {A B : Set} {f : A → B} (v : Vec A (suc n)) → tail (vmap f v) ≡ vmap f (tail v) tailmap (x ∷ v) = refl 2suc∘̬2tail : {n : ℕ} {A : Set} (v : Vec A (suc (suc n))) → (tabulate (F.suc ○ F.suc)) ∘̬ v ≡ (tail (tail v)) 2suc∘̬2tail (x ∷ x₁ ∷ v) = begin (tabulate (F.suc ○ F.suc)) ∘̬ (x ∷ x₁ ∷ v) ≡⟨ refl ⟩ tabulate (λ i → (x ∷ x₁ ∷ v) !! (tabulate (F.suc ○ F.suc) !! i)) ≡⟨ lookup∼vec (tabulate (λ i → (x ∷ x₁ ∷ v) !! (tabulate (F.suc ○ F.suc) !! i))) v (λ i → begin tabulate (λ j → (x ∷ x₁ ∷ v) !! (tabulate (F.suc ○ F.suc) !! j)) !! i ≡⟨ lookupTab i ⟩ (x ∷ x₁ ∷ v) !! (tabulate (F.suc ○ F.suc) !! i) ≡⟨ cong (λ q → (x ∷ x₁ ∷ v) !! q) (lookupTab i) ⟩ v !! i ∎) ⟩ v ∎ -- upTo n returns [0, 1, ..., n-1] as Fins upTo : (n : ℕ) → Vec (F.Fin n) n upTo n = tabulate {n} id upToTail : (n : ℕ) → (tail (tail (upTo (suc (suc n))))) ≡ (vmap F.suc (tail (upTo (suc n)))) upToTail n = begin tail (tail (upTo (suc (suc n)))) ≡⟨ refl ⟩ tabulate (F.suc ○ F.suc) ≡⟨ sym (mapTab F.suc F.suc) ⟩ vmap F.suc (tabulate F.suc) ∎ sidfn : {A : Set} {n : ℕ} (v : Vec A n) (i : F.Fin n) → ((upTo n) ∘̬ v) !! i ≡ v !! i sidfn {n = n} v i = begin ((upTo n) ∘̬ v) !! i ≡⟨ lookupTab {f = λ x → v !! ((upTo n) !! x)} i ⟩ v !! ((upTo n) !! i) ≡⟨ cong (_!!_ v) (lookupTab {f = id} i) ⟩ v !! i ∎ ∘̬simpleid : {A : Set} {n : ℕ} (v : Vec A n) → (upTo n) ∘̬ v ≡ v ∘̬simpleid {n = n} v = lookup∼vec (upTo n ∘̬ v) v (sidfn v) lookupMap : {A B : Set} → {n : ℕ} → {f : A → B} → (i : F.Fin n) → (v : Vec A n) → lookup i (vmap f v) ≡ f (lookup i v) lookupMap F.zero (x ∷ _) = refl lookupMap (F.suc i) (_ ∷ v) = lookupMap i v lookup∘tabulate : ∀ {a n} → {A : Set a} → (i : F.Fin n) → (f : F.Fin n → A) → lookup i (tabulate f) ≡ f i lookup∘tabulate F.zero f = refl lookup∘tabulate (F.suc i) f = lookup∘tabulate i (f ○ F.suc) vmap∘vmap : {n : ℕ} {A B C : Set} (f : B → C) (g : A → B) (v : Vec A n) → vmap f (vmap g v) ≡ vmap (f ○ g) v vmap∘vmap {zero} f g [] = refl vmap∘vmap {suc n} f g (x ∷ v) = cong (λ y → f (g x) ∷ y) (vmap∘vmap f g v) vmap∘id : {n : ℕ} {A : Set} {v : Vec A n} {f : A → A } → (∀ {x} → f x ≡ x) → vmap f v ≡ v vmap∘id {zero} {v = []} eq = refl vmap∘id {suc n} {v = (x ∷ v)} {f} eq = cong₂ _∷_ eq (vmap∘id {v = v} eq)
{ "alphanum_fraction": 0.4501075847, "avg_line_length": 36.4509803922, "ext": "agda", "hexsha": "31373b278160a89e2ac193ff2d7a4215107ca9a9", "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/VecHelpers.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/VecHelpers.agda", "max_line_length": 92, "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/VecHelpers.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": 3570, "size": 7436 }
open import Data.Unit open import Data.Product open import Relation.Binary.PropositionalEquality module Spire.Examples.ComputationalDesc where ---------------------------------------------------------------------- data Desc (I : Set) : Set₁ where `⊤ : Desc I `X : (i : I) → Desc I `Σ `Π : (A : Set) (B : A → Desc I) → Desc I El : (I : Set) (D : Desc I) (X : I → Set) → Set El I `⊤ X = ⊤ El I (`X i) X = X i El I (`Σ A B) X = Σ A (λ a → El I (B a) X) El I (`Π A B) X = (a : A) → El I (B a) X data μ (I : Set) (R : I → Desc I) (i : I) : Set where con : El I (R i) (μ I R) → μ I R i All : (I : Set) (X : I → Set) (D : Desc I) (xs : El I D X) (P : (i : I) → X i → Set) → Set All I X `⊤ tt P = ⊤ All I X (`X i) x P = P i x All I X (`Σ A B) (a , b) P = All I X (B a) b P All I X (`Π A B) f P = (a : A) → All I X (B a) (f a) P ---------------------------------------------------------------------- ind : (I : Set) (R : I → Desc I) (P : (i : I) → μ I R i → Set) (pcon : (i : I) (xs : El I (R i) (μ I R)) → All I (μ I R) (R i) xs P → P i (con xs)) (i : I) (x : μ I R i) → P i x hyps : (I : Set) (R : I → Desc I) (P : (i : I) → μ I R i → Set) (pcon : (i : I) (xs : El I (R i) (μ I R)) → All I (μ I R) (R i) xs P → P i (con xs)) (D : Desc I) (xs : El I D (μ I R)) → All I (μ I R) D xs P ind I R P pcon i (con xs) = pcon i xs (hyps I R P pcon (R i) xs) hyps I R P pcon `⊤ tt = tt hyps I R P pcon (`X i) xs = ind I R P pcon i xs hyps I R P pcon (`Σ A B) (a , b) = hyps I R P pcon (B a) b hyps I R P pcon (`Π A B) f = λ a → hyps I R P pcon (B a) (f a) ---------------------------------------------------------------------- data ℕT : Set where `zero `suc : ℕT data VecT : Set where `nil `cons : VecT ℕD : ⊤ → Desc ⊤ ℕD tt = `Σ ℕT λ { `zero → `⊤ ; `suc → `X tt } ℕ : ⊤ → Set ℕ = μ ⊤ ℕD -- zero : ℕ tt pattern zero = con (`zero , tt) -- suc : ℕ tt → ℕ tt pattern suc n = con (`suc , n) ---------------------------------------------------------------------- VecD : (A : Set) (n : ℕ tt) → Desc (ℕ tt) VecD A zero = `⊤ VecD A (suc n) = `Σ A λ _ → `X n Vec : (A : Set) (n : ℕ tt) → Set Vec A n = μ (ℕ tt) (VecD A) n nil : (A : Set) → Vec A zero nil A = con tt cons : (A : Set) (n : ℕ tt) (x : A) (xs : Vec A n) → Vec A (suc n) cons A n x xs = con (x , xs) ---------------------------------------------------------------------- add : ℕ tt → ℕ tt → ℕ tt add = ind ⊤ ℕD (λ _ _ → ℕ tt → ℕ tt) (λ { tt (`zero , tt) tt n → n ; tt (`suc , m) ih n → suc (ih n) } ) tt mult : ℕ tt → ℕ tt → ℕ tt mult = ind ⊤ ℕD (λ _ _ → ℕ tt → ℕ tt) (λ { tt (`zero , tt) tt n → zero ; tt (`suc , m) ih n → add n (ih n) } ) tt append : (A : Set) (m : ℕ tt) (xs : Vec A m) (n : ℕ tt) (ys : Vec A n) → Vec A (add m n) append A = ind (ℕ tt) (VecD A) (λ m xs → (n : ℕ tt) (ys : Vec A n) → Vec A (add m n)) (λ { zero tt tt n ys → ys ; (suc m) (x , xs) ih n ys → cons A (add m n) x (ih n ys) } ) concat : (A : Set) (m n : ℕ tt) (xss : Vec (Vec A m) n) → Vec A (mult n m) concat A m = ind (ℕ tt) (VecD (Vec A m)) (λ n xss → Vec A (mult n m)) (λ { zero tt tt → nil A ; (suc n) (xs , xss) ih → append A m xs (mult n m) ih } ) ----------------------------------------------------------------------
{ "alphanum_fraction": 0.4026845638, "avg_line_length": 25.811023622, "ext": "agda", "hexsha": "00ec185383828f55ac8432b9ed9d021170aee05b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-08-17T21:00:07.000Z", "max_forks_repo_forks_event_min_datetime": "2015-08-17T21:00:07.000Z", "max_forks_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "spire/spire", "max_forks_repo_path": "formalization/agda/Spire/Examples/ComputationalDesc.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353", "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": "spire/spire", "max_issues_repo_path": "formalization/agda/Spire/Examples/ComputationalDesc.agda", "max_line_length": 90, "max_stars_count": 43, "max_stars_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "spire/spire", "max_stars_repo_path": "formalization/agda/Spire/Examples/ComputationalDesc.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T17:10:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-28T23:25:33.000Z", "num_tokens": 1362, "size": 3278 }
{-# OPTIONS --sized-types #-} open import Relation.Binary.Core module BBHeap.Height.Log {A : Set} (_≤_ : A → A → Set) (tot≤ : Total _≤_ ) where open import BBHeap _≤_ hiding (#) open import BBHeap.Height _≤_ open import BBHeap.Properties _≤_ open import Bound.Lower A open import Data.Sum renaming (_⊎_ to _∨_) open import SNat open import SNat.Log open import SNat.Order open import SNat.Order.Properties open import SNat.Properties open import SNat.Sum open import Relation.Binary.PropositionalEquality lemma-height-≃ : {b b' : Bound}{l : BBHeap b}{r : BBHeap b'} → l ≃ r → height l ≡ height r lemma-height-≃ ≃lf = refl lemma-height-≃ (≃nd _ _ _ _ _ _ l≃l') rewrite lemma-height-≃ l≃l' = refl lemma-height'-≃ : {b b' : Bound}{l : BBHeap b}{r : BBHeap b'} → l ≃ r → height' l ≡ height' r lemma-height'-≃ ≃lf = refl lemma-height'-≃ (≃nd _ _ _ _ l≃r l'≃r' l≃l') rewrite lemma-height'-≃ (trans≃ (trans≃ (sym≃ l≃r) l≃l') l'≃r') = refl lemma-height-height'-⋗ : {b b' : Bound}{l : BBHeap b}{r : BBHeap b'} → l ⋗ r → height l ≡ succ (height' r) lemma-height-height'-⋗ (⋗lf _) = refl lemma-height-height'-⋗ (⋗nd _ _ _ _ _ l'≃r' l⋗l') rewrite lemma-height-height'-⋗ l⋗l' | lemma-height'-≃ l'≃r' = refl lemma-height-height'-⋘ : {b b' : Bound}{l : BBHeap b}{r : BBHeap b'} → l ⋘ r → height l ≡ height' r ∨ height l ≡ succ (height' r) lemma-height-height'-⋘ lf⋘ = inj₁ refl lemma-height-height'-⋘ (ll⋘ _ _ l⋘r _ l'≃r' r≃l') with lemma-height-height'-⋘ l⋘r ... | inj₁ hl≡h'r rewrite hl≡h'r | lemma-height'-≃ (trans≃ r≃l' l'≃r') = inj₁ refl ... | inj₂ hl≡h'r+1 rewrite hl≡h'r+1 | lemma-height'-≃ (trans≃ r≃l' l'≃r') = inj₂ refl lemma-height-height'-⋘ (lr⋘ _ _ _ _ l'≃r' l⋗l') rewrite lemma-height-height'-⋗ (lemma⋗≃ l⋗l' l'≃r')= inj₂ refl lemma-height-height'-⋙ : {b b' : Bound}{l : BBHeap b}{r : BBHeap b'} → l ⋙ r → height l ≡ height' r ∨ height l ≡ succ (height' r) lemma-height-height'-⋙ (⋙lf _) = inj₂ refl lemma-height-height'-⋙ (⋙rl _ _ _ _ _ l⋗r') rewrite lemma-height-height'-⋗ l⋗r' = inj₂ refl lemma-height-height'-⋙ (⋙rr _ _ _ _ l'⋙r' l≃l') with lemma-height-height'-⋙ l'⋙r' ... | inj₁ hl'≡h'r' rewrite lemma-height-≃ l≃l' | hl'≡h'r' = inj₁ refl ... | inj₂ hl'≡h'r'+1 rewrite lemma-height-≃ l≃l' | hl'≡h'r'+1 = inj₂ refl lemma-height-height' : {b : Bound}(h : BBHeap b) → height h ≡ height' h ∨ height h ≡ succ (height' h) lemma-height-height' leaf = inj₁ refl lemma-height-height' (left _ l⋘r) with lemma-height-height'-⋘ l⋘r ... | inj₁ hl≡h'r rewrite hl≡h'r = inj₁ refl ... | inj₂ hl≡h'r+1 rewrite hl≡h'r+1 = inj₂ refl lemma-height-height' (right _ l⋙r) with lemma-height-height'-⋙ l⋙r ... | inj₁ hl≡h'r rewrite hl≡h'r = inj₁ refl ... | inj₂ hl≡h'r+1 rewrite hl≡h'r+1 = inj₂ refl lemma-#-≃ : {b b' : Bound}{l : BBHeap b}{r : BBHeap b'} → l ≃ r → # l ≡ # r lemma-#-≃ ≃lf = refl lemma-#-≃ (≃nd _ _ _ _ l≃r l'≃r' l≃l') rewrite lemma-#-≃ (sym≃ l≃r) | lemma-#-≃ l≃l' | lemma-#-≃ l'≃r' = refl lemma-#-⋗ : {b b' : Bound}{l : BBHeap b}{r : BBHeap b'} → l ⋗ r → # l ≡ succ (# r + # r) lemma-#-⋗ (⋗lf _) = refl lemma-#-⋗ (⋗nd _ _ _ _ l≃r l'≃r' l⋗l') rewrite lemma-#-≃ (sym≃ l≃r) | lemma-#-⋗ l⋗l' | lemma-#-≃ l'≃r' = refl lemma-⋘-# : {b b' : Bound}{l : BBHeap b}{r : BBHeap b'} → l ⋘ r → # r ≤′ # l lemma-⋘-# lf⋘ = refl≤′ lemma-⋘-# (ll⋘ {r' = r'} _ _ l⋘r _ l'≃r' r≃l') rewrite lemma-#-≃ r≃l' | lemma-#-≃ l'≃r' = lemma-s≤′s (+-right-monotony-≤′ (# r') (lemma-≡-≤′ (lemma-#-≃ (sym≃ (trans≃ r≃l' l'≃r'))) (lemma-⋘-# l⋘r))) lemma-⋘-# (lr⋘ {r = r} {r' = r'} _ _ _ _ l'≃r' l⋗l') rewrite lemma-#-⋗ l⋗l' | lemma-#-≃ l'≃r' = lemma-s≤′s (≤′-step (lemma-m≤′m+n (# r' + # r') (# r))) lemma-#-⋙ : {b b' : Bound}{l : BBHeap b}{r : BBHeap b'} → l ⋙ r → # l ≤′ succ (# r + # r) lemma-#-⋙ (⋙lf _) = refl≤′ lemma-#-⋙ (⋙rl {l' = l'}{r' = r'} _ _ _ l≃r l'⋘r' l⋗r') rewrite lemma-#-≃ (sym≃ l≃r) | lemma-#-⋗ l⋗r' | +-assoc-succ (# r' + # r') (# r' + # r') | +-assoc-succ (# l' + # r') (# l' + # r') = lemma-s≤′s (lemma-s≤′s (lemma-s≤′s (lemma-4m≤′n+m+n+m (lemma-⋘-# l'⋘r')))) lemma-#-⋙ (⋙rr {l' = l'} {r' = r'} _ _ _ l≃r _ l≃l') rewrite lemma-#-≃ (sym≃ l≃r) | lemma-#-≃ l≃l' | +-assoc-succ (# l' + # r') (# l' + # r') = lemma-s≤′s (≤′-step (≤′-step (lemma-2m≤′m+n+m+n (# l') (# r')))) mutual lemma-⋙-# : {b b' : Bound}{l : BBHeap b}{r : BBHeap b'} → l ⋙ r → # r ≤′ # l lemma-⋙-# (⋙lf _) = ≤′-step refl≤′ lemma-⋙-# (⋙rl {r' = r'} _ _ _ l≃r l'⋘r' l⋗r') rewrite lemma-#-≃ (sym≃ l≃r) | lemma-#-⋗ l⋗r' = lemma-s≤′s (trans≤′ (+-right-monotony-≤′ (# r') (lemma-#-⋘ l'⋘r')) (lemma-s≤′s (+-left-monotony-≤′ (# r' + # r') (≤′-step (lemma-n≤′2n (# r')))))) lemma-⋙-# (⋙rr {l' = l'} {r' = r'} _ _ _ l≃r l'⋙r' l≃l') rewrite lemma-#-≃ (sym≃ l≃r) | lemma-#-≃ l≃l' | +-comm (# l') (# r') = lemma-s≤′s (+-right-monotony-≤′ (# l') (lemma-⋙-# l'⋙r')) lemma-#-⋘ : {b b' : Bound}{l : BBHeap b}{r : BBHeap b'} → l ⋘ r → # l ≤′ succ (# r + # r) lemma-#-⋘ lf⋘ = ≤′-step refl≤′ lemma-#-⋘ (ll⋘ {r = r} _ _ l⋘r _ l'≃r' r≃l') rewrite lemma-#-≃ (sym≃ l'≃r') | lemma-#-≃ (sym≃ r≃l') | +-assoc-succ (# r + # r) (# r + # r) | +-assoc-left (# r + # r) (# r) (# r) = lemma-s≤′s (≤′-step (trans≤′ (+-right-monotony-≤′ (# r) (lemma-#-⋘ l⋘r)) (lemma-s≤′s (lemma-m≤′m+n ((# r + # r) + # r) (# r))))) lemma-#-⋘ (lr⋘ {r' = r'} _ _ l⋙r _ l'≃r' l⋗l') rewrite lemma-#-⋗ l⋗l' | lemma-#-≃ l'≃r' = lemma-s≤′s (lemma-s≤′s (+-left-monotony-≤′ (# r' + # r') (trans≤′ (lemma-⋙-# l⋙r) (lemma-≡-≤′ (lemma-#-⋗ (lemma⋗≃ l⋗l' l'≃r')) refl≤′)))) lemma-#-#' : {b : Bound}(h : BBHeap b) → #' h ≤′ # h lemma-#-#' leaf = refl≤′ lemma-#-#' (left {r = r} _ l⋘r) = lemma-s≤′s (trans≤′ (lemma-2m≤′2n (lemma-#-#' r)) (+-right-monotony-≤′ (# r) (lemma-⋘-# l⋘r))) lemma-#-#' (right {r = r} _ l⋙r) = lemma-s≤′s (trans≤′ (lemma-2m≤′2n (lemma-#-#' r)) (+-right-monotony-≤′ (# r) (lemma-⋙-# l⋙r))) lemma-height'-#' : {b : Bound}(h : BBHeap b) → height' h ≤′ log₂ (#' h + #' h) lemma-height'-#' leaf = refl≤′ lemma-height'-#' (left {r = r} _ _) = trans≤′ (lemma-s≤′s (trans≤′ (lemma-height'-#' r) (lemma-≤′-log (≤′-step (refl≤′ {#' r + #' r}))))) (lemma-1+logn≤′log2n (#' r + #' r)) lemma-height'-#' (right {r = r} _ _) = trans≤′ (lemma-s≤′s (trans≤′ (lemma-height'-#' r) (lemma-≤′-log (≤′-step (refl≤′ {#' r + #' r}))))) (lemma-1+logn≤′log2n (#' r + #' r)) lemma-height'-# : {b : Bound}(h : BBHeap b) → height' h ≤′ succ (log₂ (# h)) lemma-height'-# h = trans≤′ (trans≤′ (lemma-height'-#' h) (lemma-log2n≤′1+logn (#' h))) (lemma-s≤′s (lemma-≤′-log (lemma-#-#' h))) theorem-height-# : {b : Bound}(h : BBHeap b) → height h ≤′ succ (succ (log₂ (# h))) theorem-height-# h with lemma-height-height' h ... | inj₁ hh≡h'h rewrite hh≡h'h = ≤′-step (lemma-height'-# h) ... | inj₂ hh≡h'h+1 rewrite hh≡h'h+1 = lemma-s≤′s (lemma-height'-# h)
{ "alphanum_fraction": 0.4670938459, "avg_line_length": 54.6788321168, "ext": "agda", "hexsha": "3c278cb001de3eccf4ebd589f8f8de4d899f5a53", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/BBHeap/Height/Log.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/BBHeap/Height/Log.agda", "max_line_length": 198, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/BBHeap/Height/Log.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 3443, "size": 7491 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.types.Sigma open import lib.types.Pi open import lib.types.Paths open import lib.types.Unit open import lib.types.Empty module lib.Equivalence2 where {- Pre- and post- composition with equivalences are equivalences -} module _ {i j k} {A : Type i} {B : Type j} {C : Type k} {h : A → B} (e : is-equiv h) where pre∘-is-equiv : is-equiv (λ (k : B → C) → k ∘ h) pre∘-is-equiv = is-eq f g f-g g-f where f = _∘ h g = _∘ is-equiv.g e f-g = λ k → ap (k ∘_) (λ= $ is-equiv.g-f e) g-f = λ k → ap (k ∘_) (λ= $ is-equiv.f-g e) post∘-is-equiv : is-equiv (λ (k : C → A) → h ∘ k) post∘-is-equiv = is-eq f g f-g g-f where f = h ∘_ g = is-equiv.g e ∘_ f-g = λ k → ap (_∘ k) (λ= $ is-equiv.f-g e) g-f = λ k → ap (_∘ k) (λ= $ is-equiv.g-f e) {- The same thing on the abstraction level of equivalences -} module _ {i j k} {A : Type i} {B : Type j} {C : Type k} (e : A ≃ B) where pre∘-equiv : (B → C) ≃ (A → C) pre∘-equiv = (_ , pre∘-is-equiv (snd e)) post∘-equiv : (C → A) ≃ (C → B) post∘-equiv = (_ , post∘-is-equiv (snd e)) is-contr-map : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) → Type (lmax i j) is-contr-map {A = A} {B = B} f = (y : B) → is-contr (hfiber f y) equiv-is-contr-map : ∀ {i j} {A : Type i} {B : Type j} {f : A → B} → (is-equiv f → is-contr-map f) equiv-is-contr-map e y = equiv-preserves-level (Σ-emap-l (_== y) (_ , e) ⁻¹) (pathto-is-contr y) contr-map-is-equiv : ∀ {i j} {A : Type i} {B : Type j} {f : A → B} → (is-contr-map f → is-equiv f) contr-map-is-equiv {f = f} cm = is-eq _ (λ b → fst (fst (cm b))) (λ b → snd (fst (cm b))) (λ a → ap fst (snd (cm (f a)) (a , idp))) fiber=-econv : ∀ {i j} {A : Type i} {B : Type j} {h : A → B} {y : B} (r s : Σ A (λ x → h x == y)) → (r == s) ≃ Σ (fst r == fst s) (λ γ → ap h γ ∙ snd s == snd r) fiber=-econv r s = Σ-emap-r (λ γ → !-equiv ∘e (↓-app=cst-econv ⁻¹)) ∘e ((=Σ-econv r s)⁻¹) module _ {i j} {A : Type i} {B : Type j} where linv : (A → B) → Type (lmax i j) linv f = Σ (B → A) (λ g → (∀ x → g (f x) == x)) rinv : (A → B) → Type (lmax i j) rinv f = Σ (B → A) (λ g → (∀ y → f (g y) == y)) lcoh : (f : A → B) → linv f → Type (lmax i j) lcoh f (g , g-f) = Σ (∀ y → f (g y) == y) (λ f-g → ∀ y → ap g (f-g y) == g-f (g y)) rcoh : (f : A → B) → rinv f → Type (lmax i j) rcoh f (g , f-g) = Σ (∀ x → g (f x) == x) (λ g-f → ∀ x → ap f (g-f x) == f-g (f x)) module _ {i j} {A : Type i} {B : Type j} {f : A → B} (e : is-equiv f) where equiv-linv-is-contr : is-contr (linv f) equiv-linv-is-contr = equiv-preserves-level (Σ-emap-r λ _ → λ=-equiv ⁻¹) (equiv-is-contr-map (pre∘-is-equiv e) (idf A)) equiv-rinv-is-contr : is-contr (rinv f) equiv-rinv-is-contr = equiv-preserves-level (Σ-emap-r λ _ → λ=-equiv ⁻¹) (equiv-is-contr-map (post∘-is-equiv e) (idf B)) module _ {i j} {A : Type i} {B : Type j} {f : A → B} where rcoh-econv : (v : rinv f) → rcoh f v ≃ Π A (λ x → (fst v (f x) , snd v (f x)) == (x , idp {a = f x})) rcoh-econv v = Π-emap-r (λ x → ((fiber=-econv {h = f} _ _)⁻¹) ∘e apply-unit-r x) ∘e choice ⁻¹ where apply-unit-r : ∀ x → Σ _ (λ γ → ap f γ == _) ≃ Σ _ (λ γ → ap f γ ∙ idp == _) apply-unit-r x = Σ-emap-r λ γ → coe-equiv (ap (λ q → q == snd v (f x)) (! (∙-unit-r _))) lcoh-econv : (v : linv f) → lcoh f v ≃ Π B (λ y → (f (fst v y) , snd v (fst v y)) == (y , idp)) lcoh-econv v = Π-emap-r (λ y → ((fiber=-econv {h = fst v} _ _)⁻¹) ∘e apply-unit-r y) ∘e choice ⁻¹ where apply-unit-r : ∀ y → Σ _ (λ γ → ap (fst v) γ == _) ≃ Σ _ (λ γ → ap (fst v) γ ∙ idp == _) apply-unit-r y = Σ-emap-r λ γ → coe-equiv (ap (λ q → q == snd v (fst v y)) (! (∙-unit-r _))) equiv-rcoh-is-contr : ∀ {i j} {A : Type i} {B : Type j} {f : A → B} (e : is-equiv f) → (v : rinv f) → is-contr (rcoh f v) equiv-rcoh-is-contr {f = f} e v = equiv-preserves-level ((rcoh-econv v)⁻¹) (Π-level (λ x → =-preserves-level (equiv-is-contr-map e (f x)))) rinv-and-rcoh-is-equiv : ∀ {i j} {A : Type i} {B : Type j} {h : A → B} → Σ (rinv h) (rcoh h) ≃ is-equiv h rinv-and-rcoh-is-equiv {h = h} = equiv f g (λ _ → idp) (λ _ → idp) where f : Σ (rinv h) (rcoh h) → is-equiv h f s = record {g = fst (fst s); f-g = snd (fst s); g-f = fst (snd s); adj = snd (snd s)} g : is-equiv h → Σ (rinv h) (rcoh h) g t = ((is-equiv.g t , is-equiv.f-g t) , (is-equiv.g-f t , is-equiv.adj t)) is-equiv-is-prop : ∀ {i j} {A : Type i} {B : Type j} {f : A → B} → is-prop (is-equiv f) is-equiv-is-prop = inhab-to-contr-is-prop λ e → equiv-preserves-level rinv-and-rcoh-is-equiv (Σ-level (equiv-rinv-is-contr e) (equiv-rcoh-is-contr e)) is-equiv-prop : ∀ {i j} {A : Type i} {B : Type j} → SubtypeProp (A → B) (lmax i j) is-equiv-prop = is-equiv , λ f → is-equiv-is-prop ∘e-unit-r : ∀ {i} {A B : Type i} (e : A ≃ B) → (e ∘e ide A) == e ∘e-unit-r e = pair= idp (prop-has-all-paths is-equiv-is-prop _ _) ua-∘e : ∀ {i} {A B : Type i} (e₁ : A ≃ B) {C : Type i} (e₂ : B ≃ C) → ua (e₂ ∘e e₁) == ua e₁ ∙ ua e₂ ua-∘e = equiv-induction (λ {A} {B} e₁ → ∀ {C} → ∀ (e₂ : B ≃ C) → ua (e₂ ∘e e₁) == ua e₁ ∙ ua e₂) (λ A → λ e₂ → ap ua (∘e-unit-r e₂) ∙ ap (λ w → (w ∙ ua e₂)) (! (ua-η idp))) {- Not sure about the interface. {- Adjointion where hom = path -} module _ {i j} {A : Type i} {B : Type j} (e : A ≃ B) where =-adjunct : ∀ {a b} → (–> e a == b) → (a == <– e b) =-adjunct p = ! (<–-inv-l e _) ∙ ap (<– e) p =-adjunct' : ∀ {a b} → (a == <– e b) → (–> e a == b) =-adjunct' p = ap (–> e) p ∙ (<–-inv-r e _) -} {- Type former equivalences involving Empty may require λ=. -} module _ {j} {B : Empty → Type j} where Σ₁-Empty : Σ Empty B ≃ Empty Σ₁-Empty = equiv (⊥-rec ∘ fst) ⊥-rec ⊥-elim (⊥-rec ∘ fst) Π₁-Empty : Π Empty B ≃ Unit Π₁-Empty = equiv (cst tt) (cst ⊥-elim) (λ _ → contr-has-all-paths Unit-is-contr _ _) (λ _ → λ= ⊥-elim) Σ₂-Empty : ∀ {i} {A : Type i} → Σ A (λ _ → Empty) ≃ Empty Σ₂-Empty = equiv (⊥-rec ∘ snd) ⊥-rec ⊥-elim (⊥-rec ∘ snd) {- Fiberwise equivalence -} module _ {i j k} {A : Type i} {P : A → Type j} {Q : A → Type k} (f : ∀ x → P x → Q x) where private f-tot : Σ A P → Σ A Q f-tot (x , y) = x , f x y fiber-equiv-is-total-equiv : (∀ x → is-equiv (f x)) → is-equiv f-tot fiber-equiv-is-total-equiv f-ise = is-eq _ from to-from from-to where from : Σ A Q → Σ A P from (x , y) = x , is-equiv.g (f-ise x) y abstract to-from : ∀ q → f-tot (from q) == q to-from (x , q) = pair= idp (is-equiv.f-g (f-ise x) q) from-to : ∀ p → from (f-tot p) == p from-to (x , p) = pair= idp (is-equiv.g-f (f-ise x) p) total-equiv-is-fiber-equiv : is-equiv f-tot → (∀ x → is-equiv (f x)) total-equiv-is-fiber-equiv f-tot-ise x = is-eq _ from to-from from-to where module f-tot = is-equiv f-tot-ise from : Q x → P x from q = transport P (fst= (f-tot.f-g (x , q))) (snd (f-tot.g (x , q))) abstract from-lemma : ∀ q → snd (f-tot.g (x , q)) == from q [ P ↓ fst= (f-tot.f-g (x , q)) ] from-lemma q = from-transp P (fst= (f-tot.f-g (x , q))) idp to-from : ∀ q → f x (from q) == q to-from q = transport (λ path → f x (from q) == q [ Q ↓ path ]) (!-inv-l (fst= (f-tot.f-g (x , q)))) (!ᵈ (ap↓ (λ {x} → f x) (from-lemma q)) ∙ᵈ snd= (f-tot.f-g (x , q))) from-to : ∀ p → from (f x p) == p from-to p = transport (λ path → from (f x p) == p [ P ↓ path ]) ( ap (λ path → ! path ∙ fst= (f-tot.g-f (x , p))) (ap fst= (! (f-tot.adj (x , p))) ∙ ∘-ap fst f-tot (f-tot.g-f (x , p))) ∙ !-inv-l (fst= (f-tot.g-f (x , p)))) (!ᵈ (from-lemma (f x p)) ∙ᵈ snd= (f-tot.g-f (x , p)))
{ "alphanum_fraction": 0.4816290945, "avg_line_length": 37.5186915888, "ext": "agda", "hexsha": "0ac516c9fb0e0e4ac762f21f91d1e9d75b6d2f10", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "core/lib/Equivalence2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "core/lib/Equivalence2.agda", "max_line_length": 104, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "core/lib/Equivalence2.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3368, "size": 8029 }
-- This file defines instances for natural numbers and integers to -- overload various operations. {-# OPTIONS --without-K --safe #-} module Instances where -- imports from stdlib. import Data.Nat as Nat import Data.Integer as Int import Data.Integer.DivMod as IDM import Data.Nat.DivMod as NDM -- imports from local. open import Typeclasses public -- Natural numbers form a semiring. instance SMℕ : SemiRing Nat.ℕ SMℕ ._+_ = Nat._+_ SMℕ ._*_ = Nat._*_ SMℕ .0# = 0 SMℕ .1# = 1 -- Integers form a semiring. instance SMℤ : SemiRing Int.ℤ SMℤ ._+_ = Int._+_ SMℤ ._*_ = Int._*_ SMℤ .0# = Int.0ℤ SMℤ .1# = Int.1ℤ -- The set of intergers is a ring. instance Ringℤ : Ring Int.ℤ Ringℤ .sra = SMℤ Ringℤ .-_ = Int.-_ -- The usual order on ℕ is decidable. instance DOℕ : DecOrd Nat.ℕ DOℕ ._≤_ = Nat._≤_ DOℕ ._≤?_ = Nat._≤?_ DOℕ ._<_ = Nat._<_ DOℕ ._<?_ = Nat._<?_ -- The usual order on ℤ is decidable. instance DOℤ : DecOrd Int.ℤ DOℤ ._≤_ = Int._≤_ DOℤ ._≤?_ = Int._≤?_ DOℤ ._<_ = Int._<_ DOℤ ._<?_ = Int._<?_ -- ℕ has NonZero stucture on it defined in Data.Nat.Base. instance NZTℕ : NonZeroTypeclass Nat.ℕ NZTℕ .NonZero = Nat.NonZero -- ℤ has NonZero stucture on it defined in Data.Integer.Base. NZTℤ : NonZeroTypeclass Int.ℤ NZTℤ .NonZero = Int.NonZero -- div and mod function on ℕ. They are defined in Data.Nat.DivMod. instance DMℕ : DivMod Nat.ℕ DMℕ .NZT = NZTℕ DMℕ ._/_ = NDM._/_ DMℕ ._%_ = NDM._%_ -- div and mod function on ℤ. They are defined in Data.Integer.DivMod. instance DMℤ : DivMod Int.ℤ DMℤ .NZT = NZTℤ DMℤ ._/_ = IDM._div_ DMℤ ._%_ n d = Int.+ (n IDM.mod d) -- Identity function can be used as the rank function. instance Rankℕ : Rank Nat.ℕ Rankℕ .rank x = x -- Absolute value function can be used as the rank function. instance Rankℤ : Rank Int.ℤ Rankℤ .rank = Int.∣_∣
{ "alphanum_fraction": 0.6480799579, "avg_line_length": 21.8505747126, "ext": "agda", "hexsha": "e23be1bd88f8fe3cc5e13e107692ec4b21ec7a31", "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": "7e268e8354065fde734c9c2d9998d2cfd4a21f71", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "onestruggler/EucDomain", "max_forks_repo_path": "Instances.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7e268e8354065fde734c9c2d9998d2cfd4a21f71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "onestruggler/EucDomain", "max_issues_repo_path": "Instances.agda", "max_line_length": 70, "max_stars_count": null, "max_stars_repo_head_hexsha": "7e268e8354065fde734c9c2d9998d2cfd4a21f71", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "onestruggler/EucDomain", "max_stars_repo_path": "Instances.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 742, "size": 1901 }
{-# OPTIONS --safe #-} module Cubical.Algebra.Group.Instances.Unit where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Structure open import Cubical.Foundations.HLevels open import Cubical.Foundations.Equiv open import Cubical.Data.Unit renaming (Unit to UnitType) open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Group.DirProd open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Algebra.Group.GroupPath open GroupStr open IsGroupHom private variable ℓ : Level Unit : Group₀ Unit = UnitType , groupstr tt (λ _ _ → tt) (λ _ → tt) (makeIsGroup isSetUnit (λ _ _ _ → refl) (λ _ → refl) (λ _ → refl) (λ _ → refl) (λ _ → refl)) open Iso -- The trivial group is a unit. lUnitGroupIso : {G : Group ℓ} → GroupIso (DirProd Unit G) G fun (fst lUnitGroupIso) = snd inv (fst lUnitGroupIso) g = tt , g rightInv (fst lUnitGroupIso) _ = refl leftInv (fst lUnitGroupIso) _ = refl snd lUnitGroupIso = makeIsGroupHom λ _ _ → refl rUnitGroupIso : {G : Group ℓ} → GroupIso (DirProd G Unit) G fun (fst rUnitGroupIso) = fst inv (fst rUnitGroupIso) g = g , tt rightInv (fst rUnitGroupIso) _ = refl leftInv (fst rUnitGroupIso) _ = refl snd rUnitGroupIso = makeIsGroupHom λ _ _ → refl lUnitGroupEquiv : {G : Group ℓ} → GroupEquiv (DirProd Unit G) G lUnitGroupEquiv = GroupIso→GroupEquiv lUnitGroupIso rUnitGroupEquiv : ∀ {ℓ} {G : Group ℓ} → GroupEquiv (DirProd G Unit) G rUnitGroupEquiv = GroupIso→GroupEquiv rUnitGroupIso contrGroupIsoUnit : {G : Group ℓ} → isContr ⟨ G ⟩ → GroupIso G Unit fun (fst (contrGroupIsoUnit contr)) _ = tt inv (fst (contrGroupIsoUnit contr)) _ = fst contr rightInv (fst (contrGroupIsoUnit contr)) _ = refl leftInv (fst (contrGroupIsoUnit contr)) x = snd contr x snd (contrGroupIsoUnit contr) = makeIsGroupHom λ _ _ → refl contrGroupEquivUnit : {G : Group ℓ} → isContr ⟨ G ⟩ → GroupEquiv G Unit contrGroupEquivUnit contr = GroupIso→GroupEquiv (contrGroupIsoUnit contr) isContr→≡UnitGroup : {G : Group ℓ-zero} → isContr (fst G) → Unit ≡ G isContr→≡UnitGroup c = fst (GroupPath _ _) (invGroupEquiv ((isContr→≃Unit c) , (makeIsGroupHom (λ _ _ → refl)))) GroupIsoUnitGroup→isContr : {G : Group ℓ-zero} → GroupIso Unit G → isContr (fst G) GroupIsoUnitGroup→isContr is = isOfHLevelRetractFromIso 0 (invIso (fst is)) isContrUnit
{ "alphanum_fraction": 0.7137724551, "avg_line_length": 35.2816901408, "ext": "agda", "hexsha": "daf64d93082aa4001577508279e0e771e0b807c6", "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": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "FernandoLarrain/cubical", "max_forks_repo_path": "Cubical/Algebra/Group/Instances/Unit.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "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": "FernandoLarrain/cubical", "max_issues_repo_path": "Cubical/Algebra/Group/Instances/Unit.agda", "max_line_length": 87, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "FernandoLarrain/cubical", "max_stars_repo_path": "Cubical/Algebra/Group/Instances/Unit.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T21:49:23.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-05T21:49:23.000Z", "num_tokens": 786, "size": 2505 }