Search is not available for this dataset
text
string
meta
dict
{-# OPTIONS --cubical #-} open import Agda.Primitive.Cubical
{ "alphanum_fraction": 0.7096774194, "avg_line_length": 15.5, "ext": "agda", "hexsha": "5b72644777bd2aed59e8c05de0c4f81149754e33", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Compiler/simple/Cubical-primitives-are-not-supported.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Compiler/simple/Cubical-primitives-are-not-supported.agda", "max_line_length": 34, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Compiler/simple/Cubical-primitives-are-not-supported.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": 17, "size": 62 }
-- Andreas, 2016-09-08, issue #2167 reported by effectfully loop : Set₁ loop = .Set -- WAS: looping of type checker -- NOW: proper error about invalid dotted expression
{ "alphanum_fraction": 0.730994152, "avg_line_length": 21.375, "ext": "agda", "hexsha": "21c48cabcf3e4af0a7d67d73be8ab35bfdb22b46", "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/Issue2167.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/Issue2167.agda", "max_line_length": 59, "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/Issue2167.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": 48, "size": 171 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Category.Cartesian.Properties {o ℓ e} (C : Category o ℓ e) where open import Level using (_⊔_) open import Function using (_$_) open import Data.Nat using (ℕ; zero; suc) open import Data.Product using (Σ; _,_; proj₁) renaming (_×_ to _&_) open import Data.Product.Properties open import Data.List as List open import Data.List.Relation.Unary.Any as Any using (here; there) open import Data.List.Relation.Unary.Any.Properties open import Data.List.Membership.Propositional open import Data.Vec as Vec using (Vec; []; _∷_) open import Data.Vec.Relation.Unary.Any as AnyV using (here; there) open import Data.Vec.Relation.Unary.Any.Properties open import Data.Vec.Membership.Propositional renaming (_∈_ to _∈ᵥ_) open import Relation.Binary using (Rel) open import Relation.Binary.PropositionalEquality as ≡ using (refl; _≡_) import Data.List.Membership.Propositional.Properties as ∈ₚ import Data.Vec.Membership.Propositional.Properties as ∈ᵥₚ open import Categories.Category.Cartesian C open import Categories.Diagram.Pullback C open import Categories.Diagram.Equalizer C open import Categories.Morphism.Reasoning C private open Category C open HomReasoning variable A B X Y : Obj f g : A ⇒ B -- all binary products and pullbacks implies equalizers module _ (prods : BinaryProducts) (pullbacks : ∀ {A B X} (f : A ⇒ X) (g : B ⇒ X) → Pullback f g) where open BinaryProducts prods open HomReasoning prods×pullbacks⇒equalizers : Equalizer f g prods×pullbacks⇒equalizers {f = f} {g = g} = record { arr = pb′.p₁ ; equality = begin f ∘ pb′.p₁ ≈⟨ refl⟩∘⟨ helper₁ ⟩ f ∘ pb.p₁ ∘ pb′.p₂ ≈⟨ pullˡ pb.commute ⟩ (g ∘ pb.p₂) ∘ pb′.p₂ ≈˘⟨ pushʳ helper₂ ⟩ g ∘ pb′.p₁ ∎ ; equalize = λ {_ i} eq → pb′.universal $ begin ⟨ id , id ⟩ ∘ i ≈⟨ ⟨⟩∘ ⟩ ⟨ id ∘ i , id ∘ i ⟩ ≈⟨ ⟨⟩-cong₂ identityˡ identityˡ ⟩ ⟨ i , i ⟩ ≈˘⟨ ⟨⟩-cong₂ pb.p₁∘universal≈h₁ pb.p₂∘universal≈h₂ ⟩ ⟨ pb.p₁ ∘ pb.universal eq , pb.p₂ ∘ pb.universal eq ⟩ ≈˘⟨ ⟨⟩∘ ⟩ h ∘ pb.universal eq ∎ ; universal = ⟺ pb′.p₁∘universal≈h₁ ; unique = λ eq → pb′.unique (⟺ eq) (pb.unique (pullˡ (⟺ helper₁) ○ ⟺ eq) (pullˡ (⟺ helper₂) ○ ⟺ eq)) } where pb : Pullback f g pb = pullbacks _ _ module pb = Pullback pb h = ⟨ pb.p₁ , pb.p₂ ⟩ pb′ : Pullback ⟨ id , id ⟩ h pb′ = pullbacks _ _ module pb′ = Pullback pb′ helper₁ : pb′.p₁ ≈ pb.p₁ ∘ pb′.p₂ helper₁ = begin pb′.p₁ ≈˘⟨ cancelˡ project₁ ⟩ π₁ ∘ ⟨ id , id ⟩ ∘ pb′.p₁ ≈⟨ refl⟩∘⟨ pb′.commute ⟩ π₁ ∘ h ∘ pb′.p₂ ≈⟨ pullˡ project₁ ⟩ pb.p₁ ∘ pb′.p₂ ∎ helper₂ : pb′.p₁ ≈ pb.p₂ ∘ pb′.p₂ helper₂ = begin pb′.p₁ ≈˘⟨ cancelˡ project₂ ⟩ π₂ ∘ ⟨ id , id ⟩ ∘ pb′.p₁ ≈⟨ refl⟩∘⟨ pb′.commute ⟩ π₂ ∘ h ∘ pb′.p₂ ≈⟨ pullˡ project₂ ⟩ pb.p₂ ∘ pb′.p₂ ∎ module Prods (car : Cartesian) where open Cartesian car -- for lists prod : List Obj → Obj prod objs = foldr _×_ ⊤ objs π[_] : ∀ {x xs} → x ∈ xs → prod xs ⇒ x π[ here refl ] = π₁ π[ there x∈xs ] = π[ x∈xs ] ∘ π₂ data _⇒_* : Obj → List Obj → Set (o ⊔ ℓ) where _~[] : ∀ x → x ⇒ [] * _∷_ : ∀ {x y ys} → x ⇒ y → x ⇒ ys * → x ⇒ y ∷ ys * ⟨_⟩* : ∀ {x ys} (fs : x ⇒ ys *) → x ⇒ prod ys ⟨ x ~[] ⟩* = ! ⟨ f ∷ fs ⟩* = ⟨ f , ⟨ fs ⟩* ⟩ ∈⇒mor : ∀ {x y ys} (fs : x ⇒ ys *) (y∈ys : y ∈ ys) → x ⇒ y ∈⇒mor (x ~[]) () ∈⇒mor (f ∷ fs) (here refl) = f ∈⇒mor (f ∷ fs) (there y∈ys) = ∈⇒mor fs y∈ys project* : ∀ {x y ys} (fs : x ⇒ ys *) (y∈ys : y ∈ ys) → π[ y∈ys ] ∘ ⟨ fs ⟩* ≈ ∈⇒mor fs y∈ys project* (x ~[]) () project* (f ∷ fs) (here refl) = project₁ project* (f ∷ fs) (there y∈ys) = pullʳ project₂ ○ project* fs y∈ys uniqueness* : ∀ {x ys} {g h : x ⇒ prod ys} → (∀ {y} (y∈ys : y ∈ ys) → π[ y∈ys ] ∘ g ≈ π[ y∈ys ] ∘ h) → g ≈ h uniqueness* {x} {[]} uni = !-unique₂ uniqueness* {x} {y ∷ ys} uni = unique′ (uni (here ≡.refl)) (uniqueness* λ y∈ys → sym-assoc ○ uni (there y∈ys) ○ assoc) module _ {a} {A : Set a} (f : A → Obj) where uniqueness*′ : ∀ {x ys} {g h : x ⇒ prod (map f ys)} → (∀ {y} (y∈ys : y ∈ ys) → π[ ∈ₚ.∈-map⁺ f y∈ys ] ∘ g ≈ π[ ∈ₚ.∈-map⁺ f y∈ys ] ∘ h) → g ≈ h uniqueness*′ {x} {[]} uni = !-unique₂ uniqueness*′ {x} {y ∷ ys} uni = unique′ (uni (here ≡.refl)) (uniqueness*′ λ y∈ys → sym-assoc ○ uni (there y∈ys) ○ assoc) module _ {x} (g : ∀ a → x ⇒ f a) where build-mors : (l : List A) → x ⇒ map f l * build-mors [] = _ ~[] build-mors (y ∷ l) = g y ∷ build-mors l build-proj≡ : ∀ {a l} (a∈l : a ∈ l) → g a ≡ ∈⇒mor (build-mors l) (∈ₚ.∈-map⁺ f a∈l) build-proj≡ (here refl) = ≡.refl build-proj≡ (there a∈l) = build-proj≡ a∈l build-proj : ∀ {a l} (a∈l : a ∈ l) → g a ≈ π[ ∈ₚ.∈-map⁺ f a∈l ] ∘ ⟨ build-mors l ⟩* build-proj {_} {l} a∈l = reflexive (build-proj≡ a∈l) ○ ⟺ (project* (build-mors l) _) build-⟨⟩*∘ : ∀ {x y} (g : ∀ a → x ⇒ f a) (h : y ⇒ x) → ∀ l → ⟨ build-mors g l ⟩* ∘ h ≈ ⟨ build-mors (λ a → g a ∘ h) l ⟩* build-⟨⟩*∘ g h [] = !-unique₂ build-⟨⟩*∘ g h (x ∷ l) = begin ⟨ build-mors g (x ∷ l) ⟩* ∘ h ≈⟨ ⟨⟩∘ ⟩ ⟨ g x ∘ h , ⟨ build-mors g l ⟩* ∘ h ⟩ ≈⟨ ⟨⟩-congˡ (build-⟨⟩*∘ g h l) ⟩ ⟨ g x ∘ h , ⟨ build-mors (λ a → g a ∘ h) l ⟩* ⟩ ∎ build-uniqueness* : ∀ {x} {g h : ∀ a → x ⇒ f a} → (∀ a → g a ≈ h a) → ∀ l → ⟨ build-mors g l ⟩* ≈ ⟨ build-mors h l ⟩* build-uniqueness* {x} {g} {h} uni [] = Equiv.refl build-uniqueness* {x} {g} {h} uni (y ∷ l) = ⟨⟩-cong₂ (uni y) (build-uniqueness* uni l) -- for vectors prodᵥ : ∀ {n} → Vec Obj (suc n) → Obj prodᵥ v = Vec.foldr₁ _×_ v π[_]ᵥ : ∀ {n x} {xs : Vec Obj (suc n)} → x ∈ᵥ xs → prodᵥ xs ⇒ x π[_]ᵥ {.0} {.x} {x ∷ []} (here refl) = id π[_]ᵥ {.(suc _)} {.x} {x ∷ y ∷ xs} (here refl) = π₁ π[_]ᵥ {.(suc _)} {x} {_ ∷ y ∷ xs} (there x∈xs) = π[ x∈xs ]ᵥ ∘ π₂ data [_]_⇒ᵥ_* : ∀ n → Obj → Vec Obj n → Set (o ⊔ ℓ) where _~[] : ∀ x → [ 0 ] x ⇒ᵥ [] * _∷_ : ∀ {x y n} {ys : Vec Obj n} → x ⇒ y → [ n ] x ⇒ᵥ ys * → [ suc n ] x ⇒ᵥ y ∷ ys * ⟨_⟩ᵥ* : ∀ {n x ys} (fs : [ suc n ] x ⇒ᵥ ys *) → x ⇒ prodᵥ ys ⟨ f ∷ (x ~[]) ⟩ᵥ* = f ⟨ f ∷ (g ∷ fs) ⟩ᵥ* = ⟨ f , ⟨ g ∷ fs ⟩ᵥ* ⟩ ∈⇒morᵥ : ∀ {n x y ys} (fs : [ n ] x ⇒ᵥ ys *) (y∈ys : y ∈ᵥ ys) → x ⇒ y ∈⇒morᵥ (x ~[]) () ∈⇒morᵥ (f ∷ fs) (here refl) = f ∈⇒morᵥ (f ∷ fs) (there y∈ys) = ∈⇒morᵥ fs y∈ys projectᵥ* : ∀ {n x y ys} (fs : [ suc n ] x ⇒ᵥ ys *) (y∈ys : y ∈ᵥ ys) → π[ y∈ys ]ᵥ ∘ ⟨ fs ⟩ᵥ* ≈ ∈⇒morᵥ fs y∈ys projectᵥ* (f ∷ (x ~[])) (here ≡.refl) = identityˡ projectᵥ* (f ∷ g ∷ fs) (here ≡.refl) = project₁ projectᵥ* (f ∷ g ∷ fs) (there y∈ys) = pullʳ project₂ ○ projectᵥ* (g ∷ fs) y∈ys uniquenessᵥ* : ∀ {x n ys} {g h : x ⇒ prodᵥ {n} ys} → (∀ {y} (y∈ys : y ∈ᵥ ys) → π[ y∈ys ]ᵥ ∘ g ≈ π[ y∈ys ]ᵥ ∘ h) → g ≈ h uniquenessᵥ* {x} {.0} {y ∷ []} uni = ⟺ identityˡ ○ uni (here ≡.refl) ○ identityˡ uniquenessᵥ* {x} {.(suc _)} {y ∷ z ∷ ys} uni = unique′ (uni (here ≡.refl)) (uniquenessᵥ* (λ y∈ys → sym-assoc ○ uni (there y∈ys) ○ assoc)) module _ {a} {A : Set a} (f : A → Obj) where uniquenessᵥ*′ : ∀ {x n ys} {g h : x ⇒ prodᵥ {n} (Vec.map f ys)} → (∀ {y} (y∈ys : y ∈ᵥ ys) → π[ ∈ᵥₚ.∈-map⁺ f y∈ys ]ᵥ ∘ g ≈ π[ ∈ᵥₚ.∈-map⁺ f y∈ys ]ᵥ ∘ h) → g ≈ h uniquenessᵥ*′ {x} {.0} {y ∷ []} uni = ⟺ identityˡ ○ uni (here ≡.refl) ○ identityˡ uniquenessᵥ*′ {x} {.(suc _)} {y ∷ z ∷ ys} uni = unique′ (uni (here ≡.refl)) (uniquenessᵥ*′ (λ y∈ys → sym-assoc ○ uni (there y∈ys) ○ assoc)) module _ {x} (g : ∀ a → x ⇒ f a) where buildᵥ-mors : ∀ {n} (l : Vec A n) → [ n ] x ⇒ᵥ Vec.map f l * buildᵥ-mors [] = _ ~[] buildᵥ-mors (y ∷ []) = g y ∷ _ ~[] buildᵥ-mors (y ∷ z ∷ l) = g y ∷ buildᵥ-mors (z ∷ l) buildᵥ-proj≡ : ∀ {a n} {l : Vec A n} (a∈l : a ∈ᵥ l) → g a ≡ ∈⇒morᵥ (buildᵥ-mors l) (∈ᵥₚ.∈-map⁺ f a∈l) buildᵥ-proj≡ {_} {_} {y ∷ []} (here refl) = ≡.refl buildᵥ-proj≡ {_} {_} {y ∷ z ∷ l} (here refl) = ≡.refl buildᵥ-proj≡ {_} {_} {y ∷ z ∷ l} (there a∈l) = buildᵥ-proj≡ a∈l buildᵥ-proj : ∀ {a n} {l : Vec A (suc n)} (a∈l : a ∈ᵥ l) → g a ≈ π[ ∈ᵥₚ.∈-map⁺ f a∈l ]ᵥ ∘ ⟨ buildᵥ-mors l ⟩ᵥ* buildᵥ-proj {_} {_} {l} a∈l = reflexive (buildᵥ-proj≡ a∈l) ○ ⟺ (projectᵥ* (buildᵥ-mors l) _) buildᵥ-⟨⟩*∘ : ∀ {x y} (g : ∀ a → x ⇒ f a) (h : y ⇒ x) → ∀ {n} (l : Vec A (suc n)) → ⟨ buildᵥ-mors g l ⟩ᵥ* ∘ h ≈ ⟨ buildᵥ-mors (λ a → g a ∘ h) l ⟩ᵥ* buildᵥ-⟨⟩*∘ g h (x ∷ []) = Equiv.refl buildᵥ-⟨⟩*∘ g h (x ∷ y ∷ []) = ⟨⟩∘ buildᵥ-⟨⟩*∘ g h (x ∷ y ∷ z ∷ l) = begin ⟨ g x , ⟨ buildᵥ-mors g (y ∷ z ∷ l) ⟩ᵥ* ⟩ ∘ h ≈⟨ ⟨⟩∘ ⟩ ⟨ g x ∘ h , ⟨ buildᵥ-mors g (y ∷ z ∷ l) ⟩ᵥ* ∘ h ⟩ ≈⟨ ⟨⟩-congˡ (buildᵥ-⟨⟩*∘ g h (y ∷ z ∷ l)) ⟩ ⟨ g x ∘ h , ⟨ buildᵥ-mors (λ a₁ → g a₁ ∘ h) (y ∷ z ∷ l) ⟩ᵥ* ⟩ ∎ buildᵥ-uniqueness* : ∀ {x} {g h : ∀ a → x ⇒ f a} → (∀ a → g a ≈ h a) → ∀ {n} (l : Vec A (suc n)) → ⟨ buildᵥ-mors g l ⟩ᵥ* ≈ ⟨ buildᵥ-mors h l ⟩ᵥ* buildᵥ-uniqueness* {x} {g} {h} uni (y ∷ []) = uni y buildᵥ-uniqueness* {x} {g} {h} uni (y ∷ z ∷ []) = ⟨⟩-cong₂ (uni y) (uni z) buildᵥ-uniqueness* {x} {g} {h} uni (y ∷ z ∷ w ∷ l) = ⟨⟩-cong₂ (uni y) (buildᵥ-uniqueness* uni (z ∷ w ∷ l))
{ "alphanum_fraction": 0.4729477612, "avg_line_length": 45.5094339623, "ext": "agda", "hexsha": "8c1bf855b420cb9bf0ddf6b550f098fe7fa21d3f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Category/Cartesian/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Category/Cartesian/Properties.agda", "max_line_length": 162, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Category/Cartesian/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4608, "size": 9648 }
{-# OPTIONS --rewriting --confluence-check #-} open import Agda.Primitive open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Rewrite postulate A : Set a b : A f : Level → A g h : Level f-g : f (lsuc g) ≡ a f-h : f (lsuc h) ≡ b g-h : g ≡ h {-# REWRITE f-g f-h g-h #-}
{ "alphanum_fraction": 0.6112956811, "avg_line_length": 17.7058823529, "ext": "agda", "hexsha": "58d8200f1f23dac3a98c6659474d4957efda3142", "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/Issue3817.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/Issue3817.agda", "max_line_length": 46, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue3817.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": 112, "size": 301 }
open import Relation.Binary using (Rel; Reflexive; Trans) open import Level using (Level; _⊔_; suc) open import Data.Product using (Σ; _×_; _,_; Σ-syntax; ∃-syntax; proj₁; proj₂) data Star {t r} {T : Set t} (R : Rel T r) : Rel T (t ⊔ r) where ε : Reflexive (Star R) _▻_ : Trans (Star R) R (Star R) _▻▻_ : ∀ {t r} {T : Set t} {R : Rel T r} {M L N : T} → Star R M L → Star R L N → Star R M N ML ▻▻ ε = ML ML ▻▻ (LL′ ▻ L′N) = (ML ▻▻ LL′) ▻ L′N Semi-Confluence : ∀ {t r} {T : Set t} (R : Rel T r) → Set (t ⊔ r) Semi-Confluence R = ∀ {M A B} → R M A → Star R M B -------------------------------- → ∃[ N ] (Star R A N × Star R B N) Confluence : ∀ {t r} {T : Set t} (R : Rel T r) → Set (t ⊔ r) Confluence R = ∀ {M A B} → Star R M A → Star R M B -------------------------------- → ∃[ N ] (Star R A N × Star R B N) semi-to-confluence : ∀ {t r} {T : Set t} {R : Rel T r} → Semi-Confluence R → Confluence R semi-to-confluence sc {B = B} ε M*B = B , M*B , ε semi-to-confluence sc (M*M′ ▻ M′A) M*B with semi-to-confluence sc M*M′ M*B ... | N , M′*N , B*N with sc M′A M′*N ... | N′ , A*N′ , N*N′ = N′ , A*N′ , B*N ▻▻ N*N′ Z : ∀ {t r} {T : Set t} (R : Rel T r) → Set (t ⊔ r) Z {t}{r}{T} R = Σ[ _* ∈ (T → T) ] (∀ {A B : T} → R A B → Star {t}{r} R B (A *)) × (∀ {A B : T} → R A B → Star {t}{r} R (A *) (B *)) z-monotonic : ∀ {t r} {T : Set t} {R : Rel T r} → (z : Z R) ------------------------------------------ → (∀ {A B} → Star R A B → Star R (proj₁ z A) (proj₁ z B)) z-monotonic z ε = ε z-monotonic z@(_* , Z₁ , Z₂) (A*A′ ▻ A′B) = z-monotonic z A*A′ ▻▻ Z₂ A′B z-semi-confluence : ∀ {t r} {T : Set t} {R : Rel T r} → Z R → Semi-Confluence R z-semi-confluence (_* , Z₁ , Z₂) {A = A} MA ε = A , ε , (ε ▻ MA) z-semi-confluence z@(_* , Z₁ , Z₂) MA (_▻_ {j = M′} M*M′ M′B) = M′ * , Z₁ MA ▻▻ z-monotonic z M*M′ , Z₁ M′B z-confluence : ∀ {t r} {T : Set t} {R : Rel T r} → Z R → Confluence R z-confluence z = semi-to-confluence (z-semi-confluence z)
{ "alphanum_fraction": 0.4518013632, "avg_line_length": 29.768115942, "ext": "agda", "hexsha": "7277da0776f9841fb81661bc9451a774f12765d6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2fa17f7738cc7da967375be928137adc4be38696", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "iwilare/church-rosser", "max_forks_repo_path": "Z.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2fa17f7738cc7da967375be928137adc4be38696", "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": "iwilare/church-rosser", "max_issues_repo_path": "Z.agda", "max_line_length": 79, "max_stars_count": 5, "max_stars_repo_head_hexsha": "2fa17f7738cc7da967375be928137adc4be38696", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "iwilare/church-rosser", "max_stars_repo_path": "Z.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-22T01:43:09.000Z", "max_stars_repo_stars_event_min_datetime": "2020-06-02T07:27:54.000Z", "num_tokens": 899, "size": 2054 }
module Basic.EqvSemantics where open import Data.Vec open import Function open import Data.Product open import Data.Maybe open import Utils.Decidable open import Basic.AST open import Basic.BigStep open import Basic.SmallStep {- Equivalence of big step and small step semantics (Theorem 2.26 in the book). The main difference from the book is the proof for the ⟨ S , s ⟩ k ⟶ s' → ⟨ S , s ⟩⟱ s' direction. The book does case analysis directly on the transition the "cons" case of the computation sequence, and then uses Lemma 2.19 (which I named "seq-split" in the SmallStep module) to split the sequence into two parts corresponding to the two parts of a composite statement. The problem with this is that it relies on the usual well-ordering of natural numbers, and it's not immediately structurally recursive. In other words, it relies on the fact that the resulting parts of a split sequence are both shorter than the original sequence. However, the book omits the proof that no splitting ever produces computation sequences of length zero. This is required for the recursion to be well-founded, and in Agda we would indeed have to prove this too. It's simpler to use "prepend". It essentially digs down to the leftmost "edge" of a small-step transition, and composes it with a big-step derivation. It's evidently structurally recursive and I find it a bit neater than the proof in the book. -} Small≡Big : ∀ {n}{S : St n}{s s'} → ⟨ S , s ⟩⟱ s' ⇔ ⟨ S , s ⟩⟶* s' Small≡Big {n} = to , from ∘ proj₂ where to : ∀ {S s s'} → ⟨ S , s ⟩⟱ s' → ⟨ S , s ⟩⟶* s' to ass = , ass stop to skip = , skip stop to (A , B) = , append (proj₂ $ to A) (proj₂ $ to B) to (if-true x p) = , if-true x ∷ proj₂ (to p) to (if-false x p) = , if-false x ∷ proj₂ (to p) to (while-true x p p₁) = , while ∷ if-true x ∷ append (proj₂ $ to p) (proj₂ $ to p₁) to (while-false x) = , while ∷ if-false x ∷ skip stop mutual prepend : ∀ {s₁ s₂ s₃}{S₁ S₂ : St n} → ⟨ S₁ , s₁ ⟩⟶⟨ S₂ , s₂ ⟩ → ⟨ S₂ , s₂ ⟩⟱ s₃ → ⟨ S₁ , s₁ ⟩⟱ s₃ prepend (p1 ◄) (p2 , p3) = prepend p1 p2 , p3 prepend (x ∙) p2 = from (x stop) , p2 prepend (if-true x) p2 = if-true x p2 prepend (if-false x) p2 = if-false x p2 prepend while (if-true x (p2 , p3)) = while-true x p2 p3 prepend while (if-false x skip) = while-false x from : ∀ {k S s s'} → ⟨ S , s ⟩ k ⟶ s' → ⟨ S , s ⟩⟱ s' from (ass stop) = ass from (skip stop) = skip from (x ∷ p) = prepend x (from p)
{ "alphanum_fraction": 0.6176024279, "avg_line_length": 34.2337662338, "ext": "agda", "hexsha": "5f6d95d02a2511c442caa1e9d9d7f05f70e9a862", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AndrasKovacs/SemanticsWithApplications", "max_forks_repo_path": "Basic/EqvSemantics.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94", "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": "AndrasKovacs/SemanticsWithApplications", "max_issues_repo_path": "Basic/EqvSemantics.agda", "max_line_length": 86, "max_stars_count": 8, "max_stars_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AndrasKovacs/SemanticsWithApplications", "max_stars_repo_path": "Basic/EqvSemantics.agda", "max_stars_repo_stars_event_max_datetime": "2020-02-02T10:01:52.000Z", "max_stars_repo_stars_event_min_datetime": "2016-09-12T04:25:39.000Z", "num_tokens": 852, "size": 2636 }
module Categories.Comonad where open import Level using (_⊔_) open import Categories.Category using (Category) open import Categories.Functor hiding (_≡_; assoc; identityˡ; identityʳ) open import Categories.NaturalTransformation renaming (id to idN) record Comonad {o ℓ e} (C : Category o ℓ e) : Set (o ⊔ ℓ ⊔ e) where field F : Endofunctor C ε : NaturalTransformation F id δ : NaturalTransformation F (F ∘ F) open Functor F field .assoc : (δ ∘ʳ F) ∘₁ δ ≡ (F ∘ˡ δ) ∘₁ δ .identityˡ : (F ∘ˡ ε) ∘₁ δ ≡ idN .identityʳ : (ε ∘ʳ F) ∘₁ δ ≡ idN
{ "alphanum_fraction": 0.6585365854, "avg_line_length": 27.3333333333, "ext": "agda", "hexsha": "8e938fc1644d03427f8c9f141a4573b1b75199a6", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "copumpkin/categories", "max_forks_repo_path": "Categories/Comonad.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "copumpkin/categories", "max_issues_repo_path": "Categories/Comonad.agda", "max_line_length": 72, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Comonad.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 210, "size": 574 }
-- A module which imports every Web.Semantic module. module Web.Semantic.Everything where import Web.Semantic.DL.ABox import Web.Semantic.DL.ABox.Interp import Web.Semantic.DL.ABox.Interp.Meet import Web.Semantic.DL.ABox.Interp.Morphism import Web.Semantic.DL.ABox.Model import Web.Semantic.DL.ABox.Skolemization import Web.Semantic.DL.Category import Web.Semantic.DL.Category.Composition import Web.Semantic.DL.Category.Morphism import Web.Semantic.DL.Category.Object import Web.Semantic.DL.Category.Properties import Web.Semantic.DL.Category.Properties.Composition import Web.Semantic.DL.Category.Properties.Composition.Assoc import Web.Semantic.DL.Category.Properties.Composition.LeftUnit import Web.Semantic.DL.Category.Properties.Composition.Lemmas import Web.Semantic.DL.Category.Properties.Composition.RespectsEquiv import Web.Semantic.DL.Category.Properties.Composition.RespectsWiring import Web.Semantic.DL.Category.Properties.Composition.RightUnit import Web.Semantic.DL.Category.Properties.Equivalence import Web.Semantic.DL.Category.Properties.Tensor import Web.Semantic.DL.Category.Properties.Tensor.AssocNatural import Web.Semantic.DL.Category.Properties.Tensor.Coherence import Web.Semantic.DL.Category.Properties.Tensor.Functor import Web.Semantic.DL.Category.Properties.Tensor.Isomorphisms import Web.Semantic.DL.Category.Properties.Tensor.Lemmas import Web.Semantic.DL.Category.Properties.Tensor.RespectsEquiv import Web.Semantic.DL.Category.Properties.Tensor.RespectsWiring import Web.Semantic.DL.Category.Properties.Tensor.SymmNatural import Web.Semantic.DL.Category.Properties.Tensor.UnitNatural import Web.Semantic.DL.Category.Tensor import Web.Semantic.DL.Category.Unit import Web.Semantic.DL.Category.Wiring import Web.Semantic.DL.Concept import Web.Semantic.DL.Concept.Model import Web.Semantic.DL.Concept.Skolemization import Web.Semantic.DL.FOL import Web.Semantic.DL.FOL.Model import Web.Semantic.DL.Integrity import Web.Semantic.DL.Integrity.Closed import Web.Semantic.DL.Integrity.Closed.Alternate import Web.Semantic.DL.Integrity.Closed.Properties import Web.Semantic.DL.KB import Web.Semantic.DL.KB.Model import Web.Semantic.DL.KB.Skolemization import Web.Semantic.DL.Role import Web.Semantic.DL.Role.Model import Web.Semantic.DL.Role.Skolemization import Web.Semantic.DL.Sequent import Web.Semantic.DL.Sequent.Model import Web.Semantic.DL.Signature import Web.Semantic.DL.TBox import Web.Semantic.DL.TBox.Interp import Web.Semantic.DL.TBox.Interp.Morphism import Web.Semantic.DL.TBox.Minimizable import Web.Semantic.DL.TBox.Model import Web.Semantic.DL.TBox.Skolemization
{ "alphanum_fraction": 0.8530878404, "avg_line_length": 42.737704918, "ext": "agda", "hexsha": "10380419b26b51991cebef1380a603d499af5036", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z", "max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z", "max_forks_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-web-semantic", "max_forks_repo_path": "src/Web/Semantic/Everything.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bblfish/agda-web-semantic", "max_issues_repo_path": "src/Web/Semantic/Everything.agda", "max_line_length": 69, "max_stars_count": 9, "max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-web-semantic", "max_stars_repo_path": "src/Web/Semantic/Everything.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z", "num_tokens": 706, "size": 2607 }
{-# OPTIONS --safe --without-K #-} module Generics.Mu where open import Generics.Prelude hiding (lookup) open import Generics.Telescope open import Generics.Desc private variable P : Telescope ⊤ V I : ExTele P p : ⟦ P ⟧tel tt ℓ : Level n : ℕ ⟦_⟧IndArgω : ConDesc P V I → (⟦ P , I ⟧xtel → Setω) → ⟦ P , V ⟧xtel → Setω ⟦ var f ⟧IndArgω X (p , v) = X (p , f (p , v)) ⟦ π (n , ai) S C ⟧IndArgω X (p , v) = (s : < relevance ai > S (p , v)) → ⟦ C ⟧IndArgω X (p , v , s) ⟦ A ⊗ B ⟧IndArgω X pv = ⟦ A ⟧IndArgω X pv ×ω ⟦ B ⟧IndArgω X pv ⟦_⟧Conω : ConDesc P V I → (⟦ P , I ⟧xtel → Setω) → ⟦ P , V & I ⟧xtel → Setω ⟦ var f ⟧Conω X (p , v , i) = Liftω (i ≡ f (p , v)) ⟦ π (n , ai) S C ⟧Conω X (p , v , i) = Σω (< relevance ai > S _) λ s → ⟦ C ⟧Conω X (p , (v , s) , i) ⟦ A ⊗ B ⟧Conω X (p , v , i) = ⟦ A ⟧IndArgω X (p , v) ×ω ⟦ B ⟧Conω X (p , v , i) ⟦_⟧Dataω : DataDesc P I n → (⟦ P , I ⟧xtel → Setω) → ⟦ P , I ⟧xtel → Setω ⟦_⟧Dataω {n = n} D X (p , i) = Σω (Fin n) λ k → ⟦ lookupCon D k ⟧Conω X (p , tt , i) data μ (D : DataDesc P I n) (pi : ⟦ P , I ⟧xtel) : Setω where ⟨_⟩ : ⟦ D ⟧Dataω (μ D) pi → μ D pi
{ "alphanum_fraction": 0.4943132108, "avg_line_length": 34.6363636364, "ext": "agda", "hexsha": "3cfab5623429ae84f43eaa2cf221ebe581a9b200", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-01-14T10:35:16.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-08T08:32:42.000Z", "max_forks_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "flupe/generics", "max_forks_repo_path": "src/Generics/Mu.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_issues_repo_issues_event_max_datetime": "2022-01-14T10:48:30.000Z", "max_issues_repo_issues_event_min_datetime": "2021-09-13T07:33:50.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "flupe/generics", "max_issues_repo_path": "src/Generics/Mu.agda", "max_line_length": 100, "max_stars_count": 11, "max_stars_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "flupe/generics", "max_stars_repo_path": "src/Generics/Mu.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T09:35:17.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-08T15:10:20.000Z", "num_tokens": 563, "size": 1143 }
{-# OPTIONS --cubical --no-import-sorts --safe --postfix-projections #-} module Cubical.Data.FinSet.Binary.Small.Properties where open import Cubical.Foundations.Equiv open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Prelude open import Cubical.Foundations.Transport open import Cubical.Foundations.Univalence open import Cubical.Functions.Embedding open import Cubical.Functions.Involution open import Cubical.Data.Sigma open import Cubical.HITs.PropositionalTruncation open import Cubical.Data.FinSet.Binary.Small.Base open import Cubical.Data.Bool import Cubical.Data.FinSet.Binary.Large as FS open FS using (isBinary) open import Cubical.Foundations.Univalence.Universe Binary El un (λ _ → refl) private variable ℓ : Level B : Type ℓ isBinaryEl : ∀ b → isBinary (El b) isBinaryEl ℕ₂ = ∣ idEquiv Bool ∣ isBinaryEl (un b c e i) = squash (transp (λ j → ∥ Bool ≃ ua e (i ∧ j) ∥) (~ i) (isBinaryEl b)) (transp (λ j → ∥ Bool ≃ ua e (i ∨ ~ j) ∥) i (isBinaryEl c)) i isBinaryEl' : ∀ ℓ b → isBinary (Lift {j = ℓ} (El b)) isBinaryEl' ℓ ℕ₂ = ∣ LiftEquiv ∣ isBinaryEl' ℓ (un b c e i) = squash (transp (λ j → ∥ Bool ≃ Lift {j = ℓ} (ua e (i ∧ j)) ∥) (~ i) (isBinaryEl' ℓ b)) (transp (λ j → ∥ Bool ≃ Lift {j = ℓ} (ua e (i ∨ ~ j)) ∥) i (isBinaryEl' ℓ c)) i isPropIsSetEl : isOfHLevelDep 1 (λ b → isSet (El b)) isPropIsSetEl = isOfHLevel→isOfHLevelDep 1 (λ b → isPropIsSet) isSetEl : ∀ b → isSet (El b) isSetEl ℕ₂ = isSetBool isSetEl (un b c e i) = isPropIsSetEl (isSetEl b) (isSetEl c) (un b c e) i isGroupoidBinary : isGroupoid Binary isGroupoidBinary b c = isOfHLevelRetract 2 fun inv leftInv sub where open Iso (pathIso b c) sub : isSet (El b ≡ El c) sub = isOfHLevel≡ 2 (isSetEl b) (isSetEl c) module Reflection where bigger : Binary → FS.Binary _ bigger b = El b , isBinaryEl b open Iso lemma : ∀(B : Type₀) → ∥ Bool ≃ B ∥ → Σ[ b ∈ Binary ] El b ≃ B lemma B = rec Sprp (_,_ ℕ₂) where Fprp : isProp (fiber El B) Fprp = isEmbedding→hasPropFibers isEmbeddingEl B Sprp : isProp (Σ[ b ∈ Binary ] El b ≃ B) Sprp = isOfHLevelRetract 1 (map-snd ua) (map-snd pathToEquiv) (λ{ (A , e) → ΣPathP (refl , pathToEquiv-ua e) }) Fprp smaller : FS.Binary ℓ-zero → Binary smaller (B , tp) = lemma B tp .fst bigger-smaller : ∀ p → bigger (smaller p) ≡ p bigger-smaller (B , tp) = ΣPathP (b≡B , ∥∥-isPropDep (λ B → Bool ≃ B) (isBinaryEl b) tp b≡B) where b = smaller (B , tp) b≡B = ua (lemma B tp .snd) smaller-bigger : ∀ b → smaller (bigger b) ≡ b smaller-bigger b = equivIso _ _ .inv (lemma (El b) (isBinaryEl b) .snd) reflectIso : Iso Binary (FS.Binary ℓ-zero) reflectIso .fun = bigger reflectIso .inv = smaller reflectIso .rightInv = bigger-smaller reflectIso .leftInv = smaller-bigger reflect : Binary ≃ FS.Binary ℓ-zero reflect = isoToEquiv Reflection.reflectIso structureᵤ : FS.BinStructure Binary structureᵤ = λ where .base → bs .base .lower .loop i → bs .loop i .lower .loop² i j → bs .loop² i j .lower .trunc → isGroupoidBinary where open FS.BinStructure path : Lift Binary ≡ FS.Binary _ path = ua (compEquiv (invEquiv LiftEquiv) reflect) bs : FS.BinStructure (Lift Binary) bs = subst⁻ FS.BinStructure path FS.structure₀
{ "alphanum_fraction": 0.6691133294, "avg_line_length": 29.3620689655, "ext": "agda", "hexsha": "cef7d92e0f207d72d2550845eae6be8716dc4442", "lang": "Agda", "max_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/Data/FinSet/Binary/Small/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Data/FinSet/Binary/Small/Properties.agda", "max_line_length": 85, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Data/FinSet/Binary/Small/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1218, "size": 3406 }
{-# OPTIONS --without-K #-} module FinEquivEquivTimes where open import Data.Product using (_×_; proj₁; proj₂) open import Equiv using (refl∼; sym∼; sym≃; _⊎≃_; id≃; _≃_; _●_; _×≃_; qinv) open import FinEquivPlusTimes using (F0≃⊥; Fin1≃⊤; module Plus; module Times) open Plus using (⊎≃+; +≃⊎) open Times using (×≃*; *≃×) open import FinEquivTypeEquiv using (_fin≃_; module PlusE; module TimesE; module PlusTimesE) open PlusE using (_+F_; unite+; uniti+; unite+r; uniti+r; assocr+; assocl+; swap+; sswap+) open TimesE using (_*F_; unite*; uniti*; unite*r; uniti*r; assocr*; assocl*; swap*; sswap*) open PlusTimesE using (distz; factorz; distzr; factorzr; dist; factor; distl; factorl) open import EquivEquiv open import TypeEquiv using (unite⋆equiv; unite⋆′equiv; assocl⋆equiv) open import Data.Empty using (⊥) open import Data.Unit using (⊤) open import Data.Nat using (ℕ; _+_; _*_) open import Data.Fin using (Fin) open import Data.Sum using (_⊎_) open import Data.Product using (_,_) import Relation.Binary.PropositionalEquality as P using (refl) import TypeEquivEquiv as T using (id×id≋id; ×●≋●×; _×≋_; sym≃-distrib×; unite⋆-nat; assocl⋆-nat; [g*1]●[1*f]≋[1*f]●[g*1]; unite⋆′-nat) ------------------------------------------------------------------------------ -- Equivalences for the multiplicative structure id1≃ : Fin 1 ≃ Fin 1 id1≃ = id≃ {A = Fin 1} id*id≋id : ∀ {m n : ℕ} → id≃ {A = Fin m} *F id≃ {A = Fin n} ≋ id≃ id*id≋id {m} {n} = let em = id≃ {A = Fin m} in let en = id≃ {A = Fin n} in let em×en = id≃ {A = Fin m × Fin n} in let em*n = id≃ {A = Fin (m * n)} in let f≋ = id≋ {x = ×≃* {m} {n}} in let g≋ = id≋ {x = *≃× {m} {n}} in begin ( em *F en ≋⟨ id≋ ⟩ ×≃* ● (em ×≃ en) ● *≃× ≋⟨ f≋ ◎ (T.id×id≋id ◎ g≋) ⟩ ×≃* ● id≃ {A = Fin m × Fin n} ● *≃× ≋⟨ f≋ ◎ lid≋ {f = *≃×} ⟩ ×≃* {m} ● *≃× ≋⟨ rinv≋ (×≃* {m}) ⟩ em*n ∎) where open ≋-Reasoning intro-inv-r* : {m n : ℕ} {B : Set} (f : (Fin m × Fin n) ≃ B) → f ≋ (f ● *≃×) ● ×≃* intro-inv-r* f = begin ( f ≋⟨ sym≋ rid≋ ⟩ f ● id≃ ≋⟨ id≋ {x = f} ◎ sym≋ (linv≋ ×≃*) ⟩ f ● (*≃× ● ×≃*) ≋⟨ ●-assocl ⟩ (f ● *≃×) ● ×≃* ∎) where open ≋-Reasoning *●≋●* : {A B C D E F : ℕ} → {f : A fin≃ C} {g : B fin≃ D} {h : C fin≃ E} {i : D fin≃ F} → (h ● f) *F (i ● g) ≋ (h *F i) ● (f *F g) *●≋●* {f = f} {g} {h} {i} = let f≋ = id≋ {x = ×≃*} in let g≋ = id≋ {x = *≃×} in let id≋fg = id≋ {x = f ×≃ g} in begin ( (h ● f) *F (i ● g) ≋⟨ id≋ ⟩ ×≃* ● ((h ● f) ×≃ (i ● g)) ● *≃× ≋⟨ f≋ ◎ (T.×●≋●× ◎ g≋) ⟩ -- the real work, rest is shuffling ×≃* ● ((h ×≃ i) ● (f ×≃ g)) ● *≃× ≋⟨ ●-assocl ⟩ (×≃* ● ((h ×≃ i) ● (f ×≃ g))) ● *≃× ≋⟨ ●-assocl ◎ g≋ ⟩ ((×≃* ● h ×≃ i) ● f ×≃ g) ● *≃× ≋⟨ ((f≋ ◎ intro-inv-r* (h ×≃ i)) ◎ id≋fg) ◎ g≋ ⟩ ((×≃* ● (h ×≃ i ● *≃×) ● ×≃*) ● f ×≃ g) ● *≃× ≋⟨ (●-assocl ◎ id≋fg) ◎ g≋ ⟩ (((×≃* ● (h ×≃ i ● *≃×)) ● ×≃*) ● f ×≃ g) ● *≃× ≋⟨ id≋ ⟩ -- the left part is done, show it ((h *F i ● ×≃*) ● f ×≃ g) ● *≃× ≋⟨ ●-assoc {f = f ×≃ g} {×≃*} {h *F i} ◎ g≋ ⟩ (h *F i ● (×≃* ● f ×≃ g)) ● *≃× ≋⟨ ●-assoc {f = *≃×} {×≃* ● f ×≃ g} {h *F i}⟩ (h *F i) ● ((×≃* ● f ×≃ g) ● *≃×) ≋⟨ id≋ {x = h *F i} ◎ ●-assoc {f = *≃×} {f ×≃ g} {×≃*}⟩ (h *F i) ● (f *F g) ∎) where open ≋-Reasoning _*≋_ : {A B C D : ℕ} {f₁ g₁ : A fin≃ B} {f₂ g₂ : C fin≃ D} → (f₁ ≋ g₁) → (f₂ ≋ g₂) → (f₁ *F f₂ ≋ g₁ *F g₂) _*≋_ {A} {B} {C} {D} {f₁} {g₁} {f₂} {g₂} f₁≋g₁ f₂≋g₂ = let f≋ = id≋ {x = ×≃*} in let g≋ = id≋ {x = *≃×} in begin ( f₁ *F f₂ ≋⟨ id≋ ⟩ ×≃* ● (f₁ ×≃ f₂) ● *≃× ≋⟨ f≋ ◎ (T._×≋_ f₁≋g₁ f₂≋g₂ ◎ g≋) ⟩ ×≃* ● (g₁ ×≃ g₂) ● *≃× ≋⟨ id≋ ⟩ g₁ *F g₂ ∎) where open ≋-Reasoning unite⋆-nat : {m n : ℕ} {f : m fin≃ n} → unite* ● (id1≃ *F f) ≋ f ● unite* unite⋆-nat {m} {n} {f} = begin ( unite* ● (id1≃ *F f) ≋⟨ id≋ ⟩ (unite⋆equiv ● (Fin1≃⊤ ×≃ id≃) ● *≃×) ● ×≃* ● ((id≃ ×≃ f) ● *≃×) ≋⟨ ●-assocl {f = (id≃ ×≃ f) ● *≃×} {×≃*} {unite⋆equiv ● (Fin1≃⊤ ×≃ id≃) ● *≃×} ⟩ ((unite⋆equiv ● ((Fin1≃⊤ ×≃ id≃) ● *≃×)) ● ×≃*) ● ((id≃ ×≃ f) ● *≃×) ≋⟨ (●-assocl ◎ id≋) ◎ id≋ ⟩ (((unite⋆equiv ● (Fin1≃⊤ ×≃ id≃)) ● *≃×) ● ×≃*) ● (id≃ ×≃ f) ● *≃× ≋⟨ sym≋ (intro-inv-r* (unite⋆equiv ● (Fin1≃⊤ ×≃ id≃))) ◎ id≋ ⟩ (unite⋆equiv ● (Fin1≃⊤ ×≃ id≃)) ● (id≃ ×≃ f) ● *≃× ≋⟨ ●-assocl ⟩ ((unite⋆equiv ● (Fin1≃⊤ ×≃ id≃)) ● (id≃ ×≃ f)) ● *≃× ≋⟨ ●-assoc ◎ id≋ ⟩ (unite⋆equiv ● (Fin1≃⊤ ×≃ id≃) ● (id≃ ×≃ f)) ● *≃× ≋⟨ (id≋ ◎ (T.[g*1]●[1*f]≋[1*f]●[g*1] {f = f} {Fin1≃⊤})) ◎ id≋ ⟩ (unite⋆equiv ● ((id≃ ×≃ f) ● (Fin1≃⊤ ×≃ id≃))) ● *≃× ≋⟨ ●-assocl ◎ id≋ ⟩ ((unite⋆equiv ● (id≃ ×≃ f)) ● (Fin1≃⊤ ×≃ id≃)) ● *≃× ≋⟨ ●-assoc ⟩ (unite⋆equiv ● (id≃ ×≃ f)) ● (Fin1≃⊤ ×≃ id≃) ● *≃× ≋⟨ T.unite⋆-nat ◎ id≋ ⟩ (f ● unite⋆equiv) ● (Fin1≃⊤ ×≃ id≃) ● *≃× ≋⟨ ●-assoc ⟩ f ● unite⋆equiv ● (Fin1≃⊤ ×≃ id≃) ● *≃× ≋⟨ id≋ ⟩ f ● unite* ∎) where open ≋-Reasoning -- sym≃ distributes over *F sym*F : ∀ {A B C D} {f : A fin≃ B} {g : C fin≃ D} → sym≃ (f *F g) ≋ sym≃ f *F sym≃ g sym*F {f = f} {g = g} = begin ( sym≃ (f *F g) ≋⟨ id≋ ⟩ sym≃ (×≃* ● (f ×≃ g ● *≃×)) ≋⟨ sym≃● ⟩ sym≃ (f ×≃ g ● *≃×) ● sym≃ ×≃* ≋⟨ sym≃● ◎ id≋ ⟩ (sym≃ *≃× ● sym≃ (f ×≃ g)) ● sym≃ ×≃* ≋⟨ (id≋ ◎ T.sym≃-distrib×) ◎ id≋ ⟩ (sym≃ *≃× ● (sym≃ f ×≃ sym≃ g)) ● sym≃ ×≃* ≋⟨ ●-assoc ⟩ sym≃ *≃× ● ((sym≃ f ×≃ sym≃ g) ● sym≃ ×≃*) ≋⟨ id≋ ⟩ sym≃ f *F sym≃ g ∎) where open ≋-Reasoning uniti⋆-nat : ∀ {A B} {f : A fin≃ B} → uniti* ● f ≋ (id1≃ *F f) ● uniti* uniti⋆-nat {f = f} = begin ( uniti* ● f ≋⟨ id≋ ⟩ sym≃ unite* ● sym≃ (sym≃ f) ≋⟨ sym≋ sym≃● ⟩ sym≃ (sym≃ f ● unite*) ≋⟨ flip-sym≋ unite⋆-nat ⟩ sym≃ (unite* ● (id1≃ *F sym≃ f)) ≋⟨ sym≃● ⟩ sym≃ (id1≃ *F sym≃ f) ● uniti* ≋⟨ sym*F ◎ id≋ {x = uniti*} ⟩ (id1≃ *F sym≃ (sym≃ f)) ● uniti* ≋⟨ id≋ ⟩ (id1≃ *F f) ● uniti* ∎) where open ≋-Reasoning unite⋆r-nat : {m n : ℕ} {f : m fin≃ n} → unite*r ● (f *F id1≃) ≋ f ● unite*r unite⋆r-nat {m} {n} {f} = let 1*⊥ = id≃ ×≃ Fin1≃⊤ in let f*1 = f ×≃ id≃ in let g≋ = id≋ {x = *≃×} in let rhs≋ = id≋ {x = f*1 ● *≃×} in begin ( unite*r ● (f *F id1≃) ≋⟨ id≋ ⟩ (unite⋆′equiv ● 1*⊥ ● *≃×) ● ×≃* ● (f*1 ● *≃×) ≋⟨ ●-assocl ⟩ ((unite⋆′equiv ● 1*⊥ ● *≃×) ● ×≃*) ● (f*1 ● *≃×) ≋⟨ (●-assocl ◎ id≋) ◎ id≋ ⟩ (((unite⋆′equiv ● 1*⊥) ● *≃×) ● ×≃*) ● (f*1 ● *≃×) ≋⟨ sym≋ (intro-inv-r* (unite⋆′equiv ● 1*⊥)) ◎ rhs≋ ⟩ (unite⋆′equiv ● 1*⊥) ● (f*1 ● *≃×) ≋⟨ trans≋ ●-assocl (●-assoc ◎ id≋) ⟩ (unite⋆′equiv ● (1*⊥ ● f*1)) ● *≃× ≋⟨ (id≋ {x = unite⋆′equiv} ◎ sym≋ (T.[g*1]●[1*f]≋[1*f]●[g*1] {f = Fin1≃⊤} {f})) ◎ g≋ ⟩ (unite⋆′equiv ● (f ×≃ id≃) ● (id≃ ×≃ Fin1≃⊤)) ● *≃× -- the id≃ are at different types! ≋⟨ ●-assocl ◎ id≋ ⟩ ((unite⋆′equiv ● (f ×≃ id≃)) ● (id≃ ×≃ Fin1≃⊤)) ● *≃× ≋⟨ ●-assoc ⟩ (unite⋆′equiv ● (f ×≃ id≃)) ● (id≃ ×≃ Fin1≃⊤) ● *≃× ≋⟨ T.unite⋆′-nat ◎ id≋ {x = (id≃ ×≃ Fin1≃⊤) ● *≃×} ⟩ (f ● unite⋆′equiv) ● (id≃ ×≃ Fin1≃⊤) ● *≃× ≋⟨ ●-assoc ⟩ -- assoc * defn f ● unite*r ∎) where open ≋-Reasoning uniti₊r-nat : {m n : ℕ} {f : m fin≃ n} → uniti*r ● f ≋ (f *F id1≃) ● uniti*r uniti₊r-nat {f = f} = begin ( uniti*r ● f ≋⟨ id≋ ⟩ sym≃ unite*r ● sym≃ (sym≃ f) ≋⟨ sym≋ sym≃● ⟩ sym≃ (sym≃ f ● unite*r) ≋⟨ flip-sym≋ unite⋆r-nat ⟩ sym≃ (unite*r ● (sym≃ f *F id1≃)) ≋⟨ sym≃● ⟩ sym≃ (sym≃ f *F id1≃) ● uniti*r ≋⟨ sym*F ◎ id≋ {x = uniti*r} ⟩ (sym≃ (sym≃ f) *F id1≃) ● uniti*r ≋⟨ id≋ ⟩ (f *F id1≃) ● uniti*r ∎) where open ≋-Reasoning -- assocl* is the one which is defined directly (?) assocl⋆-nat : {m n o m' n' o' : ℕ} {f : m fin≃ m'} {g : n fin≃ n'} {h : o fin≃ o'} → assocl* {m'} {n'} {o'} ● (f *F (g *F h)) ≋ ((f *F g) *F h) ● assocl* {m} {n} {o} -- expand the definitions right away, the pattern is clear assocl⋆-nat {m} {n} {o} {m'} {n'} {o'} {f} {g} {h} = let αmno' = assocl⋆equiv {Fin m'} {Fin n'} {Fin o'} in let αmno = assocl⋆equiv {Fin m} {Fin n} {Fin o} in begin ( (×≃* ● ×≃* ×≃ id≃ ● αmno' ● id≃ ×≃ *≃× ● *≃×) ● ×≃* ● ((f ×≃ (×≃* ● g ×≃ h ● *≃×)) ● *≃×) ≋⟨ ●-assocl ⟩ ((×≃* ● ×≃* ×≃ id≃ ● assocl⋆equiv ● id≃ ×≃ *≃× ● *≃×) ● ×≃*) ● (f ×≃ (×≃* ● g ×≃ h ● *≃×) ● *≃×) ≋⟨ ((id≋ ◎ (id≋ ◎ ●-assocl)) ◎ id≋) ◎ id≋ ⟩ ((×≃* ● ×≃* ×≃ id≃ ● (assocl⋆equiv ● id≃ ×≃ *≃×) ● *≃×) ● ×≃*) ● (f ×≃ (×≃* ● g ×≃ h ● *≃×) ● *≃×) ≋⟨ ((id≋ ◎ ●-assocl) ◎ id≋) ◎ id≋ ⟩ ((×≃* ● (×≃* ×≃ id≃ ● (assocl⋆equiv ● id≃ ×≃ *≃×)) ● *≃×) ● ×≃*) ● (f ×≃ (×≃* ● g ×≃ h ● *≃×) ● *≃×) ≋⟨ (●-assocl ◎ id≋) ◎ id≋ ⟩ (((×≃* ● (×≃* ×≃ id≃ ● (assocl⋆equiv ● id≃ ×≃ *≃×))) ● *≃×) ● ×≃*) ● (f ×≃ (×≃* ● g ×≃ h ● *≃×) ● *≃×) ≋⟨ sym≋ (intro-inv-r* (×≃* ● (×≃* ×≃ id≃ ● (assocl⋆equiv ● id≃ ×≃ *≃×)))) ◎ id≋ ⟩ (×≃* ● (×≃* ×≃ id≃ ● (assocl⋆equiv ● id≃ ×≃ *≃×))) ● (f ×≃ (×≃* ● g ×≃ h ● *≃×) ● *≃×) ≋⟨ ●-assoc ⟩ ×≃* ● (×≃* ×≃ id≃ ● (assocl⋆equiv ● id≃ ×≃ *≃×)) ● (f ×≃ (×≃* ● g ×≃ h ● *≃×) ● *≃×) ≋⟨ id≋ ◎ (●-assocl ◎ id≋) ⟩ ×≃* ● ((×≃* ×≃ id≃ ● assocl⋆equiv) ● id≃ ×≃ *≃×) ● (f ×≃ (×≃* ● g ×≃ h ● *≃×) ● *≃×) ≋⟨ id≋ ◎ ●-assoc ⟩ ×≃* ● (×≃* ×≃ id≃ ● assocl⋆equiv) ● (id≃ ×≃ *≃× ● (f ×≃ (×≃* ● g ×≃ h ● *≃×) ● *≃×)) ≋⟨ id≋ ◎ (id≋ ◎ ●-assocl) ⟩ ×≃* ● (×≃* ×≃ id≃ ● assocl⋆equiv) ● ((id≃ ×≃ *≃× ● f ×≃ (×≃* ● g ×≃ h ● *≃×)) ● *≃×) ≋⟨ id≋ ◎ (id≋ ◎ (sym≋ T.×●≋●× ◎ id≋)) ⟩ ×≃* ● (×≃* ×≃ id≃ ● assocl⋆equiv) ● ((id≃ ● f) ×≃ (*≃× ● (×≃* ● g ×≃ h ● *≃×))) ● *≃× ≋⟨ id≋ ◎ (id≋ ◎ (T._×≋_ (trans≋ lid≋ (sym≋ rid≋)) (trans≋ ●-assocl (trans≋ (linv≋ ×≃* ◎ id≋) lid≋)) ◎ id≋)) ⟩ ×≃* ● (×≃* ×≃ id≃ ● assocl⋆equiv) ● ((f ● id≃) ×≃ (g ×≃ h ● *≃×)) ● *≃× ≋⟨ id≋ ◎ (id≋ ◎ (T.×●≋●× ◎ id≋)) ⟩ ×≃* ● (×≃* ×≃ id≃ ● assocl⋆equiv) ● (f ×≃ (g ×≃ h) ● id≃ ×≃ *≃×) ● *≃× ≋⟨ id≋ ◎ ●-assocl ⟩ ×≃* ● ((×≃* ×≃ id≃ ● assocl⋆equiv) ● (f ×≃ (g ×≃ h) ● id≃ ×≃ *≃×)) ● *≃× ≋⟨ id≋ ◎ (●-assocl ◎ id≋) ⟩ ×≃* ● (((×≃* ×≃ id≃ ● assocl⋆equiv) ● f ×≃ (g ×≃ h)) ● id≃ ×≃ *≃×) ● *≃× ≋⟨ id≋ ◎ ((●-assoc ◎ id≋) ◎ id≋) ⟩ ×≃* ● ((×≃* ×≃ id≃ ● (assocl⋆equiv ● f ×≃ (g ×≃ h))) ● id≃ ×≃ *≃×) ● *≃× ≋⟨ id≋ ◎ ( ((id≋ ◎ T.assocl⋆-nat) ◎ id≋) ◎ id≋) ⟩ ×≃* ● ((×≃* ×≃ id≃ ● ((f ×≃ g) ×≃ h) ● assocl⋆equiv) ● id≃ ×≃ *≃×) ● *≃× ≋⟨ id≋ ◎ ((●-assocl ◎ id≋) ◎ id≋) ⟩ ×≃* ● (((×≃* ×≃ id≃ ● (f ×≃ g) ×≃ h) ● assocl⋆equiv) ● id≃ ×≃ *≃×) ● *≃× ≋⟨ id≋ ◎ (((T*1-nat ◎ id≋) ◎ id≋) ◎ id≋) ⟩ ×≃* ● ((((×≃* ● f ×≃ g ● *≃×) ● ×≃*) ×≃ (h ● id≃) ● assocl⋆equiv) ● id≃ ×≃ *≃×) ● *≃× ≋⟨ id≋ ◎ ●-assoc ⟩ ×≃* ● (((×≃* ● f ×≃ g ● *≃×) ● ×≃*) ×≃ (h ● id≃) ● assocl⋆equiv) ● (id≃ ×≃ *≃× ● *≃×) ≋⟨ id≋ ◎ ●-assoc ⟩ ×≃* ● ((×≃* ● f ×≃ g ● *≃×) ● ×≃*) ×≃ (h ● id≃) ● (assocl⋆equiv ● id≃ ×≃ *≃× ● *≃×) ≋⟨ ●-assocl ⟩ (×≃* ● ((×≃* ● (f ×≃ g) ● *≃×) ● ×≃*) ×≃ (h ● id≃)) ● (αmno ● id≃ ×≃ *≃× ● *≃×) ≋⟨ (id≋ ◎ T.×●≋●× ) ◎ id≋ ⟩ (×≃* ● (((×≃* ● (f ×≃ g) ● *≃×) ×≃ h) ● (×≃* ×≃ id≃))) ● (αmno ● id≃ ×≃ *≃× ● *≃×) ≋⟨ ●-assocl ◎ id≋ ⟩ ((×≃* ● ((×≃* ● (f ×≃ g) ● *≃×) ×≃ h)) ● (×≃* ×≃ id≃)) ● (αmno ● id≃ ×≃ *≃× ● *≃×) ≋⟨ ●-assoc ⟩ (×≃* ● ((×≃* ● (f ×≃ g) ● *≃×) ×≃ h)) ● (×≃* ×≃ id≃ ● αmno ● id≃ ×≃ *≃× ● *≃×) ≋⟨ id≋ ◎ sym≋ lid≋ ⟩ (×≃* ● ((×≃* ● (f ×≃ g) ● *≃×) ×≃ h)) ● id≃ ● (×≃* ×≃ id≃ ● αmno ● id≃ ×≃ *≃× ● *≃×) ≋⟨ id≋ ◎ (sym≋ (rinv≋ *≃×) ◎ id≋) ⟩ (×≃* ● ((×≃* ● (f ×≃ g) ● *≃×) ×≃ h)) ● (*≃× ● ×≃*) ● (×≃* ×≃ id≃ ● αmno ● id≃ ×≃ *≃× ● *≃×) ≋⟨ id≋ ◎ ●-assoc ⟩ ((×≃* ● ((×≃* ● (f ×≃ g) ● *≃×) ×≃ h))) ● (*≃× ● ×≃* ● ×≃* ×≃ id≃ ● αmno ● id≃ ×≃ *≃× ● *≃×) ≋⟨ ●-assocl ⟩ ((×≃* ● ((×≃* ● (f ×≃ g) ● *≃×) ×≃ h)) ● *≃×) ● (×≃* ● ×≃* ×≃ id≃ ● αmno ● id≃ ×≃ *≃× ● *≃×) ≋⟨ ●-assoc ◎ id≋ ⟩ (×≃* ● ((×≃* ● (f ×≃ g) ● *≃×) ×≃ h) ● *≃×) ● (×≃* ● ×≃* ×≃ id≃ ● αmno ● id≃ ×≃ *≃× ● *≃×) ∎) where open ≋-Reasoning T*1-nat : ×≃* ×≃ id≃ ● (f ×≃ g) ×≃ h ≋ ((×≃* ● f ×≃ g ● *≃×) ● ×≃*) ×≃ (h ● id≃) T*1-nat = begin ( ×≃* ×≃ id≃ ● (f ×≃ g) ×≃ h ≋⟨ sym≋ (T.×●≋●×) ⟩ (×≃* ● f ×≃ g) ×≃ (id≃ ● h) ≋⟨ id≋ T.×≋ (trans≋ lid≋ (sym≋ rid≋))⟩ (×≃* ● f ×≃ g) ×≃ (h ● id≃) ≋⟨ trans≋ (intro-inv-r* ((×≃* ● f ×≃ g))) ●-assoc T.×≋ id≋ ⟩ ((×≃* ● f ×≃ g) ● *≃× ● ×≃*) ×≃ (h ● id≃) ≋⟨ trans≋ ●-assocl (●-assoc ◎ id≋) T.×≋ id≋ ⟩ ((×≃* ● f ×≃ g ● *≃×) ● ×≃*) ×≃ (h ● id≃) ∎) assocr₊-nat : {m n o m' n' o' : ℕ} {f : m fin≃ m'} {g : n fin≃ n'} {h : o fin≃ o'} → assocr* {m'} {n'} {o'} ● ((f *F g) *F h) ≋ (f *F (g *F h)) ● assocr* {m} {n} {o} assocr₊-nat {m} {n} {o} {m'} {n'} {o'} {f} {g} {h} = begin ( assocr* {m'} {n'} {o'} ● ((f *F g) *F h) ≋⟨ id≋ ⟩ sym≃ assocl* ● sym≃ (sym≃ ((f *F g) *F h)) ≋⟨ sym≋ (sym≃● {f = assocl*}) ⟩ sym≃ (sym≃ ((f *F g) *F h) ● assocl* {m'} {n'} {o'}) ≋⟨ flip≋ ((trans≋ sym*F (sym*F *≋ id≋ )) ◎ id≋) ⟩ sym≃ (((sym≃ f *F sym≃ g) *F sym≃ h) ● assocl* {m'}) ≋⟨ flip-sym≋ assocl⋆-nat ⟩ sym≃ (assocl* {m} {n} {o} ● (sym≃ f *F (sym≃ g *F sym≃ h))) ≋⟨ flip≋ (id≋ ◎ (trans≋ (id≋ *≋ (sym≋ sym*F)) (sym≋ sym*F))) ⟩ sym≃ ( assocl* ● sym≃ (f *F (g *F h))) ≋⟨ sym≃● ⟩ sym≃ (sym≃ (f *F (g *F h))) ● sym≃ (assocl* {m} {n} {o}) ≋⟨ id≋ ⟩ (f *F (g *F h)) ● (assocr* {m} {n} {o}) ∎) where open ≋-Reasoning unite-assocr*-coh : {m n : ℕ} → unite*r {m = m} *F id≃ {A = Fin n} ≋ (id≃ {A = Fin m} *F unite* {m = n}) ● assocr* {m} {1} {n} unite-assocr*-coh = {!!} assocr*-coh : {m n o p : ℕ} → assocr* {m} {n} {o * p} ● assocr* {m * n} {o} {p} ≋ (id≃ {A = Fin m} *F assocr* {n} {o} {p}) ● assocr* {m} {n * o} {p} ● (assocr* {m} {n} {o} *F id≃ {A = Fin p}) assocr*-coh = {!!} swap*-nat : {m n o p : ℕ} {f : m fin≃ o} {g : n fin≃ p} → swap* {o} {p} ● (f *F g) ≋ (g *F f) ● swap* {m} {n} swap*-nat = {!!} sswap*-nat : {m n o p : ℕ} {f : m fin≃ o} {g : n fin≃ p} → sswap* {o} {p} ● (g *F f) ≋ (f *F g) ● sswap* {m} {n} sswap*-nat = {!!} assocr*-swap*-coh : {m n o : ℕ} → assocr* {n} {o} {m} ● swap* {m} {n * o} ● assocr* {m} {n} {o} ≋ (id≃ {A = Fin n} *F swap* {m} {o}) ● assocr* {n} {m} {o} ● (swap* {m} {n} *F id≃ {A = Fin o}) assocr*-swap*-coh = {!!} assocl*-swap*-coh : {m n o : ℕ} → assocl* {o} {m} {n} ● swap* {m * n} {o} ● assocl* {m} {n} {o} ≋ (swap* {m} {o} *F id≃ {A = Fin n}) ● assocl* {m} {o} {n} ● (id≃ {A = Fin m} *F swap* {n} {o}) assocl*-swap*-coh = {!!} ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.3363225676, "avg_line_length": 37.0775, "ext": "agda", "hexsha": "6aee1f7d9fbec2280d283dba68d8c3be3686ac26", "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/FinEquivEquivTimes.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/FinEquivEquivTimes.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/FinEquivEquivTimes.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": 9059, "size": 14831 }
-- Now you don't need a mutual keyword anymore! module Issue162 where data Odd : Set data Even : Set where zero : Even suc : Odd → Even data Odd where suc : Even → Odd -- This means you can have all kinds of things in -- mutual blocks. -- Like postulates _o+e_ : Odd → Even → Odd _e+e_ : Even → Even → Even zero e+e m = m suc n e+e m = suc (n o+e m) postulate todo : Even suc n o+e m = suc todo -- Or modules _e+o_ : Even → Odd → Odd _o+o_ : Odd → Odd → Even suc n o+o m = suc (n e+o m) module Helper where f : Even → Odd → Odd f zero m = m f (suc n) m = suc (n o+o m) n e+o m = Helper.f n m -- Multiplication just for the sake of it _o*o_ : Odd → Odd → Odd _e*o_ : Even → Odd → Even zero e*o m = zero suc n e*o m = m o+o (n o*o m) suc n o*o m = m o+e (n e*o m)
{ "alphanum_fraction": 0.603034134, "avg_line_length": 17.5777777778, "ext": "agda", "hexsha": "2f27cab5b76333f2659af032f70239ec8ad794d6", "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/Issue162.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/Issue162.agda", "max_line_length": 49, "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/Issue162.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": 305, "size": 791 }
module Data.Tuple.Proofs where import Lvl open import Data using (Unit ; <>) open import Data.Tuple as Tuple using (_⨯_ ; _,_) open import Data.Tuple.Equiv open import Function.Equals open import Logic.Predicate open import Logic.Propositional open import Structure.Function.Domain open import Structure.Function.Domain.Proofs open import Structure.Function open import Structure.Operator open import Structure.Relator.Properties open import Structure.Setoid open import Type private variable ℓ ℓₑ ℓₑ₁ ℓₑ₂ ℓₑ₃ ℓₑ₄ ℓₑ₅ ℓₑ₆ : Lvl.Level private variable A B A₁ B₁ A₂ B₂ : Type{ℓ} private variable f g : A → B private variable p : A ⨯ B module _ ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄ ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ ⦃ equiv-AB : Equiv{ℓₑ}(A ⨯ B) ⦄ ⦃ ext-AB : Extensionality(equiv-AB) ⦄ where open Extensionality(ext-AB) [,]-left-right-inverses : ∀{x : A ⨯ B} → ((Tuple.left x , Tuple.right x) ≡ x) [,]-left-right-inverses {_ , _} = reflexivity(_≡_) left-right-[,]-inverses : ∀{a : A}{b : B} → ((Tuple.left(a , b) ≡ a) ∧ (Tuple.right(a , b) ≡ b)) left-right-[,]-inverses = [∧]-intro (reflexivity(_≡_)) (reflexivity(_≡_)) instance [,]ₗ-injective : ∀{r : B} → Injective(_, r) Injective.proof [,]ₗ-injective = congruence₁(Tuple.left) instance [,]ᵣ-injective : ∀{l : A} → Injective(l ,_) Injective.proof [,]ᵣ-injective = congruence₁(Tuple.right) module _ ⦃ equiv-A₁ : Equiv{ℓₑ₁}(A₁) ⦄ ⦃ equiv-B₁ : Equiv{ℓₑ₂}(B₁) ⦄ ⦃ equiv-A₂ : Equiv{ℓₑ₃}(A₂) ⦄ ⦃ equiv-B₂ : Equiv{ℓₑ₄}(B₂) ⦄ ⦃ equiv-AB₁ : Equiv{ℓₑ₅}(A₁ ⨯ B₁) ⦄ ⦃ equiv-AB₁ : Extensionality(equiv-AB₁) ⦄ ⦃ equiv-AB₂ : Equiv{ℓₑ₆}(A₂ ⨯ B₂) ⦄ ⦃ equiv-AB₂ : Extensionality(equiv-AB₂) ⦄ {f : A₁ → A₂} {g : B₁ → B₂} where instance map-function : BinaryOperator(Tuple.map {A₁ = A₁}{A₂ = A₂}{B₁ = B₁}{B₂ = B₂}) _⊜_.proof (BinaryOperator.congruence map-function (intro eq₁) (intro eq₂)) {_ , _} = congruence₂(_,_) eq₁ eq₂ instance map-injective : ⦃ inj-f : Injective(f) ⦄ → ⦃ inj-g : Injective(g) ⦄ → Injective(Tuple.map f g) Injective.proof map-injective {_ , _} {_ , _} p = congruence₂(_,_) (injective(f) (congruence₁(Tuple.left) p)) (injective(g) (congruence₁(Tuple.right) p)) instance map-surjective : ⦃ surj-f : Surjective(f) ⦄ → ⦃ surj-g : Surjective(g) ⦄ → Surjective(Tuple.map f g) ∃.witness (Surjective.proof map-surjective {l , r}) = ([∃]-witness(surjective(f) {l}) , [∃]-witness(surjective(g) {r})) ∃.proof (Surjective.proof map-surjective {l , r}) = congruence₂(_,_) ([∃]-proof(surjective(f) {l})) ([∃]-proof(surjective(g) {r})) instance map-bijective : ⦃ bij-f : Bijective(f) ⦄ → ⦃ bij-g : Bijective(g) ⦄ → Bijective(Tuple.map f g) map-bijective = injective-surjective-to-bijective(Tuple.map f g) where instance inj-f : Injective(f) inj-f = bijective-to-injective(f) instance inj-g : Injective(g) inj-g = bijective-to-injective(g) instance surj-f : Surjective(f) surj-f = bijective-to-surjective(f) instance surj-g : Surjective(g) surj-g = bijective-to-surjective(g)
{ "alphanum_fraction": 0.6382087629, "avg_line_length": 37.3975903614, "ext": "agda", "hexsha": "fccd20fc24a6f0fec1eb59df70a1d125813f1f51", "lang": "Agda", "max_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": "Data/Tuple/Proofs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Data/Tuple/Proofs.agda", "max_line_length": 157, "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": "Data/Tuple/Proofs.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 1215, "size": 3104 }
{-# OPTIONS --without-K #-} open import HoTT module homotopy.JoinComm where module _ {i j} {A : Type i} {B : Type j} where swap : A * B → B * A swap = Swap.f module _ where swap-glue : (a : A) (b : B) → right a == left b swap-glue a b = ! (glue (b , a)) module Swap = PushoutRec right left (uncurry swap-glue) {- ∞TT: swap : A * B → B * A swap (left a) = right a swap (right b) = left b ap swap (glue (a , b)) = ! (glue (b , a)) -} module _ {i j} {A : Type i} {B : Type j} where swap-swap : (x : A * B) → swap (swap x) == x swap-swap = Pushout-elim (λ a → idp) (λ b → idp) (λ c → ↓-∘=idf-in swap swap (swap-swap-glue c)) where swap-swap-glue : (c : A × B) → ap swap (ap swap (glue c)) == glue c swap-swap-glue (a , b) = ap swap (ap swap (glue (a , b))) =⟨ Swap.glue-β (a , b) |in-ctx ap swap ⟩ ap swap (! (glue (b , a))) =⟨ ap-! swap (glue (b , a)) ⟩ ! (ap swap (glue (b , a))) =⟨ Swap.glue-β (b , a) |in-ctx ! ⟩ ! (! (glue (a , b))) =⟨ !-! (glue (a , b)) ⟩ glue (a , b) ∎ {- ∞TT: swap-swap : (x : A * B) → swap (swap x) == x swap-swap (left a) = idp swap-swap (right b) = idp apd swap-swap (glue (a , b)) = !-! (glue (a , b)) -} module _ {i j} {A : Type i} {B : Type j} where swap-equiv : (A * B) ≃ (B * A) swap-equiv = equiv swap swap swap-swap swap-swap swap-path : (A * B) == (B * A) swap-path = ua swap-equiv
{ "alphanum_fraction": 0.4893029676, "avg_line_length": 26.8333333333, "ext": "agda", "hexsha": "f91ef98474ed2bbda518ab1b40e345372f7c1cd8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/JoinComm.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "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": "cmknapp/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/JoinComm.agda", "max_line_length": 81, "max_stars_count": null, "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/JoinComm.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 596, "size": 1449 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties satisfied by bounded lattice ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary.Lattice module Relation.Binary.Properties.BoundedLattice {c ℓ₁ ℓ₂} (L : BoundedLattice c ℓ₁ ℓ₂) where open BoundedLattice L open import Algebra.FunctionProperties _≈_ open import Data.Product using (_,_) open import Relation.Binary using (Setoid) open import Relation.Binary.Properties.MeetSemilattice meetSemilattice open import Relation.Binary.Properties.JoinSemilattice joinSemilattice open Setoid setoid renaming (trans to ≈-trans) ∧-zeroʳ : RightZero ⊥ _∧_ ∧-zeroʳ x = y≤x⇒x∧y≈y (minimum x) ∧-zeroˡ : LeftZero ⊥ _∧_ ∧-zeroˡ x = ≈-trans (∧-comm ⊥ x) (∧-zeroʳ x) ∧-zero : Zero ⊥ _∧_ ∧-zero = ∧-zeroˡ , ∧-zeroʳ ∨-zeroʳ : RightZero ⊤ _∨_ ∨-zeroʳ x = x≤y⇒x∨y≈y (maximum x) ∨-zeroˡ : LeftZero ⊤ _∨_ ∨-zeroˡ x = ≈-trans (∨-comm ⊤ x) (∨-zeroʳ x) ∨-zero : Zero ⊤ _∨_ ∨-zero = ∨-zeroˡ , ∨-zeroʳ
{ "alphanum_fraction": 0.6029411765, "avg_line_length": 26.5365853659, "ext": "agda", "hexsha": "8400aee1d572f8e632c216825f70fb937ef961d8", "lang": "Agda", "max_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/Relation/Binary/Properties/BoundedLattice.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/Relation/Binary/Properties/BoundedLattice.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/Relation/Binary/Properties/BoundedLattice.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 374, "size": 1088 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) module Boolean.Definition where data Bool : Set where BoolTrue : Bool BoolFalse : Bool {-# BUILTIN BOOL Bool #-} {-# BUILTIN TRUE BoolTrue #-} {-# BUILTIN FALSE BoolFalse #-} if_then_else_ : {a : _} → {A : Set a} → Bool → A → A → A if BoolTrue then tr else fls = tr if BoolFalse then tr else fls = fls not : Bool → Bool not BoolTrue = BoolFalse not BoolFalse = BoolTrue boolAnd : Bool → Bool → Bool boolAnd BoolTrue y = y boolAnd BoolFalse y = BoolFalse boolOr : Bool → Bool → Bool boolOr BoolTrue y = BoolTrue boolOr BoolFalse y = y xor : Bool → Bool → Bool xor BoolTrue BoolTrue = BoolFalse xor BoolTrue BoolFalse = BoolTrue xor BoolFalse b = b
{ "alphanum_fraction": 0.6908150065, "avg_line_length": 22.7352941176, "ext": "agda", "hexsha": "d27015c58418edd509071ced38381107ed7336d5", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Boolean/Definition.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Boolean/Definition.agda", "max_line_length": 58, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Boolean/Definition.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 236, "size": 773 }
module root2 where open import Data.Nat open import Data.Nat.Properties open import Data.Empty open import Data.Unit using (⊤ ; tt) open import Relation.Nullary open import Relation.Binary.PropositionalEquality open import Relation.Binary.Definitions import gcd as GCD open import even open import nat open import logic record Rational : Set where field i j : ℕ coprime : GCD.gcd i j ≡ 1 -- record Dividable (n m : ℕ ) : Set where -- field -- factor : ℕ -- is-factor : factor * n + 0 ≡ m gcd : (i j : ℕ) → ℕ gcd = GCD.gcd gcd-euclid : ( p a b : ℕ ) → 1 < p → 0 < a → 0 < b → ((i : ℕ ) → i < p → 0 < i → gcd p i ≡ 1) → Dividable p (a * b) → Dividable p a ∨ Dividable p b gcd-euclid = GCD.gcd-euclid gcd-div1 : ( i j k : ℕ ) → k > 1 → (if : Dividable k i) (jf : Dividable k j ) → Dividable k ( gcd i j ) gcd-div1 = GCD.gcd-div open _∧_ open import prime divdable^2 : ( n k : ℕ ) → 1 < k → 1 < n → Prime k → Dividable k ( n * n ) → Dividable k n divdable^2 zero zero () 1<n pk dn2 divdable^2 (suc n) (suc k) 1<k 1<n pk dn2 with decD {suc k} {suc n} 1<k ... | yes y = y ... | no non with gcd-euclid (suc k) (suc n) (suc n) 1<k (<-trans a<sa 1<n) (<-trans a<sa 1<n) (Prime.isPrime pk) dn2 ... | case1 dn = dn ... | case2 dm = dm -- p * n * n ≡ m * m means (m/n)^2 = p -- rational m/n requires m and n is comprime each other which contradicts the condition root-prime-irrational : ( n m p : ℕ ) → n > 1 → Prime p → m > 1 → p * n * n ≡ m * m → ¬ (gcd n m ≡ 1) root-prime-irrational n m 0 n>1 pn m>1 pnm = ⊥-elim ( nat-≡< refl (<-trans a<sa (Prime.p>1 pn))) root-prime-irrational n m (suc p0) n>1 pn m>1 pnm = rot13 ( gcd-div1 n m (suc p0) 1<sp dn dm ) where p = suc p0 1<sp : 1 < p 1<sp = Prime.p>1 pn rot13 : {m : ℕ } → Dividable (suc p0) m → m ≡ 1 → ⊥ rot13 d refl with Dividable.factor d | Dividable.is-factor d ... | zero | () -- gcd 0 m ≡ 1 ... | suc n | x = ⊥-elim ( nat-≡< (sym x) rot17 ) where -- x : (suc n * p + 0) ≡ 1 rot17 : suc n * (suc p0) + 0 > 1 rot17 = begin 2 ≡⟨ refl ⟩ suc (1 * 1 ) ≤⟨ 1<sp ⟩ suc p0 ≡⟨ cong suc (+-comm 0 _) ⟩ suc (p0 + 0) ≤⟨ s≤s (+-monoʳ-≤ p0 z≤n) ⟩ suc (p0 + n * p ) ≡⟨ +-comm 0 _ ⟩ suc n * p + 0 ∎ where open ≤-Reasoning dm : Dividable p m dm = divdable^2 m p 1<sp m>1 pn record { factor = n * n ; is-factor = begin (n * n) * p + 0 ≡⟨ +-comm _ 0 ⟩ (n * n) * p ≡⟨ *-comm (n * n) p ⟩ p * (n * n) ≡⟨ sym (*-assoc p n n) ⟩ (p * n) * n ≡⟨ pnm ⟩ m * m ∎ } where open ≡-Reasoning -- p * n * n = 2m' 2m' -- n * n = m' 2m' df = Dividable.factor dm dn : Dividable p n dn = divdable^2 n p 1<sp n>1 pn record { factor = df * df ; is-factor = begin df * df * p + 0 ≡⟨ *-cancelʳ-≡ _ _ {p0} ( begin (df * df * p + 0) * p ≡⟨ cong (λ k → k * p) (+-comm (df * df * p) 0) ⟩ ((df * df) * p ) * p ≡⟨ cong (λ k → k * p) (*-assoc df df p ) ⟩ (df * (df * p)) * p ≡⟨ cong (λ k → (df * k ) * p) (*-comm df p) ⟩ (df * (p * df)) * p ≡⟨ sym ( cong (λ k → k * p) (*-assoc df p df ) ) ⟩ ((df * p) * df) * p ≡⟨ *-assoc (df * p) df p ⟩ (df * p) * (df * p) ≡⟨ cong₂ (λ j k → j * k ) (+-comm 0 (df * p)) (+-comm 0 _) ⟩ (df * p + 0) * (df * p + 0) ≡⟨ cong₂ (λ j k → j * k) (Dividable.is-factor dm ) (Dividable.is-factor dm )⟩ m * m ≡⟨ sym pnm ⟩ p * n * n ≡⟨ cong (λ k → k * n) (*-comm p n) ⟩ n * p * n ≡⟨ *-assoc n p n ⟩ n * (p * n) ≡⟨ cong (λ k → n * k) (*-comm p n) ⟩ n * (n * p) ≡⟨ sym (*-assoc n n p) ⟩ n * n * p ∎ ) ⟩ n * n ∎ } where open ≡-Reasoning Rational* : (r s : Rational) → Rational Rational* r s = record { i = {!!} ; j = {!!} ; coprime = {!!} } _r=_ : Rational → ℕ → Set r r= n = (Rational.i r ≡ n) ∧ (Rational.j r ≡ 1) root-prime-irrational1 : ( p : ℕ ) → Prime p → ¬ ( ( r : Rational ) → Rational* r r r= p ) root-prime-irrational1 = {!!}
{ "alphanum_fraction": 0.4777506112, "avg_line_length": 38.5849056604, "ext": "agda", "hexsha": "1722dbc7fa3a59a121075bf6a960bcb291897301", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/automaton-in-agda", "max_forks_repo_path": "src/root2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "shinji-kono/automaton-in-agda", "max_issues_repo_path": "src/root2.agda", "max_line_length": 118, "max_stars_count": null, "max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/automaton-in-agda", "max_stars_repo_path": "src/root2.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1772, "size": 4090 }
module Data.List.Proofs where import Lvl open import Functional open import Data.Option using (Option ; Some ; None) open import Data.List open import Data.List.Equiv open import Data.List.Functions open import Logic open import Numeral.Natural open import Numeral.Natural.Oper open import Numeral.Natural.Oper.Proofs open import Relator.Equals renaming (_≡_ to _≡ₑ_ ; _≢_ to _≢ₑ_) open import Structure.Function open import Structure.Function.Domain open import Structure.Function.Multi import Structure.Function.Names as Names import Structure.Operator.Names as Names open import Structure.Operator.Proofs.Util open import Structure.Operator.Properties open import Structure.Operator open import Structure.Relator.Properties open import Structure.Setoid open import Syntax.Transitivity open import Type private variable ℓ ℓₑ ℓₑₗ ℓₑₒ ℓₑ₁ ℓₑ₂ ℓₑₗ₁ ℓₑₗ₂ : Lvl.Level private variable T A B : Type{ℓ} private variable n : ℕ module _ ⦃ equiv : Equiv{ℓₑ}(T) ⦄ ⦃ equiv-List : Equiv{ℓₑₗ}(List(T)) ⦄ ⦃ extensionality : Extensionality(equiv-List) ⦄ where private variable l l₁ l₂ : List(T) private variable a b x : T private variable P : List(T) → Stmt{ℓ} open Equiv(equiv-List) using () renaming (_≡_ to _≡ₗ_) instance tail-function : Function(tail) Function.congruence tail-function {∅} {∅} p = p Function.congruence tail-function {∅} {x ⊰ y} p with () ← [∅][⊰]-unequal p Function.congruence tail-function {x ⊰ xl} {∅} p with () ← [∅][⊰]-unequal (symmetry(_≡_) p) Function.congruence tail-function {x ⊰ xl} {y ⊰ yl} p = [⊰]-generalized-cancellationₗ p instance first-function : ⦃ equiv-Option : Equiv{ℓₑₒ}(Option(T)) ⦄ ⦃ Some-function : Function(Some) ⦄ → Function(first) Function.congruence first-function {∅} {∅} p = reflexivity(_≡_) Function.congruence first-function {∅} {y ⊰ yl} p with () ← [∅][⊰]-unequal p Function.congruence first-function {x ⊰ xl} {∅} p with () ← [∅][⊰]-unequal (symmetry(_≡_) p) Function.congruence first-function {x ⊰ xl} {y ⊰ yl} p = congruence₁(Some) ([⊰]-generalized-cancellationᵣ p) instance [⊰]-cancellationₗ : Cancellationₗ(_⊰_) Cancellationₗ.proof([⊰]-cancellationₗ) = [⊰]-generalized-cancellationₗ instance [⊰]-cancellationᵣ : Cancellationᵣ(_⊰_) Cancellationᵣ.proof([⊰]-cancellationᵣ) = [⊰]-generalized-cancellationᵣ [⊰]-unequal : (x ⊰ l ≢ l) [⊰]-unequal {l = ∅} = [∅][⊰]-unequal ∘ symmetry(_≡_) [⊰]-unequal {l = x ⊰ l} = [⊰]-unequal {l = l} ∘ [⊰]-generalized-cancellationₗ postpend-of-prepend : (postpend a (b ⊰ l) ≡ b ⊰ postpend a l) postpend-of-prepend = reflexivity(_≡_) instance postpend-function : BinaryOperator(postpend) postpend-function = intro p where p : Names.Congruence₂(postpend) p {x₂ = ∅} {y₂ = ∅} px pl = congruence₂(_⊰_) px pl p {x₂ = ∅} {y₂ = y₂ ⊰ yl₂} px pl with () ← [∅][⊰]-unequal pl p {x₂ = x₂ ⊰ xl₂} {y₂ = ∅} px pl with () ← [∅][⊰]-unequal (symmetry(_≡_) pl) p {x₂ = x₂ ⊰ xl₂} {y₂ = y₂ ⊰ yl₂} px pl = congruence₂(_⊰_) ([⊰]-generalized-cancellationᵣ pl) (p{x₂ = xl₂} {y₂ = yl₂} px ([⊰]-generalized-cancellationₗ pl)) instance reverse-function : Function(reverse) reverse-function = intro p where p : Names.Congruence₁(reverse) p {∅} {∅} pl = reflexivity(_≡_) p {∅} {y ⊰ yl} pl with () ← [∅][⊰]-unequal pl p {x ⊰ xl} {∅} pl with () ← [∅][⊰]-unequal (symmetry(_≡_) pl) p {x ⊰ xl} {y ⊰ yl} pl = congruence₂(postpend) ([⊰]-generalized-cancellationᵣ pl) (p([⊰]-generalized-cancellationₗ pl)) instance [++]-identityₗ : Identityₗ(_++_) ∅ Identityₗ.proof([++]-identityₗ) = reflexivity(_≡_) instance [++]-identityᵣ : Identityᵣ(_++_) ∅ Identityᵣ.proof([++]-identityᵣ) {x = l} = elim (reflexivity(_≡_)) (\x l → congruence₂ᵣ(_⊰_)(x) {l ++ ∅}{l}) l instance [++]-associativity : Associativity(_++_) Associativity.proof([++]-associativity) {l₁}{l₂}{l₃} = elim (reflexivity(_≡_)) (\x l → congruence₂ᵣ(_⊰_)(x) {(l ++ l₂) ++ l₃}{l ++ (l₂ ++ l₃)}) l₁ reverse-postpend : (reverse(postpend a l) ≡ a ⊰ reverse l) reverse-postpend {a = a}{l = l} = elim (reflexivity(_≡ₗ_)) (\x l p → congruence₂ᵣ(postpend) ⦃ postpend-function ⦄ (x) {reverse(postpend a l)}{a ⊰ reverse l} p) l prepend-[++] : (a ⊰ l ≡ singleton{T = T}(a) ++ l) prepend-[++] = reflexivity(_≡_) postpend-[++] : (postpend{T = T} a l ≡ l ++ singleton(a)) postpend-[++] {a = a}{l = l} = elim (reflexivity(_≡_)) (\x l → congruence₂ᵣ(_⊰_)(x) {postpend a l}{l ++ (singleton a)}) l postpend-of-[++] : (postpend{T = T} a (l₁ ++ l₂) ≡ l₁ ++ postpend a l₂) postpend-of-[++] {a = a} {l₁}{l₂} = elim (reflexivity(_≡_)) (\x l → congruence₂ᵣ(_⊰_)(x) {postpend a (l ++ l₂)}{l ++ (postpend a l₂)}) l₁ reverse-[++] : (reverse(l₁ ++ l₂) ≡ reverse(l₂) ++ reverse(l₁)) reverse-[++] {l₁ = l₁} {l₂ = l₂} = elim (congruence₁(reverse) (identityₗ(_++_)(∅) {l₂}) 🝖 symmetry(_≡_) (identityᵣ(_++_)(∅) {reverse l₂})) (\x l₁ p → congruence₂ᵣ(postpend) ⦃ postpend-function ⦄ (x) {reverse (l₁ ++ l₂)}{reverse l₂ ++ reverse l₁} p 🝖 postpend-of-[++] {l₁ = reverse l₂} {l₂ = reverse l₁}) l₁ [∅]-postpend-unequal : (postpend x l ≢ ∅) [∅]-postpend-unequal {l = ∅} = [∅][⊰]-unequal ∘ symmetry(_≡_) [∅]-postpend-unequal {l = _ ⊰ l} = [∅][⊰]-unequal ∘ symmetry(_≡_) postpend-unequal : (postpend x l ≢ l) postpend-unequal {l = ∅} = [∅][⊰]-unequal ∘ symmetry(_≡_) postpend-unequal {l = y ⊰ l} = postpend-unequal {l = l} ∘ cancellationₗ(_⊰_) [++]-middle-prepend-postpend : postpend x l₁ ++ l₂ ≡ l₁ ++ (x ⊰ l₂) [++]-middle-prepend-postpend {l₁ = ∅} {l₂ = ∅} = reflexivity(_≡_) [++]-middle-prepend-postpend {l₁ = ∅} {l₂ = x ⊰ l₂} = reflexivity(_≡_) [++]-middle-prepend-postpend {l₁ = x ⊰ l₁} {l₂ = l₂} = congruence₂ᵣ(_⊰_)(x) ([++]-middle-prepend-postpend {l₁ = l₁} {l₂ = l₂}) instance [++]-cancellationₗ : Cancellationₗ(_++_) Cancellationₗ.proof [++]-cancellationₗ {x}{y}{z} = proof {x}{y}{z} where proof : Names.Cancellationₗ (_++_) proof {∅} p = p proof {x ⊰ l} p = proof {l} (cancellationₗ(_⊰_) p) instance [++]-cancellationᵣ : Cancellationᵣ(_++_) Cancellationᵣ.proof([++]-cancellationᵣ) {a}{b} = proof {a}{b} where proof : Names.Cancellationᵣ(_++_) proof {z} {∅} {∅} p = reflexivity(_≡_) proof {z} {x ⊰ xl} {y ⊰ yl} p = congruence₂(_⊰_) ([⊰]-generalized-cancellationᵣ p) (proof {z}{xl}{yl} ([⊰]-generalized-cancellationₗ p)) proof {∅} {∅} {y ⊰ yl} p with () ← [∅][⊰]-unequal {l = yl} (p 🝖 identityᵣ(_++_)(∅)) proof {z ⊰ zl} {∅} {y ⊰ yl} p with () ← [∅]-postpend-unequal(symmetry(_≡_) (proof{zl}{∅}{postpend z yl} ([⊰]-generalized-cancellationₗ p 🝖 symmetry(_≡_) ([++]-middle-prepend-postpend {x = z}{l₁ = yl}{l₂ = zl})))) proof {∅} {x ⊰ xl} {∅} p with () ← [∅][⊰]-unequal {l = xl} (symmetry(_≡_) p 🝖 identityᵣ(_++_)(∅)) proof {z ⊰ zl} {x ⊰ xl} {∅} p with () ← [∅]-postpend-unequal(proof{zl}{postpend z xl}{∅} ([++]-middle-prepend-postpend {x = z}{l₁ = xl}{l₂ = zl} 🝖 [⊰]-generalized-cancellationₗ p)) reverse-involution-raw : Names.Involution(reverse{T = T}) reverse-involution-raw {x = ∅} = reflexivity(_≡_) reverse-involution-raw {x = x ⊰ l} = reverse-postpend {a = x}{l = reverse l} 🝖 congruence₂ᵣ(_⊰_)(x) (reverse-involution-raw {x = l}) instance reverse-involution : Involution(reverse{T = T}) Involution.proof reverse-involution = reverse-involution-raw initial-of-∅ : (initial(n)(∅ {T = T}) ≡ ∅) initial-of-∅ {n = 𝟎} = reflexivity(_≡_) initial-of-∅ {n = 𝐒(n)} = reflexivity(_≡_) module _ where open import Relator.Equals.Proofs.Equiv {T = ℕ} foldᵣ-constant-[+]ᵣ : ∀{init step} → (foldᵣ (const(_+ step)) init l ≡ₑ (step ⋅ length(l)) + init) foldᵣ-constant-[+]ᵣ {l = ∅} = reflexivity(_≡ₑ_) foldᵣ-constant-[+]ᵣ {l = x ⊰ l} {init}{step} = const(_+ step) x (foldᵣ (const(_+ step)) init l) 🝖[ _≡_ ]-[] (foldᵣ (const(_+ step)) init l) + step 🝖[ _≡_ ]-[ congruence₁(_+ step) (foldᵣ-constant-[+]ᵣ {l = l} {init}{step}) ] ((step ⋅ length(l)) + init) + step 🝖[ _≡_ ]-[ One.commuteᵣ-assocₗ {a = step ⋅ length(l)}{init}{step} ] ((step ⋅ length(l)) + step) + init 🝖[ _≡_ ]-[ congruence₁(_+ init) (commutativity(_+_) {step ⋅ length(l)}{step}) ] (step + (step ⋅ length(l))) + init 🝖-end foldᵣ-constant-[+]ₗ : ∀{init step} → (foldᵣ (const(step +_)) init l ≡ (length(l) ⋅ step) + init) foldᵣ-constant-[+]ₗ {l = ∅} = reflexivity(_≡_) foldᵣ-constant-[+]ₗ {l = x ⊰ l} {init}{step} = foldᵣ(const(step +_)) init (x ⊰ l) 🝖[ _≡_ ]-[] step + foldᵣ(const(step +_)) init l 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)(step) (foldᵣ-constant-[+]ₗ {l = l} {init}{step}) ] step + ((length(l) ⋅ step) + init) 🝖[ _≡_ ]-[ associativity(_+_) {step}{length(l) ⋅ step}{init} ]-sym (step + (length(l) ⋅ step)) + init 🝖[ _≡_ ]-[ congruence₂ₗ(_+_)(init) (commutativity(_+_) {step}{length(l) ⋅ step}) ] ((length(l) ⋅ step) + step) + init 🝖[ _≡_ ]-[ congruence₂ₗ(_+_)(init) ([⋅]-with-[𝐒]ₗ {length(l)}{step}) ]-sym (𝐒(length(l)) ⋅ step) + init 🝖[ _≡_ ]-[] (length(x ⊰ l) ⋅ step) + init 🝖-end open import Structure.Setoid module _ ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄ ⦃ equiv-List₁ : Equiv{ℓₑₗ₁}(List(A)) ⦄ ⦃ extensionality-A : Extensionality(equiv-List₁) ⦄ ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ ⦃ equiv-List₂ : Equiv{ℓₑₗ₂}(List(B)) ⦄ ⦃ extensionality-B : Extensionality(equiv-List₂) ⦄ where private variable l l₁ l₂ : List(T) private variable a b x : T private variable P : List(T) → Stmt{ℓ} private variable f : A → B map-postpend : (map f(postpend a l) ≡ postpend (f(a)) (map f(l))) map-postpend {f = f} {a = a}{l = l} = elim (reflexivity(_≡_)) (\x l → congruence₂ᵣ(_⊰_)(f(x)) {map f (postpend a l)}{postpend (f(a)) (map f l)}) l instance map-preserves-[++] : Preserving₂(map f)(_++_)(_++_) Preserving.proof (map-preserves-[++] {f = f}) {l₁} {l₂} = elim (reflexivity(_≡_)) (\x l₁ → congruence₂ᵣ(_⊰_)(f(x)) {map f(l₁ ++ l₂)}{(map f l₁) ++ (map f l₂)}) l₁
{ "alphanum_fraction": 0.5858219916, "avg_line_length": 51.3216080402, "ext": "agda", "hexsha": "9c983bc46321bf53f54e35badad8d33e97a05edb", "lang": "Agda", "max_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": "Data/List/Proofs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Data/List/Proofs.agda", "max_line_length": 223, "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": "Data/List/Proofs.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 4216, "size": 10213 }
{-# OPTIONS --safe #-} {-# OPTIONS --sized-types #-} module ++-Identity where open import Size -- +-identityʳ : ∀ (n : ℕ) → n + 0 ≅ n -- +-identityʳ zero = refl -- +-identityʳ (suc n) = cong suc (+-identityʳ n) -- ∷-≅ : ∀ {m n : ℕ} {A : Set} (x : A) (xs : Vec A m) (ys : Vec A n) → m ≅ n → xs ≅ ys → (x ∷ xs) ≅ (x ∷ ys) -- ∷-≅ x xs .xs refl refl = refl -- ++-identityʳ : ∀ {n} {A : Set} (xs : Vec A n) → xs ++ [] ≅ xs -- ++-identityʳ {.0} {A} [] = refl -- ++-identityʳ {suc n} {A} (x ∷ xs) = ∷-≅ x (xs ++ []) xs (+-identityʳ n) (++-identityʳ xs) data Nat : {i : Size} -> Set where zero : {i : Size} -> Nat {↑ i} suc : {i : Size} -> Nat {i} -> Nat {↑ i} sub : {i : Size} -> Nat {i} -> Nat {∞} -> Nat {i} sub zero n = zero sub (suc m) zero = suc m sub (suc m) (suc n) = sub m n div : {i : Size} -> Nat {i} -> Nat -> Nat {i} div zero n = zero div (suc m) n = suc (div (sub m n) n)
{ "alphanum_fraction": 0.4707865169, "avg_line_length": 29.6666666667, "ext": "agda", "hexsha": "7af0dfd1f90491b8c94bf34f5f0cfe07c8a4375f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Brethland/LEARNING-STUFF", "max_forks_repo_path": "Agda/++-Identity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "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": "Brethland/LEARNING-STUFF", "max_issues_repo_path": "Agda/++-Identity.agda", "max_line_length": 108, "max_stars_count": 2, "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Brethland/LEARNING-STUFF", "max_stars_repo_path": "Agda/++-Identity.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z", "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z", "num_tokens": 388, "size": 890 }
{-# OPTIONS --warning=error --safe --without-K #-} open import Boolean.Definition open import LogicalFormulae open import Decidable.Lemmas module Numbers.Naturals.Definition where data ℕ : Set where zero : ℕ succ : ℕ → ℕ infix 100 succ {-# BUILTIN NATURAL ℕ #-} succInjective : {a b : ℕ} → (succ a ≡ succ b) → a ≡ b succInjective {a} {.a} refl = refl naughtE : {a : ℕ} → zero ≡ succ a → False naughtE () aIsNotSuccA : (a : ℕ) → (a ≡ succ a) → False aIsNotSuccA zero pr = naughtE pr aIsNotSuccA (succ a) pr = aIsNotSuccA a (succInjective pr) ℕDecideEquality : (a b : ℕ) → ((a ≡ b) || ((a ≡ b) → False)) ℕDecideEquality zero zero = inl refl ℕDecideEquality zero (succ b) = inr (λ ()) ℕDecideEquality (succ a) zero = inr (λ ()) ℕDecideEquality (succ a) (succ b) with ℕDecideEquality a b ℕDecideEquality (succ a) (succ b) | inl x = inl (applyEquality succ x) ℕDecideEquality (succ a) (succ b) | inr x = inr λ pr → x (succInjective pr) ℕDecideEquality' : (a b : ℕ) → Bool ℕDecideEquality' a b with ℕDecideEquality a b ℕDecideEquality' a b | inl x = BoolTrue ℕDecideEquality' a b | inr x = BoolFalse record _=N'_ (a b : ℕ) : Set where field .eq : a ≡ b squashN : {a b : ℕ} → a =N' b → a ≡ b squashN record { eq = eq } = squash ℕDecideEquality eq collapseN : {a b : ℕ} → a ≡ b → a =N' b collapseN refl = record { eq = refl } =N'Refl : {a b : ℕ} → (p1 p2 : a =N' b) → p1 ≡ p2 =N'Refl p1 p2 = refl
{ "alphanum_fraction": 0.6426043878, "avg_line_length": 27.1730769231, "ext": "agda", "hexsha": "2263738d62f6598ee28eb16851293a3e88944048", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Numbers/Naturals/Definition.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Numbers/Naturals/Definition.agda", "max_line_length": 75, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Numbers/Naturals/Definition.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 546, "size": 1413 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Base.Types open import LibraBFT.Impl.OBM.Rust.Duration as Duration open import LibraBFT.Impl.OBM.Rust.RustTypes open import LibraBFT.ImplShared.Base.Types open import LibraBFT.ImplShared.Consensus.Types open import Optics.All open import Util.Prelude module LibraBFT.Impl.Consensus.Liveness.ExponentialTimeInterval where new : Duration → F64 → Usize → ExponentialTimeInterval new base exponentBase maxExponent = {- TODO-1 if | maxExponent >= 32 -> errorExit [ "ExponentialTimeInterval", "new" , "maxExponent for PacemakerTimeInterval should be < 32", show maxExponent ] | ceiling (exponentBase ** fromIntegral maxExponent) >= {-F64-} (maxBound::Int) -> errorExit [ "ExponentialTimeInterval", "new" , "maximum interval multiplier should be less then u32::Max"] | otherwise -> -} mkExponentialTimeInterval (Duration.asMillis base) exponentBase maxExponent
{ "alphanum_fraction": 0.710483871, "avg_line_length": 38.75, "ext": "agda", "hexsha": "659edb63d8f0e5072c8b310d65bc8c005b94ba12", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_forks_repo_path": "src/LibraBFT/Impl/Consensus/Liveness/ExponentialTimeInterval.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_issues_repo_path": "src/LibraBFT/Impl/Consensus/Liveness/ExponentialTimeInterval.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_stars_repo_path": "src/LibraBFT/Impl/Consensus/Liveness/ExponentialTimeInterval.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 312, "size": 1240 }
module AllTests where import Issue14 import LanguageConstructs import Numbers import Pragmas import Sections import Test import Tuples import Where {-# FOREIGN AGDA2HS import Issue14 import LanguageConstructs import Numbers import Pragmas import Sections import Test import Tuples import Where #-}
{ "alphanum_fraction": 0.8405315615, "avg_line_length": 13.0869565217, "ext": "agda", "hexsha": "9178f10841766f9c91f26e3d6a1ec18fd1945e38", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "flupe/agda2hs", "max_forks_repo_path": "test/AllTests.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "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": "flupe/agda2hs", "max_issues_repo_path": "test/AllTests.agda", "max_line_length": 25, "max_stars_count": null, "max_stars_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "flupe/agda2hs", "max_stars_repo_path": "test/AllTests.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 76, "size": 301 }
-- Task: -- Try to compile a function that requires a proof as input. -- It should be similar to what exportSqrt does in the ℝ but -- for Nats (ℕ)
{ "alphanum_fraction": 0.7074829932, "avg_line_length": 29.4, "ext": "agda", "hexsha": "8854828a669816aeb9da7f6bb0d59d1a2ce75db8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "helq/old_code", "max_forks_repo_path": "proglangs-learning/Agda/reals-with-restrictions/playground.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z", "max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z", "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "helq/old_code", "max_issues_repo_path": "proglangs-learning/Agda/reals-with-restrictions/playground.agda", "max_line_length": 60, "max_stars_count": null, "max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "helq/old_code", "max_stars_repo_path": "proglangs-learning/Agda/reals-with-restrictions/playground.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 40, "size": 147 }
{-# OPTIONS --universe-polymorphism #-} module Categories.NaturalTransformation where open import Categories.Category open import Categories.Functor hiding (equiv) renaming (id to idF; _≡_ to _≡F_; _∘_ to _∘F_) open import Categories.NaturalTransformation.Core public infixr 9 _∘ˡ_ _∘ʳ_ _∘ˡ_ : ∀ {o₀ ℓ₀ e₀ o₁ ℓ₁ e₁ o₂ ℓ₂ e₂} → {C : Category o₀ ℓ₀ e₀} {D : Category o₁ ℓ₁ e₁} {E : Category o₂ ℓ₂ e₂} → {F G : Functor C D} → (H : Functor D E) → (η : NaturalTransformation F G) → NaturalTransformation (H ∘F F) (H ∘F G) _∘ˡ_ {C = C} {D} {E} {F} {G} H η′ = record { η = λ X → Functor.F₁ H (NaturalTransformation.η η′ X) ; commute = commute′ } where module C = Category C module D = Category D renaming (_∘_ to _∘D_; _≡_ to _≡D_) module E = Category E renaming (_∘_ to _∘E_; _≡_ to _≡E_) module H = Functor H open D open E .commute′ : ∀ {X Y} (f : C [ X , Y ]) → Functor.F₁ H (NaturalTransformation.η η′ Y) ∘E Functor.F₁ H (Functor.F₁ F f) ≡E Functor.F₁ H (Functor.F₁ G f) ∘E Functor.F₁ H (NaturalTransformation.η η′ X) commute′ {X} {Y} f = begin Functor.F₁ H (NaturalTransformation.η η′ Y) ∘E Functor.F₁ H (Functor.F₁ F f) ↑⟨ H.homomorphism ⟩ Functor.F₁ H (NaturalTransformation.η η′ Y ∘D Functor.F₁ F f) ↓⟨ H.F-resp-≡ (NaturalTransformation.commute η′ f) ⟩ Functor.F₁ H (Functor.F₁ G f ∘D NaturalTransformation.η η′ X) ↓⟨ H.homomorphism ⟩ Functor.F₁ H (Functor.F₁ G f) ∘E Functor.F₁ H (NaturalTransformation.η η′ X) ∎ where open E.HomReasoning _∘ʳ_ : ∀ {o₀ ℓ₀ e₀ o₁ ℓ₁ e₁ o₂ ℓ₂ e₂} → {C : Category o₀ ℓ₀ e₀} {D : Category o₁ ℓ₁ e₁} {E : Category o₂ ℓ₂ e₂} → {F G : Functor C D} → (η : NaturalTransformation F G) → (K : Functor E C) → NaturalTransformation (F ∘F K) (G ∘F K) _∘ʳ_ η K = record { η = λ X → NaturalTransformation.η η (Functor.F₀ K X) ; commute = λ f → NaturalTransformation.commute η (Functor.F₁ K f) } -- The vertical versions .identity₁ˡ : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {F G : Functor C D} {X : NaturalTransformation F G} → id ∘₁ X ≡ X identity₁ˡ {D = D} = Category.identityˡ D .identity₁ʳ : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {F G : Functor C D} {X : NaturalTransformation F G} → X ∘₁ id ≡ X identity₁ʳ {D = D} = Category.identityʳ D .assoc₁ : ∀ {o ℓ e o′ ℓ′ e′} {P : Category o ℓ e} {Q : Category o′ ℓ′ e′} {A B C D : Functor P Q} {X : NaturalTransformation A B} {Y : NaturalTransformation B C} {Z : NaturalTransformation C D} → (Z ∘₁ Y) ∘₁ X ≡ Z ∘₁ (Y ∘₁ X) assoc₁ {Q = Q} = Category.assoc Q -- The horizontal ones .identity₀ˡ : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {F G : Functor C D} {X : NaturalTransformation F G} → id {F = idF} ∘₀ X ≡ X identity₀ˡ {D = D} = Category.identityʳ D .identity₀ʳ : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {F G : Functor C D} {X : NaturalTransformation F G} → X ∘₀ id {F = idF} ≡ X identity₀ʳ {C = C} {D} {F} {G} {X} = begin G₁ C.id ∘ (η _) ↓⟨ ∘-resp-≡ˡ G.identity ⟩ D.id ∘ (η _) ↓⟨ D.identityˡ ⟩ η _ ∎ where module C = Category C module D = Category D module F = Functor F module G = Functor G renaming (F₀ to G₀; F₁ to G₁; F-resp-≡ to G-resp-≡) open NaturalTransformation X open D.HomReasoning open F open G open D open import Categories.Functor.Core using () renaming ( _∘_ to _∘F_) .assoc₀ : ∀ {o₀ ℓ₀ e₀ o₁ ℓ₁ e₁ o₂ ℓ₂ e₂ o₃ ℓ₃ e₃} {C₀ : Category o₀ ℓ₀ e₀} {C₁ : Category o₁ ℓ₁ e₁} {C₂ : Category o₂ ℓ₂ e₂} {C₃ : Category o₃ ℓ₃ e₃} {F G : Functor C₀ C₁} {H I : Functor C₁ C₂} {J K : Functor C₂ C₃} → {X : NaturalTransformation F G} → {Y : NaturalTransformation H I} → {Z : NaturalTransformation J K} → (Z ∘₀ Y) ∘₀ X ≡ (_∘₀_ {F = H ∘F F} {I ∘F G} Z (_∘₀_ {C = C₀} {C₁} {C₂} Y X)) assoc₀ {C₀ = C₀} {C₁} {C₂} {C₃} {F} {G} {H} {I} {J} {K} {X} {Y} {Z} = begin K₁ (I₁ (X.η _)) ∘C₃ (K₁ (Y.η (F₀ _)) ∘C₃ Z.η (H₀ (F₀ _))) ↑⟨ C₃.assoc ⟩ (K₁ (I₁ (X.η _)) ∘C₃ K₁ (Y.η (F₀ _))) ∘C₃ Z.η (H₀ (F₀ _)) ↑⟨ C₃.∘-resp-≡ˡ K.homomorphism ⟩ (K₁ ((I₁ (X.η _)) ∘C₂ Y.η (F₀ _))) ∘C₃ Z.η (H₀ (F₀ _)) ∎ where module C₂ = Category C₂ renaming (_∘_ to _∘C₂_; _≡_ to _≡C₂_) module C₃ = Category C₃ renaming (_∘_ to _∘C₃_; _≡_ to _≡C₃_) module F = Functor F module G = Functor G renaming (F₀ to G₀; F₁ to G₁; F-resp-≡ to G-resp-≡) module H = Functor H renaming (F₀ to H₀; F₁ to H₁; F-resp-≡ to H-resp-≡) module I = Functor I renaming (F₀ to I₀; F₁ to I₁; F-resp-≡ to I-resp-≡) module J = Functor J renaming (F₀ to J₀; F₁ to J₁; F-resp-≡ to J-resp-≡) module K = Functor K renaming (F₀ to K₀; F₁ to K₁; F-resp-≡ to K-resp-≡) module X = NaturalTransformation X module Y = NaturalTransformation Y module Z = NaturalTransformation Z open C₃.HomReasoning open C₂ open C₃ open F open H open I open K .interchange : ∀ {o₀ ℓ₀ e₀} {o₁ ℓ₁ e₁} {o₂ ℓ₂ e₂} {C₀ : Category o₀ ℓ₀ e₀} {C₁ : Category o₁ ℓ₁ e₁} {C₂ : Category o₂ ℓ₂ e₂} {F₀ F₁ F₅ : Functor C₀ C₁} {F₂ F₃ F₄ : Functor C₁ C₂} {α : NaturalTransformation F₃ F₄} {β : NaturalTransformation F₁ F₅} {γ : NaturalTransformation F₂ F₃} {δ : NaturalTransformation F₀ F₁} → (α ∘₀ β) ∘₁ (γ ∘₀ δ) ≡ (α ∘₁ γ) ∘₀ (β ∘₁ δ) interchange {C₀ = C₀} {C₁} {C₂} {F₀} {F₁} {F₅} {F₂} {F₃} {F₄} {α} {β} {γ} {δ} = begin (F₄.F₁ (β.η _) ∘ α.η (F₁.F₀ _)) ∘ (F₃.F₁ (δ.η _) ∘ γ.η (F₀.F₀ _)) ↓⟨ C₂.assoc ⟩ F₄.F₁ (β.η _) ∘ (α.η (F₁.F₀ _) ∘ (F₃.F₁ (δ.η _) ∘ γ.η (F₀.F₀ _))) ↑⟨ C₂.∘-resp-≡ʳ C₂.assoc ⟩ F₄.F₁ (β.η _) ∘ ((α.η (F₁.F₀ _) ∘ (F₃.F₁ (δ.η _))) ∘ γ.η (F₀.F₀ _)) ↓⟨ C₂.∘-resp-≡ʳ (C₂.∘-resp-≡ˡ (α.commute (δ.η _))) ⟩ F₄.F₁ (β.η _) ∘ ((F₄.F₁ (δ.η _) ∘ α.η (F₀.F₀ _)) ∘ γ.η (F₀.F₀ _)) ↓⟨ C₂.∘-resp-≡ʳ C₂.assoc ⟩ F₄.F₁ (β.η _) ∘ (F₄.F₁ (δ.η _) ∘ (α.η (F₀.F₀ _) ∘ γ.η (F₀.F₀ _))) ↑⟨ C₂.assoc ⟩ (F₄.F₁ (β.η _) ∘ F₄.F₁ (δ.η _)) ∘ (α.η (F₀.F₀ _) ∘ γ.η (F₀.F₀ _)) ↑⟨ C₂.∘-resp-≡ˡ F₄.homomorphism ⟩ F₄.F₁ (β.η _ ∘C₁ δ.η _) ∘ (α.η (F₀.F₀ _) ∘ γ.η (F₀.F₀ _)) ∎ where module C₁ = Category C₁ renaming (_∘_ to _∘C₁_; _≡_ to _≡C₁_) module C₂ = Category C₂ module F₀ = Functor F₀ module F₁ = Functor F₁ module F₂ = Functor F₂ module F₃ = Functor F₃ module F₄ = Functor F₄ module F₅ = Functor F₅ module α = NaturalTransformation α module β = NaturalTransformation β module γ = NaturalTransformation γ module δ = NaturalTransformation δ open C₁ open C₂ open C₂.HomReasoning .∘₁-resp-≡ : ∀ {o ℓ e} {o′ ℓ′ e′} {D : Category o ℓ e} {E : Category o′ ℓ′ e′} {A B C : Functor D E} {f h : NaturalTransformation B C} {g i : NaturalTransformation A B} → f ≡ h → g ≡ i → f ∘₁ g ≡ h ∘₁ i ∘₁-resp-≡ {E = E} f≡h g≡i = Category.∘-resp-≡ E f≡h g≡i .∘₀-resp-≡ : ∀ {o ℓ e} {o′ ℓ′ e′} {o″ ℓ″ e″} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {E : Category o″ ℓ″ e″} {F F′ : Functor C D} {G G′ : Functor D E} {f h : NaturalTransformation G G′} {g i : NaturalTransformation F F′} → f ≡ h → g ≡ i → f ∘₀ g ≡ h ∘₀ i ∘₀-resp-≡ {E = E} {G′ = G′} f≡h g≡i = Category.∘-resp-≡ E (Functor.F-resp-≡ G′ g≡i) f≡h
{ "alphanum_fraction": 0.5484043263, "avg_line_length": 39.835106383, "ext": "agda", "hexsha": "d3b8f594984e717d3a39152eed15c5788c30b7ca", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/NaturalTransformation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "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": "p-pavel/categories", "max_issues_repo_path": "Categories/NaturalTransformation.agda", "max_line_length": 130, "max_stars_count": 1, "max_stars_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "p-pavel/categories", "max_stars_repo_path": "Categories/NaturalTransformation.agda", "max_stars_repo_stars_event_max_datetime": "2018-12-29T21:51:57.000Z", "max_stars_repo_stars_event_min_datetime": "2018-12-29T21:51:57.000Z", "num_tokens": 3401, "size": 7489 }
{-# OPTIONS --without-K #-} open import HoTT open import cohomology.CofiberSequence open import cohomology.Exactness open import cohomology.ExactPairIso open import cohomology.FunctionOver open import cohomology.MayerVietoris open import cohomology.SplitExactRight open import cohomology.Theory module cohomology.Coproduct {i} (OT : OrdinaryTheory i) where open OrdinaryTheory OT open import cohomology.ConstantFunction cohomology-theory open import cohomology.Functor cohomology-theory open import cohomology.Sn OT {- Cⁿ(X ⊔ Y) == Cⁿ(X ∨ Y) × Cⁿ(S⁰). The proof is by constructing a - splitting exact sequence 0 → Cⁿ(X ∨ Y) → Cⁿ(X ⊔ Y) → C(S⁰) - by defining a map [select : S⁰ → X ⊔ Y] such that [Cofiber select == X ∨ Y] and [select] has a left inverse. -} module CofSelect (X Y : Ptd i) where select : Sphere {i} 0 → fst (X ⊙⊔ Y) select (lift true) = inl (snd X) select (lift false) = inr (snd Y) ⊙select : fst (⊙Sphere {i} 0 ⊙→ X ⊙⊔ Y) ⊙select = (select , idp) module Into = CofiberRec select {C = X ∨ Y} (winl (snd X)) add-wglue (λ {(lift true) → idp; (lift false) → wglue}) module Out = WedgeRec {X = X} {Y = Y} {C = Cofiber select} (λ x → cfcod _ (inl x)) (λ y → cfcod _ (inr y)) (! (cfglue _ (lift true)) ∙ cfglue _ (lift false)) into = Into.f out = Out.f into-out : ∀ w → into (out w) == w into-out = Wedge-elim (λ x → idp) (λ y → idp) (↓-∘=idf-in into out $ ap into (ap out wglue) =⟨ ap (ap into) Out.glue-β ⟩ ap into (! (cfglue _ (lift true)) ∙ cfglue _ (lift false)) =⟨ ap-∙ into (! (cfglue _ (lift true))) (cfglue _ (lift false)) ⟩ ap into (! (cfglue _ (lift true))) ∙ ap into (cfglue _ (lift false)) =⟨ ap-! into (cfglue _ (lift true)) ∙ ap ! (Into.glue-β (lift true)) |in-ctx (λ w → w ∙ ap into (cfglue _ (lift false))) ⟩ ap into (cfglue _ (lift false)) =⟨ Into.glue-β (lift false) ⟩ wglue ∎) out-into : ∀ κ → out (into κ) == κ out-into = Cofiber-elim _ (! (cfglue _ (lift true))) (λ {(inl x) → idp; (inr y) → idp}) (λ {(lift true) → ↓-∘=idf-from-square out into $ ap (ap out) (Into.glue-β (lift true)) ∙v⊡ bl-square _; (lift false) → ↓-∘=idf-from-square out into $ (ap (ap out) (Into.glue-β (lift false)) ∙ Out.glue-β) ∙v⊡ lt-square (! (cfglue _ (lift true))) ⊡h vid-square}) eq : Cofiber select ≃ X ∨ Y eq = equiv into out into-out out-into ⊙path : ⊙Cof ⊙select == X ⊙∨ Y ⊙path = ⊙ua eq idp cfcod-over : ⊙cfcod ⊙select == ⊙add-wglue [ (λ U → fst (X ⊙⊔ Y ⊙→ U)) ↓ ⊙path ] cfcod-over = codomain-over-⊙equiv _ _ _ ▹ pair= idp lemma where lemma : ap into (! (cfglue _ (lift true))) ∙ idp == idp lemma = ∙-unit-r _ ∙ ap-! into (cfglue _ (lift true)) ∙ ap ! (Into.glue-β (lift true)) ext-glue-cst : ⊙ext-glue == ⊙cst {X = ⊙Cof ⊙select} {Y = ⊙Sphere 1} ext-glue-cst = ⊙λ= (Cofiber-elim _ idp (λ {(inl _) → ! (merid _ (lift true)); (inr _) → ! (merid _ (lift false))}) (λ {(lift true) → ↓-='-from-square $ ExtGlue.glue-β (lift true) ∙v⊡ tr-square (merid _ (lift true)) ⊡v∙ ! (ap-cst (north _) (glue (lift true))); (lift false) → ↓-='-from-square $ ExtGlue.glue-β (lift false) ∙v⊡ tr-square (merid _ (lift false)) ⊡v∙ ! (ap-cst (north _) (glue (lift false)))})) idp ext-over : ⊙ext-glue == ⊙cst [ (λ U → fst (U ⊙→ ⊙Sphere 1)) ↓ ⊙path ] ext-over = ext-glue-cst ◃ domain-over-⊙equiv _ _ _ module C⊔ (n : ℤ) (m : ℕ) (X Y : Ptd i) where open CofSelect X Y ed : {G : Group i} (φ : GroupHom (C n (⊙Susp^ m (X ⊙⊔ Y))) G) → ExactDiag _ _ ed {G} φ = C n (⊙Susp^ m (⊙Sphere 1)) ⟨ cst-hom ⟩→ C n (⊙Susp^ m (X ⊙∨ Y)) ⟨ CF-hom n (⊙susp^-fmap m ⊙add-wglue) ⟩→ C n (⊙Susp^ m (X ⊙⊔ Y)) ⟨ φ ⟩→ -- CF-hom n (⊙susp^-fmap m ⊙select) G ⊣| -- C n (⊙Susp^ m (⊙Sphere 0)) es : ExactSeq (ed (CF-hom n (⊙susp^-fmap m ⊙select))) es = exact-build (ed (CF-hom n (⊙susp^-fmap m ⊙select))) (transport (λ g → is-exact g (CF n (⊙susp^-fmap m ⊙add-wglue))) (ap (CF n) (⊙susp^-fmap-cst m) ∙ ap GroupHom.⊙f (CF-cst n)) (transport (λ {(_ , g , h) → is-exact (CF n (⊙susp^-fmap m h)) (CF n (⊙susp^-fmap m g))}) (pair= ⊙path (↓-×-in cfcod-over ext-over)) (transport (λ {(_ , g , h) → is-exact (CF n h) (CF n g)}) (suspend^-cof= m (⊙cfcod ⊙select) (⊙ext-glue) (pair= (Cof².space-path ⊙select) (Cof².cfcod²-over ⊙select))) (C-exact n (⊙susp^-fmap m (⊙cfcod ⊙select)))))) (transport (λ {(_ , g) → is-exact (CF n (⊙susp^-fmap m g)) (CF n (⊙susp^-fmap m ⊙select))}) (pair= ⊙path cfcod-over) (transport (λ {(_ , g , h) → is-exact (CF n h) (CF n g)}) (suspend^-cof= m ⊙select _ idp) (C-exact n (⊙susp^-fmap m ⊙select)))) module Nonzero (neq : n ≠ ℕ-to-ℤ m) where iso : C n (⊙Susp^ m (X ⊙∨ Y)) == C n (⊙Susp^ m (X ⊙⊔ Y)) iso = exact-pair-iso $ transport (λ {(G , φ) → ExactSeq (ed {G} φ)}) (pair= (ap (C n) (⊙Susp^-+ m O ∙ ap (λ k → ⊙Susp^ k (⊙Sphere 0)) (+-unit-r m)) ∙ C-Sphere-≠ n m neq) (prop-has-all-paths-↓ {B = λ G → GroupHom (C n (⊙Susp^ m (X ⊙⊔ Y))) G} (contr-is-prop 0ᴳ-hom-in-level))) es add-wglue-over : idhom _ == CF-hom n (⊙susp^-fmap m ⊙add-wglue) [ (λ G → GroupHom (C n (⊙Susp^ m (X ⊙∨ Y))) G) ↓ iso ] add-wglue-over = codomain-over-iso _ _ _ _ $ codomain-over-equiv _ _ module Any where deselect : fst (X ⊙⊔ Y) → Sphere {i} 0 deselect (inl _) = lift true deselect (inr _) = lift false ⊙deselect : fst (X ⊙⊔ Y ⊙→ ⊙Sphere {i} 0) ⊙deselect = (deselect , idp) deselect-select : ⊙deselect ⊙∘ ⊙select == ⊙idf _ deselect-select = ⊙λ= (λ {(lift true) → idp; (lift false) → idp}) idp module SER = SplitExactRight (C-abelian n _) (CF-hom n (⊙susp^-fmap m ⊙add-wglue)) (CF-hom n (⊙susp^-fmap m ⊙select)) es (CF-hom n (⊙susp^-fmap m ⊙deselect)) (app= $ ap GroupHom.f $ CF-inverse n (⊙susp^-fmap m ⊙select) (⊙susp^-fmap m ⊙deselect) (! (⊙susp^-fmap-∘ m ⊙deselect ⊙select) ∙ ap (⊙susp^-fmap m) deselect-select ∙ ⊙susp^-fmap-idf m _)) iso : C n (⊙Susp^ m (X ⊙⊔ Y)) == C n (⊙Susp^ m (X ⊙∨ Y)) ×ᴳ C n (⊙Susp^ m (⊙Sphere 0)) iso = SER.iso add-wglue-over : CF-hom n (⊙susp^-fmap m ⊙add-wglue) == ×ᴳ-inl [ (λ G → GroupHom (C n (⊙Susp^ m (X ⊙∨ Y))) G) ↓ iso ] add-wglue-over = SER.φ-over-iso
{ "alphanum_fraction": 0.5168968557, "avg_line_length": 34.3737373737, "ext": "agda", "hexsha": "247ddddd76358bfc6ee34960f8033f15e08278c7", "lang": "Agda", "max_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": "cohomology/Coproduct.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": "cohomology/Coproduct.agda", "max_line_length": 76, "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": "cohomology/Coproduct.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2785, "size": 6806 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Relation.Binary.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels
{ "alphanum_fraction": 0.7944444444, "avg_line_length": 30, "ext": "agda", "hexsha": "d31b5b36a474f4e475a53713ba2390659279eee4", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Relation/Binary/Properties.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Relation/Binary/Properties.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Relation/Binary/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 43, "size": 180 }
------------------------------------------------------------------------ -- Indexed containers ------------------------------------------------------------------------ -- Partly based on "Indexed containers" by Altenkirch, Ghani, Hancock, -- McBride and Morris, and partly based on "Non-wellfounded trees in -- Homotopy Type Theory" by Ahrens, Capriotti and Spadotti. {-# OPTIONS --without-K --safe #-} open import Equality module Container.Indexed {e⁺} (eq : ∀ {a p} → Equality-with-J a p e⁺) where open Derived-definitions-and-properties eq open import Prelude import Bijection eq as B open import Equivalence eq as Eq using (_≃_) open import Function-universe eq as F hiding (id; _∘_) open import H-level.Closure eq open import Univalence-axiom eq private variable a ℓ p p₁ p₂ q s : Level A I O : Type a P Q R : A → Type p ext f i k o : A ------------------------------------------------------------------------ -- _⇾_ -- A kind of function space for indexed types. infix 4 _⇾_ _⇾_ : {A : Type a} → (A → Type p) → (A → Type q) → Type (a ⊔ p ⊔ q) P ⇾ Q = ∀ x → P x → Q x -- An identity function. id⇾ : P ⇾ P id⇾ _ = id -- Composition for _⇾_. infixr 9 _∘⇾_ _∘⇾_ : Q ⇾ R → P ⇾ Q → P ⇾ R f ∘⇾ g = λ i → f i ∘ g i ------------------------------------------------------------------------ -- Containers -- Doubly indexed containers. record Container₂ (I : Type i) (O : Type o) s p : Type (i ⊔ o ⊔ lsuc (s ⊔ p)) where field Shape : O → Type s Position : ∀ {o} → Shape o → Type p index : ∀ {o} {s : Shape o} → Position s → I open Container₂ public -- Singly indexed containers. Container : Type i → ∀ s p → Type (i ⊔ lsuc (s ⊔ p)) Container I = Container₂ I I private variable C : Container₂ I O s p -- Container₂ can be expressed as a nested Σ-type. Container≃Σ : Container₂ I O s p ≃ (∃ λ (S : O → Type s) → ∃ λ (P : ∀ {o} → S o → Type p) → ∀ {o} {s : S o} → P s → I) Container≃Σ = Eq.↔→≃ (λ C → C .Shape , C .Position , C .index) (λ (S , P , i) → record { Shape = S; Position = P; index = i }) refl refl ------------------------------------------------------------------------ -- Polynomial functors -- The polynomial functor associated to a container. ⟦_⟧ : {I : Type i} {O : Type o} → Container₂ I O s p → (I → Type ℓ) → O → Type (ℓ ⊔ s ⊔ p) ⟦ C ⟧ P i = ∃ λ (s : Shape C i) → (p : Position C s) → P (index C p) -- A map function. map : (C : Container₂ I O s p) → P ⇾ Q → ⟦ C ⟧ P ⇾ ⟦ C ⟧ Q map C f _ (s , g) = s , f _ ∘ g -- Functor laws. map-id : map C (id⇾ {P = P}) ≡ id⇾ map-id = refl _ map-∘ : (f : Q ⇾ R) (g : P ⇾ Q) → map C (f ∘⇾ g) ≡ map C f ∘⇾ map C g map-∘ _ _ = refl _ -- A preservation lemma. ⟦⟧-cong : {I : Type i} {P₁ : I → Type p₁} {P₂ : I → Type p₂} → Extensionality? k p (p₁ ⊔ p₂) → (C : Container₂ I O s p) → (∀ i → P₁ i ↝[ k ] P₂ i) → (∀ o → ⟦ C ⟧ P₁ o ↝[ k ] ⟦ C ⟧ P₂ o) ⟦⟧-cong {P₁ = P₁} {P₂ = P₂} ext C P₁↝P₂ o = (∃ λ (s : Shape C o) → (p : Position C s) → P₁ (index C p)) ↝⟨ (∃-cong λ _ → ∀-cong ext λ _ → P₁↝P₂ _) ⟩□ (∃ λ (s : Shape C o) → (p : Position C s) → P₂ (index C p)) □ -- The forward direction of ⟦⟧-cong is an instance of map (at least -- when k is equivalence). _ : _≃_.to (⟦⟧-cong ext C f o) ≡ map C (_≃_.to ∘ f) o _ = refl _ -- The shapes of a container are pointwise equivalent to the -- polynomial functor of the container applied to the constant -- function yielding the unit type. -- -- (This lemma was suggested to me by an anonymous reviewer of a -- paper.) Shape≃⟦⟧⊤ : (C : Container₂ I O s p) → Shape C o ≃ ⟦ C ⟧ (λ _ → ⊤) o Shape≃⟦⟧⊤ {o = o} C = Shape C o ↔⟨ inverse $ drop-⊤-right (λ _ → →-right-zero) ⟩□ (∃ λ (s : Shape C o) → Position C s → ⊤) □ ------------------------------------------------------------------------ -- Coalgebras -- The type of coalgebras for a (singly indexed) container. Coalgebra : {I : Type i} → Container I s p → Type (lsuc (i ⊔ s ⊔ p)) Coalgebra {i = i} {s = s} {p = p} {I = I} C = ∃ λ (P : I → Type (i ⊔ s ⊔ p)) → P ⇾ ⟦ C ⟧ P -- Coalgebra morphisms. infix 4 _⇨_ _⇨_ : {I : Type i} {C : Container I s p} → Coalgebra C → Coalgebra C → Type (i ⊔ s ⊔ p) (P , f) ⇨ (Q , g) = ∃ λ (h : P ⇾ Q) → g ∘⇾ h ≡ map _ h ∘⇾ f private variable X Y Z : Coalgebra C -- An identity morphism. id⇨ : X ⇨ X id⇨ = id⇾ , refl _ -- Composition for _⇨_. infix 9 [_]_∘⇨_ [_]_∘⇨_ : ∀ Z → Y ⇨ Z → X ⇨ Y → X ⇨ Z [_]_∘⇨_ {Y = _ , g} {X = _ , f} (_ , h) (f₁ , eq₁) (f₂ , eq₂) = f₁ ∘⇾ f₂ , (h ∘⇾ (f₁ ∘⇾ f₂) ≡⟨⟩ (h ∘⇾ f₁) ∘⇾ f₂ ≡⟨ cong (_∘⇾ f₂) eq₁ ⟩ (map _ f₁ ∘⇾ g) ∘⇾ f₂ ≡⟨⟩ map _ f₁ ∘⇾ (g ∘⇾ f₂) ≡⟨ cong (map _ f₁ ∘⇾_) eq₂ ⟩ map _ f₁ ∘⇾ (map _ f₂ ∘⇾ f) ≡⟨⟩ map _ (f₁ ∘⇾ f₂) ∘⇾ f ∎) -- The property of being a final coalgebra. Final : {I : Type i} {C : Container I s p} → Coalgebra C → Type (lsuc (i ⊔ s ⊔ p)) Final X = ∀ Y → Contractible (Y ⇨ X) -- A perhaps more traditional definition of what it means to be final. Final′ : {I : Type i} {C : Container I s p} → Coalgebra C → Type (lsuc (i ⊔ s ⊔ p)) Final′ X = ∀ Y → ∃ λ (m : Y ⇨ X) → (m′ : Y ⇨ X) → proj₁ m ≡ proj₁ m′ -- Final X implies Final′ X. Final→Final′ : (X : Coalgebra C) → Final X → Final′ X Final→Final′ _ = ∀-cong _ λ _ → ∃-cong λ _ → ∀-cong _ λ _ → cong proj₁ -- Final is pointwise propositional (assumption extensionality). Final-propositional : {I : Type i} {C : Container I s p} → Extensionality (lsuc (i ⊔ s ⊔ p)) (i ⊔ s ⊔ p) → (X : Coalgebra C) → Is-proposition (Final X) Final-propositional ext _ = Π-closure ext 1 λ _ → Contractible-propositional (lower-extensionality _ lzero ext) -- Final coalgebras. Final-coalgebra : {I : Type i} → Container I s p → Type (lsuc (i ⊔ s ⊔ p)) Final-coalgebra C = ∃ λ (X : Coalgebra C) → Final X -- Final coalgebras, defined using Final′. Final-coalgebra′ : {I : Type i} → Container I s p → Type (lsuc (i ⊔ s ⊔ p)) Final-coalgebra′ C = ∃ λ (X : Coalgebra C) → Final′ X -- Final-coalgebra C implies Final-coalgebra′ C. Final-coalgebra→Final-coalgebra′ : Final-coalgebra C → Final-coalgebra′ C Final-coalgebra→Final-coalgebra′ = ∃-cong Final→Final′ -- Carriers of final coalgebras (defined using Final′) for a given -- container are pointwise equivalent. carriers-of-final-coalgebras-equivalent′ : (((P₁ , _) , _) ((P₂ , _) , _) : Final-coalgebra′ C) → ∀ i → P₁ i ≃ P₂ i carriers-of-final-coalgebras-equivalent′ (X₁ , final₁) (X₂ , final₂) i = Eq.↔→≃ (proj₁ to i) (proj₁ from i) to∘from from∘to where to : X₁ ⇨ X₂ to = proj₁ (final₂ X₁) from : X₂ ⇨ X₁ from = proj₁ (final₁ X₂) to∘from : ∀ x → proj₁ ([ X₂ ] to ∘⇨ from) i x ≡ x to∘from x = proj₁ ([ X₂ ] to ∘⇨ from) i x ≡⟨ cong (λ f → f i x) $ sym $ proj₂ (final₂ X₂) $ [ X₂ ] to ∘⇨ from ⟩ proj₁ (proj₁ (final₂ X₂)) i x ≡⟨ cong (λ f → f i x) $ proj₂ (final₂ X₂) id⇨ ⟩ proj₁ (id⇨ {X = X₂}) i x ≡⟨⟩ x ∎ from∘to : ∀ x → proj₁ ([ X₁ ] from ∘⇨ to) i x ≡ x from∘to x = proj₁ ([ X₁ ] from ∘⇨ to) i x ≡⟨ cong (λ f → f i x) $ sym $ proj₂ (final₁ X₁) $ [ X₁ ] from ∘⇨ to ⟩ proj₁ (proj₁ (final₁ X₁)) i x ≡⟨ cong (λ f → f i x) $ proj₂ (final₁ X₁) id⇨ ⟩ proj₁ (id⇨ {X = X₁}) i x ≡⟨⟩ x ∎ -- The previous lemma relates the "out" functions of the two final -- coalgebras in a certain way. out-related′ : {C : Container I s p} (F₁@((_ , out₁) , _) F₂@((_ , out₂) , _) : Final-coalgebra′ C) → map C (_≃_.to ∘ carriers-of-final-coalgebras-equivalent′ F₁ F₂) ∘⇾ out₁ ≡ out₂ ∘⇾ (_≃_.to ∘ carriers-of-final-coalgebras-equivalent′ F₁ F₂) out-related′ (X₁ , _) (_ , final₂) = sym $ proj₂ (proj₁ (final₂ X₁)) -- Carriers of final coalgebras for a given container are pointwise -- equivalent. carriers-of-final-coalgebras-equivalent : (((P₁ , _) , _) ((P₂ , _) , _) : Final-coalgebra C) → ∀ i → P₁ i ≃ P₂ i carriers-of-final-coalgebras-equivalent = carriers-of-final-coalgebras-equivalent′ on Final-coalgebra→Final-coalgebra′ -- The previous lemma relates the "out" functions of the two final -- coalgebras in a certain way. out-related : {C : Container I s p} (F₁@((_ , out₁) , _) F₂@((_ , out₂) , _) : Final-coalgebra C) → map C (_≃_.to ∘ carriers-of-final-coalgebras-equivalent F₁ F₂) ∘⇾ out₁ ≡ out₂ ∘⇾ (_≃_.to ∘ carriers-of-final-coalgebras-equivalent F₁ F₂) out-related = out-related′ on Final-coalgebra→Final-coalgebra′ -- If X and Y are final coalgebras (with finality defined using -- Final′), then—assuming extensionality—finality of X (defined using -- Final) is equivalent to finality of Y. Final′→Final≃Final : {I : Type i} {C : Container I s p} ((X , _) (Y , _) : Final-coalgebra′ C) → Extensionality (i ⊔ s ⊔ p) (i ⊔ s ⊔ p) → Final X ↝[ lsuc (i ⊔ s ⊔ p) ∣ i ⊔ s ⊔ p ] Final Y Final′→Final≃Final {i = i} {s = s} {p = p} {C = C} ((X₁ , out₁) , final₁) ((X₂ , out₂) , final₂) ext {k = k} ext′ = ∀-cong ext′ λ Y@(_ , f) → H-level-cong (lower-extensionality? k _ lzero ext′) 0 (Σ-cong (lemma₂ Y) λ g → out₁ ∘⇾ g ≡ map C g ∘⇾ f ↝⟨ inverse $ Eq.≃-≡ (lemma₃ Y) ⟩ _≃_.to (lemma₃ Y) (out₁ ∘⇾ g) ≡ _≃_.to (lemma₃ Y) (map C g ∘⇾ f) ↔⟨⟩ map C (_≃_.to ∘ lemma₁) ∘⇾ out₁ ∘⇾ g ≡ map C (_≃_.to ∘ lemma₁) ∘⇾ map C g ∘⇾ f ↝⟨ ≡⇒↝ _ $ cong (λ h → h ∘⇾ g ≡ map C (_≃_.to ∘ lemma₁) ∘⇾ map C g ∘⇾ f) $ out-related′ ((X₁ , out₁) , final₁) ((X₂ , out₂) , final₂) ⟩ out₂ ∘⇾ (_≃_.to ∘ lemma₁) ∘⇾ g ≡ map C (_≃_.to ∘ lemma₁) ∘⇾ map C g ∘⇾ f ↔⟨⟩ out₂ ∘⇾ _≃_.to (lemma₂ Y) g ≡ map C (_≃_.to (lemma₂ Y) g) ∘⇾ f □) where ext₁ = lower-extensionality (s ⊔ p) lzero ext ext₂ = lower-extensionality (i ⊔ s) lzero ext lemma₁ : ∀ i → X₁ i ≃ X₂ i lemma₁ = carriers-of-final-coalgebras-equivalent′ ((X₁ , out₁) , final₁) ((X₂ , out₂) , final₂) lemma₂ : ((Y , _) : Coalgebra C) → (Y ⇾ X₁) ≃ (Y ⇾ X₂) lemma₂ _ = ∀-cong ext₁ λ _ → ∀-cong ext λ _ → lemma₁ _ lemma₃ : ((Y , _) : Coalgebra C) → (Y ⇾ ⟦ C ⟧ X₁) ≃ (Y ⇾ ⟦ C ⟧ X₂) lemma₃ _ = ∀-cong ext₁ λ _ → ∀-cong ext λ _ → ⟦⟧-cong ext₂ C lemma₁ _ -- If there is a final C-coalgebra, and we have Final′ X for some -- C-coalgebra X, then we also have Final X (assuming extensionality). Final′→Final : {I : Type i} {C : Container I s p} → Extensionality (i ⊔ s ⊔ p) (i ⊔ s ⊔ p) → Final-coalgebra C → ((X , _) : Final-coalgebra′ C) → Final X Final′→Final ext F₁@(_ , final₁) F₂ = Final′→Final≃Final (Final-coalgebra→Final-coalgebra′ F₁) F₂ ext _ final₁ -- Final-coalgebra is pointwise propositional, assuming extensionality -- and univalence. -- -- This is a variant of Lemma 5 from "Non-wellfounded trees in -- Homotopy Type Theory". Final-coalgebra-propositional : {I : Type i} {C : Container I s p} → Extensionality (lsuc (i ⊔ s ⊔ p)) (lsuc (i ⊔ s ⊔ p)) → Univalence (i ⊔ s ⊔ p) → Is-proposition (Final-coalgebra C) Final-coalgebra-propositional {I = I} {C = C} ext univ F₁@((P₁ , out₁) , _) F₂@(X₂@(P₂ , out₂) , _) = block λ b → Σ-≡,≡→≡ (Σ-≡,≡→≡ (lemma₁ b) (lemma₂ b)) (Final-propositional (lower-extensionality lzero _ ext) X₂ _ _) where ext₁′ = lower-extensionality _ lzero ext ext₁ = Eq.good-ext ext₁′ lemma₀ : Block "lemma₀" → ∀ i → P₁ i ≃ P₂ i lemma₀ ⊠ = carriers-of-final-coalgebras-equivalent F₁ F₂ lemma₀-lemma : ∀ b x → map C (_≃_.to ∘ lemma₀ b) i (out₁ i (_≃_.from (lemma₀ b i) x)) ≡ out₂ i x lemma₀-lemma {i = i} ⊠ x = map C (_≃_.to ∘ lemma₀ ⊠) i (out₁ i (_≃_.from (lemma₀ ⊠ i) x)) ≡⟨ cong (λ f → f _ (_≃_.from (lemma₀ ⊠ i) x)) $ out-related F₁ F₂ ⟩ out₂ i (_≃_.to (lemma₀ ⊠ i) (_≃_.from (lemma₀ ⊠ i) x)) ≡⟨ cong (out₂ _) $ _≃_.right-inverse-of (lemma₀ ⊠ i) _ ⟩∎ out₂ i x ∎ lemma₁ : Block "lemma₀" → P₁ ≡ P₂ lemma₁ b = apply-ext ext₁ λ i → ≃⇒≡ univ (lemma₀ b i) lemma₁-lemma₁ = λ b i → sym $ Σ-≡,≡→≡ (sym (lemma₁ b)) (subst-const _) ≡⟨ cong sym Σ-≡,≡→≡-subst-const-refl ⟩ sym $ cong₂ _,_ (sym (lemma₁ b)) (refl _) ≡⟨ sym cong₂-sym ⟩ cong₂ _,_ (sym (sym (lemma₁ b))) (sym (refl _)) ≡⟨ cong₂ (cong₂ _) (sym-sym _) sym-refl ⟩ cong₂ _,_ (lemma₁ b) (refl i) ≡⟨ cong₂-reflʳ _ ⟩∎ cong (_, i) (lemma₁ b) ∎ lemma₁-lemma₂ = λ b i x → subst (_$ i) (sym (lemma₁ b)) x ≡⟨⟩ subst (_$ i) (sym (apply-ext ext₁ λ i → ≃⇒≡ univ (lemma₀ b i))) x ≡⟨ cong (flip (subst (_$ i)) _) $ sym $ Eq.good-ext-sym ext₁′ _ ⟩ subst (_$ i) (apply-ext ext₁ λ i → sym (≃⇒≡ univ (lemma₀ b i))) x ≡⟨ Eq.subst-good-ext ext₁′ _ _ ⟩ subst id (sym (≃⇒≡ univ (lemma₀ b i))) x ≡⟨ subst-id-in-terms-of-inverse∘≡⇒↝ equivalence ⟩ _≃_.from (≡⇒≃ (≃⇒≡ univ (lemma₀ b i))) x ≡⟨ cong (λ eq → _≃_.from eq _) $ _≃_.right-inverse-of (≡≃≃ univ) _ ⟩∎ _≃_.from (lemma₀ b i) x ∎ lemma₁-lemma₃ = λ b i _ f p → subst (λ P → P (index C p)) (lemma₁ b) (f p) ≡⟨⟩ subst (λ P → P (index C p)) (apply-ext ext₁ λ i → ≃⇒≡ univ (lemma₀ b i)) (f p) ≡⟨ Eq.subst-good-ext ext₁′ _ _ ⟩ subst id (≃⇒≡ univ (lemma₀ b (index C p))) (f p) ≡⟨ subst-id-in-terms-of-≡⇒↝ equivalence ⟩ ≡⇒→ (≃⇒≡ univ (lemma₀ b (index C p))) (f p) ≡⟨ cong (λ eq → _≃_.to eq _) $ _≃_.right-inverse-of (≡≃≃ univ) _ ⟩∎ _≃_.to (lemma₀ b (index C p)) (f p) ∎ lemma₂ = λ b → apply-ext (lower-extensionality _ _ ext) λ i → apply-ext (lower-extensionality _ _ ext) λ x → subst (λ P → P ⇾ ⟦ C ⟧ P) (lemma₁ b) out₁ i x ≡⟨⟩ subst (λ P → ∀ i → P i → ⟦ C ⟧ P i) (lemma₁ b) out₁ i x ≡⟨ cong (_$ x) subst-∀ ⟩ subst (uncurry λ P i → P i → ⟦ C ⟧ P i) (sym $ Σ-≡,≡→≡ (sym (lemma₁ b)) (refl _)) (out₁ (subst (λ _ → I) (sym (lemma₁ b)) i)) x ≡⟨ elim¹ (λ {i′} eq → subst (uncurry λ P i → P i → ⟦ C ⟧ P i) (sym $ Σ-≡,≡→≡ (sym (lemma₁ b)) (refl _)) (out₁ (subst (λ _ → I) (sym (lemma₁ b)) i)) x ≡ subst (uncurry λ P i → P i → ⟦ C ⟧ P i) (sym $ Σ-≡,≡→≡ (sym (lemma₁ b)) eq) (out₁ i′) x) (refl _) _ ⟩ subst (uncurry λ P i → P i → ⟦ C ⟧ P i) (sym $ Σ-≡,≡→≡ (sym (lemma₁ b)) (subst-const _)) (out₁ i) x ≡⟨ cong (λ eq → subst (uncurry λ P i → P i → ⟦ C ⟧ P i) eq _ _) $ lemma₁-lemma₁ b i ⟩ subst (uncurry λ P i → P i → ⟦ C ⟧ P i) (cong (_, _) (lemma₁ b)) (out₁ i) x ≡⟨ cong (_$ x) $ sym $ subst-∘ _ _ _ ⟩ subst (λ P → P i → ⟦ C ⟧ P i) (lemma₁ b) (out₁ i) x ≡⟨ subst-→ ⟩ subst (λ P → ⟦ C ⟧ P i) (lemma₁ b) (out₁ i (subst (_$ i) (sym (lemma₁ b)) x)) ≡⟨ cong (subst (λ P → ⟦ C ⟧ P i) _) $ cong (out₁ _) $ lemma₁-lemma₂ b i x ⟩ subst (λ P → ⟦ C ⟧ P i) (lemma₁ b) (out₁ i (_≃_.from (lemma₀ b i) x)) ≡⟨⟩ subst (λ P → ∃ λ (s : Shape C i) → ∀ p → P (index C p)) (lemma₁ b) (out₁ i (_≃_.from (lemma₀ b i) x)) ≡⟨ push-subst-pair-× _ _ ⟩ (let s , f = out₁ i (_≃_.from (lemma₀ b i) x) in s , subst (λ P → (p : Position C s) → P (index C p)) (lemma₁ b) f) ≡⟨ (let s , _ = out₁ i (_≃_.from (lemma₀ b i) x) in cong (s ,_) $ apply-ext (lower-extensionality _ _ ext) λ _ → sym $ push-subst-application _ _) ⟩ (let s , f = out₁ i (_≃_.from (lemma₀ b i) x) in s , λ p → subst (λ P → P (index C p)) (lemma₁ b) (f p)) ≡⟨ (let _ , f = out₁ i (_≃_.from (lemma₀ b i) x) in cong (_ ,_) $ apply-ext (lower-extensionality _ _ ext) $ lemma₁-lemma₃ b i x f) ⟩ (let s , f = out₁ i (_≃_.from (lemma₀ b i) x) in s , λ p → _≃_.to (lemma₀ b (index C p)) (f p)) ≡⟨⟩ map C (_≃_.to ∘ lemma₀ b) i (out₁ i (_≃_.from (lemma₀ b i) x)) ≡⟨ lemma₀-lemma b x ⟩∎ out₂ i x ∎ ------------------------------------------------------------------------ -- Lifting the position type family -- One can lift the position type family so that it is in a universe -- that is at least as large as that containing the input indices. lift-positions : {I : Type i} → Container₂ I O s p → Container₂ I O s (i ⊔ p) lift-positions {i = i} C = λ where .Shape → C .Shape .Position s → ↑ i (C .Position s) .index (lift p) → C .index p -- The result of ⟦_⟧ is not affected by lift-positions (up to -- pointwise equivalence, assuming extensionality). ⟦⟧≃⟦lift-positions⟧ : {I : Type i} (C : Container₂ I O s p) (P : I → Type ℓ) → ⟦ C ⟧ P o ↝[ i ⊔ p ∣ ℓ ] ⟦ lift-positions C ⟧ P o ⟦⟧≃⟦lift-positions⟧ {o = o} C P ext = ∃-cong λ s → (( p : Position C s) → P (index C p)) ↝⟨ inverse-ext? (λ ext → Π-cong ext B.↑↔ λ _ → F.id) ext ⟩□ (((lift p) : ↑ _ (Position C s)) → P (index C p)) □ -- The definition of coalgebras is not affected by lift-positions (up -- to pointwise equivalence, assuming extensionality). Coalgebra≃Coalgebra-lift-positions : {I : Type i} {C : Container I s p} → Coalgebra C ↝[ i ⊔ s ⊔ p ∣ i ⊔ s ⊔ p ] Coalgebra (lift-positions C) Coalgebra≃Coalgebra-lift-positions {i = i} {s = s} {p = p} {C = C} {k = k} ext = (∃ λ P → P ⇾ ⟦ C ⟧ P) ↝⟨ (∃-cong λ P → ∀-cong (lower-extensionality? k l lzero ext) λ _ → ∀-cong (lower-extensionality? k l lzero ext) λ _ → ⟦⟧≃⟦lift-positions⟧ C P (lower-extensionality? k l lzero ext)) ⟩□ (∃ λ P → P ⇾ ⟦ lift-positions C ⟧ P) □ where l = i ⊔ s ⊔ p -- The definition of coalgebra morphisms is not affected by -- lift-positions (in a certain sense, assuming extensionality). ⇨≃⇨-lift-positions : {I : Type i} {C : Container I s p} (ext : Extensionality (i ⊔ s ⊔ p) (i ⊔ s ⊔ p)) → (X Y : Coalgebra C) → (X ⇨ Y) ≃ (_≃_.to (Coalgebra≃Coalgebra-lift-positions ext) X ⇨ _≃_.to (Coalgebra≃Coalgebra-lift-positions ext) Y) ⇨≃⇨-lift-positions {i = i} {s = s} {p = p} {C = C} ext (P , f) (Q , g) = (∃ λ (h : P ⇾ Q) → g ∘⇾ h ≡ map _ h ∘⇾ f) ↝⟨ (∃-cong λ _ → inverse $ Eq.≃-≡ $ ∀-cong (lower-extensionality l lzero ext) λ _ → ∀-cong (lower-extensionality l lzero ext) λ _ → ⟦⟧≃⟦lift-positions⟧ C Q (lower-extensionality l lzero ext)) ⟩□ (∃ λ (h : P ⇾ Q) → (Σ-map id (_∘ lower) ∘_) ∘ (g ∘⇾ h) ≡ (Σ-map id (_∘ lower) ∘_) ∘ (map _ h ∘⇾ f)) □ where l = i ⊔ s ⊔ p
{ "alphanum_fraction": 0.4634324009, "avg_line_length": 36.7058823529, "ext": "agda", "hexsha": "5a9ce81da53763055dfb0960effee0f39e1b0dfc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Container/Indexed.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Container/Indexed.agda", "max_line_length": 143, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Container/Indexed.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": 7719, "size": 20592 }
module Data.List.Relation.Membership.Proofs where import Lvl open import Functional open import Data.Boolean open import Data.Boolean.Stmt open import Data.List open import Data.List.Functions hiding (skip) open import Data.List.Relation.Membership open import Data.List.Relation.Quantification hiding (use ; skip) open import Data.List.Relation.Quantification.Proofs import Data.Tuple as Tuple open import Logic open import Logic.Predicate open import Logic.Propositional open import Numeral.Natural open import Structure.Function open import Structure.Relator.Properties open import Structure.Relator open import Structure.Setoid renaming (_≡_ to _≡ₛ_) open import Syntax.Transitivity open import Type private variable ℓ ℓₑ ℓₑ₁ ℓₑ₂ : Lvl.Level private variable T A B C : Type{ℓ} module _ ⦃ equiv : Equiv{ℓₑ}(T) ⦄ where private variable l l₁ l₂ : List(T) private variable a b c x : T instance [∈]-relatorₗ : UnaryRelator(_∈ l) [∈]-relatorₗ = intro p where p : Names.Substitution₁(_∈ l) p{x ⊰ _} xy (• q) = • (symmetry(_≡ₛ_) xy 🝖 q) p{x ⊰ y ⊰ l} xy (⊰ q) = ⊰ p{y ⊰ l} xy q [∈]-self : AllElements(_∈ l)(l) [∈]-self {∅} = ∅ [∈]-self {x ⊰ l} = (• reflexivity(_≡ₛ_)) ⊰ AllElements-fn (⊰_) ([∈]-self {l}) [∉]-empty : (a ∉ ∅) [∉]-empty () [∈]-in-singleton : (a ∈ singleton(a)) [∈]-in-singleton = use(reflexivity(_≡ₛ_)) [∈]-singleton : (a ∈ singleton(b)) ↔ (a ≡ₛ b) [∈]-singleton = [↔]-intro L R where L : (a ∈ singleton(b)) ← (a ≡ₛ b) L p = substitute₁(_∈ _) (symmetry(_≡ₛ_) p) [∈]-in-singleton R : (a ∈ singleton(b)) → (a ≡ₛ b) R(use p) = p R(skip ()) [∈][++] : (a ∈ (l₁ ++ l₂)) ↔ ((a ∈ l₁) ∨ (a ∈ l₂)) [∈][++] = [↔]-intro L R where L : (a ∈ (l₁ ++ l₂)) ← ((a ∈ l₁) ∨ (a ∈ l₂)) L {l₁ = ∅} ([∨]-introᵣ p) = p L {l₁ = x ⊰ l₁} ([∨]-introₗ (• p)) = • p L {l₁ = x ⊰ l₁} ([∨]-introₗ (⊰ p)) = ⊰ L {l₁ = l₁} ([∨]-introₗ p) L {l₁ = x ⊰ l₁} ([∨]-introᵣ p) = ⊰ L {l₁ = l₁} ([∨]-introᵣ p) R : (a ∈ (l₁ ++ l₂)) → ((a ∈ l₁) ∨ (a ∈ l₂)) R {l₁ = ∅} p = [∨]-introᵣ p R {l₁ = x ⊰ l₁} (• p) = [∨]-introₗ (• p) R {l₁ = x ⊰ l₁} (⊰ p) with R {l₁ = l₁} p ... | [∨]-introₗ q = [∨]-introₗ (⊰ q) ... | [∨]-introᵣ q = [∨]-introᵣ q [∈]-postpend : (a ∈ postpend a l) [∈]-postpend{l = ∅} = use (reflexivity(_≡ₛ_)) [∈]-postpend{l = _ ⊰ l} = skip([∈]-postpend{l = l}) {- open import Data.Boolean.Proofs [∈]-filter : ∀{f} ⦃ func : Function(f) ⦄ → (a ∈ filter f(l)) ↔ ((a ∈ l) ∧ IsTrue(f(a))) [∈]-filter{l = ll}{f = f} = [↔]-intro (Tuple.uncurry L) (x ↦ [∧]-intro (R₁ x) (R₂{l = ll} x)) where postulate L : (a ∈ l) → IsTrue(f(a)) → (a ∈ filter f(l)) {-L {a = a}{l = x ⊰ ∅} (• p) t with _ ← substitute₁ ⦃ {![≡]-equiv {T = Bool}!} ⦄ (IsTrue) ⦃ {!!} ⦄ p t | 𝑇 ← f(x) = {!!} L {a = a}{l = x ⊰ y ⊰ l} (• p) _ = {!!} L {a = a}{l = x ⊰ y ⊰ l} (⊰ p) _ = {!!}-} postulate R₁ : (a ∈ filter f(l)) → (a ∈ l) -- R₁ {l = x ⊰ ∅} p = {!p!} -- R₁ {l = x ⊰ x₁ ⊰ l} p = {!!} postulate R₂ : (a ∈ filter f(l)) → IsTrue(f(a)) -} module _ ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄ ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ where private variable f : A → B private variable l l₁ l₂ : List(T) private variable a b c x : T [∈]-map : ⦃ func-f : Function(f) ⦄ → (a ∈ l) → (f(a) ∈ (map f(l))) [∈]-map {f = f} (use p) = use (congruence₁(f) p) [∈]-map (skip p) = skip([∈]-map p) {- TODO: Stuff below is supposed to be moved to Structure.Sets.Proofs [∈][++]-expandₗ : (a ∈ l₂) → (a ∈ (l₁ ++ l₂)) [∈][++]-expandₗ {l₂ = l₂}{l₁ = l₁} = [↔]-to-[←] ([∈][++] {l₁ = l₁}{l₂ = l₂}) ∘ [∨]-introᵣ [∈][++]-expandᵣ : (a ∈ l₁) → (a ∈ (l₁ ++ l₂)) [∈][++]-expandᵣ {l₁ = l₁}{l₂ = l₂} = [↔]-to-[←] ([∈][++] {l₁ = l₁}{l₂ = l₂}) ∘ [∨]-introₗ [∈][⊰]-reorderₗ : (a ∈ (l₁ ++ (x ⊰ l₂))) → (a ∈ (x ⊰ (l₁ ++ l₂))) [∈][⊰]-reorderₗ (a∈l₁++xl₂) = [∨]-elim left right ([↔]-to-[→] [∈]-[++] (a∈l₁++xl₂)) where left : (a ∈ l₁) → (a ∈ (x ⊰ (l₁ ++ l₂))) left (a∈l₁) = [∈][⊰]-expand ([∈][++]-expandᵣ {a}{l₁}{l₂} (a∈l₁)) right : ∀{a} → (a ∈ (x ⊰ l₂)) → (a ∈ (x ⊰ (l₁ ++ l₂))) {-right ([∈]-id) = use right ([∈][⊰]-expand (a∈l₂)) = [∈][⊰]-expand ([∈][++]-expandₗ {_}{l₁}{l₂} (a∈l₂))-} -- [∈][⊰]-reorderᵣ : ∀{a x}{l₁ l₂} → (a ∈ (x ⊰ (l₁ ++ l₂))) → (a ∈ (l₁ ++ (x ⊰ l₂))) -- [∈][⊰]-reorderᵣ {a}{x}{l₁}{l₂} ([∈]-id) = -- [∈][⊰]-reorderᵣ {a}{x}{l₁}{l₂} ([∈][⊰]-expand (a∈l₁++l₂)) = [∈]-in-middle : (a ∈ (l₁ ++ singleton(a) ++ l₂)) [∈]-in-middle{a}{l₁}{l₂} = [↔]-to-[←] ([∈]-[++] {a}{l₁ ++ singleton(a)}{l₂}) ([∨]-introₗ ([∈]-at-last{l = l₁})) module _ where private variable ℓ₂ : Lvl.Level [⊆]-substitution : ∀{l₁ l₂ : List(T)} → (l₁ ⊆ l₂) → ∀{P : T → Stmt{ℓ₂}} → (∀{a} → (a ∈ l₂) → P(a)) → (∀{a} → (a ∈ l₁) → P(a)) [⊆]-substitution (l₁⊆l₂) proof = proof ∘ (l₁⊆l₂) [⊇]-substitution : ∀{l₁ l₂ : List(T)} → (l₁ ⊇ l₂) → ∀{P : T → Stmt{ℓ₂}} → (∀{a} → (a ∈ l₁) → P(a)) → (∀{a} → (a ∈ l₂) → P(a)) [⊇]-substitution (l₁⊇l₂) proof = proof ∘ (l₁⊇l₂) [≡]-substitutionₗ : ∀{l₁ l₂ : List(T)} → (l₁ ≡ l₂) → ∀{P : T → Stmt{ℓ₂}} → (∀{a} → (a ∈ l₁) → P(a)) → (∀{a} → (a ∈ l₂) → P(a)) [≡]-substitutionₗ (l₁≡l₂) = [⊆]-substitution ([↔]-to-[←] (l₁≡l₂)) [≡]-substitutionᵣ : ∀{l₁ l₂ : List(T)} → (l₁ ≡ l₂) → ∀{P : T → Stmt{ℓ₂}} → (∀{a} → (a ∈ l₂) → P(a)) → (∀{a} → (a ∈ l₁) → P(a)) [≡]-substitutionᵣ (l₁≡l₂) = [⊆]-substitution ([↔]-to-[→] (l₁≡l₂)) -} {- open import Structure.Relator.Properties instance [⊆]-reflexivity : Reflexivity(_⊆_) Reflexivity.proof [⊆]-reflexivity = id instance [⊆]-antisymmetry : Antisymmetry(_⊆_)(_≡_) Antisymmetry.proof [⊆]-antisymmetry = swap [↔]-intro instance [⊆]-transitivity : Transitivity(_⊆_) Transitivity.proof [⊆]-transitivity xy yz = yz ∘ xy instance [⊆]-reflexivity : Reflexivity(_⊆_) [≡]-reflexivity : ∀{L} → (L ≡ L) -- [≡]-reflexivity = [↔]-intro [⊆]-reflexivity [⊆]-reflexivity [≡]-symmetry : ∀{l₁ l₂} → (l₁ ≡ l₂) → (l₂ ≡ l₁) [≡]-symmetry (l₁≡l₂) {x} with (l₁≡l₂){x} ... | [↔]-intro l r = [↔]-intro r l [≡]-transitivity : ∀{l₁ l₂ L₃} → (l₁ ≡ l₂) → (l₂ ≡ L₃) → (l₁ ≡ L₃) [≡]-transitivity (l₁≡l₂) (l₂≡L₃) {x} with [∧]-intro ((l₁≡l₂){x}) ((l₂≡L₃){x}) ... | ([∧]-intro (lr₁) (lr₂)) = [↔]-transitivity (lr₁) (lr₂) -- [⊆]-application : ∀{l₁ l₂} → (l₁ ⊆ l₂) → ∀{f} → (map f(l₁))⊆(map f(l₂)) -- [⊆]-application proof fl₁ = [∈]-proof.application ∘ proof -- (∀{x} → (x ∈ l₂) → (x ∈ l₁)) → ∀{f} → (∀{x} → (x ∈ map f(l₂)) → (x ∈ map f(l₁))) {- [≡]-included-in : ∀{L : List(T)}{x} → (x ∈ L) → ((x ⊰ L) ≡ L) [≡]-included-in xL = [⊆]-antisymmetry (sub xL) (super xL) where super : ∀{L : List(T)}{x} → (x ∈ L) → ((x ⊰ L) ⊇ L) super [∈]-id [∈]-id = [∈]-id super [∈]-id (skip p) = skip ? super (skip p) [∈]-id = skip(use ?) super (skip p ) (skip q) = skip(skip ?) sub : ∀{L : List(T)}{x} → (x ∈ L) → ((x ⊰ L) ⊆ L) sub use use = use sub use (skip ⦃ p ⦄) = p sub skip use = skip sub skip (skip ⦃ p ⦄) = p -} postulate [≡]-included-subset : ∀{l₁ l₂ : List(T)} → (l₁ ⊆ l₂) → ((l₁ ++ l₂) ≡ l₂) postulate [≡]-subset-[++] : ∀{L l₁ l₂ : List(T)} → (l₁ ⊆ L) → (l₂ ⊆ L) → (l₁ ++ l₂ ⊆ L) [⊆]-with-[⊰] : ∀{l₁ l₂ : List(T)} → (l₁ ⊆ l₂) → ∀{b} → (l₁ ⊆ (b ⊰ l₂)) [⊆]-with-[⊰] (l₁⊆l₂) (x∈l₁) = [∈][⊰]-expand ((l₁⊆l₂) (x∈l₁)) [⊆]-with-[++]ₗ : ∀{l₁ l₂ : List(T)} → (l₁ ⊆ l₂) → ∀{L₃} → (l₁ ⊆ (L₃ ++ l₂)) -- [⊆]-with-[++]ₗ {l₁}{l₂} (l₁⊆l₂) {L₃} (x∈l₁) = [∈][++]-expandₗ {_}{L₃}{l₂} ((l₁⊆l₂) (x∈l₁)) [⊆]-with-[++]ᵣ : ∀{l₁ l₂ : List(T)} → (l₁ ⊆ l₂) → ∀{L₃} → (l₁ ⊆ (l₂ ++ L₃)) [⊆]-with-[++]ᵣ {l₁}{l₂} (l₁⊆l₂) {L₃} (x∈l₁) = [∈][++]-expandᵣ {_}{l₂}{L₃} ((l₁⊆l₂) (x∈l₁)) -- TODO: Does this work? It would be easier to "port" all (∈)-theorems to (⊆)-theorems then. -- [∈]-to-[⊆]-property : ∀{l₂}{f : List(T) → List(T)} → (∀{a} → (a ∈ l₂) → (a ∈ f(l₂))) → (∀{l₁} → (l₁ ⊆ l₂) → (l₁ ⊆ f(l₂))) -} module _ where open import Relator.Equals as Id open import Relator.Equals.Proofs.Equiv non-empty-inclusion-existence : ∀{l : List(T)} → (l Id.≢ ∅) → ∃(_∈ l) non-empty-inclusion-existence {l = ∅} p with () ← p(reflexivity(Id._≡_)) non-empty-inclusion-existence {l = x ⊰ l} p = [∃]-intro x ⦃ •(reflexivity(Id._≡_)) ⦄
{ "alphanum_fraction": 0.480790475, "avg_line_length": 37.0318181818, "ext": "agda", "hexsha": "6db5261c285342b4f2b5235a902305d85b694ea7", "lang": "Agda", "max_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": "Data/List/Relation/Membership/Proofs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Data/List/Relation/Membership/Proofs.agda", "max_line_length": 128, "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": "Data/List/Relation/Membership/Proofs.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 4110, "size": 8147 }
module Base.Free.Instance.Maybe where open import Data.Unit using (⊤; tt) open import Data.Empty using (⊥) open import Base.Free using (Free; pure; impure) open import Base.Partial using (Partial) open Partial -- Representation of the `Maybe` monad using Free. Shape : Set Shape = ⊤ Position : Shape → Set Position _ = ⊥ Maybe : Set → Set Maybe = Free Shape Position Nothing : ∀ {A} → Maybe A Nothing = impure tt λ() Just : ∀ {A} → A → Maybe A Just x = pure x instance maybePartial : Partial Shape Position undefined maybePartial = Nothing error maybePartial _ = Nothing
{ "alphanum_fraction": 0.6853377265, "avg_line_length": 19.5806451613, "ext": "agda", "hexsha": "283f17194579553139452e0df98e4e310c0980bd", "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.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.agda", "max_line_length": 51, "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.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": 165, "size": 607 }
open import Nat open import Prelude open import List open import judgemental-erase open import lemmas-matching open import statics-core open import synth-unicity module moveerase where -- type actions don't change the term other than moving the cursor -- around moveeraset : {t t' : ztyp} {δ : direction} → (t + move δ +> t') → (t ◆t) == (t' ◆t) moveeraset TMArrChild1 = refl moveeraset TMArrChild2 = refl moveeraset TMArrParent1 = refl moveeraset TMArrParent2 = refl moveeraset (TMArrZip1 {t2 = t2} m) = ap1 (λ x → x ==> t2) (moveeraset m) moveeraset (TMArrZip2 {t1 = t1} m) = ap1 (λ x → t1 ==> x) (moveeraset m) moveeraset TMPlusChild1 = refl moveeraset TMPlusChild2 = refl moveeraset TMPlusParent1 = refl moveeraset TMPlusParent2 = refl moveeraset (TMPlusZip1 {t2 = t2} m) = ap1 (λ x → x ⊕ t2) (moveeraset m) moveeraset (TMPlusZip2 {t1 = t1} m) = ap1 (λ x → t1 ⊕ x) (moveeraset m) moveeraset TMProdChild1 = refl moveeraset TMProdChild2 = refl moveeraset TMProdParent1 = refl moveeraset TMProdParent2 = refl moveeraset (TMProdZip1 {t2 = t2} m) = ap1 (λ x → x ⊠ t2) (moveeraset m) moveeraset (TMProdZip2 {t1 = t1} m) = ap1 (λ x → t1 ⊠ x) (moveeraset m) -- the actual movements don't change the erasure moveerase : {e e' : zexp} {δ : direction} → (e + move δ +>e e') → (e ◆e) == (e' ◆e) moveerase EMAscChild1 = refl moveerase EMAscChild2 = refl moveerase EMAscParent1 = refl moveerase EMAscParent2 = refl moveerase EMLamChild1 = refl moveerase EMLamParent = refl moveerase EMHalfLamChild1 = refl moveerase EMHalfLamChild2 = refl moveerase EMHalfLamParent1 = refl moveerase EMHalfLamParent2 = refl moveerase EMPlusChild1 = refl moveerase EMPlusChild2 = refl moveerase EMPlusParent1 = refl moveerase EMPlusParent2 = refl moveerase EMApChild1 = refl moveerase EMApChild2 = refl moveerase EMApParent1 = refl moveerase EMApParent2 = refl moveerase EMNEHoleChild1 = refl moveerase EMNEHoleParent = refl moveerase EMInlChild1 = refl moveerase EMInlParent = refl moveerase EMInrChild1 = refl moveerase EMInrParent = refl moveerase EMCaseParent1 = refl moveerase EMCaseParent2 = refl moveerase EMCaseParent3 = refl moveerase EMCaseChild1 = refl moveerase EMCaseChild2 = refl moveerase EMCaseChild3 = refl moveerase EMPairChild1 = refl moveerase EMPairChild2 = refl moveerase EMPairParent1 = refl moveerase EMPairParent2 = refl moveerase EMFstChild1 = refl moveerase EMFstParent = refl moveerase EMSndChild1 = refl moveerase EMSndParent = refl -- this form is essentially the same as above, but for judgemental -- erasure, which is sometimes more convenient. moveerasee' : {e e' : zexp} {e◆ : hexp} {δ : direction} → erase-e e e◆ → e + move δ +>e e' → erase-e e' e◆ moveerasee' er1 m with erase-e◆ er1 ... | refl = ◆erase-e _ _ (! (moveerase m)) moveeraset' : ∀{t t◆ t'' δ} → erase-t t t◆ → t + move δ +> t'' → erase-t t'' t◆ moveeraset' er m with erase-t◆ er moveeraset' er m | refl = ◆erase-t _ _ (! (moveeraset m)) -- movements don't change either the type or expression under expression -- actions mutual moveerase-synth : ∀{Γ e e' e◆ t t' δ } → erase-e e e◆ → Γ ⊢ e◆ => t → Γ ⊢ e => t ~ move δ ~> e' => t' → (e ◆e) == (e' ◆e) × t == t' moveerase-synth er wt (SAMove x) = moveerase x , refl moveerase-synth (EEPlusL er) (SPlus x x₁) (SAZipPlus1 x₂) = ap1 (λ q → q ·+ _) (moveerase-ana er x x₂) , refl moveerase-synth (EEPlusR er) (SPlus x x₁) (SAZipPlus2 x₂) = ap1 (λ q → _ ·+ q) (moveerase-ana er x₁ x₂) , refl moveerase-synth (EEAscL er) (SAsc x) (SAZipAsc1 x₁) = ap1 (λ q → q ·: _) (moveerase-ana er x x₁) , refl moveerase-synth er wt (SAZipAsc2 x x₁ x₂ x₃) with moveeraset x ... | qq = ap1 (λ q → _ ·: q) qq , eq-ert-trans qq x₂ x₁ moveerase-synth (EEHalfLamL x) (SLam x₁ wt) (SAZipLam1 x₂ x₃ x₄ x₅ x₆ x₇) with erase-t◆ x₃ ... | refl with erase-t◆ x₄ ... | refl with moveeraset x₅ ... | qq rewrite qq with synthunicity x₇ x₆ ... | refl = refl , refl moveerase-synth (EEHalfLamR er) (SLam x wt) (SAZipLam2 x₁ x₂ x₃ x₄) with moveerase-synth x₂ x₃ x₄ ... | qq , refl rewrite qq = refl , refl moveerase-synth (EEApL er) (SAp wt x x₁) (SAZipApArr x₂ x₃ x₄ d x₅) with erasee-det x₃ er ... | refl with synthunicity wt x₄ ... | refl with moveerase-synth er x₄ d ... | pp , refl with ▸arr-unicity x x₂ ... | refl = (ap1 (λ q → q ∘ _) pp ) , refl moveerase-synth (EEApR er) (SAp wt x x₁) (SAZipApAna x₂ x₃ x₄) with synthunicity x₃ wt ... | refl with ▸arr-unicity x x₂ ... | refl = ap1 (λ q → _ ∘ q) (moveerase-ana er x₁ x₄ ) , refl moveerase-synth er wt (SAZipNEHole x x₁ d) = ap1 ⦇⌜_⌟⦈[ _ ] (π1 (moveerase-synth x x₁ d)) , refl moveerase-synth er wt (SAZipPair1 x x₁ x₂ x₃) with moveerase-synth x x₁ x₂ ... | π1 , refl = (ap1 (λ q → ⟨ q , _ ⟩) π1) , refl moveerase-synth er wt (SAZipPair2 x x₁ x₂ x₃) with moveerase-synth x₁ x₂ x₃ ... | π1 , refl = (ap1 (λ q → ⟨ _ , q ⟩) π1) , refl moveerase-synth er wt (SAZipFst x x₁ x₂ x₃ x₄) with moveerase-synth x₂ x₃ x₄ ... | π1 , refl with ▸prod-unicity x₁ x ... | refl = (ap1 fst π1) , refl moveerase-synth er wt (SAZipSnd x x₁ x₂ x₃ x₄) with moveerase-synth x₂ x₃ x₄ ... | π1 , refl with ▸prod-unicity x₁ x ... | refl = (ap1 snd π1) , refl moveerase-ana : ∀{Γ e e' e◆ t δ } → erase-e e e◆ → Γ ⊢ e◆ <= t → Γ ⊢ e ~ move δ ~> e' ⇐ t → (e ◆e) == (e' ◆e) moveerase-ana er wt (AASubsume x x₁ x₂ x₃) = π1 (moveerase-synth x x₁ x₂) moveerase-ana er wt (AAMove x) = moveerase x moveerase-ana (EELam er) (ASubsume () x₂) _ moveerase-ana (EELam er) (ALam x₁ x₂ wt) (AAZipLam x₃ x₄ d) with ▸arr-unicity x₂ x₄ ... | refl = ap1 (λ q → ·λ _ q) (moveerase-ana er wt d) moveerase-ana (EEInl er) (ASubsume () x₁) (AAZipInl x₂ d) moveerase-ana (EEInl er) (AInl x wt) (AAZipInl x₁ d) with ▸sum-unicity x x₁ ... | refl = ap1 inl (moveerase-ana er wt d) moveerase-ana (EEInr er) (ASubsume () x₁) (AAZipInr x₂ d) moveerase-ana (EEInr er) (AInr x wt) (AAZipInr x₁ d) with ▸sum-unicity x x₁ ... | refl = ap1 inr (moveerase-ana er wt d) moveerase-ana er wt (AAZipCase1 x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈) = ap1 (λ q → case q _ _ _ _) (π1(moveerase-synth x₃ x₄ x₅)) moveerase-ana (EECase2 er) (ASubsume () x₂) (AAZipCase2 x₃ x₄ x₅ x₆ d) moveerase-ana (EECase2 er) (ACase x₁ x₂ x₃ x₄ wt wt₁) (AAZipCase2 x₅ x₆ x₇ x₈ d) with synthunicity x₄ x₇ ... | refl with ▸sum-unicity x₃ x₈ ... | refl = ap1 (λ q → case _ _ q _ _) (moveerase-ana er wt d) moveerase-ana (EECase3 er) (ASubsume () x₂) (AAZipCase3 x₃ x₄ x₅ x₆ d) moveerase-ana (EECase3 er) (ACase x₁ x₂ x₃ x₄ wt wt₁) (AAZipCase3 x₅ x₆ x₇ x₈ d) with synthunicity x₄ x₇ ... | refl with ▸sum-unicity x₃ x₈ ... | refl = ap1 (λ q → case _ _ _ _ q) (moveerase-ana er wt₁ d)
{ "alphanum_fraction": 0.6118114552, "avg_line_length": 41.9425287356, "ext": "agda", "hexsha": "b30d6e5517b9b68cac74f3ba3b717262e6e09a7d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-agda", "max_forks_repo_path": "moveerase.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnut-agda", "max_issues_repo_path": "moveerase.agda", "max_line_length": 87, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-agda", "max_stars_repo_path": "moveerase.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2889, "size": 7298 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Some code related to indexed AVL trees that relies on the K rule ------------------------------------------------------------------------ {-# OPTIONS --with-K --safe #-} open import Relation.Binary open import Relation.Binary.PropositionalEquality using (_≡_; refl; subst) module Data.AVL.Indexed.WithK {k r} (Key : Set k) {_<_ : Rel Key r} (isStrictTotalOrder : IsStrictTotalOrder _≡_ _<_) where strictTotalOrder = record { isStrictTotalOrder = isStrictTotalOrder } open import Data.Product open import Data.AVL.Indexed strictTotalOrder as AVL hiding (Value) module _ {v} {V′ : Key → Set v} where private V : AVL.Value v V = AVL.MkValue V′ (subst V′) node-injectiveˡ : ∀ {hˡ hʳ h l u k} {lk₁ : Tree V l [ proj₁ k ] hˡ} {lk₂ : Tree V l [ proj₁ k ] hˡ} {ku₁ : Tree V [ proj₁ k ] u hʳ} {ku₂ : Tree V [ proj₁ k ] u hʳ} {bal₁ bal₂ : hˡ ∼ hʳ ⊔ h} → node k lk₁ ku₁ bal₁ ≡ node k lk₂ ku₂ bal₂ → lk₁ ≡ lk₂ node-injectiveˡ refl = refl node-injectiveʳ : ∀ {hˡ hʳ h l u k} {lk₁ : Tree V l [ proj₁ k ] hˡ} {lk₂ : Tree V l [ proj₁ k ] hˡ} {ku₁ : Tree V [ proj₁ k ] u hʳ} {ku₂ : Tree V [ proj₁ k ] u hʳ} {bal₁ bal₂ : hˡ ∼ hʳ ⊔ h} → node k lk₁ ku₁ bal₁ ≡ node k lk₂ ku₂ bal₂ → ku₁ ≡ ku₂ node-injectiveʳ refl = refl node-injective-bal : ∀ {hˡ hʳ h l u k} {lk₁ : Tree V l [ proj₁ k ] hˡ} {lk₂ : Tree V l [ proj₁ k ] hˡ} {ku₁ : Tree V [ proj₁ k ] u hʳ} {ku₂ : Tree V [ proj₁ k ] u hʳ} {bal₁ bal₂ : hˡ ∼ hʳ ⊔ h} → node k lk₁ ku₁ bal₁ ≡ node k lk₂ ku₂ bal₂ → bal₁ ≡ bal₂ node-injective-bal refl = refl
{ "alphanum_fraction": 0.559976247, "avg_line_length": 35.829787234, "ext": "agda", "hexsha": "870eaad02b0956162b92f22d219a292df2cd448b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/AVL/Indexed/WithK.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/AVL/Indexed/WithK.agda", "max_line_length": 74, "max_stars_count": 5, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/AVL/Indexed/WithK.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 611, "size": 1684 }
{-# OPTIONS --safe #-} module Cubical.Algebra.Semigroup where open import Cubical.Algebra.Semigroup.Base public
{ "alphanum_fraction": 0.7521367521, "avg_line_length": 23.4, "ext": "agda", "hexsha": "53e0c0385c431a379685772c128820cfc2717aec", "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/Semigroup.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/Semigroup.agda", "max_line_length": 50, "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/Semigroup.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": 28, "size": 117 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.NType2 open import lib.types.Empty open import lib.types.Group open import lib.types.Int open import lib.types.List open import lib.types.Nat open import lib.types.Pi open import lib.types.Sigma module lib.types.Word {i} where module _ (A : Type i) where PlusMinus : Type i PlusMinus = Coprod A A Word : Type i Word = List PlusMinus module _ {A : Type i} where flip : PlusMinus A → PlusMinus A flip (inl a) = inr a flip (inr a) = inl a flip-flip : ∀ x → flip (flip x) == x flip-flip (inl x) = idp flip-flip (inr x) = idp Word-flip : Word A → Word A Word-flip = map flip Word-flip-flip : ∀ w → Word-flip (Word-flip w) == w Word-flip-flip nil = idp Word-flip-flip (x :: l) = ap2 _::_ (flip-flip x) (Word-flip-flip l) Word-inverse : Word A → Word A Word-inverse = reverse ∘ Word-flip Word-inverse-inverse : ∀ w → Word-inverse (Word-inverse w) == w Word-inverse-inverse w = Word-inverse (Word-inverse w) =⟨ reverse-map flip (Word-inverse w) ⟩ Word-flip (reverse (reverse (Word-flip w))) =⟨ ap Word-flip (reverse-reverse (Word-flip w)) ⟩ Word-flip (Word-flip w) =⟨ Word-flip-flip w ⟩ w =∎ Word-exp : A → ℤ → Word A Word-exp a (pos 0) = nil Word-exp a (pos (S n)) = inl a :: Word-exp a (pos n) Word-exp a (negsucc 0) = inr a :: nil Word-exp a (negsucc (S n)) = inr a :: Word-exp a (negsucc n) module _ {A : Type i} {j} (G : Group j) where private module G = Group G module _ (f : A → G.El) where PlusMinus-extendᴳ : PlusMinus A → G.El PlusMinus-extendᴳ (inl a) = f a PlusMinus-extendᴳ (inr a) = G.inv (f a) PlusMinus-extendᴳ-flip : ∀ x → PlusMinus-extendᴳ (flip x) == G.inv (PlusMinus-extendᴳ x) PlusMinus-extendᴳ-flip (inl a) = idp PlusMinus-extendᴳ-flip (inr a) = ! (G.inv-inv (f a)) Word-extendᴳ : Word A → G.El Word-extendᴳ = foldr' G.comp G.ident ∘ map PlusMinus-extendᴳ abstract Word-extendᴳ-++ : ∀ f l₁ l₂ → Word-extendᴳ f (l₁ ++ l₂) == G.comp (Word-extendᴳ f l₁) (Word-extendᴳ f l₂) Word-extendᴳ-++ f nil l₂ = ! $ G.unit-l _ Word-extendᴳ-++ f (x₁ :: nil) nil = ! (G.unit-r _) Word-extendᴳ-++ f (x₁ :: nil) (x₂ :: l₂) = idp Word-extendᴳ-++ f (x₁ :: l₁@(_ :: _)) l₂ = G.comp (PlusMinus-extendᴳ f x₁) (Word-extendᴳ f (l₁ ++ l₂)) =⟨ ap (G.comp (PlusMinus-extendᴳ f x₁)) (Word-extendᴳ-++ f l₁ l₂) ⟩ G.comp (PlusMinus-extendᴳ f x₁) (G.comp (Word-extendᴳ f l₁) (Word-extendᴳ f l₂)) =⟨ ! (G.assoc _ _ _) ⟩ G.comp (G.comp (PlusMinus-extendᴳ f x₁) (Word-extendᴳ f l₁)) (Word-extendᴳ f l₂) =∎ module _ {A : Type i} {j} (G : AbGroup j) where private module G = AbGroup G abstract PlusMinus-extendᴳ-comp : ∀ (f g : A → G.El) x → PlusMinus-extendᴳ G.grp (λ a → G.comp (f a) (g a)) x == G.comp (PlusMinus-extendᴳ G.grp f x) (PlusMinus-extendᴳ G.grp g x) PlusMinus-extendᴳ-comp f g (inl a) = idp PlusMinus-extendᴳ-comp f g (inr a) = G.inv-comp (f a) (g a) ∙ G.comm (G.inv (g a)) (G.inv (f a)) Word-extendᴳ-comp : ∀ (f g : A → G.El) l → Word-extendᴳ G.grp (λ a → G.comp (f a) (g a)) l == G.comp (Word-extendᴳ G.grp f l) (Word-extendᴳ G.grp g l) Word-extendᴳ-comp f g nil = ! (G.unit-l G.ident) Word-extendᴳ-comp f g (x :: nil) = PlusMinus-extendᴳ-comp f g x Word-extendᴳ-comp f g (x :: l@(_ :: _)) = G.comp (PlusMinus-extendᴳ G.grp (λ a → G.comp (f a) (g a)) x) (Word-extendᴳ G.grp (λ a → G.comp (f a) (g a)) l) =⟨ ap2 G.comp (PlusMinus-extendᴳ-comp f g x) (Word-extendᴳ-comp f g l) ⟩ G.comp (G.comp (PlusMinus-extendᴳ G.grp f x) (PlusMinus-extendᴳ G.grp g x)) (G.comp (Word-extendᴳ G.grp f l) (Word-extendᴳ G.grp g l)) =⟨ G.interchange (PlusMinus-extendᴳ G.grp f x) (PlusMinus-extendᴳ G.grp g x) (Word-extendᴳ G.grp f l) (Word-extendᴳ G.grp g l) ⟩ G.comp (G.comp (PlusMinus-extendᴳ G.grp f x) (Word-extendᴳ G.grp f l)) (G.comp (PlusMinus-extendᴳ G.grp g x) (Word-extendᴳ G.grp g l)) =∎ module RelationRespectingFunctions (A : Type i) {m} (R : Rel (Word A) m) {j} (G : Group j) where private module G = Group G respects-rel : (A → G.El) → Type (lmax (lmax i j) m) respects-rel f = ∀ {l₁ l₂} → R l₁ l₂ → Word-extendᴳ G f l₁ == Word-extendᴳ G f l₂ abstract respects-rel-is-prop : ∀ f → is-prop (respects-rel f) respects-rel-is-prop f = Πi-level $ λ l₁ → Πi-level $ λ l₂ → Π-level $ λ r → has-level-apply G.El-level _ _ record RelationRespectingFunction : Type (lmax (lmax i j) m) where constructor rel-res-fun field f : A → G.El respects : respects-rel f RelationRespectingFunction= : {lf lg : RelationRespectingFunction} → RelationRespectingFunction.f lf == RelationRespectingFunction.f lg → lf == lg RelationRespectingFunction= {rel-res-fun f f-respect} {rel-res-fun .f g-respect} idp = ap (rel-res-fun f) (prop-path (respects-rel-is-prop f) f-respect g-respect) {- For the empty relation, this is exactly the type of functions -} module _ (A : Type i) {j} (G : Group j) where private module G = Group G open RelationRespectingFunctions A empty-rel G every-function-respects-empty-rel : ∀ (f : A → G.El) → RelationRespectingFunction every-function-respects-empty-rel f = rel-res-fun f (λ {_} {_} ()) every-function-respects-empty-rel-equiv : (A → G.El) ≃ RelationRespectingFunction every-function-respects-empty-rel-equiv = equiv every-function-respects-empty-rel RelationRespectingFunction.f (λ lf → RelationRespectingFunction= idp) (λ f → idp)
{ "alphanum_fraction": 0.6123163051, "avg_line_length": 35.9496855346, "ext": "agda", "hexsha": "9eb40c4a9cec4734dbfd6abc534cbadef6a0e0c0", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AntoineAllioux/HoTT-Agda", "max_forks_repo_path": "core/lib/types/Word.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "AntoineAllioux/HoTT-Agda", "max_issues_repo_path": "core/lib/types/Word.agda", "max_line_length": 100, "max_stars_count": 294, "max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AntoineAllioux/HoTT-Agda", "max_stars_repo_path": "core/lib/types/Word.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 2129, "size": 5716 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import cw.CW open import cw.FinCW open import cw.FinBoundary open import cohomology.Theory open import cohomology.ChainComplex module cw.cohomology.ReconstructedCochainsEquivCellularCochains (OT : OrdinaryTheory lzero) where open OrdinaryTheory OT open import cw.cohomology.cellular.ChainComplex as CCC open import cw.cohomology.reconstructed.cochain.Complex OT as RCC open import cw.cohomology.ReconstructedCochainsIsoCellularCochains OT open import cw.cohomology.cochainequiv.AugmentCommSquare OT open import cw.cohomology.cochainequiv.FirstCoboundaryCommSquare OT open import cw.cohomology.cochainequiv.HigherCoboundaryCommSquare OT private frcc-comm-fccc-Type : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n) {m} (m≤n? : Dec (m ≤ n)) (Sm≤n? : Dec (S m ≤ n)) (coboundary : AbGroup.grp (RCC.cochain-template ⊙⦉ ⊙fin-skel ⦊ m≤n?) →ᴳ AbGroup.grp (RCC.cochain-template ⊙⦉ ⊙fin-skel ⦊ Sm≤n?)) (boundary : AbGroup.grp (CCC.chain-template ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊ Sm≤n?) →ᴳ AbGroup.grp (CCC.chain-template ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊ m≤n?)) → Type₀ frcc-comm-fccc-Type {n} ⊙fin-skel {m} m≤n? Sm≤n? coboundary boundary = CommSquareᴳ coboundary (pre∘ᴳ-hom (C2-abgroup 0) boundary) (GroupIso.f-hom (rcc-iso-ccc-template ⊙⦉ ⊙fin-skel ⦊ m≤n? (⊙FinSkeleton-has-cells-with-choice 0 ⊙fin-skel lzero))) (GroupIso.f-hom (rcc-iso-ccc-template ⊙⦉ ⊙fin-skel ⦊ Sm≤n? (⊙FinSkeleton-has-cells-with-choice 0 ⊙fin-skel lzero))) CCC-boundary-template' : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n) → {m : ℕ} (m≤n? : Dec (m ≤ n)) (Sm≤n? : Dec (S m ≤ n)) → AbGroup.grp (CCC.chain-template ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊ Sm≤n?) →ᴳ AbGroup.grp (CCC.chain-template ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊ m≤n?) CCC-boundary-template' ⊙fin-skel = CCC.boundary-template ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊ (FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel)) (FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel)) RCC-coboundary-template' : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n) → {m : ℕ} (m≤n? : Dec (m ≤ n)) (Sm≤n? : Dec (S m ≤ n)) → AbGroup.grp (RCC.cochain-template ⊙⦉ ⊙fin-skel ⦊ m≤n?) →ᴳ AbGroup.grp (RCC.cochain-template ⊙⦉ ⊙fin-skel ⦊ Sm≤n?) RCC-coboundary-template' ⊙fin-skel = RCC.coboundary-template ⊙⦉ ⊙fin-skel ⦊ abstract {- This can be directly generalized to the non-finite cases. -} frcc-comm-fccc-above : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n) {m} (m≤n? : Dec (m ≤ n)) (Sm≰n : ¬ (S m ≤ n)) → frcc-comm-fccc-Type ⊙fin-skel m≤n? (inr Sm≰n) (RCC-coboundary-template' ⊙fin-skel m≤n? (inr Sm≰n)) (CCC-boundary-template' ⊙fin-skel m≤n? (inr Sm≰n)) frcc-comm-fccc-above ⊙fin-skel m≤n? Sm≰n = (comm-sqrᴳ λ g → group-hom= $ λ= λ _ → ! $ GroupHom.pres-ident (GroupIso.f (rcc-iso-ccc-template ⊙⦉ ⊙fin-skel ⦊ m≤n? (⊙FinSkeleton-has-cells-with-choice 0 ⊙fin-skel lzero)) g)) frcc-comm-fccc-nth-zero : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n) (0≤n : 0 ≤ n) (1≤n : 1 ≤ n) → frcc-comm-fccc-Type ⊙fin-skel (inl 0≤n) (inl 1≤n) (RCC-coboundary-template' ⊙fin-skel (inl 0≤n) (inl 1≤n)) (CCC-boundary-template' ⊙fin-skel (inl 0≤n) (inl 1≤n)) frcc-comm-fccc-nth-zero ⊙fin-skel (inl idp) (inl 1=0) = ⊥-rec (ℕ-S≠O O 1=0) frcc-comm-fccc-nth-zero ⊙fin-skel (inl idp) (inr ()) frcc-comm-fccc-nth-zero ⊙fin-skel (inr ltS) (inl 1=1) = transport! (λ 1=1 → frcc-comm-fccc-Type ⊙fin-skel (inl lteS) (inl (inl 1=1)) (RCC-coboundary-template' ⊙fin-skel (inl lteS) (inl (inl 1=1))) (CCC-boundary-template' ⊙fin-skel (inl lteS) (inl (inl 1=1)))) (prop-has-all-paths 1=1 idp) (coe! (ap2 (λ p₁ p₂ → frcc-comm-fccc-Type ⊙fin-skel {m = O} (inl (inr ltS)) (inl (inl idp)) p₁ p₂) (RCC.coboundary-first-template-β ⊙⦉ ⊙fin-skel ⦊) (CCC.boundary-template-β ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊ (FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel)) (FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel)))) (fst (first-coboundary-comm-sqrᴳ ⊙fin-skel))) frcc-comm-fccc-nth-zero ⊙fin-skel (inr ltS) (inr (ltSR ())) frcc-comm-fccc-nth-zero ⊙fin-skel (inr (ltSR 0<n)) (inl 1=Sn) = ⊥-rec (<-to-≠ (<-ap-S 0<n) 1=Sn) frcc-comm-fccc-nth-zero ⊙fin-skel (inr (ltSR ltS)) (inr 1<2) = transport! (λ 1<2 → frcc-comm-fccc-Type ⊙fin-skel (inl (inr (ltSR ltS))) (inl (inr 1<2)) (RCC-coboundary-template' ⊙fin-skel (inl (inr (ltSR ltS))) (inl (inr 1<2))) (CCC-boundary-template' ⊙fin-skel (inl (inr (ltSR ltS))) (inl (inr 1<2)))) (prop-has-all-paths 1<2 ltS) (coe! (ap2 (λ p₁ p₂ → frcc-comm-fccc-Type ⊙fin-skel (inl (inr (ltSR ltS))) (inl (inr ltS)) p₁ p₂) (RCC.coboundary-first-template-descend-from-two ⊙⦉ ⊙fin-skel ⦊) (CCC.boundary-template-descend-from-two-above ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊ (FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel)) (FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel)))) (frcc-comm-fccc-nth-zero (⊙fcw-init ⊙fin-skel) (inr ltS) (inl idp))) frcc-comm-fccc-nth-zero ⊙fin-skel (inr (ltSR (ltSR ()))) (inr ltS) frcc-comm-fccc-nth-zero ⊙fin-skel (inr (ltSR (ltSR 0<n))) (inr (ltSR 1<Sn)) = (coe! (ap2 (λ p₁ p₂ → frcc-comm-fccc-Type ⊙fin-skel (inl (inr (ltSR (ltSR 0<n)))) (inl (inr (ltSR 1<Sn))) p₁ p₂) (RCC.coboundary-first-template-descend-from-far ⊙⦉ ⊙fin-skel ⦊ (ltSR 0<n) 1<Sn) (CCC.boundary-template-descend-from-far ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊ (FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel)) (FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel)) (ltSR 0<n) 1<Sn)) (frcc-comm-fccc-nth-zero (⊙fcw-init ⊙fin-skel) (inr (ltSR 0<n)) (inr 1<Sn))) frcc-comm-fccc-nth-higher : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n) {m} (Sm≤n : S m ≤ n) (SSm≤n : S (S m) ≤ n) → frcc-comm-fccc-Type ⊙fin-skel (inl Sm≤n) (inl SSm≤n) (RCC-coboundary-template' ⊙fin-skel (inl Sm≤n) (inl SSm≤n)) (CCC-boundary-template' ⊙fin-skel (inl Sm≤n) (inl SSm≤n)) frcc-comm-fccc-nth-higher ⊙fin-skel (inl idp) (inl SSm=Sm) = ⊥-rec (<-to-≠ ltS (! SSm=Sm)) frcc-comm-fccc-nth-higher ⊙fin-skel (inl idp) (inr SSm<Sm) = ⊥-rec (<-to-≠ (<-trans SSm<Sm ltS) idp) frcc-comm-fccc-nth-higher ⊙fin-skel {m} (inr ltS) (inl SSm=SSm) = transport! (λ SSm=SSm → frcc-comm-fccc-Type ⊙fin-skel (inl lteS) (inl (inl SSm=SSm)) (RCC-coboundary-template' ⊙fin-skel (inl lteS) (inl (inl SSm=SSm))) (CCC-boundary-template' ⊙fin-skel (inl lteS) (inl (inl SSm=SSm)))) (prop-has-all-paths SSm=SSm idp) (coe! (ap2 (λ p₁ p₂ → frcc-comm-fccc-Type ⊙fin-skel {m = S m} (inl (inr ltS)) (inl (inl idp)) p₁ p₂) (RCC.coboundary-higher-template-β ⊙⦉ ⊙fin-skel ⦊) (CCC.boundary-template-β ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊ (FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel)) (FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel)))) (fst (higher-coboundary-comm-sqrᴳ ⊙fin-skel))) frcc-comm-fccc-nth-higher ⊙fin-skel (inr ltS) (inr SSm<SSm) = ⊥-rec (<-to-≠ SSm<SSm idp) frcc-comm-fccc-nth-higher ⊙fin-skel (inr (ltSR Sm<n)) (inl SSm=Sn) = ⊥-rec (<-to-≠ (<-ap-S Sm<n) SSm=Sn) frcc-comm-fccc-nth-higher ⊙fin-skel (inr (ltSR ltS)) (inr SSm<SSSm) = transport! (λ SSm<SSSm → frcc-comm-fccc-Type ⊙fin-skel (inl (inr (ltSR ltS))) (inl (inr SSm<SSSm)) (RCC-coboundary-template' ⊙fin-skel (inl (inr (ltSR ltS))) (inl (inr SSm<SSSm))) (CCC-boundary-template' ⊙fin-skel (inl (inr (ltSR ltS))) (inl (inr SSm<SSSm)))) (prop-has-all-paths SSm<SSSm ltS) (coe! (ap2 (λ p₁ p₂ → frcc-comm-fccc-Type ⊙fin-skel (inl (inr (ltSR ltS))) (inl (inr ltS)) p₁ p₂) (RCC.coboundary-higher-template-descend-from-one-above ⊙⦉ ⊙fin-skel ⦊) (CCC.boundary-template-descend-from-two-above ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊ (FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel)) (FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel)))) (frcc-comm-fccc-nth-higher (⊙fcw-init ⊙fin-skel) (inr ltS) (inl idp))) frcc-comm-fccc-nth-higher ⊙fin-skel (inr (ltSR (ltSR Sm<Sm))) (inr ltS) = ⊥-rec (<-to-≠ Sm<Sm idp) frcc-comm-fccc-nth-higher ⊙fin-skel (inr (ltSR (ltSR Sm<n))) (inr (ltSR SSm<Sn)) = (coe! (ap2 (λ p₁ p₂ → frcc-comm-fccc-Type ⊙fin-skel (inl (inr (ltSR (ltSR Sm<n)))) (inl (inr (ltSR SSm<Sn))) p₁ p₂) (RCC.coboundary-higher-template-descend-from-far ⊙⦉ ⊙fin-skel ⦊ (ltSR Sm<n) SSm<Sn) (CCC.boundary-template-descend-from-far ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊ (FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel)) (FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel)) (ltSR Sm<n) SSm<Sn)) (frcc-comm-fccc-nth-higher (⊙fcw-init ⊙fin-skel) (inr (ltSR Sm<n)) (inr SSm<Sn))) frcc-comm-fccc-template : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n) {m} (m≤n? : Dec (m ≤ n)) (Sm≤n? : Dec (S m ≤ n)) → frcc-comm-fccc-Type ⊙fin-skel m≤n? Sm≤n? (RCC-coboundary-template' ⊙fin-skel m≤n? Sm≤n?) (CCC-boundary-template' ⊙fin-skel m≤n? Sm≤n?) frcc-comm-fccc-template ⊙fin-skel m≤n? (inr Sm≰n) = frcc-comm-fccc-above ⊙fin-skel m≤n? Sm≰n frcc-comm-fccc-template ⊙fin-skel (inr m≰n) (inl Sm≤n) = ⊥-rec $ m≰n (≤-trans lteS Sm≤n) frcc-comm-fccc-template ⊙fin-skel {m = O} (inl m≤n) (inl Sm≤n) = frcc-comm-fccc-nth-zero ⊙fin-skel m≤n Sm≤n frcc-comm-fccc-template ⊙fin-skel {m = S m} (inl Sm≤n) (inl SSm≤n) = frcc-comm-fccc-nth-higher ⊙fin-skel Sm≤n SSm≤n frcc-comm-fccc : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n) m → frcc-comm-fccc-Type ⊙fin-skel (≤-dec m n) (≤-dec (S m) n) (RCC-coboundary-template' ⊙fin-skel (≤-dec m n) (≤-dec (S m) n)) (CCC-boundary-template' ⊙fin-skel (≤-dec m n) (≤-dec (S m) n)) frcc-comm-fccc {n} ⊙fin-skel m = frcc-comm-fccc-template ⊙fin-skel {m} (≤-dec m n) (≤-dec (S m) n) frcc-comm-fccc-augment : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n) → CommSquareᴳ (CochainComplex.augment (RCC.cochain-complex ⊙⦉ ⊙fin-skel ⦊)) (pre∘ᴳ-hom (C2-abgroup 0) (FreeAbGroup-extend (Lift-abgroup {j = lzero} ℤ-abgroup) λ _ → lift 1)) (GroupIso.f-hom rhead-iso-chead) (GroupIso.f-hom (rcc-iso-ccc-template ⊙⦉ ⊙fin-skel ⦊ (inl (O≤ n)) (⊙FinSkeleton-has-cells-with-choice 0 ⊙fin-skel lzero))) frcc-comm-fccc-augment {n = O} ⊙fin-skel = fst (augment-comm-sqrᴳ ⊙fin-skel) frcc-comm-fccc-augment {n = S O} ⊙fin-skel = frcc-comm-fccc-augment (⊙fcw-init ⊙fin-skel) frcc-comm-fccc-augment {n = S (S n)} ⊙fin-skel = frcc-comm-fccc-augment (⊙fcw-init ⊙fin-skel) frcc-equiv-fccc : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n) → CochainComplexEquiv (RCC.cochain-complex ⊙⦉ ⊙fin-skel ⦊) (CCC.cochain-complex ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊ (FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel)) (FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel)) (C2-abgroup 0)) frcc-equiv-fccc {n} ⊙fin-skel = record { head = rhead-iso-chead ; cochain = λ m → rcc-iso-ccc ⊙⦉ ⊙fin-skel ⦊ m (⊙FinSkeleton-has-cells-with-choice 0 ⊙fin-skel lzero) ; augment = frcc-comm-fccc-augment ⊙fin-skel ; coboundary = frcc-comm-fccc ⊙fin-skel} frc-iso-fcc : ∀ {n} (⊙fin-skel : ⊙FinSkeleton n) (m : ℤ) → cohomology-group (RCC.cochain-complex ⊙⦉ ⊙fin-skel ⦊) m ≃ᴳ cohomology-group (CCC.cochain-complex ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊ (FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel)) (FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel)) (C2-abgroup 0)) m frc-iso-fcc ⊙fin-skel = cohomology-group-emap (frcc-equiv-fccc ⊙fin-skel)
{ "alphanum_fraction": 0.5909664197, "avg_line_length": 60.4095238095, "ext": "agda", "hexsha": "5814af5d6f6444f3c3fa158b708322333324e12f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/cw/cohomology/ReconstructedCochainsEquivCellularCochains.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/cw/cohomology/ReconstructedCochainsEquivCellularCochains.agda", "max_line_length": 121, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/cw/cohomology/ReconstructedCochainsEquivCellularCochains.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5146, "size": 12686 }
{- This file describes properties of computable relations. -} open import bool open import level open import eq open import product open import product-thms open import negation module relations where -- Decidable relations. -- This was taken from the Agda STDLIB. data Dec {p} (P : Set p) : Set p where yes : ( p : P) → Dec P no : (¬p : ¬ P) → Dec P module relationsOld {ℓ ℓ' : level}{A : Set ℓ} (_≥A_ : A → A → Set ℓ') where reflexive : Set (ℓ ⊔ ℓ') reflexive = ∀ {a : A} → a ≥A a transitive : Set (ℓ ⊔ ℓ') transitive = ∀ {a b c : A} → a ≥A b → b ≥A c → a ≥A c preorder : Set (ℓ ⊔ ℓ') preorder = reflexive ∧ transitive _iso_ : A → A → Set ℓ' d iso d' = d ≥A d' ∧ d' ≥A d iso-intro : ∀{x y : A} → x ≥A y → y ≥A x → x iso y iso-intro p1 p2 = p1 , p2
{ "alphanum_fraction": 0.5581113801, "avg_line_length": 22.9444444444, "ext": "agda", "hexsha": "06c3a3467f89f5b487ee8d79b7ea1fc04af1a53b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "heades/AUGL", "max_forks_repo_path": "relations.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "heades/AUGL", "max_issues_repo_path": "relations.agda", "max_line_length": 77, "max_stars_count": null, "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "heades/AUGL", "max_stars_repo_path": "relations.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 307, "size": 826 }
-- Andreas, 2016-09-20 test whether --no-eta-equality is respected {-# OPTIONS --no-eta-equality #-} record ⊤ : Set where test : ⊤ test = _ -- should remain unsolved
{ "alphanum_fraction": 0.6686390533, "avg_line_length": 18.7777777778, "ext": "agda", "hexsha": "12c5b3f15bad75952cfb0e7867a97db3a19529de", "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/NoEtaEquality.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/NoEtaEquality.agda", "max_line_length": 66, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/NoEtaEquality.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": 51, "size": 169 }
module BasicIPC.Metatheory.ClosedHilbert-BasicTarski where open import BasicIPC.Syntax.ClosedHilbert public open import BasicIPC.Semantics.BasicTarski public -- Soundness with respect to all models, or evaluation, for closed terms only. eval₀ : ∀ {A} → ⊢ A → ⊨ A eval₀ (app t u) = eval₀ t $ eval₀ u eval₀ ci = I eval₀ ck = K eval₀ cs = S eval₀ cpair = _,_ eval₀ cfst = π₁ eval₀ csnd = π₂ eval₀ unit = ∙ -- Correctness of evaluation with respect to conversion. eval₀✓ : ∀ {{_ : Model}} {A} {t t′ : ⊢ A} → t ⋙ t′ → eval₀ t ≡ eval₀ t′ eval₀✓ refl⋙ = refl eval₀✓ (trans⋙ p q) = trans (eval₀✓ p) (eval₀✓ q) eval₀✓ (sym⋙ p) = sym (eval₀✓ p) eval₀✓ (congapp⋙ p q) = cong² _$_ (eval₀✓ p) (eval₀✓ q) eval₀✓ (congi⋙ p) = cong I (eval₀✓ p) eval₀✓ (congk⋙ p q) = cong² K (eval₀✓ p) (eval₀✓ q) eval₀✓ (congs⋙ p q r) = cong³ S (eval₀✓ p) (eval₀✓ q) (eval₀✓ r) eval₀✓ (congpair⋙ p q) = cong² _,_ (eval₀✓ p) (eval₀✓ q) eval₀✓ (congfst⋙ p) = cong π₁ (eval₀✓ p) eval₀✓ (congsnd⋙ p) = cong π₂ (eval₀✓ p) eval₀✓ beta▻ₖ⋙ = refl eval₀✓ beta▻ₛ⋙ = refl eval₀✓ beta∧₁⋙ = refl eval₀✓ beta∧₂⋙ = refl eval₀✓ eta∧⋙ = refl eval₀✓ eta⊤⋙ = refl
{ "alphanum_fraction": 0.5765838011, "avg_line_length": 31.9743589744, "ext": "agda", "hexsha": "fce0e967c2b8541d43796e9883142a0c5ef5a612", "lang": "Agda", "max_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": "BasicIPC/Metatheory/ClosedHilbert-BasicTarski.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": "BasicIPC/Metatheory/ClosedHilbert-BasicTarski.agda", "max_line_length": 78, "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": "BasicIPC/Metatheory/ClosedHilbert-BasicTarski.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": 563, "size": 1247 }
{-# OPTIONS --without-K #-} open import Base open import Homotopy.PushoutDef open import Homotopy.PushoutUP as PushoutUP open import Homotopy.Truncation open import Homotopy.PullbackDef open import Homotopy.PullbackInvariantEquiv module Homotopy.TruncationRightExact {i} (n : ℕ₋₂) (d : pushout-diag i) where open pushout-diag d open import Homotopy.PushoutIsPushout d τd : pushout-diag i τd = diag (τ n A), (τ n B), (τ n C), (τ-fmap f), (τ-fmap g) module H = PushoutUP d (cst unit) module τH = PushoutUP τd (is-truncated n) -- I want to prove that [τ n d.pushout] is a pushout in [is-truncated n]. It -- first needs to be equipped with a cocone cocone-τpushout : τH.cocone (τ n (pushout d)) cocone-τpushout = (τ-fmap left , τ-fmap right , τ-extend ⦃ λ _ → ≡-is-truncated _ (τ-is-truncated _ _) ⦄ (ap proj ◯ glue)) -- We have a map [(τ n (pushout d) → E) → τH.cocone E] with [E] in [P] given by -- [τH.compose-cocone-map] and we want to prove that it’s an equivalence -- The idea is that it’s the composite of five equivalences: -- [equiv1 : τ n (pushout d) → E ≃ (pushout d) → E] -- by the universal property of truncations -- [equiv2 : (pushout d) → E ≃ H.cocone E] -- by the universal property of pushout in Type -- [equiv3 : H.cocone E ≃ pullback … (without truncations)] -- via [cocone-is-pullback] -- [equiv4 : pullback … (without truncations) ≃ pullback … (with truncations)] -- by the universal property of truncations and invariance of pullback wrt -- equivalence of diagrams -- [equiv5 : pullback … (with truncations) ≃ τH.cocone E] -- via [cocone-is-pullback] module _ (E : Set i) ⦃ P-E : is-truncated n E ⦄ where private ≡E-is-truncated#instance : {x y : E} → is-truncated n (x ≡ y) ≡E-is-truncated#instance = ≡-is-truncated n P-E λ-≡E-is-truncated#instance : {A : Set i} {u v : A → E} → ((x : A) → is-truncated n (u x ≡ v x)) λ-≡E-is-truncated#instance = λ _ → ≡E-is-truncated#instance ≡≡E-is-truncated#instance : {x y : E} {p q : x ≡ y} → is-truncated n (p ≡ q) ≡≡E-is-truncated#instance = ≡-is-truncated n (≡-is-truncated n P-E) λ-≡≡E-is-truncated#instance : {A : Set i} {x y : A → E} {p q : (a : A) → x a ≡ y a} → ((a : A) → is-truncated n (p a ≡ q a)) λ-≡≡E-is-truncated#instance = λ _ → ≡≡E-is-truncated#instance equiv1 : (τ n (pushout d) → E) ≃ (pushout d → E) equiv1 = ((λ u → u ◯ proj) , τ-up n _ _) equiv2 : (pushout d → E) ≃ H.cocone E equiv2 = ((λ f → ((f ◯ left) , (f ◯ right) , (ap f ◯ glue))) , pushout-is-pushout E) -- (could be defined more generally somewhere else) diag-hom : pullback-diag i diag-hom = diag (A → E), (B → E), (C → E), (λ u → u ◯ f), (λ u → u ◯ g) τdiag-hom : pullback-diag i τdiag-hom = diag (τ n A → E), (τ n B → E), (τ n C → E), (λ u → u ◯ τ-fmap f) , (λ u → u ◯ τ-fmap g) equiv3 : H.cocone E ≃ pullback diag-hom equiv3 = H.cocone-equiv-pullback E p₀ : (a : A → E) (x : τ n C) → τ-extend-nondep a (τ-fmap f x) ≡ τ-extend-nondep (a ◯ f) x p₀ a = τ-extend (λ x → refl) p : (a : A → E) → (τ-extend-nondep a) ◯ τ-fmap f ≡ τ-extend-nondep (a ◯ f) p a = funext (p₀ a) q₀ : (b : B → E) (x : τ n C) → τ-extend-nondep (b ◯ g) x ≡ τ-extend-nondep b (τ-fmap g x) q₀ b = τ-extend (λ x → refl) q : (b : B → E) → τ-extend-nondep (b ◯ g) ≡ (τ-extend-nondep b) ◯ τ-fmap g q b = funext (q₀ b) equiv4 : pullback diag-hom ≃ pullback τdiag-hom equiv4 = pullback-invariant-equiv diag-hom τdiag-hom (τ-extend-equiv n A E) (τ-extend-equiv n B E) (τ-extend-equiv n C E) p q equiv5 : pullback τdiag-hom ≃ τH.cocone E equiv5 = τH.pullback-equiv-cocone E -- We have defined the five equivalences, now we want to prove that the -- composite is what we want. We start by computing the composite of the -- equivalences 3, 4 and 5. map-543 : H.cocone E → τH.cocone E map-543 (a , b , e) = (τ-extend-nondep a , τ-extend-nondep b , τ-extend e) map-543-correct : (x : H.cocone E) → equiv5 ☆ (equiv4 ☆ (equiv3 ☆ x)) ≡ map-543 x map-543-correct (a , b , h) = ap (λ u → _ , _ , u) (funext (τ-extend (λ x → ap-concat (λ u → u (proj x)) (p a) (ap τ-extend-nondep (funext h) ∘ q b) ∘ (whisker-right _ (happly (happly-funext (p₀ a)) (proj x)) ∘ (ap-concat (λ u → u (proj x)) (ap τ-extend-nondep (funext h)) (q b) ∘ (whisker-right _ (compose-ap (λ u → u (proj x)) τ-extend-nondep (funext h)) ∘ (whisker-right _ (happly (happly-funext h) x) ∘ (whisker-left (h x) (happly (happly-funext (q₀ b)) (proj x)) ∘ refl-right-unit (h x))))))))) -- We now study the full composite map-54321 : (τ n (pushout d) → E) → τH.cocone E map-54321 = τH.compose-cocone-map _ _ cocone-τpushout map-21-A₀ : (f : τ n (pushout d) → E) (u : τ n A) → τH.A→top (map-543 (equiv2 ☆ (equiv1 ☆ f))) u ≡ τH.A→top (map-54321 f) u map-21-A₀ f = τ-extend (λ x → refl) map-21-A : (f : τ n (pushout d) → E) → τH.A→top (map-543 (equiv2 ☆ (equiv1 ☆ f))) ≡ τH.A→top (map-54321 f) map-21-A f = funext (map-21-A₀ f) map-21-B₀ : (f : τ n (pushout d) → E) (u : τ n B) → τH.B→top (map-543 (equiv2 ☆ (equiv1 ☆ f))) u ≡ τH.B→top (map-54321 f) u map-21-B₀ f = τ-extend (λ x → refl) map-21-B : (f : τ n (pushout d) → E) → τH.B→top (map-543 (equiv2 ☆ (equiv1 ☆ f))) ≡ τH.B→top (map-54321 f) map-21-B f = funext (map-21-B₀ f) map-21-correct : (h : τ n (pushout d) → E) → map-543 (equiv2 ☆ (equiv1 ☆ h)) ≡ map-54321 h map-21-correct h = τH.cocone-eq _ (map-21-A h) (map-21-B h) (τ-extend (λ x → whisker-right _ (happly (happly-funext (map-21-A₀ h)) (proj (f x))) ∘ (compose-ap h proj _ ∘ (! (refl-right-unit (ap (h ◯ proj) (glue x))) ∘ whisker-left (ap (h ◯ proj) (glue x)) (! (happly (happly-funext (map-21-B₀ h)) (proj (g x)))))))) map-54321-correct : (f : τ n (pushout d) → E) → equiv5 ☆ (equiv4 ☆ (equiv3 ☆ (equiv2 ☆ (equiv1 ☆ f)))) ≡ map-54321 f map-54321-correct f = map-543-correct (equiv2 ☆ (equiv1 ☆ f)) ∘ map-21-correct f map-54321-is-equiv : is-equiv map-54321 map-54321-is-equiv = transport is-equiv (funext map-54321-correct) (compose-is-equiv ((λ f₁ → equiv4 ☆ (equiv3 ☆ (equiv2 ☆ (equiv1 ☆ f₁)))) , compose-is-equiv ((λ f₁ → equiv3 ☆ (equiv2 ☆ (equiv1 ☆ f₁))) , compose-is-equiv ((λ f₁ → equiv2 ☆ (equiv1 ☆ f₁)) , compose-is-equiv equiv1 equiv2) equiv3) equiv4) equiv5) abstract τpushout-is-pushout : τH.is-pushout (τ n (pushout d)) cocone-τpushout τpushout-is-pushout E = map-54321-is-equiv E
{ "alphanum_fraction": 0.5553965073, "avg_line_length": 38.3846153846, "ext": "agda", "hexsha": "4827e52e85b05a6ab720de9a7cdf170561e6abc4", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "old/Homotopy/TruncationRightExact.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "old/Homotopy/TruncationRightExact.agda", "max_line_length": 80, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "old/Homotopy/TruncationRightExact.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 2598, "size": 6986 }
{-# OPTIONS --cubical --safe #-} module Container.Stream where open import Prelude open import Data.Fin open import Container Stream : Type a → Type a Stream = ⟦ ⊤ , const ℕ ⟧
{ "alphanum_fraction": 0.6983240223, "avg_line_length": 16.2727272727, "ext": "agda", "hexsha": "b318988f73b271d2e2176b13d6879e7f0a50f6d5", "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": "Container/Stream.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": "Container/Stream.agda", "max_line_length": 32, "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": "Container/Stream.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": 48, "size": 179 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Setoids.Setoids open import Functions open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Numbers.Naturals.Naturals open import Sets.FinSet open import Groups.Groups open import Groups.Definition open import Sets.EquivalenceRelations open import Setoids.Functions.Extension module Groups.SymmetricGroups.CycleType where
{ "alphanum_fraction": 0.817551963, "avg_line_length": 27.0625, "ext": "agda", "hexsha": "a407a6879944e22bed03f23f7c1572f21d403c49", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Groups/SymmetricGroups/CycleType.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Groups/SymmetricGroups/CycleType.agda", "max_line_length": 58, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Groups/SymmetricGroups/CycleType.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 104, "size": 433 }
module Structure.Setoid.Proofs where import Lvl open import Functional open import Logic open import Logic.Propositional open import Structure.Setoid open import Structure.Function open import Structure.Relator.Equivalence open import Structure.Relator.Properties {- module _ where private variable ℓ ℓ₁ ℓ₂ ℓ₃ : Level private variable A B : Type{ℓ} private variable P : Stmt{ℓ} Choice : (A → B → Stmt{ℓ}) → Stmt Choice{A = A}{B = B}(_▫_) = (∀{x} → ∃(y ↦ x ▫ y)) → (∃{Obj = A → B}(f ↦ ∀{x} → (x ▫ f(x)))) module _ ⦃ choice : ∀{ℓ₁ ℓ₂ ℓ₃}{A : Type{ℓ₁}}{B : Type{ℓ₂}}{_▫_ : A → B → Stmt{ℓ₃}} → Choice(_▫_) ⦄ where open import Data.Boolean open import Structure.Relator.Properties open import Structure.Relator.Properties.Proofs open import Relator.Equals.Proofs.Equiv thing : Stmt{ℓ} → Bool → Bool → Stmt thing P a b = (a ≡ b) ∨ P thing-functionallyTotal : ∀{x} → ∃(y ↦ thing P x y) thing-functionallyTotal {x = x} = [∃]-intro x ⦃ [∨]-introₗ (reflexivity(_≡_)) ⦄ thing-choice : ∃(f ↦ ∀{x} → thing(P) x (f(x))) thing-choice {P = P} = choice{_▫_ = thing P} thing-functionallyTotal instance thing-reflexivity : Reflexivity(thing(P)) Reflexivity.proof thing-reflexivity = [∨]-introₗ(reflexivity(_≡_)) instance thing-symmetry : Symmetry(thing(P)) Symmetry.proof thing-symmetry = [∨]-elim2 (symmetry(_≡_)) id instance thing-transitivity : Transitivity(thing(P)) Transitivity.proof thing-transitivity ([∨]-introₗ xy) ([∨]-introₗ yz) = [∨]-introₗ (transitivity(_) xy yz) Transitivity.proof thing-transitivity ([∨]-introₗ xy) ([∨]-introᵣ p) = [∨]-introᵣ p Transitivity.proof thing-transitivity ([∨]-introᵣ p) _ = [∨]-introᵣ p thing-ext : let ([∃]-intro f) = thing-choice{P = P} in ∀{a b} → thing(P) a b → (f(a) ≡ f(b)) thing-ext ([∨]-introₗ ab) = congruence₁([∃]-witness thing-choice) ab thing-ext {a = a} {b = b} ([∨]-introᵣ p) = {!!} thing-eq : let ([∃]-intro f) = thing-choice{P = P} in (P ↔ (f(𝐹) ≡ f(𝑇))) _⨯_.left (thing-eq {P = P}) ft with [∃]-proof (thing-choice{P = P}){𝐹} _⨯_.left (thing-eq {P = P}) ft | [∨]-introₗ ff = [∨]-syllogismₗ ([∃]-proof (thing-choice{P = P}){𝑇}) ((symmetry(_≢_) ⦃ negated-symmetry ⦄ ∘ [↔]-to-[←] [≢][𝑇]-is-[𝐹] ∘ symmetry(_≡_)) (transitivity(_≡_) ff ft)) _⨯_.left (thing-eq {P = P}) ft | [∨]-introᵣ p = p _⨯_.right (thing-eq {P = P}) p = thing-ext ([∨]-introᵣ p) bool-eq-classical : Classical₂ {X = Bool} (_≡_) choice-to-classical : Classical(P) excluded-middle ⦃ choice-to-classical {P = P} ⦄ with excluded-middle ⦃ bool-eq-classical {[∃]-witness (thing-choice{P = P}) 𝐹} {[∃]-witness (thing-choice{P = P}) 𝑇} ⦄ excluded-middle ⦃ choice-to-classical {P = P} ⦄ | [∨]-introₗ ft = [∨]-introₗ ([↔]-to-[←] thing-eq ft) excluded-middle ⦃ choice-to-classical {P = P} ⦄ | [∨]-introᵣ nft = [∨]-introᵣ (nft ∘ [↔]-to-[→] thing-eq) module _ ⦃ classical : ∀{ℓ}{P : Stmt{ℓ}} → Classical(P) ⦄ where proof-irrelevance : ∀{p₁ p₂ : P} → (p₁ ≡ p₂) proof-irrelevance with excluded-middle proof-irrelevance {P = P}{p₁}{p₂} | [∨]-introₗ p = {!!} proof-irrelevance {P = P}{p₁}{p₂} | [∨]-introᵣ np = [⊥]-elim(np p₁) -}
{ "alphanum_fraction": 0.5948116121, "avg_line_length": 42.0519480519, "ext": "agda", "hexsha": "4a9618d71d47c10172dd683ba2354c3cc0a1dc58", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Setoid/Proofs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Setoid/Proofs.agda", "max_line_length": 212, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Setoid/Proofs.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 1301, "size": 3238 }
module Data.NDTrie where open import Class.Map open import Data.Char open import Data.Char.Instance open import Data.List open import Data.List.Instance open import Data.AVL.Value open import Data.Product import Data.Char.Properties as Char import Data.Trie Char.<-strictTotalOrder-≈ as T NDTrie : Set -> Set NDTrie A = T.Trie (const _ A) _ instance NDTrie-Map : MapClass (List Char) NDTrie NDTrie-Map = record { insert = T.insert ; remove = T.deleteValue ; lookup = T.lookupValue ; mapSnd = λ f -> T.map f ; emptyMap = T.empty } trieKeys : ∀ {A} -> NDTrie A -> List (List Char) trieKeys t = Data.List.map proj₁ (T.toList t) lookupNDTrie : ∀ {A} -> List Char -> NDTrie A -> NDTrie A lookupNDTrie [] t = t lookupNDTrie (c ∷ cs) t = lookupNDTrie cs (T.lookupTrie c t)
{ "alphanum_fraction": 0.6555819477, "avg_line_length": 25.5151515152, "ext": "agda", "hexsha": "442abbb4daf3dbafa227faf579361bb29e9ddf01", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_path": "stdlib-exts/Data/NDTrie.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_path": "stdlib-exts/Data/NDTrie.agda", "max_line_length": 60, "max_stars_count": 35, "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_path": "stdlib-exts/Data/NDTrie.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": 254, "size": 842 }
-- New feature by Jesper Cockx in commit be89d4a8b264dd2719cb8c601a2c7f45a95ba220 : -- disabling the universe check for a data or record type. -- Andreas, 2018-10-27, re issue #3327: restructured test cases. -- Andreas, 2019-07-16, issue #3916: -- {-# NO_UNIVERSE_CHECK #-} should also disable the index sort check -- for --cubical-compatible. {-# OPTIONS --cubical-compatible #-} module _ where -- Switch off the index sort check module BigHetEq where {-# NO_UNIVERSE_CHECK #-} data _≅_ {a}{A : Set a} (x : A) : {B : Set a} → B → Set where refl : x ≅ x module PittsHetEq where {-# NO_UNIVERSE_CHECK #-} data _≅_ {a}{A : Set a} (x : A) : {B : Set a} → B → Set a where refl : x ≅ x -- Pragma is naturally attached to definition. module DataDef where data U : Set T : U → Set {-# NO_UNIVERSE_CHECK #-} data U where pi : (A : Set)(b : A → U) → U T (pi A b) = (x : A) → T (b x) -- Pragma can also be attached to signature. module DataSig where {-# NO_UNIVERSE_CHECK #-} data U : Set T : U → Set data U where pi : (A : Set)(b : A → U) → U T (pi A b) = (x : A) → T (b x) -- Works also for explicit mutual blocks. module Mutual where {-# NO_UNIVERSE_CHECK #-} data U : Set where pi : (A : Set)(b : A → U) → U T : U → Set T (pi A b) = (x : A) → T (b x) -- Records: module Records where {-# NO_UNIVERSE_CHECK #-} record R : Set where field out : Set {-# NO_UNIVERSE_CHECK #-} record S : Set record S where field out : Set
{ "alphanum_fraction": 0.6011865524, "avg_line_length": 19.4487179487, "ext": "agda", "hexsha": "5a5733930453604f10d1cacfe6a2c348cd54043e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Succeed/NoUniverseCheckPragma.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Succeed/NoUniverseCheckPragma.agda", "max_line_length": 83, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Succeed/NoUniverseCheckPragma.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 525, "size": 1517 }
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module CombiningProofs.CommDisjunction where open import Common.FOL.FOL postulate A B : Set ∨-comm : A ∨ B → B ∨ A {-# ATP prove ∨-comm #-}
{ "alphanum_fraction": 0.5548589342, "avg_line_length": 22.7857142857, "ext": "agda", "hexsha": "120227048b7f3309dcacc92c994095b4006b6ce9", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/thesis/report/CombiningProofs/CommDisjunction.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/thesis/report/CombiningProofs/CommDisjunction.agda", "max_line_length": 44, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/thesis/report/CombiningProofs/CommDisjunction.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": 83, "size": 319 }
-- Andreas, 2016-08-04, issue #964 -- Allow open metas and interaction points in imported files -- {-# OPTIONS -v import:100 #-} -- {-# OPTIONS -v meta.postulate:20 #-} -- {-# OPTIONS -v tc.conv.level:50 #-} open import Common.Level open import Common.Equality postulate something : Set₁ open import Common.Issue964.UnsolvedMetas something test = M.N.meta3 shouldFail : _≡_ {A = Level} meta (lsuc (lsuc lzero)) shouldFail = refl -- WAS: WEIRD ERROR: -- Set (Set .Issue964.UnsolvedMetas.1) != Set₂ -- when checking that the expression refl has type -- meta ≡ lsuc (lsuc lzero) -- NOW: -- Set (.Issue964.UnsolvedMetas.unsolved#meta.1 something) != Set₂ -- when checking that the expression refl has type -- meta ≡ lsuc (lsuc lzero)
{ "alphanum_fraction": 0.700947226, "avg_line_length": 25.4827586207, "ext": "agda", "hexsha": "d0d38d0f4a6938430aeacc047283871f70e2a763", "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/Issue964.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/Issue964.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/Fail/Issue964.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": 739 }
{-# OPTIONS --cubical #-} module Agda.Primitive.Cubical where {-# BUILTIN INTERVAL I #-} -- I : Setω {-# BUILTIN IZERO i0 #-} {-# BUILTIN IONE i1 #-} infix 30 primINeg infixr 20 primIMin primIMax primitive primIMin : I → I → I primIMax : I → I → I primINeg : I → I {-# BUILTIN ISONE IsOne #-} -- IsOne : I → Setω postulate itIsOne : IsOne i1 IsOne1 : ∀ i j → IsOne i → IsOne (primIMax i j) IsOne2 : ∀ i j → IsOne j → IsOne (primIMax i j) {-# BUILTIN ITISONE itIsOne #-} {-# BUILTIN ISONE1 IsOne1 #-} {-# BUILTIN ISONE2 IsOne2 #-} {-# BUILTIN PARTIAL Partial #-} {-# BUILTIN PARTIALP PartialP #-} postulate isOneEmpty : ∀ {a} {A : Partial i0 (Set a)} → PartialP i0 A {-# BUILTIN ISONEEMPTY isOneEmpty #-} primitive primPFrom1 : ∀ {a} {A : I → Set a} → A i1 → ∀ i j → Partial i (A (primIMax i j)) primPOr : ∀ {a} (i j : I) {A : Partial (primIMax i j) (Set a)} → PartialP i (λ z → A (IsOne1 i j z)) → PartialP j (λ z → A (IsOne2 i j z)) → PartialP (primIMax i j) A primComp : ∀ {a} (A : (i : I) → Set (a i)) (φ : I) → (∀ i → Partial φ (A i)) → (a : A i0) → A i1 syntax primPOr p q u t = [ p ↦ u , q ↦ t ] primitive primTransp : ∀ {a} (A : (i : I) → Set (a i)) (φ : I) → (a : A i0) → A i1 primHComp : ∀ {a} {A : Set a} {φ : I} → (∀ i → Partial φ A) → A → A
{ "alphanum_fraction": 0.5273124545, "avg_line_length": 29.847826087, "ext": "agda", "hexsha": "513798fc6910b494de6e09dc3c28bc68241968a0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f77b563d328513138d6c88bf0a3e350a9b91f8ed", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "bennn/agda", "max_forks_repo_path": "src/data/lib/prim/Agda/Primitive/Cubical.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f77b563d328513138d6c88bf0a3e350a9b91f8ed", "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": "bennn/agda", "max_issues_repo_path": "src/data/lib/prim/Agda/Primitive/Cubical.agda", "max_line_length": 98, "max_stars_count": null, "max_stars_repo_head_hexsha": "f77b563d328513138d6c88bf0a3e350a9b91f8ed", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "bennn/agda", "max_stars_repo_path": "src/data/lib/prim/Agda/Primitive/Cubical.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 546, "size": 1373 }
module Sessions.Semantics.Expr where open import Prelude open import Data.Fin open import Relation.Unary.PredicateTransformer hiding (_⊔_) open import Relation.Ternary.Separation.Morphisms open import Relation.Ternary.Separation.Monad open import Relation.Ternary.Separation.Monad.Reader open import Sessions.Syntax.Types open import Sessions.Syntax.Values open import Sessions.Syntax.Expr -- open import Sessions.Semantics.Commands open import Sessions.Semantics.Runtime open import Relation.Ternary.Separation.Construct.List Type -- open import Relation.Ternary.Separation.Monad.Free Cmd δ open import Relation.Ternary.Separation.Monad.Delay module _ where mutual data Cmd : Pred RCtx 0ℓ where fork : ∀[ Thread unit ⇒ Cmd ] mkchan : ∀ α → ε[ Cmd ] send : ∀ {a α} → ∀[ (Endptr (a ! α) ✴ Val a) ⇒ Cmd ] receive : ∀ {a α} → ∀[ Endptr (a ¿ α) ⇒ Cmd ] close : ∀[ Endptr end ⇒ Cmd ] yield : ε[ Cmd ] Cont : ∀ i {Δ} → Cmd Δ → Pt RCtx 0ℓ Cont i c P = δ c ─✴ Free i P data Free i : Pt RCtx 0ℓ where pure : ∀ {P} → ∀[ P ⇒ Free i P ] impure : ∀ {P Φ} → Thunk (λ j → (∃[ Cmd ]✴ (λ c → Cont j c P)) Φ) i → Free i P Φ δ : ∀ {Δ} → Cmd Δ → Pred RCtx 0ℓ δ (fork {α} _) = Emp δ (mkchan α) = Endptr α ✴ Endptr (α ⁻¹) δ (send {α = α} _) = Endptr α δ (receive {a} {α} _) = Val a ✴ Endptr α δ (close _) = Emp δ yield = Emp Thread : Type → Pred RCtx _ Thread a = Free ∞ (Val a) open Monads using (Monad; str; _&_) public m-monad : ∀ {i} → Monad ⊤ _ (λ _ _ → Free i) Monad.return m-monad px = pure px app (Monad.bind m-monad f) (pure px) σ = app f px σ app (Monad.bind m-monad f) (impure tx) σ = impure λ where .force → let cmd ×⟨ σ₁ ⟩ κ = tx .force _ , σ₂ , σ₃ = ⊎-assoc σ₁ (⊎-comm σ) in cmd ×⟨ σ₂ ⟩ wand λ r σ₄ → let _ , τ₁ , τ₂ = ⊎-assoc (⊎-comm σ₃) σ₄ in app (Monad.bind m-monad f) (app κ r τ₂) τ₁ module _ {i} where open ReaderTransformer id-morph Val (Free i) {{m-monad}} renaming (Reader to T) public M : Size → LCtx → LCtx → Pt RCtx 0ℓ M i Γ₁ Γ₂ P = T {i} Γ₁ Γ₂ P -- open import Relation.Ternary.Separation.Monad.Free Cmd δ renaming (Cont to Cont') ⟪_⟫ : ∀ {i Φ} → (c : Cmd Φ) → Free i (δ c) Φ ⟪_⟫ c = impure (λ where .force → c ×⟨ ⊎-idʳ ⟩ wand λ r σ → case ⊎-id⁻ˡ σ of λ where refl → pure r ) open Monad reader-monad public mutual eval : ∀ {i} → Exp a Γ → ε[ M i Γ [] (Val a) ] eval unit = do return tt eval (var refl) = do (v :⟨ σ ⟩: nil) ← ask case ⊎-id⁻ʳ σ of λ where refl → return v eval (lam a e) = do env ← ask return (clos e env) eval (ap (f ×⟨ Γ≺ ⟩ e)) = do v ← frame (⊎-comm Γ≺) (►eval e) {!!} -- eval⊸ f v eval (pairs (e₁ ×⟨ Γ≺ ⟩ e₂)) = do v₁ ← frame Γ≺ (►eval e₁) v₂⋆v₂ ← ►eval e₂ & v₁ return (pairs (✴-swap v₂⋆v₂)) eval (letpair (e₁ ×⟨ Γ≺ ⟩ e₂)) = do pairs (v₁ ×⟨ σ ⟩ v₂) ← frame Γ≺ (►eval e₁) empty ← prepend (cons (v₁ ×⟨ σ ⟩ singleton v₂)) ►eval e₂ eval (send (e₁ ×⟨ Γ≺ ⟩ e₂)) = do v₁ ← frame Γ≺ (►eval e₁) cref φ ×⟨ σ ⟩ v₁ ← ►eval e₂ & v₁ φ' ← liftM ⟪ send (φ ×⟨ σ ⟩ v₁) ⟫ return (cref φ') eval (recv e) = do cref φ ← ►eval e v ×⟨ σ ⟩ φ' ← liftM ⟪ receive φ ⟫ return (pairs (cref φ' ×⟨ ⊎-comm σ ⟩ v)) eval (fork e) = do clos body env ← ►eval e empty ← liftM ⟪ fork (app (runReader (cons (tt ×⟨ ⊎-idˡ ⟩ env))) (►eval body) ⊎-idʳ) ⟫ -- (app (runReader (cons (tt ×⟨ ⊎-idˡ ⟩ env))) (►eval body) ⊎-idʳ) return tt eval (terminate e) = do cref φ ← ►eval e empty ← liftM ⟪ close φ ⟫ return tt -- eval⊸ : ∀ {i Γ} → Exp (a ⊸ b) Γ → ∀[ Val a ⇒ⱼ M i Γ [] (Val b) ] -- eval⊸ e v = do -- (clos e env) ×⟨ σ₂ ⟩ v ← ►eval e & v -- empty ← append (cons (v ×⟨ ⊎-comm σ₂ ⟩ env)) -- ►eval e -- ►eval⊸ : ∀ {i Γ} → Exp (a ⊸ b) Γ → ∀[ Val a ⇒ⱼ M i Γ [] (Val b) ] -- app (►eval⊸ e v) E σ = impure λ where -- .force → -- yield -- ×⟨ ⊎-idˡ ⟩ -- wand (λ where empty σ' → case ⊎-id⁻ʳ σ' of λ where refl → app (eval⊸ e v) E σ ) ►eval : ∀ {i} → Exp a Γ → ε[ M i Γ [] (Val a) ] app (►eval e) E σ = impure λ where .force → yield ×⟨ ⊎-idˡ ⟩ wand (λ where empty σ' → case ⊎-id⁻ʳ σ' of λ where refl → app (eval e) E σ )
{ "alphanum_fraction": 0.5238416554, "avg_line_length": 30.2448979592, "ext": "agda", "hexsha": "47a539392af8fb6999ccaf7bc6575f6192e97b4a", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2020-05-23T00:34:36.000Z", "max_forks_repo_forks_event_min_datetime": "2020-01-30T14:15:14.000Z", "max_forks_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "laMudri/linear.agda", "max_forks_repo_path": "src/Sessions/Semantics/Struggle.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0", "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": "laMudri/linear.agda", "max_issues_repo_path": "src/Sessions/Semantics/Struggle.agda", "max_line_length": 157, "max_stars_count": 34, "max_stars_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "laMudri/linear.agda", "max_stars_repo_path": "src/Sessions/Semantics/Struggle.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-03T15:22:33.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-20T13:57:50.000Z", "num_tokens": 1788, "size": 4446 }
{- 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.Prelude open import LibraBFT.Impl.Consensus.Types -- This module defines the LBFT monad used by our (fake/simple, -- for now) "implementation", along with some utility functions -- to facilitate reasoning about it. module LibraBFT.Impl.Util.Util where open import LibraBFT.Impl.Util.RWST public ---------------- -- LBFT Monad -- ---------------- -- Global 'LBFT'; works over the whole state. LBFT : Set → Set LBFT = RWST Unit Output EventProcessor LBFT-run : ∀ {A} → LBFT A → EventProcessor → (A × EventProcessor × List Output) LBFT-run m = RWST-run m unit LBFT-post : ∀ {A} → LBFT A → EventProcessor → EventProcessor LBFT-post m ep = proj₁ (proj₂ (LBFT-run m ep)) LBFT-outs : ∀ {A} → LBFT A → EventProcessor → List Output LBFT-outs m ep = proj₂ (proj₂ (LBFT-run m ep)) -- Local 'LBFT' monad; which operates only over the part of -- the state that /depends/ on the ec; not the part -- of the state that /defines/ the ec. -- -- This is very convenient to define functions that -- do not alter the ec. LBFT-ec : EpochConfig → Set → Set LBFT-ec ec = RWST Unit Output (EventProcessorWithEC ec) -- Lifting a function that does not alter the pieces that -- define the epoch config is easy liftEC : {A : Set}(f : ∀ ec → LBFT-ec ec A) → LBFT A liftEC f = rwst λ _ st → let ec = α-EC (₋epEC st , ₋epEC-correct st) res , stec' , acts = RWST-run (f ec) unit (₋epWithEC st) in res , record st { ₋epWithEC = stec' } , acts -- Type that captures a proof that a computation in the LBFT monad -- satisfies a given contract. LBFT-Contract : ∀{A} → LBFT A → (EventProcessor → Set) → (EventProcessor → Set) → Set LBFT-Contract f Pre Post = ∀ ep → Pre ep × Post (proj₁ (proj₂ (RWST-run f unit ep)))
{ "alphanum_fraction": 0.6446555819, "avg_line_length": 36.2931034483, "ext": "agda", "hexsha": "2ae6fd4a26ed4ca0776b51e9ccff90e26b7c7f21", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "34e4627855fb198665d0c98f377403a906ba75d7", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "haroldcarr/bft-consensus-agda", "max_forks_repo_path": "LibraBFT/Impl/Util/Util.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "34e4627855fb198665d0c98f377403a906ba75d7", "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": "haroldcarr/bft-consensus-agda", "max_issues_repo_path": "LibraBFT/Impl/Util/Util.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "34e4627855fb198665d0c98f377403a906ba75d7", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "haroldcarr/bft-consensus-agda", "max_stars_repo_path": "LibraBFT/Impl/Util/Util.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 628, "size": 2105 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Natural numbers ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Nat where ------------------------------------------------------------------------ -- Publicly re-export the contents of the base module open import Data.Nat.Base public ------------------------------------------------------------------------ -- Publicly re-export queries open import Data.Nat.Properties public using ( _≟_ ; _≤?_ ; _≥?_ ; _<?_ ; _>?_ ; _≤′?_; _≥′?_; _<′?_; _>′?_ ; _≤″?_; _<″?_; _≥″?_; _>″?_ ) ------------------------------------------------------------------------ -- Deprecated -- Version 0.17 open import Data.Nat.Properties public using (≤-pred)
{ "alphanum_fraction": 0.3480861244, "avg_line_length": 24.5882352941, "ext": "agda", "hexsha": "d07ea617123bd7b81b2d32c51e25699ab862e857", "lang": "Agda", "max_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/Nat.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/Nat.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Nat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 177, "size": 836 }
-- https://personal.cis.strath.ac.uk/conor.mcbride/PolyTest.pdf module Sandbox.PolyTest where open import Data.Nat open import Data.Nat.Properties.Extra open import Relation.Binary.PropositionalEquality _^_ : ℕ → ℕ → ℕ x ^ zero = suc zero x ^ suc y = x * (x ^ y) -- data Poly : ℕ → Set where -- κ : ℕ → Poly 0 -- ι : Poly 1 -- _⊕_ : ∀ {l m} → Poly l → Poly m → Poly (l ⊓ m) -- _⊗_ : ∀ {l m} → Poly l → Poly m → Poly (l * m) -- -- ⟦_⟧_ : ∀ {n} → Poly n → ℕ → ℕ -- ⟦ κ c ⟧ x = c -- ⟦ ι ⟧ x = x -- ⟦ p ⊕ q ⟧ x = ⟦ p ⟧ x + ⟦ q ⟧ x -- ⟦ p ⊗ q ⟧ x = ⟦ p ⟧ x * ⟦ q ⟧ x -- -- Δ : ∀ {n} → Poly (suc n) → Poly n -- Δ p = {! p !} -- -- I'm not sure if there should be a case for the constructor _⊕_, -- -- because I get stuck when trying to solve the following unification -- -- problems (inferred index ≟ expected index): -- -- l ⊓ m ≟ suc n -- -- when checking that the expression ? has type Poly .n -- data Poly : ℕ → Set where -- κ : ℕ → Poly 0 -- ι : Poly 1 -- plus : ∀ {l m n} → Poly l → Poly m → (l ⊓ m) ≡ n → Poly n -- times : ∀ {l m n} → Poly l → Poly m → (l * m) ≡ n → Poly n -- -- ⟦_⟧_ : ∀ {n} → Poly n → ℕ → ℕ -- ⟦ κ c ⟧ x = c -- ⟦ ι ⟧ x = x -- ⟦ plus p q eq ⟧ x = ⟦ p ⟧ x + ⟦ q ⟧ x -- ⟦ times p q eq ⟧ x = ⟦ p ⟧ x * ⟦ q ⟧ x -- Δ : ∀ {n} → Poly (suc n) → Poly n -- Δ ι = κ 1 -- Δ (plus (κ x) q ()) -- Δ (plus ι (κ x) ()) -- Δ (plus ι ι eq) = plus (Δ ι) (Δ ι) (cancel-suc eq) -- Δ (plus ι (plus p₂ q₂ eq₂) eq) = plus (Δ ι) (Δ {! (plus p₂ q₂ eq₂) !}) {! !} -- Δ (plus ι (times p₂ q₂ eq₂) eq) = {! !} -- -- Δ (plus ι q eq) = plus (Δ ι) (Δ {! !}) {! !} -- Δ (plus (plus p q' eq') q eq) = {! !} -- Δ (plus (times p q' eq') q eq) = {! !} -- Δ (times p q eq) = {! !} -- data Poly : ℕ → Set where -- κ : ∀ {n} → ℕ → Poly n -- ι : ∀ {n} → Poly (suc n) -- plus : ∀ {n} → Poly n → Poly n → Poly n -- times : ∀ {l m n} → Poly l → Poly m → (l * m) ≡ n → Poly n -- -- -- ∆(p ⊗ r) = ∆p ⊗ (r · (1+)) ⊕ p ⊗ ∆r -- Δ : ∀ {n} → Poly (suc n) → Poly n -- Δ (κ x) = κ 0 -- Δ ι = κ 1 -- Δ (plus p q) = plus (Δ p) (Δ q) -- Δ (times p q eq) = times (Δ {! p !}) {! !} {! !} data Add : ℕ → ℕ → ℕ → Set where 0+n : ∀ {n} → Add 0 n n n+0 : ∀ {n} → Add n 0 n m+n : ∀ {l m n} → Add l m n → Add (suc l) (suc m) (suc (suc n)) data Poly : ℕ → Set where κ : ∀ {n} → ℕ → Poly n ι : ∀ {n} → Poly (suc n) ↑ : ∀ {n} → Poly n → Poly n _⊕_ : ∀ {n} → Poly n → Poly n → Poly n times : ∀ {l m n} → Poly l → Poly m → Add l m n → Poly n infixl 5 _⊕_ ⟦_⟧_ : ∀ {n} → Poly n → ℕ → ℕ ⟦ κ c ⟧ x = c ⟦ ι ⟧ x = x ⟦ ↑ p ⟧ x = ⟦ p ⟧ suc x ⟦ p ⊕ q ⟧ x = ⟦ p ⟧ x + ⟦ q ⟧ x ⟦ times p q add ⟧ x = ⟦ p ⟧ x * ⟦ q ⟧ x sucl : ∀ {l m n} → Add l m n → Add (suc l) m (suc n) sucl (0+n {zero}) = n+0 sucl (0+n {suc n}) = m+n 0+n sucl (n+0 {zero}) = n+0 sucl (n+0 {suc n}) = n+0 sucl (m+n add) = m+n (sucl add) sucr : ∀ {l m n} → Add l m n → Add l (suc m) (suc n) sucr 0+n = 0+n sucr (n+0 {zero}) = 0+n sucr (n+0 {suc n}) = m+n n+0 sucr (m+n add) = m+n (sucr add) -- -- ∆(p ⊗ q) = (∆p ⊗ (q · (1+))) ⊕ (p ⊗ ∆q) Δ : ∀ {n} → Poly (suc n) → Poly n Δ (κ c) = κ 0 Δ ι = κ 1 Δ (↑ p) = ↑ (Δ p) Δ (p ⊕ q) = Δ p ⊕ Δ q Δ (times p q 0+n) = times (κ (⟦ p ⟧ 0)) (Δ q) 0+n Δ (times p q n+0) = times (Δ p) (κ (⟦ q ⟧ 0)) n+0 Δ (times p q (m+n add)) = times (Δ p) (↑ q) (sucr add) ⊕ times p (Δ q) (sucl add) add : ∀ l m → Add l m (l + m) add zero m = 0+n add (suc l) m = sucl (add l m) _⊗_ : ∀ {l m} → Poly l → Poly m → Poly (l + m) _⊗_ {l} {m} p q = times p q (add l m) infixr 6 _⊗_ ι₁ : Poly 1 ι₁ = ι κ₀ : ℕ → Poly 0 κ₀ c = κ c _⊛_ : ∀ {m} → Poly m → (n : ℕ) → Poly (n * m) p ⊛ zero = κ 1 p ⊛ suc n = {! !}
{ "alphanum_fraction": 0.408764736, "avg_line_length": 29.5606060606, "ext": "agda", "hexsha": "c6e90785c346ee96215384404941cf1f0b12c715", "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/PolyTest.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/PolyTest.agda", "max_line_length": 82, "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/PolyTest.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": 1840, "size": 3902 }
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-} module Cubical.Experiments.NatMinusTwo.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Data.Nat open import Cubical.Data.NatMinusOne using (ℕ₋₁) open import Cubical.Experiments.NatMinusTwo.Base -2+Path : ℕ ≡ ℕ₋₂ -2+Path = isoToPath (iso -2+_ 2+_ (λ _ → refl) (λ _ → refl))
{ "alphanum_fraction": 0.7548076923, "avg_line_length": 34.6666666667, "ext": "agda", "hexsha": "12d9e3eabc73044131214bae4cd0b8f34d53f4f0", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Experiments/NatMinusTwo/Properties.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Experiments/NatMinusTwo/Properties.agda", "max_line_length": 67, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Experiments/NatMinusTwo/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 130, "size": 416 }
{-# OPTIONS --safe #-} open import Generics.Prelude hiding (lookup; pi; curry) open import Generics.Telescope open import Generics.Desc open import Generics.All open import Generics.HasDesc import Generics.Helpers as Helpers module Generics.Constructions.Fold {P I ℓ} {A : Indexed P I ℓ} (H : HasDesc {P} {I} {ℓ} A) {p c} {X : Pred′ I λ i → Set c} where open HasDesc H private variable V : ExTele P i : ⟦ I ⟧tel p v : ⟦ V ⟧tel p X′ : ⟦ I ⟧tel p → Set c X′ i = unpred′ I _ X i ------------------------ -- Types of the algebra levelAlg : ConDesc P V I → Level levelAlg (var _) = c levelAlg (π {ℓ} _ _ C) = ℓ ⊔ levelAlg C levelAlg (A ⊗ B) = levelAlg A ⊔ levelAlg B AlgIndArg : (C : ConDesc P V I) → ⟦ V ⟧tel p → Set (levelAlg C) AlgIndArg (var f) v = X′ (f (p , v)) AlgIndArg (π ia S C) v = Π< ia > (S (p , v)) λ s → AlgIndArg C (v , s) AlgIndArg (A ⊗ B) v = AlgIndArg A v × AlgIndArg B v AlgCon : (C : ConDesc P V I) → ⟦ V ⟧tel p → Set (levelAlg C) AlgCon (var f) v = X′ (f (p , v)) AlgCon (π ia S C) v = Π< ia > (S (p , v)) λ s → AlgCon C (v , s) AlgCon (A ⊗ B) v = AlgIndArg A v → AlgCon B v Algebra : ∀ k → Set (levelAlg (lookupCon D k)) Algebra k = AlgCon (lookupCon D k) tt ---------------- -- Generic fold module _ (algs : Els Algebra) where fold-wf : (x : A′ (p , i)) → Acc x → X′ i foldData-wf : (x : ⟦ D ⟧Data A′ (p , i)) → AllDataω Acc D x → X′ i foldData-wf {i} (k , x) = foldCon (lookupCon D k) (algs k) x where foldIndArg : (C : ConDesc P V I) (x : ⟦ C ⟧IndArg A′ (p , v)) → AllIndArgω Acc C x → AlgIndArg C v foldIndArg (var f) x a = fold-wf x a foldIndArg (π ia S C) x a = fun< ia > λ s → foldIndArg C (app< ia > x s) (a s) foldIndArg (A ⊗ B) (xa , xb) (aa , ab) = foldIndArg A xa aa , foldIndArg B xb ab foldCon : (C : ConDesc P V I) (alg : AlgCon C v) (x : ⟦ C ⟧Con A′ (p , v , i)) → AllConω Acc C x → X′ i foldCon (var _) alg refl _ = alg foldCon (π ia S C) alg (s , x) a = foldCon C (app< ia > alg s) x a foldCon (A ⊗ B) alg (xa , xb) (aa , ab) = foldCon B (alg (foldIndArg A xa aa)) xb ab fold-wf x (acc a) = foldData-wf (split x) a fold : A′ (p , i) → X′ i fold x = fold-wf x (wf x) deriveFold : Arrows Algebra (Pred′ I λ i → A′ (p , i) → X′ i) deriveFold = curryₙ λ m → pred′ I _ λ i → fold m
{ "alphanum_fraction": 0.5288852726, "avg_line_length": 28.5813953488, "ext": "agda", "hexsha": "9d1fadf841221b959c6e4747d3e4bab3efd016a8", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-01-14T10:35:16.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-08T08:32:42.000Z", "max_forks_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "flupe/generics", "max_forks_repo_path": "src/Generics/Constructions/Fold.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_issues_repo_issues_event_max_datetime": "2022-01-14T10:48:30.000Z", "max_issues_repo_issues_event_min_datetime": "2021-09-13T07:33:50.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "flupe/generics", "max_issues_repo_path": "src/Generics/Constructions/Fold.agda", "max_line_length": 84, "max_stars_count": 11, "max_stars_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "flupe/generics", "max_stars_repo_path": "src/Generics/Constructions/Fold.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T09:35:17.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-08T15:10:20.000Z", "num_tokens": 954, "size": 2458 }
module Either where data Either (A : Set) (B : Set) : Set where left : A → Either A B right : B → Either A B [_,_] : ∀ {A B} {C : Set} → (A → C) → (B → C) → Either A B → C [ f , g ] (left x) = f x [ f , g ] (right x) = g x
{ "alphanum_fraction": 0.4545454545, "avg_line_length": 24.2, "ext": "agda", "hexsha": "8fcd569cd5c399d8485ad6d63d917990460b7608", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "382fcfae193079783621fc5cf54b6588e22ef759", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "cantsin/agda-experiments", "max_forks_repo_path": "Either.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "382fcfae193079783621fc5cf54b6588e22ef759", "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": "cantsin/agda-experiments", "max_issues_repo_path": "Either.agda", "max_line_length": 64, "max_stars_count": null, "max_stars_repo_head_hexsha": "382fcfae193079783621fc5cf54b6588e22ef759", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "cantsin/agda-experiments", "max_stars_repo_path": "Either.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 102, "size": 242 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Instance.Properties.Cats where open import Data.Product using (_,_) open import Categories.Category open import Categories.Category.Construction.Functors using (Functors; eval; module curry) open import Categories.Category.Cartesian using (Cartesian) import Categories.Category.CartesianClosed as CCC import Categories.Category.CartesianClosed.Canonical as Canonical open import Categories.Category.Instance.Cats using (Cats) open import Categories.Category.Monoidal.Instance.Cats open import Categories.Functor using (Functor; _∘F_) renaming (id to idF) open import Categories.Functor.Bifunctor using (Bifunctor) open import Categories.Functor.Construction.Constant using (constNat) import Categories.Morphism.Reasoning as MR open import Categories.NaturalTransformation using (NaturalTransformation; _∘ˡ_) renaming (id to idNT) open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism; _≃_; module LeftRightId) -- It's easier to define exponentials with respect to the *canonical* -- product. The more generic version can then be given by appealing -- to uniqueness (up to iso) of products. module CanonicallyCartesianClosed {l} where private module Cats = Category (Cats l l l) module Cart = Cartesian (Product.Cats-is {l} {l} {l}) open Cats using (_⇒_) renaming (Obj to Cat) open Cart hiding (η) infixr 9 _^_ _^_ : Cat → Cat → Cat B ^ A = Functors A B -- The β law (aka computation principle) for exponential objects eval-comp : ∀ {A B C} {G : C × A ⇒ B} → eval ∘F (curry.F₀ G ⁂ idF) ≃ G eval-comp {A} {B} {C} {G} = record { F⇒G = record { η = λ _ → id B ; commute = λ _ → ∘-resp-≈ʳ B commute ○ MR.id-comm-sym B ; sym-commute = λ _ → ⟺ (∘-resp-≈ʳ B commute ○ MR.id-comm-sym B) } ; F⇐G = record { η = λ _ → id B ; commute = λ _ → ⟺ (MR.id-comm B ○ ∘-resp-≈ʳ B commute) ; sym-commute = λ _ → MR.id-comm B ○ ∘-resp-≈ʳ B commute } ; iso = iso-id-id } where open Functor G renaming (F₀ to G₀; F₁ to G₁) open Category hiding (_∘_) open Category B using (_∘_) open HomReasoning B open LeftRightId G commute : ∀ {a₁ a₂ b₁ b₂} {f₁ : C [ a₁ , b₁ ]} {f₂ : A [ a₂ , b₂ ]} → B [ (G₁ (f₁ , id A) ∘ G₁ (id C , f₂)) ≈ G₁ (f₁ , f₂) ] commute {_} {_} {_} {_} {f₁} {f₂} = begin G₁ (f₁ , id A) ∘ G₁ (id C , f₂) ≈˘⟨ homomorphism ⟩ G₁ (C [ f₁ ∘ id C ] , A [ id A ∘ f₂ ]) ≈⟨ F-resp-≈ (identityʳ C , identityˡ A) ⟩ G₁ (f₁ , f₂) ∎ -- The η law (aka uniqueness principle) for exponential objects η-exp : ∀ {A B C} {H : C ⇒ B ^ A} → H ≃ curry.F₀ (eval ∘F (H ⁂ idF)) η-exp {A} {B} {C} {H} = record { F⇒G = record { η = λ _ → record { η = λ _ → id B ; commute = λ f → ⟺ (MR.id-comm B ○ ∘-resp-≈ʳ B (commute₁ f)) ; sym-commute = λ f → MR.id-comm B ○ ∘-resp-≈ʳ B (commute₁ f) } ; commute = λ f → ⟺ (MR.id-comm B ○ ∘-resp-≈ʳ B (commute₂ f)) ; sym-commute = λ f → MR.id-comm B ○ ∘-resp-≈ʳ B (commute₂ f) } ; F⇐G = record { η = λ _ → record { η = λ _ → id B ; commute = λ f → ∘-resp-≈ʳ B (commute₁ f) ○ MR.id-comm-sym B ; sym-commute = λ f → ⟺ (∘-resp-≈ʳ B (commute₁ f) ○ MR.id-comm-sym B) } ; commute = λ f → ∘-resp-≈ʳ B (commute₂ f) ○ MR.id-comm-sym B ; sym-commute = λ f → ⟺ (∘-resp-≈ʳ B (commute₂ f) ○ MR.id-comm-sym B) } ; iso = λ _ → record { isoˡ = identity² B; isoʳ = identity² B } } where open Functor using (identity) renaming (F₁ to _$₁_) open Functor H hiding (identity) renaming (F₀ to H₀; F₁ to H₁) open Category hiding (_∘_) open Category B using (_∘_) open HomReasoning B open NaturalTransformation open LeftRightId H commute₁ : ∀ {a b c} (f : A [ a , b ]) → B [ (η (H₁ (id C)) b ∘ (H₀ c $₁ f)) ≈ H₀ c $₁ f ] commute₁ {_} {b} {c} f = begin η (H₁ (id C)) b ∘ (H₀ c $₁ f) ≈⟨ ∘-resp-≈ˡ B (identity H) ⟩ id B ∘ (H₀ c $₁ f) ≈⟨ identityˡ B ⟩ H₀ c $₁ f ∎ commute₂ : ∀ {c₁ c₂} (f : C [ c₁ , c₂ ]) {a} → B [ (η (H₁ f) a ∘ (H₀ c₁ $₁ id A)) ≈ η (H₁ f) a ] commute₂ {c} {_} f {a} = begin η (H₁ f) a ∘ (H₀ c $₁ id A) ≈⟨ ∘-resp-≈ʳ B (identity (H₀ c)) ⟩ η (H₁ f) a ∘ id B ≈⟨ identityʳ B ⟩ η (H₁ f) a ∎ curry-unique : ∀ {A B C} {G : C ⇒ B ^ A} {H : C × A ⇒ B} → eval ∘F (G ⁂ idF) ≃ H → G ≃ curry.F₀ H curry-unique {A} {B} {C} {G} {H} hyp = begin G ≈⟨ η-exp {A} {B} {C} {G} ⟩ curry.F₀ (eval ∘F (G ⁂ idF)) ≈⟨ curry.resp-NI {F = eval ∘F (G ⁂ idF)} {H} hyp ⟩ curry.F₀ H ∎ where open Functor open Cats.HomReasoning Cats-CCC : Canonical.CartesianClosed (Cats l l l) Cats-CCC = record { ! = ! ; π₁ = π₁ ; π₂ = π₂ ; ⟨_,_⟩ = ⟨_,_⟩ ; !-unique = !-unique ; π₁-comp = λ {_} {_} {F} {_} {G} → project₁ {h = F} {i = G} ; π₂-comp = λ {_} {_} {F} {_} {G} → project₂ {h = F} {i = G} ; ⟨,⟩-unique = unique ; eval = eval ; curry = curry.F₀ ; eval-comp = λ {_} {_} {_} {G} → eval-comp {G = G} ; curry-resp-≈ = λ {_} {_} {_} {G} {H} → curry.resp-NI {F = G} {H} ; curry-unique = λ {_} {_} {_} {G} {H} → curry-unique {G = G} {H} } open Canonical.CartesianClosed Cats-CCC Cats-CCC : ∀ {l} → CCC.CartesianClosed (Cats l l l) Cats-CCC = Canonical.Equivalence.fromCanonical _ CanonicallyCartesianClosed.Cats-CCC module CartesianClosed {l} = CCC.CartesianClosed (Cats-CCC {l})
{ "alphanum_fraction": 0.5332426458, "avg_line_length": 37.2215189873, "ext": "agda", "hexsha": "f21b35bcf4201a2d245f14dd5c4d3716d998efd2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-categories", "max_forks_repo_path": "src/Categories/Category/Instance/Properties/Cats.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "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": "bblfish/agda-categories", "max_issues_repo_path": "src/Categories/Category/Instance/Properties/Cats.agda", "max_line_length": 77, "max_stars_count": 5, "max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bblfish/agda-categories", "max_stars_repo_path": "src/Categories/Category/Instance/Properties/Cats.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 2181, "size": 5881 }
module Data.QuadTree.LensProofs.Valid-LensLeaf where open import Haskell.Prelude renaming (zero to Z; suc to S) open import Data.Lens.Lens open import Data.Logic open import Agda.Primitive open import Data.Lens.Proofs.LensLaws open import Data.Lens.Proofs.LensPostulates open import Data.Lens.Proofs.LensComposition open import Data.QuadTree.InternalAgda open import Data.QuadTree.Implementation.QuadrantLenses open import Data.QuadTree.Implementation.Definition open import Data.QuadTree.Implementation.ValidTypes --- Lens laws for lensLeaf ValidLens-Leaf-ViewSet : {t : Set} {{eqT : Eq t}} -> ViewSet (lensLeaf {t}) ValidLens-Leaf-ViewSet v (CVQuadrant (Leaf x)) = refl ValidLens-Leaf-SetView : {t : Set} {{eqT : Eq t}} -> SetView (lensLeaf {t}) ValidLens-Leaf-SetView (CVQuadrant (Leaf x)) = refl ValidLens-Leaf-SetSet : {t : Set} {{eqT : Eq t}} -> SetSet (lensLeaf {t}) ValidLens-Leaf-SetSet v1 v2 (CVQuadrant (Leaf x)) = refl ValidLens-Leaf : {t : Set} {{eqT : Eq t}} -> ValidLens (VQuadrant t {0}) t ValidLens-Leaf = CValidLens lensLeaf ValidLens-Leaf-ViewSet ValidLens-Leaf-SetView ValidLens-Leaf-SetSet
{ "alphanum_fraction": 0.7443082312, "avg_line_length": 34.6060606061, "ext": "agda", "hexsha": "55c0f7f863a5c17a04b2f0feebfe3169d96c95e7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "JonathanBrouwer/research-project", "max_forks_repo_path": "src/Data/QuadTree/LensProofs/Valid-LensLeaf.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "JonathanBrouwer/research-project", "max_issues_repo_path": "src/Data/QuadTree/LensProofs/Valid-LensLeaf.agda", "max_line_length": 104, "max_stars_count": 1, "max_stars_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "JonathanBrouwer/research-project", "max_stars_repo_path": "src/Data/QuadTree/LensProofs/Valid-LensLeaf.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-25T09:10:20.000Z", "max_stars_repo_stars_event_min_datetime": "2021-05-25T09:10:20.000Z", "num_tokens": 352, "size": 1142 }
{-# OPTIONS --without-K #-} -- Borrowed from OldUnivalence/Equivalences.agda, without HoTT -- and then upgraded to work on Setoid rather than just on ≡ module SetoidEquiv where open import Level using (Level; zero; _⊔_) open import Data.Empty using (⊥) open import Data.Sum using (_⊎_; inj₁; inj₂) import Function as Fun using (id) open import Function.Equality using (id; _∘_; _⟶_; _⟨$⟩_; _⇨_; cong) open import Relation.Binary using (Setoid; module Setoid) open import Relation.Binary.PropositionalEquality as P using (setoid; →-to-⟶) open Setoid -- Equivalence of setoids infix 4 _≃S_ ------------------------------------------------------------------------------ -- A setoid gives us a set and an equivalence relation on that set. -- The setoids constructed in PropositionalEquality (P) use ≡ as the -- equivalence relation -- the empty set with ≡ {-- 0S : Setoid zero zero 0S = P.setoid ⊥ --} -- sum of setoids -- we take the disjoint union of the carriers and construct a new -- equivalence relation that uses the underlying relations on each -- summand (and is undefined on elements that come from different -- summands) {-- _⊎S_ : (AS : Setoid zero zero) (BS : Setoid zero zero) → Setoid zero zero _⊎S_ AS BS = record { Carrier = A ⊎ B ; _≈_ = _∼₁_ ; isEquivalence = record { refl = λ { {inj₁ _} → refl AS ; {inj₂ _} → refl BS} ; sym = λ {x} {y} → sym∼₁ {x} {y} ; trans = λ {x} {y} {z} → trans∼₁ {x} {y} {z} } } where A = Carrier AS B = Carrier BS _∼₁_ : A ⊎ B → A ⊎ B → Set inj₁ x ∼₁ inj₁ x₁ = _≈_ AS x x₁ inj₁ x ∼₁ inj₂ y = ⊥ inj₂ y ∼₁ inj₁ x = ⊥ inj₂ y ∼₁ inj₂ y₁ = _≈_ BS y y₁ sym∼₁ : {x y : A ⊎ B} → x ∼₁ y → y ∼₁ x sym∼₁ {inj₁ _} {inj₁ _} x~y = sym AS x~y sym∼₁ {inj₁ _} {inj₂ _} () sym∼₁ {inj₂ _} {inj₁ _} () sym∼₁ {inj₂ _} {inj₂ _} x~y = sym BS x~y trans∼₁ : Relation.Binary.Transitive _∼₁_ trans∼₁ {inj₁ x} {inj₁ x₁} {inj₁ x₂} i~j j~k = trans AS i~j j~k trans∼₁ {inj₁ x} {inj₁ x₁} {inj₂ y} i~j () trans∼₁ {inj₁ x} {inj₂ y} {inj₁ x₁} i~j () trans∼₁ {inj₁ x} {inj₂ y} () j~k trans∼₁ {inj₂ y} {inj₁ x} () j~k trans∼₁ {inj₂ y} {inj₂ y₁} {inj₁ x} i~j () trans∼₁ {inj₂ y} {inj₂ y₁} {inj₂ y₂} i~j j~k = trans BS i~j j~k --} ------------------------------------------------------------------------------ -- Equivalence of setoids -- Two setoids are equivalent if record _≃S_ {ℓ₁ ℓ₂ ℓ₃ ℓ₄ : Level} (A : Setoid ℓ₁ ℓ₂) (B : Setoid ℓ₃ ℓ₄) : Set (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) where constructor equiv field f : A ⟶ B g : B ⟶ A α : ∀ {x y} → _≈_ B x y → _≈_ B ((f ∘ g) ⟨$⟩ x) y β : ∀ {x y} → _≈_ A x y → _≈_ A ((g ∘ f) ⟨$⟩ x) y {-- id≃S : ∀ {ℓ₁ ℓ₂} {A : Setoid ℓ₁ ℓ₂} → A ≃S A id≃S {A = A} = equiv id id Fun.id Fun.id sym≃S : ∀ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} {A : Setoid ℓ₁ ℓ₂} {B : Setoid ℓ₃ ℓ₄} → (A ≃S B) → B ≃S A sym≃S eq = equiv e.g e.f e.β e.α where module e = _≃S_ eq trans≃S : ∀ {ℓ₁ ℓ₂ ℓ₃ ℓ₄ ℓ₅ ℓ₆} {A : Setoid ℓ₁ ℓ₂} {B : Setoid ℓ₃ ℓ₄} {C : Setoid ℓ₅ ℓ₆} → A ≃S B → B ≃S C → A ≃S C trans≃S {A = A} {B} {C} A≃B B≃C = equiv f g α' β' where module fm = _≃S_ A≃B module gm = _≃S_ B≃C f : A ⟶ C f = gm.f ∘ fm.f g : C ⟶ A g = fm.g ∘ gm.g α' : _≈_ (C ⇨ C) (f ∘ g) id α' = λ z → trans C (cong gm.f (fm.α (cong gm.g (refl C)))) (gm.α z) β' : _≈_ (A ⇨ A) (g ∘ f) id β' = λ z → trans A (cong fm.g (gm.β (cong fm.f (refl A)))) (fm.β z) _✴_ : ∀ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} {A : Setoid ℓ₁ ℓ₂} {B : Setoid ℓ₃ ℓ₄} → (A ≃S B) → (x : Carrier A) → Carrier B (equiv f _ _ _) ✴ x = f ⟨$⟩ x --} -- can't use id because it is not sufficiently dependently typed! {-- 0≃S : 0S ≃S 0S 0≃S = equiv id id (λ x → x) (λ x → x) --} -- just to make things prettier _≃S≡_ : ∀ {ℓ₁} → (A B : Set ℓ₁) → Set ℓ₁ A ≃S≡ B = (P.setoid A) ≃S (P.setoid B) -- Need to be able to take ⊎ of ≃S-Setoids {-- _⊎≃S_ : {A B C D : Set} → A ≃S≡ B → C ≃S≡ D → (A ⊎ C) ≃S≡ (B ⊎ D) _⊎≃S_ {A} {B} {C} {D} (equiv f g α β) (equiv f₁ g₁ α₁ β₁) = equiv (→-to-⟶ ff) (→-to-⟶ gg) αα ββ where ff : A ⊎ C → B ⊎ D ff (inj₁ x) = inj₁ (f ⟨$⟩ x) ff (inj₂ y) = inj₂ (f₁ ⟨$⟩ y) gg : B ⊎ D → A ⊎ C gg (inj₁ x) = inj₁ (g ⟨$⟩ x) gg (inj₂ y) = inj₂ (g₁ ⟨$⟩ y) αα : {x y : B ⊎ D} → x P.≡ y → ff (gg x) P.≡ y αα {inj₁ x} P.refl = P.cong inj₁ (α P.refl) αα {inj₂ y} P.refl = P.cong inj₂ (α₁ P.refl) ββ : {x y : A ⊎ C} → x P.≡ y → gg (ff x) P.≡ y ββ {inj₁ x} P.refl = P.cong inj₁ (β P.refl) ββ {inj₂ y} P.refl = P.cong inj₂ (β₁ P.refl) --} -- note that this appears to be redundant (especially when looking at -- the proofs), but having both f and g is needed for inference of -- other aspects to succeed. record _≋_ {ℓ₁} {A B : Set ℓ₁} (eq₁ eq₂ : A ≃S≡ B) : Set ℓ₁ where constructor equivS field f≡ : ∀ (x : A) → P._≡_ (_≃S_.f eq₁ ⟨$⟩ x) (_≃S_.f eq₂ ⟨$⟩ x) g≡ : ∀ (x : B) → P._≡_ (_≃S_.g eq₁ ⟨$⟩ x) (_≃S_.g eq₂ ⟨$⟩ x) id≋ : ∀ {ℓ} {A B : Set ℓ} {x : A ≃S≡ B} → x ≋ x id≋ = record { f≡ = λ x → P.refl ; g≡ = λ x → P.refl } sym≋ : ∀ {ℓ} {A B : Set ℓ} {x y : A ≃S≡ B} → x ≋ y → y ≋ x sym≋ (equivS f≡ g≡) = equivS (λ a → P.sym (f≡ a)) (λ b → P.sym (g≡ b)) trans≋ : ∀ {ℓ} {A B : Set ℓ} {x y z : A ≃S≡ B} → x ≋ y → y ≋ z → x ≋ z trans≋ (equivS f≡ g≡) (equivS h≡ i≡) = equivS (λ a → P.trans (f≡ a) (h≡ a)) (λ b → P.trans (g≡ b) (i≡ b)) -- WARNING: this is not generic, but specific to ≡-Setoids of functions. ≃S-Setoid : ∀ {ℓ₁} → (A B : Set ℓ₁) → Setoid ℓ₁ ℓ₁ ≃S-Setoid {ℓ₁} A B = record { Carrier = AS ≃S BS ; _≈_ = _≋_ ; isEquivalence = record { refl = id≋ ; sym = sym≋ ; trans = trans≋ } } where open _≃S_ AS = P.setoid A BS = P.setoid B -- equivalences are injective {-- inj≃ : ∀ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} {A : Setoid ℓ₁ ℓ₂} {B : Setoid ℓ₃ ℓ₄} → (eq : A ≃S B) → {x y : Carrier A} → _≈_ B (eq ✴ x) (eq ✴ y) → _≈_ A x y inj≃ {A = A'} (equiv f g _ β) p = A.trans (A.sym (β A.refl)) (A.trans (cong g p) (β A.refl)) where module A = Setoid A' --} ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.4890371783, "avg_line_length": 30.8529411765, "ext": "agda", "hexsha": "bdd8365ec2fce27c66ebbeb13d280031b39c45e6", "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/Obsolete/SetoidEquiv.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/Obsolete/SetoidEquiv.agda", "max_line_length": 79, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/Obsolete/SetoidEquiv.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 2891, "size": 6294 }
------------------------------------------------------------------------------ -- Well-founded induction on the natural numbers ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.Nat.Induction.Acc.WF-I where open import FOTC.Base open import FOTC.Data.Nat.Inequalities open import FOTC.Data.Nat.Inequalities.EliminationPropertiesI open import FOTC.Data.Nat.Inequalities.PropertiesI open import FOTC.Data.Nat.Type open import FOTC.Induction.WF ------------------------------------------------------------------------------ -- The relation _<_ is well-founded. module <-WF where <-wf : WellFounded _<_ <-wf Nn = acc (helper Nn) where -- N.B. The helper function is the same that the function used by -- FOTC.Data.Nat.Induction.NonAcc.WellFoundedInductionATP. helper : ∀ {n m} → N n → N m → m < n → Acc N _<_ m helper nzero Nm m<0 = ⊥-elim (x<0→⊥ Nm m<0) helper (nsucc _) nzero 0<Sn = acc (λ Nm' m'<0 → ⊥-elim (x<0→⊥ Nm' m'<0)) helper (nsucc {n} Nn) (nsucc {m} Nm) Sm<Sn = acc (λ {m'} Nm' m'<Sm → let m<n : m < n m<n = Sx<Sy→x<y Sm<Sn m'<n : m' < n m'<n = case (λ m'<m → <-trans Nm' Nm Nn m'<m m<n) (λ m'≡m → x≡y→y<z→x<z m'≡m m<n) (x<Sy→x<y∨x≡y Nm' Nm m'<Sm) in helper Nn Nm' m'<n ) -- Well-founded induction on the natural numbers. <-wfind : (A : D → Set) → (∀ {n} → N n → (∀ {m} → N m → m < n → A m) → A n) → ∀ {n} → N n → A n <-wfind A = WellFoundedInduction <-wf ------------------------------------------------------------------------------ -- The relation _<_ is well-founded (a different proof). module <-WF' where <-wf : WellFounded {N} _<_ <-wf nzero = acc (λ Nm m<0 → ⊥-elim (x<0→⊥ Nm m<0)) <-wf (nsucc Nn) = acc (λ Nm m<Sn → helper Nm Nn (<-wf Nn) (x<Sy→x≤y Nm Nn m<Sn)) where helper : ∀ {n m} → N n → N m → Acc N _<_ m → n ≤ m → Acc N _<_ n helper {n} {m} Nn Nm (acc h) n≤m = case (λ n<m → h Nn n<m) (λ n≡m → helper₁ (sym n≡m) (acc h)) (x≤y→x<y∨x≡y Nn Nm n≤m) where helper₁ : ∀ {a b} → a ≡ b → Acc N _<_ a → Acc N _<_ b helper₁ refl h = h
{ "alphanum_fraction": 0.4316939891, "avg_line_length": 39.4153846154, "ext": "agda", "hexsha": "25d7673752528cf7390d10e9e1c4a644b21ba1d1", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Data/Nat/Induction/Acc/WF-I.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Data/Nat/Induction/Acc/WF-I.agda", "max_line_length": 79, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Data/Nat/Induction/Acc/WF-I.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": 819, "size": 2562 }
module Prelude.Ord.Properties where open import Prelude.Ord open import Prelude.Empty open import Prelude.Equality open import Prelude.Equality.Inspect open import Prelude.Function open import Prelude.Decidable open import Prelude.Bool open import Prelude.Bool.Properties -- Ord/Laws extra lemmas module _ {ℓ} {A : Set ℓ} {{_ : Ord/Laws A}} where <⇒≤ : {a b : A} → a < b → a ≤ b <⇒≤ = lt-to-leq ≡⇒≮ : {a b : A} → a ≡ b → a ≮ b ≡⇒≮ refl a<b = less-antisym a<b a<b <⇒≱ : {a b : A} → a < b → a ≱ b <⇒≱ = flip leq-less-antisym ≮⇒≥ : {a b : A} → a ≮ b → a ≥ b ≮⇒≥ {a = a} {b = b} ¬a<b with compare a b ...| less a<b = ⊥-elim (¬a<b a<b) ...| equal a≡b = eq-to-leq (sym a≡b) ...| greater a>b = lt-to-leq a>b ≰⇒> : {a b : A} → a ≰ b → a > b ≰⇒> {a = a} {b = b} a≰b with compare a b ...| less a<b = ⊥-elim (a≰b (lt-to-leq a<b)) ...| equal a≡b = ⊥-elim (a≰b (eq-to-leq a≡b)) ...| greater b>a = b>a ≰⇒≥ : {a b : A} → a ≰ b → a ≥ b ≰⇒≥ = <⇒≤ ∘ ≰⇒> <?⇒< : {a b : A} → (a <? b) ≡ true → a < b <?⇒< {a = a} {b = b} a<?b with compare a b ...| less a<b = a<b ...| equal a≡b rewrite a≡b = case a<?b of λ () ...| greater _ = case a<?b of λ () ≮?⇒≮ : {a b : A} → (a <? b) ≡ false → a ≮ b ≮?⇒≮ {a = a} {b = b} a≮?b with compare a b ...| less _ = case a≮?b of λ () ...| equal a≡b rewrite a≡b = λ a<b → ⊥-elim (less-antirefl a<b) ...| greater a>b = λ a<b → ⊥-elim (less-antisym a>b a<b) ≤?⇒≤ : {a b : A} → (a ≤? b) ≡ true → a ≤ b ≤?⇒≤ {a = a} {b = b} a≤?b with inspect (compare b a) ...| less a<b with≡ compare≡ rewrite compare≡ = case a≤?b of λ () ...| equal a≡b with≡ _ = eq-to-leq (sym a≡b) ...| greater a>b with≡ _ = lt-to-leq a>b ≰?⇒≰ : {a b : A} → (a ≤? b) ≡ false → a ≰ b ≰?⇒≰ {a = a} {b = b} a≰?b with (compare b a) ...| less b<a = <⇒≱ b<a ...| equal a≡b rewrite a≡b = case a≰?b of λ () ...| greater _ = case a≰?b of λ () ≰?⇒≥ : {a b : A} → (a ≤? b) ≡ false → a ≥ b ≰?⇒≥ = ≰⇒≥ ∘ ≰?⇒≰
{ "alphanum_fraction": 0.4597298649, "avg_line_length": 27.0135135135, "ext": "agda", "hexsha": "81d850fac68c926158dab591a0f1528def3000f5", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_path": "src/Prelude/Ord/Properties.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_path": "src/Prelude/Ord/Properties.agda", "max_line_length": 65, "max_stars_count": 111, "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_path": "src/Prelude/Ord/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 1017, "size": 1999 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.ZariskiLattice.BasicOpens where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.HLevels open import Cubical.Foundations.Powerset open import Cubical.Foundations.Transport open import Cubical.Foundations.Structure open import Cubical.Functions.FunExtEquiv import Cubical.Data.Empty as ⊥ open import Cubical.Data.Bool open import Cubical.Data.Nat renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_ ; +-comm to +ℕ-comm ; +-assoc to +ℕ-assoc ; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm) open import Cubical.Data.Sigma.Base open import Cubical.Data.Sigma.Properties open import Cubical.Data.FinData open import Cubical.Relation.Nullary open import Cubical.Relation.Binary open import Cubical.Relation.Binary.Poset open import Cubical.Algebra.Ring open import Cubical.Algebra.Algebra open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.Localisation.Base open import Cubical.Algebra.CommRing.Localisation.UniversalProperty open import Cubical.Algebra.CommRing.Localisation.InvertingElements open import Cubical.Algebra.CommAlgebra.Base open import Cubical.Algebra.CommAlgebra.Properties open import Cubical.Algebra.CommAlgebra.Localisation open import Cubical.Algebra.RingSolver.ReflectionSolving open import Cubical.Algebra.Semilattice open import Cubical.HITs.SetQuotients as SQ open import Cubical.HITs.PropositionalTruncation as PT open Iso open BinaryRelation open isEquivRel private variable ℓ ℓ' : Level module Presheaf (A' : CommRing ℓ) where open CommRingStr (snd A') renaming (_·_ to _·r_ ; ·-comm to ·r-comm ; ·Assoc to ·rAssoc ; ·Lid to ·rLid ; ·Rid to ·rRid) open Exponentiation A' open CommRingTheory A' open isMultClosedSubset open CommAlgebraStr ⦃...⦄ private A = fst A' A[1/_] : A → CommAlgebra A' ℓ A[1/ x ] = AlgLoc.S⁻¹RAsCommAlg A' ([_ⁿ|n≥0] A' x) (powersFormMultClosedSubset _ _) A[1/_]ˣ : (x : A) → ℙ (fst A[1/ x ]) A[1/ x ]ˣ = (CommAlgebra→CommRing A[1/ x ]) ˣ _≼_ : A → A → Type ℓ x ≼ y = ∃[ n ∈ ℕ ] Σ[ z ∈ A ] x ^ n ≡ z ·r y -- rad(x) ⊆ rad(y) -- ≼ is a pre-order: Refl≼ : isRefl _≼_ Refl≼ x = PT.∣ 1 , 1r , ·r-comm _ _ ∣ Trans≼ : isTrans _≼_ Trans≼ x y z = map2 Trans≼Σ where Trans≼Σ : Σ[ n ∈ ℕ ] Σ[ a ∈ A ] x ^ n ≡ a ·r y → Σ[ n ∈ ℕ ] Σ[ a ∈ A ] y ^ n ≡ a ·r z → Σ[ n ∈ ℕ ] Σ[ a ∈ A ] x ^ n ≡ a ·r z Trans≼Σ (n , a , p) (m , b , q) = n ·ℕ m , (a ^ m ·r b) , path where path : x ^ (n ·ℕ m) ≡ a ^ m ·r b ·r z path = x ^ (n ·ℕ m) ≡⟨ ^-rdist-·ℕ x n m ⟩ (x ^ n) ^ m ≡⟨ cong (_^ m) p ⟩ (a ·r y) ^ m ≡⟨ ^-ldist-· a y m ⟩ a ^ m ·r y ^ m ≡⟨ cong (a ^ m ·r_) q ⟩ a ^ m ·r (b ·r z) ≡⟨ ·rAssoc _ _ _ ⟩ a ^ m ·r b ·r z ∎ R : A → A → Type ℓ R x y = x ≼ y × y ≼ x -- rad(x) ≡ rad(y) RequivRel : isEquivRel R RequivRel .reflexive x = Refl≼ x , Refl≼ x RequivRel .symmetric _ _ Rxy = (Rxy .snd) , (Rxy .fst) RequivRel .transitive _ _ _ Rxy Ryz = Trans≼ _ _ _ (Rxy .fst) (Ryz .fst) , Trans≼ _ _ _ (Ryz .snd) (Rxy .snd) RpropValued : isPropValued R RpropValued x y = isProp× isPropPropTrunc isPropPropTrunc powerIs≽ : (x a : A) → x ∈ ([_ⁿ|n≥0] A' a) → a ≼ x powerIs≽ x a = map powerIs≽Σ where powerIs≽Σ : Σ[ n ∈ ℕ ] (x ≡ a ^ n) → Σ[ n ∈ ℕ ] Σ[ z ∈ A ] (a ^ n ≡ z ·r x) powerIs≽Σ (n , p) = n , 1r , sym p ∙ sym (·rLid _) module ≼ToLoc (x y : A) where private instance _ = snd A[1/ x ] lemma : x ≼ y → y ⋆ 1a ∈ A[1/ x ]ˣ -- y/1 ∈ A[1/x]ˣ lemma = PT.rec (A[1/ x ]ˣ (y ⋆ 1a) .snd) lemmaΣ where path1 : (y z : A) → 1r ·r (y ·r 1r ·r z) ·r 1r ≡ z ·r y path1 = solve A' path2 : (xn : A) → xn ≡ 1r ·r 1r ·r (1r ·r 1r ·r xn) path2 = solve A' lemmaΣ : Σ[ n ∈ ℕ ] Σ[ a ∈ A ] x ^ n ≡ a ·r y → y ⋆ 1a ∈ A[1/ x ]ˣ lemmaΣ (n , z , p) = [ z , (x ^ n) , PT.∣ n , refl ∣ ] -- xⁿ≡zy → y⁻¹ ≡ z/xⁿ , eq/ _ _ ((1r , powersFormMultClosedSubset _ _ .containsOne) , (path1 _ _ ∙∙ sym p ∙∙ path2 _)) module ≼PowerToLoc (x y : A) (x≼y : x ≼ y) where private [yⁿ|n≥0] = [_ⁿ|n≥0] A' y instance _ = snd A[1/ x ] lemma : ∀ (s : A) → s ∈ [yⁿ|n≥0] → s ⋆ 1a ∈ A[1/ x ]ˣ lemma _ s∈[yⁿ|n≥0] = ≼ToLoc.lemma _ _ (Trans≼ _ y _ x≼y (powerIs≽ _ _ s∈[yⁿ|n≥0])) 𝓞ᴰ : A / R → CommAlgebra A' ℓ 𝓞ᴰ = rec→Gpd.fun isGroupoidCommAlgebra (λ a → A[1/ a ]) RCoh LocPathProp where RCoh : ∀ a b → R a b → A[1/ a ] ≡ A[1/ b ] RCoh a b (a≼b , b≼a) = fst (isContrS₁⁻¹R≡S₂⁻¹R (≼PowerToLoc.lemma _ _ b≼a) (≼PowerToLoc.lemma _ _ a≼b)) where open AlgLocTwoSubsets A' ([_ⁿ|n≥0] A' a) (powersFormMultClosedSubset _ _) ([_ⁿ|n≥0] A' b) (powersFormMultClosedSubset _ _) LocPathProp : ∀ a b → isProp (A[1/ a ] ≡ A[1/ b ]) LocPathProp a b = isPropS₁⁻¹R≡S₂⁻¹R where open AlgLocTwoSubsets A' ([_ⁿ|n≥0] A' a) (powersFormMultClosedSubset _ _) ([_ⁿ|n≥0] A' b) (powersFormMultClosedSubset _ _) -- The quotient A/R corresponds to the basic opens of the Zariski topology. -- Multiplication lifts to the quotient and corresponds to intersection -- of basic opens, i.e. we get a meet-semilattice with: _∧/_ : A / R → A / R → A / R _∧/_ = setQuotSymmBinOp (RequivRel .reflexive) (RequivRel .transitive) _·r_ (λ a b → subst (λ x → R (a ·r b) x) (·r-comm a b) (RequivRel .reflexive (a ·r b))) ·r-lcoh where ·r-lcoh-≼ : (x y z : A) → x ≼ y → (x ·r z) ≼ (y ·r z) ·r-lcoh-≼ x y z = map ·r-lcoh-≼Σ where path : (x z a y zn : A) → x ·r z ·r (a ·r y ·r zn) ≡ x ·r zn ·r a ·r (y ·r z) path = solve A' ·r-lcoh-≼Σ : Σ[ n ∈ ℕ ] Σ[ a ∈ A ] x ^ n ≡ a ·r y → Σ[ n ∈ ℕ ] Σ[ a ∈ A ] (x ·r z) ^ n ≡ a ·r (y ·r z) ·r-lcoh-≼Σ (n , a , p) = suc n , (x ·r z ^ n ·r a) , (cong (x ·r z ·r_) (^-ldist-· _ _ _) ∙∙ cong (λ v → x ·r z ·r (v ·r z ^ n)) p ∙∙ path _ _ _ _ _) ·r-lcoh : (x y z : A) → R x y → R (x ·r z) (y ·r z) ·r-lcoh x y z Rxy = ·r-lcoh-≼ x y z (Rxy .fst) , ·r-lcoh-≼ y x z (Rxy .snd) BasicOpens : Semilattice ℓ BasicOpens = makeSemilattice [ 1r ] _∧/_ squash/ (elimProp3 (λ _ _ _ → squash/ _ _) λ _ _ _ → cong [_] (·rAssoc _ _ _)) (elimProp (λ _ → squash/ _ _) λ _ → cong [_] (·rRid _)) (elimProp (λ _ → squash/ _ _) λ _ → cong [_] (·rLid _)) (elimProp2 (λ _ _ → squash/ _ _) λ _ _ → cong [_] (·r-comm _ _)) (elimProp (λ _ → squash/ _ _) λ a → eq/ _ _ -- R a a² (∣ 1 , a , ·rRid _ ∣ , ∣ 2 , 1r , cong (a ·r_) (·rRid a) ∙ sym (·rLid _) ∣)) -- The induced partial order open MeetSemilattice BasicOpens renaming (_≤_ to _≼/_ ; IndPoset to BasicOpensAsPoset) -- coincides with our ≼ ≼/CoincidesWith≼ : ∀ (x y : A) → ([ x ] ≼/ [ y ]) ≡ (x ≼ y) ≼/CoincidesWith≼ x y = [ x ] ≼/ [ y ] -- ≡⟨ refl ⟩ [ x ·r y ] ≡ [ x ] ≡⟨ isoToPath (isEquivRel→effectiveIso RpropValued RequivRel _ _) ⟩ R (x ·r y) x ≡⟨ isoToPath Σ-swap-Iso ⟩ R x (x ·r y) ≡⟨ hPropExt (RpropValued _ _) isPropPropTrunc ·To≼ ≼To· ⟩ x ≼ y ∎ where x≼xy→x≼yΣ : Σ[ n ∈ ℕ ] Σ[ z ∈ A ] x ^ n ≡ z ·r (x ·r y) → Σ[ n ∈ ℕ ] Σ[ z ∈ A ] x ^ n ≡ z ·r y x≼xy→x≼yΣ (n , z , p) = n , (z ·r x) , p ∙ ·rAssoc _ _ _ ·To≼ : R x (x ·r y) → x ≼ y ·To≼ (x≼xy , _) = PT.map x≼xy→x≼yΣ x≼xy x≼y→x≼xyΣ : Σ[ n ∈ ℕ ] Σ[ z ∈ A ] x ^ n ≡ z ·r y → Σ[ n ∈ ℕ ] Σ[ z ∈ A ] x ^ n ≡ z ·r (x ·r y) x≼y→x≼xyΣ (n , z , p) = suc n , z , cong (x ·r_) p ∙ ·-commAssocl _ _ _ ≼To· : x ≼ y → R x ( x ·r y) ≼To· x≼y = PT.map x≼y→x≼xyΣ x≼y , PT.∣ 1 , y , ·rRid _ ∙ ·r-comm _ _ ∣ open IsPoset open PosetStr Refl≼/ : isRefl _≼/_ Refl≼/ = BasicOpensAsPoset .snd .isPoset .is-refl Trans≼/ : isTrans _≼/_ Trans≼/ = BasicOpensAsPoset .snd .isPoset .is-trans -- The restrictions: ρᴰᴬ : (a b : A) → a ≼ b → isContr (CommAlgebraHom A[1/ b ] A[1/ a ]) ρᴰᴬ _ b a≼b = A[1/b]HasUniversalProp _ (≼PowerToLoc.lemma _ _ a≼b) where open AlgLoc A' ([_ⁿ|n≥0] A' b) (powersFormMultClosedSubset _ _) renaming (S⁻¹RHasAlgUniversalProp to A[1/b]HasUniversalProp) ρᴰᴬId : ∀ (a : A) (r : a ≼ a) → ρᴰᴬ a a r .fst ≡ idAlgHom ρᴰᴬId a r = ρᴰᴬ a a r .snd _ ρᴰᴬComp : ∀ (a b c : A) (l : a ≼ b) (m : b ≼ c) → ρᴰᴬ a c (Trans≼ _ _ _ l m) .fst ≡ ρᴰᴬ a b l .fst ∘a ρᴰᴬ b c m .fst ρᴰᴬComp a _ c l m = ρᴰᴬ a c (Trans≼ _ _ _ l m) .snd _ ρᴰ : (x y : A / R) → x ≼/ y → CommAlgebraHom (𝓞ᴰ y) (𝓞ᴰ x) ρᴰ = elimContr2 λ _ _ → isContrΠ λ [a]≼/[b] → ρᴰᴬ _ _ (transport (≼/CoincidesWith≼ _ _) [a]≼/[b]) ρᴰId : ∀ (x : A / R) (r : x ≼/ x) → ρᴰ x x r ≡ idAlgHom ρᴰId = SQ.elimProp (λ _ → isPropΠ (λ _ → isSetAlgebraHom _ _ _ _)) λ a r → ρᴰᴬId a (transport (≼/CoincidesWith≼ _ _) r) ρᴰComp : ∀ (x y z : A / R) (l : x ≼/ y) (m : y ≼/ z) → ρᴰ x z (Trans≼/ _ _ _ l m) ≡ ρᴰ x y l ∘a ρᴰ y z m ρᴰComp = SQ.elimProp3 (λ _ _ _ → isPropΠ2 (λ _ _ → isSetAlgebraHom _ _ _ _)) λ a b c _ _ → sym (ρᴰᴬ a c _ .snd _) ∙ ρᴰᴬComp a b c _ _
{ "alphanum_fraction": 0.5327210103, "avg_line_length": 38.4779116466, "ext": "agda", "hexsha": "83fed7d2bb154981930e14c7f8f0f691d9d4f2c4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dolio/cubical", "max_forks_repo_path": "Cubical/Algebra/ZariskiLattice/BasicOpens.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "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": "dolio/cubical", "max_issues_repo_path": "Cubical/Algebra/ZariskiLattice/BasicOpens.agda", "max_line_length": 100, "max_stars_count": null, "max_stars_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dolio/cubical", "max_stars_repo_path": "Cubical/Algebra/ZariskiLattice/BasicOpens.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4234, "size": 9581 }
-- NB. This test fail if Agda is called with the --no-sharing option. module Issue1351 where open import Common.Equality open import Common.Prelude f1 : Nat → Nat f1 x = x + x f2 : Nat → Nat f2 x = f1 (f1 x) f4 : Nat → Nat f4 x = f2 (f2 x) f8 : Nat → Nat f8 x = f4 (f4 x) f16 : Nat → Nat f16 x = f8 (f8 x) f32 : Nat → Nat f32 x = f16 (f16 x) thm : f32 1 ≡ 4294967296 thm = refl
{ "alphanum_fraction": 0.6201550388, "avg_line_length": 13.8214285714, "ext": "agda", "hexsha": "bccab92da77da65bb779680607fa875d13a833e7", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Succeed/Issue1351.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "test/Succeed/Issue1351.agda", "max_line_length": 69, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Succeed/Issue1351.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 161, "size": 387 }
-- {-# OPTIONS --without-K #-} module kripke where open import common infixl 2 _▻_ infixl 3 _‘’_ infixr 1 _‘→’_ infixr 1 _‘‘→’’_ infixr 1 _ww‘‘‘→’’’_ infixl 3 _‘’ₐ_ infixl 3 _w‘‘’’ₐ_ infixr 2 _‘∘’_ infixr 2 _‘×’_ infixr 2 _‘‘×’’_ infixr 2 _w‘‘×’’_ mutual data Context : Set where ε : Context _▻_ : (Γ : Context) → Type Γ → Context data Type : Context → Set where W : ∀ {Γ A} → Type Γ → Type (Γ ▻ A) W1 : ∀ {Γ A B} → Type (Γ ▻ B) → Type (Γ ▻ A ▻ (W {Γ = Γ} {A = A} B)) _‘’_ : ∀ {Γ A} → Type (Γ ▻ A) → Term {Γ} A → Type Γ ‘Type’ : ∀ Γ → Type Γ ‘Term’ : ∀ {Γ} → Type (Γ ▻ ‘Type’ Γ) _‘→’_ : ∀ {Γ} → Type Γ → Type Γ → Type Γ _‘×’_ : ∀ {Γ} → Type Γ → Type Γ → Type Γ Quine : ∀ {Γ} → Type (Γ ▻ ‘Type’ Γ) → Type Γ ‘⊤’ : ∀ {Γ} → Type Γ ‘⊥’ : ∀ {Γ} → Type Γ data Term : {Γ : Context} → Type Γ → Set where ⌜_⌝ : ∀ {Γ} → Type Γ → Term {Γ} (‘Type’ Γ) ⌜_⌝t : ∀ {Γ T} → Term {Γ} T → Term {Γ} (‘Term’ ‘’ ⌜ T ⌝) ‘⌜‘VAR₀’⌝t’ : ∀ {Γ T} → Term {Γ ▻ ‘Term’ ‘’ ⌜ T ⌝} (W (‘Term’ ‘’ ⌜ ‘Term’ ‘’ ⌜ T ⌝ ⌝)) ‘⌜‘VAR₀’⌝’ : ∀ {Γ} → Term {Γ ▻ ‘Type’ Γ} (W (‘Term’ ‘’ ⌜ ‘Type’ Γ ⌝)) ‘λ∙’ : ∀ {Γ A B} → Term {Γ ▻ A} (W B) → Term {Γ} (A ‘→’ B) ‘VAR₀’ : ∀ {Γ T} → Term {Γ ▻ T} (W T) _‘’ₐ_ : ∀ {Γ A B} → Term {Γ} (A ‘→’ B) → Term {Γ} A → Term {Γ} B ‘‘×'’’ : ∀ {Γ} → Term {Γ} (‘Type’ Γ ‘→’ ‘Type’ Γ ‘→’ ‘Type’ Γ) quine→ : ∀ {Γ φ} → Term {Γ} (Quine φ ‘→’ φ ‘’ ⌜ Quine φ ⌝) quine← : ∀ {Γ φ} → Term {Γ} (φ ‘’ ⌜ Quine φ ⌝ ‘→’ Quine φ) ‘tt’ : ∀ {Γ} → Term {Γ} ‘⊤’ SW : ∀ {Γ X A} {a : Term A} → Term {Γ} (W X ‘’ a) → Term X →SW1SV→W : ∀ {Γ T X A B} {x : Term X} → Term {Γ} (T ‘→’ (W1 A ‘’ ‘VAR₀’ ‘→’ W B) ‘’ x) → Term {Γ} (T ‘→’ A ‘’ x ‘→’ B) ←SW1SV→W : ∀ {Γ T X A B} {x : Term X} → Term {Γ} ((W1 A ‘’ ‘VAR₀’ ‘→’ W B) ‘’ x ‘→’ T) → Term {Γ} ((A ‘’ x ‘→’ B) ‘→’ T) →SW1SV→SW1SV→W : ∀ {Γ T X A B} {x : Term X} → Term {Γ} (T ‘→’ (W1 A ‘’ ‘VAR₀’ ‘→’ W1 A ‘’ ‘VAR₀’ ‘→’ W B) ‘’ x) → Term {Γ} (T ‘→’ A ‘’ x ‘→’ A ‘’ x ‘→’ B) ←SW1SV→SW1SV→W : ∀ {Γ T X A B} {x : Term X} → Term {Γ} ((W1 A ‘’ ‘VAR₀’ ‘→’ W1 A ‘’ ‘VAR₀’ ‘→’ W B) ‘’ x ‘→’ T) → Term {Γ} ((A ‘’ x ‘→’ A ‘’ x ‘→’ B) ‘→’ T) w : ∀ {Γ A T} → Term {Γ} A → Term {Γ ▻ T} (W A) w→ : ∀ {Γ A B X} → Term {Γ ▻ X} (W (A ‘→’ B)) → Term {Γ ▻ X} (W A ‘→’ W B) →w : ∀ {Γ A B X} → Term {Γ ▻ X} (W A ‘→’ W B) → Term {Γ ▻ X} (W (A ‘→’ B)) ww→ : ∀ {Γ A B X Y} → Term {Γ ▻ X ▻ Y} (W (W (A ‘→’ B))) → Term {Γ ▻ X ▻ Y} (W (W A) ‘→’ W (W B)) →ww : ∀ {Γ A B X Y} → Term {Γ ▻ X ▻ Y} (W (W A) ‘→’ W (W B)) → Term {Γ ▻ X ▻ Y} (W (W (A ‘→’ B))) _‘∘’_ : ∀ {Γ A B C} → Term {Γ} (B ‘→’ C) → Term {Γ} (A ‘→’ B) → Term {Γ} (A ‘→’ C) _w‘‘’’ₐ_ : ∀ {Γ A B T} → Term {Γ ▻ T} (W (‘Term’ ‘’ ⌜ A ‘→’ B ⌝)) → Term {Γ ▻ T} (W (‘Term’ ‘’ ⌜ A ⌝)) → Term {Γ ▻ T} (W (‘Term’ ‘’ ⌜ B ⌝)) ‘‘’ₐ’ : ∀ {Γ A B} → Term {Γ} (‘Term’ ‘’ ⌜ A ‘→’ B ⌝ ‘→’ ‘Term’ ‘’ ⌜ A ⌝ ‘→’ ‘Term’ ‘’ ⌜ B ⌝) -- _w‘‘’’_ : ∀ {Γ A B T} → Term {Γ ▻ T} (‘Type’ (Γ ▻ T)) → Term {Γ ▻ A ▻ B} (W (W (‘Term’ ‘’ ⌜ T ⌝))) → Term {Γ ▻ A ▻ B} (W (W (‘Type’ Γ))) ‘‘□’’ : ∀ {Γ A B} → Term {Γ ▻ A ▻ B} (W (W (‘Term’ ‘’ ⌜ ‘Type’ Γ ⌝))) → Term {Γ ▻ A ▻ B} (W (W (‘Type’ Γ))) -- ‘‘’’' : ∀ {Γ A} → Term {Γ ▻ A} (‘Type’ (Γ ▻ A) ‘→’ W (‘Term’ ‘’ ⌜ A ⌝) ‘→’ W (‘Type’ Γ)) _‘‘→’’_ : ∀ {Γ} → Term {Γ} (‘Type’ Γ) → Term {Γ} (‘Type’ Γ) → Term {Γ} (‘Type’ Γ) _ww‘‘‘→’’’_ : ∀ {Γ A B} → Term {Γ ▻ A ▻ B} (W (W (‘Term’ ‘’ ⌜ ‘Type’ Γ ⌝))) → Term {Γ ▻ A ▻ B} (W (W (‘Term’ ‘’ ⌜ ‘Type’ Γ ⌝))) → Term {Γ ▻ A ▻ B} (W (W (‘Term’ ‘’ ⌜ ‘Type’ Γ ⌝))) _ww‘‘‘×’’’_ : ∀ {Γ A B} → Term {Γ ▻ A ▻ B} (W (W (‘Term’ ‘’ ⌜ ‘Type’ Γ ⌝))) → Term {Γ ▻ A ▻ B} (W (W (‘Term’ ‘’ ⌜ ‘Type’ Γ ⌝))) → Term {Γ ▻ A ▻ B} (W (W (‘Term’ ‘’ ⌜ ‘Type’ Γ ⌝))) □ : Type ε → Set _ □ = Term {ε} ‘□’ : ∀ {Γ} → Type Γ → Type Γ ‘□’ T = ‘Term’ ‘’ ⌜ T ⌝ _‘‘×’’_ : ∀ {Γ} → Term {Γ} (‘Type’ Γ) → Term {Γ} (‘Type’ Γ) → Term {Γ} (‘Type’ Γ) A ‘‘×’’ B = ‘‘×'’’ ‘’ₐ A ‘’ₐ B max-level : Level max-level = lzero mutual Context⇓ : (Γ : Context) → Set (lsuc max-level) Context⇓ ε = ⊤ Context⇓ (Γ ▻ T) = Σ (Context⇓ Γ) (Type⇓ {Γ} T) Type⇓ : {Γ : Context} → Type Γ → Context⇓ Γ → Set max-level Type⇓ (W T) Γ⇓ = Type⇓ T (Σ.proj₁ Γ⇓) Type⇓ (W1 T) Γ⇓ = Type⇓ T ((Σ.proj₁ (Σ.proj₁ Γ⇓)) , (Σ.proj₂ Γ⇓)) Type⇓ (T ‘’ x) Γ⇓ = Type⇓ T (Γ⇓ , Term⇓ x Γ⇓) Type⇓ (‘Type’ Γ) Γ⇓ = Lifted (Type Γ) Type⇓ ‘Term’ Γ⇓ = Lifted (Term (lower (Σ.proj₂ Γ⇓))) Type⇓ (A ‘→’ B) Γ⇓ = Type⇓ A Γ⇓ → Type⇓ B Γ⇓ Type⇓ (A ‘×’ B) Γ⇓ = Type⇓ A Γ⇓ × Type⇓ B Γ⇓ Type⇓ ‘⊤’ Γ⇓ = ⊤ Type⇓ ‘⊥’ Γ⇓ = ⊥ Type⇓ (Quine φ) Γ⇓ = Type⇓ φ (Γ⇓ , (lift (Quine φ))) Term⇓ : ∀ {Γ : Context} {T : Type Γ} → Term T → (Γ⇓ : Context⇓ Γ) → Type⇓ T Γ⇓ Term⇓ ⌜ x ⌝ Γ⇓ = lift x Term⇓ ⌜ x ⌝t Γ⇓ = lift x Term⇓ ‘⌜‘VAR₀’⌝t’ Γ⇓ = lift ⌜ (lower (Σ.proj₂ Γ⇓)) ⌝t Term⇓ ‘⌜‘VAR₀’⌝’ Γ⇓ = lift ⌜ (lower (Σ.proj₂ Γ⇓)) ⌝ Term⇓ (f ‘’ₐ x) Γ⇓ = Term⇓ f Γ⇓ (Term⇓ x Γ⇓) Term⇓ ‘tt’ Γ⇓ = tt Term⇓ (quine→ {φ}) Γ⇓ x = x Term⇓ (quine← {φ}) Γ⇓ x = x Term⇓ (‘λ∙’ f) Γ⇓ x = Term⇓ f (Γ⇓ , x) Term⇓ ‘VAR₀’ Γ⇓ = Σ.proj₂ Γ⇓ Term⇓ (SW t) = Term⇓ t Term⇓ (←SW1SV→W f) = Term⇓ f Term⇓ (→SW1SV→W f) = Term⇓ f Term⇓ (←SW1SV→SW1SV→W f) = Term⇓ f Term⇓ (→SW1SV→SW1SV→W f) = Term⇓ f Term⇓ (w x) Γ⇓ = Term⇓ x (Σ.proj₁ Γ⇓) Term⇓ (w→ f) Γ⇓ = Term⇓ f Γ⇓ Term⇓ (→w f) Γ⇓ = Term⇓ f Γ⇓ Term⇓ (ww→ f) Γ⇓ = Term⇓ f Γ⇓ Term⇓ (→ww f) Γ⇓ = Term⇓ f Γ⇓ Term⇓ ‘‘×'’’ Γ⇓ A B = lift (lower A ‘×’ lower B) Term⇓ (g ‘∘’ f) Γ⇓ x = Term⇓ g Γ⇓ (Term⇓ f Γ⇓ x) Term⇓ (f w‘‘’’ₐ x) Γ⇓ = lift (lower (Term⇓ f Γ⇓) ‘’ₐ lower (Term⇓ x Γ⇓)) Term⇓ ‘‘’ₐ’ Γ⇓ f x = lift (lower f ‘’ₐ lower x) -- Term⇓ (f w‘‘’’ x) Γ⇓ = lift {!!} --(lower (Term⇓ f Γ⇓) ‘’ lower (Term⇓ x Γ⇓)) Term⇓ (‘‘□’’ {Γ} T) Γ⇓ = lift (‘Term’ ‘’ lower (Term⇓ T Γ⇓)) Term⇓ (A ‘‘→’’ B) Γ⇓ = lift ((lower (Term⇓ A Γ⇓)) ‘→’ (lower (Term⇓ B Γ⇓))) Term⇓ (A ww‘‘‘→’’’ B) Γ⇓ = lift ((lower (Term⇓ A Γ⇓)) ‘‘→’’ (lower (Term⇓ B Γ⇓))) Term⇓ (A ww‘‘‘×’’’ B) Γ⇓ = lift ((lower (Term⇓ A Γ⇓)) ‘‘×’’ (lower (Term⇓ B Γ⇓))) module inner (‘X’ : Type ε) (‘f’ : Term {ε} (‘□’ ‘X’ ‘→’ ‘X’)) where ‘H’ : Type ε ‘H’ = Quine (W1 ‘Term’ ‘’ ‘VAR₀’ ‘→’ W ‘X’) ‘toH’ : □ ((‘□’ ‘H’ ‘→’ ‘X’) ‘→’ ‘H’) ‘toH’ = ←SW1SV→W quine← ‘fromH’ : □ (‘H’ ‘→’ (‘□’ ‘H’ ‘→’ ‘X’)) ‘fromH’ = →SW1SV→W quine→ ‘□‘H’→□‘X’’ : □ (‘□’ ‘H’ ‘→’ ‘□’ ‘X’) ‘□‘H’→□‘X’’ = ‘λ∙’ (w ⌜ ‘fromH’ ⌝t w‘‘’’ₐ ‘VAR₀’ w‘‘’’ₐ ‘⌜‘VAR₀’⌝t’) ‘h’ : Term ‘H’ ‘h’ = ‘toH’ ‘’ₐ (‘f’ ‘∘’ ‘□‘H’→□‘X’’) Lӧb : □ ‘X’ Lӧb = ‘fromH’ ‘’ₐ ‘h’ ‘’ₐ ⌜ ‘h’ ⌝t Lӧb : ∀ {X} → Term {ε} (‘□’ X ‘→’ X) → Term {ε} X Lӧb {X} f = inner.Lӧb X f ⌞_⌟ : Type ε → Set _ ⌞ T ⌟ = Type⇓ T tt ‘¬’_ : ∀ {Γ} → Type Γ → Type Γ ‘¬’ T = T ‘→’ ‘⊥’ _w‘‘×’’_ : ∀ {Γ X} → Term {Γ ▻ X} (W (‘Type’ Γ)) → Term {Γ ▻ X} (W (‘Type’ Γ)) → Term {Γ ▻ X} (W (‘Type’ Γ)) A w‘‘×’’ B = w→ (w→ (w ‘‘×'’’) ‘’ₐ A) ‘’ₐ B lӧb : ∀ {‘X’} → □ (‘□’ ‘X’ ‘→’ ‘X’) → ⌞ ‘X’ ⌟ lӧb f = Term⇓ (Lӧb f) tt incompleteness : ¬ □ (‘¬’ (‘□’ ‘⊥’)) incompleteness = lӧb soundness : ¬ □ ‘⊥’ soundness x = Term⇓ x tt non-emptyness : Σ (Type ε) (λ T → □ T) non-emptyness = ‘⊤’ , ‘tt’ module helpers where Wₕ : ∀ {Γ A} → Type Γ → Type (Γ ▻ A) Wₕ ‘⊤’ = ‘⊤’ Wₕ ‘⊥’ = ‘⊥’ Wₕ (T ‘→’ T₂) = Wₕ T ‘→’ Wₕ T₂ Wₕ (T ‘×’ T₂) = Wₕ T ‘×’ Wₕ T₂ Wₕ (W T₂) = W (Wₕ T₂) Wₕ T = W T _‘’ₕ_ : ∀ {Γ A} → Type (Γ ▻ A) → Term A → Type Γ ‘⊤’ ‘’ₕ x₁ = ‘⊤’ ‘⊥’ ‘’ₕ x₁ = ‘⊥’ W f ‘’ₕ x₁ = f ‘Term’ ‘’ₕ ⌜ ‘⊤’ ⌝ = ‘⊤’ (f ‘→’ f₁) ‘’ₕ x₁ = (f ‘’ₕ x₁) ‘→’ (f₁ ‘’ₕ x₁) (f ‘×’ f₁) ‘’ₕ x₁ = (f ‘’ₕ x₁) ‘×’ (f₁ ‘’ₕ x₁) f ‘’ₕ x = f ‘’ x _‘→’ₕ_ : ∀ {Γ} → Type Γ → Type Γ → Type Γ ‘⊤’ ‘→’ₕ B = B ‘⊥’ ‘→’ₕ B = ‘⊤’ A ‘→’ₕ ‘⊤’ = ‘⊤’ A ‘→’ₕ B = A ‘→’ B _‘×’ₕ_ : ∀ {Γ} → Type Γ → Type Γ → Type Γ ‘⊤’ ‘×’ₕ B = B ‘⊥’ ‘×’ₕ B = ‘⊥’ A ‘×’ₕ ‘⊤’ = A A ‘×’ₕ ‘⊥’ = ‘⊥’ A ‘×’ₕ B = A ‘×’ B open helpers mutual simplify-type : ∀ {Γ} → Type Γ → Type Γ simplify-type ‘⊤’ = ‘⊤’ simplify-type ‘⊥’ = ‘⊥’ simplify-type (T ‘→’ T₁) = simplify-type T ‘→’ₕ simplify-type T₁ simplify-type (T ‘×’ T₁) = simplify-type T ‘×’ₕ simplify-type T₁ simplify-type (T₁ ‘’ x) = simplify-type T₁ ‘’ₕ simplify-term x simplify-type (W T₁) = Wₕ (simplify-type T₁) simplify-type (W1 T₂) = W1ₕ (simplify-type T₂) where W1ₕ : ∀ {Γ A B} → Type (Γ ▻ A) → Type (Γ ▻ B ▻ W A) W1ₕ ‘⊤’ = ‘⊤’ W1ₕ ‘⊥’ = ‘⊥’ W1ₕ (T ‘→’ T₂) = W1ₕ T ‘→’ W1ₕ T₂ W1ₕ (T ‘×’ T₂) = W1ₕ T ‘×’ W1ₕ T₂ W1ₕ (W T₂) = W (Wₕ T₂) W1ₕ (W1 T₂) = W1 (W1ₕ T₂) W1ₕ T = W1 T simplify-type (‘Type’ Γ) = ‘Type’ Γ simplify-type ‘Term’ = ‘Term’ simplify-type (Quine T) = Quine (simplify-type T) simplify-term : ∀ {Γ T} → Term {Γ} T → Term T simplify-term ⌜ x ⌝ = ⌜ simplify-type x ⌝ simplify-term ⌜ t ⌝t = ⌜ simplify-term t ⌝t simplify-term ‘⌜‘VAR₀’⌝t’ = ‘⌜‘VAR₀’⌝t’ simplify-term ‘⌜‘VAR₀’⌝’ = ‘⌜‘VAR₀’⌝’ simplify-term (‘λ∙’ t) = ‘λ∙’ (simplify-term t) simplify-term ‘VAR₀’ = ‘VAR₀’ simplify-term (t ‘’ₐ t₁) = simplify-term t ‘’ₐₕ simplify-term t₁ where _‘’ₐₕ_ : ∀ {Γ A T} → Term {Γ} (A ‘→’ T) → Term A → Term T ‘λ∙’ ‘⌜‘VAR₀’⌝t’ ‘’ₐₕ x = ⌜ x ⌝t ‘λ∙’ ‘⌜‘VAR₀’⌝’ ‘’ₐₕ x = ⌜ x ⌝t ‘λ∙’ ‘VAR₀’ ‘’ₐₕ x = x ‘λ∙’ (f ‘’ₐ f₁) ‘’ₐₕ x = ‘λ∙’ (f ‘’ₐₕ f₁) ‘’ₐ x ‘λ∙’ (w f) ‘’ₐₕ x = f (f ‘’ₐ f₁) ‘’ₐₕ x = (f ‘’ₐₕ f₁) ‘’ₐ x (f ‘∘’ f₁) ‘’ₐₕ x = f ‘’ₐₕ (f₁ ‘’ₐₕ x) f ‘’ₐₕ x = f ‘’ₐ x simplify-term ‘‘×'’’ = ‘‘×'’’ simplify-term quine→ = quine→ simplify-term quine← = quine← simplify-term ‘tt’ = ‘tt’ simplify-term (SW t₁) = SW (simplify-term t₁) simplify-term (→SW1SV→W t₁) = →SW1SV→W (simplify-term t₁) simplify-term (←SW1SV→W t₁) = ←SW1SV→W (simplify-term t₁) simplify-term (→SW1SV→SW1SV→W t₁) = →SW1SV→SW1SV→W (simplify-term t₁) simplify-term (←SW1SV→SW1SV→W t₁) = ←SW1SV→SW1SV→W (simplify-term t₁) simplify-term (w t) = w (simplify-term t) simplify-term (w→ t) = w→ (simplify-term t) simplify-term (→w t) = →w (simplify-term t) simplify-term (ww→ t) = ww→ (simplify-term t) simplify-term (→ww t) = →ww (simplify-term t) simplify-term (t ‘∘’ t₁) = simplify-term t ‘∘’ simplify-term t₁ simplify-term (t w‘‘’’ₐ t₁) = simplify-term t w‘‘’’ₐ simplify-term t₁ simplify-term ‘‘’ₐ’ = ‘‘’ₐ’ simplify-term (‘‘□’’ t) = ‘‘□’’ (simplify-term t) simplify-term (t ‘‘→’’ t₁) = simplify-term t ‘‘→’’ simplify-term t₁ simplify-term (t ww‘‘‘→’’’ t₁) = simplify-term t ww‘‘‘→’’’ simplify-term t₁ simplify-term (t ww‘‘‘×’’’ t₁) = simplify-term t ww‘‘‘×’’’ simplify-term t₁ {- mutual simplify-type⇓→ : ∀ {Γ T Γ⇓} → Type⇓ {Γ} T Γ⇓ → Type⇓ {Γ} (simplify-type T) Γ⇓ simplify-type⇓→ {T = T ‘→’ T₁} T⇓ = {!!} simplify-type⇓→ {T = W T₁} T⇓ = {!!} simplify-type⇓→ {T = W1 T₂} T⇓ = {!!} simplify-type⇓→ {T = T₁ ‘’ x} T⇓ = {!!} simplify-type⇓→ {T = ‘Type’ ._} T⇓ = {!!} simplify-type⇓→ {T = ‘Term’} T⇓ = {!!} simplify-type⇓→ {T = T ‘×’ T₁} T⇓ = {!!} simplify-type⇓→ {T = Quine T} T⇓ = {!!} simplify-type⇓→ {T = ‘⊤’} T⇓ = tt simplify-type⇓→ {T = ‘⊥’} T⇓ = T⇓ simplify-type⇓← : ∀ {Γ T Γ⇓} → Type⇓ {Γ} (simplify-type T) Γ⇓ → Type⇓ {Γ} T Γ⇓ simplify-type⇓← {T = W T₁} T⇓ = {!!} simplify-type⇓← {T = W1 T₂} T⇓ = {!!} simplify-type⇓← {T = T₁ ‘’ x} T⇓ = {!!} simplify-type⇓← {T = ‘Type’ ._} T⇓ = {!!} simplify-type⇓← {T = ‘Term’} T⇓ = {!!} simplify-type⇓← {T = T ‘→’ T₁} T⇓ x = {!!} simplify-type⇓← {Γ} {T ‘×’ T₁} {Γ⇓} T⇓ = helper {Γ} {simplify-type T} {simplify-type T₁} {T} {T₁} {Γ⇓} (simplify-type⇓← {T = T}) (simplify-type⇓← {T = T₁}) T⇓ where helper : ∀ {Γ A B A' B'} {Γ⇓ : Context⇓ Γ} → (Type⇓ A Γ⇓ → Type⇓ A' Γ⇓) → (Type⇓ B Γ⇓ → Type⇓ B' Γ⇓) → Type⇓ (A ‘×’ₕ B) Γ⇓ → Type⇓ (A' ‘×’ B') Γ⇓ helper {A = ‘⊤’} f g x = f tt , g x helper {A = ‘⊥’} f g () helper {A = W A₁} {‘⊤’} f g x = f x , g tt helper {A = W1 A₂} {‘⊤’} f g x = f x , g tt helper {A = A₁ ‘’ x} {‘⊤’} f g x₁ = f x₁ , g tt helper {A = ‘Type’ ._} {‘⊤’} f g x = f x , g tt helper {A = ‘Term’} {‘⊤’} f g x = f x , g tt helper {A = A ‘→’ A₁} {‘⊤’} f g x = f x , g tt helper {A = A ‘×’ A₁} {‘⊤’} f g x = f x , g tt helper {A = Quine A} {‘⊤’} f g x = f x , g tt helper {A = W A₁} {‘⊥’} {Γ⇓ = proj₁ , proj₂} f g () helper {A = W1 A₂} {‘⊥’} {Γ⇓ = proj₁ , proj₂ , proj₃} f g () helper {A = A₁ ‘’ x} {‘⊥’} f g () helper {A = ‘Type’ ._} {‘⊥’} f g () helper {A = ‘Term’} {‘⊥’} {Γ⇓ = proj₁ , proj₂} f g () helper {A = A ‘→’ A₁} {‘⊥’} f g () helper {A = A ‘×’ A₁} {‘⊥’} f g () helper {A = Quine A} {‘⊥’} f g () helper {A = W A₁} {W B₁} {Γ⇓ = proj₁ , proj₂} f g x = f (Σ.proj₁ x) , g (Σ.proj₂ x) helper {A = W1 A₂} {W B₁} {Γ⇓ = proj₁ , proj₂} f g x = f (Σ.proj₁ x) , g (Σ.proj₂ x) helper {A = A₂ ‘’ _} {W B₁} {Γ⇓ = proj₁ , proj₂} f g x = {!f (Σ.proj₁ x) , g (Σ.proj₂ x)!} helper {A = ‘Type’ ._} {W B₁} {Γ⇓ = proj₁ , proj₂} f g x = f (Σ.proj₁ x) , g (Σ.proj₂ x) helper {A = ‘Term’} {W B₁} {Γ⇓ = proj₁ , proj₂} f g x = f (Σ.proj₁ x) , g (Σ.proj₂ x) helper {A = A₁ ‘→’ A₂} {W B₁} {Γ⇓ = proj₁ , proj₂} f g x = f (Σ.proj₁ x) , g (Σ.proj₂ x) helper {A = A₁ ‘×’ A₂} {W B₁} {Γ⇓ = proj₁ , proj₂} f g x = f (Σ.proj₁ x) , g (Σ.proj₂ x) helper {A = Quine A₁} {W B₁} {Γ⇓ = proj₁ , proj₂} f g x = f (Σ.proj₁ x) , g (Σ.proj₂ x) helper {B = W1 B₂} f g x = {!!} helper {B = B₁ ‘’ x} f g x₁ = {!!} helper {B = ‘Type’ ._} f g x = {!!} helper {B = ‘Term’} f g x = {!!} helper {B = B ‘→’ B₁} f g x = {!!} helper {B = B ‘×’ B₁} f g x = {!!} helper {B = Quine B} f g x = {!!} {- helper {A = W A₁} f g x = {!!} helper {A = W1 A₂} f g x = {!!} helper {A = A₁ ‘’ x} f g x₁ = {!!} helper {A = ‘Type’ ._} f g x = {!!} helper {A = ‘Term’} f g x = {!!} helper {A = A ‘→’ A₁} f g x = {!!} helper {A = A ‘×’ A₁} f g x = {!!} helper {A = Quine A} f g x = {!!} -} simplify-type⇓← {T = Quine T} T⇓ = {!!} simplify-type⇓← {T = ‘⊤’} T⇓ = tt simplify-type⇓← {T = ‘⊥’} T⇓ = T⇓ -} module modal-fixpoint where context-to-term : Context → Set context-to-term ε = ⊤ context-to-term (Γ ▻ x) = Σ (context-to-term Γ) (λ _ → Term x) context-to-term⇓ : ∀ {Γ} → context-to-term Γ → Context⇓ Γ context-to-term⇓ {ε} v = tt context-to-term⇓ {Γ ▻ x} v = (context-to-term⇓ (Σ.proj₁ v)) , (Term⇓ (Σ.proj₂ v) (context-to-term⇓ (Σ.proj₁ v))) Type-in : ∀ {Γ} → Type Γ → context-to-term Γ → Type ε Type-in {ε} T v = T Type-in (T ‘→’ T₁) v = (Type-in T v) ‘→’ (Type-in T₁ v) Type-in ‘⊤’ v = ‘⊤’ Type-in ‘⊥’ v = ‘⊥’ Type-in {Γ ▻ x} T v = Type-in (T ‘’ Σ.proj₂ v) (Σ.proj₁ v) postulate hold : ∀ {Γ} → ℕ → Type Γ → Type Γ postulate hold-t : ∀ {Γ T} → ℕ → Term {Γ} T → Term T helper-ikf : ∀ {Γ A} world (T₁ : Type (Γ ▻ A)) (x : Term A) → Type Γ helper-ikf zero ‘Term’ x₁ = ‘⊤’ helper-ikf world f (x₁ ‘‘→’’ x₂) = helper-ikf world f x₁ ‘→’ helper-ikf world f x₂ helper-ikf (suc world) ‘Term’ ⌜ x₁ ⌝ = x₁ helper-ikf (suc world) ‘Term’ (x₁ ‘’ₐ x₂) = hold (suc world) (‘Term’ ‘’ (x₁ ‘’ₐ x₂)) helper-ikf (suc world) ‘Term’ (SW x₂) = hold (suc world) (‘Term’ ‘’ SW x₂) helper-ikf world (W T₂) x₁ = T₂ helper-ikf world (W1 T₄) x₁ = hold world (W1 T₄ ‘’ x₁) helper-ikf world (T₃ ‘’ x₁) x₂ = hold world (T₃ ‘’ x₁ ‘’ x₂) helper-ikf world (‘Type’ ._) x₁ = hold world (‘Type’ _ ‘’ x₁) helper-ikf world (T₂ ‘→’ T₃) x₁ = helper-ikf world T₂ x₁ ‘→’ helper-ikf world T₃ x₁ helper-ikf world (T₂ ‘×’ T₃) x₁ = helper-ikf world T₂ x₁ ‘×’ helper-ikf world T₃ x₁ helper-ikf world (Quine T₂) x₁ = hold world (Quine T₂ ‘’ x₁) helper-ikf world ‘⊤’ x₁ = ‘⊤’ helper-ikf world ‘⊥’ x₁ = ‘⊥’ mutual {- _‘’ₐₕ_ : ∀ {Γ A B} {world} (f : Term {Γ} (A ‘→’ B)) (x : Term A) → Term B ‘λ∙’ ‘⌜‘VAR₀’⌝t’ ‘’ₐₕ x₂ = ⌜ x₂ ⌝t ‘λ∙’ ‘⌜‘VAR₀’⌝’ ‘’ₐₕ x₂ = ⌜ x₂ ⌝t ‘λ∙’ ‘VAR₀’ ‘’ₐₕ x₂ = x₂ ‘λ∙’ (f ‘’ₐ f₁) ‘’ₐₕ x₂ = {!!} ‘λ∙’ (SW f₁) ‘’ₐₕ x₂ = {!!} ‘λ∙’ (w f) ‘’ₐₕ x₂ = f ‘λ∙’ (→w (‘λ∙’ ‘VAR₀’)) ‘’ₐₕ x₂ = ‘λ∙’ ‘VAR₀’ ‘λ∙’ (→w (‘λ∙’ (f ‘’ₐ f₁))) ‘’ₐₕ x₂ = {!!} ‘λ∙’ (→w (‘λ∙’ (SW f₁))) ‘’ₐₕ x₂ = {!!} ‘λ∙’ (→w (‘λ∙’ (w f))) ‘’ₐₕ x₂ = ‘λ∙’ (w (‘λ∙’ f ‘’ₐₕ x₂)) ‘λ∙’ (→w (‘λ∙’ (→ww f))) ‘’ₐₕ x₂ = {!!} ‘λ∙’ (→w (‘λ∙’ (‘‘□’’ f))) ‘’ₐₕ x₂ = {!!} ‘λ∙’ (→w (‘λ∙’ (f ww‘‘‘→’’’ f₁))) ‘’ₐₕ x₂ = {!!} ‘λ∙’ (→w (‘λ∙’ (f ww‘‘‘×’’’ f₁))) ‘’ₐₕ x₂ = {!!} ‘λ∙’ (→w (f ‘’ₐ f₁)) ‘’ₐₕ x₂ = {!!} ‘λ∙’ (→w (SW f₁)) ‘’ₐₕ x₂ = {!!} ‘λ∙’ (→w (w→ f)) ‘’ₐₕ x₂ = {!!} ‘λ∙’ (→w (ww→ f)) ‘’ₐₕ x₂ = {!!} ‘λ∙’ (→w (f ‘∘’ f₁)) ‘’ₐₕ x₂ = {!!} ‘λ∙’ (→ww f) ‘’ₐₕ x₂ = {!!} ‘λ∙’ (f w‘‘’’ₐ f₁) ‘’ₐₕ x₂ = {!!} ‘λ∙’ (‘‘□’’ f) ‘’ₐₕ x₂ = {!!} ‘λ∙’ (f ww‘‘‘→’’’ f₁) ‘’ₐₕ x₂ = {!!} ‘λ∙’ (f ww‘‘‘×’’’ f₁) ‘’ₐₕ x₂ = {!!} _‘’ₐₕ_ {world = world} (f ‘’ₐ f₁) x₂ = hold-t world ((_‘’ₐₕ_ {world = world} f f₁) ‘’ₐ x₂) _‘’ₐₕ_ {world = world} ‘‘×'’’ x₂ = {!!} _‘’ₐₕ_ {world = world} quine→ x₂ = {!!} _‘’ₐₕ_ {world = world} quine← x₂ = {!!} _‘’ₐₕ_ {world = world} (SW f₁) x₂ = {!!} _‘’ₐₕ_ {world = world} (→SW1SV→W f₁) x₂ = {!!} _‘’ₐₕ_ {world = world} (←SW1SV→W f₁) x₂ = {!!} →SW1SV→SW1SV→W (‘λ∙’ f₁) ‘’ₐₕ x₂ = {!!} →SW1SV→SW1SV→W (f₁ ‘’ₐ f₂) ‘’ₐₕ x₂ = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ⌜ x ⌝) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ⌜ x₃ ⌝t) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘⌜‘VAR₀’⌝t’) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘⌜‘VAR₀’⌝’) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ ‘⌜‘VAR₀’⌝t’) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ ‘⌜‘VAR₀’⌝’) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ ‘VAR₀’) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (x₃ ‘’ₐ x₄)) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (SW x₄)) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (w x₃)) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ ‘VAR₀’))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (x₃ ‘’ₐ x₄)))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (SW x₄)))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w ‘⌜‘VAR₀’⌝t’)))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w ‘⌜‘VAR₀’⌝’)))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w ‘VAR₀’)))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (x₃ ‘’ₐ x₄))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (SW x₄))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (‘λ∙’ x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ⌜ x ⌝))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ x₃ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ⌜ x ⌝))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (SW x₃ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ⌜ x ⌝))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (←SW1SV→W (‘λ∙’ x₃) ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ⌜ x₁ ⌝))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (←SW1SV→W (x₃ ‘’ₐ x₄) ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ⌜ x₁ ⌝))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (←SW1SV→W (SW x₄) ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ⌜ x₁ ⌝))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (←SW1SV→W (x₃ ‘∘’ x₄) ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ⌜ x₁ ⌝))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (←SW1SV→SW1SV→W (‘λ∙’ x₃) ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ⌜ x₁ ⌝))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (←SW1SV→SW1SV→W (x₃ ‘’ₐ x₄) ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ⌜ x₁ ⌝))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (←SW1SV→SW1SV→W quine← ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ⌜ x ⌝))))) = ‘λ∙’ (→w (‘λ∙’ (w (w ⌜ x ⌝)))) →SW1SV→SW1SV→W quine→ ‘’ₐₕ (←SW1SV→SW1SV→W (SW x₄) ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ⌜ x₁ ⌝))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (←SW1SV→SW1SV→W (x₃ ‘∘’ x₄) ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ⌜ x₁ ⌝))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ ((x₂ ‘∘’ x₃) ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ⌜ x ⌝))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ⌜ x₃ ⌝t))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ‘⌜‘VAR₀’⌝t’))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ‘⌜‘VAR₀’⌝’))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w (‘λ∙’ x₃)))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ‘VAR₀’))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w (x₃ ‘’ₐ x₄)))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ‘‘×'’’))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w quine→))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w quine←))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ‘tt’))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w (SW x₄)))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w (→SW1SV→W x₄)))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w (←SW1SV→W x₄)))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w (→SW1SV→SW1SV→W x₄)))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w (←SW1SV→SW1SV→W x₄)))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w (w x₃)))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w (w→ x₃)))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w (→w x₃)))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w (ww→ x₃)))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w (→ww x₃)))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w (x₃ ‘∘’ x₄)))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w (x₃ w‘‘’’ₐ x₄)))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w ‘‘’ₐ’))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w (‘‘□’’ x₃)))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w (x₃ ‘‘→’’ x₄)))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w (x₃ ww‘‘‘→’’’ x₄)))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (w (x₃ ww‘‘‘×’’’ x₄)))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (→w x₃))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (→ww x₃))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (x₃ w‘‘’’ₐ x₄))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (‘‘□’’ x₃))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (x₃ ww‘‘‘→’’’ x₄))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (w (x₃ ww‘‘‘×’’’ x₄))))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (→ww x₃)))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (‘‘□’’ x₃)))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (x₃ ww‘‘‘→’’’ x₄)))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (‘λ∙’ (x₃ ww‘‘‘×’’’ x₄)))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (x₃ ‘’ₐ x₄))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (SW x₄))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (w→ x₃))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (ww→ x₃))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→w (x₃ ‘∘’ x₄))) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (→ww x₃)) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (x₃ w‘‘’’ₐ x₄)) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (‘‘□’’ x₃)) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (x₃ ww‘‘‘→’’’ x₄)) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘λ∙’ (x₃ ww‘‘‘×’’’ x₄)) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘VAR₀’) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ (x₃ ‘’ₐ x₄)) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘‘×'’’) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ quine→) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ quine←) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘tt’) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ SW x₄) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ →SW1SV→W x₄) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ←SW1SV→W x₄) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ →SW1SV→SW1SV→W x₄) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ←SW1SV→SW1SV→W x₄) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ w x₃) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ w→ x₃) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ →w x₃) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ww→ x₃) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ →ww x₃) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ (x₃ ‘∘’ x₄)) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ (x₃ w‘‘’’ₐ x₄)) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘‘’ₐ’) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ ‘‘□’’ x₃) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ (x₃ ‘‘→’’ x₄)) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ (x₃ ww‘‘‘→’’’ x₄)) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ (x₂ ‘’ₐ x₃ ww‘‘‘×’’’ x₄) = {!!} →SW1SV→SW1SV→W quine→ ‘’ₐₕ SW x₃ = {!!} →SW1SV→SW1SV→W (SW f₂) ‘’ₐₕ x₂ = {!!} →SW1SV→SW1SV→W (←SW1SV→W f₂) ‘’ₐₕ x₂ = {!!} →SW1SV→SW1SV→W (←SW1SV→SW1SV→W f₂) ‘’ₐₕ x₂ = {!!} →SW1SV→SW1SV→W (f₁ ‘∘’ f₂) ‘’ₐₕ x₂ = {!!} ←SW1SV→SW1SV→W (‘λ∙’ f₁) ‘’ₐₕ x₂ = {!!} ←SW1SV→SW1SV→W (f₁ ‘’ₐ f₂) ‘’ₐₕ x₂ = {!!} ←SW1SV→SW1SV→W quine← ‘’ₐₕ x₂ = {!!} -- ←SW1SV→SW1SV→W quine← ‘’ₐ x₂ ←SW1SV→SW1SV→W (SW f₂) ‘’ₐₕ x₂ = {!!} ←SW1SV→SW1SV→W (→SW1SV→W f₂) ‘’ₐₕ x₂ = {!!} ←SW1SV→SW1SV→W (→SW1SV→SW1SV→W f₂) ‘’ₐₕ x₂ = {!!} ←SW1SV→SW1SV→W (f₁ ‘∘’ f₂) ‘’ₐₕ x₂ = {!!} _‘’ₐₕ_ {world = world} (w→ f) x₂ = w→ f ‘’ₐ x₂ _‘’ₐₕ_ {world = world} (ww→ f) x₂ = {!!} _‘’ₐₕ_ {world = world} (f ‘∘’ f₁) x₂ = _‘’ₐₕ_ {world = world} f (_‘’ₐₕ_ {world = world} f₁ x₂) _‘’ₐₕ_ {world = world} ‘‘’ₐ’ x₂ = {!!} ‘‘□’’ₕ : ∀ {Γ A B} → Term {Γ ▻ A ▻ B} (W (W (‘Term’ ‘’ ⌜ ‘Type’ Γ ⌝))) → Term {Γ ▻ A ▻ B} (W (W (‘Type’ Γ))) ‘‘□’’ₕ t = ‘‘□’’ t _‘∘’ₕ_ : ∀ {Γ A B C} {world} (g : Term {Γ} (B ‘→’ C)) (f : Term (A ‘→’ B)) → Term (A ‘→’ C) f ‘∘’ₕ g = f ‘∘’ g-} in-kripke-frame-c : ∀ (world : ℕ) → Context → Context in-kripke-frame : ∀ {Γ} (world : ℕ) → Type Γ → Type (in-kripke-frame-c world Γ) in-kripke-frame-t : ∀ {Γ} (world : ℕ) {T : Type Γ} → Term T → Term (in-kripke-frame world T) in-kripke-frame-c world ε = ε in-kripke-frame-c world (Γ ▻ x) = in-kripke-frame-c world Γ ▻ in-kripke-frame world x _‘’ₐₕ_ : ∀ {Γ A B} → Term {Γ} (A ‘→’ B) → Term {Γ} A → Term {Γ} B (f₁ ‘’ₐ f₂) ‘’ₐₕ x₁ = (f₁ ‘’ₐₕ f₂) ‘’ₐ x₁ →SW1SV→SW1SV→W quine→ ‘’ₐₕ (←SW1SV→SW1SV→W quine← ‘’ₐ f) = f f ‘’ₐₕ x = {!!} in-kripke-frame world (T ‘→’ T₁) = (in-kripke-frame world T) ‘→’ (in-kripke-frame world T₁) in-kripke-frame world (‘Type’ Γ) = ‘Type’ (in-kripke-frame-c world Γ) in-kripke-frame world (W T₁) = W (in-kripke-frame world T₁) in-kripke-frame world (W1 T₂) = W1 (in-kripke-frame world T₂) in-kripke-frame zero (‘Term’ ‘’ x) = ‘⊤’ in-kripke-frame {Γ = Γ} (suc world) (‘Term’ ‘’ (f ‘’ₐ x)) = helper helper' where helper' : Term (in-kripke-frame world (‘Type’ Γ)) helper' = simplify-term (in-kripke-frame-t world f) ‘’ₐₕ simplify-term (in-kripke-frame-t world x) helper : ∀ {Γ} → Term (in-kripke-frame world (‘Type’ Γ)) → Type (in-kripke-frame-c (suc world) Γ) helper x = {!!} in-kripke-frame (suc world) (‘Term’ ‘’ x) = {!in-kripke-frame world x!} in-kripke-frame world (T₁ ‘’ x) = {!!} in-kripke-frame world ‘Term’ = {!!} in-kripke-frame world (T ‘×’ T₁) = {!!} in-kripke-frame world (Quine T) = {!!} in-kripke-frame world ‘⊤’ = ‘⊤’ in-kripke-frame world ‘⊥’ = ‘⊥’ in-kripke-frame-t world ⌜ x ⌝ = ⌜ (in-kripke-frame world x) ⌝ in-kripke-frame-t zero ⌜ t ⌝t = ‘tt’ in-kripke-frame-t (suc world) ⌜ t ⌝t = {!!} in-kripke-frame-t world ‘⌜‘VAR₀’⌝t’ = {!!} in-kripke-frame-t world ‘⌜‘VAR₀’⌝’ = {!!} in-kripke-frame-t world (‘λ∙’ t) = ‘λ∙’ (in-kripke-frame-t world t) in-kripke-frame-t world ‘VAR₀’ = ‘VAR₀’ in-kripke-frame-t world (t ‘’ₐ t₁) = in-kripke-frame-t world t ‘’ₐₕ in-kripke-frame-t world t₁ in-kripke-frame-t world ‘‘×'’’ = {!!} in-kripke-frame-t world quine→ = {!!} in-kripke-frame-t world quine← = {!!} in-kripke-frame-t world ‘tt’ = ‘tt’ in-kripke-frame-t world (SW t₁) = {!!} in-kripke-frame-t world (→SW1SV→W t₁) = {!!} in-kripke-frame-t world (←SW1SV→W t₁) = {!!} in-kripke-frame-t world (→SW1SV→SW1SV→W t₁) = {!!} in-kripke-frame-t world (←SW1SV→SW1SV→W t₁) = {!!} in-kripke-frame-t world (w t) = w (in-kripke-frame-t world t) in-kripke-frame-t world (w→ t) = w→ (in-kripke-frame-t world t) in-kripke-frame-t world (→w t) = →w (in-kripke-frame-t world t) in-kripke-frame-t world (ww→ t) = ww→ (in-kripke-frame-t world t) in-kripke-frame-t world (→ww t) = →ww (in-kripke-frame-t world t) in-kripke-frame-t world (t ‘∘’ t₁) = {!!} in-kripke-frame-t world (t w‘‘’’ₐ t₁) = {!!} in-kripke-frame-t world ‘‘’ₐ’ = {!!} in-kripke-frame-t zero (‘‘□’’ t) = w (w ⌜ ‘⊤’ ⌝) in-kripke-frame-t {Γ = Γ ▻ A ▻ B} (suc world) (‘‘□’’ t) = helper {lzero} (‘‘□’’ₕ (in-kripke-frame-t world t)) where ‘‘□’’ₕ : ∀ {Γ A B} → Term {in-kripke-frame-c world Γ ▻ A ▻ B} (W (W (in-kripke-frame world (‘Term’ ‘’ ⌜ ‘Type’ Γ ⌝)))) → Term {in-kripke-frame-c world Γ ▻ A ▻ B} (W (W (‘Type’ (in-kripke-frame-c world Γ)))) ‘‘□’’ₕ T = {!!} helper : ∀ {ℓ ℓ′} {A : Set ℓ} {B : Set ℓ′} → A → B helper t = {!!} in-kripke-frame-t world (t ‘‘→’’ t₁) = {!!} in-kripke-frame-t world (t ww‘‘‘→’’’ t₁) = {!!} in-kripke-frame-t world (t ww‘‘‘×’’’ t₁) = {!!} {- in-kripke-frame zero ‘Term’ = ‘⊤’ in-kripke-frame {Γ} world (T ‘→’ T₁) = simplify-type (in-kripke-frame world T ‘→’ in-kripke-frame world T₁) in-kripke-frame {Γ} world (T ‘×’ T₁) = simplify-type (in-kripke-frame world T ‘×’ in-kripke-frame world T₁) in-kripke-frame world (W T) = simplify-type (W (in-kripke-frame world T)) in-kripke-frame world (W1 T) = simplify-type (W1 (in-kripke-frame world T)) in-kripke-frame world (T₁ ‘’ x) = simplify-type (helper-ikf world (simplify-type (in-kripke-frame world T₁)) (simplify-term (in-kripke-frame-t world x))) in-kripke-frame world ‘⊤’ = ‘⊤’ in-kripke-frame world ‘⊥’ = ‘⊥’ in-kripke-frame world (‘Type’ Γ) = hold world (‘Type’ Γ) in-kripke-frame world (Quine T) = hold world (Quine T) in-kripke-frame {Γ ▻ .(‘Type’ Γ)} (suc world) ‘Term’ = ‘Term’ {-helper (in-kripke-frame-t world T v) v where helper : ∀ {Γ} → Term (‘Type’ Γ) → context-to-term Γ → Type ε helper ⌜ x ⌝ v = Type-in x v helper (t ‘‘→’’ t₁) v = helper t v ‘→’ helper t₁ v helper (t ‘’ₐ t₁) v = {!!} helper (SW t₁) v = {!!}-} in-kripke-frame-t : ∀ {Γ} (world : ℕ) → {T : Type Γ} → Term T → Term (in-kripke-frame world T) in-kripke-frame-t world ⌜ x ⌝ = ⌜ in-kripke-frame world x ⌝ in-kripke-frame-t world ⌜ x ⌝t = ⌜ in-kripke-frame-t world x ⌝t in-kripke-frame-t world ‘⌜‘VAR₀’⌝t’ = ‘⌜‘VAR₀’⌝t’ in-kripke-frame-t world ‘⌜‘VAR₀’⌝’ = ‘⌜‘VAR₀’⌝’ in-kripke-frame-t world (‘λ∙’ x) = ‘λ∙’ (in-kripke-frame-t world x) in-kripke-frame-t world ‘VAR₀’ = ‘VAR₀’ in-kripke-frame-t world (x ‘’ₐ x₁) = _‘’ₐₕ_ {world = world} (simplify-term (in-kripke-frame-t world x)) (simplify-term (in-kripke-frame-t world x₁)) in-kripke-frame-t world ‘‘×'’’ = ‘‘×'’’ in-kripke-frame-t world quine→ = quine→ in-kripke-frame-t world quine← = quine← in-kripke-frame-t world ‘tt’ = ‘tt’ in-kripke-frame-t world (SW x₁) = SW (in-kripke-frame-t world x₁) in-kripke-frame-t world (→SW1SV→W x₁) = →SW1SV→W (in-kripke-frame-t world x₁) in-kripke-frame-t world (←SW1SV→W x₁) = ←SW1SV→W (in-kripke-frame-t world x₁) in-kripke-frame-t world (→SW1SV→SW1SV→W x₁) = →SW1SV→SW1SV→W (in-kripke-frame-t world x₁) in-kripke-frame-t world (←SW1SV→SW1SV→W x₁) = ←SW1SV→SW1SV→W (in-kripke-frame-t world x₁) in-kripke-frame-t world (w x) = w (in-kripke-frame-t world x) in-kripke-frame-t world (w→ x) = w→ (in-kripke-frame-t world x) in-kripke-frame-t world (→w x) = →w (in-kripke-frame-t world x) in-kripke-frame-t world (ww→ x) = ww→ (in-kripke-frame-t world x) in-kripke-frame-t world (→ww x) = →ww (in-kripke-frame-t world x) in-kripke-frame-t world (x ‘∘’ x₁) = _‘∘’ₕ_ {world = world} (simplify-term (in-kripke-frame-t world x)) (simplify-term (in-kripke-frame-t world x₁)) in-kripke-frame-t world (x w‘‘’’ₐ x₁) = simplify-term (in-kripke-frame-t world x) w‘‘’’ₐ simplify-term (in-kripke-frame-t world x₁) in-kripke-frame-t world ‘‘’ₐ’ = ‘‘’ₐ’ in-kripke-frame-t zero (‘‘□’’ x) = w (w ⌜ ‘⊤’ ⌝) in-kripke-frame-t (suc world) (‘‘□’’ x) = ‘‘□’’ₕ (simplify-term (in-kripke-frame-t world x)) in-kripke-frame-t world (x ‘‘→’’ x₁) = {!!} in-kripke-frame-t world (x ww‘‘‘→’’’ x₁) = {!!} in-kripke-frame-t world (x ww‘‘‘×’’’ x₁) = {!!} -} kripke-reduce : ∀ {Γ} → Type Γ → context-to-term Γ → Type ε kripke-reduce (W x₁) v = kripke-reduce x₁ (Σ.proj₁ v) kripke-reduce (W1 x₂) v = kripke-reduce x₂ ((Σ.proj₁ (Σ.proj₁ v)) , (‘λ∙’ (Σ.proj₂ v) ‘’ₐ Σ.proj₂ (Σ.proj₁ v))) kripke-reduce (T₁ ‘’ x) v = kripke-reduce T₁ (v , x) kripke-reduce (‘Type’ Γ) v = Type-in (‘Type’ Γ) v -- kripke-reduce ‘TVAR₀’ v = {!!} kripke-reduce ‘Term’ (v , T) = {!!} {- Type-in (lower (Term⇓ (Σ.proj₂ v) (context-to-term⇓ (Σ.proj₁ v)))) (Σ.proj₁ v) -} kripke-reduce (T ‘→’ T₁) v = kripke-reduce T v ‘→’ kripke-reduce T₁ v kripke-reduce (T ‘×’ T₁) v = kripke-reduce T v ‘×’ kripke-reduce T₁ v kripke-reduce (Quine x) v = {!!} kripke-reduce ‘⊤’ v = ‘⊤’ kripke-reduce ‘⊥’ v = ‘⊥’ kripke-eval' : ∀ {Γ} → ℕ → Type Γ → context-to-term Γ → Type ε kripke-eval' 0 T v = Type-in T v kripke-eval' (suc n) T v = kripke-eval' n (kripke-reduce T v) tt kripke-finalize : ∀ {Γ} → Type Γ → context-to-term Γ → Type ε kripke-finalize (W x₁) v = kripke-finalize x₁ (Σ.proj₁ v) kripke-finalize (W1 x₂) v = kripke-finalize x₂ ((Σ.proj₁ (Σ.proj₁ v)) , (‘λ∙’ (Σ.proj₂ v) ‘’ₐ Σ.proj₂ (Σ.proj₁ v))) kripke-finalize (T₁ ‘’ x) v = kripke-finalize T₁ (v , x) kripke-finalize (‘Type’ Γ) v = Type-in (‘Type’ Γ) v -- kripke-finalize ‘TVAR₀’ v = {!!} kripke-finalize ‘Term’ v = ‘⊤’ kripke-finalize (T ‘→’ T₁) v = kripke-finalize T v ‘→’ kripke-finalize T₁ v kripke-finalize (T ‘×’ T₁) v = kripke-finalize T v ‘×’ kripke-finalize T₁ v kripke-finalize (Quine x) v = {!!} kripke-finalize ‘⊤’ v = ‘⊤’ kripke-finalize ‘⊥’ v = ‘⊥’ mutual kripke-count : ∀ {Γ} → Type Γ → ℕ kripke-count (W T₁) = kripke-count T₁ kripke-count (W1 T₂) = kripke-count T₂ kripke-count (T₁ ‘’ x) = kripke-count T₁ + kripke-count-t x kripke-count (‘Type’ Γ) = 0 -- kripke-count ‘TVAR₀’ = 0 kripke-count ‘Term’ = 1 kripke-count (T ‘→’ T₁) = kripke-count T + kripke-count T₁ kripke-count (T ‘×’ T₁) = kripke-count T + kripke-count T₁ kripke-count (Quine T) = kripke-count T kripke-count ‘⊤’ = 0 kripke-count ‘⊥’ = 0 kripke-count-t : ∀ {Γ T} → Term {Γ} T → ℕ kripke-count-t ⌜ x ⌝ = kripke-count x kripke-count-t (x ‘’ₐ x₁) = kripke-count-t x + kripke-count-t x₁ kripke-count-t ⌜ x ⌝t = kripke-count-t x kripke-count-t ‘⌜‘VAR₀’⌝t’ = 0 kripke-count-t ‘⌜‘VAR₀’⌝’ = 0 kripke-count-t (‘λ∙’ x) = kripke-count-t x kripke-count-t ‘VAR₀’ = 0 kripke-count-t quine→ = 0 kripke-count-t quine← = 0 kripke-count-t ‘tt’ = 0 kripke-count-t (SW x₁) = kripke-count-t x₁ kripke-count-t (→SW1SV→W x₁) = kripke-count-t x₁ kripke-count-t (←SW1SV→W x₁) = kripke-count-t x₁ kripke-count-t (→SW1SV→SW1SV→W x₁) = kripke-count-t x₁ kripke-count-t (←SW1SV→SW1SV→W x₁) = kripke-count-t x₁ kripke-count-t (w x) = kripke-count-t x kripke-count-t (w→ x) = kripke-count-t x kripke-count-t (→w x) = kripke-count-t x kripke-count-t (ww→ x) = kripke-count-t x kripke-count-t (→ww x) = kripke-count-t x kripke-count-t ‘‘×'’’ = 0 kripke-count-t (x ‘∘’ x₁) = kripke-count-t x + kripke-count-t x₁ kripke-count-t (x w‘‘’’ₐ x₁) = kripke-count-t x + kripke-count-t x₁ kripke-count-t ‘‘’ₐ’ = 0 -- kripke-count-t (f w‘‘’’ x) = kripke-count-t f + kripke-count-t x kripke-count-t (‘‘□’’ T) = 1 + kripke-count-t T kripke-count-t (x ‘‘→’’ x₁) = kripke-count-t x + kripke-count-t x₁ kripke-count-t (x ww‘‘‘→’’’ x₁) = kripke-count-t x + kripke-count-t x₁ kripke-count-t (x ww‘‘‘×’’’ x₁) = kripke-count-t x + kripke-count-t x₁ kripke-normalize' : ∀ {Γ} → Type Γ → context-to-term Γ → Type ε kripke-normalize' T v = kripke-eval' (kripke-count T) T v kripke-normalize'' : ∀ {Γ} → (T : Type Γ) → Type (in-kripke-frame-c (kripke-count T) Γ) kripke-normalize'' T = in-kripke-frame (kripke-count T) T open modal-fixpoint ‘Bot’ : ∀ {Γ} → Type Γ ‘Bot’ {Γ} = Quine (W1 ‘Term’ ‘’ ‘VAR₀’ ‘→’ W1 ‘Term’ ‘’ ‘VAR₀’ ‘→’ W (‘Type’ Γ)) {- a bot takes in the source code for itself, for another bot, and spits out the assertion that it cooperates with this bot -} _cooperates-with_ : □ ‘Bot’ → □ ‘Bot’ → Type ε b1 cooperates-with b2 = lower (Term⇓ b1 tt (lift b1) (lift b2)) ‘eval-bot'’ : ∀ {Γ} → Term {Γ} (‘Bot’ ‘→’ (‘□’ ‘Bot’ ‘→’ ‘□’ ‘Bot’ ‘→’ ‘Type’ Γ)) ‘eval-bot'’ = →SW1SV→SW1SV→W quine→ ‘‘eval-bot'’’ : ∀ {Γ} → Term {Γ} (‘□’ ‘Bot’ ‘→’ ‘□’ ({- other -} ‘□’ ‘Bot’ ‘→’ ‘Type’ Γ)) ‘‘eval-bot'’’ = ‘λ∙’ (w ⌜ ‘eval-bot'’ ⌝t w‘‘’’ₐ ‘VAR₀’ w‘‘’’ₐ ‘⌜‘VAR₀’⌝t’) ‘other-cooperates-with’ : ∀ {Γ} → Term {Γ ▻ ‘□’ ‘Bot’ ▻ W (‘□’ ‘Bot’)} (W (W (‘□’ ‘Bot’)) ‘→’ W (W (‘□’ (‘Type’ Γ)))) ‘other-cooperates-with’ {Γ} = ‘eval-other'’ ‘∘’ w→ (w (w→ (w (‘λ∙’ ‘⌜‘VAR₀’⌝t’)))) where ‘eval-other’ : Term {Γ ▻ ‘□’ ‘Bot’ ▻ W (‘□’ ‘Bot’)} (W (W (‘□’ (‘□’ ‘Bot’ ‘→’ ‘Type’ Γ)))) ‘eval-other’ = w→ (w (w→ (w ‘‘eval-bot'’’))) ‘’ₐ ‘VAR₀’ ‘eval-other'’ : Term (W (W (‘□’ (‘□’ ‘Bot’))) ‘→’ W (W (‘□’ (‘Type’ Γ)))) ‘eval-other'’ = ww→ (w→ (w (w→ (w ‘‘’ₐ’))) ‘’ₐ ‘eval-other’) ‘self’ : ∀ {Γ} → Term {Γ ▻ ‘□’ ‘Bot’ ▻ W (‘□’ ‘Bot’)} (W (W (‘□’ ‘Bot’))) ‘self’ = w ‘VAR₀’ ‘other’ : ∀ {Γ} → Term {Γ ▻ ‘□’ ‘Bot’ ▻ W (‘□’ ‘Bot’)} (W (W (‘□’ ‘Bot’))) ‘other’ = ‘VAR₀’ make-bot : ∀ {Γ} → Term {Γ ▻ ‘□’ ‘Bot’ ▻ W (‘□’ ‘Bot’)} (W (W (‘Type’ Γ))) → Term {Γ} ‘Bot’ make-bot t = ←SW1SV→SW1SV→W quine← ‘’ₐ ‘λ∙’ (→w (‘λ∙’ t)) ww‘‘‘¬’’’_ : ∀ {Γ A B} → Term {Γ ▻ A ▻ B} (W (W (‘□’ (‘Type’ Γ)))) → Term {Γ ▻ A ▻ B} (W (W (‘□’ (‘Type’ Γ)))) ww‘‘‘¬’’’ T = T ww‘‘‘→’’’ w (w ⌜ ⌜ ‘⊥’ ⌝ ⌝t) ‘DefectBot’ : □ ‘Bot’ ‘CooperateBot’ : □ ‘Bot’ ‘FairBot’ : □ ‘Bot’ ‘PrudentBot’ : □ ‘Bot’ ‘DefectBot’ = make-bot (w (w ⌜ ‘⊥’ ⌝)) ‘CooperateBot’ = make-bot (w (w ⌜ ‘⊤’ ⌝)) ‘FairBot’ = make-bot (‘‘□’’ (‘other-cooperates-with’ ‘’ₐ ‘self’)) ‘PrudentBot’ = make-bot (‘‘□’’ (φ₀ ww‘‘‘×’’’ (¬□⊥ ww‘‘‘→’’’ other-defects-against-DefectBot))) where φ₀ : ∀ {Γ} → Term {Γ ▻ ‘□’ ‘Bot’ ▻ W (‘□’ ‘Bot’)} (W (W (‘□’ (‘Type’ Γ)))) φ₀ = ‘other-cooperates-with’ ‘’ₐ ‘self’ other-defects-against-DefectBot : Term {_ ▻ ‘□’ ‘Bot’ ▻ W (‘□’ ‘Bot’)} (W (W (‘□’ (‘Type’ _)))) other-defects-against-DefectBot = ww‘‘‘¬’’’ (‘other-cooperates-with’ ‘’ₐ w (w ⌜ ‘DefectBot’ ⌝t)) ¬□⊥ : ∀ {Γ A B} → Term {Γ ▻ A ▻ B} (W (W (‘□’ (‘Type’ Γ)))) ¬□⊥ = w (w ⌜ ⌜ ‘¬’ (‘□’ ‘⊥’) ⌝ ⌝t) data KnownBot : Set where DefectBot : KnownBot CooperateBot : KnownBot FairBot : KnownBot PrudentBot : KnownBot KnownBot⇓ : KnownBot → □ ‘Bot’ KnownBot⇓ DefectBot = ‘DefectBot’ KnownBot⇓ CooperateBot = ‘CooperateBot’ KnownBot⇓ FairBot = ‘FairBot’ KnownBot⇓ PrudentBot = ‘PrudentBot’ DB-defects : ∀ {b} → □ (‘¬’ (‘DefectBot’ cooperates-with b)) CB-cooperates : ∀ {b} → □ (‘CooperateBot’ cooperates-with b) FB-spec : KnownBot → □ ‘Bot’ → Type ε FB-spec DefectBot b = ‘¬’ (‘FairBot’ cooperates-with b) FB-spec CooperateBot b = ‘FairBot’ cooperates-with b FB-spec FairBot b = ‘FairBot’ cooperates-with b FB-spec PrudentBot b = ‘FairBot’ cooperates-with b FB-good : ∀ {b} → □ (FB-spec b (KnownBot⇓ b)) DB-defects {b} = ‘λ∙’ ‘VAR₀’ CB-cooperates {b} = ‘tt’ FB-good {DefectBot} = {!!} FB-good {CooperateBot} = {!!} FB-good {FairBot} = {!!} FB-good {PrudentBot} = {!!} {- data Bot : Set where DefectBot : Bot CooperateBot : Bot FairBot : Bot PrudentBot : Bot data Opponent : Set where Self : Opponent Other : Type ε → Opponent _cooperates-with-me : ∀ {Γ} → Term {Γ} (‘Term’ ‘’ ⌜ ‘Type’ Γ ⌝ ‘→’ ‘Type’ Γ) → Term {Γ ▻ ‘Type’ Γ} (W ‘Type’ Γ) x cooperates-with-me = w→ (w x) ‘’ₐ ‘⌜‘VAR₀’⌝’ {- ‘cooperates-with'’ : □ (‘Bot’ ‘→’ ‘Bot’ ‘→’ ‘Type’ Γ) ‘cooperates-with'’ = ‘λ∙’ (→w ((‘eval-bot’ ‘VAR₀’) ‘∘’ (w→ (w {!!})))) where ‘eval-bot'’ : Term (‘Bot’ ‘→’ (‘□’ ‘Bot’ ‘→’ ‘Type’ Γ)) ‘eval-bot'’ = →SW1SV→W quine→ ‘eval-bot’_ : Term {ε ▻ ‘Bot’} (W ‘Bot’) → Term (W (‘□’ ‘Bot’) ‘→’ W ‘Type’ Γ) ‘eval-bot’ b = w→ (w→ (w ‘eval-bot'’) ‘’ₐ b) get-bot-source : Term {ε} (‘Bot’ ‘→’ ‘□’ ‘Bot’) get-bot-source = {!!}-} _‘cooperates’ : Bot → Term {ε} (‘Term’ ‘’ ⌜ ‘Type’ Γ ⌝ ‘→’ ‘Type’ Γ) DefectBot ‘cooperates’ = ‘λ∙’ (w ⌜ ‘⊥’ ⌝) CooperateBot ‘cooperates’ = ‘λ∙’ (w ⌜ ‘⊤’ ⌝) FairBot ‘cooperates’ = ‘λ∙’ {!!} PrudentBot ‘cooperates’ = {!!} _‘cooperates-with'’_ : Bot → Term {ε} (‘Term’ ‘’ ⌜ ‘Type’ Γ ⌝ ‘→’ ‘Type’ Γ) → Type ε FairBot ‘cooperates-with'’ x = Quine (W1 ‘Term’ ‘’ (x cooperates-with-me)) DefectBot ‘cooperates-with'’ b2 = ‘⊥’ CooperateBot ‘cooperates-with'’ b2 = ‘⊤’ PrudentBot ‘cooperates-with'’ x = Quine (W1 ‘Term’ ‘’ (x cooperates-with-me w‘‘×’’ w ⌜ (‘¬’ (‘Term’ ‘’ ⌜ ‘⊥’ ⌝) ‘→’ ‘¬’ {!!}) ⌝)) -} {- box-free? : ∀ {Γ} → Type Γ → context-to-term Γ → Set box-free? (T₁ ‘’ x) v = box-free? T₁ (v , x) box-free? ‘Type’ Γ v = ⊤ box-free? ‘Term’ v = ⊥ box-free? (T ‘→’ T₁) v = box-free? T v × box-free? T₁ v box-free? ‘⊤’ v = ⊤ box-free? ‘⊥’ v = ⊤ mutual kripke-lift→ : ∀ (n : ℕ) (T : Type ε) → box-free? (kripke-eval' n T) tt → Term (kripke-eval' n T ‘→’ T) kripke-lift→ zero T H = ‘λx∙x’ kripke-lift→ (suc n) (T₁ ‘’ x) H = {!!} kripke-lift→ (suc n) (T ‘→’ T₁) H = {!!} ‘∘’ (kripke-lift→ n (kripke-reduce (T ‘→’ T₁) tt) H) kripke-lift→ (suc n) ‘Type’ Γ H = kripke-lift→ n _ H kripke-lift→ (suc n) ‘⊤’ H = kripke-lift→ n _ H kripke-lift→ (suc n) ‘⊥’ H = kripke-lift→ n _ H kripke-lift← : ∀ (n : ℕ) (T : Type ε) → box-free? (kripke-eval' n T) tt → Term (kripke-eval' n T) → Term T kripke-lift← n T H t = {!!} {- kripke-lift : ∀ {Γ} (T : Type Γ) v → Term (kripke-reduce T v ‘→’ Type-in T v) kripke-lift (T₁ ‘’ x) = {!!} kripke-lift ‘Type’ Γ v = {!!} kripke-lift ‘Term’ v = {!!} kripke-lift {ε} (T ‘→’ T₁) v = {!!} kripke-lift {Γ ▻ x} (T ‘→’ T₁) v = {!!} kripke-lift ‘⊤’ v = {!!} kripke-lift ‘⊥’ v = {!!}-} Quine : Type (ε ▻ ‘Type’ Γ) → Type ε Quine φ = {!!} quine→ : ∀ {φ} → Term {ε} (Quine φ ‘→’ φ ‘’ ⌜ Quine φ ⌝) quine← : ∀ {φ} → Term {ε} (φ ‘’ ⌜ Quine φ ⌝ ‘→’ Quine φ) quine→ = {!!} quine← = {!!} -}
{ "alphanum_fraction": 0.4656734541, "avg_line_length": 47.3716814159, "ext": "agda", "hexsha": "3bce46db14d7e4905f5e1244dc7e3643ab20ab78", "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/kripke.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/kripke.agda", "max_line_length": 218, "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/kripke.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": 23765, "size": 42824 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Which Maybe type which calls out to Haskell via the FFI ------------------------------------------------------------------------ {-# OPTIONS --without-K #-} module Foreign.Haskell.Maybe where open import Level open import Data.Maybe.Base as Data using (just; nothing) private variable a : Level A : Set a ------------------------------------------------------------------------ -- Definition data Maybe (A : Set a) : Set a where just : A → Maybe A nothing : Maybe A {-# FOREIGN GHC type AgdaMaybe l a = Maybe a #-} {-# COMPILE GHC Maybe = data AgdaMaybe (Just | Nothing) #-} ------------------------------------------------------------------------ -- Conversion toForeign : Data.Maybe A → Maybe A toForeign (just x) = just x toForeign nothing = nothing fromForeign : Maybe A → Data.Maybe A fromForeign (just x) = just x fromForeign nothing = nothing
{ "alphanum_fraction": 0.4822335025, "avg_line_length": 25.2564102564, "ext": "agda", "hexsha": "e09ea311eb2257e5c5a22f0f080b774f4c55cace", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Foreign/Haskell/Maybe.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Foreign/Haskell/Maybe.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Foreign/Haskell/Maybe.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 191, "size": 985 }
-- Andreas, 2017-01-18, issue #5 is fixed -- reported by Ulf 2007-10-24 data Nat : Set where zero : Nat data Vec : Nat -> Set where [] : Vec zero f : (n : Nat) -> Vec n -> Nat f n@._ [] = n
{ "alphanum_fraction": 0.5628140704, "avg_line_length": 16.5833333333, "ext": "agda", "hexsha": "ab58d60b47fd57d45645ac17b6053b47f6c9f828", "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/Issue5.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/Issue5.agda", "max_line_length": 41, "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/Issue5.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": 77, "size": 199 }
{-# OPTIONS --without-K #-} module function.extensionality.core where open import level using (lsuc; _⊔_) open import equality.core Extensionality : ∀ i j → Set (lsuc (i ⊔ j)) Extensionality i j = {X : Set i}{Y : Set j} → {f g : X → Y} → ((x : X) → f x ≡ g x) → f ≡ g Extensionality' : ∀ i j → Set (lsuc (i ⊔ j)) Extensionality' i j = {X : Set i}{Y : X → Set j} → {f g : (x : X) → Y x} → ((x : X) → f x ≡ g x) → f ≡ g StrongExt : ∀ i j → Set (lsuc (i ⊔ j)) StrongExt i j = {X : Set i}{Y : X → Set j} → {f g : (x : X) → Y x} → (∀ x → f x ≡ g x) ≡ (f ≡ g) funext-inv : ∀ {i j}{X : Set i}{Y : X → Set j} → {f g : (x : X) → Y x} → f ≡ g → (x : X) → f x ≡ g x funext-inv refl x = refl
{ "alphanum_fraction": 0.3957845433, "avg_line_length": 29.4482758621, "ext": "agda", "hexsha": "a12bd13d60a5db10678b774d4f2d2349e216f95f", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z", "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "HoTT/M-types", "max_forks_repo_path": "function/extensionality/core.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/function/extensionality/core.agda", "max_line_length": 48, "max_stars_count": 27, "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_path": "function/extensionality/core.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "num_tokens": 307, "size": 854 }
-- This file gives the definition of Gaussian Integers, and common -- operations on them. {-# OPTIONS --without-K --safe #-} module GauInt.Base where open import Data.Bool using (Bool ; true ; false ; T ; not ; _∧_) open import Data.Nat using (ℕ ; _≡ᵇ_) open import Data.Integer renaming (-_ to -ℤ_ ; _-_ to _-ℤ_ ; _+_ to _+ℤ_ ; _*_ to _*ℤ_ ) hiding (NonZero) infix 4 _==_ -- boolean equality on 𝔾. infix 4 _==ℤ_ -- boolean equality on ℤ. infixl 6 _+_ _-_ infixl 7 _*_ infix 8 -_ infixl 9 _ᶜ -- conjugation on 𝔾. -- A Gaussian integer is a pair of integers. infix 5 _+_i data 𝔾 : Set where _+_i : ℤ -> ℤ -> 𝔾 -- Addition. _+_ : 𝔾 -> 𝔾 -> 𝔾 (a + b i) + (c + d i) = x + y i where x = a +ℤ c y = b +ℤ d -- Additive identity. 0𝔾 : 𝔾 0𝔾 = 0ℤ + 0ℤ i -- Additive inverse. -_ : 𝔾 -> 𝔾 - (a + b i) = (-ℤ a) + (-ℤ b) i -- Subtraction. _-_ : 𝔾 -> 𝔾 -> 𝔾 _-_ x y = x + (- y) -- Multiplication. _*_ : 𝔾 -> 𝔾 -> 𝔾 (a + b i) * (c + d i) = x + y i where x = a *ℤ c -ℤ b *ℤ d y = (a *ℤ d) +ℤ b *ℤ c -- Multiplicative identity. 1𝔾 : 𝔾 1𝔾 = 1ℤ + 0ℤ i -- imaginary unit i. iG : 𝔾 iG = 0ℤ + 1ℤ i -- Real and imaginary part. Re : 𝔾 -> ℤ Re (a + b i) = a Im : 𝔾 -> ℤ Im (a + b i) = b -- Conjugation of complex numbers retricted to Gaussian integers. _ᶜ : 𝔾 -> 𝔾 _ᶜ (a + b i) = a + (-ℤ b) i -- Rank. rank : 𝔾 -> ℕ rank (a + b i) = ∣ a *ℤ a +ℤ b *ℤ b ∣ -- Boolean equality on ℤ. _==ℤ_ : ℤ -> ℤ -> Bool +_ n ==ℤ +_ m = n ≡ᵇ m +_ n ==ℤ -[1+_] n₁ = false -[1+_] n ==ℤ +_ n₁ = false -[1+_] n ==ℤ -[1+_] m = n ≡ᵇ m -- Boolean equality on 𝔾. _==_ : 𝔾 -> 𝔾 -> Bool a + b i == c + d i = (a ==ℤ c) ∧ (b ==ℤ d) -- NonZero predicate. Intended to use as implicit argument to deal -- with the zero divisor case. record NonZero (x : 𝔾) : Set where field nonZero : T (not ( x == 0𝔾)) -- ---------------------------------------------------------------------- -- Injections -- I don't have good notation for this. infix 5 _+0i' _+0i' : ℤ -> 𝔾 _+0i' n = n + 0ℤ i -- Injection of naturals are used more often. infix 5 _+0i _+0i : ℕ -> 𝔾 _+0i n = + n +0i'
{ "alphanum_fraction": 0.5300387597, "avg_line_length": 19.8461538462, "ext": "agda", "hexsha": "bde8de6dc5d11fe75c6a92303bd44f818e89012c", "lang": "Agda", "max_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": "GauInt/Base.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": "GauInt/Base.agda", "max_line_length": 105, "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": "GauInt/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 932, "size": 2064 }
module Category.Instance where open import Level open import Category.Core 𝟙 : Category _ _ 𝟙 = record { Objects = record { Carrier = ⊤ ; _≈_ = λ _ _ → ⊤ ; isEquivalence = _ } ; Morphisms = record { Carrier = λ x → ⊤ ; _≈_ = λ _ _ → ⊤ ; isEquivalence = _ ; _∘_ = λ _ _ → tt ; id = λ a → tt ; isMorphism = _ } } where open import Data.Unit -- "pointing" an element with a functor from 𝟙 point : ∀ {𝒸 ℓ} → {C : Category 𝒸 ℓ} → Category.Object C → Functor 𝟙 C point {_} {_} {C} c = record { mapObject = λ _ → c ; mapMorphism = λ _ → id c ; isFunctor = record { preserve-id = λ a → MorphEq.refl ; preserve-∘ = λ _ _ → MorphEq.sym (left-identity (id c)) } } where open Category C open import Relation.Binary.Indexed module MorphEq = IsEquivalence (MorphismStructure.isEquivalence Morphisms) open IsMorphism isMorphism -- the identity functo identity : ∀ {𝒸 ℓ} → (C : Category 𝒸 ℓ) → Functor C C identity C = record { mapObject = λ x → x ; mapMorphism = λ x → x ; isFunctor = record { preserve-id = λ a → MorphEq.refl ; preserve-∘ = λ f g → MorphEq.refl } } where open Category C open import Relation.Binary.Indexed module MorphEq = IsEquivalence (MorphismStructure.isEquivalence Morphisms) open IsMorphism isMorphism
{ "alphanum_fraction": 0.5587044534, "avg_line_length": 25.5517241379, "ext": "agda", "hexsha": "b540b772a3eea129c949c04eb4056a1deac317a4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9f6d933b227aecab338ecaef1d86566a54fdac68", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/categories", "max_forks_repo_path": "src/Category/Instance.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9f6d933b227aecab338ecaef1d86566a54fdac68", "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/categories", "max_issues_repo_path": "src/Category/Instance.agda", "max_line_length": 82, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9f6d933b227aecab338ecaef1d86566a54fdac68", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/categories", "max_stars_repo_path": "src/Category/Instance.agda", "max_stars_repo_stars_event_max_datetime": "2018-01-04T23:19:30.000Z", "max_stars_repo_stars_event_min_datetime": "2018-01-04T23:19:30.000Z", "num_tokens": 458, "size": 1482 }
{-# OPTIONS --enable-prop #-} data TestProp : Prop where p₁ p₂ : TestProp data _≡Prop_ {A : Prop} (x : A) : A → Set where refl : x ≡Prop x p₁≢p₂ : {P : Prop} → p₁ ≡Prop p₂ → P p₁≢p₂ ()
{ "alphanum_fraction": 0.5625, "avg_line_length": 17.4545454545, "ext": "agda", "hexsha": "2a8271d587cec1e61cbfc057aa625bcdb07f3adf", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "asr/eagda", "max_forks_repo_path": "test/Fail/Prop-NoDisjointConstructors.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "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": "asr/eagda", "max_issues_repo_path": "test/Fail/Prop-NoDisjointConstructors.agda", "max_line_length": 47, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "asr/eagda", "max_stars_repo_path": "test/Fail/Prop-NoDisjointConstructors.agda", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "num_tokens": 83, "size": 192 }
------------------------------------------------------------------------ -- Up-to techniques for the standard coinductive definition of weak -- bisimilarity ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} open import Labelled-transition-system module Bisimilarity.Weak.Up-to {ℓ} (lts : LTS ℓ) where open import Logical-equivalence using (_⇔_) open import Prelude open import Prelude.Size open import Bisimilarity.Weak lts import Bisimilarity.Weak.Equational-reasoning-instances open import Equational-reasoning open import Expansion lts as E using (Expansion; _≲_; ≳:_) import Expansion.Equational-reasoning-instances open import Indexed-container open import Relation import Similarity.Weak lts as S import Up-to open LTS lts import Similarity.Step lts _[_]⇒̂_ as SS ------------------------------------------------------------------------ -- The general up-to machinery, instantiated with the StepC container open Up-to StepC public ------------------------------------------------------------------------ -- Up to expansion -- Up to expansion. -- -- I took this definition from "Enhancements of the bisimulation proof -- method" by Pous and Sangiorgi. Up-to-expansion : Trans₂ ℓ Proc Up-to-expansion R = Expansion ∞ ⊙ R ⊙ Expansion ∞ ⁻¹ -- Up to expansion is monotone. up-to-expansion-monotone : Monotone Up-to-expansion up-to-expansion-monotone R⊆S = Σ-map id (Σ-map id (Σ-map id (Σ-map R⊆S id))) -- Up to expansion is size-preserving. up-to-expansion-size-preserving : Size-preserving Up-to-expansion up-to-expansion-size-preserving = _⇔_.from (monotone→⇔ up-to-expansion-monotone) (λ where {x = p , q} (r , p≳r , s , r≈s , s≲q) → p ∼⟨ p≳r ⟩ r ∼′⟨ r≈s ⟩ ≳: s ∽⟨ s≲q ⟩■ q) ------------------------------------------------------------------------ -- A generalisation of up to expansion mutual -- A monolithic implementation of a non-symmetric variant of up to -- expansion, based on the technique presented in Section 6.5.2.4 of -- "Enhancements of the bisimulation proof method" by Pous and -- Sangiorgi. -- -- It is at the time of writing not clear to me if there is some -- size-preserving proof that matches this technique. 6-5-2-4 : {R : Rel₂ ℓ Proc} → (∀ {P P′ Q μ} → R (P , Q) → P [ μ ]⟶ P′ → ∃ λ Q′ → Q [ μ ]⇒̂ Q′ × (Expansion ∞ ⊙ R ⊙ Weak-bisimilarity ∞) (P′ , Q′)) → (∀ {P Q Q′ μ} → R (P , Q) → Q [ μ ]⟶ Q′ → ∃ λ P′ → P [ μ ]⇒̂ P′ × (Weak-bisimilarity ∞ ⊙ R ⊙ Expansion ∞ ⁻¹) (P′ , Q′)) → R ⊆ Weak-bisimilarity ∞ 6-5-2-4 {R} lr⟶ rl⟶ = 6-5-2-4′ (λ PRQ → S.⟨ lr⟶ PRQ ⟩) (λ PR⁻¹Q → S.⟨ Σ-map id (Σ-map id lemma) ∘ rl⟶ PR⁻¹Q ⟩) where lemma : Weak-bisimilarity ∞ ⊙ R ⊙ Expansion ∞ ⁻¹ ⊆ (Expansion ∞ ⊙ R ⁻¹ ⊙ Weak-bisimilarity ∞) ⁻¹ lemma (_ , P₁≈P₂ , _ , P₂RP₃ , P₃≲P₄) = (_ , P₃≲P₄ , _ , P₂RP₃ , symmetric P₁≈P₂) -- A variant of 6-5-2-4. 6-5-2-4′ : let Prog = λ (R : Rel₂ ℓ Proc) → R ⊆ ⟦ S.StepC ⟧ (Expansion ∞ ⊙ R ⊙ Weak-bisimilarity ∞) in ∀ {R} → Prog R → Prog (R ⁻¹) → R ⊆ Weak-bisimilarity ∞ 6-5-2-4′ {R} lr⟶ rl⟶ = R ⊆⟨ ⊆≈≈ ⟩ ≈ R ≈ ⊆⟨ unfold _ (λ P≈R≈Q → StepC.⟨ SS.Step.challenge (lemma lr⟶ P≈R≈Q) , Σ-map id (Σ-map id ≈≈-sym) ∘ SS.Step.challenge (lemma rl⟶ (≈≈-sym P≈R≈Q)) ⟩) ⟩∎ Weak-bisimilarity ∞ ∎ where ≈_≈ : Rel₂ ℓ Proc → Rel₂ ℓ Proc ≈ R ≈ = Weak-bisimilarity ∞ ⊙ R ⊙ Weak-bisimilarity ∞ ⊆≈≈ : ∀ {R} → R ⊆ ≈ R ≈ ⊆≈≈ r = _ , reflexive , _ , r , reflexive ≳_≈ : Rel₂ ℓ Proc → Rel₂ ℓ Proc ≳ R ≈ = Expansion ∞ ⊙ R ⊙ Weak-bisimilarity ∞ ⊆≳≈ : ∀ {R} → R ⊆ ≳ R ≈ ⊆≳≈ r = _ , reflexive , _ , r , reflexive ≈≈-sym : ∀ {R} → ≈ R ≈ ⊆ ≈ R ⁻¹ ≈ ⁻¹ ≈≈-sym (_ , P₁≈P₂ , _ , P₂RP₃ , P₃≈P₄) = (_ , symmetric P₃≈P₄ , _ , P₂RP₃ , symmetric P₁≈P₂) lemma : ∀ {R} → R ⊆ ⟦ S.StepC ⟧ ≳ R ≈ → ≈ R ≈ ⊆ SS.Step ≈ R ≈ lemma {R} lr⟶ = λ where (P₁ , P≈P₁ , Q₁ , P₁RQ₁ , Q₁≈Q) .SS.Step.challenge P⟶P₁ → let P₁′ , P₁⟶̂P₁′ , P′≈′P₁′ = left-to-right P≈P₁ P⟶P₁ Q₁′ , Q₁⇒̂Q₁′ , P₁″ , P₁′≳P₁″ , Q₁″ , P₁″RQ₁″ , Q₁″≈Q₁′ = lr≳≈⇒̂ (⊆≳≈ P₁RQ₁) P₁⟶̂P₁′ Q′ , Q⇒̂Q′ , Q₁′≈Q′ = weak-is-weak⇒̂ Q₁≈Q Q₁⇒̂Q₁′ in Q′ , Q⇒̂Q′ , P₁″ , transitive′ {a = ℓ} (force P′≈′P₁′) P₁′≳P₁″ , Q₁″ , P₁″RQ₁″ , transitive {a = ℓ} Q₁″≈Q₁′ Q₁′≈Q′ where lr⟶̂ : ∀ {P P′ Q μ} → R (P , Q) → P [ μ ]⟶̂ P′ → ∃ λ Q′ → Q [ μ ]⇒̂ Q′ × ≳ R ≈ (P′ , Q′) lr⟶̂ PRQ (done s) = _ , silent s done , ⊆≳≈ PRQ lr⟶̂ PRQ (step P⟶P′) = S.challenge (lr⟶ PRQ) P⟶P′ lr≳≈⟶ : ∀ {P P′ Q μ} → ≳ R ≈ (P , Q) → P [ μ ]⟶ P′ → ∃ λ Q′ → Q [ μ ]⇒̂ Q′ × ≳ R ≈ (P′ , Q′) lr≳≈⟶ (P₁ , P≳P₁ , Q₁ , P₁RQ₁ , Q₁≈Q) P⟶P′ = let P₁′ , P₁⟶̂P₁′ , P′≳P₁′ = E.left-to-right P≳P₁ P⟶P′ Q₁′ , Q₁⇒̂Q₁′ , P₁″ , P₁′≳P₁″ , Q₁″ , P₁″RQ₁″ , Q₁″≈Q₁′ = lr⟶̂ P₁RQ₁ P₁⟶̂P₁′ Q′ , Q⇒̂Q′ , Q₁′≈Q′ = weak-is-weak⇒̂ Q₁≈Q Q₁⇒̂Q₁′ in Q′ , Q⇒̂Q′ , P₁″ , transitive {a = ℓ} P′≳P₁′ P₁′≳P₁″ , Q₁″ , P₁″RQ₁″ , transitive {a = ℓ} Q₁″≈Q₁′ Q₁′≈Q′ lr≳≈⇒ : ∀ {P P′ Q} → ≳ R ≈ (P , Q) → P ⇒ P′ → ∃ λ Q′ → Q ⇒ Q′ × ≳ R ≈ (P′ , Q′) lr≳≈⇒ P≳R≈Q done = _ , done , P≳R≈Q lr≳≈⇒ P≳R≈Q (step s P⟶P′ P′⇒P″) = let Q′ , Q⇒̂Q′ , P′≳R≈Q′ = lr≳≈⟶ P≳R≈Q P⟶P′ Q″ , Q′⇒Q″ , P″≳R≈Q″ = lr≳≈⇒ P′≳R≈Q′ P′⇒P″ in Q″ , ⇒-transitive (⇒̂→⇒ s Q⇒̂Q′) Q′⇒Q″ , P″≳R≈Q″ lr≳≈[]⇒ : ∀ {P P′ Q μ} → ¬ Silent μ → ≳ R ≈ (P , Q) → P [ μ ]⇒ P′ → ∃ λ Q′ → Q [ μ ]⇒ Q′ × ≳ R ≈ (P′ , Q′) lr≳≈[]⇒ ¬s P≳R≈Q (steps P⇒P′ P′⟶P″ P″⇒P‴) = let Q′ , Q⇒Q′ , P′≳R≈Q′ = lr≳≈⇒ P≳R≈Q P⇒P′ Q″ , Q′⇒̂Q″ , P″≳R≈Q″ = lr≳≈⟶ P′≳R≈Q′ P′⟶P″ Q‴ , Q″⇒Q‴ , P‴≳R≈Q‴ = lr≳≈⇒ P″≳R≈Q″ P″⇒P‴ in Q‴ , []⇒⇒-transitive (⇒[]⇒-transitive Q⇒Q′ (⇒̂→[]⇒ ¬s Q′⇒̂Q″)) Q″⇒Q‴ , P‴≳R≈Q‴ lr≳≈⇒̂ : ∀ {P P′ Q μ} → ≳ R ≈ (P , Q) → P [ μ ]⇒̂ P′ → ∃ λ Q′ → Q [ μ ]⇒̂ Q′ × ≳ R ≈ (P′ , Q′) lr≳≈⇒̂ PRQ = λ where (silent s P⇒P′) → Σ-map id (Σ-map (silent s) id) (lr≳≈⇒ PRQ P⇒P′) (non-silent ¬s P⇒P′) → Σ-map id (Σ-map (non-silent ¬s) id) (lr≳≈[]⇒ ¬s PRQ P⇒P′) ------------------------------------------------------------------------ -- Up to weak bisimilarity -- Up to weak bisimilarity. -- -- I based this definition on Definition 4.2.13 in Milner's -- "Operational and Algebraic Semantics of Concurrent Processes". Up-to-weak-bisimilarity : Trans₂ ℓ Proc Up-to-weak-bisimilarity R = Weak-bisimilarity ∞ ⊙ R ⊙ Weak-bisimilarity ∞ -- Up to weak bisimilarity is monotone. up-to-weak-bisimilarity-monotone : Monotone Up-to-weak-bisimilarity up-to-weak-bisimilarity-monotone R⊆S = Σ-map id (Σ-map id (Σ-map id (Σ-map R⊆S id))) -- If transitivity of weak bisimilarity is size-preserving in the -- first argument, then "up to weak bisimilarity" is size-preserving. size-preserving-transitivity→up-to-weak-bisimilarity-size-preserving : (∀ {i x y z} → [ i ] x ≈ y → [ ∞ ] y ≈ z → [ i ] x ≈ z) → Size-preserving Up-to-weak-bisimilarity size-preserving-transitivity→up-to-weak-bisimilarity-size-preserving trans = _⇔_.from (monotone→⇔ up-to-weak-bisimilarity-monotone) λ where {x = p , q} (r , p≈r , s , r≈s , s≈q) → p ≈∞⟨ p≈r ⟩ r ≈⟨ r≈s ⟩∞ s ∼⟨ s≈q ⟩■ q where infixr -2 _≈⟨_⟩∞_ _≈∞⟨_⟩_ _≈⟨_⟩∞_ : ∀ {i} x {y z} → [ i ] x ≈ y → [ ∞ ] y ≈ z → [ i ] x ≈ z _ ≈⟨ p ⟩∞ q = trans p q _≈∞⟨_⟩_ : ∀ {i} x {y z} → [ ∞ ] x ≈ y → [ i ] y ≈ z → [ i ] x ≈ z _ ≈∞⟨ p ⟩ q = symmetric (trans (symmetric q) (symmetric p)) -- If transitivity of weak bisimilarity is size-preserving in both -- arguments, then weak bisimulations up to weak bisimilarity are -- contained in weak bisimilarity. size-preserving-transitivity→up-to-weak-bisimilarity-up-to : (∀ {i x y z} → [ i ] x ≈ y → [ i ] y ≈ z → [ i ] x ≈ z) → Up-to-technique Up-to-weak-bisimilarity size-preserving-transitivity→up-to-weak-bisimilarity-up-to = size-preserving→up-to ∘ size-preserving-transitivity→up-to-weak-bisimilarity-size-preserving
{ "alphanum_fraction": 0.4672016748, "avg_line_length": 35.3827160494, "ext": "agda", "hexsha": "5e574ef391ab29ed216d5e6a07a26934398ae1c9", "lang": "Agda", "max_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/Up-to.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/Up-to.agda", "max_line_length": 94, "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/Up-to.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3867, "size": 8598 }
{-# OPTIONS --safe #-} module Cubical.Algebra.CommAlgebra.FGIdeal where open import Cubical.Foundations.Prelude open import Cubical.Data.FinData open import Cubical.Data.Nat open import Cubical.Data.Vec open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.FGIdeal renaming (generatedIdeal to generatedIdealCommRing) open import Cubical.Algebra.CommAlgebra open import Cubical.Algebra.CommAlgebra.Ideal private variable ℓ : Level module _ {R : CommRing ℓ} (A : CommAlgebra R ℓ) where open CommAlgebraStr (snd A) generatedIdeal : {n : ℕ} → FinVec (fst A) n → IdealsIn A generatedIdeal = generatedIdealCommRing (CommAlgebra→CommRing A)
{ "alphanum_fraction": 0.7868852459, "avg_line_length": 29.1739130435, "ext": "agda", "hexsha": "5c5c546b70a0ba8698da7a7d734456acb2042a90", "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/CommAlgebra/FGIdeal.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/CommAlgebra/FGIdeal.agda", "max_line_length": 96, "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/CommAlgebra/FGIdeal.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": 188, "size": 671 }
{-# OPTIONS --allow-unsolved-metas #-} record ⊤ : Set where constructor tt data I : Set where i : ⊤ → I data D : I → Set where d : D (i tt) postulate P : (x : I) → D x → Set foo : (y : _) → P _ y foo d = {!!}
{ "alphanum_fraction": 0.518018018, "avg_line_length": 13.0588235294, "ext": "agda", "hexsha": "7e64b14381f606a9ce4c00a97d8118503b0890d4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Succeed/Issue1863.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "test/Succeed/Issue1863.agda", "max_line_length": 38, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Succeed/Issue1863.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 84, "size": 222 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Semigroup.Construct.Unit where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Algebra.Semigroup open import Cubical.Data.Unit import Cubical.Algebra.Magma.Construct.Unit as ⊤Magma open ⊤Magma public hiding (⊤-isMagma; ⊤-Magma) ◯-assoc : Associative _◯_ ◯-assoc _ _ _ = refl ⊤-isSemigroup : IsSemigroup ⊤ _◯_ ⊤-isSemigroup = record { isMagma = ⊤Magma.⊤-isMagma ; assoc = ◯-assoc } ⊤-Semigroup : Semigroup ℓ-zero ⊤-Semigroup = record { isSemigroup = ⊤-isSemigroup }
{ "alphanum_fraction": 0.73089701, "avg_line_length": 24.08, "ext": "agda", "hexsha": "9c94f702c865784cfb9f63632738db493ea02c41", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Algebra/Semigroup/Construct/Unit.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Algebra/Semigroup/Construct/Unit.agda", "max_line_length": 53, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Algebra/Semigroup/Construct/Unit.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 213, "size": 602 }
------------------------------------------------------------------------ -- Some properties that hold for Erased do not hold for every -- accessible modality ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} import Equality.Path as P module Erased.Counterexamples.Cubical {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq open import Logical-equivalence using (_⇔_) open import Prelude open import Bijection equality-with-J as B using (_↔_) open import Erased.Cubical eq using (Σ-closed-reflective-subuniverse; Accessible) open import Equality.Decision-procedures equality-with-J open import Equality.Path.Isomorphisms eq open import Equivalence equality-with-J as Eq using (_≃_; Is-equivalence) open import Equivalence.Path-split equality-with-J as PS using (_-Null_; Is-∞-extendable-along-[_]) open import Function-universe equality-with-J as F hiding (id; _∘_) open import H-level equality-with-J open import H-level.Closure equality-with-J open import H-level.Truncation.Propositional eq as T using (∥_∥; ∣_∣; Axiom-of-choice) open import Preimage equality-with-J using (_⁻¹_) private variable a b ℓ ℓ′ p : Level A : Type a -- A type is modal with respect to the modality ∥_∥ if it is a -- proposition. ∥∥-modal : Type ℓ → Type ℓ ∥∥-modal = Is-proposition -- Propositional truncation is a Σ-closed reflective subuniverse. -- -- This proof is based on "Modalities in Homotopy Type Theory" by -- Rijke, Shulman and Spitters. ∥∥-modality : Σ-closed-reflective-subuniverse ℓ ∥∥-modality {ℓ = ℓ} = λ where .◯ → ∥_∥ .η → ∣_∣ .Is-modal → ∥∥-modal .Is-modal-propositional → λ ext → H-level-propositional ext 1 .Is-modal-◯ → T.truncation-is-proposition .Is-modal-respects-≃ → H-level-cong _ 1 .extendable-along-η → extendable .Σ-closed → Σ-closure 1 where open Σ-closed-reflective-subuniverse extendable : {A B : Type ℓ} → Is-proposition B → Is-∞-extendable-along-[ ∣_∣ ] (λ (_ : ∥ A ∥) → B) extendable {A = A} {B = B} = Is-proposition B →⟨ (λ prop → _≃_.is-equivalence $ Eq.↔→≃ _ (T.rec prop) refl (λ f → ⟨ext⟩ $ T.elim _ (λ _ → ⇒≡ 1 prop) (λ _ → refl _))) ⟩ Is-equivalence (λ (f : ∥ A ∥ → B) → f ∘ ∣_∣) ↔⟨ inverse $ PS.Is-∞-extendable-along≃Is-equivalence ext ⟩□ Is-∞-extendable-along-[ ∣_∣ ] (λ (_ : ∥ A ∥) → B) □ -- The propositional truncation modality is accessible. -- -- This proof is based on "Modalities in Homotopy Type Theory" by -- Rijke, Shulman and Spitters. ∥∥-accessible : Accessible ℓ′ (∥∥-modality {ℓ = ℓ}) ∥∥-accessible {ℓ′ = ℓ′} {ℓ = ℓ} = ↑ ℓ′ ⊤ , (λ _ → ↑ ℓ′ Bool) , (λ A → Is-proposition A ↝⟨ record { from = from; to = to } ⟩ (λ _ → ↑ ℓ′ Bool) -Null A ↔⟨ inverse $ PS.Π-Is-∞-extendable-along≃Null ext ⟩□ (↑ ℓ′ ⊤ → Is-∞-extendable-along-[ _ ] (λ _ → A)) □) where to : Is-proposition A → (λ _ → ↑ ℓ′ Bool) -Null A to prop _ = _≃_.is-equivalence $ Eq.⇔→≃ prop (Π-closure ext 1 λ _ → prop) _ (_$ lift true) from : (λ _ → ↑ ℓ′ Bool) -Null A → Is-proposition A from {A = A} null x y = x ≡⟨⟩ case true ⦂ Bool of if_then x else y ≡⟨ cong (_$ true) $ sym $ E.right-inverse-of _ ⟩ E.to (E.from (if_then x else y)) true ≡⟨⟩ E.from (if_then x else y) ≡⟨⟩ E.to (E.from (if_then x else y)) false ≡⟨ cong (_$ false) $ E.right-inverse-of _ ⟩ case false ⦂ Bool of if_then x else y ≡⟨⟩ y ∎ where ≃Bool→ : A ≃ (Bool → A) ≃Bool→ = A ↝⟨ Eq.⟨ _ , null _ ⟩ ⟩ (↑ ℓ′ Bool → A) ↝⟨ Eq.↔→≃ (_∘ lift) (_∘ lower) refl refl ⟩□ (Bool → A) □ module E = _≃_ ≃Bool→ -- It is not the case that, for all types A and B and functions -- f : A → B, "f is ∥∥-connected" implies ∥ Is-equivalence f ∥. ¬[∥∥-connected→∥Is-equivalence∥] : ¬ ({A : Type a} {B : Type b} {f : A → B} → (∀ y → Contractible ∥ f ⁻¹ y ∥) → ∥ Is-equivalence f ∥) ¬[∥∥-connected→∥Is-equivalence∥] hyp = $⟨ (λ _ → ∣ lift true , refl _ ∣) ⟩ ((y : ↑ _ ⊤) → ∥ (const (lift tt) ⦂ (↑ _ Bool → ↑ _ ⊤)) ⁻¹ y ∥) →⟨ (∀-cong _ λ _ → propositional⇒inhabited⇒contractible T.truncation-is-proposition) ⟩ ((y : ↑ _ ⊤) → Contractible ∥ (const (lift tt) ⦂ (↑ _ Bool → ↑ _ ⊤)) ⁻¹ y ∥) →⟨ hyp ⟩ ∥ Is-equivalence (const (lift tt) ⦂ (↑ _ Bool → ↑ _ ⊤)) ∥ ↔⟨ T.∥∥↔ (Eq.propositional ext _) ⟩ Is-equivalence (const (lift tt) ⦂ (↑ _ Bool → ↑ _ ⊤)) →⟨ Eq.⟨ _ ,_⟩ ⟩ ↑ _ Bool ≃ ↑ _ ⊤ →⟨ (λ eq → Eq.↔⇒≃ B.↑↔ F.∘ eq F.∘ Eq.↔⇒≃ (inverse B.↑↔)) ⟩ Bool ≃ ⊤ →⟨ (λ eq → H-level-cong _ 1 (inverse eq) (mono₁ 0 ⊤-contractible)) ⟩ Is-proposition Bool →⟨ ¬-Bool-propositional ⟩□ ⊥ □ -- It is not the case that, for all types A and B and functions -- f : A → B, "f is ∥∥-connected" is equivalent to -- ∥ Is-equivalence f ∥. -- -- Compare with -- Erased.Level-1.[]-cong₂-⊔.Erased-connected↔Erased-Is-equivalence. ¬[∥∥-connected≃∥Is-equivalence∥] : ¬ ({A : Type a} {B : Type b} {f : A → B} → (∀ y → Contractible ∥ f ⁻¹ y ∥) ≃ ∥ Is-equivalence f ∥) ¬[∥∥-connected≃∥Is-equivalence∥] hyp = ¬[∥∥-connected→∥Is-equivalence∥] (_≃_.to hyp) -- If (x : A) → ∥ P x ∥ implies ∥ ((x : A) → P x) ∥ for all types A -- and type families P over A, then the axiom of choice holds. [Π∥∥→∥Π∥]→Axiom-of-choice : ({A : Type a} {P : A → Type p} → ((x : A) → ∥ P x ∥) → ∥ ((x : A) → P x) ∥) → Axiom-of-choice a p [Π∥∥→∥Π∥]→Axiom-of-choice hyp = λ _ → hyp -- If ∥ ((x : A) → P x) ∥ is isomorphic to (x : A) → ∥ P x ∥ for all -- types A and type families P over A, then the axiom of choice holds. -- -- Compare with Erased.Level-1.Erased-Π↔Π. [∥Π∥↔Π∥∥]→Axiom-of-choice : ({A : Type a} {P : A → Type p} → ∥ ((x : A) → P x) ∥ ↔ ((x : A) → ∥ P x ∥)) → Axiom-of-choice a p [∥Π∥↔Π∥∥]→Axiom-of-choice hyp = [Π∥∥→∥Π∥]→Axiom-of-choice (_↔_.from hyp) -- If ∥ A ∥ → ∥ B ∥ implies ∥ (A → B) ∥ for all types A and B in the -- same universe, then ∥ (∥ A ∥ → A) ∥ holds for every type A in this -- universe. This is a variant of the axiom of choice of which Kraus -- et al. state that "We expect that this makes it possible to show -- that, in MLTT with weak propositional truncation, [a logically -- equivalent variant of the axiom] is not derivable" (see "Notions of -- Anonymous Existence in Martin-Löf Type Theory"). [[∥∥→∥∥]→∥→∥]→Axiom-of-choice : ({A B : Type a} → (∥ A ∥ → ∥ B ∥) → ∥ (A → B) ∥) → ({A : Type a} → ∥ (∥ A ∥ → A) ∥) [[∥∥→∥∥]→∥→∥]→Axiom-of-choice hyp {A = A} = $⟨ T.rec T.truncation-is-proposition id ⟩ (∥ ∥ A ∥ ∥ → ∥ A ∥) →⟨ hyp ⟩□ ∥ (∥ A ∥ → A) ∥ □ -- If ∥ (A → B) ∥ is isomorphic to ∥ A ∥ → ∥ B ∥ for all types A and B -- in the same universe, then ∥ (∥ A ∥ → A) ∥ holds for every type A -- in this universe. This is a variant of the axiom of choice of which -- Kraus et al. state that "We expect that this makes it possible to -- show that, in MLTT with weak propositional truncation, [a logically -- equivalent variant of the axiom] is not derivable" (see "Notions of -- Anonymous Existence in Martin-Löf Type Theory"). -- -- Compare with Erased.Level-1.Erased-Π↔Π-Erased. [∥→∥↔[∥∥→∥∥]]→Axiom-of-choice : ({A B : Type a} → ∥ (A → B) ∥ ↔ (∥ A ∥ → ∥ B ∥)) → ({A : Type a} → ∥ (∥ A ∥ → A) ∥) [∥→∥↔[∥∥→∥∥]]→Axiom-of-choice hyp = [[∥∥→∥∥]→∥→∥]→Axiom-of-choice (_↔_.from hyp) -- It is not the case that, for every type A, if A is ∥∥-modal, then A -- is (λ (A : Type a) → ∥∥-modal A)-null. ¬[∥∥-modal→∥∥-modal-Null] : ¬ ({A : Type a} → ∥∥-modal A → (λ (A : Type a) → ∥∥-modal A) -Null A) ¬[∥∥-modal→∥∥-modal-Null] hyp = $⟨ ⊥-propositional ⟩ Is-proposition ⊥ →⟨ hyp ⟩ (∀ A → Is-equivalence (const ⦂ (⊥ → Is-proposition A → ⊥))) →⟨ _$ _ ⟩ Is-equivalence (const ⦂ (⊥ → Is-proposition (↑ _ Bool) → ⊥)) →⟨ Eq.⟨ _ ,_⟩ ⟩ ⊥ ≃ (Is-proposition (↑ _ Bool) → ⊥) →⟨ →-cong ext (Eq.↔⇒≃ $ inverse $ B.⊥↔uninhabited (¬-Bool-propositional ∘ ↑⁻¹-closure 1)) Eq.id F.∘_ ⟩ ⊥ ≃ (⊥₀ → ⊥) →⟨ Π⊥↔⊤ ext F.∘_ ⟩ ⊥ ≃ ⊤ →⟨ (λ eq → ⊥-elim $ _≃_.from eq _) ⟩□ ⊥ □ -- It is not the case that, for every type A, there is an equivalence -- between "A is ∥∥-modal" and (λ (A : Type a) → ∥∥-modal A) -Null A. -- -- Compare with Erased.Stability.Very-stable≃Very-stable-Null. ¬[∥∥-modal≃∥∥-modal-Null] : ¬ ({A : Type a} → ∥∥-modal A ≃ (λ (A : Type a) → ∥∥-modal A) -Null A) ¬[∥∥-modal≃∥∥-modal-Null] hyp = ¬[∥∥-modal→∥∥-modal-Null] (_≃_.to hyp) -- It is not the case that, for every type A : Type a and proof of -- Extensionality a a, there is an equivalence between "A is ∥∥-modal" -- and (λ (A : Type a) → ∥∥-modal A) -Null A. -- -- Compare with Erased.Stability.Very-stable≃Very-stable-Null. ¬[∥∥-modal≃∥∥-modal-Null]′ : ¬ ({A : Type a} → Extensionality a a → ∥∥-modal A ≃ (λ (A : Type a) → ∥∥-modal A) -Null A) ¬[∥∥-modal≃∥∥-modal-Null]′ hyp = ¬[∥∥-modal≃∥∥-modal-Null] (hyp ext)
{ "alphanum_fraction": 0.4681830999, "avg_line_length": 41.7215686275, "ext": "agda", "hexsha": "0dd5d8d42cf9f2c807bd289777812c1c8788789d", "lang": "Agda", "max_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/Erased/Counterexamples/Cubical.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/Erased/Counterexamples/Cubical.agda", "max_line_length": 138, "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/Erased/Counterexamples/Cubical.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": 3913, "size": 10639 }
data U : Set T : U → Set {-# NO_UNIVERSE_CHECK #-} data U where pi : (A : Set)(b : A → U) → U T (pi A b) = (x : A) → T (b x)
{ "alphanum_fraction": 0.4615384615, "avg_line_length": 13, "ext": "agda", "hexsha": "cdffbc4589790235cf5e76342ae28e5f2ed4ab14", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/NoUniverseCheckPragma2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Succeed/NoUniverseCheckPragma2.agda", "max_line_length": 31, "max_stars_count": 1, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/NoUniverseCheckPragma2.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-07T10:49:57.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-07T10:49:57.000Z", "num_tokens": 58, "size": 130 }
module Examples.TrafficLight where open import Data.Bool open import Data.Empty open import Data.Sum using (_⊎_; inj₁; inj₂) open import Data.Unit open import Relation.Binary.PropositionalEquality open import Library open import FStream.Core open import FStream.FVec open import FStream.Containers open import CTL.Modalities open import CTL.Proof data Colour : Set where red : Colour green : Colour _<$>_ = fmap boolToColour : Bool → Colour boolToColour false = green boolToColour true = red trafficLight : FStream (ReaderC Bool) Colour trafficLight = ⟨ returnReader green ▻ (boolToColour <$> ask) ▻ returnReader green ▻ returnReader red ⟩ ▻⋯ -- TODO Consider replacing Colour by Bool for simplification boolLight : FStream (ReaderC Bool) Bool boolLight = ⟨ returnReader true ▻ returnReader true ▻ returnReader false ⟩ ▻⋯ -- TODO This only proves that right now (in the first tick), liveness is satisfied, but not in the later ticks! isLive : AF (map (_≡ green) trafficLight) isLive p = alreadyA refl trafficLight₂ : FStream (ReaderC Bool) Colour trafficLight₂ = ⟨ returnReader red ▻ (boolToColour <$> ask) ▻ returnReader red ▻ returnReader green ⟩ ▻⋯ boolLight₂ : FStream (ReaderC Bool) Bool boolLight₂ = ⟨ returnReader false ▻ returnReader false ▻ returnReader true ⟩ ▻⋯ -- FIND-OUT how to call this / what this actually means isLive₂ : EF (map (_≡ true) boolLight₂) isLive₂ p = notYetE (true , (notYetE (true , (alreadyE refl)))) -- notYetE (true , (notYetE (true , (alreadyE (false , refl))))) trafficLight₃ : ∀ {i} → FStream {i} (ReaderC Bool) Colour trafficLight₃ = ⟨ returnReader green ▻ (boolToColour <$> ask) ▻ returnReader red ▻ returnReader green ⟩ ▻⋯ boolLight₃ : FStream (ReaderC Bool) Bool boolLight₃ = ⟨ returnReader true ▻ returnReader false ▻ returnReader true ⟩ ▻⋯ isLive₄ : ∀ {i} → AG {i} (AFₛ (map (_≡ green) (trafficLight₃))) nowA (isLive₄ p) = alreadyA refl nowA (laterA (isLive₄ p) false) = alreadyA refl nowA (laterA (isLive₄ p) true) = notYetA (const (notYetA (const (alreadyA refl)))) nowA (laterA (laterA (isLive₄ p) p₁) p₂) = notYetA (λ p₃ → alreadyA refl) nowA (laterA (laterA (laterA (isLive₄ p) p₁) p₂) p₃) = alreadyA refl laterA (laterA (laterA (laterA (isLive₄ p) p₁) p₂) p₃) p₄ = isLive₄ true mutual -- This fellow switches between false and true every time a "true" is entered as input trueEgde : ∀ {i} → FStream {i} (ReaderC Bool) Bool proj₁ (inF trueEgde) = tt head (proj₂ (inF trueEgde) true) = false tail (proj₂ (inF trueEgde) true) = falseEgde head (proj₂ (inF trueEgde) false) = true tail (proj₂ (inF trueEgde) false) = trueEgde falseEgde : ∀ {i} → FStream {i} (ReaderC Bool) Bool proj₁ (inF falseEgde) = tt head (proj₂ (inF falseEgde) true) = true tail (proj₂ (inF falseEgde) true) = trueEgde head (proj₂ (inF falseEgde) false) = false tail (proj₂ (inF falseEgde) false) = falseEgde -- At every point in time, it is possible (by correct input) to output true mutual edgeResponsive : ∀ {i} → AG {i} (EFₛ (map (_≡ true) trueEgde )) nowA (edgeResponsive false) = alreadyE refl nowA (edgeResponsive true) = notYetE (true , alreadyE refl) laterA (edgeResponsive false) = edgeResponsive laterA (edgeResponsive true) = edgeResponsive' edgeResponsive' : ∀ {i} → AG {i} (EFₛ (map (_≡ true) falseEgde)) edgeResponsive' = {! !} -- Exercise for you, dear reader! frob : ∀ {i} → Bool → FStream {i} (ReaderC Bool) Bool proj₁ (inF (frob b)) = tt head (proj₂ (inF (frob b)) false) = b tail (proj₂ (inF (frob b)) false) = frob b head (proj₂ (inF (frob b)) true) = not b tail (proj₂ (inF (frob b)) true) = frob (not b) frobResponsive : ∀ {i} → (b : Bool) → AG {i} (EFₛ (map (_≡ true) (frob b) )) nowA (frobResponsive false false) = notYetE (true , alreadyE refl) nowA (frobResponsive false true) = alreadyE refl nowA (frobResponsive true false) = alreadyE refl nowA (frobResponsive true true) = notYetE (true , (alreadyE refl)) laterA (frobResponsive b false) = frobResponsive b laterA (frobResponsive b true) = frobResponsive (not b) -- Prove that a series of ⊤ is always true, under any circumstance tautology : AG ⟨ returnReader ⊤ ⟩ ▻⋯ -- We create a cyclical stream of proofs tautology = ⟨ const tt ⟩AG ▻AG tautology₂ : ∀ {i} → AG {i} ⟨ returnReader ⊤ ⟩ ▻⋯ nowA (tautology₂ p) = tt laterA (tautology₂ p) = tautology₂ -- p is the position of the first side effect -- TODO Find something that this satisfies identity : ∀ {A} → FStream (ReaderC A) A identity = ⟨ ask ⟩ ▻⋯ alwaysGreen : ∀ {i} → FStream {i} (ReaderC Bool) Colour alwaysGreen = ⟨ (returnReader green) ▻ returnReader green ⟩ ▻⋯ isAlwaysGreen : ∀ {i} → AG {i} (map (_≡ green) alwaysGreen) nowA (isAlwaysGreen p) = refl nowA (laterA (isAlwaysGreen p) p₁) = refl laterA (laterA (isAlwaysGreen p) p₁) p₂ = isAlwaysGreen p {- nowA isAlwaysGreen _ = refl nowA (laterA isAlwaysGreen _) _ = refl laterA (laterA isAlwaysGreen _) _ = isAlwaysGreen -} isAlwaysGreen' : ∀ {i} → AG {i} (map (_≡ green) alwaysGreen) isAlwaysGreen' = {! !} -- TODO Would like to use bisimulation isGreenOrRed : ∀ {i} → AG {i} (map (λ x → (x ≡ green) ⊎ (x ≡ red)) ⟨ returnReader green ▻ returnReader red ⟩ ▻⋯) nowA (isGreenOrRed p) = inj₁ refl nowA (laterA (isGreenOrRed p) p₁) = inj₂ refl laterA (laterA (isGreenOrRed p) p₁) p₂ = isGreenOrRed p trafficLight₄ : ∀ {i} → FStream {i} (ReaderC Bool) Bool trafficLight₄ = ⟨ returnReader true ▻ ask ⟩ ▻⋯ liveness₄ : ∀ {i} → AG {i} (AFₛ (map (true ≡_) trafficLight₄)) nowA (liveness₄ p) = alreadyA refl nowA (laterA (liveness₄ p) p₁) = notYetA (λ p₂ → alreadyA refl) laterA (laterA (liveness₄ p) p₁) = liveness₄ responsivity : ∀ {i} → EG {i} (map (true ≡_) trafficLight₄) proj₁ responsivity = false nowE (proj₂ responsivity) = refl proj₁ (laterE (proj₂ responsivity)) = true nowE (proj₂ (laterE (proj₂ responsivity))) = refl laterE (proj₂ (laterE (proj₂ responsivity))) = responsivity responsivity₁ : ∀ {i} → EG {i} (map (true ≡_) trafficLight₄) responsivity₁ = mapEG ⟨ refl ⟩EGᵢ ▻EG responsivity₁' : ∀ {i} → EG {i} (map (true ≡_) trafficLight₄) responsivity₁' = mapEG ⟨ refl ▻EGᵢ refl ⟩EGᵢ ▻EG responsivity₂ : ∀ {i} → EG {i} (⟨ vmap (true ≡_) (returnReader true ▻ ask ⟩) ▻⋯) proj₁ responsivity₂ = false nowE (proj₂ responsivity₂) = refl proj₁ (laterE (proj₂ responsivity₂)) = true nowE (proj₂ (laterE (proj₂ responsivity₂))) = refl laterE (proj₂ (laterE (proj₂ responsivity₂))) = responsivity₂ responsoSmall : EN (⟨ vmap (true ≡_) (returnReader true ▻ ask ⟩) ▻⋯) proj₁ responsoSmall = true proj₁ (proj₂ responsoSmall) = true proj₂ (proj₂ responsoSmall) = refl responso : AG (ENₛ (⟨ vmap (true ≡_) (returnReader true ▻ ask ⟩) ▻⋯)) nowA (responso p) with fmap EN'ₛ (inF ⟨ FCons (fmap (vmap' (λ section → true ≡ section)) (fmap (λ x → x , ask ⟩) (returnReader true))) ▻⋯) nowA (responso p) | proj₃ , proj₄ with EN' (_aux_ ((true ≡ true) , FCons (tt , (λ x → (true ≡ x) , FNil))) (FCons (tt , (λ x → (true ≡ true) , FCons (tt , (λ x₁ → (true ≡ x₁) , FNil)))))) ... | bla = {! !} nowA (laterA (responso p) p₁) = {! !} laterA (laterA (responso p) p₁) p₂ = {! !} {- head (EN'ₛ (((true ≡ true) , FCons (tt , (λ x → (true ≡ x) , FNil))) aux FCons (tt , (λ x → (true ≡ true) , FCons (tt , (λ x₁ → (true ≡ x₁) , FNil)))))) EN' (((true ≡ true) , FCons (tt , (λ x → (true ≡ x) , FNil))) aux FCons (tt , (λ x → (true ≡ true) , FCons (tt , (λ x₁ → (true ≡ x₁) , FNil))))) EPred head (inF (tail (((true ≡ true) , FCons (tt , (λ x → (true ≡ x) , FNil))) aux FCons (tt , (λ x → (true ≡ true) , FCons (tt , (λ x₁ → (true ≡ x₁) , FNil))))))) EPred head (inF (( FCons (tt , (λ x → (true ≡ x) , FNil))) pre⟨ FCons (tt , (λ x → (true ≡ true) , FCons (tt , (λ x₁ → (true ≡ x₁) , FNil))) ▻⋯ ))) EPred head (fmap (_aux (FCons (tt , (λ x → (true ≡ true) , FCons (tt , (λ x₁ → (true ≡ x₁) , FNil))) ▻⋯ ))) (tt , (λ x → (true ≡ x) , FNil)) ) EPred head (tt , (λ x → (true ≡ x) , FNil) aux FCons (tt , (λ x → (true ≡ true) , FCons (tt , (λ x₁ → (true ≡ x₁) , FNil))) ▻⋯ ) ) ∃ p → head ((λ x → (true ≡ x) , FNil) aux FCons (tt , (λ x → (true ≡ true) , FCons (tt , (λ x₁ → (true ≡ x₁) , FNil))) ▻⋯ ) ) -} tautology₄ : EG ⟨ returnReader ⊤ ⟩ ▻⋯ tautology₄ = ⟨ ConsEG (23 , tt , []EG) ▻EG tautology₅ : EG ⟨ returnReader ⊤ ⟩ ▻⋯ tautology₅ = ⟨ (23 , tt) ⟩EG ▻EG tautology₆ : EG ⟨ returnReader ⊤ ▻ returnReader ⊤ ⟩ ▻⋯ tautology₆ = ⟨ (23 , tt) ▻EG (42 , tt) ⟩EG ▻EG -- In lots of cases, Agda can infer the input that will validate the proof easy : EG ⟨ (true ≡_) <$> ask ▻ returnReader ⊤ ⟩ ▻⋯ easy = ⟨ refl ▻EGᵢ tt ⟩EGᵢ ▻EG timesTwo : ∀ {i} → FStream {i} (ReaderC ℕ) ℕ timesTwo = map (_* 2) ⟨ ask ⟩ ▻⋯ even : ℕ → Set even n = ∃ λ m → n ≡ m * 2 alwaysEven : ∀ {i} → AG {i} (map even timesTwo) nowA (alwaysEven p) = p , refl laterA (alwaysEven p) = alwaysEven alwaysEven₁ : ∀ {i} → AG {i} (map even timesTwo) -- alwaysEven₁ = mapAG ([]AG pre⟨ {! !} ▻AG) -- TODO Report internal error on refining alwaysEven₁ = mapAG ⟨ (λ p → p) ⟩AG ▻AG
{ "alphanum_fraction": 0.647425203, "avg_line_length": 36.1084337349, "ext": "agda", "hexsha": "33427a4aa2a2fed71851b1c7d967f52a82a4e345", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-12-13T15:56:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-12-13T15:56:38.000Z", "max_forks_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "zimbatm/condatis", "max_forks_repo_path": "Examples/TrafficLight.agda", "max_issues_count": 5, "max_issues_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_issues_repo_issues_event_max_datetime": "2020-09-01T16:52:07.000Z", "max_issues_repo_issues_event_min_datetime": "2017-06-03T20:02:22.000Z", "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "zimbatm/condatis", "max_issues_repo_path": "Examples/TrafficLight.agda", "max_line_length": 187, "max_stars_count": 1, "max_stars_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "Aerate/condatis", "max_stars_repo_path": "Examples/TrafficLight.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-13T16:52:28.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-13T16:52:28.000Z", "num_tokens": 3481, "size": 8991 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.S2.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels data S² : Type₀ where base : S² surf : PathP (λ i → base ≡ base) refl refl S²ToSetRec : ∀ {ℓ} {A : S² → Type ℓ} → ((x : S²) → isSet (A x)) → A base → (x : S²) → A x S²ToSetRec set b base = b S²ToSetRec set b (surf i j) = isOfHLevel→isOfHLevelDep 2 set b b {a0 = refl} {a1 = refl} refl refl surf i j
{ "alphanum_fraction": 0.6146245059, "avg_line_length": 28.1111111111, "ext": "agda", "hexsha": "559a98d8fd361979cb8c7a45091657736a6deefa", "lang": "Agda", "max_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/S2/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/S2/Base.agda", "max_line_length": 79, "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/S2/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 187, "size": 506 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Base.Types import LibraBFT.Impl.OBM.ECP-LBFT-OBM-Diff.ECP-LBFT-OBM-Diff-2 as ECP-LBFT-OBM-Diff-2 import LibraBFT.Impl.Storage.DiemDB.LedgerStore.LedgerStore as LedgerStore open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.Util.Dijkstra.All open import Optics.All open import Util.Prelude module LibraBFT.Impl.Storage.DiemDB.DiemDB where ------------------------------------------------------------------------------ getEpochEndingLedgerInfosImpl : DiemDB → Epoch → Epoch → Epoch {-Usize-} → Either ErrLog (List LedgerInfoWithSignatures × Bool) getLatestLedgerInfo : DiemDB → Either ErrLog LedgerInfoWithSignatures ------------------------------------------------------------------------------ mAX_NUM_EPOCH_ENDING_LEDGER_INFO : Epoch -- Usize mAX_NUM_EPOCH_ENDING_LEDGER_INFO = 100 ------------------------------------------------------------------------------ -- impl DiemDB -- Returns ledger infos for epoch changes starting with the given epoch. -- If there are less than `MAX_NUM_EPOCH_ENDING_LEDGER_INFO` results, it returns all of them. -- Otherwise the first `MAX_NUM_EPOCH_ENDING_LEDGER_INFO` results are returned -- and a flag is set to True to indicate there are more. getEpochEndingLedgerInfos : DiemDB → Epoch → Epoch → Either ErrLog (List LedgerInfoWithSignatures × Bool) getEpochEndingLedgerInfos self startEpoch endEpoch = getEpochEndingLedgerInfosImpl self startEpoch endEpoch mAX_NUM_EPOCH_ENDING_LEDGER_INFO -- TODO-2: provide EitherD variants before writing proofs about this function; -- TODO-2: then use `whenD` in place of the two `if`s below getEpochEndingLedgerInfosImpl self startEpoch endEpoch limit = do if (not ⌊ (startEpoch ≤? endEpoch) ⌋) then (Left fakeErr {-here ["bad epoch range", lsE startEpoch, lsE endEpoch]-}) else pure unit -- the latest epoch can be the same as the current epoch (in most cases), or -- current_epoch + 1 (when the latest ledger_info carries next validator set) latestEpoch ← getLatestLedgerInfo self >>= pure ∘ (_^∙ liwsLedgerInfo ∙ liNextBlockEpoch) if (not ⌊ (endEpoch ≤? latestEpoch) ⌋) then (Left fakeErr) -- [ "unable to provide epoch change ledger info for still open epoch" -- , "asked upper bound", lsE endEpoch -- , "last sealed epoch", lsE (latestEpoch - 1) ]))) -- -1 is OK because genesis LedgerInfo has .next_block_epoch() == 1 else pure unit let (pagingEpoch , more) = ECP-LBFT-OBM-Diff-2.e_DiemDB_getEpochEndingLedgerInfosImpl_limit startEpoch endEpoch limit lis0 ← LedgerStore.getEpochEndingLedgerInfoIter (self ^∙ ddbLedgerStore) startEpoch pagingEpoch let lis = LedgerStore.obmEELIICollect lis0 if -- genericLength lis /= (pagingEpoch^.eEpoch) - (startEpoch^.eEpoch) length lis + (startEpoch {-^∙ eEpoch-}) /= (pagingEpoch {-^∙ eEpoch-}) -- rewritten to avoid monus then Left fakeErr -- [ "DB corruption: missing epoch ending ledger info" -- , lsE startEpoch, lsE endEpoch, lsE pagingEpoch ] else pure (lis , more) {- where here t = "DiemDB":"getEpochEndingLedgerInfosImpl":t -} ------------------------------------------------------------------------------ -- impl DbReader for DiemDB getLatestLedgerInfo self = maybeS (self ^∙ ddbLedgerStore ∙ lsLatestLedgerInfo) (Left fakeErr {-["DiemDB.Lib", "getLatestLedgerInfo", "Nothing"]-}) pure getEpochEndingLedgerInfo : DiemDB → Version → Either ErrLog LedgerInfoWithSignatures getEpochEndingLedgerInfo = LedgerStore.getEpochEndingLedgerInfo ∘ _ddbLedgerStore ------------------------------------------------------------------------------ -- impl DbWriter for DiemDB -- LBFT-OBM-DIFF : entire impl module saveTransactions (self : DiemDB) {- → [TransactionToCommit] → Version-} (mliws : Maybe LedgerInfoWithSignatures) where VariantFor : ∀ {ℓ} EL → EL-func {ℓ} EL VariantFor EL = EL ErrLog DiemDB step₁ : LedgerInfoWithSignatures → VariantFor EitherD step₀ : VariantFor EitherD step₀ = maybeSD mliws (LeftD fakeErr) step₁ step₁ liws = do -- TODO-2: Make an EitherD variant of putLedgerInfo and make D version default ls ← fromEither $ LedgerStore.putLedgerInfo (self ^∙ ddbLedgerStore) liws RightD (self & ddbLedgerStore ∙~ (ls & lsLatestLedgerInfo ?~ liws)) E : VariantFor Either E = toEither step₀ D : VariantFor EitherD D = fromEither E saveTransactions = saveTransactions.D
{ "alphanum_fraction": 0.6663188648, "avg_line_length": 42.407079646, "ext": "agda", "hexsha": "16978e7678b4b9b5360ef28759e1fefdfe6ef392", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_forks_repo_path": "src/LibraBFT/Impl/Storage/DiemDB/DiemDB.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_issues_repo_path": "src/LibraBFT/Impl/Storage/DiemDB/DiemDB.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_stars_repo_path": "src/LibraBFT/Impl/Storage/DiemDB/DiemDB.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1289, "size": 4792 }
{-# OPTIONS --safe #-} module Cubical.Data.FinSet.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Function open import Cubical.Foundations.Structure open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.Equiv open import Cubical.HITs.PropositionalTruncation open import Cubical.Data.Nat open import Cubical.Data.Unit open import Cubical.Data.Empty renaming (rec to EmptyRec) open import Cubical.Data.Sigma open import Cubical.Data.Fin open import Cubical.Data.SumFin renaming (Fin to SumFin) hiding (discreteFin) open import Cubical.Data.FinSet.Base open import Cubical.Relation.Nullary open import Cubical.Relation.Nullary.DecidableEq open import Cubical.Relation.Nullary.HLevels private variable ℓ ℓ' ℓ'' : Level A : Type ℓ B : Type ℓ' -- infix operator to more conveniently compose equivalences _⋆_ = compEquiv infixr 30 _⋆_ -- useful implications EquivPresIsFinSet : A ≃ B → isFinSet A → isFinSet B EquivPresIsFinSet e = rec isPropIsFinSet (λ (n , p) → ∣ n , compEquiv (invEquiv e) p ∣) isFinSetFin : {n : ℕ} → isFinSet (Fin n) isFinSetFin = ∣ _ , pathToEquiv refl ∣ isFinSetUnit : isFinSet Unit isFinSetUnit = ∣ 1 , Unit≃Fin1 ∣ isFinSet→Discrete : isFinSet A → Discrete A isFinSet→Discrete = rec isPropDiscrete (λ (_ , p) → EquivPresDiscrete (invEquiv p) discreteFin) isContr→isFinSet : isContr A → isFinSet A isContr→isFinSet h = ∣ 1 , isContr→≃Unit* h ⋆ invEquiv (Unit≃Unit* ) ⋆ Unit≃Fin1 ∣ isDecProp→isFinSet : isProp A → Dec A → isFinSet A isDecProp→isFinSet h (yes p) = isContr→isFinSet (inhProp→isContr p h) isDecProp→isFinSet h (no ¬p) = ∣ 0 , uninhabEquiv ¬p ¬Fin0 ∣ {- Alternative definition of finite sets A set is finite if it is merely equivalent to `Fin n` for some `n`. We can translate this to code in two ways: a truncated sigma of a nat and an equivalence, or a sigma of a nat and a truncated equivalence. We prove that both formulations are equivalent. -} isFinSet' : Type ℓ → Type ℓ isFinSet' A = Σ[ n ∈ ℕ ] ∥ A ≃ Fin n ∥ FinSet' : (ℓ : Level) → Type (ℓ-suc ℓ) FinSet' ℓ = TypeWithStr _ isFinSet' isPropIsFinSet' : isProp (isFinSet' A) isPropIsFinSet' {A = A} (n , equivn) (m , equivm) = Σ≡Prop (λ _ → isPropPropTrunc) n≡m where Fin-n≃Fin-m : ∥ Fin n ≃ Fin m ∥ Fin-n≃Fin-m = rec isPropPropTrunc (rec (isPropΠ λ _ → isPropPropTrunc) (λ hm hn → ∣ Fin n ≃⟨ invEquiv hn ⟩ A ≃⟨ hm ⟩ Fin m ■ ∣) equivm ) equivn Fin-n≡Fin-m : ∥ Fin n ≡ Fin m ∥ Fin-n≡Fin-m = rec isPropPropTrunc (∣_∣ ∘ ua) Fin-n≃Fin-m ∥n≡m∥ : ∥ n ≡ m ∥ ∥n≡m∥ = rec isPropPropTrunc (∣_∣ ∘ Fin-inj n m) Fin-n≡Fin-m n≡m : n ≡ m n≡m = rec (isSetℕ n m) (λ p → p) ∥n≡m∥ -- logical equivalence of two definitions isFinSet→isFinSet' : isFinSet A → isFinSet' A isFinSet→isFinSet' ∣ n , equiv ∣ = n , ∣ equiv ∣ isFinSet→isFinSet' (squash p q i) = isPropIsFinSet' (isFinSet→isFinSet' p) (isFinSet→isFinSet' q) i isFinSet'→isFinSet : isFinSet' A → isFinSet A isFinSet'→isFinSet (n , ∣ isFinSet-A ∣) = ∣ n , isFinSet-A ∣ isFinSet'→isFinSet (n , squash p q i) = isPropIsFinSet (isFinSet'→isFinSet (n , p)) (isFinSet'→isFinSet (n , q)) i isFinSet≡isFinSet' : isFinSet A ≡ isFinSet' A isFinSet≡isFinSet' {A = A} = hPropExt isPropIsFinSet isPropIsFinSet' isFinSet→isFinSet' isFinSet'→isFinSet FinSet→FinSet' : FinSet ℓ → FinSet' ℓ FinSet→FinSet' (A , isFinSetA) = A , isFinSet→isFinSet' isFinSetA FinSet'→FinSet : FinSet' ℓ → FinSet ℓ FinSet'→FinSet (A , isFinSet'A) = A , isFinSet'→isFinSet isFinSet'A FinSet≃FinSet' : FinSet ℓ ≃ FinSet' ℓ FinSet≃FinSet' = isoToEquiv (iso FinSet→FinSet' FinSet'→FinSet (λ _ → Σ≡Prop (λ _ → isPropIsFinSet') refl) (λ _ → Σ≡Prop (λ _ → isPropIsFinSet) refl)) FinSet≡FinSet' : FinSet ℓ ≡ FinSet' ℓ FinSet≡FinSet' = ua FinSet≃FinSet' -- cardinality of finite sets card : FinSet ℓ → ℕ card = fst ∘ snd ∘ FinSet→FinSet' -- definitions to reduce problems about FinSet to SumFin ≃Fin : Type ℓ → Type ℓ ≃Fin A = Σ[ n ∈ ℕ ] A ≃ Fin n ≃SumFin : Type ℓ → Type ℓ ≃SumFin A = Σ[ n ∈ ℕ ] A ≃ SumFin n ≃Fin→SumFin : ≃Fin A → ≃SumFin A ≃Fin→SumFin (n , e) = n , compEquiv e (invEquiv (SumFin≃Fin _)) ≃SumFin→Fin : ≃SumFin A → ≃Fin A ≃SumFin→Fin (n , e) = n , compEquiv e (SumFin≃Fin _) transpFamily : {A : Type ℓ}{B : A → Type ℓ'} → ((n , e) : ≃SumFin A) → (x : A) → B x ≃ B (invEq e (e .fst x)) transpFamily {B = B} (n , e) x = pathToEquiv (λ i → B (retEq e x (~ i)))
{ "alphanum_fraction": 0.6762259194, "avg_line_length": 29.8562091503, "ext": "agda", "hexsha": "d0064b1c52d105bbf7325b9022f70204022663bd", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Seanpm2001-web/cubical", "max_forks_repo_path": "Cubical/Data/FinSet/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "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": "Seanpm2001-web/cubical", "max_issues_repo_path": "Cubical/Data/FinSet/Properties.agda", "max_line_length": 114, "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/Data/FinSet/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z", "num_tokens": 1812, "size": 4568 }
open import Data.Boolean open import Type module Data.List.Sorting.SelectionSort {ℓ} {T : Type{ℓ}} (_≤?_ : T → T → Bool) where import Lvl open import Data.List open import Data.List.Functions as List using (_++_) import Data.List.Functions.Multi as List open import Data.List.Sorting.Functions(_≤?_) open import Data.Option open import Data.Tuple import Numeral.Finite.Conversions as 𝕟 open import Functional using (_∘_) {-# TERMINATING #-} selectionSort : List(T) → List(T) selectionSort l with extractMinimal l ... | Some(x , xs) = x ⊰ selectionSort(xs) ... | None = l module Proofs where
{ "alphanum_fraction": 0.7071197411, "avg_line_length": 26.8695652174, "ext": "agda", "hexsha": "3dc3adc5cbfe1da27b25fcc6759401e3b85c90a6", "lang": "Agda", "max_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": "Data/List/Sorting/SelectionSort.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": "Data/List/Sorting/SelectionSort.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": "Data/List/Sorting/SelectionSort.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": 169, "size": 618 }
module Induct where open import Data.Nat open import Data.Sum open import Relation.Binary.PropositionalEquality {- The downward closure of a set. -} data downset : (ℕ → Set) → ℕ → Set where downset-lit : {φ : ℕ → Set} → {x : ℕ} → φ x → downset φ x downset-pred : {φ : ℕ → Set} → {x : ℕ} → downset φ (suc x) → downset φ x {- Example 1: The downset of a downset is itself. Simple induction. -} downset-downset : ∀ {φ} → ∀ {x} → downset (downset φ) x → downset φ x downset-downset (downset-lit p) = p downset-downset (downset-pred p) = downset-pred (downset-downset p) {- Example 2: Downsets are downward closed. Needs lemmata. -} lemma-larger : ∀ x y → x ≤ y → (suc x ≤ y) ⊎ (x ≡ y) lemma-larger 0 0 z≤n = inj₂ refl lemma-larger 0 (suc y) z≤n = inj₁ (s≤s z≤n) lemma-larger (suc x) (suc y) (s≤s x-leq-y) with lemma-larger x y x-leq-y lemma-larger (suc x) (suc y) (s≤s x-leq-y) | inj₁ sx-leq-y = inj₁ (s≤s sx-leq-y) lemma-larger (suc x) (suc y) (s≤s x-leq-y) | inj₂ x-eq-y = inj₂ (cong suc x-eq-y) downset-zero : ∀ {φ} → ∀ y → downset φ y → downset φ zero downset-zero zero d-phi-y = d-phi-y downset-zero (suc y) d-phi-y = downset-zero y (downset-pred d-phi-y) downset-downward-closed : ∀ {φ} → ∀ x y → downset φ y → x ≤ y → downset φ x downset-downward-closed 0 y d-phi-y x-leq-y = downset-zero y d-phi-y downset-downward-closed (suc x) (suc y) d-phi-y (s≤s x-leq-y) with lemma-larger x y x-leq-y ... | inj₁ sx-leq-y = downset-downward-closed (suc x) y (downset-pred d-phi-y) sx-leq-y ... | inj₂ refl = d-phi-y
{ "alphanum_fraction": 0.6427631579, "avg_line_length": 43.4285714286, "ext": "agda", "hexsha": "a5cee158283ad4273214770c9ab30e8bf42a80cf", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "3992f5c15305c5d1ae3dcaa657defc7c92ef0a07", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "zaklogician/induct-agda-isabelle", "max_forks_repo_path": "Induct.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3992f5c15305c5d1ae3dcaa657defc7c92ef0a07", "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": "zaklogician/induct-agda-isabelle", "max_issues_repo_path": "Induct.agda", "max_line_length": 87, "max_stars_count": null, "max_stars_repo_head_hexsha": "3992f5c15305c5d1ae3dcaa657defc7c92ef0a07", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "zaklogician/induct-agda-isabelle", "max_stars_repo_path": "Induct.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 616, "size": 1520 }
{-# OPTIONS --cubical --safe #-} open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Path open import Cubical.Foundations.Isomorphism renaming (Iso to _≅_) open import Cubical.Foundations.Equiv open import Cubical.Foundations.Univalence open import Cubical.Foundations.HLevels open import Cubical.Functions.FunExtEquiv open import Cubical.Data.Unit open import Cubical.Data.Sigma open import Cubical.Data.Nat module Cubical.Data.W.Indexed where open _≅_ private variable ℓX ℓS ℓP : Level module Types {X : Type ℓX} (S : X → Type ℓS) (P : ∀ x → S x → Type ℓP) (inX : ∀ x (s : S x) → P x s → X) where data IW (x : X) : Type (ℓ-max ℓX (ℓ-max ℓS ℓP)) where node : (s : S x) → (subtree : (p : P x s) → IW (inX x s p)) → IW x Subtree : ∀ {x} → (s : S x) → Type (ℓ-max (ℓ-max ℓX ℓS) ℓP) Subtree {x} s = (p : P x s) → IW (inX x s p) RepIW : (x : X) → Type (ℓ-max (ℓ-max ℓX ℓS) ℓP) RepIW x = Σ[ s ∈ S x ] Subtree s open Types public module _ {X : Type ℓX} {S : X → Type ℓS} {P : ∀ x → S x → Type ℓP} {inX : ∀ x (s : S x) → P x s → X} where getShape : ∀ {x} → IW S P inX x → S x getShape (node s subtree) = s getSubtree : ∀ {x} → (w : IW S P inX x) → (p : P x (getShape w)) → IW S P inX (inX x (getShape w) p) getSubtree (node s subtree) = subtree wExt : ∀ {x} (w w' : IW S P inX x) → (ps : getShape w ≡ getShape w') → (pw : PathP (λ i → Subtree S P inX (ps i)) (getSubtree w) (getSubtree w')) → w ≡ w' wExt (node s subtree) (node s' subtree') ps psubtree = cong₂ node ps psubtree isoRepIW : (x : X) → IW S P inX x ≅ RepIW S P inX x fun (isoRepIW x) (node s subtree) = s , subtree inv (isoRepIW x) (s , subtree) = node s subtree rightInv (isoRepIW x) (s , subtree) = refl leftInv (isoRepIW x) (node s subtree) = refl equivRepIW : (x : X) → IW S P inX x ≃ RepIW S P inX x equivRepIW x = isoToEquiv (isoRepIW x) pathRepIW : (x : X) → IW S P inX x ≡ RepIW S P inX x pathRepIW x = ua (equivRepIW x) isPropIW : (∀ x → isProp (S x)) → ∀ x → isProp (IW S P inX x) isPropIW isPropS x (node s subtree) (node s' subtree') = cong₂ node (isPropS x s s') (toPathP (funExt λ p → isPropIW isPropS _ _ (subtree' p))) module IWPathTypes {X : Type ℓX} (S : X → Type ℓS) (P : ∀ x → S x → Type ℓP) (inX : ∀ x (s : S x) → P x s → X) where --somewhat inspired by https://github.com/jashug/IWTypes , but different. IndexCover : Type (ℓ-max (ℓ-max ℓX ℓS) ℓP) IndexCover = Σ[ x ∈ X ] IW S P inX x × IW S P inX x ShapeCover : IndexCover → Type ℓS ShapeCover (x , w , w') = getShape w ≡ getShape w' ArityCover : ∀ xww' → ShapeCover xww' → Type ℓP ArityCover (x , w , w') ps = P x (getShape w') inXCover : ∀ xww' → (ps : ShapeCover xww') → ArityCover xww' ps → IndexCover inXCover (x , w , w') ps p = (inX x (getShape w') p) , (subst (Subtree S P inX) ps (getSubtree w) p , getSubtree w' p) Cover : ∀ {x : X} → (w w' : IW S P inX x) → Type (ℓ-max (ℓ-max ℓX ℓS) ℓP) Cover {x} w w' = IW ShapeCover ArityCover inXCover (x , w , w') module IWPath {X : Type ℓX} {S : X → Type ℓS} {P : ∀ x → S x → Type ℓP} {inX : ∀ x (s : S x) → P x s → X} where open IWPathTypes S P inX isoEncode : ∀ {x} (w w' : IW S P inX x) → (w ≡ w') ≅ Cover w w' isoEncodeSubtree : ∀ {x} (w w' : IW S P inX x) (ps : ShapeCover (x , w , w')) → (PathP (λ i → Subtree S P inX (ps i)) (getSubtree w) (getSubtree w')) ≅ (∀ (p : P x (getShape w')) → IW ShapeCover ArityCover inXCover (inXCover (x , w , w') ps p)) isoEncodeSubtree w w'@(node s' subtree') ps = PathPIsoPath (λ i → Subtree S P inX (ps i)) (getSubtree w) (getSubtree w') ⟫ invIso (funExtIso) ⟫ codomainIsoDep (λ p → isoEncode _ (subtree' p)) where _⟫_ = compIso infixr 10 _⟫_ fun (isoEncode w@(node s subtree) w'@(node s' subtree')) pw = node (cong getShape pw) (fun (isoEncodeSubtree w w' (cong getShape pw)) (cong getSubtree pw)) inv (isoEncode w@(node s subtree) w'@(node s' subtree')) cw@(node ps csubtree) = cong₂ node ps (inv (isoEncodeSubtree w w' ps) csubtree) rightInv (isoEncode w@(node s subtree) w'@(node s' subtree')) cw@(node ps csubtree) = cong (node ps) ( fun (isoEncodeSubtree w w' ps) (inv (isoEncodeSubtree w w' ps) csubtree) ≡⟨ rightInv (isoEncodeSubtree w w' ps) csubtree ⟩ csubtree ∎ ) leftInv (isoEncode w@(node s subtree) w'@(node s' subtree')) pw = cong₂ node (cong getShape pw) (inv (isoEncodeSubtree w w' (cong getShape pw)) (fun (isoEncodeSubtree w w' (cong getShape pw)) (cong getSubtree pw) ) ) ≡⟨ cong (cong₂ node (cong getShape pw)) (leftInv (isoEncodeSubtree w w' (cong getShape pw)) (cong getSubtree pw)) ⟩ cong₂ node (cong getShape pw) (cong getSubtree pw) ≡⟨ flipSquare (λ i → wExt (node (getShape (pw i)) (getSubtree (pw i))) (pw i) refl refl) ⟩ pw ∎ encode : ∀ {x} (w w' : IW S P inX x) → w ≡ w' → Cover w w' encode w w' = fun (isoEncode w w') decode : ∀ {x} (w w' : IW S P inX x) → Cover w w' → w ≡ w' decode w w' = inv (isoEncode w w') decodeEncode : ∀ {x} (w w' : IW S P inX x) → (pw : w ≡ w') → decode w w' (encode w w' pw) ≡ pw decodeEncode w w' = leftInv (isoEncode w w') encodeDecode : ∀ {x} (w w' : IW S P inX x) → (cw : Cover w w') → encode w w' (decode w w' cw) ≡ cw encodeDecode w w' = rightInv (isoEncode w w') equivEncode : ∀ {x} (w w' : IW S P inX x) → (w ≡ w') ≃ Cover w w' equivEncode w w' = isoToEquiv (isoEncode w w') pathEncode : ∀ {x} (w w' : IW S P inX x) → (w ≡ w') ≡ Cover w w' pathEncode w w' = ua (equivEncode w w') open IWPathTypes open IWPath isOfHLevelSuc-IW : {X : Type ℓX} {S : X → Type ℓS} {P : ∀ x → S x → Type ℓP} {inX : ∀ x (s : S x) → P x s → X} → (n : HLevel) → (∀ x → isOfHLevel (suc n) (S x)) → ∀ x → isOfHLevel (suc n) (IW S P inX x) isOfHLevelSuc-IW zero isHS x = isPropIW isHS x isOfHLevelSuc-IW (suc n) isHS x w w' = subst (isOfHLevel (suc n)) (λ i → pathEncode w w' (~ i)) (isOfHLevelSuc-IW n (λ (y , v , v') → isHS y (getShape v) (getShape v')) (x , w , w') )
{ "alphanum_fraction": 0.5913100294, "avg_line_length": 40.5430463576, "ext": "agda", "hexsha": "71a56811ff78d2e7d2e98034906a3b345e157f65", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Data/W/Indexed.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Data/W/Indexed.agda", "max_line_length": 121, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Data/W/Indexed.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 2463, "size": 6122 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Agda.Primitive using (Level; lzero; lsuc; _⊔_; Setω) open import Setoids.Setoids open import Setoids.Subset open import Setoids.Functions.Definition open import LogicalFormulae open import Functions open import Lists.Lists open import Setoids.Orders open import Rings.Orders.Partial.Definition open import Rings.Definition module LectureNotes.MetAndTop.Chapter2 {a b c : _} {R : Set a} {S : Setoid {a} {b} R} {_<_ : Rel {a} {c} R} {_+_ _*_ : R → R → R} {ring : Ring S _+_ _*_} {ps : SetoidPartialOrder S _<_} (pRing : PartiallyOrderedRing ring ps) where open Setoid S renaming (_∼_ to _∼R_) open Ring ring record Metric {d1 e : _} {A : Set d1} {T : Setoid {d1} {e} A} (d : A → A → R) : Set (a ⊔ b ⊔ c ⊔ d1 ⊔ e) where open Setoid T field dWellDefined : (x y v w : A) → x ∼ y → v ∼ w → (d x v) ∼R (d w y) dZero : (x y : A) → (d x y) ∼R 0R → x ∼ y dZero' : (x y : A) → x ∼ y → (d x y) ∼R 0R dSymmetric : (x y : A) → (d x y) ∼R (d y x) dTriangle : (x y z : A) → ((d x z) < ((d x y) + (d y z))) || ((d x z) ∼R ((d x y) + (d y z))) dNonnegative : (x y : A) → (0R < d x y) || (0R ∼R (d x y)) dNonnegative x y = {!!}
{ "alphanum_fraction": 0.5892116183, "avg_line_length": 40.1666666667, "ext": "agda", "hexsha": "3c5d665af2f4a8aa908a8462d6007461465c590a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "LectureNotes/MetAndTop/Chapter2.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "LectureNotes/MetAndTop/Chapter2.agda", "max_line_length": 230, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "LectureNotes/MetAndTop/Chapter2.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 485, "size": 1205 }
-- Andreas, 2017-08-13, issue #2686 -- Overloaded constructor where only one alternative is not abstract. -- Not ambiguous, since abstract constructors are not in scope! -- {-# OPTIONS -v tc.check.term:40 #-} abstract data A : Set where c : A data D : Set where c : D test = c match : D → D match c = c
{ "alphanum_fraction": 0.6613924051, "avg_line_length": 17.5555555556, "ext": "agda", "hexsha": "2368e995ee5c5449d9308baeccda21314a82a308", "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/Issue2686.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/Issue2686.agda", "max_line_length": 69, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue2686.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": 92, "size": 316 }
module Prelude.Nat where open import Prelude.Unit open import Prelude.Empty open import Prelude.Bool open import Prelude.Decidable open import Prelude.Equality open import Prelude.Equality.Unsafe using (eraseEquality) open import Prelude.Ord open import Prelude.Number open import Prelude.Semiring open import Prelude.Function open import Prelude.Smashed open import Prelude.Nat.Properties open import Prelude.Nat.Core public --- Equality --- private eqNatSound : ∀ n m → IsTrue (eqNat n m) → n ≡ m eqNatSound zero zero _ = refl eqNatSound zero (suc m) () eqNatSound (suc n) zero () eqNatSound (suc n) (suc m) p rewrite eqNatSound n m p = refl eqNatComplete : ∀ n m → IsFalse (eqNat n m) → ¬ (n ≡ m) eqNatComplete zero zero () eq eqNatComplete zero (suc m) neq () eqNatComplete (suc n) zero neq () eqNatComplete (suc n) (suc m) neq eq = eqNatComplete n m neq (suc-inj eq) decEqNat : (n m : Nat) → Dec (n ≡ m) decEqNat n m with eqNat n m | eqNatSound n m | eqNatComplete n m ... | true | eq | _ = yes (eraseEquality (eq true)) ... | false | _ | neq = no (eraseNegation (neq false)) {-# INLINE decEqNat #-} instance EqNat : Eq Nat _==_ {{EqNat}} = decEqNat --- Comparison --- data LessNat n m : Set where diff : ∀ k (eq : m ≡ suc k +N n) → LessNat n m {-# DISPLAY LessNat a b = a < b #-} pattern diff! k = diff k refl private lemLessNatMinus : ∀ n m → IsTrue (lessNat n m) → m ≡ suc (m - suc n) + n lemLessNatMinus _ zero () lemLessNatMinus zero (suc m) _ = sym (suc $≡ add-zero-r m) lemLessNatMinus (suc n) (suc m) n<m = suc $≡ (lemLessNatMinus n m n<m ⟨≡⟩ʳ add-suc-r (m - suc n) n) lemNoLessEqual : ∀ n m → ¬ IsTrue (lessNat n m) → ¬ IsTrue (lessNat m n) → n ≡ m lemNoLessEqual zero zero _ _ = refl lemNoLessEqual zero (suc m) h₁ h₂ = ⊥-elim (h₁ true) lemNoLessEqual (suc n) zero h₁ h₂ = ⊥-elim (h₂ true) lemNoLessEqual (suc n) (suc m) h₁ h₂ = cong suc (lemNoLessEqual n m h₁ h₂) -- Using eraseEquality here lets us not worry about the performance of the -- proofs. compareNat : ∀ n m → Comparison LessNat n m compareNat n m with decBool (lessNat n m) ... | yes p = less (diff (m - suc n) (eraseEquality (lemLessNatMinus n m p))) ... | no np₁ with decBool (lessNat m n) ... | yes p = greater (diff (n - suc m) (eraseEquality (lemLessNatMinus m n p))) ... | no np₂ = equal (eraseEquality (lemNoLessEqual n m np₁ np₂)) {-# INLINE compareNat #-} private nat-lt-to-leq : ∀ {x y} → LessNat x y → LessNat x (suc y) nat-lt-to-leq (diff k eq) = diff (suc k) (cong suc eq) nat-eq-to-leq : ∀ {x y} → x ≡ y → LessNat x (suc y) nat-eq-to-leq eq = diff 0 (cong suc (sym eq)) nat-from-leq : ∀ {x y} → LessNat x (suc y) → LessEq LessNat x y nat-from-leq (diff zero eq) = equal (sym (suc-inj eq)) nat-from-leq (diff (suc k) eq) = less (diff k (suc-inj eq)) nat-lt-antirefl : ∀ {a} → LessNat a a → ⊥ nat-lt-antirefl {a} (diff k eq) = case add-inj₁ 0 (suc k) a eq of λ () nat-lt-antisym : ∀ {a b} → LessNat a b → LessNat b a → ⊥ nat-lt-antisym {a} (diff! k) (diff j eq) = case add-inj₁ 0 (suc j + suc k) a (eq ⟨≡⟩ suc $≡ add-assoc j (suc k) a) of λ () nat-lt-trans : ∀ {a b c} → LessNat a b → LessNat b c → LessNat a c nat-lt-trans (diff k eq) (diff j eq₁) = diff (j + suc k) (eraseEquality (case eq of λ where refl → case eq₁ of λ where refl → add-assoc (suc j) (suc k) _)) instance OrdNat : Ord Nat Ord._<_ OrdNat = LessNat Ord._≤_ OrdNat a b = LessNat a (suc b) Ord.compare OrdNat = compareNat Ord.eq-to-leq OrdNat = nat-eq-to-leq Ord.lt-to-leq OrdNat = nat-lt-to-leq Ord.leq-to-lteq OrdNat = nat-from-leq OrdNatLaws : Ord/Laws Nat Ord/Laws.super OrdNatLaws = it less-antirefl {{OrdNatLaws}} = nat-lt-antirefl less-trans {{OrdNatLaws}} = nat-lt-trans instance SmashedNatLess : {a b : Nat} → Smashed (a < b) smashed {{SmashedNatLess}} {diff! k} {diff k₁ eq} with add-inj₁ (suc k) (suc k₁) _ eq | eq ... | refl | refl = refl SmashedNatComp : {a b : Nat} → Smashed (Comparison _<_ a b) smashed {{SmashedNatComp}} {less _ } {less _ } = less $≡ smashed smashed {{SmashedNatComp}} {less lt } {equal refl} = ⊥-elim (less-antirefl {A = Nat} lt) smashed {{SmashedNatComp}} {less lt } {greater gt} = ⊥-elim (less-antisym {A = Nat} lt gt) smashed {{SmashedNatComp}} {equal refl} {less lt } = ⊥-elim (less-antirefl {A = Nat} lt) smashed {{SmashedNatComp}} {equal _ } {equal _ } = equal $≡ smashed smashed {{SmashedNatComp}} {equal refl} {greater gt} = ⊥-elim (less-antirefl {A = Nat} gt) smashed {{SmashedNatComp}} {greater gt} {less lt } = ⊥-elim (less-antisym {A = Nat} lt gt) smashed {{SmashedNatComp}} {greater gt} {equal refl} = ⊥-elim (less-antirefl {A = Nat} gt) smashed {{SmashedNatComp}} {greater _ } {greater _ } = greater $≡ smashed suc-monotone : {a b : Nat} → a < b → Nat.suc a < suc b suc-monotone (diff! k) = diff k (sym (add-suc-r (suc k) _)) inv-suc-monotone : ∀{t v} → suc t < suc v → t < v inv-suc-monotone (diff! k) = diff k (add-suc-r k _) suc-comparison : {a b : Nat} → Comparison _<_ a b → Comparison _<_ (Nat.suc a) (suc b) suc-comparison (less lt) = less (suc-monotone lt) suc-comparison (equal eq) = equal (suc $≡ eq) suc-comparison (greater gt) = greater (suc-monotone gt)
{ "alphanum_fraction": 0.6277290539, "avg_line_length": 39.1167883212, "ext": "agda", "hexsha": "781b58cc4e42ff7f8c2bb36d68fd101632c526e3", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_path": "src/Prelude/Nat.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_path": "src/Prelude/Nat.agda", "max_line_length": 101, "max_stars_count": 111, "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_path": "src/Prelude/Nat.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 1974, "size": 5359 }
open import Oscar.Prelude open import Oscar.Data.Proposequality open import Oscar.Class.Congruity module Oscar.Class.Congruity.Proposequality where instance 𝓒ongruityProposequality : ∀ {a b} → 𝓒ongruity Proposequality a b 𝓒ongruityProposequality .𝓒ongruity.congruity _ ∅ = ! 𝓒ongruity₂Proposequality : ∀ {a b c} → 𝓒ongruity₂ Proposequality a b c 𝓒ongruity₂Proposequality .𝓒ongruity₂.congruity₂ _ ∅ ∅ = !
{ "alphanum_fraction": 0.7841726619, "avg_line_length": 27.8, "ext": "agda", "hexsha": "f09db044bd06756bc5b3790100220861d32f417c", "lang": "Agda", "max_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/Congruity/Proposequality.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/Congruity/Proposequality.agda", "max_line_length": 72, "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/Congruity/Proposequality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 155, "size": 417 }
module Data.DynamicTree where import Lvl open import Data.List open import Data.Option open import Functional as Fn open import Type private variable ℓ ℓᵢ : Lvl.Level private variable T A B : Type{ℓ} data Node (T : Type{ℓ}) : Type{ℓ} where node : T → List(Node(T)) → Node(T) DynamicTree : Type{ℓ} → Type{ℓ} DynamicTree(T) = Option(Node(T))
{ "alphanum_fraction": 0.7037037037, "avg_line_length": 20.6470588235, "ext": "agda", "hexsha": "45751f91c93f28ebe77e137ab7d1b250a241256e", "lang": "Agda", "max_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": "Data/DynamicTree.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": "Data/DynamicTree.agda", "max_line_length": 39, "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": "Data/DynamicTree.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": 110, "size": 351 }
{-# OPTIONS --copatterns #-} -- {-# OPTIONS -v tc.pos:20 -v tc.meta.eta:100 #-} -- {-# OPTIONS -v tc.lhs:100 #-} module LinearTemporalLogic where import Common.Level record Stream (A : Set) : Set where coinductive field head : A tail : Stream A -- Stream properties Proposition : Set → Set₁ Proposition A = Stream A → Set Now : {A : Set} → (A → Set) → Proposition A Now P s = P (Stream.head s) -- Next time ◌ : {A : Set} → Proposition A → Proposition A ◌ P s = P (Stream.tail s) -- Forever record ▢ {A : Set} (P : Proposition A) (s : Stream A) : Set where coinductive field head : P s tail : ◌ (▢ P) s -- Sometimes data ◇ {A : Set} (P : Proposition A) (s : Stream A) : Set where now : P s → ◇ P s later : ◌ (◇ P) s → ◇ P s -- Infinitely often ▢◇ : {A : Set} → Proposition A → Proposition A ▢◇ P = ▢ (◇ P) -- Next inf. often implies inf. often ◌▢◇⇒▢◇ : {A : Set}{P : Proposition A}{s : Stream A} → ◌ (▢◇ P) s → ▢◇ P s ▢.head (◌▢◇⇒▢◇ f) = later (▢.head f) ▢.tail (◌▢◇⇒▢◇ f) = ◌▢◇⇒▢◇ (▢.tail f) -- Forever implies inf. oft. ▢⇒▢◇ : {A : Set}{P : Proposition A}{s : Stream A} → ▢ P s → ▢◇ P s ▢.head (▢⇒▢◇ f) = now (▢.head f) ▢.tail (▢⇒▢◇ f) = ▢⇒▢◇ (▢.tail f) -- Eventually ◇▢ : {A : Set} → Proposition A → Proposition A ◇▢ P = ◇ (▢ P) -- Eventually implies inf. oft. ◇▢⇒▢◇ : {A : Set}{P : Proposition A}{s : Stream A} → ◇▢ P s → ▢◇ P s ◇▢⇒▢◇ (now forever) = ▢⇒▢◇ forever ◇▢⇒▢◇ (later event) = ◌▢◇⇒▢◇ (◇▢⇒▢◇ event) -- We now prove that inf. oft. does not imply eventually -- by exhibiting a counter example data ⊥ : Set where record ⊤ : Set where constructor tt data Bool : Set where true false : Bool True : Bool → Set True true = ⊤ True false = ⊥ open Stream alternate : Stream Bool ( (head alternate)) = true (head (tail alternate)) = false (tail (tail alternate)) = alternate -- alternate contains infinitely many 'true's thm1 : ▢◇ (Now True) alternate ( (▢.head thm1)) = now tt (▢.head (▢.tail thm1)) = later (now tt) (▢.tail (▢.tail thm1)) = thm1 -- alternate does not eventually contain only 'true's mutual thm2 : ◇▢ (Now True) alternate → ⊥ thm2 (now forever⊤) = ▢.head (▢.tail forever⊤) thm2 (later event) = thm2′ event thm2′ : ◇▢ (Now True) (tail alternate) → ⊥ thm2′ (now forever⊤) = ▢.head forever⊤ thm2′ (later event) = thm2 event
{ "alphanum_fraction": 0.5686106346, "avg_line_length": 23.5555555556, "ext": "agda", "hexsha": "2b7fb55bb42f7b9ead1bb42c4c1edcedad0e07b0", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/LinearTemporalLogic.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Succeed/LinearTemporalLogic.agda", "max_line_length": 65, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/LinearTemporalLogic.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 1000, "size": 2332 }
module HC-Lec1 where -- ============================================================================== -- Lecture 1 : Programs and Proofs -- https://www.youtube.com/watch?v=O4oczQry9Jw&t=1412s ------------------------------------------------------------------------------ -- some basic logical types -- 13:22 -- like Haskell Void data Zero : Set where -- No constructors, so no inhabitants -- Represents logical impossibility. -- 16:45 -- like Haskell () record One : Set where constructor <> -- added in video Lecture 2 4:50 -- This record has no fields. -- This record has exactly one inhabitant. -- 18:42 -- like Haskell Either data _+_ (S : Set) (T : Set) : Set where inl : S -> S + T -- left constructor inr : T -> S + T -- right constructor -- 24:50 -- like Haskell pair ( , ) record _*_ (S : Set) (T : Set) : Set where constructor _,_ -- added in video Lecture 2 4:58 field fst : S snd : T ------------------------------------------------------------------------------ -- examples -- 28:36 comm-* : {A : Set} {B : Set} -> A * B -> B * A comm-* record { fst = a ; snd = b } = record { fst = b ; snd = a } -- 43:00 assocLR-+ : {A B C : Set} -> (A + B) + C -> A + (B + C) assocLR-+ (inl (inl a)) = inl a assocLR-+ (inl (inr b)) = inr (inl b) assocLR-+ (inr c) = inr (inr c) -- 47:34 -- If you can arrive at a contradiction, then you can derive any conclusion. -- Given a Zero, must produce an X for ANY X. -- But there are no inhabitants of Zero. -- So use 'absurd' pattern that indicates something that is IMPOSSIBLE. naughtE : {X : Set} -> Zero -> X naughtE () -- standard composition: f << g is "f after g" _<<_ : {X Y Z : Set} -> (Y -> Z) -> (X -> Y) -> (X -> Z) (f << g) x = f (g x) -- diagrammatic composition: f >> g is "f then g" _>>_ : {X Y Z : Set} -> (X -> Y) -> (Y -> Z) -> (X -> Z) -- ^^^^^^^^ dominoes! (f >> g) x = g (f x) -- infix application _$_ : {S : Set}{T : S -> Set}(f : (x : S) -> T x)(s : S) -> T s f $ s = f s infixl 2 _$_ -- ============================================================================== -- Lecture 2 : more Programs and Proof, Introducing "with" -- https://www.youtube.com/watch?v=qcVZxQTouDk -- 2:25 _$*_ : {A A' B B' : Set} -> (A -> A') -> (B -> B') -> A * B -> A' * B' (a→a' $* b→b') (a , b) = (a→a' a) , (b→b' b) -- 6:53 _$+_ : {A A' B B' : Set} -> (A -> A') -> (B -> B') -> A + B -> A' + B' (a→a' $+ b→b') (inl a) = inl (a→a' a) (a→a' $+ b→b') (inr b) = inr (b→b' b) -- 8:52 -- like Haskell const ; this is pure for applicative functor needing an E combinatorK : {A E : Set} -> A -> E -> A combinatorK a _ = a -- 11:25 -- this is application combinatorS : {S T E : Set} -> (E -> S -> T) -> (E -> S) -> E -> T combinatorS e→s→t e→s e = e→s→t e (e→s e) -- 14:50 idK : {X : Set} -> X -> X idK x = combinatorK x x -- 19:00 idSKK : {X : Set} -> X -> X idSKK {X} = combinatorS combinatorK (combinatorK {E = X}) -- 'Zero' and 'One' also work id : {X : Set} -> X -> X -- id x = x -- is the easy way; let's do it a funny way to make a point id = combinatorS combinatorK (combinatorK {_} {Zero}) -- no choice for -^ ^^^^- could be anything -- 30:25 -- naughtE ------------------------------------------------------------------------------ -- from logic to data -- 32:05 data Nat : Set where zero : Nat suc : Nat -> Nat -- recursive data type {-# BUILTIN NATURAL Nat #-} -- enables decimal notation -- 32:58 _+N_ : Nat -> Nat -> Nat zero +N y = y suc x +N y = suc (x +N y) four : Nat four = 2 +N 2 ------------------------------------------------------------------------------ -- and back to logic -- 36:46 data _==_ {X : Set} : X -> X -> Set where refl : (x : X) -> x == x -- the relation that is "only reflexive" {-# BUILTIN EQUALITY _==_ #-} see4 : (2 +N 2) == 4 see4 = refl 4 -- 42:35 -- application of equalities _=$=_ : {X Y : Set} {f f' : X -> Y} {x x' : X} -> f == f' -> x == x' -> f x == f' x refl f =$= refl x = refl (f x) ------------------------------------------------------------------------------ -- computing types -- 45:00 _>=_ : Nat -> Nat -> Set x >= zero = One -- i.e., true zero >= suc y = Zero -- i.e., false suc x >= suc y = x >= y --a0 : 2 >= 4 --a0 = {!!} a1 : 4 >= 2 a1 = <> refl->= : (n : Nat) -> n >= n refl->= zero = <> refl->= (suc n) = refl->= n trans->= : (x y z : Nat) -> x >= y -> y >= z -> x >= z trans->= zero zero z x>=y y>=z = y>=z trans->= (suc x) zero zero x>=y y>=z = <> trans->= (suc x) (suc y) zero x>=y y>=z = <> trans->= (suc x) (suc y) (suc z) x>=y y>=z = trans->= x y z x>=y y>=z ------------------------------------------------------------------------------ -- construction by proof -- 47:38 record Sg (S : Set) (T : S -> Set) : Set where -- Sg is short for "Sigma" constructor _,_ field fst : S -- a value snd : T fst -- some evidence about that value difference : (m n : Nat) -> m >= n -> Sg Nat λ d -> m == (n +N d) difference m zero m>=n = m , refl m difference zero (suc n) () difference (suc m) (suc n) m>=n with difference m n m>=n ...| d , e = d , xxx m n d e where xxx : ∀ (m n d : Nat) -> m == (n +N d) -> suc m == suc (n +N d) xxx m n d p rewrite p = refl (suc (n +N d)) -- ============================================================================== -- Lecture 3 : Proof by induction -- https://www.youtube.com/watch?v=8xFT9FPlm18 -- 6:20 -- Nat with zero, +N and assocLR-+ form a monoid. -- 8:48 zero-+N : (n : Nat) -> (zero +N n) == n zero-+N n = refl n -- by definition -- 9:36 -- version in video -- +N-zero' : (n : Nat) -> (n +N zero) == n -- +N-zero' zero = refl zero -- by definition -- +N-zero' (suc n) = refl suc =$= +N-zero' n -- TODO : does not compile -- HC alternate version +N-zero : (n : Nat) -> (n +N zero) == n +N-zero zero = refl zero -- by definition +N-zero (suc n) with +N-zero n ...| n+N0==n rewrite n+N0==n = refl (suc n) -- 26:00 -- version in video -- assocLR-+N' : (x y z : Nat) -> ((x +N y) +N z) == (x +N (y +N z)) -- assocLR-+N' zero y z = refl (y +N z) -- assocLR-+N' (suc x) y z = refl suc =$= assocLR-+N' x y z -- TODO : does not compile -- 30:21 assocLR-+N : (x y z : Nat) -> ((x +N y) +N z) == (x +N (y +N z)) assocLR-+N zero y z = refl (y +N z) assocLR-+N (suc x) y z rewrite assocLR-+N x y z = refl (suc (x +N (y +N z))) ------------------------------------------------------------------------------ -- computing types -- 34:46 refl->=' : (n : Nat) -> n >= n refl->=' zero = <> refl->=' (suc n) = refl->=' n -- 41:00 trans->=' : (x y z : Nat) -> x >= y -> y >= z -> x >= z -- start with 'z' trans->=' x y zero x>=y y>=z = <> trans->=' (suc x) (suc y) (suc z) x>=y y>=z = trans->=' x y z x>=y y>=z -- ============================================================================== -- Lecture 4 : Sigma, Difference, Vector Take -- https://www.youtube.com/watch?v=OZeDRtRmgkw -- 0:46 Sigma type (see above) -- 5:10 -- make _*_ from Sg _*'_ : (S : Set) -> (T : Set) -> Set s *' t = Sg s λ _ -> t -- 10:55 difference (see above) difference' : (m n : Nat) -> m >= n -> Sg Nat λ d -> m == (n +N d) -- 1st clause of >= matches on right, so start with 'n' difference' m zero m>=n = m , refl m difference' (suc m) (suc n) m>=n with difference' m n m>=n ...| d , m==n+Nd rewrite m==n+Nd = d , refl (suc (n +N d)) -- video also uses refl suc =$= m==n+Nd -- 27:24 -- pattern match on proof of equation ; here 'm==n+Nd' difference'' : (m n : Nat) -> m >= n -> Sg Nat λ d -> m == (n +N d) -- 1st clause of >= matches on right, so start with 'n' difference'' m zero m>=n = m , refl m difference'' (suc m) (suc n) m>=n with difference'' m n m>=n ...| d , m==n+Nd with m==n+Nd ... | refl .(n +N d) = d , (refl (suc (n +N d))) tryMe = difference 42 37 -- dontTryMe = difference 37 42 {!!} ------------------------------------------------------------------------------ -- things to remember to say {- -- 34:22 : = VIZ == = : makes a definition (part of Agda programming language) == : makes a type (by user built definition) function type is both IMPLICATION and UNIVERSAL QUANTIFICATION : why call Pi? why is Sigma called Sigma? -- 38:50 : B or not B must be able to return a - inl B for any B : not possible because nothing known about B - inR B→Zero for any B : not possible because Zero has no elements exMiddle : {B : Set} -> B + (B -> Zero) exMiddle = ? -- 40:45 -- not possible to "look inside" 'notAandB' to determine 'inl' or 'inr' deMorgan : {A B : Set} -> ((A * B) -> Zero) -> (A -> Zero) + (B -> Zero) deMorgan notAandB = {!!} -}
{ "alphanum_fraction": 0.4688611079, "avg_line_length": 28.6809210526, "ext": "agda", "hexsha": "745c976e72a62b33388de67f988026eb069f69dd", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/course/2017-conor_mcbride_cs410/HC-Lec1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/course/2017-conor_mcbride_cs410/HC-Lec1.agda", "max_line_length": 87, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/course/2017-conor_mcbride_cs410/HC-Lec1.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "num_tokens": 3049, "size": 8719 }
module Tait where -- Boilerplate for contexts and substitutions inspired by: -- https://plfa.github.io/DeBruijn/ -- Proof technique from "How to (Re)Invent Tait's Method": -- http://www.cs.cmu.edu/~rwh/courses/chtt/pdfs/tait.pdf open import Data.Sum open import Data.Product open import Function using (_∘_) open import Relation.Binary.PropositionalEquality as Eq using (_≡_) open import Relation.Binary.PropositionalEquality.TrustMe using (trustMe) infix 4 _⊢_ infix 4 _∋_ infixl 7 _·_ infix 9 `_ data Type : Set where unit : Type bool : Type _∧_ : Type → Type → Type _⊃_ : Type → Type → Type data Ctx : Set where ∅ : Ctx _#_ : Ctx → Type → Ctx data _∋_ : Ctx → Type → Set where Z : ∀ {Γ A} → (Γ # A) ∋ A S_ : ∀ {Γ A B} → Γ ∋ A → (Γ # B) ∋ A ext : ∀ {Γ Δ} → (∀ {A} → Γ ∋ A → Δ ∋ A) --------------------------------- → (∀ {A B} → Γ # B ∋ A → Δ # B ∋ A) ext ρ Z = Z ext ρ (S x) = S (ρ x) data _⊢_ : Ctx → Type → Set where `_ : ∀ {Γ A} → Γ ∋ A → Γ ⊢ A ⋆ : ∀ {Γ} → Γ ⊢ unit yes no : ∀ {Γ} → Γ ⊢ bool ⟨_,_⟩ : ∀ {Γ A₁ A₂} → Γ ⊢ A₁ → Γ ⊢ A₂ → Γ ⊢ (A₁ ∧ A₂) fst : ∀ {Γ A₁ A₂} → Γ ⊢ (A₁ ∧ A₂) → Γ ⊢ A₁ snd : ∀ {Γ A₁ A₂} → Γ ⊢ (A₁ ∧ A₂) → Γ ⊢ A₂ ƛ : ∀ {Γ A₁ A₂} → (Γ # A₁) ⊢ A₂ → Γ ⊢ (A₁ ⊃ A₂) _·_ : ∀ {Γ A₁ A₂} → Γ ⊢ (A₁ ⊃ A₂) → Γ ⊢ A₁ → Γ ⊢ A₂ rename : ∀ {Γ Δ} → (∀ {A} → Γ ∋ A → Δ ∋ A) ----------------------- → (∀ {A} → Γ ⊢ A → Δ ⊢ A) rename ρ (` x) = ` (ρ x) rename ρ ⋆ = ⋆ rename ρ yes = yes rename ρ no = no rename ρ ⟨ M₁ , M₂ ⟩ = ⟨ rename ρ M₁ , rename ρ M₂ ⟩ rename ρ (fst M) = fst (rename ρ M) rename ρ (snd M) = snd (rename ρ M) rename ρ (ƛ N) = ƛ (rename (ext ρ) N) rename ρ (L · M) = (rename ρ L) · (rename ρ M) Subst : (Γ Δ : Ctx) → Set Subst Γ Δ = ∀ {A} → Γ ∋ A → Δ ⊢ A exts : ∀ {Γ Δ} → Subst Γ Δ → ∀ {A} → Subst (Γ # A) (Δ # A) exts σ Z = ` Z exts σ (S x) = rename S_ (σ x) extend : ∀ {Γ Δ A} → Δ ⊢ A → Subst Γ Δ → Subst (Γ # A) Δ extend M γ Z = M extend M γ (S x) = γ x subst : ∀ {Γ Δ} → Subst Γ Δ → (∀ {A} → Γ ⊢ A → Δ ⊢ A) subst σ (` x) = σ x subst σ ⋆ = ⋆ subst σ yes = yes subst σ no = no subst σ ⟨ M₁ , M₂ ⟩ = ⟨ subst σ M₁ , subst σ M₂ ⟩ subst σ (fst M) = fst (subst σ M) subst σ (snd M) = snd (subst σ M) subst σ (ƛ M) = ƛ (subst (exts σ) M) subst σ (M₁ · M₂) = subst σ M₁ · subst σ M₂ _[_] : ∀ {Γ A B} → Γ # B ⊢ A → Γ ⊢ B --------- → Γ ⊢ A _[_] {Γ} {A} {B} N M = subst {Γ # B} {Γ} (extend M `_) {A} N data _final : ∀ {A} → ∅ ⊢ A → Set where yes : yes final no : no final ⋆ : ⋆ final pair : ∀ {A₁ A₂} → (M₁ : ∅ ⊢ A₁) → (M₂ : ∅ ⊢ A₂) → ⟨ M₁ , M₂ ⟩ final ƛ : ∀ {A₁ A₂} → (M : (∅ # A₁) ⊢ A₂) → (ƛ M) final data _↦_ : {A : Type} → ∅ ⊢ A → ∅ ⊢ A → Set where fst-step : ∀ {A₁ A₂} → {M M' : ∅ ⊢ A₁ ∧ A₂} → (M ↦ M') → (fst M ↦ fst M') snd-step : ∀ {A₁ A₂} → {M M' : ∅ ⊢ A₁ ∧ A₂} → (M ↦ M') → (snd M ↦ snd M') fst : ∀ {A₁ A₂} → {M₁ : ∅ ⊢ A₁} → {M₂ : ∅ ⊢ A₂} → (fst ⟨ M₁ , M₂ ⟩ ↦ M₁) snd : ∀ {A₁ A₂} → {M₁ : ∅ ⊢ A₁} → {M₂ : ∅ ⊢ A₂} → (snd ⟨ M₁ , M₂ ⟩ ↦ M₂) app-step : ∀ {A₁ A₂} → {M₁ M₁' : ∅ ⊢ A₁ ⊃ A₂} → {M₂ : ∅ ⊢ A₁} → (M₁ ↦ M₁') → (M₁ · M₂) ↦ (M₁' · M₂) app : ∀ {A₁ A₂} → {M : ∅ # A₁ ⊢ A₂} → {M₂ : ∅ ⊢ A₁} → (ƛ M · M₂) ↦ (M [ M₂ ]) data _↦*_ : {A : Type} → ∅ ⊢ A → ∅ ⊢ A → Set where refl : ∀ {A} → {M : ∅ ⊢ A} → M ↦* M step : ∀ {A} → {M M' M'' : ∅ ⊢ A} → M ↦ M' → M' ↦* M'' → M ↦* M'' step-trans : ∀ {A} → {M M' M'' : ∅ ⊢ A} → M ↦* M' → M' ↦* M'' → M ↦* M'' step-trans refl s₂ = s₂ step-trans (step x s₁) s₂ = step x (step-trans s₁ s₂) compatible : ∀ {A B} → ∀ {M M' : ∅ ⊢ A} → {p : ∅ ⊢ A → ∅ ⊢ B} → (∀ {N N'} → N ↦ N' → p N ↦ p N') → M ↦* M' → p M ↦* p M' compatible lift refl = refl compatible lift (step x s) = step (lift x) (compatible lift s) ht : (A : Type) → ∅ ⊢ A → Set ht unit M = M ↦* ⋆ ht bool M = (M ↦* yes) ⊎ (M ↦* no) ht (A₁ ∧ A₂) M = ∃ λ N₁ → ∃ λ N₂ → (M ↦* ⟨ N₁ , N₂ ⟩) × (ht A₁ N₁ × ht A₂ N₂) ht (A₂ ⊃ A) M = ∃ λ N → (M ↦* ƛ N) × (∀ N₂ → ht A₂ N₂ → ht A (N [ N₂ ])) HT : ∀ {Γ} → Subst Γ ∅ → Set HT {Γ} γ = ∀ {A} → (x : Γ ∋ A) → ht A (γ x) ht-reverse-step : ∀ {A M M'} → M ↦ M' → ht A M' → ht A M ht-reverse-step {unit} = step ht-reverse-step {bool} s = [ (inj₁ ∘ step s) , (inj₂ ∘ step s) ] ht-reverse-step {A ∧ A₁} s (N₁ , N₂ , term , ht₁ , ht₂) = N₁ , N₂ , step s term , ht₁ , ht₂ ht-reverse-step {A ⊃ A₁} s (N , term , ht') = N , step s term , ht' ht-reverse-steps : ∀ {A M M'} → M ↦* M' → ht A M' → ht A M ht-reverse-steps refl h = h ht-reverse-steps (step x s) h = ht-reverse-step x (ht-reverse-steps s h) -- Primary Theorem _>>_∋_ : (Γ : Ctx) → (A : Type) → Γ ⊢ A → Set Γ >> A ∋ M = (γ : Subst Γ ∅) → (h : HT γ) → ht A (subst γ M) tait : ∀ {Γ A} → (M : Γ ⊢ A) → Γ >> A ∋ M tait (` x) γ h = h x tait ⋆ γ h = refl tait yes γ h = inj₁ refl tait no γ h = inj₂ refl tait ⟨ M₁ , M₂ ⟩ γ h = subst γ M₁ , subst γ M₂ , refl , tait M₁ γ h , tait M₂ γ h tait (fst M) γ h = let _ , _ , step-to-pair , ht-M₁ , _ = tait M γ h in ht-reverse-steps (step-trans (compatible fst-step step-to-pair) (step fst refl)) ht-M₁ tait (snd M) γ h = let _ , _ , step-to-pair , _ , ht-M₂ = tait M γ h in ht-reverse-steps (step-trans (compatible snd-step step-to-pair) (step snd refl)) ht-M₂ tait (ƛ M₂) γ h = subst (exts γ) M₂ , refl , λ M₁ ht₁ → let ht₂ = tait M₂ (extend M₁ γ) λ { Z → ht₁ ; (S x) → h x } in Eq.subst (ht _) trustMe ht₂ -- FIXME tait (M₁ · M₂) γ h = let _ , step-to-lam , ht₁ = tait M₁ γ h in let ht₂ = tait M₂ γ h in ht-reverse-steps (step-trans (compatible app-step step-to-lam) (step app refl)) (ht₁ (subst γ M₂) ht₂ ) -- Corollary subst-lemma : ∀ {Γ A} → (M : Γ ⊢ A) → subst `_ M ≡ M subst-lemma (` x) = Eq.refl subst-lemma ⋆ = Eq.refl subst-lemma yes = Eq.refl subst-lemma no = Eq.refl subst-lemma ⟨ M₁ , M₂ ⟩ = Eq.cong₂ ⟨_,_⟩ (subst-lemma M₁) (subst-lemma M₂) subst-lemma (fst M) = Eq.cong fst (subst-lemma M) subst-lemma (snd M) = Eq.cong snd (subst-lemma M) subst-lemma (ƛ M) = trustMe -- FIXME subst-lemma (M₁ · M₂) = Eq.cong₂ _·_ (subst-lemma M₁) (subst-lemma M₂) bools-terminate : (M : ∅ ⊢ bool) → M ↦* yes ⊎ M ↦* no bools-terminate M = Eq.subst (λ M → M ↦* yes ⊎ M ↦* no) (subst-lemma M) (tait M `_ (λ {_} ()))
{ "alphanum_fraction": 0.4571428571, "avg_line_length": 36.5642458101, "ext": "agda", "hexsha": "c00e434d56bbbf9b2ed2389301382938008b2a7b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b140aabd0ce35d926093dcfe0b5f18a95d757e24", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "HarrisonGrodin/computational-type-theory-2021", "max_forks_repo_path": "tait/Tait.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b140aabd0ce35d926093dcfe0b5f18a95d757e24", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "HarrisonGrodin/computational-type-theory-2021", "max_issues_repo_path": "tait/Tait.agda", "max_line_length": 126, "max_stars_count": 2, "max_stars_repo_head_hexsha": "b140aabd0ce35d926093dcfe0b5f18a95d757e24", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "HarrisonGrodin/computational-type-theory-2021", "max_stars_repo_path": "tait/Tait.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-03T18:24:39.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-08T12:27:39.000Z", "num_tokens": 3021, "size": 6545 }
{-# OPTIONS --cubical --safe #-} module Algebra.Construct.Free.Semilattice.Extensionality where open import Prelude open import Algebra.Construct.Free.Semilattice.Definition open import Algebra.Construct.Free.Semilattice.Eliminators open import Algebra.Construct.Free.Semilattice.Relation.Unary open import Algebra.Construct.Free.Semilattice.Union open import HITs.PropositionalTruncation.Sugar import HITs.PropositionalTruncation as PropTrunc open import HITs.PropositionalTruncation.Properties open import Path.Reasoning infix 4 _↭_ _↭_ : 𝒦 A → 𝒦 A → Type _ xs ↭ ys = ∀ x → x ∈ xs ↔ x ∈ ys in-cons : (x : A) (xs : 𝒦 A) → x ∈ xs → xs ≡ x ∷ xs in-cons = λ x → ∥ in-cons′ x ∥⇓ where in-cons′ : ∀ x → xs ∈𝒦 A ⇒∥ (x ∈ xs → xs ≡ x ∷ xs) ∥ ∥ in-cons′ y ∥-prop {xs} p q i y∈xs = trunc xs (y ∷ xs) (p y∈xs) (q y∈xs) i ∥ in-cons′ y ∥[] () ∥ in-cons′ y ∥ x ∷ xs ⟨ Pxs ⟩ = PropTrunc.rec (trunc _ _) λ { (inl x≡y) → sym (dup x xs) ; cong (_∷ x ∷ xs) x≡y ; (inr y∈xs) → cong (x ∷_) (Pxs y∈xs) ; com x y xs } subset-ext : ∀ xs ys → (∀ (x : A) → x ∈ xs → x ∈ ys) → xs ∪ ys ≡ ys subset-ext = ∥ subset-ext′ ∥⇓ where subset-ext′ : xs ∈𝒦 A ⇒∥ (∀ ys → (∀ x → x ∈ xs → x ∈ ys) → xs ∪ ys ≡ ys) ∥ ∥ subset-ext′ ∥-prop {xs} p q i ys perm = trunc (xs ∪ ys) ys (p ys perm) (q ys perm) i ∥ subset-ext′ ∥[] _ _ = refl ∥ subset-ext′ ∥ x ∷ xs ⟨ Pxs ⟩ ys perm = (x ∷ xs) ∪ ys ≡⟨ cons-distrib-∪ x xs ys ⟩ xs ∪ (x ∷ ys) ≡⟨ Pxs (x ∷ ys) (λ y y∈xs → ∣ inr (perm y ∣ inr y∈xs ∣) ∣) ⟩ x ∷ ys ≡˘⟨ in-cons x ys (perm x ∣ inl refl ∣) ⟩ ys ∎ extensional : (xs ys : 𝒦 A) → (xs ↭ ys) → xs ≡ ys extensional xs ys xs↭ys = xs ≡˘⟨ subset-ext ys xs (inv ∘ xs↭ys) ⟩ ys ∪ xs ≡⟨ ∪-comm ys xs ⟩ xs ∪ ys ≡⟨ subset-ext xs ys (fun ∘ xs↭ys) ⟩ ys ∎
{ "alphanum_fraction": 0.5737797957, "avg_line_length": 34.5490196078, "ext": "agda", "hexsha": "97cc45e226a852c351bb389034b1e4cc7617eb5e", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Algebra/Construct/Free/Semilattice/Extensionality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Algebra/Construct/Free/Semilattice/Extensionality.agda", "max_line_length": 88, "max_stars_count": 6, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Algebra/Construct/Free/Semilattice/Extensionality.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": 792, "size": 1762 }
{- My first Proof in Agda -} -- define Natural numbers data ℕ : Set where zero : ℕ suc : ℕ → ℕ -- Simply defining 1 one : ℕ one = suc(zero) two : ℕ two = suc(suc(zero)) -- define addition of natural numbers _+_ : ℕ → ℕ → ℕ zero + n = n (suc m) + n = suc (m + n) -- Define equality data _≡_ {A : Set} (a : A) : A → Set where refl : a ≡ a -- small test for equality -- oneplusoneistwo : one + one ≡ two -- oneplusoneistwo = refl -- Prove n+0 = n
{ "alphanum_fraction": 0.5818965517, "avg_line_length": 12.8888888889, "ext": "agda", "hexsha": "d7ca397f86765e0071cdde3c5b09d23c99e75ab9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c506d7e317366443d6d17be943b95e46409c1570", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "adithyaselv/Learn-Agda", "max_forks_repo_path": "Hello-Agda.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c506d7e317366443d6d17be943b95e46409c1570", "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": "adithyaselv/Learn-Agda", "max_issues_repo_path": "Hello-Agda.agda", "max_line_length": 42, "max_stars_count": null, "max_stars_repo_head_hexsha": "c506d7e317366443d6d17be943b95e46409c1570", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "adithyaselv/Learn-Agda", "max_stars_repo_path": "Hello-Agda.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 169, "size": 464 }
{-# OPTIONS --allow-unsolved-metas #-} open import Agda.Primitive using (lzero; lsuc; _⊔_) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong; subst; setoid) open import Data.Product using (_×_; Σ; _,_; proj₁; proj₂; zip; map; <_,_>; swap) import Function.Equality -- open import Relation.Binary using (Setoid) -- import Relation.Binary.Reasoning.Setoid as SetoidR import Categories.Category import Categories.Functor import Categories.Category.Instance.Setoids import Categories.Monad.Relative import Categories.Category.Equivalence import Categories.Category.Cocartesian import Categories.Category.Construction.Functors import Categories.Category.Product import Categories.NaturalTransformation import Categories.NaturalTransformation.NaturalIsomorphism import SecondOrder.Arity import SecondOrder.Signature import SecondOrder.Metavariable import SecondOrder.VRenaming import SecondOrder.MRenaming import SecondOrder.Term import SecondOrder.Substitution import SecondOrder.RelativeMonadMorphism import SecondOrder.Instantiation import SecondOrder.IndexedCategory import SecondOrder.RelativeKleisli module SecondOrder.Mslot {ℓ} {𝔸 : SecondOrder.Arity.Arity} (Σ : SecondOrder.Signature.Signature ℓ 𝔸) where open SecondOrder.Signature.Signature Σ open SecondOrder.Metavariable Σ open SecondOrder.Term Σ open SecondOrder.VRenaming Σ open SecondOrder.MRenaming Σ -- open SecondOrder.Substitution Σ -- open import SecondOrder.RelativeMonadMorphism -- open SecondOrder.Instantiation open Categories.Category open Categories.Functor using (Functor) open Categories.NaturalTransformation renaming (id to idNt) open Categories.NaturalTransformation.NaturalIsomorphism renaming (refl to reflNt; sym to symNt; trans to transNt) open Categories.Category.Construction.Functors open Categories.Category.Instance.Setoids open Categories.Category.Product open Function.Equality using () renaming (setoid to Π-setoid) open SecondOrder.IndexedCategory -- open import SecondOrder.RelativeKleisli MTele = MContexts VTele = VContexts -- the codomain category of the MSlots functor. It should be equivalent to the -- functor category [ MTele x VTele , < Setoid >ₛₒᵣₜ ] -- objects are functors, which are really pairs of functions, one on objects -- one on morphisms -- morphisms in this category are natural transformations module _ where open Category open NaturalTransformation open Function.Equality renaming (_∘_ to _∙_) Mslots : Functor MContexts (IndexedCategory VContext (IndexedCategory sort (Setoids ℓ ℓ))) Mslots = let open Categories.NaturalTransformation in let open NaturalTransformation in let open Relation.Binary.PropositionalEquality.≡-Reasoning in record { F₀ = λ Θ Γ A → setoid ([ Γ , A ]∈ Θ) ; F₁ = λ ι Γ A → record { _⟨$⟩_ = λ M → ι M ; cong = λ M≡N → cong ι M≡N } ; identity = λ {Θ} Γ A {M} {N} M≡N → cong idᵐ M≡N ; homomorphism = λ {Θ} {Ψ} {Ξ} {ι} {μ} Γ A M≡N → cong (μ ∘ᵐ ι) M≡N ; F-resp-≈ = λ {Θ} {Ψ} {ι} {μ} ι≡ᵐμ Γ A {M} {N} M≡N → begin ι M ≡⟨ cong ι M≡N ⟩ ι N ≡⟨ ι≡ᵐμ N ⟩ μ N ∎ }
{ "alphanum_fraction": 0.7280513919, "avg_line_length": 36.3222222222, "ext": "agda", "hexsha": "27ffbcca21fd109e5a7d3d3d390b99381925fcd3", "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": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cilinder/formaltt", "max_forks_repo_path": "src/SecondOrder/Mslot.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb", "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": "cilinder/formaltt", "max_issues_repo_path": "src/SecondOrder/Mslot.agda", "max_line_length": 116, "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/Mslot.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": 939, "size": 3269 }
module STLC3 where open import Data.Nat open import Data.Nat.Properties using (≤-antisym; ≤-trans; ≰⇒>) -- open import Data.List open import Data.Empty using (⊥-elim) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong; cong₂; subst) open import Relation.Nullary.Decidable using (map) open import Relation.Nullary open import Data.Product -- de Bruijn indexed lambda calculus infix 5 ƛ_ infixl 7 _∙_ infix 9 var_ -- indexed by the number of binders out there data Term : ℕ → Set where -- if x < n -- then var x is bound -- else var x is free var_ : ∀ {n} → (x : ℕ) → Term n ƛ_ : ∀ {n} → Term (suc n) → Term n _∙_ : ∀ {n} → Term n → Term n → Term n data Var : Set where Bound : ∀ {n x} → (bound : n > x) → Var FreeIncr : ∀ {n x depth} → (free : suc x ≰ n) → (prop : depth ≡ suc x) → Var Free : ∀ {n x depth} →(free : suc x ≰ n) → (safe : suc x ≰ depth) → Var sort : (n x depth : ℕ) → suc n ≥ depth → Var sort n x depth P with n >? x sort n x depth P | yes p = Bound p sort n x depth P | no ¬p with depth >? x sort n x depth P | no ¬p | yes q = FreeIncr ¬p (≤-antisym (≤-trans P (≰⇒> ¬p)) q) sort n x depth P | no ¬p | no ¬q = Free ¬p ¬q -- only "shift" the variable when -- 1. it's free -- 2. it will be captured after substitution shift : ∀ {n} → (i : ℕ) → suc n ≥ i → Term n → Term (suc n) shift {n} depth P (var x) with sort n x depth P shift {n} depth P (var x) | Bound bound = var x shift {n} depth P (var x) | FreeIncr free prop = var suc x shift {n} depth P (var x) | Free free safe = var x shift depth P (ƛ M) = ƛ shift (suc depth) (s≤s P) M shift depth P (M ∙ N) = shift depth P M ∙ shift depth P N infixl 10 _[_/_/_] _[_/_/_] : ∀ {n} → Term (suc n) → Term n → (i : ℕ) → n ≥ i → Term n (var x) [ N / i / n≥i ] with x ≟ i (var x) [ N / i / n≥i ] | yes p = N (var x) [ N / i / n≥i ] | no ¬p = var x (ƛ M) [ N / i / n≥i ] = ƛ (M [ shift (suc i) (s≤s n≥i) N / suc i / s≤s n≥i ]) (L ∙ M) [ N / i / n≥i ] = L [ N / i / n≥i ] ∙ M [ N / i / n≥i ] -- substitution infixl 10 _[_] _[_] : ∀ {n} → Term (suc n) → Term n → Term n M [ N ] = M [ N / zero / z≤n ] -- β reduction infix 3 _β→_ data _β→_ {n : ℕ} : Term n → Term n → Set where β-ƛ-∙ : ∀ {M N} → ((ƛ M) ∙ N) β→ M [ N ] β-ƛ : ∀ {M N} → M β→ N → ƛ M β→ ƛ N β-∙-l : ∀ {L M N} → M β→ N → M ∙ L β→ N ∙ L β-∙-r : ∀ {L M N} → M β→ N → L ∙ M β→ L ∙ N -- the reflexive and transitive closure of _β→_ infix 2 _β→*_ infixr 4 _→*_ data _β→*_ {n : ℕ} : Term n → Term n → Set where ∎ : ∀ {M} → M β→* M _→*_ : ∀ {L M N} → L β→ M → M β→* N -------------- → L β→* N infixl 3 _<β>_ _<β>_ : ∀ {n} {M N O : Term n} → M β→* N → N β→* O → M β→* O ∎ <β> N→O = N→O L→M →* M→N <β> N→O = L→M →* (M→N <β> N→O) hop : ∀ {n} {M N : Term n} → M β→ N → M β→* N hop M→N = M→N →* ∎ -- infix 2 _-↠_ infixr 2 _→⟨_⟩_ _→⟨_⟩_ : ∀ {n} {M N : Term n} → ∀ L → L β→ M → M β→* N -------------- → L β→* N L →⟨ P ⟩ Q = P →* Q infixr 2 _→*⟨_⟩_ _→*⟨_⟩_ : ∀ {n} {M N : Term n} → ∀ L → L β→* M → M β→* N -------------- → L β→* N L →*⟨ P ⟩ Q = P <β> Q infix 3 _→∎ _→∎ : ∀ {n} (M : Term n) → M β→* M M →∎ = ∎ -- the symmetric closure of _β→*_ infix 1 _β≡_ data _β≡_ {n : ℕ} : Term n → Term n → Set where β-sym : ∀ {M N} → M β→* N → N β→* M ------- → M β≡ N infixr 2 _=*⟨_⟩_ _=*⟨_⟩_ : ∀ {n} {M N : Term n} → ∀ L → L β≡ M → M β≡ N -------------- → L β≡ N L =*⟨ β-sym A B ⟩ β-sym C D = β-sym (A <β> C) (D <β> B) infixr 2 _=*⟨⟩_ _=*⟨⟩_ : ∀ {n} {N : Term n} → ∀ L → L β≡ N -------------- → L β≡ N L =*⟨⟩ β-sym C D = β-sym C D infix 3 _=∎ _=∎ : ∀ {n} → (M : Term n) → M β≡ M M =∎ = β-sym ∎ ∎ forward : ∀ {n} {M N : Term n} → M β≡ N → M β→* N forward (β-sym A _) = A backward : ∀ {n} {M N : Term n} → M β≡ N → N β→* M backward (β-sym _ B) = B -- data Normal : Set where Normal : ∀ {n} → Term n → Set Normal M = ¬ ∃ (λ N → M β→ N) normal : ∀ {n} {M N : Term n} → Normal M → M β→* N → M ≡ N normal P ∎ = refl normal P (M→L →* L→N) = ⊥-elim (P (_ , M→L)) cong-ƛ : ∀ {n} {M N : Term (suc n)} → M β→* N → ƛ M β→* ƛ N cong-ƛ ∎ = ∎ cong-ƛ (M→N →* N→O) = β-ƛ M→N →* cong-ƛ N→O cong-∙-l : ∀ {n} {L M N : Term n} → M β→* N → M ∙ L β→* N ∙ L cong-∙-l ∎ = ∎ cong-∙-l (M→N →* N→O) = β-∙-l M→N →* cong-∙-l N→O cong-∙-r : ∀ {n} {L M N : Term n} → M β→* N → L ∙ M β→* L ∙ N cong-∙-r ∎ = ∎ cong-∙-r (M→N →* N→O) = β-∙-r M→N →* cong-∙-r N→O cong-shift! : ∀ {n i} (M : Term (suc n)) (N : Term n) → (n≥i : n ≥ i) → shift (suc i) (s≤s n≥i) ((ƛ M) ∙ N) β→ shift (suc i) (s≤s n≥i) (M [ N ]) cong-shift! (var x) N n≥i = {! !} cong-shift! (ƛ M) N n≥i = {! !} cong-shift! (M ∙ L) N n≥i = {! !} cong-shift : ∀ {n i} {M N : Term n} → (n≥i : n ≥ i) → M β→ N → shift (suc i) (s≤s n≥i) M β→ shift (suc i) (s≤s n≥i) N cong-shift n≥i (β-ƛ-∙ {M} {N}) = cong-shift! M N n≥i cong-shift n≥i (β-ƛ M→N) = β-ƛ (cong-shift (s≤s n≥i) M→N) cong-shift n≥i (β-∙-l M→N) = β-∙-l (cong-shift n≥i M→N) cong-shift n≥i (β-∙-r M→N) = β-∙-r (cong-shift n≥i M→N) -- cong-shift : ∀ {n i} {M N : Term n} → n ≥ i → M β→ N → shift (suc i) M β→ shift (suc i) N -- cong-shift {n} n≥i (β-ƛ-∙ {var x} {var y}) with suc n >? x -- cong-shift {n} n≥i (β-ƛ-∙ {var x} {var y}) | yes p with suc y ≤? n -- cong-shift {n} n≥i (β-ƛ-∙ {var zero} {var y}) | yes p | yes q with n >? y -- cong-shift {n} n≥i (β-ƛ-∙ {var zero} {var y}) | yes p | yes q | yes r = β-ƛ-∙ -- cong-shift {n} n≥i (β-ƛ-∙ {var zero} {var y}) | yes p | yes q | no ¬r = ⊥-elim (¬r q) -- cong-shift {n} n≥i (β-ƛ-∙ {var suc x} {var y}) | yes p | yes q with n >? suc x -- cong-shift {n} n≥i (β-ƛ-∙ {var suc x} {var y}) | yes p | yes q | yes r = {! !} -- dump -- cong-shift {n} {i} n≥i (β-ƛ-∙ {var suc x} {var y}) | yes p | yes q | no ¬r with suc i >? suc x -- -- ≤-antisym p -- cong-shift {n} {i} n≥i (β-ƛ-∙ {var suc x} {var y}) | yes p | yes q | no ¬r | yes s = {! (≰⇒> ¬r) !} -- fishy -- cong-shift {n} {i} n≥i (β-ƛ-∙ {var suc x} {var y}) | yes p | yes q | no ¬r | no ¬s = {! !} -- dump -- cong-shift {n} {i} n≥i (β-ƛ-∙ {var x} {var y}) | yes p | no ¬q with suc i >? y -- cong-shift {n} {i} n≥i (β-ƛ-∙ {var zero} {var y}) | yes p | no ¬q | yes r with n >? y -- cong-shift {n} {i} n≥i (β-ƛ-∙ {var zero} {var y}) | yes p | no ¬q | yes r | yes s = ⊥-elim (¬q s) -- cong-shift {n} {i} n≥i (β-ƛ-∙ {var zero} {var y}) | yes p | no ¬q | yes r | no ¬s with suc i >? y -- cong-shift {n} {i} n≥i (β-ƛ-∙ {var zero} {var y}) | yes p | no ¬q | yes r | no ¬s | yes t = β-ƛ-∙ -- cong-shift {n} {i} n≥i (β-ƛ-∙ {var zero} {var y}) | yes p | no ¬q | yes r | no ¬s | no ¬t = ⊥-elim (¬t r) -- cong-shift {n} {i} n≥i (β-ƛ-∙ {var suc x} {var y}) | yes p | no ¬q | yes r with n >? suc x -- cong-shift {n} {i} n≥i (β-ƛ-∙ {var suc x} {var y}) | yes p | no ¬q | yes r | yes t = {! !} -- dump -- cong-shift {n} {i} n≥i (β-ƛ-∙ {var suc x} {var y}) | yes p | no ¬q | yes r | no ¬t with suc i >? suc x -- cong-shift {n} {i} n≥i (β-ƛ-∙ {var suc x} {var y}) | yes p | no ¬q | yes r | no ¬t | yes u = {! !} -- fishy -- cong-shift {n} {i} n≥i (β-ƛ-∙ {var suc x} {var y}) | yes p | no ¬q | yes r | no ¬t | no ¬u = β-ƛ-∙ -- cong-shift {n} {i} n≥i (β-ƛ-∙ {var x} {var y}) | yes p | no ¬q | no ¬r = {! !} -- cong-shift {n} n≥i (β-ƛ-∙ {var x} {var y}) | no ¬p = {! !} -- cong-shift {n} n≥i (β-ƛ-∙ {var x} {ƛ N}) = {! !} -- cong-shift {n} n≥i (β-ƛ-∙ {var x} {N ∙ O}) = {! !} -- -- cong-shift {n} (β-ƛ-∙ {var x} {N}) with suc n >? x -- -- cong-shift {n} (β-ƛ-∙ {var zero} {N}) | yes p = β-ƛ-∙ -- -- cong-shift {n} (β-ƛ-∙ {var suc x} {N}) | yes (s≤s p) with n >? suc x -- -- cong-shift {n} (β-ƛ-∙ {var suc x} {N}) | yes (s≤s p) | yes q = {! !} -- -- cong-shift {n} {i} (β-ƛ-∙ {var suc x} {N}) | yes (s≤s p) | no ¬q with suc i >? suc x -- -- cong-shift {n} {i} (β-ƛ-∙ {var suc x} {N}) | yes (s≤s p) | no ¬q | yes r = {! !} -- fishy -- -- cong-shift {n} {i} (β-ƛ-∙ {var suc x} {N}) | yes (s≤s p) | no ¬q | no ¬r = {! !} -- -- cong-shift {n} (β-ƛ-∙ {var zero} {var x}) | no ¬p = {! !} -- -- cong-shift {n} (β-ƛ-∙ {var zero} {ƛ N}) | no ¬p = {! !} -- -- cong-shift {n} (β-ƛ-∙ {var zero} {N ∙ O}) | no ¬p = {! !} -- -- cong-shift {n} (β-ƛ-∙ {var suc x} {N}) | no ¬p = {! !} -- cong-shift n≥i (β-ƛ-∙ {ƛ M} {N}) = {! !} -- cong-shift n≥i (β-ƛ-∙ {L ∙ var x} {N}) = {! !} -- cong-shift n≥i (β-ƛ-∙ {L ∙ (ƛ M)} {N}) = {! !} -- cong-shift n≥i (β-ƛ-∙ {L ∙ (M ∙ K)} {N}) = {! !} -- cong-shift n≥i (β-ƛ M→N) = β-ƛ (cong-shift _ M→N) -- cong-shift n≥i (β-∙-l M→N) = β-∙-l (cong-shift _ M→N) -- cong-shift n≥i (β-∙-r M→N) = β-∙-r (cong-shift _ M→N) -- -- cong-[] : ∀ {n i} {M N : Term n} → (L : Term (suc n)) → M β→ N → L [ M / i ] β→* L [ N / i ] -- -- cong-[] {i = i} (var x) M→N with x ≟ i -- -- cong-[] {i = i} (var x) M→N | yes p = hop M→N -- -- cong-[] {i = i} (var x) M→N | no ¬p = ∎ -- -- cong-[] {n} {i} (ƛ L) M→N = {! !} -- -- -- cong-ƛ (cong-[] L (cong-shift M→N)) -- -- cong-[] {i = i} {M} {N} (L ∙ K) M→N = -- -- L [ M / i ] ∙ K [ M / i ] -- -- →*⟨ cong-∙-l (cong-[] L M→N) ⟩ -- -- L [ N / i ] ∙ K [ M / i ] -- -- →*⟨ cong-∙-r (cong-[] K M→N) ⟩ -- -- L [ N / i ] ∙ K [ N / i ] -- -- →∎ -- cong-[]2 : ∀ {n i} {M N : Term n} → (L : Term (suc n)) → n ≥ i → M β→ N → L [ M / i ] β→* L [ N / i ] -- cong-[]2 {n} {i} (var x) n≥i M→N with x ≟ i -- cong-[]2 {n} {i} (var x) n≥i M→N | yes p = hop M→N -- cong-[]2 {n} {i} (var x) n≥i M→N | no ¬p = ∎ -- cong-[]2 {n} {i} (ƛ M) n≥i M→N = cong-ƛ (cong-[]2 M (s≤s n≥i) {! cong-shift !}) -- cong-[]2 {n} {i} {M} {N} (L ∙ K) n≥i M→N = -- L [ M / i ] ∙ K [ M / i ] -- →*⟨ cong-∙-l (cong-[]2 L _ M→N) ⟩ -- L [ N / i ] ∙ K [ M / i ] -- →*⟨ cong-∙-r (cong-[]2 K _ M→N) ⟩ -- L [ N / i ] ∙ K [ N / i ] -- →∎ -- β→confluent : ∀ {n} (M N O : Term n) → (M β→ N) → (M β→ O) → ∃ (λ P → (N β→* P) × (O β→* P)) -- β→confluent .((ƛ M) ∙ N) _ _ (β-ƛ-∙ {M} {N}) β-ƛ-∙ = (M [ N ]) , (∎ , ∎) -- β→confluent .((ƛ M) ∙ N) _ .(O ∙ N) (β-ƛ-∙ {M} {N}) (β-∙-l {N = O} M→O) = (O ∙ N) , ({! !} , ∎) -- β→confluent .((ƛ M) ∙ N) _ .((ƛ M) ∙ O) (β-ƛ-∙ {M} {N}) (β-∙-r {N = O} N→O) = (M [ O ]) , (cong-[]2 M z≤n N→O , (hop β-ƛ-∙)) -- β→confluent .(ƛ M) .(ƛ N) .(ƛ O) (β-ƛ {M} {N} M→N) (β-ƛ {N = O} M→O) with β→confluent M N O M→N M→O -- β→confluent .(ƛ M) .(ƛ N) .(ƛ O) (β-ƛ {M} {N} M→N) (β-ƛ {N = O} M→O) | P , N→P , O→P = (ƛ P) , ((cong-ƛ N→P) , (cong-ƛ O→P)) -- β→confluent .((ƛ M) ∙ L) .(N ∙ L) _ (β-∙-l {L} {N = N} M→N) (β-ƛ-∙ {M}) = (N ∙ L) , (∎ , {! !}) -- β→confluent .(M ∙ L) .(N ∙ L) .(K ∙ L) (β-∙-l {L} {M} {N} M→N) (β-∙-l {N = K} M→O) with β→confluent M N K M→N M→O -- β→confluent .(M ∙ L) .(N ∙ L) .(K ∙ L) (β-∙-l {L} {M} {N} M→N) (β-∙-l {N = K} M→O) | P , N→P , K→P = P ∙ L , ((cong-∙-l N→P) , cong-∙-l K→P) -- β→confluent .(M ∙ L) .(N ∙ L) .(M ∙ K) (β-∙-l {L} {M} {N} M→N) (β-∙-r {N = K} M→O) = N ∙ K , hop (β-∙-r M→O) , hop (β-∙-l M→N) -- β→confluent .((ƛ L) ∙ M) .((ƛ L) ∙ N) _ (β-∙-r {M = M} {N} M→N) (β-ƛ-∙ {L}) = (L [ N ]) , (hop β-ƛ-∙ , cong-[]2 L _ M→N) -- β→confluent .(K ∙ M) .(K ∙ N) .(L ∙ M) (β-∙-r {K} {M} {N} M→N) (β-∙-l {N = L} K→L) = (L ∙ N) , ((hop (β-∙-l K→L)) , hop (β-∙-r M→N)) -- β→confluent .(_ ∙ M) .(_ ∙ N) .(_ ∙ O) (β-∙-r {M = M} {N} M→N) (β-∙-r {N = O} M→O) with β→confluent M N O M→N M→O -- β→confluent .(L ∙ M) .(L ∙ N) .(L ∙ O) (β-∙-r {L} {M} {N} M→N) (β-∙-r {N = O} M→O) | P , N→P , O→P = (L ∙ P) , (cong-∙-r N→P , cong-∙-r O→P) -- β→*-confluent : ∀ {n} {M N O : Term n} → (M β→* N) → (M β→* O) → ∃ (λ P → (N β→* P) × (O β→* P)) -- β→*-confluent {n} {M} {.M} {O} ∎ M→O = O , M→O , ∎ -- β→*-confluent {n} {M} {N} {.M} (M→L →* L→N) ∎ = N , ∎ , (M→L →* L→N) -- β→*-confluent {n} {M} {N} {O} (M→L →* L→N) (M→K →* K→O) = {! !} -- normal-unique : ∀ {n} {M N O : Term n} → Normal N → Normal O → M β→* N → M β→* O → N ≡ O -- normal-unique P Q M→N M→O = let X = β→*-confluent M→N M→O in trans (normal P (proj₁ (proj₂ X))) (sym (normal Q (proj₂ (proj₂ X))))
{ "alphanum_fraction": 0.4219590958, "avg_line_length": 39.5967213115, "ext": "agda", "hexsha": "d7fc3537349ba48516ff29a87ff0d2694912069a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/bidirectional", "max_forks_repo_path": "LC/stash/STLC3.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6", "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/bidirectional", "max_issues_repo_path": "LC/stash/STLC3.agda", "max_line_length": 144, "max_stars_count": 2, "max_stars_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/bidirectional", "max_stars_repo_path": "LC/stash/STLC3.agda", "max_stars_repo_stars_event_max_datetime": "2020-08-25T14:05:01.000Z", "max_stars_repo_stars_event_min_datetime": "2020-08-25T07:34:40.000Z", "num_tokens": 6460, "size": 12077 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Vector equality over propositional equality ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Data.Vec.Relation.Binary.Equality.Propositional {a} {A : Set a} where open import Data.Nat.Base using (ℕ; zero; suc; _+_) open import Data.Vec open import Data.Vec.Relation.Binary.Pointwise.Inductive using (Pointwise-≡⇒≡; ≡⇒Pointwise-≡) import Data.Vec.Relation.Binary.Equality.Setoid as SEq open import Relation.Binary.PropositionalEquality ------------------------------------------------------------------------ -- Publically re-export everything from setoid equality open SEq (setoid A) public ------------------------------------------------------------------------ -- ≋ is propositional ≋⇒≡ : ∀ {n} {xs ys : Vec A n} → xs ≋ ys → xs ≡ ys ≋⇒≡ = Pointwise-≡⇒≡ ≡⇒≋ : ∀ {n} {xs ys : Vec A n} → xs ≡ ys → xs ≋ ys ≡⇒≋ = ≡⇒Pointwise-≡ -- See also Data.Vec.Relation.Binary.Equality.Propositional.WithK.≋⇒≅.
{ "alphanum_fraction": 0.5112511251, "avg_line_length": 31.7428571429, "ext": "agda", "hexsha": "beb812ac12e3769a0ae0cba19dc13ed6d7503a3d", "lang": "Agda", "max_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/Binary/Equality/Propositional.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/Relation/Binary/Equality/Propositional.agda", "max_line_length": 76, "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/Binary/Equality/Propositional.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 300, "size": 1111 }
module Issue589 where data N : Set where zero : N suc : N -> N _+_ : N -> N -> N zero + y = y suc x + y = suc ?
{ "alphanum_fraction": 0.5169491525, "avg_line_length": 11.8, "ext": "agda", "hexsha": "2206c58e6804f6adc8ad4a0c27f5f1bf503e8c48", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue589.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue589.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/interaction/Issue589.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": 46, "size": 118 }
module neq where open import eq open import negation ---------------------------------------------------------------------- -- syntax ---------------------------------------------------------------------- infix 4 _≢_ ---------------------------------------------------------------------- -- defined types ---------------------------------------------------------------------- _≢_ : ∀ {ℓ}{A : Set ℓ} → A → A → Set ℓ x ≢ y = ¬ (x ≡ y)
{ "alphanum_fraction": 0.200913242, "avg_line_length": 25.7647058824, "ext": "agda", "hexsha": "cbf404f256b327fb8dc47e6827658e38262802ed", "lang": "Agda", "max_forks_count": 17, "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rfindler/ial", "max_forks_repo_path": "neq.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rfindler/ial", "max_issues_repo_path": "neq.agda", "max_line_length": 70, "max_stars_count": 29, "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rfindler/ial", "max_stars_repo_path": "neq.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "num_tokens": 73, "size": 438 }
{-# OPTIONS --without-K --safe #-} module Cats.Functor.Const where open import Function using (const) open import Cats.Category open import Cats.Functor using (Functor) module _ {lo la l≈ lo′ la′ l≈′} (C : Category lo la l≈) {D : Category lo′ la′ l≈′} where open Category D Const : Obj → Functor C D Const d = record { fobj = const d ; fmap = const id ; fmap-resp = const ≈.refl ; fmap-id = ≈.refl ; fmap-∘ = id-l }
{ "alphanum_fraction": 0.6039387309, "avg_line_length": 18.28, "ext": "agda", "hexsha": "71a3bd2ec5ace0b27e3652f79d1850373987eea5", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-18T15:35:07.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-18T15:35:07.000Z", "max_forks_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JLimperg/cats", "max_forks_repo_path": "Cats/Functor/Const.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JLimperg/cats", "max_issues_repo_path": "Cats/Functor/Const.agda", "max_line_length": 52, "max_stars_count": 24, "max_stars_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JLimperg/cats", "max_stars_repo_path": "Cats/Functor/Const.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-06T05:00:46.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-03T15:18:57.000Z", "num_tokens": 155, "size": 457 }
module Epic where data Nat : Set where Z : Nat S : Nat -> Nat _+_ : Nat -> Nat -> Nat Z + m = m S n + m = S (n + m) _*_ : Nat -> Nat -> Nat Z * m = Z S n * m = m + (n * m) {-# BUILTIN NATURAL Nat #-} {-# BUILTIN NATPLUS _+_ #-} {-# BUILTIN NATTIMES _*_ #-} data Unit : Set where unit : Unit postulate IO : Set -> Set printNat : Nat -> IO Unit {-# COMPILED_EPIC printNat (a : BigInt, u : Unit) -> Unit = putStrLn (bigIntToStr(a)) #-} main : IO Unit main = printNat (7 * 191)
{ "alphanum_fraction": 0.5407554672, "avg_line_length": 16.2258064516, "ext": "agda", "hexsha": "3d75ba8f5c0ad68ce5be70b8ceccf6359446a423", "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/Epic.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/Epic.agda", "max_line_length": 89, "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/Epic.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": 175, "size": 503 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Some properties about signs ------------------------------------------------------------------------ module Data.Sign.Properties where open import Data.Empty open import Function open import Data.Sign open import Relation.Binary.PropositionalEquality -- The opposite of a sign is not equal to the sign. opposite-not-equal : ∀ s → s ≢ opposite s opposite-not-equal - () opposite-not-equal + () -- Sign multiplication is right cancellative. cancel-*-right : ∀ s₁ s₂ {s} → s₁ * s ≡ s₂ * s → s₁ ≡ s₂ cancel-*-right - - _ = refl cancel-*-right - + eq = ⊥-elim (opposite-not-equal _ $ sym eq) cancel-*-right + - eq = ⊥-elim (opposite-not-equal _ eq) cancel-*-right + + _ = refl
{ "alphanum_fraction": 0.5596446701, "avg_line_length": 29.1851851852, "ext": "agda", "hexsha": "55f627831908e83a7df9773f9494b8f780aac70a", "lang": "Agda", "max_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/Sign/Properties.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/Sign/Properties.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/Sign/Properties.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": 190, "size": 788 }
module Cats.Category.Constructions.Mono where open import Level open import Cats.Category.Base module Build {lo la l≈} (Cat : Category lo la l≈) where private open module Cat = Category Cat open Cat.≈-Reasoning IsMono : ∀ {A B} → A ⇒ B → Set (lo ⊔ la ⊔ l≈) IsMono {A} f = ∀ {C} {g h : C ⇒ A} → f ∘ g ≈ f ∘ h → g ≈ h
{ "alphanum_fraction": 0.6121212121, "avg_line_length": 22, "ext": "agda", "hexsha": "21ac19de552de4a3588a86e161ea144b5a45ee72", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_path": "Cats/Category/Constructions/Mono.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "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": "alessio-b-zak/cats", "max_issues_repo_path": "Cats/Category/Constructions/Mono.agda", "max_line_length": 60, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_path": "Cats/Category/Constructions/Mono.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 122, "size": 330 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Functor where open import Level open import Relation.Binary using (IsEquivalence) open import Relation.Binary.PropositionalEquality using () renaming (_≡_ to _≣_) open import Relation.Nullary using (¬_) open import Data.Product using (Σ; _×_; ∃; proj₁) open import Categories.Category open import Categories.Functor.Core public import Categories.Morphisms as Morphisms infix 4 _≡_ _≡_ : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → (F G : Functor C D) → Set (e′ ⊔ ℓ′ ⊔ ℓ ⊔ o) _≡_ {C = C} {D} F G = ∀ {A B} → (f : C [ A , B ]) → Functor.F₁ F f ∼ Functor.F₁ G f where open Heterogeneous D ≡⇒≣ : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → (F G : Functor C D) → F ≡ G → (∀ x → Functor.F₀ F x ≣ Functor.F₀ G x) ≡⇒≣ {C = C} {D} F G F≡G x = domain-≣ (F≡G (Category.id C {x})) where open Heterogeneous D .assoc : ∀ {o₀ ℓ₀ e₀ o₁ ℓ₁ e₁ o₂ ℓ₂ e₂ o₃ ℓ₃ e₃} {C₀ : Category o₀ ℓ₀ e₀} {C₁ : Category o₁ ℓ₁ e₁} {C₂ : Category o₂ ℓ₂ e₂} {C₃ : Category o₃ ℓ₃ e₃} {F : Functor C₀ C₁} {G : Functor C₁ C₂} {H : Functor C₂ C₃} → (H ∘ G) ∘ F ≡ H ∘ (G ∘ F) assoc {C₃ = C₃} f = refl where open Heterogeneous C₃ .identityˡ : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {F : Functor C D} → id ∘ F ≡ F identityˡ {C = C} {D} {F} f = refl where open Heterogeneous D .identityʳ : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {F : Functor C D} → F ∘ id ≡ F identityʳ {C = C} {D} {F} f = refl where open Heterogeneous D .equiv : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → IsEquivalence (_≡_ {C = C} {D = D}) equiv {C = C} {D} = record { refl = λ f → refl ; sym = λ F∼G f → sym (F∼G f) ; trans = λ F∼G G∼H f → trans (F∼G f) (G∼H f) } where open Heterogeneous D .∘-resp-≡ : ∀ {o₀ ℓ₀ e₀ o₁ ℓ₁ e₁ o₂ ℓ₂ e₂} {A : Category o₀ ℓ₀ e₀} {B : Category o₁ ℓ₁ e₁} {C : Category o₂ ℓ₂ e₂} {F H : Functor B C} {G I : Functor A B} → F ≡ H → G ≡ I → F ∘ G ≡ H ∘ I ∘-resp-≡ {B = B} {C} {F} {I = I} F≡H G≡I q = helper (G≡I q) (F≡H (Functor.F₁ I q)) where open Heterogeneous C module C = Category C helper : ∀ {a b c d} {z w} {f : B [ a , b ]} {h : B [ c , d ]} {i : C [ z , w ]} → B [ f ∼ h ] → C [ Functor.F₁ F h ∼ i ] → C [ Functor.F₁ F f ∼ i ] helper (≡⇒∼ f≡h) (≡⇒∼ g≡i) = ≡⇒∼ (C.Equiv.trans (Functor.F-resp-≡ F f≡h) g≡i) Faithful : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → Functor C D → Set (o ⊔ ℓ ⊔ e ⊔ e′) Faithful {C = C} {D} F = ∀ {X Y} → (f g : C [ X , Y ]) → D [ F₁ f ≡ F₁ g ] → C [ f ≡ g ] where module C = Category C module D = Category D open Functor F -- Is this convoluted double-negated definition really necessary? A naive constructive definition of surjectivity -- requires a right inverse, which would probably restrict the things we can provide proofs for Full : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → Functor C D → Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) Full {C = C} {D} F = ∀ {X Y} → ¬ Σ (D [ F₀ X , F₀ Y ]) (λ f → ¬ Σ (C [ X , Y ]) (λ g → D [ F₁ g ≡ f ])) where module C = Category C module D = Category D open Functor F FullyFaithful : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → Functor C D → Set (o ⊔ ℓ ⊔ e ⊔ ℓ′ ⊔ e′) FullyFaithful F = Full F × Faithful F {- [02:22:21 AM] <ddarius> copumpkin: So I think the normal statement is fine. You should be requiring F_1 to be a setoid function, i.e. forall x ~ x'. f(x) ~ f(x'). The function that would be required by the forall y.exists x. ... is not a setoid function and thus doesn't necessarily produce an inverse. That is, you'll have a function g such that f(g(y)) ~ y but not necessarily f(g(y)) = y and it is not necessary that for y ~ y' that [02:22:22 AM] <ddarius> g(y) ~ g(y'), they could be different w.r.t. the domain setoid as long as f still maps them to equivalent elements in the codomain. [02:27:53 AM] <ddarius> For example, let f : 2/= -> 2/~ (where True ~ False). Then, we need g(True) and g(False) and we could use g = not, even though True /= False and f(g(y)) /= y (assuming say f is id on the carrier), because it is still the case that f(g(y)) ~ y. [02:28:55 AM] <ddarius> So g isn't an inverse on the carrier sets, and g isn't a setoid function inverse because it's not even a setoid function. -} EssentiallySurjective : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → Functor C D → Set _ EssentiallySurjective {D = D} F = ∀ d → ∃ (λ c → F₀ c ≅ d) where open Functor F open Morphisms D
{ "alphanum_fraction": 0.5765765766, "avg_line_length": 48.5625, "ext": "agda", "hexsha": "f2fd56a6dfdde5b8ceea432a8ff83f02a9b7c84a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Functor.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "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": "p-pavel/categories", "max_issues_repo_path": "Categories/Functor.agda", "max_line_length": 438, "max_stars_count": 1, "max_stars_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "p-pavel/categories", "max_stars_repo_path": "Categories/Functor.agda", "max_stars_repo_stars_event_max_datetime": "2018-12-29T21:51:57.000Z", "max_stars_repo_stars_event_min_datetime": "2018-12-29T21:51:57.000Z", "num_tokens": 1949, "size": 4662 }