Search is not available for this dataset
text
string
meta
dict
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.ListedFiniteSet.Properties where open import Cubical.Foundations.Prelude open import Cubical.Data.Prod using (_×_; _,_) open import Cubical.HITs.ListedFiniteSet.Base private variable ℓ : Level A B : Type ℓ assoc-++ : ∀ (xs : LFSet A) ys zs → xs ++ (ys ++ zs) ≡ (xs ++ ys) ++ zs assoc-++ [] ys zs = refl assoc-++ (x ∷ xs) ys zs = cong (x ∷_) (assoc-++ xs ys zs) assoc-++ (dup x xs i) ys zs j = dup x (assoc-++ xs ys zs j) i assoc-++ (comm x y xs i) ys zs j = comm x y (assoc-++ xs ys zs j) i assoc-++ (trunc xs xs' p q i k) ys zs j = trunc (assoc-++ xs ys zs j) (assoc-++ xs' ys zs j) (cong (λ xs → assoc-++ xs ys zs j) p) (cong (λ xs → assoc-++ xs ys zs j) q) i k comm-++-[] : ∀ (xs : LFSet A) → xs ++ [] ≡ [] ++ xs comm-++-[] xs = PropElim.f refl (λ x {xs} ind → (x ∷ xs) ++ [] ≡⟨ refl ⟩ x ∷ (xs ++ []) ≡⟨ cong (x ∷_) ind ⟩ x ∷ xs ≡⟨ refl ⟩ [] ++ (x ∷ xs) ∎ ) (λ _ → trunc _ _) xs comm-++-∷ : ∀ (z : A) xs ys → xs ++ (z ∷ ys) ≡ (z ∷ xs) ++ ys comm-++-∷ z xs ys = PropElim.f refl (λ x {xs} ind → x ∷ (xs ++ (z ∷ ys)) ≡⟨ cong (x ∷_) ind ⟩ x ∷ z ∷ (xs ++ ys) ≡⟨ comm x z (xs ++ ys) ⟩ z ∷ x ∷ (xs ++ ys) ∎ ) (λ _ → trunc _ _) xs comm-++ : (xs ys : LFSet A) → xs ++ ys ≡ ys ++ xs comm-++ xs ys = PropElim.f (comm-++-[] xs) (λ y {ys} ind → xs ++ (y ∷ ys) ≡⟨ comm-++-∷ y xs ys ⟩ y ∷ (xs ++ ys) ≡⟨ cong (y ∷_) ind ⟩ y ∷ (ys ++ xs) ≡⟨ refl ⟩ (y ∷ ys) ++ xs ∎ ) (λ _ → trunc _ _) ys idem-++ : (xs : LFSet A) → xs ++ xs ≡ xs idem-++ = PropElim.f refl (λ x {xs} ind → (x ∷ xs) ++ (x ∷ xs) ≡⟨ refl ⟩ x ∷ (xs ++ (x ∷ xs)) ≡⟨ refl ⟩ x ∷ (xs ++ ((x ∷ []) ++ xs)) ≡⟨ cong (x ∷_) (assoc-++ xs (x ∷ []) xs) ⟩ x ∷ ((xs ++ (x ∷ [])) ++ xs) ≡⟨ cong (λ h → x ∷ (h ++ xs)) (comm-++ xs (x ∷ [])) ⟩ x ∷ x ∷ (xs ++ xs) ≡⟨ cong (λ ys → x ∷ x ∷ ys) ind ⟩ x ∷ x ∷ xs ≡⟨ dup x xs ⟩ x ∷ xs ∎ ) (λ xs → trunc (xs ++ xs) xs) cart-product : LFSet A → LFSet B → LFSet (A × B) cart-product [] ys = [] cart-product (x ∷ xs) ys = map (x ,_) ys ++ cart-product xs ys cart-product (dup x xs i) ys = ( map (x ,_) ys ++ (map (x ,_) ys ++ cart-product xs ys) ≡⟨ assoc-++ (map (x ,_) ys) (map (x ,_) ys) (cart-product xs ys) ⟩ (map (x ,_) ys ++ map (x ,_) ys) ++ cart-product xs ys ≡⟨ cong (_++ cart-product xs ys) (idem-++ (map (x ,_) ys)) ⟩ map (x ,_) ys ++ cart-product xs ys ∎ ) i cart-product (comm x y xs i) ys = ( map (x ,_) ys ++ (map (y ,_) ys ++ cart-product xs ys) ≡⟨ assoc-++ (map (x ,_) ys) (map (y ,_) ys) (cart-product xs ys) ⟩ (map (x ,_) ys ++ map (y ,_) ys) ++ cart-product xs ys ≡⟨ cong (_++ cart-product xs ys) (comm-++ (map (x ,_) ys) (map (y ,_) ys)) ⟩ (map (y ,_) ys ++ map (x ,_) ys) ++ cart-product xs ys ≡⟨ sym (assoc-++ (map (y ,_) ys) (map (x ,_) ys) (cart-product xs ys)) ⟩ map (y ,_) ys ++ (map (x ,_) ys ++ cart-product xs ys) ∎ ) i cart-product (trunc xs xs′ p q i j) ys = trunc (cart-product xs ys) (cart-product xs′ ys) (λ k → cart-product (p k) ys) (λ k → cart-product (q k) ys) i j
{ "alphanum_fraction": 0.4529339853, "avg_line_length": 30.5794392523, "ext": "agda", "hexsha": "bfb2d562d242b0dab96a34ec5b7c95110841ee74", "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/ListedFiniteSet/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/HITs/ListedFiniteSet/Properties.agda", "max_line_length": 82, "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/ListedFiniteSet/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1407, "size": 3272 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Structures.TypeEqvTo where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.HITs.PropositionalTruncation open import Cubical.Data.Sigma open import Cubical.Foundations.SIP open import Cubical.Foundations.Pointed open import Cubical.Structures.Axioms open import Cubical.Structures.Pointed private variable ℓ ℓ' ℓ'' : Level TypeEqvTo : (ℓ : Level) (X : Type ℓ') → Type (ℓ-max (ℓ-suc ℓ) ℓ') TypeEqvTo ℓ X = TypeWithStr ℓ (λ Y → ∥ Y ≃ X ∥) PointedEqvTo : (ℓ : Level) (X : Type ℓ') → Type (ℓ-max (ℓ-suc ℓ) ℓ') PointedEqvTo ℓ X = TypeWithStr ℓ (λ Y → Y × ∥ Y ≃ X ∥) module _ (X : Type ℓ') where PointedEqvToStructure : Type ℓ → Type (ℓ-max ℓ ℓ') PointedEqvToStructure = AxiomsStructure PointedStructure (λ Y _ → ∥ Y ≃ X ∥) PointedEqvToEquivStr : StrEquiv PointedEqvToStructure ℓ'' PointedEqvToEquivStr = AxiomsEquivStr PointedEquivStr (λ Y _ → ∥ Y ≃ X ∥) pointedEqvToUnivalentStr : UnivalentStr {ℓ} PointedEqvToStructure PointedEqvToEquivStr pointedEqvToUnivalentStr = axiomsUnivalentStr PointedEquivStr {axioms = λ Y _ → ∥ Y ≃ X ∥} (λ _ _ → squash) pointedUnivalentStr PointedEqvToSIP : (A B : PointedEqvTo ℓ X) → A ≃[ PointedEqvToEquivStr ] B ≃ (A ≡ B) PointedEqvToSIP = SIP pointedEqvToUnivalentStr PointedEqvTo-sip : (A B : PointedEqvTo ℓ X) → A ≃[ PointedEqvToEquivStr ] B → (A ≡ B) PointedEqvTo-sip A B = equivFun (PointedEqvToSIP A B)
{ "alphanum_fraction": 0.7023498695, "avg_line_length": 36.4761904762, "ext": "agda", "hexsha": "f721fa8960220e20c6140a8635addde3d867bbfa", "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/Structures/TypeEqvTo.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Structures/TypeEqvTo.agda", "max_line_length": 92, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Structures/TypeEqvTo.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 579, "size": 1532 }
{-# OPTIONS --warning=error --safe --without-K #-} open import LogicalFormulae open import Numbers.Naturals.Definition open import Maybe module Numbers.Naturals.Subtraction where _-N'_ : (a b : ℕ) → Maybe ℕ zero -N' zero = yes 0 zero -N' succ b = no succ a -N' zero = yes (succ a) succ a -N' succ b = a -N' b subtractZero : (a : ℕ) → a -N' 0 ≡ yes a subtractZero zero = refl subtractZero (succ a) = refl
{ "alphanum_fraction": 0.6715686275, "avg_line_length": 22.6666666667, "ext": "agda", "hexsha": "a2531e434f3a04d76ddaba9372275d7af90a49cb", "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/Subtraction.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/Subtraction.agda", "max_line_length": 50, "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/Subtraction.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": 134, "size": 408 }
open import Common.Equality open import Common.Prelude NaN : Float NaN = primFloatDiv 0.0 0.0 NaN≢-NaN : primFloatEquality NaN (primFloatNegate NaN) ≡ false NaN≢-NaN = refl
{ "alphanum_fraction": 0.7556818182, "avg_line_length": 17.6, "ext": "agda", "hexsha": "32491e468cceb1da16730fda7cef0d45686ef852", "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/Issue2194.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/Issue2194.agda", "max_line_length": 62, "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/Issue2194.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 60, "size": 176 }
module Prelude.Strings where import Data.String.Literals import Data.List.Literals open import Data.Unit open import Agda.Builtin.FromString public instance isStringStringPublic = Data.String.Literals.isString isStringListPublic = Data.List.Literals.isString unitInstance = tt
{ "alphanum_fraction": 0.8251748252, "avg_line_length": 22, "ext": "agda", "hexsha": "4e8ad8dcaef43ed52b6daee8942ca461ee76c3c7", "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/Prelude/Strings.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/Prelude/Strings.agda", "max_line_length": 54, "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/Prelude/Strings.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": 66, "size": 286 }
module B where import C
{ "alphanum_fraction": 0.76, "avg_line_length": 6.25, "ext": "agda", "hexsha": "ca48559b6d8db60418372dacb4d56ad506d76c8f", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "examples/uptodate/B.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "examples/uptodate/B.agda", "max_line_length": 14, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "examples/uptodate/B.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 7, "size": 25 }
{-# OPTIONS --universe-polymorphism #-} open import Categories.Category module Categories.Object.Exponential {o ℓ e} (C : Category o ℓ e) where open Category C open import Level open import Categories.Square import Categories.Object.Product open Categories.Object.Product C hiding (repack; repack≡id; repack∘; repack-cancel; up-to-iso; transport-by-iso) import Categories.Object.Product.Morphisms open Categories.Object.Product.Morphisms C import Categories.Morphisms as Morphisms record Exponential (A B : Obj) : Set (o ⊔ ℓ ⊔ e) where field B^A : Obj product : Product B^A A module product = Product product B^A×A : Obj B^A×A = product.A×B field eval : B^A×A ⇒ B λg : {X : Obj} → (X×A : Product X A) → (Product.A×B X×A ⇒ B) → (X ⇒ B^A) .β : {X : Obj} → (X×A : Product X A) → {g : Product.A×B X×A ⇒ B} → (eval ∘ [ X×A ⇒ product ]first (λg X×A g) ≡ g) .λ-unique : {X : Obj} → (X×A : Product X A) → {g : Product.A×B X×A ⇒ B} → {h : X ⇒ B^A} → (eval ∘ [ X×A ⇒ product ]first h ≡ g) → (h ≡ λg X×A g) .η : ∀ {X : Obj} (X×A : Product X A) {f : X ⇒ B^A } → λg X×A (eval ∘ [ X×A ⇒ product ]first f) ≡ f η X×A {f} = sym (λ-unique X×A refl) where open Equiv .λ-cong : {X : Obj}(X×A : Product X A) → ∀{f g} → (f ≡ g) → (λg X×A f ≡ λg X×A g) λ-cong X×A {f}{g} f≡g = λ-unique X×A (trans (β X×A) f≡g) where open Equiv .subst : ∀ {C D} → (p₂ : Product C A) → (p₃ : Product D A) → {f : Product.A×B p₃ ⇒ B}{g : C ⇒ D} → λg p₃ f ∘ g ≡ λg p₂ (f ∘ [ p₂ ⇒ p₃ ]first g) subst {C}{D} p₂ p₃ {f}{g} = λ-unique p₂ subst-commutes where open HomReasoning open Equiv subst-commutes = let p₁ = product in begin eval ∘ [ p₂ ⇒ p₁ ]first (λg p₃ f ∘ g) ↑⟨ refl ⟩∘⟨ [ p₂ ⇒ p₃ ⇒ p₁ ]first∘first ⟩ eval ∘ [ p₃ ⇒ p₁ ]first (λg p₃ f) ∘ [ p₂ ⇒ p₃ ]first g ↑⟨ assoc ⟩ (eval ∘ [ p₃ ⇒ p₁ ]first (λg p₃ f)) ∘ [ p₂ ⇒ p₃ ]first g ↓⟨ β p₃ ⟩∘⟨ refl ⟩ f ∘ [ p₂ ⇒ p₃ ]first g ∎ .η-id : λg product eval ≡ id η-id = begin λg product eval ↑⟨ identityʳ ⟩ λg product eval ∘ id ↓⟨ subst _ _ ⟩ λg product (eval ∘ [ product ⇒ product ]first id) ↓⟨ η product ⟩ id ∎ where open Equiv open HomReasoning open Morphisms C -- some aliases to make proof signatures less ugly [_]eval : ∀{A B}(e₁ : Exponential A B) → Exponential.B^A×A e₁ ⇒ B [ e₁ ]eval = Exponential.eval e₁ [_]λ : ∀{A B}(e₁ : Exponential A B) → {X : Obj} → (X×A : Product X A) → (Product.A×B X×A ⇒ B) → (X ⇒ Exponential.B^A e₁) [ e₁ ]λ = Exponential.λg e₁ .λ-distrib : ∀ {A B C D} → (e₁ : Exponential C B) → (e₂ : Exponential A B) → (p₃ : Product D C) → (p₄ : Product D A) → (p₅ : Product (Exponential.B^A e₂) C) → {f : C ⇒ A}{g : Product.A×B p₄ ⇒ B} → [ e₁ ]λ p₃ (g ∘ [ p₃ ⇒ p₄ ]second f) ≡ [ e₁ ]λ p₅ ([ e₂ ]eval ∘ [ p₅ ⇒ Exponential.product e₂ ]second f) ∘ [ e₂ ]λ p₄ g λ-distrib {A}{B}{C}{D} e₁ e₂ p₃ p₄ p₅ {f}{g} = begin [ e₁ ]λ p₃ (g ∘ [ p₃ ⇒ p₄ ]second f) ↑⟨ e₁.λ-cong p₃ eval∘second∘first ⟩ [ e₁ ]λ p₃ (([ e₂ ]eval ∘ [ p₅ ⇒ Exponential.product e₂ ]second f) ∘ [ p₃ ⇒ p₅ ]first ([ e₂ ]λ p₄ g)) ↑⟨ e₁.subst p₃ p₅ ⟩ [ e₁ ]λ p₅ ([ e₂ ]eval ∘ [ p₅ ⇒ Exponential.product e₂ ]second f) ∘ [ e₂ ]λ p₄ g ∎ where open HomReasoning open Equiv module e₁ = Exponential e₁ module e₂ = Exponential e₂ eval∘second∘first = let p₁ = e₁.product in let p₂ = e₂.product in begin ([ e₂ ]eval ∘ [ p₅ ⇒ Exponential.product e₂ ]second f) ∘ [ p₃ ⇒ p₅ ]first ([ e₂ ]λ p₄ g) ↓⟨ assoc ⟩ [ e₂ ]eval ∘ [ p₅ ⇒ p₂ ]second f ∘ [ p₃ ⇒ p₅ ]first ([ e₂ ]λ p₄ g) ↑⟨ refl ⟩∘⟨ [ p₄ ⇒ p₂ , p₃ ⇒ p₅ ]first↔second ⟩ [ e₂ ]eval ∘ [ p₄ ⇒ p₂ ]first ([ e₂ ]λ p₄ g) ∘ [ p₃ ⇒ p₄ ]second f ↑⟨ assoc ⟩ ([ e₂ ]eval ∘ [ p₄ ⇒ p₂ ]first ([ e₂ ]λ p₄ g)) ∘ [ p₃ ⇒ p₄ ]second f ↓⟨ e₂.β p₄ ⟩∘⟨ refl ⟩ g ∘ [ p₃ ⇒ p₄ ]second f ∎ repack : ∀{A B} (e₁ e₂ : Exponential A B) → Exponential.B^A e₁ ⇒ Exponential.B^A e₂ repack e₁ e₂ = e₂.λg e₁.product e₁.eval where module e₁ = Exponential e₁ module e₂ = Exponential e₂ .repack≡id : ∀{A B} (e : Exponential A B) → repack e e ≡ id repack≡id e = Exponential.η-id e .repack∘ : ∀{A B} (e₁ e₂ e₃ : Exponential A B) → repack e₂ e₃ ∘ repack e₁ e₂ ≡ repack e₁ e₃ repack∘ {A} {B} e₁ e₂ e₃ = let p₁ = product e₁ in let p₂ = product e₂ in begin [ e₃ ]λ p₂ [ e₂ ]eval ∘ [ e₂ ]λ p₁ [ e₁ ]eval ↓⟨ λ-cong e₃ p₂ (introʳ (second-id p₂)) ⟩∘⟨ refl ⟩ [ e₃ ]λ p₂ ([ e₂ ]eval ∘ [ p₂ ⇒ p₂ ]second id) ∘ [ e₂ ]λ p₁ [ e₁ ]eval ↑⟨ λ-distrib e₃ e₂ p₁ p₁ p₂ ⟩ [ e₃ ]λ p₁ ([ e₁ ]eval ∘ [ p₁ ⇒ p₁ ]second id) ↑⟨ λ-cong e₃ p₁ (introʳ (second-id p₁)) ⟩ [ e₃ ]λ p₁ [ e₁ ]eval ∎ where open Equiv open Exponential open HomReasoning open GlueSquares C .repack-cancel : ∀{A B} (e₁ e₂ : Exponential A B) → repack e₁ e₂ ∘ repack e₂ e₁ ≡ id repack-cancel e₁ e₂ = Equiv.trans (repack∘ e₂ e₁ e₂) (repack≡id e₂) up-to-iso : ∀{A B} (e₁ e₂ : Exponential A B) → Exponential.B^A e₁ ≅ Exponential.B^A e₂ up-to-iso e₁ e₂ = record { f = repack e₁ e₂ ; g = repack e₂ e₁ ; iso = record { isoˡ = repack-cancel e₂ e₁ ; isoʳ = repack-cancel e₁ e₂ } } transport-by-iso : ∀{A B} (e : Exponential A B) → ∀ {X} → Exponential.B^A e ≅ X → Exponential A B transport-by-iso e {X} e≅X = record { B^A = X ; product = X×A ; eval = e.eval ; λg = λ Y×A y → f ∘ e.λg Y×A y ; β = λ Y×A → let open HomReasoning in let open GlueSquares C in let open Equiv in begin e.eval ∘ [ Y×A ⇒ X×A ]first (f ∘ e.λg Y×A _) ↓⟨ ∘-resp-≡ʳ (e.product.⟨⟩-cong₂ (pullˡ (cancelLeft isoˡ)) (pullˡ identityˡ)) ⟩ e.eval ∘ [ Y×A ⇒ e.product ]first (e.λg Y×A _) ↓⟨ (e.β Y×A) ⟩ _ ∎ ; λ-unique = λ Y×A y → let open GlueSquares C in switch-gfˡ e≅X (e.λ-unique Y×A (Equiv.trans (∘-resp-≡ʳ (e.product.⟨⟩-cong₂ assoc (Equiv.sym (pullˡ identityˡ)))) y)) -- look ma i can write lisp in agda --xplat } where module e = Exponential e X×A = Mobile e.product e≅X idⁱ open _≅_ e≅X
{ "alphanum_fraction": 0.5254077792, "avg_line_length": 27.8427947598, "ext": "agda", "hexsha": "816512495170d760ee991631b111a9363680247d", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Object/Exponential.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Object/Exponential.agda", "max_line_length": 105, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Object/Exponential.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": 2821, "size": 6376 }
{-# OPTIONS --no-sized-types #-} open import Common.Size renaming (↑_ to _^) data Nat : {size : Size} -> Set where zero : {size : Size} -> Nat {size ^} suc : {size : Size} -> Nat {size} -> Nat {size ^} weak : {i : Size} -> Nat {i} -> Nat {∞} weak x = x -- Should give error without sized types. -- .i != ∞ of type Size -- when checking that the expression x has type Nat
{ "alphanum_fraction": 0.5853018373, "avg_line_length": 23.8125, "ext": "agda", "hexsha": "3c18d43e3bf17aa8a001a26fb2b556a9c3670439", "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/NoSizedTypes.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/NoSizedTypes.agda", "max_line_length": 52, "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/NoSizedTypes.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": 117, "size": 381 }
module datatypes-safe where open import bool public open import integer public open import list public open import level public open import maybe public open import nat public open import nat-division public open import product public open import sum public open import tree public open import trie public open import unit public open import vector public
{ "alphanum_fraction": 0.837535014, "avg_line_length": 22.3125, "ext": "agda", "hexsha": "cdac3831b1d25eb99e9a6a442f4137c2af39a07c", "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": "datatypes-safe.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": "datatypes-safe.agda", "max_line_length": 31, "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": "datatypes-safe.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": 357 }
{-# OPTIONS --without-K #-} module hott.topology.spaces.s1 where open import hott.core -- The universe where we work. 𝒰 = Type₀ module Definition where private data SInternal : 𝒰 where pointInternal : SInternal S₁ : 𝒰 S₁ = SInternal point : S₁ point = pointInternal postulate loop : point ≡ point -- the induction principle for s₁ ind-S₁ : {ℓ : Level}{B : S₁ → Type ℓ} → (b : B point) → (b ≡ b) → (x : S₁) → B x ind-S₁ b x pointInternal = b open Definition
{ "alphanum_fraction": 0.6038095238, "avg_line_length": 18.1034482759, "ext": "agda", "hexsha": "603597b74b367345f94beb07d88a4b51fee6500a", "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": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_path": "agda/hott/topology/spaces/s1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "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": "piyush-kurur/hott", "max_issues_repo_path": "agda/hott/topology/spaces/s1.agda", "max_line_length": 40, "max_stars_count": null, "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_path": "agda/hott/topology/spaces/s1.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 165, "size": 525 }
{-# OPTIONS --safe --warning=error #-} open import LogicalFormulae open import Setoids.Setoids open import Setoids.Lists open import Functions open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Numbers.Naturals open import Sets.FinSet open import Groups.GroupDefinition open import Lists.Lists open import Orders open import Groups.Groups module Groups.GeneratedGroup where data FreeCompletion {a b : _} {A : Set a} (S : Setoid {a} {b} A) : Set (a ⊔ b) where ofLetter : A → FreeCompletion S ofInv : A → FreeCompletion S freeCompletionMap : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} (f : A → B) → FreeCompletion S → FreeCompletion T freeCompletionMap f (ofLetter x) = ofLetter (f x) freeCompletionMap f (ofInv x) = ofInv (f x) freeInverse : {a b : _} {A : Set a} {S : Setoid {a} {b} A} (l : FreeCompletion S) → FreeCompletion S freeInverse (ofLetter x) = ofInv x freeInverse (ofInv x) = ofLetter x freeCompletionSetoid : {a b : _} {A : Set a} (S : Setoid {a} {b} A) → Setoid (FreeCompletion S) (freeCompletionSetoid S Setoid.∼ ofLetter w) (ofLetter x) = Setoid._∼_ S w x (freeCompletionSetoid S Setoid.∼ ofLetter w) (ofInv x) = False' (freeCompletionSetoid S Setoid.∼ ofInv w) (ofLetter x) = False' (freeCompletionSetoid S Setoid.∼ ofInv w) (ofInv x) = Setoid._∼_ S w x Reflexive.reflexive (Equivalence.reflexiveEq (Setoid.eq (freeCompletionSetoid S))) {ofLetter x} = Reflexive.reflexive (Equivalence.reflexiveEq (Setoid.eq S)) Reflexive.reflexive (Equivalence.reflexiveEq (Setoid.eq (freeCompletionSetoid S))) {ofInv x} = Reflexive.reflexive (Equivalence.reflexiveEq (Setoid.eq S)) Symmetric.symmetric (Equivalence.symmetricEq (Setoid.eq (freeCompletionSetoid S))) {ofLetter w} {ofLetter x} = Symmetric.symmetric (Equivalence.symmetricEq (Setoid.eq S)) Symmetric.symmetric (Equivalence.symmetricEq (Setoid.eq (freeCompletionSetoid S))) {ofLetter w} {ofInv x} () Symmetric.symmetric (Equivalence.symmetricEq (Setoid.eq (freeCompletionSetoid S))) {ofInv w} {ofLetter x} () Symmetric.symmetric (Equivalence.symmetricEq (Setoid.eq (freeCompletionSetoid S))) {ofInv w} {ofInv x} = Symmetric.symmetric (Equivalence.symmetricEq (Setoid.eq S)) Transitive.transitive (Equivalence.transitiveEq (Setoid.eq (freeCompletionSetoid S))) {ofLetter w} {ofLetter x} {ofLetter y} = Transitive.transitive (Equivalence.transitiveEq (Setoid.eq S)) Transitive.transitive (Equivalence.transitiveEq (Setoid.eq (freeCompletionSetoid S))) {ofLetter w} {ofLetter x} {ofInv y} _ () Transitive.transitive (Equivalence.transitiveEq (Setoid.eq (freeCompletionSetoid S))) {ofLetter w} {ofInv x} {y} () Transitive.transitive (Equivalence.transitiveEq (Setoid.eq (freeCompletionSetoid S))) {ofInv w} {ofLetter x} {y} () Transitive.transitive (Equivalence.transitiveEq (Setoid.eq (freeCompletionSetoid S))) {ofInv w} {ofInv x} {ofLetter y} _ () Transitive.transitive (Equivalence.transitiveEq (Setoid.eq (freeCompletionSetoid S))) {ofInv w} {ofInv x} {ofInv y} = Transitive.transitive (Equivalence.transitiveEq (Setoid.eq S)) freeCompletionMapWellDefined : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} (f : A → B) → ({x y : A} → Setoid._∼_ S x y → Setoid._∼_ T (f x) (f y)) → {x y : FreeCompletion S} → (Setoid._∼_ (freeCompletionSetoid S) x y) → (Setoid._∼_ (freeCompletionSetoid T) (freeCompletionMap f x) (freeCompletionMap f y)) freeCompletionMapWellDefined f fWD {ofLetter x} {ofLetter x₁} w1=w2 = fWD w1=w2 freeCompletionMapWellDefined f fWD {ofLetter x} {ofInv x₁} () freeCompletionMapWellDefined f fWD {ofInv x} {ofLetter x₁} () freeCompletionMapWellDefined f fWD {ofInv x} {ofInv x₁} w1=w2 = fWD w1=w2 record Word {a b : _} {A : Set a} (S : Setoid {a} {b} A) : Set (a ⊔ b) where field word : List (FreeCompletion S) wordSetoid : {a b : _} {A : Set a} (S : Setoid {a} {b} A) → Setoid (Word S) (wordSetoid S Setoid.∼ record { word = word1 }) record { word = word2 } = Setoid._∼_ (listSetoid (freeCompletionSetoid S)) word1 word2 Reflexive.reflexive (Equivalence.reflexiveEq (Setoid.eq (wordSetoid S))) {record { word = word }} = Reflexive.reflexive (Equivalence.reflexiveEq (Setoid.eq (listSetoid (freeCompletionSetoid S)))) Symmetric.symmetric (Equivalence.symmetricEq (Setoid.eq (wordSetoid S))) {record { word = word1 }} {record { word = word2 }} pr = Symmetric.symmetric (Equivalence.symmetricEq (Setoid.eq (listSetoid (freeCompletionSetoid S)))) pr Transitive.transitive (Equivalence.transitiveEq (Setoid.eq (wordSetoid S))) {record { word = word1 }} {record { word = word2 }} {record { word = word3 }} pr1 pr2 = Transitive.transitive (Equivalence.transitiveEq (Setoid.eq (listSetoid (freeCompletionSetoid S)))) pr1 pr2 evalWord : {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} (G : Group S _+_) (w : Word S) → A evalWord G record { word = [] } = Group.identity G evalWord {_+_ = _+_} G record { word = (ofLetter x :: w) } = x + evalWord G record { word = w } evalWord {_+_ = _+_} G record { word = (ofInv x :: w) } = (Group.inverse G x) + evalWord G record { word = w } mapWord : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} (f : A → B) (w : Word S) → Word T mapWord f record { word = word } = record { word = map (freeCompletionMap f) word } subgroupSetoid : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} (T : Setoid {b} {d} B) {_+_ : A → A → A} (G : Group S _+_) {f : B → A} (fInj : SetoidInjection T S f) → Setoid (Word T) Setoid._∼_ (subgroupSetoid {S = S} T G {f} fInj) w1 w2 = Setoid._∼_ S (evalWord G (mapWord f w1)) (evalWord G (mapWord f w2)) Reflexive.reflexive (Equivalence.reflexiveEq (Setoid.eq (subgroupSetoid {S = S} T G {f} fInj))) = Reflexive.reflexive (Equivalence.reflexiveEq (Setoid.eq S)) Symmetric.symmetric (Equivalence.symmetricEq (Setoid.eq (subgroupSetoid {S = S} T G {f} fInj))) = Symmetric.symmetric (Equivalence.symmetricEq (Setoid.eq S)) Transitive.transitive (Equivalence.transitiveEq (Setoid.eq (subgroupSetoid {S = S} T G {f} fInj))) = Transitive.transitive (Equivalence.transitiveEq (Setoid.eq S)) evalWordWellDefined : {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} (G : Group S _+_) (w1 w2 : Word S) → Setoid._∼_ (wordSetoid S) w1 w2 → Setoid._∼_ S (evalWord G w1) (evalWord G w2) evalWordWellDefined {S = S} G record { word = [] } record { word = [] } w1=w2 = Reflexive.reflexive (Equivalence.reflexiveEq (Setoid.eq S)) evalWordWellDefined G record { word = [] } record { word = (x :: word) } () evalWordWellDefined {_+_ = _+_} G record { word = (x :: xs) } record { word = [] } () evalWordWellDefined {_+_ = _+_} G record { word = (ofLetter x :: xs) } record { word = (ofLetter y :: ys) } (x=y ,, snd) = Group.wellDefined G x=y (evalWordWellDefined G record { word = xs } record { word = ys } snd) evalWordWellDefined {_+_ = _+_} G record { word = (ofLetter x :: xs) } record { word = (ofInv y :: ys) } (() ,, snd) evalWordWellDefined {_+_ = _+_} G record { word = (ofInv x :: xs) } record { word = (ofLetter y :: ys) } (() ,, snd) evalWordWellDefined {_+_ = _+_} G record { word = (ofInv x :: xs) } record { word = (ofInv y :: ys) } (x=y ,, snd) = Group.wellDefined G (inverseWellDefined G x=y) (evalWordWellDefined G record { word = xs } record { word = ys } snd) mapWordWellDefined : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} (f : A → B) → ({x y : A} → (Setoid._∼_ S x y) → (Setoid._∼_ T (f x) (f y))) → {w1 : Word S} {w2 : Word S} → Setoid._∼_ (wordSetoid S) w1 w2 → Setoid._∼_ (wordSetoid T) (mapWord f w1) (mapWord f w2) mapWordWellDefined {S = S} {T = T} f fWD {w1} {w2} w1=w2 = p where p : listEquality (freeCompletionSetoid T) (map (freeCompletionMap {S = S} {T = T} f) (Word.word w1)) (map (freeCompletionMap f) (Word.word w2)) p = listEqualityRespectsMap (freeCompletionSetoid S) (freeCompletionSetoid T) (freeCompletionMap {S = S} {T} f) (λ {x} {y} → freeCompletionMapWellDefined {S = S} {T = T} f fWD {x} {y}) {w1 = Word.word w1} {w2 = Word.word w2} w1=w2 subgroupOp : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} (T : Setoid {b} {d} B) {_+_ : A → A → A} (G : Group S _+_) {f : B → A} (fInj : SetoidInjection T S f) → Word T → Word T → Word T subgroupOp T G fInj record { word = word1 } record { word = word2 } = record { word = word1 ++ word2 } generatedSubgroup : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} (T : Setoid {b} {d} B) {_+_ : A → A → A} (G : Group S _+_) {f : B → A} (fInj : SetoidInjection T S f) → Group (subgroupSetoid T G fInj) (subgroupOp T G fInj) Group.wellDefined (generatedSubgroup {S = S} T G {f = f} fInj) {record { word = w }} {record { word = x }} {record { word = y }} {record { word = z }} w=y x=z = need where need : Setoid._∼_ (subgroupSetoid T G fInj) (subgroupOp T G fInj (record { word = w }) (record { word = x })) (subgroupOp T G fInj (record { word = y }) (record { word = z })) need = {!!} Group.identity (generatedSubgroup T G fInj) = record { word = [] } Group.inverse (generatedSubgroup T G fInj) record { word = word } = record { word = map freeInverse (rev word) } Group.multAssoc (generatedSubgroup T G fInj) = {!!} Group.multIdentRight (generatedSubgroup {S = S} T G {f = f} fInj) {a = record { word = word }} = need where open Setoid S open Group G need : evalWord G (mapWord f (record { word = word ++ [] })) ∼ evalWord G (mapWord f record { word = word }) need = {!!} Group.multIdentLeft (generatedSubgroup {S = S} T G {f = f} fInj) = Reflexive.reflexive (Equivalence.reflexiveEq (Setoid.eq S)) Group.invLeft (generatedSubgroup {S = S} T G {f} fInj) {record { word = [] }} = Reflexive.reflexive (Equivalence.reflexiveEq (Setoid.eq S)) Group.invLeft (generatedSubgroup {S = S} T G {f} fInj) {record { word = x :: word }} = need where open Setoid S open Group G need : Setoid._∼_ (subgroupSetoid T G fInj) (record { word = (map freeInverse (rev (x :: word))) ++ (x :: word) }) (Group.identity (generatedSubgroup T G fInj)) need = {!!} Group.invRight (generatedSubgroup T G fInj) = {!!}
{ "alphanum_fraction": 0.6532736648, "avg_line_length": 87.8547008547, "ext": "agda", "hexsha": "2b5afd805baff5e15428e8d430d9897e91cbe8c2", "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/GeneratedGroup.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/GeneratedGroup.agda", "max_line_length": 347, "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/GeneratedGroup.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": 3612, "size": 10279 }
open import Agda.Builtin.Unit open import Agda.Builtin.Nat open import Agda.Builtin.Equality open import Agda.Builtin.List open import Agda.Builtin.Sigma open import Agda.Builtin.Reflection renaming (bindTC to _>>=_) data ⊥ : Set where [_] : {A : Set} → A → List A [ x ] = x ∷ [] vArg : {A : Set} → A → Arg A vArg x = arg (arg-info visible relevant) x macro getFunDef : Name → Term → TC ⊤ getFunDef f hole = do function cls ← getDefinition f where _ → error niceCls ← quoteTC cls unify hole niceCls where postulate error : _ noooo : (A : Set) → ⊥ → A noooo A () -- Quoting the term `noooo Nat x` used to produce an absurd lambda -- applied to `x`, which should not happen. It should instead simply -- keep the term `noooo Nat x` as-is. fooooo : ⊥ → Nat fooooo x = noooo Nat x test : getFunDef fooooo ≡ [ clause [ "x" , vArg (def (quote ⊥) []) ] [ vArg (var 0) ] (def (quote noooo) (vArg (def (quote Nat) []) ∷ vArg (var 0 []) ∷ [])) ] test = refl
{ "alphanum_fraction": 0.6141885326, "avg_line_length": 24.5, "ext": "agda", "hexsha": "53588158911426905177e600a8a83c5e460973a9", "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": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/Succeed/QuoteAbsurdClause.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "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": "shlevy/agda", "max_issues_repo_path": "test/Succeed/QuoteAbsurdClause.agda", "max_line_length": 88, "max_stars_count": null, "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/QuoteAbsurdClause.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 333, "size": 1029 }
{-# OPTIONS --rewriting #-} open import Agda.Primitive postulate _↦_ : ∀ {i} {A : Set i} → A → A → Set i idr : ∀ {i} {A : Set i} {a : A} → a ↦ a {-# BUILTIN REWRITE _↦_ #-} postulate _==_ : ∀ {i} {A : Set i} → A → A → Set i idp : ∀ {i} {A : Set i} {a : A} → a == a postulate HetEq : ∀ {i} {A B : Set i} (e : A == B) (a : A) (b : B) → Set i HetEq↦ : ∀ {i} {A : Set i} (a b : A) → HetEq idp a b ↦ (a == b) {-# REWRITE HetEq↦ #-} HetEq↦2 : ∀ {i j} {A : Set i} {B : Set j} (u v : A → B) → HetEq idp u v ↦ (u == v) HetEq↦2 u v = idr
{ "alphanum_fraction": 0.4424131627, "avg_line_length": 26.0476190476, "ext": "agda", "hexsha": "4022eaf832662e5c45714a4e54ad87bf16f2bbf3", "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/Issue2090.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/Issue2090.agda", "max_line_length": 82, "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/Issue2090.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": 266, "size": 547 }
module RedBlack where open import Data.Nat -- | The colour of a node. data Color : Set where red : Color black : Color -- | The red black tree data Tree (A : Set) : ℕ -- black height → Color -- color of the root → Set where -- Empty node is always black empty : Tree A 0 black -- Both the children of the red node are black. red : {d : ℕ} → Tree A d black -- left child → A -- element on the node → Tree A d black -- right child → Tree A d red -- The black height does not change -- The children can be of either color black : {d : ℕ} {cL cR : Color} → Tree A d cL -- left child → A -- element → Tree A d cR -- right child → Tree A (d + 1) black -- black height goes up by one. -- Converts a tree with red root to a black tree. The type encodes the -- fact that the height of the tree goes up by 1. blacken : {A : Set} {d : ℕ} → Tree A d red → Tree A (d + 1) black blacken (red lt x rt) = black lt x rt
{ "alphanum_fraction": 0.5256637168, "avg_line_length": 28.9743589744, "ext": "agda", "hexsha": "3c12458104e6a2583e58948d72464671dae3537a", "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": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "piyush-kurur/sample-code", "max_forks_repo_path": "agda/RedBlack/RedBlack.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_issues_repo_issues_event_max_datetime": "2017-11-01T05:48:28.000Z", "max_issues_repo_issues_event_min_datetime": "2017-11-01T05:48:28.000Z", "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "piyush-kurur/sample-code", "max_issues_repo_path": "agda/RedBlack/RedBlack.agda", "max_line_length": 70, "max_stars_count": 2, "max_stars_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "piyush-kurur/sample-code", "max_stars_repo_path": "agda/RedBlack/RedBlack.agda", "max_stars_repo_stars_event_max_datetime": "2017-06-20T02:19:33.000Z", "max_stars_repo_stars_event_min_datetime": "2017-06-19T12:34:08.000Z", "num_tokens": 319, "size": 1130 }
open import Agda.Builtin.Bool open import Agda.Builtin.Equality open import Agda.Builtin.Sigma open import Agda.Primitive infixr 2 _×_ _×_ : ∀ {a b} → Set a → Set b → Set (a ⊔ b) A × B = Σ A λ _ → B ∃-notation exists-notation : ∀ {a b} {A : Set a} → (A → Set b) → Set (a ⊔ b) ∃-notation = Σ _ exists-notation = Σ _ Σ-notation : ∀ {a b} (A : Set a) → (A → Set b) → Set (a ⊔ b) Σ-notation = Σ infixr 2 ∃-notation exists-notation Σ-notation syntax ∃-notation (λ x → B) = ∃ x × B syntax exists-notation (λ x → B) = exists x × B syntax Σ-notation A (λ x → B) = [ x ∶ A ] × B _ : ∃ b × b ≡ true × Bool _ = true , refl , false _ : exists b × b ≡ true _ = true , refl _ : [ b ∶ Bool ] × b ≡ true _ = true , refl _ : [ b₁ ∶ Bool ] × [ b₂ ∶ Bool ] × b₁ ≡ b₂ _ = true , true , refl _ : [ b₁ ∶ Bool ] × ∃ b₂ × b₁ ≡ b₂ _ = true , true , refl _ : [ f ∶ (Bool → Bool) ] × f ≡ λ x → x _ = (λ x → x) , refl data List (A : Set) : Set where [] : List A cons : A → List A → List A infixr 5 cons syntax [] = [ ] syntax cons x xs = x consed to xs _ : List Bool _ = true consed to false consed to [ ] f : List Bool → Bool f [ ] = true f (true consed to [ ]) = false f (false consed to x consed to [ ]) = x f _ = true
{ "alphanum_fraction": 0.5129375951, "avg_line_length": 21.9, "ext": "agda", "hexsha": "9a2382e2c0157592d060a3449e53d9f8cbc12a1b", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Succeed/Issue5201.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Succeed/Issue5201.agda", "max_line_length": 60, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Succeed/Issue5201.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": 510, "size": 1314 }
{-# OPTIONS --rewriting #-} open import Agda.Builtin.Bool open import Agda.Builtin.Equality {-# BUILTIN REWRITE _≡_ #-} funny : true ≡ false → true ≡ false funny x = x {-# REWRITE funny #-}
{ "alphanum_fraction": 0.6597938144, "avg_line_length": 16.1666666667, "ext": "agda", "hexsha": "83fdce17298572c394c223bbe9fdc23cacae26f8", "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/Issue1980.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/Issue1980.agda", "max_line_length": 35, "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/Issue1980.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": 57, "size": 194 }
module A.M where import A.B.M
{ "alphanum_fraction": 0.7096774194, "avg_line_length": 7.75, "ext": "agda", "hexsha": "f3077cbfc1f511337d7a0cc63958a08978815104", "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/A/M.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/A/M.agda", "max_line_length": 16, "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/A/M.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": 10, "size": 31 }
{-# OPTIONS --type-in-type #-} module dyn where open import prelude open import functors open import poly0 public open import prelude.Stream open Stream open import Data.List as L using (List) record Dyn : Set where constructor dyn field {state} : Set {body} : ∫ pheno : ∫[ (state , λ _ → state) , body ] open Dyn public run : (d : Dyn) → ∫[ body d , 𝒴 ] → state d → Stream (π₁ (body d)) hd (run d@(dyn l) e s₀) = s₀ ★ l tl (run d@(dyn l) e s₀) = run d e (s₀ # l ← hd (run d e s₀) # e ← tt) module _ (d₁ d₂ : Dyn) where _⊠⊠⊠_ : Dyn _⊠⊠⊠_ = dyn (pheno d₁ ⟦⊠⟧ pheno d₂) _⟫_ : (d : Dyn) → ∫[ body d , A ] → Dyn d ⟫ l = dyn (pheno d ▸ l) fun→dyn : ∀ {a b} → (a → b) → Dyn fun→dyn f = dyn (λ a⁺ → a⁺ , f) delay : Set → Dyn delay s = fun→dyn (id {A = s})
{ "alphanum_fraction": 0.558109834, "avg_line_length": 22.3714285714, "ext": "agda", "hexsha": "6abec05927920494116a74f2bbdac76cf205df92", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-30T11:45:57.000Z", "max_forks_repo_forks_event_min_datetime": "2021-07-10T17:19:37.000Z", "max_forks_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dspivak/poly", "max_forks_repo_path": "code-examples/agda/dyn.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea", "max_issues_repo_issues_event_max_datetime": "2022-01-12T10:06:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-09-02T02:29:39.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dspivak/poly", "max_issues_repo_path": "code-examples/agda/dyn.agda", "max_line_length": 69, "max_stars_count": 53, "max_stars_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mstone/poly", "max_stars_repo_path": "code-examples/agda/dyn.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:08:27.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-18T16:31:04.000Z", "num_tokens": 330, "size": 783 }
module Categories.Coequalizer where
{ "alphanum_fraction": 0.8888888889, "avg_line_length": 18, "ext": "agda", "hexsha": "8330f6c0d2933e291d5fd541f605101de76745ab", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Coequalizer.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Coequalizer.agda", "max_line_length": 35, "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/Coequalizer.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": 8, "size": 36 }
open import Mockingbird.Forest using (Forest) module Mockingbird.Forest.Combination.Properties {b ℓ} (forest : Forest {b} {ℓ}) where open import Data.Product using (_×_; _,_) open import Relation.Binary using (_Respects_) open import Relation.Unary using (Pred; _∈_; _⊆_; ∅; _∩_) open import Level using (Level; _⊔_) open Forest forest open import Mockingbird.Forest.Combination.Base forest private variable x y z : Bird p : Level P Q : Pred Bird p subst : P Respects _≈_ → x ≈ y → x ∈ ⟨ P ⟩ → y ∈ ⟨ P ⟩ subst respects x≈y [ x∈P ] = [ respects x≈y x∈P ] subst respects x≈y (x₁∈⟨P⟩ ⟨∙⟩ x₂∈⟨P⟩ ∣ x₁x₂≈x) = x₁∈⟨P⟩ ⟨∙⟩ x₂∈⟨P⟩ ∣ trans x₁x₂≈x x≈y subst′ : P Respects _≈_ → y ≈ x → x ∈ ⟨ P ⟩ → y ∈ ⟨ P ⟩ subst′ respects y≈x = subst respects (sym y≈x) -- TODO: maybe lift ∅ to an arbitrary level p ⟨∅⟩ : ⟨ ∅ ⟩ ⊆ ∅ ⟨∅⟩ (X ⟨∙⟩ Y ∣ xy≈z) = ⟨∅⟩ X ⟨_⟩⊆⟨_⟩ : ∀ {p} (P Q : Pred Bird p) → P ⊆ Q → ⟨ P ⟩ ⊆ ⟨ Q ⟩ ⟨ P ⟩⊆⟨ Q ⟩ P⊆Q [ x∈P ] = [ P⊆Q x∈P ] ⟨ P ⟩⊆⟨ Q ⟩ P⊆Q (x∈⟨P⟩ ⟨∙⟩ y∈⟨P⟩ ∣ xy≈z) = ⟨ P ⟩⊆⟨ Q ⟩ P⊆Q x∈⟨P⟩ ⟨∙⟩ ⟨ P ⟩⊆⟨ Q ⟩ P⊆Q y∈⟨P⟩ ∣ xy≈z weaken : ∀ {p} {P Q : Pred Bird p} → P ⊆ Q → ⟨ P ⟩ ⊆ ⟨ Q ⟩ weaken {P = P} {Q} = ⟨ P ⟩⊆⟨ Q ⟩ ⟨_∩_⟩ : ∀ {p} (P Q : Pred Bird p) → ⟨ (P ∩ Q) ⟩ ⊆ ⟨ P ⟩ ∩ ⟨ Q ⟩ ⟨ P ∩ Q ⟩ [ (x∈P , x∈Q) ] = ([ x∈P ] , [ x∈Q ]) ⟨ P ∩ Q ⟩ (_⟨∙⟩_∣_ {x} {y} {z} x∈⟨P∩Q⟩ y∈⟨P∩Q⟩ xy≈z) = let (x∈⟨P⟩ , x∈⟨Q⟩) = ⟨_∩_⟩ P Q x∈⟨P∩Q⟩ (y∈⟨P⟩ , y∈⟨Q⟩) = ⟨_∩_⟩ P Q y∈⟨P∩Q⟩ in (x∈⟨P⟩ ⟨∙⟩ y∈⟨P⟩ ∣ xy≈z , x∈⟨Q⟩ ⟨∙⟩ y∈⟨Q⟩ ∣ xy≈z) -- NOTE: the inclusion ⟨P⟩ ∩ ⟨Q⟩ ⊆ ⟨P ∩ Q⟩ does not hold for all P and Q; let -- for example P = {S, K}, Q = {I}, then SKK = I ∈ ⟨P⟩ ∩ ⟨Q⟩, but P ∩ Q = ∅, and -- hence SKK = I ∉ ⟨P ∩ Q⟩. -- TODO: formalise
{ "alphanum_fraction": 0.4834437086, "avg_line_length": 33.8979591837, "ext": "agda", "hexsha": "ee13fa0f7c41c5d38d63e192c5e18ab23e93eec2", "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": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "splintah/combinatory-logic", "max_forks_repo_path": "Mockingbird/Forest/Combination/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "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": "splintah/combinatory-logic", "max_issues_repo_path": "Mockingbird/Forest/Combination/Properties.agda", "max_line_length": 97, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "splintah/combinatory-logic", "max_stars_repo_path": "Mockingbird/Forest/Combination/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T23:44:42.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-28T23:44:42.000Z", "num_tokens": 958, "size": 1661 }
{-# OPTIONS --without-K #-} open import HoTT open import homotopy.RibbonCover import homotopy.CoverClassification module experimental.CoverClassificationCat {i} (A∙ : Ptd i) (A-conn : is-connected 0 (fst A∙)) where open Cover open Gset open homotopy.CoverClassification A∙ A-conn private A : Type i A = fst A∙ a₁ : A a₁ = snd A∙ π1A = fundamental-group A∙ -- A covering space constructed from a G-set. cover-hom-to-gset-hom : ∀ {j} → {cov₁ cov₂ : Cover A j} → CoverHom cov₁ cov₂ → GsetHom (cover-to-gset cov₁) (cover-to-gset cov₂) cover-hom-to-gset-hom {cov₁ = cov₁}{cov₂} f = record { f = f a₁ ; pres-act = λ l x → lemma₂ x l } where lemma₁ : ∀ x {a₂} (p : a₁ == a₂) → f a₂ (transport (Fiber cov₁) p x) == transport (Fiber cov₂) p (f a₁ x) lemma₁ _ idp = idp lemma₂ : ∀ x {a₂} (p : a₁ =₀ a₂) → f a₂ (transport₀ (Fiber cov₁) (Fiber-level cov₁ a₂) p x) == transport₀ (Fiber cov₂) (Fiber-level cov₂ a₂) p (f a₁ x) lemma₂ x {a₂} = Trunc-elim (λ p → =-preserves-level 0 (Fiber-level cov₂ a₂)) (lemma₁ x {a₂}) gset-hom-to-cover-hom : ∀ {j} → {gset₁ gset₂ : Gset π1A j} → GsetHom gset₁ gset₂ → CoverHom (gset-to-cover gset₁) (gset-to-cover gset₂) gset-hom-to-cover-hom {gset₁ = gset₁}{gset₂} (gset-hom f pres-act) a₂ = Ribbon-rec {P = Ribbon A∙ gset₂ a₂} Ribbon-level (λ el p → trace (f el) p) (λ el loop p → trace (f (act gset₁ el loop)) p =⟨ pres-act loop el |in-ctx (λ x → trace x p) ⟩ trace (act gset₂ (f el) loop) p =⟨ paste (f el) loop p ⟩ trace (f el) (loop ∙₀ p) ∎)
{ "alphanum_fraction": 0.5669982446, "avg_line_length": 28.9661016949, "ext": "agda", "hexsha": "0a9cd91dcada88f5be96131c1bbcf4a1cb1db370", "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/experimental/CoverClassificationCat.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/experimental/CoverClassificationCat.agda", "max_line_length": 73, "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/experimental/CoverClassificationCat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 652, "size": 1709 }
open import Nat open import Prelude open import contexts open import dynamics-core open import type-assignment-unicity module canonical-indeterminate-forms where -- this type gives somewhat nicer syntax for the output of the canonical -- forms lemma for indeterminates at num type data cif-num : (Δ : hctx) (d : ihexp) → Set where CIFNPlus1 : ∀{Δ d} → Σ[ d1 ∈ ihexp ] Σ[ d2 ∈ ihexp ] ((d == d1 ·+ d2) × (Δ , ∅ ⊢ d1 :: num) × (Δ , ∅ ⊢ d2 :: num) × (d1 indet) × (d2 final) ) → cif-num Δ d CIFNPlus2 : ∀{Δ d} → Σ[ d1 ∈ ihexp ] Σ[ d2 ∈ ihexp ] ((d == d1 ·+ d2) × (Δ , ∅ ⊢ d1 :: num) × (Δ , ∅ ⊢ d2 :: num) × (d1 final) × (d2 indet) ) → cif-num Δ d CIFNAp : ∀{Δ d} → Σ[ d1 ∈ ihexp ] Σ[ d2 ∈ ihexp ] Σ[ τ2 ∈ htyp ] ((d == d1 ∘ d2) × (Δ , ∅ ⊢ d1 :: τ2 ==> num) × (Δ , ∅ ⊢ d2 :: τ2) × (d1 indet) × (d2 final) × ((τ3 τ4 τ3' τ4' : htyp) (d1' : ihexp) → d1 ≠ (d1' ⟨ τ3 ==> τ4 ⇒ τ3' ==> τ4' ⟩)) ) → cif-num Δ d CIFNCase : ∀{Δ d} → Σ[ d1 ∈ ihexp ] Σ[ x ∈ Nat ] Σ[ d2 ∈ ihexp ] Σ[ y ∈ Nat ] Σ[ d3 ∈ ihexp ] Σ[ τ1 ∈ htyp ] Σ[ τ2 ∈ htyp ] ((d == case d1 x d2 y d3) × (Δ , ∅ ⊢ d1 :: τ1 ⊕ τ2) × (Δ , ■ (x , τ1) ⊢ d2 :: num) × (Δ , ■ (y , τ2) ⊢ d3 :: num) × (d1 indet) × ((τ : htyp) (d' : ihexp) → d1 ≠ inl τ d') × ((τ : htyp) (d' : ihexp) → d1 ≠ inr τ d') × ((τ3 τ4 τ3' τ4' : htyp) (d' : ihexp) → d1 ≠ (d' ⟨(τ3 ⊕ τ4) ⇒ (τ3' ⊕ τ4')⟩)) ) → cif-num Δ d CIFNFst : ∀{Δ d} → Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] ((d == fst d') × (Δ , ∅ ⊢ d' :: num ⊠ τ') × (d' indet) × ((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) × ((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) → d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩)) ) → cif-num Δ d CIFNSnd : ∀{Δ d} → Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] ((d == snd d') × (Δ , ∅ ⊢ d' :: τ' ⊠ num) × (d' indet) × ((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) × ((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) → d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩)) ) → cif-num Δ d CIFNEHole : ∀{Δ d} → Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ Γ ∈ tctx ] ((d == ⦇-⦈⟨ u , σ ⟩) × ((u :: num [ Γ ]) ∈ Δ) × (Δ , ∅ ⊢ σ :s: Γ) ) → cif-num Δ d CIFNNEHole : ∀{Δ d} → Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ Γ ∈ tctx ] Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] ((d == ⦇⌜ d' ⌟⦈⟨ u , σ ⟩) × (Δ , ∅ ⊢ d' :: τ') × (d' final) × ((u :: num [ Γ ]) ∈ Δ) × (Δ , ∅ ⊢ σ :s: Γ) ) → cif-num Δ d CIFNCast : ∀{Δ d} → Σ[ d' ∈ ihexp ] ((d == d' ⟨ ⦇-⦈ ⇒ num ⟩) × (Δ , ∅ ⊢ d' :: ⦇-⦈) × (d' indet) × ((d'' : ihexp) (τ' : htyp) → d' ≠ (d'' ⟨ τ' ⇒ ⦇-⦈ ⟩)) ) → cif-num Δ d CIFNFailedCast : ∀{Δ d} → Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] ((d == d' ⟨ τ' ⇒⦇-⦈⇏ num ⟩) × (Δ , ∅ ⊢ d' :: τ') × (τ' ground) × (τ' ≠ num) ) → cif-num Δ d canonical-indeterminate-forms-num : ∀{Δ d} → Δ , ∅ ⊢ d :: num → d indet → cif-num Δ d canonical-indeterminate-forms-num TANum () canonical-indeterminate-forms-num (TAPlus wt wt₁) (IPlus1 x x₁) = CIFNPlus1 (_ , _ , refl , wt , wt₁ , x , x₁) canonical-indeterminate-forms-num (TAPlus wt wt₁) (IPlus2 x x₁) = CIFNPlus2 (_ , _ , refl , wt , wt₁ , x , x₁) canonical-indeterminate-forms-num (TAVar x₁) () canonical-indeterminate-forms-num (TAAp wt wt₁) (IAp x ind x₁) = CIFNAp (_ , _ , _ , refl , wt , wt₁ , ind , x₁ , x) canonical-indeterminate-forms-num {Δ = Δ} (TACase {τ1 = τ1} {τ2 = τ2} {x = x} {d1 = d1} {y = y} {d2 = d2} wt _ wt₁ _ wt₂) (ICase ninl ninr ncast ind) = CIFNCase (_ , _ , _ , _ , _ , _ , _ , refl , wt , tr (λ Γ' → Δ , Γ' ⊢ d1 :: num) (extend-empty x τ1) wt₁ , tr (λ Γ' → Δ , Γ' ⊢ d2 :: num) (extend-empty y τ2) wt₂ , ind , ninl , ninr , ncast) canonical-indeterminate-forms-num (TAFst wt) (IFst x x₁ ind) = CIFNFst (_ , _ , refl , wt , ind , x , x₁) canonical-indeterminate-forms-num (TASnd wt) (ISnd x x₁ ind) = CIFNSnd (_ , _ , refl , wt , ind , x , x₁) canonical-indeterminate-forms-num (TAEHole x x₁) IEHole = CIFNEHole (_ , _ , _ , refl , x , x₁) canonical-indeterminate-forms-num (TANEHole x wt x₁) (INEHole x₂) = CIFNNEHole (_ , _ , _ , _ , _ , refl , wt , x₂ , x , x₁) canonical-indeterminate-forms-num (TACast wt x) (ICastHoleGround x₁ ind x₂) = CIFNCast (_ , refl , wt , ind , x₁) canonical-indeterminate-forms-num (TAFailedCast x x₁ x₂ x₃) (IFailedCast x₄ x₅ x₆ x₇) = CIFNFailedCast (_ , _ , refl , x , x₅ , x₇) -- this type gives somewhat nicer syntax for the output of the canonical -- forms lemma for indeterminates at arrow type data cif-arr : (Δ : hctx) (d : ihexp) (τ1 τ2 : htyp) → Set where CIFAEHole : ∀{d Δ τ1 τ2} → Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ Γ ∈ tctx ] ((d == ⦇-⦈⟨ u , σ ⟩) × ((u :: (τ1 ==> τ2) [ Γ ]) ∈ Δ) × (Δ , ∅ ⊢ σ :s: Γ) ) → cif-arr Δ d τ1 τ2 CIFANEHole : ∀{d Δ τ1 τ2} → Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] Σ[ Γ ∈ tctx ] ((d == ⦇⌜ d' ⌟⦈⟨ u , σ ⟩) × (Δ , ∅ ⊢ d' :: τ') × (d' final) × ((u :: (τ1 ==> τ2) [ Γ ]) ∈ Δ) × (Δ , ∅ ⊢ σ :s: Γ) ) → cif-arr Δ d τ1 τ2 CIFAAp : ∀{d Δ τ1 τ2} → Σ[ d1 ∈ ihexp ] Σ[ d2 ∈ ihexp ] Σ[ τ2' ∈ htyp ] Σ[ τ1 ∈ htyp ] Σ[ τ2 ∈ htyp ] ((d == d1 ∘ d2) × (Δ , ∅ ⊢ d1 :: τ2' ==> (τ1 ==> τ2)) × (Δ , ∅ ⊢ d2 :: τ2') × (d1 indet) × (d2 final) × ((τ3 τ4 τ3' τ4' : htyp) (d1' : ihexp) → d1 ≠ (d1' ⟨ τ3 ==> τ4 ⇒ τ3' ==> τ4' ⟩)) ) → cif-arr Δ d τ1 τ2 CIFACase : ∀{Δ d τ1 τ2} → Σ[ d1 ∈ ihexp ] Σ[ x ∈ Nat ] Σ[ d2 ∈ ihexp ] Σ[ y ∈ Nat ] Σ[ d3 ∈ ihexp ] Σ[ τ3 ∈ htyp ] Σ[ τ4 ∈ htyp ] ((d == case d1 x d2 y d3) × (Δ , ∅ ⊢ d1 :: τ3 ⊕ τ4) × (Δ , ■ (x , τ3) ⊢ d2 :: τ1 ==> τ2) × (Δ , ■ (y , τ4) ⊢ d3 :: τ1 ==> τ2) × (d1 indet) × ((τ : htyp) (d' : ihexp) → d1 ≠ inl τ d') × ((τ : htyp) (d' : ihexp) → d1 ≠ inr τ d') × ((τ5 τ6 τ5' τ6' : htyp) (d' : ihexp) → d1 ≠ (d' ⟨(τ5 ⊕ τ6) ⇒ (τ5' ⊕ τ6')⟩)) ) → cif-arr Δ d τ1 τ2 CIFAFst : ∀{Δ d τ1 τ2} → Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] ((d == fst d') × (Δ , ∅ ⊢ d' :: (τ1 ==> τ2) ⊠ τ') × (d' indet) × ((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) × ((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) → d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩)) ) → cif-arr Δ d τ1 τ2 CIFASnd : ∀{Δ d τ1 τ2} → Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] ((d == snd d') × (Δ , ∅ ⊢ d' :: τ' ⊠ (τ1 ==> τ2)) × (d' indet) × ((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) × ((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) → d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩)) ) → cif-arr Δ d τ1 τ2 CIFACast : ∀{d Δ τ1 τ2} → Σ[ d' ∈ ihexp ] Σ[ τ1 ∈ htyp ] Σ[ τ2 ∈ htyp ] Σ[ τ1' ∈ htyp ] Σ[ τ2' ∈ htyp ] ((d == d' ⟨ (τ1' ==> τ2') ⇒ (τ1 ==> τ2) ⟩) × (Δ , ∅ ⊢ d' :: τ1' ==> τ2') × (d' indet) × ((τ1' ==> τ2') ≠ (τ1 ==> τ2)) ) → cif-arr Δ d τ1 τ2 CIFACastHole : ∀{d Δ τ1 τ2} → Σ[ d' ∈ ihexp ] ((d == (d' ⟨ ⦇-⦈ ⇒ ⦇-⦈ ==> ⦇-⦈ ⟩)) × (τ1 == ⦇-⦈) × (τ2 == ⦇-⦈) × (Δ , ∅ ⊢ d' :: ⦇-⦈) × (d' indet) × ((d'' : ihexp) (τ' : htyp) → d' ≠ (d'' ⟨ τ' ⇒ ⦇-⦈ ⟩)) ) → cif-arr Δ d τ1 τ2 CIFAFailedCast : ∀{d Δ τ1 τ2} → Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] ((d == (d' ⟨ τ' ⇒⦇-⦈⇏ ⦇-⦈ ==> ⦇-⦈ ⟩) ) × (τ1 == ⦇-⦈) × (τ2 == ⦇-⦈) × (Δ , ∅ ⊢ d' :: τ') × (τ' ground) × (τ' ≠ (⦇-⦈ ==> ⦇-⦈)) ) → cif-arr Δ d τ1 τ2 canonical-indeterminate-forms-arr : ∀{Δ d τ1 τ2 } → Δ , ∅ ⊢ d :: (τ1 ==> τ2) → d indet → cif-arr Δ d τ1 τ2 canonical-indeterminate-forms-arr (TAVar x₁) () canonical-indeterminate-forms-arr (TALam _ wt) () canonical-indeterminate-forms-arr (TAAp wt wt₁) (IAp x ind x₁) = CIFAAp (_ , _ , _ , _ , _ , refl , wt , wt₁ , ind , x₁ , x) canonical-indeterminate-forms-arr {Δ = Δ} (TACase {τ1 = τ1} {τ2 = τ2} {τ = τ3 ==> τ4} {x = x} {d1 = d1} {y = y} {d2 = d2} wt _ wt₁ _ wt₂) (ICase ninl ninr ncast ind) = CIFACase (_ , _ , _ , _ , _ , _ , _ , refl , wt , tr (λ Γ' → Δ , Γ' ⊢ d1 :: τ3 ==> τ4) (extend-empty x τ1) wt₁ , tr (λ Γ' → Δ , Γ' ⊢ d2 :: τ3 ==> τ4) (extend-empty y τ2) wt₂ , ind , ninl , ninr , ncast) canonical-indeterminate-forms-arr (TAFst wt) (IFst x x₁ ind) = CIFAFst (_ , _ , refl , wt , ind , x , x₁) canonical-indeterminate-forms-arr (TASnd wt) (ISnd x x₁ ind) = CIFASnd (_ , _ , refl , wt , ind , x , x₁) canonical-indeterminate-forms-arr (TAEHole x x₁) IEHole = CIFAEHole (_ , _ , _ , refl , x , x₁) canonical-indeterminate-forms-arr (TANEHole x wt x₁) (INEHole x₂) = CIFANEHole (_ , _ , _ , _ , _ , refl , wt , x₂ , x , x₁) canonical-indeterminate-forms-arr (TACast wt x) (ICastArr x₁ ind) = CIFACast (_ , _ , _ , _ , _ , refl , wt , ind , x₁) canonical-indeterminate-forms-arr (TACast wt TCHole2) (ICastHoleGround x₁ ind GArrHole) = CIFACastHole (_ , refl , refl , refl , wt , ind , x₁) canonical-indeterminate-forms-arr (TAFailedCast x x₁ GArrHole x₃) (IFailedCast x₄ x₅ GArrHole x₇) = CIFAFailedCast (_ , _ , refl , refl , refl , x , x₅ , x₇) -- this type gives somewhat nicer syntax for the output of the canonical -- forms lemma for indeterminates at sum type data cif-sum : (Δ : hctx) (d : ihexp) (τ1 τ2 : htyp) → Set where CIFSEHole : ∀{d Δ τ1 τ2} → Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ Γ ∈ tctx ] ((d == ⦇-⦈⟨ u , σ ⟩) × ((u :: (τ1 ⊕ τ2) [ Γ ]) ∈ Δ) × (Δ , ∅ ⊢ σ :s: Γ) ) → cif-sum Δ d τ1 τ2 CIFSNEHole : ∀{d Δ τ1 τ2} → Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] Σ[ Γ ∈ tctx ] ((d == ⦇⌜ d' ⌟⦈⟨ u , σ ⟩) × (Δ , ∅ ⊢ d' :: τ') × (d' final) × ((u :: (τ1 ⊕ τ2) [ Γ ]) ∈ Δ) × (Δ , ∅ ⊢ σ :s: Γ) ) → cif-sum Δ d τ1 τ2 CIFSAp : ∀{d Δ τ1 τ2} → Σ[ d1 ∈ ihexp ] Σ[ d2 ∈ ihexp ] Σ[ τ2' ∈ htyp ] Σ[ τ1 ∈ htyp ] Σ[ τ2 ∈ htyp ] ((d == d1 ∘ d2) × (Δ , ∅ ⊢ d1 :: τ2' ==> (τ1 ⊕ τ2)) × (Δ , ∅ ⊢ d2 :: τ2') × (d1 indet) × (d2 final) × ((τ3 τ4 τ3' τ4' : htyp) (d1' : ihexp) → d1 ≠ (d1' ⟨ τ3 ==> τ4 ⇒ τ3' ==> τ4' ⟩)) ) → cif-sum Δ d τ1 τ2 CIFSInl : ∀{Δ d τ1 τ2} → Σ[ d' ∈ ihexp ] ((d == inl τ2 d') × (Δ , ∅ ⊢ d' :: τ1) × (d' indet) ) → cif-sum Δ d τ1 τ2 CIFSInr : ∀{Δ d τ1 τ2} → Σ[ d' ∈ ihexp ] ((d == inr τ1 d') × (Δ , ∅ ⊢ d' :: τ2) × (d' indet) ) → cif-sum Δ d τ1 τ2 CIFSCase : ∀{Δ d τ1 τ2} → Σ[ d1 ∈ ihexp ] Σ[ x ∈ Nat ] Σ[ d2 ∈ ihexp ] Σ[ y ∈ Nat ] Σ[ d3 ∈ ihexp ] Σ[ τ3 ∈ htyp ] Σ[ τ4 ∈ htyp ] ((d == case d1 x d2 y d3) × (Δ , ∅ ⊢ d1 :: τ3 ⊕ τ4) × (Δ , ■ (x , τ3) ⊢ d2 :: τ1 ⊕ τ2) × (Δ , ■ (y , τ4) ⊢ d3 :: τ1 ⊕ τ2) × (d1 indet) × ((τ : htyp) (d' : ihexp) → d1 ≠ inl τ d') × ((τ : htyp) (d' : ihexp) → d1 ≠ inr τ d') × ((τ5 τ6 τ5' τ6' : htyp) (d' : ihexp) → d1 ≠ (d' ⟨(τ5 ⊕ τ6) ⇒ (τ5' ⊕ τ6')⟩)) ) → cif-sum Δ d τ1 τ2 CIFSFst : ∀{Δ d τ1 τ2} → Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] ((d == fst d') × (Δ , ∅ ⊢ d' :: (τ1 ⊕ τ2) ⊠ τ') × (d' indet) × ((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) × ((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) → d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩)) ) → cif-sum Δ d τ1 τ2 CIFSSnd : ∀{Δ d τ1 τ2} → Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] ((d == snd d') × (Δ , ∅ ⊢ d' :: τ' ⊠ (τ1 ⊕ τ2)) × (d' indet) × ((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) × ((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) → d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩)) ) → cif-sum Δ d τ1 τ2 CIFSCast : ∀{d Δ τ1 τ2} → Σ[ d' ∈ ihexp ] Σ[ τ1 ∈ htyp ] Σ[ τ2 ∈ htyp ] Σ[ τ1' ∈ htyp ] Σ[ τ2' ∈ htyp ] ((d == d' ⟨ (τ1' ⊕ τ2') ⇒ (τ1 ⊕ τ2) ⟩) × (Δ , ∅ ⊢ d' :: τ1' ⊕ τ2') × (d' indet) × ((τ1' ⊕ τ2') ≠ (τ1 ⊕ τ2)) ) → cif-sum Δ d τ1 τ2 CIFSCastHole : ∀{d Δ τ1 τ2} → Σ[ d' ∈ ihexp ] ((d == (d' ⟨ ⦇-⦈ ⇒ ⦇-⦈ ⊕ ⦇-⦈ ⟩)) × (τ1 == ⦇-⦈) × (τ2 == ⦇-⦈) × (Δ , ∅ ⊢ d' :: ⦇-⦈) × (d' indet) × ((d'' : ihexp) (τ' : htyp) → d' ≠ (d'' ⟨ τ' ⇒ ⦇-⦈ ⟩)) ) → cif-sum Δ d τ1 τ2 CIFSFailedCast : ∀{d Δ τ1 τ2} → Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] ((d == (d' ⟨ τ' ⇒⦇-⦈⇏ ⦇-⦈ ⊕ ⦇-⦈ ⟩) ) × (τ1 == ⦇-⦈) × (τ2 == ⦇-⦈) × (Δ , ∅ ⊢ d' :: τ') × (τ' ground) × (τ' ≠ (⦇-⦈ ⊕ ⦇-⦈)) ) → cif-sum Δ d τ1 τ2 canonical-indeterminate-forms-sum : ∀{Δ d τ1 τ2 } → Δ , ∅ ⊢ d :: (τ1 ⊕ τ2) → d indet → cif-sum Δ d τ1 τ2 canonical-indeterminate-forms-sum (TAAp wt wt₁) (IAp x ind x₁) = CIFSAp (_ , _ , _ , _ , _ , refl , wt , wt₁ , ind , x₁ , x) canonical-indeterminate-forms-sum (TAInl wt) (IInl ind) = CIFSInl (_ , refl , wt , ind) canonical-indeterminate-forms-sum (TAInr wt) (IInr ind) = CIFSInr (_ , refl , wt , ind) canonical-indeterminate-forms-sum {Δ = Δ} (TACase {τ1 = τ1} {τ2 = τ2} {τ = τ3 ⊕ τ4} {x = x} {d1 = d1} {y = y} {d2 = d2} wt _ wt₁ _ wt₂) (ICase ninl ninr ncast ind) = CIFSCase (_ , _ , _ , _ , _ , _ , _ , refl , wt , tr (λ Γ' → Δ , Γ' ⊢ d1 :: (τ3 ⊕ τ4)) (extend-empty x τ1) wt₁ , tr (λ Γ' → Δ , Γ' ⊢ d2 :: (τ3 ⊕ τ4)) (extend-empty y τ2) wt₂ , ind , ninl , ninr , ncast) canonical-indeterminate-forms-sum (TAFst wt) (IFst x x₁ ind) = CIFSFst (_ , _ , refl , wt , ind , x , x₁) canonical-indeterminate-forms-sum (TASnd wt) (ISnd x x₁ ind) = CIFSSnd (_ , _ , refl , wt , ind , x , x₁) canonical-indeterminate-forms-sum (TAEHole x x₁) IEHole = CIFSEHole (_ , _ , _ , refl , x , x₁) canonical-indeterminate-forms-sum (TANEHole x wt x₁) (INEHole x₂) = CIFSNEHole (_ , _ , _ , _ , _ , refl , wt , x₂ , x , x₁) canonical-indeterminate-forms-sum (TACast wt x) (ICastSum x₁ ind) = CIFSCast (_ , _ , _ , _ , _ , refl , wt , ind , x₁) canonical-indeterminate-forms-sum (TACast wt x) (ICastHoleGround x₁ ind GSumHole) = CIFSCastHole (_ , refl , refl , refl , wt , ind , x₁) canonical-indeterminate-forms-sum (TAFailedCast wt x x₁ x₂) (IFailedCast x₃ x₄ GSumHole x₆) = CIFSFailedCast (_ , _ , refl , refl , refl , wt , x₄ , x₆) canonical-indeterminate-forms-sum (TAVar x) () -- this type gives somewhat nicer syntax for the output of the canonical -- forms lemma for indeterminates at product type data cif-prod : (Δ : hctx) (d : ihexp) (τ1 τ2 : htyp) → Set where CIFPEHole : ∀{d Δ τ1 τ2} → Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ Γ ∈ tctx ] ((d == ⦇-⦈⟨ u , σ ⟩) × ((u :: (τ1 ⊠ τ2) [ Γ ]) ∈ Δ) × (Δ , ∅ ⊢ σ :s: Γ) ) → cif-prod Δ d τ1 τ2 CIFPNEHole : ∀{d Δ τ1 τ2} → Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] Σ[ Γ ∈ tctx ] ((d == ⦇⌜ d' ⌟⦈⟨ u , σ ⟩) × (Δ , ∅ ⊢ d' :: τ') × (d' final) × ((u :: (τ1 ⊠ τ2) [ Γ ]) ∈ Δ) × (Δ , ∅ ⊢ σ :s: Γ) ) → cif-prod Δ d τ1 τ2 CIFPAp : ∀{d Δ τ1 τ2} → Σ[ d1 ∈ ihexp ] Σ[ d2 ∈ ihexp ] Σ[ τ2' ∈ htyp ] Σ[ τ1 ∈ htyp ] Σ[ τ2 ∈ htyp ] ((d == d1 ∘ d2) × (Δ , ∅ ⊢ d1 :: τ2' ==> (τ1 ⊠ τ2)) × (Δ , ∅ ⊢ d2 :: τ2') × (d1 indet) × (d2 final) × ((τ3 τ4 τ3' τ4' : htyp) (d1' : ihexp) → d1 ≠ (d1' ⟨ τ3 ==> τ4 ⇒ τ3' ==> τ4' ⟩)) ) → cif-prod Δ d τ1 τ2 CIFPCase : ∀{Δ d τ1 τ2} → Σ[ d1 ∈ ihexp ] Σ[ x ∈ Nat ] Σ[ d2 ∈ ihexp ] Σ[ y ∈ Nat ] Σ[ d3 ∈ ihexp ] Σ[ τ3 ∈ htyp ] Σ[ τ4 ∈ htyp ] ((d == case d1 x d2 y d3) × (Δ , ∅ ⊢ d1 :: τ3 ⊕ τ4) × (Δ , ■ (x , τ3) ⊢ d2 :: τ1 ⊠ τ2) × (Δ , ■ (y , τ4) ⊢ d3 :: τ1 ⊠ τ2) × (d1 indet) × ((τ : htyp) (d' : ihexp) → d1 ≠ inl τ d') × ((τ : htyp) (d' : ihexp) → d1 ≠ inr τ d') × ((τ5 τ6 τ5' τ6' : htyp) (d' : ihexp) → d1 ≠ (d' ⟨(τ5 ⊕ τ6) ⇒ (τ5' ⊕ τ6')⟩)) ) → cif-prod Δ d τ1 τ2 CIFPPair1 : ∀{Δ d τ1 τ2} → Σ[ d1 ∈ ihexp ] Σ[ d2 ∈ ihexp ] ((d == ⟨ d1 , d2 ⟩) × (Δ , ∅ ⊢ d1 :: τ1) × (Δ , ∅ ⊢ d2 :: τ2) × d1 indet × d2 final ) → cif-prod Δ d τ1 τ2 CIFPPair2 : ∀{Δ d τ1 τ2} → Σ[ d1 ∈ ihexp ] Σ[ d2 ∈ ihexp ] ((d == ⟨ d1 , d2 ⟩) × (Δ , ∅ ⊢ d1 :: τ1) × (Δ , ∅ ⊢ d2 :: τ2) × d1 final × d2 indet ) → cif-prod Δ d τ1 τ2 CIFPFst : ∀{Δ d τ1 τ2} → Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] ((d == fst d') × (Δ , ∅ ⊢ d' :: (τ1 ⊠ τ2) ⊠ τ') × (d' indet) × ((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) × ((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) → d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩)) ) → cif-prod Δ d τ1 τ2 CIFPSnd : ∀{Δ d τ1 τ2} → Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] ((d == snd d') × (Δ , ∅ ⊢ d' :: τ' ⊠ (τ1 ⊠ τ2)) × (d' indet) × ((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) × ((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) → d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩)) ) → cif-prod Δ d τ1 τ2 CIFPCast : ∀{d Δ τ1 τ2} → Σ[ d' ∈ ihexp ] Σ[ τ1 ∈ htyp ] Σ[ τ2 ∈ htyp ] Σ[ τ1' ∈ htyp ] Σ[ τ2' ∈ htyp ] ((d == d' ⟨ (τ1' ⊠ τ2') ⇒ (τ1 ⊠ τ2) ⟩) × (Δ , ∅ ⊢ d' :: τ1' ⊠ τ2') × (d' indet) × ((τ1' ⊠ τ2') ≠ (τ1 ⊠ τ2)) ) → cif-prod Δ d τ1 τ2 CIFPCastHole : ∀{d Δ τ1 τ2} → Σ[ d' ∈ ihexp ] ((d == (d' ⟨ ⦇-⦈ ⇒ ⦇-⦈ ⊠ ⦇-⦈ ⟩)) × (τ1 == ⦇-⦈) × (τ2 == ⦇-⦈) × (Δ , ∅ ⊢ d' :: ⦇-⦈) × (d' indet) × ((d'' : ihexp) (τ' : htyp) → d' ≠ (d'' ⟨ τ' ⇒ ⦇-⦈ ⟩)) ) → cif-prod Δ d τ1 τ2 CIFPFailedCast : ∀{d Δ τ1 τ2} → Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] ((d == (d' ⟨ τ' ⇒⦇-⦈⇏ ⦇-⦈ ⊠ ⦇-⦈ ⟩) ) × (τ1 == ⦇-⦈) × (τ2 == ⦇-⦈) × (Δ , ∅ ⊢ d' :: τ') × (τ' ground) × (τ' ≠ (⦇-⦈ ⊠ ⦇-⦈)) ) → cif-prod Δ d τ1 τ2 canonical-indeterminate-forms-prod : ∀{Δ d τ1 τ2} → Δ , ∅ ⊢ d :: (τ1 ⊠ τ2) → d indet → cif-prod Δ d τ1 τ2 canonical-indeterminate-forms-prod (TAVar x) () canonical-indeterminate-forms-prod (TAAp wt wt₁) (IAp x ind x₁) = CIFPAp (_ , _ , _ , _ , _ , refl , wt , wt₁ , ind , x₁ , x) canonical-indeterminate-forms-prod {Δ = Δ} (TACase {τ1 = τ1} {τ2 = τ2} {τ = τ3 ⊠ τ4} {x = x} {d1 = d1} {y = y} {d2 = d2} wt _ wt₁ _ wt₂) (ICase ninl ninr ncast ind) = CIFPCase (_ , _ , _ , _ , _ , _ , _ , refl , wt , tr (λ Γ' → Δ , Γ' ⊢ d1 :: (τ3 ⊠ τ4)) (extend-empty x τ1) wt₁ , tr (λ Γ' → Δ , Γ' ⊢ d2 :: (τ3 ⊠ τ4)) (extend-empty y τ2) wt₂ , ind , ninl , ninr , ncast) canonical-indeterminate-forms-prod (TAPair wt wt₁) (IPair1 ind x) = CIFPPair1 (_ , _ , refl , wt , wt₁ , ind , x) canonical-indeterminate-forms-prod (TAPair wt wt₁) (IPair2 x ind) = CIFPPair2 (_ , _ , refl , wt , wt₁ , x , ind) canonical-indeterminate-forms-prod (TAFst wt) (IFst x x₁ ind) = CIFPFst (_ , _ , refl , wt , ind , x , x₁) canonical-indeterminate-forms-prod (TASnd wt) (ISnd x x₁ ind) = CIFPSnd (_ , _ , refl , wt , ind , x , x₁) canonical-indeterminate-forms-prod (TAEHole x x₁) IEHole = CIFPEHole (_ , _ , _ , refl , x , x₁) canonical-indeterminate-forms-prod (TANEHole x wt x₁) (INEHole x₂) = CIFPNEHole (_ , _ , _ , _ , _ , refl , wt , x₂ , x , x₁) canonical-indeterminate-forms-prod (TACast wt x) (ICastProd x₁ ind) = CIFPCast (_ , _ , _ , _ , _ , refl , wt , ind , x₁) canonical-indeterminate-forms-prod (TACast wt x) (ICastHoleGround x₁ ind GProdHole) = CIFPCastHole (_ , refl , refl , refl , wt , ind , x₁) canonical-indeterminate-forms-prod (TAFailedCast wt x GProdHole x₂) (IFailedCast x₃ x₄ GProdHole x₆) = CIFPFailedCast (_ , _ , refl , refl , refl , wt , x₄ , x₆) -- this type gives somewhat nicer syntax for the output of the canonical -- forms lemma for indeterminates at hole type data cif-hole : (Δ : hctx) (d : ihexp) → Set where CIFHEHole : ∀{Δ d} → Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ Γ ∈ tctx ] ((d == ⦇-⦈⟨ u , σ ⟩) × ((u :: ⦇-⦈ [ Γ ]) ∈ Δ) × (Δ , ∅ ⊢ σ :s: Γ) ) → cif-hole Δ d CIFHNEHole : ∀{Δ d} → Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] Σ[ Γ ∈ tctx ] ((d == ⦇⌜ d' ⌟⦈⟨ u , σ ⟩) × (Δ , ∅ ⊢ d' :: τ') × (d' final) × ((u :: ⦇-⦈ [ Γ ]) ∈ Δ) × (Δ , ∅ ⊢ σ :s: Γ) ) → cif-hole Δ d CIFHAp : ∀{Δ d} → Σ[ d1 ∈ ihexp ] Σ[ d2 ∈ ihexp ] Σ[ τ2 ∈ htyp ] ((d == d1 ∘ d2) × (Δ , ∅ ⊢ d1 :: (τ2 ==> ⦇-⦈)) × (Δ , ∅ ⊢ d2 :: τ2) × (d1 indet) × (d2 final) × ((τ3 τ4 τ3' τ4' : htyp) (d1' : ihexp) → d1 ≠ (d1' ⟨ τ3 ==> τ4 ⇒ τ3' ==> τ4' ⟩)) ) → cif-hole Δ d CIFHCase : ∀{Δ d} → Σ[ d1 ∈ ihexp ] Σ[ x ∈ Nat ] Σ[ d2 ∈ ihexp ] Σ[ y ∈ Nat ] Σ[ d3 ∈ ihexp ] Σ[ τ1 ∈ htyp ] Σ[ τ2 ∈ htyp ] ((d == case d1 x d2 y d3) × (Δ , ∅ ⊢ d1 :: τ1 ⊕ τ2) × (Δ , ■ (x , τ1) ⊢ d2 :: ⦇-⦈) × (Δ , ■ (y , τ2) ⊢ d3 :: ⦇-⦈) × (d1 indet) × ((τ : htyp) (d' : ihexp) → d1 ≠ inl τ d') × ((τ : htyp) (d' : ihexp) → d1 ≠ inr τ d') × ((τ3 τ4 τ3' τ4' : htyp) (d' : ihexp) → d1 ≠ (d' ⟨(τ3 ⊕ τ4) ⇒ (τ3' ⊕ τ4')⟩)) ) → cif-hole Δ d CIFHFst : ∀{Δ d} → Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] ((d == fst d') × (Δ , ∅ ⊢ d' :: ⦇-⦈ ⊠ τ') × (d' indet) × ((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) × ((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) → d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩)) ) → cif-hole Δ d CIFHSnd : ∀{Δ d} → Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] ((d == snd d') × (Δ , ∅ ⊢ d' :: τ' ⊠ ⦇-⦈) × (d' indet) × ((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) × ((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) → d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩)) ) → cif-hole Δ d CIFHCast : ∀{Δ d} → Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] ((d == d' ⟨ τ' ⇒ ⦇-⦈ ⟩) × (Δ , ∅ ⊢ d' :: τ') × (τ' ground) × (d' indet) ) → cif-hole Δ d canonical-indeterminate-forms-hole : ∀{Δ d} → Δ , ∅ ⊢ d :: ⦇-⦈ → d indet → cif-hole Δ d canonical-indeterminate-forms-hole (TAVar x₁) () canonical-indeterminate-forms-hole (TAAp wt wt₁) (IAp x ind x₁) = CIFHAp (_ , _ , _ , refl , wt , wt₁ , ind , x₁ , x) canonical-indeterminate-forms-hole {Δ = Δ} (TACase {τ1 = τ1} {τ2 = τ2} {x = x} {d1 = d1} {y = y} {d2 = d2} wt _ wt₁ _ wt₂) (ICase ninl ninr ncast ind) = CIFHCase (_ , _ , _ , _ , _ , _ , _ , refl , wt , tr (λ Γ' → Δ , Γ' ⊢ d1 :: ⦇-⦈) (extend-empty x τ1) wt₁ , tr (λ Γ' → Δ , Γ' ⊢ d2 :: ⦇-⦈) (extend-empty y τ2) wt₂ , ind , ninl , ninr , ncast) canonical-indeterminate-forms-hole (TAFst wt) (IFst x x₁ ind) = CIFHFst (_ , _ , refl , wt , ind , x , x₁) canonical-indeterminate-forms-hole (TASnd wt) (ISnd x x₁ ind) = CIFHSnd (_ , _ , refl , wt , ind , x , x₁) canonical-indeterminate-forms-hole (TAEHole x x₁) IEHole = CIFHEHole (_ , _ , _ , refl , x , x₁) canonical-indeterminate-forms-hole (TANEHole x wt x₁) (INEHole x₂) = CIFHNEHole (_ , _ , _ , _ , _ , refl , wt , x₂ , x , x₁) canonical-indeterminate-forms-hole (TACast wt x) (ICastGroundHole x₁ ind) = CIFHCast (_ , _ , refl , wt , x₁ , ind) canonical-indeterminate-forms-hole (TACast wt x) (ICastHoleGround x₁ ind ()) canonical-indeterminate-forms-hole (TAFailedCast x x₁ () x₃) (IFailedCast x₄ x₅ x₆ x₇) canonical-indeterminate-forms-coverage : ∀{Δ d τ} → Δ , ∅ ⊢ d :: τ → d indet → τ ≠ num → ((τ1 : htyp) (τ2 : htyp) → τ ≠ (τ1 ==> τ2)) → ((τ1 : htyp) (τ2 : htyp) → τ ≠ (τ1 ⊕ τ2)) → ((τ1 : htyp) (τ2 : htyp) → τ ≠ (τ1 ⊠ τ2)) → τ ≠ ⦇-⦈ → ⊥ canonical-indeterminate-forms-coverage {τ = num} wt ind nn na ns np nh = nn refl canonical-indeterminate-forms-coverage {τ = ⦇-⦈} wt ind nn na ns np nh = nh refl canonical-indeterminate-forms-coverage {τ = τ ==> τ₁} wt ind nn na ns np nh = na τ τ₁ refl canonical-indeterminate-forms-coverage {τ = τ ⊕ τ₁} wt ind nn na ns np nh = ns τ τ₁ refl canonical-indeterminate-forms-coverage {τ = τ ⊠ τ₁} wt ind nn na ns np nh = np τ τ₁ refl
{ "alphanum_fraction": 0.4045346527, "avg_line_length": 43.9537671233, "ext": "agda", "hexsha": "130c88586c792a20223d1530f41a858361a6801c", "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": "canonical-indeterminate-forms.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": "canonical-indeterminate-forms.agda", "max_line_length": 372, "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": "canonical-indeterminate-forms.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 11598, "size": 25669 }
------------------------------------------------------------------------------ -- Testing the FOL schemata ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOL.SchemataATP where open import FOL.Base ------------------------------------------------------------------------------ postulate id₁ : {A₁ : D → Set} → ∀ {x} → A₁ x → A₁ x {-# ATP prove id₁ #-} id₂ : {A₁ : D → Set} → ∀ {x} → A₁ x → A₁ x id₂ {A} {x} = prf where postulate prf : A x → A x {-# ATP prove prf #-}
{ "alphanum_fraction": 0.3414634146, "avg_line_length": 29.0416666667, "ext": "agda", "hexsha": "ef758dba1d104aa39536561b1ee40d2496663a5d", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOL/SchemataATP.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOL/SchemataATP.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOL/SchemataATP.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": 157, "size": 697 }
module Unit where record Unit : Set where constructor unit {-# COMPILE GHC Unit = data () (()) #-}
{ "alphanum_fraction": 0.6346153846, "avg_line_length": 13, "ext": "agda", "hexsha": "686bcbc6e0f87743d63f7ccc3812413dc442bd2b", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "stephanadls/state-dependent-gui", "max_forks_repo_path": "src/Unit.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "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": "stephanadls/state-dependent-gui", "max_issues_repo_path": "src/Unit.agda", "max_line_length": 39, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "src/Unit.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 26, "size": 104 }
{-# OPTIONS --without-K --safe --exact-split #-} module Math.Googology.Function.Properties where -- agda-stdlib open import Data.Nat open import Data.Nat.Properties open import Data.Nat.GeneralisedArithmetic using (fold) open import Data.List open import Function open import Relation.Binary.PropositionalEquality -- agda-misc open import Math.Googology.Function open ≤-Reasoning ------------------------------------------------------------------------ -- Properties of hyperoperation H-rec : ∀ n a b → H (suc n) a (suc b) ≡ H n a (H (suc n) a b) H-rec zero a b = refl H-rec (suc zero) a b = refl H-rec (suc (suc n)) a b = refl -- H₀ is successor. H-suc : ∀ a b → H 0 a b ≡ suc b H-suc a b = refl -- H₁ is addition. H-+ : ∀ a b → H 1 a b ≡ a + b H-+ a 0 = sym $ +-identityʳ a H-+ a (suc b) = begin-equality suc (H 1 a b) ≡⟨ cong suc $ H-+ a b ⟩ suc (a + b) ≡⟨⟩ suc a + b ≡⟨ sym $ +-suc a b ⟩ a + suc b ∎ -- H₂ is multiplication. H-* : ∀ a b → H 2 a b ≡ a * b H-* a 0 = sym $ *-zeroʳ a H-* a (suc b) = begin-equality H 1 a (H 2 a b) ≡⟨ cong (H 1 a) $ H-* a b ⟩ H 1 a (a * b) ≡⟨ H-+ a (a * b) ⟩ a + a * b ≡⟨ sym $ *-suc a b ⟩ a * suc b ∎ -- H₃ is exponentiation. H-^ : ∀ a b → H 3 a b ≡ a ^ b H-^ a 0 = refl H-^ a (suc b) = begin-equality H 2 a (H 3 a b) ≡⟨ cong (H 2 a) $ H-^ a b ⟩ H 2 a (a ^ b) ≡⟨ H-* a (a ^ b) ⟩ a * (a ^ b) ∎ -- Hₙ(a, 1) = a (n ≥ 2) H[2+n,a,1]≡a : ∀ n a → H (2 + n) a 1 ≡ a H[2+n,a,1]≡a 0 a = refl H[2+n,a,1]≡a (suc n) a = begin-equality H (suc (suc (suc n))) a 1 ≡⟨ H-rec (suc (suc n)) a 0 ⟩ H (2 + n) a 1 ≡⟨ H[2+n,a,1]≡a n a ⟩ a ∎ -- a ↑ⁿ 1 ≡ a a↑ⁿ1≡a : ∀ a n → a ↑[ n ] 1 ≡ a a↑ⁿ1≡a a n = H[2+n,a,1]≡a n a -- Hₙ(2, 2) = 4 (n ≥ 1) H[1+n,2,2]≡4 : ∀ n → H (1 + n) 2 2 ≡ 4 H[1+n,2,2]≡4 0 = refl H[1+n,2,2]≡4 (suc n) = begin-equality H (suc (suc n)) 2 (suc 1) ≡⟨ H-rec (suc n) 2 1 ⟩ H (suc n) 2 (H (suc (suc n)) 2 1) ≡⟨ cong (H (suc n) 2) $ H[2+n,a,1]≡a n 2 ⟩ H (suc n) 2 2 ≡⟨ H[1+n,2,2]≡4 n ⟩ 4 ∎ -- Hₙ(1, b) = 1 (n ≥ 3) H[3+n,1,b]≡1 : ∀ n b → H (3 + n) 1 b ≡ 1 H[3+n,1,b]≡1 0 b = trans (H-^ 1 b) (^-zeroˡ b) H[3+n,1,b]≡1 (suc n) 0 = refl H[3+n,1,b]≡1 (suc n) (suc b) = H[3+n,1,b]≡1 n (H (4 + n) 1 b) -- Hₙ(a, a) = H₁₊ₙ(a, 2) (n ≥ 1) H[1+n,a,a]≡H[2+n,a,2] : ∀ n a → H (1 + n) a a ≡ H (2 + n) a 2 H[1+n,a,a]≡H[2+n,a,2] n a = sym lemma where lemma : H (2 + n) a 2 ≡ H (1 + n) a a lemma = begin-equality H (suc (suc n)) a 2 ≡⟨ H-rec (suc n) a 1 ⟩ H (suc n) a (H (suc (suc n)) a 1) ≡⟨ cong (H (suc n) a) $ H[2+n,a,1]≡a n a ⟩ H (suc n) a a ∎ H-is-fold : ∀ n a b → H (3 + n) a b ≡ fold 1 (H (2 + n) a) b H-is-fold n a 0 = refl H-is-fold n a (suc b) = cong (H (2 + n) a) $ H-is-fold n a b H[1+n,2,3]≡H[n,2,4] : ∀ n → H (1 + n) 2 3 ≡ H n 2 4 H[1+n,2,3]≡H[n,2,4] 0 = refl H[1+n,2,3]≡H[n,2,4] (suc n) = begin-equality H (2 + n) 2 3 ≡⟨ H-rec (1 + n) 2 2 ⟩ H (1 + n) 2 (H (2 + n) 2 2) ≡⟨ cong (H (1 + n) 2) $ H[1+n,2,2]≡4 (1 + n) ⟩ H (1 + n) 2 4 ∎ H[2+n,0,1]≡0 : ∀ n → H (2 + n) 0 1 ≡ 0 H[2+n,0,1]≡0 zero = refl H[2+n,0,1]≡0 (suc n) = H[2+n,0,1]≡0 n H[4+n,0,2*b]≡1 : ∀ n b → H (4 + n) 0 (2 * b) ≡ 1 H[4+n,0,1+2*b]≡0 : ∀ n b → H (4 + n) 0 (1 + 2 * b) ≡ 0 H[4+n,0,2*b]≡1 n zero = refl H[4+n,0,2*b]≡1 n (suc b) = begin-equality H (3 + n) 0 (H (4 + n) 0 (b + (suc (b + 0)))) ≡⟨ cong (λ v → H (3 + n) 0 (H (4 + n) 0 v)) $ +-suc b (b + 0) ⟩ H (3 + n) 0 (H (4 + n) 0 (1 + 2 * b)) ≡⟨ cong (H (3 + n) 0) $ H[4+n,0,1+2*b]≡0 n b ⟩ H (3 + n) 0 0 ≡⟨⟩ 1 ∎ H[4+n,0,1+2*b]≡0 n b = begin-equality H (3 + n) 0 (H (4 + n) 0 (2 * b)) ≡⟨ cong (H (3 + n) 0) $ H[4+n,0,2*b]≡1 n b ⟩ H (3 + n) 0 1 ≡⟨ H[2+n,0,1]≡0 (suc n) ⟩ 0 ∎ ------------------------------------------------------------------------ -- Properties of `ack` private ack-H-helper : (P : ℕ → ℕ → Set) → (∀ n → P 0 n) → (∀ m → P m 1 → P (suc m) 0) → (∀ m n → P (suc m) n → (∀ n′ → P m n′) → P (suc m) (suc n)) → ∀ m n → P m n ack-H-helper P P[0,n] P[m,0] P[m,n] = go where go : ∀ m n → P m n go 0 n = P[0,n] n go (suc m) 0 = P[m,0] m (go m 1) go (suc m) (suc n) = P[m,n] m n (go (suc m) n) (go m) -- Ackermann function can be expressed in terms of hyperoperation. -- 3 + Ack(m, n) = Hₙ(2, 3 + n) ack-H : ∀ m n → 3 + ack m n ≡ H m 2 (3 + n) ack-H = ack-H-helper P (λ _ → refl) P[m,0] P[m,n] where P : ℕ → ℕ → Set P m n = 3 + ack m n ≡ H m 2 (3 + n) P[m,0] : ∀ m → P m 1 → P (suc m) 0 P[m,0] m P[m,1] = trans P[m,1] (sym $ H[1+n,2,3]≡H[n,2,4] m) P[m,n] : ∀ m n → P (suc m) n → (∀ n′ → P m n′) → P (suc m) (suc n) P[m,n] m n P[m′,n] P[m,n′] = begin-equality 3 + ack m (ack (1 + m) n) ≡⟨ P[m,n′] (ack (1 + m) n) ⟩ H m 2 (3 + ack (1 + m) n) ≡⟨ cong (H m 2) $ P[m′,n] ⟩ H m 2 (H (1 + m) 2 (3 + n)) ≡⟨ sym $ H-rec m 2 (3 + n) ⟩ H (1 + m) 2 (4 + n) ∎ iter : (ℕ → ℕ) → ℕ → ℕ iter f 0 = f 1 iter f (suc n) = f (iter f n) iter-is-fold : ∀ f n → iter f n ≡ fold (f 1) f n iter-is-fold f zero = refl iter-is-fold f (suc n) = cong f (iter-is-fold f n) ack-is-fold′ : ∀ m n → ack m n ≡ fold suc iter m n ack-is-fold′ 0 n = refl ack-is-fold′ (suc m) 0 = ack-is-fold′ m 1 ack-is-fold′ (suc m) (suc n) = begin-equality ack m (ack (suc m) n) ≡⟨ ack-is-fold′ m (ack (suc m) n) ⟩ fold suc iter m (ack (suc m) n) ≡⟨ cong (fold suc iter m) $ ack-is-fold′ (suc m) n ⟩ fold suc iter m (iter (fold suc iter m) n) ∎ ack-is-fold : ∀ m n → ack m n ≡ fold suc (λ f n → fold (f 1) f n) m n ack-is-fold zero n = refl ack-is-fold (suc m) zero = ack-is-fold m 1 ack-is-fold (suc m) (suc n) = trans (ack-is-fold m (ack (suc m) n)) (cong (fold suc (λ f n → fold (f 1) f n) m) (ack-is-fold (suc m) n))
{ "alphanum_fraction": 0.4308313699, "avg_line_length": 30.9479166667, "ext": "agda", "hexsha": "af32c30418a26090e835988e61a44ccdd5ea5f0b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_path": "Math/Googology/Function/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_path": "Math/Googology/Function/Properties.agda", "max_line_length": 78, "max_stars_count": 3, "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_path": "Math/Googology/Function/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "num_tokens": 3123, "size": 5942 }
{-# OPTIONS --without-K #-} open import HoTT.Base open import HoTT.Equivalence module HoTT.Identity.Unit where open variables =𝟏-equiv : {x y : 𝟏 {i}} → (x == y) ≃ 𝟏 {j} =𝟏-equiv {i} {j} {★} {★} = f , qinv→isequiv (g , η , ε) where f : {x y : 𝟏} → x == y → 𝟏 {j} f _ = ★ g : {x y : 𝟏} → 𝟏 {j} → x == y g {★} {★} _ = refl η : g ∘ f ~ id η refl = refl ε : f ∘ g {★} {★} ~ id ε ★ = refl
{ "alphanum_fraction": 0.4465558195, "avg_line_length": 21.05, "ext": "agda", "hexsha": "d31690d21ed577629062231bbef5a4df6be00558", "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": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "michaelforney/hott", "max_forks_repo_path": "HoTT/Identity/Unit.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "michaelforney/hott", "max_issues_repo_path": "HoTT/Identity/Unit.agda", "max_line_length": 55, "max_stars_count": null, "max_stars_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "michaelforney/hott", "max_stars_repo_path": "HoTT/Identity/Unit.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 205, "size": 421 }
module Algebra.FreeSemiring where open import Prelude open import Algebra data 𝑅 : Type where _+_ : 𝑅 → 𝑅 → 𝑅 _*_ : 𝑅 → 𝑅 → 𝑅 1# : 𝑅 0# : 𝑅 +-comm : Commutative _+_ +-assoc : Associative _+_ *-assoc : Associative _*_ 0+ : Identityˡ _+_ 0# +0 : Identityʳ _+_ 0# 1* : Identityˡ _*_ 1# *1 : Identityʳ _*_ 1# 0* : Zeroˡ _*_ 0# *0 : Zeroʳ _*_ 0# ⟨+⟩* : _*_ Distributesˡ _+_ *⟨+⟩ : _*_ Distributesʳ _+_ semiring𝑅 : Semiring ℓzero semiring𝑅 .Semiring.nearSemiring .NearSemiring.𝑅 = 𝑅 semiring𝑅 .Semiring.nearSemiring .NearSemiring._+_ = _+_ semiring𝑅 .Semiring.nearSemiring .NearSemiring._*_ = _*_ semiring𝑅 .Semiring.nearSemiring .NearSemiring.1# = 1# semiring𝑅 .Semiring.nearSemiring .NearSemiring.0# = 0# semiring𝑅 .Semiring.nearSemiring .NearSemiring.+-assoc = +-assoc semiring𝑅 .Semiring.nearSemiring .NearSemiring.*-assoc = *-assoc semiring𝑅 .Semiring.nearSemiring .NearSemiring.0+ = 0+ semiring𝑅 .Semiring.nearSemiring .NearSemiring.+0 = +0 semiring𝑅 .Semiring.nearSemiring .NearSemiring.1* = 1* semiring𝑅 .Semiring.nearSemiring .NearSemiring.*1 = *1 semiring𝑅 .Semiring.nearSemiring .NearSemiring.0* = 0* semiring𝑅 .Semiring.nearSemiring .NearSemiring.⟨+⟩* = ⟨+⟩* semiring𝑅 .Semiring.+-comm = +-comm semiring𝑅 .Semiring.*0 = *0 semiring𝑅 .Semiring.*⟨+⟩ = *⟨+⟩ -- open import Algebra.SemiringLiterals semiring𝑅 -- open import Literals.Number -- open import Data.Unit.UniversePolymorphic -- ex : 𝑅 -- ex = 410928
{ "alphanum_fraction": 0.7051104972, "avg_line_length": 30.1666666667, "ext": "agda", "hexsha": "882bd0b966fc2e04bae2d15efadb38efb71ea2d2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Algebra/FreeSemiring.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Algebra/FreeSemiring.agda", "max_line_length": 64, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Algebra/FreeSemiring.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": 618, "size": 1448 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Agda where open import Level import Relation.Binary import Function.Equality import Categories.Support.Equivalence import Categories.Support.SetoidFunctions open import Categories.Support.PropositionalEquality open import Categories.Category open import Categories.Functor using (Functor) Sets : ∀ o → Category _ _ _ Sets o = record { Obj = Set o ; _⇒_ = λ d c → d → c ; _≡_ = λ f g → ∀ {x} → f x ≣ g x ; _∘_ = λ f g x → f (g x) ; id = λ x → x ; assoc = ≣-refl ; identityˡ = ≣-refl ; identityʳ = ≣-refl ; equiv = record { refl = ≣-refl; sym = s; trans = t } ; ∘-resp-≡ = ∘-resp-≡′ } where s : {A B : Set o} → {i j : A → B} → ({x : A} → i x ≣ j x) → {x : A} → j x ≣ i x s f {x} rewrite f {x} = ≣-refl t : {A B : Set o} {i j k : A → B} → ({x : A} → i x ≣ j x) → ({x : A} → j x ≣ k x) → {x : A} → i x ≣ k x t f g {x} rewrite f {x} | g {x} = ≣-refl ∘-resp-≡′ : {A B C : Set o} {f h : B → C} {g i : A → B} → (∀ {x} → f x ≣ h x) → (∀ {x} → g x ≣ i x) → (∀ {x} → f (g x) ≣ h (i x)) ∘-resp-≡′ {g = g} f≡h g≡i {x} rewrite f≡h {g x} | g≡i {x} = ≣-refl -- use standard library setoids here, not our special irrelevant ones Setoids : ∀ c ℓ → Category (suc (ℓ ⊔ c)) (ℓ ⊔ c) (ℓ ⊔ c) Setoids c ℓ = record { Obj = Setoid c ℓ ; _⇒_ = _⟶_ ; _≡_ = λ {X} {Y} → _≡′_ {X} {Y} ; _∘_ = _∘′_ ; id = id′ ; assoc = λ {_} {_} {_} {D} → Setoid.refl D ; identityˡ = λ {_} {B} → Setoid.refl B ; identityʳ = λ {_} {B} → Setoid.refl B ; equiv = λ {A} {B} → record { refl = Setoid.refl B ; sym = λ f → Setoid.sym B f ; trans = λ f g → Setoid.trans B f g } ; ∘-resp-≡ = λ {A} {B} {C} {f} {h} {g} {i} → ∘-resp-≡′ {A} {B} {C} {f} {h} {g} {i} } where infix 4 _≡′_ open Function.Equality using (_⟨$⟩_; cong; _⟶_) renaming (_∘_ to _∘′_; id to id′) open Relation.Binary using (Setoid; module Setoid; Rel) _≡′_ : ∀ {X Y} → Rel (X ⟶ Y) _ _≡′_ {X} {Y} f g = ∀ {x} → Setoid._≈_ Y (f ⟨$⟩ x) (g ⟨$⟩ x) .∘-resp-≡′ : ∀ {A B C} {f h : B ⟶ C} {g i : A ⟶ B} → f ≡′ h → g ≡′ i → f ∘′ g ≡′ h ∘′ i ∘-resp-≡′ {C = C} {h = h} f≡h g≡i {x} = Setoid.trans C f≡h (cong h g≡i) -- setoids with irrelevant equality ISetoids : ∀ c ℓ → Category (suc (ℓ ⊔ c)) (ℓ ⊔ c) (ℓ ⊔ c) ISetoids c ℓ = record { Obj = Setoid c ℓ ; _⇒_ = _⟶_ ; _≡_ = λ {A B} → Setoid._≈_ (A ⇨ B) ; _∘_ = _∙_ ; id = id′ ; assoc = λ {A B C D} {f g h} → cong (h ∙ g ∙ f) ; identityˡ = λ {A B f} → cong f ; identityʳ = λ {A B f} → cong f ; equiv = λ {A B} → Setoid.isEquivalence (A ⇨ B) ; ∘-resp-≡ = λ f≡h g≡i x≡y → f≡h (g≡i x≡y) } where open Relation.Binary using (Rel) open Categories.Support.Equivalence open Categories.Support.SetoidFunctions renaming (id to id′) Lift-IS : ∀ {c ℓ} a b → Functor (ISetoids c ℓ) (ISetoids (c ⊔ a) (ℓ ⊔ b)) Lift-IS {c} {ℓ} a b = record { F₀ = Lift-setoid {c} {ℓ} {a} {b}; F₁ = λ f → record { _⟨$⟩_ = λ x → lift (f ⟨$⟩ (lower x)); cong = λ eq → lift (cong f (lower eq)) }; identity = λ x → x; homomorphism = λ {_} {_} {_} {f} {g} eq → lift (cong g (cong f (lower eq))); F-resp-≡ = λ eq₀ eq₁ → lift (eq₀ (lower eq₁)) } where open import Categories.Support.Equivalence open Categories.Support.SetoidFunctions renaming (id to id′)
{ "alphanum_fraction": 0.4945858941, "avg_line_length": 32.8557692308, "ext": "agda", "hexsha": "50dc0cd6f8297945ae40a6f9f3636be8b46ed53a", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Agda.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Agda.agda", "max_line_length": 118, "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/Agda.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": 1531, "size": 3417 }
-- -- Created by Dependently-Typed Lambda Calculus on 2021-03-18 -- lambe -- Author: dplaindoux -- {-# OPTIONS --without-K --safe #-} module Lambe where open import Relation.Nullary using (yes; no) open import Data.List using (List; []; [_]; _∷_; _++_) open import Data.String using (String; _≟_) open import Relation.Binary.PropositionalEquality using (_≢_; refl; _≡_) module Kind where {- κ = | ⋆ | κ → κ | K K = {mi:κi}I -} data t : Set where * : t _->_ : t → t → t K : List (String*t) → t
{ "alphanum_fraction": 0.553633218, "avg_line_length": 15.6216216216, "ext": "agda", "hexsha": "ecbbd213f0170c62a71258facaec9d91b4717d1f", "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": "a39f8bb966594586d5fff257f5d6a1db939d2c97", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "d-plaindoux/lambe", "max_forks_repo_path": "formalism/lambe.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a39f8bb966594586d5fff257f5d6a1db939d2c97", "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": "d-plaindoux/lambe", "max_issues_repo_path": "formalism/lambe.agda", "max_line_length": 61, "max_stars_count": 5, "max_stars_repo_head_hexsha": "a39f8bb966594586d5fff257f5d6a1db939d2c97", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "d-plaindoux/lambe-spec", "max_stars_repo_path": "formalism/lambe.agda", "max_stars_repo_stars_event_max_datetime": "2019-08-22T15:42:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-18T08:40:29.000Z", "num_tokens": 192, "size": 578 }
open import Prelude open import Nat module List where data List (A : Set) : Set where [] : List A _::_ : A → List A → List A map : {A B : Set} → (A → B) → (List A) → List B map f [] = [] map f (x :: L) = (f x) :: map f L foldr : {A B : Set} → (A → B → B) → B → List A → B foldr f b [] = b foldr f b (x :: l) = f x (foldr f b l) -- list membership data _∈_ {A : Set} : A → List A → Set where ∈h : {x : A} {l : List A} → x ∈ (x :: l) ∈t : {x y : A} {l : List A} → x ∈ l → x ∈ y :: l infixr 99 _::_ data Unique {A B : Set} (f : A → B) : List A → Set where U[] : Unique f [] U:: : {x : A} {xs : List A} → Unique f xs → (f x ∈ map f xs → ⊥) → Unique f (x :: xs) L : List (Nat × Nat) L = ((1 , 9) :: (2 , 9) :: []) ex1 : Unique π1 L ex1 = U:: (U:: U[] notemp) notin where notemp : {x : Nat} → x ∈ [] → ⊥ notemp () notin : 1 ∈ (2 :: []) → ⊥ notin (∈t p) = notemp p ex2 : Unique π2 L → ⊥ ex2 (U:: p x) = x ∈h maxl : List Nat → Nat maxl = foldr max 0 -- addmax : {L : List Nat} (p : Unique (\x → x) L) → Unique (\x → x) ((1+ (maxl L)) :: L) -- addmax U[] = U:: U[] (λ ()) -- addmax (U:: p x₁) with addmax p -- ... | ih = U:: (U:: p x₁) (λ x → x₁ {!!})
{ "alphanum_fraction": 0.4149184149, "avg_line_length": 24.2830188679, "ext": "agda", "hexsha": "d62437e701508f4780446769514cf0108499bb8d", "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": "86a755ca6749e080f9a03287e34d1cda889f1edb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ivoysey/agda-tfp16", "max_forks_repo_path": "List.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "86a755ca6749e080f9a03287e34d1cda889f1edb", "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": "ivoysey/agda-tfp16", "max_issues_repo_path": "List.agda", "max_line_length": 91, "max_stars_count": 2, "max_stars_repo_head_hexsha": "86a755ca6749e080f9a03287e34d1cda889f1edb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/agda-tfp16", "max_stars_repo_path": "List.agda", "max_stars_repo_stars_event_max_datetime": "2016-06-10T04:35:42.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-10T04:35:39.000Z", "num_tokens": 545, "size": 1287 }
module Playground where -- Equality type, and its only constructor refl data _==_ {A : Set} (x : A) : A → Set where refl : x == x -- identity map of a type id : {A : Set} → A → A id x = x -- action on paths ap : {A B : Set} (f : A → B) {x y : A} → (x == y -> f x == f y) ap f refl = refl -- transport transport : {A : Set} (B : A → Set) {x y : A} (p : x == y) → (B x → B y) transport _ refl = id -- Pi types Π : (A : Set) (P : A → Set) → Set Π A P = (x : A) → P x -- Sigma types record Σ (A : Set) (B : A → Set) : Set where constructor _,_ field fst : A snd : B fst open Σ public -- empty type data ⊥ : Set where -- not operator ¬ : (A : Set) → Set ¬ A = A → ⊥
{ "alphanum_fraction": 0.5168374817, "avg_line_length": 18.4594594595, "ext": "agda", "hexsha": "f35fabee70ce9dbeda0b3c32e8f338df2789b156", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2018-06-25T15:05:21.000Z", "max_forks_repo_forks_event_min_datetime": "2018-02-22T19:58:46.000Z", "max_forks_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "glangmead/hott_cmu80818", "max_forks_repo_path": "Playground.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_issues_repo_issues_event_max_datetime": "2018-03-25T14:44:31.000Z", "max_issues_repo_issues_event_min_datetime": "2018-02-22T21:01:16.000Z", "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "glangmead/hott_cmu80818", "max_issues_repo_path": "Playground.agda", "max_line_length": 72, "max_stars_count": 4, "max_stars_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "glangmead/hott_cmu80818", "max_stars_repo_path": "Playground.agda", "max_stars_repo_stars_event_max_datetime": "2018-09-04T02:52:25.000Z", "max_stars_repo_stars_event_min_datetime": "2018-05-03T20:32:19.000Z", "num_tokens": 268, "size": 683 }
{-# OPTIONS --cubical #-} open import Agda.Builtin.Nat postulate _≡_ : {A : Set} → A → A → Set refl : (A : Set) (x : A) → x ≡ x cong : (A B : Set) (x y : A) (f : A → B) (x≡y : x ≡ y) → f x ≡ f y subst : (A : Set) (x y : A) (P : A → Set) → x ≡ y → P x → P y apply : (A : Set) (B : A → Set) → ((x : A) → B x) → ((x : A) → B x) apply _ _ f x = f x postulate A : Set record R (f : A → A) : Set where postulate P : (f : A → A) → R f → Set _ : (f : A → A) (r : R f) → P f (subst (A → A) _ f R (cong _ _ _ _ (λ f → apply _ _ f 0) (refl _ (λ _ → {!!}))) r)
{ "alphanum_fraction": 0.4114671164, "avg_line_length": 22.8076923077, "ext": "agda", "hexsha": "3ab75e82b06358e6e183a476f876ce0f4c061ac9", "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/Issue4982.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/Issue4982.agda", "max_line_length": 72, "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/Issue4982.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": 281, "size": 593 }
module Data.Boolean.Operators where open import Data.Boolean -- Definition of boolean operators with conventions from logic module Logic where infixl 1005 _∧_ infixl 1004 _∨_ _⊕_ infixl 1003 _⟵_ _⟷_ _⟶_ _∧_ : Bool → Bool → Bool _∧_ 𝑇 𝑇 = 𝑇 _∧_ 𝐹 𝑇 = 𝐹 _∧_ 𝑇 𝐹 = 𝐹 _∧_ 𝐹 𝐹 = 𝐹 _∨_ : Bool → Bool → Bool _∨_ 𝑇 𝑇 = 𝑇 _∨_ 𝐹 𝑇 = 𝑇 _∨_ 𝑇 𝐹 = 𝑇 _∨_ 𝐹 𝐹 = 𝐹 open Data.Boolean using () renaming (not to ¬) public _⊕_ : Bool → Bool → Bool _⊕_ 𝑇 𝑇 = 𝐹 _⊕_ 𝐹 𝑇 = 𝑇 _⊕_ 𝑇 𝐹 = 𝑇 _⊕_ 𝐹 𝐹 = 𝐹 _⟶_ : Bool → Bool → Bool _⟶_ 𝑇 𝑇 = 𝑇 _⟶_ 𝐹 𝑇 = 𝑇 _⟶_ 𝑇 𝐹 = 𝐹 _⟶_ 𝐹 𝐹 = 𝑇 _⟵_ : Bool → Bool → Bool _⟵_ 𝑇 𝑇 = 𝑇 _⟵_ 𝐹 𝑇 = 𝐹 _⟵_ 𝑇 𝐹 = 𝑇 _⟵_ 𝐹 𝐹 = 𝑇 _⟷_ : Bool → Bool → Bool _⟷_ 𝑇 𝑇 = 𝑇 _⟷_ 𝐹 𝑇 = 𝐹 _⟷_ 𝑇 𝐹 = 𝐹 _⟷_ 𝐹 𝐹 = 𝑇 _⊼_ : Bool → Bool → Bool _⊼_ 𝑇 𝑇 = 𝐹 _⊼_ 𝐹 𝑇 = 𝑇 _⊼_ 𝑇 𝐹 = 𝑇 _⊼_ 𝐹 𝐹 = 𝑇 _⊽_ : Bool → Bool → Bool _⊽_ 𝑇 𝑇 = 𝐹 _⊽_ 𝐹 𝑇 = 𝐹 _⊽_ 𝑇 𝐹 = 𝐹 _⊽_ 𝐹 𝐹 = 𝑇 ⊤ : Bool ⊤ = 𝑇 ⊥ : Bool ⊥ = 𝐹 -- Definition of boolean operators with conventions from typical programming languages module Programming where open Logic using () renaming (_∧_ to _&&_ ; _∨_ to _||_ ; ¬ to ! ; _⟷_ to _==_ ; _⊕_ to _!=_ ; _⟶_ to _→?_ ; _⟵_ to _←?_ ) public
{ "alphanum_fraction": 0.5119047619, "avg_line_length": 16.1538461538, "ext": "agda", "hexsha": "62c22c1d2c85604ba4e8a14b2ff5367e192da084", "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/Boolean/Operators.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/Boolean/Operators.agda", "max_line_length": 86, "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/Boolean/Operators.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": 830, "size": 1260 }
-- Andreas, 2017-09-18, issue #2754 reported by nad. -- Command line options -- -- --ignore-interfaces -v tc:10 -- -- caused internal error when processing Agda.Primitive. -- -- Reason: trying to debug print levels while level built-ins -- are not yet bound. -- -- Should work now, printing -- -- .#Lacking_Level_Builtins# -- -- where levels should be printed. -- This file is left black intentionally.
{ "alphanum_fraction": 0.6968215159, "avg_line_length": 21.5263157895, "ext": "agda", "hexsha": "97dbaf643c9233f1f84c9a26252a32313975c6fd", "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/Issue2754.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/Issue2754.agda", "max_line_length": 61, "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/Issue2754.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": 105, "size": 409 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Lists, based on the Kleene star and plus, basic types and operations. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Kleene.Base where open import Data.Product as Product using (_×_; _,_; map₂; map₁; proj₁; proj₂) open import Data.Nat as ℕ using (ℕ; suc; zero) open import Data.Maybe as Maybe using (Maybe; just; nothing) open import Data.Sum as Sum using (_⊎_; inj₁; inj₂) open import Level as Level using (Level) open import Algebra.Core using (Op₂) open import Function.Base private variable a b c : Level A : Set a B : Set b C : Set c ------------------------------------------------------------------------ -- Definitions -- -- These lists are exactly equivalent to normal lists, except the "cons" -- case is split into its own data type. This lets us write all the same -- functions as before, but it has 2 advantages: -- -- * Some functions are easier to express on the non-empty type. Head, -- for instance, has a natural safe implementation. Having the -- non-empty type be defined mutually with the normal type makes the -- use of this non-empty type occasionally more ergonomic. -- * It can make some proofs easier. By using the non-empty type where -- possible, we can avoid an extra pattern match, which can really -- simplify certain proofs. infixr 5 _&_ ∹_ record _+ {a} (A : Set a) : Set a data _* {a} (A : Set a) : Set a -- Non-Empty Lists record _+ A where inductive constructor _&_ field head : A tail : A * -- Possibly Empty Lists data _* A where [] : A * ∹_ : A + → A * open _+ public ------------------------------------------------------------------------ -- Uncons uncons : A * → Maybe (A +) uncons [] = nothing uncons (∹ xs) = just xs ------------------------------------------------------------------------ -- FoldMap foldMap+ : Op₂ B → (A → B) → A + → B foldMap+ _∙_ f (x & []) = f x foldMap+ _∙_ f (x & ∹ xs) = f x ∙ foldMap+ _∙_ f xs foldMap* : Op₂ B → B → (A → B) → A * → B foldMap* _∙_ ε f [] = ε foldMap* _∙_ ε f (∹ xs) = foldMap+ _∙_ f xs ------------------------------------------------------------------------ -- Folds module _ (f : A → B → B) (b : B) where foldr+ : A + → B foldr* : A * → B foldr+ (x & xs) = f x (foldr* xs) foldr* [] = b foldr* (∹ xs) = foldr+ xs module _ (f : B → A → B) where foldl+ : B → A + → B foldl* : B → A * → B foldl+ b (x & xs) = foldl* (f b x) xs foldl* b [] = b foldl* b (∹ xs) = foldl+ b xs ------------------------------------------------------------------------ -- Concatenation module Concat where _++++_ : A + → A + → A + _+++*_ : A + → A * → A + _*+++_ : A * → A + → A + _*++*_ : A * → A * → A * head (xs +++* ys) = head xs tail (xs +++* ys) = tail xs *++* ys xs *++* ys = foldr* (λ x zs → ∹ x & zs) ys xs xs ++++ ys = foldr+ (λ x zs → x & ∹ zs) ys xs [] *+++ ys = ys (∹ xs) *+++ ys = xs ++++ ys open Concat public using () renaming (_++++_ to _+++_; _*++*_ to _++*_) ------------------------------------------------------------------------ -- Mapping module _ (f : A → B) where map+ : A + → B + map* : A * → B * head (map+ xs) = f (head xs) tail (map+ xs) = map* (tail xs) map* [] = [] map* (∹ xs) = ∹ map+ xs module _ (f : A → Maybe B) where mapMaybe+ : A + → B * mapMaybe* : A * → B * mapMaybe+ (x & xs) with f x ... | just y = ∹ y & mapMaybe* xs ... | nothing = mapMaybe* xs mapMaybe* [] = [] mapMaybe* (∹ xs) = mapMaybe+ xs ------------------------------------------------------------------------ -- Applicative Operations pure+ : A → A + head (pure+ x) = x tail (pure+ x) = [] pure* : A → A * pure* x = ∹ pure+ x module Apply where _*<*>*_ : (A → B) * → A * → B * _+<*>*_ : (A → B) + → A * → B * _*<*>+_ : (A → B) * → A + → B * _+<*>+_ : (A → B) + → A + → B + [] *<*>* xs = [] (∹ fs) *<*>* xs = fs +<*>* xs fs +<*>* xs = map* (head fs) xs ++* (tail fs *<*>* xs) [] *<*>+ xs = [] (∹ fs) *<*>+ xs = ∹ fs +<*>+ xs fs +<*>+ xs = map+ (head fs) xs Concat.+++* (tail fs *<*>+ xs) open Apply public using () renaming (_*<*>*_ to _<*>*_; _+<*>+_ to _<*>+_) ------------------------------------------------------------------------ -- Monadic Operations module Bind where _+>>=+_ : A + → (A → B +) → B + _+>>=*_ : A + → (A → B *) → B * _*>>=+_ : A * → (A → B +) → B * _*>>=*_ : A * → (A → B *) → B * (x & xs) +>>=+ k = k x Concat.+++* (xs *>>=+ k) (x & xs) +>>=* k = k x Concat.*++* (xs *>>=* k) [] *>>=* k = [] (∹ xs) *>>=* k = xs +>>=* k [] *>>=+ k = [] (∹ xs) *>>=+ k = ∹ xs +>>=+ k open Bind public using () renaming (_*>>=*_ to _>>=*_; _+>>=+_ to _>>=+_) ------------------------------------------------------------------------ -- Scans module Scanr (f : A → B → B) (b : B) where cons : A → B + → B + head (cons x xs) = f x (head xs) tail (cons x xs) = ∹ xs scanr+ : A + → B + scanr* : A * → B + scanr* = foldr* cons (b & []) scanr+ = foldr+ cons (b & []) open Scanr public using (scanr+; scanr*) module _ (f : B → A → B) where scanl* : B → A * → B + head (scanl* b xs) = b tail (scanl* b []) = [] tail (scanl* b (∹ xs)) = ∹ scanl* (f b (head xs)) (tail xs) scanl+ : B → A + → B + head (scanl+ b xs) = b tail (scanl+ b xs) = ∹ scanl* (f b (head xs)) (tail xs) scanl₁ : B → A + → B + scanl₁ b xs = scanl* (f b (head xs)) (tail xs) ------------------------------------------------------------------------ -- Accumulating maps module _ (f : B → A → (B × C)) where mapAccumˡ* : B → A * → (B × C *) mapAccumˡ+ : B → A + → (B × C +) mapAccumˡ* b [] = b , [] mapAccumˡ* b (∹ xs) = map₂ ∹_ (mapAccumˡ+ b xs) mapAccumˡ+ b (x & xs) = let y , ys = f b x z , zs = mapAccumˡ* y xs in z , ys & zs module _ (f : A → B → (C × B)) (b : B) where mapAccumʳ* : A * → (C * × B) mapAccumʳ+ : A + → (C + × B) mapAccumʳ* [] = [] , b mapAccumʳ* (∹ xs) = map₁ ∹_ (mapAccumʳ+ xs) mapAccumʳ+ (x & xs) = let ys , y = mapAccumʳ* xs zs , z = f x y in zs & ys , z ------------------------------------------------------------------------ -- Non-Empty Folds last : A + → A last (x & []) = x last (_ & ∹ xs) = last xs module _ (f : A → A → A) where foldr₁ : A + → A foldr₁ (x & []) = x foldr₁ (x & ∹ xs) = f x (foldr₁ xs) foldl₁ : A + → A foldl₁ (x & xs) = foldl* f x xs module _ (f : A → Maybe B → B) where foldrMaybe* : A * → Maybe B foldrMaybe+ : A + → B foldrMaybe* [] = nothing foldrMaybe* (∹ xs) = just (foldrMaybe+ xs) foldrMaybe+ xs = f (head xs) (foldrMaybe* (tail xs)) ------------------------------------------------------------------------ -- Indexing _[_]* : A * → ℕ → Maybe A _[_]+ : A + → ℕ → Maybe A [] [ _ ]* = nothing (∹ xs) [ i ]* = xs [ i ]+ xs [ zero ]+ = just (head xs) xs [ suc i ]+ = tail xs [ i ]* applyUpTo* : (ℕ → A) → ℕ → A * applyUpTo+ : (ℕ → A) → ℕ → A + applyUpTo* f zero = [] applyUpTo* f (suc n) = ∹ applyUpTo+ f n head (applyUpTo+ f n) = f zero tail (applyUpTo+ f n) = applyUpTo* (f ∘ suc) n upTo* : ℕ → ℕ * upTo* = applyUpTo* id upTo+ : ℕ → ℕ + upTo+ = applyUpTo+ id ------------------------------------------------------------------------ -- Manipulation module ZipWith (f : A → B → C) where +zipWith+ : A + → B + → C + *zipWith+ : A * → B + → C * +zipWith* : A + → B * → C * *zipWith* : A * → B * → C * head (+zipWith+ xs ys) = f (head xs) (head ys) tail (+zipWith+ xs ys) = *zipWith* (tail xs) (tail ys) *zipWith+ [] ys = [] *zipWith+ (∹ xs) ys = ∹ +zipWith+ xs ys +zipWith* xs [] = [] +zipWith* xs (∹ ys) = ∹ +zipWith+ xs ys *zipWith* [] ys = [] *zipWith* (∹ xs) ys = +zipWith* xs ys open ZipWith public renaming (+zipWith+ to zipWith+; *zipWith* to zipWith*) module Unzip (f : A → B × C) where cons : B × C → B * × C * → B + × C + cons = Product.zip′ _&_ _&_ unzipWith* : A * → B * × C * unzipWith+ : A + → B + × C + unzipWith* = foldr* (λ x xs → Product.map ∹_ ∹_ (cons (f x) xs)) ([] , []) unzipWith+ xs = cons (f (head xs)) (unzipWith* (tail xs)) open Unzip using (unzipWith+; unzipWith*) public module Partition (f : A → B ⊎ C) where cons : B ⊎ C → B * × C * → B * × C * proj₁ (cons (inj₁ x) xs) = ∹ x & proj₁ xs proj₂ (cons (inj₁ x) xs) = proj₂ xs proj₂ (cons (inj₂ x) xs) = ∹ x & proj₂ xs proj₁ (cons (inj₂ x) xs) = proj₁ xs partitionSumsWith* : A * → B * × C * partitionSumsWith+ : A + → B * × C * partitionSumsWith* = foldr* (cons ∘ f) ([] , []) partitionSumsWith+ = foldr+ (cons ∘ f) ([] , []) open Partition using (partitionSumsWith+; partitionSumsWith*) public tails* : A * → (A +) * tails+ : A + → (A +) + head (tails+ xs) = xs tail (tails+ xs) = tails* (tail xs) tails* [] = [] tails* (∹ xs) = ∹ tails+ xs reverse* : A * → A * reverse* = foldl* (λ xs x → ∹ x & xs) [] reverse+ : A + → A + reverse+ (x & xs) = foldl* (λ ys y → y & ∹ ys) (x & []) xs
{ "alphanum_fraction": 0.4377457405, "avg_line_length": 25.4333333333, "ext": "agda", "hexsha": "221bb494bd8f86f5e1c2c742c8475bb449ebee36", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/List/Kleene/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/List/Kleene/Base.agda", "max_line_length": 78, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/List/Kleene/Base.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": 3277, "size": 9156 }
-- TODO: Move these to stuff related to metric spaces module Derivative where open Limit using (Lim ; lim) -- Statement that the point x of function f is a differentiable point DifferentiablePoint : (ℝ → ℝ) → ℝ → Stmt DifferentiablePoint f(p) = Lim(x ↦ ((f(x) − f(p))/(x − p)))(p) -- Statement that function f is differentiable Differentiable : (ℝ → ℝ) → Stmt Differentiable f = ∀{x} → DifferentiablePoint f(x) -- Derivative value of function f at point x (if the point is differentiable) 𝐷 : (f : ℝ → ℝ) → (x : ℝ) → ⦃ _ : DifferentiablePoint f(x) ⦄ → ℝ 𝐷 _ _ ⦃ l ⦄ = Lim.L(l) module Proofs where instance postulate Differentiable-constant : ∀{a} → Differentiable(const(a)) instance postulate Differentiable-id : Differentiable(id) instance postulate Differentiable-monomial : ∀{a} → Differentiable(x ↦ x ^ a) instance postulate Differentiable-[eˣ] : Differentiable(x ↦ e ^ x) instance postulate Differentiable-[⋅]-scalar : ∀{a} → Differentiable(x ↦ a ⋅ x) instance postulate Differentiable-[+]-function : ∀{f g} → ⦃ _ : Differentiable(f) ⦄ → ⦃ _ : Differentiable(g) ⦄ → Differentiable(x ↦ f(x) + g(x)) instance postulate Differentiable-[−]-function : ∀{f g} → ⦃ _ : Differentiable(f) ⦄ → ⦃ _ : Differentiable(g) ⦄ → Differentiable(x ↦ f(x) − g(x)) instance postulate Differentiable-[⋅]-function : ∀{f g} → ⦃ _ : Differentiable(f) ⦄ → ⦃ _ : Differentiable(g) ⦄ → Differentiable(x ↦ f(x) ⋅ g(x)) instance postulate Differentiable-[/]-function : ∀{f g} → ⦃ _ : Differentiable(f) ⦄ → ⦃ _ : Differentiable(g) ⦄ → Differentiable(x ↦ f(x) / g(x)) instance postulate Differentiable-[∘]-function : ∀{f g} → ⦃ _ : Differentiable(f) ⦄ → ⦃ _ : Differentiable(g) ⦄ → Differentiable(f ∘ g) instance postulate [𝐷]-constant : ∀{a} → ⦃ diff : Differentiable(const(a)) ⦄ → ∀{x} → 𝐷(const(a))(x)⦃ diff ⦄ ≡ a instance postulate [𝐷]-id : ⦃ diff : Differentiable(id) ⦄ → ∀{x} → 𝐷(id)(x)⦃ diff ⦄ ≡ #(1) instance postulate [𝐷]-monomial : ∀{a} → ⦃ diff : Differentiable(x ↦ x ^ a) ⦄ → ∀{x} → 𝐷(x ↦ x ^ a)(x)⦃ diff ⦄ ≡ a ⋅ x ^ (a − #(1)) instance postulate [𝐷]-[eˣ] : ⦃ diff : Differentiable(x ↦ e ^ x) ⦄ → ∀{x} → 𝐷(x ↦ e ^ x)(x)⦃ diff ⦄ ≡ e ^ x instance postulate [𝐷]-[+]-function : ∀{f g} → ⦃ diff-f : Differentiable(f) ⦄ → ⦃ diff-g : Differentiable(g) ⦄ → ∀{x} → 𝐷(x ↦ f(x) + g(x))(x)⦃ Differentiable-[+]-function ⦃ diff-f ⦄ ⦃ diff-g ⦄ ⦄ ≡ 𝐷(f)(x)⦃ diff-f ⦄ + 𝐷(g)(x)⦃ diff-g ⦄ instance postulate [𝐷]-[−]-function : ∀{f g} → ⦃ diff-f : Differentiable(f) ⦄ → ⦃ diff-g : Differentiable(g) ⦄ → ∀{x} → 𝐷(x ↦ f(x) − g(x))(x)⦃ Differentiable-[−]-function ⦃ diff-f ⦄ ⦃ diff-g ⦄ ⦄ ≡ 𝐷(f)(x)⦃ diff-f ⦄ − 𝐷(g)(x)⦃ diff-g ⦄ instance postulate [𝐷]-[⋅]-function : ∀{f g} → ⦃ diff-f : Differentiable(f) ⦄ → ⦃ diff-g : Differentiable(g) ⦄ → ∀{x} → 𝐷(x ↦ f(x) ⋅ g(x))(x)⦃ Differentiable-[⋅]-function ⦃ diff-f ⦄ ⦃ diff-g ⦄ ⦄ ≡ 𝐷(f)(x)⦃ diff-f ⦄ ⋅ g(x) + f(x) ⋅ 𝐷(g)(x)⦃ diff-g ⦄ instance postulate [𝐷]-[/]-function : ∀{f g} → ⦃ diff-f : Differentiable(f) ⦄ → ⦃ diff-g : Differentiable(g) ⦄ → ∀{x} → 𝐷(x ↦ f(x) / g(x))(x)⦃ Differentiable-[/]-function ⦃ diff-f ⦄ ⦃ diff-g ⦄ ⦄ ≡ (𝐷(f)(x)⦃ diff-f ⦄ ⋅ g(x) − f(x) ⋅ 𝐷(g)(x)⦃ diff-g ⦄)/(g(x) ^ #(2)) instance postulate [𝐷]-[∘]-function : ∀{f g} → ⦃ diff-f : Differentiable(f) ⦄ → ⦃ diff-g : Differentiable(g) ⦄ → ∀{x} → 𝐷(x ↦ f(g(x)))(x)⦃ Differentiable-[∘]-function ⦃ diff-f ⦄ ⦃ diff-g ⦄ ⦄ ≡ 𝐷(f)(g(x))⦃ diff-f ⦄ ⋅ 𝐷(g)(x)⦃ diff-g ⦄
{ "alphanum_fraction": 0.5768006942, "avg_line_length": 88.641025641, "ext": "agda", "hexsha": "9d1056affcd6c7b99a732411ab89a29eaed26bc6", "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/Real/Derivative.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/Real/Derivative.agda", "max_line_length": 266, "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/Real/Derivative.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": 1519, "size": 3457 }
module Show where open import Data.Char hiding (show) open import Data.List open import Data.String hiding (show) open import Function record Show (A : Set) : Set where field show : A → String open Show {{...}} public fromHaskell : {A : Set} → (A → List Char) → Show A fromHaskell primShow = record { show = fromList ∘ primShow }
{ "alphanum_fraction": 0.6911764706, "avg_line_length": 21.25, "ext": "agda", "hexsha": "32a6da2fa4c053c3ecbe04931d301e78259331fc", "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": "c5ffd117f6d5a98f7c68a2a6b9be54a150c70945", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda-editor", "max_forks_repo_path": "src/Show.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c5ffd117f6d5a98f7c68a2a6b9be54a150c70945", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda-editor", "max_issues_repo_path": "src/Show.agda", "max_line_length": 60, "max_stars_count": null, "max_stars_repo_head_hexsha": "c5ffd117f6d5a98f7c68a2a6b9be54a150c70945", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda-editor", "max_stars_repo_path": "src/Show.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 94, "size": 340 }
{-# OPTIONS --universe-polymorphism #-} module 13-implicitProofObligations where open import Relation.Nullary open import Relation.Nullary.Decidable open import Data.Empty open import Data.Unit hiding (_≟_) open import Data.Nat open import Data.Fin using (Fin; toℕ) open import Data.Product using (_×_; _,_) open import Data.Nat.DivMod open import Relation.Binary.PropositionalEquality open import Function postulate d : ℕ d≢0 : d ≢ 0 -- d≢0' : d ≢ 0 fromWitnessFalse : ∀ {p} {P : Set p} {Q : Dec P} → ¬ P → False Q fromWitnessFalse {Q = yes p} ¬P = ⊥-elim $ ¬P p fromWitnessFalse {Q = no ¬p} ¬P = tt ⋯ : {A : Set} → {{v : A}} → A ⋯ {{v}} = v _divMod′_ : (dividend divisor : ℕ) {{ ≢0 : divisor ≢ 0 }} → ℕ × ℕ a divMod′ d with _divMod_ a d { fromWitnessFalse ⋯ } ._ divMod′ d | (result q r) = q , toℕ r _div′_ : (dividend divisor : ℕ) {{ ≢0 : divisor ≢ 0 }} → ℕ a div′ b with a divMod′ b a div′ b | (q , _) = q --Agda can't resolve hiddens -- test : {d≢0 : False (d ≟ 0)} → ℕ -- test = 5 div d -- test2 : {{d≢0 : d ≢ 0}} → ℕ -- test2 = 5 div′ d test3 = 5 div 2 test4 = 5 div′ 2 where nz : 2 ≢ 0 nz ()
{ "alphanum_fraction": 0.6120996441, "avg_line_length": 24.4347826087, "ext": "agda", "hexsha": "f811966ba0f7001b2e13dd785f9efc3d934b59e8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dagit/agda", "max_forks_repo_path": "examples/instance-arguments/13-implicitProofObligations.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dagit/agda", "max_issues_repo_path": "examples/instance-arguments/13-implicitProofObligations.agda", "max_line_length": 65, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "examples/instance-arguments/13-implicitProofObligations.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T07:26:06.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T07:26:06.000Z", "num_tokens": 438, "size": 1124 }
open import Relation.Binary.PropositionalEquality using ( refl ) open import Web.Semantic.DL.ABox.Interp using ( _*_ ; ⌊_⌋ ; ind ) open import Web.Semantic.DL.ABox.Interp.Morphism using ( _,_ ) open import Web.Semantic.DL.ABox.Model using ( _⊨a_ ; on-bnode ; bnodes ; ⊨a-resp-≲ ; ⊨a-resp-≡³ ; _,_ ) open import Web.Semantic.DL.Category.Object using ( Object ; IN ; iface ) open import Web.Semantic.DL.Category.Morphism using ( _⇒_ ; BN ; impl ; _≣_ ; _⊑_ ; _,_ ) open import Web.Semantic.DL.Category.Composition using ( _∙_ ) open import Web.Semantic.DL.Category.Wiring using ( identity ) open import Web.Semantic.DL.Category.Properties.Composition.Lemmas using ( compose-left ; compose-right ; compose-resp-⊨a ; identity-intro ; identity-elim ) open import Web.Semantic.DL.Signature using ( Signature ) open import Web.Semantic.DL.TBox using ( TBox ) open import Web.Semantic.DL.TBox.Interp using ( Δ ; _⊨_≈_ ; ≈-refl ; ≈-sym ) open import Web.Semantic.DL.TBox.Interp.Morphism using ( ≲-refl ) open import Web.Semantic.Util using ( _∘_ ; _⊕_⊕_ ; False ; inode ; bnode ; enode ; left ; right ) module Web.Semantic.DL.Category.Properties.Composition.LeftUnit {Σ : Signature} {S T : TBox Σ} where compose-unit₁ : ∀ {A B : Object S T} (F : A ⇒ B) → (identity A ∙ F ≣ F) compose-unit₁ {A} {B} F = ( idF⊑F , F⊑idF ) where idF⊑F : identity A ∙ F ⊑ F idF⊑F I I⊨STA I⊨idF = (f , I⊨F) where Iˡ⊨id : left * I ⊨a impl (identity A) Iˡ⊨id = compose-left (identity A) F I I⊨idF Iʳ⊨F : right * I ⊨a impl F Iʳ⊨F = compose-right (identity A) F I I⊨idF f : BN F → Δ ⌊ I ⌋ f w = ind I (bnode (enode w)) f✓ : ∀ x → ⌊ I ⌋ ⊨ ind I (right x) ≈ on-bnode f (ind I) x f✓ (inode x) = ≈-sym ⌊ I ⌋ (identity-elim A (left * I) Iˡ⊨id x) f✓ (bnode v) = ≈-refl ⌊ I ⌋ f✓ (enode y) = ≈-refl ⌊ I ⌋ I⊨F : bnodes I f ⊨a impl F I⊨F = ⊨a-resp-≲ (≲-refl ⌊ I ⌋ , f✓) (impl F) Iʳ⊨F F⊑idF : F ⊑ identity A ∙ F F⊑idF I I⊨STA I⊨F = (f , I⊨idF) where f : (False ⊕ IN A ⊕ BN F) → Δ ⌊ I ⌋ f (inode ()) f (bnode x) = ind I (inode x) f (enode v) = ind I (bnode v) Iˡ⊨id : left * bnodes I f ⊨a impl (identity A) Iˡ⊨id = identity-intro A (left * bnodes I f) (λ x → ≈-refl ⌊ I ⌋) Iʳ⊨F : right * bnodes I f ⊨a impl F Iʳ⊨F = ⊨a-resp-≡³ I (on-bnode f (ind I) ∘ right) refl (impl F) I⊨F I⊨idF : bnodes I f ⊨a impl (identity A ∙ F) I⊨idF = compose-resp-⊨a (identity A) F (bnodes I f) Iˡ⊨id Iʳ⊨F
{ "alphanum_fraction": 0.6073022312, "avg_line_length": 37.9230769231, "ext": "agda", "hexsha": "87d4f9d4846d9c88856524059d2396c3ea00f788", "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": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-web-semantic", "max_forks_repo_path": "src/Web/Semantic/DL/Category/Properties/Composition/LeftUnit.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "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": "agda/agda-web-semantic", "max_issues_repo_path": "src/Web/Semantic/DL/Category/Properties/Composition/LeftUnit.agda", "max_line_length": 76, "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/DL/Category/Properties/Composition/LeftUnit.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": 1106, "size": 2465 }
{-# OPTIONS --cubical #-} --no-import-sorts module Test2 where -- open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero) open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Relation.Nullary.Base -- ¬_ open import Cubical.Data.Empty -- ⊥ open import Cubical.Foundations.Logic renaming (¬_ to ¬ᵖ_; ⊥ to ⊥ᵖ) -- open import Cubical.Relation.Binary.Base using (PropRel) -- data ⊥ : Set where -- ¬_ : ∀{ℓ} → Set ℓ → Set ℓ -- ¬ A = A → ⊥ inst-¬ : ∀{ℓ} {A : Set ℓ} → (A → ⊥) → {{a : A }} → ⊥ inst-¬ f {{a}} = f a -- record SquareRootSpace {ℓ ℓ' : Level} : Set (ℓ-suc (ℓ-max ℓ ℓ')) where -- field -- X : Set ℓ -- 0ˣ : X -- _<_ : X → X → Set ℓ' module TestA {ℓ ℓ'} (X : Set ℓ) (0ˣ : X) (_<_ : X → X → Set ℓ') where _≤_ : X → X → Set ℓ' a ≤ b = (b < a) → ⊥ -- ¬(b < a) _≤ᵢ_ : X → X → Set ℓ' a ≤ᵢ b = {{p : b < a}} → ⊥ -- postulate _≤'_ : X → X → Set ℓ' _≤'_ : X → X → Set ℓ' abstract a ≤' b = (b < a) → ⊥ -- field postulate sqrt : (x : X) → {{p : (0ˣ ≤ᵢ x)}} → X sqrt' : (x : X) → {{p : (0ˣ ≤' x)}} → X -- module _ {ℓ ℓ'} (SQS : SquareRootSpace {ℓ} {ℓ'}) where -- open SquareRootSpace SQS test1 : (x : X) → (0ˣ ≤ x) → X test1 x 0≤x = let instance _ = inst-¬ 0≤x in sqrt x -- works! -- test2 : (x y z : X) → (0ˣ ≤ x) → (0ˣ ≤ y) → (0ˣ ≤ z) → X -- test2 x y z 0≤x 0≤y 0≤z = -- let instance 0≤xᵢ : 0ˣ ≤ᵢ x -- 0≤xᵢ = inst-¬ 0≤x -- 0≤yᵢ : 0ˣ ≤ᵢ y -- 0≤yᵢ = inst-¬ 0≤y -- 0≤zᵢ : 0ˣ ≤ᵢ z -- 0≤zᵢ = inst-¬ 0≤z -- -- Goal: X -- -- Have: ⦃ p : 0ˣ ≤ᵢ x ⦄ → X -- in sqrt y -- error! test3 : (x y z : X) → (0ˣ ≤' x) → (0ˣ ≤' y) → (0ˣ ≤' z) → X test3 x y z 0≤x 0≤y 0≤z = let instance _ = 0≤x ; _ = 0≤y ; _ = 0≤z in sqrt' y -- works! -- _p_51 : 0ˣ ≤ᵢ y -- errorFailed to solve the following constraints: -- Resolve instance argument -- _p_51 -- : {ℓ = ℓ₁ : Agda.Primitive.Level} {ℓ' = ℓ'' : Agda.Primitive.Level} -- (X₁ : Set ℓ₁) (0ˣ₁ : X₁) (_<₁_ : X₁ → X₁ → Set ℓ'') (x₁ y₁ z₁ : X₁) -- (0≤x₁ : 0ˣ₁ ≤ x₁) (0≤y₁ : 0ˣ₁ ≤ y₁) (0≤z₁ : 0ˣ₁ ≤ z₁) → -- 0ˣ₁ ≤ᵢ y₁ -- Candidates -- λ ⦃ a ⦄ → z a : ⦃ p : 0ˣ _<_ X ⦄ → ⊥ -- λ ⦃ a ⦄ → 0≤x a : ⦃ p : 0ˣ x X ⦄ → ⊥ -- λ ⦃ a ⦄ → 0≤y a : ⦃ p : 0ˣ y X ⦄ → ⊥ -- Instance arguments with explicit arguments are never considered by -- instance search, so having an instance argument ⦃ p : 0ˣ ≤ x ⦄ has -- no effect. -- when checking that the expression ⦃ p : 0ˣ ≤ x ⦄ → X is a type {- there is an email of Apostolis Xekoukoulotakis from 03.11.17, 11:52 data ⊥ : Set where infix 3 ¬ᵢ_ ¬ᵢ_ : ∀ {ℓ} → Set ℓ → Set ℓ ¬ᵢ P = {{p : P}} → ⊥ infix 3 ¬_ ¬_ : ∀ {ℓ} → Set ℓ → Set ℓ ¬ P = (p : P) → ⊥ -}
{ "alphanum_fraction": 0.475, "avg_line_length": 28.1188118812, "ext": "agda", "hexsha": "76726edc0ad1f6fbe564a59e1dda2d08553be690", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "test/Test2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mchristianl/synthetic-reals", "max_issues_repo_path": "test/Test2.agda", "max_line_length": 85, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "test/Test2.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 1397, "size": 2840 }
{-# OPTIONS --without-K #-} module Lecture2 where import Basics open Basics public -- Definition 2.2.3 define the identity function, and show lambda-abstraction in so doing id : {i : Level} {A : UU i} → A → A id = λ a → a -- can also use plain backslash \ instead of lambda (as it resembles lambda?) -- Definition 2.2.4 comp : {i j k : Level} {A : UU i} {B : UU j} {C : UU k} → (B → C) → ((A → B) → (A → C)) comp = λ g f a → g(f(a)) -- the lambda extends to cover g, f and a _∘_ : {i j k : Level} {A : UU i} {B : UU j} {C : UU k} → (B → C) → ((A → B) → (A → C)) g ∘ f = comp g f data ℕ : U where Nzero : ℕ Nsucc : ℕ → ℕ add : ℕ → ℕ → ℕ add Nzero = id add (Nsucc n) = Nsucc ∘ (add n) -- try some examples, hit C-c C-n (or whatever "compute normal form" is bound to) -- and try entering "add (Nsucc Nzero) (Nsucc (Nsucc Nzero))" -- you should get "Nsucc (Nsucc (Nsucc Nzero))" _+_ : ℕ → ℕ → ℕ n + m = add n m -- Exercise 2.3 const : {i j : Level} (A : UU i) (B : UU j) (b : B) → A → B const A B b x = b -- Exercise 2.4 Pi-swap : {i j k : Level} {A : UU i} {B : UU j} {C : A → (B → UU k)} → ((x : A) (y : B) → C x y) → ((y : B) (x : A) → C x y) Pi-swap f y x = f x y -- Exercise 2.5(a) _**_ : ℕ → (ℕ → ℕ) Nzero ** n = Nzero (Nsucc m) ** n = (m ** n) + n -- Exercise 2.5(b) _^_ : ℕ → (ℕ → ℕ) m ^ Nzero = Nsucc Nzero m ^ (Nsucc n) = m ** (m ^ n) -- Exercise 2.5(c) factorial : ℕ → ℕ factorial Nzero = Nsucc Nzero factorial (Nsucc m) = (Nsucc m) ** (factorial m) -- Exercise 2.6(a) Nmax : ℕ → (ℕ → ℕ) Nmax Nzero n = n Nmax (Nsucc m) Nzero = Nsucc m Nmax (Nsucc m) (Nsucc n) = Nsucc (Nmax m n) -- Exercise 2.6(b) Nmin : ℕ → (ℕ → ℕ) Nmin Nzero n = Nzero Nmin (Nsucc m) Nzero = Nzero Nmin (Nsucc m) (Nsucc n) = Nsucc (Nmin m n) -- Exercise 2.7 -- induction: for any dependent type P over ℕ, define a section of P -- built out of a term in P 0 and a section of P n → P(Nsucc n) ind-N : {i : Level} {P : ℕ → UU i} → P Nzero → ((n : ℕ) → P n → P(Nsucc n)) → ((n : ℕ) → P n) ind-N p0 pS Nzero = p0 ind-N p0 pS (Nsucc n) = pS n (ind-N p0 pS n)
{ "alphanum_fraction": 0.5511695906, "avg_line_length": 27.36, "ext": "agda", "hexsha": "cd19968c3bbaea8505a2ed77d482f5390ad1bfd3", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2018-06-25T15:05:21.000Z", "max_forks_repo_forks_event_min_datetime": "2018-02-22T19:58:46.000Z", "max_forks_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "glangmead/hott_cmu80818", "max_forks_repo_path": "Lecture2.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_issues_repo_issues_event_max_datetime": "2018-03-25T14:44:31.000Z", "max_issues_repo_issues_event_min_datetime": "2018-02-22T21:01:16.000Z", "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "glangmead/hott_cmu80818", "max_issues_repo_path": "Lecture2.agda", "max_line_length": 93, "max_stars_count": 4, "max_stars_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "glangmead/hott_cmu80818", "max_stars_repo_path": "Lecture2.agda", "max_stars_repo_stars_event_max_datetime": "2018-09-04T02:52:25.000Z", "max_stars_repo_stars_event_min_datetime": "2018-05-03T20:32:19.000Z", "num_tokens": 867, "size": 2052 }
-- 2012-03-15, example by Nisse module Issue585-11 where data D₁ : Set where d₁ : D₁ f₁ : D₁ → D₁ → D₁ f₁ x d₁ = x data D₂ : Set where d₂ : D₂ → D₂ postulate P : D₁ → Set f₂ : ∀ {n₁ n₂} → P n₁ → P n₂ → P (f₁ n₁ n₂) mutual f₃ : D₁ → D₂ → D₁ f₃ _ (d₂ _) = _ f₄ : ∀ {n} → P n → (i : D₂) → P (f₃ n i) f₄ p (d₂ i) = f₂ p (f₄ p i) -- This worked until Agda 2.3.0 -- Now, recursive solutions [here: f₃ n (d₂ i) = f₁ n (f₃ n i)] -- are no longer found, since termination is not be guaranteed by the occurs check.
{ "alphanum_fraction": 0.5668549906, "avg_line_length": 18.9642857143, "ext": "agda", "hexsha": "476603ff14a68f851b26e4f06f7f3ad3ba2a661f", "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/Issue585-11.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/Issue585-11.agda", "max_line_length": 83, "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/Issue585-11.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": 249, "size": 531 }
-- Andreas, 2014-11-02 record U : Set where coinductive constructor inn field out : U f : U → U f u = {!u!}
{ "alphanum_fraction": 0.5737704918, "avg_line_length": 12.2, "ext": "agda", "hexsha": "7d4e6571e34e09a7b2e006e303241a12289492f6", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/Issue1339.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/Issue1339.agda", "max_line_length": 22, "max_stars_count": 3, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue1339.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": 46, "size": 122 }
module SafeFlagPrimTrustMe where open import Agda.Builtin.Equality open import Agda.Builtin.TrustMe
{ "alphanum_fraction": 0.8613861386, "avg_line_length": 20.2, "ext": "agda", "hexsha": "694748867df72877104d8d5c7a74d7f114e53ede", "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": "test/Fail/SafeFlagPrimTrustMe.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": "test/Fail/SafeFlagPrimTrustMe.agda", "max_line_length": 33, "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": "test/Fail/SafeFlagPrimTrustMe.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 27, "size": 101 }
open import Agda.Builtin.Bool open import Issue4166.Import {b = true} as A′ it : ⦃ Bool ⦄ → Bool it ⦃ b ⦄ = b b : Bool b = it
{ "alphanum_fraction": 0.6153846154, "avg_line_length": 11.8181818182, "ext": "agda", "hexsha": "b885fac78cf2e40a63f5626fc1099ef16fcae473", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Succeed/Issue4166.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Succeed/Issue4166.agda", "max_line_length": 45, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Succeed/Issue4166.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": 55, "size": 130 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use -- Data.List.Relation.Binary.Pointwise directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Relation.Pointwise where open import Data.List.Relation.Binary.Pointwise public {-# WARNING_ON_IMPORT "Data.List.Relation.Pointwise was deprecated in v1.0. Use Data.List.Relation.Binary.Pointwise instead." #-}
{ "alphanum_fraction": 0.5524344569, "avg_line_length": 29.6666666667, "ext": "agda", "hexsha": "7dd4e63d0c4d670c883b51c4d273fa4bd989d634", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/List/Relation/Pointwise.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/List/Relation/Pointwise.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/List/Relation/Pointwise.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": 93, "size": 534 }
module Thesis.SIRelBigStep.Syntax where open import Data.Nat open import Thesis.SIRelBigStep.Types public data Primitive : (τ : Type) → Set where succ : Primitive (nat ⇒ nat) add : Primitive (pair nat nat ⇒ nat) data Const : (τ : Type) → Set where lit : (n : ℕ) → Const nat data Term (Γ : Context) (τ : Type) : Set -- Source values data SVal (Γ : Context) : (τ : Type) → Set where var : ∀ {τ} → (x : Var Γ τ) → SVal Γ τ abs : ∀ {σ τ} (t : Term (σ • Γ) τ) → SVal Γ (σ ⇒ τ) cons : ∀ {τ1 τ2} (sv1 : SVal Γ τ1) (sv2 : SVal Γ τ2) → SVal Γ (pair τ1 τ2) const : ∀ {τ} → (c : Const τ) → SVal Γ τ data Term (Γ : Context) (τ : Type) where val : SVal Γ τ → Term Γ τ primapp : ∀ {σ} (p : Primitive (σ ⇒ τ)) → (sv : SVal Γ σ) → Term Γ τ -- we use de Bruijn indices, so we don't need binding occurrences. app : ∀ {σ} (vs : SVal Γ (σ ⇒ τ)) → (vt : SVal Γ σ) → Term Γ τ lett : ∀ {σ} (s : Term Γ σ) → (t : Term (σ • Γ) τ) → Term Γ τ
{ "alphanum_fraction": 0.525540275, "avg_line_length": 22.1304347826, "ext": "agda", "hexsha": "e9a6abac0d47520264b046e37fd636acdeb9ccce", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_path": "Thesis/SIRelBigStep/Syntax.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_path": "Thesis/SIRelBigStep/Syntax.agda", "max_line_length": 68, "max_stars_count": 10, "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_path": "Thesis/SIRelBigStep/Syntax.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "num_tokens": 400, "size": 1018 }
module Proof where open import Prelude open import Lambda open import Subst open import Trans open import Reduction import Chain open module C = Chain _≤_ (\x -> refl-≤) (\x y z -> trans-≤) renaming (_===_by_ to _<≤>_by_) data SN {Γ : Ctx}{τ : Type}(t : Term Γ τ) : Set where bound : (n : Nat) -> ({u : Term Γ τ}(r : t ⟶β* u) -> length r ≤ n) -> SN t SNˢ : forall {Γ Δ} -> Terms Γ Δ -> Set SNˢ ts = All² SN ts -- Let's prove a simple lemma lem-SN⟶β : {Γ : Ctx}{τ : Type}{t u : Term Γ τ} -> SN t -> t ⟶β* u -> SN u lem-SN⟶β {Γ}{τ}{t}{u}(bound n cap) r = bound n \r' -> chain> length r' <≤> length r + length r' by lem-≤+L (length r) <≤> length (r ▹◃ r') by refl-≤' (lem-length▹◃ r r') <≤> n by cap (r ▹◃ r') qed lem-SN-map : {Γ Δ : Ctx}{σ τ : Type} (tm : Term Γ σ -> Term Δ τ) -> (f : {t u : Term Γ σ} -> t ⟶β u -> tm t ⟶β tm u) {t : Term Γ σ} -> SN (tm t) -> SN t lem-SN-map tm f (bound n p) = bound n \r -> chain> length r <≤> length {R = _⟶β_} (map tm f r) by refl-≤' (lem-length-map tm f r) <≤> n by p (map tm f r) qed lem-SN•L : {Γ : Ctx}{σ τ : Type}{t : Term Γ (σ ⟶ τ)}{u : Term Γ σ} -> SN (t • u) -> SN t lem-SN•L {u = u} = lem-SN-map (\v -> v • u) •⟶L lem-SN↑ : {Γ : Ctx}(Δ : Ctx){σ : Type}{t : Term Γ σ} -> SN (t ↑ Δ) -> SN t lem-SN↑ Δ = lem-SN-map (\v -> v ↑ Δ) (↑⟶β Δ) lem-SN-x : {Γ Δ : Ctx}{σ : Type}(x : Var Γ (Δ ⇒ σ)) {ts : Terms Γ Δ} -> SNˢ ts -> SN (var x •ˢ ts) lem-SN-x x ∅² = bound zero red-var where red-var : forall {u} -> (r : var x ⟶β* u) -> length r ≤ 0 red-var () lem-SN-x x (_◄²_ {x = t}{xs = ts} snts snt) = {! !} where sn-xts : SN (var x •ˢ ts) sn-xts = lem-SN-x x snts infix 30 ⟦_⟧ ∋_ ⟦_⟧ ∋_ : (τ : Type){Γ : Ctx} -> Term Γ τ -> Set ⟦ ι ⟧ ∋ t = SN t ⟦ σ ⟶ τ ⟧ ∋ t = forall {Δ}(u : Term (_ ++ Δ) σ) -> ⟦ σ ⟧ ∋ u -> ⟦ τ ⟧ ∋ t ↑ Δ • u mutual lem-⟦⟧⊆SN : (σ : Type){Γ : Ctx}{t : Term Γ σ} -> ⟦ σ ⟧ ∋ t -> SN t lem-⟦⟧⊆SN ι okt = okt lem-⟦⟧⊆SN (σ ⟶ τ) {Γ}{t} okt = lem-SN↑ (ε , σ) sn-t↑ where ih : {Δ : Ctx}{u : Term Δ τ} -> ⟦ τ ⟧ ∋ u -> SN u ih = lem-⟦⟧⊆SN τ sn• : (Δ : Ctx)(u : Term (Γ ++ Δ) σ) -> ⟦ σ ⟧ ∋ u -> SN (t ↑ Δ • u) sn• Δ u h = ih (okt {Δ} u h) sn-t↑ : SN (wk t) sn-t↑ = lem-SN•L (sn• (ε , σ) vz (lem-⟦⟧ˣ σ vzero ∅²)) lem-⟦⟧ˣ : (σ : Type){Γ Δ : Ctx}(x : Var Γ (Δ ⇒ σ)){ts : Terms Γ Δ} -> SNˢ ts -> ⟦ σ ⟧ ∋ var x •ˢ ts lem-⟦⟧ˣ ι x snts = lem-SN-x x snts lem-⟦⟧ˣ (σ ⟶ τ) {Γ}{Δ} x {ts} snts = \u oku -> {! !} where snts↑ : (Δ : Ctx) -> SNˢ (ts ↑ˢ Δ) snts↑ Δ = {! !} rem : (Δ : Ctx)(u : Term (Γ ++ Δ) σ) -> ⟦ σ ⟧ ∋ u -> ⟦ τ ⟧ ∋ var (x ↑ˣ Δ) •ˢ ts ↑ˢ Δ • u rem Δ u oku = lem-⟦⟧ˣ τ (x ↑ˣ Δ) (snts↑ Δ ◄² lem-⟦⟧⊆SN σ oku) lem-⟦⟧subst : {Γ Δ : Ctx}{τ : Type}(σ : Type) {t : Term (Γ , τ) (Δ ⇒ σ)}{u : Term Γ τ}{vs : Terms Γ Δ} -> ⟦ σ ⟧ ∋ (t / [ u ]) •ˢ vs -> ⟦ σ ⟧ ∋ (ƛ t) • u •ˢ vs lem-⟦⟧subst ι h = {!h !} lem-⟦⟧subst (σ₁ ⟶ σ₂) h = {! !}
{ "alphanum_fraction": 0.414258794, "avg_line_length": 31.2156862745, "ext": "agda", "hexsha": "6901fe56a4b3876d3e0c0d61c02f73a4b70a9e4c", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/tait/Proof.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/tait/Proof.agda", "max_line_length": 73, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/outdated-and-incorrect/tait/Proof.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 1523, "size": 3184 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Profunctor where open import Level hiding (lift) open import Categories.Category open import Categories.Agda open import Categories.Bifunctor using (Functor; Bifunctor; _∘_) open import Categories.Functor.Hom open import Categories.Lan open import Categories.Yoneda Profunctor : ∀ {o ℓ e} {o′ ℓ′ e′} → Category o ℓ e → Category o′ ℓ′ e′ → Set _ Profunctor {ℓ = ℓ} {e} {ℓ′ = ℓ′} {e′} C D = Bifunctor (Category.op D) C (ISetoids (ℓ ⊔ ℓ′) (e ⊔ e′)) id : ∀ {o ℓ e} → {C : Category o ℓ e} → Profunctor C C id {C = C} = Hom[ C ][-,-] {- _∘_ : ∀ {o ℓ e} {o′ ℓ′ e′} {o′′ ℓ′′ e′′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {E : Category o′′ ℓ′′ e′′} → Profunctor D E → Profunctor C D → Profunctor C E F ∘ G = {!!} -}
{ "alphanum_fraction": 0.618251928, "avg_line_length": 33.8260869565, "ext": "agda", "hexsha": "7a75c3c4c6a4c5be43831b63186fc173bfc15b08", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Profunctor.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Profunctor.agda", "max_line_length": 113, "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/Profunctor.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": 315, "size": 778 }
{-# OPTIONS --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Properties.Reduction {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.RedSteps open import Definition.Typed.Weakening open import Definition.LogicalRelation open import Definition.LogicalRelation.Properties.Reflexivity open import Definition.LogicalRelation.Properties.Transitivity open import Definition.LogicalRelation.Properties.Symmetry open import Definition.LogicalRelation.Properties.Escape open import Definition.LogicalRelation.Properties.Conversion open import Tools.Product open import Tools.Empty import Tools.PropositionalEquality as PE import Data.Fin as Fin import Data.Nat as Nat -- Weak head expansion of reducible types. redSubst* : ∀ {A B r l Γ} → Γ ⊢ A ⇒* B ^ r → Γ ⊩⟨ l ⟩ B ^ r → ∃ λ ([A] : Γ ⊩⟨ l ⟩ A ^ r) → Γ ⊩⟨ l ⟩ A ≡ B ^ r / [A] redSubst* {A = A} D (Uᵣ′ B .(next l′) rU l′ l< PE.refl [[ ⊢A , ⊢B , D' ]]) = let ⊢A = redFirst* D in Uᵣ′ A (next l′) rU l′ l< PE.refl [[ ⊢A , ⊢B , D ⇨* D' ]] , D' redSubst* D (ℕᵣ [[ ⊢B , ⊢ℕ , D′ ]]) = let ⊢A = redFirst* D in ℕᵣ ([[ ⊢A , ⊢ℕ , D ⇨* D′ ]]) , D′ redSubst* D (Emptyᵣ [[ ⊢B , ⊢Empty , D′ ]]) = let ⊢A = redFirst* D in Emptyᵣ ([[ ⊢A , ⊢Empty , D ⇨* D′ ]]) , D′ redSubst* D (ne′ K [[ ⊢B , ⊢K , D′ ]] neK K≡K) = let ⊢A = redFirst* D in (ne′ K [[ ⊢A , ⊢K , D ⇨* D′ ]] neK K≡K) , (ne₌ _ [[ ⊢B , ⊢K , D′ ]] neK K≡K) redSubst* D (Πᵣ′ rF lF lG lF≤ lG≤ F G [[ ⊢B , ⊢ΠFG , D′ ]] ⊢F ⊢G A≡A [F] [G] G-ext) = let ⊢A = redFirst* D in (Πᵣ′ rF lF lG lF≤ lG≤ F G [[ ⊢A , ⊢ΠFG , D ⇨* D′ ]] ⊢F ⊢G A≡A [F] [G] G-ext) , (Π₌ _ _ D′ A≡A (λ ρ ⊢Δ → reflEq ([F] ρ ⊢Δ)) (λ ρ ⊢Δ [a] → reflEq ([G] ρ ⊢Δ [a]))) redSubst* D (∃ᵣ′ F G [[ ⊢B , ⊢ΠFG , D′ ]] ⊢F ⊢G A≡A [F] [G] G-ext) = let ⊢A = redFirst* D in (∃ᵣ′ F G [[ ⊢A , ⊢ΠFG , D ⇨* D′ ]] ⊢F ⊢G A≡A [F] [G] G-ext) , (∃₌ _ _ D′ A≡A (λ ρ ⊢Δ → reflEq ([F] ρ ⊢Δ)) (λ ρ ⊢Δ [a] → reflEq ([G] ρ ⊢Δ [a]))) redSubst* {l = ι ¹} D (emb l< X) with redSubst* D X redSubst* {l = ι ¹} D (emb l< X) | y , y₁ = emb l< y , y₁ redSubst* {l = ∞} D (emb l< X) with redSubst* D X redSubst* {l = ∞} D (emb ∞< X) | y , y₁ = emb {l′ = ι ¹} ∞< y , y₁ redSubst*Term⁰ : ∀ {A t u ll Γ} → let l = ι ⁰ in Γ ⊢ t ⇒* u ∷ A ^ ll → ([A] : Γ ⊩⟨ l ⟩ A ^ [ ! , ll ]) → Γ ⊩⟨ l ⟩ u ∷ A ^ [ ! , ll ] / [A] → Γ ⊩⟨ l ⟩ t ∷ A ^ [ ! , ll ] / [A] × Γ ⊩⟨ l ⟩ t ≡ u ∷ A ^ [ ! , ll ] / [A] redSubst*Term⁰ t⇒u (ℕᵣ D) (ℕₜ n [[ ⊢u , ⊢n , d ]] n≡n prop) = let A≡ℕ = subset* (red D) ⊢t = conv (redFirst*Term t⇒u) A≡ℕ t⇒u′ = conv* t⇒u A≡ℕ in ℕₜ n [[ ⊢t , ⊢n , t⇒u′ ⇨∷* d ]] n≡n prop , ℕₜ₌ n n [[ ⊢t , ⊢n , t⇒u′ ⇨∷* d ]] [[ ⊢u , ⊢n , d ]] n≡n (reflNatural-prop prop) redSubst*Term⁰ t⇒u (ne′ K D neK K≡K) (neₜ k [[ ⊢t , ⊢u , d ]] (neNfₜ neK₁ ⊢k k≡k)) = let A≡K = subset* (red D) [d] = [[ ⊢t , ⊢u , d ]] [d′] = [[ conv (redFirst*Term t⇒u) A≡K , ⊢u , conv* t⇒u A≡K ⇨∷* d ]] in neₜ k [d′] (neNfₜ neK₁ ⊢k k≡k) , neₜ₌ k k [d′] [d] (neNfₜ₌ neK₁ neK₁ k≡k) redSubst*Term⁰ {A} {t} {u} {l} {Γ} t⇒u (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πₜ f [[ ⊢t , ⊢u , d ]] funcF f≡f [f] [f]₁) = let A≡ΠFG = subset* (red D) t⇒u′ = conv* t⇒u A≡ΠFG [d] = [[ ⊢t , ⊢u , d ]] [d′] = [[ conv (redFirst*Term t⇒u) A≡ΠFG , ⊢u , conv* t⇒u A≡ΠFG ⇨∷* d ]] in Πₜ f [d′] funcF f≡f [f] [f]₁ , Πₜ₌ f f [d′] [d] funcF funcF f≡f (Πₜ f [d′] funcF f≡f [f] [f]₁) (Πₜ f [d] funcF f≡f [f] [f]₁) (λ [ρ] ⊢Δ [a] → reflEqTerm ([G] [ρ] ⊢Δ [a]) ([f]₁ [ρ] ⊢Δ [a])) -- Weak head expansion of reducible terms. redSubst*Term : ∀ {A t u l ll Γ} → Γ ⊢ t ⇒* u ∷ A ^ ll → ([A] : Γ ⊩⟨ l ⟩ A ^ [ ! , ll ]) → Γ ⊩⟨ l ⟩ u ∷ A ^ [ ! , ll ] / [A] → Γ ⊩⟨ l ⟩ t ∷ A ^ [ ! , ll ] / [A] × Γ ⊩⟨ l ⟩ t ≡ u ∷ A ^ [ ! , ll ] / [A] redSubst*Term {t = t} {l = ι ¹} {Γ = Γ} t⇒u (Uᵣ′ A .(next ⁰) rU ⁰ l< PE.refl D) (Uₜ K [[ ⊢u , ⊢K , d ]] typeA A≡A [u]) = let A≡U = subset* (red D) ⊢t = conv (redFirst*Term t⇒u) A≡U t⇒u′ = conv* t⇒u A≡U [t] = λ {ρ} {Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) ⊢Δ → proj₁ (redSubst* {l = ι ⁰} (wkRed* [ρ] ⊢Δ (univ* t⇒u′)) ([u] [ρ] ⊢Δ)) [t≡u] = λ {ρ} {Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) ⊢Δ → proj₂ (redSubst* {l = ι ⁰} (wkRed* [ρ] ⊢Δ (univ* t⇒u′)) ([u] [ρ] ⊢Δ)) [[t]] = Uₜ K [[ ⊢t , ⊢K , t⇒u′ ⇨∷* d ]] typeA A≡A [t] in ([[t]] , Uₜ₌ [[t]] (Uₜ K [[ ⊢u , ⊢K , d ]] typeA A≡A [u]) A≡A [t≡u]) redSubst*Term {t = t} {l = ∞} {Γ = Γ} t⇒u (Uᵣ′ A .(next ¹) rU ¹ l< PE.refl D) (Uₜ K [[ ⊢u , ⊢K , d ]] typeA A≡A [u]) = let A≡U = subset* (red D) ⊢t = conv (redFirst*Term t⇒u) A≡U t⇒u′ = conv* t⇒u A≡U [t] = λ {ρ} {Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) ⊢Δ → proj₁ (redSubst* {l = ι ¹} (wkRed* [ρ] ⊢Δ (univ* t⇒u′)) ([u] [ρ] ⊢Δ)) [t≡u] = λ {ρ} {Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) ⊢Δ → proj₂ (redSubst* {l = ι ¹} (wkRed* [ρ] ⊢Δ (univ* t⇒u′)) ([u] [ρ] ⊢Δ)) [[t]] = Uₜ K [[ ⊢t , ⊢K , t⇒u′ ⇨∷* d ]] typeA A≡A [t] in ([[t]] , Uₜ₌ [[t]] (Uₜ K [[ ⊢u , ⊢K , d ]] typeA A≡A [u]) A≡A [t≡u]) redSubst*Term t⇒u (ℕᵣ D) (ℕₜ n [[ ⊢u , ⊢n , d ]] n≡n prop) = let A≡ℕ = subset* (red D) ⊢t = conv (redFirst*Term t⇒u) A≡ℕ t⇒u′ = conv* t⇒u A≡ℕ in ℕₜ n [[ ⊢t , ⊢n , t⇒u′ ⇨∷* d ]] n≡n prop , ℕₜ₌ n n [[ ⊢t , ⊢n , t⇒u′ ⇨∷* d ]] [[ ⊢u , ⊢n , d ]] n≡n (reflNatural-prop prop) redSubst*Term t⇒u (ne′ K D neK K≡K) (neₜ k [[ ⊢t , ⊢u , d ]] (neNfₜ neK₁ ⊢k k≡k)) = let A≡K = subset* (red D) [d] = [[ ⊢t , ⊢u , d ]] [d′] = [[ conv (redFirst*Term t⇒u) A≡K , ⊢u , conv* t⇒u A≡K ⇨∷* d ]] in neₜ k [d′] (neNfₜ neK₁ ⊢k k≡k) , neₜ₌ k k [d′] [d] (neNfₜ₌ neK₁ neK₁ k≡k) redSubst*Term {A} {t} {u} {l} {Γ} t⇒u (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πₜ f [[ ⊢t , ⊢u , d ]] funcF f≡f [f] [f]₁) = let A≡ΠFG = subset* (red D) t⇒u′ = conv* t⇒u A≡ΠFG [d] = [[ ⊢t , ⊢u , d ]] [d′] = [[ conv (redFirst*Term t⇒u) A≡ΠFG , ⊢u , conv* t⇒u A≡ΠFG ⇨∷* d ]] in Πₜ f [d′] funcF f≡f [f] [f]₁ , Πₜ₌ f f [d′] [d] funcF funcF f≡f (Πₜ f [d′] funcF f≡f [f] [f]₁) (Πₜ f [d] funcF f≡f [f] [f]₁) (λ [ρ] ⊢Δ [a] → reflEqTerm ([G] [ρ] ⊢Δ [a]) ([f]₁ [ρ] ⊢Δ [a])) redSubst*Term {l = ι ¹} D (emb l< X) [u] = redSubst*Term D X [u] redSubst*Term {l = ∞} D (emb l< X) [u] = redSubst*Term D X [u] -- Weak head expansion of reducible types with single reduction step. redSubst : ∀ {A B r l Γ} → Γ ⊢ A ⇒ B ^ r → Γ ⊩⟨ l ⟩ B ^ r → ∃ λ ([A] : Γ ⊩⟨ l ⟩ A ^ r) → Γ ⊩⟨ l ⟩ A ≡ B ^ r / [A] redSubst A⇒B [B] = redSubst* (A⇒B ⇨ id (escape [B])) [B] -- Weak head expansion of reducible terms with single reduction step. redSubstTerm : ∀ {A t u l ll Γ} → Γ ⊢ t ⇒ u ∷ A ^ ll → ([A] : Γ ⊩⟨ l ⟩ A ^ [ ! , ll ]) → Γ ⊩⟨ l ⟩ u ∷ A ^ [ ! , ll ] / [A] → Γ ⊩⟨ l ⟩ t ∷ A ^ [ ! , ll ] / [A] × Γ ⊩⟨ l ⟩ t ≡ u ∷ A ^ [ ! , ll ] / [A] redSubstTerm t⇒u [A] [u] = redSubst*Term (t⇒u ⇨ id (escapeTerm [A] [u])) [A] [u] -- Equalities redSubst*EqTerm : ∀ {A B t t′ u u′ l ll Γ} → Γ ⊢ t ⇒* t′ ∷ A ^ ll → Γ ⊢ u ⇒* u′ ∷ B ^ ll → ([A] : Γ ⊩⟨ l ⟩ A ^ [ ! , ll ]) → ([B] : Γ ⊩⟨ l ⟩ B ^ [ ! , ll ]) → Γ ⊩⟨ l ⟩ A ≡ B ^ [ ! , ll ] / [A] → Γ ⊩⟨ l ⟩ t′ ∷ A ^ [ ! , ll ] / [A] → Γ ⊩⟨ l ⟩ u′ ∷ B ^ [ ! , ll ] / [B] → Γ ⊩⟨ l ⟩ t′ ≡ u′ ∷ A ^ [ ! , ll ] / [A] → Γ ⊩⟨ l ⟩ t ≡ u ∷ A ^ [ ! , ll ] / [A] redSubst*EqTerm D D′ [A] [B] [A≡B] [t′] [u′] [t′≡u′] = let [t≡t′] = proj₂ (redSubst*Term D [A] [t′]) [u≡u′:B] = proj₂ (redSubst*Term D′ [B] [u′]) [u≡u′] = convEqTerm₂ [A] [B] [A≡B] [u≡u′:B] in transEqTerm [A] [t≡t′] (transEqTerm [A] [t′≡u′] (symEqTerm [A] [u≡u′]))
{ "alphanum_fraction": 0.425688302, "avg_line_length": 44.843575419, "ext": "agda", "hexsha": "2afd5bfe2d3ac78014ac4a8bb900cc2ee8dd077f", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Properties/Reduction.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Properties/Reduction.agda", "max_line_length": 120, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Properties/Reduction.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z", "max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z", "num_tokens": 4376, "size": 8027 }
open import Data.String using ( String ) open import Data.List.Primitive using ( #List ) open import Data.Maybe.Primitive using ( #Maybe ) open import Web.URI.Port.Primitive using ( Port? ) open import Web.URI.Scheme.Primitive using ( Scheme? ) module Web.URI.Primitive where {-# IMPORT Data.Maybe #-} {-# IMPORT Web.URI.AgdaFFI #-} data #URI : Set where #abs : Scheme? → String → Port? → (#List String) → (#Maybe String) → #URI #rel : (#List String) → (#Maybe String) → #URI {-# COMPILED_DATA #URI Web.URI.AgdaFFI.URI Web.URI.AgdaFFI.Abs Web.URI.AgdaFFI.Rel #-} postulate #toString : #URI → String {-# COMPILED #toString Web.URI.AgdaFFI.toString #-} postulate #fromString : String → (#Maybe #URI) {-# COMPILED #fromString Web.URI.AgdaFFI.fromString #-}
{ "alphanum_fraction": 0.6968503937, "avg_line_length": 36.2857142857, "ext": "agda", "hexsha": "b26e5f5e28800b862f45766822ff62a1876f5bd4", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:37:59.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:37:59.000Z", "max_forks_repo_head_hexsha": "8ced22124dbe12fa820699bb362247a96d592c03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-web-uri", "max_forks_repo_path": "src/Web/URI/Primitive.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8ced22124dbe12fa820699bb362247a96d592c03", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-web-uri", "max_issues_repo_path": "src/Web/URI/Primitive.agda", "max_line_length": 86, "max_stars_count": 1, "max_stars_repo_head_hexsha": "8ced22124dbe12fa820699bb362247a96d592c03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-web-uri", "max_stars_repo_path": "src/Web/URI/Primitive.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-23T04:56:25.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-23T04:56:25.000Z", "num_tokens": 205, "size": 762 }
open import Oscar.Prelude open import Oscar.Class.IsPrefunctor open import Oscar.Class.Smap open import Oscar.Class.Surjection open import Oscar.Class.Transitivity module Oscar.Class.Prefunctor where record Prefunctor 𝔬₁ 𝔯₁ ℓ₁ 𝔬₂ 𝔯₂ ℓ₂ : Ø ↑̂ (𝔬₁ ∙̂ 𝔯₁ ∙̂ ℓ₁ ∙̂ 𝔬₂ ∙̂ 𝔯₂ ∙̂ ℓ₂) where constructor ∁ field {𝔒₁} : Ø 𝔬₁ _∼₁_ : 𝔒₁ → 𝔒₁ → Ø 𝔯₁ _∼̇₁_ : ∀ {x y} → x ∼₁ y → x ∼₁ y → Ø ℓ₁ _↦₁_ : Transitivity.type _∼₁_ {𝔒₂} : Ø 𝔬₂ _∼₂_ : 𝔒₂ → 𝔒₂ → Ø 𝔯₂ _∼̇₂_ : ∀ {x y} → x ∼₂ y → x ∼₂ y → Ø ℓ₂ _↦₂_ : Transitivity.type _∼₂_ {μ} : Surjection.type 𝔒₁ 𝔒₂ prefunctor-smap : Smap.type _∼₁_ _∼₂_ μ μ ⦃ `IsPrefunctor ⦄ : IsPrefunctor _∼₁_ _∼̇₁_ _↦₁_ _∼₂_ _∼̇₂_ _↦₂_ prefunctor-smap
{ "alphanum_fraction": 0.6145251397, "avg_line_length": 29.8333333333, "ext": "agda", "hexsha": "37ea5fc731b32ac0084d4312e445eb2f1f3bff6a", "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/Prefunctor.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/Prefunctor.agda", "max_line_length": 84, "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/Prefunctor.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 397, "size": 716 }
module Negative5 where data Funny (A : Set) : Set where funny : A -> Funny (Funny A -> A) -> Funny A
{ "alphanum_fraction": 0.619047619, "avg_line_length": 17.5, "ext": "agda", "hexsha": "d2590ca075f0fa9293d1dd38dfb735e8ca173362", "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/Negative5.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/Negative5.agda", "max_line_length": 46, "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/Negative5.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 32, "size": 105 }
module _ where -- Check that previous clauses reduce in later ones open import Agda.Builtin.Nat hiding (_==_) record Σ (A : Set) (B : A → Set) : Set where field fst : A snd : B fst open Σ postulate T : Nat → Set mkT : ∀ n → T n t5 : Σ Nat T fst t5 = 5 snd t5 = mkT 5 -- Also with instance projections -- open import Agda.Builtin.Bool open import Agda.Builtin.Equality record Eq (A : Set) : Set where field _==_ : A → A → Bool reflexive : ∀ x → true ≡ (x == x) open Eq {{...}} instance EqNat : Eq Nat _==_ {{EqNat}} zero zero = true _==_ {{EqNat}} zero (suc y) = false _==_ {{EqNat}} (suc x) zero = false _==_ {{EqNat}} (suc x) (suc y) = x == y reflexive {{EqNat}} zero = refl reflexive {{EqNat}} (suc x) rewrite reflexive x = refl
{ "alphanum_fraction": 0.5863808323, "avg_line_length": 18.4418604651, "ext": "agda", "hexsha": "6a37635b887660b86318ff8f7d0f7c5ea38561e8", "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/ClauseEval.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/ClauseEval.agda", "max_line_length": 56, "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/ClauseEval.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": 290, "size": 793 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Natural numbers represented in binary. ------------------------------------------------------------------------ -- This module aims to create an alternative formulation of ℕ that is -- still reasonably computationally efficient without having to call out -- to Haskell. {-# OPTIONS --without-K --safe #-} module Data.Nat.Binary.Base where open import Algebra.Core using (Op₂) open import Data.Nat.Base as ℕ using (ℕ) open import Data.Sum.Base using (_⊎_) open import Function using (_on_) open import Level using (0ℓ) open import Relation.Binary using (Rel) open import Relation.Binary.PropositionalEquality using (_≡_) open import Relation.Nullary using (¬_) ------------------------------------------------------------------------ -- Definition data ℕᵇ : Set where zero : ℕᵇ 2[1+_] : ℕᵇ → ℕᵇ -- n → 2*(1+n) = nonzero even numbers 1+[2_] : ℕᵇ → ℕᵇ -- n → 1 + 2*n = odd numbers ------------------------------------------------------------------------ -- Ordering relations infix 4 _<_ _>_ _≤_ _≮_ _≯_ _≰_ _≱_ data _<_ : Rel ℕᵇ 0ℓ where 0<even : ∀ {x} → zero < 2[1+ x ] 0<odd : ∀ {x} → zero < 1+[2 x ] even<even : ∀ {x y} → x < y → 2[1+ x ] < 2[1+ y ] even<odd : ∀ {x y} → x < y → 2[1+ x ] < 1+[2 y ] odd<even : ∀ {x y} → x < y ⊎ x ≡ y → 1+[2 x ] < 2[1+ y ] odd<odd : ∀ {x y} → x < y → 1+[2 x ] < 1+[2 y ] -- In these constructors "even" stands for nonzero even. _>_ : Rel ℕᵇ 0ℓ x > y = y < x _≤_ : Rel ℕᵇ 0ℓ x ≤ y = x < y ⊎ x ≡ y _≥_ : Rel ℕᵇ 0ℓ x ≥ y = y ≤ x _≮_ : Rel ℕᵇ 0ℓ x ≮ y = ¬ (x < y) _≯_ : Rel ℕᵇ 0ℓ x ≯ y = ¬ (x > y) _≰_ : Rel ℕᵇ 0ℓ x ≰ y = ¬ (x ≤ y) _≱_ : Rel ℕᵇ 0ℓ x ≱ y = ¬ (x ≥ y) ------------------------------------------------------------------------ -- Basic operations double : ℕᵇ → ℕᵇ double zero = zero double 2[1+ x ] = 2[1+ 1+[2 x ] ] double 1+[2 x ] = 2[1+ (double x) ] suc : ℕᵇ → ℕᵇ suc zero = 1+[2 zero ] suc 2[1+ x ] = 1+[2 (suc x) ] suc 1+[2 x ] = 2[1+ x ] pred : ℕᵇ → ℕᵇ pred zero = zero pred 2[1+ x ] = 1+[2 x ] pred 1+[2 x ] = double x ------------------------------------------------------------------------ -- Addition, multiplication and certain related functions infixl 6 _+_ infixl 7 _*_ _+_ : Op₂ ℕᵇ zero + y = y x + zero = x 2[1+ x ] + 2[1+ y ] = 2[1+ suc (x + y) ] 2[1+ x ] + 1+[2 y ] = suc 2[1+ (x + y) ] 1+[2 x ] + 2[1+ y ] = suc 2[1+ (x + y) ] 1+[2 x ] + 1+[2 y ] = suc 1+[2 (x + y) ] _*_ : Op₂ ℕᵇ zero * _ = zero _ * zero = zero 2[1+ x ] * 2[1+ y ] = double 2[1+ x + (y + x * y) ] 2[1+ x ] * 1+[2 y ] = 2[1+ x + y * 2[1+ x ] ] 1+[2 x ] * 2[1+ y ] = 2[1+ y + x * 2[1+ y ] ] 1+[2 x ] * 1+[2 y ] = 1+[2 x + y * 1+[2 x ] ] ------------------------------------------------------------------------ -- Conversion between ℕᵇ and ℕ toℕ : ℕᵇ → ℕ toℕ zero = 0 toℕ 2[1+ x ] = 2 ℕ.* (ℕ.suc (toℕ x)) toℕ 1+[2 x ] = ℕ.suc (2 ℕ.* (toℕ x)) -- Costs O(n), could be improved using `_/_` and `_%_` fromℕ : ℕ → ℕᵇ fromℕ 0 = zero fromℕ (ℕ.suc n) = suc (fromℕ n) -- An alternative ordering lifted from ℕ infix 4 _<ℕ_ _<ℕ_ : Rel ℕᵇ 0ℓ _<ℕ_ = ℕ._<_ on toℕ ------------------------------------------------------------------------ -- Other functions -- Useful in some termination proofs. size : ℕᵇ → ℕ size zero = 0 size 2[1+ x ] = ℕ.suc (size x) size 1+[2 x ] = ℕ.suc (size x) ------------------------------------------------------------------------ -- Constants 0ᵇ = zero 1ᵇ = suc 0ᵇ 2ᵇ = suc 1ᵇ 3ᵇ = suc 2ᵇ 4ᵇ = suc 3ᵇ 5ᵇ = suc 4ᵇ 6ᵇ = suc 5ᵇ 7ᵇ = suc 6ᵇ 8ᵇ = suc 7ᵇ 9ᵇ = suc 8ᵇ
{ "alphanum_fraction": 0.4328886469, "avg_line_length": 24.6510067114, "ext": "agda", "hexsha": "63ff8ae9d6919efd8810f82e8a3244a20d426196", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/Nat/Binary/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Nat/Binary/Base.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Nat/Binary/Base.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": 1487, "size": 3673 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Convenient syntax for reasoning with a setoid ------------------------------------------------------------------------ -- Example use: -- n*0≡0 : ∀ n → n * 0 ≡ 0 -- n*0≡0 zero = refl -- n*0≡0 (suc n) = begin -- suc n * 0 ≈⟨ refl ⟩ -- n * 0 + 0 ≈⟨ ... ⟩ -- n * 0 ≈⟨ n*0≡0 n ⟩ -- 0 ∎ -- Module `≡-Reasoning` in `Relation.Binary.PropositionalEquality` -- is recommended for equational reasoning when the underlying equality is -- `_≡_`. {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Relation.Binary.Reasoning.Setoid {s₁ s₂} (S : Setoid s₁ s₂) where open Setoid S ------------------------------------------------------------------------ -- Publicly re-export base contents open import Relation.Binary.Reasoning.Base.Single _≈_ refl trans public renaming (_∼⟨_⟩_ to _≈⟨_⟩_) infixr 2 _≈˘⟨_⟩_ _≈˘⟨_⟩_ : ∀ x {y z} → y ≈ x → y IsRelatedTo z → x IsRelatedTo z x ≈˘⟨ x≈y ⟩ y∼z = x ≈⟨ sym x≈y ⟩ y∼z
{ "alphanum_fraction": 0.4796208531, "avg_line_length": 27.0512820513, "ext": "agda", "hexsha": "931a1f79a8960510d8e0c376b39d5da22de67821", "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/Reasoning/Setoid.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Reasoning/Setoid.agda", "max_line_length": 74, "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/Reasoning/Setoid.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 347, "size": 1055 }
module bee2 where open import Bee2.Crypto.Belt open import Data.ByteString.Utf8 open import Data.ByteString.IO open import Data.String using (toList) open import Data.Product using (proj₁) open import IO -- beltPBKDF : Password → ℕ → Salt → Kek main = run (writeBinaryFile "pbkdf2" (proj₁ (beltPBKDF (packStrict "zed") 1000 (packStrict "salt"))))
{ "alphanum_fraction": 0.7528409091, "avg_line_length": 23.4666666667, "ext": "agda", "hexsha": "2ee24fd191f7c5a1b38c2929e1b5e818511c9a4a", "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": "22682afc8d488e3812307e104785d2b8dc8b9d4a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "semenov-vladyslav/bee2-agda", "max_forks_repo_path": "app/bee2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "22682afc8d488e3812307e104785d2b8dc8b9d4a", "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": "semenov-vladyslav/bee2-agda", "max_issues_repo_path": "app/bee2.agda", "max_line_length": 101, "max_stars_count": null, "max_stars_repo_head_hexsha": "22682afc8d488e3812307e104785d2b8dc8b9d4a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "semenov-vladyslav/bee2-agda", "max_stars_repo_path": "app/bee2.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 101, "size": 352 }
{-# OPTIONS --without-K --safe #-} module Dodo.Binary.Union where -- Stdlib imports open import Level using (Level; _⊔_) open import Data.Sum using (_⊎_; inj₁; inj₂; swap) open import Relation.Binary using (REL) -- Local imports open import Dodo.Binary.Equality -- # Definitions infixl 19 _∪₂_ _∪₂_ : {a b ℓ₁ ℓ₂ : Level} {A : Set a} {B : Set b} → REL A B ℓ₁ → REL A B ℓ₂ → REL A B (ℓ₁ ⊔ ℓ₂) _∪₂_ p q x y = p x y ⊎ q x y -- # Properties module _ {a b ℓ : Level} {A : Set a} {B : Set b} {R : REL A B ℓ} where ∪₂-idem : (R ∪₂ R) ⇔₂ R ∪₂-idem = ⇔: ⊆-proof ⊇-proof where ⊆-proof : (R ∪₂ R) ⊆₂' R ⊆-proof _ _ (inj₁ Rxy) = Rxy ⊆-proof _ _ (inj₂ Rxy) = Rxy ⊇-proof : R ⊆₂' (R ∪₂ R) ⊇-proof _ _ = inj₁ module _ {a b ℓ₁ ℓ₂ : Level} {A : Set a} {B : Set b} {P : REL A B ℓ₁} {Q : REL A B ℓ₂} where ∪₂-comm : (P ∪₂ Q) ⇔₂ (Q ∪₂ P) ∪₂-comm = ⇔: (λ _ _ → swap) (λ _ _ → swap) module _ {a b ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {B : Set b} {P : REL A B ℓ₁} {Q : REL A B ℓ₂} {R : REL A B ℓ₃} where ∪₂-assoc : (P ∪₂ Q) ∪₂ R ⇔₂ P ∪₂ (Q ∪₂ R) ∪₂-assoc = ⇔: ⊆-proof ⊇-proof where ⊆-proof : ((P ∪₂ Q) ∪₂ R) ⊆₂' (P ∪₂ (Q ∪₂ R)) ⊆-proof _ _ (inj₁ (inj₁ Pxy)) = inj₁ Pxy ⊆-proof _ _ (inj₁ (inj₂ Qxy)) = inj₂ (inj₁ Qxy) ⊆-proof _ _ (inj₂ Rxy) = inj₂ (inj₂ Rxy) ⊇-proof : (P ∪₂ (Q ∪₂ R)) ⊆₂' ((P ∪₂ Q) ∪₂ R) ⊇-proof _ _ (inj₁ Pxy) = inj₁ (inj₁ Pxy) ⊇-proof _ _ (inj₂ (inj₁ Qxy)) = inj₁ (inj₂ Qxy) ⊇-proof _ _ (inj₂ (inj₂ Rxy)) = inj₂ Rxy -- # Operations -- ## Operations: ⊆₂ module _ {a b ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {B : Set b} {P : REL A B ℓ₁} {Q : REL A B ℓ₂} {R : REL A B ℓ₃} where ∪₂-combine-⊆₂ : P ⊆₂ Q → R ⊆₂ Q → (P ∪₂ R) ⊆₂ Q ∪₂-combine-⊆₂ (⊆: P⊆Q) (⊆: R⊆Q) = ⊆: (λ{x y → λ{(inj₁ Px) → P⊆Q x y Px; (inj₂ Rx) → R⊆Q x y Rx}}) module _ {a b ℓ₁ ℓ₂ : Level} {A : Set a} {B : Set b} {P : REL A B ℓ₁} {Q : REL A B ℓ₂} where ∪₂-introˡ : P ⊆₂ (Q ∪₂ P) ∪₂-introˡ = ⊆: λ{_ _ → inj₂} ∪₂-introʳ : P ⊆₂ (P ∪₂ Q) ∪₂-introʳ = ⊆: λ{_ _ → inj₁} module _ {a b ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {B : Set b} {P : REL A B ℓ₁} {Q : REL A B ℓ₂} {R : REL A B ℓ₃} where ∪₂-introˡ-⊆₂ : P ⊆₂ R → P ⊆₂ (Q ∪₂ R) ∪₂-introˡ-⊆₂ (⊆: P⊆R) = ⊆: (λ x y Pxy → inj₂ (P⊆R x y Pxy)) ∪₂-introʳ-⊆₂ : P ⊆₂ Q → P ⊆₂ (Q ∪₂ R) ∪₂-introʳ-⊆₂ (⊆: P⊆Q) = ⊆: (λ x y Pxy → inj₁ (P⊆Q x y Pxy)) ∪₂-elimˡ-⊆₂ : (P ∪₂ Q) ⊆₂ R → Q ⊆₂ R ∪₂-elimˡ-⊆₂ (⊆: [P∪Q]⊆R) = ⊆: (λ x y Qxy → [P∪Q]⊆R x y (inj₂ Qxy)) ∪₂-elimʳ-⊆₂ : (P ∪₂ Q) ⊆₂ R → P ⊆₂ R ∪₂-elimʳ-⊆₂ (⊆: [P∪Q]⊆R) = ⊆: (λ x y Pxy → [P∪Q]⊆R x y (inj₁ Pxy)) module _ {a b ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {B : Set b} {P : REL A B ℓ₁} {Q : REL A B ℓ₂} {R : REL A B ℓ₃} where ∪₂-substˡ-⊆₂ : P ⊆₂ Q → (P ∪₂ R) ⊆₂ (Q ∪₂ R) ∪₂-substˡ-⊆₂ (⊆: P⊆Q) = ⊆: (λ{x y → λ{(inj₁ Pxy) → inj₁ (P⊆Q x y Pxy); (inj₂ Rxy) → inj₂ Rxy}}) ∪₂-substʳ-⊆₂ : P ⊆₂ Q → (R ∪₂ P) ⊆₂ (R ∪₂ Q) ∪₂-substʳ-⊆₂ (⊆: P⊆Q) = ⊆: (λ{x y → λ{(inj₁ Rxy) → inj₁ Rxy; (inj₂ Pxy) → inj₂ (P⊆Q x y Pxy)}}) -- ## Operations: ⇔₂ module _ {a b ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {B : Set b} {P : REL A B ℓ₁} {Q : REL A B ℓ₂} {R : REL A B ℓ₃} where ∪₂-substˡ : P ⇔₂ Q → (P ∪₂ R) ⇔₂ (Q ∪₂ R) ∪₂-substˡ = ⇔₂-compose ∪₂-substˡ-⊆₂ ∪₂-substˡ-⊆₂ ∪₂-substʳ : P ⇔₂ Q → (R ∪₂ P) ⇔₂ (R ∪₂ Q) ∪₂-substʳ = ⇔₂-compose ∪₂-substʳ-⊆₂ ∪₂-substʳ-⊆₂
{ "alphanum_fraction": 0.4817474566, "avg_line_length": 28.0840336134, "ext": "agda", "hexsha": "5d9909f615c361c73c46be49a1ff5a2d58476512", "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": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "sourcedennis/agda-dodo", "max_forks_repo_path": "src/Dodo/Binary/Union.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "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": "sourcedennis/agda-dodo", "max_issues_repo_path": "src/Dodo/Binary/Union.agda", "max_line_length": 99, "max_stars_count": null, "max_stars_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "sourcedennis/agda-dodo", "max_stars_repo_path": "src/Dodo/Binary/Union.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1972, "size": 3342 }
postulate F : @0 Set → Set G : @0 Set → Set G A = F (λ { → A })
{ "alphanum_fraction": 0.447761194, "avg_line_length": 11.1666666667, "ext": "agda", "hexsha": "f53c57483d554a4f81c197f0f56bc0543f9c67c4", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Fail/Issue4525d.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Fail/Issue4525d.agda", "max_line_length": 19, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Fail/Issue4525d.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": 30, "size": 67 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import cohomology.Theory open import homotopy.PushoutSplit open import cw.CW module cw.cohomology.WedgeOfCells {i} (OT : OrdinaryTheory i) {n} (⊙skel : ⊙Skeleton {i} (S n)) where open OrdinaryTheory OT open import cohomology.Bouquet OT open import cw.WedgeOfCells (⊙Skeleton.skel ⊙skel) module _ (m : ℤ) where CXₙ/Xₙ₋₁ : Group i CXₙ/Xₙ₋₁ = C m ⊙Xₙ/Xₙ₋₁ CEl-Xₙ/Xₙ₋₁ : Type i CEl-Xₙ/Xₙ₋₁ = Group.El CXₙ/Xₙ₋₁ abstract CXₙ/Xₙ₋₁-is-abelian : is-abelian CXₙ/Xₙ₋₁ CXₙ/Xₙ₋₁-is-abelian = C-is-abelian m ⊙Xₙ/Xₙ₋₁ CXₙ/Xₙ₋₁-abgroup : AbGroup i CXₙ/Xₙ₋₁-abgroup = CXₙ/Xₙ₋₁ , CXₙ/Xₙ₋₁-is-abelian CXₙ/Xₙ₋₁-diag-β : ⊙has-cells-with-choice 0 ⊙skel i → CXₙ/Xₙ₋₁ (ℕ-to-ℤ (S n)) ≃ᴳ Πᴳ (⊙cells-last ⊙skel) (λ _ → C2 0) CXₙ/Xₙ₋₁-diag-β ac = C-Bouquet-diag (S n) (⊙cells-last ⊙skel) (⊙cells-last-has-choice ⊙skel ac) ∘eᴳ C-emap (ℕ-to-ℤ (S n)) Bouquet-⊙equiv-Xₙ/Xₙ₋₁ abstract CXₙ/Xₙ₋₁-≠-is-trivial : ∀ {m} (m≠Sn : m ≠ ℕ-to-ℤ (S n)) → ⊙has-cells-with-choice 0 ⊙skel i → is-trivialᴳ (CXₙ/Xₙ₋₁ m) CXₙ/Xₙ₋₁-≠-is-trivial {m} m≠Sn ac = iso-preserves'-trivial (C-emap m Bouquet-⊙equiv-Xₙ/Xₙ₋₁) $ C-Bouquet-≠-is-trivial m (⊙cells-last ⊙skel) (S n) m≠Sn (⊙cells-last-has-choice ⊙skel ac) CXₙ/Xₙ₋₁-<-is-trivial : ∀ {m} (m<Sn : m < S n) → ⊙has-cells-with-choice 0 ⊙skel i → is-trivialᴳ (CXₙ/Xₙ₋₁ (ℕ-to-ℤ m)) CXₙ/Xₙ₋₁-<-is-trivial m<Sn = CXₙ/Xₙ₋₁-≠-is-trivial (ℕ-to-ℤ-≠ (<-to-≠ m<Sn)) CXₙ/Xₙ₋₁->-is-trivial : ∀ {m} (m>Sn : S n < m) → ⊙has-cells-with-choice 0 ⊙skel i → is-trivialᴳ (CXₙ/Xₙ₋₁ (ℕ-to-ℤ m)) CXₙ/Xₙ₋₁->-is-trivial m>Sn = CXₙ/Xₙ₋₁-≠-is-trivial (≠-inv (ℕ-to-ℤ-≠ (<-to-≠ m>Sn)))
{ "alphanum_fraction": 0.6094570928, "avg_line_length": 33.5882352941, "ext": "agda", "hexsha": "088703e432726bc4b77c376db62124f8597f5d34", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/cw/cohomology/WedgeOfCells.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/cw/cohomology/WedgeOfCells.agda", "max_line_length": 95, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/cw/cohomology/WedgeOfCells.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": 935, "size": 1713 }
{-# OPTIONS --safe --without-K #-} module Literals.Number where open import Agda.Builtin.FromNat public open Number ⦃ ... ⦄ public
{ "alphanum_fraction": 0.7014925373, "avg_line_length": 16.75, "ext": "agda", "hexsha": "76138af4b18dd4751145a89b04e0146c9e73fbb3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Literals/Number.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/Literals/Number.agda", "max_line_length": 39, "max_stars_count": null, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Literals/Number.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 35, "size": 134 }
module StateSizedIO.Base where open import Size open import SizedIO.Base open import Data.Product record IOInterfaceˢ : Set₁ where field IOStateˢ : Set Commandˢ : IOStateˢ → Set Responseˢ : (s : IOStateˢ) → (m : Commandˢ s) → Set IOnextˢ : (s : IOStateˢ) → (m : Commandˢ s) → (Responseˢ s m) → IOStateˢ open IOInterfaceˢ public record Interfaceˢ : Set₁ where field Stateˢ : Set Methodˢ : Stateˢ → Set Resultˢ : (s : Stateˢ) → (m : Methodˢ s) → Set nextˢ : (s : Stateˢ) → (m : Methodˢ s) → (Resultˢ s m) → Stateˢ open Interfaceˢ public {- module _ (ioinf : IOInterface) -- (let C = Command ioi) (let R = Response ioi) (objinf : Interfaceˢ) {-(let S = Stateˢ oi)-} --(let M = Methodˢ objinf) (let Rt = Resultˢ objinf) -- (let n = nextˢ objinf) where @BEGIN@IOObject record IOObjectˢ (i : Size) (s : Stateˢ objinf) : Set where coinductive field HIDE-END method : ∀{j : Size< i} (m : Methodˢ objinf s) → IO ioinf ∞ ( Σ[ r ∈ objinf .Resultˢ s m ] IOObjectˢ j (objinf .nextˢ s m r)) @END -} module _ (ioinf : IOInterface) (oinf : Interfaceˢ) where record IOObjectˢ (i : Size) (s : oinf .Stateˢ) : Set where coinductive field method : ∀{j : Size< i} (m : oinf .Methodˢ s) → IO ioinf ∞ (Σ[ r ∈ oinf .Resultˢ s m ] IOObjectˢ j (oinf .nextˢ s m r)) module _ (ioi : IOInterface) (let C = Command ioi) (let R = Response ioi) (oi : Interfaceˢ) (let S = Stateˢ oi) (let M = Methodˢ oi) (let Rt = Resultˢ oi) (let n = nextˢ oi) where record IOObjectˢ- (i : Size) (s : S) : Set where coinductive field method : ∀{j : Size< i} (m : M s) → IO ioi ∞ (Rt s m ) open IOObjectˢ public open IOObjectˢ- public module _ (I : IOInterfaceˢ ) (let S = IOStateˢ I) (let C = Commandˢ I) (let R = Responseˢ I) (let n = IOnextˢ I) where mutual record IOˢ (i : Size) (A : S → Set) (s : S) : Set where coinductive -- constructor delay field forceˢ : {j : Size< i} → IOˢ' j A s data IOˢ' (i : Size) (A : S → Set) (s : S) : Set where doˢ' : (c : C s) (f : (r : R s c) → IOˢ i A (n s c r)) → IOˢ' i A s returnˢ' : (a : A s) → IOˢ' i A s data IOˢ+ (i : Size) (A : S → Set) (s : S) : Set where doˢ' : (c : C s) (f : (r : R s c) → IOˢ i A (n s c r)) → IOˢ+ i A s open IOˢ public delayˢ : {i : Size}{I : IOInterfaceˢ}{A : IOStateˢ I → Set}{s : IOStateˢ I} → IOˢ' I i A s → IOˢ I (↑ i) A s delayˢ p .forceˢ = p module _ {I : IOInterfaceˢ } (let S = IOStateˢ I) (let C = Commandˢ I) (let R = Responseˢ I) (let n = IOnextˢ I) where returnˢ : ∀{i}{A : S → Set} (s : S) (a : A s) → IOˢ I i A s returnˢ s a .forceˢ = returnˢ' a -- 2017-04-05: Argument s is hidden now. doˢ : ∀{i}{A : S → Set} {s : S} (c : C s) (f : (r : R s c) → IOˢ I i A (n s c r)) → IOˢ I i A s doˢ c f .forceˢ = doˢ' c f mutual fmapˢ : (i : Size) → {A B : S → Set} → (f : (s : S) → A s → B s) → (s : S) → IOˢ I i A s → IOˢ I i B s fmapˢ i {A} {B} f s p .forceˢ {j} = fmapˢ' j {A} {B} f s (p .forceˢ {j}) fmapˢ' : (i : Size) → {A B : S → Set} → (f : (s : S) → A s → B s) → (s : S) → IOˢ' I i A s → IOˢ' I i B s fmapˢ' i {A} {B} f s (doˢ' c f₁) = doˢ' c (λ r → fmapˢ i {A} {B} f (IOnextˢ I s c r) (f₁ r)) fmapˢ' i {A} {B} f s (returnˢ' a) = returnˢ' (f s a)
{ "alphanum_fraction": 0.4967444384, "avg_line_length": 28.3538461538, "ext": "agda", "hexsha": "a48415439e9fa9e30f9cccc4401e66c0c8200493", "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": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "stephanadls/state-dependent-gui", "max_forks_repo_path": "src/StateSizedIO/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "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": "stephanadls/state-dependent-gui", "max_issues_repo_path": "src/StateSizedIO/Base.agda", "max_line_length": 108, "max_stars_count": 2, "max_stars_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "stephanadls/state-dependent-gui", "max_stars_repo_path": "src/StateSizedIO/Base.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-31T17:20:59.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T15:37:39.000Z", "num_tokens": 1546, "size": 3686 }
module Untyped.Abstract where open import Function open import Data.String open import Data.Nat open import Data.Unit open import Data.Product open import Data.List open import Data.Sum as Sum open import Data.Maybe open import Strict open import Debug.Trace open import Category.Monad open import Untyped.Monads postulate fail : ∀ {a : Set} → a willneverhappenipromise : ∀ {a : Set} → String → a willneverhappenipromise m = trace m fail module _ where Var = ℕ Chan = ℕ mutual record Closure : Set where inductive constructor ⟨_⊢_⟩ field env : Env body : Exp data Val : Set where tt : Val nat : ℕ → Val chan : Chan → Val ⟨_,_⟩ : Val → Val → Val -- pairs clos : Closure → Val -- closures Env = List Val data Exp : Set where -- the functional core nat : ℕ → Exp var : Var → Exp ƛ : Exp → Exp _·_ : Exp → Exp → Exp -- products pair : Exp → Exp → Exp letp : Exp → Exp → Exp -- communication close : Exp → Exp receive : Exp → Exp send : (ch : Exp) → (v : Exp) → Exp -- threading fork : Exp → Exp extend : Val → Env → Env extend = _∷_ unsafeLookup : ∀ {a} → ℕ → List a → a unsafeLookup _ [] = willneverhappenipromise "lookup fail" unsafeLookup zero (x ∷ xs) = x unsafeLookup (suc n) (x ∷ xs) = unsafeLookup n xs unsafeUpdate : ∀ {a} → ℕ → List a → a → List a unsafeUpdate n [] a = willneverhappenipromise "update fail" unsafeUpdate zero (x ∷ xs) a = a ∷ xs unsafeUpdate (suc n) (x ∷ xs) a = x ∷ unsafeUpdate n xs a -- Ideally this should be two different dispatch sets data Comm : Set where -- communication send : Chan → Val → Comm recv : Chan → Comm clos : Chan → Comm data Threading : Set where -- threading fork : Closure → Threading yield : Threading Cmd = Comm ⊎ Threading ⟦_⟧-comm : Comm → Set ⟦ clos x ⟧-comm = ⊤ ⟦ send x x₁ ⟧-comm = ⊤ ⟦ recv x ⟧-comm = Val ⟦_⟧-thr : Threading → Set ⟦ fork x ⟧-thr = Chan ⟦ yield ⟧-thr = ⊤ ⟦_⟧ : Cmd → Set ⟦ inj₁ x ⟧ = ⟦ x ⟧-comm ⟦ inj₂ y ⟧ = ⟦ y ⟧-thr data Thread : Set where thread : Free Cmd ⟦_⟧ Val → Thread ThreadPool = List Thread Links = Chan → Chan data Blocked : Set where blocked : Blocked {- Free an expression from its earthly -} module _ {m} ⦃ m-monad : RawMonad m ⦄ ⦃ m-read : MonadReader m Env ⦄ ⦃ m-res : MonadResumption m Closure Chan ⦄ ⦃ m-comm : MonadComm m Chan Val ⦄ where open M {-# NON_TERMINATING #-} eval : Exp → m Val eval (nat n) = do return (nat n) eval (var x) = do asks (unsafeLookup x) eval (ƛ e) = do asks (clos ∘ ⟨_⊢ e ⟩) eval (f · e) = do clos ⟨ env ⊢ body ⟩ ← eval f where _ → willneverhappenipromise "not a closure" v ← eval e local (λ _ → extend v env) (eval body) -- products eval (pair e₁ e₂) = do v₁ ← eval e₁ v₂ ← eval e₂ return ⟨ v₁ , v₂ ⟩ eval (letp b e) = do ⟨ v₁ , v₂ ⟩ ← eval b where _ → willneverhappenipromise "not a pair" local (extend v₂ ∘ extend v₁) $ eval e -- communication eval (close e) = do chan c ← eval e where _ → willneverhappenipromise "not a channel to close" M.close c return tt eval (receive e) = do chan c ← eval e where _ → willneverhappenipromise "not a channel to receive on" M.recv c eval (send e₁ e₂) = do chan c ← eval e₁ where _ → willneverhappenipromise "not a channel to send on" v ← eval e₂ M.send c v return tt -- threading eval (fork e) = do clos cl ← eval e where _ → willneverhappenipromise "not a closure to fork" c ← M.fork cl return (chan c) {- Interpreting communication commands -} module _ {com} ⦃ com-comm : MonadComm com Chan Val ⦄ where communicate : (cmd : Comm) → com ⟦ cmd ⟧-comm communicate (Comm.send c v) = M.send c v communicate (Comm.recv x) = M.recv x communicate (clos x) = M.close x {- Interpreting threading commands -} module _ {thr} ⦃ thr-res : MonadResumption thr Closure Chan ⦄ where threading : (cmd : Threading) → thr ⟦ cmd ⟧-thr threading (Threading.fork cl) = M.fork cl threading Threading.yield = M.yield module _ {cmd} ⦃ cmd-comm : MonadComm cmd Chan Val ⦄ ⦃ cmd-res : MonadResumption cmd Closure Chan ⦄ where handle : (c : Cmd) → cmd ⟦ c ⟧ handle = Sum.[ communicate , threading ] {- Round robin scheduling -} module _ {w : Set} {m} ⦃ monad : RawMonad m ⦄ ⦃ read : MonadState m (List w) ⦄ (atomic : w → m ⊤) where open M {-# NON_TERMINATING #-} robin : m ⊤ robin = do (h ∷ tl) ← get where [] → return tt put tl atomic h robin
{ "alphanum_fraction": 0.5655061381, "avg_line_length": 23.0046296296, "ext": "agda", "hexsha": "975825aef52e29f4143f4427232f89a86433c718", "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/Untyped/Abstract.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/Untyped/Abstract.agda", "max_line_length": 71, "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/Untyped/Abstract.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": 1639, "size": 4969 }
-- Andreas, 2011-05-09 -- {-# OPTIONS -v tc.inj:40 -v tc.meta:30 #-} module Issue383b where postulate Σ : (A : Set) → (A → Set) → Set U : Set El : U → Set mutual data Ctxt : Set where _▻_ : (Γ : Ctxt) → (Env Γ → U) → Ctxt Env : Ctxt → Set Env (Γ ▻ σ) = Σ (Env Γ) λ γ → El (σ γ) postulate Δ : Ctxt σ : Env Δ → U δ : U → Env (Δ ▻ σ) data Foo : (Γ : Ctxt) → (U → Env Γ) → Set where foo : Foo _ δ -- WORKS NOW; OLD COMPLAINT: -- Agda does not solve or simplify the following constraint. Why? Env -- is constructor-headed. -- -- _40 := δ if [(Σ (Env Δ) (λ γ → El (σ γ))) =< (Env _39) : Set]
{ "alphanum_fraction": 0.5353697749, "avg_line_length": 20.064516129, "ext": "agda", "hexsha": "7226c4e90eb34d574b26630971ad15471e7d2480", "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/Issue383b.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/Issue383b.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/Issue383b.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": 263, "size": 622 }
{- 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 Level using (0ℓ) -- This module defines utility functions to help working on proofs. module LibraBFT.Base.Util where -- This is obviously not something that should be used in any legitimate proof. It's just for -- convenience when we want to avoid importing a module with open holes while working on -- something else. obm-dangerous-magic! : ∀ {ℓ} {A : Set ℓ} → A obm-dangerous-magic! {ℓ} {A} = magic where postulate magic : A
{ "alphanum_fraction": 0.7339055794, "avg_line_length": 38.8333333333, "ext": "agda", "hexsha": "b73d411bcc180fb00841775baacbd36c06e15ee1", "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": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "cwjnkins/bft-consensus-agda", "max_forks_repo_path": "LibraBFT/Base/Util.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "cwjnkins/bft-consensus-agda", "max_issues_repo_path": "LibraBFT/Base/Util.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "cwjnkins/bft-consensus-agda", "max_stars_repo_path": "LibraBFT/Base/Util.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 187, "size": 699 }
open import Data.Fin using (Fin; suc; zero) open import Data.Nat using (ℕ) open import Data.Vec using (Vec; []; _∷_; map) open import Dipsy.Polarity renaming (pos to +; neg to -) module Dipsy.Struct (FOp : {n : ℕ} (as : Vec Polarity n) (b : Polarity) → Set) (SOp : {n : ℕ} (as : Vec Polarity n) (b : Polarity) → Set) where open import Dipsy.Form FOp mutual data Struct : (b : Polarity) → Set where ·_· : {b : Polarity} → Form → Struct b op : {n : ℕ} {as : Vec Polarity n} {b : Polarity} → SOp as b → Structs as → Struct b data Structs : {n : ℕ} (as : Vec Polarity n) → Set where [] : Structs [] _∷_ : {n : ℕ} {a : Polarity} {as : Vec Polarity n} → Struct a → Structs as → Structs (a ∷ as) mutual data Context : (b c : Polarity) → Set where [] : {b : Polarity} → Context b b op : {n : ℕ} {as : Vec Polarity n} {b c : Polarity} → SOp as c → (i : Fin n) → Contexts as b i → Context b c data Contexts : {n : ℕ} (as : Vec Polarity n) (b : Polarity) (i : Fin n) → Set where _<∷_ : {n : ℕ} {b c : Polarity} {as : Vec Polarity n} → Context b c → Structs as → Contexts (c ∷ as) b zero _∷>_ : {n : ℕ} {a b : Polarity} {as : Vec Polarity n} {i : Fin n} → Struct a → Contexts as b i → Contexts (a ∷ as) b (suc i)
{ "alphanum_fraction": 0.5578703704, "avg_line_length": 37.0285714286, "ext": "agda", "hexsha": "8b826f6a30254f9b2f850215d7f1a5c93a3a03ab", "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": "06eec3f3325c71c81809ff19dfaf4fd43ba958ed", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "wenkokke/dipsy", "max_forks_repo_path": "src/Dipsy/Struct.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "06eec3f3325c71c81809ff19dfaf4fd43ba958ed", "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": "wenkokke/dipsy", "max_issues_repo_path": "src/Dipsy/Struct.agda", "max_line_length": 86, "max_stars_count": 1, "max_stars_repo_head_hexsha": "06eec3f3325c71c81809ff19dfaf4fd43ba958ed", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wenkokke/Dipsy", "max_stars_repo_path": "src/Dipsy/Struct.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-10T13:43:29.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-10T13:43:29.000Z", "num_tokens": 488, "size": 1296 }
{-# OPTIONS --without-K #-} module Equiv2Path where open import FT using (FT; ⟦_⟧; _⇛_; _◎_; sym⇛) open import Equivalences using (_≃_) open import FT-Nat using (normal; bridge) equiv2path : {B₁ B₂ : FT} → (⟦ B₁ ⟧ ≃ ⟦ B₂ ⟧) → (B₁ ⇛ B₂) equiv2path {B₁} {B₂} eq = ((normal B₁) ◎ bridge eq) ◎ (sym⇛ (normal B₂))
{ "alphanum_fraction": 0.6121794872, "avg_line_length": 28.3636363636, "ext": "agda", "hexsha": "52a507b762eb33eaae84dd529eafd60ba6e49616", "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/OldUnivalence/Equiv2Path.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/OldUnivalence/Equiv2Path.agda", "max_line_length": 72, "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/OldUnivalence/Equiv2Path.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": 134, "size": 312 }
------------------------------------------------------------------------------ -- Inequalities on partial natural numbers ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.Nat.Inequalities where open import FOTC.Base infix 4 _<_ _≮_ _>_ _≯_ _≤_ _≰_ _≥_ _≱_ ------------------------------------------------------------------------------ -- The function terms. postulate lt : D → D → D lt-00 : lt zero zero ≡ false lt-0S : ∀ n → lt zero (succ₁ n) ≡ true lt-S0 : ∀ n → lt (succ₁ n) zero ≡ false lt-SS : ∀ m n → lt (succ₁ m) (succ₁ n) ≡ lt m n {-# ATP axioms lt-00 lt-0S lt-S0 lt-SS #-} le : D → D → D le m n = lt m (succ₁ n) {-# ATP definition le #-} gt : D → D → D gt m n = lt n m {-# ATP definition gt #-} ge : D → D → D ge m n = le n m {-# ATP definition ge #-} ------------------------------------------------------------------------ -- The relations. _<_ : D → D → Set m < n = lt m n ≡ true {-# ATP definition _<_ #-} _≮_ : D → D → Set m ≮ n = lt m n ≡ false {-# ATP definition _≮_ #-} _>_ : D → D → Set m > n = gt m n ≡ true {-# ATP definition _>_ #-} _≯_ : D → D → Set m ≯ n = gt m n ≡ false {-# ATP definition _≯_ #-} _≤_ : D → D → Set m ≤ n = le m n ≡ true {-# ATP definition _≤_ #-} _≰_ : D → D → Set m ≰ n = le m n ≡ false {-# ATP definition _≰_ #-} _≥_ : D → D → Set m ≥ n = ge m n ≡ true {-# ATP definition _≥_ #-} _≱_ : D → D → Set m ≱ n = ge m n ≡ false {-# ATP definition _≱_ #-} ------------------------------------------------------------------------------ -- The lexicographical order. Lexi : D → D → D → D → Set Lexi m n m' n' = m < m' ∨ m ≡ m' ∧ n < n' {-# ATP definition Lexi #-}
{ "alphanum_fraction": 0.4014869888, "avg_line_length": 23.835443038, "ext": "agda", "hexsha": "d5e7b3b31a79673addb7eb3d9a89cb8455f11757", "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/Inequalities.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/Inequalities.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Data/Nat/Inequalities.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": 577, "size": 1883 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Talks.DURG where open import Cubical.Algebra.Group open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.Equiv open import Cubical.Functions.FunExtEquiv open import Cubical.Data.Sigma open import Cubical.Data.Empty open import Cubical.Data.Unit open import Cubical.Data.Nat open import Cubical.Relation.Binary open import Cubical.DStructures.Base open import Cubical.DStructures.Meta.Properties open import Cubical.DStructures.Meta.Isomorphism open import Cubical.DStructures.Structures.XModule private variable ℓ ℓ' ℓ'' ℓ₁ ℓ₁' ℓ₁'' ℓ₂ ℓA ℓ≅A ℓA' ℓ≅A' ℓB ℓB' ℓ≅B' ℓ≅B ℓC ℓ≅C ℓ≅ᴰ ℓP : Level {- Goals of the project: - define strict 2-groups - define crossed modules - prove their equivalence - do something with the classifying space perspective on groups Problems: - performance - the maps going back and forth were fine, but the identity types stating that these maps are inverse to each other were too complex How did we solve this? - Copatterns - Ulrik's idea: displayed univalent reflexive graphs - Provide a fiberwise characterization of the identity types of a type family to obtain a characterization of the identity types of the total space - Avoid equality on objects in proofs - Modular and abstract -} -- DEFINITION -- - URG structure -- - alternative constructors record URGStr' (A : Type ℓA) (ℓ≅A : Level) : Type (ℓ-max ℓA (ℓ-suc ℓ≅A)) where no-eta-equality constructor urgstr' field _≅_ : Rel A A ℓ≅A ρ : isRefl _≅_ uni : isUnivalent _≅_ ρ -- substituted version record URGStr'' (A : Type ℓA) (ℓ≅A : Level) : Type (ℓ-max ℓA (ℓ-suc ℓ≅A)) where field -- a binary relation _≅_ : A → A → Type ℓ≅A -- a witness of reflexivity ρ : (a : A) → a ≅ a -- these two fields induce a map that turns -- a path into a proof the endpoints are related ≡→≅ : {a a' : A} → a ≡ a' → a ≅ a' ≡→≅ {a} {a'} p = subst (λ z → a ≅ z) p (ρ a) field -- that natural map is a fiberwise equivalence uni : (a a' : A) → isEquiv (≡→≅ {a} {a'}) -- alternatively, we could ask for any fiberwise equivalence uni' = (a a' : A) → (a ≡ a') ≃ (a ≅ a') -- another alternative: all ≅-singletons should be contractible contrRelSingl' = (a : A) → isContr (Σ[ a' ∈ A ] (a ≅ a')) -- We can prove that these are equivalent: -- uni ↔ uni' ↔ contrRelSingl' -- This gives rise to alternative constructors for URGs: make-𝒮' : {A : Type ℓA} {_≅_ : Rel A A ℓ≅A} (ρ : isRefl _≅_) (contrTotal : contrRelSingl _≅_) → URGStr A ℓ≅A make-𝒮' {_≅_ = _≅_} ρ contrTotal = urgstr _≅_ ρ (contrRelSingl→isUnivalent _≅_ ρ contrTotal) -- EXAMPLES -- - groups -- - univalent categories -- - observational equality on ℕ -- - universe -- - identity types -- The SIP for groups produces a URG structure on the type of groups 𝒮-group' : (ℓ : Level) → URGStr (Group {ℓ}) ℓ 𝒮-group' ℓ .URGStr._≅_ = GroupEquiv 𝒮-group' ℓ .URGStr.ρ = idGroupEquiv 𝒮-group' ℓ .URGStr.uni = isUnivalent'→isUnivalent GroupEquiv idGroupEquiv λ G H → invEquiv (GroupPath G H) -- Every univalent Category induces a URG on its type of objects open import Cubical.Categories.Category renaming (isUnivalent to isUnivalentCat) Cat→𝒮 : (𝒞 : Precategory ℓ ℓ') → (uni : isUnivalentCat 𝒞) → URGStr (𝒞 .ob) ℓ' Cat→𝒮 𝒞 uni = urgstr (CatIso {𝒞 = 𝒞}) idCatIso λ x y → isUnivalentCat.univ uni x y -- observational equality on ℕ ℕ-≅ : ℕ → ℕ → Type ℓ-zero ℕ-≅ 0 0 = Unit ℕ-≅ 0 (suc _) = ⊥ ℕ-≅ (suc _) 0 = ⊥ ℕ-≅ (suc n) (suc m) = ℕ-≅ n m -- observational equality on ℕ is a URG 𝒮-Nat' : URGStr ℕ ℓ-zero 𝒮-Nat' = {!!} where import Cubical.DStructures.Structures.Nat using (𝒮-Nat) -- equivalences determine a URG on any universe 𝒮-universe : URGStr (Type ℓ) ℓ 𝒮-universe = make-𝒮 {_≅_ = _≃_} idEquiv λ A → isContrRespectEquiv (Σ-cong-equiv-snd (λ A' → isoToEquiv (equivInv A' A))) (equivContr' A) where module _ (A : Type ℓ) where equivInv : (A' : Type ℓ) → Iso (A ≃ A') (A' ≃ A) Iso.fun (equivInv A') = invEquiv Iso.inv (equivInv A') = invEquiv Iso.leftInv (equivInv A') = λ e → equivEq (invEquiv (invEquiv e)) e (funExt (λ x → refl)) Iso.rightInv (equivInv A') = λ e → equivEq (invEquiv (invEquiv e)) e (funExt (λ x → refl)) equivContr' : isContr (Σ[ A' ∈ Type ℓ ] A' ≃ A) equivContr' = EquivContr A -- trivially, a type is a URGStr with the relation given by its identity types 𝒮-type : (A : Type ℓ) → URGStr A ℓ 𝒮-type A = make-𝒮 {_≅_ = _≡_} (λ _ → refl) isContrSingl -- THEOREM: -- uniqueness of small URGs 𝒮-uniqueness' : (A : Type ℓA) → isContr (URGStr A ℓA) 𝒮-uniqueness' = {!!} where import Cubical.DStructures.Structures.Type using (𝒮-uniqueness) -- DEFINITION -- - displayed URG record URGStrᴰ' {A : Type ℓA} (𝒮-A : URGStr A ℓ≅A) (B : A → Type ℓB) (ℓ≅ᴰ : Level) : Type (ℓ-max (ℓ-max (ℓ-max ℓA ℓB) ℓ≅A) (ℓ-suc ℓ≅ᴰ)) where no-eta-equality constructor urgstrᴰ' open URGStr 𝒮-A field _≅ᴰ⟨_⟩_ : {a a' : A} → B a → a ≅ a' → B a' → Type ℓ≅ᴰ ρᴰ : {a : A} → isRefl _≅ᴰ⟨ ρ a ⟩_ uniᴰ : {a : A} → isUnivalent _≅ᴰ⟨ ρ a ⟩_ ρᴰ -- Of course, this also has the alternative constructor make-𝒮ᴰ -- using that the uniᴰ field follows from uniᴰ' = {a : A} → (b : B a) → isContr (Σ[ b' ∈ B a ] b ≅ᴰ⟨ ρ a ⟩ b') -- EXAMPLE -- - pointedness displayed over the universe 𝒮ᴰ-pointed : {ℓ : Level} → URGStrᴰ (𝒮-universe {ℓ}) (λ A → A) ℓ 𝒮ᴰ-pointed {ℓ} = make-𝒮ᴰ (λ a e b → equivFun e a ≡ b) (λ _ → refl) p where p : (A : Type ℓ) (a : A) → isContr (Σ[ b ∈ A ] a ≡ b) p _ a = isContrSingl a -- THEOREM -- Every DURG on a type family B induces -- a URG on the total space Σ[ a ∈ A ] B a ∫⟨_⟩'_ : {A : Type ℓA} (𝒮-A : URGStr A ℓ≅A) {B : A → Type ℓB} (𝒮ᴰ-B : URGStrᴰ 𝒮-A B ℓ≅B) → URGStr (Σ A B) (ℓ-max ℓ≅A ℓ≅B) ∫⟨_⟩'_ = {!!} {- B ∫ | ↦ A × B A -} -- EXAMPLE -- A characterization of the identity types of pointed types 𝒮-pointed : {ℓ : Level} → URGStr (Σ[ A ∈ Type ℓ ] A) ℓ 𝒮-pointed = ∫⟨ 𝒮-universe ⟩ 𝒮ᴰ-pointed -- EXAMPLE -- - constant DURG -- - URG product -- - URG structure on pairs of groups 𝒮ᴰ-const : {A : Type ℓA} (𝒮-A : URGStr A ℓ≅A) {B : Type ℓB} (𝒮-B : URGStr B ℓ≅B) → URGStrᴰ 𝒮-A (λ _ → B) ℓ≅B 𝒮ᴰ-const {A = A} 𝒮-A {B} 𝒮-B = urgstrᴰ (λ b _ b' → b ≅ b') ρ uni where open URGStr 𝒮-B _×𝒮_ : {A : Type ℓA} (𝒮-A : URGStr A ℓ≅A) {B : Type ℓB} (𝒮-B : URGStr B ℓ≅B) → URGStr (A × B) (ℓ-max ℓ≅A ℓ≅B) _×𝒮_ 𝒮-A 𝒮-B = ∫⟨ 𝒮-A ⟩ (𝒮ᴰ-const 𝒮-A 𝒮-B) {- const B ∫ A, B ↦ | ↦ A × B A -} -- EXAMPLE -- Group Homomorphisms displayed over pairs of groups 𝒮ᴰ-G²\F' : URGStrᴰ (𝒮-group' ℓ ×𝒮 𝒮-group' ℓ') (λ (G , H) → GroupHom G H) (ℓ-max ℓ ℓ') 𝒮ᴰ-G²\F' = make-𝒮ᴰ (λ {(G , H)} {(G' , H')} f (eG , eH) f' → (g : ⟨ G ⟩) → GroupEquiv.eq eH .fst ((f .fun) g) ≡ (f' .fun) (GroupEquiv.eq eG .fst g)) (λ _ _ → refl) λ (G , H) f → isContrRespectEquiv (Σ-cong-equiv-snd (λ f' → isoToEquiv (invIso (GroupMorphismExtIso f f')))) (isContrSingl f) where open GroupHom {- The displayed relation is defined as f ≅⟨ eG , eH ⟩ f = commutativity of f G --------> H | | eG | | eH | | G'--------> H' f' Reflexivity is trivial Univalence follows from contractibility of Σ[ (f' , _) ∈ GroupHom G H ] (f ∼ f') for all (f , _) ∈ GroupHom G H -} {- Overview of Crossed Modules and Strict 2-Groups Definition: Crossed module - group action α of G₀ on H - homomorphism φ : H → G₀ - equivariance condition (g : G₀) → (h : H) → φ (g α h) ≡ g + (φ h) - g - peiffer condition (h h' : ⟨ H ⟩) → (φ h) α h' ≡ h + h' - h Definition: Strict 2-Group - internal category in the category of groups This means - split mono ι with two retractions ι : G₀ ↔ G : σ τ₁ - vertical composition operation which satisfies the interchange law _∘⟨_⟩_ : (g f : G₁) → isComposable g f → G₁ - equivalent to type of vertical compositions on internal reflexive graph: PFG (a b : G₁) → ι(σ b) + a - ι(τ a) - ι(σ b) + b + ι(τ a) ≡ b + a Produce this tree of displayed structures: PFXM PFG VertComp | | / | | / isEquivar isSecRet | | | | B B | | | | isAction isSecRet | | | | LAS F B F×B \ | | / \ | | / \ | / / \ | / / Grp | | Grp use the next result to display propositions like isAction, isEquivariant and isSecRet -} -- THEOREM -- Subtypes have a simple DURG structure given by 𝟙 -- This makes it easy to impose axioms on a structure Subtype→Sub-𝒮ᴰ : {A : Type ℓA} → (P : A → hProp ℓP) → (𝒮-A : URGStr A ℓ≅A) → URGStrᴰ 𝒮-A (λ a → P a .fst) ℓ-zero Subtype→Sub-𝒮ᴰ P 𝒮-A = make-𝒮ᴰ (λ _ _ _ → Unit) (λ _ → tt) (λ a p → isContrRespectEquiv (invEquiv (Σ-contractSnd (λ _ → isContrUnit))) (inhProp→isContr p (P a .snd))) -- EXAMPLE -- isAction axioms on pairs of groups together with a left action structure module _ (ℓ ℓ' : Level) where ℓℓ' = ℓ-max ℓ ℓ' open import Cubical.DStructures.Structures.Action 𝒮ᴰ-G²Las\Action' : URGStrᴰ (𝒮-G²Las ℓ ℓ') (λ ((G , H) , _α_) → IsGroupAction G H _α_) ℓ-zero 𝒮ᴰ-G²Las\Action' = Subtype→Sub-𝒮ᴰ (λ ((G , H) , _α_) → IsGroupAction G H _α_ , isPropIsGroupAction G H _α_) (𝒮-G²Las ℓ ℓ') 𝒮-G²LasAction' : URGStr (Action ℓ ℓ') (ℓ-max ℓ ℓ') 𝒮-G²LasAction' = ∫⟨ 𝒮-G²Las ℓ ℓ' ⟩ 𝒮ᴰ-G²Las\Action' {- -- THEOREM -- DURGs can be lifted to be displayed over the total space of -- another DURG on the same base URG B | B C Lift C \ / ↦ | A A -} VerticalLift-𝒮ᴰ' : {A : Type ℓA} (𝒮-A : URGStr A ℓ≅A) {B : A → Type ℓB} (𝒮ᴰ-B : URGStrᴰ 𝒮-A B ℓ≅B) {C : A → Type ℓC} (𝒮ᴰ-C : URGStrᴰ 𝒮-A C ℓ≅C) → URGStrᴰ (∫⟨ 𝒮-A ⟩ 𝒮ᴰ-C) (λ (a , _) → B a) ℓ≅B VerticalLift-𝒮ᴰ' {ℓ≅B = ℓ≅B} 𝒮-A {B = B} 𝒮ᴰ-B 𝒮ᴰ-C = urgstrᴰ (λ b (pA , _) b' → b ≅ᴰ⟨ pA ⟩ b') ρᴰ uniᴰ where open URGStrᴰ 𝒮ᴰ-B {- -- THEOREM -- A tower of two DURGs can be reassociated C | B split B × C | ↦ | A A (but C depends on B) -} splitTotal-𝒮ᴰ' : {A : Type ℓA} (𝒮-A : URGStr A ℓ≅A) {B : A → Type ℓB} (𝒮ᴰ-B : URGStrᴰ 𝒮-A B ℓ≅B) {C : Σ A B → Type ℓC} (𝒮ᴰ-C : URGStrᴰ (∫⟨ 𝒮-A ⟩ 𝒮ᴰ-B) C ℓ≅C) → URGStrᴰ 𝒮-A (λ a → Σ[ b ∈ B a ] C (a , b)) (ℓ-max ℓ≅B ℓ≅C) splitTotal-𝒮ᴰ' {A = A} 𝒮-A {B} 𝒮ᴰ-B {C} 𝒮ᴰ-C = make-𝒮ᴰ (λ (b , c) eA (b' , c') → Σ[ eB ∈ b B≅ᴰ⟨ eA ⟩ b' ] c ≅ᴰ⟨ eA , eB ⟩ c') (λ (b , c) → Bρᴰ b , ρᴰ c) {!!} where open URGStrᴰ 𝒮ᴰ-C open URGStr 𝒮-A _B≅ᴰ⟨_⟩_ = URGStrᴰ._≅ᴰ⟨_⟩_ 𝒮ᴰ-B Bρᴰ = URGStrᴰ.ρᴰ 𝒮ᴰ-B Buniᴰ = URGStrᴰ.uniᴰ 𝒮ᴰ-B {- -- THEOREM -- two DURGs over the same URGs can be combined B | B C Lift C split B × C \ / ↦ | ↦ | A A A -} combine-𝒮ᴰ' : {A : Type ℓA} {𝒮-A : URGStr A ℓ≅A} {B : A → Type ℓB} {C : A → Type ℓC} (𝒮ᴰ-B : URGStrᴰ 𝒮-A B ℓ≅B) (𝒮ᴰ-C : URGStrᴰ 𝒮-A C ℓ≅C) → URGStrᴰ 𝒮-A (λ a → B a × C a) (ℓ-max ℓ≅B ℓ≅C) combine-𝒮ᴰ' {𝒮-A = 𝒮-A} 𝒮ᴰ-B 𝒮ᴰ-C = splitTotal-𝒮ᴰ 𝒮-A 𝒮ᴰ-B (VerticalLift-𝒮ᴰ 𝒮-A 𝒮ᴰ-C 𝒮ᴰ-B) -- REMARK: DURG is equivalent to URG + morphism of URG via fibrant replacement module _ (C : Type ℓ) where dispTypeIso : Iso (C → Type ℓ) (Σ[ X ∈ Type ℓ ] (X → C)) Iso.fun dispTypeIso D = (Σ[ c ∈ C ] D c) , fst Iso.inv dispTypeIso (X , F) c = Σ[ x ∈ X ] F x ≡ c Iso.leftInv dispTypeIso = {!!} Iso.rightInv dispTypeIso = {!!} -- → combine is pullback in the (∞,1)-topos of DURGs {- With these operations we can construct the entire tree, but how to get equivalences? PFXM PFG VertComp | | / | | / isEquivar isSecRet | | | | B B | | | | isAction isSecRet | | | | LAS F B F×B \ | | / \ | | / \ | / / \ | / / Grp | | Grp -- For URGs: relational isomorphisms -} record RelIso' {A : Type ℓA} (_≅_ : Rel A A ℓ≅A) {A' : Type ℓA'} (_≅'_ : Rel A' A' ℓ≅A') : Type (ℓ-max (ℓ-max ℓA ℓA') (ℓ-max ℓ≅A ℓ≅A')) where constructor reliso' field fun : A → A' inv : A' → A rightInv : (a' : A') → fun (inv a') ≅' a' leftInv : (a : A) → inv (fun a) ≅ a RelIso→Iso' : {A : Type ℓA} {A' : Type ℓA'} (_≅_ : Rel A A ℓ≅A) (_≅'_ : Rel A' A' ℓ≅A') {ρ : isRefl _≅_} {ρ' : isRefl _≅'_} (uni : isUnivalent _≅_ ρ) (uni' : isUnivalent _≅'_ ρ') (f : RelIso _≅_ _≅'_) → Iso A A' Iso.fun (RelIso→Iso' _ _ _ _ f) = RelIso.fun f Iso.inv (RelIso→Iso' _ _ _ _ f) = RelIso.inv f Iso.rightInv (RelIso→Iso' _ _≅'_ {ρ' = ρ'} _ uni' f) a' = invEquiv (≡→R _≅'_ ρ' , uni' (RelIso.fun f (RelIso.inv f a')) a') .fst (RelIso.rightInv f a') Iso.leftInv (RelIso→Iso' _≅_ _ {ρ = ρ} uni _ f) a = invEquiv (≡→R _≅_ ρ , uni (RelIso.inv f (RelIso.fun f a)) a) .fst (RelIso.leftInv f a) {- For DURGs: pull back one of the DURGs along an equivalence and show that there is a fiberwise relational isomorphism between B and f*B' B f*B' B' | / | | / | A ≃ A' f -} 𝒮ᴰ-*-Iso-Over→TotalIso : {A : Type ℓA} {𝒮-A : URGStr A ℓ≅A} {A' : Type ℓA'} {𝒮-A' : URGStr A' ℓ≅A'} (ℱ : Iso A A') {B : A → Type ℓB} (𝒮ᴰ-B : URGStrᴰ 𝒮-A B ℓ≅B) {B' : A' → Type ℓB'} (𝒮ᴰ-B' : URGStrᴰ 𝒮-A' B' ℓ≅B') (𝒢 : 𝒮ᴰ-♭PIso (Iso.fun ℱ) 𝒮ᴰ-B 𝒮ᴰ-B') → Iso (Σ A B) (Σ A' B') 𝒮ᴰ-*-Iso-Over→TotalIso ℱ 𝒮ᴰ-B 𝒮ᴰ-B' 𝒢 = RelFiberIsoOver→Iso ℱ (𝒮ᴰ→relFamily 𝒮ᴰ-B) (𝒮ᴰ-B .uniᴰ) (𝒮ᴰ→relFamily 𝒮ᴰ-B') (𝒮ᴰ-B' .uniᴰ) 𝒢 where open URGStrᴰ {- Let's apply this machinery to our tower of DURGs. -} import Cubical.DStructures.Equivalences.GroupSplitEpiAction import Cubical.DStructures.Equivalences.PreXModReflGraph import Cubical.DStructures.Equivalences.XModPeifferGraph import Cubical.DStructures.Equivalences.PeifferGraphS2G {- DISCUSSION - alternate definition of URGs - how to layer the cake - uniformity, abstraction, no equality on objects, results transferrable across proof assistants and type theories - unlike displayed categories not limited to 1-truncated types and type families - easy to set up - associates the other way compared to SNS - every SNS gives DURG on the URG of the universe (not implemented) OTHER THINGS WE DID - Define (n,k)-groups - Display homomorphisms of (n,k)-groups over pairs of such groups - prove the equivalence of (0,1)-groups and axiomatic groups via EM-spaces FUTURE WORK - construct more operations - use reflection to automate steps - construct URG on the type of URG or even DURG structures - meta-theory - model of type theory - more higher group theory ... -}
{ "alphanum_fraction": 0.5282562708, "avg_line_length": 28.4767641997, "ext": "agda", "hexsha": "037aaa3c8f8587edd22bbbd10299cade8bcc7d4c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_path": "Cubical/Talks/DURG.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Schippmunk/cubical", "max_issues_repo_path": "Cubical/Talks/DURG.agda", "max_line_length": 120, "max_stars_count": null, "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_path": "Cubical/Talks/DURG.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6629, "size": 16545 }
{-# OPTIONS --cubical --safe --postfix-projections #-} open import Prelude module Cardinality.Finite.Cardinal.Category {ℓ : Level} where open import Cardinality.Finite.Cardinal open import HITs.PropositionalTruncation open import Data.Sigma.Properties open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Categories open import Cubical.Foundations.Univalence open import Categories.Product open import Categories.Exponential open import Data.Fin open import Cardinality.Finite.ManifestBishop 𝒞⇒isSet : 𝒞 A → isSet A 𝒞⇒isSet = Discrete→isSet ∘ 𝒞⇒Discrete finSetPreCategory : PreCategory (ℓsuc ℓ) ℓ finSetPreCategory .PreCategory.Ob = Σ (Type ℓ) 𝒞 finSetPreCategory .PreCategory.Hom (X , _) (Y , _) = X → Y finSetPreCategory .PreCategory.Id = id finSetPreCategory .PreCategory.Comp f g = f ∘ g finSetPreCategory .PreCategory.assoc-Comp _ _ _ = refl finSetPreCategory .PreCategory.Comp-Id _ = refl finSetPreCategory .PreCategory.Id-Comp _ = refl finSetPreCategory .PreCategory.Hom-Set {X} {Y} = hLevelPi 2 λ _ → Discrete→isSet (𝒞⇒Discrete (Y .snd)) open PreCategory finSetPreCategory iso-iso : (X ≅ Y) ⇔ (fst X ⇔ fst Y) iso-iso .fun (f , g , f∘g , g∘f) = iso f g (λ x i → g∘f i x) (λ x i → f∘g i x) iso-iso .inv (iso f g g∘f f∘g) = f , g , (λ i x → f∘g x i) , (λ i x → g∘f x i) iso-iso .rightInv _ = refl iso-iso .leftInv _ = refl finSetCategory : Category (ℓsuc ℓ) ℓ finSetCategory .Category.preCategory = finSetPreCategory finSetCategory .Category.univalent {X} {Y} = ≃ΣProp≡ (λ _ → squash) ⟨ trans-≃ ⟩ univalence ⟨ trans-≃ ⟩ isoToEquiv ( sym-⇔ (iso⇔equiv (Discrete→isSet (𝒞⇒Discrete (X .snd)))) ⟨ trans-⇔ ⟩ sym-⇔ (iso-iso {X} {Y})) finSetHasProducts : HasProducts finSetCategory finSetHasProducts .HasProducts.product X Y .Product.obj = X .fst × Y .fst , X .snd ∥×∥ Y .snd finSetHasProducts .HasProducts.product X Y .Product.proj₁ = fst finSetHasProducts .HasProducts.product X Y .Product.proj₂ = snd finSetHasProducts .HasProducts.product X Y .Product.ump f g .fst z = f z , g z finSetHasProducts .HasProducts.product X Y .Product.ump f g .snd .fst .fst = refl finSetHasProducts .HasProducts.product X Y .Product.ump f g .snd .fst .snd = refl finSetHasProducts .HasProducts.product X Y .Product.ump f g .snd .snd (f≡ , g≡) i x = f≡ (~ i) x , g≡ (~ i) x finSetHasExp : HasExponentials finSetCategory finSetHasProducts finSetHasExp X Y .Exponential.obj = (X .fst → Y .fst) , (X .snd ∥→∥ Y .snd) finSetHasExp X Y .Exponential.eval (f , x) = f x finSetHasExp X Y .Exponential.uniq X₁ f .fst = curry f finSetHasExp X Y .Exponential.uniq X₁ f .snd .fst = refl finSetHasExp X Y .Exponential.uniq X₁ f .snd .snd x = cong curry (sym x) open import Categories.Pullback open import Cardinality.Finite.SplitEnumerable using (ℰ!⟨Lift⟩; ℰ!⟨⊤⟩; ℰ!⟨⊥⟩) finSetHasPullbacks : HasPullbacks finSetCategory finSetHasPullbacks {X = X} {Y = Y} {Z = Z} f g .Pullback.P = ∃[ ab ] (f (fst ab) ≡ g (snd ab)) , ((X .snd ∥×∥ Y .snd) ∥Σ∥ λ _ → 𝒞⟨≡⟩ _ _ (Z .snd)) finSetHasPullbacks f g .Pullback.p₁ ((x , _) , _) = x finSetHasPullbacks f g .Pullback.p₂ ((_ , y) , _) = y finSetHasPullbacks f g .Pullback.commute = funExt snd finSetHasPullbacks f g .Pullback.ump {A = A} h₁ h₂ p .fst x = (h₁ x , h₂ x) , λ i → p i x finSetHasPullbacks f g .Pullback.ump {A = A} h₁ h₂ p .snd .fst .fst = refl finSetHasPullbacks f g .Pullback.ump {A = A} h₁ h₂ p .snd .fst .snd = refl finSetHasPullbacks {Z = Z} f g .Pullback.ump {A = A} h₁ h₂ p .snd .snd {i} (p₁e , p₂e) = funExt (λ x → ΣProp≡ (λ _ → 𝒞⇒isSet (Z .snd) _ _) λ j → p₁e (~ j) x , p₂e (~ j) x) finSetTerminal : Terminal finSetTerminal .fst = Lift _ ⊤ , ∣ ℰ!⇒ℬ (ℰ!⟨Lift⟩ ℰ!⟨⊤⟩) ∣ finSetTerminal .snd .fst x .lower = tt finSetTerminal .snd .snd y = funExt λ _ → refl finSetInitial : Initial finSetInitial .fst = Lift _ ⊥ , ∣ ℰ!⇒ℬ (ℰ!⟨Lift⟩ ℰ!⟨⊥⟩) ∣ finSetInitial .snd .fst () finSetInitial .snd .snd y i () open import HITs.PropositionalTruncation open import Categories.Coequalizer ∃!′ : (A : Type a) → (A → Type b) → Type (a ℓ⊔ b) ∃!′ A P = ∥ Σ A P ∥ Prelude.× AtMostOne P lemma23 : ∀ {p} {P : A → hProp p} → ∃!′ A (fst ∘ P) → Σ A (fst ∘ P) lemma23 {P = P} (x , y) = rec (λ xs ys → ΣProp≡ (snd ∘ P) (y (xs .fst) (ys .fst) (xs .snd) (ys .snd))) id x module _ {A : Type a} {P : A → Type b} (R : ∀ x → P x → hProp c) where uniqueChoice : (Π[ x ⦂ A ] (∃!′ (P x) (λ u → R x u .fst))) → Σ[ f ⦂ Π[ x ⦂ A ] P x ] Π[ x ⦂ A ] (R x (f x) .fst) uniqueChoice H = fst ∘ mid , snd ∘ mid where mid : Π[ x ⦂ A ] Σ[ u ⦂ P x ] (R x u .fst) mid x = lemma23 {P = R x} (H x) open import HITs.PropositionalTruncation.Sugar open import Data.List using (_∷_; []) open import Cardinality.Finite.SplitEnumerable.Search using (ℰ!⟨fib⟩) module CoeqProofs {X Y : Ob} (f : X ⟶ Y) where KernelPair : Pullback finSetCategory {X = X} {Z = Y} {Y = X} f f KernelPair = finSetHasPullbacks f f Im : Ob Im = ∃[ b ] ∥ fiber f b ∥ , (Y .snd ∥Σ∥ λ x → do cx ← X .snd ; cy ← Y .snd ; ∣ ℰ!⇒ℬ (ℰ!⟨fib⟩ f _ (ℬ⇒ℰ! cx) (ℬ⇒ℰ! cy)) ∣) im : X ⟶ Im im x = f x , ∣ x , refl ∣ open Pullback KernelPair lem : ∀ {H : Ob} (h : X ⟶ H) → h ∘ p₁ ≡ h ∘ p₂ → Σ[ f ⦂ (Im ⟶ H) ] Π[ x ⦂ Im .fst ] (∀ y → im y ≡ x → h y ≡ f x) lem {H = H} h eq = uniqueChoice R prf where R : Im .fst → H .fst → hProp _ R w x .fst = ∀ y → im y ≡ w → h y ≡ x R w x .snd = hLevelPi 1 λ _ → hLevelPi 1 λ _ → 𝒞⇒isSet (H .snd) _ _ prf : Π[ x ⦂ Im .fst ] ∃!′ (H .fst) (λ u → ∀ y → im y ≡ x → h y ≡ u) prf (xy , p) .fst = (λ { (z , r) → h z , λ y imy≡xyp → cong (_$ ((y , z) , cong fst imy≡xyp ; sym r)) eq }) ∥$∥ p prf (xy , p) .snd x₁ x₂ Px₁ Px₂ = rec (𝒞⇒isSet (H .snd) x₁ x₂) (λ { (z , zs) → sym (Px₁ z (ΣProp≡ (λ _ → squash) zs)) ; Px₂ z (ΣProp≡ (λ _ → squash) zs) } ) p lem₂ : ∀ (H : Ob) (h : X ⟶ H) (i : Im ⟶ H) (x : Im .fst) (hi : h ≡ i ∘ im) (eq : h ∘ p₁ ≡ h ∘ p₂) → i x ≡ lem {H = H} h eq .fst x lem₂ H h i x hi eq = rec (𝒞⇒isSet (H .snd) _ _) (λ { (y , ys) → (cong i (ΣProp≡ (λ _ → squash) (sym ys)) ; sym (cong (_$ y) hi)) ; lem {H = H} h eq .snd x y (ΣProp≡ (λ _ → squash) ys) }) (x .snd) finSetCoeq : Coequalizer finSetCategory {X = P} {Y = X} p₁ p₂ finSetCoeq .Coequalizer.obj = Im finSetCoeq .Coequalizer.arr = im finSetCoeq .Coequalizer.equality = funExt λ x → ΣProp≡ (λ _ → squash) λ i → commute i x finSetCoeq .Coequalizer.coequalize {H = H} {h = h} eq = lem {H = H} h eq .fst finSetCoeq .Coequalizer.universal {H = H} {h = h} {eq = eq} = funExt λ x → lem {H = H} h eq .snd (im x) x refl finSetCoeq .Coequalizer.unique {H = H} {h = h} {i = i} {eq = eq} prf = funExt λ x → lem₂ H h i x prf eq open CoeqProofs public using (finSetCoeq) module PullbackSurjProofs {X Y : Ob} (f : X ⟶ Y) (fSurj : Surjective f) where KernelPair : Pullback finSetCategory {X = X} {Z = Y} {Y = X} f f KernelPair = finSetHasPullbacks f f open Pullback KernelPair p₁surj : Surjective p₁ p₁surj y = ∣ ((y , y) , refl) , refl ∣ p₂surj : Surjective p₂ p₂surj y = ∣ ((y , y) , refl) , refl ∣
{ "alphanum_fraction": 0.6216409377, "avg_line_length": 44.8461538462, "ext": "agda", "hexsha": "926ed20d26192f3464c211e20bf3ffe1c79c5505", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Cardinality/Finite/Cardinal/Category.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/Cardinality/Finite/Cardinal/Category.agda", "max_line_length": 197, "max_stars_count": null, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Cardinality/Finite/Cardinal/Category.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2995, "size": 6996 }
{-# OPTIONS --safe --warning=error --without-K --guardedness #-} open import Setoids.Setoids open import Rings.Definition open import Rings.Orders.Partial.Definition open import Rings.Orders.Total.Definition open import Groups.Definition open import Groups.Lemmas open import Fields.Fields open import Sets.EquivalenceRelations open import Sequences open import Setoids.Orders.Partial.Definition open import Setoids.Orders.Total.Definition open import Functions.Definition open import LogicalFormulae open import Numbers.Naturals.Semiring open import Numbers.Naturals.Order open import Numbers.Naturals.Order.Lemmas module Fields.CauchyCompletion.Addition {m n o : _} {A : Set m} {S : Setoid {m} {n} A} {_+_ : A → A → A} {_*_ : A → A → A} {_<_ : Rel {m} {o} A} {pOrder : SetoidPartialOrder S _<_} {R : Ring S _+_ _*_} {pRing : PartiallyOrderedRing R pOrder} (order : TotallyOrderedRing pRing) (F : Field R) where open Setoid S open SetoidTotalOrder (TotallyOrderedRing.total order) open SetoidPartialOrder pOrder open Equivalence eq open PartiallyOrderedRing pRing open Ring R open Group additiveGroup open Field F open import Fields.Lemmas F open import Fields.CauchyCompletion.Definition order F open import Rings.Orders.Partial.Lemmas pRing open import Fields.Orders.Total.Lemmas {F = F} (record { oRing = order }) open import Rings.Orders.Total.AbsoluteValue order open import Rings.Orders.Total.Lemmas order open import Rings.Orders.Total.Cauchy order open import Rings.InitialRing R private lemm : (m : ℕ) (a b : Sequence A) → index (apply _+_ a b) m ≡ (index a m) + (index b m) lemm zero a b = refl lemm (succ m) a b = lemm m (Sequence.tail a) (Sequence.tail b) private additionConverges : (a b : CauchyCompletion) → cauchy (apply _+_ (CauchyCompletion.elts a) (CauchyCompletion.elts b)) additionConverges record { elts = a ; converges = convA } record { elts = b ; converges = convB } ε 0<e with halve charNot2 ε ... | e/2 , e/2Pr with convA e/2 (halvePositive e/2 (<WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq e/2Pr) 0<e)) ... | Na , prA with convB e/2 (halvePositive e/2 (<WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq e/2Pr) 0<e)) ... | Nb , prB = (Na +N Nb) , t where t : {m n : ℕ} → Na +N Nb <N m → Na +N Nb <N n → abs ((index (apply _+_ a b) m) + inverse (index (apply _+_ a b) n)) < ε t {m} {n} <m <n with prA {m} {n} (inequalityShrinkLeft <m) (inequalityShrinkLeft <n) ... | am-an<e/2 with prB {m} {n} (inequalityShrinkRight <m) (inequalityShrinkRight <n) ... | bm-bn<e/2 with triangleInequality (index a m + inverse (index a n)) (index b m + inverse (index b n)) ... | inl tri rewrite lemm m a b | lemm n a b = SetoidPartialOrder.<WellDefined pOrder (Equivalence.reflexive eq) e/2Pr (SetoidPartialOrder.<Transitive pOrder {_} {(abs ((index a m) + (inverse (index a n)))) + (abs ((index b m) + (inverse (index b n))))} (<WellDefined (absWellDefined _ _ (Equivalence.transitive eq (Equivalence.symmetric eq (+Associative {index a m})) (Equivalence.transitive eq (+WellDefined (Equivalence.reflexive eq {index a m}) (Equivalence.transitive eq groupIsAbelian (Equivalence.transitive eq (Equivalence.symmetric eq (+Associative {index b m})) (+WellDefined (Equivalence.reflexive eq {index b m}) (Equivalence.symmetric eq (invContravariant additiveGroup)))))) (+Associative {index a m})))) (Equivalence.reflexive eq) tri) (ringAddInequalities am-an<e/2 bm-bn<e/2)) ... | inr tri rewrite lemm m a b | lemm n a b = SetoidPartialOrder.<WellDefined pOrder (Equivalence.reflexive eq) e/2Pr (<WellDefined (Equivalence.transitive eq (Equivalence.symmetric eq tri) (absWellDefined _ _ (Equivalence.transitive eq (Equivalence.symmetric eq (+Associative {index a m})) (Equivalence.transitive eq (+WellDefined (Equivalence.reflexive eq {index a m}) (Equivalence.transitive eq groupIsAbelian (Equivalence.transitive eq (Equivalence.symmetric eq (+Associative {index b m})) (+WellDefined (Equivalence.reflexive eq {index b m}) (Equivalence.symmetric eq (invContravariant additiveGroup)))))) (+Associative {index a m}))))) (Equivalence.reflexive eq) (ringAddInequalities am-an<e/2 bm-bn<e/2)) _+C_ : CauchyCompletion → CauchyCompletion → CauchyCompletion CauchyCompletion.elts (record { elts = a ; converges = convA } +C record { elts = b ; converges = convB }) = apply _+_ a b CauchyCompletion.converges (a +C b) = additionConverges a b inverseDistributes : {r s : A} → inverse (r + s) ∼ inverse r + inverse s inverseDistributes = Equivalence.transitive eq (invContravariant additiveGroup) groupIsAbelian -C_ : CauchyCompletion → CauchyCompletion CauchyCompletion.elts (-C a) = map inverse (CauchyCompletion.elts a) CauchyCompletion.converges (-C record { elts = elts ; converges = converges }) ε 0<e with converges ε 0<e CauchyCompletion.converges (-C record { elts = elts ; converges = converges }) ε 0<e | N , prN = N , ans where ans : {m n : ℕ} → (N <N m) → (N <N n) → abs ((index (map inverse elts) m) + inverse (index (map inverse elts) n)) < ε ans {m} {n} N<m N<n = <WellDefined (Equivalence.transitive eq (absWellDefined _ _ (Equivalence.reflexive eq)) (Equivalence.transitive eq (absNegation (index elts m + inverse (index elts n))) (absWellDefined _ _ (Equivalence.transitive eq inverseDistributes (+WellDefined (identityOfIndiscernablesLeft _∼_ (Equivalence.reflexive eq) (equalityCommutative (mapAndIndex elts inverse m))) (inverseWellDefined additiveGroup (identityOfIndiscernablesLeft _∼_ (Equivalence.reflexive eq) (equalityCommutative (mapAndIndex elts inverse n))))))))) (Equivalence.reflexive eq) (prN N<m N<n)
{ "alphanum_fraction": 0.7316078709, "avg_line_length": 77.2739726027, "ext": "agda", "hexsha": "6d6b6788930b6163f849d4eed583bf81965384eb", "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": "Fields/CauchyCompletion/Addition.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": "Fields/CauchyCompletion/Addition.agda", "max_line_length": 800, "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": "Fields/CauchyCompletion/Addition.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": 1729, "size": 5641 }
{-# OPTIONS --cubical --safe #-} module Data.Binary where open import Data.Binary.Definition public using (𝔹; 0ᵇ; 1ᵇ_; 2ᵇ_) open import Data.Binary.Conversion public using (⟦_⇑⟧; ⟦_⇓⟧) open import Data.Binary.Addition public using (_+_) open import Data.Binary.Multiplication public using (_*_) open import Data.Binary.Subtraction public using (_-_) open import Data.Binary.Isomorphism public using (𝔹⇔ℕ) open import Data.Binary.Increment public using (inc)
{ "alphanum_fraction": 0.7405063291, "avg_line_length": 24.9473684211, "ext": "agda", "hexsha": "f525d28fda3c0f24c94ebc90dd25535ed200bc2f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Data/Binary.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Data/Binary.agda", "max_line_length": 45, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Data/Binary.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": 150, "size": 474 }
open import Prelude open import core module lemmas-ground where -- not ground types aren't hole to hole ground-arr-not-hole : ∀{τ} → (τ ground → ⊥) → (τ ≠ (⦇·⦈ ==> ⦇·⦈)) ground-arr-not-hole notg refl = notg GHole ground-prod-not-hole : ∀{τ} → (τ ground → ⊥) → (τ ≠ (⦇·⦈ ⊗ ⦇·⦈)) ground-prod-not-hole notg refl = notg GProd -- not ground types either have to be hole or an arrow or a prod notground : ∀{τ} → (τ ground → ⊥) → (τ == ⦇·⦈) + (Σ[ τ1 ∈ typ ] Σ[ τ2 ∈ typ ] (τ == (τ1 ==> τ2))) + (Σ[ τ1 ∈ typ ] Σ[ τ2 ∈ typ ] (τ == (τ1 ⊗ τ2))) notground {b} gnd = abort (gnd GBase) notground {⦇·⦈} gnd = Inl refl notground {τ ==> τ₁} gnd = Inr (Inl (τ , τ₁ , refl)) notground {τ ⊗ τ₁} gnd = Inr (Inr (τ , τ₁ , refl)) ground-arr-lem : (τ : typ) → ((τ ground) → ⊥) → (τ ≠ ⦇·⦈) → Σ[ τ1 ∈ typ ] Σ[ τ2 ∈ typ ] (((τ == (τ1 ==> τ2)) × ((τ1 ==> τ2) ≠ (⦇·⦈ ==> ⦇·⦈))) + ((τ == (τ1 ⊗ τ2)) × ((τ1 ⊗ τ2) ≠ (⦇·⦈ ⊗ ⦇·⦈)))) ground-arr-lem b ng nh = abort (ng GBase) ground-arr-lem ⦇·⦈ ng nh = abort (nh refl) ground-arr-lem (τ1 ==> τ2) ng nh = τ1 , τ2 , Inl (refl , λ x → ng (lem' x)) where lem' : ∀{τ1 τ2} → τ1 ==> τ2 == ⦇·⦈ ==> ⦇·⦈ → (τ1 ==> τ2) ground lem' refl = GHole ground-arr-lem (τ1 ⊗ τ2) ng nh = τ1 , τ2 , Inr (refl , (λ x → ng (lem' x))) where lem' : ∀{τ1 τ2} → τ1 ⊗ τ2 == ⦇·⦈ ⊗ ⦇·⦈ → (τ1 ⊗ τ2) ground lem' refl = GProd
{ "alphanum_fraction": 0.405356056, "avg_line_length": 37.3409090909, "ext": "agda", "hexsha": "8f29d13602179f65ba312b258b2180b41a9f5a24", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-livelits-agda", "max_forks_repo_path": "lemmas-ground.agda", "max_issues_count": 9, "max_issues_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_issues_repo_issues_event_max_datetime": "2020-10-20T20:44:13.000Z", "max_issues_repo_issues_event_min_datetime": "2020-09-30T20:27:56.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazel-palette-agda", "max_issues_repo_path": "lemmas-ground.agda", "max_line_length": 77, "max_stars_count": 4, "max_stars_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazel-palette-agda", "max_stars_repo_path": "lemmas-ground.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-19T15:38:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-04T06:45:06.000Z", "num_tokens": 700, "size": 1643 }
module New.LangChanges where open import New.Lang public open import New.Changes isChAlgτ : (τ : Type) → IsChAlg ⟦ τ ⟧Type ⟦ Δt τ ⟧Type Chτ : (τ : Type) → Set Chτ τ = ⟦ Δt τ ⟧Type chAlgt : (τ : Type) → ChAlg ⟦ τ ⟧Type chAlgt τ = record { Ch = Chτ τ ; isChAlg = isChAlgτ τ} instance ichAlgt : ∀ {τ} → ChAlg ⟦ τ ⟧Type ichAlgt {τ} = chAlgt τ isChAlgτ (σ ⇒ τ) = isChAlg {{funCA {{chAlgt σ}} {{chAlgt τ}}}} isChAlgτ int = isChAlg {{intCA}} isChAlgτ (pair σ τ) = isChAlg {{pairCA {{chAlgt σ}} {{chAlgt τ}}}} isChAlgτ (sum σ τ) = isChAlg {{sumCA {{chAlgt σ}} {{chAlgt τ}}}} ΔΓ : Context → Context ΔΓ ∅ = ∅ ΔΓ (τ • Γ) = Δt τ • τ • ΔΓ Γ module _ where ChΓ : ∀ (Γ : Context) → Set ChΓ Γ = ⟦ ΔΓ Γ ⟧Context _e⊕_ : ∀ {Γ} → ⟦ Γ ⟧Context → ChΓ Γ → ⟦ Γ ⟧Context _e⊕_ ∅ ∅ = ∅ _e⊕_ (v • ρ) (dv • _ • dρ) = v ⊕ dv • ρ e⊕ dρ _e⊝_ : ∀ {Γ} → ⟦ Γ ⟧Context → ⟦ Γ ⟧Context → ChΓ Γ _e⊝_ ∅ ∅ = ∅ _e⊝_ (v₂ • ρ₂) (v₁ • ρ₁) = v₂ ⊝ v₁ • v₁ • ρ₂ e⊝ ρ₁ validΓ : ∀ {Γ} → ⟦ Γ ⟧Context → ChΓ Γ → Set validΓ ∅ ∅ = ⊤ validΓ (v • ρ) (dv • v′ • dρ) = valid v dv × v ≡ v′ × validΓ ρ dρ e⊝-valid : ∀ {Γ} → (ρ1 ρ2 : ⟦ Γ ⟧Context) → validΓ ρ1 (ρ2 e⊝ ρ1) e⊝-valid ∅ ∅ = tt e⊝-valid (v₁ • ρ₁) (v₂ • ρ₂) = ⊝-valid v₁ v₂ , refl , e⊝-valid ρ₁ ρ₂ e⊕-⊝ : ∀ {Γ} → (ρ2 ρ1 : ⟦ Γ ⟧Context) → ρ1 e⊕ (ρ2 e⊝ ρ1) ≡ ρ2 e⊕-⊝ ∅ ∅ = refl e⊕-⊝ (v₂ • ρ₂) (v₁ • ρ₁) = cong₂ _•_ (⊕-⊝ v₂ v₁) (e⊕-⊝ ρ₂ ρ₁) {-# TERMINATING #-} isEnvCA : ∀ Γ → IsChAlg ⟦ Γ ⟧Context (ChΓ Γ) e⊚-valid : ∀ {Γ} → (ρ : ⟦ Γ ⟧Context) (dρ1 : ChΓ Γ) → validΓ ρ dρ1 → (dρ2 : ChΓ Γ) → validΓ (ρ e⊕ dρ1) dρ2 → validΓ ρ (IsChAlg.default-⊚ (isEnvCA Γ) dρ1 ρ dρ2) e⊚-correct : ∀ {Γ} → (ρ : ⟦ Γ ⟧Context) (dρ1 : ChΓ Γ) → validΓ ρ dρ1 → (dρ2 : ChΓ Γ) → validΓ (ρ e⊕ dρ1) dρ2 → (ρ e⊕ IsChAlg.default-⊚ (isEnvCA Γ) dρ1 ρ dρ2) ≡ ((ρ e⊕ dρ1) e⊕ dρ2) isEnvCA Γ = record { _⊕_ = _e⊕_ ; _⊝_ = _e⊝_ ; valid = validΓ ; ⊝-valid = e⊝-valid ; ⊕-⊝ = e⊕-⊝ ; _⊚[_]_ = IsChAlg.default-⊚ (isEnvCA Γ) ; ⊚-valid = e⊚-valid ; ⊚-correct = e⊚-correct } e⊚-valid {Γ} = IsChAlg.default-⊚-valid (isEnvCA Γ) e⊚-correct {Γ} = IsChAlg.default-⊚-correct (isEnvCA Γ) envCA : ∀ Γ → ChAlg ⟦ Γ ⟧Context envCA Γ = record { Ch = ChΓ Γ ; isChAlg = isEnvCA Γ } instance ienvCA : ∀ {Γ} → ChAlg ⟦ Γ ⟧Context ienvCA {Γ} = envCA Γ
{ "alphanum_fraction": 0.5076271186, "avg_line_length": 27.7647058824, "ext": "agda", "hexsha": "e5abf85cf03d92611b3278a79324e4593fadcf97", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_path": "New/LangChanges.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_path": "New/LangChanges.agda", "max_line_length": 70, "max_stars_count": 10, "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_path": "New/LangChanges.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "num_tokens": 1346, "size": 2360 }
{-# OPTIONS --without-K #-} module ConcretePermutation where open import Level renaming (zero to lzero) hiding (suc) open import Data.Nat using (ℕ) open import Data.Fin using (Fin; zero; inject+; fromℕ) open import Data.Vec using (Vec; tabulate; allFin; []; _∷_) open import Data.Vec.Properties using (tabulate∘lookup) open import Function using (_∘_) open import Relation.Binary using (Setoid) open import Relation.Binary.PropositionalEquality using (_≡_; setoid) -- open import Proofs using ( -- VectorLemmas _!!_ ) ------------------------------------------------------------------------------ -- A concrete permutation has 4 components: -- - the one-line notation for a permutation -- - the one-line notation for the inverse permutation -- - and 2 proofs that these are indeed inverses -- One-line notation for permutations with identity and composition FinVec : ℕ → ℕ → Set FinVec m n = Vec (Fin m) n 1C : {n : ℕ} → FinVec n n 1C {n} = allFin n _∘̂_ : {n₀ n₁ n₂ : ℕ} → Vec (Fin n₁) n₀ → Vec (Fin n₂) n₁ → Vec (Fin n₂) n₀ π₁ ∘̂ π₂ = tabulate (_!!_ π₂ ∘ _!!_ π₁) -- Actual permutation record CPerm (values : ℕ) (size : ℕ) : Set where constructor cp field π : FinVec values size πᵒ : FinVec size values αp : π ∘̂ πᵒ ≡ 1C βp : πᵒ ∘̂ π ≡ 1C ------------------------------------------------------------------------------ -- We can compare concrete permutations for equality using _≡_ -- It is actually sufficient to compare just the forward π using _≡_ -- The set of permutations under _≡_ SCPerm : ℕ → ℕ → Setoid lzero lzero SCPerm m n = setoid (CPerm m n) -- This is just tabulate∘lookup, but it hides the details; should this -- be called 'join' or 'flatten' ? cauchyext : {m n : ℕ} (π : FinVec m n) → tabulate (_!!_ π) ≡ π cauchyext π = tabulate∘lookup π ------------------------------------------------------------------------------ -- I always mix up which way the permutation works. Here is a small -- example to serve as a reminder: -- values 0₅ 1₅ 2₅ 3₅ 4₅ : Fin 5 0₅ = zero 1₅ = inject+ 3 (fromℕ 1) 2₅ = inject+ 2 (fromℕ 2) 3₅ = inject+ 1 (fromℕ 3) 4₅ = fromℕ 4 -- indices 0₃ 1₃ 2₃ : Fin 3 0₃ = zero 1₃ = inject+ 1 (fromℕ 1) 2₃ = fromℕ 2 πex : FinVec 5 3 πex = 4₅ ∷ 3₅ ∷ 2₅ ∷ [] fex : Fin 3 → Fin 5 fex i = πex !! i -- fex 0₃ => 4₅ -- fex 1₃ => 3₅ -- fex 2₃ => 2₅ ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.5740356698, "avg_line_length": 24.8556701031, "ext": "agda", "hexsha": "4564ed6965ca76df6f718e7d5b67cb9fa8f09652", "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/ConcretePermutation.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/ConcretePermutation.agda", "max_line_length": 78, "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/ConcretePermutation.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": 799, "size": 2411 }
{-# OPTIONS --without-K --safe #-} open import Categories.Bicategory using (Bicategory) module Categories.Bicategory.Extras {o ℓ e t} (Bicat : Bicategory o ℓ e t) where open import Data.Product using (_,_) import Categories.Category.Construction.Core as Core open import Categories.Category.Construction.Functors using (Functors; module curry) open import Categories.Functor using (Functor) open import Categories.Functor.Bifunctor using (flip-bifunctor) open import Categories.Functor.Bifunctor.Properties open import Categories.NaturalTransformation using (NaturalTransformation; ntHelper) open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism) import Categories.Morphism as Mor import Categories.Morphism.Reasoning as MR open import Categories.NaturalTransformation.NaturalIsomorphism.Properties using (push-eq) open Bicategory Bicat public private variable A B C D : Obj f g h i : A ⇒₁ B α β γ δ : f ⇒₂ g infixr 10 _▷ᵢ_ infixl 10 _◁ᵢ_ infixr 6 _⟩⊚⟨_ refl⟩⊚⟨_ infixl 7 _⟩⊚⟨refl module ⊚ {A B C} = Functor (⊚ {A} {B} {C}) module ⊚-assoc {A B C D} = NaturalIsomorphism (⊚-assoc {A} {B} {C} {D}) module unitˡ {A B} = NaturalIsomorphism (unitˡ {A} {B}) module unitʳ {A B} = NaturalIsomorphism (unitʳ {A} {B}) module id {A} = Functor (id {A}) private module MR′ {A} {B} where open Core.Shorthands (hom A B) public open MR (hom A B) public hiding (push-eq) open MR′ unitorˡ : {A B : Obj} {f : A ⇒₁ B} → id₁ ∘₁ f ≅ f unitorˡ {_} {_} {f} = record { from = unitˡ.⇒.η (_ , f) ; to = unitˡ.⇐.η (_ , f) ; iso = unitˡ.iso (_ , f) } module unitorˡ {A B f} = _≅_ (unitorˡ {A} {B} {f}) unitorʳ : {A B : Obj} {f : A ⇒₁ B} → f ∘₁ id₁ ≅ f unitorʳ {_} {_} {f} = record { from = unitʳ.⇒.η (f , _) ; to = unitʳ.⇐.η (f , _) ; iso = unitʳ.iso (f , _) } module unitorʳ {A B f} = _≅_ (unitorʳ {A} {B} {f}) associator : {A B C D : Obj} {f : D ⇒₁ B} {g : C ⇒₁ D} {h : A ⇒₁ C} → (f ∘₁ g) ∘₁ h ≅ f ∘₁ g ∘₁ h associator {_} {_} {_} {_} {f} {g} {h} = record { from = ⊚-assoc.⇒.η ((f , g) , h) ; to = ⊚-assoc.⇐.η ((f , g) , h) ; iso = ⊚-assoc.iso ((f , g) , h) } module associator {A B C D} {f : C ⇒₁ B} {g : D ⇒₁ C} {h} = _≅_ (associator {A = A} {B = B} {f = f} {g = g} {h = h}) module Shorthands where λ⇒ = unitorˡ.from λ⇐ = unitorˡ.to ρ⇒ = unitorʳ.from ρ⇐ = unitorʳ.to α⇒ = associator.from α⇐ = associator.to open Shorthands -- Two curried versions of ⊚. -⊚[-] : Functor (hom A B) (Functors (hom B C) (hom A C)) -⊚[-] = curry.F₀ (flip-bifunctor ⊚) [-]⊚- : Functor (hom B C) (Functors (hom A B) (hom A C)) [-]⊚- = curry.F₀ ⊚ -⊚_ : A ⇒₁ B → Functor (hom B C) (hom A C) -⊚_ = Functor.F₀ -⊚[-] _⊚- : B ⇒₁ C → Functor (hom A B) (hom A C) _⊚- = Functor.F₀ [-]⊚- -▷_ : ∀ {C} → f ⇒₂ g → NaturalTransformation (-⊚_ {C = C} f) (-⊚ g) -▷_ = Functor.F₁ -⊚[-] _◁- : ∀ {A} → f ⇒₂ g → NaturalTransformation (_⊚- {A = A} f) (g ⊚-) _◁- = Functor.F₁ [-]⊚- identity₂ˡ : id₂ ∘ᵥ α ≈ α identity₂ˡ = hom.identityˡ identity₂ʳ : α ∘ᵥ id₂ ≈ α identity₂ʳ = hom.identityʳ assoc₂ : (α ∘ᵥ β) ∘ᵥ γ ≈ α ∘ᵥ β ∘ᵥ γ assoc₂ = hom.assoc id₂◁ : id₂ {f = g} ◁ f ≈ id₂ id₂◁ = ⊚.identity ▷id₂ : f ▷ id₂ {f = g} ≈ id₂ ▷id₂ = ⊚.identity open hom.HomReasoning open hom.Equiv _⊚ᵢ_ : f ≅ h → g ≅ i → f ⊚₀ g ≅ h ⊚₀ i α ⊚ᵢ β = record { from = from α ⊚₁ from β ; to = to α ⊚₁ to β ; iso = record { isoˡ = [ ⊚ ]-merge (isoˡ α) (isoˡ β) ○ ⊚.identity ; isoʳ = [ ⊚ ]-merge (isoʳ α) (isoʳ β) ○ ⊚.identity } } _◁ᵢ_ : {g h : B ⇒₁ C} (α : g ≅ h) (f : A ⇒₁ B) → g ∘₁ f ≅ h ∘₁ f α ◁ᵢ _ = α ⊚ᵢ idᵢ _▷ᵢ_ : {f g : A ⇒₁ B} (h : B ⇒₁ C) (α : f ≅ g) → h ∘₁ f ≅ h ∘₁ g _ ▷ᵢ α = idᵢ ⊚ᵢ α ⊚-resp-≈ : α ≈ β → γ ≈ δ → α ⊚₁ γ ≈ β ⊚₁ δ ⊚-resp-≈ p q = ⊚.F-resp-≈ (p , q) ⊚-resp-≈ˡ : α ≈ β → α ⊚₁ γ ≈ β ⊚₁ γ ⊚-resp-≈ˡ p = ⊚.F-resp-≈ (p , hom.Equiv.refl) ⊚-resp-≈ʳ : γ ≈ δ → α ⊚₁ γ ≈ α ⊚₁ δ ⊚-resp-≈ʳ q = ⊚.F-resp-≈ (hom.Equiv.refl , q) _⟩⊚⟨_ : α ≈ β → γ ≈ δ → α ⊚₁ γ ≈ β ⊚₁ δ _⟩⊚⟨_ = ⊚-resp-≈ refl⟩⊚⟨_ : γ ≈ δ → α ⊚₁ γ ≈ α ⊚₁ δ refl⟩⊚⟨_ = ⊚-resp-≈ʳ _⟩⊚⟨refl : α ≈ β → α ⊚₁ γ ≈ β ⊚₁ γ _⟩⊚⟨refl = ⊚-resp-≈ˡ ∘ᵥ-distr-◁ : (α ◁ f) ∘ᵥ (β ◁ f) ≈ (α ∘ᵥ β) ◁ f ∘ᵥ-distr-◁ {f = f} = ⟺ (Functor.homomorphism (-⊚ f)) ∘ᵥ-distr-▷ : (f ▷ α) ∘ᵥ (f ▷ β) ≈ f ▷ (α ∘ᵥ β) ∘ᵥ-distr-▷ {f = f} = ⟺ (Functor.homomorphism (f ⊚-)) λ⇒-∘ᵥ-▷ : λ⇒ ∘ᵥ (id₁ ▷ α) ≈ α ∘ᵥ λ⇒ λ⇒-∘ᵥ-▷ {α = α} = begin λ⇒ ∘ᵥ (id₁ ▷ α) ≈˘⟨ refl⟩∘⟨ id.identity ⟩⊚⟨refl ⟩ λ⇒ ∘ᵥ id.F₁ _ ⊚₁ α ≈⟨ unitˡ.⇒.commute (_ , α) ⟩ α ∘ᵥ λ⇒ ∎ ▷-∘ᵥ-λ⇐ : (id₁ ▷ α) ∘ᵥ λ⇐ ≈ λ⇐ ∘ᵥ α ▷-∘ᵥ-λ⇐ = conjugate-to (unitorˡ ⁻¹) (unitorˡ ⁻¹) λ⇒-∘ᵥ-▷ ρ⇒-∘ᵥ-◁ : ρ⇒ ∘ᵥ (α ◁ id₁) ≈ α ∘ᵥ ρ⇒ ρ⇒-∘ᵥ-◁ {α = α} = begin ρ⇒ ∘ᵥ (α ◁ id₁) ≈˘⟨ refl⟩∘⟨ refl⟩⊚⟨ id.identity ⟩ ρ⇒ ∘ᵥ (α ⊚₁ id.F₁ _) ≈⟨ unitʳ.⇒.commute (α , _) ⟩ α ∘ᵥ ρ⇒ ∎ ◁-∘ᵥ-ρ⇐ : (α ◁ id₁) ∘ᵥ ρ⇐ ≈ ρ⇐ ∘ᵥ α ◁-∘ᵥ-ρ⇐ = conjugate-to (unitorʳ ⁻¹) (unitorʳ ⁻¹) ρ⇒-∘ᵥ-◁ α⇐-◁-∘₁ : α⇐ ∘ᵥ (γ ◁ (g ∘₁ f)) ≈ ((γ ◁ g) ◁ f) ∘ᵥ α⇐ α⇐-◁-∘₁ {γ = γ} {g = g} {f = f} = begin α⇐ ∘ᵥ (γ ◁ (g ∘₁ f)) ≈˘⟨ refl⟩∘⟨ refl⟩⊚⟨ ⊚.identity ⟩ α⇐ ∘ᵥ (γ ⊚₁ id₂ ⊚₁ id₂) ≈⟨ ⊚-assoc.⇐.commute ((γ , id₂) , id₂) ⟩ ((γ ◁ g) ◁ f) ∘ᵥ α⇐ ∎ α⇒-◁-∘₁ : α⇒ ∘ᵥ γ ◁ g ◁ f ≈ γ ◁ (g ∘₁ f) ∘ᵥ α⇒ α⇒-◁-∘₁ = ⟺ (conjugate-to associator associator α⇐-◁-∘₁) α⇐-▷-◁ : α⇐ ∘ᵥ (f ▷ (γ ◁ g)) ≈ ((f ▷ γ) ◁ g) ∘ᵥ α⇐ α⇐-▷-◁ {f = f} {γ = γ} {g = g} = ⊚-assoc.⇐.commute ((id₂ , γ) , id₂) α⇒-▷-∘₁ : α⇒ ∘ᵥ (f ∘₁ g) ▷ γ ≈ f ▷ g ▷ γ ∘ᵥ α⇒ α⇒-▷-∘₁{f = f} {g = g} {γ = γ} = begin α⇒ ∘ᵥ (f ⊚₀ g) ▷ γ ≈˘⟨ refl⟩∘⟨ ⊚.identity ⟩⊚⟨refl ⟩ α⇒ ∘ᵥ (f ▷ id₂) ⊚₁ γ ≈⟨ ⊚-assoc.⇒.commute ((id₂ , id₂) , γ) ⟩ f ▷ g ▷ γ ∘ᵥ α⇒ ∎ α⇐-▷-∘₁ : α⇐ ∘ᵥ (g ▷ (f ▷ γ)) ≈ ((g ∘₁ f) ▷ γ) ∘ᵥ α⇐ α⇐-▷-∘₁ = conjugate-from associator associator (⟺ α⇒-▷-∘₁) ◁-▷-exchg : ∀ {α : f ⇒₂ g} {β : h ⇒₂ i} → (i ▷ α) ∘ᵥ (β ◁ f) ≈ (β ◁ g) ∘ᵥ (h ▷ α) ◁-▷-exchg = [ ⊚ ]-commute triangle-iso : {f : A ⇒₁ B} {g : B ⇒₁ C} → (g ▷ᵢ unitorˡ ∘ᵢ associator) ≈ᵢ (unitorʳ ◁ᵢ f) triangle-iso = ⌞ triangle ⌟ triangle-inv : {f : A ⇒₁ B} {g : B ⇒₁ C} → α⇐ ∘ᵥ g ▷ λ⇐ ≈ ρ⇐ ◁ f triangle-inv = to-≈ triangle-iso pentagon-iso : ∀ {E} {f : A ⇒₁ B} {g : B ⇒₁ C} {h : C ⇒₁ D} {i : D ⇒₁ E} → (i ▷ᵢ associator ∘ᵢ associator ∘ᵢ associator ◁ᵢ f) ≈ᵢ (associator {f = i} {h} {g ∘₁ f} ∘ᵢ associator) pentagon-iso = ⌞ pentagon ⌟ pentagon-inv : ∀ {E} {f : A ⇒₁ B} {g : B ⇒₁ C} {h : C ⇒₁ D} {i : D ⇒₁ E} → (α⇐ ◁ f ∘ᵥ α⇐) ∘ᵥ i ▷ α⇐ ≈ α⇐ ∘ᵥ α⇐ {f = i} {h} {g ∘₁ f} pentagon-inv = to-≈ pentagon-iso module UnitorCoherence where -- Extra coherence laws for the unitors. -- -- These are similar to the extra coherence laws for monoidal -- categories that Kelly proved admissible in 1964. The proofs are -- largely the same. See Categories.Category.Monoidal.Properties -- for the monoidal versions and -- -- https://ncatlab.org/nlab/show/monoidal+category -- -- for an explanation of the proof and references to Kelly's paper. open ComHom -- As described on nLab, we start by proving that the 'perimeters' -- of two large diagrams commute... id▷λ-perimeter : [ ((id₁ ⊚₀ id₁) ⊚₀ f) ⊚₀ g ⇒ id₁ ⊚₀ (f ⊚₀ g) ]⟨ α⇒ ◁ g ⇒⟨ (id₁ ⊚₀ (id₁ ⊚₀ f)) ⊚₀ g ⟩ α⇒ ⇒⟨ id₁ ⊚₀ ((id₁ ⊚₀ f) ⊚₀ g) ⟩ id₁ ▷ α⇒ ⇒⟨ id₁ ⊚₀ (id₁ ⊚₀ (f ⊚₀ g)) ⟩ id₁ ▷ λ⇒ ≈ ρ⇒ ◁ f ◁ g ⇒⟨ (id₁ ⊚₀ f) ⊚₀ g ⟩ α⇒ ⟩ id▷λ-perimeter {f = f} {g = g} = begin id₁ ▷ λ⇒ ∘ᵥ id₁ ▷ α⇒ ∘ᵥ α⇒ ∘ᵥ α⇒ ◁ g ≈⟨ refl⟩∘⟨ pentagon ⟩ id₁ ▷ λ⇒ ∘ᵥ α⇒ ∘ᵥ α⇒ ≈⟨ pullˡ triangle ⟩ ρ⇒ ◁ (f ⊚₀ g) ∘ᵥ α⇒ ≈˘⟨ refl⟩⊚⟨ ⊚.identity ⟩∘⟨refl ⟩ ρ⇒ ⊚₁ (id₂ ◁ g) ∘ᵥ α⇒ ≈˘⟨ ⊚-assoc.⇒.commute _ ⟩ α⇒ ∘ᵥ ρ⇒ ◁ f ◁ g ∎ ρ◁id-perimeter : [ ((f ⊚₀ g) ⊚₀ id₁) ⊚₀ id₁ ⇒ f ⊚₀ (g ⊚₀ id₁) ]⟨ α⇒ ◁ id₁ ⇒⟨ (f ⊚₀ (g ⊚₀ id₁)) ⊚₀ id₁ ⟩ α⇒ ⇒⟨ f ⊚₀ ((g ⊚₀ id₁) ⊚₀ id₁) ⟩ f ▷ α⇒ ⇒⟨ f ⊚₀ (g ⊚₀ (id₁ ⊚₀ id₁)) ⟩ f ▷ g ▷ λ⇒ ≈ ρ⇒ ◁ id₁ ⇒⟨ (f ⊚₀ g) ⊚₀ id₁ ⟩ α⇒ ⟩ ρ◁id-perimeter {f = f} {g = g} = begin f ▷ g ▷ λ⇒ ∘ᵥ f ▷ α⇒ ∘ᵥ α⇒ ∘ᵥ α⇒ ◁ id₁ ≈⟨ refl⟩∘⟨ pentagon ⟩ f ▷ g ▷ λ⇒ ∘ᵥ α⇒ ∘ᵥ α⇒ ≈˘⟨ pushˡ (⊚-assoc.⇒.commute _) ⟩ (α⇒ ∘ᵥ (f ▷ id₂) ⊚₁ λ⇒) ∘ᵥ α⇒ ≈⟨ pullʳ (⊚.identity ⟩⊚⟨refl ⟩∘⟨refl) ⟩ α⇒ ∘ᵥ (f ⊚₀ g) ▷ λ⇒ ∘ᵥ α⇒ ≈⟨ refl⟩∘⟨ triangle ⟩ α⇒ ∘ᵥ ρ⇒ ◁ id₁ ∎ -- ... which allow us to prove that the following triangles commute... id▷λ-coherence : [ id₁ ⊚₀ ((id₁ ⊚₀ f) ⊚₀ g) ⇒ id₁ ⊚₀ (f ⊚₀ g) ]⟨ id₁ ▷ (λ⇒ ◁ g) ≈ id₁ ▷ α⇒ ⇒⟨ id₁ ⊚₀ (id₁ ⊚₀ (f ⊚₀ g)) ⟩ id₁ ▷ λ⇒ ⟩ id▷λ-coherence {f = f} {g = g} = begin id₁ ▷ (λ⇒ ◁ g) ≈⟨ switch-fromtoʳ associator (⟺ (⊚-assoc.⇒.commute _)) ⟩ (α⇒ ∘ᵥ (id₁ ▷ λ⇒) ◁ g) ∘ᵥ α⇐ ≈⟨ (refl⟩∘⟨ switch-fromtoʳ associator triangle ⟩⊚⟨refl) ⟩∘⟨refl ⟩ (α⇒ ∘ᵥ ((ρ⇒ ◁ f ∘ᵥ α⇐) ◁ g)) ∘ᵥ α⇐ ≈⟨ pushˡ (pushʳ (Functor.homomorphism (-⊚ g))) ⟩ (α⇒ ∘ᵥ ρ⇒ ◁ f ◁ g) ∘ᵥ (α⇐ ◁ g ∘ᵥ α⇐) ≈˘⟨ switch-fromtoʳ (associator ∘ᵢ (associator ⊚ᵢ idᵢ)) (hom.assoc ○ id▷λ-perimeter) ⟩ id₁ ▷ λ⇒ ∘ᵥ id₁ ▷ α⇒ ∎ ρ◁id-coherence : [ ((f ⊚₀ g) ⊚₀ id₁) ⊚₀ id₁ ⇒ (f ⊚₀ g) ⊚₀ id₁ ]⟨ ρ⇒ ◁ id₁ ≈ α⇒ ◁ id₁ ⇒⟨ (f ⊚₀ (g ⊚₀ id₁)) ⊚₀ id₁ ⟩ (f ▷ ρ⇒) ◁ id₁ ⟩ ρ◁id-coherence {f = f} {g = g} = begin ρ⇒ ◁ id₁ ≈⟨ switch-fromtoˡ associator (⟺ ρ◁id-perimeter) ⟩ α⇐ ∘ᵥ f ▷ g ▷ λ⇒ ∘ᵥ f ▷ α⇒ ∘ᵥ α⇒ ∘ᵥ α⇒ ◁ id₁ ≈˘⟨ pullʳ (pushˡ (Functor.homomorphism (f ⊚-))) ⟩ (α⇐ ∘ᵥ f ▷ (g ▷ λ⇒ ∘ᵥ α⇒)) ∘ᵥ α⇒ ∘ᵥ α⇒ ◁ id₁ ≈⟨ pullˡ (pushˡ (refl⟩∘⟨ refl⟩⊚⟨ triangle)) ⟩ (α⇐ ∘ᵥ f ▷ (ρ⇒ ◁ id₁) ∘ᵥ α⇒) ∘ᵥ α⇒ ◁ id₁ ≈˘⟨ switch-fromtoˡ associator (⊚-assoc.⇒.commute _) ⟩∘⟨refl ⟩ (f ▷ ρ⇒) ◁ id₁ ∘ᵥ α⇒ ◁ id₁ ∎ -- ... which are the results modulo (id₁ ⊚-) and (-⊚ id₁). unitorˡ-coherence : [ (id₁ ⊚₀ f) ⊚₀ g ⇒ f ⊚₀ g ]⟨ λ⇒ ◁ g ≈ α⇒ ⇒⟨ id₁ ⊚₀ (f ⊚₀ g) ⟩ λ⇒ ⟩ unitorˡ-coherence {f = f} {g = g} = push-eq unitˡ (begin id.F₁ _ ⊚₁ (λ⇒ ◁ g) ≈⟨ id.identity ⟩⊚⟨refl ⟩ id₁ ▷ (λ⇒ ◁ g) ≈⟨ id▷λ-coherence ⟩ id₁ ▷ λ⇒ ∘ᵥ id₁ ▷ α⇒ ≈˘⟨ Functor.homomorphism (id₁ ⊚-) ⟩ id₁ ▷ (λ⇒ ∘ᵥ α⇒) ≈˘⟨ id.identity ⟩⊚⟨refl ⟩ id.F₁ _ ⊚₁ (λ⇒ ∘ᵥ α⇒) ∎) unitorʳ-coherence : [ (f ⊚₀ g) ⊚₀ id₁ ⇒ f ⊚₀ g ]⟨ ρ⇒ ≈ α⇒ ⇒⟨ f ⊚₀ (g ⊚₀ id₁) ⟩ f ▷ ρ⇒ ⟩ unitorʳ-coherence {f = f} {g = g} = push-eq unitʳ (begin ρ⇒ ⊚₁ id.F₁ _ ≈⟨ refl⟩⊚⟨ id.identity ⟩ ρ⇒ ◁ id₁ ≈⟨ ρ◁id-coherence ⟩ (f ▷ ρ⇒) ◁ id₁ ∘ᵥ α⇒ ◁ id₁ ≈˘⟨ Functor.homomorphism (-⊚ id₁) ⟩ (f ▷ ρ⇒ ∘ᵥ α⇒) ◁ id₁ ≈˘⟨ refl⟩⊚⟨ id.identity ⟩ (f ▷ ρ⇒ ∘ᵥ α⇒) ⊚₁ id.F₁ _ ∎) open UnitorCoherence public using (unitorˡ-coherence; unitorʳ-coherence)
{ "alphanum_fraction": 0.4535173642, "avg_line_length": 33.8253012048, "ext": "agda", "hexsha": "0460206dc304ddd7e787a0df36f97239574337d8", "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": "8f3c844d929508040dfa21f681fa260056214b73", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "maxsnew/agda-categories", "max_forks_repo_path": "src/Categories/Bicategory/Extras.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "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": "maxsnew/agda-categories", "max_issues_repo_path": "src/Categories/Bicategory/Extras.agda", "max_line_length": 116, "max_stars_count": null, "max_stars_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "maxsnew/agda-categories", "max_stars_repo_path": "src/Categories/Bicategory/Extras.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6388, "size": 11230 }
------------------------------------------------------------------------------ -- Colists ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.Colist where open import FOTC.Base open import FOTC.Data.Colist.Type public
{ "alphanum_fraction": 0.3752860412, "avg_line_length": 31.2142857143, "ext": "agda", "hexsha": "374df8859f175afb4c466ed5546fc0edd650968a", "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/Colist.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/Colist.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Data/Colist.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": 67, "size": 437 }
module trie-fast where open import trie-core public open import string open import maybe open import char open import bool open import eq trie-lookup-fast3 : ∀{A : Set} → trie A → string → maybe A trie-lookup-fast3{A} t s = extract (stringFoldl f t s) where extract : trie A → maybe A extract (trie.Node x _) = x -- define an "empty trie" and change this to: -- (trie A) → char → (trie A) f : trie A → char → trie A f (Node _ ts) c with cal-lookup ts c f (Node _ ts) c | nothing = Node nothing empty-cal f (Node _ ts) c | just t = t trie-lookup : ∀{A : Set} → trie A → string → maybe A trie-lookup = trie-lookup-fast3 trie-insert-fast2 : ∀{A : Set} → trie A → string → A → trie A trie-insert-fast2{A} t s new-data = (stringFoldr g initial-f s) t where initial-f : trie A → trie A initial-f (Node _ ts) = Node (just new-data) ts g : char → (trie A → trie A) → (trie A → trie A) g c f (Node odata ts) with cal-lookup ts c g c f (Node odata ts) | nothing = Node odata (cal-add ts c (f empty-trie)) g c f (Node odata ts) | just t = Node odata (cal-insert ts c (f t)) trie-insert : ∀{A : Set} → trie A → string → A → trie A trie-insert = trie-insert-fast2 trie-remove-fast : ∀{A : Set} → trie A → string → trie A trie-remove-fast{A} t s = (stringFoldr g initial-f s) t where initial-f : trie A → trie A initial-f (Node _ ts) = Node nothing ts g : char → (trie A → trie A) → (trie A → trie A) g c f (Node odata ts) with cal-lookup ts c g c f (Node odata ts) | nothing = Node odata ts g c f (Node odata ts) | just t = Node odata (cal-insert ts c (f t)) trie-remove : ∀{A : Set} → trie A → string → trie A trie-remove = trie-remove-fast open import trie-functions trie-lookup trie-insert trie-remove public
{ "alphanum_fraction": 0.6308724832, "avg_line_length": 31.3684210526, "ext": "agda", "hexsha": "27f327f5d9f8a416bb9d6667d9b2d90f1db685af", "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": "trie-fast.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": "trie-fast.agda", "max_line_length": 77, "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": "trie-fast.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": 585, "size": 1788 }
module Lambda where -- The typed λ-calculus -- The type of types data ty : Set where ι : ty -- the base type _⇒_ : ty → ty → ty -- function type _×_ : ty → ty → ty -- product type infixr 7 _⇒_ infixl 8 _×_ -- A typing context, there are no variable names because we use de Bruijn indices. data ctx : Set where • : ctx -- empty context _,_ : ctx → ty → ctx -- context extension infixr 5 _,_ -- A variable is a natural number (de Bruijn index, position in the context), -- but at the same time a proof that a type appears in the context. -- We write Γ ∋ A for the type of variables in Γ of type A. data _∋_ : (Γ : ctx) (B : ty) → Set where Z : {Γ : ctx} {B : ty} → (Γ , B) ∋ B -- zero index S : {Γ : ctx} {A B : ty} → Γ ∋ B → (Γ , A) ∋ B -- successor index infix 4 _∋_ -- The type of terms in context Γ of type A data tm (Γ : ctx) : (A : ty) → Set where tm-var : {A : ty} → Γ ∋ A → tm Γ A tm-λ : {B : ty} {A : ty} → tm (Γ , A) B → tm Γ (A ⇒ B) tm-app : {A B : ty} → tm Γ (A ⇒ B) → tm Γ A → tm Γ B tm-pair : {A B : ty} → tm Γ A → tm Γ B → tm Γ (A × B) tm-fst : {A B : ty} → tm Γ (A × B) → tm Γ A tm-snd : {A B : ty} → tm Γ (A × B) → tm Γ B -- We need serveral boring auxiliary functions whose -- purpose is to define substitution -- A variable renaming is a type-preserving map from variables in Γ to variables in Δ -- (In Agda "renaming" is a reserved word.) variable-renaming = λ Γ Δ → ∀ {A} → Γ ∋ A → Δ ∋ A -- we may extend a renaming by one more variable (which does not get renamed) extend-renaming : ∀ {Γ Δ A} → variable-renaming Γ Δ → variable-renaming (Γ , A) (Δ , A) extend-renaming ρ Z = Z extend-renaming ρ (S x) = S (ρ x) -- the action of a renaming on a term term-rename : ∀ {Γ Δ} → variable-renaming Γ Δ → (∀ {A} → tm Γ A → tm Δ A) term-rename ρ (tm-var x) = tm-var (ρ x) term-rename ρ (tm-λ t) = tm-λ (term-rename (extend-renaming ρ) t) term-rename ρ (tm-app s t) = tm-app (term-rename ρ s) (term-rename ρ t) term-rename ρ (tm-pair s t) = tm-pair (term-rename ρ s) (term-rename ρ t) term-rename ρ (tm-fst t) = tm-fst (term-rename ρ t) term-rename ρ (tm-snd t) = tm-snd (term-rename ρ t) -- a special kind of renaming is weakening by a variable, which we write as ↑ ↑ : ∀ {Γ A B} → tm Γ A → tm (Γ , B) A ↑ = term-rename S -- a substitution from Γ to Δ takes variables in Γ to terms in Δ substitution = λ Γ Δ → (∀ {A} → Γ ∋ A → tm Δ A) extend-substutition : ∀ {Γ Δ A} → substitution Γ Δ → substitution (Γ , A) (Δ , A) extend-substutition σ Z = tm-var Z extend-substutition σ (S x) = ↑ (σ x) -- The action of a substitution on a term term-substitute : ∀ {Γ Δ} → substitution Γ Δ → ∀ {A} → tm Γ A → tm Δ A term-substitute σ (tm-var x) = σ x term-substitute σ (tm-λ t) = tm-λ (term-substitute (extend-substutition σ) t) term-substitute σ (tm-app s t) = tm-app (term-substitute σ s) (term-substitute σ t) term-substitute σ (tm-pair s t) = tm-pair (term-substitute σ s) (term-substitute σ t) term-substitute σ (tm-fst t) = tm-fst (term-substitute σ t) term-substitute σ (tm-snd t) = tm-snd (term-substitute σ t) -- Auxiliary substitution that replaces just the 0-th variable subst-Z : ∀ {Γ A} → tm Γ A → substitution (Γ , A) Γ subst-Z t Z = t subst-Z T (S x) = tm-var x -- A common kind of substitution only replaces the 0-th variable with a term -- and leaves all the others intact, so we define its action as a shorthand _[_] : ∀ {Γ A B} → tm (Γ , A) B → tm Γ A → tm Γ B _[_] {Γ} {A} {B} s t = term-substitute (subst-Z t) s where infix 5 _[_] -- Judgemental equality data _≡_ {Γ : ctx} : {A : ty} (t s : tm Γ A) → Set where -- general rules eq-refl : {A : ty} {t : tm Γ A} → t ≡ t eq-tran : {A : ty} {t s u : tm Γ A} → t ≡ s → s ≡ u → t ≡ u eq-sym : {A : ty} {t s : tm Γ A} → t ≡ s → s ≡ t -- congruence rules eq-congr-app : ∀ {A B} {t₁ t₂ : tm Γ (A ⇒ B)} {s₁ s₂ : tm Γ A} → t₁ ≡ t₂ → s₁ ≡ s₂ → tm-app t₁ s₁ ≡ tm-app t₂ s₂ eq-congr-λ : ∀ {A B} {t₁ t₂ : tm (Γ , A) B} → t₁ ≡ t₂ → tm-λ t₁ ≡ tm-λ t₂ eq-congr-pair : ∀ {A B} {t₁ t₂ : tm Γ (A ⇒ B)} {s₁ s₂ : tm Γ A} → t₁ ≡ t₂ → s₁ ≡ s₂ → tm-pair t₁ s₁ ≡ tm-pair t₂ s₂ eq-congr-fst : ∀ {A B} {s t : tm Γ (A × B)} → s ≡ t → tm-fst s ≡ tm-fst t eq-congr-snd : ∀ {A B} {s t : tm Γ (A × B)} → s ≡ t → tm-snd s ≡ tm-snd t -- function type rules eq-β : ∀ {A B} {t : tm (Γ , A) B} {s : tm Γ A} → tm-app (tm-λ t) s ≡ t [ s ] eq-⇒ : ∀ {A B} {s t : tm Γ (A ⇒ B)} → tm-app (↑ s) (tm-var Z) ≡ tm-app (↑ t) (tm-var Z) → s ≡ t -- product rules eq-fst : ∀ {A B} {u : tm Γ A} {v : tm Γ B} → tm-fst (tm-pair u v) ≡ u eq-snd : ∀ {A B} {u : tm Γ A} {v : tm Γ B} → tm-snd (tm-pair u v) ≡ v eq-× : ∀{A B} {s t : tm Γ (A × B)} → tm-fst s ≡ tm-fst t → tm-snd s ≡ tm-snd t → s ≡ t infix 4 _≡_ -- "η-equivalence" for products eq-pair-η : ∀ {Γ A B} {s : tm Γ (A × B)} → tm-pair (tm-fst s) (tm-snd s) ≡ s eq-pair-η = eq-× eq-fst eq-snd -- subst-↑ : ∀ {Γ A B} (t : tm Γ A) (s : tm Γ B) → (( (↑ t) [ s ] ) ≡ t) -- subst-↑ (tm-var x) s = eq-refl -- subst-↑ (tm-λ t) s = eq-congr-λ {!!} -- subst-↑ (tm-app t₁ t₂) s = eq-congr-app (subst-↑ t₁ s) (subst-↑ t₂ s) -- I commented this lemma that we tried to prove this morning because we did not achieve to do it yet, and Agda doesn't like the fact that I did not detail the other case of terms yet -- Example: the identity function -- Note that we actually define a family of terms, indexed by a context -- and a type, but the family is constant, i.e., it is always the same term. tm-id : ∀ {Γ A} → tm Γ (A ⇒ A) tm-id = tm-λ (tm-var Z) -- Appying the identity function twice does nothing app-id-id : ∀ {Γ A} {t : tm Γ A} → tm-app tm-id (tm-app tm-id t) ≡ t -- app-id-id = eq-tran (eq-congr-app eq-refl eq-β) eq-β app-id-id = eq-tran eq-β eq-β -- Eta-rule eq-η : ∀ {Γ A B} {t : tm Γ (A ⇒ B)} → tm-λ (tm-app (↑ t) (tm-var Z)) ≡ t eq-η = eq-⇒(eq-tran eq-β (eq-congr-app {!!} eq-refl)) -- natural numbers data N : Set where zero : N succ : N → N -- church numerals tm-numeral : ∀ {Γ} → N → tm Γ ((ι ⇒ ι) ⇒ (ι ⇒ ι)) tm-numeral zero = tm-id tm-numeral (succ n) = tm-λ (tm-λ (tm-app (tm-app (tm-numeral n) (tm-var (S Z))) (tm-app (tm-var (S Z)) (tm-var Z))))
{ "alphanum_fraction": 0.5455945779, "avg_line_length": 41.8838709677, "ext": "agda", "hexsha": "1556ffbe7a4c534a1f43f40917edd324fdbe4036", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z", "max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z", "max_forks_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/formaltt", "max_forks_repo_path": "src/Experimental/Lambda.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejbauer/formaltt", "max_issues_repo_path": "src/Experimental/Lambda.agda", "max_line_length": 185, "max_stars_count": 21, "max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cilinder/formaltt", "max_stars_repo_path": "src/Experimental/Lambda.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": 2562, "size": 6492 }
open import Prelude open import Nat open import core open import contexts module lemmas-gcomplete where -- if you add a complete type to a complete context, the result is also a -- complete context gcomp-extend : ∀{Γ τ x} → Γ gcomplete → τ tcomplete → x # Γ → (Γ ,, (x , τ)) gcomplete gcomp-extend {Γ} {τ} {x} gc tc apart x_query τ_query x₁ with natEQ x x_query gcomp-extend {Γ} {τ} {x} gc tc apart .x τ_query x₂ | Inl refl = tr (λ qq → qq tcomplete) (lem-apart-union-eq {Γ = Γ} apart x₂) tc gcomp-extend {Γ} {τ} {x} gc tc apart x_query τ_query x₂ | Inr x₁ = gc x_query τ_query (lem-neq-union-eq {Γ = Γ} (flip x₁) x₂ )
{ "alphanum_fraction": 0.6756329114, "avg_line_length": 48.6153846154, "ext": "agda", "hexsha": "8629285241163fbd6ff99461555dae0d2fea823b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-09-13T18:20:02.000Z", "max_forks_repo_forks_event_min_datetime": "2019-09-13T18:20:02.000Z", "max_forks_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-livelits-agda", "max_forks_repo_path": "lemmas-gcomplete.agda", "max_issues_count": 54, "max_issues_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_issues_repo_issues_event_max_datetime": "2018-11-29T16:32:40.000Z", "max_issues_repo_issues_event_min_datetime": "2017-06-29T20:53:34.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazel-palette-agda", "max_issues_repo_path": "lemmas-gcomplete.agda", "max_line_length": 131, "max_stars_count": 16, "max_stars_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazel-palette-agda", "max_stars_repo_path": "lemmas-gcomplete.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-19T02:50:23.000Z", "max_stars_repo_stars_event_min_datetime": "2018-03-12T14:32:03.000Z", "num_tokens": 231, "size": 632 }
------------------------------------------------------------------------ -- A definitional interpreter ------------------------------------------------------------------------ {-# OPTIONS --cubical --safe #-} module Lambda.Simplified.Partiality-monad.Inductive.Interpreter where open import Equality.Propositional.Cubical open import Prelude hiding (⊥) open import Bijection equality-with-J using (_↔_) open import Function-universe equality-with-J hiding (id; _∘_) open import Monad equality-with-J open import Univalence-axiom equality-with-J open import Vec.Function equality-with-J open import Partiality-monad.Inductive open import Partiality-monad.Inductive.Fixpoints open import Partiality-monad.Inductive.Monad open import Lambda.Simplified.Syntax open Closure Tm ------------------------------------------------------------------------ -- One interpreter module Interpreter₁ where -- This interpreter is defined as the least upper bound of a -- sequence of increasingly defined interpreters. infix 10 _∙_ mutual ⟦_⟧′ : ∀ {n} → Tm n → Env n → ℕ → Value ⊥ ⟦ var x ⟧′ ρ n = return (ρ x) ⟦ ƛ t ⟧′ ρ n = return (ƛ t ρ) ⟦ t₁ · t₂ ⟧′ ρ n = ⟦ t₁ ⟧′ ρ n >>= λ v₁ → ⟦ t₂ ⟧′ ρ n >>= λ v₂ → (v₁ ∙ v₂) n _∙_ : Value → Value → ℕ → Value ⊥ (ƛ t₁ ρ ∙ v₂) zero = never (ƛ t₁ ρ ∙ v₂) (suc n) = ⟦ t₁ ⟧′ (cons v₂ ρ) n mutual ⟦⟧′-increasing : ∀ {n} (t : Tm n) ρ n → ⟦ t ⟧′ ρ n ⊑ ⟦ t ⟧′ ρ (suc n) ⟦⟧′-increasing (var x) ρ n = return (ρ x) ■ ⟦⟧′-increasing (ƛ t) ρ n = return (ƛ t ρ) ■ ⟦⟧′-increasing (t₁ · t₂) ρ n = ⟦⟧′-increasing t₁ ρ n >>=-mono λ v₁ → ⟦⟧′-increasing t₂ ρ n >>=-mono λ v₂ → ∙-increasing v₁ v₂ n ∙-increasing : ∀ v₁ v₂ n → (v₁ ∙ v₂) n ⊑ (v₁ ∙ v₂) (suc n) ∙-increasing (ƛ t₁ ρ) v₂ (suc n) = ⟦⟧′-increasing t₁ (cons v₂ ρ) n ∙-increasing (ƛ t₁ ρ) v₂ zero = never ⊑⟨ never⊑ _ ⟩■ ⟦ t₁ ⟧′ (cons v₂ ρ) 0 ■ ⟦_⟧ˢ : ∀ {n} → Tm n → Env n → Increasing-sequence Value ⟦ t ⟧ˢ ρ = ⟦ t ⟧′ ρ , ⟦⟧′-increasing t ρ ⟦_⟧ : ∀ {n} → Tm n → Env n → Value ⊥ ⟦ t ⟧ ρ = ⨆ (⟦ t ⟧ˢ ρ) ------------------------------------------------------------------------ -- Another interpreter module Interpreter₂ where -- This interpreter is defined using a fixpoint combinator. M : Type → Type₁ M = Partial (∃ λ n → Tm n × Env n) (λ _ → Value) infix 10 _∙_ _∙_ : Value → Value → M Value ƛ t₁ ρ ∙ v₂ = rec (_ , t₁ , cons v₂ ρ) ⟦_⟧′ : ∀ {n} → Tm n → Env n → M Value ⟦ var x ⟧′ ρ = return (ρ x) ⟦ ƛ t ⟧′ ρ = return (ƛ t ρ) ⟦ t₁ · t₂ ⟧′ ρ = ⟦ t₁ ⟧′ ρ >>= λ v₁ → ⟦ t₂ ⟧′ ρ >>= λ v₂ → v₁ ∙ v₂ evalP : (∃ λ n → Tm n × Env n) → M Value evalP (_ , t , ρ) = ⟦ t ⟧′ ρ eval : Trans-⊑ (∃ λ n → Tm n × Env n) (λ _ → Value) eval = transformer evalP ⟦_⟧ : ∀ {n} → Tm n → Env n → Value ⊥ ⟦ t ⟧ ρ = fixP evalP (_ , t , ρ) ------------------------------------------------------------------------ -- The two interpreters are pointwise equal -- Both interpreters' bodies have the form ⨆ s for some sequences s, -- and element n in the first interpreter's sequence is equal to -- element 1 + n in the second interpreter's sequence (when the -- arguments are equal). interpreters-equal : ∀ {n} (t : Tm n) ρ → Interpreter₁.⟦ t ⟧ ρ ≡ Interpreter₂.⟦ t ⟧ ρ interpreters-equal = λ t ρ → $⟨ ⟦⟧-lemma t ρ ⟩ (∀ n → Interpreter₁.⟦ t ⟧′ ρ n ≡ app→ Interpreter₂.eval (suc n) (_ , t , ρ)) ↝⟨ cong ⨆ ∘ _↔_.to equality-characterisation-increasing ⟩ ⨆ (Interpreter₁.⟦ t ⟧ˢ ρ) ≡ ⨆ (tailˢ (at (fix→-sequence Interpreter₂.eval) (_ , t , ρ))) ↝⟨ flip trans (⨆tail≡⨆ _) ⟩ ⨆ (Interpreter₁.⟦ t ⟧ˢ ρ) ≡ ⨆ (at (fix→-sequence Interpreter₂.eval) (_ , t , ρ)) ↝⟨ id ⟩□ Interpreter₁.⟦ t ⟧ ρ ≡ Interpreter₂.⟦ t ⟧ ρ □ where open Partial open Trans-⊑ mutual ⟦⟧-lemma : ∀ {n} (t : Tm n) ρ n → Interpreter₁.⟦ t ⟧′ ρ n ≡ function (Interpreter₂.⟦ t ⟧′ ρ) (app→ Interpreter₂.eval n) ⟦⟧-lemma (var x) ρ n = refl ⟦⟧-lemma (ƛ t) ρ n = refl ⟦⟧-lemma (t₁ · t₂) ρ n = cong₂ _>>=_ (⟦⟧-lemma t₁ ρ n) $ ⟨ext⟩ λ v₁ → cong₂ _>>=_ (⟦⟧-lemma t₂ ρ n) $ ⟨ext⟩ λ v₂ → ∙-lemma v₁ v₂ n ∙-lemma : ∀ v₁ v₂ n → (v₁ Interpreter₁.∙ v₂) n ≡ function (v₁ Interpreter₂.∙ v₂) (app→ Interpreter₂.eval n) ∙-lemma (ƛ t₁ ρ) v₂ zero = refl ∙-lemma (ƛ t₁ ρ) v₂ (suc n) = ⟦⟧-lemma t₁ (cons v₂ ρ) n ------------------------------------------------------------------------ -- An example -- The semantics of Ω is the non-terminating computation never. -- A proof for Interpreter₁. Ω-loops₁ : Interpreter₁.⟦ Ω ⟧ nil ≡ never Ω-loops₁ = antisymmetry (least-upper-bound _ _ lemma) (never⊑ _) where open Interpreter₁ ω-nil = ƛ (var fzero · var fzero) nil reduce-twice : ∀ n → ⟦ Ω ⟧′ nil n ≡ (ω-nil ∙ ω-nil) n reduce-twice n = ⟦ Ω ⟧′ nil n ≡⟨ now->>= ⟩ (⟦ ω ⟧′ nil n >>= λ v₂ → (ω-nil ∙ v₂) n) ≡⟨ now->>= ⟩∎ (ω-nil ∙ ω-nil) n ∎ lemma : ∀ n → ⟦ Ω ⟧′ nil n ⊑ never lemma zero = ⟦ Ω ⟧′ nil zero ≡⟨ reduce-twice zero ⟩⊑ (ω-nil ∙ ω-nil) zero ⊑⟨⟩ never ■ lemma (suc n) = ⟦ Ω ⟧′ nil (suc n) ≡⟨ reduce-twice (suc n) ⟩⊑ ⟦ Ω ⟧′ nil n ⊑⟨ lemma n ⟩■ never ■ -- A direct proof for Interpreter₂. Ω-loops₂ : Interpreter₂.⟦ Ω ⟧ nil ≡ never Ω-loops₂ = antisymmetry (least-upper-bound _ _ lemma) (never⊑ _) module Ω-loops₂ where open Interpreter₂ open Trans-⊑ open Partial ω-nil = ƛ (var fzero · var fzero) nil reduce-twice : ∀ f → function eval f (_ , Ω , nil) ≡ f (_ , var fzero · var fzero , cons ω-nil nil) reduce-twice f = function eval f (_ , Ω , nil) ≡⟨⟩ function (⟦ Ω ⟧′ nil) f ≡⟨ cong {x = function (⟦ Ω ⟧′ nil)} (_$ f) (⟨ext⟩ λ _ → now->>=) ⟩ function (⟦ ω ⟧′ nil >>= λ v₂ → ω-nil ∙ v₂) f ≡⟨ cong {x = function (⟦ ω ⟧′ nil >>= ω-nil ∙_)} (_$ f) (⟨ext⟩ λ _ → now->>=) ⟩ function (ω-nil ∙ ω-nil) f ≡⟨⟩ f (_ , var fzero · var fzero , cons ω-nil nil) ∎ lemma : ∀ n → app→ eval n (_ , Ω , nil) ⊑ never lemma zero = never⊑ never lemma (suc zero) = app→ eval 1 (_ , Ω , nil) ≡⟨ reduce-twice _ ⟩⊑ app→ eval 0 (_ , Ω , nil) ⊑⟨⟩ never ■ lemma (suc (suc n)) = app→ eval (suc (suc n)) (_ , Ω , nil) ≡⟨ reduce-twice _ ⟩⊑ app→ eval (suc n) (_ , Ω , nil) ⊑⟨ lemma (suc n) ⟩■ never ■ -- Another proof for Interpreter₂. This proof uses Scott induction. Ω-loops₂′ : Interpreter₂.⟦ Ω ⟧ nil ≡ never Ω-loops₂′ = antisymmetry lemma (never⊑ _) where open Interpreter₂ open Trans-⊑ open Partial lemma = ⟦ Ω ⟧ nil ⊑⟨⟩ fixP evalP (_ , Ω , nil) ≡⟨ cong (_$ (_ , Ω , nil)) $ fixP-is-fixpoint-combinator evalP ⟩⊑ function eval (fixP evalP) (_ , Ω , nil) ⊑⟨ fixP-induction₁ (λ f → function eval f (_ , Ω , nil) ⊑ never) ( function eval (const never) (_ , Ω , nil) ≡⟨ Ω-loops₂.reduce-twice _ ⟩⊑ never ■) (λ s hyp → function eval (⨆ ∘ s) (_ , Ω , nil) ≡⟨ Ω-loops₂.reduce-twice _ ⟩⊑ ⨆ (s _) ⊑⟨ least-upper-bound _ _ (λ n → s _ [ n ] ≡⟨ sym $ Ω-loops₂.reduce-twice _ ⟩⊑ function eval (λ x → s x [ n ]) (_ , Ω , nil) ⊑⟨ hyp n ⟩■ never ■) ⟩ never ■) evalP (λ g hyp → function eval (function eval g) (_ , Ω , nil) ≡⟨ Ω-loops₂.reduce-twice _ ⟩⊑ function eval g (_ , Ω , nil) ⊑⟨ hyp ⟩■ never ■) ⟩■ never ■ ------------------------------------------------------------------------ -- Setup -- Let us use Interpreter₂ as the default interpreter. open Interpreter₂ public
{ "alphanum_fraction": 0.4333973562, "avg_line_length": 34.3062015504, "ext": "agda", "hexsha": "36680585d483a44c79750fd39b49cd543342d1f9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/partiality-monad", "max_forks_repo_path": "src/Lambda/Simplified/Partiality-monad/Inductive/Interpreter.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/partiality-monad", "max_issues_repo_path": "src/Lambda/Simplified/Partiality-monad/Inductive/Interpreter.agda", "max_line_length": 131, "max_stars_count": 2, "max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/partiality-monad", "max_stars_repo_path": "src/Lambda/Simplified/Partiality-monad/Inductive/Interpreter.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:08.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:59:18.000Z", "num_tokens": 3127, "size": 8851 }
module Elements where open import OscarPrelude open import Arity open import Vector open import Element record Elements : Set where constructor ⟨_⟩ field {arity} : Arity elements : Vector Element arity open Elements public instance EqElements : Eq Elements Eq._==_ EqElements (⟨_⟩ {𝑎₁} εs₁) (⟨_⟩ {𝑎₂} εs₂) with 𝑎₁ ≟ 𝑎₂ … | no 𝑎₁≢𝑎₂ = no λ {refl → 𝑎₁≢𝑎₂ refl} … | yes refl with εs₁ ≟ εs₂ … | yes refl = yes refl … | no εs₁≢εs₂ = no λ {refl → εs₁≢εs₂ refl}
{ "alphanum_fraction": 0.6757894737, "avg_line_length": 18.2692307692, "ext": "agda", "hexsha": "b441a8a483906b0d20b8754cb77104407ed497d5", "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-1/Elements.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-1/Elements.agda", "max_line_length": 48, "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-1/Elements.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 197, "size": 475 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Categories.DistLatticeSheaf.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Structure open import Cubical.Foundations.HLevels open import Cubical.Foundations.Powerset open import Cubical.Data.Sigma open import Cubical.Data.Nat using (ℕ) open import Cubical.Data.Nat.Order open import Cubical.Data.FinData open import Cubical.Data.FinData.Order open import Cubical.Relation.Binary.Poset open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing open import Cubical.Algebra.Semilattice open import Cubical.Algebra.Lattice open import Cubical.Algebra.DistLattice open import Cubical.Algebra.DistLattice.Basis open import Cubical.Algebra.DistLattice.BigOps open import Cubical.Categories.Category open import Cubical.Categories.Functor open import Cubical.Categories.NaturalTransformation open import Cubical.Categories.Limits.Pullback open import Cubical.Categories.Limits.Terminal open import Cubical.Categories.Limits.Limits open import Cubical.Categories.Limits.RightKan open import Cubical.Categories.Instances.Functors open import Cubical.Categories.Instances.CommRings open import Cubical.Categories.Instances.Poset open import Cubical.Categories.Instances.Semilattice open import Cubical.Categories.Instances.Lattice open import Cubical.Categories.Instances.DistLattice open import Cubical.Categories.DistLatticeSheaf.Diagram private variable ℓ ℓ' ℓ'' : Level module PreSheafExtension (L : DistLattice ℓ) (C : Category ℓ' ℓ'') (limitC : Limits {ℓ} {ℓ} C) (L' : ℙ (fst L)) where open Functor private DLCat = DistLatticeCategory L DLSubCat = ΣPropCat DLCat L' DLPreSheaf = Functor (DLCat ^op) C DLSubPreSheaf = Functor (DLSubCat ^op) C i : Functor DLSubCat DLCat F-ob i = fst F-hom i f = f F-id i = refl F-seq i _ _ = refl DLRan : DLSubPreSheaf → DLPreSheaf DLRan = Ran limitC (i ^opF) module _ (L : DistLattice ℓ) (C : Category ℓ' ℓ'') (T : Terminal C) where open Category hiding (_⋆_) open Functor open Order (DistLattice→Lattice L) open DistLatticeStr (snd L) open JoinSemilattice (Lattice→JoinSemilattice (DistLattice→Lattice L)) open MeetSemilattice (Lattice→MeetSemilattice (DistLattice→Lattice L)) using (∧≤RCancel ; ∧≤LCancel) open PosetStr (IndPoset .snd) hiding (_≤_) 𝟙 : ob C 𝟙 = terminalOb C T private DLCat : Category ℓ ℓ DLCat = DistLatticeCategory L open Category DLCat -- C-valued presheaves on a distributive lattice DLPreSheaf : Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'') DLPreSheaf = Functor (DLCat ^op) C module _ (x y : L .fst)where hom-∨₁ : DLCat [ x , x ∨l y ] hom-∨₁ = ∨≤RCancel _ _ hom-∨₂ : DLCat [ y , x ∨l y ] hom-∨₂ = ∨≤LCancel _ _ hom-∧₁ : DLCat [ x ∧l y , x ] hom-∧₁ = ≤m→≤j _ _ (∧≤RCancel _ _) hom-∧₂ : DLCat [ x ∧l y , y ] hom-∧₂ = ≤m→≤j _ _ (∧≤LCancel _ _) {- x ∧ y ----→ x | | | sq | V V y ----→ x ∨ y -} sq : hom-∧₂ ⋆ hom-∨₂ ≡ hom-∧₁ ⋆ hom-∨₁ sq = is-prop-valued (x ∧l y) (x ∨l y) (hom-∧₂ ⋆ hom-∨₂) (hom-∧₁ ⋆ hom-∨₁) {- F(x ∨ y) ----→ F(x) | | | Fsq | V V F(y) ------→ F(x ∧ y) -} Fsq : (F : DLPreSheaf) → F .F-hom hom-∨₂ ⋆⟨ C ⟩ F .F-hom hom-∧₂ ≡ F .F-hom hom-∨₁ ⋆⟨ C ⟩ F .F-hom hom-∧₁ Fsq F = F-square F sq isDLSheafPullback : (F : DLPreSheaf) → Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'') isDLSheafPullback F = (F-ob F 0l ≡ 𝟙) × ((x y : L .fst) → isPullback C _ _ _ (Fsq x y F)) -- TODO: might be better to define this as a record DLSheafPullback : Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'') DLSheafPullback = Σ[ F ∈ DLPreSheaf ] isDLSheafPullback F -- Now for the proper version using limits of the right kind: open Join L isDLSheaf : (F : DLPreSheaf) → Type _ isDLSheaf F = ∀ (n : ℕ) (α : FinVec (fst L) n) → isLimCone _ _ (F-cone F (⋁Cone L α)) --TODO: Equivalence of isDLSheaf and isDLSheafPullback module SheafOnBasis (L : DistLattice ℓ) (C : Category ℓ' ℓ'') (T : Terminal C) (L' : ℙ (fst L)) (hB : IsBasis L L') where open Category open Functor open DistLatticeStr ⦃...⦄ open SemilatticeStr ⦃...⦄ open IsBasis hB private DLCat = DistLatticeCategory L BasisCat = ΣPropCat DLCat L' DLBasisPreSheaf = Functor (BasisCat ^op) C -- to avoid writing 𝟙 L C T 1c : ob C 1c = terminalOb C T instance _ = snd L _ = snd (Basis→MeetSemilattice L L' hB) module condSquare (x y : ob BasisCat) (x∨y∈L' : fst x ∨l fst y ∈ L') where private x∨y : ob BasisCat -- = Σ[ x ∈ L ] (x ∈ L') x∨y = fst x ∨l fst y , x∨y∈L' {- x ∧ y ----→ x | | | sq | V V y ----→ x ∨ y but as a square in BasisCat -} Bsq : seq' BasisCat {x = x · y} {y = y} {z = x∨y} (hom-∧₂ L C T (fst x) (fst y)) (hom-∨₂ L C T (fst x) (fst y)) ≡ seq' BasisCat {x = x · y} {y = x} {z = x∨y} (hom-∧₁ L C T (fst x) (fst y)) (hom-∨₁ L C T (fst x) (fst y)) Bsq = sq L C T (fst x) (fst y) {- F(x ∨ y) ----→ F(x) | | | Fsq | V V F(y) ------→ F(x ∧ y) square in C but now F is only presheaf on BasisCat -} BFsq : (F : DLBasisPreSheaf) → seq' C {x = F .F-ob x∨y} {y = F .F-ob y} {z = F .F-ob (x · y)} (F .F-hom (hom-∨₂ L C T (fst x) (fst y))) (F .F-hom (hom-∧₂ L C T (fst x) (fst y))) ≡ seq' C {x = F .F-ob x∨y} {y = F .F-ob x} {z = F .F-ob (x · y)} (F .F-hom (hom-∨₁ L C T (fst x) (fst y))) (F .F-hom (hom-∧₁ L C T (fst x) (fst y))) BFsq F = F-square F Bsq -- On a basis this is weaker than the definition below! isDLBasisSheafPullback : DLBasisPreSheaf → Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'') isDLBasisSheafPullback F = ((0∈L' : 0l ∈ L') → F .F-ob (0l , 0∈L') ≡ 1c) × ((x y : ob BasisCat) (x∨y∈L' : fst x ∨l fst y ∈ L') → isPullback C _ _ _ (BFsq x y x∨y∈L' F)) where open condSquare DLBasisSheafPullback : Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'') DLBasisSheafPullback = Σ[ F ∈ DLBasisPreSheaf ] isDLBasisSheafPullback F -- the correct defintion open Join L module condCone {n : ℕ} (α : FinVec (ob BasisCat) n) (⋁α∈L' : ⋁ (λ i → α i .fst) ∈ L') where open JoinSemilattice (Lattice→JoinSemilattice (DistLattice→Lattice L)) open PosetStr (IndPoset .snd) hiding (_≤_) open MeetSemilattice (Lattice→MeetSemilattice (DistLattice→Lattice L)) using (∧≤RCancel ; ∧≤LCancel) open Order (DistLattice→Lattice L) open Cone private α' : FinVec (fst L) n α' i = α i .fst ⋁α : ob BasisCat ⋁α = ⋁ α' , ⋁α∈L' BDiag : Functor (DLShfDiag n) (BasisCat ^op) F-ob BDiag (sing i) = α i F-ob BDiag (pair i j _) = α i · α j -- α i ∧ α j + basis is closed under ∧ F-hom BDiag idAr = is-refl _ F-hom BDiag singPairL = ≤m→≤j _ _ (∧≤RCancel _ _) F-hom BDiag singPairR = ≤m→≤j _ _ (∧≤LCancel _ _) F-id BDiag = is-prop-valued _ _ _ _ F-seq BDiag _ _ = is-prop-valued _ _ _ _ B⋁Cone : Cone BDiag ⋁α coneOut B⋁Cone (sing i) = ind≤⋁ α' i coneOut B⋁Cone (pair i _ _) = is-trans _ (α' i) _ (≤m→≤j _ _ (∧≤RCancel _ _)) (ind≤⋁ α' i) coneOutCommutes B⋁Cone _ = is-prop-valued _ _ _ _ isDLBasisSheaf : DLBasisPreSheaf → Type _ isDLBasisSheaf F = ∀ {n : ℕ} (α : FinVec (ob BasisCat) n) (⋁α∈L' : ⋁ (λ i → α i .fst) ∈ L') → isLimCone _ _ (F-cone F (B⋁Cone α ⋁α∈L')) where open condCone -- To prove the statement we probably need that C is: -- 1. univalent -- 2. has finite limits (or pullbacks and a terminal object) -- 3. isGroupoid (C .ob) -- The last point is not strictly necessary, but we have to have some -- control over the hLevel as we want to write F(x) in terms of its -- basis cover which is information hidden under a prop truncation... -- Alternatively we just prove the statement for C = CommRingsCategory -- TODO: is unique existence expressed like this what we want? -- statement : (F' : DLBasisSheaf) -- → ∃![ F ∈ DLSheaf L C T ] ((x : fst L) → (x ∈ L') → CatIso C (F-ob (fst F) x) (F-ob (fst F') x)) -- TODO: if C is univalent the CatIso could be ≡? -- statement (F' , h1 , hPb) = ? -- It might be easier to prove all of these if we use the definition -- in terms of particular limits instead -- Scrap zone: -- -- Sublattices: upstream later -- record isSublattice (L' : ℙ (fst L)) : Type ℓ where -- field -- 1l-closed : 1l ∈ L' -- 0l-closed : 0l ∈ L' -- ∧l-closed : {x y : fst L} → x ∈ L' → y ∈ L' → x ∧l y ∈ L' -- ∨l-closed : {x y : fst L} → x ∈ L' → y ∈ L' → x ∨l y ∈ L' -- open isSublattice -- Sublattice : Type (ℓ-suc ℓ) -- Sublattice = Σ[ L' ∈ ℙ (fst L) ] isSublattice L' -- restrictDLSheaf : DLSheaf → Sublattice → DLSheaf -- F-ob (fst (restrictDLSheaf F (L' , HL'))) x = {!F-ob (fst F) x!} -- Hmm, not nice... -- F-hom (fst (restrictDLSheaf F L')) = {!!} -- F-id (fst (restrictDLSheaf F L')) = {!!} -- F-seq (fst (restrictDLSheaf F L')) = {!!} -- snd (restrictDLSheaf F L') = {!!}
{ "alphanum_fraction": 0.5796994073, "avg_line_length": 31.5986622074, "ext": "agda", "hexsha": "45948bd794e87bfc6a91ed421100baa946dc3c07", "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/Categories/DistLatticeSheaf/Base.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/Categories/DistLatticeSheaf/Base.agda", "max_line_length": 161, "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/Categories/DistLatticeSheaf/Base.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": 3571, "size": 9448 }
{- 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 -} -- This is a selection of useful functions and definitions -- from the standard library that we tend to use a lot. module LibraBFT.Prelude where open import Level renaming (suc to ℓ+1; zero to ℓ0; _⊔_ to _ℓ⊔_) public 1ℓ : Level 1ℓ = ℓ+1 0ℓ open import Agda.Builtin.Unit public open import Data.Unit.NonEta public open import Data.Empty public open import Data.Nat renaming (_≟_ to _≟ℕ_; _≤?_ to _≤?ℕ_) public open import Data.Nat.Properties hiding (≡-irrelevant) public open import Data.List renaming (map to List-map ; filter to List-filter ; lookup to List-lookup; tabulate to List-tabulate) hiding (fromMaybe; [_]) public open import Data.List.Properties renaming (≡-dec to List-≡-dec; length-map to List-length-map; map-compose to List-map-compose) using (∷-injective; length-++; map-++-commute; sum-++-commute; map-tabulate; ++-identityʳ) public open import Data.List.Relation.Binary.Subset.Propositional renaming (_⊆_ to _⊆List_) public open import Data.List.Relation.Unary.Any using (Any; here; there) renaming (lookup to Any-lookup; map to Any-map; satisfied to Any-satisfied ;index to Any-index; any to Any-any) public open import Data.List.Relation.Unary.Any.Properties using (¬Any[]) renaming ( map⁺ to Any-map⁺ ; map⁻ to Any-map⁻ ; concat⁺ to Any-concat⁺ ; concat⁻ to Any-concat⁻ ; ++⁻ to Any-++⁻ ; ++⁺ʳ to Any-++ʳ ; ++⁺ˡ to Any-++ˡ ; singleton⁻ to Any-singleton⁻ ; tabulate⁺ to Any-tabulate⁺ ) public open import Data.List.Relation.Unary.All using (All; []; _∷_) renaming (head to All-head; tail to All-tail; lookup to All-lookup; tabulate to All-tabulate; reduce to All-reduce) public open import Data.List.Relation.Unary.All.Properties renaming ( tabulate⁻ to All-tabulate⁻ ; tabulate⁺ to All-tabulate⁺ ; map⁺ to All-map⁺ ; map⁻ to All-map⁻ ) public open import Data.List.Membership.Propositional using (_∈_; _∉_) public open import Data.Vec using (Vec; []; _∷_) renaming (replicate to Vec-replicate; lookup to Vec-lookup ;map to Vec-map; head to Vec-head; tail to Vec-tail ;updateAt to Vec-updateAt; tabulate to Vec-tabulate ;allFin to Vec-allFin; toList to Vec-toList; fromList to Vec-fromList ;_++_ to _Vec-++_) public open import Data.Vec.Relation.Unary.All using ([]; _∷_) renaming (All to Vec-All; lookup to Vec-All-lookup) public open import Data.Vec.Properties using () renaming (updateAt-minimal to Vec-updateAt-minimal ;[]=⇒lookup to Vec-[]=⇒lookup ;lookup⇒[]= to Vec-lookup⇒[]= ;lookup∘tabulate to Vec-lookup∘tabulate ;≡-dec to Vec-≡-dec) public open import Data.List.Relation.Binary.Pointwise using (decidable-≡) public open import Data.Bool renaming (_≟_ to _≟Bool_) hiding (_≤?_; _<_; _<?_; _≤_) public open import Data.Maybe renaming (map to Maybe-map; zip to Maybe-zip ; _>>=_ to _Maybe->>=_) hiding (align; alignWith; zipWith) public open import Data.Maybe.Relation.Unary.Any renaming (Any to Maybe-Any; dec to Maybe-Any-dec) hiding (map; zip; zipWith; unzip ; unzipWith) public maybe-any-⊥ : ∀{a}{A : Set a} → Maybe-Any {A = A} (λ _ → ⊤) nothing → ⊥ maybe-any-⊥ () open import Data.Maybe.Properties using (just-injective) renaming (≡-dec to Maybe-≡-dec) public open import Data.Fin using (Fin; suc; zero; fromℕ; fromℕ< ; toℕ ; cast) renaming (_≟_ to _≟Fin_; _≤?_ to _≤?Fin_; _≤_ to _≤Fin_ ; _<_ to _<Fin_; inject₁ to Fin-inject₁; inject+ to Fin-inject+) public fins : (n : ℕ) → List (Fin n) fins n = Vec-toList (Vec-allFin n) open import Data.Fin.Properties using (toℕ-injective) renaming (<-cmp to Fin-<-cmp; <⇒≢ to <⇒≢Fin) public open import Relation.Binary.PropositionalEquality hiding (decSetoid) public open import Relation.Binary.HeterogeneousEquality using (_≅_) renaming (cong to ≅-cong; cong₂ to ≅-cong₂) public open import Relation.Binary public ≡-irrelevant : ∀{a}{A : Set a} → Irrelevant {a} {A} _≡_ ≡-irrelevant refl refl = refl to-witness-lemma : ∀{ℓ}{A : Set ℓ}{a : A}{f : Maybe A}(x : Is-just f) → to-witness x ≡ a → f ≡ just a to-witness-lemma (just x) refl = refl open import Data.Sum renaming ([_,_] to either; map to ⊎-map) public open import Function using (_∘_; id; case_of_; _on_; typeOf; flip; const) public open import Data.Product renaming (map to ×-map; map₂ to ×-map₂; map₁ to ×-map₁; <_,_> to split; swap to ×-swap) hiding (zip) public open import Data.Product.Properties public open import Relation.Nullary hiding (Irrelevant; proof) public open import Relation.Nullary.Decidable hiding (map) public infix 0 if-yes_then_else_ infix 0 if-dec_then_else_ if-yes_then_else_ : {A B : Set} → Dec A → (A → B) → (¬ A → B) → B if-yes (yes prf) then f else _ = f prf if-yes (no prf) then _ else g = g prf if-dec_then_else_ : {A B : Set} → Dec A → B → B → B if-dec x then f else g = if-yes x then const f else const g open import Relation.Nullary.Negation using (contradiction; contraposition) public open import Relation.Binary using (Setoid; IsPreorder) public -- Evidence that a function is not injective NonInjective : ∀{a b c}{A : Set a}{B : Set b} → (_≈_ : Rel A c) → (A → B) → Set (a ℓ⊔ b ℓ⊔ c) NonInjective {A = A} _≈_ f = Σ (A × A) (λ { (x₁ , x₂) → ¬ (x₁ ≈ x₂) × f x₁ ≡ f x₂ }) NonInjective-≡ : ∀{a b}{A : Set a}{B : Set b} → (A → B) → Set (a ℓ⊔ b) NonInjective-≡ = NonInjective _≡_ NonInjective-∘ : ∀{a b c}{A : Set a}{B : Set b}{C : Set c} → {f : A → B}(g : B → C) → NonInjective-≡ f → NonInjective-≡ (g ∘ f) NonInjective-∘ g ((x0 , x1) , (x0≢x1 , fx0≡fx1)) = ((x0 , x1) , x0≢x1 , (cong g fx0≡fx1)) -------------------------------------------- -- Handy fmap and bind for specific types -- _<M$>_ : ∀{a b}{A : Set a}{B : Set b} → (f : A → B) → Maybe A → Maybe B _<M$>_ = Maybe-map <M$>-univ : ∀{a b}{A : Set a}{B : Set b} → (f : A → B)(x : Maybe A) → {y : B} → f <M$> x ≡ just y → ∃[ x' ] (x ≡ just x' × f x' ≡ y) <M$>-univ f (just x) refl = x , (refl , refl) maybe-lift : {A : Set} → {mx : Maybe A}{x : A} → (P : A → Set) → P x → mx ≡ just x → maybe {B = const Set} P ⊥ mx maybe-lift {mx = just .x} {x} P px refl = px <M$>-nothing : ∀ {a b}{A : Set a}{B : Set b}(f : A → B) → f <M$> nothing ≡ nothing <M$>-nothing _ = refl _<⊎$>_ : ∀{a b c}{A : Set a}{B : Set b}{C : Set c} → (A → B) → C ⊎ A → C ⊎ B f <⊎$> (inj₁ hb) = inj₁ hb f <⊎$> (inj₂ x) = inj₂ (f x) _⊎⟫=_ : ∀{a b c}{A : Set a}{B : Set b}{C : Set c} → C ⊎ A → (A → C ⊎ B) → C ⊎ B (inj₁ x) ⊎⟫= _ = inj₁ x (inj₂ a) ⊎⟫= f = f a -- TODO-1: Maybe this belongs somewhere else? It's in a similar -- category as Optics, so maybe should similarly be in a module that -- is separate from the main project? ------------------ -- Guard Syntax -- -- -- Example Usage: -- -- > f : ℕ → ℕ -- > f x = grd‖ x ≟ℕ 10 ≔ 12 -- > ‖ otherwise≔ 40 + 2 -- -- -- > g : ℕ ⊎ ℕ → ℕ -- > g x = case x of λ -- > { (inj₁ x) → grd‖ x ≤? 10 ≔ 2 * x -- > ‖ otherwise≔ 42 -- > ; (inj₂ y) → y -- > } -- -- To type: ‖ --> \Vert -- ≔ --> \:= record ToBool {a}(A : Set a) : Set a where field toBool : A → Bool open ToBool {{ ... }} public instance ToBool-Bool : ToBool Bool ToBool-Bool = record { toBool = id } ToBool-Dec : ∀{a}{A : Set a} → ToBool (Dec A) ToBool-Dec = record { toBool = ⌊_⌋ } infix 3 _≔_ data GuardClause {a}(A : Set a) : Set (ℓ+1 a) where _≔_ : {B : Set a}{{ bb : ToBool B }} → B → A → GuardClause A infix 3 otherwise≔_ data Guards {a}(A : Set a) : Set (ℓ+1 a) where otherwise≔_ : A → Guards A clause : GuardClause A → Guards A → Guards A infixr 2 _‖_ _‖_ : ∀{a}{A : Set a} → GuardClause A → Guards A → Guards A _‖_ = clause infix 1 grd‖_ grd‖_ : ∀{a}{A : Set a} → Guards A → A grd‖_ (otherwise≔ a) = a grd‖_ (clause (b ≔ a) g) = if toBool b then a else (grd‖ g) Any-satisfied-∈ : ∀{a ℓ}{A : Set a}{P : A → Set ℓ}{xs : List A} → Any P xs → Σ A (λ x → P x × x ∈ xs) Any-satisfied-∈ (here px) = _ , (px , here refl) Any-satisfied-∈ (there p) = let (a , px , prf) = Any-satisfied-∈ p in (a , px , there prf) f-sum : ∀{a}{A : Set a} → (A → ℕ) → List A → ℕ f-sum f = sum ∘ List-map f open import LibraBFT.Base.Util public
{ "alphanum_fraction": 0.5479928353, "avg_line_length": 28.7606060606, "ext": "agda", "hexsha": "f0d37d60d0d6285ee905afb69a1ca9238b41c87d", "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": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "cwjnkins/bft-consensus-agda", "max_forks_repo_path": "LibraBFT/Prelude.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "cwjnkins/bft-consensus-agda", "max_issues_repo_path": "LibraBFT/Prelude.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "cwjnkins/bft-consensus-agda", "max_stars_repo_path": "LibraBFT/Prelude.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3360, "size": 9491 }
{-# OPTIONS --without-K --safe #-} module Math.NumberTheory.Product.Generic where -- agda-stdlib open import Algebra -- agda-misc open import Math.NumberTheory.Summation.Generic -- TODO add syntax module MonoidProduct {c e} (M : Monoid c e) = MonoidSummation M renaming ( Σ< to Π< ; Σ≤ to Π≤ ; Σ<range to Π<range ; Σ≤range to Π≤range ) using ()
{ "alphanum_fraction": 0.6712328767, "avg_line_length": 17.380952381, "ext": "agda", "hexsha": "f947b13ce1c4c6e07b06017f0dcbc8bb932566ca", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_path": "Math/NumberTheory/Product/Generic.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_path": "Math/NumberTheory/Product/Generic.agda", "max_line_length": 47, "max_stars_count": 3, "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_path": "Math/NumberTheory/Product/Generic.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "num_tokens": 127, "size": 365 }
postulate C : Set anything : C record I : Set where constructor c field f : C data Wrap : (j : I) → Set where wrap : ∀ {j} → Wrap j -- The following should not pass. -- It did before the fix of #142. issue142 : ∀ {j} → Wrap j → C issue142 {c _} (wrap {c _}) with anything issue142 {c _} (wrap .{c anything}) | z = z
{ "alphanum_fraction": 0.5958083832, "avg_line_length": 17.5789473684, "ext": "agda", "hexsha": "0b440622a834ebc918e67e41b54c081d6039c72d", "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/Issue1606.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/Issue1606.agda", "max_line_length": 43, "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/Issue1606.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 118, "size": 334 }
open import Relation.Unary using ( ∅ ; _∪_ ) open import Web.Semantic.DL.Signature using ( Signature ; CN ; RN ) open import Web.Semantic.Util using ( Subset ; ⁅_⁆ ) module Web.Semantic.DL.Role where data Role (Σ : Signature) : Set where ⟨_⟩ : (r : RN Σ) → Role Σ ⟨_⟩⁻¹ : (r : RN Σ) → Role Σ inv : ∀ {Σ} → Role Σ → Role Σ inv ⟨ r ⟩ = ⟨ r ⟩⁻¹ inv ⟨ r ⟩⁻¹ = ⟨ r ⟩
{ "alphanum_fraction": 0.5876010782, "avg_line_length": 26.5, "ext": "agda", "hexsha": "b6b3eec49aa7aa8541dd123d7c3b7526fa431822", "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/DL/Role.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/DL/Role.agda", "max_line_length": 67, "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/DL/Role.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": 154, "size": 371 }
{- 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.Lemmas open import LibraBFT.Base.PKCS open import LibraBFT.Base.Types import LibraBFT.Yasm.Base as LYB -- This module provides some definitions and properties that facilitate -- proofs of properties about a distributed system modeled by Yasm.System -- paramaterized by some SystemParameters. module LibraBFT.Yasm.Properties (ℓ-EC : Level) (EpochConfig : Set ℓ-EC) (epochId : EpochConfig → EpochId) (authorsN : EpochConfig → ℕ) (parms : LYB.SystemParameters ℓ-EC EpochConfig epochId authorsN) -- In addition to the parameters used by the rest of the system model, this module -- needs to relate Members to PKs and PeerIds, so that StepPeerState-AllValidParts -- can be defined. This enables the application to prove that honest peers sign -- new messages only for their own public key. The system model does not know that -- directly. (senderPKOK : (ec : EpochConfig) → PK → LYB.SystemParameters.PeerId parms → Set) where open LYB.SystemParameters parms open import LibraBFT.Yasm.AvailableEpochs PeerId ℓ-EC EpochConfig epochId authorsN using (AvailableEpochs) renaming (lookup'' to EC-lookup) import LibraBFT.Yasm.AvailableEpochs PeerId ℓ-EC EpochConfig epochId authorsN as AE open import LibraBFT.Yasm.Base ℓ-EC EpochConfig epochId authorsN open import LibraBFT.Yasm.System ℓ-EC EpochConfig epochId authorsN parms open import Util.FunctionOverride PeerId _≟PeerId_ -- A ValidPartForPK collects the assumptions about what a /part/ in the outputs of an honest verifier -- satisfies: (i) the epoch field is consistent with the existent epochs and (ii) the verifier is -- a member of the associated epoch config, and (iii) has the given PK in that epoch. record ValidSenderForPK {e}(𝓔s : AvailableEpochs e)(part : Part)(sender : PeerId)(pk : PK) : Set ℓ-EC where constructor mkValidSenderForPK field vp-epoch : part-epoch part < e vp-ec : EpochConfig vp-ec-≡ : AE.lookup'' 𝓔s vp-epoch ≡ vp-ec vp-sender-ok : senderPKOK vp-ec pk sender open ValidSenderForPK public -- A valid part remains valid when new epochs are added ValidSenderForPK-stable-epoch : ∀{e part α pk}{𝓔s : AvailableEpochs e}(𝓔 : EpochConfigFor e) → ValidSenderForPK 𝓔s part α pk → ValidSenderForPK (AE.append 𝓔 𝓔s) part α pk ValidSenderForPK-stable-epoch {pk = pk} {𝓔s = 𝓔s} 𝓔 (mkValidSenderForPK e ec refl vpk) = record { vp-epoch = ≤-step e ; vp-ec = ec ; vp-ec-≡ = AE.lookup''-≤-step-lemma 𝓔s 𝓔 e ; vp-sender-ok = vpk } -- A valid part remains valid ValidSenderForPK-stable : ∀{e e' α}{st : SystemState e}{st' : SystemState e'} → Step* st st' → ∀{part pk} → ValidSenderForPK (availEpochs st) part α pk → ValidSenderForPK (availEpochs st') part α pk ValidSenderForPK-stable step-0 v = v ValidSenderForPK-stable (step-s st (step-epoch 𝓔)) v = ValidSenderForPK-stable-epoch 𝓔 (ValidSenderForPK-stable st v) ValidSenderForPK-stable (step-s st (step-peer _)) v = ValidSenderForPK-stable st v sameEpoch⇒sameEC : ∀ {e p1 p2 α1 α2 pk1 pk2}{𝓔s : AvailableEpochs e} → (vp1 : ValidSenderForPK 𝓔s p1 α1 pk1) → (vp2 : ValidSenderForPK 𝓔s p2 α2 pk2) → part-epoch p1 ≡ part-epoch p2 → vp-ec vp1 ≡ vp-ec vp2 sameEpoch⇒sameEC {𝓔s = 𝓔s} vp1 vp2 parts≡ = trans (sym (vp-ec-≡ vp1)) (trans (AE.lookup-𝓔s-injective 𝓔s (vp-epoch vp1) (vp-epoch vp2) parts≡) (vp-ec-≡ vp2)) -- TODO-1 : prove it postulate ValidSenderForPK⇒ep≡ : ∀ {e p1 p2 α1 pk} {𝓔s : AvailableEpochs e} → WithVerSig pk p1 → WithVerSig pk p2 → part-epoch p1 ≡ part-epoch p2 → ValidSenderForPK 𝓔s p1 α1 pk → ValidSenderForPK 𝓔s p2 α1 pk -- We say that an implementation produces only valid parts iff all parts of every message in the -- output of a 'StepPeerState' are either: (i) a valid new part (i.e., the part is valid and no -- message with the same signature has been sent previously), or (ii) a message has been sent -- with the same signature. StepPeerState-AllValidParts : Set ℓ-EC StepPeerState-AllValidParts = ∀{e s m part pk initd' outs}{α}{𝓔s : AvailableEpochs e}{st : SystemState e} → (r : ReachableSystemState st) → Meta-Honest-PK pk → StepPeerState α 𝓔s (msgPool st) (initialised st) (peerStates st α) initd' (s , outs) → m ∈ outs → part ⊂Msg m → (ver : WithVerSig pk part) → (ValidSenderForPK 𝓔s part α pk × ¬ (MsgWithSig∈ pk (ver-signature ver) (msgPool st))) ⊎ MsgWithSig∈ pk (ver-signature ver) (msgPool st) -- A /part/ was introduced by a specific step when: IsValidNewPart : ∀{e e'}{pre : SystemState e}{post : SystemState e'} → Signature → PK → Step pre post → Set ℓ-EC IsValidNewPart _ _ (step-epoch _) = Lift (ℓ-EC) ⊥ -- said step is a /step-peer/ and IsValidNewPart {pre = pre} sig pk (step-peer {pid = pid} pstep) -- the part has never been seen before = ReachableSystemState pre × ¬ (MsgWithSig∈ pk sig (msgPool pre)) × Σ (MsgWithSig∈ pk sig (msgPool (StepPeer-post pstep))) (λ m → ValidSenderForPK (availEpochs pre) (msgPart m) (msgSender m) pk) -- When we can prove that the implementation provided by 'parms' at the -- top of this module satisfies 'StepPeerState-AllValidParts', we can -- prove a number of useful structural properties: -- TODO-2: Refactor into a file (LibraBFT.Yasm.Properties.Structural) later on -- if this grows too large. module Structural (sps-avp : StepPeerState-AllValidParts) where -- We can unwind the state and highlight the step where a part was -- originally sent. This 'unwind' function combined with Any-Step-elim -- enables a powerful form of reasoning. The 'honestVoteEpoch' below -- exemplifies this well. unwind : ∀{e}{st : SystemState e}(tr : ReachableSystemState st) → ∀{p m σ pk} → Meta-Honest-PK pk → p ⊂Msg m → (σ , m) ∈ msgPool st → (ver : WithVerSig pk p) → Any-Step (IsValidNewPart (ver-signature ver) pk) tr unwind (step-s tr (step-epoch _)) hpk p⊂m m∈sm sig = step-there (unwind tr hpk p⊂m m∈sm sig) unwind (step-s tr (step-peer {pid = β} {outs = outs} {pre = pre} sp)) hpk p⊂m m∈sm sig with Any-++⁻ (List-map (β ,_) outs) {msgPool pre} m∈sm ...| inj₂ furtherBack = step-there (unwind tr hpk p⊂m furtherBack sig) ...| inj₁ thisStep with sp ...| step-cheat fm isCheat with thisStep ...| here refl with isCheat p⊂m sig ...| inj₁ abs = ⊥-elim (hpk abs) ...| inj₂ sentb4 with unwind tr {p = msgPart sentb4} hpk (msg⊆ sentb4) (msg∈pool sentb4) (msgSigned sentb4) ...| res rewrite msgSameSig sentb4 = step-there res unwind (step-s tr (step-peer {pid = β} {outs = outs} {pre = pre} sp)) hpk p⊂m m∈sm sig | inj₁ thisStep | step-honest x with Any-satisfied-∈ (Any-map⁻ thisStep) ...| (m , refl , m∈outs) with sps-avp tr hpk x m∈outs p⊂m sig ...| inj₂ sentb4 with unwind tr {p = msgPart sentb4} hpk (msg⊆ sentb4) (msg∈pool sentb4) (msgSigned sentb4) ...| res rewrite msgSameSig sentb4 = step-there res unwind (step-s tr (step-peer {pid = β} {outs = outs} {pre = pre} sp)) {p} hpk p⊂m m∈sm sig | inj₁ thisStep | step-honest x | (m , refl , m∈outs) | inj₁ (valid-part , notBefore) = step-here tr (tr , notBefore , MsgWithSig∈-++ˡ (mkMsgWithSig∈ _ _ p⊂m β thisStep sig refl) , valid-part) -- Unwind is inconvenient to use by itself because we have to do -- induction on Any-Step-elim. The 'honestPartValid' property below -- provides a fairly general result conveniently: for every part -- verifiable with an honest PK, there is a msg with the same -- signature that is valid for some pid. honestPartValid : ∀ {e st} → ReachableSystemState {e} st → ∀ {pk nm v sender} → Meta-Honest-PK pk → v ⊂Msg nm → (sender , nm) ∈ msgPool st → (ver : WithVerSig pk v) → Σ (MsgWithSig∈ pk (ver-signature ver) (msgPool st)) (λ msg → (ValidSenderForPK (availEpochs st) (msgPart msg) (msgSender msg) pk)) honestPartValid {e} {st} r {pk = pk} hpk v⊂m m∈pool ver -- We extract two pieces of important information from the place where the part 'v' -- was first sent: (a) there is a message with the same signature /in the current pool/ -- and (b) its epoch is less than e. = Any-Step-elim (λ { {st = step-epoch _} () ; {st = step-peer {pid = pid} ps} (_ , _ , new , valid) tr → MsgWithSig∈-Step* tr new , ValidSenderForPK-stable tr (subst (λ P → ValidSenderForPK _ P (msgSender (MsgWithSig∈-Step* tr new)) pk) (MsgWithSig∈-Step*-part tr new) (subst (λ sndr → ValidSenderForPK _ _ sndr pk) (MsgWithSig∈-Step*-sender tr new) valid)) }) (unwind r hpk v⊂m m∈pool ver) -- Unforgeability is also an important property stating that every part that is -- verified with an honest public key has either been sent by α or is a replay -- of another message sent before. ext-unforgeability' : ∀{e α m part pk}{st : SystemState e} → ReachableSystemState st -- If a message m has been sent by α, containing part → (α , m) ∈ msgPool st → part ⊂Msg m -- And the part can be verified with an honest public key, → (sig : WithVerSig pk part) → Meta-Honest-PK pk -- then either the part is a valid part by α (meaning that α can -- sign the part itself) or a message with the same signature has -- been sent previously. → ValidSenderForPK (availEpochs st) part α pk ⊎ MsgWithSig∈ pk (ver-signature sig) (msgPool st) ext-unforgeability' (step-s st (step-epoch 𝓔)) m∈sm p⊆m sig hpk = ⊎-map (ValidSenderForPK-stable-epoch 𝓔) id (ext-unforgeability' st m∈sm p⊆m sig hpk) ext-unforgeability' {part = part} (step-s st (step-peer {pid = β} {outs = outs} {pre = pre} sp)) m∈sm p⊆m sig hpk with Any-++⁻ (List-map (β ,_) outs) {msgPool pre} m∈sm ...| inj₂ furtherBack = MsgWithSig∈-++ʳ <⊎$> (ext-unforgeability' st furtherBack p⊆m sig hpk) ...| inj₁ thisStep with sp ...| step-cheat fm isCheat with thisStep ...| here refl with isCheat p⊆m sig ...| inj₁ abs = ⊥-elim (hpk abs) ...| inj₂ sentb4 = inj₂ (MsgWithSig∈-++ʳ sentb4) ext-unforgeability' {α = α} {m = m} {part = part} (step-s st (step-peer {pid = β} {outs = outs} {pre = pre} sp)) m∈sm p⊆m sig hpk | inj₁ thisStep | step-honest x with Any-satisfied-∈ (Any-map⁻ thisStep) ...| (m , refl , m∈outs) = ⊎-map proj₁ MsgWithSig∈-++ʳ (sps-avp st hpk x m∈outs p⊆m sig) -- The ext-unforgeability' property can be collapsed in a single clause. -- TODO-2: so far, ext-unforgeability is used only to get a MsgWithSig∈ that is passed to -- msgWithSigSentByAuthor, which duplicates some of the reasoning in the proof of -- ext-unforgeability'; should these properties possibly be combined into one simpler proof? ext-unforgeability : ∀{e α₀ m part pk}{st : SystemState e} → ReachableSystemState st → (α₀ , m) ∈ msgPool st → part ⊂Msg m → (sig : WithVerSig pk part) → Meta-Honest-PK pk → MsgWithSig∈ pk (ver-signature sig) (msgPool st) ext-unforgeability {_} {α₀} {m} {st = st} rst m∈sm p⊂m sig hpk with ext-unforgeability' rst m∈sm p⊂m sig hpk ...| inj₁ p = mkMsgWithSig∈ _ _ p⊂m α₀ m∈sm sig refl ...| inj₂ sentb4 = sentb4 ¬cheatForgeNew : ∀ {e pid pk vsig mst outs m}{st : SystemState e} → (sp : StepPeer st pid mst outs) → outs ≡ m ∷ [] → (ic : isCheat sp) → Meta-Honest-PK pk → MsgWithSig∈ pk vsig ((pid , m) ∷ msgPool st) → MsgWithSig∈ pk vsig (msgPool st) ¬cheatForgeNew sc@(step-cheat fm isCheat) refl _ hpk mws with msg∈pool mws ...| there m∈pool = mkMsgWithSig∈ (msgWhole mws) (msgPart mws) (msg⊆ mws) (msgSender mws) m∈pool (msgSigned mws) (msgSameSig mws) ...| here m∈pool with isCheat (subst (msgPart mws ⊂Msg_) (cong proj₂ m∈pool) (msg⊆ mws)) (msgSigned mws) ...| inj₁ dis = ⊥-elim (hpk dis) ...| inj₂ mws' rewrite msgSameSig mws = mws' msgWithSigSentByAuthor : ∀ {e pk sig}{st : SystemState e} → ReachableSystemState st → Meta-Honest-PK pk → MsgWithSig∈ pk sig (msgPool st) → Σ (MsgWithSig∈ pk sig (msgPool st)) λ mws → ValidSenderForPK (availEpochs st) (msgPart mws) (msgSender mws) pk msgWithSigSentByAuthor step-0 _ () msgWithSigSentByAuthor (step-s {pre = pre} preach (step-epoch 𝓔)) hpk mws rewrite step-epoch-does-not-send pre 𝓔 with msgWithSigSentByAuthor preach hpk mws ...| mws' , vpb = mws' , ValidSenderForPK-stable {st = pre} (step-s step-0 (step-epoch 𝓔)) vpb msgWithSigSentByAuthor {pk = pk} (step-s {pre = pre} preach (step-peer theStep@(step-cheat fm cheatCons))) hpk mws with (¬cheatForgeNew theStep refl unit hpk mws) ...| mws' with msgWithSigSentByAuthor preach hpk mws' ...| mws'' , vpb'' = MsgWithSig∈-++ʳ mws'' , vpb'' msgWithSigSentByAuthor {e} (step-s {pre = pre} preach (step-peer {pid = pid} {outs = outs} (step-honest sps))) hpk mws with Any-++⁻ (List-map (pid ,_) outs) {msgPool pre} (msg∈pool mws) ...| inj₂ furtherBack with msgWithSigSentByAuthor preach hpk (MsgWithSig∈-transp mws furtherBack) ...| mws' , vpb' = MsgWithSig∈-++ʳ mws' , vpb' msgWithSigSentByAuthor {e} (step-s {pre = pre} preach (step-peer {pid = pid} {outs = outs} (step-honest sps))) hpk mws | inj₁ thisStep with Any-satisfied-∈ (Any-map⁻ thisStep) ...| (m' , refl , m∈outs) with sps-avp preach hpk sps m∈outs (msg⊆ mws) (msgSigned mws) ...| inj₁ (vpbα₀ , _) = mws , vpbα₀ ...| inj₂ mws' with msgWithSigSentByAuthor preach hpk mws' ...| mws'' , vpb'' rewrite sym (msgSameSig mws) = MsgWithSig∈-++ʳ mws'' , vpb'' newMsg⊎msgSentB4 : ∀ {e pk v m pid sndr st' outs} {st : SystemState e} → (r : ReachableSystemState st) → (stP : StepPeer st pid st' outs) → Meta-Honest-PK pk → (sig : WithVerSig pk v) → v ⊂Msg m → (sndr , m) ∈ msgPool (StepPeer-post stP) → (m ∈ outs × ValidSenderForPK (availEpochs st) v pid pk × ¬ (MsgWithSig∈ pk (ver-signature sig) (msgPool st))) ⊎ MsgWithSig∈ pk (ver-signature sig) (msgPool st) newMsg⊎msgSentB4 {e} {pk} {v} {m} {pid} {sndr} {_} {outs} {st} r stP pkH sig v⊂m m∈post with Any-++⁻ (List-map (pid ,_) outs) m∈post ...| inj₂ m∈preSt = inj₂ (mkMsgWithSig∈ m v v⊂m sndr m∈preSt sig refl) ...| inj₁ nm∈outs with Any-map (cong proj₂) (Any-map⁻ nm∈outs) ...| m∈outs with stP ...| step-honest stH with sps-avp r pkH stH m∈outs v⊂m sig ...| inj₁ newVote = inj₁ (m∈outs , newVote) ...| inj₂ msb4 = inj₂ msb4 newMsg⊎msgSentB4 {e} {pk} {v} {m} {pid} {sndr} {_} {outs} {st} r stP pkH sig v⊂m m∈post | inj₁ nm∈outs | here refl | step-cheat fm ic = let mws = mkMsgWithSig∈ m v v⊂m pid (here refl) sig refl in inj₂ (¬cheatForgeNew {st = st} (step-cheat fm ic) refl unit pkH mws) -- This could potentially be more general, for example covering the whole SystemState, rather than -- just one peer's state. However, this would put more burden on the user and is not required so -- far. CarrierProp : Set₁ CarrierProp = Part → PeerState → Set module _ (P : CarrierProp) where record PropCarrier (pk : PK) (sig : Signature) {e} (st : SystemState e) : Set (ℓ-EC ℓ⊔ (ℓ+1 0ℓ)) where constructor mkCarrier field carrStReach : ReachableSystemState st -- Enables use of invariants when proving that steps preserve carrProp carrSent : MsgWithSig∈ pk sig (msgPool st) carrValid : ValidSenderForPK (availEpochs st) (msgPart carrSent) (msgSender carrSent) pk carrProp : P (msgPart carrSent) (peerStates st (msgSender carrSent)) open PropCarrier public PeerStepPreserves : Set (ℓ+1 ℓ0 ℓ⊔ ℓ-EC) PeerStepPreserves = ∀ {e initd' ps' outs pk sig}{pre : SystemState e} → (r : ReachableSystemState pre) → (pc : PropCarrier pk sig {e} pre) → (sps : StepPeerState {e} (msgSender (carrSent pc)) (availEpochs pre) (msgPool pre) (initialised pre) (peerStates pre (msgSender (carrSent pc))) initd' (ps' , outs)) → P (msgPart (carrSent pc)) ps' module _ (PSP : PeerStepPreserves) where Carrier-transp : ∀ {e' e'' pk sig} {pre : SystemState e'}{post : SystemState e''} → (theStep : Step pre post) → PropCarrier pk sig pre → PropCarrier pk sig post Carrier-transp {pre = pre} {post} (step-epoch ec) (mkCarrier r mws vpk lvr) = mkCarrier (step-s r (step-epoch ec)) mws (ValidSenderForPK-stable-epoch ec vpk) lvr Carrier-transp {e' = e'} {pre = pre} {post} theStep@(step-peer {pid = pid} {st'} {pre = .pre} sps) pc@(mkCarrier r mws vpk prop) with step-s r theStep ...| postReach with sps ...| step-cheat fm isch = mkCarrier postReach (MsgWithSig∈-++ʳ mws) vpk (subst (λ ps → P (msgPart mws) (ps (msgSender mws))) (sym (cheatStepDNMPeerStates {pre = pre} (step-cheat fm isch) unit)) prop) -- PeerStates not changed by cheat steps ...| step-honest {st = st} sps' with msgSender mws ≟PeerId pid ...| no neq = mkCarrier postReach (MsgWithSig∈-++ʳ mws) vpk (subst (λ ps → P (msgPart mws) ps) (override-target-≢ {f = peerStates pre} neq) prop) ...| yes refl = mkCarrier postReach (MsgWithSig∈-++ʳ mws) vpk (subst (λ ps → P (msgPart mws) ps) (sym override-target-≡) (PSP r pc sps'))
{ "alphanum_fraction": 0.5915745291, "avg_line_length": 53.8181818182, "ext": "agda", "hexsha": "93d40e429814bbb99b0a6c651c1efed0d6fdb12e", "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/Yasm/Properties.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/Yasm/Properties.agda", "max_line_length": 138, "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/Yasm/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6122, "size": 19536 }
module Issue252 where data I : Set where zero : I data D : I → Set where c : ∀ i → D i → D i id : I → I id i = i index : ∀ i → D i → I index i _ = i foo : ∀ i → D i → D zero foo .i (c i d) with id i foo ._ (c i d) | zero = d bar : ∀ i → D i → D zero bar .i (c i d) with index i d bar ._ (c i d) | zero = d -- In the context of the first goal d has type D i′, in the second it -- has type D i. Well, not any more.
{ "alphanum_fraction": 0.5471698113, "avg_line_length": 16.96, "ext": "agda", "hexsha": "23f0bf5417b640cc0809fe15968f0279e8acb970", "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/Issue252.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/Issue252.agda", "max_line_length": 69, "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/Issue252.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": 166, "size": 424 }
module Thesis.SIRelBigStep.Normalization where open import Thesis.SIRelBigStep.Lang open import Data.Unit.Base hiding (_≤_) open import Data.Product open import Relation.Binary.PropositionalEquality -- Define logical relation for normalization. Adapted from TAPL Ch. 12. mutual normT : ∀ {Γ} τ (t : Term Γ τ) (ρ : ⟦ Γ ⟧Context) → Set normT τ t ρ = Σ[ v ∈ Val τ ] ρ ⊢ t ↓[ no ] v × normV τ v normV : ∀ τ (v : Val τ) → Set normV (σ ⇒ τ) (closure t ρ) = ∀ (v : Val σ) → (vv : normV _ v) → normT τ t (v • ρ) normV (pair τ1 τ2) (pairV v1 v2) = normV _ v1 × normV _ v2 normV nat (natV n) = ⊤ normρ : ∀ Γ (ρ : ⟦ Γ ⟧Context) → Set normρ ∅ ∅ = ⊤ normρ (τ • Γ) (v • ρ) = normV τ v × normρ Γ ρ ⟦_⟧VarNorm : ∀ {Γ τ} (x : Var Γ τ) {ρ} → normρ Γ ρ → normV τ (⟦ x ⟧Var ρ) ⟦ this ⟧VarNorm {v • ρ} (vv , ρρ) = vv ⟦ that x ⟧VarNorm {v • ρ} (vv , ρρ) = ⟦ x ⟧VarNorm ρρ -- Prove fundamental property. normT-fund : ∀ {τ Γ} (t : Term Γ τ) ρ (ρρ : normρ Γ ρ) → normT τ t ρ normV-fund-const : ∀ {τ} (c : Const τ) → normV τ (eval-const c) normV-fund-const (lit n) = tt normV-fund-sval : ∀ {τ Γ} (sv : SVal Γ τ) ρ (ρρ : normρ Γ ρ) → normV τ (eval sv ρ) normV-fund-sval (var x) ρ ρρ = ⟦ x ⟧VarNorm ρρ normV-fund-sval (abs t) ρ ρρ v vv = normT-fund t (v • ρ) (vv , ρρ) normV-fund-sval (cons sv1 sv2) ρ ρρ = normV-fund-sval sv1 ρ ρρ , normV-fund-sval sv2 ρ ρρ normV-fund-sval (const c) ρ ρρ = normV-fund-const c -- Not inlined because it gives the right type ascription to the derivation `val sv`. normT-fund-sval : ∀ {τ Γ} (sv : SVal Γ τ) ρ (ρρ : normρ Γ ρ) → normT τ (val sv) ρ normT-fund-sval sv ρ ρρ = eval sv ρ , val sv , normV-fund-sval sv ρ ρρ normV-fund-primitive : ∀ {σ τ} p → ∀ v → (vv : normV σ v) → normV τ (eval-primitive p v) normV-fund-primitive succ (natV n) vv = tt normV-fund-primitive add (pairV (natV m) (natV n)) vv = tt open import Data.Nat normT-fund (val sv) ρ ρρ = normT-fund-sval sv ρ ρρ normT-fund (primapp p sv) ρ ρρ = eval-primitive p (eval sv ρ) , primapp p sv , normV-fund-primitive p (eval sv ρ) (normV-fund-sval sv ρ ρρ) normT-fund (app vs vt) ρ ρρ with normT-fund-sval vs ρ ρρ | normT-fund-sval vt ρ ρρ ... | closure t ρ₁ , ↓fv , fvv | av , ↓av , avv with fvv av avv ... | v , ↓v , vv = v , app zero _ ↓fv ↓av ↓v , vv normT-fund (lett s t) ρ ρρ with normT-fund s ρ ρρ ... | sv , ↓s , svv with normT-fund t (sv • ρ) (svv , ρρ) ... | tv , ↓t , tvv = tv , lett zero zero sv s t ↓s ↓t , tvv -- Deduce from fundamental property that all terms indeed normalize. normalize : ∀ {τ} (t : Term ∅ τ) → Σ[ v ∈ Val τ ] ∅ ⊢ t ↓[ no ] v normalize t with normT-fund t ∅ tt ... | v , ↓ , _ = v , ↓
{ "alphanum_fraction": 0.6088448342, "avg_line_length": 39.7424242424, "ext": "agda", "hexsha": "9f8b45536987a7c0eea2b651aff75ba7f2f00d14", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_path": "Thesis/SIRelBigStep/Normalization.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_path": "Thesis/SIRelBigStep/Normalization.agda", "max_line_length": 139, "max_stars_count": 10, "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_path": "Thesis/SIRelBigStep/Normalization.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "num_tokens": 1159, "size": 2623 }
module Esterel.Environment where open import utility open import Data.Empty open import Esterel.Variable.Signal as Signal using (Signal ; _ₛ) open import Esterel.Variable.Shared as SharedVar using (SharedVar ; _ₛₕ) open import Esterel.Variable.Sequential as SeqVar using (SeqVar ; _ᵥ) open import Data.Product import Data.FiniteMap open import Data.Nat as Nat using (ℕ) open import Data.List as List using (List ; [] ; _∷_) open import Data.Sum using (_⊎_ ; inj₁ ; inj₂ ; [_,_]) open import Function using (_∘_) open import Relation.Nullary using (Dec ; yes ; no ; ¬_) open import Relation.Binary using (Decidable) open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; cong ; sym ; module ≡-Reasoning ; trans ; subst ; inspect) open import Data.List.Any using (Any) open ≡-Reasoning using (_≡⟨_⟩_ ; _≡⟨⟩_ ; _∎ ; begin_) module SigMap = Data.FiniteMap Signal.unwrap Signal.wrap Signal.unwrap-injective Signal.bijective module ShrMap = Data.FiniteMap SharedVar.unwrap SharedVar.wrap SharedVar.unwrap-injective SharedVar.bijective module VarMap = Data.FiniteMap SeqVar.unwrap SeqVar.wrap SeqVar.unwrap-injective SeqVar.bijective record Env : Set where constructor Θ field sig : SigMap.Map Signal.Status shr : ShrMap.Map (SharedVar.Status × ℕ) var : VarMap.Map ℕ open Env public -- A VarList is a three-tuple of lists of unwrapped signals, -- shared variables and sequential variables. VarList : Set VarList = List ℕ × List ℕ × List ℕ Dom : Env -> VarList Dom (Θ sig shr var) = (SigMap.keys sig) , (ShrMap.keys shr) , (VarMap.keys var) []env = Θ [] [] [] Sig∈ : (S : Signal) → (e : Env) → Relation.Nullary.Dec (Any (SigMap.inj= S) (SigMap.keys (sig e))) Sig∈ s e = SigMap.∈Check s (sig e) Shr∈ : (s : SharedVar) → (e : Env) → Relation.Nullary.Dec (Any (ShrMap.inj= s) (ShrMap.keys (shr e))) Shr∈ s e = ShrMap.∈Check s (shr e) Var∈ : (x : SeqVar) → (e : Env) → Relation.Nullary.Dec (Any (VarMap.inj= x) (VarMap.keys (var e))) Var∈ x e = VarMap.∈Check x (var e) isSig∈ : (S : Signal) → (e : Env) → Set isSig∈ S e = (SigMap.∈Dom S (sig e)) isShr∈ : SharedVar → Env → Set isShr∈ s e = ShrMap.∈Dom s (shr e) isVar∈ : SeqVar → Env → Set isVar∈ x e = VarMap.∈Dom x (var e) SigDomMap : ∀{a}{L : Set a} → (θ : Env) → (f : (S : Signal) → isSig∈ S θ → L) → List L SigDomMap = SigMap.key-map ∘ sig ShrDomMap : ∀{a}{L : Set a} → (θ : Env) → (f : (S : SharedVar) → isShr∈ S θ → L) → List L ShrDomMap = ShrMap.key-map ∘ shr SigDom : Env → List ℕ SigDom (Θ sig shr var) = (SigMap.keys sig) ShrDom : Env → List ℕ ShrDom (Θ sig shr var) = (ShrMap.keys shr) VarDom : Env → List ℕ VarDom (Θ sig shr var) = (VarMap.keys var) sig-stats : ∀{S} → (θ : Env) → (SigMap.∈Dom S (sig θ)) → Signal.Status sig-stats{S} θ S∈ = SigMap.lookup{k = S} (sig θ) S∈ shr-stats : ∀{s} → (θ : Env) → (ShrMap.∈Dom s (shr θ)) → SharedVar.Status shr-stats{s} θ s∈ = proj₁ (ShrMap.lookup{k = s} (shr θ) s∈) shr-vals : ∀{s} → (θ : Env) → (ShrMap.∈Dom s (shr θ)) → ℕ shr-vals{s} θ s∈ = proj₂ (ShrMap.lookup{k = s} (shr θ) s∈) var-vals : ∀{x} → (θ : Env) → (VarMap.∈Dom x (var θ)) → ℕ var-vals{x} θ x∈ = VarMap.lookup{k = x} (var θ) x∈ set-sig : ∀{S} → (θ : Env) → (SigMap.∈Dom S (sig θ)) → Signal.Status → Env set-sig{S} (Θ sig shr var) S∈ status = Θ (SigMap.update sig S status) shr var set-shr : ∀{s} → (θ : Env) → (ShrMap.∈Dom s (shr θ)) → SharedVar.Status → ℕ → Env set-shr{s} (Θ sig shr var) s∈ status n = Θ sig (ShrMap.update shr s (status , n)) var set-var : ∀{x} → (θ : Env) → (VarMap.∈Dom x (var θ)) → ℕ → Env set-var{x} (Θ sig shr var) x∈ n = Θ sig shr (VarMap.update var x n) _←_ : Env → Env → Env Θ sig₁ shr₁ seq₁ ← Θ sig₂ shr₂ seq₂ = Θ (SigMap.union sig₁ sig₂) (ShrMap.union shr₁ shr₂) (VarMap.union seq₁ seq₂) data EnvVar : Set where vsig : Signal → EnvVar vshr : SharedVar → EnvVar vvar : SeqVar → EnvVar data ∈map : EnvVar → Env → Set where ∈sig : ∀{S θ} → (isSig∈ S θ) → ∈map (vsig S) θ ∈shr : ∀{s θ} → (isShr∈ s θ) → ∈map (vshr s) θ ∈var : ∀{x θ} → (isVar∈ x θ) → ∈map (vvar x) θ -- thrms sig-set-mono' : ∀{S S' θ stat} → ∀{S'∈ : (isSig∈ S' θ)} → (isSig∈ S θ) → (isSig∈ S (set-sig{S'} θ S'∈ stat)) sig-set-mono'{S}{S'}{θ}{stat}{S'∈} i = SigMap.insert-mono{_}{k = S}{m = sig θ}{S'}{stat} i shr-set-mono' : ∀{s s' θ stat n} → ∀{s'∈ : (isShr∈ s' θ)} → (isShr∈ s θ) → (isShr∈ s (set-shr{s'} θ s'∈ stat n)) shr-set-mono'{s}{s'}{θ}{stat}{n}{s'∈} i = ShrMap.insert-mono{_}{k = s}{m = shr θ}{s'}{stat ,′ n} i seq-set-mono' : ∀{x x' θ n} → ∀{x'∈ : (isVar∈ x' θ)} → (isVar∈ x θ) → (isVar∈ x (set-var{x'} θ x'∈ n)) seq-set-mono'{x}{x'}{θ}{n}{x'∈} i = VarMap.insert-mono{_}{k = x}{m = var θ}{x'}{n} i sig-set-mono : ∀{V S' θ stat} → ∀{S'∈ : (isSig∈ S' θ)} → ∈map V θ → (∈map V (set-sig{S'} θ S'∈ stat)) sig-set-mono{S' = S'}{θ}{S'∈ = S'∈} (∈sig{S} x) = ∈sig{S} (sig-set-mono'{S = S}{S' = S'}{θ = θ}{S'∈ = S'∈} x) sig-set-mono (∈shr x) = ∈shr x sig-set-mono (∈var x₁) = ∈var x₁ shr-set-mono : ∀{V s' θ stat n} → ∀{s'∈ : (isShr∈ s' θ)} → (∈map V θ) → (∈map V (set-shr{s'} θ s'∈ stat n)) shr-set-mono (∈sig x) = ∈sig x shr-set-mono{s' = s'}{θ}{stat}{n}{s'∈}(∈shr{s} x) = ∈shr{s} (shr-set-mono'{s}{s'}{θ}{stat}{n}{s'∈} x) shr-set-mono (∈var x₁) = ∈var x₁ seq-set-mono : ∀{V x' θ n} → ∀{x'∈ : (isVar∈ x' θ)} → (∈map V θ) → (∈map V (set-var{x'} θ x'∈ n)) seq-set-mono (∈sig x) = ∈sig x seq-set-mono (∈shr x) = ∈shr x seq-set-mono{x' = x'}{θ}{n}{x'∈} (∈var{x} x₁) = ∈var {x} (seq-set-mono'{x}{x'}{θ}{n}{x'∈} x₁) ←-mono : ∀{θ θ' V} → ∈map V θ → ∈map V (θ ← θ') ←-mono{θ}{θ'}{vsig S} (∈sig x) = ∈sig{S}{(θ ← θ')} (SigMap.U-mono{_}{sig θ}{sig θ'}{S} x) ←-mono{θ}{θ'}{vshr s} (∈shr x) = ∈shr{s}{(θ ← θ')} (ShrMap.U-mono{_}{shr θ}{shr θ'}{s} x) ←-mono{θ}{θ'}{vvar x} (∈var x₁) = ∈var{x}{(θ ← θ')} (VarMap.U-mono{_}{var θ}{var θ'}{x} x₁) ←-comm : ∀ θ θ' → distinct (Dom θ) (Dom θ') → (θ ← θ') ≡ (θ' ← θ) ←-comm (Θ Ss ss xs) (Θ Ss' ss' xs') (Ss≠Ss' , ss≠ss' , xs≠xs') rewrite SigMap.union-comm Ss Ss' Ss≠Ss' | ShrMap.union-comm ss ss' ss≠ss' | VarMap.union-comm xs xs' xs≠xs' = refl ←-assoc : ∀ θ θ' θ'' → (θ ← (θ' ← θ'')) ≡ ((θ ← θ') ← θ'') ←-assoc (Θ Ss ss xs) (Θ Ss' ss' xs') (Θ Ss'' ss'' xs'') rewrite SigMap.union-assoc Ss Ss' Ss'' | ShrMap.union-assoc ss ss' ss'' | VarMap.union-assoc xs xs' xs'' = refl ←-assoc-comm : ∀ θ θ' θ'' → distinct (Dom θ') (Dom θ'') → ((θ ← θ') ← θ'') ≡ ((θ ← θ'') ← θ') ←-assoc-comm θ θ' θ'' Domθ'≠Domθ'' = (θ ← θ') ← θ'' ≡⟨ sym (←-assoc θ θ' θ'') ⟩ θ ← (θ' ← θ'') ≡⟨ cong (θ ←_) (←-comm θ' θ'' Domθ'≠Domθ'') ⟩ θ ← (θ'' ← θ') ≡⟨ ←-assoc θ θ'' θ' ⟩ (θ ← θ'') ← θ' ∎ Dom-←-assoc-comm : ∀ θ θ' θ'' → Dom ((θ ← θ') ← θ'') ≡ Dom ((θ ← θ'') ← θ') Dom-←-assoc-comm (Θ Ss ss xs) (Θ Ss' ss' xs') (Θ Ss'' ss'' xs'') rewrite SigMap.keys-assoc-comm Ss Ss' Ss'' | ShrMap.keys-assoc-comm ss ss' ss'' | VarMap.keys-assoc-comm xs xs' xs'' = refl Dom-←-comm : ∀ θ θ' → Dom (θ ← θ') ≡ Dom (θ' ← θ) Dom-←-comm θ θ' = Dom-←-assoc-comm []env θ θ' sig-←-monoʳ : ∀ S θ θ' → isSig∈ S θ → isSig∈ S (θ' ← θ) sig-←-monoʳ S θ θ' S∈Domθ rewrite cong proj₁ (Dom-←-comm θ' θ) = SigMap.U-mono {_} {Env.sig θ} {Env.sig θ'} {S} S∈Domθ shr-←-monoʳ : ∀ s θ θ' → isShr∈ s θ → isShr∈ s (θ' ← θ) shr-←-monoʳ s θ θ' s∈Domθ rewrite cong (proj₁ ∘ proj₂) (Dom-←-comm θ' θ) = ShrMap.U-mono {_} {Env.shr θ} {Env.shr θ'} {s} s∈Domθ seq-←-monoʳ : ∀ x θ θ' → isVar∈ x θ → isVar∈ x (θ' ← θ) seq-←-monoʳ x θ θ' x∈Domθ rewrite cong (proj₂ ∘ proj₂) (Dom-←-comm θ' θ) = VarMap.U-mono {_} {var θ} {var θ'} {x} x∈Domθ sig-←-monoˡ : ∀ S θ θ' → isSig∈ S θ → isSig∈ S (θ ← θ') sig-←-monoˡ S θ θ' S∈Domθ = SigMap.U-mono {_} {Env.sig θ} {Env.sig θ'} {S} S∈Domθ shr-←-monoˡ : ∀ s θ θ' → isShr∈ s θ → isShr∈ s (θ ← θ') shr-←-monoˡ s θ θ' s∈Domθ = ShrMap.U-mono {_} {Env.shr θ} {Env.shr θ'} {s} s∈Domθ seq-←-monoˡ : ∀ x θ θ' → isVar∈ x θ → isVar∈ x (θ ← θ') seq-←-monoˡ x θ θ' x∈Domθ = VarMap.U-mono {_} {var θ} {var θ'} {x} x∈Domθ sig-←⁻ : ∀ {θ₁ θ₂} S → isSig∈ S (θ₁ ← θ₂) → isSig∈ S θ₁ ⊎ isSig∈ S θ₂ sig-←⁻ {θ₁} {θ₂} S = SigMap.U⁻-m {Signal.Status} {sig θ₁} {sig θ₂} {S} shr-←⁻ : ∀ {θ₁ θ₂} s → isShr∈ s (θ₁ ← θ₂) → isShr∈ s θ₁ ⊎ isShr∈ s θ₂ shr-←⁻ {θ₁} {θ₂} s = ShrMap.U⁻-m {_} {shr θ₁} {shr θ₂} {s} seq-←⁻ : ∀ {θ₁ θ₂} x → isVar∈ x (θ₁ ← θ₂) → isVar∈ x θ₁ ⊎ isVar∈ x θ₂ seq-←⁻ {θ₁} {θ₂} x = VarMap.U⁻-m {_} {var θ₁} {var θ₂} {x} sig-↚⁻ : ∀ {θ₁ θ₂} S → ¬ isSig∈ S θ₁ → ¬ isSig∈ S θ₂ → ¬ isSig∈ S (θ₁ ← θ₂) sig-↚⁻ {θ₁} {θ₂} S S∉Domθ₁ S∉Domθ₂ = [ S∉Domθ₁ , S∉Domθ₂ ] ∘ sig-←⁻ {θ₁} {θ₂} S sig-stats-∈-irr : ∀{S θ} → (∈1 : (SigMap.∈Dom S (sig θ))) → (∈2 : (SigMap.∈Dom S (sig θ))) → sig-stats{S} θ ∈1 ≡ sig-stats{S} θ ∈2 sig-stats-∈-irr{S} {θ} ∈1 ∈2 = SigMap.lookup-∈-irr{k = S}{m = (sig θ)} ∈1 ∈2 shr-stats-∈-irr : ∀{s θ} → (∈1 : ShrMap.∈Dom s (shr θ)) → (∈2 : ShrMap.∈Dom s (shr θ)) → shr-stats{s} θ ∈1 ≡ shr-stats{s} θ ∈2 shr-stats-∈-irr{s}{θ} ∈1 ∈2 = cong proj₁ (ShrMap.lookup-∈-irr{k = s}{m = (shr θ)} ∈1 ∈2) shr-vals-∈-irr : ∀{s θ} → (∈1 : ShrMap.∈Dom s (shr θ)) → (∈2 : ShrMap.∈Dom s (shr θ)) → shr-vals{s} θ ∈1 ≡ shr-vals{s} θ ∈2 shr-vals-∈-irr{s}{θ} ∈1 ∈2 = cong proj₂ (ShrMap.lookup-∈-irr{k = s}{m = (shr θ)} ∈1 ∈2) var-vals-∈-irr : ∀{x θ} → (∈1 : VarMap.∈Dom x (var θ)) → (∈2 : VarMap.∈Dom x (var θ)) → var-vals{x} θ ∈1 ≡ var-vals{x} θ ∈2 var-vals-∈-irr{x} {θ} ∈1 ∈2 = VarMap.lookup-∈-irr{_}{x}{var θ} ∈1 ∈2 sig-←-∉-irr-stats' : ∀ S θ θ' → (S∈ : isSig∈ S θ) → (S∉ : ¬ isSig∈ S θ') → (S∈Dom⟨θ←θ'⟩ : isSig∈ S (θ ← θ')) → sig-stats {S} θ S∈ ≡ sig-stats {S} (θ ← θ') S∈Dom⟨θ←θ'⟩ sig-←-∉-irr-stats' S θ θ' S∈ S∉ S∈' = SigMap.U-∉-irr-get-help-m {_} {Env.sig θ} {Env.sig θ'} {S} S∈ S∉ S∈' sig-←-∉-irr-stats : ∀ S θ θ' → (S∈ : isSig∈ S θ) → (S∉ : ¬ isSig∈ S θ') → ∃ λ S∈Dom⟨θ←θ'⟩ → sig-stats {S} θ S∈ ≡ sig-stats {S} (θ ← θ') S∈Dom⟨θ←θ'⟩ sig-←-∉-irr-stats S θ θ' S∈ S∉ = SigMap.U-∉-irr-get-m {_} {Env.sig θ} {Env.sig θ'} {S} S∈ S∉ shr-←-∉-irr-stats' : ∀ s θ θ' → (s∈ : isShr∈ s θ) → (s∉ : ¬ isShr∈ s θ') → (s∈Dom⟨θ←θ'⟩ : isShr∈ s (θ ← θ')) → shr-stats {s} θ s∈ ≡ shr-stats {s} (θ ← θ') s∈Dom⟨θ←θ'⟩ shr-←-∉-irr-stats' s θ θ' s∈ s∉ s∈' rewrite ShrMap.U-∉-irr-get-help-m {_} {Env.shr θ} {Env.shr θ'} {s} s∈ s∉ s∈' = refl shr-←-∉-irr-stats : ∀ s θ θ' → (s∈ : isShr∈ s θ) → (s∉ : ¬ isShr∈ s θ') → ∃ λ s∈Dom⟨θ←θ'⟩ → shr-stats {s} θ s∈ ≡ shr-stats {s} (θ ← θ') s∈Dom⟨θ←θ'⟩ shr-←-∉-irr-stats s θ θ' s∈ s∉ rewrite proj₂ (ShrMap.U-∉-irr-get-m {_} {Env.shr θ} {Env.shr θ'} {s} s∈ s∉) = (_ , refl) shr-←-∉-irr-vals' : ∀ s θ θ' → (s∈ : isShr∈ s θ) → (s∉ : ¬ isShr∈ s θ') → (s∈Dom⟨θ←θ'⟩ : isShr∈ s (θ ← θ')) → shr-vals {s} θ s∈ ≡ shr-vals {s} (θ ← θ') s∈Dom⟨θ←θ'⟩ shr-←-∉-irr-vals' s θ θ' s∈ s∉ s∈' rewrite ShrMap.U-∉-irr-get-help-m {_} {Env.shr θ} {Env.shr θ'} {s} s∈ s∉ s∈' = refl shr-←-∉-irr-vals : ∀ s θ θ' → (s∈ : isShr∈ s θ) → (s∉ : ¬ isShr∈ s θ') → ∃ λ s∈Dom⟨θ←θ'⟩ → shr-vals {s} θ s∈ ≡ shr-vals {s} (θ ← θ') s∈Dom⟨θ←θ'⟩ shr-←-∉-irr-vals s θ θ' s∈ s∉ rewrite proj₂ (ShrMap.U-∉-irr-get-m {_} {Env.shr θ} {Env.shr θ'} {s} s∈ s∉) = (_ , refl) var-←-∉-irr-vals' : ∀ x θ θ' → (x∈ : isVar∈ x θ) → (x∉ : ¬ isVar∈ x θ') → (x∈Dom⟨θ←θ'⟩ : isVar∈ x (θ ← θ')) → var-vals {x} θ x∈ ≡ var-vals {x} (θ ← θ') x∈Dom⟨θ←θ'⟩ var-←-∉-irr-vals' x θ θ' x∈ x∉ x∈' = VarMap.U-∉-irr-get-help-m {_} {Env.var θ} {Env.var θ'} {x} x∈ x∉ x∈' var-←-∉-irr-vals : ∀ x θ θ' → (x∈ : isVar∈ x θ) → (x∉ : ¬ isVar∈ x θ') → ∃ λ x∈Dom⟨θ←θ'⟩ → var-vals {x} θ x∈ ≡ var-vals {x} (θ ← θ') x∈Dom⟨θ←θ'⟩ var-←-∉-irr-vals x θ θ' x∈ x∉ = VarMap.U-∉-irr-get-m {_} {Env.var θ} {Env.var θ'} {x} x∈ x∉ sig-stats-←-right-irr' : ∀ S θ θ' → (S∈ : isSig∈ S θ') → (S∈' : isSig∈ S (θ ← θ')) → sig-stats {S} (θ ← θ') S∈' ≡ sig-stats {S} θ' S∈ sig-stats-←-right-irr' S θ θ' S∈ S∈' = SigMap.get-U-right-irr-m S (Env.sig θ) (Env.sig θ') S∈' S∈ sig-stats-←-right-irr : ∀ S θ θ' → (S∈ : isSig∈ S θ') → ∃ λ S∈' → sig-stats {S} (θ ← θ') S∈' ≡ sig-stats {S} θ' S∈ sig-stats-←-right-irr S θ θ' S∈ = sig-←-monoʳ S θ' θ S∈ , SigMap.get-U-right-irr-m S (Env.sig θ) (Env.sig θ') (sig-←-monoʳ S θ' θ S∈) S∈ shr-stats-←-right-irr' : ∀ s θ θ' → (s∈ : isShr∈ s θ') → (s∈' : isShr∈ s (θ ← θ')) → shr-stats {s} (θ ← θ') s∈' ≡ shr-stats {s} θ' s∈ shr-stats-←-right-irr' s θ θ' s∈ s∈' rewrite ShrMap.get-U-right-irr-m s (Env.shr θ) (Env.shr θ') s∈' s∈ = refl shr-stats-←-right-irr : ∀ s θ θ' → (s∈ : isShr∈ s θ') → ∃ λ s∈' → shr-stats {s} (θ ← θ') s∈' ≡ shr-stats {s} θ' s∈ shr-stats-←-right-irr s θ θ' s∈ = shr-←-monoʳ s θ' θ s∈ , cong proj₁ (ShrMap.get-U-right-irr-m s (Env.shr θ) (Env.shr θ') (shr-←-monoʳ s θ' θ s∈) s∈) shr-vals-←-right-irr' : ∀ s θ θ' → (s∈ : isShr∈ s θ') → (s∈' : isShr∈ s (θ ← θ')) → shr-vals {s} (θ ← θ') s∈' ≡ shr-vals {s} θ' s∈ shr-vals-←-right-irr' s θ θ' s∈ s∈' rewrite ShrMap.get-U-right-irr-m s (Env.shr θ) (Env.shr θ') s∈' s∈ = refl shr-vals-←-right-irr : ∀ s θ θ' → (s∈ : isShr∈ s θ') → ∃ λ s∈' → shr-vals {s} (θ ← θ') s∈' ≡ shr-vals {s} θ' s∈ shr-vals-←-right-irr s θ θ' s∈ = shr-←-monoʳ s θ' θ s∈ , cong proj₂ (ShrMap.get-U-right-irr-m s (Env.shr θ) (Env.shr θ') (shr-←-monoʳ s θ' θ s∈) s∈) var-vals-←-right-irr' : ∀ x θ θ' → (x∈ : isVar∈ x θ') → (x∈' : isVar∈ x (θ ← θ')) → var-vals {x} (θ ← θ') x∈' ≡ var-vals {x} θ' x∈ var-vals-←-right-irr' x θ θ' x∈ x∈' = VarMap.get-U-right-irr-m x (Env.var θ) (Env.var θ') x∈' x∈ var-vals-←-right-irr : ∀ x θ θ' → (x∈ : isVar∈ x θ') → ∃ λ x∈' → var-vals {x} (θ ← θ') x∈' ≡ var-vals {x} θ' x∈ var-vals-←-right-irr x θ θ' x∈ = seq-←-monoʳ x θ' θ x∈ , VarMap.get-U-right-irr-m x (Env.var θ) (Env.var θ') (seq-←-monoʳ x θ' θ x∈) x∈ sig-stats-←-irr' : ∀ S θ θ' θ'' → (S∈ : isSig∈ S θ'') → (S∈' : isSig∈ S (θ ← θ'')) → (S∈'' : isSig∈ S (θ' ← θ'')) → sig-stats {S} (θ ← θ'') S∈' ≡ sig-stats {S} (θ' ← θ'') S∈'' sig-stats-←-irr' S θ θ' θ'' S∈ S∈' S∈'' = SigMap.∈-get-U-irr-m S (sig θ) (sig θ') (sig θ'') S∈' S∈'' S∈ sig-stats-←-irr : ∀ S θ θ' θ'' → (S∈ : isSig∈ S θ'') → ∃ λ S∈' → ∃ λ S∈'' → sig-stats {S} (θ ← θ'') S∈' ≡ sig-stats {S} (θ' ← θ'') S∈'' sig-stats-←-irr S θ θ' θ'' S∈ = sig-←-monoʳ S θ'' θ S∈ , sig-←-monoʳ S θ'' θ' S∈ , SigMap.∈-get-U-irr-m S (sig θ) (sig θ') (sig θ'') (sig-←-monoʳ S θ'' θ S∈) (sig-←-monoʳ S θ'' θ' S∈) S∈ shr-stats-←-irr' : ∀ s θ θ' θ'' → (s∈ : isShr∈ s θ'') → (s∈' : isShr∈ s (θ ← θ'')) → (s∈'' : isShr∈ s (θ' ← θ'')) → shr-stats {s} (θ ← θ'') s∈' ≡ shr-stats {s} (θ' ← θ'') s∈'' shr-stats-←-irr' s θ θ' θ'' s∈ s∈' s∈'' rewrite ShrMap.∈-get-U-irr-m s (shr θ) (shr θ') (shr θ'') s∈' s∈'' s∈ = refl shr-stats-←-irr : ∀ s θ θ' θ'' → (s∈ : isShr∈ s θ'') → ∃ λ s∈' → ∃ λ s∈'' → shr-stats {s} (θ ← θ'') s∈' ≡ shr-stats {s} (θ' ← θ'') s∈'' shr-stats-←-irr s θ θ' θ'' s∈ = shr-←-monoʳ s θ'' θ s∈ , shr-←-monoʳ s θ'' θ' s∈ , cong proj₁ (ShrMap.∈-get-U-irr-m s (shr θ) (shr θ') (shr θ'') (shr-←-monoʳ s θ'' θ s∈) (shr-←-monoʳ s θ'' θ' s∈) s∈) shr-vals-←-irr' : ∀ s θ θ' θ'' → (s∈ : isShr∈ s θ'') → (s∈' : isShr∈ s (θ ← θ'')) → (s∈'' : isShr∈ s (θ' ← θ'')) → shr-vals {s} (θ ← θ'') s∈' ≡ shr-vals {s} (θ' ← θ'') s∈'' shr-vals-←-irr' s θ θ' θ'' s∈ s∈' s∈'' rewrite ShrMap.∈-get-U-irr-m s (shr θ) (shr θ') (shr θ'') s∈' s∈'' s∈ = refl shr-vals-←-irr : ∀ s θ θ' θ'' → (s∈ : isShr∈ s θ'') → ∃ λ s∈' → ∃ λ s∈'' → shr-vals {s} (θ ← θ'') s∈' ≡ shr-vals {s} (θ' ← θ'') s∈'' shr-vals-←-irr s θ θ' θ'' s∈ = shr-←-monoʳ s θ'' θ s∈ , shr-←-monoʳ s θ'' θ' s∈ , cong proj₂ (ShrMap.∈-get-U-irr-m s (shr θ) (shr θ') (shr θ'') (shr-←-monoʳ s θ'' θ s∈) (shr-←-monoʳ s θ'' θ' s∈) s∈) var-vals-←-irr' : ∀ x θ θ' θ'' → (x∈ : isVar∈ x θ'') → (x∈' : isVar∈ x (θ ← θ'')) → (x∈'' : isVar∈ x (θ' ← θ'')) → var-vals {x} (θ ← θ'') x∈' ≡ var-vals {x} (θ' ← θ'') x∈'' var-vals-←-irr' x θ θ' θ'' x∈ x∈' x∈'' = VarMap.∈-get-U-irr-m x (var θ) (var θ') (var θ'') x∈' x∈'' x∈ var-vals-←-irr : ∀ x θ θ' θ'' → (x∈ : isVar∈ x θ'') → ∃ λ x∈' → ∃ λ x∈'' → var-vals {x} (θ ← θ'') x∈' ≡ var-vals {x} (θ' ← θ'') x∈'' var-vals-←-irr x θ θ' θ'' x∈ = seq-←-monoʳ x θ'' θ x∈ , seq-←-monoʳ x θ'' θ' x∈ , VarMap.∈-get-U-irr-m x (var θ) (var θ') (var θ'') (seq-←-monoʳ x θ'' θ x∈) (seq-←-monoʳ x θ'' θ' x∈) x∈ sig-stats-←-both-irr' : ∀ S θ θ' θ'' S∈ S∈' S∈Dom⟨θ←θ''⟩ S∈Dom⟨θ'←θ''⟩ → sig-stats {S} θ S∈ ≡ sig-stats {S} θ' S∈' → sig-stats {S} (θ ← θ'') S∈Dom⟨θ←θ''⟩ ≡ sig-stats {S} (θ' ← θ'') S∈Dom⟨θ'←θ''⟩ sig-stats-←-both-irr' S θ θ' θ'' S∈ S∈' S∈Dom⟨θ←θ''⟩ S∈Dom⟨θ'←θ''⟩ θS≡θ'S = SigMap.get-U-both-irr-m S (Env.sig θ) (Env.sig θ') (Env.sig θ'') S∈ S∈' S∈Dom⟨θ←θ''⟩ S∈Dom⟨θ'←θ''⟩ θS≡θ'S sig-stats-←-both-irr : ∀ S θ θ' θ'' S∈ S∈' → sig-stats {S} θ S∈ ≡ sig-stats {S} θ' S∈' → ∃ λ S∈Dom⟨θ←θ''⟩ → ∃ λ S∈Dom⟨θ'←θ''⟩ → sig-stats {S} (θ ← θ'') S∈Dom⟨θ←θ''⟩ ≡ sig-stats {S} (θ' ← θ'') S∈Dom⟨θ'←θ''⟩ sig-stats-←-both-irr S θ θ' θ'' S∈ S∈' θS≡θ'S = S∈Dom⟨θ←θ''⟩ , S∈Dom⟨θ'←θ''⟩ , SigMap.get-U-both-irr-m S (Env.sig θ) (Env.sig θ') (Env.sig θ'') S∈ S∈' S∈Dom⟨θ←θ''⟩ S∈Dom⟨θ'←θ''⟩ θS≡θ'S where S∈Dom⟨θ←θ''⟩ = sig-←-monoˡ S θ θ'' S∈ S∈Dom⟨θ'←θ''⟩ = sig-←-monoˡ S θ' θ'' S∈' shr-stats-←-both-irr' : ∀ s θ θ' θ'' s∈ s∈' s∈Dom⟨θ←θ''⟩ s∈Dom⟨θ'←θ''⟩ → shr-stats {s} θ s∈ ≡ shr-stats {s} θ' s∈' → shr-vals {s} θ s∈ ≡ shr-vals {s} θ' s∈' → shr-stats {s} (θ ← θ'') s∈Dom⟨θ←θ''⟩ ≡ shr-stats {s} (θ' ← θ'') s∈Dom⟨θ'←θ''⟩ shr-stats-←-both-irr' s θ θ' θ'' s∈ s∈' s∈Dom⟨θ←θ''⟩ s∈Dom⟨θ'←θ''⟩ proj₁θs≡proj₁θ's proj₂θs≡proj₂θ's = cong proj₁ (ShrMap.get-U-both-irr-m s (Env.shr θ) (Env.shr θ') (Env.shr θ'') s∈ s∈' s∈Dom⟨θ←θ''⟩ s∈Dom⟨θ'←θ''⟩ (prod-ind proj₁θs≡proj₁θ's proj₂θs≡proj₂θ's)) where prod-ind : {A B : Set} {x,y x',y' : A × B} → proj₁ x,y ≡ proj₁ x',y' → proj₂ x,y ≡ proj₂ x',y' → x,y ≡ x',y' prod-ind {_} {_} {x , y} {x' , y'} refl refl = refl shr-stats-←-both-irr : ∀ s θ θ' θ'' s∈ s∈' → shr-stats {s} θ s∈ ≡ shr-stats {s} θ' s∈' → shr-vals {s} θ s∈ ≡ shr-vals {s} θ' s∈' → ∃ λ s∈Dom⟨θ←θ''⟩ → ∃ λ s∈Dom⟨θ'←θ''⟩ → shr-stats {s} (θ ← θ'') s∈Dom⟨θ←θ''⟩ ≡ shr-stats {s} (θ' ← θ'') s∈Dom⟨θ'←θ''⟩ shr-stats-←-both-irr s θ θ' θ'' s∈ s∈' proj₁θs≡proj₁θ's proj₂θs≡proj₂θ's = s∈Dom⟨θ←θ''⟩ , s∈Dom⟨θ'←θ''⟩ , cong proj₁ (ShrMap.get-U-both-irr-m s (Env.shr θ) (Env.shr θ') (Env.shr θ'') s∈ s∈' s∈Dom⟨θ←θ''⟩ s∈Dom⟨θ'←θ''⟩ (prod-ind proj₁θs≡proj₁θ's proj₂θs≡proj₂θ's)) where s∈Dom⟨θ←θ''⟩ = shr-←-monoˡ s θ θ'' s∈ s∈Dom⟨θ'←θ''⟩ = shr-←-monoˡ s θ' θ'' s∈' prod-ind : {A B : Set} {x,y x',y' : A × B} → proj₁ x,y ≡ proj₁ x',y' → proj₂ x,y ≡ proj₂ x',y' → x,y ≡ x',y' prod-ind {_} {_} {x , y} {x' , y'} refl refl = refl shr-vals-←-both-irr' : ∀ s θ θ' θ'' s∈ s∈' s∈Dom⟨θ←θ''⟩ s∈Dom⟨θ'←θ''⟩ → shr-stats {s} θ s∈ ≡ shr-stats {s} θ' s∈' → shr-vals {s} θ s∈ ≡ shr-vals {s} θ' s∈' → shr-vals {s} (θ ← θ'') s∈Dom⟨θ←θ''⟩ ≡ shr-vals {s} (θ' ← θ'') s∈Dom⟨θ'←θ''⟩ shr-vals-←-both-irr' s θ θ' θ'' s∈ s∈' s∈Dom⟨θ←θ''⟩ s∈Dom⟨θ'←θ''⟩ proj₁θs≡proj₁θ's proj₂θs≡proj₂θ's = cong proj₂ (ShrMap.get-U-both-irr-m s (Env.shr θ) (Env.shr θ') (Env.shr θ'') s∈ s∈' s∈Dom⟨θ←θ''⟩ s∈Dom⟨θ'←θ''⟩ (prod-ind proj₁θs≡proj₁θ's proj₂θs≡proj₂θ's)) where prod-ind : {A B : Set} {x,y x',y' : A × B} → proj₁ x,y ≡ proj₁ x',y' → proj₂ x,y ≡ proj₂ x',y' → x,y ≡ x',y' prod-ind {_} {_} {x , y} {x' , y'} refl refl = refl shr-vals-←-both-irr : ∀ s θ θ' θ'' s∈ s∈' → shr-stats {s} θ s∈ ≡ shr-stats {s} θ' s∈' → shr-vals {s} θ s∈ ≡ shr-vals {s} θ' s∈' → ∃ λ s∈Dom⟨θ←θ''⟩ → ∃ λ s∈Dom⟨θ'←θ''⟩ → shr-vals {s} (θ ← θ'') s∈Dom⟨θ←θ''⟩ ≡ shr-vals {s} (θ' ← θ'') s∈Dom⟨θ'←θ''⟩ shr-vals-←-both-irr s θ θ' θ'' s∈ s∈' proj₁θs≡proj₁θ's proj₂θs≡proj₂θ's = s∈Dom⟨θ←θ''⟩ , s∈Dom⟨θ'←θ''⟩ , cong proj₂ (ShrMap.get-U-both-irr-m s (Env.shr θ) (Env.shr θ') (Env.shr θ'') s∈ s∈' s∈Dom⟨θ←θ''⟩ s∈Dom⟨θ'←θ''⟩ (prod-ind proj₁θs≡proj₁θ's proj₂θs≡proj₂θ's)) where s∈Dom⟨θ←θ''⟩ = shr-←-monoˡ s θ θ'' s∈ s∈Dom⟨θ'←θ''⟩ = shr-←-monoˡ s θ' θ'' s∈' prod-ind : {A B : Set} {x,y x',y' : A × B} → proj₁ x,y ≡ proj₁ x',y' → proj₂ x,y ≡ proj₂ x',y' → x,y ≡ x',y' prod-ind {_} {_} {x , y} {x' , y'} refl refl = refl var-vals-←-both-irr' : ∀ x θ θ' θ'' x∈ x∈' x∈Dom⟨θ←θ''⟩ x∈Dom⟨θ'←θ''⟩ → var-vals {x} θ x∈ ≡ var-vals {x} θ' x∈' → var-vals {x} (θ ← θ'') x∈Dom⟨θ←θ''⟩ ≡ var-vals {x} (θ' ← θ'') x∈Dom⟨θ'←θ''⟩ var-vals-←-both-irr' x θ θ' θ'' x∈ x∈' x∈Dom⟨θ←θ''⟩ x∈Dom⟨θ'←θ''⟩ θx≡θ'x = VarMap.get-U-both-irr-m x (Env.var θ) (Env.var θ') (Env.var θ'') x∈ x∈' x∈Dom⟨θ←θ''⟩ x∈Dom⟨θ'←θ''⟩ θx≡θ'x var-vals-←-both-irr : ∀ x θ θ' θ'' x∈ x∈' → var-vals {x} θ x∈ ≡ var-vals {x} θ' x∈' → ∃ λ x∈Dom⟨θ←θ''⟩ → ∃ λ x∈Dom⟨θ'←θ''⟩ → var-vals {x} (θ ← θ'') x∈Dom⟨θ←θ''⟩ ≡ var-vals {x} (θ' ← θ'') x∈Dom⟨θ'←θ''⟩ var-vals-←-both-irr x θ θ' θ'' x∈ x∈' θx≡θ'x = S∈Dom⟨θ←θ''⟩ , S∈Dom⟨θ'←θ''⟩ , VarMap.get-U-both-irr-m x (Env.var θ) (Env.var θ') (Env.var θ'') x∈ x∈' S∈Dom⟨θ←θ''⟩ S∈Dom⟨θ'←θ''⟩ θx≡θ'x where S∈Dom⟨θ←θ''⟩ = seq-←-monoˡ x θ θ'' x∈ S∈Dom⟨θ'←θ''⟩ = seq-←-monoˡ x θ' θ'' x∈' sig-putputget : ∀{S S' θ stat1 stat2} → ¬ S ≡ S' → (∈1 : SigMap.∈Dom S (sig θ)) → (∈S' : SigMap.∈Dom S' (sig θ)) → (∈2 : SigMap.∈Dom S (sig (set-sig{S'} θ ∈S' stat2))) → sig-stats{S} θ ∈1 ≡ stat1 → sig-stats{S} (set-sig{S'} θ ∈S' stat2) ∈2 ≡ stat1 sig-putputget {θ = θ} neq ∈1 ∈S' ∈2 eq = SigMap.putputget {m = (sig θ)} neq ∈1 ∈2 eq sig-putputget/m : ∀{S S' θ stat2} → ¬ S ≡ S' → (∈1 : SigMap.∈Dom S (sig θ)) → (∈S' : SigMap.∈Dom S' (sig θ)) → (∈2 : SigMap.∈Dom S (sig (set-sig{S'} θ ∈S' stat2))) → sig-stats{S} (set-sig{S'} θ ∈S' stat2) ∈2 ≡ sig-stats{S} θ ∈1 sig-putputget/m {S}{S'}{θ} neq ∈1 ∈S' ∈2 with sig-stats{S} θ ∈1 | inspect (sig-stats{S} θ) ∈1 sig-putputget/m {S} {S'} {θ} neq ∈1 ∈S' ∈2 | k | Relation.Binary.PropositionalEquality.[ eq ] = SigMap.putputget {m = (sig θ)} neq ∈1 ∈2 eq shr-putputget : ∀{s s' θ v1l v1r v2l v2r} → ¬ s ≡ s' → (∈1 : ShrMap.∈Dom s (shr θ)) → (∈s' : ShrMap.∈Dom s' (shr θ)) → (∈2 : ShrMap.∈Dom s (shr (set-shr{s'} θ ∈s' v2l v2r))) → shr-stats{s} θ ∈1 ≡ v1l → shr-vals{s} θ ∈1 ≡ v1r → (shr-stats{s} (set-shr{s'} θ ∈s' v2l v2r) ∈2) ≡ v1l × (shr-vals{s} (set-shr{s'} θ ∈s' v2l v2r) ∈2) ≡ v1r shr-putputget {θ = θ}{v1l}{v1r}{v2l}{v2r} neq ∈1 ∈S' ∈2 refl refl with ShrMap.putputget {m = (shr θ)}{v = (v1l ,′ v1r)}{(v2l ,′ v2r)} neq ∈1 ∈2 refl ... | res = (cong proj₁ res) ,′ (cong proj₂ res) seq-putputget : ∀{x x' θ v1 v2} → ¬ x ≡ x' → (∈1 : VarMap.∈Dom x (var θ)) → (∈x' : VarMap.∈Dom x' (var θ)) → (∈2 : VarMap.∈Dom x (var (set-var{x'} θ ∈x' v2))) → var-vals{x} θ ∈1 ≡ v1 → var-vals{x} (set-var{x'} θ ∈x' v2) ∈2 ≡ v1 seq-putputget {θ = θ} neq ∈1 ∈x' ∈2 eq = VarMap.putputget {m = (var θ)} neq ∈1 ∈2 eq sig-getput : ∀ {θ} S → (S∈ : isSig∈ S θ) → θ ≡ set-sig {S} θ S∈ (sig-stats {S} θ S∈) sig-getput {θ} S S∈ rewrite sym (SigMap.getput-m S (Env.sig θ) S∈) = refl shr-getput : ∀ {θ} s → (s∈ : isShr∈ s θ) → θ ≡ set-shr {s} θ s∈ (shr-stats {s} θ s∈) (shr-vals {s} θ s∈) shr-getput {θ} s s∈ rewrite sym (ShrMap.getput-m s (Env.shr θ) s∈) = refl var-getput : ∀ {θ} x → (x∈ : isVar∈ x θ) → θ ≡ set-var {x} θ x∈ (var-vals {x} θ x∈) var-getput {θ} x x∈ rewrite sym (VarMap.getput-m x (Env.var θ) x∈) = refl sig-putget : ∀{S θ stat} → (∈1 : SigMap.∈Dom S (sig θ)) → (∈2 : SigMap.∈Dom S (sig (set-sig{S} θ ∈1 stat))) → (sig-stats{S} (set-sig{S} θ ∈1 stat) ∈2) ≡ stat sig-putget {S}{θ}{stat} ∈1 ∈2 = SigMap.putget-m{_}{(sig θ)}{S}{stat} ∈2 shr-putget : ∀{s θ stat n} → (∈1 : ShrMap.∈Dom s (shr θ)) → (∈2 : ShrMap.∈Dom s (shr (set-shr{s} θ ∈1 stat n))) → (shr-stats{s} (set-shr{s} θ ∈1 stat n) ∈2) ≡ stat × (shr-vals{s} (set-shr{s} θ ∈1 stat n) ∈2) ≡ n shr-putget {s}{θ}{stat}{n} ∈1 ∈2 with ShrMap.putget-m{_}{(shr θ)}{s}{stat ,′ n} ∈2 ... | eq rewrite eq = refl , refl shr-putput-overwrite : ∀ s θ stat1 n1 stat2 n2 → (∈1 : (isShr∈ s θ)) → (∈2 : isShr∈ s (set-shr{s} θ ∈1 stat1 n1)) → (set-shr{s} (set-shr{s} θ ∈1 stat1 n1) ∈2 stat2 n2) ≡ (set-shr{s} θ ∈1 stat2 n2) shr-putput-overwrite s θ stat1 n1 stat2 n2 _ _ rewrite ShrMap.putput-overwrite (shr θ) s (stat1 ,′ n1) (stat2 ,′ n2) = refl sig-set-←-← : ∀ S v θ θ' → (S∈Domθ : isSig∈ S θ) → (S∈Domθ' : isSig∈ S θ') → θ ← θ' ≡ (set-sig {S} θ S∈Domθ v) ← θ' sig-set-←-← S v θ θ' S∈Domθ S∈Domθ' rewrite SigMap.update-union-union S v (Env.sig θ) (Env.sig θ') S∈Domθ S∈Domθ' = refl shr-set-←-← : ∀ s v n θ θ' → (s∈Domθ : isShr∈ s θ) → (s∈Domθ' : isShr∈ s θ') → θ ← θ' ≡ (set-shr {s} θ s∈Domθ v n) ← θ' shr-set-←-← s v n θ θ' s∈Domθ s∈Domθ' rewrite ShrMap.update-union-union s (v , n) (Env.shr θ) (Env.shr θ') s∈Domθ s∈Domθ' = refl var-set-←-← : ∀ x v θ θ' → (x∈Domθ : isVar∈ x θ) → (x∈Domθ' : isVar∈ x θ') → θ ← θ' ≡ (set-var {x} θ x∈Domθ v) ← θ' var-set-←-← x v θ θ' x∈Domθ x∈Domθ' rewrite VarMap.update-union-union x v (Env.var θ) (Env.var θ') x∈Domθ x∈Domθ' = refl sig∈-eq : ∀{S θ} → (∈1 : SigMap.∈Dom S (sig θ)) → (∈2 : SigMap.∈Dom S (sig θ)) → ∈1 ≡ ∈2 sig∈-eq {S}{θ} ∈1 ∈2 = SigMap.ineq-m{_}{S}{sig θ} ∈1 ∈2 shr∈-eq : ∀{s θ} → (∈1 : ShrMap.∈Dom s (shr θ)) → (∈2 : ShrMap.∈Dom s (shr θ)) → ∈1 ≡ ∈2 shr∈-eq {s}{θ} ∈1 ∈2 = ShrMap.ineq-m{_}{s}{shr θ} ∈1 ∈2 seq∈-eq : ∀{x θ} → (∈1 : VarMap.∈Dom x (var θ)) → (∈2 : VarMap.∈Dom x (var θ)) → ∈1 ≡ ∈2 seq∈-eq {x}{θ} ∈1 ∈2 = VarMap.ineq-m{_}{x}{var θ} ∈1 ∈2 sig∈-eq' : ∀{S θ} → (∈1 : SigMap.∈Dom{Signal.Status} S θ) → (∈2 : SigMap.∈Dom S θ) → ∈1 ≡ ∈2 sig∈-eq' {S}{θ} ∈1 ∈2 = SigMap.ineq-m{_}{S}{θ} ∈1 ∈2 shr∈-eq' : ∀{s θ} → (∈1 : ShrMap.∈Dom{(SharedVar.Status × ℕ)} s θ) → (∈2 : ShrMap.∈Dom s θ) → ∈1 ≡ ∈2 shr∈-eq' {s}{θ} ∈1 ∈2 = ShrMap.ineq-m{_}{s}{θ} ∈1 ∈2 seq∈-eq' : ∀{x : SeqVar} {θ : VarMap.Map ℕ} → (∈1 : VarMap.∈Dom{ℕ} x θ) → (∈2 : VarMap.∈Dom x θ) → ∈1 ≡ ∈2 seq∈-eq' {x}{θ} ∈1 ∈2 = VarMap.ineq-m{_}{x}{θ} ∈1 ∈2 sig-set-comm : ∀{θ S1 S2 stat1 stat2} → (S1∈ : isSig∈ S1 θ) → (S2∈ : isSig∈ S2 θ) → ¬ S1 ≡ S2 → ∃ λ S1∈' → ∃ λ S2∈' → (set-sig{S2} (set-sig{S1} θ S1∈ stat1) S2∈' stat2) ≡ (set-sig{S1} (set-sig{S2} θ S2∈ stat2) S1∈' stat1) sig-set-comm{θ}{S1}{S2}{stat1}{stat2} S1∈ S2∈ ¬S1≡S2 rewrite SigMap.put-comm{_}{sig θ}{S1}{S2}{stat1}{stat2} ¬S1≡S2 = sig-set-mono'{S1}{S2}{θ}{stat2}{S2∈} S1∈ , sig-set-mono'{S2}{S1}{θ}{S'∈ = S1∈} S2∈ , refl shr-set-comm : ∀ θ s1 s2 stat1 n1 stat2 n2 → (s1∈ : isShr∈ s1 θ) → (s2∈ : isShr∈ s2 θ) → ¬ s1 ≡ s2 → ∃ λ s1∈' → ∃ λ s2∈' → (set-shr{s2} (set-shr{s1} θ s1∈ stat1 n1) s2∈' stat2 n2) ≡ (set-shr{s1} (set-shr{s2} θ s2∈ stat2 n2) s1∈' stat1 n1) shr-set-comm θ s1 s2 stat1 n1 stat2 n2 s1∈ s2∈ ¬s1≡s2 rewrite ShrMap.put-comm{_}{shr θ}{s1}{s2}{stat1 , n1}{stat2 , n2} ¬s1≡s2 = shr-set-mono'{s1}{s2}{θ}{_}{_}{s2∈} s1∈ , shr-set-mono'{s2}{s1}{θ}{s'∈ = s1∈} s2∈ , refl seq-set-comm : ∀ θ x1 x2 n1 n2 → (x1∈ : isVar∈ x1 θ) → (x2∈ : isVar∈ x2 θ) → ¬ x1 ≡ x2 → ∃ λ x1∈' → ∃ λ x2∈' → (set-var{x2} (set-var{x1} θ x1∈ n1) x2∈' n2) ≡ (set-var{x1} (set-var{x2} θ x2∈ n2) x1∈' n1) seq-set-comm θ x1 x2 n1 n2 x1∈ x2∈ ¬x1≡x2 rewrite VarMap.put-comm{_}{var θ}{x1}{x2}{n1}{n2} ¬x1≡x2 = seq-set-mono'{x1}{x2}{θ}{n2}{x2∈} x1∈ , seq-set-mono'{x2}{x1}{θ}{x'∈ = x1∈} x2∈ , refl sig-←-irr-get : ∀ {θ₁ θ₂ S} → (S∈Domθ₁ : isSig∈ S θ₁) → ¬ (isSig∈ S θ₂) → ∃ λ S∈Dom⟨θ₁←θ₂⟩ → sig-stats {S} θ₁ S∈Domθ₁ ≡ sig-stats {S} (θ₁ ← θ₂) S∈Dom⟨θ₁←θ₂⟩ sig-←-irr-get {θ₁@(Θ Ss _ _)} {θ₂@(Θ Ss' _ _)} {S} S∈Domθ₁ S∉Domθ₂ with SigMap.U-∉-irr-get-m {_} {Ss} {Ss'} {S} S∈Domθ₁ S∉Domθ₂ ... | a , b rewrite b = a , refl shr-←-irr-get : ∀ {θ₁ θ₂ s} → (s∈Domθ₁ : isShr∈ s θ₁) → ¬ (isShr∈ s θ₂) → ∃ λ s∈Dom⟨θ₁←θ₂⟩ → shr-stats {s} θ₁ s∈Domθ₁ ≡ shr-stats {s} (θ₁ ← θ₂) s∈Dom⟨θ₁←θ₂⟩ shr-←-irr-get {θ₁@(Θ _ ss _)} {θ₂@(Θ _ ss' _)} {s} s∈Domθ₁ s∉Domθ₂ with ShrMap.U-∉-irr-get-m {_} {ss} {ss'} {s} s∈Domθ₁ s∉Domθ₂ ... | a , b rewrite b = a , refl seq-←-irr-get : ∀ {θ₁ θ₂ x} → (x∈Domθ₁ : isVar∈ x θ₁) → ¬ (isVar∈ x θ₂) → ∃ λ x∈Dom⟨θ₁←θ₂⟩ → var-vals {x} θ₁ x∈Domθ₁ ≡ var-vals {x} (θ₁ ← θ₂) x∈Dom⟨θ₁←θ₂⟩ seq-←-irr-get {θ₁@(Θ _ _ xs)} {θ₂@(Θ _ _ xs')} {x} x∈Domθ₁ x∉Domθ₂ with VarMap.U-∉-irr-get-m {_} {xs} {xs'} {x} x∈Domθ₁ x∉Domθ₂ ... | a , b rewrite b = a , refl sig-←-irr-get' : ∀ {θ₁ θ₂ S} → (S∈Domθ₁ : isSig∈ S θ₁) → ¬ (isSig∈ S θ₂) → (S∈Dom⟨θ₁←θ₂⟩ : isSig∈ S (θ₁ ← θ₂)) → sig-stats {S} θ₁ S∈Domθ₁ ≡ sig-stats {S} (θ₁ ← θ₂) S∈Dom⟨θ₁←θ₂⟩ sig-←-irr-get' {θ₁@(Θ Ss _ _)} {θ₂@(Θ Ss' _ _)} {S} S∈Domθ₁ S∉Domθ₂ S∈Dom⟨θ₁←θ₂⟩ with SigMap.U-∉-irr-get-m {_} {Ss} {Ss'} {S} S∈Domθ₁ S∉Domθ₂ ... | a , b rewrite b | sig∈-eq{S}{θ₁ ← θ₂} a S∈Dom⟨θ₁←θ₂⟩ = refl shr-←-irr-get' : ∀ {θ₁ θ₂ s} → (s∈Domθ₁ : isShr∈ s θ₁) → ¬ (isShr∈ s θ₂) → (s∈Dom⟨θ₁←θ₂⟩ : isShr∈ s (θ₁ ← θ₂)) → shr-stats {s} θ₁ s∈Domθ₁ ≡ shr-stats {s} (θ₁ ← θ₂) s∈Dom⟨θ₁←θ₂⟩ shr-←-irr-get' {θ₁@(Θ _ ss _)} {θ₂@(Θ _ ss' _)} {s} s∈Domθ₁ s∉Domθ₂ s∈Dom⟨θ₁←θ₂⟩ with ShrMap.U-∉-irr-get-m {_} {ss} {ss'} {s} s∈Domθ₁ s∉Domθ₂ ... | a , b rewrite (cong proj₁ b) | shr∈-eq{s}{θ₁ ← θ₂} a s∈Dom⟨θ₁←θ₂⟩ = refl shr-←-irr-get/vals' : ∀ {θ₁ θ₂ s} → (s∈Domθ₁ : isShr∈ s θ₁) → ¬ (isShr∈ s θ₂) → (s∈Dom⟨θ₁←θ₂⟩ : isShr∈ s (θ₁ ← θ₂)) → shr-vals {s} θ₁ s∈Domθ₁ ≡ shr-vals {s} (θ₁ ← θ₂) s∈Dom⟨θ₁←θ₂⟩ shr-←-irr-get/vals' {θ₁@(Θ _ ss _)} {θ₂@(Θ _ ss' _)} {s} s∈Domθ₁ s∉Domθ₂ s∈Dom⟨θ₁←θ₂⟩ with ShrMap.U-∉-irr-get-m {_} {ss} {ss'} {s} s∈Domθ₁ s∉Domθ₂ ... | a , b rewrite (cong proj₂ b) | shr∈-eq{s}{θ₁ ← θ₂} a s∈Dom⟨θ₁←θ₂⟩ = refl seq-←-irr-get' : ∀ {θ₁ θ₂ x} → (x∈Domθ₁ : isVar∈ x θ₁) → ¬ (isVar∈ x θ₂) → (x∈Dom⟨θ₁←θ₂⟩ : isVar∈ x (θ₁ ← θ₂)) → var-vals {x} θ₁ x∈Domθ₁ ≡ var-vals {x} (θ₁ ← θ₂) x∈Dom⟨θ₁←θ₂⟩ seq-←-irr-get' {θ₁@(Θ _ _ xs)} {θ₂@(Θ _ _ xs')} {x} x∈Domθ₁ x∉Domθ₂ x∈Dom⟨θ₁←θ₂⟩ with VarMap.U-∉-irr-get-m {_} {xs} {xs'} {x} x∈Domθ₁ x∉Domθ₂ ... | a , b rewrite b | seq∈-eq{x}{θ₁ ← θ₂} a x∈Dom⟨θ₁←θ₂⟩ = refl sig-set-←-comm' : ∀ S v θ θ' → (S∈ : isSig∈ S θ) → ¬ (isSig∈ S θ') → (S∈' : isSig∈ S (θ ← θ')) → (set-sig {S} θ S∈ v) ← θ' ≡ set-sig {S} (θ ← θ') S∈' v sig-set-←-comm' S v θ θ' S∈ S∉Domθ' S∈' rewrite SigMap.put-union-comm {_} S v (Env.sig θ) (Env.sig θ') S∉Domθ' = refl sig-set-←-comm : ∀ S v θ θ' → (S∈ : isSig∈ S θ) → ¬ (isSig∈ S θ') → ∃ λ S∈Dom⟨θ←θ'⟩ → (set-sig {S} θ S∈ v) ← θ' ≡ set-sig {S} (θ ← θ') S∈Dom⟨θ←θ'⟩ v sig-set-←-comm S v θ θ' S∈ S∉Domθ' rewrite SigMap.put-union-comm {_} S v (Env.sig θ) (Env.sig θ') S∉Domθ' = SigMap.U-mono {_} {Env.sig θ} {Env.sig θ'} {S} S∈ , refl shr-set-←-comm' : ∀ s v n θ θ' → (s∈ : isShr∈ s θ) → ¬ (isShr∈ s θ') → (s∈' : isShr∈ s (θ ← θ')) → (set-shr {s} θ s∈ v n) ← θ' ≡ set-shr {s} (θ ← θ') s∈' v n shr-set-←-comm' s v n θ θ' s∈ s∉Domθ' s∈' rewrite ShrMap.put-union-comm {_} s (v , n) (Env.shr θ) (Env.shr θ') s∉Domθ' = refl shr-set-←-comm : ∀ s v n θ θ' → (s∈ : isShr∈ s θ) → ¬ (isShr∈ s θ') → ∃ λ s∈Dom⟨θ←θ'⟩ → (set-shr {s} θ s∈ v n) ← θ' ≡ set-shr {s} (θ ← θ') s∈Dom⟨θ←θ'⟩ v n shr-set-←-comm s v n θ θ' s∈ s∉Domθ' rewrite ShrMap.put-union-comm {_} s (v , n) (Env.shr θ) (Env.shr θ') s∉Domθ' = ShrMap.U-mono {_} {Env.shr θ} {Env.shr θ'} {s} s∈ , refl var-set-←-comm' : ∀ x v θ θ' → (x∈ : isVar∈ x θ) → ¬ (isVar∈ x θ') → (x∈' : isVar∈ x (θ ← θ')) → (set-var {x} θ x∈ v) ← θ' ≡ set-var {x} (θ ← θ') x∈' v var-set-←-comm' x v θ θ' x∈ x∉Domθ' x∈' rewrite VarMap.put-union-comm {_} x v (Env.var θ) (Env.var θ') x∉Domθ' = refl var-set-←-comm : ∀ x v θ θ' → (x∈ : isVar∈ x θ) → ¬ (isVar∈ x θ') → ∃ λ x∈Dom⟨θ←θ'⟩ → (set-var {x} θ x∈ v) ← θ' ≡ set-var {x} (θ ← θ') x∈Dom⟨θ←θ'⟩ v var-set-←-comm x v θ θ' x∈ x∉Domθ' rewrite VarMap.put-union-comm {_} x v (Env.var θ) (Env.var θ') x∉Domθ' = VarMap.U-mono {_} {Env.var θ} {Env.var θ'} {x} x∈ , refl lookup-S-eq : ∀{a b} θ S S∈ S∈₁ → sig-stats{S = S} θ S∈ ≡ a → sig-stats{S = S} θ S∈₁ ≡ b → ¬ a ≡ b → ⊥ lookup-S-eq θ S S∈ S∈' eq1 eq2 neg rewrite sig∈-eq{S}{θ} S∈ S∈' = neg (trans (sym eq1) eq2) lookup-s-eq : ∀{a b} θ s s∈ s∈₁ → shr-stats{s = s} θ s∈ ≡ a → shr-stats{s = s} θ s∈₁ ≡ b → ¬ a ≡ b → ⊥ lookup-s-eq θ s s∈ s∈' eq1 eq2 neg rewrite shr∈-eq{s}{θ} s∈ s∈' = neg (trans (sym eq1) eq2) lookup-S-¬eq : ∀{a b} θ S S' S∈ S'∈ → sig-stats{S = S} θ S∈ ≡ a → sig-stats{S = S'} θ S'∈ ≡ b → ¬ a ≡ b → ¬ S ≡ S' lookup-S-¬eq θ S S' S∈ S'∈ S≡ S'≡ a≠b with S Signal.≟ S' ... | yes refl = ⊥-elim (lookup-S-eq θ S S∈ S'∈ S≡ S'≡ a≠b) ... | no x = x lookup-s-stat-¬eq : ∀{a b} θ s s' s∈ s'∈ → shr-stats{s = s} θ s∈ ≡ a → shr-stats{s = s'} θ s'∈ ≡ b → ¬ a ≡ b → ¬ s ≡ s' lookup-s-stat-¬eq θ s s' s∈ s'∈ s≡ s'≡ a≠b with s SharedVar.≟ s' ... | yes refl = ⊥-elim (lookup-s-eq θ s s∈ s'∈ s≡ s'≡ a≠b) ... | no x = x ←-=-irr-S : ∀ θ θ' → (Dom θ) ≡ (Dom θ') → ∀ S → (S∈ : isSig∈ S (θ ← θ')) → (S∈2 : isSig∈ S θ') → sig-stats{S} (θ ← θ') S∈ ≡ sig-stats{S} θ' S∈2 ←-=-irr-S θ θ' eq = SigMap.union-=-irr (sig θ) (sig θ') (cong proj₁ eq) ←-=-irr-s-stats : ∀ θ θ' → (Dom θ) ≡ (Dom θ') → ∀ s → (s∈ : isShr∈ s (θ ← θ')) → (s∈2 : isShr∈ s θ') → shr-stats{s} (θ ← θ') s∈ ≡ shr-stats{s} θ' s∈2 ←-=-irr-s-stats θ θ' eq a b = (cong proj₁) ∘ (ShrMap.union-=-irr (shr θ) (shr θ') (cong (proj₁ ∘ proj₂) eq) a b) ←-=-irr-s-vals : ∀ θ θ' → (Dom θ) ≡ (Dom θ') → ∀ s → (s∈ : isShr∈ s (θ ← θ')) → (s∈2 : isShr∈ s θ') → shr-vals{s} (θ ← θ') s∈ ≡ shr-vals{s} θ' s∈2 ←-=-irr-s-vals θ θ' eq a b = (cong proj₂) ∘ (ShrMap.union-=-irr (shr θ) (shr θ') (cong (proj₁ ∘ proj₂) eq) a b) ←-=-irr-x : ∀ θ θ' → (Dom θ) ≡ (Dom θ') → ∀ x → (x∈ : isVar∈ x (θ ← θ')) → (x∈2 : isVar∈ x θ') → var-vals{x} (θ ← θ') x∈ ≡ var-vals{x} θ' x∈2 ←-=-irr-x θ θ' eq = (VarMap.union-=-irr (var θ) (var θ') (cong (proj₂ ∘ proj₂) eq)) ←-single-overwrite-sig : ∀ S stat θ → isSig∈ S θ → ((Θ SigMap.[ S ↦ stat ] [] []) ← θ) ≡ θ ←-single-overwrite-sig S stat θ k∈ rewrite SigMap.single-val-overwrite S stat (sig θ) k∈ = refl ←-single-overwrite-shr : ∀ s stat v θ → isShr∈ s θ → ((Θ [] ShrMap.[ s ↦ (stat ,′ v) ] []) ← θ) ≡ θ ←-single-overwrite-shr s stat v θ k∈ rewrite ShrMap.single-val-overwrite s (stat ,′ v) (shr θ) k∈ = refl ←-single-overwrite-seq : ∀ x n θ → isVar∈ x θ → ((Θ [] [] VarMap.[ x ↦ n ]) ← θ) ≡ θ ←-single-overwrite-seq x n θ k∈ rewrite VarMap.single-val-overwrite x n (var θ) k∈ = refl sig-set=← : ∀ θ S stat → (S∈ : isSig∈ S θ) → (set-sig{S = S} θ S∈ stat) ≡ (θ ← (Θ SigMap.[ S ↦ stat ] [] [])) sig-set=← θ S stat S∈ rewrite SigMap.union-insert-eq S stat (sig θ) | ShrMap.union-comm (shr θ) [] (λ z _ → λ ()) | VarMap.union-comm (var θ) [] (λ z _ → λ ()) = refl shr-set=← : ∀ θ s stat n → (s∈ : isShr∈ s θ) → (set-shr{s = s} θ s∈ stat n) ≡ (θ ← (Θ [] ShrMap.[ s ↦ (stat ,′ n) ] [])) shr-set=← θ s stat n s∈ rewrite ShrMap.union-insert-eq s (stat ,′ n) (shr θ) | SigMap.union-comm (sig θ) [] (λ z _ → λ ()) | VarMap.union-comm (var θ) [] (λ z _ → λ ()) = refl seq-set=← : ∀ θ x n → (x∈ : isVar∈ x θ) → (set-var{x = x} θ x∈ n) ≡ (θ ← (Θ [] [] VarMap.[ x ↦ n ])) seq-set=← θ x n x∈ rewrite VarMap.union-insert-eq x n (var θ) | SigMap.union-comm (sig θ) [] (λ z _ → λ ()) | ShrMap.union-comm (shr θ) [] (λ z _ → λ ()) = refl sig-set-clobber : ∀ S stat θ θi S∈ → isSig∈ S θi → (set-sig{S = S} θ S∈ stat) ← θi ≡ θ ← θi sig-set-clobber S stat θ θi S∈θ S∈θi = (set-sig{S = S} θ S∈θ stat) ← θi ≡⟨ cong (_← θi)(sig-set=← θ S stat S∈θ) ⟩ (θ ← θ2) ← θi ≡⟨ sym (←-assoc θ θ2 θi) ⟩ (θ ← (θ2 ← θi)) ≡⟨ cong (θ ←_) (←-single-overwrite-sig S stat θi S∈θi) ⟩ (θ ← θi) ∎ where θ2 = Θ SigMap.[ S ↦ stat ] [] [] shr-set-clobber : ∀ v stat n θ θi v∈ → isShr∈ v θi → (set-shr{s = v} θ v∈ stat n) ← θi ≡ θ ← θi shr-set-clobber v stat n θ θi v∈θ v∈θi = (set-shr{s = v} θ v∈θ stat n) ← θi ≡⟨ cong (_← θi) (shr-set=← θ v stat n v∈θ) ⟩ (θ ← θ2) ← θi ≡⟨ sym (←-assoc θ θ2 θi) ⟩ (θ ← (θ2 ← θi)) ≡⟨ cong (θ ←_) (←-single-overwrite-shr v stat n θi v∈θi) ⟩ (θ ← θi) ∎ where θ2 = Θ [] ShrMap.[ v ↦ (stat ,′ n) ] [] seq-set-clobber : ∀ v n θ θi v∈ → isVar∈ v θi → (set-var{x = v} θ v∈ n) ← θi ≡ θ ← θi seq-set-clobber v n θ θi v∈θ v∈θi = (set-var{x = v} θ v∈θ n) ← θi ≡⟨ cong (_← θi) (seq-set=← θ v n v∈θ) ⟩ (θ ← θ2) ← θi ≡⟨ sym (←-assoc θ θ2 θi) ⟩ (θ ← (θ2 ← θi)) ≡⟨ cong (θ ←_) (←-single-overwrite-seq v n θi v∈θi) ⟩ (θ ← θi) ∎ where θ2 = Θ [] [] VarMap.[ v ↦ n ] sig-switch : ∀ S stat θ θi S∈ S∈2 → ¬ isSig∈ S θi → set-sig{S = S} (θ ← θi) S∈2 stat ≡ (set-sig{S = S} θ S∈ stat) ← θi sig-switch S stat θ θi S∈ S∈2 S∉ = set-sig{S = S} (θ ← θi) S∈2 stat ≡⟨ sig-set=← (θ ← θi) S stat S∈2 ⟩ (θ ← θi) ← θ2 ≡⟨ ←-assoc-comm θ θi θ2 ((λ z x x₁ → S∉ (subst (_∈ (SigMap.keys (sig θi))) (∈:: (subst (z ∈_) (SigMap.keys-1map S stat) x₁)) x)) , ((λ x x₁ → λ ()) , (λ x x₁ → λ ()))) ⟩ (θ ← θ2) ← θi ≡⟨ cong (_← θi) (sym (sig-set=← θ S stat S∈ )) ⟩ (set-sig{S = S} θ S∈ stat) ← θi ∎ where θ2 = Θ SigMap.[ S ↦ stat ] [] [] shr-switch : ∀ s stat n θ θi s∈ s∈2 → ¬ isShr∈ s θi → set-shr{s = s} (θ ← θi) s∈2 stat n ≡ (set-shr{s = s} θ s∈ stat n) ← θi shr-switch s stat n θ θi s∈ s∈2 s∉ = set-shr{s = s} (θ ← θi) s∈2 stat n ≡⟨ shr-set=← (θ ← θi) s stat n s∈2 ⟩ (θ ← θi) ← θ2 ≡⟨ ←-assoc-comm θ θi θ2 ((λ x x₁ → λ ()) , ((λ z x x₁ → s∉ (subst (_∈ (ShrMap.keys (shr θi))) (∈:: (subst (z ∈_) (ShrMap.keys-1map s (stat ,′ n)) x₁)) x)) , (λ x x₁ → λ ()))) ⟩ (θ ← θ2) ← θi ≡⟨ cong (_← θi) (sym (shr-set=← θ s stat n s∈ )) ⟩ (set-shr{s = s} θ s∈ stat n) ← θi ∎ where θ2 = Θ [] ShrMap.[ s ↦ (stat ,′ n) ] [] seq-switch : ∀ x n θ θi x∈ x∈2 → ¬ isVar∈ x θi → set-var{x = x} (θ ← θi) x∈2 n ≡ (set-var{x = x} θ x∈ n) ← θi seq-switch x n θ θi x∈ x∈2 x∉ = set-var{x = x} (θ ← θi) x∈2 n ≡⟨ seq-set=← (θ ← θi) x n x∈2 ⟩ (θ ← θi) ← θ2 ≡⟨ ←-assoc-comm θ θi θ2 ((λ x x₁ → λ ()) , ((λ x x₁ → λ ()) , (λ z j x₁ → x∉ (subst (_∈ (VarMap.keys (var θi))) (∈:: (subst (z ∈_) (VarMap.keys-1map x n) x₁)) j)))) ⟩ (θ ← θ2) ← θi ≡⟨ cong (_← θi) (sym (seq-set=← θ x n x∈ )) ⟩ (set-var{x = x} θ x∈ n) ← θi ∎ where θ2 = Θ [] [] VarMap.[ x ↦ n ] sig-switch-right : ∀ S stat θl θr S∈ S∈2 → (θl ← (set-sig{S} θr S∈ stat)) ≡ (set-sig{S} (θl ← θr) S∈2 stat) sig-switch-right S stat θl θr S∈ S∈2 = (θl ← (set-sig{S} θr S∈ stat)) ≡⟨ cong (θl ←_) (sig-set=← θr S stat S∈) ⟩ (θl ← (θr ← (Θ SigMap.[ S ↦ stat ] [] []))) ≡⟨ ←-assoc θl θr _ ⟩ ((θl ← θr) ← (Θ SigMap.[ S ↦ stat ] [] [])) ≡⟨ sym (sig-set=← (θl ← θr) S stat S∈2) ⟩ (set-sig{S} (θl ← θr) S∈2 stat) ∎ shr-switch-right : ∀ s stat n θl θr s∈ s∈2 → (θl ← (set-shr{s} θr s∈ stat n)) ≡ (set-shr{s} (θl ← θr) s∈2 stat n) shr-switch-right s stat n θl θr s∈ s∈2 = (θl ← (set-shr{s} θr s∈ stat n)) ≡⟨ cong (θl ←_) (shr-set=← θr s stat n s∈) ⟩ (θl ← (θr ← (Θ [] ShrMap.[ s ↦ (stat ,′ n) ] []))) ≡⟨ ←-assoc θl θr _ ⟩ ((θl ← θr) ← (Θ [] ShrMap.[ s ↦ (stat ,′ n) ] [])) ≡⟨ sym (shr-set=← (θl ← θr) s stat n s∈2) ⟩ (set-shr{s} (θl ← θr) s∈2 stat n) ∎ seq-switch-right : ∀ x n θl θr x∈ x∈2 → (θl ← (set-var{x} θr x∈ n)) ≡ (set-var{x} (θl ← θr) x∈2 n) seq-switch-right x n θl θr x∈ x∈2 = (θl ← (set-var{x} θr x∈ n)) ≡⟨ cong (θl ←_) (seq-set=← θr x n x∈) ⟩ (θl ← (θr ← (Θ [] [] VarMap.[ x ↦ n ]))) ≡⟨ ←-assoc θl θr _ ⟩ ((θl ← θr) ← (Θ [] [] VarMap.[ x ↦ n ])) ≡⟨ sym (seq-set=← (θl ← θr) x n x∈2) ⟩ (set-var{x} (θl ← θr) x∈2 n) ∎ sig-set-dom-eq : ∀ S stat θ S∈ → (Dom θ) ≡ (Dom (set-sig{S = S} θ S∈ stat)) sig-set-dom-eq S stat θ S∈ rewrite SigMap.update-domain-eq S stat (sig θ) S∈ = refl shr-set-dom-eq : ∀ s stat n θ s∈ → (Dom θ) ≡ (Dom (set-shr{s = s} θ s∈ stat n)) shr-set-dom-eq s stat n θ s∈ rewrite ShrMap.update-domain-eq s (stat ,′ n) (shr θ) s∈ = refl seq-set-dom-eq : ∀ x n θ x∈ → (Dom θ) ≡ (Dom (set-var{x = x} θ x∈ n)) seq-set-dom-eq x n θ x∈ rewrite VarMap.update-domain-eq x n (var θ) x∈ = refl sig-∉-maint : ∀ S S' stat θ S'∈ → ¬ isSig∈ S θ → ¬ isSig∈ S (set-sig{S = S'} θ S'∈ stat) sig-∉-maint S S' stat θ S'∈ S∉ x rewrite cong proj₁ (sig-set-dom-eq S' stat θ S'∈) = S∉ x shr-∉-maint : ∀ s s' stat n θ s'∈ → ¬ isShr∈ s θ → ¬ isShr∈ s (set-shr{s = s'} θ s'∈ stat n) shr-∉-maint s s' stat n θ s'∈ s∉ x rewrite cong snd (shr-set-dom-eq s' stat n θ s'∈) = s∉ x sig-∉-single : ∀ S S' stat → ¬ S ≡ S' → ¬ isSig∈ S (Θ SigMap.[ S' ↦ stat ] [] []) sig-∉-single S S' stat neg x rewrite SigMap.keys-1map S' stat with x ... | Any.here px = (Signal.unwrap-neq neg) px ... | Any.there () shr-∉-single : ∀ s s' stat n → ¬ s ≡ s' → ¬ isShr∈ s (Θ [] ShrMap.[ s' ↦ (stat ,′ n) ] []) shr-∉-single s s' stat n neg x rewrite ShrMap.keys-1map s' (stat ,′ n) with x ... | Any.here px = (SharedVar.unwrap-neq neg) px ... | Any.there () sig-∈-single : ∀ S stat → isSig∈ S (Θ SigMap.[ S ↦ stat ] [] []) sig-∈-single S stat rewrite SigMap.keys-1map S stat = Data.List.Any.here refl sig-∈-single-right-← : ∀ S stat θ → isSig∈ S (θ ← (Θ SigMap.[ S ↦ stat ] [] [])) sig-∈-single-right-← S stat θ = sig-←-monoʳ S (Θ SigMap.[ S ↦ stat ] [] []) θ (sig-∈-single S stat) shr-∈-single : ∀ s stat n → isShr∈ s (Θ [] ShrMap.[ s ↦ (stat ,′ n) ] []) shr-∈-single s stat n rewrite ShrMap.keys-1map s (stat ,′ n) = Data.List.Any.here refl sig-single-∈-eq : ∀ S S' stat' → isSig∈ S (Θ SigMap.[ S' ↦ stat' ] [] []) → Signal.unwrap S ≡ Signal.unwrap S' sig-single-∈-eq S S' stat' S∈Dom[S'] rewrite SigMap.keys-1map S' stat' = ∈:: S∈Dom[S'] sig-put-mby-overwrite : ∀ S S' θ statneq statput S∈ S'∈ S∈2 → ¬ statneq ≡ statput → ¬ (sig-stats{S} θ S∈ ≡ statneq) → ¬ (sig-stats{S} (set-sig{S'} θ S'∈ statput) S∈2 ≡ statneq) sig-put-mby-overwrite S S' θ statneq statput S∈ S'∈ S∈2 neq≠put ¬ref ref with S Signal.≟ S' ... | yes refl = lookup-S-eq (set-sig{S} θ S'∈ statput) S S∈2 S∈2 (sig-putget{S}{θ}{statput} S'∈ S∈2) ref (neq≠put ∘ sym) ... | no ¬refl = ¬ref (trans (sym (sig-putputget/m{S}{S'}{θ} ¬refl S∈ S'∈ S∈2)) ref) sig-stats-1map' : ∀ S status → (S∈ : isSig∈ S (Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty)) → sig-stats {S} (Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty) S∈ ≡ status sig-stats-1map' S status S∈ = SigMap.putget-m {_} {SigMap.empty} {S} {status} S∈ sig-stats-1map-right-← : ∀ S status θ → (S∈ : isSig∈ S (θ ← (Θ SigMap.[ S ↦ status ] [] []))) → (sig-stats{S} (θ ← (Θ SigMap.[ S ↦ status ] [] [])) S∈ ≡ status) sig-stats-1map-right-← S stat θ S∈ = trans (sig-stats-←-right-irr' S θ (Θ SigMap.[ S ↦ stat ] [] []) (sig-∈-single S stat) S∈) (sig-stats-1map' S stat (sig-∈-single S stat)) sig-put-1map-overwrite' : ∀ S status status' → (S∈ : isSig∈ S (Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty)) → set-sig {S} (Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty) S∈ status' ≡ Θ SigMap.[ S ↦ status' ] ShrMap.empty VarMap.empty sig-put-1map-overwrite' S status status' S∈ rewrite SigMap.putput-overwrite SigMap.empty S status status' = refl -- ←-comm : ∀ θ θ' → distinct (Dom θ) (Dom θ') → (θ ← θ') ≡ (θ' ← θ) sig-set-inner-clobber : ∀ θ θ' θ'' S stat → isSig∈ S θ'' → ((θ ← (Θ SigMap.[ S ↦ stat ] [] [])) ← θ') ← θ'' ≡ ((θ ← θ') ← θ'') sig-set-inner-clobber θ θ' θ'' S stat S∈θ'' with Sig∈ S θ' ... | yes S∈θ' = (((θ ← (Θ SigMap.[ S ↦ stat ] [] [])) ← θ') ← θ'') ≡⟨ cong (λ x → (x ← θ'')) (sym (←-assoc θ (Θ SigMap.[ S ↦ stat ] [] []) θ')) ⟩ ((θ ← ((Θ SigMap.[ S ↦ stat ] [] []) ← θ')) ← θ'') ≡⟨ cong (λ x → (θ ← x) ← θ'' ) (←-single-overwrite-sig S stat (Θ (sig θ') (shr θ') (var θ')) S∈θ') ⟩ ((θ ← θ') ← θ'') ∎ ... | no S∉θ' = (((θ ← (Θ SigMap.[ S ↦ stat ] [] [])) ← θ') ← θ'') ≡⟨ cong (λ x → (x ← θ'')) (sym (←-assoc θ (Θ SigMap.[ S ↦ stat ] [] []) θ')) ⟩ ((θ ← ((Θ SigMap.[ S ↦ stat ] [] []) ← θ')) ← θ'') ≡⟨ cong (λ x → (θ ← x) ← θ'' ) ( ←-comm (Θ SigMap.[ S ↦ stat ] [] []) θ' (ds , ((λ z → λ ()) , (λ z → λ ())))) ⟩ ((θ ← (θ' ← (Θ SigMap.[ S ↦ stat ] [] []))) ← θ'') ≡⟨ cong (_← θ'') (←-assoc θ θ' (Θ SigMap.[ S ↦ stat ] [] [])) ⟩ (((θ ← θ') ← (Θ SigMap.[ S ↦ stat ] [] [])) ← θ'') ≡⟨ sym (←-assoc (θ ← θ') (Θ SigMap.[ S ↦ stat ] [] []) θ'') ⟩ ((θ ← θ') ← ((Θ SigMap.[ S ↦ stat ] [] []) ← θ'')) ≡⟨ cong ((θ ← θ') ←_) (←-single-overwrite-sig S stat (Θ (sig θ'') (shr θ'') (var θ'')) S∈θ'') ⟩ ((θ ← θ') ← θ'') ∎ where ds : distinct' (proj₁ (Dom (Θ SigMap.[ S ↦ stat ] [] []))) (proj₁ (Dom θ')) ds z x y rewrite SigMap.keys-1map S stat with x ... | Any.here refl = ⊥-elim (S∉θ' y) ... | Any.there () sig-single-notin-distinct : ∀ S status θ → Signal.unwrap S ∉ proj₁ (Dom θ) → distinct (Dom (Θ SigMap.[ S ↦ status ] [] [])) (Dom θ) sig-single-notin-distinct S status θ S∉Domθ = (λ S'' S''∈[S] S''∈Domθ → S∉Domθ (subst (_∈ proj₁ (Dom θ)) (∈:: (subst (S'' ∈_) (SigMap.keys-1map S status) S''∈[S])) S''∈Domθ)) ,′ (λ _ ()) ,′ (λ _ ()) -- a special case of sig-single-notin-distinct sig-single-noteq-distinct : ∀ S status S' status' → ¬ Signal.unwrap S ≡ Signal.unwrap S' → distinct (Dom (Θ SigMap.[ S ↦ status ] [] [])) (Dom (Θ SigMap.[ S' ↦ status' ] [] [])) sig-single-noteq-distinct S status S' status' S≢S' = (λ S'' S''∈[S] S''∈[S'] → S≢S' (trans (sym (∈:: (subst (S'' ∈_) (SigMap.keys-1map S status) S''∈[S]))) (∈:: (subst (S'' ∈_) (SigMap.keys-1map S' status') S''∈[S'])))) ,′ (λ _ ()) ,′ (λ _ ()) sig-single-←-←-overwrite : ∀ θ S status status' → (θ ← Θ SigMap.[ S ↦ status ] [] []) ← Θ SigMap.[ S ↦ status' ] [] [] ≡ θ ← Θ SigMap.[ S ↦ status' ] [] [] sig-single-←-←-overwrite θ S status status' rewrite sym (←-assoc θ (Θ SigMap.[ S ↦ status ] [] []) (Θ SigMap.[ S ↦ status' ] [] [])) = cong (θ ←_) (←-single-overwrite-sig S status (Θ SigMap.[ S ↦ status' ] [] []) (sig-∈-single S status')) sig-set-clobber-single-as-← : ∀ S status status' θ S∈ → (set-sig{S} (θ ← (Θ SigMap.[ S ↦ status' ] [] [])) S∈ status) ≡ (θ ← (Θ SigMap.[ S ↦ status ] [] [])) sig-set-clobber-single-as-← S status status' θ S∈ =(begin (set-sig{S} (θ ← θs1) ((sig-∈-single-right-← S status' θ)) status) ≡⟨ sym (sig-switch-right S status θ θs1 ((sig-∈-single S status')) ((sig-∈-single-right-← S status' θ))) ⟩ (θ ← (set-sig{S} θs1 ((sig-∈-single S status')) status)) ≡⟨ cong (_←_ θ) (sig-put-1map-overwrite' S status' status ((sig-∈-single S status'))) ⟩ (θ ← θs2) ∎) where θs1 = (Θ SigMap.[ S ↦ status' ] [] []) θs2 = (Θ SigMap.[ S ↦ status ] [] [])
{ "alphanum_fraction": 0.4860467077, "avg_line_length": 42.2475512021, "ext": "agda", "hexsha": "8716a3b63c8e9e9e8d833c0d52c01c06df61603b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_path": "agda/Esterel/Environment.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "florence/esterel-calculus", "max_issues_repo_path": "agda/Esterel/Environment.agda", "max_line_length": 179, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_path": "agda/Esterel/Environment.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "num_tokens": 25569, "size": 47444 }
{-# OPTIONS --safe #-} module Cubical.Algebra.DistLattice.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.Transport open import Cubical.Foundations.SIP open import Cubical.Data.Sigma open import Cubical.Displayed.Base open import Cubical.Displayed.Auto open import Cubical.Displayed.Record open import Cubical.Displayed.Universe open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open import Cubical.Algebra.CommMonoid open import Cubical.Algebra.Semilattice open import Cubical.Algebra.Lattice.Base open Iso private variable ℓ ℓ' : Level record IsDistLattice {L : Type ℓ} (0l 1l : L) (_∨l_ _∧l_ : L → L → L) : Type ℓ where constructor isdistlattice field isLattice : IsLattice 0l 1l _∨l_ _∧l_ ∨l-dist-∧l : (x y z : L) → (x ∨l (y ∧l z) ≡ (x ∨l y) ∧l (x ∨l z)) × ((y ∧l z) ∨l x ≡ (y ∨l x) ∧l (z ∨l x)) ∧l-dist-∨l : (x y z : L) → (x ∧l (y ∨l z) ≡ (x ∧l y) ∨l (x ∧l z)) × ((y ∨l z) ∧l x ≡ (y ∧l x) ∨l (z ∧l x)) open IsLattice isLattice public ∨lLdist∧l : (x y z : L) → x ∨l (y ∧l z) ≡ (x ∨l y) ∧l (x ∨l z) ∨lLdist∧l x y z = ∨l-dist-∧l x y z .fst ∨lRdist∧l : (x y z : L) → (y ∧l z) ∨l x ≡ (y ∨l x) ∧l (z ∨l x) ∨lRdist∧l x y z = ∨l-dist-∧l x y z .snd ∧lLdist∨l : (x y z : L) → x ∧l (y ∨l z) ≡ (x ∧l y) ∨l (x ∧l z) ∧lLdist∨l x y z = ∧l-dist-∨l x y z .fst ∧lRdist∨l : (x y z : L) → (y ∨l z) ∧l x ≡ (y ∧l x) ∨l (z ∧l x) ∧lRdist∨l x y z = ∧l-dist-∨l x y z .snd record DistLatticeStr (A : Type ℓ) : Type (ℓ-suc ℓ) where constructor distlatticestr field 0l : A 1l : A _∨l_ : A → A → A _∧l_ : A → A → A isDistLattice : IsDistLattice 0l 1l _∨l_ _∧l_ infix 7 _∨l_ infix 6 _∧l_ open IsDistLattice isDistLattice public DistLattice : ∀ ℓ → Type (ℓ-suc ℓ) DistLattice ℓ = TypeWithStr ℓ DistLatticeStr isSetDistLattice : (L : DistLattice ℓ) → isSet ⟨ L ⟩ isSetDistLattice L = L .snd .DistLatticeStr.is-set -- when proving the axioms for a distributive lattice -- we use the fact that from distributivity and absorption -- of ∧l over ∨l we can derive distributivity and absorption -- of ∨l over ∧l and vice versa. We give provide thus two -- ways of making a distributive lattice... makeIsDistLattice∧lOver∨l : {L : Type ℓ} {0l 1l : L} {_∨l_ _∧l_ : L → L → L} (is-setL : isSet L) (∨l-assoc : (x y z : L) → x ∨l (y ∨l z) ≡ (x ∨l y) ∨l z) (∨l-rid : (x : L) → x ∨l 0l ≡ x) (∨l-comm : (x y : L) → x ∨l y ≡ y ∨l x) (∧l-assoc : (x y z : L) → x ∧l (y ∧l z) ≡ (x ∧l y) ∧l z) (∧l-rid : (x : L) → x ∧l 1l ≡ x) (∧l-comm : (x y : L) → x ∧l y ≡ y ∧l x) (∧l-absorb-∨l : (x y : L) → x ∧l (x ∨l y) ≡ x) (∧l-ldist-∨l : (x y z : L) → x ∧l (y ∨l z) ≡ (x ∧l y) ∨l (x ∧l z)) → IsDistLattice 0l 1l _∨l_ _∧l_ makeIsDistLattice∧lOver∨l {_∨l_ = _∨l_} {_∧l_ = _∧l_} is-setL ∨l-assoc ∨l-rid ∨l-comm ∧l-assoc ∧l-rid ∧l-comm ∧l-absorb-∨l ∧l-ldist-∨l = isdistlattice (makeIsLattice is-setL ∨l-assoc ∨l-rid (λ x → ∨l-comm _ x ∙ ∨l-rid x) ∨l-comm ∧l-assoc ∧l-rid (λ x → ∧l-comm _ x ∙ ∧l-rid x) ∧l-comm ∨l-absorb-∧l ∧l-absorb-∨l) (λ x y z → ∨l-ldist-∧l _ _ _ , ∨l-rdist-∧l _ _ _) (λ x y z → ∧l-ldist-∨l _ _ _ , ∧l-rdist-∨l _ _ _) where ∧l-idem : ∀ x → x ∧l x ≡ x ∧l-idem x = cong (x ∧l_) (sym (∨l-rid _)) ∙ ∧l-absorb-∨l _ _ ∨l-absorb-∧l : ∀ x y → x ∨l (x ∧l y) ≡ x ∨l-absorb-∧l x y = cong (_∨l (x ∧l y)) (sym (∧l-idem _)) ∙∙ sym (∧l-ldist-∨l _ _ _) ∙∙ ∧l-absorb-∨l _ _ ∧l-rdist-∨l : ∀ x y z → (y ∨l z) ∧l x ≡ (y ∧l x) ∨l (z ∧l x) ∧l-rdist-∨l _ _ _ = ∧l-comm _ _ ∙∙ ∧l-ldist-∨l _ _ _ ∙∙ cong₂ (_∨l_) (∧l-comm _ _) (∧l-comm _ _) ∨l-ldist-∧l : ∀ x y z → x ∨l (y ∧l z) ≡ (x ∨l y) ∧l (x ∨l z) ∨l-ldist-∧l x y z = x ∨l (y ∧l z) ≡⟨ cong (_∨l (y ∧l z)) (sym (∨l-absorb-∧l _ _)) ⟩ (x ∨l (x ∧l z)) ∨l (y ∧l z) ≡⟨ sym (∨l-assoc _ _ _) ⟩ x ∨l ((x ∧l z) ∨l (y ∧l z)) ≡⟨ cong (_∨l ((x ∧l z) ∨l (y ∧l z))) (sym (∧l-comm _ _ ∙ ∧l-absorb-∨l _ _)) ⟩ ((x ∨l y) ∧l x) ∨l ((x ∧l z) ∨l (y ∧l z)) ≡⟨ cong (((x ∨l y) ∧l x) ∨l_) (sym (∧l-rdist-∨l _ _ _)) ⟩ ((x ∨l y) ∧l x) ∨l ((x ∨l y) ∧l z) ≡⟨ sym (∧l-ldist-∨l _ _ _) ⟩ (x ∨l y) ∧l (x ∨l z) ∎ ∨l-rdist-∧l : ∀ x y z → (y ∧l z) ∨l x ≡ (y ∨l x) ∧l (z ∨l x) ∨l-rdist-∧l x y z = ∨l-comm _ x ∙∙ ∨l-ldist-∧l _ _ _ ∙∙ cong₂ (_∧l_) (∨l-comm _ _) (∨l-comm _ _) makeDistLattice∧lOver∨l : {L : Type ℓ} (0l 1l : L) (_∨l_ _∧l_ : L → L → L) (is-setL : isSet L) (∨l-assoc : (x y z : L) → x ∨l (y ∨l z) ≡ (x ∨l y) ∨l z) (∨l-rid : (x : L) → x ∨l 0l ≡ x) (∨l-comm : (x y : L) → x ∨l y ≡ y ∨l x) (∧l-assoc : (x y z : L) → x ∧l (y ∧l z) ≡ (x ∧l y) ∧l z) (∧l-rid : (x : L) → x ∧l 1l ≡ x) (∧l-comm : (x y : L) → x ∧l y ≡ y ∧l x) (∧l-absorb-∨l : (x y : L) → x ∧l (x ∨l y) ≡ x) (∧l-ldist-∨l : (x y z : L) → x ∧l (y ∨l z) ≡ (x ∧l y) ∨l (x ∧l z)) → DistLattice ℓ makeDistLattice∧lOver∨l 0l 1l _∨l_ _∧l_ is-setL ∨l-assoc ∨l-rid ∨l-comm ∧l-assoc ∧l-rid ∧l-comm ∧l-absorb-∨l ∧l-ldist-∨l = _ , distlatticestr _ _ _ _ (makeIsDistLattice∧lOver∨l is-setL ∨l-assoc ∨l-rid ∨l-comm ∧l-assoc ∧l-rid ∧l-comm ∧l-absorb-∨l ∧l-ldist-∨l) makeIsDistLattice∨lOver∧l : {L : Type ℓ} {0l 1l : L} {_∨l_ _∧l_ : L → L → L} (is-setL : isSet L) (∨l-assoc : (x y z : L) → x ∨l (y ∨l z) ≡ (x ∨l y) ∨l z) (∨l-rid : (x : L) → x ∨l 0l ≡ x) (∨l-comm : (x y : L) → x ∨l y ≡ y ∨l x) (∧l-assoc : (x y z : L) → x ∧l (y ∧l z) ≡ (x ∧l y) ∧l z) (∧l-rid : (x : L) → x ∧l 1l ≡ x) (∧l-comm : (x y : L) → x ∧l y ≡ y ∧l x) (∨l-absorb-∧l : (x y : L) → x ∨l (x ∧l y) ≡ x) (∨l-ldist-∧l : (x y z : L) → x ∨l (y ∧l z) ≡ (x ∨l y) ∧l (x ∨l z)) → IsDistLattice 0l 1l _∨l_ _∧l_ makeIsDistLattice∨lOver∧l {_∨l_ = _∨l_} {_∧l_ = _∧l_} is-setL ∨l-assoc ∨l-rid ∨l-comm ∧l-assoc ∧l-rid ∧l-comm ∨l-absorb-∧l ∨l-ldist-∧l = isdistlattice (makeIsLattice is-setL ∨l-assoc ∨l-rid (λ x → ∨l-comm _ x ∙ ∨l-rid x) ∨l-comm ∧l-assoc ∧l-rid (λ x → ∧l-comm _ x ∙ ∧l-rid x) ∧l-comm ∨l-absorb-∧l ∧l-absorb-∨l) (λ x y z → ∨l-ldist-∧l _ _ _ , ∨l-rdist-∧l _ _ _) (λ x y z → ∧l-ldist-∨l _ _ _ , ∧l-rdist-∨l _ _ _) where ∨l-idem : ∀ x → x ∨l x ≡ x ∨l-idem x = cong (x ∨l_) (sym (∧l-rid _)) ∙ ∨l-absorb-∧l _ _ ∧l-absorb-∨l : ∀ x y → x ∧l (x ∨l y) ≡ x ∧l-absorb-∨l x y = cong (_∧l (x ∨l y)) (sym (∨l-idem _)) ∙∙ sym (∨l-ldist-∧l _ _ _) ∙∙ ∨l-absorb-∧l _ _ ∨l-rdist-∧l : ∀ x y z → (y ∧l z) ∨l x ≡ (y ∨l x) ∧l (z ∨l x) ∨l-rdist-∧l _ _ _ = ∨l-comm _ _ ∙∙ ∨l-ldist-∧l _ _ _ ∙∙ cong₂ (_∧l_) (∨l-comm _ _) (∨l-comm _ _) ∧l-ldist-∨l : ∀ x y z → x ∧l (y ∨l z) ≡ (x ∧l y) ∨l (x ∧l z) ∧l-ldist-∨l x y z = x ∧l (y ∨l z) ≡⟨ cong (_∧l (y ∨l z)) (sym (∧l-absorb-∨l _ _)) ⟩ (x ∧l (x ∨l z)) ∧l (y ∨l z) ≡⟨ sym (∧l-assoc _ _ _) ⟩ x ∧l ((x ∨l z) ∧l (y ∨l z)) ≡⟨ cong (_∧l ((x ∨l z) ∧l (y ∨l z))) (sym (∨l-comm _ _ ∙ ∨l-absorb-∧l _ _)) ⟩ ((x ∧l y) ∨l x) ∧l ((x ∨l z) ∧l (y ∨l z)) ≡⟨ cong (((x ∧l y) ∨l x) ∧l_) (sym (∨l-rdist-∧l _ _ _)) ⟩ ((x ∧l y) ∨l x) ∧l ((x ∧l y) ∨l z) ≡⟨ sym (∨l-ldist-∧l _ _ _) ⟩ (x ∧l y) ∨l (x ∧l z) ∎ ∧l-rdist-∨l : ∀ x y z → (y ∨l z) ∧l x ≡ (y ∧l x) ∨l (z ∧l x) ∧l-rdist-∨l x y z = ∧l-comm _ x ∙∙ ∧l-ldist-∨l _ _ _ ∙∙ cong₂ (_∨l_) (∧l-comm _ _) (∧l-comm _ _) makeDistLattice∨lOver∧l : {L : Type ℓ} (0l 1l : L) (_∨l_ _∧l_ : L → L → L) (is-setL : isSet L) (∨l-assoc : (x y z : L) → x ∨l (y ∨l z) ≡ (x ∨l y) ∨l z) (∨l-rid : (x : L) → x ∨l 0l ≡ x) (∨l-comm : (x y : L) → x ∨l y ≡ y ∨l x) (∧l-assoc : (x y z : L) → x ∧l (y ∧l z) ≡ (x ∧l y) ∧l z) (∧l-rid : (x : L) → x ∧l 1l ≡ x) (∧l-comm : (x y : L) → x ∧l y ≡ y ∧l x) (∨l-absorb-∧l : (x y : L) → x ∨l (x ∧l y) ≡ x) (∨l-ldist-∧l : (x y z : L) → x ∨l (y ∧l z) ≡ (x ∨l y) ∧l (x ∨l z)) → DistLattice ℓ makeDistLattice∨lOver∧l 0l 1l _∨l_ _∧l_ is-setL ∨l-assoc ∨l-rid ∨l-comm ∧l-assoc ∧l-rid ∧l-comm ∨l-absorb-∧l ∨l-ldist-∧l = _ , distlatticestr _ _ _ _ (makeIsDistLattice∨lOver∧l is-setL ∨l-assoc ∨l-rid ∨l-comm ∧l-assoc ∧l-rid ∧l-comm ∨l-absorb-∧l ∨l-ldist-∧l) DistLatticeStr→LatticeStr : {A : Type ℓ} → DistLatticeStr A → LatticeStr A DistLatticeStr→LatticeStr (distlatticestr _ _ _ _ H) = latticestr _ _ _ _ (IsDistLattice.isLattice H) DistLattice→Lattice : DistLattice ℓ → Lattice ℓ DistLattice→Lattice (_ , distlatticestr _ _ _ _ H) = _ , latticestr _ _ _ _ (IsDistLattice.isLattice H) DistLatticeHom : (L : DistLattice ℓ) (M : DistLattice ℓ') → Type (ℓ-max ℓ ℓ') DistLatticeHom L M = LatticeHom (DistLattice→Lattice L) (DistLattice→Lattice M) IsDistLatticeEquiv : {A : Type ℓ} {B : Type ℓ'} (L : DistLatticeStr A) (e : A ≃ B) (M : DistLatticeStr B) → Type (ℓ-max ℓ ℓ') IsDistLatticeEquiv L e M = IsLatticeHom (DistLatticeStr→LatticeStr L) (e .fst) (DistLatticeStr→LatticeStr M) DistLatticeEquiv : (L : DistLattice ℓ) (M : DistLattice ℓ') → Type (ℓ-max ℓ ℓ') DistLatticeEquiv L M = Σ[ e ∈ (L .fst ≃ M .fst) ] IsDistLatticeEquiv (L .snd) e (M .snd) isPropIsDistLattice : {L : Type ℓ} (0l 1l : L) (_∨l_ _∧l_ : L → L → L) → isProp (IsDistLattice 0l 1l _∨l_ _∧l_) isPropIsDistLattice 0l 1l _∨l_ _∧l_ (isdistlattice LL LD1 LD2) (isdistlattice ML MD1 MD2) = λ i → isdistlattice (isPropIsLattice _ _ _ _ LL ML i) (isPropDist1 LD1 MD1 i) (isPropDist2 LD2 MD2 i) where isSetL : isSet _ isSetL = LL .IsLattice.joinSemilattice .IsSemilattice.isCommMonoid .IsCommMonoid.isMonoid .IsMonoid.isSemigroup .IsSemigroup.is-set isPropDist1 : isProp ((x y z : _) → (x ∨l (y ∧l z) ≡ (x ∨l y) ∧l (x ∨l z)) × ((y ∧l z) ∨l x ≡ (y ∨l x) ∧l (z ∨l x))) isPropDist1 = isPropΠ3 (λ _ _ _ → isProp× (isSetL _ _) (isSetL _ _)) isPropDist2 : isProp ((x y z : _) → (x ∧l (y ∨l z) ≡ (x ∧l y) ∨l (x ∧l z)) × ((y ∨l z) ∧l x ≡ (y ∧l x) ∨l (z ∧l x))) isPropDist2 = isPropΠ3 (λ _ _ _ → isProp× (isSetL _ _) (isSetL _ _)) 𝒮ᴰ-DistLattice : DUARel (𝒮-Univ ℓ) DistLatticeStr ℓ 𝒮ᴰ-DistLattice = 𝒮ᴰ-Record (𝒮-Univ _) IsDistLatticeEquiv (fields: data[ 0l ∣ null ∣ pres0 ] data[ 1l ∣ null ∣ pres1 ] data[ _∨l_ ∣ bin ∣ pres∨l ] data[ _∧l_ ∣ bin ∣ pres∧l ] prop[ isDistLattice ∣ (λ _ _ → isPropIsDistLattice _ _ _ _) ]) where open DistLatticeStr open IsLatticeHom -- faster with some sharing null = autoDUARel (𝒮-Univ _) (λ A → A) bin = autoDUARel (𝒮-Univ _) (λ A → A → A → A) DistLatticePath : (L M : DistLattice ℓ) → DistLatticeEquiv L M ≃ (L ≡ M) DistLatticePath = ∫ 𝒮ᴰ-DistLattice .UARel.ua
{ "alphanum_fraction": 0.4482458224, "avg_line_length": 46.0839416058, "ext": "agda", "hexsha": "2115bbbafd5bae1a0cd474dff0c6516b1570cada", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lpw25/cubical", "max_forks_repo_path": "Cubical/Algebra/DistLattice/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lpw25/cubical", "max_issues_repo_path": "Cubical/Algebra/DistLattice/Base.agda", "max_line_length": 100, "max_stars_count": null, "max_stars_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lpw25/cubical", "max_stars_repo_path": "Cubical/Algebra/DistLattice/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5583, "size": 12627 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Relation.Binary.Raw.Construct.Intersection where open import Cubical.Core.Everything open import Cubical.Foundations.Function using (_∘_) open import Cubical.Data.Prod open import Cubical.Data.Sum.Base using (_⊎_; inl; inr; rec) open import Cubical.Relation.Binary.Raw open import Cubical.Relation.Nullary using (yes; no) ------------------------------------------------------------------------ -- Definition _∩_ : ∀ {a b ℓ₁ ℓ₂} {A : Type a} {B : Type b} → RawREL A B ℓ₁ → RawREL A B ℓ₂ → RawREL A B (ℓ-max ℓ₁ ℓ₂) L ∩ R = λ i j → L i j × R i j ------------------------------------------------------------------------ -- Properties module _ {a ℓ₁ ℓ₂} {A : Type a} (L : RawRel A ℓ₁) (R : RawRel A ℓ₂) where reflexive : Reflexive L → Reflexive R → Reflexive (L ∩ R) reflexive L-refl R-refl = L-refl , R-refl symmetric : Symmetric L → Symmetric R → Symmetric (L ∩ R) symmetric L-sym R-sym = map L-sym R-sym transitive : Transitive L → Transitive R → Transitive (L ∩ R) transitive L-trans R-trans (xLy , xRy) (yLz , yRz) = L-trans xLy yLz , R-trans xRy yRz respects : ∀ {p} (P : A → Type p) → P Respects L ⊎ P Respects R → P Respects (L ∩ R) respects P resp (Lxy , Rxy) = rec (λ x → x Lxy) (λ x → x Rxy) resp min : ∀ {⊤} → Minimum L ⊤ → Minimum R ⊤ → Minimum (L ∩ R) ⊤ min L-min R-min = intro L-min R-min max : ∀ {⊥} → Maximum L ⊥ → Maximum R ⊥ → Maximum (L ∩ R) ⊥ max L-max R-max = intro L-max R-max toNotEq : ToNotEq L ⊎ ToNotEq R → ToNotEq (L ∩ R) toNotEq tonoteq (Lxy , Rxy) x≡y = rec (λ x → x Lxy x≡y) (λ y → y Rxy x≡y) tonoteq irreflexive : Irreflexive L ⊎ Irreflexive R → Irreflexive (L ∩ R) irreflexive irrefl (xLx , xRx) = rec (λ x → x xLx) (λ y → y xRx) irrefl antisymmetric : Antisymmetric L ⊎ Antisymmetric R → Antisymmetric (L ∩ R) antisymmetric (inl L-antisym) (Lxy , _) (Lyx , _) = L-antisym Lxy Lyx antisymmetric (inr R-antisym) (_ , Rxy) (_ , Ryx) = R-antisym Rxy Ryx module _ {a b ℓ₁ ℓ₂ ℓ₃} {A : Type a} {B : Type b} (≈ : RawREL A B ℓ₁) {L : RawREL A B ℓ₂} {R : RawREL A B ℓ₃} where implies : (≈ ⇒ L) → (≈ ⇒ R) → ≈ ⇒ (L ∩ R) implies ≈⇒L ≈⇒R = intro ≈⇒L ≈⇒R module _ {a ℓ₁ ℓ₂ ℓ₃} {A : Type a} (≈ : RawRel A ℓ₁) (L : RawRel A ℓ₂) (R : RawRel A ℓ₃) where respectsˡ : L Respectsˡ ≈ → R Respectsˡ ≈ → (L ∩ R) Respectsˡ ≈ respectsˡ L-resp R-resp x≈y = map (L-resp x≈y) (R-resp x≈y) respectsʳ : L Respectsʳ ≈ → R Respectsʳ ≈ → (L ∩ R) Respectsʳ ≈ respectsʳ L-resp R-resp x≈y = map (L-resp x≈y) (R-resp x≈y) respects₂ : L Respects₂ ≈ → R Respects₂ ≈ → (L ∩ R) Respects₂ ≈ respects₂ (Lʳ , Lˡ) (Rʳ , Rˡ) = respectsʳ Lʳ Rʳ , respectsˡ Lˡ Rˡ module _ {a b ℓ₁ ℓ₂} {A : Type a} {B : Type b} {L : RawREL A B ℓ₁} {R : RawREL A B ℓ₂} where decidable : Decidable L → Decidable R → Decidable (L ∩ R) decidable L? R? x y = ×-dec (L? x y) (R? x y) ------------------------------------------------------------------------ -- Structures module _ {a ℓ₁ ℓ₂} {A : Type a} {L : RawRel A ℓ₁} {R : RawRel A ℓ₂} where isPartialEquivalence : IsPartialEquivalence L → IsPartialEquivalence R → IsPartialEquivalence (L ∩ R) isPartialEquivalence eqₗ eqᵣ = record { symmetric = symmetric L R Eqₗ.symmetric Eqᵣ.symmetric ; transitive = transitive L R Eqₗ.transitive Eqᵣ.transitive } where module Eqₗ = IsPartialEquivalence eqₗ; module Eqᵣ = IsPartialEquivalence eqᵣ isEquivalence : IsEquivalence L → IsEquivalence R → IsEquivalence (L ∩ R) isEquivalence eqₗ eqᵣ = record { isPartialEquivalence = isPartialEquivalence Eqₗ.isPartialEquivalence Eqᵣ.isPartialEquivalence ; reflexive = reflexive L R Eqₗ.reflexive Eqᵣ.reflexive } where module Eqₗ = IsEquivalence eqₗ; module Eqᵣ = IsEquivalence eqᵣ isDecEquivalence : IsDecEquivalence L → IsDecEquivalence R → IsDecEquivalence (L ∩ R) isDecEquivalence eqₗ eqᵣ = record { isEquivalence = isEquivalence Eqₗ.isEquivalence Eqᵣ.isEquivalence ; _≟_ = decidable Eqₗ._≟_ Eqᵣ._≟_ } where module Eqₗ = IsDecEquivalence eqₗ; module Eqᵣ = IsDecEquivalence eqᵣ isPreorder : IsPreorder L → IsPreorder R → IsPreorder (L ∩ R) isPreorder Oₗ Oᵣ = record { reflexive = reflexive L R Oₗ.reflexive Oᵣ.reflexive ; transitive = transitive L R Oₗ.transitive Oᵣ.transitive } where module Oₗ = IsPreorder Oₗ; module Oᵣ = IsPreorder Oᵣ isPartialOrderˡ : IsPartialOrder L → IsPreorder R → IsPartialOrder (L ∩ R) isPartialOrderˡ Oₗ Oᵣ = record { isPreorder = isPreorder Oₗ.isPreorder Oᵣ ; antisym = antisymmetric L R (inl Oₗ.antisym) } where module Oₗ = IsPartialOrder Oₗ; module Oᵣ = IsPreorder Oᵣ isPartialOrderʳ : IsPreorder L → IsPartialOrder R → IsPartialOrder (L ∩ R) isPartialOrderʳ Oₗ Oᵣ = record { isPreorder = isPreorder Oₗ Oᵣ.isPreorder ; antisym = antisymmetric L R (inr Oᵣ.antisym) } where module Oₗ = IsPreorder Oₗ; module Oᵣ = IsPartialOrder Oᵣ isStrictPartialOrderˡ : IsStrictPartialOrder L → Transitive R → IsStrictPartialOrder (L ∩ R) isStrictPartialOrderˡ Oₗ transitiveᵣ = record { irrefl = irreflexive L R (inl Oₗ.irrefl) ; transitive = transitive L R Oₗ.transitive transitiveᵣ } where module Oₗ = IsStrictPartialOrder Oₗ isStrictPartialOrderʳ : Transitive L → IsStrictPartialOrder R → IsStrictPartialOrder (L ∩ R) isStrictPartialOrderʳ transitiveₗ Oᵣ = record { irrefl = irreflexive L R (inr Oᵣ.irrefl) ; transitive = transitive L R transitiveₗ Oᵣ.transitive } where module Oᵣ = IsStrictPartialOrder Oᵣ
{ "alphanum_fraction": 0.634402852, "avg_line_length": 40.9489051095, "ext": "agda", "hexsha": "40b580926bfdec81145a5a767a09ce9728216367", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Relation/Binary/Raw/Construct/Intersection.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Relation/Binary/Raw/Construct/Intersection.agda", "max_line_length": 103, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Relation/Binary/Raw/Construct/Intersection.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2181, "size": 5610 }
-- Andreas & Jesper, 2018-05-11, issue #3052 reported by identicalsnowflake -- -- The problem here was that free variable collection had the standard -- monoid instance of IntMap, which is just "randomly" picking one variant. -- Thus, if we have both irrelevant and relevant occurrences of a variable, -- we get whatever. -- Now we keep the stronger information (relevant, see maxVarOcc). {-# OPTIONS --show-irrelevant #-} -- {-# OPTIONS -v tc.meta.assign:100 -v tc.meta.occurs:45 #-} -- {-# OPTIONS -v tc.lhs:100 #-} postulate A : Set B : A → Set record Σ : Set where constructor _,_ field proj₁ : A proj₂ : B proj₁ open Σ public record Foo : Set where constructor foo field .theFoo : Σ test : Foo → Foo test (foo (a , b)) = foo (a , thm a b) -- Error at b -- Constraint: a, b ⊢ ?0 .a .b a = B a : Set -- Note the irrelevant occurrence .a and the relevant occurrence a -- on the lhs of this constraint! where -- Meta ?0 : [.a, .b, x] Set postulate thm : (x : A) (y : _) → B x -- Underscore should solved by B x -- thm x y = y -- WAS: Worked only if definition is given (which -- Should succeed.
{ "alphanum_fraction": 0.6460869565, "avg_line_length": 28.0487804878, "ext": "agda", "hexsha": "34070f53a3f5c932abaac107e269a0ad0f93b9a9", "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/Issue3052-simplified.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/Issue3052-simplified.agda", "max_line_length": 75, "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/Issue3052-simplified.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": 350, "size": 1150 }
module Ex3Lec where ---------------------------------------------------------------------------- -- EXERCISE 3 -- MONADS FOR HUTTON'S RAZOR -- -- VALUE: 15% -- DEADLINE: 5pm, Friday 20 November (week 9) -- -- DON'T SUBMIT, COMMIT! -- -- The purpose of this exercise is to introduce you to some useful -- mathematical structures and build good tools for working with -- vectors ---------------------------------------------------------------------------- open import CS410-Prelude open import CS410-Monoid open import CS410-Nat open import CS410-Vec open import CS410-Functor -- HINT: your tasks are heralded with the eminently searchable tag, "???" ---------------------------------------------------------------------------- -- HUTTON'S RAZOR ---------------------------------------------------------------------------- HVal : Set -- the set of *values* for Hutton's Razor HVal = Two + Nat -- Booleans or natural numbers foo : HVal foo = tt , ff goo : HVal goo = ff , 42 data HExp (X : Set) : Set where var : X -> HExp X -- variables val : HVal -> HExp X -- values _+H_ _>=H_ : (e1 e2 : HExp X) -> HExp X -- addition, comparison ifH_then_else_ : (e1 e2 e3 : HExp X) -> HExp X -- conditional _>=2_ : Nat -> Nat -> Two x >=2 zero = tt zero >=2 suc _ = ff suc m >=2 suc n = m >=2 n ---------------------------------------------------------------------------- -- ??? 3.1 the HExp syntax-with-substitution monad (score: ? / 2) ---------------------------------------------------------------------------- -- Show that HExp is a monad, where the "bind" operation performs -- simultaneous substitution (transforming all the variables in a term). hExpMonad : Monad HExp hExpMonad = record { return = {!!} ; _>>=_ = {!!} } ---------------------------------------------------------------------------- -- ??? 3.2 the error management monad (score: ? / 1) ---------------------------------------------------------------------------- -- show that "+ E" is monadic, generalising the "Maybe" monad by allowing -- some sort of error report errorMonad : (E : Set) -> Monad \ V -> V + E -- "value or error" errorMonad E = {!!} ---------------------------------------------------------------------------- -- ??? 3.3 the environment monad transformer (score: ? / 1) ---------------------------------------------------------------------------- -- show that "+ E" is monadic, generalising the "Maybe" monad by allowing -- some sort of error report envMonad : (G : Set){M : Set -> Set} -> Monad M -> Monad \ V -> G -> M V -- "computation in an environment" envMonad G MM = {!!} where open Monad MM ---------------------------------------------------------------------------- -- ??? 3.4 interpreting Hutton's Razor (score: ? / 3) ---------------------------------------------------------------------------- -- Implement an interpreter for Hutton's Razor. -- You will need to construct a type to represent possible run-time errors. -- Ensure that addition and comparison act on numbers, not Booleans. -- Ensure that the condition in an "if" is a Boolean, not a number. data InterpretError : Set where -- helpful things to build Env : Set -> Set -- an environment for a given set of variables Env X = X -> HVal Compute : Set{- variables -} -> Set{- values -} -> Set Compute X V = Env X -> V + InterpretError -- how to compute a V computeMonad : {X : Set} -> Monad (Compute X) computeMonad = {!!} -- build this from the above parts -- This operation should explain how to get the value of a variable -- from the environment. varVal : {X : Set} -> X -> Compute X HVal varVal x = {!!} -- These operations should ensure that you get the sort of value -- that you want, in order to ensure that you don't do bogus -- computation. mustBeNat : {X : Set} -> HVal -> Compute X Nat mustBeNat v = {!!} mustBeTwo : {X : Set} -> HVal -> Compute X Two mustBeTwo v = {!!} -- Now, you're ready to go. Don't introduce the environent explicitly. -- Use the monad to thread it. interpret : {X : Set} -> HExp X -> Compute X HVal interpret {X} = go where open Monad (envMonad (Env X) (errorMonad InterpretError)) go : HExp X -> Env X -> HVal + InterpretError go t = {!!}
{ "alphanum_fraction": 0.494014733, "avg_line_length": 33.6744186047, "ext": "agda", "hexsha": "2f3d8f69983ebbbfdb77b9f330f74d67ccb09bd3", "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": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "clarkdm/CS410", "max_forks_repo_path": "Ex3Lec.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "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": "clarkdm/CS410", "max_issues_repo_path": "Ex3Lec.agda", "max_line_length": 77, "max_stars_count": null, "max_stars_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "clarkdm/CS410", "max_stars_repo_path": "Ex3Lec.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1018, "size": 4344 }
{-# OPTIONS --type-in-type #-} open import Data.Product data ⊥ : Set where -- f doesn't type check unless we put the equality type in Set data _≡_ {ℓ} {A : Set ℓ} (a : A) : A → Set where refl : a ≡ a subst : ∀ {ℓ ℓ′} {A : Set ℓ} {a b : A} → (P : A → Set ℓ′) → (p : a ≡ b) → P a → P b subst _ refl pa = pa ¬_ : ∀ {ℓ} → Set ℓ → Set ℓ ¬ A = A → ⊥ ℘ : ∀ {ℓ} → Set ℓ → Set _ ℘ {ℓ} S = S → Set {-# NO_POSITIVITY_CHECK #-} record Bad : Set₁ where constructor mkBad field bad : ℘ (℘ Bad) f : ℘ Bad → Bad f p = mkBad (_≡ p) fInj : ∀ {p q} → f p ≡ f q → p ≡ q fInj {p} fp≡fq = subst (λ p≡ → p≡ p) (badInj fp≡fq) refl where badInj : ∀ {a b} → mkBad a ≡ mkBad b → a ≡ b badInj refl = refl -- type-in-type is for here onwards P₀ : ℘ Bad P₀ x = Σ[ P ∈ ℘ Bad ] x ≡ f P × ¬ (P x) x₀ : Bad x₀ = f P₀ P₀x₀→¬P₀x₀ : P₀ x₀ → ¬ P₀ x₀ P₀x₀→¬P₀x₀ (P , x₀≡fP , ¬Px₀) P₀x₀ = ¬Px₀ (subst (λ P → P x₀) (fInj x₀≡fP) P₀x₀) ¬P₀x₀→P₀x₀ : ¬ P₀ x₀ → P₀ x₀ ¬P₀x₀→P₀x₀ ¬P₀x₀ = P₀ , refl , ¬P₀x₀ ¬P₀x₀ : ¬ P₀ x₀ ¬P₀x₀ P₀x₀ = P₀x₀→¬P₀x₀ P₀x₀ P₀x₀ false : ⊥ false = ¬P₀x₀ (¬P₀x₀→P₀x₀ ¬P₀x₀)
{ "alphanum_fraction": 0.5296846011, "avg_line_length": 21.137254902, "ext": "agda", "hexsha": "8fd5263b2615ce62d17f1b3ee7e1531532899940", "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": "d54cdaf24391b2726e491a18cba2d2d8ae3ac20b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ionathanch/ionathanch.github.io", "max_forks_repo_path": "_assets/agda/Positivity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d54cdaf24391b2726e491a18cba2d2d8ae3ac20b", "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": "ionathanch/ionathanch.github.io", "max_issues_repo_path": "_assets/agda/Positivity.agda", "max_line_length": 83, "max_stars_count": null, "max_stars_repo_head_hexsha": "d54cdaf24391b2726e491a18cba2d2d8ae3ac20b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ionathanch/ionathanch.github.io", "max_stars_repo_path": "_assets/agda/Positivity.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 569, "size": 1078 }
open import System.IO using ( _>>_ ; putStr ; commit ) open import Data.Natural using ( show ) open import System.IO.Examples.Four using ( four ) module System.IO.Examples.HelloFour where main = putStr "Hello, " >> putStr (show four) >> putStr ".\n" >> commit
{ "alphanum_fraction": 0.7022900763, "avg_line_length": 32.75, "ext": "agda", "hexsha": "db9b3c20496f85d86365534c060cf98ae52f7c52", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:23.000Z", "max_forks_repo_forks_event_min_datetime": "2017-08-10T06:12:54.000Z", "max_forks_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ilya-fiveisky/agda-system-io", "max_forks_repo_path": "src/System/IO/Examples/HelloFour.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "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": "ilya-fiveisky/agda-system-io", "max_issues_repo_path": "src/System/IO/Examples/HelloFour.agda", "max_line_length": 71, "max_stars_count": 10, "max_stars_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ilya-fiveisky/agda-system-io", "max_stars_repo_path": "src/System/IO/Examples/HelloFour.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-15T04:35:41.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-04T13:45:16.000Z", "num_tokens": 71, "size": 262 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Monoids.Definition module Semirings.Definition where record Semiring {a : _} {A : Set a} (Zero One : A) (_+_ : A → A → A) (_*_ : A → A → A) : Set a where field monoid : Monoid Zero _+_ commutative : (a b : A) → a + b ≡ b + a multMonoid : Monoid One _*_ productZeroLeft : (a : A) → Zero * a ≡ Zero productZeroRight : (a : A) → a * Zero ≡ Zero +DistributesOver* : (a b c : A) → a * (b + c) ≡ (a * b) + (a * c) +DistributesOver*' : (a b c : A) → (a + b) * c ≡ (a * c) + (b * c) +Associative = Monoid.associative monoid *Associative = Monoid.associative multMonoid productOneLeft = Monoid.idLeft multMonoid productOneRight = Monoid.idRight multMonoid sumZeroLeft = Monoid.idLeft monoid sumZeroRight = Monoid.idRight monoid +WellDefined : {a b c d : A} → (a ≡ c) → (b ≡ d) → (a + b) ≡ (c + d) +WellDefined refl refl = refl -- (b+c)(a+a) == b(a+a) + c(a+a) == ba+ba+ca+ca == (ba+ca) + (ba+ca) -- (b+c)(a+a) ==? (b+c)a+(b+c)a
{ "alphanum_fraction": 0.5820754717, "avg_line_length": 37.8571428571, "ext": "agda", "hexsha": "92e5f571d9e5ff16c1b5922b9fa2251725d0e339", "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": "Semirings/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": "Semirings/Definition.agda", "max_line_length": 100, "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": "Semirings/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": 412, "size": 1060 }
{-# OPTIONS --type-in-type --rewriting #-} open import Agda.Builtin.Sigma open import Agda.Builtin.Equality coe : {A B : Set} → A ≡ B → A → B coe refl x = x {-# BUILTIN REWRITE _≡_ #-} Tel = Set U = Set variable Δ : Tel A B : Δ → U δ₀ δ₁ : Δ postulate IdTel : (Δ : Tel)(δ₀ δ₁ : Δ) → Tel Id : (A : Δ → U){δ₀ δ₁ : Δ}(δ₂ : IdTel Δ δ₀ δ₁) → A δ₀ → A δ₁ → U ap : {A : Δ → U}(a : (δ : Δ) → A δ) → {δ₀ δ₁ : Δ}(δ₂ : IdTel Δ δ₀ δ₁) → Id A δ₂ (a δ₀) (a δ₁) idTel-sigma : {a₀ : A δ₀}{a₁ : A δ₁} → IdTel (Σ Δ A) (δ₀ , a₀) (δ₁ , a₁) ≡ Σ (IdTel Δ δ₀ δ₁) (λ δ₂ → Id A δ₂ a₀ a₁) {-# REWRITE idTel-sigma #-} id-u : {A₀ A₁ : U}{δ₂ : IdTel Δ δ₀ δ₁} → Id {Δ = Δ}(λ _ → U) δ₂ A₀ A₁ ≡ (A₀ → A₁ → U) {-# REWRITE id-u #-} id-ap : {δ₂ : IdTel Δ δ₀ δ₁}{a₀ : A δ₀}{a₁ : A δ₁} → Id A δ₂ a₀ a₁ ≡ ap {A = λ _ → U} A δ₂ a₀ a₁ ap-sigma : {δ₂ : IdTel Δ δ₀ δ₁}{a₀ : A δ₀}{a₁ : A δ₁} {B : (δ : Δ) → A δ → U} {b₀ : B δ₀ a₀}{b₁ : B δ₁ a₁}→ ap {Δ = Δ}{A = λ _ → U} (λ δ → Σ (A δ) (B δ)) δ₂ (a₀ , b₀) (a₁ , b₁) ≡ Σ (Id A δ₂ a₀ a₁) λ a₂ → Id {Δ = Σ Δ A} (λ (δ , a) → B δ a) (δ₂ , a₂) b₀ b₁ {-# REWRITE ap-sigma #-} {-# REWRITE id-ap #-} ap-proj₁ : {δ₂ : IdTel Δ δ₀ δ₁} {B : (δ : Δ) → A δ → U} {ab : (δ : Δ) → Σ (A δ) (B δ)} → ap {Δ = Δ}{A = A}(λ δ → fst (ab δ)) δ₂ ≡ fst (ap ab δ₂)
{ "alphanum_fraction": 0.4121253406, "avg_line_length": 28.7843137255, "ext": "agda", "hexsha": "20baf87b539733db297ad34dd41aa8e1f01c1905", "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/Issue5531.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/Issue5531.agda", "max_line_length": 91, "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/Issue5531.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": 688, "size": 1468 }
{-# OPTIONS --cubical-compatible --rewriting --confluence-check #-} module Issue1719.Spans where open import Issue1719.Common record Span : Set₁ where constructor span field A B C : Set f : C → A g : C → B open Span public
{ "alphanum_fraction": 0.673553719, "avg_line_length": 17.2857142857, "ext": "agda", "hexsha": "b6bd69c2798968c5eedca6d1dc2a9350dc2d99fe", "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/Issue1719/Spans.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/Issue1719/Spans.agda", "max_line_length": 67, "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/Issue1719/Spans.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 69, "size": 242 }