Search is not available for this dataset
text
string
meta
dict
{-# OPTIONS --sized-types #-} open import Relation.Binary.Core module BubbleSort.Correctness.Order {A : Set} (_≤_ : A → A → Set) (tot≤ : Total _≤_) (trans≤ : Transitive _≤_) where open import BubbleSort _≤_ tot≤ open import Data.Product open import Data.List open import Data.Sum open import Function using (_∘_) open import List.Sorted _≤_ open import Order.Total _≤_ tot≤ open import Size open import SList open import SList.Order _≤_ open import SList.Order.Properties _≤_ lemma-swap*-≤*-≤ : {ι : Size}{x t : A}{xs : SList A {ι}} → x ≤ t → xs ≤* t → proj₁ (swap* x xs) ≤* t × proj₂ (swap* x xs) ≤ t lemma-swap*-≤*-≤ x≤t lenx = lenx , x≤t lemma-swap*-≤*-≤ {x = x} x≤t (lecx {x = y} y≤t ys≤*t) with tot≤ x y ... | inj₁ x≤y = lecx x≤t (proj₁ (lemma-swap*-≤*-≤ y≤t ys≤*t)), proj₂ (lemma-swap*-≤*-≤ y≤t ys≤*t) ... | inj₂ y≤x = lecx y≤t (proj₁ (lemma-swap*-≤*-≤ x≤t ys≤*t)), proj₂ (lemma-swap*-≤*-≤ x≤t ys≤*t) lemma-bubbleSort-≤* : {ι : Size}{t : A}{xs : SList A {ι}} → xs ≤* t → bubbleSort xs ≤* t lemma-bubbleSort-≤* lenx = lenx lemma-bubbleSort-≤* (lecx x≤t xs≤*t) with lemma-swap*-≤*-≤ x≤t xs≤*t ... | (zs≤*t , z≤t) = lemma-⊕≤* z≤t (lemma-bubbleSort-≤* zs≤*t) lemma-swap*-≤ : {ι : Size}(x : A) → (xs : SList A {ι}) → x ≤ proj₂ (swap* x xs) lemma-swap*-≤ x snil = refl≤ lemma-swap*-≤ x (y ∙ ys) with tot≤ x y ... | inj₁ x≤y = trans≤ x≤y (lemma-swap*-≤ y ys) ... | inj₂ y≤x = lemma-swap*-≤ x ys lemma-swap*-≤* : {ι : Size}(x : A) → (xs : SList A {ι}) → proj₁ (swap* x xs) ≤* proj₂ (swap* x xs) lemma-swap*-≤* x snil = lenx lemma-swap*-≤* x (y ∙ ys) with tot≤ x y ... | inj₁ x≤y = lecx (trans≤ x≤y (lemma-swap*-≤ y ys)) (lemma-swap*-≤* y ys) ... | inj₂ y≤x = lecx (trans≤ y≤x (lemma-swap*-≤ x ys)) (lemma-swap*-≤* x ys) lemma-bubbleSort-sorted : {ι : Size}(xs : SList A {ι}) → Sorted (unsize A (bubbleSort xs)) lemma-bubbleSort-sorted snil = nils lemma-bubbleSort-sorted (x ∙ xs) = lemma-sorted⊕ (lemma-bubbleSort-≤* (lemma-swap*-≤* x xs)) (lemma-bubbleSort-sorted (proj₁ (swap* x xs))) theorem-bubbleSort-sorted : (xs : List A) → Sorted (unsize A (bubbleSort (size A xs))) theorem-bubbleSort-sorted = lemma-bubbleSort-sorted ∘ (size A)
{ "alphanum_fraction": 0.5820962663, "avg_line_length": 39, "ext": "agda", "hexsha": "ff0a098a0e4b95ef952e8bcd93cea6fa3c4d4181", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/BubbleSort/Correctness/Order.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/BubbleSort/Correctness/Order.agda", "max_line_length": 139, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/BubbleSort/Correctness/Order.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 960, "size": 2223 }
module nix-emacs-agda where
{ "alphanum_fraction": 0.8214285714, "avg_line_length": 14, "ext": "agda", "hexsha": "bac4f0e0920c76fdce60d318a51b127c1655d4e4", "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": "f08dc7790ef9e30b7fd764643f312dd492a63793", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "o1lo01ol1o/nix-emacs-agda", "max_forks_repo_path": "src/nix-emacs-agda.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f08dc7790ef9e30b7fd764643f312dd492a63793", "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": "o1lo01ol1o/nix-emacs-agda", "max_issues_repo_path": "src/nix-emacs-agda.agda", "max_line_length": 27, "max_stars_count": null, "max_stars_repo_head_hexsha": "f08dc7790ef9e30b7fd764643f312dd492a63793", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "o1lo01ol1o/nix-emacs-agda", "max_stars_repo_path": "src/nix-emacs-agda.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 9, "size": 28 }
{-# OPTIONS --without-K #-} open import lib.Base open import lib.PathGroupoid open import lib.PathFunctor open import lib.Equivalences module lib.Univalence where {- The map [coe-equiv] is the map which is supposed to be an equivalence according to the univalence axiom. We do not define it directly by path induction because it may be helpful to know definitionally what are the components. -} coe-equiv : ∀ {i} {A B : Type i} → A == B → A ≃ B coe-equiv p = equiv (coe p) (coe! p) (coe!-inv-r p) (coe!-inv-l p) {- We postulate the univalence axiom as three separate axioms because it’s more natural this way. But it doesn’t change anything in practice. -} postulate -- Univalence axiom ua : ∀ {i} {A B : Type i} → (A ≃ B) → A == B coe-equiv-β : ∀ {i} {A B : Type i} (e : A ≃ B) → coe-equiv (ua e) == e ua-η : ∀ {i} {A B : Type i} (p : A == B) → ua (coe-equiv p) == p ua-equiv : ∀ {i} {A B : Type i} → (A ≃ B) ≃ (A == B) ua-equiv = equiv ua coe-equiv ua-η coe-equiv-β {- Reductions for coercions along a path constructed with the univalence axiom -} coe-β : ∀ {i} {A B : Type i} (e : A ≃ B) (a : A) → coe (ua e) a == –> e a coe-β e a = ap (λ e → –> e a) (coe-equiv-β e) coe!-β : ∀ {i} {A B : Type i} (e : A ≃ B) (b : B) → coe! (ua e) b == <– e b coe!-β e a = ap (λ e → <– e a) (coe-equiv-β e) {- Paths over a path in a universe in the identity fibration reduces -} ↓-idf-ua-out : ∀ {i} {A B : Type i} (e : A ≃ B) {u : A} {v : B} → u == v [ (λ x → x) ↓ (ua e) ] → –> e u == v ↓-idf-ua-out e p = ! (coe-β e _) ∙ aux (ua e) p where aux : ∀ {i} {A B : Type i} (p : A == B) {u : A} {v : B} → u == v [ (λ x → x) ↓ p ] → coe p u == v aux idp = idf _ ↓-idf-ua-in : ∀ {i} {A B : Type i} (e : A ≃ B) {u : A} {v : B} → –> e u == v → u == v [ (λ x → x) ↓ (ua e) ] ↓-idf-ua-in e p = aux (ua e) (coe-β e _ ∙ p) where aux : ∀ {i} {A B : Type i} (p : A == B) {u : A} {v : B} → coe p u == v → u == v [ (λ x → x) ↓ p ] aux idp = idf _ {- Induction along equivalences If [P] is a predicate over all equivalences in a universe [Type i] and [d] is a proof of [P] over all [ide A], then we get a section of [P] -} equiv-induction : ∀ {i j} (P : {A B : Type i} (f : A ≃ B) → Type j) (d : (A : Type i) → P (ide A)) {A B : Type i} (f : A ≃ B) → P f equiv-induction {i} {j} P d f = transport P (coe-equiv-β f) (aux P d (ua f)) where aux : ∀ {j} (P : {A : Type i} {B : Type i} (f : A ≃ B) → Type j) (d : (A : Type i) → P (ide A)) {A B : Type i} (p : A == B) → P (coe-equiv p) aux P d idp = d _
{ "alphanum_fraction": 0.5274294671, "avg_line_length": 32.7179487179, "ext": "agda", "hexsha": "b252f6192ac4abd2006df6fa7fc5516cc2a49816", "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": "c8fb8da3354fc9e0c430ac14160161759b4c5b37", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "sattlerc/HoTT-Agda", "max_forks_repo_path": "lib/Univalence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c8fb8da3354fc9e0c430ac14160161759b4c5b37", "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": "sattlerc/HoTT-Agda", "max_issues_repo_path": "lib/Univalence.agda", "max_line_length": 81, "max_stars_count": null, "max_stars_repo_head_hexsha": "c8fb8da3354fc9e0c430ac14160161759b4c5b37", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "sattlerc/HoTT-Agda", "max_stars_repo_path": "lib/Univalence.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1037, "size": 2552 }
module Data.List.Relation.Binary.Subset.Propositional.Instances where open import Data.List using (List; _∷_; []) open import Data.List.Relation.Unary.Any using (here; there) open import Data.List.Membership.Propositional using (_∈_; _∉_) open import Data.List.Membership.Setoid.Properties using (∈-resp-≈) open import Data.List.Relation.Binary.Subset.Propositional using (_⊆_) open import Relation.Nullary.Negation using (contradiction) open import Relation.Binary.PropositionalEquality using (sym; setoid) open import Level using (Level) private variable a : Level A : Set a x y : A xs ys : List A -- ---------------------------------------------------------------------- -- Wrapped subset. Could use Data.Wrap but required curried arguments -- Easier to define specific data type. infix 4 ⦅_⊆_⦆ data ⦅_⊆_⦆ {a} {A : Set a} : List A → List A → Set a where [_] : xs ⊆ ys → ⦅ xs ⊆ ys ⦆ proj : ⦅ xs ⊆ ys ⦆ → xs ⊆ ys proj [ xs⊆ys ] = xs⊆ys -- ---------------------------------------------------------------------- -- Lemmas used for instance searching x∉[] : x ∉ [] x∉[] = λ () []⊆xs : [] ⊆ xs []⊆xs = λ x∈[] → contradiction x∈[] x∉[] xs⊆x∷xs : xs ⊆ x ∷ xs xs⊆x∷xs = there xs⊆ys⇒x∷xs⊆x∷ys : xs ⊆ ys → x ∷ xs ⊆ x ∷ ys xs⊆ys⇒x∷xs⊆x∷ys xs⊆ys (here y≡x) = here y≡x xs⊆ys⇒x∷xs⊆x∷ys xs⊆ys (there y∈x∷xs) = there (xs⊆ys y∈x∷xs) x∈ys-xs⊆ys⇒x∷xs⊆ys : x ∈ ys → xs ⊆ ys → x ∷ xs ⊆ ys x∈ys-xs⊆ys⇒x∷xs⊆ys x∈ys xs⊆ys (here y≡x) = ∈-resp-≈ (setoid _) (sym y≡x) x∈ys x∈ys-xs⊆ys⇒x∷xs⊆ys x∈ys xs⊆ys (there y∈x∷xs) = xs⊆ys y∈x∷xs -- ---------------------------------------------------------------------- -- Instances instance ⦃[]⊆xs⦄ : ⦅ [] ⊆ xs ⦆ ⦃[]⊆xs⦄ = [ []⊆xs ] -- Removed to improve instance search, syntax directed. -- ⦃xs⊆x∷xs⦄ : ⦅ xs ⊆ x ∷ xs ⦆ -- ⦃xs⊆x∷xs⦄ = [ xs⊆x∷xs ] -- ⦃xs⊆ys⇒x∷xs⊆x∷ys⦄ : ⦃ ⦅ xs ⊆ ys ⦆ ⦄ → ⦅ x ∷ xs ⊆ x ∷ ys ⦆ -- ⦃xs⊆ys⇒x∷xs⊆x∷ys⦄ ⦃ [ xs⊆ys ] ⦄ = [ xs⊆ys⇒x∷xs⊆x∷ys xs⊆ys ] ⦃x∈ys-xs⊆ys⇒x∷xs⊆ys⦄ : ⦃ x ∈ ys ⦄ → ⦃ ⦅ xs ⊆ ys ⦆ ⦄ → ⦅ x ∷ xs ⊆ ys ⦆ ⦃x∈ys-xs⊆ys⇒x∷xs⊆ys⦄ ⦃ x∈ys ⦄ ⦃ [ xs⊆ys ] ⦄ = [ x∈ys-xs⊆ys⇒x∷xs⊆ys x∈ys xs⊆ys ]
{ "alphanum_fraction": 0.5207439199, "avg_line_length": 29.5352112676, "ext": "agda", "hexsha": "2b04ca3d4fc9d4c50273e473bab07e2b37701ccd", "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": "921a0dc44a69a74391031ca61568c624ab7f9c94", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "johnyob/agda-union", "max_forks_repo_path": "src/Data/List/Relation/Binary/Subset/Propositional/Instances.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "921a0dc44a69a74391031ca61568c624ab7f9c94", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "johnyob/agda-union", "max_issues_repo_path": "src/Data/List/Relation/Binary/Subset/Propositional/Instances.agda", "max_line_length": 81, "max_stars_count": null, "max_stars_repo_head_hexsha": "921a0dc44a69a74391031ca61568c624ab7f9c94", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "johnyob/agda-union", "max_stars_repo_path": "src/Data/List/Relation/Binary/Subset/Propositional/Instances.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1052, "size": 2097 }
module Pin where -- N-dimensional version of Pi -- open import Data.Fin open import Data.Nat open import Data.Empty open import Data.Unit open import Data.Sum open import Data.Product open import Function renaming (_∘_ to _○_) open import Relation.Binary.PropositionalEquality using (module ≡-Reasoning) open ≡-Reasoning open import Algebra open import Data.Nat.Properties open CommutativeSemiring commutativeSemiring using (+-commutativeMonoid) open CommutativeMonoid +-commutativeMonoid using () renaming (comm to +-comm) --infix 4 _≡_ -- propositional equality --infixr 8 _∘_ -- path composition infixr 10 _◎_ infixr 30 _⟷_ infixr 9 _>>>_ -- infixr 30 _⟺_ ------------------------------------------------------------------------------ -- base types (or 0d types) are the usual finite types data T : Set where Zero : T One : T Plus : T → T → T Times : T → T → T -- Combinators on 0d types data _⟷_ : T → T → Set where unite₊ : { t : T } → Plus Zero t ⟷ t uniti₊ : { t : T } → t ⟷ Plus Zero t swap₊ : { t₁ t₂ : T } → Plus t₁ t₂ ⟷ Plus t₂ t₁ assocl₊ : { t₁ t₂ t₃ : T } → Plus t₁ (Plus t₂ t₃) ⟷ Plus (Plus t₁ t₂) t₃ assocr₊ : { t₁ t₂ t₃ : T } → Plus (Plus t₁ t₂) t₃ ⟷ Plus t₁ (Plus t₂ t₃) unite⋆ : { t : T } → Times One t ⟷ t uniti⋆ : { t : T } → t ⟷ Times One t swap⋆ : { t₁ t₂ : T } → Times t₁ t₂ ⟷ Times t₂ t₁ assocl⋆ : { t₁ t₂ t₃ : T } → Times t₁ (Times t₂ t₃) ⟷ Times (Times t₁ t₂) t₃ assocr⋆ : { t₁ t₂ t₃ : T } → Times (Times t₁ t₂) t₃ ⟷ Times t₁ (Times t₂ t₃) distz : { t : T } → Times Zero t ⟷ Zero factorz : { t : T } → Zero ⟷ Times Zero t dist : { t₁ t₂ t₃ : T } → Times (Plus t₁ t₂) t₃ ⟷ Plus (Times t₁ t₃) (Times t₂ t₃) factor : { t₁ t₂ t₃ : T } → Plus (Times t₁ t₃) (Times t₂ t₃) ⟷ Times (Plus t₁ t₂) t₃ id⟷ : { t : T } → t ⟷ t sym⟷ : { t₁ t₂ : T } → (t₁ ⟷ t₂) → (t₂ ⟷ t₁) _◎_ : { t₁ t₂ t₃ : T } → (t₁ ⟷ t₂) → (t₂ ⟷ t₃) → (t₁ ⟷ t₃) _⊕_ : { t₁ t₂ t₃ t₄ : T } → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (Plus t₁ t₂ ⟷ Plus t₃ t₄) _⊗_ : { t₁ t₂ t₃ t₄ : T } → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (Times t₁ t₂ ⟷ Times t₃ t₄) -- Semantics ⟦_⟧ : T → Set ⟦ Zero ⟧ = ⊥ ⟦ One ⟧ = ⊤ ⟦ Plus t1 t2 ⟧ = ⟦ t1 ⟧ ⊎ ⟦ t2 ⟧ ⟦ Times t1 t2 ⟧ = ⟦ t1 ⟧ × ⟦ t2 ⟧ mutual eval : {t₁ t₂ : T} → (t₁ ⟷ t₂) → ⟦ t₁ ⟧ → ⟦ t₂ ⟧ eval unite₊ (inj₁ ()) eval unite₊ (inj₂ v) = v eval uniti₊ v = inj₂ v eval swap₊ (inj₁ v) = inj₂ v eval swap₊ (inj₂ v) = inj₁ v eval assocl₊ (inj₁ v) = inj₁ (inj₁ v) eval assocl₊ (inj₂ (inj₁ v)) = inj₁ (inj₂ v) eval assocl₊ (inj₂ (inj₂ v)) = inj₂ v eval assocr₊ (inj₁ (inj₁ v)) = inj₁ v eval assocr₊ (inj₁ (inj₂ v)) = inj₂ (inj₁ v) eval assocr₊ (inj₂ v) = inj₂ (inj₂ v) eval unite⋆ (tt , v) = v eval uniti⋆ v = (tt , v) eval swap⋆ (v1 , v2) = (v2 , v1) eval assocl⋆ (v1 , (v2 , v3)) = ((v1 , v2) , v3) eval assocr⋆ ((v1 , v2) , v3) = (v1 , (v2 , v3)) eval distz (() , v) eval factorz () eval dist (inj₁ v1 , v3) = inj₁ (v1 , v3) eval dist (inj₂ v2 , v3) = inj₂ (v2 , v3) eval factor (inj₁ (v1 , v3)) = (inj₁ v1 , v3) eval factor (inj₂ (v2 , v3)) = (inj₂ v2 , v3) eval id⟷ v = v eval (sym⟷ c) v = evalB c v eval (c₁ ◎ c₂) v = eval c₂ (eval c₁ v) eval (c₁ ⊕ c₂) (inj₁ v) = inj₁ (eval c₁ v) eval (c₁ ⊕ c₂) (inj₂ v) = inj₂ (eval c₂ v) eval (c₁ ⊗ c₂) (v₁ , v₂) = (eval c₁ v₁ , eval c₂ v₂) evalB : {t₁ t₂ : T} → (t₁ ⟷ t₂) → ⟦ t₂ ⟧ → ⟦ t₁ ⟧ evalB unite₊ v = inj₂ v evalB uniti₊ (inj₁ ()) evalB uniti₊ (inj₂ v) = v evalB swap₊ (inj₁ v) = inj₂ v evalB swap₊ (inj₂ v) = inj₁ v evalB assocl₊ (inj₁ (inj₁ v)) = inj₁ v evalB assocl₊ (inj₁ (inj₂ v)) = inj₂ (inj₁ v) evalB assocl₊ (inj₂ v) = inj₂ (inj₂ v) evalB assocr₊ (inj₁ v) = inj₁ (inj₁ v) evalB assocr₊ (inj₂ (inj₁ v)) = inj₁ (inj₂ v) evalB assocr₊ (inj₂ (inj₂ v)) = inj₂ v evalB unite⋆ v = (tt , v) evalB uniti⋆ (tt , v) = v evalB swap⋆ (v1 , v2) = (v2 , v1) evalB assocl⋆ ((v1 , v2) , v3) = (v1 , (v2 , v3)) evalB assocr⋆ (v1 , (v2 , v3)) = ((v1 , v2) , v3) evalB distz () evalB factorz (() , v) evalB dist (inj₁ (v1 , v3)) = (inj₁ v1 , v3) evalB dist (inj₂ (v2 , v3)) = (inj₂ v2 , v3) evalB factor (inj₁ v1 , v3) = inj₁ (v1 , v3) evalB factor (inj₂ v2 , v3) = inj₂ (v2 , v3) evalB id⟷ v = v evalB (sym⟷ c) v = eval c v evalB (c₁ ◎ c₂) v = evalB c₁ (evalB c₂ v) evalB (c₁ ⊕ c₂) (inj₁ v) = inj₁ (evalB c₁ v) evalB (c₁ ⊕ c₂) (inj₂ v) = inj₂ (evalB c₂ v) evalB (c₁ ⊗ c₂) (v₁ , v₂) = (evalB c₁ v₁ , evalB c₂ v₂) ------------------------------------------------------------------------------ -- N dimensional version data C : ℕ → Set where ZD : T → C 0 Node : {n : ℕ} → C n → C n → C (suc n) liftN : (n : ℕ) → (t : T) → C n liftN 0 t = ZD t liftN (suc n) t = Node (liftN n t) (liftN n Zero) zeroN : (n : ℕ) → C n zeroN n = liftN n Zero oneN : (n : ℕ) → C n oneN n = liftN n One plus : {n : ℕ} → C n → C n → C n plus (ZD t₁) (ZD t₂) = ZD (Plus t₁ t₂) plus (Node c₁ c₂) (Node c₁' c₂') = Node (plus c₁ c₁') (plus c₂ c₂') times : {m n : ℕ} → C m → C n → C (m + n) times (ZD t1) (ZD t2) = ZD (Times t1 t2) times (ZD t) (Node c1 c2) = Node (times (ZD t) c1) (times (ZD t) c2) times (Node c1 c2) c = Node (times c1 c) (times c2 c) -- Combinators on nd types data _⟺_ : {n : ℕ} → C n → C n → Set where baseC : {t₁ t₂ : T} → (t₁ ⟷ t₂) → ((ZD t₁) ⟺ (ZD t₂)) nodeC : {n : ℕ} {c₁ : C n} {c₂ : C n} {c₃ : C n} {c₄ : C n} → (c₁ ⟺ c₂) → (c₃ ⟺ c₄) → ((Node c₁ c₃) ⟺ (Node c₂ c₄)) zerolC : {n : ℕ} {c : C n} → ((Node c c) ⟺ (zeroN (suc n))) zerorC : {n : ℕ} {c : C n} → ((zeroN (suc n)) ⟺ (Node c c)) -- Def. 2.1 lists the conditions for J-graded bipermutative category mutual _>>>_ = seqF idN⟷ : {n : ℕ} {c : C n} → c ⟺ c idN⟷ {0} {ZD t} = baseC (id⟷ {t}) idN⟷ {suc n} {Node c₁ c₂} = nodeC (idN⟷ {n} {c₁}) (idN⟷ {n} {c₂}) symN⟷ : {n : ℕ} {c₁ c₂ : C n} → (c₁ ⟺ c₂) → (c₂ ⟺ c₁) symN⟷ (baseC f) = baseC (sym⟷ f) symN⟷ (nodeC f g) = nodeC (symN⟷ f) (symN⟷ g) symN⟷ (zerolC {n} {c}) = zerorC {n} {c} symN⟷ (zerorC {n} {c}) = zerolC {n} {c} seqF : {n : ℕ} {c₁ c₂ c₃ : C n} → (c₁ ⟺ c₂) → (c₂ ⟺ c₃) → (c₁ ⟺ c₃) seqF {0} (baseC f) (baseC g) = baseC (f ◎ g) seqF {suc n} (nodeC f g) (nodeC f' g') = nodeC (seqF f f') (seqF g g') seqF {suc n} (nodeC f g) zerolC = nodeC (seqF f {!!}) (seqF g {!!}) seqF {suc n} (nodeC f g) zerorC = {!!} seqF {suc n} zerolC (nodeC f g) = {!!} seqF {suc n} zerolC zerolC = {!!} seqF {suc n} zerolC zerorC = {!!} seqF {suc n} zerorC (nodeC f g) = {!!} seqF {suc n} zerorC zerolC = {!!} seqF {suc n} zerorC zerorC = {!!} {-- plusF : {n : ℕ} {c₁ c₂ c₃ c₄ : C n} → (c₁ ⟺ c₂) → (c₃ ⟺ c₄) → (plus c₁ c₃ ⟺ plus c₂ c₄) plusF (baseC f) (baseC g) = baseC (f ⊕ g) plusF (nodeC f) (nodeC g) = nodeC {!!} timesF : {m n : ℕ} {c₁ c₂ : C m} {c₃ c₄ : C n} → (c₁ ⟺ c₂) → (c₃ ⟺ c₄) → (times c₁ c₃ ⟺ times c₂ c₄) timesF (baseC f) (baseC g) = baseC (f ⊗ g) timesF (baseC f) (nodeC g) = nodeC {!!} {-- nodeC ( seqF (plusF (timesF (baseC f) idN⟷) idN⟷) ( seqF (seqF (plusF swapN⋆ swapN⋆) factorN) ( seqF (timesF idN⟷ g) ( seqF (seqF distN (plusF swapN⋆ swapN⋆)) ((plusF (timesF (baseC (sym⟷ f)) idN⟷) idN⟷)))))) --} timesF (nodeC f) (baseC g) = {!!} timesF (nodeC f) (nodeC g) = nodeC {!!} -- nodeC (timesF f₁ g) (timesF f₂ g) -- f : t1 <-> t2 -- g : c1 + c4 <=> c3 + c2 --?24 : plus (times (ZD t₁) c₁) (times (ZD t₂) c₄) ⟺ -- plus (times (ZD t₁) c₃) (times (ZD t₂) c₂) {-- plus (times (ZD t₁) c₁) (times (ZD t₂) c₄) ⟺ -> s1 plus (times (ZD t2) c₁) (times (ZD t₂) c₄) ⟺ -> s2 times (ZD t2) (plus c1 c4) -> s3 times (ZD t2) (plus c3 c2) -> s4 plus (times (ZD t2) c3) (times (ZD t2) c2) -> s5 plus (times (ZD t1) c3) (times (ZD t2) c2) --} uniteN₊ : {n : ℕ} {c : C n} → (plus (zeroN n) c) ⟺ c uniteN₊ {0} {ZD t} = baseC (unite₊ {t}) uniteN₊ {suc n} {Node c₁ c₂} = nodeC (seqF assocrN₊ (seqF (plusF idN⟷ swapN₊) assoclN₊)) unitiN₊ : {n : ℕ} {c : C n} → c ⟺ (plus (zeroN n) c) unitiN₊ {0} {ZD t} = baseC (uniti₊ {t}) unitiN₊ {suc n} {Node c₁ c₂} = nodeC (assoclN₊ >>> swapN₊ >>> (plusF idN⟷ swapN₊)) swapN₊ : { n : ℕ } { c₁ c₂ : C n } → plus c₁ c₂ ⟺ plus c₂ c₁ swapN₊ {0} {ZD t₁} {ZD t₂} = baseC (swap₊ {t₁} {t₂}) swapN₊ {suc n} {Node c₁ c₂} {Node c₁' c₂'} = nodeC (swapN₊ >>> (plusF swapN₊ swapN₊)) assoclN₊ : { n : ℕ } { c₁ c₂ c₃ : C n } → plus c₁ (plus c₂ c₃) ⟺ plus (plus c₁ c₂) c₃ assoclN₊ {0} {ZD t₁} {ZD t₂} {ZD t₃} = baseC (assocl₊ {t₁} {t₂} {t₃}) assoclN₊ {suc n} {Node c₁ c₂} {Node c₃ c₄} {Node c₅ c₆} = nodeC (swapN₊ >>> (plusF assocrN₊ assoclN₊)) assocrN₊ : { n : ℕ } { c₁ c₂ c₃ : C n } → plus (plus c₁ c₂) c₃ ⟺ plus c₁ (plus c₂ c₃) assocrN₊ {0} {ZD t₁} {ZD t₂} {ZD t₃} = baseC (assocr₊ {t₁} {t₂} {t₃}) assocrN₊ {suc n} {Node c₁ c₂} {Node c₃ c₄} {Node c₅ c₆} = nodeC (swapN₊ >>> (plusF assoclN₊ assocrN₊)) uniteN⋆ : {n : ℕ} {c : C n} → times (ZD One) c ⟺ c uniteN⋆ {0} {ZD t} = baseC (unite⋆ {t}) uniteN⋆ {suc n} {Node c₁ c₂} = nodeC {!!} unitiN⋆ : {n : ℕ} {c : C n} → c ⟺ times (ZD One) c unitiN⋆ {0} {ZD t} = baseC (uniti⋆ {t}) unitiN⋆ {suc n} {Node c₁ c₂} = nodeC {!!} -- Ugly hack or feature ??? times' : {m n : ℕ} → C n → C m → C (m + n) times' {m} {n} c₁ c₂ rewrite +-comm m n = times c₁ c₂ swapN⋆ : {m n : ℕ} {c₁ : C m} {c₂ : C n} → times c₁ c₂ ⟺ times' c₂ c₁ swapN⋆ {0} {0} {ZD t₁} {ZD t₂} = baseC (swap⋆ {t₁} {t₂}) swapN⋆ {0} {suc n} {ZD t} {Node c₁ c₂} = {!!} --nodeC (swapN⋆ {0} {n} {ZD t} {c₁}) (swapN⋆ {0} {n} {ZD t} {c₂}) swapN⋆ {suc m} {0} {Node c₁ c₂} {ZD t} = {!!} --nodeC (swapN⋆ {0} {n} {c₁} {ZD t}) (swapN⋆ {0} {n} {c₂} {ZD t}) swapN⋆ {suc m} {n} {Node c₁ c₂} {c} = {!!} --nodeC (swapN⋆ {m} {n} {c₁} {c}) (swapN⋆ {m} {n} {c₂} {c}) TODO : Set TODO = {!!} assoclN⋆ : {m n k : ℕ} {c₁ : C m} {c₂ : C n} {c₃ : C k} → TODO -- times c₁ (times c₂ c₃) ⟺ times (times c₁ c₂) c₃ assoclN⋆ = {!!} assocrN⋆ : { m n k : ℕ } { c₁ : C m } { c₂ : C n } { c₃ : C k } → TODO -- times (times c₁ c₂) c₃ ⟺ times c₁ (times c₂ c₃) assocrN⋆ = {!!} distzN : {m n : ℕ} {c : C n} → times (zeroN m) c ⟺ zeroN (m + n) distzN {0} {0} {ZD t} = baseC (distz {t}) distzN {0} {suc n} {Node c₁ c₂} = nodeC {!!} -- nodeC (distzN {0} {n} {c₁}) (distzN {0} {n} {c₂}) distzN {suc m} {n} {c} = nodeC {!!} -- nodeC (distzN {m} {n} {c}) (distzN {m} {n} {c}) factorzN : { m n : ℕ } { c : C n } → zeroN (m + n) ⟺ times (zeroN m) c factorzN {0} {0} {ZD t} = baseC (factorz {t}) factorzN {0} {suc n} {Node c₁ c₂} = nodeC {!!} -- nodeC (factorzN {0} {n} {c₁}) (factorzN {0} {n} {c₂}) factorzN {suc m} {n} {c} = nodeC {!!} -- nodeC (factorzN {m} {n} {c}) (factorzN {m} {n} {c}) distN : {m n : ℕ} {c₁ c₂ : C m} {c₃ : C n} → times (plus c₁ c₂) c₃ ⟺ plus (times c₁ c₃) (times c₂ c₃) distN {0} {0} {ZD t₁} {ZD t₂} {ZD t₃} = baseC (dist {t₁} {t₂} {t₃}) distN {0} {suc n} {ZD t₁} {ZD t₂} {Node c₁ c₂} = nodeC {!!} -- nodeC -- (distN {0} {n} {ZD t₁} {ZD t₂} {c₁}) -- (distN {0} {n} {ZD t₁} {ZD t₂} {c₂}) distN {suc m} {n} {Node c₁ c₂} {Node c₃ c₄} {c} = nodeC {!!} -- nodeC -- ((distN {m} {n} {c₁} {c₃} {c})) -- ((distN {m} {n} {c₂} {c₄} {c})) factorN : {m n : ℕ} {c₁ c₂ : C m} {c₃ : C n} → plus (times c₁ c₃) (times c₂ c₃) ⟺ times (plus c₁ c₂) c₃ factorN {0} {0} {ZD t₁} {ZD t₂} {ZD t₃} = baseC (factor {t₁} {t₂} {t₃}) factorN {0} {suc n} {ZD t₁} {ZD t₂} {Node c₁ c₂} = nodeC {!!} -- nodeC -- (factorN {0} {n} {ZD t₁} {ZD t₂} {c₁}) -- (factorN {0} {n} {ZD t₁} {ZD t₂} {c₂}) factorN {suc m} {n} {Node c₁ c₂} {Node c₃ c₄} {c} = nodeC {!!} -- nodeC -- ((factorN {m} {n} {c₁} {c₃} {c})) -- ((factorN {m} {n} {c₂} {c₄} {c})) --?25 : plus (times .c₁ .c₃) (times .c₆ .c₄) ⟺ -- plus (times .c₅ .c₃) (times .c₂ .c₄) {-- data _⟺_ : {n : ℕ} → C n → C n → Set where baseC : {t₁ t₂ : T} → (t₁ ⟷ t₂) → ((ZD t₁) ⟺ (ZD t₂)) nodeC : {n : ℕ} {c₁ : C n} {c₂ : C n} {c₃ : C n} {c₄ : C n} → (plus c₁ c₄ ⟺ plus c₃ c₂) → ((Node c₁ c₃) ⟺ (Node c₂ c₄)) --} -- eta/epsilon/trace ------------------------------------------------------------------------------ -- Semantics ⟦_⟧C : {n : ℕ} → C n → Set ⟦_⟧C (ZD t) = ⟦ t ⟧ ⟦_⟧C (Node c₁ c₂) = ⟦ c₁ ⟧C ⊎ ⟦ c₂ ⟧C evalC : {n : ℕ} {c₁ c₂ : C n} → (c₁ ⟺ c₂) → ⟦ c₁ ⟧C → ⟦ c₂ ⟧C evalC (baseC iso) v = eval iso v evalC (nodeC iso) (inj₁ v) = {!!} -- inj₁ (evalC iso v) evalC (nodeC iso) (inj₂ v) = {!!} -- inj₂ (evalC iso v) ------------------------------------------------------------------------------ -- Example -- Let's try a 3d program Bool : T Bool = Plus One One vtrue : ⟦ Bool ⟧ vtrue = inj₁ tt vfalse : ⟦ Bool ⟧ vfalse = inj₂ tt Bool² : T Bool² = Times Bool Bool Bool³ : T Bool³ = Times Bool² Bool cond : {t₁ t₂ : T} → (t₁ ⟷ t₂) → (t₁ ⟷ t₂) → ((Times Bool t₁) ⟷ (Times Bool t₂)) cond f g = dist ◎ ((id⟷ ⊗ f) ⊕ (id⟷ ⊗ g)) ◎ factor controlled : {t : T} → (t ⟷ t) → ((Times Bool t) ⟷ (Times Bool t)) controlled f = cond f id⟷ cnot : Bool² ⟷ Bool² cnot = controlled swap₊ toffoli : Bool³ ⟷ Bool³ toffoli = assocr⋆ ◎ controlled cnot ◎ assocl⋆ test₁ : ⟦ Bool³ ⟧ test₁ = eval toffoli ((vtrue , vtrue) , vfalse) -- condN : {n : ℕ} {c₁ c₂ : C n} → (c₁ ⟺ c₂) → (c₁ ⟺ c₂) → ((times (ZD Bool) c₁) ⟺ (times (ZD Bool) c₂)) condN {n} {c₁} {c₂} f g = (seqF (distN {0} {n} {ZD One} {ZD One} {c₁}) (seqF (plusF {n} (timesF {0} {n} (idN⟷ {0} {ZD One}) f) (timesF {0} {n} (idN⟷ {0} {ZD One}) g)) (factorN {0} {n} {ZD One} {ZD One} {c₂}))) controlledN : {n : ℕ} {c : C n} → (c ⟺ c) → ((times (ZD Bool) c) ⟺ (times (ZD Bool) c)) controlledN f = condN f idN⟷ BoolN : (n : ℕ) → C n BoolN n = plus (oneN n) (oneN n) {-- Note: liftN 3 Bool is not quite the same as plus (oneN 3) (oneN 3) plus (oneN 3) (oneN 3) = Node (Node (Node (ZD (Plus One One)) (ZD (Plus Zero Zero))) (Node (ZD (Plus Zero Zero)) (ZD (Plus Zero Zero)))) (Node (Node (ZD (Plus Zero Zero)) (ZD (Plus Zero Zero))) (Node (ZD (Plus Zero Zero)) (ZD (Plus Zero Zero)))) liftN 3 Bool = Node (Node (Node (ZD (Plus One One)) (ZD Zero)) (Node (ZD Zero) (ZD Zero))) (Node (Node (ZD Zero) (ZD Zero)) (Node (ZD Zero) (ZD Zero))) --} cnotN : {n : ℕ} → ((times (ZD Bool) (BoolN n)) ⟺ (times (ZD Bool) (BoolN n))) cnotN {n} = controlledN {n} (swapN₊ {n} {oneN n} {oneN n}) -- Can't do toffoliN until we get all the products done --} ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ {-- CODE THAT TRIED TO KEEP PROOF THAT DIMENSIONS ARE EQUAL ------------------------------------------------------------------------------ -- Types indexed by dimension... n-dimensional cubes -- n-dimensional types represented as trees of depth n -- Silly lemmas that should be in the library somewhere suc-inj : {m n : ℕ} → suc m ≡ suc n → m ≡ n suc-inj {0} {0} refl = refl suc-inj {0} {suc i} () suc-inj {suc i} {suc .i} refl = refl data C : ℕ → Set where ZD : T → C 0 Node : {m n : ℕ} → C m → C n → (m ≡ n) → C (suc n) Lower : {n : ℕ} → (c₁ c₂ : C n) → (c₁ ≡ c₂) → C 0 zeroN : (n : ℕ) → C n zeroN 0 = ZD Zero zeroN (suc n) = Node (zeroN n) (zeroN n) refl plus : {m n : ℕ} → C m → C n → (m ≡ n) → C n plus (ZD _) (Node _ _ _) () plus (Node _ _ _) (ZD _) () plus (ZD t1) (ZD t2) refl = ZD (Plus t1 t2) plus {suc .m₂} {suc .m₂'} (Node {m₁} {m₂} c1 c2 p₁) (Node {m₁'} {m₂'} c1' c2' p₁') p = Node (plus c1 c1' q) (plus c2 c2' (suc-inj p)) p₁' where q = begin m₁ ≡⟨ p₁ ⟩ m₂ ≡⟨ suc-inj p ⟩ m₂' ≡⟨ sym p₁' ⟩ m₁' ∎ plus _ _ _ = {!!} times : {m n : ℕ} → C m → C n → C (m + n) times (ZD t1) (ZD t2) = ZD (Times t1 t2) times (ZD t) (Node c1 c2 p) = Node (times (ZD t) c1) (times (ZD t) c2) p times {n = n} (Node c1 c2 p) c = Node (times c1 c) (times c2 c) (cong (λ z → z + n) p) times _ _ = {!!} -- Combinators on nd types data _⟺_ : {m n : ℕ} → C m → C n → (m ≡ n) → Set where baseC : { t₁ t₂ : T } → (t₁ ⟷ t₂) → (_⟺_ (ZD t₁) (ZD t₂) refl) nodeC : {m n k l : ℕ} {c₁ : C m} {c₂ : C n} {c₃ : C k} {c₄ : C l} {p₁ : m ≡ n} {p₂ : k ≡ l} {p : k ≡ m} → (_⟺_ c₁ c₂ p₁) → (_⟺_ c₃ c₄ p₂) → (_⟺_ (Node c₁ c₃ (sym p)) (Node c₂ c₄ (trans (trans (sym p₁) (sym p)) p₂)) (cong suc p₂)) eta : {m : ℕ} {c : C m} → _⟺_ (ZD Zero) (Lower c c refl) refl -- Def. 2.1 lists the conditions for J-graded bipermutative category -- (0) -- the additive unit and assoc are implicit in the paper uniteN₊ : {m : ℕ} {c : C m} → _⟺_ (plus (zeroN m) c refl) c refl uniteN₊ {0} {ZD t} = baseC (unite₊ {t}) uniteN₊ {suc m} {Node {n} {.m} c₁ c₂ n≡m} = {!!} uniteN₊ {_} {_} = {!!} unitiN₊ : {m : ℕ} {c : C m} → _⟺_ c (plus (zeroN m) c refl) refl unitiN₊ {0} {ZD t} = baseC (uniti₊ {t}) unitiN₊ {suc m} {Node {n} {.m} c₁ c₂ n≡m} = {!!} -- nodeC (unitiN₊ {n} {c₁}) (unitiN₊ {n} {c₂}) unitiN₊ {_} {_} = {!!} assoclN₊ : { n : ℕ } { c₁ c₂ c₃ : C n } → plus c₁ (plus c₂ c₃) ⟺ plus (plus c₁ c₂) c₃ assoclN₊ {0} {ZD t₁} {ZD t₂} {ZD t₃} = baseC (assocl₊ {t₁} {t₂} {t₃}) assoclN₊ {suc n} {Node c₁ c₂} {Node c₃ c₄} {Node c₅ c₆} = nodeC (assoclN₊ {n} {c₁} {c₃} {c₅}) (assoclN₊ {n} {c₂} {c₄} {c₆}) assocrN₊ : { n : ℕ } { c₁ c₂ c₃ : C n } → plus (plus c₁ c₂) c₃ ⟺ plus c₁ (plus c₂ c₃) assocrN₊ {0} {ZD t₁} {ZD t₂} {ZD t₃} = baseC (assocr₊ {t₁} {t₂} {t₃}) assocrN₊ {suc n} {Node c₁ c₂} {Node c₃ c₄} {Node c₅ c₆} = nodeC (assocrN₊ {n} {c₁} {c₃} {c₅}) (assocrN₊ {n} {c₂} {c₄} {c₆}) -- (1) have times functor on objects -- define times functor on combinators -- timesF should satisfying assoc and unitality conditions... -- diagram on top of p.6 should commute timesF : { m n : ℕ } { c₁ : C m } { c₂ : C m } { c₃ : C n } { c₄ : C n } → (c₁ ⟺ c₂) → (c₃ ⟺ c₄) → (times c₁ c₃ ⟺ times c₂ c₄) timesF {0} {0} {ZD t₁} {ZD t₂} {ZD t₃} {ZD t₄} (baseC f) (baseC g) = baseC (_⊗_ {t₁} {t₃} {t₂} {t₄} f g) timesF {0} {suc n} {ZD t₁} {ZD t₂} {Node c₁ c₂} {Node c₃ c₄} (baseC f) (nodeC g₁ g₂) = nodeC (timesF (baseC f) g₁) (timesF (baseC f) g₂) timesF {suc m} {n} {Node c₁ c₂} {Node c₃ c₄} {c₅} {c₆} (nodeC f₁ f₂) g = nodeC (timesF f₁ g) (timesF f₂ g) -- (2) there is a unit object One of dimension 0 uniteN⋆ : {n : ℕ} {c : C n} → times (ZD One) c ⟺ c uniteN⋆ {0} {ZD t} = baseC (unite⋆ {t}) uniteN⋆ {suc n} {Node c₁ c₂} = nodeC (uniteN⋆ {n} {c₁}) (uniteN⋆ {n} {c₂}) unitiN⋆ : {n : ℕ} {c : C n} → c ⟺ times (ZD One) c unitiN⋆ {0} {ZD t} = baseC (uniti⋆ {t}) unitiN⋆ {suc n} {Node c₁ c₂} = nodeC (unitiN⋆ {n} {c₁}) (unitiN⋆ {n} {c₂}) -- (3) swap swapN⋆ : {m n : ℕ} {c₁ : C m} {c₂ : C n} → times c₁ c₂ ⟺ times c₂ c₁ swapN⋆ {0} {0} {ZD t₁} {ZD t₂} = baseC (swap⋆ {t₁} {t₂}) swapN⋆ = ? swapN₊ : { n : ℕ } { c₁ c₂ : C n } → plus c₁ c₂ ⟺ plus c₂ c₁ swapN₊ {0} {ZD t₁} {ZD t₂} = baseC (swap₊ {t₁} {t₂}) swapN₊ {suc n} {Node c₁ c₂} {Node c₁' c₂'} = nodeC (swapN₊ {n} {c₁} {c₁'}) (swapN₊ {n} {c₂} {c₂'}) distzN : {m n : ℕ} {c : C n} → times (zeroN m) c ⟺ zeroN (m + n) distzN {0} {0} {ZD t} = baseC (distz {t}) distzN {0} {suc n} {Node c₁ c₂} = nodeC (distzN {0} {n} {c₁}) (distzN {0} {n} {c₂}) distzN {suc m} {n} {c} = nodeC (distzN {m} {n} {c}) (distzN {m} {n} {c}) ------------------------------------------------------------------------------ assocl⋆ : { m n k : ℕ } { c₁ : C m } { c₂ : C n } { c₃ : C k } → times c₁ (times c₂ c₃) ⟺ times (times c₁ c₂) c₃ assocr⋆ : { m n k : ℕ } { c₁ : C m } { c₂ : C n } { c₃ : C k } → times (times c₁ c₂) c₃ ⟺ times c₁ (times c₂ c₃) distz : { m n : ℕ } { c : C n } → times (zeroN m) c ⟺ zeroN m factorz : { m n : ℕ } { c : C n } → zeroN m ⟺ times (zeroN m) c dist : { m n : ℕ } { c₁ c₂ : C m } { c₃ : C n } → times (plus c₁ c₂) c₃ ⟺ plus (times c₁ c₃) (times c₂ c₃) factor : { m n : ℕ } { c₁ c₂ : C m } { c₃ : C n } → plus (times c₁ c₃) (times c₂ c₃) ⟺ times (plus c₁ c₂) c₃ id⟷ : { n : ℕ } { c : C n } → c ⟺ c sym : { m n : ℕ } { c₁ : C m } { c₂ : C n } → (c₁ ⟺ c₂) → (c₂ ⟺ c₁) _◎_ : { m n k : ℕ } { c₁ : C m } { c₂ : C n } { c₃ : C k } → (c₁ ⟺ c₂) → (c₂ ⟺ c₃) → (c₁ ⟺ c₃) _⊕_ : { m n : ℕ } { c₁ c₃ : C m } { c₂ c₄ : C n } → (c₁ ⟺ c₂) → (c₃ ⟺ c₄) → (plus c₁ c₃ ⟺ plus c₂ c₄) ------------------------------------------------------------------------------ -- Semantics -- probably should have our own × ? -- should be a sum ! -- we have a value in one of the corners; not in all of them at once ⟦_⟧C : {n : ℕ} → C n → Set ⟦_⟧C (ZD t) = ⟦ t ⟧ ⟦_⟧C (Node c₁ c₂ _) = ⟦ c₁ ⟧C ⊎ ⟦ c₂ ⟧C ⟦_⟧C (Lower c₁ c₂ _) = ⊥ evalC : {n m : ℕ} {c₁ : C n} {c₂ : C m} {p : n ≡ m} → _⟺_ c₁ c₂ p → ⟦ c₁ ⟧C → ⟦ c₂ ⟧C evalC (baseC iso) v = eval iso v evalC (nodeC isoL isoR) (inj₁ v) = inj₁ (evalC isoL v) evalC (nodeC isoL isoR) (inj₂ v) = inj₂ (evalC isoR v) evalC _ _ = {!!} -- now add etas and epsilons... --}
{ "alphanum_fraction": 0.4792045932, "avg_line_length": 34.1674641148, "ext": "agda", "hexsha": "352bab198bdceb40ef94aa4f37075081fa856bd1", "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": "Pin.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": "Pin.agda", "max_line_length": 82, "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": "Pin.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": 10653, "size": 21423 }
{-# OPTIONS --allow-unsolved-metas #-} module Issue442 where postulate A : Set f : (P : A → A → Set) → (∀ {x} → P x x) → (∀ {x y z} → P y z → P x y → A) → A P : A → A → Set reflP : ∀ {x} → P x x g : ∀ {x y z} → P y z → P x y → A a : A a = f _ reflP g
{ "alphanum_fraction": 0.4296296296, "avg_line_length": 18, "ext": "agda", "hexsha": "02f91adb117722c091632500b64741f6ccc1bc45", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/agda-kanso", "max_forks_repo_path": "test/succeed/Issue442.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/agda-kanso", "max_issues_repo_path": "test/succeed/Issue442.agda", "max_line_length": 43, "max_stars_count": null, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/Issue442.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 124, "size": 270 }
------------------------------------------------------------------------------ -- First-order logic theorems ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOL.TheoremsI where -- The theorems below are valid on intuitionistic logic and with an -- empty domain. open import FOL.Base hiding ( D≢∅ ; pem ) ------------------------------------------------------------------------------ -- We postulate some formulae and propositional functions. postulate A : Set A¹ B¹ : D → Set A² : D → D → Set -- The introduction and elimination rules for the quantifiers are theorems. {- φ(x) ----------- ∀-intro ∀x.φ(x) ∀x.φ(x) ----------- ∀-elim φ(t) φ(t) ----------- ∃-intro ∃x.φ(x) ∃x.φ(x) φ(x) → ψ ---------------------- ∃-elim ψ -} ∀-intro : ((x : D) → A¹ x) → ∀ x → A¹ x ∀-intro h = h ∀-intro' : ((x : D) → A¹ x) → ⋀ A¹ ∀-intro' = dfun ∀-elim : (t : D) → (∀ x → A¹ x) → A¹ t ∀-elim t h = h t ∀-elim' : (t : D) → ⋀ A¹ → A¹ t ∀-elim' = dapp ∃-intro : (t : D) → A¹ t → ∃ A¹ ∃-intro t A¹x = t , A¹x ∃-elim : ∃ A¹ → ((x : D) → A¹ x → A) → A ∃-elim (x , A¹x) h = h x A¹x -- Generalization of De Morgan's laws. gDM₂ : ¬ (∃ A¹) ↔ (∀ {x} → ¬ (A¹ x)) gDM₂ = l→r , r→l where l→r : ¬ (∃ A¹) → ∀ {x} → ¬ (A¹ x) l→r h A¹x = h (_ , A¹x) r→l : (∀ {x} → ¬ (A¹ x)) → ¬ (∃ A¹) r→l h (x , A¹x) = h A¹x gDM₂' : ¬ (∃ A¹) ⇔ (⋀[ x ] ¬ (A¹ x)) gDM₂' = fun l→r , fun r→l where l→r : ¬ (∃ A¹) → ⋀[ x ] ¬ A¹ x l→r h = dfun (λ d A¹d → h (d , A¹d)) r→l : ⋀[ x ] ¬ A¹ x → ¬ ∃ A¹ r→l (dfun f) (x , A¹x) = f x A¹x -- Quantification over a variable that does not occur can be erased or -- added. ∃-erase-add : (∃[ x ] A ∧ A¹ x) ↔ A ∧ (∃[ x ] A¹ x) ∃-erase-add = l→r , r→l where l→r : ∃[ x ] A ∧ A¹ x → A ∧ (∃[ x ] A¹ x) l→r (x , a , A¹x) = a , x , A¹x r→l : A ∧ (∃[ x ] A¹ x) → ∃[ x ] A ∧ A¹ x r→l (a , x , A¹x) = x , a , A¹x -- Interchange of quantifiers. -- The related theorem ∀x∃y.Axy → ∃y∀x.Axy is not (classically) valid. ∃∀ : ∃[ x ] (∀ y → A² x y) → ∀ y → ∃[ x ] A² x y ∃∀ (x , h) y = x , h y -- ∃ in terms of ∀ and ¬. ∃→¬∀¬ : ∃[ x ] A¹ x → ¬ (∀ {x} → ¬ A¹ x) ∃→¬∀¬ (_ , A¹x) h = h A¹x ∃¬→¬∀ : ∃[ x ] ¬ A¹ x → ¬ (∀ {x} → A¹ x) ∃¬→¬∀ (_ , h₁) h₂ = h₁ h₂ -- ∀ in terms of ∃ and ¬. ∀→¬∃¬ : (∀ {x} → A¹ x) → ¬ (∃[ x ] ¬ A¹ x) ∀→¬∃¬ h₁ (_ , h₂) = h₂ h₁ ∀¬→¬∃ : (∀ {x} → ¬ A¹ x) → ¬ (∃[ x ] A¹ x) ∀¬→¬∃ h₁ (_ , h₂) = h₁ h₂ -- Distribution of ∃ and ∨. ∃∨ : ∃[ x ](A¹ x ∨ B¹ x) → (∃[ x ] A¹ x) ∨ (∃[ x ] B¹ x) ∃∨ (x , inj₁ A¹x) = inj₁ (x , A¹x) ∃∨ (x , inj₂ B¹x) = inj₂ (x , B¹x)
{ "alphanum_fraction": 0.3924963925, "avg_line_length": 24.5309734513, "ext": "agda", "hexsha": "915223438a4d3fb099ec9f55f96adab429a7dcaa", "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/FOL/TheoremsI.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/FOL/TheoremsI.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/FOL/TheoremsI.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": 1267, "size": 2772 }
open import Mockingbird.Forest using (Forest) -- Birds Galore module Mockingbird.Problems.Chapter11 {b ℓ} (forest : Forest {b} {ℓ}) where open import Data.Product using (_×_; _,_; proj₁; proj₂; ∃-syntax) open import Data.Unit using (⊤; tt) open import Function using (_$_) import Mockingbird.Problems.Chapter09 forest as Chapter₉ open Forest forest module Parentheses where private variable u v w x y z A A₁ A₂ B : Bird -- A variant of _∙_ that is not parsed as a right-associative operator, to -- make sure that the parentheses in the right-hand side of the exercises -- below are fully restored. infix 6 _∙′_ _∙′_ = _∙_ exercise-a : x ∙ y ∙ (z ∙ w ∙ y) ∙ v ≈ ((x ∙′ y) ∙′ ((z ∙′ w) ∙′ y)) ∙′ v exercise-a = refl exercise-b : (x ∙ y ∙ z) ∙ (w ∙ v ∙ x) ≈ ((x ∙′ y) ∙′ z) ∙′ ((w ∙′ v) ∙′ x) exercise-b = refl exercise-c : x ∙ y ∙ (z ∙ w ∙ v) ∙ (x ∙ z) ≈ ((x ∙′ y) ∙′ ((z ∙′ w) ∙′ v)) ∙′ (x ∙′ z) exercise-c = refl exercise-d : x ∙ y ∙ (z ∙ w ∙ v) ∙ x ∙ z ≈ (((x ∙′ y) ∙′ ((z ∙′ w) ∙′ v)) ∙′ x) ∙′ z exercise-d = refl exercise-e : x ∙ (y ∙ (z ∙ w ∙ v)) ∙ x ∙ z ≈ ((x ∙′ (y ∙′ ((z ∙′ w) ∙′ v))) ∙′ x) ∙′ z exercise-e = refl exercise-f : x ∙ y ∙ z ∙ (A ∙ B) ≈ (x ∙ y ∙ z) ∙ (A ∙ B) exercise-f = refl exercise-g : A₁ ≈ A₂ → B ∙ A₁ ≈ B ∙ A₂ × A₁ ∙ B ≈ A₂ ∙ B exercise-g A₁≈A₂ = (congˡ A₁≈A₂ , congʳ A₁≈A₂) exercise-h : x ∙ y ≈ z → x ∙ y ∙ w ≈ z ∙ w exercise-h {x} {y} {z} {w} xy≈z = begin x ∙ y ∙ w ≈⟨⟩ (x ∙′ y) ∙′ w ≈⟨ congʳ xy≈z ⟩ z ∙ w ∎ -- The other part of exercise h, wxy ≈ wz, does not follow in general. open import Mockingbird.Forest.Birds forest problem₁ : ⦃ _ : HasBluebird ⦄ → HasComposition problem₁ = record { _∘_ = λ C D → B ∙ C ∙ D ; isComposition = λ C D x → begin B ∙ C ∙ D ∙ x ≈⟨ isBluebird C D x ⟩ C ∙ (D ∙ x) ∎ } private instance hasComposition : ⦃ HasBluebird ⦄ → HasComposition hasComposition = problem₁ module _ ⦃ _ : HasBluebird ⦄ ⦃ _ : HasMockingbird ⦄ where problem₂ : ∀ x → ∃[ y ] x IsFondOf y problem₂ x = let (_ , isFond) = Chapter₉.problem₁ x shorten : M ∙ (B ∙ x ∙ M) ≈ B ∙ x ∙ M ∙ (B ∙ x ∙ M) shorten = isMockingbird (B ∙ x ∙ M) in (M ∙ (B ∙ x ∙ M) , trans (congˡ shorten) (trans isFond (sym shorten))) problem₃ : ∃[ x ] IsEgocentric x problem₃ = let (_ , isEgocentric) = Chapter₉.problem₂ in (B ∙ M ∙ M ∙ (B ∙ M ∙ M) , isEgocentric) module _ ⦃ _ : HasBluebird ⦄ ⦃ _ : HasMockingbird ⦄ ⦃ _ : HasKestrel ⦄ where problem₄ : ∃[ x ] IsHopelesslyEgocentric x problem₄ = let (_ , isHopelesslyEgocentric) = Chapter₉.problem₉ in (B ∙ K ∙ M ∙ (B ∙ K ∙ M) , isHopelesslyEgocentric) module _ ⦃ _ : HasBluebird ⦄ where problem₅ : HasDove problem₅ = record { D = B ∙ B ; isDove = λ x y z w → begin B ∙ B ∙ x ∙ y ∙ z ∙ w ≈⟨ congʳ $ congʳ $ isBluebird B x y ⟩ B ∙ (x ∙ y) ∙ z ∙ w ≈⟨ isBluebird (x ∙ y) z w ⟩ x ∙ y ∙ (z ∙ w) ∎ } private instance hasDove = problem₅ problem₆ : HasBlackbird problem₆ = record { B₁ = B ∙ B ∙ B ; isBlackbird = λ x y z w → begin B ∙ B ∙ B ∙ x ∙ y ∙ z ∙ w ≈⟨ congʳ $ congʳ $ congʳ (isBluebird B B x) ⟩ B ∙ (B ∙ x) ∙ y ∙ z ∙ w ≈⟨ congʳ (isBluebird (B ∙ x) y z) ⟩ B ∙ x ∙ (y ∙ z) ∙ w ≈⟨ isBluebird x (y ∙ z) w ⟩ x ∙ (y ∙ z ∙ w) ∎ } private instance hasBlackbird = problem₆ problem₇ : HasEagle problem₇ = record { E = B ∙ B₁ ; isEagle = λ x y z w v → begin B ∙ B₁ ∙ x ∙ y ∙ z ∙ w ∙ v ≈⟨ congʳ $ congʳ $ congʳ $ isBluebird B₁ x y ⟩ B₁ ∙ (x ∙ y) ∙ z ∙ w ∙ v ≈⟨ isBlackbird (x ∙ y) z w v ⟩ x ∙ y ∙ (z ∙ w ∙ v) ∎ } private instance hasEagle = problem₇ problem₈ : HasBunting problem₈ = record { B₂ = B ∙ B ∙ B₁ ; isBunting = λ x y z w v → begin B ∙ B ∙ B₁ ∙ x ∙ y ∙ z ∙ w ∙ v ≈⟨ congʳ $ congʳ $ congʳ $ congʳ $ isBluebird B B₁ x ⟩ B ∙ (B₁ ∙ x) ∙ y ∙ z ∙ w ∙ v ≈⟨ congʳ $ congʳ $ isBluebird (B₁ ∙ x) y z ⟩ B₁ ∙ x ∙ (y ∙ z) ∙ w ∙ v ≈⟨ isBlackbird x (y ∙ z) w v ⟩ x ∙ (y ∙ z ∙ w ∙ v) ∎ } private instance hasBunting = problem₈ problem₉ : HasDickcissel problem₉ = record { D₁ = B ∙ D ; isDickcissel = λ x y z w v → begin B ∙ D ∙ x ∙ y ∙ z ∙ w ∙ v ≈⟨ congʳ $ congʳ $ congʳ $ isBluebird D x y ⟩ D ∙ (x ∙ y) ∙ z ∙ w ∙ v ≈⟨ isDove (x ∙ y) z w v ⟩ x ∙ y ∙ z ∙ (w ∙ v) ∎ } private instance hasDickcissel = problem₉ problem₁₀ : HasBecard problem₁₀ = record { B₃ = B ∙ D ∙ B ; isBecard = λ x y z w → begin B ∙ D ∙ B ∙ x ∙ y ∙ z ∙ w ≈⟨ congʳ $ congʳ $ congʳ $ isBluebird D B x ⟩ D ∙ (B ∙ x) ∙ y ∙ z ∙ w ≈⟨ isDove (B ∙ x) y z w ⟩ B ∙ x ∙ y ∙ (z ∙ w) ≈⟨ isBluebird x y (z ∙ w) ⟩ x ∙ (y ∙ (z ∙ w)) ∎ } private instance hasBecard = problem₁₀ problem₁₁ : HasDovekie problem₁₁ = record { D₂ = D ∙ D ; isDovekie = λ x y z w v → begin D ∙ D ∙ x ∙ y ∙ z ∙ w ∙ v ≈⟨ congʳ $ congʳ $ isDove D x y z ⟩ D ∙ x ∙ (y ∙ z) ∙ w ∙ v ≈⟨ isDove x (y ∙ z) w v ⟩ x ∙ (y ∙ z) ∙ (w ∙ v) ∎ } private instance hasDovekie = problem₁₁ problem₁₂ : HasBaldEagle problem₁₂ = record { Ê = E ∙ E ; isBaldEagle = λ x y₁ y₂ y₃ z₁ z₂ z₃ → begin E ∙ E ∙ x ∙ y₁ ∙ y₂ ∙ y₃ ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ congʳ $ congʳ $ congʳ $ isEagle E x y₁ y₂ y₃ ⟩ E ∙ x ∙ (y₁ ∙ y₂ ∙ y₃) ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ isEagle x (y₁ ∙ y₂ ∙ y₃) z₁ z₂ z₃ ⟩ x ∙ (y₁ ∙ y₂ ∙ y₃) ∙ (z₁ ∙ z₂ ∙ z₃) ∎ } private instance hasBaldEagle = problem₁₂ problem₁₄ : ⦃ _ : HasWarbler ⦄ ⦃ _ : HasIdentity ⦄ → HasMockingbird problem₁₄ = record { M = W ∙ I ; isMockingbird = λ x → begin W ∙ I ∙ x ≈⟨ isWarbler I x ⟩ I ∙ x ∙ x ≈⟨ congʳ $ isIdentity x ⟩ x ∙ x ∎ } problem₁₅ : ⦃ _ : HasWarbler ⦄ ⦃ _ : HasKestrel ⦄ → HasIdentity problem₁₅ = record { I = W ∙ K ; isIdentity = λ x → begin W ∙ K ∙ x ≈⟨ isWarbler K x ⟩ K ∙ x ∙ x ≈⟨ isKestrel x x ⟩ x ∎ } problem₁₃ : ⦃ _ : HasWarbler ⦄ ⦃ _ : HasKestrel ⦄ → HasMockingbird problem₁₃ = problem₁₄ where instance _ = problem₁₅ problem₁₆ : ⦃ _ : HasCardinal ⦄ ⦃ _ : HasKestrel ⦄ → HasIdentity problem₁₆ = record { I = C ∙ K ∙ K ; isIdentity = λ x → begin C ∙ K ∙ K ∙ x ≈⟨ isCardinal K K x ⟩ K ∙ x ∙ K ≈⟨ isKestrel x K ⟩ x ∎ } problem₁₇ : ⦃ _ : HasCardinal ⦄ ⦃ _ : HasIdentity ⦄ → HasThrush problem₁₇ = record { T = C ∙ I ; isThrush = λ x y → begin C ∙ I ∙ x ∙ y ≈⟨ isCardinal I x y ⟩ I ∙ y ∙ x ≈⟨ congʳ $ isIdentity y ⟩ y ∙ x ∎ } problem₁₈ : ⦃ _ : HasThrush ⦄ → (∀ x → IsNormal x) → ∃[ A ] (∀ x → Commute A x) problem₁₈ isNormal = let (A , isFond) = isNormal T commute : ∀ x → Commute A x commute x = begin A ∙ x ≈˘⟨ (congʳ $ isFond) ⟩ T ∙ A ∙ x ≈⟨ isThrush A x ⟩ x ∙ A ∎ in (A , commute) problem₁₉ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ ⦃ _ : HasMockingbird ⦄ → ∃[ x ] (∀ y → Commute x y) problem₁₉ = problem₁₈ problem₂ problem₂₀ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ → HasRobin problem₂₀ = record { R = B ∙ B ∙ T ; isRobin = λ x y z → begin B ∙ B ∙ T ∙ x ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isBluebird B T x ⟩ B ∙ (T ∙ x) ∙ y ∙ z ≈⟨ isBluebird (T ∙ x) y z ⟩ T ∙ x ∙ (y ∙ z) ≈⟨ isThrush x (y ∙ z) ⟩ (y ∙ z) ∙ x ≈⟨⟩ y ∙ z ∙ x ∎ } problem₂₁ : ⦃ _ : HasRobin ⦄ → HasCardinal problem₂₁ = record { C = R ∙ R ∙ R ; isCardinal = λ x y z → begin R ∙ R ∙ R ∙ x ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isRobin R R x ⟩ R ∙ x ∙ R ∙ y ∙ z ≈⟨ congʳ $ isRobin x R y ⟩ R ∙ y ∙ x ∙ z ≈⟨ isRobin y x z ⟩ x ∙ z ∙ y ∎ } problem₂₁′ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ → HasCardinal problem₂₁′ = problem₂₁ ⦃ problem₂₀ ⦄ problem₂₁-bonus : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ → HasCardinal problem₂₁-bonus = record { C = B ∙ (T ∙ (B ∙ B ∙ T)) ∙ (B ∙ B ∙ T) ; isCardinal = λ x y z → begin B ∙ (T ∙ (B ∙ B ∙ T)) ∙ (B ∙ B ∙ T) ∙ x ∙ y ∙ z ≈˘⟨ congʳ $ congʳ $ congʳ $ congʳ $ isBluebird B T (B ∙ B ∙ T) ⟩ B ∙ B ∙ T ∙ (B ∙ B ∙ T) ∙ (B ∙ B ∙ T) ∙ x ∙ y ∙ z ≈⟨ isCardinal x y z ⟩ x ∙ z ∙ y ∎ } where instance hasCardinal = problem₂₁′ module _ ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ where private instance hasRobin = problem₂₀ instance hasCardinal = problem₂₁′ problem₂₂-a : ∀ x → C ∙ x ≈ R ∙ x ∙ R problem₂₂-a x = begin C ∙ x ≈⟨⟩ R ∙ R ∙ R ∙ x ≈⟨ isRobin R R x ⟩ R ∙ x ∙ R ∎ problem₂₂-b : ∀ x → C ∙ x ≈ B ∙ (T ∙ x) ∙ R problem₂₂-b x = begin C ∙ x ≈⟨ problem₂₂-a x ⟩ R ∙ x ∙ R ≈⟨⟩ B ∙ B ∙ T ∙ x ∙ R ≈⟨ congʳ $ isBluebird B T x ⟩ B ∙ (T ∙ x) ∙ R ∎ problem₂₃ : ⦃ _ : HasCardinal ⦄ → HasRobin problem₂₃ = record { R = C ∙ C ; isRobin = λ x y z → begin C ∙ C ∙ x ∙ y ∙ z ≈⟨ congʳ $ isCardinal C x y ⟩ C ∙ y ∙ x ∙ z ≈⟨ isCardinal y x z ⟩ y ∙ z ∙ x ∎ } problem₂₄ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasRobin ⦄ ⦃ _ : HasCardinal ⦄ → HasFinch problem₂₄ = record { F = B ∙ C ∙ R ; isFinch = λ x y z → begin B ∙ C ∙ R ∙ x ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isBluebird C R x ⟩ C ∙ (R ∙ x) ∙ y ∙ z ≈⟨ isCardinal (R ∙ x) y z ⟩ R ∙ x ∙ z ∙ y ≈⟨ isRobin x z y ⟩ z ∙ y ∙ x ∎ } problem₂₅ : ⦃ _ : HasThrush ⦄ ⦃ _ : HasEagle ⦄ → HasFinch problem₂₅ = record { F = E ∙ T ∙ T ∙ E ∙ T ; isFinch = λ x y z → begin E ∙ T ∙ T ∙ E ∙ T ∙ x ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isEagle T T E T x ⟩ T ∙ T ∙ (E ∙ T ∙ x) ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isThrush T (E ∙ T ∙ x) ⟩ E ∙ T ∙ x ∙ T ∙ y ∙ z ≈⟨ isEagle T x T y z ⟩ T ∙ x ∙ (T ∙ y ∙ z) ≈⟨ isThrush x (T ∙ y ∙ z) ⟩ T ∙ y ∙ z ∙ x ≈⟨ congʳ $ isThrush y z ⟩ z ∙ y ∙ x ∎ } problem₂₆ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ → HasFinch problem₂₆ = record { F = short ; isFinch = shortIsFinch } where instance hasRobin = problem₂₀ hasCardinal = problem₂₁-bonus hasEagle = problem₇ long : Bird long = (B ∙ (B ∙ (T ∙ (B ∙ B ∙ T)) ∙ (B ∙ B ∙ T)) ∙ (B ∙ B ∙ T)) longIsFinch : IsFinch long longIsFinch = HasFinch.isFinch problem₂₄ short : Bird short = B ∙ (T ∙ T) ∙ (B ∙ (B ∙ B ∙ B) ∙ T) short≈ETTET : short ≈ E ∙ T ∙ T ∙ E ∙ T short≈ETTET = begin short ≈⟨⟩ B ∙ (T ∙ T) ∙ (B ∙ (B ∙ B ∙ B) ∙ T) ≈˘⟨ isBluebird (B ∙ (T ∙ T)) (B ∙ (B ∙ B ∙ B)) T ⟩ B ∙ (B ∙ (T ∙ T)) ∙ (B ∙ (B ∙ B ∙ B)) ∙ T ≈˘⟨ congʳ $ congʳ $ isBluebird B B (T ∙ T) ⟩ B ∙ B ∙ B ∙ (T ∙ T) ∙ (B ∙ (B ∙ B ∙ B)) ∙ T ≈˘⟨ congʳ $ congʳ $ isBluebird (B ∙ B ∙ B) T T ⟩ B ∙ (B ∙ B ∙ B) ∙ T ∙ T ∙ (B ∙ (B ∙ B ∙ B)) ∙ T ≈⟨⟩ E ∙ T ∙ T ∙ E ∙ T ∎ shortIsFinch : IsFinch short shortIsFinch x y z = begin short ∙ x ∙ y ∙ z ≈⟨ congʳ $ congʳ $ congʳ $ short≈ETTET ⟩ E ∙ T ∙ T ∙ E ∙ T ∙ x ∙ y ∙ z ≈⟨ HasFinch.isFinch problem₂₅ x y z ⟩ z ∙ y ∙ x ∎ problem₂₇ : ⦃ _ : HasCardinal ⦄ ⦃ _ : HasFinch ⦄ → HasVireo problem₂₇ = record { V = C ∙ F ; isVireo = λ x y z → begin C ∙ F ∙ x ∙ y ∙ z ≈⟨ congʳ $ isCardinal F x y ⟩ F ∙ y ∙ x ∙ z ≈⟨ isFinch y x z ⟩ z ∙ x ∙ y ∎ } problem₂₈ : ⦃ _ : HasFinch ⦄ ⦃ _ : HasRobin ⦄ → HasVireo problem₂₈ = record { V = R ∙ F ∙ R ; isVireo = λ x y z → begin R ∙ F ∙ R ∙ x ∙ y ∙ z ≈˘⟨ congʳ $ congʳ $ congʳ $ isRobin R R F ⟩ R ∙ R ∙ R ∙ F ∙ x ∙ y ∙ z ≈⟨ congʳ $ HasCardinal.isCardinal problem₂₁ F x y ⟩ F ∙ y ∙ x ∙ z ≈⟨ isFinch y x z ⟩ z ∙ x ∙ y ∎ } problem₂₉ : ⦃ _ : HasCardinal ⦄ ⦃ _ : HasVireo ⦄ → HasFinch problem₂₉ = record { F = C ∙ V ; isFinch = λ x y z → begin C ∙ V ∙ x ∙ y ∙ z ≈⟨ congʳ $ isCardinal V x y ⟩ V ∙ y ∙ x ∙ z ≈⟨ isVireo y x z ⟩ z ∙ y ∙ x ∎ } problem₃₀ : ⦃ _ : HasRobin ⦄ ⦃ _ : HasKestrel ⦄ → HasIdentity problem₃₀ = problem₁₆ where instance hasCardinal = problem₂₁ module _ ⦃ _ : HasBluebird ⦄ ⦃ _ : HasCardinal ⦄ where problem₃₁ : HasCardinalOnceRemoved problem₃₁ = record { C* = B ∙ C ; isCardinalOnceRemoved = λ x y z w → begin B ∙ C ∙ x ∙ y ∙ z ∙ w ≈⟨ congʳ $ congʳ $ isBluebird C x y ⟩ C ∙ (x ∙ y) ∙ z ∙ w ≈⟨ isCardinal (x ∙ y) z w ⟩ x ∙ y ∙ w ∙ z ∎ } private instance hasCardinalOnceRemoved = problem₃₁ problem₃₂ : HasRobinOnceRemoved problem₃₂ = record { R* = C* ∙ C* ; isRobinOnceRemoved = λ x y z w → begin C* ∙ C* ∙ x ∙ y ∙ z ∙ w ≈⟨ congʳ $ isCardinalOnceRemoved C* x y z ⟩ C* ∙ x ∙ z ∙ y ∙ w ≈⟨ isCardinalOnceRemoved x z y w ⟩ x ∙ z ∙ w ∙ y ∎ } private instance hasRobinOnceRemoved = problem₃₂ problem₃₃ : HasFinchOnceRemoved problem₃₃ = record { F* = B ∙ C* ∙ R* ; isFinchOnceRemoved = λ x y z w → begin B ∙ C* ∙ R* ∙ x ∙ y ∙ z ∙ w ≈⟨ congʳ $ congʳ $ congʳ $ isBluebird C* R* x ⟩ C* ∙ (R* ∙ x) ∙ y ∙ z ∙ w ≈⟨ isCardinalOnceRemoved (R* ∙ x) y z w ⟩ R* ∙ x ∙ y ∙ w ∙ z ≈⟨ isRobinOnceRemoved x y w z ⟩ x ∙ w ∙ z ∙ y ∎ } private instance hasFinchOnceRemoved = problem₃₃ problem₃₄ : HasVireoOnceRemoved problem₃₄ = record { V* = C* ∙ F* ; isVireoOnceRemoved = λ x y z w → begin C* ∙ F* ∙ x ∙ y ∙ z ∙ w ≈⟨ congʳ $ isCardinalOnceRemoved F* x y z ⟩ F* ∙ x ∙ z ∙ y ∙ w ≈⟨ isFinchOnceRemoved x z y w ⟩ x ∙ w ∙ y ∙ z ∎ } private instance hasVireoOnceRemoved = problem₃₄ problem₃₅-C** : HasCardinalTwiceRemoved problem₃₅-C** = record { C** = B ∙ C* ; isCardinalTwiceRemoved = λ x y z₁ z₂ z₃ → begin B ∙ C* ∙ x ∙ y ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ congʳ $ congʳ $ congʳ $ isBluebird C* x y ⟩ C* ∙ (x ∙ y) ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ isCardinalOnceRemoved (x ∙ y) z₁ z₂ z₃ ⟩ x ∙ y ∙ z₁ ∙ z₃ ∙ z₂ ∎ } problem₃₅-R** : HasRobinTwiceRemoved problem₃₅-R** = record { R** = B ∙ R* ; isRobinTwiceRemoved = λ x y z₁ z₂ z₃ → begin B ∙ R* ∙ x ∙ y ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ congʳ $ congʳ $ congʳ $ isBluebird R* x y ⟩ R* ∙ (x ∙ y) ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ isRobinOnceRemoved (x ∙ y) z₁ z₂ z₃ ⟩ x ∙ y ∙ z₂ ∙ z₃ ∙ z₁ ∎ } problem₃₅-F** : HasFinchTwiceRemoved problem₃₅-F** = record { F** = B ∙ F* ; isFinchTwiceRemoved = λ x y z₁ z₂ z₃ → begin B ∙ F* ∙ x ∙ y ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ congʳ $ congʳ $ congʳ $ isBluebird F* x y ⟩ F* ∙ (x ∙ y) ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ isFinchOnceRemoved (x ∙ y) z₁ z₂ z₃ ⟩ x ∙ y ∙ z₃ ∙ z₂ ∙ z₁ ∎ } problem₃₅-V** : HasVireoTwiceRemoved problem₃₅-V** = record { V** = B ∙ V* ; isVireoTwiceRemoved = λ x y z₁ z₂ z₃ → begin B ∙ V* ∙ x ∙ y ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ congʳ $ congʳ $ congʳ $ isBluebird V* x y ⟩ V* ∙ (x ∙ y) ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ isVireoOnceRemoved (x ∙ y) z₁ z₂ z₃ ⟩ x ∙ y ∙ z₃ ∙ z₁ ∙ z₂ ∎ } problem₃₆ : ⦃ _ : HasCardinalOnceRemoved ⦄ ⦃ _ : HasThrush ⦄ → HasVireo problem₃₆ = record { V = C* ∙ T ; isVireo = λ x y z → begin C* ∙ T ∙ x ∙ y ∙ z ≈⟨ isCardinalOnceRemoved T x y z ⟩ T ∙ x ∙ z ∙ y ≈⟨ congʳ $ isThrush x z ⟩ z ∙ x ∙ y ∎ } problem₃₇′ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasCardinal ⦄ → HasQueerBird problem₃₇′ = record { Q = C ∙ B ; isQueerBird = λ x y z → begin C ∙ B ∙ x ∙ y ∙ z ≈⟨ congʳ $ isCardinal B x y ⟩ B ∙ y ∙ x ∙ z ≈⟨ isBluebird y x z ⟩ y ∙ (x ∙ z) ∎ } problem₃₈′ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasCardinalOnceRemoved ⦄ → HasQuixoticBird problem₃₈′ = record { Q₁ = C* ∙ B ; isQuixoticBird = λ x y z → begin C* ∙ B ∙ x ∙ y ∙ z ≈⟨ isCardinalOnceRemoved B x y z ⟩ B ∙ x ∙ z ∙ y ≈⟨ isBluebird x z y ⟩ x ∙ (z ∙ y) ∎ } problem₃₉′-F* : ⦃ _ : HasFinchOnceRemoved ⦄ ⦃ _ : HasQueerBird ⦄ → HasQuizzicalBird problem₃₉′-F* = record { Q₂ = F* ∙ Q ; isQuizzicalBird = λ x y z → begin F* ∙ Q ∙ x ∙ y ∙ z ≈⟨ isFinchOnceRemoved Q x y z ⟩ Q ∙ z ∙ y ∙ x ≈⟨ isQueerBird z y x ⟩ y ∙ (z ∙ x) ∎ } problem₃₉′-R* : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasRobinOnceRemoved ⦄ → HasQuizzicalBird problem₃₉′-R* = record { Q₂ = R* ∙ B ; isQuizzicalBird = λ x y z → begin R* ∙ B ∙ x ∙ y ∙ z ≈⟨ isRobinOnceRemoved B x y z ⟩ B ∙ y ∙ z ∙ x ≈⟨ isBluebird y z x ⟩ y ∙ (z ∙ x) ∎ } problem₄₁′ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasVireoOnceRemoved ⦄ → HasQuirkyBird problem₄₁′ = record { Q₃ = V* ∙ B ; isQuirkyBird = λ x y z → begin V* ∙ B ∙ x ∙ y ∙ z ≈⟨ isVireoOnceRemoved B x y z ⟩ B ∙ z ∙ x ∙ y ≈⟨ isBluebird z x y ⟩ z ∙ (x ∙ y) ∎ } problem₄₂′ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasFinchOnceRemoved ⦄ → HasQuackyBird problem₄₂′ = record { Q₄ = F* ∙ B ; isQuackyBird = λ x y z → begin F* ∙ B ∙ x ∙ y ∙ z ≈⟨ isFinchOnceRemoved B x y z ⟩ B ∙ z ∙ y ∙ x ≈⟨ isBluebird z y x ⟩ z ∙ (y ∙ x) ∎ } module _ ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ where private instance hasCardinal = problem₂₁-bonus hasCardinalOnceRemoved = problem₃₁ hasRobinOnceRemoved = problem₃₂ hasFinchOnceRemoved = problem₃₃ hasVireoOnceRemoved = problem₃₄ problem₃₇ : HasQueerBird problem₃₇ = problem₃₇′ private instance hasQueerBird = problem₃₇ problem₃₈ : HasQuixoticBird problem₃₈ = problem₃₈′ private instance hasQuixoticBird = problem₃₈ problem₃₉-F* : HasQuizzicalBird problem₃₉-F* = problem₃₉′-F* problem₃₉-R* : HasQuizzicalBird problem₃₉-R* = problem₃₉′-R* private instance hasQuizzicalBird = problem₃₉-F* problem₄₁ : HasQuirkyBird problem₄₁ = problem₄₁′ problem₄₂ : HasQuackyBird problem₄₂ = problem₄₂′ module _ ⦃ _ : HasCardinal ⦄ where problem₄₀-Q₁ : ⦃ _ : HasQuizzicalBird ⦄ → HasQuixoticBird problem₄₀-Q₁ = record { Q₁ = C ∙ Q₂ ; isQuixoticBird = λ x y z → begin C ∙ Q₂ ∙ x ∙ y ∙ z ≈⟨ congʳ $ isCardinal Q₂ x y ⟩ Q₂ ∙ y ∙ x ∙ z ≈⟨ isQuizzicalBird y x z ⟩ x ∙ (z ∙ y) ∎ } problem₄₀-Q₂ : ⦃ _ : HasQuixoticBird ⦄ → HasQuizzicalBird problem₄₀-Q₂ = record { Q₂ = C ∙ Q₁ ; isQuizzicalBird = λ x y z → begin C ∙ Q₁ ∙ x ∙ y ∙ z ≈⟨ congʳ $ isCardinal Q₁ x y ⟩ Q₁ ∙ y ∙ x ∙ z ≈⟨ isQuixoticBird y x z ⟩ y ∙ (z ∙ x) ∎ } problem₄₃-Q₃ : ⦃ _ : HasQuackyBird ⦄ → HasQuirkyBird problem₄₃-Q₃ = record { Q₃ = C ∙ Q₄ ; isQuirkyBird = λ x y z → begin C ∙ Q₄ ∙ x ∙ y ∙ z ≈⟨ congʳ $ isCardinal Q₄ x y ⟩ Q₄ ∙ y ∙ x ∙ z ≈⟨ isQuackyBird y x z ⟩ z ∙ (x ∙ y) ∎ } problem₄₃-Q₄ : ⦃ _ : HasQuirkyBird ⦄ → HasQuackyBird problem₄₃-Q₄ = record { Q₄ = C ∙ Q₃ ; isQuackyBird = λ x y z → begin C ∙ Q₃ ∙ x ∙ y ∙ z ≈⟨ congʳ $ isCardinal Q₃ x y ⟩ Q₃ ∙ y ∙ x ∙ z ≈⟨ isQuirkyBird y x z ⟩ z ∙ (y ∙ x) ∎ } problem₄₄ : ⦃ _ : HasQuixoticBird ⦄ ⦃ _ : HasThrush ⦄ → HasQuackyBird problem₄₄ = record { Q₄ = Q₁ ∙ T ; isQuackyBird = λ x y z → begin Q₁ ∙ T ∙ x ∙ y ∙ z ≈⟨ congʳ $ isQuixoticBird T x y ⟩ T ∙ (y ∙ x) ∙ z ≈⟨ isThrush (y ∙ x) z ⟩ z ∙ (y ∙ x) ∎ } problem₄₅ : ⦃ _ : HasQueerBird ⦄ ⦃ _ : HasThrush ⦄ → HasBluebird problem₄₅ = record { B = Q ∙ T ∙ (Q ∙ Q) ; isBluebird = λ x y z → begin Q ∙ T ∙ (Q ∙ Q) ∙ x ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isQueerBird T (Q ∙ Q) x ⟩ Q ∙ Q ∙ (T ∙ x) ∙ y ∙ z ≈⟨ congʳ $ isQueerBird Q (T ∙ x) y ⟩ T ∙ x ∙ (Q ∙ y) ∙ z ≈⟨ congʳ $ isThrush x (Q ∙ y) ⟩ Q ∙ y ∙ x ∙ z ≈⟨ isQueerBird y x z ⟩ x ∙ (y ∙ z) ∎ } problem₄₆ : ⦃ _ : HasQueerBird ⦄ ⦃ _ : HasThrush ⦄ → HasCardinal problem₄₆ = record { C = Q ∙ Q ∙ (Q ∙ T) ; isCardinal = λ x y z → begin Q ∙ Q ∙ (Q ∙ T) ∙ x ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isQueerBird Q (Q ∙ T) x ⟩ Q ∙ T ∙ (Q ∙ x) ∙ y ∙ z ≈⟨ congʳ $ isQueerBird T (Q ∙ x) y ⟩ Q ∙ x ∙ (T ∙ y) ∙ z ≈⟨ isQueerBird x (T ∙ y) z ⟩ T ∙ y ∙ (x ∙ z) ≈⟨ isThrush y (x ∙ z) ⟩ x ∙ z ∙ y ∎ } problem₄₇ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ → HasGoldfinch problem₄₇ = record { G = D ∙ C ; isGoldfinch = λ x y z w → begin D ∙ C ∙ x ∙ y ∙ z ∙ w ≈⟨ congʳ $ isDove C x y z ⟩ C ∙ x ∙ (y ∙ z) ∙ w ≈⟨ isCardinal x (y ∙ z) w ⟩ x ∙ w ∙ (y ∙ z) ∎ } where instance hasCardinal = problem₂₁-bonus hasDove = problem₅
{ "alphanum_fraction": 0.4807120238, "avg_line_length": 32.4136858476, "ext": "agda", "hexsha": "42d7d0daf35ba501364222500ca00f1d2c70641a", "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/Problems/Chapter11.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/Problems/Chapter11.agda", "max_line_length": 121, "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/Problems/Chapter11.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": 10215, "size": 20842 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.ZCohomology.Properties where {- This module contains: 1. direct proofs of connectedness of Kn and ΩKn 2. Induction principles for cohomology groups of pointed types 3. Equivalence between cohomology of A and reduced cohomology of (A + 1) 4. Equivalence between cohomology and reduced cohomology for dimension ≥ 1 5. Encode-decode proof of Kₙ ≃ ΩKₙ₊₁ and proofs that this equivalence and its inverse are morphisms 6. A proof of coHomGr ≅ coHomGrΩ 7. A locked (non-reducing) version of Kₙ ≃ ΩKₙ₊₁ -} open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.GroupStructure open import Cubical.HITs.S1 hiding (encode ; decode) open import Cubical.HITs.Sn open import Cubical.Foundations.HLevels open import Cubical.Foundations.Transport open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.Prelude open import Cubical.Foundations.Pointed open import Cubical.Foundations.Pointed.Homogeneous open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws renaming (assoc to assoc∙) open import Cubical.Foundations.Univalence open import Cubical.HITs.Susp open import Cubical.HITs.SetTruncation renaming (rec to sRec ; rec2 to sRec2 ; elim to sElim ; elim2 to sElim2 ; setTruncIsSet to §) open import Cubical.Data.Int renaming (_+_ to _ℤ+_) hiding (-_) open import Cubical.Data.Nat open import Cubical.HITs.Truncation renaming (elim to trElim ; map to trMap ; map2 to trMap2; rec to trRec ; elim3 to trElim3) open import Cubical.Homotopy.Loopspace open import Cubical.Homotopy.Connected open import Cubical.Algebra.Group hiding (Unit ; Int) open import Cubical.Algebra.AbGroup open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Data.Sum.Base hiding (map) open import Cubical.Functions.Morphism open import Cubical.Data.Sigma open Iso renaming (inv to inv') private variable ℓ ℓ' : Level ------------------- Connectedness --------------------- is2ConnectedKn : (n : ℕ) → isConnected 2 (coHomK (suc n)) is2ConnectedKn zero = ∣ ∣ base ∣ ∣ , trElim (λ _ → isOfHLevelPath 2 (isOfHLevelTrunc 2) _ _) (trElim (λ _ → isOfHLevelPath 3 (isOfHLevelSuc 2 (isOfHLevelTrunc 2)) _ _) (toPropElim (λ _ → isOfHLevelTrunc 2 _ _) refl)) is2ConnectedKn (suc n) = ∣ ∣ north ∣ ∣ , trElim (λ _ → isOfHLevelPath 2 (isOfHLevelTrunc 2) _ _) (trElim (λ _ → isProp→isOfHLevelSuc (3 + n) (isOfHLevelTrunc 2 _ _)) (suspToPropElim (ptSn (suc n)) (λ _ → isOfHLevelTrunc 2 _ _) refl)) isConnectedKn : (n : ℕ) → isConnected (2 + n) (coHomK (suc n)) isConnectedKn n = isOfHLevelRetractFromIso 0 (invIso (truncOfTruncIso (2 + n) 1)) (sphereConnected (suc n)) -- direct proof of connectedness of ΩKₙ₊₁ not relying on the equivalence ∥ a ≡ b ∥ₙ ≃ (∣ a ∣ₙ₊₁ ≡ ∣ b ∣ₙ₊₁) isConnectedPathKn : (n : ℕ) (x y : (coHomK (suc n))) → isConnected (suc n) (x ≡ y) isConnectedPathKn n = trElim (λ _ → isProp→isOfHLevelSuc (2 + n) (isPropΠ λ _ → isPropIsContr)) (sphereElim _ (λ _ → isProp→isOfHLevelSuc n (isPropΠ λ _ → isPropIsContr)) λ y → isContrRetractOfConstFun {B = (hLevelTrunc (suc n) (ptSn (suc n) ≡ ptSn (suc n)))} ∣ refl ∣ (fun⁻ n y , trElim (λ _ → isOfHLevelPath (suc n) (isOfHLevelTrunc (suc n)) _ _) (J (λ y p → fun⁻ n y _ ≡ _) (funExt⁻ (fun⁻Id n) ∣ refl ∣)))) where fun⁻ : (n : ℕ) → (y : coHomK (suc n)) → hLevelTrunc (suc n) (ptSn (suc n) ≡ ptSn (suc n)) → hLevelTrunc (suc n) (∣ ptSn (suc n) ∣ ≡ y) fun⁻ n = trElim (λ _ → isOfHLevelΠ (3 + n) λ _ → isOfHLevelSuc (2 + n) (isOfHLevelSuc (suc n) (isOfHLevelTrunc (suc n)))) (sphereElim n (λ _ → isOfHLevelΠ (suc n) λ _ → isOfHLevelTrunc (suc n)) λ _ → ∣ refl ∣) fun⁻Id : (n : ℕ) → fun⁻ n ∣ ptSn (suc n) ∣ ≡ λ _ → ∣ refl ∣ fun⁻Id zero = refl fun⁻Id (suc n) = refl ------------------- -- Induction principles for cohomology groups (n ≥ 1) -- If we want to show a proposition about some x : Hⁿ(A), it suffices to show it under the -- assumption that x = ∣ f ∣₂ for some f : A → Kₙ and that f is pointed coHomPointedElim : {A : Type ℓ} (n : ℕ) (a : A) {B : coHom (suc n) A → Type ℓ'} → ((x : coHom (suc n) A) → isProp (B x)) → ((f : A → coHomK (suc n)) → f a ≡ coHom-pt (suc n) → B ∣ f ∣₂) → (x : coHom (suc n) A) → B x coHomPointedElim {ℓ' = ℓ'} {A = A} n a isprop indp = sElim (λ _ → isOfHLevelSuc 1 (isprop _)) λ f → helper n isprop indp f (f a) refl where helper : (n : ℕ) {B : coHom (suc n) A → Type ℓ'} → ((x : coHom (suc n) A) → isProp (B x)) → ((f : A → coHomK (suc n)) → f a ≡ coHom-pt (suc n) → B ∣ f ∣₂) → (f : A → coHomK (suc n)) → (x : coHomK (suc n)) → f a ≡ x → B ∣ f ∣₂ -- pattern matching a bit extra to avoid isOfHLevelPlus' helper zero isprop ind f = trElim (λ _ → isOfHLevelPlus {n = 1} 2 (isPropΠ λ _ → isprop _)) (toPropElim (λ _ → isPropΠ λ _ → isprop _) (ind f)) helper (suc zero) isprop ind f = trElim (λ _ → isOfHLevelPlus {n = 1} 3 (isPropΠ λ _ → isprop _)) (suspToPropElim base (λ _ → isPropΠ λ _ → isprop _) (ind f)) helper (suc (suc zero)) isprop ind f = trElim (λ _ → isOfHLevelPlus {n = 1} 4 (isPropΠ λ _ → isprop _)) (suspToPropElim north (λ _ → isPropΠ λ _ → isprop _) (ind f)) helper (suc (suc (suc n))) isprop ind f = trElim (λ _ → isOfHLevelPlus' {n = 5 + n} 1 (isPropΠ λ _ → isprop _)) (suspToPropElim north (λ _ → isPropΠ λ _ → isprop _) (ind f)) coHomPointedElim2 : {A : Type ℓ} (n : ℕ) (a : A) {B : coHom (suc n) A → coHom (suc n) A → Type ℓ'} → ((x y : coHom (suc n) A) → isProp (B x y)) → ((f g : A → coHomK (suc n)) → f a ≡ coHom-pt (suc n) → g a ≡ coHom-pt (suc n) → B ∣ f ∣₂ ∣ g ∣₂) → (x y : coHom (suc n) A) → B x y coHomPointedElim2 {ℓ' = ℓ'} {A = A} n a isprop indp = sElim2 (λ _ _ → isOfHLevelSuc 1 (isprop _ _)) λ f g → helper n a isprop indp f g (f a) (g a) refl refl where helper : (n : ℕ) (a : A) {B : coHom (suc n) A → coHom (suc n) A → Type ℓ'} → ((x y : coHom (suc n) A) → isProp (B x y)) → ((f g : A → coHomK (suc n)) → f a ≡ coHom-pt (suc n) → g a ≡ coHom-pt (suc n) → B ∣ f ∣₂ ∣ g ∣₂) → (f g : A → coHomK (suc n)) → (x y : coHomK (suc n)) → f a ≡ x → g a ≡ y → B ∣ f ∣₂ ∣ g ∣₂ helper zero a isprop indp f g = elim2 (λ _ _ → isOfHLevelPlus {n = 1} 2 (isPropΠ2 λ _ _ → isprop _ _)) (toPropElim2 (λ _ _ → isPropΠ2 λ _ _ → isprop _ _) (indp f g)) helper (suc zero) a isprop indp f g = elim2 (λ _ _ → isOfHLevelPlus {n = 1} 3 (isPropΠ2 λ _ _ → isprop _ _)) (suspToPropElim2 base (λ _ _ → isPropΠ2 λ _ _ → isprop _ _) (indp f g)) helper (suc (suc zero)) a isprop indp f g = elim2 (λ _ _ → isOfHLevelPlus {n = 1} 4 (isPropΠ2 λ _ _ → isprop _ _)) (suspToPropElim2 north (λ _ _ → isPropΠ2 λ _ _ → isprop _ _) (indp f g)) helper (suc (suc (suc n))) a isprop indp f g = elim2 (λ _ _ → isOfHLevelPlus' {n = 5 + n} 1 (isPropΠ2 λ _ _ → isprop _ _)) (suspToPropElim2 north (λ _ _ → isPropΠ2 λ _ _ → isprop _ _) (indp f g)) coHomK-elim : ∀ {ℓ} (n : ℕ) {B : coHomK (suc n) → Type ℓ} → ((x : _) → isOfHLevel (suc n) (B x)) → B (0ₖ (suc n)) → (x : _) → B x coHomK-elim n {B = B } hlev b = trElim (λ _ → isOfHLevelPlus {n = (suc n)} 2 (hlev _)) (sphereElim _ (hlev ∘ ∣_∣) b) {- Equivalence between cohomology of A and reduced cohomology of (A + 1) -} coHomRed+1Equiv : (n : ℕ) → (A : Type ℓ) → (coHom n A) ≡ (coHomRed n ((A ⊎ Unit , inr (tt)))) coHomRed+1Equiv zero A i = ∥ helpLemma {C = (Int , pos 0)} i ∥₂ module coHomRed+1 where helpLemma : {C : Pointed ℓ} → ( (A → (typ C)) ≡ ((((A ⊎ Unit) , inr (tt)) →∙ C))) helpLemma {C = C} = isoToPath (iso map1 map2 (λ b → linvPf b) (λ _ → refl)) where map1 : (A → typ C) → ((((A ⊎ Unit) , inr (tt)) →∙ C)) map1 f = map1' , refl module helpmap where map1' : A ⊎ Unit → fst C map1' (inl x) = f x map1' (inr x) = pt C map2 : ((((A ⊎ Unit) , inr (tt)) →∙ C)) → (A → typ C) map2 (g , pf) x = g (inl x) linvPf : (b :((((A ⊎ Unit) , inr (tt)) →∙ C))) → map1 (map2 b) ≡ b linvPf (f , snd) i = (λ x → helper x i) , λ j → snd ((~ i) ∨ j) where helper : (x : A ⊎ Unit) → ((helpmap.map1') (map2 (f , snd)) x) ≡ f x helper (inl x) = refl helper (inr tt) = sym snd coHomRed+1Equiv (suc zero) A i = ∥ coHomRed+1.helpLemma A i {C = (coHomK 1 , ∣ base ∣)} i ∥₂ coHomRed+1Equiv (suc (suc n)) A i = ∥ coHomRed+1.helpLemma A i {C = (coHomK (2 + n) , ∣ north ∣)} i ∥₂ Iso-coHom-coHomRed : ∀ {ℓ} {A : Pointed ℓ} (n : ℕ) → Iso (coHomRed (suc n) A) (coHom (suc n) (typ A)) fun (Iso-coHom-coHomRed {A = A , a} n) = map fst inv' (Iso-coHom-coHomRed {A = A , a} n) = map λ f → (λ x → f x -ₖ f a) , rCancelₖ _ _ rightInv (Iso-coHom-coHomRed {A = A , a} n) = sElim (λ _ → isOfHLevelPath 2 § _ _) λ f → trRec (isProp→isOfHLevelSuc _ (§ _ _)) (λ p → cong ∣_∣₂ (funExt λ x → cong (λ y → f x +ₖ y) (cong -ₖ_ p ∙ -0ₖ) ∙ rUnitₖ _ (f x))) (Iso.fun (PathIdTruncIso (suc n)) (isContr→isProp (isConnectedKn n) ∣ f a ∣ ∣ 0ₖ _ ∣)) leftInv (Iso-coHom-coHomRed {A = A , a} n) = sElim (λ _ → isOfHLevelPath 2 § _ _) λ {(f , p) → cong ∣_∣₂ (ΣPathP (((funExt λ x → (cong (λ y → f x -ₖ y) p ∙∙ cong (λ y → f x +ₖ y) -0ₖ ∙∙ rUnitₖ _ (f x)) ∙ refl)) , helper n (f a) (sym p)))} where path : (n : ℕ) (x : coHomK (suc n)) (p : 0ₖ _ ≡ x) → _ path n x p = (cong (λ y → x -ₖ y) (sym p) ∙∙ cong (λ y → x +ₖ y) -0ₖ ∙∙ rUnitₖ _ x) ∙ refl helper : (n : ℕ) (x : coHomK (suc n)) (p : 0ₖ _ ≡ x) → PathP (λ i → path n x p i ≡ 0ₖ _) (rCancelₖ _ x) (sym p) helper zero x = J (λ x p → PathP (λ i → path 0 x p i ≡ 0ₖ _) (rCancelₖ _ x) (sym p)) λ i j → rUnit (rUnit (λ _ → 0ₖ 1) (~ j)) (~ j) i helper (suc n) x = J (λ x p → PathP (λ i → path (suc n) x p i ≡ 0ₖ _) (rCancelₖ _ x) (sym p)) λ i j → rCancelₖ (suc (suc n)) (0ₖ (suc (suc n))) (~ i ∧ ~ j) +∙≡+ : (n : ℕ) {A : Pointed ℓ} (x y : coHomRed (suc n) A) → Iso.fun (Iso-coHom-coHomRed n) (x +ₕ∙ y) ≡ Iso.fun (Iso-coHom-coHomRed n) x +ₕ Iso.fun (Iso-coHom-coHomRed n) y +∙≡+ zero = sElim2 (λ _ _ → isOfHLevelPath 2 § _ _) λ _ _ → refl +∙≡+ (suc n) = sElim2 (λ _ _ → isOfHLevelPath 2 § _ _) λ _ _ → refl private homhelp : ∀ {ℓ} (n : ℕ) (A : Pointed ℓ) (x y : coHom (suc n) (typ A)) → Iso.inv (Iso-coHom-coHomRed {A = A} n) (x +ₕ y) ≡ Iso.inv (Iso-coHom-coHomRed n) x +ₕ∙ Iso.inv (Iso-coHom-coHomRed n) y homhelp n A = morphLemmas.isMorphInv _+ₕ∙_ _+ₕ_ (Iso.fun (Iso-coHom-coHomRed n)) (+∙≡+ n) _ (Iso.rightInv (Iso-coHom-coHomRed n)) (Iso.leftInv (Iso-coHom-coHomRed n)) coHomGr≅coHomRedGr : ∀ {ℓ} (n : ℕ) (A : Pointed ℓ) → GroupEquiv (coHomRedGrDir (suc n) A) (coHomGr (suc n) (typ A)) fst (coHomGr≅coHomRedGr n A) = isoToEquiv (Iso-coHom-coHomRed n) snd (coHomGr≅coHomRedGr n A) = makeIsGroupHom (+∙≡+ n) coHomRedGroup : ∀ {ℓ} (n : ℕ) (A : Pointed ℓ) → AbGroup ℓ coHomRedGroup zero A = coHomRedGroupDir zero A coHomRedGroup (suc n) A = InducedAbGroup (coHomGroup (suc n) (typ A)) _+ₕ∙_ (isoToEquiv (invIso (Iso-coHom-coHomRed n))) (homhelp n A) abstract coHomGroup≡coHomRedGroup : ∀ {ℓ} (n : ℕ) (A : Pointed ℓ) → coHomGroup (suc n) (typ A) ≡ coHomRedGroup (suc n) A coHomGroup≡coHomRedGroup n A = InducedAbGroupPath (coHomGroup (suc n) (typ A)) _+ₕ∙_ (isoToEquiv (invIso (Iso-coHom-coHomRed n))) (homhelp n A) ------------------- Kₙ ≃ ΩKₙ₊₁ --------------------- -- This proof uses the encode-decode method rather than Freudenthal -- We define the map σ : Kₙ → ΩKₙ₊₁ and prove that it is a morphism private module _ (n : ℕ) where σ : {n : ℕ} → coHomK (suc n) → Path (coHomK (2 + n)) ∣ north ∣ ∣ north ∣ σ {n = n} = trRec (isOfHLevelTrunc (4 + n) _ _) λ a → cong ∣_∣ (merid a ∙ sym (merid (ptSn (suc n)))) σ-hom-helper : ∀ {ℓ} {A : Type ℓ} {a : A} (p : a ≡ a) (r : refl ≡ p) → lUnit p ∙ cong (_∙ p) r ≡ rUnit p ∙ cong (p ∙_) r σ-hom-helper p = J (λ p r → lUnit p ∙ cong (_∙ p) r ≡ rUnit p ∙ cong (p ∙_) r) refl σ-hom : {n : ℕ} (x y : coHomK (suc n)) → σ (x +ₖ y) ≡ σ x ∙ σ y σ-hom {n = zero} = elim2 (λ _ _ → isOfHLevelPath 3 (isOfHLevelTrunc 4 _ _) _ _) (wedgeconFun _ _ (λ _ _ → isOfHLevelTrunc 4 _ _ _ _) (λ x → lUnit _ ∙ cong (_∙ σ ∣ x ∣) (cong (cong ∣_∣) (sym (rCancel (merid base))))) (λ y → cong σ (rUnitₖ 1 ∣ y ∣) ∙∙ rUnit _ ∙∙ cong (σ ∣ y ∣ ∙_) (cong (cong ∣_∣) (sym (rCancel (merid base))))) (sym (σ-hom-helper (σ ∣ base ∣) (cong (cong ∣_∣) (sym (rCancel (merid base))))))) σ-hom {n = suc n} = elim2 (λ _ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (5 + n) _ _) _ _) (wedgeconFun _ _ (λ _ _ → isOfHLevelPath ((2 + n) + (2 + n)) (wedgeConHLev' n) _ _) (λ x → lUnit _ ∙ cong (_∙ σ ∣ x ∣) (cong (cong ∣_∣) (sym (rCancel (merid north))))) (λ y → cong σ (rUnitₖ (2 + n) ∣ y ∣) ∙∙ rUnit _ ∙∙ cong (σ ∣ y ∣ ∙_) (cong (cong ∣_∣) (sym (rCancel (merid north))))) (sym (σ-hom-helper (σ ∣ north ∣) (cong (cong ∣_∣) (sym (rCancel (merid north))))))) -- We will need to following lemma σ-minusDistr : {n : ℕ} (x y : coHomK (suc n)) → σ (x -ₖ y) ≡ σ x ∙ sym (σ y) σ-minusDistr {n = n} = morphLemmas.distrMinus' _+ₖ_ _∙_ σ σ-hom ∣ (ptSn (suc n)) ∣ refl -ₖ_ sym (λ x → sym (lUnit x)) (λ x → sym (rUnit x)) (rUnitₖ (suc n)) (lCancelₖ (suc n)) rCancel (assocₖ (suc n)) assoc∙ (cong (cong ∣_∣) (rCancel (merid (ptSn (suc n))))) -- we define the code using addIso Code : (n : ℕ) → coHomK (2 + n) → Type₀ Code n x = (trRec {B = TypeOfHLevel ℓ-zero (3 + n)} (isOfHLevelTypeOfHLevel (3 + n)) λ a → Code' a , hLevCode' a) x .fst where Code' : (S₊ (2 + n)) → Type₀ Code' north = coHomK (suc n) Code' south = coHomK (suc n) Code' (merid a i) = isoToPath (addIso (suc n) ∣ a ∣) i hLevCode' : (x : S₊ (2 + n)) → isOfHLevel (3 + n) (Code' x) hLevCode' = suspToPropElim (ptSn (suc n)) (λ _ → isPropIsOfHLevel (3 + n)) (isOfHLevelTrunc (3 + n)) symMeridLem : (n : ℕ) → (x : S₊ (suc n)) (y : coHomK (suc n)) → subst (Code n) (cong ∣_∣ (sym (merid x))) y ≡ y -ₖ ∣ x ∣ symMeridLem n x = trElim (λ _ → isOfHLevelPath (3 + n) (isOfHLevelTrunc (3 + n)) _ _) (λ y → cong (_-ₖ ∣ x ∣) (transportRefl ∣ y ∣)) decode : {n : ℕ} (x : coHomK (2 + n)) → Code n x → ∣ north ∣ ≡ x decode {n = n} = trElim (λ _ → isOfHLevelΠ (4 + n) λ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _) decode-elim where north≡merid : (a : S₊ (suc n)) → Path (coHomK (2 + n)) ∣ north ∣ ∣ north ∣ ≡ (Path (coHomK (2 + n)) ∣ north ∣ ∣ south ∣) north≡merid a i = Path (coHomK (2 + n)) ∣ north ∣ ∣ merid a i ∣ decode-elim : (a : S₊ (2 + n)) → Code n ∣ a ∣ → Path (coHomK (2 + n)) ∣ north ∣ ∣ a ∣ decode-elim north = σ decode-elim south = trRec (isOfHLevelTrunc (4 + n) _ _) λ a → cong ∣_∣ (merid a) decode-elim (merid a i) = hcomp (λ k → λ { (i = i0) → σ ; (i = i1) → mainPath a k}) (funTypeTransp (Code n) (λ x → ∣ north ∣ ≡ x) (cong ∣_∣ (merid a)) σ i) where mainPath : (a : (S₊ (suc n))) → transport (north≡merid a) ∘ σ ∘ transport (λ i → Code n ∣ merid a (~ i) ∣) ≡ trRec (isOfHLevelTrunc (4 + n) _ _) λ a → cong ∣_∣ (merid a) mainPath a = funExt (trElim (λ _ → isOfHLevelPath (3 + n) (isOfHLevelTrunc (4 + n) _ _) _ _) (λ x → (λ i → transport (north≡merid a) (σ (symMeridLem n a ∣ x ∣ i))) ∙∙ cong (transport (north≡merid a)) (-distrHelp x) ∙∙ (substAbove x))) where -distrHelp : (x : S₊ (suc n)) → σ (∣ x ∣ -ₖ ∣ a ∣) ≡ cong ∣_∣ (merid x) ∙ cong ∣_∣ (sym (merid a)) -distrHelp x = σ-minusDistr ∣ x ∣ ∣ a ∣ ∙ (λ i → (cong ∣_∣ (compPath-filler (merid x) (λ j → merid (ptSn (suc n)) (~ j ∨ i)) (~ i))) ∙ (cong ∣_∣ (sym (compPath-filler (merid a) (λ j → merid (ptSn (suc n)) (~ j ∨ i)) (~ i))))) substAbove : (x : S₊ (suc n)) → transport (north≡merid a) (cong ∣_∣ (merid x) ∙ cong ∣_∣ (sym (merid a))) ≡ cong ∣_∣ (merid x) substAbove x i = transp (λ j → north≡merid a (i ∨ j)) i (compPath-filler (cong ∣_∣ (merid x)) (λ j → ∣ merid a (~ j ∨ i) ∣) (~ i)) encode : {n : ℕ} {x : coHomK (2 + n)} → Path (coHomK (2 + n)) ∣ north ∣ x → Code n x encode {n = n} p = transport (cong (Code n) p) ∣ (ptSn (suc n)) ∣ decode-encode : {n : ℕ} {x : coHomK (2 + n)} (p : Path (coHomK (2 + n)) ∣ north ∣ x) → decode _ (encode p) ≡ p decode-encode {n = n} = J (λ y p → decode _ (encode p) ≡ p) (cong (decode ∣ north ∣) (transportRefl ∣ ptSn (suc n) ∣) ∙ cong (cong ∣_∣) (rCancel (merid (ptSn (suc n))))) -- We define an addition operation on Code which we can use in order to show that encode is a -- morphism (in a very loose sense) hLevCode : {n : ℕ} (x : coHomK (2 + n)) → isOfHLevel (3 + n) (Code n x) hLevCode {n = n} = trElim (λ _ → isProp→isOfHLevelSuc (3 + n) (isPropIsOfHLevel (3 + n))) (sphereToPropElim _ (λ _ → (isPropIsOfHLevel (3 + n))) (isOfHLevelTrunc (3 + n))) Code-add' : {n : ℕ} (x : _) → Code n ∣ north ∣ → Code n ∣ x ∣ → Code n ∣ x ∣ Code-add' {n = n} north = _+ₖ_ Code-add' {n = n} south = _+ₖ_ Code-add' {n = n} (merid a i) = helper n a i where help : (n : ℕ) → (x y a : S₊ (suc n)) → transport (λ i → Code n ∣ north ∣ → Code n ∣ merid a i ∣ → Code n ∣ merid a i ∣) (_+ₖ_) ∣ x ∣ ∣ y ∣ ≡ ∣ x ∣ +ₖ ∣ y ∣ help n x y a = (λ i → transportRefl ((∣ transportRefl x i ∣ +ₖ (∣ transportRefl y i ∣ -ₖ ∣ a ∣)) +ₖ ∣ a ∣) i) ∙∙ cong (_+ₖ ∣ a ∣) (assocₖ _ ∣ x ∣ ∣ y ∣ (-ₖ ∣ a ∣)) ∙∙ sym (assocₖ _ (∣ x ∣ +ₖ ∣ y ∣) (-ₖ ∣ a ∣) ∣ a ∣) ∙∙ cong ((∣ x ∣ +ₖ ∣ y ∣) +ₖ_) (lCancelₖ _ ∣ a ∣) ∙∙ rUnitₖ _ _ helper : (n : ℕ) (a : S₊ (suc n)) → PathP (λ i → Code n ∣ north ∣ → Code n ∣ merid a i ∣ → Code n ∣ merid a i ∣) _+ₖ_ _+ₖ_ helper n a = toPathP (funExt (trElim (λ _ → isOfHLevelPath (3 + n) (isOfHLevelΠ (3 + n) (λ _ → isOfHLevelTrunc (3 + n))) _ _) λ x → funExt (trElim (λ _ → isOfHLevelPath (3 + n) (isOfHLevelTrunc (3 + n)) _ _) λ y → help n x y a))) Code-add : {n : ℕ} (x : _) → Code n ∣ north ∣ → Code n x → Code n x Code-add {n = n} = trElim (λ x → isOfHLevelΠ (4 + n) λ _ → isOfHLevelΠ (4 + n) λ _ → isOfHLevelSuc (3 + n) (hLevCode {n = n} x)) Code-add' encode-hom : {n : ℕ} {x : _} (q : 0ₖ _ ≡ 0ₖ _) (p : 0ₖ _ ≡ x) → encode (q ∙ p) ≡ Code-add {n = n} x (encode q) (encode p) encode-hom {n = n} q = J (λ x p → encode (q ∙ p) ≡ Code-add {n = n} x (encode q) (encode p)) (cong encode (sym (rUnit q)) ∙∙ sym (rUnitₖ _ (encode q)) ∙∙ cong (encode q +ₖ_) (cong ∣_∣ (sym (transportRefl _)))) stabSpheres : (n : ℕ) → Iso (coHomK (suc n)) (typ (Ω (coHomK-ptd (2 + n)))) fun (stabSpheres n) = decode _ inv' (stabSpheres n) = encode rightInv (stabSpheres n) p = decode-encode p leftInv (stabSpheres n) = trElim (λ _ → isOfHLevelPath (3 + n) (isOfHLevelTrunc (3 + n)) _ _) λ a → cong encode (congFunct ∣_∣ (merid a) (sym (merid (ptSn (suc n))))) ∙∙ (λ i → transport (congFunct (Code n) (cong ∣_∣ (merid a)) (cong ∣_∣ (sym (merid (ptSn (suc n))))) i) ∣ ptSn (suc n) ∣) ∙∙ (substComposite (λ x → x) (cong (Code n) (cong ∣_∣ (merid a))) (cong (Code n) (cong ∣_∣ (sym (merid (ptSn (suc n)))))) ∣ ptSn (suc n) ∣ ∙∙ cong (transport (λ i → Code n ∣ merid (ptSn (suc n)) (~ i) ∣)) (transportRefl (∣ (ptSn (suc n)) ∣ +ₖ ∣ a ∣) ∙ lUnitₖ (suc n) ∣ a ∣) ∙∙ symMeridLem n (ptSn (suc n)) ∣ a ∣ ∙∙ cong (∣ a ∣ +ₖ_) -0ₖ ∙∙ rUnitₖ (suc n) ∣ a ∣) Iso-Kn-ΩKn+1 : (n : HLevel) → Iso (coHomK n) (typ (Ω (coHomK-ptd (suc n)))) Iso-Kn-ΩKn+1 zero = invIso (compIso (congIso (truncIdempotentIso _ isGroupoidS¹)) ΩS¹IsoInt) Iso-Kn-ΩKn+1 (suc n) = stabSpheres n Kn≃ΩKn+1 : {n : ℕ} → coHomK n ≃ typ (Ω (coHomK-ptd (suc n))) Kn≃ΩKn+1 {n = n} = isoToEquiv (Iso-Kn-ΩKn+1 n) -- Some properties of the Iso Kn→ΩKn+1 : (n : ℕ) → coHomK n → typ (Ω (coHomK-ptd (suc n))) Kn→ΩKn+1 n = Iso.fun (Iso-Kn-ΩKn+1 n) ΩKn+1→Kn : (n : ℕ) → typ (Ω (coHomK-ptd (suc n))) → coHomK n ΩKn+1→Kn n = Iso.inv (Iso-Kn-ΩKn+1 n) Kn→ΩKn+10ₖ : (n : ℕ) → Kn→ΩKn+1 n (0ₖ n) ≡ refl Kn→ΩKn+10ₖ zero = sym (rUnit refl) Kn→ΩKn+10ₖ (suc n) i j = ∣ (rCancel (merid (ptSn (suc n))) i j) ∣ ΩKn+1→Kn-refl : (n : ℕ) → ΩKn+1→Kn n refl ≡ 0ₖ n ΩKn+1→Kn-refl zero = refl ΩKn+1→Kn-refl (suc zero) = refl ΩKn+1→Kn-refl (suc (suc n)) = refl Kn→ΩKn+1-hom : (n : ℕ) (x y : coHomK n) → Kn→ΩKn+1 n (x +[ n ]ₖ y) ≡ Kn→ΩKn+1 n x ∙ Kn→ΩKn+1 n y Kn→ΩKn+1-hom zero x y = (λ j i → hfill (doubleComp-faces (λ i₁ → ∣ base ∣) (λ _ → ∣ base ∣) i) (inS (∣ intLoop (x ℤ+ y) i ∣)) (~ j)) ∙∙ (λ j i → ∣ intLoop-hom x y (~ j) i ∣) ∙∙ (congFunct ∣_∣ (intLoop x) (intLoop y) ∙ cong₂ _∙_ (λ j i → hfill (doubleComp-faces (λ i₁ → ∣ base ∣) (λ _ → ∣ base ∣) i) (inS (∣ intLoop x i ∣)) j) λ j i → hfill (doubleComp-faces (λ i₁ → ∣ base ∣) (λ _ → ∣ base ∣) i) (inS (∣ intLoop y i ∣)) j) Kn→ΩKn+1-hom (suc n) = σ-hom ΩKn+1→Kn-hom : (n : ℕ) (x y : Path (coHomK (suc n)) (0ₖ _) (0ₖ _)) → ΩKn+1→Kn n (x ∙ y) ≡ ΩKn+1→Kn n x +[ n ]ₖ ΩKn+1→Kn n y ΩKn+1→Kn-hom zero p q = cong winding (congFunct (trRec isGroupoidS¹ (λ x → x)) p q) ∙ winding-hom (cong (trRec isGroupoidS¹ (λ x → x)) p) (cong (trRec isGroupoidS¹ (λ x → x)) q) ΩKn+1→Kn-hom (suc n) = encode-hom isHomogeneousKn : (n : HLevel) → isHomogeneous (coHomK-ptd n) isHomogeneousKn n = subst isHomogeneous (sym (ΣPathP (ua Kn≃ΩKn+1 , ua-gluePath _ (Kn→ΩKn+10ₖ n)))) (isHomogeneousPath _ _) -- With the equivalence Kn≃ΩKn+1, we get that the two definitions of cohomology groups agree open IsGroupHom coHom≅coHomΩ : ∀ {ℓ} (n : ℕ) (A : Type ℓ) → GroupIso (coHomGr n A) (coHomGrΩ n A) fun (fst (coHom≅coHomΩ n A)) = map λ f a → Kn→ΩKn+1 n (f a) inv' (fst (coHom≅coHomΩ n A)) = map λ f a → ΩKn+1→Kn n (f a) rightInv (fst (coHom≅coHomΩ n A)) = sElim (λ _ → isOfHLevelPath 2 § _ _) λ f → cong ∣_∣₂ (funExt λ x → rightInv (Iso-Kn-ΩKn+1 n) (f x)) leftInv (fst (coHom≅coHomΩ n A)) = sElim (λ _ → isOfHLevelPath 2 § _ _) λ f → cong ∣_∣₂ (funExt λ x → leftInv (Iso-Kn-ΩKn+1 n) (f x)) snd (coHom≅coHomΩ n A) = makeIsGroupHom (sElim2 (λ _ _ → isOfHLevelPath 2 § _ _) λ f g → cong ∣_∣₂ (funExt λ x → Kn→ΩKn+1-hom n (f x) (g x))) module lockedKnIso (key : Unit') where Kn→ΩKn+1' : (n : ℕ) → coHomK n → typ (Ω (coHomK-ptd (suc n))) Kn→ΩKn+1' n = lock key (Iso.fun (Iso-Kn-ΩKn+1 n)) ΩKn+1→Kn' : (n : ℕ) → typ (Ω (coHomK-ptd (suc n))) → coHomK n ΩKn+1→Kn' n = lock key (Iso.inv (Iso-Kn-ΩKn+1 n)) ΩKn+1→Kn→ΩKn+1 : (n : ℕ) → (x : typ (Ω (coHomK-ptd (suc n)))) → Kn→ΩKn+1' n (ΩKn+1→Kn' n x) ≡ x ΩKn+1→Kn→ΩKn+1 n x = pm key where pm : (key : Unit') → lock key (Iso.fun (Iso-Kn-ΩKn+1 n)) (lock key (Iso.inv (Iso-Kn-ΩKn+1 n)) x) ≡ x pm unlock = Iso.rightInv (Iso-Kn-ΩKn+1 n) x Kn→ΩKn+1→Kn : (n : ℕ) → (x : coHomK n) → ΩKn+1→Kn' n (Kn→ΩKn+1' n x) ≡ x Kn→ΩKn+1→Kn n x = pm key where pm : (key : Unit') → lock key (Iso.inv (Iso-Kn-ΩKn+1 n)) (lock key (Iso.fun (Iso-Kn-ΩKn+1 n)) x) ≡ x pm unlock = Iso.leftInv (Iso-Kn-ΩKn+1 n) x -distrLemma : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (n m : ℕ) (f : GroupHom (coHomGr n A) (coHomGr m B)) (x y : coHom n A) → fst f (x -[ n ]ₕ y) ≡ fst f x -[ m ]ₕ fst f y -distrLemma n m f' x y = sym (-cancelRₕ m (f y) (f (x -[ n ]ₕ y))) ∙∙ cong (λ x → x -[ m ]ₕ f y) (sym (f' .snd .pres· (x -[ n ]ₕ y) y)) ∙∙ cong (λ x → x -[ m ]ₕ f y) ( cong f (-+cancelₕ n _ _)) where f = fst f'
{ "alphanum_fraction": 0.5148380071, "avg_line_length": 49.254789272, "ext": "agda", "hexsha": "e418ffa1df56aa38331e5dae41f2099de85e0b55", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-03-12T20:08:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-03-12T20:08:45.000Z", "max_forks_repo_head_hexsha": "ef62b84397396d48135d73ba7400b71c721ddc94", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "maxdore/cubical", "max_forks_repo_path": "Cubical/ZCohomology/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ef62b84397396d48135d73ba7400b71c721ddc94", "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": "maxdore/cubical", "max_issues_repo_path": "Cubical/ZCohomology/Properties.agda", "max_line_length": 132, "max_stars_count": null, "max_stars_repo_head_hexsha": "ef62b84397396d48135d73ba7400b71c721ddc94", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "maxdore/cubical", "max_stars_repo_path": "Cubical/ZCohomology/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 10791, "size": 25711 }
module PatternSynonymImports where open import PatternSynonyms renaming (z to zzz) pattern myzero = zzz two = ss zzz list : List ℕ list = 1 ∷ []
{ "alphanum_fraction": 0.7364864865, "avg_line_length": 14.8, "ext": "agda", "hexsha": "766aced91ef6f06904f8a0c055806ccf79bf8f7b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/PatternSynonymImports.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/PatternSynonymImports.agda", "max_line_length": 47, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/PatternSynonymImports.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 44, "size": 148 }
{-# OPTIONS --cubical #-} module Issue2799 where open import Agda.Primitive.Cubical postulate PathP : ∀ {ℓ} (A : I → Set ℓ) → A i0 → A i1 → Set ℓ {-# BUILTIN PATHP PathP #-} _≡_ : ∀ {ℓ} {A : Set ℓ} → A → A → Set ℓ _≡_ {A = A} = PathP (λ _ → A) record Stream (A : Set) : Set where coinductive constructor _,_ field head : A tail : Stream A open Stream mapS : ∀ {A B} → (A → B) → Stream A → Stream B head (mapS f xs) = f (head xs) tail (mapS f xs) = mapS f (tail xs) mapS-id : ∀ {A} {xs : Stream A} → mapS (λ x → x) xs ≡ xs head (mapS-id {xs = xs} i) = head xs tail (mapS-id {xs = xs} i) = mapS-id {xs = tail xs} i
{ "alphanum_fraction": 0.5492307692, "avg_line_length": 20.3125, "ext": "agda", "hexsha": "d9139b685fd75f6058fd303ecd77cc1061334e48", "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/Issue2799.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/Issue2799.agda", "max_line_length": 56, "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/Issue2799.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": 265, "size": 650 }
postulate A : Set record Overlap : Set where constructor mk field overlap {{a}} : A record NoOverlap : Set where constructor mk field {{a}} : A ok : A → NoOverlap ok a = mk {{a}} bad : A → Overlap bad a = mk {{a}} -- Function does not accept argument {{a}} -- when checking that {{a}} is a valid argument to a function of type -- {{a = a₁ : A}} → Overlap
{ "alphanum_fraction": 0.6277173913, "avg_line_length": 18.4, "ext": "agda", "hexsha": "7c1cdae157db482d8494baf8a447d5f43d6d4161", "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/Issue2597.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/Issue2597.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/Issue2597.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": 113, "size": 368 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Morphism.IsoEquiv {o ℓ e} (𝒞 : Category o ℓ e) where open import Level open import Function using (flip; _on_) open import Relation.Binary hiding (_⇒_) import Relation.Binary.Construct.On as On open import Categories.Morphism 𝒞 open Category 𝒞 private variable A B C : Obj -- Two lemmas to set things up: if they exist, inverses are unique. to-unique : ∀ {f₁ f₂ : A ⇒ B} {g₁ g₂} → Iso f₁ g₁ → Iso f₂ g₂ → f₁ ≈ f₂ → g₁ ≈ g₂ to-unique {_} {_} {f₁} {f₂} {g₁} {g₂} iso₁ iso₂ hyp = begin g₁ ≈˘⟨ identityˡ ⟩ id ∘ g₁ ≈˘⟨ ∘-resp-≈ˡ Iso₂.isoˡ ⟩ (g₂ ∘ f₂) ∘ g₁ ≈˘⟨ ∘-resp-≈ˡ (∘-resp-≈ʳ hyp) ⟩ (g₂ ∘ f₁) ∘ g₁ ≈⟨ assoc ⟩ g₂ ∘ (f₁ ∘ g₁) ≈⟨ ∘-resp-≈ʳ Iso₁.isoʳ ⟩ g₂ ∘ id ≈⟨ identityʳ ⟩ g₂ ∎ where open HomReasoning module Iso₁ = Iso iso₁ module Iso₂ = Iso iso₂ from-unique : ∀ {f₁ f₂ : A ⇒ B} {g₁ g₂} → Iso f₁ g₁ → Iso f₂ g₂ → g₁ ≈ g₂ → f₁ ≈ f₂ from-unique iso₁ iso₂ hyp = to-unique iso₁⁻¹ iso₂⁻¹ hyp where iso₁⁻¹ = record { isoˡ = Iso.isoʳ iso₁ ; isoʳ = Iso.isoˡ iso₁ } iso₂⁻¹ = record { isoˡ = Iso.isoʳ iso₂ ; isoʳ = Iso.isoˡ iso₂ } -- Equality of isomorphisms is just equality of the underlying morphism(s). -- -- Only one equation needs to be given; the equation in the other -- direction holds automatically (by the above lemmas). -- -- The reason for wrapping the underlying equality in a record at all -- is that this helps unification. Concretely, it allows Agda to -- infer the isos |i| and |j| being related in function applications -- where only the equation |i ≃ j| is passed as an explicit argument. infix 4 _≃_ record _≃_ (i j : A ≅ B) : Set e where constructor ⌞_⌟ open _≅_ field from-≈ : from i ≈ from j to-≈ : to i ≈ to j to-≈ = to-unique (iso i) (iso j) from-≈ open _≃_ ≃-isEquivalence : IsEquivalence (_≃_ {A} {B}) ≃-isEquivalence = record { refl = ⌞ refl ⌟ ; sym = λ where ⌞ eq ⌟ → ⌞ sym eq ⌟ ; trans = λ where ⌞ eq₁ ⌟ ⌞ eq₂ ⌟ → ⌞ trans eq₁ eq₂ ⌟ } where open Equiv ≃-setoid : ∀ {A B : Obj} → Setoid _ _ ≃-setoid {A} {B} = record { Carrier = A ≅ B ; _≈_ = _≃_ ; isEquivalence = ≃-isEquivalence } ---------------------------------------------------------------------- -- An alternative, more direct notion of equality on isomorphisms that -- involves no wrapping/unwrapping. infix 4 _≃′_ _≃′_ : Rel (A ≅ B) e _≃′_ = _≈_ on _≅_.from ≃′-isEquivalence : IsEquivalence (_≃′_ {A} {B}) ≃′-isEquivalence = On.isEquivalence _≅_.from equiv ≃′-setoid : ∀ {A B : Obj} → Setoid _ _ ≃′-setoid {A} {B} = record { Carrier = A ≅ B ; _≈_ = _≃′_ ; isEquivalence = ≃′-isEquivalence } -- The two notions of equality are equivalent ≃⇒≃′ : ∀ {i j : A ≅ B} → i ≃ j → i ≃′ j ≃⇒≃′ eq = from-≈ eq ≃′⇒≃ : ∀ {i j : A ≅ B} → i ≃′ j → i ≃ j ≃′⇒≃ {_} {_} {i} {j} eq = ⌞ eq ⌟
{ "alphanum_fraction": 0.5655380489, "avg_line_length": 28.141509434, "ext": "agda", "hexsha": "b7b7c6e080a5512827c4570a884754bd71b0ef92", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Morphism/IsoEquiv.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Morphism/IsoEquiv.agda", "max_line_length": 75, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Morphism/IsoEquiv.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1229, "size": 2983 }
open import OutsideIn.Prelude open import OutsideIn.X module OutsideIn.Expressions(x : X) where import OutsideIn.TypeSchema as TS open TS(x) open X(x) {- SYNTAX -} data Name (n : Set) : NameType → Set where N : n → Name n Regular DC : ∀ {x} → dc x → Name n (Datacon x) mutual data Alternative (ev tv : Set) : Shape → Set where _→′_ : ∀ {n : ℕ}{r : Shape}→ Name ev (Datacon n) → Expression (ev ⨁ n) tv r → Alternative ev tv (Unary r) infixr 5 _∣_ data Alternatives (ev tv : Set) : Shape → Set where esac : Alternatives ev tv Nullary _∣_ : ∀ {r₁ r₂} → Alternative ev tv r₁ → Alternatives ev tv r₂ → Alternatives ev tv (Binary r₁ r₂) data Expression (ev tv : Set) : Shape → Set where Var : ∀ {x} → Name ev x → Expression ev tv Nullary λ′_ : ∀ {a} → Expression (Ⓢ ev) tv a → Expression ev tv (Unary a) _·_ : ∀ {a a′} → Expression ev tv a → Expression ev tv a′ → Expression ev tv (Binary a a′) let₁_in′_ : ∀ {a a′} → Expression ev tv a → Expression (Ⓢ ev) tv a′ → Expression ev tv (Binary a a′) let₂_∷_in′_ : ∀ {a a′} → Expression ev tv a → Type tv → Expression (Ⓢ ev) tv a′ → Expression ev tv (Binary a a′) let₃_·_∷_⇒_in′_ : ∀ {a a′} → (n : ℕ) → Expression ev (tv ⨁ n) a → QConstraint (tv ⨁ n) → Type (tv ⨁ n) → Expression (Ⓢ ev) tv a′ → Expression ev tv (Binary a a′) case_of_ : ∀ {r₁ r₂} → Expression ev tv r₁ → Alternatives ev tv r₂ → Expression ev tv (Binary r₁ r₂) private module PlusN-f n = Functor (Monad.is-functor (PlusN-is-monad {n})) module Ⓢ-f = Functor Ⓢ-is-functor module Type-f = Functor (type-is-functor) module TypeSchema-f {n} = Functor (type-schema-is-functor {n}) module QC-f = Functor (qconstraint-is-functor) private fmap-alt₁ : ∀ {a b tv}{r} → (a → b) → Alternative a tv r → Alternative b tv r fmap-exp₁ : ∀ {a b tv}{r} → (a → b) → Expression a tv r → Expression b tv r map-fmap-alt₁ : ∀ {a b tv}{r} → (a → b) → Alternatives a tv r → Alternatives b tv r fmap-alt₁ f (_→′_ {n} (DC c) expr) = DC c →′ fmap-exp₁ (pn.map f) expr where module pn = PlusN-f n fmap-exp₁ f (Var (DC c)) = Var (DC c) fmap-exp₁ f (Var (N x)) = Var (N (f x)) fmap-exp₁ f (λ′ x) = λ′ (fmap-exp₁ (Ⓢ-f.map f) x) fmap-exp₁ f (x · y) = (fmap-exp₁ f x) · (fmap-exp₁ f y) fmap-exp₁ f (let₁ x in′ y) = let₁ (fmap-exp₁ f x) in′ (fmap-exp₁ (Ⓢ-f.map f) y) fmap-exp₁ f (let₂ x ∷ τ in′ y) = let₂ (fmap-exp₁ f x) ∷ τ in′ (fmap-exp₁ (Ⓢ-f.map f) y) fmap-exp₁ f (let₃ n · x ∷ Q ⇒ τ in′ y) = let₃ n · fmap-exp₁ f x ∷ Q ⇒ τ in′ fmap-exp₁ (Ⓢ-f.map f) y fmap-exp₁ f (case x of alts) = case (fmap-exp₁ f x) of map-fmap-alt₁ f alts map-fmap-alt₁ f esac = esac map-fmap-alt₁ f (x ∣ xs) = fmap-alt₁ f x ∣ map-fmap-alt₁ f xs private fmap-alt₂ : ∀ {a b ev}{r} → (a → b) → Alternative ev a r → Alternative ev b r fmap-exp₂ : ∀ {a b ev}{r} → (a → b) → Expression ev a r → Expression ev b r map-fmap-alt₂ : ∀ {a b ev}{r} → (a → b) → Alternatives ev a r → Alternatives ev b r fmap-alt₂ f (p →′ expr) = p →′ fmap-exp₂ f expr fmap-exp₂ f (Var x) = Var x fmap-exp₂ f (λ′ x) = λ′ (fmap-exp₂ f x) fmap-exp₂ f (x · y) = fmap-exp₂ f x · fmap-exp₂ f y fmap-exp₂ f (let₁ x in′ y) = let₁ fmap-exp₂ f x in′ fmap-exp₂ f y fmap-exp₂ f (let₂ x ∷ τ in′ y) = let₂ fmap-exp₂ f x ∷ Type-f.map f τ in′ fmap-exp₂ f y fmap-exp₂ f (let₃ n · x ∷ Q ⇒ τ in′ y) = let₃ n · fmap-exp₂ (pn.map f) x ∷ QC-f.map (pn.map f) Q ⇒ Type-f.map (pn.map f) τ in′ fmap-exp₂ f y where module pn = PlusN-f n fmap-exp₂ f (case x of alts) = case (fmap-exp₂ f x) of map-fmap-alt₂ f alts map-fmap-alt₂ f esac = esac map-fmap-alt₂ f (x ∣ xs) = fmap-alt₂ f x ∣ map-fmap-alt₂ f xs private fmap-alt-id₁ : {A tv : Set} {f : A → A}{r : Shape} → isIdentity f → isIdentity (fmap-alt₁ {A}{A}{tv}{r} f) map-fmap-alt-id₁ : ∀ {a}{tv}{f : a → a}{r : Shape} → isIdentity f → isIdentity (map-fmap-alt₁ {a}{a}{tv}{r} f) fmap-exp-id₁ : ∀{A tv : Set}{r : Shape} {f : A → A} → isIdentity f → isIdentity (fmap-exp₁ {A}{A}{tv}{r} f) fmap-alt-id₁ {A}{f} f-is-id {_→′_ {n} (DC p) x} = cong (_→′_ (DC p)) (fmap-exp-id₁ (pn.identity f-is-id)) where module pn = PlusN-f n map-fmap-alt-id₁ {r = Unary _} f-is-id {} map-fmap-alt-id₁ {r = Nullary} f-is-id {esac} = refl map-fmap-alt-id₁ {r = Binary r₁ r₂} f-is-id {x ∣ xs} = cong₂ _∣_ (fmap-alt-id₁ f-is-id) (map-fmap-alt-id₁ f-is-id) fmap-exp-id₁ {r = Nullary} f-is-id {Var (DC x)} = refl fmap-exp-id₁ {r = Nullary} f-is-id {Var (N x)} = cong Var (cong N f-is-id) fmap-exp-id₁ {r = Unary r′} f-is-id {λ′ x} = cong λ′_ (fmap-exp-id₁ (Ⓢ-f.identity f-is-id)) fmap-exp-id₁ {r = Binary r₁ r₂} f-is-id {x · y} = cong₂ _·_ (fmap-exp-id₁ f-is-id) (fmap-exp-id₁ f-is-id) fmap-exp-id₁ {r = Binary r₁ r₂} f-is-id {let₁ x in′ y} = cong₂ let₁_in′_ (fmap-exp-id₁ f-is-id) (fmap-exp-id₁ (Ⓢ-f.identity f-is-id)) fmap-exp-id₁ {r = Binary r₁ r₂} f-is-id {let₂ x ∷ τ in′ y} = cong₂ (λ a b → let₂ a ∷ τ in′ b) (fmap-exp-id₁ f-is-id) (fmap-exp-id₁ (Ⓢ-f.identity f-is-id)) fmap-exp-id₁ {r = Binary r₁ r₂} f-is-id {let₃ n · x ∷ Q ⇒ τ in′ y} = cong₂ (λ a b → let₃ n · a ∷ Q ⇒ τ in′ b) (fmap-exp-id₁ f-is-id) (fmap-exp-id₁ (Ⓢ-f.identity f-is-id)) fmap-exp-id₁ {r = Binary r₁ r₂} f-is-id {case x of alts} = cong₂ case_of_ (fmap-exp-id₁ f-is-id) (map-fmap-alt-id₁ f-is-id) private fmap-alt-id₂ : {A ev : Set}{r : Shape}{f : A → A} → isIdentity f → isIdentity (fmap-alt₂ {A}{A}{ev}{r} f) map-fmap-alt-id₂ : ∀ {a}{ev}{r : Shape}{f : a → a} → isIdentity f → isIdentity (map-fmap-alt₂ {a}{a}{ev}{r} f) fmap-exp-id₂ : ∀{A ev : Set}{r : Shape} {f : A → A} → isIdentity f → isIdentity (fmap-exp₂ {A}{A}{ev}{r} f) fmap-alt-id₂ f-is-id {_→′_ {n} p x} = cong (_→′_ p) (fmap-exp-id₂ f-is-id) map-fmap-alt-id₂ f-is-id {esac} = refl map-fmap-alt-id₂ f-is-id {x ∣ xs} = cong₂ _∣_ (fmap-alt-id₂ f-is-id) (map-fmap-alt-id₂ f-is-id) fmap-exp-id₂ {r = Nullary} f-is-id {Var x} = refl fmap-exp-id₂ {r = Unary r′} f-is-id {λ′ x} = cong λ′_ (fmap-exp-id₂ f-is-id) fmap-exp-id₂ {r = Binary r₁ r₂} f-is-id {x · y} = cong₂ _·_ (fmap-exp-id₂ f-is-id) (fmap-exp-id₂ f-is-id) fmap-exp-id₂ {r = Binary r₁ r₂} f-is-id {let₁ x in′ y} = cong₂ let₁_in′_ (fmap-exp-id₂ f-is-id) (fmap-exp-id₂ f-is-id) fmap-exp-id₂ {r = Binary r₁ r₂} f-is-id {let₂ x ∷ τ in′ y} = cong₃ let₂_∷_in′_ (fmap-exp-id₂ f-is-id) (Type-f.identity f-is-id) (fmap-exp-id₂ f-is-id) fmap-exp-id₂ {r = Binary r₁ r₂} f-is-id {let₃ n · x ∷ Q ⇒ τ in′ y} = cong₄ (let₃_·_∷_⇒_in′_ n) (fmap-exp-id₂ (pn.identity f-is-id)) (QC-f.identity (pn.identity f-is-id)) (Type-f.identity (pn.identity f-is-id)) (fmap-exp-id₂ f-is-id) where module pn = PlusN-f n fmap-exp-id₂ {r = Binary r₁ r₂} f-is-id {case x of alts} = cong₂ case_of_ (fmap-exp-id₂ f-is-id) (map-fmap-alt-id₂ f-is-id) private fmap-alt-comp₁ : {r : Shape} {A B C tv : Set} {f : A → B}{g : B → C} {x : Alternative A tv r} → fmap-alt₁ (g ∘ f) x ≡ fmap-alt₁ g (fmap-alt₁ f x) fmap-exp-comp₁ : {r : Shape}{tv A B C : Set} {f : A → B} {g : B → C} {x : Expression A tv r} → fmap-exp₁ (g ∘ f) x ≡ fmap-exp₁ g (fmap-exp₁ f x) map-fmap-alt-comp₁ : {r : Shape}{A B C tv : Set}{f : A → B}{g : B → C}{l : Alternatives A tv r} → map-fmap-alt₁ (g ∘ f) l ≡ map-fmap-alt₁ g (map-fmap-alt₁ f l) fmap-alt-comp₁ {Nullary} {x = ()} fmap-alt-comp₁ {Binary _ _}{x = ()} fmap-alt-comp₁ {Unary r}{f = f}{g}{x = _→′_ {n} (DC p) expr} = cong (_→′_ (DC p)) (combine-composite′ ⦃ Monad.is-functor (PlusN-is-monad {n}) ⦄ {expr} fmap-exp₁ (fmap-exp-comp₁ {f = pn.map f}{g = pn.map g}{expr})) where module pn = PlusN-f n map-fmap-alt-comp₁ {l = esac} = refl map-fmap-alt-comp₁ {Binary a b}{A}{B}{C}{tv}{l = x ∣ xs} = cong₂ _∣_ (fmap-alt-comp₁ {x = x}) (map-fmap-alt-comp₁) fmap-exp-comp₁ {x = Var (N x)} = cong Var (cong N (refl)) fmap-exp-comp₁ {x = Var (DC x)} = refl fmap-exp-comp₁ {f = f}{g}{x = λ′ x } = cong λ′_ (combine-composite′ ⦃ Monad.is-functor (Ⓢ-is-monad) ⦄ {x} fmap-exp₁ (fmap-exp-comp₁ {f = Ⓢ-f.map f}{g = Ⓢ-f.map g}{x})) fmap-exp-comp₁ {f = f}{g}{x = x · y } = cong₂ _·_ (fmap-exp-comp₁ {f = f}{g}{x}) (fmap-exp-comp₁ {f = f}{g}{y}) fmap-exp-comp₁ {f = f}{g}{x = let₁ x in′ y } = cong₂ let₁_in′_ (fmap-exp-comp₁ {f = f}{g}{x}) (combine-composite′ ⦃ Monad.is-functor (Ⓢ-is-monad) ⦄ {y} fmap-exp₁ (fmap-exp-comp₁ {f = Ⓢ-f.map f}{g = Ⓢ-f.map g}{y})) fmap-exp-comp₁ {f = f}{g}{x = let₂ x ∷ τ in′ y} = cong₂ (λ a b → let₂ a ∷ τ in′ b) (fmap-exp-comp₁ {f = f}{g}{x}) (combine-composite′ ⦃ Monad.is-functor (Ⓢ-is-monad) ⦄ {y} fmap-exp₁ (fmap-exp-comp₁ {f = Ⓢ-f.map f} {g = Ⓢ-f.map g}{y})) fmap-exp-comp₁ {f = f}{g}{x = let₃ n · x ∷ Q ⇒ τ in′ y} = cong₂ (λ a b → let₃ n · a ∷ Q ⇒ τ in′ b) (fmap-exp-comp₁ {f = f}{g}{x}) (combine-composite′ ⦃ Monad.is-functor (Ⓢ-is-monad) ⦄ {y} fmap-exp₁ (fmap-exp-comp₁ {f = Ⓢ-f.map f}{g = Ⓢ-f.map g}{y})) fmap-exp-comp₁ {f = f}{g}{x = case x of alts } = cong₂ case_of_ (fmap-exp-comp₁ {f = f}{g}{x}) map-fmap-alt-comp₁ private fmap-alt-comp₂ : {A B C ev : Set}{r : Shape} {f : A → B} {g : B → C} {x : Alternative ev A r} → fmap-alt₂ (g ∘ f) x ≡ fmap-alt₂ g (fmap-alt₂ f x) fmap-exp-comp₂ : {A B C ev : Set}{r : Shape} {f : A → B} {g : B → C} {x : Expression ev A r} → fmap-exp₂ (g ∘ f) x ≡ fmap-exp₂ g (fmap-exp₂ f x) map-fmap-alt-comp₂ : ∀{r}{A B C ev : Set} {f : A → B} {g : B → C} {alts : Alternatives ev A r} → map-fmap-alt₂ (g ∘ f) alts ≡ map-fmap-alt₂ g (map-fmap-alt₂ f alts) fmap-alt-comp₂ {x = _→′_ {n} p expr} = cong (_→′_ p) fmap-exp-comp₂ map-fmap-alt-comp₂ {alts = esac} = refl map-fmap-alt-comp₂ {alts = x ∣ xs} = cong₂ _∣_ fmap-alt-comp₂ map-fmap-alt-comp₂ fmap-exp-comp₂ {x = Var a} = refl fmap-exp-comp₂ {x = λ′ x } = cong λ′_ fmap-exp-comp₂ fmap-exp-comp₂ {x = x · y } = cong₂ _·_ fmap-exp-comp₂ fmap-exp-comp₂ fmap-exp-comp₂ {x = let₁ x in′ y } = cong₂ let₁_in′_ fmap-exp-comp₂ fmap-exp-comp₂ fmap-exp-comp₂ {x = let₂ x ∷ τ in′ y } = cong₃ let₂_∷_in′_ fmap-exp-comp₂ Type-f.composite fmap-exp-comp₂ fmap-exp-comp₂ {x = let₃ n · x ∷ Q ⇒ τ in′ y } = cong₄ (λ a b c d → let₃ n · a ∷ b ⇒ c in′ d) (combine-composite′ ⦃ pnf ⦄ fmap-exp₂ fmap-exp-comp₂) (combine-composite ⦃ qconstraint-is-functor ⦄ ⦃ pnf ⦄) (combine-composite ⦃ type-is-functor ⦄ ⦃ pnf ⦄) fmap-exp-comp₂ where pnf = Monad.is-functor (PlusN-is-monad {n}) fmap-exp-comp₂ {x = case x of alts } = cong₂ case_of_ fmap-exp-comp₂ map-fmap-alt-comp₂ alternatives-is-functor₁ : ∀{tv}{r} → Functor (λ x → Alternatives x tv r) alternatives-is-functor₁ = record { map = map-fmap-alt₁ ; identity = map-fmap-alt-id₁ ; composite = map-fmap-alt-comp₁ } alternatives-is-functor₂ : ∀{ev}{r} → Functor (λ x → Alternatives ev x r) alternatives-is-functor₂ = record { map = map-fmap-alt₂ ; identity = map-fmap-alt-id₂ ; composite = map-fmap-alt-comp₂ } alternative-is-functor₁ : ∀{tv}{r} → Functor (λ x → Alternative x tv r) alternative-is-functor₁ = record { map = fmap-alt₁ ; identity = fmap-alt-id₁ ; composite = λ { {x = x} → fmap-alt-comp₁ {x = x} } } alternative-is-functor₂ : ∀{ev}{r} → Functor (λ x → Alternative ev x r) alternative-is-functor₂ = record { map = fmap-alt₂ ; identity = fmap-alt-id₂ ; composite = fmap-alt-comp₂ } expression-is-functor₁ : ∀{tv}{r} → Functor (λ x → Expression x tv r) expression-is-functor₁ {tv}{r} = record { map = fmap-exp₁ ; identity = fmap-exp-id₁ ; composite = λ {A}{B}{C}{f}{g}{x} → fmap-exp-comp₁ {r}{tv}{A}{B}{C}{f}{g}{x} } expression-is-functor₂ : ∀{ev}{r} → Functor (λ x → Expression ev x r) expression-is-functor₂ = record { map = fmap-exp₂ ; identity = fmap-exp-id₂ ; composite = fmap-exp-comp₂ }
{ "alphanum_fraction": 0.4662153013, "avg_line_length": 59.3172690763, "ext": "agda", "hexsha": "2232fb32ae995a926610a7800fc2b33394e655ea", "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": "fc1fc1bba2af95806d9075296f9ed1074afa4c24", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "liamoc/outside-in", "max_forks_repo_path": "OutsideIn/Expressions.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24", "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": "liamoc/outside-in", "max_issues_repo_path": "OutsideIn/Expressions.agda", "max_line_length": 118, "max_stars_count": 2, "max_stars_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "liamoc/outside-in", "max_stars_repo_path": "OutsideIn/Expressions.agda", "max_stars_repo_stars_event_max_datetime": "2020-11-19T14:30:07.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-14T05:22:15.000Z", "num_tokens": 4943, "size": 14770 }
{-# OPTIONS --cubical #-} module Type.Cubical.Path.Equality where open import Functional open import Function.Axioms import Lvl open import Type open import Type.Cubical open import Type.Cubical.Path open import Type.Cubical.Path.Proofs as Path open import Structure.Function open import Structure.Operator open import Structure.Relator.Equivalence open import Structure.Relator.Properties open import Structure.Relator open import Structure.Setoid using (Equiv ; intro) open import Structure.Type.Identity private variable ℓ ℓ₁ ℓ₂ ℓₚ : Lvl.Level private variable T A B C : Type{ℓ} private variable f : A → B private variable _▫_ : A → B → C private variable P : T → Type{ℓ} private variable x y : T _≡_ : T → T → Type _≡_ = Path instance Path-reflexivity : Reflexivity{T = T}(Path) Path-reflexivity = intro Path.point instance Path-symmetry : Symmetry{T = T}(Path) Path-symmetry = intro Path.reverse instance Path-transitivity : Transitivity{T = T}(Path) Path-transitivity = intro Path.concat instance Path-equivalence : Equivalence{T = T}(Path) Path-equivalence = intro instance Path-equiv : Equiv(T) Path-equiv = intro(Path) ⦃ Path-equivalence ⦄ instance Path-congruence₁ : Function(f) Path-congruence₁ {f = f} = intro(Path.map f) instance Path-congruence₂ : BinaryOperator(_▫_) Path-congruence₂ {_▫_ = _▫_} = intro(Path.map₂(_▫_)) instance Path-substitution₁ : UnaryRelator(P) Path-substitution₁ {P = P} = intro(Path.liftedSpaceMap P) instance Path-substitution₂ : BinaryRelator(_▫_) Path-substitution₂ {_▫_ = _▫_} = intro(Path.liftedSpaceMap₂(_▫_)) instance Path-coercion : Path ⊆₂ (_→ᶠ_ {ℓ}{ℓ}) Path-coercion = intro(Path.spaceMap) Path-sub-of-reflexive : ⦃ refl : Reflexivity(_▫_) ⦄ → (Path ⊆₂ (_▫_)) Path-sub-of-reflexive {_▫_ = _▫_} = intro(\{a b} → ab ↦ sub₂(Path)(_→ᶠ_) ⦃ Path-coercion ⦄ (congruence₂ᵣ(_▫_)(a) ab) (reflexivity(_▫_) {a})) instance Path-function-extensionality : FunctionExtensionality A B Path-function-extensionality = intro Path.mapping instance Path-dependent-function-extensionality : ∀{A : Type{ℓ₁}}{B : (a : A) → Type{ℓ₂}} → DependentFunctionExtensionality A B Path-dependent-function-extensionality = intro Path.mapping instance Path-function-application : FunctionApplication A B Path-function-application = intro Path.mappingPoint Path-identity-eliminator : IdentityEliminator{ℓₚ = ℓₚ}(Path{P = T}) IdentityEliminator.elim Path-identity-eliminator P prefl eq = sub₂(Path)(_→ᶠ_) ⦃ Path-coercion ⦄ (\i → P(\j → eq(Interval.min i j))) prefl -- TODO: Organize and move everything below open import Type.Properties.MereProposition open import Type.Properties.Singleton prop-is-prop-unit : ⦃ proof : MereProposition(A) ⦄ → IsUnit(MereProposition(A)) MereProposition.uniqueness (IsUnit.unit prop-is-prop-unit) {x} {y} = uniqueness _ MereProposition.uniqueness (IsUnit.uniqueness (prop-is-prop-unit {A = A}) {intro p} i) {x}{y} j = Interval.hComp d x where d : Interval → Interval.Partial (Interval.max (Interval.max (Interval.flip i) i) (Interval.max (Interval.flip j) j)) A d k (i = Interval.𝟎) = uniqueness(A) {x}{p{x}{y} j} k d k (i = Interval.𝟏) = uniqueness(A) {x}{uniqueness(A) {x}{y} j} k d k (j = Interval.𝟎) = uniqueness(A) {x}{x} k d k (j = Interval.𝟏) = uniqueness(A) {x}{y} k {- Path-isUnit : ∀{ℓ}{A : Type{ℓ}} → ⦃ _ : MereProposition(A) ⦄ → (∀{x y : A} → IsUnit(x ≡ y)) IsUnit.unit (Path-isUnit {A = A}) = uniqueness(A) IsUnit.uniqueness (Path-isUnit {A = A} ⦃ mere-A ⦄ {x = x} {y = y}) {p} i = Interval.hComp d p where d : Interval → Interval.Partial (Interval.max (Interval.flip i) i) (Path x y) d j (i = Interval.𝟎) = p d j (i = Interval.𝟏) = {!uniqueness(A) {x}{y}!} -- congruence₁ (prop ↦ MereProposition.uniqueness prop {x}{y}) (IsUnit.uniqueness prop-is-prop-unit {intro (\{x y} → {!p!})}) -} {- open import Structure.Setoid.Uniqueness open import Type.Dependent -} -- TODO -- ∀{eu₁ eu₂ : ∃!{Obj = Obj}(Pred)} → () → (eu₁ ≡ eu₂) {- Unique-MereProposition-equivalence : ⦃ prop : ∀{x} → MereProposition(P(x)) ⦄ → (Unique(P) ↔ MereProposition(∃ P)) Unique-MereProposition-equivalence {P = P} = [↔]-intro l r where l : Unique(P) ← MereProposition(∃ P) l (intro p) {x} {y} px py = mapP([∃]-witness) (p{[∃]-intro x ⦃ px ⦄} {[∃]-intro y ⦃ py ⦄}) r : Unique(P) → MereProposition(∃ P) MereProposition.uniqueness (r p) {[∃]-intro w₁ ⦃ p₁ ⦄} {[∃]-intro w₂ ⦃ p₂ ⦄} i = mapP (mapP (\w p → [∃]-intro w ⦃ p ⦄) (p p₁ p₂) i) {!!} i -- mapP [∃]-intro (p p₁ p₂) i ⦃ {!!} ⦄ Unique-prop : ⦃ prop : ∀{x} → MereProposition(P(x)) ⦄ → MereProposition(Unique(P)) MereProposition.uniqueness Unique-prop {u₁} {u₂} i {x} {y} px py j = Interval.hComp d x where d : Interval → Interval.Partial (Interval.max (Interval.max (Interval.flip i) i) (Interval.max (Interval.flip j) j)) A d k (i = Interval.𝟎) = {!!} d k (i = Interval.𝟏) = {!!} d k (j = Interval.𝟎) = {!!} d k (j = Interval.𝟏) = {!!} [∃!trunc]-to-existence : ⦃ prop : ∀{x} → MereProposition(Pred(x)) ⦄ → HTrunc₁(∃!{Obj = Obj}(Pred)) → HomotopyLevel(0)(∃{Obj = Obj}(Pred)) [∃!trunc]-to-existence {Pred = Pred} (trunc ([∧]-intro e u)) = intro e (\{e₂} i → [∃]-intro (u ([∃]-proof e₂) ([∃]-proof e) i) ⦃ {!!} ⦄) -- MereProposition.uniqueness test) {u _ _ _} -- sub₂(_≡_)(_→ᶠ_) ⦃ [≡][→]-sub ⦄ (congruence₁(Pred) ?) ? [∃!trunc]-to-existence (trunc-proof i) = {!!} -} {- [∃!]-squashed-witness : HTrunc₁(∃!{Obj = Obj}(Pred)) → Obj [∃!]-squashed-witness (trunc eu) = [∃]-witness([∧]-elimₗ eu) [∃!]-squashed-witness (trunc-proof {trunc ([∧]-intro e₁ u₁)} {trunc ([∧]-intro e₂ u₂)} i) = u₁ ([∃]-proof e₁) ([∃]-proof e₂) i [∃!]-squashed-witness (trunc-proof {trunc ([∧]-intro e₁ u₁)} {trunc-proof j} i) = {!!} [∃!]-squashed-witness (trunc-proof {trunc-proof i₁} {trunc x} i) = {!!} [∃!]-squashed-witness (trunc-proof {trunc-proof i₁} {trunc-proof i₂} i) = {!!} -}
{ "alphanum_fraction": 0.6576207544, "avg_line_length": 38.5460526316, "ext": "agda", "hexsha": "1e1a544f3dfedd2ee6a4ab914362189772f30fab", "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": "Type/Cubical/Path/Equality.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": "Type/Cubical/Path/Equality.agda", "max_line_length": 140, "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": "Type/Cubical/Path/Equality.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": 2188, "size": 5859 }
module PureLambda where data D : Set where lam : (D -> D) -> D _·_ : D -> D -> D lam f · x = f x δ : D δ = lam (\x -> x · x) loop : D loop = δ · δ
{ "alphanum_fraction": 0.464516129, "avg_line_length": 9.6875, "ext": "agda", "hexsha": "adc127c6ce2d76464bea40347e1bf88ea4490bdd", "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/PureLambda.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/PureLambda.agda", "max_line_length": 23, "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/PureLambda.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": 65, "size": 155 }
-- 2010-09-07 Andreas module IrrelevantRecordMatching where record Prod (A B : Set) : Set where constructor _,_ field fst : A snd : B wrongElim : {A : Set} -> .(Prod A A) -> A wrongElim (a , a') = a -- needs to fail because a is irrelevant
{ "alphanum_fraction": 0.6377952756, "avg_line_length": 19.5384615385, "ext": "agda", "hexsha": "bb347fad5194d3b230399ad7fa2ea9fc85f939e8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/IrrelevantRecordMatching.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/IrrelevantRecordMatching.agda", "max_line_length": 41, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/fail/IrrelevantRecordMatching.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 82, "size": 254 }
module _ where open import Common.Prelude hiding (_>>=_) open import Common.Reflection pattern `Nat = def (quote Nat) [] unquoteDecl f = declareDef (vArg f) `Nat >>= λ _ → freshName "aux" >>= λ aux → declareDef (vArg aux) `Nat >>= λ _ → defineFun f (clause [] (def aux []) ∷ [])
{ "alphanum_fraction": 0.6254295533, "avg_line_length": 20.7857142857, "ext": "agda", "hexsha": "a293f56b2b1c411139e4b20adf5634a33173d8b2", "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/Fail/UnquoteDeclHelperNotDefined.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "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": "hborum/agda", "max_issues_repo_path": "test/Fail/UnquoteDeclHelperNotDefined.agda", "max_line_length": 43, "max_stars_count": 3, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Fail/UnquoteDeclHelperNotDefined.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": 90, "size": 291 }
module Structure.LinearAlgebra where import Lvl open import Data open import Data.Tuple open import Functional hiding (id) open import Function.Equals open import Function.Proofs open import Logic open import Logic.Propositional open import Logic.Propositional.Theorems open import Logic.Predicate open import Numeral.CoordinateVector as Vec using () renaming (Vector to Vec) open import Numeral.Finite open import Numeral.Natural open import Numeral.Natural.Relation.Order open import Numeral.Natural.Relation.Order.Proofs -- open import Relator.Equals -- open import Relator.Equals.Proofs open import Structure.Setoid open import Structure.Setoid.Uniqueness open import Structure.Setoid.Uniqueness.Proofs open import Structure.Function.Domain import Structure.Function.Linear as Linear open import Structure.Operator.Field open import Structure.Operator.Group open import Structure.Operator.Properties hiding (commutativity) open import Structure.Operator.Vector open import Syntax.Number open import Type -- Finite dimensional linear algebra -- TODO: Apparently, most of linear algebra will not work in constructive logic module _ {ℓᵥ ℓₛ : Lvl.Level} {V : Type{ℓᵥ}} ⦃ equiv-V : Equiv(V) ⦄ {S : Type{ℓₛ}} ⦃ equiv-S : Equiv(S) ⦄ {_+ᵥ_ : V → V → V} {_⋅ₛᵥ_ : S → V → V} {_+ₛ_ _⋅ₛ_ : S → S → S} ⦃ vectorSpace : VectorSpace(_+ᵥ_)(_⋅ₛᵥ_)(_+ₛ_)(_⋅ₛ_) ⦄ where module _ where open VectorSpace(vectorSpace) -- A list of scalars Scalars : ℕ → Type Scalars(n) = Vec(n)(S) -- TODO: Prove that this type is a group if its underlying type (S) is a group. THen proceed to prove that injective-kernelᵣ holds with LinearCombination(_) being a homomorphism, which one can deduce that LinearlyIndependent is equivalent to Injective. -- A list of vectors Vectors : ℕ → Type Vectors(n) = Vec(n)(V) module _ where -- TODO: Make this a record instead, and then define an "eval"-function and prove LinearCombination-addition for this eval function (homomorphism) -- A specific linear combination of vectors (specific as specified by scalars). -- Linear combination of 0 scalars and vectors are the zero vector. -- Linear combination of 1 scalar and vector is just scalar on vector multiplication. -- Example: LinearCombination {4} sf vf = (sf[0] ⋅ₛᵥ vf[0]) +ᵥ (sf[1] ⋅ₛᵥ vf[1]) +ᵥ (sf[2] ⋅ₛᵥ vf[2]) +ᵥ (sf[3] ⋅ₛᵥ vf[3]) LinearCombination : ∀{n} → Vectors(n) → Scalars(n) → V LinearCombination {0} _ _ = 𝟎ᵥ LinearCombination {1} vf sf = Vec.proj(sf)(0) ⋅ₛᵥ Vec.proj(vf)(0) LinearCombination {𝐒(𝐒(n))} vf sf = (Vec.proj(sf)(0) ⋅ₛᵥ Vec.proj(vf)(0)) +ᵥ (LinearCombination {𝐒(n)} (Vec.tail vf) (Vec.tail sf)) postulate LinearCombination-addition : ∀{n}{sf₁ sf₂}{vf} → (LinearCombination{n}(vf)(sf₁) +ᵥ LinearCombination{n}(vf)(sf₂) ≡ LinearCombination{n}(vf)(sf₁ ⦗ Vec.map₂ (_+ₛ_) ⦘ sf₂)) postulate LinearCombination-subtraction : ∀{n}{sf₁ sf₂}{vf} → (LinearCombination{n}(vf)(sf₁) −ᵥ LinearCombination{n}(vf)(sf₂) ≡ LinearCombination{n}(vf)(sf₁ ⦗ Vec.map₂ (_−ₛ_) ⦘ sf₂)) -- Spanning(vf) ⇔ (VSP = Span(vf)) -- A set of vectors is spanning the vector space when every vector in the vector space can be represented as a linear combination of the set of vectors. Spanning : ∀{n} → Vectors(n) → Stmt Spanning(vf) = (∀{v} → ∃(sf ↦ LinearCombination(vf)(sf) ≡ v)) -- Basis(vf) ⇔ (vf is a basis) -- A set of vectors is a basis when every vector in the vector space can be represented as a unique linear combination of the set of vectors. -- A set of vectors is a basis when they span the vector space and is linearly independent. Basis : ∀{n} → Vectors(n) → Stmt Basis(vf) = (∀{v} → ∃!(sf ↦ LinearCombination(vf)(sf) ≡ v)) -- TODO: Should be some kind of set equality. Could be impossible to prove the uniqueness otherwise because one can just permute for commutative scalars -- A set of vectors is linearly independent when there is no vector that can be represented as a linear combination by the others. LinearlyIndependent : ∀{n} → Vectors(n) → Stmt LinearlyIndependent{n}(vf) = ∀{sf} → (LinearCombination(vf)(sf) ≡ 𝟎ᵥ) → (∀{i} → Vec.proj(sf)(i) ≡ 𝟎ₛ) -- sf ⊜ fill(𝟎ₛ) postulate independent-injective : ∀{n}{vf} → LinearlyIndependent{n}(vf) ↔ (∀{sf₁ sf₂} → (LinearCombination(vf)(sf₁) ≡ LinearCombination(vf)(sf₂)) → (∀{i}→ Vec.proj(sf₁)(i) ≡ Vec.proj(sf₂)(i))) -- TODO: Vec.proj(sf₁) ⊜ Vec.proj(sf₂) -- TODO: Is there some axioms that make this happen? I remember this pattern from somewhere, that injectivity is equivalent to stuff being the identity of something. Maybe it is usually expressed using a kernel? See the note written above -- TODO: Express this as injectivity when `Injective` is general over setoids basis-span-independent : ∀{n}{vf : Vectors(n)} → Basis(vf) ↔ (Spanning(vf) ∧ LinearlyIndependent(vf)) basis-span-independent{n}{vf} = [↔]-intro (uncurry l) (([↔]-to-[←] [→][∧]-distributivityₗ) ([∧]-intro r₁ r₂)) where l : Spanning(vf) → LinearlyIndependent(vf) → Basis(vf) l spanning indep {v} = [∃!]-intro existence uniqueness where existence : ∃(sf ↦ LinearCombination(vf)(sf) ≡ v) existence = spanning postulate uniqueness : Unique(sf ↦ LinearCombination(vf)(sf) ≡ v) -- uniqueness = ([↔]-elimₗ Uniqueness-Injectivity) (([↔]-elimᵣ independent-injective) indep) -- TODO: `Injective` over setoids is blocking this proof. It is at the moment proving something incorrect r₁ : Basis(vf) → Spanning(vf) r₁(proof) {v} = [∃!]-existence(proof{v}) postulate r₂ : Basis(vf) → LinearlyIndependent(vf) -- TODO: `Injective` over setoids is blocking this proof. It is at the moment proving something incorrect -- Cardinality of a set of linearly independent vectors is always less than the cardinality of a set of spanning vectors postulate independent-less-than-spanning : ∀{n₁ n₂} → ∀{vf₁} → LinearlyIndependent{n₁}(vf₁) → ∀{vf₂} → Spanning{n₂}(vf₂) → (n₁ ≤ n₂) -- Existence of a subset of spanning vectors which is a basis -- TODO: postulate basis-from-spanning : ∀{n}{vf} → ⦃ _ : Spanning{n}(vf) ⦄ → ∃(m ↦ (m ≤ n) ∧ ∃(f ↦ Basis{n}(vf ∘ f) ∧ Injective(f))) -- Existence of a finite set of vectors which spans the vector space -- A "finite dimensional vector space" is sometimes defined as a vector space which satisfies this proposition. postulate span-existence : ∃(n ↦ ∃(vf ↦ Spanning{n}(vf))) -- TODO: Usually, this exists because one can take the whole set -- Existence of a basis postulate basis-existence : ∃(n ↦ ∃(vf ↦ Basis{n}(vf))) -- A set of linearly independent vectors is smaller than a set of basis vectors postulate independent-lesser-than-basis-number : ∀{m n} → {vfₘ : Vectors(m)} → LinearlyIndependent(vfₘ) → {vfₙ : Vectors(n)} → Basis(vfₙ) → (m ≤ n) -- Every set of basis vectors are equal in size postulate basis-equal-number : ∀{m n} → {vfₘ : Vectors(m)} → Basis(vfₘ) → {vfₙ : Vectors(n)} → Basis(vfₙ) → (m ≡ n) -- The dimension of the vector space dim : ℕ dim = [∃]-witness(basis-existence) -- Existence of a superset of linearly independent vectors which is a basis -- TODO: basis-from-linearly-independent : ∀{n}{vf} → ⦃ _ : Spanning{n}(vf) ⦄ → ∃(m ↦ (m ≥ n) ∧ ∃(f ↦ Basis{n}(vf ∘ f) ∧ Injective(f))) postulate basis-from-dim-spanning : ∀{vf} → Spanning{dim}(vf) → Basis{dim}(vf) postulate basis-from-dim-independent : ∀{vf} → LinearlyIndependent{dim}(vf) → Basis{dim}(vf) -- TODO: Move to some algebraic structure? -- Nilpotent(f) = ∃(n ↦ ∀{v} → (f ^ n ≡ 𝟎ᵥ)) module _ where private LinearMap = Linear.LinearMap(_+ᵥ_)(_⋅ₛᵥ_)(_+ᵥ_)(_⋅ₛᵥ_) postulate linear-map-id : LinearMap(Function.id) -- v is a eigenvector for the eigenvalue 𝜆 of the linear transformation f Eigenvector : (V → V) → S → V → Stmt Eigenvector(f)(𝜆)(v) = ((v ≢ 𝟎ᵥ) → (f(v) ≡ 𝜆 ⋅ₛᵥ v)) -- 𝜆 is a eigenvalue of the linear transformation f -- Multiplication by an eigenvalue can replace a linear transformation for certain vectors. Eigenvalue : (V → V) → S → Stmt Eigenvalue(f)(𝜆) = (∀{v : V} → Eigenvector(f)(𝜆)(v)) -- Two linear mappings are similiar when there is a basis in which they are equal. -- Similiar : (f : V → V) → ⦃ _ : LinearMap(f) ⦄ → (g : V → V) → ⦃ _ : LinearMap(g) ⦄ → Stmt -- Similiar(f)(g) = (∀{v} → ∃(b ↦ Bijective(b) ∧ (f(v) ≡ (b ∘ g ∘ (inv(b)))(v)))) record DotProductSpace (_∙_ : V → V → S) (_≤_ : S → S → Stmt) : Stmt where field commutativity : Commutativity(_∙_) linearmapₗ : ∀{v₂} → Linear.LinearMap(_+ᵥ_)(_⋅ₛᵥ_)(_+ₛ_)(_⋅ₛ_) (_∙ v₂) positive : ∀{v} → (𝟎ₛ ≤ (v ∙ v)) injective-zero : ∀{v} → ((v ∙ v) ≡ 𝟎ₛ) → (v ≡ 𝟎ᵥ) postulate [⋅ₛᵥ]-commuting : ∀{s}{v₁ v₂} → ((s ⋅ₛᵥ v₁) ∙ v₂) ≡ (v₁ ∙ (s ⋅ₛᵥ v₂)) postulate almost-injectivity-zeroₗ : ∀{v₁} → (∀{v₂} → ((v₁ ∙ v₂) ≡ 𝟎ₛ)) → (v₁ ≡ 𝟎ᵥ) postulate injectivityₗ : ∀{v₁ v₂} → (∀{v₃} → ((v₁ ∙ v₃) ≡ (v₂ ∙ v₃))) → (v₁ ≡ v₂) module Norm (√ : S → S) where -- The length of a vector norm : V → S norm(v) = √(v ∙ v) -- The positive part of a scalar abs : S → S abs(s) = √(s ⋅ₛ s) postulate homogeneity : ∀{s}{v} → norm(s ⋅ₛᵥ v) ≡ abs(s) ⋅ₛ norm(v) postulate triangle-inequality : ∀{v₁ v₂} → (norm(v₁ +ᵥ v₂) ≤ (norm(v₁) +ₛ norm(v₂))) postulate positivity : ∀{v} → (𝟎ₛ ≤ norm(v)) postulate injectivity-zero : ∀{v} → (norm(v) ≡ 𝟎ₛ) → (v ≡ 𝟎ᵥ) postulate mult-inequality : ∀{v₁ v₂} → (abs(v₁ ∙ v₂) ≤ (norm(v₁) ⋅ₛ norm(v₂))) -- Two vectors are orthogonal when they are perpendicular. Orthogonal : V → V → Stmt Orthogonal(v₁)(v₂) = (v₁ ∙ v₂ ≡ 𝟎ₛ) {- OrthogonalAll : ∀{n} → Vectors(n) → Stmt OrthogonalAll{0} (vf) = ⊤ OrthogonalAll{1} (vf) = Orthogonal(vf(0))(vf(1)) OrthogonalAll{𝐒(𝐒(n))} (vf) = (OrthogonalAll{n} (vf)) ∧ Orthogonal(vf(n))(vf(𝐒(n))) -} postulate hypotenuse-length : ∀{v₁ v₂} → ⦃ _ : Orthogonal(v₁)(v₂) ⦄ → ((v₁ +ᵥ v₂) ∙ (v₁ +ᵥ v₂) ≡ (v₁ ∙ v₁) +ₛ (v₂ ∙ v₂)) -- Transforms a vector to an unit vector in the same direction. normalize : (v : V) → ⦃ _ : v ≢ 𝟎ᵥ ⦄ → V normalize(v) ⦃ proof ⦄ = (⅟ₛ (norm(v)) ⦃ contrapositiveᵣ (injectivity-zero) (proof) ⦄) ⋅ₛᵥ v postulate norm-of-normalize : ∀{v} → ⦃ nonzero : (v ≢ 𝟎ᵥ) ⦄ → (norm(normalize(v) ⦃ nonzero ⦄) ≡ 𝟏ₛ) -- -- TODO: Is it okay for VSP₂ to have a different scalar field compared to VSP? Some stuff will not be compatible (like addition for the same scalar type)? -- module _ {V₂} ⦃ lang₂ ⦄ (VSP₂ : VectorSpace(V₂)(S) ⦃ lang₂ ⦄) where -- open Language ⦃ ... ⦄ -- open VectorSpace ⦃ ... ⦄ -- -- private _+ᵥ₁_ = _+ᵥ_ ⦃ lang ⦄ -- private _⋅ₛᵥ₁_ = _⋅ₛᵥ_ ⦃ lang ⦄ -- private _+ᵥ₂_ = _+ᵥ_ ⦃ lang₂ ⦄ -- private _⋅ₛᵥ₂_ = _⋅ₛᵥ_ ⦃ lang₂ ⦄ -- -- private LinearMap₁₂ = Linear.LinearMap(_+ᵥ₁_)(_⋅ₛᵥ₁_)(_+ᵥ₂_)(_⋅ₛᵥ₂_) -- private LinearMap₂₁ = Linear.LinearMap(_+ᵥ₂_)(_⋅ₛᵥ₂_)(_+ᵥ₁_)(_⋅ₛᵥ₁_) -- -- module _ where -- -- Kernel(f)(v) ⇔ (v ∈ Kernel(f)) -- Kernel : (f : V → V₂) → ⦃ _ : LinearMap₁₂(f) ⦄ → V → Stmt -- Kernel(f)(v) = (f(v) ≡ 𝟎ᵥ ⦃ lang₂ ⦄ ⦃ VSP₂ ⦄) -- -- -- TODO: Move away the module for two vector spaces from one so that dim is not bound to V -- -- rank : (V → V₂) → ℕ -- -- rank(_) = dim ⦃ VSP₂ ⦄ -- -- module _ where -- postulate linear-map-const-zero : LinearMap₁₂(const(𝟎ᵥ ⦃ lang₂ ⦄ ⦃ VSP₂ ⦄)) -- -- -- The inverse of an invertible linear mapping is a linear mapping -- postulate linear-inverse : ∀{f} → ⦃ _ : Bijective(f) ⦄ → LinearMap₁₂(f) → LinearMap₂₁(inv(f)) -- -- -- Injectivity for only the zero vector implies injectivity -- postulate injective-zero : ∀{f} → ⦃ _ : LinearMap₁₂(f) ⦄ → (∀{v} → (f(v) ≡ 𝟎ᵥ ⦃ lang₂ ⦄ ⦃ VSP₂ ⦄) → (v ≡ 𝟎ᵥ ⦃ lang ⦄ ⦃ VSP ⦄)) → Injective(f) -- -- -- module _ {_∙₁_ : V → V → S}{_≤₁_} {_∙₂_ : V₂ → V₂ → S}{_≤₂_} (DPSP₁ : DotProductSpace(_∙₁_)(_≤₁_)) (DPSP₂ : DotProductSpace(_∙₂_)(_≤₂_)) where -- -- Adjoint : (f : V → V₂) → ⦃ _ : LinearMap₁₂(f) ⦄ → (g : V₂ → V) → ⦃ _ : LinearMap₂₁(g) ⦄ → Stmt -- -- Adjoint(f)(g) = (∀{v₁ : V}{v₂ : V₂} → (f(v₁) ∙₂ v₂ ≡ v₁ ∙₁ g(v₂)))
{ "alphanum_fraction": 0.6170468187, "avg_line_length": 52.280334728, "ext": "agda", "hexsha": "bc1bca8792ca3dc6eb2cc115a3094cc1c02f8b1b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "old/Structure/LinearAlgebra.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "old/Structure/LinearAlgebra.agda", "max_line_length": 279, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "old/Structure/LinearAlgebra.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": 4593, "size": 12495 }
{-# OPTIONS --universe-polymorphism #-} open import Categories.Category module Categories.Pullback {o ℓ e} (C : Category o ℓ e) where open Category C open import Level record Pullback {X Y Z}(f : X ⇒ Z)(g : Y ⇒ Z) : Set (o ⊔ ℓ ⊔ e) where field P : Obj p₁ : P ⇒ X p₂ : P ⇒ Y field .commutes : f ∘ p₁ ≡ g ∘ p₂ universal : ∀ {Q}(q₁ : Q ⇒ X)(q₂ : Q ⇒ Y) → .(commutes : (f ∘ q₁ ≡ g ∘ q₂)) → (Q ⇒ P) .universal-unique : ∀ {Q} {q₁ : Q ⇒ X} {q₂ : Q ⇒ Y} .{commutes : f ∘ q₁ ≡ g ∘ q₂} (u : Q ⇒ P) .(p₁∘u≡q₁ : p₁ ∘ u ≡ q₁) .(p₂∘u≡q₂ : p₂ ∘ u ≡ q₂) → u ≡ universal q₁ q₂ commutes .p₁∘universal≡q₁ : ∀ {Q} {q₁ : Q ⇒ X} {q₂ : Q ⇒ Y} .{commutes : f ∘ q₁ ≡ g ∘ q₂} → (p₁ ∘ universal q₁ q₂ commutes ≡ q₁) .p₂∘universal≡q₂ : ∀ {Q} {q₁ : Q ⇒ X} {q₂ : Q ⇒ Y} .{commutes : f ∘ q₁ ≡ g ∘ q₂} → (p₂ ∘ universal q₁ q₂ commutes ≡ q₂) glue : ∀ {W X Y Z : Obj} {f0 : W ⇒ X}{f : X ⇒ Z}{g : Y ⇒ Z} → (p : Pullback f g) → Pullback f0 (Pullback.p₁ p) → Pullback (f ∘ f0) g glue {f0 = f0} {f} {g} R L = record { P = L.P; p₁ = L.p₁; p₂ = R.p₂ ∘ L.p₂; commutes = begin (f ∘ f0) ∘ L.p₁ ↓⟨ assoc ⟩ f ∘ f0 ∘ L.p₁ ↓⟨ ∘-resp-≡ʳ L.commutes ⟩ f ∘ R.p₁ ∘ L.p₂ ↑⟨ assoc ⟩ (f ∘ R.p₁) ∘ L.p₂ ↓⟨ ∘-resp-≡ˡ R.commutes ⟩ (g ∘ R.p₂) ∘ L.p₂ ↓⟨ assoc ⟩ g ∘ R.p₂ ∘ L.p₂ ∎; universal = λ q₁ q₂ commutes → L.universal q₁ (R.universal (f0 ∘ q₁) q₂ (Equiv.trans (Equiv.sym assoc) commutes)) (Equiv.sym R.p₁∘universal≡q₁); universal-unique = λ {Q} {q₁} u p₁∘u≡q₁ p₂∘u≡q₂ → L.universal-unique u p₁∘u≡q₁ (R.universal-unique (L.p₂ ∘ u) (begin R.p₁ ∘ L.p₂ ∘ u ↑⟨ assoc ⟩ (R.p₁ ∘ L.p₂) ∘ u ↑⟨ ∘-resp-≡ˡ L.commutes ⟩ (f0 ∘ L.p₁) ∘ u ↓⟨ assoc ⟩ f0 ∘ L.p₁ ∘ u ↓⟨ ∘-resp-≡ʳ p₁∘u≡q₁ ⟩ f0 ∘ q₁ ∎) (Equiv.trans (Equiv.sym assoc) p₂∘u≡q₂)); p₁∘universal≡q₁ = L.p₁∘universal≡q₁; p₂∘universal≡q₂ = Equiv.trans assoc (Equiv.trans (∘-resp-≡ʳ L.p₂∘universal≡q₂) R.p₂∘universal≡q₂) } where module L = Pullback L module R = Pullback R open HomReasoning
{ "alphanum_fraction": 0.3344969851, "avg_line_length": 47.0298507463, "ext": "agda", "hexsha": "e5c6e7039d19d5533c6650b4e3a50027348e75b9", "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/Pullback.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/Pullback.agda", "max_line_length": 136, "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/Pullback.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": 1056, "size": 3151 }
module Issue2641.Import where open import Agda.Builtin.Nat five : Nat five = 5
{ "alphanum_fraction": 0.756097561, "avg_line_length": 10.25, "ext": "agda", "hexsha": "d8236871439a5cce045efdcba9a9f559eda830fa", "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/Issue2641/Import.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/Issue2641/Import.agda", "max_line_length": 29, "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/Issue2641/Import.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": 26, "size": 82 }
{-# OPTIONS --safe --warning=error #-} open import Sets.EquivalenceRelations open import Functions.Definition open import Agda.Primitive using (Level; lzero; lsuc; _⊔_; Setω) open import Setoids.Setoids open import Groups.Definition open import LogicalFormulae open import Orders.WellFounded.Definition open import Numbers.Naturals.Semiring open import Groups.Lemmas open import Groups.Homomorphisms.Definition open import Groups.Homomorphisms.Lemmas module Groups.FreeProduct.UniversalProperty {i : _} {I : Set i} (decidableIndex : (x y : I) → ((x ≡ y) || ((x ≡ y) → False))) {a b : _} {A : I → Set a} {S : (i : I) → Setoid {a} {b} (A i)} {_+_ : (i : I) → (A i) → (A i) → A i} (decidableGroups : (i : I) → (x y : A i) → ((Setoid._∼_ (S i) x y)) || ((Setoid._∼_ (S i) x y) → False)) (G : (i : I) → Group (S i) (_+_ i)) where open import Groups.FreeProduct.Definition decidableIndex decidableGroups G open import Groups.FreeProduct.Setoid decidableIndex decidableGroups G open import Groups.FreeProduct.Addition decidableIndex decidableGroups G open import Groups.FreeProduct.Group decidableIndex decidableGroups G private universalPropertyFunction' : {c d : _} {C : Set c} {T : Setoid {c} {d} C} {_+_ : C → C → C} (H : Group T _+_) → (fs : (i : I) → (A i → C)) → (homs : (i : I) → GroupHom (G i) H (fs i)) → {i : I} → ReducedSequenceBeginningWith i → C universalPropertyFunction' {_+_ = _+_} H fs homs {i} (ofEmpty .i g nonZero) = fs i g universalPropertyFunction' {_+_ = _+_} H fs homs {i} (prependLetter .i g nonZero x x₁) = (fs i g) + universalPropertyFunction' H fs homs x universalPropertyFunction : {c d : _} {C : Set c} {T : Setoid {c} {d} C} {_+_ : C → C → C} (H : Group T _+_) → (fs : (i : I) → (A i → C)) → (homs : (i : I) → GroupHom (G i) H (fs i)) → ReducedSequence → C universalPropertyFunction H fs homs empty = Group.0G H universalPropertyFunction H fs homs (nonempty i x) = universalPropertyFunction' H fs homs x private upWellDefined' : {c d : _} {C : Set c} {T : Setoid {c} {d} C} {_+_ : C → C → C} (H : Group T _+_) → (fs : (i : I) → (A i → C)) → (homs : (i : I) → GroupHom (G i) H (fs i)) → {m n : I} → (x : ReducedSequenceBeginningWith m) (y : ReducedSequenceBeginningWith n) → (eq : =RP' x y) → Setoid._∼_ T (universalPropertyFunction H fs homs (nonempty m x)) (universalPropertyFunction H fs homs (nonempty n y)) upWellDefined' H fs homs (ofEmpty m g nonZero) (ofEmpty n g₁ nonZero₁) eq with decidableIndex m n ... | inl refl = GroupHom.wellDefined (homs m) eq upWellDefined' H fs homs (prependLetter m g nonZero x x₁) (prependLetter n g₁ nonZero₁ y x₂) eq with decidableIndex m n ... | inl refl = Group.+WellDefined H (GroupHom.wellDefined (homs m) (_&&_.fst eq)) (upWellDefined' H fs homs x y (_&&_.snd eq)) upWellDefined : {c d : _} {C : Set c} {T : Setoid {c} {d} C} {_+_ : C → C → C} (H : Group T _+_) → (fs : (i : I) → (A i → C)) → (homs : (i : I) → GroupHom (G i) H (fs i)) → (x : ReducedSequence) (y : ReducedSequence) → (eq : _=RP_ x y) → Setoid._∼_ T (universalPropertyFunction H fs homs x) (universalPropertyFunction H fs homs y) upWellDefined {T = T} H fs homs empty empty eq = Equivalence.reflexive (Setoid.eq T) upWellDefined H fs homs (nonempty i w1) (nonempty j w2) eq = upWellDefined' H fs homs w1 w2 eq private upPrepend : {c d : _} {C : Set c} {T : Setoid {c} {d} C} {_+_ : C → C → C} (H : Group T _+_) → (fs : (i : I) → (A i → C)) → (homs : (i : I) → GroupHom (G i) H (fs i)) → {j : I} (y : ReducedSequence) → (g : A j) .(pr : _) → Setoid._∼_ T (universalPropertyFunction H fs homs (prepend j g pr y)) ((fs j g) + universalPropertyFunction H fs homs y) upPrepend {T = T} H fs homs empty g pr = Equivalence.symmetric (Setoid.eq T) (Group.identRight H) upPrepend {T = T} H fs homs {j} (nonempty i (ofEmpty .i h nonZero)) g pr with decidableIndex j i ... | inr j!=i = Equivalence.reflexive (Setoid.eq T) ... | inl refl with decidableGroups j ((j + g) h) (Group.0G (G j)) ... | inl x = Equivalence.transitive (Setoid.eq T) (Equivalence.symmetric (Setoid.eq T) (imageOfIdentityIsIdentity (homs j))) (Equivalence.transitive (Setoid.eq T) (Equivalence.symmetric (Setoid.eq T) (GroupHom.wellDefined (homs j) x)) (GroupHom.groupHom (homs j))) ... | inr x = GroupHom.groupHom (homs j) upPrepend {T = T} H fs homs {j} (nonempty k (prependLetter .k h nonZero y _)) g pr with decidableIndex j k ... | inr j!=k = Equivalence.reflexive (Setoid.eq T) ... | inl refl with decidableGroups j ((j + g) h) (Group.0G (G j)) ... | inl x = transitive (symmetric (Group.identLeft H)) (transitive (Group.+WellDefined H (transitive (symmetric (imageOfIdentityIsIdentity (homs k))) (transitive (GroupHom.wellDefined (homs k) (Equivalence.symmetric (Setoid.eq (S k)) x)) (GroupHom.groupHom (homs k)))) reflexive) (symmetric (Group.+Associative H))) where open Setoid T open Equivalence eq ... | inr x = transitive (Group.+WellDefined H (GroupHom.groupHom (homs k)) reflexive) (symmetric (Group.+Associative H)) where open Setoid T open Equivalence eq private upHom : {c d : _} {C : Set c} {T : Setoid {c} {d} C} {_+_ : C → C → C} (H : Group T _+_) → (fs : (i : I) → (A i → C)) → (homs : (i : I) → GroupHom (G i) H (fs i)) → {i : I} (x : ReducedSequenceBeginningWith i) (y : ReducedSequence) → Setoid._∼_ T (universalPropertyFunction H fs homs (plus' x y)) (universalPropertyFunction' H fs homs x + universalPropertyFunction H fs homs y) upHom {T = T} H fs homs (ofEmpty _ g nonZero) empty = Equivalence.symmetric (Setoid.eq T) (Group.identRight H) upHom {T = T} H fs homs (ofEmpty j g nonZero) (nonempty i (ofEmpty .i h nonZero1)) with decidableIndex j i ... | inr j!=i = Equivalence.reflexive (Setoid.eq T) ... | inl refl with decidableGroups j ((j + g) h) (Group.0G (G j)) ... | inl x = Equivalence.transitive (Setoid.eq T) (Equivalence.symmetric (Setoid.eq T) (imageOfIdentityIsIdentity (homs j))) (Equivalence.transitive (Setoid.eq T) (Equivalence.symmetric (Setoid.eq T) (GroupHom.wellDefined (homs j) x)) (GroupHom.groupHom (homs j))) ... | inr x = GroupHom.groupHom (homs j) upHom {T = T} H fs homs (ofEmpty j g nonZero) (nonempty i (prependLetter .i h nonZero1 x x₁)) with decidableIndex j i ... | inr j!=i = Equivalence.reflexive (Setoid.eq T) ... | inl refl with decidableGroups j ((j + g) h) (Group.0G (G j)) ... | inr _ = Equivalence.transitive (Setoid.eq T) (Group.+WellDefined H (GroupHom.groupHom (homs j)) (Equivalence.reflexive (Setoid.eq T))) (Equivalence.symmetric (Setoid.eq T) (Group.+Associative H)) ... | inl eq1 = Equivalence.transitive (Setoid.eq T) (Equivalence.symmetric (Setoid.eq T) (Group.identLeft H)) (Equivalence.transitive (Setoid.eq T) (Group.+WellDefined H (Equivalence.transitive (Setoid.eq T) (Equivalence.symmetric (Setoid.eq T) (imageOfIdentityIsIdentity (homs j))) (Equivalence.transitive (Setoid.eq T) (GroupHom.wellDefined (homs j) (Equivalence.symmetric (Setoid.eq (S j)) eq1)) (GroupHom.groupHom (homs j)))) (Equivalence.reflexive (Setoid.eq T))) (Equivalence.symmetric (Setoid.eq T) (Group.+Associative H))) upHom {T = T} H fs homs (prependLetter j g nonZero {k} w k!=j) empty = Equivalence.transitive (Setoid.eq T) (Equivalence.transitive (Setoid.eq T) (upWellDefined H fs homs (plus' (prependLetter j g _ w k!=j) empty) (prepend j g _ (nonempty k w)) (prependWD' g nonZero (plus' w empty) (nonempty k w) (plusEmptyRight w))) (upPrepend H fs homs (nonempty k w) g nonZero)) (Equivalence.symmetric (Setoid.eq T) (Group.identRight H)) upHom {T = T} H fs homs (prependLetter j g nonZero {k} m k!=j) (nonempty i x2) = transitive (upPrepend H fs homs (plus' m (nonempty i x2)) g nonZero) (transitive (Group.+WellDefined H reflexive (upHom H fs homs m (nonempty i x2))) (Group.+Associative H)) where open Setoid T open Equivalence eq universalPropertyHom : {c d : _} {C : Set c} {T : Setoid {c} {d} C} {_+_ : C → C → C} (H : Group T _+_) → (fs : (i : I) → (A i → C)) → (homs : (i : I) → GroupHom (G i) H (fs i)) → GroupHom FreeProductGroup H (universalPropertyFunction H fs homs) GroupHom.wellDefined (universalPropertyHom {T = T} H fs homs) {x} {y} eq = upWellDefined H fs homs x y eq GroupHom.groupHom (universalPropertyHom {T = T} H fs homs) {empty} {y} = Equivalence.symmetric (Setoid.eq T) (Group.identLeft H) GroupHom.groupHom (universalPropertyHom {T = T} H fs homs) {nonempty i x} {empty} = transitive (upWellDefined H fs homs (nonempty i x +RP empty) (nonempty i x) (plusEmptyRight x)) (symmetric (Group.identRight H)) where open Setoid T open Equivalence eq GroupHom.groupHom (universalPropertyHom H fs homs) {nonempty i x} {nonempty j y} = upHom H fs homs x (nonempty j y) universalPropertyFunctionHasProperty : {c d : _} {C : Set c} {T : Setoid {c} {d} C} {_+_ : C → C → C} (H : Group T _+_) → (fs : (i : I) → (A i → C)) → (homs : (i : I) → GroupHom (G i) H (fs i)) → {i : I} → (g : A i) → (nz : (Setoid._∼_ (S i) g (Group.0G (G i))) → False) → Setoid._∼_ T (fs i g) (universalPropertyFunction H fs homs (injection g nz)) universalPropertyFunctionHasProperty {T = T} H fs homs g nz = Equivalence.reflexive (Setoid.eq T) private universalPropertyFunctionUniquelyHasPropertyLemma : {c d : _} {C : Set c} {T : Setoid {c} {d} C} {_+_ : C → C → C} (H : Group T _+_) → (fs : (i : I) → (A i → C)) → (homs : (i : I) → GroupHom (G i) H (fs i)) → (otherFunction : ReducedSequence → C) → (isHom : GroupHom FreeProductGroup H otherFunction) → ({i : I} → (g : A i) → .(nz : (Setoid._∼_ (S i) g (Group.0G (G i))) → False) → Setoid._∼_ T (fs i g) (otherFunction (injection g nz))) → {k l : I} (neq : (k ≡ l) → False) (r : ReducedSequenceBeginningWith l) (g : A k) .(nz : (Setoid._∼_ (S k) g (Group.0G (G k)) → False)) → Setoid._∼_ T (otherFunction (nonempty k (prependLetter k g nz r neq))) (fs k g + universalPropertyFunction' H fs homs r) universalPropertyFunctionUniquelyHasPropertyLemma {T = T} H fs homs otherFunction hom x {k} {l} neq (ofEmpty .l g2 nonZero) g nz = transitive (GroupHom.wellDefined hom {nonempty k (prependLetter k g nz (ofEmpty l g2 nonZero) neq)} {nonempty _ (ofEmpty k g nz) +RP nonempty _ (ofEmpty l g2 nonZero)} t) (transitive (GroupHom.groupHom hom {nonempty k (ofEmpty k g nz)} {nonempty _ (ofEmpty l g2 nonZero)}) (Group.+WellDefined H (symmetric (x g nz)) (symmetric (x g2 nonZero)))) where open Setoid T open Equivalence eq t : Setoid._∼_ freeProductSetoid (nonempty k (prependLetter k g nz (ofEmpty l g2 nonZero) neq)) (prepend k g nz (nonempty l (ofEmpty l g2 nonZero))) t with decidableIndex k l ... | inl p = exFalso (neq p) ... | inr _ with decidableIndex k k ... | inr bad = exFalso (bad refl) ... | inl refl = Equivalence.reflexive (Setoid.eq (S k)) ,, =RP'reflex (ofEmpty l g2 _) universalPropertyFunctionUniquelyHasPropertyLemma {T = T} H fs homs otherFunction hom x {k} {l} neq (prependLetter .l h nonZero r pr) g nz = transitive (GroupHom.wellDefined hom {nonempty _ (prependLetter k g nz (prependLetter l h nonZero r pr) neq)} {(nonempty k (ofEmpty k g nz)) +RP (nonempty l (prependLetter l h nonZero r pr))} t) (transitive (GroupHom.groupHom hom {nonempty k (ofEmpty k g nz)} {nonempty l (prependLetter l h nonZero r pr)}) (Group.+WellDefined H (symmetric (x g nz)) (universalPropertyFunctionUniquelyHasPropertyLemma H fs homs otherFunction hom x pr r h nonZero))) where open Setoid T open Equivalence eq t : Setoid._∼_ freeProductSetoid (nonempty k (prependLetter k g nz (prependLetter l h nonZero r pr) neq)) (prepend k g nz (nonempty l (prependLetter l h nonZero r pr))) t with decidableIndex k l ... | inl bad = exFalso (neq bad) ... | inr k!=l with decidableIndex k k ... | inr bad = exFalso (bad refl) ... | inl refl with decidableIndex l l ... | inr bad = exFalso (bad refl) ... | inl refl = Equivalence.reflexive (Setoid.eq (S k)) ,, ((Equivalence.reflexive (Setoid.eq (S l))) ,, =RP'reflex r) universalPropertyFunctionUniquelyHasProperty : {c d : _} {C : Set c} {T : Setoid {c} {d} C} {_+_ : C → C → C} (H : Group T _+_) → (fs : (i : I) → (A i → C)) → (homs : (i : I) → GroupHom (G i) H (fs i)) → (otherFunction : ReducedSequence → C) → (isHom : GroupHom FreeProductGroup H otherFunction) → ({i : I} → (g : A i) → .(nz : (Setoid._∼_ (S i) g (Group.0G (G i))) → False) → Setoid._∼_ T (fs i g) (otherFunction (injection g nz))) → (r : ReducedSequence) → Setoid._∼_ T (otherFunction r) (universalPropertyFunction H fs homs r) universalPropertyFunctionUniquelyHasProperty H fs homs otherFunction hom prop empty = imageOfIdentityIsIdentity hom universalPropertyFunctionUniquelyHasProperty {T = T} H fs homs otherFunction hom prop (nonempty i (ofEmpty .i g nonZero)) = Equivalence.symmetric (Setoid.eq T) (prop g nonZero) universalPropertyFunctionUniquelyHasProperty {T = T} H fs homs otherFunction hom prop (nonempty i (prependLetter .i g nonZero {k} (ofEmpty .k g1 nonZero1) x1)) = transitive (GroupHom.wellDefined hom {_} {(nonempty i (ofEmpty i g nonZero)) +RP (nonempty k (ofEmpty k g1 nonZero1))} t) (transitive (GroupHom.groupHom hom {nonempty i (ofEmpty i g nonZero)}) (Group.+WellDefined H (symmetric (prop g nonZero)) (symmetric (prop g1 nonZero1)))) where open Setoid T open Equivalence eq t : Setoid._∼_ freeProductSetoid (nonempty i (prependLetter i g nonZero (ofEmpty k g1 nonZero1) x1)) (prepend i g nonZero (nonempty k (ofEmpty k g1 nonZero1))) t with decidableIndex i k ... | inl p = exFalso (x1 p) ... | inr _ with decidableIndex i i ... | inr bad = exFalso (bad refl) ... | inl refl = Equivalence.reflexive (Setoid.eq (S i)) ,, =RP'reflex (ofEmpty k g1 nonZero1) universalPropertyFunctionUniquelyHasProperty {T = T} H fs homs otherFunction hom prop (nonempty i (prependLetter .i g nonZero {k} (prependLetter .k g2 nonZero2 x x2) x1)) = transitive (GroupHom.wellDefined hom {nonempty i (prependLetter i g nonZero (prependLetter k g2 nonZero2 x x2) x1)} {(nonempty i (ofEmpty i g nonZero)) +RP (nonempty k (prependLetter k g2 nonZero2 x x2))} t) (transitive (GroupHom.groupHom hom {nonempty i (ofEmpty i g nonZero)} {nonempty k (prependLetter k g2 nonZero2 x x2)}) (Group.+WellDefined H (symmetric (prop g nonZero)) (universalPropertyFunctionUniquelyHasPropertyLemma H fs homs otherFunction hom prop x2 x g2 nonZero2))) where open Setoid T open Equivalence eq t : Setoid._∼_ freeProductSetoid (nonempty i (prependLetter i g nonZero (prependLetter k g2 nonZero2 x x2) x1)) (prepend i g nonZero (nonempty k (prependLetter k g2 nonZero2 x x2))) t with decidableIndex i k ... | inl x = exFalso (x1 x) ... | inr _ = =RP'reflex (prependLetter i g nonZero (prependLetter k g2 nonZero2 x x2) x1)
{ "alphanum_fraction": 0.6705355325, "avg_line_length": 105.9928057554, "ext": "agda", "hexsha": "40c4df83d1066ac02c214569c9264f5decb879a2", "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/FreeProduct/UniversalProperty.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/FreeProduct/UniversalProperty.agda", "max_line_length": 699, "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/FreeProduct/UniversalProperty.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": 5081, "size": 14733 }
{-# OPTIONS --safe -WnoSafeFlagNoCoverageCheck #-} open import Agda.Builtin.Bool open import Agda.Builtin.Equality data ⊥ : Set where {-# NON_COVERING #-} f : ∀ b → b ≡ true → ⊥ f false () bad : ⊥ bad = f true refl
{ "alphanum_fraction": 0.65, "avg_line_length": 14.6666666667, "ext": "agda", "hexsha": "9c737d0481e24f3a861a525330bf3ad5cf1c742c", "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/Issue5029-2.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/Issue5029-2.agda", "max_line_length": 50, "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/Issue5029-2.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": 70, "size": 220 }
{-# OPTIONS --without-K --safe #-} module Categories.Yoneda where -- Yoneda Lemma. In total, provides: -- * the Yoneda Embedding (called embed here) from any Category C into Presheaves C -- Worth noticing that there is no 'locally small' condition here; however, if one looks at -- the levels involved, there is indeed a raise from that of C to that of Presheaves C. -- * The traditional Yoneda lemma (yoneda-inverse) which says that for any object a of C, and -- any Presheaf F over C (where our presheaves are over Setoids), then -- Hom[ Presheaves C] (Functor.F₀ embed a , F) ≅ Functor.F₀ F a -- as Setoids. In addition, Yoneda (yoneda) also says that this isomorphism is natural in a and F. open import Level open import Function using (_$_; Inverse) -- else there's a conflict with the import below open import Function.Equality using (Π; _⟨$⟩_; cong) open import Relation.Binary using (module Setoid) import Relation.Binary.Reasoning.Setoid as SetoidR open import Data.Product using (_,_; Σ) open import Categories.Category using (Category; _[_,_]) open import Categories.Category.Product open import Categories.Category.Construction.Presheaves open import Categories.Category.Construction.Functors open import Categories.Category.Instance.Setoids open import Categories.Functor renaming (id to idF) open import Categories.Functor.Hom using (module Hom; Hom[_][-,_]; Hom[_][-,-]) open import Categories.Functor.Bifunctor open import Categories.Functor.Presheaf open import Categories.Functor.Construction.LiftSetoids open import Categories.NaturalTransformation using (NaturalTransformation; ntHelper) renaming (id to idN) open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism) import Categories.Morphism as Mor import Categories.Morphism.Reasoning as MR import Categories.NaturalTransformation.Hom as NT-Hom private variable o ℓ e : Level module Yoneda (C : Category o ℓ e) where open Category C open HomReasoning open MR C open Functor open NaturalTransformation open NT-Hom C private module CE = Category.Equiv C module C = Category C -- The Yoneda embedding functor embed : Functor C (Presheaves C) embed = record { F₀ = Hom[ C ][-,_] ; F₁ = Hom[A,C]⇒Hom[B,C] -- A⇒B induces a NatTrans on the Homs. ; identity = identityˡ ○_ ; homomorphism = λ h₁≈h₂ → ∘-resp-≈ʳ h₁≈h₂ ○ assoc ; F-resp-≈ = λ f≈g h≈i → ∘-resp-≈ f≈g h≈i } -- Using the adjunction between product and product, we get a kind of contravariant Bifunctor yoneda-inverse : (a : Obj) (F : Presheaf C (Setoids ℓ e)) → Inverse (Category.hom-setoid (Presheaves C) {Functor.F₀ embed a} {F}) (Functor.F₀ F a) yoneda-inverse a F = record { f = λ nat → η nat a ⟨$⟩ id ; f⁻¹ = λ x → ntHelper record { η = λ X → record { _⟨$⟩_ = λ X⇒a → F₁ F X⇒a ⟨$⟩ x ; cong = λ i≈j → F-resp-≈ F i≈j SE.refl } ; commute = λ {X} {Y} Y⇒X {f} {g} f≈g → let module SFY = Setoid (F₀ F Y) in let module SR = SetoidR (F₀ F Y) in SR.begin F₁ F (id ∘ f ∘ Y⇒X) ⟨$⟩ x SR.≈⟨ F-resp-≈ F (identityˡ ○ ∘-resp-≈ˡ f≈g) (SE.refl {x}) ⟩ F₁ F (g ∘ Y⇒X) ⟨$⟩ x SR.≈⟨ homomorphism F SE.refl ⟩ F₁ F Y⇒X ⟨$⟩ (F₁ F g ⟨$⟩ x) SR.∎ } ; cong₁ = λ i≈j → i≈j CE.refl ; cong₂ = λ i≈j y≈z → F-resp-≈ F y≈z i≈j ; inverse = (λ Fa → identity F SE.refl) , λ nat {x} {z} z≈y → let module S = Setoid (F₀ F x) in S.trans (S.sym (commute nat z CE.refl)) (cong (η nat x) (identityˡ ○ identityˡ ○ z≈y)) } where module SE = Setoid (F₀ F a) private -- in this bifunctor, a presheaf from Presheaves C goes from C to Setoids ℓ e, -- but the over Setoids has higher level than the hom setoids. Nat[Hom[C][-,c],F] : Bifunctor (Presheaves C) (Category.op C) (Setoids _ _) Nat[Hom[C][-,c],F] = Hom[ Presheaves C ][-,-] ∘F (Functor.op embed ∘F πʳ ※ πˡ) -- in this bifunctor, it needs to go from Presheaves which maps C to Setoids ℓ e, -- so the universe level needs to be lifted. FC : Bifunctor (Presheaves C) (Category.op C) (Setoids _ _) FC = LiftSetoids (o ⊔ ℓ ⊔ e) (o ⊔ ℓ) ∘F eval {C = Category.op C} {D = Setoids ℓ e} module yoneda-inverse {a} {F} = Inverse (yoneda-inverse a F) -- the two bifunctors above are naturally isomorphic. -- it is easy to show yoneda-inverse first then to yoneda. yoneda : NaturalIsomorphism Nat[Hom[C][-,c],F] FC yoneda = record { F⇒G = ntHelper record { η = λ where (F , A) → record { _⟨$⟩_ = λ α → lift (yoneda-inverse.f α) ; cong = λ i≈j → lift (i≈j CE.refl) } ; commute = λ where {_} {G , B} (α , f) {β} {γ} β≈γ → lift $ cong (η α B) (helper f β γ β≈γ) } ; F⇐G = ntHelper record { η = λ where (F , A) → record { _⟨$⟩_ = λ where (lift x) → yoneda-inverse.f⁻¹ x ; cong = λ where (lift i≈j) y≈z → F-resp-≈ F y≈z i≈j } ; commute = λ where (α , f) (lift eq) eq′ → helper′ α f eq eq′ } ; iso = λ where (F , A) → record { isoˡ = λ {α β} i≈j {X} y≈z → let module S = Setoid (F₀ F X) in S.trans ( yoneda-inverse.inverseʳ α {x = X} y≈z) (i≈j CE.refl) ; isoʳ = λ where (lift eq) → let module S = Setoid (F₀ F A) in lift (S.trans ( yoneda-inverse.inverseˡ {F = F} _) eq) } } where helper : ∀ {F : Functor (Category.op C) (Setoids ℓ e)} {A B : Obj} (f : B ⇒ A) (β γ : NaturalTransformation Hom[ C ][-, A ] F) → Setoid._≈_ (F₀ Nat[Hom[C][-,c],F] (F , A)) β γ → Setoid._≈_ (F₀ F B) (η β B ⟨$⟩ f ∘ id) (F₁ F f ⟨$⟩ (η γ A ⟨$⟩ id)) helper {F} {A} {B} f β γ β≈γ = S.begin η β B ⟨$⟩ f ∘ id S.≈⟨ cong (η β B) (id-comm ○ (⟺ identityˡ)) ⟩ η β B ⟨$⟩ id ∘ id ∘ f S.≈⟨ commute β f CE.refl ⟩ F₁ F f ⟨$⟩ (η β A ⟨$⟩ id) S.≈⟨ cong (F₁ F f) (β≈γ CE.refl) ⟩ F₁ F f ⟨$⟩ (η γ A ⟨$⟩ id) S.∎ where module S where open Setoid (F₀ F B) public open SetoidR (F₀ F B) public helper′ : ∀ {F G : Functor (Category.op C) (Setoids ℓ e)} {A B Z : Obj} {h i : Z ⇒ B} {X Y : Setoid.Carrier (F₀ F A)} (α : NaturalTransformation F G) (f : B ⇒ A) → Setoid._≈_ (F₀ F A) X Y → h ≈ i → Setoid._≈_ (F₀ G Z) (F₁ G h ⟨$⟩ (η α B ⟨$⟩ (F₁ F f ⟨$⟩ X))) (η α Z ⟨$⟩ (F₁ F (f ∘ i) ⟨$⟩ Y)) helper′ {F} {G} {A} {B} {Z} {h} {i} {X} {Y} α f eq eq′ = S.begin F₁ G h ⟨$⟩ (η α B ⟨$⟩ (F₁ F f ⟨$⟩ X)) S.≈˘⟨ commute α h (S′.sym (cong (F₁ F f) eq)) ⟩ η α Z ⟨$⟩ (F₁ F h ⟨$⟩ (F₁ F f ⟨$⟩ Y)) S.≈⟨ cong (η α Z) (F-resp-≈ F eq′ S′.refl) ⟩ η α Z ⟨$⟩ (F₁ F i ⟨$⟩ (F₁ F f ⟨$⟩ Y)) S.≈˘⟨ cong (η α Z) (homomorphism F (Setoid.refl (F₀ F A))) ⟩ η α Z ⟨$⟩ (F₁ F (f ∘ i) ⟨$⟩ Y) S.∎ where module S where open Setoid (F₀ G Z) public open SetoidR (F₀ G Z) public module S′ = Setoid (F₀ F B) module yoneda = NaturalIsomorphism yoneda
{ "alphanum_fraction": 0.5413453869, "avg_line_length": 43.7325581395, "ext": "agda", "hexsha": "cb43bef5b1b2ed07e5c6f3a7649d243ad431013b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Yoneda.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Yoneda.agda", "max_line_length": 110, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Yoneda.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2694, "size": 7522 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.ZCohomology.MayerVietorisUnreduced where open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.Properties open import Cubical.ZCohomology.KcompPrelims open import Cubical.Foundations.HLevels open import Cubical.Foundations.Function open import Cubical.Foundations.Prelude open import Cubical.Foundations.Structure open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws open import Cubical.Data.Sigma open import Cubical.HITs.Pushout open import Cubical.HITs.Sn open import Cubical.HITs.S1 open import Cubical.HITs.Susp open import Cubical.HITs.SetTruncation renaming (rec to sRec ; rec2 to sRec2 ; elim to sElim ; elim2 to sElim2) open import Cubical.HITs.PropositionalTruncation renaming (rec to pRec ; elim to pElim ; elim2 to pElim2 ; ∥_∥ to ∥_∥₁ ; ∣_∣ to ∣_∣₁) open import Cubical.Data.Nat open import Cubical.Data.Prod hiding (_×_) open import Cubical.Algebra.Group open import Cubical.HITs.Truncation renaming (elim to trElim ; map to trMap ; rec to trRec ; elim3 to trElim3) open GroupHom module MV {ℓ ℓ' ℓ''} (A : Type ℓ) (B : Type ℓ') (C : Type ℓ'') (f : C → A) (g : C → B) where -- Proof from Brunerie 2016. -- We first define the three morphisms involved: i, Δ and d. private i* : (n : ℕ) → coHom n (Pushout f g) → coHom n A × coHom n B i* _ = sRec (isSet× setTruncIsSet setTruncIsSet) λ δ → ∣ (λ x → δ (inl x)) ∣₂ , ∣ (λ x → δ (inr x)) ∣₂ iIsHom : (n : ℕ) → isGroupHom (coHomGr n (Pushout f g)) (×coHomGr n A B) (i* n) iIsHom _ = sElim2 (λ _ _ → isOfHLevelPath 2 (isSet× setTruncIsSet setTruncIsSet) _ _) λ _ _ → refl i : (n : ℕ) → GroupHom (coHomGr n (Pushout f g)) (×coHomGr n A B) GroupHom.fun (i n) = i* n GroupHom.isHom (i n) = iIsHom n private distrLem : (n : ℕ) (x y z w : coHomK n) → (x +[ n ]ₖ y) -[ n ]ₖ (z +[ n ]ₖ w) ≡ (x -[ n ]ₖ z) +[ n ]ₖ (y -[ n ]ₖ w) distrLem n x y z w = cong (ΩKn+1→Kn n) (cong₂ (λ q p → q ∙ sym p) (+ₖ→∙ n x y) (+ₖ→∙ n z w) ∙∙ cong ((Kn→ΩKn+1 n x ∙ Kn→ΩKn+1 n y) ∙_) (symDistr (Kn→ΩKn+1 n z) (Kn→ΩKn+1 n w)) ∙∙ ((sym (assoc (Kn→ΩKn+1 n x) (Kn→ΩKn+1 n y) _)) ∙∙ cong (Kn→ΩKn+1 n x ∙_) (assoc (Kn→ΩKn+1 n y) (sym (Kn→ΩKn+1 n w)) (sym (Kn→ΩKn+1 n z))) ∙∙ (cong (Kn→ΩKn+1 n x ∙_) (isCommΩK (suc n) _ _) ∙∙ assoc _ _ _ ∙∙ cong₂ _∙_ (sym (Iso.rightInv (Iso-Kn-ΩKn+1 n) (Kn→ΩKn+1 n x ∙ sym (Kn→ΩKn+1 n z)))) (sym (Iso.rightInv (Iso-Kn-ΩKn+1 n) (Kn→ΩKn+1 n y ∙ sym (Kn→ΩKn+1 n w))))))) Δ' : (n : ℕ) → ⟨ ×coHomGr n A B ⟩ → ⟨ coHomGr n C ⟩ Δ' n (α , β) = coHomFun n f α -[ n ]ₕ coHomFun n g β Δ'-isMorph : (n : ℕ) → isGroupHom (×coHomGr n A B) (coHomGr n C) (Δ' n) Δ'-isMorph n = prodElim2 (λ _ _ → isOfHLevelPath 2 setTruncIsSet _ _ ) λ f' x1 g' x2 i → ∣ (λ x → distrLem n (f' (f x)) (g' (f x)) (x1 (g x)) (x2 (g x)) i) ∣₂ Δ : (n : ℕ) → GroupHom (×coHomGr n A B) (coHomGr n C) GroupHom.fun (Δ n) = Δ' n GroupHom.isHom (Δ n) = Δ'-isMorph n d-pre : (n : ℕ) → (C → coHomK n) → Pushout f g → coHomK (suc n) d-pre n γ (inl x) = 0ₖ (suc n) d-pre n γ (inr x) = 0ₖ (suc n) d-pre zero γ (push a i) = Kn→ΩKn+1 zero (γ a) i d-pre (suc n) γ (push a i) = Kn→ΩKn+1 (suc n) (γ a) i dHomHelperPath : (n : ℕ) (h l : C → coHomK n) (a : C) → I → I → coHomK (suc n) dHomHelperPath zero h l a i j = hcomp (λ k → λ { (i = i0) → lUnitₖ 1 (0ₖ 1) (~ j) ; (i = i1) → lUnitₖ 1 (0ₖ 1) (~ j) ; (j = i0) → +ₖ→∙ 0 (h a) (l a) (~ k) i ; (j = i1) → cong₂Funct (λ x y → x +[ 1 ]ₖ y) (Kn→ΩKn+1 0 (h a)) (Kn→ΩKn+1 0 (l a)) (~ k) i}) (bottom i j) where bottom : I → I → coHomK 1 bottom i j = hcomp (λ k → λ { (i = i0) → lUnitₖ 1 (0ₖ 1) (~ j) ; (i = i1) → lUnitₖ 1 (Kn→ΩKn+1 0 (l a) k) (~ j) }) (anotherbottom i j) where anotherbottom : I → I → coHomK 1 anotherbottom i j = hcomp (λ k → λ { (i = i0) → rUnitlUnit0 1 k (~ j) ; (i = i1) → rUnitlUnit0 1 k (~ j) ; (j = i0) → Kn→ΩKn+1 0 (h a) i ; (j = i1) → Kn→ΩKn+1 0 (h a) i +[ 1 ]ₖ 0ₖ 1 }) (rUnitₖ 1 (Kn→ΩKn+1 0 (h a) i) (~ j)) dHomHelperPath (suc n) h l a i j = hcomp (λ k → λ { (i = i0) → lUnitₖ (2 + n) (0ₖ (2 + n)) (~ j) ; (i = i1) → lUnitₖ (2 + n) (0ₖ (2 + n)) (~ j) ; (j = i0) → +ₖ→∙ (suc n) (h a) (l a) (~ k) i ; (j = i1) → cong₂Funct (λ x y → x +[ 2 + n ]ₖ y) (Kn→ΩKn+1 (suc n) (h a)) (Kn→ΩKn+1 (suc n) (l a)) (~ k) i}) (bottom i j) where bottom : I → I → coHomK (2 + n) bottom i j = hcomp (λ k → λ { (i = i0) → lUnitₖ (2 + n) (0ₖ (2 + n)) (~ j) ; (i = i1) → lUnitₖ (2 + n) (Kn→ΩKn+1 (suc n) (l a) k) (~ j) }) (anotherbottom i j) where anotherbottom : I → I → coHomK (2 + n) anotherbottom i j = hcomp (λ k → λ { (i = i0) → rUnitlUnit0 (2 + n) k (~ j) ; (i = i1) → rUnitlUnit0 (2 + n) k (~ j) ; (j = i0) → Kn→ΩKn+1 (suc n) (h a) i ; (j = i1) → Kn→ΩKn+1 (suc n) (h a) i +[ 2 + n ]ₖ (0ₖ (2 + n)) }) (rUnitₖ (2 + n) (Kn→ΩKn+1 (suc n) (h a) i) (~ j)) dHomHelper : (n : ℕ) (h l : C → coHomK n) (x : Pushout f g) → d-pre n (λ x → h x +[ n ]ₖ l x) x ≡ d-pre n h x +[ suc n ]ₖ d-pre n l x dHomHelper n h l (inl x) = sym (lUnitₖ (suc n) (0ₖ (suc n))) dHomHelper n h l (inr x) = sym (lUnitₖ (suc n) (0ₖ (suc n))) dHomHelper zero h l (push a i) j = dHomHelperPath zero h l a i j dHomHelper (suc n) h l (push a i) j = dHomHelperPath (suc n) h l a i j dIsHom : (n : ℕ) → isGroupHom (coHomGr n C) (coHomGr (suc n) (Pushout f g)) (sRec setTruncIsSet λ a → ∣ d-pre n a ∣₂) dIsHom zero = sElim2 (λ _ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ f g i → ∣ funExt (λ x → dHomHelper zero f g x) i ∣₂ dIsHom (suc n) = sElim2 (λ _ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ f g i → ∣ funExt (λ x → dHomHelper (suc n) f g x) i ∣₂ d : (n : ℕ) → GroupHom (coHomGr n C) (coHomGr (suc n) (Pushout f g)) GroupHom.fun (d n) = sRec setTruncIsSet λ a → ∣ d-pre n a ∣₂ GroupHom.isHom (d n) = dIsHom n -- The long exact sequence Im-d⊂Ker-i : (n : ℕ) (x : ⟨ (coHomGr (suc n) (Pushout f g)) ⟩) → isInIm (coHomGr n C) (coHomGr (suc n) (Pushout f g)) (d n) x → isInKer (coHomGr (suc n) (Pushout f g)) (×coHomGr (suc n) A B) (i (suc n)) x Im-d⊂Ker-i n = sElim (λ _ → isSetΠ λ _ → isOfHLevelPath 2 (isSet× setTruncIsSet setTruncIsSet) _ _) λ a → pRec (isOfHLevelPath' 1 (isSet× setTruncIsSet setTruncIsSet) _ _) (sigmaElim (λ _ → isOfHLevelPath 2 (isSet× setTruncIsSet setTruncIsSet) _ _) λ δ b i → sRec (isSet× setTruncIsSet setTruncIsSet) (λ δ → ∣ (λ x → δ (inl x)) ∣₂ , ∣ (λ x → δ (inr x)) ∣₂ ) (b (~ i))) Ker-i⊂Im-d : (n : ℕ) (x : ⟨ coHomGr (suc n) (Pushout f g) ⟩) → isInKer (coHomGr (suc n) (Pushout f g)) (×coHomGr (suc n) A B) (i (suc n)) x → isInIm (coHomGr n C) (coHomGr (suc n) (Pushout f g)) (d n) x Ker-i⊂Im-d zero = sElim (λ _ → isSetΠ λ _ → isProp→isSet propTruncIsProp) λ a p → pRec {A = (λ x → a (inl x)) ≡ λ _ → 0ₖ 1} (isProp→ propTruncIsProp) (λ p1 → pRec propTruncIsProp λ p2 → ∣ ∣ (λ c → ΩKn+1→Kn 0 (sym (cong (λ F → F (f c)) p1) ∙∙ cong a (push c) ∙∙ cong (λ F → F (g c)) p2)) ∣₂ , cong ∣_∣₂ (funExt (λ δ → helper a p1 p2 δ)) ∣₁) (Iso.fun PathIdTrunc₀Iso (cong fst p)) (Iso.fun PathIdTrunc₀Iso (cong snd p)) where helper : (F : (Pushout f g) → hLevelTrunc 3 (S₊ 1)) (p1 : Path (_ → hLevelTrunc 3 (S₊ 1)) (λ a₁ → F (inl a₁)) (λ _ → ∣ base ∣)) (p2 : Path (_ → hLevelTrunc 3 (S₊ 1)) (λ a₁ → F (inr a₁)) (λ _ → ∣ base ∣)) → (δ : Pushout f g) → d-pre 0 (λ c → ΩKn+1→Kn 0 ((λ i₁ → p1 (~ i₁) (f c)) ∙∙ cong F (push c) ∙∙ cong (λ F → F (g c)) p2)) δ ≡ F δ helper F p1 p2 (inl x) = sym (cong (λ f → f x) p1) helper F p1 p2 (inr x) = sym (cong (λ f → f x) p2) helper F p1 p2 (push a i) j = hcomp (λ k → λ { (i = i0) → p1 (~ j) (f a) ; (i = i1) → p2 (~ j) (g a) ; (j = i0) → Iso.rightInv (Iso-Kn-ΩKn+1 0) ((λ i₁ → p1 (~ i₁) (f a)) ∙∙ cong F (push a) ∙∙ cong (λ F₁ → F₁ (g a)) p2) (~ k) i ; (j = i1) → F (push a i)}) (doubleCompPath-filler (sym (cong (λ F → F (f a)) p1)) (cong F (push a)) (cong (λ F → F (g a)) p2) (~ j) i) Ker-i⊂Im-d (suc n) = sElim (λ _ → isSetΠ λ _ → isProp→isSet propTruncIsProp) λ a p → pRec {A = (λ x → a (inl x)) ≡ λ _ → 0ₖ (2 + n)} (isProp→ propTruncIsProp) (λ p1 → pRec propTruncIsProp λ p2 → ∣ ∣ (λ c → ΩKn+1→Kn (suc n) (sym (cong (λ F → F (f c)) p1) ∙∙ cong a (push c) ∙∙ cong (λ F → F (g c)) p2)) ∣₂ , cong ∣_∣₂ (funExt (λ δ → helper a p1 p2 δ)) ∣₁) (Iso.fun PathIdTrunc₀Iso (cong fst p)) (Iso.fun PathIdTrunc₀Iso (cong snd p)) where helper : (F : (Pushout f g) → hLevelTrunc (4 + n) (S₊ (2 + n))) (p1 : Path (_ → hLevelTrunc (4 + n) (S₊ (2 + n))) (λ a₁ → F (inl a₁)) (λ _ → ∣ north ∣)) (p2 : Path (_ → hLevelTrunc (4 + n) (S₊ (2 + n))) (λ a₁ → F (inr a₁)) (λ _ → ∣ north ∣)) → (δ : (Pushout f g)) → d-pre (suc n) (λ c → ΩKn+1→Kn (suc n) ((λ i₁ → p1 (~ i₁) (f c)) ∙∙ cong F (push c) ∙∙ cong (λ F → F (g c)) p2)) δ ≡ F δ helper F p1 p2 (inl x) = sym (cong (λ f → f x) p1) helper F p1 p2 (inr x) = sym (cong (λ f → f x) p2) helper F p1 p2 (push a i) j = hcomp (λ k → λ { (i = i0) → p1 (~ j) (f a) ; (i = i1) → p2 (~ j) (g a) ; (j = i0) → Iso.rightInv (Iso-Kn-ΩKn+1 (suc n)) ((λ i₁ → p1 (~ i₁) (f a)) ∙∙ cong F (push a) ∙∙ cong (λ F₁ → F₁ (g a)) p2) (~ k) i ; (j = i1) → F (push a i)}) (doubleCompPath-filler (sym (cong (λ F → F (f a)) p1)) (cong F (push a)) (cong (λ F → F (g a)) p2) (~ j) i) open GroupHom Im-i⊂Ker-Δ : (n : ℕ) (x : ⟨ ×coHomGr n A B ⟩) → isInIm (coHomGr n (Pushout f g)) (×coHomGr n A B) (i n) x → isInKer (×coHomGr n A B) (coHomGr n C) (Δ n) x Im-i⊂Ker-Δ n (Fa , Fb) = sElim {B = λ Fa → (Fb : _) → isInIm (coHomGr n (Pushout f g)) (×coHomGr n A B) (i n) (Fa , Fb) → isInKer (×coHomGr n A B) (coHomGr n C) (Δ n) (Fa , Fb)} (λ _ → isSetΠ2 λ _ _ → isOfHLevelPath 2 setTruncIsSet _ _) (λ Fa → sElim (λ _ → isSetΠ λ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ Fb → pRec (setTruncIsSet _ _) (sigmaElim (λ x → isProp→isSet (setTruncIsSet _ _)) λ Fd p → helper n Fa Fb Fd p)) Fa Fb where helper : (n : ℕ) (Fa : A → coHomK n) (Fb : B → coHomK n) (Fd : (Pushout f g) → coHomK n) → (fun (i n) ∣ Fd ∣₂ ≡ (∣ Fa ∣₂ , ∣ Fb ∣₂)) → (fun (Δ n)) (∣ Fa ∣₂ , ∣ Fb ∣₂) ≡ 0ₕ n helper zero Fa Fb Fd p = cong (fun (Δ zero)) (sym p) ∙∙ (λ i → ∣ (λ x → Fd (inl (f x))) ∣₂ -[ 0 ]ₕ ∣ (λ x → Fd (push x (~ i))) ∣₂ ) ∙∙ cancelₕ 0 ∣ (λ x → Fd (inl (f x))) ∣₂ helper (suc n) Fa Fb Fd p = cong (fun (Δ (suc n))) (sym p) ∙∙ (λ i → ∣ (λ x → Fd (inl (f x))) ∣₂ -[ (suc n) ]ₕ ∣ (λ x → Fd (push x (~ i))) ∣₂) ∙∙ cancelₕ (suc n) ∣ (λ x → Fd (inl (f x))) ∣₂ Ker-Δ⊂Im-i : (n : ℕ) (a : ⟨ ×coHomGr n A B ⟩) → isInKer (×coHomGr n A B) (coHomGr n C) (Δ n) a → isInIm (coHomGr n (Pushout f g)) (×coHomGr n A B) (i n) a Ker-Δ⊂Im-i n = prodElim (λ _ → isSetΠ (λ _ → isProp→isSet propTruncIsProp)) (λ Fa Fb p → pRec propTruncIsProp (λ q → ∣ ∣ helpFun Fa Fb q ∣₂ , refl ∣₁) (helper Fa Fb p)) where helper : (Fa : A → coHomK n) (Fb : B → coHomK n) → fun (Δ n) (∣ Fa ∣₂ , ∣ Fb ∣₂) ≡ 0ₕ n → ∥ Path (_ → _) (λ c → Fa (f c)) (λ c → Fb (g c)) ∥₁ helper Fa Fb p = Iso.fun PathIdTrunc₀Iso (sym (-+cancelₕ n ∣ (λ c → Fa (f c)) ∣₂ ∣ (λ c → Fb (g c)) ∣₂) ∙∙ cong (λ x → x +[ n ]ₕ ∣ (λ c → Fb (g c)) ∣₂) p ∙∙ lUnitₕ n _) helpFun : (Fa : A → coHomK n) (Fb : B → coHomK n) → ((λ c → Fa (f c)) ≡ (λ c → Fb (g c))) → Pushout f g → coHomK n helpFun Fa Fb p (inl x) = Fa x helpFun Fa Fb p (inr x) = Fb x helpFun Fa Fb p (push a i) = p i a private distrHelper : (n : ℕ) (p q : _) → ΩKn+1→Kn n p +[ n ]ₖ (-[ n ]ₖ ΩKn+1→Kn n q) ≡ ΩKn+1→Kn n (p ∙ sym q) distrHelper n p q i = ΩKn+1→Kn n (Iso.rightInv (Iso-Kn-ΩKn+1 n) p i ∙ Iso.rightInv (Iso-Kn-ΩKn+1 n) (sym (Iso.rightInv (Iso-Kn-ΩKn+1 n) q i)) i) Ker-d⊂Im-Δ : (n : ℕ) (a : coHom n C) → isInKer (coHomGr n C) (coHomGr (suc n) (Pushout f g)) (d n) a → isInIm (×coHomGr n A B) (coHomGr n C) (Δ n) a Ker-d⊂Im-Δ zero = sElim (λ _ → isOfHLevelΠ 2 λ _ → isOfHLevelSuc 1 propTruncIsProp) λ Fc p → pRec propTruncIsProp (λ p → ∣ (∣ (λ a → ΩKn+1→Kn 0 (cong (λ f → f (inl a)) p)) ∣₂ , ∣ (λ b → ΩKn+1→Kn 0 (cong (λ f → f (inr b)) p)) ∣₂) , Iso.inv (PathIdTrunc₀Iso) ∣ funExt (λ c → helper2 Fc p c) ∣₁ ∣₁) (Iso.fun (PathIdTrunc₀Iso) p) where helper2 : (Fc : C → coHomK 0) (p : d-pre 0 Fc ≡ (λ _ → ∣ base ∣)) (c : C) → ΩKn+1→Kn 0 (λ i₁ → p i₁ (inl (f c))) -[ 0 ]ₖ (ΩKn+1→Kn 0 (λ i₁ → p i₁ (inr (g c)))) ≡ Fc c helper2 Fc p c = cong₂ (λ x y → ΩKn+1→Kn 0 (x ∙ sym y)) (Iso.rightInv (Iso-Kn-ΩKn+1 0) (λ i₁ → p i₁ (inl (f c)))) (Iso.rightInv (Iso-Kn-ΩKn+1 0) (λ i₁ → p i₁ (inr (g c)))) ∙∙ cong (ΩKn+1→Kn 0) (sym ((PathP→compPathR (cong (λ f → cong f (push c)) p)) ∙ (λ i → (λ i₁ → p i₁ (inl (f c))) ∙ (lUnit (sym (λ i₁ → p i₁ (inr (g c)))) (~ i))))) ∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 zero) (Fc c) Ker-d⊂Im-Δ (suc n) = sElim (λ _ → isOfHLevelΠ 2 λ _ → isOfHLevelSuc 1 propTruncIsProp) λ Fc p → pRec propTruncIsProp (λ p → ∣ (∣ (λ a → ΩKn+1→Kn (suc n) (cong (λ f → f (inl a)) p)) ∣₂ , ∣ (λ b → ΩKn+1→Kn (suc n) (cong (λ f → f (inr b)) p)) ∣₂) , Iso.inv (PathIdTrunc₀Iso) ∣ funExt (λ c → helper2 Fc p c) ∣₁ ∣₁) (Iso.fun (PathIdTrunc₀Iso) p) where helper2 : (Fc : C → coHomK (suc n)) (p : d-pre (suc n) Fc ≡ (λ _ → ∣ north ∣)) (c : C) → ΩKn+1→Kn (suc n) (λ i₁ → p i₁ (inl (f c))) -[ (suc n) ]ₖ (ΩKn+1→Kn (suc n) (λ i₁ → p i₁ (inr (g c)))) ≡ Fc c helper2 Fc p c = cong₂ (λ x y → ΩKn+1→Kn (suc n) (x ∙ sym y)) (Iso.rightInv (Iso-Kn-ΩKn+1 (suc n)) (λ i₁ → p i₁ (inl (f c)))) (Iso.rightInv (Iso-Kn-ΩKn+1 (suc n)) (λ i₁ → p i₁ (inr (g c)))) ∙∙ cong (ΩKn+1→Kn (suc n)) (sym ((PathP→compPathR (cong (λ f → cong f (push c)) p)) ∙ (λ i → (λ i₁ → p i₁ (inl (f c))) ∙ (lUnit (sym (λ i₁ → p i₁ (inr (g c)))) (~ i))))) ∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 (suc n)) (Fc c) Im-Δ⊂Ker-d : (n : ℕ) (a : coHom n C) → isInIm (×coHomGr n A B) (coHomGr n C) (Δ n) a → isInKer (coHomGr n C) (coHomGr (suc n) (Pushout f g)) (d n) a Im-Δ⊂Ker-d n = sElim (λ _ → isOfHLevelΠ 2 λ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ Fc → pRec (isOfHLevelPath' 1 setTruncIsSet _ _) (sigmaProdElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ Fa Fb p → pRec (isOfHLevelPath' 1 setTruncIsSet _ _) (λ q → ((λ i → fun (d n) ∣ (q (~ i)) ∣₂) ∙ dΔ-Id n Fa Fb)) (Iso.fun (PathIdTrunc₀Iso) p)) where d-preLeftId : (n : ℕ) (Fa : A → coHomK n)(d : (Pushout f g)) → d-pre n (Fa ∘ f) d ≡ 0ₖ (suc n) d-preLeftId zero Fa (inl x) = Kn→ΩKn+1 0 (Fa x) d-preLeftId (suc n) Fa (inl x) = Kn→ΩKn+1 (suc n) (Fa x) d-preLeftId zero Fa (inr x) = refl d-preLeftId (suc n) Fa (inr x) = refl d-preLeftId zero Fa (push a i) j = Kn→ΩKn+1 zero (Fa (f a)) (j ∨ i) d-preLeftId (suc n) Fa (push a i) j = Kn→ΩKn+1 (suc n) (Fa (f a)) (j ∨ i) d-preRightId : (n : ℕ) (Fb : B → coHomK n) (d : (Pushout f g)) → d-pre n (Fb ∘ g) d ≡ 0ₖ (suc n) d-preRightId n Fb (inl x) = refl d-preRightId zero Fb (inr x) = sym (Kn→ΩKn+1 0 (Fb x)) d-preRightId (suc n) Fb (inr x) = sym (Kn→ΩKn+1 (suc n) (Fb x)) d-preRightId zero Fb (push a i) j = Kn→ΩKn+1 zero (Fb (g a)) (~ j ∧ i) d-preRightId (suc n) Fb (push a i) j = Kn→ΩKn+1 (suc n) (Fb (g a)) (~ j ∧ i) dΔ-Id : (n : ℕ) (Fa : A → coHomK n) (Fb : B → coHomK n) → fun (d n) (fun (Δ n) (∣ Fa ∣₂ , ∣ Fb ∣₂)) ≡ 0ₕ (suc n) dΔ-Id zero Fa Fb = -distrLemma 0 1 (d zero) ∣ Fa ∘ f ∣₂ ∣ Fb ∘ g ∣₂ ∙∙ (λ i → ∣ (λ x → d-preLeftId zero Fa x i) ∣₂ -[ 1 ]ₕ ∣ (λ x → d-preRightId zero Fb x i) ∣₂) ∙∙ cancelₕ 1 (0ₕ 1) dΔ-Id (suc n) Fa Fb = -distrLemma (suc n) (2 + n) (d (suc n)) ∣ Fa ∘ f ∣₂ ∣ Fb ∘ g ∣₂ ∙∙ (λ i → ∣ (λ x → d-preLeftId (suc n) Fa x i) ∣₂ -[ (2 + n) ]ₕ ∣ (λ x → d-preRightId (suc n) Fb x i) ∣₂) ∙∙ cancelₕ (2 + n) (0ₕ (2 + n))
{ "alphanum_fraction": 0.4208886208, "avg_line_length": 58.1754385965, "ext": "agda", "hexsha": "5eae370bf74545bbf63dc7b70068f71f24e573c3", "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": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ayberkt/cubical", "max_forks_repo_path": "Cubical/ZCohomology/MayerVietorisUnreduced.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "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": "ayberkt/cubical", "max_issues_repo_path": "Cubical/ZCohomology/MayerVietorisUnreduced.agda", "max_line_length": 133, "max_stars_count": null, "max_stars_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ayberkt/cubical", "max_stars_repo_path": "Cubical/ZCohomology/MayerVietorisUnreduced.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 8023, "size": 19896 }
------------------------------------------------------------------------ -- The Agda standard library -- -- The basic code for equational reasoning with three relations: -- equality, strict ordering and non-strict ordering. ------------------------------------------------------------------------ -- -- See `Data.Nat.Properties` or `Relation.Binary.Reasoning.PartialOrder` -- for examples of how to instantiate this module. {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Relation.Binary.Reasoning.Base.Triple {a ℓ₁ ℓ₂ ℓ₃} {A : Set a} {_≈_ : Rel A ℓ₁} {_≤_ : Rel A ℓ₂} {_<_ : Rel A ℓ₃} (isPreorder : IsPreorder _≈_ _≤_) (<-trans : Transitive _<_) (<-resp-≈ : _<_ Respects₂ _≈_) (<⇒≤ : _<_ ⇒ _≤_) (<-≤-trans : Trans _<_ _≤_ _<_) (≤-<-trans : Trans _≤_ _<_ _<_) where open import Data.Product using (proj₁; proj₂) open import Function using (case_of_; id) open import Level using (Level; _⊔_; Lift; lift) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym) open import Relation.Nullary using (Dec; yes; no) open import Relation.Nullary.Decidable using (True; toWitness) open IsPreorder isPreorder renaming ( reflexive to ≤-reflexive ; trans to ≤-trans ; ∼-resp-≈ to ≤-resp-≈ ) ------------------------------------------------------------------------ -- A datatype to hide the current relation type data _IsRelatedTo_ (x y : A) : Set (a ⊔ ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃) where strict : (x<y : x < y) → x IsRelatedTo y nonstrict : (x≤y : x ≤ y) → x IsRelatedTo y equals : (x≈y : x ≈ y) → x IsRelatedTo y ------------------------------------------------------------------------ -- Types that are used to ensure that the final relation proved by the -- chain of reasoning can be converted into the required relation. data IsStrict {x y} : x IsRelatedTo y → Set (a ⊔ ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃) where isStrict : ∀ x<y → IsStrict (strict x<y) IsStrict? : ∀ {x y} (x≲y : x IsRelatedTo y) → Dec (IsStrict x≲y) IsStrict? (strict x<y) = yes (isStrict x<y) IsStrict? (nonstrict _) = no λ() IsStrict? (equals _) = no λ() extractStrict : ∀ {x y} {x≲y : x IsRelatedTo y} → IsStrict x≲y → x < y extractStrict (isStrict x<y) = x<y data IsEquality {x y} : x IsRelatedTo y → Set (a ⊔ ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃) where isEquality : ∀ x≈y → IsEquality (equals x≈y) IsEquality? : ∀ {x y} (x≲y : x IsRelatedTo y) → Dec (IsEquality x≲y) IsEquality? (strict _) = no λ() IsEquality? (nonstrict _) = no λ() IsEquality? (equals x≈y) = yes (isEquality x≈y) extractEquality : ∀ {x y} {x≲y : x IsRelatedTo y} → IsEquality x≲y → x ≈ y extractEquality (isEquality x≈y) = x≈y ------------------------------------------------------------------------ -- Reasoning combinators infix -1 begin_ begin-strict_ begin-equality_ infixr 0 _<⟨_⟩_ _≤⟨_⟩_ _≈⟨_⟩_ _≈˘⟨_⟩_ _≡⟨_⟩_ _≡˘⟨_⟩_ _≡⟨⟩_ infix 1 _∎ begin_ : ∀ {x y} (r : x IsRelatedTo y) → x ≤ y begin (strict x<y) = <⇒≤ x<y begin (nonstrict x≤y) = x≤y begin (equals x≈y) = ≤-reflexive x≈y begin-strict_ : ∀ {x y} (r : x IsRelatedTo y) → {s : True (IsStrict? r)} → x < y begin-strict_ r {s} = extractStrict (toWitness s) begin-equality_ : ∀ {x y} (r : x IsRelatedTo y) → {s : True (IsEquality? r)} → x ≈ y begin-equality_ r {s} = extractEquality (toWitness s) _<⟨_⟩_ : ∀ (x : A) {y z} → x < y → y IsRelatedTo z → x IsRelatedTo z x <⟨ x<y ⟩ strict y<z = strict (<-trans x<y y<z) x <⟨ x<y ⟩ nonstrict y≤z = strict (<-≤-trans x<y y≤z) x <⟨ x<y ⟩ equals y≈z = strict (proj₁ <-resp-≈ y≈z x<y) _≤⟨_⟩_ : ∀ (x : A) {y z} → x ≤ y → y IsRelatedTo z → x IsRelatedTo z x ≤⟨ x≤y ⟩ strict y<z = strict (≤-<-trans x≤y y<z) x ≤⟨ x≤y ⟩ nonstrict y≤z = nonstrict (≤-trans x≤y y≤z) x ≤⟨ x≤y ⟩ equals y≈z = nonstrict (proj₁ ≤-resp-≈ y≈z x≤y) _≈⟨_⟩_ : ∀ (x : A) {y z} → x ≈ y → y IsRelatedTo z → x IsRelatedTo z x ≈⟨ x≈y ⟩ strict y<z = strict (proj₂ <-resp-≈ (Eq.sym x≈y) y<z) x ≈⟨ x≈y ⟩ nonstrict y≤z = nonstrict (proj₂ ≤-resp-≈ (Eq.sym x≈y) y≤z) x ≈⟨ x≈y ⟩ equals y≈z = equals (Eq.trans x≈y y≈z) _≈˘⟨_⟩_ : ∀ x {y z} → y ≈ x → y IsRelatedTo z → x IsRelatedTo z x ≈˘⟨ x≈y ⟩ y∼z = x ≈⟨ Eq.sym x≈y ⟩ y∼z _≡⟨_⟩_ : ∀ (x : A) {y z} → x ≡ y → y IsRelatedTo z → x IsRelatedTo z x ≡⟨ x≡y ⟩ strict y<z = strict (case x≡y of λ where refl → y<z) x ≡⟨ x≡y ⟩ nonstrict y≤z = nonstrict (case x≡y of λ where refl → y≤z) x ≡⟨ x≡y ⟩ equals y≈z = equals (case x≡y of λ where refl → y≈z) _≡˘⟨_⟩_ : ∀ x {y z} → y ≡ x → y IsRelatedTo z → x IsRelatedTo z x ≡˘⟨ x≡y ⟩ y∼z = x ≡⟨ sym x≡y ⟩ y∼z _≡⟨⟩_ : ∀ (x : A) {y} → x IsRelatedTo y → x IsRelatedTo y x ≡⟨⟩ x≲y = x≲y _∎ : ∀ x → x IsRelatedTo x x ∎ = equals Eq.refl
{ "alphanum_fraction": 0.555410691, "avg_line_length": 38.6722689076, "ext": "agda", "hexsha": "789549e79d0e8c7a3ec11bbfab7d16cd79a1218c", "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/Base/Triple.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/Base/Triple.agda", "max_line_length": 84, "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/Base/Triple.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1880, "size": 4602 }
open import Everything module Test.Test0 where test-functor-surjidentity : ∀ {𝔬₁ 𝔯₁ ℓ₁ 𝔬₂ 𝔯₂ ℓ₂} ⦃ functor : Functor 𝔬₁ 𝔯₁ ℓ₁ 𝔬₂ 𝔯₂ ℓ₂ ⦄ (open Functor functor) → Surjidentity.type _∼₁_ _∼₂_ _∼̇₂_ functor-smap ε₁ ε₂ test-functor-surjidentity = surjidentity -- test-functor-transextensionality ⦃ functor ⦄ = let open Functor ⦃ … ⦄ in transextensionality1
{ "alphanum_fraction": 0.7044854881, "avg_line_length": 27.0714285714, "ext": "agda", "hexsha": "b80e119ec5cf55b48fdd19503aa20290f1182615", "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/Test/Test0.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/Test/Test0.agda", "max_line_length": 98, "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/Test/Test0.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 167, "size": 379 }
module tree where open import bool open import eq open import level open import list open import list-to-string open import nat open import nat-thms open import string ---------------------------------------------------------------------- -- datatype ---------------------------------------------------------------------- -- nonempty trees data 𝕋 {ℓ} (A : Set ℓ) : Set ℓ where node : A → 𝕃 (𝕋 A) → 𝕋 A ---------------------------------------------------------------------- -- tree operations ---------------------------------------------------------------------- leaf : ∀ {ℓ}{A : Set ℓ} → A → 𝕋 A leaf a = node a [] 𝕋-to-string : ∀ {ℓ}{A : Set ℓ} → (f : A → string) → (t : 𝕋 A) → string 𝕋s-to-string : ∀ {ℓ}{A : Set ℓ} → (f : A → string) → (ts : 𝕃 (𝕋 A)) → string 𝕋-to-string f (node a []) = f a 𝕋-to-string f (node a ts) = "(" ^ (f a) ^ (𝕋s-to-string f ts) ^ ")" 𝕋s-to-string f [] = "" 𝕋s-to-string f (t :: ts) = " " ^ (𝕋-to-string f t) ^ (𝕋s-to-string f ts) perfect-binary-tree : ∀ {ℓ}{A : Set ℓ} → ℕ → A → 𝕋 A perfect-binary-tree 0 a = (node a []) perfect-binary-tree (suc n) a = let t = perfect-binary-tree n a in (node a (t :: t :: [])) size𝕋 : ∀ {ℓ}{A : Set ℓ} → 𝕋 A → ℕ size𝕋s : ∀ {ℓ}{A : Set ℓ} → 𝕃 (𝕋 A) → ℕ size𝕋 (node a ts) = suc (size𝕋s ts) size𝕋s [] = 0 size𝕋s (t :: ts) = size𝕋 t + size𝕋s ts size-perfect : ∀ {ℓ}{A : Set ℓ}(n : ℕ)(a : A) → (size𝕋 (perfect-binary-tree n a)) ≡ pred (2 pow (suc n)) size-perfect 0 a = refl size-perfect (suc n) a with (size𝕋 (perfect-binary-tree n a)) | size-perfect n a ... | s | ps rewrite ps with 2 pow n | nonzero-pow 2 n refl ... | x | px rewrite +0 x with x + x | (iszerosum2 x x px) ... | x2 | q rewrite +0 x2 | +0 (pred x2) | sym (+suc (pred x2) (pred x2)) | sucpred q | pred+ x2 x2 q = refl
{ "alphanum_fraction": 0.4673731177, "avg_line_length": 35.1568627451, "ext": "agda", "hexsha": "7cca65047465e84f79ed2c893080230b44b4c345", "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": "tree.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": "tree.agda", "max_line_length": 109, "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": "tree.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": 649, "size": 1793 }
{-# OPTIONS --safe #-} module Cubical.Categories.Monad.Base where open import Cubical.Foundations.Prelude open import Cubical.Categories.Category open import Cubical.Categories.Functor renaming (𝟙⟨_⟩ to funcId) open import Cubical.Categories.NaturalTransformation.Base open import Cubical.Categories.NaturalTransformation.Properties open import Cubical.Categories.Functors.HomFunctor private variable ℓ ℓ' : Level module _ {C : Category ℓ ℓ'} (M : Functor C C) where open Category C open Functor open NatTrans IsPointed : Type (ℓ-max ℓ ℓ') IsPointed = NatTrans (funcId C) M record IsMonad : Type (ℓ-max ℓ ℓ') where field η : IsPointed μ : NatTrans (funcComp M M) M idl-μ : PathP (λ i → NatTrans (F-rUnit {F = M} i) M) (compTrans μ (η ∘ˡ M)) (idTrans M) idr-μ : PathP (λ i → NatTrans (F-lUnit {F = M} i) M) (compTrans μ (M ∘ʳ η)) (idTrans M) assoc-μ : PathP (λ i → NatTrans (F-assoc {F = M} {G = M} {H = M} i) M) (compTrans μ (M ∘ʳ μ)) (compTrans μ (μ ∘ˡ M)) -- bind : Hom[-,M-] -> Hom[M-,M-] bind : NatTrans (funcComp (HomFunctor C) ((funcId C ^opF) ×F M)) (funcComp (HomFunctor C) ((M ^opF) ×F M)) N-ob bind (x , y) f = N-ob μ y ∘ F-hom M f N-hom bind {x , y} {x' , y'} (f , h) = funExt λ g → (F-hom M ((f ⋆ g) ⋆ F-hom M h) ⋆ N-ob μ y') ≡⟨ cong (_⋆ N-ob μ y') (F-seq M (f ⋆ g) (F-hom M h)) ⟩ ((F-hom M (f ⋆ g) ⋆ F-hom M (F-hom M h)) ⋆ N-ob μ y') ≡⟨ ⋆Assoc (F-hom M (f ⋆ g)) (F-hom M (F-hom M h)) (N-ob μ y') ⟩ (F-hom M (f ⋆ g) ⋆ (F-hom M (F-hom M h) ⋆ N-ob μ y')) ≡⟨ cong (F-hom M (f ⋆ g) ⋆_) (N-hom μ h) ⟩ (F-hom M (f ⋆ g) ⋆ (N-ob μ y ⋆ F-hom M h)) ≡⟨ sym (⋆Assoc (F-hom M (f ⋆ g)) (N-ob μ y) (F-hom M h)) ⟩ ((F-hom M (f ⋆ g) ⋆ N-ob μ y) ⋆ F-hom M h) ≡⟨ cong (_⋆ F-hom M h) (cong (_⋆ N-ob μ y) (F-seq M f g)) ⟩ (((F-hom M f ⋆ F-hom M g) ⋆ N-ob μ y) ⋆ F-hom M h) ≡⟨ cong (_⋆ F-hom M h) (⋆Assoc (F-hom M f) (F-hom M g) (N-ob μ y)) ⟩ ((M .F-hom f ⋆ (F-hom M g ⋆ N-ob μ y)) ⋆ F-hom M h) ∎ -- Define comonads as monads on the opposite category? module _ (C : Category ℓ ℓ') where Monad : Type (ℓ-max ℓ ℓ') Monad = Σ[ M ∈ Functor C C ] IsMonad M module _ {C : Category ℓ ℓ'} (monadM monadN : Monad C) (ν : NatTrans (fst monadM) (fst monadN)) where private M N : Functor C C M = fst monadM N = fst monadN module M = IsMonad (snd monadM) module N = IsMonad (snd monadN) record IsMonadHom : Type (ℓ-max ℓ ℓ') where constructor proveMonadHom field N-η : compTrans ν M.η ≡ N.η N-μ : compTrans ν M.μ ≡ compTrans N.μ (whiskerTrans ν ν) open IsMonadHom isProp-IsMonadHom : isProp (IsMonadHom) N-η (isProp-IsMonadHom (proveMonadHom N-η1 N-μ1) (proveMonadHom N-η2 N-μ2) i) = isSetNatTrans _ _ N-η1 N-η2 i N-μ (isProp-IsMonadHom (proveMonadHom N-η1 N-μ1) (proveMonadHom N-η2 N-μ2) i) = isSetNatTrans _ _ N-μ1 N-μ2 i module _ {C : Category ℓ ℓ'} (monadM monadN : Monad C) where MonadHom : Type (ℓ-max ℓ ℓ') MonadHom = Σ[ ν ∈ NatTrans (fst monadM) (fst monadN) ] IsMonadHom monadM monadN ν
{ "alphanum_fraction": 0.5778347213, "avg_line_length": 39.025, "ext": "agda", "hexsha": "ab50ec14349e64ea143c752cfb4664e9275d7b4d", "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/Monad/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/Monad/Base.agda", "max_line_length": 111, "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/Monad/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": 1354, "size": 3122 }
-- Non-deterministic insert and permutation with choose oracle -- The oracle is passed through the individual functions. open import bool module even-double-eo (Choice : Set) (choose : Choice → 𝔹) (lchoice : Choice → Choice) (rchoice : Choice → Choice) where open import eq open import bool-thms open import nat open import nat-thms open import list ---------------------------------------------------------------------- -- double is deterministic: double : ℕ → ℕ double x = x + x -- even is a deterministic predicate: even : ℕ → 𝔹 even zero = tt even (suc 0) = ff even (suc (suc x)) = even x -- eo yields an even and odd number close to the input value: eo : Choice → ℕ → ℕ eo ch n = if choose ch then n else (suc n) -- auxiliary property for x+x instead of double: even-x+x : ∀ (x : ℕ) → even (x + x) ≡ tt even-x+x zero = refl even-x+x (suc x) rewrite +suc x x | even-x+x x = refl -- (even (double x)) is always true: even-double-is-true : ∀ (x : ℕ) → even (double x) ≡ tt even-double-is-true x rewrite even-x+x x = refl -- (even (double (eo n))) is always true: even-double-eo-is-true : ∀ (ch : Choice) (n : ℕ) → even (double (eo ch n)) ≡ tt even-double-eo-is-true ch n = even-double-is-true (eo ch n) ----------------------------------------------------------------------
{ "alphanum_fraction": 0.5775927328, "avg_line_length": 25.9019607843, "ext": "agda", "hexsha": "f718cb9d2be41b26fcdec9737c68e794b6e1e70e", "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": "b7cfdda11cdadeba882b6b72d75448acd8b0a294", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "mihanus/curry-agda", "max_forks_repo_path": "choices/even-double-eo.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b7cfdda11cdadeba882b6b72d75448acd8b0a294", "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": "mihanus/curry-agda", "max_issues_repo_path": "choices/even-double-eo.agda", "max_line_length": 70, "max_stars_count": null, "max_stars_repo_head_hexsha": "b7cfdda11cdadeba882b6b72d75448acd8b0a294", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "mihanus/curry-agda", "max_stars_repo_path": "choices/even-double-eo.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 366, "size": 1321 }
module _ where module G where module H where module A where module B where module C where open G public module I = A.B.C.H
{ "alphanum_fraction": 0.6666666667, "avg_line_length": 10.8461538462, "ext": "agda", "hexsha": "139b88a81521ae394d8a361da71adb80c70b0984", "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/Issue2666.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/Issue2666.agda", "max_line_length": 19, "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/Issue2666.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": 41, "size": 141 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT -- This file contains a helper module for FinSet, -- proving the finite pigeonhole principle module homotopy.Pigeonhole where {- loosely based on code by copumpkin and xplat via byorgey -} incl : ∀ {m n} (m<n : m < n) → Fin m → Fin n incl m<n (k , k<m) = k , <-trans k<m m<n incl-ne : ∀ {n} (i : Fin n) → ¬ (incl ltS i == n , ltS) incl-ne {n} (k , k<n) p = <-to-≠ k<n (ap fst p) Dec-Σ-Fin : ∀ {ℓ} {n} (P : Fin n → Type ℓ) (dec-P : (i : Fin n) → Dec (P i)) → Dec (Σ (Fin n) λ i → P i) Dec-Σ-Fin {ℓ} {O} P dec-P = inr λ z → –> Fin-equiv-Empty (fst z) Dec-Σ-Fin {ℓ} {S n} P dec-P with Dec-Σ-Fin {ℓ} {n} (P ∘ (incl ltS)) (dec-P ∘ (incl ltS)) Dec-Σ-Fin {ℓ} {S n} P dec-P | inl z = inl (incl ltS (fst z) , snd z) Dec-Σ-Fin {ℓ} {S n} P dec-P | inr ¬z with dec-P (n , ltS) Dec-Σ-Fin {ℓ} {S n} P dec-P | inr ¬z | (inl p) = inl ((n , ltS) , p) Dec-Σ-Fin {ℓ} {S n} P dec-P | inr ¬z | (inr ¬p) = inr ¬w where ¬w : Σ (Fin (S n)) P → ⊥ ¬w ((_ , ltS) , p) = ¬p p ¬w ((k , ltSR k<n) , p) = ¬z ((k , k<n) , p) <-trans-S : {m n k : ℕ} → m < n → n < (S k) → m < k <-trans-S m<n ltS = m<n <-trans-S m<n (ltSR n<k) = <-trans m<n n<k ℕ-dichotomy : {m n : ℕ} → m ≠ n → (m < n) ⊔ (n < m) ℕ-dichotomy {m} {n} m≠n with ℕ-trichotomy m n ℕ-dichotomy {m} {n} m≠n | inl p = ⊥-rec (m≠n p) ℕ-dichotomy {m} {n} m≠n | inr x = x Fin-fst-= : ∀ {n} {i j : Fin n} → fst i == fst j → i == j Fin-fst-= {n} {i , i<n} {j , j<n} = Subtype=-out (Fin-prop n) punchout : ∀ {n} (i j : Fin (S n)) → i ≠ j → Fin n punchout {n} (i , i<Sn) (j , j<Sn) i≠j with ℕ-dichotomy (i≠j ∘ Fin-fst-=) punchout {n} (i , i<Sn) (.(S i) , Si<Sn) i≠j | inl ltS = i , <-trans-S ltS Si<Sn punchout {n} (i , i<Sn) (S j , Sj<Sn) i≠j | inl (ltSR i<j) = j , <-cancel-S Sj<Sn punchout {n} (i , i<Sn) (j , j<Sn) i≠j | inr j<i = j , <-trans-S j<i i<Sn punchout-inj : ∀ {n} (i j k : Fin (S n)) (i≠j : i ≠ j) (i≠k : i ≠ k) → punchout i j i≠j == punchout i k i≠k → j == k punchout-inj {n} (i , i<Sn) (j , j<Sn) (k , k<Sn) i≠j i≠k q with ℕ-dichotomy (i≠j ∘ Fin-fst-=) punchout-inj {n} (i , i<Sn) (.(S i) , Si<Sn) (k , k<Sn) i≠j i≠k q | inl ltS with ℕ-dichotomy (i≠k ∘ Fin-fst-=) punchout-inj {n} (i , i<Sn) (.(S i) , Si<Sn) (.(S i) , _) i≠j i≠k q | inl ltS | inl ltS = Fin-fst-= idp punchout-inj {n} (i , i<Sn) (.(S i) , Si<Sn) (S k , Sk<Sn) i≠j i≠k q | inl ltS | inl (ltSR i<k) = ⊥-rec (<-to-≠ i<k (ap fst q)) punchout-inj {n} (i , i<Sn) (.(S i) , Si<Sn) (k , k<Sn) i≠j i≠k q | inl ltS | inr k<i = ⊥-rec (i≠k (Fin-fst-= (ap fst q))) punchout-inj {n} (i , i<Sn) (S j , Sj<Sn) (k , k<Sn) i≠j i≠k q | inl (ltSR i<j) with ℕ-dichotomy (i≠k ∘ Fin-fst-=) punchout-inj {n} (i , i<Sn) (S j , Sj<Sn) (.(S i) , Si<Sn) i≠j i≠k q | inl (ltSR i<j) | inl ltS = ⊥-rec (<-to-≠ i<j (! (ap fst q))) punchout-inj {n} (i , i<Sn) (S j , Sj<Sn) (S k , Sk<Sn) i≠j i≠k q | inl (ltSR i<j) | inl (ltSR i<k) = Fin-fst-= (ap S (ap fst q)) punchout-inj {n} (i , i<Sn) (S j , Sj<Sn) (k , k<Sn) i≠j i≠k q | inl (ltSR i<j) | inr k<i = ⊥-rec (<-to-≠ (<-trans k<i i<j) (! (ap fst q))) punchout-inj {n} (i , i<Sn) (j , j<Sn) (k , k<Sn) i≠j i≠k q | inr j<i with ℕ-dichotomy (i≠k ∘ Fin-fst-=) punchout-inj {n} (i , i<Sn) (j , j<Sn) (.(S i) , Si<Sn) i≠j i≠k q | inr j<i | (inl ltS) = ⊥-rec (i≠j (Fin-fst-= (! (ap fst q)))) punchout-inj {n} (i , i<Sn) (j , j<Sn) (S k , Sk<Sn) i≠j i≠k q | inr j<i | (inl (ltSR i<k)) = ⊥-rec (<-to-≠ (<-trans j<i i<k) (ap fst q)) punchout-inj {n} (i , i<Sn) (j , j<Sn) (k , k<Sn) i≠j i≠k q | inr j<i | (inr k<i) = Fin-fst-= (ap fst q) pigeonhole-special : ∀ {n} (f : Fin (S n) → Fin n) → Σ (Fin (S n)) λ i → Σ (Fin (S n)) λ j → (i ≠ j) × (f i == f j) pigeonhole-special {O} f = ⊥-rec (–> Fin-equiv-Empty (f (O , ltS))) pigeonhole-special {S n} f with Dec-Σ-Fin (λ i → f (incl ltS i) == f (S n , ltS)) (λ i → Fin-has-dec-eq (f (incl ltS i)) (f (S n , ltS))) pigeonhole-special {S n} f | inl (i , p) = incl ltS i , (S n , ltS) , incl-ne i , p pigeonhole-special {S n} f | inr h = incl ltS i , incl ltS j , (λ q → i≠j (Fin-fst-= (ap fst q))) , punchout-inj (f (S n , ltS)) (f (incl ltS i)) (f (incl ltS j)) (λ q → h (i , Fin-fst-= (! (ap fst q)))) (λ q → h (j , Fin-fst-= (! (ap fst q)))) (Fin-fst-= (ap fst p)) where g : Fin (S n) → Fin n g k = punchout (f (S n , ltS)) (f (incl ltS k)) λ p → h (k , Fin-fst-= (! (ap fst p))) i : Fin (S n) i = fst (pigeonhole-special g) j : Fin (S n) j = fst (snd (pigeonhole-special g)) i≠j : i ≠ j i≠j = fst (snd (snd (pigeonhole-special g))) p : g i == g j p = snd (snd (snd (pigeonhole-special g))) pigeonhole : ∀ {m n} (m<n : m < n) (f : Fin n → Fin m) → Σ (Fin n) λ i → Σ (Fin n) λ j → (i ≠ j) × (f i == f j) pigeonhole {m} {.(S m)} ltS f = pigeonhole-special f pigeonhole {m} {(S n)} (ltSR p) f = i , j , ¬q , Subtype=-out (Fin-prop m) (ap fst r) where g : Fin (S n) → Fin n g k = fst (f k) , <-trans (snd (f k)) p i : Fin (S n) i = fst (pigeonhole-special g) j : Fin (S n) j = fst (snd (pigeonhole-special g)) ¬q : i == j → ⊥ ¬q = fst (snd (snd (pigeonhole-special g))) r : g i == g j r = snd (snd (snd (pigeonhole-special g)))
{ "alphanum_fraction": 0.4863739591, "avg_line_length": 47.1785714286, "ext": "agda", "hexsha": "3b89e1247135d8ae7051a0f1054f9f563d111dea", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AntoineAllioux/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/Pigeonhole.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "AntoineAllioux/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/Pigeonhole.agda", "max_line_length": 139, "max_stars_count": 294, "max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AntoineAllioux/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/Pigeonhole.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": 2581, "size": 5284 }
open import Data.Unit using ( ⊤ ) open import FRP.LTL.RSet.Core using ( RSet ) module FRP.LTL.RSet.Unit where T : RSet T t = ⊤
{ "alphanum_fraction": 0.6769230769, "avg_line_length": 14.4444444444, "ext": "agda", "hexsha": "b9b0e5070f671b5887920dec77982a454d2e8ced", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z", "max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-frp-ltl", "max_forks_repo_path": "src/FRP/LTL/RSet/Unit.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-frp-ltl", "max_issues_repo_path": "src/FRP/LTL/RSet/Unit.agda", "max_line_length": 44, "max_stars_count": 21, "max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-frp-ltl", "max_stars_repo_path": "src/FRP/LTL/RSet/Unit.agda", "max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z", "num_tokens": 44, "size": 130 }
-- Andreas, 2017-07-13, issue #2642 record R : Set₁ where field F : Set F : Set -- duplicate field, should be rejected -- Otherwise, this gives an internal error: test : Set → R test A = record{ F = A }
{ "alphanum_fraction": 0.6313364055, "avg_line_length": 18.0833333333, "ext": "agda", "hexsha": "a9a909f3955464c6c9da9952360678d1d3f53c6c", "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/Issue2642.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/Issue2642.agda", "max_line_length": 51, "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/Issue2642.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": 68, "size": 217 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Vectors defined in terms of the reflexive-transitive closure, Star ------------------------------------------------------------------------ {-# OPTIONS --with-K --safe #-} module Data.Star.Vec where open import Data.Star.Nat open import Data.Star.Fin using (Fin) open import Data.Star.Decoration open import Data.Star.Pointer as Pointer hiding (lookup) open import Data.Star.List using (List) open import Relation.Binary open import Relation.Binary.Consequences open import Relation.Binary.Construct.Closure.ReflexiveTransitive open import Function open import Data.Unit -- The vector type. Vectors are natural numbers decorated with extra -- information (i.e. elements). Vec : Set → ℕ → Set Vec A = All (λ _ → A) -- Nil and cons. [] : ∀ {A} → Vec A zero [] = ε infixr 5 _∷_ _∷_ : ∀ {A n} → A → Vec A n → Vec A (suc n) x ∷ xs = ↦ x ◅ xs -- Projections. head : ∀ {A n} → Vec A (1# + n) → A head (↦ x ◅ _) = x tail : ∀ {A n} → Vec A (1# + n) → Vec A n tail (↦ _ ◅ xs) = xs -- Append. infixr 5 _++_ _++_ : ∀ {A m n} → Vec A m → Vec A n → Vec A (m + n) _++_ = _◅◅◅_ -- Safe lookup. lookup : ∀ {A n} → Fin n → Vec A n → A lookup i xs with Pointer.lookup i xs ... | result _ x = x ------------------------------------------------------------------------ -- Conversions fromList : ∀ {A} → (xs : List A) → Vec A (length xs) fromList ε = [] fromList (x ◅ xs) = x ∷ fromList xs toList : ∀ {A n} → Vec A n → List A toList = gmap (const tt) decoration
{ "alphanum_fraction": 0.5415873016, "avg_line_length": 23.1617647059, "ext": "agda", "hexsha": "ff4aef7af0780101f204382024650cf525308cf7", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Star/Vec.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Star/Vec.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Star/Vec.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": 461, "size": 1575 }
-- Andreas, 2017-04-11, Issue 2543 -- Printing of second non-trivial with-pattern -- {-# OPTIONS -v interaction.case:100 #-} data D : Set where c : D → D f : D → D f y with c y ... | c z with c y ... | q = {!q!} -- C-c C-c q -- Was: -- f y | c z | (c q) = ? -- Expected: -- f y | c z | c q = ?
{ "alphanum_fraction": 0.5033112583, "avg_line_length": 15.8947368421, "ext": "agda", "hexsha": "41c73842cfb1dff804f38c96f68549adc96cc7f6", "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": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "hborum/agda", "max_forks_repo_path": "test/interaction/Issue2543.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/interaction/Issue2543.agda", "max_line_length": 46, "max_stars_count": 2, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/interaction/Issue2543.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 116, "size": 302 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Showing natural numbers ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Nat.Show where open import Data.Char as Char using (Char) open import Data.Digit using (showDigit; toDigits; toNatDigits) open import Function using (_∘_; _$_) open import Data.List.Base using (List; []; _∷_; map; reverse) open import Data.Nat open import Data.Product using (proj₁) open import Data.String as String using (String) open import Relation.Nullary.Decidable using (True) ------------------------------------------------------------------------ -- Conversion from unary representation to the representation by the -- given base. toDigitChar : (n : ℕ) → Char toDigitChar n = Char.fromℕ (n + (Char.toℕ '0')) toDecimalChars : ℕ → List Char toDecimalChars = map toDigitChar ∘ toNatDigits 10 ------------------------------------------------------------------------ -- Show -- Time complexity is O(log₁₀(n)) show : ℕ → String show = String.fromList ∘ toDecimalChars -- Warning: when compiled the time complexity of `showInBase b n` is -- O(n) instead of the expected O(log(n)). showInBase : (base : ℕ) {base≥2 : True (2 ≤? base)} {base≤16 : True (base ≤? 16)} → ℕ → String showInBase base {base≥2} {base≤16} n = String.fromList $ map (showDigit {base≤16 = base≤16}) $ reverse $ proj₁ $ toDigits base {base≥2 = base≥2} n
{ "alphanum_fraction": 0.55078125, "avg_line_length": 30.72, "ext": "agda", "hexsha": "2221a676e1cc9ad5ef5ed666abd019ed449c2269", "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/Show.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/Show.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/Show.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": 369, "size": 1536 }
module Issue892b where record R : Set₁ where field A : Set B : A → Set -- The type of R.B should print as (r : R) → R.A r → Set -- rather than ( : R) → R.A → Set. bad : R.B bad = ?
{ "alphanum_fraction": 0.5408163265, "avg_line_length": 15.0769230769, "ext": "agda", "hexsha": "87a62b07b0ae7f9c43b15dbb8a30297ef1558021", "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/Issue892b.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/Issue892b.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/Fail/Issue892b.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": 70, "size": 196 }
------------------------------------------------------------------------ -- Programs used to define and specify breadth-first manipulations of -- trees ------------------------------------------------------------------------ module BreadthFirst.Programs where open import Codata.Musical.Notation open import Codata.Musical.Colist hiding ([_]) open import Data.List.NonEmpty using (List⁺; [_]; _⁺++⁺_) open import Data.Product open import BreadthFirst.Universe open import Stream hiding (zipWith) open import Tree infixr 5 _≺_ _∷_ infixr 4 _,_ infix 3 ↓_ mutual -- The term WHNF is a bit of a misnomer here; only recursive -- /coinductive/ arguments are suspended (in the form of programs). data ElW : U → Set₁ where leaf : ∀ {a} → ElW (tree a) node : ∀ {a} (l : ∞ (ElP (tree a))) (x : ElW a) (r : ∞ (ElP (tree a))) → ElW (tree a) _≺_ : ∀ {a} (x : ElW a) (xs : ∞ (ElP (stream a))) → ElW (stream a) [] : ∀ {a} → ElW (colist a) _∷_ : ∀ {a} (x : ElW a) (xs : ∞ (ElP (colist a))) → ElW (colist a) _,_ : ∀ {a b} (x : ElW a) (y : ElW b) → ElW (a ⊗ b) ⌈_⌉ : ∀ {A} (x : A) → ElW ⌈ A ⌉ -- Note that higher-order functions are not handled well (see -- longZipWith): the arguments cannot be programs, since this would -- make the type negative. -- The tree arguments to lab and flatten used to be tree programs, -- but a number of lemmas could be removed when they were turned -- into "actual" trees. data ElP : U → Set₁ where ↓_ : ∀ {a} (w : ElW a) → ElP a fst : ∀ {a b} (p : ElP (a ⊗ b)) → ElP a snd : ∀ {a b} (p : ElP (a ⊗ b)) → ElP b lab : ∀ {A B} (t : Tree A) (lss : ElP (stream ⌈ Stream B ⌉)) → ElP (tree ⌈ B ⌉ ⊗ stream ⌈ Stream B ⌉) longZipWith : ∀ {A} (f : A → A → A) (xs ys : ElP (colist ⌈ A ⌉)) → ElP (colist ⌈ A ⌉) flatten : ∀ {A} (t : Tree A) → ElP (colist ⌈ List⁺ A ⌉) infixl 9 _·_ _⊛_ _·_ : ∀ {A B} → (A → B) → ElW ⌈ A ⌉ → ElW ⌈ B ⌉ f · ⌈ x ⌉ = ⌈ f x ⌉ _⊛_ : ∀ {A B} → ElW ⌈ (A → B) ⌉ → ElW ⌈ A ⌉ → ElW ⌈ B ⌉ ⌈ f ⌉ ⊛ x = f · x fstW : ∀ {a b} → ElW (a ⊗ b) → ElW a fstW (x , y) = x sndW : ∀ {a b} → ElW (a ⊗ b) → ElW b sndW (x , y) = y -- Uses the n-th stream to label the n-th level in the tree. Returns -- the remaining stream elements (for every level). labW : ∀ {A B} → Tree A → ElW (stream ⌈ Stream B ⌉) → ElW (tree ⌈ B ⌉ ⊗ stream ⌈ Stream B ⌉) labW leaf bss = (leaf , bss) labW (node l _ r) (⌈ b ≺ bs ⌉ ≺ bss) = (node (♯ fst x) ⌈ b ⌉ (♯ fst y) , ⌈ ♭ bs ⌉ ≺ ♯ snd y) where x = lab (♭ l) (♭ bss) y = lab (♭ r) (snd x) longZipWithW : ∀ {A} → (A → A → A) → (xs ys : ElW (colist ⌈ A ⌉)) → ElW (colist ⌈ A ⌉) longZipWithW f (x ∷ xs) (y ∷ ys) = f · x ⊛ y ∷ ♯ longZipWith f (♭ xs) (♭ ys) longZipWithW f xs [] = xs longZipWithW f [] ys = ys flattenW : ∀ {A} → Tree A → ElW (colist ⌈ List⁺ A ⌉) flattenW leaf = [] flattenW (node l x r) = ⌈ [ x ] ⌉ ∷ ♯ longZipWith _⁺++⁺_ (flatten (♭ l)) (flatten (♭ r)) whnf : ∀ {a} → ElP a → ElW a whnf (↓ w) = w whnf (fst p) = fstW (whnf p) whnf (snd p) = sndW (whnf p) whnf (lab t bss) = labW t (whnf bss) whnf (longZipWith f xs ys) = longZipWithW f (whnf xs) (whnf ys) whnf (flatten t) = flattenW t mutual ⟦_⟧W : ∀ {a} → ElW a → El a ⟦ leaf ⟧W = leaf ⟦ (node l x r) ⟧W = node (♯ ⟦ ♭ l ⟧) ⟦ x ⟧W (♯ ⟦ ♭ r ⟧) ⟦ (x ≺ xs) ⟧W = ⟦ x ⟧W ≺ ♯ ⟦ ♭ xs ⟧ ⟦ [] ⟧W = [] ⟦ (x ∷ xs) ⟧W = ⟦ x ⟧W ∷ ♯ ⟦ ♭ xs ⟧ ⟦ (x , y) ⟧W = (⟦ x ⟧W , ⟦ y ⟧W) ⟦ ⌈ x ⌉ ⟧W = x ⟦_⟧ : ∀ {a} → ElP a → El a ⟦ p ⟧ = ⟦ whnf p ⟧W
{ "alphanum_fraction": 0.4614152203, "avg_line_length": 32.850877193, "ext": "agda", "hexsha": "c8af07f60b1d53644cef94f9133aea085fa66e6f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/codata", "max_forks_repo_path": "BreadthFirst/Programs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/codata", "max_issues_repo_path": "BreadthFirst/Programs.agda", "max_line_length": 76, "max_stars_count": 1, "max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/codata", "max_stars_repo_path": "BreadthFirst/Programs.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z", "num_tokens": 1611, "size": 3745 }
{-# OPTIONS --allow-unsolved-metas #-} module Real-Backup where open import Data.Float hiding (_-_; _≈_) open import Level using (0ℓ) open import Algebra.Bundles using (CommutativeRing) open import Algebra.Module.Bundles using (Module) open import Relation.Binary.Structures using (IsStrictTotalOrder) open import Relation.Binary.Bundles using (StrictTotalOrder) open import Data.Sum using (_⊎_; inj₁; inj₂) module CR = CommutativeRing open import Relation.Binary.PropositionalEquality using (_≡_; module ≡-Reasoning) open import Algebra.Module.Construct.TensorUnit import Limit open import InnerProduct open import Relation.Nullary using (¬_) private postulate todo : ∀ {a} {A : Set a} → A +-*-commutativeRing : CommutativeRing 0ℓ 0ℓ CR.Carrier +-*-commutativeRing = Float CR._≈_ +-*-commutativeRing = _≡_ CR._+_ +-*-commutativeRing = _+_ CR._*_ +-*-commutativeRing = _*_ CR.- +-*-commutativeRing = -_ CR.0# +-*-commutativeRing = 0.0 CR.1# +-*-commutativeRing = 1.0 CR.isCommutativeRing +-*-commutativeRing = todo +-*-module : Module +-*-commutativeRing 0ℓ 0ℓ +-*-module = ⟨module⟩ <-strictTotalOrder : StrictTotalOrder _ 0ℓ 0ℓ <-strictTotalOrder = record { Carrier = Float; _≈_ = _≡_; _<_ = todo; isStrictTotalOrder = todo } infixl 6 _-_ _-_ : Float → Float → Float x - y = x + (- y) open StrictTotalOrder <-strictTotalOrder +-*-isInnerProduct : IsInnerProduct isStrictTotalOrder (λ x → x) +-*-module _*_ +-*-isInnerProduct = todo +-*-isNormed : IsNormed isStrictTotalOrder (λ x → x) +-*-module _*_ sqrt +-*-isNormed = record { isInnerProduct = +-*-isInnerProduct ; sqrt-law = todo ; sqrt-concave = todo ; sqrt-cong = todo } module _ where open Limit +-*-isNormed +-*-isNormed open IsNormed +-*-isNormed open Module +-*-module open CommutativeRing +-*-commutativeRing using (refl; +-cong) open import Data.Product open import Algebra.Module.Morphism.Structures _ : ∀ c → (c + x) ⟶ c as x ⟶0 _ = λ c ε (0<ε) → ε , λ x (0<x , x<ε) → begin-strict ∥ c + x - c ∥ ≈⟨ ∥∥-cong (y+x-y≈x c x) ⟩ ∥ x ∥ <⟨ x<ε ⟩ ε ∎ where open import Relation.Binary.Reasoning.StrictPartialOrder strictPartialOrder y+x-y≈x : ∀ y x → y + x - y ≈ᴹ x y+x-y≈x y x = begin-equality y + x - y ≈⟨ +ᴹ-cong (+ᴹ-comm y x) refl ⟩ x + y - y ≈⟨ +ᴹ-assoc x y (- y) ⟩ x + (y - y) ≈⟨ +ᴹ-cong {x = x} refl (-ᴹ‿inverseʳ y) ⟩ x + 0.0 ≈⟨ +ᴹ-identityʳ x ⟩ x ∎ times : Float → Float → Float times = _*_ times-homo : ∀ m → IsModuleHomomorphism +-*-module +-*-module (times m) times-homo = todo _SlopeOf_At_ : (f' : MA.X → MB.X) (f : MA.X → MB.X) (x : MA.X) → Set _ f' SlopeOf f At x = (λ y dy → f' y * dy) Differentiates f At x dxⁿ≈nxⁿ⁻¹ : ∀ x n → (1.0 < n) ⊎ (¬ x ≈ 0.0) → (λ y → (n * (y ** (n - 1.0)))) SlopeOf (_** n) At x dxⁿ≈nxⁿ⁻¹ = todo dlogx≈1÷x : ∀ x → ¬ x ≈ 0.0 → (λ y dy → dy ÷ y) Differentiates log At x dlogx≈1÷x = todo deˣ/dx≈eˣ : ∀ x → e^_ SlopeOf e^_ At x deˣ/dx≈eˣ = todo open import Function using (_∘_) -- chain' -- : ∀ f f' g g' x -- → (λ dx → dx * f' x) Differentiates f At x -- → (λ dx → dx * g' (f x)) Differentiates g At f x -- → (λ dx → g'fx * (f'x dx)) Differentiates (g ∘ f) At x -- chain' f g x (f'x , _) (g'fx , _) = (λ dx → g'fx (f'x dx)) , todo ∂exp : ∀ x → (λ y dy → dy * (e^ y)) Differentiates e^_ At x ∂exp x = todo open import Data.Nat using (zero; suc) instance exp-n-∂ : ∀ {n} {x} → e^_ ⟦ x , n ⟧ exp-n-∂ {zero} = [] exp-n-∂ {n = suc n} = todo ∹ exp-n-∂ it : ∀ {a} {A : Set a} → {{A}} → A it {{x}} = x gradexp : ∀ {x} → e^_ ⟦ x , 0 ⟧ gradexp = it chain : ∀ f g x {n} → ⦃ f ⟦ x , n ⟧ ⦄ → ⦃ g ⟦ f x , n ⟧ ⦄ → (g ∘ f) ⟦ x , n ⟧ chain f g x {n = 0} = [] chain f g x {_} ⦃ _∹_ {_} {f'} pf ff ⦄ ⦃ _∹_ {_} {g'} pg gg ⦄ = let h y dy = g' (f y) (f' y dy) -- confusion here between xs and dxs. in _∹_ {δf = h} todo (chain (f' x) (g' (f x)) x ⦃ ff ⦄ ⦃ {! gg !} ⦄) exp : Float → Float exp = e^_ asdf : ∀ x → (exp ∘ exp) ⟦ x , 1 ⟧ asdf x = chain exp exp x -- gradsin : ∀ {x} → sin DifferentiableAt x -- gradsin {x} = (λ dx → dx * (cos x)) , todo -- gradcos : ∀ {x} → cos DifferentiableAt x -- gradcos {x} = (λ dx → dx * (- sin x)) , todo -- grad : ∀ f x → f DifferentiableAt x → Float → Float -- grad f x (f'x , _) = f'x -- teste : Float → Float -- teste x = grad e^_ x (grade^ {x}) 1.0 -- -- testsin : Float → Float -- -- testsin x = grad sin x (gradsin x) 1.0 -- -- test : Float → Float -- -- test x = grad (e^_ ∘ sin) x (chain' sin e^_ x (gradsin x) (grade^ (sin x))) 1.0 -- -- _ : ∀ x → test x ≡ 1.0 * cos x * (e^ sin x) -- -- _ = λ x → refl -- -- -- TODO -- -- -- definitely need some helper functions here. -- -- _ : ∀ y n → (λ x → n * y ** (n - 1.0) * x) Differentiates (λ x → x ** n) At y -- -- _ = λ y n → todo , λ ε 0<ε → δ₀ ε y n , λ δ (0<δ , δ<ε) → proof y n ε δ 0<δ δ<ε -- -- where -- -- δ₀ : Float → Float → Float → Float -- -- δ₀ = {! !} -- -- triangle : ∀ x y → ∥ x + y ∥ < ∥ x ∥ + ∥ y ∥ -- -- triangle = todo -- -- ≈< : ∀ x {y z} → y < z → x + y < x + z -- -- ≈< = todo -- -- -- does this imply _≈_ is _≡_? -- -- ∀-cong : ∀ {x y} (f : CR.X → CR.X) → x ≈ y → f x ≈ f y -- -- ∀-cong = todo -- -- proof -- -- : ∀ y n ε Δ (0<Δ : 0.0 < ∥ Δ ∥) (Δ<ε : ∥ Δ ∥ < ε) -- -- → ∥ (y + Δ) ** n - (y ** n +ᴹ n * y ** (n - 1.0) * Δ) ∥ < ε -- -- proof y n ε Δ 0<Δ Δ<ε = -- -- begin-strict -- -- ∥ (y + Δ) ** n - (y ** n + n * y ** (n - 1.0) * Δ) ∥ -- -- <⟨ triangle ((y + Δ) ** n) _ ⟩ -- -- ∥ (y + Δ) ** n ∥ + ∥ - (y ** n + n * y ** (n - 1.0) * Δ) ∥ -- -- ≈⟨ +-cong { ∥ (y + Δ) ** n ∥ } refl (sqrt-cong (∥-x∥²≈∥x∥² ((y ** n + n * y ** (n - 1.0) * Δ)))) ⟩ -- -- ∥ (y + Δ) ** n ∥ + ∥ (y ** n + n * y ** (n - 1.0) * Δ) ∥ -- -- <⟨ ≈< ∥ (y + Δ) ** n ∥ (triangle (y ** n) _) ⟩ -- -- ∥ (y + Δ) ** n ∥ + (∥ y ** n ∥ + ∥ n * y ** (n - 1.0) * Δ ∥) -- -- <⟨ {! +-cong refl (x→-x _) !} ⟩ -- -- ε -- -- ∎ -- -- -- (f (x MA.+ᴹ dx) MB.+ᴹ (MB.-ᴹ (f x MB.+ᴹ f' dx))) ⟶ MB.0ᴹ as dx ⟶ MA.0ᴹ -- -- _ : ∀ θ → (λ dθ → F.cos θ F.* dθ) Differentiates F.sin At θ -- -- _ = -- -- λ θ → times-homo (F.cos θ) , -- -- λ ε → ε , -- -- λ dθ (0<abs[dθ-0] , abs[dθ-0]<ε) → {! !} -- abs[x-0]<ε→abs[c+x-c]<ε x ε {! F.sin (θ F.+ x) !} abs[x-0]<ε -- -- -- if abs dθ < ε then abs ( sin (θ + dθ) - (sin θ + cos θ * dθ) ) < ε -- -- -- sin x = (e^iπx - e^-iπx) / 2i -- -- -- cos x = (e^iπx + e^-iπx) / 2 -- -- -- sin x+dx = ? -- -- -- open Diff +-*-module +-*-module -- -- -- open Line +-*-commutativeRing -- -- -- dline : ∀ m b x → Differentiable _≤_ abs abs (line m b) x -- -- -- dline m b x = (λ x' dx → m * dx) , {! !} , λ dy → (dy F.÷ m) , {! asdf dy !} -- -- -- where -- -- -- open import Relation.Binary.Reasoning.PartialOrder ≤-poset -- -- -- diff≈0 : ∀ dx → (line m b (x + dx) - line m b x) - m * dx ≈ 0# -- -- -- diff≈0 dx = -- -- -- begin-equality -- -- -- (line m b (x + dx) - line m b x - m * dx) -- -- -- ≈⟨ +-cong (linear-diff m b x dx) refl ⟩ -- -- -- m * dx - m * dx -- -- -- ≈⟨ proj₂ -‿inverse (m * dx) ⟩ -- -- -- 0# -- -- -- ∎ -- -- -- open import Data.Nat using (ℕ; zero; suc) -- -- -- -- -- -- -- -- Convex : (A → A) → Set -- -- -- -- minimize : (f : A → A) (c : Convex f) → A -- -- -- -- minimize f c = {! !} -- -- -- -- gradient : (f : A → A) (Differentiable f) -- -- -- -- gradientDescent : (f' : A → A) (n : ℕ) → A -- -- -- -- gradientDescent = ? -- -- -- open import Relation.Nullary using (¬_) -- -- -- x<y→y≮x : ∀ {x y} → x < y → ¬ y < x -- -- -- x<y→y≮x x y = post -- -- -- <-trans : ∀ {i j k} → i < j → j < k → i < k -- -- -- <-trans i<j j<k = post -- -- -- open CommutativeRing +-*-commutativeRing -- -- -- open Module +-*-module -- -- -- open import Relation.Binary -- -- -- ≤-antisym : Antisymmetric _≡_ _≤_ -- -- -- ≤-antisym (inj₂ i≡j) j≤i = i≡j -- -- -- ≤-antisym (inj₁ i<j) (inj₂ j≡i) = sym j≡i -- -- -- ≤-antisym {i} {j} (inj₁ i<j) (inj₁ j<i) with x<y→y≮x {i} {j} i<j j<i -- -- -- ... | () -- -- -- ≤-trans : Transitive _≤_ -- -- -- ≤-trans {i} {j} {k} (inj₁ i<j) (inj₁ j<k) = inj₁ (<-trans {i} {j} {k} i<j j<k) -- -- -- ≤-trans (inj₁ i<j) (inj₂ j≡k) = inj₁ {! tt !} -- -- -- ≤-trans (inj₂ y) (inj₁ x) = {! !} -- -- -- ≤-trans (inj₂ i≡j) (inj₂ j≡k) = inj₂ (trans i≡j j≡k)
{ "alphanum_fraction": 0.4585761627, "avg_line_length": 30.0721649485, "ext": "agda", "hexsha": "985d4526c1b28bb5ed024e4acc2d1d09ffe553f0", "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": "78c3dec24834ffeca5e74cb75578e9b210a5be62", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "cspollard/diff", "max_forks_repo_path": "src/Real-Backup.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "78c3dec24834ffeca5e74cb75578e9b210a5be62", "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": "cspollard/diff", "max_issues_repo_path": "src/Real-Backup.agda", "max_line_length": 120, "max_stars_count": null, "max_stars_repo_head_hexsha": "78c3dec24834ffeca5e74cb75578e9b210a5be62", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "cspollard/diff", "max_stars_repo_path": "src/Real-Backup.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3779, "size": 8751 }
-- Andreas, 2012-05-04 -- Occurs check when unifying indices in patterns {-# OPTIONS --allow-unsolved-metas #-} -- The option is supplied to force a real error to pass the regression test. module OccursCheck1 where data Nat : Set where zero : Nat suc : Nat -> Nat data _==_ {A : Set}(x : A) : A -> Set where refl : x == x test : let X : Nat X = _ in X == suc X test = refl -- should fail with error message indicating no solution possible
{ "alphanum_fraction": 0.6565217391, "avg_line_length": 23, "ext": "agda", "hexsha": "45b9c705aa30a14d52dab10a878c1718acfb8c17", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dagit/agda", "max_forks_repo_path": "test/fail/OccursCheck1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dagit/agda", "max_issues_repo_path": "test/fail/OccursCheck1.agda", "max_line_length": 76, "max_stars_count": 1, "max_stars_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dagit/agda", "max_stars_repo_path": "test/fail/OccursCheck1.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": 135, "size": 460 }
{-# OPTIONS --safe --warning=error --without-K --guardedness #-} open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Setoids.Setoids open import Rings.Definition open import Rings.Lemmas open import Rings.Orders.Partial.Definition open import Rings.Orders.Total.Definition open import Groups.Definition open import Groups.Groups 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.Naturals module Fields.CauchyCompletion.EquivalentMonotone {m n o : _} {A : Set m} {S : Setoid {m} {n} A} {_+_ : A → A → A} {_*_ : A → A → A} {_<_ : Rel {m} {o} A} {pOrder : SetoidPartialOrder S _<_} {tOrder : SetoidTotalOrder {_<_ = _<_} pOrder} {R : Ring S _+_ _*_} (order : TotallyOrderedRing R tOrder) (F : Field R) (charNot2 : Setoid._∼_ S ((Ring.1R R) + (Ring.1R R)) (Ring.0R R) → False) where open Setoid S open SetoidTotalOrder tOrder open SetoidPartialOrder pOrder open Equivalence eq open TotallyOrderedRing order open Field F open Group (Ring.additiveGroup R) open Ring R open import Fields.Lemmas F open import Fields.Orders.Lemmas {F = F} record { oRing = order } open import Rings.Orders.Lemmas(order) open import Fields.CauchyCompletion.Definition order F open import Fields.CauchyCompletion.Multiplication order F charNot2 open import Fields.CauchyCompletion.Addition order F charNot2 open import Fields.CauchyCompletion.Setoid order F charNot2 open import Fields.CauchyCompletion.Group order F charNot2 open import Fields.CauchyCompletion.Ring order F charNot2 open import Fields.CauchyCompletion.Comparison order F charNot2 open import Fields.CauchyCompletion.Approximation order F charNot2 halvingSequence : (start : A) → Sequence A Sequence.head (halvingSequence start) = start Sequence.tail (halvingSequence start) with halve charNot2 start Sequence.tail (halvingSequence start) | start/2 , _ = halvingSequence start/2 halvingSequenceMultiple : (start : A) → {n : ℕ} → index (halvingSequence start) n ∼ index (map (start *_) (halvingSequence (Ring.1R R))) n halvingSequenceMultiple start {zero} = Equivalence.symmetric eq (Equivalence.transitive eq *Commutative identIsIdent) halvingSequenceMultiple start {succ n} with halve charNot2 start ... | start/2 , _ with allInvertible (1R + 1R) charNot2 halvingSequenceMultiple start {succ n} | start/2 , b | 1/2 , pr1/2 rewrite equalityCommutative (mapAndIndex (halvingSequence (1R * 1/2)) (_*_ start) n) = Equivalence.transitive eq (halvingSequenceMultiple start/2 {n}) f where g : (start * (1/2 * index (halvingSequence 1R) n)) ∼ (start * index (map (_*_ (1R * 1/2)) (halvingSequence 1R)) n) g rewrite equalityCommutative (mapAndIndex (halvingSequence 1R) (_*_ (1R * 1/2)) n) = *WellDefined (Equivalence.reflexive eq) (*WellDefined (Equivalence.symmetric eq identIsIdent) (Equivalence.reflexive eq)) f : index (map (_*_ start/2) (halvingSequence 1R)) n ∼ (start * index (halvingSequence (1R * 1/2)) n) f rewrite equalityCommutative (mapAndIndex (halvingSequence 1R) (_*_ start/2) n) = Equivalence.transitive eq (Equivalence.transitive eq (Equivalence.transitive eq (*WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq (*WellDefined (Equivalence.symmetric eq b) (Equivalence.reflexive eq)) (halfHalves 1/2 (Equivalence.transitive eq (Equivalence.transitive eq (+WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq *Commutative identIsIdent)) (Equivalence.symmetric eq (Equivalence.transitive eq *Commutative identIsIdent))) (Equivalence.symmetric eq *DistributesOver+)) pr1/2)))) (Equivalence.reflexive eq)) (Equivalence.symmetric eq *Associative)) g) (Equivalence.symmetric eq (*WellDefined (Equivalence.reflexive eq) (halvingSequenceMultiple (1R * 1/2) {n}))) Decreasing : Sequence A → Set o Decreasing seq = ∀ (N : ℕ) → (index seq (succ N)) < (index seq N) halvingSequencePositive : (n : ℕ) → 0G < index (halvingSequence 1R) n halvingSequencePositive zero = 0<1 (charNot2ImpliesNontrivial charNot2) halvingSequencePositive (succ n) with halve charNot2 1R halvingSequencePositive (succ n) | 1/2 , pr1/2 = <WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq (Equivalence.transitive eq (halvingSequenceMultiple 1/2 {n}) (Equivalence.transitive eq (identityOfIndiscernablesLeft _∼_ (Equivalence.reflexive eq) (mapAndIndex (halvingSequence 1R) (_*_ 1/2) n)) *Commutative))) (orderRespectsMultiplication (halvingSequencePositive n) (halvePositive 1/2 (<WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq pr1/2) (0<1 (charNot2ImpliesNontrivial charNot2))))) decreasingHalving : Decreasing (halvingSequence 1R) decreasingHalving N with halve charNot2 1R decreasingHalving N | 1/2 , pr1/2 with (halfLess 1/2 1R (0<1 (charNot2ImpliesNontrivial charNot2)) pr1/2) ... | 1/2<1 = <WellDefined (Equivalence.transitive eq (identityOfIndiscernablesLeft _∼_ (Equivalence.reflexive eq) (equalityCommutative (mapAndIndex (halvingSequence 1R) (_*_ 1/2) N))) (Equivalence.symmetric eq (halvingSequenceMultiple 1/2 {N}))) identIsIdent (ringCanMultiplyByPositive {c = index (halvingSequence 1R) N} (halvingSequencePositive N) 1/2<1) imageOfN : ℕ → A imageOfN zero = 0R imageOfN (succ x) = 1R + imageOfN x nextImageOfN : (a : A) → 0R < a → ℕ nextImageOfN a 0<a = ? halvingToZero : (a : A) → (0G < a) → Sg ℕ (λ N → (index (halvingSequence 1R) N) < a) halvingToZero a 0<a with SetoidTotalOrder.totality tOrder a 1R halvingToZero a 0<a | inl (inl a<1) = {!!} halvingToZero a 0<a | inl (inr 1<a) = 0 , 1<a halvingToZero a 0<a | inr a=1 with halve charNot2 1R ... | 1/2 , pr1/2 = 1 , <WellDefined ans (Equivalence.symmetric eq a=1) (halfLess 1/2 1R (0<1 (charNot2ImpliesNontrivial charNot2)) pr1/2) where ans : 1/2 ∼ Sequence.head (Sequence.tail (halvingSequence 1R)) ans with halve charNot2 1R ans | 1/2' , pr1/2' = halvesEqual charNot2 1/2 1/2' pr1/2 pr1/2' halvesCauchy : cauchy (halvingSequence 1R) halvesCauchy e 0<e = {!!} multipleOfCauchyIsCauchy : (mult : A) → (seq : Sequence A) → cauchy seq → cauchy (map (mult *_) seq) multipleOfCauchyIsCauchy mult seq seqCauchy e 0<e with SetoidTotalOrder.totality tOrder 0R mult multipleOfCauchyIsCauchy mult seq seqCauchy e 0<e | inl (inl x) with allInvertible mult λ pr → irreflexive (<WellDefined (Equivalence.reflexive eq) pr x) ... | 1/mult , pr1/mult = {!!} multipleOfCauchyIsCauchy mult seq seqCauchy e 0<e | inl (inr x) with allInvertible mult λ pr → irreflexive (<WellDefined pr (Equivalence.reflexive eq) x) ... | 1/mult , pr1/mult = {!!} multipleOfCauchyIsCauchy mult seq seqCauchy e 0<e | inr 0=mult = 0 , ans where ans : {m n : ℕ} → (0 <N m) → (0 <N n) → abs (index (map (_*_ mult) seq) m + inverse (index (map (_*_ mult) seq) n)) < e ans {m} {n} _ _ rewrite equalityCommutative (mapAndIndex seq (_*_ mult) m) | equalityCommutative (mapAndIndex seq (_*_ mult) n) = <WellDefined {!!} (Equivalence.reflexive eq) 0<e halvingSequenceCauchy : (start : A) → cauchy (halvingSequence start) halvingSequenceCauchy start = {!!} sequenceAllAbove : (a : CauchyCompletion) → Sequence A sequenceAllAbove a = go (Ring.1R R) (0<1 (charNot2ImpliesNontrivial charNot2)) where go : (e : A) → (0G < e) → Sequence A Sequence.head (go e 0<e) = rationalApproximatelyAbove a e 0<e Sequence.tail (go e 0<e) with halve charNot2 e ... | e/2 , prE/2 = go e/2 (halvePositive e/2 (<WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq prE/2) 0<e)) sequenceAllAboveCauchy : (a : CauchyCompletion) → cauchy (sequenceAllAbove a) sequenceAllAboveCauchy a e 0<e = {!!} -- find N such that 1/2^N < e -- show that this N is enough -- show that sequenceAllAbove ∼ a -- monotonify sequenceAllAbove -- show that monotonify of a sequence which is all above its limit still converges to that limit
{ "alphanum_fraction": 0.7443798939, "avg_line_length": 64.3739837398, "ext": "agda", "hexsha": "362481033b2350d9db1c8e385489e4acaeb9998b", "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/EquivalentMonotone.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/EquivalentMonotone.agda", "max_line_length": 789, "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/EquivalentMonotone.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": 2614, "size": 7918 }
module Day4 where open import Prelude.String as String open import Data.Maybe open import Foreign.Haskell using (Unit) open import Prelude.List as List open import Data.Nat open import Data.Nat.DivMod open import Data.Nat.Properties import Data.Nat.Show as ℕs open import Prelude.Char open import Data.Vec as Vec renaming (_>>=_ to _VV=_ ; toList to VecToList) open import Data.Product open import Relation.Nullary open import Data.Nat.Properties open import Data.Bool.Base open import AocIO open import AocUtil open import AocVec open import Relation.Binary.PropositionalEquality open import EvenOdd count-falsy : List Bool → ℕ count-falsy ls = length (filter not ls) split-line : List Char → List String split-line ls with (words ls) ... | ls-words = List.map packString ls-words has-following-duplicates : List String → Bool has-following-duplicates [] = false has-following-duplicates (x ∷ []) = false has-following-duplicates (x ∷ y ∷ ls) with primStringEquality x y ... | false = has-following-duplicates (y ∷ ls) ... | true = true main : IO Unit main = mainBuilder (readFileMain process-file) where sort-word : String → String sort-word s with unpackString s ... | ls with sort ls ... | ls-sorted = packString ls-sorted is-valid-passphrase : List String → Bool is-valid-passphrase ls with List.map sort-word ls ... | sorted-words with sort sorted-words ... | ls-sorted = has-following-duplicates ls-sorted process-file : String → IO Unit process-file file-content with (lines (unpackString file-content)) ... | file-lines with (List.map split-line file-lines) ... | lines-split-into-words with (List.map is-valid-passphrase lines-split-into-words) ... | lines-are-valid with count-falsy lines-are-valid ... | valid-count = printString (ℕs.show valid-count) main2 : IO Unit main2 = mainBuilder (readFileMain process-file) where is-valid-passphrase : List String → Bool is-valid-passphrase ls with sort ls ... | ls-sorted = has-following-duplicates ls-sorted process-file : String → IO Unit process-file file-content with (lines (unpackString file-content)) ... | file-lines with (List.map split-line file-lines) ... | lines-split-into-words with (List.map is-valid-passphrase lines-split-into-words) ... | lines-are-valid with count-falsy lines-are-valid ... | valid-count = printString (ℕs.show valid-count)
{ "alphanum_fraction": 0.7214876033, "avg_line_length": 34.5714285714, "ext": "agda", "hexsha": "ad4dadd168e40de48e5a4d60082b7062d78d530b", "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": "37956e581dc51bf78008d7dd902bb18d2ee481f6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Zalastax/adventofcode2017", "max_forks_repo_path": "day-4/Day4.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37956e581dc51bf78008d7dd902bb18d2ee481f6", "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": "Zalastax/adventofcode2017", "max_issues_repo_path": "day-4/Day4.agda", "max_line_length": 91, "max_stars_count": null, "max_stars_repo_head_hexsha": "37956e581dc51bf78008d7dd902bb18d2ee481f6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Zalastax/adventofcode2017", "max_stars_repo_path": "day-4/Day4.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 626, "size": 2420 }
module Basics where id : {A : Set} -> A -> A id a = a _o_ : {A : Set}{B : A -> Set}{C : (a : A)(b : B a) -> Set} -> ({a : A}(b : B a) -> C a b) -> (g : (a : A) -> B a) -> (a : A) -> C a (g a) _o_ f g a = f (g a)
{ "alphanum_fraction": 0.3451327434, "avg_line_length": 22.6, "ext": "agda", "hexsha": "8366bdfd988a1d1ceee07b05f68f9be28ccdc8ac", "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": "benchmark/Syntacticosmos/Basics.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": "benchmark/Syntacticosmos/Basics.agda", "max_line_length": 61, "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": "benchmark/Syntacticosmos/Basics.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": 226 }
{-# OPTIONS --without-K --safe #-} module Definition.Conversion.Whnf where open import Definition.Untyped open import Definition.Typed open import Definition.Conversion open import Tools.Product mutual -- Extraction of neutrality from algorithmic equality of neutrals. ne~↑ : ∀ {t u A Γ} → Γ ⊢ t ~ u ↑ A → Neutral t × Neutral u ne~↑ (var-refl x₁ x≡y) = var _ , var _ ne~↑ (app-cong x x₁) = let _ , q , w = ne~↓ x in ∘ₙ q , ∘ₙ w ne~↑ (fst-cong x) = let _ , pNe , rNe = ne~↓ x in fstₙ pNe , fstₙ rNe ne~↑ (snd-cong x) = let _ , pNe , rNe = ne~↓ x in sndₙ pNe , sndₙ rNe ne~↑ (natrec-cong x x₁ x₂ x₃) = let _ , q , w = ne~↓ x₃ in natrecₙ q , natrecₙ w ne~↑ (Emptyrec-cong x x₁) = let _ , q , w = ne~↓ x₁ in Emptyrecₙ q , Emptyrecₙ w -- Extraction of neutrality and WHNF from algorithmic equality of neutrals -- with type in WHNF. ne~↓ : ∀ {t u A Γ} → Γ ⊢ t ~ u ↓ A → Whnf A × Neutral t × Neutral u ne~↓ ([~] A₁ D whnfB k~l) = whnfB , ne~↑ k~l -- Extraction of WHNF from algorithmic equality of types in WHNF. whnfConv↓ : ∀ {A B Γ} → Γ ⊢ A [conv↓] B → Whnf A × Whnf B whnfConv↓ (U-refl x) = Uₙ , Uₙ whnfConv↓ (ℕ-refl x) = ℕₙ , ℕₙ whnfConv↓ (Empty-refl x) = Emptyₙ , Emptyₙ whnfConv↓ (Unit-refl x) = Unitₙ , Unitₙ whnfConv↓ (ne x) = let _ , neA , neB = ne~↓ x in ne neA , ne neB whnfConv↓ (Π-cong x x₁ x₂) = Πₙ , Πₙ whnfConv↓ (Σ-cong x x₁ x₂) = Σₙ , Σₙ -- Extraction of WHNF from algorithmic equality of terms in WHNF. whnfConv↓Term : ∀ {t u A Γ} → Γ ⊢ t [conv↓] u ∷ A → Whnf A × Whnf t × Whnf u whnfConv↓Term (ℕ-ins x) = let _ , neT , neU = ne~↓ x in ℕₙ , ne neT , ne neU whnfConv↓Term (Empty-ins x) = let _ , neT , neU = ne~↓ x in Emptyₙ , ne neT , ne neU whnfConv↓Term (Unit-ins x) = let _ , neT , neU = ne~↓ x in Unitₙ , ne neT , ne neU whnfConv↓Term (ne-ins t u x x₁) = let _ , neT , neU = ne~↓ x₁ in ne x , ne neT , ne neU whnfConv↓Term (univ x x₁ x₂) = Uₙ , whnfConv↓ x₂ whnfConv↓Term (zero-refl x) = ℕₙ , zeroₙ , zeroₙ whnfConv↓Term (suc-cong x) = ℕₙ , sucₙ , sucₙ whnfConv↓Term (η-eq x₁ x₂ y y₁ x₃) = Πₙ , functionWhnf y , functionWhnf y₁ whnfConv↓Term (Σ-η _ _ pProd rProd _ _) = Σₙ , productWhnf pProd , productWhnf rProd whnfConv↓Term (η-unit _ _ tWhnf uWhnf) = Unitₙ , tWhnf , uWhnf
{ "alphanum_fraction": 0.5524225576, "avg_line_length": 35.9714285714, "ext": "agda", "hexsha": "652d1c235cac868c636855ab4e8eb2727d895444", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Vtec234/logrel-mltt", "max_forks_repo_path": "Definition/Conversion/Whnf.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Vtec234/logrel-mltt", "max_issues_repo_path": "Definition/Conversion/Whnf.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Vtec234/logrel-mltt", "max_stars_repo_path": "Definition/Conversion/Whnf.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1014, "size": 2518 }
postulate A : Set B : A → Set @0 T : _ T = (@0 x : A) → B x
{ "alphanum_fraction": 0.4153846154, "avg_line_length": 9.2857142857, "ext": "agda", "hexsha": "e74490a9b7e366179a509d491fe325edf8ebe073", "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": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/Succeed/Issue3853.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/Issue3853.agda", "max_line_length": 20, "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/Issue3853.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": 65 }
------------------------------------------------------------------------ -- Types used to make recursive arguments coinductive ------------------------------------------------------------------------ -- See Data.Colist for examples of how this type is used, or -- http://article.gmane.org/gmane.comp.lang.agda/633 for a longer -- explanation. module Coinduction where infix 10 ♯_ ♯₁_ codata ∞ (T : Set) : Set where ♯_ : (x : T) → ∞ T ♭ : ∀ {T} → ∞ T → T ♭ (♯ x) = x -- Variant for Set₁. codata ∞₁ (T : Set₁) : Set₁ where ♯₁_ : (x : T) → ∞₁ T ♭₁ : ∀ {T} → ∞₁ T → T ♭₁ (♯₁ x) = x
{ "alphanum_fraction": 0.4372881356, "avg_line_length": 22.6923076923, "ext": "agda", "hexsha": "0992d2c51249e4911e977e050616b97890cf2f00", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Coinduction.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Coinduction.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Coinduction.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 191, "size": 590 }
open import Prelude open import Data.List.Properties open import Data.List.Any hiding (map) open import Extensions.Vec open import Data.Vec open import Data.List.All as All hiding (map; lookup) module Implicits.Resolution.Infinite.Semantics where open import Implicits.Syntax open import Implicits.Resolution.Infinite.Resolution open import Implicits.Substitutions open import Implicits.Substitutions.Lemmas open import Implicits.Semantics open import Implicits.Semantics.Lemmas open import SystemF.Everything as F using () module DerivationSemantics where ⟦_,_⟧r : ∀ {ν n} {Δ : ICtx ν} {Γ : Ctx ν n} {a} → Δ ⊢ᵣ a → Γ # Δ → ∃ λ t → ⟦ Γ ⟧ctx→ F.⊢ t ∈ ⟦ a ⟧tp→ ⟦_,_⟧r {Γ = Γ} (r-simp {r = r} r∈Δ r↓τ) m with ∈⟶index (All.lookup m r∈Δ) ⟦_,_⟧r {Γ = Γ} (r-simp {r = r} r∈Δ r↓τ) m | i , lookup-i≡r = ⟦ subst (λ u → _ F.⊢ F.var i ∈ u) eq (F.var i) , r↓τ , m ⟧r↓ where eq = begin lookup i ⟦ Γ ⟧ctx→ ≡⟨ sym $ lookup-⟦⟧ctx→ Γ i ⟩ ⟦ lookup i Γ ⟧tp→ ≡⟨ cong ⟦_⟧tp→ lookup-i≡r ⟩ ⟦ r ⟧tp→ ∎ ⟦_,_,_⟧r↓ : ∀ {ν n} {Δ : ICtx ν} {Γ : Ctx ν n} {a ta τ} → ⟦ Γ ⟧ctx→ F.⊢ ta ∈ ⟦ a ⟧tp→ → Δ ⊢ a ↓ τ → Γ # Δ → ∃ λ tτ → ⟦ Γ ⟧ctx→ F.⊢ tτ ∈ ⟦ simpl τ ⟧tp→ ⟦ ⊢ta , i-simp τ , m ⟧r↓ = , ⊢ta ⟦ ⊢ta , i-iabs {ρ₁ = a} ⊢ᵣa b↓τ , m ⟧r↓ = , (proj₂ ⟦ ⊢ta F.· (proj₂ ⟦ ⊢ᵣa , m ⟧r) , b↓τ , m ⟧r↓) ⟦ ⊢ta , i-tabs {ρ = a} b p , m ⟧r↓ = ⟦ subst (λ u → _ F.⊢ _ ∈ u) (sym $ ⟦a/sub⟧tp→ a b) (⊢ta F.[ ⟦ b ⟧tp→ ]) , p , m ⟧r↓ ⟦ r-iabs {ρ₁ = a} {ρ₂ = b} ⊢b , m ⟧r = , F.λ' ⟦ a ⟧tp→ (proj₂ ⟦ ⊢b , #ivar a m ⟧r) ⟦_,_⟧r {Γ = Γ} (r-tabs {ρ = r} p) m with ⟦ p , #tvar m ⟧r ⟦_,_⟧r {Δ = Δ} {Γ = Γ} (r-tabs {ρ = r} p) m | _ , x = , F.Λ (subst (λ u → u F.⊢ _ ∈ ⟦ r ⟧tp→) (⟦weaken⟧ctx→ Γ) x) open Semantics _⊢ᵣ_ DerivationSemantics.⟦_,_⟧r public
{ "alphanum_fraction": 0.5140086207, "avg_line_length": 37.12, "ext": "agda", "hexsha": "db46eb50d598924519cc7c31f95c045313b4f332", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Implicits/Resolution/Infinite/Semantics.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Implicits/Resolution/Infinite/Semantics.agda", "max_line_length": 91, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Implicits/Resolution/Infinite/Semantics.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 896, "size": 1856 }
module Issue846.DivModUtils where open import Data.Nat open import Data.Bool open import Issue846.OldDivMod open import Relation.Nullary open import Data.Nat.Properties hiding (≤-antisym) open import Data.Nat.Solver open import Data.Fin using (Fin; toℕ; zero; suc; fromℕ≤) open import Data.Fin.Properties using ( bounded; toℕ-fromℕ≤; toℕ-injective ) open import Relation.Binary.PropositionalEquality open import Function open import Data.Product open import Relation.Binary hiding (NonEmpty) open import Data.Empty open import Relation.Nullary.Negation open ≡-Reasoning open ≤-Reasoning renaming (begin_ to start_; _∎ to _□; _≡⟨_⟩_ to _≡⟨_⟩'_) open DecTotalOrder ≤-decTotalOrder using () renaming (refl to ≤-refl; antisym to ≤-antisym) i+[j∸m]≡i+j∸m : ∀ i j m → m ≤ j → i + (j ∸ m) ≡ i + j ∸ m i+[j∸m]≡i+j∸m i zero zero lt = refl i+[j∸m]≡i+j∸m i zero (suc m) () i+[j∸m]≡i+j∸m i (suc j) zero lt = refl i+[j∸m]≡i+j∸m i (suc j) (suc m) (s≤s m≤j) = begin i + (j ∸ m) ≡⟨ i+[j∸m]≡i+j∸m i j m m≤j ⟩ suc (i + j) ∸ suc m ≡⟨ cong (λ y → y ∸ suc m) $ solve 2 (λ i' j' → con 1 :+ (i' :+ j') := i' :+ (con 1 :+ j')) refl i j ⟩ (i + suc j) ∸ suc m ∎ where open +-*-Solver -- Following code taken from https://github.com/copumpkin/derpa/blob/master/REPA/Index.agda#L210 -- the next few bits are lemmas to prove uniqueness of euclidean division -- first : for nonzero divisors, a nonzero quotient would require a larger -- dividend than is consistent with a zero quotient, regardless of -- remainders. large : ∀ {d} {r : Fin (suc d)} x (r′ : Fin (suc d)) → toℕ r ≢ suc x * suc d + toℕ r′ large {d} {r} x r′ pf = irrefl pf ( start suc (toℕ r) ≤⟨ bounded r ⟩ suc d ≤⟨ m≤m+n (suc d) (x * suc d) ⟩ suc d + x * suc d -- same as (suc x * suc d) ≤⟨ m≤m+n (suc x * suc d) (toℕ r′) ⟩ suc x * suc d + toℕ r′ -- clearer in two steps, and we'd need assoc anyway □) where open ≤-Reasoning open Relation.Binary.StrictTotalOrder Data.Nat.Properties.<-strictTotalOrder -- a raw statement of the uniqueness, in the arrangement of terms that's -- easiest to work with computationally addMul-lemma′ : ∀ x x′ d (r r′ : Fin (suc d)) → x * suc d + toℕ r ≡ x′ * suc d + toℕ r′ → r ≡ r′ × x ≡ x′ addMul-lemma′ zero zero d r r′ hyp = (toℕ-injective hyp) , refl addMul-lemma′ zero (suc x′) d r r′ hyp = ⊥-elim (large x′ r′ hyp) addMul-lemma′ (suc x) zero d r r′ hyp = ⊥-elim (large x r (sym hyp)) addMul-lemma′ (suc x) (suc x′) d r r′ hyp rewrite +-assoc (suc d) (x * suc d) (toℕ r) | +-assoc (suc d) (x′ * suc d) (toℕ r′) with addMul-lemma′ x x′ d r r′ (+-cancelˡ-≡ (suc d) hyp) ... | pf₁ , pf₂ = pf₁ , cong suc pf₂ -- and now rearranged to the order that Data.Nat.DivMod uses addMul-lemma : ∀ x x′ d (r r′ : Fin (suc d)) → toℕ r + x * suc d ≡ toℕ r′ + x′ * suc d → r ≡ r′ × x ≡ x′ addMul-lemma x x′ d r r′ hyp rewrite +-comm (toℕ r) (x * suc d) | +-comm (toℕ r′) (x′ * suc d) = addMul-lemma′ x x′ d r r′ hyp DivMod-lemma : ∀ x d (r : Fin (suc d)) → (res : DivMod (toℕ r + x * suc d) (suc d)) → res ≡ result x r refl DivMod-lemma x d r (result q r′ eq) with addMul-lemma x q d r r′ eq DivMod-lemma x d r (result .x .r eq) | refl , refl = cong (result x r) (≡-irrelevance eq refl) -- holy fuck divMod-lemma : ∀ x d (r : Fin (suc d)) → (toℕ r + x * suc d) divMod suc d ≡ result x r refl divMod-lemma x d r with (toℕ r + x * suc d) divMod suc d divMod-lemma x d r | q rewrite DivMod-lemma x d r q = refl -- End of copied code mod-lemma : ∀ x d (r : Fin (suc d)) → (toℕ r + x * suc d) mod suc d ≡ r mod-lemma x d r rewrite divMod-lemma x d r = refl mod-suc : ∀ n → n mod 7 ≡ zero → suc n mod 7 ≡ suc zero mod-suc n eq with n divMod 7 mod-suc .(q * 7) refl | result q .zero refl = mod-lemma q 6 (suc zero) mod-pred : ∀ n → suc n mod 7 ≡ suc zero → n mod 7 ≡ zero mod-pred n eq with n divMod 7 mod-pred .(toℕ r + q * 7) eq | result q r refl with toℕ r ≤? 5 mod-pred .(toℕ r + q * 7) eq | result q r refl | yes p = toℕ-injective eq4 where r' = fromℕ≤ {suc (toℕ r)} {7} (s≤s (s≤s p)) r'≡r = toℕ-fromℕ≤ (s≤s (s≤s p)) eq4 = cong pred $ begin suc (toℕ r) ≡⟨ sym r'≡r ⟩ toℕ r' ≡⟨ cong toℕ $ begin r' ≡⟨ sym (mod-lemma q 6 r') ⟩ (toℕ r' + q * 7) mod 7 ≡⟨ cong (λ y → (y + q * 7) mod 7) r'≡r ⟩ suc (toℕ r + q * 7) mod 7 ≡⟨ eq ⟩ suc zero ∎ ⟩ toℕ (suc (zero {7})) ≡⟨ refl ⟩ suc zero ∎ mod-pred .(toℕ r + q * 7) eq | result q r refl | no ¬p with eq3 where eq2 = begin 6 ≡⟨ ≤-antisym (≰⇒> ¬p) (pred-mono (bounded r)) ⟩ toℕ r ∎ eq3 = begin zero ≡⟨ sym (mod-lemma (suc q) 6 zero) ⟩ (suc q * 7) mod 7 ≡⟨ refl ⟩ suc (6 + q * 7) mod 7 ≡⟨ cong (λ y → suc (y + q * 7) mod 7) $ eq2 ⟩ suc (toℕ r + q * 7) mod 7 ≡⟨ eq ⟩ suc zero ∎ ... | () ∸-mono₁ : ∀ i j k → i ≤ j → i ∸ k ≤ j ∸ k ∸-mono₁ i j zero i≤j = i≤j ∸-mono₁ zero j (suc k) i≤j = z≤n ∸-mono₁ (suc i) zero (suc k) () ∸-mono₁ (suc i) (suc j) (suc k) (s≤s i≤j) = ∸-mono₁ i j k i≤j ∸-mono₂ : ∀ i j k → j ≤ k → i ∸ j ≥ i ∸ k ∸-mono₂ i zero k j≤k = n∸m≤n k i ∸-mono₂ i (suc j) zero () ∸-mono₂ zero (suc j) (suc k) j≤k = z≤n ∸-mono₂ (suc n) (suc j) (suc k) (s≤s j≤k) = ∸-mono₂ n j k j≤k 1' : Fin 7 1' = suc zero lem-sub-p : ∀ n p → (suc n mod 7 ≡ 1') → 1 ≤ p → p ≤ 6 → ((suc n ∸ p) mod 7 ≢ 1') lem-sub-p _ 0 _ () _ _ lem-sub-p n 1 eq1 _ _ eq2 with begin zero ≡⟨ sym (mod-pred n eq1) ⟩ n mod 7 ≡⟨ eq2 ⟩ suc zero ∎ ... | () lem-sub-p n (suc (suc p)) eq _ ≤6 eq2 with n divMod 7 | mod-pred n eq lem-sub-p .0 (suc (suc p)) _ _ ≤6 () | result zero .zero refl | refl lem-sub-p .(7 + (q * 7)) (suc (suc p)) _ _ (s≤s (s≤s (≤4))) eq2 | result (suc q) .zero refl | refl = ⊥-elim $ 1+n≰n 1<1 where <7 : (6 ∸ p) < 7 <7 = s≤s (n∸m≤n p 6) eq4 = begin toℕ (fromℕ≤ <7) + q * 7 ≡⟨ cong (λ y → y + q * 7) (toℕ-fromℕ≤ <7 )⟩ (6 ∸ p) + q * 7 ≡⟨ +-comm (6 ∸ p) (q * 7) ⟩ q * 7 + (6 ∸ p) ≡⟨ i+[j∸m]≡i+j∸m (q * 7) 6 p (≤-stepsˡ 2 ≤4) ⟩ (q * 7 + 6) ∸ p ≡⟨ cong (λ y → y ∸ p) (+-comm (q * 7) 6)⟩ (6 + q * 7) ∸ p ∎ eq5 = begin fromℕ≤ <7 ≡⟨ sym (mod-lemma q 6 (fromℕ≤ <7)) ⟩ (toℕ (fromℕ≤ <7) + q * 7) mod 7 ≡⟨ cong (λ y → y mod 7) eq4 ⟩ ((6 + q * 7) ∸ p) mod 7 ≡⟨ eq2 ⟩ suc zero ∎ 1<1 = start 2 ≤⟨ ∸-mono₂ 6 p 4 ≤4 ⟩ 6 ∸ p ≡⟨ sym (toℕ-fromℕ≤ <7) ⟩' toℕ (fromℕ≤ <7) ≡⟨ cong toℕ eq5 ⟩' toℕ (suc (zero {7})) ≡⟨ refl ⟩' suc zero □ -- bla = nonEmpty
{ "alphanum_fraction": 0.502498929, "avg_line_length": 36.664921466, "ext": "agda", "hexsha": "24c9d78d232b83fee5e95bedd4efcfce531c3ea9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/LibSucceed/Issue846/DivModUtils.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/LibSucceed/Issue846/DivModUtils.agda", "max_line_length": 125, "max_stars_count": null, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/LibSucceed/Issue846/DivModUtils.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3057, "size": 7003 }
module Oscar.Property.IsReflexive where open import Oscar.Level record IsReflexive {𝔬} (⋆ : Set 𝔬) {ℓ} (_≣_ : ⋆ → ⋆ → Set ℓ) : Set (𝔬 ⊔ ℓ) where field reflexivity : ∀ x → x ≣ x
{ "alphanum_fraction": 0.6075268817, "avg_line_length": 20.6666666667, "ext": "agda", "hexsha": "6ce59e17979548e0ed67ff6c7a6d3ae09517bed4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-2/Oscar/Property/IsReflexive.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-2/Oscar/Property/IsReflexive.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-2/Oscar/Property/IsReflexive.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 83, "size": 186 }
module Impure.LFRef.Welltyped where open import Prelude open import Data.List hiding ([_]) open import Data.List.All hiding (map) open import Data.Vec as Vec hiding ([_]; map) open import Data.Star hiding (_▻▻_; map) open import Data.Sum hiding (map) open import Extensions.List as L using () open import Impure.LFRef.Syntax hiding (subst) open import Relation.Binary.List.Pointwise using (Rel) Ctx : (n : ℕ) → Set Ctx n = Vec (Type n) n -- store typings World : Set World = List (Type 0) weaken₁-tp : ∀ {n} → Type n → Type (suc n) weaken₁-tp tp = tp tp/ wk _:+:_ : ∀ {n} → Type n → Ctx n → Ctx (suc n) a :+: Γ = (weaken₁-tp a) ∷ (Vec.map (flip _tp/_ wk) Γ) weaken+-tm : ∀ {m} n → Term m → Term (n + m) weaken+-tm n t = t / (wk⋆ n) weaken+-tp : ∀ n → Type 0 → Type n weaken+-tp zero t = t weaken+-tp (suc n) t = subst Type (+-right-identity (suc n)) (t tp/ (wk⋆ (suc n))) weaken+-tele : ∀ {m n} k → Tele n m → Tele (n + k) m weaken+-tele k T = subst (flip Tele _) (+-comm k _) (T tele/ (wk⋆ k)) -- mutually inductive welltypedness judgments for kinds/types and terms respectively data _,_,_⊢_teleok : ∀ {n m} → (𝕊 : Sig) → World → Ctx n → Tele n m → Set data _,_,_⊢_::_ : ∀ {n m} (𝕊 : Sig) → World → Ctx n → Type n → Tele n m → Set data _,_,_⊢_∶_ : ∀ {n} (𝕊 : Sig) → World → Ctx n → Term n → Type n → Set data _,_,_⊢_teleok where ε : ∀ {n 𝕊 Σ} {Γ : Ctx n} → 𝕊 , Σ , Γ ⊢ ε teleok _⟶_ : ∀ {n m 𝕊 Σ Γ} {A : Type n} {K : Tele (suc n) m}→ 𝕊 , Σ , Γ ⊢ A :: ε → 𝕊 , Σ , (A :+: Γ) ⊢ K teleok → 𝕊 , Σ , Γ ⊢ (A ⟶ K) teleok data _,_,_⊢_∶ⁿ_ {n} (𝕊 : Sig) (Σ : World) (Γ : Ctx n) : ∀ {m} → List (Term n) → Tele n m → Set where ε : 𝕊 , Σ , Γ ⊢ [] ∶ⁿ ε _⟶_ : ∀ {m A t ts} {B : Tele (suc n) m}→ 𝕊 , Σ , Γ ⊢ t ∶ A → 𝕊 , Σ , Γ ⊢ ts ∶ⁿ (B tele/ (sub t)) → 𝕊 , Σ , Γ ⊢ (t ∷ ts) ∶ⁿ (A ⟶ B) -- specialize the returntype from a constructor from it's welltyped arguments _con[_/_] : ∀ {n} → (C : ConType) → (ts : List (Term n)) → length ts ≡ (ConType.m C) → Type n _con[_/_] {n} C ts p = (ConType.tp C) [ map (flip _/_ (subst (Vec _) p (fromList ts))) (ConType.indices C) ] -- specialize the return type of a function from it's welltyped arguments _fun[_/_] : ∀ {n m} → Type m → (ts : List (Term n)) → length ts ≡ m → Type n _fun[_/_] {n} {m} a ts p = a tp/ subst (Vec _) p ((fromList ts)) data _,_,_⊢_::_ where Ref : ∀ {n 𝕊 Σ} {Γ : Ctx n} {A} → 𝕊 , Σ , Γ ⊢ A :: ε → ---------------------- 𝕊 , Σ , Γ ⊢ Ref A :: ε Unit : ∀ {n 𝕊 Σ} {Γ : Ctx n} → --------------------- 𝕊 , Σ , Γ ⊢ Unit :: ε _[_] : ∀ {n 𝕊 Σ} {Γ : Ctx n} {k K ts} → (Sig.types 𝕊) L.[ k ]= K → 𝕊 , [] , [] ⊢ (proj₂ K) teleok → 𝕊 , Σ , Γ ⊢ ts ∶ⁿ (weaken+-tele n (proj₂ K)) → ------------------------- 𝕊 , Σ , Γ ⊢ k [ ts ] :: ε data _,_,_⊢_∶_ where unit : ∀ {n 𝕊 Σ} {Γ : Ctx n} → ----------------------- 𝕊 , Σ , Γ ⊢ unit ∶ Unit var : ∀ {n 𝕊 Σ} {Γ : Ctx n} {i A} → Γ [ i ]= A → --------------------- 𝕊 , Σ , Γ ⊢ var i ∶ A con : ∀ {n 𝕊 Σ} {Γ : Ctx n} {c C ts} → (Sig.constructors 𝕊) L.[ c ]= C → (p : 𝕊 , Σ , Γ ⊢ ts ∶ⁿ weaken+-tele n (ConType.args C)) → (q : length ts ≡ (ConType.m C)) → ------------------------------------ 𝕊 , Σ , Γ ⊢ con c ts ∶ (C con[ ts / q ]) loc : ∀ {n 𝕊 Σ} {Γ : Ctx n} {i S} → Σ L.[ i ]= S → --------------------- 𝕊 , Σ , Γ ⊢ loc i ∶ Ref (weaken+-tp n S) data _,_,_⊢ₑ_∶_ : ∀ {n} (𝕊 : Sig) → World → Ctx n → Exp n → Type n → Set where tm : ∀ {n t} {Γ : Ctx n} {𝕊 Σ A} → 𝕊 , Σ , Γ ⊢ t ∶ A → --------------------- 𝕊 , Σ , Γ ⊢ₑ tm t ∶ A _·★[_]_ : ∀ {n fn ts 𝕊 Σ φ} {Γ : Ctx n} → (Sig.funs 𝕊) L.[ fn ]= φ → (q : length ts ≡ (Fun.m φ)) → (p : 𝕊 , Σ , Γ ⊢ ts ∶ⁿ weaken+-tele n (Fun.args φ)) → ----------------------------------------------------- 𝕊 , Σ , Γ ⊢ₑ (fn ·★ ts) ∶ ((Fun.returntype φ) fun[ ts / q ]) ref : ∀ {n x A 𝕊 Σ} {Γ : Ctx n} → 𝕊 , Σ , Γ ⊢ₑ x ∶ A → -------------------------- 𝕊 , Σ , Γ ⊢ₑ ref x ∶ Ref A !_ : ∀ {n x A} {Γ : Ctx n} {𝕊 Σ} → 𝕊 , Σ , Γ ⊢ₑ x ∶ Ref A → ---------------------- 𝕊 , Σ , Γ ⊢ₑ (! x) ∶ A _≔_ : ∀ {n i x A} {Γ : Ctx n} {𝕊 Σ} → 𝕊 , Σ , Γ ⊢ₑ i ∶ Ref A → 𝕊 , Σ , Γ ⊢ₑ x ∶ A → -------------------------- 𝕊 , Σ , Γ ⊢ₑ (i ≔ x) ∶ Unit data _,_,_⊢ₛ_∶_ : ∀ {n} (𝕊 : Sig) → World → Ctx n → SeqExp n → Type n → Set where ret : ∀ {n x A 𝕊 Σ} {Γ : Ctx n} → 𝕊 , Σ , Γ ⊢ₑ x ∶ A → --------------------- 𝕊 , Σ , Γ ⊢ₛ ret x ∶ A lett : ∀ {n x c A B 𝕊 Σ} {Γ : Ctx n} → 𝕊 , Σ , Γ ⊢ₑ x ∶ A → 𝕊 , (Σ) , (A :+: Γ) ⊢ₛ c ∶ weaken₁-tp B → ---------------------------------------r 𝕊 , Σ , Γ ⊢ₛ lett x c ∶ B -- telescopes as context transformers _⊢⟦_⟧ : ∀ {n m} → Ctx n → Tele n m → Ctx (n + m) Γ ⊢⟦ ε ⟧ = subst Ctx (sym $ +-right-identity _) Γ _⊢⟦_⟧ {n} Γ (_⟶_ {m = m} x T) = subst Ctx (sym $ +-suc n m) ((x :+: Γ) ⊢⟦ T ⟧) _⊢_fnOk : Sig → Fun → Set _⊢_fnOk 𝕊 φ = 𝕊 , [] , ([] ⊢⟦ Fun.args φ ⟧) ⊢ₑ (Fun.body φ) ∶ (Fun.returntype φ) -- valid signature contexts record _,_⊢ok {n} (𝕊 : Sig) (Γ : Ctx n) : Set where field funs-ok : All (λ x → 𝕊 ⊢ x fnOk) (Sig.funs 𝕊) -- store welltypedness relation -- as a pointwise lifting of the welltyped relation on closed expressions between a world and a store _,_⊢_ : Sig → World → Store → Set _,_⊢_ 𝕊 Σ μ = Rel (λ A x → 𝕊 , Σ , [] ⊢ (proj₁ x) ∶ A) Σ μ -- a useful lemma about telescoped terms tele-fit-length : ∀ {n m 𝕊 Σ Γ ts} {T : Tele n m} → 𝕊 , Σ , Γ ⊢ ts ∶ⁿ T → length ts ≡ m tele-fit-length ε = refl tele-fit-length (x ⟶ p) with tele-fit-length p tele-fit-length (x ⟶ p) | refl = refl
{ "alphanum_fraction": 0.4370940171, "avg_line_length": 32.1428571429, "ext": "agda", "hexsha": "53be2ad5017deb5706837113dc65e4a040889409", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Impure/LFRef/Welltyped.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Impure/LFRef/Welltyped.agda", "max_line_length": 101, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Impure/LFRef/Welltyped.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2581, "size": 5850 }
------------------------------------------------------------------------ -- Lemmas related to application of substitutions ------------------------------------------------------------------------ open import Data.Universe.Indexed module deBruijn.Substitution.Data.Application.Application221 {i u e} {Uni : IndexedUniverse i u e} where import deBruijn.Context; open deBruijn.Context Uni open import deBruijn.Substitution.Data.Application.Application21 open import deBruijn.Substitution.Data.Basics open import deBruijn.Substitution.Data.Map open import deBruijn.Substitution.Data.Simple open import Function using (_$_) open import Level using (_⊔_) import Relation.Binary.PropositionalEquality as P open P.≡-Reasoning -- Lemmas related to application. record Application₂₂₁ {t₁} {T₁ : Term-like t₁} {t₂} {T₂ : Term-like t₂} -- Simple substitutions for the first kind of terms. (simple₁ : Simple T₁) -- Simple substitutions for the second kind of terms. (simple₂ : Simple T₂) -- A translation from the first to the second kind of terms. (trans : [ T₁ ⟶⁼ T₂ ]) : Set (i ⊔ u ⊔ e ⊔ t₁ ⊔ t₂) where open Term-like T₂ using ([_]) renaming (_⊢_ to _⊢₂_; _≅-⊢_ to _≅-⊢₂_) open Simple simple₁ using () renaming ( wk to wk₁; wk[_] to wk₁[_]; wk-subst to wk-subst₁ ; _↑ to _↑₁; _↑_ to _↑₁_; _↑⁺_ to _↑⁺₁_; _↑⁺⋆_ to _↑⁺⋆₁_ ) open Simple simple₂ using () renaming ( var to var₂ ; weaken to weaken₂; weaken[_] to weaken₂[_] ; wk[_] to wk₂[_] ; wk-subst to wk-subst₂; wk-subst[_] to wk-subst₂[_] ; _↑ to _↑₂ ) field application₂₁ : Application₂₁ simple₁ simple₂ trans open Application₂₁ application₂₁ field -- Lifts equalities valid for all variables and liftings to -- arbitrary terms. var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} (ρs₁ : Subs T₁ ρ̂) (ρs₂ : Subs T₁ ρ̂) → (∀ Γ⁺ {σ} (x : Γ ++⁺ Γ⁺ ∋ σ) → var₂ · x /⊢⋆ ρs₁ ↑⁺⋆₁ Γ⁺ ≅-⊢₂ var₂ · x /⊢⋆ ρs₂ ↑⁺⋆₁ Γ⁺) → ∀ Γ⁺ {σ} (t : Γ ++⁺ Γ⁺ ⊢₂ σ) → t /⊢⋆ ρs₁ ↑⁺⋆₁ Γ⁺ ≅-⊢₂ t /⊢⋆ ρs₂ ↑⁺⋆₁ Γ⁺ -- The wk substitution and the weaken function are equivalent. /⊢-wk : ∀ {Γ σ τ} (t : Γ ⊢₂ τ) → t /⊢ wk₁[ σ ] ≅-⊢₂ weaken₂[ σ ] · t abstract -- wk-subst is equivalent to composition with wk. ∘-wk : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} (ρ : Sub T₂ ρ̂) → ρ ∘ wk₁[ σ ] ≅-⇨ wk-subst₂[ σ ] ρ ∘-wk ρ = begin [ map (app wk₁) ρ ] ≡⟨ map-cong-ext₁ P.refl /⊢-wk (P.refl {x = [ ρ ]}) ⟩ [ map weaken₂ ρ ] ∎ -- The wk substitution commutes (modulo lifting etc.) with any -- other. -- -- TODO: Prove this lemma using /⊢-/⊢-wk? wk-∘-↑ : ∀ {Γ Δ} σ {ρ̂ : Γ ⇨̂ Δ} (ρ : Sub T₁ ρ̂) → map trans ρ ∘ wk₁[ σ / ρ ] ≅-⇨ wk₂[ σ ] ∘ ρ ↑₁ wk-∘-↑ σ ρ = extensionality P.refl λ x → begin [ x /∋ map trans ρ ∘ wk₁ ] ≡⟨ /∋-cong (P.refl {x = [ x ]}) (∘-wk (map trans ρ)) ⟩ [ x /∋ wk-subst₂ (map trans ρ) ] ≡⟨ P.sym $ Simple.suc-/∋-↑ simple₂ σ x (map trans ρ) ⟩ [ suc[ σ ] x /∋ map trans ρ ↑₂ ] ≡⟨ /∋-cong (P.refl {x = [ suc[ σ ] x ]}) (P.sym $ map-trans-↑ ρ) ⟩ [ suc[ σ ] x /∋ map trans (ρ ↑₁) ] ≡⟨ /∋-map (suc[ σ ] x) trans (ρ ↑₁) ⟩ [ trans · (suc[ σ ] x /∋ ρ ↑₁) ] ≡⟨ P.sym $ var-/⊢ (suc[ σ ] x) (ρ ↑₁) ⟩ [ var₂ · suc[ σ ] x /⊢ ρ ↑₁ ] ≡⟨ /⊢-cong (P.sym $ Simple./∋-wk simple₂ {σ = σ} x) (P.refl {x = [ ρ ↑₁ ]}) ⟩ [ x /∋ wk₂[ σ ] /⊢ ρ ↑₁ ] ≡⟨ P.sym $ /∋-∘ x wk₂[ σ ] (ρ ↑₁) ⟩ [ x /∋ wk₂[ σ ] ∘ ρ ↑₁ ] ∎ -- A variant of suc-/∋-↑. var-suc-/⊢-↑ : ∀ {Γ Δ} σ {τ} {ρ̂ : Γ ⇨̂ Δ} (x : Γ ∋ τ) (ρ : Sub T₁ ρ̂) → var₂ · suc[ σ ] x /⊢ ρ ↑₁ ≅-⊢₂ var₂ · x /⊢ ρ /⊢ wk₁[ σ / ρ ] var-suc-/⊢-↑ σ x ρ = let lemma₁ = begin [ x /∋ map trans ρ ] ≡⟨ /∋-map x trans ρ ⟩ [ trans · (x /∋ ρ) ] ≡⟨ P.sym $ var-/⊢ x ρ ⟩ [ var₂ · x /⊢ ρ ] ∎ lemma₂ = begin [ map trans (wk-subst₁ ρ) ] ≡⟨ map-trans-wk-subst ρ ⟩ [ wk-subst₂ (map trans ρ) ] ≡⟨ P.sym $ ∘-wk (map trans ρ) ⟩ [ map trans ρ ∘ wk₁ ] ∎ in begin [ var₂ · suc[ σ ] x /⊢ ρ ↑₁ ] ≡⟨ var-/⊢ (suc[ σ ] x) (ρ ↑₁) ⟩ [ trans · (suc[ σ ] x /∋ ρ ↑₁) ] ≡⟨ trans-cong (Simple.suc-/∋-↑ simple₁ σ x ρ) ⟩ [ trans · (x /∋ wk-subst₁ ρ) ] ≡⟨ P.sym $ /∋-map x trans (wk-subst₁ ρ) ⟩ [ x /∋ map trans (wk-subst₁ ρ) ] ≡⟨ /∋-cong (P.refl {x = [ x ]}) lemma₂ ⟩ [ x /∋ map trans ρ ∘ wk₁ ] ≡⟨ /∋-∘ x (map trans ρ) wk₁ ⟩ [ x /∋ map trans ρ /⊢ wk₁ ] ≡⟨ /⊢-cong lemma₁ (P.refl {x = [ wk₁ ]}) ⟩ [ var₂ · x /⊢ ρ /⊢ wk₁ ] ∎ private -- wk ↑⁺ Γ⁺ and wk commute (more or less). -- -- This lemma is an instance of /⊢-/⊢-wk, which is proved below -- using, among other things, this lemma. /⊢-wk-↑⁺-/⊢-wk : ∀ {Γ} σ Γ⁺ τ {υ} (t : Γ ++⁺ Γ⁺ ⊢₂ υ) → let wk-σ = wk₁[ σ ] ↑⁺₁ Γ⁺ in t /⊢ wk-σ /⊢ wk₁[ τ / wk-σ ] ≅-⊢₂ t /⊢ wk₁ /⊢ wk₁[ σ ] ↑⁺₁ (Γ⁺ ▻ τ) /⊢-wk-↑⁺-/⊢-wk σ Γ⁺ τ t = var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆ (ε ▻ wk₁[ σ ] ↑⁺₁ Γ⁺ ▻ wk₁[ τ / wk₁ ↑⁺₁ Γ⁺ ]) (ε ▻ wk₁ ▻ wk₁ ↑⁺₁ (Γ⁺ ▻ τ)) (λ Γ⁺⁺ x → begin [ var₂ · x /⊢⋆ (ε ▻ wk₁ ↑⁺₁ Γ⁺ ▻ wk₁) ↑⁺⋆₁ Γ⁺⁺ ] ≡⟨ /⊢⋆-ε-▻-▻-↑⁺⋆ Γ⁺⁺ (var₂ · x) (wk₁ ↑⁺₁ Γ⁺) wk₁ ⟩ [ var₂ · x /⊢ wk₁ ↑⁺₁ Γ⁺ ↑⁺₁ Γ⁺⁺ /⊢ wk₁ ↑⁺₁ (Γ⁺⁺ /⁺ wk₁ ↑⁺₁ Γ⁺) ] ≡⟨ /⊢-cong (var-/⊢-wk-↑⁺-↑⁺ Γ⁺ Γ⁺⁺ x) P.refl ⟩ [ var₂ · (lift (lift weaken∋ Γ⁺) Γ⁺⁺ · x) /⊢ wk₁ ↑⁺₁ (Γ⁺⁺ /⁺ wk₁ ↑⁺₁ Γ⁺) ] ≡⟨ var-/⊢-wk-↑⁺ (Γ⁺⁺ /⁺ wk₁ ↑⁺₁ Γ⁺) (lift (lift weaken∋ Γ⁺) Γ⁺⁺ · x) ⟩ [ var₂ · (lift weaken∋ (Γ⁺⁺ /⁺ wk₁ ↑⁺₁ Γ⁺) · (lift (lift weaken∋ Γ⁺) Γ⁺⁺ · x)) ] ≡⟨ Simple.var-cong simple₂ (lift-weaken∋-lift-lift-weaken∋ σ Γ⁺ τ Γ⁺⁺ x) ⟩ [ var₂ · (lift (lift weaken∋ (Γ⁺ ▻ τ)) (Γ⁺⁺ /⁺ wk₁) · (lift weaken∋ Γ⁺⁺ · x)) ] ≡⟨ P.sym $ var-/⊢-wk-↑⁺-↑⁺ (Γ⁺ ▻ τ) (Γ⁺⁺ /⁺ wk₁) (lift weaken∋ Γ⁺⁺ · x) ⟩ [ var₂ · (lift weaken∋ Γ⁺⁺ · x) /⊢ wk₁[ σ ] ↑⁺₁ (Γ⁺ ▻ τ) ↑⁺₁ (Γ⁺⁺ /⁺ wk₁) ] ≡⟨ P.sym $ /⊢-cong (var-/⊢-wk-↑⁺ Γ⁺⁺ x) P.refl ⟩ [ var₂ · x /⊢ wk₁ ↑⁺₁ Γ⁺⁺ /⊢ wk₁[ σ ] ↑⁺₁ (Γ⁺ ▻ τ) ↑⁺₁ (Γ⁺⁺ /⁺ wk₁) ] ≡⟨ P.sym $ /⊢⋆-ε-▻-▻-↑⁺⋆ Γ⁺⁺ (var₂ · x) wk₁ (wk₁[ σ ] ↑⁺₁ (Γ⁺ ▻ τ)) ⟩ [ var₂ · x /⊢⋆ (ε ▻ wk₁ ▻ wk₁[ σ ] ↑⁺₁ (Γ⁺ ▻ τ)) ↑⁺⋆₁ Γ⁺⁺ ] ∎) ε t -- Another lemma used in the proof of /⊢-/⊢-wk. var-/⊢-↑⁺-/⊢-wk-↑⁺ : ∀ {Γ Δ} σ {ρ̂ : Γ ⇨̂ Δ} (ρ : Sub T₁ ρ̂) Γ⁺ {υ} (x : Γ ++⁺ Γ⁺ ∋ υ) → var₂ · x /⊢ ρ ↑⁺₁ Γ⁺ /⊢ wk₁[ σ / ρ ] ↑⁺₁ (Γ⁺ /⁺ ρ) ≅-⊢₂ var₂ · (lift weaken∋[ σ ] Γ⁺ · x) /⊢ ρ ↑₁ ↑⁺₁ (Γ⁺ /⁺ wk₁) var-/⊢-↑⁺-/⊢-wk-↑⁺ σ ρ ε x = P.sym $ var-suc-/⊢-↑ σ x ρ var-/⊢-↑⁺-/⊢-wk-↑⁺ σ ρ (Γ⁺ ▻ τ) zero = begin [ var₂ · zero /⊢ ρ ↑⁺₁ (Γ⁺ ▻ τ) /⊢ wk₁ ↑⁺₁ ((Γ⁺ ▻ τ) /⁺ ρ) ] ≡⟨ /⊢-cong (zero-/⊢-↑ τ (ρ ↑⁺₁ Γ⁺)) (P.refl {x = [ wk₁ ↑⁺₁ ((Γ⁺ ▻ τ) /⁺ ρ) ]}) ⟩ [ var₂ · zero /⊢ wk₁ ↑⁺₁ ((Γ⁺ ▻ τ) /⁺ ρ) ] ≡⟨ zero-/⊢-↑ (τ / ρ ↑⁺₁ Γ⁺) (wk₁ ↑⁺₁ (Γ⁺ /⁺ ρ)) ⟩ [ var₂ · zero ] ≡⟨ Simple.var-cong simple₂ (zero-cong (/̂-↑̂⁺-/̂-ŵk-↑̂⁺ σ ⟦ ρ ⟧⇨ Γ⁺ τ)) ⟩ [ var₂ · zero ] ≡⟨ P.sym $ zero-/⊢-↑ (τ / wk₁ ↑⁺₁ Γ⁺) (ρ ↑₁ σ ↑⁺₁ (Γ⁺ /⁺ wk₁)) ⟩ [ var₂ · zero /⊢ ρ ↑₁ σ ↑⁺₁ ((Γ⁺ ▻ τ) /⁺ wk₁) ] ∎ var-/⊢-↑⁺-/⊢-wk-↑⁺ σ ρ (Γ⁺ ▻ τ) (suc x) = begin [ var₂ · suc x /⊢ ρ ↑⁺₁ (Γ⁺ ▻ τ) /⊢ wk₁ ↑⁺₁ ((Γ⁺ ▻ τ) /⁺ ρ) ] ≡⟨ /⊢-cong (var-suc-/⊢-↑ τ x (ρ ↑⁺₁ Γ⁺)) (P.refl {x = [ wk₁ ↑⁺₁ ((Γ⁺ ▻ τ) /⁺ ρ) ]}) ⟩ [ var₂ · x /⊢ ρ ↑⁺₁ Γ⁺ /⊢ wk₁ /⊢ wk₁ ↑⁺₁ ((Γ⁺ ▻ τ) /⁺ ρ) ] ≡⟨ P.sym $ /⊢-wk-↑⁺-/⊢-wk (σ / ρ) (Γ⁺ /⁺ ρ) (τ / ρ ↑⁺₁ Γ⁺) (var₂ · x /⊢ ρ ↑⁺₁ Γ⁺) ⟩ [ var₂ · x /⊢ ρ ↑⁺₁ Γ⁺ /⊢ wk₁[ σ / ρ ] ↑⁺₁ (Γ⁺ /⁺ ρ) /⊢ wk₁[ τ / ρ ↑⁺₁ Γ⁺ / wk₁ ↑⁺₁ (Γ⁺ /⁺ ρ) ] ] ≡⟨ /⊢-cong (var-/⊢-↑⁺-/⊢-wk-↑⁺ σ ρ Γ⁺ x) (Simple.wk-cong simple₁ (/̂-↑̂⁺-/̂-ŵk-↑̂⁺ σ ⟦ ρ ⟧⇨ Γ⁺ τ)) ⟩ [ var₂ · (lift weaken∋[ σ ] Γ⁺ · x) /⊢ ρ ↑₁ ↑⁺₁ (Γ⁺ /⁺ wk₁) /⊢ wk₁ ] ≡⟨ P.sym $ var-suc-/⊢-↑ (τ / wk₁ ↑⁺₁ Γ⁺) (lift weaken∋[ σ ] Γ⁺ · x) (ρ ↑₁ ↑⁺₁ (Γ⁺ /⁺ wk₁)) ⟩ [ var₂ · suc (lift weaken∋[ σ ] Γ⁺ · x) /⊢ ρ ↑₁ ↑⁺₁ ((Γ⁺ ▻ τ) /⁺ wk₁) ] ∎ -- The wk substitution commutes (modulo lifting etc.) with any -- other. /⊢-/⊢-wk : ∀ {Γ Δ} σ {τ} {ρ̂ : Γ ⇨̂ Δ} (t : Γ ⊢₂ τ) (ρ : Sub T₁ ρ̂) → t /⊢ ρ /⊢ wk₁[ σ / ρ ] ≅-⊢₂ t /⊢ wk₁[ σ ] /⊢ ρ ↑₁ /⊢-/⊢-wk σ t ρ = var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆ (ε ▻ ρ ▻ wk₁) (ε ▻ wk₁[ σ ] ▻ ρ ↑₁) (λ Γ⁺ x → begin [ var₂ · x /⊢⋆ (ε ▻ ρ ▻ wk₁) ↑⁺⋆₁ Γ⁺ ] ≡⟨ /⊢⋆-ε-▻-▻-↑⁺⋆ Γ⁺ (var₂ · x) ρ wk₁ ⟩ [ var₂ · x /⊢ ρ ↑⁺₁ Γ⁺ /⊢ wk₁ ↑⁺₁ (Γ⁺ /⁺ ρ) ] ≡⟨ var-/⊢-↑⁺-/⊢-wk-↑⁺ σ ρ Γ⁺ x ⟩ [ var₂ · (lift weaken∋[ σ ] Γ⁺ · x) /⊢ ρ ↑₁ ↑⁺₁ (Γ⁺ /⁺ wk₁) ] ≡⟨ /⊢-cong (P.sym $ var-/⊢-wk-↑⁺ {σ = σ} Γ⁺ x) (P.refl {x = [ ρ ↑₁ ↑⁺₁ (Γ⁺ /⁺ wk₁) ]}) ⟩ [ var₂ · x /⊢ wk₁[ σ ] ↑⁺₁ Γ⁺ /⊢ ρ ↑₁ ↑⁺₁ (Γ⁺ /⁺ wk₁) ] ≡⟨ P.sym $ /⊢⋆-ε-▻-▻-↑⁺⋆ Γ⁺ (var₂ · x) wk₁[ σ ] (ρ ↑₁) ⟩ [ var₂ · x /⊢⋆ (ε ▻ wk₁[ σ ] ▻ ρ ↑₁) ↑⁺⋆₁ Γ⁺ ] ∎) ε t open Application₂₁ application₂₁ public
{ "alphanum_fraction": 0.3425753629, "avg_line_length": 51.180952381, "ext": "agda", "hexsha": "bba0e035d49c4e76c691407bfd3c50498c7440a4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/dependently-typed-syntax", "max_forks_repo_path": "deBruijn/Substitution/Data/Application/Application221.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/dependently-typed-syntax", "max_issues_repo_path": "deBruijn/Substitution/Data/Application/Application221.agda", "max_line_length": 136, "max_stars_count": 5, "max_stars_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/dependently-typed-syntax", "max_stars_repo_path": "deBruijn/Substitution/Data/Application/Application221.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-08T22:51:36.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T12:14:44.000Z", "num_tokens": 5169, "size": 10748 }
module OverloadedConInParamModule where data A : Set where module M (X : Set) where data B : Set where c : B data C : Set where c : C open M A f : B f = c
{ "alphanum_fraction": 0.612716763, "avg_line_length": 10.1764705882, "ext": "agda", "hexsha": "e89491833b04cf41021f7267421b9279c397db3d", "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/OverloadedConInParamModule.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/OverloadedConInParamModule.agda", "max_line_length": 39, "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/OverloadedConInParamModule.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": 61, "size": 173 }
-- Copyright: (c) 2016 Ertugrul Söylemez -- License: BSD3 -- Maintainer: Ertugrul Söylemez <[email protected]> module Data.Mod where open import Core open import Data.Int.Core hiding (module Props) import Data.Int.Core as ℤ open import Data.Nat.Core using (ℕ) import Data.Nat.Core as ℕ private module ℤP = ℤ.Props ModEq : ℕ → Equiv ℤ ModEq n = record { _≈_ = _≈_; refl = λ {x} → 0 , ℤP.+-right-inv x; sym = λ {x} {y} → sym' x y; trans = λ {x} {y} {z} → trans' x y z } where infix 4 _≈_ _≈_ : ℤ → ℤ → Set x ≈ y = ∃ (λ k → x - y ≡ k * pos n) sym' : ∀ x y → x ≈ y → y ≈ x sym' x y (k , p) = neg k , (begin y - x || sym (ℤP.neg-flip x y) :: neg (x - y) || cong neg p :: neg (k * pos n) || sym (ℤP.*-assoc -1 k (pos n)) :: neg k * pos n qed) where open Equiv (PropEq ℤ) trans' : ∀ x y z → x ≈ y → y ≈ z → x ≈ z trans' x y z (k1 , p1) (k2 , p2) = k1 + k2 , (begin x - z || cong (x +_) (sym (ℤP.+-left-id (neg z))) :: x + (0 - z) || cong (λ a → x + (a - z)) (sym (ℤP.+-left-inv y)) :: x + (neg y + y - z) || cong (x +_) (ℤP.+-assoc (neg y) y (neg z)) :: x + (neg y + (y - z)) || sym (ℤP.+-assoc x (neg y) (y + neg z)) :: x + neg y + (y - z) || cong2 _+_ p1 p2 :: k1 * pos n + k2 * pos n || sym (ℤP.*-+-right-dist k1 k2 (pos n)) :: (k1 + k2) * pos n qed) where open Equiv (PropEq ℤ) module Props (n : ℕ) where open Equiv (ModEq n) using (_≈_) open Equiv (PropEq ℤ) hiding (_≈_) +-cong : ∀ {x1 x2 y1 y2} → x1 ≈ x2 → y1 ≈ y2 → x1 + y1 ≈ x2 + y2 +-cong {x1} {x2} {y1} {y2} (k1 , p1) (k2 , p2) = k1 + k2 , (begin x1 + y1 - (x2 + y2) || ℤP.+-assoc x1 y1 _ :: x1 + (y1 - (x2 + y2)) || cong (x1 +_) ( y1 - (x2 + y2) || cong (y1 +_) (ℤP.*-+-left-dist -1 x2 y2) :: y1 + (neg x2 + neg y2) || sym (ℤP.+-assoc y1 (neg x2) (neg y2)) :: (y1 + neg x2 + neg y2) || cong (_+ neg y2) (ℤP.+-comm y1 (neg x2)) :: neg x2 + y1 + neg y2 || ℤP.+-assoc (neg x2) y1 _ :: neg x2 + (y1 + neg y2) qed) :: x1 + (neg x2 + (y1 + neg y2)) || sym (ℤP.+-assoc x1 (neg x2) _) :: x1 - x2 + (y1 - y2) || cong2 _+_ p1 p2 :: k1 * pos n + k2 * pos n || sym (ℤP.*-+-right-dist k1 k2 (pos n)) :: (k1 + k2) * pos n qed)
{ "alphanum_fraction": 0.4426501035, "avg_line_length": 28.75, "ext": "agda", "hexsha": "9a0f5d67026ba16684d6c0080155d6aed3064c3c", "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": "d9245e5a8b2e902781736de09bd17e81022f6f13", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "esoeylemez/agda-simple", "max_forks_repo_path": "Data/Mod.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d9245e5a8b2e902781736de09bd17e81022f6f13", "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": "esoeylemez/agda-simple", "max_issues_repo_path": "Data/Mod.agda", "max_line_length": 84, "max_stars_count": 1, "max_stars_repo_head_hexsha": "d9245e5a8b2e902781736de09bd17e81022f6f13", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "esoeylemez/agda-simple", "max_stars_repo_path": "Data/Mod.agda", "max_stars_repo_stars_event_max_datetime": "2019-10-07T17:36:42.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-07T17:36:42.000Z", "num_tokens": 1061, "size": 2415 }
module L.Base.Sigma where -- Reexport definitions open import L.Base.Sigma.Core public
{ "alphanum_fraction": 0.7954545455, "avg_line_length": 17.6, "ext": "agda", "hexsha": "0b42cf652e344bc866b1857de6bc49ecc65ae43e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "borszag/smallib", "max_forks_repo_path": "src/L/Base/Sigma.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_issues_repo_issues_event_max_datetime": "2020-11-09T16:40:39.000Z", "max_issues_repo_issues_event_min_datetime": "2020-10-19T10:13:16.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "borszag/smallib", "max_issues_repo_path": "src/L/Base/Sigma.agda", "max_line_length": 36, "max_stars_count": null, "max_stars_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "borszag/smallib", "max_stars_repo_path": "src/L/Base/Sigma.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 21, "size": 88 }
open import Prelude renaming (_++_ to _++-List_) open import Data.Maybe using (Maybe; just; nothing; maybe; From-just) open import Data.Fin using (Fin; toℕ) renaming (inject+ to finject; raise to fraise; zero to fzero; suc to fsuc) open import Data.List.All as A open import Data.Vec using (Vec; _∷_; []) open import Data.Nat renaming (decTotalOrder to decTotalOrder-ℕ) open import Relation.Binary using (module DecTotalOrder) module RW.Language.Instantiation where open import RW.Language.RTerm open import RW.Language.FinTerm -------------------------------------------------- -- Monadic Boilerplate open import RW.Utils.Monads open Monad {{...}} _<$>_ : ∀{a b}{A : Set a}{B : Set b} → (A → B) → Maybe A → Maybe B _ <$> nothing = nothing f <$> (just x) = just (f x) _<*>_ : ∀{a b}{A : Set a}{B : Set b} → Maybe (A → B) → Maybe A → Maybe B just f <*> just x = just (f x) _ <*> _ = nothing {- mapM : {A B : Set} → (A → Maybe B) → List A → Maybe (List B) mapM f = Prelude.foldr (λ a → maybe (λ x → flip _∷_ x <$> f a) nothing) (just []) -} ------------------------------------------------- -- Partial Substitutions -- -- The complexity annotations might require -- a slight notational introduction. -- -- If a variable name overlaps one in the corresponding type signature, -- this is intentional. -- -- Sₜ is defined by (S t), module RW.Language.RTermUtils. -- #Fvₜ is defined by length (Fv t), where Fv is also in RTermUtils. -- X : ℕ → Set X = Vec (Maybe (RTerm ⊥)) -- O(n) empty-X : {n : ℕ} → X n empty-X {zero} = [] empty-X {suc n} = nothing ∷ empty-X -- O(n) lookup-X : {n : ℕ} → Fin n → X n → Maybe (RTerm ⊥) lookup-X fz (x ∷ _) = x lookup-X (fs i) (_ ∷ s) = lookup-X i s -- Let n be the number of free variables, and Sₜ be the size of our term t. -- We'll denote by #Fvₜ the number of free variables actually occuring in t. -- -- O(Sₜ + n × # Fvₜ) -- -- Still, on the average case, we can expect that each (i ∈ Fin n) will -- occur in a (FinTerm n), therefore # Fvₜ ≥ n. So, we have, -- -- # Fvₜ ≥ n -- ⇒ n × # Fvₜ ≥ n² -- ⇒ Sₜ + n × # Fvₜ ≥ Sₜ + n² -- -- For calculational purposes, then, we might consider that apply-X function -- have a complexity of O(n²). {-# TERMINATING #-} apply-X : {n : ℕ} → X n → FinTerm n → Maybe (RTerm ⊥) apply-X s (ovar x) = lookup-X x s apply-X s (ivar n) = just (ivar n) apply-X s (rlit l) = just (rlit l) apply-X s (rlam t) = rlam <$> apply-X s t apply-X s (rapp n ts) = rapp n <$> mapM (apply-X s) ts -- The worst case of extending a partial substitution is -- asking to extend the last index on an already defined -- term, that is, n recursive calls on the last branch and -- finishing on the branch marked (§). comparing (t ≟-RTerm u) -- is O(min(Sₜ , Sᵤ)). -- -- Therefore, -- -- O(n + min(Sₜ , Sᵤ)) extend-X : {n : ℕ} → Fin n → RTerm ⊥ → X n → Maybe (X n) extend-X fz t (nothing ∷ s) = just (just t ∷ s) extend-X fz t (just t′ ∷ s) with t ≟-RTerm t′ ...| yes _ = just (just t ∷ s) -- (§) ...| no _ = nothing extend-X (fs i) t (mt ∷ s) = _∷_ mt <$> extend-X i t s ------------------------------ -- * Instantiation -- Taking a close look to instAcc, we can see that the only real operation it performs -- is extend-X, on the first branch. The rest is pretty much traversing down the term -- with a possibility of failing (nothing). -- -- Assuming (t : FinTerm n), Sₜ is the size of t and #Fvₜ is the number of -- free variables in t. -- -- instAcc t j empty ∈ O(Sₜ + #Fvₜ × (n + min(Sₜ , Sⱼ)ᴬ )) -- -- [ᴬ]: This is not really the size of t, but of the corresponding term sent to extend, -- which is ALWAYS smaller than or equal to Sₜ. -- -- Without loss of generality, let's assume that the subterms of t are always -- smaller than their corresponding counterparts in j, allowing us -- to simplify min(Sₜ , Sⱼ) to Sₜ. -- -- O(Sₜ + #Fvₜ × (n + Sₜ)) -- O(Sₜ + #Fvₜ × Sₜ + #Fvₜ × n) -- O(Sₜ × (#Fvₜ + 1) + #Fvₜ × n) -- -- Making the same assumption as before, that #Fvₜ ≈ n in the average scenario, -- -- O(Sₜ × (n + 1) + n²) -- O(n² + Sₜ × n + Sₜ) ≈ O(n²). mutual instAcc : {n : ℕ} → FinTerm n → RTerm ⊥ → X n → Maybe (X n) instAcc (ovar x) t s = extend-X x t s {- we need to allow ivar's to match whatever. If we end up giving a false positive, Agda typechecker will spot it. TODO: maybe there's a better workaround, but it would require a re-engineering of our AST, by providing explicit and implicit ovar's. Or, a RTerm (A ⊎ A) would suffice. instAcc (ivar n) (ivar m) s with n ≟-ℕ m ...| yes _ = just s ...| no _ = nothing -} instAcc (ivar _) _ s = just s instAcc (rlit l) (rlit k) s with l ≟-Lit k ...| yes _ = just s ...| no _ = nothing instAcc (rlam t) (rlam u) s = instAcc t u s instAcc (rapp n ts) (rapp m us) s with n ≟-RTermName m ...| no _ = nothing ...| yes _ = instAcc* ts us s instAcc _ _ _ = nothing instAcc* : {n : ℕ} → List (FinTerm n) → List (RTerm ⊥) → X n → Maybe (X n) instAcc* [] [] s = just s instAcc* [] (_ ∷ _) _ = nothing instAcc* (_ ∷ _) [] _ = nothing instAcc* (x ∷ xs) (y ∷ ys) s = instAcc x y s >>= instAcc* xs ys -- This is just a call to instAcc with an aditional n steps performed to generate -- empty-X. -- -- Keeping our degree of freedom Sₜ, we have -- inst ∈ O(n² + (Sₜ + 1) × n + Sₜ) -- inst : {n : ℕ} → FinTerm n → RTerm ⊥ → Maybe (X n) inst t u = instAcc t u empty-X ---------------------------------- -- * Interface RSubst : Set RSubst = List (ℕ × RTerm ⊥) private X2RSubst0 : {n : ℕ} → X n → Maybe RSubst X2RSubst0 {.zero} [] = just [] X2RSubst0 {suc n} (just x ∷ s) = _∷_ (suc n , x) <$> X2RSubst0 s X2RSubst0 {suc _} (nothing ∷ _) = nothing X2RSubst : {n : ℕ} → X n → Maybe RSubst X2RSubst x = reverse <$> (X2RSubst0 x) _++ₓ_ : {n : ℕ} → X n → X n → Maybe (X n) [] ++ₓ [] = just [] (x ∷ xs) ++ₓ (y ∷ ys) with x | y ...| nothing | just y' = _∷_ y <$> (xs ++ₓ ys) ...| just x' | nothing = _∷_ x <$> (xs ++ₓ ys) ...| nothing | nothing = nothing ...| just x' | just y' with x' ≟-RTerm y' ...| no _ = nothing ...| yes _ = _∷_ x <$> (xs ++ₓ ys)
{ "alphanum_fraction": 0.5483073118, "avg_line_length": 33.6927083333, "ext": "agda", "hexsha": "d9f8a6287cb4a2455c052f0d1789a95183540609", "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": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "VictorCMiraldo/agda-rw", "max_forks_repo_path": "RW/Language/Instantiation.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_issues_repo_issues_event_max_datetime": "2015-05-28T14:48:03.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-06T15:03:33.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "VictorCMiraldo/agda-rw", "max_issues_repo_path": "RW/Language/Instantiation.agda", "max_line_length": 112, "max_stars_count": 16, "max_stars_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "VictorCMiraldo/agda-rw", "max_stars_repo_path": "RW/Language/Instantiation.agda", "max_stars_repo_stars_event_max_datetime": "2019-10-24T17:38:20.000Z", "max_stars_repo_stars_event_min_datetime": "2015-02-09T15:43:38.000Z", "num_tokens": 2303, "size": 6469 }
{- ℚ is a Field -} {-# OPTIONS --safe #-} module Cubical.Algebra.Field.Instances.QuoQ where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.Data.Empty as Empty open import Cubical.Data.Nat using (ℕ ; zero ; suc) open import Cubical.Data.NatPlusOne open import Cubical.Data.Int.MoreInts.QuoInt using (ℤ ; spos ; sneg ; pos ; neg ; signed ; posneg ; isSetℤ ; 0≢1-ℤ) renaming (_·_ to _·ℤ_ ; -_ to -ℤ_ ; ·-zeroˡ to ·ℤ-zeroˡ ; ·-identityʳ to ·ℤ-identityʳ) open import Cubical.HITs.SetQuotients as SetQuot open import Cubical.HITs.Rationals.QuoQ using (ℚ ; ℕ₊₁→ℤ ; isEquivRel∼) open import Cubical.Algebra.Field open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRingSolver.Reflection open import Cubical.Algebra.CommRing.Instances.QuoInt open import Cubical.Algebra.CommRing.Instances.QuoQ open import Cubical.Relation.Nullary -- It seems there are bugs when applying ring solver to explicit ring. -- The following is a work-around. private module Helpers {ℓ : Level}(𝓡 : CommRing ℓ) where open CommRingStr (𝓡 .snd) helper1 : (x y : 𝓡 .fst) → (x · y) · 1r ≡ 1r · (y · x) helper1 = solve 𝓡 helper2 : (x y : 𝓡 .fst) → ((- x) · (- y)) · 1r ≡ 1r · (y · x) helper2 = solve 𝓡 -- A rational number is zero if and only if its numerator is zero a/b≡0→a≡0 : (x : ℤ × ℕ₊₁) → [ x ] ≡ 0 → x .fst ≡ 0 a/b≡0→a≡0 (a , b) a/b≡0 = sym (·ℤ-identityʳ a) ∙ a·1≡0·b ∙ ·ℤ-zeroˡ (ℕ₊₁→ℤ b) where a·1≡0·b : a ·ℤ 1 ≡ 0 ·ℤ (ℕ₊₁→ℤ b) a·1≡0·b = effective (λ _ _ → isSetℤ _ _) isEquivRel∼ _ _ a/b≡0 a≡0→a/b≡0 : (x : ℤ × ℕ₊₁) → x .fst ≡ 0 → [ x ] ≡ 0 a≡0→a/b≡0 (a , b) a≡0 = eq/ _ _ a·1≡0·b where a·1≡0·b : a ·ℤ 1 ≡ 0 ·ℤ (ℕ₊₁→ℤ b) a·1≡0·b = (λ i → a≡0 i ·ℤ 1) ∙ ·ℤ-zeroˡ {s = spos} 1 ∙ sym (·ℤ-zeroˡ (ℕ₊₁→ℤ b)) -- ℚ is a field open CommRingStr (ℚCommRing .snd) open Units ℚCommRing open Helpers ℤCommRing hasInverseℚ : (q : ℚ) → ¬ q ≡ 0 → Σ[ p ∈ ℚ ] q · p ≡ 1 hasInverseℚ = SetQuot.elimProp (λ q → isPropΠ (λ _ → inverseUniqueness q)) (λ x x≢0 → let a≢0 = λ a≡0 → x≢0 (a≡0→a/b≡0 x a≡0) in inv-helper x a≢0 , inv·-helper x a≢0) where inv-helper : (x : ℤ × ℕ₊₁) → ¬ x .fst ≡ 0 → ℚ inv-helper (signed spos (suc a) , b) _ = [ ℕ₊₁→ℤ b , 1+ a ] inv-helper (signed sneg (suc a) , b) _ = [ -ℤ ℕ₊₁→ℤ b , 1+ a ] inv-helper (signed spos zero , _) a≢0 = Empty.rec (a≢0 refl) inv-helper (signed sneg zero , _) a≢0 = Empty.rec (a≢0 (sym posneg)) inv-helper (posneg i , _) a≢0 = Empty.rec (a≢0 (λ j → posneg (i ∧ ~ j))) inv·-helper : (x : ℤ × ℕ₊₁)(a≢0 : ¬ x .fst ≡ 0) → [ x ] · inv-helper x a≢0 ≡ 1 inv·-helper (signed spos zero , b) a≢0 = Empty.rec (a≢0 refl) inv·-helper (signed sneg zero , b) a≢0 = Empty.rec (a≢0 (sym posneg)) inv·-helper (posneg i , b) a≢0 = Empty.rec (a≢0 (λ j → posneg (i ∧ ~ j))) inv·-helper (signed spos (suc a) , b) _ = eq/ _ _ (helper1 (pos (suc a)) (ℕ₊₁→ℤ b)) inv·-helper (signed sneg (suc a) , b) _ = eq/ _ _ (helper2 (pos (suc a)) (ℕ₊₁→ℤ b)) 0≢1-ℚ : ¬ Path ℚ 0 1 0≢1-ℚ p = 0≢1-ℤ (effective (λ _ _ → isSetℤ _ _) isEquivRel∼ _ _ p) -- The instance ℚField : Field ℓ-zero ℚField = makeFieldFromCommRing ℚCommRing hasInverseℚ 0≢1-ℚ
{ "alphanum_fraction": 0.6051740068, "avg_line_length": 34.9139784946, "ext": "agda", "hexsha": "5f0e42a9b9de853be2c53d80ed38f07aa7fd5be4", "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/Algebra/Field/Instances/QuoQ.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/Algebra/Field/Instances/QuoQ.agda", "max_line_length": 93, "max_stars_count": null, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/Field/Instances/QuoQ.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1470, "size": 3247 }
module Absurd where open import Prelude absurd : {A : Set} -> Empty -> A absurd x = {!!}
{ "alphanum_fraction": 0.6263736264, "avg_line_length": 13, "ext": "agda", "hexsha": "b74e50b4410ddb11b3542858e871c6b878de2c65", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "baf979ef78b5ec0f4783240b03f9547490bc5d42", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "carlostome/martin", "max_forks_repo_path": "data/test-files/Absurd.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "baf979ef78b5ec0f4783240b03f9547490bc5d42", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "carlostome/martin", "max_issues_repo_path": "data/test-files/Absurd.agda", "max_line_length": 32, "max_stars_count": null, "max_stars_repo_head_hexsha": "baf979ef78b5ec0f4783240b03f9547490bc5d42", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "carlostome/martin", "max_stars_repo_path": "data/test-files/Absurd.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 28, "size": 91 }
module Ethambda.Common where open import Eth.Prelude infixr 3 _<<_ infixr 3 _<d>_ export _<d>_ : String -> String -> String v <d> w = if isNullStr v then v else v ++ " " ++ " " ++ w export ShowS : Type ShowS = String -> String export _<d_ : String -> ShowS -> ShowS s <d c = (s <.>) . c
{ "alphanum_fraction": 0.5927152318, "avg_line_length": 12.5833333333, "ext": "agda", "hexsha": "6e69858d723001605fa23cd517de32085a983ad5", "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": "18e1f9271a3ce76319cdfbcffe027c2088a418aa", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "fredefox/ethambda-agda", "max_forks_repo_path": "src/Ethambda/Common.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "18e1f9271a3ce76319cdfbcffe027c2088a418aa", "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": "fredefox/ethambda-agda", "max_issues_repo_path": "src/Ethambda/Common.agda", "max_line_length": 34, "max_stars_count": null, "max_stars_repo_head_hexsha": "18e1f9271a3ce76319cdfbcffe027c2088a418aa", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "fredefox/ethambda-agda", "max_stars_repo_path": "src/Ethambda/Common.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 113, "size": 302 }
{- The James Construction, also known as James Reduced Product A very fundamental and useful construction in classical homotopy theory. It can be seen as the free A∞-monoid constructed out of a given type, namely the "correct higher version" of free monoid that is meaningful for all types, instead of only h-Sets. Referrence: Guillaume Brunerie, "The James construction and π₄(𝕊³) in homotopy type theory" (https://arxiv.org/abs/1710.10307) -} {-# OPTIONS --safe #-} module Cubical.HITs.James.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Pointed private variable ℓ ℓ' : Level module _ ((X , x₀) : Pointed ℓ) where infixr 5 _∷_ -- The James Construction data James : Type ℓ where [] : James _∷_ : X → James → James unit : (xs : James) → xs ≡ x₀ ∷ xs James∙ : Pointed ℓ James∙ = James , [] -- Basic operations on James construction, imitating those in Cubical.Data.List.Base module _ {X∙@(X , x₀) : Pointed ℓ} where infixr 5 _++_ infixl 5 _∷ʳ_ [_] : X → James X∙ [ x ] = x ∷ [] _++_ : James X∙ → James X∙ → James X∙ [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ xs ++ ys (unit xs i) ++ ys = unit (xs ++ ys) i ++₀ : (xs : James X∙) → xs ≡ xs ++ [ x₀ ] ++₀ [] = unit [] ++₀ (x ∷ xs) i = x ∷ ++₀ xs i ++₀ (unit xs i) j = unit (++₀ xs j) i rev : James X∙ → James X∙ rev [] = [] rev (x ∷ xs) = rev xs ++ [ x ] rev (unit xs i) = ++₀ (rev xs) i _∷ʳ_ : James X∙ → X → James X∙ xs ∷ʳ x = xs ++ x ∷ [] map : {X : Pointed ℓ}{Y : Pointed ℓ'} → (X →∙ Y) → James X → James Y map f [] = [] map f (x ∷ xs) = f .fst x ∷ map f xs map f (unit xs i) = (unit (map f xs) ∙ (λ i → f .snd (~ i) ∷ map f xs)) i map∙ : {X : Pointed ℓ}{Y : Pointed ℓ'} → (X →∙ Y) → James∙ X →∙ James∙ Y map∙ f .fst = map f map∙ f .snd = refl
{ "alphanum_fraction": 0.5775342466, "avg_line_length": 22.8125, "ext": "agda", "hexsha": "a4f12011dbc4c06ff36cc3f472ae05359091a484", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/HITs/James/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/HITs/James/Base.agda", "max_line_length": 84, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/HITs/James/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": 705, "size": 1825 }
{-# OPTIONS --type-in-type #-} module Compilation.Data where open import Context open import Type.Core open import Function open import Data.Product open import Data.List.Base infixr 6 _⇒ᶜ_ {- Note [Type denotations] The denotation of a System Fωμ type is an Agda type that somehow corresponds to the original type. For System Fωμ types we'll be using simple and straightforward denotations. For example, we map π ⋆ (Var vz ⇒ Var vz) to (A : Set) -> A -> A and Lam (Var vz) ∙ (π ⋆ (Var vz ⇒ Var vz)) to (λ x -> x) ((A : Set) -> A -> A) which computes to (A : Set) -> A -> A The latter is due to the fact that we map System Fωμ lambdas to Agda lambdas and System Fωμ applications to Agda applications and hence get type normalization of denotations for free. -} {- Note [Kind denotations] Of course before taking denotations of System Fωμ types, we need to be able to take denotations of System Fωμ kinds. We map a System Fωμ `⋆` to an Agda `Set` and a System Fωμ `_⇒ᵏ_` to an Agda `_->_`. For example the denotation of (⋆ ⇒ᵏ ⋆) ⇒ᵏ ⋆ is (Set -> Set) -> Set -} -- | The Agda meaning of a kind. ⟦_⟧ᵏ : Kind -> Set ⟦ ⋆ ⟧ᵏ = Set ⟦ σ ⇒ᵏ τ ⟧ᵏ = ⟦ σ ⟧ᵏ -> ⟦ τ ⟧ᵏ -- | The Agda meaning of a System Fωμ type in an environment. evalᵗ : ∀ {Θ σ} -> Env ⟦_⟧ᵏ Θ -> Θ ⊢ᵗ σ -> ⟦ σ ⟧ᵏ evalᵗ ρ (Var v) = lookupᵉ v ρ -- Look up a variable in the current context. evalᵗ ρ (Lam β) = λ A -> evalᵗ (ρ ▷ A) β -- Map a System Fωμ lambda to an Agda lambda. evalᵗ ρ (φ ∙ α) = evalᵗ ρ φ (evalᵗ ρ α) -- Map a System Fωμ application to an Agda application. evalᵗ ρ (α ⇒ β) = evalᵗ ρ α -> evalᵗ ρ β -- Map a System Fωμ arrow to an Agda arrow. evalᵗ ρ (π σ β) = (A : ⟦ σ ⟧ᵏ) -> evalᵗ (ρ ▷ A) β -- Map a System Fωμ `all` to an Agda `∀`. evalᵗ ρ (μ ψ α) = IFix (evalᵗ ρ ψ) (evalᵗ ρ α) -- Map a System Fωμ `ifix` to an Agda `IFix`. -- | The Agda meaning of a closed System Fωμ type. ⟦_⟧ᵗ : ∀ {σ} -> Type⁽⁾ σ -> ⟦ σ ⟧ᵏ ⟦_⟧ᵗ = evalᵗ ∅ {- Note [Representing data types] We represent a single data type as a list of constructor types. Each constructor type is defined in a non-empty context where the first bound variable is for handling recursion and other variables are parameters of the data type (there can be none). Each constructor type is a sequence of `_⇒ᶜ_` that ends in `endᶜ` where `endᶜ` is a placeholder that will later be substituted either for a type being defined or a type we eliminate the data type into or the unit type, depending on how we denote constructors (there are multiple ways). Consider the `list` data type. Its pattern functor binds two variables: 1. one responsible for recursion 2. one for the type of the elements stored in a list Since we define constructors in contexts, the list constructors are defined in ε ▻ (⋆ ⇒ ⋆) ▻ ⋆ (the parens are for clarity, they're not really needed). The types of the constructors are 1. List A -- The type of the `nil` constructor. 2. A -> List A -> List A -- The type of the `cons` constructor. and we translate them to 1. endᶜ 2. Var vz ⇒ᶜ Var (vs vz) ∙ Var vz ⇒ᶜ endᶜ A more interesting example is data InterList (A B : Set) : Set where InterNil : InterList A B InterCons : A -> B -> InterList B A -> InterList A B The types of its constructors are described as 1. endᶜ 2. Var (vs vz) ⇒ᶜ Var vz ⇒ᶜ Var (vs vs vz) ∙ Var vz ∙ Var (vs vz) ⇒ᶜ endᶜ Below we define the data type that describes constructors and some basic functions over it. -} -- | The type of a constructor is of the `σ₁ ⇒ … ⇒ σₙ ⇒ end` form -- where each `σ` is a type of kind `⋆`. data Cons Θ : Set where endᶜ : Cons Θ _⇒ᶜ_ : (α : Star Θ) -> (ξ : Cons Θ) -> Cons Θ -- | Convert the type of a constructor to an actual type of kind `⋆`. -- -- > consToType (α₁ ⇒ᶜ … ⇒ᶜ αₙ ⇒ᶜ endᶜ) β = α₁ ⇒ … ⇒ αₙ ⇒ β consToType : ∀ {Θ} -> Cons Θ -> Star Θ -> Star Θ consToType endᶜ β = β consToType (α ⇒ᶜ ξ) β = α ⇒ consToType ξ β -- | Rename the type of a constructor. renᶜ : ∀ {Θ Ξ} -> Θ ⊆ Ξ -> Cons Θ -> Cons Ξ renᶜ ι endᶜ = endᶜ renᶜ ι (α ⇒ᶜ ξ) = renᵗ ι α ⇒ᶜ renᶜ ι ξ -- The family we use as an example in docs below. module ProdTreeTree where mutual data ProdTree (A : Set) (B : Set) : Set where Prod : Tree (A × B) -> ProdTree A B data Tree (A : Set) : Set where Leaf : A -> Tree A Fork : ProdTree A A -> Tree A open import Data.Nat.Base open import Data.Bool.Base private example : ProdTree ℕ Bool example = Prod ∘ Fork ∘ Prod ∘ Fork ∘ Prod ∘ Leaf $ ( ( 0 , false ) , ( 1 , true ) ) , ( ( 2 , false ) , (3 , true ) ) -- | A data description is parameterized by a context of contexts of kinds. Inner contexts are those -- single data types are defined in. Outer contexts are needed in order to allow to define mutually -- recursive data types. I.e. each element of an outer context is an inner context, in which -- a single data type is defined. -- -- A single data type is described as a list of described constructors. The context of each -- constructor consists of -- -- 1. all the data types being defined (because we allow mutually recursive data types) -- 2. the particular inner context of the data type that the constructor constructs -- -- For example, consider the `ProdTree`/`Tree` family of data types defined above -- -- Since there are two data types in this family, the length of the outer context is 2. -- Since `ProdTree` is parameterized by two types, it's inner context is `ε ▻ ⋆ ▻ ⋆`. -- Since `Tree` is parameterized by one type, it's inner context is `ε ▻ ⋆`. -- I.e. the context this whole family is defined in, is -- -- > ε ▻ (ε ▻ ⋆ ▻ ⋆) ▻ (ε ▻ ⋆) -- -- The context that the constructor of `ProdTree` is defined in, consists of -- -- 1. References to both `ProdTree` and `Tree` which have the `⋆ ⇒ᵏ ⋆ ⇒ᵏ ⋆` and `⋆ ⇒ᵏ ⋆` -- kinds respectively. -- 2. The inner context of `ProdTree` which has two parameters `A` and `B`, each of kind `⋆`. -- -- hence the final context is -- -- > ε ▻ {- ProdTree :: -} (⋆ ⇒ᵏ ⋆ ⇒ᵏ ⋆) ▻ {- Tree :: -} (⋆ ⇒ᵏ ⋆) ▻ {- A :: -} ⋆ ▻ {- B :: -} ⋆ -- -- (things in `{- … -}` are comments that assign names to variables for clarity). -- -- Analogously, the context that the constructors of Tree` are defined in, is -- -- > ε ▻ {- ProdTree :: -} (⋆ ⇒ᵏ ⋆ ⇒ᵏ ⋆) ▻ {- Tree :: -} (⋆ ⇒ᵏ ⋆) ▻ {- A :: -} ⋆ -- -- I.e. the same as the one of `ProdTree`, except we bind only one type parameter, because `Tree` -- has only one type parameter. record Data Ξ (Θs : Con Conᵏ) : Set where constructor PackData field constructors : Seq (λ Θ -> List (Cons (Ξ ▻▻ mapᶜ (λ Θᵢ -> conToKind Θᵢ ⋆) Θs ▻▻ Θ))) Θs Data⁺ : Con Conᵏ -> Set Data⁺ Θs = ∀ {Ξ} -> Data Ξ Θs module prodTreeTree where -- The encoded `ProdTree`/`Tree` family from the above looks like this: -- (`∀ Q -> (A -> B -> Q) -> Q` is the Scott-encoded `A × B`) prodTreeTree : Data⁺ (ε ▻ (ε ▻ ⋆ ▻ ⋆) ▻ (ε ▻ ⋆)) prodTreeTree = PackData $ ø ▶ ( -- `Tree (∀ Q -> (A -> B -> Q) -> Q) -> ProdTree A B` Var (vs vs vz) ∙ π ⋆ ((Var (vs vs vz) ⇒ Var (vs vz) ⇒ Var vz) ⇒ Var vz) ⇒ᶜ endᶜ ∷ [] ) ▶ ( -- `A -> Tree A` Var vz ⇒ᶜ endᶜ ∷ -- `ProdTree A A -> Tree A` Var (vs vs vz) ∙ Var vz ∙ Var vz ⇒ᶜ endᶜ ∷ [] )
{ "alphanum_fraction": 0.6102081934, "avg_line_length": 33.3856502242, "ext": "agda", "hexsha": "1c932af6caf1e37416964f94c277abb07aa827a3", "lang": "Agda", "max_forks_count": 399, "max_forks_repo_forks_event_max_datetime": "2022-03-31T11:18:25.000Z", "max_forks_repo_forks_event_min_datetime": "2018-10-05T09:36:10.000Z", "max_forks_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "AriFordsham/plutus", "max_forks_repo_path": "papers/unraveling-recursion/code/src/Compilation/Data.agda", "max_issues_count": 2493, "max_issues_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_issues_repo_issues_event_max_datetime": "2022-03-31T15:31:31.000Z", "max_issues_repo_issues_event_min_datetime": "2018-09-28T19:28:17.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "AriFordsham/plutus", "max_issues_repo_path": "papers/unraveling-recursion/code/src/Compilation/Data.agda", "max_line_length": 106, "max_stars_count": 1299, "max_stars_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "AriFordsham/plutus", "max_stars_repo_path": "papers/unraveling-recursion/code/src/Compilation/Data.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-28T01:10:02.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-02T13:41:39.000Z", "num_tokens": 2681, "size": 7445 }
-- Issue reported by Christian Sattler on 2019-12-02 postulate M : Set m₀ : M D : Set d : D Y : (m : M) (a : D) → Set y : Y m₀ d R' : M → Set data X : M → Set where conX : X m₀ R : M → Set R = R' postulate felt : (m : M) (f : X m → D) (g : (x : X m) → Y m (f x)) → R m -- No error if R unfolded to R'. module _ (m : M) where foo : R m foo = felt _ f g where f : X _ → D -- No error if signature of f given as _. f conX = d g : (x : X _) → Y _ (f x) g conX = y -- Accepted if y given as hole filler. -- WAS: error: -- d != f conX of type D -- when checking that the expression y has type Y m₀ (f conX) -- SHOULD: succeed.
{ "alphanum_fraction": 0.5101156069, "avg_line_length": 18.2105263158, "ext": "agda", "hexsha": "e35654c46751e1b5b5812ff7ad2b27b3cadeb9a4", "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/Issue4255.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/Issue4255.agda", "max_line_length": 63, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue4255.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": 268, "size": 692 }
-- Functions used in googology {-# OPTIONS --without-K --safe --exact-split #-} module Math.Googology.Function where -- agda-stdlib open import Data.Nat open import Data.Nat.GeneralisedArithmetic open import Function -- Ackermann function. -- ack m n = Ack(m, n) ack : ℕ → ℕ → ℕ ack 0 n = 1 + n ack (suc m) zero = ack m 1 ack (suc m) (suc n) = ack m (ack (suc m) n) -- Hyperoperation. -- H n a b ≡ Hₙ(a, b) H : ℕ → ℕ → ℕ → ℕ H 0 a b = 1 + b H 1 a 0 = a H 1 a (suc b) = H 0 a (H 1 a b) H 2 a 0 = 0 H 2 a (suc b) = H 1 a (H 2 a b) H (suc (suc (suc _))) a 0 = 1 H (suc n@(suc (suc _))) a (suc b) = H n a (H (suc n) a b) -- Knuth's up-arrow notation. -- a ↑[ n ] b =`a ↑ⁿ b` _↑[_]_ : ℕ → ℕ → ℕ → ℕ a ↑[ n ] b = H (2 + n) a b infixr 8 _↑_ _↑↑_ _↑↑↑_ _↑↑↑↑_ -- Exponentiation. _↑_ : ℕ → ℕ → ℕ _↑_ a b = a ↑[ 1 ] b -- Tetration. _↑↑_ : ℕ → ℕ → ℕ _↑↑_ a b = a ↑[ 2 ] b -- Pentation. _↑↑↑_ : ℕ → ℕ → ℕ _↑↑↑_ a b = a ↑[ 3 ] b -- Hexation. _↑↑↑↑_ : ℕ → ℕ → ℕ _↑↑↑↑_ a b = a ↑[ 4 ] b -- Heptation. _↑↑↑↑↑_ : ℕ → ℕ → ℕ _↑↑↑↑↑_ a b = a ↑[ 5 ] b -- Graham's number. graham's-number : ℕ graham's-number = go 64 where go : ℕ → ℕ go 0 = 4 go (suc n) = 3 ↑[ go n ] 3 -- Fast-growing hierarchy FGHℕ[_][_] : ℕ → ℕ → ℕ FGHℕ[ zero ][ x ] = suc x FGHℕ[ suc n ][ x ] = fold x FGHℕ[ n ][_] x FGHω : ℕ → ℕ FGHω n = FGHℕ[ n ][ n ]
{ "alphanum_fraction": 0.457201087, "avg_line_length": 20.7323943662, "ext": "agda", "hexsha": "51c2b0c42f6d91684b1e58535a5cb6bd366a3a16", "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.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.agda", "max_line_length": 57, "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.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": 660, "size": 1472 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Pointwise equality for containers ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Container.Relation.Binary.Pointwise where open import Data.Product using (_,_; Σ-syntax; -,_; proj₁; proj₂) open import Function open import Level using (_⊔_) open import Relation.Binary using (REL; _⇒_) open import Relation.Binary.PropositionalEquality as P using (_≡_; subst; cong) open import Data.Container.Core using (Container; ⟦_⟧) -- Equality, parametrised on an underlying relation. module _ {s p} (C : Container s p) where record Pointwise {x y e} {X : Set x} {Y : Set y} (R : REL X Y e) (cx : ⟦ C ⟧ X) (cy : ⟦ C ⟧ Y) : Set (s ⊔ p ⊔ e) where constructor _,_ field shape : proj₁ cx ≡ proj₁ cy position : ∀ p → R (proj₂ cx p) (proj₂ cy (subst _ shape p)) module _ {s p} {C : Container s p} {x y} {X : Set x} {Y : Set y} {ℓ ℓ′} {R : REL X Y ℓ} {R′ : REL X Y ℓ′} where map : R ⇒ R′ → Pointwise C R ⇒ Pointwise C R′ map R⇒R′ (s , f) = s , R⇒R′ ∘ f
{ "alphanum_fraction": 0.531092437, "avg_line_length": 33.0555555556, "ext": "agda", "hexsha": "697b071f358a554ea7ea615ec6ff373859d2a9cb", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Container/Relation/Binary/Pointwise.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Container/Relation/Binary/Pointwise.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Container/Relation/Binary/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": 355, "size": 1190 }
{-# OPTIONS --cubical #-} F : Set → Set F A = A record R : Set₁ where field A : Set r : Set → R r A = λ where .R.A → A
{ "alphanum_fraction": 0.5, "avg_line_length": 10, "ext": "agda", "hexsha": "0bde5648dec6b172e5436317f52e91bdef90d587", "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/Issue4954-2.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/Issue4954-2.agda", "max_line_length": 25, "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/Issue4954-2.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": 52, "size": 130 }
module CF.Examples.Ex1 where open import Function open import Data.Bool open import Data.Product open import Data.List open import Data.List.Relation.Unary.All open import Data.Nat open import Data.String open import Relation.Binary.PropositionalEquality using (refl) open import Relation.Ternary.Core open import Relation.Ternary.Structures open import Relation.Ternary.Structures.Syntax open import Relation.Ternary.Monad.Possibly open import Relation.Ternary.Data.Allstar open import Relation.Ternary.Data.Bigstar hiding ([_]) open import CF.Types open import CF.Syntax as Src open import CF.Contexts.Lexical open import JVM.Transform.Assemble open import JVM.Printer import JVM.Printer.Jasmin as J ex₁ : Closed (Src.Block void) ex₁ = ( Src.while ( Src.bool true ∙⟨ ∙-idˡ ⟩ Src.block -- int j = true (Src.bool true ≔⟨ ∙-idˡ ⟩ Possibly.possibly ∼-all ( Src.ifthenelse -- if j (var ∙⟨ overlaps ∙-idˡ ⟩ -- then Src.block ( -- int i = j var ≔⟨ consˡ ∙-idˡ ⟩ Possibly.possibly ∼-all ( -- j := j Src.asgn (vars ∙⟨ overlaps ∙-idˡ ⟩ var) ⍮⟨ ∙-idʳ ⟩ Src.run unit ⍮⟨ ∙-idʳ ⟩ emp)) -- else ∙⟨ overlaps ∙-idˡ ⟩ Src.block ( -- int i = j var ≔⟨ consˡ ∙-idˡ ⟩ Possibly.possibly ∼-none ( Src.run unit ⍮⟨ ∙-idʳ ⟩ emp)) ) Src.⍮⟨ ∙-idʳ ⟩ emp ))) Src.⍮⟨ ∙-idʳ ⟩ emp) open import IO as IO open import Codata.Musical.Notation open import CF.Compile main = IO.run (putStrLn test) where test = Show.showBytecode $ proj₂ $ exec-extractor $ extract (proj₂ $ compile ex₁) -- Uncomment this instead of the above main to output Jasmin code. -- You can assemble this using Jasmin so that you can run the output with java. -- Disclaimer: the jasmin compiler pass is not verified. -- main = IO.run (putStrLn (J.unlines $ J.Jasmin.out proc)) -- where -- proc = procedure "ex1" (proj₂ $ compile ex₁)
{ "alphanum_fraction": 0.6213075061, "avg_line_length": 28.2876712329, "ext": "agda", "hexsha": "5b1f7dbe4daeccfffe937d291687eae7bd38eac7", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ajrouvoet/jvm.agda", "max_forks_repo_path": "src/CF/Examples/Ex1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "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": "ajrouvoet/jvm.agda", "max_issues_repo_path": "src/CF/Examples/Ex1.agda", "max_line_length": 85, "max_stars_count": 6, "max_stars_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ajrouvoet/jvm.agda", "max_stars_repo_path": "src/CF/Examples/Ex1.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-28T21:49:08.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T14:07:17.000Z", "num_tokens": 633, "size": 2065 }
{-# OPTIONS --prop --allow-unsolved-metas #-} data _≡_ {α}{A : Set α}(a : A) : A → Prop where refl : a ≡ a data _≃_ {α}{A : Set α}(a : A) : ∀ {B} → B → Prop where refl̃ : a ≃ a data ⊥ : Set where data Con : Set data Con~ : Con → Con → Prop data Ty : Con → Set data Ty~ : ∀ {Γ₀ Γ₁} → Con~ Γ₀ Γ₁ → Ty Γ₀ → Ty Γ₁ → Prop data Con where data Con~ where data Ty where U : ∀ {Γ} → Ty Γ data Ty~ where U~ : ∀ {Γ₀ Γ₁ Γ₀₁} → Ty~ {Γ₀}{Γ₁} Γ₀₁ U U Conᴹ : Con → Set Con~ᴹ : ∀ {Γ₀ Γ₁} → Con~ Γ₀ Γ₁ → Conᴹ Γ₀ ≡ Conᴹ Γ₁ Tyᴹ : ∀ {Γ} → Ty Γ → Conᴹ Γ → Set Ty~ᴹ : ∀ {Γ₀ Γ₁ Γ₀₁ A₀ A₁} → Ty~ {Γ₀}{Γ₁} Γ₀₁ A₀ A₁ → Tyᴹ A₀ ≃ Tyᴹ A₁ Conᴹ () Con~ᴹ () Tyᴹ U γ = ⊥ -- offending line: if I comment this out, the internal error goes away -- If I use Set instead of Prop everywhere, the error also goes away Ty~ᴹ U~ = {!!}
{ "alphanum_fraction": 0.5505481121, "avg_line_length": 22.1891891892, "ext": "agda", "hexsha": "61ccc0c650f2536781803ae9f307cc475a326d65", "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/Issue3724.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/Issue3724.agda", "max_line_length": 70, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue3724.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": 399, "size": 821 }
module PushArgument where open import ScopeState open import Data.List.NonEmpty open import Data.List open import ParseTree open import Data.Nat open import AgdaHelperFunctions open import Data.Unit open import Data.String hiding (toVec) open import Data.Bool open import Data.Product open import Data.Maybe open import ExpressionChanging hiding (makeInstruction) open import ParseTreeOperations open import Data.Vec hiding (_>>=_) open import Data.Fin open import Relation.Nullary open import Data.Nat.Properties open import Data.String using (_++_) data ArgType : Set where explicit : ArgType present : ArgType absent : ArgType -- if matches is false then an expected implicit argument has been omitted matches : Expr -> Expr -> ArgType matches expectedType argument with isImplicit expectedType | isImplicit argument matches expectedType argument | false | false = explicit --expected explicit but found implicit, actually an error matches expectedType argument | false | true = explicit matches expectedType argument | true | false = absent matches expectedType argument | true | true = present -- n is the argument to be pushed, so there must be another argument to switch -- it with makeIns : {n : ℕ} -> Vec Expr (suc n) -> Fin n -> (List Expr -> List Expr) makeIns (x ∷ x₁) _ [] = [] makeIns (x ∷ y ∷ list) zero (z ∷ []) with matches x z makeIns (x ∷ y ∷ list) zero (z ∷ []) | explicit = newHole ∷ [] makeIns (x ∷ y ∷ list) zero (z ∷ []) | present = implicit newHole ∷ [] makeIns (x ∷ y ∷ list) zero (z ∷ []) | absent with matches y z makeIns (x ∷ y ∷ list) zero (z ∷ []) | absent | explicit = newHole ∷ [] makeIns (x ∷ y ∷ list) zero (z ∷ []) | absent | present = z ∷ [] makeIns (x ∷ y ∷ list) zero (z ∷ []) | absent | absent = z ∷ [] makeIns (a ∷ b ∷ list) zero (y ∷ z ∷ list2) with matches a y makeIns (a ∷ b ∷ list) zero (y ∷ z ∷ list2) | absent = y ∷ z ∷ list2 makeIns (a ∷ b ∷ list) zero (y ∷ z ∷ list2) | _ with matches b z makeIns (a ∷ b ∷ list) zero (y ∷ z ∷ list2) | _ | explicit = z ∷ y ∷ list2 makeIns (a ∷ b ∷ list) zero (y ∷ z ∷ list2) | _ | present = z ∷ y ∷ list2 makeIns (a ∷ b ∷ list) zero (y ∷ z ∷ list2) | _ | absent = y ∷ z ∷ list2 makeIns (x ∷ x₁) (suc n) (y ∷ list) with matches x y makeIns (x ∷ x₁) (suc n) (y ∷ list) | explicit = y ∷ makeIns x₁ n list makeIns (x ∷ x₁) (suc n) (y ∷ list) | present = y ∷ makeIns x₁ n list makeIns (x ∷ x₁) (suc n) (y ∷ list) | absent = makeIns x₁ n (y ∷ list) makeInstruction : TypeSignature -> ℕ -> (makeIns : {n : ℕ} -> Vec Expr (suc n) -> Fin n -> (List Expr -> List Expr)) -> ScopeState (List⁺ Expr -> List⁺ Expr) makeInstruction (typeSignature funcName funcType) argNo f with toVec (typeToList funcType) ... | c = do newFin <- makeFin2 c argNo return $ function $ f c newFin where function : (List Expr -> List Expr) -> (List⁺ Expr -> List⁺ Expr) function f (ident identifier₁ ∷ tail₁) with sameId identifier₁ funcName function f (ident identifier₁ ∷ tail₁) | false = (ident identifier₁ ∷ tail₁) function f (ident identifier₁ ∷ tail₁) | true = ident identifier₁ ∷ f tail₁ function f list = list pushInstruction : TypeSignature -> ℕ -> ScopeState (List⁺ Expr -> List⁺ Expr) pushInstruction t n = makeInstruction t n makeIns --Data.List.NonEmpty.fromVec pushTypeIfApplicable : {n : ℕ} -> Vec Expr (suc n) -> Fin n -> ScopeState (Vec Expr (suc n)) pushTypeIfApplicable (namedArgument (typeSignature funcName funcType) {b} {bef1} {aft1} ∷ namedArgument (typeSignature funcName₁ funcType₁) {b2} {bef2} {aft2} ∷ v) zero = if sameName funcName funcName₁ then fail "Can't switch two arguments of the same name, to avoid anything changing meaning" else if funcName doesNotAppearInExp funcType₁ then (return $ namedArgument (typeSignature funcName₁ funcType₁) {b2} {bef2} {aft2} ∷ namedArgument (typeSignature funcName funcType) {b} {bef1} {aft1} ∷ v) else fail "The next argument depends on the one being pushed" pushTypeIfApplicable (namedArgument (typeSignature funcName funcType) {b} {bef} {aft} ∷ x ∷ v) zero = if funcName doesNotAppearInExp x then return $ x ∷ namedArgument (typeSignature funcName funcType) {b} {bef} {aft} ∷ v else fail "The next argument depends on the one being pushed" pushTypeIfApplicable (x ∷ x₁ ∷ v) zero = return $ x₁ ∷ x ∷ v pushTypeIfApplicable (x ∷ v) (suc f) = do newRest <- pushTypeIfApplicable v f return $ x ∷ newRest pushArgument : List ParseTree -> (funcID : ℕ) -> (whichArgument : ℕ) -> ScopeState (List ParseTree) pushArgument code funcId whichArgument = doForArgument code funcId whichArgument pushTypeIfApplicable pushInstruction
{ "alphanum_fraction": 0.6706524019, "avg_line_length": 50.7127659574, "ext": "agda", "hexsha": "15cbe7492d003c928e91956b7491d7d477954237", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-01-31T08:40:41.000Z", "max_forks_repo_forks_event_min_datetime": "2019-01-31T08:40:41.000Z", "max_forks_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "omega12345/RefactorAgda", "max_forks_repo_path": "RefactorAgdaEngine/PushArgument.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_issues_repo_issues_event_max_datetime": "2019-02-05T12:53:36.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-31T08:03:07.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "omega12345/RefactorAgda", "max_issues_repo_path": "RefactorAgdaEngine/PushArgument.agda", "max_line_length": 173, "max_stars_count": 5, "max_stars_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "omega12345/RefactorAgda", "max_stars_repo_path": "RefactorAgdaEngine/PushArgument.agda", "max_stars_repo_stars_event_max_datetime": "2019-05-03T10:03:36.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-31T14:10:18.000Z", "num_tokens": 1474, "size": 4767 }
-- {-# OPTIONS -v tc.cover.splittree:10 -v tc.cc.splittree:10 #-} module Issue106 where data ℕ : Set where zero : ℕ suc : ℕ -> ℕ {-# BUILTIN NATURAL ℕ #-} {-# BUILTIN ZERO zero #-} {-# BUILTIN SUC suc #-} _+_ : ℕ -> ℕ -> ℕ zero + m = m suc n + m = suc (n + m) record ⊤ : Set where data C : ℕ -> Set where c : C 0 data D : Set where d : forall s (x : C s) (xs : D) -> D f : D -> ℕ -> ⊤ f (d zero c x) (suc n) = f (d 0 c x) n f (d .zero c x) n = f x (suc n) g : D -> ℕ -> ⊤ g (d .zero c x) (suc n) = g (d zero c x) n g (d .zero c x) n = g x (suc n) h : D -> ℕ -> ⊤ h (d .zero c x) (suc n) = h (d 0 c x) n h (d .zero c x) n = h x (suc n)
{ "alphanum_fraction": 0.4739195231, "avg_line_length": 19.1714285714, "ext": "agda", "hexsha": "5708af080c835b5d4f8bea9b3a4765aca0b1bd74", "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": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_path": "test/succeed/Issue106.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "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": "np/agda-git-experiment", "max_issues_repo_path": "test/succeed/Issue106.agda", "max_line_length": 66, "max_stars_count": 1, "max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "np/agda-git-experiment", "max_stars_repo_path": "test/succeed/Issue106.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 295, "size": 671 }
module Data where data D (A : Set) : Set data D A where c : D A data E (B : Set) : Set where
{ "alphanum_fraction": 0.5, "avg_line_length": 6.4444444444, "ext": "agda", "hexsha": "fcbe1224462adee6dd54258af57aadcb28525cac", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-01T16:38:14.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-01T16:38:14.000Z", "max_forks_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "msuperdock/agda-unused", "max_forks_repo_path": "data/declaration/Data.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "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": "msuperdock/agda-unused", "max_issues_repo_path": "data/declaration/Data.agda", "max_line_length": 17, "max_stars_count": 6, "max_stars_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "msuperdock/agda-unused", "max_stars_repo_path": "data/declaration/Data.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-01T16:38:05.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-29T09:38:43.000Z", "num_tokens": 48, "size": 116 }
{-# OPTIONS --without-K --show-implicit #-} module WithoutK10 where data Unit : Set where unit : Unit data D {A : Set} (f : Unit → A) : A → Set where d : ∀ {x} → D f x Foo : ∀ {A} {x : A} → D (let f = λ { unit → x } in f) x → Set₁ Foo d = Set
{ "alphanum_fraction": 0.5298804781, "avg_line_length": 19.3076923077, "ext": "agda", "hexsha": "f4fe6f97360a2e1fb537969bfeee42b59c0fb45b", "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": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_path": "test/fail/WithoutK10.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "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": "np/agda-git-experiment", "max_issues_repo_path": "test/fail/WithoutK10.agda", "max_line_length": 62, "max_stars_count": 1, "max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "np/agda-git-experiment", "max_stars_repo_path": "test/fail/WithoutK10.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 95, "size": 251 }
{- Index a structure S by the type variable: X ↦ X → S X -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Structures.Relational.UnaryOp where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Foundations.Structure open import Cubical.Foundations.RelationalStructure open import Cubical.Foundations.Univalence open import Cubical.Functions.FunExtEquiv open import Cubical.Data.Sigma open import Cubical.Relation.Binary.Base open import Cubical.Relation.ZigZag.Base open import Cubical.HITs.SetQuotients open import Cubical.HITs.PropositionalTruncation as Trunc open import Cubical.Structures.NAryOp private variable ℓ ℓ₁ ℓ₁' : Level -- Structured relations preservesSetsUnaryFun : {S : Type ℓ → Type ℓ₁} → preservesSets S → preservesSets (NAryFunStructure 1 S) preservesSetsUnaryFun p setX = isSetΠ λ _ → p setX UnaryFunRelStr : {S : Type ℓ → Type ℓ₁} {ℓ₁' : Level} → StrRel S ℓ₁' → StrRel (NAryFunStructure 1 S) (ℓ-max ℓ ℓ₁') UnaryFunRelStr ρ R f g = ∀ {x y} → R x y → ρ R (f x) (g y) open BinaryRelation open isEquivRel open isQuasiEquivRel open SuitableStrRel private composeWith[_] : {A : Type ℓ} (R : EquivPropRel A ℓ) → compPropRel (R .fst) (quotientPropRel (R .fst .fst)) .fst ≡ graphRel [_] composeWith[_] R = funExt₂ λ a t → hPropExt squash (squash/ _ _) (Trunc.rec (squash/ _ _) (λ {(b , r , p) → eq/ a b r ∙ p })) (λ p → ∣ a , R .snd .reflexive a , p ∣) unaryFunSuitableRel : {S : Type ℓ → Type ℓ₁} (p : preservesSets S) {ρ : StrRel S ℓ₁'} → SuitableStrRel S ρ → SuitableStrRel (NAryFunStructure 1 S) (UnaryFunRelStr ρ) unaryFunSuitableRel pres {ρ} θ .quo (X , f) R h .fst = f₀ , λ {x} → J (λ y p → ρ (graphRel [_]) (f x) (f₀ y)) (θ .quo (X , f x) R (href x) .fst .snd) where href = h ∘ R .snd .reflexive f₀ : _ f₀ [ x ] = θ .quo (X , f x) R (href x) .fst .fst f₀ (eq/ x₀ x₁ r i) = path i where path : θ .quo (X , f x₀) R (href x₀) .fst .fst ≡ θ .quo (X , f x₁) R (href x₁) .fst .fst path = cong fst (θ .quo (X , f x₀) R (href x₀) .snd ( θ .quo (X , f x₁) R (href x₁) .fst .fst , subst (λ T → ρ T (f x₀) (θ .quo (X , f x₁) R (href x₁) .fst .fst)) (composeWith[_] R) (θ .transitive (R .fst) (quotientPropRel (R .fst .fst)) (h r) (θ .quo (X , f x₁) R (href x₁) .fst .snd)) )) f₀ (squash/ _ _ p q j i) = pres squash/ _ _ (cong f₀ p) (cong f₀ q) j i unaryFunSuitableRel pres {ρ} θ .quo (X , f) R h .snd (f' , c) = Σ≡Prop (λ _ → isPropImplicitΠ λ _ → isPropImplicitΠ λ _ → isPropΠ λ _ → θ .prop (λ _ _ → squash/ _ _) _ _) (funExt (elimProp (λ _ → pres squash/ _ _) (λ x → cong fst (θ .quo (X , f x) R (href x) .snd (f' [ x ] , c refl))))) where href = h ∘ R .snd .reflexive unaryFunSuitableRel pres {ρ} θ .symmetric R h {x} {y} r = θ .symmetric R (h r) unaryFunSuitableRel pres {ρ} θ .transitive R R' h h' {x} {z} = Trunc.rec (θ .prop (λ _ _ → squash) _ _) (λ {(y , r , r') → θ .transitive R R' (h r) (h' r')}) unaryFunSuitableRel pres {ρ} θ .prop propR f g = isPropImplicitΠ λ x → isPropImplicitΠ λ y → isPropΠ λ _ → θ .prop propR (f x) (g y) unaryFunRelMatchesEquiv : {S : Type ℓ → Type ℓ₁} (ρ : StrRel S ℓ₁') {ι : StrEquiv S ℓ₁'} → StrRelMatchesEquiv ρ ι → StrRelMatchesEquiv (UnaryFunRelStr ρ) (UnaryFunEquivStr ι) unaryFunRelMatchesEquiv ρ μ (X , f) (Y , g) e = compEquiv (isoToEquiv isom) (equivPi λ _ → μ _ _ e) where open Iso isom : Iso _ _ isom .fun h x = h refl isom .inv k {x} = J (λ y _ → ρ (graphRel (e .fst)) (f x) (g y)) (k x) isom .rightInv k i x = JRefl (λ y _ → ρ (graphRel (e .fst)) (f x) (g y)) (k x) i isom .leftInv h = implicitFunExt λ {x} → implicitFunExt λ {y} → funExt λ p → J (λ y p → isom .inv (isom .fun h) p ≡ h p) (funExt⁻ (isom .rightInv (isom .fun h)) x) p
{ "alphanum_fraction": 0.6130690162, "avg_line_length": 33.7685950413, "ext": "agda", "hexsha": "1f6e424848353bd91b65d15742217d9bf77637da", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "RobertHarper/cubical", "max_forks_repo_path": "Cubical/Structures/Relational/UnaryOp.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "RobertHarper/cubical", "max_issues_repo_path": "Cubical/Structures/Relational/UnaryOp.agda", "max_line_length": 92, "max_stars_count": null, "max_stars_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "RobertHarper/cubical", "max_stars_repo_path": "Cubical/Structures/Relational/UnaryOp.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1622, "size": 4086 }
module Bound.Total.Order {A : Set}(_≤_ : A → A → Set) where open import Bound.Total A data LeB : Bound → Bound → Set where lebx : {b : Bound} → LeB bot b lexy : {x y : A} → x ≤ y → LeB (val x) (val y) lext : {b : Bound} → LeB b top
{ "alphanum_fraction": 0.4267912773, "avg_line_length": 24.6923076923, "ext": "agda", "hexsha": "851a5a3c7b4889a801cc88a8d7787ac3ce0dc979", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/Bound/Total/Order.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/Bound/Total/Order.agda", "max_line_length": 60, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/Bound/Total/Order.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 103, "size": 321 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Groups.Homomorphisms.Definition open import Groups.Definition open import Rings.Definition open import Rings.Homomorphisms.Definition open import Rings.IntegralDomains.Definition open import Setoids.Setoids open import Sets.EquivalenceRelations module Fields.FieldOfFractions.Lemmas {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} {_*_ : A → A → A} {R : Ring S _+_ _*_} (I : IntegralDomain R) where open import Fields.FieldOfFractions.Setoid I open import Fields.FieldOfFractions.Ring I embedIntoFieldOfFractions : A → fieldOfFractionsSet embedIntoFieldOfFractions a = record { num = a ; denom = Ring.1R R ; denomNonzero = IntegralDomain.nontrivial I } homIntoFieldOfFractions : RingHom R fieldOfFractionsRing embedIntoFieldOfFractions RingHom.preserves1 homIntoFieldOfFractions = Equivalence.reflexive (Setoid.eq S) RingHom.ringHom homIntoFieldOfFractions {a} {b} = Equivalence.transitive (Setoid.eq S) (Ring.*WellDefined R (Equivalence.reflexive (Setoid.eq S)) (Ring.identIsIdent R)) (Ring.*Commutative R) GroupHom.groupHom (RingHom.groupHom homIntoFieldOfFractions) {x} {y} = need where open Setoid S open Equivalence eq need : ((x + y) * (Ring.1R R * Ring.1R R)) ∼ (Ring.1R R * ((x * Ring.1R R) + (Ring.1R R * y))) need = transitive (transitive (Ring.*WellDefined R reflexive (Ring.identIsIdent R)) (transitive (Ring.*Commutative R) (transitive (Ring.identIsIdent R) (Group.+WellDefined (Ring.additiveGroup R) (symmetric (transitive (Ring.*Commutative R) (Ring.identIsIdent R))) (symmetric (Ring.identIsIdent R)))))) (symmetric (Ring.identIsIdent R)) GroupHom.wellDefined (RingHom.groupHom homIntoFieldOfFractions) x=y = transitive (Ring.*Commutative R) (Ring.*WellDefined R reflexive x=y) where open Equivalence (Setoid.eq S) homIntoFieldOfFractionsIsInj : SetoidInjection S fieldOfFractionsSetoid embedIntoFieldOfFractions SetoidInjection.wellDefined homIntoFieldOfFractionsIsInj x=y = transitive (Ring.*Commutative R) (Ring.*WellDefined R reflexive x=y) where open Equivalence (Setoid.eq S) SetoidInjection.injective homIntoFieldOfFractionsIsInj x~y = transitive (symmetric identIsIdent) (transitive *Commutative (transitive x~y identIsIdent)) where open Ring R open Setoid S open Equivalence eq
{ "alphanum_fraction": 0.7664264519, "avg_line_length": 56.1666666667, "ext": "agda", "hexsha": "0f9f912bd262b61195d5184363e7eeaf9084660d", "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/FieldOfFractions/Lemmas.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/FieldOfFractions/Lemmas.agda", "max_line_length": 339, "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/FieldOfFractions/Lemmas.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": 709, "size": 2359 }
{- This file contains: - Properties of 2-groupoid truncations -} {-# OPTIONS --cubical --safe #-} module Cubical.HITs.2GroupoidTruncation.Properties where open import Cubical.Foundations.Prelude open import Cubical.HITs.2GroupoidTruncation.Base rec2GroupoidTrunc : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (gB : is2Groupoid B) → (A → B) → (∥ A ∥₂ → B) rec2GroupoidTrunc gB f ∣ x ∣₂ = f x rec2GroupoidTrunc gB f (squash₂ _ _ _ _ _ _ t u i j k l) = gB _ _ _ _ _ _ (λ m n o → rec2GroupoidTrunc gB f (t m n o)) (λ m n o → rec2GroupoidTrunc gB f (u m n o)) i j k l g2TruncFib : ∀ {ℓ ℓ'} {A : Type ℓ} (P : A → Type ℓ') {a b : A} (sPb : is2Groupoid (P b)) {p q : a ≡ b} {r s : p ≡ q} {u v : r ≡ s} (w : u ≡ v) {a1 : P a} {b1 : P b} {p1 : PathP (λ i → P (p i)) a1 b1} {q1 : PathP (λ i → P (q i)) a1 b1} {r1 : PathP (λ i → PathP (λ j → P (r i j)) a1 b1) p1 q1} {s1 : PathP (λ i → PathP (λ j → P (s i j)) a1 b1) p1 q1} (u1 : PathP (λ i → PathP (λ j → PathP (λ k → P (u i j k)) a1 b1) p1 q1) r1 s1) (v1 : PathP (λ i → PathP (λ j → PathP (λ k → P (v i j k)) a1 b1) p1 q1) r1 s1) → PathP (λ i → PathP (λ j → PathP (λ k → PathP (λ l → P (w i j k l)) a1 b1) p1 q1) r1 s1) u1 v1 g2TruncFib {A} P {a} {b} sPb {p} {q} {r} {s} {u} {v} w {a1} {b1} {p1} {q1} {r1} {s1} u1 v1 i j k l = hcomp (λ m → λ { (i = i0) → u1 j k l ; (i = i1) → v1 j k l ; (j = i0) → r1 k l ; (j = i1) → s1 k l ; (k = i0) → p1 l ; (k = i1) → q1 l ; (l = i0) → a1 ; (l = i1) → sPb b1 b1 refl refl refl refl L refl m i j k }) (Lb i j k l) where L : Path (Path (b1 ≡ b1) refl refl) refl refl L i j k = comp (λ l → P (w i j k l)) (λ l → λ { (i = i0) → u1 j k l ; (i = i1) → v1 j k l ; (j = i0) → r1 k l ; (j = i1) → s1 k l ; (k = i0) → p1 l ; (k = i1) → q1 l }) a1 Lb : PathP (λ i → PathP (λ j → PathP (λ k → PathP (λ l → P (w i j k l)) a1 (L i j k)) p1 q1) r1 s1) u1 v1 Lb i j k l = fill (λ l → P (w i j k l)) (λ l → λ { (i = i0) → u1 j k l ; (i = i1) → v1 j k l ; (j = i0) → r1 k l ; (j = i1) → s1 k l ; (k = i0) → p1 l ; (k = i1) → q1 l }) (inS a1) l g2TruncElim : ∀ {ℓ ℓ'} (A : Type ℓ) (B : ∥ A ∥₂ → Type ℓ') (bG : (x : ∥ A ∥₂) → is2Groupoid (B x)) (f : (x : A) → B ∣ x ∣₂) (x : ∥ A ∥₂) → B x g2TruncElim A B bG f ∣ x ∣₂ = f x g2TruncElim A B bG f (squash₂ x y p q r s u v i j k l) = g2TruncFib {A = ∥ A ∥₂} B {x} {y} (bG y) {p} {q} {r} {s} {u} {v} (squash₂ x y p q r s u v) {g2TruncElim A B bG f x} {g2TruncElim A B bG f y} {λ i → g2TruncElim A B bG f (p i)} {λ i → g2TruncElim A B bG f (q i)} {λ i j → g2TruncElim A B bG f (r i j)} {λ i j → g2TruncElim A B bG f (s i j)} (λ i j k → g2TruncElim A B bG f (u i j k)) (λ i j k → g2TruncElim A B bG f (v i j k)) i j k l
{ "alphanum_fraction": 0.3803455112, "avg_line_length": 43.0609756098, "ext": "agda", "hexsha": "88805968bb16dc537a0b01d0d79e5e9d2867a63f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/HITs/2GroupoidTruncation/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_path": "Cubical/HITs/2GroupoidTruncation/Properties.agda", "max_line_length": 107, "max_stars_count": null, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/HITs/2GroupoidTruncation/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1471, "size": 3531 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae module Decidable.Sets {a : _} (A : Set a) where DecidableSet : Set a DecidableSet = (a b : A) → ((a ≡ b) || ((a ≡ b) → False))
{ "alphanum_fraction": 0.6076555024, "avg_line_length": 23.2222222222, "ext": "agda", "hexsha": "332850efc0455f1b121716a4b8f2d8f20d47f4ad", "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": "Decidable/Sets.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": "Decidable/Sets.agda", "max_line_length": 57, "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": "Decidable/Sets.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": 70, "size": 209 }
{-# OPTIONS --without-K #-} open import Axiom.Extensionality.Propositional module FLA.Axiom.Extensionality.Propositional where -- Since (dependent) extensionality is not allowed in standard Agda, we -- postulate it here. In the standard library, the Extensionality term is -- given in the type, which is then often named `ext` as an input to the -- function. However this is cumberson, as anything using extensionality now -- needs to take extensionality as an argument. If this library was -- converted to cubical Agda we could prove extensionality directly, -- although we would lose UIP. postulate extensionality : ∀ {α β} → Extensionality α β
{ "alphanum_fraction": 0.7714723926, "avg_line_length": 40.75, "ext": "agda", "hexsha": "f01aa889fe2d8a9572c82e4ad2b210a8936f9946", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-09-07T19:55:59.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-12T20:34:17.000Z", "max_forks_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "turion/functional-linear-algebra", "max_forks_repo_path": "src/FLA/Axiom/Extensionality/Propositional.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_issues_repo_issues_event_max_datetime": "2022-01-07T05:27:53.000Z", "max_issues_repo_issues_event_min_datetime": "2020-09-01T01:42:12.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "turion/functional-linear-algebra", "max_issues_repo_path": "src/FLA/Axiom/Extensionality/Propositional.agda", "max_line_length": 76, "max_stars_count": 21, "max_stars_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "turion/functional-linear-algebra", "max_stars_repo_path": "src/FLA/Axiom/Extensionality/Propositional.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-07T05:28:00.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-22T20:49:34.000Z", "num_tokens": 155, "size": 652 }
------------------------------------------------------------------------ -- Some derivable properties ------------------------------------------------------------------------ open import Algebra module Algebra.Props.DistributiveLattice (dl : DistributiveLattice) where open DistributiveLattice dl import Algebra.Props.Lattice as L; open L lattice public open import Algebra.Structures import Algebra.FunctionProperties as P; open P _≈_ import Relation.Binary.EqReasoning as EqR; open EqR setoid open import Data.Function open import Data.Product ∨-∧-distrib : _∨_ DistributesOver _∧_ ∨-∧-distrib = ∨-∧-distribˡ , ∨-∧-distribʳ where ∨-∧-distribˡ : _∨_ DistributesOverˡ _∧_ ∨-∧-distribˡ x y z = begin x ∨ y ∧ z ≈⟨ ∨-comm _ _ ⟩ y ∧ z ∨ x ≈⟨ ∨-∧-distribʳ _ _ _ ⟩ (y ∨ x) ∧ (z ∨ x) ≈⟨ ∨-comm _ _ ⟨ ∧-pres-≈ ⟩ ∨-comm _ _ ⟩ (x ∨ y) ∧ (x ∨ z) ∎ ∧-∨-distrib : _∧_ DistributesOver _∨_ ∧-∨-distrib = ∧-∨-distribˡ , ∧-∨-distribʳ where ∧-∨-distribˡ : _∧_ DistributesOverˡ _∨_ ∧-∨-distribˡ x y z = begin x ∧ (y ∨ z) ≈⟨ sym (proj₂ absorptive _ _) ⟨ ∧-pres-≈ ⟩ refl ⟩ (x ∧ (x ∨ y)) ∧ (y ∨ z) ≈⟨ (refl ⟨ ∧-pres-≈ ⟩ ∨-comm _ _) ⟨ ∧-pres-≈ ⟩ refl ⟩ (x ∧ (y ∨ x)) ∧ (y ∨ z) ≈⟨ ∧-assoc _ _ _ ⟩ x ∧ ((y ∨ x) ∧ (y ∨ z)) ≈⟨ refl ⟨ ∧-pres-≈ ⟩ sym (proj₁ ∨-∧-distrib _ _ _) ⟩ x ∧ (y ∨ x ∧ z) ≈⟨ sym (proj₁ absorptive _ _) ⟨ ∧-pres-≈ ⟩ refl ⟩ (x ∨ x ∧ z) ∧ (y ∨ x ∧ z) ≈⟨ sym $ proj₂ ∨-∧-distrib _ _ _ ⟩ x ∧ y ∨ x ∧ z ∎ ∧-∨-distribʳ : _∧_ DistributesOverʳ _∨_ ∧-∨-distribʳ x y z = begin (y ∨ z) ∧ x ≈⟨ ∧-comm _ _ ⟩ x ∧ (y ∨ z) ≈⟨ ∧-∨-distribˡ _ _ _ ⟩ x ∧ y ∨ x ∧ z ≈⟨ ∧-comm _ _ ⟨ ∨-pres-≈ ⟩ ∧-comm _ _ ⟩ y ∧ x ∨ z ∧ x ∎ -- The dual construction is also a distributive lattice. ∧-∨-isDistributiveLattice : IsDistributiveLattice _≈_ _∧_ _∨_ ∧-∨-isDistributiveLattice = record { isLattice = ∧-∨-isLattice ; ∨-∧-distribʳ = proj₂ ∧-∨-distrib } ∧-∨-distributiveLattice : DistributiveLattice ∧-∨-distributiveLattice = record { _∧_ = _∨_ ; _∨_ = _∧_ ; isDistributiveLattice = ∧-∨-isDistributiveLattice }
{ "alphanum_fraction": 0.4997730368, "avg_line_length": 34.9682539683, "ext": "agda", "hexsha": "5f1319d1604044f743d11fdcaf9137576ea02e60", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Algebra/Props/DistributiveLattice.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Algebra/Props/DistributiveLattice.agda", "max_line_length": 84, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Algebra/Props/DistributiveLattice.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 977, "size": 2203 }
even : ℕ → Bool odd : ℕ → Bool even zero = true even (suc n) = odd n odd zero = false odd (suc n) = even n
{ "alphanum_fraction": 0.5603448276, "avg_line_length": 12.8888888889, "ext": "agda", "hexsha": "95a3563125fb8db2bf082a4a15d4a1afa18dff11", "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": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": [ "Info-ZIP" ], "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_path": "Task/Even-or-odd/Agda/even-or-odd.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Info-ZIP" ], "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_path": "Task/Even-or-odd/Agda/even-or-odd.agda", "max_line_length": 20, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": [ "Info-ZIP" ], "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_path": "Task/Even-or-odd/Agda/even-or-odd.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T13:42:20.000Z", "max_stars_repo_stars_event_min_datetime": "2021-05-05T13:42:20.000Z", "num_tokens": 45, "size": 116 }
{- Please do not move this file. Changes should only be made if necessary. This file contains pointers to the code examples and main results from the paper: Internalizing Representation Independence with Univalence Carlo Angiuli, Evan Cavallo, Anders Mörtberg, Max Zeuner Preprint: https://arxiv.org/abs/2009.05547 -} {-# OPTIONS --safe #-} module Cubical.Papers.RepresentationIndependence where -- 2.1 import Agda.Builtin.Cubical.Path as Path import Cubical.Foundations.Prelude as Prelude -- 2.2 import Cubical.Foundations.Univalence as Univalence import Cubical.Foundations.HLevels as HLevels import Cubical.Foundations.Equiv as Equivalences import Cubical.Data.Sigma.Properties as Sigma -- 2.3 import Cubical.HITs.PropositionalTruncation as PropositionalTruncation import Cubical.HITs.Cost.Base as CostMonad import Cubical.HITs.SetQuotients as SetQuotients import Cubical.HITs.Rationals.QuoQ as SetQuoQ import Cubical.HITs.Rationals.SigmaQ as SigmaQ -- 3.1 import Cubical.Foundations.SIP as SIP import Cubical.Structures.Axioms as Axioms import Cubical.Algebra.Semigroup.Base as Semigroup open import Cubical.Data.Sigma.Base -- 3.2 import Cubical.Structures.Pointed as PointedStr import Cubical.Structures.Constant as ConstantStr import Cubical.Structures.Product as ProductStr import Cubical.Structures.Function as FunctionStr import Cubical.Structures.Maybe as MaybeStr import Cubical.Foundations.Structure as Structure import Cubical.Structures.Auto as Auto open import Cubical.Data.Maybe.Base -- 4.1 import Cubical.Data.Vec.Base as Vector import Cubical.Algebra.Matrix as Matrices import Cubical.Data.FinData.Base as Finite open import Cubical.Algebra.AbGroup.Base open import Cubical.Data.Bool.Base -- 4.2 import Cubical.Structures.Queue as Queues import Cubical.Data.Queue.Truncated2List as BatchedQueues -- 5.1 import Cubical.Relation.Binary.Base as BinRel import Cubical.Relation.ZigZag.Base as QER import Cubical.Relation.ZigZag.Applications.MultiSet as MultiSets -- 5.2 import Cubical.Foundations.RelationalStructure as RelStructure import Cubical.Structures.Relational.Function as RelFunction ------------------------------------------------------------------------- -- 2. Programming in Cubical Type Theory -- 2.1 Equalities as Paths -- 2.2 Univalence -- 2.3 Higher Inductive Types ------------------------------------------------------------------------- -- 2.1 Equalities as Paths open Path using (PathP) public open Prelude using (_≡_ ; refl ; cong ; funExt ; transport ; subst ; J) public -- 2.2 Univalence open Univalence using (ua ; uaβ) public -- Sets and Propositions open Prelude using (isProp ; isSet) public open HLevels using (isPropΠ) public open Prelude using (isContr) public -- Equivalences and Isomorphisms open Equivalences using (isEquiv ; _≃_) public open Equivalences renaming (fiber to preim) public open Sigma using (ΣPath≃PathΣ) public open Equivalences renaming (propBiimpl→Equiv to prop≃) public -- 2.3 Higher Inductive Types -- Propositional Truncation open PropositionalTruncation using (∥_∥ ; map) public open CostMonad using (Cost ; Cost≡ ; _>>=_ ; return ; fib ; fibTail) public -- Computation _ : fib 20 ≡ (6765 , PropositionalTruncation.∣ 21890 ∣) _ = refl _ : fibTail 20 ≡ (6765 , PropositionalTruncation.∣ 19 ∣) _ = refl -- Set Quotients open SetQuotients using (_/_ ; setQuotUniversal) public -- Rational Numbers open SetQuoQ using (_∼_ ; ℚ) public open SigmaQ renaming (ℚ to ℚ') public ------------------------------------------------------------------------- -- 3. The Structure Identity Principle -- 3.1 Structures -- 3.2 Building Strucutres ------------------------------------------------------------------------- -- 3.1 Structures open SIP using (TypeWithStr ; StrEquiv ; _≃[_]_ ; UnivalentStr ; SIP ; sip) public -- the last two terms above correspond to lemma 3.3 -- and corollary 3.4 respectively open Axioms using ( AxiomsStructure ; AxiomsEquivStr ; axiomsUnivalentStr ; transferAxioms) public -- Monoids are defined using records and Σ-types in the library RawMonoidStructure : Type → Type RawMonoidStructure X = X × (X → X → X) MonoidAxioms : (M : Type) → RawMonoidStructure M → Type MonoidAxioms M (e , _·_) = Semigroup.IsSemigroup _·_ × ((x : M) → (x · e ≡ x) × (e · x ≡ x)) MonoidStructure : Type → Type MonoidStructure = AxiomsStructure RawMonoidStructure MonoidAxioms Monoid : Type₁ Monoid = TypeWithStr ℓ-zero MonoidStructure MonoidEquiv : (M N : Monoid) → fst M ≃ fst N → Type MonoidEquiv (_ , (εᴹ , _·_) , _) (_ , (εᴺ , _∗_) , _) (φ , _) = (φ εᴹ ≡ εᴺ) × (∀ x y → φ (x · y) ≡ (φ x) ∗ (φ y)) -- 3.2 Building Structures -- Constant and Pointed Structures open PointedStr using (PointedStructure ; PointedEquivStr ; pointedUnivalentStr) public open ConstantStr using (ConstantStructure ; ConstantEquivStr ; constantUnivalentStr) public -- Product Structures open ProductStr using (ProductStructure ; ProductEquivStr ; productUnivalentStr) public -- Function Structures open FunctionStr using (FunctionEquivStr) public -- Maybe Structures open MaybeStr using (MaybeEquivStr) public -- Transport Structures open Structure using (EquivAction) public open SIP using (TransportStr ; TransportStr→UnivalentStr ; UnivalentStr→TransportStr) public open Structure using (EquivAction→StrEquiv) public open FunctionStr using (FunctionEquivStr+) public -- Monoids Revisited RawMonoid : Type₁ RawMonoid = TypeWithStr _ RawMonoidStructure Monoid→RawMonoid : Monoid → RawMonoid Monoid→RawMonoid (A , r , _) = (A , r) RawMonoidEquivStr = Auto.AutoEquivStr RawMonoidStructure rawMonoidUnivalentStr : UnivalentStr _ RawMonoidEquivStr rawMonoidUnivalentStr = Auto.autoUnivalentStr RawMonoidStructure isPropMonoidAxioms : (M : Type) (s : RawMonoidStructure M) → isProp (MonoidAxioms M s) isPropMonoidAxioms M (e , _·_) = HLevels.isPropΣ (Semigroup.isPropIsSemigroup _·_) (λ α → isPropΠ λ _ → HLevels.isProp× (Semigroup.IsSemigroup.is-set α _ _) (Semigroup.IsSemigroup.is-set α _ _)) MonoidEquivStr : StrEquiv MonoidStructure ℓ-zero MonoidEquivStr = AxiomsEquivStr RawMonoidEquivStr MonoidAxioms monoidUnivalentStr : UnivalentStr MonoidStructure MonoidEquivStr monoidUnivalentStr = axiomsUnivalentStr _ isPropMonoidAxioms rawMonoidUnivalentStr MonoidΣPath : (M N : Monoid) → (M ≃[ MonoidEquivStr ] N) ≃ (M ≡ N) MonoidΣPath = SIP monoidUnivalentStr InducedMonoid : (M : Monoid) (N : RawMonoid) (e : M .fst ≃ N .fst) → RawMonoidEquivStr (Monoid→RawMonoid M) N e → Monoid InducedMonoid M N e r = Axioms.inducedStructure rawMonoidUnivalentStr M N (e , r) InducedMonoidPath : (M : Monoid) (N : RawMonoid) (e : M .fst ≃ N .fst) (E : RawMonoidEquivStr (Monoid→RawMonoid M) N e) → M ≡ InducedMonoid M N e E InducedMonoidPath M N e E = MonoidΣPath M (InducedMonoid M N e E) .fst (e , E) -- Automation open Auto using (Transp[_] ; AutoEquivStr ; autoUnivalentStr) public module _ (A : Type) (Aset : isSet A) where RawQueueEquivStr = AutoEquivStr (λ (X : Type) → X × (A → X → X) × (X → Transp[ Maybe (X × A) ])) ------------------------------------------------------------------------- -- 4. Representation Independence through the SIP -- 4.1 Matrices -- 4.2 Queues ------------------------------------------------------------------------- -- 4.1 Matrices open Vector using (Vec) public open Finite using (Fin ; _==_) public open Matrices using (VecMatrix ; FinMatrix ; FinMatrix≡VecMatrix ; FinMatrix≃VecMatrix) public open Matrices.FinMatrixAbGroup using (addFinMatrix ; addFinMatrixComm) public -- example (not in the library) open import Cubical.Data.Int renaming (Int to ℤ ; isSetInt to isSetℤ) hiding (-_) ℤ-AbGroup : AbGroup ℓ-zero ℤ-AbGroup = makeAbGroup {G = ℤ} 0 _+_ -_ isSetℤ +-assoc (λ x _ → x) rem +-comm where -_ : ℤ → ℤ - x = 0 - x rem : (x : ℤ) → x + (- x) ≡ 0 rem x = +-comm x (pos 0 - x) Prelude.∙ minusPlus x 0 module experiment where open Prelude M : FinMatrix ℤ 2 2 M i j = if i == j then 1 else 0 N : FinMatrix ℤ 2 2 N i j = if i == j then 0 else 1 replaceGoal : {A B : Type} {x y : A} → (e : A ≃ B) (h : invEq e (equivFun e x) ≡ invEq e (equivFun e y)) → x ≡ y replaceGoal e h = sym (retEq e _) ∙∙ h ∙∙ retEq e _ _ : addFinMatrix ℤ-AbGroup M N ≡ (λ _ _ → 1) _ = replaceGoal (FinMatrix≃VecMatrix) refl -- 4.2 Queues open Queues.Queues-on using (RawQueueStructure ; QueueAxioms) public open BatchedQueues.Truncated2List renaming (Q to BatchedQueueHIT) using (Raw-1≡2 ; WithLaws) public ------------------------------------------------------------------------- -- 5. Structured Equivalences from Structured Relations -- 5.1 Quasi-Equivalence Relations -- 5.2 Structured Relations ------------------------------------------------------------------------- -- 5.1 Quasi-Equivalence Relations --Lemma (5.1) open BinRel using (idPropRel ; invPropRel ; compPropRel ; graphRel) public -- Definitions (5.2) and (5.3) open QER using (isZigZagComplete ; isQuasiEquivRel) public -- Lemma (5.4) open QER.QER→Equiv using (Thm ; bwd≡ToRel) public -- Multisets open MultiSets renaming (AList to AssocList) public open MultiSets.Lists&ALists using (addIfEq ; R ; φ ; ψ ; List/Rᴸ≃AList/Rᴬᴸ) public open MultiSets.Lists&ALists.L using (insert ; union ; count) open MultiSets.Lists&ALists.AL using (insert ; union ; count) -- 5.2 Structured Relations open RelStructure using (StrRel) public -- Definition (5.6) open RelStructure using (SuitableStrRel) public -- Theorem (5.7) open RelStructure using (structuredQER→structuredEquiv) public -- Definition (5.9) open RelStructure using (StrRelAction) public -- Lemma (5.10) open RelStructure using (strRelQuotientComparison) public -- Definition (5.11) open RelStructure using (PositiveStrRel) public -- Theorem (5.12) open RelFunction using (functionSuitableRel) public -- Multisets -- (main is applying 5.7 to the example) open MultiSets.Lists&ALists using (multisetShape ; isStructuredR ; main ; List/Rᴸ≡AList/Rᴬᴸ) renaming ( hasAssociativeUnion to unionAssocAxiom ; LQassoc to LUnionAssoc ; ALQassoc to ALUnionAssoc) public
{ "alphanum_fraction": 0.6420043415, "avg_line_length": 35.0984126984, "ext": "agda", "hexsha": "4131eadba26c7a758ad5239ae4cc8047f7e3248d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-03-12T20:08:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-03-12T20:08:45.000Z", "max_forks_repo_head_hexsha": "ce8fe04f9c5d2c9faf8690885c1b702434626621", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "LuuBluum/cubical", "max_forks_repo_path": "Cubical/Papers/RepresentationIndependence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ce8fe04f9c5d2c9faf8690885c1b702434626621", "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": "LuuBluum/cubical", "max_issues_repo_path": "Cubical/Papers/RepresentationIndependence.agda", "max_line_length": 92, "max_stars_count": null, "max_stars_repo_head_hexsha": "ce8fe04f9c5d2c9faf8690885c1b702434626621", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "LuuBluum/cubical", "max_stars_repo_path": "Cubical/Papers/RepresentationIndependence.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3146, "size": 11056 }
open import Nat open import Prelude open import Hazelnut-core module Hazelnut-sensible where -- theorem 1: action sensibility synthmovelem : {Γ : ·ctx} {e e' : ê} {t : τ̇} {δ : direction} → (e + move δ +>e e') → (Γ ⊢ e ◆e => t) → (Γ ⊢ e' ◆e => t) synthmovelem EMAscFirstChild d2 = d2 synthmovelem EMAscParent1 d2 = d2 synthmovelem EMAscParent2 d2 = d2 synthmovelem EMAscNextSib d2 = d2 synthmovelem EMAscPrevSib d2 = d2 synthmovelem EMLamFirstChild d2 = d2 synthmovelem EMLamParent d2 = d2 synthmovelem EMPlusFirstChild d2 = d2 synthmovelem EMPlusParent1 d2 = d2 synthmovelem EMPlusParent2 d2 = d2 synthmovelem EMPlusNextSib d2 = d2 synthmovelem EMPlusPrevSib d2 = d2 synthmovelem EMApFirstChild d2 = d2 synthmovelem EMApParent1 d2 = d2 synthmovelem EMApParent2 d2 = d2 synthmovelem EMApNextSib d2 = d2 synthmovelem EMApPrevSib d2 = d2 synthmovelem EMFHoleFirstChild d2 = d2 synthmovelem EMFHoleParent d2 = d2 -- movements preserve analytic types up to erasure. this lemma seems -- silly because all it seems to do in each case is return the second -- derivation D. the pattern matching here, though, constrains what that -- derivation may be in each case, and is therefore actually -- non-trivial. it's just that most of the work is happening in the -- implicit arguments. anamovelem : {Γ : ·ctx} {δ : direction} {e e' : ê} {t : τ̇} (p : e + move δ +>e e') → (Γ ⊢ e ◆e <= t) → (Γ ⊢ e' ◆e <= t) anamovelem EMAscFirstChild d2 = d2 anamovelem EMAscParent1 d2 = d2 anamovelem EMAscParent2 d2 = d2 anamovelem EMAscNextSib d2 = d2 anamovelem EMAscPrevSib d2 = d2 anamovelem EMLamFirstChild d2 = d2 anamovelem EMLamParent d2 = d2 anamovelem EMPlusFirstChild d2 = d2 anamovelem EMPlusParent1 d2 = d2 anamovelem EMPlusParent2 d2 = d2 anamovelem EMPlusNextSib d2 = d2 anamovelem EMPlusPrevSib d2 = d2 anamovelem EMApFirstChild d2 = d2 anamovelem EMApParent1 d2 = d2 anamovelem EMApParent2 d2 = d2 anamovelem EMApNextSib d2 = d2 anamovelem EMApPrevSib d2 = d2 anamovelem EMFHoleFirstChild d2 = d2 anamovelem EMFHoleParent d2 = d2 mutual -- if an action transforms an zexp in a synthetic posistion to another -- zexp, they have the same type up erasure of focus. actsense1 : {Γ : ·ctx} {e e' : ê} {t t' : τ̇} {α : action} → (Γ ⊢ e => t ~ α ~> e' => t') → (Γ ⊢ (e ◆e) => t) → Γ ⊢ (e' ◆e) => t' actsense1 (SAMove x) D2 = synthmovelem x D2 actsense1 SADel D2 = SEHole actsense1 SAConAsc D2 = SAsc (ASubsume D2 TCRefl) actsense1 (SAConVar p) D2 = SVar p actsense1 (SAConLam p) D2 = SAsc (ALam p (ASubsume SEHole TCRefl)) actsense1 SAConAp1 D2 = SAp D2 (ASubsume SEHole TCHole1) actsense1 SAConAp2 D2 = SApHole D2 (ASubsume SEHole TCRefl) actsense1 (SAConAp3 x) D2 = SApHole (SFHole D2) (ASubsume SEHole TCRefl) actsense1 SAConArg D2 = SApHole SEHole (ASubsume D2 TCHole2) actsense1 SAConNumlit D2 = SNum actsense1 (SAConPlus1 TCRefl) D2 = SPlus (ASubsume D2 TCRefl) (ASubsume SEHole TCHole1) actsense1 (SAConPlus1 TCHole2) D2 = SPlus (ASubsume D2 TCHole1) (ASubsume SEHole TCHole1) actsense1 (SAConPlus2 x) D2 = SPlus (ASubsume (SFHole D2) TCHole1) (ASubsume SEHole TCHole1) actsense1 (SAFinish x) D2 = x actsense1 (SAZipAsc1 x) (SAsc D2) = SAsc (actsense2 x D2) actsense1 (SAZipAsc2 x x₁) _ = SAsc x₁ actsense1 (SAZipAp1 x D1 x₁) D2 = SAp (actsense1 D1 x) x₁ actsense1 (SAZipAp2 x D1 x₁) D2 = SApHole (actsense1 D1 x) x₁ actsense1 (SAZipAp3 x x₁) (SAp D2 x₃) with synthunicity x D2 ... | refl = SAp x (actsense2 x₁ x₃) actsense1 (SAZipAp3 x x₁) (SApHole D2 x₂) with synthunicity x D2 ... | () actsense1 (SAZipAp4 x x₁) (SAp D2 x₂) with synthunicity x D2 ... | () actsense1 (SAZipAp4 x x₁) (SApHole D2 x₂) = SApHole x (actsense2 x₁ x₂) actsense1 (SAZipPlus1 x) (SPlus x₁ x₂) = SPlus (actsense2 x x₁) x₂ actsense1 (SAZipPlus2 x) (SPlus x₁ x₂) = SPlus x₁ (actsense2 x x₂) actsense1 (SAZipHole1 x D1 x₁) D2 = SFHole (actsense1 D1 x) actsense1 (SAZipHole2 x D1) D2 = SEHole -- if an action transforms an zexp in an analytic posistion to another -- zexp, they have the same type up erasure of focus. actsense2 : {Γ : ·ctx} {e e' : ê} {t : τ̇} {α : action} → (Γ ⊢ e ~ α ~> e' ⇐ t) → (Γ ⊢ (e ◆e) <= t) → (Γ ⊢ (e' ◆e) <= t) actsense2 (AASubsume x act p) D2 = ASubsume (actsense1 act x) p actsense2 (AAMove x) D2 = anamovelem x D2 actsense2 AADel _ = ASubsume SEHole TCHole1 actsense2 AAConAsc D2 = ASubsume (SAsc D2) TCRefl actsense2 (AAConVar x₁ p) D2 = ASubsume (SFHole (SVar p)) TCHole1 actsense2 (AAConLam1 p) (ASubsume SEHole TCHole1) = ALam p (ASubsume SEHole TCHole1) actsense2 (AAConLam2 p n~) (ASubsume SEHole TCRefl) = abort (n~ TCHole2) actsense2 (AAConLam2 p x₁) (ASubsume SEHole TCHole1) = ASubsume (SFHole (SAsc (ALam p (ASubsume SEHole TCRefl)))) TCHole1 actsense2 (AAConLam2 p n~) (ASubsume SEHole TCHole2) = abort (n~ TCHole2) actsense2 (AAConNumlit _) _ = ASubsume (SFHole SNum) TCHole1 actsense2 (AAFinish x) _ = x actsense2 (AAZipLam _ _ ) (ASubsume () _) actsense2 (AAZipLam x₁ (AASubsume {p = p} x₂ x₃ x₄)) (ALam x₅ D2) = ALam x₅ (actsense2 (AASubsume {p = p} x₂ x₃ x₄) D2) actsense2 (AAZipLam x₁ (AAMove x₂)) (ALam x₃ D2) = ALam x₃ (anamovelem x₂ D2) actsense2 (AAZipLam x₁ AADel) (ALam x₂ D2) = ALam x₂ (ASubsume SEHole TCHole1) actsense2 (AAZipLam x₁ AAConAsc) (ALam x₂ (ASubsume x₃ x₄)) = ALam x₂ (ASubsume (SAsc (ASubsume x₃ x₄)) TCRefl) actsense2 (AAZipLam x₁ AAConAsc) (ALam x₂ (ALam x₃ D2)) = ALam x₂ (ASubsume (SAsc (ALam x₃ D2)) TCRefl) actsense2 (AAZipLam x₁ (AAConVar x₃ p)) (ALam x₄ D2) = ALam x₄ (ASubsume (SFHole (SVar p)) TCHole1) actsense2 (AAZipLam x₁ (AAConLam1 x₃)) (ALam x₄ D2) = ALam x₄ (ALam x₃ (ASubsume SEHole TCHole1)) actsense2 (AAZipLam x₁ (AAConLam2 x₃ x₄)) (ALam x₅ D2) = ALam x₅ (ASubsume (SFHole (SAsc (ALam x₃ (ASubsume SEHole TCRefl)))) TCHole1) actsense2 (AAZipLam x₁ (AAConNumlit x₂)) (ALam x₃ D2) = ALam x₃ (ASubsume (SFHole SNum) TCHole1) actsense2 (AAZipLam x₁ (AAFinish x₂)) (ALam x₃ D2) = ALam x₃ x₂ actsense2 (AAZipLam x₁ (AAZipLam x₃ D1)) (ALam x₄ (ASubsume () x₆)) actsense2 (AAZipLam x₁ (AAZipLam x₃ D1)) (ALam x₄ (ALam x₅ D2)) = ALam x₄ (ALam x₃ (actsense2 D1 D2))
{ "alphanum_fraction": 0.6568538647, "avg_line_length": 50.9538461538, "ext": "agda", "hexsha": "7233eedea87e7f29a8f97b1b9417fa79f3daee45", "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": "Hazelnut-sensible.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": "Hazelnut-sensible.agda", "max_line_length": 129, "max_stars_count": 2, "max_stars_repo_head_hexsha": "86a755ca6749e080f9a03287e34d1cda889f1edb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ivoysey/agda-tfp16", "max_stars_repo_path": "Hazelnut-sensible.agda", "max_stars_repo_stars_event_max_datetime": "2016-04-14T02:19:58.000Z", "max_stars_repo_stars_event_min_datetime": "2016-04-09T13:35:22.000Z", "num_tokens": 2824, "size": 6624 }
--{-# OPTIONS --allow-unsolved-metas #-} module StateSizedIO.GUI.Prelude where open import Size public renaming (Size to AgdaSize) open import Data.Nat.Base public open import Data.Bool.Base hiding (_≟_) public open import Data.List.Base public open import Function public open import Data.Integer.Base public hiding (_*_; _+_; _-_; _⊓_; _⊔_; pred; suc;_≤_) open import Agda.Builtin.Equality public open import Data.Product public using (_×_; _,_) open import NativeIO public open import StateSizedIO.GUI.WxBindingsFFI public open import StateSizedIO.GUI.VariableList public open import SizedIO.Base public open import StateSizedIO.GUI.BaseStateDependent public
{ "alphanum_fraction": 0.7907324365, "avg_line_length": 29.0869565217, "ext": "agda", "hexsha": "b58734583d369778447923fbbae41e3d337db345", "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/GUI/Prelude.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/GUI/Prelude.agda", "max_line_length": 84, "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/GUI/Prelude.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": 172, "size": 669 }
-- Andreas, 2019-08-20, issue #4012 -- unquoteDef and unquoteDecl should respect `private` open import Agda.Builtin.Reflection renaming (bindTC to _>>=_) open import Agda.Builtin.List data D : Set where c : D module M where private unquoteDecl g = do ty ← quoteTC D _ ← declareDef (arg (arg-info visible relevant) g) ty qc ← quoteTC c defineFun g (clause [] qc ∷ []) open M test = g -- Expect failure. -- g is private in M, thus, should not be in scope
{ "alphanum_fraction": 0.6578947368, "avg_line_length": 19, "ext": "agda", "hexsha": "3d6a1e1df3bf3c614d3eedecf11a7f5e74c94f8d", "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/Issue4012UnquotePrivate.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/Issue4012UnquotePrivate.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/Fail/Issue4012UnquotePrivate.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": 148, "size": 494 }
{-# OPTIONS --without-K #-} {- Imports everything that is not imported by something else. This is not supposed to be used anywhere, this is just a simple way to do `make all' This file is intentionally named index.agda so that Agda will generate index.html. -} module index where -- import Spaces.IntervalProps -- import Algebra.F2NotCommutative import homotopy.LoopSpaceCircle import homotopy.HopfJunior import homotopy.Hopf import homotopy.CoverClassification import homotopy.AnyUniversalCoverIsPathSet import homotopy.PathSetIsInital -- import Spaces.LoopSpaceDecidableWedgeCircles -- import Homotopy.PullbackIsPullback -- import Homotopy.PushoutIsPushout -- import Homotopy.Truncation -- import Sets.QuotientUP -- import Spaces.PikSn -- import Homotopy.VanKampen
{ "alphanum_fraction": 0.813229572, "avg_line_length": 26.5862068966, "ext": "agda", "hexsha": "9a6e9064f4f7ad1dd7df4326be4fd5f03de35658", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "index.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "index.agda", "max_line_length": 70, "max_stars_count": 1, "max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda", "max_stars_repo_path": "index.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "num_tokens": 205, "size": 771 }
open import Data.List using (List; _∷_; []) open import Data.Product using (_×_; _,_; Σ) open import Data.Unit using (⊤; tt) open import Relation.Binary.PropositionalEquality using (_≡_) module SystemT where data _∈_ {A : Set} : (x : A) (l : List A) → Set where -- type \in i0 : {x : A} {xs : List A} → x ∈ (x ∷ xs) iS : {x y : A} {xs : List A} → x ∈ xs → x ∈ (y ∷ xs) data TType : Set where base : TType _⟶_ : TType → TType → TType Context = List TType _,,_ : Context → TType → Context Γ ,, τ = τ ∷ Γ infixr 10 _⟶_ infixr 9 _,,_ infixr 8 _⊢_ data _⊢_ (Γ : Context) : TType → Set where -- Some constant of the base type whose type is immediate. c : Γ ⊢ base -- Variable. var : {τ : TType} → τ ∈ Γ → Γ ⊢ τ -- Function introduction. lam : {τ₁ τ₂ : TType} → Γ ,, τ₁ ⊢ τ₂ → Γ ⊢ τ₁ ⟶ τ₂ -- Function application. app : {τ₁ τ₂ : TType} → (Γ ⊢ τ₁ ⟶ τ₂) → Γ ⊢ τ₁ → Γ ⊢ τ₂ module Semantics (B : Set) (elB : B) where -- Interpretation of System T types to Agda types. ⟦_⟧t : TType → Set ⟦ base ⟧t = B ⟦ τ₁ ⟶ τ₂ ⟧t = ⟦ τ₁ ⟧t → ⟦ τ₂ ⟧t -- Interpretation of System T contexts to Agda types. ⟦_⟧c : Context → Set ⟦ [] ⟧c = ⊤ ⟦ τ ∷ Γ ⟧c = ⟦ Γ ⟧c × ⟦ τ ⟧t -- Interpretation of terms. ⟦_⟧ : {Γ : Context} {τ : TType} → (Γ ⊢ τ) → ⟦ Γ ⟧c → ⟦ τ ⟧t ⟦ c ⟧ γ = elB ⟦ var x ⟧ γ = {! !} ⟦ lam e ⟧ γ x = {! !} ⟦ app e₁ e₂ ⟧ γ = {! !}
{ "alphanum_fraction": 0.507565337, "avg_line_length": 27.4339622642, "ext": "agda", "hexsha": "77a237e4e8229b2e2c63b9e5d8db0dcf495e2d4c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "785c3d1f93ce2dac7801504b806abfd59f3875f6", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "ayberkt/system-t-normalization", "max_forks_repo_path": "SystemT.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "785c3d1f93ce2dac7801504b806abfd59f3875f6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "ayberkt/system-t-normalization", "max_issues_repo_path": "SystemT.agda", "max_line_length": 67, "max_stars_count": 3, "max_stars_repo_head_hexsha": "785c3d1f93ce2dac7801504b806abfd59f3875f6", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "ayberkt/system-t-normalization", "max_stars_repo_path": "SystemT.agda", "max_stars_repo_stars_event_max_datetime": "2016-06-25T03:40:58.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-24T14:36:42.000Z", "num_tokens": 618, "size": 1454 }
{-# OPTIONS --universe-polymorphism #-} -- {-# OPTIONS --verbose tc.records.ifs:15 #-} -- {-# OPTIONS --verbose tc.constr.findInScope:15 #-} -- {-# OPTIONS --verbose tc.term.args.ifs:15 #-} module 05-equality-std1 where open import Relation.Binary using (IsDecEquivalence; module IsDecEquivalence; Reflexive; module DecSetoid) open import Data.Bool using (false; true; decSetoid) open DecSetoid decSetoid using (isDecEquivalence) open module IsDecEquivalenceWithImplicits = IsDecEquivalence {{...}} using (_≟_) test = false ≟ true test2 : ∀ {a ℓ} {A : Set a} {_≈_} → {{ide : IsDecEquivalence {a} {ℓ} {A} _≈_}} → Reflexive _≈_ test2 = IsDecEquivalenceWithImplicits.refl
{ "alphanum_fraction": 0.7042459736, "avg_line_length": 34.15, "ext": "agda", "hexsha": "d5f288c4470d0f68bc03edcdc11d4a057ba6cc7b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_path": "examples/instance-arguments/05-equality-std1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_path": "examples/instance-arguments/05-equality-std1.agda", "max_line_length": 106, "max_stars_count": null, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "examples/instance-arguments/05-equality-std1.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 211, "size": 683 }
module Thesis.SIRelBigStep.DenSem where open import Data.Nat open import Data.Product open import Thesis.SIRelBigStep.Syntax open import Data.Nat ⟦_⟧Type : Type → Set ⟦ σ ⇒ τ ⟧Type = ⟦ σ ⟧Type → ⟦ τ ⟧Type ⟦ nat ⟧Type = ℕ ⟦ pair τ1 τ2 ⟧Type = ⟦ τ1 ⟧Type × ⟦ τ2 ⟧Type import Base.Denotation.Environment module Den = Base.Denotation.Environment Type ⟦_⟧Type open import Base.Data.DependentList ⟦_⟧Const : ∀ {τ} → Const τ → ⟦ τ ⟧Type ⟦ lit n ⟧Const = n ⟦_⟧Primitive : ∀ {τ} → Primitive τ → ⟦ τ ⟧Type ⟦ succ ⟧Primitive = suc ⟦ add ⟧Primitive = λ { (n1 , n2) → n1 + n2} ⟦_⟧Term : ∀ {Γ τ} → Term Γ τ → Den.⟦ Γ ⟧Context → ⟦ τ ⟧Type ⟦_⟧SVal : ∀ {Γ τ} → SVal Γ τ → Den.⟦ Γ ⟧Context → ⟦ τ ⟧Type ⟦ var x ⟧SVal ρ = Den.⟦ x ⟧Var ρ ⟦ abs t ⟧SVal ρ = λ v → ⟦ t ⟧Term (v • ρ) ⟦ cons sv1 sv2 ⟧SVal ρ = ⟦ sv1 ⟧SVal ρ , ⟦ sv2 ⟧SVal ρ ⟦ const c ⟧SVal ρ = ⟦ c ⟧Const ⟦ val sv ⟧Term ρ = ⟦ sv ⟧SVal ρ ⟦ app s t ⟧Term ρ = ⟦ s ⟧SVal ρ (⟦ t ⟧SVal ρ) ⟦ lett s t ⟧Term ρ = ⟦ t ⟧Term ((⟦ s ⟧Term ρ) • ρ) ⟦ primapp vs vt ⟧Term ρ = ⟦ vs ⟧Primitive (⟦ vt ⟧SVal ρ)
{ "alphanum_fraction": 0.593840231, "avg_line_length": 28.8611111111, "ext": "agda", "hexsha": "a429709d293f643d32013a89205d364a0df2f83c", "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/DenSem.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/DenSem.agda", "max_line_length": 59, "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/DenSem.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": 510, "size": 1039 }
-- Subtyping is no longer supported for irrelevance. f : {A B : Set} → (.A → B) → A → B f g = λ .x → g x
{ "alphanum_fraction": 0.5471698113, "avg_line_length": 21.2, "ext": "agda", "hexsha": "6b9f9da300fcd19aeb734dcdb8959c3d2949f439", "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/Relevance-subtyping-2.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/Relevance-subtyping-2.agda", "max_line_length": 52, "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/Relevance-subtyping-2.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 40, "size": 106 }
open import Agda.Builtin.Equality open import Agda.Builtin.Sigma postulate X : Set variable x : X data C : Σ X (λ x → x ≡ x) → Set where mkC : let eq : x ≡ x -- don't generalize over x at eq eq = refl {x = x} in C (x , eq)
{ "alphanum_fraction": 0.5691699605, "avg_line_length": 16.8666666667, "ext": "agda", "hexsha": "399682558c63730eef0bf55acf28a4d523daeb5e", "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": "b5b3b1657556f720a7310cb7744edb1fac71eaf4", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "Seanpm2001-Agda-lang/agda", "max_forks_repo_path": "test/Succeed/Issue5683.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4", "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": "Seanpm2001-Agda-lang/agda", "max_issues_repo_path": "test/Succeed/Issue5683.agda", "max_line_length": 50, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "6b13364d36eeb60d8ec15eaf8effe23c73401900", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "sseefried/agda", "max_stars_repo_path": "test/Succeed/Issue5683.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 92, "size": 253 }
module Sets.IterativeUSet where open import Data renaming (Empty to EmptyType) open import Functional import Lvl import Lvl.Decidable as Lvl open import Structure.Setoid renaming (_≡_ to _≡ₛ_) open import Syntax.Function open import Type open import Type.Dependent private variable ℓ ℓₒ ℓₑ ℓ₁ ℓ₂ : Lvl.Level private variable T Indexₗ Indexᵣ : Type{ℓ} private variable a b c x y z : T -- A model of constructive set theory with atoms/urelements (CZFU) by iterative sets. -- The definition states that an instance of IUset is either an atom or a set. -- An atom is an instance of the atoms/urelements. -- A set is an instance of a set container which is a function from a type of indices (which depends on the set) to an IUset. The function should be interpreted as pointing to every element of the set, and the image of this function is how a single set is represented. module _ (T : Type{ℓₒ}) ⦃ equiv : Equiv{ℓₑ}(T) ⦄ {ℓ} where data IUset : Type{Lvl.𝐒(ℓ) Lvl.⊔ ℓₒ} SetContainer : Type{Lvl.𝐒(ℓ) Lvl.⊔ ℓₒ} SetContainer = Σ(Type{ℓ}) (_→ᶠ IUset) data IUset where atom : T → IUset set : SetContainer → IUset module _ {T : Type{ℓₒ}} ⦃ equiv : Equiv{ℓₑ}(T) ⦄ {ℓ} where pattern setc {Index} elem = set(intro Index elem) module SetContainer where -- The projection of the index type for a set container. Index : (SC : SetContainer(T){ℓ}) → Type.of(Σ.left SC) Index = Σ.left -- The projection of the elements' function for a set container. elem : (SC : SetContainer(T){ℓ}) → Type.of(Σ.right SC) elem = Σ.right -- The projection of the index type for an IUset's set container if it is a set. -- It is non-existant otherwise (modeled by the empty type with no inhabitants). Index : IUset(T){ℓ} → Type{ℓ} Index (atom x) = EmptyType Index (set SC) = SetContainer.Index SC -- The projection of the elements' function for an IUset's set container it if it a set. -- It is non-existant otherwise (modeled by the empty function which is interpreted as the empty set). elem : (A : IUset(T){ℓ}) → (Index(A) → IUset(T){ℓ}) elem (atom _) () elem (set SC) = SetContainer.elem SC module _ ⦃ equiv : Equiv{ℓₑ}(T) ⦄ where open import Functional open import Logic.Propositional open import Logic.Propositional.Theorems open import Logic.Predicate private variable SC SCₗ SCᵣ : SetContainer(T) ⦃ equiv ⦄ {ℓ} -- The predicate stating that an IUset is a set. data IsSet {ℓ} : IUset(T){ℓ} → Type{Lvl.of(T) Lvl.⊔ Lvl.𝐒(ℓ)} where intro : IsSet(set(SC)) -- The predicate stating that an IUset is an atom. data IsAtom {ℓ} : IUset(T){ℓ} → Type{Lvl.of(T) Lvl.⊔ Lvl.𝐒(ℓ)} where intro : IsAtom(atom(x)) data _≡_ {ℓ₁ ℓ₂} : IUset(T){ℓ₁} → IUset(T){ℓ₂} → Type{Lvl.𝐒(ℓ₁ Lvl.⊔ ℓ₂) Lvl.⊔ ℓₑ Lvl.⊔ Lvl.of(T)} data _⊆_ {ℓ₁ ℓ₂} : IUset(T){ℓ₁} → IUset(T){ℓ₂} → Type{Lvl.𝐒(ℓ₁ Lvl.⊔ ℓ₂) Lvl.⊔ ℓₑ Lvl.⊔ Lvl.of(T)} _⊇_ : IUset(T){ℓ₁} → IUset(T){ℓ₂} → Type A ⊇ B = B ⊆ A -- Equality is either equivalence on its atoms or by definition the antisymmetric property of the subset relation. data _≡_ where atom : (a ≡ₛ b) → (atom a ≡ atom b) set : (set SCₗ ⊇ set SCᵣ) → (set SCₗ ⊆ set SCᵣ) → (set SCₗ ≡ set SCᵣ) -- Set membership is the existence of an index in the set that points to a set equal element to the element. -- Note: This is never satisfied for an atom on the right. data _∈_ {ℓ₁ ℓ₂} (x : IUset(T){ℓ₁}) : IUset(T){ℓ₂} → Type{Lvl.𝐒(ℓ₁ Lvl.⊔ ℓ₂) Lvl.⊔ ℓₑ Lvl.⊔ Lvl.of(T)} where set : ∃{Obj = SetContainer.Index(SC)} (i ↦ x ≡ SetContainer.elem(SC) i) → (x ∈ set SC) [∈]-proof : (x ∈ set SC) → ∃{Obj = SetContainer.Index(SC)} (i ↦ x ≡ SetContainer.elem(SC) i) [∈]-proof (set p) = p [∈]-index : (x ∈ set SC) → SetContainer.Index(SC) [∈]-index (set ([∃]-intro i)) = i [∈]-elem : (p : (x ∈ set SC)) → (x ≡ SetContainer.elem(SC) ([∈]-index p)) [∈]-elem (set ([∃]-intro _ ⦃ p ⦄)) = p -- Set subset is a mapping between the indices such that they point to the same element in both sets. -- Note: This is never satisfied for an atom on the right. data _⊆_ where set : (map : SetContainer.Index(SCₗ) → SetContainer.Index(SCᵣ)) → (∀{i} → (SetContainer.elem(SCₗ) i ≡ SetContainer.elem(SCᵣ) (map i))) → (set SCₗ ⊆ set SCᵣ) [⊆]-map : (set SCₗ ⊆ set SCᵣ) → (SetContainer.Index(SCₗ) → SetContainer.Index(SCᵣ)) [⊆]-map (set map _) = map [⊆]-proof : (p : (set SCₗ ⊆ set SCᵣ)) → (∀{i} → (SetContainer.elem(SCₗ) i ≡ SetContainer.elem(SCᵣ) ([⊆]-map p i))) [⊆]-proof (set _ p) = p -- The binary relation of non-membership. _∉_ : IUset(T){ℓ₁} → IUset(T){ℓ₂} → Type a ∉ B = ¬(a ∈ B) -- The predicate stating that an IUset contains no elements (in other words, is empty). Empty : ∀{ℓ₁ ℓ₂ : Lvl.Level} → IUset(T){ℓ₂} → Type Empty{ℓ₁}(A) = ∀{x : IUset(T){ℓ₁}} → (x ∉ A) open import Logic.Classical private variable A B C : IUset(T) ⦃ equiv ⦄ {ℓ} instance -- An IUset is exclusively either an atom or a set. atom-xor-set : IsAtom(A) ⊕ IsSet(A) atom-xor-set {A = atom _} = [⊕]-introₗ intro \() atom-xor-set {A = set _} = [⊕]-introᵣ intro \() instance IsAtom-classical : Classical₁(IsAtom{ℓ}) IsAtom-classical = classical-from-xorₗ instance IsSet-classical : Classical₁(IsSet{ℓ}) IsSet-classical = classical-from-xorᵣ -- An IUset containing something is always a set. set-if-membership : (x ∈ A) → IsSet(A) set-if-membership (set _) = intro -- An IUset which is an atom is always "empty" when interpreted as a set. atom-is-empty : IsAtom(A) → Empty{ℓ}(A) atom-is-empty p = contrapositiveᵣ set-if-membership ([⊕]-not-left atom-xor-set p) open import Functional open import Structure.Relator.Equivalence open import Structure.Relator.Properties [≡]-reflexivity-raw : (A ≡ A) [⊆]-reflexivity-raw : (set SC ⊆ set SC) [⊇]-reflexivity-raw : (set SC ⊇ set SC) [⊇]-reflexivity-raw = [⊆]-reflexivity-raw {-# TERMINATING #-} -- TODO: Passed the termination checker before Agda 2.6.2-caeadac-dirty [≡]-reflexivity-raw {A = atom x} = atom(reflexivity(_≡ₛ_)) [≡]-reflexivity-raw {A = set x} = set [⊇]-reflexivity-raw [⊆]-reflexivity-raw [⊆]-reflexivity-raw {SC = SC} = set id \{i} → [≡]-reflexivity-raw {A = SetContainer.elem(SC)(i)} [≡]-transitivity-raw : (A ≡ B) → (B ≡ C) → (A ≡ C) [⊆]-transitivity-raw : (A ⊆ B) → (B ⊆ C) → (A ⊆ C) [⊇]-transitivity-raw : (A ⊇ B) → (B ⊇ C) → (A ⊇ C) [⊇]-transitivity-raw {A = A}{B = B}{C = C} ab bc = [⊆]-transitivity-raw {A = C}{B = B}{C = A} bc ab [≡]-transitivity-raw (atom ab) (atom bc) = atom (transitivity(_≡ₛ_) ab bc) [≡]-transitivity-raw (set lab rab) (set lbc rbc) = set ([⊇]-transitivity-raw lab lbc) ([⊆]-transitivity-raw rab rbc) [⊆]-transitivity-raw (set {SCₗ = SC₁} {SCᵣ = SC₂} mapₗ pₗ) (set {SCᵣ = SC₃} mapᵣ pᵣ) = set (mapᵣ ∘ mapₗ) \{i} → [≡]-transitivity-raw {A = SetContainer.elem(SC₁) i}{B = SetContainer.elem(SC₂)(mapₗ i)} {C = SetContainer.elem(SC₃)(mapᵣ(mapₗ i))} pₗ pᵣ instance [≡]-reflexivity : Reflexivity(_≡_ {ℓ}) [≡]-reflexivity = intro [≡]-reflexivity-raw instance [⊆]-reflexivity : Reflexivity{T = SetContainer(T){ℓ}} ((_⊆_) on₂ set) [⊆]-reflexivity = intro [⊆]-reflexivity-raw instance [⊇]-reflexivity : Reflexivity{T = SetContainer(T){ℓ}} ((_⊇_) on₂ set) [⊇]-reflexivity = intro [⊇]-reflexivity-raw instance [≡]-symmetry : Symmetry(_≡_ {ℓ}) Symmetry.proof [≡]-symmetry (atom ab) = atom (symmetry(_≡ₛ_) ab) Symmetry.proof [≡]-symmetry (set l r) = set r l instance [⊆]-antisymmetry : Antisymmetry(_⊆_ {ℓ})(_≡_) Antisymmetry.proof [⊆]-antisymmetry l@(set _ _) r@(set _ _) = set r l instance [⊇]-antisymmetry : Antisymmetry(_⊇_ {ℓ})(_≡_) Antisymmetry.proof [⊇]-antisymmetry l@(set _ _) r@(set _ _) = set l r instance [≡]-transitivity : Transitivity(_≡_ {ℓ}) [≡]-transitivity = intro [≡]-transitivity-raw instance [⊆]-transitivity : Transitivity(_⊆_ {ℓ}) [⊆]-transitivity = intro [⊆]-transitivity-raw instance [⊇]-transitivity : Transitivity(_⊇_ {ℓ}) [⊇]-transitivity = intro [⊇]-transitivity-raw instance [≡]-equivalence : Equivalence(_≡_ {ℓ}) [≡]-equivalence = intro instance Iset-equiv : Equiv(IUset(T){ℓ}) Equiv._≡_ Iset-equiv = _≡_ Equiv.equivalence Iset-equiv = [≡]-equivalence [≡]-to-[⊆] : (set SCₗ ≡ set SCᵣ) → (set SCₗ ⊆ set SCᵣ) [≡]-to-[⊆] (set l r) = r [≡]-to-[⊇] : (set SCₗ ≡ set SCᵣ) → (set SCₗ ⊇ set SCᵣ) [≡]-to-[⊇] (set l r) = l [∈]-of-elem : ∀{A : IUset(T){ℓ}}{ia : Index(A)} → (elem(A)(ia) ∈ A) [∈]-of-elem {A = setc {Index} elem} {ia} = set ([∃]-intro ia ⦃ [≡]-reflexivity-raw ⦄) [⊆]-membership : ((_⊆_ on₂ set) SCₗ SCᵣ) ← (∀{x : IUset(T)} → (x ∈ set SCₗ) → (x ∈ set SCᵣ)) [⊆]-membership {SCₗ = SCₗ} {SCᵣ = SCᵣ} proof = set (ia ↦ [∃]-witness ([∈]-proof(proof {elem(set SCₗ)(ia)} ([∈]-of-elem {A = set SCₗ})))) (\{ia} → [∃]-proof ([∈]-proof(proof {elem(set SCₗ)(ia)} ([∈]-of-elem {A = set SCₗ})))) module Oper ⦃ equiv : Equiv{ℓₑ}(T) ⦄ where open import Data renaming (Empty to EmptyType) open import Data.Boolean open import Data.Boolean.Stmt open import Data.Either as Either using (_‖_) open import Functional open import Logic open import Logic.Classical open import Type.Dependent open import Type.Dependent.Functions open import Type.Properties.Decidable open import Type.Properties.Decidable.Proofs open import Syntax.Function instance _ = classical-to-decidable -- TODO: Many of these operations are simply copy-pasted from Sets.IterativeSet with small modifications. -- The operation converting an IUset from a lower universe level to a higher universe level. IUset-level-up : let _ = ℓ₁ in IUset(T){ℓ₂} → IUset(T){ℓ₁ Lvl.⊔ ℓ₂} IUset-level-up (atom x) = atom x IUset-level-up {ℓ₁}{ℓ₂} (setc {Index} elem) = setc {Lvl.Up{ℓ₁}{ℓ₂}(Index)} \{(Lvl.up i) → IUset-level-up{ℓ₁}{ℓ₂}(elem(i))} -- The empty set, consisting of no elements. -- Index is the empty type, which means that there are no objects pointing to elements in the set. ∅ : IUset(T){ℓ} ∅ = setc empty -- Lifts an unary operation on set containers to an unary operation on IUsets. set-operator₁ : (SetContainer(T){ℓ₁} → SetContainer(T){ℓ₂}) → (IUset(T){ℓ₁} → IUset(T){ℓ₂}) set-operator₁ op (atom _) = ∅ set-operator₁ op (set A) = set (op A) -- Lifts a binary operation on set containers to a binary operation on IUsets. set-operator₂ : (SetContainer(T){ℓ} → SetContainer(T){ℓ} → SetContainer(T){ℓ}) → (IUset(T){ℓ} → IUset(T){ℓ} → IUset(T){ℓ}) set-operator₂ op (atom _) (atom _) = ∅ set-operator₂ op (atom _) (set B) = set B set-operator₂ op (set A) (atom _) = set A set-operator₂ op (set A) (set B) = set (op A B) -- Filters a set to only contain set elements. sets-of : IUset(T){ℓ} → IUset(T){ℓ} sets-of{ℓ} = set-operator₁(A ↦ intro (Σ(SetContainer.Index(A)) (ia ↦ Lvl.Convert(IsSet(SetContainer.elem(A)(ia))){ℓ})) \{(intro ia p) → SetContainer.elem(A)(ia)}) -- Filters a set to only contain atomic elements. atoms-of : IUset(T){ℓ} → IUset(T){ℓ} atoms-of{ℓ} = set-operator₁(A ↦ intro (Σ(SetContainer.Index(A)) (ia ↦ Lvl.Convert(IsAtom(SetContainer.elem(A)(ia))){ℓ})) \{(intro ia p) → SetContainer.elem(A)(ia)}) -- The singleton set, consisting of one element. -- Index is the unit type, which means that there are a single object pointing to a single element in the set. singleton : IUset(T){ℓ} → IUset(T){ℓ} singleton = setc{Index = Unit} ∘ const -- The pair set, consisting of two elements. -- Index is the boolean type, which means that there are two objects pointing to two elements in the set. pair : IUset(T){ℓ} → IUset(T){ℓ} → IUset(T){ℓ} pair A B = setc{Index = Lvl.Up(Bool)} ((if_then B else A) ∘ Lvl.Up.obj) -- The union operator. -- Index(A ∪ B) is the either type of two indices, which means that both objects from the A and the B index point to elements in the set. _∪_ : IUset(T){ℓ} → IUset(T){ℓ} → IUset(T){ℓ} A ∪ B = setc{Index = Index(A) ‖ Index(B)} (Either.map1 (elem(A)) (elem(B))) -- _∪_ = set-operator₂([ℰ]-map₂ Either.map1) -- The big union operator. -- Index(⋃ A) is the dependent sum type of an Index(A) and the index of the element this index points to. ⋃ : IUset(T){ℓ} → IUset(T){ℓ} ⋃ A = setc{Index = Σ(Index(A)) (ia ↦ Index(elem(A)(ia)))} (\{(intro ia i) → elem(elem(A)(ia))(i)}) indexFilter : (A : IUset(T){ℓ}) → (Index(A) → Stmt{ℓ}) → IUset(T){ℓ} indexFilter A P = setc{Index = Σ(Index(A)) P} (elem(A) ∘ Σ.left) filter : (A : IUset(T){ℓ}) → (IUset(T){ℓ} → Stmt{ℓ}) → IUset(T){ℓ} filter{ℓ} A P = indexFilter A (P ∘ elem(A)) indexFilterBool : (A : IUset(T){ℓ}) → (Index(A) → Bool) → IUset(T){ℓ} indexFilterBool A f = indexFilter A (Lvl.Up ∘ IsTrue ∘ f) filterBool : (A : IUset(T){ℓ}) → (IUset(T){ℓ} → Bool) → IUset(T){ℓ} filterBool A f = indexFilterBool A (f ∘ elem(A)) map : (IUset(T){ℓ} → IUset(T){ℓ}) → (IUset(T){ℓ} → IUset(T){ℓ}) map f(A) = setc{Index = Index(A)} (f ∘ elem(A)) -- The power set operator. -- Index(℘(A)) is a function type. An instance of such a function represents a subset, and essentially maps every element in A to a boolean which is interpreted as "in the subset of not". -- Note: This only works properly in a classical setting. Trying to use indexFilter instead result in universe level problems. ℘ : IUset(T){ℓ} → IUset(T){ℓ} ℘(A) = setc{Index = Index(A) → Bool} (indexFilterBool A) -- The set of ordinal numbers of the first order. ω : IUset(T){ℓ} ω = setc{Index = Lvl.Up ℕ} (N ∘ Lvl.Up.obj) where open import Numeral.Natural N : ℕ → IUset(T){ℓ} N(𝟎) = ∅ N(𝐒(n)) = N(n) ∪ singleton(N(n)) module Proofs where open import Data.Boolean open import Data.Tuple as Tuple using () open import Logic.Propositional open import Logic.Predicate open import Structure.Function open import Structure.Relator.Properties instance atom-function : Function(atom{T = T}{ℓ}) Function.congruence atom-function = atom {-instance set-function : Function(set{T = T}{ℓ}) Function.congruence set-function = ? -} -- If there is an element in the empty set, then there exists an instance of the empty type by definition, and that is false by definition. ∅-membership : ∀{x : IUset(T){ℓ₁}} → (x ∉ ∅ {ℓ₂}) ∅-membership (set()) -- There is a bijection between (A ‖ B) and ∃{Lvl.Up Bool}(\{(Lvl.up 𝐹) → A ; (Lvl.up 𝑇) → B}). pair-membership : ∀{a b x : IUset(T){ℓ}} → (x ∈ pair a b) ↔ (x ≡ a)∨(x ≡ b) Tuple.left (pair-membership {x = x}) ([∨]-introₗ p) = set ([∃]-intro (Lvl.up 𝐹) ⦃ p ⦄) Tuple.left (pair-membership {x = x}) ([∨]-introᵣ p) = set ([∃]-intro (Lvl.up 𝑇) ⦃ p ⦄) Tuple.right pair-membership (set ([∃]-intro (Lvl.up 𝐹) ⦃ atom p ⦄)) = [∨]-introₗ (atom p) Tuple.right pair-membership (set ([∃]-intro (Lvl.up 𝑇) ⦃ atom p ⦄)) = [∨]-introᵣ (atom p) Tuple.right pair-membership (set ([∃]-intro (Lvl.up 𝐹) ⦃ set l r ⦄)) = [∨]-introₗ (set l r) Tuple.right pair-membership (set ([∃]-intro (Lvl.up 𝑇) ⦃ set l r ⦄)) = [∨]-introᵣ (set l r) -- There is a bijection between (A) and ∃{Unit}(\{<> → A}). singleton-membership : ∀{a x : IUset(T){ℓ}} → (x ∈ singleton(a)) ↔ (x ≡ a) Tuple.left singleton-membership xin = set ([∃]-intro <> ⦃ xin ⦄) Tuple.right singleton-membership (set ([∃]-intro _ ⦃ eq ⦄)) = eq [∪]-membership : ∀{A B x : IUset(T){ℓ}} → (x ∈ (A ∪ B)) ↔ (x ∈ A)∨(x ∈ B) Tuple.left [∪]-membership ([∨]-introₗ (set ([∃]-intro ia))) = set ([∃]-intro (Either.Left ia)) Tuple.left [∪]-membership ([∨]-introᵣ (set ([∃]-intro ib))) = set ([∃]-intro (Either.Right ib)) Tuple.right ([∪]-membership {A = set x}) (set ([∃]-intro ([∨]-introₗ ia))) = [∨]-introₗ (set ([∃]-intro ia)) {-# CATCHALL #-} Tuple.right ([∪]-membership {B = set x}) (set ([∃]-intro ([∨]-introᵣ ib))) = [∨]-introᵣ (set ([∃]-intro ib)) [⊆]-with-elem : ∀{SCₗ SCᵣ : SetContainer(T){ℓ}} → (xy : set SCₗ ⊆ set SCᵣ) → ∀{ix} → (elem (set SCₗ) ix ≡ elem (set SCᵣ) ([⊆]-map xy ix)) [⊆]-with-elem (set map proof) {ix} = proof{ix} {- open import Lang.Inspect import Relator.Equals as Equals import Relator.Equals.Proofs.Equivalence as Equals [⋃]-membership : ∀{A x : IUset(T){ℓ}} → (x ∈ (⋃ A)) ↔ ∃(a ↦ (a ∈ A) ∧ (x ∈ a)) Tuple.left ([⋃]-membership {A = A@(set _)}) ([∃]-intro a@(set _) ⦃ [∧]-intro aA xa ⦄) with elem A ([∈]-index aA) | [∈]-elem aA | inspect ⦃ Equals.[≡]-equiv ⦄ (elem A) ([∈]-index aA) ... | set _ | (set aA-mapₗ aA-mapᵣ) | intro pp = set ([∃]-intro (intro ([∈]-index aA) (Equals.[≡]-substitutionₗ pp {f = Index} ([⊆]-map aA-mapᵣ ([∈]-index xa)))) ⦃ [≡]-transitivity-raw ([∈]-elem xa) ([⊆]-with-elem ([≡]-to-[⊆] ([≡]-transitivity-raw ([∈]-elem aA) ([≡]-transitivity-raw (sub₂(Equals._≡_)(_≡_) pp) {!!}))) {[∈]-index xa}) ⦄) Tuple.right ([⋃]-membership {A = A@(atom _)}) (set ([∃]-intro (intro iA ia))) = {!!} ∃.witness (Tuple.right ([⋃]-membership {A = A@(set _)}) (set ([∃]-intro (intro iA ia)))) = elem(A) iA ∃.proof (Tuple.right ([⋃]-membership {A = A@(set _)}) (set ([∃]-intro (intro iA ia) ⦃ proof ⦄))) = [∧]-intro ([∈]-of-elem {A = A}) {!set([∃]-intro ia ⦃ proof ⦄)!} -} {- Σ.left (∃.witness (Tuple.left ([⋃]-membership {A = A} {x}) ([∃]-intro a ⦃ [∧]-intro ([∃]-intro iA) _ ⦄))) = iA Σ.right (∃.witness (Tuple.left ([⋃]-membership {A = A} {x}) ([∃]-intro a ⦃ [∧]-intro ([∃]-intro iA ⦃ aA ⦄) ([∃]-intro ia) ⦄))) = _⊆_.map (_≡_.right aA) ia ∃.proof (Tuple.left ([⋃]-membership {A = A} {x}) ([∃]-intro a ⦃ [∧]-intro ([∃]-intro iA ⦃ aA ⦄) ([∃]-intro ia ⦃ xa ⦄) ⦄)) = [≡]-transitivity-raw xa ([⊆]-with-elem (sub₂(_≡_)(_⊆_) aA) {ia}) ∃.witness (Tuple.right ([⋃]-membership {A = A} {x}) ([∃]-intro (intro iA ia) ⦃ proof ⦄)) = elem(A)(iA) Tuple.left (∃.proof (Tuple.right ([⋃]-membership {A = A} {x}) ([∃]-intro (intro iA ia) ⦃ proof ⦄))) = [∈]-of-elem {A = A} ∃.witness (Tuple.right (∃.proof (Tuple.right ([⋃]-membership {A = A} {x}) ([∃]-intro (intro iA ia) ⦃ proof ⦄)))) = ia ∃.proof (Tuple.right (∃.proof (Tuple.right ([⋃]-membership {A = A} {x}) ([∃]-intro (intro iA ia) ⦃ proof ⦄)))) = proof -}
{ "alphanum_fraction": 0.610455498, "avg_line_length": 48.486631016, "ext": "agda", "hexsha": "708d8a09ad3a8bc624caa674ec44e3df29724f49", "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": "Sets/IterativeUSet.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": "Sets/IterativeUSet.agda", "max_line_length": 341, "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": "Sets/IterativeUSet.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": 7139, "size": 18134 }
module treeThms where open import lib -- simple Tree type storing natural numbers data Tree : Set where Node : ℕ → Tree → Tree → Tree Leaf : Tree mirror : Tree → Tree mirror (Node x t1 t2) = Node x (mirror t2) (mirror t1) mirror Leaf = Leaf mirror-mirror : ∀ (t : Tree) → mirror (mirror t) ≡ t mirror-mirror Leaf = refl mirror-mirror (Node x t1 t2) rewrite mirror-mirror t2 | mirror-mirror t1 = refl size : Tree → ℕ size (Node x t t₁) = 1 + size t + size t₁ size Leaf = 1 height : Tree → ℕ height (Node x t t₁) = 1 + (max (height t) (height t₁)) height Leaf = 0 numLeaves : Tree → ℕ numLeaves (Node x t t₁) = numLeaves t + numLeaves t₁ numLeaves Leaf = 1 perfect : ℕ → Tree perfect zero = Leaf perfect (suc n) = Node 1 (perfect n) (perfect n) -- I found I needed the +0 theorem from nat-thms.agda in the IAL perfect-numLeaves : ∀(n : ℕ) → numLeaves (perfect n) ≡ 2 pow n perfect-numLeaves zero = refl perfect-numLeaves (suc n) rewrite +0 (2 pow n) | perfect-numLeaves n = refl perfect-size : ∀(n : ℕ) → suc (size (perfect n)) ≡ 2 pow (suc n) perfect-size zero = refl perfect-size (suc n) rewrite sym (perfect-size n) | +0 (size(perfect n)) | sym (+suc(size(perfect n))(size(perfect n)))= refl -- helper lemma I found I needed below max-same : ∀ (n : ℕ) → max n n ≡ n max-same n rewrite <-irrefl n = refl perfect-height : ∀(n : ℕ) → height (perfect n) ≡ n perfect-height zero = refl perfect-height (suc n) rewrite max-same (height(perfect n)) | perfect-height n = refl numNodes : Tree → ℕ numNodes (Node x t1 t2) = 1 + numNodes t1 + numNodes t2 numNodes Leaf = 0 -- flatten a tree into a list of all the values stored at the nodes prefixFlatten : Tree → 𝕃 ℕ prefixFlatten (Node x t1 t2) = x :: prefixFlatten t1 ++ prefixFlatten t2 prefixFlatten Leaf = [] -- I found I needed a theorem from list-thms.agda in the IAL length-flatten : ∀(t : Tree) → numNodes t ≡ length (prefixFlatten t) length-flatten (Node x t1 t2) rewrite length-++(prefixFlatten t1) (prefixFlatten t2) | length-flatten t1 | length-flatten t2 = refl length-flatten Leaf = refl
{ "alphanum_fraction": 0.6611919287, "avg_line_length": 32.7846153846, "ext": "agda", "hexsha": "fa78d604d84f53c4712c4dcc8b9c3ad057fc784b", "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": "0117aa66ff3cbc8d75be3c9705bada96bdcf8d5a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout7", "max_forks_repo_path": "treeThms.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0117aa66ff3cbc8d75be3c9705bada96bdcf8d5a", "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": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout7", "max_issues_repo_path": "treeThms.agda", "max_line_length": 132, "max_stars_count": null, "max_stars_repo_head_hexsha": "0117aa66ff3cbc8d75be3c9705bada96bdcf8d5a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout7", "max_stars_repo_path": "treeThms.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 694, "size": 2131 }
open import Agda.Builtin.Unit open import Agda.Builtin.Bool open import Agda.Builtin.Sigma open import Agda.Builtin.List open import Agda.Builtin.Equality open import Agda.Builtin.Reflection renaming (returnTC to return; bindTC to _>>=_) _>>_ : ∀ {a} {b} {A : Set a} {B : Set b} → TC A → TC B → TC B x >> y = x >>= λ _ → y macro false-oh-no-actually-true : Term → TC ⊤ false-oh-no-actually-true goal = do runSpeculative (do unify goal (con (quote false) []) return (tt , false)) unify goal (con (quote true) []) false-yes-really-false : Term → TC ⊤ false-yes-really-false goal = runSpeculative (do unify goal (con (quote false) []) return (tt , true)) test₁ : Bool test₁ = false-oh-no-actually-true _ : test₁ ≡ true _ = refl test₂ : Bool test₂ = false-yes-really-false _ : test₂ ≡ false _ = refl
{ "alphanum_fraction": 0.6471277843, "avg_line_length": 22.4473684211, "ext": "agda", "hexsha": "e54075e8f1baa44ff1ca349dd801501a6325fb0d", "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/ReflectionRunSpeculative.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/ReflectionRunSpeculative.agda", "max_line_length": 82, "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/ReflectionRunSpeculative.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": 280, "size": 853 }
{-# OPTIONS --without-K --rewriting --termination-depth=2 #-} open import HoTT open import cohomology.ChainComplex open import cohomology.Theory open import groups.KernelImage open import cw.CW module cw.cohomology.ReconstructedHigherCohomologyGroups {i : ULevel} (OT : OrdinaryTheory i) where open OrdinaryTheory OT import cw.cohomology.HigherCoboundary OT as HC open import cw.cohomology.WedgeOfCells OT open import cw.cohomology.Descending OT open import cw.cohomology.ReconstructedCochainComplex OT import cw.cohomology.HigherCohomologyGroups OT as HCG import cw.cohomology.HigherCohomologyGroupsOnDiag OT as HCGD import cw.cohomology.CohomologyGroupsTooHigh OT as CGTH private ≤-dec-has-all-paths : {m n : ℕ} → has-all-paths (Dec (m ≤ n)) ≤-dec-has-all-paths = prop-has-all-paths (Dec-level ≤-is-prop) private abstract higher-cohomology-group-descend : ∀ {n} (⊙skel : ⊙Skeleton {i} (2 + n)) {m} (Sm<n : S m < n) → cohomology-group (cochain-complex ⊙skel) (ℕ-to-ℤ (2 + m)) == cohomology-group (cochain-complex (⊙cw-init ⊙skel)) (ℕ-to-ℤ (2 + m)) higher-cohomology-group-descend ⊙skel {m} ltS -- n = 2 + m = ap3 (λ Sm≤4+m? SSm≤4+m? SSSm≤4+m? → Ker/Im (coboundary-template ⊙skel SSm≤4+m? SSSm≤4+m?) (coboundary-template ⊙skel Sm≤4+m? SSm≤4+m?) (cochain-is-abelian-template ⊙skel SSm≤4+m?)) (≤-dec-has-all-paths (≤-dec (1 + m) (4 + m)) (inl (lteSR $ lteSR lteS))) (≤-dec-has-all-paths (≤-dec (2 + m) (4 + m)) (inl (lteSR lteS))) (≤-dec-has-all-paths (≤-dec (3 + m) (4 + m)) (inl lteS)) ∙ ap2 (λ δ₁ δ₂ → Ker/Im δ₂ δ₁ (CXₙ/Xₙ₋₁-is-abelian (⊙cw-take (lteSR lteS) ⊙skel) (ℕ-to-ℤ (2 + m)))) (coboundary-higher-template-descend-from-far {n = 3 + m} ⊙skel {m = m} (ltSR ltS) ltS) (coboundary-higher-template-descend-from-one-above ⊙skel) ∙ ap3 (λ Sm≤3+m? SSm≤3+m? SSSm≤3+m? → Ker/Im (coboundary-template (⊙cw-init ⊙skel) SSm≤3+m? SSSm≤3+m?) (coboundary-template (⊙cw-init ⊙skel) Sm≤3+m? SSm≤3+m?) (cochain-is-abelian-template (⊙cw-init ⊙skel) SSm≤3+m?)) (≤-dec-has-all-paths (inl (lteSR lteS)) (≤-dec (1 + m) (3 + m))) (≤-dec-has-all-paths (inl lteS) (≤-dec (2 + m) (3 + m))) (≤-dec-has-all-paths (inl lteE) (≤-dec (3 + m) (3 + m))) higher-cohomology-group-descend {n = S n} ⊙skel {m} (ltSR Sm<n) -- n = S n = ap3 (λ Sm≤3+n? SSm≤3+n? SSSm≤3+n? → Ker/Im (coboundary-template ⊙skel SSm≤3+n? SSSm≤3+n?) (coboundary-template ⊙skel Sm≤3+n? SSm≤3+n?) (cochain-is-abelian-template ⊙skel SSm≤3+n?)) (≤-dec-has-all-paths (≤-dec (1 + m) (3 + n)) (inl (lteSR $ lteSR $ lteSR (inr Sm<n)))) (≤-dec-has-all-paths (≤-dec (2 + m) (3 + n)) (inl (≤-+-l 1 (lteSR $ lteSR $ inr Sm<n)))) (≤-dec-has-all-paths (≤-dec (3 + m) (3 + n)) (inl (≤-+-l 2 (lteSR (inr Sm<n))))) ∙ ap2 (λ δ₁ δ₂ → Ker/Im δ₂ δ₁ (CXₙ/Xₙ₋₁-is-abelian (⊙cw-take (≤-+-l 1 (lteSR $ lteSR $ inr Sm<n)) ⊙skel) (ℕ-to-ℤ (2 + m)))) (coboundary-higher-template-descend-from-far {n = 2 + n} ⊙skel {m = m} (ltSR (ltSR Sm<n)) (<-+-l 1 (ltSR Sm<n))) (coboundary-higher-template-descend-from-far {n = 2 + n} ⊙skel {m = S m} (<-+-l 1 (ltSR Sm<n)) (<-+-l 2 Sm<n)) ∙ ap3 (λ Sm≤2+n? SSm≤2+n? SSSm≤2+n? → Ker/Im (coboundary-template (⊙cw-init ⊙skel) SSm≤2+n? SSSm≤2+n?) (coboundary-template (⊙cw-init ⊙skel) Sm≤2+n? SSm≤2+n?) (cochain-is-abelian-template (⊙cw-init ⊙skel) SSm≤2+n?)) (≤-dec-has-all-paths (inl (lteSR $ lteSR $ inr Sm<n)) (≤-dec (1 + m) (2 + n))) (≤-dec-has-all-paths (inl (≤-+-l 1 (lteSR $ inr Sm<n))) (≤-dec (2 + m) (2 + n))) (≤-dec-has-all-paths (inl (≤-+-l 2 (inr Sm<n))) (≤-dec (3 + m) (2 + n))) higher-cohomology-group-β : ∀ {n} (⊙skel : ⊙Skeleton {i} (3 + n)) → cohomology-group (cochain-complex ⊙skel) (ℕ-to-ℤ (2 + n)) == Ker/Im (HC.cw-co∂-last ⊙skel) (HC.cw-co∂-last (⊙cw-init ⊙skel)) (CXₙ/Xₙ₋₁-is-abelian (⊙cw-init ⊙skel) (ℕ-to-ℤ (2 + n))) higher-cohomology-group-β {n} ⊙skel = ap3 (λ 1+n≤3+n? 2+n≤3+n? 3+n≤3+n? → Ker/Im (coboundary-template ⊙skel 2+n≤3+n? 3+n≤3+n?) (coboundary-template ⊙skel 1+n≤3+n? 2+n≤3+n?) (cochain-is-abelian-template ⊙skel 2+n≤3+n?)) (≤-dec-has-all-paths (≤-dec (1 + n) (3 + n)) (inl (lteSR lteS))) (≤-dec-has-all-paths (≤-dec (2 + n) (3 + n)) (inl lteS)) (≤-dec-has-all-paths (≤-dec (3 + n) (3 + n)) (inl lteE)) ∙ ap2 (λ δ₁ δ₂ → Ker/Im δ₂ δ₁ (CXₙ/Xₙ₋₁-is-abelian (⊙cw-init ⊙skel) (ℕ-to-ℤ (2 + n)))) ( coboundary-higher-template-descend-from-one-above ⊙skel ∙ coboundary-higher-template-β (⊙cw-init ⊙skel)) (coboundary-higher-template-β ⊙skel) higher-cohomology-group-β-one-below : ∀ {n} (⊙skel : ⊙Skeleton {i} (2 + n)) → cohomology-group (cochain-complex ⊙skel) (ℕ-to-ℤ (2 + n)) == Ker/Im (cst-hom {H = Lift-group {j = i} Unit-group}) (HC.cw-co∂-last ⊙skel) (CXₙ/Xₙ₋₁-is-abelian ⊙skel (ℕ-to-ℤ (2 + n))) higher-cohomology-group-β-one-below {n} ⊙skel = ap3 (λ 1+n≤2+n? 2+n≤2+n? 3+n≤2+n? → Ker/Im (coboundary-template ⊙skel 2+n≤2+n? 3+n≤2+n?) (coboundary-template ⊙skel 1+n≤2+n? 2+n≤2+n?) (cochain-is-abelian-template ⊙skel 2+n≤2+n?)) (≤-dec-has-all-paths (≤-dec (1 + n) (2 + n)) (inl lteS)) (≤-dec-has-all-paths (≤-dec (2 + n) (2 + n)) (inl lteE)) (≤-dec-has-all-paths (≤-dec (3 + n) (2 + n)) (inr (<-to-≱ ltS))) ∙ ap (λ δ₁ → Ker/Im (cst-hom {H = Lift-group {j = i} Unit-group}) δ₁ (CXₙ/Xₙ₋₁-is-abelian ⊙skel (ℕ-to-ℤ (2 + n)))) (coboundary-higher-template-β ⊙skel) higher-cohomology-group-β-far-below : ∀ {n} (⊙skel : ⊙Skeleton {i} n) {m} (SSm≰n : ¬ (2 + m ≤ n)) → cohomology-group (cochain-complex ⊙skel) (ℕ-to-ℤ (2 + m)) == Ker/Im (cst-hom {H = Lift-group {j = i} Unit-group}) (cst-hom {G = AbGroup.grp (cochain-template ⊙skel (≤-dec (1 + m) n))} {H = Lift-group {j = i} Unit-group}) (snd (Lift-abgroup {j = i} Unit-abgroup)) higher-cohomology-group-β-far-below {n} ⊙skel {m} SSm≰n = ap2 (λ 2+m≤n? 3+m≤n? → Ker/Im (coboundary-template ⊙skel 2+m≤n? 3+m≤n?) (coboundary-template ⊙skel (≤-dec (1 + m) n) 2+m≤n?) (cochain-is-abelian-template ⊙skel 2+m≤n?)) (≤-dec-has-all-paths (≤-dec (2 + m) n) (inr SSm≰n)) (≤-dec-has-all-paths (≤-dec (3 + m) n) (inr (λ SSSm≤n → SSm≰n (≤-trans lteS SSSm≤n)))) abstract higher-cohomology-group : ∀ m {n} (⊙skel : ⊙Skeleton {i} n) → ⊙has-cells-with-choice 0 ⊙skel i → C (ℕ-to-ℤ (2 + m)) ⊙⟦ ⊙skel ⟧ ≃ᴳ cohomology-group (cochain-complex ⊙skel) (ℕ-to-ℤ (2 + m)) higher-cohomology-group m {n = 0} ⊙skel ac = CGTH.C-cw-iso-ker/im (2 + m) (O<S (S m)) (Lift-group {j = i} Unit-group) ⊙skel ac higher-cohomology-group m {n = 1} ⊙skel ac = CGTH.C-cw-iso-ker/im (2 + m) (<-+-l 1 (O<S m)) (AbGroup.grp (cochain-template ⊙skel (≤-dec (1 + m) 1))) ⊙skel ac higher-cohomology-group m {n = S (S n)} ⊙skel ac with ℕ-trichotomy (S m) (S n) ... | inl idp = coe!ᴳ-iso (higher-cohomology-group-β-one-below ⊙skel) ∘eᴳ HCGD.C-cw-iso-ker/im ⊙skel ac ... | inr (inl ltS) = coe!ᴳ-iso (higher-cohomology-group-β ⊙skel) ∘eᴳ HCG.C-cw-iso-ker/im ⊙skel ac ... | inr (inl (ltSR Sm<n)) = coe!ᴳ-iso (higher-cohomology-group-descend ⊙skel Sm<n) ∘eᴳ higher-cohomology-group m {n = S n} (⊙cw-init ⊙skel) (⊙init-has-cells-with-choice ⊙skel ac) ∘eᴳ C-cw-descend-at-lower ⊙skel (<-+-l 1 Sm<n) ac ... | inr (inr Sn<Sm) = coe!ᴳ-iso (higher-cohomology-group-β-far-below ⊙skel (<-to-≱ (<-+-l 1 Sn<Sm))) ∘eᴳ CGTH.C-cw-iso-ker/im (2 + m) (<-+-l 1 Sn<Sm) (AbGroup.grp (cochain-template ⊙skel (≤-dec (1 + m) (2 + n)))) ⊙skel ac
{ "alphanum_fraction": 0.5157684161, "avg_line_length": 55.1818181818, "ext": "agda", "hexsha": "387989d736af36096e008e36819a3d5db020ddef", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "theorems/cw/cohomology/ReconstructedHigherCohomologyGroups.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "theorems/cw/cohomology/ReconstructedHigherCohomologyGroups.agda", "max_line_length": 129, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "theorems/cw/cohomology/ReconstructedHigherCohomologyGroups.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3574, "size": 8498 }
module Verifier (down : Set₁ -> Set) (up : Set → Set₁) (iso : ∀ {A} → down (up A) -> A) (osi : ∀ {A} → up (down A) -> A) where import UniverseCollapse as UC open UC down up iso osi using (anything) check : (A : Set) -> A check = anything
{ "alphanum_fraction": 0.55859375, "avg_line_length": 21.3333333333, "ext": "agda", "hexsha": "9a85e2af15d6e02d3cec06192c38a9003f7ba52f", "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": "ece25bed081a24f02e9f85056d05933eae2afabf", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "danr/agder", "max_forks_repo_path": "problems/UniverseCollapse/Verifier.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ece25bed081a24f02e9f85056d05933eae2afabf", "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": "danr/agder", "max_issues_repo_path": "problems/UniverseCollapse/Verifier.agda", "max_line_length": 42, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ece25bed081a24f02e9f85056d05933eae2afabf", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "danr/agder", "max_stars_repo_path": "problems/UniverseCollapse/Verifier.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-17T12:07:03.000Z", "max_stars_repo_stars_event_min_datetime": "2021-05-17T12:07:03.000Z", "num_tokens": 89, "size": 256 }
module Data.Bin.DivMod where import Data.Fin import Data.Product import Data.Bin import Data.Nat import Relation.Binary.PropositionalEquality import Data.Digit hiding (0b; 1b) import Data.List import Algebra import Algebra.Structures import Data.Bin.NatHelpers open Data.Bin using (Bin; toℕ; toBits; fromBits; _1#; 0#; 2+_; 0b; 1b) module PropEq = Relation.Binary.PropositionalEquality open Data.List using (_∷_; []; List) open Data.Nat using (ℕ; zero; suc) import Data.Nat.Properties open import Data.Bin.Utils open import Data.Bin.Bijection using (fromℕ-bijection; fromℕ; toℕ-inj; toFromℕ-inverse) import Data.Bin.Addition module Properties where open import Data.Bin.Multiplication open Data.Bin using () renaming (_+_ to _B+_; _*_ to _B*_) open Algebra.Structures using (IsCommutativeMonoid; module IsCommutativeSemiring) open PropEq open Data.Nat using (_+_; _*_) open Data.Nat.Properties using (isCommutativeSemiring) open IsCommutativeSemiring isCommutativeSemiring module Everything where open Data.Bin using (_1#; 0#; Bin; _+_; _*2; _*2+1; toℕ; ⌊_/2⌋; _*_; less) open import Data.Bin.Properties using (<-strictTotalOrder) open import Function open Data.Product open import Relation.Binary open Relation.Binary.PropositionalEquality renaming (setoid to ≡-setoid) open import Relation.Nullary open import Relation.Nullary.Decidable open Data.Fin using (zero; suc) open Data.List using (_∷_; []) open StrictTotalOrder <-strictTotalOrder hiding (trans) open import Data.Bin.Minus using (_-_) BinFin : Bin → Set BinFin n = ∃ λ x → x < n toBin : ∀ {x} → BinFin x → Bin toBin = proj₁ {- data DivMod : Bin → Bin → Set where result : ∀ {divisor : Bin} (q : Bin) (r : BinFin divisor) → DivMod (toBin r + q * divisor) divisor-} data DivMod' (dividend : Bin) (divisor : Bin) : Set where result : (q : Bin) (r : BinFin divisor) → (eq : dividend ≡ toBin r + q * divisor) → DivMod' dividend divisor open Data.Digit open Data.Bin using (addBitLists; addBits; toBits; fromBits) open import Data.List using (List; _++_; [_]; []) open import Data.Empty import Data.Bin.Bijection import Data.Bin.Multiplication open Algebra.Structures using (module IsCommutativeMonoid) import Data.Bin.Props open Data.Bin.Props using (*-distrib; *2-is-2*; *2-distrib) open IsCommutativeMonoid Data.Bin.Props.bin-+-is-comm-monoid using () renaming (identity to +-identity; comm to +-comm; assoc to +-assoc) open IsCommutativeMonoid Data.Bin.Props.bin-*-is-comm-monoid using () renaming (comm to *-comm) *-distribˡ : ∀ {a b c} → c * (a + b) ≡ c * a + c * b *-distribˡ {a} {b} {c} = *-comm c (a + b) ⟨ trans ⟩ *-distrib {a} {b} {c} ⟨ trans ⟩ cong₂ _+_ (*-comm a c) (*-comm b c) *-*2-assoc : ∀ {a b} → (a * b) *2 ≡ a *2 * b *-*2-assoc {a} {b} = Data.Bin.Multiplication.*-*2-comm a b *2-cong : ∀ {a b} → a ≡ b → a *2 ≡ b *2 *2-cong = cong _*2 +-cong₁ : ∀ {a b c} → a ≡ b → a + c ≡ b + c +-cong₁ {c = c} = cong (λ z → z + c) +-cong₂ : ∀ {a b c} → a ≡ b → c + a ≡ c + b +-cong₂ {c = c} = cong (λ z → c + z) +-identityʳ = proj₂ +-identity divMod2-lem : ∀ {a} → a ≡ ⌊ a /2⌋ *2 + a %2 divMod2-lem {0#} = refl divMod2-lem {[] 1#} = refl divMod2-lem {(zero ∷ xs) 1#} = sym (+-identityʳ (⌊ (zero ∷ xs) 1# /2⌋ *2)) divMod2-lem {(suc zero ∷ xs) 1#} = Data.Bin.Multiplication.∷1#-interpretation (suc zero) xs ⟨ trans ⟩ +-comm ([] 1#) ((zero ∷ xs) 1#) divMod2-lem {(suc (suc ()) ∷ xs) 1#} import Relation.Binary.EqReasoning open import Data.Bin.Props helper' : ∀ l → ⌊ l 1# /2⌋ < l 1# helper' [] = Data.Bin.less (Data.Nat.s≤s Data.Nat.z≤n) helper' (x ∷ xs) = Data.Bin.less (Data.Bin.NatHelpers.kojojo x (toℕ (xs 1#)) (1+≢0 xs)) helper : ∀ {a} {d} → (≢0 : False (d ≟ fromℕ 0)) → ¬ (a < d) → ⌊ a /2⌋ < a helper {_} {0#} () _ helper {0#} {l 1#} _ a≮d = ⊥-elim (a≮d (z<nz l)) helper {l 1#} _ _ = helper' l open import Data.Sum _≤_ : Bin → Bin → Set a ≤ b = a ≡ b ⊎ a < b ¬>→< : ∀ {a b} → ¬ (b ≤ a) → a < b ¬>→< {a} {b} a≰b with compare a b ... | tri< a<b _ _ = a<b ... | tri≈ _ a≡b _ = ⊥-elim (a≰b (inj₁ (sym a≡b))) ... | tri> _ _ a>b = ⊥-elim (a≰b (inj₂ a>b)) *2-gives-space : ∀ {x y z} → (x < y) → z < fromℕ 2 → x *2 + z < y *2 *2-gives-space {x} {y} {z} (less x<y) (less z<2) = less (finalize (Data.Bin.NatHelpers.*2-gives-space x<y z<2)) where open Data.Nat using () renaming (_*_ to _ℕ*_; _+_ to _ℕ+_; _<_ to _ℕ<_) eq1 : toℕ x ℕ* 2 ℕ+ toℕ z ≡ toℕ (x *2 + z) eq1 = sym (Data.Bin.Addition.+-is-addition (x *2) z ⟨ trans ⟩ cong (λ q → q ℕ+ toℕ z) (Data.Bin.Multiplication.*2-is-*2 x)) eq2 : toℕ y ℕ* 2 ≡ toℕ (y *2) eq2 = sym (Data.Bin.Multiplication.*2-is-*2 y) finalize : toℕ x ℕ* 2 ℕ+ toℕ z ℕ< toℕ y ℕ* 2 → toℕ (x *2 + z) ℕ< toℕ (y *2) finalize = subst₂ _ℕ<_ eq1 eq2 <-pres₁ : ∀ {a b c} → a ≡ b → a < c → b < c <-pres₁ refl eq = eq <-pres₂ : ∀ {a b c} → a ≡ b → c < a → c < b <-pres₂ refl eq = eq *-identityˡ : ∀ {x} → [] 1# * x ≡ x *-identityˡ = refl x*2≡x+x : ∀ {x} → x *2 ≡ x + x x*2≡x+x {x} = *2-is-2* x ⟨ trans ⟩ *-distrib {[] 1#} {[] 1#} {x} ⟨ trans ⟩ cong₂ _+_ (*-identityˡ {x}) (*-identityˡ {x}) %2<2 : ∀ {x} → x %2 < fromℕ 2 %2<2 {0#} = Data.Bin.less (Data.Nat.s≤s Data.Nat.z≤n) %2<2 {[] 1#} = Data.Bin.less (Data.Nat.s≤s (Data.Nat.s≤s Data.Nat.z≤n)) %2<2 {(zero ∷ xs) 1#} = Data.Bin.less (Data.Nat.s≤s Data.Nat.z≤n) %2<2 {(suc zero ∷ xs) 1#} = Data.Bin.less (Data.Nat.s≤s (Data.Nat.s≤s Data.Nat.z≤n)) %2<2 {(suc (suc ()) ∷ xs) 1#} -+-elim : ∀ {x z} → ¬ x < z → x - z + z ≡ x -+-elim = Data.Bin.Minus.-+-elim' open import Data.Bin.Addition using (+-is-addition) open import Data.Bin.Minus using (_-?_; positive; negative; equal; Greater; greater) lemma1 : ∀ (f d q : Bin) → (d + f) + q * d ≡ f + (fromℕ 1 + q) * d lemma1 f d q = let open ≡-Reasoning in begin (d + f) + q * d ≡⟨ +-cong₁ {c = q * d} (+-comm d f) ⟩ (f + d) + q * d ≡⟨ +-assoc f d (q * d) ⟩ f + (d + q * d) ≡⟨ +-cong₂ {c = f} (+-cong₁ {c = q * d} (*-identityˡ {d})) ⟩ f + ((fromℕ 1 * d) + q * d) ≡⟨ +-cong₂ {c = f} (PropEq.sym (*-distrib {fromℕ 1} {q} {d})) ⟩ f + (fromℕ 1 + q) * d ∎ lemma2 : ∀ d q → d + q * d ≡ d + 0# + q * d lemma2 d q = cong₂ _+_ (sym (proj₂ +-identity d)) (refl {x = q * d}) open import Algebra.FunctionProperties using (LeftCancellative; RightCancellative; Cancellative) +-cancelˡ-< : LeftCancellative Data.Nat._<_ Data.Nat._+_ +-cancelˡ-< c {y} {z} le = Data.Nat.Properties.+-cancelˡ-≤ c (subst₂ Data.Nat._≤_ (PropEq.sym (Data.Nat.Properties.+-suc c y)) (PropEq.refl {x = (Data.Nat._+_ c z)}) le) +-<-left-cancellative : LeftCancellative _<_ _+_ +-<-left-cancellative c {a} {b} (less le) = less (+-cancelˡ-< (toℕ c) brr) where brr : toℕ c Data.Nat.+ toℕ a Data.Nat.< toℕ c Data.Nat.+ toℕ b brr = (subst₂ Data.Nat._<_ (Data.Bin.Addition.+-is-addition c a) (Data.Bin.Addition.+-is-addition c b) le) +-elim₂ : RightCancellative _<_ _+_ +-elim₂ {z} x y (less lt) rewrite +-is-addition x z | +-is-addition y z = less (Data.Bin.NatHelpers.+-elim₂ {toℕ x} {toℕ y} {toℕ z} lt) fixup-divmod : ∀ a d q r → a ≡ r + q * d → r < d + d → DivMod' a d fixup-divmod a d q r eq not-too-big = case r -? d of λ { (positive (greater diff PropEq.refl)) → result (fromℕ 1 + q) (diff 1# , +-<-left-cancellative d not-too-big) (PropEq.trans eq (lemma1 (diff 1#) d q)); (negative x) → result q (r , Data.Bin.Minus.greater-to-< _ _ x) eq ; (equal PropEq.refl) → result (fromℕ 1 + q) (0# , (+-<-left-cancellative d (subst (λ z → z < d + d) (PropEq.sym (proj₂ +-identity _)) not-too-big )) ) (PropEq.trans eq (PropEq.trans (lemma2 d q) (lemma1 0# d q))) } lemma3 : ∀ r q d bit → (r + q * d) *2 + bit ≡ (r *2 + bit) + q *2 * d lemma3 r q d bit = let open ≡-Reasoning in begin (r + q * d) *2 + bit ≡⟨ +-cong₁ {c = bit} (begin (r + q * d) *2 ≡⟨ *2-distrib r (q * d) ⟩ r *2 + (q * d) *2 ≡⟨ +-comm (r *2) ((q * d) *2) ⟩ (q * d) *2 + r *2 ∎) ⟩ ((q * d) *2 + r *2) + bit ≡⟨ +-assoc ((q * d) *2) (r *2) (bit) ⟩ (q * d) *2 + (r *2 + bit) ≡⟨ +-comm ((q * d) *2) (r *2 + bit) ⟩ (r *2 + bit) + (q * d) *2 ≡⟨ +-cong₂ {c = r *2 + bit} (*-*2-assoc {q} {d}) ⟩ (r *2 + bit) + q *2 * d ∎ dm-step : ∀ a d q (r : BinFin d) → a ≡ toBin r + q * d → ∀ w (bit : BinFin (fromℕ 2)) → w ≡ (a *2 + proj₁ bit) → DivMod' w d dm-step ._ d q (r' , r'<d) refl ._ (bit , bit<2) refl = fixup-divmod _ d (q *2) (r' *2 + bit) (lemma3 r' q d bit) (<-pres₂ x*2≡x+x (*2-gives-space {r'} {d} {bit} r'<d (bit<2))) dmRec : (d : Bin) → {≢0 : False (d ≟ fromℕ 0)} → (a : Bin) → ((a' : Bin) → (a' < a) → DivMod' a' d) → DivMod' a d dmRec d {≢0} a rec = case a <? d of λ { (yes a<d) → result (0#) (a , a<d) (sym (+-identityʳ _)) ; (no ¬a<d) → case rec ⌊ a /2⌋ (helper ≢0 ¬a<d) of λ { (result q r eq) → dm-step ⌊ a /2⌋ d q r eq a (a %2 , %2<2) divMod2-lem } } import Data.Bin.Rec _divMod_ : (a : Bin) → (d : Bin) → {≢0 : False (d ≟ fromℕ 0)} → DivMod' a d _divMod_ a d {≡0} = Data.Bin.Rec.rec (λ x → DivMod' x d) (dmRec d {≡0}) a
{ "alphanum_fraction": 0.5324069273, "avg_line_length": 33.7167832168, "ext": "agda", "hexsha": "76622c63e75b5a6e29293ec4182e526ba182f6ba", "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": "09cc5104421e88da82f9fead5a43f0028f77810d", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "Rotsor/BinDivMod", "max_forks_repo_path": "Data/Bin/DivMod.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "09cc5104421e88da82f9fead5a43f0028f77810d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "Rotsor/BinDivMod", "max_issues_repo_path": "Data/Bin/DivMod.agda", "max_line_length": 137, "max_stars_count": 1, "max_stars_repo_head_hexsha": "09cc5104421e88da82f9fead5a43f0028f77810d", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "Rotsor/BinDivMod", "max_stars_repo_path": "Data/Bin/DivMod.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-18T13:58:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-18T13:58:14.000Z", "num_tokens": 4045, "size": 9643 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.ZariskiLattice.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.HLevels open import Cubical.Foundations.Transport import Cubical.Data.Empty as ⊥ open import Cubical.Data.Bool open import Cubical.Data.Nat renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_ ; _^_ to _^ℕ_ ; +-comm to +ℕ-comm ; +-assoc to +ℕ-assoc ; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm ; ·-identityʳ to ·ℕ-rid) open import Cubical.Data.Sigma.Base open import Cubical.Data.Sigma.Properties open import Cubical.Data.FinData open import Cubical.Data.Unit open import Cubical.Relation.Nullary open import Cubical.Relation.Binary open import Cubical.Relation.Binary.Poset open import Cubical.Algebra.Ring open import Cubical.Algebra.Ring.Properties open import Cubical.Algebra.Ring.BigOps open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.BinomialThm open import Cubical.Algebra.CommRing.Ideal open import Cubical.Algebra.CommRing.FGIdeal open import Cubical.Algebra.CommRing.RadicalIdeal open import Cubical.Algebra.RingSolver.Reflection open import Cubical.Algebra.Semilattice open import Cubical.Algebra.Lattice open import Cubical.Algebra.DistLattice open import Cubical.Algebra.Matrix open import Cubical.HITs.SetQuotients as SQ open Iso open BinaryRelation open isEquivRel private variable ℓ ℓ' : Level module ZarLat (R' : CommRing ℓ) where open CommRingStr (snd R') open RingTheory (CommRing→Ring R') open Sum (CommRing→Ring R') open CommRingTheory R' open Exponentiation R' open BinomialThm R' open CommIdeal R' open RadicalIdeal R' open isCommIdeal open ProdFin R' private R = fst R' A = Σ[ n ∈ ℕ ] (FinVec R n) ⟨_⟩ : {n : ℕ} → FinVec R n → CommIdeal ⟨ V ⟩ = ⟨ V ⟩[ R' ] _∼_ : A → A → Type (ℓ-suc ℓ) (_ , α) ∼ (_ , β) = √ ⟨ α ⟩ ≡ √ ⟨ β ⟩ ∼EquivRel : isEquivRel (_∼_) reflexive ∼EquivRel _ = refl symmetric ∼EquivRel _ _ = sym transitive ∼EquivRel _ _ _ = _∙_ ZL : Type (ℓ-suc ℓ) ZL = A / _∼_ 0z : ZL 0z = [ 0 , (λ ()) ] 1z : ZL 1z = [ 1 , (replicateFinVec 1 1r) ] _∨z_ : ZL → ZL → ZL _∨z_ = setQuotSymmBinOp (reflexive ∼EquivRel) (transitive ∼EquivRel) (λ (_ , α) (_ , β) → (_ , α ++Fin β)) (λ (_ , α) (_ , β) → cong √ (FGIdealAddLemma _ α β ∙∙ +iComm _ _ ∙∙ sym (FGIdealAddLemma _ β α))) λ (_ , α) (_ , β) (_ , γ) α∼β → --need to show α∨γ ∼ β∨γ √ ⟨ α ++Fin γ ⟩ ≡⟨ cong √ (FGIdealAddLemma _ α γ) ⟩ √ (⟨ α ⟩ +i ⟨ γ ⟩) ≡⟨ sym (√+LContr _ _) ⟩ √ (√ ⟨ α ⟩ +i ⟨ γ ⟩) ≡⟨ cong (λ I → √ (I +i ⟨ γ ⟩)) α∼β ⟩ √ (√ ⟨ β ⟩ +i ⟨ γ ⟩) ≡⟨ √+LContr _ _ ⟩ √ (⟨ β ⟩ +i ⟨ γ ⟩) ≡⟨ cong √ (sym (FGIdealAddLemma _ β γ)) ⟩ √ ⟨ β ++Fin γ ⟩ ∎ _∧z_ : ZL → ZL → ZL _∧z_ = setQuotSymmBinOp (reflexive ∼EquivRel) (transitive ∼EquivRel) (λ (_ , α) (_ , β) → (_ , α ··Fin β)) (λ (_ , α) (_ , β) → cong √ (FGIdealMultLemma _ α β ∙∙ ·iComm _ _ ∙∙ sym (FGIdealMultLemma _ β α))) λ (_ , α) (_ , β) (_ , γ) α∼β → --need to show α∧γ ∼ β∧γ √ ⟨ α ··Fin γ ⟩ ≡⟨ cong √ (FGIdealMultLemma _ α γ) ⟩ √ (⟨ α ⟩ ·i ⟨ γ ⟩) ≡⟨ sym (√·LContr _ _) ⟩ √ (√ ⟨ α ⟩ ·i ⟨ γ ⟩) ≡⟨ cong (λ I → √ (I ·i ⟨ γ ⟩)) α∼β ⟩ √ (√ ⟨ β ⟩ ·i ⟨ γ ⟩) ≡⟨ √·LContr _ _ ⟩ √ (⟨ β ⟩ ·i ⟨ γ ⟩) ≡⟨ cong √ (sym (FGIdealMultLemma _ β γ)) ⟩ √ ⟨ β ··Fin γ ⟩ ∎ -- join axioms ∨zAssoc : ∀ (𝔞 𝔟 𝔠 : ZL) → 𝔞 ∨z (𝔟 ∨z 𝔠) ≡ (𝔞 ∨z 𝔟) ∨z 𝔠 ∨zAssoc = SQ.elimProp3 (λ _ _ _ → squash/ _ _) λ (_ , α) (_ , β) (_ , γ) → eq/ _ _ (cong √ (IdealAddAssoc _ _ _ _)) ∨zComm : ∀ (𝔞 𝔟 : ZL) → 𝔞 ∨z 𝔟 ≡ 𝔟 ∨z 𝔞 ∨zComm = SQ.elimProp2 (λ _ _ → squash/ _ _) λ (_ , α) (_ , β) → eq/ _ _ (cong √ (FGIdealAddLemma _ α β ∙∙ +iComm _ _ ∙∙ sym (FGIdealAddLemma _ β α))) ∨zLid : ∀ (𝔞 : ZL) → 0z ∨z 𝔞 ≡ 𝔞 ∨zLid = SQ.elimProp (λ _ → squash/ _ _) λ _ → eq/ _ _ refl ∨zRid : ∀ (𝔞 : ZL) → 𝔞 ∨z 0z ≡ 𝔞 ∨zRid _ = ∨zComm _ _ ∙ ∨zLid _ -- -- meet axioms ∧zAssoc : ∀ (𝔞 𝔟 𝔠 : ZL) → 𝔞 ∧z (𝔟 ∧z 𝔠) ≡ (𝔞 ∧z 𝔟) ∧z 𝔠 ∧zAssoc = SQ.elimProp3 (λ _ _ _ → squash/ _ _) λ (_ , α) (_ , β) (_ , γ) → eq/ _ _ (√ ⟨ α ··Fin (β ··Fin γ) ⟩ ≡⟨ cong √ (FGIdealMultLemma _ _ _) ⟩ √ (⟨ α ⟩ ·i ⟨ β ··Fin γ ⟩) ≡⟨ cong (λ x → √ (⟨ α ⟩ ·i x)) (FGIdealMultLemma _ _ _) ⟩ √ (⟨ α ⟩ ·i (⟨ β ⟩ ·i ⟨ γ ⟩)) ≡⟨ cong √ (·iAssoc _ _ _) ⟩ √ ((⟨ α ⟩ ·i ⟨ β ⟩) ·i ⟨ γ ⟩) ≡⟨ cong (λ x → √ (x ·i ⟨ γ ⟩)) (sym (FGIdealMultLemma _ _ _)) ⟩ √ (⟨ α ··Fin β ⟩ ·i ⟨ γ ⟩) ≡⟨ cong √ (sym (FGIdealMultLemma _ _ _)) ⟩ √ ⟨ (α ··Fin β) ··Fin γ ⟩ ∎) ∧zComm : ∀ (𝔞 𝔟 : ZL) → 𝔞 ∧z 𝔟 ≡ 𝔟 ∧z 𝔞 ∧zComm = SQ.elimProp2 (λ _ _ → squash/ _ _) λ (_ , α) (_ , β) → eq/ _ _ (cong √ (FGIdealMultLemma _ α β ∙∙ ·iComm _ _ ∙∙ sym (FGIdealMultLemma _ β α))) ∧zRid : ∀ (𝔞 : ZL) → 𝔞 ∧z 1z ≡ 𝔞 ∧zRid = SQ.elimProp (λ _ → squash/ _ _) λ (_ , α) → eq/ _ _ (cong √ (⟨ α ··Fin (replicateFinVec 1 1r) ⟩ ≡⟨ FGIdealMultLemma _ _ _ ⟩ ⟨ α ⟩ ·i ⟨ (replicateFinVec 1 1r) ⟩ ≡⟨ cong (⟨ α ⟩ ·i_) (contains1Is1 _ (indInIdeal _ _ zero)) ⟩ ⟨ α ⟩ ·i 1Ideal ≡⟨ ·iRid _ ⟩ ⟨ α ⟩ ∎)) -- absorption and distributivity ∧zAbsorb∨z : ∀ (𝔞 𝔟 : ZL) → 𝔞 ∧z (𝔞 ∨z 𝔟) ≡ 𝔞 ∧zAbsorb∨z = SQ.elimProp2 (λ _ _ → squash/ _ _) λ (_ , α) (_ , β) → eq/ _ _ (√ ⟨ α ··Fin (α ++Fin β) ⟩ ≡⟨ cong √ (FGIdealMultLemma _ α (α ++Fin β)) ⟩ √ (⟨ α ⟩ ·i ⟨ α ++Fin β ⟩) ≡⟨ cong (λ x → √ (⟨ α ⟩ ·i x)) (FGIdealAddLemma _ α β) ⟩ √ (⟨ α ⟩ ·i (⟨ α ⟩ +i ⟨ β ⟩)) ≡⟨ √·Absorb+ _ _ ⟩ √ ⟨ α ⟩ ∎) ∧zLDist∨z : ∀ (𝔞 𝔟 𝔠 : ZL) → 𝔞 ∧z (𝔟 ∨z 𝔠) ≡ (𝔞 ∧z 𝔟) ∨z (𝔞 ∧z 𝔠) ∧zLDist∨z = SQ.elimProp3 (λ _ _ _ → squash/ _ _) λ (_ , α) (_ , β) (_ , γ) → eq/ _ _ (√ ⟨ α ··Fin (β ++Fin γ) ⟩ ≡⟨ cong √ (FGIdealMultLemma _ _ _) ⟩ √ (⟨ α ⟩ ·i ⟨ β ++Fin γ ⟩) ≡⟨ cong (λ x → √ (⟨ α ⟩ ·i x)) (FGIdealAddLemma _ _ _) ⟩ √ (⟨ α ⟩ ·i (⟨ β ⟩ +i ⟨ γ ⟩)) ≡⟨ cong √ (·iRdist+i _ _ _) ⟩ -- L/R-dist are swapped -- in Lattices vs Rings √ (⟨ α ⟩ ·i ⟨ β ⟩ +i ⟨ α ⟩ ·i ⟨ γ ⟩) ≡⟨ cong₂ (λ x y → √ (x +i y)) (sym (FGIdealMultLemma _ _ _)) (sym (FGIdealMultLemma _ _ _)) ⟩ √ (⟨ α ··Fin β ⟩ +i ⟨ α ··Fin γ ⟩) ≡⟨ cong √ (sym (FGIdealAddLemma _ _ _)) ⟩ √ ⟨ (α ··Fin β) ++Fin (α ··Fin γ) ⟩ ∎) ZariskiLattice : DistLattice (ℓ-suc ℓ) fst ZariskiLattice = ZL DistLatticeStr.0l (snd ZariskiLattice) = 0z DistLatticeStr.1l (snd ZariskiLattice) = 1z DistLatticeStr._∨l_ (snd ZariskiLattice) = _∨z_ DistLatticeStr._∧l_ (snd ZariskiLattice) = _∧z_ DistLatticeStr.isDistLattice (snd ZariskiLattice) = makeIsDistLattice∧lOver∨l squash/ ∨zAssoc ∨zRid ∨zComm ∧zAssoc ∧zRid ∧zComm ∧zAbsorb∨z ∧zLDist∨z -- An equivalent definition that doesn't bump up the unviverse level module SmallZarLat (R' : CommRing ℓ) where open CommRingStr (snd R') open CommIdeal R' open RadicalIdeal R' open ZarLat R' open Iso private R = fst R' A = Σ[ n ∈ ℕ ] (FinVec R n) ⟨_⟩ : {n : ℕ} → FinVec R n → CommIdeal ⟨ V ⟩ = ⟨ V ⟩[ R' ] -- This is small! _≼_ : A → A → Type ℓ (_ , α) ≼ (_ , β) = ∀ i → α i ∈ √ ⟨ β ⟩ _∼'_ : A → A → Type ℓ α ∼' β = (α ≼ β) × (β ≼ α) -- lives in the same universe as R ZL' : Type ℓ ZL' = A / (_∼'_) IsoLarLatSmall : Iso ZL ZL' IsoLarLatSmall = relBiimpl→TruncIso ~→∼' ~'→∼ where ~→∼' : ∀ {a b : A} → a ∼ b → a ∼' b ~→∼' r = √FGIdealCharLImpl _ ⟨ _ ⟩ (λ x h → subst (λ p → x ∈ p) r h) , √FGIdealCharLImpl _ ⟨ _ ⟩ (λ x h → subst (λ p → x ∈ p) (sym r) h) ~'→∼ : ∀ {a b : A} → a ∼' b → a ∼ b ~'→∼ r = CommIdeal≡Char (√FGIdealCharRImpl _ ⟨ _ ⟩ (fst r)) (√FGIdealCharRImpl _ ⟨ _ ⟩ (snd r)) ZL≃ZL' : ZL ≃ ZL' ZL≃ZL' = isoToEquiv IsoLarLatSmall
{ "alphanum_fraction": 0.5184823716, "avg_line_length": 36.1101321586, "ext": "agda", "hexsha": "fd78ec0894db6397f0da21b284deb61cd90afb9f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_path": "Cubical/Algebra/ZariskiLattice/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_path": "Cubical/Algebra/ZariskiLattice/Base.agda", "max_line_length": 102, "max_stars_count": null, "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_path": "Cubical/Algebra/ZariskiLattice/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3662, "size": 8197 }
------------------------------------------------------------------------------ -- Agda-Prop Library. -- Theorems with different connectives. ------------------------------------------------------------------------------ open import Data.Nat using ( ℕ ) module Data.PropFormula.Theorems.Mixies ( n : ℕ ) where ------------------------------------------------------------------------------ open import Data.PropFormula.Syntax n open import Data.PropFormula.Theorems.Classical n open import Data.PropFormula.Theorems.Biimplication n using ( ⇔-¬-to-¬; ⊃-⇔-¬∨ ) open import Data.PropFormula.Theorems.Disjunction n using ( ∨-dmorgan; ∨-dmorgan₁ ) open import Data.PropFormula.Theorems.Implication n using ( vanDalen244e; ⊃-equiv ) open import Data.PropFormula.Theorems.Weakening n open import Function using ( _$_ ; _∘_ ) ------------------------------------------------------------------------------ -- Theorem. e245b : ∀ {Γ Δ} {φ ψ} → Γ ⊢ φ → Δ , φ ⊢ ψ → Γ ⨆ Δ ⊢ ψ -- Proof. e245b {Γ}{Δ} Γ⊢φ Δ,φ⊢ψ = ⊃-elim (weaken-Δ₂ Γ $ ⊃-intro Δ,φ⊢ψ) (weaken-Δ₁ Δ Γ⊢φ) -------------------------------------------------------------------------- ∎ -- Theorem. ¬⊃-to-∧¬ : ∀ {Γ} {φ ψ} → Γ ⊢ ¬ (φ ⊃ ψ) → Γ ⊢ φ ∧ ¬ ψ -- Proof. ¬⊃-to-∧¬ {Γ}{φ}{ψ} Γ⊢¬⟪φ⊃ψ⟫ = ∧-intro (⊃-elim vanDalen244e (∧-proj₁ p2)) (∧-proj₂ p2) where p1 : Γ ⊢ ¬ (¬ φ ∨ ψ) p1 = ⇔-¬-to-¬ ⊃-⇔-¬∨ Γ⊢¬⟪φ⊃ψ⟫ p2 : Γ ⊢ ¬ (¬ φ) ∧ ¬ ψ p2 = ∨-dmorgan₁ p1 -------------------------------------------------------------------------- ∎ -- Theorem. ⊃¬∧¬⊃-to-¬⇔ : ∀ {Γ} {φ ψ} → Γ ⊢ (φ ⊃ ¬ ψ) ∧ (¬ ψ ⊃ φ) → Γ ⊢ ¬ (φ ⇔ ψ) -- Proof. ⊃¬∧¬⊃-to-¬⇔ {Γ}{φ}{ψ} thm = ¬-intro (¬-elim (¬-intro (¬-elim (⊃-elim (weaken ψ (weaken (φ ⇔ ψ) (∧-proj₁ thm))) (⇔-elim₂ (assume {Γ = Γ , φ ⇔ ψ} ψ) (weaken ψ (assume (φ ⇔ ψ))))) (assume {Γ = Γ , φ ⇔ ψ} ψ))) (RAA (¬-elim (¬-intro (¬-elim (⊃-elim (weaken φ (weaken (¬ ψ ) (weaken (φ ⇔ ψ) (∧-proj₁ thm)))) (assume {Γ = Γ , φ ⇔ ψ , ¬ ψ} φ)) (⇔-elim₁ (assume {Γ = Γ , φ ⇔ ψ , ¬ ψ} φ) (weaken φ (weaken (¬ ψ) (assume (φ ⇔ ψ))))))) (⊃-elim (weaken (¬ ψ) (weaken (φ ⇔ ψ) (∧-proj₂ thm))) (assume {Γ = Γ , φ ⇔ ψ} (¬ ψ)))))) -------------------------------------------------------------------------- ∎
{ "alphanum_fraction": 0.3568515498, "avg_line_length": 27.2444444444, "ext": "agda", "hexsha": "3f0750f19f6c352e6483988b562e887487b0a4cc", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2017-12-01T17:01:25.000Z", "max_forks_repo_forks_event_min_datetime": "2017-03-30T16:41:56.000Z", "max_forks_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jonaprieto/agda-prop", "max_forks_repo_path": "src/Data/PropFormula/Theorems/Mixies.agda", "max_issues_count": 18, "max_issues_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_issues_repo_issues_event_max_datetime": "2017-12-18T16:34:21.000Z", "max_issues_repo_issues_event_min_datetime": "2017-03-08T14:33:10.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "jonaprieto/agda-prop", "max_issues_repo_path": "src/Data/PropFormula/Theorems/Mixies.agda", "max_line_length": 78, "max_stars_count": 13, "max_stars_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jonaprieto/agda-prop", "max_stars_repo_path": "src/Data/PropFormula/Theorems/Mixies.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T03:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2017-05-01T16:45:41.000Z", "num_tokens": 938, "size": 2452 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties of non-empty lists ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.NonEmpty.Properties where open import Category.Monad open import Data.List as List using (List; []; _∷_; _++_) open import Data.List.Categorical using () renaming (monad to listMonad) open import Data.List.NonEmpty.Categorical using () renaming (monad to list⁺Monad) open import Data.List.NonEmpty as List⁺ open import Data.List.Properties open import Function open import Relation.Binary.PropositionalEquality open ≡-Reasoning private open module LMo {a} = RawMonad {f = a} listMonad using () renaming (_>>=_ to _⋆>>=_) open module L⁺Mo {a} = RawMonad {f = a} list⁺Monad η : ∀ {a} {A : Set a} (xs : List⁺ A) → head xs ∷ tail xs ≡ List⁺.toList xs η _ = refl toList-fromList : ∀ {a} {A : Set a} x (xs : List A) → x ∷ xs ≡ List⁺.toList (x ∷ xs) toList-fromList _ _ = refl toList-⁺++ : ∀ {a} {A : Set a} (xs : List⁺ A) ys → List⁺.toList xs ++ ys ≡ List⁺.toList (xs ⁺++ ys) toList-⁺++ _ _ = refl toList-⁺++⁺ : ∀ {a} {A : Set a} (xs ys : List⁺ A) → List⁺.toList xs ++ List⁺.toList ys ≡ List⁺.toList (xs ⁺++⁺ ys) toList-⁺++⁺ _ _ = refl toList->>= : ∀ {ℓ} {A B : Set ℓ} (f : A → List⁺ B) (xs : List⁺ A) → (List⁺.toList xs ⋆>>= List⁺.toList ∘ f) ≡ (List⁺.toList (xs >>= f)) toList->>= f (x ∷ xs) = begin List.concat (List.map (List⁺.toList ∘ f) (x ∷ xs)) ≡⟨ cong List.concat $ map-compose {g = List⁺.toList} (x ∷ xs) ⟩ List.concat (List.map List⁺.toList (List.map f (x ∷ xs))) ∎
{ "alphanum_fraction": 0.5213533001, "avg_line_length": 32.7818181818, "ext": "agda", "hexsha": "e5921cb82d5e6d69f224ae219bfb1b8556667d48", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/NonEmpty/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/NonEmpty/Properties.agda", "max_line_length": 82, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/NonEmpty/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 582, "size": 1803 }
{-# OPTIONS --without-K --safe #-} module Categories.Bicategory where open import Level open import Data.Product using (_,_) open import Relation.Binary using (Rel) open import Categories.Category using (Category; module Commutation) open import Categories.Category.Monoidal.Instance.Cats using (module Product) open import Categories.Enriched.Category using () renaming (Category to Enriched) open import Categories.Functor using (module Functor) open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism) -- https://ncatlab.org/nlab/show/bicategory -- notice that some axioms in nLab are inconsistent. they have been fixed in this definition. record Bicategory o ℓ e t : Set (suc (o ⊔ ℓ ⊔ e ⊔ t)) where field enriched : Enriched (Product.Cats-Monoidal {o} {ℓ} {e}) t open Enriched enriched public module hom {A B} = Category (hom A B) module ComHom {A B} = Commutation (hom A B) infix 4 _⇒₁_ _⇒₂_ _≈_ infixr 7 _∘ᵥ_ _∘₁_ infixr 9 _▷_ infixl 9 _◁_ infixr 11 _⊚₀_ _⊚₁_ _∘ₕ_ _⇒₁_ : Obj → Obj → Set o A ⇒₁ B = Category.Obj (hom A B) _⇒₂_ : {A B : Obj} → A ⇒₁ B → A ⇒₁ B → Set ℓ _⇒₂_ = hom._⇒_ _⊚₀_ : {A B C : Obj} → B ⇒₁ C → A ⇒₁ B → A ⇒₁ C f ⊚₀ g = Functor.F₀ ⊚ (f , g) _⊚₁_ : {A B C : Obj} {f h : B ⇒₁ C} {g i : A ⇒₁ B} → f ⇒₂ h → g ⇒₂ i → f ⊚₀ g ⇒₂ h ⊚₀ i α ⊚₁ β = Functor.F₁ ⊚ (α , β) _≈_ : {A B : Obj} {f g : A ⇒₁ B} → Rel (f ⇒₂ g) e _≈_ = hom._≈_ id₁ : {A : Obj} → A ⇒₁ A id₁ {_} = Functor.F₀ id _ id₂ : {A B : Obj} {f : A ⇒₁ B} → f ⇒₂ f id₂ {A} {B} = Category.id (hom A B) -- 1-cell composition _∘₁_ : {A B C : Obj} → B ⇒₁ C → A ⇒₁ B → A ⇒₁ C _∘₁_ = _⊚₀_ -- horizontal composition _∘ₕ_ : {A B C : Obj} {f h : B ⇒₁ C} {g i : A ⇒₁ B} → f ⇒₂ h → g ⇒₂ i → f ⊚₀ g ⇒₂ h ⊚₀ i _∘ₕ_ = _⊚₁_ -- vertical composition _∘ᵥ_ : {A B : Obj} {f g h : A ⇒₁ B} (α : g ⇒₂ h) (β : f ⇒₂ g) → f ⇒₂ h _∘ᵥ_ = hom._∘_ _◁_ : {A B C : Obj} {g h : B ⇒₁ C} (α : g ⇒₂ h) (f : A ⇒₁ B) → g ∘₁ f ⇒₂ h ∘₁ f α ◁ _ = α ⊚₁ id₂ _▷_ : {A B C : Obj} {f g : A ⇒₁ B} (h : B ⇒₁ C) (α : f ⇒₂ g) → h ∘₁ f ⇒₂ h ∘₁ g _ ▷ α = id₂ ⊚₁ α private λ⇒ : {A B : Obj} {f : A ⇒₁ B} → id₁ ⊚₀ f hom.⇒ f λ⇒ {_} {_} {f} = NaturalIsomorphism.⇒.η unitˡ (_ , f) ρ⇒ : {A B : Obj} {f : A ⇒₁ B} → f ⊚₀ id₁ hom.⇒ f ρ⇒ {_} {_} {f} = NaturalIsomorphism.⇒.η unitʳ (f , _) α⇒ : {A B C D : Obj} {f : D ⇒₁ B} {g : C ⇒₁ D} {h : A ⇒₁ C} → ((f ⊚₀ g) ⊚₀ h) hom.⇒ (f ⊚₀ (g ⊚₀ h)) α⇒ {_} {_} {_} {_} {f} {g} {h} = NaturalIsomorphism.⇒.η ⊚-assoc ((f , g) , h) field triangle : {A B C : Obj} {f : A ⇒₁ B} {g : B ⇒₁ C} → let open ComHom {A} {C} in [ (g ∘₁ id₁) ∘₁ f ⇒ g ∘₁ f ]⟨ α⇒ ⇒⟨ g ∘₁ id₁ ∘₁ f ⟩ g ▷ λ⇒ ≈ ρ⇒ ◁ f ⟩ pentagon : {A B C D E : Obj} {f : A ⇒₁ B} {g : B ⇒₁ C} {h : C ⇒₁ D} {i : D ⇒₁ E} → let open ComHom {A} {E} in [ ((i ∘₁ h) ∘₁ g) ∘₁ f ⇒ i ∘₁ h ∘₁ g ∘₁ f ]⟨ α⇒ ◁ f ⇒⟨ (i ∘₁ h ∘₁ g) ∘₁ f ⟩ α⇒ ⇒⟨ i ∘₁ (h ∘₁ g) ∘₁ f ⟩ i ▷ α⇒ ≈ α⇒ ⇒⟨ (i ∘₁ h) ∘₁ g ∘₁ f ⟩ α⇒ ⟩
{ "alphanum_fraction": 0.4678982435, "avg_line_length": 33.693877551, "ext": "agda", "hexsha": "6410518212bd5f12e376e91edc983f63a8c19bf7", "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.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.agda", "max_line_length": 93, "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.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1504, "size": 3302 }
{- Pointed structure: X ↦ X -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Structures.Pointed where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Univalence open import Cubical.Foundations.SIP open import Cubical.Foundations.Pointed.Base private variable ℓ : Level -- Structured isomorphisms PointedStructure : Type ℓ → Type ℓ PointedStructure X = X PointedEquivStr : StrEquiv PointedStructure ℓ PointedEquivStr A B f = equivFun f (pt A) ≡ pt B pointedUnivalentStr : UnivalentStr {ℓ} PointedStructure PointedEquivStr pointedUnivalentStr f = invEquiv (ua-ungluePath-Equiv f) pointedSIP : (A B : Pointed ℓ) → A ≃[ PointedEquivStr ] B ≃ (A ≡ B) pointedSIP = SIP pointedUnivalentStr pointed-sip : (A B : Pointed ℓ) → A ≃[ PointedEquivStr ] B → (A ≡ B) pointed-sip A B = equivFun (pointedSIP A B) -- ≡ λ (e , p) i → ua e i , ua-gluePath e p i pointedEquivAction : EquivAction {ℓ} PointedStructure pointedEquivAction e = e pointedTransportStr : TransportStr {ℓ} pointedEquivAction pointedTransportStr e s = sym (transportRefl _)
{ "alphanum_fraction": 0.75, "avg_line_length": 26.8571428571, "ext": "agda", "hexsha": "e9ce88e40d17948500f737302582792155b91f0f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Structures/Pointed.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/Pointed.agda", "max_line_length": 89, "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/Pointed.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 378, "size": 1128 }