{"text": "module API where\r\n\r\nopen import Algebra\r\nopen import Prelude\r\n\r\nempty : ∀ {A} -> Graph A\r\nempty = ε\r\n\r\nvertex : ∀ {A} -> A -> Graph A\r\nvertex = v\r\n\r\noverlay : ∀ {A} -> Graph A -> Graph A -> Graph A\r\noverlay = _+_\r\n\r\nconnect : ∀ {A} -> Graph A -> Graph A -> Graph A\r\nconnect = _*_\r\n\r\nedge : ∀ {A} -> A -> A -> Graph A\r\nedge x y = connect (vertex x) (vertex y)\r\n\r\noverlays : ∀ {A} -> List (Graph A) -> Graph A\r\noverlays = foldr overlay empty\r\n\r\nconnects : ∀ {A} -> List (Graph A) -> Graph A\r\nconnects = foldr connect empty\r\n\r\nvertices : ∀ {A} -> List A -> Graph A\r\nvertices = overlays ∘ map vertex\r\n\r\nedges : ∀ {A} -> List (A × A) -> Graph A\r\nedges = overlays ∘ map (uncurry edge)\r\n\r\ngraph : ∀ {A} -> List A -> List (A × A) -> Graph A\r\ngraph vs es = overlay (vertices vs) (edges es)\r\n\r\nfoldg : ∀ {A} {B : Set} -> B -> (A -> B) -> (B -> B -> B) -> (B -> B -> B) -> Graph A -> B\r\nfoldg {A} {B} e w o c = go\r\n where\r\n go : Graph A -> B\r\n go ε = e\r\n go (v x) = w x\r\n go (x + y) = o (go x) (go y)\r\n go (x * y) = c (go x) (go y)\r\n\r\npath : ∀ {A} -> List A -> Graph A\r\npath [] = empty\r\npath (x :: []) = vertex x\r\npath (x :: xs) = edges (zip (x :: xs) xs)\r\n\r\ncircuit : ∀ {A} -> List A -> Graph A\r\ncircuit [] = empty\r\ncircuit (x :: xs) = path ([ x ] ++ xs ++ [ x ])\r\n\r\nclique : ∀ {A} -> List A -> Graph A\r\nclique = connects ∘ map vertex\r\n\r\nbiclique : ∀ {A} -> List A -> List A -> Graph A\r\nbiclique xs ys = connect (vertices xs) (vertices ys)\r\n\r\nstar : ∀ {A} -> A -> List A -> Graph A\r\nstar x ys = connect (vertex x) (vertices ys)\r\n\r\n", "meta": {"hexsha": "a17b9a7a87cec917db0d69577a1a06507ac4e0fd", "size": 1559, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/API.agda", "max_stars_repo_name": "asr/alga", "max_stars_repo_head_hexsha": "01f5f9f53ea81f692215300744aa77e26d8bf332", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/API.agda", "max_issues_repo_name": "asr/alga", "max_issues_repo_head_hexsha": "01f5f9f53ea81f692215300744aa77e26d8bf332", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/API.agda", "max_forks_repo_name": "asr/alga", "max_forks_repo_head_hexsha": "01f5f9f53ea81f692215300744aa77e26d8bf332", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.746031746, "max_line_length": 91, "alphanum_fraction": 0.5048107761, "num_tokens": 530, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.822189121808099, "lm_q2_score": 0.7905303137346446, "lm_q1q2_score": 0.6499654244121684}} {"text": "{-# OPTIONS --no-universe-polymorphism #-}\n\nopen import Relation.Binary.Core\nopen import Function\n\n\nmodule Equivalence where\n\ninfixr 5 _⇔_\n\nrecord _⇔_ (A B : Set) : Set where\n field to : A → B\n from : B → A\n\ninfixr 3 _↔_\n\nrecord _↔_ (A B : Set) : Set where\n field to : A → B\n from : B → A\n from-to : ∀ a → from (to a) ≡ a\n to-from : ∀ b → to (from b) ≡ b\n\n\n\n\ninfixr 3 _=⟨_⟩_\n\n_=⟨_⟩_ : {A : Set} (x : A) { y z : A} → x ≡ y → y ≡ z → x ≡ z\n_=⟨_⟩_ _ refl refl = refl\n\n=sym : {A : Set} {x y : A} → x ≡ y → y ≡ x\n=sym refl = refl\n\n\ninfixr 5 _under_\n\n_under_ : {A B : Set} → {x y : A} → x ≡ y → (f : A → B) → f x ≡ f y\n_under_ refl f = refl\n\n\n\ninfixr 4 _□=\n\n_□= : {A : Set} → (x : A) → x ≡ x\n_□= x = refl \n\n\n\n⇔sym : {A B : Set} → A ⇔ B → B ⇔ A \n⇔sym p = record {to = _⇔_.from p ;\n from = _⇔_.to p }\n\ninfixr 4 _□⇔\n\n_□⇔ : (A : Set) → A ⇔ A\n_□⇔ A = record {to = λ x → x;\n from = λ x → x}\n\ninfixr 3 _⇔⟨_⟩_\n\n_⇔⟨_⟩_ : (A : Set) {B C : Set} → A ⇔ B → B ⇔ C → A ⇔ C\n_⇔⟨_⟩_ A {B} {C} AisB BisC = record {to = (_⇔_.to BisC) ∘ (_⇔_.to AisB);\n from = (_⇔_.from AisB) ∘ (_⇔_.from BisC) }\n\n\n\n\n↔sym : {A B : Set} → A ↔ B → B ↔ A \n↔sym p = record {to = _↔_.from p ;\n from = _↔_.to p ;\n from-to = _↔_.to-from p ;\n to-from = _↔_.from-to p }\n\ninfixr 4 _□↔\n\n_□↔ : (A : Set) → A ↔ A\n_□↔ A = record {to = λ x → x;\n from = λ x → x;\n from-to = λ a → refl;\n to-from = λ b → refl}\n\ninfixr 3 _↔⟨_⟩_\n\n_↔⟨_⟩_ : (A : Set) {B C : Set} → A ↔ B → B ↔ C → A ↔ C\n_↔⟨_⟩_ A {B} {C} AisB BisC = record {to = to₂ ∘ to₁ ;\n from = from₁ ∘ from₂ ;\n from-to = λ a → (from₁ ∘ from₂ ∘ to₂ ∘ to₁) a =⟨ from-to₂ (to₁ a) under from₁ ⟩\n from₁ (to₁ a) =⟨ from-to₁ a ⟩\n a □= ;\n to-from = λ c → (to₂ ∘ to₁ ∘ from₁ ∘ from₂) c =⟨ to-from₁ (from₂ c) under to₂ ⟩\n to₂ (from₂ c) =⟨ to-from₂ c ⟩\n c □= } where\n to₁ = _↔_.to AisB\n to₂ = _↔_.to BisC\n from₁ = _↔_.from AisB\n from₂ = _↔_.from BisC\n from-to₁ = _↔_.from-to AisB\n from-to₂ = _↔_.from-to BisC\n to-from₁ = _↔_.to-from AisB\n to-from₂ = _↔_.to-from BisC\n", "meta": {"hexsha": "c59c6b555d4a5193022caf272e767e5f3d03a924", "size": 2884, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Equivalence.agda", "max_stars_repo_name": "NAMEhzj/Divide-and-Conquer-in-Agda", "max_stars_repo_head_hexsha": "99bd3a5e772563153d78f61c1bbca48d7809ff48", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Equivalence.agda", "max_issues_repo_name": "NAMEhzj/Divide-and-Conquer-in-Agda", "max_issues_repo_head_hexsha": "99bd3a5e772563153d78f61c1bbca48d7809ff48", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Equivalence.agda", "max_forks_repo_name": "NAMEhzj/Divide-and-Conquer-in-Agda", "max_forks_repo_head_hexsha": "99bd3a5e772563153d78f61c1bbca48d7809ff48", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.5544554455, "max_line_length": 117, "alphanum_fraction": 0.3425797503, "num_tokens": 1044, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891130942474, "lm_q2_score": 0.7905303162021597, "lm_q1q2_score": 0.6499654195523686}} {"text": "module Cats.Category.Setoids.Facts.Terminal where\n\nopen import Data.Unit using (⊤)\nopen import Level\n\nopen import Cats.Category\nopen import Cats.Category.Setoids using (Setoids)\n\n\nmodule Build {l} {l≈} where\n\n open Category (Setoids l l≈)\n\n\n One : Obj\n One = record\n { Carrier = Lift l ⊤\n ; _≈_ = λ _ _ → Lift l≈ ⊤\n }\n\n\n isTerminal : IsTerminal One\n isTerminal X = ∃!-intro _ _ _\n\n\nopen Build\n\n\ninstance\n hasTerminal : ∀ l l≈ → HasTerminal (Setoids l l≈)\n hasTerminal l l≈ = record\n { One = One\n ; isTerminal = isTerminal\n }\n", "meta": {"hexsha": "a586cdc46896716cd602e17b8c0d93d5b681afbf", "size": 562, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Category/Setoids/Facts/Terminal.agda", "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cats/Category/Setoids/Facts/Terminal.agda", "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cats/Category/Setoids/Facts/Terminal.agda", "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.0571428571, "max_line_length": 51, "alphanum_fraction": 0.6352313167, "num_tokens": 176, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9207896780646393, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.6498795628665519}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule ProMonoid where\n\nopen import Level\nopen import Algebra.Core using (Op₂)\nopen import Algebra.Definitions using (Congruent₂)\nopen import Algebra.Structures\nopen import Algebra.Bundles\nopen import Relation.Binary\n\n-- Pre-ordered monoids, additively written\n\nrecord ProMonoid c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _≼_\n infixl 7 _∙_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ₁ -- The underlying equality.\n\n _≼_ : Rel Carrier ℓ₂ -- The relation.\n isPreorder : IsPreorder _≈_ _≼_\n\n _∙_ : Op₂ Carrier -- The monoid operations.\n ε : Carrier\n isMonoid : IsMonoid _≈_ _∙_ ε\n\n ∙-mon : Congruent₂ _≼_ _∙_\n\n open IsPreorder isPreorder public\n hiding (module Eq)\n\n module Eq where\n setoid : Setoid c ℓ₁\n setoid = record { isEquivalence = isEquivalence }\n\n open Setoid setoid public\n\n monoid : Monoid c ℓ₁\n monoid = record { isMonoid = isMonoid }\n\n open IsMonoid isMonoid public -- using (∙-cong)\n hiding (reflexive; refl)\n", "meta": {"hexsha": "7b5dbc2af703be28c42397147164c11ecab20f7b", "size": 1061, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src-cbpv/ProMonoid.agda", "max_stars_repo_name": "andreasabel/ipl", "max_stars_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 19, "max_stars_repo_stars_event_min_datetime": "2018-05-16T08:08:51.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-27T19:10:49.000Z", "max_issues_repo_path": "src-cbpv/ProMonoid.agda", "max_issues_repo_name": "andreasabel/ipl", "max_issues_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src-cbpv/ProMonoid.agda", "max_forks_repo_name": "andreasabel/ipl", "max_forks_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-11-13T16:01:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-25T20:39:03.000Z", "avg_line_length": 24.1136363636, "max_line_length": 60, "alphanum_fraction": 0.6559849199, "num_tokens": 349, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9207896693699845, "lm_q2_score": 0.7057850154599563, "lm_q1q2_score": 0.6498795510316626}} {"text": "{-# OPTIONS --safe #-}\n\nmodule Cubical.Algebra.CommAlgebra.FreeCommAlgebra.Base where\n{-\n The free commutative algebra over a commutative ring,\n or in other words the ring of polynomials with coefficients in a given ring.\n Note that this is a constructive definition, which entails that polynomials\n cannot be represented by lists of coefficients, where the last one is non-zero.\n For rings with decidable equality, that is still possible.\n\n I learned about this (and other) definition(s) from David Jaz Myers.\n You can watch him talk about these things here:\n https://www.youtube.com/watch?v=VNp-f_9MnVk\n\n This file contains\n * the definition of the free commutative algebra on a type I over a commutative ring R as a HIT\n (let us call that R[I])\n * a prove that the construction is an commutative R-algebra\n * definitions of the induced maps appearing in the universal property of R[I],\n that is: * for any map I → A, where A is a commutative R-algebra,\n the induced algebra homomorphism R[I] → A\n ('inducedHom')\n * for any hom R[I] → A, the 'restricttion to variables' I → A\n ('evaluateAt')\n * a proof that the two constructions are inverse to each other\n ('homRetrievable' and 'mapRetrievable')\n * a proof, that the corresponding pointwise equivalence of functors is natural\n ('naturalR', 'naturalL')\n-}\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Algebra.CommRing\nopen import Cubical.Algebra.CommAlgebra.Base\n\nprivate\n variable\n ℓ ℓ' : Level\n\nmodule Construction (R : CommRing ℓ) where\n open CommRingStr (snd R) using (1r; 0r) renaming (_+_ to _+r_; _·_ to _·r_)\n\n data R[_] (I : Type ℓ') : Type (ℓ-max ℓ ℓ') where\n var : I → R[ I ]\n const : fst R → R[ I ]\n _+_ : R[ I ] → R[ I ] → R[ I ]\n -_ : R[ I ] → R[ I ]\n _·_ : R[ I ] → R[ I ] → R[ I ] -- \\cdot\n\n +-assoc : (x y z : R[ I ]) → x + (y + z) ≡ (x + y) + z\n +-rid : (x : R[ I ]) → x + (const 0r) ≡ x\n +-rinv : (x : R[ I ]) → x + (- x) ≡ (const 0r)\n +-comm : (x y : R[ I ]) → x + y ≡ y + x\n\n ·-assoc : (x y z : R[ I ]) → x · (y · z) ≡ (x · y) · z\n ·-lid : (x : R[ I ]) → (const 1r) · x ≡ x\n ·-comm : (x y : R[ I ]) → x · y ≡ y · x\n\n ldist : (x y z : R[ I ]) → (x + y) · z ≡ (x · z) + (y · z)\n\n +HomConst : (s t : fst R) → const (s +r t) ≡ const s + const t\n ·HomConst : (s t : fst R) → const (s ·r t) ≡ (const s) · (const t)\n\n 0-trunc : (x y : R[ I ]) (p q : x ≡ y) → p ≡ q\n\n _⋆_ : {I : Type ℓ'} → fst R → R[ I ] → R[ I ]\n r ⋆ x = const r · x\n\n ⋆-assoc : {I : Type ℓ'} → (s t : fst R) (x : R[ I ]) → (s ·r t) ⋆ x ≡ s ⋆ (t ⋆ x)\n ⋆-assoc s t x = const (s ·r t) · x ≡⟨ cong (λ u → u · x) (·HomConst _ _) ⟩\n (const s · const t) · x ≡⟨ sym (·-assoc _ _ _) ⟩\n const s · (const t · x) ≡⟨ refl ⟩\n s ⋆ (t ⋆ x) ∎\n\n ⋆-ldist-+ : {I : Type ℓ'} → (s t : fst R) (x : R[ I ]) → (s +r t) ⋆ x ≡ (s ⋆ x) + (t ⋆ x)\n ⋆-ldist-+ s t x = (s +r t) ⋆ x ≡⟨ cong (λ u → u · x) (+HomConst _ _) ⟩\n (const s + const t) · x ≡⟨ ldist _ _ _ ⟩\n (s ⋆ x) + (t ⋆ x) ∎\n\n ⋆-rdist-+ : {I : Type ℓ'} → (s : fst R) (x y : R[ I ]) → s ⋆ (x + y) ≡ (s ⋆ x) + (s ⋆ y)\n ⋆-rdist-+ s x y = const s · (x + y) ≡⟨ ·-comm _ _ ⟩\n (x + y) · const s ≡⟨ ldist _ _ _ ⟩\n (x · const s) + (y · const s) ≡⟨ cong (λ u → u + (y · const s)) (·-comm _ _) ⟩\n (s ⋆ x) + (y · const s) ≡⟨ cong (λ u → (s ⋆ x) + u) (·-comm _ _) ⟩\n (s ⋆ x) + (s ⋆ y) ∎\n\n ⋆-assoc-· : {I : Type ℓ'} → (s : fst R) (x y : R[ I ]) → (s ⋆ x) · y ≡ s ⋆ (x · y)\n ⋆-assoc-· s x y = (s ⋆ x) · y ≡⟨ sym (·-assoc _ _ _) ⟩\n s ⋆ (x · y) ∎\n\n 0a : {I : Type ℓ'} → R[ I ]\n 0a = (const 0r)\n\n 1a : {I : Type ℓ'} → R[ I ]\n 1a = (const 1r)\n\n isCommAlgebra : {I : Type ℓ'} → IsCommAlgebra R {A = R[ I ]} 0a 1a _+_ _·_ -_ _⋆_\n isCommAlgebra = makeIsCommAlgebra 0-trunc\n +-assoc +-rid +-rinv +-comm\n ·-assoc ·-lid ldist ·-comm\n ⋆-assoc ⋆-rdist-+ ⋆-ldist-+ ·-lid ⋆-assoc-·\n\n_[_] : (R : CommRing ℓ) (I : Type ℓ') → CommAlgebra R (ℓ-max ℓ ℓ')\n(R [ I ]) = R[ I ] , commalgebrastr 0a 1a _+_ _·_ -_ _⋆_ isCommAlgebra\n where\n open Construction R\n", "meta": {"hexsha": "9c88e4d95d585b6fd45ab8c61801c278adea1c96", "size": 4407, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommAlgebra/FreeCommAlgebra/Base.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/CommAlgebra/FreeCommAlgebra/Base.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/CommAlgebra/FreeCommAlgebra/Base.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.5754716981, "max_line_length": 98, "alphanum_fraction": 0.4858180168, "num_tokens": 1752, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677468516187, "lm_q2_score": 0.7662936377487304, "lm_q1q2_score": 0.6497922894285214}} {"text": "\nmodule Prelude.Semiring where\n\nopen import Agda.Builtin.Nat using (Nat; zero; suc)\nopen import Prelude.Function\n\nrecord Semiring {a} (A : Set a) : Set a where\n infixl 6 _+_\n infixl 7 _*_\n field zro one : A\n _+_ _*_ : A → A → A\n\nopen Semiring {{...}} public\n\n{-# DISPLAY Semiring.zro _ = zro #-}\n{-# DISPLAY Semiring.one _ = one #-}\n{-# DISPLAY Semiring._+_ _ a b = a + b #-}\n{-# DISPLAY Semiring._*_ _ a b = a * b #-}\n\ninfixr 8 _^_\n_^_ : ∀ {a} {A : Set a} {{_ : Semiring A}} → A → Nat → A\nn ^ zero = one\nn ^ suc m = n ^ m * n\n\nrecord Subtractive {a} (A : Set a) : Set a where\n infixl 6 _-_\n field _-_ : A → A → A\n negate : A → A\n\nopen Subtractive {{...}} public\n\n{-# DISPLAY Subtractive._-_ _ a b = a - b #-}\n{-# DISPLAY Subtractive.negate _ = negate #-}\n", "meta": {"hexsha": "d990fb42e13a36dcff1e70bf96f37e2b3d95ab0c", "size": 779, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Prelude/Semiring.agda", "max_stars_repo_name": "t-more/agda-prelude", "max_stars_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 111, "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_issues_repo_path": "src/Prelude/Semiring.agda", "max_issues_repo_name": "t-more/agda-prelude", "max_issues_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_forks_repo_path": "src/Prelude/Semiring.agda", "max_forks_repo_name": "t-more/agda-prelude", "max_forks_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "avg_line_length": 22.9117647059, "max_line_length": 56, "alphanum_fraction": 0.5725288832, "num_tokens": 267, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8887587875995483, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.6497347360074522}} {"text": "module induction where\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong; sym)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎)\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_; _^_)\n\n-- -------------------------------\n-- (zero + n) + p ≡ zero + (n + p)\n--\n-- (m + n) + p ≡ m + (n + p)\n-- ---------------------------------\n-- (suc m + n) + p ≡ suc m + (n + p)\n\n-- 1)\n-- In the beginning, we know nothing.\n\n-- On the first day, we know zero.\n-- 0 : ℕ\n\n-- On the second day, we know one and about associativity of 0.\n-- 0 : ℕ\n-- 1 : ℕ (0 + 0) + 0 ≡ 0 + (0 + 0)\n\n-- On the third day, we know two and about associativity of 1.\n-- 0 : ℕ\n-- 1 : ℕ (0 + 0) + 0 ≡ 0 + (0 + 0)\n-- 2 : ℕ (0 + 1) + 0 ≡ 0 + (1 + 0) (0 + 1) + 1 ≡ 0 + (1 + 1) (0 + 0) + 1 ≡ 0 + (0 + 1) (1 + 0) + 0 ≡ 1 + (0 + 0)\n\n-- On the fourth day, we know two and about associativity of 2.\n-- 0 : ℕ\n-- 1 : ℕ (0 + 0) + 0 ≡ 0 + (0 + 0)\n-- 2 : ℕ (0 + 1) + 0 ≡ 0 + (1 + 0) (0 + 1) + 1 ≡ 0 + (1 + 1) (0 + 0) + 1 ≡ 0 + (0 + 1) (1 + 0) + 0 ≡ 1 + (0 + 0) (1 + 0) + 1 ≡ 1 + (0 + 1) (1 + 1) + 0 ≡ 1 + (1 + 0) (1 + 1) + 1 ≡ 1 + (1 + 1)\n-- 3 : ℕ (0 + 2) + 0 ≡ 0 + (2 + 0) (0 + 2) + 2 ≡ 0 + (2 + 2) (0 + 0) + 2 ≡ 0 + (0 + 2) (0 + 2) + 1 ≡ 0 + (2 + 1) (0 + 1) + 2 ≡ 0 + (1 + 2) (2 + 0) + 0 ≡ 2 + (0 + 0) (2 + 1) + 0 ≡ 2 + (1 + 0) (2 + 2) + 0 ≡ 2 + (2 + 0) (2 + 0) + 1 ≡ 2 + (0 + 1) (2 + 0) + 2 ≡ 2 + (0 + 2) (2 + 1) + 1 ≡ 2 + (1 + 1) (2 + 1) + 2 ≡ 2 + (1 + 2) (2 + 2) + 1 ≡ 2 + (2 + 1) (2 + 2) + 2 ≡ 2 + (2 + 2)\n\n\n-- 2)\n+-assoc : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p)\n+-assoc zero n p =\n begin\n (zero + n) + p\n ≡⟨⟩\n n + p\n ≡⟨⟩\n zero + (n + p)\n ∎\n+-assoc (suc m) n p =\n begin\n (suc m + n) + p\n ≡⟨⟩\n suc (m + n) + p\n ≡⟨⟩\n suc ((m + n) + p)\n ≡⟨ cong suc (+-assoc m n p) ⟩\n suc (m + (n + p))\n ≡⟨⟩\n suc m + (n + p)\n ∎\n\n+-identityʳ : ∀ (m : ℕ) → m + zero ≡ m\n+-identityʳ zero =\n begin\n zero + zero\n ≡⟨⟩\n zero\n ∎\n+-identityʳ (suc m) =\n begin\n suc m + zero\n ≡⟨⟩\n suc (m + zero)\n ≡⟨ cong suc (+-identityʳ m) ⟩\n suc m\n ∎\n\n+-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n)\n+-suc zero n =\n begin\n zero + suc n\n ≡⟨⟩\n suc n\n ≡⟨⟩\n suc (zero + n)\n ∎\n+-suc (suc m) n =\n begin\n suc m + suc n\n ≡⟨⟩\n suc (m + suc n)\n ≡⟨ cong suc (+-suc m n) ⟩\n suc (suc (m + n))\n ≡⟨⟩\n suc (suc m + n)\n ∎\n\n+-comm : ∀ (m n : ℕ) → m + n ≡ n + m\n+-comm m zero =\n begin\n m + zero\n ≡⟨ +-identityʳ m ⟩\n m\n ≡⟨⟩\n zero + m\n ∎\n+-comm m (suc n) =\n begin\n m + suc n\n ≡⟨ +-suc m n ⟩\n suc (m + n)\n ≡⟨ cong suc (+-comm m n) ⟩\n suc (n + m)\n ≡⟨⟩\n suc n + m\n ∎\n\n+-swap : ∀ (m n p : ℕ) → m + (n + p) ≡ n + (m + p)\n+-swap m n p =\n begin\n m + (n + p)\n ≡⟨ sym (+-assoc m n p) ⟩\n (m + n) + p\n ≡⟨ cong (_+ p) (+-comm m n) ⟩\n (n + m) + p\n ≡⟨ +-assoc n m p ⟩\n n + (m + p)\n ∎\n\n-- +-swap : ∀ (m n p : ℕ) → m + (n + p) ≡ n + (m + p)\n-- +-swap m n p rewrite sym (+-assoc m n p)\n-- | cong (_+ p) (+-comm m n)\n-- | +-assoc n m p\n-- = refl\n\n-- 3)\n*-distrib-+ : ∀ (m n p : ℕ) → (m + n) * p ≡ m * p + n * p\n*-distrib-+ zero n p =\n begin\n (zero + n) * p\n ≡⟨⟩\n n * p\n ≡⟨⟩\n zero * p + n * p\n ∎\n*-distrib-+ (suc m) n p =\n begin\n ((suc m) + n) * p\n ≡⟨⟩\n suc (m + n) * p\n ≡⟨⟩\n p + ((m + n) * p)\n ≡⟨ cong (p +_) (*-distrib-+ m n p) ⟩\n p + (m * p + n * p)\n ≡⟨ sym (+-assoc p (m * p) (n * p))⟩\n (p + m * p) + n * p\n ≡⟨⟩\n (suc m) * p + n * p\n ∎\n\n-- 4)\n*-assoc : ∀ (m n p : ℕ) → (m * n) * p ≡ m * (n * p)\n*-assoc zero n p =\n begin\n (zero * n) * p\n ≡⟨⟩\n zero * p\n ≡⟨⟩\n zero\n ≡⟨⟩\n zero * n\n ≡⟨⟩\n zero * (n * p)\n ∎\n*-assoc (suc m) n p =\n begin\n (suc m * n) * p\n ≡⟨⟩\n (n + m * n) * p\n ≡⟨ *-distrib-+ n (m * n) p ⟩\n (n * p) + (m * n) * p\n ≡⟨ cong ((n * p) +_) (*-assoc m n p) ⟩\n (n * p) + m * (n * p)\n ≡⟨⟩\n suc m * (n * p)\n ∎\n\n-- 5)\n*-absorbingʳ : ∀ (m : ℕ) → m * zero ≡ zero\n*-absorbingʳ zero =\n begin\n zero * zero\n ≡⟨⟩\n zero\n ∎\n*-absorbingʳ (suc m) =\n begin\n suc m * zero\n ≡⟨⟩\n zero + m * zero\n ≡⟨ cong (zero +_) (*-absorbingʳ m) ⟩\n zero + zero\n ≡⟨⟩\n zero\n ∎\n\n*-suc : ∀ (m n : ℕ) → m * suc n ≡ m + m * n\n*-suc zero n =\n begin\n zero * (suc n)\n ≡⟨⟩\n zero\n ≡⟨⟩\n zero * n\n ≡⟨⟩\n zero + zero * n\n ∎\n*-suc (suc m) n =\n begin\n suc m * suc n\n ≡⟨⟩\n (suc n) + (m * suc n)\n ≡⟨ cong ((suc n) +_) (*-suc m n) ⟩\n (suc n) + (m + m * n)\n ≡⟨⟩\n suc (n + (m + m * n))\n ≡⟨ cong suc (sym (+-assoc n m (m * n))) ⟩\n suc ((n + m) + m * n)\n ≡⟨ cong (λ {term → suc (term + m * n)}) (+-comm n m) ⟩\n suc ((m + n) + m * n)\n ≡⟨ cong suc (+-assoc m n (m * n)) ⟩\n suc (m + (n + m * n))\n ≡⟨⟩\n suc (m + (suc m * n))\n ≡⟨⟩\n suc m + suc m * n\n ∎\n\n*-comm : ∀ (m n : ℕ) → m * n ≡ n * m\n*-comm m zero =\n begin\n m * zero\n ≡⟨ *-absorbingʳ m ⟩\n zero\n ≡⟨⟩\n zero * m\n ∎\n*-comm m (suc n) =\n begin\n m * suc n\n ≡⟨ *-suc m n ⟩\n m + m * n\n ≡⟨ cong (m +_) (*-comm m n) ⟩\n m + n * m\n ≡⟨⟩\n suc n * m\n ∎\n\n-- 6)\n0∸n≡0 : ∀ (n : ℕ) → zero ∸ n ≡ zero\n0∸n≡0 zero =\n begin\n zero ∸ zero\n ≡⟨⟩\n zero\n ∎\n0∸n≡0 (suc n) =\n begin\n zero ∸ suc n\n ≡⟨⟩\n zero\n ∎\n-- No induction needed, just prove it holds for 0 and for suc n. (Holds because of definition of ∸)\n\n-- 7)\n0∸n≡0∸n+p : ∀ (n p : ℕ) → zero ∸ n ≡ zero ∸ (n + p)\n0∸n≡0∸n+p n zero =\n begin\n zero ∸ n\n ≡⟨ cong (zero ∸_) (sym (+-identityʳ n)) ⟩\n zero ∸ (n + zero)\n ∎\n0∸n≡0∸n+p n (suc p) =\n begin\n zero ∸ n\n ≡⟨ 0∸n≡0 n ⟩\n zero\n ≡⟨⟩\n zero ∸ suc (n + p)\n ≡⟨ cong (zero ∸_) (sym (+-suc n p)) ⟩\n zero ∸ (n + suc p)\n ∎\n\n∸-+-assoc : ∀ (m n p : ℕ) → (m ∸ n) ∸ p ≡ m ∸ (n + p)\n∸-+-assoc zero n p =\n begin\n (zero ∸ n) ∸ p\n ≡⟨ cong (_∸ p) (0∸n≡0 n) ⟩\n zero ∸ p\n ≡⟨ 0∸n≡0 p ⟩\n zero\n ≡⟨ sym (0∸n≡0 n) ⟩\n zero ∸ n\n ≡⟨ 0∸n≡0∸n+p n p ⟩\n zero ∸ (n + p)\n ∎\n∸-+-assoc (suc m) zero p =\n begin\n (suc m ∸ zero) ∸ p\n ≡⟨⟩\n suc m ∸ (zero + p)\n ∎\n∸-+-assoc (suc m) (suc n) p =\n begin\n (suc m ∸ suc n) ∸ p\n ≡⟨⟩\n (m ∸ n) ∸ p\n ≡⟨ ∸-+-assoc m n p ⟩\n m ∸ (n + p)\n ≡⟨⟩\n suc m ∸ suc (n + p)\n ≡⟨⟩\n suc m ∸ (suc n + p)\n ∎\n\n-- 8)\n*-identityˡ : ∀ (n : ℕ) → 1 * n ≡ n\n*-identityˡ n =\n begin\n 1 * n\n ≡⟨⟩\n (suc zero) * n\n ≡⟨⟩\n n + (zero * n)\n ≡⟨⟩\n n + zero\n ≡⟨ +-identityʳ n ⟩\n n\n ∎\n\n^-distribˡ-+-* : ∀ (m n p : ℕ) → m ^ (n + p) ≡ (m ^ n) * (m ^ p)\n^-distribˡ-+-* m zero p =\n begin\n m ^ (zero + p)\n ≡⟨⟩\n m ^ p\n ≡⟨ sym (*-identityˡ (m ^ p)) ⟩\n 1 * m ^ p\n ≡⟨⟩\n (m ^ zero) * (m ^ p)\n ∎\n^-distribˡ-+-* m (suc n) p =\n begin\n m ^ (suc n + p)\n ≡⟨⟩\n m ^ suc (n + p)\n ≡⟨⟩\n m * (m ^ (n + p))\n ≡⟨ cong (m *_) (^-distribˡ-+-* m n p) ⟩\n m * (m ^ n * m ^ p)\n ≡⟨ sym (*-assoc m (m ^ n) (m ^ p)) ⟩\n (m * m ^ n) * m ^ p\n ≡⟨⟩\n (m ^ suc n) * (m ^ p)\n ∎\n\n\n^-distribʳ-* : ∀ (m n p : ℕ) → (m * n) ^ p ≡ (m ^ p) * (n ^ p)\n^-distribʳ-* m n zero =\n begin\n (m * n) ^ zero\n ≡⟨⟩\n 1\n ≡⟨⟩\n 1 * 1\n ≡⟨⟩\n (m ^ zero) * (n ^ zero)\n ∎\n^-distribʳ-* m n (suc p) =\n begin\n (m * n) ^ (suc p)\n ≡⟨⟩\n (m * n) * (m * n) ^ p\n ≡⟨ cong ((m * n) *_) (^-distribʳ-* m n p) ⟩\n (m * n) * ((m ^ p) * (n ^ p))\n ≡⟨ sym (*-assoc (m * n) (m ^ p) (n ^ p)) ⟩\n ((m * n) * (m ^ p)) * (n ^ p)\n ≡⟨ cong (_* (n ^ p)) (*-assoc m n (m ^ p)) ⟩\n (m * (n * (m ^ p))) * (n ^ p)\n ≡⟨ cong (λ {term → (m * term) * (n ^ p)}) (*-comm n (m ^ p)) ⟩\n (m * ((m ^ p) * n)) * (n ^ p)\n ≡⟨ cong (_* (n ^ p)) (sym (*-assoc m (m ^ p) n)) ⟩\n (m * (m ^ p) * n) * (n ^ p)\n ≡⟨ *-assoc (m * (m ^ p)) n (n ^ p) ⟩\n m * (m ^ p) * (n * (n ^ p))\n ≡⟨⟩\n (m ^ suc p) * (n ^ suc p)\n ∎\n\n^-*-assoc : ∀ (m n p : ℕ) → (m ^ n) ^ p ≡ m ^ (n * p)\n^-*-assoc m n zero =\n begin\n (m ^ n) ^ zero\n ≡⟨⟩\n 1\n ≡⟨⟩\n m ^ zero\n ≡⟨ cong (m ^_) (sym (*-absorbingʳ n)) ⟩\n m ^ (n * zero)\n ∎\n^-*-assoc m n (suc p) =\n begin\n (m ^ n) ^ suc p\n ≡⟨⟩\n (m ^ n) * (m ^ n) ^ p\n ≡⟨ cong ((m ^ n) *_) (^-*-assoc m n p) ⟩\n (m ^ n) * (m ^ (n * p))\n ≡⟨ cong (λ {term → (m ^ n) * (m ^ term)}) (*-comm n p) ⟩\n (m ^ n) * (m ^ (p * n))\n ≡⟨ sym (^-distribˡ-+-* m n (p * n)) ⟩\n m ^ (n + p * n)\n ≡⟨⟩\n m ^ (suc p * n)\n ≡⟨ cong (m ^_) (*-comm (suc p) n) ⟩\n m ^ (n * suc p)\n ∎\n\n-- 9)\ndata Bin : Set where\n - : Bin\n _O : Bin → Bin\n _I : Bin → Bin\n\ninc : Bin → Bin\ninc - = - I\ninc (rest O) = rest I\ninc (rest I) = (inc rest) O\n\nto : ℕ → Bin\nto zero = - O\nto (suc n) = inc (to n)\n\nfrom : Bin → ℕ\nfrom - = 0\nfrom (rest O) = 2 * from rest\nfrom (rest I) = 2 * from rest + 1\n\nbin-inverse-suc-inc : ∀ (b : Bin) → from (inc b) ≡ suc (from b)\nbin-inverse-suc-inc - =\n begin\n from (inc -)\n ≡⟨⟩\n from (- I)\n ≡⟨⟩\n 2 * from - + 1\n ≡⟨⟩\n 2 * 0 + 1\n ≡⟨⟩\n 0 + 1\n ≡⟨⟩\n 1\n ≡⟨⟩\n suc 0\n ≡⟨⟩\n suc (from -)\n ∎\nbin-inverse-suc-inc (b O) =\n begin\n from (inc (b O))\n ≡⟨⟩\n from (b I)\n ≡⟨⟩\n 2 * from b + 1\n ≡⟨ +-comm (2 * from b) 1 ⟩\n suc (2 * from b)\n ≡⟨⟩\n suc (from (b O))\n ∎\nbin-inverse-suc-inc (b I) =\n begin\n from (inc (b I))\n ≡⟨⟩\n from ((inc b) O)\n ≡⟨⟩\n 2 * from (inc b)\n ≡⟨ cong (2 *_) (bin-inverse-suc-inc b) ⟩\n 2 * suc (from b)\n ≡⟨ *-comm 2 (suc (from b)) ⟩\n suc (from b) * 2\n ≡⟨⟩\n (1 + from b) * 2\n ≡⟨ *-distrib-+ 1 (from b) 2 ⟩\n 1 * 2 + from b * 2\n ≡⟨ cong (1 * 2 +_) (*-comm (from b) 2) ⟩\n 1 * 2 + 2 * from b\n ≡⟨⟩\n 2 + 2 * from b\n ≡⟨⟩\n suc 1 + 2 * from b\n ≡⟨⟩\n suc (1 + 2 * from b)\n ≡⟨ cong (suc) (+-comm 1 (2 * from b)) ⟩\n suc (2 * from b + 1)\n ≡⟨⟩\n suc (from (b I))\n ∎\n\n-- ∀ (b : Bin) → to (from b) ≡ b\n-- This does not work, as \"from\" is a surjective function. Both \"-\" and \"- O\" from Bin map into 0 from ℕ. Surjective functions have no left inverse.\n-- 0 would have to map into two values, making the inverse of \"from\" not a function.\n\n-- This works, as \"to\" is an injective function. 0 from ℕ maps (according to our definition) into \"- O\" in Bin. Injective functions have a left inverse.\n-- \"from\" is a left inverse to \"to\". Note that there are infinitely many left inverses, since \"-\" could be mapped to any value in ℕ.\nfrom∘to≡idₗ : ∀ (n : ℕ) → from (to n) ≡ n\nfrom∘to≡idₗ zero =\n begin\n from (to zero)\n ≡⟨⟩\n from (- O)\n ≡⟨⟩\n 2 * from -\n ≡⟨⟩\n 2 * 0\n ≡⟨⟩\n zero\n ∎\nfrom∘to≡idₗ (suc n) =\n begin\n from (to (suc n))\n ≡⟨⟩\n from (inc (to n))\n ≡⟨ bin-inverse-suc-inc (to n) ⟩\n suc (from (to n))\n ≡⟨ cong suc (from∘to≡idₗ n) ⟩\n suc n\n ∎\n", "meta": {"hexsha": "7300e638625217f9bbee465ffc9dff0a2751f4e3", "size": 10476, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "plfa/induction.agda", "max_stars_repo_name": "aronerben/agda-playground", "max_stars_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "plfa/induction.agda", "max_issues_repo_name": "aronerben/agda-playground", "max_issues_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "plfa/induction.agda", "max_forks_repo_name": "aronerben/agda-playground", "max_forks_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.6179775281, "max_line_length": 414, "alphanum_fraction": 0.3785796105, "num_tokens": 5575, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513814471134, "lm_q2_score": 0.7248702880639791, "lm_q1q2_score": 0.6496659970473083}} {"text": "open import Data.Product using ( ∃ ; _×_ )\nopen import FRP.LTL.RSet.Core using ( RSet )\nopen import FRP.LTL.Time using ( _≤_ )\n\nmodule FRP.LTL.RSet.Future where\n\n◇ : RSet → RSet\n◇ A t = ∃ λ u → (t ≤ u) × A u\n\n", "meta": {"hexsha": "8473aa19cc82c29297a60dde2f640dc90d5bcb5e", "size": 209, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/FRP/LTL/RSet/Future.agda", "max_stars_repo_name": "agda/agda-frp-ltl", "max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 21, "max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z", "max_issues_repo_path": "src/FRP/LTL/RSet/Future.agda", "max_issues_repo_name": "agda/agda-frp-ltl", "max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z", "max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z", "max_forks_repo_path": "src/FRP/LTL/RSet/Future.agda", "max_forks_repo_name": "agda/agda-frp-ltl", "max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z", "avg_line_length": 20.9, "max_line_length": 44, "alphanum_fraction": 0.6267942584, "num_tokens": 79, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8962513620489618, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.6496659776592255}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Groups.Definition\nopen import Groups.Abelian.Definition\nopen import Groups.FiniteGroups.Definition\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import Numbers.Naturals.Order.Lemmas\nopen import Setoids.Setoids\nopen import Sets.FinSet.Definition\nopen import Sets.FinSet.Lemmas\nopen import Functions\nopen import Semirings.Definition\nopen import Numbers.Modulo.Definition\nopen import Numbers.Modulo.Addition\nopen import Orders.Total.Definition\nopen import Numbers.Modulo.ModuloFunction\nopen import Numbers.Integers.Definition\nopen import Numbers.Modulo.Group\nopen import Modules.Definition\nopen import Numbers.Integers.RingStructure.Ring\n\nmodule Numbers.Modulo.ZModule {n : ℕ} (pr : 0 _ _ _\n _≤_ = compare\n\n \n data Color : Set where\n R B : Color\n \n _=ᶜ_ : Color → Color → Bool\n R =ᶜ R = true\n B =ᶜ B = true\n _ =ᶜ _ = false\n\n Height = ℕ\n\n data Tree : Set a where\n E : Tree\n T : Color → Tree → A → Tree → Tree\n\n \n set = Tree\n\n empty : set\n empty = E\n\n member : A → set → Bool\n member x E = false\n member x (T _ a y b) with x ≤ y\n ... | LT = member x a\n ... | EQ = true\n ... | GT = member x b\n\n insert : A → set → set\n insert x s = makeBlack (ins s)\n where \n balance : Color → set → A → set → set\n balance B (T R (T R a x b) y c) z d = T R (T B a x b) y (T B c z d)\n balance B (T R a x (T R b y c)) z d = T R (T B a x b) y (T B c z d)\n balance B a x (T R (T R b y c) z d) = T R (T B a x b) y (T B c z d)\n balance B a x (T R b y (T R c z d)) = T R (T B a x b) y (T B c z d)\n balance color a x b = T color a x b\n\n ins : set → set\n ins E = T R E x E\n ins (T color a y b) with x ≤ y\n ... | LT = balance color (ins a) y b\n ... | EQ = T color a y b\n ... | GT = balance color a y (ins b)\n\n makeBlack : set → set\n makeBlack E = E\n makeBlack (T _ a y b) = T B a y b\n", "meta": {"hexsha": "26621045dea82ff3322b71b93632bc450913ead1", "size": 1601, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Okasaki.agda", "max_stars_repo_name": "toonn/sciartt", "max_stars_repo_head_hexsha": "72e0989445760f63b9422ce5e0f8956d7f58d578", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Okasaki.agda", "max_issues_repo_name": "toonn/sciartt", "max_issues_repo_head_hexsha": "72e0989445760f63b9422ce5e0f8956d7f58d578", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Okasaki.agda", "max_forks_repo_name": "toonn/sciartt", "max_forks_repo_head_hexsha": "72e0989445760f63b9422ce5e0f8956d7f58d578", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.5441176471, "max_line_length": 76, "alphanum_fraction": 0.5334166146, "num_tokens": 593, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.874077222043951, "lm_q2_score": 0.7431680086124812, "lm_q1q2_score": 0.6495862284799326}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Category.Species where\n\n-- The Category of Species, as the Functor category from Core (FinSetoids) to Setoids.\n-- Setoids used here because that's what fits best in this setting.\n-- The constructions of the theory of Species are in Species.Construction\n\nopen import Level\n\nopen import Categories.Category.Core using (Category)\nopen import Categories.Category.Construction.Functors\nopen import Categories.Category.Construction.Core using (Core)\nopen import Categories.Category.Instance.FinSetoids using (FinSetoids)\nopen import Categories.Category.Instance.Setoids using (Setoids)\n\nprivate\n variable\n o ℓ o′ ℓ′ : Level\n\n-- note how Species, as a category, raises levels.\nSpecies : (o ℓ o′ ℓ′ : Level) → Category (suc (o ⊔ ℓ ⊔ o′ ⊔ ℓ′)) (suc (o ⊔ ℓ) ⊔ (o′ ⊔ ℓ′)) (suc (o ⊔ ℓ) ⊔ o′ ⊔ ℓ′)\nSpecies o ℓ o′ ℓ′ = Functors (Core (FinSetoids o ℓ)) (Setoids o′ ℓ′)\n", "meta": {"hexsha": "d5a5b9b937762e76ec66c6987fc11b5723dafcbc", "size": 911, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Species.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/Species.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/Species.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 39.6086956522, "max_line_length": 114, "alphanum_fraction": 0.7255762898, "num_tokens": 262, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9161096135894201, "lm_q2_score": 0.7090191276365463, "lm_q1q2_score": 0.6495392390466241}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary using (Rel)\n\nopen import Algebra.Structures.Bundles.Field\n\nmodule Algebra.Linear.Morphism.Definitions\n {k ℓᵏ} (K : Field k ℓᵏ)\n {a} (A : Set a)\n {b} (B : Set b)\n {ℓ} (_≈_ : Rel B ℓ)\n where\n\nopen import Algebra.Linear.Core\nopen import Function\n\nimport Algebra.Morphism as Morphism\nopen Morphism.Definitions A B _≈_\n\nprivate\n K' : Set k\n K' = Field.Carrier K\n\nLinear : Morphism\n -> VectorAddition A -> ScalarMultiplication K' A\n -> VectorAddition B -> ScalarMultiplication K' B\n -> Set _\nLinear ⟦_⟧ _+₁_ _∙₁_ _+₂_ _∙₂_ =\n ∀ (a b : K') (u v : A) ->\n ⟦ (a ∙₁ u) +₁ (b ∙₁ v) ⟧ ≈ ((a ∙₂ ⟦ u ⟧) +₂ (b ∙₂ ⟦ v ⟧))\n\nScalarHomomorphism : Morphism\n -> ScalarMultiplication K' A\n -> ScalarMultiplication K' B\n -> Set _\nScalarHomomorphism ⟦_⟧ _∙_ _∘_ = ∀ (c : K') (u : A) -> ⟦ c ∙ u ⟧ ≈ (c ∘ ⟦ u ⟧)\n", "meta": {"hexsha": "fba40f9a8266e2e0089b07b0e1534ba4d92a718c", "size": 932, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Algebra/Linear/Morphism/Definitions.agda", "max_stars_repo_name": "felko/linear-algebra", "max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z", "max_issues_repo_path": "src/Algebra/Linear/Morphism/Definitions.agda", "max_issues_repo_name": "felko/linear-algebra", "max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Algebra/Linear/Morphism/Definitions.agda", "max_forks_repo_name": "felko/linear-algebra", "max_forks_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.1891891892, "max_line_length": 78, "alphanum_fraction": 0.5686695279, "num_tokens": 344, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9161096044278532, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.6495392325508978}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Groups.Definition\nopen import Numbers.Naturals.Definition\nopen import Setoids.Setoids\nopen import Sets.EquivalenceRelations\nopen import Lists.Lists\nopen import Maybe\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\n\nmodule Groups.Polynomials.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} (G : Group S _+_) where\n\nopen Setoid S\nopen Equivalence eq\nopen Group G\n\nNaivePoly : Set a\nNaivePoly = List A\n\n0P : NaivePoly\n0P = []\n\npolysEqual : NaivePoly → NaivePoly → Set (a ⊔ b)\npolysEqual [] [] = True'\npolysEqual [] (x :: b) = (x ∼ 0G) && polysEqual [] b\npolysEqual (x :: a) [] = (x ∼ 0G) && polysEqual a []\npolysEqual (x :: a) (y :: b) = (x ∼ y) && polysEqual a b\n\npolysReflexive : {x : NaivePoly} → polysEqual x x\npolysReflexive {[]} = record {}\npolysReflexive {x :: y} = reflexive ,, polysReflexive\n\npolysSymmetricZero : {x : NaivePoly} → polysEqual [] x → polysEqual x []\npolysSymmetricZero {[]} 0=x = record {}\npolysSymmetricZero {x :: y} (fst ,, snd) = fst ,, polysSymmetricZero snd\n\npolysSymmetricZero' : {x : NaivePoly} → polysEqual x [] → polysEqual [] x\npolysSymmetricZero' {[]} 0=x = record {}\npolysSymmetricZero' {x :: y} (fst ,, snd) = fst ,, polysSymmetricZero' snd\n\npolysSymmetric : {x y : NaivePoly} → polysEqual x y → polysEqual y x\npolysSymmetric {[]} {y} x=y = polysSymmetricZero x=y\npolysSymmetric {x :: xs} {[]} x=y = polysSymmetricZero' {x :: xs} x=y\npolysSymmetric {x :: xs} {y :: ys} (fst ,, snd) = symmetric fst ,, polysSymmetric {xs} {ys} snd\n\npolysTransitive : {x y z : NaivePoly} → polysEqual x y → polysEqual y z → polysEqual x z\npolysTransitive {[]} {[]} {[]} x=y y=z = record {}\npolysTransitive {[]} {[]} {x :: z} x=y y=z = y=z\npolysTransitive {[]} {x :: y} {[]} (fst ,, snd) y=z = record {}\npolysTransitive {[]} {x :: y} {x₁ :: z} (fst ,, snd) (fst2 ,, snd2) = transitive (symmetric fst2) fst ,, polysTransitive snd snd2\npolysTransitive {x :: xs} {[]} {[]} x=y y=z = x=y\npolysTransitive {x :: xs} {[]} {z :: zs} (fst ,, snd) (fst2 ,, snd2) = transitive fst (symmetric fst2) ,, polysTransitive snd snd2\npolysTransitive {x :: xs} {y :: ys} {[]} (fst ,, snd) (fst2 ,, snd2) = transitive fst fst2 ,, polysTransitive snd snd2\npolysTransitive {x :: xs} {y :: ys} {z :: zs} (fst ,, snd) (fst2 ,, snd2) = transitive fst fst2 ,, polysTransitive snd snd2\n\nnaivePolySetoid : Setoid NaivePoly\nSetoid._∼_ naivePolySetoid = polysEqual\nEquivalence.reflexive (Setoid.eq naivePolySetoid) = polysReflexive\nEquivalence.symmetric (Setoid.eq naivePolySetoid) = polysSymmetric\nEquivalence.transitive (Setoid.eq naivePolySetoid) = polysTransitive\n\npolyInjection : A → NaivePoly\npolyInjection a = a :: []\n\npolyInjectionIsInj : SetoidInjection S naivePolySetoid polyInjection\nSetoidInjection.wellDefined polyInjectionIsInj x=y = x=y ,, record {}\nSetoidInjection.injective polyInjectionIsInj {x} {y} (fst ,, snd) = fst\n\n-- the zero polynomial has no degree\n-- all other polynomials have a degree\n\ndegree : ((x : A) → (x ∼ 0G) || ((x ∼ 0G) → False)) → NaivePoly → Maybe ℕ\ndegree decide [] = no\ndegree decide (x :: poly) with decide x\ndegree decide (x :: poly) | inl x=0 with degree decide poly\ndegree decide (x :: poly) | inl x=0 | no = no\ndegree decide (x :: poly) | inl x=0 | yes deg = yes (succ deg)\ndegree decide (x :: poly) | inr x!=0 with degree decide poly\ndegree decide (x :: poly) | inr x!=0 | no = yes 0\ndegree decide (x :: poly) | inr x!=0 | yes n = yes (succ n)\n\ndegreeWellDefined : (decide : ((x : A) → (x ∼ 0G) || ((x ∼ 0G) → False))) {x y : NaivePoly} → polysEqual x y → degree decide x ≡ degree decide y\ndegreeWellDefined decide {[]} {[]} x=y = refl\ndegreeWellDefined decide {[]} {x :: y} (fst ,, snd) with decide x\ndegreeWellDefined decide {[]} {x :: y} (fst ,, snd) | inl x=0 with inspect (degree decide y)\ndegreeWellDefined decide {[]} {x :: y} (fst ,, snd) | inl x=0 | no with≡ pr rewrite pr = refl\ndegreeWellDefined decide {[]} {x :: y} (fst ,, snd) | inl x=0 | yes bad with≡ pr rewrite pr = exFalso (noNotYes (transitivity (degreeWellDefined decide {[]} {y} snd) pr))\ndegreeWellDefined decide {[]} {x :: y} (fst ,, snd) | inr x!=0 with inspect (degree decide y)\ndegreeWellDefined decide {[]} {x :: y} (fst ,, snd) | inr x!=0 | no with≡ pr rewrite pr = exFalso (x!=0 fst)\ndegreeWellDefined decide {[]} {x :: y} (fst ,, snd) | inr x!=0 | yes deg with≡ pr rewrite pr = exFalso (x!=0 fst)\ndegreeWellDefined decide {x :: xs} {[]} x=y with decide x\ndegreeWellDefined decide {x :: xs} {[]} (fst ,, snd) | inl x=0 with inspect (degree decide xs)\ndegreeWellDefined decide {x :: xs} {[]} (fst ,, snd) | inl x=0 | no with≡ pr rewrite pr = refl\ndegreeWellDefined decide {x :: xs} {[]} (fst ,, snd) | inl x=0 | yes bad with≡ pr rewrite pr = exFalso (noNotYes (transitivity (equalityCommutative (degreeWellDefined decide snd)) pr))\ndegreeWellDefined decide {x :: xs} {[]} (fst ,, snd) | inr x!=0 = exFalso (x!=0 fst)\ndegreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) with decide x\ndegreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inl x=0 with decide y\ndegreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inl x=0 | inl y=0 with inspect (degree decide ys)\ndegreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inl x=0 | inl y=0 | no with≡ pr rewrite degreeWellDefined decide {xs} {ys} snd | pr = refl\ndegreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inl x=0 | inl y=0 | (yes th) with≡ pr rewrite degreeWellDefined decide {xs} {ys} snd | pr = refl\ndegreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inl x=0 | inr y!=0 = exFalso (y!=0 (transitive (symmetric fst) x=0))\ndegreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inr x!=0 with decide y\ndegreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inr x!=0 | inl y=0 = exFalso (x!=0 (transitive fst y=0))\ndegreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inr x!=0 | inr y!=0 with inspect (degree decide ys)\ndegreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inr x!=0 | inr y!=0 | no with≡ pr rewrite degreeWellDefined decide {xs} {ys} snd | pr = refl\ndegreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inr x!=0 | inr y!=0 | yes x₁ with≡ pr rewrite degreeWellDefined decide {xs} {ys} snd | pr = refl\n\ndegreeNoImpliesZero : (decide : ((x : A) → (x ∼ 0G) || ((x ∼ 0G) → False))) → (a : NaivePoly) → degree decide a ≡ no → polysEqual a []\ndegreeNoImpliesZero decide [] not = record {}\ndegreeNoImpliesZero decide (x :: a) not with decide x\ndegreeNoImpliesZero decide (x :: a) not | inl x=0 with inspect (degree decide a)\ndegreeNoImpliesZero decide (x :: a) not | inl x=0 | no with≡ pr rewrite pr = x=0 ,, degreeNoImpliesZero decide a pr\ndegreeNoImpliesZero decide (x :: a) not | inl x=0 | (yes deg) with≡ pr rewrite pr = exFalso (noNotYes (equalityCommutative not))\ndegreeNoImpliesZero decide (x :: a) not | inr x!=0 with degree decide a\ndegreeNoImpliesZero decide (x :: a) () | inr x!=0 | no\ndegreeNoImpliesZero decide (x :: a) () | inr x!=0 | yes x₁\n\nemptyImpliesDegreeZero : (decide : ((x : A) → (x ∼ 0G) || ((x ∼ 0G) → False))) → (a : NaivePoly) → polysEqual a [] → degree decide a ≡ no\nemptyImpliesDegreeZero decide [] a=[] = refl\nemptyImpliesDegreeZero decide (x :: a) (fst ,, snd) with decide x\nemptyImpliesDegreeZero decide (x :: a) (fst ,, snd) | inl x=0 with inspect (degree decide a)\nemptyImpliesDegreeZero decide (x :: a) (fst ,, snd) | inl x=0 | no with≡ pr rewrite pr = refl\nemptyImpliesDegreeZero decide (x :: a) (fst ,, snd) | inl x=0 | (yes deg) with≡ pr rewrite pr = exFalso (noNotYes (transitivity (equalityCommutative (emptyImpliesDegreeZero decide a snd)) pr))\nemptyImpliesDegreeZero decide (x :: a) (fst ,, snd) | inr x!=0 = exFalso (x!=0 fst)\n", "meta": {"hexsha": "64fc0346848ac7979cd485df25e42c8ff357319f", "size": 7741, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Groups/Polynomials/Definition.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Groups/Polynomials/Definition.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Groups/Polynomials/Definition.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 60.9527559055, "max_line_length": 192, "alphanum_fraction": 0.6539206821, "num_tokens": 2648, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127492339909, "lm_q2_score": 0.7606506526772884, "lm_q1q2_score": 0.6495292900342928}} {"text": "{-\nThis second-order equational theory was created from the following second-order syntax description:\n\nsyntax Group | G\n\ntype\n * : 0-ary\n\nterm\n unit : * | ε\n add : * * -> * | _⊕_ l20\n neg : * -> * | ⊖_ r40\n\ntheory\n (εU⊕ᴸ) a |> add (unit, a) = a\n (εU⊕ᴿ) a |> add (a, unit) = a\n (⊕A) a b c |> add (add(a, b), c) = add (a, add(b, c))\n (⊖N⊕ᴸ) a |> add (neg (a), a) = unit\n (⊖N⊕ᴿ) a |> add (a, neg (a)) = unit\n-}\n\nmodule Group.Equality where\n\nopen import SOAS.Common\nopen import SOAS.Context\nopen import SOAS.Variable\nopen import SOAS.Families.Core\nopen import SOAS.Families.Build\nopen import SOAS.ContextMaps.Inductive\n\nopen import Group.Signature\nopen import Group.Syntax\n\nopen import SOAS.Metatheory.SecondOrder.Metasubstitution G:Syn\nopen import SOAS.Metatheory.SecondOrder.Equality G:Syn\n\nprivate\n variable\n α β γ τ : *T\n Γ Δ Π : Ctx\n\ninfix 1 _▹_⊢_≋ₐ_\n\n-- Axioms of equality\ndata _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ G) α Γ → (𝔐 ▷ G) α Γ → Set where\n εU⊕ᴸ : ⁅ * ⁆̣ ▹ ∅ ⊢ ε ⊕ 𝔞 ≋ₐ 𝔞\n εU⊕ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ⊕ ε ≋ₐ 𝔞\n ⊕A : ⁅ * ⁆ ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (𝔞 ⊕ 𝔟) ⊕ 𝔠 ≋ₐ 𝔞 ⊕ (𝔟 ⊕ 𝔠)\n ⊖N⊕ᴸ : ⁅ * ⁆̣ ▹ ∅ ⊢ (⊖ 𝔞) ⊕ 𝔞 ≋ₐ ε\n ⊖N⊕ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ⊕ (⊖ 𝔞) ≋ₐ ε\n\nopen EqLogic _▹_⊢_≋ₐ_\nopen ≋-Reasoning\n", "meta": {"hexsha": "57086400ce456eb25f6753b1323c0ed712a458bd", "size": 1270, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "out/Group/Equality.agda", "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_issues_repo_path": "out/Group/Equality.agda", "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_forks_repo_path": "out/Group/Equality.agda", "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "avg_line_length": 23.5185185185, "max_line_length": 99, "alphanum_fraction": 0.5338582677, "num_tokens": 653, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8807970811069351, "lm_q2_score": 0.7371581626286834, "lm_q1q2_score": 0.6492867579574957}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nmodule Cubical.HITs.MappingCones.Properties where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.Isomorphism\n\nopen import Cubical.Data.Unit\nopen import Cubical.Data.Sum\nopen import Cubical.HITs.Pushout\n\nopen import Cubical.HITs.MappingCones.Base\n\nprivate\n variable\n ℓ ℓ' ℓ'' : Level\n\nPushoutUnit-iso-Cone : ∀ {X : Type ℓ} {Y : Type ℓ'} (f : X → Y) → Iso (Pushout (const tt) f) (Cone f)\nIso.fun (PushoutUnit-iso-Cone f) (inl tt) = hub\nIso.fun (PushoutUnit-iso-Cone f) (inr x) = inj x\nIso.fun (PushoutUnit-iso-Cone f) (push x i) = spoke x i\nIso.inv (PushoutUnit-iso-Cone f) (inj x) = inr x\nIso.inv (PushoutUnit-iso-Cone f) hub = inl tt\nIso.inv (PushoutUnit-iso-Cone f) (spoke x i) = push x i\nIso.rightInv (PushoutUnit-iso-Cone f) (inj x) = refl\nIso.rightInv (PushoutUnit-iso-Cone f) hub = refl\nIso.rightInv (PushoutUnit-iso-Cone f) (spoke x i) = refl\nIso.leftInv (PushoutUnit-iso-Cone f) (inl tt) = refl\nIso.leftInv (PushoutUnit-iso-Cone f) (inr x) = refl\nIso.leftInv (PushoutUnit-iso-Cone f) (push x i) = refl\n\nPushoutUnit≡Cone : ∀ {X : Type ℓ} {Y : Type ℓ'} (f : X → Y) → Pushout (const tt) f ≡ Cone f\nPushoutUnit≡Cone f = isoToPath (PushoutUnit-iso-Cone f)\n\nConesUnit-iso-Cone : ∀ {X : Type ℓ} {Y : Type ℓ'} (f : X → Y) → Iso (Cones Unit (λ { tt → f })) (Cone f)\nIso.fun (ConesUnit-iso-Cone f) (inj x) = inj x\nIso.fun (ConesUnit-iso-Cone f) (hub tt) = hub\nIso.fun (ConesUnit-iso-Cone f) (spoke tt x i) = spoke x i\nIso.inv (ConesUnit-iso-Cone f) (inj x) = inj x\nIso.inv (ConesUnit-iso-Cone f) hub = hub tt\nIso.inv (ConesUnit-iso-Cone f) (spoke x i) = spoke tt x i\nIso.rightInv (ConesUnit-iso-Cone f) (inj x) = refl\nIso.rightInv (ConesUnit-iso-Cone f) hub = refl\nIso.rightInv (ConesUnit-iso-Cone f) (spoke x i) = refl\nIso.leftInv (ConesUnit-iso-Cone f) (inj x) = refl\nIso.leftInv (ConesUnit-iso-Cone f) (hub x) = refl\nIso.leftInv (ConesUnit-iso-Cone f) (spoke a x i) = refl\n\nConesUnit≡Cone : ∀ {X : Type ℓ} {Y : Type ℓ'} (f : X → Y) → (Cones Unit (λ { tt → f })) ≡ (Cone f)\nConesUnit≡Cone f = isoToPath (ConesUnit-iso-Cone f)\n", "meta": {"hexsha": "4af0d01466e4690c5ba23edd5e399a3acca3ad93", "size": 2219, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/MappingCones/Properties.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/HITs/MappingCones/Properties.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/HITs/MappingCones/Properties.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "avg_line_length": 42.6730769231, "max_line_length": 104, "alphanum_fraction": 0.6620099144, "num_tokens": 852, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9032942041005327, "lm_q2_score": 0.7185943805178139, "lm_q1q2_score": 0.649102139020954}} {"text": "open import Agda.Primitive\nopen import Agda.Builtin.Equality renaming (_≡_ to _==_) --(( If I want to rename the built-in equality ))\n\nmodule AlgebraFormalization where\n\n -- Here is an attempt to translate (part of) the Coq formalization. I did not translate the definition of the free algebra, the proof, and the part concerning the groups yet. I hope I did not do too weird things with the levels.\n\n\n -- ** Formalization of single-sorted algebraic theories **\n\n -- Function extensionality\n postulate\n funext : ∀ {X : Set} {Y : X → Set} {f g : ∀ (x : X) → (Y x)} → (∀ (x : X) → ((f x) == (g x))) → (f == g)\n -- Operation Signature\n record OpSignature {l : Level} : Set (lsuc l) where\n field\n operation : Set l\n arity : operation → Set l\n -- I used the things with the levels of the hierachy of types because Agda was unhappy with what I was doing (and I did not want to define it only with Set₀ and Set₁ beacause I wanted to avoid weird things if we then want to define an OpSignature with an operation OpSignature)\n\n\n-- Here is a attempt (partial for the moment) to add context and terms, based on the same principles as in the file \"ManySortedAlgebra.agda\"\n -- Contexts\n record Context {l : Level} (Σ : OpSignature {l}) : Set (lsuc l) where\n field\n var : Set l\n\n open Context\n\n -- Terms on an operation signature\n data Term {l : Level} {Σ : OpSignature {l}} (Γ : Context Σ) : Set l where\n tm-var : ∀ (x : var Γ) → Term Γ\n tm-op : ∀ (f : OpSignature.operation Σ) → (OpSignature.arity Σ f → Term Γ) → Term Γ\n\n substitution : ∀ {l : Level} {Σ : OpSignature {l}} (Γ Δ : Context Σ) → Set l\n substitution Γ Δ = ∀ (x : var Γ) → Term Δ\n\n\n -- the action of a substitution on a term\n _·_ : ∀ {l : Level} {Σ : OpSignature {l}} {Γ Δ : Context Σ} → substitution Γ Δ → Term Γ → Term Δ\n σ · (tm-var x) = σ x\n σ · (tm-op f x) = tm-op f (λ i → σ · x i)\n\n infixr 6 _·_\n\n -- composition of substitutions\n _○_ : ∀ {l : Level} {Σ : OpSignature {l}} {Γ Δ Θ : Context Σ} → substitution Δ Θ → substitution Γ Δ → substitution Γ Θ\n (σ ○ τ) x = σ · τ x\n\n infixl 7 _○_\n\n-- End of the attempt\n\n\n\n\n\n\n -- Operation Algebra\n record OpAlgebra {l : Level} (S : OpSignature {l}) : Set (lsuc l) where\n field\n carrier : Set l\n op : ∀ (o : OpSignature.operation S) (f : OpSignature.arity S o → carrier) → carrier\n\n -- Homomorphisms\n record Hom {l : Level} {S : OpSignature {l}} (A : OpAlgebra {l} S) (B : OpAlgebra {l} S) : Set (lsuc l) where\n field\n map : (OpAlgebra.carrier A) → (OpAlgebra.carrier B)\n op-commute : ∀ (o : OpSignature.operation S) (args : OpSignature.arity S o → OpAlgebra.carrier A) → (map (OpAlgebra.op A o args) == OpAlgebra.op B o (λ x → map (args x) ))\n\n -- For the moment I skip the translation of the part concerning the free algebra\n\n\n\n\n\n\n\n-- Attempt to formalize the Equational theories diffenrently, based on what is done in the file \"ManySortedAglebra.agda\"\n\n -- Equational Theory (equations are seen as \"in a context\" and not with arities anymore)\n record EquationalTheory {l : Level} (Σ : OpSignature {l}) : Set (lsuc l) where\n field\n eq : Set l\n eq-ctx : ∀ (ε : eq) → Context {l} Σ\n eq-lhs : ∀ (ε : eq) → Term (eq-ctx ε)\n eq-rhs : ∀ (ε : eq) → Term (eq-ctx ε)\n\n open EquationalTheory\n\n -- Equality of terms\n infix 4 _≡_\n\n data _≡_ {l : Level} {Σ : OpSignature {l}} {T : EquationalTheory {l} Σ } : {Γ : Context Σ} → Term Γ → Term Γ → Set (lsuc l) where\n -- general rules\n eq-refl : ∀ {Γ} {t : Term Γ } → t ≡ t\n eq-symm : ∀ {Γ} {s t : Term {l} {Σ} Γ } → _≡_ {T = T} s t → t ≡ s\n eq-tran : ∀ {Γ} {s t u : Term Γ } → _≡_ {T = T} s t → _≡_ {T = T} t u → s ≡ u\n -- congruence rule\n eq-congr : ∀ {Γ} {f : OpSignature.operation Σ} (x y : ∀ (i : OpSignature.arity Σ f) → Term Γ) → (∀ i → _≡_ {_} {_} {T} (x i) (y i)) → ((tm-op f x) ≡ (tm-op f y))\n -- equational axiom\n eq-axiom : ∀ (ε : eq T) {Δ : Context {l} Σ} (σ : substitution (eq-ctx T ε) Δ) →\n ((σ · eq-lhs T ε) ≡ (σ · eq-rhs T ε))\n\n\n -- composition is functorial\n subst-○ : ∀ {l : Level} {Σ : OpSignature {l}} {T : EquationalTheory Σ} {Γ Δ Θ : Context Σ}\n (σ : substitution Δ Θ) (τ : substitution Γ Δ) →\n ∀ (t : Term Γ ) → _≡_ {T = T} (σ · τ · t) (σ ○ τ · t)\n subst-○ σ τ (tm-var x) = eq-refl\n subst-○ σ τ (tm-op f x) = eq-congr (λ i → σ · τ · x i) (λ i → σ ○ τ · x i) λ i → subst-○ σ τ (x i)\n\n -- substitution preserves equality\n eq-subst : ∀ {l : Level} {Σ : OpSignature {l}} {T : EquationalTheory Σ} {Γ Δ : Context Σ} (σ : substitution Γ Δ)\n {s t : Term Γ} → _≡_ {T = T} s t → _≡_ {T = T} (σ · s) (σ · t)\n eq-subst σ eq-refl = eq-refl\n eq-subst σ (eq-symm ξ) = eq-symm (eq-subst σ ξ)\n eq-subst σ (eq-tran ζ ξ) = eq-tran (eq-subst σ ζ) (eq-subst σ ξ)\n eq-subst σ (eq-congr x y ξ) = eq-congr (λ i → σ · x i) (λ i → σ · y i) λ i → eq-subst σ (ξ i)\n eq-subst {T = T} σ (eq-axiom ε τ) =\n eq-tran (subst-○ σ τ (eq-lhs T ε))\n (eq-tran (eq-axiom ε (σ ○ τ)) (eq-symm (subst-○ σ τ (eq-rhs T ε))))\n\n\n-- End of the attempt\n\n\n\n\n\n -- Equation Signature\n record EqSignature {l : Level} (S : OpSignature {l}) : Set (lsuc l) where\n field\n eq : Set l\n eq-arity : eq → Set l\n -- the two sides of the equation\n lhs : ∀ {A : OpAlgebra {l} S} {e : eq} → ((eq-arity e) → (OpAlgebra.carrier A)) → (OpAlgebra.carrier A)\n rhs : ∀ {A : OpAlgebra {l} S} {e : eq} → ((eq-arity e) → (OpAlgebra.carrier A)) → (OpAlgebra.carrier A)\n -- naturality / commutation\n lhs-natural : ∀ (A B : OpAlgebra {l} S) (f : Hom A B) (e : eq) (args : eq-arity e → OpAlgebra.carrier A) → ( (Hom.map f) (lhs {A} {e} args) == lhs {B} {e} (λ i → (Hom.map f) (args i)))\n rhs-natural : ∀ (A B : OpAlgebra {l} S) (f : Hom A B) (e : eq) (args : eq-arity e → OpAlgebra.carrier A) → ( (Hom.map f) (rhs {A} {e} args) == rhs {B} {e} (λ i → (Hom.map f) (args i)))\n\n -- Algebra\n record Algebra {l : Level} (S : OpSignature {l}) (E : EqSignature {l} S) : Set (lsuc l) where\n field\n alg : OpAlgebra S\n equations : ∀ (e : EqSignature.eq E) (args : EqSignature.eq-arity E e → OpAlgebra.carrier alg) → (EqSignature.rhs E {alg} {e} args == EqSignature.lhs E {alg} {e} args)\n\n\n -- For the moment, I think that we did not talk about terms in contexts, did we ? Should we generalize the things we did in Lambda.agda (using De Bruijn indices for the variables) ? -> I tried things\n\n\n\n\n\n\n\n -- ** Other things **\n\n -- Useful arities\n data nullary : Set where\n data unary : Set where\n only : unary\n data binary : Set where\n fst : binary\n snd : binary\n\n\n -- Definition of groups\n data GroupOperation : Set where\n one : GroupOperation\n mul : GroupOperation\n inv : GroupOperation\n\n GroupArity : (o : GroupOperation) → Set\n GroupArity one = nullary\n GroupArity mul = binary\n GroupArity inv = unary\n\n GroupOp : OpSignature\n GroupOp = record { operation = GroupOperation ; arity = GroupArity}\n\n\n\n", "meta": {"hexsha": "072e502468e44918a54b125abf6d7354f620e59b", "size": 6978, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Experimental/AlgebraFormalization.agda", "max_stars_repo_name": "cilinder/formaltt", "max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 21, "max_stars_repo_stars_event_min_datetime": "2021-02-16T14:07:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-19T15:50:08.000Z", "max_issues_repo_path": "src/Experimental/AlgebraFormalization.agda", "max_issues_repo_name": "andrejbauer/formaltt", "max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z", "max_forks_repo_path": "src/Experimental/AlgebraFormalization.agda", "max_forks_repo_name": "andrejbauer/formaltt", "max_forks_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z", "avg_line_length": 37.7189189189, "max_line_length": 279, "alphanum_fraction": 0.5912869017, "num_tokens": 2471, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.843895106480586, "lm_q2_score": 0.7690802423634963, "lm_q1q2_score": 0.6490230530214576}} {"text": "------------------------------------------------------------------------------\n-- Arithmetic properties\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOTC.Data.Nat.PropertiesI where\n\nopen import Common.FOL.Relation.Binary.EqReasoning\n\nopen import FOTC.Base\nopen import FOTC.Base.PropertiesI\nopen import FOTC.Data.Nat\nopen import FOTC.Data.Nat.UnaryNumbers\nopen import FOTC.Data.Nat.UnaryNumbers.TotalityI\n\n------------------------------------------------------------------------------\n-- Congruence properties\n\n+-leftCong : ∀ {m n o} → m ≡ n → m + o ≡ n + o\n+-leftCong refl = refl\n\n+-rightCong : ∀ {m n o} → n ≡ o → m + n ≡ m + o\n+-rightCong refl = refl\n\n∸-leftCong : ∀ {m n o} → m ≡ n → m ∸ o ≡ n ∸ o\n∸-leftCong refl = refl\n\n∸-rightCong : ∀ {m n o} → n ≡ o → m ∸ n ≡ m ∸ o\n∸-rightCong refl = refl\n\n*-leftCong : ∀ {m n o} → m ≡ n → m * o ≡ n * o\n*-leftCong refl = refl\n\n*-rightCong : ∀ {m n o} → n ≡ o → m * n ≡ m * o\n*-rightCong refl = refl\n\n------------------------------------------------------------------------------\n\nSx≢x : ∀ {n} → N n → succ₁ n ≢ n\nSx≢x nzero h = ⊥-elim (0≢S (sym h))\nSx≢x (nsucc Nn) h = ⊥-elim (Sx≢x Nn (succInjective h))\n\n+-leftIdentity : ∀ n → zero + n ≡ n\n+-leftIdentity = +-0x\n\n+-rightIdentity : ∀ {n} → N n → n + zero ≡ n\n+-rightIdentity nzero = +-leftIdentity zero\n+-rightIdentity (nsucc {n} Nn) =\n trans (+-Sx n zero) (succCong (+-rightIdentity Nn))\n\npred-N : ∀ {n} → N n → N (pred₁ n)\npred-N nzero = subst N (sym pred-0) nzero\npred-N (nsucc {n} Nn) = subst N (sym (pred-S n)) Nn\n\n+-N : ∀ {m n} → N m → N n → N (m + n)\n+-N {n = n} nzero Nn = subst N (sym (+-leftIdentity n)) Nn\n+-N {n = n} (nsucc {m} Nm) Nn = subst N (sym (+-Sx m n)) (nsucc (+-N Nm Nn))\n\n∸-N : ∀ {m n} → N m → N n → N (m ∸ n)\n∸-N {m} Nm nzero = subst N (sym (∸-x0 m)) Nm\n∸-N {m} Nm (nsucc {n} Nn) = subst N (sym (∸-xS m n)) (pred-N (∸-N Nm Nn))\n\n+-assoc : ∀ {m} → N m → ∀ n o → m + n + o ≡ m + (n + o)\n+-assoc nzero n o =\n zero + n + o ≡⟨ +-leftCong (+-leftIdentity n) ⟩\n n + o ≡⟨ sym (+-leftIdentity (n + o)) ⟩\n zero + (n + o) ∎\n\n+-assoc (nsucc {m} Nm) n o =\n succ₁ m + n + o ≡⟨ +-leftCong (+-Sx m n) ⟩\n succ₁ (m + n) + o ≡⟨ +-Sx (m + n) o ⟩\n succ₁ (m + n + o) ≡⟨ succCong (+-assoc Nm n o) ⟩\n succ₁ (m + (n + o)) ≡⟨ sym (+-Sx m (n + o)) ⟩\n succ₁ m + (n + o) ∎\n\nx+Sy≡S[x+y] : ∀ {m} → N m → ∀ n → m + succ₁ n ≡ succ₁ (m + n)\nx+Sy≡S[x+y] nzero n =\n zero + succ₁ n ≡⟨ +-leftIdentity (succ₁ n) ⟩\n succ₁ n ≡⟨ succCong (sym (+-leftIdentity n)) ⟩\n succ₁ (zero + n) ∎\n\nx+Sy≡S[x+y] (nsucc {m} Nm) n =\n succ₁ m + succ₁ n ≡⟨ +-Sx m (succ₁ n) ⟩\n succ₁ (m + succ₁ n) ≡⟨ succCong (x+Sy≡S[x+y] Nm n) ⟩\n succ₁ (succ₁ (m + n)) ≡⟨ succCong (sym (+-Sx m n)) ⟩\n succ₁ (succ₁ m + n) ∎\n\n+-comm : ∀ {m n} → N m → N n → m + n ≡ n + m\n+-comm {n = n} nzero Nn =\n zero + n ≡⟨ +-leftIdentity n ⟩\n n ≡⟨ sym (+-rightIdentity Nn) ⟩\n n + zero ∎\n\n+-comm {n = n} (nsucc {m} Nm) Nn =\n succ₁ m + n ≡⟨ +-Sx m n ⟩\n succ₁ (m + n) ≡⟨ succCong (+-comm Nm Nn) ⟩\n succ₁ (n + m) ≡⟨ sym (x+Sy≡S[x+y] Nn m) ⟩\n n + succ₁ m ∎\n\n0∸x : ∀ {n} → N n → zero ∸ n ≡ zero\n0∸x nzero = ∸-x0 zero\n0∸x (nsucc {n} Nn) =\n zero ∸ succ₁ n ≡⟨ ∸-xS zero n ⟩\n pred₁ (zero ∸ n) ≡⟨ predCong (0∸x Nn) ⟩\n pred₁ zero ≡⟨ pred-0 ⟩\n zero ∎\n\nS∸S : ∀ {m n} → N m → N n → succ₁ m ∸ succ₁ n ≡ m ∸ n\nS∸S {m} _ nzero =\n succ₁ m ∸ succ₁ zero ≡⟨ ∸-xS (succ₁ m) zero ⟩\n pred₁ (succ₁ m ∸ zero) ≡⟨ predCong (∸-x0 (succ₁ m)) ⟩\n pred₁ (succ₁ m) ≡⟨ pred-S m ⟩\n m ≡⟨ sym (∸-x0 m) ⟩\n m ∸ zero ∎\n\nS∸S {m} Nm (nsucc {n} Nn) =\n succ₁ m ∸ succ₁ (succ₁ n) ≡⟨ ∸-xS (succ₁ m) (succ₁ n) ⟩\n pred₁ (succ₁ m ∸ succ₁ n) ≡⟨ predCong (S∸S Nm Nn) ⟩\n pred₁ (m ∸ n) ≡⟨ sym (∸-xS m n) ⟩\n m ∸ succ₁ n ∎\n\nx∸x≡0 : ∀ {n} → N n → n ∸ n ≡ zero\nx∸x≡0 nzero = ∸-x0 zero\nx∸x≡0 (nsucc Nn) = trans (S∸S Nn Nn) (x∸x≡0 Nn)\n\nSx∸x≡1 : ∀ {n} → N n → succ₁ n ∸ n ≡ 1'\nSx∸x≡1 nzero = ∸-x0 1'\nSx∸x≡1 (nsucc Nn) = trans (S∸S (nsucc Nn) Nn) (Sx∸x≡1 Nn)\n\n[x+Sy]∸y≡Sx : ∀ {m n} → N m → N n → m + succ₁ n ∸ n ≡ succ₁ m\n[x+Sy]∸y≡Sx {n = n} nzero Nn =\n zero + succ₁ n ∸ n ≡⟨ ∸-leftCong (+-leftIdentity (succ₁ n)) ⟩\n succ₁ n ∸ n ≡⟨ Sx∸x≡1 Nn ⟩\n 1' ∎\n\n[x+Sy]∸y≡Sx (nsucc {m} Nm) nzero =\n succ₁ m + 1' ∸ zero ≡⟨ ∸-leftCong (+-Sx m 1') ⟩\n succ₁ (m + 1') ∸ zero ≡⟨ ∸-x0 (succ₁ (m + 1')) ⟩\n succ₁ (m + 1') ≡⟨ succCong (+-comm Nm 1-N) ⟩\n succ₁ (1' + m) ≡⟨ succCong (+-Sx zero m) ⟩\n succ₁ (succ₁ (zero + m)) ≡⟨ succCong (succCong (+-leftIdentity m)) ⟩\n succ₁ (succ₁ m) ∎\n\n[x+Sy]∸y≡Sx (nsucc {m} Nm) (nsucc {n} Nn) =\n succ₁ m + succ₁ (succ₁ n) ∸ succ₁ n\n ≡⟨ ∸-leftCong (+-Sx m (succ₁ (succ₁ n))) ⟩\n succ₁ (m + succ₁ (succ₁ n)) ∸ succ₁ n\n ≡⟨ S∸S (+-N Nm (nsucc (nsucc Nn))) Nn ⟩\n m + succ₁ (succ₁ n) ∸ n\n ≡⟨ ∸-leftCong (x+Sy≡S[x+y] Nm (succ₁ n)) ⟩\n succ₁ (m + succ₁ n) ∸ n\n ≡⟨ ∸-leftCong (sym (+-Sx m (succ₁ n))) ⟩\n succ₁ m + succ₁ n ∸ n\n ≡⟨ [x+Sy]∸y≡Sx (nsucc Nm) Nn ⟩\n succ₁ (succ₁ m) ∎\n\n[x+y]∸[x+z]≡y∸z : ∀ {m n o} → N m → N n → N o → (m + n) ∸ (m + o) ≡ n ∸ o\n[x+y]∸[x+z]≡y∸z {n = n} {o} nzero _ _ =\n (zero + n) ∸ (zero + o) ≡⟨ ∸-leftCong (+-leftIdentity n) ⟩\n n ∸ (zero + o) ≡⟨ ∸-rightCong (+-leftIdentity o) ⟩\n n ∸ o ∎\n\n[x+y]∸[x+z]≡y∸z {n = n} {o} (nsucc {m} Nm) Nn No =\n (succ₁ m + n) ∸ (succ₁ m + o) ≡⟨ ∸-leftCong (+-Sx m n) ⟩\n succ₁ (m + n) ∸ (succ₁ m + o) ≡⟨ ∸-rightCong (+-Sx m o) ⟩\n succ₁ (m + n) ∸ succ₁ (m + o) ≡⟨ S∸S (+-N Nm Nn) (+-N Nm No) ⟩\n (m + n) ∸ (m + o) ≡⟨ [x+y]∸[x+z]≡y∸z Nm Nn No ⟩\n n ∸ o ∎\n\n*-leftZero : ∀ n → zero * n ≡ zero\n*-leftZero = *-0x\n\n*-rightZero : ∀ {n} → N n → n * zero ≡ zero\n*-rightZero nzero = *-leftZero zero\n*-rightZero (nsucc {n} Nn) =\n trans (*-Sx n zero)\n (trans (+-leftIdentity (n * zero)) (*-rightZero Nn))\n\n*-N : ∀ {m n} → N m → N n → N (m * n)\n*-N {n = n} nzero Nn = subst N (sym (*-leftZero n)) nzero\n*-N {n = n} (nsucc {m} Nm) Nn = subst N (sym (*-Sx m n)) (+-N Nn (*-N Nm Nn))\n\n*-leftIdentity : ∀ {n} → N n → 1' * n ≡ n\n*-leftIdentity {n} Nn =\n 1' * n ≡⟨ *-Sx zero n ⟩\n n + zero * n ≡⟨ +-rightCong (*-leftZero n) ⟩\n n + zero ≡⟨ +-rightIdentity Nn ⟩\n n ∎\n\nx*Sy≡x+xy : ∀ {m n} → N m → N n → m * succ₁ n ≡ m + m * n\nx*Sy≡x+xy {n = n} nzero Nn = sym\n (\n zero + zero * n ≡⟨ +-rightCong (*-leftZero n) ⟩\n zero + zero ≡⟨ +-leftIdentity zero ⟩\n zero ≡⟨ sym (*-leftZero (succ₁ n)) ⟩\n zero * succ₁ n ∎\n )\n\nx*Sy≡x+xy {n = n} (nsucc {m} Nm) Nn =\n succ₁ m * succ₁ n\n ≡⟨ *-Sx m (succ₁ n) ⟩\n succ₁ n + m * succ₁ n\n ≡⟨ +-rightCong (x*Sy≡x+xy Nm Nn) ⟩\n succ₁ n + (m + m * n)\n ≡⟨ +-Sx n (m + m * n) ⟩\n succ₁ (n + (m + m * n))\n ≡⟨ succCong (sym (+-assoc Nn m (m * n))) ⟩\n succ₁ (n + m + m * n)\n ≡⟨ succCong (+-leftCong (+-comm Nn Nm)) ⟩\n succ₁ (m + n + m * n)\n ≡⟨ succCong (+-assoc Nm n (m * n)) ⟩\n succ₁ (m + (n + m * n))\n ≡⟨ sym (+-Sx m (n + m * n)) ⟩\n succ₁ m + (n + m * n)\n ≡⟨ +-rightCong (sym (*-Sx m n)) ⟩\n succ₁ m + succ₁ m * n ∎\n\n*-comm : ∀ {m n} → N m → N n → m * n ≡ n * m\n*-comm {n = n} nzero Nn = trans (*-leftZero n) (sym (*-rightZero Nn))\n*-comm {n = n} (nsucc {m} Nm) Nn =\n succ₁ m * n ≡⟨ *-Sx m n ⟩\n n + m * n ≡⟨ +-rightCong (*-comm Nm Nn) ⟩\n n + n * m ≡⟨ sym (x*Sy≡x+xy Nn Nm) ⟩\n n * succ₁ m ∎\n\n*-rightIdentity : ∀ {n} → N n → n * 1' ≡ n\n*-rightIdentity {n} Nn = trans (*-comm Nn (nsucc nzero)) (*-leftIdentity Nn)\n\n*∸-leftDistributive : ∀ {m n o} → N m → N n → N o → (m ∸ n) * o ≡ m * o ∸ n * o\n*∸-leftDistributive {m} {o = o} _ nzero _ =\n (m ∸ zero) * o ≡⟨ *-leftCong (∸-x0 m) ⟩\n m * o ≡⟨ sym (∸-x0 (m * o)) ⟩\n m * o ∸ zero ≡⟨ ∸-rightCong (sym (*-leftZero o)) ⟩\n m * o ∸ zero * o ∎\n\n*∸-leftDistributive {o = o} nzero (nsucc {n} Nn) No =\n (zero ∸ succ₁ n) * o ≡⟨ *-leftCong (0∸x (nsucc Nn)) ⟩\n zero * o ≡⟨ *-leftZero o ⟩\n zero ≡⟨ sym (0∸x (*-N (nsucc Nn) No)) ⟩\n zero ∸ succ₁ n * o ≡⟨ ∸-leftCong (sym (*-leftZero o)) ⟩\n zero * o ∸ succ₁ n * o ∎\n\n*∸-leftDistributive (nsucc {m} Nm) (nsucc {n} Nn) nzero =\n (succ₁ m ∸ succ₁ n) * zero\n ≡⟨ *-comm (∸-N (nsucc Nm) (nsucc Nn)) nzero ⟩\n zero * (succ₁ m ∸ succ₁ n)\n ≡⟨ *-leftZero (succ₁ m ∸ succ₁ n) ⟩\n zero\n ≡⟨ sym (0∸x (*-N (nsucc Nn) nzero)) ⟩\n zero ∸ succ₁ n * zero\n ≡⟨ ∸-leftCong (sym (*-leftZero (succ₁ m))) ⟩\n zero * succ₁ m ∸ succ₁ n * zero\n ≡⟨ ∸-leftCong (*-comm nzero (nsucc Nm)) ⟩\n succ₁ m * zero ∸ succ₁ n * zero ∎\n\n*∸-leftDistributive (nsucc {m} Nm) (nsucc {n} Nn) (nsucc {o} No) =\n (succ₁ m ∸ succ₁ n) * succ₁ o\n ≡⟨ *-leftCong (S∸S Nm Nn) ⟩\n (m ∸ n) * succ₁ o\n ≡⟨ *∸-leftDistributive Nm Nn (nsucc No) ⟩\n m * succ₁ o ∸ n * succ₁ o\n ≡⟨ sym ([x+y]∸[x+z]≡y∸z (nsucc No) (*-N Nm (nsucc No)) (*-N Nn (nsucc No))) ⟩\n (succ₁ o + m * succ₁ o) ∸ (succ₁ o + n * succ₁ o)\n ≡⟨ ∸-leftCong (sym (*-Sx m (succ₁ o))) ⟩\n (succ₁ m * succ₁ o) ∸ (succ₁ o + n * succ₁ o)\n ≡⟨ ∸-rightCong (sym (*-Sx n (succ₁ o))) ⟩\n (succ₁ m * succ₁ o) ∸ (succ₁ n * succ₁ o) ∎\n\n*+-leftDistributive : ∀ {m n o} → N m → N n → N o → (m + n) * o ≡ m * o + n * o\n*+-leftDistributive {m} {n} Nm Nn nzero =\n (m + n) * zero\n ≡⟨ *-comm (+-N Nm Nn) nzero ⟩\n zero * (m + n)\n ≡⟨ *-leftZero (m + n) ⟩\n zero\n ≡⟨ sym (*-leftZero m) ⟩\n zero * m\n ≡⟨ *-comm nzero Nm ⟩\n m * zero\n ≡⟨ sym (+-rightIdentity (*-N Nm nzero)) ⟩\n m * zero + zero\n ≡⟨ +-rightCong (trans (sym (*-leftZero n)) (*-comm nzero Nn)) ⟩\n m * zero + n * zero ∎\n\n*+-leftDistributive {n = n} nzero Nn (nsucc {o} No) =\n (zero + n) * succ₁ o ≡⟨ *-leftCong (+-leftIdentity n) ⟩\n n * succ₁ o ≡⟨ sym (+-leftIdentity (n * succ₁ o)) ⟩\n zero + n * succ₁ o ≡⟨ +-leftCong (sym (*-leftZero (succ₁ o))) ⟩\n zero * succ₁ o + n * succ₁ o ∎\n\n*+-leftDistributive (nsucc {m} Nm) nzero (nsucc {o} No) =\n (succ₁ m + zero) * succ₁ o\n ≡⟨ *-leftCong (+-rightIdentity (nsucc Nm)) ⟩\n succ₁ m * succ₁ o\n ≡⟨ sym (+-rightIdentity (*-N (nsucc Nm) (nsucc No))) ⟩\n succ₁ m * succ₁ o + zero\n ≡⟨ +-rightCong (sym (*-leftZero (succ₁ o))) ⟩\n succ₁ m * succ₁ o + zero * succ₁ o ∎\n\n*+-leftDistributive (nsucc {m} Nm) (nsucc {n} Nn) (nsucc {o} No) =\n (succ₁ m + succ₁ n) * succ₁ o\n ≡⟨ *-leftCong (+-Sx m (succ₁ n)) ⟩\n succ₁ (m + succ₁ n) * succ₁ o\n ≡⟨ *-Sx (m + succ₁ n) (succ₁ o) ⟩\n succ₁ o + (m + succ₁ n) * succ₁ o\n ≡⟨ +-rightCong (*+-leftDistributive Nm (nsucc Nn) (nsucc No)) ⟩\n succ₁ o + (m * succ₁ o + succ₁ n * succ₁ o)\n ≡⟨ sym (+-assoc (nsucc No) (m * succ₁ o) (succ₁ n * succ₁ o)) ⟩\n succ₁ o + m * succ₁ o + succ₁ n * succ₁ o\n ≡⟨ +-leftCong (sym (*-Sx m (succ₁ o))) ⟩\n succ₁ m * succ₁ o + succ₁ n * succ₁ o ∎\n\nxy≡0→x≡0∨y≡0 : ∀ {m n} → N m → N n → m * n ≡ zero → m ≡ zero ∨ n ≡ zero\nxy≡0→x≡0∨y≡0 nzero _ _ = inj₁ refl\nxy≡0→x≡0∨y≡0 (nsucc Nm) nzero _ = inj₂ refl\nxy≡0→x≡0∨y≡0 (nsucc {m} Nm) (nsucc {n} Nn) SmSn≡0 = ⊥-elim (0≢S prf)\n where\n prf : zero ≡ succ₁ (n + m * succ₁ n)\n prf = zero ≡⟨ sym SmSn≡0 ⟩\n succ₁ m * succ₁ n ≡⟨ *-Sx m (succ₁ n) ⟩\n succ₁ n + m * succ₁ n ≡⟨ +-Sx n (m * succ₁ n) ⟩\n succ₁ (n + m * succ₁ n) ∎\n\nxy≡1→x≡1 : ∀ {m n} → N m → N n → m * n ≡ 1' → m ≡ 1'\nxy≡1→x≡1 {n = n} nzero Nn h = ⊥-elim (0≢S (trans (sym (*-leftZero n)) h))\nxy≡1→x≡1 (nsucc nzero) Nn h = refl\nxy≡1→x≡1 (nsucc (nsucc {m} Nm)) nzero h =\n ⊥-elim (0≢S (trans (sym (*-rightZero (nsucc (nsucc Nm)))) h))\nxy≡1→x≡1 (nsucc (nsucc {m} Nm)) (nsucc {n} Nn) h = ⊥-elim (0≢S prf₂)\n where\n prf₁ : 1' ≡ succ₁ (succ₁ (m + n * succ₁ (succ₁ m)))\n prf₁ = 1'\n ≡⟨ sym h ⟩\n succ₁ (succ₁ m) * succ₁ n\n ≡⟨ *-comm (nsucc (nsucc Nm)) (nsucc Nn) ⟩\n succ₁ n * succ₁ (succ₁ m)\n ≡⟨ *-Sx n (succ₁ (succ₁ m)) ⟩\n succ₁ (succ₁ m) + n * succ₁ (succ₁ m)\n ≡⟨ +-Sx (succ₁ m) (n * succ₁ (succ₁ m)) ⟩\n succ₁ (succ₁ m + n * succ₁ (succ₁ m))\n ≡⟨ succCong (+-Sx m (n * succ₁ (succ₁ m))) ⟩\n succ₁ (succ₁ (m + n * succ₁ (succ₁ m))) ∎\n\n prf₂ : zero ≡ succ₁ (m + n * succ₁ (succ₁ m))\n prf₂ = succInjective prf₁\n\nxy≡1→y≡1 : ∀ {m n} → N m → N n → m * n ≡ 1' → n ≡ 1'\nxy≡1→y≡1 Nm Nn h = xy≡1→x≡1 Nn Nm (trans (*-comm Nn Nm) h)\n\n-- Feferman's axiom as presented by (Beeson 1986, p. 74).\nsuccOnto : ∀ {n} → N n → n ≢ zero → succ₁ (pred₁ n) ≡ n\nsuccOnto nzero h = ⊥-elim (h refl)\nsuccOnto (nsucc {n} Nn) h = succCong (pred-S n)\n\n------------------------------------------------------------------------------\n-- References\n--\n-- Beeson, M. J. (1986). Proving Programs and Programming Proofs. In:\n-- Logic, Methodology and Philosophy of Science VII (1983). Ed. by\n-- Barcan Marcus, Ruth, Dorn, George J. W. and Weingartner,\n-- Paul. Vol. 114. Studies in Logic and the Foundations of\n-- Mathematics. Elsevier, pp. 51–82.\n", "meta": {"hexsha": "8b7c4b048c6a7e5f47f94f408bb505d086a2bbb0", "size": 13143, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/FOTC/Data/Nat/PropertiesI.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/FOTC/Data/Nat/PropertiesI.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/FOTC/Data/Nat/PropertiesI.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 35.8119891008, "max_line_length": 81, "alphanum_fraction": 0.4656471125, "num_tokens": 6314, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031738010682209, "lm_q2_score": 0.8080672112416736, "lm_q1q2_score": 0.649018413571572}} {"text": "module LinkedList.Properties where\n\nopen import LinkedList\n\nopen import Data.Nat\nopen import Data.Nat.Properties.Simple\nopen import Relation.Nullary.Decidable using (False)\nopen import Relation.Binary.PropositionalEquality as PropEq\n using (_≡_; _≢_; refl; cong; cong₂; trans; sym; inspect)\nopen PropEq.≡-Reasoning\n\n\n\nincr-suc : ∀ {A x} → {xs : LinkedList A} → ⟦ incr x xs ⟧ ≡ suc ⟦ xs ⟧\nincr-suc {_} {x} {xs} = refl\n\ndecr-pred : ∀ {A} → {xs : LinkedList A} → (p : False (null? xs)) → ⟦ decr xs p ⟧ ≡ pred ⟦ xs ⟧\ndecr-pred {xs = [] } ()\ndecr-pred {xs = x ∷ xs} p = refl\n\n++-left-indentity : ∀ {A} → {xs : LinkedList A} → [] ++ xs ≡ xs\n++-left-indentity {A} {xs} = refl\n\n++-right-indentity : ∀ {A} → {xs : LinkedList A} → [] ++ xs ≡ xs\n++-right-indentity {A} {xs} = refl\n\n⟦xs++ys⟧≡⟦xs⟧+⟦ys⟧ : ∀ {A} → (xs : LinkedList A)\n → (ys : LinkedList A)\n → ⟦ xs ++ ys ⟧ ≡ ⟦ xs ⟧ + ⟦ ys ⟧\n⟦xs++ys⟧≡⟦xs⟧+⟦ys⟧ [] ys = refl\n⟦xs++ys⟧≡⟦xs⟧+⟦ys⟧ (x ∷ xs) ys = cong suc (⟦xs++ys⟧≡⟦xs⟧+⟦ys⟧ xs ys)\n", "meta": {"hexsha": "e5e48ff3fdc0912f34c9bc764f6519eaedc98737", "size": 1038, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "legacy/LinkedList/Properties.agda", "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_issues_repo_path": "legacy/LinkedList/Properties.agda", "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "legacy/LinkedList/Properties.agda", "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "avg_line_length": 32.4375, "max_line_length": 94, "alphanum_fraction": 0.5500963391, "num_tokens": 418, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8840392909114835, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.6489905008626045}} {"text": "------------------------------------------------------------------------\n-- INCREMENTAL λ-CALCULUS\n--\n-- About the group structure of integers and bags for Nehemiah plugin.\n------------------------------------------------------------------------\n\nmodule Theorem.Groups-Nehemiah where\n\nopen import Structure.Bag.Nehemiah public\n\nopen import Relation.Binary.PropositionalEquality\nopen import Algebra.Structures\n\n4-way-shuffle : ∀ {A : Set} {f} {z a b c d : A}\n {{comm-monoid : IsCommutativeMonoid _≡_ f z}} →\n f (f a b) (f c d) ≡ f (f a c) (f b d)\n4-way-shuffle {f = f} {z = z} {a} {b} {c} {d} {{comm-monoid}} =\n let\n assoc = associative comm-monoid\n cmute = commutative comm-monoid\n in\n begin\n f (f a b) (f c d)\n ≡⟨ assoc a b (f c d) ⟩\n f a (f b (f c d))\n ≡⟨ cong (f a) (sym (assoc b c d)) ⟩\n f a (f (f b c) d)\n ≡⟨ cong (λ hole → f a (f hole d)) (cmute b c) ⟩\n f a (f (f c b) d)\n ≡⟨ cong (f a) (assoc c b d) ⟩\n f a (f c (f b d))\n ≡⟨ sym (assoc a c (f b d)) ⟩\n f (f a c) (f b d)\n ∎ where open ≡-Reasoning\n\nmodule _ where\n open import Data.Nat\n -- Apologies for irregular name.\n ℕ-mn·pq=mp·nq : ∀ {m n p q : ℕ} →\n (m + n) + (p + q) ≡ (m + p) + (n + q)\n ℕ-mn·pq=mp·nq {m} {n} {p} {q} =\n 4-way-shuffle {a = m} {n} {p} {q} {{comm-monoid-nat}}\n\nopen import Data.Integer\n\nn+[m-n]=m : ∀ {n m} → n + (m - n) ≡ m\nn+[m-n]=m {n} {m} =\n begin\n n + (m - n)\n ≡⟨ cong (λ hole → n + hole) (commutative-int m (- n)) ⟩\n n + (- n + m)\n ≡⟨ sym (associative-int n (- n) m) ⟩\n (n - n) + m\n ≡⟨ cong (λ hole → hole + m) (right-inv-int n) ⟩\n (+ 0) + m\n ≡⟨ left-id-int m ⟩\n m\n ∎ where open ≡-Reasoning\n\na++[b\\\\a]=b : ∀ {a b} → a ++ (b \\\\ a) ≡ b\na++[b\\\\a]=b {b} {d} = trans\n (cong (λ hole → b ++ hole) (commutative-bag d (negateBag b))) (trans\n (sym (associative-bag b (negateBag b) d)) (trans\n (cong (λ hole → hole ++ d) (right-inv-bag b))\n (left-id-bag d)))\n\nab·cd=ac·bd : ∀ {a b c d : Bag} →\n (a ++ b) ++ (c ++ d) ≡ (a ++ c) ++ (b ++ d)\nab·cd=ac·bd {a} {b} {c} {d} =\n 4-way-shuffle {a = a} {b} {c} {d} {{comm-monoid-bag}}\n\nmn·pq=mp·nq : ∀ {m n p q : ℤ} →\n (m + n) + (p + q) ≡ (m + p) + (n + q)\nmn·pq=mp·nq {m} {n} {p} {q} =\n 4-way-shuffle {a = m} {n} {p} {q} {{comm-monoid-int}}\n\ninverse-unique : ∀ {A : Set} {f neg} {z a b : A}\n {{abelian : IsAbelianGroup _≡_ f z neg}} →\n f a b ≡ z → b ≡ neg a\n\ninverse-unique {f = f} {neg} {z} {a} {b} {{abelian}} ab=z =\n let\n assoc = associative (IsAbelianGroup.isCommutativeMonoid abelian)\n cmute = commutative (IsAbelianGroup.isCommutativeMonoid abelian)\n in\n begin\n b\n ≡⟨ sym (left-identity abelian b) ⟩\n f z b\n ≡⟨ cong (λ hole → f hole b) (sym (left-inverse abelian a)) ⟩\n f (f (neg a) a) b\n ≡⟨ assoc (neg a) a b ⟩\n f (neg a) (f a b)\n ≡⟨ cong (f (neg a)) ab=z ⟩\n f (neg a) z\n ≡⟨ right-identity abelian (neg a) ⟩\n neg a\n ∎ where\n open ≡-Reasoning\n eq1 : f (neg a) (f a b) ≡ f (neg a) z\n eq1 rewrite ab=z = cong (f (neg a)) refl\n\ndistribute-neg : ∀ {A : Set} {f neg} {z a b : A}\n {{abelian : IsAbelianGroup _≡_ f z neg}} →\n f (neg a) (neg b) ≡ neg (f a b)\ndistribute-neg {f = f} {neg} {z} {a} {b} {{abelian}} = inverse-unique\n {{abelian}}\n (begin\n f (f a b) (f (neg a) (neg b))\n ≡⟨ 4-way-shuffle {{IsAbelianGroup.isCommutativeMonoid abelian}} ⟩\n f (f a (neg a)) (f b (neg b))\n ≡⟨ cong₂ f (inverse a) (inverse b) ⟩\n f z z\n ≡⟨ left-identity abelian z ⟩\n z\n ∎) where\n open ≡-Reasoning\n inverse = right-inverse abelian\n\n-a·-b=-ab : ∀ {a b : Bag} →\n negateBag a ++ negateBag b ≡ negateBag (a ++ b)\n-a·-b=-ab {a} {b} = distribute-neg {a = a} {b} {{abelian-bag}}\n\n-m·-n=-mn : ∀ {m n : ℤ} →\n (- m) + (- n) ≡ - (m + n)\n-m·-n=-mn {m} {n} = distribute-neg {a = m} {n} {{abelian-int}}\n\n[a++b]\\\\a=b : ∀ {a b} → (a ++ b) \\\\ a ≡ b\n[a++b]\\\\a=b {b} {d} =\n begin\n (b ++ d) \\\\ b\n ≡⟨ cong (λ hole → hole \\\\ b) (commutative-bag b d) ⟩\n (d ++ b) \\\\ b\n ≡⟨ associative-bag d b (negateBag b) ⟩\n d ++ (b \\\\ b)\n ≡⟨ cong (_++_ d) (right-inv-bag b) ⟩\n d ++ emptyBag\n ≡⟨ right-id-bag d ⟩\n d\n ∎ where open ≡-Reasoning\n", "meta": {"hexsha": "73dbd184ade1dcefb6e2e2466c4da4524bb9e70b", "size": 4127, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Theorem/Groups-Nehemiah.agda", "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_issues_repo_path": "Theorem/Groups-Nehemiah.agda", "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_forks_repo_path": "Theorem/Groups-Nehemiah.agda", "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "avg_line_length": 29.2695035461, "max_line_length": 72, "alphanum_fraction": 0.4872788951, "num_tokens": 1793, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392848011834, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.648990496376914}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Path where\n\nopen import Cubical.Foundations.Everything\n using ( _≡_\n ; sym\n ; refl\n ; subst\n ; transport\n ; Path\n ; PathP\n ; I\n ; i0\n ; i1\n ; funExt\n ; cong\n ; toPathP\n ; cong₂\n ; ~_\n ; _∧_\n ; _∨_\n ; hcomp\n ; transp\n ; J\n )\n renaming (_∙_ to _;_; subst2 to subst₂)\n public\n\nopen import Data.Empty using (¬_)\nopen import Level\n\ninfix 4 _≢_\n_≢_ : {A : Type a} → A → A → Type a\nx ≢ y = ¬ (x ≡ y)\n\ninfix 4 PathP-syntax\nPathP-syntax = PathP\n{-# DISPLAY PathP-syntax = PathP #-}\n\nsyntax PathP-syntax (λ i → Ty) lhs rhs = lhs ≡[ i ≔ Ty ]≡ rhs\n\nimport Agda.Builtin.Equality as MLTT\n\nbuiltin-eq-to-path : {A : Type a} {x y : A} → x MLTT.≡ y → x ≡ y\nbuiltin-eq-to-path {x = x} MLTT.refl i = x\n\npath-to-builtin-eq : {A : Type a} {x y : A} → x ≡ y → x MLTT.≡ y\npath-to-builtin-eq {x = x} x≡y = subst (x MLTT.≡_) x≡y MLTT.refl\n", "meta": {"hexsha": "1ac4acdfef0d29b2bad86ea26b880e15282a604b", "size": 998, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Path.agda", "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_issues_repo_path": "Path.agda", "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Path.agda", "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "avg_line_length": 19.96, "max_line_length": 64, "alphanum_fraction": 0.5080160321, "num_tokens": 371, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637577007394, "lm_q2_score": 0.7549149978955811, "lm_q1q2_score": 0.6489730638355611}} {"text": "{-# OPTIONS --without-K #-}\nmodule function.extensionality.computation where\n\nopen import equality\nopen import function.isomorphism\nopen import function.core\nopen import function.extensionality.core\nopen import function.extensionality.proof\nopen import function.extensionality.strong\n\nfunext-inv-hom : ∀ {i j}{X : Set i}{Y : X → Set j}\n → {f₁ f₂ f₃ : (x : X) → Y x}\n → (p₁ : f₁ ≡ f₂)\n → (p₂ : f₂ ≡ f₃)\n → funext-inv (p₁ · p₂)\n ≡ (λ x → funext-inv p₁ x · funext-inv p₂ x)\nfunext-inv-hom refl p₂ = refl\n\nfunext-hom : ∀ {i j}{X : Set i}{Y : X → Set j}\n → {f₁ f₂ f₃ : (x : X) → Y x}\n → (h₁ : (x : X) → f₁ x ≡ f₂ x)\n → (h₂ : (x : X) → f₂ x ≡ f₃ x)\n → funext (λ x → h₁ x · h₂ x)\n ≡ funext h₁ · funext h₂\nfunext-hom h₁ h₂ = begin\n funext (λ x → h₁ x · h₂ x)\n ≡⟨ sym (ap funext (ap₂ (λ u v x → u x · v x)\n (_≅_.iso₁ strong-funext-iso h₁)\n (_≅_.iso₁ strong-funext-iso h₂))) ⟩\n funext (λ x → funext-inv (funext h₁) x · funext-inv (funext h₂) x)\n ≡⟨ sym (ap funext (funext-inv-hom (funext h₁) (funext h₂))) ⟩\n funext (funext-inv (funext h₁ · funext h₂))\n ≡⟨ _≅_.iso₂ strong-funext-iso (funext h₁ · funext h₂) ⟩\n funext h₁ · funext h₂\n ∎\n where open ≡-Reasoning\n\nfunext-inv-ap : ∀ {i j k}{X : Set i}{Y : X → Set j}{Z : X → Set k}\n → (g : {x : X} → Y x → Z x)\n → {f₁ f₂ : (x : X) → Y x}\n → (p : f₁ ≡ f₂)\n → funext-inv (ap (_∘'_ g) p)\n ≡ ((λ x → ap g (funext-inv p x)))\nfunext-inv-ap g refl = refl\n\nfunext-ap : ∀ {i j k}{X : Set i}{Y : X → Set j}{Z : X → Set k}\n → (g : {x : X} → Y x → Z x)\n → {f₁ f₂ : (x : X) → Y x}\n → (h : (x : X) → f₁ x ≡ f₂ x)\n → funext (λ x → ap g (h x))\n ≡ ap (_∘'_ g) (funext h)\nfunext-ap g h = begin\n funext (λ x → ap g (h x))\n ≡⟨ sym (ap funext (ap (λ h x → ap g (h x))\n (_≅_.iso₁ strong-funext-iso h))) ⟩\n funext (λ x → ap g (funext-inv (funext h) x))\n ≡⟨ ap funext (sym (funext-inv-ap g (funext h))) ⟩\n funext (funext-inv (ap (_∘'_ g) (funext h)))\n ≡⟨ _≅_.iso₂ strong-funext-iso _ ⟩\n ap (_∘'_ g) (funext h)\n ∎\n where open ≡-Reasoning\n", "meta": {"hexsha": "15ea5fee86f3115c94d90d78b9f94fd6b086c1c5", "size": 2280, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "function/extensionality/computation.agda", "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_issues_repo_path": "function/extensionality/computation.agda", "max_issues_repo_name": "HoTT/M-types", "max_issues_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-02-11T11:14:59.000Z", "max_issues_repo_issues_event_max_datetime": "2015-02-11T15:20:34.000Z", "max_forks_repo_path": "function/extensionality/computation.agda", "max_forks_repo_name": "HoTT/M-types", "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z", "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z", "avg_line_length": 36.1904761905, "max_line_length": 70, "alphanum_fraction": 0.4828947368, "num_tokens": 901, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637541053281, "lm_q2_score": 0.7549149923816048, "lm_q1q2_score": 0.6489730563811655}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Groups.Homomorphisms.Definition\nopen import Groups.Definition\nopen import Setoids.Setoids\nopen import Rings.Definition\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\n\nmodule Rings.Homomorphisms.Definition where\n\nrecord RingHom {m n o p : _} {A : Set m} {B : Set n} {SA : Setoid {m} {o} A} {SB : Setoid {n} {p} B} {_+A_ : A → A → A} {_*A_ : A → A → A} (R : Ring SA _+A_ _*A_) {_+B_ : B → B → B} {_*B_ : B → B → B} (S : Ring SB _+B_ _*B_) (f : A → B) : Set (m ⊔ n ⊔ o ⊔ p) where\n open Ring S\n open Group additiveGroup\n open Setoid SB\n field\n preserves1 : f (Ring.1R R) ∼ 1R\n ringHom : {r s : A} → f (r *A s) ∼ (f r) *B (f s)\n groupHom : GroupHom (Ring.additiveGroup R) additiveGroup f\n", "meta": {"hexsha": "e4bb44a362e1ccf19150471837f9ad5fba15ed60", "size": 773, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Rings/Homomorphisms/Definition.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Rings/Homomorphisms/Definition.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Rings/Homomorphisms/Definition.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 38.65, "max_line_length": 264, "alphanum_fraction": 0.6183699871, "num_tokens": 302, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9111797027760039, "lm_q2_score": 0.7122321964553658, "lm_q1q2_score": 0.6489715210737007}} {"text": "\nmodule Tactic.Nat.Exp where\n\nopen import Prelude\n\nVar = Nat\n\nEnv : Set → Set\nEnv Atom = Atom → Nat\n\ninfixl 6 _⟨+⟩_\ninfixl 7 _⟨*⟩_\ndata Exp (Atom : Set) : Set where\n var : (x : Atom) → Exp Atom\n lit : (n : Nat) → Exp Atom\n _⟨+⟩_ _⟨*⟩_ : (e e₁ : Exp Atom) → Exp Atom\n\n⟦_⟧e : ∀ {Atom} → Exp Atom → Env Atom → Nat\n⟦ var x ⟧e ρ = ρ x\n⟦ lit n ⟧e ρ = n\n⟦ e₁ ⟨+⟩ e₂ ⟧e ρ = ⟦ e₁ ⟧e ρ + ⟦ e₂ ⟧e ρ\n⟦ e₁ ⟨*⟩ e₂ ⟧e ρ = ⟦ e₁ ⟧e ρ * ⟦ e₂ ⟧e ρ\n\n", "meta": {"hexsha": "4a327fa6a00ed5ae98e0a2f9cb9766ca3d7d9bd4", "size": 437, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Tactic/Nat/Exp.agda", "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 111, "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_issues_repo_path": "src/Tactic/Nat/Exp.agda", "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_forks_repo_path": "src/Tactic/Nat/Exp.agda", "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "avg_line_length": 18.2083333333, "max_line_length": 44, "alphanum_fraction": 0.5148741419, "num_tokens": 231, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9324533144915913, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.6489486410452393}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Unary relations\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Relation.Unary where\n\nopen import Data.Empty\nopen import Data.Unit.Base using (⊤)\nopen import Data.Product\nopen import Data.Sum.Base using (_⊎_; [_,_])\nopen import Function.Base\nopen import Level\nopen import Relation.Nullary hiding (Irrelevant)\nopen import Relation.Nullary.Decidable.Core using (True)\nopen import Relation.Binary.PropositionalEquality.Core using (_≡_)\n\nprivate\n variable\n a b c ℓ ℓ₁ ℓ₂ : Level\n A : Set a\n B : Set b\n C : Set c\n\n------------------------------------------------------------------------\n-- Definition\n\n-- Unary relations are known as predicates and `Pred A ℓ` can be viewed\n-- as some property that elements of type A might satisfy.\n\n-- Consequently `P : Pred A ℓ` can also be seen as a subset of A\n-- containing all the elements of A that satisfy property P. This view\n-- informs much of the notation used below.\n\nPred : ∀ {a} → Set a → (ℓ : Level) → Set (a ⊔ suc ℓ)\nPred A ℓ = A → Set ℓ\n\n------------------------------------------------------------------------\n-- Special sets\n\n-- The empty set.\n\n∅ : Pred A 0ℓ\n∅ = λ _ → ⊥\n\n-- The singleton set.\n\n{_} : A → Pred A _\n{ x } = x ≡_\n\n-- The universal set.\n\nU : Pred A 0ℓ\nU = λ _ → ⊤\n\n------------------------------------------------------------------------\n-- Membership\n\ninfix 4 _∈_ _∉_\n\n_∈_ : A → Pred A ℓ → Set _\nx ∈ P = P x\n\n_∉_ : A → Pred A ℓ → Set _\nx ∉ P = ¬ x ∈ P\n\n------------------------------------------------------------------------\n-- Subset relations\n\ninfix 4 _⊆_ _⊇_ _⊈_ _⊉_ _⊂_ _⊃_ _⊄_ _⊅_\n\n_⊆_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _\nP ⊆ Q = ∀ {x} → x ∈ P → x ∈ Q\n\n_⊇_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _\nP ⊇ Q = Q ⊆ P\n\n_⊈_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _\nP ⊈ Q = ¬ (P ⊆ Q)\n\n_⊉_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _\nP ⊉ Q = ¬ (P ⊇ Q)\n\n_⊂_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _\nP ⊂ Q = P ⊆ Q × Q ⊈ P\n\n_⊃_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _\nP ⊃ Q = Q ⊂ P\n\n_⊄_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _\nP ⊄ Q = ¬ (P ⊂ Q)\n\n_⊅_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _\nP ⊅ Q = ¬ (P ⊃ Q)\n\n-- The following primed variants of _⊆_ can be used when 'x' can't\n-- be inferred from 'x ∈ P'.\n\ninfix 4 _⊆′_ _⊇′_ _⊈′_ _⊉′_ _⊂′_ _⊃′_ _⊄′_ _⊅′_\n\n_⊆′_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _\nP ⊆′ Q = ∀ x → x ∈ P → x ∈ Q\n\n_⊇′_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _\nQ ⊇′ P = P ⊆′ Q\n\n_⊈′_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _\nP ⊈′ Q = ¬ (P ⊆′ Q)\n\n_⊉′_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _\nP ⊉′ Q = ¬ (P ⊇′ Q)\n\n_⊂′_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _\nP ⊂′ Q = P ⊆′ Q × Q ⊈′ P\n\n_⊃′_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _\nP ⊃′ Q = Q ⊂′ P\n\n_⊄′_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _\nP ⊄′ Q = ¬ (P ⊂′ Q)\n\n_⊅′_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _\nP ⊅′ Q = ¬ (P ⊃′ Q)\n\n------------------------------------------------------------------------\n-- Properties of sets\n\ninfix 10 Satisfiable Universal IUniversal\n\n-- Emptiness - no element satisfies P.\n\nEmpty : Pred A ℓ → Set _\nEmpty P = ∀ x → x ∉ P\n\n-- Satisfiable - at least one element satisfies P.\n\nSatisfiable : Pred A ℓ → Set _\nSatisfiable P = ∃ λ x → x ∈ P\n\nsyntax Satisfiable P = ∃⟨ P ⟩\n\n-- Universality - all elements satisfy P.\n\nUniversal : Pred A ℓ → Set _\nUniversal P = ∀ x → x ∈ P\n\nsyntax Universal P = Π[ P ]\n\n-- Implicit universality - all elements satisfy P.\n\nIUniversal : Pred A ℓ → Set _\nIUniversal P = ∀ {x} → x ∈ P\n\nsyntax IUniversal P = ∀[ P ]\n\n-- Decidability - it is possible to determine if an arbitrary element\n-- satisfies P.\n\nDecidable : Pred A ℓ → Set _\nDecidable P = ∀ x → Dec (P x)\n\n-- Erasure: A decidable predicate gives rise to another one, more\n-- amenable to η-expansion\n\n⌊_⌋ : {P : Pred A ℓ} → Decidable P → Pred A ℓ\n⌊ P? ⌋ a = Lift _ (True (P? a))\n\n-- Irrelevance - any two proofs that an element satifies P are\n-- indistinguishable.\n\nIrrelevant : Pred A ℓ → Set _\nIrrelevant P = ∀ {x} (a : P x) (b : P x) → a ≡ b\n\n-- Recomputability - we can rebuild a relevant proof given an\n-- irrelevant one.\n\nRecomputable : Pred A ℓ → Set _\nRecomputable P = ∀ {x} → .(P x) → P x\n\n------------------------------------------------------------------------\n-- Operations on sets\n\ninfix 10 ⋃ ⋂\ninfixr 9 _⊢_\ninfixr 8 _⇒_\ninfixr 7 _∩_\ninfixr 6 _∪_\ninfix 4 _≬_\n\n-- Complement.\n\n∁ : Pred A ℓ → Pred A ℓ\n∁ P = λ x → x ∉ P\n\n-- Implication.\n\n_⇒_ : Pred A ℓ₁ → Pred A ℓ₂ → Pred A _\nP ⇒ Q = λ x → x ∈ P → x ∈ Q\n\n-- Union.\n\n_∪_ : Pred A ℓ₁ → Pred A ℓ₂ → Pred A _\nP ∪ Q = λ x → x ∈ P ⊎ x ∈ Q\n\n-- Intersection.\n\n_∩_ : Pred A ℓ₁ → Pred A ℓ₂ → Pred A _\nP ∩ Q = λ x → x ∈ P × x ∈ Q\n\n-- Infinitary union.\n\n⋃ : ∀ {i} (I : Set i) → (I → Pred A ℓ) → Pred A _\n⋃ I P = λ x → Σ[ i ∈ I ] P i x\n\nsyntax ⋃ I (λ i → P) = ⋃[ i ∶ I ] P\n\n-- Infinitary intersection.\n\n⋂ : ∀ {i} (I : Set i) → (I → Pred A ℓ) → Pred A _\n⋂ I P = λ x → (i : I) → P i x\n\nsyntax ⋂ I (λ i → P) = ⋂[ i ∶ I ] P\n\n-- Positive version of non-disjointness, dual to inclusion.\n\n_≬_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _\nP ≬ Q = ∃ λ x → x ∈ P × x ∈ Q\n\n-- Update.\n\n_⊢_ : (A → B) → Pred B ℓ → Pred A ℓ\nf ⊢ P = λ x → P (f x)\n\n------------------------------------------------------------------------\n-- Predicate combinators\n\n-- These differ from the set operations above, as the carrier set of the\n-- resulting predicates are not the same as the carrier set of the\n-- component predicates.\n\ninfixr 2 _⟨×⟩_\ninfixr 2 _⟨⊙⟩_\ninfixr 1 _⟨⊎⟩_\ninfixr 0 _⟨→⟩_\ninfixl 9 _⟨·⟩_\ninfix 10 _~\ninfixr 9 _⟨∘⟩_\ninfixr 2 _//_ _\\\\_\n\n-- Product.\n\n_⟨×⟩_ : Pred A ℓ₁ → Pred B ℓ₂ → Pred (A × B) _\n(P ⟨×⟩ Q) (x , y) = x ∈ P × y ∈ Q\n\n-- Sum over one element.\n\n_⟨⊎⟩_ : Pred A ℓ → Pred B ℓ → Pred (A ⊎ B) _\nP ⟨⊎⟩ Q = [ P , Q ]\n\n-- Sum over two elements.\n\n_⟨⊙⟩_ : Pred A ℓ₁ → Pred B ℓ₂ → Pred (A × B) _\n(P ⟨⊙⟩ Q) (x , y) = x ∈ P ⊎ y ∈ Q\n\n-- Implication.\n\n_⟨→⟩_ : Pred A ℓ₁ → Pred B ℓ₂ → Pred (A → B) _\n(P ⟨→⟩ Q) f = P ⊆ Q ∘ f\n\n-- Product.\n\n_⟨·⟩_ : (P : Pred A ℓ₁) (Q : Pred B ℓ₂) →\n (P ⟨×⟩ (P ⟨→⟩ Q)) ⊆ Q ∘ uncurry (flip _$_)\n(P ⟨·⟩ Q) (p , f) = f p\n\n-- Converse.\n\n_~ : Pred (A × B) ℓ → Pred (B × A) ℓ\nP ~ = P ∘ swap\n\n-- Composition.\n\n_⟨∘⟩_ : Pred (A × B) ℓ₁ → Pred (B × C) ℓ₂ → Pred (A × C) _\n(P ⟨∘⟩ Q) (x , z) = ∃ λ y → (x , y) ∈ P × (y , z) ∈ Q\n\n-- Post-division.\n\n_//_ : Pred (A × C) ℓ₁ → Pred (B × C) ℓ₂ → Pred (A × B) _\n(P // Q) (x , y) = Q ∘ (y ,_) ⊆ P ∘ (x ,_)\n\n-- Pre-division.\n\n_\\\\_ : Pred (A × C) ℓ₁ → Pred (A × B) ℓ₂ → Pred (B × C) _\nP \\\\ Q = (P ~ // Q ~) ~\n", "meta": {"hexsha": "ffee3d05c8f60b6cd5d574a4a1d25a78833f83c6", "size": 6387, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Relation/Unary.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Relation/Unary.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Relation/Unary.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 21.432885906, "max_line_length": 72, "alphanum_fraction": 0.4933458588, "num_tokens": 2554, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006919925839875, "lm_q2_score": 0.8104789063814617, "lm_q1q2_score": 0.6489439704978636}} {"text": "------------------------------------------------------------------------\n-- Lists where all elements satisfy a given property\n------------------------------------------------------------------------\n\nmodule Data.List.All where\n\nopen import Data.Function\nopen import Data.List as List hiding (map; all)\nopen import Data.List.Any as Any using (here; there)\nopen Any.Membership-≡ using (_∈_; _⊆_)\nopen import Data.Product as Prod using (_,_)\nopen import Relation.Nullary\nimport Relation.Nullary.Decidable as Dec\nopen import Relation.Unary using (Pred) renaming (_⊆_ to _⋐_)\nopen import Relation.Binary.PropositionalEquality\n\n-- All P xs means that all elements in xs satisfy P.\n\ninfixr 5 _∷_\n\ndata All {A} (P : A → Set) : List A → Set where\n [] : All P []\n _∷_ : ∀ {x xs} (px : P x) (pxs : All P xs) → All P (x ∷ xs)\n\nhead : ∀ {A} {P : A → Set} {x xs} → All P (x ∷ xs) → P x\nhead (px ∷ pxs) = px\n\ntail : ∀ {A} {P : A → Set} {x xs} → All P (x ∷ xs) → All P xs\ntail (px ∷ pxs) = pxs\n\nlookup : ∀ {A} {P : A → Set} {xs} → All P xs → (∀ {x} → x ∈ xs → P x)\nlookup [] ()\nlookup (px ∷ pxs) (here refl) = px\nlookup (px ∷ pxs) (there x∈xs) = lookup pxs x∈xs\n\ntabulate : ∀ {A} {P : A → Set} {xs} → (∀ {x} → x ∈ xs → P x) → All P xs\ntabulate {xs = []} hyp = []\ntabulate {xs = x ∷ xs} hyp = hyp (here refl) ∷ tabulate (hyp ∘ there)\n\nmap : ∀ {A} {P Q : Pred A} → P ⋐ Q → All P ⋐ All Q\nmap g [] = []\nmap g (px ∷ pxs) = g px ∷ map g pxs\n\nall : ∀ {A} {P : A → Set} →\n (∀ x → Dec (P x)) → (xs : List A) → Dec (All P xs)\nall p [] = yes []\nall p (x ∷ xs) with p x\nall p (x ∷ xs) | yes px = Dec.map (_∷_ px , tail) (all p xs)\nall p (x ∷ xs) | no ¬px = no (¬px ∘ head)\n", "meta": {"hexsha": "cad0e3d2a8a02b40a1a2339788ac29a433bd8f5a", "size": 1680, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Data/List/All.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Data/List/All.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Data/List/All.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 33.6, "max_line_length": 72, "alphanum_fraction": 0.5119047619, "num_tokens": 599, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8991213718636754, "lm_q2_score": 0.7217432182679956, "lm_q1q2_score": 0.6489347525424243}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Level using (Level)\n\nopen import Data.List using (List; sum) renaming ([] to []ᴸ; _∷_ to _∷ᴸ_)\nopen import Data.Nat using (ℕ; _+_; zero; suc)\nopen import Data.Vec using (Vec; _++_; take; drop) renaming ([] to []ⱽ; _∷_ to _∷ⱽ_)\nopen import Data.Product as Prod using (∃; ∃₂; _×_; _,_)\n\nmodule FLA.Data.VectorList where\n\n-- At the moment, `VectorList` is named `RList` in the Haskell code.\ndata VectorList (A : Set) : List ℕ → Set where\n []ⱽᴸ : VectorList A []ᴸ\n _∷ⱽᴸ_ : {n : ℕ} {ns : List ℕ} → Vec A n → VectorList A ns\n → VectorList A (n ∷ᴸ ns)\ninfixr 5 _∷ⱽᴸ_\n\nconcat : {A : Set} {ns : List ℕ} → VectorList A ns → Vec A (sum ns)\nconcat []ⱽᴸ = []ⱽ\nconcat (v ∷ⱽᴸ vs) = v ++ concat vs\n\n-- We will want to use split to split a VectorList\nsplit : {ℓ : Level} {A : Set ℓ} → {m n : ℕ} → Vec A (m + n) → Vec A m × Vec A n\nsplit {ℓ} {A} {zero} {n} v = []ⱽ , v\nsplit {ℓ} {A} {suc m} {n} (v ∷ⱽ vs) = let v₁ , v₂ = split vs in v ∷ⱽ v₁ , v₂\n\n-- split' : {ℓ : Level} {A : Set ℓ} → {m n : ℕ} → Vec A (m + n) → Vec A m × Vec A n\n-- split' {ℓ} {A} {m} {n} v = (take v , drop v)\n\n-- Hmm, this will be hard to translate to Haskell, since we match on ns\nsplitToVectorList : {A : Set} → (ns : List ℕ) → Vec A (sum ns) → VectorList A ns\nsplitToVectorList []ᴸ v = []ⱽᴸ\nsplitToVectorList (_ ∷ᴸ ns) v = let v₁ , v₂ = split v in\n v₁ ∷ⱽᴸ (splitToVectorList ns v₂)\n\n", "meta": {"hexsha": "7478834529dc4af2f91b481bf0fcb737c04f045f", "size": 1451, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/FLA/Data/VectorList.agda", "max_stars_repo_name": "turion/functional-linear-algebra", "max_stars_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 21, "max_stars_repo_stars_event_min_datetime": "2020-09-22T20:49:34.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-07T05:28:00.000Z", "max_issues_repo_path": "src/FLA/Data/VectorList.agda", "max_issues_repo_name": "turion/functional-linear-algebra", "max_issues_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2020-09-01T01:42:12.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-07T05:27:53.000Z", "max_forks_repo_path": "src/FLA/Data/VectorList.agda", "max_forks_repo_name": "turion/functional-linear-algebra", "max_forks_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-04-12T20:34:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-07T19:55:59.000Z", "avg_line_length": 39.2162162162, "max_line_length": 84, "alphanum_fraction": 0.5706409373, "num_tokens": 599, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289388252252041, "lm_q2_score": 0.7826624688140726, "lm_q1q2_score": 0.6487793074465953}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.NaturalTransformation.Core where\n\nopen import Level\n\nopen import Categories.Category\nopen import Categories.Functor renaming (id to idF)\nopen import Categories.Functor.Properties\nimport Categories.Morphism as Morphism\nimport Categories.Morphism.Reasoning as MR\n\nprivate\n variable\n o ℓ e o′ ℓ′ e′ : Level\n C D E : Category o ℓ e\n\nrecord NaturalTransformation {C : Category o ℓ e}\n {D : Category o′ ℓ′ e′}\n (F G : Functor C D) : Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where\n eta-equality\n private\n module F = Functor F\n module G = Functor G\n open F using (F₀; F₁)\n open Category D hiding (op)\n\n field\n η : ∀ X → D [ F₀ X , G.F₀ X ]\n commute : ∀ {X Y} (f : C [ X , Y ]) → η Y ∘ F₁ f ≈ G.F₁ f ∘ η X\n -- We introduce an extra proof to ensure the opposite of the opposite of a natural\n -- transformation is definitionally equal to itself.\n sym-commute : ∀ {X Y} (f : C [ X , Y ]) → G.F₁ f ∘ η X ≈ η Y ∘ F₁ f\n\n op : NaturalTransformation G.op F.op\n op = record\n { η = η\n ; commute = sym-commute\n ; sym-commute = commute\n }\n\n-- Just like `Category`, we introduce a helper definition to ease the actual\n-- construction of a natural transformation.\nrecord NTHelper {C : Category o ℓ e}\n {D : Category o′ ℓ′ e′}\n (F G : Functor C D) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where\n private\n module G = Functor G\n open Functor F using (F₀; F₁)\n open Category D hiding (op)\n field\n η : ∀ X → D [ F₀ X , G.F₀ X ]\n commute : ∀ {X Y} (f : C [ X , Y ]) → η Y ∘ F₁ f ≈ G.F₁ f ∘ η X\n\nntHelper : ∀ {F G : Functor C D} → NTHelper F G → NaturalTransformation F G\nntHelper {D = D} α = record\n { η = η\n ; commute = commute\n ; sym-commute = λ f → Equiv.sym (commute f)\n }\n where open NTHelper α\n open Category D\n\nid : ∀ {F : Functor C D} → NaturalTransformation F F\nid {D = D} = ntHelper record\n { η = λ _ → D.id\n ; commute = λ _ → D.identityˡ ○ ⟺ D.identityʳ\n }\n where\n module D = Category D\n open D.HomReasoning\n\ninfixr 9 _∘ᵥ_ _∘ₕ_ _∘ˡ_ _∘ʳ_\n\n-- \"Vertical composition\"\n_∘ᵥ_ : ∀ {F G H : Functor C D} →\n NaturalTransformation G H → NaturalTransformation F G → NaturalTransformation F H\n_∘ᵥ_ {C = C} {D = D} {F} {G} {H} X Y = ntHelper record\n { η = λ q → D [ X.η q ∘ Y.η q ]\n ; commute = λ f → glue (X.commute f) (Y.commute f)\n }\n where module X = NaturalTransformation X\n module Y = NaturalTransformation Y\n open MR D\n\n-- \"Horizontal composition\"\n_∘ₕ_ : ∀ {F G : Functor C D} {H I : Functor D E} →\n NaturalTransformation H I → NaturalTransformation F G → NaturalTransformation (H ∘F F) (I ∘F G)\n_∘ₕ_ {E = E} {F} {I = I} Y X = ntHelper record\n { η = λ q → E [ I₁ (X.η q) ∘ Y.η (F.F₀ q) ]\n ; commute = λ f → glue ([ I ]-resp-square (X.commute f)) (Y.commute (F.F₁ f))\n }\n where module F = Functor F\n module X = NaturalTransformation X\n module Y = NaturalTransformation Y\n open Functor I renaming (F₀ to I₀; F₁ to I₁)\n open MR E\n\n_∘ˡ_ : ∀ {G H : Functor C D} (F : Functor D E) → NaturalTransformation G H → NaturalTransformation (F ∘F G) (F ∘F H)\n_∘ˡ_ F α = ntHelper record\n { η = λ X → F₁ (η X)\n ; commute = λ f → [ F ]-resp-square (commute f)\n }\n where open Functor F\n open NaturalTransformation α\n\n_∘ʳ_ : ∀ {G H : Functor D E} → NaturalTransformation G H → (F : Functor C D) → NaturalTransformation (G ∘F F) (H ∘F F)\n_∘ʳ_ {D = D} {E = E} {G = G} {H = H} α F = ntHelper record\n { η = λ X → η (F₀ X)\n ; commute = λ f → commute (F₁ f)\n }\n where open Functor F\n open NaturalTransformation α\n\nid∘id⇒id : {C : Category o ℓ e} → NaturalTransformation {C = C} {D = C} (idF ∘F idF) idF\nid∘id⇒id {C = C} = ntHelper record { η = λ _ → Category.id C ; commute = λ f → MR.id-comm-sym C {f = f} }\n\nid⇒id∘id : {C : Category o ℓ e} → NaturalTransformation {C = C} {D = C} idF (idF ∘F idF)\nid⇒id∘id {C = C} = ntHelper record { η = λ _ → Category.id C ; commute = λ f → MR.id-comm-sym C {f = f} }\n\nmodule _ {F : Functor C D} where\n open Category.HomReasoning D\n open Functor F\n open Category D\n open MR D\n private module D = Category D\n\n F⇒F∘id : NaturalTransformation F (F ∘F idF)\n F⇒F∘id = ntHelper record { η = λ _ → D.id ; commute = λ _ → id-comm-sym }\n\n F⇒id∘F : NaturalTransformation F (idF ∘F F)\n F⇒id∘F = ntHelper record { η = λ _ → D.id ; commute = λ _ → id-comm-sym }\n\n F∘id⇒F : NaturalTransformation (F ∘F idF) F\n F∘id⇒F = ntHelper record { η = λ _ → D.id ; commute = λ _ → id-comm-sym }\n\n id∘F⇒F : NaturalTransformation (idF ∘F F) F\n id∘F⇒F = ntHelper record { η = λ _ → D.id ; commute = λ _ → id-comm-sym }\n", "meta": {"hexsha": "2ca779fca16d55a29a990f0c7954af7a4b33baa6", "size": 4745, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/NaturalTransformation/Core.agda", "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/NaturalTransformation/Core.agda", "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/NaturalTransformation/Core.agda", "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.1366906475, "max_line_length": 118, "alphanum_fraction": 0.5839831401, "num_tokens": 1725, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289387998695208, "lm_q2_score": 0.7826624840223698, "lm_q1q2_score": 0.6487793002084012}} {"text": "{-# OPTIONS --without-K --safe #-}\n\n-- Categorical equivalences preserve various structures\n\nmodule Categories.Category.Equivalence.Preserves where\n\nopen import Level\n\nopen import Categories.Adjoint.Equivalence using (⊣Equivalence)\nopen import Categories.Category.Core\nopen import Categories.Category.Equivalence using (WeakInverse; StrongEquivalence)\nopen import Categories.Category.Equivalence.Properties using (C≅D)\nopen import Categories.Diagram.Duality\nopen import Categories.Functor.Core\nopen import Categories.Morphism\nimport Categories.Morphism.Reasoning as MR\nopen import Categories.NaturalTransformation.NaturalIsomorphism.Properties\nopen import Categories.Object.Initial\nopen import Categories.Object.Terminal\nopen import Categories.Object.Duality\n\nprivate\n variable\n o ℓ e o′ ℓ′ e′ : Level\n C : Category o ℓ e\n D : Category o′ ℓ′ e′\n\nmodule _ (S : StrongEquivalence C D) where\n open StrongEquivalence S\n open IsInitial\n private\n module C = Category C\n module D = Category D\n module F = Functor F\n module G = Functor G\n X : ⊣Equivalence C D\n X = C≅D S\n\n -- see below the proof for the abbreviations that make the proof readable\n pres-IsInitial : {c : C.Obj} (i : IsInitial C c) → IsInitial D (F.₀ c)\n pres-IsInitial {c} i = record\n { ! = λ {A} → F∘G≈id.⇒.η A D.∘ F.₁ (! i)\n ; !-unique = λ {A} f → begin {- f : F.₀ c D.⇒ A -}\n FG⇒ A D.∘ F.₁ (! i) ≈⟨ (refl⟩∘⟨ F.F-resp-≈ (!-unique i _)) ⟩\n FG⇒ A D.∘ F.₁ ((G.₁ f C.∘ GF⇒) C.∘ G.₁ FG⇐′ C.∘ GF⇐) ≈⟨ (refl⟩∘⟨ F.homomorphism) ⟩\n FG⇒ A D.∘ F.₁ (G.₁ f C.∘ GF⇒) D.∘ F.₁ (G.₁ FG⇐′ C.∘ GF⇐) ≈⟨ (refl⟩∘⟨ refl⟩∘⟨ (F.homomorphism ○ (D.Equiv.sym (F≃id-comm₂ F∘G≈id) ⟩∘⟨refl))) ⟩\n FG⇒ A D.∘ F.₁ (G.₁ f C.∘ GF⇒) D.∘ FG⇐ D.∘ F.F₁ GF⇐ ≈⟨ (refl⟩∘⟨ F.homomorphism ⟩∘⟨refl) ⟩\n FG⇒ A D.∘ (F.₁ (G.₁ f) D.∘ F.₁ GF⇒) D.∘ (FG⇐ D.∘ F.F₁ GF⇐) ≈⟨ (D.sym-assoc ○ (D.sym-assoc ⟩∘⟨refl) ○ D.assoc) ⟩\n (FG⇒ A D.∘ F.₁ (G.₁ f)) D.∘ F.F₁ GF⇒ D.∘ FG⇐ D.∘ F.F₁ GF⇐ ≈⟨ (F∘G≈id.⇒.commute f ⟩∘⟨ D.sym-assoc) ⟩\n (f D.∘ FG⇒ (F.₀ c)) D.∘ (F.F₁ GF⇒ D.∘ FG⇐) D.∘ F.F₁ GF⇐ ≈⟨ (D.assoc ○ (refl⟩∘⟨ D.sym-assoc)) ⟩\n f D.∘ (FG⇒ (F.₀ c) D.∘ F.F₁ GF⇒ D.∘ FG⇐) D.∘ F.F₁ GF⇐ ≈⟨ elimʳ (⊣Equivalence.zig X) ⟩\n f ∎\n }\n where\n open D.HomReasoning\n open MR D\n FG⇒ : (A : D.Obj) → F.₀ (G.₀ A) D.⇒ A\n FG⇒ A = F∘G≈id.⇒.η A\n FG⇐ = F∘G≈id.⇐.η (F.F₀ (G.F₀ (F.F₀ c)))\n FG⇐′ = F∘G≈id.⇐.η (F.₀ c)\n GF⇐ : c C.⇒ G.₀ (F.₀ c)\n GF⇐ = G∘F≈id.⇐.η c\n GF⇒ = G∘F≈id.⇒.η (G.F₀ (F.F₀ c))\n\n pres-Initial : Initial C → Initial D\n pres-Initial i = record { ⊥ = F.₀ ⊥ ; ⊥-is-initial = pres-IsInitial ⊥-is-initial }\n where open Initial i\n\n-- We can do the other proof by duality\npres-terminal : {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (S : StrongEquivalence C D) {c : Category.Obj C} → (t : IsTerminal C c) → IsTerminal D (Functor.F₀ (StrongEquivalence.F S) c)\npres-terminal {C = C} {D} S {c} t = IsInitial⇒coIsTerminal (Category.op D) (pres-IsInitial Sop (coIsTerminal⇒IsInitial (Category.op C) t))\n where\n Sop : StrongEquivalence (Category.op C) (Category.op D)\n Sop = StrongEquivalence.op S\n\npres-Terminal : {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (S : StrongEquivalence C D) (t : Terminal C) → Terminal D\npres-Terminal S t = record { ⊤ = Functor.F₀ F ⊤; ⊤-is-terminal = pres-terminal S ⊤-is-terminal}\n where\n open Terminal t\n open StrongEquivalence S\n", "meta": {"hexsha": "92e9728e07ca712014d07dd152bc61818198a4c4", "size": 3458, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Equivalence/Preserves.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/Equivalence/Preserves.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/Equivalence/Preserves.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 42.6913580247, "max_line_length": 186, "alphanum_fraction": 0.5951417004, "num_tokens": 1512, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289388083214156, "lm_q2_score": 0.7826624738835052, "lm_q1q2_score": 0.6487792984188839}} {"text": "\n-- You can have infix declarations in records.\n\nmodule InfixRecordFields where\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\ninfixl 50 _+_\n_+_ : Nat -> Nat -> Nat\nzero + m = m\nsuc n + m = suc (n + m)\n\ndata _==_ {A : Set}(x : A) : A -> Set where\n refl : x == x\n\none = suc zero\ntwo = suc (suc zero)\n\nrecord A : Set where\n field x : Nat\n _*_ : Nat -> Nat -> Nat\n h : (one + one * x) == one -- later fields make use of the fixity\n infixl 60 _*_\n\na : A\na = record { x = zero; _*_ = \\ x y -> y; h = refl }\n\nopen module X = A a\n\n-- The projection functions also have the right fixity.\np : (one + one * zero) == one\np = refl\n\n", "meta": {"hexsha": "da804f51de6e7b4911105d4ddeb269c586cd5cbd", "size": 652, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/InfixRecordFields.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/InfixRecordFields.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/InfixRecordFields.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 18.1111111111, "max_line_length": 76, "alphanum_fraction": 0.5628834356, "num_tokens": 225, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9407897442783527, "lm_q2_score": 0.6893056295505783, "lm_q1q2_score": 0.6484916669545174}} {"text": "-- Copyright: (c) 2016 Ertugrul Söylemez\n-- License: BSD3\n-- Maintainer: Ertugrul Söylemez \n\nmodule Algebra.Category.Groupoid where\n\nopen import Algebra.Category.Category\nopen import Core\n\n\n-- A groupoid is a category where all morphisms are isomorphisms.\n\nrecord Groupoid {c h r} : Set (lsuc (c ⊔ h ⊔ r)) where\n field category : Category {c} {h} {r}\n open Category category public\n\n field iso : ∀ {A B} (f : Hom A B) → Iso f\n open module MyIso {A B} (f : Hom A B) = Iso (iso f) public\n using (inv; left-inv; right-inv; inv-unique)\n\n field\n inv-cong : ∀ {A B} {f g : Hom A B} → f ≈ g → inv f ≈ inv g\n\n -- The inverse function is an involution.\n inv-invol : ∀ {A B} {f : Hom A B} → inv (inv f) ≈ f\n inv-invol {f = f} =\n begin\n inv (inv f) ≈[ sym (right-id _) ]\n inv (inv f) ∘ id ≈[ ∘-cong refl (sym (left-inv _)) ]\n inv (inv f) ∘ (inv f ∘ f) ≈[ sym (assoc _ _ _) ]\n (inv (inv f) ∘ inv f) ∘ f ≈[ ∘-cong (left-inv _) refl ]\n id ∘ f ≈[ left-id _ ]\n f\n qed\n", "meta": {"hexsha": "198fba3577418100b6325cc9da5fe3334e89241d", "size": 1066, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Algebra/Category/Groupoid.agda", "max_stars_repo_name": "esoeylemez/agda-simple", "max_stars_repo_head_hexsha": "d9245e5a8b2e902781736de09bd17e81022f6f13", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-10-07T17:36:42.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-07T17:36:42.000Z", "max_issues_repo_path": "Algebra/Category/Groupoid.agda", "max_issues_repo_name": "esoeylemez/agda-simple", "max_issues_repo_head_hexsha": "d9245e5a8b2e902781736de09bd17e81022f6f13", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Algebra/Category/Groupoid.agda", "max_forks_repo_name": "esoeylemez/agda-simple", "max_forks_repo_head_hexsha": "d9245e5a8b2e902781736de09bd17e81022f6f13", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.4571428571, "max_line_length": 67, "alphanum_fraction": 0.5572232645, "num_tokens": 384, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9230391643039738, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.6484627628253068}} {"text": "------------------------------------------------------------------------------\n-- Propositional equality\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- Tested with the development version of Agda on 15 June 2012.\n\nmodule FOT.Agsy.NoStd.MyPropositionalEquality where\n\n-- We add 3 to the fixities of the Agda standard library 0.8.1 (see\n-- Relation/Binary/Core.agda).\ninfix 7 _≡_\n\n------------------------------------------------------------------------------\n\ndata _≡_ {A : Set}(x : A) : A → Set where\n refl : x ≡ x\n\n-- Identity properties\n\nsym : ∀ {A} → {x y : A} → x ≡ y → y ≡ x\nsym refl = refl\n\ntrans : ∀ {A} → {x y z : A} → x ≡ y → y ≡ z → x ≡ z\ntrans refl y≡z = y≡z\n\ncong : {A B : Set} (f : A → B) → ∀ {x y} → x ≡ y → f x ≡ f y\ncong f refl = refl\n\nmodule ≡-Reasoning where\n -- We add 3 to the fixities of the Agda standard library 0.8.1 (see\n -- Relation/Binary/PreorderReasoning.agda).\n infix 7 _≃_\n infix 4 begin_\n infixr 5 _≡⟨_⟩_\n infix 6 _∎\n\n ----------------------------------------------------------------------------\n -- Adapted from the Agda standard library 0.8.1 (see\n -- Relation/Binary/PreorderReasoning.agda).\n private\n data _≃_ {A : Set}(x y : A) : Set where\n prf : x ≡ y → x ≃ y\n\n begin_ : {A : Set}{x y : A} → x ≃ y → x ≡ y\n begin prf x≡y = x≡y\n\n _≡⟨_⟩_ : {A : Set}(x : A){y z : A} → x ≡ y → y ≃ z → x ≃ z\n _ ≡⟨ x≡y ⟩ prf y≡z = prf (trans x≡y y≡z)\n\n _∎ : {A : Set}(x : A) → x ≃ x\n _∎ _ = prf refl\n", "meta": {"hexsha": "40474964409be21fdda7f556a396e0a38fc75f83", "size": 1654, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/Agsy/NoStd/MyPropositionalEquality.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/FOT/Agsy/NoStd/MyPropositionalEquality.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/FOT/Agsy/NoStd/MyPropositionalEquality.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 29.0175438596, "max_line_length": 78, "alphanum_fraction": 0.4467956469, "num_tokens": 556, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744850834648, "lm_q2_score": 0.7931059560743422, "lm_q1q2_score": 0.6484231936541094}} {"text": "module plfa.part1.Naturals where\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\nseven = suc (suc (suc (suc (suc (suc (suc zero))))))\n\n{-# BUILTIN NATURAL ℕ #-}\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎)\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\n(suc m) + n = suc (m + n)\n\n_ : 2 + 3 ≡ 5\n_ =\n begin\n 2 + 3\n ≡⟨⟩ -- is shorthand for\n (suc (suc zero)) + (suc (suc (suc zero)))\n ≡⟨⟩ -- inductive case\n suc ((suc zero) + (suc (suc (suc zero))))\n ≡⟨⟩ -- inductive case\n suc (suc (zero + (suc (suc (suc zero)))))\n ≡⟨⟩ -- base case\n suc (suc (suc (suc (suc zero))))\n ≡⟨⟩ -- is longhand for\n 5\n ∎\n\n_*_ : ℕ → ℕ → ℕ\nzero * n = zero\n(suc m) * n = n + (m * n)\n\n_̂_ : ℕ → ℕ → ℕ\nn ̂ zero = 1\nn ̂ (suc m) = n * (n ̂ m)\n\n_ : 3 ̂ 4 ≡ 81\n_ =\n begin\n 3 ̂ 4\n ≡⟨⟩\n 81 \n ∎\n\n_∸_ : ℕ → ℕ → ℕ\nm ∸ zero = m\nzero ∸ suc n = zero\nsuc m ∸ suc n = m ∸ n\n", "meta": {"hexsha": "8dc5e7fd843bee4768b8df42816faeafbdd5eba1", "size": 959, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "plfa/part1/Naturals.agda", "max_stars_repo_name": "UnsoundWitch/proofs", "max_stars_repo_head_hexsha": "275ecc582b3a6a1da1af387251c6b4d74d9a5203", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2021-01-03T03:29:40.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-18T10:58:03.000Z", "max_issues_repo_path": "plfa/part1/Naturals.agda", "max_issues_repo_name": "sym-cereal/proofs", "max_issues_repo_head_hexsha": "275ecc582b3a6a1da1af387251c6b4d74d9a5203", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "plfa/part1/Naturals.agda", "max_forks_repo_name": "sym-cereal/proofs", "max_forks_repo_head_hexsha": "275ecc582b3a6a1da1af387251c6b4d74d9a5203", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.4363636364, "max_line_length": 52, "alphanum_fraction": 0.4786235662, "num_tokens": 463, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473746782093, "lm_q2_score": 0.7431680029241321, "lm_q1q2_score": 0.6483006562957144}} {"text": "{-# OPTIONS --universe-polymorphism #-}\nmodule Graphs.Graph where\n\nopen import Level\nopen import Categories.Support.Equivalence\nopen import Relation.Binary\n using (Rel; IsEquivalence; module IsEquivalence; Reflexive; Symmetric; Transitive)\n renaming (_⇒_ to _⊆_)\nopen import Relation.Binary.PropositionalEquality\n using ()\n renaming (_≡_ to _≣_)\n\nrecord Graph (o ℓ e : Level) : Set (suc (o ⊔ ℓ ⊔ e)) where\n field\n Obj : Set o\n _↝_ : Obj → Obj → Set ℓ\n _≈_ : {A B : Obj} → Rel (A ↝ B) e\n .equiv : ∀ {A B : Obj} → IsEquivalence (_≈_ {A}{B})\n \n edge-setoid : ∀ {A B : Obj} → Setoid ℓ e\n edge-setoid {A}{B} = record\n { Carrier = A ↝ B\n ; _≈_ = _≈_\n ; isEquivalence = equiv\n }\n \n module Equiv {A B : Obj} where\n private\n module e = IsEquivalence\n .q : IsEquivalence _≈_\n q = equiv {A} {B}\n\n .refl : Reflexive _≈_\n refl = e.refl q\n .trans : Transitive _≈_\n trans = e.trans q\n .sym : Symmetric _≈_\n sym = e.sym q\n .reflexive : _≣_ ⊆ _≈_\n reflexive = e.reflexive q\n\n_[_↝_] : ∀ {o ℓ e} → (G : Graph o ℓ e) → Graph.Obj G → Graph.Obj G → Set ℓ\nG [ A ↝ B ] = Graph._↝_ G A B\n\n_[_≈_] : ∀ {o ℓ e} → (G : Graph o ℓ e) → {A B : Graph.Obj G} → Rel (G [ A ↝ B ]) e\nG [ f ≈ g ] = Graph._≈_ G f g\n\nmodule Heterogeneous {o ℓ e} (G : Graph o ℓ e) where\n open Graph G\n open Equiv renaming (refl to refl′; sym to sym′; trans to trans′)\n\n data _~_ {A B} (f : A ↝ B) : ∀ {X Y} → (X ↝ Y) → Set (ℓ ⊔ e) where\n ≈⇒~ : {g : A ↝ B} → .(f ≈ g) → f ~ g\n\n refl : ∀ {A B} {f : A ↝ B} → f ~ f\n refl = ≈⇒~ refl′\n\n sym : ∀ {A B} {f : A ↝ B} {D E} {g : D ↝ E} → f ~ g → g ~ f\n sym (≈⇒~ f≈g) = ≈⇒~ (sym′ f≈g)\n\n trans : ∀ {A B} {f : A ↝ B} \n {D E} {g : D ↝ E}\n {F G} {h : F ↝ G}\n → f ~ g → g ~ h → f ~ h\n trans (≈⇒~ f≈g) (≈⇒~ g≈h) = ≈⇒~ (trans′ f≈g g≈h)\n\n_[_~_] : ∀ {o ℓ e} (G : Graph o ℓ e) {A B} (f : G [ A ↝ B ]) {X Y} (g : G [ X ↝ Y ]) → Set (ℓ ⊔ e)\nG [ f ~ g ] = Heterogeneous._~_ G f g", "meta": {"hexsha": "89c9d2825d4d0f93a878567befadeb7bf5777ec0", "size": 1999, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Graphs/Graph.agda", "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 98, "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_issues_repo_path": "Graphs/Graph.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_forks_repo_path": "Graphs/Graph.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 23, "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "avg_line_length": 29.3970588235, "max_line_length": 98, "alphanum_fraction": 0.4932466233, "num_tokens": 887, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473614033683, "lm_q2_score": 0.7431680029241321, "lm_q1q2_score": 0.6483006464302774}} {"text": "-- Agda Sample File\n-- https://github.com/agda/agda/blob/master/examples/syntax/highlighting/Test.agda\n\n-- This test file currently lacks module-related stuff.\n\n{- Nested\n {- comment. -} -}\n\nmodule Test where\n\ninfix 12 _!\ninfixl 7 _+_ _-_\ninfixr 2 -_\n\npostulate x : Set\n\nf : (Set -> Set -> Set) -> Set\nf _*_ = x * x\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ -> ℕ\n\n_+_ : ℕ -> ℕ -> ℕ\nzero + n = n\nsuc m + n = suc (m + n)\n\npostulate _-_ : ℕ -> ℕ -> ℕ\n\n-_ : ℕ -> ℕ\n- n = n\n\n_! : ℕ -> ℕ\nzero ! = suc zero\nsuc n ! = n - n !\n\nrecord Equiv {a : Set} (_≈_ : a -> a -> Set) : Set where\n field\n refl : forall x -> x ≈ x\n sym : {x y : a} -> x ≈ y -> y ≈ x\n _`trans`_ : forall {x y z} -> x ≈ y -> y ≈ z -> x ≈ z\n\ndata _≡_ {a : Set} (x : a) : a -> Set where\n refl : x ≡ x\n\nsubst : forall {a x y} ->\n (P : a -> Set) -> x ≡ y -> P x -> P y\nsubst {x = x} .{y = x} _ refl p = p\n\nEquiv-≡ : forall {a} -> Equiv {a} _≡_\nEquiv-≡ {a} =\n record { refl = \\_ -> refl\n ; sym = sym\n ; _`trans`_ = _`trans`_\n }\n where\n sym : {x y : a} -> x ≡ y -> y ≡ x\n sym refl = refl\n\n _`trans`_ : {x y z : a} -> x ≡ y -> y ≡ z -> x ≡ z\n refl `trans` refl = refl\n\npostulate\n String : Set\n Char : Set\n Float : Set\n\ndata Int : Set where\n pos : ℕ → Int\n negsuc : ℕ → Int\n\n{-# BUILTIN STRING String #-}\n{-# BUILTIN CHAR Char #-}\n{-# BUILTIN FLOAT Float #-}\n\n{-# BUILTIN NATURAL ℕ #-}\n\n{-# BUILTIN INTEGER Int #-}\n{-# BUILTIN INTEGERPOS pos #-}\n{-# BUILTIN INTEGERNEGSUC negsuc #-}\n\ndata [_] (a : Set) : Set where\n [] : [ a ]\n _∷_ : a -> [ a ] -> [ a ]\n\n{-# BUILTIN LIST [_] #-}\n{-# BUILTIN NIL [] #-}\n{-# BUILTIN CONS _∷_ #-}\n\nprimitive\n primStringToList : String -> [ Char ]\n\nstring : [ Char ]\nstring = primStringToList \"∃ apa\"\n\nchar : Char\nchar = '∀'\n\nanotherString : String\nanotherString = \"¬ be\\\n \\pa\"\n\nnat : ℕ\nnat = 45\n\nfloat : Float\nfloat = 45.0e-37\n\n-- Testing qualified names.\n\nopen import Test\nEq = Test.Equiv {Test.ℕ}\n", "meta": {"hexsha": "0b33568ca3f83047721432ed58c38564fd5172ad", "size": 2012, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "autotests/input/test.agda", "max_stars_repo_name": "dawidsowa/syntax-highlighting", "max_stars_repo_head_hexsha": "5ed3cf60fe0829b9c84698248e73e7e3306def5f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "autotests/input/test.agda", "max_issues_repo_name": "dawidsowa/syntax-highlighting", "max_issues_repo_head_hexsha": "5ed3cf60fe0829b9c84698248e73e7e3306def5f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "autotests/input/test.agda", "max_forks_repo_name": "dawidsowa/syntax-highlighting", "max_forks_repo_head_hexsha": "5ed3cf60fe0829b9c84698248e73e7e3306def5f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.8053097345, "max_line_length": 82, "alphanum_fraction": 0.5034791252, "num_tokens": 748, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473614033683, "lm_q2_score": 0.743167997235783, "lm_q1q2_score": 0.648300641468061}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Interleavings of lists using setoid equality\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary using (Setoid)\n\nmodule Data.List.Relation.Ternary.Interleaving.Setoid {c ℓ} (S : Setoid c ℓ) where\n\nopen import Level using (_⊔_)\nopen import Data.List.Base as List using (List; []; _∷_)\nopen import Data.List.Relation.Ternary.Interleaving.Properties\nimport Data.List.Relation.Ternary.Interleaving as General\nopen Setoid S renaming (Carrier to A)\n\n------------------------------------------------------------------------\n-- Definition\n\nInterleaving : List A → List A → List A → Set (c ⊔ ℓ)\nInterleaving = General.Interleaving _≈_ _≈_\n\n------------------------------------------------------------------------\n-- Re-export the basic combinators\n\nopen General hiding (Interleaving) public\n", "meta": {"hexsha": "7a7e4c38af2e24f3ef077ae25f59374ec6aef65e", "size": 976, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Ternary/Interleaving/Setoid.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Ternary/Interleaving/Setoid.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Ternary/Interleaving/Setoid.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 33.6551724138, "max_line_length": 82, "alphanum_fraction": 0.5245901639, "num_tokens": 194, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8688267898240861, "lm_q2_score": 0.7461389986757757, "lm_q1q2_score": 0.6482655509820322}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Groups.Definition\nopen import Groups.Abelian.Definition\nopen import Setoids.Setoids\nopen import Rings.Definition\nopen import Modules.Definition\n\n\nmodule Modules.DirectSum {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+R_ : A → A → A} {_*R_ : A → A → A} (R : Ring S _+R_ _*R_) {m n o p : _} {M : Set m} {T : Setoid {m} {n} M} {_+_ : M → M → M} {G' : Group T _+_} {G : AbelianGroup G'} {_·1_ : A → M → M} {N : Set o} {U : Setoid {o} {p} N} {_+'_ : N → N → N} {H' : Group U _+'_} {H : AbelianGroup H'} {_·2_ : A → N → N} (M1 : Module R G _·1_) (M2 : Module R H _·2_) where\n\nopen import Groups.Abelian.DirectSum G H\nopen import Setoids.Product T U\n\ndirectSumModule : Module R directSumAbGroup λ r mn → ((r ·1 (_&&_.fst mn)) ,, (r ·2 (_&&_.snd mn)))\nModule.dotWellDefined directSumModule r=s t=u = productLift (Module.dotWellDefined M1 r=s (_&&_.fst t=u)) (Module.dotWellDefined M2 r=s (_&&_.snd t=u))\nModule.dotDistributesLeft directSumModule = productLift (Module.dotDistributesLeft M1) (Module.dotDistributesLeft M2)\nModule.dotDistributesRight directSumModule = productLift (Module.dotDistributesRight M1) (Module.dotDistributesRight M2)\nModule.dotAssociative directSumModule = productLift (Module.dotAssociative M1) (Module.dotAssociative M2)\nModule.dotIdentity directSumModule = productLift (Module.dotIdentity M1) (Module.dotIdentity M2)\n", "meta": {"hexsha": "bc3d54dff95b58fde16a7efebc2a863eb5e00542", "size": 1432, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Modules/DirectSum.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Modules/DirectSum.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Modules/DirectSum.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 65.0909090909, "max_line_length": 424, "alphanum_fraction": 0.6976256983, "num_tokens": 478, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.918480237330998, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.6482496055564432}} {"text": "{- Name: Bowornmet (Ben) Hudson\n\n--Complexity : \"Playing The Game\"--\n\n-}\n\nopen import Preliminaries\nopen import Preorder-withmax\n\nmodule Complexity-lang where\n\n data Typ : Set where\n nat : Typ\n _×'_ : Typ → Typ → Typ\n _⇒_ : Typ → Typ → Typ\n unit : Typ\n\n------------------------------------------\n\n -- represent a context as a list of types\n Ctx = List Typ\n\n -- de Bruijn indices (for free variables)\n data _∈_ : Typ → Ctx → Set where\n i0 : ∀ {Γ T}\n → T ∈ (T :: Γ)\n iS : ∀ {Γ T T1}\n → T ∈ Γ\n → T ∈ (T1 :: Γ)\n\n------------------------------------------\n\n -- some syntax\n data _|-_ : Ctx → Typ → Set where\n var : ∀ {Γ T}\n → (x : T ∈ Γ) → Γ |- T\n z : ∀ {Γ}\n → Γ |- nat\n suc : ∀ {Γ}\n → (e : Γ |- nat)\n → Γ |- nat\n rec : ∀ {Γ T}\n → (e : Γ |- nat)\n → (e0 : Γ |- T)\n → (e1 : (nat :: (T :: Γ)) |- T)\n → Γ |- T\n lam : ∀ {Γ T Ρ}\n → (x : (Ρ :: Γ) |- T)\n → Γ |- (Ρ ⇒ T)\n app : ∀ {Γ T1 T2}\n → (e1 : Γ |- (T2 ⇒ T1)) → (e2 : Γ |- T2)\n → Γ |- T1\n unit : ∀ {Γ}\n → Γ |- unit\n prod : ∀ {Γ T1 T2}\n → (e1 : Γ |- T1) → (e2 : Γ |- T2)\n → Γ |- (T1 ×' T2)\n l-proj : ∀ {Γ T1 T2}\n → (e : Γ |- (T1 ×' T2))\n → Γ |- T1\n r-proj : ∀ {Γ T1 T2}\n → (e : Γ |- (T1 ×' T2))\n → Γ |- T2\n\n------------------------------------------\n\n -- renaming function\n rctx : Ctx → Ctx → Set\n rctx Γ Γ' = ∀ {τ} → τ ∈ Γ' → τ ∈ Γ\n\n lem1 : ∀ {Γ Γ' τ} → rctx Γ Γ' → rctx (τ :: Γ) (τ :: Γ')\n lem1 d i0 = i0\n lem1 d (iS x) = iS (d x)\n\n ren : ∀ {Γ Γ' τ} → Γ' |- τ → rctx Γ Γ' → Γ |- τ\n ren (var x) d = var (d x)\n ren z d = z\n ren (suc e) d = suc (ren e d)\n ren (rec e0 e1 e2) d = rec (ren e0 d) (ren e1 d) (ren e2 (lem1 (lem1 d)))\n ren (lam x) d = lam (ren x (lem1 d))\n ren (app e1 e2) d = app (ren e1 d) (ren e2 d)\n ren unit d = unit\n ren (prod e1 e2) d = prod (ren e1 d) (ren e2 d)\n ren (l-proj e) d = l-proj (ren e d)\n ren (r-proj e) d = r-proj (ren e d)\n\n------------------------------------------\n\n -- substitution\n sctx : Ctx → Ctx → Set\n sctx Γ Γ' = ∀ {τ} → τ ∈ Γ' → Γ |- τ\n\n -- weakening\n wkn : ∀ {Γ τ1 τ2} → Γ |- τ2 → (τ1 :: Γ) |- τ2\n wkn e = ren e iS\n\n -- lemmas everywhere\n wkn-s : ∀ {Γ τ1 Γ'} → sctx Γ Γ' → sctx (τ1 :: Γ) Γ'\n wkn-s d = λ f → wkn (d f)\n\n wkn-r : ∀ {Γ τ1 Γ'} → rctx Γ Γ' → rctx (τ1 :: Γ) Γ'\n wkn-r d = λ x → iS (d x)\n\n lem2 : ∀ {Γ Γ' τ} → sctx Γ Γ' → sctx (τ :: Γ) (τ :: Γ')\n lem2 d i0 = var i0\n lem2 d (iS i) = wkn (d i)\n\n lem3 : ∀ {Γ τ} → Γ |- τ → sctx Γ (τ :: Γ)\n lem3 e i0 = e\n lem3 e (iS i) = var i\n\n lem4 : ∀ {Γ τ1 τ2} → Γ |- τ1 → Γ |- τ2 → sctx Γ (τ1 :: (τ2 :: Γ))\n lem4 e1 e2 i0 = e1\n lem4 e1 e2 (iS i0) = e2\n lem4 e1 e2 (iS (iS i)) = var i\n\n subst : ∀ {Γ Γ' τ} → sctx Γ Γ' → Γ' |- τ → Γ |- τ\n subst d (var x) = d x\n subst d z = z\n subst d (suc e) = suc (subst d e)\n subst d (rec e0 e1 e2) = rec (subst d e0) (subst d e1) (subst (lem2 (lem2 d)) e2)\n subst d (lam e) = lam (subst (lem2 d) e)\n subst d (app e1 e2) = app (subst d e1) (subst d e2)\n subst d unit = unit\n subst d (prod e1 e2) = prod (subst d e1) (subst d e2)\n subst d (l-proj e) = l-proj (subst d e)\n subst d (r-proj e) = r-proj (subst d e)\n\n------------------------------------------\n\n -- define 'stepping' as a datatype (fig. 1 of proof)\n data _≤s_ : ∀ {Γ T} → Γ |- T → Γ |- T → Set where\n refl-s : ∀ {Γ T}\n → (e : Γ |- T)\n → e ≤s e\n trans-s : ∀ {Γ T}\n → (e e' e'' : Γ |- T)\n → e ≤s e' → e' ≤s e''\n → e ≤s e''\n cong-s : ∀ {Γ T T'}\n → (e : (T :: Γ) |- T')\n → (e1 e2 : Γ |- T)\n → e1 ≤s e2\n → subst (lem3 e1) e ≤s subst (lem3 e2) e\n lam-s : ∀ {Γ T T'}\n → (e : (T :: Γ) |- T')\n → (e2 : Γ |- T)\n → subst (lem3 e2) e ≤s app (lam e) e2\n l-proj-s : ∀ {Γ T1 T2}\n → (e1 : Γ |- T1) → (e2 : Γ |- T2)\n → e1 ≤s (l-proj (prod e1 e2))\n r-proj-s : ∀ {Γ T1 T2}\n → (e1 : Γ |- T1) → (e2 : Γ |- T2)\n → e2 ≤s (r-proj (prod e1 e2))\n rec-steps-s : ∀ {Γ T}\n → (e : Γ |- nat)\n → (e0 : Γ |- T)\n → (e1 : (nat :: (T :: Γ)) |- T)\n → subst (lem4 e (rec e e0 e1)) e1 ≤s (rec (suc e) e0 e1)\n rec-steps-z : ∀ {Γ T}\n → (e0 : Γ |- T)\n → (e1 : (nat :: (T :: Γ)) |- T)\n → e0 ≤s (rec z e0 e1)\n\n------------------------------------------\n\n el : PREORDER → Set\n el = fst\n\n PREORDER≤ : (PA : PREORDER) → el PA → el PA → Set\n PREORDER≤ PA = Preorder-max-str.≤ (snd PA)\n\n interp : Typ → PREORDER\n interp nat = Nat , nat-p\n interp (A ×' B) = interp A ×p interp B\n interp (A ⇒ B) = interp A ->p interp B\n interp unit = unit-p\n\n interpC : Ctx → PREORDER\n interpC [] = unit-p\n interpC (A :: Γ) = interpC Γ ×p interp A\n\n -- look up a variable in context\n lookup : ∀{Γ τ} → τ ∈ Γ → el (interpC Γ ->p interp τ)\n lookup (i0 {Γ} {τ}) = snd' {interpC (τ :: Γ)} {interpC Γ} {_} id\n lookup (iS {Γ} {τ} {τ1} x) = comp {interpC (τ1 :: Γ)} {_} {_} (fst' {interpC (τ1 :: Γ)} {_} {interp τ1} id) (lookup x)\n\n interpE : ∀{Γ τ} → Γ |- τ → el (interpC Γ ->p interp τ)\n interpE (var x) = lookup x\n interpE z = monotone (λ x → Z) (λ x y _ → <>)\n interpE (suc e) = {!!} --monotone (λ x → S {!!}) {!!}\n interpE (rec e0 e1 e2) = mnatrec {!!} (interpE e1) (λ x x₁ → {!!}) {!!} --mnatrec {!!} (λ x x₁ → interpE e1) {!!}\n interpE (lam e) = lam' (interpE e)\n interpE (app e1 e2) = app' (interpE e1) (interpE e2)\n interpE unit = monotone (λ _ → <>) (λ x y _ → <>)\n interpE (prod e1 e2) = pair' (interpE e1) (interpE e2)\n interpE (l-proj {Γ} {τ1} {τ2} e) = fst' {_} {_} {interp τ2} (interpE e)\n interpE (r-proj {Γ} {τ1} {τ2} e) = snd' {_} {interp τ1} {_} (interpE e)\n\n sound : ∀ {Γ τ} (e e' : Γ |- τ) → e ≤s e' → PREORDER≤ (interpC Γ ->p interp τ) (interpE e) (interpE e')\n sound {_} {τ} .e' e' (refl-s .e') k = Preorder-max-str.refl (snd (interp τ)) (Monotone.f (interpE e') k)\n sound {_} {τ} e e' (trans-s .e e'' .e' p p₁) k = Preorder-max-str.trans (snd (interp τ)) (Monotone.f (interpE e) k)\n (Monotone.f (interpE e'') k) (Monotone.f (interpE e') k)\n (sound e e'' p k) (sound e'' e' p₁ k)\n sound .(subst (lem3 e1) e) .(subst (lem3 e2) e) (cong-s e e1 e2 p) k = {!!}\n sound .(subst (lem3 e2) e) .(app (lam e) e2) (lam-s e e2) k = {!!}\n sound {_} {τ} e .(l-proj (prod e e2)) (l-proj-s .e e2) k = Preorder-max-str.refl (snd (interp τ)) (Monotone.f (interpE e) k)\n sound {_} {τ} e .(r-proj (prod e1 e)) (r-proj-s e1 .e) k = Preorder-max-str.refl (snd (interp τ)) (Monotone.f (interpE e) k)\n sound .(subst (lem4 e (rec e e0 e1)) e1) .(rec (suc e) e0 e1) (rec-steps-s e e0 e1) k = {!!}\n sound e .(rec z e e1) (rec-steps-z .e e1) k = {!!}\n", "meta": {"hexsha": "dde258f525e5d9e2ba0aff18342b8dc6db83ac95", "size": 6905, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "ug/Complexity-lang.agda", "max_stars_repo_name": "benhuds/Agda", "max_stars_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-04-26T20:22:22.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-08T12:27:18.000Z", "max_issues_repo_path": "ug/Complexity-lang.agda", "max_issues_repo_name": "benhuds/Agda", "max_issues_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-03-23T08:39:04.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-12T00:32:45.000Z", "max_forks_repo_path": "ug/Complexity-lang.agda", "max_forks_repo_name": "benhuds/Agda", "max_forks_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.7251184834, "max_line_length": 126, "alphanum_fraction": 0.4256335988, "num_tokens": 2879, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424334245618, "lm_q2_score": 0.7662936430859597, "lm_q1q2_score": 0.6482403091499094}} {"text": "------------------------------------------------------------------------------\n-- Properties for the relation _◁_\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOTC.Program.McCarthy91.WF-Relation.PropertiesATP where\n\nopen import FOTC.Base\nopen import FOTC.Data.Nat\nopen import FOTC.Data.Nat.Inequalities\nopen import FOTC.Data.Nat.Inequalities.EliminationPropertiesATP\n using ( x Empty) -> NSPos) -> NSPos\n\n\n\n", "meta": {"hexsha": "0cbf4aa364f4176eb274650e4f59c6c3a242c672", "size": 118, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/fail/Negative4.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "test/fail/Negative4.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/fail/Negative4.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 11.8, "max_line_length": 43, "alphanum_fraction": 0.6355932203, "num_tokens": 35, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467548438124, "lm_q2_score": 0.7371581510799253, "lm_q1q2_score": 0.6480701963285812}} {"text": "{-# OPTIONS --safe --warning=error --without-K --guardedness #-}\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import LogicalFormulae\nopen import Groups.Lemmas\nopen import Groups.Definition\nopen import Setoids.Orders.Partial.Definition\nopen import Setoids.Orders.Total.Definition\nopen import Setoids.Setoids\nopen import Functions.Definition\nopen import Sets.EquivalenceRelations\nopen import Rings.Definition\nopen import Rings.Orders.Total.Definition\nopen import Rings.Orders.Partial.Definition\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import Numbers.Modulo.Definition\nopen import Semirings.Definition\nopen import Orders.Total.Definition\nopen import Sequences\n\n-- Note: totality is necessary here. The construction of a base-n expansion fundamentally relies on being able to take floors.\n\nmodule Rings.Orders.Total.BaseExpansion {a m p : _} {A : Set a} {S : Setoid {a} {m} A} {_+_ : A → A → A} {_*_ : A → A → A} {R : Ring S _+_ _*_} {_<_ : Rel {_} {p} A} {pOrder : SetoidPartialOrder S _<_} {pOrderRing : PartiallyOrderedRing R pOrder} (order : TotallyOrderedRing pOrderRing) {n : ℕ} (1 : Cover) where\n private\n module F = Functor F\n module = Cover \n\n Section : Set\n Section =\n ∀ i → F.apply (.at i , .at-open i)\n\n Coherence : Section → Set\n Coherence =\n ∀ i j →\n let ij = (.at i ∩ .at j) , (T.inter-open (.at-open i) (.at-open j) ) in\n F.map {.at i , .at-open i} {ij} (λ _ → π₁) ( i)\n ==\n F.map {.at j , .at-open j} {ij} (λ _ → π₂) ( j)\n\n Sheaf : Presheaf → Set\n Sheaf F =\n let module F = Functor F in\n (U : P X)\n (U-open : T.O U)\n ( : Cover U U-open)\n ( : Section U _ F )\n (coh : Coherence U _ F )\n →\n let module = Cover _ _ in\n Σ![ s ∶ F.apply (U , U-open) ]\n (∀ i → F.map {U , U-open} (.at-subset i) s == i)\n\n", "meta": {"hexsha": "30bd9361df0b673f9ee0314193b289e807691a6e", "size": 4712, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "sheaves.agda", "max_stars_repo_name": "jonsterling/Agda-Sheaves", "max_stars_repo_head_hexsha": "8a06162a8f0f7df308458db91d720cf8f7345d69", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-05-08T22:58:35.000Z", "max_stars_repo_stars_event_max_datetime": "2015-05-08T22:58:35.000Z", "max_issues_repo_path": "sheaves.agda", "max_issues_repo_name": "jonsterling/Agda-Sheaves", "max_issues_repo_head_hexsha": "8a06162a8f0f7df308458db91d720cf8f7345d69", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sheaves.agda", "max_forks_repo_name": "jonsterling/Agda-Sheaves", "max_forks_repo_head_hexsha": "8a06162a8f0f7df308458db91d720cf8f7345d69", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.9187817259, "max_line_length": 113, "alphanum_fraction": 0.4314516129, "num_tokens": 1946, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.86153820232079, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.6478875609196463}} {"text": "open import Agda.Builtin.Nat\n\n\ndata Vec (A : Set) : Nat -> Set where\n [] : Vec A 0\n cons : {n : Nat} -> A -> Vec A n -> Vec A (suc n)\n\nempty : Vec Nat 0\nempty = []\n", "meta": {"hexsha": "4c156fe33145f20e48c6f71b44b5b0825baf1eea", "size": 166, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "RefactorAgdaEngine/Test/Tests/input/Vector.agda", "max_stars_repo_name": "omega12345/RefactorAgda", "max_stars_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-01-31T14:10:18.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-03T10:03:36.000Z", "max_issues_repo_path": "RefactorAgdaEngine/Test/Tests/input/Vector.agda", "max_issues_repo_name": "omega12345/RefactorAgda", "max_issues_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2019-01-31T08:03:07.000Z", "max_issues_repo_issues_event_max_datetime": "2019-02-05T12:53:36.000Z", "max_forks_repo_path": "RefactorAgdaEngine/Test/Tests/input/Vector.agda", "max_forks_repo_name": "omega12345/RefactorAgda", "max_forks_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-01-31T08:40:41.000Z", "max_forks_repo_forks_event_max_datetime": "2019-01-31T08:40:41.000Z", "avg_line_length": 16.6, "max_line_length": 51, "alphanum_fraction": 0.5421686747, "num_tokens": 62, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382094310355, "lm_q2_score": 0.752012562644147, "lm_q1q2_score": 0.6478875566900828}} {"text": "{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n-- {-# OPTIONS --without-K #-}\n\n-- [1] Hofmann, Martin and Thomas Streicher (1998). “The groupoid\n-- interpretation on type theory”. In: Twenty-five Years of\n-- Constructive Type Theory. Ed. by Giovanni Sambin and Jan\n-- M. Smith. Oxford University Press. Chap. 6.\n\nmodule UIP where\n\ndata Id (A : Set)(x : A) : A → Set where\n refl : Id A x x\n\nK : (A : Set)(x : A)(P : Id A x x → Set) → P refl → (p : Id A x x ) → P p\nK A x P pr refl = pr\n\n-- From [1, p. 88].\nUIP : (A : Set)(a a' : A)(p p' : Id A a a') → Id (Id A a a') p p'\nUIP A a .a refl refl = refl\n", "meta": {"hexsha": "3d32f6bab19db8eec9a46596bca0241e299fd7b2", "size": 710, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/k-axiom/UIP.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/k-axiom/UIP.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/k-axiom/UIP.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 32.2727272727, "max_line_length": 73, "alphanum_fraction": 0.5450704225, "num_tokens": 230, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9136765328159727, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.6478141438569482}} {"text": "{-# OPTIONS --without-K --safe #-}\n\n-- Exact category (https://ncatlab.org/nlab/show/exact+category)\n-- is a regular category\n-- in which every internal equivalence is a kernel pair\n\nmodule Categories.Category.Exact where\n\nopen import Level\n\nopen import Categories.Category.Core\nopen import Categories.Diagram.Pullback\nopen import Categories.Category.Cocartesian\nopen import Categories.Object.Coproduct\nopen import Categories.Morphism\nopen import Categories.Category.Complete.Finitely using (FinitelyComplete)\nopen import Categories.Diagram.Coequalizer\nopen import Categories.Diagram.KernelPair\n\nopen import Categories.Category.Regular\nopen import Categories.Morphism.Regular\n\nopen import Categories.Object.InternalRelation\n\nrecord Exact {o ℓ e : Level} (𝒞 : Category o ℓ e) : Set (suc (o ⊔ ℓ ⊔ e)) where\n open Category 𝒞\n open Pullback\n open Coequalizer\n open Equivalence\n\n field\n regular : Regular 𝒞\n quotient : ∀ {X : Obj} (E : Equivalence 𝒞 X) → Coequalizer 𝒞 (R.p₁ E) (R.p₂ E)\n effective : ∀ {X : Obj} (E : Equivalence 𝒞 X) → IsPullback 𝒞 (R.p₁ E) (R.p₂ E)\n (arr (quotient E)) (arr (quotient E))\n", "meta": {"hexsha": "23cd34507e044066419c62b0e5c6ec740f6e9421", "size": 1126, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Exact.agda", "max_stars_repo_name": "Akshobhya1234/agda-categories", "max_stars_repo_head_hexsha": "c202a616d4f376b11e8320e641c98db2ddc9d233", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Category/Exact.agda", "max_issues_repo_name": "Akshobhya1234/agda-categories", "max_issues_repo_head_hexsha": "c202a616d4f376b11e8320e641c98db2ddc9d233", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Exact.agda", "max_forks_repo_name": "Akshobhya1234/agda-categories", "max_forks_repo_head_hexsha": "c202a616d4f376b11e8320e641c98db2ddc9d233", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.2777777778, "max_line_length": 84, "alphanum_fraction": 0.7424511545, "num_tokens": 309, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9304582497090322, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.6475601649810561}} {"text": "module Formalization.LambdaCalculus where\n\nimport Lvl\nopen import Data\nopen import Numeral.Natural\nopen import Numeral.Finite\nopen import Syntax.Number\nopen import Type\n\n-- A lambda term (A term in the language of lambda calculus).\n-- This is encoded with an abstraction depth which ensures that every term is well-formed.\n-- `Term(𝟎)` is the type of closed terms, terms that have no unbound variables.\n-- In this representation, it means that there are no occurrences of `Var(_)` in a term.\n-- `Term(𝐒(n))` for some `n` is the types of open terms with possibly `n` number of different variables, terms that have unbound variables.\n-- In this representation, it means that there can be `Var(i)` for `i < n` in a term.\ndata Term : ℕ → Type{0} where\n -- The term which represents applying the second term on the first term.\n -- Representation in function notation:\n -- (Apply f(x)) is f(x)\n Apply : ∀{d} → Term(d) → Term(d) → Term(d)\n\n -- The term which represents bounding a new variable (introducing a variable).\n -- Representation in function notation:\n -- (Abstract{n} term) is (xₙ ↦ term)\n Abstract : ∀{d} → Term(𝐒(d)) → Term(d)\n\n -- The term which represents a specific variable in scope.\n -- Representation in function notation:\n -- (Var(n)) is xₙ\n Var : ∀{d} → 𝕟(d) → Term(d)\n\n-- An expression in the language of lambda calculus is a closed term.\nExpression : Type{0}\nExpression = Term(0)\n\nmodule VarNumeralSyntax where\n -- Syntax for writing Var as a numeral.\n instance\n Term-from-ℕ : ∀{N} → Numeral(Term(N))\n Numeral.restriction-ℓ ( Term-from-ℕ {N} ) = Numeral.restriction-ℓ ( 𝕟-from-ℕ {N} )\n Numeral.restriction ( Term-from-ℕ {N} ) = Numeral.restriction ( 𝕟-from-ℕ {N} )\n num ⦃ Term-from-ℕ {N} ⦄ (n) ⦃ proof ⦄ = Var(num n)\n\nmodule OperSyntax where\n open VarNumeralSyntax public\n\n infixr 100 _↦_\n infixl 101 _←_\n\n pattern _↦_ d expr = Term.Abstract{d} expr\n pattern _←_ a b = Term.Apply a b\n\nmodule ExplicitLambdaSyntax where\n open VarNumeralSyntax public\n\n infixl 101 _←_\n\n pattern 𝜆 d expr = Term.Abstract{d} expr\n pattern _←_ a b = Term.Apply a b\n", "meta": {"hexsha": "8e2cf11e109e0eed8ea0970b6827f3802bc8fb68", "size": 2132, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Formalization/LambdaCalculus.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Formalization/LambdaCalculus.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Formalization/LambdaCalculus.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.5333333333, "max_line_length": 139, "alphanum_fraction": 0.6857410882, "num_tokens": 631, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681122619883, "lm_q2_score": 0.7549149813536518, "lm_q1q2_score": 0.6475419984740161}} {"text": "-- {-# OPTIONS --show-implicit #-}\n\nmodule Issue89 where\n\nopen import Common.Coinduction renaming (∞ to ∞_)\n\n------------------------------------------------------------------------\n-- Streams\n\ninfixr 5 _≺_\n\ndata Stream A : Set where\n _≺_ : (x : A) (xs : ∞ (Stream A)) -> Stream A\n\nhead : forall {A} -> Stream A -> A\nhead (x ≺ xs) = x\n\ntail : forall {A} -> Stream A -> Stream A\ntail (x ≺ xs) = ♭ xs\n\n------------------------------------------------------------------------\n-- Stream programs\n\ninfix 8 _∞\ninfixr 5 _⋎_\ninfix 4 ↓_\n\nmutual\n\n data Stream′ A : Set1 where\n _≺_ : (x : A) (xs : ∞ (StreamProg A)) -> Stream′ A\n\n data StreamProg (A : Set) : Set1 where\n ↓_ : (xs : Stream′ A) -> StreamProg A\n _∞ : (x : A) -> StreamProg A\n _⋎_ : (xs ys : StreamProg A) -> StreamProg A\n\nhead′ : ∀ {A} → Stream′ A → A\nhead′ (x ≺ xs) = x\n\ntail′ : ∀ {A} → Stream′ A → StreamProg A\ntail′ (x ≺ xs) = ♭ xs\n\nP⇒′ : forall {A} -> StreamProg A -> Stream′ A\nP⇒′ (↓ xs) = xs\nP⇒′ (x ∞) = x ≺ ♯ (x ∞)\nP⇒′ (xs ⋎ ys) with P⇒′ xs\nP⇒′ (xs ⋎ ys) | xs′ = head′ xs′ ≺ ♯ (ys ⋎ tail′ xs′)\n\nmutual\n\n ′⇒ : forall {A} -> Stream′ A -> Stream A\n ′⇒ (x ≺ xs) = x ≺ ♯ P⇒ (♭ xs)\n\n P⇒ : forall {A} -> StreamProg A -> Stream A\n P⇒ xs = ′⇒ (P⇒′ xs)\n\n------------------------------------------------------------------------\n-- Stream equality\n\ninfix 4 _≡_ _≈_ _≊_\n\ndata _≡_ {a : Set} (x : a) : a -> Set where\n ≡-refl : x ≡ x\n\ndata _≈_ {A} (xs ys : Stream A) : Set where\n _≺_ : (x≡ : head xs ≡ head ys) (xs≈ : ∞ (tail xs ≈ tail ys)) ->\n xs ≈ ys\n\n_≊_ : forall {A} (xs ys : StreamProg A) -> Set\nxs ≊ ys = P⇒ xs ≈ P⇒ ys\n\nfoo : forall {A} (x : A) -> x ∞ ⋎ x ∞ ≊ x ∞\nfoo x = ≡-refl ≺ ♯ foo x\n\n-- The first goal has goal type\n-- head (′⇒ (x ≺ x ∞ ⋎ x ∞)) ≡ head (′⇒ (x ≺ x ∞)).\n-- The normal form of the left-hand side is x, and the normal form of\n-- the right-hand side is x (both according to Agda), but ≡-refl is\n-- not accepted by the type checker:\n-- x != head (′⇒ (P⇒′ (x ∞))) of type .A\n-- when checking that the expression ≡-refl has type\n-- (head (P⇒ (x ∞ ⋎ x ∞)) ≡ head (P⇒ (x ∞)))\n\n", "meta": {"hexsha": "fc55e36ad1eb7ad2530feadea9924cc9feda174d", "size": 2086, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue89.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/succeed/Issue89.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/Issue89.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 24.5411764706, "max_line_length": 72, "alphanum_fraction": 0.4597315436, "num_tokens": 869, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094003735664, "lm_q2_score": 0.7248702821204019, "lm_q1q2_score": 0.6475334370695942}} {"text": "{-# OPTIONS --universe-polymorphism #-}\nmodule Categories.Colimit where\n\nopen import Level\n\nopen import Categories.Category\nopen import Categories.Functor\nopen import Categories.NaturalTransformation\nopen import Categories.Functor.Constant\nopen import Categories.Cocones\nopen import Categories.Cocone\nopen import Categories.Object.Initial\n\n-- Isomorphic to an terminal object, but worth keeping distinct in case we change its definition\nrecord Colimit {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {J : Category o′ ℓ′ e′} (F : Functor J C) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where\n field\n initial : Initial (Cocones F)\n \n module I = Initial initial\n module Ic = Cocone I.⊥\n private module C = Category C\n\n ∃F : C.Obj\n ∃F = Ic.N\n\n ι : NaturalTransformation F (Constant ∃F) \n ι = record { η = Ic.ψ; commute = λ f → C.Equiv.trans (C.Equiv.sym (Ic.commute f)) (C.Equiv.sym C.identityˡ) }\n \n <_> : ∀ {Q} → NaturalTransformation F (Constant Q) → ∃F C.⇒ Q\n <_> {Q} η = CoconeMorphism.f (I.! {record \n { N = Q\n ; ψ = η.η\n ; commute = λ f → C.Equiv.trans (C.Equiv.sym C.identityˡ) (C.Equiv.sym (η.commute f)) }}) \n where\n module η = NaturalTransformation η\n \nrecord Cocomplete (o ℓ e : Level) {o′ ℓ′ e′} (C : Category o′ ℓ′ e′) : Set (suc o ⊔ suc ℓ ⊔ suc e ⊔ o′ ⊔ ℓ′ ⊔ e′) where\n field\n colimit : ∀ {J : Category o ℓ e} (F : Functor J C) → Colimit F\n", "meta": {"hexsha": "d6163f38fcaff15bb06f70cb1534c0dc341b2ab7", "size": 1391, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Colimit.agda", "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 98, "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_issues_repo_path": "Categories/Colimit.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_forks_repo_path": "Categories/Colimit.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 23, "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "avg_line_length": 34.775, "max_line_length": 135, "alphanum_fraction": 0.639108555, "num_tokens": 481, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314677809303, "lm_q2_score": 0.731058584489497, "lm_q1q2_score": 0.6474484872152825}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.HITs.Ints.QuoInt.Properties where\n\nopen import Cubical.Core.Everything\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Relation.Nullary\n\nopen import Cubical.Data.Nat as ℕ using (ℕ; zero; suc)\nopen import Cubical.Data.Bool as Bool using (Bool; not; notnot)\nopen import Cubical.Data.Empty\nopen import Cubical.Data.Unit renaming (Unit to ⊤)\n\nopen import Cubical.HITs.Ints.QuoInt.Base\n\n·S-comm : ∀ x y → x ·S y ≡ y ·S x\n·S-comm = Bool.⊕-comm\n\n·S-assoc : ∀ x y z → x ·S (y ·S z) ≡ (x ·S y) ·S z\n·S-assoc = Bool.⊕-assoc\n\nnot-·Sˡ : ∀ x y → not (x ·S y) ≡ not x ·S y\nnot-·Sˡ = Bool.not-⊕ˡ\n\n\nsnotz : ∀ s n s' → ¬ (signed s (suc n) ≡ signed s' zero)\nsnotz s n s' eq = subst (λ { (signed s (suc n)) → ⊤\n ; _ → ⊥ }) eq tt\n\n\n+-zeroʳ : ∀ s m → m + signed s zero ≡ m\n+-zeroʳ s (signed s' zero) = signed-zero s s'\n+-zeroʳ s (pos (suc n)) = cong sucℤ (+-zeroʳ s (pos n))\n+-zeroʳ s (neg (suc n)) = cong predℤ (+-zeroʳ s (neg n))\n+-zeroʳ spos (posneg i) j = posneg (i ∧ j)\n+-zeroʳ sneg (posneg i) j = posneg (i ∨ ~ j)\n\n+-identityʳ : ∀ m → m + pos zero ≡ m\n+-identityʳ = +-zeroʳ spos\n\nsucℤ-+ʳ : ∀ m n → sucℤ (m + n) ≡ m + sucℤ n\nsucℤ-+ʳ (signed _ zero) _ = refl\nsucℤ-+ʳ (posneg _) _ = refl\nsucℤ-+ʳ (pos (suc m)) n = cong sucℤ (sucℤ-+ʳ (pos m) n)\nsucℤ-+ʳ (neg (suc m)) n =\n sucPredℤ (neg m + n) ∙∙\n sym (predSucℤ (neg m + n)) ∙∙\n cong predℤ (sucℤ-+ʳ (neg m) n)\n\n-- I wonder if we could somehow use negEq to get this for free from the above...\npredℤ-+ʳ : ∀ m n → predℤ (m + n) ≡ m + predℤ n\npredℤ-+ʳ (signed _ zero) _ = refl\npredℤ-+ʳ (posneg _) _ = refl\npredℤ-+ʳ (neg (suc m)) n = cong predℤ (predℤ-+ʳ (neg m) n)\npredℤ-+ʳ (pos (suc m)) n =\n predSucℤ (pos m + n) ∙∙\n sym (sucPredℤ (pos m + n)) ∙∙\n cong sucℤ (predℤ-+ʳ (pos m) n)\n\n+-comm : ∀ m n → m + n ≡ n + m\n+-comm (signed s zero) n = sym (+-zeroʳ s n)\n+-comm (pos (suc m)) n = cong sucℤ (+-comm (pos m) n) ∙ sucℤ-+ʳ n (pos m)\n+-comm (neg (suc m)) n = cong predℤ (+-comm (neg m) n) ∙ predℤ-+ʳ n (neg m)\n+-comm (posneg i) n = lemma n i\n where\n -- get some help from:\n -- https://www.codewars.com/kata/reviews/5c878e3ef1abb10001e32eb1/groups/5cca3f9e840f4b0001d8ac98\n lemma : ∀ n → (λ i → (posneg i + n) ≡ (n + posneg i))\n [ sym (+-zeroʳ spos n) ≡ sym (+-zeroʳ sneg n) ]\n lemma (pos zero) i j = posneg (i ∧ j)\n lemma (pos (suc n)) i = cong sucℤ (lemma (pos n) i)\n lemma (neg zero) i j = posneg (i ∨ ~ j)\n lemma (neg (suc n)) i = cong predℤ (lemma (neg n) i)\n lemma (posneg i) j k = posneg ((i ∧ ~ k) ∨ (i ∧ j) ∨ (j ∧ k))\n\nsucℤ-+ˡ : ∀ m n → sucℤ (m + n) ≡ sucℤ m + n\nsucℤ-+ˡ (pos _) n = refl\nsucℤ-+ˡ (neg zero) n = refl\nsucℤ-+ˡ (neg (suc m)) n = sucPredℤ _\nsucℤ-+ˡ (posneg _) n = refl\n\n-- I wonder if we could somehow use negEq to get this for free from the above...\npredℤ-+ˡ : ∀ m n → predℤ (m + n) ≡ predℤ m + n\npredℤ-+ˡ (pos zero) n = refl\npredℤ-+ˡ (pos (suc m)) n = predSucℤ _\npredℤ-+ˡ (neg _) n = refl\npredℤ-+ˡ (posneg _) n = refl\n\n+-assoc : ∀ m n o → m + (n + o) ≡ m + n + o\n+-assoc (signed s zero) n o = refl\n+-assoc (posneg i) n o = refl\n+-assoc (pos (suc m)) n o = cong sucℤ (+-assoc (pos m) n o) ∙ sucℤ-+ˡ (pos m + n) o\n+-assoc (neg (suc m)) n o = cong predℤ (+-assoc (neg m) n o) ∙ predℤ-+ˡ (neg m + n) o\n\n\nsucℤ-inj : ∀ m n → sucℤ m ≡ sucℤ n → m ≡ n\nsucℤ-inj m n p = sym (predSucℤ m) ∙ cong predℤ p ∙ predSucℤ n\n\npredℤ-inj : ∀ m n → predℤ m ≡ predℤ n → m ≡ n\npredℤ-inj m n p = sym (sucPredℤ m) ∙ cong sucℤ p ∙ sucPredℤ n\n\n+-injˡ : ∀ o m n → o + m ≡ o + n → m ≡ n\n+-injˡ (signed _ zero) _ _ p = p\n+-injˡ (posneg _) _ _ p = p\n+-injˡ (pos (suc o)) m n p = +-injˡ (pos o) m n (sucℤ-inj _ _ p)\n+-injˡ (neg (suc o)) m n p = +-injˡ (neg o) m n (predℤ-inj _ _ p)\n\n+-injʳ : ∀ m n o → m + o ≡ n + o → m ≡ n\n+-injʳ m n o p = +-injˡ o m n (+-comm o m ∙ p ∙ +-comm n o)\n\n\n·-comm : ∀ m n → m · n ≡ n · m\n·-comm m n i = signed (·S-comm (sign m) (sign n) i) (ℕ.·-comm (abs m) (abs n) i)\n\n·-identityˡ : ∀ n → pos 1 · n ≡ n\n·-identityˡ n = cong (signed (sign n)) (ℕ.+-zero (abs n)) ∙ signed-inv n\n\n·-identityʳ : ∀ n → n · pos 1 ≡ n\n·-identityʳ n = ·-comm n (pos 1) ∙ ·-identityˡ n\n\n·-zeroˡ : ∀ {s} n → signed s zero · n ≡ signed s zero\n·-zeroˡ _ = signed-zero _ _\n\n·-zeroʳ : ∀ {s} n → n · signed s zero ≡ signed s zero\n·-zeroʳ n = cong (signed _) (sym (ℕ.0≡m·0 (abs n))) ∙ signed-zero _ _\n\n·-signed-pos : ∀ {s} m n → signed s m · pos n ≡ signed s (m ℕ.· n)\n·-signed-pos {s} zero n = ·-zeroˡ {s} (pos n)\n·-signed-pos {s} (suc m) n i = signed (·S-comm s (sign-pos n i) i) (suc m ℕ.· n)\n\n\n-- this proof is why we defined ℤ using `signed` instead of `pos` and `neg`\n-- based on that in: https://github.com/danr/Agda-Numerics\n·-assoc : ∀ m n o → m · (n · o) ≡ m · n · o\n\n·-assoc (signed s zero) n o =\n ·-zeroˡ (n · o)\n·-assoc m@(signed _ (suc _)) (signed s zero) o =\n ·-zeroʳ {sign o} m ∙ signed-zero _ _ ∙ cong (_· o) (sym (·-zeroʳ {s} m))\n·-assoc m@(signed _ (suc _)) n@(signed _ (suc _)) (signed s zero) =\n cong (m ·_) (·-zeroʳ {s} n) ∙ ·-zeroʳ {s} m ∙ sym (·-zeroʳ {s} (m · n))\n\n·-assoc (signed sm (suc m)) (signed sn (suc n)) (signed so (suc o)) i =\n signed (·S-assoc sm sn so i) (ℕ.·-assoc (suc m) (suc n) (suc o) i)\n\n·-assoc (posneg i) n o j =\n isSet→isSet' isSetℤ (·-assoc (pos zero) n o) (·-assoc (neg zero) n o)\n (λ i → posneg i · (n · o)) (λ i → posneg i · n · o) i j\n·-assoc m@(signed _ (suc _)) (posneg i) o j =\n isSet→isSet' isSetℤ (·-assoc m (pos zero) o) (·-assoc m (neg zero) o)\n (λ i → m · (posneg i · o)) (λ i → m · posneg i · o) i j\n·-assoc m@(signed _ (suc _)) n@(signed _ (suc _)) (posneg i) j =\n isSet→isSet' isSetℤ (·-assoc m n (pos zero)) (·-assoc m n (neg zero))\n (λ i → m · (n · posneg i)) (λ i → m · n · posneg i) i j\n\n\nnegateSuc : ∀ n → - sucℤ n ≡ predℤ (- n)\nnegateSuc n i = - sucℤ (negate-invol n (~ i))\n\nnegatePred : ∀ n → - predℤ n ≡ sucℤ (- n)\nnegatePred n i = negate-invol (sucℤ (- n)) i\n\nnegate-+ : ∀ m n → - (m + n) ≡ (- m) + (- n)\nnegate-+ (signed _ zero) n = refl\nnegate-+ (posneg _) n = refl\nnegate-+ (pos (suc m)) n = negateSuc (pos m + n) ∙ cong predℤ (negate-+ (pos m) n)\nnegate-+ (neg (suc m)) n = negatePred (neg m + n) ∙ cong sucℤ (negate-+ (neg m) n)\n\n\nnegate-·ˡ : ∀ m n → - (m · n) ≡ (- m) · n\nnegate-·ˡ (signed _ zero) n = signed-zero (not (sign n)) (sign n)\nnegate-·ˡ (signed ss (suc m)) n i = signed (not-·Sˡ ss (sign n) i) (suc m ℕ.· abs n)\nnegate-·ˡ (posneg i) n j =\n isSet→isSet' isSetℤ (signed-zero (not (sign n)) _) (signed-zero _ _)\n refl (λ i → posneg (~ i) · n) i j\n\n\nsigned-distrib : ∀ s m n → signed s (m ℕ.+ n) ≡ signed s m + signed s n\nsigned-distrib s zero n = refl\nsigned-distrib spos (suc m) n = cong sucℤ (signed-distrib spos m n)\nsigned-distrib sneg (suc m) n = cong predℤ (signed-distrib sneg m n)\n\n·-pos-suc : ∀ m n → pos (suc m) · n ≡ n + pos m · n\n·-pos-suc m n = signed-distrib (sign n) (abs n) (m ℕ.· abs n)\n ∙ (λ i → signed-inv n i + signed (sign-pos m (~ i) ·S sign n) (m ℕ.· abs n))\n\n\n-- the below is based on that in: https://github.com/danr/Agda-Numerics\n\n·-distribˡ-pos : ∀ o m n → (pos o · m) + (pos o · n) ≡ pos o · (m + n)\n·-distribˡ-pos zero m n = signed-zero (sign n) (sign (m + n))\n·-distribˡ-pos (suc o) m n =\n pos (suc o) · m + pos (suc o) · n ≡[ i ]⟨ ·-pos-suc o m i + ·-pos-suc o n i ⟩\n m + pos o · m + (n + pos o · n) ≡⟨ +-assoc (m + pos o · m) n (pos o · n) ⟩\n m + pos o · m + n + pos o · n ≡[ i ]⟨ +-assoc m (pos o · m) n (~ i) + pos o · n ⟩\n m + (pos o · m + n) + pos o · n ≡[ i ]⟨ m + +-comm (pos o · m) n i + pos o · n ⟩\n m + (n + pos o · m) + pos o · n ≡[ i ]⟨ +-assoc m n (pos o · m) i + pos o · n ⟩\n m + n + pos o · m + pos o · n ≡⟨ sym (+-assoc (m + n) (pos o · m) (pos o · n)) ⟩\n m + n + (pos o · m + pos o · n) ≡⟨ cong ((m + n) +_) (·-distribˡ-pos o m n) ⟩\n m + n + pos o · (m + n) ≡⟨ sym (·-pos-suc o (m + n)) ⟩\n pos (suc o) · (m + n) ∎\n\n·-distribˡ-neg : ∀ o m n → (neg o · m) + (neg o · n) ≡ neg o · (m + n)\n·-distribˡ-neg o m n =\n neg o · m + neg o · n ≡[ i ]⟨ negate-·ˡ (pos o) m (~ i) + negate-·ˡ (pos o) n (~ i) ⟩\n - (pos o · m) + - (pos o · n) ≡⟨ sym (negate-+ (pos o · m) (pos o · n)) ⟩\n - (pos o · m + pos o · n) ≡⟨ cong -_ (·-distribˡ-pos o m n) ⟩\n - (pos o · (m + n)) ≡⟨ negate-·ˡ (pos o) (m + n) ⟩\n neg o · (m + n) ∎\n\n·-distribˡ : ∀ o m n → (o · m) + (o · n) ≡ o · (m + n)\n·-distribˡ (pos o) m n = ·-distribˡ-pos o m n\n·-distribˡ (neg o) m n = ·-distribˡ-neg o m n\n·-distribˡ (posneg i) m n j =\n isSet→isSet' isSetℤ (·-distribˡ-pos zero m n) (·-distribˡ-neg zero m n)\n (λ i → posneg i · n) (λ i → posneg i · (m + n)) i j\n\n·-distribʳ : ∀ m n o → (m · o) + (n · o) ≡ (m + n) · o\n·-distribʳ m n o = (λ i → ·-comm m o i + ·-comm n o i) ∙ ·-distribˡ o m n ∙ ·-comm o (m + n)\n\n\nsign-pos-suc-· : ∀ m n → sign (pos (suc m) · n) ≡ sign n\nsign-pos-suc-· m (signed s zero) = sign-pos (suc m ℕ.· zero)\nsign-pos-suc-· m (posneg i) = sign-pos (suc m ℕ.· zero)\nsign-pos-suc-· m (signed s (suc n)) = refl\n\n·-injˡ : ∀ o m n → pos (suc o) · m ≡ pos (suc o) · n → m ≡ n\n·-injˡ o m n p = sym (signed-inv m) ∙ (λ i → signed (sign-eq i) (abs-eq i)) ∙ signed-inv n\n where sign-eq = sym (sign-pos-suc-· o m) ∙ cong sign p ∙ sign-pos-suc-· o n\n abs-eq = ℕ.inj-sm· {o} (cong abs p)\n\n·-injʳ : ∀ m n o → m · pos (suc o) ≡ n · pos (suc o) → m ≡ n\n·-injʳ m n o p = ·-injˡ o m n (·-comm (pos (suc o)) m ∙ p ∙ ·-comm n (pos (suc o)))\n", "meta": {"hexsha": "2404d05ff7d15c3ee8eaf815b55e6d660ab12b80", "size": 9637, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/Ints/QuoInt/Properties.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/HITs/Ints/QuoInt/Properties.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/HITs/Ints/QuoInt/Properties.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.8347457627, "max_line_length": 99, "alphanum_fraction": 0.5293141019, "num_tokens": 4450, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314677809303, "lm_q2_score": 0.731058584489497, "lm_q1q2_score": 0.6474484872152825}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import LogicalFormulae\nopen import Sets.EquivalenceRelations\nopen import Setoids.Setoids\n\nmodule Setoids.Algebra.Lemmas {a b : _} {A : Set a} (S : Setoid {a} {b} A) where\n\nopen Setoid S\nopen Equivalence eq\nopen import Setoids.Subset S\nopen import Setoids.Equality S\nopen import Setoids.Intersection.Definition S\nopen import Setoids.Union.Definition S\n\nintersectionAndUnion : {c d e : _} {pred1 : A → Set c} {pred2 : A → Set d} {pred3 : A → Set e} → (s1 : subset pred1) (s2 : subset pred2) (s3 : subset pred3) → intersection s1 (union s2 s3) =S union (intersection s1 s2) (intersection s1 s3)\nintersectionAndUnion s1 s2 s3 x = ans1 ,, ans2\n where\n ans1 : _\n ans1 (fst ,, inl x) = inl (fst ,, x)\n ans1 (fst ,, inr x) = inr (fst ,, x)\n ans2 : _\n ans2 (inl x) = _&&_.fst x ,, inl (_&&_.snd x)\n ans2 (inr x) = _&&_.fst x ,, inr (_&&_.snd x)\n", "meta": {"hexsha": "e610f2e6b5328ad29047225df61883613378e76d", "size": 971, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Setoids/Algebra/Lemmas.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Setoids/Algebra/Lemmas.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Setoids/Algebra/Lemmas.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 37.3461538462, "max_line_length": 239, "alphanum_fraction": 0.6632337796, "num_tokens": 338, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314677809303, "lm_q2_score": 0.7310585786300048, "lm_q1q2_score": 0.6474484820259317}} {"text": "open import Functional hiding (Domain)\nimport Structure.Logic.Classical.NaturalDeduction\nimport Structure.Logic.Classical.SetTheory.ZFC\n\nmodule Structure.Logic.Classical.SetTheory.ZFC.FunctionSet {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} ⦃ classicLogic : _ ⦄ (_∈_ : Domain → Domain → Formula) ⦃ signature : _ ⦄ where\nopen Structure.Logic.Classical.NaturalDeduction.ClassicalLogic {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} (classicLogic)\nopen Structure.Logic.Classical.SetTheory.ZFC.Signature {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} ⦃ classicLogic ⦄ {_∈_} (signature)\n\nopen import Structure.Logic.Classical.SetTheory.SetBoundedQuantification ⦃ classicLogic ⦄ (_∈_)\nopen import Structure.Logic.Classical.SetTheory.ZFC.BinaryRelatorSet ⦃ classicLogic ⦄ (_∈_) ⦃ signature ⦄\n\n-- The set s can be interpreted as a function.\nFunctionSet : Domain → Formula\nFunctionSet(s) = ∀ₗ(x ↦ Unique(y ↦ (x , y) ∈ s))\n-- TODO: Maybe also define something that states ∀ₗ(x ↦ (x ∈ A) ↔ ∃ₗ(y ↦ (x , y) ∈ s)) so that a set representation of a function with domains becomes unique? But I think when (s ∈ (B ^ A)) is satisfied, this is implied? So try to prove that (FunctionSet(f) ∧ Total(A)(f) ∧ (the thing I mentioned earlier)) ↔ (f ∈ (B ^ A))\n\n-- The set s can be interpreted as a function with a specified domain.\n-- The following describes the relation to the standard notation of functions:\n-- • ∀(x∊A)∀y. ((x,y) ∈ S) ⇔ (S(x) = y)\nTotal : Domain → Domain → Formula\nTotal(A)(s) = ∀ₛ(A)(x ↦ ∃ₗ(y ↦ (x , y) ∈ s))\n\nInjective' : Domain → Formula\nInjective'(f) = ∀ₗ(y ↦ Unique(x ↦ (x , y) ∈ f))\n\nSurjective' : Domain → Domain → Formula\nSurjective'(B)(f) = ∀ₛ(B)(y ↦ ∃ₗ(x ↦ (x , y) ∈ f))\n\nBijective' : Domain → Domain → Formula\nBijective'(B)(f) =\n Injective'(f)\n ∧ Surjective'(B)(f)\n\n-- The set of total function sets. All sets which can be interpreted as a total function.\n_^_ : Domain → Domain → Domain\nB ^ A = filter(℘(A ⨯ B)) (f ↦ FunctionSet(f) ∧ Total(A)(f))\n\n_→ₛₑₜ_ = swap _^_\n\n⊷ : Domain → Domain\n⊷ = lefts\n\n⊶ : Domain → Domain\n⊶ = rights\n\nmap' : Domain → Domain → Domain\nmap' = rightsOfMany\n\nunmap' : Domain → Domain → Domain\nunmap' = leftsOfMany\n\napply-set : Domain → Domain → Domain\napply-set = rightsOf\n\nunapply-set : Domain → Domain → Domain\nunapply-set = leftsOf\n\n_∘'_ : Domain → Domain → Domain\n_∘'_ f g = filter((⊷ f) ⨯ (⊶ g)) (a ↦ ∃ₗ(x ↦ ∃ₗ(y ↦ ∃ₗ(a₁ ↦ ((a₁ , y) ∈ f) ∧ ((x , a₁) ∈ g)) ∧ (a ≡ (x , y)))))\n\n-- inv : Domain → Domain\n-- inv f = filter(?) (yx ↦ ∃ₗ(x ↦ ∃ₗ(y ↦ ((x , y) ∈ f) ∧ (yx ≡ (y , x)))))\n\nmodule Cardinality where\n -- Injection\n _≼_ : Domain → Domain → Formula\n _≼_ (a)(b) = ∃ₛ(a →ₛₑₜ b)(Injective')\n\n -- Surjection\n _≽_ : Domain → Domain → Formula\n _≽_ (a)(b) = ∃ₛ(a →ₛₑₜ b)(Surjective'(b))\n\n -- Bijection\n _≍_ : Domain → Domain → Formula\n _≍_ (a)(b) = ∃ₛ(a →ₛₑₜ b)(Bijective'(b))\n\n -- Strict injection\n _≺_ : Domain → Domain → Formula\n _≺_ A B = (A ≼ B) ∧ ¬(A ≍ B)\n\n -- Strict surjection\n _≻_ : Domain → Domain → Formula\n _≻_ A B = (A ≽ B) ∧ ¬(A ≍ B)\n\n -- TODO: Definition of a \"cardinality object\" requires ordinals, which requires axiom of choice\n -- # : Domain → Domain\n", "meta": {"hexsha": "d118426f8f5a0856957f99009daafb49e55c83b6", "size": 3122, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "old/Structure/Logic/Classical/SetTheory/ZFC/FunctionSet.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "old/Structure/Logic/Classical/SetTheory/ZFC/FunctionSet.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "old/Structure/Logic/Classical/SetTheory/ZFC/FunctionSet.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.8850574713, "max_line_length": 322, "alphanum_fraction": 0.632607303, "num_tokens": 1164, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9343951643678381, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.6472013137508942}} {"text": "module product where\n\nopen import Data.Nat using (ℕ; _*_)\nopen import lists using (List; foldr)\n\n-- リストの要素の積\nproduct : (List ℕ) → ℕ\nproduct xs = foldr _*_ 1 xs\n", "meta": {"hexsha": "17333e10a404ea3ea5f223ac7835c3f58a8d8347", "size": 160, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/lists/product.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/lists/product.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/lists/product.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.7777777778, "max_line_length": 37, "alphanum_fraction": 0.7, "num_tokens": 58, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9086178969328287, "lm_q2_score": 0.7122321720225278, "lm_q1q2_score": 0.6471468982710098}} {"text": "-- mathematical integers; see int.agda for imported machine integers from Haskell.\nmodule integer where\n\nopen import bool\nopen import bool-thms2\nopen import eq\nopen import nat\nopen import nat-thms\nopen import product\nopen import product-thms\nopen import sum\nopen import unit\n\nℤ-pos-t : ℕ → Set\nℤ-pos-t 0 = ⊤\nℤ-pos-t (suc _) = 𝔹\n\n{- In mkℤ n a, the argument a tells whether the integer is positive or negative, if n is nonzero.\n If n is zero, then a is just triv : ⊤, so there is a unique integer value for 0. -}\ndata ℤ : Set where\n mkℤ : (n : ℕ) → ℤ-pos-t n → ℤ\n\n0ℤ : ℤ\n0ℤ = mkℤ 0 triv\n\n1ℤ : ℤ\n1ℤ = mkℤ 1 tt\n\n-1ℤ : ℤ\n-1ℤ = mkℤ 1 ff\n\nabs-val : ℤ → ℕ\nabs-val (mkℤ n _) = n\n\nis-evenℤ : ℤ → 𝔹\nis-evenℤ (mkℤ n _) = is-even n\n\nis-oddℤ : ℤ → 𝔹\nis-oddℤ (mkℤ n _) = is-odd n\n\n{- subtract the second natural number from the first, returning an integer.\n This is mostly a helper for _+ℤ_ -}\ndiffℤ : ℕ → ℕ → ℤ\ndiffℤ n m with ℕ-trichotomy n m \ndiffℤ n m | inj₁ p with <∸suc{m}{n} p -- n < m\ndiffℤ n m | inj₁ p | x , _ = mkℤ (suc x) ff\ndiffℤ n m | inj₂ (inj₁ p) = mkℤ 0 triv -- n = m \ndiffℤ n m | inj₂ (inj₂ p) with <∸suc{n}{m} p\ndiffℤ n m | inj₂ (inj₂ p) | x , _ = mkℤ (suc x) tt -- m < n \n\n_+ℤ_ : ℤ → ℤ → ℤ\n(mkℤ 0 _) +ℤ x = x\nx +ℤ (mkℤ 0 _) = x\n(mkℤ (suc n) p1) +ℤ (mkℤ (suc m) p2) with p1 xor p2 \n(mkℤ (suc n) p1) +ℤ (mkℤ (suc m) p2) | ff = mkℤ (suc n + suc m) p1\n(mkℤ (suc n) p1) +ℤ (mkℤ (suc m) p2) | tt = if p1 imp p2 then diffℤ m n else diffℤ n m \n\ntest-+ℤ1 : (mkℤ 2 ff) +ℤ (mkℤ 4 tt) ≡ (mkℤ 2 tt)\ntest-+ℤ1 = refl\n\ntest-+ℤ2 : (mkℤ 2 tt) +ℤ (mkℤ 4 ff) ≡ (mkℤ 2 ff)\ntest-+ℤ2 = refl\n\n_≤ℤ_ : ℤ → ℤ → 𝔹\n(mkℤ 0 triv) ≤ℤ (mkℤ 0 triv) = tt\n(mkℤ 0 triv) ≤ℤ (mkℤ (suc _) pos) = pos\n(mkℤ (suc _) pos) ≤ℤ (mkℤ 0 triv) = ~ pos\n(mkℤ (suc x) pos1) ≤ℤ (mkℤ (suc y) pos2) with pos1 xor pos2\n(mkℤ (suc x) pos1) ≤ℤ (mkℤ (suc y) pos2) | tt = pos1 imp pos2\n(mkℤ (suc x) pos1) ≤ℤ (mkℤ (suc y) pos2) | ff = if pos1 then x ≤ y else y ≤ x\n\n≤ℤ-antisymm : ∀(x y : ℤ) → x ≤ℤ y ≡ tt → y ≤ℤ x ≡ tt → x ≡ y\n≤ℤ-antisymm (mkℤ zero triv) (mkℤ zero triv) p q = refl\n≤ℤ-antisymm (mkℤ zero triv) (mkℤ (suc y) pos2) p q rewrite p with q \n≤ℤ-antisymm (mkℤ zero triv) (mkℤ (suc y) pos2) p q | ()\n≤ℤ-antisymm (mkℤ (suc x) pos1) (mkℤ zero triv) p q rewrite q with p\n≤ℤ-antisymm (mkℤ (suc x) pos1) (mkℤ zero triv) p q | ()\n≤ℤ-antisymm (mkℤ (suc x) pos1) (mkℤ (suc y) pos2) p q with keep (pos1 xor pos2)\n≤ℤ-antisymm (mkℤ (suc x) pos1) (mkℤ (suc y) pos2) p q | tt , rp rewrite rp | xor-comm pos1 pos2 | rp with imp-antisymm{pos1} p q \n≤ℤ-antisymm (mkℤ (suc x) pos1) (mkℤ (suc y) pos2) p q | tt , rp | pp rewrite pp | xor-anti-idem pos2 with rp\n≤ℤ-antisymm (mkℤ (suc x) pos1) (mkℤ (suc y) pos2) p q | tt , rp | pp | ()\n≤ℤ-antisymm (mkℤ (suc x) pos1) (mkℤ (suc y) pos2) p q | ff , rp\n rewrite rp | xor-comm pos1 pos2 | rp | xor-≡{pos2}rp with pos1 \n≤ℤ-antisymm (mkℤ (suc x) pos1) (mkℤ (suc y) pos2) p q | ff , rp | tt rewrite ≤-antisym{x} p q = refl\n≤ℤ-antisymm (mkℤ (suc x) pos1) (mkℤ (suc y) pos2) p q | ff , rp | ff rewrite ≤-antisym{y} p q = refl\n", "meta": {"hexsha": "24b8630d5b930a67e5128584a927627d8841247f", "size": 3030, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "integer.agda", "max_stars_repo_name": "rfindler/ial", "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 29, "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_issues_repo_path": "integer.agda", "max_issues_repo_name": "rfindler/ial", "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_forks_repo_path": "integer.agda", "max_forks_repo_name": "rfindler/ial", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 17, "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "avg_line_length": 35.2325581395, "max_line_length": 129, "alphanum_fraction": 0.598679868, "num_tokens": 1522, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9086178944582997, "lm_q2_score": 0.7122321720225279, "lm_q1q2_score": 0.6471468965085707}} {"text": "------------------------------------------------------------------------------\n-- Common stuff used by the gcd example\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOTC.Program.GCD.Partial.Definitions where\n\nopen import FOTC.Base\nopen import FOTC.Data.Nat.Divisibility.NotBy0\nopen import FOTC.Data.Nat.Inequalities\nopen import FOTC.Data.Nat.Type\n\n------------------------------------------------------------------------------\n-- Common divisor.\nCD : D → D → D → Set\nCD m n cd = cd ∣ m ∧ cd ∣ n\n{-# ATP definition CD #-}\n\n-- Divisible for any common divisor.\nDivisible : D → D → D → Set\nDivisible m n gcd = ∀ cd → N cd → CD m n cd → cd ∣ gcd\n{-# ATP definition Divisible #-}\n\n-- Greatest that any common divisor.\nGACD : D → D → D → Set\nGACD m n gcd = ∀ cd → N cd → CD m n cd → cd ≤ gcd\n{-# ATP definition GACD #-}\n\n-- Greatest common divisor specification\ngcdSpec : D → D → D → Set\ngcdSpec m n gcd = CD m n gcd ∧ GACD m n gcd\n{-# ATP definition gcdSpec #-}\n\nx≢0≢y : D → D → Set\nx≢0≢y m n = ¬ (m ≡ zero ∧ n ≡ zero)\n{-# ATP definition x≢0≢y #-}\n", "meta": {"hexsha": "bf777eabc4beb1dd02627605bc13601b4bfecf2b", "size": 1257, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/FOTC/Program/GCD/Partial/Definitions.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/FOTC/Program/GCD/Partial/Definitions.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/FOTC/Program/GCD/Partial/Definitions.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 30.6585365854, "max_line_length": 78, "alphanum_fraction": 0.4972155927, "num_tokens": 322, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9005297807787537, "lm_q2_score": 0.7185944046238981, "lm_q1q2_score": 0.647115661664798}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Category.Construction.Kleisli where\n\nopen import Level\n\nopen import Categories.Category\nopen import Categories.Functor using (Functor; module Functor)\nopen import Categories.NaturalTransformation hiding (id)\nopen import Categories.Monad\nimport Categories.Morphism.Reasoning as MR\n\nprivate\n variable\n o ℓ e : Level\n\nKleisli : {𝒞 : Category o ℓ e} → Monad 𝒞 → Category o ℓ e\nKleisli {𝒞 = 𝒞} M = record\n { Obj = Obj\n ; _⇒_ = λ A B → (A ⇒ F₀ B)\n ; _≈_ = _≈_\n ; _∘_ = λ f g → (μ.η _ ∘ F₁ f) ∘ g\n ; id = η.η _\n ; assoc = assoc′\n ; sym-assoc = Equiv.sym assoc′\n ; identityˡ = identityˡ′\n ; identityʳ = identityʳ′\n ; identity² = identity²′\n ; equiv = equiv\n ; ∘-resp-≈ = λ f≈h g≈i → ∘-resp-≈ (∘-resp-≈ʳ (F-resp-≈ f≈h)) g≈i\n }\n where\n module M = Monad M\n open M using (μ; η; F)\n open Functor F\n open Category 𝒞\n open HomReasoning\n open MR 𝒞\n\n -- shorthands to make the proofs nicer\n F≈ = F-resp-≈\n\n assoc′ : ∀ {A B C D} {f : A ⇒ F₀ B} {g : B ⇒ F₀ C} {h : C ⇒ F₀ D}\n → (μ.η D ∘ (F₁ ((μ.η D ∘ F₁ h) ∘ g))) ∘ f ≈ (μ.η D ∘ F₁ h) ∘ ((μ.η C ∘ F₁ g) ∘ f)\n assoc′ {A} {B} {C} {D} {f} {g} {h} =\n begin\n (μ.η D ∘ F₁ ((μ.η D ∘ F₁ h) ∘ g)) ∘ f ≈⟨ assoc ⟩\n μ.η D ∘ (F₁ ((μ.η D ∘ F₁ h) ∘ g) ∘ f) ≈⟨ refl⟩∘⟨ (F≈ assoc ⟩∘⟨refl ) ⟩\n μ.η D ∘ (F₁ (μ.η D ∘ (F₁ h ∘ g)) ∘ f) ≈⟨ refl⟩∘⟨ (homomorphism ⟩∘⟨refl) ⟩\n μ.η D ∘ ((F₁ (μ.η D) ∘ F₁ (F₁ h ∘ g)) ∘ f) ≈⟨ refl⟩∘⟨ assoc ○ ⟺ assoc ⟩\n (μ.η D ∘ F₁ (μ.η D)) ∘ (F₁ (F₁ h ∘ g) ∘ f) ≈⟨ M.assoc ⟩∘⟨refl ○ assoc ⟩\n μ.η D ∘ (μ.η (F₀ D) ∘ (F₁ (F₁ h ∘ g) ∘ f)) ≈˘⟨ refl⟩∘⟨ assoc ⟩\n μ.η D ∘ ((μ.η (F₀ D) ∘ F₁ (F₁ h ∘ g)) ∘ f) ≈⟨ refl⟩∘⟨ ( (refl⟩∘⟨ homomorphism) ⟩∘⟨refl) ⟩\n μ.η D ∘ ((μ.η (F₀ D) ∘ (F₁ (F₁ h) ∘ F₁ g)) ∘ f) ≈˘⟨ refl⟩∘⟨ (assoc ⟩∘⟨refl) ⟩\n μ.η D ∘ (((μ.η (F₀ D) ∘ F₁ (F₁ h)) ∘ F₁ g) ∘ f) ≈⟨ refl⟩∘⟨ ((μ.commute h ⟩∘⟨refl) ⟩∘⟨refl) ⟩\n μ.η D ∘ (((F₁ h ∘ μ.η C) ∘ F₁ g) ∘ f) ≈⟨ refl⟩∘⟨ (assoc ⟩∘⟨refl) ⟩\n μ.η D ∘ ((F₁ h ∘ (μ.η C ∘ F₁ g)) ∘ f) ≈⟨ refl⟩∘⟨ assoc ○ ⟺ assoc ⟩\n (μ.η D ∘ F₁ h) ∘ ((μ.η C ∘ F₁ g) ∘ f)\n ∎\n\n identityˡ′ : ∀ {A B} {f : A ⇒ F₀ B} → (μ.η B ∘ F₁ (η.η B)) ∘ f ≈ f\n identityˡ′ {A} {B} {f} = elimˡ M.identityˡ\n\n identityʳ′ : ∀ {A B} {f : A ⇒ F₀ B} → (μ.η B ∘ F₁ f) ∘ η.η A ≈ f\n identityʳ′ {A} {B} {f} =\n begin\n (μ.η B ∘ F₁ f) ∘ η.η A ≈⟨ assoc ⟩\n μ.η B ∘ (F₁ f ∘ η.η A) ≈˘⟨ refl⟩∘⟨ η.commute f ⟩\n μ.η B ∘ (η.η (F₀ B) ∘ f) ≈˘⟨ assoc ⟩\n (μ.η B ∘ η.η (F₀ B)) ∘ f ≈⟨ elimˡ M.identityʳ ⟩\n f\n ∎\n\n identity²′ : {A : Obj} → (μ.η A ∘ F₁ (η.η A)) ∘ η.η A ≈ η.η A\n identity²′ = elimˡ M.identityˡ\n", "meta": {"hexsha": "11f320ba4ba4b7c2d047581a5af20442f699a6a7", "size": 2792, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Category/Construction/Kleisli.agda", "max_stars_repo_name": "Taneb/agda-categories", "max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Categories/Category/Construction/Kleisli.agda", "max_issues_repo_name": "Taneb/agda-categories", "max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Categories/Category/Construction/Kleisli.agda", "max_forks_repo_name": "Taneb/agda-categories", "max_forks_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.2266666667, "max_line_length": 103, "alphanum_fraction": 0.4455587393, "num_tokens": 1478, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.853912760387131, "lm_q2_score": 0.7577943712746406, "lm_q1q2_score": 0.6470902833809588}} {"text": "{-# OPTIONS --prop --without-K --rewriting #-}\n\nmodule Data.Nat.Log2 where\n\nopen import Data.Nat\nopen import Data.Nat.Properties\n\nopen import Relation.Nullary\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as Eq using (_≡_; refl)\n\nopen import Agda.Builtin.Equality.Rewrite\n\nprivate\n aux : (P : ℕ → Set) → P zero → P (suc zero) → ((n : ℕ) → P ⌈ suc (suc n) /2⌉ → P (suc (suc n))) →\n (n : ℕ) → (m : ℕ) → m ≤ n → P m\n aux P bc₀ bc₁ is n zero h = bc₀\n aux P bc₀ bc₁ is n (suc zero) h = bc₁\n aux P bc₀ bc₁ is (suc (suc n)) (suc (suc m)) (s≤s (s≤s h)) =\n is m (aux P bc₀ bc₁ is (suc n) ⌈ suc (suc m) /2⌉ (s≤s (≤-trans (⌈n/2⌉≤n m) h)))\n\nstrong-induction : (P : ℕ → Set) → P zero → P (suc zero) → ((n : ℕ) → P ⌈ suc (suc n) /2⌉ → P (suc (suc n))) → (n : ℕ) → P n\nstrong-induction P bc₀ bc₁ is n = aux P bc₀ bc₁ is n n ≤-refl\n\nstrong-induction/is : ∀ {P bc₀ bc₁ is n} →\n aux P bc₀ bc₁ is (suc n) ⌈ suc (suc n) /2⌉ (s≤s (≤-trans (⌈n/2⌉≤n n) ≤-refl)) ≡\n strong-induction P bc₀ bc₁ is ⌈ suc (suc n) /2⌉\nstrong-induction/is {P} {bc₀} {bc₁} {is} {n} = aux/unique\n where\n aux/unique : ∀ {m n₁ n₂ h₁ h₂} → aux P bc₀ bc₁ is n₁ m h₁ ≡ aux P bc₀ bc₁ is n₂ m h₂\n aux/unique {zero} = refl\n aux/unique {suc zero} = refl\n aux/unique {suc (suc m)} {h₁ = s≤s (s≤s h₁)} {h₂ = s≤s (s≤s h₂)} = Eq.cong (is m) aux/unique\n{-# REWRITE strong-induction/is #-}\n\n⌈log₂_⌉ : ℕ → ℕ\n⌈log₂_⌉ = strong-induction (λ _ → ℕ) zero zero (λ _ → suc)\n\nlog₂-mono : ⌈log₂_⌉ Preserves _≤_ ⟶ _≤_\nlog₂-mono {n₁} {n₂} =\n strong-induction (λ n₁ → ∀ n₂ → n₁ ≤ n₂ → ⌈log₂ n₁ ⌉ ≤ ⌈log₂ n₂ ⌉)\n (λ _ _ → z≤n)\n (λ _ _ → z≤n)\n (λ { n₁ ih (suc (suc n₂)) (s≤s (s≤s h)) → s≤s (ih ⌈ suc (suc n₂) /2⌉ (⌈n/2⌉-mono (s≤s (s≤s h))))})\n n₁\n n₂\n\n⌈log₂n⌉≤n : ∀ n → ⌈log₂ n ⌉ ≤ n\n⌈log₂n⌉≤n n = strong-induction' n n ≤-refl\n where\n strong-induction' : (n m : ℕ) → m ≤ n → ⌈log₂ m ⌉ ≤ m\n strong-induction' n zero h = z≤n\n strong-induction' n (suc zero) h = z≤n\n strong-induction' (suc (suc n)) (suc (suc m)) (s≤s (s≤s h)) =\n s≤s (\n let open ≤-Reasoning in\n begin\n ⌈log₂ suc ⌈ m /2⌉ ⌉\n ≤⟨ strong-induction' (suc n) (suc ⌈ m /2⌉) (s≤s (≤-trans (⌈n/2⌉≤n m) h)) ⟩\n suc ⌈ m /2⌉\n ≤⟨ s≤s (⌈n/2⌉≤n m) ⟩\n suc m\n ∎\n )\n\nlog₂-suc : ∀ n {k} → ⌈log₂ n ⌉ ≤ suc k → ⌈log₂ ⌈ n /2⌉ ⌉ ≤ k\nlog₂-suc zero h = z≤n\nlog₂-suc (suc zero) h = z≤n\nlog₂-suc (suc (suc n)) (s≤s h) = h\n\n⌈log₂n⌉≡0⇒n≤1 : {n : ℕ} → ⌈log₂ n ⌉ ≡ 0 → n ≤ 1\n⌈log₂n⌉≡0⇒n≤1 {zero} refl = z≤n\n⌈log₂n⌉≡0⇒n≤1 {suc zero} refl = s≤s z≤n\n", "meta": {"hexsha": "e954d0d6a9d9c1d8c55914591975b8c9bcd12233", "size": 2560, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Nat/Log2.agda", "max_stars_repo_name": "jonsterling/agda-calf", "max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 29, "max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z", "max_issues_repo_path": "src/Data/Nat/Log2.agda", "max_issues_repo_name": "jonsterling/agda-calf", "max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/Nat/Log2.agda", "max_forks_repo_name": "jonsterling/agda-calf", "max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z", "avg_line_length": 34.5945945946, "max_line_length": 124, "alphanum_fraction": 0.5296875, "num_tokens": 1349, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127529517043, "lm_q2_score": 0.7577943767446202, "lm_q1q2_score": 0.6470902824173197}} {"text": "module x10-747Lists-hc where\n\n-- Library\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; sym; trans; cong)\nopen Eq.≡-Reasoning\nopen import Data.Bool using (Bool; true; false; T; _∧_; _∨_; not)\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_; _≤_; s≤s; z≤n)\nopen import Data.Nat.Properties using (+-assoc; +-identityˡ; +-identityʳ; *-assoc; *-identityˡ; *-identityʳ)\nopen import Relation.Nullary using (¬_; Dec; yes; no)\nopen import Data.Product using (_×_; ∃; ∃-syntax) renaming (_,_ to ⟨_,_⟩)\nopen import Data.Sum using (_⊎_; inj₁; inj₂)\nopen import Function using (_∘_)\nopen import Level using (Level)\nopen import Data.Empty using (⊥)\n\n------------------------------------------------------------------------------\n-- Copied from 747Isomorphism.\n\ninfix 0 _≃_\nrecord _≃_ (A B : Set) : Set where\n constructor mk-≃ -- This has been added, not in PLFA\n field\n to : A → B\n from : B → A\n from∘to : ∀ (x : A) → from (to x) ≡ x\n to∘from : ∀ (y : B) → to (from y) ≡ y\nopen _≃_\n\ninfix 0 _≲_\nrecord _≲_ (A B : Set) : Set where\n field\n to : A → B\n from : B → A\n from∘to : ∀ (x : A) → from (to x) ≡ x\nopen _≲_\n\nrecord _⇔_ (A B : Set) : Set where\n field\n to : A → B\n from : B → A\nopen _⇔_\n\n------------------------------------------------------------------------------\n-- Polymorphic lists (parameterized version).\n\ndata List (A : Set) : Set where\n [] : List A\n _∷_ : A → List A → List A\n\ninfixr 5 _∷_\n\n-- example\n_ : List ℕ\n_ = 0 ∷ 1 ∷ 2 ∷ []\n\n-- equivalent indexed version\ndata List' : Set → Set where\n []' : ∀ {A : Set} → List' A\n _∷'_ : ∀ {A : Set} → A → List' A → List' A\n\n-- using implicit arguments in above example (why?)\n_ : List ℕ\n_ = _∷_ {ℕ} 0 (_∷_ {ℕ} 1 (_∷_ {ℕ} 2 ([] {ℕ})))\n\n-- tell Agda to use Haskell lists internally\n{-# BUILTIN LIST List #-}\n\n-- useful syntax\npattern [_] z = z ∷ []\npattern [_,_] y z = y ∷ z ∷ []\npattern [_,_,_] x y z = x ∷ y ∷ z ∷ []\npattern [_,_,_,_] w x y z = w ∷ x ∷ y ∷ z ∷ []\npattern [_,_,_,_,_] v w x y z = v ∷ w ∷ x ∷ y ∷ z ∷ []\npattern [_,_,_,_,_,_] u v w x y z = u ∷ v ∷ w ∷ x ∷ y ∷ z ∷ []\n\n-- append for lists\ninfixr 5 _++_\n\n_++_ : ∀ {A : Set} → List A → List A → List A\n[] ++ ys = ys\n(x ∷ xs) ++ ys = x ∷ (xs ++ ys)\n\n_ : [ 0 , 2 , 4 ] ++ [ 3 , 5 ] ≡ [ 0 , 2 , 4 , 3 , 5 ]\n_ = refl\n\n-- associativity of append\n++-assoc : ∀ {A : Set} → (xs ys zs : List A) → (xs ++ ys) ++ zs ≡ xs ++ (ys ++ zs)\n++-assoc [] ys zs = refl\n++-assoc (x ∷ xs) ys zs rewrite ++-assoc xs ys zs = refl\n\n-- left/right identities for append\n++-identityˡ : ∀ {A : Set} → (xs : List A) → [] ++ xs ≡ xs\n++-identityˡ xs = refl\n\n++-identityʳ : ∀ {A : Set} → (xs : List A) → xs ++ [] ≡ xs\n++-identityʳ [] = refl\n++-identityʳ (x ∷ xs) rewrite ++-identityʳ xs = refl\n\n-- length of a list\nlength : ∀ {A : Set} → List A → ℕ\nlength [] = zero\nlength (x ∷ xs) = suc (length xs)\n\n_ : length [ 0 , 1 , 2 ] ≡ 3\n_ = refl\n\n-- reasoning about length.\nlength-++ : ∀ {A : Set} → (xs ys : List A) → length (xs ++ ys) ≡ length xs + length ys\nlength-++ [] ys = refl\nlength-++ (x ∷ xs) ys rewrite length-++ xs ys = refl\n\n-- quadratic time reverse using structural recursion\nreverse : ∀ {A : Set} → List A → List A\nreverse [] = []\nreverse (x ∷ xs) = reverse xs ++ [ x ]\n\n_ : reverse [ 0 , 1 , 2 ] ≡ [ 2 , 1 , 0 ]\n_ = refl\n\n-- 747/PLFA exercise: RevCommApp (1 point)\n-- reverse commutes with ++\n-- https://gist.github.com/pedrominicz/012e842362f6c65361722ed1aaf10178\n-- The key to this one is NOT splitting ys.\nreverse-++-commute : ∀ {A : Set}\n → (xs ys : List A)\n → reverse (xs ++ ys) ≡ reverse ys ++ reverse xs\nreverse-++-commute [] ys rewrite ++-identityʳ (reverse ys) = refl\nreverse-++-commute (x ∷ xs) ys\n-- reverse ((x ∷ xs) ++ ys) ≡ reverse ys ++ reverse (x ∷ xs)\n-- reverse (xs ++ ys) ++ [ x ] ≡ reverse ys ++ reverse xs ++ [ x ]\n rewrite\n reverse-++-commute xs ys\n-- (reverse ys ++ reverse xs) ++ [ x ] ≡ reverse ys ++ reverse xs ++ [ x ]\n | ++-assoc (reverse ys) (reverse xs) [ x ]\n-- reverse ys ++ reverse xs ++ [ x ] ≡ reverse ys ++ reverse xs ++ [ x ]\n = refl\n\n-- NOT USED\nsnoc : {A : Set} → List A → A → List A\nsnoc [] x = x ∷ []\nsnoc (y ∷ l) x = y ∷ (snoc l x)\n\n-- NOT USED\nsnoc≡app : {A : Set} → (l : List A) → (a : A) → snoc l a ≡ l ++ [ a ]\nsnoc≡app [] a = refl\nsnoc≡app (x ∷ l) a rewrite (snoc≡app l a) = refl\n\n-- NOT USED\nreverse-snoc : ∀ {A : Set} → (xs : List A) → List A\nreverse-snoc [] = []\nreverse-snoc (x ∷ xs) = snoc (reverse-snoc xs) x\n\n_ : reverse-snoc [ 0 , 1 , 2 ] ≡ [ 2 , 1 , 0 ]\n_ = refl\n\n-- NOT USED\nreverse≡reverse-snoc : ∀ {A : Set} → (xs : List A) → reverse xs ≡ reverse-snoc xs\nreverse≡reverse-snoc [] = refl\nreverse≡reverse-snoc (x ∷ xs) -- reverse (x ∷ xs) ≡ reverse-snoc (x ∷ xs)\n -- reverse xs ++ [ x ] ≡ snoc (reverse-snoc xs) x\n rewrite\n reverse≡reverse-snoc xs -- reverse-snoc xs ++ [ x ] ≡ snoc (reverse-snoc xs) x\n | snoc≡app (reverse-snoc xs) x -- reverse-snoc xs ++ [ x ] ≡ reverse-snoc xs ++ [ x ]\n = refl\n\n-- 747/PLFA exercise: RevInvol (1 point)\n-- Reverse is its own inverse.\nreverse-involutive : ∀ {A : Set} → (xs : List A) → reverse (reverse xs) ≡ xs\nreverse-involutive [] = refl\nreverse-involutive (x ∷ xs) -- reverse (reverse (x ∷ xs)) ≡ x ∷ xs\n -- reverse (reverse xs ++ [ x ]) ≡ x ∷ xs\n rewrite\n (reverse-++-commute (reverse xs) [ x ]) -- x ∷ reverse (reverse xs) ≡ x ∷ xs\n | reverse-involutive xs -- x ∷ xs ≡ x ∷ xs\n = refl\n\n-- towards more efficient linear time reverse\n\n-- generalization of reverse\nshunt : ∀ {A : Set} → List A → List A → List A\nshunt [] ys = ys\nshunt (x ∷ xs) ys = shunt xs (x ∷ ys)\n\n-- explanation of what shunt is doing\nshunt-reverse : ∀ {A : Set} → (xs ys : List A) → shunt xs ys ≡ reverse xs ++ ys\nshunt-reverse [] ys = refl\nshunt-reverse (x ∷ xs) [] -- shunt (x ∷ xs) [] ≡ reverse (x ∷ xs) ++ []\n -- shunt xs [ x ] ≡ (reverse xs ++ [ x ]) ++ []\n rewrite\n ++-identityʳ (reverse xs ++ [ x ])\n -- shunt xs [ x ] ≡ reverse xs ++ [ x ]\n | shunt-reverse xs [ x ] -- reverse xs ++ [ x ] ≡ reverse xs ++ [ x ]\n = refl\nshunt-reverse (x ∷ xs) (y ∷ ys)\n -- shunt (x ∷ xs) (y ∷ ys) ≡ reverse (x ∷ xs) ++ y ∷ ys\n -- shunt xs (x ∷ y ∷ ys) ≡ (reverse xs ++ [ x ]) ++ y ∷ ys\n rewrite\n shunt-reverse xs (x ∷ y ∷ ys)\n -- reverse xs ++ x ∷ y ∷ ys ≡ (reverse xs ++ [ x ]) ++ y ∷ ys\n | ++-assoc (reverse xs) [ x ] (y ∷ ys)\n -- reverse xs ++ x ∷ y ∷ ys ≡ reverse xs ++ x ∷ y ∷ ys\n = refl\n\n-- linear reverse is a special case of shunt\nreverse' : ∀ {A : Set} → List A → List A\nreverse' xs = shunt xs []\n\n_ : reverse' [ 0 , 1 , 2 ] ≡ [ 2 , 1 , 0 ]\n_ = refl\n\n-- prove quadratic and linear reverse are equivalent\nreverses : ∀ {A : Set} → (xs : List A) → reverse' xs ≡ reverse xs\nreverses [] = refl\nreverses (x ∷ xs) -- reverse' (x ∷ xs) ≡ reverse (x ∷ xs)\n -- reverse' (x ∷ xs) ≡ reverse xs ++ [ x ]\n rewrite shunt-reverse xs [ x ] -- reverse xs ++ [ x ] ≡ reverse xs ++ [ x ]\n = refl\n\n-- common higher-order list functions\n\nmap : ∀ {A B : Set} → (A → B) → List A → List B\nmap f [] = []\nmap f (x ∷ xs) = f x ∷ map f xs\n\n_ : map suc [ 0 , 1 , 2 ] ≡ [ 1 , 2 , 3 ]\n_ = refl\n\n-- 747/PLFA exercise: MapCompose (1 point)\n-- The map of a composition is the composition of maps.\n-- Changed from PLFA: some arguments made explicit, uses pointwise equality.\nmap-compose : ∀ {A B C : Set} (f : A → B) (g : B → C) (xs : List A)\n → map (g ∘ f) xs ≡ (map g ∘ map f) xs\nmap-compose f g [] = refl\nmap-compose f g (x ∷ xs) -- map (g ∘ f) (x ∷ xs) ≡ (map g ∘ map f) (x ∷ xs)\n -- (g ∘ f) x ∷ map (g ∘ f) xs ≡ (map g ∘ map f) (x ∷ xs)\n rewrite\n map-compose f g xs -- g (f x) ∷ map g (map f xs) ≡ g (f x) ∷ map g (map f xs)\n = refl\n\n-- 747/PLFA exercise: MapAppendComm (1 point)\n-- The map of an append is the append of maps.\n-- Changed from PLFA: some arguments made explicit.\nmap-++-commute : ∀ {A B : Set} (f : A → B) (xs ys : List A)\n → map f (xs ++ ys) ≡ map f xs ++ map f ys\nmap-++-commute f [] ys = refl\nmap-++-commute f (x ∷ xs) ys -- map f ((x ∷ xs) ++ ys) ≡ map f (x ∷ xs) ++ map f ys\n -- f x ∷ map f (xs ++ ys) ≡ f x ∷ map f xs ++ map f ys\n rewrite\n map-++-commute f xs ys -- f x ∷ map f xs ++ map f ys ≡ f x ∷ map f xs ++ map f ys\n = refl\n\n------------------------------------------------------------------------------\n\n-- PLFA exercise: map over trees\n-- trees with leaves of type A and internal nodes of type B\ndata Tree (A B : Set) : Set where\n leaf : A → Tree A B\n node : Tree A B → B → Tree A B → Tree A B\n\nmap-Tree : ∀ {A B C D : Set} → (A → C) → (B → D) → Tree A B → Tree C D\nmap-Tree f g (leaf a) = leaf (f a)\nmap-Tree f g (node tl b tr) = node (map-Tree f g tl) (g b) (map-Tree f g tr)\n\n------------------------------------------------------------------------------\n\n-- Fold-right: put operator ⊗ between each list element (and supplied final element).\n-- ⊗ is considered right-associative.\n-- Fold-right is universal for structural recursion on one argument.\n\nfoldr : ∀ {A B : Set} → (A → B → B) → B → List A → B\nfoldr _⊗_ e [] = e\nfoldr _⊗_ e (x ∷ xs) = x ⊗ foldr _⊗_ e xs\n\n_ : foldr _+_ 0 [ 1 , 2 , 3 , 4 ] ≡ 10\n_ = refl\n\n-- Summing a list using foldr.\n\nsum : List ℕ → ℕ\nsum = foldr _+_ 0\n\n_ : sum [ 1 , 2 , 3 , 4 ] ≡ 10\n_ = refl\n\n-- PLFA exercise: use foldr to define product on lists of naturals\nproduct : List ℕ → ℕ\nproduct = foldr _*_ 1\n\n_ : product [ 1 , 2 , 3 , 4 ] ≡ 24\n_ = refl\n\n-- 747/PLFA exercise: FoldrOverAppend (1 point)\n-- prove foldr over an append can be expressed as foldrs over each list.\nfoldr-++ : ∀ {A B : Set} (_⊗_ : A → B → B) (b : B) (xs ys : List A) →\n foldr _⊗_ b (xs ++ ys) ≡ foldr _⊗_ (foldr _⊗_ b ys) xs\nfoldr-++ _⊗_ b [] ys = refl\nfoldr-++ _⊗_ b (x ∷ xs) ys\n -- foldr _⊗_ b ((x ∷ xs) ++ ys) ≡ foldr _⊗_ (foldr _⊗_ b ys) (x ∷ xs)\n -- (x ⊗ foldr _⊗_ b (xs ++ ys)) ≡ (x ⊗ foldr _⊗_ (foldr _⊗_ b ys) xs)\n rewrite foldr-++ _⊗_ b xs ys\n -- (x ⊗ foldr _⊗_ (foldr _⊗_ b ys) xs) ≡ (x ⊗ foldr _⊗_ (foldr _⊗_ b ys) xs)\n = refl\n\n-- 747/PLFA exercise: MapIsFoldr (1 point)\n-- Show that map can be expressed as a fold.\n-- Changed from PLFA: some arguments made explicit, uses pointwise equality.\nmap-is-foldr : ∀ {A B : Set} (f : A → B) (xs : List A)\n → map f xs ≡ foldr (λ x rs → f x ∷ rs) [] xs\nmap-is-foldr f [] = refl\nmap-is-foldr f (x ∷ xs) rewrite map-is-foldr f xs = refl\n\n-- PLFA exercise: write a fold for trees\nfold-Tree : ∀ {A B C : Set} → (A → C) → (C → B → C → C) → Tree A B → C\nfold-Tree f g (leaf a) = f a\nfold-Tree f g (node tl b tr) = g (fold-Tree f g tl) b (fold-Tree f g tr)\n\n-- PLFA exercise: the downFrom function computes a countdown list\n-- Prove an equality about its sum\n\ndownFrom : ℕ → List ℕ\ndownFrom zero = []\ndownFrom (suc n) = n ∷ downFrom n\n\n_ : downFrom 4 ≡ [ 3 , 2 , 1 , 0 ]\n_ = refl\n\n_ : sum (downFrom 4) ≡ 6\n_ = refl\n{- TODO\nsum-downFrom : ∀ (n : ℕ) → sum (downFrom n) * 2 ≡ n * (n ∸ 1)\nsum-downFrom n = {!!}\n-}\n\n------------------------------------------------------------------------------\n\n-- 'Monoid' : set with\n-- - an associative operator\n-- - an element which is the left and right identity\nrecord IsMonoid (A : Set) : Set where\n field\n id : A\n _⊗_ : A → A → A\n assoc : ∀ (x y z : A) → (x ⊗ y) ⊗ z ≡ x ⊗ (y ⊗ z)\n identityˡ : ∀ (x : A) → id ⊗ x ≡ x\n identityʳ : ∀ (x : A) → x ⊗ id ≡ x\n\n-- The following open command is different from PLFA; it uses instance arguments,\n-- which work like typeclasses in Haskell (allow overloading, which is cleaner).\n\nopen IsMonoid {{ ...}} public\n\n-- These pragmas make displays of goal and context look nicer.\n{-# DISPLAY IsMonoid.id _ = id #-}\n{-# DISPLAY IsMonoid._⊗_ _ = _⊗_ #-}\n\n-- instances of Monoid\ninstance\n\n +-monoid : IsMonoid ℕ\n IsMonoid.id +-monoid = 0\n IsMonoid._⊗_ +-monoid = _+_\n IsMonoid.assoc +-monoid = +-assoc\n IsMonoid.identityˡ +-monoid = +-identityˡ\n IsMonoid.identityʳ +-monoid = +-identityʳ\n\n *-monoid : IsMonoid ℕ\n IsMonoid.id *-monoid = 1\n IsMonoid._⊗_ *-monoid = _*_\n IsMonoid.assoc *-monoid = *-assoc\n IsMonoid.identityˡ *-monoid = *-identityˡ\n IsMonoid.identityʳ *-monoid = *-identityʳ\n\n ++-monoid : ∀ {A : Set} → IsMonoid (List A)\n IsMonoid.id ++-monoid = []\n IsMonoid._⊗_ ++-monoid = _++_\n IsMonoid.assoc ++-monoid = ++-assoc\n IsMonoid.identityˡ ++-monoid = ++-identityˡ\n IsMonoid.identityʳ ++-monoid = ++-identityʳ\n\n-- property of foldr over a monoid\nfoldr-monoid : ∀ {A : Set} → {{m : IsMonoid A}} →\n ∀ (xs : List A) (y : A)\n → foldr _⊗_ y xs ≡ (foldr _⊗_ id xs) ⊗ y\nfoldr-monoid {A} ⦃ m ⦄ [] y\n rewrite identityˡ y = refl\nfoldr-monoid {A} ⦃ m ⦄ (x ∷ xs) y\n with foldr-monoid xs y\n... | xxx\n rewrite\n xxx\n | sym (assoc x (foldr _⊗_ id xs) y)\n = refl\n\nfoldr-monoid-++ : ∀ {A : Set} → {{m : IsMonoid A}} →\n ∀ (xs ys : List A)\n → foldr _⊗_ id (xs ++ ys) ≡ foldr _⊗_ id xs ⊗ foldr _⊗_ id ys\nfoldr-monoid-++ {A} ⦃ m ⦄ [] ys\n rewrite\n sym (foldr-monoid {A} {{m}} [] (foldr _⊗_ id ys))\n = refl\nfoldr-monoid-++ {A} ⦃ m ⦄ (x ∷ xs) ys\n rewrite\n foldr-monoid-++ {A} {{m}} xs ys\n | assoc x (foldr _⊗_ id xs) (foldr _⊗_ id ys)\n = refl\n\n-- 747/PLFA exercise: Foldl (1 point)\n-- Define foldl, which associates left instead of right, e.g.\n-- foldr _⊗_ e [ x , y , z ] = x ⊗ (y ⊗ (z ⊗ e))\n-- foldl _⊗_ e [ x , y , z ] = ((e ⊗ x) ⊗ y) ⊗ z\n\nfoldl : ∀ {A B : Set} → (B → A → B) → B → List A → B\nfoldl _⊗_ e [] = e\nfoldl _⊗_ e (x ∷ xs) = foldl _⊗_ (e ⊗ x) xs\n\nsum-foldl : foldl _+_ 0 [ 4 , 3 , 2 , 1 ] ≡ 10\nsum-foldl = refl\n\nmonus-foldl : foldl _∸_ 20 [ 4 , 3 , 2 ] ≡ 11\nmonus-foldl = refl\n\nmonus-foldr : foldr _∸_ 20 [ 4 , 3 , 2 ] ≡ 1\nmonus-foldr = refl\n\n-- 747/PLFA exercise: FoldrMonFoldl (2 points)\n-- Show that foldr and foldl compute the same value on a monoid\n-- when the base case is the identity.\n-- Hint: generalize to when the base case is an arbitrary value.\n\nfoldl-r-mon-helper : ∀ {A : Set} {{m : IsMonoid A}}\n → ∀ (xs : List A) (y : A)\n → foldl _⊗_ y xs ≡ y ⊗ foldl _⊗_ id xs\nfoldl-r-mon-helper [] y rewrite identityʳ y = refl\nfoldl-r-mon-helper (x ∷ xs) y -- foldl _⊗_ y (x ∷ xs) ≡ (y ⊗ foldl _⊗_ id (x ∷ xs))\n -- foldl _⊗_ (y ⊗ x) xs ≡ (y ⊗ foldl _⊗_ (id ⊗ x) xs)\n rewrite\n identityˡ x -- foldl _⊗_ (y ⊗ x) xs ≡ (y ⊗ foldl _⊗_ x xs)\n | foldl-r-mon-helper xs (y ⊗ x) -- ((y ⊗ x) ⊗ foldl _⊗_ id xs) ≡ (y ⊗ foldl _⊗_ x xs)\n | assoc y x (foldl _⊗_ id xs) -- (y ⊗ (x ⊗ foldl _⊗_ id xs)) ≡ (y ⊗ foldl _⊗_ x xs)\n | foldl-r-mon-helper xs x -- (y ⊗ (x ⊗ foldl _⊗_ id xs)) ≡ (y ⊗ (x ⊗ foldl _⊗_ id xs))\n = refl\n\nfoldl-r-mon : ∀ {A : Set} → {{m : IsMonoid A}}\n → ∀ (xs : List A) → foldl _⊗_ id xs ≡ foldr _⊗_ id xs\nfoldl-r-mon [] = refl\nfoldl-r-mon (x ∷ xs)\n -- foldl _⊗_ id (x ∷ xs) ≡ foldr _⊗_ id (x ∷ xs)\n -- foldl _⊗_ (id ⊗ x) xs ≡ (x ⊗ foldr _⊗_ id xs)\n rewrite\n identityˡ x -- foldl _⊗_ x xs ≡ (x ⊗ foldr _⊗_ id xs)\n | foldl-r-mon-helper xs x -- (x ⊗ foldl _⊗_ id xs) ≡ (x ⊗ foldr _⊗_ id xs)\n | foldl-r-mon xs -- (x ⊗ foldr _⊗_ id xs) ≡ (x ⊗ foldr _⊗_ id xs)\n = refl\n\n------------------------------------------------------------------------------\n\n-- Inductively-defined predicates over lists\n\n-- All P xs means P x holds for every element of xs\ndata All {A : Set} (P : A → Set) : List A → Set where\n [] : All P []\n _∷_ : ∀ {x : A} {xs : List A} → P x → All P xs → All P (x ∷ xs)\n\n_ : All (_≤ 2) [ 0 , 1 , 2 ]\n_ = z≤n ∷ s≤s z≤n ∷ s≤s (s≤s z≤n) ∷ []\n\n-- Any P xs means P x holds for some element of xs\ndata Any {A : Set} (P : A → Set) : List A → Set where\n here : ∀ {x : A} {xs : List A} → P x → Any P (x ∷ xs)\n there : ∀ {x : A} {xs : List A} → Any P xs → Any P (x ∷ xs)\n\n-- membership in list as application of Any\ninfix 4 _∈_ _∉_\n_∈_ : ∀ {A : Set} (x : A) (xs : List A) → Set\nx ∈ xs = Any (x ≡_) xs\n\n_∉_ : ∀ {A : Set} (x : A) (xs : List A) → Set\nx ∉ xs = ¬ (x ∈ xs)\n\n_ : 0 ∈ [ 0 , 1 , 0 , 2 ]\n_ = here refl\n\n_ : 0 ∈ [ 1 , 2 , 0 ]\n_ = there (there (here refl))\n\nnot-in : 3 ∉ [ 0 , 1 , 0 , 2 ]\nnot-in (here ())\nnot-in (there (here ()))\nnot-in (there (there (here ())))\nnot-in (there (there (there (here ()))))\n\n-- The development in PLFA, repeated with our notation.\n\nAll-++-⇔ : ∀ {A : Set} {P : A → Set}\n → (xs ys : List A)\n → All P (xs ++ ys) ⇔ (All P xs × All P ys)\nto (All-++-⇔ xs ys) = to' xs ys\n where\n to' : ∀ {A : Set} {P : A → Set} (xs ys : List A)\n → All P (xs ++ ys) → (All P xs × All P ys)\n to' [] ys = λ All-P-ys → ⟨ [] , All-P-ys ⟩\n to' (x ∷ xs) ys (Px ∷ All-P-xs++ys) with to' xs ys All-P-xs++ys\n ... | ⟨ All-P-xs , All-PP-ys ⟩ = ⟨ Px ∷ All-P-xs , All-PP-ys ⟩\nfrom (All-++-⇔ xs ys) = from' xs ys\n where\n from' : ∀ { A : Set} {P : A → Set} (xs ys : List A)\n → All P xs × All P ys → All P (xs ++ ys)\n from' [] ys = λ { ⟨ All-P-[] , All-P-ys ⟩ → All-P-ys }\n from' (x ∷ xs) ys = λ { ⟨ Px ∷ All-P-xs , All-P-ys ⟩ → Px ∷ from' xs ys ⟨ All-P-xs , All-P-ys ⟩ }\n\n-- PLFA exercise: state and prove Any-++-⇔\nAny-++-⇔ : ∀ {A : Set} {P : A → Set}\n → (xs ys : List A)\n → Any P (xs ++ ys) ⇔ (Any P xs ⊎ Any P ys)\nto (Any-++-⇔ xs ys) = to' xs ys\n where\n to' : ∀ {A : Set} {P : A → Set}\n → (xs ys : List A)\n → Any P (xs ++ ys)\n → (Any P xs ⊎ Any P ys)\n to' [] ys = λ Any-P-ys → inj₂ Any-P-ys\n to' (x ∷ xs) ys (here Px ) = inj₁ (here Px)\n to' (x ∷ xs) ys (there Any-P-xs++ys) with to' xs ys Any-P-xs++ys\n ... | inj₁ Any-P-xs = inj₁ (there Any-P-xs)\n ... | inj₂ Any-P-ys = inj₂ Any-P-ys\nfrom (Any-++-⇔ xs ys) = from' xs ys\n where\n from' : ∀ {A : Set} {P : A → Set}\n → (xs ys : List A)\n → (Any P xs ⊎ Any P ys)\n → Any P (xs ++ ys)\n from' [] ys (inj₂ Any-P-ys) = Any-P-ys\n from' (x ∷ xs) ys (inj₂ Any-P-ys) = there (from' xs ys (inj₂ Any-P-ys))\n from' (x ∷ xs) ys (inj₁ (here Px)) = here Px\n from' (x ∷ xs) ys (inj₁ (there Any-P-xs)) = there (from' xs ys (inj₁ Any-P-xs))\n\n-- use Any-++-⇔ to demonstrate an equivalence relating ∈ and _++_ TODO\n\n\n-- PLFA exercise: Show that the equivalence All-++-⇔ can be extended to an isomorphism.\n\n-- PLFA exercise: Here is a universe-polymorphic version of composition,\n-- and a version of DeMorgan's law for Any and All expressed using it.\n\n_∘'_ : ∀ {ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set ℓ₁} {B : Set ℓ₂} {C : Set ℓ₃}\n → (B → C) → (A → B) → A → C\n(g ∘' f) x = g (f x)\n\n¬Any≃All¬ : ∀ {A : Set} (P : A → Set) (xs : List A)\n → (¬_ ∘' Any P) xs ≃ All (¬_ ∘' P) xs\nto (¬Any≃All¬ _ []) ¬_∘'AnyPxs = []\nto (¬Any≃All¬ P (_ ∷ xs)) ¬_∘'AnyPxs with to (¬Any≃All¬ P xs)\n... | AnyPxs→⊥→Allλx₁→Px₁→⊥xs\n = (λ Px → ¬ here Px ∘'AnyPxs) ∷ AnyPxs→⊥→Allλx₁→Px₁→⊥xs (λ AnyPxs → ¬ there AnyPxs ∘'AnyPxs)\n\nfrom (¬Any≃All¬ _ []) All¬_∘'Pxs ()\nfrom (¬Any≃All¬ P (x ∷ xs)) All¬_∘'Pxs (here Px) with from (¬Any≃All¬ P xs)\n... | All-λx₁→Px₁→⊥-xs→AnyPxs→⊥\n = All-λx₁→Px₁→⊥-xs→AnyPxs→⊥ {!!} {!!}\nfrom (¬Any≃All¬ _ (x ∷ xs)) All¬_∘'Pxs (there AnyPxs) = {!!}\n\nfrom∘to (¬Any≃All¬ P xs) = {!!}\nto∘from (¬Any≃All¬ P xs) = {!!}\n{-\n-- Can we prove the following? If not, explain why.\n-- ¬All≃Any¬ : ∀ {A : Set} (P : A → Set) (xs : List A)\n-- → (¬_ ∘' All P) xs ≃ Any (¬_ ∘' P) xs\n\n-- End of PLFA exercise\n\n-- Decidability of All\n\n-- A Boolean analogue of All\n\nall : ∀ {A : Set} → (A → Bool) → List A → Bool\nall p = foldr _∧_ true ∘ map p\n\n-- A Dec analogue of All\n\n-- A definition of a predicate being decidable\n\nDecidable : ∀ {A : Set} → (A → Set) → Set\nDecidable {A} P = ∀ (x : A) → Dec (P x)\n\nAll? : ∀ {A : Set} {P : A → Set} → Decidable P → Decidable (All P)\nAll? P? [] = yes []\nAll? P? (x ∷ xs) with P? x | All? P? xs\nAll? P? (x ∷ xs) | yes p | yes p₁ = yes (p ∷ p₁)\nAll? P? (x ∷ xs) | yes p | no ¬p = no (λ { (x ∷ x₁) → ¬p x₁})\nAll? P? (x ∷ xs) | no ¬p | _ = no (λ { (x ∷ x₁) → ¬p x})\n\n-- PLFA exercise: repeat above for Any\n\n-- PLFA exercises: All-∀ and Any-∃\n-- You will need the stronger version of extensionality\n-- (for dependent function types) given in PLFA Isomorphism.\n\n-- PLFA exercise: a version of 'filter' for decidable predicates\n\n-- filter? : ∀ {A : Set} {P : A → Set}\n-- → (P? : Decidable P) → List A → ∃[ ys ]( All P ys )\n-- filter? P? xs = {!!}\n-}\n", "meta": {"hexsha": "50def15eb7b9ce4a8a4f5ba5182839ccf5895ea2", "size": 21163, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x10-747Lists-hc.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x10-747Lists-hc.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x10-747Lists-hc.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 34.9224422442, "max_line_length": 108, "alphanum_fraction": 0.4997401125, "num_tokens": 8272, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920116079209, "lm_q2_score": 0.808067208930584, "lm_q1q2_score": 0.6470129590330275}} {"text": "module Ag03 where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong; sym)\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_)\nopen import Data.Nat.Properties using (+-comm; *-comm; +-suc)\n\ndata _≤_ : ℕ → ℕ → Set where\n\n z≤n : ∀ {n : ℕ} → zero ≤ n\n s≤s : ∀ {m n : ℕ} → m ≤ n → suc m ≤ suc n\n\ninfix 4 _≤_\n\ninv-s≤s : ∀ {m n : ℕ}\n → suc m ≤ suc n\n → m ≤ n\n\ninv-s≤s (s≤s m≤n) = m≤n\n\ninv-z≤n : ∀ {m : ℕ}\n → m ≤ zero\n → m ≡ zero\n\ninv-z≤n z≤n = refl\n\n≤-refl : ∀ {n : ℕ} → n ≤ n\n≤-refl {0} = z≤n\n≤-refl {suc n} = s≤s ≤-refl\n\n≤-trans : ∀ {m n p : ℕ } → m ≤ n → n ≤ p → m ≤ p\n≤-trans z≤n _ = z≤n\n≤-trans (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans m≤n n≤p)\n\n≤-antisym : ∀ {m n : ℕ} → m ≤ n → n ≤ m → m ≡ n\n≤-antisym z≤n z≤n = refl\n≤-antisym (s≤s m≤n) (s≤s n≤m) = cong suc (≤-antisym m≤n n≤m)\n\ndata Total (m n : ℕ) : Set where\n forward :\n m ≤ n → Total m n\n flipped :\n n ≤ m → Total m n\n\n+-monoʳ-≤ : ∀ (n p q : ℕ)\n → p ≤ q\n -------------\n → n + p ≤ n + q\n+-monoʳ-≤ zero p q p≤q = p≤q\n+-monoʳ-≤ (suc n) p q p≤q = s≤s (+-monoʳ-≤ n p q p≤q)\n\n+-monoˡ-≤ : ∀ (m n p : ℕ)\n → m ≤ n\n -------------\n → m + p ≤ n + p\n+-monoˡ-≤ m n p m≤n rewrite +-comm m p | +-comm n p = +-monoʳ-≤ p m n m≤n\n\n+-mono-≤ : ∀ (m n p q : ℕ)\n → m ≤ n\n → p ≤ q\n -------------\n → m + p ≤ n + q\n+-mono-≤ m n p q m≤n p≤q = ≤-trans (+-monoˡ-≤ m n p m≤n) (+-monoʳ-≤ n p q p≤q)\n\n*-mono-ʳ : ∀ (n p q : ℕ) → p ≤ q → n * p ≤ n * q\n*-mono-ʳ 0 _ _ p≤q = z≤n\n*-mono-ʳ (suc n) p q p≤q = +-mono-≤ p q (n * p) (n * q) p≤q (*-mono-ʳ n p q p≤q)\n\n*-mono-ˡ : ∀ (m n p : ℕ) → m ≤ n → m * p ≤ n * p\n*-mono-ˡ m n p m≤n rewrite *-comm m p | *-comm n p = *-mono-ʳ p m n m≤n\n\n*-mono : ∀ (m n p q : ℕ) → m ≤ n → p ≤ q → m * p ≤ n * q\n*-mono m n p q m≤n p≤q = ≤-trans (*-mono-ˡ m n p m≤n) (*-mono-ʳ n p q p≤q)\n\ninfix 4 _⟨_\n\ndata _⟨_ : ℕ → ℕ → Set where\n z⟨s : ∀ {n : ℕ} → 0 ⟨ suc n\n s⟨s : ∀ {m n : ℕ} → m ⟨ n → suc m ⟨ suc n\n\n⟨-trans : ∀ {m n p : ℕ} → m ⟨ n → n ⟨ p → m ⟨ p\n⟨-trans z⟨s (s⟨s n⟨p) = z⟨s\n⟨-trans (s⟨s m⟨n) (s⟨s n⟨p) = s⟨s (⟨-trans m⟨n n⟨p)\n\ndata Total-trichotomy (m n : ℕ) : Set where\n lt : m ⟨ n → Total-trichotomy m n\n eq : m ≡ n → Total-trichotomy m n\n gt : n ⟨ m → Total-trichotomy m n\n\ntrichotomy : ∀ (m n : ℕ) → Total-trichotomy m n\ntrichotomy zero zero = eq refl\ntrichotomy zero (suc n) = lt z⟨s\ntrichotomy (suc m) zero = gt z⟨s\ntrichotomy (suc m) (suc n) with trichotomy m n\n... | lt m⟨n = lt (s⟨s m⟨n)\n... | eq m≡n = eq (cong suc m≡n)\n... | gt n⟨m = gt (s⟨s n⟨m)\n\n+-monoʳ-⟨ : ∀ (n p q : ℕ) → p ⟨ q → n + p ⟨ n + q\n+-monoʳ-⟨ 0 _ _ p⟨q = p⟨q\n+-monoʳ-⟨ (suc n) p q p⟨q = s⟨s (+-monoʳ-⟨ n p q p⟨q)\n\n+-monoˡ-⟨ : ∀ (m n p : ℕ) → m ⟨ n → m + p ⟨ n + p\n+-monoˡ-⟨ m n p m⟨n rewrite +-comm m p | +-comm n p = +-monoʳ-⟨ p m n m⟨n\n\n+-mono-⟨ : ∀ (m n p q : ℕ) → m ⟨ n → p ⟨ q → m + p ⟨ n + q\n+-mono-⟨ m n p q m⟨n p⟨q = ⟨-trans (+-monoˡ-⟨ m n p m⟨n) (+-monoʳ-⟨ n p q p⟨q)\n\n≤-iffˡ-⟨ : ∀ (m n : ℕ) → suc m ≤ n → m ⟨ n\n≤-iffˡ-⟨ 0 _ (s≤s z≤n) = z⟨s\n≤-iffˡ-⟨ (suc m) (suc n) (s≤s sm≤n) = s⟨s (≤-iffˡ-⟨ m n sm≤n)\n\n≤-iffʳ-⟨ : ∀ (m n : ℕ) → m ⟨ n → suc m ≤ n\n≤-iffʳ-⟨ .0 .(suc _) z⟨s = s≤s z≤n\n≤-iffʳ-⟨ .(suc _) .(suc _) (s⟨s m⟨n) = s≤s (≤-iffʳ-⟨ _ _ m⟨n)\n\ndata Even : ℕ → Set\ndata Odd : ℕ → Set\n\ndata Even where\n\n zero :\n ---------\n Even zero\n\n suc : ∀ {n : ℕ}\n → Odd n\n ------------\n → Even (suc n)\n\ndata Odd where\n\n suc : ∀ {n : ℕ}\n → Even n\n -----------\n → Odd (suc n)\n\ne+e≡e : ∀ {m n : ℕ}\n → Even m\n → Even n\n ------------\n → Even (m + n)\n\no+e≡o : ∀ {m n : ℕ}\n → Odd m\n → Even n\n -----------\n → Odd (m + n)\n\ne+e≡e zero en = en\ne+e≡e (suc om) en = suc (o+e≡o om en)\n\no+e≡o (suc em) en = suc (e+e≡e em en)\n\no+o≡e : ∀ {m n : ℕ} → Odd m → Odd n → Even (m + n)\no+o≡e {m} {suc n} om (suc en) rewrite +-suc m n = suc (o+e≡o om en)\n\ne+o≡o : ∀ (m n : ℕ) → Even m → Odd n → Odd(m + n)\ne+o≡o .0 .(suc _) zero (suc x) = suc x\ne+o≡o (suc m) (suc n) (suc x) (suc x₁) rewrite +-suc m n = suc (suc (o+e≡o x x₁))\n\ninfixl 7 _e*e_ _o*e_ _o*o_ _e*o_\n_e*e_ : ∀ {m n : ℕ} → Even m → Even n → Even (m * n)\n_o*e_ : ∀ {m n : ℕ} → Odd m → Even n → Even (m * n)\n_o*o_ : ∀ {m n : ℕ} → Odd m → Odd n → Odd (m * n)\n_e*o_ : ∀ {m n : ℕ} → Even m → Odd n → Even (m * n)\n\nzero e*e en = zero\nsuc x e*e en = e+e≡e en (x o*e en)\n\nsuc x o*e en = e+e≡e en (x e*e en)\n\nsuc x o*o on = o+e≡o on (x e*o on)\n\nzero e*o on = zero\nsuc x e*o on = o+o≡e on (x o*o on)\n", "meta": {"hexsha": "00108afab007036889910cc681c15a7ebce22f2e", "size": 4464, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/Ag03.agda", "max_stars_repo_name": "Brethland/LEARNING-STUFF", "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z", "max_issues_repo_path": "Agda/Ag03.agda", "max_issues_repo_name": "Brethland/LEARNING-STUFF", "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Agda/Ag03.agda", "max_forks_repo_name": "Brethland/LEARNING-STUFF", "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z", "avg_line_length": 25.2203389831, "max_line_length": 81, "alphanum_fraction": 0.438172043, "num_tokens": 2403, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972616934406, "lm_q2_score": 0.7431680086124812, "lm_q1q2_score": 0.6470000332761935}} {"text": "module Logics.Or where\n\nopen import Function\nopen import Logics.And\n\n------------------------------------------------------------------------\n-- definitions\n\ninfixl 4 _∨_\n\ndata _∨_ (P Q : Set) : Set where\n ∨-intro₀ : P → P ∨ Q\n ∨-intro₁ : Q → P ∨ Q\n\n------------------------------------------------------------------------\n-- internal stuffs\n\nprivate\n\n p→r+q→r+p∨q=r : ∀ {P Q n} {R : Set n} → (P → R) → (Q → R) → (P ∨ Q) → R\n p→r+q→r+p∨q=r pr _ (∨-intro₀ p) = pr p\n p→r+q→r+p∨q=r _ qr (∨-intro₁ q) = qr q\n\n ∨-comm′ : ∀ {P Q} → (P ∨ Q) → (Q ∨ P)\n ∨-comm′ (∨-intro₀ p) = ∨-intro₁ p\n ∨-comm′ (∨-intro₁ q) = ∨-intro₀ q\n\n ∨-assoc₀ : ∀ {P Q R} → ((P ∨ Q) ∨ R) → (P ∨ (Q ∨ R))\n ∨-assoc₀ (∨-intro₀ (∨-intro₀ x)) = ∨-intro₀ x\n ∨-assoc₀ (∨-intro₀ (∨-intro₁ x)) = ∨-intro₁ $ ∨-intro₀ x\n ∨-assoc₀ (∨-intro₁ x) = ∨-intro₁ $ ∨-intro₁ x\n\n ∨-assoc₁ : ∀ {P Q R} → (P ∨ (Q ∨ R)) → ((P ∨ Q) ∨ R)\n ∨-assoc₁ (∨-intro₀ x) = ∨-intro₀ $ ∨-intro₀ x\n ∨-assoc₁ (∨-intro₁ (∨-intro₀ x)) = ∨-intro₀ $ ∨-intro₁ x\n ∨-assoc₁ (∨-intro₁ (∨-intro₁ x)) = ∨-intro₁ x\n\n ∨-elim : ∀ {P Q n} {R : Set n} → (P → R) → (Q → R) → (P ∨ Q) → R\n ∨-elim = p→r+q→r+p∨q=r\n\n ∨-comm : ∀ {P Q} → (P ∨ Q) ⇔ (Q ∨ P)\n ∨-comm = ∧-intro ∨-comm′ ∨-comm′\n\n ∨-assoc : ∀ {P Q R} → (P ∨ (Q ∨ R)) ⇔ ((P ∨ Q) ∨ R)\n ∨-assoc = ∧-intro ∨-assoc₁ ∨-assoc₀\n\n------------------------------------------------------------------------\n-- public aliases\n\nor-elim : ∀ {P Q n} {R : Set n} → (P → R) → (Q → R) → (P ∨ Q) → R\nor-elim = ∨-elim\n\nor-comm : ∀ {P Q} → (P ∨ Q) ⇔ (Q ∨ P)\nor-comm = ∨-comm\n\nor-assoc : ∀ {P Q R} → (P ∨ (Q ∨ R)) ⇔ ((P ∨ Q) ∨ R)\nor-assoc = ∨-assoc\n", "meta": {"hexsha": "9edc424100a393a68869bdbf3aafafd26a70e512", "size": 1611, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Logics/Or.agda", "max_stars_repo_name": "ice1k/Theorems", "max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z", "max_issues_repo_path": "src/Logics/Or.agda", "max_issues_repo_name": "ice1k/Theorems", "max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Logics/Or.agda", "max_forks_repo_name": "ice1k/Theorems", "max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.775862069, "max_line_length": 73, "alphanum_fraction": 0.3891992551, "num_tokens": 776, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8887587993853654, "lm_q2_score": 0.727975460709318, "lm_q1q2_score": 0.6469945964420216}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Lists where every pair of elements are related (symmetrically)\n------------------------------------------------------------------------\n\n-- Core modules are not meant to be used directly outside of the\n-- standard library.\n\n-- This module should be removable if and when Agda issue\n-- https://github.com/agda/agda/issues/3210 is fixed\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary using (Rel)\n\nmodule Data.List.Relation.Unary.AllPairs.Core\n {a ℓ} {A : Set a} (R : Rel A ℓ) where\n\nopen import Level\nopen import Data.List.Base\nopen import Data.List.Relation.Unary.All\n\n------------------------------------------------------------------------\n-- Definition\n\n-- AllPairs R xs means that every pair of elements (x , y) in xs is a\n-- member of relation R (as long as x comes before y in the list).\n\ninfixr 5 _∷_\n\ndata AllPairs : List A → Set (a ⊔ ℓ) where\n [] : AllPairs []\n _∷_ : ∀ {x xs} → All (R x) xs → AllPairs xs → AllPairs (x ∷ xs)\n", "meta": {"hexsha": "0a4cd7f4815006cbc67b0585bbb0b9ca3015adb3", "size": 1069, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/List/Relation/Unary/AllPairs/Core.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Data/List/Relation/Unary/AllPairs/Core.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Data/List/Relation/Unary/AllPairs/Core.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 30.5428571429, "max_line_length": 72, "alphanum_fraction": 0.5463049579, "num_tokens": 249, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8887587993853655, "lm_q2_score": 0.7279754548076478, "lm_q1q2_score": 0.6469945911968604}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import HoTT\nopen import homotopy.OneSkeleton\n\nmodule homotopy.ConstantToSetFactorization\n {i j} {A : Type i} {B : Type j} (B-is-set : is-set B)\n (f : A → B) (f-is-const : ∀ a₁ a₂ → f a₁ == f a₂) where\n\n private\n Skel : Type i\n Skel = Trunc ⟨0⟩ (OneSkeleton f)\n\n abstract\n Skel-has-all-paths : has-all-paths Skel\n Skel-has-all-paths =\n Trunc-elim (λ _ → Π-is-set λ _ → =-preserves-set Trunc-level)\n (OneSkeleton-elim {P = λ s₁ → ∀ [s₂] → [ s₁ ] == [s₂]}\n (λ a₁ → Trunc-elim (λ _ → =-preserves-set Trunc-level)\n (OneSkeleton-elim {P = λ s₂ → [ point a₁ ] == [ s₂ ]}\n (λ a₂ → ap [_] $ link a₁ a₂ $ f-is-const a₁ a₂)\n (λ _ _ _ → prop-has-all-paths-↓ (Trunc-level {n = ⟨0⟩} _ _))))\n (λ a₁ a₂ p → ↓-cst→app-in λ s₂ →\n prop-has-all-paths-↓ (Trunc-level {n = ⟨0⟩} _ _)))\n\n Skel-is-prop : is-prop Skel\n Skel-is-prop = all-paths-is-prop Skel-has-all-paths\n\n cst-extend : Trunc ⟨-1⟩ A → B\n cst-extend = Trunc-rec B-is-set OneSkeleton-lift\n ∘ Trunc-rec Skel-is-prop ([_] ∘ point)\n\n -- The beta rule.\n -- This is definitionally true, so you don't need it.\n cst-extend-β : cst-extend ∘ [_] == f\n cst-extend-β = idp\n", "meta": {"hexsha": "82f0edb7353d162802e5e7753abd93521a02f6ec", "size": 1275, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "homotopy/ConstantToSetFactorization.agda", "max_stars_repo_name": "danbornside/HoTT-Agda", "max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "homotopy/ConstantToSetFactorization.agda", "max_issues_repo_name": "danbornside/HoTT-Agda", "max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "homotopy/ConstantToSetFactorization.agda", "max_forks_repo_name": "danbornside/HoTT-Agda", "max_forks_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.4594594595, "max_line_length": 78, "alphanum_fraction": 0.5474509804, "num_tokens": 454, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.888758793492457, "lm_q2_score": 0.7279754371026367, "lm_q1q2_score": 0.6469945711714834}} {"text": "import Lvl\nopen import Data.Boolean\nopen import Type\n\nmodule Data.List.Sorting.MergeSort {ℓ} {T : Type{ℓ}} (_≤?_ : T → T → Bool) where\n\nopen import Data.List\nopen import Data.List.Functions as List\nopen import Data.List.Relation.Membership as Membership using (_∈_ ; use ; skip)\nopen import Data.List.Relation.Membership.Proofs\nopen import Data.List.Sorting.Functions(_≤?_)\nopen import Relator.Equals.Proofs\nopen import Structure.Relator.Ordering\n\nmodule _\n (split : List(T) → List(List(T)))\n (_<_ : _)\n ⦃ well-founded : Strict.Properties.WellFounded{ℓ₂ = ℓ}(_<_) ⦄\n ⦃ shrinking-proof : ∀{l}{ll} → ⦃ _ : (ll ∈ split(l)) ⦄ → (ll < l) ⦄\n where\n\n import Data.List.FunctionsProven as Listₚ\n\n -- Definition without using well-founded recursion:\n -- merge-sort = Sorted.concat ∘ List.map merge-sort ∘ split\n -- TODO: Correctness requires proof of split(l) being a partition of l\n merge-sort : List(T) → List(T)\n merge-sort = Strict.Properties.wellfounded-recursion(_<_) f where\n f : (l : List(T)) → ((prev : List(T)) → ⦃ _ : prev < l ⦄ → List(T)) → List(T)\n f(l) rec = mergeAll(Listₚ.map (\\ll p → rec ll ⦃ shrinking-proof ⦃ p ⦄ ⦄) (split l) [∈]-self)\n\nmodule Proofs where\n open import Data.Boolean.Stmt\n open import Data.List.Relation.Permutation\n open import Data.List.Sorting(_≤?_)\n open import Data.List.Sorting.Proofs(_≤?_)\n open import Functional using (_∘₂_)\n open import Logic.Propositional\n open import Relator.Equals\n open import Structure.Relator.Properties\n open import Syntax.Transitivity\n\n module _ (asym : ∀{x y} → (x ≤? y ≡ not(y ≤? x))) where -- TODO: Use Structure.Relator.Properties.Asymmetry by the relation (IsTrue ∘₂ (_≤?_))\n -- module _ (asym : ∀{x y} → (x ≤? y ≡ not(y ≤? x))) (trans : ∀{x y z} → IsTrue(x ≤? y) → IsTrue(y ≤? z) → IsTrue(x ≤? z)) where\n {-\n merge-sort-sorted-proof : ∀{l} → Sorted(merge-sort l)\n merge-sort-sorted-proof {∅} = Sorted.empty\n merge-sort-sorted-proof {a ⊰ ∅} = single\n merge-sort-sorted-proof l@{_ ⊰ _ ⊰ _} with Tuple.map1 merge-sort (split2 l)\n ... | (a , b) = Sorted.merge-sorted-proof asym trans (merge-sort-sorted-proof{l = ∅}) (merge-sort-sorted-proof{l = l})\n -}\n", "meta": {"hexsha": "799a478a9bb4a09f927773789f5178dfdb4773aa", "size": 2184, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/List/Sorting/MergeSort.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/List/Sorting/MergeSort.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/List/Sorting/MergeSort.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.0, "max_line_length": 144, "alphanum_fraction": 0.6584249084, "num_tokens": 701, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772351648677, "lm_q2_score": 0.7401743735019595, "lm_q1q2_score": 0.6469695699304808}} {"text": "open import Type\n\n-- The relation (_⟶_) should be interpreted as \"a term reduces/rewritten to another term\".\n-- Also called: Abstract reduction system, abstract rewriting system, rewriting system.\nmodule ReductionSystem {ℓ₁ ℓ₂} {Term : Type{ℓ₁}} (_⟶_ : Term → Term → Type{ℓ₂}) where\n\nopen import Functional\nopen import Graph.Properties\nopen import Graph.Walk\nopen import Graph.Walk.Proofs\nopen import Lang.Instance\nimport Lvl\nopen import Logic\nopen import Logic.Propositional\nopen import Logic.Predicate\nopen import Relator.Converse\nopen import Relator.Equals\nopen import Relator.Equals.Proofs.Equiv\nopen import Relator.ReflexiveTransitiveClosure\nopen import Structure.Setoid.Uniqueness\nopen import Structure.Relator.Equivalence\nopen import Structure.Relator.Ordering\nopen import Structure.Relator.Properties\nopen import Syntax.Function\nopen import Syntax.Transitivity\n\nopen Graph.Properties using (intro) public\n\n-- The relation (_⟶_) is a function on the left argument.\n-- In terms of paths, it means that there are no forks on any paths.\nDeterministic = ∀{a} → Unique(a ⟶_)\n\n-- A term is reducible when there is a term it can reduce to.\n-- In terms of paths, it means that one can go somewhere else from this point.\nReducible : Term → Stmt\nReducible(a) = ∃(a ⟶_)\n\n-- A term is in normal form when it is irreducible (cannot be reduced any further).\n-- Also called: Irreducible term\n-- In terms of paths, it means that this point is a dead-end.\nNormalForm : Term → Stmt\nNormalForm = FinalVertex(_⟶_)\nmodule NormalForm = FinalVertex\n\n-- \"a normalizes to b\" means that \"a\" reduces to the normal form \"b\".\n-- In terms of paths, this means that the dead end of one path from \"a\" is \"b\".\nrecord _normalizes-to_ (a : Term) (b : Term) : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where\n constructor intro\n field\n reduction : Walk(_⟶_) a b\n ⦃ normalForm ⦄ : NormalForm(b)\n\n-- In terms of paths, this means that there is a path which leads to a dead-end.\nWeaklyNormalizes : Term → Stmt\nWeaklyNormalizes a = ∃(a normalizes-to_)\n\n-- A reduction system is weakly normalizing when all terms in the language have a normal form.\n-- In terms of paths, this means that all points have a path whch eventually lead to a dead-end.\nWeaklyNormalizing = ∀ₗ(WeaklyNormalizes)\n\nStronglyNormalizes : Term → Stmt\nStronglyNormalizes = Strict.Properties.Accessibleₗ(Converse(_⟶_))\n\n-- Every term reduces to a normal form.\n-- Also called: Terminating.\nStronglyNormalizing : Stmt\nStronglyNormalizing = Strict.Properties.WellFounded(Converse(_⟶_))\n\n-- Both a and b reduce to c in zero or more steps.\n-- Also called: _⟶*_*⟵_\nCommonReduct : Term → Term → Term → Stmt\nCommonReduct c a b = (Walk(_⟶_) a c) ∧ (Walk(_⟶_) b c)\n\n-- Both a and b reduce to the same term in zero or more steps.\n-- In terms of paths, this means that paths starting from the two points are able to eventually meet.\n-- Also called: Joinable, _⟶*_*⟵_ _↓_.\nJoinable : Term → Term → Stmt\nJoinable a b = ∃(c ↦ CommonReduct c a b)\n\nmodule Names where\n import Structure.Relator.Names as Names\n\n EverywhereCommonReduct = Names.Subrelation (Walk(_⟶_)) Joinable\n\n module _ (a : Term) where\n Confluent = ∀{b c} → (Walk(_⟶_) a b) → (Walk(_⟶_) a c) → Joinable b c\n Semiconfluent = ∀{b c} → (a ⟶ b) → (Walk(_⟶_) a c) → Joinable b c\n LocallyConfluent = ∀{b c} → (a ⟶ b) → (a ⟶ c) → Joinable b c\n StronglyConfluent = ∀{b c} → (a ⟶ b) → (a ⟶ c) → ∃(d ↦ (ReflexiveClosure(_⟶_) b d) ∧ (Walk(_⟶_) c d))\n DiamondProperty = ∀{b c} → (a ⟶ b) → (a ⟶ c) → ∃(d ↦ (b ⟶ d) ∧ (c ⟶ d))\n\n Confluence = ∀ₗ(Confluent)\n\n-- Also called: The Church-Rosser property\nEverywhereCommonReduct = (Walk(_⟶_)) ⊆₂ Joinable\n\nmodule _ (a : Term) where\n -- A term is confluent when all its reducts have a common reduct.\n -- In terms of paths, this means that paths starting from this point will always eventually meet.\n record Confluent : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where\n constructor intro\n field proof : Names.Confluent(a)\n confluent = inst-fn Confluent.proof\n\n record Semiconfluent : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where\n constructor intro\n field proof : Names.Semiconfluent(a)\n semiconfluent = inst-fn Semiconfluent.proof\n\n record LocallyConfluent : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where\n constructor intro\n field proof : Names.LocallyConfluent(a)\n locally-confluent = inst-fn LocallyConfluent.proof\n\n record StronglyConfluent : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where\n constructor intro\n field proof : Names.StronglyConfluent(a)\n strongly-confluent = inst-fn StronglyConfluent.proof\n\n record DiamondProperty : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where\n constructor intro\n field proof : Names.DiamondProperty(a)\n diamond-property = inst-fn DiamondProperty.proof\n\n-- All terms are confluent.\n-- In terms of paths, this means that parts starting from the same point can always eventually meet.\nConfluence = ∀ₗ(Confluent)\n\nSemiconfluence = ∀ₗ(Semiconfluent)\n\nLocalConfluence = ∀ₗ(LocallyConfluent)\n\nStrongConfluence = ∀ₗ(StronglyConfluent)\n\nrecord Convergent : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where\n constructor intro\n field\n ⦃ confluence ⦄ : Confluence\n ⦃ strongly-normalizing ⦄ : StronglyNormalizing\n\n-- Evaluable = ∃(f ↦ )\n\n\n\n-- All paths from a dead-end results in going nowhere.\nNormal-unique-Path : ∀{a} → ⦃ _ : NormalForm(a) ⦄ → ∀{b} → Walk(_⟶_) a b → (a ≡ b)\nNormal-unique-Path at = [≡]-intro\nNormal-unique-Path ⦃ intro na ⦄ (prepend ab1 sb1b) = [⊥]-elim(na ab1)\n\ninstance\n -- A term reduces to itself in zero steps.\n -- In terms of paths, this means that two paths starting from the same point can reach this same point.\n Joinable-reflexivity : Reflexivity(Joinable)\n ∃.witness (Reflexivity.proof Joinable-reflexivity {x}) = x\n ∃.proof (Reflexivity.proof Joinable-reflexivity {x}) = [∧]-intro Walk.at Walk.at\n\ninstance\n -- When one reduces to the same term as the other, the other also reduces to the same term as the first one.\n Joinable-symmetry : Symmetry(Joinable)\n ∃.witness (Symmetry.proof Joinable-symmetry {x} {y} xy) = [∃]-witness xy\n ∃.proof (Symmetry.proof Joinable-symmetry {x} {y} xy) = [∧]-intro ([∧]-elimᵣ(∃.proof xy)) (([∧]-elimₗ(∃.proof xy)))\n\ninstance\n -- When one reduces to the same term as the other, the other also reduces to the same term as the first one.\n Walk-Joinable-subrelation : Walk(_⟶_) ⊆₂ Joinable\n ∃.witness (_⊆₂_.proof Walk-Joinable-subrelation {y = y} ab) = y\n ∃.proof (_⊆₂_.proof Walk-Joinable-subrelation ab) = [∧]-intro ab (reflexivity(Walk(_⟶_)))\n\nmodule _ ⦃ confl : Confluence ⦄ where\n import Structure.Relator.Names as Names\n\n instance\n Confluence-to-Joinable-transitivity : Transitivity(Joinable)\n Confluence-to-Joinable-transitivity = intro proof where\n proof : Names.Transitivity(Joinable)\n proof {x}{y}{z} ([∃]-intro obj-xy ⦃ [∧]-intro pxxy pyxy ⦄) ([∃]-intro obj-yz ⦃ [∧]-intro pyyz pzyz ⦄) = [∃]-intro obj ⦃ [∧]-intro l r ⦄ where\n objxy-objyz-common-reduct : Joinable obj-xy obj-yz\n objxy-objyz-common-reduct = confluent(y) pyxy pyyz\n\n obj : Term\n obj = [∃]-witness objxy-objyz-common-reduct\n\n l : Walk(_⟶_) x obj\n l = transitivity(Walk(_⟶_)) pxxy ([∧]-elimₗ ([∃]-proof objxy-objyz-common-reduct))\n\n r : Walk(_⟶_) z obj\n r = transitivity(Walk(_⟶_)) pzyz ([∧]-elimᵣ ([∃]-proof objxy-objyz-common-reduct))\n\n instance\n Confluence-to-Joinable-equivalence : Equivalence(Joinable)\n Confluence-to-Joinable-equivalence = intro\n\nmodule _ (det : Deterministic) where\n -- Frege thing\n deterministic-dichotomy : ∀{a b c} → (Walk(_⟶_) a b) → (Walk(_⟶_) a c) → (Walk(_⟶_) b c) ∨ (Walk(_⟶_) c b)\n deterministic-dichotomy at ac = [∨]-introₗ ac\n deterministic-dichotomy (ab @ (prepend _ _)) at = [∨]-introᵣ ab\n deterministic-dichotomy (prepend ab2 b) (prepend ab3 ac) with det ab2 ab3\n ... | [≡]-intro = deterministic-dichotomy b ac\n\n deterministic-step : ∀{a b c} → (a ⟶ b) → (Walk(_⟶_) a c) → ((a ≡ c) ∨ (Walk(_⟶_) b c))\n deterministic-step ab at = [∨]-introₗ [≡]-intro\n deterministic-step ab (prepend ab₁ ac) rewrite det ab ab₁ = [∨]-introᵣ ac\n\n instance\n deterministic-confluence : Confluence\n deterministic-confluence = intro proof where\n proof : Names.Confluence\n proof {c = c} at ac = [∃]-intro c ⦃ [∧]-intro ac at ⦄\n {-# CATCHALL #-}\n proof {b = b} ab at = [∃]-intro b ⦃ [∧]-intro at ab ⦄\n proof (prepend ab1 ab) (prepend ab2 ac) rewrite det ab1 ab2 = proof ab ac\n\n deterministic-unique-normalizes-to : ∀{a} → Unique(a normalizes-to_)\n deterministic-unique-normalizes-to (intro ax) (intro ay) = proof ax ay where\n proof : ∀{a b c} → ⦃ _ : NormalForm(b) ⦄ → ⦃ _ : NormalForm(c) ⦄ → Walk(_⟶_) a b → Walk(_⟶_) a c → (b ≡ c)\n proof at at = [≡]-intro\n proof ⦃ intro normal-x ⦄ ⦃ _ ⦄ at (prepend ab by) = [⊥]-elim(normal-x ab)\n proof ⦃ _ ⦄ ⦃ intro normal-y ⦄ (prepend ab bx) at = [⊥]-elim(normal-y ab)\n proof (prepend ab₁ b₁x) (prepend ab₂ b₂y) rewrite det ab₁ ab₂ = proof b₁x b₂y\n\nconfluence-semiconfluence : Confluence ↔ Semiconfluence\nconfluence-semiconfluence = [↔]-intro (semiconfl ↦ intro(l(semiconfl))) r where\n l : Names.Confluence ← Semiconfluence\n l semiconfl at xc = sub₂(Walk(_⟶_))(Joinable) xc\n l semiconfl (prepend xb₁ b₁b) xc with Semiconfluent.proof semiconfl xb₁ xc\n ... | [∃]-intro d ⦃ [∧]-intro b₁d c₁d ⦄ with l semiconfl b₁b b₁d\n ... | [∃]-intro e ⦃ [∧]-intro be de ⦄ = [∃]-intro e ⦃ [∧]-intro be (transitivity(Walk(_⟶_)) c₁d de) ⦄\n\n r : Confluence → Semiconfluence\n Semiconfluent.proof (r confl) xb xc = Confluent.proof confl (sub₂(_⟶_)(Walk(_⟶_)) xb) xc\n\n-- TODO: Not sure, but maybe?\n{-# TERMINATING #-}\nstrong-confluence-confluence : StrongConfluence → Confluence\nstrong-confluence-confluence strconfl = intro(proof strconfl) where\n proof : StrongConfluence → Names.Confluence\n proof strconfl {x} at at = reflexivity(Joinable)\n proof strconfl {x} at (prepend xb bc) = sub₂(Walk(_⟶_))(Joinable) (prepend xb bc)\n proof strconfl {x} (prepend xb₁ b₁b) at = symmetry(Joinable) (sub₂(Walk(_⟶_))(Joinable) (prepend xb₁ b₁b))\n proof strconfl {x} {b}{c} (prepend xb₁ b₁b) (prepend xb₂ b₂c) with StronglyConfluent.proof strconfl xb₁ xb₂\n proof strconfl {x} {b}{c} (prepend xd db) (prepend xb₁ b₁c) | [∃]-intro d ⦃ [∧]-intro refl b₁d ⦄ with proof strconfl b₁c b₁d\n ... | [∃]-intro e ⦃ [∧]-intro ce de ⦄ with proof strconfl db de\n ... | [∃]-intro f ⦃ [∧]-intro bf ef ⦄ = [∃]-intro f ⦃ [∧]-intro bf (transitivity(Walk(_⟶_)) ce ef) ⦄\n proof strconfl {x} {b}{c} (prepend xb₁ b₁b) (prepend xb₂ b₂c) | [∃]-intro d ⦃ [∧]-intro (super b₁d) b₂d ⦄ with proof strconfl b₁b (sub₂(_⟶_)(Walk(_⟶_)) b₁d)\n ... | [∃]-intro e ⦃ [∧]-intro be de ⦄ with proof strconfl b₂c b₂d\n ... | [∃]-intro f ⦃ [∧]-intro cf df ⦄ with proof strconfl de df\n ... | [∃]-intro g ⦃ [∧]-intro eg fg ⦄ = [∃]-intro g ⦃ [∧]-intro (transitivity(Walk(_⟶_)) be eg) (transitivity(Walk(_⟶_)) cf fg) ⦄\n\nsemiconfluence-everywhere-common-reduct : ⦃ _ : Semiconfluence ⦄ → EverywhereCommonReduct\nsemiconfluence-everywhere-common-reduct ⦃ semiconfl ⦄ = intro proof where\n instance\n confl : Confluence\n confl = [↔]-to-[←] confluence-semiconfluence semiconfl\n\n proof : Names.EverywhereCommonReduct\n proof at = reflexivity(Joinable)\n proof {a}{c} (prepend {b = b} ab bc) = transitivity(Joinable) (sub₂(Walk(_⟶_))(Joinable) (sub₂(_⟶_)(Walk(_⟶_)) ab)) (proof bc)\n\ndiamond-property-locally-confluent : ⦃ _ : ∀ₗ(DiamondProperty) ⦄ → LocalConfluence\nLocallyConfluent.proof (diamond-property-locally-confluent {x}) xb xc = [∃]-map-proof ([∧]-map (sub₂(_⟶_)(Walk(_⟶_))) (sub₂(_⟶_)(Walk(_⟶_)))) (diamond-property _ xb xc)\n\n-- locally-confluent-diamond-property : ⦃ LocalConfluence ⦄ → ∀ₗ(DiamondProperty)\n-- DiamondProperty.proof locally-confluent-diamond-property xb xc = {!locally-confluent _ xb xc!}\n\n-- Terminating ↔ LocalConfluence (TODO: See Newman's lemma)\n-- Convergent → ∀{a} → Unique(a normalizes-to_)\n-- Confluence → (Walk(_⟶_) x y) → NormalForm(y) → (ReflexiveClosure(_⟶_) x y)\n-- Confluence → (Walk(_⟶_) x y) → Unique(NormalForm)\n-- Confluence → ∀{a} → Unique(a normalizes-to_)\n\n", "meta": {"hexsha": "6c609177f06d66f8efc3ae60ea294457d23b4c94", "size": 12132, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "ReductionSystem.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "ReductionSystem.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ReductionSystem.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.6029411765, "max_line_length": 168, "alphanum_fraction": 0.6741674909, "num_tokens": 4133, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357632379241, "lm_q2_score": 0.746138993030751, "lm_q1q2_score": 0.6469291913039934}} {"text": "{-# OPTIONS --without-K #-}\nopen import Type hiding (★)\nopen import Function\nopen import Relation.Binary.PropositionalEquality\n\nopen import Explore.Core\nopen import Explore.Properties\n\n-- Explore ℓ is not an endo functor because of universe levels\nmodule Explore.Monad {a} ℓ where\n\nM = Explore {a} ℓ\n\nmodule _ {A : ★ a} where\n return : A → M A\n return = point-explore\n\n mzero : M A\n mzero = empty-explore\n\n mplus : M A → M A → M A\n mplus = merge-explore\n\n module _ {p} where\n return-ind : ∀ x → ExploreInd p (return x)\n return-ind = point-explore-ind\n\n mzero-ind : ExploreInd p mzero\n mzero-ind = empty-explore-ind\n\n mplus-ind : ∀ {e₀ e₁ : M A}\n → ExploreInd p e₀ → ExploreInd p e₁\n → ExploreInd p (merge-explore e₀ e₁)\n mplus-ind Pe₀ Pe₁ P Pε _P∙_ Pf = (Pe₀ P Pε _P∙_ Pf) P∙ (Pe₁ P Pε _P∙_ Pf)\n\nmodule _ {A B : ★ a} where\n\n infixl 1 _>>=_ _>>=-ind_\n _>>=_ : M A → (A → M B) → M B\n (expᴬ >>= expᴮ) ε _∙_ f = expᴬ ε _∙_ λ x → expᴮ x ε _∙_ f\n\n _>>=-ind_ : ∀ {p}\n {expᴬ : M A} → ExploreInd p expᴬ →\n {expᴮ : A → M B} → (∀ x → ExploreInd p (expᴮ x))\n → ExploreInd p (expᴬ >>= expᴮ)\n _>>=-ind_ {expᴬ} Pᴬ {expᴮ} Pᴮ P Pz _P∙_ Pf\n = Pᴬ (λ e → P (e >>= expᴮ)) Pz _P∙_ λ x → Pᴮ x P Pz _P∙_ Pf\n\n map : (A → B) → M A → M B\n map f e = e >>= return ∘ f\n\n map-ind : ∀ {p} (f : A → B) {expᴬ : M A} → ExploreInd p expᴬ → ExploreInd p (map f expᴬ)\n map-ind f Pᴬ = Pᴬ >>=-ind return-ind ∘ f\n\n private\n {- This law is for free: map f e = e >>= return ∘ f -}\n map' : (A → B) → M A → M B\n map' f exp ε _∙_ g = exp ε _∙_ (g ∘ f)\n\n map'≡map : map' ≡ map\n map'≡map = refl\n\n-- universe issues...\n-- join : M (M A) → M A\n\nmodule _ {A B C : ★ a} (m : M A) (f : A → M B) (g : B → M C) where\n infix 0 _≡e_\n _≡e_ = λ {A} → _≡_ {A = M A}\n\n left-identity : f ≡ (λ x → return x >>= f)\n left-identity = refl\n\n right-identity : m ≡e m >>= return\n right-identity = refl\n\n associativity : m >>= (λ x → f x >>= g) ≡e (m >>= f) >>= g\n associativity = refl\n", "meta": {"hexsha": "406433361d0b03ff1a1e733fbbb8da3f403a4e22", "size": 2159, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lib/Explore/Monad.agda", "max_stars_repo_name": "crypto-agda/explore", "max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z", "max_issues_repo_path": "lib/Explore/Monad.agda", "max_issues_repo_name": "crypto-agda/explore", "max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z", "max_forks_repo_path": "lib/Explore/Monad.agda", "max_forks_repo_name": "crypto-agda/explore", "max_forks_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.6794871795, "max_line_length": 92, "alphanum_fraction": 0.5127373784, "num_tokens": 847, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357735451834, "lm_q2_score": 0.7461389817407017, "lm_q1q2_score": 0.6469291892057647}} {"text": "open import Haskell.Prim\nopen import Agda.Builtin.Nat\n\ndata _≤_ : Nat → Nat → Set where\n instance\n zero-≤ : ∀ {n} → zero ≤ n\n suc-≤ : ∀ {m n} → @0 {{m ≤ n}} → suc m ≤ suc n\n\ndata Tree {l u : Nat} : Set where\n Leaf : @0 {{l ≤ u}} → Tree {l} {u}\n Node : (x : Nat) → Tree {l} {x} → Tree {x} {u} → Tree {l} {u}\n{-# COMPILE AGDA2HS Tree #-}\n", "meta": {"hexsha": "7baa4280264d9399d5410d0c7bde34d00507cd42", "size": 347, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Tree.agda", "max_stars_repo_name": "agda/agda2hs", "max_stars_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 55, "max_stars_repo_stars_event_min_datetime": "2020-10-20T13:36:25.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T21:57:56.000Z", "max_issues_repo_path": "test/Tree.agda", "max_issues_repo_name": "seanpm2001/agda2hs", "max_issues_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 63, "max_issues_repo_issues_event_min_datetime": "2020-10-22T05:19:27.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-25T15:47:30.000Z", "max_forks_repo_path": "test/Tree.agda", "max_forks_repo_name": "seanpm2001/agda2hs", "max_forks_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 18, "max_forks_repo_forks_event_min_datetime": "2020-10-21T22:19:09.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:42:52.000Z", "avg_line_length": 26.6923076923, "max_line_length": 64, "alphanum_fraction": 0.5100864553, "num_tokens": 145, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9207896802383028, "lm_q2_score": 0.7025300573952052, "lm_q1q2_score": 0.6468824269067275}} {"text": "open import Relation.Binary\nopen import Relation.Binary.PropositionalEquality\nopen import Data.Product\nopen import Level\n\nmodule IndexedMap\n {Index : Set} {Key : Index → Set} {_≈_ _<_ : Rel (∃ Key) zero}\n (isOrderedKeySet : IsStrictTotalOrder _≈_ _<_)\n -- Equal keys must have equal indices.\n (indicesEqual : _≈_ =[ proj₁ ]⇒ _≡_)\n (Value : Index → Set)\n where\n", "meta": {"hexsha": "2e93f26b4829e04d9ab459df5de4a694e1b58f86", "size": 408, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "benchmark/monad/IndexedMap.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "benchmark/monad/IndexedMap.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "benchmark/monad/IndexedMap.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 31.3846153846, "max_line_length": 71, "alphanum_fraction": 0.6348039216, "num_tokens": 112, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8962513786759491, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.6468633490584648}} {"text": "{-# OPTIONS --safe #-}\n\nmodule Cubical.Categories.Limits.Terminal where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Data.Sigma\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Categories.Category\nopen import Cubical.Categories.Functor\n\nprivate\n variable\n ℓ ℓ' : Level\n\nmodule _ (C : Precategory ℓ ℓ') where\n open Precategory C\n\n isInitial : (x : ob) → Type (ℓ-max ℓ ℓ')\n isInitial x = ∀ (y : ob) → isContr (C [ x , y ])\n\n isFinal : (x : ob) → Type (ℓ-max ℓ ℓ')\n isFinal x = ∀ (y : ob) → isContr (C [ y , x ])\n\n hasInitialOb : Type (ℓ-max ℓ ℓ')\n hasInitialOb = Σ[ x ∈ ob ] isInitial x\n\n hasFinalOb : Type (ℓ-max ℓ ℓ')\n hasFinalOb = Σ[ x ∈ ob ] isFinal x\n\n -- Initiality of an object is a proposition.\n isPropIsInitial : (x : ob) → isProp (isInitial x)\n isPropIsInitial x = isPropΠ λ y → isPropIsContr\n\n -- Objects that are initial are isomorphic.\n isInitialToIso : {x y : ob} (hx : isInitial x) (hy : isInitial y) →\n CatIso {C = C} x y\n isInitialToIso {x = x} {y = y} hx hy =\n let x→y : C [ x , y ]\n x→y = fst (hx y) -- morphism forwards\n y→x : C [ y , x ]\n y→x = fst (hy x) -- morphism backwards\n x→y→x : x→y ⋆⟨ C ⟩ y→x ≡ id x\n x→y→x = isContr→isProp (hx x) _ _ -- compose to id by uniqueness\n y→x→y : y→x ⋆⟨ C ⟩ x→y ≡ id y\n y→x→y = isContr→isProp (hy y) _ _ -- similar.\n in catiso x→y y→x y→x→y x→y→x\n\n open isUnivalent\n\n -- The type of initial objects of a univalent precategory is a proposition,\n -- i.e. all initial objects are equal.\n isPropInitial : (hC : isUnivalent C) → isProp (hasInitialOb)\n isPropInitial hC x y =\n -- Being initial is a prop ∴ Suffices equal as objects in C.\n Σ≡Prop (isPropIsInitial)\n -- C is univalent ∴ Suffices isomorphic as objects in C.\n (CatIsoToPath hC (isInitialToIso (snd x) (snd y)))\n\n -- Now the dual argument for final objects.\n\n -- Finality of an object is a proposition.\n isPropIsFinal : (x : ob) → isProp (isFinal x)\n isPropIsFinal x = isPropΠ λ y → isPropIsContr\n\n -- Objects that are initial are isomorphic.\n isFinalToIso : {x y : ob} (hx : isFinal x) (hy : isFinal y) →\n CatIso {C = C} x y\n isFinalToIso {x = x} {y = y} hx hy =\n let x→y : C [ x , y ]\n x→y = fst (hy x) -- morphism forwards\n y→x : C [ y , x ]\n y→x = fst (hx y) -- morphism backwards\n x→y→x : x→y ⋆⟨ C ⟩ y→x ≡ id x\n x→y→x = isContr→isProp (hx x) _ _ -- compose to id by uniqueness\n y→x→y : y→x ⋆⟨ C ⟩ x→y ≡ id y\n y→x→y = isContr→isProp (hy y) _ _ -- similar.\n in catiso x→y y→x y→x→y x→y→x\n\n -- The type of final objects of a univalent precategory is a proposition,\n -- i.e. all final objects are equal.\n isPropFinal : (hC : isUnivalent C) → isProp (hasFinalOb)\n isPropFinal hC x y =\n -- Being final is a prop ∴ Suffices equal as objects in C.\n Σ≡Prop (isPropIsFinal)\n -- C is univalent ∴ Suffices isomorphic as objects in C.\n (CatIsoToPath hC (isFinalToIso (snd x) (snd y)))\n", "meta": {"hexsha": "26a933671c1565948872793c4b56f8a4c07f4431", "size": 2991, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Limits/Terminal.agda", "max_stars_repo_name": "kl-i/cubical-0.4", "max_stars_repo_head_hexsha": "0f4d9b6abc83e5c5bd0dbf21f9de1e8644acf282", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Categories/Limits/Terminal.agda", "max_issues_repo_name": "kl-i/cubical-0.4", "max_issues_repo_head_hexsha": "0f4d9b6abc83e5c5bd0dbf21f9de1e8644acf282", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Categories/Limits/Terminal.agda", "max_forks_repo_name": "kl-i/cubical-0.4", "max_forks_repo_head_hexsha": "0f4d9b6abc83e5c5bd0dbf21f9de1e8644acf282", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.3793103448, "max_line_length": 77, "alphanum_fraction": 0.6125041792, "num_tokens": 1083, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.877476793890012, "lm_q2_score": 0.7371581684030624, "lm_q1q2_score": 0.6468391862001527}} {"text": "{-# OPTIONS --cubical --safe #-}\nmodule Algebra where\n\nopen import Prelude\n\nmodule _ {a} {A : Type a} (_∙_ : A → A → A) where\n Associative : Type a\n Associative = ∀ x y z → (x ∙ y) ∙ z ≡ x ∙ (y ∙ z)\n\n Commutative : Type _\n Commutative = ∀ x y → x ∙ y ≡ y ∙ x\n\n Idempotent : Type _\n Idempotent = ∀ x → x ∙ x ≡ x\n\nmodule _ {a b} {A : Type a} {B : Type b} where\n Identityˡ : (A → B → B) → A → Type _\n Identityˡ _∙_ x = ∀ y → x ∙ y ≡ y\n\n Zeroˡ : (A → B → A) → A → Type _\n Zeroˡ _∙_ x = ∀ y → x ∙ y ≡ x\n\n Zeroʳ : (A → B → B) → B → Type _\n Zeroʳ _∙_ x = ∀ y → y ∙ x ≡ x\n\n Identityʳ : (A → B → A) → B → Type _\n Identityʳ _∙_ x = ∀ y → y ∙ x ≡ y\n\n _Distributesʳ_ : (A → B → B) → (B → B → B) → Type _\n _⊗_ Distributesʳ _⊕_ = ∀ x y z → x ⊗ (y ⊕ z) ≡ (x ⊗ y) ⊕ (x ⊗ z)\n\n _Distributesˡ_ : (B → A → B) → (B → B → B) → Type _\n _⊗_ Distributesˡ _⊕_ = ∀ x y z → (x ⊕ y) ⊗ z ≡ (x ⊗ z) ⊕ (y ⊗ z)\n\nrecord Semigroup ℓ : Type (ℓsuc ℓ) where\n infixl 6 _∙_\n field\n 𝑆 : Type ℓ\n _∙_ : 𝑆 → 𝑆 → 𝑆\n assoc : ∀ x y z → (x ∙ y) ∙ z ≡ x ∙ (y ∙ z)\n\nrecord Monoid ℓ : Type (ℓsuc ℓ) where\n infixl 6 _∙_\n field\n 𝑆 : Type ℓ\n _∙_ : 𝑆 → 𝑆 → 𝑆\n ε : 𝑆\n assoc : ∀ x y z → (x ∙ y) ∙ z ≡ x ∙ (y ∙ z)\n ε∙ : ∀ x → ε ∙ x ≡ x\n ∙ε : ∀ x → x ∙ ε ≡ x\n\n semigroup : Semigroup ℓ\n semigroup = record\n { 𝑆 = 𝑆; _∙_ = _∙_; assoc = assoc }\n\nrecord MonoidHomomorphism_⟶_\n {ℓ₁ ℓ₂}\n (from : Monoid ℓ₁)\n (to : Monoid ℓ₂)\n : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where\n open Monoid from\n open Monoid to\n renaming ( 𝑆 to 𝑅\n ; _∙_ to _⊙_\n ; ε to ⓔ\n )\n field\n f : 𝑆 → 𝑅\n ∙-homo : ∀ x y → f (x ∙ y) ≡ f x ⊙ f y\n ε-homo : f ε ≡ ⓔ\n\nrecord Group ℓ : Type (ℓsuc ℓ) where\n field\n monoid : Monoid ℓ\n open Monoid monoid public\n field\n inv : 𝑆 → 𝑆\n ∙⁻ : ∀ x → x ∙ inv x ≡ ε\n ⁻∙ : ∀ x → inv x ∙ x ≡ ε\n\nrecord CommutativeMonoid ℓ : Type (ℓsuc ℓ) where\n field\n monoid : Monoid ℓ\n open Monoid monoid public\n field\n comm : Commutative _∙_\n\nrecord Semilattice ℓ : Type (ℓsuc ℓ) where\n field\n commutativeMonoid : CommutativeMonoid ℓ\n open CommutativeMonoid commutativeMonoid public\n field\n idem : Idempotent _∙_\n\nrecord NearSemiring ℓ : Type (ℓsuc ℓ) where\n infixl 6 _+_\n infixl 7 _*_\n field\n 𝑅 : Type ℓ\n _+_ : 𝑅 → 𝑅 → 𝑅\n _*_ : 𝑅 → 𝑅 → 𝑅\n 1# : 𝑅\n 0# : 𝑅\n +-assoc : Associative _+_\n *-assoc : Associative _*_\n 0+ : Identityˡ _+_ 0#\n +0 : Identityʳ _+_ 0#\n 1* : Identityˡ _*_ 1#\n *1 : Identityʳ _*_ 1#\n 0* : Zeroˡ _*_ 0#\n ⟨+⟩* : _*_ Distributesˡ _+_\n\nrecord Semiring ℓ : Type (ℓsuc ℓ) where\n field\n nearSemiring : NearSemiring ℓ\n open NearSemiring nearSemiring public\n field\n +-comm : Commutative _+_\n *0 : Zeroʳ _*_ 0#\n *⟨+⟩ : _*_ Distributesʳ _+_\n\nrecord IdempotentSemiring ℓ : Type (ℓsuc ℓ) where\n field\n semiring : Semiring ℓ\n open Semiring semiring public\n field\n +-idem : Idempotent _+_\n\n\nrecord CommutativeSemiring ℓ : Type (ℓsuc ℓ) where\n field\n semiring : Semiring ℓ\n open Semiring semiring public\n field\n *-comm : Commutative _*_\n\nrecord LeftSemimodule ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where\n field\n semiring : Semiring ℓ₁\n open Semiring semiring public\n field\n semimodule : CommutativeMonoid ℓ₂\n open CommutativeMonoid semimodule renaming (_∙_ to _∪_) public\n renaming (𝑆 to 𝑉\n ; assoc to ∪-assoc\n ; ε∙ to ∅∪\n ; ∙ε to ∪∅\n ; ε to ∅\n )\n infixr 7 _⋊_\n field\n _⋊_ : 𝑅 → 𝑉 → 𝑉\n ⟨*⟩⋊ : ∀ x y z → (x * y) ⋊ z ≡ x ⋊ (y ⋊ z)\n ⟨+⟩⋊ : ∀ x y z → (x + y) ⋊ z ≡ (x ⋊ z) ∪ (y ⋊ z)\n ⋊⟨∪⟩ : _⋊_ Distributesʳ _∪_\n 1⋊ : Identityˡ _⋊_ 1#\n 0⋊ : ∀ x → 0# ⋊ x ≡ ∅\n\nrecord StarSemiring ℓ : Type (ℓsuc ℓ) where\n field\n semiring : Semiring ℓ\n open Semiring semiring public\n field\n _⋆ : 𝑅 → 𝑅\n star-iterʳ : ∀ x → x ⋆ ≡ 1# + x * x ⋆\n star-iterˡ : ∀ x → x ⋆ ≡ 1# + x ⋆ * x\n _⁺ : 𝑅 → 𝑅\n x ⁺ = x * x ⋆\n\nrecord Functor ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where\n field\n 𝐹 : Type ℓ₁ → Type ℓ₂\n map : (A → B) → 𝐹 A → 𝐹 B\n map-id : map (id {ℓ₁} {A}) ≡ id\n map-comp : (f : B → C) → (g : A → B) → map (f ∘ g) ≡ map f ∘ map g\n\nrecord Applicative ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where\n field\n functor : Functor ℓ₁ ℓ₂\n open Functor functor public\n infixl 5 _<*>_\n field\n pure : A → 𝐹 A\n _<*>_ : 𝐹 (A → B) → 𝐹 A → 𝐹 B\n map-ap : (f : A → B) → map f ≡ pure f <*>_\n pure-homo : (f : A → B) → (x : A) → map f (pure x) ≡ pure (f x)\n <*>-interchange : (u : 𝐹 (A → B)) → (y : A) → u <*> pure y ≡ map (_$ y) u\n <*>-comp : (u : 𝐹 (B → C)) → (v : 𝐹 (A → B)) → (w : 𝐹 A) → pure _∘′_ <*> u <*> v <*> w ≡ u <*> (v <*> w)\n\nrecord Monad ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where\n field\n applicative : Applicative ℓ₁ ℓ₂\n open Applicative applicative public\n infixl 1 _>>=_\n field\n _>>=_ : 𝐹 A → (A → 𝐹 B) → 𝐹 B\n >>=-idˡ : (f : A → 𝐹 B) → (x : A) → (pure x >>= f) ≡ f x\n >>=-idʳ : (x : 𝐹 A) → (x >>= pure) ≡ x\n >>=-assoc : (xs : 𝐹 A) (f : A → 𝐹 B) (g : B → 𝐹 C) → ((xs >>= f) >>= g) ≡ (xs >>= (λ x → f x >>= g))\n return : A → 𝐹 A\n return = pure\n\nrecord Alternative ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where\n field\n applicative : Applicative ℓ₁ ℓ₂\n open Applicative applicative public\n field\n 0# : 𝐹 A\n _<|>_ : 𝐹 A → 𝐹 A → 𝐹 A\n <|>-idˡ : (x : 𝐹 A) → 0# <|> x ≡ x\n <|>-idʳ : (x : 𝐹 A) → x <|> 0# ≡ x\n 0-annˡ : (x : 𝐹 A) → 0# <*> x ≡ 0# {B}\n <|>-distrib : (x y : 𝐹 (A → B)) → (z : 𝐹 A) → (x <|> y) <*> z ≡ (x <*> z) <|> (y <*> z)\n\nrecord MonadPlus ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where\n field\n monad : Monad ℓ₁ ℓ₂\n open Monad monad public\n field\n 0# : 𝐹 A\n _<|>_ : 𝐹 A → 𝐹 A → 𝐹 A\n <|>-idˡ : (x : 𝐹 A) → 0# <|> x ≡ x\n <|>-idʳ : (x : 𝐹 A) → x <|> 0# ≡ x\n 0-annˡ : (x : A → 𝐹 B) → (0# >>= x) ≡ 0#\n <|>-distrib : (x y : 𝐹 A) → (z : A → 𝐹 B) → ((x <|> y) >>= z) ≡ (x >>= z) <|> (y >>= z)\n\nEndo : Type a → Type a\nEndo A = A → A\n\nendoMonoid : ∀ {a} → Type a → Monoid a\nendoMonoid A .Monoid.𝑆 = Endo A\nendoMonoid A .Monoid.ε x = x\nendoMonoid A .Monoid._∙_ f g x = f (g x)\nendoMonoid A .Monoid.assoc _ _ _ = refl\nendoMonoid A .Monoid.ε∙ _ = refl\nendoMonoid A .Monoid.∙ε _ = refl\n\nrecord Foldable ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where\n field\n 𝐹 : Type ℓ₁ → Type ℓ₂\n open Monoid ⦃ ... ⦄\n field\n foldMap : {A : Type ℓ₁} ⦃ _ : Monoid ℓ₁ ⦄ → (A → 𝑆) → 𝐹 A → 𝑆\n foldr : {A B : Type ℓ₁} → (A → B → B) → B → 𝐹 A → B\n foldr f b xs = foldMap ⦃ endoMonoid _ ⦄ f xs b\n", "meta": {"hexsha": "d48508cbb1a8525dbd484d2b8e0c66d2ce42124f", "size": 6485, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Algebra.agda", "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z", "max_issues_repo_path": "agda/Algebra.agda", "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Algebra.agda", "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "avg_line_length": 26.3617886179, "max_line_length": 108, "alphanum_fraction": 0.4945258288, "num_tokens": 3214, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774767874818408, "lm_q2_score": 0.7371581568543044, "lm_q1q2_score": 0.6468391713425499}} {"text": "{-# OPTIONS --allow-unsolved-metas #-}\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule AgdaIntroduction where\n\n-- We add 3 to the fixities of the Agda standard library 0.8.1 (see\n-- Data/Nat.agda).\ninfixl 10 _*_\ninfixl 9 _+_\ninfixr 5 _∷_ _++_\ninfix 4 _≡_\n\n-- Dependent function types\nid : (A : Set) → A → A\nid A x = x\n\n-- λ-notation\nid₂ : (A : Set) → A → A\nid₂ = λ A → λ x → x\n\nid₃ : (A : Set) → A → A\nid₃ = λ A x → x\n\n-- Implicit arguments\nid₄ : {A : Set} → A → A\nid₄ x = x\n\nid₅ : {A : Set} → A → A\nid₅ = λ x → x\n\n-- Inductively defined sets and families\ndata Bool : Set where\n false true : Bool\n\ndata ℕ : Set where\n zero : ℕ\n succ : ℕ → ℕ\n\ndata List (A : Set) : Set where\n [] : List A\n _∷_ : A → List A → List A\n\ndata Vec (A : Set) : ℕ → Set where\n [] : Vec A zero\n _∷_ : {n : ℕ} → A → Vec A n → Vec A (succ n)\n\ndata Fin : ℕ → Set where\n fzero : {n : ℕ} → Fin (succ n)\n fsucc : {n : ℕ} → Fin n → Fin (succ n)\n\n-- Structurally recursive functions and pattern matching\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\nsucc m + n = succ (m + n)\n\nmap : {A B : Set} → (A → B) → List A → List B\nmap f [] = []\nmap f (x ∷ xs) = f x ∷ map f xs\n\nf : ℕ → ℕ\nf zero = zero\n{-# CATCHALL #-}\nf _ = succ zero\n\n-- The absurd pattern\nmagic : {A : Set} → Fin zero → A\nmagic ()\n\n-- The with constructor\n\nfilter : {A : Set} → (A → Bool) → List A → List A\nfilter p [] = []\nfilter p (x ∷ xs) with p x\n... | true = x ∷ filter p xs\n... | false = filter p xs\n\nfilter' : {A : Set} → (A → Bool) → List A → List A\nfilter' p [] = []\nfilter' p (x ∷ xs) with p x\nfilter' p (x ∷ xs) | true = x ∷ filter' p xs\nfilter' p (x ∷ xs) | false = filter' p xs\n\n-- Mutual definitions\neven : ℕ → Bool\nodd : ℕ → Bool\n\neven zero = true\neven (succ n) = odd n\n\nodd zero = false\nodd (succ n) = even n\n\ndata EvenList : Set\ndata OddList : Set\n\ndata EvenList where\n [] : EvenList\n _∷_ : ℕ → OddList → EvenList\n\ndata OddList where\n _∷_ : ℕ → EvenList → OddList\n\n-- Normalisation\n\ndata _≡_ {A : Set} : A → A → Set where\n refl : {a : A} → a ≡ a\n\nlength : {A : Set} → List A → ℕ\nlength [] = zero\nlength (x ∷ xs) = succ zero + length xs\n\n_++_ : {A : Set} → List A → List A → List A\n[] ++ ys = ys\n(x ∷ xs) ++ ys = x ∷ xs ++ ys\n\nsuccCong : {m n : ℕ} → m ≡ n → succ m ≡ succ n\nsuccCong refl = refl\n\nlength-++ : {A : Set}(xs ys : List A) →\n length (xs ++ ys) ≡ length xs + length ys\nlength-++ [] ys = refl\nlength-++ (x ∷ xs) ys = succCong (length-++ xs ys)\n\n-- Coverage and termination checkers\nhead : {A : Set} → List A → A\nhead [] = ?\nhead (x ∷ xs) = x\n\nack : ℕ → ℕ → ℕ\nack zero n = succ n\nack (succ m) zero = ack m (succ zero)\nack (succ m) (succ n) = ack m (ack (succ m) n)\n\n-- Combinators for equational reasoning\n\npostulate\n sym : {A : Set}{a b : A} → a ≡ b → b ≡ a\n trans : {A : Set}{a b c : A} → a ≡ b → b ≡ c → a ≡ c\n subst : {A : Set}(P : A → Set){a b : A} → a ≡ b → P a → P b\n\npostulate\n _*_ : ℕ → ℕ → ℕ\n *-comm : ∀ m n → m * n ≡ n * m\n *-rightIdentity : ∀ n → n * succ zero ≡ n\n\n*-leftIdentity : ∀ n → succ zero * n ≡ n\n*-leftIdentity n =\n trans {ℕ} {succ zero * n} {n * succ zero} {n} (*-comm (succ zero) n) (*-rightIdentity n)\n\nmodule ER\n {A : Set}\n (_∼_ : A → A → Set)\n (∼-refl : ∀ {x} → x ∼ x)\n (∼-trans : ∀ {x y z} → x ∼ y → y ∼ z → x ∼ z)\n where\n\n infixr 5 _∼⟨_⟩_\n infix 6 _∎\n\n _∼⟨_⟩_ : ∀ x {y z} → x ∼ y → y ∼ z → x ∼ z\n _ ∼⟨ x∼y ⟩ y∼z = ∼-trans x∼y y∼z\n\n _∎ : ∀ x → x ∼ x\n _∎ _ = ∼-refl\n\nopen module ≡-Reasoning = ER _≡_ (refl {ℕ}) (trans {ℕ})\n renaming ( _∼⟨_⟩_ to _≡⟨_⟩_ )\n\n*-leftIdentity' : ∀ n → succ zero * n ≡ n\n*-leftIdentity' n =\n succ zero * n ≡⟨ *-comm (succ zero) n ⟩\n n * succ zero ≡⟨ *-rightIdentity n ⟩\n n ∎\n", "meta": {"hexsha": "89c620b0fbffddd0735d0df8e0ad2d0c1e70841e", "size": 3854, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/thesis/report/AgdaIntroduction.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/thesis/report/AgdaIntroduction.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/thesis/report/AgdaIntroduction.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 21.7740112994, "max_line_length": 90, "alphanum_fraction": 0.5119356513, "num_tokens": 1552, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375735, "lm_q2_score": 0.7956581049086031, "lm_q1q2_score": 0.6467644696527829}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Sets.EquivalenceRelations\nopen import LogicalFormulae\nopen import Setoids.Setoids\nopen import Rings.Definition\nopen import Modules.Definition\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import Lists.Lists\nopen import Vectors\nopen import Groups.Definition\nopen import Orders.Total.Definition\nopen import Groups.Homomorphisms.Definition\nopen import Groups.Homomorphisms.Lemmas\nopen import Rings.Homomorphisms.Definition\n\nmodule Modules.PolynomialModule {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) where\n\nopen Ring R\nopen import Groups.Polynomials.Definition additiveGroup\nopen import Groups.Polynomials.Group additiveGroup\nopen import Rings.Polynomial.Multiplication R\nopen import Rings.Polynomial.Evaluation R\nopen import Rings.Polynomial.Ring R\nopen import Rings.Lemmas polyRing\n\npolynomialRingModule : Module R abelianUnderlyingGroup (λ a b → _*P_ (polyInjection a) b)\nModule.dotWellDefined (polynomialRingModule) r=s t=u = Ring.*WellDefined polyRing (r=s ,, record {}) t=u\nModule.dotDistributesLeft (polynomialRingModule) {r} {s} {t} = Ring.*DistributesOver+ polyRing {polyInjection r} {s} {t}\nModule.dotDistributesRight (polynomialRingModule) {r} {s} {t} = Ring.*DistributesOver+' polyRing {polyInjection r} {polyInjection s} {t}\nModule.dotAssociative (polynomialRingModule) {r} {s} {t} = Equivalence.transitive (Setoid.eq naivePolySetoid) (Ring.*WellDefined polyRing m (Equivalence.reflexive (Setoid.eq naivePolySetoid) {t})) (Equivalence.symmetric (Setoid.eq naivePolySetoid) (Ring.*Associative polyRing {polyInjection r} {polyInjection s} {t}))\n where\n m : Setoid._∼_ naivePolySetoid ((r * s) :: []) ((r * s) :: (([] +P []) +P (0R :: [])))\n m = Equivalence.reflexive (Setoid.eq S) ,, (Equivalence.reflexive (Setoid.eq S) ,, record {})\nModule.dotIdentity (polynomialRingModule) = Ring.identIsIdent polyRing\n\nopen import Modules.Span polynomialRingModule\n\npolynomialBasis : ℕ → NaivePoly\npolynomialBasis zero = polyInjection 1R\npolynomialBasis (succ a) = 0R :: polynomialBasis a\n\ncount : (n : ℕ) → Vec ℕ n\ncount zero = []\ncount (succ n) = 0 ,- vecMap succ (count n)\n\nlemma : {d : _} {D : Set d} → (f : D → List A) → {n : ℕ} → (m : Vec D n) (r : Vec A n) → Setoid._∼_ naivePolySetoid (dot (vecMap (λ i → 0R :: f i) m) r) (0R :: dot (vecMap f m) r)\nlemma f [] [] = reflexive ,, record {}\n where\n open Setoid S\n open Equivalence eq\nlemma f (m ,- ms) (r ,- rs) rewrite refl {x = 0} = transitive (+WellDefined {(r * 0R) :: (((map (_*_ r) (f m)) +P []) +P (0R :: []))} {_} {(r * 0R) :: (((map (_*_ r) (f m)) +P []) +P (0R :: []))} (reflexive {(r * 0R) :: (((map (_*_ r) (f m)) +P []) +P (0R :: []))}) (lemma f ms rs)) (Equivalence.transitive (Setoid.eq S) (Group.identRight additiveGroup) (Ring.timesZero R) ,, +WellDefined {((map (_*_ r) (f m)) +P []) +P (0R :: [])} {dot (vecMap f ms) rs} {(r :: []) *P f m} {dot (vecMap f ms) rs} t (reflexive {dot (vecMap f ms) rs}))\n where\n open Setoid naivePolySetoid\n open Equivalence eq\n open Group polyGroup\n lemm : (v : List A) → polysEqual (map (_*_ r) v) ((r :: []) *P v)\n lemm [] = record {}\n lemm (x :: v) = Equivalence.reflexive (Setoid.eq S) ,, symmetric (transitive (+WellDefined {map (_*_ r) v +P []} {0R :: []} {_} {[]} reflexive (Equivalence.reflexive (Setoid.eq S) ,, record {})) (transitive (identRight {(map (_*_ r) v) +P []}) (identRight {map (_*_ r) v})))\n t : ((map (_*_ r) (f m) +P []) +P (0R :: [])) ∼ ((r :: []) *P f m)\n t = transitive (+WellDefined {map (_*_ r) (f m) +P []} {0R :: []} {_} {[]} reflexive (Equivalence.reflexive (Setoid.eq S) ,, record {})) (transitive (identRight {map (_*_ r) (f m) +P []}) (transitive (identRight {map (_*_ r) (f m)}) (lemm (f m))))\n\nidentityMap : (v : List A) → Setoid._∼_ naivePolySetoid (dot (vecMap polynomialBasis (count (length v))) (listToVec v)) v\nidentityMap [] = record {}\nidentityMap (x :: v) rewrite vecMapCompose succ polynomialBasis (count (length v)) = transitive (+WellDefined {(x * 1R) :: Group.0G additiveGroup :: []} {dot (vecMap (λ i → Group.0G additiveGroup :: polynomialBasis i) (count (length v))) (listToVec v)} {(x * 1R) :: 0R :: []} {0R :: dot (vecMap polynomialBasis (count (length v))) (listToVec v)} (reflexive {(x * 1R) :: 0R :: []}) (lemma polynomialBasis (count (length v)) (listToVec v))) (Equivalence.transitive (Setoid.eq S) (Group.identRight additiveGroup) (Equivalence.transitive (Setoid.eq S) *Commutative identIsIdent) ,, transitive (+WellDefined {0R :: []} {dot (vecMap polynomialBasis (count (length v))) (listToVec v)} {[]} (Equivalence.reflexive (Setoid.eq S) ,, record {}) reflexive) (transitive identLeft (identityMap v)))\n where\n open Group polyGroup\n open Setoid naivePolySetoid\n open Equivalence eq\n\npolynomialBasisSpans : Spans polynomialBasis\npolynomialBasisSpans m = length m , ((count (length m) ,, listToVec m) , identityMap m)\n\n{-\nprivate\n indepWithZero : {n : ℕ} (rs : Vec ℕ n) (indicesDistinct : {a b : ℕ} → (a α ⊕ β\n inr : β -> α ⊕ β\n case : α ⊕ β α.γ β.γ -> γ\n\ntheory\n (lβ) a : α f : α.γ g : β.γ |> case (inl(a), x.f[x], y.g[y]) = f[a]\n (rβ) b : β f : α.γ g : β.γ |> case (inr(b), x.f[x], y.g[y]) = g[b]\n (cη) s : α ⊕ β c : (α ⊕ β).γ |> case (s, x.c[inl(x)], y.c[inr(y)]) = c[s]\n-}\n\nmodule Sum.Signature where\n\nopen import SOAS.Context\n\n-- Type declaration\ndata ST : Set where\n _⊕_ : ST → ST → ST\ninfixl 30 _⊕_\n\n\nopen import SOAS.Syntax.Signature ST public\nopen import SOAS.Syntax.Build ST public\n\n-- Operator symbols\ndata Sₒ : Set where\n inlₒ inrₒ : {α β : ST} → Sₒ\n caseₒ : {α β γ : ST} → Sₒ\n\n-- Term signature\nS:Sig : Signature Sₒ\nS:Sig = sig λ\n { (inlₒ {α}{β}) → (⊢₀ α) ⟼₁ α ⊕ β\n ; (inrₒ {α}{β}) → (⊢₀ β) ⟼₁ α ⊕ β\n ; (caseₒ {α}{β}{γ}) → (⊢₀ α ⊕ β) , (α ⊢₁ γ) , (β ⊢₁ γ) ⟼₃ γ\n }\n\nopen Signature S:Sig public\n", "meta": {"hexsha": "d07a0ac8c6c56a18cacd0af990dfbd2e6b05fb86", "size": 1005, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "out/Sum/Signature.agda", "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_issues_repo_path": "out/Sum/Signature.agda", "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_forks_repo_path": "out/Sum/Signature.agda", "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "avg_line_length": 21.3829787234, "max_line_length": 91, "alphanum_fraction": 0.5273631841, "num_tokens": 464, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392725805822, "lm_q2_score": 0.7310585727705127, "lm_q1q2_score": 0.6462844888858427}} {"text": "{-# OPTIONS --without-K #-}\nmodule algebra.group.core where\n\nopen import level\nopen import algebra.monoid.core\nopen import equality.core\nopen import function.isomorphism\nopen import sum\n\nrecord IsGroup {i} (G : Set i) : Set i where\n field instance mon : IsMonoid G\n open IsMonoid mon public\n\n field\n inv : G → G\n linv : (x : G) → inv x * x ≡ e\n rinv : (x : G) → x * inv x ≡ e\n\nGroup : ∀ i → Set (lsuc i)\nGroup i = Σ (Set i) IsGroup\n\nmodule _ {i} {G : Set i} ⦃ grp : IsGroup G ⦄ where\n open IsGroup ⦃ ... ⦄\n\n left-translation-iso : (g : G) → G ≅ G\n left-translation-iso g = record\n { to = λ x → g * x\n ; from = λ x → inv g * x\n ; iso₁ = λ x → sym (assoc _ _ _)\n · ap (λ u → u * x) (linv g)\n · lunit x\n ; iso₂ = λ x → sym (assoc _ _ _)\n · ap (λ u → u * x) (rinv g)\n · lunit x }\n\n right-translation-iso : (g : G) → G ≅ G\n right-translation-iso g = record\n { to = λ x → x * g\n ; from = λ x → x * inv g\n ; iso₁ = λ x → assoc _ _ _\n · ap (λ u → x * u) (rinv g)\n · runit x\n ; iso₂ = λ x → assoc _ _ _\n · ap (λ u → x * u) (linv g)\n · runit x }\n", "meta": {"hexsha": "0602fac044275ce23571ccccf19bbc234b906970", "size": 1158, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/algebra/group/core.agda", "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 20, "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_issues_repo_path": "src/algebra/group/core.agda", "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_forks_repo_path": "src/algebra/group/core.agda", "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "avg_line_length": 25.1739130435, "max_line_length": 50, "alphanum_fraction": 0.5077720207, "num_tokens": 424, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.903294214513915, "lm_q2_score": 0.7154240079185319, "lm_q1q2_score": 0.6462383672771672}} {"text": "module Thesis.SIRelBigStep.DenSem where\n\nopen import Data.Nat\nopen import Data.Product\nopen import Thesis.SIRelBigStep.Syntax\n\nopen import Data.Nat\n\n⟦_⟧Type : Type → Set\n⟦ σ ⇒ τ ⟧Type = ⟦ σ ⟧Type → ⟦ τ ⟧Type\n⟦ nat ⟧Type = ℕ\n⟦ pair τ1 τ2 ⟧Type = ⟦ τ1 ⟧Type × ⟦ τ2 ⟧Type\n\nimport Base.Denotation.Environment\nmodule Den = Base.Denotation.Environment Type ⟦_⟧Type\nopen import Base.Data.DependentList\n\n⟦_⟧Const : ∀ {τ} → Const τ → ⟦ τ ⟧Type\n⟦ lit n ⟧Const = n\n\n⟦_⟧Primitive : ∀ {τ} → Primitive τ → ⟦ τ ⟧Type\n⟦ succ ⟧Primitive = suc\n⟦ add ⟧Primitive = λ { (n1 , n2) → n1 + n2}\n\n⟦_⟧Term : ∀ {Γ τ} → Term Γ τ → Den.⟦ Γ ⟧Context → ⟦ τ ⟧Type\n⟦_⟧SVal : ∀ {Γ τ} → SVal Γ τ → Den.⟦ Γ ⟧Context → ⟦ τ ⟧Type\n⟦ var x ⟧SVal ρ = Den.⟦ x ⟧Var ρ\n⟦ abs t ⟧SVal ρ = λ v → ⟦ t ⟧Term (v • ρ)\n⟦ cons sv1 sv2 ⟧SVal ρ = ⟦ sv1 ⟧SVal ρ , ⟦ sv2 ⟧SVal ρ\n⟦ const c ⟧SVal ρ = ⟦ c ⟧Const\n\n⟦ val sv ⟧Term ρ = ⟦ sv ⟧SVal ρ\n⟦ app s t ⟧Term ρ = ⟦ s ⟧SVal ρ (⟦ t ⟧SVal ρ)\n⟦ lett s t ⟧Term ρ = ⟦ t ⟧Term ((⟦ s ⟧Term ρ) • ρ)\n⟦ primapp vs vt ⟧Term ρ = ⟦ vs ⟧Primitive (⟦ vt ⟧SVal ρ)\n", "meta": {"hexsha": "a429709d293f643d32013a89205d364a0df2f83c", "size": 1039, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Thesis/SIRelBigStep/DenSem.agda", "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_issues_repo_path": "Thesis/SIRelBigStep/DenSem.agda", "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_forks_repo_path": "Thesis/SIRelBigStep/DenSem.agda", "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "avg_line_length": 28.8611111111, "max_line_length": 59, "alphanum_fraction": 0.593840231, "num_tokens": 510, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9073122288794594, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.6462169650194715}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Fragment.Examples.CSemigroup.Arith.Reasoning where\n\nopen import Fragment.Examples.CSemigroup.Arith.Base\n\n+-direct : ∀ {m n} → (m + 2) + (3 + n) ≡ m + (n + 5)\n+-direct {m} {n} = begin\n (m + 2) + (3 + n)\n ≡⟨ fragment CSemigroupFrex +-csemigroup ⟩\n m + (n + 5)\n ∎\n\nopen import Data.Nat.Properties using (*-distribˡ-+)\n\n+-inner : ∀ {m n k} → k * (m + 2) + k * (3 + n) ≡ (m + n + 5) * k\n+-inner {m} {n} {k} = begin\n k * (m + 2) + k * (3 + n)\n ≡⟨ sym (*-distribˡ-+ k (m + 2) (3 + n)) ⟩\n k * ((m + 2) + (3 + n))\n ≡⟨ cong (k *_) (fragment CSemigroupFrex +-csemigroup) ⟩\n k * (m + n + 5)\n ≡⟨ fragment CSemigroupFrex *-csemigroup ⟩\n (m + n + 5) * k\n ∎\n", "meta": {"hexsha": "0fb776acdd4c099560afd695488473a167dc11a7", "size": 709, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Fragment/Examples/CSemigroup/Arith/Reasoning.agda", "max_stars_repo_name": "yallop/agda-fragment", "max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 18, "max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z", "max_issues_repo_path": "src/Fragment/Examples/CSemigroup/Arith/Reasoning.agda", "max_issues_repo_name": "yallop/agda-fragment", "max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z", "max_forks_repo_path": "src/Fragment/Examples/CSemigroup/Arith/Reasoning.agda", "max_forks_repo_name": "yallop/agda-fragment", "max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z", "avg_line_length": 27.2692307692, "max_line_length": 65, "alphanum_fraction": 0.5049365303, "num_tokens": 321, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9241418220680099, "lm_q2_score": 0.6992544335934766, "lm_q1q2_score": 0.6462102663502097}} {"text": "{-# OPTIONS --without-K #-}\nmodule sets.list.properties where\n\nopen import level\nopen import equality.core\nopen import sets.list.core\n\nmodule _ {i}{A : Set i} where\n data all {j}(P : A → Set j) : List A → Set (i ⊔ j) where\n mk-all : ∀ {x xs} → P x → all P xs → all P (x ∷ xs)\n\n data any {j}(P : A → Set j) : List A → Set (i ⊔ j) where\n hd-any : ∀ {x xs} → P x → any P (x ∷ xs)\n tl-any : ∀ {x xs} → any P xs → any P (x ∷ xs)\n\n elem : A → List A → Set i\n elem x = any (λ x' → x ≡ x')\n", "meta": {"hexsha": "e80a524abddfd57ad0d2b7fa1632b1125678f138", "size": 495, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/sets/list/properties.agda", "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 20, "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_issues_repo_path": "src/sets/list/properties.agda", "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_forks_repo_path": "src/sets/list/properties.agda", "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "avg_line_length": 27.5, "max_line_length": 58, "alphanum_fraction": 0.5373737374, "num_tokens": 185, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.92414182206801, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.6462102489744238}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Algebra.Band.Properties where\n\nopen import Cubical.Core.Everything\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Data.Nat\nopen import Cubical.Data.NatPlusOne\n\nopen import Cubical.Algebra\nopen import Cubical.Algebra.Properties\nopen import Cubical.Algebra.Semigroup.Properties using (isPropIsSemigroup)\n\nopen import Cubical.Relation.Binary.Reasoning.Equality\n\nprivate\n variable\n ??? : Level\n\nisPropIsBand : ??? {B : Type ???} {_???_} ??? isProp (IsBand B _???_)\nisPropIsBand {_} {_} {_???_} (isband aSemigroup aIdem) (isband bSemigroup bIdem) =\n cong??? isband (isPropIsSemigroup aSemigroup bSemigroup) (isPropIdempotent (IsSemigroup.is-set aSemigroup) _???_ aIdem bIdem)\n\nmodule BandLemmas (S : Band ???) where\n open Band S\n\n ^-id : ??? x n ??? x ^ n ??? x\n ^-id x one = refl\n ^-id x (2+ zero) = idem x\n ^-id x (2+ (suc n)) =\n x ??? (x ??? x ^ 1+ n) ???????? assoc x x (x ^ 1+ n) ???\n x ??? x ??? x ^ 1+ n ?????? cong (_??? x ^ 1+ n) (idem x) ???\n x ??? x ^ 1+ n ?????? ^-id x (2+ n) ???\n x ???\n\nopen BandLemmas public\n", "meta": {"hexsha": "bb212ae74f9470b89dc395ffb5804a8e0ae939f3", "size": 1197, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Band/Properties.agda", "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Band/Properties.agda", "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Band/Properties.agda", "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.3513513514, "max_line_length": 127, "alphanum_fraction": 0.6232247285, "num_tokens": 397, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8991213799730774, "lm_q2_score": 0.7185943805178139, "lm_q1q2_score": 0.6461035710520755}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule hott.functions where\n\nopen import hott.core.universe\nopen import hott.core.equality\n\n-- Composition of functions.\n_∘_ : ∀ {ℓ₀ ℓ₁ ℓ₂ : Level} → {A : Type ℓ₀} {B : Type ℓ₁} {C : Type ℓ₂}\n → (B → C) → (A → B) → A → C\nf ∘ g = λ x → f (g x)\n\n-- The identity function.\nid : ∀{ℓ} {A : Type ℓ} → A → A\nid x = x\n\n-- Change the order of arguments in a bivariate function.\nflip : {a b c : Level}{A : Type a}{B : Type b}{C : Type c}\n → (A → B → C) → (B → A → C)\nflip f b a = f a b\n\n-- We want compostion to have very high precedence.\ninfixr 100 _∘_\n\n-- The constant function.\nconstant : ∀ {ℓ₀ ℓ₁}{A : Type ℓ₀}{B : Type ℓ₁} → A → B → A\nconstant a b = a\n\n-- Alternate syntax for dependent function type.\nΠ : ∀{ℓ₀ ℓ₁}{A : Type ℓ₀}(B : A → Type ℓ₁) → Type (ℓ₀ ⊔ ℓ₁)\nΠ {_}{_}{A} B = (a : A) → B(a)\n\n-- One should use f ~ g to mean that f and g are homotopic.\n_~_ : ∀{ℓ₀ ℓ₁}{A : Type ℓ₀}{B : Type ℓ₁} (f g : A → B) → Type (ℓ₁ ⊔ ℓ₀)\nf ~ g = Π λ x → f x ≡ g x\n\ninfixr 1 _~_\n", "meta": {"hexsha": "48b72ee03e36c26b43bc08ffae3a1899d0a0385b", "size": 1002, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/hott/functions.agda", "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "agda/hott/functions.agda", "max_issues_repo_name": "piyush-kurur/hott", "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/hott/functions.agda", "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.3684210526, "max_line_length": 73, "alphanum_fraction": 0.5608782435, "num_tokens": 418, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511543206819, "lm_q2_score": 0.7549149813536516, "lm_q1q2_score": 0.6460948582054988}} {"text": "{-# OPTIONS --without-K --exact-split --safe #-}\n\nopen import Fragment.Algebra.Signature\n\nmodule Fragment.Equational.Theory.Laws (Σ : Signature) where\n\nopen import Fragment.Equational.Theory.Base using (Eq)\n\nopen import Function using (_∘_)\nopen import Data.Empty using (⊥)\nopen import Data.Fin using (#_)\nopen import Data.Sum using (inj₁; inj₂)\nopen import Data.Product using (_,_)\nimport Relation.Binary.PropositionalEquality as PE\n\nopen import Fragment.Algebra.Free Σ\nopen import Fragment.Algebra.Free.Syntax Σ (PE.setoid ⊥)\n\nmodule _ where\n\n private\n a = # 0\n\n dne : ops Σ 1 → Eq Σ 1\n dne ~ = ⟨ ~ ⟩₁ ⟨ ~ ⟩₁ ⟨ a ⟩ , ⟨ a ⟩\n\nmodule _ (e : ops Σ 0) where\n\n private\n a = # 0\n\n idₗ : ops Σ 2 → Eq Σ 1\n idₗ • = ⟨ e ⟩₀ ⟨ • ⟩₂ ⟨ a ⟩ , ⟨ a ⟩\n\n idᵣ : ops Σ 2 → Eq Σ 1\n idᵣ • = ⟨ a ⟩ ⟨ • ⟩₂ ⟨ e ⟩₀ , ⟨ a ⟩\n\n anₗ : ops Σ 2 → Eq Σ 1\n anₗ • = ⟨ e ⟩₀ ⟨ • ⟩₂ ⟨ a ⟩ , ⟨ e ⟩₀\n\n anᵣ : ops Σ 2 → Eq Σ 1\n anᵣ • = ⟨ a ⟩ ⟨ • ⟩₂ ⟨ e ⟩₀ , ⟨ e ⟩₀\n\n invₗ : ops Σ 1 → ops Σ 2 → Eq Σ 1\n invₗ ~ • = (⟨ ~ ⟩₁ ⟨ a ⟩) ⟨ • ⟩₂ ⟨ a ⟩ , ⟨ e ⟩₀\n\n invᵣ : ops Σ 1 → ops Σ 2 → Eq Σ 1\n invᵣ ~ • = ⟨ a ⟩ ⟨ • ⟩₂ (⟨ ~ ⟩₁ ⟨ a ⟩) , ⟨ e ⟩₀\n\nmodule _ where\n\n private\n\n a = # 0\n b = # 1\n c = # 2\n\n hom : ops Σ 1 → ∀ {n} → ops Σ n → Eq Σ n\n hom h {n} f =\n ⟨ h ⟩₁ term f (map ⟨_⟩ (allFin n))\n ,\n term f (map (⟨ h ⟩₁_ ∘ ⟨_⟩) (allFin n))\n where open import Data.Vec using (map; allFin)\n\n comm : ops Σ 2 → Eq Σ 2\n comm • = ⟨ a ⟩ ⟨ • ⟩₂ ⟨ b ⟩ , ⟨ b ⟩ ⟨ • ⟩₂ ⟨ a ⟩\n\n assoc : ops Σ 2 → Eq Σ 3\n assoc • =\n (⟨ a ⟩ ⟨ • ⟩₂ ⟨ b ⟩) ⟨ • ⟩₂ ⟨ c ⟩\n ,\n ⟨ a ⟩ ⟨ • ⟩₂ (⟨ b ⟩ ⟨ • ⟩₂ ⟨ c ⟩)\n", "meta": {"hexsha": "40aef704ec3f146b1fb6845ae846e62898f4dcdb", "size": 1588, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Fragment/Equational/Theory/Laws.agda", "max_stars_repo_name": "yallop/agda-fragment", "max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 18, "max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z", "max_issues_repo_path": "src/Fragment/Equational/Theory/Laws.agda", "max_issues_repo_name": "yallop/agda-fragment", "max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z", "max_forks_repo_path": "src/Fragment/Equational/Theory/Laws.agda", "max_forks_repo_name": "yallop/agda-fragment", "max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z", "avg_line_length": 21.7534246575, "max_line_length": 60, "alphanum_fraction": 0.4943324937, "num_tokens": 744, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511396138365, "lm_q2_score": 0.7549149813536518, "lm_q1q2_score": 0.646094847103081}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Setoids.Setoids\nopen import Functions.Definition\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import Sets.FinSet.Definition\nopen import Groups.Definition\nopen import Groups.SymmetricGroups.Definition\nopen import Decidable.Sets\nopen import Boolean.Definition\n\nmodule Groups.FreeGroup.Definition where\n\ndata FreeCompletion {a : _} (A : Set a) : Set a where\n ofLetter : A → FreeCompletion A\n ofInv : A → FreeCompletion A\n\nfreeCompletionMap : {a b : _} {A : Set a} {B : Set b} (f : A → B) (w : FreeCompletion A) → FreeCompletion B\nfreeCompletionMap f (ofLetter x) = ofLetter (f x)\nfreeCompletionMap f (ofInv x) = ofInv (f x)\n\nfreeInverse : {a : _} {A : Set a} (l : FreeCompletion A) → FreeCompletion A\nfreeInverse (ofLetter x) = ofInv x\nfreeInverse (ofInv x) = ofLetter x\n\nofLetterInjective : {a : _} {A : Set a} {x y : A} → (ofLetter x ≡ ofLetter y) → x ≡ y\nofLetterInjective refl = refl\n\nofInvInjective : {a : _} {A : Set a} {x y : A} → (ofInv x ≡ ofInv y) → x ≡ y\nofInvInjective refl = refl\n\nofLetterOfInv : {a : _} {A : Set a} {x y : A} → ofLetter x ≡ ofInv y → False\nofLetterOfInv ()\n\ndecidableFreeCompletion : {a : _} {A : Set a} → DecidableSet A → DecidableSet (FreeCompletion A)\ndecidableFreeCompletion {A = A} dec = pr\n where\n pr : (a b : FreeCompletion A) → (a ≡ b) || (a ≡ b → False)\n pr (ofLetter x) (ofLetter y) with dec x y\n ... | inl refl = inl refl\n ... | inr x!=y = inr λ p → x!=y (ofLetterInjective p)\n pr (ofLetter x) (ofInv y) = inr λ ()\n pr (ofInv x) (ofLetter y) = inr λ ()\n pr (ofInv x) (ofInv y) with dec x y\n ... | inl refl = inl refl\n ... | inr x!=y = inr λ p → x!=y (ofInvInjective p)\n\nfreeCompletionEqual : {a : _} {A : Set a} (dec : DecidableSet A) (x y : FreeCompletion A) → Bool\nfreeCompletionEqual dec x y with decidableFreeCompletion dec x y\nfreeCompletionEqual dec x y | inl x₁ = BoolTrue\nfreeCompletionEqual dec x y | inr x₁ = BoolFalse\n\nfreeCompletionEqualFalse : {a : _} {A : Set a} (dec : DecidableSet A) {x y : FreeCompletion A} → ((x ≡ y) → False) → (freeCompletionEqual dec x y) ≡ BoolFalse\nfreeCompletionEqualFalse dec {x = x} {y} x!=y with decidableFreeCompletion dec x y\nfreeCompletionEqualFalse dec {x} {y} x!=y | inl x=y = exFalso (x!=y x=y)\nfreeCompletionEqualFalse dec {x} {y} x!=y | inr _ = refl\n\nfreeCompletionEqualFalse' : {a : _} {A : Set a} (dec : DecidableSet A) {x y : FreeCompletion A} → .((freeCompletionEqual dec x y) ≡ BoolFalse) → (x ≡ y) → False\nfreeCompletionEqualFalse' dec {x} {y} pr with decidableFreeCompletion dec x y\nfreeCompletionEqualFalse' dec {x} {y} () | inl x₁\nfreeCompletionEqualFalse' dec {x} {y} pr | inr ans = ans\n\n", "meta": {"hexsha": "61d2691d87f0b91fe74356b57b751c382003c759", "size": 2803, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Groups/FreeGroup/Definition.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Groups/FreeGroup/Definition.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Groups/FreeGroup/Definition.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 42.4696969697, "max_line_length": 160, "alphanum_fraction": 0.6778451659, "num_tokens": 951, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430478583168, "lm_q2_score": 0.7772998560157665, "lm_q1q2_score": 0.646047371428775}} {"text": "import Lvl\nopen import Type\n\nmodule Type.Cardinality {ℓₗ : Lvl.Level} where\n\nimport Type.Functions\nimport Logic.Predicate\n\nmodule _ {ℓₒ₁}{ℓₒ₂} (X : Type{ℓₒ₁}) (Y : Type{ℓₒ₂}) where\n open Type.Functions{ℓₗ}{ℓₒ₁}{ℓₒ₂}\n open Logic.Predicate{ℓₗ}\n\n _≍_ : Type{ℓₗ Lvl.⊔ ℓₒ₁ Lvl.⊔ ℓₒ₂}\n _≍_ = ∃(Bijective{X}{Y})\n\n _≼_ : Type{ℓₗ Lvl.⊔ ℓₒ₁ Lvl.⊔ ℓₒ₂}\n _≼_ = ∃(Injective{X}{Y})\n\n _≽_ : Type{ℓₗ Lvl.⊔ ℓₒ₁ Lvl.⊔ ℓₒ₂}\n _≽_ = ∃(Surjective{X}{Y})\n", "meta": {"hexsha": "9e8eaa87385e3416710656fac0feb88b75a0dc2c", "size": 445, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "old/Type/Cardinality.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "old/Type/Cardinality.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "old/Type/Cardinality.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.1904761905, "max_line_length": 57, "alphanum_fraction": 0.6224719101, "num_tokens": 259, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9111797051879431, "lm_q2_score": 0.7090191214879992, "lm_q1q2_score": 0.6460438340900495}} {"text": "{-# OPTIONS --type-in-type #-}\nmodule Primitive where\n\ninfixr 2 _,_\nrecord Σ (A : Set)(B : A → Set) : Set where\n constructor _,_\n field fst : A\n snd : B fst\n\nopen Σ\n\ndata ⊤ : Set where\n tt : ⊤\n\n∃ : {A : Set}(B : A → Set) → Set\n∃ B = Σ _ B\n\ninfix 10 _≡_\n\ndata _≡_ {A : Set}(a : A) : {B : Set} → B → Set where\n refl : a ≡ a\n\ntrans : ∀ {A B C}{a : A}{b : B}{c : C} → a ≡ b → b ≡ c → a ≡ c\ntrans refl p = p\n\nsym : ∀ {A B}{a : A}{b : B} → a ≡ b → b ≡ a\nsym refl = refl\n\nresp : ∀ {A}{B : A → Set}{a a' : A} →\n (f : (a : A) → B a) → a ≡ a' → f a ≡ f a'\nresp f refl = refl\n\nCat : Set\nCat =\n ∃ λ (Obj : Set) →\n ∃ λ (Hom : Obj → Obj → Set) →\n ∃ λ (id : ∀ X → Hom X X) →\n ∃ λ (_○_ : ∀ {X Y Z} → Hom Y Z → Hom X Y → Hom X Z) →\n ∃ λ (idl : ∀ {X Y}{f : Hom X Y} → id Y ○ f ≡ f) →\n ∃ λ (idr : ∀ {X Y}{f : Hom X Y} → f ○ id X ≡ f) →\n ∃ λ (assoc : ∀ {W X Y Z}{f : Hom W X}{g : Hom X Y}{h : Hom Y Z} →\n (h ○ g) ○ f ≡ h ○ (g ○ f)) →\n ⊤\n\nObj : (C : Cat) → Set\nObj C = fst C\n\nHom : (C : Cat) → Obj C → Obj C → Set\nHom C = fst (snd C)\n\nid : (C : Cat) → ∀ X → Hom C X X\nid C = fst (snd (snd C))\n\ncomp : (C : Cat) → ∀ {X Y Z} → Hom C Y Z → Hom C X Y → Hom C X Z\ncomp C = fst (snd (snd (snd C)))\n\nidl : (C : Cat) → ∀ {X Y}{f : Hom C X Y} → comp C (id C Y) f ≡ f\nidl C = fst (snd (snd (snd (snd C))))\n\nidr : (C : Cat) → ∀ {X Y}{f : Hom C X Y} → comp C f (id C X) ≡ f\nidr C = fst (snd (snd (snd (snd (snd C)))))\n\nassoc : (C : Cat) → ∀ {W X Y Z}{f : Hom C W X}{g : Hom C X Y}{h : Hom C Y Z} →\n comp C (comp C h g) f ≡ comp C h (comp C g f)\nassoc C = fst (snd (snd (snd (snd (snd (snd C))))))\n\n{-\nrecord Functor (C D : Cat) : Set where\n field Fun : Obj C → Obj D\n map : ∀ {X Y} → (Hom C X Y) → Hom D (Fun X) (Fun Y)\n mapid : ∀ {X} → map (id C X) ≡ id D (Fun X)\n map○ : ∀ {X Y Z}{f : Hom C X Y}{g : Hom C Y Z} →\n map (_○_ C g f) ≡ _○_ D (map g) (map f)\n\nopen Functor\n\nidF : ∀ C → Functor C C\nidF C = record {Fun = \\x → x; map = \\x → x; mapid = refl; map○ = refl}\n\n_•_ : ∀ {C D E} → Functor D E → Functor C D → Functor C E\nF • G = record {Fun = \\X → Fun F (Fun G X);\n map = \\f → map F (map G f);\n mapid = trans (resp (\\x → map F x) (mapid G)) (mapid F);\n map○ = trans (resp (\\x → map F x) (map○ G)) (map○ F)}\n\nrecord Nat {C D : Cat} (F G : Functor C D) : Set where\n field η : (X : Obj C) → Hom D (Fun F X) (Fun G X)\n law : {X Y : Obj C}{f : Hom C X Y} →\n _○_ D (η Y) (map F f) ≡ _○_ D (map G f) (η X)\n\nopen Nat\n\n_▪_ : ∀ {C D : Cat}{F G H : Functor C D} → Nat G H → Nat F G → Nat F H\n_▪_ {D = D} A B =\n record {\n η = \\X → _○_ D (η A X) (η B X);\n law = \\{X}{Y} →\n trans (assoc D)\n (trans (resp (\\f → _○_ D (η A Y) f) (law B))\n (trans (sym (assoc D))\n (trans (resp (\\g → _○_ D g (η B X)) (law A))\n (assoc D))))\n }\n\n-}\n", "meta": {"hexsha": "3330130fcf91ba62b2a67b9eb91de61758426137", "size": 2935, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "benchmark/categories/Primitive.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "benchmark/categories/Primitive.agda", "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "benchmark/categories/Primitive.agda", "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 27.6886792453, "max_line_length": 78, "alphanum_fraction": 0.4231686542, "num_tokens": 1271, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872046026642944, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.645863174131978}} {"text": "------------------------------------------------------------------------\n-- The \"always true\" predicate, □\n------------------------------------------------------------------------\n\n{-# OPTIONS --sized-types #-}\n\nmodule Delay-monad.Sized.Always where\n\nopen import Prelude\nopen import Prelude.Size\n\nopen import Delay-monad.Sized\nopen import Delay-monad.Sized.Monad\n\n-- The \"always true\" predicate, □.\n\nmutual\n\n data □ {a p} {A : Size → Type a} (i : Size) (P : A ∞ → Type p) :\n Delay A ∞ → Type (a ⊔ p) where\n now : ∀ {x} → P x → □ i P (now x)\n later : ∀ {x} → □′ i P (force x) → □ i P (later x)\n\n record □′ {a p} {A : Size → Type a} (i : Size) (P : A ∞ → Type p)\n (x : Delay A ∞) : Type (a ⊔ p) where\n coinductive\n field\n force : {j : Size< i} → □ j P x\n\nopen □′ public\n\n-- □ is closed, in a certain sense, under bind.\n\n□->>= :\n ∀ {i a b p q}\n {A : Size → Type a} {B : Size → Type b}\n {P : A ∞ → Type p} {Q : B ∞ → Type q}\n {x : Delay A ∞} {f : ∀ {i} → A i → Delay B i} →\n □ i P x → (∀ {x} → P x → □ i Q (f x)) → □ i Q (x >>= f)\n□->>= (now P-x) □-f = □-f P-x\n□->>= (later □-x) □-f = later λ { .force → □->>= (force □-x) □-f }\n", "meta": {"hexsha": "ee3dcdc0f1b4335131bf78d9331e20acf7b30855", "size": 1177, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Delay-monad/Sized/Always.agda", "max_stars_repo_name": "nad/delay-monad", "max_stars_repo_head_hexsha": "495f9996673d0f1f34ce202902daaa6c39f8925e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Delay-monad/Sized/Always.agda", "max_issues_repo_name": "nad/delay-monad", "max_issues_repo_head_hexsha": "495f9996673d0f1f34ce202902daaa6c39f8925e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Delay-monad/Sized/Always.agda", "max_forks_repo_name": "nad/delay-monad", "max_forks_repo_head_hexsha": "495f9996673d0f1f34ce202902daaa6c39f8925e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.0238095238, "max_line_length": 72, "alphanum_fraction": 0.4214103653, "num_tokens": 433, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872045907347108, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.6458631654475341}} {"text": "{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule CombiningProofs.CommAddGlobalHints where\n\nopen import PA.Axiomatic.Standard.Base\n\n+-leftIdentity : ∀ n → zero + n ≡ n\n+-leftIdentity = PA₃\n\n+-rightIdentity : ∀ n → n + zero ≡ n\n+-rightIdentity = ℕ-ind A A0 is\n where\n A : ℕ → Set\n A i = i + zero ≡ i\n {-# ATP definition A #-}\n\n A0 : A zero\n A0 = +-leftIdentity zero\n\n postulate is : ∀ i → A i → A (succ i)\n {-# ATP prove is #-}\n\nx+Sy≡S[x+y] : ∀ m n → m + succ n ≡ succ (m + n)\nx+Sy≡S[x+y] m n = ℕ-ind A A0 is m\n where\n A : ℕ → Set\n A i = i + succ n ≡ succ (i + n)\n {-# ATP definition A #-}\n\n postulate A0 : A zero\n {-# ATP prove A0 #-}\n\n postulate is : ∀ i → A i → A (succ i)\n {-# ATP prove is #-}\n\n-- Global hints\n{-# ATP hints x+Sy≡S[x+y] +-rightIdentity #-}\n\n+-comm : ∀ m n → m + n ≡ n + m\n+-comm m n = ℕ-ind A A0 is m\n where\n A : ℕ → Set\n A i = i + n ≡ n + i\n {-# ATP definition A #-}\n\n postulate A0 : A zero\n {-# ATP prove A0 #-}\n\n postulate is : ∀ i → A i → A (succ i)\n {-# ATP prove is #-}\n", "meta": {"hexsha": "e26b9a0013042fdde5e1a9ec60dcd49cacb07903", "size": 1150, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/thesis/report/CombiningProofs/CommAddGlobalHints.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/thesis/report/CombiningProofs/CommAddGlobalHints.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/thesis/report/CombiningProofs/CommAddGlobalHints.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 21.2962962963, "max_line_length": 47, "alphanum_fraction": 0.5234782609, "num_tokens": 404, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872045907347108, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.6458631549755561}} {"text": "{-# OPTIONS --safe --warning=error --without-K --guardedness #-}\n\nopen import Functions.Definition\nopen import Functions.Lemmas\nopen import LogicalFormulae\nopen import Numbers.Naturals.Definition\nopen import Numbers.Naturals.Order\nopen import Sets.FinSet.Definition\nopen import Sets.FinSet.Lemmas\nopen import Sets.Cardinality.Infinite.Definition\nopen import Sets.Cardinality.Finite.Lemmas\nopen import Numbers.Reals.Definition\nopen import Numbers.Rationals.Definition\nopen import Numbers.Integers.Definition\nopen import Sets.Cardinality.Infinite.Lemmas\nopen import Setoids.Setoids\n\nmodule Sets.Cardinality.Infinite.Examples where\n\nℕIsInfinite : InfiniteSet ℕ\nℕIsInfinite n f bij = pigeonhole (le 0 refl) badInj\n where\n inv : ℕ → FinSet n\n inv = Invertible.inverse (bijectionImpliesInvertible bij)\n invInj : Injection inv\n invInj = Bijection.inj (invertibleImpliesBijection (inverseIsInvertible (bijectionImpliesInvertible bij)))\n bumpUp : FinSet n → FinSet (succ n)\n bumpUp = intoSmaller (le 0 refl)\n bumpUpInj : Injection bumpUp\n bumpUpInj = intoSmallerInj (le 0 refl)\n nextInj : Injection (toNat {succ n})\n nextInj = finsetInjectIntoℕ {succ n}\n bad : FinSet (succ n) → FinSet n\n bad a = (inv (toNat a))\n badInj : Injection bad\n badInj = injComp nextInj invInj\n\nℝIsInfinite : DedekindInfiniteSet ℝ\nDedekindInfiniteSet.inj ℝIsInfinite n = injectionR (injectionQ (nonneg n))\nDedekindInfiniteSet.isInjection ℝIsInfinite {x} {y} pr = nonnegInjective (injectionQInjective (injectionRInjective pr))\n", "meta": {"hexsha": "a9fde8ec85a91c904e2a8d6ab047f19a0c3bb56b", "size": 1536, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Sets/Cardinality/Infinite/Examples.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Sets/Cardinality/Infinite/Examples.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Sets/Cardinality/Infinite/Examples.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 37.4634146341, "max_line_length": 119, "alphanum_fraction": 0.77734375, "num_tokens": 453, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.868826769445233, "lm_q2_score": 0.7431680086124811, "lm_q1q2_score": 0.645684260077829}} {"text": "module HT where\n\nopen import Prelude\nopen import T\nopen import SubstTheory\nopen import DynTheory\n\n\nmodule HT where\n\n ---- Halting and Hereditary Termination\n -- An old comment about lhs-halt\n\n -- Mostly for fun, I didn't want to include \"and it halts\" as part\n -- of the definition of HT for arrows, and I didn't want to define\n -- it in terms of evaluating to a lambda and then substituting.\n -- This seems to require being able to generate an inhabitant of an\n -- arbitrary type as well as a proof that it is HT. The former is\n -- easy in T and we accomplish the latter by appealing to all-HT,\n -- although we could have also generated the proof along with the\n -- inhabitant. This all seems to be handwaved away when doing it on\n -- paper. Things get more unclear when in a system where not all\n -- types are inhabited; if we know that either a type is inhabited or\n -- it is not, then we are fine. But since we are constructive, we would\n -- get tripped up by a language like System F in which type inhabitability\n -- is undecidable. (Of course, the proof is easy to repair in a number of\n -- ways by modifying the definition of HT.)\n --\n -- When I went to make the system deterministic, I found that I now depended\n -- on HT-halts in all-HT, which broke the previous proof technique.\n -- I decided that proving the inhabitant we construct is HT would be\n -- annoying, so I decided to not bother and went back to hanging onto the\n -- proof that arrows halt.\n\n -- Extract that the lhs must halt if its application to something halts.\n -- I think this isn't actually useful, though, since to use it we would\n -- need to be able to produce an argument to the function.\n {-\n lhs-halt : {A B : TTp} {e : TCExp (A ⇒ B)} {e' : TCExp A} →\n THalts (e $ e') → THalts e\n lhs-halt (halts eval-refl ())\n lhs-halt (halts (eval-cons (step-app-l S1) E) val) with lhs-halt (halts E val)\n ... | halts E' val' = halts (eval-cons S1 E') val'\n lhs-halt (halts (eval-cons step-beta E) val) = halts eval-refl val-lam\n -}\n\n -- I think the induction principle for this datatype is the definition of\n -- HTω from http://www.cs.cmu.edu/~rwh/courses/typesys/hw3/hw3-handout.pdf\n data HTω : TNat → Set where\n HT-z : {e : TNat} → (E : e ~>* zero) → HTω e\n HT-s : {e e' : TNat} → (E : e ~>* suc e') → (HT : HTω e') → HTω e\n\n -- definition of hereditary termination\n HT : (A : TTp) → TCExp A → Set\n HT nat e = THalts e\n -- It is kind of ugly to have to hang on to the halting proof.\n HT (A ⇒ B) e = THalts e × ((e' : TCExp A) → HT A e' → HT B (e $ e'))\n\n -- proof that hereditary termination implies termination\n HT-halts : ∀{A} → (e : TCExp A) → HT A e → THalts e\n HT-halts {nat} e h = h\n HT-halts {A ⇒ B} _ (h , _) = h\n\n\n -- extend HT to substitutions\n HTΓ : (Γ : Ctx) → TSubst Γ [] → Set\n HTΓ Γ γ = ∀{A} (x : A ∈ Γ) -> HT A (γ x)\n\n emptyHTΓ : ∀{γ : TSubst [] []} -> HTΓ [] γ\n emptyHTΓ ()\n\n extendHTΓ : ∀{Γ A} {e : TCExp A} {γ : TSubst Γ []} ->\n HTΓ Γ γ -> HT A e -> HTΓ (A :: Γ) (extendγ γ e)\n extendHTΓ η ht Z = ht\n extendHTΓ {_} {_} {e} {γ} η ht {B} (S n) =\n ID.coe1 (HT B) (extend-nofail-s γ e n) (η n)\n\n -- head expansion lemma\n head-expansion : ∀{A} {e e' : TCExp A} → (e ~>* e') → HT A e' → HT A e\n head-expansion {nat} eval (halts eval₁ val) = halts (eval-trans eval eval₁) val\n head-expansion {A ⇒ B} eval (halts eval' val , ht-logic) =\n halts (eval-trans eval eval') val ,\n (λ e' ht → head-expansion (eval-compat step-app-l eval) (ht-logic e' ht))\n\n -- the main theorem\n all-HT : ∀{Γ A} {γ : TSubst Γ []} → (e : TExp Γ A) → HTΓ Γ γ\n → HT A (ssubst γ e)\n all-HT (var x) η = η x\n all-HT (e₁ $ e₂) η with all-HT e₁ η\n ... | _ , HT₁ = HT₁ (ssubst _ e₂) (all-HT e₂ η)\n all-HT zero η = halts eval-refl val-zero\n all-HT (suc e) η with all-HT e η\n ... | halts eval val = halts (eval-compat step-suc eval) (val-suc val)\n\n all-HT {Γ} {A ⇒ B} {γ} (Λ e) η =\n (halts eval-refl val-lam) ,\n lam-case\n where lam-case : (e' : TCExp A) → HT A e' → HT B (Λ (ssubst (liftγ γ) e) $ e')\n lam-case e' ht' with all-HT {γ = extendγ γ e'} e (extendHTΓ η ht')\n ... | ht with eval-step (step-beta {e = (ssubst (liftγ γ) e)})\n ... | steps-full with combine-subst-noob γ e e'\n ... | eq = head-expansion steps-full (ID.coe1 (HT B) eq ht)\n\n all-HT {Γ} {A} {γ} (rec e e₀ es) η with all-HT e η\n ... | halts E val = head-expansion (eval-compat step-rec E) (inner val)\n where inner : {n : TNat} → TVal n → HT A (rec n (ssubst γ e₀) (ssubst (liftγ γ) es))\n inner val-zero = head-expansion (eval-step step-rec-z) (all-HT e₀ η)\n inner (val-suc v) with all-HT es (extendHTΓ η (inner v))\n ... | ht with eval-step (step-rec-s v)\n ... | steps with combine-subst-noob γ es _\n ... | eq = head-expansion steps (ID.coe1 (HT A) eq ht)\n\n -- Prove that all programs in Gödel's System T halt.\n all-halt : ∀{A} → (e : TCExp A) → THalts e\n all-halt {A} e = HT-halts e (ID.coe1 (HT A) (subid e) (all-HT e (emptyHTΓ {emptyγ})))\n\nopen HT public\n", "meta": {"hexsha": "1ef8de03687edac624c588746be8e8fe7858aa93", "size": 5101, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "HT.agda", "max_stars_repo_name": "msullivan/godels-t", "max_stars_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2016-12-25T01:52:57.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-22T00:28:03.000Z", "max_issues_repo_path": "HT.agda", "max_issues_repo_name": "msullivan/godels-t", "max_issues_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HT.agda", "max_forks_repo_name": "msullivan/godels-t", "max_forks_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-04-26T11:39:14.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-04T22:37:18.000Z", "avg_line_length": 43.2288135593, "max_line_length": 88, "alphanum_fraction": 0.6106645756, "num_tokens": 1756, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891261650247, "lm_q2_score": 0.7853085859124002, "lm_q1q2_score": 0.6456721800212075}} {"text": "module Data.List.Relation.Binary.Subset.Propositional.Instances where\n\nopen import Data.List using (List; _∷_; [])\nopen import Data.List.Relation.Unary.Any using (here; there)\nopen import Data.List.Membership.Propositional using (_∈_; _∉_)\nopen import Data.List.Membership.Setoid.Properties using (∈-resp-≈)\nopen import Data.List.Relation.Binary.Subset.Propositional using (_⊆_)\n\nopen import Relation.Nullary.Negation using (contradiction)\n\nopen import Relation.Binary.PropositionalEquality using (sym; setoid)\n\nopen import Level using (Level)\n\nprivate\n variable\n a : Level\n A : Set a\n x y : A\n xs ys : List A\n\n\n-- ----------------------------------------------------------------------\n-- Wrapped subset. Could use Data.Wrap but required curried arguments\n-- Easier to define specific data type. \n\ninfix 4 ⦅_⊆_⦆\ndata ⦅_⊆_⦆ {a} {A : Set a} : List A → List A → Set a where\n [_] : xs ⊆ ys → ⦅ xs ⊆ ys ⦆\n\nproj : ⦅ xs ⊆ ys ⦆ → xs ⊆ ys\nproj [ xs⊆ys ] = xs⊆ys\n\n-- ----------------------------------------------------------------------\n-- Lemmas used for instance searching\n\nx∉[] : x ∉ []\nx∉[] = λ ()\n\n[]⊆xs : [] ⊆ xs\n[]⊆xs = λ x∈[] → contradiction x∈[] x∉[]\n\nxs⊆x∷xs : xs ⊆ x ∷ xs\nxs⊆x∷xs = there\n\nxs⊆ys⇒x∷xs⊆x∷ys : xs ⊆ ys → x ∷ xs ⊆ x ∷ ys\nxs⊆ys⇒x∷xs⊆x∷ys xs⊆ys (here y≡x) = here y≡x\nxs⊆ys⇒x∷xs⊆x∷ys xs⊆ys (there y∈x∷xs) = there (xs⊆ys y∈x∷xs)\n\nx∈ys-xs⊆ys⇒x∷xs⊆ys : x ∈ ys → xs ⊆ ys → x ∷ xs ⊆ ys\nx∈ys-xs⊆ys⇒x∷xs⊆ys x∈ys xs⊆ys (here y≡x) = ∈-resp-≈ (setoid _) (sym y≡x) x∈ys\nx∈ys-xs⊆ys⇒x∷xs⊆ys x∈ys xs⊆ys (there y∈x∷xs) = xs⊆ys y∈x∷xs\n\n-- ----------------------------------------------------------------------\n-- Instances\n\ninstance\n ⦃[]⊆xs⦄ : ⦅ [] ⊆ xs ⦆\n ⦃[]⊆xs⦄ = [ []⊆xs ]\n\n -- Removed to improve instance search, syntax directed. \n \n -- ⦃xs⊆x∷xs⦄ : ⦅ xs ⊆ x ∷ xs ⦆\n -- ⦃xs⊆x∷xs⦄ = [ xs⊆x∷xs ]\n\n -- ⦃xs⊆ys⇒x∷xs⊆x∷ys⦄ : ⦃ ⦅ xs ⊆ ys ⦆ ⦄ → ⦅ x ∷ xs ⊆ x ∷ ys ⦆\n -- ⦃xs⊆ys⇒x∷xs⊆x∷ys⦄ ⦃ [ xs⊆ys ] ⦄ = [ xs⊆ys⇒x∷xs⊆x∷ys xs⊆ys ]\n\n ⦃x∈ys-xs⊆ys⇒x∷xs⊆ys⦄ : ⦃ x ∈ ys ⦄ → ⦃ ⦅ xs ⊆ ys ⦆ ⦄ → ⦅ x ∷ xs ⊆ ys ⦆\n ⦃x∈ys-xs⊆ys⇒x∷xs⊆ys⦄ ⦃ x∈ys ⦄ ⦃ [ xs⊆ys ] ⦄ = [ x∈ys-xs⊆ys⇒x∷xs⊆ys x∈ys xs⊆ys ]\n", "meta": {"hexsha": "2b04ca3d4fc9d4c50273e473bab07e2b37701ccd", "size": 2097, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/List/Relation/Binary/Subset/Propositional/Instances.agda", "max_stars_repo_name": "johnyob/agda-union", "max_stars_repo_head_hexsha": "921a0dc44a69a74391031ca61568c624ab7f9c94", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Data/List/Relation/Binary/Subset/Propositional/Instances.agda", "max_issues_repo_name": "johnyob/agda-union", "max_issues_repo_head_hexsha": "921a0dc44a69a74391031ca61568c624ab7f9c94", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/List/Relation/Binary/Subset/Propositional/Instances.agda", "max_forks_repo_name": "johnyob/agda-union", "max_forks_repo_head_hexsha": "921a0dc44a69a74391031ca61568c624ab7f9c94", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.5352112676, "max_line_length": 81, "alphanum_fraction": 0.5207439199, "num_tokens": 1052, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8221891130942472, "lm_q2_score": 0.7853085758631159, "lm_q1q2_score": 0.6456721614942016}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import lib.Basics\nopen import lib.types.Paths\nopen import lib.types.Pointed\nopen import lib.types.Pushout\nopen import lib.types.PushoutFmap\nopen import lib.types.Sigma\nopen import lib.types.Span\n\nmodule lib.types.Join where\n\nmodule _ {i j} (A : Type i) (B : Type j) where\n\n *-span : Span\n *-span = span A B (A × B) fst snd\n\n infix 80 _*_\n\n _*_ : Type _\n _*_ = Pushout *-span\n\nmodule _ {i j} {A : Type i} {B : Type j} where\n jleft : A → A * B\n jleft = left\n\n jright : B → A * B\n jright = right\n\n jglue : ∀ a b → jleft a == jright b\n jglue = curry glue\n\n module JoinElim {k} {P : A * B → Type k}\n (jleft* : (a : A) → P (jleft a)) (jright* : (b : B) → P (jright b))\n (jglue* : ∀ a b → jleft* a == jright* b [ P ↓ jglue a b ]) where\n\n private\n module M = PushoutElim {d = *-span A B} {P = P} jleft* jright* (uncurry jglue*)\n f = M.f\n glue-β = curry M.glue-β\n\n Join-elim = JoinElim.f\n\n module JoinRec {k} {C : Type k}\n (jleft* : (a : A) → C) (jright* : (b : B) → C)\n (jglue* : ∀ a b → jleft* a == jright* b) where\n\n private\n module M = PushoutRec jleft* jright* (uncurry jglue*)\n f = M.f\n glue-β = curry M.glue-β\n\n Join-rec = JoinRec.f\n\nmodule _ {i j} (X : Ptd i) (Y : Ptd j) where\n\n ⊙*-span : ⊙Span\n ⊙*-span = ⊙span X Y (X ⊙× Y) ⊙fst ⊙snd\n\n infix 80 _⊙*_\n\n _⊙*_ : Ptd _\n _⊙*_ = ⊙Pushout ⊙*-span\n\nmodule _ {i i' j j'} {A : Type i} {A' : Type i'} {B : Type j} {B' : Type j'}\n (eqA : A ≃ A') (eqB : B ≃ B') where\n\n *-span-emap : SpanEquiv (*-span A B) (*-span A' B')\n *-span-emap = ( span-map (fst eqA) (fst eqB) (×-fmap (fst eqA) (fst eqB)) (comm-sqr λ _ → idp) (comm-sqr λ _ → idp)\n , snd eqA , snd eqB , ×-isemap (snd eqA) (snd eqB))\n\n *-emap : A * B ≃ A' * B'\n *-emap = Pushout-emap *-span-emap\n\nmodule _ {i i' j j'} {X : Ptd i} {X' : Ptd i'} {Y : Ptd j} {Y' : Ptd j'} where\n\n ⊙*-emap : X ⊙≃ X' → Y ⊙≃ Y' → X ⊙* Y ⊙≃ X' ⊙* Y'\n ⊙*-emap ⊙eqX ⊙eqY = ≃-to-⊙≃ (*-emap (⊙≃-to-≃ ⊙eqX) (⊙≃-to-≃ ⊙eqY)) (ap left (snd (⊙–> ⊙eqX)))\n", "meta": {"hexsha": "9680ada16f91c8ea750b4530beae56545f16c47e", "size": 2047, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/types/Join.agda", "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 294, "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_issues_repo_path": "core/lib/types/Join.agda", "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 31, "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_forks_repo_path": "core/lib/types/Join.agda", "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 50, "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "avg_line_length": 25.9113924051, "max_line_length": 117, "alphanum_fraction": 0.529555447, "num_tokens": 901, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519527906914787, "lm_q2_score": 0.7577943822145998, "lm_q1q2_score": 0.6456050386980533}} {"text": "{-\nThis second-order equational theory was created from the following second-order syntax description:\n\nsyntax Monoid | M\n\ntype\n * : 0-ary\n\nterm\n unit : * | ε\n add : * * -> * | _⊕_ l20\n\ntheory\n (εU⊕ᴸ) a |> add (unit, a) = a\n (εU⊕ᴿ) a |> add (a, unit) = a\n (⊕A) a b c |> add (add(a, b), c) = add (a, add(b, c))\n-}\n\nmodule Monoid.Equality where\n\nopen import SOAS.Common\nopen import SOAS.Context\nopen import SOAS.Variable\nopen import SOAS.Families.Core\nopen import SOAS.Families.Build\nopen import SOAS.ContextMaps.Inductive\n\nopen import Monoid.Signature\nopen import Monoid.Syntax\n\nopen import SOAS.Metatheory.SecondOrder.Metasubstitution M:Syn\nopen import SOAS.Metatheory.SecondOrder.Equality M:Syn\n\nprivate\n variable\n α β γ τ : *T\n Γ Δ Π : Ctx\n\ninfix 1 _▹_⊢_≋ₐ_\n\n-- Axioms of equality\ndata _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ M) α Γ → (𝔐 ▷ M) α Γ → Set where\n εU⊕ᴸ : ⁅ * ⁆̣ ▹ ∅ ⊢ ε ⊕ 𝔞 ≋ₐ 𝔞\n εU⊕ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ⊕ ε ≋ₐ 𝔞\n ⊕A : ⁅ * ⁆ ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (𝔞 ⊕ 𝔟) ⊕ 𝔠 ≋ₐ 𝔞 ⊕ (𝔟 ⊕ 𝔠)\n\nopen EqLogic _▹_⊢_≋ₐ_\nopen ≋-Reasoning\n", "meta": {"hexsha": "bf255b53c09970f2f5da4c41fa76f276264b3512", "size": 1069, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "out/Monoid/Equality.agda", "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_issues_repo_path": "out/Monoid/Equality.agda", "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_forks_repo_path": "out/Monoid/Equality.agda", "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "avg_line_length": 21.8163265306, "max_line_length": 99, "alphanum_fraction": 0.592142189, "num_tokens": 499, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8519527869325346, "lm_q2_score": 0.7577943712746406, "lm_q1q2_score": 0.6456050265292179}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import lib.Basics\nopen import lib.NType2\nopen import lib.types.TLevel\nopen import lib.types.Sigma\nopen import lib.types.Pi\n\nmodule lib.types.Groupoid where\n\nrecord GroupoidStructure {i j} {El : Type i} (Arr : El → El → Type j)\n (_ : ∀ x y → has-level 0 (Arr x y)) : Type (lmax i j) where\n field\n ident : ∀ {x} → Arr x x\n inv : ∀ {x y} → Arr x y → Arr y x\n comp : ∀ {x y z} → Arr x y → Arr y z → Arr x z\n unit-l : ∀ {x y} (a : Arr x y) → comp ident a == a\n assoc : ∀ {x y z w} (a : Arr x y) (b : Arr y z) (c : Arr z w)\n → comp (comp a b) c == comp a (comp b c)\n inv-l : ∀ {x y } (a : Arr x y) → (comp (inv a) a) == ident\n\n private\n infix 80 _⊙_\n _⊙_ = comp\n\n abstract\n inv-r : ∀ {x y} (a : Arr x y) → a ⊙ inv a == ident\n inv-r a =\n a ⊙ inv a =⟨ ! $ unit-l (a ⊙ inv a) ⟩\n ident ⊙ (a ⊙ inv a) =⟨ ! $ inv-l (inv a) |in-ctx _⊙ (a ⊙ inv a) ⟩\n (inv (inv a) ⊙ inv a) ⊙ (a ⊙ inv a) =⟨ assoc (inv (inv a)) (inv a) (a ⊙ inv a) ⟩\n inv (inv a) ⊙ (inv a ⊙ (a ⊙ inv a)) =⟨ ! $ assoc (inv a) a (inv a) |in-ctx inv (inv a) ⊙_ ⟩\n inv (inv a) ⊙ ((inv a ⊙ a) ⊙ inv a) =⟨ inv-l a |in-ctx (λ h → inv (inv a) ⊙ (h ⊙ inv a)) ⟩\n inv (inv a) ⊙ (ident ⊙ inv a) =⟨ unit-l (inv a) |in-ctx inv (inv a) ⊙_ ⟩\n inv (inv a) ⊙ inv a =⟨ inv-l (inv a) ⟩\n ident =∎\n\n unit-r : ∀ {x y} (a : Arr x y) → a ⊙ ident == a\n unit-r a =\n a ⊙ ident =⟨ ! (inv-l a) |in-ctx a ⊙_ ⟩\n a ⊙ (inv a ⊙ a) =⟨ ! $ assoc a (inv a) a ⟩\n (a ⊙ inv a) ⊙ a =⟨ inv-r a |in-ctx _⊙ a ⟩\n ident ⊙ a =⟨ unit-l a ⟩\n a =∎\n\nrecord PreGroupoid i j : Type (lsucc (lmax i j)) where\n constructor groupoid\n field\n El : Type i\n Arr : El → El → Type j\n Arr-level : ∀ x y → has-level 0 (Arr x y)\n groupoid-struct : GroupoidStructure Arr Arr-level\n", "meta": {"hexsha": "db5b782861b558abb0cf173ac1c5a90a23fb5eb1", "size": 1978, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/types/Groupoid.agda", "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "core/lib/types/Groupoid.agda", "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "core/lib/types/Groupoid.agda", "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "avg_line_length": 37.320754717, "max_line_length": 97, "alphanum_fraction": 0.4585439838, "num_tokens": 796, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.875787001374006, "lm_q2_score": 0.7371581568543043, "lm_q1q2_score": 0.6455935317298204}} {"text": "\nmodule Issue475 where\n\ndata Box (A : Set) : Set where\n box : A → Box A\n\npostulate\n T : {A : Set} → A → Set\n\nunbox : {A : Set} → Box A → A\n\ndata BoxT {A : Set}(b : Box A) : Set where\n boxT : T (unbox b) → BoxT b\n\n-- Can't be projection-like since we've already used it in BoxT\nunbox (box x) = x\n\npostulate\n A : Set\n b : Box A\n\nunboxT : BoxT b → T (unbox b)\nunboxT (boxT p) = p\n", "meta": {"hexsha": "73721c7fe576b506cda6a0777ebdb06a88e7202f", "size": 382, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue475.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue475.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue475.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 15.9166666667, "max_line_length": 63, "alphanum_fraction": 0.5890052356, "num_tokens": 151, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8757869884059267, "lm_q2_score": 0.7371581568543043, "lm_q1q2_score": 0.6455935221702949}} {"text": "{-\n\nA possible implementation of the following HIT arr. Note that this type is\nmutually defined with App, that is to say, they are defined by\ninduction-recursion!\n\nInductive arr (A,B:Set) : Set :=\n| base : B -> arr A B\n| step : (A -> arr A B) -> arr A B.\n| path : (forall x : A, App f x = App g x) -> f = g.\n\nwhere App is defined by\n\nFixpoint App (f : arr A B)(a : A) :=\nmatch f with\n| base b => b\n| step g => App (g a) a\nend.\n\nDue to the fact that arr and App are defined by induction-recuriosn, the\nrecursion principle for arr needs to make extra assumptions, see the parameters\nof the arr-Rec module.\nEffectively, we see the function space A → B as algebra for the functor (-) × A\nand App is an algebra homomorphism from arr A B to A → B.\nThis is reflected in the extra assumption in the recursion principle.\n\n-}\n\n\n{-# OPTIONS --without-K #-}\nopen import lib.Basics\nopen import lib.PathGroupoid\nopen import lib.types.Paths\nopen import lib.Funext\n\n\nmodule _ where\n private\n data #arr-aux (A B : Set) : Set where\n #base : B → #arr-aux A B\n #step : (A → #arr-aux A B) → #arr-aux A B\n\n #App : ∀{A B} → #arr-aux A B → A → B\n #App (#base b) a = b\n #App (#step g) a = #App (g a) a\n\n _~>_ : Set → Set → Set\n _~>_ = #arr-aux\n\n base : ∀{A B} → B → A ~> B\n base = #base\n\n step : ∀{A B} → (A → A ~> B) → A ~> B\n step = #step\n\n App : ∀{A B} → A ~> B → A → B\n App = #App\n\n Abstr : ∀{A B} → (A → B) → A ~> B\n Abstr f = step (λ x → base (f x))\n\n postulate\n path : ∀{A B} (f g : A ~> B) (a : A) → App f a == App g a → f == g\n\n module arr-Rec {A B X : Set}\n (base* : B → X)\n (step* : (A → X) → X)\n (App* : X → A → B)\n -- Here we need to make the assumption that App* is an algebra homomorphism\n -- from X into the function space.\n (App*-β₂ : (a : A) (f : A → X) → App* (step* f) a == App* (f a) a)\n (path* : (x y : X) (a : A) → App* x a == App* y a → x == y)\n where\n rec : A ~> B → X\n rec = rec-aux phantom where\n rec-aux : Phantom path* → A ~> B → X\n rec-aux ph (#base b) = base* b\n rec-aux ph (#step f) = step* (λ a → rec-aux ph (f a))\n\n lem : (f g : A ~> B) (a : A) →\n App f a == App g a → App* (rec f) a == App* (rec g) a\n lem (#base b) (#base .b) a idp = idp\n lem (#base b) (#step g) a p =\n let β-red* = App*-β₂ a (rec ∘ g)\n IH = lem (#base b) (g a) a p\n in IH ∙ ! β-red*\n lem (#step f) (#base b) a p =\n let β-red* = App*-β₂ a (rec ∘ f)\n IH = lem (f a) (#base b) a p\n in β-red* ∙ IH\n lem (#step f) (#step g) a p =\n let IH = lem (f a) (g a) a p\n β-red-f = App*-β₂ a (rec ∘ f)\n β-red-g = App*-β₂ a (rec ∘ g)\n in β-red-f ∙ IH ∙ ! β-red-g\n\n postulate\n path-β : (f g : A ~> B) (a : A) (p : App f a == App g a) →\n ap rec (path f g a p)\n == path* (rec f) (rec g) a (lem f g a p)\n", "meta": {"hexsha": "7c1eedfcce12f476181a7cda32455f92904568c9", "size": 2869, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "TypeTheory/HoTT/Functions.agda", "max_stars_repo_name": "hbasold/Sandbox", "max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "TypeTheory/HoTT/Functions.agda", "max_issues_repo_name": "hbasold/Sandbox", "max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TypeTheory/HoTT/Functions.agda", "max_forks_repo_name": "hbasold/Sandbox", "max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.4059405941, "max_line_length": 79, "alphanum_fraction": 0.5155106309, "num_tokens": 1063, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467643431002, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.6453988118294304}} {"text": "open import Level using () renaming (zero to ℓ₀)\nopen import Relation.Binary using (DecSetoid)\n\nmodule CheckInsert (A : DecSetoid ℓ₀ ℓ₀) where\n\nopen import Data.Nat using (ℕ)\nopen import Data.Fin using (Fin)\nopen import Data.Fin.Properties using (_≟_)\nopen import Data.Maybe using (Maybe ; nothing ; just) renaming (setoid to MaybeSetoid ; Eq to MaybeEq)\nopen import Data.Vec using (Vec) renaming (_∷_ to _∷V_)\nopen import Data.Vec.Equality using () renaming (module Equality to VecEq)\nopen import Relation.Nullary using (Dec ; yes ; no ; ¬_)\nopen import Relation.Nullary.Negation using (contradiction)\nopen import Relation.Binary using (Setoid ; module DecSetoid)\nopen import Relation.Binary.Core using (refl ; _≡_ ; _≢_)\nimport Relation.Binary.EqReasoning as EqR\nopen import Relation.Binary.PropositionalEquality using (cong ; sym ; inspect ; [_] ; trans)\n\nopen import FinMap\n\nprivate\n open module A = DecSetoid A using (Carrier ; _≈_) renaming (_≟_ to deq)\n\ncheckInsert : {n : ℕ} → Fin n → Carrier → FinMapMaybe n Carrier → Maybe (FinMapMaybe n Carrier)\ncheckInsert i b m with lookupM i m\n... | nothing = just (insert i b m)\n... | just c with deq b c\n... | yes b≈c = just m\n... | no b≉c = nothing\n\ndata InsertionResult {n : ℕ} (i : Fin n) (x : Carrier) (h : FinMapMaybe n Carrier) : Maybe (FinMapMaybe n Carrier) → Set where\n same : (x' : Carrier) → x ≈ x' → lookupM i h ≡ just x' → InsertionResult i x h (just h)\n new : lookupM i h ≡ nothing → InsertionResult i x h (just (insert i x h))\n wrong : (x' : Carrier) → ¬ (x ≈ x') → lookupM i h ≡ just x' → InsertionResult i x h nothing\n\ninsertionresult : {n : ℕ} → (i : Fin n) → (x : Carrier) → (h : FinMapMaybe n Carrier) → InsertionResult i x h (checkInsert i x h)\ninsertionresult i x h with lookupM i h | inspect (lookupM i) h\ninsertionresult i x h | just x' | _ with deq x x'\ninsertionresult i x h | just x' | [ il ] | yes x≈x' = same x' x≈x' il\ninsertionresult i x h | just x' | [ il ] | no x≉x' = wrong x' x≉x' il\ninsertionresult i x h | nothing | [ il ] = new il\n\nlemma-checkInsert-same : {n : ℕ} → (i : Fin n) → (x : Carrier) → (m : FinMapMaybe n Carrier) → lookupM i m ≡ just x → checkInsert i x m ≡ just m\nlemma-checkInsert-same i x m p with lookupM i m\nlemma-checkInsert-same i x m refl | .(just x) with deq x x\nlemma-checkInsert-same i x m refl | .(just x) | yes x≈x = refl\nlemma-checkInsert-same i x m refl | .(just x) | no x≉x = contradiction A.refl x≉x\n\nlemma-checkInsert-new : {n : ℕ} → (i : Fin n) → (x : Carrier) → (m : FinMapMaybe n Carrier) → lookupM i m ≡ nothing → checkInsert i x m ≡ just (insert i x m)\nlemma-checkInsert-new i x m p with lookupM i m\nlemma-checkInsert-new i x m refl | .nothing = refl\n\nlemma-checkInsert-wrong : {n : ℕ} → (i : Fin n) → (x : Carrier) → (m : FinMapMaybe n Carrier) → (x' : Carrier) → ¬ (x ≈ x') → lookupM i m ≡ just x' → checkInsert i x m ≡ nothing\nlemma-checkInsert-wrong i x m x' d p with lookupM i m\nlemma-checkInsert-wrong i x m x' d refl | .(just x') with deq x x'\nlemma-checkInsert-wrong i x m x' d refl | .(just x') | yes q = contradiction q d\nlemma-checkInsert-wrong i x m x' d refl | .(just x') | no ¬q = refl\n\nlemma-checkInsert-restrict : {n m : ℕ} → (f : Fin n → Carrier) → (i : Fin n) → (is : Vec (Fin n) m) → checkInsert i (f i) (restrict f is) ≡ just (restrict f (i ∷V is))\nlemma-checkInsert-restrict f i is with checkInsert i (f i) (restrict f is) | insertionresult i (f i) (restrict f is)\nlemma-checkInsert-restrict f i is | ._ | same x fi≈x p = cong just (lemma-insert-same _ i (trans p (cong just (sym (lemma-lookupM-restrict i f is p)))))\nlemma-checkInsert-restrict f i is | ._ | new _ = refl\nlemma-checkInsert-restrict f i is | ._ | wrong x fi≉x p = contradiction (Setoid.reflexive A.setoid (lemma-lookupM-restrict i f is p)) fi≉x\n\nlemma-lookupM-checkInsert : {n : ℕ} → (i j : Fin n) → (h : FinMapMaybe n Carrier) → {x : Carrier} → lookupM i h ≡ just x → (y : Carrier) → {h' : FinMapMaybe n Carrier} → checkInsert j y h ≡ just h' → lookupM i h' ≡ just x\nlemma-lookupM-checkInsert i j h pl y ph' with checkInsert j y h | insertionresult j y h\nlemma-lookupM-checkInsert i j h pl y refl | ._ | same _ _ _ = pl\nlemma-lookupM-checkInsert i j h pl y ph' | ._ | new _ with i ≟ j\nlemma-lookupM-checkInsert i .i h pl y ph' | ._ | new pl' | yes refl = contradiction (trans (sym pl) pl') (λ ())\nlemma-lookupM-checkInsert i j h {x} pl y refl | ._ | new _ | no i≢j = begin\n lookupM i (insert j y h)\n ≡⟨ lemma-lookupM-insert-other i j y h i≢j ⟩\n lookupM i h\n ≡⟨ pl ⟩\n just x ∎\n where open Relation.Binary.PropositionalEquality.≡-Reasoning\n\nlemma-lookupM-checkInsert i j h pl y () | ._ | wrong _ _ _\n\nlemma-lookupM-checkInsert-other : {n : ℕ} → (i j : Fin n) → i ≢ j → (x : Carrier) → (h : FinMapMaybe n Carrier) → {h' : FinMapMaybe n Carrier} → checkInsert j x h ≡ just h' → lookupM i h' ≡ lookupM i h\nlemma-lookupM-checkInsert-other i j i≢j x h ph' with lookupM j h\nlemma-lookupM-checkInsert-other i j i≢j x h ph' | just y with deq x y\nlemma-lookupM-checkInsert-other i j i≢j x h refl | just y | yes x≈y = refl\nlemma-lookupM-checkInsert-other i j i≢j x h () | just y | no x≉y\nlemma-lookupM-checkInsert-other i j i≢j x h refl | nothing = lemma-lookupM-insert-other i j x h i≢j\n", "meta": {"hexsha": "e0e35ec67dc447330fbf1d17928260a3f4e37ad9", "size": 5279, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "CheckInsert.agda", "max_stars_repo_name": "jvoigtlaender/bidiragda", "max_stars_repo_head_hexsha": "a5abbd177f032523d1d9d3fa4b9137aefe88dee0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "CheckInsert.agda", "max_issues_repo_name": "jvoigtlaender/bidiragda", "max_issues_repo_head_hexsha": "a5abbd177f032523d1d9d3fa4b9137aefe88dee0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "CheckInsert.agda", "max_forks_repo_name": "jvoigtlaender/bidiragda", "max_forks_repo_head_hexsha": "a5abbd177f032523d1d9d3fa4b9137aefe88dee0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 61.3837209302, "max_line_length": 221, "alphanum_fraction": 0.6590263307, "num_tokens": 1776, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382058759129, "lm_q2_score": 0.7490872243177518, "lm_q1q2_score": 0.6453672632832834}} {"text": "{-\n\nMatrix with coefficients in a commutative ring\n\n-}\n{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.Matrix.CommRingCoefficient where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Powerset\n\nopen import Cubical.Data.Nat hiding (_+_ ; _·_)\nopen import Cubical.Data.FinData\n\nopen import Cubical.Data.Sigma\nopen import Cubical.Data.Empty as Empty\n\nopen import Cubical.Relation.Nullary\n\nopen import Cubical.Algebra.Ring\nopen import Cubical.Algebra.Ring.BigOps\nopen import Cubical.Algebra.CommRing\nopen import Cubical.Algebra.RingSolver.Reflection\n\nopen import Cubical.Algebra.Matrix\n\nprivate\n variable\n ℓ : Level\n m n k l : ℕ\n\nmodule Coefficient (𝓡 : CommRing ℓ) where\n\n private\n R = 𝓡 .fst\n 𝑹 = CommRing→Ring 𝓡\n AbR = Ring→AbGroup 𝑹\n\n open CommRingStr (𝓡 .snd) renaming ( is-set to isSetR )\n\n open Sum 𝑹\n open FinMatrixAbGroup\n\n -- Convenient renaming\n\n Mat : (m n : ℕ) → Type ℓ\n Mat m n = FinMatrix R m n\n\n isSetMat : isSet (Mat m n)\n isSetMat = isSetΠ2 (λ _ _ → isSetR)\n\n isContrEmpty : {n : ℕ} → isContr (Mat 0 n)\n isContrEmpty =\n isOfHLevelRespectEquiv _ (equiv→ (uninhabEquiv (λ ()) ¬Fin0) (idEquiv _)) isContr⊥→A\n\n isContrEmptyᵗ : {m : ℕ} → isContr (Mat m 0)\n isContrEmptyᵗ =\n isContrΠ (λ _ → isOfHLevelRespectEquiv _ (equiv→ (uninhabEquiv (λ ()) ¬Fin0) (idEquiv _)) isContr⊥→A)\n\n 𝟙 : Mat n n\n 𝟙 = oneFinMatrix 𝑹\n\n 𝟘 : Mat m n\n 𝟘 = zeroFinMatrix AbR\n\n _⋆_ : Mat m n → Mat n k → Mat m k\n M ⋆ N = mulFinMatrix 𝑹 M N\n\n infixl 8 _⋆_\n\n ⋆lUnit : (M : Mat m n) → 𝟙 ⋆ M ≡ M\n ⋆lUnit = mulFinMatrix1r 𝑹\n\n ⋆rUnit : (M : Mat m n) → M ⋆ 𝟙 ≡ M\n ⋆rUnit = mulFinMatrixr1 𝑹\n\n ⋆Assoc : (M : Mat m n)(N : Mat n k)(K : Mat k l) → M ⋆ (N ⋆ K) ≡ (M ⋆ N) ⋆ K\n ⋆Assoc = mulFinMatrixAssoc 𝑹\n\n -- Transposition\n\n _ᵗ : Mat m n → Mat n m\n (M ᵗ) i j = M j i\n\n idemᵗ : (M : Mat m n) → (M ᵗ)ᵗ ≡ M\n idemᵗ M t i j = M i j\n\n compᵗ : (M : Mat m n)(N : Mat n k) → (M ⋆ N)ᵗ ≡ N ᵗ ⋆ M ᵗ\n compᵗ M N t i j = ∑ (λ l → ·Comm (M j l) (N l i) t)\n\n 𝟙ᵗ : 𝟙 ᵗ ≡ 𝟙 {n = n}\n 𝟙ᵗ t zero zero = 1r\n 𝟙ᵗ t (suc i) zero = 0r\n 𝟙ᵗ t zero (suc j) = 0r\n 𝟙ᵗ t (suc i) (suc j) = 𝟙ᵗ t i j\n\n -- Invertible matrices\n\n isInv' : Mat n n → Mat n n → Type ℓ\n isInv' {n = n} M N = (M ⋆ N ≡ 𝟙) × (N ⋆ M ≡ 𝟙)\n\n isPropIsInv' : (M N : Mat n n) → isProp (isInv' M N)\n isPropIsInv' M N = isProp× (isSetMat _ _) (isSetMat _ _)\n\n invUniq : (M N N' : Mat n n) → isInv' M N → isInv' M N' → N ≡ N'\n invUniq M N N' p q =\n sym (⋆lUnit N)\n ∙ (λ i → q .snd (~ i) ⋆ N)\n ∙ sym (⋆Assoc N' M N)\n ∙ (λ i → N' ⋆ p .fst i)\n ∙ ⋆rUnit N'\n\n isInv : Mat n n → Type ℓ\n isInv {n = n} M = Σ[ N ∈ Mat n n ] isInv' M N\n\n isPropIsInv : (M : Mat n n) → isProp (isInv M)\n isPropIsInv M p q = Σ≡Prop (λ _ → isPropIsInv' M _) (invUniq M _ _ (p .snd) (q .snd))\n\n isInv⋆ : {M M' : Mat n n} → isInv M → isInv M' → isInv (M ⋆ M')\n isInv⋆ (N , p) (N' , q) .fst = N' ⋆ N\n isInv⋆ {M = M} {M' = M'} (N , p) (N' , q) .snd .fst =\n sym (⋆Assoc M M' (N' ⋆ N))\n ∙ (λ i → M ⋆ ⋆Assoc M' N' N i)\n ∙ (λ i → M ⋆ (q .fst i ⋆ N))\n ∙ (λ i → M ⋆ ⋆lUnit N i)\n ∙ p .fst\n isInv⋆ {M = M} {M' = M'} (N , p) (N' , q) .snd .snd =\n sym (⋆Assoc N' N (M ⋆ M'))\n ∙ (λ i → N' ⋆ ⋆Assoc N M M' i)\n ∙ (λ i → N' ⋆ (p .snd i ⋆ M'))\n ∙ (λ i → N' ⋆ ⋆lUnit M' i)\n ∙ q .snd\n\n InvMat : (n : ℕ) → Type ℓ\n InvMat n = Σ[ M ∈ Mat n n ] isInv M\n\n isInv𝟙 : isInv {n = n} 𝟙\n isInv𝟙 .fst = 𝟙\n isInv𝟙 .snd .fst = ⋆lUnit _\n isInv𝟙 .snd .snd = ⋆lUnit _\n\n isInvᵗ : {M : Mat n n} → isInv M → isInv (M ᵗ)\n isInvᵗ {M = M} isInvM .fst = (isInvM .fst)ᵗ\n isInvᵗ {M = M} isInvM .snd .fst = (sym (compᵗ _ M)) ∙ (λ t → (isInvM .snd .snd t)ᵗ) ∙ 𝟙ᵗ\n isInvᵗ {M = M} isInvM .snd .snd = (sym (compᵗ M _)) ∙ (λ t → (isInvM .snd .fst t)ᵗ) ∙ 𝟙ᵗ\n\n -- Inversion formula for 2 × 2 matrices\n\n dot2 : (V W : FinVec R 2) → (∑ λ i → V i · W i) ≡ V zero · W zero + V one · W one\n dot2 V W i = V zero · W zero + (+Rid (V one · W one) i)\n\n mul2 :\n (M : Mat m 2)(N : Mat 2 n)\n → (i : Fin m)(j : Fin n)\n → (M ⋆ N) i j ≡ M i zero · N zero j + M i one · N one j\n mul2 M N i j = dot2 (M i) (λ k → N k j)\n\n open Units 𝓡\n\n det2×2 : Mat 2 2 → R\n det2×2 M = M zero zero · M one one - M zero one · M one zero\n\n module _\n (M : Mat 2 2)(p : det2×2 M ∈ Rˣ) where\n\n private\n Δ = det2×2 M\n Δ⁻¹ = (_⁻¹) Δ ⦃ p ⦄\n\n ·rInv : Δ · Δ⁻¹ ≡ 1r\n ·rInv = ·-rinv _ ⦃ p ⦄\n\n M⁻¹ : Mat 2 2\n M⁻¹ zero zero = M one one · Δ⁻¹\n M⁻¹ zero one = - M zero one · Δ⁻¹\n M⁻¹ one zero = - M one zero · Δ⁻¹\n M⁻¹ one one = M zero zero · Δ⁻¹\n\n isInvMat2x2 : isInv M\n isInvMat2x2 .fst = M⁻¹\n isInvMat2x2 .snd .fst i zero zero =\n (mul2 M M⁻¹ zero zero ∙ helper _ _ _ _ _ ∙ ·rInv) i\n where helper : (x y z w d : R) → x · (w · d) + y · (- z · d) ≡ (x · w - y · z) · d\n helper = solve 𝓡\n isInvMat2x2 .snd .fst i zero one =\n (mul2 M M⁻¹ zero one ∙ helper _ _ _) i\n where helper : (x y d : R) → x · (- y · d) + y · (x · d) ≡ 0r\n helper = solve 𝓡\n isInvMat2x2 .snd .fst i one zero =\n (mul2 M M⁻¹ one zero ∙ helper _ _ _) i\n where helper : (z w d : R) → z · (w · d) + w · (- z · d) ≡ 0r\n helper = solve 𝓡\n isInvMat2x2 .snd .fst i one one =\n (mul2 M M⁻¹ one one ∙ helper _ _ _ _ _ ∙ ·rInv) i\n where helper : (x y z w d : R) → z · (- y · d) + w · (x · d) ≡ (x · w - y · z) · d\n helper = solve 𝓡\n isInvMat2x2 .snd .snd i zero zero =\n (mul2 M⁻¹ M zero zero ∙ helper _ _ _ _ _ ∙ ·rInv) i\n where helper : (x y z w d : R) → (w · d) · x + (- y · d) · z ≡ (x · w - y · z) · d\n helper = solve 𝓡\n isInvMat2x2 .snd .snd i zero one =\n (mul2 M⁻¹ M zero one ∙ helper _ _ _) i\n where helper : (y w d : R) → (w · d) · y + (- y · d) · w ≡ 0r\n helper = solve 𝓡\n isInvMat2x2 .snd .snd i one zero =\n (mul2 M⁻¹ M one zero ∙ helper _ _ _) i\n where helper : (x z d : R) → (- z · d) · x + (x · d) · z ≡ 0r\n helper = solve 𝓡\n isInvMat2x2 .snd .snd i one one =\n (mul2 M⁻¹ M one one ∙ helper _ _ _ _ _ ∙ ·rInv) i\n where helper : (x y z w d : R) → (- z · d) · y + (x · d) · w ≡ (x · w - y · z) · d\n helper = solve 𝓡\n\n -- Similarity of matrices\n\n record SimRel (M N : Mat m n) : Type ℓ where\n field\n transMatL : Mat m m\n transMatR : Mat n n\n transEq : N ≡ transMatL ⋆ M ⋆ transMatR\n\n isInvTransL : isInv transMatL\n isInvTransR : isInv transMatR\n\n open SimRel\n\n record Sim (M : Mat m n) : Type ℓ where\n field\n result : Mat m n\n simrel : SimRel M result\n\n open Sim\n\n idSimRel : (M : Mat m n) → SimRel M M\n idSimRel _ .transMatL = 𝟙\n idSimRel _ .transMatR = 𝟙\n idSimRel M .transEq = sym ((λ t → ⋆lUnit M t ⋆ 𝟙) ∙ ⋆rUnit _)\n idSimRel _ .isInvTransL = isInv𝟙\n idSimRel _ .isInvTransR = isInv𝟙\n\n idSim : (M : Mat m n) → Sim M\n idSim M .result = M\n idSim M .simrel = idSimRel M\n\n ≡SimRel : {M N : Mat m n} → M ≡ N → SimRel M N\n ≡SimRel p .transMatL = 𝟙\n ≡SimRel p .transMatR = 𝟙\n ≡SimRel {M = M} p .transEq = sym p ∙ sym ((λ t → ⋆lUnit M t ⋆ 𝟙) ∙ ⋆rUnit _)\n ≡SimRel p .isInvTransL = isInv𝟙\n ≡SimRel p .isInvTransR = isInv𝟙\n\n ≡Sim : {M N : Mat m n} → M ≡ N → Sim M\n ≡Sim _ .result = _\n ≡Sim p .simrel = ≡SimRel p\n\n compSimRel : {M N K : Mat m n} → SimRel M N → SimRel N K → SimRel M K\n compSimRel p q .transMatL = q .transMatL ⋆ p .transMatL\n compSimRel p q .transMatR = p .transMatR ⋆ q .transMatR\n compSimRel {M = M} p q .transEq =\n let L = p .transMatL\n R = p .transMatR\n L' = q .transMatL\n R' = q .transMatR in\n q .transEq\n ∙ (λ t → L' ⋆ p .transEq t ⋆ R')\n ∙ (λ t → L' ⋆ ⋆Assoc L M R (~ t) ⋆ R')\n ∙ (λ t → ⋆Assoc L' (L ⋆ (M ⋆ R)) R' (~ t))\n ∙ (λ t → L' ⋆ ⋆Assoc L (M ⋆ R) R' (~ t))\n ∙ (λ t → L' ⋆ (L ⋆ ⋆Assoc M R R' (~ t)))\n ∙ (λ t → L' ⋆ ⋆Assoc L M (R ⋆ R') t)\n ∙ (λ t → ⋆Assoc L' (L ⋆ M) (R ⋆ R') t)\n ∙ (λ t → ⋆Assoc L' L M t ⋆ (R ⋆ R'))\n compSimRel p q .isInvTransL = isInv⋆ (q .isInvTransL) (p .isInvTransL)\n compSimRel p q .isInvTransR = isInv⋆ (p .isInvTransR) (q .isInvTransR)\n\n compSim : {M : Mat m n}(p : Sim M)(q : Sim (p .result)) → Sim M\n compSim p q .result = q .result\n compSim p q .simrel = compSimRel (p .simrel) (q .simrel)\n\n -- Add a new element at upper-left corner\n\n _⊕_ : R → Mat m n → Mat (suc m) (suc n)\n (a ⊕ M) zero zero = a\n (a ⊕ M) (suc i) zero = 0r\n (a ⊕ M) zero (suc j) = 0r\n (a ⊕ M) (suc i) (suc j) = M i j\n\n infixr 5 _⊕_\n\n sucMat : (M : Mat (suc m) (suc n)) → Mat m n\n sucMat M i j = M (suc i) (suc j)\n\n 𝟙suc : (i j : Fin m) → 𝟙 i j ≡ sucMat 𝟙 i j\n 𝟙suc zero zero = refl\n 𝟙suc (suc i) zero = refl\n 𝟙suc zero (suc j) = refl\n 𝟙suc (suc i) (suc j) = refl\n\n 1⊕𝟙 : 1r ⊕ 𝟙 {n = n} ≡ 𝟙\n 1⊕𝟙 t zero zero = 1r\n 1⊕𝟙 t (suc i) zero = 0r\n 1⊕𝟙 t zero (suc j) = 0r\n 1⊕𝟙 t (suc i) (suc j) = 𝟙suc i j t\n\n ⊕-⋆ : (a b : R)(M : Mat m n)(N : Mat n k) → (a ⊕ M) ⋆ (b ⊕ N) ≡ (a · b) ⊕ (M ⋆ N)\n ⊕-⋆ {n = n} a b M N t zero zero =\n ((λ t → a · b + ∑Mul0r {n = n} (λ i → 0r) t) ∙ helper _ _) t\n where helper : (a b : R) → a · b + 0r ≡ a · b\n helper = solve 𝓡\n ⊕-⋆ a b M N t zero (suc j) = (helper a _ ∙ ∑Mul0r (λ i → N i j)) t\n where helper : (a c : R) → a · 0r + c ≡ c\n helper = solve 𝓡\n ⊕-⋆ a b M N t (suc i) zero = (helper b _ ∙ ∑Mulr0 (λ j → M i j)) t\n where helper : (b c : R) → 0r · b + c ≡ c\n helper = solve 𝓡\n ⊕-⋆ _ _ M N t (suc i) (suc j) = helper ((M ⋆ N) i j) t\n where helper : (c : R) → 0r · 0r + c ≡ c\n helper = solve 𝓡\n\n isInv⊕ : (M : Mat m m) → isInv M → (isInv (1r ⊕ M))\n isInv⊕ M isInvM .fst = 1r ⊕ isInvM .fst\n isInv⊕ M isInvM .snd .fst = ⊕-⋆ _ _ _ _ ∙ (λ t → ·Lid 1r t ⊕ isInvM .snd .fst t) ∙ 1⊕𝟙\n isInv⊕ M isInvM .snd .snd = ⊕-⋆ _ _ _ _ ∙ (λ t → ·Rid 1r t ⊕ isInvM .snd .snd t) ∙ 1⊕𝟙\n\n ⊕SimRel : (a : R){M N : Mat m n} → (sim : SimRel M N) → SimRel (a ⊕ M) (a ⊕ N)\n ⊕SimRel _ sim .transMatL = 1r ⊕ sim .transMatL\n ⊕SimRel _ sim .transMatR = 1r ⊕ sim .transMatR\n ⊕SimRel a {M = M} sim .transEq =\n let P = sim .transMatL\n Q = sim .transMatR in\n (λ t → helper a t ⊕ sim .transEq t)\n ∙ sym (⊕-⋆ _ _ _ Q)\n ∙ (λ t → ⊕-⋆ 1r a P M (~ t) ⋆ (1r ⊕ Q))\n where helper : (a : R) → a ≡ (1r · a) · 1r\n helper = solve 𝓡\n ⊕SimRel _ sim .isInvTransL = isInv⊕ _ (sim .isInvTransL)\n ⊕SimRel _ sim .isInvTransR = isInv⊕ _ (sim .isInvTransR)\n\n ⊕Sim : (a : R){M : Mat m n} → (sim : Sim M) → Sim (a ⊕ M)\n ⊕Sim a sim .result = a ⊕ sim .result\n ⊕Sim _ sim .simrel = ⊕SimRel _ (sim .simrel)\n", "meta": {"hexsha": "ec10c810055a13573a6de073866bbc9b6d15d6b2", "size": 10682, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Matrix/CommRingCoefficient.agda", "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Matrix/CommRingCoefficient.agda", "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Matrix/CommRingCoefficient.agda", "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.0523255814, "max_line_length": 105, "alphanum_fraction": 0.5136678525, "num_tokens": 5229, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382129861583, "lm_q2_score": 0.749087201911703, "lm_q1q2_score": 0.6453672493058101}} {"text": "{-# OPTIONS --type-in-type #-}\n\nopen import Function\nopen import Data.Nat.Base\nopen import Data.Bool.Base\nopen import Data.Product\n\n{-# NO_POSITIVITY_CHECK #-}\nrecord IFix {I : Set} (F : (I -> Set) -> I -> Set) (i : I) : Set where\n constructor wrap\n field unwrap : F (IFix F) i\nopen IFix\n\ndata Expr : Set -> Set where\n Lit : ℕ -> Expr ℕ\n Inc : Expr ℕ -> Expr ℕ\n IsZ : Expr ℕ -> Expr Bool\n Pair : ∀ {A B} -> Expr A -> Expr B -> Expr (A × B)\n Fst : ∀ {A B} -> Expr (A × B) -> Expr A\n Snd : ∀ {A B} -> Expr (A × B) -> Expr B\n\n-- As usually the pattern vector of a Scott-encoded data type encodes pattern-matching.\nExprF′ : (Set -> Set) -> Set -> Set\nExprF′\n = λ Rec I\n -> (R : Set -> Set)\n -> (ℕ -> R ℕ)\n -> (Rec ℕ -> R ℕ)\n -> (Rec ℕ -> R Bool)\n -> (∀ {A B} -> Rec A -> Rec B -> R (A × B))\n -> (∀ {A B} -> Rec (A × B) -> R A)\n -> (∀ {A B} -> Rec (A × B) -> R B)\n -> R I\n\nExpr′ : Set -> Set\nExpr′ = IFix ExprF′\n\nexpr-to-expr′ : ∀ {A} -> Expr A -> Expr′ A\nexpr-to-expr′ (Lit x) = wrap λ R lit inc isZ pair fst snd -> lit x\nexpr-to-expr′ (Inc x) = wrap λ R lit inc isZ pair fst snd -> inc (expr-to-expr′ x)\nexpr-to-expr′ (IsZ x) = wrap λ R lit inc isZ pair fst snd -> isZ (expr-to-expr′ x)\nexpr-to-expr′ (Pair x y) = wrap λ R lit inc isZ pair fst snd -> pair (expr-to-expr′ x) (expr-to-expr′ y)\nexpr-to-expr′ (Fst p) = wrap λ R lit inc isZ pair fst snd -> fst (expr-to-expr′ p)\nexpr-to-expr′ (Snd p) = wrap λ R lit inc isZ pair fst snd -> snd (expr-to-expr′ p)\n\n{-# TERMINATING #-}\nexpr′-to-expr : ∀ {A} -> Expr′ A -> Expr A\nexpr′-to-expr e =\n unwrap\n e\n Expr\n Lit\n (Inc ∘ expr′-to-expr)\n (IsZ ∘ expr′-to-expr)\n (λ x y -> Pair (expr′-to-expr x) (expr′-to-expr y))\n (Fst ∘ expr′-to-expr)\n (Snd ∘ expr′-to-expr)\n\nisZero : ℕ -> Bool\nisZero zero = true\nisZero (suc _) = false\n\n{-# TERMINATING #-}\nevalExpr′ : ∀ {A} -> Expr′ A -> A\nevalExpr′ e =\n unwrap\n e\n id\n id\n (suc ∘ evalExpr′)\n (isZero ∘ evalExpr′)\n (λ x y -> (evalExpr′ x , evalExpr′ y))\n (proj₁ ∘ evalExpr′)\n (proj₂ ∘ evalExpr′)\n", "meta": {"hexsha": "fea773f2da29b2e175cd7e15ab63abd6c50881d3", "size": 2067, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/fomega/gadts/Expr.agda", "max_stars_repo_name": "AriFordsham/plutus", "max_stars_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1299, "max_stars_repo_stars_event_min_datetime": "2018-10-02T13:41:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-28T01:10:02.000Z", "max_issues_repo_path": "notes/fomega/gadts/Expr.agda", "max_issues_repo_name": "AriFordsham/plutus", "max_issues_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 2493, "max_issues_repo_issues_event_min_datetime": "2018-09-28T19:28:17.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T15:31:31.000Z", "max_forks_repo_path": "notes/fomega/gadts/Expr.agda", "max_forks_repo_name": "AriFordsham/plutus", "max_forks_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 399, "max_forks_repo_forks_event_min_datetime": "2018-10-05T09:36:10.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T11:18:25.000Z", "avg_line_length": 27.56, "max_line_length": 104, "alphanum_fraction": 0.541848089, "num_tokens": 790, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8902942290328344, "lm_q2_score": 0.7248702880639791, "lm_q1q2_score": 0.6453478342607288}} {"text": "-- Modified: Andreas, 2011-04-11 freezing Metas\nmodule HereditarilySingletonRecord where\n\ndata _≡_ {A : Set} (x : A) : A → Set where\n refl : x ≡ x\n\n-- * trivial unit type\n\nrecord Singleton : Set where\n\nfoo : Singleton\nfoo = _\n\n-- * product of unit types\n\nrecord HereditarilySingleton : Set where\n field\n singleton : Singleton\n also-singleton : Singleton\n\nbar : HereditarilySingleton\nbar = _\n\n-- * hiding the unit types behind a type case\n\ndata ℕ : Set where\n zero : ℕ\n suc : (n : ℕ) → ℕ\n\nUnit : ℕ → Set\nUnit zero = Singleton\nUnit (suc n) = Unit n\n\nmutual -- needed to avoid freezing\n\n one : ℕ\n one = _\n\n record HereditarilySingleton₂ : Set where\n field\n singleton : Unit one\n\n baz : HereditarilySingleton₂\n baz = _\n\n force : one ≡ suc zero\n force = refl\n", "meta": {"hexsha": "8b23988cee18fbd687f47e36742a0921ee219ee6", "size": 788, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/HereditarilySingletonRecord.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/Succeed/HereditarilySingletonRecord.agda", "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/HereditarilySingletonRecord.agda", "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 16.4166666667, "max_line_length": 47, "alphanum_fraction": 0.6611675127, "num_tokens": 234, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8902942144788076, "lm_q2_score": 0.7248702702332475, "lm_q1q2_score": 0.64534780783635}} {"text": "-- In this file we consider the special of localising at a single\n-- element f : R (or rather the set of powers of f). This is also\n-- known as inverting f.\n-- We then prove that localising first at an element f and at an element\n-- g (or rather the image g/1) is the same as localising at the product f·g\n-- This fact has an important application in algebraic geometry where it's\n-- used to define the structure sheaf of a commutative ring.\n\n{-# OPTIONS --safe --experimental-lossy-unification #-}\nmodule Cubical.Algebra.CommRing.Localisation.InvertingElements where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Univalence\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Powerset\nopen import Cubical.Foundations.Transport\nopen import Cubical.Functions.FunExtEquiv\n\nimport Cubical.Data.Empty as ⊥\nopen import Cubical.Data.Bool\nopen import Cubical.Data.Nat renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_\n ; +-comm to +ℕ-comm ; +-assoc to +ℕ-assoc\n ; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm)\nopen import Cubical.Data.Nat.Order\nopen import Cubical.Data.Vec\nopen import Cubical.Data.Sigma.Base\nopen import Cubical.Data.Sigma.Properties\nopen import Cubical.Data.FinData\nopen import Cubical.Relation.Nullary\nopen import Cubical.Relation.Binary\n\nopen import Cubical.Algebra.Group\nopen import Cubical.Algebra.AbGroup\nopen import Cubical.Algebra.Monoid\nopen import Cubical.Algebra.Ring\nopen import Cubical.Algebra.CommRing\nopen import Cubical.Algebra.CommRing.Localisation.Base\nopen import Cubical.Algebra.CommRing.Localisation.UniversalProperty\nopen import Cubical.Algebra.RingSolver.ReflectionSolving\n\nopen import Cubical.HITs.SetQuotients as SQ\nopen import Cubical.HITs.PropositionalTruncation as PT\n\nopen Iso\n\nprivate\n variable\n ℓ ℓ' : Level\n A : Type ℓ\n\nmodule _(R' : CommRing ℓ) where\n open isMultClosedSubset\n private R = fst R'\n open CommRingStr (snd R')\n open Exponentiation R'\n\n\n [_ⁿ|n≥0] : R → ℙ R\n [ f ⁿ|n≥0] g = (∃[ n ∈ ℕ ] g ≡ f ^ n) , isPropPropTrunc\n -- Σ[ n ∈ ℕ ] (s ≡ f ^ n) × (∀ m → s ≡ f ^ m → n ≤ m) maybe better, this isProp:\n -- (n,s≡fⁿ,p) (m,s≡fᵐ,q) then n≤m by p and m≤n by q => n≡m\n\n powersFormMultClosedSubset : (f : R) → isMultClosedSubset R' [ f ⁿ|n≥0]\n powersFormMultClosedSubset f .containsOne = PT.∣ zero , refl ∣\n powersFormMultClosedSubset f .multClosed =\n PT.map2 λ (m , p) (n , q) → (m +ℕ n) , (λ i → (p i) · (q i)) ∙ ·-of-^-is-^-of-+ f m n\n\n\n R[1/_] : R → Type ℓ\n R[1/ f ] = Loc.S⁻¹R R' [ f ⁿ|n≥0] (powersFormMultClosedSubset f)\n\n\n R[1/_]AsCommRing : R → CommRing ℓ\n R[1/ f ]AsCommRing = Loc.S⁻¹RAsCommRing R' [ f ⁿ|n≥0] (powersFormMultClosedSubset f)\n\n -- A useful lemma: (gⁿ/1)≡(g/1)ⁿ in R[1/f]\n ^-respects-/1 : {f g : R} (n : ℕ) → [ (g ^ n) , 1r , PT.∣ 0 , (λ _ → 1r) ∣ ] ≡\n Exponentiation._^_ R[1/ f ]AsCommRing [ g , 1r , powersFormMultClosedSubset _ .containsOne ] n\n ^-respects-/1 zero = refl\n ^-respects-/1 {f} {g} (suc n) = eq/ _ _ ( (1r , powersFormMultClosedSubset f .containsOne)\n , cong (1r · (g · (g ^ n)) ·_) (·Lid 1r))\n ∙ cong (CommRingStr._·_ (R[1/ f ]AsCommRing .snd)\n [ g , 1r , powersFormMultClosedSubset f .containsOne ]) (^-respects-/1 n)\n\n -- A slight improvement for eliminating into propositions\n InvElPropElim : {f : R} {P : R[1/ f ] → Type ℓ'}\n → (∀ x → isProp (P x))\n → (∀ (r : R) (n : ℕ) → P [ r , (f ^ n) , PT.∣ n , refl ∣ ]) -- ∀ r n → P (r/fⁿ)\n ----------------------------------------------------------\n → (∀ x → P x)\n InvElPropElim {f = f} {P = P} PisProp base = elimProp (λ _ → PisProp _) []-case\n where\n S[f] = Loc.S R' [ f ⁿ|n≥0] (powersFormMultClosedSubset f)\n []-case : (a : R × S[f]) → P [ a ]\n []-case (r , s , s∈S[f]) = PT.rec (PisProp _) Σhelper s∈S[f]\n where\n Σhelper : Σ[ n ∈ ℕ ] s ≡ f ^ n → P [ r , s , s∈S[f] ]\n Σhelper (n , p) = subst P (cong [_] (≡-× refl (Σ≡Prop (λ _ → isPropPropTrunc) (sym p)))) (base r n)\n\n -- For predicates over the set of powers\n powersPropElim : {f : R} {P : R → Type ℓ'}\n → (∀ x → isProp (P x))\n → (∀ n → P (f ^ n))\n ------------------------------\n → ∀ s → s ∈ [ f ⁿ|n≥0] → P s\n powersPropElim {f = f} {P = P} PisProp base s =\n PT.rec (PisProp s) λ (n , p) → subst P (sym p) (base n)\n\n\n\nmodule DoubleLoc (R' : CommRing ℓ) (f g : (fst R')) where\n open isMultClosedSubset\n open CommRingStr (snd R')\n open CommRingTheory R'\n open Exponentiation R'\n open RingTheory (CommRing→Ring R')\n open CommRingStr (snd (R[1/_]AsCommRing R' f)) renaming ( _·_ to _·ᶠ_ ; 1r to 1ᶠ\n ; _+_ to _+ᶠ_ ; 0r to 0ᶠ\n ; ·Lid to ·ᶠ-lid ; ·Rid to ·ᶠ-rid\n ; ·Assoc to ·ᶠ-assoc ; ·-comm to ·ᶠ-comm)\n open IsRingHom\n\n private\n R = fst R'\n R[1/f] = R[1/_] R' f\n R[1/f]AsCommRing = R[1/_]AsCommRing R' f\n R[1/fg] = R[1/_] R' (f · g)\n R[1/fg]AsCommRing = R[1/_]AsCommRing R' (f · g)\n R[1/f][1/g] = R[1/_] (R[1/_]AsCommRing R' f)\n [ g , 1r , powersFormMultClosedSubset R' f .containsOne ]\n R[1/f][1/g]AsCommRing = R[1/_]AsCommRing (R[1/_]AsCommRing R' f)\n [ g , 1r , powersFormMultClosedSubset R' f .containsOne ]\n R[1/f][1/g]ˣ = R[1/f][1/g]AsCommRing ˣ\n\n\n _/1/1 : R → R[1/f][1/g]\n r /1/1 = [ [ r , 1r , PT.∣ 0 , refl ∣ ] , 1ᶠ , PT.∣ 0 , refl ∣ ]\n\n /1/1AsCommRingHom : CommRingHom R' R[1/f][1/g]AsCommRing\n fst /1/1AsCommRingHom = _/1/1\n snd /1/1AsCommRingHom = makeIsRingHom refl lem+ lem·\n where\n lem+ : _\n lem+ r r' =\n cong [_]\n (≡-×\n (cong [_]\n (≡-×\n (cong₂ _+_\n (sym (·Rid _) ∙ (λ i → (·Rid r (~ i)) · (·Rid 1r (~ i))))\n (sym (·Rid _) ∙ (λ i → (·Rid r' (~ i)) · (·Rid 1r (~ i)))))\n (Σ≡Prop (λ _ → isPropPropTrunc)\n (sym (·Lid _) ∙ (λ i → (·Lid 1r (~ i)) · (·Lid 1r (~ i)))))))\n (Σ≡Prop (λ _ → isPropPropTrunc) (sym (·ᶠ-lid 1ᶠ))))\n\n lem· : _\n lem· r r' =\n cong [_]\n (≡-×\n (cong [_] (≡-× refl (Σ≡Prop (λ _ → isPropPropTrunc) (sym (·Lid _)))))\n (Σ≡Prop (λ _ → isPropPropTrunc) (sym (·ᶠ-lid 1ᶠ))))\n\n -- this will give us a map R[1/fg] → R[1/f][1/g] by the universal property of localisation\n fⁿgⁿ/1/1∈R[1/f][1/g]ˣ : (s : R) → s ∈ ([_ⁿ|n≥0] R' (f · g)) → s /1/1 ∈ R[1/f][1/g]ˣ\n fⁿgⁿ/1/1∈R[1/f][1/g]ˣ = powersPropElim R' (λ s → R[1/f][1/g]ˣ (s /1/1) .snd) ℕcase\n where\n ℕcase : (n : ℕ) → ((f · g) ^ n) /1/1 ∈ R[1/f][1/g]ˣ\n ℕcase n = [ [ 1r , (f ^ n) , PT.∣ n , refl ∣ ]\n , [ (g ^ n) , 1r , PT.∣ 0 , refl ∣ ] --denominator\n , PT.∣ n , ^-respects-/1 _ n ∣ ]\n , eq/ _ _ ((1ᶠ , powersFormMultClosedSubset _ _ .containsOne)\n , eq/ _ _ ((1r , powersFormMultClosedSubset _ _ .containsOne) , path))\n where\n eq1 : ∀ x → 1r · (1r · (x · 1r) · 1r) · (1r · 1r · (1r · 1r)) ≡ x\n eq1 = solve R'\n\n eq2 : ∀ x y → x · y ≡ 1r · (1r · 1r · (1r · y)) · (1r · (1r · x) · 1r)\n eq2 = solve R'\n\n path : 1r · (1r · ((f · g) ^ n · 1r) · 1r) · (1r · 1r · (1r · 1r))\n ≡ 1r · (1r · 1r · (1r · g ^ n)) · (1r · (1r · f ^ n) · 1r)\n path = 1r · (1r · ((f · g) ^ n · 1r) · 1r) · (1r · 1r · (1r · 1r)) ≡⟨ eq1 ((f · g) ^ n) ⟩\n (f · g) ^ n ≡⟨ ^-ldist-· _ _ _ ⟩\n f ^ n · g ^ n ≡⟨ eq2 (f ^ n) (g ^ n) ⟩\n 1r · (1r · 1r · (1r · g ^ n)) · (1r · (1r · f ^ n) · 1r) ∎\n\n\n -- the main result: localising at one element and then at another is\n -- the same as localising at the product.\n -- takes forever to compute without experimental lossy unification\n R[1/fg]≡R[1/f][1/g] : R[1/fg]AsCommRing ≡ R[1/f][1/g]AsCommRing\n R[1/fg]≡R[1/f][1/g] = S⁻¹RChar R' ([_ⁿ|n≥0] R' (f · g))\n (powersFormMultClosedSubset R' (f · g)) _ /1/1AsCommRingHom pathtoR[1/fg]\n where\n open PathToS⁻¹R\n pathtoR[1/fg] : PathToS⁻¹R R' ([_ⁿ|n≥0] R' (f · g)) (powersFormMultClosedSubset R' (f · g))\n R[1/f][1/g]AsCommRing /1/1AsCommRingHom\n φS⊆Aˣ pathtoR[1/fg] = fⁿgⁿ/1/1∈R[1/f][1/g]ˣ\n\n kerφ⊆annS pathtoR[1/fg] r p = toGoal helperR[1/f]\n where\n open RingTheory (CommRing→Ring R[1/f]AsCommRing) renaming ( 0RightAnnihilates to 0ᶠRightAnnihilates\n ; 0LeftAnnihilates to 0ᶠ-leftNullifies)\n open Exponentiation R[1/f]AsCommRing renaming (_^_ to _^ᶠ_)\n hiding (·-of-^-is-^-of-+ ; ^-ldist-·)\n\n S[f] = Loc.S R' ([_ⁿ|n≥0] R' f) (powersFormMultClosedSubset R' f)\n S[fg] = Loc.S R' ([_ⁿ|n≥0] R' (f · g)) (powersFormMultClosedSubset R' (f · g))\n g/1 : R[1/_] R' f\n g/1 = [ g , 1r , powersFormMultClosedSubset R' f .containsOne ]\n S[g/1] = Loc.S R[1/f]AsCommRing\n ([_ⁿ|n≥0] R[1/f]AsCommRing g/1)\n (powersFormMultClosedSubset R[1/f]AsCommRing g/1)\n r/1 : R[1/_] R' f\n r/1 = [ r , 1r , powersFormMultClosedSubset R' f .containsOne ]\n\n -- this is the crucial step, modulo truncation we can take p to be generated\n -- by the quotienting relation of localisation. Note that we wouldn't be able\n -- to prove our goal if kerφ⊆annS was formulated with a Σ instead of a ∃\n ∥r/1,1/1≈0/1,1/1∥ : ∃[ u ∈ S[g/1] ] fst u ·ᶠ r/1 ·ᶠ 1ᶠ ≡ fst u ·ᶠ 0ᶠ ·ᶠ 1ᶠ\n ∥r/1,1/1≈0/1,1/1∥ = Iso.fun (SQ.isEquivRel→TruncIso (Loc.locIsEquivRel _ _ _) _ _) p\n\n helperR[1/f] : ∃[ n ∈ ℕ ] [ g ^ n · r , 1r , PT.∣ 0 , refl ∣ ] ≡ 0ᶠ\n helperR[1/f] = PT.rec isPropPropTrunc\n (uncurry (uncurry (powersPropElim R[1/f]AsCommRing\n (λ _ → isPropΠ (λ _ → isPropPropTrunc)) baseCase)))\n ∥r/1,1/1≈0/1,1/1∥\n where\n baseCase : ∀ n → g/1 ^ᶠ n ·ᶠ r/1 ·ᶠ 1ᶠ ≡ g/1 ^ᶠ n ·ᶠ 0ᶠ ·ᶠ 1ᶠ\n → ∃[ n ∈ ℕ ] [ g ^ n · r , 1r , PT.∣ 0 , refl ∣ ] ≡ 0ᶠ\n baseCase n q = PT.∣ n , path ∣\n where\n path : [ g ^ n · r , 1r , PT.∣ 0 , refl ∣ ] ≡ 0ᶠ\n path = [ g ^ n · r , 1r , PT.∣ 0 , refl ∣ ]\n\n ≡⟨ cong [_] (≡-× refl (Σ≡Prop (λ _ → isPropPropTrunc) (sym (·Rid _)))) ⟩\n\n [ g ^ n , 1r , PT.∣ 0 , refl ∣ ] ·ᶠ r/1\n\n ≡⟨ cong (_·ᶠ r/1) (^-respects-/1 _ n) ⟩\n\n g/1 ^ᶠ n ·ᶠ r/1\n\n ≡⟨ sym (·ᶠ-rid _) ⟩\n\n g/1 ^ᶠ n ·ᶠ r/1 ·ᶠ 1ᶠ\n\n ≡⟨ q ⟩\n\n g/1 ^ᶠ n ·ᶠ 0ᶠ ·ᶠ 1ᶠ\n\n ≡⟨ cong (_·ᶠ 1ᶠ) (0ᶠRightAnnihilates _) ∙ 0ᶠ-leftNullifies 1ᶠ ⟩\n\n 0ᶠ ∎\n\n\n toGoal : ∃[ n ∈ ℕ ] [ g ^ n · r , 1r , PT.∣ 0 , refl ∣ ] ≡ 0ᶠ\n → ∃[ u ∈ S[fg] ] fst u · r ≡ 0r\n toGoal = PT.rec isPropPropTrunc Σhelper\n where\n Σhelper : Σ[ n ∈ ℕ ] [ g ^ n · r , 1r , PT.∣ 0 , refl ∣ ] ≡ 0ᶠ\n → ∃[ u ∈ S[fg] ] fst u · r ≡ 0r\n Σhelper (n , q) = PT.map Σhelper2 helperR\n where\n -- now, repeat the above strategy with q\n ∥gⁿr≈0∥ : ∃[ u ∈ S[f] ] fst u · (g ^ n · r) · 1r ≡ fst u · 0r · 1r\n ∥gⁿr≈0∥ = Iso.fun (SQ.isEquivRel→TruncIso (Loc.locIsEquivRel _ _ _) _ _) q\n\n helperR : ∃[ m ∈ ℕ ] f ^ m · g ^ n · r ≡ 0r\n helperR = PT.rec isPropPropTrunc\n (uncurry (uncurry (powersPropElim R'\n (λ _ → isPropΠ (λ _ → isPropPropTrunc)) baseCase)))\n ∥gⁿr≈0∥\n where\n baseCase : (m : ℕ) → f ^ m · (g ^ n · r) · 1r ≡ f ^ m · 0r · 1r\n → ∃[ m ∈ ℕ ] f ^ m · g ^ n · r ≡ 0r\n baseCase m q' = PT.∣ m , path ∣\n where\n path : f ^ m · g ^ n · r ≡ 0r\n path = (λ i → ·Rid (·Assoc (f ^ m) (g ^ n) r (~ i)) (~ i))\n ∙∙ q' ∙∙ (λ i → ·Rid (0RightAnnihilates (f ^ m) i) i)\n\n Σhelper2 : Σ[ m ∈ ℕ ] f ^ m · g ^ n · r ≡ 0r\n → Σ[ u ∈ S[fg] ] fst u · r ≡ 0r\n Σhelper2 (m , q') = (((f · g) ^ l) , PT.∣ l , refl ∣) , path\n where\n l = max m n\n\n path : (f · g) ^ l · r ≡ 0r\n path = (f · g) ^ l · r\n\n ≡⟨ cong (_· r) (^-ldist-· _ _ _) ⟩\n\n f ^ l · g ^ l · r\n\n ≡⟨ cong₂ (λ x y → f ^ x · g ^ y · r) (sym (≤-∸-+-cancel {m = m} left-≤-max))\n (sym (≤-∸-+-cancel {m = n} right-≤-max)) ⟩\n\n f ^ (l ∸ m +ℕ m) · g ^ (l ∸ n +ℕ n) · r\n\n ≡⟨ cong₂ (λ x y → x · y · r) (sym (·-of-^-is-^-of-+ _ _ _))\n (sym (·-of-^-is-^-of-+ _ _ _)) ⟩\n\n f ^ (l ∸ m) · f ^ m · (g ^ (l ∸ n) · g ^ n) · r\n\n ≡⟨ cong (_· r) (·-commAssocSwap _ _ _ _) ⟩\n\n f ^ (l ∸ m) · g ^ (l ∸ n) · (f ^ m · g ^ n) · r\n\n ≡⟨ sym (·Assoc _ _ _) ⟩\n\n f ^ (l ∸ m) · g ^ (l ∸ n) · (f ^ m · g ^ n · r)\n\n ≡⟨ cong (f ^ (l ∸ m) · g ^ (l ∸ n) ·_) q' ⟩\n\n f ^ (l ∸ m) · g ^ (l ∸ n) · 0r\n\n ≡⟨ 0RightAnnihilates _ ⟩\n\n 0r ∎\n\n\n surχ pathtoR[1/fg] = InvElPropElim _ (λ _ → isPropPropTrunc) toGoal\n where\n open Exponentiation R[1/f]AsCommRing renaming (_^_ to _^ᶠ_)\n hiding (·-of-^-is-^-of-+ ; ^-ldist-·)\n open CommRingStr (snd R[1/f][1/g]AsCommRing) renaming (_·_ to _·R[1/f][1/g]_)\n hiding (1r ; ·Lid ; ·Rid ; ·Assoc)\n open Units R[1/f][1/g]AsCommRing\n g/1 : R[1/_] R' f\n g/1 = [ g , 1r , powersFormMultClosedSubset R' f .containsOne ]\n S[fg] = Loc.S R' ([_ⁿ|n≥0] R' (f · g)) (powersFormMultClosedSubset R' (f · g))\n\n baseCase : (r : R) (m n : ℕ) → ∃[ x ∈ R × S[fg] ] (x .fst /1/1)\n ≡ [ [ r , f ^ m , PT.∣ m , refl ∣ ]\n , [ g ^ n , 1r , PT.∣ 0 , refl ∣ ] , PT.∣ n , ^-respects-/1 _ n ∣ ]\n ·R[1/f][1/g] (x .snd .fst /1/1)\n baseCase r m n = PT.∣ ((r · f ^ (l ∸ m) · g ^ (l ∸ n)) -- x .fst\n , (f · g) ^ l , PT.∣ l , refl ∣) -- x .snd\n , eq/ _ _ ((1ᶠ , PT.∣ 0 , refl ∣) , eq/ _ _ ((1r , PT.∣ 0 , refl ∣) , path)) ∣\n -- reduce equality of double fractions into equality in R\n where\n eq1 : ∀ r flm gln gn fm\n → 1r · (1r · (r · flm · gln) · (gn · 1r)) · (1r · (fm · 1r) · 1r)\n ≡ r · flm · (gln · gn) · fm\n eq1 = solve R'\n\n eq2 : ∀ r flm gl fm → r · flm · gl · fm ≡ r · (flm · fm ) · gl\n eq2 = solve R'\n\n eq3 : ∀ r fgl → r · fgl ≡ 1r · (1r · (r · fgl) · 1r) · (1r · 1r · (1r · 1r))\n eq3 = solve R'\n\n l = max m n\n\n path : 1r · (1r · (r · f ^ (l ∸ m) · g ^ (l ∸ n)) · (g ^ n · 1r)) · (1r · (f ^ m · 1r) · 1r)\n ≡ 1r · (1r · (r · (f · g) ^ l) · 1r) · (1r · 1r · (1r · 1r))\n path = 1r · (1r · (r · f ^ (l ∸ m) · g ^ (l ∸ n)) · (g ^ n · 1r)) · (1r · (f ^ m · 1r) · 1r)\n\n ≡⟨ eq1 r (f ^ (l ∸ m)) (g ^ (l ∸ n)) (g ^ n) (f ^ m) ⟩\n\n r · f ^ (l ∸ m) · (g ^ (l ∸ n) · g ^ n) · f ^ m\n\n ≡⟨ cong (λ x → r · f ^ (l ∸ m) · x · f ^ m) (·-of-^-is-^-of-+ _ _ _) ⟩\n\n r · f ^ (l ∸ m) · g ^ (l ∸ n +ℕ n) · f ^ m\n\n ≡⟨ cong (λ x → r · f ^ (l ∸ m) · g ^ x · f ^ m) (≤-∸-+-cancel right-≤-max) ⟩\n\n r · f ^ (l ∸ m) · g ^ l · f ^ m\n\n ≡⟨ eq2 r (f ^ (l ∸ m)) (g ^ l) (f ^ m) ⟩\n\n r · (f ^ (l ∸ m) · f ^ m) · g ^ l\n\n ≡⟨ cong (λ x → r · x · g ^ l) (·-of-^-is-^-of-+ _ _ _) ⟩\n\n r · f ^ (l ∸ m +ℕ m) · g ^ l\n\n ≡⟨ cong (λ x → r · f ^ x · g ^ l) (≤-∸-+-cancel left-≤-max) ⟩\n\n r · f ^ l · g ^ l\n\n ≡⟨ sym (·Assoc _ _ _) ⟩\n\n r · (f ^ l · g ^ l)\n\n ≡⟨ cong (r ·_) (sym (^-ldist-· _ _ _)) ⟩\n\n r · (f · g) ^ l\n\n ≡⟨ eq3 r ((f · g) ^ l) ⟩\n\n 1r · (1r · (r · (f · g) ^ l) · 1r) · (1r · 1r · (1r · 1r)) ∎\n\n\n base-^ᶠ-helper : (r : R) (m n : ℕ) → ∃[ x ∈ R × S[fg] ] (x .fst /1/1)\n ≡ [ [ r , f ^ m , PT.∣ m , refl ∣ ]\n , g/1 ^ᶠ n , PT.∣ n , refl ∣ ] ·R[1/f][1/g] (x .snd .fst /1/1)\n base-^ᶠ-helper r m n = subst (λ y → ∃[ x ∈ R × S[fg] ] (x .fst /1/1)\n ≡ [ [ r , f ^ m , PT.∣ m , refl ∣ ] , y ] ·R[1/f][1/g] (x .snd .fst /1/1))\n (Σ≡Prop (λ _ → isPropPropTrunc) (^-respects-/1 _ n)) (baseCase r m n)\n\n indStep : (r : R[1/_] R' f) (n : ℕ) → ∃[ x ∈ R × S[fg] ]\n (x .fst /1/1) ≡ [ r , g/1 ^ᶠ n , PT.∣ n , refl ∣ ] ·R[1/f][1/g] (x .snd .fst /1/1)\n indStep = InvElPropElim _ (λ _ → isPropΠ λ _ → isPropPropTrunc) base-^ᶠ-helper\n\n toGoal : (r : R[1/_] R' f) (n : ℕ) → ∃[ x ∈ R × S[fg] ]\n (x .fst /1/1) ·R[1/f][1/g]\n ((x .snd .fst /1/1) ⁻¹) ⦃ φS⊆Aˣ pathtoR[1/fg] (x .snd .fst) (x .snd .snd) ⦄\n ≡ [ r , g/1 ^ᶠ n , PT.∣ n , refl ∣ ]\n toGoal r n = PT.map Σhelper (indStep r n)\n where\n Σhelper : Σ[ x ∈ R × S[fg] ]\n (x .fst /1/1) ≡ [ r , g/1 ^ᶠ n , PT.∣ n , refl ∣ ] ·R[1/f][1/g] (x .snd .fst /1/1)\n → Σ[ x ∈ R × S[fg] ]\n (x .fst /1/1) ·R[1/f][1/g] ((x .snd .fst /1/1) ⁻¹)\n ⦃ φS⊆Aˣ pathtoR[1/fg] (x .snd .fst) (x .snd .snd) ⦄\n ≡ [ r , g/1 ^ᶠ n , PT.∣ n , refl ∣ ]\n Σhelper ((r' , s , s∈S[fg]) , p) = (r' , s , s∈S[fg])\n , ⁻¹-eq-elim ⦃ φS⊆Aˣ pathtoR[1/fg] s s∈S[fg] ⦄ p\n\n\n -- In this module we construct the map R[1/fg]→R[1/f][1/g] directly\n -- and show that it is equal (although not judgementally) to the map induced\n -- by the universal property of localisation, i.e. transporting along the path\n -- constructed above. Given that this is the easier direction, we can see that\n -- it is pretty cumbersome to prove R[1/fg]≡R[1/f][1/g] directly,\n -- which illustrates the usefulness of S⁻¹RChar quite well.\n private\n module check where\n φ : R[1/fg] → R[1/f][1/g]\n φ = SQ.rec squash/ ϕ ϕcoh\n where\n S[fg] = Loc.S R' ([_ⁿ|n≥0] R' (f · g)) (powersFormMultClosedSubset R' (f · g))\n\n curriedϕΣ : (r s : R) → Σ[ n ∈ ℕ ] s ≡ (f · g) ^ n → R[1/f][1/g]\n curriedϕΣ r s (n , s≡fg^n) = [ [ r , (f ^ n) , PT.∣ n , refl ∣ ]\n , [ (g ^ n) , 1r , PT.∣ 0 , refl ∣ ] --denominator\n , PT.∣ n , ^-respects-/1 R' n ∣ ]\n\n curriedϕ : (r s : R) → ∃[ n ∈ ℕ ] s ≡ (f · g) ^ n → R[1/f][1/g]\n curriedϕ r s = elim→Set (λ _ → squash/) (curriedϕΣ r s) coh\n where\n coh : (x y : Σ[ n ∈ ℕ ] s ≡ (f · g) ^ n) → curriedϕΣ r s x ≡ curriedϕΣ r s y\n coh (n , s≡fg^n) (m , s≡fg^m) = eq/ _ _ ((1ᶠ , PT.∣ 0 , refl ∣) ,\n eq/ _ _ ( (1r , powersFormMultClosedSubset R' f .containsOne)\n , path))\n where\n eq1 : ∀ r gm fm → 1r · (1r · r · gm) · (1r · fm · 1r) ≡ r · (gm · fm)\n eq1 = solve R'\n\n path : 1r · (1r · r · (g ^ m)) · (1r · (f ^ m) · 1r)\n ≡ 1r · (1r · r · (g ^ n)) · (1r · (f ^ n) · 1r)\n path = 1r · (1r · r · (g ^ m)) · (1r · (f ^ m) · 1r)\n\n ≡⟨ eq1 r (g ^ m) (f ^ m) ⟩\n\n r · (g ^ m · f ^ m)\n\n ≡⟨ cong (r ·_) (sym (^-ldist-· g f m)) ⟩\n\n r · ((g · f) ^ m)\n\n ≡⟨ cong (λ x → r · (x ^ m)) (·-comm _ _) ⟩\n\n r · ((f · g) ^ m)\n\n ≡⟨ cong (r ·_) ((sym s≡fg^m) ∙ s≡fg^n) ⟩\n\n r · ((f · g) ^ n)\n\n ≡⟨ cong (λ x → r · (x ^ n)) (·-comm _ _) ⟩\n\n r · ((g · f) ^ n)\n\n ≡⟨ cong (r ·_) (^-ldist-· g f n) ⟩\n\n r · (g ^ n · f ^ n)\n\n ≡⟨ sym (eq1 r (g ^ n) (f ^ n)) ⟩\n\n 1r · (1r · r · (g ^ n)) · (1r · (f ^ n) · 1r) ∎\n\n\n ϕ : R × S[fg] → R[1/f][1/g]\n ϕ = uncurry2 curriedϕ -- λ (r / (fg)ⁿ) → ((r / fⁿ) / gⁿ)\n\n curriedϕcohΣ : (r s r' s' u : R) → (p : u · r · s' ≡ u · r' · s)\n → (α : Σ[ n ∈ ℕ ] s ≡ (f · g) ^ n)\n → (β : Σ[ m ∈ ℕ ] s' ≡ (f · g) ^ m)\n → (γ : Σ[ l ∈ ℕ ] u ≡ (f · g) ^ l)\n → ϕ (r , s , PT.∣ α ∣) ≡ ϕ (r' , s' , PT.∣ β ∣)\n curriedϕcohΣ r s r' s' u p (n , s≡fgⁿ) (m , s'≡fgᵐ) (l , u≡fgˡ) =\n eq/ _ _ ( ( [ (g ^ l) , 1r , powersFormMultClosedSubset R' f .containsOne ]\n , PT.∣ l , ^-respects-/1 R' l ∣)\n , eq/ _ _ ((f ^ l , PT.∣ l , refl ∣) , path))\n where\n eq1 : ∀ fl gl r gm fm\n → fl · (gl · r · gm) · (1r · fm · 1r) ≡ fl · gl · r · (gm · fm)\n eq1 = solve R'\n\n path : f ^ l · (g ^ l · transp (λ i → R) i0 r · transp (λ i → R) i0 (g ^ m))\n · (1r · transp (λ i → R) i0 (f ^ m) · transp (λ i → R) i0 1r)\n ≡ f ^ l · (g ^ l · transp (λ i → R) i0 r' · transp (λ i → R) i0 (g ^ n))\n · (1r · transp (λ i → R) i0 (f ^ n) · transp (λ i → R) i0 1r)\n path = f ^ l · (g ^ l · transp (λ i → R) i0 r · transp (λ i → R) i0 (g ^ m))\n · (1r · transp (λ i → R) i0 (f ^ m) · transp (λ i → R) i0 1r)\n\n ≡⟨ (λ i → f ^ l · (g ^ l · transportRefl r i · transportRefl (g ^ m) i)\n · (1r · transportRefl (f ^ m) i · transportRefl 1r i)) ⟩\n\n f ^ l · (g ^ l · r · g ^ m) · (1r · f ^ m · 1r)\n\n ≡⟨ eq1 (f ^ l) (g ^ l) r (g ^ m) (f ^ m) ⟩\n\n f ^ l · g ^ l · r · (g ^ m · f ^ m)\n\n ≡⟨ (λ i → ^-ldist-· f g l (~ i) · r · ^-ldist-· g f m (~ i)) ⟩\n\n (f · g) ^ l · r · (g · f) ^ m\n\n ≡⟨ cong (λ x → (f · g) ^ l · r · x ^ m) (·-comm _ _) ⟩\n\n (f · g) ^ l · r · (f · g) ^ m\n\n ≡⟨ (λ i → u≡fgˡ (~ i) · r · s'≡fgᵐ (~ i)) ⟩\n\n u · r · s'\n\n ≡⟨ p ⟩\n\n u · r' · s\n\n ≡⟨ (λ i → u≡fgˡ i · r' · s≡fgⁿ i) ⟩\n\n (f · g) ^ l · r' · (f · g) ^ n\n\n ≡⟨ cong (λ x → (f · g) ^ l · r' · x ^ n) (·-comm _ _) ⟩\n\n (f · g) ^ l · r' · (g · f) ^ n\n\n ≡⟨ (λ i → ^-ldist-· f g l i · r' · ^-ldist-· g f n i) ⟩\n\n f ^ l · g ^ l · r' · (g ^ n · f ^ n)\n\n ≡⟨ sym (eq1 (f ^ l) (g ^ l) r' (g ^ n) (f ^ n)) ⟩\n\n f ^ l · (g ^ l · r' · g ^ n) · (1r · f ^ n · 1r)\n\n ≡⟨ (λ i → f ^ l · (g ^ l · transportRefl r' (~ i) · transportRefl (g ^ n) (~ i))\n · (1r · transportRefl (f ^ n) (~ i) · transportRefl 1r (~ i))) ⟩\n\n f ^ l · (g ^ l · transp (λ i → R) i0 r' · transp (λ i → R) i0 (g ^ n))\n · (1r · transp (λ i → R) i0 (f ^ n) · transp (λ i → R) i0 1r) ∎\n\n\n curriedϕcoh : (r s r' s' u : R) → (p : u · r · s' ≡ u · r' · s)\n → (α : ∃[ n ∈ ℕ ] s ≡ (f · g) ^ n)\n → (β : ∃[ m ∈ ℕ ] s' ≡ (f · g) ^ m)\n → (γ : ∃[ l ∈ ℕ ] u ≡ (f · g) ^ l)\n → ϕ (r , s , α) ≡ ϕ (r' , s' , β)\n curriedϕcoh r s r' s' u p = PT.elim (λ _ → isPropΠ2 (λ _ _ → squash/ _ _))\n λ α → PT.elim (λ _ → isPropΠ (λ _ → squash/ _ _))\n λ β → PT.rec (squash/ _ _)\n λ γ → curriedϕcohΣ r s r' s' u p α β γ\n\n ϕcoh : (a b : R × S[fg])\n → Loc._≈_ R' ([_ⁿ|n≥0] R' (f · g)) (powersFormMultClosedSubset R' (f · g)) a b\n → ϕ a ≡ ϕ b\n ϕcoh (r , s , α) (r' , s' , β) ((u , γ) , p) = curriedϕcoh r s r' s' u p α β γ\n\n\n\n\n -- the map induced by the universal property\n open S⁻¹RUniversalProp R' ([_ⁿ|n≥0] R' (f · g)) (powersFormMultClosedSubset R' (f · g))\n χ : R[1/fg] → R[1/f][1/g]\n χ = S⁻¹RHasUniversalProp R[1/f][1/g]AsCommRing /1/1AsCommRingHom fⁿgⁿ/1/1∈R[1/f][1/g]ˣ .fst .fst .fst\n\n -- the sanity check:\n -- both maps send a fraction r/(fg)ⁿ to a double fraction,\n -- where numerator and denominator are almost the same fraction respectively.\n -- unfortunately the proofs that the denominators are powers are quite different for\n -- the two maps, but of course we can ignore them.\n -- The definition of χ introduces a lot of (1r ·_). Perhaps most surprisingly,\n -- we have to give the path eq1 for the equality of the numerator of the numerator.\n φ≡χ : ∀ r → φ r ≡ χ r\n φ≡χ = InvElPropElim _ (λ _ → squash/ _ _) ℕcase\n where\n ℕcase : (r : R) (n : ℕ)\n → φ [ r , (f · g) ^ n , PT.∣ n , refl ∣ ] ≡ χ [ r , (f · g) ^ n , PT.∣ n , refl ∣ ]\n ℕcase r n = cong [_] (ΣPathP --look into the components of the double-fractions\n ( cong [_] (ΣPathP (eq1 , Σ≡Prop (λ x → S'[f] x .snd) (sym (·Lid _))))\n , Σ≡Prop (λ x → S'[f][g] x .snd) --ignore proof that denominator is power of g/1\n ( cong [_] (ΣPathP (sym (·Lid _) , Σ≡Prop (λ x → S'[f] x .snd) (sym (·Lid _)))))))\n where\n S'[f] = ([_ⁿ|n≥0] R' f)\n S'[f][g] = ([_ⁿ|n≥0] R[1/f]AsCommRing [ g , 1r , powersFormMultClosedSubset R' f .containsOne ])\n\n eq1 : transp (λ i → fst R') i0 r ≡ r · transp (λ i → fst R') i0 1r\n eq1 = transportRefl r ∙∙ sym (·Rid r) ∙∙ cong (r ·_) (sym (transportRefl 1r))\n", "meta": {"hexsha": "54f99ce12c17122de5241d774c797924c604e1ec", "size": 24882, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommRing/Localisation/InvertingElements.agda", "max_stars_repo_name": "dolio/cubical", "max_stars_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/CommRing/Localisation/InvertingElements.agda", "max_issues_repo_name": "dolio/cubical", "max_issues_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/CommRing/Localisation/InvertingElements.agda", "max_forks_repo_name": "dolio/cubical", "max_forks_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.0594059406, "max_line_length": 104, "alphanum_fraction": 0.4375452134, "num_tokens": 10683, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619177503206, "lm_q2_score": 0.7826624840223698, "lm_q1q2_score": 0.6452754125283127}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule Pi0Semiring where\n\nimport Level\n\nopen import PiU\nopen import PiLevel0\n\nopen import Algebra using (CommutativeSemiring)\nopen import Algebra.Structures\n using (IsSemigroup; IsCommutativeMonoid; IsCommutativeSemiring)\n \n------------------------------------------------------------------------------\n-- Commutative semiring structure of U\n\ntypesPlusIsSG : IsSemigroup _⟷_ PLUS\ntypesPlusIsSG = record {\n isEquivalence = record { refl = id⟷ ; sym = ! ; trans = _◎_ } ;\n assoc = λ t₁ t₂ t₃ → assocr₊ {t₁} {t₂} {t₃} ;\n ∙-cong = _⊕_\n }\n\ntypesTimesIsSG : IsSemigroup _⟷_ TIMES\ntypesTimesIsSG = record {\n isEquivalence = record { refl = id⟷ ; sym = ! ; trans = _◎_ } ;\n assoc = λ t₁ t₂ t₃ → assocr⋆ {t₁} {t₂} {t₃} ;\n ∙-cong = _⊗_\n }\n\ntypesPlusIsCM : IsCommutativeMonoid _⟷_ PLUS ZERO\ntypesPlusIsCM = record {\n isSemigroup = typesPlusIsSG ;\n identityˡ = λ t → unite₊l {t} ;\n comm = λ t₁ t₂ → swap₊ {t₁} {t₂}\n }\n\ntypesTimesIsCM : IsCommutativeMonoid _⟷_ TIMES ONE\ntypesTimesIsCM = record {\n isSemigroup = typesTimesIsSG ;\n identityˡ = λ t → unite⋆l {t} ;\n comm = λ t₁ t₂ → swap⋆ {t₁} {t₂}\n }\n\ntypesIsCSR : IsCommutativeSemiring _⟷_ PLUS TIMES ZERO ONE\ntypesIsCSR = record {\n +-isCommutativeMonoid = typesPlusIsCM ;\n *-isCommutativeMonoid = typesTimesIsCM ;\n distribʳ = λ t₁ t₂ t₃ → dist {t₂} {t₃} {t₁} ; \n zeroˡ = λ t → absorbr {t}\n }\n\ntypesCSR : CommutativeSemiring Level.zero Level.zero\ntypesCSR = record {\n Carrier = U ;\n _≈_ = _⟷_ ;\n _+_ = PLUS ;\n _*_ = TIMES ;\n 0# = ZERO ;\n 1# = ONE ;\n isCommutativeSemiring = typesIsCSR\n }\n\n------------------------------------------------------------------------------\n", "meta": {"hexsha": "291624ab2602e7a17b001193f29b65afdfe8bf44", "size": 1664, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Univalence/Pi0Semiring.agda", "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_issues_repo_path": "Univalence/Pi0Semiring.agda", "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_forks_repo_path": "Univalence/Pi0Semiring.agda", "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "avg_line_length": 25.6, "max_line_length": 78, "alphanum_fraction": 0.6021634615, "num_tokens": 582, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898203834278, "lm_q2_score": 0.7122321964553657, "lm_q1q2_score": 0.6452751197378911}} {"text": "-- -----------------------------\n-- Equality\n\nmodule Homogenous.Equality where\nimport Homogenous.Base\nimport EqBase\nimport PolyDepPrelude\n\nopen PolyDepPrelude using ( Datoid\n ; Bool; true; false; _&&_\n ; Pair; pair\n ; Either; left; right\n ; suc; zero\n ; _::_; nil\n ; cmp; Unit; unit\n )\nopen Homogenous.Base using (Arity; Sig; Fa; F; T; It; out)\n\neq_step_ar : (n : Arity){X : Set}(fs : Fa n (X -> Bool))(xs : Fa n X) -> Bool\neq_step_ar zero unit unit = true\neq_step_ar (suc m) (pair f fs') (pair x xs') = f x && eq_step_ar m fs' xs'\n\n-- We write left as This (as in \"This constructor\" and right as Other\n-- (as in \"one of the Other constructors\") to help the reader\n\neq_step' : (fi : Sig){X : Set} -> F fi (X -> Bool) -> F fi X -> Bool\neq_step' (nil) () () -- empty\neq_step' (n :: ns) (left fs ) (left xs ) = eq_step_ar n fs xs\neq_step' (n :: ns) (left fs ) (right y') = false\neq_step' (n :: ns) (right x') (left xs ) = false\neq_step' (n :: ns) (right x') (right y') = eq_step' ns x' y'\n\neq_step : (fi : Sig)(x : F fi (T fi -> Bool)) -> T fi -> Bool\neq_step fi x = \\t -> eq_step' fi x (out fi t)\n\nequal' : (fi : Sig) -> T fi -> (T fi -> Bool)\nequal' fi = It fi (eq_step fi)\n\nequal : (fi : Sig) -> T fi -> T fi -> Bool\nequal fi x y = equal' fi x y\n\n", "meta": {"hexsha": "7aedda17759cfb8af9ee3d745100319879abf786", "size": 1403, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/AIM5/PolyDep/Homogenous/Equality.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/AIM5/PolyDep/Homogenous/Equality.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/AIM5/PolyDep/Homogenous/Equality.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 33.4047619048, "max_line_length": 77, "alphanum_fraction": 0.5210263721, "num_tokens": 442, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898254600902, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.645275117819678}} {"text": "module Structure.Numeral.Integer where\n\nimport Lvl\nopen import Structure.Setoid\nopen import Structure.Operator.Properties\nopen import Structure.Operator.Ring\nopen import Structure.OrderedField\nopen import Structure.Relator\nopen import Type\n\nprivate variable ℓₒ ℓₗ ℓₑ ℓₗ₁ ℓₗ₂ : Lvl.Level\nprivate variable Z : Type{ℓₒ}\n\nrecord Integer ⦃ equiv : Equiv{ℓₑ}(Z) ⦄ (_+_ : Z → Z → Z) (_⋅_ : Z → Z → Z) (_≤_ : Z → Z → Type{ℓₗ}) : Typeω where\n constructor intro\n field\n ⦃ ring ⦄ : Ring(_+_)(_⋅_)\n ⦃ ordered ⦄ : Ordered(_+_)(_⋅_)(_≤_)\n open Ring(ring) public\n open Ordered(ordered) public\n\n 𝐒 : Z → Z\n 𝐒 = _+ 𝟏\n\n 𝐏 : Z → Z\n 𝐏 = _− 𝟏\n\n field\n ⦃ distinct-identities ⦄ : DistinctIdentities\n positive-induction : ∀{ℓ}{P : Z → Type{ℓ}} ⦃ rel-p : UnaryRelator(P) ⦄ → P(𝟎) → (∀{n} → (𝟎 ≤ n) → P(n) → P(𝐒(n))) → (∀{n} → (𝟎 ≤ n) → P(n))\n", "meta": {"hexsha": "a42b6ca3026323ec059dbb5befc72776bf0a6708", "size": 866, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Numeral/Integer.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Numeral/Integer.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Numeral/Integer.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.935483871, "max_line_length": 143, "alphanum_fraction": 0.6062355658, "num_tokens": 359, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9184802507195635, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.6452599889747976}} {"text": "open import x1-Base\n\nmodule x2-Sort\n {X : Set}\n {_≈_ : Rel X}\n {_≤_ : Rel X}\n (_≤?_ : Decidable _≤_)\n (ord : TotalOrder _≈_ _≤_)\n where\nopen TotalOrder ord using (total; equivalence)\nopen Equivalence equivalence using (refl)\n\n-- represent bounded lists, but want bounds to be open\n-- so lift X in a type that contains a top and bottom elements\ndata ⊥X⊤ : Set where\n ⊤ ⊥ : ⊥X⊤\n ⟦_⟧ : X → ⊥X⊤\n\n-- lift ordering to work with ⊥X⊤\ndata _≤̂_ : Rel ⊥X⊤ where\n ⊥≤̂ : ∀ {x} → ⊥ ≤̂ x\n ≤̂⊤ : ∀ {x} → x ≤̂ ⊤\n ≤-lift : ∀ {x y} → x ≤ y → ⟦ x ⟧ ≤̂ ⟦ y ⟧\n\n-- bounded, ordered lists\n-- elements ordered according to ≤ relation\ndata OList (l u : ⊥X⊤) : Set where\n -- nil works with any bounds l ≤ u\n nil : l ≤̂ u\n → OList l u\n -- cons x to a list with x as a lower bound,\n -- return a list with lower bound l, l ≤̂ ⟦ x ⟧\n cons : ∀ x\n (xs : OList ⟦ x ⟧ u)\n → l ≤̂ ⟦ x ⟧\n → OList l u\n\ntoList : ∀ {l u} → OList l u → List X\ntoList (nil _) = []\ntoList (cons x xs _) = x ∷ toList xs\n\ninsert : ∀ {l u} x\n → OList l u\n → l ≤̂ ⟦ x ⟧\n → ⟦ x ⟧ ≤̂ u\n → OList l u\ninsert x (nil _) l≤̂⟦x⟧ ⟦x⟧≤̂u =\n cons x (nil ⟦x⟧≤̂u)\n l≤̂⟦x⟧\n\ninsert x L@(cons x' xs l≤̂⟦x'⟧) l≤̂⟦x⟧ ⟦x⟧≤̂u with x ≤? x'\n... | left x≤x' =\n cons x (cons x' xs (≤-lift x≤x'))\n l≤̂⟦x⟧\n... | (right x≤x'→Empty) =\n cons x' (insert x xs ([ ≤-lift\n , (λ y≤x → absurd (x≤x'→Empty y≤x)) ]\n (total x' x))\n ⟦x⟧≤̂u)\n l≤̂⟦x'⟧\n\n-- Insertion sort uses OList ⊥ ⊤ to represent a sorted list with open bounds:\nisort' : List X → OList ⊥ ⊤\nisort' = foldr (λ x xs → insert x xs ⊥≤̂ ≤̂⊤) (nil ⊥≤̂)\n\nisort : List X → List X\nisort xs = toList (isort' xs)\n\n------------------------------------------------------------------------------\n-- Tree sort (more efficient)\n\n-- bounded, ordered binary tree\ndata Tree (l u : ⊥X⊤) : Set where\n leaf : l ≤̂ u\n → Tree l u\n node : (x : X)\n → Tree l ⟦ x ⟧\n → Tree ⟦ x ⟧ u\n → Tree l u\n\n\nt-insert : ∀ {l u}\n → (x : X)\n → Tree l u\n → l ≤̂ ⟦ x ⟧\n → ⟦ x ⟧ ≤̂ u\n → Tree l u\nt-insert x (leaf _) l≤x x≤u =\n node x (leaf l≤x) (leaf x≤u)\nt-insert x (node y ly yu) l≤x x≤u with x ≤? y\n... | left x≤y =\n node y (t-insert x ly l≤x (≤-lift x≤y)) yu\n... | right x>y =\n node y ly (t-insert x yu ([ (λ x≤y → absurd (x>y x≤y)) , ≤-lift ] (total x y)) x≤u)\n\nt-fromList : List X → Tree ⊥ ⊤\nt-fromList = foldr (λ x xs → t-insert x xs ⊥≤̂ ≤̂⊤) (leaf ⊥≤̂)\n\n-- OList concatenation, including inserting a new element in the middle\n_⇒_++_ : ∀ {l u} x\n → OList l ⟦ x ⟧\n → OList ⟦ x ⟧ u\n → OList l u\nx ⇒ nil l≤u ++ xu = cons x xu l≤u\nx ⇒ cons y yx l≤y ++ xu = cons y (x ⇒ yx ++ xu) l≤y\n\nt-flatten : ∀ {l u} → Tree l u → OList l u\nt-flatten (leaf l≤u) = (nil l≤u)\nt-flatten (node x lx xu) = x ⇒ t-flatten lx ++ t-flatten xu\n\nt-sort' : List X → OList ⊥ ⊤\nt-sort' xs = t-flatten (foldr (λ x xs → t-insert x xs ⊥≤̂ ≤̂⊤) (leaf ⊥≤̂) xs)\n\nt-sort : List X → List X\nt-sort xs = toList (t-sort' xs)\n\n", "meta": {"hexsha": "e4fe205117764a6ed39498f25236df220563c072", "size": 3271, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/topic/order/2013-04-01-sorting-francesco-mazzo/x2-Sort.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/topic/order/2013-04-01-sorting-francesco-mazzo/x2-Sort.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/topic/order/2013-04-01-sorting-francesco-mazzo/x2-Sort.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 27.9572649573, "max_line_length": 85, "alphanum_fraction": 0.4484867013, "num_tokens": 1382, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278664544911, "lm_q2_score": 0.7310585669110202, "lm_q1q2_score": 0.6451064514525694}} {"text": "module NatProps where\r\nopen import Data.Nat using (ℕ ; _≟_ ; _<_ ; zero ; suc ; s≤s)\r\nopen import Relation.Nullary using (Dec ; yes ; no ; ¬_)\r\nopen import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; sym)\r\n\r\n<-¬≡ : ∀ {n m} → n < m → ¬ n ≡ m\r\n<-¬≡ {zero} {zero} ()\r\n<-¬≡ {zero} {suc m} p = λ ()\r\n<-¬≡ {suc n} {zero} p = λ ()\r\n<-¬≡ {suc n} {suc m} (Data.Nat.s≤s p) with (<-¬≡ p)\r\n... | q = λ { refl → q refl }\r\n", "meta": {"hexsha": "dbadc11fae6741f8bad5a4a7211310958fa256df", "size": 423, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/NatProps.agda", "max_stars_repo_name": "Zalastax/thesis", "max_stars_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-02-02T16:44:43.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-02T16:44:43.000Z", "max_issues_repo_path": "src/NatProps.agda", "max_issues_repo_name": "Zalastax/singly-typed-actors", "max_issues_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/NatProps.agda", "max_forks_repo_name": "Zalastax/singly-typed-actors", "max_forks_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.25, "max_line_length": 75, "alphanum_fraction": 0.5224586288, "num_tokens": 172, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8577681195338729, "lm_q2_score": 0.7520125682019722, "lm_q1q2_score": 0.645052406492444}} {"text": "{-# OPTIONS --copatterns #-}\n-- {-# OPTIONS -v tc.lhs.split:50 -v tc.cover:20 -v tc.cc:15 -v tc.lhs.top:10 #-}\n-- {-# OPTIONS -v term:20 #-}\n-- {-# OPTIONS --no-positivity-check #-}\n-- {-# OPTIONS -v tc.def.fun:50 #-}\n-- {-# OPTIONS -v 100 #-}\nmodule CoPatStream where\n\nimport Common.Level\nopen import Common.Prelude hiding (map)\nopen import Common.Equality\n\nrecord Stream (A : Set) : Set where\n coinductive\n constructor cons\n field\n head : A\n tail : Stream A\nmodule S = Stream\n\nrecord _≈_ {A : Set}(s t : Stream A) : Set where\n coinductive\n field\n head : S.head s ≡ S.head t\n tail : S.tail s ≈ S.tail t\nmodule B = _≈_\n\nrepeat : {A : Set}(a : A) → Stream A\n-- repeat a = cons a (repeat a)\nS.head (repeat a) = a\nS.tail (repeat a) = repeat a\n\nmodule Cycle where\n\n cycle : Nat -> Stream Nat\n cycle n = cycle' n where\n cycle' : Nat -> Stream Nat\n S.head (cycle' n) = n\n S.tail (cycle' zero ) = cycle n\n S.tail (cycle' (suc n')) = cycle' n'\n\nmodule CoPat where\n\n map : {A B : Set} → (A → B) → Stream A → Stream B\n S.head (map f s) = f (S.head s)\n S.tail (map f s) = map f (S.tail s)\n\n map_id : {A : Set}(s : Stream A) → map (λ x → x) s ≈ s\n B.head (map_id s) = refl\n B.tail (map_id s) = map_id (S.tail s)\n\nmodule HandTranslated where\n\n {-# NON_TERMINATING #-}\n map : {A B : Set} → (A → B) → Stream A → Stream B\n map f s = record\n { head = f (S.head s)\n ; tail = map f (S.tail s)\n }\n\n {- rejected because map is not unfolded\n {-# NON_TERMINATING #-}\n map_id : {A : Set}(s : Stream A) → map (λ x → x) s ≈ s\n map_id s = record\n { head = refl\n ; tail = map_id (S.tail s)\n }\n -}\n\nmodule DeepCoPat where\n\n repeat₂ : {A : Set}(a₁ a₂ : A) → Stream A\n ( (S.head (repeat₂ a₁ a₂))) = a₁\n (S.head (S.tail (repeat₂ a₁ a₂))) = a₂\n (S.tail (S.tail (repeat₂ a₁ a₂))) = repeat₂ a₁ a₂\n\n repeat≈repeat₂ : {A : Set}(a : A) → repeat a ≈ repeat₂ a a\n ( (B.head (repeat≈repeat₂ a))) = refl\n (B.head (B.tail (repeat≈repeat₂ a))) = refl\n (B.tail (B.tail (repeat≈repeat₂ a))) = repeat≈repeat₂ a\n\nmodule ProjectionRHS where\n\n repeat′ : {A : Set}(a : A) → Stream A\n ( (S.head (repeat′ a))) = a\n (S.head (S.tail (repeat′ a))) = a\n (S.tail (S.tail (repeat′ a))) = S.tail (repeat′ a)\n\n-- -- Type error:\n-- repeat≈repeat′ : {A : Set}(a : A) → repeat a ≈ repeat′ a\n-- ( (B.head (repeat≈repeat′ a))) = refl\n-- (B.head (B.tail (repeat≈repeat′ a))) = refl\n-- (B.tail (B.tail (repeat≈repeat′ a))) = repeat≈repeat′ a\n\n", "meta": {"hexsha": "e2e8454b862ca51cc029f50891a27fbbf564223e", "size": 2487, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/CoPatStream.agda", "max_stars_repo_name": "alhassy/agda", "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Succeed/CoPatStream.agda", "max_issues_repo_name": "alhassy/agda", "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/CoPatStream.agda", "max_forks_repo_name": "alhassy/agda", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 26.1789473684, "max_line_length": 81, "alphanum_fraction": 0.5657418577, "num_tokens": 903, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835207180243, "lm_q2_score": 0.7718435030872968, "lm_q1q2_score": 0.644862527402708}} {"text": "-- Intuitionistic propositional logic, vector-based de Bruijn approach, initial encoding\n\nmodule Vi.Ip where\n\nopen import Lib using (Nat; suc; _+_; Fin; fin; Vec; _,_; proj; VMem; mem)\n\n\n-- Types\n\ninfixl 2 _&&_\ninfixl 1 _||_\ninfixr 0 _=>_\ndata Ty : Set where\n UNIT : Ty\n _=>_ : Ty -> Ty -> Ty\n _&&_ : Ty -> Ty -> Ty\n _||_ : Ty -> Ty -> Ty\n FALSE : Ty\n\ninfixr 0 _<=>_\n_<=>_ : Ty -> Ty -> Ty\na <=> b = (a => b) && (b => a)\n\nNOT : Ty -> Ty\nNOT a = a => FALSE\n\nTRUE : Ty\nTRUE = FALSE => FALSE\n\n\n-- Context and truth judgement\n\nCx : Nat -> Set\nCx n = Vec Ty n\n\nisTrue : forall {tn} -> Ty -> Fin tn -> Cx tn -> Set\nisTrue a i tc = VMem a i tc\n\n\n-- Terms\n\nmodule Ip where\n infixl 1 _$_\n infixr 0 lam=>_\n data Tm {tn} (tc : Cx tn) : Ty -> Set where\n var : forall {a i} -> isTrue a i tc -> Tm tc a\n lam=>_ : forall {a b} -> Tm (tc , a) b -> Tm tc (a => b)\n _$_ : forall {a b} -> Tm tc (a => b) -> Tm tc a -> Tm tc b\n pair' : forall {a b} -> Tm tc a -> Tm tc b -> Tm tc (a && b)\n fst : forall {a b} -> Tm tc (a && b) -> Tm tc a\n snd : forall {a b} -> Tm tc (a && b) -> Tm tc b\n left : forall {a b} -> Tm tc a -> Tm tc (a || b)\n right : forall {a b} -> Tm tc b -> Tm tc (a || b)\n case' : forall {a b c} -> Tm tc (a || b) -> Tm (tc , a) c -> Tm (tc , b) c -> Tm tc c\n abort : forall {a} -> Tm tc FALSE -> Tm tc a\n\n syntax pair' x y = [ x , y ]\n syntax case' xy x y = case xy => x => y\n\n v : forall {tn} (k : Nat) {tc : Cx (suc (k + tn))} -> Tm tc (proj tc (fin k))\n v i = var (mem i)\n\n Thm : Ty -> Set\n Thm a = forall {tn} {tc : Cx tn} -> Tm tc a\nopen Ip public\n\n\n-- Example theorems\n\nt1 : forall {a b} -> Thm (a => NOT a => b)\nt1 =\n lam=>\n lam=> abort (v 0 $ v 1)\n\nt2 : forall {a b} -> Thm (NOT a => a => b)\nt2 =\n lam=>\n lam=> abort (v 1 $ v 0)\n\nt3 : forall {a} -> Thm (a => NOT (NOT a))\nt3 =\n lam=>\n lam=> v 0 $ v 1\n\nt4 : forall {a} -> Thm (NOT a <=> NOT (NOT (NOT a)))\nt4 =\n [ lam=>\n lam=> v 0 $ v 1\n , lam=>\n lam=> v 1 $ (lam=> v 0 $ v 1)\n ]\n", "meta": {"hexsha": "cd4e21f59c08e4232b0f90386c7c216d82902737", "size": 2175, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Vi/Ip.agda", "max_stars_repo_name": "mietek/formal-logic", "max_stars_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_stars_repo_licenses": ["X11"], "max_stars_count": 26, "max_stars_repo_stars_event_min_datetime": "2015-08-31T09:49:52.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-13T12:37:44.000Z", "max_issues_repo_path": "src/Vi/Ip.agda", "max_issues_repo_name": "mietek/formal-logic", "max_issues_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_issues_repo_licenses": ["X11"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Vi/Ip.agda", "max_forks_repo_name": "mietek/formal-logic", "max_forks_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_forks_repo_licenses": ["X11"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.6413043478, "max_line_length": 90, "alphanum_fraction": 0.451954023, "num_tokens": 859, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094088947399, "lm_q2_score": 0.7217432122827967, "lm_q1q2_score": 0.6447400023381359}} {"text": "open import Relation.Binary.Core\n\nmodule BBHeap.Equality.Properties {A : Set}(_≤_ : A → A → Set) where\n\nopen import BBHeap _≤_\nopen import BBHeap.Equality _≤_\nopen import Bound.Lower A\n\nrefl≈ : {b : Bound}{h : BBHeap b} → h ≈ h\nrefl≈ {b} {leaf} = ≈leaf\nrefl≈ {b} {left b≤x l⋘r} = ≈left b≤x b≤x l⋘r l⋘r refl≈ refl≈\nrefl≈ {b} {right b≤x l⋙r} = ≈right b≤x b≤x l⋙r l⋙r refl≈ refl≈\n\nsym≈ : {b b' : Bound}{h : BBHeap b}{h' : BBHeap b'} → h ≈ h' → h' ≈ h\nsym≈ ≈leaf = ≈leaf\nsym≈ (≈left b≤x b'≤x' l⋘r l'⋘r' l≈l' r≈r') = ≈left b'≤x' b≤x l'⋘r' l⋘r (sym≈ l≈l') (sym≈ r≈r')\nsym≈ (≈right b≤x b'≤x' l⋙r l'⋙r' l≈l' r≈r') = ≈right b'≤x' b≤x l'⋙r' l⋙r (sym≈ l≈l') (sym≈ r≈r')\n\ntrans≈ : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}{h'' : BBHeap b''} → h ≈ h' → h' ≈ h'' → h ≈ h''\ntrans≈ ≈leaf ≈leaf = ≈leaf\ntrans≈ (≈left b≤x b'≤x' l⋘r l'⋘r' l≈l' r≈r') (≈left .b'≤x' b''≤x'' .l'⋘r' l''⋘r'' l'≈l'' r'≈r'') = ≈left b≤x b''≤x'' l⋘r l''⋘r'' (trans≈ l≈l' l'≈l'') (trans≈ r≈r' r'≈r'')\ntrans≈ (≈right b≤x b'≤x' l⋙r l'⋙r' l≈l' r≈r') (≈right .b'≤x' b''≤x'' .l'⋙r' l''⋙r'' l'≈l'' r'≈r'') = ≈right b≤x b''≤x'' l⋙r l''⋙r'' (trans≈ l≈l' l'≈l'') (trans≈ r≈r' r'≈r'')\n\nmutual\n lemma≈≃ : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}{h'' : BBHeap b''} → h ≈ h' → h' ≃ h'' → h ≃ h''\n lemma≈≃ ≈leaf ≃lf = ≃lf\n lemma≈≃ (≈left b≤x b'≤x' l⋘r l'⋘r' l≈l' r≈r') (≃nd .b'≤x' b''≤x'' .l'⋘r' l''⋘r'' l'≃r' l''≃r'' l'≃l'') = ≃nd b≤x b''≤x'' l⋘r l''⋘r'' (lemma≈≃ l≈l' (lemma≃≈ l'≃r' (sym≈ r≈r'))) l''≃r'' (lemma≈≃ l≈l' l'≃l'')\n\n lemma≃≈ : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}{h'' : BBHeap b''} → h ≃ h' → h' ≈ h'' → h ≃ h''\n lemma≃≈ ≃lf ≈leaf = ≃lf\n lemma≃≈ (≃nd b≤x b'≤x' l⋘r l'⋘r' l≃r l'≃r' l≃l') (≈left .b'≤x' b''≤x'' .l'⋘r' l''⋘r'' l'≈l'' r'≈r'') = ≃nd b≤x b''≤x'' l⋘r l''⋘r'' l≃r (lemma≈≃ (sym≈ l'≈l'') (lemma≃≈ l'≃r' r'≈r'')) (lemma≃≈ l≃l' l'≈l'')\n\nlemma≈⋗ : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}{h'' : BBHeap b''} → h ≈ h' → h' ⋗ h'' → h ⋗ h''\nlemma≈⋗ (≈left b≤x .b'≤x' lf⋘ .lf⋘ ≈leaf ≈leaf) (⋗lf b'≤x') = ⋗lf b≤x\nlemma≈⋗ (≈left b≤x .b'≤x' l⋘r .l'⋘r' l≈l' r≈r') (⋗nd b'≤x' b''≤x'' l'⋘r' l''⋘r'' l'≃r' l''≃r'' l'⋗l'') = ⋗nd b≤x b''≤x'' l⋘r l''⋘r'' (lemma≈≃ l≈l' (lemma≃≈ l'≃r' (sym≈ r≈r'))) l''≃r'' (lemma≈⋗ l≈l' l'⋗l'')\n\nlemma⋗≈ : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}{h'' : BBHeap b''} → h ⋗ h' → h' ≈ h'' → h ⋗ h''\nlemma⋗≈ (⋗lf b≤x) ≈leaf = ⋗lf b≤x\nlemma⋗≈ (⋗nd b≤x b'≤x' l⋘r l'⋘r' l≃r l'≃r' l⋗l') (≈left .b'≤x' b''≤x'' .l'⋘r' l''⋘r'' l'≈l'' r'≈r'') = ⋗nd b≤x b''≤x'' l⋘r l''⋘r'' l≃r (lemma≈≃ (sym≈ l'≈l'') (lemma≃≈ l'≃r' r'≈r'')) (lemma⋗≈ l⋗l' l'≈l'')\n\nlemma≈⋘ : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}{h'' : BBHeap b''} → h ≈ h' → h' ⋘ h'' → h ⋘ h''\nlemma≈⋘ ≈leaf lf⋘ = lf⋘\nlemma≈⋘ (≈left b≤x b'≤x' l⋘r l'⋘r' l≈l' r≈r') (ll⋘ .b'≤x' b''≤x'' .l'⋘r' l''⋘r'' l''≃r'' r'≃l'') = ll⋘ b≤x b''≤x'' l⋘r l''⋘r'' l''≃r'' (lemma≈≃ r≈r' r'≃l'')\nlemma≈⋘ (≈right b≤x b'≤x' l⋙r l'⋙r' l≈l' r≈r') (lr⋘ .b'≤x' b''≤x'' .l'⋙r' l''⋘r'' l''≃r'' l'⋗l'') = lr⋘ b≤x b''≤x'' l⋙r l''⋘r'' l''≃r'' (lemma≈⋗ l≈l' l'⋗l'')\n\nlemma⋘≈ : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}{h'' : BBHeap b''} → h ⋘ h' → h' ≈ h'' → h ⋘ h''\nlemma⋘≈ lf⋘ ≈leaf = lf⋘\nlemma⋘≈ (ll⋘ b≤x b'≤x' l⋘r l'⋘r' l'≃r' r≃l') (≈left .b'≤x' b''≤x'' .l'⋘r' l''⋘r'' l'≈l'' r'≈r'') = ll⋘ b≤x b''≤x'' l⋘r l''⋘r'' (lemma≈≃ (sym≈ l'≈l'') (lemma≃≈ l'≃r' r'≈r'')) (lemma≃≈ r≃l' l'≈l'')\nlemma⋘≈ (lr⋘ b≤x b'≤x' l⋙r l'⋘r' l'≃r' l⋗l') (≈left .b'≤x' b''≤x'' .l'⋘r' l''⋘r'' l'≈l'' r'≈r'') = lr⋘ b≤x b''≤x'' l⋙r l''⋘r'' (lemma≈≃ (sym≈ l'≈l'') (lemma≃≈ l'≃r' r'≈r'')) (lemma⋗≈ l⋗l' l'≈l'')\n\nlemma≈⋙ : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}{h'' : BBHeap b''} → h ≈ h' → h' ⋙ h'' → h ⋙ h''\nlemma≈⋙ (≈left b≤x b'≤x' lf⋘ lf⋘ ≈leaf ≈leaf) (⋙lf .b'≤x') = ⋙lf b≤x\nlemma≈⋙ (≈left b≤x b'≤x' l⋘r l'⋘r' l≈l' r≈r') (⋙rl .b'≤x' b'≤x'' .l'⋘r' l'≃r' l''⋘r'' l'⋗r'') = ⋙rl b≤x b'≤x'' l⋘r (lemma≈≃ l≈l' (lemma≃≈ l'≃r' (sym≈ r≈r'))) l''⋘r'' (lemma≈⋗ l≈l' l'⋗r'')\nlemma≈⋙ (≈left b≤x b'≤x' l⋘r l'⋘r' l≈l' r≈r') (⋙rr .b'≤x' b''≤x'' .l'⋘r' l'≃r' l''⋙r'' l'≃l'') = ⋙rr b≤x b''≤x'' l⋘r (lemma≈≃ l≈l' (lemma≃≈ l'≃r' (sym≈ r≈r'))) l''⋙r'' (lemma≈≃ l≈l' l'≃l'')\n\nlemma⋙≈ : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}{h'' : BBHeap b''} → h ⋙ h' → h' ≈ h'' → h ⋙ h''\nlemma⋙≈ (⋙lf b≤x) ≈leaf = ⋙lf b≤x\nlemma⋙≈ (⋙rl b≤x b'≤x' l⋘r l≃r l'⋘r' l⋗r') (≈left .b'≤x' b'≤x'' .l'⋘r' l''⋘r'' l'≈l'' r'≈r'') = ⋙rl b≤x b'≤x'' l⋘r l≃r l''⋘r'' (lemma⋗≈ l⋗r' r'≈r'')\nlemma⋙≈ (⋙rr b≤x b'≤x' l⋘r l≃r l'⋙r' l≃l') (≈right .b'≤x' b''≤x'' .l'⋙r' l'⋙r'' l'≈l'' r'≈r'') = ⋙rr b≤x b''≤x'' l⋘r l≃r l'⋙r'' (lemma≃≈ l≃l' l'≈l'')\n", "meta": {"hexsha": "74d10e5b7f4cda336effda1878f140bb2aafc95a", "size": 4529, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/BBHeap/Equality/Properties.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/BBHeap/Equality/Properties.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/BBHeap/Equality/Properties.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 75.4833333333, "max_line_length": 207, "alphanum_fraction": 0.4173106646, "num_tokens": 3415, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094060543488, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.644739989594834}} {"text": "\nmodule Oscar.Class.ThickAndThin where\n\nopen import Oscar.Data.Fin\nopen import Oscar.Data.Equality\nopen import Oscar.Data.Nat\nopen import Oscar.Data.Maybe\n\nrecord ThickAndThin {a} (A : Nat → Set a) : Set a where\n field\n thin : ∀ {m} → Fin (suc m) → A m → A (suc m)\n thin-injective : ∀ {m} (x : Fin (suc m)) {y₁ y₂ : A m} → thin x y₁ ≡ thin x y₂ → y₁ ≡ y₂\n thick : ∀ {m} → A (suc m) → Fin m → A m\n thick∘thin=id : ∀ {m} (x : Fin m) (y : A m) → thick (thin (suc x) y) x ≡ y\n check : ∀ {m} → Fin (suc m) → A (suc m) → Maybe (A m)\n thin-check-id : ∀ {m} (x : Fin (suc m)) y → ∀ y' → thin x y' ≡ y → check x y ≡ just y'\n\nopen ThickAndThin ⦃ … ⦄ public\n\n-- open import Oscar.Level\n\n-- record ThickAndThin' {a} {A : Set a} (f : A → A) {b} (B : A → Set b) (g : ∀ {x} → B x → B (f x)) {c} (C : A → Set c) : Set (a ⊔ b ⊔ c) where\n-- field\n-- thin : ∀ {n} → B (f n) → C n → C (f n)\n-- thick : ∀ {n} → C (f n) → B n → C n\n-- thin-injective : ∀ {n} (z : B (f n)) {x y : C n} → thin z x ≡ thin z y → x ≡ y\n-- thick∘thin=id : ∀ {n} (x : B n) (y : C n) → thick (thin (g x) y) x ≡ y\n-- check : ∀ {n} → B (f n) → C (f n) → Maybe (C n)\n-- thin-check-id : ∀ {n} (x : B (f n)) y → ∀ y' → thin x y' ≡ y → check x y ≡ just y'\n\n-- --open ThickAndThin' ⦃ … ⦄ public\n", "meta": {"hexsha": "5f9b6cbdf5380036f85813e0d90f6600b8d791bd", "size": 1286, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-2/Oscar/Class/ThickAndThin.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-2/Oscar/Class/ThickAndThin.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-2/Oscar/Class/ThickAndThin.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.1875, "max_line_length": 143, "alphanum_fraction": 0.4906687403, "num_tokens": 558, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314738181875, "lm_q2_score": 0.7279754489059775, "lm_q1q2_score": 0.6447179697180575}} {"text": "------------------------------------------------------------------------------\n-- FOTC natural numbers\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOTC.Data.Nat where\n\nopen import FOTC.Base\nopen import FOTC.Data.Nat.Type public\n\ninfixl 7 _*_\ninfixl 6 _+_ _∸_\n\n------------------------------------------------------------------------------\n-- Arithmetic operations\n\npostulate\n _+_ : D → D → D\n +-0x : ∀ n → zero + n ≡ n\n +-Sx : ∀ m n → succ₁ m + n ≡ succ₁ (m + n)\n{-# ATP axioms +-0x +-Sx #-}\n\npostulate\n _∸_ : D → D → D\n ∸-x0 : ∀ n → n ∸ zero ≡ n\n ∸-xS : ∀ m n → m ∸ succ₁ n ≡ pred₁ (m ∸ n)\n{-# ATP axioms ∸-x0 ∸-xS #-}\n\npostulate\n _*_ : D → D → D\n *-0x : ∀ n → zero * n ≡ zero\n *-Sx : ∀ m n → succ₁ m * n ≡ n + m * n\n{-# ATP axioms *-0x *-Sx #-}\n", "meta": {"hexsha": "9833a9c97e759aa8583d960e9e1a85f7690b611b", "size": 990, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/FOTC/Data/Nat.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/FOTC/Data/Nat.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/FOTC/Data/Nat.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 26.0526315789, "max_line_length": 78, "alphanum_fraction": 0.3737373737, "num_tokens": 303, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314647623016, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.6447179683522997}} {"text": "module Data.Num.Digit where\n\nopen import Data.Nat\nopen import Data.Nat.Properties\nopen import Data.Nat.Properties.Simple\nopen import Data.Nat.Properties.Extra\nopen import Data.Fin as Fin\n using (Fin; fromℕ≤; inject≤; toℕ; zero; suc)\nopen import Data.Fin.Properties as FinProps using (bounded; toℕ-fromℕ≤)\n\nopen import Function\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary\nopen import Relation.Nullary.Negation\nopen import Relation.Binary\n\nopen ≡-Reasoning\nopen ≤-Reasoning renaming (begin_ to start_; _∎ to _□; _≡⟨_⟩_ to _≈⟨_⟩_)\nopen DecTotalOrder decTotalOrder using (reflexive) renaming (refl to ≤-refl)\n\n\n--------------------------------------------------------------------------------\n-- Digits\n--------------------------------------------------------------------------------\n\nDigit : ℕ → Set\nDigit = Fin\n\n-- converting to and from ℕ\nDigit-toℕ : ∀ {d} → Digit d → ℕ → ℕ\nDigit-toℕ x o = toℕ x + o\n\nDigit-fromℕ : ∀ {d} → (n o : ℕ) → d + o ≥ n → Digit (suc d)\nDigit-fromℕ {d} n o upper-bound with n ∸ o ≤? d\nDigit-fromℕ {d} n o upper-bound | yes p = fromℕ≤ (s≤s p)\nDigit-fromℕ {d} n o upper-bound | no ¬p = contradiction p ¬p\n where p : n ∸ o ≤ d\n p = start\n n ∸ o\n ≤⟨ ∸n-mono o upper-bound ⟩\n (d + o) ∸ o\n ≈⟨ m+n∸n≡m d o ⟩\n d\n □\n\nDigit-fromℕ-toℕ : ∀ {d o}\n → (n : ℕ)\n → (lower-bound : o ≤ n)\n → (upper-bound : d + o ≥ n)\n → Digit-toℕ (Digit-fromℕ {d} n o upper-bound) o ≡ n\nDigit-fromℕ-toℕ {d} {o} n lb ub with n ∸ o ≤? d\nDigit-fromℕ-toℕ {d} {o} n lb ub | yes q =\n begin\n toℕ (fromℕ≤ (s≤s q)) + o\n ≡⟨ cong (λ x → x + o) (toℕ-fromℕ≤ (s≤s q)) ⟩\n n ∸ o + o\n ≡⟨ m∸n+n≡m lb ⟩\n n\n ∎\nDigit-fromℕ-toℕ {d} {o} n lb ub | no ¬q = contradiction q ¬q\n where q : n ∸ o ≤ d\n q = +n-mono-inverse o $\n start\n n ∸ o + o\n ≈⟨ m∸n+n≡m lb ⟩\n n\n ≤⟨ ub ⟩\n d + o\n □\n\n--------------------------------------------------------------------------------\n-- Properties of all Digits\n--------------------------------------------------------------------------------\n\nDigit-upper-bound : ∀ {d} → (o : ℕ) → (x : Digit d) → Digit-toℕ x o < d + o\nDigit-upper-bound {d} o x = +n-mono o (bounded x)\n\nDigit-lower-bound : ∀ {d} → (o : ℕ) → (x : Digit d) → Digit-toℕ x o ≥ o\nDigit-lower-bound {d} o x = n≤m+n (toℕ x) o\n\n--------------------------------------------------------------------------------\n-- Special Digits\n--------------------------------------------------------------------------------\n\n-- A digit at its greatest\nGreatest : ∀ {d} (x : Digit d) → Set\nGreatest {d} x = suc (toℕ x) ≡ d\n\nGreatest? : ∀ {d} (x : Digit d) → Dec (Greatest x)\nGreatest? {d} x = suc (toℕ x) ≟ d\n\ngreatest-digit : ∀ d → Digit (suc d)\ngreatest-digit d = Fin.fromℕ d\n\ngreatest-digit-toℕ : ∀ {d o}\n → (x : Digit (suc d))\n → Greatest x\n → Digit-toℕ x o ≡ d + o\ngreatest-digit-toℕ {d} {o} x greatest = cancel-suc $\n begin\n suc (Digit-toℕ x o)\n ≡⟨ cong (λ w → w + o) greatest ⟩\n suc (d + o)\n ∎\n\ngreatest-of-all : ∀ {d} (o : ℕ) → (x y : Digit d) → Greatest x → Digit-toℕ x o ≥ Digit-toℕ y o\ngreatest-of-all o zero zero refl = ≤-refl\ngreatest-of-all o zero (suc ()) refl\ngreatest-of-all o (suc x) zero greatest = +n-mono o {zero} {suc (toℕ x)} z≤n\ngreatest-of-all o (suc x) (suc y) greatest = s≤s (greatest-of-all o x y (cancel-suc greatest))\n\ngreatest-digit-is-the-Greatest : ∀ d → Greatest (greatest-digit d)\ngreatest-digit-is-the-Greatest d = cong suc (FinProps.to-from d)\n\n-- carry, 1 `max` o, in case that the least digit \"o\" is 0\ncarry : ℕ → ℕ\ncarry o = 1 ⊔ o\n\ncarry-lower-bound : ∀ {o} → carry o ≥ o\ncarry-lower-bound {o} = m≤n⊔m o 1\n\ncarry-upper-bound : ∀ {d o} → 2 ≤ suc d + o → carry o ≤ d + o\ncarry-upper-bound {d} {zero} proper = ≤-pred proper\ncarry-upper-bound {d} {suc o} proper = n≤m+n d (suc o)\n\ncarry-digit : ∀ d o → 2 ≤ suc d + o → Digit (suc d)\ncarry-digit d o proper = Digit-fromℕ (carry o) o (carry-upper-bound {d} proper)\n\ncarry-digit-toℕ : ∀ d o\n → (proper : 2 ≤ suc (d + o))\n → Digit-toℕ (carry-digit d o proper) o ≡ carry o\ncarry-digit-toℕ d o proper = Digit-fromℕ-toℕ (carry o) (m≤n⊔m o 1) (carry-upper-bound {d} proper)\n\n\n-- LCD-upper-bound-prim d zero proper = ≤-pred proper\n-- LCD-upper-bound-prim d (suc o) proper = n≤m+n (suc o) d\n--\n-- LCD : ∀ d o → 2 ≤ suc d + o → Digit (suc d)\n-- LCD d o proper = Digit-fromℕ (1 ⊔ o) o (LCD-upper-bound-prim d o proper)\n--\n-- LCD-toℕ : ∀ d o\n-- → (proper : 2 ≤ suc (d + o))\n-- → Digit-toℕ (LCD d o proper) o ≡ 1 ⊔ o\n-- LCD-toℕ d o proper = Digit-fromℕ-toℕ (1 ⊔ o) (m≤n⊔m o 1) (LCD-upper-bound-prim d o proper)\n--\n-- LCD-upper-bound : ∀ {d o}\n-- → (proper : 2 ≤ suc (d + o))\n-- → Digit-toℕ (LCD d o proper) o ≤ d + o\n-- LCD-upper-bound {d} {o} proper =\n-- start\n-- Digit-toℕ (LCD d o proper) o\n-- ≈⟨ LCD-toℕ d o proper ⟩\n-- 1 ⊔ o\n-- ≤⟨ LCD-upper-bound-prim d o proper ⟩\n-- d + o\n-- □\n\n--------------------------------------------------------------------------------\n-- Functions on Digits\n--------------------------------------------------------------------------------\n\n-- +1\ndigit+1 : ∀ {d} → (x : Digit d) → (¬greatest : ¬ (Greatest x)) → Fin d\ndigit+1 x ¬greatest = fromℕ≤ {suc (toℕ x)} (≤∧≢⇒< (bounded x) ¬greatest)\n\ndigit+1-toℕ : ∀ {d o}\n → (x : Digit d)\n → (¬greatest : ¬ (Greatest x))\n → Digit-toℕ (digit+1 x ¬greatest) o ≡ suc (Digit-toℕ x o)\ndigit+1-toℕ {d} {o} x ¬greatest =\n begin\n Digit-toℕ (digit+1 x ¬greatest) o\n ≡⟨ cong (λ w → w + o) (toℕ-fromℕ≤ (≤∧≢⇒< (bounded x) ¬greatest)) ⟩\n suc (Digit-toℕ x o)\n ∎\n\ndigit+1-n-lemma : ∀ {d}\n → (x : Digit d)\n → Greatest x\n → (n : ℕ)\n → n > 0\n → suc (toℕ x) ∸ n < d\ndigit+1-n-lemma {zero } () greatest n n>0\ndigit+1-n-lemma {suc d} x greatest n n>0 = s≤s $ start\n suc (toℕ x) ∸ n\n ≤⟨ ∸n-mono n (bounded x) ⟩\n suc d ∸ n\n ≤⟨ n∸-mono (suc d) n>0 ⟩\n suc d ∸ 1\n ≤⟨ ≤-refl ⟩\n d\n □\n\n\n-- +1 and then -n, useful for handling carrying on increment\ndigit+1-n : ∀ {d}\n → (x : Digit d)\n → Greatest x\n → (n : ℕ)\n → n > 0\n → Digit d\ndigit+1-n x greatest n n>0 = fromℕ≤ (digit+1-n-lemma x greatest n n>0)\n\ndigit+1-n-toℕ : ∀ {d o}\n → (x : Digit d)\n → (greatest : Greatest x)\n → (n : ℕ)\n → (n>0 : n > 0)\n → n ≤ d\n → Digit-toℕ (digit+1-n x greatest n n>0) o ≡ suc (Digit-toℕ x o) ∸ n\ndigit+1-n-toℕ {zero} {o} () greatest n n>0 n≤d\ndigit+1-n-toℕ {suc d} {o} x greatest n n>0 n≤d =\n begin\n toℕ (digit+1-n x greatest n n>0) + o\n ≡⟨ cong (λ w → w + o) (toℕ-fromℕ≤ (digit+1-n-lemma x greatest n n>0)) ⟩\n suc (toℕ x) ∸ n + o\n ≡⟨ +-comm (suc (toℕ x) ∸ n) o ⟩\n o + (suc (toℕ x) ∸ n)\n ≡⟨ sym (+-∸-assoc o {suc (toℕ x)} {n} $\n start\n n\n ≤⟨ n≤d ⟩\n suc d\n ≈⟨ sym greatest ⟩\n suc (toℕ x)\n □)\n ⟩\n (o + suc (toℕ x)) ∸ n\n ≡⟨ cong (λ w → w ∸ n) (+-comm o (suc (toℕ x))) ⟩\n suc (toℕ x) + o ∸ n\n ∎\n", "meta": {"hexsha": "d2f4b2fdbc50e7486b9d54bfc4e2322b6f800bed", "size": 7208, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Num/Digit.agda", "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_issues_repo_path": "Data/Num/Digit.agda", "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Num/Digit.agda", "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "avg_line_length": 31.0689655172, "max_line_length": 97, "alphanum_fraction": 0.4750277469, "num_tokens": 2699, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.885631476836816, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.64471796668884}} {"text": "\n-- Isomorphism of indexed families\nmodule SOAS.Families.Isomorphism {T} where\n\nopen import SOAS.Common\nopen import SOAS.Context {T}\nopen import SOAS.Families.Core {T}\n\nopen import Categories.Morphism 𝔽amilies public using ()\n renaming ( _≅_ to _≅ₘ_ ; module ≅ to ≅ₘ ; ≅-setoid to ≅ₘ-setoid)\n\n-- Isomorphism between two families\nrecord FamIso (X Y : Family) : Set where\n\n -- Prove isomorphism of the families X and Y in the category 𝔽am from\n -- a proof of isomorphism of the sets X Γ and Y Γ for all contexts Γ.\n field iso : (Γ : Ctx) → X Γ ≅ₛ Y Γ\n\n -- Two directions of the isomorphism.\n iso⇒ : X ⇾ Y\n iso⇒ {Γ} = _≅ₛ_.from (iso Γ)\n iso⇐ : Y ⇾ X\n iso⇐ {Γ} = _≅ₛ_.to (iso Γ)\n\n -- Construct the isomorphism of families\n ≅ₘ : X ≅ₘ Y\n ≅ₘ = record\n { from = iso⇒\n ; to = iso⇐\n ; iso = record\n { isoˡ = λ {Γ}{x} → _≅ₛ_.isoˡ (iso Γ)\n ; isoʳ = λ {Γ}{x} → _≅ₛ_.isoʳ (iso Γ)\n }\n }\n\n≅ₘ→FamIso : {X Y : Family} → X ≅ₘ Y → FamIso X Y\n≅ₘ→FamIso p = record { iso = λ Γ → record\n { from = _≅ₘ_.from p\n ; to = _≅ₘ_.to p\n ; iso = record { isoˡ = _≅ₘ_.isoˡ p ; isoʳ = _≅ₘ_.isoʳ p }\n } }\n\n-- | Isomorphism of sorted families\n\nopen import Categories.Morphism 𝔽amiliesₛ public\n using () renaming ( _≅_ to _≅̣ₘ_ ; module ≅ to ≅̣ₘ)\n\n-- Sorted family isomorphism gives a family isomorphism at each sort\n≅̣ₘ→≅ₘ : {τ : T}{𝒳 𝒴 : Familyₛ} → 𝒳 ≅̣ₘ 𝒴 → 𝒳 τ ≅ₘ 𝒴 τ\n≅̣ₘ→≅ₘ {τ} p = record { from = _≅̣ₘ_.from p ; to = _≅̣ₘ_.to p\n ; iso = record { isoˡ = _≅̣ₘ_.isoˡ p ; isoʳ = _≅̣ₘ_.isoʳ p } }\n\n-- Family isomorphism at each sort gives sorted family isomorphism\n≅ₘ→≅̣ₘ : {𝒳 𝒴 : Familyₛ} → ({τ : T} → 𝒳 τ ≅ₘ 𝒴 τ) → 𝒳 ≅̣ₘ 𝒴\n≅ₘ→≅̣ₘ p = record { from = _≅ₘ_.from p ; to = _≅ₘ_.to p\n ; iso = record { isoˡ = _≅ₘ_.isoˡ p ; isoʳ = _≅ₘ_.isoʳ p } }\n", "meta": {"hexsha": "8b36c7f8da193d376790466aa9e558b2f97187bb", "size": 1792, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "SOAS/Families/Isomorphism.agda", "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_issues_repo_path": "SOAS/Families/Isomorphism.agda", "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_forks_repo_path": "SOAS/Families/Isomorphism.agda", "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "avg_line_length": 31.4385964912, "max_line_length": 83, "alphanum_fraction": 0.5831473214, "num_tokens": 834, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8856314677809303, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.6447179600963775}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule sets.int.core where\n\nopen import sum\nopen import equality\nopen import function\nimport sets.nat as N\nopen N using (ℕ; suc)\nopen import sets.int.definition\nopen import sets.int.utils\nopen import sets.vec\nopen import hott.level.closure\n\ninfixl 7 _*_\ninfixl 6 _+_\n\nfrom-nat : ℕ → ℤ\nfrom-nat n = n [-] 0\n\nzero : ℤ\nzero = from-nat 0\n\none : ℤ\none = from-nat 1\n\nprivate\n module _ where\n open N\n\n add : ℕ → ℕ → ℕ → ℕ → ℤ\n add n n' m m' = (n + m) [-] (n' + m')\n\n add-sound : (n n' d m m' e : ℕ)\n → add n n' m m'\n ≡ add (d + n) (d + n') (e + m) (e + m')\n add-sound n n' d m m' e\n = eq-ℤ (n + m) (n' + m') (d + e)\n · ap₂ _[-]_ (solve 4 (exp λ d e n m → d :+ e :+ (n :+ m))\n (exp λ d e n m → d :+ n :+ (e :+ m))\n (d ∷∷ e ∷∷ n ∷∷ m ∷∷ ⟦⟧))\n (solve 4 (exp λ d e n m → d :+ e :+ (n :+ m))\n (exp λ d e n m → d :+ n :+ (e :+ m))\n (d ∷∷ e ∷∷ n' ∷∷ m' ∷∷ ⟦⟧))\n\n mul : ℕ → ℕ → ℕ → ℕ → ℤ\n mul n n' m m' = (n * m + n' * m') [-] (n' * m + n * m')\n\n mul-sound : (n n' d m m' e : ℕ)\n → mul n n' m m'\n ≡ mul (d + n) (d + n') (e + m) (e + m')\n mul-sound n n' d m m' e\n = eq-ℤ (n * m + n' * m') (n' * m + n * m')\n (d * e + d * m + n * e + d * e + d * m' + n' * e)\n · ap₂ _[-]_ lem₁ lem₂\n where\n distr₂ : ∀ a b c d\n → (a + b) * (c + d)\n ≡ a * c + a * d + b * c + b * d\n distr₂ a b c d = right-distr a b (c + d)\n · ap₂ _+_ (left-distr a c d) (left-distr b c d)\n · sym (+-associativity (a * c + a * d) (b * c) (b * d))\n\n lem₁ : d * e + d * m + n * e + d * e + d * m' + n' * e + (n * m + n' * m')\n ≡ (d + n) * (e + m) + (d + n') * (e + m')\n lem₁ = sym\n $ ap₂ _+_ (distr₂ d n e m) (distr₂ d n' e m')\n · solve 7 (exp λ a b c d e f g → a :+ b :+ c :+ d :+ (a :+ e :+ f :+ g))\n (exp λ a b c d e f g → a :+ b :+ c :+ a :+ e :+ f :+ (d :+ g))\n ((d * e) ∷∷ (d * m) ∷∷ (n * e) ∷∷ (n * m) ∷∷\n (d * m') ∷∷ (n' * e) ∷∷ (n' * m') ∷∷ ⟦⟧)\n\n lem₂ : d * e + d * m + n * e + d * e + d * m' + n' * e + (n' * m + n * m')\n ≡ (d + n') * (e + m) + (d + n) * (e + m')\n lem₂ = sym\n $ ap₂ _+_ (distr₂ d n' e m) (distr₂ d n e m')\n · solve 7 (exp λ a b c d e f g → a :+ b :+ c :+ d :+ (a :+ e :+ f :+ g))\n (exp λ a b c d e f g → a :+ b :+ f :+ a :+ e :+ c :+ (d :+ g))\n ((d * e) ∷∷ (d * m) ∷∷ (n' * e) ∷∷ (n' * m) ∷∷\n (d * m') ∷∷ (n * e) ∷∷ (n * m') ∷∷ ⟦⟧)\n\n neg : ℕ → ℕ → ℤ\n neg n n' = n' [-] n\n\n neg-sound : (n n' d : ℕ) → neg n n' ≡ neg (d + n) (d + n')\n neg-sound n n' d = eq-ℤ n' n d\n\n_+_ : ℤ → ℤ → ℤ\n_+_ = elim₂-ℤ hℤ add add-sound\n\nnegate : ℤ → ℤ\nnegate = elim-ℤ hℤ (neg , neg-sound)\n\ninc : ℤ → ℤ\ninc n = one + n\n\ndec : ℤ → ℤ\ndec n = negate one + n\n\n_*_ : ℤ → ℤ → ℤ\n_*_ = elim₂-ℤ hℤ mul mul-sound\n", "meta": {"hexsha": "931bc735e31ece43c60f1e92ce4c10e73adc47a5", "size": 3155, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/sets/int/core.agda", "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 20, "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_issues_repo_path": "src/sets/int/core.agda", "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_forks_repo_path": "src/sets/int/core.agda", "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "avg_line_length": 30.931372549, "max_line_length": 87, "alphanum_fraction": 0.3375594295, "num_tokens": 1375, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314738181875, "lm_q2_score": 0.7279754371026367, "lm_q1q2_score": 0.6447179592646474}} {"text": "{-# OPTIONS --cubical --safe #-}\nmodule Cubical.HITs.FiniteMultiset.Properties where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\n\nopen import Cubical.HITs.FiniteMultiset.Base\n\nprivate\n variable\n A : Type₀\n\ninfixr 30 _++_\n\n_++_ : ∀ (xs ys : FMSet A) → FMSet A\n[] ++ ys = ys\n(x ∷ xs) ++ ys = x ∷ xs ++ ys\ncomm x y xs i ++ ys = comm x y (xs ++ ys) i\ntrunc xs zs p q i j ++ ys =\n trunc (xs ++ ys) (zs ++ ys) (cong (_++ ys) p) (cong (_++ ys) q) i j\n\nunitl-++ : ∀ (xs : FMSet A) → [] ++ xs ≡ xs\nunitl-++ xs = refl\n\nunitr-++ : ∀ (xs : FMSet A) → xs ++ [] ≡ xs\nunitr-++ = FMSetElimProp.f (trunc _ _)\n refl\n (λ x p → cong (_∷_ x) p)\n\nassoc-++ : ∀ (xs ys zs : FMSet A) → xs ++ (ys ++ zs) ≡ (xs ++ ys) ++ zs\nassoc-++ = FMSetElimProp.f (propPi (λ _ → propPi (λ _ → trunc _ _)))\n (λ ys zs → refl)\n (λ x p ys zs → cong (_∷_ x) (p ys zs))\n\ncons-++ : ∀ (x : A) (xs : FMSet A) → x ∷ xs ≡ xs ++ [ x ]\ncons-++ x = FMSetElimProp.f (trunc _ _)\n refl\n (λ y {xs} p → comm x y xs ∙ cong (_∷_ y) p)\n\ncomm-++ : ∀ (xs ys : FMSet A) → xs ++ ys ≡ ys ++ xs\ncomm-++ = FMSetElimProp.f (propPi (λ _ → trunc _ _))\n (λ ys → sym (unitr-++ ys))\n (λ x {xs} p ys → cong (x ∷_) (p ys)\n ∙ cong (_++ xs) (cons-++ x ys)\n ∙ sym (assoc-++ ys [ x ] xs))\n\nmodule FMSetUniversal {ℓ} {M : Type ℓ} (MSet : isSet M)\n (e : M) (_⊗_ : M → M → M)\n (comm-⊗ : ∀ x y → x ⊗ y ≡ y ⊗ x) (assoc-⊗ : ∀ x y z → x ⊗ (y ⊗ z) ≡ (x ⊗ y) ⊗ z)\n (unit-⊗ : ∀ x → e ⊗ x ≡ x)\n (f : A → M) where\n\n f-extend : FMSet A → M\n f-extend = FMSetRec.f MSet e (λ x m → f x ⊗ m)\n (λ x y m → comm-⊗ (f x) (f y ⊗ m) ∙ sym (assoc-⊗ (f y) m (f x)) ∙ cong (f y ⊗_) (comm-⊗ m (f x)))\n\n f-extend-nil : f-extend [] ≡ e\n f-extend-nil = refl\n\n f-extend-cons : ∀ x xs → f-extend (x ∷ xs) ≡ f x ⊗ f-extend xs\n f-extend-cons x xs = refl\n\n f-extend-sing : ∀ x → f-extend [ x ] ≡ f x\n f-extend-sing x = comm-⊗ (f x) e ∙ unit-⊗ (f x)\n\n f-extend-++ : ∀ xs ys → f-extend (xs ++ ys) ≡ f-extend xs ⊗ f-extend ys\n f-extend-++ = FMSetElimProp.f (propPi λ _ → MSet _ _)\n (λ ys → sym (unit-⊗ (f-extend ys)))\n (λ x {xs} p ys → cong (f x ⊗_) (p ys) ∙ assoc-⊗ (f x) (f-extend xs) (f-extend ys))\n\n module _ (h : FMSet A → M) (h-nil : h [] ≡ e) (h-sing : ∀ x → h [ x ] ≡ f x)\n (h-++ : ∀ xs ys → h (xs ++ ys) ≡ h xs ⊗ h ys) where\n\n f-extend-unique : h ≡ f-extend\n f-extend-unique = funExt (FMSetElimProp.f (MSet _ _)\n h-nil\n (λ x {xs} p → (h-++ [ x ] xs) ∙ cong (_⊗ h xs) (h-sing x) ∙ cong (f x ⊗_) p))\n", "meta": {"hexsha": "b9f6f14863e3c6d434f9b613edc58d74814dd532", "size": 2573, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/FiniteMultiset/Properties.agda", "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/HITs/FiniteMultiset/Properties.agda", "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/HITs/FiniteMultiset/Properties.agda", "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.9871794872, "max_line_length": 107, "alphanum_fraction": 0.486202876, "num_tokens": 1122, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673087708699, "lm_q2_score": 0.7931059609645723, "lm_q1q2_score": 0.6446899080594065}} {"text": "module GGT.Bundles where\n\nopen import Level\nopen import Relation.Unary\nopen import Relation.Binary -- using (Rel)\nopen import Algebra.Core\nopen import Algebra.Bundles\nopen import GGT.Structures\nopen import Data.Product\n-- do we need a left action definition?\n-- parametrize over Op r/l?\n\nrecord Action a b ℓ₁ ℓ₂ : Set (suc (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂)) where\n infixl 6 _·_\n infix 3 _≋_\n open Group hiding (setoid)\n field\n G : Group a ℓ₁\n Ω : Set b\n _≋_ : Rel Ω ℓ₂\n _·_ : Opᵣ (Carrier G) Ω\n isAction : IsAction (_≈_ G) _≋_ _·_ (_∙_ G) (ε G) (_⁻¹ G)\n\n open IsAction isAction public\n\n -- the (raw) pointwise stabilizer\n stab : Ω → Pred (Carrier G) ℓ₂\n stab o = λ (g : Carrier G) → o · g ≋ o\n\n -- Orbital relation\n _ω_ : Rel Ω (a ⊔ ℓ₂)\n o ω o' = ∃[ g ] (o · g ≋ o')\n\n _·G : Ω → Pred Ω (a ⊔ ℓ₂)\n o ·G = o ω_\n\n -- Orbits\n open import GGT.Setoid setoid (a ⊔ ℓ₂)\n Orbit : Ω → Setoid (b ⊔ (a ⊔ ℓ₂)) ℓ₂\n Orbit o = subSetoid (o ·G)\n", "meta": {"hexsha": "eefc85226d1c645c106702f105e59817a795a19e", "size": 944, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/ggt/Bundles.agda", "max_stars_repo_name": "zampino/ggt", "max_stars_repo_head_hexsha": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-04-17T11:10:00.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-28T05:48:39.000Z", "max_issues_repo_path": "src/ggt/Bundles.agda", "max_issues_repo_name": "zampino/ggt", "max_issues_repo_head_hexsha": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/ggt/Bundles.agda", "max_forks_repo_name": "zampino/ggt", "max_forks_repo_head_hexsha": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.0243902439, "max_line_length": 61, "alphanum_fraction": 0.6122881356, "num_tokens": 389, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9219218434359676, "lm_q2_score": 0.6992544210587586, "lm_q1q2_score": 0.644657924893241}} {"text": "{-\n\nDefinition of finite sets\n\nA set is finite if it is merely equivalent to `Fin n` for some `n`. We\ncan translate this to code in two ways: a truncated sigma of a nat and\nan equivalence, or a sigma of a nat and a truncated equivalence. We\nprove that both formulations are equivalent.\n\n-}\n\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nmodule Cubical.Data.FinSet where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Logic\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.Structure\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Univalence\nopen import Cubical.Foundations.Equiv\nopen import Cubical.HITs.PropositionalTruncation\nopen import Cubical.Data.Unit\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Fin\nopen import Cubical.Data.Sigma\n\nprivate\n variable\n ℓ : Level\n A : Type ℓ\n\nisFinSet : Type ℓ → Type ℓ\nisFinSet A = ∃[ n ∈ ℕ ] A ≃ Fin n\n\nisProp-isFinSet : isProp (isFinSet A)\nisProp-isFinSet = propTruncIsProp\n\nFinSet : Type (ℓ-suc ℓ)\nFinSet = TypeWithStr _ isFinSet\n\nisFinSetFin : ∀ {n} → isFinSet (Fin n)\nisFinSetFin = ∣ _ , pathToEquiv refl ∣\n\nisFinSetUnit : isFinSet Unit\nisFinSetUnit = ∣ 1 , Unit≃Fin1 ∣\n\nisFinSetΣ : Type ℓ → Type ℓ\nisFinSetΣ A = Σ[ n ∈ ℕ ] ∥ A ≃ Fin n ∥\n\nFinSetΣ : Type (ℓ-suc ℓ)\nFinSetΣ = TypeWithStr _ isFinSetΣ\n\nisProp-isFinSetΣ : isProp (isFinSetΣ A)\nisProp-isFinSetΣ {A = A} (n , equivn) (m , equivm) =\n Σ≡Prop (λ _ → propTruncIsProp) n≡m\n where\n Fin-n≃Fin-m : ∥ Fin n ≃ Fin m ∥\n Fin-n≃Fin-m = rec\n propTruncIsProp\n (rec\n (isPropΠ λ _ → propTruncIsProp)\n (λ hm hn → ∣ Fin n ≃⟨ invEquiv hn ⟩ A ≃⟨ hm ⟩ Fin m ■ ∣)\n equivm\n )\n equivn\n\n Fin-n≡Fin-m : ∥ Fin n ≡ Fin m ∥\n Fin-n≡Fin-m = rec propTruncIsProp (∣_∣ ∘ ua) Fin-n≃Fin-m\n\n ∥n≡m∥ : ∥ n ≡ m ∥\n ∥n≡m∥ = rec propTruncIsProp (∣_∣ ∘ Fin-inj n m) Fin-n≡Fin-m\n\n n≡m : n ≡ m\n n≡m = rec (isSetℕ n m) (λ p → p) ∥n≡m∥\n\nisFinSet≡isFinSetΣ : isFinSet A ≡ isFinSetΣ A\nisFinSet≡isFinSetΣ {A = A} = hPropExt isProp-isFinSet isProp-isFinSetΣ to from\n where\n to : isFinSet A → isFinSetΣ A\n to ∣ n , equiv ∣ = n , ∣ equiv ∣\n to (squash p q i) = isProp-isFinSetΣ (to p) (to q) i\n\n from : isFinSetΣ A → isFinSet A\n from (n , ∣ isFinSet-A ∣) = ∣ n , isFinSet-A ∣\n from (n , squash p q i) = isProp-isFinSet (from (n , p)) (from (n , q)) i\n\nFinSet≡FinSetΣ : FinSet {ℓ} ≡ FinSetΣ\nFinSet≡FinSetΣ = ua (isoToEquiv (iso to from to-from from-to))\n where\n to : FinSet → FinSetΣ\n to (A , isFinSetA) = A , transport isFinSet≡isFinSetΣ isFinSetA\n\n from : FinSetΣ → FinSet\n from (A , isFinSetΣA) = A , transport (sym isFinSet≡isFinSetΣ) isFinSetΣA\n\n to-from : ∀ A → to (from A) ≡ A\n to-from A = Σ≡Prop (λ _ → isProp-isFinSetΣ) refl\n\n from-to : ∀ A → from (to A) ≡ A\n from-to A = Σ≡Prop (λ _ → isProp-isFinSet) refl\n\ncard : FinSet {ℓ} → ℕ\ncard = fst ∘ snd ∘ transport FinSet≡FinSetΣ\n", "meta": {"hexsha": "791a2cc10ebf0337972f6f334602feab6cc108c1", "size": 2943, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/FinSet.agda", "max_stars_repo_name": "knrafto/cubical", "max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/FinSet.agda", "max_issues_repo_name": "knrafto/cubical", "max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Data/FinSet.agda", "max_forks_repo_name": "knrafto/cubical", "max_forks_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.7641509434, "max_line_length": 78, "alphanum_fraction": 0.6568127761, "num_tokens": 1181, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152324983301568, "lm_q2_score": 0.7905303211371898, "lm_q1q2_score": 0.6444660087064124}} {"text": "------------------------------------------------------------------------\n-- Some derivable properties\n------------------------------------------------------------------------\n\nopen import Algebra\n\nmodule Algebra.Props.Ring (r : Ring) where\n\nopen Ring r\nimport Relation.Binary.EqReasoning as EqR; open EqR setoid\nopen import Data.Function\nopen import Data.Product\n\n-‿*-distribˡ : ∀ x y → - x * y ≈ - (x * y)\n-‿*-distribˡ x y = begin\n - x * y ≈⟨ sym $ proj₂ +-identity _ ⟩\n - x * y + 0# ≈⟨ refl ⟨ +-pres-≈ ⟩ sym (proj₂ -‿inverse _) ⟩\n - x * y + (x * y + - (x * y)) ≈⟨ sym $ +-assoc _ _ _ ⟩\n - x * y + x * y + - (x * y) ≈⟨ sym (proj₂ distrib _ _ _) ⟨ +-pres-≈ ⟩ refl ⟩\n (- x + x) * y + - (x * y) ≈⟨ (proj₁ -‿inverse _ ⟨ *-pres-≈ ⟩ refl)\n ⟨ +-pres-≈ ⟩\n refl ⟩\n 0# * y + - (x * y) ≈⟨ proj₁ zero _ ⟨ +-pres-≈ ⟩ refl ⟩\n 0# + - (x * y) ≈⟨ proj₁ +-identity _ ⟩\n - (x * y) ∎\n\n-‿*-distribʳ : ∀ x y → x * - y ≈ - (x * y)\n-‿*-distribʳ x y = begin\n x * - y ≈⟨ sym $ proj₁ +-identity _ ⟩\n 0# + x * - y ≈⟨ sym (proj₁ -‿inverse _) ⟨ +-pres-≈ ⟩ refl ⟩\n - (x * y) + x * y + x * - y ≈⟨ +-assoc _ _ _ ⟩\n - (x * y) + (x * y + x * - y) ≈⟨ refl ⟨ +-pres-≈ ⟩ sym (proj₁ distrib _ _ _) ⟩\n - (x * y) + x * (y + - y) ≈⟨ refl ⟨ +-pres-≈ ⟩ (refl ⟨ *-pres-≈ ⟩ proj₂ -‿inverse _) ⟩\n - (x * y) + x * 0# ≈⟨ refl ⟨ +-pres-≈ ⟩ proj₂ zero _ ⟩\n - (x * y) + 0# ≈⟨ proj₂ +-identity _ ⟩\n - (x * y) ∎\n", "meta": {"hexsha": "4de1f3af998e6a211f94992e2cc7bd22a6308aae", "size": 1648, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Algebra/Props/Ring.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Algebra/Props/Ring.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Algebra/Props/Ring.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 44.5405405405, "max_line_length": 93, "alphanum_fraction": 0.3446601942, "num_tokens": 636, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026550642018, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.6444326926241138}} {"text": "open import Prelude\n\nmodule Nat where\n\n -- definitions\n\n data Nat : Set where\n Z : Nat\n 1+ : Nat → Nat\n\n {-# BUILTIN NATURAL Nat #-}\n\n _+_ : Nat → Nat → Nat\n Z + m = m\n 1+ n + m = 1+ (n + m)\n\n infixl 60 _+_\n\n data _≤_ : Nat → Nat → Set where\n ≤refl : ∀{n} → n ≤ n\n ≤1+ : ∀{n m} → n ≤ m → n ≤ 1+ m\n\n infix 40 _≤_\n\n _<_ : Nat → Nat → Set\n n < m = n ≤ m ∧ n ≠ m\n infix 40 _<_\n\n -- The `difference` operation accepts two numbers n and m and a proof that n ≤ m.\n -- Alternative definitions could return an option, returning None if n > m,\n -- or truncation, returning 0 if n > m. The latter may make some of the work easier,\n -- if it allows us to avoid issues with proof relevance. Even so, many proofs would\n -- still need to make use of the proof that n ≤ m to establish that the difference is\n -- not arbitrarily 0. As such, we believe that refactoring to use the perhaps more\n -- conventional truncation approach would not necessarily go far enough in cleaning up\n -- proofs as to be worth the refactoring effort.\n difference : ∀{n m} → n ≤ m → Nat\n difference {n} {.n} ≤refl = Z\n difference {n} {.(1+ _)} (≤1+ n≤m-1) = 1+ (difference n≤m-1)\n\n -- basic theorems\n\n -- the succ operation is injective\n 1+inj : ∀{n m} → 1+ n == 1+ m → n == m\n 1+inj refl = refl\n\n 1+ap : ∀{n m} → n == m → 1+ n == 1+ m\n 1+ap {n} {.n} refl = refl\n\n 1+ap-cp : ∀{n m} → 1+ n ≠ 1+ m → n ≠ m\n 1+ap-cp h1 h2 = h1 (1+ap h2)\n\n 1+inj-cp : ∀{n m} → n ≠ m → 1+ n ≠ 1+ m\n 1+inj-cp h1 h2 = h1 (1+inj h2)\n\n -- equality of naturals is decidable. we represent this as computing a\n -- choice of units, with inl <> meaning that the naturals are indeed the\n -- same and inr <> that they are not.\n natEQ : (x y : Nat) → ((x == y) ∨ ((x == y) → ⊥))\n natEQ Z Z = Inl refl\n natEQ Z (1+ y) = Inr (λ ())\n natEQ (1+ x) Z = Inr (λ ())\n natEQ (1+ x) (1+ y) with natEQ x y\n natEQ (1+ x) (1+ .x) | Inl refl = Inl refl\n ... | Inr b = Inr (λ x₁ → b (1+inj x₁))\n\n 0≠1+n : ∀{n} → 0 ≠ 1+ n\n 0≠1+n = λ ()\n\n -- _+_ theorems\n\n n+Z==n : ∀{n} → n + Z == n\n n+Z==n {Z} = refl\n n+Z==n {1+ n} = 1+ap n+Z==n\n\n n+1+m==1+n+m : ∀{n m} → n + 1+ m == 1+ (n + m)\n n+1+m==1+n+m {Z} = refl\n n+1+m==1+n+m {1+ n} = 1+ap n+1+m==1+n+m\n\n n≠n+1+m : ∀{n m} → n ≠ n + 1+ m\n n≠n+1+m {Z} {m} ()\n n≠n+1+m {1+ n} {m} h = 1+inj-cp n≠n+1+m h\n\n +comm : ∀{a b} → a + b == b + a\n +comm {Z} {b} = ! n+Z==n\n +comm {1+ a} {Z} = 1+ap n+Z==n\n +comm {1+ a} {1+ b} with a + 1+ b | b + 1+ a | n+1+m==1+n+m {a} {b} | n+1+m==1+n+m {b} {a}\n +comm {1+ a} {1+ b} | _ | _ | refl | refl = 1+ap (1+ap (+comm {a}))\n\n +assc : ∀{a b c} → (a + b) + c == a + (b + c)\n +assc {Z} = refl\n +assc {1+ a} = 1+ap (+assc {a})\n\n a+n==a+m→n==m : ∀{a n m} → a + n == a + m → n == m\n a+n==a+m→n==m {Z} refl = refl\n a+n==a+m→n==m {1+ a} a+n==a+m = a+n==a+m→n==m (1+inj a+n==a+m)\n\n n+a==m+a→n==m : ∀{n m a} → n + a == m + a → n == m\n n+a==m+a→n==m {n} {m} {a} n+a==m+a rewrite +comm {n} {a} | +comm {m} {a} = a+n==a+m→n==m n+a==m+a\n\n +inj : ∀{a1 a2 b} → a1 + b == a2 + b → a1 == a2\n +inj {a1} {a2} {Z} h\n rewrite (n+Z==n {a1}) | (n+Z==n {a2}) = h\n +inj {a1} {a2} {1+ b} h\n rewrite n+1+m==1+n+m {a1} {b} | n+1+m==1+n+m {a2} {b} = +inj (1+inj h)\n\n +inj-cp : ∀{a1 a2 b} → a1 ≠ a2 → a1 + b ≠ a2 + b\n +inj-cp ne f = ne (+inj f)\n\n -- even/odd theorems\n\n even-inj : ∀{m n} → m + m == n + n → m == n\n even-inj {Z} {Z} eq = refl\n even-inj {1+ m} {1+ n} eq rewrite (n+1+m==1+n+m {n} {n}) | (n+1+m==1+n+m {m} {m})\n = 1+ap (even-inj (1+inj (1+inj eq)))\n\n even-not-odd : ∀{m n} → 1+ (m + m) ≠ (n + n)\n even-not-odd {Z} {1+ n} eq rewrite (n+1+m==1+n+m {n} {n}) = 0≠1+n (1+inj eq)\n even-not-odd {1+ m} {1+ n} eq rewrite (n+1+m==1+n+m {n} {n}) | (n+1+m==1+n+m {m} {m})\n = even-not-odd {m} {n} (1+inj (1+inj eq))\n\n -- _≤_ theorems\n\n 0≤n : ∀{n} → Z ≤ n\n 0≤n {Z} = ≤refl\n 0≤n {1+ n} = ≤1+ 0≤n\n\n 1+n≰0 : ∀{n} → 1+ n ≤ Z → ⊥\n 1+n≰0 = λ ()\n\n n≤m→1+n≤1+m : ∀{n m} → n ≤ m → 1+ n ≤ 1+ m\n n≤m→1+n≤1+m {n} {.n} ≤refl = ≤refl\n n≤m→1+n≤1+m {n} {.(1+ _)} (≤1+ h) = ≤1+ (n≤m→1+n≤1+m h)\n\n n≤m→s+n=m : ∀{n m} → n ≤ m → Σ[ s ∈ Nat ] (s + n == m)\n n≤m→s+n=m ≤refl = Z , refl\n n≤m→s+n=m (≤1+ n≤m)\n with n≤m→s+n=m n≤m\n ... | _ , refl = _ , refl\n\n 1+n≤1+m→n≤m : ∀{n m} → 1+ n ≤ 1+ m → n ≤ m\n 1+n≤1+m→n≤m {n} {.n} ≤refl = ≤refl\n 1+n≤1+m→n≤m {n} {Z} (≤1+ h) = abort (1+n≰0 h)\n 1+n≤1+m→n≤m {n} {1+ m} (≤1+ h) = ≤1+ (1+n≤1+m→n≤m h)\n\n n+s≤m+s→n≤m : ∀{n m s} → n + s ≤ m + s → n ≤ m\n n+s≤m+s→n≤m {n} {m} {s = Z} n+s≤m+s\n rewrite n+Z==n {n} | n+Z==n {m} = n+s≤m+s\n n+s≤m+s→n≤m {n} {m} {s = 1+ s} n+s≤m+s\n rewrite n+1+m==1+n+m {n} {s} | n+1+m==1+n+m {m} {s}\n = n+s≤m+s→n≤m (1+n≤1+m→n≤m n+s≤m+s)\n\n 1+n≰n : ∀{n} → 1+ n ≤ n → ⊥\n 1+n≰n {Z} h = abort (1+n≰0 h)\n 1+n≰n {1+ n} h = 1+n≰n (1+n≤1+m→n≤m h)\n\n ≤total : ∀{n m} → n ≤ m ∨ m ≤ n\n ≤total {Z} {m} = Inl 0≤n\n ≤total {1+ n} {Z} = Inr (≤1+ 0≤n)\n ≤total {1+ n} {1+ m} with ≤total {n} {m}\n ≤total {1+ n} {1+ m} | Inl h = Inl (n≤m→1+n≤1+m h)\n ≤total {1+ n} {1+ m} | Inr h = Inr (n≤m→1+n≤1+m h)\n\n ≤trans : ∀{a b c} → a ≤ b → b ≤ c → a ≤ c\n ≤trans ≤refl b≤c = b≤c\n ≤trans (≤1+ a≤b) ≤refl = ≤1+ a≤b\n ≤trans (≤1+ a≤b) (≤1+ b≤c) = ≤1+ (≤trans (≤1+ a≤b) b≤c)\n\n ≤antisym : ∀{n m} → n ≤ m → m ≤ n → n == m\n ≤antisym {n} {.n} ≤refl m≤n = refl\n ≤antisym {n} {.(1+ _)} (≤1+ h1) h2 = abort (1+n≰n (≤trans h2 h1))\n\n n≤n+m : ∀{n m} → n ≤ n + m\n n≤n+m {n} {Z} with n + Z | n+Z==n {n}\n n≤n+m {_} {Z} | _ | refl = ≤refl\n n≤n+m {n} {1+ m} with n + 1+ m | ! (n+1+m==1+n+m {n} {m})\n n≤n+m {n} {1+ m} | _ | refl = ≤trans n≤n+m (≤1+ ≤refl)\n\n n≤m+n : ∀{n m} → n ≤ m + n\n n≤m+n {n} {m} rewrite +comm {m} {n} = n≤n+m\n\n -- _<_ theorems\n\n n≮0 : ∀{n} → n < Z → ⊥\n n≮0 {Z} (π3 , π4) = π4 refl\n n≮0 {1+ n} (π3 , π4) = 1+n≰0 π3\n\n n<1+n : ∀{n} → n < 1+ n\n π1 n<1+n = ≤1+ ≤refl\n π2 n<1+n ()\n\n 1+n<1+m→n Carrier -> Carrier\n _∙_ : Field.Carrier K -> Carrier -> Carrier\n -_ : Carrier -> Carrier\n 0# : Carrier\n\n rawGroup : RawGroup c ℓ\n rawGroup = record { _≈_ = _≈_; _∙_ = _+_; ε = 0#; _⁻¹ = -_ }\n\n open RawGroup rawGroup public\n using (rawMagma; rawMonoid)\n\nrecord VectorSpace {k ℓᵏ} (K : Field k ℓᵏ) (c ℓ : Level) : Set (suc (c ⊔ k ⊔ ℓ ⊔ ℓᵏ)) where\n infix 20 _≈_\n infixl 25 _+_\n infixr 30 _∙_\n\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ\n _+_ : Carrier -> Carrier -> Carrier\n _∙_ : Field.Carrier K -> Carrier -> Carrier\n -_ : Carrier -> Carrier\n 0# : Carrier\n isVectorSpace : IsVectorSpace K _≈_ _+_ _∙_ -_ 0#\n\n open IsVectorSpace isVectorSpace public\n\n rawVectorSpace : RawVectorSpace K c ℓ\n rawVectorSpace = record\n { _≈_ = _≈_; _+_ = _+_; _∙_ = _∙_; -_ = -_; 0# = 0# }\n\n abelianGroup : AbelianGroup c ℓ\n abelianGroup = record { isAbelianGroup = isAbelianGroup }\n\n open AbelianGroup abelianGroup public\n using (rawMagma; magma; rawMonoid; monoid; rawGroup; group)\n", "meta": {"hexsha": "cd552e34c0b1a00772c73950f69b73b8542bb216", "size": 1718, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Algebra/Linear/Structures/Bundles.agda", "max_stars_repo_name": "felko/linear-algebra", "max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z", "max_issues_repo_path": "src/Algebra/Linear/Structures/Bundles.agda", "max_issues_repo_name": "felko/linear-algebra", "max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Algebra/Linear/Structures/Bundles.agda", "max_forks_repo_name": "felko/linear-algebra", "max_forks_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.6206896552, "max_line_length": 91, "alphanum_fraction": 0.6146682189, "num_tokens": 581, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357598021707, "lm_q2_score": 0.7431680086124811, "lm_q1q2_score": 0.6443532390079887}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Some derivable properties\n------------------------------------------------------------------------\n\nopen import Algebra\n\nmodule Algebra.Properties.Lattice {l₁ l₂} (L : Lattice l₁ l₂) where\n\nopen Lattice L\nopen import Algebra.Structures\nimport Algebra.FunctionProperties as P; open P _≈_\nopen import Relation.Binary\nimport Relation.Binary.EqReasoning as EqR; open EqR setoid\nopen import Function\nopen import Function.Equality using (_⟨$⟩_)\nopen import Function.Equivalence using (_⇔_; module Equivalence)\nopen import Data.Product\n\n∧-idempotent : Idempotent _∧_\n∧-idempotent x = begin\n x ∧ x ≈⟨ refl ⟨ ∧-cong ⟩ sym (proj₁ absorptive _ _) ⟩\n x ∧ (x ∨ x ∧ x) ≈⟨ proj₂ absorptive _ _ ⟩\n x ∎\n\n∨-idempotent : Idempotent _∨_\n∨-idempotent x = begin\n x ∨ x ≈⟨ refl ⟨ ∨-cong ⟩ sym (∧-idempotent _) ⟩\n x ∨ x ∧ x ≈⟨ proj₁ absorptive _ _ ⟩\n x ∎\n\n-- The dual construction is also a lattice.\n\n∧-∨-isLattice : IsLattice _≈_ _∧_ _∨_\n∧-∨-isLattice = record\n { isEquivalence = isEquivalence\n ; ∨-comm = ∧-comm\n ; ∨-assoc = ∧-assoc\n ; ∨-cong = ∧-cong\n ; ∧-comm = ∨-comm\n ; ∧-assoc = ∨-assoc\n ; ∧-cong = ∨-cong\n ; absorptive = swap absorptive\n }\n\n∧-∨-lattice : Lattice _ _\n∧-∨-lattice = record\n { _∧_ = _∨_\n ; _∨_ = _∧_\n ; isLattice = ∧-∨-isLattice\n }\n\n-- Every lattice can be turned into a poset.\n\nposet : Poset _ _ _\nposet = record\n { Carrier = Carrier\n ; _≈_ = _≈_\n ; _≤_ = λ x y → x ≈ x ∧ y\n ; isPartialOrder = record\n { isPreorder = record\n { isEquivalence = isEquivalence\n ; reflexive = λ {i} {j} i≈j → begin\n i ≈⟨ sym $ ∧-idempotent _ ⟩\n i ∧ i ≈⟨ ∧-cong refl i≈j ⟩\n i ∧ j ∎\n ; trans = λ {i} {j} {k} i≈i∧j j≈j∧k → begin\n i ≈⟨ i≈i∧j ⟩\n i ∧ j ≈⟨ ∧-cong refl j≈j∧k ⟩\n i ∧ (j ∧ k) ≈⟨ sym (∧-assoc _ _ _) ⟩\n (i ∧ j) ∧ k ≈⟨ ∧-cong (sym i≈i∧j) refl ⟩\n i ∧ k ∎\n }\n ; antisym = λ {x} {y} x≈x∧y y≈y∧x → begin\n x ≈⟨ x≈x∧y ⟩\n x ∧ y ≈⟨ ∧-comm _ _ ⟩\n y ∧ x ≈⟨ sym y≈y∧x ⟩\n y ∎\n }\n }\n\n-- One can replace the underlying equality with an equivalent one.\n\nreplace-equality : {_≈′_ : Rel Carrier l₂} →\n (∀ {x y} → x ≈ y ⇔ x ≈′ y) → Lattice _ _\nreplace-equality {_≈′_} ≈⇔≈′ = record\n { _≈_ = _≈′_\n ; _∧_ = _∧_\n ; _∨_ = _∨_\n ; isLattice = record\n { isEquivalence = record\n { refl = to ⟨$⟩ refl\n ; sym = λ x≈y → to ⟨$⟩ sym (from ⟨$⟩ x≈y)\n ; trans = λ x≈y y≈z → to ⟨$⟩ trans (from ⟨$⟩ x≈y) (from ⟨$⟩ y≈z)\n }\n ; ∨-comm = λ x y → to ⟨$⟩ ∨-comm x y\n ; ∨-assoc = λ x y z → to ⟨$⟩ ∨-assoc x y z\n ; ∨-cong = λ x≈y u≈v → to ⟨$⟩ ∨-cong (from ⟨$⟩ x≈y) (from ⟨$⟩ u≈v)\n ; ∧-comm = λ x y → to ⟨$⟩ ∧-comm x y\n ; ∧-assoc = λ x y z → to ⟨$⟩ ∧-assoc x y z\n ; ∧-cong = λ x≈y u≈v → to ⟨$⟩ ∧-cong (from ⟨$⟩ x≈y) (from ⟨$⟩ u≈v)\n ; absorptive = (λ x y → to ⟨$⟩ proj₁ absorptive x y)\n , (λ x y → to ⟨$⟩ proj₂ absorptive x y)\n }\n } where open module E {x y} = Equivalence (≈⇔≈′ {x} {y})\n", "meta": {"hexsha": "13d039104419bf020adf0c94637845186e5f5e7a", "size": 3467, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Algebra/Properties/Lattice.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Algebra/Properties/Lattice.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Algebra/Properties/Lattice.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.4018691589, "max_line_length": 74, "alphanum_fraction": 0.4404384194, "num_tokens": 1347, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357460591569, "lm_q2_score": 0.743167997235783, "lm_q1q2_score": 0.6443532189306166}} {"text": "module Logic.IntroInstances where\n\nimport Data.Tuple as Tuple\nimport Lvl\nopen import Logic.Predicate\nopen import Logic.Propositional\nopen import Type\n\nprivate variable ℓ : Lvl.Level\nprivate variable A B Obj : Type{ℓ}\nprivate variable P : Obj → Type{ℓ}\nprivate variable x : Obj\n\ninstance\n [∧]-intro-instance : ⦃ _ : A ⦄ → ⦃ _ : B ⦄ → (A ∧ B)\n [∧]-intro-instance ⦃ a ⦄ ⦃ b ⦄ = [∧]-intro a b\n\ninstance\n [∨]-introₗ-instance : ⦃ _ : A ⦄ → (A ∨ B)\n [∨]-introₗ-instance ⦃ a ⦄ = [∨]-introₗ a\n\ninstance\n [∨]-introᵣ-instance : ⦃ _ : B ⦄ → (A ∨ B)\n [∨]-introᵣ-instance ⦃ b ⦄ = [∨]-introᵣ b\n\ninstance\n [∃]-intro-instance : ⦃ _ : P(x) ⦄ → ∃(P)\n [∃]-intro-instance {x = x} ⦃ proof ⦄ = [∃]-intro (x) ⦃ proof ⦄\n", "meta": {"hexsha": "50976c29b6da15636c5b9aa2f84f0f7f64e6a4d1", "size": 713, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Logic/IntroInstances.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Logic/IntroInstances.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Logic/IntroInstances.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.5862068966, "max_line_length": 64, "alphanum_fraction": 0.5890603086, "num_tokens": 312, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9046505325302034, "lm_q2_score": 0.7122321781307375, "lm_q1q2_score": 0.6443212192311184}} {"text": "module MLib.Finite where\n\nopen import MLib.Prelude\nimport MLib.Fin.Parts as P\nimport MLib.Fin.Parts.Simple as PS\nopen import MLib.Prelude.RelProps\n\nopen import Data.List.All as All using (All; []; _∷_) hiding (module All)\nopen import Data.List.Any as Any using (Any; here; there) hiding (module Any)\nimport Data.List.Membership.Setoid as Membership\nimport Data.List.Membership.Propositional as PropMembership\n\nimport Relation.Binary.Indexed as I\nimport Relation.Unary as U using (Decidable)\nopen LeftInverse using () renaming (_∘_ to _ⁱ∘_)\nopen FE using (_⇨_; cong)\nopen import Function.Related using () renaming (module EquationalReasoning to RelReasoning)\n\nimport Data.Product.Relation.SigmaPropositional as OverΣ\n\nopen Algebra using (IdempotentCommutativeMonoid)\n\n--------------------------------------------------------------------------------\n-- Main Definition\n--------------------------------------------------------------------------------\n\nrecord IsFiniteSetoid {c ℓ} (setoid : Setoid c ℓ) (N : ℕ) : Set (c ⊔ˡ ℓ) where\n open Setoid setoid public\n open Setoid setoid using () renaming (Carrier to A)\n\n OntoFin : ℕ → Set _\n OntoFin N = LeftInverse setoid (≡.setoid (Fin N))\n\n field\n ontoFin : OntoFin N\n\n fromIx : Fin N → A\n fromIx i = LeftInverse.from ontoFin ⟨$⟩ i\n\n toIx : A → Fin N\n toIx x = LeftInverse.to ontoFin ⟨$⟩ x\n\n fromIx-toIx : ∀ x → fromIx (toIx x) ≈ x\n fromIx-toIx = LeftInverse.left-inverse-of ontoFin\n\n enumₜ : Table A N\n enumₜ = tabulate fromIx\n\n enumₗ : List A\n enumₗ = Table.toList enumₜ\n\n\nIsFiniteSet : ∀ {a} → Set a → ℕ → Set a\nIsFiniteSet = IsFiniteSetoid ∘ ≡.setoid\n\n\nrecord FiniteSet c ℓ : Set (sucˡ (c ⊔ˡ ℓ)) where\n field\n setoid : Setoid c ℓ\n N : ℕ\n isFiniteSetoid : IsFiniteSetoid setoid N\n\n open IsFiniteSetoid isFiniteSetoid public\n\n--------------------------------------------------------------------------------\n-- Combinators\n--------------------------------------------------------------------------------\n\n-- An enumerable setoid is finite\n\nmodule _ {c ℓ} (setoid : Setoid c ℓ) where\n open Setoid setoid\n open Membership setoid\n\n Any-cong : ∀ {xs} → (∀ x → x ∈ xs) → Set _\n Any-cong f = ∀ {x y} → x ≈ y → Any.index (f x) ≡ Any.index (f y)\n\n private\n from : ∀ xs → Fin (List.length xs) → Carrier\n from List.[] ()\n from (x List.∷ xs) Fin.zero = x\n from (x List.∷ xs) (Fin.suc i) = from xs i\n\n left-inverse-of : ∀ {xs} (f : ∀ x → x ∈ xs) x → from xs (Any.index (f x)) ≈ x\n left-inverse-of f x = go (f x)\n where\n go : ∀ {xs} (p : x ∈ xs) → from xs (Any.index p) ≈ x\n go (here px) = sym px\n go (there p) = go p\n\n enumerable-isFiniteSetoid : ∀ {xs} (f : ∀ x → x ∈ xs) → Any-cong f → IsFiniteSetoid setoid (List.length xs)\n enumerable-isFiniteSetoid {xs} f f-cong = record\n { ontoFin = record\n { to = record\n { _⟨$⟩_ = Any.index ∘ f\n ; cong = f-cong\n }\n ; from = ≡.→-to-⟶ (from xs)\n ; left-inverse-of = left-inverse-of f\n }\n }\n\n\n-- As a special case of the previous theorem requiring fewer conditions, an\n-- enumerable set is finite.\n\nmodule _ {a} {A : Set a} where\n open PropMembership\n\n enumerable-isFiniteSet : (xs : List A) (f : ∀ x → x ∈ xs) → IsFiniteSet A (List.length xs)\n enumerable-isFiniteSet _ f = enumerable-isFiniteSetoid (≡.setoid _) f (≡.cong (Any.index ∘ f))\n\n\n-- Given a function with a left inverse from some 'A' to a finite set, 'A' must also be finite.\n\nextendedIsFinite : ∀ {c ℓ c′ ℓ′} {S : Setoid c ℓ} (F : FiniteSet c′ ℓ′) → LeftInverse S (FiniteSet.setoid F) → IsFiniteSetoid S (FiniteSet.N F)\nextendedIsFinite finiteSet ontoF = record\n { ontoFin = ontoFin ⁱ∘ ontoF\n }\n where\n open FiniteSet finiteSet using (ontoFin)\n\nextendFinite : ∀ {c ℓ c′ ℓ′} {S : Setoid c ℓ} (F : FiniteSet c′ ℓ′) → LeftInverse S (FiniteSet.setoid F) → FiniteSet c ℓ\nextendFinite finiteSet ontoF = record\n { isFiniteSetoid = extendedIsFinite finiteSet ontoF\n }\n\nmodule _ {c ℓ c′ ℓ′} {S : Setoid c ℓ} (F : FiniteSet c′ ℓ′) where\n\n extendedIsFinite′N : (¬ Setoid.Carrier S) ⊎ LeftInverse S (FiniteSet.setoid F) → ℕ\n extendedIsFinite′N (inj₁ x) = 0\n extendedIsFinite′N (inj₂ y) = FiniteSet.N F\n\n extendedIsFinite′ : (inj : (¬ Setoid.Carrier S) ⊎ LeftInverse S (FiniteSet.setoid F)) → IsFiniteSetoid S (extendedIsFinite′N inj)\n extendedIsFinite′ (inj₂ f) = extendedIsFinite F f\n extendedIsFinite′ (inj₁ p) = record\n { ontoFin = record\n { to = record { _⟨$⟩_ = ⊥-elim ∘ p ; cong = λ {i} → ⊥-elim (p i) }\n ; from = ≡.→-to-⟶ λ ()\n ; left-inverse-of = ⊥-elim ∘ p\n }\n }\n\n\n-- Given a family of finite sets, indexed by a finite set, the sum over the entire family is finite.\n\nmodule _ {c} {A : Set c} {N} (isFiniteSet : IsFiniteSet A N) where\n private\n finiteSet : FiniteSet c c\n finiteSet = record { isFiniteSetoid = isFiniteSet }\n module F = FiniteSet finiteSet\n\n Σᶠ : ∀ {p} → (A → Set p) → Set p\n Σᶠ P = ∃ (P ∘ lookup F.enumₜ)\n\n module _ {p ℓ} (finiteAt : A → FiniteSet p ℓ) where\n private\n module PW x = FiniteSet (finiteAt x)\n open PW using () renaming (Carrier to P)\n\n parts : P.Parts A PW.N\n parts = record\n { numParts = N\n ; parts = F.enumₜ\n }\n\n open P.Parts parts hiding (parts)\n\n Σ-isFiniteSetoid : IsFiniteSetoid (OverΣ.setoid PW.setoid) totalSize\n Σ-isFiniteSetoid = record\n { ontoFin\n = Inverse.left-inverse (Inverse.sym asParts)\n ⁱ∘ intoCoords\n ⁱ∘ Σ-↞′ {B-setoid = PW.setoid} F.ontoFin\n }\n where\n P-setoidᶠ : Fin N → Setoid _ _\n P-setoidᶠ i = record\n { Carrier = P (F.fromIx i)\n ; _≈_ = PW._≈_ _\n ; isEquivalence = record\n { refl = PW.refl _\n ; sym = PW.sym _\n ; trans = PW.trans _\n }\n }\n\n ΣᶠP-setoid = OverΣ.setoid P-setoidᶠ\n\n open Setoid ΣᶠP-setoid using ()\n renaming (_≈_ to _≈ᶠ_)\n\n to : Σᶠ P → Σ (Fin N) (Fin ∘ sizeAt)\n to (_ , px) = _ , PW.toIx _ px\n\n to-cong : ∀ {x y} → x ≈ᶠ y → to x ≡ to y\n to-cong (≡.refl , q) = OverΣ.to-≡ (≡.refl , cong (LeftInverse.to (PW.ontoFin _)) q)\n\n from : Σ (Fin N) (Fin ∘ sizeAt) → Σᶠ P\n from (i , j) = _ , PW.fromIx _ j\n\n left-inverse-of : ∀ x → from (to x) ≈ᶠ x\n left-inverse-of (i , x) = ≡.refl , PW.fromIx-toIx _ _\n\n intoCoords : LeftInverse ΣᶠP-setoid (≡.setoid (Σ (Fin N) (Fin ∘ sizeAt)))\n intoCoords = record\n { to = record { _⟨$⟩_ = to ; cong = to-cong }\n ; from = ≡.→-to-⟶ from\n ; left-inverse-of = left-inverse-of\n }\n\n Σ-finiteSet : FiniteSet _ _\n Σ-finiteSet = record { isFiniteSetoid = Σ-isFiniteSetoid }\n\nmodule All′ {a} {A : Set a} where\n module _ {p ℓ} (setoid : A → Setoid p ℓ) where\n module P′ x = Setoid (setoid x)\n module P′′ {x} = P′ x\n open P′ using () renaming (Carrier to P)\n open P′′ using (_≈_)\n\n data PW : {xs : List A} → All P xs → All P xs → Set (p ⊔ˡ ℓ) where\n [] : PW [] []\n _∷_ : ∀ {x xs} {px py : P x} {apx apy : All P xs} → px ≈ py → PW apx apy → PW (px ∷ apx) (py ∷ apy)\n\n PW-setoid : List A → Setoid _ _\n Setoid.Carrier (PW-setoid xs) = All P xs\n Setoid._≈_ (PW-setoid xs) = PW\n IsEquivalence.refl (Setoid.isEquivalence (PW-setoid .[])) {[]} = []\n IsEquivalence.refl (Setoid.isEquivalence (PW-setoid .(_ ∷ _))) {px ∷ ap} =\n P′′.refl ∷ IsEquivalence.refl (Setoid.isEquivalence (PW-setoid _))\n IsEquivalence.sym (Setoid.isEquivalence (PW-setoid .[])) [] = []\n IsEquivalence.sym (Setoid.isEquivalence (PW-setoid .(_ ∷ _))) (p ∷ q) =\n P′′.sym p ∷ IsEquivalence.sym (Setoid.isEquivalence (PW-setoid _)) q\n IsEquivalence.trans (Setoid.isEquivalence (PW-setoid .[])) [] [] = []\n IsEquivalence.trans (Setoid.isEquivalence (PW-setoid .(_ ∷ _))) (p ∷ q) (p′ ∷ q′) =\n P′′.trans p p′ ∷ IsEquivalence.trans (Setoid.isEquivalence (PW-setoid _)) q q′\n\n\n module _ {p} (P : A → Set p) where\n PW-≡ : ∀ {xs} {apx apy : All P xs} → PW (≡.setoid ∘ P) apx apy → apx ≡ apy\n PW-≡ [] = ≡.refl\n PW-≡ (p ∷ q) = ≡.cong₂ _∷_ p (PW-≡ q)\n\n-- module _ {c ℓ} (finiteSet : FiniteSet c ℓ) where\n-- private\n-- module A = FiniteSet finiteSet\n\n-- open A using (_≈_) renaming (Carrier to A)\n\n-- open IsFiniteSetoid\n-- open LeftInverse\n\n-- private\n-- boolToFin : Bool → Fin 2\n-- boolToFin false = Fin.zero\n-- boolToFin true = Fin.suc Fin.zero\n\n-- open Nat using (_^_; _+_; _*_)\n\n-- _ℕ+_ : ∀ {n} (m : ℕ) → Fin n → Fin (m + n)\n-- zero ℕ+ i = i\n-- suc m ℕ+ i = Fin.suc (m ℕ+ i)\n\n-- -- ℕ*-+ m \"i\" \"k\" = \"i + m * k\"\n-- ℕ*-+′ : ∀ {n} (m : ℕ) → Fin m → Fin n → Fin (n * m)\n-- ℕ*-+′ {zero} m i ()\n-- ℕ*-+′ {suc n} m i Fin.zero = Fin.inject+ (n * m) i\n-- ℕ*-+′ {suc n} m i (Fin.suc k) = m ℕ+ (ℕ*-+′ m i k)\n\n-- -- ℕ*-+ m \"i\" \"k\" = \"i + m * k\"\n-- ℕ*-+ : ∀ {n} m → Fin m → Fin n → Fin (m * n)\n-- ℕ*-+ m i k = ≡.subst Fin (Nat.*-comm _ m) (ℕ*-+′ m i k)\n\n-- from-n-ary : ∀ {n m} → Table (Fin n) m → Fin (n ^ m)\n-- from-n-ary {m = zero} _ = Fin.zero -- an empty table represents an empty n-ary string\n-- from-n-ary {n} {suc m} t = ℕ*-+ n (Table.lookup t Fin.zero) (from-n-ary (Table.tail t))\n\n-- from-n-ary-cong : ∀ {n m} (t t′ : Table (Fin n) m) → t Table.≗ t′ → from-n-ary t ≡ from-n-ary t′\n-- from-n-ary-cong {m = zero} t t′ eq = ≡.refl\n-- from-n-ary-cong {n} {suc m} t t′ eq = ≡.cong₂ (ℕ*-+ n) (eq Fin.zero) (from-n-ary-cong (Table.tail t) (Table.tail t′) (eq ∘ Fin.suc))\n\n-- -- div-rem m i = \"i % m\" , \"i / m\"\n-- div-rem : ∀ {n} m → Fin (m * n) → Fin m × Fin n\n-- div-rem zero ()\n-- div-rem {zero} (suc m) i with ≡.subst Fin (Nat.*-zeroʳ m) i\n-- div-rem {zero} (suc m) i | ()\n-- div-rem {suc n} (suc m) Fin.zero = Fin.zero , Fin.zero\n-- div-rem {suc n} (suc m) (Fin.suc i) = {!!}\n\n-- to-n-ary : ∀ {n m} → Fin (n ^ m) → Table (Fin n) m\n-- to-n-ary {m = zero} _ = tabulate λ ()\n-- to-n-ary {n} {suc m} k =\n-- let r , d = div-rem n k\n-- ind = to-n-ary {n} {m} d\n-- in tabulate λ\n-- { Fin.zero → r\n-- ; (Fin.suc i) → lookup ind i\n-- }\n\n-- boolF-isFiniteSetoid : IsFiniteSetoid (A.setoid ⇨ ≡.setoid Bool) (2 Nat.^ A.N)\n-- _⟨$⟩_ (to (ontoFin boolF-isFiniteSetoid)) f =\n-- let digits = Table.map (boolToFin ∘ (f ⟨$⟩_)) A.enumₜ\n-- in from-n-ary digits\n-- cong (to (ontoFin boolF-isFiniteSetoid)) {f} {f′} p =\n-- let t = Table.map (boolToFin ∘ (f ⟨$⟩_)) A.enumₜ\n-- in from-n-ary-cong t _ λ _ → ≡.cong boolToFin (p A.refl)\n-- _⟨$⟩_ (_⟨$⟩_ (from (ontoFin boolF-isFiniteSetoid)) i) x = {!!}\n-- cong (_⟨$⟩_ (from (ontoFin boolF-isFiniteSetoid)) i) = {!!}\n-- cong (from (ontoFin boolF-isFiniteSetoid)) ≡.refl = {!≡.cong ?!}\n-- left-inverse-of (ontoFin boolF-isFiniteSetoid) = {!!}\n\n-- module _ {c₁ ℓ₁ c₂ ℓ₂} (A-finiteSet : FiniteSet c₁ ℓ₁) (B-finiteSet : FiniteSet c₂ ℓ₂) where\n-- private\n-- module A = FiniteSet A-finiteSet\n-- module B = FiniteSet B-finiteSet\n\n-- open A using (_≈_) renaming (Carrier to A)\n-- open B using () renaming (Carrier to B; _≈_ to _≈′_)\n\n-- open IsFiniteSetoid\n-- open LeftInverse\n\n-- function-isFiniteSetoid : IsFiniteSetoid (A.setoid ⇨ B.setoid) (B.N Nat.^ A.N)\n-- _⟨$⟩_ (to (ontoFin function-isFiniteSetoid)) f = {!!}\n-- cong (to (ontoFin function-isFiniteSetoid)) = {!!}\n-- _⟨$⟩_ (from (ontoFin function-isFiniteSetoid)) i = {!!}\n-- cong (from (ontoFin function-isFiniteSetoid)) = {!!}\n-- left-inverse-of (ontoFin function-isFiniteSetoid) = {!!}\n\n-- TODO: Prove dependent function spaces with finite domain and codomain are\n-- finite sets, and recast as an instance of that.\n\nmodule _ {a p ℓ} {A : Set a} (finiteAt : A → FiniteSet p ℓ) where\n private\n module PW x = FiniteSet (finiteAt x)\n module PW′ {x} = PW x\n open PW using () renaming (Carrier to P; N to boundAt)\n open PW′ using (_≈_)\n\n All≈ = All′.PW PW.setoid\n All-setoid = All′.PW-setoid PW.setoid\n open All′.PW PW.setoid\n\n finiteAllSize : List A → ℕ\n finiteAllSize = List.product ∘ List.map boundAt\n\n All-isFiniteSetoid : (xs : List A) → IsFiniteSetoid (All-setoid xs) _\n All-isFiniteSetoid _ = record\n { ontoFin = record\n { to = record { _⟨$⟩_ = to ; cong = to-cong }\n ; from = ≡.→-to-⟶ from\n ; left-inverse-of = left-inverse-of\n }\n }\n where\n to : ∀ {xs} → All P xs → Fin (finiteAllSize xs)\n to [] = Fin.zero\n to (_∷_ {x} {xs} px ap) = PS.fromParts (PW.toIx _ px , to ap)\n\n to-cong : ∀ {xs}{apx apy : All P xs} → All≈ apx apy → to apx ≡ to apy\n to-cong [] = ≡.refl\n to-cong (p ∷ q) = ≡.cong₂ (curry PS.fromParts) (cong (LeftInverse.to PW′.ontoFin) p) (to-cong q)\n\n from : ∀ {xs} → Fin (finiteAllSize xs) → All P xs\n from {List.[]} _ = []\n from {x List.∷ xs} i =\n (PW.fromIx _ (proj₁ (PS.toParts i))) ∷\n from {xs} (proj₂ (PS.toParts {boundAt x} i))\n\n left-inverse-of : ∀ {xs} (ap : All P xs) → All≈ (from (to ap)) ap\n left-inverse-of [] = Setoid.refl (All-setoid _)\n left-inverse-of (px ∷ ap) rewrite Inverse.right-inverse-of PS.asParts (PW.toIx _ px , to ap) =\n PW′.fromIx-toIx px ∷ left-inverse-of ap\n\n All-finiteSet : List A → FiniteSet _ _\n All-finiteSet xs = record { isFiniteSetoid = All-isFiniteSetoid xs }\n\n\n1-Truncate : ∀ {c ℓ} (setoid : Setoid c ℓ) → Setoid _ _\n1-Truncate setoid = record\n { Carrier = Carrier\n ; _≈_ = λ _ _ → ⊤\n ; isEquivalence = record { refl = _ ; sym = _ ; trans = _ }\n }\n where open Setoid setoid\n\nmodule DecFinite {a p} {A : Set a} {P : A → Set p} (decP : U.Decidable P) where\n P-setoid : A → Setoid _ _\n P-setoid = 1-Truncate ∘ ≡.setoid ∘ P\n\n P-size : A → ℕ\n P-size x = if ⌊ decP x ⌋ then 1 else 0\n\n P-isFinite : ∀ x → IsFiniteSetoid (P-setoid x) (P-size x)\n P-isFinite x with decP x\n P-isFinite x | yes p = record\n { ontoFin = record\n { to = record\n { _⟨$⟩_ = λ _ → Fin.zero ; cong = λ _ → ≡.refl }\n ; from = ≡.→-to-⟶ λ _ → p\n ; left-inverse-of = _\n }\n }\n P-isFinite x | no ¬p = record\n { ontoFin = record\n { to = record { _⟨$⟩_ = ⊥-elim ∘ ¬p ; cong = λ {x} → ⊥-elim (¬p x) }\n ; from = ≡.→-to-⟶ λ ()\n ; left-inverse-of = _\n }\n }\n\n Decidable-finite : A → FiniteSet p _\n Decidable-finite x = record { isFiniteSetoid = P-isFinite x }\n\nmodule _ {c} {A : Set c} {N} (isFiniteSet : IsFiniteSet A N) {p} {P : A → Set p} (decP : U.Decidable P) where\n open IsFiniteSetoid isFiniteSet\n\n subsetFinite : FiniteSet _ _\n subsetFinite = Σ-finiteSet isFiniteSet (DecFinite.Decidable-finite decP)\n\n subset-isFiniteSet : ∀ {a′} {A′ : Set a′} → LeftInverse (≡.setoid A′) (FiniteSet.setoid subsetFinite) → IsFiniteSet A′ _\n subset-isFiniteSet = extendedIsFinite subsetFinite\n", "meta": {"hexsha": "a66072515c35affe17acc503378ed562dc83308b", "size": 14774, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/MLib/Finite.agda", "max_stars_repo_name": "bch29/agda-matrices", "max_stars_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/MLib/Finite.agda", "max_issues_repo_name": "bch29/agda-matrices", "max_issues_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/MLib/Finite.agda", "max_forks_repo_name": "bch29/agda-matrices", "max_forks_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.8443396226, "max_line_length": 143, "alphanum_fraction": 0.5649790172, "num_tokens": 5341, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8438951025545425, "lm_q2_score": 0.7634837689358857, "lm_q1q2_score": 0.6443002134848779}} {"text": "\nmodule Utils.NatOrdLemmas where\n\nopen import Data.Nat.Properties.Simple \nopen import Data.Nat\nopen import Data.Empty\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary\nopen import Function\n\n{- Just a bunch of lemmas about the standard ordering on naturals -}\n\ndata Cmp (a b : ℕ) : Set where\n LT : a Data.Nat.< b → Cmp a b\n EQ : a ≡ b → Cmp a b\n GT : a > b → Cmp a b\n\ncmp : ∀ a b → Cmp a b\ncmp zero zero = EQ refl\ncmp zero (suc b) = LT (s≤s z≤n)\ncmp (suc a) zero = GT (s≤s z≤n)\ncmp (suc a) (suc b) with cmp a b\ncmp (suc a) (suc b) | LT x = LT (s≤s x)\ncmp (suc a) (suc .a) | EQ refl = EQ refl\ncmp (suc a) (suc b) | GT x = GT (s≤s x)\n\na≮a : ∀ a → ¬ (a < a)\na≮a zero ()\na≮a (suc a) (s≤s p) = a≮a a p\n\n<-weakenr1 : ∀ a b → a < b → a < suc b\n<-weakenr1 zero b p = s≤s z≤n\n<-weakenr1 (suc a) zero ()\n<-weakenr1 (suc a) (suc b) (s≤s p) = s≤s (<-weakenr1 a b p)\n\n<-weakenr : ∀ c a b → a < b → a < c + b\n<-weakenr zero a b p = p\n<-weakenr (suc c) a b p = <-weakenr1 a (c + b) (<-weakenr c a b p)\n\n<-weakenl1 : ∀ a b → suc a < b → a < b\n<-weakenl1 zero ._ (s≤s p) = s≤s z≤n\n<-weakenl1 (suc a) zero ()\n<-weakenl1 (suc a) (suc b) (s≤s p) = s≤s (<-weakenl1 a b p)\n\n<-weakenl : ∀ c a b → c + a < b → a < b\n<-weakenl zero a b p = p\n<-weakenl (suc c) a b p = <-weakenl c a b (<-weakenl1 (c + a) b p)\n\na≢sa : (a : ℕ) → a ≢ suc a\na≢sa a ()\n\na ▫ <>) ⦄ where\n Unit-equiv : Equiv(Unit)\n Equiv._≡_ Unit-equiv = (_▫_)\n Reflexivity.proof (Equivalence.reflexivity (Equiv.equivalence Unit-equiv)) = proof\n Symmetry.proof (Equivalence.symmetry (Equiv.equivalence Unit-equiv)) _ = proof\n Transitivity.proof (Equivalence.transitivity (Equiv.equivalence Unit-equiv)) _ _ = proof\n\nmodule _ where\n open import Relator.Equals\n\n instance\n Empty-equiv : Equiv(Empty{ℓ})\n Empty-equiv = General.Empty-equiv {_▫_ = _≡_}\n\n instance\n Unit-equiv : Equiv(Unit{ℓ})\n Unit-equiv = General.Unit-equiv ⦃ [≡]-intro {x = <>} ⦄\n\n {- TODO: So, why is this unprovable but Unit-IsUnit is? UIP? What is the difference?\n module _ where\n open import Relator.Equals.Proofs.Equiv\n testee : ∀{T : Type{ℓ}}{a : T} → IsUnit{ℓ}(a ≡ a)\n IsUnit.unit testee = [≡]-intro\n IsUnit.uniqueness testee {x} = {!!}\n -}\n\ninstance\n -- `Unit` is an unit type.\n Unit-IsUnit : ⦃ equiv : Equiv{ℓₑ}(Unit) ⦄ → IsUnit{ℓ}(Unit)\n IsUnit.unit Unit-IsUnit = <>\n IsUnit.uniqueness Unit-IsUnit = reflexivity(_≡ₛ_)\n\ninstance\n -- `Empty` is an empty type.\n Empty-IsEmpty : IsEmpty{ℓ}(Empty)\n Empty-IsEmpty = intro(empty)\n\nmodule _ ⦃ _ : Equiv{ℓₑ₁}(T) ⦄ ⦃ empty-equiv : Equiv{ℓₑ₂}(Empty{ℓ₂}) ⦄ where\n instance\n empty-injective : Injective ⦃ empty-equiv ⦄(empty{T = T})\n Injective.proof(empty-injective) {}\n\n instance\n empty-function : Function ⦃ empty-equiv ⦄(empty{T = T})\n Function.congruence empty-function {()}\n\nmodule _ ⦃ equiv : Equiv{ℓₑ}(T) ⦄ where -- TODO: Duplicated in Type.Properties.Singleton.Proofs\n Unit-fn-unique-value : ∀{f : Unit{ℓ} → T} → (∀{x y} → (f(x) ≡ₛ f(y)))\n Unit-fn-unique-value {x = <>} {y = <>} = reflexivity(_≡ₛ_)\n\nmodule _ ⦃ equiv : Equiv{ℓₑ}(Unit{ℓ₁}) ⦄ where\n Unit-fn-unique-fn : ∀{f g : T → Unit{ℓ₁}} → (∀{x y} → (_≡ₛ_ ⦃ equiv ⦄ (f(x)) (g(y))))\n Unit-fn-unique-fn {f = f}{g = g}{x = x}{y = y} with f(x) | g(y)\n ... | <> | <> = reflexivity(_≡ₛ_ ⦃ equiv ⦄)\n", "meta": {"hexsha": "f19370d415969c18171f847f772714f1fe142e19", "size": 3043, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Proofs.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/Proofs.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Proofs.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.6626506024, "max_line_length": 95, "alphanum_fraction": 0.6618468616, "num_tokens": 1041, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950868503682, "lm_q2_score": 0.7634837689358857, "lm_q1q2_score": 0.6443002014949957}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nmodule LogicalTopology where\n open import Basics\n\n open import lib.types.Truncation\n\n -- For convenience, we define the \"power type\" ℘ A\n ℘ : {i : ULevel} (j : ULevel) (A : Type i) → Type _\n ℘ j A = A → Prop j\n\n _∩_ : {i j k : ULevel} {A : Type i}\n → ℘ j A → ℘ k A → ℘ _ A\n U ∩ V = λ a → (U a) ∧ (V a)\n\n _∪_ : ∀ {i j k} {A : Type i}\n → ℘ j A → ℘ k A → ℘ _ A\n P ∪ Q = λ a → (P a) ∨ (Q a)\n\n ⋃ : {i j : ULevel} {A : Type i}\n {I : Type j} (U : I → ℘ (lmax i j) A)\n → ℘ _ A\n ⋃ U = λ a → ∃ₚ λ i → (U i a)\n\n infix 30 _⊆_\n _⊆_ : ∀ {i j k} {A : Type i} (P : ℘ j A) (Q : ℘ k A)\n → Prop _\n _⊆_ {A = A} P Q = ∀ₚ \\(a : A) → (P a) ⇒ (Q a)\n\n -- The definition of logically (Penon) open.\n _is-open : {i j : ULevel} {A : Type i} (U : ℘ j A) → Type (lmax i j)\n U is-open = ∀ x y → (p : (U x) holds) → ∥ (x ≠ y) ⊔ ((U y) holds) ∥\n\n _is-closed : ∀ {i j} {A : Type i} (U : ℘ j A) → Type (lmax i j)\n C is-closed = (not ∘ C) is-open\n\n maps-are-cts : {i j k : ULevel} {A : Type i} {B : Type j}\n {f : A → B} {U : ℘ k B} (p : U is-open)\n → (U ∘ f) is-open\n maps-are-cts {A = A} {f = f} {U = U} p x y q =\n let[ p' ]:= (p (f x) (f y) q) in-\n [ (case₀ ⊔→ case₁) p' ]\n where\n case₀ : (f x ≠ f y) → x ≠ y\n case₀ ne p = ne (ap f p)\n\n case₁ : (U (f y)) holds → (U (f y)) holds\n case₁ z = z\n\n maps-are-cts-closed : {i j k : ULevel} {A : Type i} {B : Type j}\n {f : A → B} {C : ℘ k B} (p : C is-closed)\n → (C ∘ f) is-closed\n maps-are-cts-closed {C = C} = maps-are-cts {U = not ∘ C}\n\n unions-of-opens-are-open : {i j : ULevel} {A : Type i}\n {I : Type j} (U : I → ℘ _ A)\n (o : (i : I) → (U i) is-open)\n → (⋃ U) is-open\n unions-of-opens-are-open U o x y p = -- Supposing that x is in ⋃ U,\n let[ q ]:= p in- -- We know that x is in some particular U i (i ≡ fst q), so\n let[ z ]:= (o (fst q) x y (snd q)) in- -- we use the open-ness of U i to split into two cases\n [ z |> -- z : (x ≠ y) ⊔ (U i y) holds\n ((idf (x ≠ y)) -- Case₀: x already isn't y\n ⊔→\n ((λ (w : U (fst q) y holds) → -- Case₁: y is in U i and therefore ⋃ U\n [ (fst q) , w ])))\n ] \n\n \n _is-logically-connected : ∀ {i j} {A : Type i} (U : ℘ j A) → Prop _\n _is-logically-connected {j = j} {A = A} U =\n ∀ₚ λ (P : ℘ j A) → (U ⊆ (P ∪ (not ∘ P)))\n ⇒ ((U ⊆ P) ∨ (U ⊆ not ∘ P))\n\n _is-detachable : ∀ {i j} {A : Type i} (P : ℘ j A) → Prop _\n _is-detachable {A = A} P =\n ∀ₚ λ (a : A) → (P a) ∨ (not $ P a)\n\n _is-inhabited : ∀ {i j} {A : Type i} (P : ℘ j A) → Prop _\n _is-inhabited {A = A} P =\n ∃ₚ λ (a : A) → P a\n\n _is-logical-ctd-cmp : ∀ {i j} {A : Type i} (P : ℘ j A) → Prop _\n P is-logical-ctd-cmp =\n (P is-inhabited) ∧\n (P is-detachable) ∧\n (P is-logically-connected)\n", "meta": {"hexsha": "5a62c01b874300912204f0c3c928fd4973ac9671", "size": 3023, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "cohesion/david_jaz_261/LogicalTopology.agda", "max_stars_repo_name": "glangmead/formalization", "max_stars_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2021-10-06T17:39:22.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-13T05:51:12.000Z", "max_issues_repo_path": "cohesion/david_jaz_261/LogicalTopology.agda", "max_issues_repo_name": "glangmead/formalization", "max_issues_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cohesion/david_jaz_261/LogicalTopology.agda", "max_forks_repo_name": "glangmead/formalization", "max_forks_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.3522727273, "max_line_length": 99, "alphanum_fraction": 0.4164737016, "num_tokens": 1273, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9005297754396142, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.6442606157309936}} {"text": "open import Formalization.PredicateLogic.Signature\n\nmodule Formalization.PredicateLogic.Constructive.NaturalDeduction (𝔏 : Signature) where\nopen Signature(𝔏)\n\nopen import Data.ListSized\nimport Lvl\nopen import Formalization.PredicateLogic.Syntax(𝔏)\nopen import Formalization.PredicateLogic.Syntax.Substitution(𝔏)\nopen import Functional using (_∘_ ; _∘₂_ ; swap)\nopen import Numeral.Finite\nopen import Numeral.Natural\nopen import Relator.Equals.Proofs.Equiv\nopen import Sets.PredicateSet using (PredSet ; _∈_ ; _∉_ ; _∪_ ; _∪•_ ; _∖_ ; _⊆_ ; _⊇_ ; ∅ ; [≡]-to-[⊆] ; [≡]-to-[⊇]) renaming (•_ to · ; _≡_ to _≡ₛ_)\nopen import Type\n\nprivate variable ℓ : Lvl.Level\nprivate variable args vars : ℕ\nprivate variable Γ : PredSet{ℓ}(Formula(vars))\n\ndata _⊢_ {ℓ} : PredSet{ℓ}(Formula(vars)) → Formula(vars) → Type{Lvl.𝐒(ℓₚ Lvl.⊔ ℓₒ Lvl.⊔ ℓ)} where\n direct : (Γ ⊆ (Γ ⊢_))\n\n [⊤]-intro : (Γ ⊢ ⊤)\n\n [⊥]-elim : ∀{φ} → (Γ ⊢ ⊥) → (Γ ⊢ φ)\n\n [∧]-intro : ∀{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ ψ) → (Γ ⊢ (φ ∧ ψ))\n [∧]-elimₗ : ∀{φ ψ} → (Γ ⊢ (φ ∧ ψ)) → (Γ ⊢ φ)\n [∧]-elimᵣ : ∀{φ ψ} → (Γ ⊢ (φ ∧ ψ)) → (Γ ⊢ ψ)\n\n [∨]-introₗ : ∀{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ (φ ∨ ψ))\n [∨]-introᵣ : ∀{φ ψ} → (Γ ⊢ ψ) → (Γ ⊢ (φ ∨ ψ))\n [∨]-elim : ∀{φ ψ χ} → ((Γ ∪ · φ) ⊢ χ) → ((Γ ∪ · ψ) ⊢ χ) → (Γ ⊢ (φ ∨ ψ)) → (Γ ⊢ χ)\n\n [⟶]-intro : ∀{φ ψ} → ((Γ ∪ · φ) ⊢ ψ) → (Γ ⊢ (φ ⟶ ψ))\n [⟶]-elim : ∀{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ (φ ⟶ ψ)) → (Γ ⊢ ψ)\n\n [Ɐ]-intro : ∀{φ} → (∀{t} → (Γ ⊢ (substitute0 t φ))) → (Γ ⊢ (Ɐ φ))\n [Ɐ]-elim : ∀{φ} → (Γ ⊢ (Ɐ φ)) → ∀{t} → (Γ ⊢ (substitute0 t φ))\n\n [∃]-intro : ∀{φ}{t} → (Γ ⊢ (substitute0 t φ)) → (Γ ⊢ (∃ φ))\n [∃]-elim : ∀{φ ψ} → (∀{t} → (Γ ∪ ·(substitute0 t φ)) ⊢ ψ) → (Γ ⊢ (∃ φ)) → (Γ ⊢ ψ)\n", "meta": {"hexsha": "942b8b3ec915d8d5c65676aed5c420ddad66b8de", "size": 1657, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Formalization/PredicateLogic/Constructive/NaturalDeduction.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Formalization/PredicateLogic/Constructive/NaturalDeduction.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Formalization/PredicateLogic/Constructive/NaturalDeduction.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.6590909091, "max_line_length": 151, "alphanum_fraction": 0.5093542547, "num_tokens": 879, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633915994285382, "lm_q2_score": 0.7461389930307512, "lm_q1q2_score": 0.6442101385888191}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nopen import Cubical.Core.Everything\n\nmodule Cubical.Algebra.Structures {a} (A : Type a) where\n\n-- The file is divided into sections depending on the arities of the\n-- components of the algebraic structure.\n\nopen import Cubical.Foundations.Prelude using (isSet; cong; _∙_)\nopen import Cubical.Foundations.HLevels using (hSet)\n\nopen import Cubical.Algebra.Base\nopen import Cubical.Algebra.Definitions\nopen import Cubical.Algebra.Properties\nopen import Cubical.Data.Sigma using (_,_; fst; snd)\nopen import Cubical.Data.Nat.Base renaming (zero to ℕ-zero; suc to ℕ-suc)\nopen import Cubical.Data.Int.Base\nopen import Cubical.Data.NatPlusOne.Base\n\nopen import Cubical.Relation.Nullary using (¬_)\nopen import Cubical.Relation.Binary.Reasoning.Equality\n\n_NotEqualTo_ : A → Type a\n_NotEqualTo_ z = Σ[ x ∈ A ] ¬ (x ≡ z)\n\n------------------------------------------------------------------------\n-- Algebra with 1 binary operation\n------------------------------------------------------------------------\n\nrecord IsMagma (_•_ : Op₂ A) : Type a where\n constructor ismagma\n field\n is-set : isSet A\n\n set : hSet a\n set = A , is-set\n\n\nrecord IsSemigroup (_•_ : Op₂ A) : Type a where\n constructor issemigroup\n field\n isMagma : IsMagma _•_\n assoc : Associative _•_\n\n open IsMagma isMagma public\n\n infixl 10 _^_\n _^_ : A → ℕ₊₁ → A\n x ^ one = x\n x ^ (2+ n) = x • (x ^ 1+ n)\n\n\nrecord IsBand (_•_ : Op₂ A) : Type a where\n constructor isband\n field\n isSemigroup : IsSemigroup _•_\n idem : Idempotent _•_\n\n open IsSemigroup isSemigroup public\n\n\nrecord IsCommutativeSemigroup (_•_ : Op₂ A) : Type a where\n constructor iscommsemigroup\n field\n isSemigroup : IsSemigroup _•_\n comm : Commutative _•_\n\n open IsSemigroup isSemigroup public\n\n\nrecord IsSemilattice (_•_ : Op₂ A) : Type a where\n constructor issemilattice\n field\n isBand : IsBand _•_\n comm : Commutative _•_\n\n open IsBand isBand public\n\n\nrecord IsSelectiveMagma (_•_ : Op₂ A) : Type a where\n constructor isselmagma\n field\n isMagma : IsMagma _•_\n sel : Selective _•_\n\n open IsMagma isMagma public\n\n\n------------------------------------------------------------------------\n-- Algebra with 1 binary operation & 1 element\n------------------------------------------------------------------------\n\nrecord IsMonoid (_•_ : Op₂ A) (ε : A) : Type a where\n constructor ismonoid\n field\n isSemigroup : IsSemigroup _•_\n identity : Identity ε _•_\n\n open IsSemigroup isSemigroup public hiding (_^_)\n\n identityˡ : LeftIdentity ε _•_\n identityˡ = fst identity\n\n identityʳ : RightIdentity ε _•_\n identityʳ = snd identity\n\n ε-uniqueʳ : ∀ {e} → RightIdentity e _•_ → ε ≡ e\n ε-uniqueʳ idʳ = id-unique′ identityˡ idʳ\n\n ε-uniqueˡ : ∀ {e} → LeftIdentity e _•_ → e ≡ ε\n ε-uniqueˡ idˡ = id-unique′ idˡ identityʳ\n\n infixl 10 _^_\n _^_ : A → ℕ → A\n _ ^ ℕ-zero = ε\n x ^ (ℕ-suc n) = x • (x ^ n)\n\n\nrecord IsCommutativeMonoid (_•_ : Op₂ A) (ε : A) : Type a where\n constructor iscommmonoid\n field\n isMonoid : IsMonoid _•_ ε\n comm : Commutative _•_\n\n open IsMonoid isMonoid public\n\n isCommutativeSemigroup : IsCommutativeSemigroup _•_\n isCommutativeSemigroup = record\n { isSemigroup = isSemigroup\n ; comm = comm\n }\n\n\nrecord IsIdempotentCommutativeMonoid (_•_ : Op₂ A) (ε : A) : Type a where\n constructor isidemcommmonoid\n field\n isCommutativeMonoid : IsCommutativeMonoid _•_ ε\n idem : Idempotent _•_\n\n open IsCommutativeMonoid isCommutativeMonoid public\n\n\n-- Idempotent commutative monoids are also known as bounded lattices.\n-- Note that the BoundedLattice necessarily uses the notation inherited\n-- from monoids rather than lattices.\n\nIsBoundedLattice = IsIdempotentCommutativeMonoid\npattern isboundedlattice = isidemcommmonoid\n\nmodule IsBoundedLattice {_•_ : Op₂ A}\n {ε : A}\n (isIdemCommMonoid : IsIdempotentCommutativeMonoid _•_ ε) =\n IsIdempotentCommutativeMonoid isIdemCommMonoid\n\n\n------------------------------------------------------------------------\n-- Algebra with 1 binary operation, 1 unary operation & 1 element\n------------------------------------------------------------------------\n\nrecord IsGroup (_•_ : Op₂ A) (ε : A) (_⁻¹ : Op₁ A) : Type a where\n constructor isgroup\n field\n isMonoid : IsMonoid _•_ ε\n inverse : Inverse ε _⁻¹ _•_\n\n open IsMonoid isMonoid public hiding (_^_)\n\n infixl 10 _^_\n _^_ : A → ℤ → A\n x ^ pos ℕ-zero = ε\n x ^ pos (ℕ-suc n) = x • (x ^ pos n)\n x ^ negsuc ℕ-zero = x ⁻¹\n x ^ negsuc (ℕ-suc n) = (x ⁻¹) • (x ^ negsuc n)\n\n -- Right division\n infixl 6 _/_\n _/_ : Op₂ A\n x / y = x • (y ⁻¹)\n\n -- Left division\n infixr 6 _/ˡ_\n _/ˡ_ : Op₂ A\n x /ˡ y = (x ⁻¹) • y\n\n inverseˡ : LeftInverse ε _⁻¹ _•_\n inverseˡ = fst inverse\n\n inverseʳ : RightInverse ε _⁻¹ _•_\n inverseʳ = snd inverse\n\n inv-uniqueʳ : ∀ x y → (x • y) ≡ ε → x ≡ (y ⁻¹)\n inv-uniqueʳ = assoc+id+invʳ⇒invʳ-unique assoc identity inverseʳ\n\n inv-uniqueˡ : ∀ x y → (x • y) ≡ ε → y ≡ (x ⁻¹)\n inv-uniqueˡ = assoc+id+invˡ⇒invˡ-unique assoc identity inverseˡ\n\n cancelˡ : LeftCancellative _•_\n cancelˡ = assoc+idˡ+invˡ⇒cancelˡ assoc identityˡ inverseˡ\n\n cancelʳ : RightCancellative _•_\n cancelʳ = assoc+idʳ+invʳ⇒cancelʳ assoc identityʳ inverseʳ\n\n\nrecord IsAbelianGroup (_+_ : Op₂ A) (ε : A) (-_ : Op₁ A) : Type a where\n constructor isabgroup\n field\n isGroup : IsGroup _+_ ε -_\n comm : Commutative _+_\n\n open IsGroup isGroup public hiding (_/ˡ_) renaming (_/_ to _-_; _^_ to _*_)\n\n isCommutativeMonoid : IsCommutativeMonoid _+_ ε\n isCommutativeMonoid = record\n { isMonoid = isMonoid\n ; comm = comm\n }\n\n open IsCommutativeMonoid isCommutativeMonoid public\n using (isCommutativeSemigroup)\n\n\n------------------------------------------------------------------------\n-- Algebra with 2 binary operations\n------------------------------------------------------------------------\n\n-- Note that `IsLattice` is not defined in terms of `IsSemilattice`\n-- because the idempotence laws of ⋀ and ⋁ can be derived from the\n-- absorption laws, which makes the corresponding \"idem\" fields\n-- redundant. The derived idempotence laws are stated and proved in\n-- `Algebra.Properties.Lattice` along with the fact that every lattice\n-- consists of two semilattices.\n\nrecord IsLattice (_⋀_ _⋁_ : Op₂ A) : Type a where\n constructor islattice\n field\n ⋀-comm : Commutative _⋀_\n ⋀-assoc : Associative _⋀_\n ⋁-comm : Commutative _⋁_\n ⋁-assoc : Associative _⋁_\n absorptive : Absorptive _⋀_ _⋁_\n\n ⋀-absorbs-⋁ : _⋀_ Absorbs _⋁_\n ⋀-absorbs-⋁ = fst absorptive\n\n ⋁-absorbs-⋀ : _⋁_ Absorbs _⋀_\n ⋁-absorbs-⋀ = snd absorptive\n\n\nrecord IsDistributiveLattice (_⋀_ _⋁_ : Op₂ A) : Type a where\n constructor isdistrlattice\n field\n isLattice : IsLattice _⋀_ _⋁_\n ⋀-distribʳ-⋁ : _⋀_ DistributesOverʳ _⋁_\n\n open IsLattice isLattice public\n\n------------------------------------------------------------------------\n-- Algebra with 2 binary operations & 1 element\n------------------------------------------------------------------------\n\nrecord IsNearSemiring (_+_ _*_ : Op₂ A) (0# : A) : Type a where\n constructor isnearsemiring\n field\n +-isMonoid : IsMonoid _+_ 0#\n *-isSemigroup : IsSemigroup _*_\n distribˡ : _*_ DistributesOverˡ _+_\n zeroˡ : LeftZero 0# _*_\n\n open IsMonoid +-isMonoid public\n renaming\n ( assoc to +-assoc\n ; identity to +-identity\n ; identityˡ to +-identityˡ\n ; identityʳ to +-identityʳ\n ; ε-uniqueˡ to 0#-uniqueˡ\n ; ε-uniqueʳ to 0#-uniqueʳ\n ; isMagma to +-isMagma\n ; isSemigroup to +-isSemigroup\n ; _^_ to _**_\n )\n\n open IsSemigroup *-isSemigroup public\n using (_^_)\n renaming\n ( assoc to *-assoc\n ; isMagma to *-isMagma\n )\n\n\nrecord IsSemiringWithoutOne (_+_ _*_ : Op₂ A) (0# : A) : Type a where\n constructor issemiringwo1\n field\n +-isCommutativeMonoid : IsCommutativeMonoid _+_ 0#\n *-isSemigroup : IsSemigroup _*_\n distrib : _*_ DistributesOver _+_\n zero : Zero 0# _*_\n\n open IsCommutativeMonoid +-isCommutativeMonoid public\n using ()\n renaming\n ( comm to +-comm\n ; isMonoid to +-isMonoid\n ; isCommutativeSemigroup to +-isCommutativeSemigroup\n )\n\n zeroˡ : LeftZero 0# _*_\n zeroˡ = fst zero\n\n zeroʳ : RightZero 0# _*_\n zeroʳ = snd zero\n\n distribˡ : _*_ DistributesOverˡ _+_\n distribˡ = fst distrib\n\n distribʳ : _*_ DistributesOverʳ _+_\n distribʳ = snd distrib\n\n isNearSemiring : IsNearSemiring _+_ _*_ 0#\n isNearSemiring = record\n { +-isMonoid = +-isMonoid\n ; *-isSemigroup = *-isSemigroup\n ; distribˡ = distribˡ\n ; zeroˡ = zeroˡ\n }\n\n open IsNearSemiring isNearSemiring public\n hiding (+-isMonoid; zeroˡ; *-isSemigroup; distribˡ)\n\n\nrecord IsCommutativeSemiringWithoutOne (_+_ _*_ : Op₂ A) (0# : A) : Type a where\n constructor iscommsemiringwo1\n field\n isSemiringWithoutOne : IsSemiringWithoutOne _+_ _*_ 0#\n *-comm : Commutative _*_\n\n open IsSemiringWithoutOne isSemiringWithoutOne public\n\n\n------------------------------------------------------------------------\n-- Algebra with 2 binary operations & 2 elements\n------------------------------------------------------------------------\n\nrecord IsSemiringWithoutAnnihilatingZero (_+_ _*_ : Op₂ A)\n (0# 1# : A) : Type a where\n constructor issemiringwoa0\n field\n -- Note that these Algebra do have an additive unit, but this\n -- unit does not necessarily annihilate multiplication.\n +-isCommutativeMonoid : IsCommutativeMonoid _+_ 0#\n *-isMonoid : IsMonoid _*_ 1#\n distrib : _*_ DistributesOver _+_\n\n distribˡ : _*_ DistributesOverˡ _+_\n distribˡ = fst distrib\n\n distribʳ : _*_ DistributesOverʳ _+_\n distribʳ = snd distrib\n\n open IsCommutativeMonoid +-isCommutativeMonoid public\n renaming\n ( assoc to +-assoc\n ; identity to +-identity\n ; identityˡ to +-identityˡ\n ; identityʳ to +-identityʳ\n ; ε-uniqueˡ to 0#-uniqueˡ\n ; ε-uniqueʳ to 0#-uniqueʳ\n ; comm to +-comm\n ; isMagma to +-isMagma\n ; isSemigroup to +-isSemigroup\n ; isMonoid to +-isMonoid\n ; isCommutativeSemigroup to +-isCommutativeSemigroup\n ; _^_ to _**_\n )\n\n open IsMonoid *-isMonoid public\n using ()\n renaming\n ( assoc to *-assoc\n ; identity to *-identity\n ; identityˡ to *-identityˡ\n ; identityʳ to *-identityʳ\n ; ε-uniqueˡ to 1#-uniqueˡ\n ; ε-uniqueʳ to 1#-uniqueʳ\n ; isMagma to *-isMagma\n ; isSemigroup to *-isSemigroup\n )\n\n\nrecord IsSemiring (_+_ _*_ : Op₂ A) (0# 1# : A) : Type a where\n constructor issemiring\n field\n isSemiringWithoutAnnihilatingZero :\n IsSemiringWithoutAnnihilatingZero _+_ _*_ 0# 1#\n zero : Zero 0# _*_\n\n open IsSemiringWithoutAnnihilatingZero\n isSemiringWithoutAnnihilatingZero public\n\n isSemiringWithoutOne : IsSemiringWithoutOne _+_ _*_ 0#\n isSemiringWithoutOne = record\n { +-isCommutativeMonoid = +-isCommutativeMonoid\n ; *-isSemigroup = *-isSemigroup\n ; distrib = distrib\n ; zero = zero\n }\n\n open IsSemiringWithoutOne isSemiringWithoutOne public\n using\n ( isNearSemiring\n ; zeroˡ\n ; zeroʳ\n )\n\n\nrecord IsCommutativeSemiring (_+_ _*_ : Op₂ A) (0# 1# : A) : Type a where\n constructor iscommsemiring\n field\n isSemiring : IsSemiring _+_ _*_ 0# 1#\n *-comm : Commutative _*_\n\n open IsSemiring isSemiring public\n\n isCommutativeSemiringWithoutOne :\n IsCommutativeSemiringWithoutOne _+_ _*_ 0#\n isCommutativeSemiringWithoutOne = record\n { isSemiringWithoutOne = isSemiringWithoutOne\n ; *-comm = *-comm\n }\n\n *-isCommutativeSemigroup : IsCommutativeSemigroup _*_\n *-isCommutativeSemigroup = record\n { isSemigroup = *-isSemigroup\n ; comm = *-comm\n }\n\n *-isCommutativeMonoid : IsCommutativeMonoid _*_ 1#\n *-isCommutativeMonoid = record\n { isMonoid = *-isMonoid\n ; comm = *-comm\n }\n\n\n------------------------------------------------------------------------\n-- Algebra with 2 binary operations, 1 unary operation & 2 elements\n------------------------------------------------------------------------\n\nrecord IsRing (_+_ _*_ : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Type a where\n constructor isring\n field\n +-isAbelianGroup : IsAbelianGroup _+_ 0# -_\n *-isMonoid : IsMonoid _*_ 1#\n distrib : _*_ DistributesOver _+_\n\n open IsAbelianGroup +-isAbelianGroup public\n renaming\n ( assoc to +-assoc\n ; identity to +-identity\n ; identityˡ to +-identityˡ\n ; identityʳ to +-identityʳ\n ; ε-uniqueˡ to 0#-uniqueˡ\n ; ε-uniqueʳ to 0#-uniqueʳ\n ; inverse to +-inverse\n ; inverseˡ to +-inverseˡ\n ; inverseʳ to +-inverseʳ\n ; inv-uniqueˡ to neg-uniqueˡ\n ; inv-uniqueʳ to neg-uniqueʳ\n ; cancelˡ to +-cancelˡ\n ; cancelʳ to +-cancelʳ\n ; comm to +-comm\n ; isMagma to +-isMagma\n ; isSemigroup to +-isSemigroup\n ; isMonoid to +-isMonoid\n ; isCommutativeMonoid to +-isCommutativeMonoid\n ; isCommutativeSemigroup to +-isCommutativeSemigroup\n ; isGroup to +-isGroup\n ; _*_ to _**_\n )\n\n open IsMonoid *-isMonoid public\n using ()\n renaming\n ( assoc to *-assoc\n ; identity to *-identity\n ; identityˡ to *-identityˡ\n ; identityʳ to *-identityʳ\n ; ε-uniqueˡ to 1#-uniqueˡ\n ; ε-uniqueʳ to 1#-uniqueʳ\n ; isMagma to *-isMagma\n ; isSemigroup to *-isSemigroup\n )\n\n distribˡ : _*_ DistributesOverˡ _+_\n distribˡ = fst distrib\n\n distribʳ : _*_ DistributesOverʳ _+_\n distribʳ = snd distrib\n\n zeroˡ : LeftZero 0# _*_\n zeroˡ = assoc+distribʳ+idʳ+invʳ⇒zeˡ {_+_ = _+_} {_*_ = _*_} { -_} +-assoc distribʳ +-identityʳ +-inverseʳ\n\n zeroʳ : RightZero 0# _*_\n zeroʳ = assoc+distribˡ+idʳ+invʳ⇒zeʳ {_+_ = _+_} {_*_ = _*_} { -_} +-assoc distribˡ +-identityʳ +-inverseʳ\n\n zero : Zero 0# _*_\n zero = zeroˡ , zeroʳ\n\n isSemiringWithoutAnnihilatingZero\n : IsSemiringWithoutAnnihilatingZero _+_ _*_ 0# 1#\n isSemiringWithoutAnnihilatingZero = record\n { +-isCommutativeMonoid = +-isCommutativeMonoid\n ; *-isMonoid = *-isMonoid\n ; distrib = distrib\n }\n\n isSemiring : IsSemiring _+_ _*_ 0# 1#\n isSemiring = record\n { isSemiringWithoutAnnihilatingZero =\n isSemiringWithoutAnnihilatingZero\n ; zero = zero\n }\n\n open IsSemiring isSemiring public\n using (isNearSemiring; isSemiringWithoutOne)\n\n\nrecord IsCommutativeRing (_+_ _*_ : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Type a where\n constructor iscommring\n field\n isRing : IsRing _+_ _*_ -_ 0# 1#\n *-comm : Commutative _*_\n\n open IsRing isRing public\n\n *-isCommutativeMonoid : IsCommutativeMonoid _*_ 1#\n *-isCommutativeMonoid = record\n { isMonoid = *-isMonoid\n ; comm = *-comm\n }\n\n isCommutativeSemiring : IsCommutativeSemiring _+_ _*_ 0# 1#\n isCommutativeSemiring = record\n { isSemiring = isSemiring\n ; *-comm = *-comm\n }\n\n open IsCommutativeSemiring isCommutativeSemiring public\n using ( isCommutativeSemiringWithoutOne )\n\nrecord IsIntegralDomain {ℓ} (Cancellable : A → Type ℓ) (_+_ _*_ : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Type (ℓ-max a ℓ) where\n constructor isintegraldomain\n\n Cancellables : Type (ℓ-max a ℓ)\n Cancellables = Σ A Cancellable\n\n field\n isCommutativeRing : IsCommutativeRing _+_ _*_ -_ 0# 1#\n *-cancelˡ : ∀ (x : Cancellables) {y z} → (x .fst) * y ≡ (x .fst) * z → y ≡ z\n\n open IsCommutativeRing isCommutativeRing public\n\n *-cancelʳ : ∀ {x y} (z : Cancellables) → x * (z .fst) ≡ y * (z .fst) → x ≡ y\n *-cancelʳ {x} {y} zᵖ@(z , _) eq = *-cancelˡ zᵖ (\n z * x ≡⟨ *-comm z x ⟩\n x * z ≡⟨ eq ⟩\n y * z ≡⟨ *-comm y z ⟩\n z * y ∎)\n\nrecord IsBooleanAlgebra (_⋀_ _⋁_ : Op₂ A) (¬_ : Op₁ A) (⊤ ⊥ : A) : Type a where\n constructor isbooleanalgebra\n field\n isDistributiveLattice : IsDistributiveLattice _⋀_ _⋁_\n ⋀-identityʳ : RightIdentity ⊤ _⋀_\n ⋁-identityʳ : RightIdentity ⊥ _⋁_\n ⋀-complementʳ : RightInverse ⊥ ¬_ _⋀_\n ⋁-complementʳ : RightInverse ⊤ ¬_ _⋁_\n\n open IsDistributiveLattice isDistributiveLattice public\n\n ⋀-identityˡ : LeftIdentity ⊤ _⋀_\n ⋀-identityˡ x = ⋀-comm _ _ ∙ ⋀-identityʳ x\n\n ⋀-identity : Identity ⊤ _⋀_\n ⋀-identity = ⋀-identityˡ , ⋀-identityʳ\n\n ⋁-identityˡ : LeftIdentity ⊥ _⋁_\n ⋁-identityˡ x = ⋁-comm _ _ ∙ ⋁-identityʳ x\n\n ⋁-identity : Identity ⊥ _⋁_\n ⋁-identity = ⋁-identityˡ , ⋁-identityʳ\n\n ⋀-complementˡ : LeftInverse ⊥ ¬_ _⋀_\n ⋀-complementˡ = comm+invʳ⇒invˡ ⋀-comm ⋀-complementʳ\n\n ⋀-complement : Inverse ⊥ ¬_ _⋀_\n ⋀-complement = ⋀-complementˡ , ⋀-complementʳ\n\n ⋁-complementˡ : LeftInverse ⊤ ¬_ _⋁_\n ⋁-complementˡ = comm+invʳ⇒invˡ ⋁-comm ⋁-complementʳ\n\n ⋁-complement : Inverse ⊤ ¬_ _⋁_\n ⋁-complement = ⋁-complementˡ , ⋁-complementʳ\n\n\n------------------------------------------------------------------------\n-- Algebra with 2 binary operations, 2 unary operations & 2 elements\n------------------------------------------------------------------------\n\n-- The standard definition of division rings excludes the zero ring, but such a restriction is rarely important\nrecord IsDivisionRing {ℓ} (Invertible : A → Type ℓ) (_+_ _*_ : Op₂ A) (-_ : Op₁ A) (_⁻¹ : Σ A Invertible → A) (0# 1# : A) : Type (ℓ-max a ℓ) where\n constructor isdivring\n\n Invertibles : Type (ℓ-max a ℓ)\n Invertibles = Σ A Invertible\n\n field\n isRing : IsRing _+_ _*_ -_ 0# 1#\n *-inverseˡ : (x : Invertibles) → (x ⁻¹) * (x .fst) ≡ 1#\n *-inverseʳ : (x : Invertibles) → (x .fst) * (x ⁻¹) ≡ 1#\n\n open IsRing isRing public\n\n infixl 6 _/_\n _/_ : A → Invertibles → A\n x / y = x * (y ⁻¹)\n\n infixr 6 _/ˡ_\n _/ˡ_ : Invertibles → A → A\n x /ˡ y = (x ⁻¹) * y\n\n *-cancelˡ : ∀ (x : Invertibles) {y z} → (x .fst) * y ≡ (x .fst) * z → y ≡ z\n *-cancelˡ xᵖ@(x , _) {y} {z} eq =\n y ≡˘⟨ *-identityˡ y ⟩\n 1# * y ≡˘⟨ cong (_* y) (*-inverseˡ xᵖ) ⟩\n ((xᵖ ⁻¹) * x) * y ≡⟨ *-assoc (xᵖ ⁻¹) x y ⟩\n (xᵖ ⁻¹) * (x * y) ≡⟨ cong ((xᵖ ⁻¹) *_) eq ⟩\n (xᵖ ⁻¹) * (x * z) ≡˘⟨ *-assoc (xᵖ ⁻¹) x z ⟩\n ((xᵖ ⁻¹) * x) * z ≡⟨ cong (_* z) (*-inverseˡ xᵖ) ⟩\n 1# * z ≡⟨ *-identityˡ z ⟩\n z ∎\n\n *-cancelʳ : ∀ {x y} (z : Invertibles) → x * (z .fst) ≡ y * (z .fst) → x ≡ y\n *-cancelʳ {x} {y} zᵖ@(z , _) eq =\n x ≡˘⟨ *-identityʳ x ⟩\n x * 1# ≡˘⟨ cong (x *_) (*-inverseʳ zᵖ) ⟩\n x * (z * (zᵖ ⁻¹)) ≡˘⟨ *-assoc x z (zᵖ ⁻¹) ⟩\n (x * z) * (zᵖ ⁻¹) ≡⟨ cong (_* (zᵖ ⁻¹)) eq ⟩\n (y * z) * (zᵖ ⁻¹) ≡⟨ *-assoc y z (zᵖ ⁻¹) ⟩\n y * (z * (zᵖ ⁻¹)) ≡⟨ cong (y *_) (*-inverseʳ zᵖ) ⟩\n y * 1# ≡⟨ *-identityʳ y ⟩\n y ∎\n\n\nrecord IsField {ℓ} (Invertible : A → Type ℓ) (_+_ _*_ : Op₂ A) (-_ : Op₁ A) (_⁻¹ : Σ A Invertible → A) (0# 1# : A) : Type (ℓ-max a ℓ) where\n constructor isfield\n field\n isDivisionRing : IsDivisionRing Invertible _+_ _*_ -_ _⁻¹ 0# 1#\n *-comm : Commutative _*_\n\n open IsDivisionRing isDivisionRing public hiding (_/ˡ_)\n\n isCommutativeRing : IsCommutativeRing _+_ _*_ -_ 0# 1#\n isCommutativeRing = record\n { isRing = isRing\n ; *-comm = *-comm\n }\n\n isIntegralDomain : IsIntegralDomain Invertible _+_ _*_ -_ 0# 1#\n isIntegralDomain = record\n { isCommutativeRing = isCommutativeRing\n ; *-cancelˡ = *-cancelˡ\n }\n\n open IsIntegralDomain isIntegralDomain public\n using (*-isCommutativeMonoid; isCommutativeSemiring; isCommutativeSemiringWithoutOne)\n", "meta": {"hexsha": "434efc7c2ca1a94e3fe7e6bf899c4debcbd66d92", "size": 20073, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Structures.agda", "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Structures.agda", "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Structures.agda", "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.6937869822, "max_line_length": 146, "alphanum_fraction": 0.5817266976, "num_tokens": 7040, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.863391595913457, "lm_q2_score": 0.7461389817407016, "lm_q1q2_score": 0.6442101262183462}} {"text": "{-# OPTIONS --universe-polymorphism #-}\n\nmodule 13-implicitProofObligations where\n\nmodule Imports where\n module L where\n open import Agda.Primitive public\n using (Level; _⊔_) renaming (lzero to zero; lsuc to suc)\n\n -- extract from Data.Unit\n record ⊤ : Set where\n constructor tt\n\n -- extract from Data.Empty\n data ⊥ : Set where\n\n ⊥-elim : ∀ {w} {Whatever : Set w} → ⊥ → Whatever\n ⊥-elim ()\n\n -- extract from Function\n id : ∀ {a} {A : Set a} → A → A\n id x = x\n\n _$_ : ∀ {a b} {A : Set a} {B : A → Set b} →\n ((x : A) → B x) → ((x : A) → B x)\n f $ x = f x\n\n _∘_ : ∀ {a b c}\n {A : Set a} {B : A → Set b} {C : {x : A} → B x → Set c} →\n (∀ {x} (y : B x) → C y) → (g : (x : A) → B x) →\n ((x : A) → C (g x))\n f ∘ g = λ x → f (g x)\n\n -- extract from Data.Bool\n data Bool : Set where\n true : Bool\n false : Bool\n\n not : Bool → Bool\n not true = false\n not false = true\n\n T : Bool → Set\n T true = ⊤\n T false = ⊥\n\n -- extract from Relation.Nullary.Decidable and friends\n infix 3 ¬_\n\n ¬_ : ∀ {ℓ} → Set ℓ → Set ℓ\n ¬ P = P → ⊥\n\n data Dec {p} (P : Set p) : Set p where\n yes : ( p : P) → Dec P\n no : (¬p : ¬ P) → Dec P\n ⌊_⌋ : ∀ {p} {P : Set p} → Dec P → Bool\n ⌊ yes _ ⌋ = true\n ⌊ no _ ⌋ = false\n\n False : ∀ {p} {P : Set p} → Dec P → Set\n False Q = T (not ⌊ Q ⌋)\n\n -- extract from Relation.Binary.PropositionalEquality\n data _≡_ {a} {A : Set a} (x : A) : A → Set a where\n refl : x ≡ x\n\n cong : ∀ {a b} {A : Set a} {B : Set b}\n (f : A → B) {x y} → x ≡ y → f x ≡ f y\n cong f refl = refl\n\n _≢_ : ∀ {a} {A : Set a} → A → A → Set a\n x ≢ y = ¬ x ≡ y\n\n -- extract from Data.Nat\n data ℕ : Set where\n zero : ℕ\n suc : (n : ℕ) → ℕ\n\n {-# BUILTIN NATURAL ℕ #-}\n\n pred : ℕ → ℕ\n pred zero = zero\n pred (suc n) = n\n\n infixl 6 _+_\n\n _+_ : ℕ → ℕ → ℕ\n -- zero + n = n\n -- suc m + n = suc (m + n)\n zero + n = n\n suc m + n = suc (m + n)\n\n _*_ : ℕ → ℕ → ℕ\n zero * n = zero\n suc m * n = n + m * n\n\n _≟_ : (x y : ℕ) → Dec (x ≡ y)\n zero ≟ zero = yes refl\n suc m ≟ suc n with m ≟ n\n suc m ≟ suc .m | yes refl = yes refl\n suc m ≟ suc n | no prf = no (prf ∘ cong pred)\n zero ≟ suc n = no λ()\n suc m ≟ zero = no λ()\n\n -- extract from Data.Fin\n data Fin : ℕ → Set where\n zero : {n : ℕ} → Fin (suc n)\n suc : {n : ℕ} (i : Fin n) → Fin (suc n)\n\n -- A conversion: toℕ \"n\" = n.\n\n toℕ : ∀ {n} → Fin n → ℕ\n toℕ zero = 0\n toℕ (suc i) = suc (toℕ i)\n\n -- extract from Data.Product\n record Σ {a b} (A : Set a) (B : A → Set b) : Set (a L.⊔ b) where\n constructor _,_\n field\n proj₁ : A\n proj₂ : B proj₁\n\n _×_ : ∀ {a b} (A : Set a) (B : Set b) → Set (a L.⊔ b)\n A × B = Σ A (λ (_ : A) → B)\n\n -- extract from Data.Nat.DivMod\n\n data DivMod : ℕ → ℕ → Set where\n result : {divisor : ℕ} (q : ℕ) (r : Fin divisor) →\n DivMod (toℕ r + q * divisor) divisor\n\n data DivMod' (dividend divisor : ℕ) : Set where\n result : (q : ℕ) (r : Fin divisor)\n (eq : dividend ≡ (toℕ r + q * divisor)) →\n DivMod' dividend divisor\n\n postulate\n _div_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → ℕ\n _divMod_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} →\n DivMod dividend divisor\n _divMod'_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} →\n DivMod' dividend divisor\n\nopen Imports\n\n\n-- Begin of actual example!\n\npostulate\n d : ℕ\n d≢0 : d ≢ 0\n-- d≢0' : d ≢ 0\n\nfromWitnessFalse : ∀ {p} {P : Set p} {Q : Dec P} → ¬ P → False Q\nfromWitnessFalse {Q = yes p} ¬P = ⊥-elim $ ¬P p\nfromWitnessFalse {Q = no ¬p} ¬P = tt\n\n⋯ : {A : Set} → {{v : A}} → A\n⋯ {{v}} = v\n\n_divMod′_ : (dividend divisor : ℕ) {{ ≢0 : divisor ≢ 0 }} → ℕ × ℕ\n_divMod′_ a d {{_}} with _divMod_ a d { fromWitnessFalse ⋯ }\n._ divMod′ d | (result q r) = q , toℕ r\n\n_div′_ : (dividend divisor : ℕ) {{ ≢0 : divisor ≢ 0 }} → ℕ\n_div′_ a b {{_}} with a divMod′ b\na div′ b | (q , _) = q\n\n--Agda can't resolve hiddens\n-- test : {d≢0 : False (d ≟ 0)} → ℕ\n-- test = 5 div d\n-- test2 : {{d≢0 : d ≢ 0}} → ℕ\n-- test2 = 5 div′ d\n\ntest3 = 5 div 2\ntest4 = 5 div′ 2\n where nz : 2 ≢ 0\n nz ()\n", "meta": {"hexsha": "4fe89adef8ac13c6ad922e0352f76dcfe40f8d40", "size": 4153, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/instance-arguments/13-implicitProofObligations.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_issues_repo_path": "examples/instance-arguments/13-implicitProofObligations.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/instance-arguments/13-implicitProofObligations.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 23.2011173184, "max_line_length": 67, "alphanum_fraction": 0.4863953768, "num_tokens": 1742, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199714402812, "lm_q2_score": 0.7690802370707281, "lm_q1q2_score": 0.6441969662104681}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Types and functions which are used to keep track of height\n-- invariants in AVL Trees\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.AVL.Height where\n\nopen import Data.Nat.Base\nopen import Data.Fin using (Fin; zero; suc)\n\nℕ₂ = Fin 2\npattern 0# = zero\npattern 1# = suc zero\npattern ## = suc (suc ())\n\n-- Addition.\n\ninfixl 6 _⊕_\n\n_⊕_ : ℕ₂ → ℕ → ℕ\n0# ⊕ n = n\n1# ⊕ n = 1 + n\n## ⊕ n\n\n-- pred[ i ⊕ n ] = pred (i ⊕ n).\n\npred[_⊕_] : ℕ₂ → ℕ → ℕ\npred[ i ⊕ zero ] = 0\npred[ i ⊕ suc n ] = i ⊕ n\n\ninfix 4 _∼_⊔_\n\n-- If i ∼ j ⊔ m, then the difference between i and j is at most 1,\n-- and the maximum of i and j is m. _∼_⊔_ is used to record the\n-- balance factor of the AVL trees, and also to ensure that the\n-- absolute value of the balance factor is never more than 1.\n\ndata _∼_⊔_ : ℕ → ℕ → ℕ → Set where\n ∼+ : ∀ {n} → n ∼ 1 + n ⊔ 1 + n\n ∼0 : ∀ {n} → n ∼ n ⊔ n\n ∼- : ∀ {n} → 1 + n ∼ n ⊔ 1 + n\n\n-- Some lemmas.\n\nmax∼ : ∀ {i j m} → i ∼ j ⊔ m → m ∼ i ⊔ m\nmax∼ ∼+ = ∼-\nmax∼ ∼0 = ∼0\nmax∼ ∼- = ∼0\n\n∼max : ∀ {i j m} → i ∼ j ⊔ m → j ∼ m ⊔ m\n∼max ∼+ = ∼0\n∼max ∼0 = ∼0\n∼max ∼- = ∼+\n", "meta": {"hexsha": "5e7516e0ac1cea734740ded9386701173ad014bb", "size": 1262, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/AVL/Height.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/AVL/Height.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/AVL/Height.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.7586206897, "max_line_length": 72, "alphanum_fraction": 0.4667194929, "num_tokens": 506, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774768002981829, "lm_q2_score": 0.7341195385342971, "lm_q1q2_score": 0.6441728637094536}} {"text": "module Data.List.Equiv where\n\nopen import Logic.Propositional\nimport Lvl\nopen import Data.List\nopen import Structure.Operator\nopen import Structure.Setoid\nopen import Type\n\nprivate variable ℓ ℓₑ ℓₚ : Lvl.Level\nprivate variable T : Type{ℓ}\n\n-- A correct equality relation on lists should state that prepend is a function and have the generalized cancellation properties for lists.\nrecord Extensionality ⦃ equiv : Equiv{ℓₑ}(T) ⦄ (equiv-List : Equiv{ℓₚ}(List(T))) : Type{ℓₑ Lvl.⊔ Lvl.of(T) Lvl.⊔ ℓₚ} where\n constructor intro\n private instance _ = equiv-List\n field\n ⦃ binaryOperator ⦄ : BinaryOperator(List._⊰_)\n generalized-cancellationᵣ : ∀{x y : T}{l₁ l₂ : List(T)} → (x ⊰ l₁ ≡ y ⊰ l₂) → (x ≡ y)\n generalized-cancellationₗ : ∀{x y : T}{l₁ l₂ : List(T)} → (x ⊰ l₁ ≡ y ⊰ l₂) → (l₁ ≡ l₂)\n case-unequality : ∀{x : T}{l : List(T)} → (∅ ≢ x ⊰ l)\n\n generalized-cancellation : ∀{x y : T}{l₁ l₂ : List(T)} → (x ⊰ l₁ ≡ y ⊰ l₂) → ((x ≡ y) ∧ (l₁ ≡ l₂))\n generalized-cancellation p = [∧]-intro (generalized-cancellationᵣ p) (generalized-cancellationₗ p)\nopen Extensionality ⦃ … ⦄ renaming\n ( binaryOperator to [⊰]-binaryOperator\n ; generalized-cancellationₗ to [⊰]-generalized-cancellationₗ\n ; generalized-cancellationᵣ to [⊰]-generalized-cancellationᵣ\n ; generalized-cancellation to [⊰]-generalized-cancellation\n ; case-unequality to [∅][⊰]-unequal\n ) public\n", "meta": {"hexsha": "6370e115c015d5907255d8ae0cba4383db66ba8b", "size": 1375, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/List/Equiv.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/List/Equiv.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/List/Equiv.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.96875, "max_line_length": 139, "alphanum_fraction": 0.6843636364, "num_tokens": 494, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711870587667, "lm_q2_score": 0.757794360334681, "lm_q1q2_score": 0.6441033720001076}} {"text": "{-# OPTIONS --safe #-}\n\nmodule Cubical.Algebra.CommRing.Instances.Polynomials.UnivariatePolyList where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Data.Nat using (ℕ ; zero ; suc)\n\nopen import Cubical.Algebra.CommRing\nopen import Cubical.Algebra.Polynomials.UnivariateList.Base\nopen import Cubical.Algebra.Polynomials.UnivariateList.Properties\n\nprivate\n variable\n ℓ : Level\n\nopen CommRingStr\n\nmodule _ (R : CommRing ℓ) where\n\n open PolyMod R\n open PolyModTheory R\n\n UnivariatePolyList : CommRing ℓ\n fst UnivariatePolyList = Poly R\n 0r (snd UnivariatePolyList) = 0P\n 1r (snd UnivariatePolyList) = 1P\n _+_ (snd UnivariatePolyList) = _Poly+_\n _·_ (snd UnivariatePolyList) = _Poly*_\n - snd UnivariatePolyList = Poly-\n isCommRing (snd UnivariatePolyList) = makeIsCommRing isSetPoly\n Poly+Assoc Poly+Rid Poly+Inverses Poly+Comm\n Poly*Associative Poly*Rid Poly*LDistrPoly+ Poly*Commutative\n\n\nnUnivariatePolyList : (A' : CommRing ℓ) → (n : ℕ) → CommRing ℓ\nnUnivariatePolyList A' zero = A'\nnUnivariatePolyList A' (suc n) = UnivariatePolyList (nUnivariatePolyList A' n)\n", "meta": {"hexsha": "8c9baf9506c0e69c4f48129daaa17abd3063c038", "size": 1160, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials/UnivariatePolyList.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials/UnivariatePolyList.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials/UnivariatePolyList.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.5263157895, "max_line_length": 95, "alphanum_fraction": 0.725, "num_tokens": 343, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513786759491, "lm_q2_score": 0.7185943805178139, "lm_q1q2_score": 0.6440412042478803}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Cats.Util.SetoidReasoning where\n\nopen import Relation.Binary.Reasoning.MultiSetoid public\n\nopen import Relation.Binary using (Setoid)\n\nmodule _ {c ℓ} (S : Setoid c ℓ) where\n\n open Setoid S\n\n triangle :\n ∀ m {x y}\n → x ≈ m\n → y ≈ m\n → x ≈ y\n triangle m x≈m y≈m = trans x≈m (sym y≈m)\n", "meta": {"hexsha": "22480955c2d9f5ccae7a4f946d66ef6b13a776c7", "size": 339, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Util/SetoidReasoning.agda", "max_stars_repo_name": "JLimperg/cats", "max_stars_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 24, "max_stars_repo_stars_event_min_datetime": "2017-11-03T15:18:57.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-06T05:00:46.000Z", "max_issues_repo_path": "Cats/Util/SetoidReasoning.agda", "max_issues_repo_name": "JLimperg/cats", "max_issues_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cats/Util/SetoidReasoning.agda", "max_forks_repo_name": "JLimperg/cats", "max_forks_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-18T15:35:07.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-18T15:35:07.000Z", "avg_line_length": 18.8333333333, "max_line_length": 56, "alphanum_fraction": 0.6312684366, "num_tokens": 117, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8807970904940925, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.643914269038055}} {"text": "\nmodule NamedWhere where\n\ndata _==_ {A : Set}(x : A) : A -> Set where\n refl : x == x\n\ndata List (A : Set) : Set where\n [] : List A\n _::_ : A -> List A -> List A\n\n_++_ : {A : Set} -> List A -> List A -> List A\n[] ++ ys = ys\n(x :: xs) ++ ys = x :: (xs ++ ys)\n\nreverse : {A : Set} -> List A -> List A\nreverse {A} xs = rev xs []\n module reverse where\n rev : List A -> List A -> List A\n rev [] ys = ys\n rev (x :: xs) ys = rev xs (x :: ys)\n\nrev : {A : Set} -> List A -> List A -> List A\nrev = reverse.rev []\n\n", "meta": {"hexsha": "c35ea618acbbc6463f2beec09da284dea4a04e57", "size": 532, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/NamedWhere.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/NamedWhere.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/NamedWhere.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 21.28, "max_line_length": 46, "alphanum_fraction": 0.4718045113, "num_tokens": 188, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8807970779778825, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.6439142598879724}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Heterogeneous N-ary Relations\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Relation.Nary where\n\n------------------------------------------------------------------------\n-- Concrete examples can be found in README.Nary. This file's comments\n-- are more focused on the implementation details and the motivations\n-- behind the design decisions.\n------------------------------------------------------------------------\n\nopen import Level using (Level; _⊔_; Lift)\nopen import Data.Unit.Base\nopen import Data.Bool.Base using (true; false)\nopen import Data.Empty\nopen import Data.Nat.Base using (zero; suc)\nopen import Data.Product as Prod using (_×_; _,_)\nopen import Data.Product.Nary.NonDependent\nopen import Data.Sum.Base using (_⊎_)\nopen import Function using (_$_; _∘′_)\nopen import Function.Nary.NonDependent\nopen import Relation.Nullary using (¬_; Dec; yes; no; _because_)\nimport Relation.Nullary.Decidable as Dec\nopen import Relation.Nullary.Product using (_×-dec_)\nimport Relation.Unary as Unary\nopen import Relation.Binary.PropositionalEquality using (_≡_; cong; subst)\n\nprivate\n variable\n r : Level\n R : Set r\n\n------------------------------------------------------------------------\n-- Generic type constructors\n\n-- `Relation.Unary` provides users with a wealth of combinators to work\n-- with indexed sets. We can generalise these to n-ary relations.\n\n-- The crucial thing to notice here is that because we are explicitly\n-- considering that the input function should be a `Set`-ended `Arrows`,\n-- all the other parameters are inferrable. This allows us to make the\n-- number arguments (`n`) implicit.\n------------------------------------------------------------------------\n\n------------------------------------------------------------------------\n-- Quantifiers\n\n-- If we already know how to quantify over one variable, we can easily\n-- describe how to quantify over `n` variables by induction over said `n`.\n\nquantₙ : (∀ {i l} {I : Set i} → (I → Set l) → Set (i ⊔ l)) →\n ∀ n {ls} {as : Sets n ls} →\n Arrows n as (Set r) → Set (r ⊔ (⨆ n ls))\nquantₙ Q zero f = f\nquantₙ Q (suc n) f = Q (λ x → quantₙ Q n (f x))\n\ninfix 5 ∃⟨_⟩ Π[_] ∀[_]\n\n-- existential quantifier\n\n∃⟨_⟩ : ∀ {n ls r} {as : Sets n ls} → as ⇉ Set r → Set (r ⊔ (⨆ n ls))\n∃⟨_⟩ = quantₙ Unary.Satisfiable _\n\n-- explicit universal quantifiers\n\nΠ[_] : ∀ {n ls r} {as : Sets n ls} → as ⇉ Set r → Set (r ⊔ (⨆ n ls))\nΠ[_] = quantₙ Unary.Universal _\n\n-- implicit universal quantifiers\n\n∀[_] : ∀ {n ls r} {as : Sets n ls} → as ⇉ Set r → Set (r ⊔ (⨆ n ls))\n∀[_] = quantₙ Unary.IUniversal _\n\n-- ≟-mapₙ : ∀ n. (con : A₁ → ⋯ → Aₙ → R) →\n-- Injectiveₙ n con →\n-- ∀ a₁₁ a₁₂ ⋯ aₙ₁ aₙ₂ →\n-- Dec (a₁₁ ≡ a₁₂) → ⋯ → Dec (aₙ₁ ≡ aₙ₂) →\n-- Dec (con a₁₁ ⋯ aₙ₁ ≡ con a₁₂ ⋯ aₙ₂)\n\n≟-mapₙ : ∀ n {ls} {as : Sets n ls} (con : Arrows n as R) → Injectiveₙ n con →\n ∀ {l r} → Arrows n (Dec <$> Equalₙ n l r) (Dec (uncurryₙ n con l ≡ uncurryₙ n con r))\n≟-mapₙ n con con-inj =\n curryₙ n λ a?s → let as? = Product-dec n a?s in\n Dec.map′ (cong (uncurryₙ n con) ∘′ fromEqualₙ n) con-inj as?\n\n------------------------------------------------------------------------\n-- Substitution\n\nmodule _ {n r ls} {as : Sets n ls} (P : as ⇉ Set r) where\n\n-- Substitutionₙ : ∀ n. ∀ a₁₁ a₁₂ ⋯ aₙ₁ aₙ₂ →\n-- a₁₁ ≡ a₁₂ → ⋯ → aₙ₁ ≡ aₙ₂ →\n-- P a₁₁ ⋯ aₙ₁ → P a₁₂ ⋯ aₙ₂\n\n Substitutionₙ : Set (r ⊔ (⨆ n ls))\n Substitutionₙ = ∀ {l r} → Equalₙ n l r ⇉ (uncurryₙ n P l → uncurryₙ n P r)\n\n substₙ : Substitutionₙ\n substₙ = curryₙ n (subst (uncurryₙ n P) ∘′ fromEqualₙ n)\n\n------------------------------------------------------------------------\n-- Pointwise liftings of k-ary operators\n\n-- Rather than having multiple ad-hoc lifting functions for various arities\n-- we have a fully generic liftₙ functional which lifts a k-ary operator\n-- to work with k n-ary functions whose respective codomains match the domains\n-- of the operator.\n-- The type of liftₙ is fairly unreadable. Here it is written with ellipsis:\n\n-- liftₙ : ∀ k n. (B₁ → ⋯ → Bₖ → R) →\n-- (A₁ → ⋯ → Aₙ → B₁) →\n-- ⋮\n-- (A₁ → ⋯ → Aₙ → B₁) →\n-- (A₁ → ⋯ → Aₙ → R)\n\nliftₙ : ∀ k n {ls rs} {as : Sets n ls} {bs : Sets k rs} →\n Arrows k bs R → Arrows k (smap _ (Arrows n as) k bs) (Arrows n as R)\nliftₙ k n op = curry⊤ₙ k λ fs →\n curry⊤ₙ n λ vs →\n uncurry⊤ₙ k op $\n palg _ _ k (λ f → uncurry⊤ₙ n f vs) fs where\n\n -- The bulk of the work happens in this auxiliary definition:\n palg : ∀ f (F : ∀ {l} → Set l → Set (f l)) n {ls} {as : Sets n ls} →\n (∀ {l} {r : Set l} → F r → r) → Product⊤ n (smap f F n as) → Product⊤ n as\n palg f F zero alg ps = _\n palg f F (suc n) alg (p , ps) = alg p , palg f F n alg ps\n\n\n-- implication\n\ninfixr 6 _⇒_\n_⇒_ : ∀ {n} {ls r s} {as : Sets n ls} →\n as ⇉ Set r → as ⇉ Set s → as ⇉ Set (r ⊔ s)\n_⇒_ = liftₙ 2 _ (λ A B → A → B)\n\n-- conjunction\n\ninfixr 7 _∩_\n_∩_ : ∀ {n} {ls r s} {as : Sets n ls} →\n as ⇉ Set r → as ⇉ Set s → as ⇉ Set (r ⊔ s)\n_∩_ = liftₙ 2 _ _×_\n\n-- disjunction\n\ninfixr 8 _∪_\n_∪_ : ∀ {n} {ls r s} {as : Sets n ls} →\n as ⇉ Set r → as ⇉ Set s → as ⇉ Set (r ⊔ s)\n_∪_ = liftₙ 2 _ _⊎_\n\n-- negation\n\n∁ : ∀ {n ls r} {as : Sets n ls} → as ⇉ Set r → as ⇉ Set r\n∁ = liftₙ 1 _ ¬_\n\n\napply⊤ₙ : ∀ {n ls r} {as : Sets n ls} {R : as ⇉ Set r} →\n Π[ R ] → (vs : Product⊤ n as) → uncurry⊤ₙ n R vs\napply⊤ₙ {zero} prf vs = prf\napply⊤ₙ {suc n} prf (v , vs) = apply⊤ₙ (prf v) vs\n\napplyₙ : ∀ {n ls r} {as : Sets n ls} {R : as ⇉ Set r} →\n Π[ R ] → (vs : Product n as) → uncurry⊤ₙ n R (toProduct⊤ n vs)\napplyₙ {n} prf vs = apply⊤ₙ prf (toProduct⊤ n vs)\n\niapply⊤ₙ : ∀ {n ls r} {as : Sets n ls} {R : as ⇉ Set r} →\n ∀[ R ] → {vs : Product⊤ n as} → uncurry⊤ₙ n R vs\niapply⊤ₙ {zero} prf = prf\niapply⊤ₙ {suc n} prf = iapply⊤ₙ {n} prf\n\niapplyₙ : ∀ {n ls r} {as : Sets n ls} {R : as ⇉ Set r} →\n ∀[ R ] → {vs : Product n as} → uncurry⊤ₙ n R (toProduct⊤ n vs)\niapplyₙ {n} prf = iapply⊤ₙ {n} prf\n\n------------------------------------------------------------------------\n-- Properties of N-ary relations\n\n-- Decidability\n\nDecidable : ∀ {n ls r} {as : Sets n ls} → as ⇉ Set r → Set (r ⊔ ⨆ n ls)\nDecidable R = Π[ mapₙ _ Dec R ]\n\n-- erasure\n\n⌊_⌋ : ∀ {n ls r} {as : Sets n ls} {R : as ⇉ Set r} → Decidable R → as ⇉ Set r\n⌊_⌋ {zero} R? = Lift _ (Dec.True R?)\n⌊_⌋ {suc n} R? a = ⌊ R? a ⌋\n\n-- equivalence between R and its erasure\n\nfromWitness : ∀ {n ls r} {as : Sets n ls} (R : as ⇉ Set r) (R? : Decidable R) →\n ∀[ ⌊ R? ⌋ ⇒ R ]\nfromWitness {zero} R R? with R?\n... | yes r = λ _ → r\n... | false because _ = λ ()\nfromWitness {suc n} R R? = fromWitness (R _) (R? _)\n\ntoWitness : ∀ {n ls r} {as : Sets n ls} (R : as ⇉ Set r) (R? : Decidable R) →\n ∀[ R ⇒ ⌊ R? ⌋ ]\ntoWitness {zero} R R? with R?\n... | true because _ = _\n... | no ¬r = ⊥-elim ∘′ ¬r\ntoWitness {suc n} R R? = toWitness (R _) (R? _)\n", "meta": {"hexsha": "c451f508f0c20d38d6d83f1f46148f50922053bd", "size": 7207, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Relation/Nary.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Relation/Nary.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Relation/Nary.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 34.4832535885, "max_line_length": 94, "alphanum_fraction": 0.5088108783, "num_tokens": 2613, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430436757312, "lm_q2_score": 0.774583389368527, "lm_q1q2_score": 0.6437895958204215}} {"text": "------------------------------------------------------------------------------\n-- Example of a partial function using the Bove-Capretta method\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- From: Ana Bove and Venanzio Capretta. Nested general recursion and\n-- partiality in type theory. vol 2152 LNCS. 2001.\n\nmodule FOT.FOTC.Program.Min.MinBC-SL where\n\nopen import Data.Nat renaming ( suc to succ )\nopen import Relation.Binary.PropositionalEquality\n\n------------------------------------------------------------------------------\n\ndata minAcc : (ℕ → ℕ) → Set where\n minacc0 : (f : ℕ → ℕ) → f 0 ≡ 0 → minAcc f\n minacc1 : (f : ℕ → ℕ) → f 0 ≢ 0 → minAcc (λ n → f (succ n)) → minAcc f\n\nmin : (f : ℕ → ℕ) → minAcc f → ℕ\nmin f (minacc0 .f q) = 0\nmin f (minacc1 .f q h) = succ (min (λ n → f (succ n)) h)\n", "meta": {"hexsha": "c4bdb3294be4c6d384e9299a424382c8e457b84a", "size": 1009, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/FOTC/Program/Min/MinBC-SL.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/FOT/FOTC/Program/Min/MinBC-SL.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/FOT/FOTC/Program/Min/MinBC-SL.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 37.3703703704, "max_line_length": 78, "alphanum_fraction": 0.4648166501, "num_tokens": 258, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8918110368115781, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.6436585571199736}} {"text": "{-# OPTIONS --cubical --safe --guardedness --postfix-projections #-}\n\nmodule Codata.Stream where\n\nopen import Prelude\nopen import Data.List using (List; _∷_; [])\nopen import Data.List.Kleene\nimport Data.List.Kleene.Membership as Kleene\nopen import Data.Fin\n\ninfixr 5 _◃_\nrecord Stream (A : Type a) : Type a where\n constructor _◃_\n coinductive\n field\n head : A\n tail : Stream A\nopen Stream public\n\nStream′ : Type a → Type a\nStream′ A = ℕ → A\n\n_!_ : Stream A → Stream′ A\nxs ! zero = xs .head\nxs ! suc n = xs .tail ! n\n\ntabulate : Stream′ A → Stream A\ntabulate xs .head = xs zero\ntabulate xs .tail = tabulate (xs ∘ suc)\n\nlinv : (xs : Stream A) → tabulate (xs !_) ≡ xs\nlinv xs i .head = xs .head\nlinv xs i .tail = linv (xs .tail) i\n\nrinv : (xs : Stream′ A) → (tabulate xs !_) ≡ xs\nrinv xs i zero = xs zero\nrinv xs i (suc n) = rinv (xs ∘ suc) i n\n\nstream : Stream A ⇔ Stream′ A\nstream .fun = _!_\nstream .inv = tabulate\nstream .rightInv = rinv\nstream .leftInv = linv\n\n\n\n-- infixr 5 _∈_\n-- _∈_ : A → Stream A → Type _\n-- x ∈ xs = fiber xs x\n\n-- toList : ℕ → Stream A → List A\n-- toList zero xs = []\n-- toList (suc n) xs = xs zero ∷ toList n (xs ∘ suc)\n\n-- mutual\n-- concat⋆ : A ⋆ → Stream (A ⁺) → Stream A\n-- concat⋆ [] xs = concat⁺ (xs zero) (xs ∘ suc)\n-- concat⋆ (∹ x) xs = concat⁺ x xs\n\n-- concat⁺ : A ⁺ → Stream (A ⁺) → Stream A\n-- concat⁺ x xs zero = x .head\n-- concat⁺ x xs (suc n) = concat⋆ (x .tail) xs n\n\n-- concat : Stream (A ⁺) → Stream A\n-- concat xs = concat⁺ (xs zero) (xs ∘ suc)\n\n-- infixr 5 _∈²_\n-- _∈²_ : A → Stream (A ⁺) → Type _\n-- x ∈² xs = ∃ n x Kleene.∈⁺ xs n\n\n-- mutual\n-- ◇++⋆ : ∀ (x : A) y ys → x Kleene.∈⋆ y → x ∈ concat⋆ y ys\n-- ◇++⋆ x (∹ y) ys x∈y = ◇++⁺ x y ys x∈y\n\n-- ◇++⁺ : ∀ (x : A) y ys → x Kleene.∈⁺ y → x ∈ concat⁺ y ys\n-- ◇++⁺ x y ys (f0 , x∈y) = zero , x∈y\n-- ◇++⁺ x y ys (fs n , x∈y) = let m , p = ◇++⋆ x (y .tail) ys (n , x∈y) in suc m , p\n\n-- mutual\n-- ++◇⋆ : ∀ (x : A) y ys → x ∈ concat ys → x ∈ concat⋆ y ys\n-- ++◇⋆ x [] ys x∈ys = x∈ys\n-- ++◇⋆ x (∹ y) ys x∈ys = ++◇⁺ x y ys x∈ys\n\n-- ++◇⁺ : ∀ (x : A) y ys → x ∈ concat ys → x ∈ concat⁺ y ys\n-- ++◇⁺ x y ys x∈ys = let n , p = ++◇⋆ x (y .tail) ys x∈ys in suc n , p\n\n-- concat-∈ : ∀ (x : A) xs → x ∈² xs → x ∈ concat xs\n-- concat-∈ x xs (zero , x∈xs) = ◇++⁺ x (xs zero) (xs ∘ suc) x∈xs\n-- concat-∈ x xs (suc n , x∈xs) = ++◇⁺ x (xs zero) (xs ∘ suc) (concat-∈ x (xs ∘ suc) (n , x∈xs))\n", "meta": {"hexsha": "9edd981047315f3f75a1e9c40c282a43747f0968", "size": 2418, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Codata/Stream.agda", "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_issues_repo_path": "Codata/Stream.agda", "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Codata/Stream.agda", "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "avg_line_length": 26.8666666667, "max_line_length": 96, "alphanum_fraction": 0.5268817204, "num_tokens": 1079, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511616741042, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.6436108348458555}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Numbers.Naturals.Definition\nopen import Numbers.Naturals.Order\nopen import Numbers.Naturals.Naturals -- for length\nopen import Lists.Lists\nopen import Orders.Partial.Definition\nopen import Orders.Total.Definition\nopen import Functions.Definition\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import Groups.FinitePermutations\nopen import Boolean.Definition\n\nmodule Lists.SortList where\n isSorted : {a b : _} {A : Set a} (ord : TotalOrder A) (l : List A) → Set (a ⊔ b)\n isSorted ord [] = True'\n isSorted ord (x :: []) = True'\n isSorted ord (x :: (y :: l)) = (TotalOrder._≤_ ord x y) && (isSorted ord (y :: l))\n\n sortedTailIsSorted : {a b : _} {A : Set a} (ord : TotalOrder A) → (x : A) → (l : List A) → (isSorted ord (x :: l)) → isSorted ord l\n sortedTailIsSorted ord x [] pr = record {}\n sortedTailIsSorted ord x (y :: l) (fst ,, snd) = snd\n\n insert : {a b : _} {A : Set a} (ord : TotalOrder A) → (l : List A) → (isSorted ord l) → (x : A) → List A\n insert ord [] pr x = [ x ]\n insert ord (y :: l) pr x with TotalOrder.totality ord x y\n insert ord (y :: l) pr x | inl (inl x_\ndata Ty : Set where\n UNIT : Ty\n _=>_ : Ty -> Ty -> Ty\n\n\n-- Context and truth judgement\n\nCx : Set1\nCx = Ty -> Set\n\nisTrue : Ty -> Cx -> Set\nisTrue a tc = tc a\n\n\n-- Terms\n\nTmRepr : Set1\nTmRepr = Cx -> Ty -> Set\n\nmodule ArrMp where\n record Tm (tr : TmRepr) : Set1 where\n infixl 1 _$_\n field\n var : forall {tc a} -> isTrue a tc -> tr tc a\n lam' : forall {tc a b} -> (isTrue a tc -> tr tc b) -> tr tc (a => b)\n _$_ : forall {tc a b} -> tr tc (a => b) -> tr tc a -> tr tc b\n\n lam'' : forall {tc a b} -> (tr tc a -> tr tc b) -> tr tc (a => b)\n lam'' f = lam' \\x -> f (var x)\n\n syntax lam'' (\\a -> b) = lam a => b\n open Tm {{...}} public\n\n Thm : Ty -> Set1\n Thm a = forall {tr tc} {{_ : Tm tr}} -> tr tc a\nopen ArrMp public\n\n\n-- Example theorems\n\naI : forall {a} -> Thm (a => a)\naI =\n lam x => x\n\naK : forall {a b} -> Thm (a => b => a)\naK =\n lam x =>\n lam _ => x\n\naS : forall {a b c} -> Thm ((a => b => c) => (a => b) => a => c)\naS =\n lam f =>\n lam g =>\n lam x => f $ x $ (g $ x)\n\ntSKK : forall {a} -> Thm (a => a)\ntSKK {a = a} =\n aS {b = a => a} $ aK $ aK\n", "meta": {"hexsha": "33c9fd38a750dc06545e741b5d207b5cddc43280", "size": 1243, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Pf/ArrMp.agda", "max_stars_repo_name": "mietek/formal-logic", "max_stars_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_stars_repo_licenses": ["X11"], "max_stars_count": 26, "max_stars_repo_stars_event_min_datetime": "2015-08-31T09:49:52.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-13T12:37:44.000Z", "max_issues_repo_path": "src/Pf/ArrMp.agda", "max_issues_repo_name": "mietek/formal-logic", "max_issues_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_issues_repo_licenses": ["X11"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Pf/ArrMp.agda", "max_forks_repo_name": "mietek/formal-logic", "max_forks_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_forks_repo_licenses": ["X11"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.552238806, "max_line_length": 75, "alphanum_fraction": 0.4778761062, "num_tokens": 485, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392909114836, "lm_q2_score": 0.727975443004307, "lm_q1q2_score": 0.6435588944345008}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Divisibility\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Nat.Divisibility where\n\nopen import Algebra\nopen import Data.Nat.Base\nopen import Data.Nat.DivMod\nopen import Data.Nat.Properties\nopen import Data.Product\nopen import Function.Base\nopen import Function.Equivalence using (_⇔_; equivalence)\nopen import Level using (0ℓ)\nopen import Relation.Nullary using (yes; no)\nopen import Relation.Nullary.Decidable as Dec using (False)\nopen import Relation.Nullary.Negation using (contradiction)\nopen import Relation.Binary\nimport Relation.Binary.Reasoning.Preorder as PreorderReasoning\nopen import Relation.Binary.PropositionalEquality as PropEq\n using (_≡_; _≢_; refl; sym; trans; cong; cong₂; subst)\n\n------------------------------------------------------------------------\n-- Definition\n\nopen import Data.Nat.Divisibility.Core public\n\n------------------------------------------------------------------------\n-- Relationship with _%_\n\nm%n≡0⇒n∣m : ∀ m n → m % suc n ≡ 0 → suc n ∣ m\nm%n≡0⇒n∣m m n eq = divides (m / suc n) (begin-equality\n m ≡⟨ m≡m%n+[m/n]*n m n ⟩\n m % suc n + m / suc n * (suc n) ≡⟨ cong₂ _+_ eq refl ⟩\n m / suc n * (suc n) ∎)\n where open ≤-Reasoning\n\nn∣m⇒m%n≡0 : ∀ m n → suc n ∣ m → m % suc n ≡ 0\nn∣m⇒m%n≡0 m n (divides v eq) = begin-equality\n m % suc n ≡⟨ cong (_% suc n) eq ⟩\n (v * suc n) % suc n ≡⟨ m*n%n≡0 v n ⟩\n 0 ∎\n where open ≤-Reasoning\n\nm%n≡0⇔n∣m : ∀ m n → m % suc n ≡ 0 ⇔ suc n ∣ m\nm%n≡0⇔n∣m m n = equivalence (m%n≡0⇒n∣m m n) (n∣m⇒m%n≡0 m n)\n\n------------------------------------------------------------------------\n-- Properties of _∣_ and _≤_\n\n∣⇒≤ : ∀ {m n} → m ∣ suc n → m ≤ suc n\n∣⇒≤ {m} {n} (divides (suc q) eq) = begin\n m ≤⟨ m≤m+n m (q * m) ⟩\n suc q * m ≡⟨ sym eq ⟩\n suc n ∎\n where open ≤-Reasoning\n\n>⇒∤ : ∀ {m n} → m > suc n → m ∤ suc n\n>⇒∤ (s≤s m>n) m∣n = contradiction (∣⇒≤ m∣n) (≤⇒≯ m>n)\n\n------------------------------------------------------------------------\n-- _∣_ is a partial order\n\n∣-reflexive : _≡_ ⇒ _∣_\n∣-reflexive {n} refl = divides 1 (sym (*-identityˡ n))\n\n∣-refl : Reflexive _∣_\n∣-refl = ∣-reflexive refl\n\n∣-trans : Transitive _∣_\n∣-trans (divides p refl) (divides q refl) =\n divides (q * p) (sym (*-assoc q p _))\n\n∣-antisym : Antisymmetric _≡_ _∣_\n∣-antisym {m} {zero} _ (divides q refl) = *-zeroʳ q\n∣-antisym {zero} {n} (divides p eq) _ = sym (trans eq (*-comm p 0))\n∣-antisym {suc m} {suc n} p∣q q∣p = ≤-antisym (∣⇒≤ p∣q) (∣⇒≤ q∣p)\n\ninfix 4 _∣?_\n\n_∣?_ : Decidable _∣_\nzero ∣? zero = yes (divides 0 refl)\nzero ∣? suc m = no ((λ()) ∘′ ∣-antisym (divides 0 refl))\nsuc n ∣? m = Dec.map (m%n≡0⇔n∣m m n) (m % suc n ≟ 0)\n\n∣-isPreorder : IsPreorder _≡_ _∣_\n∣-isPreorder = record\n { isEquivalence = PropEq.isEquivalence\n ; reflexive = ∣-reflexive\n ; trans = ∣-trans\n }\n\n∣-isPartialOrder : IsPartialOrder _≡_ _∣_\n∣-isPartialOrder = record\n { isPreorder = ∣-isPreorder\n ; antisym = ∣-antisym\n }\n\n∣-preorder : Preorder 0ℓ 0ℓ 0ℓ\n∣-preorder = record\n { isPreorder = ∣-isPreorder\n }\n\n∣-poset : Poset 0ℓ 0ℓ 0ℓ\n∣-poset = record\n { isPartialOrder = ∣-isPartialOrder\n }\n\n------------------------------------------------------------------------\n-- A reasoning module for the _∣_ relation\n\nmodule ∣-Reasoning where\n private\n module Base = PreorderReasoning ∣-preorder\n\n open Base public\n hiding (step-≈; step-≈˘; step-∼)\n\n infixr 2 step-∣\n step-∣ = Base.step-∼\n syntax step-∣ x y∣z x∣y = x ∣⟨ x∣y ⟩ y∣z\n\n------------------------------------------------------------------------\n-- Simple properties of _∣_\n\ninfix 10 1∣_ _∣0\n\n1∣_ : ∀ n → 1 ∣ n\n1∣ n = divides n (sym (*-identityʳ n))\n\n_∣0 : ∀ n → n ∣ 0\nn ∣0 = divides 0 refl\n\n0∣⇒≡0 : ∀ {n} → 0 ∣ n → n ≡ 0\n0∣⇒≡0 {n} 0∣n = ∣-antisym (n ∣0) 0∣n\n\n∣1⇒≡1 : ∀ {n} → n ∣ 1 → n ≡ 1\n∣1⇒≡1 {n} n∣1 = ∣-antisym n∣1 (1∣ n)\n\nn∣n : ∀ {n} → n ∣ n\nn∣n {n} = ∣-refl\n\n------------------------------------------------------------------------\n-- Properties of _∣_ and _+_\n\n∣m∣n⇒∣m+n : ∀ {i m n} → i ∣ m → i ∣ n → i ∣ m + n\n∣m∣n⇒∣m+n (divides p refl) (divides q refl) =\n divides (p + q) (sym (*-distribʳ-+ _ p q))\n\n∣m+n∣m⇒∣n : ∀ {i m n} → i ∣ m + n → i ∣ m → i ∣ n\n∣m+n∣m⇒∣n {i} {m} {n} (divides p m+n≡p*i) (divides q m≡q*i) =\n divides (p ∸ q) $ begin-equality\n n ≡⟨ sym (m+n∸n≡m n m) ⟩\n n + m ∸ m ≡⟨ cong (_∸ m) (+-comm n m) ⟩\n m + n ∸ m ≡⟨ cong₂ _∸_ m+n≡p*i m≡q*i ⟩\n p * i ∸ q * i ≡⟨ sym (*-distribʳ-∸ i p q) ⟩\n (p ∸ q) * i ∎\n where open ∣-Reasoning\n\n------------------------------------------------------------------------\n-- Properties of _∣_ and _*_\n\nn∣m*n : ∀ m {n} → n ∣ m * n\nn∣m*n m = divides m refl\n\nm∣m*n : ∀ {m} n → m ∣ m * n\nm∣m*n n = divides n (*-comm _ n)\n\n∣m⇒∣m*n : ∀ {i m} n → i ∣ m → i ∣ m * n\n∣m⇒∣m*n {i} {m} n (divides q refl) = ∣-trans (n∣m*n q) (m∣m*n n)\n\n∣n⇒∣m*n : ∀ {i} m {n} → i ∣ n → i ∣ m * n\n∣n⇒∣m*n {i} m {n} i∣n = subst (i ∣_) (*-comm n m) (∣m⇒∣m*n m i∣n)\n\n*-monoʳ-∣ : ∀ {i j} k → i ∣ j → k * i ∣ k * j\n*-monoʳ-∣ {i} {j} k (divides q refl) = divides q $ begin-equality\n k * (q * i) ≡⟨ sym (*-assoc k q i) ⟩\n (k * q) * i ≡⟨ cong (_* i) (*-comm k q) ⟩\n (q * k) * i ≡⟨ *-assoc q k i ⟩\n q * (k * i) ∎\n where open ≤-Reasoning\n\n*-monoˡ-∣ : ∀ {i j} k → i ∣ j → i * k ∣ j * k\n*-monoˡ-∣ {i} {j} k rewrite *-comm i k | *-comm j k = *-monoʳ-∣ k\n\n*-cancelˡ-∣ : ∀ {i j} k → suc k * i ∣ suc k * j → i ∣ j\n*-cancelˡ-∣ {i} {j} k (divides q eq) =\n divides q $ *-cancelʳ-≡ j (q * i) $ begin-equality\n j * (suc k) ≡⟨ *-comm j (suc k) ⟩\n suc k * j ≡⟨ eq ⟩\n q * (suc k * i) ≡⟨ cong (q *_) (*-comm (suc k) i) ⟩\n q * (i * suc k) ≡⟨ sym (*-assoc q i (suc k)) ⟩\n (q * i) * suc k ∎\n where open ≤-Reasoning\n\n*-cancelʳ-∣ : ∀ {i j} k {k≢0 : False (k ≟ 0)} → i * k ∣ j * k → i ∣ j\n*-cancelʳ-∣ {i} {j} k@(suc k-1) rewrite *-comm i k | *-comm j k = *-cancelˡ-∣ k-1\n\n------------------------------------------------------------------------\n-- Properties of _∣_ and _∸_\n\n∣m∸n∣n⇒∣m : ∀ i {m n} → n ≤ m → i ∣ m ∸ n → i ∣ n → i ∣ m\n∣m∸n∣n⇒∣m i {m} {n} n≤m (divides p m∸n≡p*i) (divides q n≡q*o) =\n divides (p + q) $ begin-equality\n m ≡⟨ sym (m+[n∸m]≡n n≤m) ⟩\n n + (m ∸ n) ≡⟨ +-comm n (m ∸ n) ⟩\n m ∸ n + n ≡⟨ cong₂ _+_ m∸n≡p*i n≡q*o ⟩\n p * i + q * i ≡⟨ sym (*-distribʳ-+ i p q) ⟩\n (p + q) * i ∎\n where open ≤-Reasoning\n\n------------------------------------------------------------------------\n-- Properties of _∣_ and _/_\n\nm/n∣m : ∀ {m n n≢0} → n ∣ m → (m / n) {n≢0} ∣ m\nm/n∣m {m} {n} (divides p refl) = begin\n p * n / n ≡⟨ m*n/n≡m p n ⟩\n p ∣⟨ m∣m*n n ⟩\n p * n ∎\n where open ∣-Reasoning\n\nm*n∣o⇒m∣o/n : ∀ m n {o n≢0} → m * n ∣ o → m ∣ (o / n) {n≢0}\nm*n∣o⇒m∣o/n m n {_} {≢0} (divides p refl) = begin\n m ∣⟨ n∣m*n p ⟩\n p * m ≡⟨ sym (*-identityʳ (p * m)) ⟩\n p * m * 1 ≡⟨ sym (cong (p * m *_) (n/n≡1 n)) ⟩\n p * m * (n / n) ≡⟨ sym (*-/-assoc (p * m) {≢0 = ≢0} (n∣n {n})) ⟩\n p * m * n / n ≡⟨ cong (λ v → (v / n) {≢0}) (*-assoc p m n) ⟩\n p * (m * n) / n ∎\n where open ∣-Reasoning\n\nm*n∣o⇒n∣o/m : ∀ m n {o n≢0} → m * n ∣ o → n ∣ (o / m) {n≢0}\nm*n∣o⇒n∣o/m m n {o} {≢0} rewrite *-comm m n = m*n∣o⇒m∣o/n n m {o} {≢0}\n\nm∣n/o⇒m*o∣n : ∀ {m n o n≢0} → o ∣ n → m ∣ (n / o) {n≢0} → m * o ∣ n\nm∣n/o⇒m*o∣n {m} {n} {o} (divides p refl) m∣p*o/o = begin\n m * o ∣⟨ *-monoˡ-∣ o (subst (m ∣_) (m*n/n≡m p o) m∣p*o/o) ⟩\n p * o ∎\n where open ∣-Reasoning\n\nm∣n/o⇒o*m∣n : ∀ {m n o o≢0} → o ∣ n → m ∣ (n / o) {o≢0} → o * m ∣ n\nm∣n/o⇒o*m∣n {m} {_} {o} {≢0} rewrite *-comm o m = m∣n/o⇒m*o∣n {n≢0 = ≢0}\n\nm/n∣o⇒m∣o*n : ∀ {m n o n≢0} → n ∣ m → (m / n) {n≢0} ∣ o → m ∣ o * n\nm/n∣o⇒m∣o*n {_} {n} {o} (divides p refl) p*n/n∣o = begin\n p * n ∣⟨ *-monoˡ-∣ n (subst (_∣ o) (m*n/n≡m p n) p*n/n∣o) ⟩\n o * n ∎\n where open ∣-Reasoning\n\nm∣n*o⇒m/n∣o : ∀ {m n o n≢0} → n ∣ m → m ∣ o * n → (m / n) {n≢0} ∣ o\nm∣n*o⇒m/n∣o {_} {n@(suc _)} {o} (divides p refl) pn∣on = begin\n p * n / n ≡⟨ m*n/n≡m p n ⟩\n p ∣⟨ *-cancelʳ-∣ n pn∣on ⟩\n o ∎\n where open ∣-Reasoning\n\n------------------------------------------------------------------------\n-- Properties of _∣_ and _%_\n\n∣n∣m%n⇒∣m : ∀ {m n d ≢0} → d ∣ n → d ∣ (m % n) {≢0} → d ∣ m\n∣n∣m%n⇒∣m {m} {n@(suc n-1)} {d} (divides a n≡ad) (divides b m%n≡bd) =\n divides (b + (m / n) * a) (begin-equality\n m ≡⟨ m≡m%n+[m/n]*n m n-1 ⟩\n m % n + (m / n) * n ≡⟨ cong₂ _+_ m%n≡bd (cong (m / n *_) n≡ad) ⟩\n b * d + (m / n) * (a * d) ≡⟨ sym (cong (b * d +_) (*-assoc (m / n) a d)) ⟩\n b * d + ((m / n) * a) * d ≡⟨ sym (*-distribʳ-+ d b _) ⟩\n (b + (m / n) * a) * d ∎)\n where open ≤-Reasoning\n\n%-presˡ-∣ : ∀ {m n d ≢0} → d ∣ m → d ∣ n → d ∣ (m % n) {≢0}\n%-presˡ-∣ {m} {n@(suc n-1)} {d} (divides a refl) (divides b 1+n≡bd) =\n divides (a ∸ ad/n * b) $ begin-equality\n a * d % n ≡⟨ m%n≡m∸m/n*n (a * d) n-1 ⟩\n a * d ∸ ad/n * n ≡⟨ cong (λ v → a * d ∸ ad/n * v) 1+n≡bd ⟩\n a * d ∸ ad/n * (b * d) ≡⟨ sym (cong (a * d ∸_) (*-assoc ad/n b d)) ⟩\n a * d ∸ (ad/n * b) * d ≡⟨ sym (*-distribʳ-∸ d a (ad/n * b)) ⟩\n (a ∸ ad/n * b) * d ∎\n where open ≤-Reasoning; ad/n = a * d / n\n\n------------------------------------------------------------------------\n-- DEPRECATED - please use new names as continuing support for the old\n-- names is not guaranteed.\n\n-- Version 0.14\n\n∣-+ = ∣m∣n⇒∣m+n\n{-# WARNING_ON_USAGE ∣-+\n\"Warning: ∣-+ was deprecated in v0.14.\nPlease use ∣m∣n⇒∣m+n instead.\"\n#-}\n∣-∸ = ∣m+n∣m⇒∣n\n{-# WARNING_ON_USAGE ∣-∸\n\"Warning: ∣-∸ was deprecated in v0.14.\nPlease use ∣m+n∣m⇒∣n instead.\"\n#-}\n∣-* = n∣m*n\n{-# WARNING_ON_USAGE ∣-*\n\"Warning: ∣-* was deprecated in v0.14.\nPlease use n∣m*n instead.\"\n#-}\n\n-- Version 0.17\n\nopen import Data.Fin.Base using (Fin; zero; suc; toℕ)\nimport Data.Fin.Properties as FP\nopen import Data.Nat.Solver\nopen +-*-Solver\n\nnonZeroDivisor-lemma : ∀ m q (r : Fin (1 + m)) → toℕ r ≢ 0 →\n 1 + m ∤ toℕ r + q * (1 + m)\nnonZeroDivisor-lemma m zero r r≢zero (divides zero eq) = r≢zero $ begin-equality\n toℕ r ≡⟨ sym (*-identityˡ (toℕ r)) ⟩\n 1 * toℕ r ≡⟨ eq ⟩\n 0 ∎\n where open ≤-Reasoning\nnonZeroDivisor-lemma m zero r r≢zero (divides (suc q) eq) =\n m+1+n≰m m $ begin\n m + suc (q * suc m) ≡⟨ +-suc m (q * suc m) ⟩\n suc (m + q * suc m) ≡⟨ sym eq ⟩\n 1 * toℕ r ≡⟨ *-identityˡ (toℕ r) ⟩\n toℕ r ≤⟨ FP.toℕ≤pred[n] r ⟩\n m ∎\n where open ≤-Reasoning\nnonZeroDivisor-lemma m (suc q) r r≢zero d =\n nonZeroDivisor-lemma m q r r≢zero (∣m+n∣m⇒∣n d' ∣-refl)\n where\n lem = solve 3 (λ m r q → r :+ (m :+ q) := m :+ (r :+ q))\n refl (suc m) (toℕ r) (q * suc m)\n d' = subst (1 + m ∣_) lem d\n{-# WARNING_ON_USAGE nonZeroDivisor-lemma\n\"Warning: nonZeroDivisor-lemma was deprecated in v0.17.\"\n#-}\n\n-- Version 1.1\n\nposet = ∣-poset\n{-# WARNING_ON_USAGE poset\n\"Warning: poset was deprecated in v1.1.\nPlease use ∣-poset instead.\"\n#-}\n*-cong = *-monoʳ-∣\n{-# WARNING_ON_USAGE *-cong\n\"Warning: *-cong was deprecated in v1.1.\nPlease use *-monoʳ-∣ instead.\"\n#-}\n/-cong = *-cancelˡ-∣\n{-# WARNING_ON_USAGE /-cong\n\"Warning: /-cong was deprecated in v1.1.\nPlease use *-cancelˡ-∣ instead.\"\n#-}\n", "meta": {"hexsha": "888d88463f2615d4c1d4605d12b46130d68e0386", "size": 11348, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/Nat/Divisibility.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Data/Nat/Divisibility.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Data/Nat/Divisibility.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 31.9661971831, "max_line_length": 81, "alphanum_fraction": 0.450563976, "num_tokens": 5401, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891392358014, "lm_q2_score": 0.7826624738835052, "lm_q1q2_score": 0.643496585714442}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Relation.Unary.Properties where\n\nopen import Cubical.Core.Everything\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Univalence\nopen import Cubical.Foundations.Function using (id; _∘_)\n\nopen import Cubical.Data.Unit\nopen import Cubical.Data.Empty\n\nopen import Cubical.HITs.PropositionalTruncation\n\nopen import Cubical.Relation.Unary\n\nprivate\n variable\n ℓ ℓ₁ ℓ₂ ℓ₃ : Level\n A : Type ℓ\n\n------------------------------------------------------------------------\n-- Special sets\n\n\nEmpty∅ : Empty {A = A} ∅\nEmpty∅ _ ()\n\nUniversalU : Π[ U {A = A} ]\nUniversalU _ = tt\n\n\n∁∅≡U : ∁ ∅ ≡ U {A = A}\n∁∅≡U = ⇔toPath _ _ ((λ _ → tt) , λ _ ())\n\n∁U≡∅ : ∁ U ≡ ∅ {A = A}\n∁U≡∅ = ⇔toPath _ _ ((λ f → f tt) , λ ())\n\n\n------------------------------------------------------------------------\n-- Propositions\n\nmodule _ (P : Pred A ℓ₁) (Q : Pred A ℓ₂) where\n\n isProp⊆ : isProp (P ⊆ Q)\n isProp⊆ = isPropImplicitΠ λ _ → isPropΠ λ _ → isProp[ Q ] _\n\n isProp⊂ : isProp (P ⊂ Q)\n isProp⊂ = isProp× isProp⊆ (isPropΠ λ _ → isProp⊥)\n\n isProp⇔ : isProp (P ⇔ Q)\n isProp⇔ = isProp× isProp⊆ (isPropImplicitΠ λ _ → isPropΠ λ _ → isProp[ P ] _)\n\n\n\nmodule _ (P : Pred A ℓ) where\n\n isPropEmpty : isProp (Empty P)\n isPropEmpty = isPropΠ2 λ _ _ → isProp⊥\n\n isPropSatisfiable : isProp ∃⟨ P ⟩\n isPropSatisfiable = squash\n\n isPropUniversal : isProp Π[ P ]\n isPropUniversal = isPropΠ isProp[ P ]\n\n\n------------------------------------------------------------------------\n-- Predicate equivalence\n\n\n⇔-reflexive : (P : Pred A ℓ) → P ⇔ P\n⇔-reflexive P = id , id\n\n⇔-symmetric : (P : Pred A ℓ₁) (Q : Pred A ℓ₂) → P ⇔ Q → Q ⇔ P\n⇔-symmetric P Q (x , y) = (y , x)\n\n⇔-transitive : (P : Pred A ℓ₁) (Q : Pred A ℓ₂) (R : Pred A ℓ₃) →\n P ⇔ Q → Q ⇔ R → P ⇔ R\n⇔-transitive P Q R (x , y) (w , z) = w ∘ x , y ∘ z\n", "meta": {"hexsha": "66b6dd76401404fe2827a46ba849ef11ce09e880", "size": 1993, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Relation/Unary/Properties.agda", "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Relation/Unary/Properties.agda", "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Relation/Unary/Properties.agda", "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.0120481928, "max_line_length": 79, "alphanum_fraction": 0.5584545911, "num_tokens": 741, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339837155239, "lm_q2_score": 0.7662936484231889, "lm_q1q2_score": 0.6434828180863075}} {"text": "open import bool\nopen import eq using (_≡_)\nopen import nat\nopen import nat-thms\nopen import z05-01-hc-slist2-base\n\nmodule z05-01-hc-slist2-test where\n\ndata _R≤_ : ℕ → ℕ → Set where\n\n z≤n : ∀ {n : ℕ}\n --------\n → zero R≤ n\n\n s≤s : ∀ {m n : ℕ}\n → m R≤ n\n -------------\n → suc m R≤ suc n\n\n≤-pred : ∀ {m n} → suc m R≤ suc n → m R≤ n\n≤-pred (s≤s m≤n) = m≤n\n\n_≤?_ : Decidable _R≤_\nzero ≤? _ = left z≤n\nsuc m ≤? zero = right λ()\nsuc m ≤? suc n with m ≤? n\n... | left m≤n = left (s≤s m≤n)\n... | right m≰n = right λ x → m≰n (≤-pred x)\n\nℕ-Equivalence : Equivalence {X = ℕ} _≡_\nℕ-Equivalence = record\n { refl = _≡_.refl\n ; sym = λ x≡y → eq.sym x≡y\n ; trans = λ {_≡_.refl _≡_.refl → eq.trans _≡_.refl _≡_.refl} }\n\nxR≤y→x≤y≡tt : ∀ {x y : ℕ} → x R≤ y → x ≤ y ≡ bool.𝔹.tt\nxR≤y→x≤y≡tt {x} {y} z≤n = 0-≤ y\nxR≤y→x≤y≡tt {x} {y} (s≤s xR≤y) = xR≤y→x≤y≡tt xR≤y\n\nx≤y≡tt→xR≤y : ∀ {x y : ℕ} → x ≤ y ≡ bool.𝔹.tt → x R≤ y\nx≤y≡tt→xR≤y {zero} {_} _ = z≤n\nx≤y≡tt→xR≤y {suc x} {y} sucx≤y≡tt = {!!} -- TODO\n\nR≤-total : (x y : ℕ) → Either (x R≤ y) (y R≤ x)\nR≤-total zero zero = left z≤n\nR≤-total zero (suc y) = left z≤n\nR≤-total (suc x) zero = right z≤n\nR≤-total (suc x) (suc y) with R≤-total x y\n... | left l = left (s≤s l)\n... | right r = right (s≤s r)\n\nx≡y→xR≤y : ∀ {x y : ℕ} → x ≡ y → x R≤ y\nx≡y→xR≤y {zero} {_} _ = z≤n\nx≡y→xR≤y {suc x} {.(suc x)} _≡_.refl = s≤s (x≤y≡tt→xR≤y (≤-refl x))\n\nℕ-TotalOrder : TotalOrder {X = ℕ} _≡_ _R≤_\nℕ-TotalOrder = record\n { antisym = λ x≤y y≤x → ≤-antisym (xR≤y→x≤y≡tt x≤y) (xR≤y→x≤y≡tt y≤x)\n ; trans = λ {x} {y} {z} xR≤y yR≤z →\n x≤y≡tt→xR≤y (≤-trans {x} {y} {z} (xR≤y→x≤y≡tt xR≤y) (xR≤y→x≤y≡tt yR≤z))\n ; total = R≤-total\n ; reflexive = x≡y→xR≤y\n ; equivalence = ℕ-Equivalence\n }\n\nimport z05-01-hc-slist2-list as SL\nopen SL {ℕ}\n {_≡_}\n {_R≤_}\n _≤?_\n ℕ-TotalOrder\n\nempty : OList ⟦ 0 ⟧ ⟦ 9 ⟧\nempty = nil (≤-lift z≤n)\n\nl-9 : OList ⟦ 0 ⟧ ⟦ 9 ⟧\nl-9 = insert 9 empty (≤-lift z≤n) (≤-lift (s≤s (s≤s (s≤s (s≤s (s≤s (s≤s (s≤s (s≤s (s≤s z≤n))))))))))\n\nl-5-9 : OList ⟦ 0 ⟧ ⟦ 9 ⟧\nl-5-9 = insert 5 l-9 (≤-lift z≤n) (≤-lift (s≤s (s≤s (s≤s (s≤s (s≤s z≤n))))))\n\nl-1-5-9 : OList ⟦ 0 ⟧ ⟦ 9 ⟧\nl-1-5-9 = insert 1 l-5-9 (≤-lift z≤n) (≤-lift (s≤s z≤n))\n\nl-1-5-9' : OList ⊥ ⊤\nl-1-5-9' = isort' (9 ∷ 1 ∷ 5 ∷ [])\n\n-- cannot do because lower/upper indices different : l-1-5-9 ≡ l-1-5-9'\n_ : toList l-1-5-9 ≡ toList l-1-5-9'\n_ = eq.refl\n", "meta": {"hexsha": "e5acc02faf5b7a82ad73f3bd92980f7ee8a90320", "size": 2484, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z05-01-hc-slist2-test.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z05-01-hc-slist2-test.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z05-01-hc-slist2-test.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 27.2967032967, "max_line_length": 100, "alphanum_fraction": 0.4778582931, "num_tokens": 1449, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339596505965, "lm_q2_score": 0.7662936324115011, "lm_q1q2_score": 0.6434827861999485}} {"text": "{-# OPTIONS --safe --warning=error #-}\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import LogicalFormulae\nopen import Logic.PropositionalLogic\n\nmodule ExampleSheets.LogicAndSets.Sheet1 where\n\n q1i : {a : _} {A : Set a} → (p1 p2 p3 : Propositions A) → Tautology (implies (implies p1 (implies p2 p3)) (implies p2 (implies p1 p3)))\n Tautology.isTaut (q1i p1 p2 p3) {v} with inspect (Valuation.v v p3)\n Tautology.isTaut (q1i p1 p2 p3) {v} | BoolTrue with≡ p3T = Valuation.vImplicationT v (Valuation.vImplicationT v (Valuation.vImplicationT v p3T))\n Tautology.isTaut (q1i p1 p2 p3) {v} | BoolFalse with≡ p3F with inspect (Valuation.v v p2)\n Tautology.isTaut (q1i p1 p2 p3) {v} | BoolFalse with≡ p3F | BoolTrue with≡ p2T with inspect (Valuation.v v p1)\n Tautology.isTaut (q1i p1 p2 p3) {v} | BoolFalse with≡ p3F | BoolTrue with≡ p2T | BoolTrue with≡ p1T = Valuation.vImplicationVacuous v (Valuation.vImplicationF v p1T (Valuation.vImplicationF v p2T p3F))\n Tautology.isTaut (q1i p1 p2 p3) {v} | BoolFalse with≡ p3F | BoolTrue with≡ p2T | BoolFalse with≡ p1F = Valuation.vImplicationT v (Valuation.vImplicationT v (Valuation.vImplicationVacuous v p1F))\n Tautology.isTaut (q1i p1 p2 p3) {v} | BoolFalse with≡ p3F | BoolFalse with≡ p2F = Valuation.vImplicationT v (Valuation.vImplicationVacuous v p2F)\n", "meta": {"hexsha": "fff8104f3877172783bb2223e95dcc30b4a7b1f5", "size": 1322, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "ExampleSheets/LogicAndSets/Sheet1.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "ExampleSheets/LogicAndSets/Sheet1.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "ExampleSheets/LogicAndSets/Sheet1.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 77.7647058824, "max_line_length": 203, "alphanum_fraction": 0.7375189107, "num_tokens": 516, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424256566559, "lm_q2_score": 0.7606506418255928, "lm_q1q2_score": 0.6434666490232341}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Demos.Cantor where\n\nopen import Prelude\nopen import Data.Bool.Properties using (false≢true; true≢false)\n\nStream : Type a → Type a\nStream A = ℕ → A\n\n_∈_ : ∀ {A : Type a} (x : A) → Stream A → Type a\nx ∈ xs = ∃ i × (xs i ≡ x)\n\nCountable : Type a → Type a\nCountable A = Σ[ xs ⦂ Stream A ] × (∀ x → x ∈ xs)\n\nx≢¬x : ∀ x → x ≢ not x\nx≢¬x false = false≢true\nx≢¬x true = true≢false\n\ncantor : ¬ (Countable (Stream Bool))\ncantor (support , cover) =\n let p , ps = cover (λ i → not (support i i))\n q = cong (_$ p) ps\n in x≢¬x _ q\n", "meta": {"hexsha": "22f39244a257302012a37762afefd41bf6a9de36", "size": 566, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Demos/Cantor.agda", "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_issues_repo_path": "Demos/Cantor.agda", "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Demos/Cantor.agda", "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "avg_line_length": 21.7692307692, "max_line_length": 63, "alphanum_fraction": 0.5795053004, "num_tokens": 218, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9032942041005327, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.6433552095144137}} {"text": "{-# OPTIONS --without-K --exact-split --safe #-}\n\nopen import Fragment.Algebra.Signature\n\nmodule Fragment.Algebra.Homomorphism.Definitions (Σ : Signature) where\n\nopen import Fragment.Algebra.Algebra Σ\n\nopen import Level using (Level; _⊔_)\nopen import Relation.Binary using (Setoid)\nopen import Data.Vec using (Vec; map)\n\nopen import Function using (Congruent) public\n\nprivate\n variable\n a b ℓ₁ ℓ₂ : Level\n\nHomomorphic : (S : Algebra {a} {ℓ₁}) (T : Algebra {b} {ℓ₂})\n → (∥ S ∥ → ∥ T ∥) → Set (a ⊔ ℓ₂)\nHomomorphic S T h = ∀ {arity} → (f : ops Σ arity)\n → (xs : Vec ∥ S ∥ arity)\n → T ⟦ f ⟧ (map h xs) =[ T ] h (S ⟦ f ⟧ xs)\n", "meta": {"hexsha": "997d7cfac7c8f6d48d17b92c199264e01357e9c6", "size": 675, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Fragment/Algebra/Homomorphism/Definitions.agda", "max_stars_repo_name": "yallop/agda-fragment", "max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 18, "max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z", "max_issues_repo_path": "src/Fragment/Algebra/Homomorphism/Definitions.agda", "max_issues_repo_name": "yallop/agda-fragment", "max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z", "max_forks_repo_path": "src/Fragment/Algebra/Homomorphism/Definitions.agda", "max_forks_repo_name": "yallop/agda-fragment", "max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z", "avg_line_length": 28.125, "max_line_length": 70, "alphanum_fraction": 0.5985185185, "num_tokens": 217, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9032942093072239, "lm_q2_score": 0.7122321842389469, "lm_q1q2_score": 0.6433552077052765}} {"text": "module Thesis.Syntax where\n\nopen import Thesis.Types public\nopen import Thesis.Contexts public\n\ndata Const : (τ : Type) → Set where\n unit : Const unit\n lit : ℤ → Const int\n plus : Const (int ⇒ int ⇒ int)\n minus : Const (int ⇒ int ⇒ int)\n cons : ∀ {t1 t2} → Const (t1 ⇒ t2 ⇒ pair t1 t2)\n fst : ∀ {t1 t2} → Const (pair t1 t2 ⇒ t1)\n snd : ∀ {t1 t2} → Const (pair t1 t2 ⇒ t2)\n linj : ∀ {t1 t2} → Const (t1 ⇒ sum t1 t2)\n rinj : ∀ {t1 t2} → Const (t2 ⇒ sum t1 t2)\n match : ∀ {t1 t2 t3} → Const (sum t1 t2 ⇒ (t1 ⇒ t3) ⇒ (t2 ⇒ t3) ⇒ t3)\n\ndata Term (Γ : Context) :\n (τ : Type) → Set where\n -- constants aka. primitives\n const : ∀ {τ} →\n (c : Const τ) →\n Term Γ τ\n var : ∀ {τ} →\n (x : Var Γ τ) →\n Term Γ τ\n app : ∀ {σ τ}\n (s : Term Γ (σ ⇒ τ)) →\n (t : Term Γ σ) →\n Term Γ τ\n -- we use de Bruijn indices, so we don't need binding occurrences.\n abs : ∀ {σ τ}\n (t : Term (σ • Γ) τ) →\n Term Γ (σ ⇒ τ)\n\n-- Weakening\n\nweaken : ∀ {Γ₁ Γ₂ τ} →\n (Γ₁≼Γ₂ : Γ₁ ≼ Γ₂) →\n Term Γ₁ τ →\n Term Γ₂ τ\nweaken Γ₁≼Γ₂ (const c) = const c\nweaken Γ₁≼Γ₂ (var x) = var (weaken-var Γ₁≼Γ₂ x)\nweaken Γ₁≼Γ₂ (app s t) = app (weaken Γ₁≼Γ₂ s) (weaken Γ₁≼Γ₂ t)\nweaken Γ₁≼Γ₂ (abs {σ} t) = abs (weaken (keep σ • Γ₁≼Γ₂) t)\n\n-- Shorthands for nested applications\napp₂ : ∀ {Γ α β γ} →\n Term Γ (α ⇒ β ⇒ γ) →\n Term Γ α → Term Γ β → Term Γ γ\napp₂ f x = app (app f x)\n\napp₃ : ∀ {Γ α β γ δ} →\n Term Γ (α ⇒ β ⇒ γ ⇒ δ) →\n Term Γ α → Term Γ β → Term Γ γ → Term Γ δ\napp₃ f x = app₂ (app f x)\n\napp₄ : ∀ {Γ α β γ δ ε} →\n Term Γ (α ⇒ β ⇒ γ ⇒ δ ⇒ ε) →\n Term Γ α → Term Γ β → Term Γ γ → Term Γ δ →\n Term Γ ε\napp₄ f x = app₃ (app f x)\n\napp₅ : ∀ {Γ α β γ δ ε ζ} →\n Term Γ (α ⇒ β ⇒ γ ⇒ δ ⇒ ε ⇒ ζ) →\n Term Γ α → Term Γ β → Term Γ γ → Term Γ δ →\n Term Γ ε → Term Γ ζ\napp₅ f x = app₄ (app f x)\n\napp₆ : ∀ {Γ α β γ δ ε ζ η} →\n Term Γ (α ⇒ β ⇒ γ ⇒ δ ⇒ ε ⇒ ζ ⇒ η) →\n Term Γ α → Term Γ β → Term Γ γ → Term Γ δ →\n Term Γ ε → Term Γ ζ → Term Γ η\napp₆ f x = app₅ (app f x)\n", "meta": {"hexsha": "96b9b4eda38a03342eae5dfe8c2af427bf8cfd86", "size": 1962, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Thesis/Syntax.agda", "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_issues_repo_path": "Thesis/Syntax.agda", "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_forks_repo_path": "Thesis/Syntax.agda", "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "avg_line_length": 26.16, "max_line_length": 72, "alphanum_fraction": 0.5178389399, "num_tokens": 903, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9032942041005327, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.6433551984793933}} {"text": "{-# OPTIONS --safe #-}\n\nmodule Cubical.Algebra.CommRing.Instances.Polynomials where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Algebra.CommRing\nopen import Cubical.Algebra.Polynomials\n\nprivate\n variable\n ℓ : Level\n\n\nPoly : (CommRing ℓ) → CommRing ℓ\nPoly R = (PolyMod.Poly R) , str\n where\n open CommRingStr --(snd R)\n str : CommRingStr (PolyMod.Poly R)\n 0r str = PolyMod.0P R\n 1r str = PolyMod.1P R\n _+_ str = PolyMod._Poly+_ R\n _·_ str = PolyMod._Poly*_ R\n - str = PolyMod.Poly- R\n isCommRing str = makeIsCommRing (PolyMod.isSetPoly R)\n (PolyMod.Poly+Assoc R)\n (PolyMod.Poly+Rid R)\n (PolyMod.Poly+Inverses R)\n (PolyMod.Poly+Comm R)\n (PolyMod.Poly*Associative R)\n (PolyMod.Poly*Rid R)\n (PolyMod.Poly*LDistrPoly+ R)\n (PolyMod.Poly*Commutative R)\n", "meta": {"hexsha": "a359a454a95bb376620ac769e25c791da32ef222", "size": 1106, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials.agda", "max_stars_repo_name": "AkermanRydbeck/cubical", "max_stars_repo_head_hexsha": "038bcaff93d278c627ccdcec34a4f6df2b56ad5a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials.agda", "max_issues_repo_name": "AkermanRydbeck/cubical", "max_issues_repo_head_hexsha": "038bcaff93d278c627ccdcec34a4f6df2b56ad5a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials.agda", "max_forks_repo_name": "AkermanRydbeck/cubical", "max_forks_repo_head_hexsha": "038bcaff93d278c627ccdcec34a4f6df2b56ad5a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.5151515152, "max_line_length": 66, "alphanum_fraction": 0.5036166365, "num_tokens": 282, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8991213880824791, "lm_q2_score": 0.7154240018510025, "lm_q1q2_score": 0.6432530216117955}} {"text": "module Cats.Limit.Product where\n\nopen import Data.Bool using (Bool ; true ; false)\nopen import Data.Product using (_×_ ; _,_ ; ∃-syntax ; proj₁ ; proj₂)\n\nopen import Cats.Category\nopen import Cats.Category.Cones using (Cones ; Cone ; HasObj-Cone)\nopen import Cats.Category.Discrete as Discrete using (Discrete)\nopen import Cats.Functor using (Functor)\nopen import Cats.Limit\nopen import Cats.Util.Conv\n\n\nmodule _ {lo la l≈ li}\n {Cat : Category lo la l≈}\n {I : Set li} {O : I → Category.Obj Cat}\n where\n\n open Category Cat\n open Product using (isProduct)\n open Cone using (arr)\n\n\n F : Functor (Discrete I) Cat\n F = Discrete.functor I O\n\n\n private\n module Cones = Category (Cones F)\n\n\n productData→cone : ∀ {P} → (∀ i → P ⇒ O i) → Cone F\n productData→cone {P} proj = record\n { Apex = P\n ; arr = proj\n ; commute = λ { Discrete.id → ≈.sym id-l }\n }\n\n\n cone→productData : Cone F → ∃[ P ] (∀ i → P ⇒ O i)\n cone→productData c = c ᴼ , arr c\n\n\n terminal : ∀ {P} {proj : ∀ i → P ⇒ O i}\n → IsProduct O P proj\n → Cones.IsTerminal (productData→cone proj)\n terminal {P} {proj} isProduct c = record\n { arr = record\n { θ = θ\n ; commute = commute\n }\n ; unique = λ where\n {record { θ = θ′ ; commute = commute′ }} _ →\n ∃!′.unique prod (λ i → ≈.sym (commute′ i))\n }\n where\n prod : ∃![ u ] (∀ i → arr c i ≈ proj i ∘ u)\n prod = isProduct (arr c)\n\n θ : c ᴼ ⇒ P\n θ = prod ⃗\n\n commute : ∀ j → arr (productData→cone proj) j ∘ θ ≈ arr c j\n commute j = ≈.sym (∃!′.prop prod j)\n\n\n product : ∀ {c}\n → Cones.IsTerminal c\n → let (P , proj) = cone→productData c\n in IsProduct O P proj\n product {c} term {X} x = record\n { arr = f\n ; prop = prop\n ; unique = uniq\n }\n where\n open Cats.Category.Cones._⇒_ using (θ ; commute)\n\n P = proj₁ (cone→productData c)\n proj = proj₂ (cone→productData c)\n\n u : Cones.∃! (productData→cone x) c\n u = term (productData→cone x)\n\n f : X ⇒ P\n f = θ (u ⃗)\n\n prop : ∀ i → x i ≈ proj i ∘ f\n prop i = ≈.sym (commute (u ⃗) _)\n\n uniq : IsUniqueSuchThat (λ g → ∀ i → x i ≈ proj i ∘ g) f\n uniq {g} eq = Cones.∃!′.unique u {f′} _\n where\n f′ : productData→cone x Cones.⇒ c\n f′ = record\n { θ = g\n ; commute = λ i → ≈.sym (eq i)\n }\n\n\n product→limit : Product O → Limit F\n product→limit P = record\n { cone = productData→cone (Product.proj P)\n ; isLimit = terminal (isProduct P)\n }\n\n\n limit→product : Limit F → Product O\n limit→product L\n = let (P , proj) = cone→productData (L ᴼ) in\n record\n { prod = P\n ; proj = proj\n ; isProduct = product (Limit.isLimit L)\n }\n\n\n product-unique : (P Q : Product O) → P ᴼ ≅ Q ᴼ\n product-unique P Q = obj-unique (product→limit P) (product→limit Q)\n", "meta": {"hexsha": "d33d5f7ad65785ce9751924e87dbad8955a59e82", "size": 2926, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Limit/Product.agda", "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cats/Limit/Product.agda", "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cats/Limit/Product.agda", "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.3833333333, "max_line_length": 69, "alphanum_fraction": 0.540328093, "num_tokens": 977, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8991213718636754, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.6432530100084741}} {"text": "module Singleton where\n\nopen import Level\nopen import Data.Unit\nopen import Data.Product\nopen import Function \nopen import Relation.Binary\nopen import Function.Inverse\nopen import Function.Equality as FE\nopen import Relation.Binary.PropositionalEquality as P\n\nopen import Pi using (⟦_⟧; _⟷_ )\n\nembed₁ : Set → Set\nembed₁ b = Σ b (λ _ → ⊤)\n\nB-to-Σ⊤ : {B : Set} → B → embed₁ B\nB-to-Σ⊤ v = (v , tt)\n\nΣ⊤-to-B : {B : Set} → embed₁ B → B\nΣ⊤-to-B (v , _) = v\n\nBΣ₁ : ∀ {b} → Inverse (P.setoid b) (P.setoid (embed₁ b))\nBΣ₁ = record { \n to = record { _⟨$⟩_ = B-to-Σ⊤; cong = P.cong B-to-Σ⊤ }\n ; from = record { _⟨$⟩_ = Σ⊤-to-B; cong = P.cong Σ⊤-to-B }\n ; inverse-of = record { left-inverse-of = λ _ → refl\n ; right-inverse-of = λ x → refl } } \n\ndata Singleton {c : Level} {A : Set c} : A → Set c where\n singleton : (x : A) -> Singleton x\n\n-- That a Singleton type is a setoid is not needed, but here is the proof anyways.\ndata _∼_ {c : Level} {A : Set c} {v : A} (x : Singleton v) (y : Singleton v) : Set c where\n uniq : x ∼ y\n\n∼Equiv : {c : Level} {A : Set c} {v : A} → IsEquivalence {_} {_} {Singleton v} _∼_\n∼Equiv {v = v } = record { \n refl = uniq\n ; sym = λ _ → uniq\n ; trans = λ _ _ → uniq }\n \nSingSetoid : {c c : Level} → (A : Setoid c c) → (Setoid.Carrier A) → Setoid c c\nSingSetoid A v = record { \n Carrier = Singleton v\n ; _≈_ = _∼_ \n ; isEquivalence = ∼Equiv }\n\n-- We can map a type to its Σ of Singletons and back.\nembed₂ : Set → Set\nembed₂ b = Σ b Singleton\n\nB-to-ΣS : {B : Set} → B → embed₂ B\nB-to-ΣS v = (v , singleton v)\n\nΣS-to-B : {B : Set} → embed₂ B → B\nΣS-to-B x = proj₁ x\n\nright-inverse : ∀ {c} {b : Set c} → (x : Σ b (Singleton {A = b})) → (proj₁ x , singleton (proj₁ x)) ≡ x\nright-inverse (v , singleton .v) = refl\n\nBΣ₂ : ∀ {b} → Inverse (P.setoid b) (P.setoid (embed₂ b))\nBΣ₂ = record { \n to = record { _⟨$⟩_ = B-to-ΣS; cong = P.cong B-to-ΣS }\n ; from = record { _⟨$⟩_ = ΣS-to-B; cong = P.cong ΣS-to-B }\n ; inverse-of = record { left-inverse-of = λ x → refl\n ; right-inverse-of = right-inverse } }\n\n-- A generalized idea of a permutation: a bijection between any two types\nPermutation : Set → Set -> Set\nPermutation a b = Inverse (P.setoid a) (P.setoid b)\n\n-- Now, what we really want is to interpret Pi combinators as\n-- permutations. We need a refined version of embed₂ which \n-- allows us to use a permutation to transport things.\n\nembed₃ : {l : Level} → (S T : Setoid l l) → Inverse S T → Setoid l l\nembed₃ S T f = record { \n Carrier = Σ A (λ b → Singleton (to f ⟨$⟩ b))\n ; _≈_ = _≡_\n ; isEquivalence = P.isEquivalence }\n where open Inverse {From = S} {T}\n A = Setoid.Carrier S\n", "meta": {"hexsha": "4e98801b39ea5719cac4fe22a97dcc147386add2", "size": 2880, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Singleton.agda", "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_issues_repo_path": "agda/Singleton.agda", "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_forks_repo_path": "agda/Singleton.agda", "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "avg_line_length": 34.2857142857, "max_line_length": 103, "alphanum_fraction": 0.5538194444, "num_tokens": 1002, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8991213664574069, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.6432530061406999}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Well-founded induction\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary\n\nmodule Induction.WellFounded where\n\nopen import Data.Product\nopen import Function\nopen import Induction\nopen import Level\nopen import Relation.Unary\n\n-- When using well-founded recursion you can recurse arbitrarily, as\n-- long as the arguments become smaller, and \"smaller\" is\n-- well-founded.\n\nWfRec : ∀ {a r} {A : Set a} → Rel A r → ∀ {ℓ} → RecStruct A ℓ _\nWfRec _<_ P x = ∀ y → y < x → P y\n\n-- The accessibility predicate: x is accessible if everything which is\n-- smaller than x is also accessible (inductively).\n\ndata Acc {a ℓ} {A : Set a} (_<_ : Rel A ℓ) (x : A) : Set (a ⊔ ℓ) where\n acc : (rs : WfRec _<_ (Acc _<_) x) → Acc _<_ x\n\n-- The accessibility predicate encodes what it means to be\n-- well-founded; if all elements are accessible, then _<_ is\n-- well-founded.\n\nWellFounded : ∀ {a ℓ} {A : Set a} → Rel A ℓ → Set _\nWellFounded _<_ = ∀ x → Acc _<_ x\n\nWell-founded = WellFounded\n{-# WARNING_ON_USAGE Well-founded\n\"Warning: Well-founded was deprecated in v0.15.\nPlease use WellFounded instead.\"\n#-}\n\n------------------------------------------------------------------------\n-- Well-founded induction for the subset of accessible elements:\n\nmodule Some {a lt} {A : Set a} {_<_ : Rel A lt} {ℓ} where\n\n wfRecBuilder : SubsetRecursorBuilder (Acc _<_) (WfRec _<_ {ℓ = ℓ})\n wfRecBuilder P f x (acc rs) = λ y y ⟦ e₁ ⟧ ρ\n\n⟦_⟧n_ : ∀ {a} {A : Set a} {{_ : Monoid A}} → List Nat → (Nat → A) → A\n⟦ xs ⟧n ρ = mconcat (map ρ xs)\n\nmap/++ : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) (xs ys : List A) → map f (xs ++ ys) ≡ map f xs ++ map f ys\nmap/++ f [] ys = refl\nmap/++ f (x ∷ xs) ys = f x ∷_ $≡ map/++ f xs ys\n\nmodule _ {a} {A : Set a} {{Mon : Monoid A}} {{Laws : MonoidLaws A}} where\n\n mconcat/++ : (xs ys : List A) → mconcat (xs ++ ys) ≡ mconcat xs <> mconcat ys\n mconcat/++ [] ys = sym (idLeft _)\n mconcat/++ (x ∷ xs) ys = x <>_ $≡ mconcat/++ xs ys ⟨≡⟩ <>assoc x _ _\n\n sound : ∀ e (ρ : Nat → A) → ⟦ e ⟧ ρ ≡ ⟦ flatten e ⟧n ρ\n sound (var x) ρ = sym (idRight (ρ x))\n sound ε ρ = refl\n sound (e ⊕ e₁) ρ = _<>_ $≡ sound e ρ *≡ sound e₁ ρ ⟨≡⟩ʳ\n mconcat $≡ map/++ ρ (flatten e) (flatten e₁) ⟨≡⟩\n mconcat/++ (map ρ (flatten e)) _\n\n proof : ∀ e e₁ (ρ : Nat → A) → flatten e ≡ flatten e₁ → ⟦ e ⟧ ρ ≡ ⟦ e₁ ⟧ ρ\n proof e e₁ ρ nfeq = eraseEquality $ sound e ρ ⟨≡⟩ (⟦_⟧n ρ) $≡ nfeq ⟨≡⟩ʳ sound e₁ ρ\n\n\n", "meta": {"hexsha": "84b8ee1323af5716ab11a4f01b540c92a8bf72e8", "size": 1274, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Tactic/Monoid/Proofs.agda", "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Tactic/Monoid/Proofs.agda", "max_issues_repo_name": "lclem/agda-prelude", "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Tactic/Monoid/Proofs.agda", "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.5263157895, "max_line_length": 111, "alphanum_fraction": 0.4913657771, "num_tokens": 596, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473647220786, "lm_q2_score": 0.7371581626286834, "lm_q1q2_score": 0.6430579805525014}} {"text": "{-\n\nCubical Agda - A Dependently Typed PL with Univalence and HITs\n==============================================================\n Anders Mörtberg\n Every Proof Assistant - September 17, 2020\n\n\nLink to slides: https://staff.math.su.se/anders.mortberg/slides/EPA2020.pdf\n\nLink to video: https://vimeo.com/459020971\n\n-}\n\n-- To make Agda cubical add the following options\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Talks.EPA2020 where\n\n-- The \"Foundations\" package contain a lot of important results (in\n-- particular the univalence theorem)\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Univalence\n\nopen import Cubical.Data.Int\nopen import Cubical.Data.Prod.Base\n\n\n-- The interval in Cubical Agda is written I and the endpoints i0 and i1.\n\napply0 : (A : Type) (p : I → A) → A\napply0 A p = p i0\n\n-- We omit the universe level ℓ for simplicity in this talk. In the\n-- library everything is maximally universe polymorphic.\n\n\n-- We can write functions out of the interval using λ-abstraction:\nrefl' : {A : Type} (x : A) → x ≡ x\nrefl' x = λ i → x\n-- In fact, x ≡ y is short for PathP (λ _ → A) x y\n\nrefl'' : {A : Type} (x : A) → PathP (λ _ → A) x x\nrefl'' x = λ _ → x\n\n-- In general PathP A x y has A : I → Type, x : A i0 and y : A i1\n-- PathP = Dependent paths (Path over a Path)\n\n-- We cannot pattern-match on interval variables as I is not inductively defined\n-- foo : {A : Type} → I → A\n-- foo r = {!r!} -- Try typing C-c C-c\n\n-- cong has a direct proof\ncong' : {A B : Type} (f : A → B) {x y : A} → x ≡ y → f x ≡ f y\ncong' f p i = f (p i)\n\n-- function extensionality also has a direct proof.\n-- It also has computational content: swap the arguments.\nfunExt' : {A B : Type} {f g : A → B} (p : (x : A) → f x ≡ g x) → f ≡ g\nfunExt' p i x = p x i\n\n-- Transport is more complex as ≡ isn't inductively defined (so we\n-- can't define it by pattern-matching on p)\ntransport' : {A B : Type} → A ≡ B → A → B\ntransport' p a = transp (λ i → p i) i0 a\n\n-- This lets us define subst (which is called \"transport\" in the HoTT book)\nsubst' : {A : Type} (P : A → Type) {x y : A} (p : x ≡ y) → P x → P y\nsubst' P p pa = transport (λ i → P (p i)) pa\n\n-- The transp operation reduces differently for different types\n-- formers. For paths it reduces to another primitive operation called\n-- hcomp.\n\n-- We can also define the J eliminator (aka path induction)\nJ' : {A : Type} {B : A → Type} {x : A}\n (P : (z : A) → x ≡ z → Type)\n (d : P x refl) {y : A} (p : x ≡ y) → P y p\nJ' P d p = transport (λ i → P (p i) (λ j → p (i ∧ j))) d\n\n-- So J is provable, but it doesn't satisfy computation rule\n-- definitionally. This is almost never a problem in practice as the\n-- cubical primitives satisfy many new definitional equalities.\n\n\n\n-- Another key concept in HoTT/UF is the Univalence Axiom. In Cubical\n-- Agda this is provable, we hence refer to it as the Univalence\n-- Theorem.\n\n-- The univalence theorem: equivalences of types give paths of types\nua' : {A B : Type} → A ≃ B → A ≡ B\nua' = ua\n\n-- Any isomorphism of types gives rise to an equivalence\nisoToEquiv' : {A B : Type} → Iso A B → A ≃ B\nisoToEquiv' = isoToEquiv\n\n-- And hence to a path\nisoToPath' : {A B : Type} → Iso A B → A ≡ B\nisoToPath' e = ua' (isoToEquiv' e)\n\n-- ua satisfies the following computation rule\n-- This suffices to be able to prove the standard formulation of univalence.\nuaβ' : {A B : Type} (e : A ≃ B) (x : A)\n → transport (ua' e) x ≡ fst e x\nuaβ' e x = transportRefl (equivFun e x)\n\n\n\n-- Time for an example!\n\n-- Booleans\ndata Bool : Type where\n false true : Bool\n\nnot : Bool → Bool\nnot false = true\nnot true = false\n\nnotPath : Bool ≡ Bool\nnotPath = isoToPath' (iso not not rem rem)\n where\n rem : (b : Bool) → not (not b) ≡ b\n rem false = refl\n rem true = refl\n\n_ : transport notPath true ≡ false\n_ = refl\n\n\n-- Another example, integers:\n\nsucPath : Int ≡ Int\nsucPath = isoToPath' (iso sucInt predInt sucPred predSuc)\n\n_ : transport sucPath (pos 0) ≡ pos 1\n_ = refl\n\n_ : transport (sucPath ∙ sucPath) (pos 0) ≡ pos 2\n_ = refl\n\n_ : transport (sym sucPath) (pos 0) ≡ negsuc 0\n_ = refl\n\n\n\n-----------------------------------------------------------------------------\n-- Higher inductive types\n\n-- The following definition of finite multisets is due to Vikraman\n-- Choudhury and Marcelo Fiore.\n\ninfixr 5 _∷_\n\ndata FMSet (A : Type) : Type where\n [] : FMSet A\n _∷_ : (x : A) → (xs : FMSet A) → FMSet A\n comm : (x y : A) (xs : FMSet A) → x ∷ y ∷ xs ≡ y ∷ x ∷ xs\n-- trunc : (xs ys : FMSet A) (p q : xs ≡ ys) → p ≡ q\n\n-- We need to add the trunc constructor for FMSets to be sets, omitted\n-- here for simplicity.\n\n_++_ : ∀ {A : Type} (xs ys : FMSet A) → FMSet A\n[] ++ ys = ys\n(x ∷ xs) ++ ys = x ∷ xs ++ ys\ncomm x y xs i ++ ys = comm x y (xs ++ ys) i\n-- trunc xs zs p q i j ++ ys =\n-- trunc (xs ++ ys) (zs ++ ys) (cong (_++ ys) p) (cong (_++ ys) q) i j\n\nunitr-++ : {A : Type} (xs : FMSet A) → xs ++ [] ≡ xs\nunitr-++ [] = refl\nunitr-++ (x ∷ xs) = cong (x ∷_) (unitr-++ xs)\nunitr-++ (comm x y xs i) j = comm x y (unitr-++ xs j) i\n-- unitr-++ (trunc xs ys x y i j) = {!!}\n\n\n-- This is a special case of set quotients! Very useful for\n-- programming and set level mathematics\n\ndata _/_ (A : Type) (R : A → A → Type) : Type where\n [_] : A → A / R\n eq/ : (a b : A) → R a b → [ a ] ≡ [ b ]\n trunc : (a b : A / R) (p q : a ≡ b) → p ≡ q\n\n-- Proving that they are effective ((a b : A) → [ a ] ≡ [ b ] → R a b)\n-- requires univalence for propositions.\n\n\n-------------------------------------------------------------------------\n-- Topological examples of things that are not sets\n\n-- We can define the circle as the following simple data declaration:\ndata S¹ : Type where\n base : S¹\n loop : base ≡ base\n\n-- We can write functions on S¹ using pattern-matching equations:\ndouble : S¹ → S¹\ndouble base = base\ndouble (loop i) = (loop ∙ loop) i\n\nhelix : S¹ → Type\nhelix base = Int\nhelix (loop i) = sucPathInt i\n\nΩS¹ : Type\nΩS¹ = base ≡ base\n\nwinding : ΩS¹ → Int\nwinding p = subst helix p (pos 0)\n\n_ : winding (λ i → double ((loop ∙ loop) i)) ≡ pos 4\n_ = refl\n\n\n-- We can define the Torus as:\ndata Torus : Type where\n point : Torus\n line1 : point ≡ point\n line2 : point ≡ point\n square : PathP (λ i → line1 i ≡ line1 i) line2 line2\n\n-- And prove that it is equivalent to two circle:\nt2c : Torus → S¹ × S¹\nt2c point = (base , base)\nt2c (line1 i) = (loop i , base)\nt2c (line2 j) = (base , loop j)\nt2c (square i j) = (loop i , loop j)\n\nc2t : S¹ × S¹ → Torus\nc2t (base , base) = point\nc2t (loop i , base) = line1 i\nc2t (base , loop j) = line2 j\nc2t (loop i , loop j) = square i j\n\nc2t-t2c : (t : Torus) → c2t (t2c t) ≡ t\nc2t-t2c point = refl\nc2t-t2c (line1 _) = refl\nc2t-t2c (line2 _) = refl\nc2t-t2c (square _ _) = refl\n\nt2c-c2t : (p : S¹ × S¹) → t2c (c2t p) ≡ p\nt2c-c2t (base , base) = refl\nt2c-c2t (base , loop _) = refl\nt2c-c2t (loop _ , base) = refl\nt2c-c2t (loop _ , loop _) = refl\n\n-- Using univalence we get the following equality:\nTorus≡S¹×S¹ : Torus ≡ S¹ × S¹\nTorus≡S¹×S¹ = isoToPath' (iso t2c c2t t2c-c2t c2t-t2c)\n\n\nwindingTorus : point ≡ point → Int × Int\nwindingTorus l = ( winding (λ i → proj₁ (t2c (l i)))\n , winding (λ i → proj₂ (t2c (l i))))\n\n_ : windingTorus (line1 ∙ sym line2) ≡ (pos 1 , negsuc 0)\n_ = refl\n\n-- We have many more topological examples, including Klein bottle, RP^n,\n-- higher spheres, suspensions, join, wedges, smash product:\nopen import Cubical.HITs.KleinBottle\nopen import Cubical.HITs.RPn\nopen import Cubical.HITs.S2\nopen import Cubical.HITs.S3\nopen import Cubical.HITs.Susp\nopen import Cubical.HITs.Join\nopen import Cubical.HITs.Wedge\nopen import Cubical.HITs.SmashProduct\n\n-- There's also a proof of the \"3x3 lemma\" for pushouts in less than\n-- 200LOC. In HoTT-Agda this took about 3000LOC. For details see:\n-- https://github.com/HoTT/HoTT-Agda/tree/master/theorems/homotopy/3x3\nopen import Cubical.HITs.Pushout\n\n-- We also defined the Hopf fibration and proved that its total space\n-- is S³ in about 300LOC:\nopen import Cubical.HITs.Hopf\n\n-- There is also some integer cohomology:\nopen import Cubical.ZCohomology.Everything\n-- To compute cohomology groups of various spaces we need a bunch of\n-- interesting theorems: Freudenthal suspension theorem,\n-- Mayer-Vietoris sequence...\nopen import Cubical.Homotopy.Freudenthal\nopen import Cubical.ZCohomology.MayerVietorisUnreduced\n\n\n-------------------------------------------------------------------------\n-- The structure identity principle\n\n-- A more efficient version of finite multisets based on association lists\nopen import Cubical.HITs.AssocList.Base\n\n-- data AssocList (A : Type) : Type where\n-- ⟨⟩ : AssocList A\n-- ⟨_,_⟩∷_ : (a : A) (n : ℕ) (xs : AssocList A) → AssocList A\n-- per : (a b : A) (m n : ℕ) (xs : AssocList A)\n-- → ⟨ a , m ⟩∷ ⟨ b , n ⟩∷ xs ≡ ⟨ b , n ⟩∷ ⟨ a , m ⟩∷ xs\n-- agg : (a : A) (m n : ℕ) (xs : AssocList A)\n-- → ⟨ a , m ⟩∷ ⟨ a , n ⟩∷ xs ≡ ⟨ a , m + n ⟩∷ xs\n-- del : (a : A) (xs : AssocList A) → ⟨ a , 0 ⟩∷ xs ≡ xs\n-- trunc : (xs ys : AssocList A) (p q : xs ≡ ys) → p ≡ q\n\n\n-- Programming and proving is more complicated with AssocList compared\n-- to FMSet. This kind of example occurs everywhere in programming and\n-- mathematics: one representation is easier to work with, but not\n-- efficient, while another is efficient but difficult to work with.\n\n-- Solution: substitute using univalence\nsubstIso : {A B : Type} (P : Type → Type) (e : Iso A B) → P A → P B\nsubstIso P e = subst P (isoToPath e)\n\n-- Can transport for example Monoid structure from FMSet to AssocList\n-- this way, but the achieved Monoid structure is not very efficient\n-- to work with. A better solution is to prove that FMSet and\n-- AssocList are equal *as monoids*, but how to do this?\n\n-- Solution: structure identity principle (SIP)\n-- This is a very useful consequence of univalence\nopen import Cubical.Foundations.SIP\n\nsip' : {ℓ : Level} {S : Type ℓ → Type ℓ} {ι : StrEquiv S ℓ}\n (θ : UnivalentStr S ι) (A B : TypeWithStr ℓ S) → A ≃[ ι ] B → A ≡ B\nsip' = sip\n\n-- The tricky thing is to prove that (S,ι) is a univalent structure.\n-- Luckily we provide automation for this in the library, see for example:\nopen import Cubical.Algebra.Monoid.Base\n\n-- Another cool application of the SIP: matrices represented as\n-- functions out of pairs of Fin's and vectors are equal as abelian\n-- groups:\nopen import Cubical.Algebra.Matrix\n\n\n-- The end, back to slides!\n", "meta": {"hexsha": "12b37d9c29d3ed147e74cbf6e28996aee663280e", "size": 10535, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Talks/EPA2020.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Talks/EPA2020.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/Talks/EPA2020.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.8040935673, "max_line_length": 80, "alphanum_fraction": 0.628761272, "num_tokens": 3549, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8652240964782012, "lm_q2_score": 0.7431680143008301, "lm_q1q2_score": 0.6430068737049347}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Functions.Definition\nopen import Groups.Definition\nopen import Groups.Abelian.Definition\nopen import Setoids.Setoids\nopen import Rings.Definition\nopen import Sets.FinSet.Definition\nopen import Vectors\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import Sets.EquivalenceRelations\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import Modules.Definition\n\nmodule Modules.Span {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+R_ : A → A → A} {_*_ : A → A → A} {R : Ring S _+R_ _*_} {m n : _} {M : Set m} {T : Setoid {m} {n} M} {_+_ : M → M → M} {G' : Group T _+_} {G : AbelianGroup G'} {_·_ : A → M → M} (mod : Module R G _·_) where\n\nopen Group G'\nopen Setoid T\nopen Equivalence eq\n\n_=V_ : {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} (G : Group S _+_) {n1 : ℕ} → Rel {a} {b ⊔ n} (Vec A n1)\n_=V_ G [] [] = True'\n_=V_ {S = S} G (x ,- xs) (y ,- ys) = (Setoid._∼_ S x y) && (_=V_ G xs ys)\n\ndot : {n : ℕ} → (Vec M n) → (Vec A n) → M\ndot [] [] = 0G\ndot (v ,- vs) (x ,- xs) = (x · v) + (dot vs xs)\n\nSpans : {c : _} {C : Set c} (f : C → M) → Set (a ⊔ m ⊔ n ⊔ c)\nSpans {C = C} f = (m : M) → Sg ℕ (λ n → Sg ((Vec C n) && (Vec A n)) (λ t → (dot (vecMap f (_&&_.fst t)) (_&&_.snd t)) ∼ m))\n\nIndependent : {c : _} {C : Set c} (f : C → M) → Set (a ⊔ b ⊔ n ⊔ c)\nIndependent {C = C} f = {n : ℕ} → (r : Vec C n) → ({a b : ℕ} → (a\n\n------------------------------------------\n-- Negation\n\n¬_ : ∀{ℓ} → Stmt{ℓ} → Stmt\n¬_ {ℓ} T = (T → ⊥)\n\n[¬]-intro : ∀{ℓ}{P : Stmt{ℓ}} → (P → ⊥) → (¬ P)\n[¬]-intro = id\n\n[¬]-elim : ∀{ℓ}{P : Stmt{ℓ}} → (¬ P) → (P → ⊥) -- written like (P → (¬ P) → ⊥) looks like a [⊥]-intro\n[¬]-elim = id\n\n¬¬_ : ∀{ℓ} → Stmt{ℓ} → Stmt\n¬¬ p = ¬(¬ p)\n\n------------------------------------------\n-- Exclusive disjunction (XOR)\n\ndata _⊕_ {ℓ₁ ℓ₂} (P : Stmt{ℓ₁}) (Q : Stmt{ℓ₂}) : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where\n [⊕]-introₗ : P → (¬ Q) → (P ⊕ Q)\n [⊕]-introᵣ : Q → (¬ P) → (P ⊕ Q)\n\n------------------------------------------\n-- Negative disjunction (NOR)\n\n_⊽_ : ∀{ℓ₁ ℓ₂} → Stmt{ℓ₁} → Stmt{ℓ₂} → Stmt\np ⊽ q = (¬ p) ∧ (¬ q)\n\n[⊽]-intro : ∀{ℓ₁ ℓ₂}{P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} → (¬ P) → (¬ Q) → (P ⊽ Q)\n[⊽]-intro = [∧]-intro\n\n[⊽]-elimₗ : ∀{ℓ₁ ℓ₂}{P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} → (P ⊽ Q) → ¬ P\n[⊽]-elimₗ = [∧]-elimₗ\n\n[⊽]-elimᵣ : ∀{ℓ₁ ℓ₂}{P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} → (P ⊽ Q) → ¬ Q\n[⊽]-elimᵣ = [∧]-elimᵣ\n\n------------------------------------------\n-- Negative conjunction (NAND)\n\n-- data _⊼_ {P : Stmt} {Q : Stmt} : Stmt where\n-- [⊼]-intro ¬(P ∧ Q) → (P ⊼ Q)\n-- \n-- [⊼]-elim : {P Q : Stmt} → (P ⨯ Q ⨯ (P ⊼ Q)) → ⊥\n-- [⊼]-elim(p , q , nand)\n", "meta": {"hexsha": "3e0d402ebf25a9271d818772403035a275fc9074", "size": 3619, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Logic/Propositional.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Logic/Propositional.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Logic/Propositional.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.9668874172, "max_line_length": 101, "alphanum_fraction": 0.4161370544, "num_tokens": 1741, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672181749422, "lm_q2_score": 0.7956581024858786, "lm_q1q2_score": 0.642945229494117}} {"text": "{-# OPTIONS --without-K #-}\nmodule Equivalence where\n\nopen import Homotopy\nopen import PathOperations\nopen import Types\n\ninfix 1 _≃_\n\nqinv : ∀ {a b} {A : Set a} {B : Set b}\n (f : A → B) → Set _\nqinv {A = A} {B = B} f =\n Σ (B → A) λ g → (f ∘ g ∼ id) × (g ∘ f ∼ id)\n\nisequiv : ∀ {a b} {A : Set a} {B : Set b}\n (f : A → B) → Set _\nisequiv {A = A} {B = B} f\n = (Σ (B → A) λ g → f ∘ g ∼ id)\n × (Σ (B → A) λ h → h ∘ f ∼ id)\n\n_≃_ : ∀ {a b} (A : Set a) (B : Set b) → Set _\nA ≃ B = Σ (A → B) isequiv\n\nqi→eq : ∀ {a b} {A : Set a} {B : Set b}\n {f : A → B} → qinv f → isequiv f\nqi→eq (g , p , q) = (g , p) , (g , q)\n\neq→qi : ∀ {a b} {A : Set a} {B : Set b}\n {f : A → B} → isequiv f → qinv f\neq→qi {f = f} ((g , p) , (h , q)) =\n g , p , λ _ → q _ ⁻¹ · ap h (p _) · q _\n\n≡→eq : ∀ {ℓ} {A : Set ℓ} {B : Set ℓ} → A ≡ B → A ≃ B\n≡→eq p\n = tr id p\n , (tr id (p ⁻¹) , λ b → J\n (λ _ B p → (b : B) → tr id p (tr id (p ⁻¹) b) ≡ b)\n (λ _ _ → refl)\n _ _ p b)\n , (tr id (p ⁻¹) , λ a → J\n (λ A _ p → (a : A) → tr id (p ⁻¹) (tr id p a) ≡ a)\n (λ _ _ → refl)\n _ _ p a)\n\nrefl-equiv : ∀ {a} {A : Set a} → A ≃ A\nrefl-equiv = id , (id , λ _ → refl) , (id , λ _ → refl)\n\nsym-equiv : ∀ {a b} {A : Set a} {B : Set b} →\n A ≃ B → B ≃ A\nsym-equiv (f , (g , p) , (h , q))\n = g\n , (f , λ _ → q _ ⁻¹ · ap h (p _) · q _)\n , (f , p)\n\ntrans-equiv : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} →\n A ≃ B → B ≃ C → A ≃ C\ntrans-equiv\n (f₁ , (g₁ , p₁) , (h₁ , q₁)) (f₂ , (g₂ , p₂) , (h₂ , q₂))\n = f₂ ∘ f₁\n , (g₁ ∘ g₂ , λ _ → ap f₂ (p₁ _) · p₂ _)\n , (h₁ ∘ h₂ , λ _ → ap h₁ (q₂ _) · q₁ _)\n", "meta": {"hexsha": "33154bffbe1e68e0e32dc857033a0e66e4ea8eb0", "size": 1589, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Equivalence.agda", "max_stars_repo_name": "vituscze/HoTT-lectures", "max_stars_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Equivalence.agda", "max_issues_repo_name": "vituscze/HoTT-lectures", "max_issues_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Equivalence.agda", "max_forks_repo_name": "vituscze/HoTT-lectures", "max_forks_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.6290322581, "max_line_length": 61, "alphanum_fraction": 0.3977344242, "num_tokens": 821, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757869884059266, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.642932324499392}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import lib.Basics\nopen import lib.types.Empty\nopen import lib.types.Group\nopen import lib.types.Word\nopen import lib.groups.GeneratedGroup\nopen import lib.groups.Homomorphism\n\nmodule lib.groups.FreeGroup where\n\nmodule FreeGroup {i} (A : Type i) where\n\n private\n module Gen = GeneratedGroup A empty-rel\n open Gen hiding (GenGroup) public\n\n FreeGroup : Group i\n FreeGroup = Gen.GenGroup\n\n module Freeness {j} (G : Group j) where\n\n private\n module G = Group G\n module HE = HomomorphismEquiv G\n\n extend-equiv : (A → G.El) ≃ (FreeGroup →ᴳ G)\n extend-equiv =\n HE.extend-equiv ∘e every-function-respects-empty-rel-equiv A G\n\n extend : (A → G.El) → (FreeGroup →ᴳ G)\n extend = –> extend-equiv\n\n extend-is-equiv : is-equiv extend\n extend-is-equiv = snd extend-equiv\n", "meta": {"hexsha": "ceaa2d4f7f22b89f6925c873bbf2701d462a32c1", "size": 846, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/groups/FreeGroup.agda", "max_stars_repo_name": "AntoineAllioux/HoTT-Agda", "max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 294, "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_issues_repo_path": "core/lib/groups/FreeGroup.agda", "max_issues_repo_name": "AntoineAllioux/HoTT-Agda", "max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 31, "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_forks_repo_path": "core/lib/groups/FreeGroup.agda", "max_forks_repo_name": "AntoineAllioux/HoTT-Agda", "max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 50, "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "avg_line_length": 23.5, "max_line_length": 68, "alphanum_fraction": 0.6891252955, "num_tokens": 232, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9372107861416413, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.6428792279816586}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- This module constructs the unit of the monoidal structure on\n-- R-modules, and similar for weaker module-like structures.\n-- The intended universal property is that the maps out of the tensor\n-- unit into M are isomorphic to the elements of M.\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Algebra.Module.Construct.TensorUnit where\n\nopen import Algebra.Bundles\nopen import Algebra.Module.Bundles\nopen import Level\n\nprivate\n variable\n c ℓ : Level\n\nleftSemimodule : {R : Semiring c ℓ} → LeftSemimodule R c ℓ\nleftSemimodule {R = semiring} = record\n { Carrierᴹ = Carrier\n ; _≈ᴹ_ = _≈_\n ; _+ᴹ_ = _+_\n ; _*ₗ_ = _*_\n ; 0ᴹ = 0#\n ; isLeftSemimodule = record\n { +ᴹ-isCommutativeMonoid = +-isCommutativeMonoid\n ; isPreleftSemimodule = record\n { *ₗ-cong = *-cong\n ; *ₗ-zeroˡ = zeroˡ\n ; *ₗ-distribʳ = distribʳ\n ; *ₗ-identityˡ = *-identityˡ\n ; *ₗ-assoc = *-assoc\n ; *ₗ-zeroʳ = zeroʳ\n ; *ₗ-distribˡ = distribˡ\n }\n }\n } where open Semiring semiring\n\nrightSemimodule : {R : Semiring c ℓ} → RightSemimodule R c ℓ\nrightSemimodule {R = semiring} = record\n { Carrierᴹ = Carrier\n ; _≈ᴹ_ = _≈_\n ; _+ᴹ_ = _+_\n ; _*ᵣ_ = _*_\n ; 0ᴹ = 0#\n ; isRightSemimodule = record\n { +ᴹ-isCommutativeMonoid = +-isCommutativeMonoid\n ; isPrerightSemimodule = record\n { *ᵣ-cong = *-cong\n ; *ᵣ-zeroʳ = zeroʳ\n ; *ᵣ-distribˡ = distribˡ\n ; *ᵣ-identityʳ = *-identityʳ\n ; *ᵣ-assoc = *-assoc\n ; *ᵣ-zeroˡ = zeroˡ\n ; *ᵣ-distribʳ = distribʳ\n }\n }\n } where open Semiring semiring\n\nbisemimodule : {R : Semiring c ℓ} → Bisemimodule R R c ℓ\nbisemimodule {R = semiring} = record\n { isBisemimodule = record\n { +ᴹ-isCommutativeMonoid = +-isCommutativeMonoid\n ; isPreleftSemimodule =\n LeftSemimodule.isPreleftSemimodule leftSemimodule\n ; isPrerightSemimodule =\n RightSemimodule.isPrerightSemimodule rightSemimodule\n ; *ₗ-*ᵣ-assoc = *-assoc\n }\n } where open Semiring semiring\n\nsemimodule : {R : CommutativeSemiring c ℓ} → Semimodule R c ℓ\nsemimodule {R = commutativeSemiring} = record\n { isSemimodule = record\n { isBisemimodule = Bisemimodule.isBisemimodule bisemimodule\n }\n } where open CommutativeSemiring commutativeSemiring\n\nleftModule : {R : Ring c ℓ} → LeftModule R c ℓ\nleftModule {R = ring} = record\n { -ᴹ_ = -_\n ; isLeftModule = record\n { isLeftSemimodule = LeftSemimodule.isLeftSemimodule leftSemimodule\n ; -ᴹ‿cong = -‿cong\n ; -ᴹ‿inverse = -‿inverse\n }\n } where open Ring ring\n\nrightModule : {R : Ring c ℓ} → RightModule R c ℓ\nrightModule {R = ring} = record\n { -ᴹ_ = -_\n ; isRightModule = record\n { isRightSemimodule = RightSemimodule.isRightSemimodule rightSemimodule\n ; -ᴹ‿cong = -‿cong\n ; -ᴹ‿inverse = -‿inverse\n }\n } where open Ring ring\n\nbimodule : {R : Ring c ℓ} → Bimodule R R c ℓ\nbimodule {R = ring} = record\n { isBimodule = record\n { isBisemimodule = Bisemimodule.isBisemimodule bisemimodule\n ; -ᴹ‿cong = -‿cong\n ; -ᴹ‿inverse = -‿inverse\n }\n } where open Ring ring\n\n⟨module⟩ : {R : CommutativeRing c ℓ} → Module R c ℓ\n⟨module⟩ {R = commutativeRing} = record\n { isModule = record\n { isBimodule = Bimodule.isBimodule bimodule\n }\n } where open CommutativeRing commutativeRing\n", "meta": {"hexsha": "2dbdda06cb5eb8e11b2d9dfd3e12d04464b20c84", "size": 3411, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Algebra/Module/Construct/TensorUnit.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Algebra/Module/Construct/TensorUnit.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Algebra/Module/Construct/TensorUnit.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 28.906779661, "max_line_length": 75, "alphanum_fraction": 0.6291410144, "num_tokens": 1251, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382058759129, "lm_q2_score": 0.7461389986757757, "lm_q1q2_score": 0.642827254253178}} {"text": "{-# OPTIONS --without-K --safe #-}\n\n-- https://personal.cis.strath.ac.uk/conor.mcbride/pub/DepRep/DepRep.pdf\n\nmodule Experiment.Outrageous.#03 where\n\nopen import Experiment.Outrageous.#02\n\ndata U : Set\nEl : U → Set\n\ndata U where\n :Zero: :𝟏: :𝟐: :ℕ: : U\n :Π: :Σ: : (S : U) → (El S → U) → U\nEl :Zero: = Zero\nEl :𝟏: = 𝟏\nEl :𝟐: = 𝟐\nEl :ℕ: = ℕ\nEl (:Π: S T) = (s : El S) → El (T s)\nEl (:Σ: S T) = Σ (El S) λ s → El (T s)\n\n_:→:_ : U → U → U\nS :→: T = :Π: S λ _ → T\n\n_:×:_ : U → U → U\nS :×: T = :Σ: S λ _ → T\n\n:If: : 𝟐 → U → U → U\n:If: tt T F = T\n:If: ff T F = F\n\n:Vec: : U → ℕ → U\n:Vec: X ze = :𝟏:\n:Vec: X (su n) = X :×: :Vec: X n\n", "meta": {"hexsha": "b61b6818de36c3364af8fa2bfb0235ed0df98f4d", "size": 639, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Experiment/Outrageous/#03.agda", "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_issues_repo_path": "Experiment/Outrageous/#03.agda", "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Experiment/Outrageous/#03.agda", "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.2571428571, "max_line_length": 72, "alphanum_fraction": 0.4710485133, "num_tokens": 323, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009480320036, "lm_q2_score": 0.7025300636233415, "lm_q1q2_score": 0.6427454212299789}} {"text": "open import Data.Product using ( _×_ ; _,_ )\nopen import Data.Sum using ( _⊎_ ; inj₁ ; inj₂ )\nopen import FRP.LTL.Time.Interval using ( _⊑_ ; _~_ ; _⌢_∵_ )\nopen import FRP.LTL.ISet.Core using ( ISet ; [_] ; _,_ ; M⟦_⟧ ; splitM⟦_⟧ ; subsumM⟦_⟧ )\n\nmodule FRP.LTL.ISet.Sum where\n\n_∨_ : ISet → ISet → ISet\nA ∨ B = [ (λ i → M⟦ A ⟧ i ⊎ M⟦ B ⟧ i) , split , subsum ] where\n\n split : ∀ i j i~j → \n (M⟦ A ⟧ (i ⌢ j ∵ i~j) ⊎ M⟦ B ⟧ (i ⌢ j ∵ i~j)) → \n ((M⟦ A ⟧ i ⊎ M⟦ B ⟧ i) × (M⟦ A ⟧ j ⊎ M⟦ B ⟧ j)) \n split i j i~j (inj₁ σ) with splitM⟦ A ⟧ i j i~j σ\n split i j i~j (inj₁ σ) | (σ₁ , σ₂) = (inj₁ σ₁ , inj₁ σ₂)\n split i j i~j (inj₂ τ) with splitM⟦ B ⟧ i j i~j τ\n split i j i~j (inj₂ τ) | (τ₁ , τ₂) = (inj₂ τ₁ , inj₂ τ₂)\n \n subsum : ∀ i j → (i ⊑ j) → (M⟦ A ⟧ j ⊎ M⟦ B ⟧ j) → (M⟦ A ⟧ i ⊎ M⟦ B ⟧ i)\n subsum i j i⊑j (inj₁ σ) = inj₁ (subsumM⟦ A ⟧ i j i⊑j σ)\n subsum i j i⊑j (inj₂ τ) = inj₂ (subsumM⟦ B ⟧ i j i⊑j τ)\n", "meta": {"hexsha": "c9414ed3322f14f0e243996ae633d79bfb1a5751", "size": 915, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/FRP/LTL/ISet/Sum.agda", "max_stars_repo_name": "agda/agda-frp-ltl", "max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 21, "max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z", "max_issues_repo_path": "src/FRP/LTL/ISet/Sum.agda", "max_issues_repo_name": "agda/agda-frp-ltl", "max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z", "max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z", "max_forks_repo_path": "src/FRP/LTL/ISet/Sum.agda", "max_forks_repo_name": "agda/agda-frp-ltl", "max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z", "avg_line_length": 41.5909090909, "max_line_length": 88, "alphanum_fraction": 0.5005464481, "num_tokens": 507, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009526726545, "lm_q2_score": 0.7025300573952052, "lm_q1q2_score": 0.6427454187920479}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Some defined operations (multiplication by natural number and\n-- exponentiation)\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Algebra\n\nmodule Algebra.Operations.Semiring {s₁ s₂} (S : Semiring s₁ s₂) where\n\nimport Algebra.Operations.CommutativeMonoid as MonoidOperations\nopen import Data.Nat.Base\n using (zero; suc; ℕ) renaming (_+_ to _ℕ+_; _*_ to _ℕ*_)\nopen import Data.Product using (module Σ)\nopen import Function using (_$_)\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as P using (_≡_)\n\nopen Semiring S renaming (zero to *-zero)\nopen import Relation.Binary.Reasoning.Setoid setoid\n\n------------------------------------------------------------------------\n-- Operations\n\n-- Re-export all monoid operations and proofs\nopen MonoidOperations +-commutativeMonoid public\n\n-- Exponentiation.\ninfixr 9 _^_\n_^_ : Carrier → ℕ → Carrier\nx ^ zero = 1#\nx ^ suc n = x * x ^ n\n\n------------------------------------------------------------------------\n-- Properties of _×_\n\n-- _× 1# is homomorphic with respect to _ℕ*_/_*_.\n\n×1-homo-* : ∀ m n → (m ℕ* n) × 1# ≈ (m × 1#) * (n × 1#)\n×1-homo-* 0 n = begin\n 0# ≈⟨ sym (Σ.proj₁ *-zero (n × 1#)) ⟩\n 0# * (n × 1#) ∎\n×1-homo-* (suc m) n = begin\n (n ℕ+ m ℕ* n) × 1# ≈⟨ ×-homo-+ 1# n (m ℕ* n) ⟩\n n × 1# + (m ℕ* n) × 1# ≈⟨ +-cong refl (×1-homo-* m n) ⟩\n n × 1# + (m × 1#) * (n × 1#) ≈⟨ sym (+-cong (*-identityˡ _) refl) ⟩\n 1# * (n × 1#) + (m × 1#) * (n × 1#) ≈⟨ sym (distribʳ (n × 1#) 1# (m × 1#)) ⟩\n (1# + m × 1#) * (n × 1#) ∎\n\n------------------------------------------------------------------------\n-- Properties of _×′_\n\n-- _×′ 1# is homomorphic with respect to _ℕ*_/_*_.\n\n×′1-homo-* : ∀ m n → (m ℕ* n) ×′ 1# ≈ (m ×′ 1#) * (n ×′ 1#)\n×′1-homo-* m n = begin\n (m ℕ* n) ×′ 1# ≈⟨ sym $ ×≈×′ (m ℕ* n) 1# ⟩\n (m ℕ* n) × 1# ≈⟨ ×1-homo-* m n ⟩\n (m × 1#) * (n × 1#) ≈⟨ *-cong (×≈×′ m 1#) (×≈×′ n 1#) ⟩\n (m ×′ 1#) * (n ×′ 1#) ∎\n\n------------------------------------------------------------------------\n-- Properties of _^_\n\n-- _^_ preserves equality.\n\n^-congˡ : ∀ n → (_^ n) Preserves _≈_ ⟶ _≈_\n^-congˡ zero x≈y = refl\n^-congˡ (suc n) x≈y = *-cong x≈y (^-congˡ n x≈y)\n\n^-cong : _^_ Preserves₂ _≈_ ⟶ _≡_ ⟶ _≈_\n^-cong {v = n} x≈y P.refl = ^-congˡ n x≈y\n", "meta": {"hexsha": "bb7c67a604818ed5adff185713b11b515e9e5e7e", "size": 2490, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Operations/Semiring.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Operations/Semiring.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Operations/Semiring.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 32.7631578947, "max_line_length": 79, "alphanum_fraction": 0.4401606426, "num_tokens": 937, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467675095294, "lm_q2_score": 0.7310585844894971, "lm_q1q2_score": 0.6427077914140336}} {"text": "------------------------------------------------------------------------------\n-- The gcd program is correct\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- This module proves the correctness of the gcd program using\n-- the Euclid's algorithm.\n\nmodule LTC-PCF.Program.GCD.Partial.CorrectnessProof where\n\nopen import LTC-PCF.Base\nopen import LTC-PCF.Data.Nat.Divisibility.NotBy0.Properties\n using ( 0∤x ; x∣S→x≤S )\nopen import LTC-PCF.Data.Nat.Type\n\nopen import LTC-PCF.Program.GCD.Partial.CommonDivisor using ( gcdCD )\nopen import LTC-PCF.Program.GCD.Partial.Definitions using ( x≢0≢y ; gcdSpec )\nopen import LTC-PCF.Program.GCD.Partial.Divisible using ( gcdDivisible )\nopen import LTC-PCF.Program.GCD.Partial.GCD using ( gcd )\n\nimport LTC-PCF.Program.GCD.Partial.GreatestAnyCommonDivisor\nopen module GreatestAnyCommonDivisor =\n LTC-PCF.Program.GCD.Partial.GreatestAnyCommonDivisor x∣S→x≤S 0∤x\n using ( gcdGACD )\n\nopen import LTC-PCF.Program.GCD.Partial.Totality using ( gcd-N )\n\n------------------------------------------------------------------------------\n-- The gcd is correct\ngcdCorrect : ∀ {m n} → N m → N n → x≢0≢y m n → gcdSpec m n (gcd m n)\ngcdCorrect Nm Nn m≢0≢n = gcdCD Nm Nn m≢0≢n\n , gcdGACD (gcd-N Nm Nn m≢0≢n)\n (gcdCD Nm Nn m≢0≢n)\n (gcdDivisible Nm Nn m≢0≢n)\n", "meta": {"hexsha": "a229b9c0a1d2902daa6d004aa8423d0bd6a6f414", "size": 1576, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/LTC-PCF/Program/GCD/Partial/CorrectnessProof.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/LTC-PCF/Program/GCD/Partial/CorrectnessProof.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/LTC-PCF/Program/GCD/Partial/CorrectnessProof.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 40.4102564103, "max_line_length": 78, "alphanum_fraction": 0.557106599, "num_tokens": 421, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467738423873, "lm_q2_score": 0.7310585727705127, "lm_q1q2_score": 0.6427077857410163}} {"text": "\n-- Ad-hoc monoid typeclass module\n\nmodule Utils.Monoid where\n\nopen import Data.List\nopen import Data.String\n\nrecord Monoid {α}(A : Set α) : Set α where\n constructor rec\n field\n append : A → A → A\n identity : A\n\ninfixr 5 _<>_\n_<>_ : ∀ {α}{A : Set α} ⦃ _ : Monoid A ⦄ → A → A → A\n_<>_ ⦃ dict ⦄ a b = Monoid.append dict a b\n\nmempty : ∀ {α}{A : Set α} ⦃ _ : Monoid A ⦄ → A\nmempty ⦃ dict ⦄ = Monoid.identity dict\n\ninstance\n MonoidList : ∀ {α A} → Monoid {α} (List A)\n MonoidList = rec Data.List._++_ []\n\n MonoidString : Monoid String\n MonoidString = rec Data.String._++_ \"\"\n \n", "meta": {"hexsha": "1198c5b1ba1cee854f6c36f3c35416b9bf5d68dd", "size": 589, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Utils/Monoid.agda", "max_stars_repo_name": "AndrasKovacs/SemanticsWithApplications", "max_stars_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2016-09-12T04:25:39.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-02T10:01:52.000Z", "max_issues_repo_path": "Utils/Monoid.agda", "max_issues_repo_name": "AndrasKovacs/SemanticsWithApplications", "max_issues_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Utils/Monoid.agda", "max_forks_repo_name": "AndrasKovacs/SemanticsWithApplications", "max_forks_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.3103448276, "max_line_length": 52, "alphanum_fraction": 0.6095076401, "num_tokens": 221, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467675095294, "lm_q2_score": 0.7310585727705126, "lm_q1q2_score": 0.6427077811113262}} {"text": "{-\n\nThis file contains:\n\n- An implementation of the free groupoid (a free group that has no limitiations\n over the high dimensional path structure). An intermediate construction used\n to calculate the fundamental group of a Bouquet.\n\n-}\n{-# OPTIONS --safe #-}\n\nmodule Cubical.HITs.FreeGroupoid.Base where\n\nopen import Cubical.Foundations.Prelude\n\nprivate\n variable\n ℓ : Level\n\ndata FreeGroupoid (A : Type ℓ) : Type ℓ where\n η : A → FreeGroupoid A\n _·_ : FreeGroupoid A → FreeGroupoid A → FreeGroupoid A\n ε : FreeGroupoid A\n inv : FreeGroupoid A → FreeGroupoid A\n assoc : ∀ x y z → x · (y · z) ≡ (x · y) · z\n idr : ∀ x → x ≡ x · ε\n idl : ∀ x → x ≡ ε · x\n invr : ∀ x → x · (inv x) ≡ ε\n invl : ∀ x → (inv x) · x ≡ ε\n", "meta": {"hexsha": "3f766f97208fd972e9740ff4a8f46ae4b0a5df31", "size": 748, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/FreeGroupoid/Base.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_issues_repo_path": "Cubical/HITs/FreeGroupoid/Base.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/HITs/FreeGroupoid/Base.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.9333333333, "max_line_length": 79, "alphanum_fraction": 0.6296791444, "num_tokens": 252, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467580102419, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.6427077793181443}} {"text": "module Esterel.Variable.Sequential where\n\nopen import Data.Nat\n using (ℕ) renaming (_≟_ to _≟ℕ_)\nopen import Function\n using (_∘_)\nopen import Relation.Nullary\n using (Dec ; yes ; no ; ¬_)\nopen import Relation.Binary\n using (Decidable)\nopen import Relation.Binary.PropositionalEquality\n using (_≡_ ; refl ; cong ; trans ; sym)\n\n\ndata SeqVar : Set where\n _ᵥ : ℕ → SeqVar\n\nunwrap : SeqVar → ℕ\nunwrap (n ᵥ) = n\n\nunwrap-inverse : ∀ {s} → (unwrap s) ᵥ ≡ s\nunwrap-inverse {_ ᵥ} = refl\n\nunwrap-injective : ∀ {s t} → unwrap s ≡ unwrap t → s ≡ t\nunwrap-injective s'≡t' = trans (sym unwrap-inverse) (trans (cong _ᵥ s'≡t') unwrap-inverse)\n\n-- for backward compatibility\nunwrap-neq : ∀{k1 : SeqVar} → ∀{k2 : SeqVar} → ¬ k1 ≡ k2 → ¬ (unwrap k1) ≡ (unwrap k2)\nunwrap-neq = (_∘ unwrap-injective)\n\nwrap : ℕ → SeqVar\nwrap = _ᵥ\n\nbijective : ∀{x} → unwrap (wrap x) ≡ x\nbijective = refl\n\n\n\n_≟_ : Decidable {A = SeqVar} _≡_\n(s ᵥ) ≟ (t ᵥ) with s ≟ℕ t\n... | yes p = yes (cong _ᵥ p)\n... | no ¬p = no (¬p ∘ cong unwrap)\n", "meta": {"hexsha": "c311a36536ad96e75db175e9eb60212594ab3656", "size": 1001, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Esterel/Variable/Sequential.agda", "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_issues_repo_path": "agda/Esterel/Variable/Sequential.agda", "max_issues_repo_name": "florence/esterel-calculus", "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Esterel/Variable/Sequential.agda", "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "avg_line_length": 23.2790697674, "max_line_length": 90, "alphanum_fraction": 0.6383616384, "num_tokens": 377, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677583778258, "lm_q2_score": 0.7577943658046609, "lm_q1q2_score": 0.6425851896827244}} {"text": "{-# OPTIONS --safe --warning=error #-}\n\nopen import Setoids.Setoids\nopen import Groups.SymmetricGroups.Definition\nopen import Groups.FreeGroup.Definition\nopen import Decidable.Sets\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import LogicalFormulae\nopen import Boolean.Definition\n\nmodule Groups.FreeGroup.Word {a : _} {A : Set a} (decA : DecidableSet A) where\n\ndata ReducedWord : Set a\nwordLength : ReducedWord → ℕ\nfirstLetter : (w : ReducedWord) → .(0 Functor A B -> Functor (Functors B C) (Functors A C)\nCat[-∘_] {C = C} r = record \n { F₀ = λ X → X Cat.∘ r\n ; F₁ = λ η → η ∘ʳ r\n ; identity = C.Equiv.refl\n ; homomorphism = C.Equiv.refl\n ; F-resp-≡ = λ x → x \n }\n where\n module C = Category C\n", "meta": {"hexsha": "13671053f87694bb9e1eacd14669f651cc2492aa", "size": 2814, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/FunctorCategory.agda", "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 98, "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_issues_repo_path": "Categories/FunctorCategory.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_forks_repo_path": "Categories/FunctorCategory.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 23, "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "avg_line_length": 39.6338028169, "max_line_length": 110, "alphanum_fraction": 0.4534470505, "num_tokens": 1248, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278788223264, "lm_q2_score": 0.7279754489059774, "lm_q1q2_score": 0.6423858312128325}} {"text": "module map-Tree where\n\n-- ツリー\ndata Tree (A B : Set) : Set where\n leaf : A → Tree A B\n node : Tree A B → B → Tree A B → Tree A B\n\n-- ツリーのmap\nmap-Tree : ∀ {A B C D : Set} → (A → C) → (B → D) → Tree A B → Tree C D\nmap-Tree f g (leaf a) = leaf (f a)\nmap-Tree f g (node treeˡ b treeʳ) = node (map-Tree f g treeˡ) (g b) (map-Tree f g treeʳ)\n", "meta": {"hexsha": "c84b9330cbc4699fdc78efa6a18f5f7b81cfce2f", "size": 349, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/lists/map-Tree.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/lists/map-Tree.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/lists/map-Tree.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.0833333333, "max_line_length": 88, "alphanum_fraction": 0.547277937, "num_tokens": 149, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8824278664544912, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.6423858274171504}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Monad.Relative where\n\nopen import Level\n\nopen import Categories.Category using (Category)\nopen import Categories.Functor using (Functor; Endofunctor; _∘F_) renaming (id to idF)\nimport Categories.Morphism.Reasoning as MR\nopen import Categories.NaturalTransformation renaming (id to idN)\nopen import Categories.NaturalTransformation.NaturalIsomorphism hiding (_≃_)\nopen import Categories.NaturalTransformation.Equivalence\nopen NaturalIsomorphism\n\nprivate\n variable\n o ℓ e o′ ℓ′ e′ : Level\n C : Category o ℓ e\n D : Category o′ ℓ′ e′\n\nrecord Monad {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (J : Functor C D) : Set (o ⊔ o′ ⊔ ℓ′ ⊔ e′) where\n private\n module C = Category C\n module D = Category D\n module J = Functor J\n open D using (_⇒_; _∘_; _≈_)\n field\n F₀ : C.Obj → D.Obj\n unit : {c : C.Obj} → J.₀ c ⇒ F₀ c\n extend : {x y : C.Obj} → (J.₀ x ⇒ F₀ y) → F₀ x ⇒ F₀ y\n identityʳ : {x y : C.Obj} { k : J.₀ x ⇒ F₀ y} → extend k ∘ unit ≈ k\n identityˡ : {x : C.Obj} → extend {x} unit ≈ D.id\n assoc : {x y z : C.Obj} {k : J.₀ x ⇒ F₀ y} {l : J.₀ y ⇒ F₀ z} → extend (extend l ∘ k) ≈ extend l ∘ extend k\n extend-≈ : {x y : C.Obj} {k h : J.₀ x ⇒ F₀ y} → k ≈ h → extend k ≈ extend h\n\n-- From a Relative Monad, we can extract a functor\nRMonad⇒Functor : {J : Functor C D} → Monad J → Functor C D\nRMonad⇒Functor {C = C} {D = D} {J = J} r = record\n { F₀ = F₀\n ; F₁ = λ f → extend (unit ∘ J.₁ f)\n ; identity = identity′\n ; homomorphism = hom′\n ; F-resp-≈ = λ f≈g → extend-≈ (∘-resp-≈ʳ (J.F-resp-≈ f≈g))\n }\n where\n open Monad r\n module C = Category C\n module D = Category D\n module J = Functor J\n open Category D hiding (identityˡ; identityʳ; assoc)\n open HomReasoning\n open MR D\n identity′ : {c : C.Obj} → extend {c} (unit ∘ J.₁ C.id) ≈ id\n identity′ = begin\n extend (unit ∘ J.₁ C.id) ≈⟨ extend-≈ (elimʳ J.identity) ⟩\n extend unit ≈⟨ identityˡ ⟩\n id ∎\n hom′ : {X Y Z : C.Obj} {f : X C.⇒ Y} {g : Y C.⇒ Z} →\n extend (unit ∘ J.₁ (g C.∘ f)) ≈ extend (unit ∘ J.₁ g) ∘ extend (unit ∘ J.F₁ f)\n hom′ {f = f} {g} = begin\n extend (unit ∘ J.₁ (g C.∘ f)) ≈⟨ extend-≈ (pushʳ J.homomorphism) ⟩\n extend ((unit ∘ J.₁ g) ∘ J.₁ f) ≈⟨ extend-≈ (pushˡ (⟺ identityʳ)) ⟩\n extend (extend (unit ∘ J.₁ g) ∘ (unit ∘ J.F₁ f)) ≈⟨ assoc ⟩\n extend (unit ∘ J.₁ g) ∘ extend (unit ∘ J.F₁ f) ∎\n", "meta": {"hexsha": "e795584112881390fced385e81f869aea2f6e08f", "size": 2461, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Monad/Relative.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Monad/Relative.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Monad/Relative.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 38.453125, "max_line_length": 111, "alphanum_fraction": 0.5717188135, "num_tokens": 969, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278726384089, "lm_q2_score": 0.7279754489059774, "lm_q1q2_score": 0.6423858267110925}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import Setoids.Setoids\n\nmodule Setoids.Functions.Definition {a b c d : _} {A : Set a} {B : Set b} where\n\nWellDefined : (S : Setoid {a} {c} A) (T : Setoid {b} {d} B) (f : A → B) → Set (a ⊔ c ⊔ d)\nWellDefined S T f = {x y : A} → Setoid._∼_ S x y → Setoid._∼_ T (f x) (f y)\n", "meta": {"hexsha": "1f04e6cf67ffdfe1c4f7918233f83c1853a59384", "size": 387, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Setoids/Functions/Definition.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Setoids/Functions/Definition.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Setoids/Functions/Definition.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 38.7, "max_line_length": 89, "alphanum_fraction": 0.5994832041, "num_tokens": 154, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8824278540866548, "lm_q2_score": 0.7279754607093178, "lm_q1q2_score": 0.6423858236214672}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule root2 where\n\n-- imports. We use the latest agda stdlib. \nopen import Data.Nat\nopen import Data.Nat.DivMod\nopen import Data.Nat.Properties\nopen import Data.Nat.Solver\nopen import Relation.Binary.PropositionalEquality\nopen import Data.Product\nopen import Data.Sum renaming (inj₁ to even ; inj₂ to odd)\nopen import Relation.Nullary\nopen import Data.Empty\n\n-- Even predicate.\nEven : ℕ -> Set\nEven n = ∃ λ k → n ≡ 2 * k\n\n-- Odd predicate.\nOdd : ℕ -> Set\nOdd n = ∃ λ k → n ≡ 1 + 2 * k\n\n\nopen +-*-Solver\n\n-- Lemma: an even number cannot equal to an odd number. \nlemma-even-odd-exclusive : ∀ k l -> ¬ 2 * k ≡ 1 + 2 * l\nlemma-even-odd-exclusive k l hyp = z hyp'\n where\n z : ¬ 0 ≡ 1\n z ()\n\n n*m%n≡0 : ∀ m n .{{_ : NonZero n}} → (n * m) % n ≡ 0\n n*m%n≡0 m n = begin\n (n * m) % n ≡⟨ cong (_% n) (solve 2 (λ n m → n :* m := m :* n) refl n m) ⟩\n (m * n) % n ≡⟨ m*n%n≡0 m n ⟩\n 0 ∎\n where\n open ≡-Reasoning\n \n \n lem1%2 : 1 % 2 ≡ 1\n lem1%2 = refl \n \n hyp' : 0 ≡ 1\n hyp' = begin\n 0 ≡⟨ sym (n*m%n≡0 k 2) ⟩ \n (2 * k) % 2 ≡⟨ cong (_% 2) hyp ⟩ \n (1 + 2 * l) % 2 ≡⟨ %-distribˡ-+ 1 (2 * l) 2 ⟩\n ((1 % 2) + ((2 * l) % 2)) % 2 ≡⟨ cong (_% 2) (cong₂ (_+_) lem1%2 (n*m%n≡0 l 2)) ⟩\n (1 + 0) % 2 ≡⟨ refl ⟩\n 1 % 2 ≡⟨ refl ⟩\n 1 ∎\n where\n open ≡-Reasoning \n\n-- Lemma: a natural number cannot be both even and odd. \nlemma-even-odd-exclusive' : ∀ n -> ¬ (Even n × Odd n)\nlemma-even-odd-exclusive' n ((k , eqn) , (l , eqn')) = lemma-even-odd-exclusive k l claim\n where\n claim : 2 * k ≡ 1 + 2 * l\n claim = begin\n 2 * k ≡⟨ sym eqn ⟩\n n ≡⟨ eqn' ⟩ \n 1 + 2 * l ∎\n where\n open ≡-Reasoning\n \n\n\n-- Lemma: a natrual number is either even or odd (but not both as shown by lemma-even-odd-exclusive').\nParity : (n : ℕ) -> Even n ⊎ Odd n\nParity zero = even (zero , refl)\nParity (suc n) with Parity n\n... | even (k , eq) = odd (k , cong suc eq)\n... | odd (k , eq) = even (suc k , claim)\n where\n claim : suc n ≡ suc (k + suc (k + 0))\n claim = begin\n suc n ≡⟨ refl ⟩\n 1 + n ≡⟨ cong (1 +_) eq ⟩ \n 1 + suc (k + (k + 0)) ≡⟨ solve 1 (λ k → con 1 :+ (con 1 :+ (k :+ (k :+ con 0))) := con 1 :+ (k :+ (con 1 :+ (k :+ con 0)))) refl k ⟩\n 1 + (k + (1 + (k + 0))) ≡⟨ refl ⟩\n suc (k + suc (k + 0)) ∎\n where\n open ≡-Reasoning\n \n-- Auxillary lemmas:\nlemma-div2 : ∀ n .{{_ : NonZero n}} -> n / 2 < n\nlemma-div2 n = m/n a < b -> b < suc c -> a < c\nlemma-<-< (s≤s ab) (s≤s bc) = <-transˡ (s≤s ab) bc\n\nlemma-div2' : ∀ n b .{{_ : NonZero n}} -> n < 1 + b -> n / 2 < b\nlemma-div2' n b n1b = lemma-<-< (lemma-div2 n) n1b\n\n-- We do a case split in the parity of m and n. For each of the four\n-- cases, we can derive a contradiction using induction on the bound\n-- of m and n.\nlemma-root2-irra : ∀ b m n -> ¬ m ≡ 0 -> ¬ n ≡ 0 → m < b → n < b → ¬ m * m ≡ 2 * (n * n)\nlemma-root2-irra (suc b) 0 0 mnz nnz mlb nlb hyp = mnz refl \nlemma-root2-irra (suc b) 0 (suc n) mnz nnz mlb nlb hyp = mnz refl \nlemma-root2-irra (suc b) (suc m) 0 mnz nnz mlb nlb hyp = nnz refl \nlemma-root2-irra (suc b) m@(suc m') n@(suc n') mnz nnz mlb nlb hyp with Parity m | Parity n\n... | even (k , eqm) | even (l , eqn) = ih\n where\n factor-four : 4 * (k * k) ≡ 4 * (2 * (l * l))\n factor-four = begin\n 4 * (k * k) ≡⟨ solve 1 (λ k → con 4 :* (k :* k) := (con 2 :* k) :* (con 2 :* k)) refl k ⟩\n (2 * k) * (2 * k) ≡⟨ cong₂ _*_ (sym eqm) (sym eqm) ⟩\n m * m ≡⟨ hyp ⟩\n 2 * (n * n) ≡⟨ cong (2 *_) (cong₂ _*_ eqn eqn) ⟩\n 2 * ((2 * l) * (2 * l)) ≡⟨ solve 1 (λ l → con 2 :* ((con 2 :* l) :* (con 2 :* l)) := con 4 :* (con 2 :* (l :* l))) refl l ⟩\n 4 * (2 * (l * l)) ∎\n where\n open ≡-Reasoning\n \n \n hyp' : k * k ≡ 2 * (l * l)\n hyp' = *-cancelˡ-≡ 4 factor-four\n \n klb : k < b\n klb = begin-strict\n k ≡⟨ sym (m*n/n≡m k 2) ⟩\n (k * 2) / 2 ≡⟨ cong (_/ 2) (solve 1 (λ k → k :* con 2 := con 2 :* k) refl k) ⟩ \n (2 * k) / 2 ≡⟨ cong (_/ 2) (sym eqm) ⟩ \n m / 2 <⟨ lemma-div2' m b mlb ⟩ \n b ∎\n where\n open ≤-Reasoning\n \n\n llb : l < b\n llb = begin-strict\n l ≡⟨ sym (m*n/n≡m l 2) ⟩\n (l * 2) / 2 ≡⟨ cong (_/ 2) (solve 1 (λ l → l :* con 2 := con 2 :* l) refl l) ⟩ \n (2 * l) / 2 ≡⟨ cong (_/ 2) (sym eqn) ⟩ \n n / 2 <⟨ lemma-div2' n b nlb ⟩ \n b ∎\n where\n open ≤-Reasoning\n \n\n knz : ¬ k ≡ 0\n knz k0 = mnz m0\n where\n m0 : m ≡ 0\n m0 = begin\n m ≡⟨ eqm ⟩\n 2 * k ≡⟨ cong (2 *_) k0 ⟩ \n 2 * 0 ≡⟨ refl ⟩ \n 0 ∎\n where\n open ≡-Reasoning\n \n\n\n lnz : ¬ l ≡ 0\n lnz l0 = nnz n0\n where\n n0 : n ≡ 0\n n0 = begin\n n ≡⟨ eqn ⟩\n 2 * l ≡⟨ cong (2 *_) l0 ⟩ \n 2 * 0 ≡⟨ refl ⟩ \n 0 ∎\n where\n open ≡-Reasoning\n \n\n ih : ⊥\n ih = lemma-root2-irra b k l knz lnz klb llb hyp'\n\n\n... | even (k , eqm) | odd (l , eqn) = lemma-even-odd-exclusive' (n * n) (even-right , odd-right)\n where\n even-left : Even (m * m)\n even-left = 2 * (k * k) , claim\n where\n claim : m * m ≡ 2 * (2 * (k * k)) \n claim = begin\n m * m ≡⟨ cong₂ _*_ eqm eqm ⟩\n (2 * k) * (2 * k) ≡⟨ solve 1 (λ k → (con 2 :* k) :* (con 2 :* k) := con 2 :* (con 2 :* (k :* k))) refl k ⟩\n 2 * (2 * (k * k)) ∎\n where\n open ≡-Reasoning\n \n\n odd-right : Odd (n * n)\n odd-right = (2 * (l * l) + 2 * l) , claim\n where\n claim : n * n ≡ 1 + 2 * (2 * (l * l) + 2 * l) \n claim = begin\n n * n ≡⟨ cong₂ _*_ eqn eqn ⟩\n (1 + 2 * l) * (1 + 2 * l) ≡⟨ solve 1 (λ l → (con 1 :+ con 2 :* l) :* (con 1 :+ con 2 :* l) := con 1 :+ (con 2 :* ((con 2 :* (l :* l)) :+ con 2 :* l))) refl l ⟩\n 1 + 2 * (2 * (l * l) + 2 * l) ∎\n where\n open ≡-Reasoning\n \n\n 2*n*n≡2*2*k*k : 2 * (n * n) ≡ 2 * (2 * (k * k))\n 2*n*n≡2*2*k*k = begin\n 2 * (n * n) ≡⟨ sym hyp ⟩\n m * m ≡⟨ (let (_ , p) = even-left in p) ⟩\n 2 * (2 * (k * k)) ∎\n where\n open ≡-Reasoning\n \n n*n≡2*k*k : (n * n) ≡ (2 * (k * k))\n n*n≡2*k*k = *-cancelˡ-≡ 2 2*n*n≡2*2*k*k\n\n even-right : Even (n * n)\n even-right = k * k , (n*n≡2*k*k)\n\n... | odd (k , eqn) | _ = lemma-even-odd-exclusive' (m * m) (even-left , odd-left)\n where\n odd-left : Odd (m * m)\n odd-left = (2 * (k * k) + 2 * k) , claim\n where\n claim : m * m ≡ 1 + 2 * (2 * (k * k) + 2 * k) \n claim = begin\n m * m ≡⟨ cong₂ _*_ eqn eqn ⟩\n (1 + 2 * k) * (1 + 2 * k) ≡⟨ solve 1 (λ k → (con 1 :+ con 2 :* k) :* (con 1 :+ con 2 :* k) := con 1 :+ (con 2 :* ((con 2 :* (k :* k)) :+ con 2 :* k))) refl k ⟩\n 1 + 2 * (2 * (k * k) + 2 * k) ∎\n where\n open ≡-Reasoning\n\n even-left : Even (m * m)\n even-left = (n * n) , hyp\n \n\n-- Main theorem: for any natural number m and n, it impossible that m\n-- * m ≡ 2 * (n * n) except when m ≡ 0 and n ≡ 0 (in this situation,\n-- m/n is not defined), in other words, no rational number equals √2.\ntheorem-root2-irra : ∀ m n -> m * m ≡ 2 * (n * n) -> m ≡ 0 × n ≡ 0\ntheorem-root2-irra zero zero hyp = (refl , refl )\ntheorem-root2-irra zero n@(suc n') hyp = (refl , sym 0≡n )\n where\n 2*0≡2*n*n : 2 * 0 ≡ 2 * (n * n)\n 2*0≡2*n*n = hyp\n 0≡n*n : 0 ≡ n * n\n 0≡n*n = *-cancelˡ-≡ 2 hyp\n n*0≡n*n : n * 0 ≡ n * n\n n*0≡n*n = begin\n n * 0 ≡⟨ *-comm n 0 ⟩\n 0 * n ≡⟨ refl ⟩\n 0 ≡⟨ 0≡n*n ⟩\n n * n ∎\n where\n open ≡-Reasoning\n\n 0≡n : 0 ≡ n\n 0≡n = *-cancelˡ-≡ n n*0≡n*n\n\ntheorem-root2-irra m@(suc m') n@(suc n') hyp = ⊥-elim claim\n where\n -- m ⊔ n = max m n \n b = 1 + (m ⊔ n)\n mlb : m < b\n mlb = s≤s (m≤m⊔n m n)\n nlb : n < b\n nlb = s≤s (m≤n⊔m m n)\n claim = lemma-root2-irra b m n (λ ()) (λ ()) mlb nlb hyp\n", "meta": {"hexsha": "7693556ce7499f63e24c0ff8ce50cdc89f6fa7dc", "size": 8064, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "root2.agda", "max_stars_repo_name": "onestruggler/root2", "max_stars_repo_head_hexsha": "1e50ef1caffc2a4d2e2f8bc7aaa969acc1ba1cc4", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "root2.agda", "max_issues_repo_name": "onestruggler/root2", "max_issues_repo_head_hexsha": "1e50ef1caffc2a4d2e2f8bc7aaa969acc1ba1cc4", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "root2.agda", "max_forks_repo_name": "onestruggler/root2", "max_forks_repo_head_hexsha": "1e50ef1caffc2a4d2e2f8bc7aaa969acc1ba1cc4", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.3157894737, "max_line_length": 169, "alphanum_fraction": 0.4343998016, "num_tokens": 3622, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.882427872638409, "lm_q2_score": 0.7279754371026367, "lm_q1q2_score": 0.6423858162954956}} {"text": "module Productive where\n\nopen import Stream\nopen import Size\nopen import Data.Maybe\nopen import Data.Product\nopen import Relation.Binary.PropositionalEquality as P\n\nPStream : Set → Set\nPStream A = Stream (Maybe A)\n\nmutual\n record Productive {A : Set} (s : PStream A) : Set where\n coinductive\n field\n step : EventualOutput s\n\n data EventualOutput {A : Set} (s : PStream A) : Set where\n here : (a : A) → s .hd ≡ just a → Productive (s .tl) → EventualOutput s\n there : s .hd ≡ nothing → EventualOutput (s .tl) → EventualOutput s\n\nopen Productive public\n\nProdStr : Set → Set\nProdStr A = Σ[ s ∈ PStream A ] (Productive s)\n\ninjS : {A : Set} → Stream A → ProdStr A\ninjS {A} s = (toPStream s , prod s)\n where\n toPStream : Stream {∞} A → PStream A\n toPStream s .hd = just (s .hd)\n toPStream s .tl = toPStream (s .tl)\n\n prod : (s : Stream A) → Productive (toPStream s)\n prod s .step = here (s .hd) refl (prod (s .tl))\n\nextract : {A : Set} → ProdStr A → Stream A\nextract (s , p) = extr s p\n where\n extr : {A : Set} → (s : PStream A) → Productive s → Stream A\n extrμ : {A : Set} → (s : PStream A) → EventualOutput s → Stream A\n\n extr {A} s p = extrμ s (p .step)\n\n extrμ {A} s (here a q p') .hd = a\n extrμ {A} s (here a q p') .tl = extr (s .tl) p'\n extrμ {A} s (there x p') = extrμ (s .tl) p'\n\nzipS : ∀{A} → ProdStr A → ProdStr A → ProdStr A\nzipS {A} (s , p) (t , q) = (z s t , pz p q)\n where\n z : PStream A → PStream A → PStream A\n cz : Maybe A → PStream A → PStream A → PStream A\n\n z s t = cz (s .hd) (s .tl) t\n\n cz (just a) s' t .hd = just a\n cz (just a) s' t .tl = z t s'\n cz nothing s' t .hd = nothing\n cz nothing s' t .tl = cz (s' .hd) (s' .tl) t\n\n pz : {s t : PStream A} → Productive s → Productive t → Productive (z s t)\n pcz : {s t : PStream A} → Productive s → Productive t →\n Productive (cz (s .hd) (s .tl) t)\n pczE : {s t : PStream A} → EventualOutput s → Productive t →\n EventualOutput (cz (s .hd) (s .tl) t)\n pz p q = pcz p q\n\n pcz p q .step = pczE (p .step) q\n\n pczE {s} (here a s₀≡a p') q with s .hd\n pczE {s} (here .a refl p') q | just a = here a refl (pz q p')\n pczE {s} (here a () p') q | nothing\n pczE {s} (there s₀≡∗ p') q with s .hd\n pczE {s} (there () p') q | just a\n pczE {s} (there refl p') q | nothing = there refl (pczE p' q)\n", "meta": {"hexsha": "7aa93d60b01051e67de96db06f99e27e0f264a3c", "size": 2406, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Streams/Productive.agda", "max_stars_repo_name": "hbasold/Sandbox", "max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Streams/Productive.agda", "max_issues_repo_name": "hbasold/Sandbox", "max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Streams/Productive.agda", "max_forks_repo_name": "hbasold/Sandbox", "max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.2467532468, "max_line_length": 81, "alphanum_fraction": 0.5619285121, "num_tokens": 923, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.901920681802153, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.6423769427193481}} {"text": "module Sets.IterativeSet where\n\nimport Lvl\nopen import Logic\nopen import Type\n\nmodule _ where\n private variable {ℓ ℓ₁ ℓ₂} : Lvl.Level\n\n -- A model of constructive set theory (CZF) by using W-types (iterative sets).\n -- The interpretation of Iset being a type of sets comes from the idea that the image of `elem` is a set of elements.\n record Iset : Type{Lvl.𝐒(ℓ)} where\n constructor set\n inductive\n pattern\n field\n {Index} : Type{ℓ}\n elem : Index → Iset{ℓ}\n open Iset\n\n Iset-index-induction : ∀{P : Iset{ℓ₁} → Stmt{ℓ₂}} → (∀{A : Iset{ℓ₁}} → (∀{i : Index(A)} → P(elem(A)(i))) → P(A)) → (∀{A : Iset{ℓ₁}} → P(A))\n Iset-index-induction {P = P} proof {set elem} = proof{_} \\{i} → Iset-index-induction{P = P} proof {elem(i)}\n", "meta": {"hexsha": "dc9924299a6d2c4aab8aa21fae49aa8d8977250f", "size": 753, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Sets/IterativeSet.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Sets/IterativeSet.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Sets/IterativeSet.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.7391304348, "max_line_length": 141, "alphanum_fraction": 0.630810093, "num_tokens": 266, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.90192067652954, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.6423769389640234}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Level\nopen import Categories.Category\n\nmodule Categories.Functor.Power.Functorial {o ℓ e : Level} (C : Category o ℓ e) where\n\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl; trans)\n\nopen import Categories.Functor renaming (id to idF)\nopen import Categories.Category.Discrete\nopen import Categories.Category.Equivalence\nopen import Categories.Category.Construction.Functors\nopen import Categories.NaturalTransformation using (NaturalTransformation; ntHelper)\nopen import Categories.NaturalTransformation.NaturalIsomorphism as NI\n using (module NaturalIsomorphism; _≃_; refl)\nimport Categories.Morphism.Reasoning as MR\nopen MR C\n\nimport Categories.Functor.Power as Power\nopen Power C\n\nopen Category using (Obj)\nopen Category C using (_⇒_; _∘_; module Equiv)\nmodule C = Category C\nmodule CE = Equiv\n\nprivate\n variable\n i : Level\n I : Set i\n\nexp→functor₀ : Obj (Exp I) → Functor (Discrete I) C\nexp→functor₀ X = record\n { F₀ = X\n ; F₁ = λ { refl → C.id }\n ; identity = CE.refl\n ; homomorphism = λ { {_} {_} {_} {refl} {refl} → CE.sym C.identityˡ}\n ; F-resp-≈ = λ { {_} {_} {refl} {refl} refl → CE.refl}\n }\n\nexp→functor₁ : {X Y : I → C.Obj} → Exp I [ X , Y ] → NaturalTransformation (exp→functor₀ X) (exp→functor₀ Y)\nexp→functor₁ F = record { η = F ; commute = λ { refl → id-comm } ; sym-commute = λ { refl → id-comm-sym } }\n\nexp→functor : Functor (Exp I) (Functors (Discrete I) C)\nexp→functor = record\n { F₀ = exp→functor₀\n ; F₁ = exp→functor₁\n ; identity = CE.refl\n ; homomorphism = CE.refl\n ; F-resp-≈ = λ eqs {x} → eqs x\n }\n\nfunctor→exp : Functor (Functors (Discrete I) C) (Exp I)\nfunctor→exp = record\n { F₀ = Functor.F₀\n ; F₁ = NaturalTransformation.η\n ; identity = λ _ → CE.refl\n ; homomorphism = λ _ → CE.refl\n ; F-resp-≈ = λ eqs i → eqs {i}\n }\n\nexp≋functor : StrongEquivalence (Exp I) (Functors (Discrete I) C)\nexp≋functor = record\n { F = exp→functor\n ; G = functor→exp\n ; weak-inverse = record\n { F∘G≈id = record\n { F⇒G = ntHelper record\n { η = λ DI → record\n { η = λ _ → C.id\n ; commute = λ { refl → C.∘-resp-≈ˡ (CE.sym (Functor.identity DI))}\n ; sym-commute = λ { refl → C.∘-resp-≈ˡ (Functor.identity DI)}\n }\n ; commute = λ _ → id-comm-sym\n }\n ; F⇐G = ntHelper record\n { η = λ DI → ntHelper record { η = λ _ → C.id ; commute = λ { refl → C.∘-resp-≈ʳ (Functor.identity DI)} }\n ; commute = λ _ → id-comm-sym\n }\n ; iso = λ X → record { isoˡ = C.identity²; isoʳ = C.identity² }\n }\n ; G∘F≈id = record\n { F⇒G = record { η = λ _ _ → C.id ; commute = λ _ _ → id-comm-sym ; sym-commute = λ _ _ → id-comm }\n ; F⇐G = record { η = λ _ _ → C.id ; commute = λ _ _ → id-comm-sym ; sym-commute = λ _ _ → id-comm }\n ; iso = λ X → record { isoˡ = λ _ → C.identity² ; isoʳ = λ _ → C.identity² }\n }\n }\n }\n where\n open C.HomReasoning\n", "meta": {"hexsha": "cab3e9fcb996a5a133dbec54a483a132ba3a2f33", "size": 2967, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Functor/Power/Functorial.agda", "max_stars_repo_name": "bblfish/agda-categories", "max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "src/Categories/Functor/Power/Functorial.agda", "max_issues_repo_name": "bblfish/agda-categories", "max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Functor/Power/Functorial.agda", "max_forks_repo_name": "bblfish/agda-categories", "max_forks_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 32.25, "max_line_length": 113, "alphanum_fraction": 0.6130771823, "num_tokens": 1015, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898279984213, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.6423641286360673}} {"text": "{-# OPTIONS --without-K --safe #-}\n\n-- Monadic Adjunctions\n-- https://ncatlab.org/nlab/show/monadic+adjunction\nmodule Categories.Adjoint.Monadic where\n\nopen import Level\n\nopen import Categories.Adjoint\nopen import Categories.Adjoint.Properties\nopen import Categories.Category\nopen import Categories.Category.Equivalence\nopen import Categories.Functor\nopen import Categories.Monad\n\nopen import Categories.Category.Construction.EilenbergMoore\nopen import Categories.Category.Construction.Properties.EilenbergMoore\n\nprivate\n variable\n o ℓ e : Level\n 𝒞 𝒟 : Category o ℓ e\n\n-- An adjunction is monadic if the adjunction \"comes from\" the induced monad in some sense.\nrecord IsMonadicAdjunction {L : Functor 𝒞 𝒟} {R : Functor 𝒟 𝒞} (adjoint : L ⊣ R) : Set (levelOfTerm 𝒞 ⊔ levelOfTerm 𝒟) where\n private\n T : Monad 𝒞\n T = adjoint⇒monad adjoint\n\n field\n Comparison⁻¹ : Functor (EilenbergMoore T) 𝒟\n comparison-equiv : WeakInverse (ComparisonF adjoint) Comparison⁻¹\n", "meta": {"hexsha": "a86a01319a976c46b642c6cdd7b115e23cd960bb", "size": 976, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Adjoint/Monadic.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Adjoint/Monadic.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Adjoint/Monadic.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 29.5757575758, "max_line_length": 124, "alphanum_fraction": 0.7674180328, "num_tokens": 277, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898102301019, "lm_q2_score": 0.7090191460821871, "lm_q1q2_score": 0.6423641216085096}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Level\nopen import Categories.Category\nopen import Categories.Monad\n\nmodule Categories.Monad.Idempotent {o ℓ e} {C : Category o ℓ e} (M : Monad C) where\n\nopen import Categories.NaturalTransformation\nopen import Categories.NaturalTransformation.Equivalence\nopen import Categories.Functor\n\nprivate\n module M = Monad M\n\nopen NaturalTransformation\n\nrecord Idempotent : Set (o ⊔ ℓ ⊔ e) where\n field\n Fη≡ηF : ∀ X → C [ η (M.F ∘ˡ M.η) X ≈ η (M.η ∘ʳ M.F) X ]\n", "meta": {"hexsha": "a3425405e6325b53442e9d52132ea8493fb9b307", "size": 503, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Monad/Idempotent.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Monad/Idempotent.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Monad/Idempotent.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 23.9523809524, "max_line_length": 83, "alphanum_fraction": 0.7196819085, "num_tokens": 153, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.905989810230102, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.6423641160379888}} {"text": "\nmodule DecidableMembership where\n\nopen import OscarPrelude\nopen import Membership\nopen import Successor\n\nrecord DecidableMembership {ℓ} (m : Set ℓ) (M : Set ℓ) ⦃ _ : Membership m M ⦄ : Set (⊹ ℓ)\n where\n field _∈?_ : (x : m) → (X : M) → Dec $ x ∈ X\n field _∉?_ : (x : m) → (X : M) → Dec $ x ∉ X\n\nopen DecidableMembership ⦃ … ⦄ public\n\ninstance DecidableMembershipList : ∀ {ℓ} {A : Set ℓ} ⦃ _ : Eq A ⦄ → DecidableMembership A $ List A\nDecidableMembership._∈?_ (DecidableMembershipList {ℓ} {A}) = _∈List?_\n where\n _∈List?_ : (a : A) → (xs : List A) → Dec (a ∈ xs)\n a ∈List? [] = no λ ()\n a ∈List? (x ∷ xs) with a ≟ x\n … | yes a≡x rewrite a≡x = yes zero\n … | no a≢x with a ∈List? xs\n … | yes a∈xs = yes (⊹ a∈xs)\n … | no a∉xs = no (λ {zero → a≢x refl ; (suc a∈xs) → a∉xs a∈xs})\nDecidableMembership._∉?_ (DecidableMembershipList {ℓ} {A}) x X with x ∈? X\nDecidableMembership._∉?_ (DecidableMembershipList {ℓ} {A}) x X | yes x∈X = no (λ x∉X → x∉X x∈X)\nDecidableMembership._∉?_ (DecidableMembershipList {ℓ} {A}) x X | no x∉X = yes x∉X\n", "meta": {"hexsha": "e0fa54ead15d3b772ed888369d864c17da5f98c7", "size": 1036, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-1/DecidableMembership.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-1/DecidableMembership.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-1/DecidableMembership.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.0, "max_line_length": 98, "alphanum_fraction": 0.6052123552, "num_tokens": 451, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898254600902, "lm_q2_score": 0.7090191214879991, "lm_q1q2_score": 0.6423641101247788}} {"text": "{-# OPTIONS --type-in-type #-}\nmodule Data where\n\nopen import Prelude\n\ndata Sigma (A : Set)(B : A -> Set) : Set\ndata Sigma A B where\n pair : (x : A) -> B x -> Sigma A B\n\nfst : {A : _} {B : _} -> Sigma A B -> A\nfst (pair x y) = x\n\nsnd : {A : _} {B : _} (p : Sigma A B) -> B (fst p)\nsnd (pair x y) = y\n\ndata Unit : Set\ndata Unit where\n tt : Unit\n\nCat : Set\nCat =\n Sigma Set (\\ Obj ->\n Sigma (Obj -> Obj -> Set) (\\ Hom ->\n Sigma ((X : _) -> Hom X X) (\\ id ->\n Sigma ((X Y Z : _) -> Hom Y Z -> Hom X Y -> Hom X Z) (\\ comp ->\n Sigma ((X Y : _)(f : Hom X Y) -> comp _ _ _ (id Y) f == f) (\\ idl ->\n Sigma ((X Y : _)(f : Hom X Y) -> comp _ _ _ f (id X) == f) (\\ idr ->\n Sigma ((W X Y Z : _)\n (f : Hom W X)(g : Hom X Y)(h : Hom Y Z) ->\n comp _ _ _ (comp _ _ _ h g) f ==\n comp _ _ _ h (comp _ _ _ g f)) (\\ assoc ->\n Unit)))))))\n\nObj : (C : Cat) -> Set\nObj C = fst C\n\nHom : (C : Cat) -> Obj C -> Obj C -> Set\nHom C = fst (snd C)\n\nid : (C : Cat) -> (X : _) -> Hom C X X\nid C = fst (snd (snd C))\n\ncomp : (C : Cat) -> (X Y Z : _) -> Hom C Y Z -> Hom C X Y -> Hom C X Z\ncomp C = fst (snd (snd (snd C)))\n\nidl : (C : Cat) -> (X Y : _)(f : Hom C X Y) ->\n comp C _ _ _ (id C Y) f == f\nidl C = fst (snd (snd (snd (snd C))))\n\nidr : (C : Cat) -> (X Y : _)(f : Hom C X Y) ->\n comp C _ _ _ f (id C X) == f\nidr C = fst (snd (snd (snd (snd (snd C)))))\n\nassoc : (C : Cat) ->\n (W X Y Z : _) (f : Hom C W X)(g : Hom C X Y)(h : Hom C Y Z) ->\n comp C _ _ _ (comp C _ _ _ h g) f ==\n comp C _ _ _ h (comp C _ _ _ g f)\nassoc C = fst (snd (snd (snd (snd (snd (snd C))))))\n", "meta": {"hexsha": "a6bb4b62b32a01f2c46803ed02ab2f00fec34467", "size": 1745, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/prototyping/term/examples/Data.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_issues_repo_path": "src/prototyping/term/examples/Data.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/prototyping/term/examples/Data.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 29.5762711864, "max_line_length": 72, "alphanum_fraction": 0.4137535817, "num_tokens": 633, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898203834277, "lm_q2_score": 0.7090191214879992, "lm_q1q2_score": 0.642364106525328}} {"text": "\nopen import Oscar.Prelude\nopen import Oscar.Class.HasEquivalence\nopen import Oscar.Class.Smap\nopen import Oscar.Class.Surjextensionality\nopen import Oscar.Class.Symmetry\nopen import Oscar.Class.Symmetrical\nopen import Oscar.Class.Transitivity\nopen import Oscar.Data.ProductIndexEquivalence\nopen import Oscar.Data.Surjextenscollation\nimport Oscar.Class.HasEquivalence.ExtensionṖroperty\nimport Oscar.Class.Surjection.⋆\nimport Oscar.Data.ExtensionṖroperty\nimport Oscar.Data.Proposequality\n\nmodule Oscar.Class.Symmetrical.ExtensionalUnifies where\n\nmodule _\n {𝔵} {𝔛 : Ø 𝔵}\n {𝔞} {𝔄 : 𝔛 → Ø 𝔞}\n {𝔟} {𝔅 : 𝔛 → Ø 𝔟}\n (let _↦_ = Arrow 𝔄 𝔅)\n {𝔠} {ℭ : 𝔛 → Ø 𝔠}\n {ℓ₁} {_↦̇_ : ∀ {x y} → x ↦ y → x ↦ y → Ø ℓ₁}\n {ℓ₂} {_∼₂_ : ∀ {y} → ℭ y → ℭ y → Ø ℓ₂}\n ⦃ _ : ∀ {y} → Symmetry.class (_∼₂_ {y}) ⦄\n ⦃ _ : ∀ {y} → Transitivity.class (_∼₂_ {y}) ⦄\n ⦃ _ : Smap!.class _↦_ (Extension ℭ) ⦄\n ⦃ _ : Surjextensionality!.class _↦_ _↦̇_ (Extension ℭ) (Pointwise _∼₂_) ⦄\n where\n\n instance\n\n 𝓢ymmetricalExtensionalUnifies : ∀ {m} → Symmetrical {𝔄 = (ℭ m)} {𝔅 = (LeftExtensionṖroperty ℓ₂ _↦_ _↦̇_ m)} surjextenscollation⟦ _↦̇_ ⟧ _≈_\n 𝓢ymmetricalExtensionalUnifies .𝓢ymmetrical.symmetrical x y .π₀ = ∁ (symmetry , symmetry)\n", "meta": {"hexsha": "a33bc2f472e1541988777dd52314e2e1156255c0", "size": 1233, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Symmetrical/ExtensionalUnifies.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Symmetrical/ExtensionalUnifies.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Symmetrical/ExtensionalUnifies.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.25, "max_line_length": 144, "alphanum_fraction": 0.6739659367, "num_tokens": 508, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9362850128595115, "lm_q2_score": 0.685949467848392, "lm_q1q2_score": 0.6422442063254067}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Groups.Lemmas\nopen import Groups.Definition\nopen import Setoids.Orders.Partial.Definition\nopen import Setoids.Setoids\nopen import Functions.Definition\nopen import Sets.EquivalenceRelations\nopen import Rings.Definition\nopen import Rings.Orders.Partial.Definition\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\n\nmodule Rings.Orders.Partial.Lemmas {n m p : _} {A : Set n} {S : Setoid {n} {m} A} {_+_ : A → A → A} {_*_ : A → A → A} {_<_ : Rel {_} {p} A} {R : Ring S _+_ _*_} {pOrder : SetoidPartialOrder S _<_} (pRing : PartiallyOrderedRing R pOrder) where\n\nabstract\n\n open PartiallyOrderedRing pRing\n open Setoid S\n open SetoidPartialOrder pOrder\n open Ring R\n open Group additiveGroup\n open Equivalence eq\n\n open import Rings.Lemmas R\n\n ringAddInequalities : {w x y z : A} → w < x → y < z → (w + y) < (x + z)\n ringAddInequalities {w = w} {x} {y} {z} w → n})\n-- e : ∀{P : N → Type{Lvl.𝟎}} → (∀{empty} → P(z empty)) → (∀{n} → P(n) → P(s n)) → (∀{n} → P(n)) -- TODO: Is this a correct eliminator? Note: It does not pass the termination checker\n-- e pz ps {sup 𝐹 b} = pz\n-- e pz ps {sup 𝑇 b} = ps (e pz (\\{n} → ps{n}) {b <>})\nrecord W {A : Type{ℓ₁}} (B : A → Type{ℓ₂}) : Type{ℓ₁ Lvl.⊔ ℓ₂} where\n inductive\n eta-equality\n constructor sup\n field\n a : A\n b : B(a) → W(B)\n\n-- TODO: Is the type of this eliminator correct?\n-- W-elim : ∀{A : Type{ℓ₁}}{B : A → Type{ℓ₂}}{P : W(B) → Type{ℓ}} → (∀{a : A}{b : B(a) → W(B)} → (∀{ba : B(a)} → P(b(ba))) → P(sup a b)) → (∀{w : W(B)} → P(w))\n\n-- TODO: Note that this is essentially Sets.IterativeSet\nV : ∀{ℓ₁} → Type{Lvl.𝐒(ℓ₁)}\nV {ℓ₁} = W {A = Type{ℓ₁}} id\n", "meta": {"hexsha": "cb80acc682c4d5b3e2c5659c3042b44f5751e989", "size": 2714, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Type/WellOrdering.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Type/WellOrdering.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Type/WellOrdering.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.7931034483, "max_line_length": 256, "alphanum_fraction": 0.5858511422, "num_tokens": 821, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289388083214156, "lm_q2_score": 0.7745833789613196, "lm_q1q2_score": 0.6420822231017718}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.CommMonoid.CommMonoidProd where\n\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Data.Sigma\n\nopen import Cubical.Algebra.Monoid\nopen import Cubical.Algebra.Semigroup\nopen import Cubical.Algebra.CommMonoid.Base\n\n\nopen CommMonoidStr\nopen IsCommMonoid hiding (rid ; lid)\nopen IsMonoid hiding (rid ; lid)\nopen IsSemigroup\n\n\nprivate\n variable\n ℓ ℓ' : Level\n\n\nCommMonoidProd : CommMonoid ℓ → CommMonoid ℓ' → CommMonoid (ℓ-max ℓ ℓ')\nCommMonoidProd M N = makeCommMonoid ε× _·×_ is-set× assoc× rid× comm×\n where\n ε× : (fst M) × (fst N)\n ε× = (ε (snd M)) , (ε (snd N))\n\n _·×_ : (fst M) × (fst N) → (fst M) × (fst N) → (fst M) × (fst N)\n (x₁ , x₂) ·× (y₁ , y₂) = (_·_ (snd M) x₁ y₁) , (_·_ (snd N) x₂ y₂)\n\n is-set× : isSet ((fst M) × (fst N))\n is-set× = isSet× (is-set (snd M)) (is-set (snd N))\n\n assoc× : ∀ x y z → x ·× (y ·× z) ≡ (x ·× y) ·× z\n assoc× _ _ _ = cong₂ (_,_) (assoc (snd M) _ _ _) (assoc (snd N) _ _ _)\n\n rid× : ∀ x → x ·× ε× ≡ x\n rid× _ = cong₂ (_,_) (rid (snd M) _) (rid (snd N) _)\n\n comm× : ∀ x y → x ·× y ≡ y ·× x\n comm× _ _ = cong₂ (_,_) (comm (snd M) _ _) (comm (snd N) _ _)\n", "meta": {"hexsha": "c6e11fc4939477edb678725d1a6ed3ff8beaa632", "size": 1202, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommMonoid/CommMonoidProd.agda", "max_stars_repo_name": "guilhermehas/cubical", "max_stars_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_issues_repo_path": "Cubical/Algebra/CommMonoid/CommMonoidProd.agda", "max_issues_repo_name": "guilhermehas/cubical", "max_issues_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/CommMonoid/CommMonoidProd.agda", "max_forks_repo_name": "guilhermehas/cubical", "max_forks_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.7111111111, "max_line_length": 72, "alphanum_fraction": 0.5990016639, "num_tokens": 476, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314828740728, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.64196793758182}} {"text": "{-# OPTIONS --exact-split #-}\n\nmodule ExactSplitMin where\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\nmin : ℕ → ℕ → ℕ\nmin zero y = zero\nmin x zero = zero\nmin (suc x) (suc y) = suc (min x y)\n", "meta": {"hexsha": "ee546fcc53dc90fbd147b5c057f5701751b6afce", "size": 211, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/ExactSplitMin.agda", "max_stars_repo_name": "alhassy/agda", "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Fail/ExactSplitMin.agda", "max_issues_repo_name": "alhassy/agda", "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Fail/ExactSplitMin.agda", "max_forks_repo_name": "alhassy/agda", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 16.2307692308, "max_line_length": 35, "alphanum_fraction": 0.5355450237, "num_tokens": 73, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8856314617436728, "lm_q2_score": 0.7248702880639791, "lm_q1q2_score": 0.6419679327926591}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\nopen import Categories.Comonad\n\n-- verbatim dual of Categories.Category.Construction.EilenbergMoore\nmodule Categories.Category.Construction.CoEilenbergMoore {o ℓ e} {C : Category o ℓ e} (M : Comonad C) where\n\nopen import Level\n\nopen import Categories.Morphism.Reasoning C\n\nprivate\n module C = Category C\n module M = Comonad M\n open C\n open M.F\n open HomReasoning\n open Equiv\n\nrecord Comodule : Set (o ⊔ ℓ ⊔ e) where\n field\n A : Obj\n coaction : A ⇒ F₀ A\n commute : F₁ coaction ∘ coaction ≈ M.δ.η A ∘ coaction\n identity : M.ε.η A ∘ coaction ≈ C.id\n\nrecord Comodule⇒ (X Y : Comodule) : Set (ℓ ⊔ e) where\n private\n module X = Comodule X\n module Y = Comodule Y\n field\n arr : X.A ⇒ Y.A\n commute : Y.coaction ∘ arr ≈ F₁ arr ∘ X.coaction\n\nCoEilenbergMoore : Category (o ⊔ ℓ ⊔ e) (ℓ ⊔ e) e\nCoEilenbergMoore =\n record\n { Obj = Comodule\n ; _⇒_ = Comodule⇒\n ; _≈_ = λ f g → Comodule⇒.arr f ≈ Comodule⇒.arr g\n ; id = record { arr = C.id ; commute = identityʳ ○ introˡ identity }\n ; _∘_ = compose\n ; assoc = assoc\n ; sym-assoc = sym-assoc\n ; identityˡ = identityˡ\n ; identityʳ = identityʳ\n ; identity² = identity²\n ; equiv = record { refl = refl ; sym = sym ; trans = trans }\n ; ∘-resp-≈ = ∘-resp-≈\n }\n where\n open Equiv\n compose : ∀ {X Y Z} → Comodule⇒ Y Z → Comodule⇒ X Y → Comodule⇒ X Z\n compose {X} {Y} {Z} f g = record\n { arr = f.arr ∘ g.arr\n ; commute = begin\n Comodule.coaction Z ∘ f.arr ∘ g.arr ≈⟨ pullˡ f.commute ⟩\n (F₁ f.arr ∘ Comodule.coaction Y) ∘ g.arr ≈⟨ pullʳ g.commute ⟩\n F₁ f.arr ∘ F₁ g.arr ∘ Comodule.coaction X ≈⟨ pullˡ (sym homomorphism) ⟩\n F₁ (f.arr ∘ g.arr) ∘ Comodule.coaction X ∎\n }\n where module f = Comodule⇒ f\n module g = Comodule⇒ g\n", "meta": {"hexsha": "b49a5188dd1f9afa46875710550a368cf835da51", "size": 1839, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Construction/CoEilenbergMoore.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-05-21T17:07:19.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-22T03:54:24.000Z", "max_issues_repo_path": "src/Categories/Category/Construction/CoEilenbergMoore.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Construction/CoEilenbergMoore.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.2923076923, "max_line_length": 107, "alphanum_fraction": 0.6133768352, "num_tokens": 697, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314768368161, "lm_q2_score": 0.7248702702332475, "lm_q1q2_score": 0.6419679279417729}} {"text": "module Function.Iteration where\n\nopen import Data\nopen import Functional\nopen import Numeral.Natural\nopen import Type\nopen import Syntax.Number\n\nmodule _ {ℓ} {T : Type{ℓ}} where\n -- Repeated function composition\n -- Example:\n -- f ^ 0 = id\n -- f ^ 1 = f\n -- f ^ 2 = f ∘ f\n -- f ^ 3 = f ∘ f ∘ f\n -- f ^ 4 = f ∘ f ∘ f ∘ f\n _^_ : (T → T) → ℕ → (T → T)\n _^_ f 𝟎 = id\n _^_ f (𝐒(n)) = f ∘ (f ^ n)\n\n _⁰ : (T → T) → (T → T)\n _⁰ = _^ 0\n\n _¹ : (T → T) → (T → T)\n _¹ = _^ 1\n\n _² : (T → T) → (T → T)\n _² = _^ 2\n\n _³ : (T → T) → (T → T)\n _³ = _^ 3\n\n _⁴ : (T → T) → (T → T)\n _⁴ = _^ 4\n\n _⁵ : (T → T) → (T → T)\n _⁵ = _^ 5\n\n _⁶ : (T → T) → (T → T)\n _⁶ = _^ 6\n\n _⁷ : (T → T) → (T → T)\n _⁷ = _^ 7\n\n _⁸ : (T → T) → (T → T)\n _⁸ = _^ 8\n\n _⁹ : (T → T) → (T → T)\n _⁹ = _^ 9\n\nmodule _ {ℓ₁}{ℓ₂} {X : Type{ℓ₁}} {Y : Type{ℓ₂}} where\n -- Repeat a binary operation n times for the same element and an initial element\n -- Example: repeatₗ 3 id (_∘_) f = ((id ∘ f) ∘ f) ∘ f\n -- Example in Haskell: (foldl (.) (id) (take 5 (repeat f)))\n -- Implementation in Haskell: (\\n null op elem -> foldl op null (take n (repeat elem))) :: Int -> a -> (b -> a -> b) -> b -> b\n repeatₗ : ℕ → (Y → X → Y) → (Y → X → Y)\n repeatₗ n (_▫_) null elem = ((_▫ elem) ^ n) (null)\n\n -- Repeat a binary operation n times for the same element and an initial element\n -- Example: repeatᵣ 3 id (_∘_) f = f ∘ (f ∘ (f ∘ id))\n -- Implementation in Haskell: (\\n elem op null -> foldr op null (take n (repeat elem))) :: Int -> a -> (a -> b -> b) -> b -> b\n repeatᵣ : ℕ → (X → Y → Y) → (X → Y → Y)\n repeatᵣ n (_▫_) elem = (elem ▫_) ^ n\n\nmodule _ {ℓ} {X : Type{ℓ}} where\n -- Repeat a binary operation n times for the same element and using the default element on zero.\n -- Examples:\n -- repeatₗ 0 def (_∘_) f = def\n -- repeatₗ 1 def (_∘_) f = f\n -- repeatₗ 4 def (_∘_) f = ((f ∘ f) ∘ f) ∘ f\n repeatₗ-default : ℕ → (X → X → X) → X → (X → X)\n repeatₗ-default 𝟎 _ def _ = def\n repeatₗ-default (𝐒(n)) (_▫_) _ elem = repeatₗ(n) (_▫_) elem elem\n\n -- Repeat a binary operation n times for the same element and using the default element on zero.\n -- Examples:\n -- repeatᵣ 0 f (_∘_) def = def\n -- repeatᵣ 1 f (_∘_) def = f\n -- repeatᵣ 4 f (_∘_) def = f ∘ (f ∘ (f ∘ f))\n repeatᵣ-default : ℕ → (X → X → X) → X → (X → X)\n repeatᵣ-default 𝟎 _ _ def = def\n repeatᵣ-default (𝐒(n)) (_▫_) elem _ = repeatᵣ(n) (_▫_) elem elem\n", "meta": {"hexsha": "851cfd054fb8bcbe96db1c338bd41835c36984e6", "size": 2455, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Function/Iteration.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Function/Iteration.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Function/Iteration.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.578313253, "max_line_length": 128, "alphanum_fraction": 0.5018329939, "num_tokens": 1086, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094060543487, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.6419271354050049}} {"text": "{-# OPTIONS --sized-types #-}\n\nmodule SizedTypesMergeSort where\n\npostulate\n Size : Set\n _^ : Size -> Size\n ∞ : Size\n\n{-# BUILTIN SIZE Size #-}\n{-# BUILTIN SIZESUC _^ #-}\n{-# BUILTIN SIZEINF ∞ #-}\n\n-- sized lists\n\ndata List (A : Set) : {_ : Size} -> Set where\n [] : {size : Size} -> List A {size ^}\n _::_ : {size : Size} -> A -> List A {size} -> List A {size ^}\n\n-- CPS split\n\nsplit : {A : Set}{i : Size} -> List A {i} ->\n {C : Set} -> (List A {i} -> List A {i} -> C) -> C\nsplit [] k = k [] []\nsplit (x :: xs) k = split xs (\\ l r -> k (x :: r) l)\n\n\nmodule Sort (A : Set) (compare : A -> A -> {B : Set} -> B -> B -> B) where\n\n{- merge is currently rejected by the termination checker\n it would be nice if it worked\n see test/succeed/SizedTypesMergeSort.agda\n -}\n merge : List A -> List A -> List A\n merge [] ys = ys\n merge xs [] = xs\n merge (x :: xs) (y :: ys) =\n compare x y (x :: merge xs (y :: ys))\n (y :: merge (x :: xs) ys)\n\n sort : {i : Size} -> List A {i} -> List A\n sort [] = []\n sort (x :: []) = x :: []\n sort (x :: (y :: xs)) = split xs (\\ l r -> merge (sort (x :: l))\n (sort (y :: r)))\n", "meta": {"hexsha": "34fc866f73b8900a2e1d80e718a797433fc14ed6", "size": 1203, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/bugs/SizedTypesMergeSort.agda", "max_stars_repo_name": "alhassy/agda", "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/bugs/SizedTypesMergeSort.agda", "max_issues_repo_name": "alhassy/agda", "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/bugs/SizedTypesMergeSort.agda", "max_forks_repo_name": "alhassy/agda", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 26.152173913, "max_line_length": 74, "alphanum_fraction": 0.4671654198, "num_tokens": 393, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951182587158, "lm_q2_score": 0.760650658103136, "lm_q1q2_score": 0.6419093770735159}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Examples showing how the generic n-ary operations the stdlib provides\n-- can be used\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule README.Nary where\n\nopen import Level using (Level)\nopen import Data.Nat.Base\nopen import Data.Nat.Properties\nopen import Data.Fin using (Fin; fromℕ; #_; inject₁)\nopen import Data.List\nopen import Data.List.Properties\nopen import Data.Product using (_×_; _,_)\nopen import Data.Sum using (inj₁; inj₂)\nopen import Function\nopen import Relation.Nullary\nopen import Relation.Binary using (module Tri); open Tri\nopen import Relation.Binary.PropositionalEquality\n\nprivate\n variable\n a b c d e : Level\n A : Set a\n B : Set b\n C : Set c\n D : Set d\n E : Set e\n\n------------------------------------------------------------------------\n-- Introduction\n------------------------------------------------------------------------\n\n-- Function.Nary.NonDependent and Data.Product.N-ary.Heterogeneous provide\n-- a generic representation of n-ary heterogeneous (non dependent) products\n-- and the corresponding types of (non-dependent) n-ary functions. The\n-- representation works well with inference thus allowing us to use generic\n-- combinators to manipulate such functions.\n\nopen import Data.Product.Nary.NonDependent\nopen import Function.Nary.NonDependent\nopen import Relation.Nary\n\n\n------------------------------------------------------------------------\n-- Generalised equality-manipulating combinators\n------------------------------------------------------------------------\n\n-- By default the standard library provides users with (we are leaving out\n-- the implicit arguments here):\n--\n-- cong : (f : A₁ → B) → a₁ ≡ b₁ → f a₁ ≡ f b₁\n-- cong₂ : (f : A₁ → A₂ → B) → a₁ ≡ b₁ → a₂ ≡ b₂ → f a₁ a₂ ≡ f b₁ b₂\n--\n-- and\n--\n-- subst : (P : A₁ → Set p) → a₁ ≡ b₁ → P a₁ → P b₁\n-- subst₂ : (P : A₁ → A₂ → Set p) → a₁ ≡ b₁ → a₂ ≡ b₂ → P a₁ a₂ → P b₁ b₂\n--\n-- This pattern can be generalised to any natural number `n`. Thanks to our\n-- library for n-ary functions, we can write the types and implementations\n-- of `congₙ` and `substₙ`.\n\n------------------------------------------------------------------------\n-- congₙ : ∀ n (f : A₁ → ⋯ → Aₙ → B) →\n-- a₁ ≡ b₁ → ⋯ aₙ ≡ bₙ → f a₁ ⋯ aₙ ≡ f b₁ ⋯ bₙ\n\n-- It may be used directly to prove something:\n\n_ : ∀ (as bs cs : List ℕ) →\n zip (zip (as ++ []) (map id cs)) (reverse (reverse bs))\n ≡ zip (zip as cs) bs\n_ = λ as bs cs → congₙ 3 (λ as bs → zip (zip as bs))\n (++-identityʳ as)\n (map-id cs)\n (reverse-involutive bs)\n\n-- Or as part of a longer derivation:\n\n_ : ∀ m n p q → suc (m + (p * n) + (q ^ (m + n)))\n ≡ (m + 0) + (n * p) + (q ^ m * q ^ n) + 1\n_ = λ m n p q → begin\n suc (m + (p * n) + (q ^ (m + n))) ≡⟨ +-comm 1 _ ⟩\n m + (p * n) + (q ^ (m + n)) + 1 ≡⟨ congₙ 3 (λ m n p → m + n + p + 1)\n (+-comm 0 m)\n (*-comm p n)\n (^-distribˡ-+-* q m n)\n ⟩\n m + 0 + n * p + (q ^ m) * (q ^ n) + 1 ∎ where open ≡-Reasoning\n\n-- Partial application of the functional argument is fine: the number of arguments\n-- `congₙ` is going to take is determined by its first argument (a natural number)\n-- and not by the type of the function it works on.\n\n_ : ∀ m → (m +_) ≡ ((m + 0) +_)\n_ = λ m → congₙ 1 _+_ (+-comm 0 m)\n\n-- We don't have to work on the function's first argument either: we can just as\n-- easily use `congₙ` to act on the second one by `flip`ping it. See `holeₙ` for\n-- a generalisation of this idea allowing to target *any* of the function's\n-- arguments and not just the first or second one.\n\n_ : ∀ m → (_+ m) ≡ (_+ (m + 0))\n_ = λ m → congₙ 1 (flip _+_) (+-comm 0 m)\n\n------------------------------------------------------------------------\n-- substₙ : (P : A₁ → ⋯ → Aₙ → Set p) →\n-- a₁ ≡ b₁ → ⋯ aₙ ≡ bₙ → P a₁ ⋯ aₙ → P b₁ ⋯ bₙ\n\n-- We can play the same type of game with subst\n\nopen import Agda.Builtin.Nat using (mod-helper)\n\n-- Because we know from the definition `mod-helper` that this equation holds:\n-- mod-helper k m (suc n) (suc j) = mod-helper (suc k) m n j\n-- we should be able to prove the slightly modified statement by transforming\n-- all the `x + 1` into `suc x`. We can do so using `substₙ`.\n\n_ : ∀ k m n j → mod-helper k m (n + 1) (j + 1) ≡ mod-helper (k + 1) m n j\n_ = λ k m n j →\n let P sk sn sj = mod-helper k m sn sj ≡ mod-helper sk m n j\n in substₙ P (+-comm 1 k) (+-comm 1 n) (+-comm 1 j) refl\n\n-----------------------------------------------------------------------\n-- Generic programs working on n-ary products & functions\n-----------------------------------------------------------------------\n\n-----------------------------------------------------------------------\n-- curryₙ : ∀ n → (A₁ × ⋯ × Aₙ → B) → A₁ → ⋯ → Aₙ → B\n-- uncurryₙ : ∀ n → (A₁ → ⋯ → Aₙ → B) → A₁ × ⋯ × Aₙ → B\n\n-- The first thing we may want to do generically is convert between\n-- curried function types and uncurried ones. We can do this by using:\n\n-- They both work the same way so we will focus on curryₙ only here.\n-- If we pass to `curryₙ` the arity of its argument then we obtain a\n-- fully curried function.\n\ncurry₁ : (A × B × C × D → E) → A → B → C → D → E\ncurry₁ = curryₙ 4\n\n-- Note that here we are not flattening arbitrary nestings: products have\n-- to be right nested. Which means that if you have a deeply-nested product\n-- then it won't be affected by the procedure.\n\ncurry₁' : (A × (B × C) × D → E) → A → (B × C) → D → E\ncurry₁' = curryₙ 3\n\n-- When we are currying a function, we have no obligation to pass its exact\n-- arity as the parameter: we can decide to only curry part of it like so:\n-- Indeed (A₁ × ⋯ × Aₙ → B) can also be seen as (A₁ × ⋯ × (Aₖ × ⋯ × Aₙ) → B)\n\ncurry₂ : (A × B × C × D → E) → A → B → (C × D) → E\ncurry₂ = curryₙ 3\n\n-----------------------------------------------------------------------\n-- projₙ : ∀ n (k : Fin n) → (A₁ × ⋯ × Aₙ) → Aₖ₊₁\n\n-- Another useful class of functions to manipulate n-ary product is a\n-- generic projection function. Note the (k + 1) in the return index:\n-- Fin counts from 0 up.\n\n-- It behaves as one expects (Data.Fin's #_ comes in handy to write down\n-- Fin literals):\n\nproj₃ : (A × B × C × D × E) → C\nproj₃ = projₙ 5 (# 2)\n\n-- Of course we can once more project the \"tail\" of the n-ary product by\n-- passing `projₙ` a natural number which is smaller than the size of the\n-- n-ary product, seeing (A₁ × ⋯ × Aₙ) as (A₁ × ⋯ × (Aₖ × ⋯ × Aₙ)).\n\nproj₃' : (A × B × C × D × E) → C × D × E\nproj₃' = projₙ 3 (# 2)\n\n-----------------------------------------------------------------------\n-- insertₙ : ∀ n (k : Fin (suc n)) →\n-- B → (A₁ × ⋯ Aₙ) → (A₁ × ⋯ × Aₖ × B × Aₖ₊₁ × ⋯ Aₙ)\n\ninsert₁ : C → (A × B × D × E) → (A × B × C × D × E)\ninsert₁ = insertₙ 4 (# 2)\n\ninsert₁' : C → (A × B × D × E) → (A × B × C × D × E)\ninsert₁' = insertₙ 3 (# 2)\n\n-- Note that `insertₙ` takes a `Fin (suc n)`. Indeed in an n-ary product\n-- there are (suc n) positions at which one may insert a value. We may\n-- insert at the front or the back of the product:\n\ninsert-front : A → (B × C × D × E) → (A × B × C × D × E)\ninsert-front = insertₙ 4 (# 0)\n\ninsert-back : E → (A × B × C × D) → (A × B × C × D × E)\ninsert-back = insertₙ 4 (# 4)\n\n-----------------------------------------------------------------------\n-- removeₙ : ∀ n (k : Fin n) → (A₁ × ⋯ Aₙ) → (A₁ × ⋯ × Aₖ × Aₖ₊₂ × ⋯ Aₙ)\n\n-- Dual to `insertₙ`, we may remove a value.\n\nremove₁ : (A × B × C × D × E) → (A × B × D × E)\nremove₁ = removeₙ 5 (# 2)\n\n-- Inserting at `k` and then removing at `inject₁ k` should yield the identity\n\nremove-insert : C → (A × B × D × E) → (A × B × D × E)\nremove-insert c = removeₙ 5 (inject₁ k) ∘′ insertₙ 4 k c\n where k = # 2\n\n-----------------------------------------------------------------------\n-- updateₙ : ∀ n (k : Fin n) (f : (a : Aₖ₊₁) → B a) →\n-- (p : A₁ × ⋯ Aₙ) → (A₁ × ⋯ × Aₖ × B (projₙ n k p) × Aₖ₊₂ × ⋯ Aₙ)\n\n-- We can not only project out, insert or remove values: we can update them\n-- in place. The type (and value) of the replacement at position k may depend\n-- upon the current value at position k.\n\nupdate₁ : (p : A × B × ℕ × C × D) → (A × B × Fin _ × C × D)\nupdate₁ = updateₙ 5 (# 2) fromℕ\n\n-- We can explicitly use the primed version of `updateₙ` to make it known to\n-- Agda that the update function is non dependent. This type of information\n-- is useful for inference: the tighter the constraints, the easier it is to\n-- find a solution (if possible).\n\nupdate₂ : (p : A × B × ℕ × C × D) → (A × B × List D × C × D)\nupdate₂ = λ p → updateₙ′ 5 (# 2) (λ n → replicate n (projₙ 5 (# 4) p)) p\n\n-----------------------------------------------------------------------\n-- _%=_⊢_ : ∀ n → (C → D) → (A₁ → ⋯ Aₙ → D → B) → A₁ → ⋯ → Aₙ → C → B\n\n-- Traditional composition (also known as the index update operator `_⊢_`\n-- in `Relation.Unary`) focuses solely on the first argument of an n-ary\n-- function. `_%=_⊢_` on the other hand allows us to touch any one of the\n-- arguments.\n\n-- In the following example we have a function `f : A → B` and `replicate`\n-- of type `ℕ → B → List B`. We want ̀f` to act on the second argument of\n-- replicate. Which we can do like so.\n\ncompose₁ : (A → B) → ℕ → A → List B\ncompose₁ f = 1 %= f ⊢ replicate\n\n-- Here we spell out the equivalent explicit variable-manipulation and\n-- prove the two functions equal.\n\ncompose₁' : (A → B) → ℕ → A → List B\ncompose₁' f n a = replicate n (f a)\n\ncompose₁-eq : compose₁ {a} {A} {b} {B} ≡ compose₁'\ncompose₁-eq = refl\n\n-----------------------------------------------------------------------\n-- _∷=_⊢_ : ∀ n → A → (A₁ → ⋯ Aₙ → A → B) → A₁ → ⋯ → Aₙ → B\n\n-- Partial application usually focuses on the first argument of a function.\n-- We can now partially apply a function in any of its arguments using\n-- `_∷=_⊢_`. Reusing our example involving replicate: we can specialise it\n-- to only output finite lists of `0`:\n\napply₁ : ℕ → List ℕ\napply₁ = 1 ∷= 0 ⊢ replicate\n\napply₁-eq : apply₁ 3 ≡ 0 ∷ 0 ∷ 0 ∷ []\napply₁-eq = refl\n\n------------------------------------------------------------------------\n-- holeₙ : ∀ n → (A → (A₁ → ⋯ Aₙ → B)) → A₁ → ⋯ → Aₙ → (A → B)\n\n-- As we have seen earlier, `cong` acts on a function's first variable.\n-- If we want to access the second one, we can use `flip`. But what about\n-- the fourth one? We typically use an explicit λ-abstraction shuffling\n-- variables. Not anymore.\n\n-- Reusing mod-helper just because it takes a lot of arguments:\n\nhole₁ : ∀ k m n j → mod-helper k (m + 1) n j ≡ mod-helper k (suc m) n j\nhole₁ = λ k m n j → cong (holeₙ 2 (mod-helper k) n j) (+-comm m 1)\n\n-----------------------------------------------------------------------\n-- mapₙ : ∀ n → (B → C) → (A₁ → ⋯ Aₙ → B) → (A₁ → ⋯ → Aₙ → C)\n\n-- (R →_) gives us the reader monad (and, a fortiori, functor). That is to\n-- say that given a function (A → B) and an (R → A) we can get an (R → B)\n-- This generalises to n-ary functions.\n\n-- Reusing our `composeₙ` example: instead of applying `f` to the replicated\n-- element, we can map it on the resulting list. Giving us:\n\nmap₁ : (A → B) → ℕ → A → List B\nmap₁ f = mapₙ 2 (map f) replicate\n\n------------------------------------------------------------------------\n-- constₙ : ∀ n → B → A₁ → ⋯ → Aₙ → B\n\n-- `const` is basically `pure` for the reader monad discussed above. Just\n-- like we can generalise the functorial action corresponding to the reader\n-- functor to n-ary functions, we can do the same for `pure`.\n\nconst₁ : A → B → C → D → E → A\nconst₁ = constₙ 4\n\n-- Together with `holeₙ`, this means we can make a constant function out\n-- of any of the arguments. The fourth for instance:\n\nconst₂ : A → B → C → D → E → D\nconst₂ = holeₙ 3 (constₙ 4)\n\n------------------------------------------------------------------------\n-- Generalised quantifiers\n------------------------------------------------------------------------\n\n-- As we have seen multiple times already, one of the advantages of working\n-- with non-dependent products is that they can be easily inferred. This is\n-- a prime opportunity to define generic quantifiers.\n\n-- And because n-ary relations are Set-terminated, there is no ambiguity\n-- where to split between arguments & codomain. As a consequence Agda can\n-- infer even `n`, the number of arguments. We can use notations which are\n-- just like the ones defined in `Relation.Unary`.\n\n------------------------------------------------------------------------\n-- ∃⟨_⟩ : (A₁ → ⋯ → Aₙ → Set r) → Set _\n-- ∃⟨ P ⟩ = ∃ λ a₁ → ⋯ → ∃ λ aₙ → P a₁ ⋯ aₙ\n\n-- Returning to our favourite function taking a lot of arguments: we can\n-- find a set of input for which it evaluates to 666\n\nexist₁ : ∃⟨ (λ k m n j → mod-helper k m n j ≡ 666) ⟩\nexist₁ = 19 , 793 , 3059 , 10 , refl\n\n------------------------------------------------------------------------\n-- ∀[_] : (A₁ → ⋯ → Aₙ → Set r) → Set _\n-- ∀[_] P = ∀ {a₁} → ⋯ → ∀ {aₙ} → P a₁ ⋯ aₙ\n\nall₁ : ∀[ (λ (a₁ a₂ : ℕ) → Dec (a₁ ≡ a₂)) ]\nall₁ {a₁} {a₂} = a₁ ≟ a₂\n\n------------------------------------------------------------------------\n-- Π : (A₁ → ⋯ → Aₙ → Set r) → Set _\n-- Π P = ∀ a₁ → ⋯ → ∀ aₙ → P a₁ ⋯ aₙ\n\nall₂ : Π[ (λ (a₁ a₂ : ℕ) → Dec (a₁ ≡ a₂)) ]\nall₂ = _≟_\n\n------------------------------------------------------------------------\n-- _⇒_ : (A₁ → ⋯ → Aₙ → Set r) → (A₁ → ⋯ → Aₙ → Set s) → (A₁ → ⋯ → Aₙ → Set _)\n-- P ⇒ Q = λ a₁ → ⋯ → λ aₙ → P a₁ ⋯ aₙ → Q a₁ ⋯ aₙ\n\nantisym : ∀[ _≤_ ⇒ _≥_ ⇒ _≡_ ]\nantisym = ≤-antisym\n\n------------------------------------------------------------------------\n-- _∪_ : (A₁ → ⋯ → Aₙ → Set r) → (A₁ → ⋯ → Aₙ → Set s) → (A₁ → ⋯ → Aₙ → Set _)\n-- P ∪ Q = λ a₁ → ⋯ → λ aₙ → P a₁ ⋯ aₙ ⊎ Q a₁ ⋯ aₙ\n\n≤->-connex : Π[ _≤_ ∪ _>_ ]\n≤->-connex m n with <-cmp m n\n... | tri< a ¬b ¬c = inj₁ (<⇒≤ a)\n... | tri≈ ¬a b ¬c = inj₁ (≤-reflexive b)\n... | tri> ¬a ¬b c = inj₂ c\n\n------------------------------------------------------------------------\n-- _∩_ : (A₁ → ⋯ → Aₙ → Set r) → (A₁ → ⋯ → Aₙ → Set s) → (A₁ → ⋯ → Aₙ → Set _)\n-- P ∩ Q = λ a₁ → ⋯ → λ aₙ → P a₁ ⋯ aₙ × Q a₁ ⋯ aₙ\n\n<-inversion : ∀[ _<_ ⇒ _≤_ ∩ _≢_ ]\n<-inversion m_ ⇒ ∁ _≤_ ]\nmn m≤n = <⇒≱ m>n m≤n\n", "meta": {"hexsha": "3ea619e7462551579ef5a7fef5c448dd7c8ad731", "size": 14592, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/README/Nary.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/README/Nary.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/README/Nary.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 38.4, "max_line_length": 82, "alphanum_fraction": 0.4950657895, "num_tokens": 4790, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950907764118, "lm_q2_score": 0.7606506526772884, "lm_q1q2_score": 0.6419093515902371}} {"text": "------------------------------------------------------------------------------\n-- Equivalence of definitions of total lists\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule LFPs.List where\n\nopen import FOTC.Base\nopen import FOTC.Base.List\nopen import FOTC.Data.Nat.UnaryNumbers\n\n------------------------------------------------------------------------------\nmodule LFP where\n\n -- List is a least fixed-point of a functor\n\n -- The functor.\n ListF : (D → Set) → D → Set\n ListF A xs = xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ A xs')\n\n -- List is the least fixed-point of ListF. i.e.\n postulate\n List : D → Set\n\n -- List is a pre-fixed point of ListF, i.e.\n --\n -- ListF List ≤ List.\n --\n -- Peter: It corresponds to the introduction rules.\n List-in : ∀ {xs} → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ List xs') →\n List xs\n\n -- The higher-order version.\n List-in-ho : {xs : D} → ListF List xs → List xs\n\n -- List is the least pre-fixed point of ListF, i.e.\n --\n -- ∀ A. ListF A ≤ A ⇒ List ≤ A.\n --\n -- Peter: It corresponds to the elimination rule of an inductively\n -- defined predicate.\n List-ind :\n (A : D → Set) →\n (∀ {xs} → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ A xs') → A xs) →\n ∀ {xs} → List xs → A xs\n\n -- Higher-order version.\n List-ind-ho :\n (A : D → Set) →\n (∀ {xs} → ListF A xs → A xs) →\n ∀ {xs} → List xs → A xs\n\n ----------------------------------------------------------------------------\n -- List-in and List-in-ho are equivalents\n\n List-in-fo : ∀ {xs} → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ List xs') →\n List xs\n List-in-fo = List-in-ho\n\n List-in-ho' : {xs : D} → ListF List xs → List xs\n List-in-ho' = List-in-ho\n\n ----------------------------------------------------------------------------\n -- List-ind and List-ind-ho are equivalents\n\n List-ind-fo :\n (A : D → Set) →\n (∀ {xs} → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ A xs') → A xs) →\n ∀ {xs} → List xs → A xs\n List-ind-fo = List-ind-ho\n\n List-ind-ho' :\n (A : D → Set) →\n (∀ {xs} → ListF A xs → A xs) →\n ∀ {xs} → List xs → A xs\n List-ind-ho' = List-ind\n\n ----------------------------------------------------------------------------\n -- The data constructors of List.\n lnil : List []\n lnil = List-in (inj₁ refl)\n\n lcons : ∀ x {xs} → List xs → List (x ∷ xs)\n lcons x {xs} Lxs = List-in (inj₂ (x , xs , refl , Lxs))\n\n ----------------------------------------------------------------------------\n -- The type theoretical induction principle for List.\n List-ind' : (A : D → Set) →\n A [] →\n (∀ x {xs} → A xs → A (x ∷ xs)) →\n ∀ {xs} → List xs → A xs\n List-ind' A A[] is = List-ind A prf\n where\n prf : ∀ {xs} → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ A xs') → A xs\n prf (inj₁ xs≡[]) = subst A (sym xs≡[]) A[]\n prf (inj₂ (x' , xs' , h₁ , Axs')) = subst A (sym h₁) (is x' Axs')\n\n ----------------------------------------------------------------------------\n -- Example\n\n xs : D\n xs = 0' ∷ true ∷ 1' ∷ false ∷ []\n\n xs-List : List xs\n xs-List = lcons 0' (lcons true (lcons 1' (lcons false lnil)))\n\n------------------------------------------------------------------------------\nmodule Data where\n\n data List : D → Set where\n lnil : List []\n lcons : ∀ x {xs} → List xs → List (x ∷ xs)\n\n -- Induction principle.\n List-ind : (A : D → Set) →\n A [] →\n (∀ x {xs} → A xs → A (x ∷ xs)) →\n ∀ {xs} → List xs → A xs\n List-ind A A[] h lnil = A[]\n List-ind A A[] h (lcons x Lxs) = h x (List-ind A A[] h Lxs)\n\n ----------------------------------------------------------------------------\n -- List-in\n\n List-in : ∀ {xs} → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ List xs') →\n List xs\n List-in {xs} h = case prf₁ prf₂ h\n where\n prf₁ : xs ≡ [] → List xs\n prf₁ xs≡[] = subst List (sym xs≡[]) lnil\n\n prf₂ : ∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ List xs' → List xs\n prf₂ (x' , xs' , prf , Lxs') = subst List (sym prf) (lcons x' Lxs')\n\n ----------------------------------------------------------------------------\n -- The fixed-point induction principle for List.\n\n List-ind' :\n (A : D → Set) →\n (∀ {xs} → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ A xs') → A xs) →\n ∀ {xs} → List xs → A xs\n List-ind' A h Lxs = List-ind A h₁ h₂ Lxs\n where\n h₁ : A []\n h₁ = h (inj₁ refl)\n\n h₂ : ∀ y {ys} → A ys → A (y ∷ ys)\n h₂ y {ys} Ays = h (inj₂ (y , ys , refl , Ays))\n", "meta": {"hexsha": "11089e25fc9714c377e6102dc8b0e36c80a1030f", "size": 4772, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/fixed-points/LFPs/List.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/fixed-points/LFPs/List.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/fixed-points/LFPs/List.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 31.1895424837, "max_line_length": 79, "alphanum_fraction": 0.3843252305, "num_tokens": 1529, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199714402812, "lm_q2_score": 0.7662936430859597, "lm_q1q2_score": 0.6418628594365307}} {"text": "{-# OPTIONS --without-K --exact-split --allow-unsolved-metas #-}\n\nmodule 12-univalence where\n\nimport 11-function-extensionality\nopen 11-function-extensionality public\n\n-- Section 10.1 Type extensionality\n\nequiv-eq : {i : Level} {A : UU i} {B : UU i} → Id A B → A ≃ B\nequiv-eq {A = A} refl = equiv-id A\n\nUNIVALENCE : {i : Level} (A B : UU i) → UU (lsuc i)\nUNIVALENCE A B = is-equiv (equiv-eq {A = A} {B = B})\n\nis-contr-total-equiv-UNIVALENCE : {i : Level} (A : UU i) →\n ((B : UU i) → UNIVALENCE A B) → is-contr (Σ (UU i) (λ X → A ≃ X))\nis-contr-total-equiv-UNIVALENCE A UA =\n fundamental-theorem-id' A\n ( equiv-id A)\n ( λ B → equiv-eq {B = B})\n ( UA)\n\nUNIVALENCE-is-contr-total-equiv : {i : Level} (A : UU i) →\n is-contr (Σ (UU i) (λ X → A ≃ X)) → (B : UU i) → UNIVALENCE A B\nUNIVALENCE-is-contr-total-equiv A c =\n fundamental-theorem-id A\n ( equiv-id A)\n ( c)\n ( λ B → equiv-eq {B = B})\n\nev-id : {i j : Level} {A : UU i} (P : (B : UU i) → (A ≃ B) → UU j) →\n ((B : UU i) (e : A ≃ B) → P B e) → P A (equiv-id A)\nev-id {A = A} P f = f A (equiv-id A)\n\nIND-EQUIV : {i j : Level} {A : UU i} → ((B : UU i) (e : A ≃ B) → UU j) → UU _\nIND-EQUIV P = sec (ev-id P)\n\ntriangle-ev-id : {i j : Level} {A : UU i}\n (P : (Σ (UU i) (λ X → A ≃ X)) → UU j) →\n (ev-pt (Σ (UU i) (λ X → A ≃ X)) (pair A (equiv-id A)) P)\n ~ ((ev-id (λ X e → P (pair X e))) ∘ (ev-pair {A = UU i} {B = λ X → A ≃ X} {C = P}))\ntriangle-ev-id P f = refl\n\nabstract\n IND-EQUIV-is-contr-total-equiv : {i j : Level} (A : UU i) →\n is-contr (Σ (UU i) (λ X → A ≃ X)) →\n (P : (Σ (UU i) (λ X → A ≃ X)) → UU j) → IND-EQUIV (λ B e → P (pair B e))\n IND-EQUIV-is-contr-total-equiv {i} {j} A c P =\n section-comp\n ( ev-pt (Σ (UU i) (λ X → A ≃ X)) (pair A (equiv-id A)) P)\n ( ev-id (λ X e → P (pair X e)))\n ( ev-pair {A = UU i} {B = λ X → A ≃ X} {C = P})\n ( triangle-ev-id P)\n ( sec-ev-pair (UU i) (λ X → A ≃ X) P)\n ( is-sing-is-contr (Σ (UU i) (λ X → A ≃ X))\n ( pair\n ( pair A (equiv-id A))\n ( λ t → \n ( inv (contraction c (pair A (equiv-id A)))) ∙\n ( contraction c t)))\n ( P)\n ( pair A (equiv-id A)))\n\nabstract\n is-contr-total-equiv-IND-EQUIV : {i : Level} (A : UU i) →\n ( {j : Level} (P : (Σ (UU i) (λ X → A ≃ X)) → UU j) →\n IND-EQUIV (λ B e → P (pair B e))) →\n is-contr (Σ (UU i) (λ X → A ≃ X))\n is-contr-total-equiv-IND-EQUIV {i} A ind =\n is-contr-is-sing\n ( Σ (UU i) (λ X → A ≃ X))\n ( pair A (equiv-id A))\n ( λ P → section-comp'\n ( ev-pt (Σ (UU i) (λ X → A ≃ X)) (pair A (equiv-id A)) P)\n ( ev-id (λ X e → P (pair X e)))\n ( ev-pair {A = UU i} {B = λ X → A ≃ X} {C = P})\n ( triangle-ev-id P)\n ( sec-ev-pair (UU i) (λ X → A ≃ X) P)\n ( ind P))\n\n-- The univalence axiom\n\npostulate univalence : {i : Level} (A B : UU i) → UNIVALENCE A B\n\neq-equiv : {i : Level} (A B : UU i) → (A ≃ B) → Id A B\neq-equiv A B = inv-is-equiv (univalence A B)\n\nabstract\n is-contr-total-equiv : {i : Level} (A : UU i) →\n is-contr (Σ (UU i) (λ X → A ≃ X))\n is-contr-total-equiv A = is-contr-total-equiv-UNIVALENCE A (univalence A)\n\ninv-inv-equiv :\n {i j : Level} {A : UU i} {B : UU j} (e : A ≃ B) →\n Id (inv-equiv (inv-equiv e)) e\ninv-inv-equiv (pair f (pair (pair g G) (pair h H))) = eq-htpy-equiv refl-htpy\n\nis-equiv-inv-equiv :\n {i j : Level} {A : UU i} {B : UU j} → is-equiv (inv-equiv {A = A} {B = B})\nis-equiv-inv-equiv =\n is-equiv-has-inverse\n ( inv-equiv)\n ( inv-inv-equiv)\n ( inv-inv-equiv)\n\nequiv-inv-equiv :\n {i j : Level} {A : UU i} {B : UU j} → (A ≃ B) ≃ (B ≃ A)\nequiv-inv-equiv = pair inv-equiv is-equiv-inv-equiv\n\nis-contr-total-equiv' : {i : Level} (A : UU i) →\n is-contr (Σ (UU i) (λ X → X ≃ A))\nis-contr-total-equiv' A =\n is-contr-equiv\n ( Σ (UU _) (λ X → A ≃ X))\n ( equiv-tot (λ X → equiv-inv-equiv))\n ( is-contr-total-equiv A)\n\nabstract\n Ind-equiv : {i j : Level} (A : UU i) (P : (B : UU i) (e : A ≃ B) → UU j) →\n sec (ev-id P)\n Ind-equiv A P =\n IND-EQUIV-is-contr-total-equiv A\n ( is-contr-total-equiv A)\n ( λ t → P (pr1 t) (pr2 t))\n\nind-equiv : {i j : Level} (A : UU i) (P : (B : UU i) (e : A ≃ B) → UU j) →\n P A (equiv-id A) → {B : UU i} (e : A ≃ B) → P B e\nind-equiv A P p {B} = pr1 (Ind-equiv A P) p B\n\n-- Subuniverses\n\nis-subuniverse :\n {l1 l2 : Level} (P : UU l1 → UU l2) → UU ((lsuc l1) ⊔ l2)\nis-subuniverse P = is-subtype P\n\nsubuniverse :\n (l1 l2 : Level) → UU ((lsuc l1) ⊔ (lsuc l2))\nsubuniverse l1 l2 = Σ (UU l1 → UU l2) is-subuniverse\n\n{- By univalence, subuniverses are closed under equivalences. -}\nin-subuniverse-equiv :\n {l1 l2 : Level} (P : UU l1 → UU l2) {X Y : UU l1} → X ≃ Y → P X → P Y\nin-subuniverse-equiv P e = tr P (eq-equiv _ _ e)\n\nin-subuniverse-equiv' :\n {l1 l2 : Level} (P : UU l1 → UU l2) {X Y : UU l1} → X ≃ Y → P Y → P X\nin-subuniverse-equiv' P e = tr P (inv (eq-equiv _ _ e))\n\ntotal-subuniverse :\n {l1 l2 : Level} (P : subuniverse l1 l2) → UU ((lsuc l1) ⊔ l2)\ntotal-subuniverse {l1} P = Σ (UU l1) (pr1 P)\n\n{- We also introduce the notion of 'global subuniverse'. The handling of \n universe levels is a bit more complicated here, since (l : Level) → A l are \n kinds but not types. -}\n \nis-global-subuniverse :\n (α : Level → Level) (P : (l : Level) → subuniverse l (α l)) →\n (l1 l2 : Level) → UU _\nis-global-subuniverse α P l1 l2 =\n (X : UU l1) (Y : UU l2) → X ≃ Y → (pr1 (P l1)) X → (pr1 (P l2)) Y\n\n{- Next we characterize the identity type of a subuniverse. -}\n\nEq-total-subuniverse :\n {l1 l2 : Level} (P : subuniverse l1 l2) →\n (s t : total-subuniverse P) → UU l1\nEq-total-subuniverse (pair P H) (pair X p) t = X ≃ (pr1 t)\n\nEq-total-subuniverse-eq :\n {l1 l2 : Level} (P : subuniverse l1 l2) →\n (s t : total-subuniverse P) → Id s t → Eq-total-subuniverse P s t\nEq-total-subuniverse-eq (pair P H) (pair X p) .(pair X p) refl = equiv-id X\n\nabstract\n is-contr-total-Eq-total-subuniverse :\n {l1 l2 : Level} (P : subuniverse l1 l2)\n (s : total-subuniverse P) →\n is-contr (Σ (total-subuniverse P) (λ t → Eq-total-subuniverse P s t))\n is-contr-total-Eq-total-subuniverse (pair P H) (pair X p) =\n is-contr-total-Eq-substructure (is-contr-total-equiv X) H X (equiv-id X) p\n\nabstract\n is-equiv-Eq-total-subuniverse-eq :\n {l1 l2 : Level} (P : subuniverse l1 l2)\n (s t : total-subuniverse P) → is-equiv (Eq-total-subuniverse-eq P s t)\n is-equiv-Eq-total-subuniverse-eq (pair P H) (pair X p) =\n fundamental-theorem-id\n ( pair X p)\n ( equiv-id X)\n ( is-contr-total-Eq-total-subuniverse (pair P H) (pair X p))\n ( Eq-total-subuniverse-eq (pair P H) (pair X p))\n\neq-Eq-total-subuniverse :\n {l1 l2 : Level} (P : subuniverse l1 l2) →\n {s t : total-subuniverse P} → Eq-total-subuniverse P s t → Id s t\neq-Eq-total-subuniverse P {s} {t} =\n inv-is-equiv (is-equiv-Eq-total-subuniverse-eq P s t)\n\n-- Section 12.2 Univalence implies function extensionality\n\nis-equiv-postcomp-univalence :\n {l1 l2 : Level} {X Y : UU l1} (A : UU l2) (e : X ≃ Y) →\n is-equiv (postcomp A (map-equiv e))\nis-equiv-postcomp-univalence {X = X} A =\n ind-equiv X\n ( λ Y e → is-equiv (postcomp A (map-equiv e)))\n ( is-equiv-id (A → X))\n\nweak-funext-univalence :\n {l : Level} {A : UU l} {B : A → UU l} → WEAK-FUNEXT A B\nweak-funext-univalence {A = A} {B} is-contr-B =\n is-contr-retract-of\n ( fib (postcomp A (pr1 {B = B})) id)\n ( pair\n ( λ f → pair (λ x → pair x (f x)) refl)\n ( pair\n ( λ h x → tr B (htpy-eq (pr2 h) x) (pr2 (pr1 h x)))\n ( refl-htpy)))\n ( is-contr-map-is-equiv\n ( is-equiv-postcomp-univalence A (equiv-pr1 is-contr-B))\n ( id))\n\nfunext-univalence :\n {l : Level} {A : UU l} {B : A → UU l} (f : (x : A) → B x) → FUNEXT f\nfunext-univalence {A = A} {B} f =\n FUNEXT-WEAK-FUNEXT (λ A B → weak-funext-univalence) A B f\n\n-- Exercises\n\n-- Exercise 10.1\n\ntr-equiv-eq-ap : {l1 l2 : Level} {A : UU l1} {B : A → UU l2} {x y : A}\n (p : Id x y) → (map-equiv (equiv-eq (ap B p))) ~ tr B p\ntr-equiv-eq-ap refl = refl-htpy\n\n-- Exercise 10.2\n\nsubuniverse-is-contr :\n {i : Level} → subuniverse i i\nsubuniverse-is-contr {i} = pair is-contr is-subtype-is-contr\n\nunit' :\n (i : Level) → UU i\nunit' i = pr1 (Raise i unit)\n\nabstract\n is-contr-unit' :\n (i : Level) → is-contr (unit' i)\n is-contr-unit' i =\n is-contr-equiv' unit (pr2 (Raise i unit)) is-contr-unit\n\nabstract\n center-UU-contr :\n (i : Level) → total-subuniverse (subuniverse-is-contr {i})\n center-UU-contr i =\n pair (unit' i) (is-contr-unit' i)\n \n contraction-UU-contr :\n {i : Level} (A : Σ (UU i) is-contr) →\n Id (center-UU-contr i) A\n contraction-UU-contr (pair A is-contr-A) =\n eq-Eq-total-subuniverse subuniverse-is-contr\n ( equiv-is-contr (is-contr-unit' _) is-contr-A)\n\nabstract\n is-contr-UU-contr : (i : Level) → is-contr (Σ (UU i) is-contr)\n is-contr-UU-contr i =\n pair (center-UU-contr i) (contraction-UU-contr)\n\nis-trunc-UU-trunc :\n (k : 𝕋) (i : Level) → is-trunc (succ-𝕋 k) (Σ (UU i) (is-trunc k))\nis-trunc-UU-trunc k i X Y =\n is-trunc-is-equiv k\n ( Id (pr1 X) (pr1 Y))\n ( ap pr1)\n ( is-emb-pr1-is-subtype\n ( is-prop-is-trunc k) X Y)\n ( is-trunc-is-equiv k\n ( (pr1 X) ≃ (pr1 Y))\n ( equiv-eq)\n ( univalence (pr1 X) (pr1 Y))\n ( is-trunc-equiv-is-trunc k (pr2 X) (pr2 Y)))\n\nev-true-false :\n {l : Level} (A : UU l) → (f : bool → A) → A × A\nev-true-false A f = pair (f true) (f false)\n\nmap-universal-property-bool :\n {l : Level} {A : UU l} →\n A × A → (bool → A)\nmap-universal-property-bool (pair x y) true = x\nmap-universal-property-bool (pair x y) false = y\n\nissec-map-universal-property-bool :\n {l : Level} {A : UU l} →\n ((ev-true-false A) ∘ map-universal-property-bool) ~ id\nissec-map-universal-property-bool (pair x y) =\n eq-pair-triv (pair refl refl)\n\nisretr-map-universal-property-bool' :\n {l : Level} {A : UU l} (f : bool → A) →\n (map-universal-property-bool (ev-true-false A f)) ~ f\nisretr-map-universal-property-bool' f true = refl\nisretr-map-universal-property-bool' f false = refl\n\nisretr-map-universal-property-bool :\n {l : Level} {A : UU l} →\n (map-universal-property-bool ∘ (ev-true-false A)) ~ id\nisretr-map-universal-property-bool f =\n eq-htpy (isretr-map-universal-property-bool' f)\n\nuniversal-property-bool :\n {l : Level} (A : UU l) →\n is-equiv (λ (f : bool → A) → pair (f true) (f false))\nuniversal-property-bool A =\n is-equiv-has-inverse\n map-universal-property-bool\n issec-map-universal-property-bool\n isretr-map-universal-property-bool\n\nev-true :\n {l : Level} {A : UU l} → (bool → A) → A\nev-true f = f true\n\ntriangle-ev-true :\n {l : Level} (A : UU l) →\n (ev-true) ~ (pr1 ∘ (ev-true-false A))\ntriangle-ev-true A = refl-htpy\n\naut-bool-bool :\n bool → (bool ≃ bool)\naut-bool-bool true = equiv-id bool\naut-bool-bool false = equiv-neg-𝟚\n\nbool-aut-bool :\n (bool ≃ bool) → bool\nbool-aut-bool e = map-equiv e true\n\ndecide-true-false :\n (b : bool) → coprod (Id b true) (Id b false)\ndecide-true-false true = inl refl\ndecide-true-false false = inr refl\n\neq-false :\n (b : bool) → (¬ (Id b true)) → (Id b false)\neq-false true p = ind-empty (p refl)\neq-false false p = refl\n\neq-true :\n (b : bool) → (¬ (Id b false)) → Id b true\neq-true true p = refl\neq-true false p = ind-empty (p refl)\n\nEq-𝟚-eq : (x y : bool) → Id x y → Eq-𝟚 x y\nEq-𝟚-eq x .x refl = reflexive-Eq-𝟚 x\n\neq-false-equiv' :\n (e : bool ≃ bool) → Id (map-equiv e true) true →\n is-decidable (Id (map-equiv e false) false) → Id (map-equiv e false) false\neq-false-equiv' e p (inl q) = q\neq-false-equiv' e p (inr x) =\n ind-empty\n ( Eq-𝟚-eq true false\n ( ap pr1\n ( is-prop-is-contr'\n ( is-contr-map-is-equiv (is-equiv-map-equiv e) true)\n ( pair true p)\n ( pair false (eq-true (map-equiv e false) x)))))\n\n{-\neq-false-equiv :\n (e : bool ≃ bool) → Id (map-equiv e true) true → Id (map-equiv e false) false\neq-false-equiv e p =\n eq-false-equiv' e p (has-decidable-equality-𝟚 (map-equiv e false) false)\n-}\n\n{-\neq-true-equiv :\n (e : bool ≃ bool) →\n ¬ (Id (map-equiv e true) true) → Id (map-equiv e false) true\neq-true-equiv e f = {!!}\n\nissec-bool-aut-bool' :\n ( e : bool ≃ bool) (d : is-decidable (Id (map-equiv e true) true)) →\n htpy-equiv (aut-bool-bool (bool-aut-bool e)) e\nissec-bool-aut-bool' e (inl p) true =\n ( htpy-equiv-eq (ap aut-bool-bool p) true) ∙ (inv p)\nissec-bool-aut-bool' e (inl p) false =\n ( htpy-equiv-eq (ap aut-bool-bool p) false) ∙\n ( inv (eq-false-equiv e p))\nissec-bool-aut-bool' e (inr f) true =\n ( htpy-equiv-eq\n ( ap aut-bool-bool (eq-false (map-equiv e true) f)) true) ∙\n ( inv (eq-false (map-equiv e true) f))\nissec-bool-aut-bool' e (inr f) false =\n ( htpy-equiv-eq (ap aut-bool-bool {!eq-true-equiv e ?!}) {!!}) ∙\n ( inv {!!})\n\nissec-bool-aut-bool :\n (aut-bool-bool ∘ bool-aut-bool) ~ id\nissec-bool-aut-bool e =\n eq-htpy-equiv\n ( issec-bool-aut-bool' e\n ( has-decidable-equality-𝟚 (map-equiv e true) true))\n-}\n", "meta": {"hexsha": "7153bfad9c70b0a1f5a6d45a77f57e52e5289b36", "size": 12920, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/12-univalence.agda", "max_stars_repo_name": "hemangandhi/HoTT-Intro", "max_stars_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Agda/12-univalence.agda", "max_issues_repo_name": "hemangandhi/HoTT-Intro", "max_issues_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Agda/12-univalence.agda", "max_forks_repo_name": "hemangandhi/HoTT-Intro", "max_forks_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.6666666667, "max_line_length": 85, "alphanum_fraction": 0.5734520124, "num_tokens": 5120, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199592797929, "lm_q2_score": 0.7662936430859597, "lm_q1q2_score": 0.6418628501180258}} {"text": "module Structure.Relator.Function.Multi where\n\nopen import Data.Tuple.RaiseTypeᵣ\nimport Data.Tuple.RaiseTypeᵣ.Functions as RaiseType\nopen import Function.Multi\nimport Function.Multi.Functions as Multi\nimport Lvl\nimport Lvl.MultiFunctions as Lvl\nopen import Logic\nopen import Logic.Predicate\nopen import Logic.Predicate.Multi\nopen import Functional\nopen import Numeral.Natural\nimport Structure.Function.Multi as Multi\nopen import Structure.Setoid\nopen import Type\n\nprivate variable ℓ ℓₑ : Lvl.Level\n\nmodule _ (n : ℕ) {ℓ𝓈}{ℓ₁ ℓ₂} {Xs : Types{n}(ℓ𝓈)}{Y : Type{ℓ₁}} where\n module Names where\n -- A relator is total when every LHS have at least one RHS in which the relation holds.\n Total : (Xs ⇉ (Y → Stmt{ℓ₂})) → Stmt\n Total(φ) = ∀₊(n)(Multi.compose(n) ∃ φ)\n\n module _ ⦃ equiv-Y : Equiv{ℓₑ}(Y) ⦄ where\n -- A relator is a function when every LHS have at least one RHS in which the relation holds.\n Function : ∀{ℓ𝓈ₑ} → (RaiseType.mapWithLvls(\\X ℓₑ → Equiv{ℓₑ}(X)) Xs ℓ𝓈ₑ) ⇉ᵢₙₛₜ ((Xs ⇉ (Y → Type{ℓ₂})) → Stmt)\n Function = Multi.expl-to-inst(n) (Multi.compose(n) (_$₂_) (Multi.inst-to-expl(n) (Multi.Names.RelationReplacement(f ↦ g ↦ ∀{y₁ y₂} → f(y₁) → g(y₂) → (y₁ ≡ y₂))(n))))\n\n record Total(φ : Xs ⇉ (Y → Stmt{ℓ₂})) : Stmt{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ (Lvl.⨆ ℓ𝓈)} where\n constructor intro\n field proof : Names.Total(φ)\n", "meta": {"hexsha": "9eb2096aa6b201dee66ec139b6b4fadc65f89d01", "size": 1363, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Relator/Function/Multi.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Relator/Function/Multi.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Relator/Function/Multi.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.0882352941, "max_line_length": 171, "alphanum_fraction": 0.6786500367, "num_tokens": 491, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8705972616934406, "lm_q2_score": 0.7371581626286834, "lm_q1q2_score": 0.6417678778194997}} {"text": "module Logic.WeaklyClassical where\n\nimport Lvl\nopen import Functional\nopen import Logic.Names\nopen import Logic.Predicate\nopen import Logic.Propositional\nopen import Logic.Propositional.Theorems\nopen import Type\n\nprivate variable ℓ : Lvl.Level\nprivate variable T X Y : Type{ℓ}\nprivate variable P : T → Type{ℓ}\n\n-- TODO: What should (¬¬ P → P) for a P be called? DoubleNegation? Stable proposition?\n\n[⊤]-doubleNegation : DoubleNegationOn(⊤)\n[⊤]-doubleNegation = const [⊤]-intro\n\n[⊥]-doubleNegation : DoubleNegationOn(⊥)\n[⊥]-doubleNegation = apply id\n\n[¬]-doubleNegation : DoubleNegationOn(¬ X)\n[¬]-doubleNegation = _∘ apply\n\n[∧]-doubleNegation : DoubleNegationOn(X) → DoubleNegationOn(Y) → DoubleNegationOn(X ∧ Y)\n[∧]-doubleNegation nnxx nnyy nnxy = [∧]-intro (nnxx(nx ↦ nnxy(nx ∘ [∧]-elimₗ))) (nnyy(ny ↦ nnxy(ny ∘ [∧]-elimᵣ)))\n\n[→]-doubleNegation : DoubleNegationOn(Y) → DoubleNegationOn(X → Y)\n[→]-doubleNegation nnyy nnxy x = nnyy(ny ↦ nnxy(xy ↦ (ny ∘ xy) x))\n\n[∀]-doubleNegation-distribute : (∀{x} → DoubleNegationOn(P(x))) → DoubleNegationOn(∀{x} → P(x))\n[∀]-doubleNegation-distribute annp nnap = annp(npx ↦ nnap(npx $_))\n\ndoubleNegation-to-callCC : DoubleNegationOn(X) → DoubleNegationOn(Y) → (((X → Y) → X) → X)\ndoubleNegation-to-callCC dx dy xyx = dx(nx ↦ nx(xyx(dy ∘ const ∘ nx)))\n", "meta": {"hexsha": "d6a608c01bdc4ca7b8a571d7c9926ca73fb397c4", "size": 1294, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Logic/WeaklyClassical.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Logic/WeaklyClassical.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Logic/WeaklyClassical.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.972972973, "max_line_length": 113, "alphanum_fraction": 0.6978361669, "num_tokens": 466, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357632379241, "lm_q2_score": 0.7401743563075446, "lm_q1q2_score": 0.6417576379502511}} {"text": "module Function.Iteration.Order where\n\nopen import Data\nopen import Data.Boolean.Stmt\nopen import Functional renaming (id to id-fn)\nopen import Function.Iteration hiding (_^_)\nopen import Function.Iteration.Proofs\nopen import Logic\nopen import Logic.IntroInstances\nopen import Logic.Propositional\nopen import Logic.Propositional.Theorems\nopen import Logic.Predicate\nimport Lvl\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper hiding (_^_)\nopen import Numeral.Natural.Oper.Comparisons\nopen import Numeral.Natural.Oper.DivMod.Proofs\nopen import Numeral.Natural.Oper.FlooredDivision\nopen import Numeral.Natural.Oper.Modulo\nopen import Numeral.Natural.Oper.Modulo.Proofs\nopen import Numeral.Natural.Relation.Divisibility\nopen import Numeral.Natural.Relation.Divisibility.Proofs\nopen import Numeral.Natural.Relation.Order.Decidable\nopen import Numeral.Natural.Relation.Order.Proofs\nopen import Numeral.Natural.Relation.Order\nopen import Relator.Equals using () renaming (_≡_ to _≡ₑ_ ; _≢_ to _≢ₑ_ ; [≡]-intro to [≡ₑ]-intro)\nopen import Structure.Setoid\nopen import Structure.Function.Domain\nopen import Structure.Function\nopen import Structure.Operator.Properties\nopen import Structure.Operator.Proofs\nopen import Structure.Operator\nopen import Structure.Relator.Properties\nopen import Structure.Relator.Ordering\nopen import Structure.Relator.Ordering.Lattice\nopen import Syntax.Transitivity\nopen import Type\nopen import Type.Properties.Decidable.Proofs\nopen import Type.Properties.Empty\nopen import Type.Size.Finite\n\nprivate variable ℓ ℓₑ : Lvl.Level\nprivate variable T : Type{ℓ}\n\nmodule _ ⦃ equiv-T : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) ⦃ op : BinaryOperator(_▫_) ⦄ {id} ⦃ ident : Identity(_▫_)(id) ⦄ ⦃ assoc : Associativity(_▫_) ⦄ where\n -- Operator alias for iterated application of an operator with an element.\n _^_ : T → ℕ → T\n x ^ n = Function.Iteration.repeatₗ(n)(_▫_)(id)(x)\n\n -- `FiniteOrder(x)(n)` means that the element `x` is of order `n`.\n -- It is finite in the sense that it is a number and not infinite.\n -- An element's order is the smallest positive integer power of x such that the result is the identity element.\n data FiniteOrder (x : T) : ℕ → Stmt{ℓₑ} where\n intro : ∀{n} → LE.Minimum(_≤_)(n ↦ x ^ 𝐒(n) ≡ id)(n) → FiniteOrder(x)(𝐒(n))\n\n -- `Ord(x)` means that the element `x` has a finite order.\n Ord : T → Stmt\n Ord(x) = ∃(FiniteOrder(x))\n\n -- `ord(x)` is the order of x (when it is finite).\n ord : (x : T) → ⦃ _ : Ord(x) ⦄ → ℕ\n ord(_) ⦃ [∃]-intro n ⦄ = n\n\n module _ {x : T} where\n -- An order is never 0 by definition.\n finite-order-0 : ¬ FiniteOrder(x)(𝟎)\n finite-order-0 ()\n\n -- An element power its order is the identity element.\n [^]-by-ord : ⦃ p : Ord(x) ⦄ → (x ^ ord(x) ⦃ p ⦄ ≡ id)\n [^]-by-ord ⦃ [∃]-intro (𝐒(_)) ⦃ intro p ⦄ ⦄ = LE.Minimum.membership{_≤_ = _≤_}(p)\n\n -- When an element power something is the identity element, then the power is either zero or greater/equal its order.\n ord-is-minimum : ⦃ p : Ord(x) ⦄ → ∀{n} → (x ^ n ≡ id) → (n ≡ₑ 𝟎) ∨ (ord(x) ⦃ p ⦄ ≤ n)\n ord-is-minimum ⦃ [∃]-intro (_) ⦃ intro p ⦄ ⦄ {𝟎} x0id = [∨]-introₗ [≡ₑ]-intro\n ord-is-minimum ⦃ [∃]-intro .(𝐒 po) ⦃ intro {po} p ⦄ ⦄ {𝐒 n} xsnid = [∨]-introᵣ ([≤]-with-[𝐒] ⦃ LE.Minimum.proof{_≤_ = _≤_}(p) ⦃ xsnid ⦄ ⦄)\n\n -- When an element power something less than its order and it is the identity element, then the power is 0.\n ord-is-minimum-but-0 : ⦃ p : Ord(x) ⦄ → ∀{n} → (x ^ n ≡ id) → (n < ord(x) ⦃ p ⦄) → (n ≡ₑ 𝟎)\n ord-is-minimum-but-0 ⦃ p ⦄ {𝟎} _ _ = [≡ₑ]-intro\n ord-is-minimum-but-0 ⦃ p ⦄ {𝐒(n)} xnid nord with ord-is-minimum ⦃ p ⦄ {𝐒(n)} xnid\n ... | [∨]-introᵣ ordsn = [⊥]-elim([<]-to-[≱] nord (ordsn))\n\n -- An order is never 0.\n ord-non-zero : ⦃ p : Ord(x) ⦄ → (ord(x) ⦃ p ⦄ ≢ₑ 𝟎)\n ord-non-zero ⦃ [∃]-intro 𝟎 ⦃ ⦄ ⦄ [≡ₑ]-intro\n\n -- Iteration (_^_) distributes to the right.\n -- Can also be seen as iteration preserving from addition to the operation.\n [^]-by-add : ∀{a b} → ((x ^ a) ▫ (x ^ b) ≡ x ^ (a + b))\n [^]-by-add {a}{b} = repeatₗ-by-sum {X = T}{_▫_}{x}{id}{a}{b}\n\n -- Nested iterations can join to be a product.\n [^]-by-product : ∀{a b} → ((((x ^ a)) ^ b) ≡ x ^ (a ⋅ b))\n [^]-by-product {a}{b} = repeatₗ-by-product {X = T}{_▫_}{x}{id}{a}{b}\n\n -- When powering a difference yields the identity element, the powered elements are the same.\n [^]-by-distanceₗ : ∀{a b} → (x ^ a ≡ x ^ b) ← (x ^ (a 𝄩 b) ≡ id)\n [^]-by-distanceₗ {a}{b} = repeatₗ-by-distanceₗ {X = T}{_▫_}{x}{id}{a}{b}\n\n -- Theorems where `n` is a power which yields an identity element.\n module _ {n} (n-id : (x ^ n ≡ id)) where\n -- Adding something to `n` is only leaving the something behind.\n [^]-by-id-add : ∀{a} → (x ^ (n + a) ≡ x ^ a)\n [^]-by-id-add {a} =\n x ^ (n + a) 🝖-[ symmetry(_≡_) ([^]-by-add {n}{a}) ]\n (x ^ n) ▫ (x ^ a) 🝖-[ congruence₂ₗ(_▫_)(_) n-id ]\n id ▫ (x ^ a) 🝖-[ identityₗ(_▫_)(id) ]\n x ^ a 🝖-end\n\n -- Multiplying something by `n` is still the identity element.\n [^]-by-id-multiple : ∀{a} → (x ^ (n ⋅ a) ≡ id)\n [^]-by-id-multiple {𝟎} = repeatₗ-by-0 {X = T}{_▫_}{x}{id}\n [^]-by-id-multiple {𝐒(a)} =\n x ^ (n + (n ⋅ a)) 🝖-[ symmetry(_≡_) ([^]-by-add {n}{n ⋅ a}) ]\n (x ^ n) ▫ (x ^ (n ⋅ a)) 🝖-[ congruence₂(_▫_) n-id ([^]-by-id-multiple {a}) ]\n id ▫ id 🝖-[ identityₗ(_▫_)(id) ]\n id 🝖-end\n\n -- A power yields an identity element only when it is a multiple of the order of the element.\n [^]-id-when-div : ⦃ p : Ord(x) ⦄ → ∀{n} → (x ^ n ≡ id) ↔ (ord(x) ⦃ p ⦄ ∣ n)\n [^]-id-when-div ⦃ p ⦄ {n} = [↔]-intro (l{n}) (r{n}) where\n l : ∀{n} → (x ^ n ≡ id) ← (ord(x) ⦃ p ⦄ ∣ n)\n l {.0} Div𝟎 = repeatₗ-by-0 {X = T}{_▫_}{x}{id}\n l {.(ord(x) ⦃ p ⦄ + n)} (Div𝐒 {_}{n} div) =\n x ^ (ord x ⦃ p ⦄ + n) 🝖-[ symmetry(_≡_) ([^]-by-add {ord(x) ⦃ p ⦄}{n}) ]\n (x ^ ord x ⦃ p ⦄) ▫ (x ^ n) 🝖-[ congruence₂(_▫_) ([^]-by-ord ⦃ p ⦄) (l{n} div) ]\n id ▫ id 🝖-[ identityₗ(_▫_)(id) ]\n id 🝖-end\n\n r : ∀{n} → (x ^ n ≡ id) → (ord(x) ⦃ p ⦄ ∣ n)\n r {𝟎} _ = Div𝟎\n r {𝐒(n)} xnid = [↔]-to-[→] mod-divisibility mod-is-0 where\n open import Relator.Equals.Proofs.Equiv using ([≡]-to-equivalence)\n\n instance\n ord-non-zero-comp : IsTrue(ord(x) ⦃ p ⦄ ≢? 𝟎)\n ord-non-zero-comp = [↔]-to-[→] decider-true (ord-non-zero ⦃ p ⦄)\n\n instance\n ord-positive : IsTrue(positive?(ord(x) ⦃ p ⦄))\n ord-positive with ord(x) ⦃ p ⦄ | [∃]-proof p\n ... | 𝟎 | pp = finite-order-0 pp\n ... | 𝐒 _ | _ = <>\n\n instance\n ord-n-ineq : ord(x) ⦃ p ⦄ ≤ 𝐒(n)\n ord-n-ineq with ord-is-minimum ⦃ p ⦄ {𝐒(n)} xnid\n ord-n-ineq | [∨]-introₗ ()\n ord-n-ineq | [∨]-introᵣ proof = proof\n\n mod-is-id : x ^ (𝐒(n) mod ord(x) ⦃ p ⦄) ≡ id\n mod-is-id =\n x ^ (𝐒(n) mod ord(x) ⦃ p ⦄) 🝖-[ symmetry(_≡_) (identityₗ(_▫_)(id)) ]\n id ▫ (x ^ (𝐒(n) mod ord(x) ⦃ p ⦄)) 🝖-[ congruence₂ₗ(_▫_)(_) (symmetry(_≡_) ([^]-by-id-multiple {ord(x) ⦃ p ⦄} ([^]-by-ord ⦃ p ⦄) {𝐒(n) ⌊/⌋ ord(x) ⦃ p ⦄})) ]\n (x ^ ((ord(x) ⦃ p ⦄) ⋅ (𝐒(n) ⌊/⌋ ord(x) ⦃ p ⦄))) ▫ (x ^ (𝐒(n) mod ord(x) ⦃ p ⦄)) 🝖-[ [^]-by-add {(ord(x) ⦃ p ⦄) ⋅ (𝐒(n) ⌊/⌋ ord(x) ⦃ p ⦄)} {𝐒(n) mod ord(x) ⦃ p ⦄} ]\n x ^ (((ord(x) ⦃ p ⦄) ⋅ (𝐒(n) ⌊/⌋ ord(x) ⦃ p ⦄)) + (𝐒(n) mod ord(x) ⦃ p ⦄)) 🝖-[ congruence₁(x ^_) ⦃ Relator.Equals.Proofs.Equiv.[≡]-to-function ⦄ ([≡]-to-equivalence([⌊/⌋][mod]-is-division-with-remainder-pred-commuted{𝐒(n)}{ord(x) ⦃ p ⦄})) ]\n x ^ 𝐒(n) 🝖-[ xnid ]\n id 🝖-end\n\n mod-is-0 : 𝐒(n) mod ord(x) ⦃ p ⦄ ≡ 𝟎\n mod-is-0 = ord-is-minimum-but-0 ⦃ p ⦄ mod-is-id mod-maxᵣ\n\n module _ {inv} ⦃ _ : InverseFunctionᵣ(_▫_)(inv) ⦄ where\n [^]-by-distanceᵣ : ∀{a b} → (x ^ a ≡ x ^ b) → (x ^ (a 𝄩 b) ≡ id)\n [^]-by-distanceᵣ {a}{b} = repeatₗ-by-distanceᵣ{X = T}{_▫_}{x}{id} ⦃ cancᵣ = One.cancellationᵣ-by-associativity-inverse ⦄ {a}{b}\n\n [^]-equal-[𝄩] : ⦃ p : Ord(x) ⦄ → ∀{a b} → (x ^ a ≡ x ^ b) ↔ (ord(x) ⦃ p ⦄ ∣ (a 𝄩 b))\n [^]-equal-[𝄩] ⦃ p ⦄ {a}{b} = [↔]-transitivity ([↔]-intro ([^]-by-distanceₗ{a}{b}) ([^]-by-distanceᵣ{a}{b})) ([^]-id-when-div ⦃ p ⦄)\n\n postulate [^]-cancellationₗ : ⦃ p : Ord(x) ⦄ → ∀{a b} → ⦃ a < ord(x) ⦃ p ⦄ ⦄ → ⦃ b < ord(x) ⦃ p ⦄ ⦄ → (x ^ a ≡ x ^ b) → (a ≡ₑ b)\n\n -- ord(x ^ n) ≡ ord(x) / gcd(n)(ord(x))\n -- (x ▫ y ≡ y ▫ x) → ord(x ▫ y) ∣ lcm(ord(x))(ord(y))\n -- (∀{x} → (ord(x) ≡ 2)) → Commutativity(_▫_)\n\n -- One element in the group can \"generate\" any element element in the group by repeated application of the operator.\n Generator : T → Stmt\n Generator(x) = Surjective(x ^_)\n\n -- A group is cyclic when there is an element that can generate it.\n Cyclic : Stmt\n Cyclic = ∃(Generator)\n\n {- TODO: Because the thing exists, there is finitely many. Search for the first one\n finite-order-from-dec-existence : ⦃ Decidable(_≡_) ⦄ → ∀{a} → ∃(n ↦ (a ^ 𝐒(n) ≡ id)) → Ord(a)\n finite-order-from-dec-existence {n} asnid = {!!}\n -- intro (Weak.Properties.intro ⦃ asnid ⦄ {!!})\n\n -- TODO: Assume decidable equality and use finite-order-from-dec-existence above. Existence should follow from finiteness\n finite-have-order : ⦃ Finite(T) ⦄ → ∀{a} → Ord(a)\n ∃.witness (finite-have-order ⦃ [∃]-intro size ⦃ fin-bij ⦄ ⦄) = size\n ∃.proof (finite-have-order ⦃ [∃]-intro 𝟎 ⦃ [∃]-intro fin-bij ⦄ ⦄ {a = a}) with fin-bij a\n ... | ()\n ∃.proof (finite-have-order ⦃ [∃]-intro (𝐒(size)) ⦃ fin-bij ⦄ ⦄) = intro {!!}\n -}\n\n\n postulate cyclic-commutative : ⦃ Cyclic ⦄ → Commutativity(_▫_)\n -- generator-order-size : ⦃ Finite(T) ⦄ → ∀{a} → ⦃ p : Ord(a) ⦄ → Generator(a) ↔ ((# T) ≡ₑ ord(a) ⦃ p ⦄)\n -- cyclic-order-size : ⦃ Finite(T) ⦄ → ⦃ Cyclic ⦄ ↔ ∃(a ↦ (# T) ≡ₑ ord(a))\n\n -- generator-of-power : Generator(a ^ k) ↔ Generator(a ^ gcd(ord(a))(k))\n -- order-of-power : ord(a ^ k) ∣ ord(a) / gcd(ord(a),k)\n\n{-\n module _ {id} ⦃ ident : Identity(_▫_)(id) ⦄ where\n open import Data.Boolean\n open import Data.Boolean.Stmt\n import Function.Iteration\n open import Logic.Computability\n open import Logic.Computability.Binary renaming (ComputablyDecidable to ComputablyDecidable2)\n open import Logic\n\n open import Numeral.Natural.Relation.Computability\n \n \n\n-}\n {-\n boundedMinOr : ℕ → (ℕ → Bool) → ℕ → ℕ\n boundedMinOr 𝟎 p default = default\n boundedMinOr (𝐒(bound)) p default = if p(bound) then bound else (boundedMinOr bound p default)\n\n boundedMinOr-proof : ∀{p : ℕ → Bool}{bound default : ℕ} → IsTrue(p(default)) → IsTrue(p(boundedMinOr bound p default))\n\n min-by-bruteforce : ∀{ℓ}{P : ℕ → Stmt{ℓ}} → ⦃ comp : ComputablyDecidable(P) ⦄ → ⦃ e : ∃(P) ⦄ → ∃(Weak.Properties.MinimumOf(_≤_)(P))\n ∃.witness (min-by-bruteforce {P = P} ⦃ comp ⦄ ⦃ e ⦄) = boundedMinOr([∃]-witness(e)) (ComputablyDecidable.decide(comp)) ([∃]-witness(e))\n Weak.Properties.MinimumOf.proof (∃.proof min-by-bruteforce) {x} ⦃ x₁ ⦄ = {!!}\n\n ord : (x : T) → ⦃ e : FiniteOrder(x) ⦄ → ⦃ comp : ComputablyDecidable2{X = T}(_≡_) ⦄ → ℕ\n ord(x) ⦃ e ⦄ ⦃ comp ⦄ = Weak.minOf(_≤_)(n ↦ x ^ 𝐒(n) ≡ id) ⦃ min-by-bruteforce ⦃ {!!} ⦄ ⦃ e ⦄ ⦄\n -}\n", "meta": {"hexsha": "a84552bbdcac9ae526ee367d6e371e9d3725dc56", "size": 11546, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Function/Iteration/Order.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Function/Iteration/Order.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Function/Iteration/Order.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.3418803419, "max_line_length": 256, "alphanum_fraction": 0.5416594492, "num_tokens": 4659, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357494949104, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.6417576377168065}} {"text": "module Data.Union where\n\nopen import Data.List using (List; _∷_; [_]; [])\nopen import Data.List.Relation.Unary.Any using (here; there; _─_)\nopen import Data.List.Membership.Propositional using (_∈_)\n\nopen import Data.Maybe using (Maybe; just; nothing; _>>=_)\n\nopen import Level using (Level; _⊔_)\n\nopen import Function using (_∘_)\n\n-- ----------------------------------------------------------------------\n-- Definition\n-- \n-- A union of the family B defined by the list of tags ts \n-- of type A\n\ndata Union {a b} (A : Set a) (B : A → Set b) : List A → Set (a ⊔ b) where\n here : ∀ {t ts} → B t → Union A B (t ∷ ts) \n there : ∀ {t ts} → Union A B ts → Union A B (t ∷ ts)\n\n-- ----------------------------------------------------------------------\n-- Injection and projections to (and from) unions\n\nprivate\n variable\n a b : Level\n A : Set a\n B : A → Set b\n t : A\n ts ts′ : List A\n\ninj : t ∈ ts → B t → Union A B ts\ninj (here t≡t′) x rewrite t≡t′ = here x\ninj (there t∈ts) x = there (inj t∈ts x)\n\n`_ : ⦃ t ∈ ts ⦄ → B t → Union A B ts\n`_ ⦃ t∈ts ⦄ x = inj t∈ts x\n\nproj : t ∈ ts → Union A B ts → Maybe (B t)\nproj (here t≡t′) (here x) rewrite t≡t′ = just x\nproj (there t∈ts) (here x) = nothing\nproj (here t≡t′) (there x) = nothing\nproj (there t∈ts) (there x) = proj t∈ts x\n\n`proj : ⦃ t ∈ ts ⦄ → Union A B ts → Maybe (B t)\n`proj ⦃ t∈ts ⦄ x = proj t∈ts x\n\nproj₀ : Union A B [ t ] → B t\nproj₀ (here x) = x\n\nremove : Union A B ts → (i : t ∈ ts) → Maybe (Union A B (ts ─ i))\nremove (here x) (here _) = nothing\nremove (here x) (there _) = just (here x)\nremove (there x) (here _) = just x\nremove (there x) (there t∈ts) = remove x t∈ts >>= just ∘ there\n\n\n\n", "meta": {"hexsha": "8ed7c869907f3add746b85fc9290a2a511292a1c", "size": 1658, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Union.agda", "max_stars_repo_name": "johnyob/agda-union", "max_stars_repo_head_hexsha": "921a0dc44a69a74391031ca61568c624ab7f9c94", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Data/Union.agda", "max_issues_repo_name": "johnyob/agda-union", "max_issues_repo_head_hexsha": "921a0dc44a69a74391031ca61568c624ab7f9c94", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/Union.agda", "max_forks_repo_name": "johnyob/agda-union", "max_forks_repo_head_hexsha": "921a0dc44a69a74391031ca61568c624ab7f9c94", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.1803278689, "max_line_length": 73, "alphanum_fraction": 0.5379975875, "num_tokens": 591, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357460591569, "lm_q2_score": 0.7401743563075446, "lm_q1q2_score": 0.6417576252349682}} {"text": "module container.m.extensionality where\n\nopen import sum\nopen import equality\nopen import container.core\nopen import container.fixpoint\nopen import container.equality\nopen import container.m.core\n\nmodule Extensionality {li la lb}(c : Container li la lb) where\n private\n module C where\n open Definition c public\n\n fp : Fixpoint c _\n fp = fix M fixpoint\n\n open Fixpoint fp public\n using (head; tail)\n\n module S where\n open Equality c C.fp\n using (equality)\n open Equality c C.fp public\n using (substX)\n open Definition equality public\n\n fp : Fixpoint equality _\n fp = fix M fixpoint\n\n open Fixpoint fp public\n using (head; tail)\n\n open C\n\n -- bisimilarity relation\n _≡M_ : ∀ {i}(u v : M i) → Set _\n u ≡M v = S.M (_ , u , v)\n\n reflM : ∀ {i}{u : M i} → u ≡M u\n reflM = S.inf refl (λ b → ♯ reflM)\n\n private\n -- total space of bisimilarity\n E : ∀ i → Set _\n E i = Σ (M i × M i) (uncurry _≡M_)\n\n f : E →ⁱ F E\n f i ((xs , ys) , bisim)\n = head xs\n , (λ b → (( tail xs b\n , S.substX (S.head bisim) b\n (tail ys (subst B (S.head bisim) b)))\n , S.tail bisim b))\n\n π₁ : E →ⁱ M\n π₁ i ((xs , _), _) = xs\n\n π₁-mor : ∀ {i} (e : E i) → out i (π₁ i e) ≡ imap π₁ i (f i e)\n π₁-mor ((xs , ys) , p) = refl\n\n π₂ : E →ⁱ M\n π₂ _ ((_ , ys), _) = ys\n\n π₂-mor : ∀ {i} (e : E i) → out i (π₂ i e) ≡ imap π₂ i (f i e)\n π₂-mor {i} ((xs , ys) , bisim) = lem (S.head bisim) (tail ys)\n where\n lem : {a a' : A i}(p : a ≡ a')\n → (f : (b' : B a') → M (r b'))\n → _≡_ {A = F M i}\n (a' , f)\n (a , λ b → S.substX p b (f (subst B p b)))\n lem refl f = refl\n\n equal-π : ∀ {i}(e : E i) → π₁ i e ≡ π₂ i e\n equal-π e = unfold-η f π₁ π₁-mor e · sym (unfold-η f π₂ π₂-mor e)\n\n abstract\n mext₀ : ∀ {i} {xs ys : M i} → xs ≡M ys → xs ≡ ys\n mext₀ p = equal-π (_ , p)\n\n mext-inv : ∀ {i}{xs ys : M i} → xs ≡ ys → xs ≡M ys\n mext-inv refl = reflM\n\n mext : ∀ {i} {xs ys : M i} → xs ≡M ys → xs ≡ ys\n mext p = mext₀ p · sym (mext₀ reflM)\n\n mext-id : ∀ {i}{u : M i} → mext (reflM {u = u}) ≡ refl\n mext-id = left-inverse (mext₀ reflM)\n\n mext-retraction : ∀ {i}{xs ys : M i}(p : xs ≡ ys)\n → mext (mext-inv p) ≡ p\n mext-retraction refl = left-inverse (mext₀ reflM)\n", "meta": {"hexsha": "3117120599021e1e8a249c22b785f6f122f102b7", "size": 2409, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "container/m/extensionality.agda", "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_issues_repo_path": "src/container/m/extensionality.agda", "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_forks_repo_path": "container/m/extensionality.agda", "max_forks_repo_name": "HoTT/M-types", "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z", "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z", "avg_line_length": 25.6276595745, "max_line_length": 69, "alphanum_fraction": 0.499792445, "num_tokens": 892, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916099737806, "lm_q2_score": 0.7431680086124811, "lm_q1q2_score": 0.6416450234369385}} {"text": "module Numeral.Natural.Oper.Proofs.Multiplication where\n\nopen import Logic.Propositional\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.Oper.Proofs\nopen import Numeral.Natural.Oper.Proofs.Order\nopen import Numeral.Natural.Relation\nopen import Numeral.Natural.Relation.Order\nopen import Numeral.Natural.Relation.Order.Classical\nopen import Numeral.Natural.Relation.Order.Proofs\nopen import Relator.Equals\nopen import Relator.Equals.Proofs\nopen import Structure.Operator\nimport Structure.Operator.Names as Names\nopen import Structure.Operator.Properties\nopen import Structure.Relator.Properties\nopen import Syntax.Transitivity\n\ninstance\n [⋅][−₀]-distributivityᵣ : Distributivityᵣ(_⋅_)(_−₀_)\n Distributivityᵣ.proof([⋅][−₀]-distributivityᵣ) {x}{y}{z} = p{x}{y}{z} where\n p : ∀{x y z : ℕ} → ((x −₀ y) ⋅ z) ≡ (x ⋅ z) −₀ (y ⋅ z)\n p {x} {y} {𝟎} = [≡]-intro\n p {x} {y} {𝐒 z} with [≥]-or-[<] {x}{y}\n ... | [∨]-introₗ gt =\n (x −₀ y) ⋅ 𝐒(z) 🝖[ _≡_ ]-[]\n (x −₀ y) + ((x −₀ y) ⋅ z) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)(x −₀ y) (p {x}{y}{z}) ]\n (x −₀ y) + ((x ⋅ z) −₀ (y ⋅ z)) 🝖[ _≡_ ]-[ [+][−₀]-almost-associativity {x −₀ y} ([≤]-with-[⋅]ᵣ {c = z} gt) ]-sym\n ((x −₀ y) + (x ⋅ z)) −₀ (y ⋅ z) 🝖[ _≡_ ]-[ congruence₂ₗ(_−₀_)(y ⋅ z) (commutativity(_+_) {x −₀ y}{x ⋅ z}) ]\n ((x ⋅ z) + (x −₀ y)) −₀ (y ⋅ z) 🝖[ _≡_ ]-[ congruence₂ₗ(_−₀_)(y ⋅ z) ([+][−₀]-almost-associativity {x ⋅ z} gt) ]-sym\n (((x ⋅ z) + x) −₀ y) −₀ (y ⋅ z) 🝖[ _≡_ ]-[ congruence₂ₗ(_−₀_)(y ⋅ z) (congruence₂ₗ(_−₀_)(y) (commutativity(_+_) {x ⋅ z}{x})) ]\n ((x + (x ⋅ z)) −₀ y) −₀ (y ⋅ z) 🝖[ _≡_ ]-[ [−₀][−₀]-to-[−₀][+] {x + (x ⋅ z)}{y}{y ⋅ z} ]\n (x + (x ⋅ z)) −₀ (y + (y ⋅ z)) 🝖[ _≡_ ]-[]\n (x ⋅ 𝐒(z)) −₀ (y ⋅ 𝐒(z)) 🝖-end\n ... | [∨]-introᵣ lt =\n (x −₀ y) ⋅ 𝐒(z) 🝖[ _≡_ ]-[ congruence₂ₗ(_⋅_)(𝐒(z)) ([↔]-to-[→] [−₀]-when-0 (sub₂(_<_)(_≤_) lt)) ]\n 𝟎 ⋅ 𝐒(z) 🝖[ _≡_ ]-[ absorberₗ(_⋅_)(𝟎) {𝐒(z)} ]\n 𝟎 🝖[ _≡_ ]-[ [↔]-to-[→] [−₀]-when-0 ([≤]-with-[+] ⦃ sub₂(_<_)(_≤_) lt ⦄ ⦃ [≤]-with-[⋅]ᵣ {c = z} (sub₂(_<_)(_≤_) lt) ⦄) ]-sym\n (x + (x ⋅ z)) −₀ (y + (y ⋅ z)) 🝖-end\n\n-- TODO: This is a specialized distributivity-equivalence-by-commutativity\ninstance\n [⋅][−₀]-distributivityₗ : Distributivityₗ(_⋅_)(_−₀_)\n Distributivityₗ.proof([⋅][−₀]-distributivityₗ) {x}{y}{z} = p{x}{y}{z} where\n p : ∀{x y z : ℕ} → (x ⋅ (y −₀ z)) ≡ (x ⋅ y) −₀ (x ⋅ z)\n p{x}{y}{z} =\n x ⋅ (y −₀ z) 🝖[ _≡_ ]-[ commutativity(_⋅_) {x}{y −₀ z} ]\n (y −₀ z) ⋅ x 🝖[ _≡_ ]-[ distributivityᵣ(_⋅_)(_−₀_) {y}{z}{x} ]\n (y ⋅ x) −₀ (z ⋅ x) 🝖[ _≡_ ]-[ congruence₂(_−₀_) (commutativity(_⋅_) {y}{x}) (commutativity(_⋅_) {z}{x}) ]\n (x ⋅ y) −₀ (x ⋅ z) 🝖-end\n\n[⋅]-cancellationₗ : ∀{x} → ⦃ pos : Positive(x) ⦄ → (Names.CancellationOnₗ(_⋅_)(x))\n[⋅]-cancellationₗ {𝐒 a}{b}{c} p with [<]-trichotomy {b}{c}\n... | [∨]-introₗ ([∨]-introₗ lt) with () ← [<]-to-[≢] ([<]-with-[⋅]ₗ {a = a} lt) p\n... | [∨]-introₗ ([∨]-introᵣ eq) = eq\n... | [∨]-introᵣ gt with () ← [>]-to-[≢] ([<]-with-[⋅]ₗ {a = a} gt) p\n\n[⋅]-cancellationᵣ : ∀{x} → ⦃ pos : Positive(x) ⦄ → (Names.CancellationOnᵣ(_⋅_)(x))\n[⋅]-cancellationᵣ {𝐒 c}{a}{b} p with [<]-trichotomy {a}{b}\n... | [∨]-introₗ ([∨]-introₗ lt) with () ← [<]-to-[≢] ([<]-with-[⋅]ᵣ {c = c} lt) p\n... | [∨]-introₗ ([∨]-introᵣ eq) = eq\n... | [∨]-introᵣ gt with () ← [>]-to-[≢] ([<]-with-[⋅]ᵣ {c = c} gt) p\n", "meta": {"hexsha": "106bbf45d16dfafa4673b19f5eb8aefff1ec2dbd", "size": 3491, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Oper/Proofs/Multiplication.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Oper/Proofs/Multiplication.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Oper/Proofs/Multiplication.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.546875, "max_line_length": 159, "alphanum_fraction": 0.4906903466, "num_tokens": 1778, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.863391599428538, "lm_q2_score": 0.7431680086124811, "lm_q1q2_score": 0.6416450156000516}} {"text": "module plfa.Induction where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong; sym) \nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _≡⟨_⟩_ ;_∎)\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_; _^_)\n\n-- @practice: exercise `operators` start\n--\n-- 1. _+_ _*_: Unit (Zero), Associativity, Commutativity\n-- operator _*_ distributes over operator _+_ from the left and right.\n--\n-- 2. x operator of matrices: Unit (Unit matrix),\n-- Associativity (Associativity of the Linear transformation)\n-- No Commutativity\n\n-- @practice: exercise `operators` end\n\n_ : (3 + 4) + 5 ≡ 3 + (4 + 5)\n_ =\n begin\n (3 + 4) + 5\n ≡⟨⟩\n 7 + 5\n ≡⟨⟩\n 12\n ≡⟨⟩\n 3 + 9\n ≡⟨⟩\n 3 + (4 + 5)\n ∎\n\n+-assoc : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p)\n+-assoc zero n p =\n begin\n (zero + n) + p\n ≡⟨⟩\n n + p\n ≡⟨⟩\n zero + (n + p)\n ∎\n+-assoc (suc m) n p =\n begin\n (suc m + n) + p\n ≡⟨⟩\n suc (m + n) + p\n ≡⟨⟩\n suc ((m + n) + p)\n ≡⟨ cong suc (+-assoc m n p) ⟩\n suc (m + (n + p))\n ≡⟨⟩\n suc m + (n + p)\n ∎\n\n-- examples start\n\n+-assoc-2 : ∀ (n p : ℕ) → (2 + n) + p ≡ 2 + (n + p)\n+-assoc-2 n p =\n begin\n (2 + n) + p\n ≡⟨⟩\n suc (1 + n) + p\n ≡⟨⟩\n suc ((1 + n) + p)\n ≡⟨ cong suc (+-assoc-1 n p) ⟩\n suc (1 + (n + p))\n ≡⟨⟩\n 2 + (n + p)\n ∎\n where\n +-assoc-1 : ∀ (n p : ℕ) → (1 + n) + p ≡ 1 + (n + p)\n +-assoc-1 n p =\n begin\n (1 + n) + p\n ≡⟨⟩\n suc (0 + n) + p\n ≡⟨⟩\n suc ((0 + n) + p)\n ≡⟨ cong suc (+-assoc-0 n p) ⟩\n suc (0 + (n + p))\n ≡⟨⟩\n 1 + (n + p)\n ∎\n where\n +-assoc-0 : ∀ (n p : ℕ) → (0 + n) + p ≡ 0 + (n + p)\n +-assoc-0 n p =\n begin\n (0 + n) + p\n ≡⟨⟩\n n + p\n ≡⟨⟩\n 0 + (n + p)\n ∎\n\n-- examples end\n\n+-identityʳ : ∀ ( m : ℕ ) → m + zero ≡ m\n+-identityʳ zero =\n begin\n zero + zero\n ≡⟨⟩\n zero\n ∎\n+-identityʳ (suc m) =\n begin\n suc m + zero\n ≡⟨⟩\n suc (m + zero)\n ≡⟨ cong suc (+-identityʳ m) ⟩\n suc m\n ∎\n\n\n+-suc : ∀ ( m n : ℕ ) → m + suc n ≡ suc ( m + n )\n+-suc zero n =\n begin\n zero + suc n\n ≡⟨⟩\n suc n\n ≡⟨⟩\n suc (zero + n)\n ∎\n+-suc (suc m) n =\n begin\n suc m + suc n\n ≡⟨⟩\n suc ( m + suc n )\n ≡⟨ cong suc (+-suc m n)⟩\n suc ( suc ( m + n ))\n ≡⟨⟩\n suc ( suc m + n)\n ∎\n\n+-comm : ∀ ( m n : ℕ ) → m + n ≡ n + m\n+-comm m zero =\n begin\n m + zero\n ≡⟨ +-identityʳ m ⟩\n m\n ≡⟨⟩\n zero + m\n ∎\n+-comm m (suc n) =\n begin\n m + suc n\n ≡⟨ +-suc m n ⟩\n suc (m + n)\n ≡⟨ cong suc ( +-comm m n )⟩\n suc (n + m)\n ≡⟨⟩\n suc n + m\n ∎\n\n+-rearrange : ∀ (m n p q : ℕ) → (m + n) + (p + q) ≡ m + (n + p) + q\n+-rearrange m n p q =\n begin\n (m + n) + (p + q)\n ≡⟨ +-assoc m n (p + q) ⟩\n m + (n + (p + q))\n ≡⟨ cong ( m +_ ) (sym (+-assoc n p q)) ⟩\n m + ((n + p) + q)\n ≡⟨ sym (+-assoc m (n + p) q)⟩\n (m + (n + p)) + q\n ∎\n\n-- @stretch: exercise `finite-+-assoc` start\n\n-- Day 0\n\n-- Day 1\n-- 0: ℕ\n\n--Day 2\n-- 1: ℕ\n-- (0 + 0) + 0 ≡ 0 + (0 + 0)\n\n-- Day 3\n-- 2: ℕ\n-- (0 + 0) + 1 ≡ 0 + (0 + 1)\n-- (0 + 1) + 0 ≡ 0 + (1 + 0)\n-- (0 + 1) + 1 ≡ 0 + (1 + 1)\n-- (1 + 0) + 0 ≡ 1 + (0 + 0)\n-- (1 + 0) + 1 ≡ 1 + (0 + 1)\n-- (1 + 1) + 0 ≡ 1 + (1 + 0)\n-- (1 + 1) + 1 ≡ 1 + (1 + 1)\n\n-- Day 4\n-- 3 : ℕ\n-- (0 + 0) + 2 ≡ 0 + (0 + 2)\n-- (0 + 1) + 2 ≡ 0 + (1 + 2)\n-- (0 + 2) + 0 ≡ 0 + (2 + 0)\n-- (0 + 2) + 1 ≡ 0 + (2 + 1)\n-- (0 + 2) + 2 ≡ 0 + (2 + 2)\n-- (1 + 0) + 2 ≡ 1 + (0 + 2)\n-- (1 + 1) + 2 ≡ 1 + (1 + 2)\n-- (1 + 2) + 0 ≡ 1 + (2 + 0)\n-- (1 + 2) + 1 ≡ 1 + (2 + 1)\n-- (1 + 2) + 2 ≡ 1 + (2 + 2)\n-- (2 + 0) + 0 ≡ 2 + (0 + 0)\n-- (2 + 0) + 1 ≡ 2 + (0 + 1)\n-- (2 + 0) + 2 ≡ 2 + (0 + 2)\n-- (2 + 1) + 0 ≡ 2 + (1 + 0)\n-- (2 + 1) + 1 ≡ 2 + (1 + 1)\n-- (2 + 1) + 2 ≡ 2 + (1 + 2)\n-- (2 + 2) + 0 ≡ 2 + (2 + 0)\n-- (2 + 2) + 1 ≡ 2 + (2 + 1)\n-- (2 + 2) + 2 ≡ 2 + (2 + 2)\n\n-- @stretch: exercise `finite-+-assoc` end\n\n+-assoc' : ∀ ( m n p : ℕ ) → (m + n) + p ≡ m + (n + p)\n+-assoc' zero n p = refl\n+-assoc' (suc m) n p rewrite +-assoc' m n p = refl\n\n+-identity' : ∀ ( n : ℕ ) → n + zero ≡ n\n+-identity' zero = refl\n+-identity' (suc m) rewrite +-identity' m = refl\n\n+-suc' : ∀ ( m n : ℕ ) → m + suc n ≡ suc (m + n)\n+-suc' zero n = refl\n+-suc' (suc m) n rewrite +-suc' m n = refl\n\n+-comm' : ∀ ( m n : ℕ ) → m + n ≡ n + m\n+-comm' m zero rewrite +-identity' m = refl\n+-comm' m (suc n) rewrite +-suc' m n | +-comm' m n = refl\n\n-- with hole\n\n+-assoc'' : ∀ (m n p : ℕ ) → ( m + n ) + p ≡ m + (n + p)\n+-assoc'' zero n p = refl\n+-assoc'' (suc m) n p rewrite +-assoc'' m n p = refl\n\n-- @recommended: exercise `+-swap` start\n\n+-swap : ∀ ( m n p : ℕ ) → m + (n + p) ≡ n + (m + p)\n+-swap zero n p = refl\n+-swap (suc m) n p rewrite +-swap m n p | +-suc n (m + p) = refl\n\n-- @recommended: exercise `+-swap` end\n\n-- @recommended: exercise `*-distrib-+` start\n\n*-distrib-+ : ∀ ( m n p : ℕ ) → ( m + n ) * p ≡ m * p + n * p\n*-distrib-+ zero n p = refl\n*-distrib-+ (suc m) n p rewrite *-distrib-+ m n p | +-assoc p (m * p) (n * p) = refl\n\n-- @recommended: exercise `*-distrib-+` end\n\n-- @recommended: exercise `*-assoc` start\n\n*-assoc : ∀ ( m n p : ℕ ) → (m * n) * p ≡ m * ( n * p)\n*-assoc zero n p = refl\n*-assoc (suc m) n p rewrite *-distrib-+ n (m * n) p | *-assoc m n p = refl\n\n-- @recommended: exercise `*-assoc` end\n\n-- @practice: exercise `*-comm` start\n\n*-zeroʳ : ∀ ( m : ℕ ) → m * zero ≡ zero\n*-zeroʳ zero = refl\n*-zeroʳ ( suc m ) rewrite *-distrib-+ 1 m zero | *-zeroʳ m = refl\n\n*-suc : ∀ ( n m : ℕ ) → n + n * m ≡ n * suc m\n*-suc zero m = refl\n*-suc (suc n) m\n rewrite\n sym (*-suc n m) |\n sym (+-assoc m n ( n * m )) | sym ( +-assoc n m ( n * m )) |\n +-comm m n = refl\n\n*-comm : ∀ ( m n : ℕ ) → m * n ≡ n * m\n*-comm zero n rewrite *-zeroʳ n = refl\n*-comm (suc m) n rewrite *-distrib-+ 1 m n | +-identityʳ n | *-comm m n | *-suc n m = refl\n\n-- @practice: exercise `*-comm` end\n-- @practice: exercise `0∸n≡0` start\n\n0∸n≡0 : ∀ ( n : ℕ ) → 0 ∸ n ≡ 0\n0∸n≡0 zero = refl\n0∸n≡0 (suc n) = refl\n\n-- @practice: exercise `0∸n≡0` end\n-- @practice: exercise `∸-|-assoc` start\n\n∸-|-assoc : ∀ ( m n p : ℕ ) → m ∸ n ∸ p ≡ m ∸ ( n + p )\n∸-|-assoc zero n p rewrite 0∸n≡0 n | 0∸n≡0 p | 0∸n≡0 ( n + p ) = refl\n∸-|-assoc (suc m) zero p = refl\n∸-|-assoc (suc m) (suc n) p rewrite ∸-|-assoc m n p = refl\n\n-- @practice: exercise `∸-|-assoc` end\n\n-- @stretch: exercise `+*^` start\n\n^-distribʳ-+-* : ∀ ( m n p : ℕ ) → m ^ ( n + p ) ≡ (m ^ n) * (m ^ p)\n^-distribʳ-+-* m zero zero = refl\n^-distribʳ-+-* m zero (suc p) rewrite +-identityʳ (m * (m ^ p)) = refl\n^-distribʳ-+-* m (suc n) p =\n begin\n m ^ (suc n + p)\n ≡⟨⟩\n m ^ suc ( n + p )\n ≡⟨⟩\n m * ( m ^ ( n + p ) )\n ≡⟨ cong (_*_ m) ( ^-distribʳ-+-* m n p ) ⟩\n m * ( ( m ^ n ) * ( m ^ p ) )\n ≡⟨ sym (*-assoc m (m ^ n) (m ^ p)) ⟩\n m * ( m ^ n ) * (m ^ p)\n ≡⟨⟩\n (m ^ suc n ) * ( m ^ p )\n ∎\n\n^-sucʳ : ∀ ( n p : ℕ ) → n ^ suc p ≡ n * n ^ p\n^-sucʳ n p = refl\n\n^-distribˡ-* : ∀ ( m n p : ℕ ) → (m * n) ^ p ≡ ( m ^ p ) * ( n ^ p)\n^-distribˡ-* m n zero = refl\n^-distribˡ-* m n (suc p) =\n begin\n (m * n) ^ ( suc p )\n ≡⟨ ^-sucʳ (m * n) p ⟩\n (m * n) * ((m * n) ^ p)\n ≡⟨ cong (_*_ (m * n)) (^-distribˡ-* m n p) ⟩\n m * n * ((m ^ p) * (n ^ p))\n ≡⟨ sym (*-assoc (m * n) (m ^ p) (n ^ p)) ⟩\n m * n * (m ^ p) * (n ^ p)\n ≡⟨ *-1234-[13][24] m n (m ^ p) (n ^ p) ⟩\n (m * m ^ p ) * (n * n ^ p)\n ≡⟨ cong (_*_ (m * m ^ p)) (sym (^-sucʳ n p))⟩\n (m * m ^ p ) * ( n ^ suc p)\n ≡⟨ cong (λ {x → x * (n ^ suc p)}) (^-sucʳ m p) ⟩\n (m ^ suc p) * (n ^ suc p)\n ∎\n where\n *-1234-[13][24] : ∀ ( a b c d : ℕ ) → a * b * c * d ≡ (a * c) * ( b * d )\n *-1234-[13][24] a b c d\n rewrite\n *-assoc a b c |\n *-comm b c |\n sym (*-assoc a c b) |\n *-assoc (a * c) b d = refl\n\n^-oneˡ : ∀ ( p : ℕ ) → 1 ^ p ≡ 1\n^-oneˡ zero = refl\n^-oneˡ (suc p) rewrite ^-oneˡ p = refl\n\n^-distribʳ-* : ∀ ( m n p : ℕ ) → m ^ (n * p) ≡ (m ^ n) ^ p\n^-distribʳ-* m zero p rewrite ^-oneˡ p = refl\n^-distribʳ-* m n zero rewrite *-zeroʳ n = refl\n^-distribʳ-* m (suc n) (suc p)\n rewrite\n ^-distribʳ-+-* m p ( n * suc p) |\n ^-distribˡ-* m (m ^ n) p |\n ^-distribʳ-* m n (suc p) =\n begin\n m * ((m ^ p) * ((m ^ n) * ((m ^ n) ^ p)))\n ≡⟨ *-1[2[34]]-13[24] m (m ^ p) (m ^ n) ((m ^ n) ^ p) ⟩\n m * (m ^ n) * ((m ^ p) * ((m ^ n) ^ p))\n ∎\n where\n *-1[2[34]]-13[24] : ∀ ( a b c d : ℕ ) → a * ( b * ( c * d ) ) ≡ a * c * ( b * d )\n *-1[2[34]]-13[24] a b c d\n rewrite\n sym (*-assoc b c d) |\n *-comm b c |\n *-assoc c b d |\n sym (*-assoc a c (b * d)) = refl\n \n-- @stretch: exercise `+*^` end\n\n-- @stretch: exercise `Bin-laws` start\n\ndata Bin : Set where\n ⟨⟩ : Bin\n _O : Bin → Bin\n _I : Bin → Bin\n\ninc : Bin → Bin\ninc (m O) = m I\ninc (m I) = (inc m) O\ninc ⟨⟩ = ⟨⟩ I\n\nto : ℕ → Bin\nto zero = ⟨⟩ O\nto (suc n) = inc (to n)\n\nfrom : Bin -> ℕ\nfrom (m O) = 2 * (from m)\nfrom (m I) = 2 * (from m) + 1\nfrom ⟨⟩ = 0\n\ncomm-+-from : ∀ ( b : Bin ) → from (inc b) ≡ suc (from b)\ncomm-+-from ⟨⟩ = refl\ncomm-+-from (b O)\n rewrite\n sym ( +-suc' (from b) (from b + zero)) |\n +-assoc' (from b) (from b + 0) 1 |\n +-identityʳ (from b) |\n +-comm' (from b) 1 = refl\ncomm-+-from (b I)\n rewrite\n +-identityʳ (from (inc b)) | +-identityʳ ( from b) |\n comm-+-from b |\n sym (+-comm' (from b) 1) |\n +-assoc' (from b) (from b) 1 = refl\n\nidentity-to-from : ∀ ( n : ℕ ) → from (to n) ≡ n\nidentity-to-from zero = refl\nidentity-to-from (suc n) rewrite comm-+-from (to n) | identity-to-from n = refl\n\n-- ⟨⟩ !== ⟨⟩ O\n-- @todo: rewrite with ∃-syntax\n\n-- @stretch: exercise `Bin-laws` end\n\n-- import Data.Nat.Properties using (+-assoc; +-identityʳ; +-suc; +-comm)\n", "meta": {"hexsha": "e3d280d4f5040604de0303f636d36e8821745a60", "size": 9509, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "fp/agda/plfa/Induction.agda", "max_stars_repo_name": "lonelyhentai/workspace", "max_stars_repo_head_hexsha": "2a996af58d6b9be5d608ed040267398bcf72403b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-04-26T16:37:38.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-15T01:26:19.000Z", "max_issues_repo_path": "fp/agda/plfa/Induction.agda", "max_issues_repo_name": "lonelyhentai/workspace", "max_issues_repo_head_hexsha": "2a996af58d6b9be5d608ed040267398bcf72403b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "fp/agda/plfa/Induction.agda", "max_forks_repo_name": "lonelyhentai/workspace", "max_forks_repo_head_hexsha": "2a996af58d6b9be5d608ed040267398bcf72403b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-15T01:26:23.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-15T01:26:23.000Z", "avg_line_length": 22.8581730769, "max_line_length": 91, "alphanum_fraction": 0.4192869913, "num_tokens": 4620, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.935346511643776, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.6416004239008443}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import LogicalFormulae\nopen import Sets.EquivalenceRelations\nopen import Setoids.Setoids\n\nmodule Setoids.Equality {a b : _} {A : Set a} (S : Setoid {a} {b} A) where\n\nopen import Setoids.Subset S\n\n_=S_ : {c d : _} {pred1 : A → Set c} {pred2 : A → Set d} (s1 : subset pred1) (s2 : subset pred2) → Set _\n_=S_ {pred1 = pred1} {pred2} s1 s2 = (x : A) → (pred1 x → pred2 x) && (pred2 x → pred1 x)\n\nsetoidEqualitySymmetric : {c d : _} {pred1 : A → Set c} {pred2 : A → Set d} → (s1 : subset pred1) (s2 : subset pred2) → s1 =S s2 → s2 =S s1\nsetoidEqualitySymmetric s1 s2 s1=s2 x = _&&_.snd (s1=s2 x) ,, _&&_.fst (s1=s2 x)\n\nsetoidEqualityTransitive : {c d e : _} {pred1 : A → Set c} {pred2 : A → Set d} {pred3 : A → Set e} (s1 : subset pred1) (s2 : subset pred2) (s3 : subset pred3) → s1 =S s2 → s2 =S s3 → s1 =S s3\nsetoidEqualityTransitive s1 s2 s3 s1=s2 s2=s3 x with s1=s2 x\nsetoidEqualityTransitive s1 s2 s3 s1=s2 s2=s3 x | p1top2 ,, p1top2' with s2=s3 x\nsetoidEqualityTransitive s1 s2 s3 s1=s2 s2=s3 x | p1top2 ,, p1top2' | fst ,, snd = (λ i → fst (p1top2 i)) ,, λ i → p1top2' (snd i)\n\nsetoidEqualityReflexive : {c : _} {pred : A → Set c} (s : subset pred) → s =S s\nsetoidEqualityReflexive s x = (λ x → x) ,, λ x → x\n", "meta": {"hexsha": "f75ace318895ae46f20b7f0cb6a8225c07771f7c", "size": 1327, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Setoids/Equality.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Setoids/Equality.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Setoids/Equality.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 53.08, "max_line_length": 191, "alphanum_fraction": 0.6360211002, "num_tokens": 550, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430394931457, "lm_q2_score": 0.7718435030872968, "lm_q1q2_score": 0.6415123551690131}} {"text": "------------------------------------------------------------------------------\n-- The relation of divisibility on partial natural numbers\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule LTC-PCF.Data.Nat.Divisibility.By0 where\n\nopen import LTC-PCF.Base\nopen import LTC-PCF.Data.Nat\n\ninfix 4 _∣_\n\n------------------------------------------------------------------------------\n-- The relation of divisibility (the symbol is '\\mid' not '|')\n--\n-- (See documentation in FOTC.Data.Nat.Divisibility.By0)\n--\n-- In our definition 0∣0, which is used to prove properties of the gcd\n-- as it is in GHC ≥ 7.2.1, where gcd 0 0 = 0 (see\n-- http://hackage.haskell.org/trac/ghc/ticket/3304).\n\n-- Note that @k@ should be a total natural number.\n_∣_ : D → D → Set\nm ∣ n = ∃[ k ] N k ∧ n ≡ k * m\n", "meta": {"hexsha": "9c7d68e463ef41cc3de5bce8c1f9fb87e126778d", "size": 988, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/LTC-PCF/Data/Nat/Divisibility/By0.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/LTC-PCF/Data/Nat/Divisibility/By0.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/LTC-PCF/Data/Nat/Divisibility/By0.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 34.0689655172, "max_line_length": 78, "alphanum_fraction": 0.479757085, "num_tokens": 234, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8774767874818408, "lm_q2_score": 0.731058584489497, "lm_q1q2_score": 0.6414869381788657}} {"text": "module Generic.Lib.Equality.Propositional where\n\nopen import Level\nopen import Relation.Binary\nopen import Data.Empty\n\ninfix 3 _≡_ _≢_ _≗_\n\ndata _≡_ {α} {A : Set α} (x : A) : A -> Set where\n instance refl : x ≡ x\n\npattern lrefl = lift refl\n\n_≢_ : ∀ {α} {A : Set α} -> A -> A -> Set\nx ≢ y = x ≡ y -> ⊥\n\n_≗_ : ∀ {α β} {A : Set α} {B : A -> Set β} -> (∀ x -> B x) -> (∀ x -> B x) -> Set α\nf ≗ g = ∀ x -> f x ≡ g x\n\nsym : ∀ {α} {A : Set α} {x y : A} -> x ≡ y -> y ≡ x\nsym refl = refl\n\ntrans : ∀ {α} {A : Set α} {x y z : A} -> x ≡ y -> y ≡ z -> x ≡ z\ntrans refl refl = refl\n\nleft : ∀ {α} {A : Set α} {x y z : A} -> y ≡ x -> z ≡ x -> y ≡ z\nleft refl refl = refl\n\nright : ∀ {α} {A : Set α} {x y z : A} -> x ≡ y -> x ≡ z -> y ≡ z\nright refl refl = refl\n\nsubst : ∀ {α β} {A : Set α} {x y} -> (B : A -> Set β) -> x ≡ y -> B x -> B y\nsubst B refl z = z\n\ncong : ∀ {α β} {A : Set α} {B : Set β} {x y} -> (f : A -> B) -> x ≡ y -> f x ≡ f y\ncong f refl = refl\n\ncong₂ : ∀ {α β γ} {A : Set α} {B : Set β} {C : Set γ} {x₁ x₂ y₁ y₂}\n -> (g : A -> B -> C) -> x₁ ≡ x₂ -> y₁ ≡ y₂ -> g x₁ y₁ ≡ g x₂ y₂\ncong₂ g refl refl = refl\n\n≡-Setoid : ∀ {α} -> Set α -> Setoid α zero\n≡-Setoid A = record\n { Carrier = A\n ; _≈_ = _≡_\n ; isEquivalence = record\n { refl = refl\n ; sym = sym\n ; trans = trans\n }\n }\n", "meta": {"hexsha": "f8f47eea8854f202a96bed7715fa6da1fffe70bf", "size": 1322, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Generic/Lib/Equality/Propositional.agda", "max_stars_repo_name": "turion/Generic", "max_stars_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 30, "max_stars_repo_stars_event_min_datetime": "2016-07-19T21:10:54.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T10:19:38.000Z", "max_issues_repo_path": "src/Generic/Lib/Equality/Propositional.agda", "max_issues_repo_name": "turion/Generic", "max_issues_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2017-04-06T18:58:09.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-04T15:43:14.000Z", "max_forks_repo_path": "src/Generic/Lib/Equality/Propositional.agda", "max_forks_repo_name": "turion/Generic", "max_forks_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2017-07-17T07:23:39.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-27T12:57:09.000Z", "avg_line_length": 25.4230769231, "max_line_length": 83, "alphanum_fraction": 0.4508320726, "num_tokens": 595, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774767778695834, "lm_q2_score": 0.7310585844894971, "lm_q1q2_score": 0.6414869311517426}} {"text": "module List.Permutation.Base.Bag (A : Set) where\n\nopen import Data.List\nopen import Data.List.Any as Any\nopen import Data.List.Any.BagAndSetEquality\nopen import Data.List.Any.Properties\nopen import Data.Sum renaming (_⊎_ to _∨_)\nopen import Function\nopen import Function.Inverse hiding (sym ; _∘_ ; id)\nopen import Function.Related as Related hiding (_∼[_]_) \nopen import List.Permutation.Base A\nimport Relation.Binary.EqReasoning as EqR\nopen import Relation.Binary.PropositionalEquality as P hiding (sym)\n\nopen Any.Membership-≡\nopen EqR ([ bag ]-Equality A)\nopen Related.EquationalReasoning renaming (_∎ to _□)\n\ninfix 4 _≈-bag_\n\n_≈-bag_ : ∀ {a} {A : Set a} → List A → List A → Set a\nxs ≈-bag ys = xs ∼[ bag ] ys\n\nsym-≈-bag : {xs ys : List A} → xs ≈-bag ys → ys ≈-bag xs\nsym-≈-bag {xs} {ys} xs≈ys {z} = record\n { to = Inverse.from xs≈ys\n ; from = Inverse.to xs≈ys\n ; inverse-of = record\n { left-inverse-of = Inverse.right-inverse-of xs≈ys\n ; right-inverse-of = Inverse.left-inverse-of xs≈ys\n }\n }\n\nrefl-≈-bag : {xs : List A} → xs ≈-bag xs\nrefl-≈-bag {xs} = begin xs ∎\n\n∨↔ : ∀{a b}{A : Set a}{B : Set b} → (A ∨ B) ↔ (B ∨ A)\n∨↔ = record\n { to = P.→-to-⟶ ∨→\n ; from = P.→-to-⟶ ∨→\n ; inverse-of = record\n { left-inverse-of = v→∘v→\n ; right-inverse-of = v→∘v→\n }\n }\n where\n ∨→ : ∀{a b}{A : Set a}{B : Set b} → (A ∨ B) → (B ∨ A)\n ∨→ (inj₁ x) = inj₂ x\n ∨→ (inj₂ x) = inj₁ x\n\n v→∘v→ : ∀{a b}{A : Set a}{B : Set b}(a∨b : A ∨ B) → ∨→ (∨→ a∨b) ≡ a∨b\n v→∘v→ (inj₁ _) = refl\n v→∘v→ (inj₂ _) = refl\n\nxy≈-bag-yx : {x y : A} → x ∷ y ∷ [] ≈-bag y ∷ x ∷ []\nxy≈-bag-yx {x} {y} {z} = \n z ∈ x ∷ y ∷ [] ↔⟨ sym $ ++↔ {xs = x ∷ []} {ys = y ∷ []} ⟩\n (z ∈ x ∷ [] ∨ z ∈ y ∷ []) ↔⟨ ∨↔ ⟩ \n (z ∈ y ∷ [] ∨ z ∈ x ∷ []) ↔⟨ ++↔ ⟩\n z ∈ y ∷ x ∷ [] □\n\nlemma-/-≈-bag : {y : A}{xs ys : List A} → xs / y ⟶ ys → xs ≈-bag (y ∷ ys)\nlemma-/-≈-bag /head = refl-≈-bag \nlemma-/-≈-bag (/tail {x} {y} {xs} {ys} xs/y⟶ys) = begin\n x ∷ xs ≈⟨ ∷-cong refl (lemma-/-≈-bag xs/y⟶ys) ⟩\n x ∷ y ∷ ys ≈⟨ ++-cong xy≈-bag-yx refl-≈-bag ⟩\n y ∷ x ∷ ys ∎\n\nlemma-∼-≈-bag : {xs ys : List A} → xs ∼ ys → xs ≈-bag ys\nlemma-∼-≈-bag ∼[] = refl-≈-bag \nlemma-∼-≈-bag (∼x {x} {xs} {ys} {xs'} {ys'} xs/x⟶xs' ys/x⟶ys' xs'∼ys') = begin\n xs ≈⟨ lemma-/-≈-bag xs/x⟶xs' ⟩\n x ∷ xs' ≈⟨ ∷-cong refl (lemma-∼-≈-bag xs'∼ys') ⟩\n x ∷ ys' ≈⟨ sym-≈-bag (lemma-/-≈-bag ys/x⟶ys') ⟩\n ys ∎\n \n", "meta": {"hexsha": "0ef0fe6c942d9307706017cf7f178fb23a5e9581", "size": 2373, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/List/Permutation/Base/Bag.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/List/Permutation/Base/Bag.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/List/Permutation/Base/Bag.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.8181818182, "max_line_length": 78, "alphanum_fraction": 0.5179098188, "num_tokens": 1143, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637505099167, "lm_q2_score": 0.7461389986757757, "lm_q1q2_score": 0.6414286500033312}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Setoids.Setoids\nopen import Sets.EquivalenceRelations\nopen import Rings.Definition\n\n\nmodule Rings.Ideals.Principal.Lemmas {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) where\n\nopen Setoid S\nopen Ring R\nopen Equivalence eq\nopen import Rings.Ideals.Principal.Definition R\nopen import Rings.Ideals.Definition R\nopen import Rings.Ideals.Lemmas R\nopen import Rings.Divisible.Definition R\n\ngeneratorZeroImpliesAllZero : {c : _} {pred : A → Set c} → {i : Ideal pred} → (princ : PrincipalIdeal i) → PrincipalIdeal.generator princ ∼ 0R → {x : A} → pred x → x ∼ 0R\ngeneratorZeroImpliesAllZero record { generator = gen ; genIsInIdeal = genIsInIdeal ; genGenerates = genGenerates } gen=0 {x} predX = generatorZeroImpliesMembersZero {x} (divisibleWellDefined gen=0 reflexive (genGenerates predX))\n", "meta": {"hexsha": "1fa04184e92b73d87afbba50c01ac6d7041240d7", "size": 889, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Rings/Ideals/Principal/Lemmas.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Rings/Ideals/Principal/Lemmas.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Rings/Ideals/Principal/Lemmas.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 44.45, "max_line_length": 228, "alphanum_fraction": 0.733408324, "num_tokens": 275, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8596637505099168, "lm_q2_score": 0.746138993030751, "lm_q1q2_score": 0.6414286451505081}} {"text": "module Setoids where\n\nopen import Eq\nopen import Prelude\n\nrecord Setoid : Set1 where\n field\n carrier : Set\n _≈_ : carrier -> carrier -> Set\n equiv : Equiv _≈_\n\nrecord Datoid : Set1 where\n field\n setoid : Setoid\n _≟_ : forall x y -> Dec (Setoid._≈_ setoid x y)\n\nSetoid-≡ : Set -> Setoid\nSetoid-≡ a = record { carrier = a; _≈_ = _≡_; equiv = Equiv-≡ }\n", "meta": {"hexsha": "3b7898b54577a5686178045b26281d51670d411b", "size": 376, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/AIM6/RegExp/talk/Setoids.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/AIM6/RegExp/talk/Setoids.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/AIM6/RegExp/talk/Setoids.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 19.7894736842, "max_line_length": 63, "alphanum_fraction": 0.6143617021, "num_tokens": 135, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9046505402422644, "lm_q2_score": 0.7090191460821871, "lm_q1q2_score": 0.6414145535453596}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Setoids.Setoids\nopen import Rings.Definition\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\n\nmodule Rings.Ideals.Principal.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) where\n\nopen import Rings.Ideals.Definition R\nopen import Rings.Divisible.Definition R\nopen Setoid S\n\nrecord PrincipalIdeal {c : _} {pred : A → Set c} (ideal : Ideal pred) : Set (a ⊔ b ⊔ c) where\n field\n generator : A\n genIsInIdeal : pred generator\n genGenerates : {x : A} → pred x → generator ∣ x\n", "meta": {"hexsha": "1fe2042b2d0b2cf49ca638072ebbee573ee98ae7", "size": 606, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Rings/Ideals/Principal/Definition.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Rings/Ideals/Principal/Definition.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Rings/Ideals/Principal/Definition.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 31.8947368421, "max_line_length": 134, "alphanum_fraction": 0.6650165017, "num_tokens": 199, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9046505248181418, "lm_q2_score": 0.7090191460821871, "lm_q1q2_score": 0.6414145426093613}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category using (Category; module Commutation)\nopen import Categories.Category.Cartesian using (Cartesian)\n\n-- Defines the following properties of a Category:\n-- Cartesian.SymmetricMonoidal\n-- a Cartesian category is Symmetric Monoidal if its induced monoidal structure is symmetric\n\nmodule Categories.Category.Cartesian.SymmetricMonoidal {o ℓ e} (𝒞 : Category o ℓ e) (cartesian : Cartesian 𝒞) where\n\nopen import Data.Product using (_,_)\n\nopen Category 𝒞\nopen Commutation 𝒞\nopen HomReasoning\n\nopen import Categories.Category.BinaryProducts 𝒞 using (module BinaryProducts)\nopen import Categories.Category.Cartesian.Monoidal using (module CartesianMonoidal)\nopen import Categories.Category.Monoidal using (Monoidal)\nimport Categories.Category.Monoidal.Symmetric as Sym\n\nopen import Categories.NaturalTransformation using (ntHelper)\n\nprivate\n variable\n W X Y Z : Obj\n\nopen Cartesian cartesian using (products)\nopen CartesianMonoidal cartesian using (monoidal)\nopen Sym monoidal using (Symmetric; symmetricHelper)\nopen Monoidal monoidal using (_⊗₀_; _⊗₁_; module associator)\nopen BinaryProducts products\n\nprivate\n B : ∀ {X Y} → X ⊗₀ Y ⇒ Y ⊗₀ X\n B = swap\n\nhexagon : [ (X ⊗₀ Y) ⊗₀ Z ⇒ Y ⊗₀ Z ⊗₀ X ]⟨\n B ⊗₁ id ⇒⟨ (Y ⊗₀ X) ⊗₀ Z ⟩\n associator.from ⇒⟨ Y ⊗₀ X ⊗₀ Z ⟩\n id ⊗₁ B\n ≈ associator.from ⇒⟨ X ⊗₀ Y ⊗₀ Z ⟩\n B ⇒⟨ (Y ⊗₀ Z) ⊗₀ X ⟩\n associator.from\n ⟩\nhexagon = begin\n id ⊗₁ swap ∘ assocˡ ∘ swap ⊗₁ id ≈⟨ refl⟩∘⟨ refl⟩∘⟨ ⟨⟩-congʳ ⟨⟩∘ ⟩\n id ⊗₁ swap ∘ assocˡ ∘ ⟨ ⟨ π₂ ∘ π₁ , π₁ ∘ π₁ ⟩ , id ∘ π₂ ⟩ ≈⟨ refl⟩∘⟨ assocˡ∘⟨⟩ ⟩\n id ⊗₁ swap ∘ ⟨ π₂ ∘ π₁ , ⟨ π₁ ∘ π₁ , id ∘ π₂ ⟩ ⟩ ≈⟨ ⁂∘⟨⟩ ⟩\n ⟨ id ∘ π₂ ∘ π₁ , swap ∘ ⟨ π₁ ∘ π₁ , id ∘ π₂ ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ identityˡ swap∘⟨⟩ ⟩\n ⟨ π₂ ∘ π₁ , ⟨ id ∘ π₂ , π₁ ∘ π₁ ⟩ ⟩ ≈⟨ ⟨⟩-congˡ (⟨⟩-congʳ identityˡ) ⟩\n ⟨ π₂ ∘ π₁ , ⟨ π₂ , π₁ ∘ π₁ ⟩ ⟩ ≈˘⟨ assocˡ∘⟨⟩ ⟩\n assocˡ ∘ ⟨ ⟨ π₂ ∘ π₁ , π₂ ⟩ , π₁ ∘ π₁ ⟩ ≈˘⟨ refl⟩∘⟨ swap∘⟨⟩ ⟩\n assocˡ ∘ swap ∘ assocˡ ∎\n\nsymmetric : Symmetric\nsymmetric = symmetricHelper record\n { braiding = record\n { F⇒G = ntHelper record\n { η = λ _ → swap\n ; commute = λ _ → swap∘⁂\n }\n ; F⇐G = ntHelper record\n { η = λ _ → swap\n ; commute = λ _ → swap∘⁂\n }\n ; iso = λ _ → record\n { isoˡ = swap∘swap\n ; isoʳ = swap∘swap\n }\n }\n ; commutative = swap∘swap\n ; hexagon = hexagon\n }\n", "meta": {"hexsha": "84670dfe26bfc2a8bbc07778e7d9a42794ef26cc", "size": 2675, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Cartesian/SymmetricMonoidal.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/Cartesian/SymmetricMonoidal.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/Cartesian/SymmetricMonoidal.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 35.1973684211, "max_line_length": 115, "alphanum_fraction": 0.5506542056, "num_tokens": 951, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9046505248181417, "lm_q2_score": 0.7090191460821871, "lm_q1q2_score": 0.6414145426093611}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\nopen import cw.CW\nopen import cw.FinCW\nopen import cw.FinBoundary\nopen import cohomology.Theory\n\nmodule cw.cohomology.cochainequiv.DualizedHigherBoundary (OT : OrdinaryTheory lzero)\n {n} (⊙fin-skel : ⊙FinSkeleton (S (S n))) where\n\nopen OrdinaryTheory OT\n\nprivate\n fin-skel = ⊙FinSkeleton.skel ⊙fin-skel\n I = AttachedFinSkeleton.numCells fin-skel\n\n fin-skel₋₁ = AttachedFinSkeleton.skel fin-skel\n I₋₁ = AttachedFinSkeleton.numCells fin-skel₋₁\n\n module FAG = FreeAbelianGroup (Fin I)\n module FAG₋₁ = FreeAbelianGroup (Fin I₋₁)\n\n open FAG renaming (FreeAbGroup to G) using ()\n open FAG₋₁ renaming (FreeAbGroup to G₋₁) using ()\n\nabstract\n rephrase-dualized-higher-boundary-in-degree : ∀ (g : Fin I₋₁ → Group.El (C2 0)) Set where\n refl : x == x\n\nsubst : {A : Set}{x y : A}(P : A -> Set) -> x == y -> P x -> P y\nsubst {A} P refl px = px\n\n", "meta": {"hexsha": "b0bc4a33696f485ec99ecc8507b5dc575d7e0634", "size": 187, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/JMEq.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/JMEq.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/JMEq.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 18.7, "max_line_length": 64, "alphanum_fraction": 0.4545454545, "num_tokens": 80, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8962513786759491, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.6411997371207627}} {"text": "\nmodule Numeric.Nat.LCM where\n\nopen import Prelude\nopen import Numeric.Nat.Divide\nopen import Numeric.Nat.Divide.Properties\nopen import Numeric.Nat.GCD\nopen import Numeric.Nat.GCD.Extended\nopen import Numeric.Nat.GCD.Properties\nopen import Numeric.Nat.Properties\nopen import Tactic.Nat\n\n--- Least common multiple ---\n\nrecord IsLCM m a b : Set where\n no-eta-equality\n constructor is-lcm\n field\n a|m : a Divides m\n b|m : b Divides m\n l : ∀ k → a Divides k → b Divides k → m Divides k\n\nrecord LCM a b : Set where\n no-eta-equality\n constructor lcm-res\n field\n m : Nat\n isLCM : IsLCM m a b\n\nopen LCM using () renaming (m to get-lcm) public\n\neraseIsLCM : ∀ {a b m} → IsLCM m a b → IsLCM m a b\neraseIsLCM (is-lcm a|m b|m g) = is-lcm (fast-divides a|m) (fast-divides b|m)\n λ k a|k b|k → fast-divides (g k a|k b|k)\n\neraseLCM : ∀ {a b} → LCM a b → LCM a b\neraseLCM (lcm-res m p) = lcm-res m (eraseIsLCM p)\n\nprivate\n lem-is-lcm : ∀ {a b d} (g : IsGCD d a b) →\n IsLCM (is-gcd-factor₁ g * b) a b\n lem-is-lcm {a} {b} {0} (is-gcd (factor q eq) d|b g)\n rewrite a ≡⟨ by eq ⟩ 0 ∎ | divides-zero d|b | q * 0 ≡⟨ auto ⟩ 0 ∎ =\n is-lcm divides-refl divides-refl (λ _ 0|k _ → 0|k)\n lem-is-lcm {a} {b} {d@(suc d′)} isg@(is-gcd (factor! q) d|b@(factor! q′) g) =\n is-lcm (divides-mul-cong-l q d|b)\n (divides-mul-r q divides-refl) least\n where\n lem : IsGCD d a b\n lem = is-gcd (factor! q) d|b g\n\n lem₂ : Coprime q q′\n lem₂ = is-gcd-factors-coprime lem\n\n least : ∀ k → a Divides k → b Divides k → (q * b) Divides k\n least k (factor qa qa=k) (factor qb qb=k) =\n case lem₄ of λ where\n (factor! qqb) → factor qqb (by qb=k)\n where\n lem₃ : qa * q ≡ q′ * qb\n lem₃ = mul-inj₁ (qa * q) (q′ * qb) (suc d′)\n (by (qa=k ⟨≡⟩ʳ qb=k))\n\n lem₄ : q Divides qb\n lem₄ = coprime-divide-mul-l q q′ qb (is-gcd-factors-coprime isg)\n (factor qa lem₃)\n\nlcm : ∀ a b → LCM a b\nlcm a b = eraseLCM $\n case gcd a b of λ where\n (gcd-res d g) →\n lcm-res (is-gcd-factor₁ g * b) (lem-is-lcm g)\n\nlcm! : Nat → Nat → Nat\nlcm! a b = get-lcm (lcm a b)\n", "meta": {"hexsha": "8a4bd1c5c57b6bffd5ddc57ba6cd78334e24addd", "size": 2222, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Numeric/Nat/LCM.agda", "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Numeric/Nat/LCM.agda", "max_issues_repo_name": "lclem/agda-prelude", "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Numeric/Nat/LCM.agda", "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.2368421053, "max_line_length": 80, "alphanum_fraction": 0.5666066607, "num_tokens": 838, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8807970842359877, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.6411986579899431}} {"text": "open import Agda.Builtin.Nat\n\ndata B {A : Set} : A → Set where\n b : (a : A) → B a\n\ndata C {A : Set} : ∀ {a} → B {A} a → Set where\n c : {a : A} → C (b a)\n\nid : ∀ {b} → C b → B 0\nid c = {!!}\n", "meta": {"hexsha": "793e2fcaeb91b23b5f1ee1a9be54faed0dc6f498", "size": 191, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue2620.agda", "max_stars_repo_name": "alhassy/agda", "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_issues_repo_path": "test/interaction/Issue2620.agda", "max_issues_repo_name": "alhassy/agda", "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/interaction/Issue2620.agda", "max_forks_repo_name": "alhassy/agda", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 17.3636363636, "max_line_length": 46, "alphanum_fraction": 0.4397905759, "num_tokens": 89, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.880797071719777, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.6411986384821011}} {"text": "module Qsort where\nopen import Sec4 -- The module with definition of propositions\nimport Sec2\n\n-- postulate needed for ≤ on A\npostulate leq : {A : Set} → A → A → Prop\npostulate geq : {A : Set} → A → A → Prop\npostulate tot-list : {A : Set} → (a b : A) → (leq a b) ∨ (leq b a)\npostulate trans-list : {A : Set} → (a b c : A) → (leq a b) → (leq b c) → (leq a c)\n\n{-\n Definition of a list\n-}\ndata List (A : Set) : Set where\n [] : List A -- Empty list\n _∷_ : A → List A → List A -- Cons\n\n\n-- Proposition stating what is a non empty list\nnelist : {A : Set} → (List A) → Prop\nnelist [] = ⊥\nnelist (x ∷ x₁) = ⊤\n\n\n-- Head function that only works on non empty list\nhead : {A : Set} → (l : List A) → (p : nelist l) → A\nhead [] () -- This can never happen\nhead (x ∷ _) ⋆ = x -- This is the head of the list\n\n-- The tail of the list only works on non empty list\ntail : {A : Set} → (l : List A) → (p : nelist l) → (List A)\ntail [] ()\ntail (_ ∷ l) ⋆ = l\n\ndata Bool : Set where\n True : Bool\n False : Bool\n\ndata ℕ : Set where\n Z : ℕ\n S : ℕ → ℕ\n\n-- Addition of natural numbers\n_+_ : ℕ → ℕ → ℕ\nZ + y = y\nS x + y = S (x + y)\n\n-- Relation on natural numbers\n_≤_ : ℕ → ℕ → Prop\nZ ≤ Z = ⊤\nZ ≤ (S y) = ⊤\nS x ≤ Z = ⊥\nS x ≤ S y = x ≤ y\n\n\n-- {-# BUILTIN NATURAL ℕ #-}\n-- {-# BUILTIN BOOL Bool #-}\n\n-- ≤ is reflexive\n≤-ref : ∀ (x : ℕ) → (x ≤ x) → (x ≤ x)\n≤-ref _ y = y\n\n-- ≤ is not symmetric\n-- ≤-sym : ∀ (x y : ℕ) → (x ≤ y) → (y ≤ x)\n-- ≤-sym Z Z p = ⋆\n-- ≤-sym Z (S y) ⋆ = {!!}\n-- ≤-sym (S x) Z ()\n-- ≤-sym (S x) (S y) p = ≤-sym x y p\n\n-- ≤ is transitive\n≤-trans : ∀ (x y z : ℕ) → (x ≤ y) → (y ≤ z) → (x ≤ z)\n≤-trans Z Z Z p1 p2 = ⋆\n≤-trans Z Z (S z) p1 p2 = ⋆\n≤-trans Z (S y) Z p1 p2 = ⋆\n≤-trans Z (S y) (S z) p1 p2 = ⋆\n≤-trans (S x) Z z () p2\n≤-trans (S x) (S y) Z p1 ()\n≤-trans (S x) (S y) (S z) p1 p2 = ≤-trans x y z p1 p2\n\n-- length of a list \nlength : {A : Set} → (List A) → ℕ\nlength [] = Z\nlength (x ∷ l) = (S Z) + (length l)\n\n-- filter' on a list\nfilter' : {A : Set} → (A → Bool) → (l : List A)\n → List A\nfilter' f [] = []\nfilter' f (x ∷ l) with (f x)\nfilter' f (x ∷ l) | True = (x ∷ (filter' f l))\nfilter' f (x ∷ l) | False = filter' f l\n\n≤-cong : ∀ (x y : ℕ) → (x ≤ y) → (x ≤ (S y))\n≤-cong Z y p = ⋆\n≤-cong (S x) Z ()\n≤-cong (S x) (S y) p = ≤-cong x y p\n\nthm-filter' : {A : Set} → (l : List A) → (f : A → Bool) → length (filter' f l) ≤ S (length l)\nthm-filter' [] f = ⋆\nthm-filter' (x ∷ l) f with (f x) \nthm-filter' (x ∷ l) f | True = thm-filter' l f\nthm-filter' (x ∷ l) f | False = ≤-cong (length (filter' f l)) (S (length l)) (thm-filter' l f)\n\nfilter : {A : Set} → (A → Bool) → (l : List A)\n → Exists (List A) (λ l' → (length l') ≤ (length l))\nfilter f [] = [ [] , ⋆ ]\nfilter f (x ∷ l) = [ filter' f l , thm-filter' l f ]\n\n-- append two lists\n_++_ : {A : Set} → (l : List A) → (l' : List A) → (List A)\n[] ++ l' = l'\n(x ∷ l) ++ l' = (x ∷ (l ++ l'))\n\nleq-nat : ℕ → ℕ → Bool\nleq-nat Z _ = True\nleq-nat (S n) Z = False\nleq-nat (S n) (S m) = leq-nat n m\n\n_<_ : ℕ → ℕ → Bool\nZ < (S _) = True\nZ < Z = False\n(S n) < (S m) = n < m\n(S n) < Z = False\n\n_>_ : ℕ → ℕ → Bool\nm > n = n < m\n\n\n-- The sorting algorithm\n-- The trick here is that we are reducing qsort on \"n\"\nqsort' : ∀ (n : ℕ) → ∀ (l : List ℕ) → (p : (length l) ≤ n) → (List ℕ)\nqsort' Z [] p = []\nqsort' Z (x ∷ l) ()\nqsort' (S n) [] p = []\nqsort' (S n) (x ∷ l) p =\n let\n ll = (filter (leq-nat x) l)\n rr = (filter ((_>_) x) l)\n pl = elim2-exists ll\n pr = elim2-exists rr\n left = qsort' n (elim1-exists ll) (≤-trans (length (elim1-exists ll)) (length l) n pl p)\n right = qsort' n (elim1-exists rr) (≤-trans (length (elim1-exists rr)) (length l) n pr p)\n in\n (left ++ (x ∷ [])) ++ right\n\n\nl' : {A : Set} → (l : List A) → (length l ≤ length l)\nl' [] = ⋆\nl' (x ∷ l) = l' l\n\nqsort : ∀ (l : List ℕ) → List ℕ\nqsort l = qsort' (length l) l (l' l)\n\n-- XXX: definition of an sorted list\nall-sorted-list : {A : Set} → (a : A)\n → (l : List A)\n → Prop\nall-sorted-list a [] = ⊤\nall-sorted-list a (x ∷ l) = leq a x ∧ (all-sorted-list a l)\n\nsorted-list : {A : Set} → List A → Prop\nsorted-list [] = ⊤\nsorted-list (x ∷ l) = (all-sorted-list x l) ∧ (sorted-list l)\n\n\nlem-qsort' : (x₁ : ℕ) → (l : List ℕ) → sorted-list\n ((qsort' (S (length l)) (filter' (leq-nat x₁) l)\n (≤-trans (length (filter' (leq-nat x₁) l)) (S (length l))\n (S (length l)) (thm-filter' l (leq-nat x₁)) (l' l))\n ++ (x₁ ∷ []))\n ++\n qsort' (S (length l)) (filter' (_>_ x₁) l)\n (≤-trans (length (filter' (_>_ x₁) l)) (S (length l))\n (S (length l)) (thm-filter' l (_>_ x₁)) (l' l)))\nlem-qsort' x [] = and ⋆ ⋆\nlem-qsort' x (x₁ ∷ l) = {!!}\n\nlem-qsort : (l : List ℕ) → (x : ℕ) →\n sorted-list\n ((qsort' (length l) (elim1-exists (filter (leq-nat x) l))\n (≤-trans (length (elim1-exists (filter (leq-nat x) l))) (length l)\n (length l) (elim2-exists (filter (leq-nat x) l)) (l' l))\n ++ (x ∷ []))\n ++\n qsort' (length l) (elim1-exists (filter (_>_ x) l))\n (≤-trans (length (elim1-exists (filter (_>_ x) l))) (length l)\n (length l) (elim2-exists (filter (_>_ x) l)) (l' l)))\nlem-qsort [] x = and ⋆ ⋆\nlem-qsort (x ∷ l) x₁ = lem-qsort' x₁ l\n\n-- Theorem that given a list, qsort will actually sort the list\nthm-qsort : ∀ (l : List ℕ) → sorted-list (qsort l)\nthm-qsort [] = ⋆\nthm-qsort (x ∷ l) = lem-qsort l x \n\n\n\n", "meta": {"hexsha": "2e2df15bc99760ee9792c7cb918bf9c13f3e8098", "size": 5629, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Qsort.agda", "max_stars_repo_name": "amal029/agda-tutorial-dybjer", "max_stars_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:52:30.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-08T12:52:30.000Z", "max_issues_repo_path": "Qsort.agda", "max_issues_repo_name": "amal029/agda-tutorial-dybjer", "max_issues_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Qsort.agda", "max_forks_repo_name": "amal029/agda-tutorial-dybjer", "max_forks_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.4292929293, "max_line_length": 114, "alphanum_fraction": 0.4739740629, "num_tokens": 2286, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339556397749, "lm_q2_score": 0.7634837743174788, "lm_q1q2_score": 0.6411232498744017}} {"text": "------------------------------------------------------------------------------\n-- Note on the equality type class using Kettelhoit's approach\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- Adapted from Kettelhoit's thesis.\n\nmodule FOT.FOTC.TypeClasses.EqualityKettelhoit where\n\nopen import FOTC.Base\nopen import FOTC.Data.Bool\nopen import FOTC.Data.Bool.Type\nopen import FOTC.Data.Nat.Type\n\n------------------------------------------------------------------------------\n\nrecord Eq (P : D → Set) : Set₁ where\n field equal : ∀ {t₁ t₂} → P t₁ → P t₂ → Set\n\nopen Eq {{...}} public\n\nboolEq : ∀ {b₁ b₂} → Bool b₁ → Bool b₂ → Set\nboolEq btrue btrue = Bool true\nboolEq bfalse bfalse = Bool true\n{-# CATCHALL #-}\nboolEq _ _ = Bool false\n\nnEq : ∀ {m n} → N m → N n → Set\nnEq nzero nzero = Bool true\nnEq (nsucc Nm) (nsucc Nn) = Bool true\n{-# CATCHALL #-}\nnEq _ _ = Bool false\n\ninstance\n eqInstanceBool : Eq Bool\n eqInstanceBool = record { equal = boolEq }\n\n eqInstanceN : Eq N\n eqInstanceN = record { equal = nEq }\n\ntest₁ : Set\ntest₁ = equal nzero (nsucc nzero)\n\ntest₂ : Set\ntest₂ = equal bfalse bfalse\n\neqN-sym : ∀ {m n} → (Nm : N m) → (Nn : N n) → equal Nm Nn → equal Nn Nm\neqN-sym nzero nzero h = h\neqN-sym nzero (nsucc Nn) h = h\neqN-sym (nsucc Nm) nzero h = h\neqN-sym (nsucc Nm) (nsucc Nn) h = h\n\npostulate eqN-sym' : ∀ {m n} → (Nm : N m) → (Nn : N n) → equal Nm Nn → equal Nn Nm\n-- {-# ATP prove eqN-sym' #-}\n", "meta": {"hexsha": "6f272e8a048889a5946a103972ac223d56066c52", "size": 1677, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/FOTC/TypeClasses/EqualityKettelhoit.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/FOT/FOTC/TypeClasses/EqualityKettelhoit.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/FOT/FOTC/TypeClasses/EqualityKettelhoit.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 28.4237288136, "max_line_length": 82, "alphanum_fraction": 0.5158020274, "num_tokens": 508, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511616741041, "lm_q2_score": 0.7490872131147275, "lm_q1q2_score": 0.6411071615394567}} {"text": "module Progress where\n\nopen import Prelude\nopen import T\n\n---- progress\n\nmodule Progress where\n -- Define a datatype representing that a term satisfies progress\n data TProgress : ∀{A} → TCExp A → Set where\n prog-val : ∀{A} {e : TCExp A} → (D : TVal e) → TProgress e\n prog-step : ∀{A} {e e' : TCExp A} → (D : e ~> e') → TProgress e\n\n -- prove that all terms satisfy progress\n progress : ∀{A} (e : TCExp A) → TProgress e\n progress (var ())\n progress (Λ e) = prog-val val-lam\n progress (e₁ $ e₂) with progress e₁\n progress (e₁ $ e₂) | prog-step D = prog-step (step-app-l D)\n progress (.(Λ e) $ e₂) | prog-val (val-lam {_} {_} {e}) = prog-step step-beta\n progress zero = prog-val val-zero\n progress (suc e) with progress e\n ... | prog-val D = prog-val (val-suc D)\n ... | prog-step D' = prog-step (step-suc D')\n progress (rec e e₀ es) with progress e\n progress (rec .zero e₀ es) | prog-val val-zero = prog-step step-rec-z\n progress (rec .(suc _) e₀ es) | prog-val (val-suc y) = prog-step (step-rec-s y)\n ... | prog-step D = prog-step (step-rec D)\n\n\nopen Progress public\n", "meta": {"hexsha": "b5ef8f11387206dd4f5669721de841971a7fb682", "size": 1089, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Progress.agda", "max_stars_repo_name": "msullivan/godels-t", "max_stars_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2016-12-25T01:52:57.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-22T00:28:03.000Z", "max_issues_repo_path": "Progress.agda", "max_issues_repo_name": "msullivan/godels-t", "max_issues_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Progress.agda", "max_forks_repo_name": "msullivan/godels-t", "max_forks_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-04-26T11:39:14.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-04T22:37:18.000Z", "avg_line_length": 34.03125, "max_line_length": 82, "alphanum_fraction": 0.6290174472, "num_tokens": 357, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9124361652391385, "lm_q2_score": 0.7025300698514777, "lm_q1q2_score": 0.6410138429004665}} {"text": "\nmodule Oscar.Property.IsReflexive where\n\nopen import Oscar.Level\n\nrecord IsReflexive {𝔬} (⋆ : Set 𝔬) {ℓ} (_≣_ : ⋆ → ⋆ → Set ℓ) : Set (𝔬 ⊔ ℓ) where\n field\n reflexivity : ∀ x → x ≣ x\n", "meta": {"hexsha": "6ce59e17979548e0ed67ff6c7a6d3ae09517bed4", "size": 186, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-2/Oscar/Property/IsReflexive.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-2/Oscar/Property/IsReflexive.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-2/Oscar/Property/IsReflexive.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.6666666667, "max_line_length": 80, "alphanum_fraction": 0.6075268817, "num_tokens": 83, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.912436153333645, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.641013823170946}} {"text": "module List.Permutation.Alternative.Correctness (A : Set) where\n\nopen import Data.List\nopen import List.Permutation.Alternative A renaming (_∼_ to _∼′_)\nopen import List.Permutation.Base A\nopen import List.Permutation.Base.Equivalence A\n\nlemma-∼′-∼ : {xs ys : List A} → xs ∼′ ys → xs ∼ ys \nlemma-∼′-∼ ∼refl = refl∼\nlemma-∼′-∼ (∼trans xs∼′ys ys∼′zs) = trans∼ (lemma-∼′-∼ xs∼′ys) (lemma-∼′-∼ ys∼′zs)\nlemma-∼′-∼ (∼head x xs∼′ys) = ∼x /head /head (lemma-∼′-∼ xs∼′ys)\nlemma-∼′-∼ (∼swap xyxs∼′ys) = trans∼ (∼x /head (/tail /head) refl∼) (lemma-∼′-∼ xyxs∼′ys)\n", "meta": {"hexsha": "a70230aa3aac5f670e7f5e883137d66486b0a82e", "size": 553, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/List/Permutation/Alternative/Correctness.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/List/Permutation/Alternative/Correctness.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/List/Permutation/Alternative/Correctness.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.5384615385, "max_line_length": 89, "alphanum_fraction": 0.6292947559, "num_tokens": 259, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9124361604769414, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.6410138225065496}} {"text": "module Generic.Lib.Equality.Heteroindexed where\n\nopen import Data.Product\n\nopen import Generic.Lib.Equality.Propositional\n\ndata [_]_≅_ {ι α} {I : Set ι} {i} (A : I -> Set α) (x : A i) : ∀ {j} -> A j -> Set where\n irefl : [ A ] x ≅ x\n\ninds : ∀ {ι α} {I : Set ι} {A : I -> Set α} {i j} {x : A i} {y : A j}\n -> [ A ] x ≅ y -> i ≡ j\ninds irefl = refl\n\nhomo : ∀ {ι α} {I : Set ι} {A : I -> Set α} {i} {x y : A i}\n -> [ A ] x ≅ y -> x ≡ y\nhomo irefl = refl\n\ninds-homo : ∀ {ι α} {I : Set ι} {A : Set α} {i j : I} {x y : A}\n -> [_]_≅_ {i = i} (λ _ -> A) x {j} y -> i ≡ j × x ≡ y\ninds-homo irefl = refl , refl\n", "meta": {"hexsha": "4cb3ac0e3b9477d9daceb65a2bf3c2f637649977", "size": 619, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Generic/Lib/Equality/Heteroindexed.agda", "max_stars_repo_name": "turion/Generic", "max_stars_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 30, "max_stars_repo_stars_event_min_datetime": "2016-07-19T21:10:54.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T10:19:38.000Z", "max_issues_repo_path": "src/Generic/Lib/Equality/Heteroindexed.agda", "max_issues_repo_name": "turion/Generic", "max_issues_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2017-04-06T18:58:09.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-04T15:43:14.000Z", "max_forks_repo_path": "src/Generic/Lib/Equality/Heteroindexed.agda", "max_forks_repo_name": "turion/Generic", "max_forks_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2017-07-17T07:23:39.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-27T12:57:09.000Z", "avg_line_length": 29.4761904762, "max_line_length": 88, "alphanum_fraction": 0.4717285945, "num_tokens": 278, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9124361509525462, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.6410138158153756}} {"text": "{-# OPTIONS --no-coverage-check #-}\nmodule FlexibleFunArity where\n\ndata Bool : Set where true false : Bool\n\ng : Bool -> Bool -> Bool\ng true = \\ x -> true\ng false true = false\ng false false = true\n\nT : Bool -> Set\nT true = Bool\nT false = Bool -> Bool\n\nf : (b : Bool) -> T b\nf true = true\nf false true = false\nf false false = true\n\n{- checking clause \n\n f false true\n\nstarts with \n\n f (b : Bool) : T b\n\nsplits on b\n\n f true -- no match, discard\n f false -- matches\n\ninstantiate type\n\n f false : T false = Bool -> Bool\n\nextend clause\n\n f false (y : Bool) : Bool\n\nsplit on y\n\n f false true -- matches\n f false false -- no match, discard\n\ndone\n-}\n\n\n{- coverage check starts with\n\n f (x : Bool)\n\nsplits on x\n\n f true -- finds clause 1\n f false\n\nNEW: remaing clauses have bigger arity, so expands to\n\n f false (y : Bool)\n\nsplits on y\n\n f false true -- finds clause 2\n f false false -- finds clause 3\n\ndone\n-}\n\n", "meta": {"hexsha": "e44be10acac9c050a080805a43a0cc06e6836973", "size": 927, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/features/FlexibleFunArity.agda", "max_stars_repo_name": "dagit/agda", "max_stars_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T07:26:06.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T07:26:06.000Z", "max_issues_repo_path": "test/features/FlexibleFunArity.agda", "max_issues_repo_name": "dagit/agda", "max_issues_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/features/FlexibleFunArity.agda", "max_forks_repo_name": "dagit/agda", "max_forks_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 13.0563380282, "max_line_length": 53, "alphanum_fraction": 0.6267529666, "num_tokens": 286, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245787544825, "lm_q2_score": 0.7690802317779601, "lm_q1q2_score": 0.6408934601747684}} {"text": "{-# OPTIONS --without-K --exact-split #-}\n\nimport 05-identity-types\nopen 05-identity-types public\n\n-- Inversion is uninteresting and comes from:\ninversion-proof :\n {i : Level} {A : UU i} (x : A) → (y : A) → Id x y → Id y x\ninversion-proof x y = ind-Id x (λ y' p' → Id y' x) refl y\n\nlemma-2-2-2-i :\n {i j : Level} {A : UU i} {B : UU j} (x y z : A) (f : A → B) → (p : Id x y) → (q : Id y z)\n → Id (ap f (p ∙ q)) ((ap f p) ∙ (ap f q))\nlemma-2-2-2-i x y z f refl q = refl\n-- We apparently don't need a second induction on q..\n\nlemma-2-2-2-ii :\n {i j : Level} {A : UU i} {B : UU j} (x y : A) (f : A → B) → (p : Id x y)\n → Id (ap f (inv p)) (inv (ap f p))\nlemma-2-2-2-ii x y f refl = refl\n\nlemma-2-2-2-iii :\n {i j k : Level} {A : UU i} {B : UU j} {C : UU k} (x y : A) (f : A → B) → (g : B → C) → (p : Id x y)\n → Id (ap g (ap f p)) (ap (g ∘ f) p)\nlemma-2-2-2-iii x y f g refl = refl\n\nlemma-2-2-2-iv :\n {i j k : Level} {A : UU i} {B : UU j} {C : UU k} (x y : A) → (p : Id x y)\n → Id (ap (λ x → x) p) p\nlemma-2-2-2-iv x y refl = refl\n\n-- Path lifting property\nlemma-2-3-2 :\n {i j : Level} {A : UU i} {P : A → UU j} (x y : A) (u : P x) → (p : Id x y)\n → Id (pair x u) (pair y (tr P p u))\nlemma-2-3-2 x y u refl = refl\n\nlemma-2-3-9 :\n {i j : Level} {A : UU i} {P : A → UU j} (x y z : A) (u : P x) → (p : Id x y)\n → (q : Id y z) → Id (tr P q (tr P p u)) (tr P (p ∙ q) u)\nlemma-2-3-9 x y z u refl q = refl\n\nlemma-2-3-10 :\n {i j k : Level} {A : UU i} {B : UU j} {P : B → UU k} (x y : A) (f : A → B) (u : P (f x)) → (p : Id x y)\n → Id (tr (P ∘ f) p u) (tr P (ap f p) u)\nlemma-2-3-10 x y f u refl = refl\n\nlemma-2-3-11 :\n {i j k : Level} {A : UU i} {P : A → UU j} {Q : A → UU k}\n (x y : A) (f : (z : A) → P z → Q z) (u : P x) → (p : Id x y)\n → Id (tr Q p (f x u)) (f y (tr P p u))\nlemma-2-3-11 x y f u refl = refl\n\n-- Eckert-Hamilton\n\n-- First, the loop\nloop-type : {i : Level} {A : UU i} (x : A) → UU i\nloop-type x = Id x x\n\norder-2-star : \n {i : Level} {A : UU i} (a b c : A) → (p q : Id a b) → (r s : Id b c)\n → (alpha : Id p q) → (beta : Id r s) → Id (concat p c r) (concat q c s)\norder-2-star a b c refl q refl s refl refl = refl\n\nleft-whisker :\n {i : Level} {A : UU i} (a b c : A) → (p q : Id a b) → (r : Id b c)\n → (alpha : Id p q) → Id (concat p c r) (concat q c r)\nleft-whisker a b c refl refl r refl = refl\n\nright-whisker :\n {i : Level} {A : UU i} (a b c : A) → (p : Id a b) → (r s : Id b c)\n → (beta : Id r s) → Id (concat p c r) (concat p c s)\nright-whisker a b c p refl refl refl = refl\n\n-- TODO: Eckmann Hilton\n\n-- 2.4: the equivalence of functions, quasi-inverses\n\n-- `Sim-By` might be poorly set up since it basically takes the witness of what it\n-- actually should just be. (../07- has the correct stuff.)\ndata Homotopic-Fn {i j : Level} (A : UU i) (B : UU j) (f g : A → B) : UU (i ⊔ j) where\n Sim-By : ((x : A) → (Id (f x) (g x))) → Homotopic-Fn A B f g\n\ndata Is-Equiv {i j : Level} {A : UU i} {B : UU j} (f : A → B) : UU (i ⊔ j) where\n With-Qinv : (g : B → A) → (Homotopic-Fn A A (g ∘ f) (λ x → x))\n → (Homotopic-Fn B B (f ∘ g) (λ x → x))\n → Is-Equiv f\n\n-- Relying on the book's lemma 2.4.12, we're just using the above for type equivalence\ndata Equiv-Types {i j : Level} (A : UU i) (B : UU j) : UU (i ⊔ j) where\n Eq-By : (Σ (A → B) Is-Equiv) → Equiv-Types A B\n\n-- 2.6.1\nproduct-functoriality :\n {i j : Level} {A : UU i} {B : UU j} (x y : prod A B) → (Id x y)\n → (prod (Id (pr1 x) (pr1 y)) (Id (pr2 x) (pr2 y)))\nproduct-functoriality x y refl = pair refl refl\n\n-- 2.6.2\npair= :\n {i j : Level} {A : UU i} {B : UU j} (a₁ a₂ : A) → (b₁ b₂ : B)\n → (prod (Id a₁ a₂) (Id b₁ b₂)) → (Id (pair a₁ b₁) (pair a₂ b₂))\npair= a₁ a₂ b₁ b₂ (pair refl refl) = refl\n\n-- This is a bit of laziness to exhibit both bits of the proof with the same a₁ etc.\n-- The point is to show that product-functoriality and pair= are quasi-inverses.\nfunctoriality-is-equiv-to-2-6-2 :\n {i j : Level} {A : UU i} {B : UU j} {a₁ a₂ : A} {b₁ b₂ : B} →\n -- First two bindings give us shorthands for the proper invocations of the above\n -- functions (currying away aₙ and bₙ).\n let functorial = (product-functoriality (pair a₁ b₁) (pair a₂ b₂))\n 2-6-2 = (pair= a₁ a₂ b₁ b₂)\n thm-after-funct = (Homotopic-Fn (prod (Id a₁ a₂) (Id b₁ b₂))\n (prod (Id a₁ a₂) (Id b₁ b₂))\n (λ x → x)\n (functorial ∘ 2-6-2))\n funct-after-thm = (Homotopic-Fn (Id (pair a₁ b₁) (pair a₂ b₂))\n (Id (pair a₁ b₁) (pair a₂ b₂))\n (2-6-2 ∘ functorial)\n (λ x → x))\n in (prod thm-after-funct funct-after-thm)\nfunctoriality-is-equiv-to-2-6-2 = pair (Sim-By (λ {(pair refl refl) → refl})) (Sim-By (λ {refl → refl}))\n\n-- 2.6.4\npair-transport :\n {i j k : Level} {Z : UU k} {A : Z → UU i} {B : Z → UU j} (z w : Z) → (p : Id z w) → (x : prod (A z) (B z))\n → (Id (tr (λ z → (prod (A z) (B z))) p x) (pair (tr A p (pr1 x)) (tr B p (pr2 x))))\npair-transport z w refl (pair az bz) = refl\n\n-- 2.6.5\nap-functorial :\n {i j k l : Level} {A : UU i} {A' : UU j} {B : UU k} {B' : UU l} (g : A → A') → (h : B → B')\n → (x y : prod A B) → (p : Id (pr1 x) (pr1 y)) → (q : Id (pr2 x) (pr2 y)) →\n let pf= = (pair= (pr1 x) (pr1 y) (pr2 x) (pr2 y))\n pgh = (pair= (g (pr1 x)) (g (pr1 y)) (h (pr2 x)) (h (pr2 y)))\n f = (λ x → pair (g (pr1 x)) (h (pr2 x)))\n in Id (ap f (pf= (pair p q))) (pgh (pair (ap g p) (ap h q)))\nap-functorial g h (pair aₓ bₓ) (pair ay by) refl refl = refl\n\n-- 2.9: Extensionality\nhapply : {i j : Level} {A : UU i} {B : A → UU j} (f g : (x : A) → B(x)) →\n (Id f g) → ((x : A) → (Id (f x) (g x)))\nhapply f g refl = λ x → refl\n\npostulate fn-ext : Is-Equiv happly\n\ndependent-fn-transport : {i j : Level} {X : UU i} (A : X → UU j) → (B : (x : X) → A x → UU (i ⊔ j))\n (x₁ x₂ : X) → (Id x₁ x₂) →\n (f : (a : A x₁) → (B x₁ a)) → (A x₂) → ((a : A x₂) → (B x₂ a))\ndependent-fn-transport A B x₁ x₂ refl f a = tr (B-hat B) (pair= x₁ x₂ (tr A refl a) a\n (pair refl refl))\n (f (tr A refl a))\n where\n B-hat : {i j : Level} {X : UU i} {A : X → UU j} (B : (x : X) → A x → UU (i ⊔ j)) → (Σ X (λ x → A x)) → UU (i ⊔ j)\n B-hat B w = B (pr1 w) (pr2 w)\n", "meta": {"hexsha": "f8ef409b6e0c8ad4a8b23abf3726894ed2331190", "size": 6445, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/univalent-hott/2-homotopy-type-theory.agda", "max_stars_repo_name": "hemangandhi/HoTT-Intro", "max_stars_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Agda/univalent-hott/2-homotopy-type-theory.agda", "max_issues_repo_name": "hemangandhi/HoTT-Intro", "max_issues_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Agda/univalent-hott/2-homotopy-type-theory.agda", "max_forks_repo_name": "hemangandhi/HoTT-Intro", "max_forks_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.3141025641, "max_line_length": 117, "alphanum_fraction": 0.481768813, "num_tokens": 2791, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619177503205, "lm_q2_score": 0.7772998508568417, "lm_q1q2_score": 0.6408541257044699}} {"text": "open import Relation.Binary hiding (_⇒_)\nopen import Level\n\nmodule Relation.Unary.Monotone {c i}(pre : Preorder i c i) where\n\nopen Preorder pre renaming (Carrier to I; _∼_ to _≤_)\nopen import Relation.Unary\nopen import Data.Product hiding (map)\nopen import Data.List\nopen import Function\n\nrecord Monotone {ℓ}(p : Pred I ℓ) : Set (i ⊔ ℓ) where\n field wk : ∀ {i j} → i ≤ j → p i → p j\n\nopen Monotone\nopen Monotone ⦃...⦄ public\n\n∀≥[_] : ∀ {ℓ} → Pred I ℓ → Pred I (i ⊔ ℓ)\n∀≥[ P ] i = ∀ {j} → i ≤ j → P j\n\n∃≥[_] : ∀ {ℓ} → Pred I ℓ → Pred I (i ⊔ ℓ)\n∃≥[ P ] i = ∃ λ j → i ≤ j × P j\n\ninfixr 4 _↗_\n_↗_ : ∀ {ℓ} → Pred I ℓ → Pred I ℓ → Pred I (i ⊔ ℓ)\n(P ↗ Q) = ∀≥[ P ⇒ Q ]\n\ninstance\n ∀≥-monotone : ∀ {ℓ}{P : Pred I ℓ} → Monotone ∀≥[ P ]\n wk ∀≥-monotone ext f ext' = f (trans ext ext')\n\n mono-∩ : ∀ {i j}{p : Pred I i}{q : Pred I j}\n ⦃ wp : Monotone p ⦄ ⦃ wq : Monotone q ⦄ → Monotone (p ∩ q)\n wk (mono-∩ ⦃ wp ⦄ ⦃ wq ⦄) ext (x , y) = (wk wp ext x , wk wq ext y)\n\n list-monotone : ∀ {B : Pred I i}⦃ wb : Monotone B ⦄ → Monotone (λ W → List (B W))\n wk (list-monotone ⦃ wₐ ⦄) ext v = map (wk wₐ ext) v\n\n open import Data.List.All as All\n all-monotone : ∀ {b i}{B : Set b}{xs : List B}{C : B → Pred I i}\n ⦃ wₐ : ∀ x → Monotone (C x) ⦄ →\n Monotone (λ ys → All (λ x → C x ys) xs)\n wk (all-monotone ⦃ wₐ ⦄) ext v = All.map (λ {a} y → wk (wₐ a) ext y) v\n\n open import Data.Vec using (Vec)\n open import Data.Vec.All as VAll\n vec-all-monotone : ∀ {b i n}{B : Set b}{xs : Vec B n}{C : B → Pred I i}\n ⦃ wₐ : ∀ x → Monotone (C x) ⦄ →\n Monotone (λ ys → VAll.All (λ x → C x ys) xs)\n wk (vec-all-monotone ⦃ wₐ ⦄) ext v = VAll.map (λ {a} y → wk (wₐ a) ext y) v\n\n ≤-mono : ∀ {i} → Monotone (_≤_ i)\n wk ≤-mono = flip trans\n\n open import Data.Maybe as Maybe\n maybe-monotone : ∀ {i}{P : Pred I i} ⦃ mono : Monotone P ⦄ → Monotone (λ W → Maybe (P W))\n wk (maybe-monotone ⦃ mono ⦄) ext mv = Maybe.map (wk mono ext) mv\n", "meta": {"hexsha": "008f1d8729c969b644b635a4897e3f960ff700d2", "size": 1978, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Relation/Unary/Monotone.agda", "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_issues_repo_path": "src/Relation/Unary/Monotone.agda", "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_forks_repo_path": "src/Relation/Unary/Monotone.agda", "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "avg_line_length": 34.1034482759, "max_line_length": 91, "alphanum_fraction": 0.5328614762, "num_tokens": 878, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110368115783, "lm_q2_score": 0.7185943865443349, "lm_q1q2_score": 0.6408504049110834}} {"text": "module 842Isomorphism where\n\n-- Library\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong; cong-app; sym) -- added last\nopen Eq.≡-Reasoning\nopen import Data.Nat using (ℕ; zero; suc; _+_)\nopen import Data.Nat.Properties using (+-comm; +-suc; +-identityʳ) -- added last\n\n-- Function composition.\n\n_∘_ : ∀ {A B C : Set} → (B → C) → (A → B) → (A → C)\n(g ∘ f) x = g (f x)\n\n_∘′_ : ∀ {A B C : Set} → (B → C) → (A → B) → (A → C)\ng ∘′ f = λ x → g (f x)\n\npostulate\n extensionality : ∀ {A B : Set} {f g : A → B}\n → (∀ (x : A) → f x ≡ g x)\n -----------------------\n → f ≡ g\n\n-- Another definition of addition.\n\n_+′_ : ℕ → ℕ → ℕ -- split on n instead, get different code\nm +′ zero = m\nm +′ suc n = suc (m +′ n)\n\nsame-app : ∀ (m n : ℕ) → m +′ n ≡ m + n\nsame-app m zero = sym (+-identityʳ m)\nsame-app m (suc n) rewrite +-suc m n | same-app m n = refl\n\nsame : _+′_ ≡ _+_ -- this requires extensionality\nsame = extensionality λ x → extensionality λ x₁ → same-app x x₁\n\n-- Isomorphism.\n\ninfix 0 _≃_\nrecord _≃_ (A B : Set) : Set where\n constructor mk-≃ -- This has been added, not in PLFA\n field\n to : A → B\n from : B → A\n from∘to : ∀ (x : A) → from (to x) ≡ x\n to∘from : ∀ (y : B) → to (from y) ≡ y\nopen _≃_\n\n-- Equivalent to the following:\n\ndata _≃′_ (A B : Set): Set where\n mk-≃′ : ∀ (to : A → B) →\n ∀ (from : B → A) →\n ∀ (from∘to : (∀ (x : A) → from (to x) ≡ x)) →\n ∀ (to∘from : (∀ (y : B) → to (from y) ≡ y)) →\n A ≃′ B\n\nto′ : ∀ {A B : Set} → (A ≃′ B) → (A → B)\nto′ (mk-≃′ f g g∘f f∘g) = f\n\nfrom′ : ∀ {A B : Set} → (A ≃′ B) → (B → A)\nfrom′ (mk-≃′ f g g∘f f∘g) = g\n\nfrom∘to′ : ∀ {A B : Set} → (A≃B : A ≃′ B)\n → (∀ (x : A)\n → from′ A≃B (to′ A≃B x) ≡ x)\nfrom∘to′ (mk-≃′ f g g∘f f∘g) = g∘f\n\nto∘from′ : ∀ {A B : Set} → (A≃B : A ≃′ B)\n → (∀ (y : B)\n → to′ A≃B (from′ A≃B y) ≡ y)\nto∘from′ (mk-≃′ f g g∘f f∘g) = f∘g\n\n-- End of equivalent formulation (records are faster!)\n\n-- Properties of isomorphism.\n\n-- Reflexivity.\n\n≃-refl : ∀ {A : Set}\n -----\n → A ≃ A\n\n-- in empty hole, split on result, get copatterns (not in PLFA)\n\nto ≃-refl x = x\nfrom ≃-refl x = x\nfrom∘to ≃-refl x = refl\nto∘from ≃-refl x = refl\n\n-- Symmetry.\n\n≃-sym : ∀ {A B : Set}\n → A ≃ B\n -----\n → B ≃ A\n\nto (≃-sym A≃B) = from A≃B\nfrom (≃-sym A≃B) = to A≃B\nfrom∘to (≃-sym A≃B) = to∘from A≃B\nto∘from (≃-sym A≃B) = from∘to A≃B\n\n-- Transitivity.\n\n≃-trans : ∀ {A B C : Set}\n → A ≃ B\n → B ≃ C\n -----\n → A ≃ C\n\nto (≃-trans A≃B B≃C) = to B≃C ∘ to A≃B\nfrom (≃-trans A≃B B≃C) = from A≃B ∘ from B≃C\nfrom∘to (≃-trans A≃B B≃C) x rewrite from∘to B≃C (to A≃B x) = from∘to A≃B x\nto∘from (≃-trans A≃B B≃C) x rewrite to∘from A≃B (from B≃C x) = to∘from B≃C x\n\n-- Isomorphism is an equivalence relation.\n-- We can create syntax for equational reasoning.\n\nmodule ≃-Reasoning where\n\n infix 1 ≃-begin_\n infixr 2 _≃⟨_⟩_\n infix 3 _≃-∎\n\n ≃-begin_ : ∀ {A B : Set}\n → A ≃ B\n -----\n → A ≃ B\n ≃-begin A≃B = A≃B\n\n _≃⟨_⟩_ : ∀ (A : Set) {B C : Set}\n → A ≃ B\n → B ≃ C\n -----\n → A ≃ C\n A ≃⟨ A≃B ⟩ B≃C = ≃-trans A≃B B≃C\n\n _≃-∎ : ∀ (A : Set)\n -----\n → A ≃ A\n A ≃-∎ = ≃-refl\n\nopen ≃-Reasoning\n\n-- Embedding (weaker than isomorphism)\n\ninfix 0 _≲_\nrecord _≲_ (A B : Set) : Set where\n field\n to : A → B\n from : B → A\n from∘to : ∀ (x : A) → from (to x) ≡ x\nopen _≲_\n\n≲-refl : ∀ {A : Set} → A ≲ A\nto ≲-refl x = x\nfrom ≲-refl x = x\nfrom∘to ≲-refl x = refl\n\n≲-trans : ∀ {A B C : Set} → A ≲ B → B ≲ C → A ≲ C\nto (≲-trans A≲B B≲C) = to B≲C ∘ to A≲B\nfrom (≲-trans A≲B B≲C) = from A≲B ∘ from B≲C\nfrom∘to (≲-trans A≲B B≲C) x rewrite from∘to B≲C (to A≲B x) = from∘to A≲B x\n\n≲-antisym : ∀ {A B : Set}\n → (A≲B : A ≲ B)\n → (B≲A : B ≲ A)\n → (to A≲B ≡ from B≲A)\n → (from A≲B ≡ to B≲A)\n -------------------\n → A ≃ B\n\nto (≲-antisym A≲B B≲A to≡from from≡to) = to A≲B\nfrom (≲-antisym A≲B B≲A to≡from from≡to) = from A≲B\nfrom∘to (≲-antisym A≲B B≲A to≡from from≡to) x = from∘to A≲B x\nto∘from (≲-antisym A≲B B≲A to≡from from≡to) y\n rewrite from≡to | to≡from = from∘to B≲A y\n\n-- Tabular reasoning for embedding.\n\nmodule ≲-Reasoning where\n\n infix 1 ≲-begin_\n infixr 2 _≲⟨_⟩_\n infix 3 _≲-∎\n\n ≲-begin_ : ∀ {A B : Set}\n → A ≲ B\n -----\n → A ≲ B\n ≲-begin A≲B = A≲B\n\n _≲⟨_⟩_ : ∀ (A : Set) {B C : Set}\n → A ≲ B\n → B ≲ C\n -----\n → A ≲ C\n A ≲⟨ A≲B ⟩ B≲C = ≲-trans A≲B B≲C\n\n _≲-∎ : ∀ (A : Set)\n -----\n → A ≲ A\n A ≲-∎ = ≲-refl\n\nopen ≲-Reasoning\n\n-- PLFA exercise: Isomorphism implies embedding.\n\n≃-implies-≲ : ∀ {A B : Set}\n → A ≃ B\n -----\n → A ≲ B \n\nto (≃-implies-≲ a≃b) = to a≃b\nfrom (≃-implies-≲ a≃b) = from a≃b\nfrom∘to (≃-implies-≲ a≃b) = from∘to a≃b\n\n-- PLFA exercise: propositional equivalence (weaker than embedding).\n\nrecord _⇔_ (A B : Set) : Set where\n field\n to : A → B\n from : B → A\nopen _⇔_ -- added\n\n-- This is also an equivalence relation.\n\n⇔-refl : ∀ {A : Set}\n -----\n → A ⇔ A\n\n_⇔_.to ⇔-refl x = x\n_⇔_.from ⇔-refl x = x\n\n⇔-sym : ∀ {A B : Set}\n → A ⇔ B\n -----\n → B ⇔ A\n\n_⇔_.to (⇔-sym A⇔B) = from A⇔B\n_⇔_.from (⇔-sym A⇔B) = to A⇔B\n\n⇔-trans : ∀ {A B C : Set}\n → A ⇔ B\n → B ⇔ C\n -----\n → A ⇔ C\n\nto (⇔-trans A⇔B B⇔C) = to B⇔C ∘ to A⇔B\nfrom (⇔-trans A⇔B B⇔C) = from A⇔B ∘ from B⇔C\n\n-- 842 extended exercise: Canonical bitstrings.\n-- Modified and extended from Bin-predicates exercise in PLFA Relations.\n\n-- Copied from 842Naturals.\n\ndata Bin-ℕ : Set where\n bits : Bin-ℕ\n _x0 : Bin-ℕ → Bin-ℕ\n _x1 : Bin-ℕ → Bin-ℕ\n\ndbl : ℕ → ℕ\ndbl zero = zero\ndbl (suc n) = suc (suc (dbl n))\n\n-- Copy your versions of 'inc', 'tob', and 'fromb' over from earlier files.\n-- You may choose to change the definitions here to make proofs easier.\n-- But make sure to test them if you do!\n-- You may also copy over any theorems that prove useful.\n\ninc : Bin-ℕ → Bin-ℕ\ninc n = {!!}\n\ntob : ℕ → Bin-ℕ\ntob n = {!!}\n\ndblb : Bin-ℕ → Bin-ℕ\ndblb n = {!!}\n\nfromb : Bin-ℕ → ℕ\nfromb n = {!!}\n\n\n-- The reason that we couldn't prove ∀ {n : Bin-ℕ} → tob (fromb n) ≡ n\n-- is because of the possibility of leading zeroes in a Bin-ℕ value.\n-- 'bits x0 x0 x1' is such a value that gives a counterexample.\n-- However, the theorem is true is true for n without leading zeroes.\n-- We define a predicate to be able to state this in a theorem.\n-- A value of type One n is evidence that n has a leading one.\n\ndata One : Bin-ℕ → Set where\n [bitsx1] : One (bits x1)\n _[x0] : ∀ {n : Bin-ℕ} → One n → One (n x0)\n _[x1] : ∀ {n : Bin-ℕ} → One n → One (n x1)\n\n-- Here's a proof that 'bits x1 x0 x0' has a leading one.\n\n_ : One (bits x1 x0 x0)\n_ = [bitsx1] [x0] [x0]\n\n-- There is no value of type One (bits x0 x0 x1).\n-- But we can't state and prove this yet, because we don't know\n-- how to express negation. That comes in the Connectives chapter.\n\n-- A canonical binary representation is either zero or has a leading one.\n\ndata Can : Bin-ℕ → Set where\n [zero] : Can bits\n [pos] : ∀ {n : Bin-ℕ} → One n → Can n\n\n-- Some obvious examples:\n\n_ : Can bits\n_ = [zero]\n\n_ : Can (bits x1 x0)\n_ = [pos] ([bitsx1] [x0])\n\n-- The Bin-predicates exercise in PLFA Relations gives three properties of canonicity. \n-- The first is that the increment of a canonical number is canonical.\n\n-- Most of the work is done in the following lemma.\n\n-- 842 exercise: IncCanOne (2 points)\n-- The increment of a canonical number has a leading one.\n\none-inc : ∀ {n : Bin-ℕ} → Can n → One (inc n)\none-inc cn = {!!}\n\n-- The first canonicity property is now an easy corollary.\n\n-- 842 exercise: OneInc (1 point)\n\ncan-inc : ∀ {n : Bin-ℕ} → Can n → Can (inc n)\ncan-inc cn = {!!}\n\n-- The second canonicity property is that converting a unary number\n-- to binary produces a canonical number.\n\n-- 842 exercise: CanToB (1 point)\n\nto-can : ∀ (n : ℕ) → Can (tob n)\nto-can n = {!!}\n\n-- The third canonicity property is that converting a canonical number\n-- from binary and back to unary produces the same number.\n\n-- This takes more work, and some helper lemmas from 842Induction.\n-- You will need to discover which ones.\n\n-- 842 exercise: OneDblbX0 (1 point)\n\n-- This helper function relates binary double to the x0 constructor,\n-- for numbers with a leading one.\n\ndblb-x0 : ∀ {n : Bin-ℕ} → One n → dblb n ≡ n x0\ndblb-x0 on = {!!}\n\n-- We can now prove the third property for numbers with a leading one.\n\n-- 842 exercise: OneToFrom (3 points)\n\none-to∘from : ∀ {n : Bin-ℕ} → One n → tob (fromb n) ≡ n\none-to∘from on = {!!}\n\n-- The third property is now an easy corollary.\n\n-- 842 exercise: CanToFrom (1 point)\n\ncan-to∘from : ∀ {n : Bin-ℕ} → Can n → tob (fromb n) ≡ n\ncan-to∘from cn = {!!}\n\n-- 842 exercise: OneUnique (2 points)\n-- Proofs of positivity are unique.\n\none-unique : ∀ {n : Bin-ℕ} → (x y : One n) → x ≡ y\none-unique x y = {!!}\n\n-- 842 exercise: CanUnique (1 point)\n-- Proofs of canonicity are unique.\n\ncan-unique : ∀ {n : Bin-ℕ} → (x y : Can n) → x ≡ y\ncan-unique x y = {!!}\n\n-- Do we have an isomorphism between ℕ (unary) and canonical binary representations?\n-- Can is not a set, but a family of sets, so it doesn't quite fit\n-- into our framework for isomorphism.\n-- But we can roll all the values into one set which is isomorphic to ℕ.\n\n-- A CanR value wraps up a Bin-ℕ and proof it has a canonical representation.\n\ndata CanR : Set where\n wrap : ∀ (n : Bin-ℕ) → Can n → CanR\n\n-- We can show that there is an isomorphism between ℕ and CanR.\n\n-- 842 exercise: IsoNCanR (3 points)\n\niso-ℕ-CanR : ℕ ≃ CanR\niso-ℕ-CanR = {!!}\n\n-- Can we get an isomorphism between ℕ and some binary encoding,\n-- without the awkwardness of non-canonical values?\n-- Yes: we use digits 1 and 2, instead of 0 and 1 (multiplier/base is still 2).\n-- This is known as bijective binary numbering.\n-- The counting sequence goes , 1, 2, 11, 12, 21, 22, 111...\n\ndata Bij-ℕ : Set where\n bits : Bij-ℕ\n _x1 : Bij-ℕ → Bij-ℕ\n _x2 : Bij-ℕ → Bij-ℕ\n\n-- There is an isomorphism between ℕ and Bij-ℕ.\n-- The proof largely follows the outline of what we did above,\n-- and is left as an optional exercise.\n\n-- See PLFA for remarks on standard library definitions similar to those here.\n\n-- Unicode introduced in this chapter:\n\n{-\n\n ∘ U+2218 RING OPERATOR (\\o, \\circ, \\comp)\n λ U+03BB GREEK SMALL LETTER LAMBDA (\\lambda, \\Gl)\n ≃ U+2243 ASYMPTOTICALLY EQUAL TO (\\~-)\n ≲ U+2272 LESS-THAN OR EQUIVALENT TO (\\<~)\n ⇔ U+21D4 LEFT RIGHT DOUBLE ARROW (\\<=>)\n\n-}\n", "meta": {"hexsha": "ac716b16c1985fae07b50ba2209dab9901a63f14", "size": 10388, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x05-842Isomorphism.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x05-842Isomorphism.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x05-842Isomorphism.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 24.1020881671, "max_line_length": 87, "alphanum_fraction": 0.5667115903, "num_tokens": 4278, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789040926008, "lm_q2_score": 0.7905303236047049, "lm_q1q2_score": 0.6407081503271103}} {"text": "module Integer10 where\r\n\r\nopen import Relation.Binary.PropositionalEquality\r\n as PropEq using (_≡_; refl)\r\n\r\n-- 整数の素朴な定義\r\n--(succ (succ (pred zero))などが有効、という弱点がある)\r\ndata ℤ : Set where\r\n zero : ℤ\r\n succ : ℤ → ℤ\r\n pred : ℤ → ℤ\r\n\r\n-- 加法\r\n_+_ : ℤ → ℤ → ℤ\r\nzero + y = y\r\nsucc x + zero = succ x\r\nsucc x + succ y = succ (succ x + y)\r\nsucc x + pred y = x + y\r\npred x + zero = pred x\r\npred x + succ y = x + y\r\npred x + pred y = pred (pred x + y)\r\n\r\n-- 反数\r\nopposite : ℤ → ℤ\r\nopposite zero = zero\r\nopposite (succ x) = pred (opposite x)\r\nopposite (pred x) = succ (opposite x)\r\n\r\n-- 乗法\r\n_*_ : ℤ → ℤ → ℤ\r\nx * zero = zero\r\nx * succ y = (x * y) + x\r\nx * pred y = (x * y) + (opposite x)\r\n\r\ninfixl 40 _+_\r\ninfixl 60 _*_\r\n\r\n-- (-1) * (-1) = (+1)\r\ntheorem : pred zero * pred zero ≡ succ zero\r\ntheorem = refl\r\n", "meta": {"hexsha": "f2eae749895f76e107941230082fc97703135e5c", "size": 793, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Integer10.agda", "max_stars_repo_name": "righ1113/Agda", "max_stars_repo_head_hexsha": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Integer10.agda", "max_issues_repo_name": "righ1113/Agda", "max_issues_repo_head_hexsha": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Integer10.agda", "max_forks_repo_name": "righ1113/Agda", "max_forks_repo_head_hexsha": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.3414634146, "max_line_length": 50, "alphanum_fraction": 0.5586380832, "num_tokens": 321, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9294404096760998, "lm_q2_score": 0.6893056040203136, "lm_q1q2_score": 0.6406684829926717}} {"text": "------------------------------------------------------------------------------\n-- Comparing styles for equational reasoning\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOT.Common.FOL.Relation.Binary.PreorderReasoning.Comparison where\n\ninfix 7 _≡_\ninfixl 9 _+_\n\ndata _≡_ {A : Set}(x : A) : A → Set where\n refl : x ≡ x\n\ntrans : {A : Set}{x y z : A} → x ≡ y → y ≡ z → x ≡ z\ntrans refl refl = refl\n\npostulate\n ℕ : Set\n zero : ℕ\n _+_ : ℕ → ℕ → ℕ\n +-comm : (m n : ℕ) → m + n ≡ n + m\n +-rightIdentity : (n : ℕ) → n + zero ≡ n\n\nmodule Thesis where\n -- From Ulf's thesis (p. 112).\n\n infix 7 _≃_\n infix 6 chain>_\n infixl 5 _===_by_\n infix 4 _qed\n\n data _≃_ (x y : ℕ) : Set where\n prf : x ≡ y → x ≃ y\n\n chain>_ : (x : ℕ) → x ≃ x\n chain> x = prf refl\n\n _===_by_ : {x y : ℕ} → x ≃ y → (z : ℕ) → y ≡ z → x ≃ z\n prf p === z by q = prf (trans {_} {_} {_} p q)\n\n _qed : {x y : ℕ} → x ≃ y → x ≡ y\n prf p qed = p\n\n -- Example.\n +-leftIdentity : (n : ℕ) → zero + n ≡ n\n +-leftIdentity n =\n chain> zero + n\n === n + zero by +-comm zero n\n === n by +-rightIdentity n\n qed\n\nmodule SL where\n -- Adapted from the Agda standard library 0.8.1 (see\n -- Relation/Binary/PreorderReasoning.agda).\n\n infix 7 _≃_\n infix 4 begin_\n infixr 5 _≡⟨_⟩_\n infix 6 _∎\n\n data _≃_ (x y : ℕ) : Set where\n prf : x ≡ y → x ≃ y\n\n begin_ : {x y : ℕ} → x ≃ y → x ≡ y\n begin prf x≡y = x≡y\n\n _≡⟨_⟩_ : (x : ℕ){y z : ℕ} → x ≡ y → y ≃ z → x ≃ z\n _ ≡⟨ x≡y ⟩ prf y≡z = prf (trans x≡y y≡z)\n\n _∎ : (x : ℕ) → x ≃ x\n _∎ _ = prf refl\n\n -- Example.\n +-leftIdentity : (n : ℕ) → zero + n ≡ n\n +-leftIdentity n =\n begin\n zero + n ≡⟨ +-comm zero n ⟩\n n + zero ≡⟨ +-rightIdentity n ⟩\n n\n ∎\n\nmodule NonWrapper where\n -- A set of combinators without request a wrapper data type (Mu,\n -- S.-C., Ko, H.-S. and Jansson, P. (2009)).\n\n infixr 5 _≡⟨_⟩_\n infix 6 _∎\n\n _≡⟨_⟩_ : (x : ℕ){y z : ℕ} → x ≡ y → y ≡ z → x ≡ z\n _ ≡⟨ x≡y ⟩ y≡z = trans x≡y y≡z\n\n _∎ : (x : ℕ) → x ≡ x\n _∎ _ = refl\n\n -- Example.\n +-leftIdentity : (n : ℕ) → zero + n ≡ n\n +-leftIdentity n = zero + n ≡⟨ +-comm zero n ⟩\n n + zero ≡⟨ +-rightIdentity n ⟩\n n ∎\n\n------------------------------------------------------------------------------\n-- References\n--\n-- Mu, S.-C., Ko, H.-S. and Jansson, P. (2009). Algebra of programming\n-- in Agda: Dependent types for relational program derivation. Journal\n-- of Functional Programming 19.5, pp. 545–579.\n", "meta": {"hexsha": "fe949cdc997178e2299d47b9405593b00f354b06", "size": 2754, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/Common/FOL/Relation/Binary/PreorderReasoning/Comparison.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/FOT/Common/FOL/Relation/Binary/PreorderReasoning/Comparison.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/FOT/Common/FOL/Relation/Binary/PreorderReasoning/Comparison.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 24.8108108108, "max_line_length": 78, "alphanum_fraction": 0.4527959332, "num_tokens": 1040, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673087708699, "lm_q2_score": 0.7879311981328135, "lm_q1q2_score": 0.6404835125228272}} {"text": "\nmodule HasSatisfaction where\n\nopen import OscarPrelude\nopen import Interpretation\n\nrecord HasSatisfaction (A : Set) : Set₁\n where\n field\n _⊨_ : Interpretation → A → Set\n\n _⊭_ : Interpretation → A → Set\n _⊭_ I = ¬_ ∘ I ⊨_\n\nopen HasSatisfaction ⦃ … ⦄ public\n\n{-# DISPLAY HasSatisfaction._⊨_ _ = _⊨_ #-}\n{-# DISPLAY HasSatisfaction._⊭_ _ = _⊭_ #-}\n\ninstance HasSatisfactionList : {A : Set} ⦃ _ : HasSatisfaction A ⦄ → HasSatisfaction $ List A\nHasSatisfaction._⊨_ HasSatisfactionList I [] = ⊤\nHasSatisfaction._⊨_ HasSatisfactionList I (x ∷ xs) = I ⊨ x × I ⊨ xs\n\nmodule _ {A} ⦃ _ : HasSatisfaction A ⦄\n where\n\n ⊨_ : A → Set\n ⊨ x = (I : Interpretation) → I ⊨ x\n\n ⊭_ : A → Set\n ⊭_ = ¬_ ∘ ⊨_\n\nrecord HasDecidableValidation (A : Set) ⦃ _ : HasSatisfaction A ⦄ : Set₁\n where\n field\n ⊨?_ : (x : A) → Dec $ ⊨ x\n\nopen HasDecidableValidation ⦃ … ⦄ public\n\n{-# DISPLAY HasDecidableValidation.⊨?_ _ = ⊨?_ #-}\n\nrecord HasDecidableSatisfaction (A : Set) ⦃ _ : HasSatisfaction A ⦄ : Set₁\n where\n field\n _⊨?_ : (I : Interpretation) → (x : A) → Dec (I ⊨ x)\n\nopen HasDecidableSatisfaction ⦃ … ⦄ public\n\n{-# DISPLAY HasDecidableSatisfaction._⊨?_ _ = _⊨?_ #-}\n", "meta": {"hexsha": "db56e39109dcca412739a3ca91b415974621b48c", "size": 1159, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-1/HasSatisfaction.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-1/HasSatisfaction.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-1/HasSatisfaction.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.18, "max_line_length": 93, "alphanum_fraction": 0.6384814495, "num_tokens": 454, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267830311353, "lm_q2_score": 0.7371581626286833, "lm_q1q2_score": 0.6404627550218214}} {"text": "module sv20.compiler where\n\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_)\n--open import Data.Nat.DivMod using (_/_)\nopen import Data.List using (List; _++_; []; _∷_; head)\nopen import Data.Maybe as DM\nopen DM using (Maybe; just; nothing; maybe; _>>=_; from-just; From-just)\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; sym; trans; cong; subst)\nopen import Data.Product using (∃-syntax) renaming (_,_ to ⟨_,_⟩)\nopen import Function.Base using (_∘_; flip)\n\npattern [_] z = z ∷ []\npattern [_,_] y z = y ∷ z ∷ []\npattern [_,_,_] x y z = x ∷ y ∷ z ∷ []\npattern [_,_,_,_] w x y z = w ∷ x ∷ y ∷ z ∷ []\npattern [_,_,_,_,_] v w x y z = v ∷ w ∷ x ∷ y ∷ z ∷ []\npattern [_,_,_,_,_,_] u v w x y z = u ∷ v ∷ w ∷ x ∷ y ∷ z ∷ []\n\ndata ExOp : Set where\n sum diff prod : ExOp\n\ndata Exp : Set where\n const : ℕ → Exp\n exop : ExOp → Exp → Exp → Exp\n\n--exop sum (const 5) (const 2)\n\nprim-ex : ExOp → ℕ → ℕ → ℕ\nprim-ex sum = _+_\nprim-ex diff = _∸_\nprim-ex prod = _*_\n\ninterpreter : Exp → ℕ\ninterpreter (const ℕ) = ℕ\ninterpreter (exop op x y) = prim-ex op (interpreter x) (interpreter y)\n\n--interpreter (exop sum (const 5) (const 2))\n\ndata BinOp : Set where\n add sub mul : BinOp\n\ndata StackCmd : Set where\n push : ℕ → StackCmd\n binop : BinOp → StackCmd\n\nProgram = List StackCmd\nStack = List ℕ\n\nprim-op : BinOp → ℕ → ℕ → ℕ\nprim-op add = _+_\nprim-op sub = _∸_\nprim-op mul = _*_\n\nrun-vm : Program → Stack → Maybe Stack\nrun-vm [] st = just st\nrun-vm (push n ∷ ps) st = run-vm ps (n ∷ st)\nrun-vm (binop op ∷ ps) (n ∷ m ∷ st) = run-vm ps ((prim-op op n m) ∷ st)\nrun-vm _ _ = nothing\n\nexop-binop : ExOp → BinOp\nexop-binop sum = add\nexop-binop diff = sub\nexop-binop prod = mul\n\ncompile : Exp → Program\ncompile (const n) = [ push n ]\ncompile (exop op x y) = compile y ++ compile x ++ [ binop (exop-binop op) ]\n\n-- (3 - 2) + 6 => + (- 3 2) 6 => \"sum (diff 3 2) 6\"\n_ : compile (exop sum (exop diff (const 3) (const 2)) (const 6))\n ≡ [ push 6 , push 2 , push 3 , binop sub , binop add ]\n_ = refl\n\n_ : run-vm (compile (const 3)) [] ≡ just [ interpreter (const 3) ]\n_ = refl\n\n--run-vm [ push 2 , push 1 , binop add ] []\n--run-vm [ push 1 , binop add ] [ 2 ]\n--run-vm [ binop add ] [ 1 , 2 ]\n_ : (run-vm [ push 1 ] [ 2 ] >>= run-vm [ binop add ])\n ≡ run-vm [ push 1 , binop add ] [ 2 ]\n_ = refl\n\nlemma₁ : ∀ (a b : Program) (s : Stack) → run-vm (a ++ b) s ≡ (run-vm a s >>= run-vm b)\nlemma₁ [] _ _ = refl\nlemma₁ (push n ∷ ps) b s rewrite lemma₁ ps b (n ∷ s) = refl\nlemma₁ (binop _ ∷ ps) b [] = refl\nlemma₁ (binop _ ∷ _) _ (_ ∷ []) = refl\nlemma₁ (binop op ∷ ps) b (n ∷ m ∷ st) rewrite lemma₁ ps b (prim-op op n m ∷ st) = refl\n\nlemma₂ : ∀ {op : ExOp} → prim-op (exop-binop op) ≡ prim-ex op\nlemma₂ {sum} = refl\nlemma₂ {diff} = refl\nlemma₂ {prod} = refl\n\ncompiler-correctness₁ : ∀ {e : Exp} {s : Stack} → run-vm (compile e) s ≡ just (interpreter e ∷ s)\ncompiler-correctness₁ {const n} = refl\ncompiler-correctness₁ {exop op x y} {s}\n rewrite\n-- run-vm (compile (exop op x y)) s ≡ just (interpreter (exop op x y) ∷ s)\n--\n-- run-vm (compile y ++ compile x ++ [ binop (exop-binop op) ]) s ≡ just (prim-ex op (interpreter x) (interpreter y) ∷ s)\n lemma₁ (compile y) (compile x ++ [ binop (exop-binop op) ]) s\n-- (run-vm (compile y) s >>= run-vm (compile x ++ [ binop (exop-binop op) ])) ≡ just (prim-ex op (interpreter x) (interpreter y) ∷ s)\n | compiler-correctness₁ {y} {s}\n-- (just (interpreter y ∷ s) >>= run-vm (compile x ++ [ binop (exop-binop op) ])) ≡ just (prim-ex op (interpreter x) (interpreter y) ∷ s)\n-- run-vm (compile x ++ [ binop (exop-binop op) ]) (interpreter y ∷ s) ≡ just (prim-ex op (interpreter x) (interpreter y) ∷ s)\n | lemma₁ (compile x) [ binop (exop-binop op) ] (interpreter y ∷ s)\n-- (run-vm (compile x) (interpreter y ∷ s) >>= run-vm [ binop (exop-binop op) ]) ≡ just (prim-ex op (interpreter x) (interpreter y) ∷ s)\n | compiler-correctness₁ {x} {interpreter y ∷ s}\n-- (just (interpreter x ∷ interpreter y ∷ s) >>= run-vm [ binop (exop-binop op) ]) ≡ just (prim-ex op (interpreter x) (interpreter y) ∷ s)\n-- just (prim-op (exop-binop op) (interpreter x) (interpreter y) ∷ s) ≡ just (prim-ex op (interpreter x) (interpreter y) ∷ s)\n | lemma₂ {op}\n = refl\n\ncompiler-correctness : ∀ (e : Exp) → run-vm (compile e) [] ≡ just [ interpreter e ]\ncompiler-correctness e = compiler-correctness₁ {e} {[]}\n\n-- Which algorithm is it using when executed \"interpreter\" or \"compile then\n-- run-vm\"?\n-- Well, if I understand correctly. \"from-just\" will return the value\n-- contained in \"just\" and \"subst\" will pass the values untouched. Which\n-- would mean that there is an associated cost in proving stuff but the code\n-- that is being used is \"compile then run-vm\"\nrun-vm∘compile : Exp → Maybe ℕ\nrun-vm∘compile e =\n let\n justln = from-just (run-vm (compile e) [])\n list = subst From-just (compiler-correctness e) justln\n in head list\n\n_ : run-vm∘compile (const 5) ≡ just 5\n_ = refl\n\nreduce : {A : Set} → Maybe (List A) → Maybe A\nreduce (just (x ∷ _)) = just x\nreduce _ = nothing\n\n_ : reduce (just [ 5 ]) ≡ just 5\n_ = refl\n\n\n-- Look, it is possible to execute compile and run-vm and get an unwrapped result\n-- For an even prettier proof look at the end of the file\nrun-vm∘compile` : Exp → ℕ\nrun-vm∘compile` e =\n let\n computing = reduce (run-vm (compile e) [])\n justn = from-just computing\n redruncomp≡jinter = cong reduce (compiler-correctness e) -- reduce (run-vm (compile e) []) ≡ just (interpreter e)\n in subst From-just redruncomp≡jinter justn\n\n_ : run-vm∘compile` (const 5) ≡ 5\n_ = refl\n\n---- So. I wanted to generalise the approach used before, but I'm stuck. Agda\n---- seems not able to infer some variable.\n---- It's because it is never using 'g', I think\n---- Ans: NO. IT WAS BECAUSE x WAS IMPLICIT IN eq\n--\n--unwrap : {A B : Set}\n-- → {g : A → B}\n-- → (f : A → Maybe (List B))\n-- → ({x : A} → f x ≡ just [ g x ]) -- <- This was the problem! It should be explicit!\n-- --------------------------------\n-- → A → B -- Computed using f\n--unwrap {A} {B} {g} f eq x =\n-- let\n-- computing = reduce (f x) -- type: Maybe B\n-- justb = from-just computing -- type: From-just (f x)\n-- in subst From-just new-eq justb -- type: B -- thanks to the magic of From-just\n--\n-- where\n-- new-eq : {x : A} → reduce (f x) ≡ just (g x)\n-- new-eq {x} rewrite eq {x} = refl\n--\n---- Why doesn't this work!? Ans: See above or below\n----run-vm∘compile`` : Exp → ℕ\n----run-vm∘compile`` = unwrap {Exp} {ℕ}\n---- {interpreter}\n---- (λ e → run-vm (compile e) [])\n---- compiler-correctness\n\nunwrap : {A B : Set} {g : A → B}\n → (f : A → Maybe (List B))\n → ((x : A) → f x ≡ just [ g x ])\n --------------------------------\n → A → B -- Computed using f not g (g might still be run to prove the property correct)\nunwrap f eq x =\n let\n -- Proof: f x ≡ just [ g x ]\n fx≡mlgx = eq x\n -- New proof: reduce (f x) ≡ just (g x)\n redfx≡gx = cong reduce {x = f x} fx≡mlgx\n compute = reduce (f x) -- type: Maybe B\n justredfx = from-just compute -- type: From-just (reduce (f x)) -- lifting to the type level, so we can prove stuff\n in subst From-just redfx≡gx justredfx -- type: From-just (just (g x)) which is the same as `B` -- thanks to the magic of From-just\n\n--from-just (just 3) -- evaluates to: 3\n-- -- with type: From-just (just 3)\n-- -- which evaluates to: ℕ\n-- ie,\n-- from-just (just 3) : From-just (just 3)\n-- from-just (just 3) : ℕ\n-- 3 : ℕ\n-- 3 : From-just (just 3)\n\n_ : from-just (just 3) ≡ 3\n_ = refl\n\n_ : From-just (just 3) ≡ ℕ\n_ = refl\n\n_ : Set\n_ = From-just (just 3)\n\n_ : From-just (just 3) -- same as ℕ\n_ = 3\n_ = from-just (just 3)\n_ = 2 -- This is an ℕ too\n\nrun-vm∘compile`` : Exp → ℕ\nrun-vm∘compile`` = unwrap ((flip run-vm []) ∘ compile) compiler-correctness\n--run-vm∘compile`` = unwrap (λ e → run-vm (compile e) []) compiler-correctness\n\n--LESSON LEARNT:\n--Don't use implicit paramaters unless it makes for a clearer proof.\n--Always use explicit parameters and make them implicit as you use the\n--functions in more places (without breaking anything)\n\n_ : run-vm∘compile`` (const 5) ≡ 5\n_ = refl\n\nI-am-a-number : ℕ\nI-am-a-number = run-vm∘compile`` (exop sum (exop diff (const 3) (const 2)) (const 20))\n", "meta": {"hexsha": "d6422fad36f66537dc6ce23863cf7b649f12dfa9", "size": 8470, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "proglangs-learning/Agda/sv20/compiler.agda", "max_stars_repo_name": "helq/old_code", "max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "proglangs-learning/Agda/sv20/compiler.agda", "max_issues_repo_name": "helq/old_code", "max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z", "max_forks_repo_path": "proglangs-learning/Agda/sv20/compiler.agda", "max_forks_repo_name": "helq/old_code", "max_forks_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.7383966245, "max_line_length": 141, "alphanum_fraction": 0.5863046045, "num_tokens": 2966, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267830311354, "lm_q2_score": 0.7371581510799253, "lm_q1q2_score": 0.6404627449879512}} {"text": "\nopen import Agda.Builtin.Nat\nopen import Agda.Builtin.Equality\n\nrecord Eq (A : Set) : Set₁ where\n field\n _≈_ : A → A → Set\n\nopen Eq {{...}} public\n\nrecord Setoid : Set₁ where\n field\n ∣_∣ : Set\n {{eq}} : Eq ∣_∣\n\nopen Setoid public\n\ninstance\n EqNat : Eq Nat\n _≈_ {{EqNat}} = _≡_\n\nNatSetoid : Setoid\n∣ NatSetoid ∣ = Nat\n\nthm : (x : ∣ NatSetoid ∣) → x ≈ x\nthm x = refl\n", "meta": {"hexsha": "61038f9b28f64be1a6cecce47cf919caa7239286", "size": 382, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue2288.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue2288.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue2288.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 14.1481481481, "max_line_length": 33, "alphanum_fraction": 0.5916230366, "num_tokens": 157, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8652240756264639, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.6404166831566227}} {"text": "------------------------------------------------------------------------\n-- Commutative semirings with some additional structure (\"almost\"\n-- commutative rings), used by the ring solver\n------------------------------------------------------------------------\n\nmodule Algebra.RingSolver.AlmostCommutativeRing where\n\nopen import Relation.Binary\nopen import Algebra\nopen import Algebra.Structures\nopen import Algebra.FunctionProperties\nopen import Algebra.Morphism\nopen import Data.Function\n\n------------------------------------------------------------------------\n-- Definitions\n\nrecord IsAlmostCommutativeRing {A} (_≈_ : Rel A)\n (_+_ _*_ : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Set where\n field\n isCommutativeSemiring : IsCommutativeSemiring _≈_ _+_ _*_ 0# 1#\n -‿pres-≈ : -_ Preserves _≈_ ⟶ _≈_\n -‿*-distribˡ : ∀ x y → ((- x) * y) ≈ (- (x * y))\n -‿+-comm : ∀ x y → ((- x) + (- y)) ≈ (- (x + y))\n\n open IsCommutativeSemiring isCommutativeSemiring public\n\nrecord AlmostCommutativeRing : Set₁ where\n infix 8 -_\n infixl 7 _*_\n infixl 6 _+_\n infix 4 _≈_\n field\n carrier : Set\n _≈_ : Rel carrier\n _+_ : Op₂ carrier\n _*_ : Op₂ carrier\n -_ : Op₁ carrier\n 0# : carrier\n 1# : carrier\n isAlmostCommutativeRing :\n IsAlmostCommutativeRing _≈_ _+_ _*_ -_ 0# 1#\n\n open IsAlmostCommutativeRing isAlmostCommutativeRing public\n\n commutativeSemiring : CommutativeSemiring\n commutativeSemiring =\n record { isCommutativeSemiring = isCommutativeSemiring }\n\n open CommutativeSemiring commutativeSemiring public\n using ( setoid\n ; +-semigroup; +-monoid; +-commutativeMonoid\n ; *-semigroup; *-monoid; *-commutativeMonoid\n ; semiring\n )\n\n rawRing : RawRing\n rawRing = record\n { _≈_ = _≈_\n ; _+_ = _+_\n ; _*_ = _*_\n ; -_ = -_\n ; 0# = 0#\n ; 1# = 1#\n }\n\n------------------------------------------------------------------------\n-- Homomorphisms\n\n_-Raw-AlmostCommutative⟶_ : RawRing → AlmostCommutativeRing → Set\nfrom -Raw-AlmostCommutative⟶ to = from -RawRing⟶ rawRing to\n where open AlmostCommutativeRing\n\n-raw-almostCommutative⟶\n : ∀ r →\n AlmostCommutativeRing.rawRing r -Raw-AlmostCommutative⟶ r\n-raw-almostCommutative⟶ r = record\n { ⟦_⟧ = id\n ; +-homo = λ _ _ → refl\n ; *-homo = λ _ _ → refl\n ; -‿homo = λ _ → refl\n ; 0-homo = refl\n ; 1-homo = refl\n }\n where open AlmostCommutativeRing r\n\n------------------------------------------------------------------------\n-- Conversions\n\n-- Commutative rings are almost commutative rings.\n\nfromCommutativeRing : CommutativeRing → AlmostCommutativeRing\nfromCommutativeRing cr = record\n { isAlmostCommutativeRing = record\n { isCommutativeSemiring = isCommutativeSemiring\n ; -‿pres-≈ = -‿pres-≈\n ; -‿*-distribˡ = -‿*-distribˡ\n ; -‿+-comm = -‿∙-comm\n }\n }\n where\n open CommutativeRing cr\n import Algebra.Props.Ring as R; open R ring\n import Algebra.Props.AbelianGroup as AG; open AG +-abelianGroup\n\n-- Commutative semirings can be viewed as almost commutative rings by\n-- using identity as the \"almost negation\".\n\nfromCommutativeSemiring : CommutativeSemiring → AlmostCommutativeRing\nfromCommutativeSemiring cs = record\n { -_ = id\n ; isAlmostCommutativeRing = record\n { isCommutativeSemiring = isCommutativeSemiring\n ; -‿pres-≈ = id\n ; -‿*-distribˡ = λ _ _ → refl\n ; -‿+-comm = λ _ _ → refl\n }\n }\n where open CommutativeSemiring cs\n", "meta": {"hexsha": "6e08f30d72158334e95ca4efc54d95e92bd982db", "size": 3737, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Algebra/RingSolver/AlmostCommutativeRing.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Algebra/RingSolver/AlmostCommutativeRing.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Algebra/RingSolver/AlmostCommutativeRing.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 31.1416666667, "max_line_length": 72, "alphanum_fraction": 0.5453572384, "num_tokens": 1098, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.865224072151174, "lm_q2_score": 0.7401743505760728, "lm_q1q2_score": 0.6404166657072804}} {"text": "\n{--\n-- normalize a finite type to (1 + (1 + (1 + ... + (1 + 0) ... )))\n-- a bunch of ones ending with zero with left biased + in between\n\ntoℕ : U → ℕ\ntoℕ ZERO = 0\ntoℕ ONE = 1\ntoℕ (PLUS t₁ t₂) = toℕ t₁ + toℕ t₂\ntoℕ (TIMES t₁ t₂) = toℕ t₁ * toℕ t₂\n\nfromℕ : ℕ → U\nfromℕ 0 = ZERO\nfromℕ (suc n) = PLUS ONE (fromℕ n)\n\nnormalℕ : U → U\nnormalℕ = fromℕ ∘ toℕ\n\n-- invert toℕ: give t and n such that toℕ t = n, return constraints on components of t\n\nreflectPlusZero : {m n : ℕ} → (m + n ≡ 0) → m ≡ 0 × n ≡ 0\nreflectPlusZero {0} {0} refl = (refl , refl)\nreflectPlusZero {0} {suc n} ()\nreflectPlusZero {suc m} {0} ()\nreflectPlusZero {suc m} {suc n} ()\n\n-- nbe\n\nnbe : {t₁ t₂ : U} → (p : toℕ t₁ ≡ toℕ t₂) → (⟦ t₁ ⟧ → ⟦ t₂ ⟧) → (t₁ ⟷ t₂)\nnbe {ZERO} {ZERO} refl f = id⟷\nnbe {ZERO} {ONE} ()\nnbe {ZERO} {PLUS t₁ t₂} p f = {!!} \nnbe {ZERO} {TIMES t₂ t₃} p f = {!!}\nnbe {ONE} {ZERO} ()\nnbe {ONE} {ONE} p f = id⟷\nnbe {ONE} {PLUS t₂ t₃} p f = {!!}\nnbe {ONE} {TIMES t₂ t₃} p f = {!!}\nnbe {PLUS t₁ t₂} {ZERO} p f = {!!}\nnbe {PLUS t₁ t₂} {ONE} p f = {!!}\nnbe {PLUS t₁ t₂} {PLUS t₃ t₄} p f = {!!}\nnbe {PLUS t₁ t₂} {TIMES t₃ t₄} p f = {!!}\nnbe {TIMES t₁ t₂} {ZERO} p f = {!!}\nnbe {TIMES t₁ t₂} {ONE} p f = {!!}\nnbe {TIMES t₁ t₂} {PLUS t₃ t₄} p f = {!!}\nnbe {TIMES t₁ t₂} {TIMES t₃ t₄} p f = {!!} \n\n-- build a combinator that does the normalization\n\nassocrU : {m : ℕ} (n : ℕ) → (PLUS (fromℕ n) (fromℕ m)) ⟷ fromℕ (n + m)\nassocrU 0 = unite₊\nassocrU (suc n) = assocr₊ ◎ (id⟷ ⊕ assocrU n)\n\ndistrU : (m : ℕ) {n : ℕ} → TIMES (fromℕ m) (fromℕ n) ⟷ fromℕ (m * n)\ndistrU 0 = distz\ndistrU (suc n) {m} = dist ◎ (unite⋆ ⊕ distrU n) ◎ assocrU m\n\nnormalU : (t : U) → t ⟷ normalℕ t\nnormalU ZERO = id⟷\nnormalU ONE = uniti₊ ◎ swap₊\nnormalU (PLUS t₁ t₂) = (normalU t₁ ⊕ normalU t₂) ◎ assocrU (toℕ t₁)\nnormalU (TIMES t₁ t₂) = (normalU t₁ ⊗ normalU t₂) ◎ distrU (toℕ t₁)\n\n-- a few lemmas\n\nfromℕplus : {m n : ℕ} → fromℕ (m + n) ⟷ PLUS (fromℕ m) (fromℕ n)\nfromℕplus {0} {n} = \n fromℕ n\n ⟷⟨ uniti₊ ⟩\n PLUS ZERO (fromℕ n) □\nfromℕplus {suc m} {n} = \n fromℕ (suc (m + n))\n ⟷⟨ id⟷ ⟩ \n PLUS ONE (fromℕ (m + n))\n ⟷⟨ id⟷ ⊕ fromℕplus {m} {n} ⟩ \n PLUS ONE (PLUS (fromℕ m) (fromℕ n))\n ⟷⟨ assocl₊ ⟩ \n PLUS (PLUS ONE (fromℕ m)) (fromℕ n)\n ⟷⟨ id⟷ ⟩ \n PLUS (fromℕ (suc m)) (fromℕ n) □\n\nnormalℕswap : {t₁ t₂ : U} → normalℕ (PLUS t₁ t₂) ⟷ normalℕ (PLUS t₂ t₁)\nnormalℕswap {t₁} {t₂} = \n fromℕ (toℕ t₁ + toℕ t₂) \n ⟷⟨ fromℕplus {toℕ t₁} {toℕ t₂} ⟩\n PLUS (normalℕ t₁) (normalℕ t₂)\n ⟷⟨ swap₊ ⟩\n PLUS (normalℕ t₂) (normalℕ t₁)\n ⟷⟨ ! (fromℕplus {toℕ t₂} {toℕ t₁}) ⟩\n fromℕ (toℕ t₂ + toℕ t₁) □\n\nassocrUS : {m : ℕ} {t : U} → PLUS t (fromℕ m) ⟷ fromℕ (toℕ t + m)\nassocrUS {m} {ZERO} = unite₊\nassocrUS {m} {ONE} = id⟷\nassocrUS {m} {t} = \n PLUS t (fromℕ m)\n ⟷⟨ normalU t ⊕ id⟷ ⟩\n PLUS (normalℕ t) (fromℕ m)\n ⟷⟨ ! fromℕplus ⟩\n fromℕ (toℕ t + m) □\n\n-- convert each combinator to a normal form\n\nnormal⟷ : {t₁ t₂ : U} → (c₁ : t₁ ⟷ t₂) → \n Σ[ c₂ ∈ normalℕ t₁ ⟷ normalℕ t₂ ] (c₁ ⇔ (normalU t₁ ◎ c₂ ◎ (! (normalU t₂))))\nnormal⟷ {PLUS ZERO t} {.t} unite₊ = \n (id⟷ , \n (unite₊\n ⇔⟨ idr◎r ⟩\n unite₊ ◎ id⟷\n ⇔⟨ resp◎⇔ id⇔ linv◎r ⟩\n unite₊ ◎ (normalU t ◎ (! (normalU t)))\n ⇔⟨ assoc◎l ⟩\n (unite₊ ◎ normalU t) ◎ (! (normalU t))\n ⇔⟨ resp◎⇔ unitel₊⇔ id⇔ ⟩\n ((id⟷ ⊕ normalU t) ◎ unite₊) ◎ (! (normalU t))\n ⇔⟨ resp◎⇔ id⇔ idl◎r ⟩\n ((id⟷ ⊕ normalU t) ◎ unite₊) ◎ (id⟷ ◎ (! (normalU t)))\n ⇔⟨ id⇔ ⟩\n normalU (PLUS ZERO t) ◎ (id⟷ ◎ (! (normalU t))) ▤))\nnormal⟷ {t} {PLUS ZERO .t} uniti₊ = \n (id⟷ , \n (uniti₊ \n ⇔⟨ idl◎r ⟩ \n id⟷ ◎ uniti₊\n ⇔⟨ resp◎⇔ linv◎r id⇔ ⟩ \n (normalU t ◎ (! (normalU t))) ◎ uniti₊\n ⇔⟨ assoc◎r ⟩ \n normalU t ◎ ((! (normalU t)) ◎ uniti₊)\n ⇔⟨ resp◎⇔ id⇔ unitir₊⇔ ⟩ \n normalU t ◎ (uniti₊ ◎ (id⟷ ⊕ (! (normalU t))))\n ⇔⟨ resp◎⇔ id⇔ idl◎r ⟩ \n normalU t ◎ (id⟷ ◎ (uniti₊ ◎ (id⟷ ⊕ (! (normalU t)))))\n ⇔⟨ id⇔ ⟩ \n normalU t ◎ (id⟷ ◎ (! ((id⟷ ⊕ (normalU t)) ◎ unite₊)))\n ⇔⟨ id⇔ ⟩ \n normalU t ◎ (id⟷ ◎ (! (normalU (PLUS ZERO t)))) ▤))\nnormal⟷ {PLUS ZERO t₂} {PLUS .t₂ ZERO} swap₊ = \n (normalℕswap {ZERO} {t₂} , \n (swap₊ \n ⇔⟨ {!!} ⟩\n (unite₊ ◎ normalU t₂) ◎ \n (normalℕswap {ZERO} {t₂} ◎ ((! (assocrU (toℕ t₂))) ◎ (! (normalU t₂) ⊕ id⟷)))\n ⇔⟨ resp◎⇔ unitel₊⇔ id⇔ ⟩\n ((id⟷ ⊕ normalU t₂) ◎ unite₊) ◎ \n (normalℕswap {ZERO} {t₂} ◎ ((! (assocrU (toℕ t₂))) ◎ (! (normalU t₂) ⊕ id⟷)))\n ⇔⟨ id⇔ ⟩\n normalU (PLUS ZERO t₂) ◎ (normalℕswap {ZERO} {t₂} ◎ (! (normalU (PLUS t₂ ZERO)))) ▤))\nnormal⟷ {PLUS ONE t₂} {PLUS .t₂ ONE} swap₊ = \n (normalℕswap {ONE} {t₂} , \n (swap₊ \n ⇔⟨ {!!} ⟩\n ((normalU ONE ⊕ normalU t₂) ◎ assocrU (toℕ ONE)) ◎ \n (normalℕswap {ONE} {t₂} ◎ ((! (assocrU (toℕ t₂))) ◎ (! (normalU t₂) ⊕ ! (normalU ONE))))\n ⇔⟨ id⇔ ⟩\n normalU (PLUS ONE t₂) ◎ (normalℕswap {ONE} {t₂} ◎ (! (normalU (PLUS t₂ ONE)))) ▤))\nnormal⟷ {PLUS t₁ t₂} {PLUS .t₂ .t₁} swap₊ = \n (normalℕswap {t₁} {t₂} , \n (swap₊ \n ⇔⟨ {!!} ⟩\n ((normalU t₁ ⊕ normalU t₂) ◎ assocrU (toℕ t₁)) ◎ \n (normalℕswap {t₁} {t₂} ◎ ((! (assocrU (toℕ t₂))) ◎ (! (normalU t₂) ⊕ ! (normalU t₁))))\n ⇔⟨ id⇔ ⟩\n normalU (PLUS t₁ t₂) ◎ (normalℕswap {t₁} {t₂} ◎ (! (normalU (PLUS t₂ t₁)))) ▤))\nnormal⟷ {PLUS t₁ (PLUS t₂ t₃)} {PLUS (PLUS .t₁ .t₂) .t₃} assocl₊ = {!!}\nnormal⟷ {PLUS (PLUS t₁ t₂) t₃} {PLUS .t₁ (PLUS .t₂ .t₃)} assocr₊ = {!!}\nnormal⟷ {TIMES ONE t} {.t} unite⋆ = {!!} \nnormal⟷ {t} {TIMES ONE .t} uniti⋆ = {!!}\nnormal⟷ {TIMES t₁ t₂} {TIMES .t₂ .t₁} swap⋆ = {!!}\nnormal⟷ {TIMES t₁ (TIMES t₂ t₃)} {TIMES (TIMES .t₁ .t₂) .t₃} assocl⋆ = {!!}\nnormal⟷ {TIMES (TIMES t₁ t₂) t₃} {TIMES .t₁ (TIMES .t₂ .t₃)} assocr⋆ = {!!}\nnormal⟷ {TIMES ZERO t} {ZERO} distz = {!!}\nnormal⟷ {ZERO} {TIMES ZERO t} factorz = {!!}\nnormal⟷ {TIMES (PLUS t₁ t₂) t₃} {PLUS (TIMES .t₁ .t₃) (TIMES .t₂ .t₃)} dist = {!!}\nnormal⟷ {PLUS (TIMES .t₁ .t₃) (TIMES .t₂ .t₃)} {TIMES (PLUS t₁ t₂) t₃} factor = {!!}\nnormal⟷ {t} {.t} id⟷ = \n (id⟷ , \n (id⟷ \n ⇔⟨ linv◎r ⟩\n normalU t ◎ (! (normalU t))\n ⇔⟨ resp◎⇔ id⇔ idl◎r ⟩\n normalU t ◎ (id⟷ ◎ (! (normalU t))) ▤))\nnormal⟷ {t₁} {t₃} (_◎_ {t₂ = t₂} c₁ c₂) = {!!}\nnormal⟷ {PLUS t₁ t₂} {PLUS t₃ t₄} (c₁ ⊕ c₂) = {!!}\nnormal⟷ {TIMES t₁ t₂} {TIMES t₃ t₄} (c₁ ⊗ c₂) = {!!}\n\n-- if c₁ c₂ : t₁ ⟷ t₂ and c₁ ∼ c₂ then we want a canonical combinator\n-- normalℕ t₁ ⟷ normalℕ t₂. If we have that then we should be able to\n-- decide whether c₁ ∼ c₂ by normalizing and looking at the canonical\n-- combinator.\n\n-- Use ⇔ to normalize a path\n\n{-# NO_TERMINATION_CHECK #-}\nnormalize : {t₁ t₂ : U} → (c₁ : t₁ ⟷ t₂) → Σ[ c₂ ∈ t₁ ⟷ t₂ ] (c₁ ⇔ c₂)\nnormalize unite₊ = (unite₊ , id⇔)\nnormalize uniti₊ = (uniti₊ , id⇔)\nnormalize swap₊ = (swap₊ , id⇔)\nnormalize assocl₊ = (assocl₊ , id⇔)\nnormalize assocr₊ = (assocr₊ , id⇔)\nnormalize unite⋆ = (unite⋆ , id⇔)\nnormalize uniti⋆ = (uniti⋆ , id⇔)\nnormalize swap⋆ = (swap⋆ , id⇔)\nnormalize assocl⋆ = (assocl⋆ , id⇔)\nnormalize assocr⋆ = (assocr⋆ , id⇔)\nnormalize distz = (distz , id⇔)\nnormalize factorz = (factorz , id⇔)\nnormalize dist = (dist , id⇔)\nnormalize factor = (factor , id⇔)\nnormalize id⟷ = (id⟷ , id⇔)\nnormalize (c₁ ◎ c₂) with normalize c₁ | normalize c₂\n... | (c₁' , α) | (c₂' , β) = {!!} \nnormalize (c₁ ⊕ c₂) with normalize c₁ | normalize c₂\n... | (c₁' , α) | (c₂₁ ⊕ c₂₂ , β) = \n (assocl₊ ◎ ((c₁' ⊕ c₂₁) ⊕ c₂₂) ◎ assocr₊ , trans⇔ (resp⊕⇔ α β) assoc⊕l)\n... | (c₁' , α) | (c₂' , β) = (c₁' ⊕ c₂' , resp⊕⇔ α β)\nnormalize (c₁ ⊗ c₂) with normalize c₁ | normalize c₂\n... | (c₁₁ ⊕ c₁₂ , α) | (c₂' , β) = \n (dist ◎ ((c₁₁ ⊗ c₂') ⊕ (c₁₂ ⊗ c₂')) ◎ factor , \n trans⇔ (resp⊗⇔ α β) dist⇔)\n... | (c₁' , α) | (c₂₁ ⊗ c₂₂ , β) = \n (assocl⋆ ◎ ((c₁' ⊗ c₂₁) ⊗ c₂₂) ◎ assocr⋆ , trans⇔ (resp⊗⇔ α β) assoc⊗l)\n... | (c₁' , α) | (c₂' , β) = (c₁' ⊗ c₂' , resp⊗⇔ α β)\n\n\n\nrecord Permutation (t t' : U) : Set where\n field\n t₀ : U -- no occurrences of TIMES .. (TIMES .. ..)\n phase₀ : t ⟷ t₀ \n t₁ : U -- no occurrences of TIMES (PLUS .. ..)\n phase₁ : t₀ ⟷ t₁\n t₂ : U -- no occurrences of TIMES\n phase₂ : t₁ ⟷ t₂\n t₃ : U -- no nested left PLUS, all PLUS of form PLUS simple (PLUS ...)\n phase₃ : t₂ ⟷ t₃\n t₄ : U -- no occurrences PLUS ZERO\n phase₄ : t₃ ⟷ t₄\n t₅ : U -- do actual permutation using swapij\n phase₅ : t₄ ⟷ t₅\n rest : t₅ ⟷ t' -- blah blah\n\np◎id∼p : ∀ {t₁ t₂} {c : t₁ ⟷ t₂} → (c ◎ id⟷ ∼ c)\np◎id∼p {t₁} {t₂} {c} v = \n (begin (proj₁ (perm2path (c ◎ id⟷) v))\n ≡⟨ {!!} ⟩\n (proj₁ (perm2path id⟷ (proj₁ (perm2path c v))))\n ≡⟨ {!!} ⟩\n (proj₁ (perm2path c v)) ∎)\n\n-- perm2path {t} id⟷ v = (v , edge •[ t , v ] •[ t , v ])\n\n--perm2path (_◎_ {t₁} {t₂} {t₃} c₁ c₂) v₁ with perm2path c₁ v₁\n--... | (v₂ , p) with perm2path c₂ v₂\n--... | (v₃ , q) = (v₃ , seq p q) \n\n\n-- Equivalences between paths leading to 2path structure\n-- Two paths are the same if they go through the same points\n\n_∼_ : ∀ {t₁ t₂ v₁ v₂} → \n (p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) → \n (q : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) → \n Set\n(edge ._ ._) ∼ (edge ._ ._) = ⊤ \n(edge ._ ._) ∼ (seq p q) = {!!}\n(edge ._ ._) ∼ (left p) = {!!}\n(edge ._ ._) ∼ (right p) = {!!}\n(edge ._ ._) ∼ (par p q) = {!!}\nseq p p₁ ∼ edge ._ ._ = {!!}\nseq p₁ p ∼ seq q q₁ = {!!}\nseq p p₁ ∼ left q = {!!}\nseq p p₁ ∼ right q = {!!}\nseq p p₁ ∼ par q q₁ = {!!}\nleft p ∼ edge ._ ._ = {!!}\nleft p ∼ seq q q₁ = {!!}\nleft p ∼ left q = {!!}\nright p ∼ edge ._ ._ = {!!}\nright p ∼ seq q q₁ = {!!}\nright p ∼ right q = {!!}\npar p p₁ ∼ edge ._ ._ = {!!}\npar p p₁ ∼ seq q q₁ = {!!}\npar p p₁ ∼ par q q₁ = {!!} \n\n-- Equivalences between paths leading to 2path structure\n-- Following the HoTT approach two paths are considered the same if they\n-- map the same points to equal points\n\ninfix 4 _∼_ \n\n_∼_ : ∀ {t₁ t₂ v₁ v₂ v₂'} → \n (p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) → \n (q : Path •[ t₁ , v₁ ] •[ t₂ , v₂' ]) → \n Set\n_∼_ {t₁} {t₂} {v₁} {v₂} {v₂'} p q = (v₂ ≡ v₂')\n\n\n-- Lemma 2.4.2\n\np∼p : {t₁ t₂ : U} {p : Path t₁ t₂} → p ∼ p\np∼p {p = path c} _ = refl\n\np∼q→q∼p : {t₁ t₂ : U} {p q : Path t₁ t₂} → (p ∼ q) → (q ∼ p)\np∼q→q∼p {p = path c₁} {q = path c₂} α v = sym (α v) \n\np∼q∼r→p∼r : {t₁ t₂ : U} {p q r : Path t₁ t₂} → \n (p ∼ q) → (q ∼ r) → (p ∼ r) \np∼q∼r→p∼r {p = path c₁} {q = path c₂} {r = path c₃} α β v = trans (α v) (β v) \n\n-- lift inverses and compositions to paths\n\ninv : {t₁ t₂ : U} → Path t₁ t₂ → Path t₂ t₁\ninv (path c) = path (! c)\n\ninfixr 10 _●_\n\n_●_ : {t₁ t₂ t₃ : U} → Path t₁ t₂ → Path t₂ t₃ → Path t₁ t₃\npath c₁ ● path c₂ = path (c₁ ◎ c₂)\n\n-- Lemma 2.1.4\n\np∼p◎id : {t₁ t₂ : U} {p : Path t₁ t₂} → p ∼ p ● path id⟷\np∼p◎id {t₁} {t₂} {path c} v = \n (begin (perm2path c v)\n ≡⟨ refl ⟩\n (perm2path c (perm2path id⟷ v))\n ≡⟨ refl ⟩\n (perm2path (c ◎ id⟷) v) ∎)\n\np∼id◎p : {t₁ t₂ : U} {p : Path t₁ t₂} → p ∼ path id⟷ ● p\np∼id◎p {t₁} {t₂} {path c} v = \n (begin (perm2path c v)\n ≡⟨ refl ⟩\n (perm2path id⟷ (perm2path c v))\n ≡⟨ refl ⟩\n (perm2path (id⟷ ◎ c) v) ∎)\n\n!p◎p∼id : {t₁ t₂ : U} {p : Path t₁ t₂} → (inv p) ● p ∼ path id⟷\n!p◎p∼id {t₁} {t₂} {path c} v = \n (begin (perm2path ((! c) ◎ c) v)\n ≡⟨ refl ⟩\n (perm2path c (perm2path (! c) v))\n ≡⟨ invr {t₁} {t₂} {c} {v} ⟩\n (perm2path id⟷ v) ∎)\n\np◎!p∼id : {t₁ t₂ : U} {p : Path t₁ t₂} → p ● (inv p) ∼ path id⟷\np◎!p∼id {t₁} {t₂} {path c} v = \n (begin (perm2path (c ◎ (! c)) v)\n ≡⟨ refl ⟩\n (perm2path (! c) (perm2path c v))\n ≡⟨ invl {t₁} {t₂} {c} {v} ⟩\n (perm2path id⟷ v) ∎)\n\n\n!!p∼p : {t₁ t₂ : U} {p : Path t₁ t₂} → inv (inv p) ∼ p\n!!p∼p {t₁} {t₂} {path c} v = \n begin (perm2path (! (! c)) v\n ≡⟨ cong (λ x → perm2path x v) (!! {c = c}) ⟩ \n perm2path c v ∎)\n\nassoc◎ : {t₁ t₂ t₃ t₄ : U} {p : Path t₁ t₂} {q : Path t₂ t₃} {r : Path t₃ t₄} → \n p ● (q ● r) ∼ (p ● q) ● r\nassoc◎ {t₁} {t₂} {t₃} {t₄} {path c₁} {path c₂} {path c₃} v = \n begin (perm2path (c₁ ◎ (c₂ ◎ c₃)) v \n ≡⟨ refl ⟩\n perm2path (c₂ ◎ c₃) (perm2path c₁ v)\n ≡⟨ refl ⟩\n perm2path c₃ (perm2path c₂ (perm2path c₁ v))\n ≡⟨ refl ⟩\n perm2path c₃ (perm2path (c₁ ◎ c₂) v)\n ≡⟨ refl ⟩\n perm2path ((c₁ ◎ c₂) ◎ c₃) v ∎)\n\nresp◎ : {t₁ t₂ t₃ : U} {p q : Path t₁ t₂} {r s : Path t₂ t₃} → \n p ∼ q → r ∼ s → (p ● r) ∼ (q ● s)\nresp◎ {t₁} {t₂} {t₃} {path c₁} {path c₂} {path c₃} {path c₄} α β v = \n begin (perm2path (c₁ ◎ c₃) v \n ≡⟨ refl ⟩\n perm2path c₃ (perm2path c₁ v)\n ≡⟨ cong (λ x → perm2path c₃ x) (α v) ⟩\n perm2path c₃ (perm2path c₂ v)\n ≡⟨ β (perm2path c₂ v) ⟩ \n perm2path c₄ (perm2path c₂ v)\n ≡⟨ refl ⟩ \n perm2path (c₂ ◎ c₄) v ∎)\n\n-- Recall that two perminators are the same if they denote the same\n-- permutation; in that case there is a 2path between them in the relevant\n-- path space\n\ndata _⇔_ {t₁ t₂ : U} : Path t₁ t₂ → Path t₁ t₂ → Set where\n 2path : {p q : Path t₁ t₂} → (p ∼ q) → (p ⇔ q)\n\n-- Examples\n\np q r : Path BOOL BOOL\np = path id⟷\nq = path swap₊\nr = path (swap₊ ◎ id⟷)\n\nα : q ⇔ r\nα = 2path (p∼p◎id {p = path swap₊})\n\n-- The equivalence of paths makes U a 1groupoid: the points are types t : U;\n-- the 1paths are ⟷; and the 2paths between them are ⇔\n\nG : 1Groupoid\nG = record\n { set = U\n ; _↝_ = Path\n ; _≈_ = _⇔_ \n ; id = path id⟷\n ; _∘_ = λ q p → p ● q\n ; _⁻¹ = inv\n ; lneutr = λ p → 2path (p∼q→q∼p p∼p◎id) \n ; rneutr = λ p → 2path (p∼q→q∼p p∼id◎p)\n ; assoc = λ r q p → 2path assoc◎\n ; equiv = record { \n refl = 2path p∼p\n ; sym = λ { (2path α) → 2path (p∼q→q∼p α) }\n ; trans = λ { (2path α) (2path β) → 2path (p∼q∼r→p∼r α β) }\n }\n ; linv = λ p → 2path p◎!p∼id\n ; rinv = λ p → 2path !p◎p∼id\n ; ∘-resp-≈ = λ { (2path β) (2path α) → 2path (resp◎ α β) }\n }\n\n------------------------------------------------------------------------------\n\ndata ΩU : Set where\n ΩZERO : ΩU -- empty set of paths\n ΩONE : ΩU -- a trivial path\n ΩPLUS : ΩU → ΩU → ΩU -- disjoint union of paths\n ΩTIMES : ΩU → ΩU → ΩU -- pairs of paths\n PATH : (t₁ t₂ : U) → ΩU -- level 0 paths between values\n\n-- values\n\nΩ⟦_⟧ : ΩU → Set\nΩ⟦ ΩZERO ⟧ = ⊥\nΩ⟦ ΩONE ⟧ = ⊤\nΩ⟦ ΩPLUS t₁ t₂ ⟧ = Ω⟦ t₁ ⟧ ⊎ Ω⟦ t₂ ⟧\nΩ⟦ ΩTIMES t₁ t₂ ⟧ = Ω⟦ t₁ ⟧ × Ω⟦ t₂ ⟧\nΩ⟦ PATH t₁ t₂ ⟧ = Path t₁ t₂\n\n-- two perminators are the same if they denote the same permutation\n\n\n-- 2paths\n\ndata _⇔_ : ΩU → ΩU → Set where\n unite₊ : {t : ΩU} → ΩPLUS ΩZERO t ⇔ t\n uniti₊ : {t : ΩU} → t ⇔ ΩPLUS ΩZERO t\n swap₊ : {t₁ t₂ : ΩU} → ΩPLUS t₁ t₂ ⇔ ΩPLUS t₂ t₁\n assocl₊ : {t₁ t₂ t₃ : ΩU} → ΩPLUS t₁ (ΩPLUS t₂ t₃) ⇔ ΩPLUS (ΩPLUS t₁ t₂) t₃\n assocr₊ : {t₁ t₂ t₃ : ΩU} → ΩPLUS (ΩPLUS t₁ t₂) t₃ ⇔ ΩPLUS t₁ (ΩPLUS t₂ t₃)\n unite⋆ : {t : ΩU} → ΩTIMES ΩONE t ⇔ t\n uniti⋆ : {t : ΩU} → t ⇔ ΩTIMES ΩONE t\n swap⋆ : {t₁ t₂ : ΩU} → ΩTIMES t₁ t₂ ⇔ ΩTIMES t₂ t₁\n assocl⋆ : {t₁ t₂ t₃ : ΩU} → ΩTIMES t₁ (ΩTIMES t₂ t₃) ⇔ ΩTIMES (ΩTIMES t₁ t₂) t₃\n assocr⋆ : {t₁ t₂ t₃ : ΩU} → ΩTIMES (ΩTIMES t₁ t₂) t₃ ⇔ ΩTIMES t₁ (ΩTIMES t₂ t₃)\n distz : {t : ΩU} → ΩTIMES ΩZERO t ⇔ ΩZERO\n factorz : {t : ΩU} → ΩZERO ⇔ ΩTIMES ΩZERO t\n dist : {t₁ t₂ t₃ : ΩU} → \n ΩTIMES (ΩPLUS t₁ t₂) t₃ ⇔ ΩPLUS (ΩTIMES t₁ t₃) (ΩTIMES t₂ t₃) \n factor : {t₁ t₂ t₃ : ΩU} → \n ΩPLUS (ΩTIMES t₁ t₃) (ΩTIMES t₂ t₃) ⇔ ΩTIMES (ΩPLUS t₁ t₂) t₃\n id⇔ : {t : ΩU} → t ⇔ t\n _◎_ : {t₁ t₂ t₃ : ΩU} → (t₁ ⇔ t₂) → (t₂ ⇔ t₃) → (t₁ ⇔ t₃)\n _⊕_ : {t₁ t₂ t₃ t₄ : ΩU} → \n (t₁ ⇔ t₃) → (t₂ ⇔ t₄) → (ΩPLUS t₁ t₂ ⇔ ΩPLUS t₃ t₄)\n _⊗_ : {t₁ t₂ t₃ t₄ : ΩU} → \n (t₁ ⇔ t₃) → (t₂ ⇔ t₄) → (ΩTIMES t₁ t₂ ⇔ ΩTIMES t₃ t₄)\n _∼⇔_ : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → \n PATH t₁ t₂ ⇔ PATH t₁ t₂\n\n-- two spaces are equivalent if there is a path between them; this path\n-- automatically has an inverse which is an equivalence. It is a\n-- quasi-equivalence but for finite types that's the same as an equivalence.\n\ninfix 4 _≃_ \n\n_≃_ : (t₁ t₂ : U) → Set\nt₁ ≃ t₂ = (t₁ ⟷ t₂)\n\n-- Univalence says (t₁ ≃ t₂) ≃ (t₁ ⟷ t₂) but as shown above, we actually have\n-- this by definition instead of up to ≃\n\n------------------------------------------------------------------------------\n------------------------------------------------------------------------------\n------------------------------------------------------------------------------\n\nanother idea is to look at c and massage it as follows: rewrite every \nswap+ ; c\nto \nc' ; swaps ; c''\n\ngeneral start with \n id || id || c\nexamine c and move anything that's not swap to left. If we get to\n c' || id || id\nwe are done\nif we get to:\n c' || id || swap+;c\nthen we rewrite\n c';c1 || swaps || c2;c\nand we keep going\n\nmodule Phase₁ where\n\n -- no occurrences of (TIMES (TIMES t₁ t₂) t₃)\n\napproach that maintains the invariants in proofs\n\n invariant : (t : U) → Bool\n invariant ZERO = true\n invariant ONE = true\n invariant (PLUS t₁ t₂) = invariant t₁ ∧ invariant t₂ \n invariant (TIMES ZERO t₂) = invariant t₂\n invariant (TIMES ONE t₂) = invariant t₂\n invariant (TIMES (PLUS t₁ t₂) t₃) = (invariant t₁ ∧ invariant t₂) ∧ invariant t₃\n invariant (TIMES (TIMES t₁ t₂) t₃) = false\n\n Invariant : (t : U) → Set\n Invariant t = invariant t ≡ true\n\n invariant? : Decidable Invariant\n invariant? t with invariant t \n ... | true = yes refl\n ... | false = no (λ ())\n\n conj : ∀ {b₁ b₂} → (b₁ ≡ true) → (b₂ ≡ true) → (b₁ ∧ b₂ ≡ true)\n conj {true} {true} p q = refl\n conj {true} {false} p ()\n conj {false} {true} ()\n conj {false} {false} ()\n\n phase₁ : (t₁ : U) → Σ[ t₂ ∈ U ] (True (invariant? t₂) × t₁ ⟷ t₂)\n phase₁ ZERO = (ZERO , (fromWitness {Q = invariant? ZERO} refl , id⟷))\n phase₁ ONE = (ONE , (fromWitness {Q = invariant? ONE} refl , id⟷))\n phase₁ (PLUS t₁ t₂) with phase₁ t₁ | phase₁ t₂\n ... | (t₁' , (p₁ , c₁)) | (t₂' , (p₂ , c₂)) with toWitness p₁ | toWitness p₂\n ... | t₁'ok | t₂'ok = \n (PLUS t₁' t₂' , \n (fromWitness {Q = invariant? (PLUS t₁' t₂')} (conj t₁'ok t₂'ok) , \n c₁ ⊕ c₂))\n phase₁ (TIMES ZERO t) with phase₁ t\n ... | (t' , (p , c)) with toWitness p \n ... | t'ok = \n (TIMES ZERO t' , \n (fromWitness {Q = invariant? (TIMES ZERO t')} t'ok , \n id⟷ ⊗ c))\n phase₁ (TIMES ONE t) with phase₁ t \n ... | (t' , (p , c)) with toWitness p\n ... | t'ok = \n (TIMES ONE t' , \n (fromWitness {Q = invariant? (TIMES ONE t')} t'ok , \n id⟷ ⊗ c))\n phase₁ (TIMES (PLUS t₁ t₂) t₃) with phase₁ t₁ | phase₁ t₂ | phase₁ t₃\n ... | (t₁' , (p₁ , c₁)) | (t₂' , (p₂ , c₂)) | (t₃' , (p₃ , c₃)) \n with toWitness p₁ | toWitness p₂ | toWitness p₃ \n ... | t₁'ok | t₂'ok | t₃'ok = \n (TIMES (PLUS t₁' t₂') t₃' , \n (fromWitness {Q = invariant? (TIMES (PLUS t₁' t₂') t₃')}\n (conj (conj t₁'ok t₂'ok) t₃'ok) , \n (c₁ ⊕ c₂) ⊗ c₃))\n phase₁ (TIMES (TIMES t₁ t₂) t₃) = {!!} \n\n -- invariants are informal\n -- rewrite (TIMES (TIMES t₁ t₂) t₃) to TIMES t₁ (TIMES t₂ t₃)\n invariant : (t : U) → Bool\n invariant ZERO = true\n invariant ONE = true\n invariant (PLUS t₁ t₂) = invariant t₁ ∧ invariant t₂ \n invariant (TIMES ZERO t₂) = invariant t₂\n invariant (TIMES ONE t₂) = invariant t₂\n invariant (TIMES (PLUS t₁ t₂) t₃) = invariant t₁ ∧ invariant t₂ ∧ invariant t₃\n invariant (TIMES (TIMES t₁ t₂) t₃) = false\n\n step₁ : (t₁ : U) → Σ[ t₂ ∈ U ] (t₁ ⟷ t₂)\n step₁ ZERO = (ZERO , id⟷)\n step₁ ONE = (ONE , id⟷)\n step₁ (PLUS t₁ t₂) with step₁ t₁ | step₁ t₂\n ... | (t₁' , c₁) | (t₂' , c₂) = (PLUS t₁' t₂' , c₁ ⊕ c₂)\n step₁ (TIMES (TIMES t₁ t₂) t₃) with step₁ t₁ | step₁ t₂ | step₁ t₃\n ... | (t₁' , c₁) | (t₂' , c₂) | (t₃' , c₃) = \n (TIMES t₁' (TIMES t₂' t₃') , ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆)\n step₁ (TIMES ZERO t₂) with step₁ t₂ \n ... | (t₂' , c₂) = (TIMES ZERO t₂' , id⟷ ⊗ c₂)\n step₁ (TIMES ONE t₂) with step₁ t₂ \n ... | (t₂' , c₂) = (TIMES ONE t₂' , id⟷ ⊗ c₂)\n step₁ (TIMES (PLUS t₁ t₂) t₃) with step₁ t₁ | step₁ t₂ | step₁ t₃\n ... | (t₁' , c₁) | (t₂' , c₂) | (t₃' , c₃) = \n (TIMES (PLUS t₁' t₂') t₃' , (c₁ ⊕ c₂) ⊗ c₃)\n\n {-# NO_TERMINATION_CHECK #-}\n phase₁ : (t₁ : U) → Σ[ t₂ ∈ U ] (t₁ ⟷ t₂)\n phase₁ t with invariant t\n ... | true = (t , id⟷)\n ... | false with step₁ t\n ... | (t' , c) with phase₁ t'\n ... | (t'' , c') = (t'' , c ◎ c')\n\n test₁ = phase₁ (TIMES (TIMES (TIMES ONE ONE) (TIMES ONE ONE)) ONE)\n TIMES ONE (TIMES ONE (TIMES ONE (TIMES ONE ONE))) ,\n (((id⟷ ⊗ id⟷) ⊗ (id⟷ ⊗ id⟷)) ⊗ id⟷ ◎ assocr⋆) ◎\n ((id⟷ ⊗ id⟷) ⊗ ((id⟷ ⊗ id⟷) ⊗ id⟷ ◎ assocr⋆) ◎ assocr⋆) ◎ id⟷\n\n -- Now any perminator (t₁ ⟷ t₂) can be transformed to a canonical\n -- representation in which we first associate all the TIMES to the right\n -- and then do the rest of the perminator\n\n normalize₁ : {t₁ t₂ : U} → (t₁ ⟷ t₂) → \n (Σ[ t₁' ∈ U ] (t₁ ⟷ t₁' × t₁' ⟷ t₂))\n normalize₁ {ZERO} {t} c = ZERO , id⟷ , c\n normalize₁ {ONE} c = ONE , id⟷ , c\n normalize₁ {PLUS .ZERO t₂} unite₊ with phase₁ t₂\n ... | (t₂n , cn) = PLUS ZERO t₂n , id⟷ ⊕ cn , unite₊ ◎ ! cn\n normalize₁ {PLUS t₁ t₂} uniti₊ = {!!}\n normalize₁ {PLUS t₁ t₂} swap₊ = {!!}\n normalize₁ {PLUS t₁ ._} assocl₊ = {!!}\n normalize₁ {PLUS ._ t₂} assocr₊ = {!!}\n normalize₁ {PLUS t₁ t₂} uniti⋆ = {!!}\n normalize₁ {PLUS ._ ._} factor = {!!}\n normalize₁ {PLUS t₁ t₂} id⟷ = {!!}\n normalize₁ {PLUS t₁ t₂} (c ◎ c₁) = {!!}\n normalize₁ {PLUS t₁ t₂} (c ⊕ c₁) = {!!} \n normalize₁ {TIMES t₁ t₂} c = {!!}\n\nrecord Permutation (t t' : U) : Set where\n field\n t₀ : U -- no occurrences of TIMES .. (TIMES .. ..)\n phase₀ : t ⟷ t₀ \n t₁ : U -- no occurrences of TIMES (PLUS .. ..)\n phase₁ : t₀ ⟷ t₁\n t₂ : U -- no occurrences of TIMES\n phase₂ : t₁ ⟷ t₂\n t₃ : U -- no nested left PLUS, all PLUS of form PLUS simple (PLUS ...)\n phase₃ : t₂ ⟷ t₃\n t₄ : U -- no occurrences PLUS ZERO\n phase₄ : t₃ ⟷ t₄\n t₅ : U -- do actual permutation using swapij\n phase₅ : t₄ ⟷ t₅\n rest : t₅ ⟷ t' -- blah blah\n\ncanonical : {t₁ t₂ : U} → (t₁ ⟷ t₂) → Permutation t₁ t₂\ncanonical c = {!!}\n\n------------------------------------------------------------------------------\n-- These paths do NOT reach \"inside\" the finite sets. For example, there is\n-- NO PATH between false and true in BOOL even though there is a path between\n-- BOOL and BOOL that \"twists the space around.\"\n-- \n-- In more detail how do these paths between types relate to the whole\n-- discussion about higher groupoid structure of type formers (Sec. 2.5 and\n-- on).\n\n-- Then revisit the early parts of Ch. 2 about higher groupoid structure for\n-- U, how functions from U to U respect the paths in U, type families and\n-- dependent functions, homotopies and equivalences, and then Sec. 2.5 and\n-- beyond again.\n\n\nshould this be on the code as done now or on their interpreation\ni.e. data _⟷_ : ⟦ U ⟧ → ⟦ U ⟧ → Set where\n\ncan add recursive types \nrec : U\n⟦_⟧ takes an additional argument X that is passed around\n⟦ rec ⟧ X = X\nfixpoitn\ndata μ (t : U) : Set where\n ⟨_⟩ : ⟦ t ⟧ (μ t) → μ t\n\n-- We identify functions with the paths above. Since every function is\n-- reversible, every function corresponds to a path and there is no\n-- separation between functions and paths and no need to mediate between them\n-- using univalence.\n--\n-- Note that none of the above functions are dependent functions.\n\n------------------------------------------------------------------------------\n-- Now we consider homotopies, i.e., paths between functions. Since our\n-- functions are identified with the paths ⟷, the homotopies are paths\n-- between elements of ⟷\n\n-- First, a sanity check. Our notion of paths matches the notion of\n-- equivalences in the conventional HoTT presentation\n\n-- Homotopy between two functions (paths)\n\n-- That makes id ∼ not which is bad. The def. of ∼ should be parametric...\n\n_∼_ : {t₁ t₂ t₃ : U} → (f : t₁ ⟷ t₂) → (g : t₁ ⟷ t₃) → Set\n_∼_ {t₁} {t₂} {t₃} f g = t₂ ⟷ t₃\n\n-- Every f and g of the right type are related by ∼\n\nhomotopy : {t₁ t₂ t₃ : U} → (f : t₁ ⟷ t₂) → (g : t₁ ⟷ t₃) → (f ∼ g)\nhomotopy f g = (! f) ◎ g\n\n-- Equivalences \n-- \n-- If f : t₁ ⟷ t₂ has two inverses g₁ g₂ : t₂ ⟷ t₁ then g₁ ∼ g₂. More\n-- generally, any two paths of the same type are related by ∼.\n\nequiv : {t₁ t₂ : U} → (f g : t₁ ⟷ t₂) → (f ∼ g) \nequiv f g = id⟷ \n\n-- It follows that any two types in U are equivalent if there is a path\n-- between them\n\n_≃_ : (t₁ t₂ : U) → Set\nt₁ ≃ t₂ = t₁ ⟷ t₂ \n\n-- Now we want to understand the type of paths between paths\n\n------------------------------------------------------------------------------\n\nelems : (t : U) → List ⟦ t ⟧\nelems ZERO = []\nelems ONE = [ tt ] \nelems (PLUS t₁ t₂) = map inj₁ (elems t₁) ++ map inj₂ (elems t₂)\nelems (TIMES t₁ t₂) = concat \n (map \n (λ v₂ → map (λ v₁ → (v₁ , v₂)) (elems t₁))\n (elems t₂))\n\n_≟_ : {t : U} → ⟦ t ⟧ → ⟦ t ⟧ → Bool\n_≟_ {ZERO} ()\n_≟_ {ONE} tt tt = true\n_≟_ {PLUS t₁ t₂} (inj₁ v) (inj₁ w) = v ≟ w\n_≟_ {PLUS t₁ t₂} (inj₁ v) (inj₂ w) = false\n_≟_ {PLUS t₁ t₂} (inj₂ v) (inj₁ w) = false\n_≟_ {PLUS t₁ t₂} (inj₂ v) (inj₂ w) = v ≟ w\n_≟_ {TIMES t₁ t₂} (v₁ , w₁) (v₂ , w₂) = v₁ ≟ v₂ ∧ w₁ ≟ w₂\n\n findLoops : {t t₁ t₂ : U} → (PLUS t t₁ ⟷ PLUS t t₂) → List ⟦ t ⟧ → \n List (Σ[ t ∈ U ] ⟦ t ⟧)\n findLoops c [] = []\n findLoops {t} c (v ∷ vs) = ? with perm2path c (inj₁ v)\n ... | (inj₂ _ , loops) = loops ++ findLoops c vs\n ... | (inj₁ v' , loops) with v ≟ v' \n ... | true = (t , v) ∷ loops ++ findLoops c vs\n ... | false = loops ++ findLoops c vs\n\ntraceLoopsEx : {t : U} → List (Σ[ t ∈ U ] ⟦ t ⟧)\ntraceLoopsEx {t} = findLoops traceBodyEx (elems (PLUS t (PLUS t t)))\n-- traceLoopsEx {ONE} ==> (PLUS ONE (PLUS ONE ONE) , inj₂ (inj₁ tt)) ∷ []\n\n-- Each permutation is a \"path\" between types. We can think of this path as\n-- being indexed by \"time\" where \"time\" here is in discrete units\n-- corresponding to the sequencing of combinators. A homotopy between paths p\n-- and q is a map that, for each \"time unit\", maps the specified type along p\n-- to a corresponding type along q. At each such time unit, the mapping\n-- between types is itself a path. So a homotopy is essentially a collection\n-- of paths. As an example, given two paths starting at t₁ and ending at t₂\n-- and going through different intermediate points:\n-- p = t₁ -> t -> t' -> t₂\n-- q = t₁ -> u -> u' -> t₂\n-- A possible homotopy between these two paths is a path from t to u and \n-- another path from t' to u'. Things get slightly more complicated if the\n-- number of intermediate points is not the same etc. but that's the basic idea.\n-- The vertical paths must commute with the horizontal ones.\n-- \n-- Postulate the groupoid laws and use them to prove commutativity etc.\n-- \n-- Bool -id-- Bool -id-- Bool -id-- Bool\n-- | | | |\n-- | not id | the last square does not commute\n-- | | | |\n-- Bool -not- Bool -not- Bool -not- Bool\n--\n-- If the large rectangle commutes then the smaller squares commute. For a\n-- proof, let p o q o r o s be the left-bottom path and p' o q' o r' o s' be\n-- the top-right path. Let's focus on the square:\n-- \n-- A-- r'--C\n-- | |\n-- ? s'\n-- | |\n-- B-- s --D\n-- \n-- We have a path from A to B that is: !q' o !p' o p o q o r. \n-- Now let's see if r' o s' is equivalent to \n-- !q' o !p' o p o q o r o s\n-- We know p o q o r o s ⇔ p' o q' o r' o s' \n-- If we know that ⇔ is preserved by composition then:\n-- !q' o !p' o p o q o r o s ⇔ !q' o !p' o p' o q' o r' o s' \n-- and of course by inverses and id being unit of composition:\n-- !q' o !p' o p o q o r o s ⇔ r' o s' \n-- and we are done.\n\n{-# NO_TERMINATION_CHECK #-}\nPath∼ : ∀ {t₁ t₂ t₁' t₂' v₁ v₂ v₁' v₂'} → \n (p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) → \n (q : Path •[ t₁' , v₁' ] •[ t₂' , v₂' ]) → \n Set\n-- sequential composition\nPath∼ {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'} \n (_●_ {t₂ = t₂} {v₂ = v₂} p₁ p₂) (_●_ {t₂ = t₂'} {v₂ = v₂'} q₁ q₂) = \n (Path∼ p₁ q₁ × Path∼ p₂ q₂) ⊎\n (Path∼ {t₁} {t₂} {t₁'} {t₁'} {v₁} {v₂} {v₁'} {v₁'} p₁ id⟷• × Path∼ p₂ (q₁ ● q₂)) ⊎ \n (Path∼ p₁ (q₁ ● q₂) × Path∼ {t₂} {t₃} {t₃'} {t₃'} {v₂} {v₃} {v₃'} {v₃'} p₂ id⟷•) ⊎ \n (Path∼ {t₁} {t₁} {t₁'} {t₂'} {v₁} {v₁} {v₁'} {v₂'} id⟷• q₁ × Path∼ (p₁ ● p₂) q₂) ⊎\n (Path∼ (p₁ ● p₂) q₁ × Path∼ {t₃} {t₃} {t₂'} {t₃'} {v₃} {v₃} {v₂'} {v₃'} id⟷• q₂)\nPath∼ {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'} \n (_●_ {t₂ = t₂} {v₂ = v₂} p q) c = \n (Path∼ {t₁} {t₂} {t₁'} {t₁'} {v₁} {v₂} {v₁'} {v₁'} p id⟷• × Path∼ q c)\n ⊎ (Path∼ p c × Path∼ {t₂} {t₃} {t₃'} {t₃'} {v₂} {v₃} {v₃'} {v₃'} q id⟷•)\nPath∼ {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'} \n c (_●_ {t₂ = t₂'} {v₂ = v₂'} p q) = \n (Path∼ {t₁} {t₁} {t₁'} {t₂'} {v₁} {v₁} {v₁'} {v₂'} id⟷• p × Path∼ c q)\n ⊎ (Path∼ c p × Path∼ {t₃} {t₃} {t₂'} {t₃'} {v₃} {v₃} {v₂'} {v₃'} id⟷• q)\n-- choices\nPath∼ (⊕1• p) (⊕1• q) = Path∼ p q\nPath∼ (⊕1• p) _ = ⊥\nPath∼ _ (⊕1• p) = ⊥\nPath∼ (⊕2• p) (⊕2• q) = Path∼ p q\nPath∼ (⊕2• p) _ = ⊥\nPath∼ _ (⊕2• p) = ⊥\n-- parallel paths\nPath∼ (p₁ ⊗• p₂) (q₁ ⊗• q₂) = Path∼ p₁ q₁ × Path∼ p₂ q₂\nPath∼ (p₁ ⊗• p₂) _ = ⊥\nPath∼ _ (q₁ ⊗• q₂) = ⊥\n-- simple edges connecting two points\nPath∼ {t₁} {t₂} {t₁'} {t₂'} {v₁} {v₂} {v₁'} {v₂'} c₁ c₂ = \n Path •[ t₁ , v₁ ] •[ t₁' , v₁' ] × Path •[ t₂ , v₂ ] •[ t₂' , v₂' ] \n\n-- In the setting of finite types (in particular with no loops) every pair of\n-- paths with related start and end points is equivalent. In other words, we\n-- really have no interesting 2-path structure.\n\nallequiv : ∀ {t₁ t₂ t₁' t₂' v₁ v₂ v₁' v₂'} → \n (p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) → \n (q : Path •[ t₁' , v₁' ] •[ t₂' , v₂' ]) → \n (start : Path •[ t₁ , v₁ ] •[ t₁' , v₁' ]) → \n (end : Path •[ t₂ , v₂ ] •[ t₂' , v₂' ]) → \n Path∼ p q\nallequiv {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'} \n (_●_ {t₂ = t₂} {v₂ = v₂} p₁ p₂) (_●_ {t₂ = t₂'} {v₂ = v₂'} q₁ q₂) \n start end = {!!}\nallequiv {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'} \n (_●_ {t₂ = t₂} {v₂ = v₂} p q) c start end = {!!}\nallequiv {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'} \n c (_●_ {t₂ = t₂'} {v₂ = v₂'} p q) start end = {!!}\nallequiv (⊕1• p) (⊕1• q) start end = {!!}\nallequiv (⊕1• p) _ start end = {!!}\nallequiv _ (⊕1• p) start end = {!!}\nallequiv (⊕2• p) (⊕2• q) start end = {!!}\nallequiv (⊕2• p) _ start end = {!!}\nallequiv _ (⊕2• p) start end = {!!}\n-- parallel paths\nallequiv (p₁ ⊗• p₂) (q₁ ⊗• q₂) start end = {!!}\nallequiv (p₁ ⊗• p₂) _ start end = {!!}\nallequiv _ (q₁ ⊗• q₂) start end = {!!}\n-- simple edges connecting two points\nallequiv {t₁} {t₂} {t₁'} {t₂'} {v₁} {v₂} {v₁'} {v₂'} c₁ c₂ start end = {!!}\n\n\n\n\n\nrefl∼ : ∀ {t₁ t₂ v₁ v₂} → (p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) → Path∼ p p \nrefl∼ unite•₊ = id⟷• , id⟷• \nrefl∼ uniti•₊ = id⟷• , id⟷• \nrefl∼ swap1•₊ = id⟷• , id⟷• \nrefl∼ swap2•₊ = id⟷• , id⟷• \nrefl∼ assocl1•₊ = id⟷• , id⟷• \nrefl∼ assocl2•₊ = id⟷• , id⟷• \nrefl∼ assocl3•₊ = id⟷• , id⟷• \nrefl∼ assocr1•₊ = id⟷• , id⟷• \nrefl∼ assocr2•₊ = id⟷• , id⟷• \nrefl∼ assocr3•₊ = id⟷• , id⟷• \nrefl∼ unite•⋆ = id⟷• , id⟷• \nrefl∼ uniti•⋆ = id⟷• , id⟷• \nrefl∼ swap•⋆ = id⟷• , id⟷• \nrefl∼ assocl•⋆ = id⟷• , id⟷• \nrefl∼ assocr•⋆ = id⟷• , id⟷• \nrefl∼ distz• = id⟷• , id⟷• \nrefl∼ factorz• = id⟷• , id⟷• \nrefl∼ dist1• = id⟷• , id⟷• \nrefl∼ dist2• = id⟷• , id⟷• \nrefl∼ factor1• = id⟷• , id⟷• \nrefl∼ factor2• = id⟷• , id⟷• \nrefl∼ id⟷• = id⟷• , id⟷• \nrefl∼ (p ● q) = inj₁ (refl∼ p , refl∼ q)\nrefl∼ (⊕1• p) = refl∼ p\nrefl∼ (⊕2• q) = refl∼ q\nrefl∼ (p ⊗• q) = refl∼ p , refl∼ q \n\n-- Extensional view\n\n-- First we enumerate all the values of a given finite type\n\nsize : U → ℕ\nsize ZERO = 0\nsize ONE = 1\nsize (PLUS t₁ t₂) = size t₁ + size t₂\nsize (TIMES t₁ t₂) = size t₁ * size t₂\n\nenum : (t : U) → ⟦ t ⟧ → Fin (size t)\nenum ZERO () -- absurd\nenum ONE tt = zero\nenum (PLUS t₁ t₂) (inj₁ v₁) = inject+ (size t₂) (enum t₁ v₁)\nenum (PLUS t₁ t₂) (inj₂ v₂) = raise (size t₁) (enum t₂ v₂)\nenum (TIMES t₁ t₂) (v₁ , v₂) = fromℕ≤ (pr {s₁} {s₂} {n₁} {n₂})\n where n₁ = enum t₁ v₁\n n₂ = enum t₂ v₂\n s₁ = size t₁ \n s₂ = size t₂\n pr : {s₁ s₂ : ℕ} → {n₁ : Fin s₁} {n₂ : Fin s₂} → \n ((toℕ n₁ * s₂) + toℕ n₂) < (s₁ * s₂)\n pr {0} {_} {()} \n pr {_} {0} {_} {()}\n pr {suc s₁} {suc s₂} {zero} {zero} = {!z≤n!}\n pr {suc s₁} {suc s₂} {zero} {Fsuc n₂} = {!!}\n pr {suc s₁} {suc s₂} {Fsuc n₁} {zero} = {!!}\n pr {suc s₁} {suc s₂} {Fsuc n₁} {Fsuc n₂} = {!!}\n\nvals3 : Fin 3 × Fin 3 × Fin 3\nvals3 = (enum THREE LL , enum THREE LR , enum THREE R)\n where THREE = PLUS (PLUS ONE ONE) ONE\n LL = inj₁ (inj₁ tt)\n LR = inj₁ (inj₂ tt)\n R = inj₂ tt\n\n--}\n\n\nxxx : {s₁ s₂ : ℕ} → (i : Fin s₁) → (j : Fin s₂) → \n suc (toℕ i * s₂ + toℕ j) ≤ s₁ * s₂\nxxx {0} {_} ()\nxxx {suc s₁} {s₂} i j = {!!} \n\n-- i : Fin (suc s₁)\n-- j : Fin s₂\n-- ?0 : suc (toℕ i * s₂ + toℕ j) ≤ suc s₁ * s₂\n-- (suc (toℕ i) * s₂ + toℕ j ≤ s₂ + s₁ * s₂\n-- (suc (toℕ i) * s₂ + toℕ j ≤ s₁ * s₂ + s₂\n\n\n\nutoVecℕ : (t : U) → Vec (Fin (utoℕ t)) (utoℕ t)\nutoVecℕ ZERO = []\nutoVecℕ ONE = [ zero ]\nutoVecℕ (PLUS t₁ t₂) = \n map (inject+ (utoℕ t₂)) (utoVecℕ t₁) ++ \n map (raise (utoℕ t₁)) (utoVecℕ t₂)\nutoVecℕ (TIMES t₁ t₂) = \n concat (map (λ i → map (λ j → inject≤ (fromℕ (toℕ i * utoℕ t₂ + toℕ j)) \n (xxx i j))\n (utoVecℕ t₂))\n (utoVecℕ t₁))\n\n-- Vector representation of types so that we can test permutations\n\nutoVec : (t : U) → Vec ⟦ t ⟧ (utoℕ t)\nutoVec ZERO = []\nutoVec ONE = [ tt ]\nutoVec (PLUS t₁ t₂) = map inj₁ (utoVec t₁) ++ map inj₂ (utoVec t₂)\nutoVec (TIMES t₁ t₂) = \n concat (map (λ v₁ → map (λ v₂ → (v₁ , v₂)) (utoVec t₂)) (utoVec t₁))\n\n-- Examples permutations and their actions on a simple ordered vector\n\nmodule PermExamples where\n\n -- ordered vector: position i has value i\n ordered : ∀ {n} → Vec (Fin n) n\n ordered = tabulate id\n\n -- empty permutation p₀ { }\n\n p₀ : Perm 0\n p₀ = []\n\n v₀ = permute p₀ ordered\n\n -- permutation p₁ { 0 -> 0 }\n\n p₁ : Perm 1\n p₁ = 0F ∷ p₀\n where 0F = fromℕ 0\n\n v₁ = permute p₁ ordered\n\n -- permutations p₂ { 0 -> 0, 1 -> 1 }\n -- q₂ { 0 -> 1, 1 -> 0 }\n\n p₂ q₂ : Perm 2\n p₂ = 0F ∷ p₁ \n where 0F = inject+ 1 (fromℕ 0)\n q₂ = 1F ∷ p₁\n where 1F = fromℕ 1\n\n v₂ = permute p₂ ordered\n w₂ = permute q₂ ordered\n\n -- permutations p₃ { 0 -> 0, 1 -> 1, 2 -> 2 }\n -- s₃ { 0 -> 0, 1 -> 2, 2 -> 1 }\n -- q₃ { 0 -> 1, 1 -> 0, 2 -> 2 }\n -- r₃ { 0 -> 1, 1 -> 2, 2 -> 0 }\n -- t₃ { 0 -> 2, 1 -> 0, 2 -> 1 }\n -- u₃ { 0 -> 2, 1 -> 1, 2 -> 0 }\n\n p₃ q₃ r₃ s₃ t₃ u₃ : Perm 3\n p₃ = 0F ∷ p₂\n where 0F = inject+ 2 (fromℕ 0)\n s₃ = 0F ∷ q₂\n where 0F = inject+ 2 (fromℕ 0)\n q₃ = 1F ∷ p₂\n where 1F = inject+ 1 (fromℕ 1)\n r₃ = 2F ∷ p₂\n where 2F = fromℕ 2\n t₃ = 1F ∷ q₂\n where 1F = inject+ 1 (fromℕ 1)\n u₃ = 2F ∷ q₂\n where 2F = fromℕ 2\n\n v₃ = permute p₃ ordered\n y₃ = permute s₃ ordered\n w₃ = permute q₃ ordered\n x₃ = permute r₃ ordered\n z₃ = permute t₃ ordered\n α₃ = permute u₃ ordered\n\n -- end module PermExamples\n\n------------------------------------------------------------------------------\n-- Testing\n\nt₁ = PLUS ZERO BOOL\nt₂ = BOOL\nm₁ = matchP {t₁} {t₂} unite₊\n-- (inj₂ (inj₁ tt) , inj₁ tt) ∷ (inj₂ (inj₂ tt) , inj₂ tt) ∷ []\nm₂ = matchP {t₂} {t₁} uniti₊\n-- (inj₁ tt , inj₂ (inj₁ tt)) ∷ (inj₂ tt , inj₂ (inj₂ tt)) ∷ []\n\nt₃ = PLUS BOOL ONE\nt₄ = PLUS ONE BOOL\nm₃ = matchP {t₃} {t₄} swap₊\n-- (inj₂ tt , inj₁ tt) ∷\n-- (inj₁ (inj₁ tt) , inj₂ (inj₁ tt)) ∷\n-- (inj₁ (inj₂ tt) , inj₂ (inj₂ tt)) ∷ []\nm₄ = matchP {t₄} {t₃} swap₊\n-- (inj₂ (inj₁ tt) , inj₁ (inj₁ tt)) ∷\n-- (inj₂ (inj₂ tt) , inj₁ (inj₂ tt)) ∷ \n-- (inj₁ tt , inj₂ tt) ∷ []\n\nt₅ = PLUS ONE (PLUS BOOL ONE)\nt₆ = PLUS (PLUS ONE BOOL) ONE\nm₅ = matchP {t₅} {t₆} assocl₊\n-- (inj₁ tt , inj₁ (inj₁ tt)) ∷\n-- (inj₂ (inj₁ (inj₁ tt)) , inj₁ (inj₂ (inj₁ tt))) ∷\n-- (inj₂ (inj₁ (inj₂ tt)) , inj₁ (inj₂ (inj₂ tt))) ∷\n-- (inj₂ (inj₂ tt) , inj₂ tt) ∷ []\nm₆ = matchP {t₆} {t₅} assocr₊\n-- (inj₁ (inj₁ tt) , inj₁ tt) ∷\n-- (inj₁ (inj₂ (inj₁ tt)) , inj₂ (inj₁ (inj₁ tt))) ∷\n-- (inj₁ (inj₂ (inj₂ tt)) , inj₂ (inj₁ (inj₂ tt))) ∷\n-- (inj₂ tt , inj₂ (inj₂ tt)) ∷ []\n\nt₇ = TIMES ONE BOOL\nt₈ = BOOL\nm₇ = matchP {t₇} {t₈} unite⋆\n-- ((tt , inj₁ tt) , inj₁ tt) ∷ ((tt , inj₂ tt) , inj₂ tt) ∷ []\nm₈ = matchP {t₈} {t₇} uniti⋆\n-- (inj₁ tt , (tt , inj₁ tt)) ∷ (inj₂ tt , (tt , inj₂ tt)) ∷ []\n\nt₉ = TIMES BOOL ONE\nt₁₀ = TIMES ONE BOOL\nm₉ = matchP {t₉} {t₁₀} swap⋆\n-- ((inj₁ tt , tt) , (tt , inj₁ tt)) ∷\n-- ((inj₂ tt , tt) , (tt , inj₂ tt)) ∷ []\nm₁₀ = matchP {t₁₀} {t₉} swap⋆\n-- ((tt , inj₁ tt) , (inj₁ tt , tt)) ∷\n-- ((tt , inj₂ tt) , (inj₂ tt , tt)) ∷ []\n\nt₁₁ = TIMES BOOL (TIMES ONE BOOL)\nt₁₂ = TIMES (TIMES BOOL ONE) BOOL\nm₁₁ = matchP {t₁₁} {t₁₂} assocl⋆\n-- ((inj₁ tt , (tt , inj₁ tt)) , ((inj₁ tt , tt) , inj₁ tt)) ∷\n-- ((inj₁ tt , (tt , inj₂ tt)) , ((inj₁ tt , tt) , inj₂ tt)) ∷\n-- ((inj₂ tt , (tt , inj₁ tt)) , ((inj₂ tt , tt) , inj₁ tt)) ∷\n-- ((inj₂ tt , (tt , inj₂ tt)) , ((inj₂ tt , tt) , inj₂ tt)) ∷ []\nm₁₂ = matchP {t₁₂} {t₁₁} assocr⋆\n-- (((inj₁ tt , tt) , inj₁ tt) , (inj₁ tt , (tt , inj₁ tt)) ∷\n-- (((inj₁ tt , tt) , inj₂ tt) , (inj₁ tt , (tt , inj₂ tt)) ∷\n-- (((inj₂ tt , tt) , inj₁ tt) , (inj₂ tt , (tt , inj₁ tt)) ∷\n-- (((inj₂ tt , tt) , inj₂ tt) , (inj₂ tt , (tt , inj₂ tt)) ∷ []\n\nt₁₃ = TIMES ZERO BOOL\nt₁₄ = ZERO\nm₁₃ = matchP {t₁₃} {t₁₄} distz\n-- []\nm₁₄ = matchP {t₁₄} {t₁₃} factorz\n-- []\n\nt₁₅ = TIMES (PLUS BOOL ONE) BOOL\nt₁₆ = PLUS (TIMES BOOL BOOL) (TIMES ONE BOOL)\nm₁₅ = matchP {t₁₅} {t₁₆} dist\n-- ((inj₁ (inj₁ tt) , inj₁ tt) , inj₁ (inj₁ tt , inj₁ tt)) ∷\n-- ((inj₁ (inj₁ tt) , inj₂ tt) , inj₁ (inj₁ tt , inj₂ tt)) ∷\n-- ((inj₁ (inj₂ tt) , inj₁ tt) , inj₁ (inj₂ tt , inj₁ tt)) ∷\n-- ((inj₁ (inj₂ tt) , inj₂ tt) , inj₁ (inj₂ tt , inj₂ tt)) ∷\n-- ((inj₂ tt , inj₁ tt) , inj₂ (tt , inj₁ tt)) ∷\n-- ((inj₂ tt , inj₂ tt) , inj₂ (tt , inj₂ tt)) ∷ []\nm₁₆ = matchP {t₁₆} {t₁₅} factor\n-- (inj₁ (inj₁ tt , inj₁ tt) , (inj₁ (inj₁ tt) , inj₁ tt)) ∷\n-- (inj₁ (inj₁ tt , inj₂ tt) , (inj₁ (inj₁ tt) , inj₂ tt)) ∷\n-- (inj₁ (inj₂ tt , inj₁ tt) , (inj₁ (inj₂ tt) , inj₁ tt)) ∷\n-- (inj₁ (inj₂ tt , inj₂ tt) , (inj₁ (inj₂ tt) , inj₂ tt)) ∷\n-- (inj₂ (tt , inj₁ tt) , (inj₂ tt , inj₁ tt)) ∷\n-- (inj₂ (tt , inj₂ tt) , (inj₂ tt , inj₂ tt)) ∷ []\n\nt₁₇ = BOOL \nt₁₈ = BOOL\nm₁₇ = matchP {t₁₇} {t₁₈} id⟷\n-- (inj₁ tt , inj₁ tt) ∷ (inj₂ tt , inj₂ tt) ∷ []\n\n--◎\n--⊕\n--⊗\n\n------------------------------------------------------------------------------\n\nmergeS :: SubPerm → SubPerm (suc m * n) (m * n) → SubPerm (suc m * suc n) (m * suc n) \nmergeS = ? \n\nsubP : ∀ {m n} → Fin (suc m) → Perm n → SubPerm (suc m * n) (m * n)\nsubP {m} {0} i β = {!!}\nsubP {m} {suc n} i (j ∷ β) = mergeS ? (subP {m} {n} i β)\n\n\n-- injectP (Perm n) (m * n) \n-- ...\n-- SP (suc m * n) (m * n)\n-- SP (n + m * n) (m * n)\n\n--SP (suc m * n) (m * n) \n--\n--\n--==> \n--\n--(suc m * suc n) (m * suc n)\n\n--m : ℕ\n--n : ℕ\n--i : Fin (suc m)\n--j : Fin (suc n)\n--β : Perm n\n--?1 : SubPerm (suc m * suc n) (m * suc n)\n\n\ntcompperm : ∀ {m n} → Perm m → Perm n → Perm (m * n)\ntcompperm [] β = []\ntcompperm (i ∷ α) β = merge (subP i β) (tcompperm α β)\n\n-- shift m=3 n=4 i=ax:F3 β=[ay:F4,by:F3,cy:F2,dy:F1] γ=[r4,...,r11]:P8\n-- ==> [F12,F11,F10,F9...γ]\n\n-- m = 3\n-- n = 4\n-- 3 * 4\n-- x = [ ax, bx, cx ] : P 3, y : [ay, by, cy, dy] : P 4\n-- (shift ax 4 y) || \n-- ( (shift bx 4 y) ||\n-- ( (shift cx 4 y) ||\n-- [])))\n-- \n-- ax : F3, bx : F2, cx : F1\n-- ay : F4, by : F3, cy : F2, dy : F1\n--\n-- suc m = 3, m = 2\n-- F12 F11 F10 F9 F8 F7 F6 F5 F4 F3 F2 F1\n-- [ r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11 ]\n-- ---------------\n-- ax : F3 with y=[F4,F3,F2,F1]\n-- --------------\n-- bx : F2\n-- ------------------\n-- cx : F1\n\n -- β should be something like i * n + entry in β\n\n{--\n0 * n = 0\n(suc m) * n = n + (m * n)\n\ncomb2perm (c₁ ⊗ c₂) = tcompperm (comb2perm c₁) (comb2perm c₂) \n\nc1 = swap+ (f->t,t->f) [1,0]\nc2 = id (f->f,t->t) [0,0]\n\nc1xc2 (f,f)->(t,f), (f,t)->(t,t), (t,f)->(f,f), (t,t)->(f,t)\n[\n\nff ft tf tt\n 2 2 0 0\n\nindex in α * n + index in β\n\n--}\n\npex qex pqex qpex : Perm 3\npex = inject+ 1 (fromℕ 1) ∷ fromℕ 1 ∷ zero ∷ []\nqex = zero ∷ fromℕ 1 ∷ zero ∷ []\npqex = fromℕ 2 ∷ fromℕ 1 ∷ zero ∷ []\nqpex = inject+ 1 (fromℕ 1) ∷ zero ∷ zero ∷ []\n\npqexv = (permute qex ∘ permute pex) (tabulate id)\npqexv' = permute pqex (tabulate id) \n\nqpexv = (permute pex ∘ permute qex) (tabulate id)\nqpexv' = permute qpex (tabulate id)\n\n-- [1,1,0]\n-- [z] => [z]\n-- [y,z] => [z,y]\n-- [x,y,z] => [z,x,y] \n\n-- [0,1,0]\n-- [w] => [w]\n-- [v,w] => [w,v]\n-- [u,v,w] => [u,w,v]\n\n-- R,R,_ ◌ _,R,_\n-- R in p1 takes you to middle which also goes R, so first goes RR\n-- [a,b,c] ◌ [d,e,f]\n-- [a+p2[a], ...]\n\n-- [1,1,0] ◌ [0,1,0] one step [2,1,0]\n-- [z] => [z]\n-- [y,z] => [z,y]\n-- [x,y,z] => [z,y,x]\n\n-- [1,1,0] ◌ [0,1,0]\n-- [z] => [z] => [z]\n-- [y,z] => \n-- [x,y,z] => \n\n-- so [1,1,0] ◌ [0,1,0] ==> [2,1,0]\n-- so [0,1,0] ◌ [1,1,0] ==> [1,0,0]\n\n-- pex takes [0,1,2] to [2,0,1]\n-- qex takes [0,1,2] to [0,2,1]\n-- pex ◌ qex takes [0,1,2] to [2,1,0]\n-- qex ◌ pex takes [0,1,2] to [1,0,2]\n\n-- seq : ∀ {m n} → (m ≤ n) → Perm m → Perm n → Perm m\n-- seq lp [] _ = []\n-- seq lp (i ∷ p) q = (lookupP i q) ∷ (seq lp p q)\n\n-- i F+ ...\n\n-- lookupP : ∀ {n} → Fin n → Perm n → Fin n\n-- i : Fin (suc m)\n-- p : Perm m\n-- q : Perm n\n\n\n-- \n-- (zero ∷ p₁) ◌ (q ∷ q₁) = q ∷ (p₁ ◌ q₁)\n-- (suc p ∷ p₁) ◌ (zero ∷ q₁) = {!!}\n-- (suc p ∷ p₁) ◌ (suc q ∷ q₁) = {!!}\n-- \n-- data Perm : ℕ → Set where\n-- [] : Perm 0\n-- _∷_ : {n : ℕ} → Fin (suc n) → Perm n → Perm (suc n)\n\n-- Given a vector of (suc n) elements, return one of the elements and\n-- the rest. Example: pick (inject+ 1 (fromℕ 1)) (10 ∷ 20 ∷ 30 ∷ 40 ∷ [])\n\npick : ∀ {ℓ} {n : ℕ} {A : Set ℓ} → Fin n → Vec A (suc n) → (A × Vec A n)\npick {ℓ} {0} {A} ()\npick {ℓ} {suc n} {A} zero (v ∷ vs) = (v , vs)\npick {ℓ} {suc n} {A} (suc i) (v ∷ vs) = \n let (w , ws) = pick {ℓ} {n} {A} i vs \n in (w , v ∷ ws)\n\ninsertV : ∀ {ℓ} {n : ℕ} {A : Set ℓ} → \n A → Fin (suc n) → Vec A n → Vec A (suc n) \ninsertV {n = 0} v zero [] = [ v ]\ninsertV {n = 0} v (suc ()) \ninsertV {n = suc n} v zero vs = v ∷ vs\ninsertV {n = suc n} v (suc i) (w ∷ ws) = w ∷ insertV v i ws\n\n-- A permutation takes two vectors of the same size, matches one\n-- element from each and returns another permutation\n\ndata P {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') : \n (m n : ℕ) → (m ≡ n) → Vec A m → Vec B n → Set (ℓ ⊔ ℓ') where\n nil : P A B 0 0 refl [] []\n cons : {m n : ℕ} {i : Fin (suc m)} {j : Fin (suc n)} → (p : m ≡ n) → \n (v : A) → (w : B) → (vs : Vec A m) → (ws : Vec B n) →\n P A B m n p vs ws → \n P A B (suc m) (suc n) (cong suc p) (insertV v i vs) (insertV w j ws)\n\n-- A permutation is a sequence of \"insertions\".\n\ninfixr 5 _∷_\n\ndata Perm : ℕ → Set where\n [] : Perm 0\n _∷_ : {n : ℕ} → Fin (suc n) → Perm n → Perm (suc n)\n\nlookupP : ∀ {n} → Fin n → Perm n → Fin n\nlookupP () [] \nlookupP zero (j ∷ _) = j\nlookupP {suc n} (suc i) (j ∷ q) = inject₁ (lookupP i q)\n\ninsert : ∀ {ℓ n} {A : Set ℓ} → Vec A n → Fin (suc n) → A → Vec A (suc n)\ninsert vs zero w = w ∷ vs\ninsert [] (suc ()) -- absurd\ninsert (v ∷ vs) (suc i) w = v ∷ insert vs i w\n\n-- A permutation acts on a vector by inserting each element in its new\n-- position.\n\npermute : ∀ {ℓ n} {A : Set ℓ} → Perm n → Vec A n → Vec A n\npermute [] [] = []\npermute (p ∷ ps) (v ∷ vs) = insert (permute ps vs) p v\n\n-- Use a permutation to match up the elements in two vectors. See more\n-- convenient function matchP below.\n\nmatch : ∀ {t t'} → (size t ≡ size t') → Perm (size t) → \n Vec ⟦ t ⟧ (size t) → Vec ⟦ t' ⟧ (size t) → \n Vec (⟦ t ⟧ × ⟦ t' ⟧) (size t)\nmatch {t} {t'} sp α vs vs' = \n let js = permute α (tabulate id)\n in zip (tabulate (λ j → lookup (lookup j js) vs)) vs'\n\n-- swap\n-- \n-- swapperm produces the permutations that maps:\n-- [ a , b || x , y , z ] \n-- to \n-- [ x , y , z || a , b ]\n-- Ex. \n-- permute (swapperm {5} (inject+ 2 (fromℕ 2))) ordered=[0,1,2,3,4]\n-- produces [2,3,4,0,1]\n-- Explicitly:\n-- swapex : Perm 5\n-- swapex = inject+ 1 (fromℕ 3) -- :: Fin 5\n-- ∷ inject+ 0 (fromℕ 3) -- :: Fin 4\n-- ∷ zero\n-- ∷ zero\n-- ∷ zero\n-- ∷ []\n\nswapperm : ∀ {n} → Fin n → Perm n\nswapperm {0} () -- absurd\nswapperm {suc n} zero = idperm\nswapperm {suc n} (suc i) = \n subst Fin (-+-id n i) \n (inject+ (toℕ i) (fromℕ (n ∸ toℕ i))) ∷ swapperm {n} i\n\n-- compositions\n\n-- Sequential composition\n\nscompperm : ∀ {n} → Perm n → Perm n → Perm n\nscompperm α β = {!!} \n\n-- Sub-permutations\n-- useful for parallel and multiplicative compositions\n\n-- Perm 4 has elements [Fin 4, Fin 3, Fin 2, Fin 1]\n-- SubPerm 11 7 has elements [Fin 11, Fin 10, Fin 9, Fin 8]\n-- So Perm 4 is a special case SubPerm 4 0\n\ndata SubPerm : ℕ → ℕ → Set where\n []s : {n : ℕ} → SubPerm n n\n _∷s_ : {n m : ℕ} → Fin (suc n) → SubPerm n m → SubPerm (suc n) m\n\nmerge : ∀ {m n} → SubPerm m n → Perm n → Perm m\nmerge []s β = β\nmerge (i ∷s α) β = i ∷ merge α β\n\ninjectP : ∀ {m} → Perm m → (n : ℕ) → SubPerm (m + n) n\ninjectP [] n = []s \ninjectP (i ∷ α) n = inject+ n i ∷s injectP α n\n \n-- Parallel + composition\n\npcompperm : ∀ {m n} → Perm m → Perm n → Perm (m + n)\npcompperm {m} {n} α β = merge (injectP α n) β\n\n-- Multiplicative * composition\n\ntcompperm : ∀ {m n} → Perm m → Perm n → Perm (m * n)\ntcompperm [] β = []\ntcompperm (i ∷ α) β = {!!} \n\n------------------------------------------------------------------------------\n-- A combinator t₁ ⟷ t₂ denotes a permutation.\n\ncomb2perm : {t₁ t₂ : U} → (c : t₁ ⟷ t₂) → Perm (size t₁)\ncomb2perm {PLUS ZERO t} {.t} unite₊ = idperm\ncomb2perm {t} {PLUS ZERO .t} uniti₊ = idperm\ncomb2perm {PLUS t₁ t₂} {PLUS .t₂ .t₁} swap₊ with size t₂\n... | 0 = idperm \n... | suc j = swapperm {size t₁ + suc j} \n (inject≤ (fromℕ (size t₁)) (suc≤ (size t₁) j))\ncomb2perm {PLUS t₁ (PLUS t₂ t₃)} {PLUS (PLUS .t₁ .t₂) .t₃} assocl₊ = idperm\ncomb2perm {PLUS (PLUS t₁ t₂) t₃} {PLUS .t₁ (PLUS .t₂ .t₃)} assocr₊ = idperm\ncomb2perm {TIMES ONE t} {.t} unite⋆ = idperm\ncomb2perm {t} {TIMES ONE .t} uniti⋆ = idperm\ncomb2perm {TIMES t₁ t₂} {TIMES .t₂ .t₁} swap⋆ = idperm \ncomb2perm assocl⋆ = idperm \ncomb2perm assocr⋆ = idperm \ncomb2perm distz = idperm \ncomb2perm factorz = idperm \ncomb2perm dist = idperm \ncomb2perm factor = idperm \ncomb2perm id⟷ = idperm \ncomb2perm (c₁ ◎ c₂) = scompperm \n (comb2perm c₁) \n (subst Perm (sym (size≡ c₁)) (comb2perm c₂))\ncomb2perm (c₁ ⊕ c₂) = pcompperm (comb2perm c₁) (comb2perm c₂) \ncomb2perm (c₁ ⊗ c₂) = tcompperm (comb2perm c₁) (comb2perm c₂) \n\n-- Convenient way of \"seeing\" what the permutation does for each combinator\n\nmatchP : ∀ {t t'} → (t ⟷ t') → Vec (⟦ t ⟧ × ⟦ t' ⟧) (size t)\nmatchP {t} {t'} c = \n match sp (comb2perm c) (utoVec t) \n (subst (λ n → Vec ⟦ t' ⟧ n) (sym sp) (utoVec t'))\n where sp = size≡ c\n\n------------------------------------------------------------------------------\n-- Extensional equivalence of combinators: two combinators are\n-- equivalent if they denote the same permutation. Generally we would\n-- require that the two permutations map the same value x to values y\n-- and z that have a path between them, but because the internals of each\n-- type are discrete groupoids, this reduces to saying that y and z\n-- are identical, and hence that the permutations are identical.\n\ninfix 10 _∼_ \n\n_∼_ : ∀ {t₁ t₂} → (c₁ c₂ : t₁ ⟷ t₂) → Set\nc₁ ∼ c₂ = (comb2perm c₁ ≡ comb2perm c₂)\n\n-- The relation ~ is an equivalence relation\n\nrefl∼ : ∀ {t₁ t₂} {c : t₁ ⟷ t₂} → (c ∼ c)\nrefl∼ = refl \n\nsym∼ : ∀ {t₁ t₂} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₂ ∼ c₁)\nsym∼ = sym\n\ntrans∼ : ∀ {t₁ t₂} {c₁ c₂ c₃ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₂ ∼ c₃) → (c₁ ∼ c₃)\ntrans∼ = trans\n\n-- The relation ~ validates the groupoid laws\n\nc◎id∼c : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ◎ id⟷ ∼ c\nc◎id∼c = {!!} \n\nid◎c∼c : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ◎ c ∼ c\nid◎c∼c = {!!} \n\nassoc∼ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} → \n c₁ ◎ (c₂ ◎ c₃) ∼ (c₁ ◎ c₂) ◎ c₃\nassoc∼ = {!!} \n\nlinv∼ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ◎ ! c ∼ id⟷\nlinv∼ = {!!} \n\nrinv∼ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → ! c ◎ c ∼ id⟷\nrinv∼ = {!!} \n\nresp∼ : {t₁ t₂ t₃ : U} {c₁ c₂ : t₁ ⟷ t₂} {c₃ c₄ : t₂ ⟷ t₃} → \n (c₁ ∼ c₂) → (c₃ ∼ c₄) → (c₁ ◎ c₃ ∼ c₂ ◎ c₄)\nresp∼ = {!!} \n\n-- The equivalence ∼ of paths makes U a 1groupoid: the points are\n-- types (t : U); the 1paths are ⟷; and the 2paths between them are\n-- based on extensional equivalence ∼\n\nG : 1Groupoid\nG = record\n { set = U\n ; _↝_ = _⟷_\n ; _≈_ = _∼_\n ; id = id⟷\n ; _∘_ = λ p q → q ◎ p\n ; _⁻¹ = !\n ; lneutr = λ c → c◎id∼c {c = c}\n ; rneutr = λ c → id◎c∼c {c = c}\n ; assoc = λ c₃ c₂ c₁ → assoc∼ {c₁ = c₁} {c₂ = c₂} {c₃ = c₃} \n ; equiv = record { \n refl = λ {c} → refl∼ {c = c}\n ; sym = λ {c₁} {c₂} → sym∼ {c₁ = c₁} {c₂ = c₂}\n ; trans = λ {c₁} {c₂} {c₃} → trans∼ {c₁ = c₁} {c₂ = c₂} {c₃ = c₃} \n }\n ; linv = λ c → linv∼ {c = c} \n ; rinv = λ c → rinv∼ {c = c} \n ; ∘-resp-≈ = λ α β → resp∼ β α \n }\n\n-- And there are additional laws\n\nassoc⊕∼ : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n c₁ ⊕ (c₂ ⊕ c₃) ∼ assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊\nassoc⊕∼ = {!!} \n\nassoc⊗∼ : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n c₁ ⊗ (c₂ ⊗ c₃) ∼ assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆\nassoc⊗∼ = {!!} \n\n------------------------------------------------------------------------------\n-- Picture so far:\n--\n-- path p\n-- =====================\n-- || || ||\n-- || ||2path ||\n-- || || ||\n-- || || path q ||\n-- t₁ =================t₂\n-- || ... ||\n-- =====================\n--\n-- The types t₁, t₂, etc are discrete groupoids. The paths between\n-- them correspond to permutations. Each syntactically different\n-- permutation corresponds to a path but equivalent permutations are\n-- connected by 2paths. But now we want an alternative definition of\n-- 2paths that is structural, i.e., that looks at the actual\n-- construction of the path t₁ ⟷ t₂ in terms of combinators... The\n-- theorem we want is that α ∼ β iff we can rewrite α to β using\n-- various syntactic structural rules. We start with a collection of\n-- simplication rules and then try to show they are complete.\n\n-- Simplification rules\n\ninfix 30 _⇔_\n\ndata _⇔_ : {t₁ t₂ : U} → (t₁ ⟷ t₂) → (t₁ ⟷ t₂) → Set where\n assoc◎l : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} → \n (c₁ ◎ (c₂ ◎ c₃)) ⇔ ((c₁ ◎ c₂) ◎ c₃)\n assoc◎r : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} → \n ((c₁ ◎ c₂) ◎ c₃) ⇔ (c₁ ◎ (c₂ ◎ c₃))\n assoc⊕l : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (c₁ ⊕ (c₂ ⊕ c₃)) ⇔ (assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊)\n assoc⊕r : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊) ⇔ (c₁ ⊕ (c₂ ⊕ c₃))\n assoc⊗l : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (c₁ ⊗ (c₂ ⊗ c₃)) ⇔ (assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆)\n assoc⊗r : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆) ⇔ (c₁ ⊗ (c₂ ⊗ c₃))\n dist⇔ : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n ((c₁ ⊕ c₂) ⊗ c₃) ⇔ (dist ◎ ((c₁ ⊗ c₃) ⊕ (c₂ ⊗ c₃)) ◎ factor)\n factor⇔ : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (dist ◎ ((c₁ ⊗ c₃) ⊕ (c₂ ⊗ c₃)) ◎ factor) ⇔ ((c₁ ⊕ c₂) ⊗ c₃)\n idl◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (id⟷ ◎ c) ⇔ c\n idl◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ id⟷ ◎ c\n idr◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (c ◎ id⟷) ⇔ c\n idr◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ (c ◎ id⟷) \n linv◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (c ◎ ! c) ⇔ id⟷\n linv◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ⇔ (c ◎ ! c) \n rinv◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (! c ◎ c) ⇔ id⟷\n rinv◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ⇔ (! c ◎ c) \n unitel₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} → \n (unite₊ ◎ c₂) ⇔ ((c₁ ⊕ c₂) ◎ unite₊)\n uniter₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} → \n ((c₁ ⊕ c₂) ◎ unite₊) ⇔ (unite₊ ◎ c₂)\n unitil₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} → \n (uniti₊ ◎ (c₁ ⊕ c₂)) ⇔ (c₂ ◎ uniti₊)\n unitir₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} → \n (c₂ ◎ uniti₊) ⇔ (uniti₊ ◎ (c₁ ⊕ c₂))\n unitial₊⇔ : {t₁ t₂ : U} → (uniti₊ {PLUS t₁ t₂} ◎ assocl₊) ⇔ (uniti₊ ⊕ id⟷)\n unitiar₊⇔ : {t₁ t₂ : U} → (uniti₊ {t₁} ⊕ id⟷ {t₂}) ⇔ (uniti₊ ◎ assocl₊)\n swapl₊⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} → \n (swap₊ ◎ (c₁ ⊕ c₂)) ⇔ ((c₂ ⊕ c₁) ◎ swap₊)\n swapr₊⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} → \n ((c₂ ⊕ c₁) ◎ swap₊) ⇔ (swap₊ ◎ (c₁ ⊕ c₂))\n unitel⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} → \n (unite⋆ ◎ c₂) ⇔ ((c₁ ⊗ c₂) ◎ unite⋆)\n uniter⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} → \n ((c₁ ⊗ c₂) ◎ unite⋆) ⇔ (unite⋆ ◎ c₂)\n unitil⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} → \n (uniti⋆ ◎ (c₁ ⊗ c₂)) ⇔ (c₂ ◎ uniti⋆)\n unitir⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} → \n (c₂ ◎ uniti⋆) ⇔ (uniti⋆ ◎ (c₁ ⊗ c₂))\n unitial⋆⇔ : {t₁ t₂ : U} → (uniti⋆ {TIMES t₁ t₂} ◎ assocl⋆) ⇔ (uniti⋆ ⊗ id⟷)\n unitiar⋆⇔ : {t₁ t₂ : U} → (uniti⋆ {t₁} ⊗ id⟷ {t₂}) ⇔ (uniti⋆ ◎ assocl⋆)\n swapl⋆⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} → \n (swap⋆ ◎ (c₁ ⊗ c₂)) ⇔ ((c₂ ⊗ c₁) ◎ swap⋆)\n swapr⋆⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} → \n ((c₂ ⊗ c₁) ◎ swap⋆) ⇔ (swap⋆ ◎ (c₁ ⊗ c₂))\n swapfl⋆⇔ : {t₁ t₂ t₃ : U} → \n (swap₊ {TIMES t₂ t₃} {TIMES t₁ t₃} ◎ factor) ⇔ \n (factor ◎ (swap₊ {t₂} {t₁} ⊗ id⟷))\n swapfr⋆⇔ : {t₁ t₂ t₃ : U} → \n (factor ◎ (swap₊ {t₂} {t₁} ⊗ id⟷)) ⇔ \n (swap₊ {TIMES t₂ t₃} {TIMES t₁ t₃} ◎ factor)\n id⇔ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ c\n trans⇔ : {t₁ t₂ : U} {c₁ c₂ c₃ : t₁ ⟷ t₂} → \n (c₁ ⇔ c₂) → (c₂ ⇔ c₃) → (c₁ ⇔ c₃)\n resp◎⇔ : {t₁ t₂ t₃ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₁ ⟷ t₂} {c₄ : t₂ ⟷ t₃} → \n (c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ◎ c₂) ⇔ (c₃ ◎ c₄)\n resp⊕⇔ : {t₁ t₂ t₃ t₄ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₁ ⟷ t₂} {c₄ : t₃ ⟷ t₄} → \n (c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ⊕ c₂) ⇔ (c₃ ⊕ c₄)\n resp⊗⇔ : {t₁ t₂ t₃ t₄ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₁ ⟷ t₂} {c₄ : t₃ ⟷ t₄} → \n (c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ⊗ c₂) ⇔ (c₃ ⊗ c₄)\n\n-- better syntax for writing 2paths\n\ninfix 2 _▤ \ninfixr 2 _⇔⟨_⟩_ \n\n_⇔⟨_⟩_ : {t₁ t₂ : U} (c₁ : t₁ ⟷ t₂) {c₂ : t₁ ⟷ t₂} {c₃ : t₁ ⟷ t₂} → \n (c₁ ⇔ c₂) → (c₂ ⇔ c₃) → (c₁ ⇔ c₃)\n_ ⇔⟨ α ⟩ β = trans⇔ α β \n\n_▤ : {t₁ t₂ : U} → (c : t₁ ⟷ t₂) → (c ⇔ c)\n_▤ c = id⇔ \n\n-- Inverses for 2paths\n\n2! : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ⇔ c₂) → (c₂ ⇔ c₁)\n2! assoc◎l = assoc◎r\n2! assoc◎r = assoc◎l\n2! assoc⊕l = assoc⊕r\n2! assoc⊕r = assoc⊕l\n2! assoc⊗l = assoc⊗r\n2! assoc⊗r = assoc⊗l\n2! dist⇔ = factor⇔ \n2! factor⇔ = dist⇔\n2! idl◎l = idl◎r\n2! idl◎r = idl◎l\n2! idr◎l = idr◎r\n2! idr◎r = idr◎l\n2! linv◎l = linv◎r\n2! linv◎r = linv◎l\n2! rinv◎l = rinv◎r\n2! rinv◎r = rinv◎l\n2! unitel₊⇔ = uniter₊⇔\n2! uniter₊⇔ = unitel₊⇔\n2! unitil₊⇔ = unitir₊⇔\n2! unitir₊⇔ = unitil₊⇔\n2! swapl₊⇔ = swapr₊⇔\n2! swapr₊⇔ = swapl₊⇔\n2! unitial₊⇔ = unitiar₊⇔ \n2! unitiar₊⇔ = unitial₊⇔ \n2! unitel⋆⇔ = uniter⋆⇔\n2! uniter⋆⇔ = unitel⋆⇔\n2! unitil⋆⇔ = unitir⋆⇔\n2! unitir⋆⇔ = unitil⋆⇔\n2! unitial⋆⇔ = unitiar⋆⇔ \n2! unitiar⋆⇔ = unitial⋆⇔ \n2! swapl⋆⇔ = swapr⋆⇔\n2! swapr⋆⇔ = swapl⋆⇔\n2! swapfl⋆⇔ = swapfr⋆⇔\n2! swapfr⋆⇔ = swapfl⋆⇔\n2! id⇔ = id⇔\n2! (trans⇔ α β) = trans⇔ (2! β) (2! α)\n2! (resp◎⇔ α β) = resp◎⇔ (2! α) (2! β)\n2! (resp⊕⇔ α β) = resp⊕⇔ (2! α) (2! β)\n2! (resp⊗⇔ α β) = resp⊗⇔ (2! α) (2! β) \n\n-- a nice example of 2 paths\n\nnegEx : neg₅ ⇔ neg₁\nnegEx = uniti⋆ ◎ (swap⋆ ◎ ((swap₊ ⊗ id⟷) ◎ (swap⋆ ◎ unite⋆)))\n ⇔⟨ resp◎⇔ id⇔ assoc◎l ⟩\n uniti⋆ ◎ ((swap⋆ ◎ (swap₊ ⊗ id⟷)) ◎ (swap⋆ ◎ unite⋆))\n ⇔⟨ resp◎⇔ id⇔ (resp◎⇔ swapl⋆⇔ id⇔) ⟩\n uniti⋆ ◎ (((id⟷ ⊗ swap₊) ◎ swap⋆) ◎ (swap⋆ ◎ unite⋆))\n ⇔⟨ resp◎⇔ id⇔ assoc◎r ⟩\n uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ (swap⋆ ◎ (swap⋆ ◎ unite⋆)))\n ⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ assoc◎l) ⟩\n uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ ((swap⋆ ◎ swap⋆) ◎ unite⋆))\n ⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ (resp◎⇔ linv◎l id⇔)) ⟩\n uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ (id⟷ ◎ unite⋆))\n ⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ idl◎l) ⟩\n uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ unite⋆)\n ⇔⟨ assoc◎l ⟩\n (uniti⋆ ◎ (id⟷ ⊗ swap₊)) ◎ unite⋆\n ⇔⟨ resp◎⇔ unitil⋆⇔ id⇔ ⟩\n (swap₊ ◎ uniti⋆) ◎ unite⋆\n ⇔⟨ assoc◎r ⟩\n swap₊ ◎ (uniti⋆ ◎ unite⋆)\n ⇔⟨ resp◎⇔ id⇔ linv◎l ⟩\n swap₊ ◎ id⟷\n ⇔⟨ idr◎l ⟩\n swap₊ ▤\n\n-- The equivalence ⇔ of paths is rich enough to make U a 1groupoid:\n-- the points are types (t : U); the 1paths are ⟷; and the 2paths\n-- between them are based on the simplification rules ⇔ \n\nG' : 1Groupoid\nG' = record\n { set = U\n ; _↝_ = _⟷_\n ; _≈_ = _⇔_\n ; id = id⟷\n ; _∘_ = λ p q → q ◎ p\n ; _⁻¹ = !\n ; lneutr = λ _ → idr◎l\n ; rneutr = λ _ → idl◎l\n ; assoc = λ _ _ _ → assoc◎l\n ; equiv = record { \n refl = id⇔\n ; sym = 2!\n ; trans = trans⇔\n }\n ; linv = λ {t₁} {t₂} α → linv◎l\n ; rinv = λ {t₁} {t₂} α → rinv◎l\n ; ∘-resp-≈ = λ p∼q r∼s → resp◎⇔ r∼s p∼q \n }\n\n------------------------------------------------------------------------------\n-- Inverting permutations to syntactic combinators\n\nperm2comb : {t₁ t₂ : U} → (size t₁ ≡ size t₂) → Perm (size t₁) → (t₁ ⟷ t₂)\nperm2comb {ZERO} {t₂} sp [] = {!!} \nperm2comb {ONE} {t₂} sp p = {!!} \nperm2comb {PLUS t₁ t₂} {t₃} sp p = {!!} \nperm2comb {TIMES t₁ t₂} {t₃} sp p = {!!} \n\n------------------------------------------------------------------------------\n-- Soundness and completeness\n-- \n-- Proof of soundness and completeness: now we want to verify that ⇔\n-- is sound and complete with respect to ∼. The statement to prove is\n-- that for all c₁ and c₂, we have c₁ ∼ c₂ iff c₁ ⇔ c₂\n\nsoundness : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ⇔ c₂) → (c₁ ∼ c₂)\nsoundness assoc◎l = assoc∼\nsoundness assoc◎r = sym∼ assoc∼\nsoundness assoc⊕l = assoc⊕∼\nsoundness assoc⊕r = sym∼ assoc⊕∼\nsoundness assoc⊗l = assoc⊗∼\nsoundness assoc⊗r = sym∼ assoc⊗∼\nsoundness dist⇔ = {!!}\nsoundness factor⇔ = {!!}\nsoundness idl◎l = id◎c∼c\nsoundness idl◎r = sym∼ id◎c∼c\nsoundness idr◎l = c◎id∼c\nsoundness idr◎r = sym∼ c◎id∼c\nsoundness linv◎l = linv∼\nsoundness linv◎r = sym∼ linv∼\nsoundness rinv◎l = rinv∼\nsoundness rinv◎r = sym∼ rinv∼\nsoundness unitel₊⇔ = {!!}\nsoundness uniter₊⇔ = {!!}\nsoundness unitil₊⇔ = {!!}\nsoundness unitir₊⇔ = {!!}\nsoundness unitial₊⇔ = {!!}\nsoundness unitiar₊⇔ = {!!}\nsoundness swapl₊⇔ = {!!}\nsoundness swapr₊⇔ = {!!}\nsoundness unitel⋆⇔ = {!!}\nsoundness uniter⋆⇔ = {!!}\nsoundness unitil⋆⇔ = {!!}\nsoundness unitir⋆⇔ = {!!}\nsoundness unitial⋆⇔ = {!!}\nsoundness unitiar⋆⇔ = {!!}\nsoundness swapl⋆⇔ = {!!}\nsoundness swapr⋆⇔ = {!!}\nsoundness swapfl⋆⇔ = {!!}\nsoundness swapfr⋆⇔ = {!!}\nsoundness id⇔ = refl∼\nsoundness (trans⇔ α β) = trans∼ (soundness α) (soundness β)\nsoundness (resp◎⇔ α β) = resp∼ (soundness α) (soundness β)\nsoundness (resp⊕⇔ α β) = {!!}\nsoundness (resp⊗⇔ α β) = {!!} \n\n-- The idea is to invert evaluation and use that to extract from each\n-- extensional representation of a combinator, a canonical syntactic\n-- representative\n\ncanonical : {t₁ t₂ : U} → (t₁ ⟷ t₂) → (t₁ ⟷ t₂)\ncanonical c = perm2comb (size≡ c) (comb2perm c)\n\n-- Note that if c₁ ⇔ c₂, then by soundness c₁ ∼ c₂ and hence their\n-- canonical representatives are identical. \n\ncanonicalWellDefined : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → \n (c₁ ⇔ c₂) → (canonical c₁ ≡ canonical c₂)\ncanonicalWellDefined {t₁} {t₂} {c₁} {c₂} α = \n cong₂ perm2comb (size∼ c₁ c₂) (soundness α) \n\n-- If we can prove that every combinator is equal to its normal form\n-- then we can prove completeness.\n\ninversion : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ canonical c\ninversion = {!!} \n\nresp≡⇔ : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ≡ c₂) → (c₁ ⇔ c₂)\nresp≡⇔ {t₁} {t₂} {c₁} {c₂} p rewrite p = id⇔ \n\ncompleteness : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₁ ⇔ c₂)\ncompleteness {t₁} {t₂} {c₁} {c₂} c₁∼c₂ = \n c₁\n ⇔⟨ inversion ⟩\n canonical c₁\n ⇔⟨ resp≡⇔ (cong₂ perm2comb (size∼ c₁ c₂) c₁∼c₂) ⟩ \n canonical c₂\n ⇔⟨ 2! inversion ⟩ \n c₂ ▤\n\n------------------------------------------------------------------------------\n\n------------------------------------------------------------------------------\n-- Nat and Fin lemmas\n\nsuc≤ : (m n : ℕ) → suc m ≤ m + suc n\nsuc≤ 0 n = s≤s z≤n\nsuc≤ (suc m) n = s≤s (suc≤ m n)\n\n-+-id : (n : ℕ) → (i : Fin n) → suc (n ∸ toℕ i) + toℕ i ≡ suc n\n-+-id 0 () -- absurd\n-+-id (suc n) zero = +-right-identity (suc (suc n))\n-+-id (suc n) (suc i) = begin\n suc (suc n ∸ toℕ (suc i)) + toℕ (suc i) \n ≡⟨ refl ⟩\n suc (n ∸ toℕ i) + suc (toℕ i) \n ≡⟨ +-suc (suc (n ∸ toℕ i)) (toℕ i) ⟩\n suc (suc (n ∸ toℕ i) + toℕ i)\n ≡⟨ cong suc (-+-id n i) ⟩\n suc (suc n) ∎\n\np0 p1 : Perm 4\np0 = idπ\np1 = swap (inject+ 1 (fromℕ 2)) (inject+ 3 (fromℕ 0))\n (swap (fromℕ 3) zero\n (swap zero (inject+ 1 (fromℕ 2))\n idπ))\n\n\nxx = action p1 (10 ∷ 20 ∷ 30 ∷ 40 ∷ [])\n\nn≤sn : ∀ {x} → x ≤ suc x\nn≤sn {0} = z≤n\nn≤sn {suc n} = s≤s (n≤sn {n})\n\n 2 * 3\n-- (zero , zero) ∷\n-- (suc zero , suc (suc (suc zero))) ∷\n-- (suc (suc zero) , suc zero) ∷\n-- (suc (suc (suc zero)) , suc (suc (suc (suc zero)))) ∷\n-- (suc (suc (suc (suc zero))) , suc (suc zero)) ∷ []\n\n{--\n------------------------------------------------------------------------------\n-- Extensional equivalence of combinators: two combinators are\n-- equivalent if they denote the same permutation. Generally we would\n-- require that the two permutations map the same value x to values y\n-- and z that have a path between them, but because the internals of each\n-- type are discrete groupoids, this reduces to saying that y and z\n-- are identical, and hence that the permutations are identical.\n\nnormalize : ∀ {n} → Perm n → Perm< n\nnormalize = sort ∘ filter=\n\ninfix 10 _∼_ \n\n_∼_ : ∀ {t₁ t₂} → (c₁ c₂ : t₁ ⟷ t₂) → Set\nc₁ ∼ c₂ = (normalize (c2π c₁) ≡ normalize (c2π c₂))\n\n-- The relation ~ is an equivalence relation\n\nrefl∼ : ∀ {t₁ t₂} {c : t₁ ⟷ t₂} → (c ∼ c)\nrefl∼ = refl \n\nsym∼ : ∀ {t₁ t₂} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₂ ∼ c₁)\nsym∼ = sym\n\ntrans∼ : ∀ {t₁ t₂} {c₁ c₂ c₃ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₂ ∼ c₃) → (c₁ ∼ c₃)\ntrans∼ = trans\n\n-- The relation ~ validates the groupoid laws\n\nc◎id∼c : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ◎ id⟷ ∼ c\nc◎id∼c = {!!} \n\nid◎c∼c : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ◎ c ∼ c\nid◎c∼c = {!!} \n\nassoc∼ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} → \n c₁ ◎ (c₂ ◎ c₃) ∼ (c₁ ◎ c₂) ◎ c₃\nassoc∼ = {!!} \n\nlinv∼ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ◎ ! c ∼ id⟷\nlinv∼ = {!!} \n\nrinv∼ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → ! c ◎ c ∼ id⟷\nrinv∼ = {!!} \n\nresp∼ : {t₁ t₂ t₃ : U} {c₁ c₂ : t₁ ⟷ t₂} {c₃ c₄ : t₂ ⟷ t₃} → \n (c₁ ∼ c₂) → (c₃ ∼ c₄) → (c₁ ◎ c₃ ∼ c₂ ◎ c₄)\nresp∼ = {!!} \n\n-- The equivalence ∼ of paths makes U a 1groupoid: the points are\n-- types (t : U); the 1paths are ⟷; and the 2paths between them are\n-- based on extensional equivalence ∼\n\nG : 1Groupoid\nG = record\n { set = U\n ; _↝_ = _⟷_\n ; _≈_ = _∼_\n ; id = id⟷\n ; _∘_ = λ p q → q ◎ p\n ; _⁻¹ = !\n ; lneutr = λ c → c◎id∼c {c = c}\n ; rneutr = λ c → id◎c∼c {c = c}\n ; assoc = λ c₃ c₂ c₁ → assoc∼ {c₁ = c₁} {c₂ = c₂} {c₃ = c₃} \n ; equiv = record { \n refl = λ {c} → refl∼ {c = c}\n ; sym = λ {c₁} {c₂} → sym∼ {c₁ = c₁} {c₂ = c₂}\n ; trans = λ {c₁} {c₂} {c₃} → trans∼ {c₁ = c₁} {c₂ = c₂} {c₃ = c₃} \n }\n ; linv = λ c → linv∼ {c = c} \n ; rinv = λ c → rinv∼ {c = c} \n ; ∘-resp-≈ = {!!} -- λ α β → resp∼ β α \n }\n\n-- And there are additional laws\n\nassoc⊕∼ : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n c₁ ⊕ (c₂ ⊕ c₃) ∼ assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊\nassoc⊕∼ = {!!} \n\nassoc⊗∼ : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n c₁ ⊗ (c₂ ⊗ c₃) ∼ assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆\nassoc⊗∼ = {!!} \n\n------------------------------------------------------------------------------\n-- Picture so far:\n--\n-- path p\n-- =====================\n-- || || ||\n-- || ||2path ||\n-- || || ||\n-- || || path q ||\n-- t₁ =================t₂\n-- || ... ||\n-- =====================\n--\n-- The types t₁, t₂, etc are discrete groupoids. The paths between\n-- them correspond to permutations. Each syntactically different\n-- permutation corresponds to a path but equivalent permutations are\n-- connected by 2paths. But now we want an alternative definition of\n-- 2paths that is structural, i.e., that looks at the actual\n-- construction of the path t₁ ⟷ t₂ in terms of combinators... The\n-- theorem we want is that α ∼ β iff we can rewrite α to β using\n-- various syntactic structural rules. We start with a collection of\n-- simplication rules and then try to show they are complete.\n\n-- Simplification rules\n\ninfix 30 _⇔_\n\ndata _⇔_ : {t₁ t₂ : U} → (t₁ ⟷ t₂) → (t₁ ⟷ t₂) → Set where\n assoc◎l : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} → \n (c₁ ◎ (c₂ ◎ c₃)) ⇔ ((c₁ ◎ c₂) ◎ c₃)\n assoc◎r : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} → \n ((c₁ ◎ c₂) ◎ c₃) ⇔ (c₁ ◎ (c₂ ◎ c₃))\n assoc⊕l : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (c₁ ⊕ (c₂ ⊕ c₃)) ⇔ (assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊)\n assoc⊕r : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊) ⇔ (c₁ ⊕ (c₂ ⊕ c₃))\n assoc⊗l : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (c₁ ⊗ (c₂ ⊗ c₃)) ⇔ (assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆)\n assoc⊗r : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆) ⇔ (c₁ ⊗ (c₂ ⊗ c₃))\n dist⇔ : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n ((c₁ ⊕ c₂) ⊗ c₃) ⇔ (dist ◎ ((c₁ ⊗ c₃) ⊕ (c₂ ⊗ c₃)) ◎ factor)\n factor⇔ : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (dist ◎ ((c₁ ⊗ c₃) ⊕ (c₂ ⊗ c₃)) ◎ factor) ⇔ ((c₁ ⊕ c₂) ⊗ c₃)\n idl◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (id⟷ ◎ c) ⇔ c\n idl◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ id⟷ ◎ c\n idr◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (c ◎ id⟷) ⇔ c\n idr◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ (c ◎ id⟷) \n linv◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (c ◎ ! c) ⇔ id⟷\n linv◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ⇔ (c ◎ ! c) \n rinv◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (! c ◎ c) ⇔ id⟷\n rinv◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ⇔ (! c ◎ c) \n unitel₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} → \n (unite₊ ◎ c₂) ⇔ ((c₁ ⊕ c₂) ◎ unite₊)\n uniter₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} → \n ((c₁ ⊕ c₂) ◎ unite₊) ⇔ (unite₊ ◎ c₂)\n unitil₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} → \n (uniti₊ ◎ (c₁ ⊕ c₂)) ⇔ (c₂ ◎ uniti₊)\n unitir₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} → \n (c₂ ◎ uniti₊) ⇔ (uniti₊ ◎ (c₁ ⊕ c₂))\n unitial₊⇔ : {t₁ t₂ : U} → (uniti₊ {PLUS t₁ t₂} ◎ assocl₊) ⇔ (uniti₊ ⊕ id⟷)\n unitiar₊⇔ : {t₁ t₂ : U} → (uniti₊ {t₁} ⊕ id⟷ {t₂}) ⇔ (uniti₊ ◎ assocl₊)\n swapl₊⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} → \n (swap₊ ◎ (c₁ ⊕ c₂)) ⇔ ((c₂ ⊕ c₁) ◎ swap₊)\n swapr₊⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} → \n ((c₂ ⊕ c₁) ◎ swap₊) ⇔ (swap₊ ◎ (c₁ ⊕ c₂))\n unitel⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} → \n (unite⋆ ◎ c₂) ⇔ ((c₁ ⊗ c₂) ◎ unite⋆)\n uniter⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} → \n ((c₁ ⊗ c₂) ◎ unite⋆) ⇔ (unite⋆ ◎ c₂)\n unitil⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} → \n (uniti⋆ ◎ (c₁ ⊗ c₂)) ⇔ (c₂ ◎ uniti⋆)\n unitir⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} → \n (c₂ ◎ uniti⋆) ⇔ (uniti⋆ ◎ (c₁ ⊗ c₂))\n unitial⋆⇔ : {t₁ t₂ : U} → (uniti⋆ {TIMES t₁ t₂} ◎ assocl⋆) ⇔ (uniti⋆ ⊗ id⟷)\n unitiar⋆⇔ : {t₁ t₂ : U} → (uniti⋆ {t₁} ⊗ id⟷ {t₂}) ⇔ (uniti⋆ ◎ assocl⋆)\n swapl⋆⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} → \n (swap⋆ ◎ (c₁ ⊗ c₂)) ⇔ ((c₂ ⊗ c₁) ◎ swap⋆)\n swapr⋆⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} → \n ((c₂ ⊗ c₁) ◎ swap⋆) ⇔ (swap⋆ ◎ (c₁ ⊗ c₂))\n swapfl⋆⇔ : {t₁ t₂ t₃ : U} → \n (swap₊ {TIMES t₂ t₃} {TIMES t₁ t₃} ◎ factor) ⇔ \n (factor ◎ (swap₊ {t₂} {t₁} ⊗ id⟷))\n swapfr⋆⇔ : {t₁ t₂ t₃ : U} → \n (factor ◎ (swap₊ {t₂} {t₁} ⊗ id⟷)) ⇔ \n (swap₊ {TIMES t₂ t₃} {TIMES t₁ t₃} ◎ factor)\n id⇔ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ c\n trans⇔ : {t₁ t₂ : U} {c₁ c₂ c₃ : t₁ ⟷ t₂} → \n (c₁ ⇔ c₂) → (c₂ ⇔ c₃) → (c₁ ⇔ c₃)\n resp◎⇔ : {t₁ t₂ t₃ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₁ ⟷ t₂} {c₄ : t₂ ⟷ t₃} → \n (c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ◎ c₂) ⇔ (c₃ ◎ c₄)\n resp⊕⇔ : {t₁ t₂ t₃ t₄ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₁ ⟷ t₂} {c₄ : t₃ ⟷ t₄} → \n (c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ⊕ c₂) ⇔ (c₃ ⊕ c₄)\n resp⊗⇔ : {t₁ t₂ t₃ t₄ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₁ ⟷ t₂} {c₄ : t₃ ⟷ t₄} → \n (c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ⊗ c₂) ⇔ (c₃ ⊗ c₄)\n\n-- better syntax for writing 2paths\n\ninfix 2 _▤ \ninfixr 2 _⇔⟨_⟩_ \n\n_⇔⟨_⟩_ : {t₁ t₂ : U} (c₁ : t₁ ⟷ t₂) {c₂ : t₁ ⟷ t₂} {c₃ : t₁ ⟷ t₂} → \n (c₁ ⇔ c₂) → (c₂ ⇔ c₃) → (c₁ ⇔ c₃)\n_ ⇔⟨ α ⟩ β = trans⇔ α β \n\n_▤ : {t₁ t₂ : U} → (c : t₁ ⟷ t₂) → (c ⇔ c)\n_▤ c = id⇔ \n\n-- Inverses for 2paths\n\n2! : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ⇔ c₂) → (c₂ ⇔ c₁)\n2! assoc◎l = assoc◎r\n2! assoc◎r = assoc◎l\n2! assoc⊕l = assoc⊕r\n2! assoc⊕r = assoc⊕l\n2! assoc⊗l = assoc⊗r\n2! assoc⊗r = assoc⊗l\n2! dist⇔ = factor⇔ \n2! factor⇔ = dist⇔\n2! idl◎l = idl◎r\n2! idl◎r = idl◎l\n2! idr◎l = idr◎r\n2! idr◎r = idr◎l\n2! linv◎l = linv◎r\n2! linv◎r = linv◎l\n2! rinv◎l = rinv◎r\n2! rinv◎r = rinv◎l\n2! unitel₊⇔ = uniter₊⇔\n2! uniter₊⇔ = unitel₊⇔\n2! unitil₊⇔ = unitir₊⇔\n2! unitir₊⇔ = unitil₊⇔\n2! swapl₊⇔ = swapr₊⇔\n2! swapr₊⇔ = swapl₊⇔\n2! unitial₊⇔ = unitiar₊⇔ \n2! unitiar₊⇔ = unitial₊⇔ \n2! unitel⋆⇔ = uniter⋆⇔\n2! uniter⋆⇔ = unitel⋆⇔\n2! unitil⋆⇔ = unitir⋆⇔\n2! unitir⋆⇔ = unitil⋆⇔\n2! unitial⋆⇔ = unitiar⋆⇔ \n2! unitiar⋆⇔ = unitial⋆⇔ \n2! swapl⋆⇔ = swapr⋆⇔\n2! swapr⋆⇔ = swapl⋆⇔\n2! swapfl⋆⇔ = swapfr⋆⇔\n2! swapfr⋆⇔ = swapfl⋆⇔\n2! id⇔ = id⇔\n2! (trans⇔ α β) = trans⇔ (2! β) (2! α)\n2! (resp◎⇔ α β) = resp◎⇔ (2! α) (2! β)\n2! (resp⊕⇔ α β) = resp⊕⇔ (2! α) (2! β)\n2! (resp⊗⇔ α β) = resp⊗⇔ (2! α) (2! β) \n\n-- a nice example of 2 paths\n\nnegEx : neg₅ ⇔ neg₁\nnegEx = uniti⋆ ◎ (swap⋆ ◎ ((swap₊ ⊗ id⟷) ◎ (swap⋆ ◎ unite⋆)))\n ⇔⟨ resp◎⇔ id⇔ assoc◎l ⟩\n uniti⋆ ◎ ((swap⋆ ◎ (swap₊ ⊗ id⟷)) ◎ (swap⋆ ◎ unite⋆))\n ⇔⟨ resp◎⇔ id⇔ (resp◎⇔ swapl⋆⇔ id⇔) ⟩\n uniti⋆ ◎ (((id⟷ ⊗ swap₊) ◎ swap⋆) ◎ (swap⋆ ◎ unite⋆))\n ⇔⟨ resp◎⇔ id⇔ assoc◎r ⟩\n uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ (swap⋆ ◎ (swap⋆ ◎ unite⋆)))\n ⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ assoc◎l) ⟩\n uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ ((swap⋆ ◎ swap⋆) ◎ unite⋆))\n ⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ (resp◎⇔ linv◎l id⇔)) ⟩\n uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ (id⟷ ◎ unite⋆))\n ⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ idl◎l) ⟩\n uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ unite⋆)\n ⇔⟨ assoc◎l ⟩\n (uniti⋆ ◎ (id⟷ ⊗ swap₊)) ◎ unite⋆\n ⇔⟨ resp◎⇔ unitil⋆⇔ id⇔ ⟩\n (swap₊ ◎ uniti⋆) ◎ unite⋆\n ⇔⟨ assoc◎r ⟩\n swap₊ ◎ (uniti⋆ ◎ unite⋆)\n ⇔⟨ resp◎⇔ id⇔ linv◎l ⟩\n swap₊ ◎ id⟷\n ⇔⟨ idr◎l ⟩\n swap₊ ▤\n\n-- The equivalence ⇔ of paths is rich enough to make U a 1groupoid:\n-- the points are types (t : U); the 1paths are ⟷; and the 2paths\n-- between them are based on the simplification rules ⇔ \n\nG' : 1Groupoid\nG' = record\n { set = U\n ; _↝_ = _⟷_\n ; _≈_ = _⇔_\n ; id = id⟷\n ; _∘_ = λ p q → q ◎ p\n ; _⁻¹ = !\n ; lneutr = λ _ → idr◎l\n ; rneutr = λ _ → idl◎l\n ; assoc = λ _ _ _ → assoc◎l\n ; equiv = record { \n refl = id⇔\n ; sym = 2!\n ; trans = trans⇔\n }\n ; linv = λ {t₁} {t₂} α → linv◎l\n ; rinv = λ {t₁} {t₂} α → rinv◎l\n ; ∘-resp-≈ = λ p∼q r∼s → resp◎⇔ r∼s p∼q \n }\n\n------------------------------------------------------------------------------\n-- Inverting permutations to syntactic combinators\n\nπ2c : {t₁ t₂ : U} → (size t₁ ≡ size t₂) → NPerm (size t₁) → (t₁ ⟷ t₂)\nπ2c = {!!}\n\n------------------------------------------------------------------------------\n-- Soundness and completeness\n-- \n-- Proof of soundness and completeness: now we want to verify that ⇔\n-- is sound and complete with respect to ∼. The statement to prove is\n-- that for all c₁ and c₂, we have c₁ ∼ c₂ iff c₁ ⇔ c₂\n\nsoundness : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ⇔ c₂) → (c₁ ∼ c₂)\nsoundness assoc◎l = {!!} -- assoc∼\nsoundness assoc◎r = {!!} -- sym∼ assoc∼\nsoundness assoc⊕l = {!!} -- assoc⊕∼\nsoundness assoc⊕r = {!!} -- sym∼ assoc⊕∼\nsoundness assoc⊗l = {!!} -- assoc⊗∼\nsoundness assoc⊗r = {!!} -- sym∼ assoc⊗∼\nsoundness dist⇔ = {!!}\nsoundness factor⇔ = {!!}\nsoundness idl◎l = {!!} -- id◎c∼c\nsoundness idl◎r = {!!} -- sym∼ id◎c∼c\nsoundness idr◎l = {!!} -- c◎id∼c\nsoundness idr◎r = {!!} -- sym∼ c◎id∼c\nsoundness linv◎l = {!!} -- linv∼\nsoundness linv◎r = {!!} -- sym∼ linv∼\nsoundness rinv◎l = {!!} -- rinv∼\nsoundness rinv◎r = {!!} -- sym∼ rinv∼\nsoundness unitel₊⇔ = {!!}\nsoundness uniter₊⇔ = {!!}\nsoundness unitil₊⇔ = {!!}\nsoundness unitir₊⇔ = {!!}\nsoundness unitial₊⇔ = {!!}\nsoundness unitiar₊⇔ = {!!}\nsoundness swapl₊⇔ = {!!}\nsoundness swapr₊⇔ = {!!}\nsoundness unitel⋆⇔ = {!!}\nsoundness uniter⋆⇔ = {!!}\nsoundness unitil⋆⇔ = {!!}\nsoundness unitir⋆⇔ = {!!}\nsoundness unitial⋆⇔ = {!!}\nsoundness unitiar⋆⇔ = {!!}\nsoundness swapl⋆⇔ = {!!}\nsoundness swapr⋆⇔ = {!!}\nsoundness swapfl⋆⇔ = {!!}\nsoundness swapfr⋆⇔ = {!!}\nsoundness id⇔ = {!!} -- refl∼\nsoundness (trans⇔ α β) = {!!} -- trans∼ (soundness α) (soundness β)\nsoundness (resp◎⇔ α β) = {!!} -- resp∼ (soundness α) (soundness β)\nsoundness (resp⊕⇔ α β) = {!!}\nsoundness (resp⊗⇔ α β) = {!!} \n\n-- The idea is to invert evaluation and use that to extract from each\n-- extensional representation of a combinator, a canonical syntactic\n-- representative\n\ncanonical : {t₁ t₂ : U} → (t₁ ⟷ t₂) → (t₁ ⟷ t₂)\ncanonical c = π2c (size≡ c) (normalize (c2π c))\n\n-- Note that if c₁ ⇔ c₂, then by soundness c₁ ∼ c₂ and hence their\n-- canonical representatives are identical. \n\ncanonicalWellDefined : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → \n (c₁ ⇔ c₂) → (canonical c₁ ≡ canonical c₂)\ncanonicalWellDefined {t₁} {t₂} {c₁} {c₂} α = \n cong₂ π2c (size∼ c₁ c₂) (soundness α) \n\n-- If we can prove that every combinator is equal to its normal form\n-- then we can prove completeness.\n\ninversion : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ canonical c\ninversion = {!!} \n\nresp≡⇔ : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ≡ c₂) → (c₁ ⇔ c₂)\nresp≡⇔ {t₁} {t₂} {c₁} {c₂} p rewrite p = id⇔ \n\ncompleteness : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₁ ⇔ c₂)\ncompleteness {t₁} {t₂} {c₁} {c₂} c₁∼c₂ = \n c₁\n ⇔⟨ inversion ⟩\n canonical c₁\n ⇔⟨ resp≡⇔ (cong₂ π2c (size∼ c₁ c₂) c₁∼c₂) ⟩ \n canonical c₂\n ⇔⟨ 2! inversion ⟩ \n c₂ ▤\n\n------------------------------------------------------------------------------\n\n-- normalize a finite type to (1 + (1 + (1 + ... + (1 + 0) ... )))\n-- a bunch of ones ending with zero with left biased + in between\n\ntoℕ : U → ℕ\ntoℕ ZERO = 0\ntoℕ ONE = 1\ntoℕ (PLUS t₁ t₂) = toℕ t₁ + toℕ t₂\ntoℕ (TIMES t₁ t₂) = toℕ t₁ * toℕ t₂\n\nfromℕ : ℕ → U\nfromℕ 0 = ZERO\nfromℕ (suc n) = PLUS ONE (fromℕ n)\n\nnormalℕ : U → U\nnormalℕ = fromℕ ∘ toℕ\n\n-- invert toℕ: give t and n such that toℕ t = n, return constraints on components of t\n\nreflectPlusZero : {m n : ℕ} → (m + n ≡ 0) → m ≡ 0 × n ≡ 0\nreflectPlusZero {0} {0} refl = (refl , refl)\nreflectPlusZero {0} {suc n} ()\nreflectPlusZero {suc m} {0} ()\nreflectPlusZero {suc m} {suc n} ()\n\n-- nbe\n\nnbe : {t₁ t₂ : U} → (p : toℕ t₁ ≡ toℕ t₂) → (⟦ t₁ ⟧ → ⟦ t₂ ⟧) → (t₁ ⟷ t₂)\nnbe {ZERO} {ZERO} refl f = id⟷\nnbe {ZERO} {ONE} ()\nnbe {ZERO} {PLUS t₁ t₂} p f = {!!} \nnbe {ZERO} {TIMES t₂ t₃} p f = {!!}\nnbe {ONE} {ZERO} ()\nnbe {ONE} {ONE} p f = id⟷\nnbe {ONE} {PLUS t₂ t₃} p f = {!!}\nnbe {ONE} {TIMES t₂ t₃} p f = {!!}\nnbe {PLUS t₁ t₂} {ZERO} p f = {!!}\nnbe {PLUS t₁ t₂} {ONE} p f = {!!}\nnbe {PLUS t₁ t₂} {PLUS t₃ t₄} p f = {!!}\nnbe {PLUS t₁ t₂} {TIMES t₃ t₄} p f = {!!}\nnbe {TIMES t₁ t₂} {ZERO} p f = {!!}\nnbe {TIMES t₁ t₂} {ONE} p f = {!!}\nnbe {TIMES t₁ t₂} {PLUS t₃ t₄} p f = {!!}\nnbe {TIMES t₁ t₂} {TIMES t₃ t₄} p f = {!!} \n\n-- build a combinator that does the normalization\n\nassocrU : {m : ℕ} (n : ℕ) → (PLUS (fromℕ n) (fromℕ m)) ⟷ fromℕ (n + m)\nassocrU 0 = unite₊\nassocrU (suc n) = assocr₊ ◎ (id⟷ ⊕ assocrU n)\n\ndistrU : (m : ℕ) {n : ℕ} → TIMES (fromℕ m) (fromℕ n) ⟷ fromℕ (m * n)\ndistrU 0 = distz\ndistrU (suc n) {m} = dist ◎ (unite⋆ ⊕ distrU n) ◎ assocrU m\n\nnormalU : (t : U) → t ⟷ normalℕ t\nnormalU ZERO = id⟷\nnormalU ONE = uniti₊ ◎ swap₊\nnormalU (PLUS t₁ t₂) = (normalU t₁ ⊕ normalU t₂) ◎ assocrU (toℕ t₁)\nnormalU (TIMES t₁ t₂) = (normalU t₁ ⊗ normalU t₂) ◎ distrU (toℕ t₁)\n\n-- a few lemmas\n\nfromℕplus : {m n : ℕ} → fromℕ (m + n) ⟷ PLUS (fromℕ m) (fromℕ n)\nfromℕplus {0} {n} = \n fromℕ n\n ⟷⟨ uniti₊ ⟩\n PLUS ZERO (fromℕ n) □\nfromℕplus {suc m} {n} = \n fromℕ (suc (m + n))\n ⟷⟨ id⟷ ⟩ \n PLUS ONE (fromℕ (m + n))\n ⟷⟨ id⟷ ⊕ fromℕplus {m} {n} ⟩ \n PLUS ONE (PLUS (fromℕ m) (fromℕ n))\n ⟷⟨ assocl₊ ⟩ \n PLUS (PLUS ONE (fromℕ m)) (fromℕ n)\n ⟷⟨ id⟷ ⟩ \n PLUS (fromℕ (suc m)) (fromℕ n) □\n\nnormalℕswap : {t₁ t₂ : U} → normalℕ (PLUS t₁ t₂) ⟷ normalℕ (PLUS t₂ t₁)\nnormalℕswap {t₁} {t₂} = \n fromℕ (toℕ t₁ + toℕ t₂) \n ⟷⟨ fromℕplus {toℕ t₁} {toℕ t₂} ⟩\n PLUS (normalℕ t₁) (normalℕ t₂)\n ⟷⟨ swap₊ ⟩\n PLUS (normalℕ t₂) (normalℕ t₁)\n ⟷⟨ ! (fromℕplus {toℕ t₂} {toℕ t₁}) ⟩\n fromℕ (toℕ t₂ + toℕ t₁) □\n\nassocrUS : {m : ℕ} {t : U} → PLUS t (fromℕ m) ⟷ fromℕ (toℕ t + m)\nassocrUS {m} {ZERO} = unite₊\nassocrUS {m} {ONE} = id⟷\nassocrUS {m} {t} = \n PLUS t (fromℕ m)\n ⟷⟨ normalU t ⊕ id⟷ ⟩\n PLUS (normalℕ t) (fromℕ m)\n ⟷⟨ ! fromℕplus ⟩\n fromℕ (toℕ t + m) □\n\n-- convert each combinator to a normal form\n\nnormal⟷ : {t₁ t₂ : U} → (c₁ : t₁ ⟷ t₂) → \n Σ[ c₂ ∈ normalℕ t₁ ⟷ normalℕ t₂ ] (c₁ ⇔ (normalU t₁ ◎ c₂ ◎ (! (normalU t₂))))\nnormal⟷ {PLUS ZERO t} {.t} unite₊ = \n (id⟷ , \n (unite₊\n ⇔⟨ idr◎r ⟩\n unite₊ ◎ id⟷\n ⇔⟨ resp◎⇔ id⇔ linv◎r ⟩\n unite₊ ◎ (normalU t ◎ (! (normalU t)))\n ⇔⟨ assoc◎l ⟩\n (unite₊ ◎ normalU t) ◎ (! (normalU t))\n ⇔⟨ resp◎⇔ unitel₊⇔ id⇔ ⟩\n ((id⟷ ⊕ normalU t) ◎ unite₊) ◎ (! (normalU t))\n ⇔⟨ resp◎⇔ id⇔ idl◎r ⟩\n ((id⟷ ⊕ normalU t) ◎ unite₊) ◎ (id⟷ ◎ (! (normalU t)))\n ⇔⟨ id⇔ ⟩\n normalU (PLUS ZERO t) ◎ (id⟷ ◎ (! (normalU t))) ▤))\nnormal⟷ {t} {PLUS ZERO .t} uniti₊ = \n (id⟷ , \n (uniti₊ \n ⇔⟨ idl◎r ⟩ \n id⟷ ◎ uniti₊\n ⇔⟨ resp◎⇔ linv◎r id⇔ ⟩ \n (normalU t ◎ (! (normalU t))) ◎ uniti₊\n ⇔⟨ assoc◎r ⟩ \n normalU t ◎ ((! (normalU t)) ◎ uniti₊)\n ⇔⟨ resp◎⇔ id⇔ unitir₊⇔ ⟩ \n normalU t ◎ (uniti₊ ◎ (id⟷ ⊕ (! (normalU t))))\n ⇔⟨ resp◎⇔ id⇔ idl◎r ⟩ \n normalU t ◎ (id⟷ ◎ (uniti₊ ◎ (id⟷ ⊕ (! (normalU t)))))\n ⇔⟨ id⇔ ⟩ \n normalU t ◎ (id⟷ ◎ (! ((id⟷ ⊕ (normalU t)) ◎ unite₊)))\n ⇔⟨ id⇔ ⟩ \n normalU t ◎ (id⟷ ◎ (! (normalU (PLUS ZERO t)))) ▤))\nnormal⟷ {PLUS ZERO t₂} {PLUS .t₂ ZERO} swap₊ = \n (normalℕswap {ZERO} {t₂} , \n (swap₊ \n ⇔⟨ {!!} ⟩\n (unite₊ ◎ normalU t₂) ◎ \n (normalℕswap {ZERO} {t₂} ◎ ((! (assocrU (toℕ t₂))) ◎ (! (normalU t₂) ⊕ id⟷)))\n ⇔⟨ resp◎⇔ unitel₊⇔ id⇔ ⟩\n ((id⟷ ⊕ normalU t₂) ◎ unite₊) ◎ \n (normalℕswap {ZERO} {t₂} ◎ ((! (assocrU (toℕ t₂))) ◎ (! (normalU t₂) ⊕ id⟷)))\n ⇔⟨ id⇔ ⟩\n normalU (PLUS ZERO t₂) ◎ (normalℕswap {ZERO} {t₂} ◎ (! (normalU (PLUS t₂ ZERO)))) ▤))\nnormal⟷ {PLUS ONE t₂} {PLUS .t₂ ONE} swap₊ = \n (normalℕswap {ONE} {t₂} , \n (swap₊ \n ⇔⟨ {!!} ⟩\n ((normalU ONE ⊕ normalU t₂) ◎ assocrU (toℕ ONE)) ◎ \n (normalℕswap {ONE} {t₂} ◎ ((! (assocrU (toℕ t₂))) ◎ (! (normalU t₂) ⊕ ! (normalU ONE))))\n ⇔⟨ id⇔ ⟩\n normalU (PLUS ONE t₂) ◎ (normalℕswap {ONE} {t₂} ◎ (! (normalU (PLUS t₂ ONE)))) ▤))\nnormal⟷ {PLUS t₁ t₂} {PLUS .t₂ .t₁} swap₊ = \n (normalℕswap {t₁} {t₂} , \n (swap₊ \n ⇔⟨ {!!} ⟩\n ((normalU t₁ ⊕ normalU t₂) ◎ assocrU (toℕ t₁)) ◎ \n (normalℕswap {t₁} {t₂} ◎ ((! (assocrU (toℕ t₂))) ◎ (! (normalU t₂) ⊕ ! (normalU t₁))))\n ⇔⟨ id⇔ ⟩\n normalU (PLUS t₁ t₂) ◎ (normalℕswap {t₁} {t₂} ◎ (! (normalU (PLUS t₂ t₁)))) ▤))\nnormal⟷ {PLUS t₁ (PLUS t₂ t₃)} {PLUS (PLUS .t₁ .t₂) .t₃} assocl₊ = {!!}\nnormal⟷ {PLUS (PLUS t₁ t₂) t₃} {PLUS .t₁ (PLUS .t₂ .t₃)} assocr₊ = {!!}\nnormal⟷ {TIMES ONE t} {.t} unite⋆ = {!!} \nnormal⟷ {t} {TIMES ONE .t} uniti⋆ = {!!}\nnormal⟷ {TIMES t₁ t₂} {TIMES .t₂ .t₁} swap⋆ = {!!}\nnormal⟷ {TIMES t₁ (TIMES t₂ t₃)} {TIMES (TIMES .t₁ .t₂) .t₃} assocl⋆ = {!!}\nnormal⟷ {TIMES (TIMES t₁ t₂) t₃} {TIMES .t₁ (TIMES .t₂ .t₃)} assocr⋆ = {!!}\nnormal⟷ {TIMES ZERO t} {ZERO} distz = {!!}\nnormal⟷ {ZERO} {TIMES ZERO t} factorz = {!!}\nnormal⟷ {TIMES (PLUS t₁ t₂) t₃} {PLUS (TIMES .t₁ .t₃) (TIMES .t₂ .t₃)} dist = {!!}\nnormal⟷ {PLUS (TIMES .t₁ .t₃) (TIMES .t₂ .t₃)} {TIMES (PLUS t₁ t₂) t₃} factor = {!!}\nnormal⟷ {t} {.t} id⟷ = \n (id⟷ , \n (id⟷ \n ⇔⟨ linv◎r ⟩\n normalU t ◎ (! (normalU t))\n ⇔⟨ resp◎⇔ id⇔ idl◎r ⟩\n normalU t ◎ (id⟷ ◎ (! (normalU t))) ▤))\nnormal⟷ {t₁} {t₃} (_◎_ {t₂ = t₂} c₁ c₂) = {!!}\nnormal⟷ {PLUS t₁ t₂} {PLUS t₃ t₄} (c₁ ⊕ c₂) = {!!}\nnormal⟷ {TIMES t₁ t₂} {TIMES t₃ t₄} (c₁ ⊗ c₂) = {!!}\n\n-- if c₁ c₂ : t₁ ⟷ t₂ and c₁ ∼ c₂ then we want a canonical combinator\n-- normalℕ t₁ ⟷ normalℕ t₂. If we have that then we should be able to\n-- decide whether c₁ ∼ c₂ by normalizing and looking at the canonical\n-- combinator.\n\n-- Use ⇔ to normalize a path\n\n{-# NO_TERMINATION_CHECK #-}\nnormalize : {t₁ t₂ : U} → (c₁ : t₁ ⟷ t₂) → Σ[ c₂ ∈ t₁ ⟷ t₂ ] (c₁ ⇔ c₂)\nnormalize unite₊ = (unite₊ , id⇔)\nnormalize uniti₊ = (uniti₊ , id⇔)\nnormalize swap₊ = (swap₊ , id⇔)\nnormalize assocl₊ = (assocl₊ , id⇔)\nnormalize assocr₊ = (assocr₊ , id⇔)\nnormalize unite⋆ = (unite⋆ , id⇔)\nnormalize uniti⋆ = (uniti⋆ , id⇔)\nnormalize swap⋆ = (swap⋆ , id⇔)\nnormalize assocl⋆ = (assocl⋆ , id⇔)\nnormalize assocr⋆ = (assocr⋆ , id⇔)\nnormalize distz = (distz , id⇔)\nnormalize factorz = (factorz , id⇔)\nnormalize dist = (dist , id⇔)\nnormalize factor = (factor , id⇔)\nnormalize id⟷ = (id⟷ , id⇔)\nnormalize (c₁ ◎ c₂) with normalize c₁ | normalize c₂\n... | (c₁' , α) | (c₂' , β) = {!!} \nnormalize (c₁ ⊕ c₂) with normalize c₁ | normalize c₂\n... | (c₁' , α) | (c₂₁ ⊕ c₂₂ , β) = \n (assocl₊ ◎ ((c₁' ⊕ c₂₁) ⊕ c₂₂) ◎ assocr₊ , trans⇔ (resp⊕⇔ α β) assoc⊕l)\n... | (c₁' , α) | (c₂' , β) = (c₁' ⊕ c₂' , resp⊕⇔ α β)\nnormalize (c₁ ⊗ c₂) with normalize c₁ | normalize c₂\n... | (c₁₁ ⊕ c₁₂ , α) | (c₂' , β) = \n (dist ◎ ((c₁₁ ⊗ c₂') ⊕ (c₁₂ ⊗ c₂')) ◎ factor , \n trans⇔ (resp⊗⇔ α β) dist⇔)\n... | (c₁' , α) | (c₂₁ ⊗ c₂₂ , β) = \n (assocl⋆ ◎ ((c₁' ⊗ c₂₁) ⊗ c₂₂) ◎ assocr⋆ , trans⇔ (resp⊗⇔ α β) assoc⊗l)\n... | (c₁' , α) | (c₂' , β) = (c₁' ⊗ c₂' , resp⊗⇔ α β)\n\n\n\nrecord Permutation (t t' : U) : Set where\n field\n t₀ : U -- no occurrences of TIMES .. (TIMES .. ..)\n phase₀ : t ⟷ t₀ \n t₁ : U -- no occurrences of TIMES (PLUS .. ..)\n phase₁ : t₀ ⟷ t₁\n t₂ : U -- no occurrences of TIMES\n phase₂ : t₁ ⟷ t₂\n t₃ : U -- no nested left PLUS, all PLUS of form PLUS simple (PLUS ...)\n phase₃ : t₂ ⟷ t₃\n t₄ : U -- no occurrences PLUS ZERO\n phase₄ : t₃ ⟷ t₄\n t₅ : U -- do actual permutation using swapij\n phase₅ : t₄ ⟷ t₅\n rest : t₅ ⟷ t' -- blah blah\n\np◎id∼p : ∀ {t₁ t₂} {c : t₁ ⟷ t₂} → (c ◎ id⟷ ∼ c)\np◎id∼p {t₁} {t₂} {c} v = \n (begin (proj₁ (perm2path (c ◎ id⟷) v))\n ≡⟨ {!!} ⟩\n (proj₁ (perm2path id⟷ (proj₁ (perm2path c v))))\n ≡⟨ {!!} ⟩\n (proj₁ (perm2path c v)) ∎)\n\n-- perm2path {t} id⟷ v = (v , edge •[ t , v ] •[ t , v ])\n\n--perm2path (_◎_ {t₁} {t₂} {t₃} c₁ c₂) v₁ with perm2path c₁ v₁\n--... | (v₂ , p) with perm2path c₂ v₂\n--... | (v₃ , q) = (v₃ , seq p q) \n\n\n-- Equivalences between paths leading to 2path structure\n-- Two paths are the same if they go through the same points\n\n_∼_ : ∀ {t₁ t₂ v₁ v₂} → \n (p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) → \n (q : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) → \n Set\n(edge ._ ._) ∼ (edge ._ ._) = ⊤ \n(edge ._ ._) ∼ (seq p q) = {!!}\n(edge ._ ._) ∼ (left p) = {!!}\n(edge ._ ._) ∼ (right p) = {!!}\n(edge ._ ._) ∼ (par p q) = {!!}\nseq p p₁ ∼ edge ._ ._ = {!!}\nseq p₁ p ∼ seq q q₁ = {!!}\nseq p p₁ ∼ left q = {!!}\nseq p p₁ ∼ right q = {!!}\nseq p p₁ ∼ par q q₁ = {!!}\nleft p ∼ edge ._ ._ = {!!}\nleft p ∼ seq q q₁ = {!!}\nleft p ∼ left q = {!!}\nright p ∼ edge ._ ._ = {!!}\nright p ∼ seq q q₁ = {!!}\nright p ∼ right q = {!!}\npar p p₁ ∼ edge ._ ._ = {!!}\npar p p₁ ∼ seq q q₁ = {!!}\npar p p₁ ∼ par q q₁ = {!!} \n\n-- Equivalences between paths leading to 2path structure\n-- Following the HoTT approach two paths are considered the same if they\n-- map the same points to equal points\n\ninfix 4 _∼_ \n\n_∼_ : ∀ {t₁ t₂ v₁ v₂ v₂'} → \n (p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) → \n (q : Path •[ t₁ , v₁ ] •[ t₂ , v₂' ]) → \n Set\n_∼_ {t₁} {t₂} {v₁} {v₂} {v₂'} p q = (v₂ ≡ v₂')\n\n\n-- Lemma 2.4.2\n\np∼p : {t₁ t₂ : U} {p : Path t₁ t₂} → p ∼ p\np∼p {p = path c} _ = refl\n\np∼q→q∼p : {t₁ t₂ : U} {p q : Path t₁ t₂} → (p ∼ q) → (q ∼ p)\np∼q→q∼p {p = path c₁} {q = path c₂} α v = sym (α v) \n\np∼q∼r→p∼r : {t₁ t₂ : U} {p q r : Path t₁ t₂} → \n (p ∼ q) → (q ∼ r) → (p ∼ r) \np∼q∼r→p∼r {p = path c₁} {q = path c₂} {r = path c₃} α β v = trans (α v) (β v) \n\n-- lift inverses and compositions to paths\n\ninv : {t₁ t₂ : U} → Path t₁ t₂ → Path t₂ t₁\ninv (path c) = path (! c)\n\ninfixr 10 _●_\n\n_●_ : {t₁ t₂ t₃ : U} → Path t₁ t₂ → Path t₂ t₃ → Path t₁ t₃\npath c₁ ● path c₂ = path (c₁ ◎ c₂)\n\n-- Lemma 2.1.4\n\np∼p◎id : {t₁ t₂ : U} {p : Path t₁ t₂} → p ∼ p ● path id⟷\np∼p◎id {t₁} {t₂} {path c} v = \n (begin (perm2path c v)\n ≡⟨ refl ⟩\n (perm2path c (perm2path id⟷ v))\n ≡⟨ refl ⟩\n (perm2path (c ◎ id⟷) v) ∎)\n\np∼id◎p : {t₁ t₂ : U} {p : Path t₁ t₂} → p ∼ path id⟷ ● p\np∼id◎p {t₁} {t₂} {path c} v = \n (begin (perm2path c v)\n ≡⟨ refl ⟩\n (perm2path id⟷ (perm2path c v))\n ≡⟨ refl ⟩\n (perm2path (id⟷ ◎ c) v) ∎)\n\n!p◎p∼id : {t₁ t₂ : U} {p : Path t₁ t₂} → (inv p) ● p ∼ path id⟷\n!p◎p∼id {t₁} {t₂} {path c} v = \n (begin (perm2path ((! c) ◎ c) v)\n ≡⟨ refl ⟩\n (perm2path c (perm2path (! c) v))\n ≡⟨ invr {t₁} {t₂} {c} {v} ⟩\n (perm2path id⟷ v) ∎)\n\np◎!p∼id : {t₁ t₂ : U} {p : Path t₁ t₂} → p ● (inv p) ∼ path id⟷\np◎!p∼id {t₁} {t₂} {path c} v = \n (begin (perm2path (c ◎ (! c)) v)\n ≡⟨ refl ⟩\n (perm2path (! c) (perm2path c v))\n ≡⟨ invl {t₁} {t₂} {c} {v} ⟩\n (perm2path id⟷ v) ∎)\n\n\n!!p∼p : {t₁ t₂ : U} {p : Path t₁ t₂} → inv (inv p) ∼ p\n!!p∼p {t₁} {t₂} {path c} v = \n begin (perm2path (! (! c)) v\n ≡⟨ cong (λ x → perm2path x v) (!! {c = c}) ⟩ \n perm2path c v ∎)\n\nassoc◎ : {t₁ t₂ t₃ t₄ : U} {p : Path t₁ t₂} {q : Path t₂ t₃} {r : Path t₃ t₄} → \n p ● (q ● r) ∼ (p ● q) ● r\nassoc◎ {t₁} {t₂} {t₃} {t₄} {path c₁} {path c₂} {path c₃} v = \n begin (perm2path (c₁ ◎ (c₂ ◎ c₃)) v \n ≡⟨ refl ⟩\n perm2path (c₂ ◎ c₃) (perm2path c₁ v)\n ≡⟨ refl ⟩\n perm2path c₃ (perm2path c₂ (perm2path c₁ v))\n ≡⟨ refl ⟩\n perm2path c₃ (perm2path (c₁ ◎ c₂) v)\n ≡⟨ refl ⟩\n perm2path ((c₁ ◎ c₂) ◎ c₃) v ∎)\n\nresp◎ : {t₁ t₂ t₃ : U} {p q : Path t₁ t₂} {r s : Path t₂ t₃} → \n p ∼ q → r ∼ s → (p ● r) ∼ (q ● s)\nresp◎ {t₁} {t₂} {t₃} {path c₁} {path c₂} {path c₃} {path c₄} α β v = \n begin (perm2path (c₁ ◎ c₃) v \n ≡⟨ refl ⟩\n perm2path c₃ (perm2path c₁ v)\n ≡⟨ cong (λ x → perm2path c₃ x) (α v) ⟩\n perm2path c₃ (perm2path c₂ v)\n ≡⟨ β (perm2path c₂ v) ⟩ \n perm2path c₄ (perm2path c₂ v)\n ≡⟨ refl ⟩ \n perm2path (c₂ ◎ c₄) v ∎)\n\n-- Recall that two perminators are the same if they denote the same\n-- permutation; in that case there is a 2path between them in the relevant\n-- path space\n\ndata _⇔_ {t₁ t₂ : U} : Path t₁ t₂ → Path t₁ t₂ → Set where\n 2path : {p q : Path t₁ t₂} → (p ∼ q) → (p ⇔ q)\n\n-- Examples\n\np q r : Path BOOL BOOL\np = path id⟷\nq = path swap₊\nr = path (swap₊ ◎ id⟷)\n\nα : q ⇔ r\nα = 2path (p∼p◎id {p = path swap₊})\n\n-- The equivalence of paths makes U a 1groupoid: the points are types t : U;\n-- the 1paths are ⟷; and the 2paths between them are ⇔\n\nG : 1Groupoid\nG = record\n { set = U\n ; _↝_ = Path\n ; _≈_ = _⇔_ \n ; id = path id⟷\n ; _∘_ = λ q p → p ● q\n ; _⁻¹ = inv\n ; lneutr = λ p → 2path (p∼q→q∼p p∼p◎id) \n ; rneutr = λ p → 2path (p∼q→q∼p p∼id◎p)\n ; assoc = λ r q p → 2path assoc◎\n ; equiv = record { \n refl = 2path p∼p\n ; sym = λ { (2path α) → 2path (p∼q→q∼p α) }\n ; trans = λ { (2path α) (2path β) → 2path (p∼q∼r→p∼r α β) }\n }\n ; linv = λ p → 2path p◎!p∼id\n ; rinv = λ p → 2path !p◎p∼id\n ; ∘-resp-≈ = λ { (2path β) (2path α) → 2path (resp◎ α β) }\n }\n\n------------------------------------------------------------------------------\n\ndata ΩU : Set where\n ΩZERO : ΩU -- empty set of paths\n ΩONE : ΩU -- a trivial path\n ΩPLUS : ΩU → ΩU → ΩU -- disjoint union of paths\n ΩTIMES : ΩU → ΩU → ΩU -- pairs of paths\n PATH : (t₁ t₂ : U) → ΩU -- level 0 paths between values\n\n-- values\n\nΩ⟦_⟧ : ΩU → Set\nΩ⟦ ΩZERO ⟧ = ⊥\nΩ⟦ ΩONE ⟧ = ⊤\nΩ⟦ ΩPLUS t₁ t₂ ⟧ = Ω⟦ t₁ ⟧ ⊎ Ω⟦ t₂ ⟧\nΩ⟦ ΩTIMES t₁ t₂ ⟧ = Ω⟦ t₁ ⟧ × Ω⟦ t₂ ⟧\nΩ⟦ PATH t₁ t₂ ⟧ = Path t₁ t₂\n\n-- two perminators are the same if they denote the same permutation\n\n\n-- 2paths\n\ndata _⇔_ : ΩU → ΩU → Set where\n unite₊ : {t : ΩU} → ΩPLUS ΩZERO t ⇔ t\n uniti₊ : {t : ΩU} → t ⇔ ΩPLUS ΩZERO t\n swap₊ : {t₁ t₂ : ΩU} → ΩPLUS t₁ t₂ ⇔ ΩPLUS t₂ t₁\n assocl₊ : {t₁ t₂ t₃ : ΩU} → ΩPLUS t₁ (ΩPLUS t₂ t₃) ⇔ ΩPLUS (ΩPLUS t₁ t₂) t₃\n assocr₊ : {t₁ t₂ t₃ : ΩU} → ΩPLUS (ΩPLUS t₁ t₂) t₃ ⇔ ΩPLUS t₁ (ΩPLUS t₂ t₃)\n unite⋆ : {t : ΩU} → ΩTIMES ΩONE t ⇔ t\n uniti⋆ : {t : ΩU} → t ⇔ ΩTIMES ΩONE t\n swap⋆ : {t₁ t₂ : ΩU} → ΩTIMES t₁ t₂ ⇔ ΩTIMES t₂ t₁\n assocl⋆ : {t₁ t₂ t₃ : ΩU} → ΩTIMES t₁ (ΩTIMES t₂ t₃) ⇔ ΩTIMES (ΩTIMES t₁ t₂) t₃\n assocr⋆ : {t₁ t₂ t₃ : ΩU} → ΩTIMES (ΩTIMES t₁ t₂) t₃ ⇔ ΩTIMES t₁ (ΩTIMES t₂ t₃)\n distz : {t : ΩU} → ΩTIMES ΩZERO t ⇔ ΩZERO\n factorz : {t : ΩU} → ΩZERO ⇔ ΩTIMES ΩZERO t\n dist : {t₁ t₂ t₃ : ΩU} → \n ΩTIMES (ΩPLUS t₁ t₂) t₃ ⇔ ΩPLUS (ΩTIMES t₁ t₃) (ΩTIMES t₂ t₃) \n factor : {t₁ t₂ t₃ : ΩU} → \n ΩPLUS (ΩTIMES t₁ t₃) (ΩTIMES t₂ t₃) ⇔ ΩTIMES (ΩPLUS t₁ t₂) t₃\n id⇔ : {t : ΩU} → t ⇔ t\n _◎_ : {t₁ t₂ t₃ : ΩU} → (t₁ ⇔ t₂) → (t₂ ⇔ t₃) → (t₁ ⇔ t₃)\n _⊕_ : {t₁ t₂ t₃ t₄ : ΩU} → \n (t₁ ⇔ t₃) → (t₂ ⇔ t₄) → (ΩPLUS t₁ t₂ ⇔ ΩPLUS t₃ t₄)\n _⊗_ : {t₁ t₂ t₃ t₄ : ΩU} → \n (t₁ ⇔ t₃) → (t₂ ⇔ t₄) → (ΩTIMES t₁ t₂ ⇔ ΩTIMES t₃ t₄)\n _∼⇔_ : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → \n PATH t₁ t₂ ⇔ PATH t₁ t₂\n\n-- two spaces are equivalent if there is a path between them; this path\n-- automatically has an inverse which is an equivalence. It is a\n-- quasi-equivalence but for finite types that's the same as an equivalence.\n\ninfix 4 _≃_ \n\n_≃_ : (t₁ t₂ : U) → Set\nt₁ ≃ t₂ = (t₁ ⟷ t₂)\n\n-- Univalence says (t₁ ≃ t₂) ≃ (t₁ ⟷ t₂) but as shown above, we actually have\n-- this by definition instead of up to ≃\n\n------------------------------------------------------------------------------\n------------------------------------------------------------------------------\n------------------------------------------------------------------------------\n\nanother idea is to look at c and massage it as follows: rewrite every \nswap+ ; c\nto \nc' ; swaps ; c''\n\ngeneral start with \n id || id || c\nexamine c and move anything that's not swap to left. If we get to\n c' || id || id\nwe are done\nif we get to:\n c' || id || swap+;c\nthen we rewrite\n c';c1 || swaps || c2;c\nand we keep going\n\nmodule Phase₁ where\n\n -- no occurrences of (TIMES (TIMES t₁ t₂) t₃)\n\napproach that maintains the invariants in proofs\n\n invariant : (t : U) → Bool\n invariant ZERO = true\n invariant ONE = true\n invariant (PLUS t₁ t₂) = invariant t₁ ∧ invariant t₂ \n invariant (TIMES ZERO t₂) = invariant t₂\n invariant (TIMES ONE t₂) = invariant t₂\n invariant (TIMES (PLUS t₁ t₂) t₃) = (invariant t₁ ∧ invariant t₂) ∧ invariant t₃\n invariant (TIMES (TIMES t₁ t₂) t₃) = false\n\n Invariant : (t : U) → Set\n Invariant t = invariant t ≡ true\n\n invariant? : Decidable Invariant\n invariant? t with invariant t \n ... | true = yes refl\n ... | false = no (λ ())\n\n conj : ∀ {b₁ b₂} → (b₁ ≡ true) → (b₂ ≡ true) → (b₁ ∧ b₂ ≡ true)\n conj {true} {true} p q = refl\n conj {true} {false} p ()\n conj {false} {true} ()\n conj {false} {false} ()\n\n phase₁ : (t₁ : U) → Σ[ t₂ ∈ U ] (True (invariant? t₂) × t₁ ⟷ t₂)\n phase₁ ZERO = (ZERO , (fromWitness {Q = invariant? ZERO} refl , id⟷))\n phase₁ ONE = (ONE , (fromWitness {Q = invariant? ONE} refl , id⟷))\n phase₁ (PLUS t₁ t₂) with phase₁ t₁ | phase₁ t₂\n ... | (t₁' , (p₁ , c₁)) | (t₂' , (p₂ , c₂)) with toWitness p₁ | toWitness p₂\n ... | t₁'ok | t₂'ok = \n (PLUS t₁' t₂' , \n (fromWitness {Q = invariant? (PLUS t₁' t₂')} (conj t₁'ok t₂'ok) , \n c₁ ⊕ c₂))\n phase₁ (TIMES ZERO t) with phase₁ t\n ... | (t' , (p , c)) with toWitness p \n ... | t'ok = \n (TIMES ZERO t' , \n (fromWitness {Q = invariant? (TIMES ZERO t')} t'ok , \n id⟷ ⊗ c))\n phase₁ (TIMES ONE t) with phase₁ t \n ... | (t' , (p , c)) with toWitness p\n ... | t'ok = \n (TIMES ONE t' , \n (fromWitness {Q = invariant? (TIMES ONE t')} t'ok , \n id⟷ ⊗ c))\n phase₁ (TIMES (PLUS t₁ t₂) t₃) with phase₁ t₁ | phase₁ t₂ | phase₁ t₃\n ... | (t₁' , (p₁ , c₁)) | (t₂' , (p₂ , c₂)) | (t₃' , (p₃ , c₃)) \n with toWitness p₁ | toWitness p₂ | toWitness p₃ \n ... | t₁'ok | t₂'ok | t₃'ok = \n (TIMES (PLUS t₁' t₂') t₃' , \n (fromWitness {Q = invariant? (TIMES (PLUS t₁' t₂') t₃')}\n (conj (conj t₁'ok t₂'ok) t₃'ok) , \n (c₁ ⊕ c₂) ⊗ c₃))\n phase₁ (TIMES (TIMES t₁ t₂) t₃) = {!!} \n\n -- invariants are informal\n -- rewrite (TIMES (TIMES t₁ t₂) t₃) to TIMES t₁ (TIMES t₂ t₃)\n invariant : (t : U) → Bool\n invariant ZERO = true\n invariant ONE = true\n invariant (PLUS t₁ t₂) = invariant t₁ ∧ invariant t₂ \n invariant (TIMES ZERO t₂) = invariant t₂\n invariant (TIMES ONE t₂) = invariant t₂\n invariant (TIMES (PLUS t₁ t₂) t₃) = invariant t₁ ∧ invariant t₂ ∧ invariant t₃\n invariant (TIMES (TIMES t₁ t₂) t₃) = false\n\n step₁ : (t₁ : U) → Σ[ t₂ ∈ U ] (t₁ ⟷ t₂)\n step₁ ZERO = (ZERO , id⟷)\n step₁ ONE = (ONE , id⟷)\n step₁ (PLUS t₁ t₂) with step₁ t₁ | step₁ t₂\n ... | (t₁' , c₁) | (t₂' , c₂) = (PLUS t₁' t₂' , c₁ ⊕ c₂)\n step₁ (TIMES (TIMES t₁ t₂) t₃) with step₁ t₁ | step₁ t₂ | step₁ t₃\n ... | (t₁' , c₁) | (t₂' , c₂) | (t₃' , c₃) = \n (TIMES t₁' (TIMES t₂' t₃') , ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆)\n step₁ (TIMES ZERO t₂) with step₁ t₂ \n ... | (t₂' , c₂) = (TIMES ZERO t₂' , id⟷ ⊗ c₂)\n step₁ (TIMES ONE t₂) with step₁ t₂ \n ... | (t₂' , c₂) = (TIMES ONE t₂' , id⟷ ⊗ c₂)\n step₁ (TIMES (PLUS t₁ t₂) t₃) with step₁ t₁ | step₁ t₂ | step₁ t₃\n ... | (t₁' , c₁) | (t₂' , c₂) | (t₃' , c₃) = \n (TIMES (PLUS t₁' t₂') t₃' , (c₁ ⊕ c₂) ⊗ c₃)\n\n {-# NO_TERMINATION_CHECK #-}\n phase₁ : (t₁ : U) → Σ[ t₂ ∈ U ] (t₁ ⟷ t₂)\n phase₁ t with invariant t\n ... | true = (t , id⟷)\n ... | false with step₁ t\n ... | (t' , c) with phase₁ t'\n ... | (t'' , c') = (t'' , c ◎ c')\n\n test₁ = phase₁ (TIMES (TIMES (TIMES ONE ONE) (TIMES ONE ONE)) ONE)\n TIMES ONE (TIMES ONE (TIMES ONE (TIMES ONE ONE))) ,\n (((id⟷ ⊗ id⟷) ⊗ (id⟷ ⊗ id⟷)) ⊗ id⟷ ◎ assocr⋆) ◎\n ((id⟷ ⊗ id⟷) ⊗ ((id⟷ ⊗ id⟷) ⊗ id⟷ ◎ assocr⋆) ◎ assocr⋆) ◎ id⟷\n\n -- Now any perminator (t₁ ⟷ t₂) can be transformed to a canonical\n -- representation in which we first associate all the TIMES to the right\n -- and then do the rest of the perminator\n\n normalize₁ : {t₁ t₂ : U} → (t₁ ⟷ t₂) → \n (Σ[ t₁' ∈ U ] (t₁ ⟷ t₁' × t₁' ⟷ t₂))\n normalize₁ {ZERO} {t} c = ZERO , id⟷ , c\n normalize₁ {ONE} c = ONE , id⟷ , c\n normalize₁ {PLUS .ZERO t₂} unite₊ with phase₁ t₂\n ... | (t₂n , cn) = PLUS ZERO t₂n , id⟷ ⊕ cn , unite₊ ◎ ! cn\n normalize₁ {PLUS t₁ t₂} uniti₊ = {!!}\n normalize₁ {PLUS t₁ t₂} swap₊ = {!!}\n normalize₁ {PLUS t₁ ._} assocl₊ = {!!}\n normalize₁ {PLUS ._ t₂} assocr₊ = {!!}\n normalize₁ {PLUS t₁ t₂} uniti⋆ = {!!}\n normalize₁ {PLUS ._ ._} factor = {!!}\n normalize₁ {PLUS t₁ t₂} id⟷ = {!!}\n normalize₁ {PLUS t₁ t₂} (c ◎ c₁) = {!!}\n normalize₁ {PLUS t₁ t₂} (c ⊕ c₁) = {!!} \n normalize₁ {TIMES t₁ t₂} c = {!!}\n\nrecord Permutation (t t' : U) : Set where\n field\n t₀ : U -- no occurrences of TIMES .. (TIMES .. ..)\n phase₀ : t ⟷ t₀ \n t₁ : U -- no occurrences of TIMES (PLUS .. ..)\n phase₁ : t₀ ⟷ t₁\n t₂ : U -- no occurrences of TIMES\n phase₂ : t₁ ⟷ t₂\n t₃ : U -- no nested left PLUS, all PLUS of form PLUS simple (PLUS ...)\n phase₃ : t₂ ⟷ t₃\n t₄ : U -- no occurrences PLUS ZERO\n phase₄ : t₃ ⟷ t₄\n t₅ : U -- do actual permutation using swapij\n phase₅ : t₄ ⟷ t₅\n rest : t₅ ⟷ t' -- blah blah\n\ncanonical : {t₁ t₂ : U} → (t₁ ⟷ t₂) → Permutation t₁ t₂\ncanonical c = {!!}\n\n------------------------------------------------------------------------------\n-- These paths do NOT reach \"inside\" the finite sets. For example, there is\n-- NO PATH between false and true in BOOL even though there is a path between\n-- BOOL and BOOL that \"twists the space around.\"\n-- \n-- In more detail how do these paths between types relate to the whole\n-- discussion about higher groupoid structure of type formers (Sec. 2.5 and\n-- on).\n\n-- Then revisit the early parts of Ch. 2 about higher groupoid structure for\n-- U, how functions from U to U respect the paths in U, type families and\n-- dependent functions, homotopies and equivalences, and then Sec. 2.5 and\n-- beyond again.\n\n\nshould this be on the code as done now or on their interpreation\ni.e. data _⟷_ : ⟦ U ⟧ → ⟦ U ⟧ → Set where\n\ncan add recursive types \nrec : U\n⟦_⟧ takes an additional argument X that is passed around\n⟦ rec ⟧ X = X\nfixpoitn\ndata μ (t : U) : Set where\n ⟨_⟩ : ⟦ t ⟧ (μ t) → μ t\n\n-- We identify functions with the paths above. Since every function is\n-- reversible, every function corresponds to a path and there is no\n-- separation between functions and paths and no need to mediate between them\n-- using univalence.\n--\n-- Note that none of the above functions are dependent functions.\n\n------------------------------------------------------------------------------\n-- Now we consider homotopies, i.e., paths between functions. Since our\n-- functions are identified with the paths ⟷, the homotopies are paths\n-- between elements of ⟷\n\n-- First, a sanity check. Our notion of paths matches the notion of\n-- equivalences in the conventional HoTT presentation\n\n-- Homotopy between two functions (paths)\n\n-- That makes id ∼ not which is bad. The def. of ∼ should be parametric...\n\n_∼_ : {t₁ t₂ t₃ : U} → (f : t₁ ⟷ t₂) → (g : t₁ ⟷ t₃) → Set\n_∼_ {t₁} {t₂} {t₃} f g = t₂ ⟷ t₃\n\n-- Every f and g of the right type are related by ∼\n\nhomotopy : {t₁ t₂ t₃ : U} → (f : t₁ ⟷ t₂) → (g : t₁ ⟷ t₃) → (f ∼ g)\nhomotopy f g = (! f) ◎ g\n\n-- Equivalences \n-- \n-- If f : t₁ ⟷ t₂ has two inverses g₁ g₂ : t₂ ⟷ t₁ then g₁ ∼ g₂. More\n-- generally, any two paths of the same type are related by ∼.\n\nequiv : {t₁ t₂ : U} → (f g : t₁ ⟷ t₂) → (f ∼ g) \nequiv f g = id⟷ \n\n-- It follows that any two types in U are equivalent if there is a path\n-- between them\n\n_≃_ : (t₁ t₂ : U) → Set\nt₁ ≃ t₂ = t₁ ⟷ t₂ \n\n-- Now we want to understand the type of paths between paths\n\n------------------------------------------------------------------------------\n\nelems : (t : U) → List ⟦ t ⟧\nelems ZERO = []\nelems ONE = [ tt ] \nelems (PLUS t₁ t₂) = map inj₁ (elems t₁) ++ map inj₂ (elems t₂)\nelems (TIMES t₁ t₂) = concat \n (map \n (λ v₂ → map (λ v₁ → (v₁ , v₂)) (elems t₁))\n (elems t₂))\n\n_≟_ : {t : U} → ⟦ t ⟧ → ⟦ t ⟧ → Bool\n_≟_ {ZERO} ()\n_≟_ {ONE} tt tt = true\n_≟_ {PLUS t₁ t₂} (inj₁ v) (inj₁ w) = v ≟ w\n_≟_ {PLUS t₁ t₂} (inj₁ v) (inj₂ w) = false\n_≟_ {PLUS t₁ t₂} (inj₂ v) (inj₁ w) = false\n_≟_ {PLUS t₁ t₂} (inj₂ v) (inj₂ w) = v ≟ w\n_≟_ {TIMES t₁ t₂} (v₁ , w₁) (v₂ , w₂) = v₁ ≟ v₂ ∧ w₁ ≟ w₂\n\n findLoops : {t t₁ t₂ : U} → (PLUS t t₁ ⟷ PLUS t t₂) → List ⟦ t ⟧ → \n List (Σ[ t ∈ U ] ⟦ t ⟧)\n findLoops c [] = []\n findLoops {t} c (v ∷ vs) = ? with perm2path c (inj₁ v)\n ... | (inj₂ _ , loops) = loops ++ findLoops c vs\n ... | (inj₁ v' , loops) with v ≟ v' \n ... | true = (t , v) ∷ loops ++ findLoops c vs\n ... | false = loops ++ findLoops c vs\n\ntraceLoopsEx : {t : U} → List (Σ[ t ∈ U ] ⟦ t ⟧)\ntraceLoopsEx {t} = findLoops traceBodyEx (elems (PLUS t (PLUS t t)))\n-- traceLoopsEx {ONE} ==> (PLUS ONE (PLUS ONE ONE) , inj₂ (inj₁ tt)) ∷ []\n\n-- Each permutation is a \"path\" between types. We can think of this path as\n-- being indexed by \"time\" where \"time\" here is in discrete units\n-- corresponding to the sequencing of combinators. A homotopy between paths p\n-- and q is a map that, for each \"time unit\", maps the specified type along p\n-- to a corresponding type along q. At each such time unit, the mapping\n-- between types is itself a path. So a homotopy is essentially a collection\n-- of paths. As an example, given two paths starting at t₁ and ending at t₂\n-- and going through different intermediate points:\n-- p = t₁ -> t -> t' -> t₂\n-- q = t₁ -> u -> u' -> t₂\n-- A possible homotopy between these two paths is a path from t to u and \n-- another path from t' to u'. Things get slightly more complicated if the\n-- number of intermediate points is not the same etc. but that's the basic idea.\n-- The vertical paths must commute with the horizontal ones.\n-- \n-- Postulate the groupoid laws and use them to prove commutativity etc.\n-- \n-- Bool -id-- Bool -id-- Bool -id-- Bool\n-- | | | |\n-- | not id | the last square does not commute\n-- | | | |\n-- Bool -not- Bool -not- Bool -not- Bool\n--\n-- If the large rectangle commutes then the smaller squares commute. For a\n-- proof, let p o q o r o s be the left-bottom path and p' o q' o r' o s' be\n-- the top-right path. Let's focus on the square:\n-- \n-- A-- r'--C\n-- | |\n-- ? s'\n-- | |\n-- B-- s --D\n-- \n-- We have a path from A to B that is: !q' o !p' o p o q o r. \n-- Now let's see if r' o s' is equivalent to \n-- !q' o !p' o p o q o r o s\n-- We know p o q o r o s ⇔ p' o q' o r' o s' \n-- If we know that ⇔ is preserved by composition then:\n-- !q' o !p' o p o q o r o s ⇔ !q' o !p' o p' o q' o r' o s' \n-- and of course by inverses and id being unit of composition:\n-- !q' o !p' o p o q o r o s ⇔ r' o s' \n-- and we are done.\n\n{-# NO_TERMINATION_CHECK #-}\nPath∼ : ∀ {t₁ t₂ t₁' t₂' v₁ v₂ v₁' v₂'} → \n (p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) → \n (q : Path •[ t₁' , v₁' ] •[ t₂' , v₂' ]) → \n Set\n-- sequential composition\nPath∼ {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'} \n (_●_ {t₂ = t₂} {v₂ = v₂} p₁ p₂) (_●_ {t₂ = t₂'} {v₂ = v₂'} q₁ q₂) = \n (Path∼ p₁ q₁ × Path∼ p₂ q₂) ⊎\n (Path∼ {t₁} {t₂} {t₁'} {t₁'} {v₁} {v₂} {v₁'} {v₁'} p₁ id⟷• × Path∼ p₂ (q₁ ● q₂)) ⊎ \n (Path∼ p₁ (q₁ ● q₂) × Path∼ {t₂} {t₃} {t₃'} {t₃'} {v₂} {v₃} {v₃'} {v₃'} p₂ id⟷•) ⊎ \n (Path∼ {t₁} {t₁} {t₁'} {t₂'} {v₁} {v₁} {v₁'} {v₂'} id⟷• q₁ × Path∼ (p₁ ● p₂) q₂) ⊎\n (Path∼ (p₁ ● p₂) q₁ × Path∼ {t₃} {t₃} {t₂'} {t₃'} {v₃} {v₃} {v₂'} {v₃'} id⟷• q₂)\nPath∼ {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'} \n (_●_ {t₂ = t₂} {v₂ = v₂} p q) c = \n (Path∼ {t₁} {t₂} {t₁'} {t₁'} {v₁} {v₂} {v₁'} {v₁'} p id⟷• × Path∼ q c)\n ⊎ (Path∼ p c × Path∼ {t₂} {t₃} {t₃'} {t₃'} {v₂} {v₃} {v₃'} {v₃'} q id⟷•)\nPath∼ {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'} \n c (_●_ {t₂ = t₂'} {v₂ = v₂'} p q) = \n (Path∼ {t₁} {t₁} {t₁'} {t₂'} {v₁} {v₁} {v₁'} {v₂'} id⟷• p × Path∼ c q)\n ⊎ (Path∼ c p × Path∼ {t₃} {t₃} {t₂'} {t₃'} {v₃} {v₃} {v₂'} {v₃'} id⟷• q)\n-- choices\nPath∼ (⊕1• p) (⊕1• q) = Path∼ p q\nPath∼ (⊕1• p) _ = ⊥\nPath∼ _ (⊕1• p) = ⊥\nPath∼ (⊕2• p) (⊕2• q) = Path∼ p q\nPath∼ (⊕2• p) _ = ⊥\nPath∼ _ (⊕2• p) = ⊥\n-- parallel paths\nPath∼ (p₁ ⊗• p₂) (q₁ ⊗• q₂) = Path∼ p₁ q₁ × Path∼ p₂ q₂\nPath∼ (p₁ ⊗• p₂) _ = ⊥\nPath∼ _ (q₁ ⊗• q₂) = ⊥\n-- simple edges connecting two points\nPath∼ {t₁} {t₂} {t₁'} {t₂'} {v₁} {v₂} {v₁'} {v₂'} c₁ c₂ = \n Path •[ t₁ , v₁ ] •[ t₁' , v₁' ] × Path •[ t₂ , v₂ ] •[ t₂' , v₂' ] \n\n-- In the setting of finite types (in particular with no loops) every pair of\n-- paths with related start and end points is equivalent. In other words, we\n-- really have no interesting 2-path structure.\n\nallequiv : ∀ {t₁ t₂ t₁' t₂' v₁ v₂ v₁' v₂'} → \n (p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) → \n (q : Path •[ t₁' , v₁' ] •[ t₂' , v₂' ]) → \n (start : Path •[ t₁ , v₁ ] •[ t₁' , v₁' ]) → \n (end : Path •[ t₂ , v₂ ] •[ t₂' , v₂' ]) → \n Path∼ p q\nallequiv {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'} \n (_●_ {t₂ = t₂} {v₂ = v₂} p₁ p₂) (_●_ {t₂ = t₂'} {v₂ = v₂'} q₁ q₂) \n start end = {!!}\nallequiv {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'} \n (_●_ {t₂ = t₂} {v₂ = v₂} p q) c start end = {!!}\nallequiv {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'} \n c (_●_ {t₂ = t₂'} {v₂ = v₂'} p q) start end = {!!}\nallequiv (⊕1• p) (⊕1• q) start end = {!!}\nallequiv (⊕1• p) _ start end = {!!}\nallequiv _ (⊕1• p) start end = {!!}\nallequiv (⊕2• p) (⊕2• q) start end = {!!}\nallequiv (⊕2• p) _ start end = {!!}\nallequiv _ (⊕2• p) start end = {!!}\n-- parallel paths\nallequiv (p₁ ⊗• p₂) (q₁ ⊗• q₂) start end = {!!}\nallequiv (p₁ ⊗• p₂) _ start end = {!!}\nallequiv _ (q₁ ⊗• q₂) start end = {!!}\n-- simple edges connecting two points\nallequiv {t₁} {t₂} {t₁'} {t₂'} {v₁} {v₂} {v₁'} {v₂'} c₁ c₂ start end = {!!}\n\n\n\n\n\nrefl∼ : ∀ {t₁ t₂ v₁ v₂} → (p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) → Path∼ p p \nrefl∼ unite•₊ = id⟷• , id⟷• \nrefl∼ uniti•₊ = id⟷• , id⟷• \nrefl∼ swap1•₊ = id⟷• , id⟷• \nrefl∼ swap2•₊ = id⟷• , id⟷• \nrefl∼ assocl1•₊ = id⟷• , id⟷• \nrefl∼ assocl2•₊ = id⟷• , id⟷• \nrefl∼ assocl3•₊ = id⟷• , id⟷• \nrefl∼ assocr1•₊ = id⟷• , id⟷• \nrefl∼ assocr2•₊ = id⟷• , id⟷• \nrefl∼ assocr3•₊ = id⟷• , id⟷• \nrefl∼ unite•⋆ = id⟷• , id⟷• \nrefl∼ uniti•⋆ = id⟷• , id⟷• \nrefl∼ swap•⋆ = id⟷• , id⟷• \nrefl∼ assocl•⋆ = id⟷• , id⟷• \nrefl∼ assocr•⋆ = id⟷• , id⟷• \nrefl∼ distz• = id⟷• , id⟷• \nrefl∼ factorz• = id⟷• , id⟷• \nrefl∼ dist1• = id⟷• , id⟷• \nrefl∼ dist2• = id⟷• , id⟷• \nrefl∼ factor1• = id⟷• , id⟷• \nrefl∼ factor2• = id⟷• , id⟷• \nrefl∼ id⟷• = id⟷• , id⟷• \nrefl∼ (p ● q) = inj₁ (refl∼ p , refl∼ q)\nrefl∼ (⊕1• p) = refl∼ p\nrefl∼ (⊕2• q) = refl∼ q\nrefl∼ (p ⊗• q) = refl∼ p , refl∼ q \n\n-- Extensional view\n\n-- First we enumerate all the values of a given finite type\n\nsize : U → ℕ\nsize ZERO = 0\nsize ONE = 1\nsize (PLUS t₁ t₂) = size t₁ + size t₂\nsize (TIMES t₁ t₂) = size t₁ * size t₂\n\nenum : (t : U) → ⟦ t ⟧ → Fin (size t)\nenum ZERO () -- absurd\nenum ONE tt = zero\nenum (PLUS t₁ t₂) (inj₁ v₁) = inject+ (size t₂) (enum t₁ v₁)\nenum (PLUS t₁ t₂) (inj₂ v₂) = raise (size t₁) (enum t₂ v₂)\nenum (TIMES t₁ t₂) (v₁ , v₂) = fromℕ≤ (pr {s₁} {s₂} {n₁} {n₂})\n where n₁ = enum t₁ v₁\n n₂ = enum t₂ v₂\n s₁ = size t₁ \n s₂ = size t₂\n pr : {s₁ s₂ : ℕ} → {n₁ : Fin s₁} {n₂ : Fin s₂} → \n ((toℕ n₁ * s₂) + toℕ n₂) < (s₁ * s₂)\n pr {0} {_} {()} \n pr {_} {0} {_} {()}\n pr {suc s₁} {suc s₂} {zero} {zero} = {!z≤n!}\n pr {suc s₁} {suc s₂} {zero} {Fsuc n₂} = {!!}\n pr {suc s₁} {suc s₂} {Fsuc n₁} {zero} = {!!}\n pr {suc s₁} {suc s₂} {Fsuc n₁} {Fsuc n₂} = {!!}\n\nvals3 : Fin 3 × Fin 3 × Fin 3\nvals3 = (enum THREE LL , enum THREE LR , enum THREE R)\n where THREE = PLUS (PLUS ONE ONE) ONE\n LL = inj₁ (inj₁ tt)\n LR = inj₁ (inj₂ tt)\n R = inj₂ tt\n\nxxx : {s₁ s₂ : ℕ} → (i : Fin s₁) → (j : Fin s₂) → \n suc (toℕ i * s₂ + toℕ j) ≤ s₁ * s₂\nxxx {0} {_} ()\nxxx {suc s₁} {s₂} i j = {!!} \n\n-- i : Fin (suc s₁)\n-- j : Fin s₂\n-- ?0 : suc (toℕ i * s₂ + toℕ j) ≤ suc s₁ * s₂\n-- (suc (toℕ i) * s₂ + toℕ j ≤ s₂ + s₁ * s₂\n-- (suc (toℕ i) * s₂ + toℕ j ≤ s₁ * s₂ + s₂\n\n\n\nutoVecℕ : (t : U) → Vec (Fin (utoℕ t)) (utoℕ t)\nutoVecℕ ZERO = []\nutoVecℕ ONE = [ zero ]\nutoVecℕ (PLUS t₁ t₂) = \n map (inject+ (utoℕ t₂)) (utoVecℕ t₁) ++ \n map (raise (utoℕ t₁)) (utoVecℕ t₂)\nutoVecℕ (TIMES t₁ t₂) = \n concat (map (λ i → map (λ j → inject≤ (fromℕ (toℕ i * utoℕ t₂ + toℕ j)) \n (xxx i j))\n (utoVecℕ t₂))\n (utoVecℕ t₁))\n\n-- Vector representation of types so that we can test permutations\n\nutoVec : (t : U) → Vec ⟦ t ⟧ (utoℕ t)\nutoVec ZERO = []\nutoVec ONE = [ tt ]\nutoVec (PLUS t₁ t₂) = map inj₁ (utoVec t₁) ++ map inj₂ (utoVec t₂)\nutoVec (TIMES t₁ t₂) = \n concat (map (λ v₁ → map (λ v₂ → (v₁ , v₂)) (utoVec t₂)) (utoVec t₁))\n\n-- Examples permutations and their actions on a simple ordered vector\n\nmodule PermExamples where\n\n -- ordered vector: position i has value i\n ordered : ∀ {n} → Vec (Fin n) n\n ordered = tabulate id\n\n -- empty permutation p₀ { }\n\n p₀ : Perm 0\n p₀ = []\n\n v₀ = permute p₀ ordered\n\n -- permutation p₁ { 0 -> 0 }\n\n p₁ : Perm 1\n p₁ = 0F ∷ p₀\n where 0F = fromℕ 0\n\n v₁ = permute p₁ ordered\n\n -- permutations p₂ { 0 -> 0, 1 -> 1 }\n -- q₂ { 0 -> 1, 1 -> 0 }\n\n p₂ q₂ : Perm 2\n p₂ = 0F ∷ p₁ \n where 0F = inject+ 1 (fromℕ 0)\n q₂ = 1F ∷ p₁\n where 1F = fromℕ 1\n\n v₂ = permute p₂ ordered\n w₂ = permute q₂ ordered\n\n -- permutations p₃ { 0 -> 0, 1 -> 1, 2 -> 2 }\n -- s₃ { 0 -> 0, 1 -> 2, 2 -> 1 }\n -- q₃ { 0 -> 1, 1 -> 0, 2 -> 2 }\n -- r₃ { 0 -> 1, 1 -> 2, 2 -> 0 }\n -- t₃ { 0 -> 2, 1 -> 0, 2 -> 1 }\n -- u₃ { 0 -> 2, 1 -> 1, 2 -> 0 }\n\n p₃ q₃ r₃ s₃ t₃ u₃ : Perm 3\n p₃ = 0F ∷ p₂\n where 0F = inject+ 2 (fromℕ 0)\n s₃ = 0F ∷ q₂\n where 0F = inject+ 2 (fromℕ 0)\n q₃ = 1F ∷ p₂\n where 1F = inject+ 1 (fromℕ 1)\n r₃ = 2F ∷ p₂\n where 2F = fromℕ 2\n t₃ = 1F ∷ q₂\n where 1F = inject+ 1 (fromℕ 1)\n u₃ = 2F ∷ q₂\n where 2F = fromℕ 2\n\n v₃ = permute p₃ ordered\n y₃ = permute s₃ ordered\n w₃ = permute q₃ ordered\n x₃ = permute r₃ ordered\n z₃ = permute t₃ ordered\n α₃ = permute u₃ ordered\n\n -- end module PermExamples\n\n------------------------------------------------------------------------------\n-- Testing\n\nt₁ = PLUS ZERO BOOL\nt₂ = BOOL\nm₁ = matchP {t₁} {t₂} unite₊\n-- (inj₂ (inj₁ tt) , inj₁ tt) ∷ (inj₂ (inj₂ tt) , inj₂ tt) ∷ []\nm₂ = matchP {t₂} {t₁} uniti₊\n-- (inj₁ tt , inj₂ (inj₁ tt)) ∷ (inj₂ tt , inj₂ (inj₂ tt)) ∷ []\n\nt₃ = PLUS BOOL ONE\nt₄ = PLUS ONE BOOL\nm₃ = matchP {t₃} {t₄} swap₊\n-- (inj₂ tt , inj₁ tt) ∷\n-- (inj₁ (inj₁ tt) , inj₂ (inj₁ tt)) ∷\n-- (inj₁ (inj₂ tt) , inj₂ (inj₂ tt)) ∷ []\nm₄ = matchP {t₄} {t₃} swap₊\n-- (inj₂ (inj₁ tt) , inj₁ (inj₁ tt)) ∷\n-- (inj₂ (inj₂ tt) , inj₁ (inj₂ tt)) ∷ \n-- (inj₁ tt , inj₂ tt) ∷ []\n\nt₅ = PLUS ONE (PLUS BOOL ONE)\nt₆ = PLUS (PLUS ONE BOOL) ONE\nm₅ = matchP {t₅} {t₆} assocl₊\n-- (inj₁ tt , inj₁ (inj₁ tt)) ∷\n-- (inj₂ (inj₁ (inj₁ tt)) , inj₁ (inj₂ (inj₁ tt))) ∷\n-- (inj₂ (inj₁ (inj₂ tt)) , inj₁ (inj₂ (inj₂ tt))) ∷\n-- (inj₂ (inj₂ tt) , inj₂ tt) ∷ []\nm₆ = matchP {t₆} {t₅} assocr₊\n-- (inj₁ (inj₁ tt) , inj₁ tt) ∷\n-- (inj₁ (inj₂ (inj₁ tt)) , inj₂ (inj₁ (inj₁ tt))) ∷\n-- (inj₁ (inj₂ (inj₂ tt)) , inj₂ (inj₁ (inj₂ tt))) ∷\n-- (inj₂ tt , inj₂ (inj₂ tt)) ∷ []\n\nt₇ = TIMES ONE BOOL\nt₈ = BOOL\nm₇ = matchP {t₇} {t₈} unite⋆\n-- ((tt , inj₁ tt) , inj₁ tt) ∷ ((tt , inj₂ tt) , inj₂ tt) ∷ []\nm₈ = matchP {t₈} {t₇} uniti⋆\n-- (inj₁ tt , (tt , inj₁ tt)) ∷ (inj₂ tt , (tt , inj₂ tt)) ∷ []\n\nt₉ = TIMES BOOL ONE\nt₁₀ = TIMES ONE BOOL\nm₉ = matchP {t₉} {t₁₀} swap⋆\n-- ((inj₁ tt , tt) , (tt , inj₁ tt)) ∷\n-- ((inj₂ tt , tt) , (tt , inj₂ tt)) ∷ []\nm₁₀ = matchP {t₁₀} {t₉} swap⋆\n-- ((tt , inj₁ tt) , (inj₁ tt , tt)) ∷\n-- ((tt , inj₂ tt) , (inj₂ tt , tt)) ∷ []\n\nt₁₁ = TIMES BOOL (TIMES ONE BOOL)\nt₁₂ = TIMES (TIMES BOOL ONE) BOOL\nm₁₁ = matchP {t₁₁} {t₁₂} assocl⋆\n-- ((inj₁ tt , (tt , inj₁ tt)) , ((inj₁ tt , tt) , inj₁ tt)) ∷\n-- ((inj₁ tt , (tt , inj₂ tt)) , ((inj₁ tt , tt) , inj₂ tt)) ∷\n-- ((inj₂ tt , (tt , inj₁ tt)) , ((inj₂ tt , tt) , inj₁ tt)) ∷\n-- ((inj₂ tt , (tt , inj₂ tt)) , ((inj₂ tt , tt) , inj₂ tt)) ∷ []\nm₁₂ = matchP {t₁₂} {t₁₁} assocr⋆\n-- (((inj₁ tt , tt) , inj₁ tt) , (inj₁ tt , (tt , inj₁ tt)) ∷\n-- (((inj₁ tt , tt) , inj₂ tt) , (inj₁ tt , (tt , inj₂ tt)) ∷\n-- (((inj₂ tt , tt) , inj₁ tt) , (inj₂ tt , (tt , inj₁ tt)) ∷\n-- (((inj₂ tt , tt) , inj₂ tt) , (inj₂ tt , (tt , inj₂ tt)) ∷ []\n\nt₁₃ = TIMES ZERO BOOL\nt₁₄ = ZERO\nm₁₃ = matchP {t₁₃} {t₁₄} distz\n-- []\nm₁₄ = matchP {t₁₄} {t₁₃} factorz\n-- []\n\nt₁₅ = TIMES (PLUS BOOL ONE) BOOL\nt₁₆ = PLUS (TIMES BOOL BOOL) (TIMES ONE BOOL)\nm₁₅ = matchP {t₁₅} {t₁₆} dist\n-- ((inj₁ (inj₁ tt) , inj₁ tt) , inj₁ (inj₁ tt , inj₁ tt)) ∷\n-- ((inj₁ (inj₁ tt) , inj₂ tt) , inj₁ (inj₁ tt , inj₂ tt)) ∷\n-- ((inj₁ (inj₂ tt) , inj₁ tt) , inj₁ (inj₂ tt , inj₁ tt)) ∷\n-- ((inj₁ (inj₂ tt) , inj₂ tt) , inj₁ (inj₂ tt , inj₂ tt)) ∷\n-- ((inj₂ tt , inj₁ tt) , inj₂ (tt , inj₁ tt)) ∷\n-- ((inj₂ tt , inj₂ tt) , inj₂ (tt , inj₂ tt)) ∷ []\nm₁₆ = matchP {t₁₆} {t₁₅} factor\n-- (inj₁ (inj₁ tt , inj₁ tt) , (inj₁ (inj₁ tt) , inj₁ tt)) ∷\n-- (inj₁ (inj₁ tt , inj₂ tt) , (inj₁ (inj₁ tt) , inj₂ tt)) ∷\n-- (inj₁ (inj₂ tt , inj₁ tt) , (inj₁ (inj₂ tt) , inj₁ tt)) ∷\n-- (inj₁ (inj₂ tt , inj₂ tt) , (inj₁ (inj₂ tt) , inj₂ tt)) ∷\n-- (inj₂ (tt , inj₁ tt) , (inj₂ tt , inj₁ tt)) ∷\n-- (inj₂ (tt , inj₂ tt) , (inj₂ tt , inj₂ tt)) ∷ []\n\nt₁₇ = BOOL \nt₁₈ = BOOL\nm₁₇ = matchP {t₁₇} {t₁₈} id⟷\n-- (inj₁ tt , inj₁ tt) ∷ (inj₂ tt , inj₂ tt) ∷ []\n\n--◎\n--⊕\n--⊗\n\n------------------------------------------------------------------------------\n\nmergeS :: SubPerm → SubPerm (suc m * n) (m * n) → SubPerm (suc m * suc n) (m * suc n) \nmergeS = ? \n\nsubP : ∀ {m n} → Fin (suc m) → Perm n → SubPerm (suc m * n) (m * n)\nsubP {m} {0} i β = {!!}\nsubP {m} {suc n} i (j ∷ β) = mergeS ? (subP {m} {n} i β)\n\n\n-- injectP (Perm n) (m * n) \n-- ...\n-- SP (suc m * n) (m * n)\n-- SP (n + m * n) (m * n)\n\n--SP (suc m * n) (m * n) \n--\n--\n--==> \n--\n--(suc m * suc n) (m * suc n)\n\n--m : ℕ\n--n : ℕ\n--i : Fin (suc m)\n--j : Fin (suc n)\n--β : Perm n\n--?1 : SubPerm (suc m * suc n) (m * suc n)\n\n\ntcompperm : ∀ {m n} → Perm m → Perm n → Perm (m * n)\ntcompperm [] β = []\ntcompperm (i ∷ α) β = merge (subP i β) (tcompperm α β)\n\n-- shift m=3 n=4 i=ax:F3 β=[ay:F4,by:F3,cy:F2,dy:F1] γ=[r4,...,r11]:P8\n-- ==> [F12,F11,F10,F9...γ]\n\n-- m = 3\n-- n = 4\n-- 3 * 4\n-- x = [ ax, bx, cx ] : P 3, y : [ay, by, cy, dy] : P 4\n-- (shift ax 4 y) || \n-- ( (shift bx 4 y) ||\n-- ( (shift cx 4 y) ||\n-- [])))\n-- \n-- ax : F3, bx : F2, cx : F1\n-- ay : F4, by : F3, cy : F2, dy : F1\n--\n-- suc m = 3, m = 2\n-- F12 F11 F10 F9 F8 F7 F6 F5 F4 F3 F2 F1\n-- [ r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11 ]\n-- ---------------\n-- ax : F3 with y=[F4,F3,F2,F1]\n-- --------------\n-- bx : F2\n-- ------------------\n-- cx : F1\n\n -- β should be something like i * n + entry in β\n\n0 * n = 0\n(suc m) * n = n + (m * n)\n\ncomb2perm (c₁ ⊗ c₂) = tcompperm (comb2perm c₁) (comb2perm c₂) \n\nc1 = swap+ (f->t,t->f) [1,0]\nc2 = id (f->f,t->t) [0,0]\n\nc1xc2 (f,f)->(t,f), (f,t)->(t,t), (t,f)->(f,f), (t,t)->(f,t)\n[\n\nff ft tf tt\n 2 2 0 0\n\nindex in α * n + index in β\n\npex qex pqex qpex : Perm 3\npex = inject+ 1 (fromℕ 1) ∷ fromℕ 1 ∷ zero ∷ []\nqex = zero ∷ fromℕ 1 ∷ zero ∷ []\npqex = fromℕ 2 ∷ fromℕ 1 ∷ zero ∷ []\nqpex = inject+ 1 (fromℕ 1) ∷ zero ∷ zero ∷ []\n\npqexv = (permute qex ∘ permute pex) (tabulate id)\npqexv' = permute pqex (tabulate id) \n\nqpexv = (permute pex ∘ permute qex) (tabulate id)\nqpexv' = permute qpex (tabulate id)\n\n-- [1,1,0]\n-- [z] => [z]\n-- [y,z] => [z,y]\n-- [x,y,z] => [z,x,y] \n\n-- [0,1,0]\n-- [w] => [w]\n-- [v,w] => [w,v]\n-- [u,v,w] => [u,w,v]\n\n-- R,R,_ ◌ _,R,_\n-- R in p1 takes you to middle which also goes R, so first goes RR\n-- [a,b,c] ◌ [d,e,f]\n-- [a+p2[a], ...]\n\n-- [1,1,0] ◌ [0,1,0] one step [2,1,0]\n-- [z] => [z]\n-- [y,z] => [z,y]\n-- [x,y,z] => [z,y,x]\n\n-- [1,1,0] ◌ [0,1,0]\n-- [z] => [z] => [z]\n-- [y,z] => \n-- [x,y,z] => \n\n-- so [1,1,0] ◌ [0,1,0] ==> [2,1,0]\n-- so [0,1,0] ◌ [1,1,0] ==> [1,0,0]\n\n-- pex takes [0,1,2] to [2,0,1]\n-- qex takes [0,1,2] to [0,2,1]\n-- pex ◌ qex takes [0,1,2] to [2,1,0]\n-- qex ◌ pex takes [0,1,2] to [1,0,2]\n\n-- seq : ∀ {m n} → (m ≤ n) → Perm m → Perm n → Perm m\n-- seq lp [] _ = []\n-- seq lp (i ∷ p) q = (lookupP i q) ∷ (seq lp p q)\n\n-- i F+ ...\n\n-- lookupP : ∀ {n} → Fin n → Perm n → Fin n\n-- i : Fin (suc m)\n-- p : Perm m\n-- q : Perm n\n\n\n-- \n-- (zero ∷ p₁) ◌ (q ∷ q₁) = q ∷ (p₁ ◌ q₁)\n-- (suc p ∷ p₁) ◌ (zero ∷ q₁) = {!!}\n-- (suc p ∷ p₁) ◌ (suc q ∷ q₁) = {!!}\n-- \n-- data Perm : ℕ → Set where\n-- [] : Perm 0\n-- _∷_ : {n : ℕ} → Fin (suc n) → Perm n → Perm (suc n)\n\n-- Given a vector of (suc n) elements, return one of the elements and\n-- the rest. Example: pick (inject+ 1 (fromℕ 1)) (10 ∷ 20 ∷ 30 ∷ 40 ∷ [])\n\npick : ∀ {ℓ} {n : ℕ} {A : Set ℓ} → Fin n → Vec A (suc n) → (A × Vec A n)\npick {ℓ} {0} {A} ()\npick {ℓ} {suc n} {A} zero (v ∷ vs) = (v , vs)\npick {ℓ} {suc n} {A} (suc i) (v ∷ vs) = \n let (w , ws) = pick {ℓ} {n} {A} i vs \n in (w , v ∷ ws)\n\ninsertV : ∀ {ℓ} {n : ℕ} {A : Set ℓ} → \n A → Fin (suc n) → Vec A n → Vec A (suc n) \ninsertV {n = 0} v zero [] = [ v ]\ninsertV {n = 0} v (suc ()) \ninsertV {n = suc n} v zero vs = v ∷ vs\ninsertV {n = suc n} v (suc i) (w ∷ ws) = w ∷ insertV v i ws\n\n-- A permutation takes two vectors of the same size, matches one\n-- element from each and returns another permutation\n\ndata P {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') : \n (m n : ℕ) → (m ≡ n) → Vec A m → Vec B n → Set (ℓ ⊔ ℓ') where\n nil : P A B 0 0 refl [] []\n cons : {m n : ℕ} {i : Fin (suc m)} {j : Fin (suc n)} → (p : m ≡ n) → \n (v : A) → (w : B) → (vs : Vec A m) → (ws : Vec B n) →\n P A B m n p vs ws → \n P A B (suc m) (suc n) (cong suc p) (insertV v i vs) (insertV w j ws)\n\n-- A permutation is a sequence of \"insertions\".\n\ninfixr 5 _∷_\n\ndata Perm : ℕ → Set where\n [] : Perm 0\n _∷_ : {n : ℕ} → Fin (suc n) → Perm n → Perm (suc n)\n\nlookupP : ∀ {n} → Fin n → Perm n → Fin n\nlookupP () [] \nlookupP zero (j ∷ _) = j\nlookupP {suc n} (suc i) (j ∷ q) = inject₁ (lookupP i q)\n\ninsert : ∀ {ℓ n} {A : Set ℓ} → Vec A n → Fin (suc n) → A → Vec A (suc n)\ninsert vs zero w = w ∷ vs\ninsert [] (suc ()) -- absurd\ninsert (v ∷ vs) (suc i) w = v ∷ insert vs i w\n\n-- A permutation acts on a vector by inserting each element in its new\n-- position.\n\npermute : ∀ {ℓ n} {A : Set ℓ} → Perm n → Vec A n → Vec A n\npermute [] [] = []\npermute (p ∷ ps) (v ∷ vs) = insert (permute ps vs) p v\n\n-- Use a permutation to match up the elements in two vectors. See more\n-- convenient function matchP below.\n\nmatch : ∀ {t t'} → (size t ≡ size t') → Perm (size t) → \n Vec ⟦ t ⟧ (size t) → Vec ⟦ t' ⟧ (size t) → \n Vec (⟦ t ⟧ × ⟦ t' ⟧) (size t)\nmatch {t} {t'} sp α vs vs' = \n let js = permute α (tabulate id)\n in zip (tabulate (λ j → lookup (lookup j js) vs)) vs'\n\n-- swap\n-- \n-- swapperm produces the permutations that maps:\n-- [ a , b || x , y , z ] \n-- to \n-- [ x , y , z || a , b ]\n-- Ex. \n-- permute (swapperm {5} (inject+ 2 (fromℕ 2))) ordered=[0,1,2,3,4]\n-- produces [2,3,4,0,1]\n-- Explicitly:\n-- swapex : Perm 5\n-- swapex = inject+ 1 (fromℕ 3) -- :: Fin 5\n-- ∷ inject+ 0 (fromℕ 3) -- :: Fin 4\n-- ∷ zero\n-- ∷ zero\n-- ∷ zero\n-- ∷ []\n\nswapperm : ∀ {n} → Fin n → Perm n\nswapperm {0} () -- absurd\nswapperm {suc n} zero = idperm\nswapperm {suc n} (suc i) = \n subst Fin (-+-id n i) \n (inject+ (toℕ i) (fromℕ (n ∸ toℕ i))) ∷ swapperm {n} i\n\n-- compositions\n\n-- Sequential composition\n\nscompperm : ∀ {n} → Perm n → Perm n → Perm n\nscompperm α β = {!!} \n\n-- Sub-permutations\n-- useful for parallel and multiplicative compositions\n\n-- Perm 4 has elements [Fin 4, Fin 3, Fin 2, Fin 1]\n-- SubPerm 11 7 has elements [Fin 11, Fin 10, Fin 9, Fin 8]\n-- So Perm 4 is a special case SubPerm 4 0\n\ndata SubPerm : ℕ → ℕ → Set where\n []s : {n : ℕ} → SubPerm n n\n _∷s_ : {n m : ℕ} → Fin (suc n) → SubPerm n m → SubPerm (suc n) m\n\nmerge : ∀ {m n} → SubPerm m n → Perm n → Perm m\nmerge []s β = β\nmerge (i ∷s α) β = i ∷ merge α β\n\ninjectP : ∀ {m} → Perm m → (n : ℕ) → SubPerm (m + n) n\ninjectP [] n = []s \ninjectP (i ∷ α) n = inject+ n i ∷s injectP α n\n \n-- Parallel + composition\n\npcompperm : ∀ {m n} → Perm m → Perm n → Perm (m + n)\npcompperm {m} {n} α β = merge (injectP α n) β\n\n-- Multiplicative * composition\n\ntcompperm : ∀ {m n} → Perm m → Perm n → Perm (m * n)\ntcompperm [] β = []\ntcompperm (i ∷ α) β = {!!} \n\n------------------------------------------------------------------------------\n-- A combinator t₁ ⟷ t₂ denotes a permutation.\n\ncomb2perm : {t₁ t₂ : U} → (c : t₁ ⟷ t₂) → Perm (size t₁)\ncomb2perm {PLUS ZERO t} {.t} unite₊ = idperm\ncomb2perm {t} {PLUS ZERO .t} uniti₊ = idperm\ncomb2perm {PLUS t₁ t₂} {PLUS .t₂ .t₁} swap₊ with size t₂\n... | 0 = idperm \n... | suc j = swapperm {size t₁ + suc j} \n (inject≤ (fromℕ (size t₁)) (suc≤ (size t₁) j))\ncomb2perm {PLUS t₁ (PLUS t₂ t₃)} {PLUS (PLUS .t₁ .t₂) .t₃} assocl₊ = idperm\ncomb2perm {PLUS (PLUS t₁ t₂) t₃} {PLUS .t₁ (PLUS .t₂ .t₃)} assocr₊ = idperm\ncomb2perm {TIMES ONE t} {.t} unite⋆ = idperm\ncomb2perm {t} {TIMES ONE .t} uniti⋆ = idperm\ncomb2perm {TIMES t₁ t₂} {TIMES .t₂ .t₁} swap⋆ = idperm \ncomb2perm assocl⋆ = idperm \ncomb2perm assocr⋆ = idperm \ncomb2perm distz = idperm \ncomb2perm factorz = idperm \ncomb2perm dist = idperm \ncomb2perm factor = idperm \ncomb2perm id⟷ = idperm \ncomb2perm (c₁ ◎ c₂) = scompperm \n (comb2perm c₁) \n (subst Perm (sym (size≡ c₁)) (comb2perm c₂))\ncomb2perm (c₁ ⊕ c₂) = pcompperm (comb2perm c₁) (comb2perm c₂) \ncomb2perm (c₁ ⊗ c₂) = tcompperm (comb2perm c₁) (comb2perm c₂) \n\n-- Convenient way of \"seeing\" what the permutation does for each combinator\n\nmatchP : ∀ {t t'} → (t ⟷ t') → Vec (⟦ t ⟧ × ⟦ t' ⟧) (size t)\nmatchP {t} {t'} c = \n match sp (comb2perm c) (utoVec t) \n (subst (λ n → Vec ⟦ t' ⟧ n) (sym sp) (utoVec t'))\n where sp = size≡ c\n\n------------------------------------------------------------------------------\n-- Extensional equivalence of combinators: two combinators are\n-- equivalent if they denote the same permutation. Generally we would\n-- require that the two permutations map the same value x to values y\n-- and z that have a path between them, but because the internals of each\n-- type are discrete groupoids, this reduces to saying that y and z\n-- are identical, and hence that the permutations are identical.\n\ninfix 10 _∼_ \n\n_∼_ : ∀ {t₁ t₂} → (c₁ c₂ : t₁ ⟷ t₂) → Set\nc₁ ∼ c₂ = (comb2perm c₁ ≡ comb2perm c₂)\n\n-- The relation ~ is an equivalence relation\n\nrefl∼ : ∀ {t₁ t₂} {c : t₁ ⟷ t₂} → (c ∼ c)\nrefl∼ = refl \n\nsym∼ : ∀ {t₁ t₂} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₂ ∼ c₁)\nsym∼ = sym\n\ntrans∼ : ∀ {t₁ t₂} {c₁ c₂ c₃ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₂ ∼ c₃) → (c₁ ∼ c₃)\ntrans∼ = trans\n\n-- The relation ~ validates the groupoid laws\n\nc◎id∼c : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ◎ id⟷ ∼ c\nc◎id∼c = {!!} \n\nid◎c∼c : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ◎ c ∼ c\nid◎c∼c = {!!} \n\nassoc∼ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} → \n c₁ ◎ (c₂ ◎ c₃) ∼ (c₁ ◎ c₂) ◎ c₃\nassoc∼ = {!!} \n\nlinv∼ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ◎ ! c ∼ id⟷\nlinv∼ = {!!} \n\nrinv∼ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → ! c ◎ c ∼ id⟷\nrinv∼ = {!!} \n\nresp∼ : {t₁ t₂ t₃ : U} {c₁ c₂ : t₁ ⟷ t₂} {c₃ c₄ : t₂ ⟷ t₃} → \n (c₁ ∼ c₂) → (c₃ ∼ c₄) → (c₁ ◎ c₃ ∼ c₂ ◎ c₄)\nresp∼ = {!!} \n\n-- The equivalence ∼ of paths makes U a 1groupoid: the points are\n-- types (t : U); the 1paths are ⟷; and the 2paths between them are\n-- based on extensional equivalence ∼\n\nG : 1Groupoid\nG = record\n { set = U\n ; _↝_ = _⟷_\n ; _≈_ = _∼_\n ; id = id⟷\n ; _∘_ = λ p q → q ◎ p\n ; _⁻¹ = !\n ; lneutr = λ c → c◎id∼c {c = c}\n ; rneutr = λ c → id◎c∼c {c = c}\n ; assoc = λ c₃ c₂ c₁ → assoc∼ {c₁ = c₁} {c₂ = c₂} {c₃ = c₃} \n ; equiv = record { \n refl = λ {c} → refl∼ {c = c}\n ; sym = λ {c₁} {c₂} → sym∼ {c₁ = c₁} {c₂ = c₂}\n ; trans = λ {c₁} {c₂} {c₃} → trans∼ {c₁ = c₁} {c₂ = c₂} {c₃ = c₃} \n }\n ; linv = λ c → linv∼ {c = c} \n ; rinv = λ c → rinv∼ {c = c} \n ; ∘-resp-≈ = λ α β → resp∼ β α \n }\n\n-- And there are additional laws\n\nassoc⊕∼ : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n c₁ ⊕ (c₂ ⊕ c₃) ∼ assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊\nassoc⊕∼ = {!!} \n\nassoc⊗∼ : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n c₁ ⊗ (c₂ ⊗ c₃) ∼ assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆\nassoc⊗∼ = {!!} \n\n------------------------------------------------------------------------------\n-- Picture so far:\n--\n-- path p\n-- =====================\n-- || || ||\n-- || ||2path ||\n-- || || ||\n-- || || path q ||\n-- t₁ =================t₂\n-- || ... ||\n-- =====================\n--\n-- The types t₁, t₂, etc are discrete groupoids. The paths between\n-- them correspond to permutations. Each syntactically different\n-- permutation corresponds to a path but equivalent permutations are\n-- connected by 2paths. But now we want an alternative definition of\n-- 2paths that is structural, i.e., that looks at the actual\n-- construction of the path t₁ ⟷ t₂ in terms of combinators... The\n-- theorem we want is that α ∼ β iff we can rewrite α to β using\n-- various syntactic structural rules. We start with a collection of\n-- simplication rules and then try to show they are complete.\n\n-- Simplification rules\n\ninfix 30 _⇔_\n\ndata _⇔_ : {t₁ t₂ : U} → (t₁ ⟷ t₂) → (t₁ ⟷ t₂) → Set where\n assoc◎l : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} → \n (c₁ ◎ (c₂ ◎ c₃)) ⇔ ((c₁ ◎ c₂) ◎ c₃)\n assoc◎r : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} → \n ((c₁ ◎ c₂) ◎ c₃) ⇔ (c₁ ◎ (c₂ ◎ c₃))\n assoc⊕l : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (c₁ ⊕ (c₂ ⊕ c₃)) ⇔ (assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊)\n assoc⊕r : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊) ⇔ (c₁ ⊕ (c₂ ⊕ c₃))\n assoc⊗l : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (c₁ ⊗ (c₂ ⊗ c₃)) ⇔ (assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆)\n assoc⊗r : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆) ⇔ (c₁ ⊗ (c₂ ⊗ c₃))\n dist⇔ : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n ((c₁ ⊕ c₂) ⊗ c₃) ⇔ (dist ◎ ((c₁ ⊗ c₃) ⊕ (c₂ ⊗ c₃)) ◎ factor)\n factor⇔ : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (dist ◎ ((c₁ ⊗ c₃) ⊕ (c₂ ⊗ c₃)) ◎ factor) ⇔ ((c₁ ⊕ c₂) ⊗ c₃)\n idl◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (id⟷ ◎ c) ⇔ c\n idl◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ id⟷ ◎ c\n idr◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (c ◎ id⟷) ⇔ c\n idr◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ (c ◎ id⟷) \n linv◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (c ◎ ! c) ⇔ id⟷\n linv◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ⇔ (c ◎ ! c) \n rinv◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (! c ◎ c) ⇔ id⟷\n rinv◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ⇔ (! c ◎ c) \n unitel₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} → \n (unite₊ ◎ c₂) ⇔ ((c₁ ⊕ c₂) ◎ unite₊)\n uniter₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} → \n ((c₁ ⊕ c₂) ◎ unite₊) ⇔ (unite₊ ◎ c₂)\n unitil₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} → \n (uniti₊ ◎ (c₁ ⊕ c₂)) ⇔ (c₂ ◎ uniti₊)\n unitir₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} → \n (c₂ ◎ uniti₊) ⇔ (uniti₊ ◎ (c₁ ⊕ c₂))\n unitial₊⇔ : {t₁ t₂ : U} → (uniti₊ {PLUS t₁ t₂} ◎ assocl₊) ⇔ (uniti₊ ⊕ id⟷)\n unitiar₊⇔ : {t₁ t₂ : U} → (uniti₊ {t₁} ⊕ id⟷ {t₂}) ⇔ (uniti₊ ◎ assocl₊)\n swapl₊⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} → \n (swap₊ ◎ (c₁ ⊕ c₂)) ⇔ ((c₂ ⊕ c₁) ◎ swap₊)\n swapr₊⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} → \n ((c₂ ⊕ c₁) ◎ swap₊) ⇔ (swap₊ ◎ (c₁ ⊕ c₂))\n unitel⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} → \n (unite⋆ ◎ c₂) ⇔ ((c₁ ⊗ c₂) ◎ unite⋆)\n uniter⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} → \n ((c₁ ⊗ c₂) ◎ unite⋆) ⇔ (unite⋆ ◎ c₂)\n unitil⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} → \n (uniti⋆ ◎ (c₁ ⊗ c₂)) ⇔ (c₂ ◎ uniti⋆)\n unitir⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} → \n (c₂ ◎ uniti⋆) ⇔ (uniti⋆ ◎ (c₁ ⊗ c₂))\n unitial⋆⇔ : {t₁ t₂ : U} → (uniti⋆ {TIMES t₁ t₂} ◎ assocl⋆) ⇔ (uniti⋆ ⊗ id⟷)\n unitiar⋆⇔ : {t₁ t₂ : U} → (uniti⋆ {t₁} ⊗ id⟷ {t₂}) ⇔ (uniti⋆ ◎ assocl⋆)\n swapl⋆⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} → \n (swap⋆ ◎ (c₁ ⊗ c₂)) ⇔ ((c₂ ⊗ c₁) ◎ swap⋆)\n swapr⋆⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} → \n ((c₂ ⊗ c₁) ◎ swap⋆) ⇔ (swap⋆ ◎ (c₁ ⊗ c₂))\n swapfl⋆⇔ : {t₁ t₂ t₃ : U} → \n (swap₊ {TIMES t₂ t₃} {TIMES t₁ t₃} ◎ factor) ⇔ \n (factor ◎ (swap₊ {t₂} {t₁} ⊗ id⟷))\n swapfr⋆⇔ : {t₁ t₂ t₃ : U} → \n (factor ◎ (swap₊ {t₂} {t₁} ⊗ id⟷)) ⇔ \n (swap₊ {TIMES t₂ t₃} {TIMES t₁ t₃} ◎ factor)\n id⇔ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ c\n trans⇔ : {t₁ t₂ : U} {c₁ c₂ c₃ : t₁ ⟷ t₂} → \n (c₁ ⇔ c₂) → (c₂ ⇔ c₃) → (c₁ ⇔ c₃)\n resp◎⇔ : {t₁ t₂ t₃ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₁ ⟷ t₂} {c₄ : t₂ ⟷ t₃} → \n (c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ◎ c₂) ⇔ (c₃ ◎ c₄)\n resp⊕⇔ : {t₁ t₂ t₃ t₄ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₁ ⟷ t₂} {c₄ : t₃ ⟷ t₄} → \n (c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ⊕ c₂) ⇔ (c₃ ⊕ c₄)\n resp⊗⇔ : {t₁ t₂ t₃ t₄ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₁ ⟷ t₂} {c₄ : t₃ ⟷ t₄} → \n (c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ⊗ c₂) ⇔ (c₃ ⊗ c₄)\n\n-- better syntax for writing 2paths\n\ninfix 2 _▤ \ninfixr 2 _⇔⟨_⟩_ \n\n_⇔⟨_⟩_ : {t₁ t₂ : U} (c₁ : t₁ ⟷ t₂) {c₂ : t₁ ⟷ t₂} {c₃ : t₁ ⟷ t₂} → \n (c₁ ⇔ c₂) → (c₂ ⇔ c₃) → (c₁ ⇔ c₃)\n_ ⇔⟨ α ⟩ β = trans⇔ α β \n\n_▤ : {t₁ t₂ : U} → (c : t₁ ⟷ t₂) → (c ⇔ c)\n_▤ c = id⇔ \n\n-- Inverses for 2paths\n\n2! : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ⇔ c₂) → (c₂ ⇔ c₁)\n2! assoc◎l = assoc◎r\n2! assoc◎r = assoc◎l\n2! assoc⊕l = assoc⊕r\n2! assoc⊕r = assoc⊕l\n2! assoc⊗l = assoc⊗r\n2! assoc⊗r = assoc⊗l\n2! dist⇔ = factor⇔ \n2! factor⇔ = dist⇔\n2! idl◎l = idl◎r\n2! idl◎r = idl◎l\n2! idr◎l = idr◎r\n2! idr◎r = idr◎l\n2! linv◎l = linv◎r\n2! linv◎r = linv◎l\n2! rinv◎l = rinv◎r\n2! rinv◎r = rinv◎l\n2! unitel₊⇔ = uniter₊⇔\n2! uniter₊⇔ = unitel₊⇔\n2! unitil₊⇔ = unitir₊⇔\n2! unitir₊⇔ = unitil₊⇔\n2! swapl₊⇔ = swapr₊⇔\n2! swapr₊⇔ = swapl₊⇔\n2! unitial₊⇔ = unitiar₊⇔ \n2! unitiar₊⇔ = unitial₊⇔ \n2! unitel⋆⇔ = uniter⋆⇔\n2! uniter⋆⇔ = unitel⋆⇔\n2! unitil⋆⇔ = unitir⋆⇔\n2! unitir⋆⇔ = unitil⋆⇔\n2! unitial⋆⇔ = unitiar⋆⇔ \n2! unitiar⋆⇔ = unitial⋆⇔ \n2! swapl⋆⇔ = swapr⋆⇔\n2! swapr⋆⇔ = swapl⋆⇔\n2! swapfl⋆⇔ = swapfr⋆⇔\n2! swapfr⋆⇔ = swapfl⋆⇔\n2! id⇔ = id⇔\n2! (trans⇔ α β) = trans⇔ (2! β) (2! α)\n2! (resp◎⇔ α β) = resp◎⇔ (2! α) (2! β)\n2! (resp⊕⇔ α β) = resp⊕⇔ (2! α) (2! β)\n2! (resp⊗⇔ α β) = resp⊗⇔ (2! α) (2! β) \n\n-- a nice example of 2 paths\n\nnegEx : neg₅ ⇔ neg₁\nnegEx = uniti⋆ ◎ (swap⋆ ◎ ((swap₊ ⊗ id⟷) ◎ (swap⋆ ◎ unite⋆)))\n ⇔⟨ resp◎⇔ id⇔ assoc◎l ⟩\n uniti⋆ ◎ ((swap⋆ ◎ (swap₊ ⊗ id⟷)) ◎ (swap⋆ ◎ unite⋆))\n ⇔⟨ resp◎⇔ id⇔ (resp◎⇔ swapl⋆⇔ id⇔) ⟩\n uniti⋆ ◎ (((id⟷ ⊗ swap₊) ◎ swap⋆) ◎ (swap⋆ ◎ unite⋆))\n ⇔⟨ resp◎⇔ id⇔ assoc◎r ⟩\n uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ (swap⋆ ◎ (swap⋆ ◎ unite⋆)))\n ⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ assoc◎l) ⟩\n uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ ((swap⋆ ◎ swap⋆) ◎ unite⋆))\n ⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ (resp◎⇔ linv◎l id⇔)) ⟩\n uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ (id⟷ ◎ unite⋆))\n ⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ idl◎l) ⟩\n uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ unite⋆)\n ⇔⟨ assoc◎l ⟩\n (uniti⋆ ◎ (id⟷ ⊗ swap₊)) ◎ unite⋆\n ⇔⟨ resp◎⇔ unitil⋆⇔ id⇔ ⟩\n (swap₊ ◎ uniti⋆) ◎ unite⋆\n ⇔⟨ assoc◎r ⟩\n swap₊ ◎ (uniti⋆ ◎ unite⋆)\n ⇔⟨ resp◎⇔ id⇔ linv◎l ⟩\n swap₊ ◎ id⟷\n ⇔⟨ idr◎l ⟩\n swap₊ ▤\n\n-- The equivalence ⇔ of paths is rich enough to make U a 1groupoid:\n-- the points are types (t : U); the 1paths are ⟷; and the 2paths\n-- between them are based on the simplification rules ⇔ \n\nG' : 1Groupoid\nG' = record\n { set = U\n ; _↝_ = _⟷_\n ; _≈_ = _⇔_\n ; id = id⟷\n ; _∘_ = λ p q → q ◎ p\n ; _⁻¹ = !\n ; lneutr = λ _ → idr◎l\n ; rneutr = λ _ → idl◎l\n ; assoc = λ _ _ _ → assoc◎l\n ; equiv = record { \n refl = id⇔\n ; sym = 2!\n ; trans = trans⇔\n }\n ; linv = λ {t₁} {t₂} α → linv◎l\n ; rinv = λ {t₁} {t₂} α → rinv◎l\n ; ∘-resp-≈ = λ p∼q r∼s → resp◎⇔ r∼s p∼q \n }\n\n------------------------------------------------------------------------------\n-- Inverting permutations to syntactic combinators\n\nperm2comb : {t₁ t₂ : U} → (size t₁ ≡ size t₂) → Perm (size t₁) → (t₁ ⟷ t₂)\nperm2comb {ZERO} {t₂} sp [] = {!!} \nperm2comb {ONE} {t₂} sp p = {!!} \nperm2comb {PLUS t₁ t₂} {t₃} sp p = {!!} \nperm2comb {TIMES t₁ t₂} {t₃} sp p = {!!} \n\n------------------------------------------------------------------------------\n-- Soundness and completeness\n-- \n-- Proof of soundness and completeness: now we want to verify that ⇔\n-- is sound and complete with respect to ∼. The statement to prove is\n-- that for all c₁ and c₂, we have c₁ ∼ c₂ iff c₁ ⇔ c₂\n\nsoundness : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ⇔ c₂) → (c₁ ∼ c₂)\nsoundness assoc◎l = assoc∼\nsoundness assoc◎r = sym∼ assoc∼\nsoundness assoc⊕l = assoc⊕∼\nsoundness assoc⊕r = sym∼ assoc⊕∼\nsoundness assoc⊗l = assoc⊗∼\nsoundness assoc⊗r = sym∼ assoc⊗∼\nsoundness dist⇔ = {!!}\nsoundness factor⇔ = {!!}\nsoundness idl◎l = id◎c∼c\nsoundness idl◎r = sym∼ id◎c∼c\nsoundness idr◎l = c◎id∼c\nsoundness idr◎r = sym∼ c◎id∼c\nsoundness linv◎l = linv∼\nsoundness linv◎r = sym∼ linv∼\nsoundness rinv◎l = rinv∼\nsoundness rinv◎r = sym∼ rinv∼\nsoundness unitel₊⇔ = {!!}\nsoundness uniter₊⇔ = {!!}\nsoundness unitil₊⇔ = {!!}\nsoundness unitir₊⇔ = {!!}\nsoundness unitial₊⇔ = {!!}\nsoundness unitiar₊⇔ = {!!}\nsoundness swapl₊⇔ = {!!}\nsoundness swapr₊⇔ = {!!}\nsoundness unitel⋆⇔ = {!!}\nsoundness uniter⋆⇔ = {!!}\nsoundness unitil⋆⇔ = {!!}\nsoundness unitir⋆⇔ = {!!}\nsoundness unitial⋆⇔ = {!!}\nsoundness unitiar⋆⇔ = {!!}\nsoundness swapl⋆⇔ = {!!}\nsoundness swapr⋆⇔ = {!!}\nsoundness swapfl⋆⇔ = {!!}\nsoundness swapfr⋆⇔ = {!!}\nsoundness id⇔ = refl∼\nsoundness (trans⇔ α β) = trans∼ (soundness α) (soundness β)\nsoundness (resp◎⇔ α β) = resp∼ (soundness α) (soundness β)\nsoundness (resp⊕⇔ α β) = {!!}\nsoundness (resp⊗⇔ α β) = {!!} \n\n-- The idea is to invert evaluation and use that to extract from each\n-- extensional representation of a combinator, a canonical syntactic\n-- representative\n\ncanonical : {t₁ t₂ : U} → (t₁ ⟷ t₂) → (t₁ ⟷ t₂)\ncanonical c = perm2comb (size≡ c) (comb2perm c)\n\n-- Note that if c₁ ⇔ c₂, then by soundness c₁ ∼ c₂ and hence their\n-- canonical representatives are identical. \n\ncanonicalWellDefined : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → \n (c₁ ⇔ c₂) → (canonical c₁ ≡ canonical c₂)\ncanonicalWellDefined {t₁} {t₂} {c₁} {c₂} α = \n cong₂ perm2comb (size∼ c₁ c₂) (soundness α) \n\n-- If we can prove that every combinator is equal to its normal form\n-- then we can prove completeness.\n\ninversion : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ canonical c\ninversion = {!!} \n\nresp≡⇔ : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ≡ c₂) → (c₁ ⇔ c₂)\nresp≡⇔ {t₁} {t₂} {c₁} {c₂} p rewrite p = id⇔ \n\ncompleteness : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₁ ⇔ c₂)\ncompleteness {t₁} {t₂} {c₁} {c₂} c₁∼c₂ = \n c₁\n ⇔⟨ inversion ⟩\n canonical c₁\n ⇔⟨ resp≡⇔ (cong₂ perm2comb (size∼ c₁ c₂) c₁∼c₂) ⟩ \n canonical c₂\n ⇔⟨ 2! inversion ⟩ \n c₂ ▤\n\n------------------------------------------------------------------------------\n\n------------------------------------------------------------------------------\n-- Nat and Fin lemmas\n\nsuc≤ : (m n : ℕ) → suc m ≤ m + suc n\nsuc≤ 0 n = s≤s z≤n\nsuc≤ (suc m) n = s≤s (suc≤ m n)\n\n-+-id : (n : ℕ) → (i : Fin n) → suc (n ∸ toℕ i) + toℕ i ≡ suc n\n-+-id 0 () -- absurd\n-+-id (suc n) zero = +-right-identity (suc (suc n))\n-+-id (suc n) (suc i) = begin\n suc (suc n ∸ toℕ (suc i)) + toℕ (suc i) \n ≡⟨ refl ⟩\n suc (n ∸ toℕ i) + suc (toℕ i) \n ≡⟨ +-suc (suc (n ∸ toℕ i)) (toℕ i) ⟩\n suc (suc (n ∸ toℕ i) + toℕ i)\n ≡⟨ cong suc (-+-id n i) ⟩\n suc (suc n) ∎\n\np0 p1 : Perm 4\np0 = idπ\np1 = swap (inject+ 1 (fromℕ 2)) (inject+ 3 (fromℕ 0))\n (swap (fromℕ 3) zero\n (swap zero (inject+ 1 (fromℕ 2))\n idπ))\n\n\nxx = action p1 (10 ∷ 20 ∷ 30 ∷ 40 ∷ [])\n\nn≤sn : ∀ {x} → x ≤ suc x\nn≤sn {0} = z≤n\nn≤sn {suc n} = s≤s (n≤sn {n})\n\n id\n-- B. (a X b) (c X d) => (c X d) (a X b) if c < a\n-- C. (a X b) (c X b) => (c X a) (a X b) if c < a\n-- D. (a X b) (c X a) => (c X b) (a X b) \n-- E. (a X b) (a X d) => (a X d) (b X d) if b < d\n-- F. (a X b) (a X d) => (a X d) (d X b) if d < b\n-- \n-- The point is that we get closer and closer to the following\n-- invariant. For any two adjacent transpositions (a X b) (c X d) we have\n-- that a < c. Transformations B, C, and D rewrite anything in which a > c.\n-- Transformations A, E, and F rewrite anything in which a = c. Termination \n-- is subtle clearly.\n-- \n-- New strategy to implement: So could we index things so that a first set of\n-- (up to) n passes 'bubble down' (0 X a) until there is only one left at the\n-- root, then recurse on the tail to 'bubble down' (1 X b)'s [if any]? That\n-- would certainly ensure termination.\n\n{-# NO_TERMINATION_CHECK #-}\nbubble : ∀ {n} → Transposition<* n → Transposition<* n\nbubble [] = []\nbubble (x ∷ []) = x ∷ []\nbubble (_X!_ i j {i β | _$_ l20\n lam : α.β -> α ↣ β | ƛ_ r10\n tr : B\n fl : B\n ze : N\n su : N -> N\n pr : N -> N\n iz : N -> B | 0?\n if : B α α -> α\n fix : α.α -> α\n\ntheory\n (ƛβ) b : α.β a : α |> app (lam(x.b[x]), a) = b[a]\n (ƛη) f : α ↣ β |> lam (x. app(f, x)) = f\n (zz) |> iz (ze) = tr\n (zs) n : N |> iz (su (n)) = fl\n (ps) n : N |> pr (su (n)) = n\n (ift) t f : α |> if (tr, t, f) = t\n (iff) t f : α |> if (fl, t, f) = f\n (fix) t : α.α |> fix (x.t[x]) = t[fix (x.t[x])]\n-}\n\nmodule PCF.Equality where\n\nopen import SOAS.Common\nopen import SOAS.Context\nopen import SOAS.Variable\nopen import SOAS.Families.Core\nopen import SOAS.Families.Build\nopen import SOAS.ContextMaps.Inductive\n\nopen import PCF.Signature\nopen import PCF.Syntax\n\nopen import SOAS.Metatheory.SecondOrder.Metasubstitution PCF:Syn\nopen import SOAS.Metatheory.SecondOrder.Equality PCF:Syn\n\nprivate\n variable\n α β γ τ : PCFT\n Γ Δ Π : Ctx\n\ninfix 1 _▹_⊢_≋ₐ_\n\n-- Axioms of equality\ndata _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ PCF) α Γ → (𝔐 ▷ PCF) α Γ → Set where\n ƛβ : ⁅ α ⊩ β ⁆ ⁅ α ⁆̣ ▹ ∅ ⊢ (ƛ 𝔞⟨ x₀ ⟩) $ 𝔟 ≋ₐ 𝔞⟨ 𝔟 ⟩\n ƛη : ⁅ α ↣ β ⁆̣ ▹ ∅ ⊢ ƛ (𝔞 $ x₀) ≋ₐ 𝔞\n zz : ⁅⁆ ▹ ∅ ⊢ 0? ze ≋ₐ tr\n zs : ⁅ N ⁆̣ ▹ ∅ ⊢ 0? (su 𝔞) ≋ₐ fl\n ps : ⁅ N ⁆̣ ▹ ∅ ⊢ pr (su 𝔞) ≋ₐ 𝔞\n ift : ⁅ α ⁆ ⁅ α ⁆̣ ▹ ∅ ⊢ if tr 𝔞 𝔟 ≋ₐ 𝔞\n iff : ⁅ α ⁆ ⁅ α ⁆̣ ▹ ∅ ⊢ if fl 𝔞 𝔟 ≋ₐ 𝔟\n fix : ⁅ α ⊩ α ⁆̣ ▹ ∅ ⊢ fix (𝔞⟨ x₀ ⟩) ≋ₐ 𝔞⟨ (fix (𝔞⟨ x₀ ⟩)) ⟩\n\nopen EqLogic _▹_⊢_≋ₐ_\nopen ≋-Reasoning\n", "meta": {"hexsha": "e24f112a545dce9d6ea4d5cff1126c089929c260", "size": 1732, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "out/PCF/Equality.agda", "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_issues_repo_path": "out/PCF/Equality.agda", "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_forks_repo_path": "out/PCF/Equality.agda", "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "avg_line_length": 25.1014492754, "max_line_length": 99, "alphanum_fraction": 0.4763279446, "num_tokens": 903, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8723473680407889, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.6404072320442293}} {"text": "module modal-lob-reduced where\ndata TYP : Set where\n ARR : TYP → TYP → TYP -- the type of implications, or function types\n BOX : TYP → TYP -- the modal □ operator, denoted to TERM\n LӦB-SENTENCE : TYP → TYP -- the Lӧbian sentence \"If this sentence is provable, then A\"\n -- this is the modal fixpoint of λ Ψ. □ Ψ → A\n\ndata TERM : TYP → Set where\n k : {A : TYP} → TERM A → TERM (BOX A) -- from A, we deduce □ A\n distr : {A B : TYP} → TERM (ARR (BOX (ARR A B)) (ARR (BOX A) (BOX B))) -- we deduce □ (A → B) → □ A → □ B\n s4 : {A : TYP} → TERM (ARR (BOX A) (BOX (BOX A))) -- we deduce □ A → □ □ A\n app : {A B : TYP} → TERM (ARR A B) → TERM A → TERM B -- from A → B, and A, we deduce B\n lӧb→ : {A : TYP} → TERM (ARR (LӦB-SENTENCE A) (ARR (BOX (LӦB-SENTENCE A)) A)) -- LӦB-SENTENCE A is Ψ such that Ψ → (□ Ψ → A)\n lӧb← : {A : TYP} → TERM (ARR (ARR (BOX (LӦB-SENTENCE A)) A) (LӦB-SENTENCE A)) -- LӦB-SENTENCE A is Ψ such that (□ Ψ → A) → Ψ\n compose : {A B C : TYP} → TERM (ARR A B) → TERM (ARR B C) → TERM (ARR A C) -- from A → B and B → C, we deduce A → C\n compose2 : {A B C : TYP} → TERM (ARR A B) → TERM (ARR A (ARR B C)) → TERM (ARR A C) -- from A → B and A → B → C, we deduce A → C\n\n⟦_⟧ᵀ : TYP → Set\n⟦ ARR A B ⟧ᵀ = ⟦ A ⟧ᵀ → ⟦ B ⟧ᵀ\n⟦ BOX T ⟧ᵀ = TERM T\n⟦ LӦB-SENTENCE A ⟧ᵀ = TERM (LӦB-SENTENCE A) → ⟦ A ⟧ᵀ\n\n⟦_⟧ᵗ : {T : TYP} → TERM T → ⟦ T ⟧ᵀ\n⟦ k e ⟧ᵗ = e\n⟦ distr ⟧ᵗ box-a-b box-a = app box-a-b box-a\n⟦ s4 ⟧ᵗ = k\n⟦ app f x ⟧ᵗ = ⟦ f ⟧ᵗ ⟦ x ⟧ᵗ\n⟦ lӧb→ ⟧ᵗ = λ x → x -- this implication is true because on denotation, the two are judgmentally equal\n⟦ lӧb← ⟧ᵗ = λ x → x -- this implication is true because on denotation, the two are judgmentally equal\n⟦ compose f g ⟧ᵗ = λ x → ⟦ g ⟧ᵗ (⟦ f ⟧ᵗ x)\n⟦ compose2 f g ⟧ᵗ = λ x → ⟦ g ⟧ᵗ x (⟦ f ⟧ᵗ x)\n\nLӧb′s-Theorem : {A : TYP} → TERM (ARR (BOX A) A) → TERM A -- from □ A → A, we deduce A\nLӧb′s-Theorem {A} interp = app prog (k (app lӧb← prog))\n where prog : TERM (ARR (BOX (LӦB-SENTENCE A)) A)\n prog = compose (compose2 s4 (compose (app distr (k lӧb→)) distr)) interp\n", "meta": {"hexsha": "72020ee26d973f71fa125658fc6191aa994e5e28", "size": 2042, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "internal/modal-logic-lob-reduced.agda", "max_stars_repo_name": "JasonGross/lob", "max_stars_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 19, "max_stars_repo_stars_event_min_datetime": "2015-07-17T17:53:30.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-17T14:04:53.000Z", "max_issues_repo_path": "internal/modal-logic-lob-reduced.agda", "max_issues_repo_name": "JasonGross/lob", "max_issues_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2015-07-17T20:20:43.000Z", "max_issues_repo_issues_event_max_datetime": "2015-07-17T20:20:43.000Z", "max_forks_repo_path": "internal/modal-logic-lob-reduced.agda", "max_forks_repo_name": "JasonGross/lob", "max_forks_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-07-17T18:53:37.000Z", "max_forks_repo_forks_event_max_datetime": "2015-07-17T18:53:37.000Z", "avg_line_length": 55.1891891892, "max_line_length": 130, "alphanum_fraction": 0.5543584721, "num_tokens": 958, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9073122288794595, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.64036738671655}} {"text": "{-\n Define finitely generated ideals of commutative rings and\n show that they are an ideal.\n Parts of this should be reusable for explicit constructions\n of free modules over a finite set.\n-}\n{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.CommRing.FGIdeal where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Powerset\nopen import Cubical.Foundations.HLevels\n\nopen import Cubical.Data.Sigma\nopen import Cubical.Data.Vec\nopen import Cubical.Data.Nat using (ℕ)\n\nopen import Cubical.HITs.PropositionalTruncation hiding (map)\n\nopen import Cubical.Algebra.CommRing\nopen import Cubical.Algebra.CommRing.Ideal\nopen import Cubical.Algebra.Ring.QuotientRing\nopen import Cubical.Algebra.Ring.Properties\nopen import Cubical.Algebra.RingSolver.ReflectionSolving\n\nprivate\n variable\n ℓ : Level\n\nmodule _ (Ring@(R , str) : CommRing ℓ) (r : R) where\n infixr 5 _holds\n _holds : hProp ℓ → Type ℓ\n P holds = fst P\n open CommRingStr str\n open RingTheory (CommRing→Ring Ring)\n\n linearCombination : {n : ℕ} → Vec R n → Vec R n → R\n linearCombination [] [] = 0r\n linearCombination (c ∷ coefficients) (x ∷ l) = c · x + linearCombination coefficients l\n\n coefficientSum : {n : ℕ} → Vec R n → Vec R n → Vec R n\n coefficientSum [] [] = []\n coefficientSum (x ∷ c) (y ∷ c′) = x + y ∷ coefficientSum c c′\n\n sumDist+ : (n : ℕ) (c c′ l : Vec R n)\n → linearCombination (coefficientSum c c′) l\n ≡ linearCombination c l + linearCombination c′ l\n sumDist+ ℕ.zero [] [] [] = solve Ring\n sumDist+ (ℕ.suc n) (x ∷ c) (y ∷ c′) (a ∷ l) =\n linearCombination (coefficientSum (x ∷ c) (y ∷ c′)) (a ∷ l) ≡⟨ refl ⟩\n (x + y) · a + linearCombination (coefficientSum c c′) l ≡⟨ step1 ⟩\n (x + y) · a + (linearCombination c l + linearCombination c′ l) ≡⟨ step2 ⟩\n (x · a + linearCombination c l) + (y · a + linearCombination c′ l) ≡⟨ refl ⟩\n linearCombination (x ∷ c) (a ∷ l) + linearCombination (y ∷ c′) (a ∷ l) ∎\n where\n step1 = cong (λ z → (x + y) · a + z) (sumDist+ n c c′ l)\n autoSolve : (x y a t1 t2 : R)\n → (x + y) · a + (t1 + t2) ≡ (x · a + t1) + (y · a + t2)\n autoSolve = solve Ring\n step2 = autoSolve x y a _ _\n\n dist- : (n : ℕ) (c l : Vec R n)\n → linearCombination (map -_ c) l\n ≡ - linearCombination c l\n dist- ℕ.zero [] [] = solve Ring\n dist- (ℕ.suc n) (x ∷ c) (a ∷ l) =\n - x · a + linearCombination (map -_ c) l ≡[ i ]⟨ - x · a + dist- n c l i ⟩\n - x · a - linearCombination c l ≡⟨ step1 x a _ ⟩\n - (x · a + linearCombination c l) ∎\n where step1 : (x a t1 : R) → - x · a - t1 ≡ - (x · a + t1)\n step1 = solve Ring\n\n dist0 : (n : ℕ) (l : Vec R n)\n → linearCombination (replicate 0r) l ≡ 0r\n dist0 ℕ.zero [] = refl\n dist0 (ℕ.suc n) (a ∷ l) =\n 0r · a + linearCombination (replicate 0r) l ≡[ i ]⟨ 0r · a + dist0 n l i ⟩\n 0r · a + 0r ≡⟨ step1 a ⟩\n 0r ∎\n where step1 : (a : R) → 0r · a + 0r ≡ 0r\n step1 = solve Ring\n\n isLinearCombination : {n : ℕ} → Vec R n → R → Type ℓ\n isLinearCombination l x =\n ∥ Σ[ coefficients ∈ Vec R _ ] x ≡ linearCombination coefficients l ∥\n\n {- If x and y are linear combinations of l, then (x + y) is\n a linear combination. -}\n isLinearCombination+ : {n : ℕ} {x y : R} → (l : Vec R n)\n → isLinearCombination l x\n → isLinearCombination l y\n → isLinearCombination l (x + y)\n isLinearCombination+ l =\n elim (λ _ → isOfHLevelΠ 1 (λ _ → isPropPropTrunc))\n (λ {(cx , px) → elim (λ _ → isPropPropTrunc)\n λ {(cy , py) →\n ∣ coefficientSum cx cy ,\n (_ + _ ≡[ i ]⟨ px i + py i ⟩\n linearCombination cx l + linearCombination cy l ≡⟨ sym (sumDist+ _ cx cy l) ⟩\n linearCombination (coefficientSum cx cy) l ∎) ∣}})\n\n {- If x is a linear combinations of l, then -x is\n a linear combination. -}\n isLinearCombination- : {n : ℕ} {x y : R} (l : Vec R n)\n → isLinearCombination l x\n → isLinearCombination l (- x)\n isLinearCombination- l =\n elim (λ _ → isPropPropTrunc)\n λ {(cx , px) → ∣ map -_ cx ,\n ( - _ ≡⟨ cong -_ px ⟩\n - linearCombination cx l ≡⟨ sym (dist- _ cx l) ⟩\n linearCombination (map -_ cx) l ∎) ∣}\n\n {- 0r is the trivial linear Combination -}\n isLinearCombination0 : {n : ℕ} (l : Vec R n)\n → isLinearCombination l 0r\n isLinearCombination0 l = ∣ replicate 0r , sym (dist0 _ l) ∣\n\n {- Linear combinations are stable under left multiplication -}\n isLinearCombinationL· : {n : ℕ} (l : Vec R n)\n → (r x : R)\n → isLinearCombination l x\n → isLinearCombination l (r · x)\n isLinearCombinationL· l r x =\n elim (λ _ → isPropPropTrunc)\n λ {(cx , px) →\n ∣ map (r ·_) cx ,\n (r · _ ≡[ i ]⟨ r · px i ⟩\n r · linearCombination cx l ≡⟨ step1 _ cx l r ⟩\n linearCombination (map (r ·_) cx) l ∎) ∣}\n where\n step2 : (r c a t1 : R) → r · (c · a + t1) ≡ r · (c · a) + r · t1\n step2 = solve Ring\n step3 : (r c a t1 : R) → r · (c · a) + t1 ≡ r · c · a + t1\n step3 = solve Ring\n step1 : (k : ℕ) (cx l : Vec R k)\n → (r : R)\n → r · linearCombination cx l ≡ linearCombination (map (r ·_) cx) l\n step1 ℕ.zero [] [] r = 0RightAnnihilates _\n step1 (ℕ.suc k) (c ∷ cx) (a ∷ l) r =\n r · (c · a + linearCombination cx l) ≡⟨ step2 r c a _ ⟩\n r · (c · a) + r · linearCombination cx l ≡[ i ]⟨ r · (c · a) + step1 _ cx l r i ⟩\n r · (c · a) + linearCombination (map (_·_ r) cx) l ≡⟨ step3 r c a _ ⟩\n r · c · a + linearCombination (map (_·_ r) cx) l ∎\n\n generatedIdeal : {n : ℕ} → Vec R n → IdealsIn Ring\n generatedIdeal l = makeIdeal Ring\n (λ x → isLinearCombination l x , isPropPropTrunc)\n (isLinearCombination+ l)\n (isLinearCombination0 l)\n λ r → isLinearCombinationL· l r _\n", "meta": {"hexsha": "9e3467d1226f3b7bbfd652e7cd6bac5a1fb54537", "size": 6434, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommRing/FGIdeal.agda", "max_stars_repo_name": "kl-i/cubical-0.3", "max_stars_repo_head_hexsha": "f2d74ae8e2e176963029a35bd886364480948214", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/CommRing/FGIdeal.agda", "max_issues_repo_name": "kl-i/cubical-0.3", "max_issues_repo_head_hexsha": "f2d74ae8e2e176963029a35bd886364480948214", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/CommRing/FGIdeal.agda", "max_forks_repo_name": "kl-i/cubical-0.3", "max_forks_repo_head_hexsha": "f2d74ae8e2e176963029a35bd886364480948214", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.3289473684, "max_line_length": 99, "alphanum_fraction": 0.5184954927, "num_tokens": 2160, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117855317474, "lm_q2_score": 0.7745833789613196, "lm_q1q2_score": 0.6403572082643266}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Inverses\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Function.Inverse where\n\nopen import Level\nopen import Function using (flip)\nopen import Function.Bijection hiding (id; _∘_; bijection)\nopen import Function.Equality as F\n using (_⟶_) renaming (_∘_ to _⟪∘⟫_)\nopen import Function.LeftInverse as Left hiding (id; _∘_)\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as P using (_≗_; _≡_)\nopen import Relation.Unary using (Pred)\n\n------------------------------------------------------------------------\n-- Inverses\n\nrecord _InverseOf_ {f₁ f₂ t₁ t₂}\n {From : Setoid f₁ f₂} {To : Setoid t₁ t₂}\n (from : To ⟶ From) (to : From ⟶ To) :\n Set (f₁ ⊔ f₂ ⊔ t₁ ⊔ t₂) where\n field\n left-inverse-of : from LeftInverseOf to\n right-inverse-of : from RightInverseOf to\n\n------------------------------------------------------------------------\n-- The set of all inverses between two setoids\n\nrecord Inverse {f₁ f₂ t₁ t₂}\n (From : Setoid f₁ f₂) (To : Setoid t₁ t₂) :\n Set (f₁ ⊔ f₂ ⊔ t₁ ⊔ t₂) where\n field\n to : From ⟶ To\n from : To ⟶ From\n inverse-of : from InverseOf to\n\n open _InverseOf_ inverse-of public\n\n left-inverse : LeftInverse From To\n left-inverse = record\n { to = to\n ; from = from\n ; left-inverse-of = left-inverse-of\n }\n\n open LeftInverse left-inverse public\n using (injective; injection)\n\n bijection : Bijection From To\n bijection = record\n { to = to\n ; bijective = record\n { injective = injective\n ; surjective = record\n { from = from\n ; right-inverse-of = right-inverse-of\n }\n }\n }\n\n open Bijection bijection public\n using (equivalence; surjective; surjection; right-inverse;\n to-from; from-to)\n\n------------------------------------------------------------------------\n-- The set of all inverses between two sets (i.e. inverses with\n-- propositional equality)\n\ninfix 3 _↔_ _↔̇_\n\n_↔_ : ∀ {f t} → Set f → Set t → Set _\nFrom ↔ To = Inverse (P.setoid From) (P.setoid To)\n\n_↔̇_ : ∀ {i f t} {I : Set i} → Pred I f → Pred I t → Set _\nFrom ↔̇ To = ∀ {i} → From i ↔ To i\n\ninverse : ∀ {f t} {From : Set f} {To : Set t} →\n (to : From → To) (from : To → From) →\n (∀ x → from (to x) ≡ x) →\n (∀ x → to (from x) ≡ x) →\n From ↔ To\ninverse to from from∘to to∘from = record\n { to = P.→-to-⟶ to\n ; from = P.→-to-⟶ from\n ; inverse-of = record\n { left-inverse-of = from∘to\n ; right-inverse-of = to∘from\n }\n }\n\n------------------------------------------------------------------------\n-- If two setoids are in bijective correspondence, then there is an\n-- inverse between them\n\nfromBijection :\n ∀ {f₁ f₂ t₁ t₂} {From : Setoid f₁ f₂} {To : Setoid t₁ t₂} →\n Bijection From To → Inverse From To\nfromBijection b = record\n { to = Bijection.to b\n ; from = Bijection.from b\n ; inverse-of = record\n { left-inverse-of = Bijection.left-inverse-of b\n ; right-inverse-of = Bijection.right-inverse-of b\n }\n }\n\n------------------------------------------------------------------------\n-- Inverse is an equivalence relation\n\n-- Reflexivity\n\nid : ∀ {s₁ s₂} → Reflexive (Inverse {s₁} {s₂})\nid {x = S} = record\n { to = F.id\n ; from = F.id\n ; inverse-of = record\n { left-inverse-of = LeftInverse.left-inverse-of id′\n ; right-inverse-of = LeftInverse.left-inverse-of id′\n }\n } where id′ = Left.id {S = S}\n\n-- Transitivity\n\ninfixr 9 _∘_\n\n_∘_ : ∀ {f₁ f₂ m₁ m₂ t₁ t₂} →\n TransFlip (Inverse {f₁} {f₂} {m₁} {m₂})\n (Inverse {m₁} {m₂} {t₁} {t₂})\n (Inverse {f₁} {f₂} {t₁} {t₂})\nf ∘ g = record\n { to = to f ⟪∘⟫ to g\n ; from = from g ⟪∘⟫ from f\n ; inverse-of = record\n { left-inverse-of = LeftInverse.left-inverse-of (Left._∘_ (left-inverse f) (left-inverse g))\n ; right-inverse-of = LeftInverse.left-inverse-of (Left._∘_ (right-inverse g) (right-inverse f))\n }\n } where open Inverse\n\n-- Symmetry.\n\nsym : ∀ {f₁ f₂ t₁ t₂} →\n Sym (Inverse {f₁} {f₂} {t₁} {t₂}) (Inverse {t₁} {t₂} {f₁} {f₂})\nsym inv = record\n { from = to\n ; to = from\n ; inverse-of = record\n { left-inverse-of = right-inverse-of\n ; right-inverse-of = left-inverse-of\n }\n } where open Inverse inv\n\n------------------------------------------------------------------------\n-- Transformations\n\nmap : ∀ {f₁ f₂ t₁ t₂} {From : Setoid f₁ f₂} {To : Setoid t₁ t₂}\n {f₁′ f₂′ t₁′ t₂′}\n {From′ : Setoid f₁′ f₂′} {To′ : Setoid t₁′ t₂′} →\n (t : (From ⟶ To) → (From′ ⟶ To′)) →\n (f : (To ⟶ From) → (To′ ⟶ From′)) →\n (∀ {to from} → from InverseOf to → f from InverseOf t to) →\n Inverse From To → Inverse From′ To′\nmap t f pres eq = record\n { to = t to\n ; from = f from\n ; inverse-of = pres inverse-of\n } where open Inverse eq\n\nzip : ∀ {f₁₁ f₂₁ t₁₁ t₂₁}\n {From₁ : Setoid f₁₁ f₂₁} {To₁ : Setoid t₁₁ t₂₁}\n {f₁₂ f₂₂ t₁₂ t₂₂}\n {From₂ : Setoid f₁₂ f₂₂} {To₂ : Setoid t₁₂ t₂₂}\n {f₁ f₂ t₁ t₂} {From : Setoid f₁ f₂} {To : Setoid t₁ t₂} →\n (t : (From₁ ⟶ To₁) → (From₂ ⟶ To₂) → (From ⟶ To)) →\n (f : (To₁ ⟶ From₁) → (To₂ ⟶ From₂) → (To ⟶ From)) →\n (∀ {to₁ from₁ to₂ from₂} →\n from₁ InverseOf to₁ → from₂ InverseOf to₂ →\n f from₁ from₂ InverseOf t to₁ to₂) →\n Inverse From₁ To₁ → Inverse From₂ To₂ → Inverse From To\nzip t f pres eq₁ eq₂ = record\n { to = t (to eq₁) (to eq₂)\n ; from = f (from eq₁) (from eq₂)\n ; inverse-of = pres (inverse-of eq₁) (inverse-of eq₂)\n } where open Inverse\n", "meta": {"hexsha": "8883e0a3ca31293fdf94f06a8135d9241fc95683", "size": 5862, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Function/Inverse.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Function/Inverse.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Function/Inverse.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.8526315789, "max_line_length": 99, "alphanum_fraction": 0.5085295121, "num_tokens": 1878, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256313782276, "lm_q2_score": 0.7606506526772883, "lm_q1q2_score": 0.6403352159483191}} {"text": "-- Inductive types\n-- See Chapter 15 of \"Practical Foundations for Programming Languages\" by Robert Harper\n\nmodule ITypes where\n\nopen import Data.Vec\nopen import Data.Nat\nopen import Data.List\nopen import Data.Fin.Base\n\n-- auxiliary\ndata Bool : Set where\n True False : Bool\n\n_if_else_ : {A : Set} → A → Bool → A → A\nA if True else B = A\nA if False else B = B\n-- end of auxiliary\n\n{-- required later on\ndata IType' (n : ℕ) : Set\ndata IType' n where\n Unit Nat : IType' n\n Pair Sum : IType n → IType n → IType' n\n\nMap'[_,_]_ : ∀ {n} → Fin n → IType' n → IType n → IType' n\nMap'[ var , Unit ] type' = Unit\nMap'[ var , Nat ] type' = Nat\nMap'[ var , Pair x x₁ ] type' = Pair (Map[ var , x ] type') (Map[ var , x₁ ] type')\nMap'[ var , Sum x x₁ ] type' = Sum (Map[ var , x ] type') (Map[ var , x₁ ] type')\n--}\n\ndata IType (n : ℕ) : Set\n\ndata IType n where\n Unit Nat : IType n\n Pair Sum : IType n → IType n → IType n\n Ind : IType (suc n) → IType n\n Var : Fin n → IType n\n Func : IType n → IType n → IType n\n\nFinEq : ∀ {n} → Fin n → Fin n → Bool\nFinEq zero zero = True\nFinEq zero (suc b) = False\nFinEq (suc a) zero = False\nFinEq (suc a) (suc b) = FinEq a b\n\n-- Substitute type' for var in type\nMap[_,_]_ : ∀ {n} → Fin (suc n) → IType (suc n) → IType n → IType n\nMap[ var , Unit ] type' = Unit\nMap[ var , Nat ] type' = Nat\nMap[ var , Pair type type₁ ] type' = Pair (Map[ var , type ] type') (Map[ var , type₁ ] type')\nMap[ var , Sum type type₁ ] type' = Pair (Map[ var , type ] type') (Map[ var , type₁ ] type')\nMap[ var , Ind x ] type' = {!!} --Ind (Map[ var , x ] type')\nMap[ var , Func a b ] type' = Func (Map[ var , a ] type') (Map[ var , b ] type')\nMap[ var , Var x ] type' = type' if (FinEq var x) else Var {!!}\n\n-- Alternative notation\n[_/_]_ : ∀ {n} → IType n → Fin (suc n) → IType (suc n) → IType n\n[ type' / var ] type = Map[ var , type ] type'\n\nEnv : ℕ → Set\nEnv n = List (IType n)\n\n-- Environment lookup\ndata _∈`_ {n} : IType n → Env n → Set where\n here : ∀ {φ A} → A ∈` (A ∷ φ)\n there : ∀ {φ A A'} → A ∈` φ → A ∈` (A' ∷ φ)\n\n-- Expressions\ndata Expr {n} : Env n → IType n → Set where\n-- Fold : ∀ {ϕ t τ} → Expr ϕ ([ Ind τ / t ] τ) → Expr ϕ (Ind τ)\n-- Rec : ∀ {ϕ t τ ρ} → Expr ((Map[ t , τ ] ρ) ∷ ϕ) ρ → Expr ϕ (Ind τ) → {!!}\n FoldNat : ∀ {ϕ} → Expr ϕ (Sum Unit Nat) → Expr ϕ Nat\n RecNat : ∀ {ϕ} → Expr (Sum Unit Nat ∷ ϕ) Nat → Expr ϕ Nat → Expr ϕ Nat\n Var : ∀ {φ τ} → τ ∈` φ → Expr φ τ\n Abs : ∀ {φ τ τ'} → Expr (τ ∷ φ) τ' → Expr φ (Func τ τ')\n App : ∀ {φ τ τ'} → Expr φ (Func τ τ') → Expr φ τ → Expr φ τ'\n\n-- Expression substitution\n[_//_] : ∀ {n ϕ} {τ τ' : IType n} → Expr (τ' ∷ ϕ) τ → Expr ϕ τ' → Expr ϕ τ\n-- TODO\n\ndata _↦_ {n ϕ} : {τ : IType n} → Expr ϕ τ → Expr ϕ τ → Set where\n\n ξ-RecNat : ∀ {e} {e' e''}\n → e' ↦ e''\n → _↦_ {τ = Nat} (RecNat e e') (RecNat e e'')\n\n β-RecNat : ∀ {e e'}\n → _↦_ {τ = Nat} (RecNat e (FoldNat e')) [ e // e' ]\n \n\n-- IValue\n-- data IValue (n : ℕ) : Set where\n\n-- Interpreter\n-- int : ∀ {n} → IType n → Set\n-- int' : ∀ {n} → IType' n → Set\n--- int {n} (Ind it') = IValue n (int' it')\n", "meta": {"hexsha": "0460e509ce6d2a6e2d055e298a54187a8b80e077", "size": 3230, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/sigmatypes/ITypes.agda", "max_stars_repo_name": "kcaliban/ldlc", "max_stars_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/sigmatypes/ITypes.agda", "max_issues_repo_name": "kcaliban/ldlc", "max_issues_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/sigmatypes/ITypes.agda", "max_forks_repo_name": "kcaliban/ldlc", "max_forks_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-14T17:52:29.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-14T17:52:29.000Z", "avg_line_length": 31.9801980198, "max_line_length": 94, "alphanum_fraction": 0.5145510836, "num_tokens": 1241, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872045996818986, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.6403338871062942}} {"text": "module Cats.Category.Slice where\n\nopen import Data.Product using (_,_ ; proj₁ ; proj₂)\nopen import Level\nopen import Relation.Binary using (IsEquivalence ; _Preserves₂_⟶_⟶_)\n\nopen import Cats.Category\n\nmodule _ {lo la l≈} (C : Category lo la l≈) (X : Category.Obj C) where\n\n infixr 9 _∘_\n infixr 4 _≈_\n\n\n private\n module C = Category C\n module ≈ = C.≈\n\n\n record Obj : Set (lo ⊔ la) where\n constructor mkObj\n field\n {Dom} : C.Obj\n arr : Dom C.⇒ X\n\n open Obj\n\n\n record _⇒_ (f g : Obj) : Set (la ⊔ l≈) where\n field\n dom : Dom f C.⇒ Dom g\n commute : arr f C.≈ arr g C.∘ dom\n\n open _⇒_\n\n\n record _≈_ {A B} (F G : A ⇒ B) : Set l≈ where -- [1]\n constructor ≈-i\n field\n dom : dom F C.≈ dom G\n\n -- [1] This could also be defined as\n --\n -- F ≈ G = dom F C.≈ dom G\n --\n -- but Agda was then giving me very strange unsolved metas in _/_ below.\n\n\n id : ∀ {A} → A ⇒ A\n id = record { dom = C.id ; commute = ≈.sym C.id-r }\n\n\n _∘_ : ∀ {A B C} → (B ⇒ C) → (A ⇒ B) → (A ⇒ C)\n _∘_ {F} {G} {H}\n record { dom = F-dom ; commute = F-commute}\n record { dom = G-dom ; commute = G-commute}\n = record\n { dom = F-dom C.∘ G-dom\n ; commute\n = begin\n arr F\n ≈⟨ G-commute ⟩\n arr G C.∘ G-dom\n ≈⟨ C.∘-resp-l F-commute ⟩\n (arr H C.∘ F-dom) C.∘ G-dom\n ≈⟨ C.assoc ⟩\n arr H C.∘ F-dom C.∘ G-dom\n ∎\n }\n where\n open C.≈-Reasoning\n\n\n ≈-equiv : ∀ {A B} → IsEquivalence (_≈_ {A} {B})\n ≈-equiv = record\n { refl = ≈-i ≈.refl\n ; sym = λ { (≈-i eq) → ≈-i (≈.sym eq) }\n ; trans = λ { (≈-i eq₁) (≈-i eq₂) → ≈-i (≈.trans eq₁ eq₂) }\n }\n\n\n ∘-preserves-≈ : ∀ {A B C} → _∘_ {A} {B} {C} Preserves₂ _≈_ ⟶ _≈_ ⟶ _≈_\n ∘-preserves-≈ (≈-i eq₁) (≈-i eq₂) = ≈-i (C.∘-resp eq₁ eq₂)\n\n\n id-identity-r : ∀ {A B} {F : A ⇒ B} → F ∘ id ≈ F\n id-identity-r = ≈-i C.id-r\n\n id-identity-l : ∀ {A B} {F : A ⇒ B} → id ∘ F ≈ F\n id-identity-l = ≈-i C.id-l\n\n\n ∘-assoc : ∀ {A B C D} {F : C ⇒ D} {G : B ⇒ C} {H : A ⇒ B}\n → (F ∘ G) ∘ H ≈ F ∘ (G ∘ H)\n ∘-assoc = ≈-i C.assoc\n\n\n instance _/_ : Category (la ⊔ lo) (l≈ ⊔ la) l≈\n _/_ = record\n { Obj = Obj\n ; _⇒_ = _⇒_\n ; _≈_ = _≈_\n ; id = id\n ; _∘_ = _∘_\n ; equiv = ≈-equiv\n ; ∘-resp = ∘-preserves-≈\n ; id-r = id-identity-r\n ; id-l = id-identity-l\n ; assoc = ∘-assoc\n }\n\n\n open Category _/_ using (IsTerminal ; IsUnique ; ∃!-intro)\n\n\n One : Obj\n One = mkObj C.id\n\n\n One-Terminal : IsTerminal One\n One-Terminal Y@(mkObj f)\n = ∃!-intro F _ F-Unique\n where\n F : Y ⇒ One\n F = record { dom = f ; commute = C.≈.sym C.id-l }\n\n F-Unique : IsUnique F\n F-Unique {record { dom = g ; commute = commute }} _\n = ≈-i (≈.trans commute C.id-l)\n", "meta": {"hexsha": "c224a7491be6881531e9d9c74a4ede05b3cab0f6", "size": 2825, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Category/Slice.agda", "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cats/Category/Slice.agda", "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cats/Category/Slice.agda", "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.7307692308, "max_line_length": 74, "alphanum_fraction": 0.4725663717, "num_tokens": 1194, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382094310357, "lm_q2_score": 0.743167997235783, "lm_q1q2_score": 0.6402676256449653}} {"text": "{-# OPTIONS --universe-polymorphism #-}\n\nopen import FRP.JS.Bool using ( Bool ; true ; false ; if_then_else_ ; not ; _∧_ )\n\nmodule FRP.JS.True where\n\nrecord ⊤ : Set where\n constructor tt\n\ndata ⊥ : Set where\n\ncontradiction : ∀ {α} {A : Set α} → ⊥ → A\ncontradiction ()\n\nTrue : Bool → Set\nTrue true = ⊤\nTrue false = ⊥\n\nFalse : Bool → Set\nFalse b = True b → ⊥\n\n∧-intro : ∀ {a b} → True a → True b → True (a ∧ b)\n∧-intro {false} () b\n∧-intro {true} {false} tt ()\n∧-intro {true} {true} tt tt = tt\n\n∧-elim₁ : ∀ {a b} → True (a ∧ b) → True a\n∧-elim₁ {false} ()\n∧-elim₁ {true} b = tt\n\n∧-elim₂ : ∀ {a b} → True (a ∧ b) → True b\n∧-elim₂ {false} ()\n∧-elim₂ {true} b = b\n\ndata Dec (b : Bool) : Set where\n yes : True b → Dec b\n no : False b → Dec b\n\n{-# COMPILED_JS Dec function(x,v) {\n if (x) { return v.yes(null); } else { return v.no(null); } \n} #-}\n{-# COMPILED_JS yes true #-}\n{-# COMPILED_JS no false #-}\n\ndec : ∀ b → Dec b\ndec true = yes tt\ndec false = no contradiction\n", "meta": {"hexsha": "50206c3d585f49f311cb8baf6c38a81f1b47c9b3", "size": 984, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/agda/FRP/JS/True.agda", "max_stars_repo_name": "agda/agda-frp-js", "max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_stars_repo_licenses": ["MIT", "BSD-3-Clause"], "max_stars_count": 63, "max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z", "max_issues_repo_path": "src/agda/FRP/JS/True.agda", "max_issues_repo_name": "agda/agda-frp-js", "max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_issues_repo_licenses": ["MIT", "BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/agda/FRP/JS/True.agda", "max_forks_repo_name": "agda/agda-frp-js", "max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_forks_repo_licenses": ["MIT", "BSD-3-Clause"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z", "avg_line_length": 20.5, "max_line_length": 81, "alphanum_fraction": 0.5630081301, "num_tokens": 375, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757869916479466, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.6402515932967958}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.ZCohomology.Groups.WedgeOfSpheres where\n\nopen import Cubical.ZCohomology.Base\nopen import Cubical.ZCohomology.Properties\nopen import Cubical.ZCohomology.Groups.Unit\nopen import Cubical.ZCohomology.Groups.Sn\nopen import Cubical.ZCohomology.Groups.Wedge\nopen import Cubical.ZCohomology.Groups.Connected\n\nopen import Cubical.HITs.Sn\nopen import Cubical.HITs.S1\nopen import Cubical.Foundations.Prelude\nopen import Cubical.HITs.Susp\nopen import Cubical.HITs.Wedge\nopen import Cubical.HITs.Pushout\nopen import Cubical.HITs.Truncation renaming (elim to trElim)\nopen import Cubical.Algebra.Group\n\nS¹⋁S¹ : Type₀\nS¹⋁S¹ = S₊∙ 1 ⋁ S₊∙ 1\n\nS²⋁S¹⋁S¹ : Type₀\nS²⋁S¹⋁S¹ = S₊∙ 2 ⋁ (S¹⋁S¹ , inl base)\n\n------------- H⁰(S¹⋁S¹) ------------\nH⁰-S¹⋁S¹ : GroupIso (coHomGr 0 S¹⋁S¹) intGroup\nH⁰-S¹⋁S¹ = H⁰-connected (inl base) (wedgeConnected _ _ (Sn-connected 0) (Sn-connected 0))\n\n------------- H¹(S¹⋁S¹) ------------\nH¹-S¹⋁S¹ : GroupIso (coHomGr 1 S¹⋁S¹) (dirProd intGroup intGroup)\nH¹-S¹⋁S¹ = (Hⁿ-⋁ _ _ 0) □ dirProdGroupIso coHom1S1≃ℤ coHom1S1≃ℤ\n\n------------- H⁰(S²⋁S¹⋁S¹) ---------\nH⁰-S²⋁S¹⋁S¹ : GroupIso (coHomGr 0 S²⋁S¹⋁S¹) intGroup\nH⁰-S²⋁S¹⋁S¹ = H⁰-connected (inl north)\n (wedgeConnected _ _\n (Sn-connected 1)\n (wedgeConnected _ _\n (Sn-connected 0)\n (Sn-connected 0)))\n\n------------- H¹(S²⋁S¹⋁S¹) ---------\nH¹-S²⋁S¹⋁S¹ : GroupIso (coHomGr 1 S²⋁S¹⋁S¹) (dirProd intGroup intGroup)\nH¹-S²⋁S¹⋁S¹ =\n Hⁿ-⋁ (S₊∙ 2) (S¹⋁S¹ , inl base) 0\n □ dirProdGroupIso (H¹-Sⁿ≅0 0) H¹-S¹⋁S¹\n □ lUnitGroupIso\n\n------------- H²(S²⋁S¹⋁S¹) ---------\nH²-S²⋁S¹⋁S¹ : GroupIso (coHomGr 2 S²⋁S¹⋁S¹) intGroup\nH²-S²⋁S¹⋁S¹ =\n compGroupIso\n (Hⁿ-⋁ _ _ 1)\n (dirProdGroupIso {B = trivialGroup}\n (invGroupIso (Hⁿ-Sⁿ≅ℤ 1))\n ((Hⁿ-⋁ _ _ 1) □ dirProdGroupIso (Hⁿ-S¹≅0 0) (Hⁿ-S¹≅0 0) □ rUnitGroupIso)\n □ rUnitGroupIso)\n\nprivate\n open import Cubical.Data.Int\n open import Cubical.Foundations.Equiv\n open import Cubical.Data.Sigma\n to₂ : coHom 2 S²⋁S¹⋁S¹ → Int\n to₂ = GroupHom.fun (GroupIso.map H²-S²⋁S¹⋁S¹)\n from₂ : Int → coHom 2 S²⋁S¹⋁S¹\n from₂ = GroupIso.inv H²-S²⋁S¹⋁S¹\n\n to₁ : coHom 1 S²⋁S¹⋁S¹ → Int × Int\n to₁ = GroupHom.fun (GroupIso.map H¹-S²⋁S¹⋁S¹)\n from₁ : Int × Int → coHom 1 S²⋁S¹⋁S¹\n from₁ = GroupIso.inv H¹-S²⋁S¹⋁S¹\n\n to₀ : coHom 0 S²⋁S¹⋁S¹ → Int\n to₀ = GroupHom.fun (GroupIso.map H⁰-S²⋁S¹⋁S¹)\n from₀ : Int → coHom 0 S²⋁S¹⋁S¹\n from₀ = GroupIso.inv H⁰-S²⋁S¹⋁S¹\n\n\n{-\n-- Computes (a lot slower than for the torus)\ntest : to₁ (from₁ (1 , 0) +ₕ from₁ (0 , 1)) ≡ (1 , 1)\ntest = refl\n\n-- Does not compute:\ntest2 : to₂ (from₂ 0) ≡ 0\ntest2 = refl\n-}\n", "meta": {"hexsha": "408d3c9c20cca3e21fdcb737f89cd56a04fc51b4", "size": 2686, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/ZCohomology/Groups/WedgeOfSpheres.agda", "max_stars_repo_name": "ayberkt/cubical", "max_stars_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/ZCohomology/Groups/WedgeOfSpheres.agda", "max_issues_repo_name": "ayberkt/cubical", "max_issues_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/ZCohomology/Groups/WedgeOfSpheres.agda", "max_forks_repo_name": "ayberkt/cubical", "max_forks_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.1797752809, "max_line_length": 89, "alphanum_fraction": 0.6403574088, "num_tokens": 1297, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.875787001374006, "lm_q2_score": 0.7310585669110203, "lm_q1q2_score": 0.6402515901437806}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Relation.Binary.Construct.Always where\n\nopen import Cubical.Core.Everything\n\nopen import Cubical.Relation.Binary\nopen import Cubical.Relation.Binary.Construct.Constant using (Const)\nopen import Cubical.Data.Unit.Polymorphic\n\n------------------------------------------------------------------------\n-- Definition\n\nAlways : ∀ {a b ℓ} {A : Type a} {B : Type b} → REL A B ℓ\nAlways = Const (⊤ , isProp⊤)\n\n------------------------------------------------------------------------\n-- Properties\n\nmodule _ {a} (A : Type a) ℓ where\n\n reflexive : Reflexive {A = A} {ℓ = ℓ} Always\n reflexive = _\n\n symmetric : Symmetric {A = A} {ℓ = ℓ} Always\n symmetric _ = _\n\n transitive : Transitive {A = A} {ℓ = ℓ} Always\n transitive _ _ = _\n\n isEquivalence : IsEquivalence {ℓ = ℓ} {A} Always\n isEquivalence = record {}\n\n equivalence : Equivalence A ℓ\n equivalence = record\n { isEquivalence = isEquivalence\n }\n", "meta": {"hexsha": "75fa39d85d16fe6c4e469839a7d8f8af2e9311c2", "size": 967, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Relation/Binary/Construct/Always.agda", "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Relation/Binary/Construct/Always.agda", "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Relation/Binary/Construct/Always.agda", "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.1351351351, "max_line_length": 72, "alphanum_fraction": 0.5780765253, "num_tokens": 264, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8757869851639066, "lm_q2_score": 0.7310585727705126, "lm_q1q2_score": 0.6402515834249156}} {"text": "module tree where\n\nopen import bool\nopen import eq\nopen import level\nopen import list \nopen import list-to-string \nopen import nat\nopen import nat-thms\nopen import string\n\n----------------------------------------------------------------------\n-- datatype\n----------------------------------------------------------------------\n\n-- nonempty trees\ndata 𝕋 {ℓ} (A : Set ℓ) : Set ℓ where\n node : A → 𝕃 (𝕋 A) → 𝕋 A\n\n----------------------------------------------------------------------\n-- tree operations\n----------------------------------------------------------------------\n\nleaf : ∀ {ℓ}{A : Set ℓ} → A → 𝕋 A\nleaf a = node a []\n\n𝕋-to-string : ∀ {ℓ}{A : Set ℓ} → (f : A → string) → (t : 𝕋 A) → string\n𝕋s-to-string : ∀ {ℓ}{A : Set ℓ} → (f : A → string) → (ts : 𝕃 (𝕋 A)) → string\n𝕋-to-string f (node a []) = f a\n𝕋-to-string f (node a ts) = \"(\" ^ (f a) ^ (𝕋s-to-string f ts) ^ \")\"\n𝕋s-to-string f [] = \"\"\n𝕋s-to-string f (t :: ts) = \" \" ^ (𝕋-to-string f t) ^ (𝕋s-to-string f ts)\n\nperfect-binary-tree : ∀ {ℓ}{A : Set ℓ} → ℕ → A → 𝕋 A\nperfect-binary-tree 0 a = (node a [])\nperfect-binary-tree (suc n) a = let t = perfect-binary-tree n a in \n (node a (t :: t :: []))\n\nsize𝕋 : ∀ {ℓ}{A : Set ℓ} → 𝕋 A → ℕ\nsize𝕋s : ∀ {ℓ}{A : Set ℓ} → 𝕃 (𝕋 A) → ℕ\nsize𝕋 (node a ts) = suc (size𝕋s ts)\nsize𝕋s [] = 0\nsize𝕋s (t :: ts) = size𝕋 t + size𝕋s ts\n\nsize-perfect : ∀ {ℓ}{A : Set ℓ}(n : ℕ)(a : A) → (size𝕋 (perfect-binary-tree n a)) ≡ pred (2 pow (suc n))\nsize-perfect 0 a = refl\nsize-perfect (suc n) a with (size𝕋 (perfect-binary-tree n a)) | size-perfect n a\n... | s | ps rewrite ps with 2 pow n | nonzero-pow 2 n refl\n... | x | px rewrite +0 x with x + x | (iszerosum2 x x px)\n... | x2 | q rewrite +0 x2 | +0 (pred x2) | sym (+suc (pred x2) (pred x2)) | sucpred q | pred+ x2 x2 q = refl\n", "meta": {"hexsha": "7cca65047465e84f79ed2c893080230b44b4c345", "size": 1793, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tree.agda", "max_stars_repo_name": "rfindler/ial", "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 29, "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_issues_repo_path": "tree.agda", "max_issues_repo_name": "rfindler/ial", "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_forks_repo_path": "tree.agda", "max_forks_repo_name": "rfindler/ial", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 17, "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "avg_line_length": 35.1568627451, "max_line_length": 109, "alphanum_fraction": 0.4673731177, "num_tokens": 649, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835207180243, "lm_q2_score": 0.7662936377487304, "lm_q1q2_score": 0.6402257063701317}} {"text": "-- Andreas, AIM XIII, 2011-04-07\n-- {-# OPTIONS -v tc.rec.proj:50 #-}\nmodule DependentIrrelevance where\n\nopen import Common.Irrelevance\n\nElimSq = {A : Set}(P : Squash A -> Set)\n (ih : .(a : A) -> P (squash a)) ->\n (a- : Squash A) -> P a-\nelimSq : ElimSq\nelimSq P ih (squash a) = ih a\n\nelimSq' : ElimSq\nelimSq' P ih a- = ih (Squash.unsquash a-)\n\nElimSq' = {A : Set}(P : Squash A -> Set)\n (ih : forall .a -> P (squash a)) ->\n (a- : Squash A) -> P a-\n\nrecord Union (A : Set)(B : .A -> Set) : Set where\n field\n .index : A\n elem : B index\n\nmakeUnion : {A : Set}{B : .A -> Set}.(index : A)(elem : B index) -> Union A B\nmakeUnion i e = record { index = i ; elem = e }\n\n\n{- extended parsing examples (do not work yet)\n\npostulate\n A : Set\n P : .A -> Set\n a : A\n\nf1 : _\nf1 = λ .x -> P x\n\nf2 : .A -> A\nf2 = λ x -> a\n\npostulate\n g : forall .x -> P x\n f : (.x : A) -> P x\n f' : .(x : A) -> P x\n f'' : forall .x .(y : A) -> P x\n g1 : forall .(x y : A) -> P x\n g2 : forall (.x .y : A) -> P x\n g3 : forall {.x .y : A} -> P x\n g4 : forall x1 {.x2} .{x3 x4} {.x y} -> P x\n\n-}\n", "meta": {"hexsha": "15483051c91da59ad9bb3f4528cb74d0075b8ade", "size": 1121, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/DependentIrrelevance.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/succeed/DependentIrrelevance.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/DependentIrrelevance.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 21.1509433962, "max_line_length": 77, "alphanum_fraction": 0.4915254237, "num_tokens": 458, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152324713956854, "lm_q2_score": 0.7853085808877581, "lm_q1q2_score": 0.6402090552053656}} {"text": "{-# OPTIONS --cubical --safe #-}\nmodule Cubical.Data.HomotopyGroup.Base where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\nimport Cubical.Foundations.GroupoidLaws as GL\n\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Group.Base\n\nopen import Cubical.HITs.SetTruncation\n\nPointed : ∀ {ℓ} → Type (ℓ-suc ℓ)\nPointed {ℓ} = Σ[ A ∈ Type ℓ ] A\n\nΩ : ∀ {ℓ} → Pointed {ℓ} → Pointed {ℓ}\nΩ (A , a ) = ( (a ≡ a) , refl)\n\nΩ^_ : ∀ {ℓ} → ℕ → Pointed {ℓ} → Pointed {ℓ}\n(Ω^ 0) p = p\n(Ω^ (suc n)) p = Ω ((Ω^ n) p)\n\nπ^_ : ∀ {ℓ} → ℕ → Pointed {ℓ} → Group {ℓ}\nπ^_ {ℓ} n p = group ∥ A ∥₀ squash₀ g\n where\n n' : ℕ\n n' = suc n\n\n A : Type ℓ\n A = (Ω^ n') p .fst\n\n g : isGroup ∥ A ∥₀\n g = group-struct e _⁻¹ _⊙_ lUnit rUnit assoc lCancel rCancel\n where\n e : ∥ A ∥₀\n e = ∣ (Ω^ n') p .snd ∣₀\n\n _⁻¹ : ∥ A ∥₀ → ∥ A ∥₀\n _⁻¹ = elimSetTrunc {B = λ _ → ∥ A ∥₀} (λ x → squash₀) λ a → ∣ sym a ∣₀\n\n _⊙_ : ∥ A ∥₀ → ∥ A ∥₀ → ∥ A ∥₀\n _⊙_ = elimSetTrunc2 (λ _ _ → squash₀) λ a₀ a₁ → ∣ a₀ ∙ a₁ ∣₀\n\n lUnit : (a : ∥ A ∥₀) → (e ⊙ a) ≡ a\n lUnit = elimSetTrunc (λ _ → isProp→isSet (squash₀ _ _))\n (λ a → cong ∣_∣₀ (sym (GL.lUnit a) ))\n\n rUnit : (a : ∥ A ∥₀) → a ⊙ e ≡ a\n rUnit = elimSetTrunc (λ _ → isProp→isSet (squash₀ _ _))\n (λ a → cong ∣_∣₀ (sym (GL.rUnit a) ))\n\n assoc : (a b c : ∥ A ∥₀) → ((a ⊙ b) ⊙ c) ≡ (a ⊙ (b ⊙ c))\n assoc = elimSetTrunc3 (λ _ _ _ → isProp→isSet (squash₀ _ _))\n (λ a b c → cong ∣_∣₀ (sym (GL.assoc _ _ _)))\n\n lCancel : (a : ∥ A ∥₀) → ((a ⁻¹) ⊙ a) ≡ e\n lCancel = elimSetTrunc (λ _ → isProp→isSet (squash₀ _ _))\n λ a → cong ∣_∣₀ (GL.lCancel _)\n\n rCancel : (a : ∥ A ∥₀) → (a ⊙ (a ⁻¹)) ≡ e\n rCancel = elimSetTrunc (λ _ → isProp→isSet (squash₀ _ _))\n λ a → cong ∣_∣₀ (GL.rCancel _)\n", "meta": {"hexsha": "1c2a8544144d932b0ab915248d59c18245666355", "size": 1911, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/HomotopyGroup/Base.agda", "max_stars_repo_name": "cj-xu/cubical", "max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/HomotopyGroup/Base.agda", "max_issues_repo_name": "cj-xu/cubical", "max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Data/HomotopyGroup/Base.agda", "max_forks_repo_name": "cj-xu/cubical", "max_forks_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.3333333333, "max_line_length": 79, "alphanum_fraction": 0.4882260597, "num_tokens": 861, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.894789457685656, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.6401538437732378}} {"text": "{-# OPTIONS --universe-polymorphism #-}\n\nopen import Categories.Category\nopen import Categories.Object.Terminal\nopen import Level\n\nmodule Categories.Object.Terminal.Exponentials {o ℓ e : Level}\n (C : Category o ℓ e)\n (T : Terminal C) where\n\nopen Category C\nopen Terminal T\n\nimport Categories.Object.Exponential\nimport Categories.Object.Product\nimport Categories.Object.Product.Morphisms\nimport Categories.Object.Terminal.Products\n\nopen Categories.Object.Exponential C hiding (repack)\nopen Categories.Object.Product C\nopen Categories.Object.Product.Morphisms C\nopen Categories.Object.Terminal.Products C T\n\n[_↑⊤] : Obj → Obj\n[ B ↑⊤] = B\n\n[_↑⊤]-exponential : (B : Obj) → Exponential ⊤ B\n[ B ↑⊤]-exponential = record\n { B^A = [ B ↑⊤]\n ; product = [ B ×⊤]-product\n ; eval = id\n ; λg = λ {X} p g → g ∘ repack [ X ×⊤]-product p\n ; β = λ {X} p {g} → \n begin\n id ∘ (g ∘ [ p ]⟨ id , ! ⟩) ∘ [ p ]π₁\n ↓⟨ identityˡ ⟩\n (g ∘ [ p ]⟨ id , ! ⟩) ∘ [ p ]π₁\n ↓⟨ assoc ⟩\n g ∘ [ p ]⟨ id , ! ⟩ ∘ [ p ]π₁\n ↓⟨ refl ⟩∘⟨ Product.⟨⟩∘ p ⟩\n g ∘ [ p ]⟨ id ∘ [ p ]π₁ , ! ∘ [ p ]π₁ ⟩\n ↓⟨ refl ⟩∘⟨ Product.⟨⟩-cong₂ p identityˡ (!-unique₂ (! ∘ [ p ]π₁) [ p ]π₂) ⟩\n g ∘ [ p ]⟨ [ p ]π₁ , [ p ]π₂ ⟩\n ↓⟨ refl ⟩∘⟨ Product.η p ⟩\n g ∘ id\n ↓⟨ identityʳ ⟩\n g\n ∎\n ; λ-unique = λ{X} p {g}{h} h-commutes → \n begin\n h\n ↑⟨ identityʳ ⟩\n h ∘ id\n ↑⟨ refl ⟩∘⟨ Product.commute₁ p ⟩\n h ∘ [ p ]π₁ ∘ [ p ]⟨ id , ! ⟩\n ↑⟨ assoc ⟩\n (h ∘ [ p ]π₁) ∘ [ p ]⟨ id , ! ⟩\n ↑⟨ identityˡ ⟩∘⟨ refl ⟩\n (id ∘ h ∘ [ p ]π₁) ∘ [ p ]⟨ id , ! ⟩\n ↓⟨ h-commutes ⟩∘⟨ refl ⟩\n g ∘ repack [ X ×⊤]-product p\n ∎\n } \n where\n open HomReasoning\n open Equiv\n\n[⊤↑_] : Obj → Obj\n[⊤↑ B ] = ⊤\n\n[⊤↑_]-exponential : (A : Obj) → Exponential A ⊤\n[⊤↑ A ]-exponential = record\n { B^A = [⊤↑ A ]\n ; product = [⊤× A ]-product\n ; eval = !\n ; λg = λ _ _ → !\n ; β = λ _ → !-unique₂ _ _\n ; λ-unique = λ _ _ → !-unique₂ _ _\n } \n", "meta": {"hexsha": "c8fe885d01ea224f38a58bdfdb7f2c934caef1a5", "size": 2185, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Object/Terminal/Exponentials.agda", "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 98, "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_issues_repo_path": "Categories/Object/Terminal/Exponentials.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_forks_repo_path": "Categories/Object/Terminal/Exponentials.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 23, "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "avg_line_length": 27.3125, "max_line_length": 84, "alphanum_fraction": 0.4604118993, "num_tokens": 869, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797075998823, "lm_q2_score": 0.7025300573952052, "lm_q1q2_score": 0.6401311322774916}} {"text": "{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-}\n\nmodule Cubical.Data.InfNat.Base where\n\nopen import Cubical.Data.Nat as ℕ using (ℕ)\nopen import Cubical.Core.Primitives\n\ndata ℕ+∞ : Type₀ where\n ∞ : ℕ+∞\n fin : ℕ → ℕ+∞\n\nsuc : ℕ+∞ → ℕ+∞\nsuc ∞ = ∞\nsuc (fin n) = fin (ℕ.suc n)\n\nzero : ℕ+∞\nzero = fin ℕ.zero\n\ncaseInfNat : ∀ {ℓ} → {A : Type ℓ} → (aF aI : A) → ℕ+∞ → A\ncaseInfNat aF aI (fin n) = aF\ncaseInfNat aF aI ∞ = aI\n\ninfixl 6 _+_\n_+_ : ℕ+∞ → ℕ+∞ → ℕ+∞\n∞ + m = ∞\nfin n + ∞ = ∞\nfin n + fin m = fin (n ℕ.+ m)\n\ninfixl 7 _·_\n_·_ : ℕ+∞ → ℕ+∞ → ℕ+∞\nfin m · fin n = fin (m ℕ.· n)\n∞ · fin ℕ.zero = zero\nfin ℕ.zero · ∞ = zero\n∞ · ∞ = ∞\n∞ · fin (ℕ.suc _) = ∞\nfin (ℕ.suc _) · ∞ = ∞\n", "meta": {"hexsha": "e152f6f8a2c6c2aabe1a040afe6302e7a820a943", "size": 802, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/InfNat/Base.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/InfNat/Base.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/Data/InfNat/Base.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.6756756757, "max_line_length": 67, "alphanum_fraction": 0.4501246883, "num_tokens": 356, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9241418158002492, "lm_q2_score": 0.6926419894793248, "lm_q1q2_score": 0.6400994258569203}} {"text": "{-# OPTIONS --allow-unsolved-metas #-}\nmodule nat where\n\nopen import Data.Nat \nopen import Data.Nat.Properties\nopen import Data.Empty\nopen import Relation.Nullary\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Binary.Core\nopen import Relation.Binary.Definitions\nopen import logic\nopen import Level hiding ( zero ; suc ) \n\nnat-<> : { x y : ℕ } → x < y → y < x → ⊥\nnat-<> (s≤s x x : { x y : ℕ } → x ≤ y → y < x → ⊥\nnat-≤> (s≤s x x→¬< : {x y : ℕ } → (x < y ) → ¬ ( y < x )\n>→¬< (s≤s x→¬< x y → minus x y + y ≡ x\nminus+n {x} {zero} _ = trans (sym (+-comm zero _ )) refl\nminus+n {zero} {suc y} (s≤s ())\nminus+n {suc x} {suc y} (s≤s lt) = begin\n minus (suc x) (suc y) + suc y\n ≡⟨ +-comm _ (suc y) ⟩\n suc y + minus x y \n ≡⟨ cong ( λ k → suc k ) (\n begin\n y + minus x y \n ≡⟨ +-comm y _ ⟩\n minus x y + y\n ≡⟨ minus+n {x} {y} lt ⟩\n x \n ∎ \n ) ⟩\n suc x\n ∎ where open ≡-Reasoning\n\n<-minus-0 : {x y z : ℕ } → z + x < z + y → x < y\n<-minus-0 {x} {suc _} {zero} lt = lt\n<-minus-0 {x} {y} {suc z} (s≤s lt) = <-minus-0 {x} {y} {z} lt\n\n<-minus : {x y z : ℕ } → x + z < y + z → x < y\n<-minus {x} {y} {z} lt = <-minus-0 ( subst₂ ( λ j k → j < k ) (+-comm x _) (+-comm y _ ) lt )\n\nx≤x+y : {z y : ℕ } → z ≤ z + y\nx≤x+y {zero} {y} = z≤n\nx≤x+y {suc z} {y} = s≤s (x≤x+y {z} {y})\n\nx≤y+x : {z y : ℕ } → z ≤ y + z\nx≤y+x {z} {y} = subst (λ k → z ≤ k ) (+-comm _ y ) x≤x+y\n\n<-plus : {x y z : ℕ } → x < y → x + z < y + z \n<-plus {zero} {suc y} {z} (s≤s z≤n) = s≤s (subst (λ k → z ≤ k ) (+-comm z _ ) x≤x+y )\n<-plus {suc x} {suc y} {z} (s≤s lt) = s≤s (<-plus {x} {y} {z} lt)\n\n<-plus-0 : {x y z : ℕ } → x < y → z + x < z + y \n<-plus-0 {x} {y} {z} lt = subst₂ (λ j k → j < k ) (+-comm _ z) (+-comm _ z) ( <-plus {x} {y} {z} lt )\n\n≤-plus : {x y z : ℕ } → x ≤ y → x + z ≤ y + z\n≤-plus {0} {y} {zero} z≤n = z≤n\n≤-plus {0} {y} {suc z} z≤n = subst (λ k → z < k ) (+-comm _ y ) x≤x+y \n≤-plus {suc x} {suc y} {z} (s≤s lt) = s≤s ( ≤-plus {x} {y} {z} lt )\n\n≤-plus-0 : {x y z : ℕ } → x ≤ y → z + x ≤ z + y \n≤-plus-0 {x} {y} {zero} lt = lt\n≤-plus-0 {x} {y} {suc z} lt = s≤s ( ≤-plus-0 {x} {y} {z} lt )\n\nx+y0 : {x y : ℕ } → x < y → 0 < minus y x \nminus>0 {zero} {suc _} (s≤s z≤n) = s≤s z≤n\nminus>0 {suc x} {suc y} (s≤s lt) = minus>0 {x} {y} lt\n\nminus>0→x0→x ¬a ¬b c = ⊥-elim ( nat-≡< (sym (minus<=0 {y} (≤-trans refl-≤s c ))) lt )\n\nminus+y-y : {x y : ℕ } → (x + y) - y ≡ x\nminus+y-y {zero} {y} = minus<=0 {zero + y} {y} ≤-refl \nminus+y-y {suc x} {y} = begin\n (suc x + y) - y ≡⟨ sym (minus+1 {_} {y} x≤y+x) ⟩\n suc ((x + y) - y) ≡⟨ cong suc (minus+y-y {x} {y}) ⟩\n suc x ∎ where open ≡-Reasoning\n\nminus+yx-yz : {x y z : ℕ } → (y + x) - (y + z) ≡ x - z\nminus+yx-yz {x} {zero} {z} = refl\nminus+yx-yz {x} {suc y} {z} = minus+yx-yz {x} {y} {z} \n\nminus+xy-zy : {x y z : ℕ } → (x + y) - (z + y) ≡ x - z\nminus+xy-zy {x} {y} {z} = subst₂ (λ j k → j - k ≡ x - z ) (+-comm y x) (+-comm y z) (minus+yx-yz {x} {y} {z})\n\ny-x ¬a ¬b c = subst ( λ k → k < y ) (sym (minus<=0 {y} {x} (≤-trans (≤-trans refl-≤s refl-≤s) c))) 0 ¬a ¬b c = +m= {_} {_} {suc y * z} ( begin\n minus x (suc y) * z + suc y * z\n ≡⟨ sym (proj₂ *-distrib-+ z (minus x (suc y) ) _) ⟩\n ( minus x (suc y) + suc y ) * z\n ≡⟨ cong (λ k → k * z) (minus+n {x} {suc y} (s≤s c)) ⟩\n x * z \n ≡⟨ sym (minus+n {x * z} {suc y * z} (s≤s (lt c))) ⟩\n minus (x * z) (suc y * z) + suc y * z\n ∎ ) where\n open ≡-Reasoning\n lt : {x y z : ℕ } → suc y ≤ x → z + y * z ≤ x * z\n lt {x} {y} {z} le = *≤ le \n\ndistr-minus-*' : {z x y : ℕ } → z * (minus x y) ≡ minus (z * x) (z * y) \ndistr-minus-*' {z} {x} {y} = begin\n z * (minus x y) ≡⟨ *-comm _ (x - y) ⟩\n (minus x y) * z ≡⟨ distr-minus-* {x} {y} {z} ⟩\n minus (x * z) (y * z) ≡⟨ cong₂ (λ j k → j - k ) (*-comm x z ) (*-comm y z) ⟩\n minus (z * x) (z * y) ∎ where open ≡-Reasoning\n\nminus- : {x y z : ℕ } → suc x > z + y → minus (minus x y) z ≡ minus x (y + z)\nminus- {x} {y} {z} gt = +m= {_} {_} {z} ( begin\n minus (minus x y) z + z\n ≡⟨ minus+n {_} {z} lemma ⟩\n minus x y\n ≡⟨ +m= {_} {_} {y} ( begin\n minus x y + y \n ≡⟨ minus+n {_} {y} lemma1 ⟩\n x\n ≡⟨ sym ( minus+n {_} {z + y} gt ) ⟩\n minus x (z + y) + (z + y)\n ≡⟨ sym ( +-assoc (minus x (z + y)) _ _ ) ⟩\n minus x (z + y) + z + y\n ∎ ) ⟩\n minus x (z + y) + z\n ≡⟨ cong (λ k → minus x k + z ) (+-comm _ y ) ⟩\n minus x (y + z) + z\n ∎ ) where\n open ≡-Reasoning\n lemma1 : suc x > y\n lemma1 = x+y z\n lemma = <-minus {_} {_} {y} ( subst ( λ x → z + y < suc x ) (sym (minus+n {x} {y} lemma1 )) gt )\n\nminus-* : {M k n : ℕ } → n < k → minus k (suc n) * M ≡ minus (minus k n * M ) M\nminus-* {zero} {k} {n} lt = begin\n minus k (suc n) * zero\n ≡⟨ *-comm (minus k (suc n)) zero ⟩\n zero * minus k (suc n) \n ≡⟨⟩\n 0 * minus k n \n ≡⟨ *-comm 0 (minus k n) ⟩\n minus (minus k n * 0 ) 0\n ∎ where\n open ≡-Reasoning\nminus-* {suc m} {k} {n} lt with <-cmp k 1\nminus-* {suc m} {.0} {zero} lt | tri< (s≤s z≤n) ¬b ¬c = refl\nminus-* {suc m} {.0} {suc n} lt | tri< (s≤s z≤n) ¬b ¬c = refl\nminus-* {suc zero} {.1} {zero} lt | tri≈ ¬a refl ¬c = refl\nminus-* {suc (suc m)} {.1} {zero} lt | tri≈ ¬a refl ¬c = minus-* {suc m} {1} {zero} lt \nminus-* {suc m} {.1} {suc n} (s≤s ()) | tri≈ ¬a refl ¬c\nminus-* {suc m} {k} {n} lt | tri> ¬a ¬b c = begin\n minus k (suc n) * M\n ≡⟨ distr-minus-* {k} {suc n} {M} ⟩\n minus (k * M ) ((suc n) * M)\n ≡⟨⟩\n minus (k * M ) (M + n * M )\n ≡⟨ cong (λ x → minus (k * M) x) (+-comm M _ ) ⟩\n minus (k * M ) ((n * M) + M )\n ≡⟨ sym ( minus- {k * M} {n * M} (lemma lt) ) ⟩\n minus (minus (k * M ) (n * M)) M\n ≡⟨ cong (λ x → minus x M ) ( sym ( distr-minus-* {k} {n} )) ⟩\n minus (minus k n * M ) M\n ∎ where\n M = suc m\n lemma : {n k m : ℕ } → n < k → suc (k * suc m) > suc m + n * suc m\n lemma {zero} {suc k} {m} (s≤s lt) = s≤s (s≤s (subst (λ x → x ≤ m + k * suc m) (+-comm 0 _ ) x≤x+y ))\n lemma {suc n} {suc k} {m} lt = begin\n suc (suc m + suc n * suc m) \n ≡⟨⟩\n suc ( suc (suc n) * suc m)\n ≤⟨ ≤-plus-0 {_} {_} {1} (*≤ lt ) ⟩\n suc (suc k * suc m)\n ∎ where open ≤-Reasoning\n open ≡-Reasoning\n\nx=y+z→x-z=y : {x y z : ℕ } → x ≡ y + z → x - z ≡ y\nx=y+z→x-z=y {x} {zero} {.x} refl = minus<=0 {x} {x} refl-≤ -- x ≡ suc (y + z) → (x ≡ y + z → x - z ≡ y) → (x - z) ≡ suc y\nx=y+z→x-z=y {suc x} {suc y} {zero} eq = begin -- suc x ≡ suc (y + zero) → (suc x - zero) ≡ suc y\n suc x - zero ≡⟨ refl ⟩\n suc x ≡⟨ eq ⟩\n suc y + zero ≡⟨ +-comm _ zero ⟩\n suc y ∎ where open ≡-Reasoning\nx=y+z→x-z=y {suc x} {suc y} {suc z} eq = x=y+z→x-z=y {x} {suc y} {z} ( begin\n x ≡⟨ cong pred eq ⟩\n pred (suc y + suc z) ≡⟨ +-comm _ (suc z) ⟩\n suc z + y ≡⟨ cong suc ( +-comm _ y ) ⟩\n suc y + z ∎ ) where open ≡-Reasoning\n\nm*1=m : {m : ℕ } → m * 1 ≡ m\nm*1=m {zero} = refl\nm*1=m {suc m} = cong suc m*1=m\n\nrecord Finduction {n m : Level} (P : Set n ) (Q : P → Set m ) (f : P → ℕ) : Set (n Level.⊔ m) where\n field\n fzero : {p : P} → f p ≡ zero → Q p\n pnext : (p : P ) → P\n decline : {p : P} → 0 < f p → f (pnext p) < f p\n ind : {p : P} → Q (pnext p) → Q p\n\ny ¬a ¬b ()\n... | tri≈ ¬a b ¬c = Finduction.fzero I (sym b) \n... | tri< lt _ _ = f-induction0 p (f p) ( ¬a ¬b c = ⊥-elim ( nat-≤> le c ) \n\n\nrecord Ninduction {n m : Level} (P : Set n ) (Q : P → Set m ) (f : P → ℕ) : Set (n Level.⊔ m) where\n field\n pnext : (p : P ) → P\n fzero : {p : P} → f (pnext p) ≡ zero → Q p\n decline : {p : P} → 0 < f p → f (pnext p) < f p\n ind : {p : P} → Q (pnext p) → Q p\n\ns≤s→≤ : { i j : ℕ} → suc i ≤ suc j → i ≤ j\ns≤s→≤ (s≤s lt) = lt\n\nn-induction : {n m : Level} {P : Set n } → {Q : P → Set m }\n → (f : P → ℕ) \n → Ninduction P Q f\n → (p : P ) → Q p\nn-induction {n} {m} {P} {Q} f I p = f-induction0 p (f (Ninduction.pnext I p)) ≤-refl where \n f-induction0 : (p : P) → (x : ℕ) → (f (Ninduction.pnext I p)) ≤ x → Q p\n f-induction0 p zero lt = Ninduction.fzero I {p} (fi0 _ lt) \n f-induction0 p (suc x) le with <-cmp (f (Ninduction.pnext I p)) (suc x) \n ... | tri< (s≤s a) ¬b ¬c = f-induction0 p x a\n ... | tri≈ ¬a b ¬c = Ninduction.ind I (f-induction0 (Ninduction.pnext I p) x (s≤s→≤ nle) ) where\n f>0 : 0 < f (Ninduction.pnext I p)\n f>0 = subst (λ k → 0 < k ) (sym b) ( s≤s z≤n ) \n nle : suc (f (Ninduction.pnext I (Ninduction.pnext I p))) ≤ suc x\n nle = subst (λ k → suc (f (Ninduction.pnext I (Ninduction.pnext I p))) ≤ k) b (Ninduction.decline I {Ninduction.pnext I p} f>0 ) \n ... | tri> ¬a ¬b c = ⊥-elim ( nat-≤> le c ) \n\n\n", "meta": {"hexsha": "e4c7a928c285f2a9dbf69c84a9fe41c86b1cd5aa", "size": 18283, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/nat.agda", "max_stars_repo_name": "shinji-kono/HyperReal-in-agda", "max_stars_repo_head_hexsha": "64d5f1ec0a6d81b7b9c45a289f669bbf32c9c891", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/nat.agda", "max_issues_repo_name": "shinji-kono/HyperReal-in-agda", "max_issues_repo_head_hexsha": "64d5f1ec0a6d81b7b9c45a289f669bbf32c9c891", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/nat.agda", "max_forks_repo_name": "shinji-kono/HyperReal-in-agda", "max_forks_repo_head_hexsha": "64d5f1ec0a6d81b7b9c45a289f669bbf32c9c891", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.1691022965, "max_line_length": 136, "alphanum_fraction": 0.4259694798, "num_tokens": 8949, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9196425333801889, "lm_q2_score": 0.6959583376458153, "lm_q1q2_score": 0.6400328887596625}} {"text": "module TimeSpace where\nopen import Data.Product\nopen import Data.Sum\nopen import Data.List\nopen import Data.Nat\nopen import Data.Nat.Properties\nopen import Relation.Nullary\nopen import Relation.Binary.PropositionalEquality\nopen import Pi.Syntax\nopen import Pi.Opsem\nopen import Pi.Eval\nopen import Pi.Examples\n\n-- 𝔹+ n = 𝔹 +ᵤ … +ᵤ 𝔹\n𝔹+ : ℕ → 𝕌\n𝔹+ 0 = 𝟘\n𝔹+ 1 = 𝔹\n𝔹+ (suc (suc n)) = 𝔹 +ᵤ (𝔹+ (suc n))\n\n-- 𝔹* n = 𝔹 ×ᵤ … ×ᵤ 𝔹\n𝔹* : ℕ → 𝕌\n𝔹* 0 = 𝔹\n𝔹* (suc n) = 𝔹 ×ᵤ 𝔹* n\n\nconvert : ∀ {n} → 𝔹+ (2 ^ n) ↔ 𝔹* n\nconvert {0} = id↔\nconvert {1} = (uniti⋆l ⊕ uniti⋆l) ⨾ factor\nconvert {suc (suc n)} = split ⨾ (convert {suc n} ⊕ (coe {n} ⨾ convert {suc n})) ⨾ (uniti⋆l ⊕ uniti⋆l) ⨾ factor\n where\n coe : ∀ {n} → 𝔹+ ((2 ^ n) + ((2 ^ n) + 0) + 0) ↔ 𝔹+ (2 ^ (1 + n))\n coe {n} rewrite +-identityʳ ((2 ^ n) + ((2 ^ n) + 0)) = id↔\n \n split : ∀ {n m} → 𝔹+ (n + m) ↔ (𝔹+ n +ᵤ 𝔹+ m)\n split {0} {m} = uniti₊l\n split {1} {0} = uniti₊r\n split {1} {1} = id↔\n split {1} {suc (suc m)} = id↔\n split {suc (suc n)} {m} = (id↔ ⊕ split) ⨾ assocl₊\n\n-- flip the last 𝔹\nflip+ : (n : ℕ) → 𝔹+ n ↔ 𝔹+ n\nflip+ 0 = id↔\nflip+ 1 = swap₊\nflip+ (suc (suc n)) = id↔ ⊕ flip+ (suc n)\n\n-- flip* n (b₁,…,bₙ,b) = (b₁,…,bₙ,b xor (b₁ ∧ … ∧ bₙ)) \nflip* : (n : ℕ) → (𝔹* n) ↔ (𝔹* n)\nflip* 0 = swap₊\nflip* (suc n) = dist ⨾ (id↔ ⊕ (id↔ ⊗ flip* n)) ⨾ factor\n\nv* : (n : ℕ) → ⟦ 𝔹* n ⟧\nv* 0 = 𝔽\nv* 1 = 𝕋 , v* 0\nv* (suc (suc n)) = 𝕋 , v* (suc n)\n\nv+ : (n : ℕ) → n ≢ 0 → ⟦ 𝔹+ n ⟧\nv+ 0 0≠0 = 0≠0 refl\nv+ 1 _ = 𝔽\nv+ (suc (suc n)) _ = inj₂ (v+ (suc n) (λ ()))\n\n-- Counting number of values in given context\n#ctx : ∀ {A B} → Context {A} {B} → ℕ\n#ctx ☐ = 0\n#ctx (☐⨾ c₂ • κ) = #ctx κ\n#ctx (c₁ ⨾☐• κ) = #ctx κ\n#ctx (☐⊕ c₂ • κ) = #ctx κ\n#ctx (c₁ ⊕☐• κ) = #ctx κ\n#ctx (☐⊗[ c₂ , x ]• κ) = 1 + #ctx κ\n#ctx ([ c₁ , x ]⊗☐• κ) = 1 + #ctx κ\n\n#st : State → ℕ\n#st ⟨ c ∣ v ∣ κ ⟩ = 1 + #ctx κ\n#st [ c ∣ v ∣ κ ] = 1 + #ctx κ\n\n-- Returns the number of steps and maximum #st in a execution trace\nrunST : ∀ {A B} → A ↔ B → ⟦ A ⟧ → List State × ℕ × ℕ\nrunST c v = states , length states , foldl (λ { s st → s ⊔ #st st }) 0 states\n where states = evalₜᵣ c v\n\n-- Examples\nex1 : ℕ × ℕ\nex1 = let(_ , t , s) = runST (flip* 9) (v* 9)\n in (t , s) -- t=128 , s=10\n\nex2 : ℕ × ℕ\nex2 = let (_ , t , s) = runST (flip+ 512) (v+ 512 (λ ()))\n in (t , s) -- t=1024 , s=1\n", "meta": {"hexsha": "facd09331772b92b961b2821dc1bd8ed0a90d91c", "size": 2288, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "TimeSpace.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "TimeSpace.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TimeSpace.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 26.0, "max_line_length": 110, "alphanum_fraction": 0.493006993, "num_tokens": 1256, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9196425355825848, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.6400328786935731}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Fixed-size tables of values, implemented as functions from 'Fin n'.\n-- Similar to 'Data.Vec', but focusing on ease of retrieval instead of\n-- ease of adding and removing elements.\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Table where\n\nopen import Data.Table.Base public\n\nopen import Data.Bool using (true; false)\nopen import Data.Fin using (Fin; _≟_)\nopen import Function.Equality using (_⟨$⟩_)\nopen import Function.Inverse using (Inverse; _↔_)\nopen import Relation.Nullary using (yes; no)\nopen import Relation.Nullary.Decidable using (⌊_⌋)\n\n--------------------------------------------------------------------------------\n-- Combinators\n--------------------------------------------------------------------------------\n\n-- Changes the order of elements in the table according to a permutation (i.e.\n-- an 'Inverse' object on the indices).\n\npermute : ∀ {m n a} {A : Set a} → Fin m ↔ Fin n → Table A n → Table A m\npermute π = rearrange (Inverse.to π ⟨$⟩_)\n\n-- The result of 'select z i t' takes the value of 'lookup t i' at index 'i',\n-- and 'z' everywhere else.\n\nselect : ∀ {n} {a} {A : Set a} → A → Fin n → Table A n → Table A n\nlookup (select z i t) j with j ≟ i\n... | yes _ = lookup t i\n... | no _ = z\n", "meta": {"hexsha": "4d0fc4f3a9e57ec24290c80a972bad445367cc28", "size": 1394, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Table.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Table.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Table.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.7435897436, "max_line_length": 80, "alphanum_fraction": 0.5272596844, "num_tokens": 322, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.919642526773001, "lm_q2_score": 0.6959583250334527, "lm_q1q2_score": 0.6400328725624699}} {"text": "\nopen import Common.List\nopen import Common.Equality\n\nmap-append : ∀{A B : Set}(f : A → B) (xs {ys} : List A) →\n map f (xs ++ ys) ≡ map f xs ++ map f ys\nmap-append f [] = refl\nmap-append f (x ∷ xs) = {!cong (f x ∷_)!} -- Keep section on C-c C-r\n\nmap-append₂ : ∀{A B : Set}(f : A → B) (xs {ys} : List A) →\n map f (xs ++ ys) ≡ map f xs ++ map f ys\nmap-append₂ f [] = refl\nmap-append₂ f (x ∷ xs) = {!cong (λ section → f x ∷ section)!} -- Keep lambda on C-c C-r\n\n-- Check that we print sections in goals\npostulate\n _+_ : Set → Set → Set\n μ : (Set → Set) → Set\n\nfoo : (A : Set) → μ (_+ A)\nfoo A = {!!}\n\nbar : (A : Set) → μ (λ section → section + A)\nbar A = {!!}\n", "meta": {"hexsha": "d6c47952be7b159f179e37e7af02960cb40af586", "size": 685, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue2270.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/interaction/Issue2270.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/interaction/Issue2270.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 27.4, "max_line_length": 87, "alphanum_fraction": 0.5211678832, "num_tokens": 256, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681049901037, "lm_q2_score": 0.7461390043208003, "lm_q1q2_score": 0.6400142397954557}} {"text": "\nmodule Issue535 where\n\ndata Nat : Set where\n zero : Nat\n suc : Nat → Nat\n\ndata Vec A : Nat → Set where\n [] : Vec A zero\n _∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)\n\nreplicate : ∀ {A n} → A → Vec A n\nreplicate {n = n} x = {!n!}\n\nreplicate′ : ∀ {n A} → A → Vec A n\nreplicate′ {n} x = {!n!}\n\nextlam : Nat → {n m : Nat} → Vec Nat n\nextlam = λ { x {m = m} → {!m!} }\n", "meta": {"hexsha": "50d81505f942f8d033657f1f1f5fdc6aebd78c4e", "size": 366, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue535.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/interaction/Issue535.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/interaction/Issue535.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 18.3, "max_line_length": 43, "alphanum_fraction": 0.5054644809, "num_tokens": 154, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577680904463334, "lm_q2_score": 0.7461389817407016, "lm_q1q2_score": 0.6400142095752932}} {"text": "module Class.Monoid where\n\nopen import Level\nopen import Data.List using (List; []; _∷_)\n\nrecord Monoid {a} (M : Set a) : Set (suc a) where\n infixl 6 _+_\n field\n mzero : M\n _+_ : M -> M -> M\n\nopen Monoid {{...}} public\n\nconcat : ∀ {a} {M : Set a} {{_ : Monoid M}} -> List M -> M\nconcat [] = mzero\nconcat (x ∷ l) = x + concat l\n", "meta": {"hexsha": "a3ff58d476e605927aa1005d4b356ac221835ab6", "size": 335, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "stdlib-exts/Class/Monoid.agda", "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 35, "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_issues_repo_path": "stdlib-exts/Class/Monoid.agda", "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 10, "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_forks_repo_path": "stdlib-exts/Class/Monoid.agda", "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "avg_line_length": 19.7058823529, "max_line_length": 58, "alphanum_fraction": 0.5671641791, "num_tokens": 124, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467611766711, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.6399972529333889}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\n\nmodule Categories.Functor.Core where\n\nopen import Level\n\nprivate\n variable\n o ℓ e o′ ℓ′ e′ : Level\n\nrecord Functor (C : Category o ℓ e) (D : Category o′ ℓ′ e′) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where\n eta-equality\n private module C = Category C\n private module D = Category D\n\n field\n F₀ : C.Obj → D.Obj\n F₁ : ∀ {A B} (f : C [ A , B ]) → D [ F₀ A , F₀ B ]\n\n identity : ∀ {A} → D [ F₁ (C.id {A}) ≈ D.id ]\n homomorphism : ∀ {X Y Z} {f : C [ X , Y ]} {g : C [ Y , Z ]} →\n D [ F₁ (C [ g ∘ f ]) ≈ D [ F₁ g ∘ F₁ f ] ]\n F-resp-≈ : ∀ {A B} {f g : C [ A , B ]} → C [ f ≈ g ] → D [ F₁ f ≈ F₁ g ]\n\n -- nice shorthands\n ₀ = F₀\n ₁ = F₁\n\n op : Functor C.op D.op\n op = record\n { F₀ = F₀\n ; F₁ = F₁\n ; identity = identity\n ; homomorphism = homomorphism\n ; F-resp-≈ = F-resp-≈\n }\n", "meta": {"hexsha": "361098fcb579588cd835d2ac13d65e6e614474c2", "size": 933, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Functor/Core.agda", "max_stars_repo_name": "laMudri/agda-categories", "max_stars_repo_head_hexsha": "5a49c6ac87cbb7e20511c28f28205163fe69f48f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Functor/Core.agda", "max_issues_repo_name": "laMudri/agda-categories", "max_issues_repo_head_hexsha": "5a49c6ac87cbb7e20511c28f28205163fe69f48f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Functor/Core.agda", "max_forks_repo_name": "laMudri/agda-categories", "max_forks_repo_head_hexsha": "5a49c6ac87cbb7e20511c28f28205163fe69f48f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.9230769231, "max_line_length": 98, "alphanum_fraction": 0.4673097535, "num_tokens": 376, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.879146761176671, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.6399972529333889}} {"text": "\nopen import Oscar.Prelude\nopen import Oscar.Class\nopen import Oscar.Class.HasEquivalence\nopen import Oscar.Class.Reflexivity\nopen import Oscar.Class.Symmetry\nopen import Oscar.Class.Transitivity\nopen import Oscar.Class.IsEquivalence\nopen import Oscar.Data.ProductIndexEquivalence\nimport Oscar.Data.Constraint\n\nmodule Oscar.Property.Setoid.ProductIndexEquivalence where\n\nmodule _ {𝔬} {𝔒 : Ø 𝔬} {𝔭} {𝔓 : 𝔒 → Ø 𝔭} {ℓ} ⦃ _ : HasEquivalence 𝔒 ℓ ⦄ where\n\n instance\n\n 𝓡eflexivityExtensionṖropertyEquivalence : Reflexivity.class ProductIndexEquivalence⟦ 𝔒 / 𝔓 ⟧\n 𝓡eflexivityExtensionṖropertyEquivalence .⋆ .π₀ = reflexivity\n\n 𝓢ymmetryExtensionṖropertyEquivalence : Symmetry.class ProductIndexEquivalence⟦ 𝔒 / 𝔓 ⟧\n 𝓢ymmetryExtensionṖropertyEquivalence .⋆ (∁ P≈Q) .π₀ = symmetry P≈Q\n\n 𝓣ransitivityExtensionṖropertyEquivalence : Transitivity.class ProductIndexEquivalence⟦ 𝔒 / 𝔓 ⟧\n 𝓣ransitivityExtensionṖropertyEquivalence .⋆ (∁ P≈Q) (∁ Q≈R) .π₀ = transitivity P≈Q Q≈R\n\n IsEquivalenceExtensionṖroperty : IsEquivalence ProductIndexEquivalence⟦ 𝔒 / 𝔓 ⟧\n IsEquivalenceExtensionṖroperty = ∁\n", "meta": {"hexsha": "6f659a85b9db1705abac3116533e7da678f9fc1d", "size": 1110, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-3/src/Oscar/Property/Setoid/ProductIndexEquivalence.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-3/src/Oscar/Property/Setoid/ProductIndexEquivalence.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-3/src/Oscar/Property/Setoid/ProductIndexEquivalence.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.275862069, "max_line_length": 99, "alphanum_fraction": 0.7792792793, "num_tokens": 383, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9284087926320944, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.6399573954342971}} {"text": "-- Example, ℤ is an Euclidean Domain. Here all the properties needed\n-- are already proved in Data.Integer.Properties. However, we will\n-- prove there is another divmod pair such that the rank estimation\n-- is more precise, see EucDomain2.agda.\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Integer.EucDomain where\n\n -- imports from stdlib.\n open import Relation.Nullary using (¬_)\n open import Relation.Binary.PropositionalEquality using (refl ; _≡_)\n\n open import Data.Nat using (_<_)\n open import Data.Integer\n using (_+_ ; _*_ ; -_ ; ℤ ; 0ℤ ; 1ℤ ; ∣_∣ ; +[1+_] ; -[1+_] ; +_)\n open import Data.Integer.DivMod\n renaming (_div_ to _divℤ_; _mod_ to _modℤ_ ; n%d ¬ d ≡ 0ℤ -> ℤ\n div n (+ 0) n0 with n0 refl\n ... | ()\n div n d@(+[1+ n₁ ]) n0 = n divℤ d \n div n d@(-[1+_] n₁) n0 = n divℤ d\n\n -- mod with irrelevant instance argument replaced by non-equality\n -- argument. \n mod : ∀ (n d : ℤ) -> ¬ d ≡ 0ℤ -> ℤ\n mod n (+ 0) n0 with n0 refl\n ... | ()\n mod n d@(+[1+ n₁ ]) n0 = + (n modℤ d)\n mod n d@(-[1+_] n₁) n0 = + (n modℤ d)\n\n -- Divident = reminder + quotient * divisor.\n euc-eq : ∀ (n d : ℤ) (n0 : ¬ d ≡ 0ℤ) ->\n let r = mod n d n0 in let q = div n d n0 in \n n ≡ r + q * d \n euc-eq n (+ 0) n0 with n0 refl\n ... | ()\n euc-eq n d@(+[1+ n₁ ]) n0 = euc-eqℤ n d \n euc-eq n d@(-[1+_] n₁) n0 = euc-eqℤ n d \n\n\n -- The rank of the reminder is strictly smaller than the rank of the\n -- divisor.\n euc-rank : ∀ (n d : ℤ) (n0 : ¬ d ≡ 0ℤ) ->\n let r = mod n d n0 in let q = div n d n0 in \n ∣ r ∣ < ∣ d ∣ \n euc-rank n (+ 0) n0 with n0 refl\n ... | ()\n euc-rank n d@(+[1+ n₁ ]) n0 = euc-rankℤ n d\n euc-rank n d@(-[1+_] n₁) n0 = euc-rankℤ n d\n\n\n -- Multiplication is left cancellative. \n *-alc-ℤ : AlmostLeftCancellative 0ℤ _*_\n *-alc-ℤ {+ 0} j k n0 with n0 refl\n ... | ()\n *-alc-ℤ {i@(+[1+ n ])} j k n0 = *-cancelˡ-≡ i j k\n *-alc-ℤ { i@(-[1+ n ])} j k n0 = *-cancelˡ-≡ i j k\n\n -- ℤ is an Euclidean Domain. \n +-*-isEuclideanDomain : IsEuclideanDomain _+_ _*_ -_ 0ℤ 1ℤ\n +-*-isEuclideanDomain = record\n { isCommutativeRing = +-*-isCommutativeRing \n ; *-alc = *-alc-ℤ\n ; div = div \n ; mod = mod \n ; rank = ∣_∣\n ; euc-eq = euc-eq \n ; euc-rank = euc-rank \n }\n\n -- Bundle.\n +-*-euclideanDomain : EuclideanDomainBundle _ _\n +-*-euclideanDomain = record\n { isEuclideanDomain = +-*-isEuclideanDomain\n }\n\n", "meta": {"hexsha": "f9a36ce8c59129d5c9a453f42e356a342c4aaf1c", "size": 4031, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Integer/EucDomain.agda", "max_stars_repo_name": "onestruggler/EucDomain", "max_stars_repo_head_hexsha": "7e268e8354065fde734c9c2d9998d2cfd4a21f71", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Integer/EucDomain.agda", "max_issues_repo_name": "onestruggler/EucDomain", "max_issues_repo_head_hexsha": "7e268e8354065fde734c9c2d9998d2cfd4a21f71", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Integer/EucDomain.agda", "max_forks_repo_name": "onestruggler/EucDomain", "max_forks_repo_head_hexsha": "7e268e8354065fde734c9c2d9998d2cfd4a21f71", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.3153153153, "max_line_length": 94, "alphanum_fraction": 0.5862068966, "num_tokens": 1372, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744761936437, "lm_q2_score": 0.7826624789529376, "lm_q1q2_score": 0.6398848662663666}} {"text": "{- Name: Bowornmet (Ben) Hudson\n\n--Progress and Preservation in Godel's T--\n\nProgress: if e:τ, then either e val or ∃e' such that e=>e'.\nPreservation: if e:τ and e=>e', then e':τ.\n\n-}\n\nopen import Preliminaries\n\nmodule Godel where\n\n -- nat and =>\n data Typ : Set where\n nat : Typ\n _⇒_ : Typ → Typ → Typ\n\n------------------------------------------\n\n -- represent a context as a list of types\n Ctx = List Typ\n\n -- de Bruijn indices (for free variables)\n data _∈_ : Typ → Ctx → Set where\n i0 : ∀ {Γ τ}\n → τ ∈ (τ :: Γ)\n iS : ∀ {Γ τ τ1}\n → τ ∈ Γ\n → τ ∈ (τ1 :: Γ)\n\n------------------------------------------\n\n -- static semantics\n data _|-_ : Ctx → Typ → Set where\n var : ∀ {Γ τ}\n → (x : τ ∈ Γ) → Γ |- τ\n z : ∀ {Γ}\n → Γ |- nat\n suc : ∀ {Γ}\n → (e : Γ |- nat)\n → Γ |- nat\n rec : ∀ {Γ τ}\n → (e : Γ |- nat)\n → (e0 : Γ |- τ)\n → (e1 : (nat :: (τ :: Γ)) |- τ)\n → Γ |- τ\n lam : ∀ {Γ τ ρ}\n → (x : (ρ :: Γ) |- τ)\n → Γ |- (ρ ⇒ τ)\n app : ∀ {Γ τ1 τ2}\n → (e1 : Γ |- (τ2 ⇒ τ1)) → (e2 : Γ |- τ2)\n → Γ |- τ1\n\n------------------------------------------\n\n -- renaming function\n rctx : Ctx → Ctx → Set\n rctx Γ Γ' = ∀ {τ} → τ ∈ Γ' → τ ∈ Γ\n\n -- re: transferring variables in contexts\n lem1 : ∀ {Γ Γ' τ} → rctx Γ Γ' → rctx (τ :: Γ) (τ :: Γ')\n lem1 d i0 = i0\n lem1 d (iS x) = iS (d x)\n\n -- renaming lemma\n ren : ∀ {Γ Γ' τ} → Γ' |- τ → rctx Γ Γ' → Γ |- τ\n ren (var x) d = var (d x)\n ren z d = z\n ren (suc e) d = suc (ren e d)\n ren (rec e e0 e1) d = rec (ren e d) (ren e0 d) (ren e1 (lem1(lem1 d)))\n ren (lam e) d = lam (ren e (lem1 d))\n ren (app e1 e2) d = app (ren e1 d) (ren e2 d)\n\n------------------------------------------\n\n -- substitution\n sctx : Ctx → Ctx → Set\n sctx Γ Γ' = ∀ {τ} → τ ∈ Γ' → Γ |- τ\n\n -- weakening a context\n wkn : ∀ {Γ τ1 τ2} → Γ |- τ2 → (τ1 :: Γ) |- τ2\n wkn e = ren e iS\n\n -- weakening also works with substitution\n wkn-s : ∀ {Γ τ1 Γ'} → sctx Γ Γ' → sctx (τ1 :: Γ) Γ'\n wkn-s d = λ f → wkn (d f)\n\n wkn-r : ∀ {Γ τ1 Γ'} → rctx Γ Γ' → rctx (τ1 :: Γ) Γ'\n wkn-r d = λ x → iS (d x)\n\n -- lem2 (need a lemma for subst like we did for renaming)\n lem2 : ∀ {Γ Γ' τ} → sctx Γ Γ' → sctx (τ :: Γ) (τ :: Γ')\n lem2 d i0 = var i0\n lem2 d (iS i) = wkn (d i)\n\n -- another substitution lemma\n lem3 : ∀ {Γ τ} → Γ |- τ → sctx Γ (τ :: Γ)\n lem3 e i0 = e\n lem3 e (iS i) = var i\n\n -- one final lemma needed for the last stepping rule. Thank you Professor Licata!\n lem4 : ∀ {Γ τ1 τ2} → Γ |- τ1 → Γ |- τ2 → sctx Γ (τ1 :: (τ2 :: Γ))\n lem4 e1 e2 i0 = e1\n lem4 e1 e2 (iS i0) = e2\n lem4 e1 e2 (iS (iS i)) = var i\n\n -- the 'real' substitution lemma (if (x : τ') :: Γ |- (e : τ) and Γ |- (e : τ') , then Γ |- e[x -> e'] : τ)\n subst : ∀ {Γ Γ' τ} → sctx Γ Γ' → Γ' |- τ → Γ |- τ\n subst d (var x) = d x\n subst d z = z\n subst d (suc e) = suc (subst d e)\n subst d (rec e e0 e1) = rec (subst d e) (subst d e0) (subst (lem2 (lem2 d)) e1)\n subst d (lam e) = lam (subst (lem2 d) e)\n subst d (app e1 e2) = app (subst d e1) (subst d e2)\n\n------------------------------------------\n\n -- closed values of L{nat,⇒} (when something is a value)\n -- recall that we use empty contexts when we work with dynamic semantics\n data val : ∀ {τ} → [] |- τ → Set where\n z-isval : val z\n suc-isval : (e : [] |- nat) → (val e)\n → val (suc e)\n lam-isval : ∀ {ρ τ} (e : (ρ :: []) |- τ)\n → val (lam e)\n\n------------------------------------------\n\n -- stepping rules (preservation is folded into this)\n -- Preservation: if e:τ and e=>e', then e':τ\n data _>>_ : ∀ {τ} → [] |- τ → [] |- τ → Set where\n suc-steps : (e e' : [] |- nat)\n → e >> e'\n → (suc e) >> (suc e')\n app-steps : ∀ {τ1 τ2}\n → (e1 e1' : [] |- (τ2 ⇒ τ1)) → (e2 : [] |- τ2)\n → e1 >> e1'\n → (app e1 e2) >> (app e1' e2)\n app-steps-2 : ∀ {τ1 τ2}\n → (e1 : [] |- (τ2 ⇒ τ1)) → (e2 e2' : [] |- τ2)\n → val e1 → e2 >> e2'\n → (app e1 e2) >> (app e1 e2')\n app-steps-3 : ∀ {τ1 τ2}\n → (e1 : (τ1 :: []) |- τ2)\n → (e2 : [] |- τ1)\n → (app (lam e1) e2) >> subst (lem3 e2) e1\n rec-steps : ∀ {τ}\n → (e e' : [] |- nat)\n → (e0 : [] |- τ)\n → (e1 : (nat :: (τ :: [])) |- τ)\n → e >> e'\n → (rec e e0 e1) >> (rec e' e0 e1)\n rec-steps-z : ∀ {τ}\n → (e : val z)\n → (e0 : [] |- τ)\n → (e1 : (nat :: (τ :: [])) |- τ)\n → (rec z e0 e1) >> e0\n rec-steps-suc : ∀ {τ}\n → (e : [] |- nat)\n → (e0 : [] |- τ)\n → (e1 : (nat :: (τ :: [])) |- τ)\n → val e\n → (rec (suc e) e0 e1) >> subst (lem4 e (rec e e0 e1)) e1\n\n------------------------------------------\n\n -- Proof of progress!\n -- Progress: if e:τ, then either e val or ∃e' such that e=>e'\n progress : ∀ {τ} (e : [] |- τ) → Either (val e) (Σ (λ e' → (e >> e')))\n progress (var ())\n progress z = Inl z-isval\n progress (suc e) with progress e\n progress (suc e) | Inl d = Inl (suc-isval e d)\n progress (suc e) | Inr (e' , d) = Inr (suc e' , suc-steps e e' d)\n progress (rec e e1 e2) with progress e\n progress (rec .z e1 e2) | Inl z-isval = Inr (e1 , rec-steps-z z-isval e1 e2)\n progress (rec .(suc e) e1 e2) | Inl (suc-isval e d) = Inr (subst (lem4 e (rec e e1 e2)) e2 , rec-steps-suc e e1 e2 d)\n progress (rec e e1 e2) | Inr (e' , d) = Inr (rec e' e1 e2 , rec-steps e e' e1 e2 d)\n progress (lam e) = Inl (lam-isval e)\n progress (app e1 e2) with progress e1\n progress (app .(lam e) e2) | Inl (lam-isval e) = Inr (subst (lem3 e2) e , app-steps-3 e e2)\n progress (app e1 e2) | Inr (e1' , d) = Inr (app e1' e2 , app-steps e1 e1' e2 d)\n\n------------------------------------------\n\n -- Denotational semantics\n\n -- interpreting a T type in Agda\n interp : Typ → Set\n interp nat = Nat\n interp (A ⇒ B) = interp A → interp B\n\n -- interpreting contexts\n interpC : Ctx → Set\n interpC [] = Unit\n interpC (A :: Γ) = interpC Γ × interp A\n\n -- helper function to look a variable up in an interpC gamma\n lookupC : ∀{Γ A} → (x : A ∈ Γ) → interpC Γ → interp A\n lookupC i0 (recur , return) = return\n lookupC (iS i) (recur , return) = lookupC i recur\n\n -- primitive recursion function corresponding to rec\n natrec : ∀{C : Set} → C → (Nat → C → C) → Nat → C\n natrec base step Z = base\n natrec base step (S n) = step n (natrec base step n)\n\n -- interpreting expressions in Godel's T as a function from the interpretation of the context to the interpretation of its corresponding type\n interpE : ∀{Γ τ} → Γ |- τ → (interpC Γ → interp τ)\n interpE (var x) d = lookupC x d\n interpE z d = Z\n interpE (suc e) d = S (interpE e d)\n interpE (rec e e0 e1) d = natrec (interpE e0 d) (λ n k → interpE e1 ((d , k) , n)) (interpE e d)\n interpE (lam e) d = λ x → interpE e (d , x)\n interpE (app e1 e2) d = interpE e1 d (interpE e2 d)\n\n helper : ∀ {Γ Γ' τ} → sctx Γ (τ :: Γ') → sctx Γ Γ'\n helper d = λ x → d (iS x)\n\n helper-r : ∀ {Γ Γ' τ} → rctx Γ (τ :: Γ') → rctx Γ Γ'\n helper-r d = λ x → d (iS x)\n\n -- compositionality of functions\n interpS : ∀ {Γ Γ'} → sctx Γ Γ' → interpC Γ → interpC Γ'\n interpS {Γ} {[]} a b = <>\n interpS {Γ} {A :: Γ'} a b = interpS (helper a) b , interpE (a i0) b\n\n interpR : ∀ {Γ Γ'} → rctx Γ Γ' → interpC Γ → interpC Γ'\n interpR {Γ} {[]} a b = <>\n interpR {Γ} {A :: Γ'} a b = interpR (helper-r a) b , lookupC (a i0) b\n\n --lemmas for lambda case of interpR-lemma\n interpR-lemma-lemma-lemma : ∀ {Γ Γ' τ} → (x : interp τ) → (Θ : rctx Γ Γ') → (Θ' : interpC Γ) → (interpR Θ Θ') == interpR (wkn-r Θ) (Θ' , x)\n interpR-lemma-lemma-lemma {Γ} {[]} x Θ Θ' = Refl\n interpR-lemma-lemma-lemma {Γ} {A :: Γ'} x Θ Θ' = ap (λ h → h , lookupC (Θ i0) Θ') (interpR-lemma-lemma-lemma x (helper-r Θ) Θ')\n\n interpR-lemma-lemma : ∀ {Γ Γ' τ} → (x : interp τ) → (Θ : rctx Γ Γ') → (Θ' : interpC Γ) → (interpR Θ Θ' , x) == (interpR (lem1 Θ) (Θ' , x))\n interpR-lemma-lemma {Γ} {[]} x Θ Θ' = Refl\n interpR-lemma-lemma {Γ} {A :: Γ'} x Θ Θ' = ap (λ h → h , x) (interpR-lemma-lemma-lemma x Θ Θ')\n\n interpR-lemma-lemma-rec : ∀ {Γ Γ' τ} → (x : interp nat) → (y : interp τ) → (Θ : rctx Γ Γ') → (Θ' : interpC Γ)\n → ((interpR Θ Θ' , y) , x) == interpR (lem1 (lem1 Θ)) ((Θ' , y) , x)\n interpR-lemma-lemma-rec x y Θ Θ' = interpR-lemma-lemma x (lem1 Θ) (Θ' , y) ∘ ap (λ h → h , x) (interpR-lemma-lemma y Θ Θ')\n\n interpR-lemma : ∀ {Γ Γ' τ} (e : Γ' |- τ) → (Θ : rctx Γ Γ') → (Θ' : interpC Γ) → (interpE e) (interpR Θ Θ') == (interpE (ren e Θ)) Θ'\n interpR-lemma (var i0) Θ Θ' = Refl\n interpR-lemma (var (iS x)) Θ Θ' = interpR-lemma (var x) (helper-r Θ) Θ'\n interpR-lemma z Θ Θ' = Refl\n interpR-lemma (suc e) Θ Θ' = ap S (interpR-lemma e Θ Θ')\n interpR-lemma {Γ} {Γ'} {τ} (rec e e1 e2) Θ Θ' = natrec (interpE e1 (interpR Θ Θ'))\n (λ n k → interpE e2 ((interpR Θ Θ' , k) , n))\n (interpE e (interpR Θ Θ')) =⟨ ap\n (λ h →\n natrec h (λ n k → interpE e2 ((interpR Θ Θ' , k) , n))\n (interpE e (interpR Θ Θ')))\n (interpR-lemma e1 Θ Θ') ⟩\n natrec (interpE (ren e1 Θ) Θ')\n (λ n k → interpE e2 ((interpR Θ Θ' , k) , n))\n (interpE e (interpR Θ Θ')) =⟨ ap\n (λ h →\n natrec (interpE (ren e1 Θ) Θ')\n (λ n k → interpE e2 ((interpR Θ Θ' , k) , n)) h)\n (interpR-lemma e Θ Θ') ⟩\n natrec (interpE (ren e1 Θ) Θ')\n (λ n k → interpE e2 ((interpR Θ Θ' , k) , n))\n (interpE (ren e Θ) Θ') =⟨ ap\n (λ h → \n natrec (interpE (ren e1 Θ) Θ') h (interpE (ren e Θ) Θ'))\n (λ=\n (λ x →\n λ=\n (λ y →\n ap (λ h → interpE e2 h) (interpR-lemma-lemma-rec x y Θ Θ')))) ⟩\n natrec (interpE (ren e1 Θ) Θ')\n (λ n k → interpE e2 (interpR (lem1 (lem1 Θ)) ((Θ' , k) , n)))\n (interpE (ren e Θ) Θ') =⟨ ap \n (λ h → \n natrec (interpE (ren e1 Θ) Θ') h (interpE (ren e Θ) Θ'))\n (λ=\n (λ x →\n λ=\n (λ y →\n interpR-lemma {nat :: τ :: Γ} {nat :: τ :: Γ'} e2 (lem1 (lem1 Θ))\n ((Θ' , y) , x)))) ⟩\n natrec (interpE (ren e1 Θ) Θ')\n (λ n k → interpE (ren e2 (lem1 (lem1 Θ))) ((Θ' , k) , n))\n (interpE (ren e Θ) Θ') ∎\n\n interpR-lemma {Γ} {Γ'} {ρ ⇒ τ} (lam e) Θ Θ' = interpE (lam e) (interpR Θ Θ') =⟨ Refl ⟩\n (λ x → interpE e (interpR Θ Θ' , x)) =⟨ λ= (λ x → ap (λ h → interpE e h) (interpR-lemma-lemma x Θ Θ')) ⟩\n (λ x → interpE e (interpR (lem1 Θ) (Θ' , x))) =⟨ λ= (λ x → interpR-lemma {ρ :: Γ} {ρ :: Γ'} e (lem1 Θ) (Θ' , x)) ⟩\n ((λ x → interpE (ren e (lem1 Θ)) (Θ' , x)) ∎)\n \n interpR-lemma (app e1 e2) Θ Θ' = interpE (app e1 e2) (interpR Θ Θ') =⟨ Refl ⟩\n interpE e1 (interpR Θ Θ') (interpE e2 (interpR Θ Θ')) =⟨ ap (λ x → x (interpE e2 (interpR Θ Θ'))) (interpR-lemma e1 Θ Θ') ⟩\n interpE (ren e1 Θ) Θ' (interpE e2 (interpR Θ Θ')) =⟨ ap (λ x → interpE (ren e1 Θ) Θ' x) (interpR-lemma e2 Θ Θ') ⟩\n interpE (ren e1 Θ) Θ' (interpE (ren e2 Θ) Θ') ∎\n\n -- no proof is possible without the genius of Dan Licata\n mutual\n wkn-lemma : ∀ {Γ τ} (a : interp τ) → (Θ' : interpC Γ) → Θ' == interpR iS (Θ' , a)\n wkn-lemma a Θ' = interpR-lemma-lemma-lemma a (λ x → x) Θ' ∘ ! (mutual-lemma Θ')\n\n mutual-lemma : ∀ {Γ} (Θ' : interpC Γ) → interpR (λ x → x) Θ' == Θ'\n mutual-lemma {[]} Θ' = Refl\n mutual-lemma {A :: Γ} (Θ' , a) = ! (ap (λ h → h , a) (wkn-lemma a Θ'))\n\n interp-lemma2 : ∀ {Γ τ' Θ' τ} (a : interp τ) → (e : Γ |- τ') → interpE e Θ' == interpE (wkn e) (Θ' , a)\n interp-lemma2 {Γ} {τ'} {Θ'} a e = interpE e Θ' =⟨ ap (λ x → interpE e x) (wkn-lemma a Θ') ⟩\n interpE e (interpR iS (Θ' , a)) =⟨ interpR-lemma e iS (Θ' , a) ⟩\n interpE (ren e iS) (Θ' , a) ∎\n\n interp-lemma : ∀ {Γ Γ' Θ' τ} (a : interp τ) → (Θ : sctx Γ Γ') → interpS Θ Θ' == interpS (wkn-s Θ) (Θ' , a)\n interp-lemma {Γ} {[]} a Θ = Refl\n interp-lemma {Γ} {A :: Γ'} a Θ = ap2 (λ x y → x , y) (interp-lemma a (helper Θ)) (interp-lemma2 a (Θ i0))\n\n lemma : ∀ {Γ Γ' Θ' τ} (x : interp τ) → (Θ : sctx Γ Γ') → ((interpS Θ Θ') , x) == (interpS (lem2 Θ) (Θ' , x))\n lemma x Θ = ap (λ y → y , x) (interp-lemma x Θ)\n\n lemma-c-lemma-lemma : ∀ {Γ Γ' τ} → (x : interp τ) → (Θ : sctx Γ Γ') → (Θ' : interpC Γ) → (interpS Θ Θ') == (interpS (wkn-s Θ) (Θ' , x))\n lemma-c-lemma-lemma {Γ} {[]} x Θ Θ' = Refl\n lemma-c-lemma-lemma {Γ} {A :: Γ'} x Θ Θ' = ap2 (λ x₁ y → x₁ , y) (lemma-c-lemma-lemma x (helper Θ) Θ') (interp-lemma2 x (Θ i0))\n\n lemma-c-lemma : ∀ {Γ Γ' τ} → (x : interp τ) → (Θ : sctx Γ Γ') → (Θ' : interpC Γ) → (interpS Θ Θ' , x) == (interpS (lem2 Θ) (Θ' , x))\n lemma-c-lemma {Γ} {[]} x Θ Θ' = Refl\n lemma-c-lemma {Γ} {A :: Γ'} x Θ Θ' = ap (λ h → h , x) (lemma-c-lemma-lemma x Θ Θ')\n\n lemma-c-lemma-rec : ∀ {Γ Γ' τ} → (x : interp nat) → (y : interp τ) → (Θ : sctx Γ Γ') → (Θ' : interpC Γ)\n → ((interpS Θ Θ' , y) , x) == interpS (lem2 (lem2 Θ)) ((Θ' , y) , x)\n lemma-c-lemma-rec {Γ} {[]} x y Θ Θ' = Refl\n lemma-c-lemma-rec {Γ} {A :: Γ'} x y Θ Θ' = lemma-c-lemma x (lem2 Θ) (Θ' , y) ∘ ap (λ h → h , x) (lemma-c-lemma y Θ Θ')\n\n lemma-c : ∀ {Γ Γ' τ} (e : Γ' |- τ) → (Θ : sctx Γ Γ') → (Θ' : interpC Γ) → (interpE e) (interpS Θ Θ') == (interpE (subst Θ e)) Θ'\n lemma-c (var i0) b c = Refl\n lemma-c (var (iS x)) b c = lemma-c (var x) (helper b) c\n lemma-c z b c = Refl\n lemma-c (suc e) b c = ap S (lemma-c e b c)\n lemma-c {Γ} {Γ'} {τ} (rec e e0 e1) b c = natrec (interpE e0 (interpS b c))\n (λ n k → interpE e1 ((interpS b c , k) , n))\n (interpE e (interpS b c))\n =⟨ ap\n (λ h →\n natrec h (λ n k → interpE e1 ((interpS b c , k) , n))\n (interpE e (interpS b c)))\n (lemma-c e0 b c) ⟩\n natrec (interpE (subst b e0) c)\n (λ n k → interpE e1 ((interpS b c , k) , n))\n (interpE e (interpS b c))\n =⟨ ap\n (λ h →\n natrec (interpE (subst b e0) c)\n (λ n k → interpE e1 ((interpS b c , k) , n)) h)\n (lemma-c e b c) ⟩\n natrec (interpE (subst b e0) c)\n (λ n k → interpE e1 ((interpS b c , k) , n))\n (interpE (subst b e) c) =⟨ ap\n (λ h → natrec (interpE (subst b e0) c) h (interpE (subst b e) c))\n (λ= (λ x →\n λ= (λ y →\n ap (λ h → interpE e1 h) (lemma-c-lemma-rec x y b c)))) ⟩\n natrec (interpE (subst b e0) c)\n (λ n k → interpE e1 (interpS (lem2 (lem2 b)) ((c , k) , n)))\n (interpE (subst b e) c) =⟨ ap\n (λ h → natrec (interpE (subst b e0) c) h (interpE (subst b e) c)) \n (λ= (λ x → \n λ= (λ y → lemma-c {nat :: τ :: Γ} {nat :: τ :: Γ'} e1 (lem2 (lem2 b)) ((c , y) , x)))) ⟩\n natrec (interpE (subst b e0) c)\n (λ n k → interpE (subst (lem2 (lem2 b)) e1) ((c , k) , n))\n (interpE (subst b e) c)\n ∎\n\n lemma-c {Γ} {Γ'} {ρ ⇒ τ} (lam e) b c = interpE (lam e) (interpS b c) =⟨ Refl ⟩\n (λ x → interpE e (interpS b c , x)) =⟨ λ= (λ x → ap (λ h → interpE e h) (lemma-c-lemma x b c)) ⟩\n (λ x → interpE e (interpS (lem2 b) (c , x))) =⟨ λ= (λ x → lemma-c {ρ :: Γ} {ρ :: Γ'} e (lem2 b) (c , x)) ⟩\n (λ x → interpE (subst (lem2 b) e) (c , x)) ∎\n lemma-c (app e1 e2) b c = interpE (app e1 e2) (interpS b c) =⟨ Refl ⟩\n interpE e1 (interpS b c) (interpE e2 (interpS b c)) =⟨ ap (λ f → f (interpE e2 (interpS b c))) (lemma-c e1 b c) ⟩\n interpE (subst b e1) c (interpE e2 (interpS b c)) =⟨ ap (λ f → interpE (subst b e1) c f) (lemma-c e2 b c) ⟩\n interpE (subst b e1) c (interpE (subst b e2) c) ∎\n\n -- Soundness: if e >> e' then interp e == interp e'\n sound : ∀ {τ} (e e' : [] |- τ) → e >> e' → (interpE e <>) == (interpE e' <>)\n sound (var x) d ()\n sound z d ()\n sound (suc e) .(suc e') (suc-steps .e e' p) = ap S (sound e e' p)\n sound (rec e e0 e1) .(rec e' e0 e1) (rec-steps .e e' .e0 .e1 p) = ap (natrec (interpE e0 <>) (λ n k → interpE e1 ((<> , k) , n))) (sound e e' p)\n sound (rec .z .d e1) d (rec-steps-z e .d .e1) = Refl\n sound (rec .(suc e) e0 e1) .(subst (lem4 e (rec e e0 e1)) e1) (rec-steps-suc e .e0 .e1 x) = lemma-c e1 (lem4 e (rec e e0 e1)) <>\n sound (lam x) d ()\n sound (app e1 e2) .(app e1' e2) (app-steps .e1 e1' .e2 p) = ap (λ d → d (interpE e2 <>)) (sound e1 e1' p)\n sound (app e1 e2) .(app e1 e2') (app-steps-2 .e1 .e2 e2' x p) = ap (λ d → interpE e1 <> d) (sound e2 e2' p)\n sound (app .(lam e1) e2) .(subst (lem3 e2) e1) (app-steps-3 e1 .e2) = lemma-c e1 (lem3 e2) <>\n", "meta": {"hexsha": "9904a90c1f2f61a8c52818232ab70dbba1b373d1", "size": 21250, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "old/Godel.agda", "max_stars_repo_name": "benhuds/Agda", "max_stars_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-04-26T20:22:22.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-08T12:27:18.000Z", "max_issues_repo_path": "ug/Godel.agda", "max_issues_repo_name": "benhuds/Agda", "max_issues_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-03-23T08:39:04.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-12T00:32:45.000Z", "max_forks_repo_path": "ug/Godel.agda", "max_forks_repo_name": "benhuds/Agda", "max_forks_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.9340101523, "max_line_length": 175, "alphanum_fraction": 0.3663058824, "num_tokens": 7079, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289387998695209, "lm_q2_score": 0.7718435030872968, "lm_q1q2_score": 0.6398110271362706}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Relations between properties of scaling and other operations\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Algebra.Module.Consequences where\n\nopen import Algebra.Core using (Op₂; Opₗ; Opᵣ)\nimport Algebra.Definitions as Defs\nopen import Algebra.Module.Definitions\nopen import Function.Base using (flip)\nopen import Level using (Level)\nopen import Relation.Binary using (Rel; Setoid)\nimport Relation.Binary.Reasoning.Setoid as Rea\n\nprivate\n variable\n a b c ℓ ℓa : Level\n A : Set a\n B : Set b\n\nmodule _ (_≈ᴬ_ : Rel {a} A ℓa) (S : Setoid c ℓ) where\n\n open Setoid S\n open Rea S\n open Defs _≈ᴬ_\n\n private\n module L = LeftDefs A _≈_\n module R = RightDefs A _≈_\n module B = BiDefs A A _≈_\n\n module _ {_*_ : Op₂ A} {_*ₗ_ : Opₗ A Carrier} where\n\n private\n _*ᵣ_ = flip _*ₗ_\n\n *ₗ-assoc+comm⇒*ᵣ-assoc :\n L.RightCongruent _≈ᴬ_ _*ₗ_ →\n L.Associative _*_ _*ₗ_ → Commutative _*_ → R.Associative _*_ _*ᵣ_\n *ₗ-assoc+comm⇒*ᵣ-assoc *ₗ-congʳ *ₗ-assoc *-comm m x y = begin\n (m *ᵣ x) *ᵣ y ≈⟨ refl ⟩\n y *ₗ (x *ₗ m) ≈˘⟨ *ₗ-assoc _ _ _ ⟩\n (y * x) *ₗ m ≈⟨ *ₗ-congʳ (*-comm y x) ⟩\n (x * y) *ₗ m ≈⟨ refl ⟩\n m *ᵣ (x * y) ∎\n\n *ₗ-assoc+comm⇒*ₗ-*ᵣ-assoc :\n L.RightCongruent _≈ᴬ_ _*ₗ_ →\n L.Associative _*_ _*ₗ_ → Commutative _*_ → B.Associative _*ₗ_ _*ᵣ_\n *ₗ-assoc+comm⇒*ₗ-*ᵣ-assoc *ₗ-congʳ *ₗ-assoc *-comm x m y = begin\n ((x *ₗ m) *ᵣ y) ≈⟨ refl ⟩\n (y *ₗ (x *ₗ m)) ≈˘⟨ *ₗ-assoc _ _ _ ⟩\n ((y * x) *ₗ m) ≈⟨ *ₗ-congʳ (*-comm y x) ⟩\n ((x * y) *ₗ m) ≈⟨ *ₗ-assoc _ _ _ ⟩\n (x *ₗ (y *ₗ m)) ≈⟨ refl ⟩\n (x *ₗ (m *ᵣ y)) ∎\n\n module _ {_*_ : Op₂ A} {_*ᵣ_ : Opᵣ A Carrier} where\n\n private\n _*ₗ_ = flip _*ᵣ_\n\n *ᵣ-assoc+comm⇒*ₗ-assoc :\n R.LeftCongruent _≈ᴬ_ _*ᵣ_ →\n R.Associative _*_ _*ᵣ_ → Commutative _*_ → L.Associative _*_ _*ₗ_\n *ᵣ-assoc+comm⇒*ₗ-assoc *ᵣ-congˡ *ᵣ-assoc *-comm x y m = begin\n ((x * y) *ₗ m) ≈⟨ refl ⟩\n (m *ᵣ (x * y)) ≈⟨ *ᵣ-congˡ (*-comm x y) ⟩\n (m *ᵣ (y * x)) ≈˘⟨ *ᵣ-assoc _ _ _ ⟩\n ((m *ᵣ y) *ᵣ x) ≈⟨ refl ⟩\n (x *ₗ (y *ₗ m)) ∎\n\n *ᵣ-assoc+comm⇒*ₗ-*ᵣ-assoc :\n R.LeftCongruent _≈ᴬ_ _*ᵣ_ →\n R.Associative _*_ _*ᵣ_ → Commutative _*_ → B.Associative _*ₗ_ _*ᵣ_\n *ᵣ-assoc+comm⇒*ₗ-*ᵣ-assoc *ᵣ-congˡ *ᵣ-assoc *-comm x m y = begin\n ((x *ₗ m) *ᵣ y) ≈⟨ refl ⟩\n ((m *ᵣ x) *ᵣ y) ≈⟨ *ᵣ-assoc _ _ _ ⟩\n (m *ᵣ (x * y)) ≈⟨ *ᵣ-congˡ (*-comm x y) ⟩\n (m *ᵣ (y * x)) ≈˘⟨ *ᵣ-assoc _ _ _ ⟩\n ((m *ᵣ y) *ᵣ x) ≈⟨ refl ⟩\n (x *ₗ (m *ᵣ y)) ∎\n", "meta": {"hexsha": "f4b581c5297b91edfa64ed8551b11b76c6e754b9", "size": 2705, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Algebra/Module/Consequences.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Algebra/Module/Consequences.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Algebra/Module/Consequences.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 31.091954023, "max_line_length": 72, "alphanum_fraction": 0.5001848429, "num_tokens": 1329, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289388083214156, "lm_q2_score": 0.7718434925908524, "lm_q1q2_score": 0.6398110249589006}} {"text": "module Relator.Equals.Proofs where\n\nimport Lvl\nopen import Functional as Fn using (_→ᶠ_ ; _∘_)\nopen import Logic\nopen import Logic.Propositional\nopen import Logic.Propositional.Theorems\nopen import Logic.Propositional.Proofs.Structures\nopen import Relator.Equals\nopen import Relator.Equals.Proofs.Equiv public\nopen import Structure.Function.Names\nopen import Structure.Relator.Properties\nopen import Structure.Setoid using (Equiv ; intro) renaming (_≡_ to _≡ₛ_)\nopen import Structure.Type.Identity\nopen import Syntax.Function\nopen import Type\n\nprivate variable ℓ ℓ₁ ℓ₂ ℓₑ₁ ℓₑ₂ ℓₑ ℓₚ : Lvl.Level\nprivate variable T A B : Type{ℓ}\nprivate variable x y : T\n\n[≡]-coercion : (_≡_ {T = Type{ℓ}}) ⊆₂ (_→ᶠ_)\n[≡]-coercion = [≡]-sub-of-reflexive\n\n[≡]-unsubstitution : (∀{f : T → Stmt} → f(x) → f(y)) → (x ≡ y)\n[≡]-unsubstitution {x = x} F = F {x ≡_} [≡]-intro\n\n-- The statement that two functions are equal when all their values are equal are not provable.\n-- Also called: Extensional equality, function extensionality.\n-- [≡]-function : ∀{A B : Type}{f₁ f₂ : A → B) → (∀{x} → (f₁(x) ≡ f₂(x))) → (f₁ ≡ f₂)\n\n[≡]-function-application : FunctionApplication A B\n[≡]-function-application [≡]-intro = [≡]-intro\n\n[≡]-with-specific : ∀{x y : A} → (f : (a : A) → ⦃ _ : (a ≡ x) ⦄ → ⦃ _ : (a ≡ y) ⦄ → B) → (p : (x ≡ y)) → (f(x) ⦃ [≡]-intro ⦄ ⦃ p ⦄ ≡ f(y) ⦃ symmetry(_≡_) p ⦄ ⦃ [≡]-intro ⦄)\n[≡]-with-specific f [≡]-intro = [≡]-intro\n", "meta": {"hexsha": "9637f02000b9908b0e166f344ffb7103d25cd26d", "size": 1415, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Relator/Equals/Proofs.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Relator/Equals/Proofs.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Relator/Equals/Proofs.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.2432432432, "max_line_length": 172, "alphanum_fraction": 0.6551236749, "num_tokens": 537, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8289388040954683, "lm_q2_score": 0.7718434873426302, "lm_q1q2_score": 0.6398110173466756}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Setoids.Setoids\nopen import Functions.Definition\nopen import Groups.Definition\nopen import Sets.EquivalenceRelations\nopen import Groups.Isomorphisms.Definition\nopen import Groups.Homomorphisms.Definition\nopen import Groups.Homomorphisms.Lemmas\n\nmodule Groups.Isomorphisms.Lemmas where\n\ngroupIsosCompose : {m n o r s t : _} {A : Set m} {S : Setoid {m} {r} A} {_+A_ : A → A → A} {B : Set n} {T : Setoid {n} {s} B} {_+B_ : B → B → B} {C : Set o} {U : Setoid {o} {t} C} {_+C_ : C → C → C} {G : Group S _+A_} {H : Group T _+B_} {I : Group U _+C_} {f : A → B} {g : B → C} (fHom : GroupIso G H f) (gHom : GroupIso H I g) → GroupIso G I (g ∘ f)\nGroupIso.groupHom (groupIsosCompose fHom gHom) = groupHomsCompose (GroupIso.groupHom fHom) (GroupIso.groupHom gHom)\nGroupIso.bij (groupIsosCompose {A = A} {S = S} {T = T} {C = C} {U = U} {f = f} {g = g} fHom gHom) = record { inj = record { injective = λ pr → (SetoidInjection.injective (SetoidBijection.inj (GroupIso.bij fHom))) (SetoidInjection.injective (SetoidBijection.inj (GroupIso.bij gHom)) pr) ; wellDefined = +WellDefined } ; surj = record { surjective = surj ; wellDefined = +WellDefined } }\n where\n open Setoid S renaming (_∼_ to _∼A_)\n open Setoid U renaming (_∼_ to _∼C_)\n +WellDefined : {x y : A} → (x ∼A y) → (g (f x) ∼C g (f y))\n +WellDefined = GroupHom.wellDefined (groupHomsCompose (GroupIso.groupHom fHom) (GroupIso.groupHom gHom))\n surj : {x : C} → Sg A (λ a → (g (f a) ∼C x))\n surj {x} with SetoidSurjection.surjective (SetoidBijection.surj (GroupIso.bij gHom)) {x}\n surj {x} | a , prA with SetoidSurjection.surjective (SetoidBijection.surj (GroupIso.bij fHom)) {a}\n ... | b , prB = b , transitive (GroupHom.wellDefined (GroupIso.groupHom gHom) prB) prA\n where\n open Equivalence (Setoid.eq U)\n\n--groupIsoInvertible : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d}} {_+A_ : A → A → A} {_+B_ : B → B → B} {G : Group S _+A_} {H : Group T _+B_} {f : A → B} → (iso : GroupIso G H f) → GroupIso H G (Invertible.inverse (bijectionImpliesInvertible (GroupIso.bijective iso)))\n--GroupHom.groupHom (GroupIso.groupHom (groupIsoInvertible {G = G} {H} {f} iso)) {x} {y} = {!!}\n-- where\n-- open Group G renaming (_·_ to _+G_)\n-- open Group H renaming (_·_ to _+H_)\n--GroupHom.wellDefined (GroupIso.groupHom (groupIsoInvertible {G = G} {H} {f} iso)) {x} {y} x∼y = {!GroupHom.wellDefined x∼y!}\n--GroupIso.bijective (groupIsoInvertible {G = G} {H} {f} iso) = invertibleImpliesBijection (inverseIsInvertible (bijectionImpliesInvertible (GroupIso.bijective iso)))\n", "meta": {"hexsha": "e7e0197c1e81dd6215ca855a74e907611844cd85", "size": 2673, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Groups/Isomorphisms/Lemmas.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Groups/Isomorphisms/Lemmas.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Groups/Isomorphisms/Lemmas.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 74.25, "max_line_length": 385, "alphanum_fraction": 0.657687991, "num_tokens": 997, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289387914176259, "lm_q2_score": 0.7718434978390747, "lm_q1q2_score": 0.6398110162622755}} {"text": "module MLib.Prelude.RelProps where\n\nopen import MLib.Prelude.FromStdlib\n\nimport Relation.Binary.Indexed as I\nopen FE using (cong)\nimport Data.Product.Relation.SigmaPropositional as OverΣ\n\nΣ-bij : ∀ {a b c} {A : Set a} {B : A → Set b} {C : A → Set c} → (∀ x → B x ↔ C x) → Σ A B ↔ Σ A C\nΣ-bij pw = record\n { to = ≡.→-to-⟶ (uncurry λ x y → x , Inverse.to (pw x) ⟨$⟩ y)\n ; from = ≡.→-to-⟶ (uncurry λ x y → x , Inverse.from (pw x) ⟨$⟩ y)\n ; inverse-of = record\n { left-inverse-of = uncurry λ x y → OverΣ.to-≡ (≡.refl , Inverse.left-inverse-of (pw x) y)\n ; right-inverse-of = uncurry λ x y → OverΣ.to-≡ (≡.refl , Inverse.right-inverse-of (pw x) y)\n }\n }\n\n\nΣ-↞ : ∀ {a b c} {A : Set a} {B : A → Set b} {C : A → Set c} → (∀ x → B x ↞ C x) → Σ A B ↞ Σ A C\nΣ-↞ f = record\n { to = ≡.→-to-⟶ (uncurry λ x y → x , LeftInverse.to (f x) ⟨$⟩ y)\n ; from = ≡.→-to-⟶ (uncurry λ x y → x , LeftInverse.from (f x) ⟨$⟩ y)\n ; left-inverse-of = uncurry λ x y → OverΣ.to-≡ (≡.refl , LeftInverse.left-inverse-of (f x) y)\n }\n\n\nΣ-↞′ :\n ∀ {a a′ b β} {A : Set a} {A′ : Set a′} {B-setoid : A → Setoid b β} (f : A ↞ A′)\n → LeftInverse (OverΣ.setoid B-setoid) (OverΣ.setoid (B-setoid ∘ (LeftInverse.from f ⟨$⟩_)))\nΣ-↞′ {A = A} {A′} {B-setoid} f = record\n { to = record\n { _⟨$⟩_ = uncurry λ x y → LeftInverse.to f ⟨$⟩ x , ≡.subst B (≡.sym (LeftInverse.left-inverse-of f _)) y\n ; cong = uncurry λ {≡.refl y → ≡.refl , subst≈ _ _ (≡.sym (LeftInverse.left-inverse-of f _)) y}\n }\n ; from = record\n { _⟨$⟩_ = uncurry λ x y → LeftInverse.from f ⟨$⟩ x , y\n ; cong = λ { (≡.refl , q) → ≡.refl , q }\n }\n ; left-inverse-of = uncurry λ x y → OverΣ.symmetric sym (OverΣ.subst (≡.sym (LeftInverse.left-inverse-of f _)) refl)\n }\n where\n module B x = Setoid (B-setoid x)\n module B′ {x} = Setoid (B-setoid x)\n open B using () renaming (Carrier to B)\n open B′\n\n subst≈ : ∀ {i j} (x y : B i) (p : i ≡ j) → x ≈ y → ≡.subst B p x ≈ ≡.subst B p y\n subst≈ x y ≡.refl q = q\n", "meta": {"hexsha": "6209fecb1c83bcdc3ebcf0eeac237ade0ae7417b", "size": 1975, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/MLib/Prelude/RelProps.agda", "max_stars_repo_name": "bch29/agda-matrices", "max_stars_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/MLib/Prelude/RelProps.agda", "max_issues_repo_name": "bch29/agda-matrices", "max_issues_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/MLib/Prelude/RelProps.agda", "max_forks_repo_name": "bch29/agda-matrices", "max_forks_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.5, "max_line_length": 118, "alphanum_fraction": 0.5432911392, "num_tokens": 862, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8902942261220292, "lm_q2_score": 0.7185944046238981, "lm_q1q2_score": 0.6397604493602538}} {"text": "module Base.Isomorphism where\n\nopen import Relation.Binary.PropositionalEquality using (_≡_)\n\n-- The stdlib contains `Function.Inverse`, which seems to have a similar purpose, but is more complicated.\n\ninfix 0 _≃_\nrecord _≃_ (A B : Set) : Set where\n field\n to : A → B\n from : B → A\n from∘to : ∀ (x : A) → from (to x) ≡ x\n to∘from : ∀ (y : B) → to (from y) ≡ y\nopen _≃_\n", "meta": {"hexsha": "ae646cc65749e0a242fa4ad46806e81a175f588c", "size": 384, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "base/agda/Base/Isomorphism.agda", "max_stars_repo_name": "FreeProving/free-compiler", "max_stars_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2020-02-06T11:03:34.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-21T13:38:23.000Z", "max_issues_repo_path": "base/agda/Base/Isomorphism.agda", "max_issues_repo_name": "FreeProving/free-compiler", "max_issues_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 120, "max_issues_repo_issues_event_min_datetime": "2020-04-09T09:40:39.000Z", "max_issues_repo_issues_event_max_datetime": "2020-12-08T07:46:01.000Z", "max_forks_repo_path": "base/agda/Base/Isomorphism.agda", "max_forks_repo_name": "FreeProving/free-compiler", "max_forks_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-04-08T11:23:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-14T07:48:41.000Z", "avg_line_length": 25.6, "max_line_length": 106, "alphanum_fraction": 0.6328125, "num_tokens": 134, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8902942377652497, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.639760441630876}} {"text": "------------------------------------------------------------------------------\n-- Common stuff used by the gcd example\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule LTC-PCF.Program.GCD.Partial.Definitions where\n\nopen import LTC-PCF.Base\nopen import LTC-PCF.Data.Nat.Divisibility.NotBy0\nopen import LTC-PCF.Data.Nat.Inequalities\nopen import LTC-PCF.Data.Nat.Type\n\n------------------------------------------------------------------------------\n-- Common divisor.\nCD : D → D → D → Set\nCD m n cd = cd ∣ m ∧ cd ∣ n\n\n-- Divisible for any common divisor.\nDivisible : D → D → D → Set\nDivisible m n gcd = ∀ cd → N cd → CD m n cd → cd ∣ gcd\n\n-- Greatest that any common divisor.\nGACD : D → D → D → Set\nGACD m n gcd = ∀ cd → N cd → CD m n cd → cd ≤ gcd\n\n-- Greatest common divisor specification.\ngcdSpec : D → D → D → Set\ngcdSpec m n gcd = CD m n gcd ∧ GACD m n gcd\n\nx≢0≢y : D → D → Set\nx≢0≢y m n = ¬ (m ≡ zero ∧ n ≡ zero)\n", "meta": {"hexsha": "d2034c48f81a3ea8c08c4fd122bbb0b12c33577f", "size": 1126, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/LTC-PCF/Program/GCD/Partial/Definitions.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/LTC-PCF/Program/GCD/Partial/Definitions.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/LTC-PCF/Program/GCD/Partial/Definitions.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 31.2777777778, "max_line_length": 78, "alphanum_fraction": 0.4840142096, "num_tokens": 292, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8902942348544448, "lm_q2_score": 0.7185943805178139, "lm_q1q2_score": 0.6397604341738109}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule Types where\n\nimport Level\nopen import Data.Empty\nopen import Data.Unit\nopen import Data.Sum\nopen import Data.Product\nopen import Relation.Binary\n\n--\n\ndata U : Set where\n ZERO : U\n ONE : U\n PLUS : U → U → U\n TIMES : U → U → U\n\n⟦_⟧ : U → Set \n⟦ ZERO ⟧ = ⊥ \n⟦ ONE ⟧ = ⊤\n⟦ PLUS t₁ t₂ ⟧ = ⟦ t₁ ⟧ ⊎ ⟦ t₂ ⟧\n⟦ TIMES t₁ t₂ ⟧ = ⟦ t₁ ⟧ × ⟦ t₂ ⟧\n\nU∼ : U → Set₁\nU∼ u = Rel ⟦ u ⟧ (Level.zero)\n\nrecord Typ : Set₁ where\n field \n carr : U\n auto : U∼ carr\n\nBOOL : U\nBOOL = PLUS ONE ONE\n\nFALSE TRUE : ⟦ BOOL ⟧\nFALSE = inj₁ tt\nTRUE = inj₂ tt\n\ndata ONE∼ : U∼ ONE where\n id : ONE∼ tt tt\n\ndata BOOL∼ : U∼ BOOL where\n idff : BOOL∼ FALSE FALSE\n idft : BOOL∼ FALSE TRUE\n idtf : BOOL∼ TRUE FALSE\n idtt : BOOL∼ TRUE TRUE\n\n--\n\n\n{--\nThen < Bool , ~* > is essentially < Unit , ~= >\n\nNow we need to define what it means to say < U1, ~1> + < U2, ~2 > etc.\nand then what it means for two types to be equivalent etc. etc. etc.\n--}\n", "meta": {"hexsha": "7ebaae9dd02bbb5afe8ab2a29386d487ebf46b9b", "size": 971, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Univalence/2D/Types.agda", "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_issues_repo_path": "Univalence/2D/Types.agda", "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_forks_repo_path": "Univalence/2D/Types.agda", "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "avg_line_length": 16.4576271186, "max_line_length": 70, "alphanum_fraction": 0.5726055613, "num_tokens": 372, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009549929797, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.6397485318757083}} {"text": "{-\n\nComputable stuff constructed from the Combinatorics of Finite Sets\n\n-}\n{-# OPTIONS --safe #-}\n\nmodule Cubical.Experiments.Combinatorics where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\n\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Nat.Order\nopen import Cubical.Data.Bool\nopen import Cubical.Data.Sum\nopen import Cubical.Data.Sigma\nopen import Cubical.Data.Vec\n\nopen import Cubical.Data.SumFin renaming (Fin to Fin')\nopen import Cubical.Data.FinSet.Base\nopen import Cubical.Data.FinSet.Properties\nopen import Cubical.Data.FinSet.Constructors\nopen import Cubical.Data.FinSet.Cardinality\nopen import Cubical.Data.FinSet.DecidablePredicate\nopen import Cubical.Data.FinSet.Quotients\n\nopen import Cubical.HITs.PropositionalTruncation\n\nopen import Cubical.Relation.Nullary\nopen import Cubical.Relation.Nullary.DecidablePropositions\n hiding (DecProp) renaming (DecProp' to DecProp)\nopen import Cubical.Relation.Binary\n\nopen import Cubical.Functions.Embedding\nopen import Cubical.Functions.Surjection\n\nprivate\n variable\n ℓ ℓ' ℓ'' : Level\n\n-- convenient renaming\n\nFin : ℕ → FinSet ℓ-zero\nFin n = _ , isFinSetFin {n = n}\n\n-- explicit numbers\n\ns2 : card (_ , isFinSet≃ (Fin 2) (Fin 2)) ≡ 2\ns2 = refl\n\ns3 : card (_ , isFinSet≃ (Fin 3) (Fin 3)) ≡ 6\ns3 = refl\n\na3,2 : card (_ , isFinSet↪ (Fin 2) (Fin 3)) ≡ 6\na3,2 = refl\n\n2^4 : card (_ , isFinSet→ (Fin 4) (Fin 2)) ≡ 16\n2^4 = refl\n\n-- construct numerical functions from list\ngetFun : {n : ℕ} → Vec ℕ n → Fin n .fst → ℕ\ngetFun {n = n} ns = fun n ns\n where\n fun : (n : ℕ) → Vec ℕ n → Fin' n → ℕ\n fun 0 _ _ = 0\n fun (suc m) (n ∷ ns) (inl tt) = n\n fun (suc m) (n ∷ ns) (inr x) = fun m ns x\n\n-- an example function\nf = getFun (3 ∷ 1 ∷ 4 ∷ 1 ∷ 5 ∷ 9 ∷ 2 ∷ 6 ∷ [])\n\n-- the total sum\ns : sum (Fin _) f ≡ 31\ns = refl\n\n-- the total product\np : prod (Fin _) f ≡ 6480\np = refl\n\n-- the maximal value\nm : maxValue (Fin _) f ∣ fzero ∣ ≡ 9\nm = refl\n\n-- the number of numeral 1\nn1 : card (_ , isFinSetFiberDisc (Fin _) ℕ discreteℕ f 1) ≡ 2\nn1 = refl\n\n-- a somewhat trivial equivalence relation making everything equivalent\nR : {n : ℕ} → Fin n .fst → Fin n .fst → Type\nR _ _ = Unit\n\nisDecR : {n : ℕ} → (x y : Fin n .fst) → isDecProp (R {n = n} x y)\nisDecR _ _ = true , idEquiv _\n\nopen BinaryRelation\nopen isEquivRel\n\nisEquivRelR : {n : ℕ} → isEquivRel (R {n = n})\nisEquivRelR {n = n} .reflexive _ = tt\nisEquivRelR {n = n} .symmetric _ _ tt = tt\nisEquivRelR {n = n} .transitive _ _ _ tt tt = tt\n\ncollapsed : (n : ℕ) → FinSet ℓ-zero\ncollapsed n = _ , isFinSetQuot (Fin n) R isEquivRelR isDecR\n\n-- this number should be 1\n≡1 : card (collapsed 2) ≡ 1\n≡1 = refl\n", "meta": {"hexsha": "ecf9ab7646bd4997dcc81ec2fd6b01f49dc86622", "size": 2641, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Experiments/Combinatorics.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_issues_repo_path": "Cubical/Experiments/Combinatorics.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Experiments/Combinatorics.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.0090909091, "max_line_length": 71, "alphanum_fraction": 0.6834532374, "num_tokens": 946, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127566694178, "lm_q2_score": 0.7490872131147275, "lm_q1q2_score": 0.6396551271366085}} {"text": "{-# OPTIONS --no-pattern-matching #-}\n\nid : {A : Set} (x : A) → A\nid x = x\n\nconst : {A B : Set} (x : A) (y : B) → A\nconst x y = x\n\nhapp : {A B C : Set} (f : A → B → C) (g : A → B) (x : A) → C\nhapp f g x = f x (g x)\n\nK = const\nS = happ\n\nI : {A : Set} (x : A) → A\nI = S K K\n\n-- Mmh, pretty boring...\n", "meta": {"hexsha": "904e68ac34e5b2e72b11f98b12587670dc48a28d", "size": 298, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/NoPatternMatching.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_issues_repo_path": "test/succeed/NoPatternMatching.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/NoPatternMatching.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 15.6842105263, "max_line_length": 60, "alphanum_fraction": 0.432885906, "num_tokens": 137, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8539127529517043, "lm_q2_score": 0.7490872075132152, "lm_q1q2_score": 0.6396551195685142}} {"text": "------------------------------------------------------------------------------\n-- The division program is correct\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- This module proves the correctness of the division program using\n-- repeated subtraction (Dybjer 1985).\n\nmodule FOTC.Program.Division.CorrectnessProofI where\n\nopen import FOTC.Base\nopen import FOTC.Data.Nat\nopen import FOTC.Data.Nat.Inequalities\nopen import FOTC.Data.Nat.Inequalities.PropertiesI\nopen import FOTC.Data.Nat.PropertiesI\n\nimport FOTC.Data.Nat.Induction.NonAcc.WF-I\nopen module WFInd = FOTC.Data.Nat.Induction.NonAcc.WF-I.WFInd\n\nopen import FOTC.Program.Division.Division\nopen import FOTC.Program.Division.ResultI\nopen import FOTC.Program.Division.Specification\nopen import FOTC.Program.Division.TotalityI\n\n------------------------------------------------------------------------------\n-- The division program is correct when the dividend is less than the\n-- divisor.\ndiv-x zero →\n i ≮ j →\n divSpec i j (div i j)\ndiv-x≮y-correct {i} {j} Ni Nj ah j>0 i≮j =\n div-x≮y-N ih i≮j , div-x≮y-resultCorrect Ni Nj ih i≮j\n\n where\n -- The inductive hypothesis on i ∸ j.\n ih : divSpec (i ∸ j) j (div (i ∸ j) j)\n ih = ah {i ∸ j}\n (∸-N Ni Nj)\n (x≥y→y>0→x∸y0)\n\n------------------------------------------------------------------------------\n-- The division program is correct.\n\n-- We do the well-founded induction on i and we keep j fixed.\ndivCorrect : ∀ {i j} → N i → N j → j > zero → divSpec i j (div i j)\ndivCorrect {j = j} Ni Nj j>0 = <-wfind A ih Ni\n where\n A : D → Set\n A d = divSpec d j (div d j)\n\n -- The inductive step doesn't use the variable i (nor Ni). To make\n -- this clear we write down the inductive step using the variables m\n -- and n.\n ih : ∀ {n} → N n → (∀ {m} → N m → m < n → A m) → A n\n ih {n} Nn ah =\n case (div-x0) (x; swap)\n\n zipWith : ∀ {a b c p q r s} {A : Set a} {B : Set b} {C : Set c} {P : A → Set p} {Q : B → Set q} {R : C → Set r} {S : (x : C) → R x → Set s} (_∙_ : A → B → C) → (_∘_ : ∀ {x y} → P x → Q y → R (x ∙ y)) → (_*_ : (x : C) → (y : R x) → S x y) → (x : Σ A P) → (y : Σ B Q) → S (proj₁ x ∙ proj₁ y) (proj₂ x ∘ proj₂ y)\n zipWith _∙_ _∘_ _*_ (a , p) (b , q) = (a ∙ b) * (p ∘ q)\n syntax zipWith f g h = f -< h >- g\n\n record Functor (C : Category o ℓ e) (D : Category o′ ℓ′ e′) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where\n eta-equality\n private module C = Category C\n private module D = Category D\n\n field\n F₀ : C.Obj → D.Obj\n F₁ : ∀ {A B} (f : C [ A , B ]) → D [ F₀ A , F₀ B ]\n\n Product : (C : Category o ℓ e) (D : Category o′ ℓ′ e′) → Category (o ⊔ o′) (ℓ ⊔ ℓ′) (e ⊔ e′)\n Product C D = record\n { Obj = C.Obj × D.Obj\n ; _⇒_ = C._⇒_ -< _×_ >- D._⇒_\n ; _≈_ = C._≈_ -< _×_ >- D._≈_\n ; _∘_ = zip C._∘_ D._∘_\n }\n where module C = Category C\n module D = Category D\n\n Bifunctor : Category o ℓ e → Category o′ ℓ′ e′ → Category o″ ℓ″ e″ → Set _\n Bifunctor C D E = Functor (Product C D) E\n\n private\n module CC = Category CC\n\n open CC\n\n infix 4 _≅_\n record _≅_ (A B : Obj) : Set (x₂) where\n field\n from : A ⇒ B\n to : B ⇒ A\n\n private\n variable\n X Y Z W : Obj\n f g h : X ⇒ Y\n\n record Monoidal : Set (x₁ ⊔ x₂ ⊔ x₃) where\n infixr 10 _⊗₀_ _⊗₁_\n\n field\n ⊗ : Bifunctor CC CC CC\n\n module ⊗ = Functor ⊗\n\n open Functor ⊗\n\n _⊗₀_ : Obj → Obj → Obj\n _⊗₀_ = curry′ F₀\n\n -- this is also 'curry', but a very-dependent version\n _⊗₁_ : X ⇒ Y → Z ⇒ W → X ⊗₀ Z ⇒ Y ⊗₀ W\n f ⊗₁ g = F₁ (f , g)\n\n field\n associator : (X ⊗₀ Y) ⊗₀ Z ≅ X ⊗₀ (Y ⊗₀ Z)\n\n module associator {X} {Y} {Z} = _≅_ (associator {X} {Y} {Z})\n\n -- for exporting, it makes sense to use the above long names, but for\n -- internal consumption, the traditional (short!) categorical names are more\n -- convenient. However, they are not symmetric, even though the concepts are, so\n -- we'll use ⇒ and ⇐ arrows to indicate that\n private\n α⇒ = associator.from\n α⇐ = λ {X} {Y} {Z} → associator.to {X} {Y} {Z}\n\n field\n assoc-commute-from : CommutativeSquare ((f ⊗₁ g) ⊗₁ h) α⇒ α⇒ (f ⊗₁ (g ⊗₁ h))\n assoc-commute-to : CommutativeSquare (f ⊗₁ (g ⊗₁ h)) α⇐ α⇐ ((f ⊗₁ g) ⊗₁ h)\n", "meta": {"hexsha": "18e948affb321af2fda685b7f446991e06a725a6", "size": 3206, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/LibSucceed/Issue4312.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-05-20T13:58:52.000Z", "max_stars_repo_stars_event_max_datetime": "2016-05-20T13:58:52.000Z", "max_issues_repo_path": "test/LibSucceed/Issue4312.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_forks_repo_path": "test/LibSucceed/Issue4312.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-18T13:34:07.000Z", "avg_line_length": 29.4128440367, "max_line_length": 311, "alphanum_fraction": 0.498128509, "num_tokens": 1401, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278726384089, "lm_q2_score": 0.7248702880639791, "lm_q1q2_score": 0.6396457462350877}} {"text": "------------------------------------------------------------------------\n-- A bunch of properties\n------------------------------------------------------------------------\n\nmodule Data.Bool.Properties where\n\nopen import Data.Bool as Bool\nopen import Data.Fin\nopen import Data.Function\nopen import Algebra\nopen import Algebra.Structures\nimport Algebra.RingSolver.Simple as Solver\nimport Algebra.RingSolver.AlmostCommutativeRing as ACR\nopen import Relation.Nullary using (_⇔_)\nopen import Relation.Binary.PropositionalEquality\nimport Algebra.FunctionProperties as P; open P _≡_\nopen import Data.Product\nopen import Data.Sum\nopen import Data.Empty\n\nimport Relation.Binary.EqReasoning as EqR; open EqR Bool.setoid\n\n------------------------------------------------------------------------\n-- Duality\n\n-- Can we take advantage of duality in some (nice) way?\n\n------------------------------------------------------------------------\n-- (Bool, ∨, ∧, false, true) forms a commutative semiring\n\nprivate\n\n ∨-assoc : Associative _∨_\n ∨-assoc true y z = refl\n ∨-assoc false y z = refl\n\n ∧-assoc : Associative _∧_\n ∧-assoc true y z = refl\n ∧-assoc false y z = refl\n\n ∨-comm : Commutative _∨_\n ∨-comm true true = refl\n ∨-comm true false = refl\n ∨-comm false true = refl\n ∨-comm false false = refl\n\n ∧-comm : Commutative _∧_\n ∧-comm true true = refl\n ∧-comm true false = refl\n ∧-comm false true = refl\n ∧-comm false false = refl\n\n ∨-identity : Identity false _∨_\n ∨-identity = (λ _ → refl) , (λ x → ∨-comm x false)\n\n ∧-identity : Identity true _∧_\n ∧-identity = (λ _ → refl) , (λ x → ∧-comm x true)\n\n zero-∧ : Zero false _∧_\n zero-∧ = (λ _ → refl) , (λ x → ∧-comm x false)\n\n distrib-∧-∨ : _∧_ DistributesOver _∨_\n distrib-∧-∨ = distˡ , distʳ\n where\n distˡ : _∧_ DistributesOverˡ _∨_\n distˡ true y z = refl\n distˡ false y z = refl\n\n distʳ : _∧_ DistributesOverʳ _∨_\n distʳ x y z =\n begin\n (y ∨ z) ∧ x\n ≈⟨ ∧-comm (y ∨ z) x ⟩\n x ∧ (y ∨ z)\n ≈⟨ distˡ x y z ⟩\n x ∧ y ∨ x ∧ z\n ≈⟨ cong₂ _∨_ (∧-comm x y) (∧-comm x z) ⟩\n y ∧ x ∨ z ∧ x\n ∎\n\nisCommutativeSemiring-∨-∧\n : IsCommutativeSemiring _≡_ _∨_ _∧_ false true\nisCommutativeSemiring-∨-∧ = record\n { isSemiring = record\n { isSemiringWithoutAnnihilatingZero = record\n { +-isCommutativeMonoid = record\n { isMonoid = record\n { isSemigroup = record\n { isEquivalence = isEquivalence\n ; assoc = ∨-assoc\n ; ∙-pres-≈ = cong₂ _∨_\n }\n ; identity = ∨-identity\n }\n ; comm = ∨-comm\n }\n ; *-isMonoid = record\n { isSemigroup = record\n { isEquivalence = isEquivalence\n ; assoc = ∧-assoc\n ; ∙-pres-≈ = cong₂ _∧_\n }\n ; identity = ∧-identity\n }\n ; distrib = distrib-∧-∨\n }\n ; zero = zero-∧\n }\n ; *-comm = ∧-comm\n }\n\ncommutativeSemiring-∨-∧ : CommutativeSemiring\ncommutativeSemiring-∨-∧ = record\n { _+_ = _∨_\n ; _*_ = _∧_\n ; 0# = false\n ; 1# = true\n ; isCommutativeSemiring = isCommutativeSemiring-∨-∧\n }\n\nmodule RingSolver =\n Solver (ACR.fromCommutativeSemiring commutativeSemiring-∨-∧)\n\n------------------------------------------------------------------------\n-- (Bool, ∧, ∨, true, false) forms a commutative semiring\n\nprivate\n\n zero-∨ : Zero true _∨_\n zero-∨ = (λ _ → refl) , (λ x → ∨-comm x true)\n\n distrib-∨-∧ : _∨_ DistributesOver _∧_\n distrib-∨-∧ = distˡ , distʳ\n where\n distˡ : _∨_ DistributesOverˡ _∧_\n distˡ true y z = refl\n distˡ false y z = refl\n\n distʳ : _∨_ DistributesOverʳ _∧_\n distʳ x y z =\n begin\n (y ∧ z) ∨ x\n ≈⟨ ∨-comm (y ∧ z) x ⟩\n x ∨ (y ∧ z)\n ≈⟨ distˡ x y z ⟩\n (x ∨ y) ∧ (x ∨ z)\n ≈⟨ cong₂ _∧_ (∨-comm x y) (∨-comm x z) ⟩\n (y ∨ x) ∧ (z ∨ x)\n ∎\n\nisCommutativeSemiring-∧-∨\n : IsCommutativeSemiring _≡_ _∧_ _∨_ true false\nisCommutativeSemiring-∧-∨ = record\n { isSemiring = record\n { isSemiringWithoutAnnihilatingZero = record\n { +-isCommutativeMonoid = record\n { isMonoid = record\n { isSemigroup = record\n { isEquivalence = isEquivalence\n ; assoc = ∧-assoc\n ; ∙-pres-≈ = cong₂ _∧_\n }\n ; identity = ∧-identity\n }\n ; comm = ∧-comm\n }\n ; *-isMonoid = record\n { isSemigroup = record\n { isEquivalence = isEquivalence\n ; assoc = ∨-assoc\n ; ∙-pres-≈ = cong₂ _∨_\n }\n ; identity = ∨-identity\n }\n ; distrib = distrib-∨-∧\n }\n ; zero = zero-∨\n }\n ; *-comm = ∨-comm\n }\n\ncommutativeSemiring-∧-∨ : CommutativeSemiring\ncommutativeSemiring-∧-∨ = record\n { _+_ = _∧_\n ; _*_ = _∨_\n ; 0# = true\n ; 1# = false\n ; isCommutativeSemiring = isCommutativeSemiring-∧-∨\n }\n\n------------------------------------------------------------------------\n-- (Bool, ∨, ∧, not, true, false) is a boolean algebra\n\nprivate\n\n absorptive : Absorptive _∨_ _∧_\n absorptive = abs-∨-∧ , abs-∧-∨\n where\n abs-∨-∧ : _∨_ Absorbs _∧_\n abs-∨-∧ true y = refl\n abs-∨-∧ false y = refl\n\n abs-∧-∨ : _∧_ Absorbs _∨_\n abs-∧-∨ true y = refl\n abs-∧-∨ false y = refl\n\n not-∧-inverse : Inverse false not _∧_\n not-∧-inverse =\n ¬x∧x≡⊥ , (λ x → ∧-comm x (not x) ⟨ trans ⟩ ¬x∧x≡⊥ x)\n where\n ¬x∧x≡⊥ : LeftInverse false not _∧_\n ¬x∧x≡⊥ false = refl\n ¬x∧x≡⊥ true = refl\n\n not-∨-inverse : Inverse true not _∨_\n not-∨-inverse =\n ¬x∨x≡⊤ , (λ x → ∨-comm x (not x) ⟨ trans ⟩ ¬x∨x≡⊤ x)\n where\n ¬x∨x≡⊤ : LeftInverse true not _∨_\n ¬x∨x≡⊤ false = refl\n ¬x∨x≡⊤ true = refl\n\nisBooleanAlgebra : IsBooleanAlgebra _≡_ _∨_ _∧_ not true false\nisBooleanAlgebra = record\n { isDistributiveLattice = record\n { isLattice = record\n { isEquivalence = isEquivalence\n ; ∨-comm = ∨-comm\n ; ∨-assoc = ∨-assoc\n ; ∨-pres-≈ = cong₂ _∨_\n ; ∧-comm = ∧-comm\n ; ∧-assoc = ∧-assoc\n ; ∧-pres-≈ = cong₂ _∧_\n ; absorptive = absorptive\n }\n ; ∨-∧-distribʳ = proj₂ distrib-∨-∧\n }\n ; ∨-complementʳ = proj₂ not-∨-inverse\n ; ∧-complementʳ = proj₂ not-∧-inverse\n ; ¬-pres-≈ = cong not\n }\n\nbooleanAlgebra : BooleanAlgebra\nbooleanAlgebra = record\n { _∨_ = _∨_\n ; _∧_ = _∧_\n ; ¬_ = not\n ; ⊤ = true\n ; ⊥ = false\n ; isBooleanAlgebra = isBooleanAlgebra\n }\n\n------------------------------------------------------------------------\n-- (Bool, xor, ∧, id, false, true) forms a commutative ring\n\nprivate\n\n xor-is-ok : ∀ x y → x xor y ≡ (x ∨ y) ∧ not (x ∧ y)\n xor-is-ok true y = refl\n xor-is-ok false y = sym $ proj₂ ∧-identity _\n\ncommutativeRing-xor-∧ : CommutativeRing\ncommutativeRing-xor-∧ = commutativeRing\n where\n import Algebra.Props.BooleanAlgebra as BA\n open BA booleanAlgebra\n open XorRing _xor_ xor-is-ok\n\nmodule XorRingSolver =\n Solver (ACR.fromCommutativeRing commutativeRing-xor-∧)\n\n------------------------------------------------------------------------\n-- Miscellaneous other properties\n\nnot-involutive : Involutive not\nnot-involutive true = refl\nnot-involutive false = refl\n\nnot-¬ : ∀ {x y} → x ≡ y → x ≢ not y\nnot-¬ {true} refl ()\nnot-¬ {false} refl ()\n\n¬-not : ∀ {x y} → x ≢ y → x ≡ not y\n¬-not {true} {true} x≢y = ⊥-elim (x≢y refl)\n¬-not {true} {false} _ = refl\n¬-not {false} {true} _ = refl\n¬-not {false} {false} x≢y = ⊥-elim (x≢y refl)\n\n⇔→≡ : {b₁ b₂ b : Bool} → b₁ ≡ b ⇔ b₂ ≡ b → b₁ ≡ b₂\n⇔→≡ {true } {true } hyp = refl\n⇔→≡ {true } {false} {true } hyp = sym (proj₁ hyp refl)\n⇔→≡ {true } {false} {false} hyp = proj₂ hyp refl\n⇔→≡ {false} {true } {true } hyp = proj₂ hyp refl\n⇔→≡ {false} {true } {false} hyp = sym (proj₁ hyp refl)\n⇔→≡ {false} {false} hyp = refl\n\nT-≡ : ∀ {b} → T b ⇔ b ≡ true\nT-≡ {false} = ((λ ()) , λ ())\nT-≡ {true} = (const refl , const _)\n\nT-∧ : ∀ {b₁ b₂} → T (b₁ ∧ b₂) ⇔ (T b₁ × T b₂)\nT-∧ {true} {true} = (const (_ , _) , const _)\nT-∧ {true} {false} = ((λ ()) , proj₂)\nT-∧ {false} {_} = ((λ ()) , proj₁)\n\nT-∨ : ∀ {b₁ b₂} → T (b₁ ∨ b₂) ⇔ (T b₁ ⊎ T b₂)\nT-∨ {true} {b₂} = (inj₁ , const _)\nT-∨ {false} {true} = (inj₂ , const _)\nT-∨ {false} {false} = (inj₁ , [ id , id ])\n\nproof-irrelevance : ∀ {b} (p q : T b) → p ≡ q\nproof-irrelevance {true} _ _ = refl\nproof-irrelevance {false} () ()\n", "meta": {"hexsha": "ff302cc54a9b232de33e9af9ee84dde7a32ad525", "size": 8785, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Data/Bool/Properties.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Data/Bool/Properties.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Data/Bool/Properties.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 27.9777070064, "max_line_length": 72, "alphanum_fraction": 0.4853727945, "num_tokens": 3184, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.88242786954645, "lm_q2_score": 0.7248702880639791, "lm_q1q2_score": 0.6396457439938187}} {"text": "module ExCoinduction where\nopen import Coinduction\nopen import Relation.Binary.PropositionalEquality\nopen import Data.Stream\nopen import Data.Nat\nopen import Data.Bool\n\ndata Loc : Set where\n A : Loc\n DONE : Loc\n\nrecord Values : Set where\n field\n x : ℕ\n δ : ℕ\n k : ℕ\n\ndata _Π_ (A B : Set) : Set where\n <_,_> : (a : Loc) → (b : Values) → A Π B\n\n-- The computation of x in the state\n-- The state machine step function\n\nfunₓ : ℕ → ℕ → ℕ → ℕ\nfunₓ x slope δ = x + δ * slope\n\nstep : (Loc Π Values) → (Loc Π Values)\nstep < A , b > with (X >= 10)\n where\n _>=_ : ℕ → ℕ → Bool\n zero >= zero = true\n zero >= suc y = false\n suc x >= zero = false\n suc x >= suc y = x >= y\n\n _==_ : ℕ → ℕ → Bool\n zero == zero = true\n zero == suc y = false\n suc x == zero = false\n suc x == suc y = x == y\n\n X : ℕ\n X = funₓ (Values.x b) 1 (Values.δ b)\nstep < A , b > | false = < A , record { x = X; δ = Values.δ b ; k = Values.k b + 1 } >\n where\n X : ℕ\n X = funₓ (Values.x b) 1 (Values.δ b)\nstep < A , b > | true = < DONE , record { x = X; δ = Values.δ b ; k = Values.k b + 1 } >\n where\n X : ℕ\n X = funₓ (Values.x b) 1 (Values.δ b)\n\nstep < DONE , b > = < DONE , b > -- Just remain in this state forever\n\n-- Make a stream of runFSM\n-- \nf' : ∀ st → Stream (Loc Π Values)\nf' st = st ∷ ♯ (f' (step st))\nfrom : Stream (Loc Π Values)\nfrom = f' (< A , (record { x = zero ; δ = 1 ; k = zero }) >)\n\nthm : from ≈ from \nthm = refl ∷ ♯ (refl ∷ (♯ (refl ∷ (♯ (refl ∷ (♯ (refl ∷ (♯ (refl ∷ (♯ (refl ∷ (♯ (refl ∷ (♯ (refl ∷\n (♯ (refl ∷ ♯ (t'))))))))))))))))))\n\n where\n y : Stream (Loc Π Values)\n y = f' (< DONE , record { x = 10 ; δ = 1 ; k = 10 } > ) \n t' : y ≈ y\n t' = refl ∷ (♯ t')\n", "meta": {"hexsha": "15280562c454e976bc277819bd378f6f9431ad8f", "size": 1678, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "ExCoinduction.agda", "max_stars_repo_name": "amal029/agda-tutorial-dybjer", "max_stars_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:52:30.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-08T12:52:30.000Z", "max_issues_repo_path": "ExCoinduction.agda", "max_issues_repo_name": "amal029/agda-tutorial-dybjer", "max_issues_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ExCoinduction.agda", "max_forks_repo_name": "amal029/agda-tutorial-dybjer", "max_forks_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.6338028169, "max_line_length": 99, "alphanum_fraction": 0.5220500596, "num_tokens": 660, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278664544911, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.6396457365077715}} {"text": "{-# OPTIONS --cubical #-}\n\nopen import Agda.Primitive.Cubical\n renaming ( primIMin to _∧_ -- I → I → I\n ; primIMax to _∨_ -- I → I → I\n ; primINeg to ~_ -- I → I\n )\n\ninfix 10 _≡_\npostulate\n _≡_ : I → I → Set\n refl : ∀ {i} → i ≡ i\n\n\nmodule Vars (i j k : I) where\n\n _ : i ∧ i1 ≡ i\n _ = refl\n\n _ : i ∧ i0 ≡ i0\n _ = refl\n\n _ : i1 ∧ i ≡ i\n _ = refl\n\n _ : i0 ∧ i ≡ i0\n _ = refl\n\n _ : i ∧ j ≡ j ∧ i\n _ = refl\n\n _ : i ∧ (j ∧ k) ≡ (i ∧ j) ∧ k\n _ = refl\n\n _ : i ∧ i ≡ i\n _ = refl\n\n _ : i ∨ j ≡ j ∨ i\n _ = refl\n\n _ : i ∨ (j ∨ k) ≡ (i ∨ j) ∨ k\n _ = refl\n\n _ : i ∨ i ≡ i\n _ = refl\n\n _ : i ∨ i1 ≡ i1\n _ = refl\n\n _ : i ∨ i0 ≡ i\n _ = refl\n\n _ : i1 ∨ i ≡ i1\n _ = refl\n\n _ : i0 ∨ i ≡ i\n _ = refl\n\n _ : ~ i0 ≡ i1\n _ = refl\n\n _ : ~ i1 ≡ i0\n _ = refl\n\n _ : ~ (~ i) ≡ i\n _ = refl\n\n _ : ~ (i ∧ j) ≡ ~ i ∨ ~ j\n _ = refl\n\n _ : ~ (i ∨ j) ≡ ~ i ∧ ~ j\n _ = refl\n\n _ : i ∧ (j ∨ k) ≡ (i ∧ j) ∨ (i ∧ k)\n _ = refl\n\n _ : i ∨ (j ∧ k) ≡ (i ∨ j) ∧ (i ∨ k)\n _ = refl\n\nmodule Postulates where\n postulate\n i j k : I\n\n _ : i ∧ i1 ≡ i\n _ = refl\n\n _ : i ∧ i0 ≡ i0\n _ = refl\n\n _ : i1 ∧ i ≡ i\n _ = refl\n\n _ : i0 ∧ i ≡ i0\n _ = refl\n\n _ : i ∧ j ≡ j ∧ i\n _ = refl\n\n _ : i ∧ (j ∧ k) ≡ (i ∧ j) ∧ k\n _ = refl\n\n _ : i ∧ i ≡ i\n _ = refl\n\n _ : i ∨ j ≡ j ∨ i\n _ = refl\n\n _ : i ∨ (j ∨ k) ≡ (i ∨ j) ∨ k\n _ = refl\n\n _ : i ∨ i ≡ i\n _ = refl\n\n _ : i ∨ i1 ≡ i1\n _ = refl\n\n _ : i ∨ i0 ≡ i\n _ = refl\n\n _ : i1 ∨ i ≡ i1\n _ = refl\n\n _ : i0 ∨ i ≡ i\n _ = refl\n\n _ : ~ i0 ≡ i1\n _ = refl\n\n _ : ~ i1 ≡ i0\n _ = refl\n\n _ : ~ (~ i) ≡ i\n _ = refl\n\n _ : ~ (i ∧ j) ≡ ~ i ∨ ~ j\n _ = refl\n\n _ : ~ (i ∨ j) ≡ ~ i ∧ ~ j\n _ = refl\n\n _ : i ∧ (j ∨ k) ≡ (i ∧ j) ∨ (i ∧ k)\n _ = refl\n\n _ : i ∨ (j ∧ k) ≡ (i ∨ j) ∧ (i ∨ k)\n _ = refl\n", "meta": {"hexsha": "f803636714c4b821cf6d691b036de278b3470def", "size": 1788, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue2582.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue2582.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue2582.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 12.2465753425, "max_line_length": 48, "alphanum_fraction": 0.3467561521, "num_tokens": 961, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278540866547, "lm_q2_score": 0.7248702761768249, "lm_q1q2_score": 0.6396457222979163}} {"text": "\nopen import Agda.Builtin.Nat\n\ndata Bal : Nat → Nat → Nat → Set where\n leanR : ∀ {n} → Bal n (suc n) (suc n)\n leanL : ∀ {n} → Bal (suc n) n (suc n)\n\ndata Tree : Nat → Set where\n leaf : Tree 0\n node : ∀ {hˡ hʳ h} (t : Tree hʳ) (b : Bal hˡ hʳ h) → Tree (suc h)\n\njoin : ∀ {hˡ hʳ} h → Bal hˡ hʳ h → Tree (suc hˡ) → Nat\njoin _ leanL (node (node t b) leanR) = 0\njoin (suc _) leanL (node t leanL) = 1\njoin _ leanR t₁ = 2\n", "meta": {"hexsha": "0ad9adbbce306f2919b53003eac33bcb3e47e5a8", "size": 460, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue4179.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue4179.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue4179.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 28.75, "max_line_length": 67, "alphanum_fraction": 0.5152173913, "num_tokens": 201, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9324533126145178, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.6396158416085123}} {"text": "-- Andreas, 2017-05-26\n-- Expand ellipsis with C-c C-c . RET\n\nopen import Agda.Builtin.Nat\n\ntest0 : Nat → Nat\ntest0 x with zero\n\n... | q = {!.!} -- C-c C-c\n\n-- Expected result:\n-- test0 x | q = ?\n\ndata Fin : Nat → Set where\n zero : ∀ n → Fin (suc n)\n suc : ∀{n} → Fin n → Fin (suc n)\n\ntest1 : ∀{n} → Fin n → Nat\n\ntest1 (zero _) with Nat\n\n... | q = {!.!} -- C-c C-c\n\n-- Expected result:\n-- test1 (zero _) | q = ?\n\ntest1 {.(suc n)} (suc {n} i) with Fin zero\n\n... | q = {!.!} -- C-c C-c\n\n-- Expected result:\n-- test1 {.(suc n)} (suc {n} i) | q = ?\n", "meta": {"hexsha": "c4d2a22271931b9f96a7d64fbfca21419e8d8862", "size": 549, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/ExpandEllipsis.agda", "max_stars_repo_name": "hborum/agda", "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_issues_repo_path": "test/interaction/ExpandEllipsis.agda", "max_issues_repo_name": "hborum/agda", "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_forks_repo_path": "test/interaction/ExpandEllipsis.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 16.6363636364, "max_line_length": 42, "alphanum_fraction": 0.5081967213, "num_tokens": 218, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199714402812, "lm_q2_score": 0.7634837581726991, "lm_q1q2_score": 0.6395092437157348}} {"text": "{-# OPTIONS --cubical-compatible --show-implicit #-}\n-- {-# OPTIONS -v tc.lhs.split.well-formed:100 #-}\n-- Andreas, adapted from Andres Sicard, 2013-05-29\nmodule WithoutKRestrictive where\n\nopen import Common.Level\nopen import Common.Equality\nopen import Common.Product\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\ndata _≤_ : ℕ → ℕ → Set where\n z≤n : ∀ {n} → zero ≤ n\n s≤s : ∀ {n m} → n ≤ m → suc n ≤ suc m\n\n_<_ : ℕ → ℕ → Set\nn < m = suc n ≤ m\n\nrefl≤ : ∀ (n : ℕ) → n ≤ n\nrefl≤ zero = z≤n\nrefl≤ (suc n) = s≤s (refl≤ n)\n\ndata List {a} (A : Set a) : Set a where\n [] : List A\n _∷_ : (x : A) (xs : List A) → List A\n\nlength : {A : Set} → List A → ℕ\nlength [] = zero\nlength (x ∷ xs) = suc (length xs)\n\nP : {A : Set} → List A → List A → Set\nP xs ys = Σ _ (λ x → ys ≡ (x ∷ xs))\n\nQ : {A : Set} → List A → List A → Set\nQ xs ys = (length xs) < (length ys)\n\nhelper : {A : Set}(y : A)(xs : List A) → (length xs) < (length (y ∷ xs))\nhelper y [] = s≤s z≤n\nhelper y (x ∷ xs) = s≤s (refl≤ _)\n\n-- Why the --cubical-compatible option rejects the following proof\n\nfoo : {A : Set}(xs ys : List A) → P xs ys → Q xs ys\nfoo xs .(x ∷ xs) (x , refl) = helper x xs\n\n-- if I can prove foo using only subst\n\nfoo' : {A : Set}(xs ys : List A) → P xs ys → Q xs ys\nfoo' xs ys (x , h) =\n subst (λ ys' → length xs < length ys') (sym h) (helper x xs)\n", "meta": {"hexsha": "27fb75ee61aef19a8b78ae58941daa49fe8a0b7a", "size": 1336, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/WithoutKRestrictive.agda", "max_stars_repo_name": "KDr2/agda", "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/Succeed/WithoutKRestrictive.agda", "max_issues_repo_name": "KDr2/agda", "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_forks_repo_path": "test/Succeed/WithoutKRestrictive.agda", "max_forks_repo_name": "KDr2/agda", "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.2075471698, "max_line_length": 72, "alphanum_fraction": 0.5516467066, "num_tokens": 530, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199633332891, "lm_q2_score": 0.7634837635542924, "lm_q1q2_score": 0.639509242033908}} {"text": "\nmodule Preliminaries where\n\n open import Agda.Primitive using (Level) renaming (lzero to lZ; lsuc to lS; _⊔_ to lmax)\n\n -- ----------------------------------------------------------------------\n -- functions\n\n _o_ : {A B C : Set} → (B → C) → (A → B) → A → C\n g o f = \\ x → g (f x)\n infixr 10 _o_\n\n -- ----------------------------------------------------------------------\n -- identity type\n\n data _==_ {l : Level} {A : Set l} (M : A) : A → Set l where\n Refl : M == M\n\n Id : {l : Level} {A : Set l} (M : A) → A → Set l\n Id M N = M == N\n\n {-# BUILTIN EQUALITY _==_ #-}\n {-# BUILTIN REFL Refl #-}\n\n transport : {l1 : Level} {l2 : Level} {A : Set l1} (B : A → Set l2) \n {a1 a2 : A} → a1 == a2 → (B a1 → B a2)\n transport B Refl = λ x → x\n\n ! : {l : Level} {A : Set l} {M N : A} → M == N → N == M \n ! Refl = Refl\n\n _∘_ : {l : Level} {A : Set l} {M N P : A} \n → N == P → M == N → M == P\n β ∘ Refl = β\n\n ap : {l1 l2 : Level} {A : Set l1} {B : Set l2} {M N : A}\n (f : A → B) → M == N → (f M) == (f N)\n ap f Refl = Refl\n\n ap2 : {l1 l2 l3 : Level} {A : Set l1} {B : Set l2} {C : Set l3} {M N : A} {M' N' : B} (f : A -> B -> C) -> M == N -> M' == N' -> (f M M') == (f N N')\n ap2 f Refl Refl = Refl\n\n ap3 : {l1 l2 l3 l4 : Level} {A : Set l1} {B : Set l2} {C : Set l3} {D : Set l4} {M N : A} {M' N' : B} {M'' N'' : C}\n (f : A → B → C → D) → M == N → M' == N' → M'' == N'' → (f M M' M'') == (f N N' N'')\n ap3 f Refl Refl Refl = Refl\n\n postulate\n -- function extensionality\n λ= : {l1 l2 : Level} {A : Set l1} {B : A -> Set l2} {f g : (x : A) -> B x} -> ((x : A) -> (f x) == (g x)) -> f == g\n -- function extensionality for implicit functions\n λ=i : {l1 l2 : Level} {A : Set l1} {B : A -> Set l2} {f g : {x : A} -> B x} -> ((x : A) -> (f {x}) == (g {x})) -> _==_ {_}{ {x : A} → B x } f g\n\n private primitive primTrustMe : {l : Level} {A : Set l} {x y : A} -> x == y\n\n infixr 9 _==_\n\n\n infix 2 _∎\n infixr 2 _=⟨_⟩_\n \n _=⟨_⟩_ : {l : Level} {A : Set l} (x : A) {y z : A} → x == y → y == z → x == z\n _ =⟨ p1 ⟩ p2 = (p2 ∘ p1)\n \n _∎ : {l : Level} {A : Set l} (x : A) → x == x\n _∎ _ = Refl\n\n\n -- ----------------------------------------------------------------------\n -- product types\n\n record Unit : Set where\n constructor <> \n \n record Σ {l1 l2 : Level} {A : Set l1} (B : A -> Set l2) : Set (lmax l1 l2) where\n constructor _,_\n field\n fst : A\n snd : B fst\n open Σ public\n\n infixr 0 _,_\n\n _×_ : {l1 l2 : Level} → Set l1 -> Set l2 -> Set (lmax l1 l2)\n A × B = Σ (\\ (_ : A) -> B)\n\n infixr 10 _×_\n\n -- ----------------------------------------------------------------------\n -- booleans\n\n data Bool : Set where\n True : Bool\n False : Bool\n {-# COMPILED_DATA Bool Bool True False #-}\n {-# BUILTIN BOOL Bool #-}\n {-# BUILTIN TRUE True #-}\n {-# BUILTIN FALSE False #-}\n\n -- ----------------------------------------------------------------------\n -- order\n\n data Order : Set where\n Less : Order\n Equal : Order\n Greater : Order\n\n -- ----------------------------------------------------------------------\n -- sums\n\n data Void : Set where\n\n abort : {A : Set} → Void → A\n abort () \n\n data Either (A B : Set) : Set where\n Inl : A → Either A B\n Inr : B → Either A B\n\n DecEq : Set → Set\n DecEq A = (x y : A) → Either (x == y) (x == y → Void)\n\n -- ----------------------------------------------------------------------\n -- natural numbers\n\n module Nat where\n data Nat : Set where\n Z : Nat\n S : Nat -> Nat\n\n -- let's you use numerals for Nat\n {-# BUILTIN NATURAL Nat #-}\n\n _+_ : Nat → Nat → Nat\n Z + n = n\n (S m) + n = S (m + n)\n\n max : Nat → Nat → Nat\n max Z n = n\n max m Z = m\n max (S m) (S n) = S (max m n)\n\n equal : Nat → Nat → Bool\n equal Z Z = True\n equal Z (S _) = False\n equal (S _) Z = False\n equal (S m) (S n) = equal m n\n\n compare : Nat → Nat → Order\n compare Z Z = Equal\n compare Z (S m) = Less\n compare (S n) Z = Greater\n compare (S n) (S m) = compare n m\n\n open Nat public using (Nat ; Z ; S)\n\n\n -- ----------------------------------------------------------------------\n -- monad \n\n module Monad where\n\n record Monad : Set1 where\n field \n T : Set → Set\n return : ∀ {A} → A → T A\n _>>=_ : ∀ {A B} → T A → (A → T B) -> T B\n\n\n -- ----------------------------------------------------------------------\n -- options \n \n module Maybe where\n\n data Maybe {l : Level} (A : Set l) : Set l where\n Some : A → Maybe A\n None : Maybe A\n\n Monad : Monad.Monad \n Monad = record { T = Maybe; return = Some; _>>=_ = (λ {None _ → None; (Some v) f → f v}) }\n\n open Maybe public using (Maybe;Some;None)\n\n -- ----------------------------------------------------------------------\n -- lists\n\n module List where\n data List {l : Level} (A : Set l) : Set l where\n [] : List A\n _::_ : A -> List A -> List A\n \n {-# COMPILED_DATA List [] [] (:) #-}\n {-# BUILTIN LIST List #-}\n {-# BUILTIN NIL [] #-}\n {-# BUILTIN CONS _::_ #-}\n \n infixr 99 _::_\n \n _++_ : {A : Set} → List A → List A → List A\n [] ++ ys = ys\n (x :: xs) ++ ys = x :: (xs ++ ys)\n\n infixr 10 _++_\n\n map : {l1 l2 : Level} {A : Set l1} {B : Set l2} → (A → B) → List A → List B\n map f [] = []\n map f (x :: xs) = f x :: map f xs\n\n map-id : {l : Level} {A : Set l} (l : List A) → map (\\ (x : A) → x) l == l\n map-id [] = Refl\n map-id (x :: l) with map (\\ x -> x) l | map-id l\n ... | ._ | Refl = Refl\n \n ++-assoc : ∀ {A} (l1 l2 l3 : List A) → (l1 ++ l2) ++ l3 == l1 ++ (l2 ++ l3)\n ++-assoc [] l2 l3 = Refl\n ++-assoc (x :: xs) l2 l3 = ap (_::_ x) (++-assoc xs l2 l3)\n\n open List public using (List ; [] ; _::_)\n\n\n -- ----------------------------------------------------------------------\n -- characters\n\n module Char where\n\n postulate {- Agda Primitive -}\n Char : Set\n \n {-# BUILTIN CHAR Char #-}\n {-# COMPILED_TYPE Char Char #-}\n \n private\n primitive\n primCharToNat : Char → Nat\n primCharEquality : Char → Char → Bool\n \n toNat : Char → Nat\n toNat = primCharToNat\n \n equalb : Char -> Char -> Bool\n equalb = primCharEquality\n\n -- need to go outside the real language a little to give the primitives good types,\n -- but from the outside this should be safe\n equal : DecEq Char\n equal x y with equalb x y \n ... | True = Inl primTrustMe\n ... | False = Inr canthappen where\n postulate canthappen : _\n\n open Char public using (Char)\n\n -- ----------------------------------------------------------------------\n -- vectors\n\n module Vector where\n\n data Vec (A : Set) : Nat → Set where\n [] : Vec A 0\n _::_ : ∀ {n} → A → Vec A n → Vec A (S n)\n\n infixr 99 _::_\n\n Vec-elim : {A : Set} (P : {n : Nat} → Vec A n → Set)\n → (P [])\n → ({n : Nat} (x : A) (xs : Vec A n) → P xs → P (x :: xs))\n → {n : Nat} (v : Vec A n) → P v\n Vec-elim P n c [] = n\n Vec-elim P n c (y :: ys) = c y ys (Vec-elim P n c ys)\n\n fromList : {A : Set} → List A → Σ \\n → Vec A n\n fromList [] = _ , []\n fromList (x :: xs) = _ , x :: snd (fromList xs)\n\n toList : {A : Set} {n : Nat} → Vec A n → List A\n toList [] = []\n toList (x :: xs) = x :: (toList xs)\n\n toList' : {A : Set} → (Σ \\ n → Vec A n) → List A\n toList' (._ , []) = []\n toList' (._ , (x :: xs)) = x :: (toList' (_ , xs))\n\n -- ----------------------------------------------------------------------\n -- strings\n\n module String where\n\n postulate {- Agda Primitive -}\n String : Set\n {-# BUILTIN STRING String #-}\n {-# COMPILED_TYPE String String #-}\n\n private\n primitive\n primStringToList : String -> List Char\n primStringFromList : List Char -> String\n primStringAppend : String -> String -> String\n primStringEquality : String -> String -> Bool\n \n equal : String -> String -> Bool\n equal = primStringEquality\n \n toList = primStringToList\n fromList = primStringFromList\n \n append = primStringAppend\n\n toVec : String -> Σ \\ m → Vector.Vec Char m\n toVec = Vector.fromList o toList\n \n\n", "meta": {"hexsha": "4ae5066f215b86f79ea967bd0ee01c6a391ebb3d", "size": 8225, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "complexity-drafts/Preliminaries.agda", "max_stars_repo_name": "benhuds/Agda", "max_stars_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-04-26T20:22:22.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-08T12:27:18.000Z", "max_issues_repo_path": "complexity-drafts/Preliminaries.agda", "max_issues_repo_name": "benhuds/Agda", "max_issues_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-03-23T08:39:04.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-12T00:32:45.000Z", "max_forks_repo_path": "complexity-drafts/Preliminaries.agda", "max_forks_repo_name": "benhuds/Agda", "max_forks_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.4469453376, "max_line_length": 151, "alphanum_fraction": 0.4207902736, "num_tokens": 2753, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951182587159, "lm_q2_score": 0.7577943658046609, "lm_q1q2_score": 0.6394989659465129}} {"text": "open import Data.Product renaming (_×_ to _∧_)\n\n×-comm : {A B : Set} → (A ∧ B) → (B ∧ A)\n×-comm (fst , snd) = snd , fst\n\n\nid : {A : Set} → A → A\nid a = a\n\nK : {A B : Set} → A → B → A\nK a b = a\n\napp : {A B : Set} → (A → B) → A → B\napp f a = f a\n\nflip : {A B C : Set} → (A → B → C) → B → A → C\nflip f b a = f a b\n\ncomp : {A B C : Set} → (A → B) → (B → C) → (A → C)\ncomp ab bc = λ x → bc (ab x)\n\nS : {A B C : Set} → (A → B → C) → (A → B) → A → C\nS g f = λ x → g x (f x)\n\n\nproj1 : {A B : Set} → (A ∧ B) → A\nproj1 (fst , snd) = fst\n\nproj2 : {A B : Set} → (A ∧ B) → B\nproj2 (fst , snd) = snd\n\ndiagonal : {A B : Set} → A → (A ∧ A)\ndiagonal a = a , a\n\ncommut : {A B : Set} → (A ∧ B) → (B ∧ A)\ncommut (fst , snd) = snd , fst\n\ncurry1 : {A B C : Set} → (A ∧ B → C) → (A → B → C)\ncurry1 f = λ x x₁ → f (x , x₁)\n\ncurry2 : {A B C : Set} → (A → B → C) → (A ∧ B → C)\ncurry2 f (fst , snd) = f fst snd\n\n_↔_ : (A B : Set) → Set\nA ↔ B = (A → B) ∧ (B → A)\n\ncurrying : {A B C : Set} → (A ∧ B → C) ↔ (A → B → C)\ncurrying = curry1 , curry2\n\ndistrib : {A B C : Set} → (A → (B ∧ C)) ↔ ((A → B) ∧ (A → C))\ndistrib = (λ x → (λ x₁ → proj1 (x x₁)) , λ x₁ → proj2 (x x₁)) , λ x x₁ → ((proj1 x) x₁) , ((proj2 x) x₁)\n\n\ndata _∨_ (A B : Set) : Set where\n left : A → A ∨ B\n right : B → A ∨ B\n\nor-elim : {A B C : Set} → (A ∨ B) → (A → C) → (B → C) → C\nor-elim (left x) = λ x₁ x₂ → x₁ x\nor-elim (right x) = λ x₁ x₂ → x₂ x\n\nor-comm : {A B : Set} → (A ∨ B) → (B ∨ A)\nor-comm (left x) = right x\nor-comm (right x) = left x\n\nor-dist : {A B C : Set} → (A ∧ (B ∨ C)) → ((A ∧ B) ∨ (A ∧ C))\nor-dist (fst , left x) = left (fst , x)\nor-dist (fst , right x) = right (fst , x)\n\n\ndata ⊥ : Set where\n\n⊥-elim : {A : Set} → ⊥ → A\n⊥-elim ()\n\n¬ : Set → Set\n¬ A = A → ⊥\n\ncontr : {A B : Set} → (A → B) → (¬ B → ¬ A)\ncontr f = λ x x₁ → x (f x₁)\n\nnon-contr : {A : Set} → ¬ (A ∧ ¬ A)\nnon-contr (fst , snd) = snd fst\n\nnni : {A : Set} → A → ¬ (¬ A)\nnni a = λ x → x a\n\n⊥-nne : ¬ (¬ ⊥) → ⊥\n⊥-nne x = x ⊥-elim\n\n¬-elim : {A B : Set} → ¬ A → A → B\n¬-elim n a = ⊥-elim (n a)\n\nnnlem : {A : Set} → ¬ (¬ (A ∨ ¬ A))\nnnlem = (λ x → x (right λ y → x (left y)))\n\nrp2 : {A : Set} → (A → ¬ A) → (¬ A → A) → ⊥\nrp2 a na = nnlem (λ x → or-elim x (λ x₁ → a x₁ x₁) λ x₁ → x₁ (na x₁))\n\n\ndata ⊤ : Set where\n tt : ⊤\n\nti : {A : Set} → (⊤ → A) → A\nti f = f tt\n\ndmnt : ¬ ⊤ → ⊥\ndmnt f = f tt\n\ndmtn : ⊥ → ¬ ⊤\ndmtn = λ x x₁ → x\n\n\nlem : Set₁\nlem = (A : Set) → A ∨ ¬ A\n\nnne : Set₁\nnne = (A : Set) → ¬ (¬ A) → A\n\nnne-lem : nne → lem\nnne-lem x A = x (A ∨ ¬ A) nnlem\n\nlem-nne : lem → nne\nlem-nne x A y = or-elim (x A) (λ x₁ → x₁) λ x₁ → ¬-elim y x₁\n\n_↔₁_ : (A B : Set₁) → Set₁\nA ↔₁ B = (A → B) ∧ (B → A)\n\npeirce : Set₁\npeirce = (A B : Set) → ((A → B) → A) → A\n\nlem-peirce : lem ↔₁ peirce\nlem-peirce = (λ x A B x₁ → or-elim (x A) id λ x₂ → x₁ λ x₃ → ¬-elim x₂ x₃) , λ x A → x (A ∨ ¬ A) ⊥ λ x₁ → right λ x₂ → x₁ (left x₂)\n\nnne-peirce : nne ↔₁ peirce\nnne-peirce = (λ x A B x₁ → x A λ x₂ → x₂ (x₁ λ x₃ → ¬-elim x₂ x₃)) , (λ x A x₁ → x A ⊥ λ x₂ → ¬-elim x₁ x₂)\n", "meta": {"hexsha": "132ae92ab39ee68960d1d94d29d89d68fe1b52d5", "size": 2961, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "TD5/prop.agda", "max_stars_repo_name": "erwinkn/program-eq-proof", "max_stars_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "TD5/prop.agda", "max_issues_repo_name": "erwinkn/program-eq-proof", "max_issues_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TD5/prop.agda", "max_forks_repo_name": "erwinkn/program-eq-proof", "max_forks_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.6131386861, "max_line_length": 131, "alphanum_fraction": 0.4366767984, "num_tokens": 1491, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950986284991, "lm_q2_score": 0.7577943712746406, "lm_q1q2_score": 0.6394989556869343}} {"text": "{-# OPTIONS --without-K --exact-split --rewriting #-}\n\nopen import lib.Basics\nopen import lib.NConnected\n\nopen import Graphs.Definition\nopen import Coequalizers.Definition\n\n{- We will consider two properties of graphs: if they are trees and if they are connected,\n both are defined in terms of the geometric realisation (coequalizer). -}\nmodule Graphs.Properties where\n\n{- A graph is a tree if its coequalizer is contractible. -}\nis-tree : {i j : ULevel} {E : Type i} {V : Type j} ( gph : Graph E V ) → Type (lmax i j)\nis-tree gph = is-contr (Coeq gph)\n\n{- A graph is connected if its coequalizer is connected. -}\ngph-is-connected : {i j : ULevel} {E : Type i} {V : Type j} (gph : Graph E V) → Type (lmax i j)\ngph-is-connected gph = is-connected 0 (Coeq gph)\n", "meta": {"hexsha": "cb373bbc3115c87b123d89fd702b30889277fe8f", "size": 761, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "main/Graphs/Properties.agda", "max_stars_repo_name": "awswan/nielsenschreier-hott", "max_stars_repo_head_hexsha": "84be713b8a8e41ea6f01f8ccf7251ebbbd73ad5d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "main/Graphs/Properties.agda", "max_issues_repo_name": "awswan/nielsenschreier-hott", "max_issues_repo_head_hexsha": "84be713b8a8e41ea6f01f8ccf7251ebbbd73ad5d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "main/Graphs/Properties.agda", "max_forks_repo_name": "awswan/nielsenschreier-hott", "max_forks_repo_head_hexsha": "84be713b8a8e41ea6f01f8ccf7251ebbbd73ad5d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.05, "max_line_length": 95, "alphanum_fraction": 0.7017082786, "num_tokens": 225, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9019206870747657, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.6394790242926065}} {"text": "------------------------------------------------------------------------\n-- agda-misc\n-- All modules\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule AgdaMiscEverything where\n\n------------------------------------------------------------------------\n-- Algorithms\n\n-- Insertion sort\nimport Algorithms.List.Sort.Insertion\n\nimport Algorithms.List.Sort.Insertion.Properties\n\n-- Quicksort\nimport Algorithms.List.Sort.Quick\n\nimport Algorithms.List.Sort.Quick.Properties\n\n------------------------------------------------------------------------\n-- Constructive mathematics\n\n-- Definitions of Axioms that are nonconstructive\nimport Constructive.Axiom\n\nimport Constructive.Axiom.Properties\n\nimport Constructive.Axiom.Properties.Base\n\nimport Constructive.Axiom.Properties.Base.Lemma\n\nimport Constructive.Axiom.Properties.Bool\n\nimport Constructive.Axiom.Properties.Transport\n\n-- Alternative proof of LLPO => MP∨\nimport Constructive.Axiom.Properties.Alternative\n\n-- Combinators for reasoning\nimport Constructive.Combinators\n\nimport Constructive.Common\n\n-- Searchable set\nimport Constructive.Searchable\n\n-- Experiment\n\n-- Category theory\nimport Experiment.Categories.Solver.Category\n\nimport Experiment.Categories.Solver.Category.Example\n\nimport Experiment.Categories.Solver.Category.Cartesian\n\nimport Experiment.Categories.Solver.Category.Cartesian.Example\n\nimport Experiment.Categories.Solver.Functor\n\nimport Experiment.Categories.Solver.Functor.Example\n\nimport Experiment.Categories.Solver.MultiFunctor\n\nimport Experiment.Categories.Solver.MultiFunctor.Example\n\n------------------------------------------------------------------------\n-- Formal language\n\nimport Math.FormalLanguage\n\n------------------------------------------------------------------------\n-- Googology\n\nimport Math.Googology.Function\n\nimport Math.Googology.Function.Properties\n\n------------------------------------------------------------------------\n-- Number theory\n\n-- Fibonacci number\nimport Math.NumberTheory.Fibonacci.Generic\n\nimport Math.NumberTheory.Fibonacci.Nat\n\nimport Math.NumberTheory.Fibonacci.Nat.Properties\n\n-- Summation\nimport Math.NumberTheory.Summation.Generic\n\nimport Math.NumberTheory.Summation.Generic.Properties\n\nimport Math.NumberTheory.Summation.Nat\n\nimport Math.NumberTheory.Summation.Nat.Properties\n\n-- Product\nimport Math.NumberTheory.Product.Generic\n\nimport Math.NumberTheory.Product.Generic.Properties\n\nimport Math.NumberTheory.Product.Nat\n\nimport Math.NumberTheory.Product.Nat.Properties\n\n------------------------------------------------------------------------\n-- Type theory\n\n-- Natural number\nimport TypeTheory.Nat.Operations\n\nimport TypeTheory.Nat.Properties\n\nimport TypeTheory.Nat.Instance\n\n-- Homotopy Type Theory\nimport TypeTheory.HoTT.Base\n\nimport TypeTheory.HoTT.Data.Empty.Properties\n\nimport TypeTheory.HoTT.Data.Sum.Properties\n\nimport TypeTheory.HoTT.Function.Properties\n\nimport TypeTheory.HoTT.Relation.Nullary.Negation.Properties\n\n-- Identity type\nimport TypeTheory.Identity\n", "meta": {"hexsha": "5998309b4ff1b739b700fb6625265b5e05f29721", "size": 3043, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "AgdaMiscEverything.agda", "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_issues_repo_path": "AgdaMiscEverything.agda", "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "AgdaMiscEverything.agda", "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.053030303, "max_line_length": 72, "alphanum_fraction": 0.6717055537, "num_tokens": 536, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.90192067652954, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.6394790168158396}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Setoids.Setoids\nopen import Rings.Definition\nopen import Rings.Ideals.Definition\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\n\nmodule Rings.Ideals.Maximal.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} {R : Ring S _+_ _*_} {c : _} {pred : A → Set c} (i : Ideal R pred) where\n\nrecord MaximalIdeal {d : _} : Set (a ⊔ b ⊔ c ⊔ lsuc d) where\n field\n notContained : A\n notContainedIsNotContained : (pred notContained) → False\n isMaximal : {bigger : A → Set d} → Ideal R bigger → ({a : A} → pred a → bigger a) → (Sg A (λ a → bigger a && (pred a → False))) → ({a : A} → bigger a)\n", "meta": {"hexsha": "4567c7809cbb6b449476ee5883c95f7b7bfbcafa", "size": 720, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Rings/Ideals/Maximal/Definition.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Rings/Ideals/Maximal/Definition.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Rings/Ideals/Maximal/Definition.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 42.3529411765, "max_line_length": 178, "alphanum_fraction": 0.6305555556, "num_tokens": 249, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.90192066862062, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.6394790167537657}} {"text": "module Structure.Category.NaturalTransformation.NaturalTransformations where\n\nopen import Functional using () renaming (id to idᶠⁿ)\nopen import Functional.Dependent using () renaming (_∘_ to _∘ᶠⁿ_)\nopen import Logic\nopen import Logic.Predicate\nimport Lvl\nopen import Structure.Category\nopen import Structure.Category.Functor\nopen import Structure.Category.NaturalTransformation\nopen import Structure.Categorical.Properties\nopen import Structure.Operator\nopen import Structure.Relator.Equivalence\nopen import Structure.Setoid\nopen import Syntax.Transitivity\nopen import Type\n\nopen CategoryObject\nprivate variable ℓₒₗ ℓₒᵣ ℓₘₗ ℓₘᵣ ℓₑₗ ℓₑᵣ : Lvl.Level\n\nmodule Raw\n (catₗ : CategoryObject{ℓₒₗ}{ℓₘₗ}{ℓₑₗ})\n (catᵣ : CategoryObject{ℓₒᵣ}{ℓₘᵣ}{ℓₑᵣ})\n where\n\n private variable F F₁ F₂ F₃ : Object(catₗ) → Object(catᵣ)\n private instance _ = category catₗ\n private instance _ = category catᵣ\n\n open Category.ArrowNotation ⦃ … ⦄\n open Category ⦃ … ⦄ hiding (identity)\n\n idᴺᵀ : (x : Object(catₗ)) → (F(x) ⟶ F(x))\n idᴺᵀ _ = id\n\n _∘ᴺᵀ_ : ((x : Object(catₗ)) → (F₂(x) ⟶ F₃(x))) → ((x : Object(catₗ)) → (F₁(x) ⟶ F₂(x))) → ((x : Object(catₗ)) → (F₁(x) ⟶ F₃(x)))\n (comp₁ ∘ᴺᵀ comp₂)(x) = comp₁(x) ∘ comp₂(x)\n\nmodule _\n {catₗ : CategoryObject{ℓₒₗ}{ℓₘₗ}{ℓₑₗ}}\n {catᵣ : CategoryObject{ℓₒᵣ}{ℓₘᵣ}{ℓₑᵣ}}\n where\n\n private instance _ = category catₗ\n private instance _ = category catᵣ\n\n open Category ⦃ … ⦄ hiding (identity)\n open Functor ⦃ … ⦄\n private open module Equivᵣ {x}{y} = Equivalence (Equiv-equivalence ⦃ morphism-equiv(catᵣ){x}{y} ⦄) using ()\n\n module _ where\n open Raw(catₗ)(catᵣ)\n\n module _ {functor@([∃]-intro F) : catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ} where\n identity : NaturalTransformation(functor)(functor)(idᴺᵀ)\n NaturalTransformation.natural identity {x} {y} {f} =\n id ∘ map f 🝖-[ Morphism.identityₗ(_)(id) ⦃ identityₗ ⦄ ]\n map f 🝖-[ Morphism.identityᵣ(_)(id) ⦃ identityᵣ ⦄ ]-sym\n map f ∘ id 🝖-end\n\n module _ {functor₁@([∃]-intro F₁) functor₂@([∃]-intro F₂) functor₃@([∃]-intro F₃) : catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ} where\n composition : ∀{comp₁ comp₂} → NaturalTransformation(functor₂)(functor₃)(comp₁) → NaturalTransformation(functor₁)(functor₂)(comp₂) → NaturalTransformation(functor₁)(functor₃)(comp₁ ∘ᴺᵀ comp₂)\n NaturalTransformation.natural (composition {comp₁} {comp₂} nat₁ nat₂) {x} {y} {f} =\n (comp₁(y) ∘ comp₂(y)) ∘ map f 🝖-[ Morphism.associativity(_) ⦃ associativity ⦄ ]\n comp₁(y) ∘ (comp₂(y) ∘ map f) 🝖-[ congruence₂ᵣ(_∘_)(comp₁(y)) (NaturalTransformation.natural nat₂) ]\n comp₁(y) ∘ (map f ∘ comp₂(x)) 🝖-[ Morphism.associativity(_) ⦃ associativity ⦄ ]-sym\n (comp₁(y) ∘ map f) ∘ comp₂(x) 🝖-[ congruence₂ₗ(_∘_)(comp₂(x)) (NaturalTransformation.natural nat₁) ]\n (map f ∘ comp₁(x)) ∘ comp₂(x) 🝖-[ Morphism.associativity(_) ⦃ associativity ⦄ ]\n map f ∘ (comp₁(x) ∘ comp₂(x)) 🝖-end\n\n module Wrapped where\n private variable F F₁ F₂ F₃ : catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ\n\n idᴺᵀ : (F →ᴺᵀ F)\n idᴺᵀ = [∃]-intro (Raw.idᴺᵀ(catₗ)(catᵣ)) ⦃ identity ⦄\n\n _∘ᴺᵀ_ : (F₂ →ᴺᵀ F₃) → (F₁ →ᴺᵀ F₂) → (F₁ →ᴺᵀ F₃)\n _∘ᴺᵀ_ ([∃]-intro F ⦃ F-proof ⦄) ([∃]-intro G ⦃ G-proof ⦄) = [∃]-intro (Raw._∘ᴺᵀ_ (catₗ)(catᵣ) F G) ⦃ composition F-proof G-proof ⦄\n", "meta": {"hexsha": "57e8878bf2242dfef3e619bb93887b1f9be962a6", "size": 3226, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Category/NaturalTransformation/NaturalTransformations.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Category/NaturalTransformation/NaturalTransformations.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Category/NaturalTransformation/NaturalTransformations.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.835443038, "max_line_length": 197, "alphanum_fraction": 0.6593304402, "num_tokens": 1419, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9019206686206199, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.6394790056627624}} {"text": "{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-}\n\nmodule Light.Library.Relation where\n\nopen import Light.Level using (Level ; Setω)\nopen import Light.Variable.Sets\n\nrecord Kind : Setω where\n field\n iℓ : Level\n Index : Set iℓ\n ℓf : Index → Level\n Proposition : ∀ i → Set (ℓf i)\n\nrecord Style (kind : Kind) : Setω where\n open Kind kind\n field\n true‐i false‐i : Index\n true : Proposition true‐i\n false : Proposition false‐i\n \n ¬‐index‐f : Index → Index\n ¬_ : ∀ {i} → Proposition i → Proposition (¬‐index‐f i)\n \n ∧‐index‐f ∨‐index‐f ⇢‐index‐f : Index → Index → Index\n _∧_ : ∀ {ia ib} → Proposition ia → Proposition ib → Proposition (∧‐index‐f ia ib)\n _∨_ : ∀ {ia ib} → Proposition ia → Proposition ib → Proposition (∨‐index‐f ia ib)\n _⇢_ : ∀ {ia ib} → Proposition ia → Proposition ib → Proposition (⇢‐index‐f ia ib)\n \n true‐set‐ℓf false‐set‐ℓf : Index → Level\n True : ∀ {i} → Proposition i → Set (true‐set‐ℓf i)\n False : ∀ {i} → Proposition i → Set (false‐set‐ℓf i)\n true‐is‐true : True true\n false‐is‐false : False false\n\nrecord Base : Setω where\n field ⦃ kind ⦄ : Kind\n field ⦃ style ⦄ : Style kind\n\nopen Kind ⦃ ... ⦄ public\nopen Style ⦃ ... ⦄ public\n", "meta": {"hexsha": "000712144e5afee093cf78d88f3f85a684bc2197", "size": 1436, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Light/Library/Relation.agda", "max_stars_repo_name": "zamfofex/lightlib", "max_stars_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_stars_repo_licenses": ["0BSD"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z", "max_issues_repo_path": "Light/Library/Relation.agda", "max_issues_repo_name": "Zambonifofex/lightlib", "max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_issues_repo_licenses": ["0BSD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Light/Library/Relation.agda", "max_forks_repo_name": "Zambonifofex/lightlib", "max_forks_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_forks_repo_licenses": ["0BSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.1904761905, "max_line_length": 93, "alphanum_fraction": 0.5389972145, "num_tokens": 420, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9059898254600903, "lm_q2_score": 0.7057850340255387, "lm_q1q2_score": 0.6394340597891417}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Ways to give instances of certain structures where some fields can\n-- be given in terms of others\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary using (Rel; Setoid; IsEquivalence)\n\nmodule Algebra.Structures.Biased\n {a ℓ} {A : Set a} -- The underlying set\n (_≈_ : Rel A ℓ) -- The underlying equality relation\n where\n\nopen import Algebra.Core\nopen import Algebra.Definitions _≈_\nopen import Algebra.Structures _≈_\nimport Algebra.Consequences.Setoid as Consequences\nopen import Data.Product using (_,_; proj₁; proj₂)\nopen import Level using (_⊔_)\n\n------------------------------------------------------------------------\n-- IsCommutativeMonoid\n\nrecord IsCommutativeMonoidˡ (∙ : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where\n field\n isSemigroup : IsSemigroup ∙\n identityˡ : LeftIdentity ε ∙\n comm : Commutative ∙\n\n open IsSemigroup isSemigroup\n\n private\n\n identityʳ : RightIdentity ε ∙\n identityʳ = Consequences.comm+idˡ⇒idʳ setoid comm identityˡ\n\n identity : Identity ε ∙\n identity = (identityˡ , identityʳ)\n\n isCommutativeMonoid : IsCommutativeMonoid ∙ ε\n isCommutativeMonoid = record\n { isMonoid = record\n { isSemigroup = isSemigroup\n ; identity = identity\n }\n ; comm = comm\n }\n\nopen IsCommutativeMonoidˡ public\n using () renaming (isCommutativeMonoid to isCommutativeMonoidˡ)\n\n\nrecord IsCommutativeMonoidʳ (∙ : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where\n field\n isSemigroup : IsSemigroup ∙\n identityʳ : RightIdentity ε ∙\n comm : Commutative ∙\n\n open IsSemigroup isSemigroup\n\n private\n\n identityˡ : LeftIdentity ε ∙\n identityˡ = Consequences.comm+idʳ⇒idˡ setoid comm identityʳ\n\n identity : Identity ε ∙\n identity = (identityˡ , identityʳ)\n\n isCommutativeMonoid : IsCommutativeMonoid ∙ ε\n isCommutativeMonoid = record\n { isMonoid = record\n { isSemigroup = isSemigroup\n ; identity = identity\n }\n ; comm = comm\n }\n\nopen IsCommutativeMonoidʳ public\n using () renaming (isCommutativeMonoid to isCommutativeMonoidʳ)\n\n\n------------------------------------------------------------------------\n-- IsCommutativeSemiring\n\nrecord IsCommutativeSemiringˡ (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ) where\n field\n +-isCommutativeMonoid : IsCommutativeMonoid + 0#\n *-isCommutativeMonoid : IsCommutativeMonoid * 1#\n distribʳ : * DistributesOverʳ +\n zeroˡ : LeftZero 0# *\n\n private\n module +-CM = IsCommutativeMonoid +-isCommutativeMonoid\n open module *-CM = IsCommutativeMonoid *-isCommutativeMonoid public\n using () renaming (comm to *-comm)\n\n distribˡ : * DistributesOverˡ +\n distribˡ = Consequences.comm+distrʳ⇒distrˡ\n +-CM.setoid +-CM.∙-cong *-comm distribʳ\n\n distrib : * DistributesOver +\n distrib = (distribˡ , distribʳ)\n\n zeroʳ : RightZero 0# *\n zeroʳ = Consequences.comm+zeˡ⇒zeʳ +-CM.setoid *-comm zeroˡ\n\n zero : Zero 0# *\n zero = (zeroˡ , zeroʳ)\n\n isCommutativeSemiring : IsCommutativeSemiring + * 0# 1#\n isCommutativeSemiring = record\n { isSemiring = record\n { isSemiringWithoutAnnihilatingZero = record\n { +-isCommutativeMonoid = +-isCommutativeMonoid\n ; *-isMonoid = *-CM.isMonoid\n ; distrib = distrib\n }\n ; zero = zero\n }\n ; *-comm = *-comm\n }\n\nopen IsCommutativeSemiringˡ public\n using () renaming (isCommutativeSemiring to isCommutativeSemiringˡ)\n\n\nrecord IsCommutativeSemiringʳ (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ) where\n field\n +-isCommutativeMonoid : IsCommutativeMonoid + 0#\n *-isCommutativeMonoid : IsCommutativeMonoid * 1#\n distribˡ : * DistributesOverˡ +\n zeroʳ : RightZero 0# *\n\n private\n module +-CM = IsCommutativeMonoid +-isCommutativeMonoid\n open module *-CM = IsCommutativeMonoid *-isCommutativeMonoid public\n using () renaming (comm to *-comm)\n\n distribʳ : * DistributesOverʳ +\n distribʳ = Consequences.comm+distrˡ⇒distrʳ\n +-CM.setoid +-CM.∙-cong *-comm distribˡ\n\n distrib : * DistributesOver +\n distrib = (distribˡ , distribʳ)\n\n zeroˡ : LeftZero 0# *\n zeroˡ = Consequences.comm+zeʳ⇒zeˡ +-CM.setoid *-comm zeroʳ\n\n zero : Zero 0# *\n zero = (zeroˡ , zeroʳ)\n\n isCommutativeSemiring : IsCommutativeSemiring + * 0# 1#\n isCommutativeSemiring = record\n { isSemiring = record\n { isSemiringWithoutAnnihilatingZero = record\n { +-isCommutativeMonoid = +-isCommutativeMonoid\n ; *-isMonoid = *-CM.isMonoid\n ; distrib = distrib\n }\n ; zero = zero\n }\n ; *-comm = *-comm\n }\n\nopen IsCommutativeSemiringʳ public\n using () renaming (isCommutativeSemiring to isCommutativeSemiringʳ)\n\n\n------------------------------------------------------------------------\n-- IsRing\n\n-- We can recover a ring without proving that 0# annihilates *.\nrecord IsRingWithoutAnnihilatingZero (+ * : Op₂ A) (-_ : Op₁ A) (0# 1# : A)\n : Set (a ⊔ ℓ) where\n field\n +-isAbelianGroup : IsAbelianGroup + 0# -_\n *-isMonoid : IsMonoid * 1#\n distrib : * DistributesOver +\n\n private\n\n module + = IsAbelianGroup +-isAbelianGroup\n module * = IsMonoid *-isMonoid\n\n open + using (setoid) renaming (∙-cong to +-cong)\n open * using () renaming (∙-cong to *-cong)\n\n zeroˡ : LeftZero 0# *\n zeroˡ = Consequences.assoc+distribʳ+idʳ+invʳ⇒zeˡ setoid\n +-cong *-cong +.assoc (proj₂ distrib) +.identityʳ +.inverseʳ\n\n zeroʳ : RightZero 0# *\n zeroʳ = Consequences.assoc+distribˡ+idʳ+invʳ⇒zeʳ setoid\n +-cong *-cong +.assoc (proj₁ distrib) +.identityʳ +.inverseʳ\n\n zero : Zero 0# *\n zero = (zeroˡ , zeroʳ)\n\n isRing : IsRing + * -_ 0# 1#\n isRing = record\n { +-isAbelianGroup = +-isAbelianGroup\n ; *-isMonoid = *-isMonoid\n ; distrib = distrib\n ; zero = zero\n }\n\nopen IsRingWithoutAnnihilatingZero public\n using () renaming (isRing to isRingWithoutAnnihilatingZero)\n", "meta": {"hexsha": "fe3f5b88774a207da90f77901a265895e06cefda", "size": 6158, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Algebra/Structures/Biased.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Algebra/Structures/Biased.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Algebra/Structures/Biased.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 29.0471698113, "max_line_length": 75, "alphanum_fraction": 0.610100682, "num_tokens": 1941, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8976952948443462, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.639367486111325}} {"text": "\nmodule _ where\n\ndata Sigma (A : Set)(B : A → Set) : Set where\n _,_ : (x : A) → B x → Sigma A B\n\nrecord Top : Set where\n\n_o_ : {A B : Set}{C : Set1} →\n (f : B → C) → (g : A → B) → (A → C)\nf o g = \\ x → f (g x)\n\nmutual\n data U : Set where\n top : U\n sig : (X : U) → (T X → U) → U\n\n T : U → Set\n T top = Top\n T (sig a b) = Sigma (T a) (T o b)\n", "meta": {"hexsha": "3906b24d5e03224d32031bd172ad0479b609748a", "size": 357, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue695.agda", "max_stars_repo_name": "hborum/agda", "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_issues_repo_path": "test/Succeed/Issue695.agda", "max_issues_repo_name": "hborum/agda", "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_forks_repo_path": "test/Succeed/Issue695.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 17.0, "max_line_length": 45, "alphanum_fraction": 0.4369747899, "num_tokens": 160, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8976952866333483, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.639367480263188}} {"text": "open import Type\n\nmodule Graph.Properties.Proofs where\n\nopen import Data.Either.Proofs\nopen import Functional\nopen import Function.Equals\nopen import Lang.Instance\nopen import Logic\nopen import Logic.Propositional\nopen import Logic.Propositional.Theorems\nimport Lvl\nopen import Graph\nopen import Graph.Properties\nopen import Relator.Equals.Proofs.Equiv\nopen import Structure.Setoid.Uniqueness\nopen import Structure.Relator.Properties\nopen import Type.Properties.Singleton\n\nmodule _ {ℓ₁ ℓ₂} {V : Type{ℓ₁}} (_⟶_ : Graph{ℓ₁}{ℓ₂}(V)) where\n instance\n undirect-undirected : Undirected(undirect(_⟶_))\n Undirected.reversable undirect-undirected = intro [∨]-symmetry\n Undirected.reverse-involution undirect-undirected = intro (_⊜_.proof swap-involution)\n\n -- [++]-visits : ∀{ae be a₁ b₁ a₂ b₂}{e : ae ⟶ be}{w₁ : Walk(_⟶_) a₁ b₁}{w₂ : Walk(_⟶_) a₂ b₂} → (Visits(_⟶_) e w₁) ∨ (Visits(_⟶_) e w₂) → Visits(_⟶_) e (w₁ ++ w₂)\n\n complete-singular-is-undirected : ⦃ CompleteWithLoops(_⟶_) ⦄ → ⦃ Singular(_⟶_) ⦄ → Undirected(_⟶_)\n Undirected.reversable complete-singular-is-undirected = intro(const (completeWithLoops(_⟶_)))\n Undirected.reverse-involution complete-singular-is-undirected = intro(singular(_⟶_))\n\n -- traceable-is-connected : ⦃ Traceable(_⟶_) ⦄ → Connected(_⟶_)\n", "meta": {"hexsha": "18010979c3a76485df33a30c3db24bd093d69ab8", "size": 1296, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Graph/Properties/Proofs.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Graph/Properties/Proofs.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Graph/Properties/Proofs.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.2727272727, "max_line_length": 165, "alphanum_fraction": 0.7307098765, "num_tokens": 412, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9230391664210672, "lm_q2_score": 0.6926419894793248, "lm_q1q2_score": 0.6393356845972256}} {"text": "{-\n\nType-level differentiation in Agda; or differentiation of functors!\n\nMost things below are just restatements of elementary category theory.\n\nThe new things are Diff, which defines the derivative of an arbitrary\nfunctor from Set to Set, and _+++_ _***_ _∘∘∘_ which show how to\ndifferentiate sums, products and compositions of such functors.\n\n-}\n\n{-# OPTIONS --type-in-type #-} -- needed in (fun (Diff f) x)\nmodule DiffFunctor where\n\n-- ( syntax )\ninfix 6 _[_]\ninfix 5 _∘∘_\ninfix 5 _∘∘∘_\ninfix 4 _**_\ninfix 4 _***_\ninfix 3 _++_\ninfix 2 _=>_\n\n-- Numbers are formalised as sets!\nNum = Set\n\n-- ( addition of numbers )\ndata _+_ (a : Num) (b : Num) : Num where\n inl : a -> a + b\n inr : b -> a + b\n\n[_,_] : {a b c : Num} -> (a -> c) -> (b -> c) -> (a + b -> c)\n[ a , b ] (inl x) = a x\n[ a , b ] (inr x) = b x\n\nmap[+] : {a₀ b₀ a₁ b₁ : Num} -> (a₀ -> a₁) -> (b₀ -> b₁) -> (a₀ + b₀ -> a₁ + b₁)\nmap[+] a b (inl x) = inl (a x)\nmap[+] a b (inr x) = inr (b x)\n\n-- ( multiplication of numbers )\ndata _*_ (a : Num) (b : Num) : Num where\n pair : a -> b -> a * b\n\n⟨_,_⟩ : {a b c : Num} -> (c -> a) -> (c -> b) -> (c -> a * b)\n⟨ a , b ⟩ x = pair (a x) (b x)\n\nmap[*] : {a₀ b₀ a₁ b₁ : Num} -> (a₀ -> a₁) -> (b₀ -> b₁) -> (a₀ * b₀ -> a₁ * b₁)\nmap[*] a b (pair x y) = pair (a x) (b y)\n\n-- Functions are formalised as functors!\nrecord Fun : Set where\n constructor _[_]\n field\n fun : Num -> Num\n map : {x y : Num} -> (u : x -> y) -> (fun x -> fun y)\n\nopen Fun\n\n-- ( pointwise addition of functions )\n_++_ : Fun -> Fun -> Fun\nfun (f ++ g) x = fun f x + fun g x\nmap (f ++ g) u = map[+] (map f u) (map g u)\n\n-- ( pointwise multiplication of functions )\n_**_ : Fun -> Fun -> Fun\nfun (f ** g) x = fun f x * fun g x\nmap (f ** g) u = map[*] (map f u) (map g u)\n\n-- ( composition of functions )\n_∘∘_ : Fun -> Fun -> Fun\nfun (f ∘∘ g) x = fun f (fun g x)\nmap (f ∘∘ g) u = map f (map g u)\n\n-- Differentiation is parametric consumption of a resource!\n-- You are supposed to use dx : h precisely once, like in linear logic.\nDiff : Fun -> Fun\nfun (Diff f) x = {h : Num} -> (dx : h) -> fun f (x + h)\nmap (Diff f) u f[x+·] dx = map f (map[+] u (\\dx -> dx)) (f[x+·] dx)\n\n-- A differentiation rule is a natural transformation! (in reverse)\n_=>_ : Fun -> Fun -> Set\nf => g = ((x : Num) -> fun f x -> fun g x)\n-- (omitting naturality conditions)\n\n-- ( derivative of sum )\n_+++_ : (f g : Fun) -> Diff f ++ Diff g => Diff (f ++ g)\n(f +++ g) x (inl f[x+·]) dx = inl (f[x+·] dx)\n(f +++ g) x (inr g[x+·]) dx = inr (g[x+·] dx)\n\n-- (derivative of product )\n_***_ : (f g : Fun) -> Diff f ** g ++ f ** Diff g => Diff (f ** g)\n(f *** g) x (inl (pair f[x+·] g[x])) dx = pair (f[x+·] dx) (map g inl g[x])\n(f *** g) x (inr (pair f[x] g[x+·])) dx = pair (map f inl f[x]) (g[x+·] dx)\n\n-- ( derivative of composition )\n_∘∘∘_ : (f g : Fun) -> Diff f ∘∘ g ** Diff g => Diff (f ∘∘ g)\n(f ∘∘∘ g) x (pair f[g[x]+·] g[x+·]) {h} dx = f[g[x+dx]]\n where\n f[g[x+dx]] : fun (f ∘∘ g) (x + h)\n f[g[x+dx]] = map f [ map g inl , g[x+·] ] (f[g[x]+·] dx)\n\n{-\n\nThings that need to be done:\n - Define higher order derivatives as follows:\n HighDiff n f x = forall h. h |n| -> f (x + h)\n Here h |n| stands for n copies of the resource h. Try to show\n n! -> Diff^n f => HighDiff n f.\n - Explore differential calculus in several variables.\n - Explore integration and differential equations. (hard)\n - Solve partial differential equations. (good luck)\n - Explore inverse functions. (hard)\n - Write some examples, such as\n 0 => Diff (Const a)\n 1 => Diff Id\n n * Id^(n-1) => Diff Id^n\n List ** List => Diff List\n derivatives of linear transformations\n\n-}\n", "meta": {"hexsha": "c92356c9fd5d84c2b9570b84cb4f2fd025b3c0e9", "size": 3633, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "DiffFunctor.agda", "max_stars_repo_name": "JoelSjogren/diff-functor", "max_stars_repo_head_hexsha": "e56caa8dfeb8d5a033ae2f06782bbeb67ced58d1", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "DiffFunctor.agda", "max_issues_repo_name": "JoelSjogren/diff-functor", "max_issues_repo_head_hexsha": "e56caa8dfeb8d5a033ae2f06782bbeb67ced58d1", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "DiffFunctor.agda", "max_forks_repo_name": "JoelSjogren/diff-functor", "max_forks_repo_head_hexsha": "e56caa8dfeb8d5a033ae2f06782bbeb67ced58d1", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.7786885246, "max_line_length": 80, "alphanum_fraction": 0.5428020919, "num_tokens": 1359, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9099070158103778, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.6392370337085896}} {"text": "module Cats.Profunctor where\n\nopen import Data.Product using (_,_)\nopen import Level using (suc ; _⊔_)\n\nopen import Cats.Category\nopen import Cats.Category.Op using (_ᵒᵖ)\nopen import Cats.Category.Product.Binary using (_×_)\nopen import Cats.Category.Setoids using (Setoids)\nopen import Cats.Functor\n\nimport Cats.Category.Cat as Cat\nimport Cats.Category.Cat.Facts.Product as Cat\n\n\n-- The usual definition inverts C and D, so\n--\n-- Profunctor C D E = Functor (Dᵒᵖ × C) E\n--\n-- but that's just confusing.\nProfunctor : ∀ {lo la l≈ lo′ la′ l≈′ lo″ la″ l≈″}\n → Category lo la l≈\n → Category lo′ la′ l≈′\n → Category lo″ la″ l≈″\n → Set (lo ⊔ la ⊔ l≈ ⊔ lo′ ⊔ la′ ⊔ l≈′ ⊔ lo″ ⊔ la″ ⊔ l≈″)\nProfunctor C D E = Functor ((C ᵒᵖ) × D) E\n\n\nmodule Profunctor {lo la l≈ lo′ la′ l≈′ lo″ la″ l≈″}\n {C : Category lo la l≈}\n {D : Category lo′ la′ l≈′}\n {E : Category lo″ la″ l≈″}\n (F : Profunctor C D E)\n where\n\n private\n module C = Category C\n module D = Category D\n module E = Category E\n\n\n pobj : C.Obj → D.Obj → E.Obj\n pobj c d = fobj F (c , d)\n\n\n pmap : ∀ {c c′} (f : c′ C.⇒ c) {d d′} (g : d D.⇒ d′)\n → pobj c d E.⇒ pobj c′ d′\n pmap f g = fmap F (f , g)\n\n\n pmap₁ : ∀ {c c′ d} (f : c′ C.⇒ c)\n → pobj c d E.⇒ pobj c′ d\n pmap₁ f = pmap f D.id\n\n\n pmap₂ : ∀ {c d d′} (g : d D.⇒ d′)\n → pobj c d E.⇒ pobj c d′\n pmap₂ g = pmap C.id g\n\n\nopen Profunctor public\n\n\nFunctor→Profunctor₁ : ∀ {lo la l≈ lo′ la′ l≈′ lo″ la″ l≈″}\n → {C : Category lo la l≈} {D : Category lo′ la′ l≈′} {X : Category lo″ la″ l≈″}\n → Functor (C ᵒᵖ) D\n → Profunctor C X D\nFunctor→Profunctor₁ F = F Cat.∘ Cat.proj₁\n\n\nFunctor→Profunctor₂ : ∀ {lo la l≈ lo′ la′ l≈′ lo″ la″ l≈″}\n → {C : Category lo la l≈} {D : Category lo′ la′ l≈′} {X : Category lo″ la″ l≈″}\n → Functor C D\n → Profunctor X C D\nFunctor→Profunctor₂ F = F Cat.∘ Cat.proj₂\n", "meta": {"hexsha": "f2f4a76a001b0baef227f95f15f935312d931c03", "size": 1820, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Profunctor.agda", "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cats/Profunctor.agda", "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cats/Profunctor.agda", "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.9473684211, "max_line_length": 81, "alphanum_fraction": 0.5818681319, "num_tokens": 791, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9099070133672955, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.6392370206582011}} {"text": "\nmodule Dual where\n\nopen import Prelude using (flip)\nopen import Logic.Equivalence\nopen import Category\n\n_op : Cat -> Cat\nℂ@(cat _ _ _ _ _ _ _ _ _) op = cat Obj\n\t (\\A B -> B ─→ A)\n\t id\n\t (\\{_}{_}{_} -> flip _∘_)\n\t (\\{_}{_} -> Eq)\n\t (\\{_}{_}{_}{_}{_}{_}{_} -> flip cong)\n\t (\\{_}{_}{_} -> idR)\n\t (\\{_}{_}{_} -> idL)\n\t (\\{_}{_}{_}{_}{_}{_}{_} -> sym assoc)\n where open module C = Cat ℂ\n\n{-\nopen Poly-Cat\n\ndualObj : {ℂ : Cat} -> Obj ℂ -> Obj (ℂ op)\ndualObj {cat _ _ _ _ _ _ _ _ _}(obj A) = obj A\n\nundualObj : {ℂ : Cat} -> Obj (ℂ op) -> Obj ℂ\nundualObj {cat _ _ _ _ _ _ _ _ _}(obj A) = obj A\n\ndualdualArr : {ℂ : Cat}{A B : Obj ℂ} -> A ─→ B -> dualObj B ─→ dualObj A\ndualdualArr {cat _ _ _ _ _ _ _ _ _}{A = obj _}{B = obj _}(arr f) = arr f\n\ndualundualArr : {ℂ : Cat}{A : Obj ℂ}{B : Obj (ℂ op)} ->\n\t\tA ─→ undualObj B -> B ─→ dualObj A\ndualundualArr {cat _ _ _ _ _ _ _ _ _}{A = obj _}{B = obj _}(arr f) = arr f\n-}\n", "meta": {"hexsha": "9f044991abb391970269ae23fcfd054bc44e8b1b", "size": 924, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/cat/Dual.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/cat/Dual.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/cat/Dual.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 25.6666666667, "max_line_length": 74, "alphanum_fraction": 0.5183982684, "num_tokens": 403, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9099070060380482, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.6392370155091845}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\nopen import groups.KernelImage\n\nmodule cohomology.ChainComplex where\n\n record ChainComplex i : Type (lsucc i) where\n field\n head : AbGroup i\n chain : ℕ → AbGroup i\n augment : AbGroup.grp (chain 0) →ᴳ AbGroup.grp head\n boundary : ∀ n → (AbGroup.grp (chain (S n)) →ᴳ AbGroup.grp (chain n))\n\n record CochainComplex i : Type (lsucc i) where\n field\n head : AbGroup i\n cochain : ℕ → AbGroup i\n augment : AbGroup.grp head →ᴳ AbGroup.grp (cochain 0)\n coboundary : ∀ n → (AbGroup.grp (cochain n) →ᴳ AbGroup.grp (cochain (S n)))\n\n homology-group : ∀ {i} → ChainComplex i\n → (n : ℤ) → Group i\n homology-group cc (pos 0) = Ker/Im cc.augment (cc.boundary 0) (snd (cc.chain 0))\n where module cc = ChainComplex cc\n homology-group cc (pos (S n)) = Ker/Im (cc.boundary n) (cc.boundary (S n)) (snd (cc.chain (S n)))\n where module cc = ChainComplex cc\n homology-group {i} cc (negsucc _) = Lift-group {j = i} Unit-group\n\n cohomology-group : ∀ {i} → CochainComplex i\n → (n : ℤ) → Group i\n cohomology-group cc (pos 0) = Ker/Im (cc.coboundary 0) cc.augment (snd (cc.cochain 0))\n where module cc = CochainComplex cc\n cohomology-group cc (pos (S n)) = Ker/Im (cc.coboundary (S n)) (cc.coboundary n) (snd (cc.cochain (S n)))\n where module cc = CochainComplex cc\n cohomology-group {i} cc (negsucc _) = Lift-group {j = i} Unit-group\n\n complex-dualize : ∀ {i j} → ChainComplex i → AbGroup j\n → CochainComplex (lmax i j)\n complex-dualize {i} {j} cc G = record {M} where\n module cc = ChainComplex cc\n module M where\n head : AbGroup (lmax i j)\n head = hom-abgroup (AbGroup.grp cc.head) G\n\n cochain : ℕ → AbGroup (lmax i j)\n cochain n = hom-abgroup (AbGroup.grp (cc.chain n)) G\n\n augment : AbGroup.grp head →ᴳ AbGroup.grp (cochain 0)\n augment = pre∘ᴳ-hom G cc.augment\n\n coboundary : ∀ n → (AbGroup.grp (cochain n) →ᴳ AbGroup.grp (cochain (S n)))\n coboundary n = pre∘ᴳ-hom G (cc.boundary n)\n", "meta": {"hexsha": "89ed69bd73e6c61363da66f3c55b03c54a248a68", "size": 2041, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/cohomology/ChainComplex.agda", "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "theorems/cohomology/ChainComplex.agda", "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "theorems/cohomology/ChainComplex.agda", "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "avg_line_length": 37.7962962963, "max_line_length": 107, "alphanum_fraction": 0.6335129838, "num_tokens": 695, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802507195635, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.6392239710749898}} {"text": "open import Numeral.Natural\nopen import Type\n\nmodule Formalization.ClassicalPredicateLogic.Syntax {ℓₚ ℓᵥ ℓₒ} (Prop : ℕ → Type{ℓₚ}) (Var : Type{ℓᵥ}) (Obj : ℕ → Type{ℓₒ}) where\n\nopen import Data.ListSized\nimport Lvl\nopen import Functional using (_∘_ ; _∘₂_ ; swap)\nopen import Sets.PredicateSet using (PredSet)\n\nprivate variable ℓ : Lvl.Level\nprivate variable n : ℕ\n\ndata Term : Type{ℓᵥ Lvl.⊔ ℓₒ} where\n var : Var → Term -- Variables\n func : Obj(n) → List(Term)(n) → Term -- Constants/functions\n\n-- Formulas.\n-- Inductive definition of the grammatical elements of the language of predicate logic.\ndata Formula : Type{ℓₚ Lvl.⊔ ℓᵥ Lvl.⊔ ℓₒ} where\n _$_ : Prop(n) → List(Term)(n) → Formula -- Relations\n\n ⊤ : Formula -- Tautology (Top / True)\n ⊥ : Formula -- Contradiction (Bottom / False)\n\n _∧_ : Formula → Formula → Formula -- Conjunction (And)\n _∨_ : Formula → Formula → Formula -- Disjunction (Or)\n _⟶_ : Formula → Formula → Formula -- Implication\n\n Ɐ : Var → Formula → Formula\n ∃ : Var → Formula → Formula\n\ninfix 1011 _$_\ninfixr 1005 _∧_\ninfixr 1004 _∨_\ninfixr 1000 _⟶_\n\n-- Negation\n¬_ : Formula → Formula\n¬_ = _⟶ ⊥\n\n-- Double negation\n¬¬_ : Formula → Formula\n¬¬_ = (¬_) ∘ (¬_)\n\n-- Reverse implication\n_⟵_ : Formula → Formula → Formula\n_⟵_ = swap(_⟶_)\n\n-- Equivalence\n_⟷_ : Formula → Formula → Formula\np ⟷ q = (p ⟵ q) ∧ (p ⟶ q)\n\n-- (Nor)\n_⊽_ : Formula → Formula → Formula\n_⊽_ = (¬_) ∘₂ (_∨_)\n\n-- (Nand)\n_⊼_ : Formula → Formula → Formula\n_⊼_ = (¬_) ∘₂ (_∧_)\n\n-- (Exclusive or / Xor)\n_⊻_ : Formula → Formula → Formula\n_⊻_ = (¬_) ∘₂ (_⟷_)\n\ninfix 1010 ¬_ ¬¬_\ninfixl 1000 _⟵_ _⟷_\n", "meta": {"hexsha": "cf4c5aff3c5a5c929fd468ed2fad143bc419458f", "size": 1607, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Formalization/ClassicalPredicateLogic/Syntax.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Formalization/ClassicalPredicateLogic/Syntax.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Formalization/ClassicalPredicateLogic/Syntax.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.6323529412, "max_line_length": 128, "alphanum_fraction": 0.6347230865, "num_tokens": 621, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802417938535, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.6392239648630677}} {"text": "module DerivedProps where\n\n{-\nopen import Relation.Binary.PropositionalEquality\nopen import Data.Nat hiding (_>_)\n-}\n\nopen import StdLibStuff\n\nopen import Syntax\nopen import STT\n\n\nlem3 : {n : ℕ} {Γ-t : Ctx n} (F G : Form Γ-t $o) → ⊢ ((F => (F => G)) => (F => G))\nlem3 F G = inf-V (inf-V ax-4-s ax-1-s) (inf-V (inf-V ax-4-s (inf-V ax-4-s ax-2-s)) ax-3-s)\n\nlem4 : {n : ℕ} {Γ-t : Ctx n} (F G H : Form Γ-t $o) →\n ⊢ ((F => (G => H)) => (G => (F => H)))\nlem4 F G H = inf-V (inf-V ax-4-s ax-1-s) (inf-V (inf-V ax-4-s (inf-V ax-4-s (inf-V (inf-V ax-4-s (inf-V (inf-V ax-4-s ax-3-s) ax-2-s)) ax-2-s))) (inf-V (inf-V ax-4-s ax-3-s) (inf-V ax-4-s (inf-V ax-4-s (inf-V (inf-V ax-4-s ax-3-s) ax-2-s)))))\n\nlem5 : {n : ℕ} {Γ-t : Ctx n} (F G : Form Γ-t $o) →\n ⊢ ((F => G) => (~ G => ~ F))\nlem5 F G = inf-V (inf-V ax-4-s ax-3-s) (inf-V ax-4-s (inf-V ax-3-s (inf-V (inf-V ax-4-s ax-1-s) ax-2-s)))\n\nlem6 : {n : ℕ} {Γ-t : Ctx n} (F G H : Form Γ-t $o) →\n ⊢ ((F => H) => ((F & G) => H))\nlem6 F G H = inf-V (inf-V ax-4-s ax-3-s) (inf-V (inf-V ax-4-s (inf-V ax-4-s (inf-V (inf-V ax-4-s (inf-V ax-3-s (inf-V (inf-V ax-4-s ax-1-s) ax-2-s))) ax-2-s))) ax-3-s)\n\nlem6b : {n : ℕ} {Γ-t : Ctx n} (F G H : Form Γ-t $o) →\n ⊢ ((G => H) => ((F & G) => H))\nlem6b F G H = inf-V (inf-V ax-4-s ax-3-s) (inf-V (inf-V ax-4-s (inf-V ax-4-s (inf-V (inf-V ax-4-s (inf-V ax-3-s (inf-V (inf-V ax-4-s ax-1-s) ax-2-s))) (inf-V (inf-V ax-4-s ax-3-s) ax-2-s)))) ax-3-s)\n\nlemb3 : {n : ℕ} {Γ-t : Ctx n} (F G : Form Γ-t $o) →\n ⊢ (F => ((F => G) => G))\nlemb3 F G = inf-V ax-1-s (inf-V (inf-V ax-4-s ax-3-s) (inf-V (inf-V ax-4-s ax-2-s) (inf-V (inf-V ax-4-s ax-2-s) (inf-V ax-3-s (inf-V ax-4-s (inf-V (inf-V ax-4-s ax-3-s) ax-2-s))))))\n\nlem7 : {n : ℕ} {Γ-t : Ctx n} (F G H : Form Γ-t $o) →\n ⊢ (F => ((G => H) => ((F => G) => H)))\nlem7 F G H = inf-V (inf-V ax-4-s (lem4 (F => G) (G => H) H)) (inf-V (inf-V ax-4-s (inf-V ax-4-s (lemb3 G H))) (lemb3 F G))\n\nlem8h : {n : ℕ} {Γ-t : Ctx n} (F G H : Form Γ-t $o) →\n ⊢ ((H => (F => G)) => ((H => F) => (H => G)))\nlem8h F G H = inf-V (inf-V ax-4-s ax-1-s) (inf-V (inf-V ax-4-s (inf-V ax-4-s (inf-V (inf-V ax-4-s ax-3-s) (inf-V (inf-V ax-4-s ax-2-s) ax-2-s)))) (inf-V (inf-V ax-4-s ax-3-s) (inf-V ax-4-s ax-4-s)))\n\nlem8 : {n : ℕ} {Γ-t : Ctx n} (X F G H : Form Γ-t $o) →\n ⊢ ((F => (G => H)) => ((X => F) => ((X => G) => (X => H))))\nlem8 X F G H = inf-V (inf-V ax-4-s (inf-V ax-4-s (lem8h G H X))) (inf-V (inf-V ax-4-s (lem8h F (G => H) X)) (inf-V (lem4 X (F => (G => H)) (F => (G => H))) (inf-V ax-3-s (inf-V ax-2-s (inf-V (inf-V ax-4-s ax-1-s) ax-2-s)))))\n\nlem8-3 : {n : ℕ} {Γ-t : Ctx n} (X F G H I : Form Γ-t $o) →\n ⊢ ((F => (G => (H => I))) => ((X => F) => ((X => G) => ((X => H) => (X => I)))))\nlem8-3 X F G H I = inf-V (inf-V ax-4-s (inf-V ax-4-s (inf-V ax-4-s (lem8h H I X)))) (inf-V (inf-V ax-4-s (inf-V ax-4-s (lem8h G (H => I) X))) (inf-V (inf-V ax-4-s (lem8h F (G => (H => I)) X)) (inf-V (lem4 X (F => (G => (H => I))) (F => (G => (H => I)))) (inf-V ax-3-s (inf-V ax-2-s (inf-V (inf-V ax-4-s ax-1-s) ax-2-s))))))\n\nlemb2 : {n : ℕ} {Γ-t : Ctx n} (F : Form Γ-t $o) →\n ⊢ (~ (~ F) => F)\nlemb2 F = inf-V ax-3-s (inf-V (inf-V ax-4-s (inf-V ax-3-s (inf-V (inf-V ax-4-s ax-1-s) ax-2-s))) (inf-V ax-3-s (inf-V (inf-V ax-4-s ax-1-s) ax-2-s)))\n\nlem2h2h : {n : ℕ} {Γ-t : Ctx n} (F : Form Γ-t $o) →\n ⊢ (F => ~ (~ F))\nlem2h2h F = inf-V ax-3-s (inf-V (inf-V ax-4-s ax-1-s) ax-2-s)\n\nlem2h2hb : {n : ℕ} {Γ-t : Ctx n} (F : Form Γ-t $o) →\n ⊢ (F => F)\nlem2h2hb F = inf-V (inf-V ax-4-s ax-1-s) ax-2-s\n\nlem2h2 : {n : ℕ} {Γ-t : Ctx n} (F G H : Form Γ-t $o) →\n ⊢ ((F || (G || H)) => ((F || G) || H))\nlem2h2 F G H = inf-V (inf-V ax-4-s (inf-V ax-4-s (lemb2 H))) (inf-V (inf-V ax-4-s ax-3-s) (inf-V (inf-V ax-4-s (inf-V ax-4-s ax-3-s)) (inf-V (inf-V ax-4-s (inf-V ax-4-s (inf-V ax-4-s (lemb2 F)))) (inf-V (inf-V ax-4-s (inf-V ax-4-s ax-3-s)) (inf-V (inf-V ax-4-s (lem4 (~ F) (~ H) G)) (inf-V (inf-V ax-4-s ax-3-s) (inf-V (inf-V ax-4-s (inf-V ax-4-s (lem2h2h F))) (inf-V (inf-V ax-4-s ax-3-s) (inf-V (inf-V ax-4-s (inf-V ax-4-s ax-3-s)) (inf-V (inf-V ax-4-s (inf-V ax-4-s (inf-V ax-4-s (lem2h2h H)))) (lem2h2hb (F || (G || H)))))))))))))\n\nlem2h1 : {n : ℕ} {Γ-t : Ctx n} (F G H : Form Γ-t $o) →\n ⊢ ((F => (G => H)) => ((F & G) => H))\nlem2h1 F G H = inf-V (inf-V ax-4-s ax-3-s) (inf-V (inf-V ax-4-s (inf-V ax-4-s (inf-V ax-3-s (inf-V (inf-V ax-4-s ax-1-s) ax-2-s)))) (inf-V (inf-V ax-4-s ax-3-s) (inf-V (inf-V ax-4-s (lem2h2 (~ F) (~ G) H)) (inf-V (inf-V ax-4-s ax-1-s) ax-2-s))))\n\nlemb1 : {n : ℕ} {Γ-t : Ctx n} (F G : Form Γ-t $o) →\n ⊢ (F => (G => (F & G)))\nlemb1 F G = inf-V ax-1-s (inf-V (inf-V ax-4-s ax-3-s) (inf-V (inf-V ax-4-s ax-2-s) (inf-V (inf-V ax-4-s ax-3-s) (inf-V (inf-V ax-4-s ax-2-s) (inf-V ax-3-s (inf-V ax-4-s ax-2-s))))))\n\n\nlem2 : {n : ℕ} {Γ-t : Ctx n} (F G H : Form Γ-t $o) → ⊢ (((F => G) & (F => H)) => (F => (G & H)))\nlem2 F G H = inf-V (lem2h1 (F => G) (F => H) (F => (G & H))) (inf-V (lem8 F G H (G & H)) (lemb1 G H))\n\n\nlem9 : {n : ℕ} {Γ-t : Ctx n} (F G H : Form Γ-t $o) →\n ⊢ ((F => G) => ((G => H) => (F => H)))\nlem9 F G H = inf-V (inf-V ax-4-s (lem4 F (G => H) H)) (inf-V (inf-V ax-4-s (inf-V ax-4-s (lemb3 G H))) (inf-V (lem4 F (F => G) G) (lemb3 F G)))\n\nlemb4 : {n : ℕ} {Γ-t : Ctx n} (F G : Form Γ-t $o) →\n ⊢ (F => (~ F => G))\nlemb4 F G = inf-V (inf-V ax-4-s ax-2-s) (inf-V ax-3-s (inf-V (inf-V ax-4-s ax-1-s) ax-2-s))\n\nlem5r : {n : ℕ} {Γ-t : Ctx n} (F G : Form Γ-t $o) →\n ⊢ ((~ F => ~ G) => (G => F))\nlem5r F G = inf-V (inf-V ax-4-s (inf-V ax-4-s (lemb2 F))) (inf-V (inf-V ax-4-s ax-3-s) (lem2h2hb (~ F => ~ G)))\n\nlemb5 : {n : ℕ} {Γ-t : Ctx n} (F G H : Form Γ-t $o) →\n ⊢ ((F => H) => ((G => H) => ((F || G) => H)))\nlemb5 F G H = inf-V (inf-V ax-4-s (inf-V ax-4-s (lem5r H (F || G)))) (inf-V (inf-V ax-4-s ax-3-s) (inf-V (inf-V ax-4-s (inf-V ax-4-s (inf-V (lem5 (G => H) (~ H => ~ G)) (lem5 G H)))) (inf-V (inf-V ax-4-s ax-3-s) (inf-V ax-3-s (inf-V (inf-V ax-4-s (inf-V (lem5 (F => H) (~ H => ~ F)) (lem5 F H))) (inf-V ax-3-s (inf-V (lem8 (~ H) (~ F) (~ G) (~ (F || G))) (inf-V (inf-V ax-4-s (inf-V ax-4-s (inf-V (lem5 (F || G) (~ (~ F) || ~ (~ G))) (inf-V (inf-V ax-4-s (inf-V ax-4-s (lem2h2h G))) (inf-V (inf-V ax-4-s ax-3-s) (inf-V (inf-V ax-4-s (inf-V ax-4-s (lem2h2h F))) (inf-V (inf-V ax-4-s ax-3-s) (lem2h2hb (F || G))))))))) (lemb1 (~ F) (~ G))))))))))\n\n\n-- ---------------\n\nlem10 : {n : ℕ} {Γ-t : Ctx n} (F : Form Γ-t $o) →\n ⊢ ((F => $false) => ~ F)\nlem10 F = inf-V ax-3-s (inf-V (inf-V ax-4-s (inf-V (lem5 (F => $false) (F => ~ F)) (inf-V ax-4-s (inf-V (inf-V ax-4-s (ax-5-s ($ this {refl}) (~ F))) (lem2h2hb (![ _ ] ($ this {refl}))))))) (inf-V ax-3-s ax-1-s))\n\nlem11 : {n : ℕ} {Γ-t : Ctx n} (F : Form Γ-t $o) →\n ⊢ ($false => F)\nlem11 F = inf-V (inf-V ax-4-s (ax-5-s ($ this {refl}) F)) (lem2h2hb (![ _ ] ($ this {refl})))\n\n\nlem12 : {n : ℕ} {Γ-t : Ctx n} {t : Type n} (F : Form Γ-t t) →\n ⊢ (F == F)\nlem12 {n} {Γ-t} {t} F = inf-V (inf-III-samectx {n} {Γ-t} {t} {t > $o} (λ z → (z · F)) (^[ t ] (![ t > $o ] (($ this {refl} · $ (next (next this)) {refl}) => ($ this {refl} · $ (next this) {refl})))) F) (inf-V (inf-III-samectx {n} {Γ-t} {t} {$o} (λ z → (z)) (![ t > $o ] (($ this {refl} · weak (weak F)) => ($ this {refl} · $ (next this) {refl}))) F) (inf-VI-s (subst (λ z → ⊢ ((($ this {refl} · z) => ($ this {refl} · weak F)))) (sub-weak-p-1 F F) (inf-V (inf-V ax-4-s ax-1-s) ax-2-s))))\n\n\nlem13 : {n : ℕ} {Γ-t : Ctx n} (F G : Form Γ-t $o) →\n ⊢ ((G == F) => (F => G))\nlem13 F G =\n inf-V (inf-III-samectx (λ z → ((z · F) => (F => G))) (^[ $o ] (![ $o > $o ] (($ this {refl} · $ (next (next this)) {refl}) => ($ this {refl} · $ (next this) {refl})))) G) (\n inf-V (inf-III-samectx (λ z → (z => (F => G))) (![ $o > $o ] (($ this {refl} · weak (weak G)) => ($ this {refl} · $ (next this) {refl}))) F) (\n subst (λ z → ⊢ ((![ $o > $o ] (($ this {refl} · z) => ($ this {refl} · weak F))) => (F => G))) (sub-weak-p-1 G F) (\n inf-V ax-3-s (\n inf-V (inf-V ax-4-s (inf-V (lem5 (![ $o > $o ] (($ this {refl} · weak G) => ($ this {refl} · weak F))) (((^[ $o ] ~ ($ this {refl})) · sub (^[ $o ] ~ ($ this {refl})) (weak G)) => ((^[ $o ] ~ ($ this {refl})) · sub (^[ $o ] ~ ($ this {refl})) (weak F))))\n (ax-5-s (($ this {refl} · weak G) => ($ this {refl} · weak F)) (^[ $o ] ~ ($ this {refl}))))) (\n inf-V ax-3-s (\n subst (λ z → ⊢ ((((^[ $o ] ~ ($ this {refl})) · z) => ((^[ $o ] ~ ($ this {refl})) · sub (^[ $o ] ~ ($ this {refl})) (weak F))) => (F => G))) (sub-weak-p-1' G (^[ $o ] ~ ($ this {refl}))) (\n subst (λ z → ⊢ ((((^[ $o ] ~ ($ this {refl})) · G) => ((^[ $o ] ~ ($ this {refl})) · z)) => (F => G))) (sub-weak-p-1' F (^[ $o ] ~ ($ this {refl}))) (\n inf-V (inf-III-samectx (λ z → ((z => ((^[ $o ] ~ ($ this {refl})) · F)) => (F => G))) (~ ($ this {refl})) G) (\n inf-V (inf-III-samectx (λ z → (((~ G) => z) => (F => G))) (~ ($ this {refl})) F) (\n lem5r G F\n ))))))))))\n \ntransitivity : {n : ℕ} {Γ-t : Ctx n} {t : Type n} (F G H : Form Γ-t t) →\n ⊢ ((F == G) => ((G == H) => (F == H)))\ntransitivity F G H = \n inf-V (inf-III-samectx (λ z → ((z · G) => ((G == H) => (F == H)))) (^[ _ ] (![ _ > $o ] (($ this {refl} · $ (next (next this)) {refl}) => ($ this {refl} · $ (next this) {refl})))) F) (\n inf-V (inf-III-samectx (λ z → (z => ((G == H) => (F == H)))) (![ _ > $o ] (($ this {refl} · weak (weak F)) => ($ this {refl} · $ (next this) {refl}))) G) (\n subst (λ z → ⊢ ((![ _ > $o ] (($ this {refl} · z) => ($ this {refl} · weak G))) => ((G == H) => (F == H)))) (sub-weak-p-1 F G) (\n inf-V (inf-III-samectx (λ z → ((![ _ > $o ] (($ this {refl} · weak F) => ($ this {refl} · weak G))) => ((z · H) => (F == H)))) (^[ _ ] (![ _ > $o ] (($ this {refl} · $ (next (next this)) {refl}) => ($ this {refl} · $ (next this) {refl})))) G) (\n inf-V (inf-III-samectx (λ z → ((![ _ > $o ] (($ this {refl} · weak F) => ($ this {refl} · weak G))) => (z => (F == H)))) (![ _ > $o ] (($ this {refl} · weak (weak G)) => ($ this {refl} · $ (next this) {refl}))) H) (\n subst (λ z → ⊢ ((![ _ > $o ] (($ this {refl} · weak F) => ($ this {refl} · weak G))) => ((![ _ > $o ] (($ this {refl} · z) => ($ this {refl} · weak H))) => (F == H)))) (sub-weak-p-1 G H) (\n inf-V (inf-III-samectx (λ z → ((![ _ > $o ] (($ this {refl} · weak F) => ($ this {refl} · weak G))) => ((![ _ > $o ] (($ this {refl} · weak G) => ($ this {refl} · weak H))) => (z · H)))) (^[ _ ] (![ _ > $o ] (($ this {refl} · $ (next (next this)) {refl}) => ($ this {refl} · $ (next this) {refl})))) F) (\n inf-V (inf-III-samectx (λ z → ((![ _ > $o ] (($ this {refl} · weak F) => ($ this {refl} · weak G))) => ((![ _ > $o ] (($ this {refl} · weak G) => ($ this {refl} · weak H))) => z))) (![ _ > $o ] (($ this {refl} · weak (weak F)) => ($ this {refl} · $ (next this) {refl}))) H) (\n subst (λ z → ⊢ ((![ _ > $o ] (($ this {refl} · weak F) => ($ this {refl} · weak G))) => ((![ _ > $o ] (($ this {refl} · weak G) => ($ this {refl} · weak H))) => (![ _ > $o ] (($ this {refl} · z) => ($ this {refl} · weak H)))))) (sub-weak-p-1 F H) (\n inf-V (inf-V ax-4-s (ax-6-s {_} {_} {_} {~ (![ _ ] (($ this {refl} · weak G) => ($ this {refl} · weak H)))} {($ this {refl} · weak F) => ($ this {refl} · weak H)})) (\n inf-V (ax-6-s {_} {_} {_} {~ (![ _ ] (($ this {refl} · weak F) => ($ this {refl} · weak G)))} {(weak (![ _ ] (($ this {refl} · weak G) => ($ this {refl} · weak H)))) => (($ this {refl} · weak F) => ($ this {refl} · weak H))}) (\n inf-VI-s (\n inf-V ax-3-s (\n inf-V (inf-V ax-4-s (inf-V (lem5 (![ _ ] (($ this {refl} · weak-i (_ ∷ ε) _ (weak F)) => ($ this {refl} · weak-i (_ ∷ ε) _ (weak G)))) (sub ($ this {refl}) (($ this {refl} · weak-i (_ ∷ ε) _ (weak F)) => ($ this {refl} · weak-i (_ ∷ ε) _ (weak G)))))\n (ax-5-s (($ this {refl} · weak-i (_ ∷ ε) _ (weak F)) => ($ this {refl} · weak-i (_ ∷ ε) _ (weak G))) ($ this {refl})))) (\n inf-V ax-3-s (\n inf-V (inf-V ax-4-s ax-3-s) (\n inf-V (inf-V ax-4-s (inf-V ax-4-s (inf-V (lem5 (![ _ ] (($ this {refl} · weak-i (_ ∷ ε) _ (weak G)) => ($ this {refl} · weak-i (_ ∷ ε) _ (weak H)))) (sub ($ this {refl}) (($ this {refl} · weak-i (_ ∷ ε) _ (weak G)) => ($ this {refl} · weak-i (_ ∷ ε) _ (weak H)))))\n (ax-5-s (($ this {refl} · weak-i (_ ∷ ε) _ (weak G)) => ($ this {refl} · weak-i (_ ∷ ε) _ (weak H))) ($ this {refl}))))) (\n inf-V (inf-V ax-4-s ax-3-s) (\n subst (λ z → ⊢ (((($ this {refl}) · z) => (($ this {refl}) · (sub ($ this {refl}) (weak-i (_ ∷ ε) _ (weak G))))) => (((($ this {refl}) · (sub ($ this {refl}) (weak-i (_ ∷ ε) _ (weak G)))) => (($ this {refl}) · (sub ($ this {refl}) (weak-i (_ ∷ ε) _ (weak H))))) => (($ this {refl} · weak F) => ($ this {refl} · weak H))))) (sub-weak-p-23 F ($ this {refl})) (\n subst (λ z → ⊢ (((($ this {refl}) · (weak F)) => (($ this {refl}) · z)) => (((($ this {refl}) · (sub ($ this {refl}) (weak-i (_ ∷ ε) _ (weak G)))) => (($ this {refl}) · (sub ($ this {refl}) (weak-i (_ ∷ ε) _ (weak H))))) => (($ this {refl} · weak F) => ($ this {refl} · weak H))))) (sub-weak-p-23 G ($ this {refl})) (\n subst (λ z → ⊢ (((($ this {refl}) · (weak F)) => (($ this {refl}) · (weak G))) => (((($ this {refl}) · z) => (($ this {refl}) · (sub ($ this {refl}) (weak-i (_ ∷ ε) _ (weak H))))) => (($ this {refl} · weak F) => ($ this {refl} · weak H))))) (sub-weak-p-23 G ($ this {refl})) (\n subst (λ z → ⊢ (((($ this {refl}) · (weak F)) => (($ this {refl}) · (weak G))) => (((($ this {refl}) · (weak G)) => (($ this {refl}) · z)) => (($ this {refl} · weak F) => ($ this {refl} · weak H))))) (sub-weak-p-23 H ($ this {refl})) (\n lem9 ($ this {refl} · weak F) ($ this {refl} · weak G) ($ this {refl} · weak H)\n ))))))))))))))))))))))\n\nlem14 : {n : ℕ} {Γ-t : Ctx n} {t : Type n} (F G H I : Form Γ-t t) →\n ⊢ ((F == G) => ((G == H) => ((H == I) => (F == I))))\nlem14 F G H I = inf-V (inf-V ax-4-s (inf-V ax-4-s (transitivity F H I))) (transitivity F G H)\n\nlem15 : {n : ℕ} {Γ-t : Ctx n} {t : Type n} (F G : Form Γ-t t) →\n ⊢ ((F == G) => (G == F))\nlem15 F G = \n inf-V (inf-III-samectx (λ z → ((z · G) => (G == F))) (^[ _ ] (![ _ > $o ] (($ this {refl} · $ (next (next this)) {refl}) => ($ this {refl} · $ (next this) {refl})))) F) (\n inf-V (inf-III-samectx (λ z → (z => (G == F))) (![ _ > $o ] (($ this {refl} · weak (weak F)) => ($ this {refl} · $ (next this) {refl}))) G) (\n subst (λ z → ⊢ ((![ _ > $o ] (($ this {refl} · z) => ($ this {refl} · weak G))) => (G == F))) (sub-weak-p-1 F G) (\n inf-V (inf-III-samectx (λ z → ((![ _ > $o ] (($ this {refl} · weak F) => ($ this {refl} · weak G))) => (z · F))) (^[ _ ] (![ _ > $o ] (($ this {refl} · $ (next (next this)) {refl}) => ($ this {refl} · $ (next this) {refl})))) G) (\n inf-V (inf-III-samectx (λ z → ((![ _ > $o ] (($ this {refl} · weak F) => ($ this {refl} · weak G))) => z)) (![ _ > $o ] (($ this {refl} · weak (weak G)) => ($ this {refl} · $ (next this) {refl}))) F) (\n subst (λ z → ⊢ ((![ _ > $o ] (($ this {refl} · weak F) => ($ this {refl} · weak G))) => (![ _ > $o ] (($ this {refl} · z) => ($ this {refl} · weak F))))) (sub-weak-p-1 G F) (\n inf-V (ax-6-s {_} {_} {_} {~ (![ _ ] (($ this {refl} · weak F) => ($ this {refl} · weak G)))} {($ this {refl} · weak G) => ($ this {refl} · weak F)}) (\n inf-VI-s (\n inf-V ax-3-s (\n inf-V (inf-V ax-4-s (inf-V (lem5 (![ _ ] (($ this {refl} · weak-i (_ ∷ ε) _ (weak F)) => ($ this {refl} · weak-i (_ ∷ ε) _ (weak G)))) (sub (^[ _ ] ~ ($ (next this) {refl} · $ this {refl})) (($ this {refl} · weak-i (_ ∷ ε) _ (weak F)) => ($ this {refl} · weak-i (_ ∷ ε) _ (weak G)))))\n (ax-5-s (($ this {refl} · weak-i (_ ∷ ε) _ (weak F)) => ($ this {refl} · weak-i (_ ∷ ε) _ (weak G))) (^[ _ ] ~ ($ (next this) {refl} · $ this {refl}))))) (\n inf-V ax-3-s (\n subst (λ z → ⊢ ((((^[ _ ] ~ ($ (next this) {refl} · $ this {refl})) · z) => ((^[ _ ] ~ ($ (next this) {refl} · $ this {refl})) · (sub (^[ _ ] ~ ($ (next this) {refl} · $ this {refl})) (weak-i (_ ∷ ε) _ (weak G))))) => (($ this {refl} · weak G) => ($ this {refl} · weak F)))) (sub-weak-p-23 F (^[ _ ] ~ ($ (next this) {refl} · $ this {refl}))) (\n subst (λ z → ⊢ ((((^[ _ ] ~ ($ (next this) {refl} · $ this {refl})) · (weak F)) => ((^[ _ ] ~ ($ (next this) {refl} · $ this {refl})) · z)) => (($ this {refl} · weak G) => ($ this {refl} · weak F)))) (sub-weak-p-23 G (^[ _ ] ~ ($ (next this) {refl} · $ this {refl}))) (\n inf-V (inf-III-samectx (λ z → ((z => ((^[ _ ] ~ ($ (next this) {refl} · $ this {refl})) · weak G)) => (($ this {refl} · weak G) => ($ this {refl} · weak F)))) (~ ($ (next this) {refl} · $ this {refl})) (weak F)) (\n inf-V (inf-III-samectx (λ z → (((~ ($ this {refl} · weak F)) => z) => (($ this {refl} · weak G) => ($ this {refl} · weak F)))) (~ ($ (next this) {refl} · $ this {refl})) (weak G)) (\n lem5r ($ this {refl} · weak F) ($ this {refl} · weak G)\n )))))))))))))))\n\nsubstitutivity : {n : ℕ} {Γ-t : Ctx n} {t u : Type n} (F G : Form Γ-t t) (H : Form Γ-t (t > u)) →\n ⊢ ((F == G) => ((H · F) == (H · G)))\nsubstitutivity F G H = \n inf-V (inf-III-samectx (λ z → ((z · G) => ((H · F) == (H · G)))) (^[ _ ] (![ _ > _ ] (($ this {refl} · $ (next (next this)) {refl}) => ($ this {refl} · $ (next this) {refl})))) F) (\n inf-V (inf-III-samectx (λ z → (z => ((H · F) == (H · G)))) (![ _ > _ ] (($ this {refl} · weak (weak F)) => ($ this {refl} · $ (next this) {refl}))) G) (\n subst (λ z → ⊢ ((![ _ > _ ] (($ this {refl} · z) => ($ this {refl} · weak G))) => ((H · F) == (H · G)))) (sub-weak-p-1 F G) (\n inf-V (inf-III-samectx (λ z → ((![ _ > _ ] (($ this {refl} · weak F) => ($ this {refl} · weak G))) => (z · (H · G)))) (^[ _ ] (![ _ > _ ] (($ this {refl} · $ (next (next this)) {refl}) => ($ this {refl} · $ (next this) {refl})))) ((H · F))) (\n inf-V (inf-III-samectx (λ z → ((![ _ > _ ] (($ this {refl} · weak F) => ($ this {refl} · weak G))) => z)) (![ _ > _ ] (($ this {refl} · weak (weak ((H · F)))) => ($ this {refl} · $ (next this) {refl}))) ((H · G))) (\n subst (λ z → ⊢ ((![ _ > _ ] (($ this {refl} · weak F) => ($ this {refl} · weak G))) => (![ _ > _ ] (($ this {refl} · z) => ($ this {refl} · weak ((H · G))))))) (sub-weak-p-1 ((H · F)) ((H · G))) (\n inf-V (ax-6-s {_} {_} {_} {~ (![ _ ] (($ this {refl} · weak F) => ($ this {refl} · weak G)))} {($ this {refl} · weak ((H · F))) => ($ this {refl} · weak ((H · G)))}) (\n inf-VI-s (\n inf-V ax-3-s (\n inf-V (inf-V ax-4-s (inf-V (lem5 (![ _ ] (($ this {refl} · weak-i (_ ∷ ε) _ (weak F)) => ($ this {refl} · weak-i (_ ∷ ε) _ (weak G)))) (sub (^[ _ ] ($ (next this) {refl} · (weak (weak H) · $ this {refl}))) (($ this {refl} · weak-i (_ ∷ ε) _ (weak F)) => ($ this {refl} · weak-i (_ ∷ ε) _ (weak G)))))\n (ax-5-s (($ this {refl} · weak-i (_ ∷ ε) _ (weak F)) => ($ this {refl} · weak-i (_ ∷ ε) _ (weak G))) (^[ _ ] ($ (next this) {refl} · (weak (weak H) · $ this {refl})))))) (\n inf-V ax-3-s (\n subst (λ z → ⊢ ((((^[ _ ] ($ (next this) {refl} · (weak (weak H) · $ this {refl}))) · z) => ((^[ _ ] ($ (next this) {refl} · (weak (weak H) · $ this {refl}))) · (sub (^[ _ ] ($ (next this) {refl} · (weak (weak H) · $ this {refl}))) (weak-i (_ ∷ ε) _ (weak G))))) => (($ this {refl} · weak (H · F)) => ($ this {refl} · weak (H · G))))) {-{weak F} {sub (^[ _ ] ($ (next this) {refl} · (weak (weak H) · $ this {refl}))) (weak-i (_ ∷ ε) _ (weak F))}-} (sub-weak-p-23 F (^[ _ ] ($ (next this) {refl} · (weak (weak H) · $ this {refl})))) (\n subst (λ z → ⊢ ((((^[ _ ] ($ (next this) {refl} · (weak (weak H) · $ this {refl}))) · (weak F)) => ((^[ _ ] ($ (next this) {refl} · (weak (weak H) · $ this {refl}))) · z)) => (($ this {refl} · weak (H · F)) => ($ this {refl} · weak (H · G))))) {-{weak G} {sub (^[ _ ] ($ (next this) {refl} · (weak (weak H) · $ this {refl}))) (weak-i (_ ∷ ε) _ (weak G))}-} (sub-weak-p-23 G (^[ _ ] ($ (next this) {refl} · (weak (weak H) · $ this {refl})))) (\n inf-V (inf-III-samectx (λ z → ((z => ((^[ _ ] ($ (next this) {refl} · (weak (weak H) · $ this {refl}))) · weak G)) => (($ this {refl} · weak (H · F)) => ($ this {refl} · weak (H · G))))) ($ (next this) {refl} · (weak (weak H) · $ this {refl})) (weak F)) (\n subst (λ z → ⊢ ((($ this {refl} · (z · weak F)) => ((^[ _ ] ($ (next this) {refl} · (weak (weak H) · $ this {refl}))) · weak G)) => (($ this {refl} · weak (H · F)) => ($ this {refl} · weak (H · G))))) {-{weak H} {sub (weak F) (weak (weak H))}-} (sub-weak-p-1' (weak H) (weak F)) (\n inf-V (inf-III-samectx (λ z → ((($ this {refl} · weak (H · F)) => z) => (($ this {refl} · weak (H · F)) => ($ this {refl} · weak (H · G))))) ($ (next this) {refl} · (weak (weak H) · $ this {refl})) (weak G)) (\n subst (λ z → ⊢ ((($ this {refl} · (weak (H · F))) => ($ this {refl} · (z · weak G))) => (($ this {refl} · weak (H · F)) => ($ this {refl} · weak (H · G))))) {-{weak H} {sub (weak G) (weak (weak H))}-} (sub-weak-p-1' (weak H) (weak G)) (\n lem2h2hb (($ this {refl} · weak (H · F)) => ($ this {refl} · (weak H · weak G)))\n )))))))))))))))))\n\n\nlem16 : {n : ℕ} {Γ-t : Ctx n} {α β : Type n} (F₁ F₂ : Form Γ-t (α > β)) (G₁ G₂ : Form Γ-t α) →\n ⊢ ((F₁ == F₂) => ((G₁ == G₂) => ((F₁ · G₁) == (F₂ · G₂))))\nlem16 F₁ F₂ G₁ G₂ =\n inf-V (inf-V (inf-V (lem8 (F₁ == F₂) ((G₁ == G₂) => ((F₁ · G₁) == (F₂ · G₁))) ((G₁ == G₂) => ((F₂ · G₁) == (F₂ · G₂))) ((G₁ == G₂) => ((F₁ · G₁) == (F₂ · G₂))))\n (inf-V (lem8 (G₁ == G₂) ((F₁ · G₁) == (F₂ · G₁)) ((F₂ · G₁) == (F₂ · G₂)) ((F₁ · G₁) == (F₂ · G₂))) (\n transitivity (F₁ · G₁) (F₂ · G₁) (F₂ · G₂))))\n (inf-V (lem4 (G₁ == G₂) (F₁ == F₂) ((F₁ · G₁) == (F₂ · G₁))) (inf-V ax-3-s (inf-V ax-2-s (\n subst (λ z → ⊢ ((F₁ == F₂) => ((F₁ · G₁) == (F₂ · z)))) (sym (sub-weak-p-1' G₁ F₂)) (\n inf-V (inf-II-samectx (λ z → ((F₁ == F₂) => ((F₁ · G₁) == z))) (($ this {refl}) · weak G₁) F₂) (\n subst (λ z → ⊢ ((F₁ == F₂) => ((F₁ · z) == ((^[ _ ] (($ this {refl}) · weak G₁)) · F₂)))) (sym (sub-weak-p-1' G₁ F₁)) (\n inf-V (inf-II-samectx (λ z → ((F₁ == F₂) => (z == ((^[ _ ] (($ this {refl}) · weak G₁)) · F₂)))) (($ this {refl}) · weak G₁) F₁) (\n substitutivity F₁ F₂ (^[ _ ] (($ this {refl}) · weak G₁))\n )))))))))\n (inf-V ax-3-s (inf-V ax-2-s (\n subst (λ z → ⊢ ((G₁ == G₂) => ((F₂ · G₁) == (z · G₂)))) (sym (sub-weak-p-1' F₂ G₂)) (\n inf-V (inf-II-samectx (λ z → ((G₁ == G₂) => ((F₂ · G₁) == z))) (weak F₂ · ($ this {refl})) G₂) (\n subst (λ z → ⊢ ((G₁ == G₂) => ((z · G₁) == ((^[ _ ] (weak F₂ · ($ this {refl}))) · G₂)))) (sym (sub-weak-p-1' F₂ G₁)) (\n inf-V (inf-II-samectx (λ z → ((G₁ == G₂) => (z == ((^[ _ ] (weak F₂ · ($ this {refl}))) · G₂)))) (weak F₂ · ($ this {refl})) G₁) (\n substitutivity G₁ G₂ (^[ _ ] (weak F₂ · ($ this {refl})))\n )))))))\n", "meta": {"hexsha": "f18bcec33bda9c0bedb1d0c8b2142c3a43b534c8", "size": 22396, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "soundness/DerivedProps.agda", "max_stars_repo_name": "frelindb/agsyHOL", "max_stars_repo_head_hexsha": "032efd5f42e4b56d436ac8e0c3c0f5127b8dc1f7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 17, "max_stars_repo_stars_event_min_datetime": "2015-09-04T14:38:28.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-19T20:53:45.000Z", "max_issues_repo_path": "soundness/DerivedProps.agda", "max_issues_repo_name": "frelindb/agsyHOL", "max_issues_repo_head_hexsha": "032efd5f42e4b56d436ac8e0c3c0f5127b8dc1f7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "soundness/DerivedProps.agda", "max_forks_repo_name": "frelindb/agsyHOL", "max_forks_repo_head_hexsha": "032efd5f42e4b56d436ac8e0c3c0f5127b8dc1f7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-17T20:28:10.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-15T11:51:19.000Z", "avg_line_length": 96.1201716738, "max_line_length": 644, "alphanum_fraction": 0.4273977496, "num_tokens": 9996, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9458012671214071, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.6391390159196073}} {"text": "{-# OPTIONS --without-K #-}\r\n\r\nmodule SEquivSCPermEquiv where\r\n\r\nopen import Level using (Level; _⊔_)\r\nopen import Data.Fin using (Fin) \r\nopen import Data.Product using (_,_; proj₁; proj₂)\r\nopen import Data.Vec using (tabulate)\r\nopen import Function using (_∘_; id)\r\n\r\nopen import Data.Vec.Properties using (lookup∘tabulate)\r\nopen import Relation.Binary using (Setoid)\r\nopen import Function.Equality using (_⟨$⟩_; _⟶_)\r\n renaming (_∘_ to _⊚_)\r\n\r\nopen import Relation.Binary.PropositionalEquality\r\n using (_≡_; refl; sym; trans; cong; module ≡-Reasoning)\r\n \r\n--\r\n\r\nopen import Proofs using (_!!_; finext)\r\nopen import Equiv using (_≃_; qinv; module isqinv)\r\nopen import EquivEquiv using (_S≃_; eq; _≋_; id≋)\r\nopen import ConcretePermutation using (CPerm; cp; _∘̂_; 1C; cauchyext; SCPerm)\r\nopen import ConcretePermutationProperties using (p≡)\r\n\r\n--\r\n\r\ninfix 4 _≃S_\r\n\r\n------------------------------------------------------------------------------\r\n-- The big (semantic) theorem!\r\n\r\n-- On one side we have the setoid of permutations under ≡\r\n-- On the other we have the setoid of equivalences under ≋\r\n-- \r\n-- The regular equivalence ≃ relates sets. To relate the above two\r\n-- setoids, this regular equivalence is generalized to an equivalence\r\n-- ≃S that relates setoids each with its own equivalence relation.\r\n\r\nrecord _≃S_ {ℓ₁ ℓ₂ ℓ₃ ℓ₄ : Level} (A : Setoid ℓ₁ ℓ₂) (B : Setoid ℓ₃ ℓ₄) : \r\n Set (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) where\r\n constructor equiv\r\n field\r\n f : A ⟶ B\r\n g : B ⟶ A\r\n α : ∀ {x y} → Setoid._≈_ B x y → Setoid._≈_ B ((f ⊚ g) ⟨$⟩ x) y\r\n β : ∀ {x y} → Setoid._≈_ A x y → Setoid._≈_ A ((g ⊚ f) ⟨$⟩ x) y\r\n\r\n-- Big theorem\r\n\r\nunivalence : ∀ {m n} → (SCPerm m n) ≃S (Fin m S≃ Fin n)\r\nunivalence {m} {n} = equiv fwd bwd α β \r\n where\r\n\r\n fwd' : (CPerm m n) → (Fin m ≃ Fin n)\r\n fwd' (cp π πᵒ αp βp) =\r\n (λ m → πᵒ !! m) ,\r\n let index = (λ n → π !! n) in qinv index pf₁ pf₂ \r\n where\r\n open ≡-Reasoning\r\n pf₁ : ∀ m → πᵒ !! (π !! m) ≡ m\r\n pf₁ m = begin (\r\n πᵒ !! (π !! m)\r\n ≡⟨ sym (lookup∘tabulate (λ x → πᵒ !! (π !! x)) m) ⟩\r\n (π ∘̂ πᵒ) !! m\r\n ≡⟨ cong (λ x → x !! m) αp ⟩\r\n 1C !! m\r\n ≡⟨ lookup∘tabulate id m ⟩\r\n m ∎)\r\n pf₂ : ∀ m → π !! (πᵒ !! m) ≡ m\r\n pf₂ m = begin (\r\n π !! (πᵒ !! m)\r\n ≡⟨ sym (lookup∘tabulate (λ x → π !! (πᵒ !! x)) m) ⟩\r\n (πᵒ ∘̂ π) !! m\r\n ≡⟨ cong (λ x → x !! m) βp ⟩\r\n 1C !! m\r\n ≡⟨ lookup∘tabulate id m ⟩\r\n m ∎)\r\n \r\n bwd' : (Fin m ≃ Fin n) → (CPerm m n)\r\n bwd' (f , qinv g α β) =\r\n cp (tabulate g) (tabulate f) g∘̂f≡1C f∘̂g≡1C\r\n where\r\n open ≡-Reasoning\r\n g∘̂f≡1C : tabulate g ∘̂ tabulate f ≡ 1C\r\n g∘̂f≡1C = finext (λ i → begin (\r\n tabulate f !! (tabulate g !! i)\r\n ≡⟨ lookup∘tabulate f (tabulate g !! i) ⟩\r\n f (tabulate g !! i)\r\n ≡⟨ cong f (lookup∘tabulate g i) ⟩\r\n f (g i)\r\n ≡⟨ α i ⟩\r\n i ∎))\r\n f∘̂g≡1C : tabulate f ∘̂ tabulate g ≡ 1C\r\n f∘̂g≡1C = finext (λ i → begin (\r\n tabulate g !! (tabulate f !! i)\r\n ≡⟨ lookup∘tabulate g (tabulate f !! i) ⟩\r\n g (tabulate f !! i)\r\n ≡⟨ cong g (lookup∘tabulate f i) ⟩\r\n g (f i)\r\n ≡⟨ β i ⟩\r\n i ∎))\r\n\r\n fwd : (SCPerm m n) ⟶ (Fin m S≃ Fin n)\r\n fwd = record\r\n { _⟨$⟩_ = fwd'\r\n ; cong = λ { {π} {.π} refl → id≋ }\r\n }\r\n\r\n bwd : (Fin m S≃ Fin n) ⟶ (SCPerm m n)\r\n bwd = record\r\n { _⟨$⟩_ = bwd'\r\n ; cong = λ eq₁≋eq₂ → p≡ (finext (_≋_.g≡ eq₁≋eq₂))\r\n }\r\n\r\n α : {eq₁ eq₂ : Fin m ≃ Fin n} → eq₁ ≋ eq₂ → (fwd ⊚ bwd ⟨$⟩ eq₁) ≋ eq₂\r\n α {eq₁} {eq₂} eq₁≋eq₂ =\r\n eq (λ x → trans (lookup∘tabulate (proj₁ eq₁) x) (_≋_.f≡ eq₁≋eq₂ x))\r\n (λ x → trans (lookup∘tabulate (isqinv.g (proj₂ eq₁)) x) (_≋_.g≡ eq₁≋eq₂ x)) \r\n\r\n β : {π₁ π₂ : CPerm m n} → π₁ ≡ π₂ → (bwd ⊚ fwd ⟨$⟩ π₁) ≡ π₂\r\n β {π} {.π} refl = p≡ (cauchyext (CPerm.π π)) \r\n\r\n\r\n", "meta": {"hexsha": "72ebdac0951b57bf72abc812dada0b1572edbfee", "size": 4081, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Univalence/SEquivSCPermEquiv.agda", "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_issues_repo_path": "Univalence/SEquivSCPermEquiv.agda", "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_forks_repo_path": "Univalence/SEquivSCPermEquiv.agda", "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "avg_line_length": 32.3888888889, "max_line_length": 86, "alphanum_fraction": 0.4790492526, "num_tokens": 1597, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.870597271765821, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.6391224623336287}} {"text": "--\n-- Created by Dependently-Typed Lambda Calculus on 2020-10-08\n-- Connective\n-- Author: dplaindoux\n--\n\n{-# OPTIONS --without-K #-}\n\nmodule Connective where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl)\nopen Eq.≡-Reasoning\nopen import Data.Nat using (ℕ)\nopen import Function using (_∘_)\nopen import Isomorphism using (_≃_; _≲_; extensionality)\nopen Isomorphism.≃-Reasoning\n\ndata _×_ (A B : Set) : Set where\n\n ⟨_,_⟩ :\n A\n → B\n -----\n → A × B\n\nproj₁ : ∀ {A B : Set}\n → A × B\n -----\n → A\nproj₁ ⟨ x , y ⟩ = x\n\nproj₂ : ∀ {A B : Set}\n → A × B\n -----\n → B\nproj₂ ⟨ x , y ⟩ = y\n\n", "meta": {"hexsha": "7b20fc3a7c019c85ee867b8a0b29a938a3b1b9f8", "size": 630, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/exercices/Connective.agda", "max_stars_repo_name": "d-plaindoux/colca", "max_stars_repo_head_hexsha": "a81447af3ab2ba898bb7d57be71369abbba12d81", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-03-12T18:31:14.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-04T09:35:36.000Z", "max_issues_repo_path": "src/exercices/Connective.agda", "max_issues_repo_name": "d-plaindoux/colca", "max_issues_repo_head_hexsha": "a81447af3ab2ba898bb7d57be71369abbba12d81", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/exercices/Connective.agda", "max_forks_repo_name": "d-plaindoux/colca", "max_forks_repo_head_hexsha": "a81447af3ab2ba898bb7d57be71369abbba12d81", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.1538461538, "max_line_length": 61, "alphanum_fraction": 0.5888888889, "num_tokens": 219, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8705972616934408, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.6391224448106696}} {"text": "------------------------------------------------------------------------------\n-- The gcd program is correct\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- This module proves the correctness of the gcd program using\n-- the Euclid's algorithm.\n\nmodule FOTC.Program.GCD.Partial.CorrectnessProofI where\n\nopen import FOTC.Base\nopen import FOTC.Data.Nat.Divisibility.NotBy0.PropertiesI\n using ( 0∤x ; x∣S→x≤S )\nopen import FOTC.Data.Nat.Type\nopen import FOTC.Program.GCD.Partial.CommonDivisorI using ( gcdCD )\nopen import FOTC.Program.GCD.Partial.Definitions\nopen import FOTC.Program.GCD.Partial.DivisibleI using ( gcdDivisible )\nopen import FOTC.Program.GCD.Partial.GCD using ( gcd )\n\nimport FOTC.Program.GCD.Partial.GreatestAnyCommonDivisor\nopen module GreatestAnyCommonDivisorI =\n FOTC.Program.GCD.Partial.GreatestAnyCommonDivisor x∣S→x≤S 0∤x\n using ( gcdGACD )\n\nopen import FOTC.Program.GCD.Partial.TotalityI using ( gcd-N )\n\n------------------------------------------------------------------------------\n-- The gcd is correct.\ngcdCorrect : ∀ {m n} → N m → N n → x≢0≢y m n → gcdSpec m n (gcd m n)\ngcdCorrect Nm Nn m≢0≢n = gcdCD Nm Nn m≢0≢n\n , gcdGACD (gcd-N Nm Nn m≢0≢n)\n (gcdCD Nm Nn m≢0≢n)\n (gcdDivisible Nm Nn m≢0≢n)\n", "meta": {"hexsha": "6e81d8ae38a9a060c5c673031626e8af013db8c0", "size": 1523, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/FOTC/Program/GCD/Partial/CorrectnessProofI.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/FOTC/Program/GCD/Partial/CorrectnessProofI.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/FOTC/Program/GCD/Partial/CorrectnessProofI.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 40.0789473684, "max_line_length": 78, "alphanum_fraction": 0.5561391989, "num_tokens": 404, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8933094117351309, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.6390949833943502}} {"text": "module Structure.Numeral.Integer.Proofs where\n\nopen import Data.Either as Either using (Left ; Right)\nimport Data.Tuple as Tuple\nopen import Functional\nopen import Function.Proofs\nopen import Logic.IntroInstances\nopen import Logic.Predicate\nopen import Logic.Propositional\nimport Lvl\nopen import Structure.Function.Domain\nopen import Structure.Function\nopen import Structure.Numeral.Integer\nopen import Structure.Relator\nopen import Structure.Relator.Proofs\nopen import Structure.Relator.Properties\nopen import Structure.Setoid\nopen import Structure.Operator\nopen import Structure.Operator.Properties\nopen import Structure.Operator.Ring.Proofs\nopen import Structure.Operator.Ring\nopen import Structure.OrderedField\nopen import Syntax.Implication\nopen import Syntax.Transitivity\nopen import Type\n\nprivate variable ℓₒ ℓₗ ℓₑ ℓₗ₁ ℓₗ₂ : Lvl.Level\nprivate variable Z : Type{ℓₒ}\nprivate variable _+_ _⋅_ : Z → Z → Z\nprivate variable _≤_ : Z → Z → Type{ℓₗ}\n\nmodule _ ⦃ equiv : Equiv{ℓₑ}(Z) ⦄ ⦃ int : Integer ⦃ equiv ⦄ (_+_)(_⋅_)(_≤_) ⦄ where\n open Integer(int)\n\n negative-induction : ∀{ℓ}{P : Z → Type{ℓ}} ⦃ rel-p : UnaryRelator(P) ⦄ → P(𝟎) → (∀{n} → (n ≤ 𝟎) → P(n) → P(𝐏(n))) → (∀{n} → (n ≤ 𝟎) → P(n))\n negative-induction {P = P} pz ps {n} neg =\n substitute₁(P) (involution(−_)) (positive-induction\n {P = P ∘ (−_)}\n ⦃ [∘]-unaryRelator ⦄\n (substitute₁ₗ(P) [−]-of-𝟎 pz)\n (\\{n} pos pnn → substitute₁ₗ(P) [+]-negation-distribution (ps{− n} ([↔]-to-[→] [≤]-flip-positive pos) pnn))\n {− n}\n ([↔]-to-[→] [≤]-flip-negative neg)\n )\n\n induction : ∀{ℓ}{P : Z → Type{ℓ}} ⦃ rel-p : UnaryRelator(P) ⦄ → P(𝟎) → (∀{n} → (n ≤ 𝟎) → P(n) → P(𝐏(n))) → (∀{n} → (𝟎 ≤ n) → P(n) → P(𝐒(n))) → (∀{n} → P(n))\n induction pz pp ps {n} with converseTotal(_≤_) {n}{𝟎}\n ... | Left neg = negative-induction pz pp neg\n ... | Right pos = positive-induction pz ps pos\n\n [⋅]-commutativity : Commutativity(_⋅_)\n [⋅]-commutativity = intro(induction{P = x ↦ ∀{y} → (x ⋅ y ≡ y ⋅ x)} ⦃ {!!} ⦄ base (const pred) (const succ)) where\n base : ∀{y} → (𝟎 ⋅ y ≡ y ⋅ 𝟎)\n base{y} =\n 𝟎 ⋅ y 🝖[ _≡_ ]-[ absorberₗ(_⋅_)(𝟎) ]\n 𝟎 🝖[ _≡_ ]-[ absorberᵣ(_⋅_)(𝟎) ]-sym\n y ⋅ 𝟎 🝖-end\n\n pred : ∀{x} → (∀{y} → (x ⋅ y ≡ y ⋅ x)) → (∀{y} → (𝐏(x) ⋅ y ≡ y ⋅ 𝐏(x)))\n pred {x} p {y} =\n 𝐏(x) ⋅ y 🝖[ _≡_ ]-[]\n (x − 𝟏) ⋅ y 🝖[ _≡_ ]-[ distributivityᵣ(_⋅_)(_−_) ⦃ [⋅][−]-distributivityᵣ ⦄ ]\n (x ⋅ y) − (𝟏 ⋅ y) 🝖[ _≡_ ]-[ congruence₂ᵣ(_−_) ⦃ [−]-binaryOperator ⦄ (_) (identityₗ(_⋅_)(𝟏)) ]\n (x ⋅ y) − y 🝖[ _≡_ ]-[ congruence₂ₗ(_−_) ⦃ [−]-binaryOperator ⦄ (_) p ]\n (y ⋅ x) − y 🝖[ _≡_ ]-[ congruence₂ᵣ(_−_) ⦃ [−]-binaryOperator ⦄ (_) (identityᵣ(_⋅_)(𝟏)) ]-sym\n (y ⋅ x) − (y ⋅ 𝟏) 🝖[ _≡_ ]-[ distributivityₗ(_⋅_)(_−_) ⦃ [⋅][−]-distributivityₗ ⦄ ]-sym\n y ⋅ (x − 𝟏) 🝖[ _≡_ ]-[]\n y ⋅ 𝐏(x) 🝖-end\n\n succ : ∀{x} → (∀{y} → (x ⋅ y ≡ y ⋅ x)) → (∀{y} → (𝐒(x) ⋅ y ≡ y ⋅ 𝐒(x)))\n succ {x} p {y} =\n 𝐒(x) ⋅ y 🝖[ _≡_ ]-[]\n (x + 𝟏) ⋅ y 🝖[ _≡_ ]-[ distributivityᵣ(_⋅_)(_+_) ]\n (x ⋅ y) + (𝟏 ⋅ y) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)(_) (identityₗ(_⋅_)(𝟏)) ]\n (x ⋅ y) + y 🝖[ _≡_ ]-[ congruence₂ₗ(_+_)(_) p ]\n (y ⋅ x) + y 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)(_) (identityᵣ(_⋅_)(𝟏)) ]-sym\n (y ⋅ x) + (y ⋅ 𝟏) 🝖[ _≡_ ]-[ distributivityₗ(_⋅_)(_+_) ]-sym\n y ⋅ (x + 𝟏) 🝖[ _≡_ ]-[]\n y ⋅ 𝐒(x) 🝖-end\n\n [≤]-identities : (𝟎 ≤ 𝟏)\n [≤]-identities with converseTotal(_≤_) {𝟎}{− 𝟏}\n ... | Left omi =\n omi ⇒\n (𝟎 ≤ (− 𝟏)) ⇒-[ swap apply₂ [≤][⋅]-zero ]\n (𝟎 ≤ ((− 𝟏) ⋅ (− 𝟏))) ⇒-[ _🝖 sub₂(_≡_)(_≤_) [⋅]-of-[−] ]\n (𝟎 ≤ (𝟏 ⋅ 𝟏)) ⇒-[ _🝖 sub₂(_≡_)(_≤_) (identityₗ(_⋅_)(𝟏)) ]\n (𝟎 ≤ 𝟏) ⇒-end\n ... | Right mio = [↔]-to-[←] [≤]-flip-positive mio\n\n [<]-identities : (𝟎 < 𝟏)\n [<]-identities = [≤][≢]-to-[<] [≤]-identities (NonZero.proof distinct-identities ∘ symmetry(_≡_))\n\n 𝐒-of-𝟎 : 𝐒(𝟎) ≡ 𝟏\n 𝐒-of-𝟎 =\n 𝐒(𝟎) 🝖[ _≡_ ]-[]\n 𝟎 + 𝟏 🝖[ _≡_ ]-[ identityₗ(_+_)(𝟎) ]\n 𝟏 🝖-end\n\n instance\n postulate 𝐒-function : Function(𝐒)\n -- 𝐒-function = {!!}\n\n instance\n postulate [<]-relator : BinaryRelator(_<_)\n -- [<]-relator = {![¬]-binaryRelator!}\n\n [≤]-with-𝐒 : ∀{x y} → (x ≤ y) → (𝐒(x) ≤ 𝐒(y))\n [≤]-with-𝐒 = [≤][+]ₗ-preserve\n\n [<]-with-𝐒 : ∀{x y} → (x < y) → (𝐒(x) < 𝐒(y))\n [<]-with-𝐒 = [<][+]-preserveₗ\n\n [≤]-with-𝐏 : ∀{x y} → (x ≤ y) → (𝐏(x) ≤ 𝐏(y))\n [≤]-with-𝐏 = [≤][−]ₗ-preserve\n\n [<]-with-𝐏 : ∀{x y} → (x < y) → (𝐏(x) < 𝐏(y))\n [<]-with-𝐏 = [<][+]-preserveₗ\n\n 𝐒-𝐏-inverse : ∀{x} → (𝐒(𝐏(x)) ≡ x)\n 𝐒-𝐏-inverse = associativity(_+_) 🝖 congruence₂ᵣ(_+_)(_) (inverseFunctionₗ(_+_)(−_)) 🝖 identityᵣ(_+_)(𝟎)\n\n 𝐏-𝐒-inverse : ∀{x} → (𝐏(𝐒(x)) ≡ x)\n 𝐏-𝐒-inverse = associativity(_+_) 🝖 congruence₂ᵣ(_+_)(_) (inverseFunctionᵣ(_+_)(−_)) 🝖 identityᵣ(_+_)(𝟎)\n\n 𝐒-order : ∀{x} → (x < 𝐒(x))\n 𝐒-order {x} = induction\n {P = x ↦ x < 𝐒(x)}\n ⦃ binary-unaryRelator ⦃ rel-P = [∘]-binaryRelator ⦄ ⦄\n (subtransitivityᵣ(_<_)(_≡_) [<]-identities (symmetry(_≡_) 𝐒-of-𝟎))\n (const (p ↦ subtransitivityᵣ(_<_)(_≡_) ([<]-with-𝐏 p) (𝐏-𝐒-inverse 🝖 symmetry(_≡_) 𝐒-𝐏-inverse)))\n (const [<]-with-𝐒)\n\n 𝐒-least-upper-bound : ∀{x m} → (x < m) → (𝐒(x) ≤ m)\n 𝐒-least-upper-bound {x}{m} xm with converseTotal(_≤_) {x}{m} | converseTotal(_≤_) {𝐒(x)}{m}\n ... | Left x₁ | Left x₂ = x₂\n ... | Left x₁ | Right x₂ = {!!} -- x\n\nBool-Path-to-Id : ∀{x y : Bool} → (Path x y) → (Id x y)\nBool-Path-to-Id {𝑇} {𝑇} _ = intro\nBool-Path-to-Id {𝑇} {𝐹} = [⊥]-elim ∘ Bool-different-values ∘ symmetry(Path)\nBool-Path-to-Id {𝐹} {𝑇} = [⊥]-elim ∘ Bool-different-values\nBool-Path-to-Id {𝐹} {𝐹} _ = intro\n", "meta": {"hexsha": "a3195564129b1feecc9494779df45a07a8f0b9de", "size": 711, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Boolean/Equiv/Path.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/Boolean/Equiv/Path.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Boolean/Equiv/Path.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.625, "max_line_length": 77, "alphanum_fraction": 0.7215189873, "num_tokens": 241, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.935346511643776, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.6384429674619284}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Categories.Functor.Base where\n\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Data.Sigma\n\nopen import Cubical.Categories.Category\n\nprivate\n variable\n ℓC ℓC' ℓD ℓD' : Level\n\nrecord Functor (C : Category ℓC ℓC') (D : Category ℓD ℓD') :\n Type (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD')) where\n no-eta-equality\n\n open Category\n\n field\n F-ob : C .ob → D .ob\n F-hom : {x y : C .ob} → C [ x , y ] → D [ F-ob x , F-ob y ]\n F-id : {x : C .ob} → F-hom (C .id) ≡ D .id {x = F-ob x}\n F-seq : {x y z : C .ob} (f : C [ x , y ]) (g : C [ y , z ])\n → F-hom (f ⋆⟨ C ⟩ g) ≡ (F-hom f) ⋆⟨ D ⟩ (F-hom g)\n\n isFull = (x y : _) (F[f] : D [ F-ob x , F-ob y ]) → ∃[ f ∈ C [ x , y ] ] F-hom f ≡ F[f]\n isFaithful = (x y : _) (f g : C [ x , y ]) → F-hom f ≡ F-hom g → f ≡ g\n isEssentiallySurj = (d : D .ob) → Σ[ c ∈ C .ob ] CatIso D (F-ob c) d\n\n F-square : {x y u v : C .ob}\n {f : C [ x , y ]} {g : C [ x , u ]}\n {h : C [ u , v ]} {k : C [ y , v ]}\n → f ⋆⟨ C ⟩ k ≡ g ⋆⟨ C ⟩ h\n → (F-hom f) ⋆⟨ D ⟩ (F-hom k) ≡ (F-hom g) ⋆⟨ D ⟩ (F-hom h)\n F-square Csquare = sym (F-seq _ _) ∙∙ cong F-hom Csquare ∙∙ F-seq _ _\n\n\nprivate\n variable\n ℓ ℓ' : Level\n C D E : Category ℓ ℓ'\n\nopen Category\nopen Functor\n\nFunctor≡ : {F G : Functor C D}\n → (h : ∀ (c : ob C) → F-ob F c ≡ F-ob G c)\n → (∀ {c c' : ob C} (f : C [ c , c' ]) → PathP (λ i → D [ h c i , h c' i ]) (F-hom F f) (F-hom G f))\n → F ≡ G\nF-ob (Functor≡ hOb hHom i) c = hOb c i\nF-hom (Functor≡ hOb hHom i) f = hHom f i\nF-id (Functor≡ {C = C} {D = D} {F = F} {G = G} hOb hHom i) =\n isProp→PathP (λ j → isSetHom D (hHom (C .id) j) (D .id)) (F-id F) (F-id G) i\nF-seq (Functor≡ {C = C} {D = D} {F = F} {G = G} hOb hHom i) f g =\n isProp→PathP (λ j → isSetHom D (hHom (f ⋆⟨ C ⟩ g) j) ((hHom f j) ⋆⟨ D ⟩ (hHom g j))) (F-seq F f g) (F-seq G f g) i\n\n\n\n-- Helpful notation\n\n-- action on objects\ninfix 30 _⟅_⟆\n_⟅_⟆ : (F : Functor C D)\n → C .ob\n → D .ob\n_⟅_⟆ = F-ob\n\n-- action on morphisms\ninfix 30 _⟪_⟫ -- same infix level as on objects since these will never be used in the same context\n_⟪_⟫ : (F : Functor C D)\n → ∀ {x y}\n → C [ x , y ]\n → D [(F ⟅ x ⟆) , (F ⟅ y ⟆)]\n_⟪_⟫ = F-hom\n\n\n-- Functor constructions\n\n𝟙⟨_⟩ : ∀ (C : Category ℓ ℓ') → Functor C C\n𝟙⟨ C ⟩ .F-ob x = x\n𝟙⟨ C ⟩ .F-hom f = f\n𝟙⟨ C ⟩ .F-id = refl\n𝟙⟨ C ⟩ .F-seq _ _ = refl\n\n-- functor composition\nfuncComp : ∀ (G : Functor D E) (F : Functor C D) → Functor C E\n(funcComp G F) .F-ob c = G ⟅ F ⟅ c ⟆ ⟆\n(funcComp G F) .F-hom f = G ⟪ F ⟪ f ⟫ ⟫\n(funcComp G F) .F-id = cong (G ⟪_⟫) (F .F-id) ∙ G .F-id\n(funcComp G F) .F-seq f g = cong (G ⟪_⟫) (F .F-seq _ _) ∙ G .F-seq _ _\n\ninfixr 30 funcComp\nsyntax funcComp G F = G ∘F F\n\n_^opF : Functor C D → Functor (C ^op) (D ^op)\n(F ^opF) .F-ob = F .F-ob\n(F ^opF) .F-hom = F .F-hom\n(F ^opF) .F-id = F .F-id\n(F ^opF) .F-seq f g = F .F-seq g f\n", "meta": {"hexsha": "161edd56a8b8402c3312c7a7ce364956159ce2e7", "size": 2955, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Functor/Base.agda", "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Categories/Functor/Base.agda", "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Categories/Functor/Base.agda", "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.2574257426, "max_line_length": 116, "alphanum_fraction": 0.4805414552, "num_tokens": 1397, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673133042217, "lm_q2_score": 0.7853085859124002, "lm_q1q2_score": 0.6383516803453503}} {"text": "module huffman-tree where\n\nopen import lib\n\ndata huffman-tree : Set where\n ht-leaf : string → ℕ → huffman-tree\n ht-node : ℕ → huffman-tree → huffman-tree → huffman-tree\n\n-- get the frequency out of a Huffman tree\nht-frequency : huffman-tree → ℕ\nht-frequency (ht-leaf _ f) = f\nht-frequency (ht-node f _ _) = f\n\n-- lower frequency nodes are considered smaller \nht-compare : huffman-tree → huffman-tree → 𝔹\nht-compare h1 h2 = (ht-frequency h1) < (ht-frequency h2)\n\n{- return (just s) if Huffman tree is an ht-leaf with string s;\n otherwise, return nothing (this is a constructor for the maybe type -- see maybe.agda in the IAL) -}\nht-string : huffman-tree → maybe string\nht-string (ht-leaf s f) = just s\nht-string _ = nothing\n\n-- several helper functions for ht-to-string (defined at the bottom)\nprivate \n -- helper function for ht-to-stringh\n ht-declare-node : huffman-tree → ℕ → string × string\n ht-declare-node h n = \n let cur = \"n\" ^ (ℕ-to-string n) in\n cur , (cur ^ \" [label = \\\"\" ^ (help (ht-string h)) ^ (ℕ-to-string (ht-frequency h)) ^ \"\\\"];\\n\")\n where help : maybe string → string\n help (just s) = s ^ \" , \"\n help nothing = \"\"\n\n -- helper function for ht-to-stringh\n ht-attach : maybe string → string → string\n ht-attach nothing _ = \"\"\n ht-attach (just c) c' = c ^ \" -> \" ^ c' ^ \";\\n\"\n\n ht-to-stringh : huffman-tree → ℕ → maybe string → ℕ × string\n ht-to-stringh h n prev with ht-declare-node h n \n ht-to-stringh (ht-leaf _ _) n prev | c , s = suc n , (ht-attach prev c) ^ s \n ht-to-stringh (ht-node _ h1 h2) n prev | c , s with ht-to-stringh h1 (suc n) (just c) \n ht-to-stringh (ht-node _ h1 h2) _ prev | c , s | n , s1 with ht-to-stringh h2 n (just c) \n ht-to-stringh (ht-node _ h1 h2) _ prev | c , s | _ , s1 | n , s2 = n , (ht-attach prev c) ^ s ^ s1 ^ s2\n\n{- turn a Huffman tree into a string in Graphviz format \n (you can render the output .gv file at http://sandbox.kidstrythisathome.com/erdos/) -}\nht-to-string : huffman-tree → string\nht-to-string h with ht-to-stringh h 0 nothing\nht-to-string h | _ , s = \"digraph h {\\nnode [shape = plaintext];\\n\" ^ s ^ \"}\"\n", "meta": {"hexsha": "65bee8682a59d199dbb7ecbd39927ec71a5769d6", "size": 2121, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "huffman/huffman-tree.agda", "max_stars_repo_name": "rfindler/ial", "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 29, "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_issues_repo_path": "huffman/huffman-tree.agda", "max_issues_repo_name": "rfindler/ial", "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_forks_repo_path": "huffman/huffman-tree.agda", "max_forks_repo_name": "rfindler/ial", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 17, "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "avg_line_length": 40.7884615385, "max_line_length": 105, "alphanum_fraction": 0.639321075, "num_tokens": 676, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375735, "lm_q2_score": 0.7853085758631159, "lm_q1q2_score": 0.6383516757366956}} {"text": "{-# OPTIONS --without-K #-}\nmodule horner where\n\nopen import Type\nopen import Type.Identities\nopen import Function.NP\nopen import Function.Extensionality\nopen import Data.Fin.NP using (Fin; Fin▹ℕ)\nopen import Data.Product renaming (proj₁ to fst; proj₂ to snd) hiding (map)\nopen import Data.Zero\nopen import Data.One\nopen import Data.Sum hiding (map)\nopen import Data.Nat.NP\nopen import Data.Nat.Properties\nimport Data.List as L\nimport Data.List.Properties as LP\nopen L using (List; []; _∷_)\nopen import Relation.Binary.PropositionalEquality.NP\nopen import HoTT\n--open import Explore.Fin\n\nℕ< : ℕ → Set\nℕ< n = Σ ℕ λ x → x < n\n\nsumFin : (n : ℕ) (f : Fin n → ℕ) → ℕ\nsumFin n f = {!!}\n\nsum< : (n : ℕ) (f : ℕ< n → ℕ) → ℕ\nsum< n f = {!!}\n\nprod< : (n : ℕ) (f : ℕ< n → ℕ) → ℕ\nprod< n f = {!!}\n\n{-\nfoo : ∀ n a x → sumFin n λ i → a i * x ^ i\nfoo = ?\n\nbar : ∀ n a x → sumFin n λ i → a i * x ^ i\nbar = ?\n-}\n\nbaz : ∀ n (u : ℕ< n → ℕ) → (sum< n λ { (i , p) → prod< i (λ { (j , q) → u (j , <-trans q p) }) }) ≡ {!!}\nbaz = {!!}\n\nmodule _ n (u : ℕ< n → Set) {{_ : UA}} {{_ : FunExt}} where\n open ≡-Reasoning\n Baz : _ ≡ _\n Baz = (Σ (ℕ< n) λ { (i , p) → Π (ℕ< i) λ { (j , q) → u (j , <-trans q p) } })\n ≡⟨ ! Σ-assoc ⟩\n (Σ ℕ λ i → Σ (i < n) λ p → Π (ℕ< i) λ { (j , q) → u (j , <-trans q p) })\n ≡⟨ Σ=′ ℕ (λ i → Σ=′ (i < n) λ p → ΠΣ-curry) ⟩\n (Σ ℕ λ i → Σ (i < n) λ p → Π ℕ λ j → Π (j < i) λ q → u (j , <-trans q p))\n ∎\n\nmodule DataVersion (A : ★) where\n open import Data.Tree.Binary\n data T : BinTree A → ★ where\n empty : T empty\n _⊕_ : ∀ {t u} → (𝟙 ⊎ T t × T u) → T (fork t u)\n\nmodule TypeVersion where\n ε = 𝟙\n _⊕_ : ★ → ★ → ★\n _⊕_ = λ u z → ε ⊎ u × z\n \n\nmodule ListVersion where\n open L\n open ≡-Reasoning\n map-∘ = LP.map-compose\n\n sum-lin : ∀ k xs → sum (map (_*_ k) xs) ≡ k * sum xs\n sum-lin k [] = ℕ°.*-comm 0 k\n sum-lin k (x ∷ xs) = k * x + sum (map (_*_ k) xs)\n ≡⟨ ap (_+_ (k * x)) (sum-lin k xs) ⟩\n k * x + k * sum xs\n ≡⟨ ! fst ℕ°.distrib k x (sum xs) ⟩\n k * (x + sum xs)\n ∎\n\n lemma : ∀ x xss → sum (map product (map (_∷_ x) xss)) ≡ x * sum (map product xss)\n lemma x xss = sum (map product (map (_∷_ x) xss))\n ≡⟨ ap sum (! map-∘ xss) ⟩\n sum (map (product ∘ _∷_ x) xss)\n ≡⟨by-definition⟩\n sum (map (_*_ x ∘ product) xss)\n ≡⟨ ap sum (map-∘ xss) ⟩\n sum (map (_*_ x) (map product xss))\n ≡⟨ sum-lin x (map product xss) ⟩\n x * sum (map product xss)\n ∎\n\n ε = 1\n _⊕_ = λ u z → ε + u * z\n t3 = ∀ xs → sum (map product (inits xs)) ≡ foldr _⊕_ ε xs\n t4 : t3\n t4 [] = refl\n t4 (x ∷ xs) = ap suc (lemma x (inits xs) ∙ ap (_*_ x) (t4 xs))\n", "meta": {"hexsha": "edcc842b0471e5e0eeb2bb78110a6ceab0dd23e7", "size": 2894, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "experiments/horner.agda", "max_stars_repo_name": "crypto-agda/explore", "max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z", "max_issues_repo_path": "experiments/horner.agda", "max_issues_repo_name": "crypto-agda/explore", "max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z", "max_forks_repo_path": "experiments/horner.agda", "max_forks_repo_name": "crypto-agda/explore", "max_forks_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.2323232323, "max_line_length": 104, "alphanum_fraction": 0.4626814098, "num_tokens": 1132, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513786759491, "lm_q2_score": 0.7122321964553657, "lm_q1q2_score": 0.638339088010521}} {"text": "\ndata D : Set where\n c : D\n s : D → D\n\npredD : D → D\npredD c = c\npredD (s x) = x\n\nf : D → D\nf c = c\nf (s n) with c\nf x@(s _) | c = x\nf (s _) | s _ = c\n\ndata E : D → Set where\n e : E c\n s : ∀ {x} → E x → E (s x)\n\npredE : ∀ {d} → E d → E (predD d)\npredE e = e\npredE (s x) = x\n\ng : ∀ {d} → E d → E (predD d)\ng e = e\ng (s x) with x\ng y@(s _) | s z = predE y\ng (s z@e) | e = predE z\n", "meta": {"hexsha": "434bc2c1138ff724b9d07cfe5375cc39dfc0111c", "size": 390, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue2313.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue2313.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue2313.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 13.4482758621, "max_line_length": 33, "alphanum_fraction": 0.4230769231, "num_tokens": 201, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513786759491, "lm_q2_score": 0.7122321903471562, "lm_q1q2_score": 0.6383390825360298}} {"text": "\nopen import Oscar.Prelude\nopen import Oscar.Class\nopen import Oscar.Class.Smap\nopen import Oscar.Data.Fin\nopen import Oscar.Data.Term\nopen import Oscar.Data.Vec\nimport Oscar.Class.Surjection.⋆\n\nmodule Oscar.Class.Smap.ExtensionFinExtensionTerm where\n\nmodule _ {𝔭} {𝔓 : Ø 𝔭} where\n\n open Term 𝔓\n\n private\n\n mutual\n\n 𝓼urjectivityExtensionFinExtensionTerm : Smap!.type (Extension Fin) (Extension Term)\n 𝓼urjectivityExtensionFinExtensionTerm x (i y) = i (x y)\n 𝓼urjectivityExtensionFinExtensionTerm x leaf = leaf\n 𝓼urjectivityExtensionFinExtensionTerm x (l fork r) = 𝓼urjectivityExtensionFinExtensionTerm x l fork 𝓼urjectivityExtensionFinExtensionTerm x r\n 𝓼urjectivityExtensionFinExtensionTerm x (function f ts) = function f $ 𝓼urjectivityExtensionFinExtensionTerms x ts\n\n 𝓼urjectivityExtensionFinExtensionTerms : ∀ {N} → Smap!.type (Extension Fin) (Extension $ Terms N)\n 𝓼urjectivityExtensionFinExtensionTerms x ∅ = ∅\n 𝓼urjectivityExtensionFinExtensionTerms x (t , ts) = 𝓼urjectivityExtensionFinExtensionTerm x t , 𝓼urjectivityExtensionFinExtensionTerms x ts\n\n instance\n\n 𝓢urjectivityExtensionFinExtensionTerm : Smap!.class (Extension Fin) (Extension Term)\n 𝓢urjectivityExtensionFinExtensionTerm .⋆ _ _ = 𝓼urjectivityExtensionFinExtensionTerm\n\n 𝓢urjectivityExtensionFinExtensionTerms : ∀ {N} → Smap!.class (Extension Fin) (Extension $ Terms N)\n 𝓢urjectivityExtensionFinExtensionTerms .⋆ _ _ = 𝓼urjectivityExtensionFinExtensionTerms\n", "meta": {"hexsha": "97c5cdc3ad6262b8a8b7898c7b9339b98c35bd36", "size": 1489, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Smap/ExtensionFinExtensionTerm.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Smap/ExtensionFinExtensionTerm.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Smap/ExtensionFinExtensionTerm.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.2432432432, "max_line_length": 147, "alphanum_fraction": 0.7884486232, "num_tokens": 442, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513675912912, "lm_q2_score": 0.7122321964553657, "lm_q1q2_score": 0.6383390801156708}} {"text": "{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-}\n\nmodule Light.Implementation.Relation.Binary.Equality.Propositional where\n\nopen import Agda.Builtin.Equality using (_≡_ ; refl)\nopen import Light.Library.Relation.Binary\n using (SelfSymmetric ; SelfTransitive ; Reflexive ; Binary ; SelfBinary ; Symmetric ; Transitive ; CongruentFor ; Preserved)\nopen import Light.Implementation.Relation.Sets using (base) public\nopen import Light.Library.Relation.Binary.Equality using (SelfEquality ; wrap)\nopen import Light.Variable.Sets\nopen import Light.Variable.Levels\n\nopen Reflexive\nopen Symmetric\nopen Transitive\nopen Preserved\n\nmodule _ {𝕒 : Set aℓ} where\n instance relation : SelfBinary 𝕒\n relation = record { are = λ a b → a ≡ b }\n \n instance reflexive : Reflexive relation\n reflexive .reflexivity = refl\n \n instance symmetric : SelfSymmetric relation\n symmetric .symmetry refl = refl\n \n instance transitive : SelfTransitive relation\n transitive .transitivity refl refl = refl\n \n instance equals : SelfEquality 𝕒\n equals = wrap relation\n\ninstance congruent : ∀ {f : 𝕒 → 𝕓} → CongruentFor f relation relation\ncongruent .preservation refl = refl\n", "meta": {"hexsha": "b219f88a4897d9801c53c7ce78f609f66184b9e3", "size": 1244, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Light/Implementation/Relation/Binary/Equality/Propositional.agda", "max_stars_repo_name": "zamfofex/lightlib", "max_stars_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_stars_repo_licenses": ["0BSD"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z", "max_issues_repo_path": "Light/Implementation/Relation/Binary/Equality/Propositional.agda", "max_issues_repo_name": "Zambonifofex/lightlib", "max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_issues_repo_licenses": ["0BSD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Light/Implementation/Relation/Binary/Equality/Propositional.agda", "max_forks_repo_name": "Zambonifofex/lightlib", "max_forks_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_forks_repo_licenses": ["0BSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.5555555556, "max_line_length": 130, "alphanum_fraction": 0.731511254, "num_tokens": 300, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8962513675912912, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.6383390636921975}} {"text": "-- Σ type (also used as existential) and\n-- cartesian product (also used as conjunction).\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Tools.Product where\n\nopen import Agda.Primitive\n\ninfixr 4 _,_\ninfixr 2 _×_\n\n-- Dependent pair type (aka dependent sum, Σ type).\n\nrecord Σ {ℓ ℓ′ : Level} (A : Set ℓ) (B : A → Set ℓ′) : Set (ℓ ⊔ ℓ′) where\n constructor _,_\n field\n proj₁ : A\n proj₂ : B proj₁\n\nopen Σ public\n\nrecord Σω₀ {ℓ} (A : Set ℓ) (B : A → Setω) : Setω where\n constructor _,_\n field\n proj₁ : A\n proj₂ : B proj₁\n\nopen Σω₀ public\n\nrecord Σω₂ {ℓ} (A : Setω) (B : A → Set ℓ) : Setω where\n constructor _,_\n field\n proj₁ : A\n proj₂ : B proj₁\n\nopen Σω₂ public\n\nrecord Σω₃ (A : Setω) (B : A → Setω) : Setω where\n constructor _,_\n field\n proj₁ : A\n proj₂ : B proj₁\n\nopen Σω₃ public\n\nrecord Σω₄ (A : Setω₁) (B : A → Setω) : Setω₁ where\n constructor _,_\n field\n proj₁ : A\n proj₂ : B proj₁\n\nopen Σω₄ public\n\n-- Existential quantification.\n\n∃ : {ℓ ℓ′ : Level} → {A : Set ℓ} → (A → Set ℓ′) → Set (ℓ ⊔ ℓ′)\n∃ = Σ _\n\n∃₂ : {ℓ ℓ′ ℓ″ : Level} → {A : Set ℓ} {B : A → Set ℓ′}\n (C : (x : A) → B x → Set ℓ″) → Set (ℓ ⊔ ℓ′ ⊔ ℓ″)\n∃₂ C = ∃ λ a → ∃ λ b → C a b\n\n∃ω₃ : {A : Setω} → (A → Setω) → Setω\n∃ω₃ = Σω₃ _\n\n∃ω₃² : {A : Setω} {B : A → Setω}\n (C : (x : A) → B x → Setω) → Setω\n∃ω₃² C = ∃ω₃ λ a → ∃ω₃ λ b → C a b\n\n∃ω₄ : {A : Setω₁} → (A → Setω) → Setω₁\n∃ω₄ = Σω₄ _\n\n-- Cartesian product.\n\n_×_ : {ℓ ℓ′ : Level} → (A : Set ℓ) → (B : Set ℓ′) → Set (ℓ ⊔ ℓ′)\nA × B = Σ A (λ x → B)\n\n_×ω₂_ : {ℓ : Level} → (A : Setω) → (B : Set ℓ) → Setω\nA ×ω₂ B = Σω₂ A (λ x → B)\n\n_×ω₃_ : (A : Setω) → (B : Setω) → Setω\nA ×ω₃ B = Σω₃ A (λ x → B)\n", "meta": {"hexsha": "7a4461e06f9c0d669b490ba93ed400badd77df53", "size": 1646, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Tools/Product.agda", "max_stars_repo_name": "loic-p/logrel-mltt", "max_stars_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Tools/Product.agda", "max_issues_repo_name": "loic-p/logrel-mltt", "max_issues_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Tools/Product.agda", "max_forks_repo_name": "loic-p/logrel-mltt", "max_forks_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.5952380952, "max_line_length": 73, "alphanum_fraction": 0.5291616039, "num_tokens": 791, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519527944504228, "lm_q2_score": 0.7490872075132153, "lm_q1q2_score": 0.6381869397279476}} {"text": "\nmodule _ where\n\nopen import Agda.Builtin.Bool\nopen import Agda.Builtin.Nat renaming (_==_ to _==N_; _<_ to _ Set where\n varE : {ι : _} -> A -> LamE A (↑ ι)\n appE : {ι : _} -> LamE A ι -> LamE A ι -> LamE A (↑ ι)\n absE : {ι : _} -> LamE (Maybe A) ι -> LamE A (↑ ι)\n flatE : {ι : _} -> LamE (LamE A ι) ι -> LamE A (↑ ι)\n\n-- functoriality of LamE\nlamE : {A B : Set} -> (A -> B) -> {ι : _} -> LamE A ι -> LamE B ι\nlamE f (varE a) = varE (f a)\nlamE f (appE t1 t2) = appE (lamE f t1) (lamE f t2)\nlamE f (absE r) = absE (lamE (fmap f) r)\nlamE f (flatE r) = flatE (lamE (lamE f) r)\n\neval : {ι : _} -> {A : Set} -> LamE A ι -> Lam A\neval (varE a) = var a\neval (appE t1 t2) = app (eval t1) (eval t2)\neval (absE r) = abs (eval r)\neval (flatE r) = subst (eval) (eval r)\n\n\n-- Theorem (naturality of eval): eval ∘ lamE f ≡ lam f ∘ eval\nevalNAT : {A B : Set}(f : A -> B) -> {ι : _} -> (t : LamE A ι) ->\n eval (lamE f t) ≡ lam f (eval t)\nevalNAT f (varE a) = ≡-refl\nevalNAT f (appE t1 t2) = begin\n eval (lamE f (appE t1 t2))\n ≡⟨ ≡-refl ⟩\n eval (appE (lamE f t1) (lamE f t2))\n ≡⟨ ≡-refl ⟩\n app (eval (lamE f t1)) (eval (lamE f t2))\n ≡⟨ ≡-cong (\\ x -> app x (eval (lamE f t2))) (evalNAT f t1) ⟩\n app (lam f (eval t1)) (eval (lamE f t2))\n ≡⟨ ≡-cong (\\ x -> app (lam f (eval t1)) x) (evalNAT f t2) ⟩\n app (lam f (eval t1)) (lam f (eval t2))\n ≡⟨ ≡-refl ⟩\n lam f (app (eval t1) (eval t2))\n ≡⟨ ≡-refl ⟩\n lam f (eval (appE t1 t2))\n ∎\nevalNAT f (absE r) = begin\n eval (lamE f (absE r))\n ≡⟨ ≡-refl ⟩\n eval (absE (lamE (fmap f) r))\n ≡⟨ ≡-refl ⟩\n abs (eval (lamE (fmap f) r))\n ≡⟨ ≡-cong abs (evalNAT (fmap f) r) ⟩\n abs (lam (fmap f) (eval r))\n ≡⟨ ≡-refl ⟩\n lam f (abs (eval r))\n ≡⟨ ≡-refl ⟩\n lam f (eval (absE r))\n ∎\n-- in the following case, one manual size annotation is needed on the RHS\n-- it is for the first application of the I.H.\nevalNAT f (flatE {ι} r) = begin\n eval (lamE f (flatE r))\n ≡⟨ ≡-refl ⟩\n eval (flatE (lamE (lamE f) r))\n ≡⟨ ≡-refl ⟩\n subst eval (eval (lamE (lamE f) r))\n ≡⟨ ≡-cong (subst (eval {ι})) (evalNAT (lamE f) r) ⟩\n subst eval (lam (lamE f) (eval r))\n ≡⟨ substLaw1 (lamE f) eval (eval r) ⟩\n subst (eval ∘ lamE f) (eval r)\n ≡⟨ substExt (evalNAT f) (eval r) ⟩\n subst (lam f ∘ eval) (eval r)\n ≡⟨ substLaw2 f eval (eval r) ⟩\n lam f (subst eval (eval r))\n ≡⟨ ≡-refl ⟩\n lam f (eval (flatE r))\n ∎\n\nevalNATcor : {A : Set}{ι : _}(ee : LamE (LamE A ι) ι) ->\n subst id (eval (lamE eval ee)) ≡ eval (flatE ee)\nevalNATcor ee = begin\n subst id (eval (lamE eval ee))\n ≡⟨ ≡-cong (subst id) (evalNAT eval ee) ⟩\n subst id (lam eval (eval ee))\n ≡⟨ substLaw1 eval id (eval ee) ⟩\n subst eval (eval ee)\n ≡⟨ ≡-refl ⟩\n eval (flatE ee)\n ∎\n", "meta": {"hexsha": "10973240effaef2d9b3ff3970769274337854b54", "size": 3052, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/Termination/Sized/DeBruijnExSubstSized.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "examples/Termination/Sized/DeBruijnExSubstSized.agda", "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/Termination/Sized/DeBruijnExSubstSized.agda", "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 30.8282828283, "max_line_length": 73, "alphanum_fraction": 0.5396461337, "num_tokens": 1375, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256631249077, "lm_q2_score": 0.7577943767446202, "lm_q1q2_score": 0.6379307537153661}} {"text": "open import Data.Product using ( ∃ ; _×_ ; _,_ )\nopen import Relation.Binary.PropositionalEquality using ( _≡_ ; refl )\nopen import Relation.Nullary using ( ¬_ )\nopen import Relation.Unary using ( _∈_ ; ∅ )\nopen import Web.Semantic.DL.Signature using ( Signature ; CN ; RN )\nopen import Web.Semantic.Util using ( Setoid ; Subset ; _∘_ ; False )\n\nmodule Web.Semantic.DL.TBox.Interp where\n\n{- TBox interpretation of a Signature Σ\n consists essentially of:\n 1. A Domain Δ of intepretation\n 2. An equivalence relation on Δ\n 3. An interpretation of Σ, i.e. a function from CN and RN to Δ\n 4. Proofs that the interpretations respect the Equivalence Relation\n One would use records in Agda 2.6.x\n -}\ndata Interp (Σ : Signature) : Set₁ where\n interp :\n (Δ : Set) → -- The Domain of Interpretation (e.g. representing real objects in the world)\n (_≈_ : Δ → Δ → Set) → -- an equivalence relation between those objects (one may have hesperus ≈ phosphorus)\n (ref : ∀ {x} → (x ≈ x)) → -- proof of reflexivity of equivalence relation\n (sym : ∀ {x y} → (x ≈ y) → (y ≈ x)) → -- proof of symmetry of ≈\n (trans : ∀ {x y z} → (x ≈ y) → (y ≈ z) → (x ≈ z)) → -- proof of transitivity\n (con : CN Σ → Subset Δ) → -- concept names of signature map\n (rol : RN Σ → Subset (Δ × Δ)) → -- role name of signature map\n (con-≈ : ∀ {x y} c → (x ∈ con c) → (x ≈ y) → (y ∈ con c)) →\n (rol-≈ : ∀ {w x y z} r → (w ≈ x) → ((x , y) ∈ rol r) → (y ≈ z) → ((w , z) ∈ rol r)) →\n Interp Σ\n\n{-\n the functions below return some elements of Interp,\n which would with Agda 2.6.* be given by the record structure\n -}\n\n-- The Domain of Interpretation (e.g. representing real objects in the world) \nΔ : ∀ {Σ} → Interp Σ → Set\nΔ (interp Δ _≈_ ref sym trans con rol con-≈ rol-≈) = Δ\n\n-- this semantic entailment relation is unusual as it relates an interpretation to \n-- elements in the domain whereas usually we have \n-- M ⊨ P where M is a model and P a sentence of the language (as done in Institution Theory)\n-- so we might have I ⊨ { a owl:sameAs b }\n-- which would be true if a refers to the same object as b in Δ via I\n-- this may indicate a confusion of syntax with semantics here.\n_⊨_≈_ : ∀ {Σ} → (I : Interp Σ) → (Δ I) → (Δ I) → Set\n_⊨_≈_ (interp Δ _≈_ ref sym trans con rol con-≈ rol-≈) = _≈_\n\n≈-refl : ∀ {Σ} → (I : Interp Σ) → ∀ {x} → (I ⊨ x ≈ x)\n≈-refl (interp Δ _≈_ ref sym trans con rol con-≈ rol-≈) = ref\n\n≈-sym : ∀ {Σ} → (I : Interp Σ) → ∀ {x y} → (I ⊨ x ≈ y) → (I ⊨ y ≈ x)\n≈-sym (interp Δ _≈_ ref sym trans con rol con-≈ rol-≈) = sym\n\n≈-trans : ∀ {Σ} → (I : Interp Σ) → ∀ {x y z} → (I ⊨ x ≈ y) → (I ⊨ y ≈ z) → (I ⊨ x ≈ z)\n≈-trans (interp Δ _≈_ ref sym trans con rol con-≈ rol-≈) = trans\n\n-- concept names of signature map\ncon : ∀ {Σ} → (I : Interp Σ) → CN Σ → Subset (Δ I)\ncon (interp Δ _≈_ ref sym trans con rol con-≈ rol-≈) = con\n\n-- role name of signature map\nrol : ∀ {Σ} → (I : Interp Σ) → RN Σ → Subset (Δ I × Δ I)\nrol (interp Δ _≈_ ref sym trans con rol con-≈ rol-≈) = rol\n\ncon-≈ : ∀ {Σ} → (I : Interp Σ) → ∀ {x y} c → (x ∈ con I c) → (I ⊨ x ≈ y) → (y ∈ con I c)\ncon-≈ (interp Δ _≈_ ref sym trans con rol con-≈ rol-≈) = con-≈\n\nrol-≈ : ∀ {Σ} → (I : Interp Σ) → ∀ {w x y z} r → (I ⊨ w ≈ x) → ((x , y) ∈ rol I r) → (I ⊨ y ≈ z) → ((w , z) ∈ rol I r)\nrol-≈ (interp Δ _≈_ ref sym trans con rol con-≈ rol-≈) = rol-≈\n\n{-\n Additional functions\n-}\n\n-- Interpretation implies two elements are not equal\n_⊨_≉_ : ∀ {Σ} → (I : Interp Σ) → (Δ I) → (Δ I) → Set\nI ⊨ x ≉ y = ¬(I ⊨ x ≈ y)\n\n-- the Empty Interpretation\nemp : ∀ {Σ} → Interp Σ\nemp = interp False (λ ()) (λ {}) (λ {}) (λ {}) (λ c → ∅) (λ r → ∅) (λ {}) (λ {})\n\n-- relf implies ≈\n≈-refl′ : ∀ {Σ} (I : Interp Σ) → ∀ {x y} → (x ≡ y) → (I ⊨ x ≈ y)\n≈-refl′ I refl = ≈-refl I\n", "meta": {"hexsha": "f9be0638d4d10f2ec6bae0d656306041f9901090", "size": 3767, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Web/Semantic/DL/TBox/Interp.agda", "max_stars_repo_name": "bblfish/agda-web-semantic", "max_stars_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-02-22T09:43:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-22T09:43:23.000Z", "max_issues_repo_path": "src/Web/Semantic/DL/TBox/Interp.agda", "max_issues_repo_name": "bblfish/agda-web-semantic", "max_issues_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Web/Semantic/DL/TBox/Interp.agda", "max_forks_repo_name": "bblfish/agda-web-semantic", "max_forks_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.2988505747, "max_line_length": 118, "alphanum_fraction": 0.5707459517, "num_tokens": 1488, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256393148981, "lm_q2_score": 0.7577943658046609, "lm_q1q2_score": 0.6379307264627364}} {"text": "{- Definition of vectors. Inspired by the Agda Standard Library -}\n\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Data.Vec.Base where\n\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Data.Nat\nopen import Cubical.Data.FinData\n\nprivate\n variable\n ℓ ℓ' : Level\n\n A : Type ℓ\n\ninfixr 5 _∷_\n\ndata Vec (A : Type ℓ) : ℕ → Type ℓ where\n [] : Vec A zero\n _∷_ : ∀ {n} (x : A) (xs : Vec A n) → Vec A (suc n)\n\n\n-- Basic functions\n\nlength : ∀ {n} → Vec A n → ℕ\nlength {n = n} _ = n\n\nhead : ∀ {n} → Vec A (1 + n) → A\nhead (x ∷ xs) = x\n\ntail : ∀ {n} → Vec A (1 + n) → Vec A n\ntail (x ∷ xs) = xs\n\nmap : ∀ {A : Type ℓ} {B : Type ℓ'} {n} → (A → B) → Vec A n → Vec B n\nmap f [] = []\nmap f (x ∷ xs) = f x ∷ map f xs\n\nreplicate : ∀ {n} {A : Type ℓ} → A → Vec A n\nreplicate {n = zero} x = []\nreplicate {n = suc n} x = x ∷ replicate x\n\n-- Concatenation\n\ninfixr 5 _++_\n\n_++_ : ∀ {m n} → Vec A m → Vec A n → Vec A (m + n)\n[] ++ ys = ys\n(x ∷ xs) ++ ys = x ∷ (xs ++ ys)\n\nconcat : ∀ {m n} → Vec (Vec A m) n → Vec A (n · m)\nconcat [] = []\nconcat (xs ∷ xss) = xs ++ concat xss\n\nlookup : ∀ {n} {A : Type ℓ} → Fin n → Vec A n → A\nlookup zero (x ∷ xs) = x\nlookup (suc i) (x ∷ xs) = lookup i xs\n", "meta": {"hexsha": "005365dd2751e2091f9c102a630330f9c164e5b0", "size": 1227, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/Vec/Base.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/Vec/Base.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/Data/Vec/Base.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.1551724138, "max_line_length": 68, "alphanum_fraction": 0.5256723716, "num_tokens": 494, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835371034368, "lm_q2_score": 0.7634837743174788, "lm_q1q2_score": 0.6378781242878493}} {"text": "{-\nThis second-order equational theory was created from the following second-order syntax description:\n\nsyntax Combinatory | CL\n\ntype\n * : 0-ary\n\nterm\n app : * * -> * | _$_ l20\n i : *\n k : *\n s : *\n\ntheory\n (IA) x |> app (i, x) = x\n (KA) x y |> app (app(k, x), y) = x\n (SA) x y z |> app (app (app (s, x), y), z) = app (app(x, z), app(y, z))\n-}\n\nmodule Combinatory.Equality where\n\nopen import SOAS.Common\nopen import SOAS.Context\nopen import SOAS.Variable\nopen import SOAS.Families.Core\nopen import SOAS.Families.Build\nopen import SOAS.ContextMaps.Inductive\n\nopen import Combinatory.Signature\nopen import Combinatory.Syntax\n\nopen import SOAS.Metatheory.SecondOrder.Metasubstitution CL:Syn\nopen import SOAS.Metatheory.SecondOrder.Equality CL:Syn\n\nprivate\n variable\n α β γ τ : *T\n Γ Δ Π : Ctx\n\ninfix 1 _▹_⊢_≋ₐ_\n\n-- Axioms of equality\ndata _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ CL) α Γ → (𝔐 ▷ CL) α Γ → Set where\n IA : ⁅ * ⁆̣ ▹ ∅ ⊢ I $ 𝔞 ≋ₐ 𝔞\n KA : ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (K $ 𝔞) $ 𝔟 ≋ₐ 𝔞\n SA : ⁅ * ⁆ ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ ((S $ 𝔞) $ 𝔟) $ 𝔠 ≋ₐ (𝔞 $ 𝔠) $ (𝔟 $ 𝔠)\n\nopen EqLogic _▹_⊢_≋ₐ_\nopen ≋-Reasoning\n", "meta": {"hexsha": "519f71880546123ee100558bce2c22e98bb31d91", "size": 1150, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "out/Combinatory/Equality.agda", "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_issues_repo_path": "out/Combinatory/Equality.agda", "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_forks_repo_path": "out/Combinatory/Equality.agda", "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "avg_line_length": 22.5490196078, "max_line_length": 99, "alphanum_fraction": 0.5773913043, "num_tokens": 501, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8688267864276108, "lm_q2_score": 0.7341195385342971, "lm_q1q2_score": 0.6378227195184739}} {"text": "module Categories.Setoids where\n\nopen import Library\nopen import Categories\n\n\nrecord Setoid {a b} : Set (lsuc (a ⊔ b)) where\n field set : Set a\n eq : set → set → Set b\n ref : {s : set} → eq s s\n sym' : {s s' : set} → eq s s' → eq s' s\n trn : {s s' s'' : set} → \n eq s s' → eq s' s'' → eq s s''\nopen Setoid\n\nrecord SetoidFun (S S' : Setoid) : Set where\n constructor setoidfun\n field fun : set S → set S'\n feq : {s s' : set S} → \n eq S s s' → eq S' (fun s) (fun s')\nopen SetoidFun\n\nSetoidFunEq : {S S' : Setoid}{f g : SetoidFun S S'} →\n fun f ≅ fun g →\n (λ{s}{s'}(p : eq S s s') → feq f p)\n ≅\n (λ{s}{s'}(p : eq S s s') → feq g p) →\n f ≅ g\nSetoidFunEq {f = setoidfun fun feq} {setoidfun .fun .feq} refl refl = refl\n\nidFun : {S : Setoid} → SetoidFun S S\nidFun = record {fun = id; feq = id}\n\ncompFun : {S S' S'' : Setoid} → \n SetoidFun S' S'' → SetoidFun S S' → SetoidFun S S''\ncompFun f g = record {fun = fun f ∘ fun g; feq = feq f ∘ feq g}\n\nidl : {X Y : Setoid} {f : SetoidFun X Y} → compFun idFun f ≅ f\nidl {f = setoidfun _ _} = refl\n\nidr : {X Y : Setoid} {f : SetoidFun X Y} → compFun f idFun ≅ f\nidr {f = setoidfun _ _} = refl\n\nSetoids : Cat\nSetoids = record{\n Obj = Setoid; \n Hom = SetoidFun;\n iden = idFun; \n comp = compFun; \n idl = idl;\n idr = idr;\n ass = refl}\n-- -}\n", "meta": {"hexsha": "c86564888b1028b7777c0c954e328cf7c208e5cf", "size": 1423, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Setoids.agda", "max_stars_repo_name": "jmchapman/Relative-Monads", "max_stars_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 21, "max_stars_repo_stars_event_min_datetime": "2015-07-30T01:25:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-13T18:02:18.000Z", "max_issues_repo_path": "Categories/Setoids.agda", "max_issues_repo_name": "jmchapman/Relative-Monads", "max_issues_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:12:33.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-29T09:50:26.000Z", "max_forks_repo_path": "Categories/Setoids.agda", "max_forks_repo_name": "jmchapman/Relative-Monads", "max_forks_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-04T21:33:13.000Z", "avg_line_length": 26.3518518519, "max_line_length": 74, "alphanum_fraction": 0.5122979621, "num_tokens": 553, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267728417087, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.6378226943827531}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import HoTT\nopen import homotopy.SuspSectionDecomp\nopen import homotopy.CofiberComp\n\nmodule homotopy.SuspProduct where\n\nmodule SuspProduct {i} {j} (X : Ptd i) (Y : Ptd j) where\n\n private\n i₁ : fst (X ⊙→ X ⊙× Y)\n i₁ = ((λ x → (x , snd Y)) , idp)\n\n i₂ : fst (Y ⊙→ X ⊙× Y)\n i₂ = ((λ y → (snd X , y)) , idp)\n\n j₂ : fst (⊙Cof i₁) → fst Y\n j₂ = CofiberRec.f (snd Y) snd (λ x → idp)\n\n ⊙path : ⊙Susp (X ⊙× Y) == ⊙Susp X ⊙∨ (⊙Susp Y ⊙∨ ⊙Susp (X ⊙∧ Y))\n ⊙path =\n ⊙ua (⊙≃-in (SuspSectionDecomp.eq i₁ fst (λ x → idp))\n (! $ ap winl $ merid (snd X)))\n ∙ ap (λ Z → ⊙Susp X ⊙∨ Z)\n (⊙ua (⊙≃-in (SuspSectionDecomp.eq (⊙cfcod' i₁ ⊙∘ i₂) j₂ (λ y → idp))\n (! $ ap winl $ merid (snd Y))))\n ∙ ap (λ Z → ⊙Susp X ⊙∨ (⊙Susp Y ⊙∨ ⊙Susp Z))\n (CofiberComp.⊙path i₁ i₂)\n", "meta": {"hexsha": "dd2667b3131be2cef210244ee25bfc401ec0f5e9", "size": 859, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/homotopy/SuspProduct.agda", "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "theorems/homotopy/SuspProduct.agda", "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "theorems/homotopy/SuspProduct.agda", "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.6333333333, "max_line_length": 77, "alphanum_fraction": 0.4924330617, "num_tokens": 391, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9207896780646393, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.6377775945067187}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Integers\n------------------------------------------------------------------------\n\nmodule Data.Integer where\n\nopen import Data.Nat as ℕ\n using (ℕ) renaming (_+_ to _ℕ+_; _*_ to _ℕ*_)\nimport Data.Nat.Show as ℕ\nopen import Data.Sign as Sign using (Sign) renaming (_*_ to _S*_)\nopen import Data.Product as Prod\nopen import Data.String using (String; _++_)\nopen import Function\nopen import Data.Sum as Sum\nopen import Relation.Nullary\nimport Relation.Nullary.Decidable as Dec\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as PropEq\n using (_≡_; refl; sym; cong; cong₂)\nopen PropEq.≡-Reasoning\n\ninfix 8 +_ -_\ninfixl 7 _*_ _⊓_\ninfixl 6 _+_ _-_ _⊖_ _⊔_\ninfix 4 _≤_ _≤?_\n\n------------------------------------------------------------------------\n-- The types\n\n-- Integers.\n\ndata ℤ : Set where\n -[1+_] : (n : ℕ) → ℤ -- -[1+ n ] stands for - (1 + n).\n +_ : (n : ℕ) → ℤ -- + n stands for n.\n\n------------------------------------------------------------------------\n-- Conversions\n\n-- Absolute value.\n\n∣_∣ : ℤ → ℕ\n∣ + n ∣ = n\n∣ -[1+ n ] ∣ = ℕ.suc n\n\n-- Gives the sign. For zero the sign is arbitrarily chosen to be +.\n\nsign : ℤ → Sign\nsign (+ _) = Sign.+\nsign -[1+ _ ] = Sign.-\n\n-- Decimal string representation.\n\nshow : ℤ → String\nshow i = showSign (sign i) ++ ℕ.show ∣ i ∣\n where\n showSign : Sign → String\n showSign Sign.- = \"-\"\n showSign Sign.+ = \"\"\n\n------------------------------------------------------------------------\n-- A view of integers as sign + absolute value\n\ninfix 5 _◂_ _◃_\n\n_◃_ : Sign → ℕ → ℤ\n_ ◃ ℕ.zero = + ℕ.zero\nSign.+ ◃ n = + n\nSign.- ◃ ℕ.suc n = -[1+ n ]\n\n◃-left-inverse : ∀ i → sign i ◃ ∣ i ∣ ≡ i\n◃-left-inverse -[1+ n ] = refl\n◃-left-inverse (+ ℕ.zero) = refl\n◃-left-inverse (+ ℕ.suc n) = refl\n\n◃-cong : ∀ {i j} → sign i ≡ sign j → ∣ i ∣ ≡ ∣ j ∣ → i ≡ j\n◃-cong {i} {j} sign-≡ abs-≡ = begin\n i ≡⟨ sym $ ◃-left-inverse i ⟩\n sign i ◃ ∣ i ∣ ≡⟨ cong₂ _◃_ sign-≡ abs-≡ ⟩\n sign j ◃ ∣ j ∣ ≡⟨ ◃-left-inverse j ⟩\n j ∎\n\ndata SignAbs : ℤ → Set where\n _◂_ : (s : Sign) (n : ℕ) → SignAbs (s ◃ n)\n\nsignAbs : ∀ i → SignAbs i\nsignAbs i = PropEq.subst SignAbs (◃-left-inverse i) $\n sign i ◂ ∣ i ∣\n\n------------------------------------------------------------------------\n-- Equality is decidable\n\ninfix 4 _≟_\n\n_≟_ : Decidable {A = ℤ} _≡_\ni ≟ j with Sign._≟_ (sign i) (sign j) | ℕ._≟_ ∣ i ∣ ∣ j ∣\ni ≟ j | yes sign-≡ | yes abs-≡ = yes (◃-cong sign-≡ abs-≡)\ni ≟ j | no sign-≢ | _ = no (sign-≢ ∘ cong sign)\ni ≟ j | _ | no abs-≢ = no (abs-≢ ∘ cong ∣_∣)\n\ndecSetoid : DecSetoid _ _\ndecSetoid = PropEq.decSetoid _≟_\n\n------------------------------------------------------------------------\n-- Arithmetic\n\n-- Negation.\n\n-_ : ℤ → ℤ\n- (+ ℕ.suc n) = -[1+ n ]\n- (+ ℕ.zero) = + ℕ.zero\n- -[1+ n ] = + ℕ.suc n\n\n-- Subtraction of natural numbers.\n\n_⊖_ : ℕ → ℕ → ℤ\nm ⊖ ℕ.zero = + m\nℕ.zero ⊖ ℕ.suc n = -[1+ n ]\nℕ.suc m ⊖ ℕ.suc n = m ⊖ n\n\n-- Addition.\n\n_+_ : ℤ → ℤ → ℤ\n-[1+ m ] + -[1+ n ] = -[1+ ℕ.suc (m ℕ+ n) ]\n-[1+ m ] + + n = n ⊖ ℕ.suc m\n+ m + -[1+ n ] = m ⊖ ℕ.suc n\n+ m + + n = + (m ℕ+ n)\n\n-- Subtraction.\n\n_-_ : ℤ → ℤ → ℤ\ni - j = i + - j\n\n-- Successor.\n\nsuc : ℤ → ℤ\nsuc i = + 1 + i\n\nprivate\n\n suc-is-lazy⁺ : ∀ n → suc (+ n) ≡ + ℕ.suc n\n suc-is-lazy⁺ n = refl\n\n suc-is-lazy⁻ : ∀ n → suc -[1+ ℕ.suc n ] ≡ -[1+ n ]\n suc-is-lazy⁻ n = refl\n\n-- Predecessor.\n\npred : ℤ → ℤ\npred i = - + 1 + i\n\nprivate\n\n pred-is-lazy⁺ : ∀ n → pred (+ ℕ.suc n) ≡ + n\n pred-is-lazy⁺ n = refl\n\n pred-is-lazy⁻ : ∀ n → pred -[1+ n ] ≡ -[1+ ℕ.suc n ]\n pred-is-lazy⁻ n = refl\n\n-- Multiplication.\n\n_*_ : ℤ → ℤ → ℤ\ni * j = sign i S* sign j ◃ ∣ i ∣ ℕ* ∣ j ∣\n\n-- Maximum.\n\n_⊔_ : ℤ → ℤ → ℤ\n-[1+ m ] ⊔ -[1+ n ] = -[1+ ℕ._⊓_ m n ]\n-[1+ m ] ⊔ + n = + n\n+ m ⊔ -[1+ n ] = + m\n+ m ⊔ + n = + (ℕ._⊔_ m n)\n\n-- Minimum.\n\n_⊓_ : ℤ → ℤ → ℤ\n-[1+ m ] ⊓ -[1+ n ] = -[1+ ℕ._⊔_ m n ]\n-[1+ m ] ⊓ + n = -[1+ m ]\n+ m ⊓ -[1+ n ] = -[1+ n ]\n+ m ⊓ + n = + (ℕ._⊓_ m n)\n\n------------------------------------------------------------------------\n-- Ordering\n\ndata _≤_ : ℤ → ℤ → Set where\n -≤+ : ∀ {m n} → -[1+ m ] ≤ + n\n -≤- : ∀ {m n} → (n≤m : ℕ._≤_ n m) → -[1+ m ] ≤ -[1+ n ]\n +≤+ : ∀ {m n} → (m≤n : ℕ._≤_ m n) → + m ≤ + n\n\ndrop‿+≤+ : ∀ {m n} → + m ≤ + n → ℕ._≤_ m n\ndrop‿+≤+ (+≤+ m≤n) = m≤n\n\ndrop‿-≤- : ∀ {m n} → -[1+ m ] ≤ -[1+ n ] → ℕ._≤_ n m\ndrop‿-≤- (-≤- n≤m) = n≤m\n\n_≤?_ : Decidable _≤_\n-[1+ m ] ≤? -[1+ n ] = Dec.map′ -≤- drop‿-≤- (ℕ._≤?_ n m)\n-[1+ m ] ≤? + n = yes -≤+\n+ m ≤? -[1+ n ] = no λ ()\n+ m ≤? + n = Dec.map′ +≤+ drop‿+≤+ (ℕ._≤?_ m n)\n\ndecTotalOrder : DecTotalOrder _ _ _\ndecTotalOrder = record\n { Carrier = ℤ\n ; _≈_ = _≡_\n ; _≤_ = _≤_\n ; isDecTotalOrder = record\n { isTotalOrder = record\n { isPartialOrder = record\n { isPreorder = record\n { isEquivalence = PropEq.isEquivalence\n ; reflexive = refl′\n ; trans = trans\n }\n ; antisym = antisym\n }\n ; total = total\n }\n ; _≟_ = _≟_\n ; _≤?_ = _≤?_\n }\n }\n where\n module ℕO = DecTotalOrder ℕ.decTotalOrder\n\n refl′ : _≡_ ⇒ _≤_\n refl′ { -[1+ n ]} refl = -≤- ℕO.refl\n refl′ {+ n} refl = +≤+ ℕO.refl\n\n trans : Transitive _≤_\n trans -≤+ (+≤+ n≤m) = -≤+\n trans (-≤- n≤m) -≤+ = -≤+\n trans (-≤- n≤m) (-≤- k≤n) = -≤- (ℕO.trans k≤n n≤m)\n trans (+≤+ m≤n) (+≤+ n≤k) = +≤+ (ℕO.trans m≤n n≤k)\n\n antisym : Antisymmetric _≡_ _≤_\n antisym -≤+ ()\n antisym (-≤- n≤m) (-≤- m≤n) = cong -[1+_] $ ℕO.antisym m≤n n≤m\n antisym (+≤+ m≤n) (+≤+ n≤m) = cong +_ $ ℕO.antisym m≤n n≤m\n\n total : Total _≤_\n total (-[1+ m ]) (-[1+ n ]) = [ inj₂ ∘′ -≤- , inj₁ ∘′ -≤- ]′ $ ℕO.total m n\n total (-[1+ m ]) (+ n ) = inj₁ -≤+\n total (+ m ) (-[1+ n ]) = inj₂ -≤+\n total (+ m ) (+ n ) = [ inj₁ ∘′ +≤+ , inj₂ ∘′ +≤+ ]′ $ ℕO.total m n\n\nposet : Poset _ _ _\nposet = DecTotalOrder.poset decTotalOrder\n\nimport Relation.Binary.PartialOrderReasoning as POR\nmodule ≤-Reasoning = POR poset\n renaming (_≈⟨_⟩_ to _≡⟨_⟩_)\n", "meta": {"hexsha": "f106a9f994bfe354725e712ffcc9f14f1ab72be2", "size": 6288, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Integer.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Integer.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Integer.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.8537549407, "max_line_length": 77, "alphanum_fraction": 0.4195292621, "num_tokens": 2655, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473879530492, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.6377370415085536}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Sets.EquivalenceRelations\nopen import LogicalFormulae\nopen import Orders.Total.Definition\nopen import Orders.Partial.Definition\nopen import Setoids.Setoids\nopen import Functions.Definition\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\n\nmodule Setoids.Orders.Partial.Definition where\n\nrecord SetoidPartialOrder {a b c : _} {A : Set a} (S : Setoid {a} {b} A) (_<_ : Rel {a} {c} A) : Set (a ⊔ b ⊔ c) where\n open Setoid S\n field\n β | _$_ l20\n lam : α.β -> α ↣ β | ƛ_ r10\n throw : α ¬ α -> β\n callcc : ¬ α.α -> α\n\ntheory\n (ƛβ) b : α.β a : α |> app (lam(x.b[x]), a) = b[a]\n (ƛη) f : α ↣ β |> lam (x. app(f, x)) = f\n-}\n\nmodule CTLC.Equality where\n\nopen import SOAS.Common\nopen import SOAS.Context\nopen import SOAS.Variable\nopen import SOAS.Families.Core\nopen import SOAS.Families.Build\nopen import SOAS.ContextMaps.Inductive\n\nopen import CTLC.Signature\nopen import CTLC.Syntax\n\nopen import SOAS.Metatheory.SecondOrder.Metasubstitution ΛC:Syn\nopen import SOAS.Metatheory.SecondOrder.Equality ΛC:Syn\n\nprivate\n variable\n α β γ τ : ΛCT\n Γ Δ Π : Ctx\n\ninfix 1 _▹_⊢_≋ₐ_\n\n-- Axioms of equality\ndata _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ ΛC) α Γ → (𝔐 ▷ ΛC) α Γ → Set where\n ƛβ : ⁅ α ⊩ β ⁆ ⁅ α ⁆̣ ▹ ∅ ⊢ (ƛ 𝔞⟨ x₀ ⟩) $ 𝔟 ≋ₐ 𝔞⟨ 𝔟 ⟩\n ƛη : ⁅ α ↣ β ⁆̣ ▹ ∅ ⊢ ƛ (𝔞 $ x₀) ≋ₐ 𝔞\n\nopen EqLogic _▹_⊢_≋ₐ_\nopen ≋-Reasoning\n", "meta": {"hexsha": "85659407efd9692d49a4cafa48281aee3bf56b63", "size": 1111, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "out/CTLC/Equality.agda", "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_issues_repo_path": "out/CTLC/Equality.agda", "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_forks_repo_path": "out/CTLC/Equality.agda", "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "avg_line_length": 21.7843137255, "max_line_length": 99, "alphanum_fraction": 0.598559856, "num_tokens": 522, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473647220787, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.6377370245253534}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\n\nmodule stash.modalities.PushoutProduct {i j k l}\n {A : Type i} {B : Type j}\n {A' : Type k} {B' : Type l}\n where\n\n□-span : (f : A → B) (g : A' → B') → Span\n□-span f g = span (B × A') (A × B') (A × A')\n (λ { (a , a') → f a , a'})\n (λ { (a , a') → a , g a' })\n\nmodule PshoutProd (f : A → B) (g : A' → B') =\n PushoutRec {d = □-span f g}\n (λ { (b , a') → b , g a' })\n (λ { (a , b') → f a , b' })\n (λ { (a , a') → idp })\n\n_□_ : (f : A → B) (g : A' → B') → Pushout (□-span f g) → B × B'\nf □ g = PshoutProd.f f g\n\n□-glue-β : (f : A → B) (g : A' → B') (a : A) (a' : A') → ap (f □ g) (glue (a , a')) == idp\n□-glue-β f g a a' = PshoutProd.glue-β f g (a , a')\n \nmodule _ (f : A → B) (g : A' → B') where\n\n private\n abstract\n \n ↓-□=cst-out : ∀ {a a' b b'} {p p' : (f a , g a') == (b , b')}\n → p == p' [ (λ w → (f □ g) w == (b , b')) ↓ glue (a , a') ]\n → p == p'\n ↓-□=cst-out {p' = idp} q = ↓-app=cst-out' q ∙ □-glue-β f g _ _\n\n ↓-□=cst-in : ∀ {a a' b b'} {p p' : (f a , g a') == (b , b')}\n → p == p'\n → p == p' [ (λ w → (f □ g) w == (b , b')) ↓ glue (a , a') ]\n ↓-□=cst-in {p' = idp} q = ↓-app=cst-in' (q ∙ ! (□-glue-β f g _ _))\n\n\n ↓-□=cst-β : ∀ {a a' b b'} {p p' : (f a , g a') == (b , b')}\n (q : p == p')\n → ↓-□=cst-out (↓-□=cst-in q) == q\n ↓-□=cst-β {a} {a'} {p' = idp} idp = {!!} ∙ !-inv-l (□-glue-β f g a a')\n\n\n □-hfiber-to : (b : B) (b' : B')\n → hfiber (f □ g) (b , b') → hfiber f b * hfiber g b'\n □-hfiber-to b b' = uncurry $ Pushout-elim\n (λ { (_ , a') → λ p → right (a' , snd×= p) })\n (λ { (a , _) → λ p → left (a , fst×= p) }) {!!}\n\n --\n -- Here is the main theorem\n --\n \n □-hfiber : (b : B) (b' : B')\n → hfiber (f □ g) (b , b') ≃ hfiber f b * hfiber g b'\n □-hfiber b b' = {!!}\n", "meta": {"hexsha": "298bf8bb9386e6c32b50edfa4f53c4bed2cea165", "size": 1849, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/stash/modalities/PushoutProduct.agda", "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 294, "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_issues_repo_path": "theorems/stash/modalities/PushoutProduct.agda", "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 31, "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_forks_repo_path": "theorems/stash/modalities/PushoutProduct.agda", "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 50, "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "avg_line_length": 29.8225806452, "max_line_length": 90, "alphanum_fraction": 0.3656030287, "num_tokens": 901, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473779969194, "lm_q2_score": 0.7310585669110203, "lm_q1q2_score": 0.637737024007014}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Algebra.Definitions where\n\nopen import Cubical.Core.Everything\nopen import Cubical.Relation.Binary\nopen import Cubical.Data.Sigma using (_×_)\nopen import Cubical.Data.Sum using (_⊎_)\nopen import Cubical.HITs.PropositionalTruncation using (∥_∥)\n\nopen import Cubical.Algebra.Base\n\nprivate\n variable\n a b c ℓ : Level\n A : Type a\n B : Type b\n C : Type c\n\n------------------------------------------------------------------------\n-- Properties of operations\n\nCongruent₁ : Rel A ℓ → Op₁ A → Type _\nCongruent₁ R f = f Preserves R ⟶ R\n\nCongruent₂ : Rel A ℓ → Op₂ A → Type _\nCongruent₂ R • = • Preserves₂ R ⟶ R ⟶ R\n\nLeftCongruent : Rel A ℓ → Op₂ A → Type _\nLeftCongruent R _•_ = ∀ {x} → (x •_) Preserves R ⟶ R\n\nRightCongruent : Rel A ℓ → Op₂ A → Type _\nRightCongruent R _•_ = ∀ {x} → (_• x) Preserves R ⟶ R\n\nHomomorphic₀ : (A → B) → A → B → Type _\nHomomorphic₀ ⟦_⟧ x y = ⟦ x ⟧ ≡ y\n\nHomomorphic₁ : (A → B) → Op₁ A → Op₁ B → Type _\nHomomorphic₁ ⟦_⟧ f g = ∀ x → ⟦ f x ⟧ ≡ g ⟦ x ⟧\n\nHomomorphic₂ : (A → B) → Op₂ A → Op₂ B → Type _\nHomomorphic₂ ⟦_⟧ _•_ _◦_ = ∀ x y → ⟦ x • y ⟧ ≡ ⟦ x ⟧ ◦ ⟦ y ⟧\n\nContramorphic₂ : (A → B) → Op₂ A → Op₂ B → Type _\nContramorphic₂ ⟦_⟧ _•_ _◦_ = ∀ x y → ⟦ x • y ⟧ ≡ ⟦ y ⟧ ◦ ⟦ x ⟧\n\nAssociative : Op₂ A → Type _\nAssociative _•_ = ∀ x y z → (x • y) • z ≡ x • (y • z)\n\nCommutative : Op₂ A → Type _\nCommutative _•_ = ∀ x y → x • y ≡ y • x\n\nLeftIdentity : A → Opₗ A B → Type _\nLeftIdentity e _•_ = ∀ x → e • x ≡ x\n\nRightIdentity : A → Opᵣ A B → Type _\nRightIdentity e _•_ = ∀ x → x • e ≡ x\n\nIdentity : A → Op₂ A → Type _\nIdentity e • = (LeftIdentity e •) × (RightIdentity e •)\n\nLeftZero : A → Opᵣ B A → Type _\nLeftZero z _•_ = ∀ x → z • x ≡ z\n\nRightZero : A → Opₗ B A → Type _\nRightZero z _•_ = ∀ x → x • z ≡ z\n\nZero : A → Op₂ A → Type _\nZero z • = (LeftZero z •) × (RightZero z •)\n\nLeftInverse : C → (A → B) → (B → A → C) → Type _\nLeftInverse e _⁻¹ _•_ = ∀ x → (x ⁻¹) • x ≡ e\n\nRightInverse : C → (A → B) → (A → B → C) → Type _\nRightInverse e _⁻¹ _•_ = ∀ x → x • (x ⁻¹) ≡ e\n\nInverse : A → Op₁ A → Op₂ A → Type _\nInverse e ⁻¹ • = (LeftInverse e ⁻¹ •) × (RightInverse e ⁻¹ •)\n\nLeftConical : B → Opᵣ A B → Type _\nLeftConical e _•_ = ∀ x y → x • y ≡ e → x ≡ e\n\nRightConical : B → Opₗ A B → Type _\nRightConical e _•_ = ∀ x y → x • y ≡ e → y ≡ e\n\nConical : A → Op₂ A → Type _\nConical e • = (LeftConical e •) × (RightConical e •)\n\n_DistributesOverˡ_ : Opₗ A B → Op₂ B → Type _\n_*_ DistributesOverˡ _+_ =\n ∀ x y z → (x * (y + z)) ≡ ((x * y) + (x * z))\n\n_DistributesOverʳ_ : Opᵣ A B → Op₂ B → Type _\n_*_ DistributesOverʳ _+_ =\n ∀ x y z → ((y + z) * x) ≡ ((y * x) + (z * x))\n\n_DistributesOver_ : Op₂ A → Op₂ A → Type _\n* DistributesOver + = (* DistributesOverˡ +) × (* DistributesOverʳ +)\n\n_IdempotentOn_ : Op₂ A → A → Type _\n_•_ IdempotentOn x = (x • x) ≡ x\n\nIdempotent : Op₂ A → Type _\nIdempotent • = ∀ x → • IdempotentOn x\n\nIdempotentFun : Op₁ A → Type _\nIdempotentFun f = ∀ x → f (f x) ≡ f x\n\nSelective : Op₂ A → Type _\nSelective _•_ = ∀ x y → ∥ (x • y ≡ x) ⊎ (x • y ≡ y) ∥\n\n_Absorbs_ : Op₂ A → Op₂ A → Type _\n_∧_ Absorbs _∨_ = ∀ x y → (x ∧ (x ∨ y)) ≡ x\n\nAbsorptive : Op₂ A → Op₂ A → Type _\nAbsorptive ∧ ∨ = (∧ Absorbs ∨) × (∨ Absorbs ∧)\n\nInvolutive : Op₁ A → Type _\nInvolutive f = ∀ x → f (f x) ≡ x\n\nLeftCancellative : (A → B → C) → Type _\nLeftCancellative _•_ = ∀ x {y z} → (x • y) ≡ (x • z) → y ≡ z\n\nRightCancellative : (A → B → C) → Type _\nRightCancellative _•_ = ∀ {x y} z → (x • z) ≡ (y • z) → x ≡ y\n\nCancellative : (A → A → B) → Type _\nCancellative • = (LeftCancellative •) × (RightCancellative •)\n\nInterchangeable : Op₂ A → Op₂ A → Type _\nInterchangeable _•_ _◦_ = ∀ w x y z → ((w • x) ◦ (y • z)) ≡ ((w ◦ y) • (x ◦ z))\n", "meta": {"hexsha": "e8db90c242593ea31627fbe0c3f24d67f1afc18b", "size": 3707, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Definitions.agda", "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Definitions.agda", "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Definitions.agda", "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.2977099237, "max_line_length": 79, "alphanum_fraction": 0.556244942, "num_tokens": 1553, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.779992900254107, "lm_q2_score": 0.8175744806385543, "lm_q1q2_score": 0.6377022903270112}} {"text": "{-\n\nPart 2: Transport and composition\n\n• Cubical transport\n• Subst as a special case of cubical transport\n• Path induction from subst\n• Homogeneous composition (hcomp)\n• Binary composition of paths as special case of hcomp\n\n-}\n\n{-# OPTIONS --cubical #-}\nmodule Part2 where\n\nopen import Part1\n\n-- While path types are great for reasoning about equality they don't\n-- let us transport along paths between types or even compose paths.\n-- Furthermore, as paths are not inductively defined we don't\n-- automatically get an induction principle for them. In order to\n-- remedy this Cubical Agda also has a built-in (generalized)\n-- transport operation and homogeneous composition operation from\n-- which the induction principle (and much more!) is derivable.\n\n-- The basic operation is called transp and we will soon explain it,\n-- but let's first focus on the special case of cubical transport:\ntransport : A ≡ B → A → B\ntransport p a = transp (λ i → p i) i0 a\n\n-- This is a more primitive operation than \"transport\" in HoTT as it\n-- only lets us turn a path into a function. However, the transport of\n-- HoTT can easily be proved from cubical transport and in order to\n-- avoid a name clash we call it \"subst\":\nsubst : (B : A → Type ℓ') {x y : A} (p : x ≡ y) → B x → B y\nsubst B p pa = transport (λ i → B (p i)) pa\n\n-- The transp operation is a generalized transport in the sense that\n-- it lets us specify where the transport is the identity function.\n-- The general type of transp is:\n--\n-- transp : (A : I → Type ℓ) (r : I) (a : A i0) → A i1\n--\n-- There is an additional side condition which to be satisfied for\n-- Cubical Agda to typecheck \"transp A r a\". This is that A has to be\n-- \"constant\" on r. This means that A should be a constant function\n-- whenever r = i1 is satisfied. This side condition is vacuously true\n-- when r = i0, so there is nothing to check when writing transport as\n-- above. However, when r is equal to i1 the transp function will\n-- compute as the identity function.\n--\n-- transp A i1 a = a\n--\n-- Having this extra generality is useful for quite technical reasons,\n-- for instance we can easily relate a with its transport over p:\ntransportFill : (p : A ≡ B) (a : A) → PathP (λ i → p i) a (transport p a)\ntransportFill p a i = transp (λ j → p (i ∧ j)) (~ i) a\n\n-- Another result that follows easily from transp is that transporting\n-- in a constant family is the identity function (up to a path). Note\n-- that this is *not* proved by refl. This is maybe not surprising as\n-- transport is not defined by pattern-matching on p.\ntransportRefl : (x : A) → transport refl x ≡ x\ntransportRefl {A = A} x i = transp (λ _ → A) i x\n\n-- Having transp lets us prove many more useful lemmas like this. For\n-- details see:\n--\n-- Cubical.Foundations.Transport\n--\n-- For experts: the file\n--\n-- Cubical.Foundations.CartesianKanOps\n--\n-- contains a reformulation of these operations which might be useful\n-- for people familiar with \"cartesian\" cubical type theory.\n\n\n-- We can also define the J eliminator (aka path induction)\nJ : {x : A} (P : (z : A) → x ≡ z → Type ℓ'')\n (d : P x refl) {y : A} (p : x ≡ y) → P y p\nJ {x = x} P d p = subst (λ X → P (fst X) (snd X)) (isContrSingl x .snd (_ , p)) d\n\n-- Unfolded version:\n--\n-- transport (λ i → P (p i) (λ j → p (i ∧ j))) d\n\n-- So J is provable, but it doesn't satisfy the computation rule of\n-- refl definitionally as _≡_ is not inductively defined. See\n-- exercises for how to prove it. Not having this hold definitionally\n-- is almost never a problem in practice as the cubical primitives\n-- satisfy many new definitional equalities (c.f. cong).\n\n-- As we now have J we can define path concatenation and many more\n-- things, however this is not the way to do things in Cubical\n-- Agda. One of the key features of cubical type theory is that the\n-- transp primitive reduces differently for different types formers\n-- (see CCHM or the Cubical Agda paper for details). For paths it\n-- reduces to another primitive operation called hcomp. This primitive\n-- is much better suited for concatenating paths than J as it is much\n-- more general. In particular, it lets us compose multiple higher\n-- dimensional cubes directly. We will explain it by example.\n\n-- In order to compose two paths we write:\ncompPath : {x y z : A} → x ≡ y → y ≡ z → x ≡ z\ncompPath {x = x} p q i = hcomp (λ j → λ { (i = i0) → x\n ; (i = i1) → q j })\n (p i)\n\n-- This is best understood with the following drawing:\n--\n-- x z\n-- ^ ^\n-- ¦ ¦\n-- x ¦ ¦ q j\n-- ¦ ¦\n-- x ----------> y\n-- p i\n--\n-- In the drawing the direction i goes left-to-right and j goes\n-- bottom-to-top. As we are constructing a path from x to z along i we\n-- have i : I in the context already and we put p i as bottom. The\n-- direction j that we are doing the composition in is abstracted in\n-- the first argument to hcomp.\n\n-- These are related to lifting conditions for Kan cubical sets.\n\n-- A more natural form of composition of paths in Cubical Agda is\n-- ternary composition:\n--\n-- x w\n-- ^ ^\n-- ¦ ¦\n-- p (~ j) ¦ ¦ r j\n-- ¦ ¦\n-- y ----------> z\n-- q i\n--\n-- This is written p ∙∙ q ∙∙ r in the agda/cubical library (∙ is \"\\.\")\n-- and implemented by:\n\n_∙∙_∙∙_ : {x y z w : A} → x ≡ y → y ≡ z → z ≡ w → x ≡ w\n(p ∙∙ q ∙∙ r) i = hcomp (λ j → λ { (i = i0) → p (~ j)\n ; (i = i1) → r j })\n (q i)\n\n-- Note that we can easily define mixfix operators with many arguments\n-- in Agda.\n\n-- Using this we can define compPath much slicker:\n_∙_ : {x y z : A} → x ≡ y → y ≡ z → x ≡ z\np ∙ q = refl ∙∙ p ∙∙ q\n\n-- To prove algebraic properties of this operation (in particular that\n-- it's a groupoid) we need to talk about filling using the hfill\n-- operation. There is no time for this today, but the interested\n-- reader can consult\n--\n-- Cubical.Foundations.GroupoidLaws\n\n-- In case there is time I might show the following briefly:\n\ndoubleCompPath-filler : {x y z w : A} (p : x ≡ y) (q : y ≡ z) (r : z ≡ w)\n → PathP (λ j → p (~ j) ≡ r j) q (p ∙∙ q ∙∙ r)\ndoubleCompPath-filler p q r j i =\n hfill (λ j → λ { (i = i0) → p (~ j)\n ; (i = i1) → r j })\n (inS (q i)) j\n\ncompPath-filler : {x y z : A} (p : x ≡ y) (q : y ≡ z)\n → PathP (λ j → x ≡ q j) p (p ∙ q)\ncompPath-filler p q = doubleCompPath-filler refl p q\n\nrUnit : {x y : A} (p : x ≡ y) → p ≡ p ∙ refl\nrUnit p i j = compPath-filler p refl i j\n\n\n-- Having hcomp as a primitive operation lets us prove many things\n-- very directly. For instance, we can prove that any proposition is\n-- also a set using a higher dimensional hcomp.\nisProp→isSet : isProp A → isSet A\nisProp→isSet h a b p q j i =\n hcomp (λ k → λ { (i = i0) → h a a k\n ; (i = i1) → h a b k\n ; (j = i0) → h a (p i) k\n ; (j = i1) → h a (q i) k }) a\n\n-- Geometric picture: start with a square with a everywhere as base,\n-- then change its sides so that they connect p with q over refl_a and\n-- refl_b.\n\nisPropIsProp : isProp (isProp A)\nisPropIsProp f g i a b = isProp→isSet f a b (f a b) (g a b) i\n\nisPropIsSet : isProp (isSet A)\nisPropIsSet h1 h2 i x y = isPropIsProp (h1 x y) (h2 x y) i\n\n-- In order to understand what the second argument to hcomp is one\n-- should read about partial elements. We refer the interested reader\n-- to the Cubical Agda documentation:\n--\n-- https://agda.readthedocs.io/en/v2.6.1.3/language/cubical.html#partial-elements\n--\n-- However, for beginners one doesn't need to write hcomp to prove\n-- thing as the library provide many basic lemmas. In particular, the\n-- library provides equational reasoning combinators as in regular\n-- Agda which let us write things like:\n--\n-- inverseUniqueness : (r : R) → isProp (Σ[ r' ∈ R ] r · r' ≡ 1r)\n-- inverseUniqueness r (r' , rr'≡1) (r'' , rr''≡1) = Σ≡Prop (λ _ → is-set _ _) path\n-- where\n-- path : r' ≡ r''\n-- path = r' ≡⟨ sym (·Rid _) ⟩\n-- r' · 1r ≡⟨ cong (r' ·_) (sym rr''≡1) ⟩\n-- r' · (r · r'') ≡⟨ ·Assoc _ _ _ ⟩\n-- (r' · r) · r'' ≡⟨ cong (_· r'') (·-comm _ _) ⟩\n-- (r · r') · r'' ≡⟨ cong (_· r'') rr'≡1 ⟩\n-- 1r · r'' ≡⟨ ·Lid _ ⟩\n-- r'' ∎\n", "meta": {"hexsha": "771033f3a4c14f012d0fe6465d7e2a0a4afd7961", "size": 8447, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "04-cubical-type-theory/material/Part2.agda", "max_stars_repo_name": "bafain/EPIT-2020", "max_stars_repo_head_hexsha": "34742c0409818f8fe581ffc92992d1b5f29f6b47", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-04-03T16:28:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-03T16:28:06.000Z", "max_issues_repo_path": "04-cubical-type-theory/material/Part2.agda", "max_issues_repo_name": "EgbertRijke/EPIT-2020", "max_issues_repo_head_hexsha": "9a510959fb0e6da9bcc6b0faa0dea76a2821bbdb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "04-cubical-type-theory/material/Part2.agda", "max_forks_repo_name": "EgbertRijke/EPIT-2020", "max_forks_repo_head_hexsha": "9a510959fb0e6da9bcc6b0faa0dea76a2821bbdb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.3954545455, "max_line_length": 83, "alphanum_fraction": 0.6134722387, "num_tokens": 2581, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.817574471748733, "lm_q2_score": 0.7799928900257126, "lm_q1q2_score": 0.6377022750305396}} {"text": "{-# OPTIONS --allow-unsolved-metas #-}\nmodule automaton-ex where\n\nopen import Data.Nat\nopen import Data.List\nopen import Data.Maybe\nopen import Relation.Binary.PropositionalEquality hiding ( [_] )\nopen import Relation.Binary.Definitions\nopen import Relation.Nullary using (¬_; Dec; yes; no)\nopen import logic\n\nopen import automaton\nopen Automaton\n\ndata StatesQ : Set where\n q1 : StatesQ\n q2 : StatesQ\n q3 : StatesQ\n\ndata In2 : Set where\n i0 : In2\n i1 : In2\n\ntransitionQ : StatesQ → In2 → StatesQ\ntransitionQ q1 i0 = q1\ntransitionQ q1 i1 = q2\ntransitionQ q2 i0 = q3\ntransitionQ q2 i1 = q2\ntransitionQ q3 i0 = q2\ntransitionQ q3 i1 = q2\n\naendQ : StatesQ → Bool\naendQ q2 = true\naendQ _ = false\n\na1 : Automaton StatesQ In2\na1 = record {\n δ = transitionQ\n ; aend = aendQ\n }\n\ntest1 : accept a1 q1 ( i0 ∷ i1 ∷ i0 ∷ [] ) ≡ false\ntest1 = refl\ntest2 = accept a1 q1 ( i0 ∷ i1 ∷ i0 ∷ i1 ∷ [] ) \ntest3 = trace a1 q1 ( i0 ∷ i1 ∷ i0 ∷ i1 ∷ [] ) \n\ndata States1 : Set where\n sr : States1\n ss : States1\n st : States1\n\ntransition1 : States1 → In2 → States1\ntransition1 sr i0 = sr\ntransition1 sr i1 = ss\ntransition1 ss i0 = sr\ntransition1 ss i1 = st\ntransition1 st i0 = sr\ntransition1 st i1 = st\n\nfin1 : States1 → Bool\nfin1 st = true\nfin1 ss = false\nfin1 sr = false\n\nam1 : Automaton States1 In2\nam1 = record { δ = transition1 ; aend = fin1 }\n\n\nexample1-1 = accept am1 sr ( i0 ∷ i1 ∷ i0 ∷ [] )\nexample1-2 = accept am1 sr ( i1 ∷ i1 ∷ i1 ∷ [] )\ntrace-2 = trace am1 sr ( i1 ∷ i1 ∷ i1 ∷ [] )\n\nexample1-3 = reachable am1 sr st ( i1 ∷ i1 ∷ i1 ∷ [] )\n\n-- data Dec' (A : Set) : Set where\n-- yes' : A → Dec' A\n-- no' : ¬ A → Dec' A\n-- \n-- ieq' : (i i' : In2 ) → Dec' ( i ≡ i' )\n-- ieq' i0 i0 = yes' refl\n-- ieq' i1 i1 = yes' refl\n-- ieq' i0 i1 = no' ( λ () )\n-- ieq' i1 i0 = no' ( λ () )\n\nieq : (i i' : In2 ) → Dec ( i ≡ i' )\nieq i0 i0 = yes refl\nieq i1 i1 = yes refl\nieq i0 i1 = no ( λ () )\nieq i1 i0 = no ( λ () )\n\n-- p.83 problem 1.4\n--\n-- w has at least three i0's and at least two i1's\n\ncount-chars : List In2 → In2 → ℕ\ncount-chars [] _ = 0\ncount-chars (h ∷ t) x with ieq h x\n... | yes y = suc ( count-chars t x )\n... | no n = count-chars t x \n\ntest11 : count-chars ( i1 ∷ i1 ∷ i0 ∷ [] ) i0 ≡ 1\ntest11 = refl\n\nex1_4a : (x : List In2) → Bool\nex1_4a x = ( count-chars x i0 ≥b 3 ) /\\ ( count-chars x i1 ≥b 2 )\n\nlanguage' : { Σ : Set } → Set\nlanguage' {Σ} = List Σ → Bool\n\nlang14a : language' {In2}\nlang14a = ex1_4a\n\nopen _∧_\n\nam14a-tr : ℕ ∧ ℕ → In2 → ℕ ∧ ℕ\nam14a-tr p i0 = record { proj1 = suc (proj1 p) ; proj2 = proj2 p }\nam14a-tr p i1 = record { proj1 = proj1 p ; proj2 = suc (proj2 p) }\n\nam14a : Automaton (ℕ ∧ ℕ) In2\nam14a = record { δ = am14a-tr ; aend = λ x → ( proj1 x ≥b 3 ) /\\ ( proj2 x ≥b 2 )}\n\ndata am14s : Set where\n a00 : am14s\n a10 : am14s\n a20 : am14s\n a30 : am14s\n a01 : am14s\n a11 : am14s\n a21 : am14s\n a31 : am14s\n a02 : am14s\n a12 : am14s\n a22 : am14s\n a32 : am14s\n\nam14a-tr' : am14s → In2 → am14s\nam14a-tr' a00 i0 = a10\nam14a-tr' _ _ = a10\n\nam14a' : Automaton am14s In2\nam14a' = record { δ = am14a-tr' ; aend = λ x → {!!} }\n", "meta": {"hexsha": "095fe1021808243ae66d37833159a4cdb5211fad", "size": 3133, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/automaton-ex.agda", "max_stars_repo_name": "shinji-kono/automaton-in-agda", "max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/automaton-ex.agda", "max_issues_repo_name": "shinji-kono/automaton-in-agda", "max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/automaton-ex.agda", "max_forks_repo_name": "shinji-kono/automaton-in-agda", "max_forks_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.0633802817, "max_line_length": 85, "alphanum_fraction": 0.5863389722, "num_tokens": 1352, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744673038222, "lm_q2_score": 0.7799928900257126, "lm_q1q2_score": 0.6377022715635408}} {"text": "module L.Base.Sigma.Core where\n\n-- Import the Σ record with constructors fst, snd\nopen import Agda.Builtin.Sigma public\n\nsplit : ∀{a b c} {A : Set a} {B : A → Set b} (C : Σ A B → Set c)\n → ((x : A)(y : B x) → C (x , y)) → (p : Σ A B) → C p\nsplit C g (a , b) = g a b\n", "meta": {"hexsha": "6256cef57b0b63ed19078c92be9494603863e07c", "size": 273, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/L/Base/Sigma/Core.agda", "max_stars_repo_name": "borszag/smallib", "max_stars_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/L/Base/Sigma/Core.agda", "max_issues_repo_name": "borszag/smallib", "max_issues_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 10, "max_issues_repo_issues_event_min_datetime": "2020-10-19T10:13:16.000Z", "max_issues_repo_issues_event_max_datetime": "2020-11-09T16:40:39.000Z", "max_forks_repo_path": "src/L/Base/Sigma/Core.agda", "max_forks_repo_name": "borszag/smallib", "max_forks_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.3333333333, "max_line_length": 64, "alphanum_fraction": 0.5421245421, "num_tokens": 108, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8615382165412809, "lm_q2_score": 0.7401743677704878, "lm_q1q2_score": 0.6376885047385563}} {"text": "------------------------------------------------------------------------------\n-- Proving mirror (mirror t) = t using mutual data types\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOT.FOTC.Program.Mirror.MirrorMutualSL where\n\ninfixr 5 _∷_ _++_\n\nopen import Function\nopen import Relation.Binary.PropositionalEquality\nopen ≡-Reasoning\n\n------------------------------------------------------------------------------\n-- The mutual data types\n\ndata Tree (A : Set) : Set\ndata Forest (A : Set) : Set\n\ndata Tree A where\n tree : A → Forest A → Tree A\n\ndata Forest A where\n [] : Forest A\n _∷_ : Tree A → Forest A → Forest A\n\n------------------------------------------------------------------------------\n-- Auxiliary functions\n\n_++_ : {A : Set} → Forest A → Forest A → Forest A\n[] ++ ys = ys\n(a ∷ xs) ++ ys = a ∷ xs ++ ys\n\nmap : {A B : Set} → (Tree A → Tree B) → Forest A → Forest B\nmap f [] = []\nmap f (a ∷ ts) = f a ∷ map f ts\n\nreverse : {A : Set} → Forest A → Forest A\nreverse [] = []\nreverse (a ∷ ts) = reverse ts ++ a ∷ []\n\npostulate\n map-++ : {A B : Set}(f : Tree A → Tree B)(xs ys : Forest A) →\n map f (xs ++ ys) ≡ map f xs ++ map f ys\n reverse-++ : {A : Set}(xs ys : Forest A) →\n reverse (xs ++ ys) ≡ reverse ys ++ reverse xs\n\n------------------------------------------------------------------------------\n-- The mirror function.\n\n{-# TERMINATING #-}\nmirror : {A : Set} → Tree A → Tree A\nmirror (tree a ts) = tree a (reverse (map mirror ts))\n\n------------------------------------------------------------------------------\n-- The proof of the property.\nmirror-involutive : {A : Set} → (t : Tree A) → mirror (mirror t) ≡ t\nhelper : {A : Set} → (ts : Forest A) →\n reverse (map mirror (reverse (map mirror ts))) ≡ ts\n\nmirror-involutive (tree a []) = refl\nmirror-involutive (tree a (t ∷ ts)) =\n begin\n tree a (reverse (map mirror (reverse (map mirror ts) ++ mirror t ∷ [])))\n ≡⟨ cong (tree a) (helper (t ∷ ts)) ⟩\n tree a (t ∷ ts)\n ∎\n\nhelper [] = refl\nhelper (t ∷ ts) =\n begin\n reverse (map mirror (reverse (map mirror ts) ++ mirror t ∷ []))\n ≡⟨ cong reverse\n (map-++ mirror (reverse (map mirror ts)) (mirror t ∷ []))\n ⟩\n reverse (map mirror (reverse (map mirror ts)) ++\n (map mirror (mirror t ∷ [])))\n ≡⟨ subst (λ x → (reverse (map mirror (reverse (map mirror ts)) ++\n (map mirror (mirror t ∷ [])))) ≡ x)\n (reverse-++ (map mirror (reverse (map mirror ts)))\n (map mirror (mirror t ∷ [])))\n refl\n ⟩\n reverse (map mirror (mirror t ∷ [])) ++\n reverse (map mirror (reverse (map mirror ts)))\n ≡⟨ refl ⟩\n mirror (mirror t) ∷ reverse (map mirror (reverse (map mirror ts)))\n ≡⟨ cong (flip _∷_ (reverse (map mirror (reverse (map mirror ts)))))\n (mirror-involutive t)\n ⟩\n t ∷ reverse (map mirror (reverse (map mirror ts)))\n ≡⟨ cong (_∷_ t) (helper ts) ⟩\n t ∷ ts\n ∎\n", "meta": {"hexsha": "184359c9471fcd0acb0a4d81629e219a8ac7276b", "size": 3248, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/FOTC/Program/Mirror/MirrorMutualSL.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/FOT/FOTC/Program/Mirror/MirrorMutualSL.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/FOT/FOTC/Program/Mirror/MirrorMutualSL.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 32.8080808081, "max_line_length": 78, "alphanum_fraction": 0.4525862069, "num_tokens": 869, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382094310357, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.637688499475735}} {"text": "------------------------------------------------------------------------------\n-- Co-lists\n------------------------------------------------------------------------------\n\n{-# OPTIONS --allow-unsolved-metas #-}\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule GFPs.Colist where\n\nopen import FOTC.Base\nopen import FOTC.Base.List\n\n------------------------------------------------------------------------------\n-- Colist is a greatest fixed-point of a functor\n\n-- The functor.\nListF : (D → Set) → D → Set\nListF A xs = xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ A xs')\n\n-- Colist is the greatest fixed-point of ListF.\npostulate\n Colist : D → Set\n\n -- Colist is a post-fixed point of ListF, i.e.\n --\n -- Colist ≤ ListF Colist.\n Colist-out-ho : ∀ {n} → Colist n → ListF Colist n\n\n -- Colist is the greatest post-fixed point of ListF, i.e.\n --\n -- ∀ A. A ≤ ListF A ⇒ A ≤ Colist.\n Colist-coind-ho :\n (A : D → Set) →\n -- A is post-fixed point of ListF.\n (∀ {xs} → A xs → ListF A xs) →\n -- Colist is greater than A.\n ∀ {xs} → A xs → Colist xs\n\n------------------------------------------------------------------------------\n-- First-order versions\n\nColist-out : ∀ {xs} →\n Colist xs →\n xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ Colist xs')\nColist-out = Colist-out-ho\n\nColist-coind :\n (A : D → Set) →\n (∀ {xs} → A xs → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ A xs')) →\n ∀ {xs} → A xs → Colist xs\nColist-coind = Colist-coind-ho\n\n------------------------------------------------------------------------------\n-- Because a greatest post-fixed point is a fixed-point, then the\n-- Colist predicate is also a pre-fixed point of the functional ListF,\n-- i.e.\n--\n-- ListF Colist ≤ Colist.\nColist-in-ho : ∀ {xs} → ListF Colist xs → Colist xs\nColist-in-ho h = Colist-coind-ho A h' h\n where\n A : D → Set\n A xs = ListF Colist xs\n\n h' : ∀ {xs} → A xs → ListF A xs\n h' (inj₁ xs≡0) = inj₁ xs≡0\n h' (inj₂ (x' , xs' , prf , CLxs' )) =\n inj₂ (x' , xs' , prf , Colist-out CLxs')\n\n-- The first-order version.\nColist-in : ∀ {xs} →\n xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ Colist xs') →\n Colist xs\nColist-in = Colist-in-ho\n\n------------------------------------------------------------------------------\n-- A stronger co-induction principle\n--\n-- From (Paulson, 1997. p. 16).\n\npostulate\n Colist-coind-stronger-ho :\n (A : D → Set) →\n (∀ {xs} → A xs → ListF A xs ∨ Colist xs) →\n ∀ {xs} → A xs → Colist xs\n\nColist-coind-ho' :\n (A : D → Set) →\n (∀ {xs} → A xs → ListF A xs) →\n ∀ {xs} → A xs → Colist xs\nColist-coind-ho' A h Axs =\n Colist-coind-stronger-ho A (λ Ays → inj₁ (h Ays)) Axs\n\n-- The first-order version.\nColist-coind-stronger :\n (A : D → Set) →\n (∀ {xs} → A xs →\n (xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ A xs'))\n ∨ Colist xs) →\n ∀ {xs} → A xs → Colist xs\nColist-coind-stronger = Colist-coind-stronger-ho\n\n-- 13 January 2014. As expected, we cannot prove\n-- Colist-coind-stronger-ho from Colist-coind-ho.\nColist-coind-stronger-ho' :\n (A : D → Set) →\n (∀ {xs} → A xs → ListF A xs ∨ Colist xs) →\n ∀ {xs} → A xs → Colist xs\nColist-coind-stronger-ho' A h {xs} Axs = case prf (λ h' → h') (h Axs)\n where\n prf : ListF A xs → Colist xs\n prf h' = Colist-coind-ho A {!!} Axs\n\n------------------------------------------------------------------------------\n-- References\n--\n-- Paulson, L. C. (1997). Mechanizing Coinduction and Corecursion in\n-- Higher-order Logic. Journal of Logic and Computation 7.2,\n-- pp. 175–204.\n", "meta": {"hexsha": "103fe245d3185267679ea35119d6845978523d06", "size": 3638, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/fixed-points/GFPs/Colist.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/fixed-points/GFPs/Colist.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/fixed-points/GFPs/Colist.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 29.5772357724, "max_line_length": 78, "alphanum_fraction": 0.4686641012, "num_tokens": 1196, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677583778257, "lm_q2_score": 0.7520125793176222, "lm_q1q2_score": 0.6376824211558909}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Foundations.HLevels' where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Data.Nat\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Univalence\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Pointed\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.GroupoidLaws\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Homotopy.Connected\nopen import Cubical.Homotopy.Loopspace\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Sigma\nopen import Cubical.Data.Unit\nopen import Cubical.Foundations.Structure\n\nprivate\n variable\n ℓ : Level\n\nisOfHLevel' : HLevel → Type ℓ → Type ℓ\nisOfHLevel' 0 A = isOfHLevel 0 A\nisOfHLevel' (suc n) A = (x y : A) → isOfHLevel' n (x ≡ y)\n\nisOfHLevel'→ : {n : HLevel} {A : Type ℓ} (l : isOfHLevel' n A) → isOfHLevel n A\nisOfHLevel'→ {n = 0} l = l\nisOfHLevel'→ {n = 1} l a b = l a b .fst\nisOfHLevel'→ {n = suc (suc _)} l a b = isOfHLevel'→ (l a b)\n\nisOfHLevel→' : {n : HLevel} {A : Type ℓ} (l : isOfHLevel n A) → isOfHLevel' n A\nisOfHLevel→' {n = 0} l = l\nisOfHLevel→' {n = 1} l = isProp→isContrPath l\nisOfHLevel→' {n = suc (suc _)} l = λ x y → isOfHLevel→' (l x y)\n\nisPropIsOfHLevel' : (n : HLevel) {A : Type ℓ} → isProp (isOfHLevel' n A)\nisPropIsOfHLevel' 0 = isPropIsOfHLevel 0\nisPropIsOfHLevel' 1 p q = funExt (λ a → funExt (λ b → isPropIsContr (p a b) (q a b)))\nisPropIsOfHLevel' (suc (suc n)) f g i a b = isPropIsOfHLevel' (suc n) (f a b) (g a b) i -- isPropIsOfHLevel (suc (suc n))\n\nisOfHLevel≡' : (n : HLevel) {A : Type ℓ} → isOfHLevel n A ≡ isOfHLevel' n A\nisOfHLevel≡' n = isoToPath (iso isOfHLevel→'\n isOfHLevel'→\n (λ p' → isPropIsOfHLevel' n _ p')\n λ p → isPropIsOfHLevel n _ p)\n\nHL→ = isOfHLevel→'\nHL← = isOfHLevel'→\n\nmodule _ {X : Type ℓ} where\n -- Lemma 7.2.8 in the HoTT book\n -- For n >= -1, if X being inhabited implies X is an n-type, then X is an n-type\n inh→ntype→ntype : {n : ℕ} (t : X → isOfHLevel (suc n) X) → isOfHLevel (suc n) X\n inh→ntype→ntype {n = 0} t = λ x y → t x x y\n inh→ntype→ntype {n = suc _} t = λ x y → t x x y\n\nmodule _ {X : Type ℓ} where\n -- Theorem 7.2.7 in the HoTT book\n -- For n >= -1, X is an (n+1)-type if all its loop spaces are n-types\n truncSelfId→truncId : {n : ℕ} → ((x : X) → isOfHLevel (suc n) (x ≡ x)) → isOfHLevel (suc (suc n)) X\n truncSelfId→truncId {n = 0} t =\n λ x x' → inh→ntype→ntype {n = 0}\n λ p → J (λ y q → isOfHLevel 1 (x ≡ y))\n (t x)\n p\n truncSelfId→truncId {n = suc m} t =\n λ x x' → inh→ntype→ntype {n = suc m}\n λ p → J (λ y q → isOfHLevel (suc (suc m)) (x ≡ y))\n (t x)\n p\n\n EquivPresHLevel : {Y : Type ℓ} → {n : ℕ} → (X≃Y : X ≃ Y) → (hX : isOfHLevel n X) → isOfHLevel n Y\n EquivPresHLevel {Y} {n} X≃Y hX = subst (λ x → isOfHLevel n x) (ua X≃Y) hX\n", "meta": {"hexsha": "4e0d82542dc5df323814877d2b921104addbb8b5", "size": 3241, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Foundations/HLevels'.agda", "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Foundations/HLevels'.agda", "max_issues_repo_name": "Schippmunk/cubical", "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Foundations/HLevels'.agda", "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.0253164557, "max_line_length": 121, "alphanum_fraction": 0.6001234187, "num_tokens": 1237, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677430095496, "lm_q2_score": 0.7520125848754472, "lm_q1q2_score": 0.6376824143116103}} {"text": "-- open import Data.List\n-- open import Data.Fin\n\nopen import Agda.Builtin.Nat public\n using (Nat; zero; suc)\n\nopen import Agda.Builtin.List public\n using (List; []; _∷_)\n\ndata Fin : Nat → Set where\n fzero : {n : Nat} → Fin (suc n)\n fsuc : {n : Nat} (i : Fin n) → Fin (suc n)\n\nfoldr : ∀ {a b} {A : Set a} {B : Set b} → (A → B → B) → B → List A → B\nfoldr c n [] = n\nfoldr c n (x ∷ xs) = c x (foldr c n xs)\n\nlength : ∀ {a} {A : Set a} → List A → Nat\nlength = foldr (λ _ → suc) 0\n\nlookup : ∀ {a} {A : Set a} (xs : List A) → Fin (length xs) → A\nlookup [] ()\nlookup (x ∷ xs) fzero = x\nlookup (x ∷ xs) (fsuc i) = lookup xs i\n\ndata ListD {I : Set} (T : I → Set) : List I → Set where\n nilD : ListD T []\n consD : ∀ {x xs} → (elem : T x) → (rest : ListD T xs) → ListD T (x ∷ xs)\n\nlookupD : {I : Set} {T : I → Set} {xs : List I} → ListD T xs → (at : Fin (length xs)) → {!lookup ? ?!}\nlookupD xs at = {!!}\n", "meta": {"hexsha": "b8af4c121b59982710020ea09e081792d92bca9f", "size": 908, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue3312.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/interaction/Issue3312.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/interaction/Issue3312.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 28.375, "max_line_length": 102, "alphanum_fraction": 0.5297356828, "num_tokens": 369, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677660619633, "lm_q2_score": 0.752012562644147, "lm_q1q2_score": 0.6376824127958896}} {"text": "open import Data.Product using ( _×_ ; _,_ ; proj₁ ; proj₂ )\nopen import FRP.LTL.RSet.Core using ( RSet ; ⟦_⟧ )\nopen import FRP.LTL.RSet.Globally using ( [_] )\nopen import FRP.LTL.RSet.Causal using ( _⊵_ ; arr )\nopen import FRP.LTL.RSet.Stateless using ( _⇒_ )\n\nmodule FRP.LTL.RSet.Product where\n\ninfixr 2 _∧_\n\n-- Conjunction of LTL formulae\n\n_∧_ : RSet → RSet → RSet\n(A ∧ B) t = A t × B t\n\n-- Product structure\n\nfst : ∀ {A B} → ⟦ (A ∧ B) ⊵ A ⟧\nfst {A} {B} = arr [ (λ {u} (ab : A u × B u) → proj₁ ab) ]\n\nsnd : ∀ {A B} → ⟦ (A ∧ B) ⊵ B ⟧\nsnd {A} {B} = arr [ (λ {u} (ab : A u × B u) → proj₂ ab) ]\n\n_&&&_ : ∀ {A B C} → ⟦ (A ⊵ B) ⇒ (A ⊵ C) ⇒ (A ⊵ (B ∧ C)) ⟧\n(f &&& g) s≤t σ = (f s≤t σ , g s≤t σ)", "meta": {"hexsha": "d896e0ab82f7b6fd5b9ed12c63a27e85b090dbe5", "size": 691, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/FRP/LTL/RSet/Product.agda", "max_stars_repo_name": "agda/agda-frp-ltl", "max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 21, "max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z", "max_issues_repo_path": "src/FRP/LTL/RSet/Product.agda", "max_issues_repo_name": "agda/agda-frp-ltl", "max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z", "max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z", "max_forks_repo_path": "src/FRP/LTL/RSet/Product.agda", "max_forks_repo_name": "agda/agda-frp-ltl", "max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z", "avg_line_length": 27.64, "max_line_length": 60, "alphanum_fraction": 0.5282199711, "num_tokens": 319, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9161096204605946, "lm_q2_score": 0.6959583124210896, "lm_q1q2_score": 0.6375741054484804}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\nopen import cw.CW\nopen import cw.FinCW\nopen import cw.FinBoundary\nopen import cohomology.Theory\n\n{- The reason that RephraseDualizedFirstFinBoundary did not handle this case\n is because [FinSkeleton n] does not compute. -}\n\nmodule cw.cohomology.cochainequiv.DualizedFirstBoundary (OT : OrdinaryTheory lzero)\n (⊙fin-skel : ⊙FinSkeleton 1) where\n\nopen OrdinaryTheory OT\nopen FreeAbelianGroup\n\nprivate\n fin-skel = ⊙FinSkeleton.skel ⊙fin-skel\n I = AttachedFinSkeleton.numCells fin-skel\n\n I₋₁ = AttachedFinSkeleton.skel fin-skel\n\n module FAG = FreeAbelianGroup (Fin I)\n module FAG₋₁ = FreeAbelianGroup (Fin I₋₁)\n\n open FAG renaming (FreeAbGroup to G) using ()\n open FAG₋₁ renaming (FreeAbGroup to G₋₁) using ()\n\nabstract\n rephrase-dualized-first-boundary-in-degree : ∀ g * x) (symm eq) e''-eval)\n\nkleene-converse-evaluation : ∀{e e' d : TNat} →\n e ≃ e' → d ~>* e → d ≃ e'\nkleene-converse-evaluation (kleeneq n val S1 S2) eval =\n kleeneq n val (eval-trans eval S1) S2\n", "meta": {"hexsha": "cfee9eb0be20374ac86e2d1acbd2c598e859c98a", "size": 863, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Eq/KleeneTheoryEarly.agda", "max_stars_repo_name": "msullivan/godels-t", "max_stars_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2016-12-25T01:52:57.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-22T00:28:03.000Z", "max_issues_repo_path": "Eq/KleeneTheoryEarly.agda", "max_issues_repo_name": "msullivan/godels-t", "max_issues_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Eq/KleeneTheoryEarly.agda", "max_forks_repo_name": "msullivan/godels-t", "max_forks_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-04-26T11:39:14.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-04T22:37:18.000Z", "avg_line_length": 33.1923076923, "max_line_length": 90, "alphanum_fraction": 0.6790266512, "num_tokens": 283, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9073122238669025, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.6374140974068578}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Dodo.Unary.Unique where\n\n-- Stdlib imports\nopen import Level using (Level)\nopen import Relation.Unary using (Pred)\nopen import Relation.Binary using (Rel)\n-- Local imports\nopen import Dodo.Nullary.Unique\n\n\n-- # Definitions #\n\n-- | At most one element satisfies the predicate\nUnique₁ : ∀ {a ℓ₁ ℓ₂ : Level} {A : Set a}\n → Rel A ℓ₁ → Pred A ℓ₂ → Set _\nUnique₁ _≈_ P = ∀ {x y} → P x → P y → x ≈ y\n\n-- | For every `x`, there exists at most one inhabitant of `P x`.\nUniquePred : ∀ {a ℓ : Level} {A : Set a}\n → Pred A ℓ → Set _\nUniquePred P = ∀ x → Unique (P x)\n", "meta": {"hexsha": "21416802f97d42f092e6f877fc67ea78d96c19af", "size": 600, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Dodo/Unary/Unique.agda", "max_stars_repo_name": "sourcedennis/agda-dodo", "max_stars_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Dodo/Unary/Unique.agda", "max_issues_repo_name": "sourcedennis/agda-dodo", "max_issues_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Dodo/Unary/Unique.agda", "max_forks_repo_name": "sourcedennis/agda-dodo", "max_forks_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.0, "max_line_length": 65, "alphanum_fraction": 0.6433333333, "num_tokens": 190, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8947894745194281, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.6372978564054302}} {"text": "module L.Base.Nat where\n\n-- Reexport definitions\nopen import L.Base.Nat.Core public\n\n-- Functions on Nats\npred : Nat → Nat\npred = ind (λ _ → Nat) zero (λ x _ → x)\n\ninfixl 6 _+_\ninfixl 7 _*_\n\n_+_ : Nat → Nat → Nat\nzero + y = y\nsucc x + y = succ (x + y)\n\n{-# BUILTIN NATPLUS _+_ #-}\n\n_*_ : Nat → Nat → Nat\nzero * y = zero\nsucc x * y = y + x * y\n\n{-# BUILTIN NATTIMES _*_ #-}\n", "meta": {"hexsha": "abd25bb12d24e2d1a8764649984bdba47e730053", "size": 377, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/L/Base/Nat.agda", "max_stars_repo_name": "borszag/smallib", "max_stars_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/L/Base/Nat.agda", "max_issues_repo_name": "borszag/smallib", "max_issues_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 10, "max_issues_repo_issues_event_min_datetime": "2020-10-19T10:13:16.000Z", "max_issues_repo_issues_event_max_datetime": "2020-11-09T16:40:39.000Z", "max_forks_repo_path": "src/L/Base/Nat.agda", "max_forks_repo_name": "borszag/smallib", "max_forks_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 15.7083333333, "max_line_length": 39, "alphanum_fraction": 0.5835543767, "num_tokens": 137, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467738423873, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.6372673699803726}} {"text": "{-# OPTIONS --safe --experimental-lossy-unification #-}\nmodule Cubical.Algebra.Polynomials.Multivariate.Equiv.Induced-Poly where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Isomorphism\n\nopen import Cubical.Data.Nat renaming (_+_ to _+n_; _·_ to _·n_)\nopen import Cubical.Data.Vec\nopen import Cubical.Data.Sigma\n\nopen import Cubical.Algebra.Ring\nopen import Cubical.Algebra.CommRing\n\nopen import Cubical.Algebra.Polynomials.Univariate.Base\n\nopen import Cubical.Algebra.Polynomials.Multivariate.Base\nopen import Cubical.Algebra.Polynomials.Multivariate.Properties\nopen import Cubical.Algebra.CommRing.Instances.MultivariatePoly\nopen Nth-Poly-structure\n\nprivate variable\n ℓ : Level\n\n\n-----------------------------------------------------------------------------\n-- Lift\n\nopen IsRingHom\n\nmakeCommRingHomPoly : (A' B' : CommRing ℓ) → (f : CommRingHom A' B') → (n : ℕ) → CommRingHom (PolyCommRing A' n) (PolyCommRing B' n)\nfst (makeCommRingHomPoly A' B' (f , fcrhom) n) = Poly-Rec-Set.f A' n (Poly B' n) trunc\n 0P\n (λ v a → base v (f a))\n _Poly+_\n Poly+-assoc\n Poly+-Rid\n Poly+-comm\n (λ v → (cong (base v) (pres0 fcrhom)) ∙ (base-0P v))\n λ v a b → (base-Poly+ v (f a) (f b)) ∙ (cong (base v) (sym (pres+ fcrhom a b)))\nsnd (makeCommRingHomPoly A' B' (f , fcrhom) n) = makeIsRingHom\n (cong (base (replicate zero)) (pres1 fcrhom))\n (λ P Q → refl)\n (Poly-Ind-Prop.f A' n _ (λ P p q i Q j → trunc _ _ (p Q) (q Q) i j)\n (λ Q → refl)\n (λ v a → Poly-Ind-Prop.f A' n _ (λ _ → trunc _ _)\n refl\n (λ v' a' → cong (base (v +n-vec v')) (pres· fcrhom a a'))\n λ {U V} ind-U ind-V → cong₂ _Poly+_ ind-U ind-V)\n λ {U V} ind-U ind-V Q → cong₂ _Poly+_ (ind-U Q) (ind-V Q))\n\n\n\n-----------------------------------------------------------------------------\n-- Lift preserve equivalence\n\nopen RingEquivs\n\nlift-equiv-poly : (A' B' : CommRing ℓ) → (e : CommRingEquiv A' B') → (n : ℕ) → CommRingEquiv (PolyCommRing A' n) (PolyCommRing B' n)\nfst (lift-equiv-poly A' B' e n) = isoToEquiv is\n where\n et = fst e\n fcrh = snd e\n f = fst et\n g = invEq et\n gcrh : IsRingHom (snd (CommRing→Ring B')) g (snd (CommRing→Ring A'))\n gcrh = isRingHomInv (et , fcrh)\n\n is : Iso _ _\n Iso.fun is = fst (makeCommRingHomPoly A' B' (f , fcrh) n)\n Iso.inv is = fst (makeCommRingHomPoly B' A' (g , gcrh) n)\n Iso.rightInv is = (Poly-Ind-Prop.f B' n _ (λ _ → trunc _ _)\n refl\n (λ v a → cong (base v) (secEq et a))\n λ {U V} ind-U ind-V → cong₂ _Poly+_ ind-U ind-V)\n Iso.leftInv is = (Poly-Ind-Prop.f A' n _ (λ _ → trunc _ _)\n refl\n (λ v a → cong (base v) (retEq et a))\n λ {U V} ind-U ind-V → cong₂ _Poly+_ ind-U ind-V)\nsnd (lift-equiv-poly A' B' e n) = snd (makeCommRingHomPoly A' B' (fst (fst e) , snd e) n)\n", "meta": {"hexsha": "95fa9a44c6b75e6f9b4c265b0357d4735c49a580", "size": 3420, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Polynomials/Multivariate/Equiv/Induced-Poly.agda", "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Polynomials/Multivariate/Equiv/Induced-Poly.agda", "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Polynomials/Multivariate/Equiv/Induced-Poly.agda", "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.2222222222, "max_line_length": 132, "alphanum_fraction": 0.5005847953, "num_tokens": 981, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467548438126, "lm_q2_score": 0.7248702880639791, "lm_q1q2_score": 0.6372673614341469}} {"text": "{-\n\nTheory about isomorphisms\n\n- Definitions of [section] and [retract]\n- Definition of isomorphisms ([Iso])\n- Any isomorphism is an equivalence ([isoToEquiv])\n\n-}\n{-# OPTIONS --cubical --safe #-}\nmodule Cubical.Foundations.Isomorphism where\n\nopen import Cubical.Core.Everything\n\nopen import Cubical.Foundations.Prelude\n\nprivate\n variable\n ℓ : Level\n\n-- Section and retract\nmodule _ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} where\n section : (f : A → B) → (g : B → A) → Type ℓ'\n section f g = ∀ b → f (g b) ≡ b\n\n -- NB: `g` is the retraction!\n retract : (f : A → B) → (g : B → A) → Type ℓ\n retract f g = ∀ a → g (f a) ≡ a\n\nrecord Iso {ℓ ℓ'} (A : Type ℓ) (B : Type ℓ') : Type (ℓ-max ℓ ℓ') where\n constructor iso\n field\n fun : A → B\n inv : B → A\n rightInv : section fun inv\n leftInv : retract fun inv\n\n-- Any iso is an equivalence\nmodule _ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (i : Iso A B) where\n open Iso i renaming ( fun to f\n ; inv to g\n ; rightInv to s\n ; leftInv to t)\n\n private\n module _ (y : B) (x0 x1 : A) (p0 : f x0 ≡ y) (p1 : f x1 ≡ y) where\n fill0 : I → I → A\n fill0 i = hfill (λ k → λ { (i = i1) → t x0 k\n ; (i = i0) → g y })\n (inS (g (p0 (~ i))))\n\n fill1 : I → I → A\n fill1 i = hfill (λ k → λ { (i = i1) → t x1 k\n ; (i = i0) → g y })\n (inS (g (p1 (~ i))))\n\n fill2 : I → I → A\n fill2 i = hfill (λ k → λ { (i = i1) → fill1 k i1\n ; (i = i0) → fill0 k i1 })\n (inS (g y))\n\n p : x0 ≡ x1\n p i = fill2 i i1\n\n sq : I → I → A\n sq i j = hcomp (λ k → λ { (i = i1) → fill1 j (~ k)\n ; (i = i0) → fill0 j (~ k)\n ; (j = i1) → t (fill2 i i1) (~ k)\n ; (j = i0) → g y })\n (fill2 i j)\n\n sq1 : I → I → B\n sq1 i j = hcomp (λ k → λ { (i = i1) → s (p1 (~ j)) k\n ; (i = i0) → s (p0 (~ j)) k\n ; (j = i1) → s (f (p i)) k\n ; (j = i0) → s y k })\n (f (sq i j))\n\n lemIso : (x0 , p0) ≡ (x1 , p1)\n lemIso i .fst = p i\n lemIso i .snd = λ j → sq1 i (~ j)\n\n isoToIsEquiv : isEquiv f\n isoToIsEquiv .equiv-proof y .fst .fst = g y\n isoToIsEquiv .equiv-proof y .fst .snd = s y\n isoToIsEquiv .equiv-proof y .snd z = lemIso y (g y) (fst z) (s y) (snd z)\n\n\nisoToPath : ∀ {ℓ} {A B : Type ℓ} → (Iso A B) → A ≡ B\nisoToPath {A = A} {B = B} f i =\n Glue B (λ { (i = i0) → (A , (Iso.fun f , isoToIsEquiv f))\n ; (i = i1) → (B , (λ x → x) ,\n record { equiv-proof = λ y → (y , refl)\n , λ z i → z .snd (~ i)\n , λ j → z .snd (~ i ∨ j)})})\n", "meta": {"hexsha": "169b83ba873f49f1906787bd81f2a02e8aed4a2d", "size": 2989, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Foundations/Isomorphism.agda", "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Foundations/Isomorphism.agda", "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Foundations/Isomorphism.agda", "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.1354166667, "max_line_length": 94, "alphanum_fraction": 0.3964536634, "num_tokens": 1044, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467675095294, "lm_q2_score": 0.7248702702332475, "lm_q1q2_score": 0.6372673549393185}} {"text": "{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-}\nmodule Cubical.Data.NatMinusOne.Base where\n\nopen import Cubical.Core.Primitives\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Empty\nopen import Cubical.Data.Int.Base using (ℤ; pos; negsuc; -_)\n\nrecord ℕ₋₁ : Type₀ where\n constructor -1+_\n field\n n : ℕ\n\npattern neg1 = -1+ zero\npattern ℕ→ℕ₋₁ n = -1+ (suc n)\n\n1+_ : ℕ₋₁ → ℕ\n1+_ (-1+ n) = n\n\nsuc₋₁ : ℕ₋₁ → ℕ₋₁\nsuc₋₁ (-1+ n) = -1+ (suc n)\n\n-- Natural number and negative integer literals for ℕ₋₁\n\nopen import Cubical.Data.Nat.Literals public\n\ninstance\n fromNatℕ₋₁ : FromNat ℕ₋₁\n fromNatℕ₋₁ = record { Constraint = λ _ → ⊤ ; fromNat = ℕ→ℕ₋₁ }\n\ninstance\n negativeℕ₋₁ : Negative ℕ₋₁\n negativeℕ₋₁ = record { Constraint = λ { (suc (suc _)) → ⊥ ; _ → ⊤ }\n ; fromNeg = λ { zero → 0 ; (suc zero) → neg1 } }\n", "meta": {"hexsha": "be040de923ad0fa61bdb654584d061a74db93c4a", "size": 850, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/NatMinusOne/Base.agda", "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/NatMinusOne/Base.agda", "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Data/NatMinusOne/Base.agda", "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.2857142857, "max_line_length": 70, "alphanum_fraction": 0.6305882353, "num_tokens": 321, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.879146761176671, "lm_q2_score": 0.7248702702332475, "lm_q1q2_score": 0.6372673503488178}} {"text": "module Cats.Category.Cones where\n\nopen import Relation.Binary using (Rel ; IsEquivalence ; _Preserves₂_⟶_⟶_)\nopen import Level using (_⊔_)\n\nopen import Cats.Category.Base\nopen import Cats.Functor using (Functor) renaming (_∘_ to _∘F_)\nopen import Cats.Util.Conv\n\nimport Relation.Binary.PropositionalEquality as ≡\n\nimport Cats.Category.Constructions.Iso as Iso\nimport Cats.Util.Function as Fun\n\n\nmodule _ {lo la l≈ lo′ la′ l≈′}\n {J : Category lo la l≈}\n {Z : Category lo′ la′ l≈′}\n (D : Functor J Z)\n where\n\n infixr 9 _∘_\n infixr 4 _≈_\n\n private\n module Z = Category Z\n module J = Category J\n module D = Functor D\n\n\n -- We could define cones in terms of wedges (and limits in terms of ends).\n record Cone : Set (lo ⊔ la ⊔ la′ ⊔ lo′ ⊔ l≈′) where\n field\n Apex : Z.Obj\n arr : ∀ j → Apex Z.⇒ D.fobj j\n commute : ∀ {i j} (α : i J.⇒ j) → arr j Z.≈ D.fmap α Z.∘ arr i\n\n\n instance\n HasObj-Cone : HasObj Cone lo′ la′ l≈′\n HasObj-Cone = record { Cat = Z ; _ᴼ = Cone.Apex }\n\n\n Obj = Cone\n\n\n record _⇒_ (A B : Obj) : Set (lo ⊔ la′ ⊔ l≈′) where\n private\n module A = Cone A ; module B = Cone B\n\n field\n θ : A.Apex Z.⇒ B.Apex\n commute : ∀ j → B.arr j Z.∘ θ Z.≈ A.arr j\n\n\n instance\n HasArrow-⇒ : ∀ {A B} → HasArrow (A ⇒ B) lo′ la′ l≈′\n HasArrow-⇒ = record { Cat = Z ; _⃗ = _⇒_.θ }\n\n\n _≈_ : ∀ {A B} → Rel (A ⇒ B) l≈′\n _≈_ = Z._≈_ Fun.on _⇒_.θ\n\n\n equiv : ∀ {A B} → IsEquivalence (_≈_ {A} {B})\n equiv = Fun.on-isEquivalence _⇒_.θ Z.equiv\n\n\n id : ∀ {A} → A ⇒ A\n id = record\n { θ = Z.id\n ; commute = λ j → Z.id-r\n }\n\n\n _∘_ : ∀ {A B C} → B ⇒ C → A ⇒ B → A ⇒ C\n _∘_ {A} {B} {C} f g = record\n { θ = f ⃗ Z.∘ g ⃗\n ; commute = λ j →\n begin\n arr C j Z.∘ f ⃗ Z.∘ g ⃗\n ≈⟨ Z.unassoc ⟩\n (arr C j Z.∘ f ⃗) Z.∘ g ⃗\n ≈⟨ Z.∘-resp-l (commute f j) ⟩\n arr B j Z.∘ g ⃗\n ≈⟨ commute g j ⟩\n arr A j\n ∎\n }\n where\n open Cone using (arr)\n open _⇒_ using (commute)\n open Z.≈-Reasoning\n\n\n Cones : Category (lo ⊔ la ⊔ lo′ ⊔ la′ ⊔ l≈′) (lo ⊔ la′ ⊔ l≈′) l≈′\n Cones = record\n { Obj = Obj\n ; _⇒_ = _⇒_\n ; _≈_ = _≈_\n ; id = id\n ; _∘_ = _∘_\n ; equiv = equiv\n ; ∘-resp = Z.∘-resp\n ; id-r = Z.id-r\n ; id-l = Z.id-l\n ; assoc = Z.assoc\n }\n\n\n open Iso.Build Cones using (_≅_)\n open Iso.Build Z using () renaming (_≅_ to _≅Z_)\n\n\n cone-iso→obj-iso : ∀ {c d : Cone}\n → c ≅ d\n → c ᴼ ≅Z d ᴼ\n cone-iso→obj-iso i = record\n { forth = forth i ⃗\n ; back = back i ⃗\n ; back-forth = back-forth i\n ; forth-back = forth-back i\n }\n where\n open _≅_\n\n\napFunctor : ∀ {lo la l≈ lo′ la′ l≈′ lo″ la″ l≈″}\n → {Y : Category lo la l≈}\n → {Z : Category lo′ la′ l≈′}\n → (F : Functor Y Z)\n → {J : Category lo″ la″ l≈″}\n → {D : Functor J Y}\n → Cone D\n → Cone (F ∘F D)\napFunctor {Y = Y} {Z} F {J} {D} c = record\n { Apex = fobj F Apex\n ; arr = λ j → fmap F (arr j)\n ; commute = λ {i} {j} α → Z.≈.sym (\n begin\n fmap (F ∘F D) α Z.∘ fmap F (arr i)\n ≡⟨ ≡.refl ⟩\n fmap F (fmap D α) Z.∘ fmap F (arr i)\n ≈⟨ fmap-∘ F ⟩\n fmap F (fmap D α Y.∘ arr i)\n ≈⟨ fmap-resp F (Y.≈.sym (commute α)) ⟩\n fmap F (arr j)\n ∎\n )\n }\n where\n module Y = Category Y\n module Z = Category Z\n open Cone c\n open Z.≈-Reasoning\n open Functor\n", "meta": {"hexsha": "561887bedc1a53b1b0be83b7444c62ddf41e0de1", "size": 3443, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Category/Cones.agda", "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cats/Category/Cones.agda", "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cats/Category/Cones.agda", "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.9299363057, "max_line_length": 76, "alphanum_fraction": 0.4879465582, "num_tokens": 1437, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467580102419, "lm_q2_score": 0.7248702642896702, "lm_q1q2_score": 0.6372673428282908}} {"text": "module MUniverse where\n\n-- This is universe polymorphism and extensional equality module\nopen import Sec2\n-- import Data.List\n\ndata _≃₀_ {A : Set} (a : A) (b : A) : Set where\n a≃b : (a ≡ b) → a ≃₀ b\n\ndata _≃₁_ {A : Set} (f : A → A) (g : A → A) : Set where\n f≃g : ((x y : A) → (x ≃₀ y) → (f x ≃₀ g y)) → f ≃₁ g\n\nB==B : 1 ≃₀ 1\nB==B = a≃b refl\n\nB==B1 : T ≃₀ T\nB==B1 = a≃b refl \n\n\n-- This is the same as + for natural numbers\n_⋆_ : (x y : ℕ) → ℕ\nZ ⋆ y = y\n(S x) ⋆ y = S (x ⋆ y)\n\n-- Proof that + and ⋆ are equivalent functions!\n+==⋆ : (x : ℕ) → ((_+_) x) ≃₁ ((_⋆_) x)\n+==⋆ x = f≃g (λ x₁ y x₂ → a≃b (prove x x₁ y x₂))\n where\n fcong : (x y : ℕ) → (p : (x + y) ≡ (x ⋆ y)) → S (x + y) ≡ S (x ⋆ y)\n fcong x y p with (x + y) | (x ⋆ y) \n fcong x y refl | m | .m = refl\n\n prove' : (x y : ℕ) → (x + y) ≡ (x ⋆ y)\n prove' Z y = refl\n prove' (S x) y with (prove' x y)\n prove' (S x) y | p = fcong x y p\n\n\n prove : (x y z : ℕ) → (p : y ≃₀ z) → (x + y) ≡ (x ⋆ z)\n prove x y .y (a≃b refl) = prove' x y\n\nelim≃₁ : {A : Set} → (f g : A → A) (a : f ≃₁ g)\n → (x y : A) → (p : x ≃₀ y)\n → (f x ≃₀ g y)\nelim≃₁ f g (f≃g a) x .x (a≃b refl) = a x x (a≃b refl)\n\n-- Theorem that ≃₁ is a partial equivalence relation\n≃₁-symmetric : {A : Set} → {f g : A → A} → (f ≃₁ g) → (g ≃₁ f)\n≃₁-symmetric {A} {f} {g} (f≃g x) = f≃g (λ x₁ y x₂ → a≃b (prove x₁ y x₂ (f≃g x)))\n where\n prove : (z y : A) → (p : z ≃₀ y) → (f ≃₁ g) → (g z ≡ f y) \n prove z .z (a≃b refl) (f≃g x) with (x z z (a≃b refl) )\n prove z .z (a≃b refl) (f≃g x₁) | a≃b p with (f z) | (g z) \n prove z .z (a≃b refl) (f≃g x₁) | a≃b refl | m | .m = refl\n\n≃₁-transitive : {A : Set} → {f g h : A → A}\n → (f ≃₁ g) → (g ≃₁ h) → (f ≃₁ h)\n≃₁-transitive {A} {f} {g} {h} (f≃g x) (f≃g y) = f≃g (λ x₁ y₁ x₂ → a≃b (prove x₁ y₁ x₂ (f≃g x) (f≃g y)))\n where\n prove : (x y : A) (p : x ≃₀ y)\n → (f ≃₁ g)\n → (g ≃₁ h)\n → (f x ≡ h y)\n prove x₁ .x₁ (a≃b refl) (f≃g x₂) (f≃g x₃) with (x₂ x₁ x₁ (a≃b refl)) | (x₃ x₁ x₁ (a≃b refl))\n prove x₁ .x₁ (a≃b refl) (f≃g x₂) (f≃g x₃) | a≃b x₄ | a≃b x₅ with (f x₁) | (g x₁) | (h x₁)\n prove x₁ .x₁ (a≃b refl) (f≃g x₂) (f≃g x₃) | a≃b refl | a≃b refl | p1 | .p1 | .p1 = refl\n", "meta": {"hexsha": "38439f46cc834f4870346b0a99e38543303c0a5b", "size": 2239, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "MUniverse.agda", "max_stars_repo_name": "amal029/agda-tutorial-dybjer", "max_stars_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:52:30.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-08T12:52:30.000Z", "max_issues_repo_path": "MUniverse.agda", "max_issues_repo_name": "amal029/agda-tutorial-dybjer", "max_issues_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MUniverse.agda", "max_forks_repo_name": "amal029/agda-tutorial-dybjer", "max_forks_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.4179104478, "max_line_length": 103, "alphanum_fraction": 0.4385886556, "num_tokens": 1194, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797100118214, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.637146446315494}} {"text": "\nmodule Vec where\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\ndata Vec (A : Set) : Nat -> Set where\n ε : Vec A zero\n _►_ : {n : Nat} -> A -> Vec A n -> Vec A (suc n)\n\nvec : {A : Set}{n : Nat} -> A -> Vec A n\nvec {n = zero} x = ε\nvec {n = suc n} x = x ► vec x\n\n_<*>_ : {A B : Set}{n : Nat} -> Vec (A -> B) n -> Vec A n -> Vec B n\nε <*> ε = ε\n(f ► fs) <*> (x ► xs) = f x ► (fs <*> xs)\n\n-- map\n-- zip\n", "meta": {"hexsha": "e98a58dfbf2f028a317a3b4014aee97aed476e5f", "size": 429, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/tactics/bool/Vec.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/tactics/bool/Vec.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/outdated-and-incorrect/tactics/bool/Vec.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 19.5, "max_line_length": 68, "alphanum_fraction": 0.4312354312, "num_tokens": 176, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9111797100118214, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.6371464406048036}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import LogicalFormulae\nopen import Functions.Definition\nopen import Numbers.Naturals.Definition\nopen import Numbers.Naturals.Order\nopen import Sets.FinSet.Definition\nopen import Sets.FinSet.Lemmas\nopen import Setoids.Setoids\nopen import Setoids.Cardinality.Infinite.Definition\nopen import Sets.Cardinality.Infinite.Lemmas\nopen import Setoids.Subset\nopen import Sets.EquivalenceRelations\n\nmodule Setoids.Cardinality.Infinite.Lemmas where\n\nfinsetNotInfiniteSetoid : {n : ℕ} → InfiniteSetoid (reflSetoid (FinSet n)) → False\nfinsetNotInfiniteSetoid {n} isInfinite = isInfinite n id (record { inj = record { wellDefined = id ; injective = id } ; surj = record { wellDefined = id ; surjective = λ {x} → x , refl } })\n\ndedekindInfiniteImpliesInfiniteSetoid : {a b : _} {A : Set a} (S : Setoid {a} {b} A) → DedekindInfiniteSetoid S → InfiniteSetoid S\ndedekindInfiniteImpliesInfiniteSetoid S record { inj = inj ; isInjection = isInj } zero f isBij with SetoidInvertible.inverse (setoidBijectiveImpliesInvertible isBij) (inj 0)\n... | ()\ndedekindInfiniteImpliesInfiniteSetoid {A = A} S record { inj = inj ; isInjection = isInj } (succ n) f isBij = noInjectionNToFinite {f = t} tInjective\n where\n t : ℕ → FinSet (succ n)\n t n = SetoidInvertible.inverse (setoidBijectiveImpliesInvertible isBij) (inj n)\n tInjective : Injection t\n tInjective pr = SetoidInjection.injective isInj (SetoidInjection.injective (SetoidBijection.inj (setoidInvertibleImpliesBijective (inverseInvertible (setoidBijectiveImpliesInvertible isBij)))) pr)\n", "meta": {"hexsha": "1b73c694290d1618e51c1cbd81ade4f211038340", "size": 1643, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Setoids/Cardinality/Infinite/Lemmas.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Setoids/Cardinality/Infinite/Lemmas.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Setoids/Cardinality/Infinite/Lemmas.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 54.7666666667, "max_line_length": 200, "alphanum_fraction": 0.7723676202, "num_tokens": 497, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.853912760387131, "lm_q2_score": 0.746138993030751, "lm_q1q2_score": 0.6371376071713629}} {"text": "------------------------------------------------------------------------\n-- Finite maps, i.e. lookup tables (currently only some type\n-- signatures)\n------------------------------------------------------------------------\n\nmodule Data.Map where\n\nopen import Relation.Nullary\nopen import Relation.Binary\nopen import Data.List as L using (List)\nopen import Data.Product\n\nmodule Map₁ (key-dto : DecTotalOrder) (elem-s : Setoid) where\n\n open DecTotalOrder key-dto renaming (carrier to key)\n open Setoid elem-s renaming (carrier to elem; _≈_ to _≗_)\n\n infixr 6 _∪_\n infix 5 _∈?_\n infix 4 _∈_ _|≈|_\n\n abstract postulate decSetoid : DecSetoid\n\n Map : Set\n Map = Setoid.carrier (DecSetoid.setoid decSetoid)\n\n _|≈|_ : Rel Map\n _|≈|_ = Setoid._≈_ (DecSetoid.setoid decSetoid)\n\n abstract\n postulate\n empty : Map\n insert : key → elem → Map → Map\n _∪_ : Map → Map → Map\n _∈_ : key → Map → Set\n _↦_∈_ : key → elem → Map → Set\n\n data LookupResult (k : key) (s : Map) : Set where\n found : (e : elem) (k↦e∈s : k ↦ e ∈ s) → LookupResult k s\n notFound : (k∉s : ¬ k ∈ s) → LookupResult k s\n\n abstract\n postulate\n _∈?_ : (k : key) → (s : Map) → LookupResult k s\n toList : Map → List (key × elem)\n\n postulate\n prop-∈₁ : ∀ {x v s} → x ↦ v ∈ s → x ∈ s\n prop-∈₂ : ∀ {x s} → x ∈ s → Σ elem (λ v → x ↦ v ∈ s)\n prop-∈₃ : ∀ {x v w s} → x ↦ v ∈ s → x ↦ w ∈ s → v ≗ w\n\n prop-∈-insert₁ : ∀ {x y v w s} →\n x ≈ y → v ≗ w → x ↦ v ∈ insert y w s\n prop-∈-insert₂ : ∀ {x y v w s} →\n ¬ x ≈ y → x ↦ v ∈ s → x ↦ v ∈ insert y w s\n prop-∈-insert₃ : ∀ {x y v w s} →\n ¬ x ≈ y → x ↦ v ∈ insert y w s → x ↦ v ∈ s\n\n prop-∈-empty : ∀ {x} → ¬ x ∈ empty\n\n prop-∈-∪ : ∀ {x s₁ s₂} → x ∈ s₁ → x ∈ s₁ ∪ s₂\n\n prop-∪₁ : ∀ {s₁ s₂} → s₁ ∪ s₂ |≈| s₂ ∪ s₁\n prop-∪₂ : ∀ {s₁ s₂ s₃} → s₁ ∪ (s₂ ∪ s₃) |≈| (s₁ ∪ s₂) ∪ s₃\n\n prop-∈-|≈|₁ : ∀ {x} → (λ s → x ∈ s) Respects _|≈|_\n prop-∈-|≈|₂ : ∀ {x v} → (λ s → x ↦ v ∈ s) Respects _|≈|_\n prop-∈-≈₁ : ∀ {s} → (λ x → x ∈ s) Respects _≈_\n prop-∈-≈₂ : ∀ {v s} → (λ x → x ↦ v ∈ s) Respects _≈_\n prop-∈-≗ : ∀ {x s} → (λ v → x ↦ v ∈ s) Respects _≗_\n\n -- TODO: Postulates for toList.\n\n singleton : key → elem → Map\n singleton k v = insert k v empty\n\n ⋃_ : List Map → Map\n ⋃_ = L.foldr _∪_ empty\n\n fromList : List (key × elem) → Map\n fromList = L.foldr (uncurry insert) empty\n\nopen Map₁ public renaming (Map to _⇰_)\n", "meta": {"hexsha": "9f750245d487806e800a1de571c29747c8e42def", "size": 2504, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Data/Map.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Data/Map.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Data/Map.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 29.8095238095, "max_line_length": 72, "alphanum_fraction": 0.4748402556, "num_tokens": 1014, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199552262967, "lm_q2_score": 0.7606506418255927, "lm_q1q2_score": 0.6371361565488068}} {"text": "module lists where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; sym; trans; cong)\nopen Eq.≡-Reasoning\nopen import Data.Bool using (Bool; true; false; T; _∧_; _∨_; not)\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_; _≤_; s≤s; z≤n)\nopen import Data.Nat.Properties using\n (+-assoc; +-identityˡ; +-identityʳ; *-assoc; *-identityˡ; *-identityʳ)\nopen import Relation.Nullary using (¬_; Dec; yes; no)\nopen import Data.Product using (_×_; ∃; ∃-syntax) renaming (_,_ to ⟨_,_⟩)\nopen import Function using (_∘_)\nopen import Level using (Level)\n-- open import plfa.part1.Isomorphism using (_≃_; _⇔_)\n\n-- 同型 (isomorphism)\ninfix 0 _≃_\nrecord _≃_ (A B : Set) : Set where\n field\n to : A → B\n from : B → A\n from∘to : ∀ (x : A) → from (to x) ≡ x\n to∘from : ∀ (y : B) → to (from y) ≡ y\n-- open _≃_\n\n-- 同値 (equivalence)\nrecord _⇔_ (A B : Set) : Set where\n field\n to : A → B\n from : B → A\n\n-- Lists\n\n-- リスト\ninfixr 5 _∷_\ndata List (A : Set) : Set where\n [] : List A\n _∷_ : A → List A → List A\n\n_ : List ℕ\n_ = 0 ∷ 1 ∷ 2 ∷ []\n\ndata List′ : Set → Set where\n []′ : ∀ {A : Set} → List′ A\n _∷′_ : ∀ {A : Set} → A → List′ A → List′ A\n\n_ : List ℕ\n_ = _∷_ {ℕ} 0 (_∷_ {ℕ} 1 (_∷_ {ℕ} 2 ([] {ℕ})))\n\n-- List syntax\n\n-- リストの便利記法\npattern [_] z = z ∷ []\npattern [_,_] y z = y ∷ z ∷ []\npattern [_,_,_] x y z = x ∷ y ∷ z ∷ []\npattern [_,_,_,_] w x y z = w ∷ x ∷ y ∷ z ∷ []\npattern [_,_,_,_,_] v w x y z = v ∷ w ∷ x ∷ y ∷ z ∷ []\npattern [_,_,_,_,_,_] u v w x y z = u ∷ v ∷ w ∷ x ∷ y ∷ z ∷ []\n\n-- Append\n\n-- リストの結合\ninfixr 5 _++_\n_++_ : ∀ {A : Set} → List A → List A → List A\n[] ++ ys = ys\n(x ∷ xs) ++ ys = x ∷ (xs ++ ys)\n\n_ : [ 0 , 1 , 2 ] ++ [ 3 , 4 ] ≡ [ 0 , 1 , 2 , 3 , 4 ]\n_ =\n begin\n 0 ∷ 1 ∷ 2 ∷ [] ++ 3 ∷ 4 ∷ []\n ≡⟨⟩\n 0 ∷ (1 ∷ 2 ∷ [] ++ 3 ∷ 4 ∷ [])\n ≡⟨⟩\n 0 ∷ 1 ∷ (2 ∷ [] ++ 3 ∷ 4 ∷ [])\n ≡⟨⟩\n 0 ∷ 1 ∷ 2 ∷ ([] ++ 3 ∷ 4 ∷ [])\n ≡⟨⟩\n 0 ∷ 1 ∷ 2 ∷ 3 ∷ 4 ∷ []\n ∎\n\n-- Reasoning about append\n\n-- リストの結合法則\n++-assoc : ∀ {A : Set} (xs ys zs : List A)\n → (xs ++ ys) ++ zs ≡ xs ++ (ys ++ zs)\n++-assoc [] ys zs =\n begin\n ([] ++ ys) ++ zs\n ≡⟨⟩\n ys ++ zs\n ≡⟨⟩\n [] ++ (ys ++ zs)\n ∎\n++-assoc (x ∷ xs) ys zs =\n begin\n (x ∷ xs ++ ys) ++ zs\n ≡⟨⟩\n x ∷ (xs ++ ys) ++ zs\n ≡⟨⟩\n x ∷ ((xs ++ ys) ++ zs)\n ≡⟨ cong (x ∷_) (++-assoc xs ys zs) ⟩\n x ∷ (xs ++ (ys ++ zs))\n ≡⟨⟩\n x ∷ xs ++ (ys ++ zs)\n ∎\n\n-- 空のリストが左単位元であることの証明\n++-identityˡ : ∀ {A : Set} (xs : List A) → [] ++ xs ≡ xs\n++-identityˡ xs =\n begin\n [] ++ xs\n ≡⟨⟩\n xs\n ∎\n\n-- 空のリストが右単位元であることの証明\n++-identityʳ : ∀ {A : Set} (xs : List A) → xs ++ [] ≡ xs\n++-identityʳ [] =\n begin\n [] ++ []\n ≡⟨⟩\n []\n ∎\n++-identityʳ (x ∷ xs) =\n begin\n (x ∷ xs) ++ []\n ≡⟨⟩\n x ∷ (xs ++ [])\n ≡⟨ cong (x ∷_) (++-identityʳ xs) ⟩\n x ∷ xs\n ∎\n\n-- Length\n\n-- リスト長を返す関数\nlength : ∀ {A : Set} → List A → ℕ\nlength [] = zero\nlength (x ∷ xs) = suc (length xs)\n\n_ : length [ 0 , 1 , 2 ] ≡ 3\n_ =\n begin\n length (0 ∷ 1 ∷ 2 ∷ [])\n ≡⟨⟩\n suc (length (1 ∷ 2 ∷ []))\n ≡⟨⟩\n suc (suc (length (2 ∷ [])))\n ≡⟨⟩\n suc (suc (suc (length {ℕ} [])))\n ≡⟨⟩\n suc (suc (suc zero))\n ∎\n\n-- Reasoning about length\n\n-- lengthの分配性の証明\nlength-++ : ∀ {A : Set} (xs ys : List A)\n → length (xs ++ ys) ≡ length xs + length ys\nlength-++ {A} [] ys =\n begin\n length ([] ++ ys)\n ≡⟨⟩\n length ys\n ≡⟨⟩\n length {A} [] + length ys\n ∎\nlength-++ (x ∷ xs) ys =\n begin\n length ((x ∷ xs) ++ ys)\n ≡⟨⟩\n suc (length (xs ++ ys))\n ≡⟨ cong suc (length-++ xs ys) ⟩\n suc (length xs + length ys)\n ≡⟨⟩\n length (x ∷ xs) + length ys\n ∎\n\n-- Reverse\n\n-- 逆順のリストを返す関数\nreverse : ∀ {A : Set} → List A → List A\nreverse [] = []\nreverse (x ∷ xs) = reverse xs ++ [ x ]\n\n_ : reverse [ 0 , 1 , 2 ] ≡ [ 2 , 1 , 0 ]\n_ =\n begin\n reverse (0 ∷ 1 ∷ 2 ∷ [])\n ≡⟨⟩\n reverse (1 ∷ 2 ∷ []) ++ [ 0 ]\n ≡⟨⟩\n (reverse (2 ∷ []) ++ [ 1 ]) ++ [ 0 ]\n ≡⟨⟩\n ((reverse [] ++ [ 2 ]) ++ [ 1 ]) ++ [ 0 ]\n ≡⟨⟩\n (([] ++ [ 2 ]) ++ [ 1 ]) ++ [ 0 ]\n ≡⟨⟩\n (([] ++ 2 ∷ []) ++ 1 ∷ []) ++ 0 ∷ []\n ≡⟨⟩\n (2 ∷ [] ++ 1 ∷ []) ++ 0 ∷ []\n ≡⟨⟩\n 2 ∷ ([] ++ 1 ∷ []) ++ 0 ∷ []\n ≡⟨⟩\n (2 ∷ 1 ∷ []) ++ 0 ∷ []\n ≡⟨⟩\n 2 ∷ (1 ∷ [] ++ 0 ∷ [])\n ≡⟨⟩\n 2 ∷ 1 ∷ ([] ++ 0 ∷ [])\n ≡⟨⟩\n 2 ∷ 1 ∷ 0 ∷ []\n ≡⟨⟩\n [ 2 , 1 , 0 ]\n ∎\n\n-- Faster reverse\n\nshunt : ∀ {A : Set} → List A → List A → List A\nshunt [] ys = ys\nshunt (x ∷ xs) ys = shunt xs (x ∷ ys)\n\nshunt-reverse : ∀ {A : Set} (xs ys : List A)\n → shunt xs ys ≡ reverse xs ++ ys\nshunt-reverse [] ys =\n begin\n shunt [] ys\n ≡⟨⟩\n ys\n ≡⟨⟩\n reverse [] ++ ys\n ∎\nshunt-reverse (x ∷ xs) ys =\n begin\n shunt (x ∷ xs) ys\n ≡⟨⟩\n shunt xs (x ∷ ys)\n ≡⟨ shunt-reverse xs (x ∷ ys) ⟩\n reverse xs ++ (x ∷ ys)\n ≡⟨⟩\n reverse xs ++ ([ x ] ++ ys)\n ≡⟨ sym (++-assoc (reverse xs) [ x ] ys) ⟩\n (reverse xs ++ [ x ]) ++ ys\n ≡⟨⟩\n reverse (x ∷ xs) ++ ys\n ∎\n\nreverse′ : ∀ {A : Set} → List A → List A\nreverse′ xs = shunt xs []\n\nreverses : ∀ {A : Set} (xs : List A)\n → reverse′ xs ≡ reverse xs\nreverses xs =\n begin\n reverse′ xs\n ≡⟨⟩\n shunt xs []\n ≡⟨ shunt-reverse xs [] ⟩\n reverse xs ++ []\n ≡⟨ ++-identityʳ (reverse xs) ⟩\n reverse xs\n ∎\n\n_ : reverse′ [ 0 , 1 , 2 ] ≡ [ 2 , 1 , 0 ]\n_ =\n begin\n reverse′ (0 ∷ 1 ∷ 2 ∷ [])\n ≡⟨⟩\n shunt (0 ∷ 1 ∷ 2 ∷ []) []\n ≡⟨⟩\n shunt (1 ∷ 2 ∷ []) (0 ∷ [])\n ≡⟨⟩\n shunt (2 ∷ []) (1 ∷ 0 ∷ [])\n ≡⟨⟩\n shunt [] (2 ∷ 1 ∷ 0 ∷ [])\n ≡⟨⟩\n 2 ∷ 1 ∷ 0 ∷ []\n ∎\n\n-- Map\n\nmap : ∀ {A B : Set} → (A → B) → List A → List B\nmap f [] = []\nmap f (x ∷ xs) = f x ∷ map f xs\n\n_ : map suc [ 0 , 1 , 2 ] ≡ [ 1 , 2 , 3 ]\n_ =\n begin\n map suc (0 ∷ 1 ∷ 2 ∷ [])\n ≡⟨⟩\n suc 0 ∷ map suc (1 ∷ 2 ∷ [])\n ≡⟨⟩\n suc 0 ∷ suc 1 ∷ map suc (2 ∷ [])\n ≡⟨⟩\n suc 0 ∷ suc 1 ∷ suc 2 ∷ map suc []\n ≡⟨⟩\n suc 0 ∷ suc 1 ∷ suc 2 ∷ []\n ≡⟨⟩\n 1 ∷ 2 ∷ 3 ∷ []\n ∎\n\nsucs : List ℕ → List ℕ\nsucs = map suc\n\n_ : sucs [ 0 , 1 , 2 ] ≡ [ 1 , 2 , 3 ]\n_ =\n begin\n sucs [ 0 , 1 , 2 ]\n ≡⟨⟩\n map suc [ 0 , 1 , 2 ]\n ≡⟨⟩\n [ 1 , 2 , 3 ]\n ∎\n\n-- 右畳み込み\nfoldr : ∀ {A B : Set} → (A → B → B) → B → List A → B\nfoldr _⊗_ e [] = e\nfoldr _⊗_ e (x ∷ xs) = x ⊗ foldr _⊗_ e xs\n\n_ : foldr _+_ 0 [ 1 , 2 , 3 , 4 ] ≡ 10\n_ =\n begin\n foldr _+_ 0 (1 ∷ 2 ∷ 3 ∷ 4 ∷ [])\n ≡⟨⟩\n 1 + foldr _+_ 0 (2 ∷ 3 ∷ 4 ∷ [])\n ≡⟨⟩\n 1 + (2 + foldr _+_ 0 (3 ∷ 4 ∷ []))\n ≡⟨⟩\n 1 + (2 + (3 + foldr _+_ 0 (4 ∷ [])))\n ≡⟨⟩\n 1 + (2 + (3 + (4 + foldr _+_ 0 [])))\n ≡⟨⟩\n 1 + (2 + (3 + (4 + 0)))\n ∎\n\n-- リストの要素の和\nsum : List ℕ → ℕ\nsum = foldr _+_ 0\n\n_ : sum [ 1 , 2 , 3 , 4 ] ≡ 10\n_ =\n begin\n sum [ 1 , 2 , 3 , 4 ]\n ≡⟨⟩\n foldr _+_ 0 [ 1 , 2 , 3 , 4 ]\n ≡⟨⟩\n 10\n ∎\n\n-- Monoids\n\nrecord IsMonoid {A : Set} (_⊗_ : A → A → A) (e : A) : Set where\n field\n assoc : ∀ (x y z : A) → (x ⊗ y) ⊗ z ≡ x ⊗ (y ⊗ z)\n identityˡ : ∀ (x : A) → e ⊗ x ≡ x\n identityʳ : ∀ (x : A) → x ⊗ e ≡ x\n\nopen IsMonoid\n\n+-monoid : IsMonoid _+_ 0\n+-monoid =\n record\n { assoc = +-assoc\n ; identityˡ = +-identityˡ\n ; identityʳ = +-identityʳ\n }\n\n*-monoid : IsMonoid _*_ 1\n*-monoid =\n record\n { assoc = *-assoc\n ; identityˡ = *-identityˡ\n ; identityʳ = *-identityʳ\n }\n\n++-monoid : ∀ {A : Set} → IsMonoid {List A} _++_ []\n++-monoid =\n record\n { assoc = ++-assoc\n ; identityˡ = ++-identityˡ\n ; identityʳ = ++-identityʳ\n }\n\nfoldr-monoid : ∀ {A : Set} (_⊗_ : A → A → A) (e : A) → IsMonoid _⊗_ e →\n ∀ (xs : List A) (y : A) → foldr _⊗_ y xs ≡ foldr _⊗_ e xs ⊗ y\nfoldr-monoid _⊗_ e ⊗-monoid [] y =\n begin\n foldr _⊗_ y []\n ≡⟨⟩\n y\n ≡⟨ sym (identityˡ ⊗-monoid y) ⟩\n (e ⊗ y)\n ≡⟨⟩\n foldr _⊗_ e [] ⊗ y\n ∎\nfoldr-monoid _⊗_ e ⊗-monoid (x ∷ xs) y =\n begin\n foldr _⊗_ y (x ∷ xs)\n ≡⟨⟩\n x ⊗ (foldr _⊗_ y xs)\n ≡⟨ cong (x ⊗_) (foldr-monoid _⊗_ e ⊗-monoid xs y) ⟩\n x ⊗ (foldr _⊗_ e xs ⊗ y)\n ≡⟨ sym (assoc ⊗-monoid x (foldr _⊗_ e xs) y) ⟩\n (x ⊗ foldr _⊗_ e xs) ⊗ y\n ≡⟨⟩\n foldr _⊗_ e (x ∷ xs) ⊗ y\n ∎\n\npostulate\n foldr-++ : ∀ {A : Set} (_⊗_ : A → A → A) (e : A) (xs ys : List A) →\n foldr _⊗_ e (xs ++ ys) ≡ foldr _⊗_ (foldr _⊗_ e ys) xs\n\nfoldr-monoid-++ : ∀ {A : Set} (_⊗_ : A → A → A) (e : A) → IsMonoid _⊗_ e →\n ∀ (xs ys : List A) → foldr _⊗_ e (xs ++ ys) ≡ foldr _⊗_ e xs ⊗ foldr _⊗_ e ys\nfoldr-monoid-++ _⊗_ e monoid-⊗ xs ys =\n begin\n foldr _⊗_ e (xs ++ ys)\n ≡⟨ foldr-++ _⊗_ e xs ys ⟩\n foldr _⊗_ (foldr _⊗_ e ys) xs\n ≡⟨ foldr-monoid _⊗_ e monoid-⊗ xs (foldr _⊗_ e ys) ⟩\n foldr _⊗_ e xs ⊗ foldr _⊗_ e ys\n ∎\n\n-- All\n\ndata All {A : Set} (P : A → Set) : List A → Set where\n [] : All P []\n _∷_ : ∀ {x : A} {xs : List A} → P x → All P xs → All P (x ∷ xs)\n\n_ : All (_≤ 2) [ 0 , 1 , 2 ]\n_ = z≤n ∷ s≤s z≤n ∷ s≤s (s≤s z≤n) ∷ []\n\n-- Any\n\ndata Any {A : Set} (P : A → Set) : List A → Set where\n here : ∀ {x : A} {xs : List A} → P x → Any P (x ∷ xs)\n there : ∀ {x : A} {xs : List A} → Any P xs → Any P (x ∷ xs)\n\ninfix 4 _∈_ _∉_\n\n_∈_ : ∀ {A : Set} (x : A) (xs : List A) → Set\nx ∈ xs = Any (x ≡_) xs\n\n_∉_ : ∀ {A : Set} (x : A) (xs : List A) → Set\nx ∉ xs = ¬ (x ∈ xs)\n\n_ : 0 ∈ [ 0 , 1 , 0 , 2 ]\n_ = here refl\n\n_ : 0 ∈ [ 0 , 1 , 0 , 2 ]\n_ = there (there (here refl))\n\nnot-in : 3 ∉ [ 0 , 1 , 0 , 2 ]\nnot-in (here ())\nnot-in (there (here ()))\nnot-in (there (there (here ())))\nnot-in (there (there (there (here ()))))\nnot-in (there (there (there (there ()))))\n\n-- All and append\n\nAll-++-⇔ : ∀ {A : Set} {P : A → Set} (xs ys : List A) →\n All P (xs ++ ys) ⇔ (All P xs × All P ys)\nAll-++-⇔ xs ys =\n record\n { to = to xs ys\n ; from = from xs ys\n }\n where\n to : ∀ {A : Set} {P : A → Set} (xs ys : List A) →\n All P (xs ++ ys) → (All P xs × All P ys)\n to [] ys Pys = ⟨ [] , Pys ⟩\n to (x ∷ xs) ys (Px ∷ Pxs++ys) with to xs ys Pxs++ys\n ... | ⟨ Pxs , Pys ⟩ = ⟨ Px ∷ Pxs , Pys ⟩\n\n from : ∀ { A : Set} {P : A → Set} (xs ys : List A) →\n All P xs × All P ys → All P (xs ++ ys)\n from [] ys ⟨ [] , Pys ⟩ = Pys\n from (x ∷ xs) ys ⟨ Px ∷ Pxs , Pys ⟩ = Px ∷ from xs ys ⟨ Pxs , Pys ⟩\n\n-- Decidability of All\n\nall : ∀ {A : Set} → (A → Bool) → List A → Bool\nall p = foldr _∧_ true ∘ map p\n\nDecidable : ∀ {A : Set} → (A → Set) → Set\nDecidable {A} P = ∀ (x : A) → Dec (P x)\n\nAll? : ∀ {A : Set} {P : A → Set} → Decidable P → Decidable (All P)\nAll? P? [] = yes []\nAll? P? (x ∷ xs) with P? x | All? P? xs\n... | yes Px | yes Pxs = yes (Px ∷ Pxs)\n... | no ¬Px | _ = no λ{ (Px ∷ Pxs) → ¬Px Px }\n... | _ | no ¬Pxs = no λ{ (Px ∷ Pxs) → ¬Pxs Pxs }\n", "meta": {"hexsha": "6d578896ea690a0281b42bc8b31ff3bfec5c1174", "size": 10401, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/lists/lists.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/lists/lists.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/lists/lists.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.0546558704, "max_line_length": 79, "alphanum_fraction": 0.4205364869, "num_tokens": 5242, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569014, "lm_q2_score": 0.793105951184112, "lm_q1q2_score": 0.6370019177257946}} {"text": "--\n-- Created by Dependently-Typed Lambda Calculus on 2020-09-23\n-- Commerce\n-- Author: dplaindoux\n--\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Commerce where\n\nopen import Relation.Nullary using (Reflects; Dec; yes; no)\nopen import Data.Bool using (Bool; true; false)\nopen import Data.Nat using (ℕ; _+_; _≥?_; _≥_)\nopen import Agda.Builtin.Nat using (_-_)\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎; step-≡)\n\nmodule Customer where\n record Account : Set where\n field\n balance : ℕ\n\n account : ℕ -> Account\n account n = record { balance = n }\n\n _↑_ : Account → ℕ → Account\n c ↑ n = account (Account.balance c + n)\n\n _↓_ : Account → ℕ → Account\n c ↓ n = account (Account.balance c - n )\n\n infixl 50 _↑_\n infixl 50 _↓_\n\nmodule Product where\n record Item : Set where\n field\n price : ℕ\n\n data Basket : Set where\n ∅ : Basket\n _then_ : Item → Basket → Basket\n\n total : Basket → ℕ\n total ∅ = 0\n total (a then b) = Item.price a + total b\n\nmodule Payment where\n open Customer\n open Product\n\n pay : (c : Account) → (p : Basket) → {Account.balance c ≥ total p} → Account\n pay c p = c ↓ total p\n\n module Front where\n pay? : Account → Basket → Account\n pay? c p with Account.balance c ≥? total p\n ... | yes proof = pay c p {proof}\n ... | no _ = c", "meta": {"hexsha": "41d0d317e6790ad8101fb3da9aebf84f650d0670", "size": 1463, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/exercices/Commerce.agda", "max_stars_repo_name": "d-plaindoux/colca", "max_stars_repo_head_hexsha": "a81447af3ab2ba898bb7d57be71369abbba12d81", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-03-12T18:31:14.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-04T09:35:36.000Z", "max_issues_repo_path": "src/exercices/Commerce.agda", "max_issues_repo_name": "d-plaindoux/colca", "max_issues_repo_head_hexsha": "a81447af3ab2ba898bb7d57be71369abbba12d81", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/exercices/Commerce.agda", "max_forks_repo_name": "d-plaindoux/colca", "max_forks_repo_head_hexsha": "a81447af3ab2ba898bb7d57be71369abbba12d81", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.9836065574, "max_line_length": 80, "alphanum_fraction": 0.5974025974, "num_tokens": 427, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9196425355825847, "lm_q2_score": 0.6926419704455588, "lm_q1q2_score": 0.6369830179514714}} {"text": "-- Andreas, 2012-04-18\nmodule Issue611 where\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\ndata Bool : Set where\n true false : Bool\n\nT : Bool -> Set\nT true = {x : Bool} -> Nat\nT false = {x : Bool} -> Bool\n\ndata D (b : Bool) : Set where\n c : T b -> D b\n\nd : D false\nd = c {_} true\n", "meta": {"hexsha": "10e83154aa11cc8089b50c3dbcd06c356926c33b", "size": 293, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue611.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue611.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue611.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 14.65, "max_line_length": 29, "alphanum_fraction": 0.5699658703, "num_tokens": 108, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8902942319436397, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.6369378514382106}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Bicategory using (Bicategory)\n\n-- A Pseudofunctor is a homomorphism of Bicategories\n-- Follow Bénabou's definition, which is basically that of a Functor\n\n-- Note that what is in nLab is an \"exploded\" version of the simpler version below\nmodule Categories.Pseudofunctor where\n\nopen import Level\nopen import Data.Product using (_,_)\n\nimport Categories.Category as Category\nopen Category.Category using (Obj; module Commutation)\nopen Category using (Category; _[_,_])\nopen import Categories.Functor using (Functor; _∘F_) renaming (id to idF)\nopen import Categories.Category.Product using (_⁂_)\nopen import Categories.NaturalTransformation using (NaturalTransformation)\nopen import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism; _≃_)\nopen import Categories.Category.Instance.One using (shift)\nopen NaturalIsomorphism using (F⇒G; F⇐G)\n\nrecord Pseudofunctor {o ℓ e t o′ ℓ′ e′ t′ : Level} (C : Bicategory o ℓ e t) (D : Bicategory o′ ℓ′ e′ t′)\n : Set (o ⊔ ℓ ⊔ e ⊔ t ⊔ o′ ⊔ ℓ′ ⊔ e′ ⊔ t′) where\n private\n module C = Bicategory C\n module D = Bicategory D\n\n field\n P₀ : C.Obj → D.Obj\n P₁ : {x y : C.Obj} → Functor (C.hom x y) (D.hom (P₀ x) (P₀ y))\n -- For maximal generality, shift the levels of One. P preserves id\n P-identity : {A : C.Obj} → D.id {P₀ A} ∘F shift o′ ℓ′ e′ ≃ P₁ ∘F (C.id {A})\n -- P preserves composition\n P-homomorphism : {x y z : C.Obj} → D.⊚ ∘F (P₁ ⁂ P₁) ≃ P₁ ∘F C.⊚ {x} {y} {z}\n -- P preserves ≃\n\n module unitˡ {A} = NaturalTransformation (F⇒G (P-identity {A}))\n module unitʳ {A} = NaturalTransformation (F⇐G (P-identity {A}))\n module Hom {x} {y} {z} = NaturalTransformation (F⇒G (P-homomorphism {x} {y} {z}))\n\n -- For notational convenience, shorten some functor applications\n private\n F₀ = λ {x y} X → Functor.F₀ (P₁ {x} {y}) X\n\n field\n unitaryˡ : {x y : C.Obj} →\n let open Commutation (D.hom (P₀ x) (P₀ y)) in\n {f : Obj (C.hom x y)} →\n [ D.id₁ D.⊚₀ (F₀ f) ⇒ F₀ f ]⟨\n unitˡ.η _ D.⊚₁ D.id₂ ⇒⟨ F₀ C.id₁ D.⊚₀ F₀ f ⟩\n Hom.η ( C.id₁ , f) ⇒⟨ F₀ (C.id₁ C.⊚₀ f) ⟩\n Functor.F₁ P₁ C.unitorˡ.from\n ≈ D.unitorˡ.from\n ⟩\n unitaryʳ : {x y : C.Obj} →\n let open Commutation (D.hom (P₀ x) (P₀ y)) in\n {f : Obj (C.hom x y)} →\n [ (F₀ f) D.⊚₀ D.id₁ ⇒ F₀ f ]⟨\n D.id₂ D.⊚₁ unitˡ.η _ ⇒⟨ F₀ f D.⊚₀ F₀ C.id₁ ⟩\n Hom.η ( f , C.id₁ ) ⇒⟨ F₀ (f C.⊚₀ C.id₁) ⟩\n Functor.F₁ P₁ (C.unitorʳ.from)\n ≈ D.unitorʳ.from\n ⟩\n\n assoc : {x y z w : C.Obj} →\n let open Commutation (D.hom (P₀ x) (P₀ w)) in\n {f : Obj (C.hom x y)} {g : Obj (C.hom y z)} {h : Obj (C.hom z w)} →\n [ (F₀ h D.⊚₀ F₀ g) D.⊚₀ F₀ f ⇒ F₀ (h C.⊚₀ (g C.⊚₀ f)) ]⟨\n Hom.η (h , g) D.⊚₁ D.id₂ ⇒⟨ F₀ (h C.⊚₀ g) D.⊚₀ F₀ f ⟩\n Hom.η (_ , f) ⇒⟨ F₀ ((h C.⊚₀ g) C.⊚₀ f) ⟩\n Functor.F₁ P₁ C.associator.from\n ≈ D.associator.from ⇒⟨ F₀ h D.⊚₀ (F₀ g D.⊚₀ F₀ f) ⟩\n D.id₂ D.⊚₁ Hom.η (g , f) ⇒⟨ F₀ h D.⊚₀ F₀ (g C.⊚₀ f) ⟩\n Hom.η (h , _)\n ⟩\n", "meta": {"hexsha": "69b7e3e08a571be3889966c84b089a65ce9ea403", "size": 3360, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Pseudofunctor.agda", "max_stars_repo_name": "Taneb/agda-categories", "max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Categories/Pseudofunctor.agda", "max_issues_repo_name": "Taneb/agda-categories", "max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Categories/Pseudofunctor.agda", "max_forks_repo_name": "Taneb/agda-categories", "max_forks_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.0769230769, "max_line_length": 105, "alphanum_fraction": 0.53125, "num_tokens": 1274, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8902942232112239, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.6369378451908309}} {"text": "module PiNF-semantics where\n\nopen import Data.Nat hiding (_⊔_; suc; _+_; _*_)\nopen import Data.Vec \nopen import Level\nopen import Algebra.Structures\n\nopen import PiNF-algebra\n\n------------------------------------------------------------------------------\n-- Define module over a ring (the types bot, top, disjoint union, and product\n-- do form a ring as shown in the type-iso library) \n\nR-module : ℕ → Set → Set\nR-module dim c = Vec c dim \n\n-- The only element of (R-module 0) is the zero vector\n\nzeroV : ∀ {A : Set} → R-module 0 A\nzeroV = []\n\n-- (R-module 1 A) is isomorphic to A\n\nv-R1 : ∀ {A : Set} → A → R-module 1 A\nv-R1 a = [ a ]\n\nR1-v : ∀ {A : Set} → R-module 1 A → A\nR1-v (a ∷ []) = a\n\n-- \n\nmodule MR (C : CommutativeSemiringWithoutAnnihilatingZero Level.zero Level.zero) where\n\n open Data.Nat using (ℕ; zero; suc; _+_; _*_)\n open Data.Vec using ([]; _∷_; map; _++_)\n open CommutativeSemiringWithoutAnnihilatingZero \n using (Carrier; _≈_; 0#; 1#)\n renaming (_+_ to _+r_; _*_ to _*r_)\n\n{--\n zeroV : ∀ {b : Set} → R-module b 0\n zeroV = []\n\n tensorV : {b₁ b₂ : Set } {m₁ m₂ : ℕ} → \n R-module b₁ m₁ → R-module b₂ m₂ → \n R-module (b₁ × b₂) (m₁ * m₂)\n tensorV [] _ = []\n tensorV (x ∷ xs) ys = (map (λ y → (x , y)) ys) ++ (tensorV xs ys)\n\n addV : {n : ℕ} → R-module (Carrier C) n → R-module (Carrier C) n\n → R-module (Carrier C) n\n addV x y = Data.Vec.zipWith (_+r_ C) x y\n\n--}\n\nopen MR\n\n------------------------------------------------------------------------------\n", "meta": {"hexsha": "6c7eb0033234232f96f8daa8f7b23d4648bbb4a6", "size": 1521, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/PiNF-semantics.agda", "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_issues_repo_path": "agda/PiNF-semantics.agda", "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_forks_repo_path": "agda/PiNF-semantics.agda", "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "avg_line_length": 25.7796610169, "max_line_length": 86, "alphanum_fraction": 0.5305719921, "num_tokens": 498, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8824278633625322, "lm_q2_score": 0.7217432182679956, "lm_q1q2_score": 0.6368863259926251}} {"text": "\n--------------------------------------------------------------------------------\n-- Author : Bradley Hardy\n--------------------------------------------------------------------------------\n-- The first exercise from the ACS Algebraic Path Problems course, taught by\n-- Timothy Griffin\n--\n-- Final proofs of 'fun fun facts' are at the bottom of the file; the rest\n-- consists of definitions and supplementary proofs.\n--------------------------------------------------------------------------------\n\nmodule MLib.Lattices {ℓ} {S : Set ℓ} where\n\nopen import Matrix.Prelude\n\nopen import Function using (flip)\n\nopen Algebra.FunctionProperties (_≡_ {A = S}) using (Associative; Idempotent; Commutative)\n\nmodule OperatorProperties (_∙_ : S → S → S) where\n _≤L_ = λ a b → a ≡ a ∙ b\n _≤R_ = λ a b → b ≡ a ∙ b\n\n-- open OperatorProperties using (Associative; Idempotent; Commutative)\n\n--------------------------------------------------------------------------------\n-- Semigroups\n--------------------------------------------------------------------------------\n\nrecord IsCISemigroup (_∙_ : S → S → S) : Set ℓ where\n field\n isAssociative : Associative _∙_\n isIdempotent : Idempotent _∙_\n isCommutative : Commutative _∙_\n\n open OperatorProperties _∙_ public\n\n ≤L→flip≤R : ∀ {x y} → x ≤L y → y ≤R x\n ≤L→flip≤R p = ≡.trans p (isCommutative _ _)\n\n ≤R→flip≤L : ∀ {x y} → x ≤R y → y ≤L x\n ≤R→flip≤L p = ≡.trans p (isCommutative _ _)\n\n ≤L-isPartialOrder : IsPartialOrder _≡_ _≤L_\n ≤L-isPartialOrder =\n record\n { isPreorder =\n record\n { isEquivalence = ≡.isEquivalence\n ; reflexive = λ {i j} p →\n begin\n i ≡⟨ ≡.sym (isIdempotent _) ⟩\n i ∙ i ≡⟨ ≡.cong₂ _∙_ ≡.refl p ⟩\n i ∙ j ∎\n ; trans = λ {i j k} p q →\n begin\n i ≡⟨ p ⟩\n i ∙ j ≡⟨ ≡.cong₂ _∙_ ≡.refl q ⟩\n i ∙ (j ∙ k) ≡⟨ ≡.sym (isAssociative _ _ _) ⟩\n (i ∙ j) ∙ k ≡⟨ ≡.cong₂ _∙_ (≡.sym p) ≡.refl ⟩\n i ∙ k ∎\n }\n ; antisym = λ {x y} p q →\n begin\n x ≡⟨ p ⟩\n x ∙ y ≡⟨ isCommutative _ _ ⟩\n y ∙ x ≡⟨ ≡.sym q ⟩\n y ∎\n }\n where open ≡.≡-Reasoning\n\n -- Prove this by deferring to ≤L-isPartialOrder and taking advantage of the\n -- fact that _≤L_ and _≤R_ are dual.\n ≤R-isPartialOrder : IsPartialOrder _≡_ _≤R_\n ≤R-isPartialOrder =\n record\n { isPreorder =\n record\n { isEquivalence = ≡.isEquivalence\n ; reflexive = λ p → fromL (≤L.reflexive (≡.sym p))\n ; trans = λ {i j k} p q → fromL (≤L.trans (toL q) (toL p))\n }\n ; antisym = λ {x y} p q → ≤L.antisym (toL q) (toL p)\n }\n where module ≤L = IsPartialOrder ≤L-isPartialOrder\n fromL = ≤L→flip≤R\n toL = ≤R→flip≤L\n\n--------------------------------------------------------------------------------\n-- (Greatest) lower and (least) upper bounds\n--------------------------------------------------------------------------------\n\nrecord IsLowerBound (_≤_ : S → S → Set ℓ) (c a b : S) : Set ℓ where\n field\n ≤L : c ≤ a\n ≤R : c ≤ b\n\nrecord IsGlb (_≤_ : S → S → Set ℓ) (c a b : S) : Set ℓ where\n field\n isLowerBound : IsLowerBound _≤_ c a b\n isGreatest : ∀ {d} → d ≤ a → d ≤ b → d ≤ c\n\n open IsLowerBound isLowerBound public\n\nrecord IsUpperBound (_≤_ : S → S → Set ℓ) (c a b : S) : Set ℓ where\n field\n L≤ : a ≤ c\n R≤ : b ≤ c\n\nrecord IsLub (_≤_ : S → S → Set ℓ) (c a b : S) : Set ℓ where\n field\n isUpperBound : IsUpperBound _≤_ c a b\n isLeast : ∀ {d} → a ≤ d → b ≤ d → c ≤ d\n\n open IsUpperBound isUpperBound public\n\n -- A least upper bound is a greatest lower bound with respect to the reversed\n -- order.\n flipGlb : IsGlb (flip _≤_) c a b\n flipGlb = record\n { isLowerBound = record { ≤L = L≤ ; ≤R = R≤ }\n ; isGreatest = isLeast\n }\n\nmodule IsGlbProperties {≤ c a b} (isGlb : IsGlb ≤ c a b) where\n open IsGlb isGlb public\n\n sym : IsGlb ≤ c b a\n sym = record\n { isLowerBound = record { ≤L = ≤R ; ≤R = ≤L }\n ; isGreatest = λ x y → isGreatest y x\n }\n\n -- A greatest lower bound is a least upper bound with respect to the reversed\n -- order.\n flipLub : IsLub (flip ≤) c a b\n flipLub = record\n { isUpperBound = record { L≤ = ≤L ; R≤ = ≤R }\n ; isLeast = isGreatest\n }\n\nmodule PartialOrderProperties (_≤_ : S → S → Set ℓ)\n (isPartialOrder : IsPartialOrder _≡_ _≤_)\n where\n module ≤ = IsPartialOrder isPartialOrder\n\n IsGlb-self : ∀ {a} → IsGlb _≤_ a a a\n IsGlb-self = record\n { isLowerBound = record { ≤L = ≤.refl ; ≤R = ≤.refl }\n ; isGreatest = λ x y → x\n }\n\n -- In a partial order, there is at most one greatest lower bound for any given\n -- pair of values.\n IsGlb-unique : ∀ {a b c} → IsGlb _≤_ c a b → ∀ {d} → IsGlb _≤_ d a b → c ≡ d\n IsGlb-unique p q =\n ≤.antisym\n (IsGlb.isGreatest q (IsGlb.≤L p) (IsGlb.≤R p))\n (IsGlb.isGreatest p (IsGlb.≤L q) (IsGlb.≤R q))\n\n flipIsPartialOrder : IsPartialOrder _≡_ (flip _≤_)\n flipIsPartialOrder = record\n { isPreorder = record\n { isEquivalence = ≡.isEquivalence\n ; reflexive = λ p → ≤.reflexive (≡.sym p)\n ; trans = flip ≤.trans\n }\n ; antisym = flip ≤.antisym\n }\n\n--------------------------------------------------------------------------------\n-- Semilattices\n--------------------------------------------------------------------------------\n\nrecord IsMeetSemilattice (_≤_ : S → S → Set ℓ) (_⊓_ : S → S → S) : Set ℓ where\n field\n isPartialOrder : IsPartialOrder _≡_ _≤_\n isGlb : ∀ {a b} → IsGlb _≤_ (a ⊓ b) a b\n\n open PartialOrderProperties _≤_ isPartialOrder public\n module This {a b} = IsGlbProperties (isGlb {a} {b})\n open This public\n\n -- In a meet semilattice, the only greatest lower bound of any pair 'a' and\n -- 'b' is 'a ⊓ b'.\n glb-intro : ∀ {c a b} → IsGlb _≤_ c a b → c ≡ a ⊓ b\n glb-intro p = IsGlb-unique p isGlb\n\n module CISemigroup where\n isCommutative : Commutative _⊓_\n isCommutative _ _ = glb-intro (IsGlbProperties.sym isGlb)\n\n isIdempotent : Idempotent _⊓_\n isIdempotent _ = ≡.sym (glb-intro IsGlb-self)\n\n isAssociative : Associative _⊓_\n isAssociative a b c =\n let d = (a ⊓ b) ⊓ c\n\n d≤a : d ≤ a\n d≤a = ≤.trans ≤L ≤L\n\n d≤b : d ≤ b\n d≤b = ≤.trans ≤L ≤R\n\n d≤c : d ≤ c\n d≤c = ≤R\n\n d≤b⊓c : d ≤ (b ⊓ c)\n d≤b⊓c = isGreatest d≤b d≤c\n\n d-greatest : ∀ {d′} → d′ ≤ a → d′ ≤ b → d′ ≤ c → d′ ≤ d\n d-greatest p q r = isGreatest (isGreatest p q) r\n in glb-intro (\n record\n { isLowerBound = record { ≤L = ≤.trans ≤L ≤L ; ≤R = d≤b⊓c}\n ; isGreatest = λ p q → d-greatest p (≤.trans q ≤L) (≤.trans q ≤R)\n })\n\n -- A meet semilattic is also a commutative idempotent semigroup\n isCISemigroup : IsCISemigroup _⊓_\n isCISemigroup = record { CISemigroup }\n\nrecord IsJoinSemilattice (≤ : S → S → Set ℓ) (_⊔_ : S → S → S) : Set ℓ where\n field\n isPartialOrder : IsPartialOrder _≡_ ≤\n isLub : ∀ {a b} → IsLub ≤ (a ⊔ b) a b\n\n open PartialOrderProperties ≤ isPartialOrder public\n module This {a b} = IsLub (isLub {a} {b})\n open This\n\n -- A join semilattice is a meet semilattice with respect to the reversed order\n flipIsMeetSemilattice : IsMeetSemilattice (flip ≤) _⊔_\n flipIsMeetSemilattice = record\n { isPartialOrder = flipIsPartialOrder\n ; isGlb = flipGlb\n }\n\n -- A join semilattice is also a commutative idempotent semigroup\n open IsMeetSemilattice flipIsMeetSemilattice using (isCISemigroup) public\n\nmodule MeetSemilatticeProperties {≤ ⊓}\n (isMeetSemilattice : IsMeetSemilattice ≤ ⊓)\n where\n\n open IsMeetSemilattice isMeetSemilattice\n\n -- A meet semilattice is a join semilattice with respect to the reversed order\n flipIsJoinSemilattice : IsJoinSemilattice (flip ≤) ⊓\n flipIsJoinSemilattice = record\n { isPartialOrder = flipIsPartialOrder\n ; isLub = flipLub\n }\n\n--------------------------------------------------------------------------------\n-- Proofs of fun fun facts\n--------------------------------------------------------------------------------\n\n-- Commutative idempotent semigroups create meet and join semilattices from\n-- their left and right natural orders respectively.\nmodule FunFunFact1 {_∙_ : S → S → S} (isCISemigroup : IsCISemigroup _∙_) where\n open IsCISemigroup isCISemigroup\n\n funFunFact1Meet : IsMeetSemilattice _≤L_ _∙_\n funFunFact1Meet =\n record\n { isPartialOrder = ≤L-isPartialOrder\n ; isGlb = λ {a b} → record\n { isLowerBound = record\n { ≤L =\n begin\n a ∙ b ≡⟨ ≡.cong₂ _∙_ (≡.sym (isIdempotent _)) ≡.refl ⟩\n (a ∙ a) ∙ b ≡⟨ isAssociative _ _ _ ⟩\n a ∙ (a ∙ b) ≡⟨ isCommutative _ _ ⟩\n (a ∙ b) ∙ a ∎\n ; ≤R =\n begin\n a ∙ b ≡⟨ ≡.cong₂ _∙_ ≡.refl (≡.sym (isIdempotent _)) ⟩\n a ∙ (b ∙ b) ≡⟨ ≡.sym (isAssociative _ _ _) ⟩\n (a ∙ b) ∙ b ∎\n }\n ; isGreatest = λ {d} p q →\n begin\n d ≡⟨ ≡.sym (isIdempotent _) ⟩\n d ∙ d ≡⟨ ≡.cong₂ _∙_ p q ⟩\n (d ∙ a) ∙ (d ∙ b) ≡⟨ isAssociative _ _ _ ⟩\n d ∙ (a ∙ (d ∙ b)) ≡⟨ ≡.cong₂ _∙_ ≡.refl (≡.sym (isAssociative _ _ _)) ⟩\n d ∙ ((a ∙ d) ∙ b) ≡⟨ ≡.cong₂ _∙_ ≡.refl\n (≡.cong₂ _∙_ (isCommutative _ _) ≡.refl) ⟩\n d ∙ ((d ∙ a) ∙ b) ≡⟨ ≡.cong₂ _∙_ ≡.refl (isAssociative _ _ _) ⟩\n d ∙ (d ∙ (a ∙ b)) ≡⟨ ≡.sym (isAssociative _ _ _) ⟩\n (d ∙ d) ∙ (a ∙ b) ≡⟨ ≡.cong₂ _∙_ (isIdempotent _) ≡.refl ⟩\n d ∙ (a ∙ b) ∎\n }\n }\n where open ≡.≡-Reasoning\n\n -- Prove for join by symmetry with meet\n funFunFact1Join : IsJoinSemilattice _≤R_ _∙_\n funFunFact1Join =\n record\n { isPartialOrder = ≤R-isPartialOrder\n ; isLub = λ {a b} → record\n { isUpperBound = record\n { L≤ = fromL Meet.≤L\n ; R≤ = fromL Meet.≤R\n }\n ; isLeast =\n λ {d} p q →\n fromL (Meet.isGreatest (toL p) (toL q))\n }\n }\n where\n open ≡.≡-Reasoning\n module Meet = IsMeetSemilattice funFunFact1Meet\n toL = ≤R→flip≤L\n fromL = ≤L→flip≤R\n\n-- Semilattices are commutative idempotent semigroups\nmodule FunFunFact2 {≤ : S → S → Set ℓ} where\n funFunFact2Meet : ∀ {⊓} → IsMeetSemilattice ≤ ⊓ → IsCISemigroup ⊓\n funFunFact2Meet ijs = isCISemigroup\n where open IsMeetSemilattice ijs\n\n -- Note this is using 'isCISemigroup' from the flipped /meet/ semilattice.\n funFunFact2Join : ∀ {⊔} → IsJoinSemilattice ≤ ⊔ → IsCISemigroup ⊔\n funFunFact2Join ijs = isCISemigroup\n where open IsJoinSemilattice ijs\n", "meta": {"hexsha": "4985295ad157a9df38c7a28ca33b0d18d8da9e9b", "size": 10746, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/MLib/Lattices.agda", "max_stars_repo_name": "bch29/agda-matrices", "max_stars_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/MLib/Lattices.agda", "max_issues_repo_name": "bch29/agda-matrices", "max_issues_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/MLib/Lattices.agda", "max_forks_repo_name": "bch29/agda-matrices", "max_forks_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.5636363636, "max_line_length": 90, "alphanum_fraction": 0.513400335, "num_tokens": 3843, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.822189134878876, "lm_q2_score": 0.7745833945721304, "lm_q1q2_score": 0.636854051074803}} {"text": "open import MLib.Algebra.PropertyCode\nopen import MLib.Algebra.PropertyCode.Structures\n\nmodule MLib.Matrix.SemiTensor.Associativity {c ℓ} (struct : Struct bimonoidCode c ℓ) where\n\nopen import MLib.Prelude\nopen import MLib.Matrix.Core\nopen import MLib.Matrix.Equality struct\nopen import MLib.Matrix.Mul struct\nopen import MLib.Matrix.Tensor struct\nopen import MLib.Matrix.SemiTensor.Core struct\nopen import MLib.Algebra.Operations struct\n\nopen Nat using () renaming (_+_ to _+ℕ_; _*_ to _*ℕ_)\n\nopen import MLib.Fin.Parts.Simple\n\nopen import Data.Nat.LCM\nopen import Data.Nat.Divisibility\n\nmodule _ ⦃ props : Has (1# is rightIdentity for * ∷ associative on * ∷ []) ⦄ where\n open _≃_\n\n {-\n m *ℕ (lcm n (p * (lcm q r) / q))/n ≡ m *ℕ (lcm n p)/n *ℕ (lcm (q *ℕ (lcm n p)/p) r) / r\n\n m * lcm(n, p * lcm(q, r) / q) / n =\n m * (lcm(n, p) / n) * lcm (q * lcm(n, p) / p, r) / r\n\n lcm(n, p * lcm(q, r) / q) = lcm (q * lcm(n, p) / p, r) * p / q\n\n f(a, b) = lcm(a, b) / a\n\n lcm(n, p * f(q, r)) = lcm(r, q * f(p, n)) * p / q\n -}\n\n module _ {m n p q r s} (A : Matrix S m n) (B : Matrix S p q) (C : Matrix S r s) where\n t₁ = lcm n p .proj₁\n lcm-n-p=t₁ = lcm n p .proj₂\n\n open Defn lcm-n-p=t₁ using () renaming (t/n to t₁/n; t/p to t₁/p)\n\n t₂ = lcm q r .proj₁\n lcm-q-r=t₂ = lcm q r .proj₂\n\n open Defn lcm-q-r=t₂ using () renaming (t/n to t₂/q; t/p to t₂/r)\n\n t₃ = lcm n (p *ℕ t₂/q) .proj₁\n lcm-n-pt₂/q=t₃ = lcm n (p *ℕ t₂/q) .proj₂\n\n open Defn lcm-n-pt₂/q=t₃ using () renaming (t/n to t₃/n; t/p to t₃/[p*t₂/q])\n\n t₄ = lcm (q *ℕ t₁/p) r .proj₁\n lcm-qt₁/p-r=t₄ = lcm (q *ℕ t₁/p) r .proj₂\n\n open Defn lcm-qt₁/p-r=t₄ using () renaming (t/n to t₄/[q*t₁/p]; t/p to t₄/r)\n -- module D₁ = Defn {n} {p} {q}\n -- module D₂ = Defn {q} {r} {s}\n\n ⋉-associative : A ⋉ (B ⋉ C) ≃ (A ⋉ B) ⋉ C\n ⋉-associative .m≡p = {!!}\n ⋉-associative .n≡q = {!!}\n ⋉-associative .equal = {!!}\n", "meta": {"hexsha": "76f110ef3d8cd665e9d090f57e185fe08a684f9e", "size": 1906, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/MLib/Matrix/SemiTensor/Associativity.agda", "max_stars_repo_name": "bch29/agda-matrices", "max_stars_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/MLib/Matrix/SemiTensor/Associativity.agda", "max_issues_repo_name": "bch29/agda-matrices", "max_issues_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/MLib/Matrix/SemiTensor/Associativity.agda", "max_forks_repo_name": "bch29/agda-matrices", "max_forks_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.78125, "max_line_length": 90, "alphanum_fraction": 0.5813221406, "num_tokens": 801, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009619539554, "lm_q2_score": 0.6959583376458152, "lm_q1q2_score": 0.636732952592032}} {"text": "------------------------------------------------------------------------\n-- Propositional equality\n------------------------------------------------------------------------\n\n-- This file contains some core definitions which are reexported by\n-- Relation.Binary.PropositionalEquality.\n\nmodule Relation.Binary.PropositionalEquality.Core where\n\nopen import Relation.Binary.Core\nopen import Relation.Binary.Consequences.Core\n\n------------------------------------------------------------------------\n-- Some properties\n\nsym : {a : Set} → Symmetric {a} _≡_\nsym refl = refl\n\ntrans : {a : Set} → Transitive {a} _≡_\ntrans refl refl = refl\n\nsubst : {a : Set} → Substitutive {a} _≡_\nsubst P refl p = p\n\nresp₂ : ∀ {a} (∼ : Rel a) → ∼ Respects₂ _≡_\nresp₂ _∼_ = subst⟶resp₂ _∼_ subst\n\nisEquivalence : ∀ {a} → IsEquivalence {a} _≡_\nisEquivalence = record\n { refl = refl\n ; sym = sym\n ; trans = trans\n }\n", "meta": {"hexsha": "5eb95bb3649b43d14347820312a4da12512abfad", "size": 894, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Relation/Binary/PropositionalEquality/Core.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Relation/Binary/PropositionalEquality/Core.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Relation/Binary/PropositionalEquality/Core.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 26.2941176471, "max_line_length": 72, "alphanum_fraction": 0.5212527964, "num_tokens": 219, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9149009457116781, "lm_q2_score": 0.6959583376458153, "lm_q1q2_score": 0.6367329412880838}} {"text": "{-# OPTIONS --sized-types #-}\n\nmodule FormalLanguage {ℓ} where\n\nimport Lvl\nopen import Sized.Data.List renaming (∅ to [])\nopen import Lang.Size\nopen import Data.Boolean\nopen import Data.Boolean.Operators\nopen Data.Boolean.Operators.Programming\nopen import Data.Boolean.Stmt\nopen import Functional\nopen import Relator.Equals\nopen import Type\n\n-- Definitions:\n-- A language is a set of words.\n-- A word in a language is a list of valid symbols in the language.\n-- A valid symbol in the language is an element in the alphabet of the language.\n-- An alphabet of a language is a set.\n-- A string is a word.\n-- Standard conventions for variable naming in languages:\n-- L is a language\n-- Σ is an alphabet\n\nAlphabet = Type{ℓ}\nWord = List\n\n-- Language is defined as a trie: (LHS is using the definition of Language, RHS is using the usual \"semantics\" of languages as sets):\n-- For a language L\n-- accepts-ε:\n-- (accepts-ε(L) = 𝑇) ↔ (ε ∈ L)\n-- accepts-ε(L) returns a boolean determining whether the empty word is accepted in the language.\n-- suffix-lang:\n-- ∀word∀c. (word ∈ suffix-lang(L)(c)) ↔ ((c 𝁼 word) ∈ L)\n-- suffix-lang(L)(c) is the language that consists of the rest of the words when a word is starting with c in L.\n-- Copied (with modifications) from: http://agda.readthedocs.io/en/v2.5.2/language/sized-types.html (2017-05-13)\n-- which links the following paper: \"Formal Languages, Formally and Coinductively, Dmitriy Traytel, FSCD (2016)\" [https://www21.in.tum.de/~traytel/papers/fscd16-coind_lang/paper.pdf]\n-- Example:\n-- A language 𝔏 consists of 6 words:\n-- 𝔏 = {\"\" , \"aa\" , \"aaa\" , \"aab\" , \"aba\" , \"aaab\"}\n-- accepts-ε (𝔏) = 𝑇\n-- suffix-lang(𝔏)(a) = {\"a\" , \"aa\" , \"ab\" , \"ba\" , \"aab\"}\n-- accepts-ε (suffix-lang(𝔏)(a)) = 𝐹\n-- suffix-lang(suffix-lang(𝔏)(a))(a) = {\"\" , \"a\" , \"b\" , \"ab\"}\n-- suffix-lang(suffix-lang(𝔏)(a))(b) = {\"a\"}\nrecord Language (Σ : Alphabet) {s : Size} : Type{ℓ} where\n constructor intro\n coinductive\n field\n accepts-ε : Bool\n suffix-lang : ∀{sₛ : <ˢⁱᶻᵉ s} → Σ → Language(Σ){sₛ}\n\nmodule Oper {Σ} where\n infixl 1003 _∪_\n infixl 1002 _∩_\n infixl 1001 _𝁼_\n infixl 1000 _*\n\n -- The empty language.\n -- The language that does not include any word at all.\n ∅ : ∀{s} → Language(Σ){s}\n Language.accepts-ε ∅ = 𝐹\n Language.suffix-lang ∅ _ = ∅\n\n -- The empty word language.\n -- The language with only the empty word.\n ε : ∀{s} → Language(Σ){s}\n Language.accepts-ε ε = 𝑇\n Language.suffix-lang ε _ = ∅\n\n -- The language of length 1 words that only accepts some symbols of its alphabet\n alphabet-filter : ∀{s} → (Σ → Bool) → Language(Σ){s}\n Language.accepts-ε (alphabet-filter f) = 𝐹\n Language.suffix-lang (alphabet-filter f) c = if f(c) then ε else ∅\n\n -- The single symbol language.\n -- The language consisting of a single word with a single letter\n -- Note: This is only possible when Alphabet has a computably decidable equality relation\n single : ⦃ _ : ComputablyDecidable(_≡_) ⦄ → ∀{s} → Σ → Language(Σ){s}\n single(a) = alphabet-filter(ComputablyDecidable.decide(_≡_) a)\n\n -- The sublanguage filtered by a decidable predicate.\n filter : ∀{s} → (Word(Σ) → Bool) → Language(Σ){s} → Language(Σ){s}\n Language.accepts-ε (filter P(𝔏)) = P(List.∅)\n Language.suffix-lang (filter P(𝔏)) c = filter (P ∘ tail) (Language.suffix-lang(𝔏)(c))\n\n -- The language where every letter in the alphabet is applied to a function.\n unmap : ∀{Σ₂}{s} → (Σ → Σ₂) → Language(Σ₂){s} → Language(Σ){s}\n Language.accepts-ε (unmap f(𝔏)) = Language.accepts-ε (𝔏)\n Language.suffix-lang (unmap f(𝔏)) c = unmap f(Language.suffix-lang(𝔏)(f(c)))\n\n -- Union.\n -- The language that includes any words that the two languages have.\n _∪_ : ∀{s} → Language(Σ){s} → Language(Σ){s} → Language(Σ){s}\n Language.accepts-ε (L₁ ∪ L₂) = Language.accepts-ε(L₁) || Language.accepts-ε(L₂)\n Language.suffix-lang (L₁ ∪ L₂) c = Language.suffix-lang(L₁)(c) ∪ Language.suffix-lang(L₂)(c)\n\n -- Intersection.\n -- The language that only includes the words that both languages have in common.\n _∩_ : ∀{s} → Language(Σ){s} → Language(Σ){s} → Language(Σ){s}\n Language.accepts-ε (L₁ ∩ L₂) = Language.accepts-ε(L₁) && Language.accepts-ε(L₂)\n Language.suffix-lang (L₁ ∩ L₂) c = Language.suffix-lang(L₁)(c) ∩ Language.suffix-lang(L₂)(c)\n\n -- Concatenation.\n -- The language that includes words that start with a word the first language and end in a word from the second language.\n _𝁼_ : ∀{s} → Language(Σ){s} → Language(Σ){s} → Language(Σ){s}\n Language.accepts-ε (L₁ 𝁼 L₂) = Language.accepts-ε(L₁) && Language.accepts-ε(L₂)\n Language.suffix-lang (L₁ 𝁼 L₂) c =\n if Language.accepts-ε(L₁)\n then (Language.suffix-lang(L₁)(c) 𝁼 L₂) ∪ Language.suffix-lang(L₂)(c)\n else (Language.suffix-lang(L₁)(c) 𝁼 L₂)\n\n -- Star/Closure\n -- The language that includes words in any number of concatenations with itself.\n _* : ∀{s} → Language(Σ){s} → Language(Σ){s}\n Language.accepts-ε (L *) = 𝑇\n Language.suffix-lang (L *) c = Language.suffix-lang(L)(c) 𝁼 (L *)\n\n -- Complement\n -- The language that includes all words that a language does not have.\n ∁_ : ∀{s} → Language(Σ){s} → Language(Σ){s}\n Language.accepts-ε (∁ L) = !(Language.accepts-ε(L))\n Language.suffix-lang (∁ L) c = ∁(Language.suffix-lang(L)(c))\n\n -- The universal language.\n -- The language that includes all words in any combination of the alphabet.\n -- The largest language (with most words) with a certain alphabet.\n 𝐔 : ∀{s} → Language(Σ){s}\n 𝐔 = ∁(∅)\n\n -- Containment check\n -- Checks whether a word is in the language.\n _∈?_ : ∀{s} → Word{s = s}(Σ) → Language(Σ) → Bool\n _∈?_ [] L = Language.accepts-ε(L)\n _∈?_ (_⊰_ {sₗ} c w) L = _∈?_ {s = sₗ} w (Language.suffix-lang L c)\n\n -- Containment\n -- The relation of whether a word is in the language or not.\n _∈_ : ∀{s} → Word{s = s}(Σ) → Language(Σ) → Type\n _∈_ {s} a b = IsTrue(_∈?_ {s} a b)\n\n [_]_∈_ : ∀(s) → Word{s = s}(Σ) → Language(Σ) → Type\n [ s ] a ∈ b = _∈_ {s} a b\n\n -- Uncontainment\n -- The relation of whether a word is not in the language or not.\n _∉_ : ∀{s} → Word{s = s}(Σ) → Language(Σ) → Type\n _∉_ {s} a b = IsFalse(_∈?_ {s} a b)\n\n [_]_∉_ : ∀(s) → Word{s = s}(Σ) → Language(Σ) → Type\n [ s ] a ∉ b = _∉_ {s} a b\n", "meta": {"hexsha": "522f57d683e26504dd7634e3b80887110d4df7da", "size": 6294, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "FormalLanguage.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "FormalLanguage.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "FormalLanguage.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.137254902, "max_line_length": 182, "alphanum_fraction": 0.636638068, "num_tokens": 2228, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711718571775, "lm_q2_score": 0.7490872075132153, "lm_q1q2_score": 0.6367025315932283}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Algebra.Monoid.Submonoid where\n\nopen import Cubical.Core.Everything\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Data.Sigma\n\nopen import Cubical.Algebra\nopen import Cubical.Algebra.Monoid.Morphism\nopen import Cubical.Algebra.Semigroup.Subsemigroup\n\nopen import Cubical.Relation.Unary\nopen import Cubical.Relation.Unary.Subtype\n\nopen import Cubical.HITs.PropositionalTruncation\n\n\nrecord IsSubmonoid {c ℓ} (M : Monoid c) (Member : Pred ⟨ M ⟩ ℓ) : Type (ℓ-max c ℓ) where\n constructor issubmonoid\n\n private module M = Monoid M\n\n field\n preservesOp : M._•_ Preserves₂ Member\n preservesId : M.ε ∈ Member\n\n isSubsemigroup : IsSubsemigroup M.semigroup Member\n isSubsemigroup = record { closed = preservesOp }\n\n open IsSubsemigroup isSubsemigroup hiding (closed; _^_) public\n\n\n ε : Carrier\n ε = M.ε , preservesId\n\n identityˡ : LeftIdentity ε _•_\n identityˡ _ = ΣPathTransport→PathΣ _ _ (M.identityˡ _ , isProp[ Member ] _ _ _)\n\n identityʳ : RightIdentity ε _•_\n identityʳ _ = ΣPathTransport→PathΣ _ _ (M.identityʳ _ , isProp[ Member ] _ _ _)\n\n identity : Identity ε _•_\n identity = identityˡ , identityʳ\n\n\n isMonoid : IsMonoid Carrier _•_ ε\n isMonoid = record\n { isSemigroup = isSemigroup\n ; identity = identity\n }\n\n monoid : Monoid _\n monoid = record { isMonoid = isMonoid }\n\n open Monoid monoid using (ε-uniqueˡ; ε-uniqueʳ; _^_) public\n\n\n\n\nrecord Submonoid {c} (M : Monoid c) ℓ : Type (ℓ-max c (ℓ-suc ℓ)) where\n constructor mksubmonoid\n\n private module M = Monoid M\n\n field\n Member : Pred ⟨ M ⟩ ℓ\n isSubmonoid : IsSubmonoid M Member\n\n open IsSubmonoid isSubmonoid public\n\n subsemigroup : Subsemigroup M.semigroup ℓ\n subsemigroup = record { isSubsemigroup = isSubsemigroup }\n\n open Subsemigroup subsemigroup public using (submagma)\n\n\ninstance\n SubmonoidCarrier : ∀ {c ℓ} {M : Monoid c} → HasCarrier (Submonoid M ℓ) _\n SubmonoidCarrier = record { ⟨_⟩ = Submonoid.Carrier }\n\n\nmodule _ {ℓ} (M : Monoid ℓ) where\n open Monoid M\n\n ε-isSubmonoid : IsSubmonoid M { ε }\n ε-isSubmonoid = record\n { preservesOp = map2 λ p q → cong₂ _•_ p q ∙ identityʳ ε\n ; preservesId = ∣ refl ∣\n }\n\n ε-submonoid : Submonoid M _\n ε-submonoid = record { isSubmonoid = ε-isSubmonoid }\n\n U-isSubmonoid : IsSubmonoid M U\n U-isSubmonoid = record {} -- trivial\n\n U-submonoid : Submonoid M _\n U-submonoid = record { isSubmonoid = U-isSubmonoid }\n", "meta": {"hexsha": "421e2252f13cbaa09a7a2b597ebcc5eb72ba84c7", "size": 2492, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Monoid/Submonoid.agda", "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Monoid/Submonoid.agda", "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Monoid/Submonoid.agda", "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.92, "max_line_length": 88, "alphanum_fraction": 0.7138844302, "num_tokens": 822, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711604559846, "lm_q2_score": 0.749087201911703, "lm_q1q2_score": 0.6367025182916166}} {"text": "\nmodule HasDecidableSatisfaction where\n\nopen import OscarPrelude\nopen import 𝓐ssertion\nopen import HasSatisfaction\nopen import Interpretation\n\nrecord HasDecidableSatisfaction (A : Set) ⦃ _ : 𝓐ssertion A ⦄ ⦃ _ : HasSatisfaction A ⦄ : Set₁\n where\n field\n _⊨?_ : (I : Interpretation) → (x : A) → Dec (I ⊨ x)\n\nopen HasDecidableSatisfaction ⦃ … ⦄ public\n\n{-# DISPLAY HasDecidableSatisfaction._⊨?_ _ = _⊨?_ #-}\n", "meta": {"hexsha": "1f50baa4b84cc7fb74dded1dc69c0813780f3f4d", "size": 409, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-1/HasDecidableSatisfaction.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-1/HasDecidableSatisfaction.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-1/HasDecidableSatisfaction.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.0588235294, "max_line_length": 94, "alphanum_fraction": 0.7212713936, "num_tokens": 147, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9019206686206199, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.6365621097907408}} {"text": "open import Level hiding ( suc ; zero )\nopen import Algebra\nmodule sym4 where\n\nopen import Symmetric \nopen import Data.Unit\nopen import Function.Inverse as Inverse using (_↔_; Inverse; _InverseOf_)\nopen import Function\nopen import Data.Nat hiding (_⊔_) -- using (ℕ; suc; zero)\nopen import Relation.Nullary\nopen import Data.Empty\nopen import Data.Product\n\nopen import Gutil \nopen import Putil \nopen import Solvable using (solvable)\nopen import Relation.Binary.PropositionalEquality hiding ( [_] )\n\nopen import Data.Fin\nopen import Data.Fin.Permutation hiding (_∘ₚ_)\n\ninfixr 200 _∘ₚ_\n_∘ₚ_ = Data.Fin.Permutation._∘ₚ_\n\nsym4solvable : solvable (Symmetric 4)\nsolvable.dervied-length sym4solvable = 3\nsolvable.end sym4solvable x d = solved1 x d where\n\n open import Data.List using ( List ; [] ; _∷_ )\n open Solvable (Symmetric 4)\n\n -- Klien\n --\n -- 1 (1,2),(3,4) (1,3),(2,4) (1,4),(2,3)\n -- 0 ∷ 1 ∷ 2 ∷ 3 ∷ [] , 1 ∷ 0 ∷ 3 ∷ 2 ∷ [] , 2 ∷ 3 ∷ 0 ∷ 1 ∷ [] , 3 ∷ 2 ∷ 1 ∷ 0 ∷ [] , \n\n a0 = pid {4}\n a1 = pswap (pswap (pid {0}))\n a2 = pid {4} ∘ₚ pins (n≤ 3) ∘ₚ pins (n≤ 3 ) \n a3 = pins (n≤ 3) ∘ₚ pins (n≤ 2) ∘ₚ pswap (pid {2})\n\n k3 = plist (a1 ∘ₚ a2 ) ∷ plist (a1 ∘ₚ a3) ∷ plist (a2 ∘ₚ a1 ) ∷ []\n\n open import FLutil\n open import Data.List.Fresh hiding ([_])\n open import Relation.Nary using (⌊_⌋)\n\n p0id : FL→perm ((# 0) :: (# 0) :: ((# 0) :: ((# 0 ) :: f0))) =p= pid\n p0id = pleq _ _ refl\n\n\n open import Data.List.Fresh.Relation.Unary.Any\n open import FLComm\n\n stage3FList : CommFListN 4 3 ≡ cons (zero :: zero :: zero :: zero :: f0) [] (Level.lift tt)\n stage3FList = refl\n\n st3 = proj₁ (toList ( CommFListN 4 2 ))\n -- st4 = {!!}\n \n solved1 : (x : Permutation 4 4) → deriving 3 x → x =p= pid \n solved1 x dr = CommSolved 4 x ( CommFListN 4 3 ) stage3FList p0id solved2 where\n -- p0id : FL→perm ((# 0) :: ((# 0) :: ((# 0 ) :: f0))) =p= pid\n solved2 : Any (perm→FL x ≡_) ( CommFListN 4 3 )\n solved2 = CommStage→ 4 3 x dr \n", "meta": {"hexsha": "9ffda672b10be6aae69d65e9e2bfd3bc657324bf", "size": 2034, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/sym4.agda", "max_stars_repo_name": "shinji-kono/Galois", "max_stars_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-16T03:37:05.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-16T03:37:05.000Z", "max_issues_repo_path": "src/sym4.agda", "max_issues_repo_name": "shinji-kono/Galois", "max_issues_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/sym4.agda", "max_forks_repo_name": "shinji-kono/Galois", "max_forks_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.8181818182, "max_line_length": 95, "alphanum_fraction": 0.5884955752, "num_tokens": 815, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357598021707, "lm_q2_score": 0.7341195152660687, "lm_q1q2_score": 0.6365078717043171}} {"text": "module Optics.Lens where\nopen import Agda.Primitive using (Level; _⊔_; lsuc)\nopen import Data.Product using (_×_; _,_; ∃-syntax)\nopen import Function.Inverse using (_↔_; inverse)\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl; module ≡-Reasoning; cong)\n\nopen import Category.Functor.Arr\nopen import Category.Functor.Const\nopen import Category.Profunctor.Star\nopen import Category.Strong\nopen import Optics\n\nLens : ∀ {l} (S T A B : Set l) → Set (lsuc l)\nLens = Optic StrongImp\n\nmodule Lens {l} {S T A B : Set l} (lens : Lens S T A B) where\n get : S → A\n get = getOptic S T A B (starStrong constFunctor) lens\n set : S → B → T\n set = setOptic S T A B (starStrong arrFunctor) lens\n\nrecord LawfulLens {l} {S A : Set l} (lens' : Lens S S A A) : Set (lsuc l) where\n open Lens lens' public\n lens : Lens S S A A\n lens = lens'\n field\n setget : ∀ (s : S) → set s (get s) ≡ s\n getset : ∀ (s : S) (a : A) → get (set s a) ≡ a\n setset : ∀ (s : S) (a a' : A) → set (set s a) ≡ set s\n\n\nlensIso : ∀ {l} {S A : Set l} {lens : Lens S S A A} → (lawful : LawfulLens lens) → S ↔ (∃[ a ] ∃[ c ] ∃[ s ] (c ≡ Lens.set lens s × Lens.get lens s ≡ a))\nlensIso {_} {S} {A} lawful = inverse to from from∘to to∘from\n where\n open LawfulLens lawful\n to : S → ∃[ a ] ∃[ c ] ∃[ s ] (c ≡ set s × get s ≡ a)\n to s = get s , set s , s , refl , refl\n from : ∃[ a ] ∃[ c ] ∃[ s ] (c ≡ set s × get s ≡ a) → S\n from (a , c , _ , _ , _) = c a\n from∘to : (s : S) → from (to s) ≡ s\n from∘to = setget\n to∘from : (elem : ∃[ a ] ∃[ c ] ∃[ s ] (c ≡ set s × get s ≡ a)) → to (from elem) ≡ elem\n open ≡-Reasoning\n to∘from (.(get s) , .(set s) , s , refl , refl) = begin\n (get (set s (get s)) , set (set s (get s)) , set s (get s) , _ , _) ≡⟨ cong (λ sᵢ → get sᵢ , set sᵢ , sᵢ , refl , refl) (setget s) ⟩\n (get s , set s , s , _ , _) ∎\n\n", "meta": {"hexsha": "3a36bf4da2ecdb0ca60fad5de7c9897c5150f2b3", "size": 1876, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Optics/Lens.agda", "max_stars_repo_name": "crisoagf/agda-optics", "max_stars_repo_head_hexsha": "308afeeaa905870dbf1a995fa82e8825dfaf2d74", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Optics/Lens.agda", "max_issues_repo_name": "crisoagf/agda-optics", "max_issues_repo_head_hexsha": "308afeeaa905870dbf1a995fa82e8825dfaf2d74", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Optics/Lens.agda", "max_forks_repo_name": "crisoagf/agda-optics", "max_forks_repo_head_hexsha": "308afeeaa905870dbf1a995fa82e8825dfaf2d74", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.0833333333, "max_line_length": 153, "alphanum_fraction": 0.5575692964, "num_tokens": 760, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898254600902, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.6364850897225773}} {"text": "open import Coinduction using ( ♭ ; ♯_ )\nopen import Data.Unit using ( ⊤ ; tt )\nopen import System.IO.Transducers.Syntax \n using ( lazy ; strict ; _⇒_is_ ; inp ; out ; done )\n renaming ( _⟫_ to _⟫'_ ; _[&]_ to _[&]'_ ; _⟨&⟩_ to _⟨&⟩'_ ;\n discard to discard' ; π₁ to π₁' ; π₂ to π₂' ;\n ⟦_⟧ to ⟦_⟧' )\nopen import System.IO.Transducers.Session using ( Session ; I ; Σ ; _&_ )\nopen import System.IO.Transducers.Trace using ( Trace )\n\nmodule System.IO.Transducers.Function where\n\n-- We can regard strict transducers as functions.\n-- Note that in the case of S ⇒ T where S is a Σ session,\n-- this agrees with the type of inp, so we can regard\n-- inp as a function of type ∞ (S ⇒ T) → (S to T is s).\n\nLHS : Session → Set\nLHS I = ⊤\nLHS (Σ {A} V F) = A\n\nRHS : (S T : Session) → (LHS S) → Set₁\nRHS I T a = I ⇒ T is strict\nRHS (Σ V F) T a = ♭ F a ⇒ T is lazy\n\n_⇛_ : Session → Session → Set₁\nS ⇛ T = (a : LHS S) → (RHS S T a)\n\n-- Map from functions to syntax and back.\n\nφ : ∀ {S T} → (S ⇒ T is strict) → (S ⇛ T)\nφ {I} done a = done\nφ {Σ W F} (inp P) a = ♭ P a\nφ {Σ W F} done a = out a done\n\nφ' : ∀ {S T} → (S ⇛ T) → (S ⇒ T is strict)\nφ' {I} P = P tt\nφ' {Σ W F} P = inp (♯ P)\n\n-- Semantics of functions is inherited from semantics on syntax\n\n⟦_⟧ : ∀ {S T} → (S ⇛ T) → (Trace S) → (Trace T)\n⟦ P ⟧ = ⟦ φ' P ⟧'\n\n-- Structure on functions is inherited from structure on syntax\n\nid : ∀ {S} → (S ⇛ S)\nid {S} = φ (done {S})\n\n_⟫_ : ∀ {S T U} → (S ⇛ T) → (T ⇛ U) → (S ⇛ U)\n_⟫_ {S} P Q = φ (φ' {S} P ⟫' φ' Q)\n\n_[&]_ : ∀ {S T U V} → (S ⇛ T) → (U ⇛ V) → ((S & U) ⇛ (T & V))\n_[&]_ {S} P Q = φ (φ' {S} P [&]' φ' Q)\n\n_⟨&⟩_ : ∀ {S T U} → (S ⇛ T) → (S ⇛ U) → (S ⇛ (T & U))\n_⟨&⟩_ {S} P Q = φ (φ' {S} P ⟨&⟩' φ' Q)\n\ndiscard : ∀ {S} → (S ⇛ I)\ndiscard {S} = φ (discard' {S})\n\nπ₁ : ∀ {S T} → ((S & T) ⇛ S)\nπ₁ {S} = φ (π₁' {S})\n\nπ₂ : ∀ {S T} → ((S & T) ⇛ T)\nπ₂ {S} = φ (π₂' {S})\n", "meta": {"hexsha": "ab0b2e4fbc272f9c580f93c93a8a9d8383e6fad3", "size": 1880, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/System/IO/Transducers/Function.agda", "max_stars_repo_name": "ilya-fiveisky/agda-system-io", "max_stars_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2015-01-04T13:45:16.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-15T04:35:41.000Z", "max_issues_repo_path": "src/System/IO/Transducers/Function.agda", "max_issues_repo_name": "ilya-fiveisky/agda-system-io", "max_issues_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/System/IO/Transducers/Function.agda", "max_forks_repo_name": "ilya-fiveisky/agda-system-io", "max_forks_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-08-10T06:12:54.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:23.000Z", "avg_line_length": 28.0597014925, "max_line_length": 73, "alphanum_fraction": 0.5015957447, "num_tokens": 831, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8976952921073469, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.6364831384129073}} {"text": "module list-thms2 where\n\nopen import bool\nopen import bool-thms\nopen import bool-thms2\nopen import functions\nopen import list\nopen import list-thms\nopen import nat\nopen import nat-thms\nopen import product-thms\nopen import logic\n\nlist-and-++ : ∀(l1 l2 : 𝕃 𝔹) → list-and (l1 ++ l2) ≡ (list-and l1) && (list-and l2)\nlist-and-++ [] l2 = refl\nlist-and-++ (x :: l1) l2 rewrite (list-and-++ l1 l2) | (&&-assoc x (list-and l1) (list-and l2))= refl\n\nlist-or-++ : ∀(l1 l2 : 𝕃 𝔹) → list-or (l1 ++ l2) ≡ (list-or l1) || (list-or l2)\nlist-or-++ [] l2 = refl\nlist-or-++ (x :: l1) l2 rewrite (list-or-++ l1 l2) | (||-assoc x (list-or l1) (list-or l2)) = refl\n\n++-singleton : ∀{ℓ}{A : Set ℓ}(a : A)(l1 l2 : 𝕃 A) → (l1 ++ [ a ]) ++ l2 ≡ l1 ++ (a :: l2)\n++-singleton a l1 [] rewrite ++[] (l1 ++ a :: []) = refl\n++-singleton a l1 l2 rewrite (++-assoc l1 [ a ] l2) = refl\n\nlist-member-++ : ∀{ℓ}{A : Set ℓ}(eq : A → A → 𝔹)(a : A)(l1 l2 : 𝕃 A) → \n list-member eq a (l1 ++ l2) ≡ (list-member eq a l1) || (list-member eq a l2)\nlist-member-++ eq a [] l2 = refl\nlist-member-++ eq a (x :: l1) l2 with eq a x\nlist-member-++ eq a (x :: l1) l2 | tt = refl\nlist-member-++ eq a (x :: l1) l2 | ff rewrite (list-member-++ eq a l1 l2) = refl\n\nlist-member-++2 : ∀{ℓ}{A : Set ℓ}(eq : A → A → 𝔹)(a : A)(l1 l2 : 𝕃 A) → \n list-member eq a l1 ≡ tt → \n list-member eq a (l1 ++ l2) ≡ tt\nlist-member-++2 eq a [] l2 ()\nlist-member-++2 eq a (x :: l1) l2 p with eq a x\nlist-member-++2 eq a (x :: l1) l2 p | tt = refl\nlist-member-++2 eq a (x :: l1) l2 p | ff rewrite (list-member-++2 eq a l1 l2 p) = refl\n\n\nlist-member-++3 : ∀{ℓ}{A : Set ℓ}(eq : A → A → 𝔹)(a : A)(l1 l2 : 𝕃 A) → \n list-member eq a l2 ≡ tt → \n list-member eq a (l1 ++ l2) ≡ tt\nlist-member-++3 eq a [] l2 p = p\nlist-member-++3 eq a (x :: l1) l2 p with eq a x\nlist-member-++3 eq a (x :: l1) l2 p | tt = refl\nlist-member-++3 eq a (x :: l1) l2 p | ff rewrite (list-member-++3 eq a l1 l2 p) = refl\n\nfilter-ff-repeat : ∀{ℓ}{A : Set ℓ}{p : A → 𝔹}{a : A}(n : ℕ) →\n p a ≡ ff → \n filter p (repeat n a) ≡ []\nfilter-ff-repeat zero p1 = refl\nfilter-ff-repeat{ℓ}{A}{p0}{a} (suc n) p1 with keep (p0 a)\nfilter-ff-repeat{ℓ}{A}{p0}{a} (suc n) p1 | tt , y rewrite y = 𝔹-contra (sym p1)\nfilter-ff-repeat{ℓ}{A}{p0}{a} (suc n) p1 | ff , y rewrite y = filter-ff-repeat {ℓ} {A} {p0} {a} n y\n\nis-empty-distr : ∀{ℓ}{A : Set ℓ} (l1 l2 : 𝕃 A) → is-empty (l1 ++ l2) ≡ (is-empty l1) && (is-empty l2)\nis-empty-distr [] l2 = refl\nis-empty-distr (x :: l1) l2 = refl\n\nis-empty-reverse : ∀{ℓ}{A : Set ℓ}(l : 𝕃 A) → is-empty l ≡ is-empty (reverse l)\nis-empty-reverse [] = refl\nis-empty-reverse (x :: xs) rewrite (reverse-++h (x :: []) xs) | (is-empty-distr (reverse-helper [] xs) (x :: []))\n | (&&-comm (is-empty (reverse-helper [] xs)) ff) = refl\n\nreverse-length : ∀{ℓ}{A : Set ℓ}(l : 𝕃 A) → length (reverse l) ≡ length l\nreverse-length l = length-reverse-helper [] l\n\nlast-distr : ∀{ℓ}{A : Set ℓ}(l : 𝕃 A)(x : A)(p : is-empty l ≡ ff) → last (x :: l) refl ≡ last l p\nlast-distr [] x ()\nlast-distr (x :: l) x2 refl = refl\n\nis-empty-[] : ∀{ℓ}{A : Set ℓ} (l : 𝕃 A)(p : is-empty l ≡ tt) → l ≡ []\nis-empty-[] [] p = refl\nis-empty-[] (x :: l) ()\n\nrev-help-empty : ∀ {ℓ}{A : Set ℓ} (l1 l2 : 𝕃 A) → (p1 : is-empty l2 ≡ ff) → \n is-empty (reverse-helper l1 l2) ≡ ff\nrev-help-empty l1 [] ()\nrev-help-empty l1 (x :: l2) p rewrite reverse-++h (x :: l1) l2 | is-empty-distr (reverse-helper [] l2) (x :: l1)\n | (&&-comm (is-empty (reverse-helper [] l2)) ff) = refl\n\nis-empty-revh : ∀{ℓ}{A : Set ℓ}(h l : 𝕃 A) → is-empty l ≡ ff → is-empty (reverse-helper h l) ≡ ff\nis-empty-revh h l p = rev-help-empty h l p\n\nhead-last-reverse-lem : ∀{ℓ}{A : Set ℓ}(h l : 𝕃 A)(p : is-empty l ≡ ff) → last l p ≡ head (reverse-helper h l) (is-empty-revh h l p)\nhead-last-reverse-lem h [] ()\nhead-last-reverse-lem h (x :: []) p = refl\nhead-last-reverse-lem h (x :: y :: l) p = head-last-reverse-lem (x :: h) (y :: l) refl\n\nhead-last-reverse : ∀{ℓ}{A : Set ℓ}(l : 𝕃 A)(p : is-empty l ≡ ff) → last l p ≡ head (reverse l) (rev-help-empty [] l p)\nhead-last-reverse [] ()\nhead-last-reverse (x :: l) p with keep (is-empty l)\nhead-last-reverse (x :: l) refl | tt , b rewrite is-empty-[] l b = refl\nhead-last-reverse (x :: l) refl | ff , b rewrite (last-distr l x b) = head-last-reverse-lem (x :: []) l b\n\nreverse-reverse : ∀{ℓ}{A : Set ℓ}(l : 𝕃 A) → reverse (reverse l) ≡ l\nreverse-reverse [] = refl\nreverse-reverse (x :: l) rewrite (reverse-++h (x :: []) l) | (reverse-++ (reverse-helper [] l) (x :: [])) | reverse-reverse l = refl\n\nempty++elem : ∀ {ℓ}{A : Set ℓ} (a : A) (l : 𝕃 A) → is-empty ( l ++ [ a ]) ≡ ff\nempty++elem a [] = refl\nempty++elem a (x :: l) = refl\n\nlast-++ : ∀{ℓ}{A : Set ℓ} (a : A) (l : 𝕃 A) → last (l ++ [ a ]) (empty++elem a l) ≡ a\nlast-++ a [] = refl\nlast-++ a (x :: l) rewrite last-distr (l ++ [ a ]) x (empty++elem a l) | last-++ a l = refl\n", "meta": {"hexsha": "0fb13ff5ccf562c286c4f64fd4f3a2e702ea92e9", "size": 5027, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "list-thms2.agda", "max_stars_repo_name": "heades/AUGL", "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "list-thms2.agda", "max_issues_repo_name": "heades/AUGL", "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "list-thms2.agda", "max_forks_repo_name": "heades/AUGL", "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.119266055, "max_line_length": 133, "alphanum_fraction": 0.5317286652, "num_tokens": 2029, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.863391617003942, "lm_q2_score": 0.7371581626286833, "lm_q1q2_score": 0.6364561780196337}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Function.Isomorphism where\n\nopen import Cubical.Foundations.Equiv using (isoToEquiv) public\nopen import Cubical.Foundations.Isomorphism using (Iso; section; retract; isoToPath; iso) public\nopen import Level\nopen import Path\nopen import Function\nopen import Data.Sigma\nopen import Relation.Binary\n\nopen Iso public\n\ninfix 4 _⇔_\n_⇔_ = Iso\n\nsym-⇔ : (A ⇔ B) → (B ⇔ A)\nfun (sym-⇔ A⇔B) = inv A⇔B\ninv (sym-⇔ A⇔B) = fun A⇔B\nleftInv (sym-⇔ A⇔B) = rightInv A⇔B\nrightInv (sym-⇔ A⇔B) = leftInv A⇔B\n\nrefl-⇔ : A ⇔ A\nfun refl-⇔ x = x\ninv refl-⇔ x = x\nleftInv refl-⇔ x = refl\nrightInv refl-⇔ x = refl\n\ntrans-⇔ : A ⇔ B → B ⇔ C → A ⇔ C\nfun (trans-⇔ A⇔B B⇔C) = fun B⇔C ∘ fun A⇔B\ninv (trans-⇔ A⇔B B⇔C) = inv A⇔B ∘ inv B⇔C\nleftInv (trans-⇔ A⇔B B⇔C) x = cong (inv A⇔B) (leftInv B⇔C _) ; leftInv A⇔B _\nrightInv (trans-⇔ A⇔B B⇔C) x = cong (fun B⇔C) (rightInv A⇔B _) ; rightInv B⇔C _\n\niso-Σ : {B : A → Type b} {C : A → Type c} → (∀ x → B x ⇔ C x) → Σ A B ⇔ Σ A C\niso-Σ B⇔C .fun (x , xs) = x , B⇔C x .fun xs\niso-Σ B⇔C .inv (x , xs) = x , B⇔C x .inv xs\niso-Σ B⇔C .rightInv (x , xs) i .fst = x\niso-Σ B⇔C .rightInv (x , xs) i .snd = B⇔C x .rightInv xs i\niso-Σ B⇔C .leftInv (x , xs) i .fst = x\niso-Σ B⇔C .leftInv (x , xs) i .snd = B⇔C x .leftInv xs i\n\n⇔-equiv : Equivalence (Type a) a\nEquivalence._≋_ ⇔-equiv = _⇔_\nEquivalence.sym ⇔-equiv = sym-⇔\nEquivalence.refl ⇔-equiv = refl-⇔\nEquivalence.trans ⇔-equiv = trans-⇔\n\nopen import HLevels\nopen import Equiv\n\niso⇔equiv : isSet A → (A ⇔ B) ⇔ (A ≃ B)\niso⇔equiv isSetA .fun = isoToEquiv\niso⇔equiv isSetA .inv = equivToIso\niso⇔equiv isSetA .rightInv x i .fst = x .fst\niso⇔equiv isSetA .rightInv x i .snd = isPropIsEquiv (x .fst) (isoToEquiv (equivToIso x) .snd) (x .snd) i\niso⇔equiv isSetA .leftInv x i .fun = x .fun\niso⇔equiv isSetA .leftInv x i .inv = x .inv\niso⇔equiv isSetA .leftInv x i .rightInv = x .rightInv\niso⇔equiv isSetA .leftInv x i .leftInv y = isSetA _ y (equivToIso (isoToEquiv x) .leftInv y) (x .leftInv y) i\n", "meta": {"hexsha": "53e76b5fd9857805b93445e1be0216a026a981ff", "size": 1991, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Function/Isomorphism.agda", "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "agda/Function/Isomorphism.agda", "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Function/Isomorphism.agda", "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.1129032258, "max_line_length": 109, "alphanum_fraction": 0.6343545957, "num_tokens": 988, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916064586998, "lm_q2_score": 0.7371581568543044, "lm_q1q2_score": 0.6364561652605721}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Category.Groupoid where\n\nopen import Level using (Level; suc; _⊔_)\n\nopen import Categories.Category using (Category)\nimport Categories.Morphism\n\nrecord IsGroupoid {o ℓ e} (C : Category o ℓ e) : Set (o ⊔ ℓ ⊔ e) where\n open Category C public\n\n open Categories.Morphism C\n\n infix 10 _⁻¹\n\n field\n _⁻¹ : ∀ {A B} → A ⇒ B → B ⇒ A\n iso : ∀ {A B} {f : A ⇒ B} → Iso f (f ⁻¹)\n\n module iso {A B f} = Iso (iso {A} {B} {f})\n\n equiv-obj : ∀ {A B} → A ⇒ B → A ≅ B\n equiv-obj f = record\n { from = f\n ; to = _\n ; iso = iso\n }\n\n -- this definition doesn't seem to 'carry its weight'\n equiv-obj-sym : ∀ {A B} → A ⇒ B → B ≅ A\n equiv-obj-sym f = ≅.sym (equiv-obj f)\n\n-- A groupoid is a category that has a groupoid structure\n\nrecord Groupoid (o ℓ e : Level) : Set (suc (o ⊔ ℓ ⊔ e)) where\n field\n category : Category o ℓ e\n isGroupoid : IsGroupoid category\n\n open IsGroupoid isGroupoid public\n", "meta": {"hexsha": "5c8b0c643fd6690d26a9ac08205eb5fb71f4bfec", "size": 964, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Groupoid.agda", "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Category/Groupoid.agda", "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Groupoid.agda", "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.512195122, "max_line_length": 70, "alphanum_fraction": 0.6006224066, "num_tokens": 343, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314647623015, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.6364098097997802}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import Types\n\nmodule Functions where\n\n-- Identity functions\nid : ∀ {i} (A : Set i) → (A → A)\nid A = λ x → x\n\n-- Constant functions\ncst : ∀ {i j} {A : Set i} {B : Set j} (b : B) → (A → B)\ncst b = λ _ → b\n\n-- Composition of dependent functions\n_◯_ : ∀ {i j k} {A : Set i} {B : A → Set j} {C : (a : A) → (B a → Set k)}\n → (g : {a : A} → Π (B a) (C a)) → (f : Π A B) → Π A (λ a → C a (f a))\ng ◯ f = λ x → g (f x)\n\n-- Application\ninfixr 0 _$_\n_$_ : ∀ {i j} {A : Set i} {B : A → Set j} → (∀ x → B x) → (∀ x → B x)\nf $ x = f x\n\n-- Curry! Can't live without it!\ncurry : ∀ {i j k} {A : Set i} {B : A → Set j} {C : Σ A B → Set k}\n → (∀ s → C s) → (∀ x y → C (x , y))\ncurry f x y = f (x , y)\n\nuncurry : ∀ {i j k} {A : Set i} {B : A → Set j} {C : ∀ x → B x → Set k}\n → (∀ x y → C x y) → (∀ s → C (π₁ s) (π₂ s))\nuncurry f (x , y) = f x y\n", "meta": {"hexsha": "809c3f8642b68e803b856aaa3aab99d2ebc053fb", "size": 862, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "old/Functions.agda", "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 294, "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_issues_repo_path": "old/Functions.agda", "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 31, "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_forks_repo_path": "old/Functions.agda", "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 50, "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "avg_line_length": 26.1212121212, "max_line_length": 73, "alphanum_fraction": 0.4373549884, "num_tokens": 398, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772384450967, "lm_q2_score": 0.7279754371026367, "lm_q1q2_score": 0.6363067597185348}} {"text": "module Numeral.Natural.Oper.FlooredDivision.Proofs.DivisibilityWithRemainder where\n\nopen import Data\nopen import Functional\nopen import Numeral.Finite\nimport Numeral.Finite.Proofs as 𝕟\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.Oper.FlooredDivision\nopen import Numeral.Natural.Oper.FlooredDivision.Proofs\nopen import Numeral.Natural.Relation.DivisibilityWithRemainder hiding (base₀ ; base₊ ; step)\nopen import Numeral.Natural.Relation.DivisibilityWithRemainder.Proofs\nopen import Relator.Equals\nopen import Relator.Equals.Proofs\nopen import Syntax.Transitivity\n\n-- The quotient of the divisibility relation is given by the floored division operation.\n[⌊/⌋][∣ᵣₑₘ]-quotient-equality : ∀{x y r}{p : (𝐒(y) ∣ᵣₑₘ x)(r)} → ((x ⌊/⌋ 𝐒(y)) ≡ [∣ᵣₑₘ]-quotient p)\n[⌊/⌋][∣ᵣₑₘ]-quotient-equality {𝟎} {_} {𝟎} {DivRem𝟎} = [≡]-intro\n[⌊/⌋][∣ᵣₑₘ]-quotient-equality {𝐒 .(𝕟-to-ℕ r)} {𝐒 y} {𝐒 r} {DivRem𝟎} =\n ([ 0 , 𝐒(y) ] (𝕟-to-ℕ r) div y) 🝖[ _≡_ ]-[ inddiv-smaller(𝕟.bounded{y}{r}) ]\n 𝟎 🝖-end\n[⌊/⌋][∣ᵣₑₘ]-quotient-equality {𝐒 x} {𝟎} {𝟎} {DivRem𝐒 p} = [≡]-with(𝐒) $\n ([ 0 , 0 ] x div 0) 🝖[ _≡_ ]-[ [⌊/⌋]-of-1ᵣ ]\n x 🝖[ _≡_ ]-[ [∣ᵣₑₘ]-quotient-of-1 p ]-sym\n [∣ᵣₑₘ]-quotient p 🝖-end\n{-# CATCHALL #-}\n[⌊/⌋][∣ᵣₑₘ]-quotient-equality {𝐒 .(x + y)} {y} {r} {DivRem𝐒 {x = x} p} =\n ([ 0 , (y) ] (𝐒(x) + y) div y) 🝖[ _≡_ ]-[ inddiv-step-denominator{0}{(y)}{𝐒(x)}{y} ]\n ([ 0 , (y) ] 𝐒(x) div 𝟎) 🝖[ _≡_ ]-[]\n 𝐒([ 0 , y ] x div y) 🝖[ _≡_ ]-[ [≡]-with(𝐒) ([⌊/⌋][∣ᵣₑₘ]-quotient-equality {p = p}) ]\n 𝐒([∣ᵣₑₘ]-quotient p) 🝖-end\n", "meta": {"hexsha": "aa32c5745387c77f61c76ea29cfa556ef1c88ec3", "size": 1639, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Oper/FlooredDivision/Proofs/DivisibilityWithRemainder.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Oper/FlooredDivision/Proofs/DivisibilityWithRemainder.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Oper/FlooredDivision/Proofs/DivisibilityWithRemainder.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.6666666667, "max_line_length": 99, "alphanum_fraction": 0.59609518, "num_tokens": 816, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637577007394, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.6363010783513467}} {"text": "module Capability where\n\nopen import Relation.Nullary\n using (yes; no)\n\nopen import Data.List\n using (List; []; [_]; _∷_; _++_)\n\nopen import Data.String\n using (String; _≟_)\n\nopen import Relation.Binary.PropositionalEquality\n using (_≢_; refl; _≡_)\n\n-- Local modules ---------------------------------------------------------------\n\nopen import Common\n using (Id)\n\n-- Capabilities Definition -----------------------------------------------------\n\ninfix 50 `_\ninfixr 15 _∙_\n\ndata Capability : Set where\n `_ : Id → Capability -- Name\n In : Id → Capability -- Can enter\n Out : Id → Capability -- Can exit\n Open : Id → Capability -- Can open\n ε : Capability -- Null\n _∙_ : Capability → Capability → Capability -- Path\n\n-- Free variable ---------------------------------------------------------------\n\nfreeVar : Capability -> List Id\nfreeVar (` a) = [ a ]\nfreeVar (a ∙ b) = (freeVar a) ++ (freeVar b)\nfreeVar _ = []\n\n-- Capability substitution -----------------------------------------------------\n\n_[_/_] : Capability -> Id -> Capability -> Capability\n\n` x [ y / M ] with x ≟ y\n... | yes _ = M\n... | no _ = ` x\n(N ∙ R) [ y / M ] = N [ y / M ] ∙ R [ y / M ]\nC [ _ / _ ] = C\n\nmodule Test where\n a = \"a\"\n b = \"b\"\n\n ------------------------------------------------------------------------------\n\n _ : freeVar (` a) ≡ [ a ]\n _ = refl\n\n _ : freeVar (` a ∙ ` b) ≡ a ∷ b ∷ []\n _ = refl\n\n ------------------------------------------------------------------------------\n\n _ : ∀ {M} → ` a [ a / M ] ≡ M\n _ = refl\n\n _ : ∀ {M} → ` b [ a / M ] ≡ ` b\n _ = refl\n\n", "meta": {"hexsha": "5182e4c3ac71acfe844884283fbeb4a7026f6aec", "size": 1753, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Capability.agda", "max_stars_repo_name": "d-plaindoux/colca", "max_stars_repo_head_hexsha": "a81447af3ab2ba898bb7d57be71369abbba12d81", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-03-12T18:31:14.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-04T09:35:36.000Z", "max_issues_repo_path": "src/Capability.agda", "max_issues_repo_name": "d-plaindoux/colca", "max_issues_repo_head_hexsha": "a81447af3ab2ba898bb7d57be71369abbba12d81", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Capability.agda", "max_forks_repo_name": "d-plaindoux/colca", "max_forks_repo_head_hexsha": "a81447af3ab2ba898bb7d57be71369abbba12d81", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.0428571429, "max_line_length": 80, "alphanum_fraction": 0.3707929264, "num_tokens": 438, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637505099167, "lm_q2_score": 0.7401743735019594, "lm_q1q2_score": 0.6363010779560223}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Category.Instance.LawvereTheories where\n\n-- Category of Lawvere Theories\n\nopen import Level\n\nopen import Categories.Category\nopen import Categories.Functor.Cartesian.Properties\nopen import Categories.NaturalTransformation.NaturalIsomorphism\nopen import Categories.Theory.Lawvere\n\nLawvereTheories : (o ℓ e : Level) → Category (suc (o ⊔ ℓ ⊔ e)) (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e)\nLawvereTheories o ℓ e = record\n { Obj = FiniteProduct o ℓ e\n ; _⇒_ = LT-Hom\n ; _≈_ = λ H₁ H₂ → F H₁ ≃ F H₂\n ; id = LT-id\n ; _∘_ = LT-∘\n ; assoc = λ { {f = f} {g} {h} → associator (F f) (F g) (F h)}\n ; sym-assoc = λ { {f = f} {g} {h} → sym-associator (F f) (F g) (F h)}\n ; identityˡ = unitorˡ\n ; identityʳ = unitorʳ\n ; identity² = unitor²\n ; equiv = record { refl = refl ; sym = sym ; trans = trans }\n ; ∘-resp-≈ = _ⓘₕ_\n }\n where open LT-Hom\n", "meta": {"hexsha": "f00c7609cd98e65bcd7c01f133f2bd8b7db014b7", "size": 875, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Instance/LawvereTheories.agda", "max_stars_repo_name": "bond15/agda-categories", "max_stars_repo_head_hexsha": "6cbfdf3f1be15ef513435e3b85faae92cb1ac36f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Category/Instance/LawvereTheories.agda", "max_issues_repo_name": "bond15/agda-categories", "max_issues_repo_head_hexsha": "6cbfdf3f1be15ef513435e3b85faae92cb1ac36f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Instance/LawvereTheories.agda", "max_forks_repo_name": "bond15/agda-categories", "max_forks_repo_head_hexsha": "6cbfdf3f1be15ef513435e3b85faae92cb1ac36f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.1724137931, "max_line_length": 86, "alphanum_fraction": 0.6342857143, "num_tokens": 332, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9099070158103778, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.6362564978550743}} {"text": "module FlexInterpreter where\n\ndata Ty : Set where\n nat : Ty\n arr : Ty -> Ty -> Ty\n\ndata Exp : Ty -> Set where\n zero : Exp nat\n suc : Exp (arr nat nat)\n pred : Exp (arr nat nat)\n app : {a b : Ty} -> Exp (arr a b) -> Exp a -> Exp b\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\nSem : Ty -> Set\nSem nat = Nat\nSem (arr a b) = Sem a -> Sem b\n\neval : {a : Ty} -> Exp a -> Sem a\neval zero = zero\neval suc = suc\neval pred zero = zero\neval pred (suc n) = n\neval (app f e) = eval f (eval e)\n", "meta": {"hexsha": "f46b7a2b81db5c1f6372e86d6d214c9ff82695a2", "size": 500, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/features/FlexInterpreter.agda", "max_stars_repo_name": "dagit/agda", "max_stars_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T07:26:06.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T07:26:06.000Z", "max_issues_repo_path": "test/features/FlexInterpreter.agda", "max_issues_repo_name": "dagit/agda", "max_issues_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/features/FlexInterpreter.agda", "max_forks_repo_name": "dagit/agda", "max_forks_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.5185185185, "max_line_length": 54, "alphanum_fraction": 0.568, "num_tokens": 179, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9230391664210672, "lm_q2_score": 0.6893056231680121, "lm_q1q2_score": 0.6362560878183562}} {"text": "\nmodule Prelude.Int.Core where\n\nopen import Prelude.Unit\nopen import Prelude.Empty\nopen import Prelude.Nat\nopen import Prelude.Number\nopen import Prelude.Semiring\nopen import Prelude.Ord\n\nopen import Agda.Builtin.Int public\n\nneg : Nat → Int\nneg zero = pos zero\nneg (suc n) = negsuc n\n{-# INLINE neg #-}\n\n-- Integers are numbers --\n\ninstance\n NumInt : Number Int\n Number.Constraint NumInt _ = ⊤\n Number.fromNat NumInt n = pos n\n\n NegInt : Negative Int\n Negative.Constraint NegInt _ = ⊤\n Negative.fromNeg NegInt n = neg n\n\n-- Arithmetic --\n\n_-NZ_ : Nat → Nat → Int\na -NZ b with compare a b\n... | less (diff k _) = negsuc k\n... | equal _ = pos (a - b) -- a - b instead of 0 makes it compile to Integer minus\n... | greater (diff k _) = pos (suc k)\n{-# INLINE _-NZ_ #-}\n\n_+Z_ : Int → Int → Int\npos a +Z pos b = pos (a + b)\npos a +Z negsuc b = a -NZ suc b\nnegsuc a +Z pos b = b -NZ suc a\nnegsuc a +Z negsuc b = negsuc (suc a + b)\n{-# INLINE _+Z_ #-}\n\n{-# DISPLAY _+Z_ a b = a + b #-}\n\nnegateInt : Int → Int\nnegateInt (pos n) = neg n\nnegateInt (negsuc n) = pos (suc n)\n{-# INLINE negateInt #-}\n\n{-# DISPLAY negateInt a = negate a #-}\n\n_-Z_ : Int → Int → Int\na -Z b = a +Z negateInt b\n{-# INLINE _-Z_ #-}\n\nabs : Int → Nat\nabs (pos n) = n\nabs (negsuc n) = suc n\n\n_*Z_ : Int → Int → Int\npos a *Z pos b = pos (a * b)\npos a *Z negsuc b = neg (a * suc b)\nnegsuc a *Z pos b = neg (suc a * b)\nnegsuc a *Z negsuc b = pos (suc a * suc b)\n{-# INLINE _*Z_ #-}\n\n{-# DISPLAY _*Z_ a b = a * b #-}\n\ninstance\n SemiringInt : Semiring Int\n Semiring.zro SemiringInt = 0\n Semiring.one SemiringInt = 1\n Semiring._+_ SemiringInt = _+Z_\n Semiring._*_ SemiringInt = _*Z_\n\n SubInt : Subtractive Int\n Subtractive._-_ SubInt = _-Z_\n Subtractive.negate SubInt = negateInt\n\nNonZeroInt : Int → Set\nNonZeroInt (pos zero) = ⊥\nNonZeroInt _ = ⊤\n\ninfixl 7 quotInt-by remInt-by\n\nsyntax quotInt-by b a = a quot b\nquotInt-by : (b : Int) {{_ : NonZeroInt b}} → Int → Int\nquotInt-by (pos zero) {{}} _\nquotInt-by (pos (suc n)) (pos m) = pos (m div suc n)\nquotInt-by (pos (suc n)) (negsuc m) = neg (suc m div suc n)\nquotInt-by (negsuc n) (pos m) = neg (m div suc n)\nquotInt-by (negsuc n) (negsuc m) = pos (suc m div suc n)\n{-# INLINE quotInt-by #-}\n\nsyntax remInt-by b a = a rem b\nremInt-by : (b : Int) {{_ : NonZeroInt b}} → Int → Int\nremInt-by (pos zero) {{}} _\nremInt-by (pos (suc n)) (pos m) = pos ( m mod suc n)\nremInt-by (pos (suc n)) (negsuc m) = neg (suc m mod suc n)\nremInt-by (negsuc n) (pos m) = pos ( m mod suc n)\nremInt-by (negsuc n) (negsuc m) = neg (suc m mod suc n)\n{-# INLINE remInt-by #-}\n", "meta": {"hexsha": "3e27451ccb3d22bd82f34adbfc305313c75e6241", "size": 2655, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Prelude/Int/Core.agda", "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 111, "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_issues_repo_path": "src/Prelude/Int/Core.agda", "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_forks_repo_path": "src/Prelude/Int/Core.agda", "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "avg_line_length": 25.2857142857, "max_line_length": 95, "alphanum_fraction": 0.6086629002, "num_tokens": 960, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094117351309, "lm_q2_score": 0.7122321842389469, "lm_q1q2_score": 0.636243713521321}} {"text": "\nmodule Issue121 where\n\nid : Set → Set\nid A = A\n\ndata Bool : Set where\n true : Bool\n false : Bool\n\nF : Bool → Set → Set\nF true = id\nF false = id\n\nG : Bool → Set → Set\nG true = id\nG false = λ A → A\n\ndata D : Set where\n nop : (b : Bool) → F b D → D\n bop : (b : Bool) → G b D → D\n", "meta": {"hexsha": "956cf396bb327d3e6bd6c65ada054c980a47e52b", "size": 283, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue121.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue121.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue121.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 12.8636363636, "max_line_length": 30, "alphanum_fraction": 0.5441696113, "num_tokens": 111, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8933094003735664, "lm_q2_score": 0.712232184238947, "lm_q1q2_score": 0.6362437054292492}} {"text": "------------------------------------------------------------------------\n-- Second-order abstract syntax\n--\n-- Examples of the formalisation framework in use\n------------------------------------------------------------------------\n\n\nmodule Examples where\n\n-- | Algebraic structures\n\n-- Monoids\nimport Monoid.Signature\nimport Monoid.Syntax\nimport Monoid.Equality\n\n-- Commutative monoids\nimport CommMonoid.Signature\nimport CommMonoid.Syntax\nimport CommMonoid.Equality\n\n-- Groups\nimport Group.Signature\nimport Group.Syntax\nimport Group.Equality\n\n-- Commutative groups\nimport CommGroup.Signature\nimport CommGroup.Syntax\nimport CommGroup.Equality\n\n-- Group actions\nimport GroupAction.Signature\nimport GroupAction.Syntax\nimport GroupAction.Equality\n\n-- Semirings\nimport Semiring.Signature\nimport Semiring.Syntax\nimport Semiring.Equality\n\n-- Rings\nimport Ring.Signature\nimport Ring.Syntax\nimport Ring.Equality\n\n-- Commutative rings\nimport CommRing.Signature\nimport CommRing.Syntax\nimport CommRing.Equality\n\n\n-- | Logic\n\n-- Propositional logic\nimport PropLog.Signature\nimport PropLog.Syntax\nimport PropLog.Equality\n\n-- First-order logic (with example proofs)\nimport FOL.Signature\nimport FOL.Syntax\nimport FOL.Equality\n\n\n-- | Computational calculi\n\n-- Combinatory logic\nimport Combinatory.Signature\nimport Combinatory.Syntax\nimport Combinatory.Equality\n\n-- Untyped λ-calculus\nimport UTLC.Signature\nimport UTLC.Syntax\nimport UTLC.Equality\n\n-- Simply-typed λ-calculus (with operational semantics and environment model)\nimport STLC.Signature\nimport STLC.Syntax\nimport STLC.Equality\nimport STLC.Model\n\n-- Typed λ-calculus with product and sum types, and naturals (with example derivation)\nimport TLC.Signature\nimport TLC.Syntax\nimport TLC.Equality\n\n-- PCF\nimport PCF.Signature\nimport PCF.Syntax\nimport PCF.Equality\n\n\n-- | Miscellaneous\n\n-- Lenses\nimport Lens.Signature\nimport Lens.Syntax\nimport Lens.Equality\n\n-- Inception algebras\nimport Inception.Signature\nimport Inception.Syntax\nimport Inception.Equality\n\n-- Substitution algebras\nimport Sub.Signature\nimport Sub.Syntax\nimport Sub.Equality\n\n-- Partial differentiation (with some example proofs)\nimport PDiff.Signature\nimport PDiff.Syntax\nimport PDiff.Equality\n", "meta": {"hexsha": "024711177c6a9655ab3507d16cfa804fed862f19", "size": 2201, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "out/Examples.agda", "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_issues_repo_path": "out/Examples.agda", "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_forks_repo_path": "out/Examples.agda", "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "avg_line_length": 18.974137931, "max_line_length": 86, "alphanum_fraction": 0.762380736, "num_tokens": 495, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094032139577, "lm_q2_score": 0.7122321720225278, "lm_q1q2_score": 0.6362436965392251}} {"text": "{- Name: Bowornmet (Ben) Hudson\n\n--Type safety and meaning functions for L{⇒,+,×,unit}--\n\n-}\n\nopen import Preliminaries\nopen import Preorder\nopen import Preorder-repackage\n\nmodule L where\n\n -- => and + and × and unit\n data Typ : Set where\n _⇒_ : Typ → Typ → Typ\n _×'_ : Typ → Typ → Typ\n _+'_ : Typ → Typ → Typ\n unit : Typ\n\n------------------------------------------\n\n -- represent a context as a list of types\n Ctx = List Typ\n\n -- de Bruijn indices (for free variables)\n data _∈_ : Typ → Ctx → Set where\n i0 : ∀ {Γ τ}\n → τ ∈ (τ :: Γ)\n iS : ∀ {Γ τ τ1}\n → τ ∈ Γ\n → τ ∈ (τ1 :: Γ)\n\n------------------------------------------\n\n -- static semantics\n data _|-_ : Ctx → Typ → Set where\n var : ∀ {Γ τ}\n → (x : τ ∈ Γ) → Γ |- τ\n lam : ∀ {Γ τ ρ}\n → (x : (ρ :: Γ) |- τ)\n → Γ |- (ρ ⇒ τ)\n app : ∀ {Γ τ1 τ2}\n → (e1 : Γ |- (τ2 ⇒ τ1)) → (e2 : Γ |- τ2)\n → Γ |- τ1\n unit : ∀ {Γ}\n → Γ |- unit\n prod : ∀ {Γ τ1 τ2}\n → (e1 : Γ |- τ1) → (e2 : Γ |- τ2)\n → Γ |- (τ1 ×' τ2)\n l-proj : ∀ {Γ τ1 τ2}\n → (e : Γ |- (τ1 ×' τ2))\n → Γ |- τ1\n r-proj : ∀ {Γ τ1 τ2}\n → (e : Γ |- (τ1 ×' τ2))\n → Γ |- τ2\n inl : ∀ {Γ τ1 τ2}\n → (e : Γ |- τ1)\n → Γ |- (τ1 +' τ2)\n inr : ∀ {Γ τ1 τ2}\n → (e : Γ |- τ2)\n → Γ |- (τ1 +' τ2)\n case` : ∀ {Γ τ1 τ2 τ}\n → (e : Γ |- (τ1 +' τ2))\n → (e1 : (τ1 :: Γ) |- τ)\n → (e2 : (τ2 :: Γ) |- τ)\n → Γ |- τ\n\n------------------------------------------\n\n -- renaming\n rctx : Ctx → Ctx → Set\n rctx Γ Γ' = ∀ {τ} → τ ∈ Γ' → τ ∈ Γ\n\n -- re: transferring variables in contexts\n lem1 : ∀ {Γ Γ' τ} → rctx Γ Γ' → rctx (τ :: Γ) (τ :: Γ')\n lem1 d i0 = i0\n lem1 d (iS x) = iS (d x)\n\n -- renaming lemma\n ren : ∀ {Γ Γ' τ} → Γ' |- τ → rctx Γ Γ' → Γ |- τ\n ren (var x) d = var (d x)\n ren (lam e) d = lam (ren e (lem1 d))\n ren (app e1 e2) d = app (ren e1 d) (ren e2 d)\n ren unit d = unit\n ren (prod e1 e2) d = prod (ren e1 d) (ren e2 d)\n ren (l-proj e) d = l-proj (ren e d)\n ren (r-proj e) d = r-proj (ren e d)\n ren (inl x) d = inl (ren x d)\n ren (inr x) d = inr (ren x d)\n ren (case` e e1 e2) d = case` (ren e d) (ren e1 (lem1 d)) (ren e2 (lem1 d))\n\n------------------------------------------\n\n -- substitution\n sctx : Ctx → Ctx → Set\n sctx Γ Γ' = ∀ {τ} → τ ∈ Γ' → Γ |- τ\n\n -- weakening (didn't need this later on. Oh well)\n wkn : ∀ {Γ τ1 τ2} → Γ |- τ2 → (τ1 :: Γ) |- τ2\n wkn e = ren e iS\n\n -- lem2 (need a lemma for subst like we did for renaming)\n lem2 : ∀ {Γ Γ' τ} → sctx Γ Γ' → sctx (τ :: Γ) (τ :: Γ')\n lem2 d i0 = var i0\n lem2 d (iS i0) = ren (d i0) iS\n lem2 d (iS (iS i)) = ren (d (iS i)) iS\n\n -- another substitution lemma\n lem3 : ∀ {Γ τ} → Γ |- τ → sctx Γ (τ :: Γ)\n lem3 d i0 = d\n lem3 d (iS i) = var i\n\n -- one final lemma needed for the last stepping rule. Thank you Professor Licata!\n lem4 : ∀ {Γ τ1 τ2} → Γ |- τ1 → Γ |- τ2 → sctx Γ (τ1 :: (τ2 :: Γ))\n lem4 x y i0 = x\n lem4 x y (iS i0) = y\n lem4 x y (iS (iS i)) = var i\n\n -- the 'real' substitution lemma\n subst : ∀ {Γ Γ' τ} → sctx Γ Γ' → Γ' |- τ → Γ |- τ\n subst d (var x) = d x\n subst d (lam e) = lam (subst (lem2 d) e)\n subst d (app e1 e2) = app (subst d e1) (subst d e2)\n subst d unit = unit\n subst d (prod e1 e2) = prod (subst d e1) (subst d e2)\n subst d (l-proj e) = l-proj (subst d e)\n subst d (r-proj e) = r-proj (subst d e)\n subst d (inl x) = inl (subst d x)\n subst d (inr x) = inr (subst d x)\n subst d (case` e e1 e2) = case` (subst d e) (subst (lem2 d) e1) (subst (lem2 d) e2)\n\n------------------------------------------\n\n -- closed values of L (when something is a value)\n -- recall that we use empty contexts when we work with dynamic semantics\n data val : ∀ {τ} → [] |- τ → Set where\n unit-isval : val unit\n lam-isval : ∀ {ρ τ} (e : (ρ :: []) |- τ)\n → val (lam e)\n prod-isval : ∀ {τ1 τ2}\n → (e1 : [] |- τ1) → (e2 : [] |- τ2)\n → val e1 → val e2\n → val (prod e1 e2)\n inl-isval : ∀ {τ1 τ2}\n → (e : [] |- τ1)\n → val e\n → val (inl {_} {_} {τ2} e)\n inr-isval : ∀ {τ1 τ2}\n → (e : [] |- τ2)\n → val e\n → val (inr {_} {τ1} {_} e)\n\n------------------------------------------\n\n -- stepping rules (preservation is folded into this)\n -- Preservation: if e:τ and e=>e', then e':τ\n data _>>_ : ∀ {τ} → [] |- τ → [] |- τ → Set where\n app-steps : ∀ {τ1 τ2}\n → (e1 e1' : [] |- (τ2 ⇒ τ1)) → (e2 : [] |- τ2)\n → e1 >> e1'\n → (app e1 e2) >> (app e1' e2)\n app-steps-2 : ∀ {τ1 τ2}\n → (e1 : [] |- (τ2 ⇒ τ1)) → (e2 e2' : [] |- τ2)\n → val e1 → e2 >> e2'\n → (app e1 e2) >> (app e1 e2')\n app-steps-3 : ∀ {τ1 τ2}\n → (e1 : (τ1 :: []) |- τ2)\n → (e2 : [] |- τ1)\n → (app (lam e1) e2) >> subst (lem3 e2) e1\n prod-steps : ∀ {τ1 τ2}\n → (e1 e1' : [] |- τ1) → (e2 : [] |- τ2)\n → e1 >> e1'\n → (prod e1 e2) >> (prod e1' e2)\n prod-steps-2 : ∀ {τ1 τ2}\n → (e1 : [] |- τ1) → (e2 e2' : [] |- τ2)\n → val e1 → e2 >> e2'\n → (prod e1 e2) >> (prod e1 e2')\n l-proj-steps : ∀ {τ1 τ2}\n → (e e' : [] |- (τ1 ×' τ2))\n → e >> e'\n → (l-proj e) >> (l-proj e')\n l-proj-steps-2 : ∀ {τ1 τ2}\n → (e1 : [] |- τ1) → (e2 : [] |- τ2)\n → val e1 → val e2\n → (l-proj (prod e1 e2)) >> e1\n r-proj-steps : ∀ {τ1 τ2}\n → (e e' : [] |- (τ1 ×' τ2))\n → e >> e'\n → (r-proj e) >> (r-proj e')\n r-proj-steps-2 : ∀ {τ1 τ2}\n → (e1 : [] |- τ1) → (e2 : [] |- τ2)\n → val e1 → val e2\n → (r-proj (prod e1 e2)) >> e2\n inl-steps : ∀ {τ1 τ2}\n → (e e' : [] |- τ1)\n → e >> e'\n → inl {_} {_} {τ2} e >> inl e'\n inr-steps : ∀ {τ1 τ2}\n → (e e' : [] |- τ2)\n → e >> e'\n → inr {_} {τ1} {_} e >> inr e'\n case`-steps : ∀ {τ1 τ2 τ}\n → (e e' : [] |- (τ1 +' τ2))\n → (e1 : (τ1 :: []) |- τ)\n → (e2 : (τ2 :: []) |- τ)\n → e >> e'\n → (case` e e1 e2) >> (case` e' e1 e2)\n case`-steps-2 : ∀ {τ1 τ2 τ}\n → (e : [] |- τ1)\n → (e1 : (τ1 :: []) |- τ)\n → (e2 : (τ2 :: []) |- τ)\n → val e\n → (case` (inl e) e1 e2) >> subst (lem3 e) e1\n case`-steps-3 : ∀ {τ1 τ2 τ}\n → (e : [] |- τ2)\n → (e1 : (τ1 :: []) |- τ)\n → (e2 : (τ2 :: []) |- τ)\n → val e\n → (case` (inr e) e1 e2) >> subst (lem3 e) e2\n\n------------------------------------------\n\n -- Proof of progress!\n -- Progress: if e:τ, then either e val or ∃e' such that e=>e'\n progress : ∀ {τ} (e : [] |- τ) → Either (val e) (Σ (λ e' → (e >> e')))\n progress (var ())\n progress (lam x) = Inl (lam-isval x)\n progress (app e1 e2) with progress e1 \n progress (app .(lam e) e2) | Inl (lam-isval e) = Inr (_ , app-steps-3 e e2)\n progress (app e1 e2) | Inr (x , d) = Inr (_ , app-steps e1 x e2 d)\n progress unit = Inl unit-isval\n progress (prod e1 e2) with progress e1\n progress (prod e1 e2) | Inl d with progress e2\n progress (prod e1 e2) | Inl d | Inl x = Inl (prod-isval e1 e2 d x)\n progress (prod e1 e2) | Inl d | Inr (x , k) = Inr (_ , prod-steps-2 e1 e2 x d k)\n progress (prod e1 e2) | Inr (x , d) = Inr (_ , prod-steps e1 x e2 d)\n progress (l-proj e) with progress e\n progress (l-proj .(prod e1 e2)) | Inl (prod-isval e1 e2 d d₁) = Inr (_ , l-proj-steps-2 e1 e2 d d₁)\n progress (l-proj e) | Inr (x , d) = Inr (_ , l-proj-steps e x d)\n progress (r-proj e) with progress e\n progress (r-proj .(prod e1 e2)) | Inl (prod-isval e1 e2 d d₁) = Inr (_ , r-proj-steps-2 e1 e2 d d₁)\n progress (r-proj e) | Inr (x , d) = Inr (_ , r-proj-steps e x d)\n progress (inl e) with progress e\n progress (inl e) | Inl x = Inl (inl-isval e x)\n progress (inl e) | Inr (x , d) = Inr (_ , inl-steps e x d)\n progress (inr e) with progress e\n progress (inr e) | Inl x = Inl (inr-isval e x)\n progress (inr e) | Inr (x , d) = Inr (_ , inr-steps e x d)\n progress (case` e e1 e2) with progress e\n progress (case` .(inl e) e1 e2) | Inl (inl-isval e x) = Inr (_ , case`-steps-2 e e1 e2 x)\n progress (case` .(inr e) e1 e2) | Inl (inr-isval e x) = Inr (_ , case`-steps-3 e e1 e2 x)\n progress (case` e e1 e2) | Inr (x , d) = Inr (_ , case`-steps e x e1 e2 d)\n\n------------------------------------------\n\n -- how to interpret types in L as preorders\n\n interp : Typ → PREORDER\n interp (A ⇒ B) = interp A ->p interp B\n interp (A ×' B) = interp A ×p interp B\n interp (A +' B) = interp A +p interp B\n interp unit = unit-p\n\n interpC : Ctx → PREORDER\n interpC [] = unit-p\n interpC (A :: Γ) = interpC Γ ×p interp A\n\n -- look up a variable in context\n lookup : ∀{Γ τ} → τ ∈ Γ → el (interpC Γ ->p interp τ)\n lookup (i0 {Γ} {τ}) = snd' {interpC (τ :: Γ)} {interpC Γ} {_} id\n lookup (iS {Γ} {τ} {τ1} x) = comp {interpC (τ1 :: Γ)} {_} {_} (fst' {interpC (τ1 :: Γ)} {_} {interp τ1} id) (lookup x)\n\n interpE : ∀{Γ τ} → Γ |- τ → el (interpC Γ ->p interp τ)\n interpE (var x) = lookup x\n interpE (lam e) = lam' (interpE e)\n interpE (app e1 e2) = app' (interpE e1) (interpE e2)\n interpE unit = monotone (λ _ → <>) (λ x y _ → <>)\n interpE (prod e1 e2) = pair' (interpE e1) (interpE e2)\n interpE (l-proj {Γ} {τ1} {τ2} e) = fst' {_} {_} {interp τ2} (interpE e)\n interpE (r-proj {Γ} {τ1} {τ2} e) = snd' {_} {interp τ1} {_} (interpE e)\n interpE (inl e) = inl' (interpE e)\n interpE (inr e) = inr' (interpE e)\n interpE (case` e e1 e2) = case' (interpE e1) (interpE e2) (interpE e)\n", "meta": {"hexsha": "01155eaf198f8d301a5e1d11358ec1b1183cd64c", "size": 9996, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "ug/L.agda", "max_stars_repo_name": "benhuds/Agda", "max_stars_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-04-26T20:22:22.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-08T12:27:18.000Z", "max_issues_repo_path": "ug/L.agda", "max_issues_repo_name": "benhuds/Agda", "max_issues_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-03-23T08:39:04.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-12T00:32:45.000Z", "max_forks_repo_path": "ug/L.agda", "max_forks_repo_name": "benhuds/Agda", "max_forks_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.1971830986, "max_line_length": 120, "alphanum_fraction": 0.4231692677, "num_tokens": 3926, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245828938678, "lm_q2_score": 0.7634837635542924, "lm_q1q2_score": 0.636229788810121}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.CommRing.QuotientRing where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Structure\nopen import Cubical.Foundations.Powerset\n\nopen import Cubical.Data.Nat\nopen import Cubical.Data.FinData\n\nopen import Cubical.HITs.SetQuotients using ([_]; squash/; elimProp2)\nopen import Cubical.HITs.PropositionalTruncation as PT\n\nopen import Cubical.Algebra.CommRing\nopen import Cubical.Algebra.CommRing.Ideal\nopen import Cubical.Algebra.CommRing.FGIdeal\nopen import Cubical.Algebra.CommRing.Kernel\nopen import Cubical.Algebra.Ring\nimport Cubical.Algebra.Ring.QuotientRing as Ring\n\nprivate\n variable\n ℓ ℓ' : Level\n\n_/_ : (R : CommRing ℓ) → (I : IdealsIn R) → CommRing ℓ\nR / I =\n fst asRing , commringstr _ _ _ _ _\n (iscommring (RingStr.isRing (snd asRing))\n (elimProp2 (λ _ _ → squash/ _ _)\n commEq))\n where\n asRing = (CommRing→Ring R) Ring./ (CommIdeal→Ideal I)\n _·/_ : fst asRing → fst asRing → fst asRing\n _·/_ = RingStr._·_ (snd asRing)\n commEq : (x y : fst R) → ([ x ] ·/ [ y ]) ≡ ([ y ] ·/ [ x ])\n commEq x y i = [ CommRingStr.·Comm (snd R) x y i ]\n\n[_]/ : {R : CommRing ℓ} {I : IdealsIn R} → (a : fst R) → fst (R / I)\n[ a ]/ = [ a ]\n\n\nmodule Quotient-FGideal-CommRing-Ring\n (A : CommRing ℓ)\n (B : Ring ℓ')\n (g : RingHom (CommRing→Ring A) B)\n {n : ℕ}\n (v : FinVec ⟨ A ⟩ n)\n (gnull : (k : Fin n) → g $ v k ≡ RingStr.0r (snd B))\n where\n\n open RingStr (snd B) using (0r)\n\n zeroOnGeneratedIdeal : (x : ⟨ A ⟩) → x ∈ fst (generatedIdeal A v) → g $ x ≡ 0r\n zeroOnGeneratedIdeal x x∈FGIdeal =\n PT.elim\n (λ _ → isSetRing B (g $ x) 0r)\n (λ {(α , isLC) → subst _ (sym isLC) (cancelLinearCombination A B g _ α v gnull)})\n x∈FGIdeal\n\n inducedHom : RingHom (CommRing→Ring (A / (generatedIdeal _ v))) B\n inducedHom = Ring.UniversalProperty.inducedHom (CommRing→Ring A) (CommIdeal→Ideal ideal) g zeroOnGeneratedIdeal\n where ideal = generatedIdeal A v\n\nmodule Quotient-FGideal-CommRing-CommRing\n (A : CommRing ℓ)\n (B : CommRing ℓ')\n (g : CommRingHom A B)\n {n : ℕ}\n (v : FinVec ⟨ A ⟩ n)\n (gnull : (k : Fin n) → g $ v k ≡ CommRingStr.0r (snd B))\n where\n\n inducedHom : CommRingHom (A / (generatedIdeal _ v)) B\n inducedHom = Quotient-FGideal-CommRing-Ring.inducedHom A (CommRing→Ring B) g v gnull\n\n\nquotientHom : (R : CommRing ℓ) → (I : IdealsIn R) → CommRingHom R (R / I)\nquotientHom R I = Ring.quotientHom (CommRing→Ring R) (CommIdeal→Ideal I)\n\n\nmodule _ {R : CommRing ℓ} (I : IdealsIn R) where\n private\n π = quotientHom R I\n\n kernel≡I : kernelIdeal R (R / I) π ≡ I\n kernel≡I = cong Ideal→CommIdeal (Ring.kernel≡I (CommIdeal→Ideal I))\n", "meta": {"hexsha": "36cd1e4be24cf407b66ed0cab5290d2f018e9bb3", "size": 2748, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommRing/QuotientRing.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_issues_repo_path": "Cubical/Algebra/CommRing/QuotientRing.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/CommRing/QuotientRing.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.5862068966, "max_line_length": 113, "alphanum_fraction": 0.6390101892, "num_tokens": 954, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424411924673, "lm_q2_score": 0.7520125793176222, "lm_q1q2_score": 0.6361593571553933}} {"text": "module Issue268 where\n\nmodule Example₁ where\n open import Common.Coinduction\n\n module Record where\n\n record Stream : Set where\n constructor cons\n field\n tail : ∞ Stream\n\n module Data where\n\n data Stream : Set where\n cons : ∞ Stream → Stream\n\n -- open Data\n open Record\n\n id : Stream → Stream\n id (cons xs) = cons (♯ id (♭ xs))\n\n postulate\n P : Stream → Set\n f : ∀ xs → P (id xs) → Set\n xs : Stream\n p : P (id xs)\n\n Foo : Set\n Foo = f _ p\n\n -- The code type checks when Data is opened, but not when Record is\n -- opened:\n --\n -- Bug.agda:34,11-12\n -- (Stream.tail (id xs)) != (.Bug.♯-0 _40) of type (∞ Stream)\n -- when checking that the expression p has type P (id (cons _40))\n\nmodule Example₂ where\n\n data D : Set where\n d : D\n\n id : D → D\n id d = d\n\n module Record where\n\n record E : Set where\n constructor e\n field\n f : D\n\n module Data where\n\n data E : Set where\n e : D → E\n\n -- open Data\n open Record\n\n id′ : E → E\n id′ (e xs) = e (id xs)\n\n postulate\n P : E → Set\n f : (x : E) → P (id′ x) → Set\n x : E\n p : P (id′ x)\n\n Foo : Set\n Foo = f _ p\n", "meta": {"hexsha": "7cb9e40f4b32a3f00e9c6d47feadce21d0f38bdf", "size": 1159, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/Issue268.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/succeed/Issue268.agda", "max_issues_repo_name": "asr/agda-kanso", "max_issues_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/Issue268.agda", "max_forks_repo_name": "asr/agda-kanso", "max_forks_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 15.6621621622, "max_line_length": 69, "alphanum_fraction": 0.5470232959, "num_tokens": 388, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424256566558, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.6361593407706676}} {"text": "open import Data.Nat\nmodule OpenTheory where\n\n----------------------------------------------------------------------\n\ndata Vec (A : Set) : ℕ → Set₁ where\n nil : Vec A zero\n cons : (n : ℕ) (x : A) (xs : Vec A n) → Vec A (suc n)\n\ndata Vec2 : Set → ℕ → Set₁ where\n nil : (A : Set) → Vec2 A zero\n cons : (A : Set) (n : ℕ) (x : A) (xs : Vec2 A n) → Vec2 A (suc n)\n\nelimVec : {A : Set} (P : (n : ℕ) → Vec A n → Set)\n (pnil : P zero nil)\n (pcnons : (n : ℕ) (x : A) (xs : Vec A n) → P n xs → P (suc n) (cons n x xs))\n (n : ℕ) (xs : Vec A n) → P n xs\nelimVec P pnil pcons .zero nil = pnil\nelimVec P pnil pcons .(suc n) (cons n x xs) = pcons n x xs (elimVec P pnil pcons n xs)\n\n----------------------------------------------------------------------\n\ndata Tree (A B : Set) : ℕ → ℕ → Set where\n leaf₁ : A → Tree A B (suc zero) zero\n leaf₂ : B → Tree A B zero (suc zero)\n branch : (m n x y : ℕ)\n → Tree A B m n → Tree A B x y\n → Tree A B (m + x) (n + y)\n\n----------------------------------------------------------------------\n", "meta": {"hexsha": "bd0c4360a3b86223a2e8d8c79e8afbfbf22ed737", "size": 1029, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "slides/OpenTheory.agda", "max_stars_repo_name": "larrytheliquid/generic-elim", "max_stars_repo_head_hexsha": "832383d7adf37aa2364213fb0aeb67e9f61a248f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-06-02T14:05:20.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-09T08:46:42.000Z", "max_issues_repo_path": "slides/OpenTheory.agda", "max_issues_repo_name": "larrytheliquid/generic-elim", "max_issues_repo_head_hexsha": "832383d7adf37aa2364213fb0aeb67e9f61a248f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "slides/OpenTheory.agda", "max_forks_repo_name": "larrytheliquid/generic-elim", "max_forks_repo_head_hexsha": "832383d7adf37aa2364213fb0aeb67e9f61a248f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-05-02T08:56:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:31:22.000Z", "avg_line_length": 33.1935483871, "max_line_length": 86, "alphanum_fraction": 0.4198250729, "num_tokens": 353, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774768002981829, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.6360568505709003}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Categories.Instances.CommAlgebras where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.Powerset\n\nopen import Cubical.Algebra.CommRing\nopen import Cubical.Algebra.Algebra\nopen import Cubical.Algebra.CommAlgebra\n\nopen import Cubical.Categories.Category\nopen import Cubical.Categories.Functor.Base\n\nopen import Cubical.HITs.PropositionalTruncation\n\nopen Category\nopen CommAlgebraHoms\n\nprivate\n variable\n ℓ ℓ' ℓ'' : Level\n\nmodule _ (R : CommRing ℓ) where\n CommAlgebrasCategory : Category (ℓ-suc (ℓ-max ℓ ℓ')) (ℓ-max ℓ ℓ')\n ob CommAlgebrasCategory = CommAlgebra R _\n Hom[_,_] CommAlgebrasCategory = CommAlgebraHom\n id CommAlgebrasCategory {A} = idCommAlgebraHom A\n _⋆_ CommAlgebrasCategory {A} {B} {C} = compCommAlgebraHom A B C\n ⋆IdL CommAlgebrasCategory {A} {B} = compIdCommAlgebraHom {A = A} {B}\n ⋆IdR CommAlgebrasCategory {A} {B} = idCompCommAlgebraHom {A = A} {B}\n ⋆Assoc CommAlgebrasCategory {A} {B} {C} {D} = compAssocCommAlgebraHom {A = A} {B} {C} {D}\n isSetHom CommAlgebrasCategory = isSetAlgebraHom _ _\n\n\nmodule PreSheafFromUniversalProp (C : Category ℓ ℓ') (P : ob C → Type ℓ)\n {R : CommRing ℓ''} (𝓕 : Σ (ob C) P → CommAlgebra R ℓ'')\n (uniqueHom : ∀ x y → C [ fst x , fst y ] → isContr (CommAlgebraHom (𝓕 y) (𝓕 x)))\n where\n\n private\n ∥P∥ : ℙ (ob C)\n ∥P∥ x = ∥ P x ∥ , isPropPropTrunc\n ΣC∥P∥Cat = ΣPropCat C ∥P∥\n\n 𝓕UniqueEquiv : (x : ob C) (p q : P x) → isContr (CommAlgebraEquiv (𝓕 (x , p)) (𝓕 (x , q)))\n 𝓕UniqueEquiv x = contrCommAlgebraHom→contrCommAlgebraEquiv (curry 𝓕 x) λ p q → uniqueHom _ _ (id C)\n\n theMap : (x : ob C) → ∥ P x ∥ → CommAlgebra R ℓ''\n theMap x = recPT→CommAlgebra (curry 𝓕 x) (λ p q → 𝓕UniqueEquiv x p q .fst)\n λ p q r → 𝓕UniqueEquiv x p r .snd _\n\n theAction : (x y : ob C) → C [ x , y ]\n → (p : ∥ P x ∥) (q : ∥ P y ∥) → isContr (CommAlgebraHom (theMap y q) (theMap x p))\n theAction _ _ f = elim2 (λ _ _ → isPropIsContr) λ _ _ → uniqueHom _ _ f\n\n open Functor\n universalPShf : Functor (ΣC∥P∥Cat ^op) (CommAlgebrasCategory {ℓ = ℓ''} R {ℓ' = ℓ''})\n F-ob universalPShf = uncurry theMap\n F-hom universalPShf {x = x} {y = y} f = theAction _ _ f (y .snd) (x. snd) .fst\n F-id universalPShf {x = x} = theAction (x .fst) (x .fst) (id C) (x .snd) (x .snd) .snd _\n F-seq universalPShf {x = x} {z = z} f g = theAction _ _ (g ⋆⟨ C ⟩ f) (z .snd) (x .snd) .snd _\n", "meta": {"hexsha": "29e3a8eb9c0e9d19b155ff219991289ce6919bb4", "size": 2516, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Instances/CommAlgebras.agda", "max_stars_repo_name": "FernandoLarrain/cubical", "max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z", "max_issues_repo_path": "Cubical/Categories/Instances/CommAlgebras.agda", "max_issues_repo_name": "Seanpm2001-web/cubical", "max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Categories/Instances/CommAlgebras.agda", "max_forks_repo_name": "Seanpm2001-web/cubical", "max_forks_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.9365079365, "max_line_length": 100, "alphanum_fraction": 0.6387122417, "num_tokens": 976, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774767874818409, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.6360568412807149}} {"text": "\n{-\n FP Lunch, Nottingham\n July 27, 2007\n Conor McBride\n-}\n\nmodule Binary where\n\ndata Bit : Set where\n O : Bit\n I : Bit\n\ninfixl 80 _◃_\n\ndata Pos : Set where\n ◃I : Pos\n _◃_ : Pos -> Bit -> Pos\n\nbsuc : Pos -> Pos\nbsuc ◃I = ◃I ◃ O\nbsuc (n ◃ O) = n ◃ I\nbsuc (n ◃ I) = bsuc n ◃ O\n\ndata Peano : Pos -> Set where\n pI : Peano ◃I\n psuc : {n : Pos} -> Peano n -> Peano (bsuc n)\n\npdouble : {n : Pos} -> Peano n -> Peano (n ◃ O)\npdouble pI = psuc pI\npdouble (psuc p) = psuc (psuc (pdouble p))\n\npeano : (n : Pos) -> Peano n\npeano ◃I = pI\npeano (n ◃ O) = pdouble (peano n)\npeano (n ◃ I) = psuc (pdouble (peano n))\n\n-- Slow addition (yay!)\n_+_ : Pos -> Pos -> Pos\n_+_ n m = peano n ⊕ m\n where\n _⊕_ : {n : Pos} -> Peano n -> Pos -> Pos\n pI ⊕ m = bsuc m\n psuc p ⊕ m = bsuc (p ⊕ m)\n\ninfixl 60 _+_\ninfix 40 _==_\n\ndata _==_ {A : Set}(x : A) : A -> Set where\n refl : x == x\n\ntest : (◃I ◃ I ◃ O ◃ O ◃ O) == (◃I ◃ I ◃ O ◃ I) + (◃I ◃ O ◃ I ◃ I)\ntest = refl\n", "meta": {"hexsha": "f4b88fc4c9a8d10d1d4b7f581b736c762d92c7d3", "size": 980, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/Binary.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/Binary.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/Binary.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 18.1481481481, "max_line_length": 66, "alphanum_fraction": 0.5030612245, "num_tokens": 455, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9136765187126079, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.6358807853474324}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import HoTT\nopen import homotopy.RibbonCover\nimport homotopy.CoverClassification\n\nmodule experimental.CoverClassificationCat {i} (A∙ : Ptd i)\n (A-conn : is-connected 0 (fst A∙)) where\n\n open Cover\n open Gset\n open homotopy.CoverClassification A∙ A-conn\n\n private\n A : Type i\n A = fst A∙\n a₁ : A\n a₁ = snd A∙\n π1A = fundamental-group A∙\n\n -- A covering space constructed from a G-set.\n cover-hom-to-gset-hom : ∀ {j}\n → {cov₁ cov₂ : Cover A j}\n → CoverHom cov₁ cov₂\n → GsetHom (cover-to-gset cov₁) (cover-to-gset cov₂)\n cover-hom-to-gset-hom {cov₁ = cov₁}{cov₂} f = record\n { f = f a₁\n ; pres-act = λ l x → lemma₂ x l\n }\n where\n lemma₁ : ∀ x {a₂} (p : a₁ == a₂)\n → f a₂ (transport (Fiber cov₁) p x)\n == transport (Fiber cov₂) p (f a₁ x)\n lemma₁ _ idp = idp\n\n lemma₂ : ∀ x {a₂} (p : a₁ =₀ a₂)\n → f a₂ (transport₀ (Fiber cov₁) (Fiber-level cov₁ a₂) p x)\n == transport₀ (Fiber cov₂) (Fiber-level cov₂ a₂) p (f a₁ x)\n lemma₂ x {a₂} = Trunc-elim\n (λ p → =-preserves-level 0 (Fiber-level cov₂ a₂))\n (lemma₁ x {a₂})\n\n gset-hom-to-cover-hom : ∀ {j}\n → {gset₁ gset₂ : Gset π1A j}\n → GsetHom gset₁ gset₂\n → CoverHom (gset-to-cover gset₁) (gset-to-cover gset₂)\n gset-hom-to-cover-hom {gset₁ = gset₁}{gset₂} (gset-hom f pres-act) a₂ =\n Ribbon-rec\n {P = Ribbon A∙ gset₂ a₂}\n Ribbon-level\n (λ el p → trace (f el) p)\n (λ el loop p →\n trace (f (act gset₁ el loop)) p\n =⟨ pres-act loop el |in-ctx (λ x → trace x p) ⟩\n trace (act gset₂ (f el) loop) p\n =⟨ paste (f el) loop p ⟩\n trace (f el) (loop ∙₀ p)\n ∎)\n", "meta": {"hexsha": "0a9cd91dcada88f5be96131c1bbcf4a1cb1db370", "size": 1709, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/experimental/CoverClassificationCat.agda", "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "theorems/experimental/CoverClassificationCat.agda", "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "theorems/experimental/CoverClassificationCat.agda", "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.9661016949, "max_line_length": 73, "alphanum_fraction": 0.5669982446, "num_tokens": 652, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9136765187126079, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.6358807795856226}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Induction over Subset\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Fin.Subset.Induction where\n\nopen import Data.Nat.Base using (ℕ)\nopen import Data.Nat.Induction using (<-wellFounded)\nopen import Data.Fin.Subset using (Subset; _⊂_; ∣_∣)\nopen import Data.Fin.Subset.Properties\nopen import Induction\nopen import Induction.WellFounded as WF\n\n------------------------------------------------------------------------\n-- Re-export accessability\n\nopen WF public using (Acc; acc)\n\n------------------------------------------------------------------------\n-- Complete induction based on _⊂_\n\n⊂-Rec : ∀ {n ℓ} → RecStruct (Subset n) ℓ ℓ\n⊂-Rec = WfRec _⊂_\n\n⊂-wellFounded : ∀ {n} → WellFounded (_⊂_ {n})\n⊂-wellFounded {n} = Subrelation.wellFounded p⊂q⇒∣p∣<∣q∣ (InverseImage.wellFounded ∣_∣ <-wellFounded)\n", "meta": {"hexsha": "df304e1d5f8786c271161f4f8117c2dc807d6937", "size": 976, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/Fin/Subset/Induction.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Data/Fin/Subset/Induction.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Data/Fin/Subset/Induction.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 31.4838709677, "max_line_length": 100, "alphanum_fraction": 0.4989754098, "num_tokens": 246, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8887588023318196, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.6358393682593944}} {"text": "{-# OPTIONS --without-K --safe #-}\n\n-- 'Traditionally', meaning in nLab and in\n-- \"Lectures on n-Categories and Cohomology\" by Baez and Shulman\n-- https://arxiv.org/abs/math/0608420\n-- (-2)-Categories are defined to be just a single value, with trivial Hom\n\n-- But that's hardly a definition of a class of things, it's a definition of\n-- a single structure! What we want is the definition of a class which turns\n-- out to be (essentially) unique. Rather like the reals are (essentially) the\n-- only ordered complete archimedean field.\n\n-- So we will take a -2-Category to be a full-fledge Category, but where\n-- 1. |Obj| is (Categorically) contractible\n-- 2. |Hom| is connected (all arrows are equal)\n-- Note that we don't need to say anything at all about ≈\n\nmodule Categories.Minus2-Category where\n\nopen import Level\nopen import Categories.Category\nopen import Data.Product using (Σ)\nimport Categories.Morphism as M\n\nprivate\n variable\n o ℓ e : Level\n\nrecord -2-Category : Set (suc (o ⊔ ℓ ⊔ e)) where\n field\n cat : Category o ℓ e\n open Category cat public\n open M cat using (_≅_)\n\n field\n Obj-Contr : Σ Obj (λ x → (y : Obj) → x ≅ y)\n Hom-Conn : {x y : Obj} {f g : x ⇒ y} → f ≈ g\n", "meta": {"hexsha": "cb3ff8fa9679b48e65965f64f244d794c540fa5d", "size": 1206, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Minus2-Category.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Minus2-Category.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Minus2-Category.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 31.7368421053, "max_line_length": 78, "alphanum_fraction": 0.6890547264, "num_tokens": 360, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9314625050654264, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.6357918465621826}} {"text": "{-# OPTIONS --safe --without-K #-}\n\nmodule Level where\n\nopen import Agda.Primitive\n using (Level)\n renaming ( _⊔_ to _ℓ⊔_\n ; lzero to ℓzero\n ; lsuc to ℓsuc\n ; Set to Type\n )\n public\n\nvariable\n a b c : Level\n A : Type a\n B : Type b\n C : Type c\n", "meta": {"hexsha": "751fc1428a2bdab88fc983bca6df004049e04dab", "size": 294, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Level.agda", "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_issues_repo_path": "Level.agda", "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Level.agda", "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "avg_line_length": 15.4736842105, "max_line_length": 34, "alphanum_fraction": 0.5238095238, "num_tokens": 101, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8807970748488296, "lm_q2_score": 0.7217432182679956, "lm_q1q2_score": 0.6357093154424309}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import lib.Basics\nopen import lib.NType2\nopen import lib.types.Int\nopen import lib.types.Group\nopen import lib.types.List\nopen import lib.types.Word\nopen import lib.groups.Homomorphism\nopen import lib.groups.Isomorphism\nopen import lib.groups.FreeAbelianGroup\nopen import lib.types.SetQuotient\n\nmodule lib.groups.Int where\n\nℤ-group-structure : GroupStructure ℤ\nℤ-group-structure = record\n { ident = 0\n ; inv = ℤ~\n ; comp = _ℤ+_\n ; unit-l = ℤ+-unit-l\n ; assoc = ℤ+-assoc\n ; inv-l = ℤ~-inv-l\n }\n\nℤ-group : Group₀\nℤ-group = group _ ℤ-group-structure\n\nℤ-group-is-abelian : is-abelian ℤ-group\nℤ-group-is-abelian = ℤ+-comm\n\nℤ-abgroup : AbGroup₀\nℤ-abgroup = ℤ-group , ℤ-group-is-abelian\n\nℤ-iso-FreeAbGroup-Unit : ℤ-group ≃ᴳ FreeAbGroup.grp Unit\nℤ-iso-FreeAbGroup-Unit = ≃-to-≃ᴳ (equiv to from to-from from-to) to-pres-comp where\n to = FreeAbGroup.exp Unit fs[ inl unit :: nil ]\n from = FormalSum-extend ℤ-abgroup (λ _ → 1)\n abstract\n to-pres-comp = FreeAbGroup.exp-+ Unit fs[ inl unit :: nil ]\n\n to-from' : ∀ l → to (Word-extendᴳ ℤ-group (λ _ → 1) l) == fs[ l ]\n to-from' nil = idp\n to-from' (inl unit :: l) =\n FreeAbGroup.exp-succ Unit fs[ inl unit :: nil ] (Word-extendᴳ ℤ-group (λ _ → 1) l)\n ∙ ap (FreeAbGroup.comp Unit fs[ inl unit :: nil ]) (to-from' l)\n to-from' (inr unit :: l) =\n FreeAbGroup.exp-pred Unit fs[ inl unit :: nil ] (Word-extendᴳ ℤ-group (λ _ → 1) l)\n ∙ ap (FreeAbGroup.comp Unit fs[ inr unit :: nil ]) (to-from' l)\n\n to-from : ∀ fs → to (from fs) == fs\n to-from = FormalSum-elim to-from' (λ _ → prop-has-all-paths-↓)\n\n from-to : ∀ z → from (to z) == z\n from-to (pos 0) = idp\n from-to (pos 1) = idp\n from-to (negsucc 0) = idp\n from-to (pos (S (S n))) =\n GroupHom.pres-comp (FreeAbGroup-extend ℤ-abgroup (λ _ → 1))\n fs[ inl unit :: nil ] (FreeAbGroup.exp Unit fs[ inl unit :: nil ] (pos (S n)))\n ∙ ap succ (from-to (pos (S n)))\n from-to (negsucc (S n)) =\n GroupHom.pres-comp (FreeAbGroup-extend ℤ-abgroup (λ _ → 1))\n fs[ inr unit :: nil ] (FreeAbGroup.exp Unit fs[ inl unit :: nil ] (negsucc n))\n ∙ ap pred (from-to (negsucc n))\n\nexp-shom : ∀ {i} {GEl : Type i} (GS : GroupStructure GEl) (g : GEl) → ℤ-group-structure →ᴳˢ GS\nexp-shom GS g = group-structure-hom (GroupStructure.exp GS g) (GroupStructure.exp-+ GS g)\n\nexp-hom : ∀ {i} (G : Group i) (g : Group.El G) → ℤ-group →ᴳ G\nexp-hom G g = group-hom (Group.exp G g) (Group.exp-+ G g)\n", "meta": {"hexsha": "766f557ef827300a5854fa3e2d572d9d0c2af7d6", "size": 2509, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/groups/Int.agda", "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "core/lib/groups/Int.agda", "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "core/lib/groups/Int.agda", "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.8472222222, "max_line_length": 94, "alphanum_fraction": 0.6245516142, "num_tokens": 900, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8807970779778824, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.6357093071573122}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Groups.Definition\nopen import Groups.Abelian.Definition\nopen import Setoids.Setoids\nopen import Rings.Definition\nopen import Modules.Definition\nopen import Fields.Fields\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\n\nmodule Vectors.VectorSpace {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+R_ : A → A → A} {_*_ : A → A → A} (R : Ring S _+R_ _*_) {m n : _} {M : Set m} {T : Setoid {m} {n} M} {_+_ : M → M → M} {G' : Group T _+_} (G : AbelianGroup G') (_·_ : A → M → M) where\n\nrecord VectorSpace : Set (lsuc a ⊔ b ⊔ m ⊔ n) where\n field\n isModule : Module R G _·_\n isField : Field R\n", "meta": {"hexsha": "ce1b0b4b9be3f7f5104169f562bf0bb68ebb0d44", "size": 667, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Vectors/VectorSpace.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Vectors/VectorSpace.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Vectors/VectorSpace.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 37.0555555556, "max_line_length": 258, "alphanum_fraction": 0.6311844078, "num_tokens": 240, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9553191309994468, "lm_q2_score": 0.665410572017153, "lm_q1q2_score": 0.6356794494172714}} {"text": "--------------------------------------------------------------------------------\n-- This is part of Agda Inference Systems\n\nopen import Data.Nat\nopen import Data.Fin\n\nmodule Examples.Lambda.Lambda where\n\n {- Terms & Values -}\n data Term (n : ℕ) : Set where\n var : Fin n → Term n\n lambda : Term (suc n) → Term n\n app : Term n → Term n → Term n\n\n data Value : Set where\n lambda : Term 1 → Value\n\n term : Value → Term 0\n term (lambda x) = lambda x\n\n {- Substitution -}\n ext : ∀{n m} → (Fin n → Fin m) → (Fin (suc n) → Fin (suc m))\n ext f zero = zero\n ext f (suc n) = suc (f n)\n\n rename : ∀{n m} → (Fin n → Fin m) → (Term n → Term m)\n rename f (var x) = var (f x)\n rename f (lambda t) = lambda (rename (ext f) t)\n rename f (app t t₁) = app (rename f t) (rename f t₁)\n\n exts : ∀{n m} → (Fin n → Term m) → (Fin (suc n) → Term (suc m))\n exts _ zero = var zero\n exts f (suc n) = rename suc (f n)\n\n subst : ∀{n m} → (Fin n → Term m) → (Term n → Term m)\n subst f (var x) = f x\n subst f (lambda t) = lambda (subst (exts f) t)\n subst f (app t t₁) = app (subst f t) (subst f t₁)\n\n subst-0 : ∀{n} → Term (suc n) → Term n → Term n\n subst-0 {n} t t₁ = subst {suc n}{n} f t where\n f : Fin (suc n) → Term n\n f zero = t₁\n f (suc n) = var n", "meta": {"hexsha": "5ebdb4891aeba5ea2d542daf61544891a560bb7c", "size": 1263, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Examples/Lambda/Lambda.agda", "max_stars_repo_name": "LcicC/inference-systems-agda", "max_stars_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2022-03-10T15:53:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-25T15:48:52.000Z", "max_issues_repo_path": "Examples/Lambda/Lambda.agda", "max_issues_repo_name": "LcicC/inference-systems-agda", "max_issues_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Examples/Lambda/Lambda.agda", "max_forks_repo_name": "LcicC/inference-systems-agda", "max_forks_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.7045454545, "max_line_length": 80, "alphanum_fraction": 0.5186064925, "num_tokens": 463, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9046505351008904, "lm_q2_score": 0.7025300636233415, "lm_q1q2_score": 0.6355441979813184}} {"text": "\nmodule Issue566 where\n\nopen import Common.Level using (Level; _⊔_)\n\ndata D (a : Level) (A : Set a) : Set a where\n d : D a A → D a A\n\nP-level : (a : Level) (A : Set a) → D a A → Level\nP-level a A (d x) = P-level a A x\n\nP : (a : Level) (A : Set a) (x : D a A) → Set (P-level a A x)\nP a A (d x) = P a A x\n\npostulate\n a : Level\n E : (b : Level) → Set b → Set a → Set (a ⊔ b)\n Q : (A : Set a) → D a A → Set a\n e : (A : Set a) (x : D a A) → E (P-level a A x) (P a A x) (Q A x)\n A : Set a\n x : D a A\n\nfoo : E (P-level a A x) (P a A x) (Q A x)\nfoo = e _ _\n\n-- Bug.agda:23,7-12\n-- P-level a A x ⊔ a != P-level a A x ⊔ a of type Level\n-- when checking that the expression e _ _ has type\n-- E (P-level a A x) (P a A x) (Q A x)\n", "meta": {"hexsha": "afb575e5ce7f1489d69133ea6ea677342ca3c986", "size": 717, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue566.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue566.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue566.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 23.9, "max_line_length": 66, "alphanum_fraction": 0.5216178522, "num_tokens": 307, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9046505325302034, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.6355441905410469}} {"text": "module DayConvolution where\n\nopen import Library\nopen import Functors\nopen import Categories\nopen import Categories.Sets\nopen import MonoidalCat\n\n-- first draft\n\nODay : ∀{l m}(M : Monoidal {l}{m})\n (F G : Fun (Monoidal.C M) (Sets {l})) ->\n Cat.Obj (Monoidal.C M) -> Set _\nODay M F G X =\n Σ Obj \\Y -> Σ Obj \\Z -> OMap F Y × OMap G Z × Hom X (OMap ⊗ (Y , Z))\n where open Monoidal M; open Cat C; open Fun\n\nHDay : ∀{l m}(M : Monoidal {l}{m})\n (F G : Fun (Monoidal.C M) (Sets {l})) -> ∀{X X'} ->\n Cat.Hom (Monoidal.C M) X X' -> ODay M F G X' -> ODay M F G X\nHDay M F G f (y , z , fy , gz , g) = y , z , fy , gz , comp g f\n where open Monoidal M; open Cat C\n\n\nDayF : ∀{l m}(M : Monoidal {l}{m})\n (F G : Fun (Monoidal.C M) (Sets {l})) -> Fun ((Monoidal.C M) Op) Sets\nDayF M F G = functor\n (ODay M F G)\n (HDay M F G)\n (\\ {X} -> ext (\\{ (y , z , fy , gz , g) ->\n cong (λ g → y , z , fy , gz , g) idr}))\n (\\ {X Y Z h k} -> ext (\\{ (y , z , fy , gz , g) ->\n cong (λ l → y , z , fy , gz , l) (sym ass)}))\n where open Monoidal M; open Cat C\n \n-- subject to some additional conditions\n-- forall h : y -> y'.\n-- (y , F h fy' , gz , g) ~ (y' , z , fy' , gz , [h,id] . g)\n--\n-- forall k : z -> z'\n-- (y , z , fy , G k gz' , g) ~ (y , z' , fy , gz' , [id,k] . g)\n\n", "meta": {"hexsha": "7d04a4b315fb2d870442155850497655edde7216", "size": 1295, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "DayConvolution.agda", "max_stars_repo_name": "jmchapman/Relative-Monads", "max_stars_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 21, "max_stars_repo_stars_event_min_datetime": "2015-07-30T01:25:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-13T18:02:18.000Z", "max_issues_repo_path": "DayConvolution.agda", "max_issues_repo_name": "jmchapman/Relative-Monads", "max_issues_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:12:33.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-29T09:50:26.000Z", "max_forks_repo_path": "DayConvolution.agda", "max_forks_repo_name": "jmchapman/Relative-Monads", "max_forks_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-04T21:33:13.000Z", "avg_line_length": 30.1162790698, "max_line_length": 76, "alphanum_fraction": 0.5019305019, "num_tokens": 508, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9046505402422645, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.6355441903247148}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule overloading.level where\n\nopen import sum\nopen import equality.core\nopen import overloading.bundle\nopen import function.isomorphism\nopen import hott.level.core\nopen import sets.unit\n\nopen Bundle\n\nbundle-structure-iso : ∀ {i j}{Base : Set i}\n (Struct : Base → Set j)\n → Σ Base Struct ≅ Bundle Struct\nbundle-structure-iso Struct = record\n { to = λ { (X , s) → bundle X s }\n ; from = λ { (bundle X s) → X , s }\n ; iso₁ = λ _ → refl\n ; iso₂ = λ _ → refl }\n\nbundle-equality-iso : ∀ {i j}{Base : Set i}\n (Struct : Base → Set j)\n → ((B : Base) → h 1 (Struct B))\n → {X Y : Bundle Struct}\n → (parent X ≡ parent Y)\n ≅ (X ≡ Y)\nbundle-equality-iso Struct hS {X}{Y} = begin\n parent X ≡ parent Y\n ≅⟨ sym≅ ×-right-unit ⟩\n ((parent X ≡ parent Y) × ⊤)\n ≅⟨ Σ-ap-iso refl≅ (λ p → sym≅ (contr-⊤-iso (hS _ _ _))) ⟩\n ( Σ (parent X ≡ parent Y) λ p\n → (subst Struct p (struct X) ≡ struct Y) )\n ≅⟨ Σ-split-iso ⟩\n (parent X , struct X) ≡ (parent Y , struct Y)\n ≅⟨ iso≡ (bundle-structure-iso Struct) ⟩\n X ≡ Y\n ∎\n where open ≅-Reasoning\n", "meta": {"hexsha": "4e8c8ccd60689a760b08caa6f5488900176ec756", "size": 1211, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "overloading/level.agda", "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_issues_repo_path": "src/overloading/level.agda", "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_forks_repo_path": "overloading/level.agda", "max_forks_repo_name": "HoTT/M-types", "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z", "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z", "avg_line_length": 28.8333333333, "max_line_length": 59, "alphanum_fraction": 0.5276630884, "num_tokens": 402, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.904650527388829, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.6355441869290769}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Algebra.Semigroup.Construct.Unit where\n\nopen import Cubical.Core.Everything\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Algebra.Semigroup\n\nopen import Cubical.Data.Unit\n\nimport Cubical.Algebra.Magma.Construct.Unit as ⊤Magma\nopen ⊤Magma public hiding (⊤-isMagma; ⊤-Magma)\n\n◯-assoc : Associative _◯_\n◯-assoc _ _ _ = refl\n\n\n⊤-isSemigroup : IsSemigroup ⊤ _◯_\n⊤-isSemigroup = record\n { isMagma = ⊤Magma.⊤-isMagma\n ; assoc = ◯-assoc\n }\n\n⊤-Semigroup : Semigroup ℓ-zero\n⊤-Semigroup = record { isSemigroup = ⊤-isSemigroup }\n", "meta": {"hexsha": "9c94f702c865784cfb9f63632738db493ea02c41", "size": 602, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Semigroup/Construct/Unit.agda", "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Semigroup/Construct/Unit.agda", "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Semigroup/Construct/Unit.agda", "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.08, "max_line_length": 53, "alphanum_fraction": 0.73089701, "num_tokens": 213, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9046505273888291, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.6355441812947901}} {"text": "{-# OPTIONS --prop --rewriting #-}\n\nopen import Examples.Sorting.Sequential.Comparable\n\nmodule Examples.Sorting.Sequential.MergeSort.Split (M : Comparable) where\n\nopen Comparable M\nopen import Examples.Sorting.Sequential.Core M\n\nopen import Calf costMonoid\nopen import Calf.Types.Nat\nopen import Calf.Types.List\nopen import Calf.Types.Bounded costMonoid\n\nopen import Relation.Binary.PropositionalEquality as Eq using (_≡_; refl)\nopen import Data.Product using (_×_; _,_; ∃; proj₁; proj₂)\nopen import Data.Nat as Nat using (ℕ; zero; suc; _+_; _*_; ⌊_/2⌋; ⌈_/2⌉)\nopen import Data.Nat.Properties as N using (module ≤-Reasoning)\n\n\npair = Σ++ (list A) λ _ → (list A)\n\nsplit/clocked : cmp (Π nat λ _ → Π (list A) λ _ → F pair)\nsplit/clocked zero l = ret ([] , l)\nsplit/clocked (suc k) [] = ret ([] , [])\nsplit/clocked (suc k) (x ∷ xs) = bind (F pair) (split/clocked k xs) λ (l₁ , l₂) → ret (x ∷ l₁ , l₂)\n\nsplit/clocked/correct : ∀ k k' l → k + k' ≡ length l →\n ◯ (∃ λ l₁ → ∃ λ l₂ → split/clocked k l ≡ ret (l₁ , l₂) × length l₁ ≡ k × length l₂ ≡ k' × l ↭ (l₁ ++ l₂))\nsplit/clocked/correct zero k' l refl u = [] , l , refl , refl , refl , refl\nsplit/clocked/correct (suc k) k' (x ∷ xs) h u =\n let (l₁ , l₂ , ≡ , h₁ , h₂ , ↭) = split/clocked/correct k k' xs (N.suc-injective h) u in\n x ∷ l₁ , l₂ , Eq.cong (λ e → bind (F pair) e _) ≡ , Eq.cong suc h₁ , h₂ , prep x ↭\n\nsplit/clocked/cost : cmp (Π nat λ _ → Π (list A) λ _ → cost)\nsplit/clocked/cost _ _ = zero\n\nsplit/clocked≤split/clocked/cost : ∀ k l → IsBounded pair (split/clocked k l) (split/clocked/cost k l)\nsplit/clocked≤split/clocked/cost zero l = bound/ret\nsplit/clocked≤split/clocked/cost (suc k) [] = bound/ret\nsplit/clocked≤split/clocked/cost (suc k) (x ∷ xs) = bound/bind/const zero zero (split/clocked≤split/clocked/cost k xs) λ _ → bound/ret\n\nsplit : cmp (Π (list A) λ _ → F pair)\nsplit l = split/clocked ⌊ length l /2⌋ l\n\nsplit/correct : ∀ l →\n ◯ (∃ λ l₁ → ∃ λ l₂ → split l ≡ ret (l₁ , l₂) × length l₁ ≡ ⌊ length l /2⌋ × length l₂ ≡ ⌈ length l /2⌉ × l ↭ (l₁ ++ l₂))\nsplit/correct l = split/clocked/correct ⌊ length l /2⌋ ⌈ length l /2⌉ l (N.⌊n/2⌋+⌈n/2⌉≡n (length l))\n\nsplit/cost : cmp (Π (list A) λ _ → cost)\nsplit/cost l = split/clocked/cost ⌊ length l /2⌋ l\n\nsplit≤split/cost : ∀ l → IsBounded pair (split l) (split/cost l)\nsplit≤split/cost l = split/clocked≤split/clocked/cost ⌊ length l /2⌋ l\n", "meta": {"hexsha": "8f8211edb358827a462fca09be4ab70b8810c7a0", "size": 2403, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Examples/Sorting/Sequential/MergeSort/Split.agda", "max_stars_repo_name": "jonsterling/agda-calf", "max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 29, "max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z", "max_issues_repo_path": "src/Examples/Sorting/Sequential/MergeSort/Split.agda", "max_issues_repo_name": "jonsterling/agda-calf", "max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Examples/Sorting/Sequential/MergeSort/Split.agda", "max_forks_repo_name": "jonsterling/agda-calf", "max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z", "avg_line_length": 43.6909090909, "max_line_length": 134, "alphanum_fraction": 0.6337910945, "num_tokens": 921, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8962513814471134, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.6354593781273254}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\nopen import Categories.Category.Monoidal.Core using (Monoidal)\n\nmodule Categories.Category.Monoidal.Rigid {o ℓ e} {C : Category o ℓ e} (M : Monoidal C) where\n\nopen import Level\n\nopen import Categories.Functor.Bifunctor\nopen import Categories.NaturalTransformation.NaturalIsomorphism\n\nopen Category C\nopen Commutation C\n\nprivate\n variable\n X : Obj\n\n-- left rigid monoidal category\nrecord LeftRigid : Set (levelOfTerm M) where\n open Monoidal M public\n\n field\n _⁻¹ : Obj → Obj\n η : ∀ {X} → unit ⇒ X ⊗₀ X ⁻¹\n ε : ∀ {X} → X ⁻¹ ⊗₀ X ⇒ unit\n\n snake₁ : [ X ⇒ X ]⟨\n unitorˡ.to ⇒⟨ (unit ⊗₀ X) ⟩\n (η ⊗₁ id) ⇒⟨ (X ⊗₀ X ⁻¹) ⊗₀ X ⟩\n associator.from ⇒⟨ X ⊗₀ (X ⁻¹ ⊗₀ X) ⟩\n (id ⊗₁ ε) ⇒⟨ X ⊗₀ unit ⟩\n unitorʳ.from\n ≈ id\n ⟩\n snake₂ : [ X ⁻¹ ⇒ X ⁻¹ ]⟨\n unitorʳ.to ⇒⟨ X ⁻¹ ⊗₀ unit ⟩\n (id ⊗₁ η) ⇒⟨ X ⁻¹ ⊗₀ (X ⊗₀ X ⁻¹) ⟩\n associator.to ⇒⟨ (X ⁻¹ ⊗₀ X) ⊗₀ X ⁻¹ ⟩\n (ε ⊗₁ id) ⇒⟨ unit ⊗₀ X ⁻¹ ⟩\n unitorˡ.from\n ≈ id\n ⟩\n\n-- right rigid monoidal category\nrecord RightRigid : Set (levelOfTerm M) where\n open Monoidal M public\n\n field\n _⁻¹ : Obj → Obj\n η : ∀ {X} → unit ⇒ X ⁻¹ ⊗₀ X\n ε : ∀ {X} → X ⊗₀ X ⁻¹ ⇒ unit\n\n snake₁ : [ X ⇒ X ]⟨\n unitorʳ.to ⇒⟨ (X ⊗₀ unit) ⟩\n (id ⊗₁ η) ⇒⟨ X ⊗₀ (X ⁻¹ ⊗₀ X) ⟩\n associator.to ⇒⟨ (X ⊗₀ X ⁻¹) ⊗₀ X ⟩\n (ε ⊗₁ id) ⇒⟨ unit ⊗₀ X ⟩\n unitorˡ.from\n ≈ id\n ⟩\n snake₂ : [ X ⁻¹ ⇒ X ⁻¹ ]⟨\n unitorˡ.to ⇒⟨ unit ⊗₀ X ⁻¹ ⟩\n (η ⊗₁ id) ⇒⟨ (X ⁻¹ ⊗₀ X) ⊗₀ X ⁻¹ ⟩\n associator.from ⇒⟨ X ⁻¹ ⊗₀ (X ⊗₀ X ⁻¹) ⟩\n (id ⊗₁ ε) ⇒⟨ X ⁻¹ ⊗₀ unit ⟩\n unitorʳ.from\n ≈ id\n ⟩\n", "meta": {"hexsha": "e551b0ac638c9a9cd1d993b075eb2f7e62360299", "size": 1940, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Monoidal/Rigid.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/Monoidal/Rigid.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/Monoidal/Rigid.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 27.323943662, "max_line_length": 93, "alphanum_fraction": 0.4448453608, "num_tokens": 785, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513648201267, "lm_q2_score": 0.709019146082187, "lm_q1q2_score": 0.6354593773597609}} {"text": "open import Prelude\nopen import dynamics-core\n\nmodule lemmas-ground where\n -- not ground types aren't just a type constructor filled with holes\n ground-not-holes : ∀{τ} →\n (τ ground → ⊥) →\n (τ ≠ (⦇-⦈ ==> ⦇-⦈)) × (τ ≠ (⦇-⦈ ⊕ ⦇-⦈)) × (τ ≠ (⦇-⦈ ⊠ ⦇-⦈))\n ground-not-holes notg = (λ{refl → notg GArrHole}) ,\n (λ{refl → notg GSumHole}) ,\n (λ{refl → notg GProdHole})\n\n -- not ground types either have to be hole, an arrow, or a sum\n not-ground : ∀{τ} →\n (τ ground → ⊥) →\n ((τ == ⦇-⦈) +\n (Σ[ τ1 ∈ htyp ] Σ[ τ2 ∈ htyp ] (τ == (τ1 ==> τ2))) + \n (Σ[ τ1 ∈ htyp ] Σ[ τ2 ∈ htyp ] (τ == (τ1 ⊕ τ2))) +\n (Σ[ τ1 ∈ htyp ] Σ[ τ2 ∈ htyp ] (τ == (τ1 ⊠ τ2))))\n not-ground {num} gnd = abort (gnd GNum)\n not-ground {⦇-⦈} gnd = Inl refl\n not-ground {τ ==> τ₁} gnd = Inr (Inl (τ , τ₁ , refl))\n not-ground {τ ⊕ τ₁} gnd = Inr (Inr (Inl (τ , τ₁ , refl)))\n not-ground {τ ⊠ τ₁} gnd = Inr (Inr (Inr (τ , τ₁ , refl)))\n", "meta": {"hexsha": "e97235933bd8f36e6e82d94ff21f389a272d9d8f", "size": 1052, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lemmas-ground.agda", "max_stars_repo_name": "hazelgrove/hazelnut-agda", "max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lemmas-ground.agda", "max_issues_repo_name": "hazelgrove/hazelnut-agda", "max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lemmas-ground.agda", "max_forks_repo_name": "hazelgrove/hazelnut-agda", "max_forks_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.08, "max_line_length": 80, "alphanum_fraction": 0.4439163498, "num_tokens": 432, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513759047847, "lm_q2_score": 0.7090191337850933, "lm_q1q2_score": 0.6354593741977085}} {"text": "module 100-natural where\n\nopen import 010-false-true\nopen import 020-equivalence\n\nrecord Natural\n {N : Set}\n (zero : N)\n (suc : N -> N)\n (_==_ : N -> N -> Set)\n : Set1 where\n\n -- axioms\n field\n equiv : Equivalence _==_\n sucn!=zero : ∀ {r} -> suc r == zero -> False\n sucinjective : ∀ {r s} -> suc r == suc s -> r == s\n cong : ∀ {r s} -> r == s -> suc r == suc s\n induction : (p : N -> Set) -> p zero -> (∀ n -> p n -> p (suc n)) -> (∀ n -> p n)\n\n open Equivalence equiv public\n", "meta": {"hexsha": "5cd1349b216d6f83e1ce26ac5874b4f8768495f9", "size": 499, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "100-natural.agda", "max_stars_repo_name": "mcmtroffaes/agda-proofs", "max_stars_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-08-09T22:51:55.000Z", "max_stars_repo_stars_event_max_datetime": "2016-08-17T16:15:42.000Z", "max_issues_repo_path": "100-natural.agda", "max_issues_repo_name": "mcmtroffaes/agda-proofs", "max_issues_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "100-natural.agda", "max_forks_repo_name": "mcmtroffaes/agda-proofs", "max_forks_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.6818181818, "max_line_length": 85, "alphanum_fraction": 0.5150300601, "num_tokens": 180, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9263037302939515, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.6353975449141541}} {"text": "\nmodule UniDB.Subst.Shifts where\n\nopen import UniDB.Subst.Core\nopen import UniDB.Morph.Shifts\n\nmodule _ {T : STX} {{vrT : Vr T}} {{apTT : Ap T T}} {{apVrT : ApVr T}} where\n\n instance\n iLkCompApShifts : LkCompAp T Shifts\n lk-⊙-ap {{iLkCompApShifts}} ξ₁ ξ₂ i = begin\n vr (lk (ξ₁ ⊙ ξ₂) i) ≡⟨ cong vr (shiftIx-⊙ ξ₁ ξ₂ i) ⟩\n vr (lk ξ₂ (lk ξ₁ i)) ≡⟨ sym (ap-vr {T} ξ₂ (lk ξ₁ i)) ⟩\n ap {T} ξ₂ (vr (lk ξ₁ i)) ∎\n", "meta": {"hexsha": "ad1d893482ddcf1faa1bf95d07bbf8c1898c3fef", "size": 433, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "UniDB/Subst/Shifts.agda", "max_stars_repo_name": "skeuchel/unidb-agda", "max_stars_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "UniDB/Subst/Shifts.agda", "max_issues_repo_name": "skeuchel/unidb-agda", "max_issues_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "UniDB/Subst/Shifts.agda", "max_forks_repo_name": "skeuchel/unidb-agda", "max_forks_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.8666666667, "max_line_length": 76, "alphanum_fraction": 0.5750577367, "num_tokens": 214, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9173026573249612, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.6353623200645083}} {"text": "-- TODO: Move these to stuff related to metric spaces\n\nmodule Continuity where\n open Limit\n\n -- Statement that the point x of function f is a continous point\n ContinuousPoint : (ℝ → ℝ) → ℝ → Stmt\n ContinuousPoint f(x) = (⦃ limit : Lim f(x) ⦄ → (lim f(x)⦃ limit ⦄ ≡ f(x)))\n\n -- Statement that the function f is continous\n Continuous : (ℝ → ℝ) → Stmt\n Continuous f = ∀{x} → ContinuousPoint f(x)\n\nmodule Proofs where\n -- instance postulate DifferentiablePoint-to-ContinuousPoint : ∀{f}{x}{diff} → ⦃ _ : DifferentiablePoint f(x)⦃ diff ⦄ ⦄ → ContinuousPoint f(x)\n -- instance postulate Differentiable-to-Continuous : ∀{f}{diff} → ⦃ _ : Differentiable(f)⦃ diff ⦄ ⦄ → Continuous(f)\n", "meta": {"hexsha": "b15c35006f86db1fb111bc81c19e99c4cfe51999", "size": 684, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Real/Continuity.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Real/Continuity.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Real/Continuity.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.2352941176, "max_line_length": 144, "alphanum_fraction": 0.6739766082, "num_tokens": 222, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9449947132556618, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.6353499012786212}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Rings.Definition\nopen import Rings.IntegralDomains.Definition\nopen import Fields.Fields\nopen import Setoids.Setoids\nopen import Sets.EquivalenceRelations\n\n\nmodule Fields.FieldOfFractions.Field {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} {_*_ : A → A → A} {R : Ring S _+_ _*_} (I : IntegralDomain R) where\n\nopen import Fields.FieldOfFractions.Ring I\n\nfieldOfFractions : Field fieldOfFractionsRing\nField.allInvertible fieldOfFractions (record { num = fst ; denom = b }) prA = (record { num = b ; denom = fst ; denomNonzero = ans }) , need\n where\n abstract\n open Setoid S\n open Equivalence eq\n need : ((b * fst) * Ring.1R R) ∼ ((fst * b) * Ring.1R R)\n need = Ring.*WellDefined R (Ring.*Commutative R) reflexive\n ans : fst ∼ Ring.0R R → False\n ans pr = prA need'\n where\n need' : (fst * Ring.1R R) ∼ (b * Ring.0R R)\n need' = transitive (Ring.*WellDefined R pr reflexive) (transitive (transitive (Ring.*Commutative R) (Ring.timesZero R)) (symmetric (Ring.timesZero R)))\nField.nontrivial fieldOfFractions pr = IntegralDomain.nontrivial I (symmetric (transitive (symmetric (Ring.timesZero R)) (transitive (Ring.*Commutative R) (transitive pr (Ring.identIsIdent R)))))\n where\n open Setoid S\n open Equivalence eq\n pr' : (Ring.0R R) * (Ring.1R R) ∼ (Ring.1R R) * (Ring.1R R)\n pr' = pr\n", "meta": {"hexsha": "3a6d1afebd50978c95846c1a9cbc9dcb03686d37", "size": 1457, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Fields/FieldOfFractions/Field.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Fields/FieldOfFractions/Field.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Fields/FieldOfFractions/Field.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 42.8529411765, "max_line_length": 195, "alphanum_fraction": 0.6643788607, "num_tokens": 459, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8840392756357327, "lm_q2_score": 0.7185943805178139, "lm_q1q2_score": 0.6352656556288763}} {"text": "{-\nThis second-order equational theory was created from the following second-order syntax description:\n\nsyntax Prod | P\n\ntype\n _⊗_ : 2-ary | l40\n\nterm\n pair : α β -> α ⊗ β | ⟨_,_⟩\n fst : α ⊗ β -> α\n snd : α ⊗ β -> β\n\ntheory\n (fβ) a : α b : β |> fst (pair(a, b)) = a\n (sβ) a : α b : β |> snd (pair(a, b)) = b\n (pη) p : α ⊗ β |> pair (fst(p), snd(p)) = p\n-}\n\nmodule Prod.Equality where\n\nopen import SOAS.Common\nopen import SOAS.Context\nopen import SOAS.Variable\nopen import SOAS.Families.Core\nopen import SOAS.Families.Build\nopen import SOAS.ContextMaps.Inductive\n\nopen import Prod.Signature\nopen import Prod.Syntax\n\nopen import SOAS.Metatheory.SecondOrder.Metasubstitution P:Syn\nopen import SOAS.Metatheory.SecondOrder.Equality P:Syn\n\nprivate\n variable\n α β γ τ : PT\n Γ Δ Π : Ctx\n\ninfix 1 _▹_⊢_≋ₐ_\n\n-- Axioms of equality\ndata _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ P) α Γ → (𝔐 ▷ P) α Γ → Set where\n fβ : ⁅ α ⁆ ⁅ β ⁆̣ ▹ ∅ ⊢ fst ⟨ 𝔞 , 𝔟 ⟩ ≋ₐ 𝔞\n sβ : ⁅ α ⁆ ⁅ β ⁆̣ ▹ ∅ ⊢ snd ⟨ 𝔞 , 𝔟 ⟩ ≋ₐ 𝔟\n pη : ⁅ α ⊗ β ⁆̣ ▹ ∅ ⊢ ⟨ fst 𝔞 , snd 𝔞 ⟩ ≋ₐ 𝔞\n\nopen EqLogic _▹_⊢_≋ₐ_\nopen ≋-Reasoning\n", "meta": {"hexsha": "e2289d09ff28bb952824e6f75fde77a6ca0bfa28", "size": 1111, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "out/Prod/Equality.agda", "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_issues_repo_path": "out/Prod/Equality.agda", "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_forks_repo_path": "out/Prod/Equality.agda", "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "avg_line_length": 22.22, "max_line_length": 99, "alphanum_fraction": 0.5904590459, "num_tokens": 501, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8652240756264639, "lm_q2_score": 0.7341195210831258, "lm_q1q2_score": 0.6351778840284898}} {"text": "module Sets.IterativeSet.Relator where\n\nimport Lvl\nopen import Logic.Propositional\nopen import Logic.Predicate\nopen import Numeral.Natural\nopen import Sets.IterativeSet\nopen import Syntax.Function\nopen import Type\n\nmodule _ where\n private variable {ℓ ℓ₁ ℓ₂} : Lvl.Level\n private variable {A B} : Iset{ℓ}\n open Iset\n\n _≡_ : (A : Iset{ℓ₁}) → (B : Iset{ℓ₂}) → Type{ℓ₁ Lvl.⊔ ℓ₂}\n record _⊆_ (A : Iset{ℓ₁}) (B : Iset{ℓ₂}) : Type{ℓ₁ Lvl.⊔ ℓ₂}\n _⊇_ : Iset{ℓ₁} → Iset{ℓ₂} → Type{ℓ₁ Lvl.⊔ ℓ₂}\n\n -- Set equality is by definition the antisymmetric property of the subset relation.\n _≡_ A B = (A ⊇ B) ∧ (A ⊆ B)\n\n -- Set membership is the existence of an index in the set that points to a set equal element to the element.\n _∈_ : Iset{ℓ₁} → Iset{ℓ₂} → Type{ℓ₁ Lvl.⊔ ℓ₂}\n a ∈ B = ∃{Obj = Index(B)} (ib ↦ a ≡ elem(B)(ib))\n\n -- Set subset is a mapping between the indices such that they point to the same element in both sets.\n record _⊆_ A B where\n constructor intro\n inductive\n eta-equality\n field\n map : Index(A) → Index(B)\n proof : ∀{ia} → (elem(A)(ia) ≡ elem(B)(map(ia)))\n\n A ⊇ B = B ⊆ A\n module _⊇_ where\n open _⊆_ public\n\n _∉_ : Iset{ℓ₁} → Iset{ℓ₂} → Type{ℓ₁ Lvl.⊔ ℓ₂}\n a ∉ B = ¬(a ∈ B)\n", "meta": {"hexsha": "f08f12a7a217f69bafee8b9bc66130f9a14e0008", "size": 1225, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Sets/IterativeSet/Relator.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Sets/IterativeSet/Relator.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Sets/IterativeSet/Relator.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.1666666667, "max_line_length": 110, "alphanum_fraction": 0.6334693878, "num_tokens": 497, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267796346599, "lm_q2_score": 0.7310585903489891, "lm_q1q2_score": 0.6351632807771663}} {"text": "------------------------------------------------------------------------------\n-- From inductive PA to Mendelson's axioms\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- From the definition of PA using Agda data types and primitive\n-- recursive functions for addition and multiplication, we can prove the\n-- Mendelson's axioms [1].\n\n-- N.B. We make the recursion in the first argument for _+_ and _*_.\n\n-- S₁. m = n → m = o → n = o\n-- S₂. m = n → succ m = succ n\n-- S₃. 0 ≠ succ n\n-- S₄. succ m = succ n → m = n\n-- S₅. 0 + n = n\n-- S₆. succ m + n = succ (m + n)\n-- S₇. 0 * n = 0\n-- S₈. succ m * n = (m * n) + m\n-- S₉. P(0) → (∀n.P(n) → P(succ n)) → ∀n.P(n), for any wf P(n) of PA.\n\n-- [1]. Elliott Mendelson. Introduction to mathematical\n-- logic. Chapman& Hall, 4th edition, 1997, p. 155.\n\nmodule PA.Inductive2Mendelson where\n\nopen import PA.Inductive.Base\n\n------------------------------------------------------------------------------\n\nS₁ : ∀ {m n o} → m ≡ n → m ≡ o → n ≡ o\nS₁ refl refl = refl\n\nS₂ : ∀ {m n} → m ≡ n → succ m ≡ succ n\nS₂ refl = refl\n\nS₃ : ∀ {n} → zero ≢ succ n\nS₃ ()\n\nS₄ : ∀ {m n} → succ m ≡ succ n → m ≡ n\nS₄ refl = refl\n\nS₅ : ∀ n → zero + n ≡ n\nS₅ n = refl\n\nS₆ : ∀ m n → succ m + n ≡ succ (m + n)\nS₆ m n = refl\n\nS₇ : ∀ n → zero * n ≡ zero\nS₇ n = refl\n\nS₈ : ∀ m n → succ m * n ≡ n + m * n\nS₈ m n = refl\n\nS₉ : (A : ℕ → Set) → A zero → (∀ n → A n → A (succ n)) → ∀ n → A n\nS₉ = ℕ-ind\n", "meta": {"hexsha": "80bb393bb51391da1c0be454e0e5595cfc30b299", "size": 1617, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/PA/Inductive2Mendelson.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/PA/Inductive2Mendelson.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/PA/Inductive2Mendelson.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 26.5081967213, "max_line_length": 78, "alphanum_fraction": 0.452690167, "num_tokens": 557, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267728417087, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.6351632656293538}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Relation.Binary.Construct.Constant where\n\nopen import Cubical.Core.Everything\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels using (hProp)\n\nopen import Cubical.Relation.Binary\nopen import Cubical.Structures.Carrier\n\n------------------------------------------------------------------------\n-- Definition\n\nConst : ∀ {a b ℓ} {A : Type a} {B : Type b} → hProp ℓ → REL A B ℓ\nConst I = λ _ _ → I\n\n------------------------------------------------------------------------\n-- Properties\n\nmodule _ {a c} {A : Type a} {C : hProp c} where\n\n reflexive : ⟨ C ⟩ → Reflexive {A = A} (Const C)\n reflexive c = c\n\n symmetric : Symmetric {A = A} (Const C)\n symmetric c = c\n\n transitive : Transitive {A = A} (Const C)\n transitive c d = c\n\n isPartialEquivalence : IsPartialEquivalence {A = A} (Const C)\n isPartialEquivalence = record\n { symmetric = λ {x} {y} → symmetric {x} {y}\n ; transitive = λ {x} {y} {z} → transitive {x} {y} {z}\n }\n\n partialEquivalence : PartialEquivalence A c\n partialEquivalence = record { isPartialEquivalence = isPartialEquivalence }\n\n isEquivalence : ⟨ C ⟩ → IsEquivalence {A = A} (Const C)\n isEquivalence c = record\n { isPartialEquivalence = isPartialEquivalence\n ; reflexive = λ {x} → reflexive c {x}\n }\n\n equivalence : ⟨ C ⟩ → Equivalence A c\n equivalence x = record { isEquivalence = isEquivalence x }\n", "meta": {"hexsha": "ccd09d0be12de25ce74c9a53a3ad10f49de0aaf1", "size": 1454, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Relation/Binary/Construct/Constant.agda", "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Relation/Binary/Construct/Constant.agda", "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Relation/Binary/Construct/Constant.agda", "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.2916666667, "max_line_length": 77, "alphanum_fraction": 0.6011004127, "num_tokens": 411, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267830311355, "lm_q2_score": 0.7310585669110203, "lm_q1q2_score": 0.6351632628966539}} {"text": "module LC.Subst.Term where \n\nopen import LC.Base \nopen import LC.Subst.Var \n\nopen import Data.Nat\nopen import Data.Nat.Properties\nopen import Relation.Nullary\n\n--------------------------------------------------------------------------------\n-- lifting terms\n\nlift : (n i : ℕ) → Term → Term\nlift n i (var x) = var (lift-var n i x)\nlift n i (ƛ M) = ƛ lift (suc n) i M\nlift n i (M ∙ N) = lift n i M ∙ lift n i N\n\n--------------------------------------------------------------------------------\n-- properties of lift\n\nopen import Relation.Binary.PropositionalEquality hiding ([_])\n\n-- lift l (n + i)\n-- ∙ --------------------------> ∙\n-- | |\n-- | |\n-- lift l (n + m + i) lift (l + n) m\n-- | |\n-- ∨ ∨ \n-- ∙ --------------------------> ∙\n-- \n\n\nlift-lemma : ∀ l m n i N → lift l (n + m + i) N ≡ lift (l + n) m (lift l (n + i) N)\nlift-lemma l m n i (var x) = cong var_ (LC.Subst.Var.lift-var-lemma l m n i x)\nlift-lemma l m n i (ƛ M) = cong ƛ_ (lift-lemma (suc l) m n i M)\nlift-lemma l m n i (M ∙ N) = cong₂ _∙_ (lift-lemma l m n i M) (lift-lemma l m n i N)\n\n-- lift (l + n) i\n-- ∙ --------------------------> ∙\n-- | |\n-- | |\n-- lift l m lift l m\n-- | |\n-- ∨ ∨ \n-- ∙ --------------------------> ∙\n-- lift (l + m + n) i\n\nlift-lift : ∀ l m n i N → lift l m (lift (l + n) i N) ≡ lift (l + m + n) i (lift l m N)\nlift-lift l m n i (var x) = cong var_ (lift-var-lift-var l m n i x)\nlift-lift l m n i (ƛ N) = cong ƛ_ (lift-lift (suc l) m n i N)\nlift-lift l m n i (M ∙ N) = cong₂ _∙_ (lift-lift l m n i M) (lift-lift l m n i N)\n\n\n--------------------------------------------------------------------------------\n-- substituting variables \n\ndata Match : ℕ → ℕ → Set where\n Under : ∀ {i x} → x < i → Match x i\n Exact : ∀ {i x} → x ≡ i → Match x i\n Above : ∀ {i} v → suc v > i → Match (suc v) i\n\nopen import Relation.Binary.Definitions\n\nmatch : (x i : ℕ) → Match x i\nmatch x i with <-cmp x i \nmatch x i | tri< a ¬b ¬c = Under a\nmatch x i | tri≈ ¬a b ¬c = Exact b\nmatch (suc x) i | tri> ¬a ¬b c = Above x c\n\nsubst-var : ∀ {x i} → Match x i → Term → Term \nsubst-var {x} (Under _) N = var x\nsubst-var {_} {i} (Exact _) N = lift 0 i N\nsubst-var (Above x _) N = var x\n\n--------------------------------------------------------------------------------\n-- properties of subst-var\n\nopen import Relation.Nullary.Negation using (contradiction)\nopen ≡-Reasoning\n\nsubst-var-match-< : ∀ {m n} N → (mn = contradiction m>n (<⇒≱ (≤-step mm = contradiction refl (<⇒≢ m>m)\n\nsubst-var-match-> : ∀ {m n} N → (1+m>n : suc m > n) → subst-var (match (suc m) n) N ≡ var m\nsubst-var-match-> {m} {n} N 1+mn = refl\n\n\n\n-- subst-var (match x m)\n-- ∙ -------------------------------------------------------> ∙\n-- | |\n-- | |\n-- lift n lift (m + n) \n-- | |\n-- ∨ ∨ \n-- ∙ --------------------------------------------------------> ∙\n-- subst-var (match (lift-var (suc (m + n)) i x) m)\n\nopen import Relation.Binary.PropositionalEquality hiding (preorder; [_]) \nopen ≡-Reasoning\n\nsubst-var-lift : ∀ m n i x N \n → subst-var (match (lift-var (suc (m + n)) i x) m) (lift n i N)\n ≡ lift (m + n) i (subst-var (match x m) N)\nsubst-var-lift m n i x N with match x m\n... | Under x prop1) ⟩ \n subst-var (match x m) (lift n i N)\n ≡⟨ subst-var-match-< (lift n i N) x prop2)) ⟩ \n lift (m + n) i (var x)\n ∎ \n where\n prop1 : suc (m + n) > x\n prop1 = ≤-trans x x\n prop2 = ≤-trans x prop) ⟩ \n subst-var (match m m) (lift n i N)\n ≡⟨ subst-var-match-≡ (lift n i N) refl ⟩ \n lift 0 m (lift n i N)\n ≡⟨ lift-lift 0 m n i N ⟩ \n lift (m + n) i (lift 0 m N)\n ∎ \n where \n prop : suc (m + n) > m\n prop = s≤s (m≤m+n m n)\n\n... | Above v m≤v with inspectBinding (suc m + n) (suc v)\n... | Free n≤x =\n begin \n subst-var (match (i + suc v) m) (lift n i N)\n ≡⟨ cong (λ w → subst-var (match w m) (lift n i N)) (+-suc i v) ⟩ \n subst-var (match (suc i + v) m) (lift n i N) \n ≡⟨ subst-var-match-> (lift n i N) prop ⟩ \n var (i + v) \n ≡⟨ cong var_ (sym (LC.Subst.Var.lift-var-≤ prop2)) ⟩ \n var (lift-var (m + n) i v)\n ∎ \n where \n prop : suc (i + v) > m\n prop = s≤s (≤-trans (≤-pred m≤v) (m≤n+m v i))\n\n prop2 : m + n ≤ v \n prop2 = ≤-pred n≤x\n... | Bound n>x =\n begin \n subst-var (match (suc v) m) (lift n i N)\n ≡⟨ subst-var-match-> {v} {m} (lift n i N) m≤v ⟩ \n var v\n ≡⟨ cong var_ (sym (LC.Subst.Var.lift-var-> {m + n} {i} {v} (≤-pred n>x))) ⟩ \n var (lift-var (m + n) i v)\n ∎\n\n", "meta": {"hexsha": "a3ab38b89a0473615773daa6c22acc237e55cea0", "size": 6333, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "LC/Subst/Term.agda", "max_stars_repo_name": "banacorn/bidirectional", "max_stars_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-08-25T07:34:40.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-25T14:05:01.000Z", "max_issues_repo_path": "LC/Subst/Term.agda", "max_issues_repo_name": "banacorn/bidirectional", "max_issues_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LC/Subst/Term.agda", "max_forks_repo_name": "banacorn/bidirectional", "max_forks_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.9829545455, "max_line_length": 92, "alphanum_fraction": 0.4054950261, "num_tokens": 2119, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267830311354, "lm_q2_score": 0.7310585669110202, "lm_q1q2_score": 0.6351632628966537}} {"text": "module Max where\n\nopen import Data.Empty using (⊥-elim)\nopen import Data.Fin\nopen import Data.Nat hiding (_≤_)\nopen import Function using (_∘_)\n\nopen import Relation.Nullary\n\nvariable\n n : ℕ\n\n-- from https://github.com/zmthy/recursive-types/tree/ftfjp16\n-- RecursiveTypes.Inductive.Type\n-- adapted to use \"variable\"\n\n\n-- A proposition that the indexed number is the largest it can be, i.e. one less\n-- than its exclusive upper bound.\ndata Max : Fin n → Set where\n max : Max {suc n} (fromℕ n)\n\n-- A lemma on Max: if a number is max, then one less than that number with a\n-- simultaneously lowered upper bound is also max.\nmax-pre : {x : Fin (suc n)} → Max (suc x) → Max x\nmax-pre max = max\n\n-- A lemma on Max: if a number is max, then one more than that number with a\n-- simultaneously increased upper bound is also max.\nmax-suc : {x : Fin n} → Max x → Max (suc x)\nmax-suc max = max\n\n-- Given a proof that a number is not max, reduce its lower bound by one,\n-- keeping the value of the number the same.\nreduce : {x : Fin (suc n)} → ¬ Max x → Fin n\nreduce {zero} {zero} ¬p = ⊥-elim (¬p max)\nreduce {zero} {suc ()} ¬p\nreduce {suc n} {zero} ¬p = zero\nreduce {suc n} {suc x} ¬p = suc (reduce {x = x} (¬p ∘ max-suc))\n\n-- Max is a decidable proposition: just compare the number value to the value of\n-- the upper bound.\nmax? : (x : Fin n) → Dec (Max x)\nmax? {zero} ()\nmax? {suc zero} zero = yes max\nmax? {suc zero} (suc ())\nmax? {suc (suc n)} zero = no (λ ())\nmax? {suc (suc n)} (suc x) with max? x\nmax? {suc (suc n)} (suc .(fromℕ n)) | yes max = yes max\nmax? {suc (suc n)} (suc x) | no ¬p = no (¬p ∘ max-pre)\n\n-- The reduce function preserves ≤.\nreduce₁ : ∀ {m} {x : Fin n} (¬p : ¬ Max (suc x))\n → m ≤ x → suc m ≤ inject₁ (reduce ¬p)\nreduce₁ {m = zero} ¬p₁ z≤n = s≤s z≤n\nreduce₁ {m = suc m} {zero} ¬p ()\nreduce₁ {m = suc m₁} {suc x₁} ¬p₁ (s≤s q₁) =\n s≤s (reduce₁ (λ z → ¬p₁ (max-suc z)) q₁)\n\n-- Injection is compatible with ordering.\ninject-≤ : {i j : Fin n} → inject₁ i ≤ inject₁ j → i ≤ j\ninject-≤ {i = 0F} {0F} z≤n = z≤n\ninject-≤ {i = 0F} {suc j} z≤n = z≤n\ninject-≤ {i = suc i} {0F} ()\ninject-≤ {i = suc i} {suc j} (s≤s ii≤ij) = s≤s (inject-≤ ii≤ij)\n\n-- Technical lemma about reduce.\nlemma-reduce : {i j : Fin (suc n)} →\n (i≤j : inject₁ i ≤ inject₁ j) → (¬p : ¬ Max j) → i ≤ inject₁ (reduce ¬p)\nlemma-reduce {i = 0F} i≤j ¬p = z≤n\nlemma-reduce {i = suc i} {suc j} (s≤s i≤j) ¬p = reduce₁ ¬p (inject-≤ i≤j)\n\n-- A lemma on ≤: if x ≤ y, then x ≤ suc y.\nsuc-≤ : {x y : Fin n} → x ≤ y → inject₁ x ≤ suc y\nsuc-≤ {x = zero} z≤n = z≤n\nsuc-≤ {x = suc x} {zero} ()\nsuc-≤ {x = suc x} {suc y} (s≤s p) = s≤s (suc-≤ p)\n\n\n-- A lemma on ≤: if suc x ≤ y, then x ≤ y.\npred-≤ : {x y : Fin n} → suc x ≤ inject₁ y → inject₁ x ≤ inject₁ y\npred-≤ {y = zero} ()\npred-≤ {y = suc x} (s≤s p) = suc-≤ p\n\n-- A lemma on ≤: if x ≤ y, then for any z < x, z ≤ y.\ntrans-< : {x y : Fin n} {z : Fin′ x} → x ≤ y → inject z ≤ y\ntrans-< {x = zero} {z = ()} p\ntrans-< {x = suc x} {zero} ()\ntrans-< {x = suc x} {suc y} {zero} (s≤s p) = z≤n\ntrans-< {x = suc x} {suc y} {suc z} (s≤s p) = s≤s (trans-< p)\n\n", "meta": {"hexsha": "56c9bfdd93e637d2cf534252f1bdec34a05cbfb0", "size": 3109, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Max.agda", "max_stars_repo_name": "kcaliban/dual-session", "max_stars_repo_head_hexsha": "cd41919582013e75463308c32750e2712cf2de86", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Max.agda", "max_issues_repo_name": "kcaliban/dual-session", "max_issues_repo_head_hexsha": "cd41919582013e75463308c32750e2712cf2de86", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Max.agda", "max_forks_repo_name": "kcaliban/dual-session", "max_forks_repo_head_hexsha": "cd41919582013e75463308c32750e2712cf2de86", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.7934782609, "max_line_length": 80, "alphanum_fraction": 0.5741395947, "num_tokens": 1280, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.86153820232079, "lm_q2_score": 0.7371581568543043, "lm_q1q2_score": 0.6350899132823643}} {"text": "\nmodule Data.Maybe where\n\ndata Maybe (a : Set) : Set where\n nothing : Maybe a\n just : a -> Maybe a\n\nfmap : {A B : Set} -> (A -> B) -> Maybe A -> Maybe B\nfmap f nothing = nothing\nfmap f (just a) = just (f a )\n\n", "meta": {"hexsha": "112f1e11017eb55cef4a4fa14893565c8ac31e9d", "size": 215, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/lib/Data/Maybe.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/lib/Data/Maybe.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/lib/Data/Maybe.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 17.9166666667, "max_line_length": 52, "alphanum_fraction": 0.5720930233, "num_tokens": 75, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8723473813156294, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.6350474816635058}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Bisimilarity for M-types\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe --sized-types #-}\n\nmodule Codata.M.Bisimilarity where\n\nopen import Level\nopen import Size\nopen import Codata.Thunk\nopen import Codata.M\nopen import Data.Container.Core\nopen import Data.Container.Relation.Binary.Pointwise using (Pointwise; _,_)\nopen import Data.Product using (_,_)\nopen import Function\nopen import Relation.Binary\nimport Relation.Binary.PropositionalEquality as P\n\ndata Bisim {s p} (C : Container s p) (i : Size) : Rel (M C ∞) (s ⊔ p) where\n inf : ∀ {t u} → Pointwise C (Thunk^R (Bisim C) i) t u → Bisim C i (inf t) (inf u)\n\nmodule _ {s p} {C : Container s p} where\n\n -- unfortunately the proofs are a lot nicer if we do not use the combinators\n -- C.refl, C.sym and C.trans\n\n refl : ∀ {i} → Reflexive (Bisim C i)\n refl {x = inf t} = inf (P.refl , λ where p .force → refl)\n\n sym : ∀ {i} → Symmetric (Bisim C i)\n sym (inf (P.refl , f)) = inf (P.refl , λ where p .force → sym (f p .force))\n\n trans : ∀ {i} → Transitive (Bisim C i)\n trans (inf (P.refl , f)) (inf (P.refl , g)) =\n inf (P.refl , λ where p .force → trans (f p .force) (g p .force))\n\n isEquivalence : ∀ {i} → IsEquivalence (Bisim C i)\n isEquivalence = record\n { refl = refl\n ; sym = sym\n ; trans = trans\n }\n\n setoid : {i : Size} → Setoid (s ⊔ p) (s ⊔ p)\n setoid {i} = record\n { isEquivalence = isEquivalence {i}\n }\n", "meta": {"hexsha": "5d82efa08f8cd51a430e95ad2eba41b1482e9ff8", "size": 1567, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Codata/M/Bisimilarity.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Codata/M/Bisimilarity.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Codata/M/Bisimilarity.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 30.7254901961, "max_line_length": 83, "alphanum_fraction": 0.5743458839, "num_tokens": 480, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473813156294, "lm_q2_score": 0.7279754489059774, "lm_q1q2_score": 0.6350474765151992}} {"text": "import Categories.2-Category\nimport Categories.2-Functor\nimport Categories.Adjoint\nimport Categories.Adjoint.Construction.EilenbergMoore\nimport Categories.Adjoint.Construction.Kleisli\nimport Categories.Adjoint.Equivalence\nimport Categories.Adjoint.Instance.0-Truncation\nimport Categories.Adjoint.Instance.01-Truncation\nimport Categories.Adjoint.Instance.Core\nimport Categories.Adjoint.Instance.Discrete\nimport Categories.Adjoint.Instance.PosetCore\nimport Categories.Adjoint.Instance.StrictCore\nimport Categories.Adjoint.Mate\nimport Categories.Adjoint.Properties\nimport Categories.Adjoint.RAPL\nimport Categories.Bicategory\nimport Categories.Bicategory.Bigroupoid\nimport Categories.Bicategory.Construction.1-Category\nimport Categories.Bicategory.Instance.Cats\nimport Categories.Bicategory.Instance.EnrichedCats\nimport Categories.Category\nimport Categories.Category.BicartesianClosed\nimport Categories.Category.Cartesian\nimport Categories.Category.Cartesian.Properties\nimport Categories.Category.CartesianClosed\nimport Categories.Category.CartesianClosed.Canonical\nimport Categories.Category.CartesianClosed.Locally\nimport Categories.Category.CartesianClosed.Locally.Properties\nimport Categories.Category.Closed\nimport Categories.Category.Cocartesian\nimport Categories.Category.Cocomplete\nimport Categories.Category.Cocomplete.Finitely\nimport Categories.Category.Complete\nimport Categories.Category.Complete.Finitely\nimport Categories.Category.Construction.0-Groupoid\nimport Categories.Category.Construction.Arrow\nimport Categories.Category.Construction.Cocones\nimport Categories.Category.Construction.Comma\nimport Categories.Category.Construction.Cones\nimport Categories.Category.Construction.Coproduct\nimport Categories.Category.Construction.Core\nimport Categories.Category.Construction.EilenbergMoore\nimport Categories.Category.Construction.Elements\nimport Categories.Category.Construction.EnrichedFunctors\nimport Categories.Category.Construction.F-Algebras\nimport Categories.Category.Construction.Fin\nimport Categories.Category.Construction.Functors\nimport Categories.Category.Construction.Graphs\nimport Categories.Category.Construction.Grothendieck\nimport Categories.Category.Construction.Kleisli\nimport Categories.Category.Construction.Path\nimport Categories.Category.Construction.Presheaves\nimport Categories.Category.Construction.Properties.Comma\nimport Categories.Category.Construction.Pullbacks\nimport Categories.Category.Construction.Thin\nimport Categories.Category.Core\nimport Categories.Category.Discrete\nimport Categories.Category.Equivalence\nimport Categories.Category.Finite\nimport Categories.Category.Groupoid\nimport Categories.Category.Groupoid.Properties\nimport Categories.Category.Indiscrete\nimport Categories.Category.Instance.Cats\nimport Categories.Category.Instance.EmptySet\nimport Categories.Category.Instance.FamilyOfSets\nimport Categories.Category.Instance.Globe\nimport Categories.Category.Instance.Groupoids\nimport Categories.Category.Instance.One\nimport Categories.Category.Instance.PointedSets\nimport Categories.Category.Instance.Posets\nimport Categories.Category.Instance.Properties.Cats\nimport Categories.Category.Instance.Properties.Posets\nimport Categories.Category.Instance.Properties.Setoids\nimport Categories.Category.Instance.Setoids\nimport Categories.Category.Instance.Sets\nimport Categories.Category.Instance.Simplex\nimport Categories.Category.Instance.SimplicialSet\nimport Categories.Category.Instance.SingletonSet\nimport Categories.Category.Instance.Span\nimport Categories.Category.Instance.StrictCats\nimport Categories.Category.Instance.StrictGroupoids\nimport Categories.Category.Instance.Zero\nimport Categories.Category.Monoidal\nimport Categories.Category.Monoidal.Braided\nimport Categories.Category.Monoidal.Braided.Properties\nimport Categories.Category.Monoidal.Closed\nimport Categories.Category.Monoidal.Closed.IsClosed\nimport Categories.Category.Monoidal.Closed.IsClosed.Diagonal\nimport Categories.Category.Monoidal.Closed.IsClosed.Dinatural\nimport Categories.Category.Monoidal.Closed.IsClosed.Identity\nimport Categories.Category.Monoidal.Closed.IsClosed.L\nimport Categories.Category.Monoidal.Closed.IsClosed.Pentagon\nimport Categories.Category.Monoidal.Construction.Minus2\nimport Categories.Category.Monoidal.Core\nimport Categories.Category.Monoidal.Instance.Cats\nimport Categories.Category.Monoidal.Instance.One\nimport Categories.Category.Monoidal.Instance.Setoids\nimport Categories.Category.Monoidal.Instance.Sets\nimport Categories.Category.Monoidal.Instance.StrictCats\nimport Categories.Category.Monoidal.Properties\nimport Categories.Category.Monoidal.Reasoning\nimport Categories.Category.Monoidal.Symmetric\nimport Categories.Category.Monoidal.Traced\nimport Categories.Category.Monoidal.Utilities\nimport Categories.Category.Product\nimport Categories.Category.Product.Properties\nimport Categories.Category.RigCategory\nimport Categories.Category.SetoidDiscrete\nimport Categories.Category.Site\nimport Categories.Category.Slice\nimport Categories.Category.Slice.Properties\nimport Categories.Category.SubCategory\nimport Categories.Category.Topos\nimport Categories.Category.WithFamilies\nimport Categories.Comonad\nimport Categories.Diagram.Cocone\nimport Categories.Diagram.Cocone.Properties\nimport Categories.Diagram.Coend\nimport Categories.Diagram.Coequalizer\nimport Categories.Diagram.Coequalizer.Properties\nimport Categories.Diagram.Colimit\nimport Categories.Diagram.Colimit.DualProperties\nimport Categories.Diagram.Colimit.Lan\nimport Categories.Diagram.Colimit.Properties\nimport Categories.Diagram.Cone\nimport Categories.Diagram.Cone.Properties\nimport Categories.Diagram.Duality\nimport Categories.Diagram.End\nimport Categories.Diagram.End.Properties\nimport Categories.Diagram.Equalizer\nimport Categories.Diagram.Finite\nimport Categories.Diagram.Limit\nimport Categories.Diagram.Limit.Properties\nimport Categories.Diagram.Limit.Ran\nimport Categories.Diagram.Pullback\nimport Categories.Diagram.Pullback.Limit\nimport Categories.Diagram.Pullback.Properties\nimport Categories.Diagram.Pushout\nimport Categories.Diagram.Pushout.Properties\nimport Categories.Diagram.SubobjectClassifier\nimport Categories.Enriched.Category\nimport Categories.Enriched.Functor\nimport Categories.Enriched.NaturalTransformation\nimport Categories.Enriched.NaturalTransformation.NaturalIsomorphism\nimport Categories.Enriched.Over.One\nimport Categories.Functor\nimport Categories.Functor.Algebra\nimport Categories.Functor.Bifunctor\nimport Categories.Functor.Bifunctor.Properties\nimport Categories.Functor.Coalgebra\nimport Categories.Functor.Cocontinuous\nimport Categories.Functor.Construction.Constant\nimport Categories.Functor.Construction.Diagonal\nimport Categories.Functor.Construction.LiftSetoids\nimport Categories.Functor.Construction.Limit\nimport Categories.Functor.Construction.Zero\nimport Categories.Functor.Continuous\nimport Categories.Functor.Core\nimport Categories.Functor.Equivalence\nimport Categories.Functor.Fibration\nimport Categories.Functor.Groupoid\nimport Categories.Functor.Hom\nimport Categories.Functor.Instance.0-Truncation\nimport Categories.Functor.Instance.01-Truncation\nimport Categories.Functor.Instance.Core\nimport Categories.Functor.Instance.Discrete\nimport Categories.Functor.Instance.SetoidDiscrete\nimport Categories.Functor.Instance.StrictCore\nimport Categories.Functor.Monoidal\nimport Categories.Functor.Power\nimport Categories.Functor.Power.Functorial\nimport Categories.Functor.Power.NaturalTransformation\nimport Categories.Functor.Presheaf\nimport Categories.Functor.Profunctor\nimport Categories.Functor.Properties\nimport Categories.Functor.Representable\nimport Categories.Functor.Slice\nimport Categories.GlobularSet\nimport Categories.Kan\nimport Categories.Kan.Duality\nimport Categories.Minus2-Category\nimport Categories.Minus2-Category.Construction.Indiscrete\nimport Categories.Minus2-Category.Instance.One\nimport Categories.Minus2-Category.Properties\nimport Categories.Monad\nimport Categories.Monad.Duality\nimport Categories.Monad.Idempotent\nimport Categories.Monad.Strong\nimport Categories.Morphism\nimport Categories.Morphism.Cartesian\nimport Categories.Morphism.Duality\nimport Categories.Morphism.HeterogeneousIdentity\nimport Categories.Morphism.HeterogeneousIdentity.Properties\nimport Categories.Morphism.IsoEquiv\nimport Categories.Morphism.Isomorphism\nimport Categories.Morphism.Properties\nimport Categories.Morphism.Reasoning\nimport Categories.Morphism.Reasoning.Core\nimport Categories.Morphism.Reasoning.Iso\nimport Categories.Morphism.Universal\nimport Categories.NaturalTransformation\nimport Categories.NaturalTransformation.Core\nimport Categories.NaturalTransformation.Dinatural\nimport Categories.NaturalTransformation.Equivalence\nimport Categories.NaturalTransformation.Hom\nimport Categories.NaturalTransformation.NaturalIsomorphism\nimport Categories.NaturalTransformation.NaturalIsomorphism.Equivalence\nimport Categories.NaturalTransformation.NaturalIsomorphism.Functors\nimport Categories.NaturalTransformation.NaturalIsomorphism.Properties\nimport Categories.NaturalTransformation.Properties\nimport Categories.Object.Coproduct\nimport Categories.Object.Duality\nimport Categories.Object.Exponential\nimport Categories.Object.Initial\nimport Categories.Object.Product\nimport Categories.Object.Product.Construction\nimport Categories.Object.Product.Core\nimport Categories.Object.Product.Morphisms\nimport Categories.Object.Terminal\nimport Categories.Object.Zero\nimport Categories.Pseudofunctor\nimport Categories.Pseudofunctor.Instance.EnrichedUnderlying\nimport Categories.Utils.EqReasoning\nimport Categories.Utils.Product\nimport Categories.Yoneda\nimport Categories.Yoneda.Properties\nimport Relation.Binary.Construct.Symmetrize\n", "meta": {"hexsha": "2f30f271df46533d1b5574e1c6bf8ac088408770", "size": 9671, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Everything.agda", "max_stars_repo_name": "Taneb/agda-categories", "max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Everything.agda", "max_issues_repo_name": "Taneb/agda-categories", "max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Everything.agda", "max_forks_repo_name": "Taneb/agda-categories", "max_forks_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.4166666667, "max_line_length": 70, "alphanum_fraction": 0.8912211767, "num_tokens": 1850, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.872347368040789, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.6350474719997479}} {"text": "{-\nThis second-order signature was created from the following second-order syntax description:\n\nsyntax CommMonoid | CM\n\ntype\n * : 0-ary\n\nterm\n unit : * | ε \n add : * * -> * | _⊕_ l20\n\ntheory\n (εU⊕ᴸ) a |> add (unit, a) = a\n (εU⊕ᴿ) a |> add (a, unit) = a\n (⊕A) a b c |> add (add(a, b), c) = add (a, add(b, c))\n (⊕C) a b |> add(a, b) = add(b, a)\n-}\n\nmodule CommMonoid.Signature where\n\nopen import SOAS.Context\n\nopen import SOAS.Common\n\n\nopen import SOAS.Syntax.Signature *T public\nopen import SOAS.Syntax.Build *T public\n\n-- Operator symbols\ndata CMₒ : Set where\n unitₒ addₒ : CMₒ\n\n-- Term signature\nCM:Sig : Signature CMₒ\nCM:Sig = sig λ\n { unitₒ → ⟼₀ *\n ; addₒ → (⊢₀ *) , (⊢₀ *) ⟼₂ *\n }\n\nopen Signature CM:Sig public\n", "meta": {"hexsha": "dfb4b5a097619506a081a43efa0942a44795b63e", "size": 735, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "out/CommMonoid/Signature.agda", "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_issues_repo_path": "out/CommMonoid/Signature.agda", "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_forks_repo_path": "out/CommMonoid/Signature.agda", "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "avg_line_length": 17.5, "max_line_length": 91, "alphanum_fraction": 0.6054421769, "num_tokens": 292, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8723473713594992, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.6350474641190743}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Data.List.Properties where\n\nopen import Data.List\nopen import Prelude\nopen import Data.Fin\n\nmap-length : (f : A → B) (xs : List A)\n → length xs ≡ length (map f xs)\nmap-length f [] _ = zero\nmap-length f (x ∷ xs) i = suc (map-length f xs i)\n\nmap-ind : (f : A → B) (xs : List A)\n → PathP (λ i → Fin (map-length f xs i) → B) (f ∘ (xs !_)) (map f xs !_)\nmap-ind f [] i ()\nmap-ind f (x ∷ xs) i f0 = f x\nmap-ind f (x ∷ xs) i (fs n) = map-ind f xs i n\n\ntab-length : ∀ n (f : Fin n → A) → length (tabulate n f) ≡ n\ntab-length zero f _ = zero\ntab-length (suc n) f i = suc (tab-length n (f ∘ fs) i)\n\ntab-distrib : ∀ n (f : Fin n → A) m → ∃[ i ] (f i ≡ tabulate n f ! m)\ntab-distrib (suc n) f f0 = f0 , refl\ntab-distrib (suc n) f (fs m) = let i , p = tab-distrib n (f ∘ fs) m in fs i , p\n\ntab-id : ∀ n (f : Fin n → A) → PathP (λ i → Fin (tab-length n f i) → A) (_!_ (tabulate n f)) f\ntab-id zero f _ ()\ntab-id (suc n) f i f0 = f f0\ntab-id (suc n) f i (fs m) = tab-id n (f ∘ fs) i m\n", "meta": {"hexsha": "4879349f46567772261e9baa0b2a333da0aaec7e", "size": 1028, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Data/List/Properties.agda", "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z", "max_issues_repo_path": "agda/Data/List/Properties.agda", "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Data/List/Properties.agda", "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "avg_line_length": 32.125, "max_line_length": 94, "alphanum_fraction": 0.5496108949, "num_tokens": 410, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473614033682, "lm_q2_score": 0.7279754489059774, "lm_q1q2_score": 0.6350474620195619}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Category.Lift where\n\nopen import Level\nopen import Categories.Category\n\nliftC : ∀ {o ℓ e} o′ ℓ′ e′ → Category o ℓ e → Category (o ⊔ o′) (ℓ ⊔ ℓ′) (e ⊔ e′)\nliftC o′ ℓ′ e′ C = record\n { Obj = Lift o′ Obj\n ; _⇒_ = λ X Y → Lift ℓ′ (lower X ⇒ lower Y)\n ; _≈_ = λ f g → Lift e′ (lower f ≈ lower g)\n ; id = lift id\n ; _∘_ = λ f g → lift (lower f ∘ lower g)\n ; assoc = lift assoc\n ; sym-assoc = lift sym-assoc\n ; identityˡ = lift identityˡ\n ; identityʳ = lift identityʳ\n ; identity² = lift identity²\n ; equiv = record\n { refl = lift Equiv.refl\n ; sym = λ eq → lift (Equiv.sym (lower eq))\n ; trans = λ eq eq′ → lift (Equiv.trans (lower eq) (lower eq′))\n }\n ; ∘-resp-≈ = λ eq eq′ → lift (∘-resp-≈ (lower eq) (lower eq′))\n }\n where open Category C\n", "meta": {"hexsha": "12710ad22d035df3dd0a1ffb83216335fb494499", "size": 859, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Lift.agda", "max_stars_repo_name": "laMudri/agda-categories", "max_stars_repo_head_hexsha": "5a49c6ac87cbb7e20511c28f28205163fe69f48f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Category/Lift.agda", "max_issues_repo_name": "laMudri/agda-categories", "max_issues_repo_head_hexsha": "5a49c6ac87cbb7e20511c28f28205163fe69f48f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Lift.agda", "max_forks_repo_name": "laMudri/agda-categories", "max_forks_repo_head_hexsha": "5a49c6ac87cbb7e20511c28f28205163fe69f48f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.6785714286, "max_line_length": 81, "alphanum_fraction": 0.5471478463, "num_tokens": 323, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9124361652391386, "lm_q2_score": 0.695958331339634, "lm_q1q2_score": 0.6350175510137654}} {"text": "-- examples for termination with tupled arguments\n\nmodule Tuple where\n\ndata Nat : Set where\n zero : Nat\n succ : Nat -> Nat\n\ndata Pair (A : Set) (B : Set) : Set where\n pair : A -> B -> Pair A B\n\n-- uncurried addition\nadd : Pair Nat Nat -> Nat\nadd (pair x (succ y)) = succ (add (pair x y))\nadd (pair x zero) = x\n\n\ndata T (A : Set) (B : Set) : Set where\n c1 : A -> B -> T A B\n c2 : A -> B -> T A B\n\n{-\n-- constructor names do not matter\nadd' : T Nat Nat -> Nat\nadd' (c1 x (succ y)) = succ (add' (c2 x y))\nadd' (c2 x (succ y)) = succ (add' (c1 x y))\nadd' (c1 x zero) = x\nadd' (c2 x zero) = x\n\n-- additionally: permutation of arguments\nadd'' : T Nat Nat -> Nat\nadd'' (c1 x (succ y)) = succ (add'' (c2 y x))\nadd'' (c2 (succ y) x) = succ (add'' (c1 x y))\nadd'' (c1 x zero) = x\nadd'' (c2 zero x) = x\n-}\n", "meta": {"hexsha": "e10eb6db6f9abbd0f5b90e5a2382639439f6f22a", "size": 806, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/Termination/Tuple.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/Termination/Tuple.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/Termination/Tuple.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 21.7837837838, "max_line_length": 49, "alphanum_fraction": 0.5595533499, "num_tokens": 304, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9124361509525462, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.6350175353169045}} {"text": "{-# OPTIONS --cubical #-}\n\nopen import Cubical.Core.Glue\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Univalence\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Empty\nopen import Cubical.Data.Unit\nopen import Cubical.Data.Prod\nopen import Cubical.Data.BinNat\nopen import Cubical.Data.Bool\nopen import Cubical.Relation.Nullary\nopen import Direction\n\nmodule NNat where\n-- much of this is based directly on the\n-- BinNat module in the Cubical Agda library\n\ndata BNat : Type₀ where\n b0 : BNat\n b1 : BNat\n x0 : BNat → BNat\n x1 : BNat → BNat\n\nsucBNat : BNat → BNat\nsucBNat b0 = b1\nsucBNat b1 = x0 b1\nsucBNat (x0 bs) = x1 bs\nsucBNat (x1 bs) = x0 (sucBNat bs)\n\nBNat→ℕ : BNat → ℕ\nBNat→ℕ b0 = 0\nBNat→ℕ b1 = 1\nBNat→ℕ (x0 x) = doubleℕ (BNat→ℕ x)\nBNat→ℕ (x1 x) = suc (doubleℕ (BNat→ℕ x))\n\n-- BNat→Binℕ : BNat → Binℕ\n-- BNat→Binℕ pos0 = binℕ0\n-- BNat→Binℕ pos1 = binℕpos pos1\n-- BNat→Binℕ (x0 x) = {!binℕpos (x0 binℕpos (BNat→Binℕ x))!}\n-- BNat→Binℕ (x1 x) = {!!}\n\nBNat→ℕsucBNat : (b : BNat) → BNat→ℕ (sucBNat b) ≡ suc (BNat→ℕ b)\nBNat→ℕsucBNat b0 = refl\nBNat→ℕsucBNat b1 = refl\nBNat→ℕsucBNat (x0 b) = refl\nBNat→ℕsucBNat (x1 b) = λ i → doubleℕ (BNat→ℕsucBNat b i)\n\nℕ→BNat : ℕ → BNat\nℕ→BNat zero = b0\nℕ→BNat (suc zero) = b1\nℕ→BNat (suc (suc n)) = sucBNat (ℕ→BNat (suc n))\n\nℕ→BNatSuc : ∀ n → ℕ→BNat (suc n) ≡ sucBNat (ℕ→BNat n)\nℕ→BNatSuc zero = refl\nℕ→BNatSuc (suc n) = refl\n\nbNatInd : {P : BNat → Type₀} → P b0 → ((b : BNat) → P b → P (sucBNat b)) → (b : BNat) → P b\n-- prove later...\n\nBNat→ℕ→BNat : (b : BNat) → ℕ→BNat (BNat→ℕ b) ≡ b\nBNat→ℕ→BNat b = bNatInd refl hs b\n where\n hs : (b : BNat) → ℕ→BNat (BNat→ℕ b) ≡ b → ℕ→BNat (BNat→ℕ (sucBNat b)) ≡ sucBNat b\n hs b hb = \n ℕ→BNat (BNat→ℕ (sucBNat b))\n ≡⟨ cong ℕ→BNat (BNat→ℕsucBNat b) ⟩ \n ℕ→BNat (suc (BNat→ℕ b))\n ≡⟨ ℕ→BNatSuc (BNat→ℕ b) ⟩ \n sucBNat (ℕ→BNat (BNat→ℕ b))\n ≡⟨ cong sucBNat hb ⟩ \n sucBNat b\n ∎\n\nℕ→BNat→ℕ : (n : ℕ) → BNat→ℕ (ℕ→BNat n) ≡ n\nℕ→BNat→ℕ zero = refl\nℕ→BNat→ℕ (suc n) = \n BNat→ℕ (ℕ→BNat (suc n))\n ≡⟨ cong BNat→ℕ (ℕ→BNatSuc n) ⟩ \n BNat→ℕ (sucBNat (ℕ→BNat n))\n ≡⟨ BNat→ℕsucBNat (ℕ→BNat n) ⟩ \n suc (BNat→ℕ (ℕ→BNat n))\n ≡⟨ cong suc (ℕ→BNat→ℕ n) ⟩ \n suc n\n ∎\n\nBNat≃ℕ : BNat ≃ ℕ\nBNat≃ℕ = isoToEquiv (iso BNat→ℕ ℕ→BNat ℕ→BNat→ℕ BNat→ℕ→BNat)\n\nBNat≡ℕ : BNat ≡ ℕ\nBNat≡ℕ = ua BNat≃ℕ\n\nopen NatImpl\n\nNatImplBNat : NatImpl BNat\nz NatImplBNat = b0\ns NatImplBNat = sucBNat\n\n--\n\ndata np (r : ℕ) : Type₀ where\n bp : DirNum r → np r\n zp : ∀ (d d′ : DirNum r) → bp d ≡ bp d′\n xp : DirNum r → np r → np r\n\nsucnp : ∀ {r} → np r → np r\nsucnp {zero} (bp tt) = xp tt (bp tt)\nsucnp {zero} (zp tt tt i) = xp tt (bp tt)\nsucnp {zero} (xp tt n) = xp tt (sucnp n)\nsucnp {suc r} (bp d) = xp (one-n (suc r)) (bp d)\nsucnp {suc r} (zp d d′ i) = xp (one-n (suc r)) (zp d d′ i)\nsucnp {suc r} (xp d n) with max? d\n... | no _ = xp (next d) n \n... | yes _ = xp (zero-n (suc r)) (sucnp n)\n\nnp→ℕ : (r : ℕ) (x : np r) → ℕ\nnp→ℕ r (bp x) = 0\nnp→ℕ r (zp d d′ i) = 0\nnp→ℕ zero (xp x x₁) = suc (np→ℕ zero x₁)\nnp→ℕ (suc r) (xp x x₁) = sucn (DirNum→ℕ x) (doublesℕ (suc r) (np→ℕ (suc r) x₁))\n\nℕ→np : (r : ℕ) → (n : ℕ) → np r\nℕ→np r zero = bp (zero-n r)\nℕ→np zero (suc n) = xp tt (ℕ→np zero n)\nℕ→np (suc r) (suc n) = sucnp (ℕ→np (suc r) n)\n\n\n\n---- generalize bnat:\n\ndata N (r : ℕ) : Type₀ where\n bn : DirNum r → N r\n xr : DirNum r → N r → N r\n\n\n-- should define induction principle for N r\n \n-- we have 2ⁿ \"unary\" constructors, analogous to BNat with 2¹ (b0 and b1)\n-- rename n to r\n-- this likely introduces inefficiencies compared\n-- to BinNat, with the max? check etc.\nsucN : ∀ {n} → N n → N n\nsucN {zero} (bn tt) = xr tt (bn tt)\nsucN {zero} (xr tt x) = xr tt (sucN x)\nsucN {suc n} (bn (↓ , ds)) = (bn (↑ , ds))\nsucN {suc n} (bn (↑ , ds)) with max? ds\n... | no _ = (bn (↓ , next ds))\n... | yes _ = xr (zero-n (suc n)) (bn (one-n (suc n)))\nsucN {suc n} (xr d x) with max? d\n... | no _ = xr (next d) x\n... | yes _ = xr (zero-n (suc n)) (sucN x)\n\nsucnN : {r : ℕ} → (n : ℕ) → (N r → N r)\nsucnN n = iter n sucN\n\ndoubleN : (r : ℕ) → N r → N r\ndoubleN zero (bn tt) = bn tt\ndoubleN zero (xr d x) = sucN (sucN (doubleN zero x))\ndoubleN (suc r) (bn x) with zero-n? x\n... | yes _ = bn x\n -- bad:\n... | no _ = caseBool (bn (doubleDirNum (suc r) x)) (xr (zero-n (suc r)) (bn x)) (doubleable-n? x)\n-- ... | no _ | doubleable = {!bn (doubleDirNum x)!}\n-- ... | no _ | notdoubleable = xr (zero-n (suc r)) (bn x)\ndoubleN (suc r) (xr x x₁) = sucN (sucN (doubleN (suc r) x₁))\n\ndoublesN : (r : ℕ) → ℕ → N r → N r\ndoublesN r zero m = m\ndoublesN r (suc n) m = doublesN r n (doubleN r m)\n\nN→ℕ : (r : ℕ) (x : N r) → ℕ\nN→ℕ zero (bn tt) = zero\nN→ℕ zero (xr tt x) = suc (N→ℕ zero x)\nN→ℕ (suc r) (bn x) = DirNum→ℕ x\nN→ℕ (suc r) (xr d x) = sucn (DirNum→ℕ d) (doublesℕ (suc r) (N→ℕ (suc r) x))\n\nN→ℕsucN : (r : ℕ) (x : N r) → N→ℕ r (sucN x) ≡ suc (N→ℕ r x)\nN→ℕsucN zero (bn tt) = refl\nN→ℕsucN zero (xr tt x) = \n suc (N→ℕ zero (sucN x))\n ≡⟨ cong suc (N→ℕsucN zero x) ⟩ \n suc (suc (N→ℕ zero x))\n ∎\nN→ℕsucN (suc r) (bn (↓ , d)) = refl\nN→ℕsucN (suc r) (bn (↑ , d)) with max? d\n... | no d≠max = \n doubleℕ (DirNum→ℕ (next d))\n ≡⟨ cong doubleℕ (next≡suc r d d≠max) ⟩ \n doubleℕ (suc (DirNum→ℕ d))\n ∎\n... | yes d≡max = -- this can probably be shortened by not reducing down to zero\n sucn (doubleℕ (DirNum→ℕ (zero-n r)))\n (doublesℕ r (suc (suc (doubleℕ (doubleℕ (DirNum→ℕ (zero-n r)))))))\n ≡⟨ cong (λ x → sucn (doubleℕ x) (doublesℕ r (suc (suc (doubleℕ (doubleℕ x)))))) (zero-n→0 {r}) ⟩ \n sucn (doubleℕ zero) (doublesℕ r (suc (suc (doubleℕ (doubleℕ zero)))))\n ≡⟨ refl ⟩\n doublesℕ (suc r) (suc zero) -- 2^(r+1)\n ≡⟨ sym (doubleDoubles r 1) ⟩\n doubleℕ (doublesℕ r (suc zero)) --2*2^r\n ≡⟨ sym (sucPred (doubleℕ (doublesℕ r (suc zero))) (doubleDoublesOne≠0 r)) ⟩\n suc (predℕ (doubleℕ (doublesℕ r (suc zero))))\n ≡⟨ cong suc (sym (sucPred (predℕ (doubleℕ (doublesℕ r (suc zero)))) (predDoubleDoublesOne≠0 r))) ⟩\n suc (suc (predℕ (predℕ (doubleℕ (doublesℕ r (suc zero))))))\n ≡⟨ cong (λ x → suc (suc x)) (sym (doublePred (doublesℕ r (suc zero)))) ⟩\n suc (suc (doubleℕ (predℕ (doublesℕ r (suc zero)))))\n ≡⟨ cong (λ x → suc (suc (doubleℕ x))) (sym (maxr≡pred2ʳ r d d≡max)) ⟩\n suc (suc (doubleℕ (DirNum→ℕ d))) -- 2*(2^r - 1) + 2 = 2^(r+1) - 2 + 2 = 2^(r+1)\n ∎\nN→ℕsucN (suc r) (xr (↓ , d) x) = refl\nN→ℕsucN (suc r) (xr (↑ , d) x) with max? d\n... | no d≠max = \n sucn (doubleℕ (DirNum→ℕ (next d)))\n (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))\n ≡⟨ cong (λ y → sucn (doubleℕ y) (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))) (next≡suc r d d≠max) ⟩ \n sucn (doubleℕ (suc (DirNum→ℕ d)))\n (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))\n ≡⟨ refl ⟩ \n suc\n (suc\n (iter (doubleℕ (DirNum→ℕ d)) suc\n (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))))\n ∎\n... | yes d≡max = \n sucn (doubleℕ (DirNum→ℕ (zero-n r)))\n (doublesℕ r (doubleℕ (N→ℕ (suc r) (sucN x))))\n ≡⟨ cong (λ z → sucn (doubleℕ z) (doublesℕ r (doubleℕ (N→ℕ (suc r) (sucN x))))) (zero-n≡0 {r}) ⟩ \n sucn (doubleℕ zero)\n (doublesℕ r (doubleℕ (N→ℕ (suc r) (sucN x))))\n ≡⟨ refl ⟩ \n doublesℕ r (doubleℕ (N→ℕ (suc r) (sucN x)))\n ≡⟨ cong (λ x → doublesℕ r (doubleℕ x)) (N→ℕsucN (suc r) x) ⟩ \n doublesℕ r (doubleℕ (suc (N→ℕ (suc r) x)))\n ≡⟨ refl ⟩ \n doublesℕ r (suc (suc (doubleℕ (N→ℕ (suc r) x)))) -- 2^r * (2x + 2) = 2^(r+1)x + 2^(r+1)\n ≡⟨ doublesSucSuc r (doubleℕ (N→ℕ (suc r) x)) ⟩ \n sucn (doublesℕ (suc r) 1) -- _ + 2^(r+1)\n (doublesℕ (suc r) (N→ℕ (suc r) x)) -- 2^(r+1)x + 2^(r+1)\n ≡⟨ H r (doublesℕ (suc r) (N→ℕ (suc r) x)) ⟩\n suc\n (suc\n (sucn (doubleℕ (predℕ (doublesℕ r 1))) -- _ + 2(2^r - 1) + 2\n (doublesℕ (suc r) (N→ℕ (suc r) x))))\n ≡⟨ refl ⟩\n suc\n (suc\n (sucn (doubleℕ (predℕ (doublesℕ r 1)))\n (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))))\n ≡⟨ cong (λ z → suc (suc (sucn (doubleℕ z) (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))))) (sym (max→ℕ r)) ⟩\n suc\n (suc\n (sucn (doubleℕ (DirNum→ℕ (max-n r)))\n (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))))\n ≡⟨ cong (λ z → suc (suc (sucn (doubleℕ (DirNum→ℕ z)) (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))))) (sym (d≡max)) ⟩\n suc\n (suc\n (sucn (doubleℕ (DirNum→ℕ d))\n (doublesℕ r (doubleℕ (N→ℕ (suc r) x))))) -- (2^r*2x + (2*(2^r - 1))) + 2 = 2^(r+1)x + 2^(r+1)\n ∎\n where\n H : (n m : ℕ) → sucn (doublesℕ (suc n) 1) m ≡ suc (suc (sucn (doubleℕ (predℕ (doublesℕ n 1))) m))\n H zero m = refl\n H (suc n) m = \n sucn (doublesℕ n 4) m\n ≡⟨ cong (λ z → sucn z m) (doublesSucSuc n 2) ⟩ \n sucn (sucn (doublesℕ (suc n) 1) (doublesℕ n 2)) m\n ≡⟨ refl ⟩ \n sucn (sucn (doublesℕ n 2) (doublesℕ n 2)) m\n ≡⟨ {!!} ⟩ \n sucn (doubleℕ (doublesℕ n 2)) m\n ≡⟨ {!!} ⟩ {!!}\n\n\n\n\n\n\n\nℕ→N : (r : ℕ) → (n : ℕ) → N r\nℕ→N r zero = bn (zero-n r)\nℕ→N zero (suc n) = xr tt (ℕ→N zero n)\nℕ→N (suc r) (suc n) = sucN (ℕ→N (suc r) n)\n\nℕ→Nsuc : (r : ℕ) (n : ℕ) → ℕ→N r (suc n) ≡ sucN (ℕ→N r n)\nℕ→Nsuc r n = {!!}\n\nℕ→Nsucn : (r : ℕ) (n m : ℕ) → ℕ→N r (sucn n m) ≡ sucnN n (ℕ→N r m)\nℕ→Nsucn r n m = {!!}\n\n-- NℕNlemma is actually a pretty important fact;\n-- this is what allows the direct isomorphism of N and ℕ to go\n-- without the need for an extra datatype, e.g. Pos for BinNat,\n-- since each ℕ < 2^r maps to its \"numeral\" in N r.\n-- should rename and move elsewhere.\nnumeral-next : (r : ℕ) (d : DirNum r) → N (suc r)\nnumeral-next r d = bn (embed-next r d)\n\n\n-- \nNℕNlemma : (r : ℕ) (d : DirNum r) → ℕ→N r (DirNum→ℕ d) ≡ bn d\nNℕNlemma zero tt = refl\nNℕNlemma (suc r) (↓ , ds) = \n ℕ→N (suc r) (doubleℕ (DirNum→ℕ ds))\n ≡⟨ {!!} ⟩ {!!}\nNℕNlemma (suc r) (↑ , ds) = {!!}\n\nN→ℕ→N : (r : ℕ) → (x : N r) → ℕ→N r (N→ℕ r x) ≡ x\nN→ℕ→N zero (bn tt) = refl\nN→ℕ→N zero (xr tt x) = cong (xr tt) (N→ℕ→N zero x)\nN→ℕ→N (suc r) (bn (↓ , ds)) = \n ℕ→N (suc r) (doubleℕ (DirNum→ℕ ds))\n ≡⟨ cong (λ x → ℕ→N (suc r) x) (double-lemma ds) ⟩ \n ℕ→N (suc r) (DirNum→ℕ {suc r} (↓ , ds))\n ≡⟨ NℕNlemma (suc r) (↓ , ds) ⟩ \n bn (↓ , ds)\n ∎\nN→ℕ→N (suc r) (bn (↑ , ds)) = \n sucN (ℕ→N (suc r) (doubleℕ (DirNum→ℕ ds)))\n ≡⟨ cong (λ x → sucN (ℕ→N (suc r) x)) (double-lemma ds) ⟩ \n sucN (ℕ→N (suc r) (DirNum→ℕ {suc r} (↓ , ds)))\n ≡⟨ cong sucN (NℕNlemma (suc r) (↓ , ds)) ⟩ \n sucN (bn (↓ , ds))\n ≡⟨ refl ⟩\n bn (↑ , ds)\n ∎\nN→ℕ→N (suc r) (xr (↓ , ds) x) = \n ℕ→N (suc r)\n (sucn (doubleℕ (DirNum→ℕ ds))\n (doublesℕ r (doubleℕ (N→ℕ (suc r) x))))\n ≡⟨ cong (λ z → ℕ→N (suc r) (sucn z (doublesℕ r (doubleℕ (N→ℕ (suc r) x))))) (double-lemma ds) ⟩ \n ℕ→N (suc r)\n (sucn (DirNum→ℕ {suc r} (↓ , ds))\n (doublesℕ r (doubleℕ (N→ℕ (suc r) x))))\n ≡⟨ refl ⟩\n ℕ→N (suc r)\n (sucn (DirNum→ℕ {suc r} (↓ , ds))\n (doublesℕ (suc r) (N→ℕ (suc r) x)))\n ≡⟨ ℕ→Nsucn (suc r) (DirNum→ℕ {suc r} (↓ , ds)) (doublesℕ (suc r) (N→ℕ (suc r) x)) ⟩\n sucnN (DirNum→ℕ {suc r} (↓ , ds))\n (ℕ→N (suc r) (doublesℕ (suc r) (N→ℕ (suc r) x)))\n ≡⟨ cong (λ z → sucnN (DirNum→ℕ {suc r} (↓ , ds)) z) (H (suc r) (suc r) (N→ℕ (suc r) x)) ⟩\n sucnN (DirNum→ℕ {suc r} (↓ , ds))\n (doublesN (suc r) (suc r) (ℕ→N (suc r) (N→ℕ (suc r) x)))\n ≡⟨ cong (λ z → sucnN (DirNum→ℕ {suc r} (↓ , ds)) (doublesN (suc r) (suc r) z)) (N→ℕ→N (suc r) x) ⟩\n sucnN (DirNum→ℕ {suc r} (↓ , ds))\n (doublesN (suc r) (suc r) x)\n ≡⟨ G (suc r) (↓ , ds) x snotz ⟩\n xr (↓ , ds) x ∎\n where\n H : (r m n : ℕ) → ℕ→N r (doublesℕ m n) ≡ doublesN r m (ℕ→N r n)\n H r m n = {!!}\n G : (r : ℕ) (d : DirNum r) (x : N r) → ¬ (r ≡ 0) → sucnN (DirNum→ℕ {r} d) (doublesN r r x) ≡ xr d x\n G zero d x 0≠0 = ⊥-elim (0≠0 refl)\n G (suc r) d (bn x) r≠0 = {!!}\n G (suc r) d (xr x x₁) r≠0 = {!!}\nN→ℕ→N (suc r) (xr (↑ , ds) x) with max? ds\n... | no ds≠max = \n sucN\n (ℕ→N (suc r)\n (sucn (doubleℕ (DirNum→ℕ ds))\n (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))))\n ≡⟨ sym (ℕ→Nsuc (suc r)\n (sucn (doubleℕ (DirNum→ℕ ds)) (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))))\n ⟩ \n ℕ→N (suc r)\n (suc (sucn (doubleℕ (DirNum→ℕ ds)) (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))))\n ≡⟨ refl ⟩ \n ℕ→N (suc r)\n (suc (sucn (doubleℕ (DirNum→ℕ ds)) (doublesℕ (suc r) (N→ℕ (suc r) x))))\n ≡⟨ cong (λ z → ℕ→N (suc r) z)\n (sym (sucnsuc (doubleℕ (DirNum→ℕ ds)) (doublesℕ (suc r) (N→ℕ (suc r) x))))\n ⟩ \n ℕ→N (suc r)\n (sucn (doubleℕ (DirNum→ℕ ds)) (suc (doublesℕ (suc r) (N→ℕ (suc r) x))))\n ≡⟨ ℕ→Nsucn (suc r) (doubleℕ (DirNum→ℕ ds)) (suc (doublesℕ (suc r) (N→ℕ (suc r) x))) ⟩ \n sucnN (doubleℕ (DirNum→ℕ ds)) (ℕ→N (suc r) (suc (doublesℕ (suc r) (N→ℕ (suc r) x))))\n ≡⟨ cong (λ z → sucnN (doubleℕ (DirNum→ℕ ds)) z)\n (ℕ→Nsuc (suc r) (doublesℕ (suc r) (N→ℕ (suc r) x)))\n ⟩\n -- (2^(r+1)*x + 1) + 2*ds\n -- = 2*(2^r*x + ds) + 1\n -- = 2*(\n sucnN (doubleℕ (DirNum→ℕ ds)) (sucN (ℕ→N (suc r) (doublesℕ (suc r) (N→ℕ (suc r) x))))\n ≡⟨ {!!} ⟩ {!!}\n\n... | yes ds≡max = {!!}\n\nℕ→N→ℕ : (r : ℕ) → (n : ℕ) → N→ℕ r (ℕ→N r n) ≡ n\nℕ→N→ℕ zero zero = refl\nℕ→N→ℕ (suc r) zero = \n doubleℕ (DirNum→ℕ (zero-n r))\n ≡⟨ cong doubleℕ (zero-n≡0 {r}) ⟩ \n doubleℕ zero\n ≡⟨ refl ⟩ \n zero\n ∎\nℕ→N→ℕ zero (suc n) = cong suc (ℕ→N→ℕ zero n)\nℕ→N→ℕ (suc r) (suc n) = \n N→ℕ (suc r) (sucN (ℕ→N (suc r) n))\n ≡⟨ N→ℕsucN (suc r) (ℕ→N (suc r) n) ⟩ \n suc (N→ℕ (suc r) (ℕ→N (suc r) n))\n ≡⟨ cong suc (ℕ→N→ℕ (suc r) n) ⟩ \n suc n\n ∎\n\nN≃ℕ : (r : ℕ) → N r ≃ ℕ\nN≃ℕ r = isoToEquiv (iso (N→ℕ r) (ℕ→N r) (ℕ→N→ℕ r) (N→ℕ→N r))\n\nN≡ℕ : (r : ℕ) → N r ≡ ℕ\nN≡ℕ r = ua (N≃ℕ r)\n\n\n\n---- pos approach:\n\ndata NPos (n : ℕ) : Type₀ where\n npos1 : NPos n\n x⇀ : DirNum n → NPos n → NPos n\n \nsucNPos : ∀ {n} → NPos n → NPos n\nsucNPos {zero} npos1 = x⇀ tt npos1\nsucNPos {zero} (x⇀ tt x) = x⇀ tt (sucNPos x)\nsucNPos {suc n} npos1 = x⇀ (next (one-n (suc n))) npos1\nsucNPos {suc n} (x⇀ d x) with (max? d)\n... | (no _) = x⇀ (next d) x\n... | (yes _) = x⇀ (zero-n (suc n)) (sucNPos x)\n\n-- some examples for sanity check\n\n2₂ : NPos 1\n2₂ = x⇀ (↓ , tt) npos1\n\n3₂ : NPos 1\n3₂ = x⇀ (↑ , tt) npos1\n\n4₂ : NPos 1\n4₂ = x⇀ (↓ , tt) (x⇀ (↓ , tt) npos1)\n\n2₄ : NPos 2\n2₄ = x⇀ (↓ , (↑ , tt)) npos1 -- how does this make sense?\n\n3₄ : NPos 2\n3₄ = x⇀ (↑ , (↑ , tt)) npos1 -- how does this make sense?\n\n-- sucnpos1≡x⇀one-n : ∀ {r} → sucNPos npos1 ≡ x⇀ (one-n r) npos1\n-- sucnpos1≡x⇀one-n {zero} = refl\n-- sucnpos1≡x⇀one-n {suc r} = {!!}\n\n-- sucnposx⇀zero-n≡x⇀one-n : ∀ {r} {p} → sucNPos (x⇀ (zero-n r) p) ≡ x⇀ (one-n r) p\n-- sucnposx⇀zero-n≡x⇀one-n {zero} {npos1} = {!!}\n-- sucnposx⇀zero-n≡x⇀one-n {zero} {x⇀ x p} = {!!}\n-- sucnposx⇀zero-n≡x⇀one-n {suc r} {p} = refl\n\nnPosInd : ∀ {r} {P : NPos r → Type₀} →\n P npos1 →\n ((p : NPos r) → P p → P (sucNPos p)) →\n (p : NPos r) →\n P p\nnPosInd {r} {P} h1 hs ps = f ps\n where\n H : (p : NPos r) → P (x⇀ (zero-n r) p) → P (x⇀ (zero-n r) (sucNPos p))\n --H p hx0p = hs (x⇀ (one-n r) p) (hs (x⇀ (zero-n r) p) hx0p)\n\n f : (ps : NPos r) → P ps\n f npos1 = h1\n f (x⇀ d ps) with (max? d)\n ... | (no _) = {!nPosInd (hs npos1 h1) H ps!}\n ... | (yes _) = {!hs (x⇀ (zero-n r) ps) (nPosInd (hs npos1 h1) H ps)!}\n \n-- nPosInd {zero} {P} h1 hs ps = f ps\n-- where\n-- H : (p : NPos zero) → P (x⇀ (zero-n zero) p) → P (x⇀ (zero-n zero) (sucNPos p))\n-- H p hx0p = hs (x⇀ tt (x⇀ (zero-n zero) p)) (hs (x⇀ (zero-n zero) p) hx0p)\n\n-- f : (ps : NPos zero) → P ps\n-- f npos1 = h1\n-- f (x⇀ tt ps) = nPosInd (hs npos1 h1) H ps\n-- nPosInd {suc r} {P} h1 hs ps = f ps\n-- where\n-- H : (p : NPos (suc r)) → P (x⇀ (zero-n (suc r)) p) → P (x⇀ (zero-n (suc r)) (sucNPos p))\n-- --H p hx0p = hs (x⇀ (one-n r) p) (hs (x⇀ (zero-n r) p) hx0p)\n\n-- f : (ps : NPos (suc r)) → P ps\n-- f npos1 = h1\n-- f (x⇀ d ps) = {!!}\n\nNPos→ℕ : ∀ r → NPos r → ℕ\nNPos→ℕ zero npos1 = suc zero\nNPos→ℕ zero (x⇀ tt x) = suc (NPos→ℕ zero x)\nNPos→ℕ (suc r) npos1 = suc zero\nNPos→ℕ (suc r) (x⇀ d x) with max? d\n... | no _ = sucn (DirNum→ℕ (next d)) (doublesℕ (suc r) (NPos→ℕ (suc r) x))\n... | yes _ = sucn (DirNum→ℕ (next d)) (doublesℕ (suc r) (suc (NPos→ℕ (suc r) x)))\n-- NPos→ℕ (suc r) (x⇀ d x) = \n-- sucn (DirNum→ℕ d) (doublesℕ (suc r) (NPos→ℕ (suc r) x))\n\nNPos→ℕsucNPos : ∀ r → (p : NPos r) → NPos→ℕ r (sucNPos p) ≡ suc (NPos→ℕ r p)\nNPos→ℕsucNPos zero npos1 = refl\nNPos→ℕsucNPos zero (x⇀ d p) = cong suc (NPos→ℕsucNPos zero p)\nNPos→ℕsucNPos (suc r) npos1 = {!!}\n sucn (doubleℕ (DirNum→ℕ (zero-n r))) (doublesℕ r 2)\n ≡⟨ cong (λ y → sucn y (doublesℕ r 2)) (zero-n→0) ⟩\n sucn (doubleℕ zero) (doublesℕ r 2)\n ≡⟨ refl ⟩ \n doublesℕ r 2\n ≡⟨ {!!} ⟩ {!!}\nNPos→ℕsucNPos (suc r) (x⇀ d p) with max? d\n... | no _ = {!!}\n... | yes _ = {!!}\n\n-- zero≠NPos→ℕ : ∀ {r} → (p : NPos r) → ¬ (zero ≡ NPos→ℕ r p)\n-- zero≠NPos→ℕ {r} p = {!!}\n\nℕ→NPos : ∀ r → ℕ → NPos r\nℕ→NPos zero zero = npos1\nℕ→NPos zero (suc zero) = npos1\nℕ→NPos zero (suc (suc n)) = sucNPos (ℕ→NPos zero (suc n))\nℕ→NPos (suc r) zero = npos1\nℕ→NPos (suc r) (suc zero) = npos1\nℕ→NPos (suc r) (suc (suc n)) = sucNPos (ℕ→NPos (suc r) (suc n))\n\nlemma : ∀ {r} → (ℕ→NPos r (NPos→ℕ r npos1)) ≡ npos1\nlemma {zero} = refl\nlemma {suc r} = refl\n\nNPos→ℕ→NPos : ∀ r → (p : NPos r) → ℕ→NPos r (NPos→ℕ r p) ≡ p\nNPos→ℕ→NPos r p = nPosInd lemma hs p\n where\n hs : (p : NPos r) → ℕ→NPos r (NPos→ℕ r p) ≡ p → ℕ→NPos r (NPos→ℕ r (sucNPos p)) ≡ (sucNPos p)\n hs p hp = \n ℕ→NPos r (NPos→ℕ r (sucNPos p))\n ≡⟨ {!!} ⟩ \n ℕ→NPos r (suc (NPos→ℕ r p))\n ≡⟨ {!!} ⟩ \n sucNPos (ℕ→NPos r (NPos→ℕ r p))\n ≡⟨ cong sucNPos hp ⟩ \n sucNPos p\n ∎\n\n\n-- note: the cases for zero and suc r are almost identical\n-- (why) does this need to split?\nℕ→NPos→ℕ : ∀ r → (n : ℕ) → NPos→ℕ r (ℕ→NPos r (suc n)) ≡ (suc n)\nℕ→NPos→ℕ zero zero = refl\nℕ→NPos→ℕ zero (suc n) = \n NPos→ℕ zero (sucNPos (ℕ→NPos zero (suc n)))\n ≡⟨ {!!} ⟩ \n suc (NPos→ℕ zero (ℕ→NPos zero (suc n)))\n ≡⟨ cong suc (ℕ→NPos→ℕ zero n) ⟩ \n suc (suc n)\n ∎\nℕ→NPos→ℕ (suc r) zero = refl\nℕ→NPos→ℕ (suc r) (suc n) = \n NPos→ℕ (suc r) (sucNPos (ℕ→NPos (suc r) (suc n)))\n ≡⟨ {!!} ⟩ \n suc (NPos→ℕ (suc r) (ℕ→NPos (suc r) (suc n)))\n ≡⟨ cong suc (ℕ→NPos→ℕ (suc r) n) ⟩ \n suc (suc n)\n ∎\n\n\n\n", "meta": {"hexsha": "123aba03793af34365f2ff689c791296871a7ce8", "size": 18623, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Multidimensional/NNat.agda", "max_stars_repo_name": "wrrnhttn/agda-cubical-multidimensional", "max_stars_repo_head_hexsha": "55709dd950e319c4a105ace33ddaf8b955354add", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Multidimensional/NNat.agda", "max_issues_repo_name": "wrrnhttn/agda-cubical-multidimensional", "max_issues_repo_head_hexsha": "55709dd950e319c4a105ace33ddaf8b955354add", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-06-19T20:40:07.000Z", "max_issues_repo_issues_event_max_datetime": "2019-07-02T16:24:01.000Z", "max_forks_repo_path": "Multidimensional/NNat.agda", "max_forks_repo_name": "wrrnhttn/agda-cubical-multidimensional", "max_forks_repo_head_hexsha": "55709dd950e319c4a105ace33ddaf8b955354add", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.0195035461, "max_line_length": 116, "alphanum_fraction": 0.5038930355, "num_tokens": 9496, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681049901037, "lm_q2_score": 0.7401743677704878, "lm_q1q2_score": 0.6348979648047395}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\n\nmodule Categories.Diagram.Pullback.Limit {o ℓ e} (C : Category o ℓ e) where\n\nopen import Data.Product using (∃₂; _,_)\nopen import Function using (_$_)\n\nopen import Categories.Category.Instance.Span\nopen import Categories.Functor\nopen import Categories.Diagram.Pullback C\nopen import Categories.Morphism.Reasoning C as MR hiding (center)\n\nimport Relation.Binary.PropositionalEquality as ≡\n\nimport Categories.Category.Construction.Cones as Con\nimport Categories.Diagram.Limit as Lim\n\nprivate\n module C = Category C\n module Span = Category Span\n open Category C\n variable\n X Y Z : Obj\n f g h : X ⇒ Y\n\nopen HomReasoning\n\nmodule _ {F : Functor Span.op C} where\n open Functor F\n open Lim F\n open Con F\n\n private\n W = F₀ center\n A = F₀ left\n B = F₀ right\n\n A⇒W : A ⇒ W\n A⇒W = F₁ span-arrˡ\n\n B⇒W : B ⇒ W\n B⇒W = F₁ span-arrʳ\n\n limit⇒pullback : Limit → Pullback A⇒W B⇒W\n limit⇒pullback lim = record\n { p₁ = proj left\n ; p₂ = proj right\n ; commute = trans (limit-commute span-arrˡ) (sym (limit-commute span-arrʳ))\n ; universal = universal\n ; unique = commute′\n ; p₁∘universal≈h₁ = commute\n ; p₂∘universal≈h₂ = commute\n }\n where open Limit lim\n universal : A⇒W ∘ f ≈ B⇒W ∘ g → dom f ⇒ apex\n universal {f = f} {g = g} eq = rep $ record\n { apex = record\n { ψ = λ { center → B⇒W ∘ g\n ; left → f\n ; right → g\n }\n ; commute = λ { {center} {center} span-id → elimˡ identity\n ; {left} {center} span-arrˡ → eq\n ; {left} {left} span-id → elimˡ identity\n ; {right} {center} span-arrʳ → refl\n ; {right} {right} span-id → elimˡ identity\n }\n }\n }\n\n proj-center : proj center ≈ B⇒W ∘ proj right\n proj-center = sym (limit-commute span-arrʳ)\n\n commute′ : ∀ {eq : A⇒W ∘ f ≈ B⇒W ∘ g} → proj left ∘ h ≈ f → proj right ∘ h ≈ g → h ≈ universal eq\n commute′ {f = f} {g = g} {h = h} {eq = eq} eq₁ eq₂ = sym $ terminal.!-unique $ record\n { arr = h\n ; commute = λ { {center} → begin\n proj center ∘ h ≈⟨ pushˡ proj-center ⟩\n B⇒W ∘ proj right ∘ h ≈⟨ refl⟩∘⟨ eq₂ ⟩\n B⇒W ∘ g ∎\n ; {left} → eq₁\n ; {right} → eq₂\n }\n }\n\nmodule _ (p : Pullback f g) where\n open Pullback p\n\n pullback⇒limit-F : Functor Span.op C\n pullback⇒limit-F = record\n { F₀ = λ { center → cod f\n ; left → dom f\n ; right → dom g\n }\n ; F₁ = λ { {center} {.center} span-id → C.id\n ; {left} {.left} span-id → C.id\n ; {right} {.right} span-id → C.id\n ; {.left} {.center} span-arrˡ → f\n ; {.right} {.center} span-arrʳ → g\n }\n ; identity = λ { {center} → refl\n ; {left} → refl\n ; {right} → refl\n }\n ; homomorphism = λ { {center} {.center} {.center} {span-id} {span-id} → sym identityˡ\n ; {left} {.left} {.left} {span-id} {span-id} → sym identityˡ\n ; {right} {.right} {.right} {span-id} {span-id} → sym identityˡ\n ; {.left} {.left} {.center} {span-id} {span-arrˡ} → sym identityʳ\n ; {.right} {.right} {.center} {span-id} {span-arrʳ} → sym identityʳ\n ; {.left} {.center} {.center} {span-arrˡ} {span-id} → sym identityˡ\n ; {.right} {.center} {.center} {span-arrʳ} {span-id} → sym identityˡ\n }\n ; F-resp-≈ = λ { {center} {.center} {span-id} {.span-id} ≡.refl → refl\n ; {left} {.left} {span-id} {.span-id} ≡.refl → refl\n ; {right} {.right} {span-id} {.span-id} ≡.refl → refl\n ; {.left} {.center} {span-arrˡ} {.span-arrˡ} ≡.refl → refl\n ; {.right} {.center} {span-arrʳ} {.span-arrʳ} ≡.refl → refl\n }\n }\n\n open Functor pullback⇒limit-F\n open Lim pullback⇒limit-F\n open Con pullback⇒limit-F\n\n pullback⇒limit : Limit\n pullback⇒limit = record\n { terminal = record\n { ⊤ = ⊤\n ; ! = !\n ; !-unique = !-unique\n }\n }\n where ⊤ : Cone\n ⊤ = record\n { apex = record\n { ψ = λ { center → g ∘ p₂\n ; left → p₁\n ; right → p₂\n }\n ; commute = λ { {center} {.center} span-id → identityˡ\n ; {left} {.left} span-id → identityˡ\n ; {right} {.right} span-id → identityˡ\n ; {.left} {.center} span-arrˡ → commute\n ; {.right} {.center} span-arrʳ → refl\n }\n }\n }\n\n ! : ∀ {A : Cone} → Cone⇒ A ⊤\n ! {A} = record\n { arr = universal commute′\n ; commute = λ { {center} → begin\n (g ∘ p₂) ∘ universal _ ≈⟨ pullʳ p₂∘universal≈h₂ ⟩\n g ∘ A.ψ right ≈⟨ A.commute span-arrʳ ⟩\n A.ψ center ∎\n ; {left} → p₁∘universal≈h₁\n ; {right} → p₂∘universal≈h₂\n }\n }\n where module A = Cone A\n commute′ = trans (A.commute span-arrˡ) (sym (A.commute span-arrʳ))\n\n !-unique : ∀ {A : Cone} (h : Cone⇒ A ⊤) → Cones [ ! ≈ h ]\n !-unique {A} h = sym (unique h.commute h.commute)\n where module h = Cone⇒ h\n", "meta": {"hexsha": "1b68b6e9854f17f1d4bf742f00868318c4856593", "size": 6252, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Diagram/Pullback/Limit.agda", "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Diagram/Pullback/Limit.agda", "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Diagram/Pullback/Limit.agda", "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.2142857143, "max_line_length": 107, "alphanum_fraction": 0.4214651312, "num_tokens": 1831, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577680977182187, "lm_q2_score": 0.7401743735019594, "lm_q1q2_score": 0.63489796433855}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Numbers.Naturals.Definition\nopen import Numbers.Naturals.Naturals\nopen import Numbers.Integers.Integers\nopen import Groups.Groups\nopen import Groups.Definition\nopen import Groups.Lemmas\nopen import Rings.Definition\nopen import Rings.Orders.Total.Definition\nopen import Rings.Orders.Partial.Definition\nopen import Fields.Fields\nopen import Setoids.Setoids\nopen import Setoids.Orders.Partial.Definition\nopen import Setoids.Orders.Total.Definition\nopen import Functions.Definition\nopen import Sets.EquivalenceRelations\n\nmodule Numbers.Rationals.Definition where\n\nopen import Fields.FieldOfFractions.Setoid ℤIntDom\nopen import Fields.FieldOfFractions.Addition ℤIntDom\nopen import Fields.FieldOfFractions.Multiplication ℤIntDom\nopen import Fields.FieldOfFractions.Ring ℤIntDom\nopen import Fields.FieldOfFractions.Field ℤIntDom\nopen import Fields.FieldOfFractions.Lemmas ℤIntDom\nopen import Fields.FieldOfFractions.Order ℤIntDom ℤOrderedRing\n\nℚ : Set\nℚ = fieldOfFractionsSet\n\nℚSetoid : Setoid ℚ\nℚSetoid = fieldOfFractionsSetoid\n\n_+Q_ : ℚ → ℚ → ℚ\na +Q b = fieldOfFractionsPlus a b\n\n_*Q_ : ℚ → ℚ → ℚ\na *Q b = fieldOfFractionsTimes a b\n\nℚRing : Ring fieldOfFractionsSetoid _+Q_ _*Q_\nℚRing = fieldOfFractionsRing\n\n0Q : ℚ\n0Q = Ring.0R ℚRing\n\ninjectionQ : ℤ → ℚ\ninjectionQ = embedIntoFieldOfFractions\n\ninjectionNQ : ℕ → ℚ\ninjectionNQ n = injectionQ (nonneg n)\n\ninjectionQInjective : Injection injectionQ\ninjectionQInjective {nonneg x} {nonneg .x} refl = refl\ninjectionQInjective {negSucc x} {negSucc .x} refl = refl\n\nℚField : Field ℚRing\nℚField = fieldOfFractions\n\n_ Q -> P ∧ Q\n\n ∧-elim₁ : {P Q : Prop} -> P ∧ Q -> P\n ∧-elim₁ (∧-intro p _) = p\n\n ∧-elim₂ : {P Q : Prop} -> P ∧ Q -> Q\n ∧-elim₂ (∧-intro _ q) = q\n\n data _∨_ (P Q : Prop) : Prop where\n ∨-intro₁ : P -> P ∨ Q\n ∨-intro₂ : Q -> P ∨ Q\n\n ∨-elim : {P Q R : Prop} -> (P -> R) -> (Q -> R) -> P ∨ Q -> R\n ∨-elim f g (∨-intro₁ p) = f p\n ∨-elim f g (∨-intro₂ q) = g q\n\n data ⊥ : Prop where\n\n data ⊤ : Prop where\n ⊤-intro : ⊤\n\n data ¬_ (P : Prop) : Prop where\n ¬-intro : (P -> ⊥) -> ¬ P\n\n data ∏ {A : Set}(P : A -> Prop) : Prop where\n ∏-intro : ((x : A) -> P x) -> ∏ P\n\n", "meta": {"hexsha": "7606ec7b024e9639bceb9f717389d42b9e1a47f4", "size": 796, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/Introduction/Unicode.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/Introduction/Unicode.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/Introduction/Unicode.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 21.5135135135, "max_line_length": 78, "alphanum_fraction": 0.4849246231, "num_tokens": 340, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9207896824119662, "lm_q2_score": 0.6893056295505783, "lm_q1q2_score": 0.6347055117186574}} {"text": "open import Prelude\n\nopen import Data.Nat\nopen import Data.Nat.Properties\nopen import Induction.Nat\n\nmodule Implicits.Resolution.GenericFinite.Examples.MaximumDepth\n where\n\nopen import Implicits.Resolution.GenericFinite.TerminationCondition\n\n_<′?_ : (x y : ℕ) → Dec (x <′ y)\nx <′? y with (suc x) ≤? y\nx <′? y | yes p = yes (≤⇒≤′ p)\nx <′? y | no ¬p = no (λ p → ¬p (≤′⇒≤ p))\n\nMaxDepthCondition : TerminationCondition\nMaxDepthCondition = record\n { TCtx = ℕ\n ; _<_ = _<′_\n ; _ Extensionality a b\n\n\n-- Type class for categories.\n-- Based on https://github.com/UlfNorell/category-theory-experiments\nrecord Category (n : Level) : Set (lsuc (lsuc n)) where\n infixr 10 _~>_\n infixl 40 _≈_\n infixr 60 _∘_\n field\n -- || Data\n -- Objects\n obj : Set (lsuc n)\n -- Arrows\n _~>_ : obj -> obj -> Set n\n\n -- || Operations\n -- Identity arrow\n id : {A : obj} -> A ~> A\n -- Composition of arrows\n _∘_ : {A B C : obj} -> (B ~> C) -> (A ~> B) -> (A ~> C)\n -- Equality of arrows (as we don't have function extensionality)\n _≈_ : {A B : obj} -> (A ~> B) -> (A ~> B) -> Set n\n\n -- || Laws\n -- Left identity\n id-left : {A B : obj} {f : A ~> B} -> id ∘ f ≈ f\n -- Right identity\n id-right : {A B : obj} {f : A ~> B} -> f ∘ id ≈ f\n -- Associativity of composition\n ∘-assoc : {A B C D : obj} {f : C ~> D} {g : B ~> C} {h : A ~> B}\n -> (f ∘ g) ∘ h ≈ f ∘ (g ∘ h)\n -- Arrow equality is an equivalence relation\n ≈-equiv : ∀{A B : obj} -> IsEquivalence (_≈_ {A} {B})\n -- Congruence of equality and composition\n ≈-cong : ∀{A B C : obj} {f f′ : A ~> B} {g g′ : B ~> C}\n -> f ≈ f′ -> g ≈ g′ -> g ∘ f ≈ g′ ∘ f′\n\n -- Equational reasoning for ≈ (based on the standard library definitions)\n infix 3 _∎\n infixr 2 _≈⟨⟩_ _≈⟨_⟩_\n infix 1 begin_\n infixl 20 _[sym]\n infixr 15 _≈>_\n\n begin_ : ∀{A B : obj} {x y : A ~> B} → x ≈ y → x ≈ y\n begin_ x≈y = x≈y\n\n _≈⟨⟩_ : ∀{A B : obj} (x {y} : A ~> B) → x ≈ y → x ≈ y\n _ ≈⟨⟩ x≈y = x≈y\n\n _≈⟨_⟩_ : ∀{A B : obj} (x {y z} : A ~> B) → x ≈ y → y ≈ z → x ≈ z\n _ ≈⟨ x≈y ⟩ y≈z = IsEquivalence.trans ≈-equiv x≈y y≈z\n\n _∎ : ∀{A B : obj} (x : A ~> B) → x ≈ x\n _∎ _ = IsEquivalence.refl ≈-equiv\n\n r≈ : ∀{A B : obj} {x : A ~> B} → x ≈ x\n r≈ = IsEquivalence.refl ≈-equiv\n\n _[sym] : ∀{A B : obj} {x y : A ~> B} → x ≈ y → y ≈ x\n p [sym] = IsEquivalence.sym ≈-equiv p\n\n _≈>_ : ∀{A B : obj} {x y z : A ~> B} → x ≈ y → y ≈ z → x ≈ z\n p1 ≈> p2 = IsEquivalence.trans ≈-equiv p1 p2\n\n id-comm : {A B : obj} {f : A ~> B} -> f ∘ id ≈ id ∘ f\n id-comm = id-right ≈> id-left [sym]\n\n -- Derived congruence properties\n ≈-cong-left : ∀{A B C : obj} {f : A ~> B} {g g′ : B ~> C}\n -> g ≈ g′ -> g ∘ f ≈ g′ ∘ f\n ≈-cong-left e = ≈-cong r≈ e\n ≈-cong-right : ∀{A B C : obj} {g : B ~> C} {f f′ : A ~> B}\n -> f ≈ f′ -> g ∘ f ≈ g ∘ f′\n ≈-cong-right e = ≈-cong e r≈\n\n -- Isomorphism of two objects\n record _<~>_ (A B : obj) : Set (lsuc n) where\n field\n -- | Data\n -- Arrow in one direction\n iso~> : A ~> B\n -- Arrow in other direction\n iso<~ : B ~> A\n\n -- | Laws\n iso-id₁ : iso<~ ∘ iso~> ≈ id {A}\n iso-id₂ : iso~> ∘ iso<~ ≈ id {B}\n", "meta": {"hexsha": "efcfea1f50c7a17770f3427054afa1f282193ac6", "size": 3362, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/CategoryTheory/Categories.agda", "max_stars_repo_name": "DimaSamoz/temporal-type-systems", "max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z", "max_issues_repo_path": "src/CategoryTheory/Categories.agda", "max_issues_repo_name": "DimaSamoz/temporal-type-systems", "max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/CategoryTheory/Categories.agda", "max_forks_repo_name": "DimaSamoz/temporal-type-systems", "max_forks_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.9607843137, "max_line_length": 77, "alphanum_fraction": 0.4663890541, "num_tokens": 1308, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.831143031127974, "lm_q2_score": 0.7634837635542925, "lm_q1q2_score": 0.6345642094575081}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Binary.Proofs.Bijection where\n\nopen import Relation.Binary.PropositionalEquality\nopen import Data.Binary.Operations.Unary\nopen import Data.Binary.Proofs.Unary\nopen import Data.Binary.Definitions\nopen import Data.Binary.Operations.Semantics\nopen import Data.Nat as ℕ using (ℕ; suc; zero)\nopen import Relation.Binary.PropositionalEquality.FasterReasoning\nimport Data.Nat.Properties as ℕ\nopen import Function\n\nhomo : ∀ n → ⟦ ⟦ n ⇑⟧ ⇓⟧ ≡ n\nhomo zero = refl\nhomo (suc n) = inc-homo ⟦ n ⇑⟧ ⟨ trans ⟩ cong suc (homo n)\n\ninj : ∀ {x y} → ⟦ x ⇓⟧ ≡ ⟦ y ⇓⟧ → x ≡ y\ninj {xs} {ys} eq = go (subst (IncView xs) eq (inc-view xs)) (inc-view ys)\n where\n go : ∀ {n xs ys} → IncView xs n → IncView ys n → xs ≡ ys\n go Izero Izero = refl\n go (Isuc refl xs) (Isuc refl ys) = cong inc (go xs ys)\n\nopen import Function.Bijection\n\n𝔹↔ℕ : 𝔹 ⤖ ℕ\n𝔹↔ℕ = bijection ⟦_⇓⟧ ⟦_⇑⟧ inj homo\n", "meta": {"hexsha": "975378e8312630f11ce0165084073ef4fe764eb0", "size": 903, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Binary/Proofs/Bijection.agda", "max_stars_repo_name": "oisdk/agda-binary", "max_stars_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-03-21T21:30:10.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-21T21:30:10.000Z", "max_issues_repo_path": "Data/Binary/Proofs/Bijection.agda", "max_issues_repo_name": "oisdk/agda-binary", "max_issues_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Binary/Proofs/Bijection.agda", "max_forks_repo_name": "oisdk/agda-binary", "max_forks_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.1, "max_line_length": 73, "alphanum_fraction": 0.6832779623, "num_tokens": 333, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9161096112990285, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.6345359663142741}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.DStructures.Structures.PeifferGraph where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Structure\n\nopen import Cubical.Functions.FunExtEquiv\n\nopen import Cubical.Homotopy.Base\n\nopen import Cubical.Data.Sigma\n\nopen import Cubical.Relation.Binary\n\nopen import Cubical.Algebra.Group\nopen import Cubical.Structures.LeftAction\n\nopen import Cubical.DStructures.Base\nopen import Cubical.DStructures.Meta.Properties\nopen import Cubical.DStructures.Structures.Constant\n\nopen import Cubical.DStructures.Structures.Type\nopen import Cubical.DStructures.Structures.Group\nopen import Cubical.DStructures.Structures.ReflGraph\n\nopen GroupLemmas\nopen MorphismLemmas\n\nprivate\n variable\n ℓ ℓ' : Level\n\nmodule _ (𝒢 : ReflGraph ℓ ℓ') where\n open ReflGraphNotation 𝒢\n\n ----------------------------------------------------\n -- The peiffer condition for reflexive graphs,\n -- i.e. the missing property to turn a precrossed\n -- module into a crossed module\n ----------------------------------------------------\n isPeifferGraph : Type ℓ'\n isPeifferGraph = (a b : ⟨ G₁ ⟩) → ((is b +₁ (a -₁ it a)) +₁ (-is b +₁ b)) +₁ it a ≡ b +₁ a\n\n -- G₁ is a set, so isPeifferGraph is a proposition\n isPropIsPeifferGraph : isProp isPeifferGraph\n isPropIsPeifferGraph = isPropΠ2 (λ a b → set₁ (((is b +₁ (a -₁ it a)) +₁ (-is b +₁ b)) +₁ it a) (b +₁ a))\n\n ---------------------------------------------------\n -- lemmas about the peiffer graphs\n ---------------------------------------------------\n module _ (isPeifferG : isPeifferGraph) where\n abstract\n -- the peiffer condition can be simplified to this\n isPeifferGraph2 : (a b : ⟨ G₁ ⟩) → (a -₁ it a) +₁ (-is b +₁ b) ≡ (-is b +₁ (b +₁ a)) -₁ it a\n isPeifferGraph2 a b = (a -₁ ita) +₁ (-isb +₁ b)\n ≡⟨ sym (lCancel-lId G₁ isb ((a -₁ ita) +₁ (-isb +₁ b)))\n ∙ sym (rCancel-rId G₁ ((-isb +₁ isb) +₁ ((a -₁ ita) +₁ (-isb +₁ b))) ita) ⟩\n ((-isb +₁ isb) +₁ ((a -₁ ita) +₁ (-isb +₁ b))) +₁ (ita -₁ ita)\n ≡⟨ assoc₁ ((-isb +₁ isb) +₁ ((a -₁ ita) +₁ (-isb +₁ b))) ita -ita ⟩\n (((-isb +₁ isb) +₁ ((a -₁ ita) +₁ (-isb +₁ b))) +₁ ita) +₁ -ita\n ≡⟨ cong (λ z → (z +₁ ita) -₁ ita)\n (sym (assoc₁ -isb isb _)) ⟩\n ((-isb +₁ (isb +₁ ((a -₁ ita) +₁ (-isb +₁ b)))) +₁ ita) +₁ -ita\n ≡⟨ cong (λ z → ((-isb +₁ z) +₁ ita) +₁ -ita)\n (assoc₁ _ _ _) ⟩\n ((-isb +₁ ((isb +₁ (a -₁ ita)) +₁ (-isb +₁ b))) +₁ ita) +₁ -ita\n ≡⟨ cong (_+₁ -ita)\n (sym (assoc₁ -isb _ ita)) ⟩\n (-isb +₁ (((isb +₁ (a -₁ ita)) +₁ (-isb +₁ b)) +₁ ita)) -₁ ita\n ≡⟨ cong (λ z → (-isb +₁ z) -₁ ita)\n (isPeifferG a b) ⟩\n (-isb +₁ (b +₁ a)) -₁ ita ∎\n where\n -a = -₁ a\n -ita = -it a\n ita = it a\n isb = is b\n -isb = -is b\n -b = -₁ b\n\n -- inverting both sides of the identity isPeifferGraph2 and simplifying\n -- gives this\n isPeifferGraph3 : (a b : ⟨ G₁ ⟩) → (-₁ b) +₁ (is b +₁ (it a -₁ a)) ≡ it a +₁ ((-₁ a) +₁ ((-₁ b) +₁ is b))\n isPeifferGraph3 a b = -b +₁ (isb +₁ (ita -₁ a))\n ≡⟨ cong (λ z → -b +₁ (z +₁ (ita -₁ a)))\n (sym (invInvo G₁ isb))\n ∙ cong (λ z → -b +₁ ((-₁ -isb) +₁ (z -₁ a)))\n (sym (invInvo G₁ ita)) ⟩\n -b +₁ ((-₁ -isb) +₁ ((-₁ -ita) -₁ a))\n ≡⟨ sym (invDistr₄ G₁ a -ita -isb b) ⟩\n -₁ (((a +₁ -ita) +₁ -isb) +₁ b)\n ≡⟨ cong -₁_ (sym (assoc₁ _ -isb b)) ⟩\n -₁ ((a -₁ ita) +₁ (-isb +₁ b))\n ≡⟨ cong -₁_ (isPeifferGraph2 a b) ⟩\n -₁ ((-isb +₁ (b +₁ a)) -₁ ita)\n ≡⟨ cong (λ z → -₁ (z -₁ ita)) (assoc₁ -isb b a) ⟩\n -₁ (((-isb +₁ b) +₁ a) -₁ ita)\n ≡⟨ invDistr₄ G₁ -isb b a -ita ⟩\n (-₁ -ita) +₁ (-a +₁ (-b +₁ (-₁ -isb)))\n ≡⟨ cong (_+₁ (-a +₁ (-b +₁ (-₁ -isb))))\n (invInvo G₁ ita)\n ∙ cong (λ z → ita +₁ (-a +₁ (-b +₁ z)))\n (invInvo G₁ isb) ⟩\n ita +₁ (-a +₁ (-b +₁ isb)) ∎\n where\n -a = -₁ a\n -ita = -₁ (it a)\n ita = it a\n isb = is b\n -isb = -₁ isb\n -b = -₁ b\n\n -- plugging -a and -b into isPeifferGraph4 gives this\n isPeifferGraph4 : (a b : ⟨ G₁ ⟩) → b +₁ ((-₁ (is b)) +₁ ((-₁ (it a)) +₁ a)) ≡ (-₁ (it a)) +₁ (a +₁ (b -₁ (is b)))\n isPeifferGraph4 a b = b +₁ (-isb +₁ (-ita +₁ a))\n ≡⟨ cong (_+₁ (-isb +₁ (-ita +₁ a)))\n (sym (invInvo G₁ b)) ⟩\n (-₁ -b) +₁ (-isb +₁ (-ita +₁ a))\n ≡⟨ cong (λ z → (-₁ -b) +₁ (-isb +₁ (-ita +₁ z)))\n (sym (invInvo G₁ a)) ⟩\n (-₁ -b) +₁ (-isb +₁ (-ita -₁ -a))\n ≡⟨ cong (λ z → (-₁ -b) +₁ (-isb +₁ (z -₁ -a))) (sym (mapInv ι∘τ a)) ⟩\n (-₁ -b) +₁ (-isb +₁ ((it -a) -₁ -a))\n ≡⟨ cong (λ z → (-₁ -b) +₁ (z +₁ ((it -a) -₁ -a))) (sym (mapInv ι∘σ b)) ⟩\n (-₁ -b) +₁ (is -b +₁ ((it -a) -₁ -a))\n ≡⟨ isPeifferGraph3 -a -b ⟩\n it -a +₁ ((-₁ -a) +₁ ((-₁ -b) +₁ is -b))\n ≡⟨ cong (_+₁ ((-₁ -a) +₁ ((-₁ -b) +₁ is -b)))\n (mapInv ι∘τ a) ⟩\n -ita +₁ ((-₁ -a) +₁ ((-₁ -b) +₁ is -b))\n ≡⟨ cong (λ z → -ita +₁ (z +₁ ((-₁ -b) +₁ is -b)))\n (invInvo G₁ a) ⟩\n -ita +₁ (a +₁ ((-₁ -b) +₁ is -b))\n ≡⟨ cong (λ z → -ita +₁ (a +₁ (z +₁ is -b)))\n (invInvo G₁ b) ⟩\n -ita +₁ (a +₁ (b +₁ is -b))\n ≡⟨ cong (λ z → -ita +₁ (a +₁ (b +₁ z)))\n (mapInv ι∘σ b) ⟩\n -ita +₁ (a +₁ (b -₁ isb)) ∎\n where\n -a = -₁ a\n -ita = -it a\n isb = is b\n -isb = -is b\n -b = -₁ b\n\n-----------------------------------------------\n-- URG structure on the type of peiffer graphs\n--\n-- isPeifferGraph\n-- |\n-- ReflGraph\n-----------------------------------------------\n\nmodule _ (ℓ ℓ' : Level) where\n private\n ℓℓ' = ℓ-max ℓ ℓ'\n\n 𝒮ᴰ-ReflGraph\\Peiffer : URGStrᴰ (𝒮-ReflGraph ℓ ℓℓ')\n (λ 𝒢 → isPeifferGraph 𝒢)\n ℓ-zero\n 𝒮ᴰ-ReflGraph\\Peiffer = Subtype→Sub-𝒮ᴰ (λ 𝒢 → isPeifferGraph 𝒢 , isPropIsPeifferGraph 𝒢)\n (𝒮-ReflGraph ℓ ℓℓ')\n\n PeifferGraph : Type (ℓ-suc ℓℓ')\n PeifferGraph = Σ[ 𝒢 ∈ ReflGraph ℓ ℓℓ' ] isPeifferGraph 𝒢\n\n 𝒮-PeifferGraph : URGStr PeifferGraph ℓℓ'\n 𝒮-PeifferGraph = ∫⟨ 𝒮-ReflGraph ℓ ℓℓ' ⟩ 𝒮ᴰ-ReflGraph\\Peiffer\n", "meta": {"hexsha": "aad692310ea949467d3bf5ed3ba64a9368a7abf0", "size": 8168, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/DStructures/Structures/PeifferGraph.agda", "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/DStructures/Structures/PeifferGraph.agda", "max_issues_repo_name": "Schippmunk/cubical", "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/DStructures/Structures/PeifferGraph.agda", "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.2138728324, "max_line_length": 118, "alphanum_fraction": 0.3681439765, "num_tokens": 2618, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467706759583, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.6345182038119768}} {"text": "import Structure.Logic.Classical.NaturalDeduction\n\n-- TODO: MAybe rename to SetBoundedQuantification\nmodule Structure.Logic.Classical.SetTheory.SetBoundedQuantification {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} ⦃ classicLogic : _ ⦄ (_∈_ : Domain → Domain → Formula) where\nopen Structure.Logic.Classical.NaturalDeduction.ClassicalLogic {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} (classicLogic)\n\nopen import Functional hiding (Domain)\nopen import Lang.Instance\nimport Lvl\nopen import Type.Dependent\nopen import Structure.Logic.Classical.PredicateBoundedQuantification {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} ⦃ classicLogic ⦄\n\n-- Bounded universal quantifier\n∀ₛ : Domain → (Domain → Formula) → Formula\n∀ₛ(S)(P) = ∀ₚ(_∈ S)(P)\n\n[∀ₛ]-intro : ∀{S}{P} → (∀{x} → Proof(x ∈ S) → Proof(P(x))) → Proof(∀ₛ(S)(P))\n[∀ₛ]-intro = [∀ₚ]-intro\n\n[∀ₛ]-elim : ∀{S}{P} → Proof(∀ₛ(S)(P)) → ∀{x} → Proof(x ∈ S) → Proof(P(x))\n[∀ₛ]-elim = [∀ₚ]-elim\n\n-- Bounded existential quantifier\n∃ₛ : Domain → (Domain → Formula) → Formula\n∃ₛ(S)(P) = ∃ₚ(_∈ S)(P)\n\n[∃ₛ]-intro : ∀{S}{P}{x} → Proof(x ∈ S) → Proof(P(x)) → Proof(∃ₛ(S)(P))\n[∃ₛ]-intro = [∃ₚ]-intro\n\n[∃ₛ]-elim : ∀{S}{P}{Q} → (∀{x} → Proof(x ∈ S) → Proof(P(x)) → Proof(Q)) → Proof(∃ₛ(S)(P)) → Proof(Q)\n[∃ₛ]-elim = [∃ₚ]-elim\n\n[∃ₛ]-witness : ∀{S : Domain}{P : Domain → Formula} → ⦃ _ : Proof(∃ₛ S P) ⦄ → Domain\n[∃ₛ]-witness = [∃ₚ]-witness\n\n[∃ₛ]-domain : ∀{S : Domain}{P : Domain → Formula} → ⦃ p : Proof(∃ₛ S P) ⦄ → Proof([∃ₛ]-witness{S}{P} ⦃ p ⦄ ∈ S)\n[∃ₛ]-domain = [∃ₚ]-bound\n\n[∃ₛ]-proof : ∀{S : Domain}{P : Domain → Formula} → ⦃ p : Proof(∃ₛ S P) ⦄ → Proof(P([∃ₛ]-witness{S}{P} ⦃ p ⦄))\n[∃ₛ]-proof = [∃ₚ]-proof\n\nUniqueₛ : Domain → (Domain → Formula) → Formula\nUniqueₛ(S)(P) = Uniqueₚ(_∈ S)(P)\n\n-- Bounded unique existential quantifier\n∃ₛ! : Domain → (Domain → Formula) → Formula\n∃ₛ!(S)(P) = ∃ₚ!(_∈ S)(P)\n\n[∃ₛ!]-witness : ∀{S : Domain}{P : Domain → Formula} → ⦃ _ : Proof(∃ₛ! S P) ⦄ → Domain\n[∃ₛ!]-witness = [∃ₚ!]-witness\n\n[∃ₛ!]-domain : ∀{S : Domain}{P : Domain → Formula} → ⦃ p : Proof(∃ₛ! S P) ⦄ → Proof([∃ₛ!]-witness{S}{P} ⦃ p ⦄ ∈ S)\n[∃ₛ!]-domain = [∃ₚ!]-bound\n\n[∃ₛ!]-proof : ∀{S : Domain}{P : Domain → Formula} → ⦃ p : Proof(∃ₛ! S P) ⦄ → Proof(P([∃ₛ!]-witness{S}{P} ⦃ p ⦄))\n[∃ₛ!]-proof = [∃ₚ!]-proof\n\n[∃ₛ!]-unique : ∀{S : Domain}{P : Domain → Formula} → ⦃ p : Proof(∃ₛ! S P) ⦄ → Proof(∀ₗ(x ↦ P(x) ⟶ (x ≡ [∃ₛ!]-witness{S}{P} ⦃ p ⦄)))\n[∃ₛ!]-unique = [∃ₚ!]-unique\n", "meta": {"hexsha": "b2c94e278dbf6147d40cf5e6422879e6eefc5e03", "size": 2391, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "old/Structure/Logic/Classical/SetTheory/SetBoundedQuantification.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "old/Structure/Logic/Classical/SetTheory/SetBoundedQuantification.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "old/Structure/Logic/Classical/SetTheory/SetBoundedQuantification.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.85, "max_line_length": 171, "alphanum_fraction": 0.5725637808, "num_tokens": 1153, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.879146761176671, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.6345182022177991}} {"text": "\nmodule Basic.AST where\n\nimport Data.Bool as Bool using (not)\nopen import Data.Bool hiding (not; if_then_else_)\nopen import Data.Fin using (Fin; suc; zero; #_)\nopen import Data.Nat \nopen import Data.Vec \nopen import Relation.Nullary\nopen import Relation.Nullary.Decidable\nopen import Utils.Decidable\n\n{-\nThis module covers the first chapter of the book.\n\nWe omitted a couple of proofs that are present in the chapter. \n\nIn particular, determinism and totality of the evaluation of expressions\nis a trivial consequence of Agda's totality, so there's no need to bother\nwith it here. Also, the notion of \"composionality\" as mentioned in book corresponds\nsimply to structural recursion in Agda. \n\nAlso, we skipped the proofs about the evaluation of expression with substitutions\n(exercise 1.14) and contexts with substitutions (exercise 1.13), since we make\nno use of these in other proofs. \n-} \n\n-- Our type universe (it's not a large one). \ndata Ty : Set where\n bool nat : Ty\n\n{-\nInterpretation of types into Agda sets.\nNote that we use natural numbers instead of integers, since naturals are\nmuch simpler to handle in formal contexts (also, there's not enough Agda library\nsupport for integers).\n-}\n\n⟦_⟧ᵗ : Ty → Set\n⟦ nat ⟧ᵗ = ℕ\n⟦ bool ⟧ᵗ = Bool\n\n{-\nThis is a point where we make a departure from the book. The book defines states as:\n\nState = String → ℕ\n\nThis is supposed to be a total funuction, and the book doesn't concern itself with scope\nerrors or shadowing, but we certainly have to do so in Agda.\n\nSo we opt for de Bruijn indices as variables and a finite vector as State. These are as\nsimple to handle as it can get, and we also get alpha equality of programs for free.\n\nOn the flip side, we have much less readable programs.\n-}\n\nState : ℕ → Set\nState = Vec ℕ \n\n\n{-\nIn the book there's a mutual definition of boolean and numeric expressions.\nWe instead have a single universe-indexed type family. It's more convenient, and\nit's also equivalent to the mutual definition (it's a standard Agda/Haskell trick\nto encode multiple types data as a single indexed type). \n-}\ndata Exp (n : ℕ) : Ty → Set where\n lit : ℕ → Exp n nat\n add mul sub : Exp n nat → Exp n nat → Exp n nat\n var : Fin n → Exp n nat\n tt ff : Exp n bool\n eq lte lt : Exp n nat → Exp n nat → Exp n bool\n and : Exp n bool → Exp n bool → Exp n bool\n not : Exp n bool → Exp n bool\n\n \n{-\nStatements are parameterized by the size of the State they operate on. Since the\nvanilla \"While\" language has no declarations or other features that might change\nthe size of the state, we are fine with this. It also allows us to use finite numbers\nas de Bruijn indices.\n-}\n\ninfixr 5 _:=_\ninfixr 4 _,_\ndata St (n : ℕ) : Set where\n _:=_ : Fin n → Exp n nat → St n\n skip : St n\n _,_ : St n → St n → St n\n if_then_else_ : Exp n bool → St n → St n → St n\n while_do_ : Exp n bool → St n → St n\n\n{-\nThe semantics of expressions follows the book exactly.\n-}\n\n⟦_⟧ᵉ : ∀ {n t} → Exp n t → State n → ⟦ t ⟧ᵗ\n⟦ lit x ⟧ᵉ s = x\n⟦ add a b ⟧ᵉ s = ⟦ a ⟧ᵉ s + ⟦ b ⟧ᵉ s\n⟦ mul a b ⟧ᵉ s = ⟦ a ⟧ᵉ s * ⟦ b ⟧ᵉ s\n⟦ sub a b ⟧ᵉ s = ⟦ a ⟧ᵉ s ∸ ⟦ b ⟧ᵉ s\n⟦ var x ⟧ᵉ s = lookup x s\n⟦ tt ⟧ᵉ s = true\n⟦ ff ⟧ᵉ s = false\n⟦ eq a b ⟧ᵉ s = ⌊ ⟦ a ⟧ᵉ s ≡⁇ ⟦ b ⟧ᵉ s ⌋\n⟦ lte a b ⟧ᵉ s = ⌊ ⟦ a ⟧ᵉ s ≤⁇ ⟦ b ⟧ᵉ s ⌋\n⟦ lt a b ⟧ᵉ s = ⌊ ⟦ a ⟧ᵉ s <⁇ ⟦ b ⟧ᵉ s ⌋\n⟦ and a b ⟧ᵉ s = ⟦ a ⟧ᵉ s ∧ ⟦ b ⟧ᵉ s \n⟦ not e ⟧ᵉ s = Bool.not (⟦ e ⟧ᵉ s)\n\n \n", "meta": {"hexsha": "357a325a3fb2526ef8e03ee6ca7e2ff23384ce40", "size": 3446, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Basic/AST.agda", "max_stars_repo_name": "AndrasKovacs/SemanticsWithApplications", "max_stars_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2016-09-12T04:25:39.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-02T10:01:52.000Z", "max_issues_repo_path": "Basic/AST.agda", "max_issues_repo_name": "AndrasKovacs/SemanticsWithApplications", "max_issues_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Basic/AST.agda", "max_forks_repo_name": "AndrasKovacs/SemanticsWithApplications", "max_forks_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.7678571429, "max_line_length": 88, "alphanum_fraction": 0.6633778294, "num_tokens": 1173, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467675095294, "lm_q2_score": 0.721743200312399, "lm_q1q2_score": 0.6345182015266283}} {"text": "module Cats.Category.Sets where\n\nopen import Data.Product using (Σ ; _×_ ; proj₁ ; proj₂)\nopen import Level\nopen import Relation.Binary using (Rel ; IsEquivalence ; _Preserves₂_⟶_⟶_)\nopen import Relation.Binary.PropositionalEquality as ≡ using (_≡_)\n\nopen import Cats.Category.Base\nopen import Cats.Util.Function\nopen import Cats.Util.Logic.Constructive\n\n\nmodule _ {l} {A B : Set l} where\n\n infixr 4 _≈_\n\n\n _≈_ : (f g : A → B) → Set l\n f ≈ g = ∀ x → f x ≡ g x\n\n\n equiv : IsEquivalence _≈_\n equiv = record\n { refl = λ x → ≡.refl\n ; sym = λ eq x → ≡.sym (eq x)\n ; trans = λ eq₁ eq₂ x → ≡.trans (eq₁ x) (eq₂ x)\n }\n\n\ninstance Sets : ∀ l → Category (suc l) l l\nSets l = record\n { Obj = Set l\n ; _⇒_ = λ A B → A → B\n ; _≈_ = _≈_\n ; id = id\n ; _∘_ = _∘_\n ; equiv = equiv\n ; ∘-resp = λ {_} {_} {_} {f} eq₁ eq₂ x\n → ≡.trans (≡.cong f (eq₂ _)) (eq₁ _)\n ; id-r = λ _ → ≡.refl\n ; id-l = λ _ → ≡.refl\n ; assoc = λ _ → ≡.refl\n }\n", "meta": {"hexsha": "7c77a2c22b5d71dc754fd6417bf5021c61d4b241", "size": 980, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Category/Sets.agda", "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cats/Category/Sets.agda", "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cats/Category/Sets.agda", "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.2727272727, "max_line_length": 74, "alphanum_fraction": 0.5540816327, "num_tokens": 386, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9073122238669026, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.6344420895060371}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import lib.Base\nopen import lib.Function\nopen import lib.NType\nopen import lib.PathGroupoid\nopen import lib.Relation\nopen import lib.types.Coproduct\nopen import lib.types.Empty\n\nmodule lib.types.Nat where\n\ninfixl 80 _+_\n_+_ : ℕ → ℕ → ℕ\n0 + n = n\n(S m) + n = S (m + n)\n\n{-# BUILTIN NATPLUS _+_ #-}\n\nabstract\n +-unit-r : (m : ℕ) → m + 0 == m\n +-unit-r 0 = idp\n +-unit-r (S m) = ap S (+-unit-r m)\n\n +-βr : (m n : ℕ) → m + (S n) == S (m + n)\n +-βr 0 n = idp\n +-βr (S m) n = ap S (+-βr m n)\n\n +-comm : (m n : ℕ) → m + n == n + m\n +-comm m 0 = +-unit-r m\n +-comm m (S n) = +-βr m n ∙ ap S (+-comm m n)\n\n +-assoc : (k m n : ℕ) → (k + m) + n == k + (m + n)\n +-assoc 0 m n = idp\n +-assoc (S k) m n = ap S (+-assoc k m n)\n\n-- the [+] is like [ℕ-S^]\nℕ-S^' : ℕ → ℕ → ℕ\nℕ-S^' O n = n\nℕ-S^' (S m) n = ℕ-S^' m (S n)\n\nℕ-pred : ℕ → ℕ\nℕ-pred 0 = 0\nℕ-pred (S n) = n\n\nabstract\n ℕ-S-is-inj : is-inj (S :> (ℕ → ℕ))\n ℕ-S-is-inj n m p = ap ℕ-pred p\n\n ℕ-S-≠ : ∀ {n m : ℕ} (p : n ≠ m) → S n ≠ S m :> ℕ\n ℕ-S-≠ {n} {m} p = p ∘ ℕ-S-is-inj n m\n\n private\n ℕ-S≠O-type : ℕ → Type₀\n ℕ-S≠O-type O = Empty\n ℕ-S≠O-type (S n) = Unit\n\n ℕ-S≠O : (n : ℕ) → S n ≠ O\n ℕ-S≠O n p = transport ℕ-S≠O-type p unit\n\n ℕ-O≠S : (n : ℕ) → (O ≠ S n)\n ℕ-O≠S n p = ℕ-S≠O n (! p)\n\n ℕ-has-dec-eq : has-dec-eq ℕ\n ℕ-has-dec-eq O O = inl idp\n ℕ-has-dec-eq O (S n) = inr (ℕ-O≠S n)\n ℕ-has-dec-eq (S n) O = inr (ℕ-S≠O n)\n ℕ-has-dec-eq (S n) (S m) with ℕ-has-dec-eq n m\n ℕ-has-dec-eq (S n) (S m) | inl p = inl (ap S p)\n ℕ-has-dec-eq (S n) (S m) | inr ¬p = inr (ℕ-S-≠ ¬p)\n\nℕ-is-set : is-set ℕ\nℕ-is-set = dec-eq-is-set ℕ-has-dec-eq\n\ninstance\n ℕ-level : {n : ℕ₋₂} → has-level (S (S n)) ℕ\n ℕ-level {⟨-2⟩} = ℕ-is-set\n ℕ-level {n = S n} = raise-level (S (S n)) ℕ-level\n\n{- Inequalities -}\ninfix 40 _<_ _≤_\n\ndata _<_ : ℕ → ℕ → Type₀ where\n ltS : {m : ℕ} → m < (S m)\n ltSR : {m n : ℕ} → m < n → m < (S n)\n\n_≤_ : ℕ → ℕ → Type₀\nm ≤ n = Coprod (m == n) (m < n)\n\n-- experimental: [lteE] [lteS] [lteSR]\nlteE : {m : ℕ} → m ≤ m\nlteE = inl idp\n\nlteS : {m : ℕ} → m ≤ S m\nlteS = inr ltS\n\nlteSR : {m n : ℕ} → m ≤ n → m ≤ (S n)\nlteSR (inl idp) = lteS\nlteSR (inr lt) = inr (ltSR lt)\n\n-- properties of [<]\n\nOn) = inr (inr (<-ap-S m>n))\n", "meta": {"hexsha": "ea28161e2d811dc933f10d989e15971d9173839c", "size": 6867, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/types/Nat.agda", "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "core/lib/types/Nat.agda", "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "core/lib/types/Nat.agda", "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.0354330709, "max_line_length": 87, "alphanum_fraction": 0.4735692442, "num_tokens": 3442, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711832583696, "lm_q2_score": 0.746138993030751, "lm_q1q2_score": 0.6341966427815559}} {"text": "-- Andreas, 2022-06-14, issue #5953 reported by Szumi Xi\n-- Cubical Agda switches dot-pattern termination off (#4606).\n-- However, this breaks also some benign cases.\n--\n-- In this example with inductive-inductive types,\n-- dotted variables should still be recognized\n-- as variable patterns for termination certification.\n\n{-# OPTIONS --cubical #-} -- worked with --without-K but not --cubical\n\n-- Debugging:\n-- {-# OPTIONS -v term.check.clause:25 #-}\n-- {-# OPTIONS -v term:20 #-}\n\ndata Con : Set\ndata Ty : Con → Set\n\ndata Con where\n nil : Con\n ext : (Γ : Con) → Ty Γ → Con\n\ndata Ty where\n univ : (Γ : Con) → Ty Γ\n pi : (Γ : Con) (A : Ty Γ) → Ty (ext Γ A) → Ty Γ\n\nmodule _\n (A : Set)\n (B : A → Set)\n (n : A)\n (e : (a : A) → B a → A)\n (u : (a : A) → B a)\n (p : (a : A) (b : B a) → B (e a b) → B a)\n where\n recCon : Con → A\n recTy : (Γ : Con) → Ty Γ → B (recCon Γ)\n\n recCon nil = n\n recCon (ext Γ A) = e (recCon Γ) (recTy Γ A)\n\n recTy Γ (univ Γ) = u (recCon Γ)\n recTy Γ (pi Γ A B) = p (recCon Γ) (recTy Γ A) (recTy (ext Γ A) B)\n\n-- Should pass the termination checker.\n", "meta": {"hexsha": "ded35b8e86eb6e0170fcfd892b3d81970c3f7ef1", "size": 1087, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue5953.agda", "max_stars_repo_name": "KDr2/agda", "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/Succeed/Issue5953.agda", "max_issues_repo_name": "KDr2/agda", "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/Issue5953.agda", "max_forks_repo_name": "KDr2/agda", "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.7045454545, "max_line_length": 71, "alphanum_fraction": 0.5832566697, "num_tokens": 393, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.849971175657575, "lm_q2_score": 0.7461389930307512, "lm_q1q2_score": 0.6341966371103067}} {"text": "module Chunk where\n\nopen import Codata.Stream using (chunksOf; iterate; take)\nopen import Data.Nat using (ℕ; suc)\nopen import Data.Vec using (Vec; []; _∷_)\n\n\n-- mylist 3 = [[1,2,3],[4,5,6],[7,8,9]]\nmyVec : (n : ℕ) → Vec (Vec ℕ n) n\nmyVec n = take n (chunksOf n (iterate suc 1))\n\n\n\n\n", "meta": {"hexsha": "0bdc025f0aa6908f5f01889326d8f81365e1b1ee", "size": 282, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Chunk.agda", "max_stars_repo_name": "righ1113/Agda", "max_stars_repo_head_hexsha": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chunk.agda", "max_issues_repo_name": "righ1113/Agda", "max_issues_repo_head_hexsha": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chunk.agda", "max_forks_repo_name": "righ1113/Agda", "max_forks_repo_head_hexsha": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.8, "max_line_length": 57, "alphanum_fraction": 0.6312056738, "num_tokens": 104, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8824278664544911, "lm_q2_score": 0.7185943925708562, "lm_q1q2_score": 0.6341077166824617}} {"text": "{-# OPTIONS --cubical --safe #-}\nmodule Cubical.Data.Unit.Properties where\n\nopen import Cubical.Core.Everything\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\n\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Unit.Base\nopen import Cubical.Data.Prod.Base\n\nisContrUnit : isContr Unit\nisContrUnit = tt , λ {tt → refl}\n\nisPropUnit : isProp Unit\nisPropUnit _ _ i = tt -- definitionally equal to: isContr→isProp isContrUnit\n\nisOfHLevelUnit : (n : ℕ) → isOfHLevel n Unit\nisOfHLevelUnit n = isContr→isOfHLevel n isContrUnit\n\ndiagonal-unit : Unit ≡ Unit × Unit\ndiagonal-unit = isoToPath (iso (λ x → tt , tt) (λ x → tt) (λ {(tt , tt) i → tt , tt}) λ {tt i → tt})\n where open import Cubical.Foundations.Isomorphism\n", "meta": {"hexsha": "95b20ffb667cce8bee897d1ba3a7b9958d7d0cc9", "size": 744, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/Unit/Properties.agda", "max_stars_repo_name": "cmester0/cubical", "max_stars_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-03-23T23:52:11.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-23T23:52:11.000Z", "max_issues_repo_path": "Cubical/Data/Unit/Properties.agda", "max_issues_repo_name": "cmester0/cubical", "max_issues_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Data/Unit/Properties.agda", "max_forks_repo_name": "cmester0/cubical", "max_forks_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.76, "max_line_length": 100, "alphanum_fraction": 0.7419354839, "num_tokens": 227, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8902942348544447, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.6340962129438268}} {"text": "module Data.Finitude.FinType where\nopen import Relation.Binary.PropositionalEquality as P using (_≡_)\nopen import Data.Nat as ℕ\nopen import Data.Fin as Fin using (Fin; #_)\nopen import Data.Finitude\nopen import Function.Equality using (_⟨$⟩_)\nopen import Function.Injection as Inj using (Injective)\nopen import Function.Inverse as Inv using (Inverse)\nopen import Data.Vec\nopen import Data.Vec.Membership.Propositional\nopen import Data.Vec.Membership.Propositional.Properties\nopen import Data.Vec.Membership.Propositional.Distinct as Distinct using (Distinct)\n\nrecord FinType {a} (A : Set a) : Set a where\n field\n size : ℕ\n finitude : Finitude (P.setoid A) size\n open import Data.Vec.Properties \n \n index : A → Fin size\n index = Inverse.to finitude ⟨$⟩_\n\n index-injective : ∀ {x y} → index x ≡ index y → x ≡ y\n index-injective = Inverse.injective finitude\n\n enum : Fin size → A\n enum = Inverse.from finitude ⟨$⟩_\n\n enum-injective : ∀ {i j} → enum i ≡ enum j → i ≡ j\n enum-injective = Inverse.injective (Inv.sym finitude)\n\n elems : Vec A size\n elems = tabulate enum \n\n elems-distinct : Distinct elems\n elems-distinct = Distinct.tabulate (Inverse.injection (Inv.sym finitude))\n\n _∈elems : ∀ x → x ∈ elems\n x ∈elems rewrite P.sym (Inverse.left-inverse-of finitude x) = ∈-tabulate⁺ enum (index x)\n \nopen FinType ⦃ ... ⦄ using (index ; _∈elems)\n\nsize : ∀ {a} (A : Set a) ⦃ fin : FinType A ⦄ → ℕ\nsize A {{ fin }} = FinType.size fin \n\nelems : ∀ {a} (A : Set a) ⦃ fin : FinType A ⦄ → Vec A (size A)\nelems A {{ fin }} = FinType.elems fin\n\ninstance\n open import Data.Bool\n open import Data.Unit\n open import Data.Empty\n empty : FinType ⊥\n empty = record {\n size = 0\n ; finitude = record {\n to = P.→-to-⟶ λ()\n ; from = P.→-to-⟶ λ()\n ; inverse-of = record {\n left-inverse-of = λ ()\n ; right-inverse-of = λ ()\n }\n }\n }\n\n \n unit : FinType ⊤\n unit = record {\n size = 1\n ; finitude = record {\n to = P.→-to-⟶ λ _ → Fin.zero\n ; from = P.→-to-⟶ λ _ → tt\n ; inverse-of = record {\n left-inverse-of = λ _ → P.refl\n ; right-inverse-of = λ { Fin.zero → P.refl ; (Fin.suc ()) }\n }\n }\n }\n\n bool : FinType Bool\n bool = record {\n size = 2\n ; finitude = record {\n to = P.→-to-⟶ λ { false → # 0 ; true → # 1 }\n ; from = P.→-to-⟶ λ { Fin.zero → false ; (Fin.suc Fin.zero) → true ; (Fin.suc (Fin.suc ())) }\n ; inverse-of = record {\n left-inverse-of = λ { false → P.refl ; true → P.refl }\n ; right-inverse-of = λ { Fin.zero → P.refl ; (Fin.suc Fin.zero) → P.refl ; (Fin.suc (Fin.suc ())) }\n }\n }\n }\nprivate \n bools : Vec Bool _\n bools = elems Bool \n\n example : bools ≡ false ∷ true ∷ []\n example = P.refl\n", "meta": {"hexsha": "b68b39b18c7d82d0d9fc7feca2b378cbe346a60a", "size": 2916, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Finitude/FinType.agda", "max_stars_repo_name": "tizmd/agda-finitary", "max_stars_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Data/Finitude/FinType.agda", "max_issues_repo_name": "tizmd/agda-finitary", "max_issues_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/Finitude/FinType.agda", "max_forks_repo_name": "tizmd/agda-finitary", "max_forks_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.7551020408, "max_line_length": 109, "alphanum_fraction": 0.5679012346, "num_tokens": 895, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619436290698, "lm_q2_score": 0.7690802476562641, "lm_q1q2_score": 0.6340773957894099}} {"text": "module FunctorComposition where\n\nopen import Functor as F\n\ncompose : {F₁ F₂ : Setoid → Setoid} →\n Functor F₁ → Functor F₂ → Functor (λ A → F₁ (F₂ A))\ncompose {F₁} {F₂} FF₁ FF₂ = record\n { map = map FF₁ ∘ map FF₂\n ; identity = λ {A} →\n trans (F₁ (F₂ A) ⇨ F₁ (F₂ A))\n {i = map FF₁ ⟨$⟩ (map FF₂ ⟨$⟩ id)}\n {j = map FF₁ ⟨$⟩ id}\n {k = id}\n (cong (map FF₁) (identity FF₂))\n (identity FF₁)\n ; composition = λ {A B C} f g →\n trans (F₁ (F₂ A) ⇨ F₁ (F₂ C))\n {i = map FF₁ ⟨$⟩ (map FF₂ ⟨$⟩ (f ∘ g))}\n {j = map FF₁ ⟨$⟩ ((map FF₂ ⟨$⟩ f) ∘ (map FF₂ ⟨$⟩ g))}\n {k = (map FF₁ ⟨$⟩ (map FF₂ ⟨$⟩ f)) ∘\n (map FF₁ ⟨$⟩ (map FF₂ ⟨$⟩ g))}\n (cong (map FF₁) (composition FF₂ f g))\n (composition FF₁ (map FF₂ ⟨$⟩ f) (map FF₂ ⟨$⟩ g))\n }\n where\n open Setoid\n open F.Functor\n", "meta": {"hexsha": "857ca2f31d7d46dfd6622ead7e21399607d6cb1e", "size": 899, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "benchmark/misc/FunctorComposition.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "benchmark/misc/FunctorComposition.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "benchmark/misc/FunctorComposition.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 32.1071428571, "max_line_length": 65, "alphanum_fraction": 0.447163515, "num_tokens": 346, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9334308073258007, "lm_q2_score": 0.6791787056691697, "lm_q1q2_score": 0.6339663275512655}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties of sums (disjoint unions)\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Sum.Properties where\n\nopen import Level\nopen import Data.Sum.Base\nopen import Function\nopen import Relation.Binary using (Decidable)\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary using (yes; no)\nopen import Relation.Nullary.Decidable using (map′)\n\nprivate\n variable\n a b c d e f : Level\n A : Set a\n B : Set b\n C : Set c\n D : Set d\n E : Set e\n F : Set f\n\ninj₁-injective : ∀ {x y} → (A ⊎ B ∋ inj₁ x) ≡ inj₁ y → x ≡ y\ninj₁-injective refl = refl\n\ninj₂-injective : ∀ {x y} → (A ⊎ B ∋ inj₂ x) ≡ inj₂ y → x ≡ y\ninj₂-injective refl = refl\n\nmodule _ (dec₁ : Decidable {A = A} {B = A} _≡_)\n (dec₂ : Decidable {A = B} {B = B} _≡_) where\n\n ≡-dec : Decidable {A = A ⊎ B} _≡_\n ≡-dec (inj₁ x) (inj₁ y) = map′ (cong inj₁) inj₁-injective (dec₁ x y)\n ≡-dec (inj₁ x) (inj₂ y) = no λ()\n ≡-dec (inj₂ x) (inj₁ y) = no λ()\n ≡-dec (inj₂ x) (inj₂ y) = map′ (cong inj₂) inj₂-injective (dec₂ x y)\n\nswap-involutive : swap {A = A} {B = B} ∘ swap ≗ id\nswap-involutive = [ (λ _ → refl) , (λ _ → refl) ]\n\n[,]-∘-distr : {f : A → B}\n {g : C → A} {h : D → A} →\n f ∘ [ g , h ] ≗ [ f ∘ g , f ∘ h ]\n[,]-∘-distr (inj₁ _) = refl\n[,]-∘-distr (inj₂ _) = refl\n\n[,]-map-commute : {f : A → B} {g : C → D}\n {f′ : B → E} {g′ : D → E} →\n [ f′ , g′ ] ∘ (map f g) ≗ [ f′ ∘ f , g′ ∘ g ]\n[,]-map-commute (inj₁ _) = refl\n[,]-map-commute (inj₂ _) = refl\n\nmap-commute : {f : A → B} {g : C → D}\n {f′ : B → E} {g′ : D → F} →\n ((map f′ g′) ∘ (map f g)) ≗ map (f′ ∘ f) (g′ ∘ g)\nmap-commute (inj₁ _) = refl\nmap-commute (inj₂ _) = refl\n", "meta": {"hexsha": "b0c66a8a310dd364661a8b557f0016b1565f1e0c", "size": 1898, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/Sum/Properties.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Data/Sum/Properties.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Data/Sum/Properties.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 29.65625, "max_line_length": 72, "alphanum_fraction": 0.4768177028, "num_tokens": 721, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339596505965, "lm_q2_score": 0.7549149978955811, "lm_q1q2_score": 0.6339277603824781}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Semi-heterogeneous vector equality\n------------------------------------------------------------------------\n\nmodule Data.Vec.Equality where\n\nopen import Data.Vec\nopen import Data.Nat using (suc)\nopen import Function\nopen import Level using (_⊔_)\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as P using (_≡_)\n\nmodule Equality {s₁ s₂} (S : Setoid s₁ s₂) where\n\n private\n open module SS = Setoid S\n using () renaming (_≈_ to _≊_; Carrier to A)\n\n infix 4 _≈_\n\n data _≈_ : ∀ {n¹} → Vec A n¹ →\n ∀ {n²} → Vec A n² → Set (s₁ ⊔ s₂) where\n []-cong : [] ≈ []\n _∷-cong_ : ∀ {x¹ n¹} {xs¹ : Vec A n¹}\n {x² n²} {xs² : Vec A n²}\n (x¹≈x² : x¹ ≊ x²) (xs¹≈xs² : xs¹ ≈ xs²) →\n x¹ ∷ xs¹ ≈ x² ∷ xs²\n\n length-equal : ∀ {n¹} {xs¹ : Vec A n¹}\n {n²} {xs² : Vec A n²} →\n xs¹ ≈ xs² → n¹ ≡ n²\n length-equal []-cong = P.refl\n length-equal (_ ∷-cong eq₂) = P.cong suc $ length-equal eq₂\n\n refl : ∀ {n} (xs : Vec A n) → xs ≈ xs\n refl [] = []-cong\n refl (x ∷ xs) = SS.refl ∷-cong refl xs\n\n sym : ∀ {n m} {xs : Vec A n} {ys : Vec A m} →\n xs ≈ ys → ys ≈ xs\n sym []-cong = []-cong\n sym (x¹≡x² ∷-cong xs¹≈xs²) = SS.sym x¹≡x² ∷-cong sym xs¹≈xs²\n\n trans : ∀ {n m l} {xs : Vec A n} {ys : Vec A m} {zs : Vec A l} →\n xs ≈ ys → ys ≈ zs → xs ≈ zs\n trans []-cong []-cong = []-cong\n trans (x≈y ∷-cong xs≈ys) (y≈z ∷-cong ys≈zs) =\n SS.trans x≈y y≈z ∷-cong trans xs≈ys ys≈zs\n\n _++-cong_ : ∀ {n₁¹ n₂¹} {xs₁¹ : Vec A n₁¹} {xs₂¹ : Vec A n₂¹}\n {n₁² n₂²} {xs₁² : Vec A n₁²} {xs₂² : Vec A n₂²} →\n xs₁¹ ≈ xs₁² → xs₂¹ ≈ xs₂² →\n xs₁¹ ++ xs₂¹ ≈ xs₁² ++ xs₂²\n []-cong ++-cong eq₃ = eq₃\n (eq₁ ∷-cong eq₂) ++-cong eq₃ = eq₁ ∷-cong (eq₂ ++-cong eq₃)\n\nmodule DecidableEquality {d₁ d₂} (D : DecSetoid d₁ d₂) where\n\n private module DS = DecSetoid D\n open DS using () renaming (_≟_ to _≟′_ ; Carrier to A)\n open Equality DS.setoid\n open import Relation.Nullary\n\n _≟_ : ∀ {n m} (xs : Vec A n) (ys : Vec A m) → Dec (xs ≈ ys)\n _≟_ [] [] = yes []-cong\n _≟_ [] (y ∷ ys) = no (λ())\n _≟_ (x ∷ xs) [] = no (λ())\n _≟_ (x ∷ xs) (y ∷ ys) with xs ≟ ys | x ≟′ y\n ... | yes xs≈ys | yes x≊y = yes (x≊y ∷-cong xs≈ys)\n ... | no ¬xs≈ys | _ = no helper\n where\n helper : ¬ (x ∷ xs ≈ y ∷ ys)\n helper (_ ∷-cong xs≈ys) = ¬xs≈ys xs≈ys\n ... | _ | no ¬x≊y = no helper\n where\n helper : ¬ (x ∷ xs ≈ y ∷ ys)\n helper (x≊y ∷-cong _) = ¬x≊y x≊y\n\nmodule PropositionalEquality {a} {A : Set a} where\n\n open Equality (P.setoid A) public\n\n to-≡ : ∀ {n} {xs ys : Vec A n} → xs ≈ ys → xs ≡ ys\n to-≡ []-cong = P.refl\n to-≡ (P.refl ∷-cong xs¹≈xs²) = P.cong (_∷_ _) $ to-≡ xs¹≈xs²\n\n from-≡ : ∀ {n} {xs ys : Vec A n} → xs ≡ ys → xs ≈ ys\n from-≡ P.refl = refl _\n", "meta": {"hexsha": "04f58b6b09fc89acf8d0456087800d067d1e81fb", "size": 3028, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Vec/Equality.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Vec/Equality.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Vec/Equality.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.9130434783, "max_line_length": 72, "alphanum_fraction": 0.4715984148, "num_tokens": 1282, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339676722393, "lm_q2_score": 0.7549149868676284, "lm_q1q2_score": 0.63392775717759}} {"text": "{-# OPTIONS --allow-unsolved-metas #-}\n------------------------------------------------------------------------------\n------------------------------------------------------------------------------\n-- CS410 2017/18 Exercise 1 VECTORS AND FRIENDS (worth 25%)\n------------------------------------------------------------------------------\n------------------------------------------------------------------------------\n\n-- NOTE (19/9/17) This file is currently incomplete: more will arrive on\n-- GitHub.\n\n-- MARK SCHEME (transcribed from paper): the (m) numbers add up to slightly\n-- more than 25, so should be taken as the maximum number of marks losable on\n-- the exercise. In fact, I did mark it negatively, but mostly because it was\n-- done so well (with Agda's help) that it was easier to find the errors.\n\n\n------------------------------------------------------------------------------\n-- Dependencies\n------------------------------------------------------------------------------\n\nopen import CS410-Prelude\n\n\n------------------------------------------------------------------------------\n-- Vectors\n------------------------------------------------------------------------------\n\ndata Vec (X : Set) : Nat -> Set where -- like lists, but length-indexed\n [] : Vec X zero\n _,-_ : {n : Nat} -> X -> Vec X n -> Vec X (suc n)\ninfixr 4 _,-_ -- the \"cons\" operator associates to the right\n\n-- I like to use the asymmetric ,- to remind myself that the element is to\n-- the left and the rest of the list is to the right.\n\n-- Vectors are useful when there are important length-related safety\n-- properties.\n\n\n------------------------------------------------------------------------------\n-- Heads and Tails\n------------------------------------------------------------------------------\n\n-- We can rule out nasty head and tail errors by insisting on nonemptiness!\n\n--??--1.1-(2)-----------------------------------------------------------------\n\nvHead : {X : Set}{n : Nat} -> Vec X (suc n) -> X\nvHead (x ,- xs) = x\n\nvTail : {X : Set}{n : Nat} -> Vec X (suc n) -> Vec X n\nvTail (x ,- xs) = xs\n\nvHeadTailFact : {X : Set}{n : Nat}(xs : Vec X (suc n)) ->\n (vHead xs ,- vTail xs) == xs\nvHeadTailFact (x ,- xs) = refl (x ,- xs) \n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Concatenation and its Inverse\n------------------------------------------------------------------------------\n\n--??--1.2-(2)-----------------------------------------------------------------\n\n_+V_ : {X : Set}{m n : Nat} -> Vec X m -> Vec X n -> Vec X (m +N n)\n[] +V ys = ys\n(x ,- xs) +V ys = x ,- xs +V ys\ninfixr 4 _+V_\n\nvChop : {X : Set}(m : Nat){n : Nat} -> Vec X (m +N n) -> Vec X m * Vec X n\nvChop zero xs = [] , xs\nvChop (suc m) (x ,- xs) with vChop m xs\nvChop (suc m) (x ,- xs) | fst₁ , snd₁ = (x ,- fst₁) , snd₁\n\nvChopAppendFact : {X : Set}{m n : Nat}(xs : Vec X m)(ys : Vec X n) ->\n vChop m (xs +V ys) == (xs , ys)\nvChopAppendFact [] ys = refl ([] , ys)\nvChopAppendFact (x ,- xs) ys rewrite vChopAppendFact xs ys = refl ((x ,- xs) , ys)\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Map, take I\n------------------------------------------------------------------------------\n\n-- Implement the higher-order function that takes an operation on\n-- elements and does it to each element of a vector. Use recursion\n-- on the vector.\n-- Note that the type tells you the size remains the same.\n\n-- Show that if the elementwise function \"does nothing\", neither does\n-- its vMap. \"map of identity is identity\"\n\n-- Show that two vMaps in a row can be collapsed to just one, or\n-- \"composition of maps is map of compositions\"\n\n--??--1.3-(2)-----------------------------------------------------------------\n\nvMap : {X Y : Set} -> (X -> Y) -> {n : Nat} -> Vec X n -> Vec Y n\nvMap f [] = []\nvMap f (x ,- xs) = f x ,- vMap f xs\n\nvMapIdFact : {X : Set}{f : X -> X}(feq : (x : X) -> f x == x) ->\n {n : Nat}(xs : Vec X n) -> vMap f xs == xs\nvMapIdFact feq [] = refl []\nvMapIdFact feq (x ,- xs) rewrite feq x | vMapIdFact feq xs = refl (x ,- xs)\n\nvMapCpFact : (X Y Z : Set)(f : Y -> Z)(g : X -> Y)(h : X -> Z)\n (heq : (x : X) -> f (g x) == h x) ->\n {n : Nat}(xs : Vec X n) ->\n vMap f (vMap g xs) == vMap h xs\nvMapCpFact _ _ _ _ _ _ heq [] = refl []\nvMapCpFact X Y Z f g h heq (x ,- xs) rewrite heq x | vMapCpFact X Y Z f g h heq xs = refl (h x ,- vMap h xs)\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- vMap and +V\n------------------------------------------------------------------------------\n\n-- Show that if you've got two vectors of Xs and a function from X to Y,\n-- and you want to concatenate and map, it doesn't matter which you do\n-- first.\n\n--??--1.4-(1)-----------------------------------------------------------------\n\nvMap+VFact : {X Y : Set}(f : X -> Y) ->\n {m n : Nat}(xs : Vec X m)(xs' : Vec X n) ->\n vMap f (xs +V xs') == (vMap f xs +V vMap f xs')\nvMap+VFact f [] xs' = refl (vMap f xs')\nvMap+VFact f (x ,- xs) xs' rewrite vMap+VFact f xs xs' = refl _\n\n--??--------------------------------------------------------------------------\n\n-- Think about what you could prove, relating vMap with vHead, vTail, vChop...\n-- Now google \"Philip Wadler\" \"Theorems for Free\"\n\n\n------------------------------------------------------------------------------\n-- Applicative Structure (giving mapping and zipping cheaply)\n------------------------------------------------------------------------------\n\n--??--1.5-(2)-----------------------------------------------------------------\n\n-- HINT: you will need to override the default invisibility of n to do this.\nvPure : {X : Set} -> X -> {n : Nat} -> Vec X n\nvPure x {zero} = []\nvPure x {suc n} = x ,- vPure x\n\n_$V_ : {X Y : Set}{n : Nat} -> Vec (X -> Y) n -> Vec X n -> Vec Y n\n[] $V [] = []\nx ,- fs $V x₁ ,- xs = x x₁ ,- (fs $V xs)\ninfixl 3 _$V_ -- \"Application associates to the left,\n -- rather as we all did in the sixties.\" (Roger Hindley)\n\n-- Pattern matching and recursion are forbidden for the next two tasks.\n\n-- implement vMap again, but as a one-liner\nvec : {X Y : Set} -> (X -> Y) -> {n : Nat} -> Vec X n -> Vec Y n\nvec f xs = vPure f $V xs\n\n-- implement the operation which pairs up corresponding elements\nvZip : {X Y : Set}{n : Nat} -> Vec X n -> Vec Y n -> Vec (X * Y) n\nvZip [] [] = []\nvZip (x ,- xs) (x₁ ,- ys) = (x , x₁) ,- vZip xs ys\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Applicative Laws\n------------------------------------------------------------------------------\n\n-- According to \"Applicative programming with effects\" by\n-- Conor McBride and Ross Paterson\n-- some laws should hold for applicative functors.\n-- Check that this is the case.\n\n--??--1.6-(2)-----------------------------------------------------------------\n\nvIdentity : {X : Set}{f : X -> X}(feq : (x : X) -> f x == x) ->\n {n : Nat}(xs : Vec X n) -> (vPure f $V xs) == xs\nvIdentity feq [] = refl []\nvIdentity feq (x ,- xs) rewrite feq x | vIdentity feq xs = refl (x ,- xs)\n\nvHomomorphism : {X Y : Set}(f : X -> Y)(x : X) ->\n {n : Nat} -> (vPure f $V vPure x) == vPure (f x) {n}\nvHomomorphism f x {zero} = refl []\nvHomomorphism f x {suc n} rewrite vHomomorphism f x {n} = refl (f x ,- vPure (f x))\n\nvInterchange : {X Y : Set}{n : Nat}(fs : Vec (X -> Y) n)(x : X) ->\n (fs $V vPure x) == (vPure (_$ x) $V fs)\nvInterchange [] x = refl []\nvInterchange (x₁ ,- fs) x rewrite vInterchange fs x = refl _\n\nvComposition : {X Y Z : Set}{n : Nat}\n (fs : Vec (Y -> Z) n)(gs : Vec (X -> Y) n)(xs : Vec X n) ->\n (vPure _<<_ $V fs $V gs $V xs) == (fs $V (gs $V xs))\nvComposition [] [] [] = refl []\nvComposition (x₁ ,- fs) (x₂ ,- gs) (x ,- xs) rewrite vComposition fs gs xs = refl _\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Order-Preserving Embeddings (also known in the business as \"thinnings\")\n------------------------------------------------------------------------------\n\n-- What have these to do with Pascal's Triangle?\n\ndata _<=_ : Nat -> Nat -> Set where\n oz : zero <= zero\n os : {n m : Nat} -> n <= m -> suc n <= suc m\n o' : {n m : Nat} -> n <= m -> n <= suc m\n\n-- Find all the values in each of the following <= types.\n-- This is a good opportunity to learn to use C-c C-a with the -l option\n-- (a.k.a. \"google the type\" without \"I feel lucky\")\n-- The -s n option also helps.\n\n--??--1.7-(1)-----------------------------------------------------------------\n\nall0<=4 : Vec (0 <= 4) 3\nall0<=4 = o' (o' (o' (o' oz))) ,- o' (o' (o' (o' oz))) ,- o' (o' (o' (o' oz))) ,- [] \n\nall1<=4 : Vec (1 <= 4) 2\nall1<=4 = os (o' (o' (o' oz))) ,- os (o' (o' (o' oz))) ,- []\n\nall2<=4 : Vec (2 <= 4) _\nall2<=4 = os (o' (o' (os oz))) ,- os (os (o' (o' oz))) ,- []\n \nall3<=4 : Vec (3 <= 4) zero\nall3<=4 = []\n\nall4<=4 : Vec (4 <= 4) zero\nall4<=4 = []\n\n-- Prove the following. A massive case analysis \"rant\" is fine.\n\nno5<=4 : 5 <= 4 -> Zero\nno5<=4 (os (os (os (os ()))))\nno5<=4 (os (os (os (o' ()))))\nno5<=4 (os (os (o' (os ()))))\nno5<=4 (os (os (o' (o' ()))))\nno5<=4 (os (o' (os (os ()))))\nno5<=4 (os (o' (os (o' ()))))\nno5<=4 (os (o' (o' (os ()))))\nno5<=4 (os (o' (o' (o' ()))))\nno5<=4 (o' (os (os (os ()))))\nno5<=4 (o' (os (os (o' ()))))\nno5<=4 (o' (os (o' (os ()))))\nno5<=4 (o' (os (o' (o' ()))))\nno5<=4 (o' (o' (os (os ()))))\nno5<=4 (o' (o' (os (o' ()))))\nno5<=4 (o' (o' (o' (os ()))))\nno5<=4 (o' (o' (o' (o' ()))))\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Order-Preserving Embeddings Select From Vectors\n------------------------------------------------------------------------------\n\n-- Use n <= m to encode the choice of n elements from an m-Vector.\n-- The os constructor tells you to take the next element of the vector;\n-- the o' constructor tells you to omit the next element of the vector.\n\n--??--1.8-(2)-----------------------------------------------------------------\n\n_ n <= m -> Vec X m\n -> Vec X n\noz Y)\n {n m : Nat}(th : n <= m)(xs : Vec X m) ->\n vMap f (th n <= n\noi {zero} = oz\noi {suc n} = os oi\n\noe : {n : Nat} -> 0 <= n\noe {zero} = oz\noe {suc n} = o' oe\n\n--??--------------------------------------------------------------------------\n\n\n-- Show that all empty thinnings are equal to yours.\n\n--??--1.10-(1)----------------------------------------------------------------\n\noeUnique : {n : Nat}(th : 0 <= n) -> th == oe\noeUnique oz = refl oz\noeUnique (o' i) rewrite oeUnique i = refl (o' oe)\n\n--??--------------------------------------------------------------------------\n\n\n-- Show that there are no thinnings of form big <= small (TRICKY)\n-- Then show that all the identity thinnings are equal to yours.\n-- Note that you can try the second even if you haven't finished the first.\n-- HINT: you WILL need to expose the invisible numbers.\n-- HINT: check CS410-Prelude for a reminder of >=\n\n--??--1.11-(3)----------------------------------------------------------------\n\nthinMore : {n m : Nat} -> suc n <= m -> n <= m\nthinMore (os n<=m) = o' n<=m\nthinMore (o' n<=m) = o' (thinMore n<=m)\n\noTooBig : {n m : Nat} -> n >= m -> suc n <= m -> Zero\noTooBig {zero} {.(suc _)} n>=m (os th) = n>=m\noTooBig {zero} {.(suc _)} n>=m (o' th) = n>=m\noTooBig {suc n} {.(suc _)} n>=m (os th) = oTooBig n>=m th\noTooBig {suc n} {.(suc _)} n>=m (o' th) = oTooBig n>=m (thinMore th)\n\noiUnique : {n : Nat}(th : n <= n) -> th == oi\noiUnique oz = refl oz\noiUnique (os th) rewrite oiUnique th = refl (os oi)\noiUnique {m} (o' th) with oTooBig (refl->= m) th\noiUnique {.(suc _)} (o' th) | ()\n\n--??--------------------------------------------------------------------------\n\n\n-- Show that the identity thinning selects the whole vector\n\n--??--1.12-(1)----------------------------------------------------------------\n\nid- (oi >_ : {p n m : Nat} -> p <= n -> n <= m -> p <= m\nth o>> oz = th\nos th o>> os th' = os (th o>> th')\no' th o>> os th' = o' (th o>> th')\nth o>> o' th' = o' (th o>> th')\n\ncp-\n {X : Set}(xs : Vec X m) ->\n ((th o>> th') > : {n m : Nat}(th : n <= m) -> (oi o>> th) == th\nidThen-o>> oz = refl oz\nidThen-o>> (os th) rewrite idThen-o>> th = refl (os th)\nidThen-o>> (o' th) rewrite idThen-o>> th = refl (o' th)\n\nidAfter-o>> : {n m : Nat}(th : n <= m) -> (th o>> oi) == th\nidAfter-o>> oz = refl oz\nidAfter-o>> (os th) rewrite idAfter-o>> th = refl (os th)\nidAfter-o>> (o' th) rewrite idAfter-o>> th = refl (o' th)\n\nassoc-o>> : {q p n m : Nat}(th0 : q <= p)(th1 : p <= n)(th2 : n <= m) ->\n ((th0 o>> th1) o>> th2) == (th0 o>> (th1 o>> th2))\nassoc-o>> th0 th1 oz = refl (th0 o>> th1)\nassoc-o>> th0 (o' th1) (os th2) rewrite assoc-o>> th0 th1 th2 = refl (o' (th0 o>> (th1 o>> th2)))\nassoc-o>> (os th0) (os th1) (os th2) rewrite assoc-o>> th0 th1 th2 = refl (os (th0 o>> (th1 o>> th2)))\nassoc-o>> (o' th0) (os th1) (os th2) rewrite assoc-o>> th0 th1 th2 = refl (o' (th0 o>> (th1 o>> th2)))\nassoc-o>> th0 th1 (o' th2) rewrite assoc-o>> th0 th1 th2 = refl (o' (th0 o>> (th1 o>> th2)))\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Vectors as Arrays\n------------------------------------------------------------------------------\n\n-- We can use 1 <= n as the type of bounded indices into a vector and do\n-- a kind of \"array projection\". First we select a 1-element vector from\n-- the n-element vector, then we take its head to get the element out.\n\nvProject : {n : Nat}{X : Set} -> Vec X n -> 1 <= n -> X\nvProject xs i = vHead (i 1 <= (suc n)\nselectHead n = os oe\n\n-- HINT: composition of functions\nvTabulate : {n : Nat}{X : Set} -> (1 <= n -> X) -> Vec X n\nvTabulate {zero} f = []\nvTabulate {suc n} f = (f (selectHead n)) ,- (vTabulate (\\p -> f (o' p)))\n\n-- This should be easy if vTabulate is correct.\nvTabulateProjections : {n : Nat}{X : Set}(xs : Vec X n) ->\n vTabulate (vProject xs) == xs\nvTabulateProjections [] = refl []\nvTabulateProjections (x ,- xs) rewrite vTabulateProjections xs = refl (x ,- xs)\n\n-- HINT: oeUnique\nvProjectFromTable : {n : Nat}{X : Set}(f : 1 <= n -> X)(i : 1 <= n) ->\n vProject (vTabulate f) i == f i\nvProjectFromTable {.(suc _)} {X} f (os i) with oeUnique i\nvProjectFromTable {.(suc _)} {X} f (os .oe) | refl .oe = refl (f (os oe))\nvProjectFromTable {.(suc _)} {X} f (o' i) = vProjectFromTable (λ z → f (o' z)) i\n\n--??--------------------------------------------------------------------------\n", "meta": {"hexsha": "d26261938e8d52df95f0e8d18055a5d6b6b72aaa", "size": 17874, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Ex1.agda", "max_stars_repo_name": "poscat0x04/CS410", "max_stars_repo_head_hexsha": "5b20aeffeaf714769e121bc9f7aa7c25106d0a1b", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Ex1.agda", "max_issues_repo_name": "poscat0x04/CS410", "max_issues_repo_head_hexsha": "5b20aeffeaf714769e121bc9f7aa7c25106d0a1b", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Ex1.agda", "max_forks_repo_name": "poscat0x04/CS410", "max_forks_repo_head_hexsha": "5b20aeffeaf714769e121bc9f7aa7c25106d0a1b", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.1115973742, "max_line_length": 108, "alphanum_fraction": 0.4033232628, "num_tokens": 4957, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.8397339676722393, "lm_q1q2_score": 0.6339277571775899}} {"text": "-- Andreas, 2015-07-20, record patterns\n\nopen import Common.Product\nopen import Common.Prelude\nopen import Common.Equality\n\nswap : {A B : Set} (p : A × B) → B × A\nswap record{ proj₁ = a; proj₂ = b } = record{ proj₁ = b; proj₂ = a }\n\nfst : {A : Set}{B : A → Set} (p : Σ A B) → A\nfst record{ proj₁ = a } = a\n\nsnd : {A : Set}{B : A → Set} (p : Σ A B) → B (fst p)\nsnd record{ proj₂ = b } = b\n\nmodule _ (A : Set) (B : A → Set) (C : (a : A) → B a → Set) where\n\n Tr = Σ A (λ a → Σ (B a) (C a))\n\n fst3 : Tr → A\n fst3 record{ proj₁ = a } = a\n\n snd3 : (t : Tr) → B (fst3 t)\n snd3 record{ proj₂ = record { proj₁ = b }} = b\n\n thd3 : (t : Tr) → C (fst3 t) (snd3 t)\n thd3 record{ proj₂ = record { proj₂ = c }} = c\n\n thd32 : (t u : Tr) → C (fst3 t) (snd3 t)\n thd32 record{ proj₂ = record { proj₂ = c }}\n record{ proj₂ = record { proj₂ = _ }} = c\n\npostulate A : Set\n\nrecord R : Set where\n field f : A\n\nT : Bool → Set\nT true = R\nT false = A\n\n-- Postponed record pattern\ntest : ∀{b} → T b → b ≡ true → A\ntest record{f = a} refl = a\n", "meta": {"hexsha": "f3375e776cd9c565893acb993b9446547d61b7c2", "size": 1032, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/RecordPattern.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/RecordPattern.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/RecordPattern.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 22.9333333333, "max_line_length": 68, "alphanum_fraction": 0.5368217054, "num_tokens": 421, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245953120234, "lm_q2_score": 0.7606506581031359, "lm_q1q2_score": 0.63386890183762}} {"text": "module Algebra where\n\n-- Core graph construction primitives\ndata Graph (A : Set) : Set where\n ε : Graph A -- Empty graph\n v : A -> Graph A -- Graph comprising a single vertex\n _+_ : Graph A -> Graph A -> Graph A -- Overlay two graphs\n _*_ : Graph A -> Graph A -> Graph A -- Connect two graphs\n\ninfixl 4 _≡_\ninfixl 8 _+_\ninfixl 9 _*_\ninfix 10 _⊆_\n\n-- Equational theory of graphs\ndata _≡_ {A} : (x y : Graph A) -> Set where\n -- Equivalence relation\n reflexivity : ∀ {x : Graph A} -> x ≡ x\n symmetry : ∀ {x y : Graph A} -> x ≡ y -> y ≡ x\n transitivity : ∀ {x y z : Graph A} -> x ≡ y -> y ≡ z -> x ≡ z\n\n -- Congruence\n +left-congruence : ∀ {x y z : Graph A} -> x ≡ y -> x + z ≡ y + z\n +right-congruence : ∀ {x y z : Graph A} -> x ≡ y -> z + x ≡ z + y\n *left-congruence : ∀ {x y z : Graph A} -> x ≡ y -> x * z ≡ y * z\n *right-congruence : ∀ {x y z : Graph A} -> x ≡ y -> z * x ≡ z * y\n\n -- Axioms of +\n +commutativity : ∀ {x y : Graph A} -> x + y ≡ y + x\n +associativity : ∀ {x y z : Graph A} -> x + (y + z) ≡ (x + y) + z\n\n -- Axioms of *\n *left-identity : ∀ {x : Graph A} -> ε * x ≡ x\n *right-identity : ∀ {x : Graph A} -> x * ε ≡ x\n *associativity : ∀ {x y z : Graph A} -> x * (y * z) ≡ (x * y) * z\n\n -- Other axioms\n left-distributivity : ∀ {x y z : Graph A} -> x * (y + z) ≡ x * y + x * z\n right-distributivity : ∀ {x y z : Graph A} -> (x + y) * z ≡ x * z + y * z\n decomposition : ∀ {x y z : Graph A} -> x * y * z ≡ x * y + x * z + y * z\n\n-- Subgraph relation\n_⊆_ : ∀ {A} -> Graph A -> Graph A -> Set\nx ⊆ y = x + y ≡ y\n", "meta": {"hexsha": "231a43654a6cd07684fac0cbc45573f79f9f058d", "size": 1717, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Algebra.agda", "max_stars_repo_name": "asr/alga", "max_stars_repo_head_hexsha": "01f5f9f53ea81f692215300744aa77e26d8bf332", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Algebra.agda", "max_issues_repo_name": "asr/alga", "max_issues_repo_head_hexsha": "01f5f9f53ea81f692215300744aa77e26d8bf332", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Algebra.agda", "max_forks_repo_name": "asr/alga", "max_forks_repo_head_hexsha": "01f5f9f53ea81f692215300744aa77e26d8bf332", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.1555555556, "max_line_length": 85, "alphanum_fraction": 0.4566103669, "num_tokens": 659, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357701094303, "lm_q2_score": 0.7310585786300048, "lm_q1q2_score": 0.6338539377175717}} {"text": "{-# OPTIONS --no-universe-polymorphism #-}\nopen import Induction.WellFounded as WF\nopen import Induction.Nat\nopen import Relation.Binary.Core hiding (Total)\nopen import Relation.Unary as U using (Decidable)\nopen import Relation.Nullary\nopen import Function using (_on_)\nopen import Data.Nat\nimport Level as L using (zero)\nopen import Data.List\n\nopen import BagEquality\n\n\nmodule Lists where\n\ninfixr 8 _ α ≡ β -> Set α -> Set β\nCoerce′ refl = id\n\ncoerce′ : ∀ {α β} {A : Set α} -> (q : α ≡ β) -> A -> Coerce′ q A\ncoerce′ refl = id\n\nuncoerce′ : ∀ {α β} {A : Set α} -> (q : α ≡ β) -> Coerce′ q A -> A\nuncoerce′ refl = id\n\ninspectUncoerce′ : ∀ {α β} {A : Set α}\n -> (q : α ≡ β) -> (p : Coerce′ q A) -> ∃ λ x -> p ≡ coerce′ q x\ninspectUncoerce′ refl x = x , refl\n\nsplit : ∀ {α β γ δ} {A : Set α} {B : A -> Set β} {C : Set γ}\n -> (q : α ⊔ β ≡ δ) -> Coerce′ q (Σ A B) -> (∀ x -> B x -> C) -> C\nsplit q p g = uncurry g (uncoerce′ q p)\n\ndecCoerce′ : ∀ {α β} {A : Set α} -> (q : α ≡ β) -> IsSet A -> IsSet (Coerce′ q A)\ndecCoerce′ refl = id\n\ndata Coerce {β} : ∀ {α} -> α ≡ β -> Set α -> Set β where\n coerce : ∀ {A} -> A -> Coerce refl A\n\nqcoerce : ∀ {α β} {A : Set α} {q : α ≡ β} -> A -> Coerce q A\nqcoerce {q = refl} = coerce\n", "meta": {"hexsha": "db8e9fca435ac642408830fa94125050bc08981d", "size": 1047, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Generic/Lib/Equality/Coerce.agda", "max_stars_repo_name": "turion/Generic", "max_stars_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 30, "max_stars_repo_stars_event_min_datetime": "2016-07-19T21:10:54.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T10:19:38.000Z", "max_issues_repo_path": "src/Generic/Lib/Equality/Coerce.agda", "max_issues_repo_name": "turion/Generic", "max_issues_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2017-04-06T18:58:09.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-04T15:43:14.000Z", "max_forks_repo_path": "src/Generic/Lib/Equality/Coerce.agda", "max_forks_repo_name": "turion/Generic", "max_forks_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2017-07-17T07:23:39.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-27T12:57:09.000Z", "avg_line_length": 31.7272727273, "max_line_length": 81, "alphanum_fraction": 0.5272206304, "num_tokens": 424, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916099737807, "lm_q2_score": 0.7341195152660687, "lm_q1q2_score": 0.6338326301987425}} {"text": "module FFI.Data.Either where\n\n{-# FOREIGN GHC import qualified Data.Either #-}\n\ndata Either (A B : Set) : Set where\n Left : A → Either A B\n Right : B → Either A B\n{-# COMPILE GHC Either = data Data.Either.Either (Data.Either.Left|Data.Either.Right) #-}\n\nswapLR : ∀ {A B} → Either A B → Either B A\nswapLR (Left x) = Right x\nswapLR (Right x) = Left x\n\nmapL : ∀ {A B C} → (A → B) → Either A C → Either B C\nmapL f (Left x) = Left (f x)\nmapL f (Right x) = Right x\n\nmapR : ∀ {A B C} → (B → C) → Either A B → Either A C\nmapR f (Left x) = Left x\nmapR f (Right x) = Right (f x)\n\nmapLR : ∀ {A B C D} → (A → B) → (C → D) → Either A C → Either B D\nmapLR f g (Left x) = Left (f x)\nmapLR f g (Right x) = Right (g x)\n\ncond : ∀ {A B C : Set} → (A → C) → (B → C) → (Either A B) → C\ncond f g (Left x) = f x\ncond f g (Right x) = g x\n", "meta": {"hexsha": "8a5d3e6655a47f74c8514c7947dc52f9f6d41ca7", "size": 816, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "prototyping/FFI/Data/Either.agda", "max_stars_repo_name": "TheGreatSageEqualToHeaven/luau", "max_stars_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-05T21:53:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-05T21:53:03.000Z", "max_issues_repo_path": "prototyping/FFI/Data/Either.agda", "max_issues_repo_name": "TheGreatSageEqualToHeaven/luau", "max_issues_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "prototyping/FFI/Data/Either.agda", "max_forks_repo_name": "TheGreatSageEqualToHeaven/luau", "max_forks_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.1379310345, "max_line_length": 89, "alphanum_fraction": 0.5698529412, "num_tokens": 316, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972818382005, "lm_q2_score": 0.7279754607093178, "lm_q1q2_score": 0.6337734573384438}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties related to addition of integers\n------------------------------------------------------------------------\n\nmodule Data.Integer.Addition.Properties where\n\nopen import Algebra\nimport Algebra.FunctionProperties\nopen import Algebra.Structures\nopen import Data.Integer hiding (suc)\nopen import Data.Nat using (suc; zero) renaming (_+_ to _ℕ+_)\nimport Data.Nat.Properties as ℕ\nopen import Relation.Binary.PropositionalEquality\n\nopen Algebra.FunctionProperties (_≡_ {A = ℤ})\nopen CommutativeSemiring ℕ.commutativeSemiring\n using (+-comm; +-assoc; +-identity)\n\n------------------------------------------------------------------------\n-- Addition and zero form a commutative monoid\n\nprivate\n\n comm : Commutative _+_\n comm -[1+ a ] -[1+ b ] rewrite +-comm a b = refl\n comm (+ a ) (+ b ) rewrite +-comm a b = refl\n comm -[1+ _ ] (+ _ ) = refl\n comm (+ _ ) -[1+ _ ] = refl\n\n identityˡ : LeftIdentity (+ 0) _+_\n identityˡ -[1+ _ ] = refl\n identityˡ (+ _ ) = refl\n\n identityʳ : RightIdentity (+ 0) _+_\n identityʳ x rewrite comm x (+ 0) = identityˡ x\n\n distribˡ-⊖-+-neg : ∀ a b c → b ⊖ c + -[1+ a ] ≡ b ⊖ (suc c ℕ+ a)\n distribˡ-⊖-+-neg _ zero zero = refl\n distribˡ-⊖-+-neg _ zero (suc _) = refl\n distribˡ-⊖-+-neg _ (suc _) zero = refl\n distribˡ-⊖-+-neg a (suc b) (suc c) = distribˡ-⊖-+-neg a b c\n\n distribʳ-⊖-+-neg : ∀ a b c → -[1+ a ] + (b ⊖ c) ≡ b ⊖ (suc a ℕ+ c)\n distribʳ-⊖-+-neg a b c\n rewrite comm -[1+ a ] (b ⊖ c)\n | distribˡ-⊖-+-neg a b c\n | +-comm a c\n = refl\n\n distribˡ-⊖-+-pos : ∀ a b c → b ⊖ c + + a ≡ b ℕ+ a ⊖ c\n distribˡ-⊖-+-pos _ zero zero = refl\n distribˡ-⊖-+-pos _ zero (suc _) = refl\n distribˡ-⊖-+-pos _ (suc _) zero = refl\n distribˡ-⊖-+-pos a (suc b) (suc c) = distribˡ-⊖-+-pos a b c\n\n distribʳ-⊖-+-pos : ∀ a b c → + a + (b ⊖ c) ≡ a ℕ+ b ⊖ c\n distribʳ-⊖-+-pos a b c\n rewrite comm (+ a) (b ⊖ c)\n | distribˡ-⊖-+-pos a b c\n | +-comm a b\n = refl\n\n assoc : Associative _+_\n assoc (+ zero) y z rewrite identityˡ y | identityˡ (y + z) = refl\n assoc x (+ zero) z rewrite identityʳ x | identityˡ z = refl\n assoc x y (+ zero) rewrite identityʳ (x + y) | identityʳ y = refl\n assoc -[1+ a ] -[1+ b ] (+ suc c) = sym (distribʳ-⊖-+-neg a c b)\n assoc -[1+ a ] (+ suc b) (+ suc c) = distribˡ-⊖-+-pos (suc c) b a\n assoc (+ suc a) -[1+ b ] -[1+ c ] = distribˡ-⊖-+-neg c a b\n assoc (+ suc a) -[1+ b ] (+ suc c)\n rewrite distribˡ-⊖-+-pos (suc c) a b\n | distribʳ-⊖-+-pos (suc a) c b\n | sym (+-assoc a 1 c)\n | +-comm a 1\n = refl\n assoc (+ suc a) (+ suc b) -[1+ c ]\n rewrite distribʳ-⊖-+-pos (suc a) b c\n | sym (+-assoc a 1 b)\n | +-comm a 1\n = refl\n assoc -[1+ a ] -[1+ b ] -[1+ c ]\n rewrite sym (+-assoc a 1 (b ℕ+ c))\n | +-comm a 1\n | +-assoc a b c\n = refl\n assoc -[1+ a ] (+ suc b) -[1+ c ]\n rewrite distribʳ-⊖-+-neg a b c\n | distribˡ-⊖-+-neg c b a\n = refl\n assoc (+ suc a) (+ suc b) (+ suc c)\n rewrite +-assoc (suc a) (suc b) (suc c)\n = refl\n\n isSemigroup : IsSemigroup _≡_ _+_\n isSemigroup = record\n { isEquivalence = isEquivalence\n ; assoc = assoc\n ; ∙-cong = cong₂ _+_\n }\n\n isCommutativeMonoid : IsCommutativeMonoid _≡_ _+_ (+ 0)\n isCommutativeMonoid = record\n { isSemigroup = isSemigroup\n ; identityˡ = identityˡ\n ; comm = comm\n }\n\ncommutativeMonoid : CommutativeMonoid _ _\ncommutativeMonoid = record\n { Carrier = ℤ\n ; _≈_ = _≡_\n ; _∙_ = _+_\n ; ε = + 0\n ; isCommutativeMonoid = isCommutativeMonoid\n }\n", "meta": {"hexsha": "d4cd9c311f5743ab0cdab3bb2b8a63f1578051d9", "size": 3818, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Integer/Addition/Properties.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Integer/Addition/Properties.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Integer/Addition/Properties.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.3559322034, "max_line_length": 73, "alphanum_fraction": 0.4994761655, "num_tokens": 1430, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972616934408, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.6337734375355752}} {"text": "------------------------------------------------------------------------------\n-- Properties of the divisibility relation\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule LTC-PCF.Data.Nat.Divisibility.By0.Properties where\n\nopen import Common.FOL.Relation.Binary.EqReasoning\n\nopen import LTC-PCF.Base\nopen import LTC-PCF.Base.Properties\nopen import LTC-PCF.Data.Nat\nopen import LTC-PCF.Data.Nat.Properties\nopen import LTC-PCF.Data.Nat.Divisibility.By0\nopen import LTC-PCF.Data.Nat.Inequalities\nopen import LTC-PCF.Data.Nat.Inequalities.Properties\nopen import LTC-PCF.Data.Nat.Properties\nopen import LTC-PCF.Data.Nat.UnaryNumbers\nopen import LTC-PCF.Data.Nat.UnaryNumbers.Totality\n\n------------------------------------------------------------------------------\n-- Any positive number divides 0.\nS∣0 : ∀ {n} → N n → succ₁ n ∣ zero\nS∣0 {n} Nn = zero , nzero , sym (*-leftZero (succ₁ n))\n\n-- 0 divides 0.\n0∣0 : zero ∣ zero\n0∣0 = zero , nzero , sym (*-leftZero zero)\n\n-- The divisibility relation is reflexive.\n∣-refl : ∀ {n} → N n → n ∣ n\n∣-refl {n} Nn = [1] , 1-N , sym (*-leftIdentity Nn)\n\n-- If x divides y and z then x divides y ∸ z.\nx∣y→x∣z→x∣y∸z-helper : ∀ {m n o k k'} → N m → N k → N k' →\n n ≡ k * m →\n o ≡ k' * m →\n n ∸ o ≡ (k ∸ k') * m\nx∣y→x∣z→x∣y∸z-helper Nm Nk Nk' refl refl = sym (*∸-leftDistributive Nk Nk' Nm)\n\nx∣y→x∣z→x∣y∸z : ∀ {m n o} → N m → N n → N o → m ∣ n → m ∣ o → m ∣ n ∸ o\nx∣y→x∣z→x∣y∸z Nm Nn No (k , Nk , h₁) (k' , Nk' , h₂) =\n k ∸ k' , ∸-N Nk Nk' , x∣y→x∣z→x∣y∸z-helper Nm Nk Nk' h₁ h₂\n\n-- If x divides y and z then x divides y + z.\nx∣y→x∣z→x∣y+z-helper : ∀ {m n o k k'} → N m → N k → N k' →\n n ≡ k * m →\n o ≡ k' * m →\n n + o ≡ (k + k') * m\nx∣y→x∣z→x∣y+z-helper Nm Nk Nk' refl refl = sym (*+-leftDistributive Nk Nk' Nm)\n\nx∣y→x∣z→x∣y+z : ∀ {m n o} → N m → N n → N o → m ∣ n → m ∣ o → m ∣ n + o\nx∣y→x∣z→x∣y+z Nm Nn No (k , Nk , h₁) (k' , Nk' , h₂) =\n k + k' , +-N Nk Nk' , x∣y→x∣z→x∣y+z-helper Nm Nk Nk' h₁ h₂\n\n-- If x divides y and y is positive, then x ≤ y.\nx∣S→x≤S : ∀ {m n} → N m → N n → m ∣ (succ₁ n) → m ≤ succ₁ n\nx∣S→x≤S {m} Nm Nn (.zero , nzero , Sn≡0*m) =\n ⊥-elim (0≢S (trans (sym (*-leftZero m)) (sym Sn≡0*m)))\nx∣S→x≤S {m} Nm Nn (.(succ₁ k) , nsucc {k} Nk , Sn≡Sk*m) =\n subst (λ t₁ → m ≤ t₁)\n (sym Sn≡Sk*m)\n (subst (λ t₂ → m ≤ t₂)\n (sym (*-Sx k m))\n (x≤x+y Nm (*-N Nk Nm)))\n\n0∣x→x≡0 : ∀ {m} → N m → zero ∣ m → m ≡ zero\n0∣x→x≡0 nzero _ = refl\n0∣x→x≡0 (nsucc {m} Nm) (k , Nk , Sm≡k*0) =\n ⊥-elim (0≢S (trans (sym (*-leftZero k))\n (trans (*-comm nzero Nk) (sym Sm≡k*0))))\n", "meta": {"hexsha": "1ee9d99af0b2fb32ef3ef52d2ad0c8d66e0910cc", "size": 2933, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/LTC-PCF/Data/Nat/Divisibility/By0/Properties.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/LTC-PCF/Data/Nat/Divisibility/By0/Properties.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/LTC-PCF/Data/Nat/Divisibility/By0/Properties.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 38.5921052632, "max_line_length": 78, "alphanum_fraction": 0.4742584385, "num_tokens": 1194, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.815232489352, "lm_q2_score": 0.7772998714925403, "lm_q1q2_score": 0.6336801092098533}} {"text": "\nmodule Screen where\n\nimport Data.Nat\nimport Data.Bool\nimport Data.List\nimport Logic.Base\n\nopen Data.Bool\nopen Data.List\nopen Data.Nat\nopen Logic.Base\n\n-- Ranges -----------------------------------------------------------------\n\ndata Range : Set where\n range : Nat -> Nat -> Range\n\ninRange : Range -> Nat -> Bool\ninRange (range lo hi) x = lo ≤ x && x ≤ hi\n\nlow : Range -> Nat\nlow (range lo _) = lo\n\nhigh : Range -> Nat\nhigh (range _ hi) = hi\n\nsize : Range -> Nat\nsize (range lo hi) = suc hi - lo\n\nenumerate : Range -> List Nat\nenumerate (range lo hi) = enum lo hi\n where\n list : Nat -> Nat -> List Nat\n list _ 0 = []\n list k (suc n) = k :: list (suc k) n\n\n enum : Nat -> Nat -> List Nat\n enum lo hi = map (_+_ lo) (list 0 (suc hi - lo))\n\n-- The screen example -----------------------------------------------------\n\nxRange : Range\nxRange = range 0 79\n\nyRange : Range\nyRange = range 0 24\n\nscreenRange : Range\nscreenRange = range 0xb8000 0xb87ff\n\n-- Converting (x,y) to addr\n\nplot : Nat -> Nat -> Nat\nplot x y = low screenRange + x + size xRange * y\n\n-- The property\n\nforAll : Range -> (Nat -> Bool) -> Bool\nforAll r p = foldr (\\n b -> p n && b) true (enumerate r)\n\nprop : Bool\nprop = forAll xRange \\x ->\n forAll yRange \\y ->\n inRange screenRange (plot x y)\n\nproof : IsTrue prop\nproof = tt\n\n", "meta": {"hexsha": "98058b84023e9d51c1c8ed205ddb37d652eeaaff", "size": 1323, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/Screen.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/Screen.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/outdated-and-incorrect/Screen.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 18.9, "max_line_length": 75, "alphanum_fraction": 0.5638699924, "num_tokens": 388, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.901920681802153, "lm_q2_score": 0.7025300573952052, "lm_q1q2_score": 0.6336263883523892}} {"text": "{-# OPTIONS --safe #-}\n\nmodule Ferros.Prelude where\n\nopen import Relation.Binary.PropositionalEquality\nopen import Data.Nat\nopen import Data.Nat.Properties\nopen import Data.Bool hiding (_≤_)\n\nℕ-sub : (x y : ℕ) → (y ≤ x) → ℕ\nℕ-sub x .zero z≤n = x\nℕ-sub ._ ._ (s≤s p) = ℕ-sub _ _ p\n\ninvert-ℕ-sub : ∀ x y → (p : y ≤ x) → (ℕ-sub x y p) + y ≡ x\ninvert-ℕ-sub x .zero z≤n = +-identityʳ x\ninvert-ℕ-sub (suc x) (suc y) (s≤s p) = begin\n (ℕ-sub (suc x) (suc y) (s≤s p)) + suc y ≡⟨ +-suc (ℕ-sub (suc x) (suc y) (s≤s p)) y ⟩\n suc ((ℕ-sub (suc x) (suc y) (s≤s p)) + y) ≡⟨ cong suc (invert-ℕ-sub x y p) ⟩\n suc x\n ∎ where open ≡-Reasoning\n", "meta": {"hexsha": "931c81371fb1b76092050b0803b6df919f9fbd74", "size": 629, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Ferros/Prelude.agda", "max_stars_repo_name": "auxoncorp/ferros-spec", "max_stars_repo_head_hexsha": "8759d36ac9ec24c53f226a60fa3811eb1d4e5d93", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-09-11T01:06:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-27T23:18:55.000Z", "max_issues_repo_path": "Ferros/Prelude.agda", "max_issues_repo_name": "auxoncorp/ferros-spec", "max_issues_repo_head_hexsha": "8759d36ac9ec24c53f226a60fa3811eb1d4e5d93", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Ferros/Prelude.agda", "max_forks_repo_name": "auxoncorp/ferros-spec", "max_forks_repo_head_hexsha": "8759d36ac9ec24c53f226a60fa3811eb1d4e5d93", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.9523809524, "max_line_length": 88, "alphanum_fraction": 0.5786963434, "num_tokens": 289, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9019206712569267, "lm_q2_score": 0.7025300573952052, "lm_q1q2_score": 0.6336263809440508}} {"text": "{-# OPTIONS --rewriting --without-K #-}\n\nopen import Agda.Primitive\nopen import Prelude\nimport GSeTT.Typed-Syntax\nimport Globular-TT.Syntax\n\n\n\n{- Type theory for globular sets -}\nmodule Globular-TT.Eqdec-syntax {l}\n (index : Set l) (eqdec-index : eqdec index) where\n\n open import Globular-TT.Syntax index\n\n eqdec-Ty : eqdec Pre-Ty\n eqdec-Tm : eqdec Pre-Tm\n eqdec-Sub : eqdec Pre-Sub\n\n eqdec-Ty ∗ ∗ = inl idp\n eqdec-Ty ∗ (⇒ _ _ _) = inr λ{()}\n eqdec-Ty (⇒ _ _ _ ) ∗ = inr λ{()}\n eqdec-Ty (⇒ A t u) (⇒ B t' u') with eqdec-Ty A B | eqdec-Tm t t' | eqdec-Tm u u'\n ... | inl idp | inl idp | inl idp = inl idp\n ... | inr A≠B | _ | _ = inr λ{idp → A≠B idp}\n ... | inl idp | inr t≠t' | _ = inr λ eq → t≠t' (snd (fst (=⇒ eq)))\n ... | inl idp | inl idp | inr u≠u' = inr λ eq → u≠u' (snd (=⇒ eq))\n eqdec-Tm (Var x) (Var y) with eqdecℕ x y\n ... | inl idp = inl idp\n ... | inr x≠y = inr λ {idp → x≠y idp}\n eqdec-Tm (Var _) (Tm-constructor _ _) = inr λ{()}\n eqdec-Tm (Tm-constructor _ _) (Var _) = inr λ{()}\n eqdec-Tm (Tm-constructor i γ) (Tm-constructor i' γ') with eqdec-index i i' | eqdec-Sub γ γ'\n ... | inl idp | inl idp = inl idp\n ... | inr i≠i' | _ = inr λ{idp → i≠i' idp}\n ... | inl idp | inr γ≠γ' = inr λ eq → γ≠γ' (snd (=Tm-constructor eq))\n eqdec-Sub <> <> = inl idp\n eqdec-Sub < _ , _ ↦ _ > <> = inr λ{()}\n eqdec-Sub <> < _ , _ ↦ _ > = inr λ{()}\n eqdec-Sub < γ , x ↦ t > < γ' , y ↦ t' > with eqdec-Sub γ γ' | eqdecℕ x y | eqdec-Tm t t'\n ... | inl idp | inl idp | inl idp = inl idp\n ... | inr γ≠γ' | _ | _ = inr λ{idp → γ≠γ' idp}\n ... | inl idp | inr x≠y | _ = inr λ eq → x≠y (snd (fst (=<,> eq)))\n ... | inl idp | inl idp | inr t≠t' = inr λ eq → t≠t' (snd (=<,> eq))\n\n\n", "meta": {"hexsha": "0c3ac1080b8ca7b244023c9d6819e505d330a22f", "size": 2145, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Globular-TT/Eqdec-syntax.agda", "max_stars_repo_name": "thibautbenjamin/catt-formalization", "max_stars_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Globular-TT/Eqdec-syntax.agda", "max_issues_repo_name": "thibautbenjamin/catt-formalization", "max_issues_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Globular-TT/Eqdec-syntax.agda", "max_forks_repo_name": "thibautbenjamin/catt-formalization", "max_forks_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.6382978723, "max_line_length": 121, "alphanum_fraction": 0.4228438228, "num_tokens": 804, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9019206712569267, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.6336263753267658}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import Numbers.Integers.RingStructure.Ring\nopen import Semirings.Definition\nopen import Rings.Orders.Partial.Definition\nopen import Rings.Orders.Total.Definition\nopen import Orders.Total.Definition\nopen import Orders.Partial.Definition\nopen import Setoids.Orders.Total.Definition\n\nmodule Numbers.Integers.Order where\n\ninfix 5 _100 : 100' + 11' ∸ 10' > 100'\n 100+11>100 : 100' + 11' > 100'\n{-# ATP prove 100+11∸10>100 101≡100+11∸10 #-}\n{-# ATP prove 100+11>100 111≡100+11 #-}\n\npostulate\n 99+11>100 : 99' + 11' > 100'\n 98+11>100 : 98' + 11' > 100'\n 97+11>100 : 97' + 11' > 100'\n 96+11>100 : 96' + 11' > 100'\n 95+11>100 : 95' + 11' > 100'\n 94+11>100 : 94' + 11' > 100'\n 93+11>100 : 93' + 11' > 100'\n 92+11>100 : 92' + 11' > 100'\n 91+11>100 : 91' + 11' > 100'\n 90+11>100 : 90' + 11' > 100'\n{-# ATP prove 99+11>100 110≡99+11 #-}\n{-# ATP prove 98+11>100 109≡98+11 #-}\n{-# ATP prove 97+11>100 108≡97+11 #-}\n{-# ATP prove 96+11>100 107≡96+11 #-}\n{-# ATP prove 95+11>100 106≡95+11 #-}\n{-# ATP prove 94+11>100 105≡94+11 #-}\n{-# ATP prove 93+11>100 104≡93+11 #-}\n{-# ATP prove 92+11>100 103≡92+11 #-}\n{-# ATP prove 91+11>100 102≡91+11 #-}\n{-# ATP prove 90+11>100 101≡90+11 #-}\n\nx+11-N : ∀ {n} → N n → N (n + 11')\nx+11-N Nn = +-N Nn 11-N\n\nx+11∸10≡Sx : ∀ {n} → N n → n + 11' ∸ 10' ≡ succ₁ n\nx+11∸10≡Sx Nn = [x+Sy]∸y≡Sx Nn 10-N\n\npostulate x+1≤x∸10+11 : ∀ {n} → N n → n + 1' ≤ (n ∸ 10') + 11'\n{-# ATP prove x+1≤x∸10+11 x≤y+x∸y 10-N 11-N +-N ∸-N +-comm #-}\n\npostulate x≤89→x+11≯100 : ∀ {n} → N n → n ≤ 89' → n + 11' ≯ 100'\n{-# ATP prove x≤89→x+11≯100 x≤y→x≯y x≤y→x+k≤y+k x+11-N 89-N 100-N 100≡89+11 #-}\n", "meta": {"hexsha": "00dd8bab4c26ba465e87022aca8a275bf6987657", "size": 3219, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/FOTC/Program/McCarthy91/ArithmeticATP.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/FOTC/Program/McCarthy91/ArithmeticATP.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/FOTC/Program/McCarthy91/ArithmeticATP.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 30.0841121495, "max_line_length": 79, "alphanum_fraction": 0.4889717304, "num_tokens": 1467, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772318846386, "lm_q2_score": 0.7248702702332475, "lm_q1q2_score": 0.6335925992809469}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Algebra\nopen import Relation.Unary\nopen import Relation.Binary hiding (Decidable)\n\nmodule Data.FingerTree.Split.Point\n {r m}\n (ℳ : Monoid r m)\n {s}\n {ℙ : Pred (Monoid.Carrier ℳ) s}\n (ℙ-resp : ℙ Respects (Monoid._≈_ ℳ))\n (ℙ? : Decidable ℙ)\n where\n\nopen import Relation.Nullary using (¬_; yes; no; Dec)\nopen import Level using (_⊔_)\nopen import Data.Product\nopen import Function\nopen import Data.List as List using (List; _∷_; [])\n\nopen import Data.FingerTree.Measures ℳ\nopen import Data.FingerTree.Reasoning ℳ\n\nopen import Relation.Nullary using (Dec; yes; no)\nopen import Relation.Nullary.Decidable using (True; toWitness; False; toWitnessFalse)\n\nopen σ ⦃ ... ⦄\n\nopen Monoid ℳ renaming (Carrier to 𝓡)\n\nopen import Data.FingerTree.Relation.Binary.Reasoning.FasterInference.Setoid setoid\n\ninfixr 5 _∣_\nrecord _∣_ (left focus : 𝓡) : Set s where\n constructor ¬[_]ℙ[_]\n field\n ¬ℙ : ¬ ℙ left\n !ℙ : ℙ (left ∙ focus)\nopen _∣_ public\n\n_∣?_ : ∀ x y → Dec (x ∣ y)\nx ∣? y with ℙ? x\n... | yes p = no λ c → ¬ℙ c p\n... | no ¬p with ℙ? (x ∙ y)\n... | no ¬c = no (¬c ∘ !ℙ)\n... | yes p = yes ¬[ ¬p ]ℙ[ p ]\n\ninfixl 2 _≈◄⟅_⟆ _≈▻⟅_⟆ _≈⟅_∣_⟆ _◄_ _▻_\n_◄_ : ∀ {l f₁ f₂} → l ∣ f₁ ∙ f₂ → ¬ ℙ (l ∙ f₁) → (l ∙ f₁) ∣ f₂\n!ℙ (p ◄ ¬ℙf) = ℙ-resp (sym (assoc _ _ _)) (!ℙ p)\n¬ℙ (p ◄ ¬ℙf) = ¬ℙf\n\n_▻_ : ∀ {l f₁ f₂} → l ∣ f₁ ∙ f₂ → ℙ (l ∙ f₁) → l ∣ f₁\n!ℙ (p ▻ ℙf) = ℙf\n¬ℙ (p ▻ ℙf) = ¬ℙ p\n\n_≈◄⟅_⟆ : ∀ {x y z} → x ∣ y → x ≈ z → z ∣ y\n¬ℙ (x⟅y⟆ ≈◄⟅ x≈z ⟆) = ¬ℙ x⟅y⟆ ∘ ℙ-resp (sym x≈z)\n!ℙ (x⟅y⟆ ≈◄⟅ x≈z ⟆) = ℙ-resp (≪∙ x≈z) (!ℙ x⟅y⟆)\n\n_≈▻⟅_⟆ : ∀ {x y z} → x ∣ y → y ≈ z → x ∣ z\n¬ℙ (x⟅y⟆ ≈▻⟅ y≈z ⟆) = ¬ℙ x⟅y⟆\n!ℙ (x⟅y⟆ ≈▻⟅ y≈z ⟆) = ℙ-resp (∙≫ y≈z) (!ℙ x⟅y⟆)\n\n_≈⟅_∣_⟆ : ∀ {x₁ y₁ x₂ y₂} → x₁ ∣ y₁ → x₁ ≈ x₂ → y₁ ≈ y₂ → x₂ ∣ y₂\n¬ℙ (x⟅y⟆ ≈⟅ x≈ ∣ y≈ ⟆) = ¬ℙ x⟅y⟆ ∘ ℙ-resp (sym x≈)\n!ℙ (x⟅y⟆ ≈⟅ x≈ ∣ y≈ ⟆) = ℙ-resp (∙-cong x≈ y≈) (!ℙ x⟅y⟆)\n\n¬∄ℙ : ∀ {i} → ¬ (i ∣ ε)\n¬∄ℙ i⟅ε⟆ = ¬ℙ i⟅ε⟆ (ℙ-resp (identityʳ _) (!ℙ i⟅ε⟆))\n", "meta": {"hexsha": "1c8639b49402fe61ef4ce3b723d180ac2a043c7d", "size": 1927, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/FingerTree/Split/Point.agda", "max_stars_repo_name": "oisdk/agda-indexed-fingertree", "max_stars_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-02-26T07:04:54.000Z", "max_stars_repo_stars_event_max_datetime": "2019-02-26T07:04:54.000Z", "max_issues_repo_path": "src/Data/FingerTree/Split/Point.agda", "max_issues_repo_name": "oisdk/agda-indexed-fingertree", "max_issues_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/FingerTree/Split/Point.agda", "max_forks_repo_name": "oisdk/agda-indexed-fingertree", "max_forks_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.7638888889, "max_line_length": 85, "alphanum_fraction": 0.5313959523, "num_tokens": 1075, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8976952838963489, "lm_q2_score": 0.7057850402140659, "lm_q1q2_score": 0.6335799020447619}} {"text": "module Structure.Categorical.Names where\n\nimport Lvl\nopen import Functional using (const ; swap)\nopen import Logic\nopen import Structure.Setoid\nimport Structure.Operator.Names as Names\nimport Structure.Relator.Names as Names\nopen import Type\n\nprivate variable ℓₒ ℓₘ ℓₑ : Lvl.Level\nprivate variable Obj : Type{ℓₒ}\nprivate variable x y z w : Obj\n\n-- Obj is the collection of objects.\n-- _⟶_ is the collection of morphisms.\nmodule _ (Morphism : Obj → Obj → Type{ℓₘ}) where\n -- A morphism is an endomorphism when the domain and the codomain are equal.\n -- Something which morphs itself (referring to the object).\n Endomorphism : Obj → Stmt{ℓₘ}\n Endomorphism a = Morphism a a\n\n module ArrowNotation where\n _⟶_ : Obj → Obj → Type{ℓₘ}\n _⟶_ = Morphism\n\n -- Reversed arrow\n _⟵_ : Obj → Obj → Type{ℓₘ}\n _⟵_ = swap(_⟶_)\n\n -- Self-pointing arrow\n ⟲_ : Obj → Type{ℓₘ}\n ⟲_ = Endomorphism\n\nmodule Morphism where\n module _ (Morphism : Obj → Obj → Type{ℓₘ}) where\n open ArrowNotation(Morphism)\n\n -- The domain of a morphism\n dom : ∀{x y : Obj} → Morphism(x)(y) → Obj\n dom{x}{_} (_) = x\n\n -- The codomain of a morphism\n codom : ∀{x y : Obj} → Morphism(x)(y) → Obj\n codom{_}{y} (_) = y\n\n module _ {Morphism : Obj → Obj → Type{ℓₘ}} ⦃ equiv-morphism : ∀{x y} → Equiv{ℓₑ}(Morphism x y) ⦄ where\n open ArrowNotation(Morphism)\n\n module _ (_▫_ : Names.SwappedTransitivity(_⟶_)) where\n Associativity : Stmt\n Associativity = ∀{x y z w : Obj} → Names.AssociativityPattern {T₁ = z ⟶ w} {T₂ = y ⟶ z} {T₃ = x ⟶ y} (_▫_)(_▫_)(_▫_)(_▫_)\n\n Idempotent : (x ⟶ x) → Stmt\n Idempotent(f) = (f ▫ f ≡ f)\n\n module _ (id : Names.Reflexivity(_⟶_)) where\n Identityₗ : Stmt\n Identityₗ = ∀{x y}{f : x ⟶ y} → (id ▫ f ≡ f)\n\n Identityᵣ : Stmt\n Identityᵣ = ∀{x y}{f : x ⟶ y} → (f ▫ id ≡ f)\n\n Inverseₗ : (x ⟶ y) → (y ⟶ x) → Stmt\n Inverseₗ(f)(f⁻¹) = (f⁻¹ ▫ f ≡ id)\n\n Inverseᵣ : (x ⟶ y) → (y ⟶ x) → Stmt\n Inverseᵣ(f)(f⁻¹) = (f ▫ f⁻¹ ≡ id)\n\n Involution : (x ⟶ x) → Stmt\n Involution(f) = Inverseᵣ f f\n\nmodule Polymorphism where\n module _ {Morphism : Obj → Obj → Type{ℓₘ}} ⦃ equiv-morphism : ∀{x y} → Equiv{ℓₑ}(Morphism x y) ⦄ where\n open ArrowNotation(Morphism)\n\n module _ (_▫_ : Names.SwappedTransitivity(_⟶_)) where\n IdempotentOn : Obj → Obj → (∀{x y} → (x ⟶ y)) → Stmt\n IdempotentOn(x)(z) (f) = ∀{y} → (f{y}{z} ▫ f{x}{y} ≡ f{x}{z})\n\n module _ (id : Names.Reflexivity(_⟶_)) where\n InvolutionOn : Obj → Obj → (∀{x y} → (x ⟶ y)) → Stmt\n InvolutionOn(x)(y) (f) = (f{x}{y} ▫ f{y}{x} ≡ id{y})\n\n Involution : (∀{x y} → (x ⟶ y)) → Stmt\n Involution(f) = ∀{x y} → InvolutionOn(x)(y)(f)\n", "meta": {"hexsha": "a8cbfbd65b08f57795f4710ab3d4f6d1d9bde86f", "size": 2740, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Categorical/Names.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Categorical/Names.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Categorical/Names.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.4942528736, "max_line_length": 127, "alphanum_fraction": 0.5773722628, "num_tokens": 1053, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511543206819, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.6334790821496664}} {"text": "module Natural where\n\nopen import Equality\nopen import Cubical.Data.Nat.Properties public\nopen import Data.Empty\nopen import Data.Nat as ℕ public hiding (_+_; _*_; _^_)\nopen import Data.Nat.Properties public hiding (+-assoc; +-suc)\nopen import Data.Unit\nopen import Function\nopen import Syntax\n\ninstance\n ℕ-plus-syntax : plus-syntax-simple ℕ ℕ ℕ\n ℕ-plus-syntax = record { _+_ = ℕ._+_ }\n\n ℕ-times-syntax : times-syntax-simple ℕ ℕ ℕ\n ℕ-times-syntax = record { _*_ = ℕ._*_ }\n\n ℕ-raise-syntax : raise-syntax-simple ℕ ℕ ℕ\n ℕ-raise-syntax = record { _^_ = ℕ._^_ }\n\n+-cross : (a b c d : ℕ) → (a + b) + (c + d) ≡ (a + c) + (b + d)\n+-cross a b c d =\n (a + b) + (c + d)\n ≡⟨ sym (+-assoc a _ _) ⟩\n a + (b + (c + d))\n ≡⟨ cong (a +_) (+-assoc b _ _) ⟩\n a + ((b + c) + d)\n ≡⟨ cong (a +_) (cong (_+ d) ⟨ +-comm b c ⟩) ⟩\n a + ((c + b) + d)\n ≡⟨ cong (a +_) (sym (+-assoc c _ _)) ⟩\n a + (c + (b + d))\n ≡⟨ +-assoc a _ _ ⟩\n (a + c) + (b + d)\n ∎\n\ninstance\n ℕ-Number : Number ℕ\n ℕ-Number = record { Constraint = λ _ → ⊤ ; fromNat = λ x → x }\n", "meta": {"hexsha": "c0ef3ecc382b2247538959f708d59fea07ca8fc2", "size": 1052, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Natural.agda", "max_stars_repo_name": "kcsmnt0/numbers", "max_stars_repo_head_hexsha": "67ea7b96228c592daf79e800ebe4a7c12ed7221e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2019-05-20T01:29:41.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-16T07:16:26.000Z", "max_issues_repo_path": "src/Natural.agda", "max_issues_repo_name": "kcsmnt0/numbers", "max_issues_repo_head_hexsha": "67ea7b96228c592daf79e800ebe4a7c12ed7221e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Natural.agda", "max_forks_repo_name": "kcsmnt0/numbers", "max_forks_repo_head_hexsha": "67ea7b96228c592daf79e800ebe4a7c12ed7221e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.3, "max_line_length": 64, "alphanum_fraction": 0.5494296578, "num_tokens": 399, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094032139576, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.6333734647613936}} {"text": "\nmodule QualifiedConstructors where\n\ndata Nat₁ : Set where\n zero : Nat₁\n suc : Nat₁ → Nat₁\n\ndata Nat₂ : Set where\n zero : Nat₂\n suc : Nat₂ → Nat₂\n\nzero₁ = Nat₁.zero\none₂ = Nat₂.suc Nat₂.zero\n\nrecord Suc : Set where\n constructor suc\n field n : Nat₁\n\none₃ = Suc.suc zero₁\n\npred : Suc → Nat₁\npred s = Suc.n s\n\nconv : Nat₂ → Nat₁\nconv Nat₂.zero = Nat₁.zero\nconv (Nat₂.suc n) = Nat₁.suc (conv n)\n\ndata _≡_ {A : Set}(x : A) : A → Set where\n refl : x ≡ x\n\ninj : (n m : Nat₁) → Nat₁.suc n ≡ suc m → n ≡ m\ninj .m m refl = refl\n", "meta": {"hexsha": "1744dcf992da82c2f80b2f7024b41e5b4f7f276c", "size": 531, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/QualifiedConstructors.agda", "max_stars_repo_name": "hborum/agda", "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Succeed/QualifiedConstructors.agda", "max_issues_repo_name": "hborum/agda", "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/QualifiedConstructors.agda", "max_forks_repo_name": "hborum/agda", "max_forks_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 16.0909090909, "max_line_length": 47, "alphanum_fraction": 0.6214689266, "num_tokens": 211, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094145755219, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.6333734618318503}} {"text": "module Formalization.LambdaCalculus.Semantics.CallByName where\n\nimport Lvl\nopen import Data\nopen import Formalization.LambdaCalculus\nopen import Formalization.LambdaCalculus.Semantics\nopen import Formalization.LambdaCalculus.SyntaxTransformation\nopen import Logic.Predicate\nopen import Numeral.Natural\nopen import Syntax.Number\nopen import Type\n\nprivate variable d db : ℕ\nprivate variable f t x : Term(d)\nprivate variable body : Term(db)\nprivate variable v : ∃(Value)\n\ndata _⇓_ : Term(d) → ∃(Value) → Type{0} where\n value : ⦃ val : Value(t) ⦄ → (t ⇓ [∃]-intro t)\n apply : (f ⇓ [∃]-intro(Abstract body)) → (substituteVar0 x body ⇓ v) → (Apply f x ⇓ v)\n", "meta": {"hexsha": "b406154ce87e92a106d2ac3c702d482c005a09c8", "size": 658, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Formalization/LambdaCalculus/Semantics/CallByName.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Formalization/LambdaCalculus/Semantics/CallByName.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Formalization/LambdaCalculus/Semantics/CallByName.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.3333333333, "max_line_length": 88, "alphanum_fraction": 0.7446808511, "num_tokens": 193, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.89330940889474, "lm_q2_score": 0.7090191214879992, "lm_q1q2_score": 0.6333734523115123}} {"text": "{-# OPTIONS --allow-unsolved-metas #-}\nmodule nat where\n\nopen import Data.Nat \nopen import Data.Nat.Properties\nopen import Data.Empty\nopen import Relation.Nullary\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Binary.Core\nopen import Relation.Binary.Definitions\nopen import logic\n\n\nnat-<> : { x y : ℕ } → x < y → y < x → ⊥\nnat-<> (s≤s x x : { x y : ℕ } → x ≤ y → y < x → ⊥\nnat-≤> (s≤s x x→¬< : {x y : ℕ } → (x < y ) → ¬ ( y < x )\n>→¬< (s≤s x→¬< x y → minus x y + y ≡ x\nminus+n {x} {zero} _ = trans (sym (+-comm zero _ )) refl\nminus+n {zero} {suc y} (s≤s ())\nminus+n {suc x} {suc y} (s≤s lt) = begin\n minus (suc x) (suc y) + suc y\n ≡⟨ +-comm _ (suc y) ⟩\n suc y + minus x y \n ≡⟨ cong ( λ k → suc k ) (\n begin\n y + minus x y \n ≡⟨ +-comm y _ ⟩\n minus x y + y\n ≡⟨ minus+n {x} {y} lt ⟩\n x \n ∎ \n ) ⟩\n suc x\n ∎ where open ≡-Reasoning\n\nsn-m=sn-m : {m n : ℕ } → m ≤ n → suc n - m ≡ suc ( n - m )\nsn-m=sn-m {0} {n} z≤n = refl\nsn-m=sn-m {suc m} {suc n} (s≤s m0 : {x y : ℕ } → x < y → 0 < minus y x \nminus>0 {zero} {suc _} (s≤s z≤n) = s≤s z≤n\nminus>0 {suc x} {suc y} (s≤s lt) = minus>0 {x} {y} lt\n\ndistr-minus-* : {x y z : ℕ } → (minus x y) * z ≡ minus (x * z) (y * z) \ndistr-minus-* {x} {zero} {z} = refl\ndistr-minus-* {x} {suc y} {z} with <-cmp x y\ndistr-minus-* {x} {suc y} {z} | tri< a ¬b ¬c = begin\n minus x (suc y) * z\n ≡⟨ cong (λ k → k * z ) (minus<=0 {x} {suc y} (x ¬a ¬b c = +m= {_} {_} {suc y * z} ( begin\n minus x (suc y) * z + suc y * z\n ≡⟨ sym (proj₂ *-distrib-+ z (minus x (suc y) ) _) ⟩\n ( minus x (suc y) + suc y ) * z\n ≡⟨ cong (λ k → k * z) (minus+n {x} {suc y} (s≤s c)) ⟩\n x * z \n ≡⟨ sym (minus+n {x * z} {suc y * z} (s≤s (lt c))) ⟩\n minus (x * z) (suc y * z) + suc y * z\n ∎ ) where\n open ≡-Reasoning\n lt : {x y z : ℕ } → suc y ≤ x → z + y * z ≤ x * z\n lt {x} {y} {z} le = *≤ le \n\nminus- : {x y z : ℕ } → suc x > z + y → minus (minus x y) z ≡ minus x (y + z)\nminus- {x} {y} {z} gt = +m= {_} {_} {z} ( begin\n minus (minus x y) z + z\n ≡⟨ minus+n {_} {z} lemma ⟩\n minus x y\n ≡⟨ +m= {_} {_} {y} ( begin\n minus x y + y \n ≡⟨ minus+n {_} {y} lemma1 ⟩\n x\n ≡⟨ sym ( minus+n {_} {z + y} gt ) ⟩\n minus x (z + y) + (z + y)\n ≡⟨ sym ( +-assoc (minus x (z + y)) _ _ ) ⟩\n minus x (z + y) + z + y\n ∎ ) ⟩\n minus x (z + y) + z\n ≡⟨ cong (λ k → minus x k + z ) (+-comm _ y ) ⟩\n minus x (y + z) + z\n ∎ ) where\n open ≡-Reasoning\n lemma1 : suc x > y\n lemma1 = x+y z\n lemma = <-minus {_} {_} {y} ( subst ( λ x → z + y < suc x ) (sym (minus+n {x} {y} lemma1 )) gt )\n\nminus-* : {M k n : ℕ } → n < k → minus k (suc n) * M ≡ minus (minus k n * M ) M\nminus-* {zero} {k} {n} lt = begin\n minus k (suc n) * zero\n ≡⟨ *-comm (minus k (suc n)) zero ⟩\n zero * minus k (suc n) \n ≡⟨⟩\n 0 * minus k n \n ≡⟨ *-comm 0 (minus k n) ⟩\n minus (minus k n * 0 ) 0\n ∎ where\n open ≡-Reasoning\nminus-* {suc m} {k} {n} lt with <-cmp k 1\nminus-* {suc m} {.0} {zero} lt | tri< (s≤s z≤n) ¬b ¬c = refl\nminus-* {suc m} {.0} {suc n} lt | tri< (s≤s z≤n) ¬b ¬c = refl\nminus-* {suc zero} {.1} {zero} lt | tri≈ ¬a refl ¬c = refl\nminus-* {suc (suc m)} {.1} {zero} lt | tri≈ ¬a refl ¬c = minus-* {suc m} {1} {zero} lt \nminus-* {suc m} {.1} {suc n} (s≤s ()) | tri≈ ¬a refl ¬c\nminus-* {suc m} {k} {n} lt | tri> ¬a ¬b c = begin\n minus k (suc n) * M\n ≡⟨ distr-minus-* {k} {suc n} {M} ⟩\n minus (k * M ) ((suc n) * M)\n ≡⟨⟩\n minus (k * M ) (M + n * M )\n ≡⟨ cong (λ x → minus (k * M) x) (+-comm M _ ) ⟩\n minus (k * M ) ((n * M) + M )\n ≡⟨ sym ( minus- {k * M} {n * M} (lemma lt) ) ⟩\n minus (minus (k * M ) (n * M)) M\n ≡⟨ cong (λ x → minus x M ) ( sym ( distr-minus-* {k} {n} )) ⟩\n minus (minus k n * M ) M\n ∎ where\n M = suc m\n lemma : {n k m : ℕ } → n < k → suc (k * suc m) > suc m + n * suc m\n lemma {zero} {suc k} {m} (s≤s lt) = s≤s (s≤s (subst (λ x → x ≤ m + k * suc m) (+-comm 0 _ ) x≤x+y ))\n lemma {suc n} {suc k} {m} lt = begin\n suc (suc m + suc n * suc m) \n ≡⟨⟩\n suc ( suc (suc n) * suc m)\n ≤⟨ ≤-plus-0 {_} {_} {1} (*≤ lt ) ⟩\n suc (suc k * suc m)\n ∎ where open ≤-Reasoning\n open ≡-Reasoning\n\nopen import Data.List\n\nℕL-inject : {h h1 : ℕ } {x y : List ℕ } → h ∷ x ≡ h1 ∷ y → h ≡ h1\nℕL-inject refl = refl\n\nℕL-inject-t : {h h1 : ℕ } {x y : List ℕ } → h ∷ x ≡ h1 ∷ y → x ≡ y\nℕL-inject-t refl = refl\n\nℕL-eq? : (x y : List ℕ ) → Dec (x ≡ y )\nℕL-eq? [] [] = yes refl\nℕL-eq? [] (x ∷ y) = no (λ ())\nℕL-eq? (x ∷ x₁) [] = no (λ ())\nℕL-eq? (h ∷ x) (h1 ∷ y) with h ≟ h1 | ℕL-eq? x y\n... | yes y1 | yes y2 = yes ( cong₂ (λ j k → j ∷ k ) y1 y2 )\n... | yes y1 | no n = no (λ e → n (ℕL-inject-t e))\n... | no n | t = no (λ e → n (ℕL-inject e)) \n\n", "meta": {"hexsha": "0d913994c9f6e4e21cb34ea86752f4ca59a4219b", "size": 11702, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/nat.agda", "max_stars_repo_name": "shinji-kono/Galois", "max_stars_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-16T03:37:05.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-16T03:37:05.000Z", "max_issues_repo_path": "src/nat.agda", "max_issues_repo_name": "shinji-kono/Galois", "max_issues_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/nat.agda", "max_forks_repo_name": "shinji-kono/Galois", "max_forks_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.3167155425, "max_line_length": 113, "alphanum_fraction": 0.3982225261, "num_tokens": 5784, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.877476800298183, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.6333129140470943}} {"text": "{-# OPTIONS --cubical --safe #-}\nmodule Cubical.HITs.Pushout.Base where\n\nopen import Cubical.Core.Glue\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Isomorphism\n\nopen import Cubical.Data.Unit\n\nopen import Cubical.HITs.Susp\n\ndata Pushout {ℓ ℓ' ℓ''} {A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''}\n (f : A → B) (g : A → C) : Type (ℓ-max ℓ (ℓ-max ℓ' ℓ'')) where\n inl : B → Pushout f g\n inr : C → Pushout f g\n push : (a : A) → inl (f a) ≡ inr (g a)\n\n\n-- Suspension defined as a pushout\n\nPushoutSusp : ∀ {ℓ} (A : Type ℓ) → Type ℓ\nPushoutSusp A = Pushout {A = A} {B = Unit} {C = Unit} (λ _ → tt) (λ _ → tt)\n\nPushoutSusp→Susp : ∀ {ℓ} {A : Type ℓ} → PushoutSusp A → Susp A\nPushoutSusp→Susp (inl _) = north\nPushoutSusp→Susp (inr _) = south\nPushoutSusp→Susp (push a i) = merid a i\n\nSusp→PushoutSusp : ∀ {ℓ} {A : Type ℓ} → Susp A → PushoutSusp A\nSusp→PushoutSusp north = inl tt\nSusp→PushoutSusp south = inr tt\nSusp→PushoutSusp (merid a i) = push a i\n\nSusp→PushoutSusp→Susp : ∀ {ℓ} {A : Type ℓ} (x : Susp A) →\n PushoutSusp→Susp (Susp→PushoutSusp x) ≡ x\nSusp→PushoutSusp→Susp north = refl\nSusp→PushoutSusp→Susp south = refl\nSusp→PushoutSusp→Susp (merid _ _) = refl\n\nPushoutSusp→Susp→PushoutSusp : ∀ {ℓ} {A : Type ℓ} (x : PushoutSusp A) →\n Susp→PushoutSusp (PushoutSusp→Susp x) ≡ x\nPushoutSusp→Susp→PushoutSusp (inl _) = refl\nPushoutSusp→Susp→PushoutSusp (inr _) = refl\nPushoutSusp→Susp→PushoutSusp (push _ _) = refl\n\nPushoutSusp≃Susp : ∀ {ℓ} {A : Type ℓ} → PushoutSusp A ≃ Susp A\nPushoutSusp≃Susp = isoToEquiv (iso PushoutSusp→Susp Susp→PushoutSusp Susp→PushoutSusp→Susp PushoutSusp→Susp→PushoutSusp)\n\nPushoutSusp≡Susp : ∀ {ℓ} {A : Type ℓ} → PushoutSusp A ≡ Susp A\nPushoutSusp≡Susp = isoToPath (iso PushoutSusp→Susp Susp→PushoutSusp Susp→PushoutSusp→Susp PushoutSusp→Susp→PushoutSusp)\n", "meta": {"hexsha": "ed18bf81217a7c9d062e1f6f3744fbe596461200", "size": 1899, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/Pushout/Base.agda", "max_stars_repo_name": "cj-xu/cubical", "max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/HITs/Pushout/Base.agda", "max_issues_repo_name": "cj-xu/cubical", "max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/HITs/Pushout/Base.agda", "max_forks_repo_name": "cj-xu/cubical", "max_forks_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.8301886792, "max_line_length": 120, "alphanum_fraction": 0.6682464455, "num_tokens": 706, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744584140003, "lm_q2_score": 0.7745833841649232, "lm_q1q2_score": 0.6332795908051206}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\nopen import homotopy.Freudenthal\n\nmodule homotopy.IterSuspensionStable where\n\n{- π (S k) (Ptd-Susp^ (S n) X) == π k (Ptd-Susp^ n X), where k = S k'\n Susp^Stable below assumes k ≠ O instead of taking k' as the argument -}\nmodule Susp^StableSucc {i} (k n : ℕ) (Skle : S k ≤ n *2)\n (X : Ptd i) {{_ : is-connected ⟨ n ⟩ (de⊙ X)}} where\n\n {- some numeric computations -}\n private\n Skle' : ⟨ S k ⟩ ≤T ⟨ n ⟩₋₁ +2+ ⟨ n ⟩₋₁\n Skle' = ≤T-trans (⟨⟩-monotone-≤ Skle) (inl (lemma n))\n where lemma : (n : ℕ) → ⟨ n *2 ⟩ == ⟨ n ⟩₋₁ +2+ ⟨ n ⟩₋₁\n lemma O = idp\n lemma (S n') = ap S (ap S (lemma n')\n ∙ ! (+2+-βr ⟨ S n' ⟩₋₂ ⟨ S n' ⟩₋₂))\n\n private\n module F = FreudenthalIso\n ⟨ n ⟩₋₂ k Skle' X\n\n stable : πS (S k) (⊙Susp X) ≃ᴳ πS k X\n stable =\n πS (S k) (⊙Susp X)\n ≃ᴳ⟨ πS-Ω-split-iso k (⊙Susp X) ⟩\n πS k (⊙Ω (⊙Susp X))\n ≃ᴳ⟨ Ω^S-group-Trunc-fuse-diag-iso k (⊙Ω (⊙Susp X)) ⁻¹ᴳ ⟩\n Ω^S-group k (⊙Trunc ⟨ S k ⟩ (⊙Ω (⊙Susp X)))\n ≃ᴳ⟨ F.iso ⁻¹ᴳ ⟩\n Ω^S-group k (⊙Trunc ⟨ S k ⟩ X)\n ≃ᴳ⟨ Ω^S-group-Trunc-fuse-diag-iso k X ⟩\n πS k X ≃ᴳ∎\n", "meta": {"hexsha": "9fc226b944cde6972907de0caba2f8f8363d4cec", "size": 1177, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/homotopy/IterSuspensionStable.agda", "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "theorems/homotopy/IterSuspensionStable.agda", "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "theorems/homotopy/IterSuspensionStable.agda", "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.8108108108, "max_line_length": 74, "alphanum_fraction": 0.4961767205, "num_tokens": 565, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9099070035949656, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.6332573598961985}} {"text": "open import Data.Product using ( _×_ )\nopen import Web.Semantic.DL.Signature using ( Signature ; CN ; RN )\n\nmodule Web.Semantic.DL.FOL where\n\n-- A fragment of first order logic with no existentials or disjunctions.\n\ninfixr 4 _∧_\n\ndata Formula (Σ : Signature) (Δ : Set) : Set where\n true : Formula Σ Δ\n false : Formula Σ Δ\n _∧_ : Formula Σ Δ → Formula Σ Δ → Formula Σ Δ\n _∈₁_ : Δ → CN Σ → Formula Σ Δ\n _∈₁_⇒_ : Δ → CN Σ → Formula Σ Δ → Formula Σ Δ\n _∈₂_ : (Δ × Δ) → RN Σ → Formula Σ Δ\n _∈₂_⇒_ : (Δ × Δ) → RN Σ → Formula Σ Δ → Formula Σ Δ\n _∼_ : Δ → Δ → Formula Σ Δ\n _∼_⇒_ : Δ → Δ → Formula Σ Δ → Formula Σ Δ\n ∀₁ : (Δ → Formula Σ Δ) → Formula Σ Δ\n", "meta": {"hexsha": "6cda59c91985174c6ee0bcb736196ae33bb1e915", "size": 655, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Web/Semantic/DL/FOL.agda", "max_stars_repo_name": "agda/agda-web-semantic", "max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z", "max_issues_repo_path": "src/Web/Semantic/DL/FOL.agda", "max_issues_repo_name": "agda/agda-web-semantic", "max_issues_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z", "max_forks_repo_path": "src/Web/Semantic/DL/FOL.agda", "max_forks_repo_name": "agda/agda-web-semantic", "max_forks_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z", "avg_line_length": 31.1904761905, "max_line_length": 72, "alphanum_fraction": 0.6152671756, "num_tokens": 277, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9099070109242131, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.6332573592590108}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Unsigned divisibility\n------------------------------------------------------------------------\n-- For signed divisibility see `Data.Integer.Divisibility.Signed`\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Integer.Divisibility where\n\nopen import Function\nopen import Data.Integer\nopen import Data.Integer.Properties\nimport Data.Nat as ℕ\nimport Data.Nat.Properties as ℕᵖ\nimport Data.Nat.Divisibility as ℕᵈ\nimport Data.Nat.Coprimality as ℕᶜ\nopen import Level\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality\n\n------------------------------------------------------------------------\n-- Divisibility\n\ninfix 4 _∣_\n\n_∣_ : Rel ℤ 0ℓ\n_∣_ = ℕᵈ._∣_ on ∣_∣\n\nopen ℕᵈ public using (divides)\n\n------------------------------------------------------------------------\n-- Properties of divisibility\n\n*-monoʳ-∣ : ∀ k → (k *_) Preserves _∣_ ⟶ _∣_\n*-monoʳ-∣ k {i} {j} i∣j = begin\n ∣ k * i ∣ ≡⟨ abs-*-commute k i ⟩\n ∣ k ∣ ℕ.* ∣ i ∣ ∣⟨ ℕᵈ.*-cong ∣ k ∣ i∣j ⟩\n ∣ k ∣ ℕ.* ∣ j ∣ ≡⟨ sym (abs-*-commute k j) ⟩\n ∣ k * j ∣ ∎\n where open ℕᵈ.∣-Reasoning\n\n*-monoˡ-∣ : ∀ k → (_* k) Preserves _∣_ ⟶ _∣_\n*-monoˡ-∣ k {i} {j}\n rewrite *-comm i k\n | *-comm j k\n = *-monoʳ-∣ k\n\n*-cancelˡ-∣ : ∀ k {i j} → k ≢ + 0 → k * i ∣ k * j → i ∣ j\n*-cancelˡ-∣ k {i} {j} k≢0 k*i∣k*j = ℕᵈ./-cong (ℕ.pred ∣ k ∣) $ begin\n let ∣k∣-is-suc = ℕᵖ.m≢0⇒suc[pred[m]]≡m (k≢0 ∘ ∣n∣≡0⇒n≡0) in\n ℕ.suc (ℕ.pred ∣ k ∣) ℕ.* ∣ i ∣ ≡⟨ cong (ℕ._* ∣ i ∣) (∣k∣-is-suc) ⟩\n ∣ k ∣ ℕ.* ∣ i ∣ ≡⟨ sym (abs-*-commute k i) ⟩\n ∣ k * i ∣ ∣⟨ k*i∣k*j ⟩\n ∣ k * j ∣ ≡⟨ abs-*-commute k j ⟩\n ∣ k ∣ ℕ.* ∣ j ∣ ≡⟨ cong (ℕ._* ∣ j ∣) (sym ∣k∣-is-suc) ⟩\n ℕ.suc (ℕ.pred ∣ k ∣) ℕ.* ∣ j ∣ ∎\n where open ℕᵈ.∣-Reasoning\n\n*-cancelʳ-∣ : ∀ k {i j} → k ≢ + 0 → i * k ∣ j * k → i ∣ j\n*-cancelʳ-∣ k {i} {j} ≢0 = *-cancelˡ-∣ k ≢0 ∘\n subst₂ _∣_ (*-comm i k) (*-comm j k)\n", "meta": {"hexsha": "fb67676470b975d43a67986969d3261961c4361a", "size": 2012, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Integer/Divisibility.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Integer/Divisibility.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Integer/Divisibility.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.4375, "max_line_length": 72, "alphanum_fraction": 0.4453280318, "num_tokens": 858, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8519528057272544, "lm_q2_score": 0.7431680143008301, "lm_q1q2_score": 0.6331440749103445}} {"text": "module product-thms where\n\nopen import eq\nopen import level\nopen import product\nopen import unit\nopen import functions\n\n-- this is called the inspect idiom, in the Agda stdlib\nkeep : ∀{ℓ}{A : Set ℓ} → (x : A) → Σ A (λ y → x ≡ y)\nkeep x = ( x , refl )\n\n,inj : ∀{ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'}{a a' : A}{b b' : B} → \n (a , b) ≡ (a' , b') → (a ≡ a') ∧ (b ≡ b')\n,inj refl = refl , refl\n\neta-× : ∀{ℓ₁ ℓ₂ ℓ₃}{A : Set ℓ₁}{B : Set ℓ₂}{C : Set ℓ₃}{h : A × B → C}\n → (extensionality {ℓ₁ ⊔ ℓ₂}{ℓ₃})\n → (λ c → h (fst c , snd c)) ≡ h\neta-× {A = A}{B}{C}{h} ext = ext eta-×-aux\n where\n eta-×-aux : ∀{a : Σ A (λ x → B)} → h (fst a , snd a) ≡ h a\n eta-×-aux {(a , b)} = refl\n\neq-× : ∀{ℓ₁ ℓ₂}{A : Set ℓ₁}{B : Set ℓ₂}{a a' : A}{b b' : B}\n → a ≡ a'\n → b ≡ b'\n → (a , b) ≡ (a' , b')\neq-× refl refl = refl\n\ntwist-×-iso : ∀{ℓ : level}{U V : Set ℓ}{a : U × V} → (twist-× ∘ twist-×) a ≡ id a\ntwist-×-iso {a = u , v} = refl\n\n-- This module proves typical isomorphisms about ∧.\nmodule ∧-Isos where\n postulate ext-set : ∀{l1 l2 : level} → extensionality {l1} {l2}\n \n ∧-unit-l : ∀{ℓ}{A : Set ℓ} → A → A ∧ (⊤ {ℓ})\n ∧-unit-l x = x , triv\n\n ∧-unit-r : ∀{ℓ}{A : Set ℓ} → A → ⊤ ∧ A\n ∧-unit-r x = twist-× (∧-unit-l x)\n\n ∧-unit-l-iso : ∀{ℓ}{A : Set ℓ} → Iso A (A ∧ ⊤)\n ∧-unit-l-iso {_}{A} = isIso ∧-unit-l fst refl (ext-set aux)\n where\n aux : {a : A ∧ ⊤} → (fst a , triv) ≡ a\n aux {x , triv} = refl\n\n ∧-unit-r-iso : ∀{ℓ}{A : Set ℓ} → Iso A (⊤ ∧ A)\n ∧-unit-r-iso {_}{A} = isIso ∧-unit-r snd refl (ext-set aux)\n where\n aux : {a : ⊤ ∧ A} → (triv , snd a) ≡ a\n aux {triv , x} = refl\n\n ∧-assoc₁ : ∀{ℓ}{A B C : Set ℓ} → (A ∧ (B ∧ C)) → ((A ∧ B) ∧ C)\n ∧-assoc₁ (a , b , c) = ((a , b) , c)\n\n ∧-assoc₂ : ∀{ℓ}{A B C : Set ℓ} → ((A ∧ B) ∧ C) → (A ∧ (B ∧ C))\n ∧-assoc₂ ((a , b) , c) = (a , b , c)\n\n ∧-assoc-iso : ∀{ℓ}{A B C : Set ℓ} → Iso (A ∧ (B ∧ C)) ((A ∧ B) ∧ C)\n ∧-assoc-iso {_}{A}{B}{C} = isIso ∧-assoc₁ ∧-assoc₂ (ext-set aux₁) (ext-set aux₂)\n where\n aux₁ : {a : A ∧ (B ∧ C)} → ∧-assoc₂ (∧-assoc₁ a) ≡ a\n aux₁ {a , (b , c)} = refl\n\n aux₂ : {a : (A ∧ B) ∧ C} → ∧-assoc₁ (∧-assoc₂ a) ≡ a\n aux₂ {(a , b) , c} = refl\n\n\n", "meta": {"hexsha": "f82962f81782fb1827e858e05cc5f0d699b34ab3", "size": 2135, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "product-thms.agda", "max_stars_repo_name": "heades/AUGL", "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "product-thms.agda", "max_issues_repo_name": "heades/AUGL", "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "product-thms.agda", "max_forks_repo_name": "heades/AUGL", "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.6527777778, "max_line_length": 82, "alphanum_fraction": 0.4529274005, "num_tokens": 1046, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835452961425, "lm_q2_score": 0.7577943822145998, "lm_q1q2_score": 0.633124737058154}} {"text": "\ndata Nat : Set where\n zero : Nat\n suc : Nat → Nat\n\nplus : Nat → Nat → Nat\nplus zero b = b\nplus (suc a) b = suc (plus a b)\n\ninfixl 6 _+_\n_+_ = plus\n\n{-# DISPLAY suc n = 1 + n #-}\n{-# DISPLAY plus a b = a + b #-}\n\npostulate\n T : {A : Set} → A → Set\n\ntest₁ : ∀ a b → T (plus (suc a) b)\ntest₁ a b = {!!}\n\ndata Vec (A : Set) : Nat → Set where\n [] : Vec A zero\n _∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)\n\ndata List A : Set where\n [] : List A\n _∷_ : A → List A → List A\n\ninfixr 4 _∷_\n\n[_] : ∀ {A} → A → Vec A (suc zero)\n[ x ] = x ∷ []\n\n{-# DISPLAY Vec._∷_ x Vec.[] = [ x ] #-}\n\ntest₂ : (n : Nat) → T (n Vec.∷ [])\ntest₂ n = {!!}\n\nappend : ∀ {A : Set} {n m} → Vec A n → Vec A m → Vec A (n + m)\nappend [] ys = ys\nappend (x ∷ xs) ys = x ∷ append xs ys\n\ninfixr 4 _++_\n_++_ = append\n\n{-# DISPLAY append xs ys = xs ++ ys #-}\n{-# DISPLAY append xs (y Vec.∷ ys) = xs ++ [ y ] ++ ys #-}\n\ntest₃ : ∀ {n} (xs ys : Vec Nat n) → T (append xs (n ∷ ys))\ntest₃ {n} xs ys = {!!}\n", "meta": {"hexsha": "72ecc258d6f1945bb1f4b8225ef93f5b54e083d9", "size": 970, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/DisplayForm.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/interaction/DisplayForm.agda", "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/interaction/DisplayForm.agda", "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 18.6538461538, "max_line_length": 62, "alphanum_fraction": 0.4783505155, "num_tokens": 401, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802462567085, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.6331135867889679}} {"text": "{-# OPTIONS --cubical --no-exact-split --safe #-}\nmodule Cubical.Data.NatPlusOne.Properties where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Data.Nat\nopen import Cubical.Data.NatPlusOne.Base\n\n1+Path : ℕ ≡ ℕ₊₁\n1+Path = isoToPath (iso 1+_ -1+_ (λ _ → refl) (λ _ → refl))\n", "meta": {"hexsha": "256eb8e7aaadee4f0a4d947da4f32f4a43f11e0a", "size": 331, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/NatPlusOne/Properties.agda", "max_stars_repo_name": "cmester0/cubical", "max_stars_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-03-23T23:52:11.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-23T23:52:11.000Z", "max_issues_repo_path": "Cubical/Data/NatPlusOne/Properties.agda", "max_issues_repo_name": "cmester0/cubical", "max_issues_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Data/NatPlusOne/Properties.agda", "max_forks_repo_name": "cmester0/cubical", "max_forks_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.0909090909, "max_line_length": 59, "alphanum_fraction": 0.7432024169, "num_tokens": 104, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8887587875995482, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.6330026179823093}} {"text": "\nopen import Category\n\nmodule Iso (ℂ : Cat) where\n\nprivate open module C = Cat (η-Cat ℂ)\n\ndata _≅_ (A B : Obj) : Set where\n iso : (i : A ─→ B)(j : B ─→ A) ->\n\ti ∘ j == id -> j ∘ i == id ->\n\tA ≅ B\n\n", "meta": {"hexsha": "a26ef3e41c623d4b9b49f6a3037a08bea2ac6a3f", "size": 198, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/cat/Iso.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/cat/Iso.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/cat/Iso.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 15.2307692308, "max_line_length": 37, "alphanum_fraction": 0.5050505051, "num_tokens": 83, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9273632876167044, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.6329938163972774}} {"text": "\nopen import Agda.Primitive\nopen import Agda.Builtin.Nat\n\n-- Named implicit function types\n\npostulate\n T : Set → Set → Set\n foo : {A = X : Set} {B : Set} → T X B\n bar : ∀ {A = X} {B} → T X B\n\nfoo₁ : (X : Set) → T X X\nfoo₁ X = foo {A = X} {B = X}\n\nbar₁ : ∀ X → T X X\nbar₁ X = bar {A = X} {B = X}\n\nId : {A = _ : Set} → Set\nId {A = X} = X\n\nId₁ : Set → Set\nId₁ X = Id {A = X}\n\n-- With blanks\n\npostulate\n namedUnused : {A = _ : Set} → Set\n unnamedUsed : {_ = X : Set} → X → X\n unnamedUnused : {_ = _ : Set} → Set\n\n_ : Set\n_ = namedUnused {A = Nat}\n\n_ : Nat → Nat\n_ = unnamedUsed {Nat} -- can't give by name\n\n_ : Set\n_ = unnamedUnused {Nat}\n\n-- In left-hand sides\n\nid : {A = X : Set} → X → X\nid {A = Y} x = x\n\n-- In with-functions\n\nwith-fun : ∀ {A} {B = X} → T A X → T A X\nwith-fun {A = A} {B = Z} x with T A Z\nwith-fun {B = Z} x | Goal = x\n\n-- In datatypes\n\ndata List {ℓ = a} (A : Set a) : Set a where\n [] : List A\n _∷_ : A → List A → List A\n\nList₁ = List {ℓ = lsuc lzero}\n\n-- In module telescopes\n\nmodule Named {A : Set} {B = X : Set} where\n postulate H : X → A\n\nh : (A : Set) → A → A\nh A = Named.H {A = A} {B = A}\n\npostulate\n X : Set\n\nopen Named {A = X} {B = X}\n\nhh : X → X\nhh = H\n\n-- Constructors\n\ndata Q (n : Nat) : Set where\n mkQ : Q n\n\ndata E {n = x} (q : Q x) : Set where\n mkE : E q\n\ne₁ : (q : Q 1) → E q\ne₁ q = mkE {n = 1} {q = q}\n\n-- Generalized variables\n\nvariable\n m n : Nat\n\nq₁ = mkQ {n = 1}\n\ndata D (x : Q n) : Q m → Set where\n refl : {y = z : Q m} → D x z\n\nD₁ = D {n = 1}\nD₁₂ = λ x → D {n = 1} x {m = 2}\n\nrefl′ = λ x → refl {n = 1} {x = x} {m = 2} {y = mkQ}\n", "meta": {"hexsha": "e9b1323adc270006b001ccd4d7b2d759faedf740", "size": 1587, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue952.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue952.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue952.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 15.87, "max_line_length": 52, "alphanum_fraction": 0.5028355388, "num_tokens": 687, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920068519376, "lm_q2_score": 0.7905303137346446, "lm_q1q2_score": 0.6329713033814844}} {"text": "{-# OPTIONS --cubical --safe --postfix-projections #-}\n\n-- This file contains an implementation of the stack-based compiler for Hutton's\n-- razor, as from:\n--\n-- P. Bahr and G. Hutton, “Calculating correct compilers,” Journal of\n-- Functional Programming, vol. 25, no. e14, Sep. 2015,\n-- doi: 10.1017/S0956796815000180.\n--\n-- The compiler is total and the evaluator is stack-safe, and furthermore we have\n-- proven a full isomorphism between the code representation and the AST.\n\nmodule Data.Dyck.Prog where\n\nopen import Prelude\nopen import Data.Nat using (_+_)\n\nprivate variable n : ℕ\n\n--------------------------------------------------------------------------------\n-- We have 2 forms that we want to convert between: an AST and a flat code.\n--------------------------------------------------------------------------------\n\ndata Expr : Type where\n [_] : ℕ → Expr\n _⊕_ : Expr → Expr → Expr\n\n--------------------------------------------------------------------------------\n-- We do the conversion with cayley forms of the dyck monoids\n--------------------------------------------------------------------------------\n\n⟨_⟩_↝_ : (ℕ → Type) → ℕ → ℕ → Type\n⟨ C ⟩ n ↝ m = ∀ {i} → C (n + i) → C (m + i)\n\n--------------------------------------------------------------------------------\n-- An encoding of an AST\n--------------------------------------------------------------------------------\n\ndata Code : ℕ → Type where\n HALT : Code 1\n PUSH : ℕ → ⟨ Code ⟩ 1 ↝ 0\n ADD : ⟨ Code ⟩ 1 ↝ 2\n\n--------------------------------------------------------------------------------\n-- We will need a stack (a snoc-list)\n--------------------------------------------------------------------------------\n\nStack : Type → ℕ → Type\nStack A zero = ⊤\nStack A (suc n) = Stack A n × A\n\ninfixl 5 _∷_\npattern _∷_ xs x = xs , x\n\nfoldl : (P : ℕ → Type) → (A → ⟨ P ⟩ 1 ↝ 0) → Stack A n → P n → P zero\nfoldl {n = zero} P f tt = id\nfoldl {n = suc n} P f (xs ∷ x) = foldl P f xs ∘ f x\n\nprivate variable st : Stack Expr n\n\n--------------------------------------------------------------------------------\n-- Conversion to and from code\n--------------------------------------------------------------------------------\n\n-- Code n → ⟨ Stack Expr ⟩ n ↝ 1\ncode→expr⊙ : Code n → Stack Expr n → Expr\ncode→expr⊙ HALT (tt ∷ e) = e\ncode→expr⊙ (PUSH v is) st = code→expr⊙ is (st ∷ [ v ])\ncode→expr⊙ (ADD is) (st ∷ xs ∷ ys) = code→expr⊙ is (st ∷ xs ⊕ ys)\n\ncode→expr : Code 0 → Expr\ncode→expr ds = code→expr⊙ ds tt\n\nexpr→code⊙ : Expr → ⟨ Code ⟩ 1 ↝ 0\nexpr→code⊙ [ x ] = PUSH x\nexpr→code⊙ (xs ⊕ ys) = expr→code⊙ xs ∘ expr→code⊙ ys ∘ ADD\n\nexpr→code : Expr → Code 0\nexpr→code xs = expr→code⊙ xs HALT\n\n--------------------------------------------------------------------------------\n-- Proof of isomorphism\n--------------------------------------------------------------------------------\n\nexpr→code→expr⊙ : {is : Code (1 + n)} (e : Expr) →\n code→expr⊙ (expr→code⊙ e is) st ≡ code→expr⊙ is (st ∷ e)\nexpr→code→expr⊙ [ x ] = refl\nexpr→code→expr⊙ (xs ⊕ ys) = expr→code→expr⊙ xs ; expr→code→expr⊙ ys\n\ncode→expr→code⊙ : (is : Code n) →\n expr→code (code→expr⊙ is st) ≡ foldl Code expr→code⊙ st is\ncode→expr→code⊙ HALT = refl\ncode→expr→code⊙ (PUSH i is) = code→expr→code⊙ is\ncode→expr→code⊙ (ADD is) = code→expr→code⊙ is\n\nprog-iso : Code 0 ⇔ Expr\nprog-iso .fun = code→expr\nprog-iso .inv = expr→code\nprog-iso .rightInv = expr→code→expr⊙\nprog-iso .leftInv = code→expr→code⊙\n", "meta": {"hexsha": "17143778f05fc5cd421a873c7a906d247ffacaed", "size": 3488, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Dyck/Prog.agda", "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_issues_repo_path": "Data/Dyck/Prog.agda", "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Dyck/Prog.agda", "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "avg_line_length": 34.5346534653, "max_line_length": 81, "alphanum_fraction": 0.4383600917, "num_tokens": 1028, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8807970842359877, "lm_q2_score": 0.7185944046238981, "lm_q1q2_score": 0.632935856341025}} {"text": "{-\n Define finitely generated ideals of commutative rings and\n show that they are an ideal.\n Parts of this should be reusable for explicit constructions\n of free modules over a finite set.\n-}\n{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.CommRing.FGIdeal where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.Transport\nopen import Cubical.Foundations.HLevels\n\nopen import Cubical.Data.Sigma\nopen import Cubical.Data.FinData hiding (elim ; rec)\nopen import Cubical.Data.Nat renaming ( zero to ℕzero ; suc to ℕsuc\n ; _+_ to _+ℕ_ ; _·_ to _·ℕ_\n ; +-assoc to +ℕ-assoc ; +-comm to +ℕ-comm\n ; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm)\n hiding (elim)\nopen import Cubical.HITs.PropositionalTruncation\n\nopen import Cubical.Algebra.CommRing\nopen import Cubical.Algebra.CommRing.Ideal\nopen import Cubical.Algebra.Ring.QuotientRing\nopen import Cubical.Algebra.Ring.Properties\nopen import Cubical.Algebra.Ring.BigOps\nopen import Cubical.Algebra.RingSolver.ReflectionSolving\nopen import Cubical.Algebra.Matrix\n\nprivate\n variable\n ℓ : Level\n\nmodule _ (Ring@(R , str) : CommRing ℓ) where\n infixr 5 _holds\n _holds : hProp ℓ → Type ℓ\n P holds = fst P\n open CommRingStr str\n open RingTheory (CommRing→Ring Ring)\n open Sum (CommRing→Ring Ring)\n\n linearCombination : {n : ℕ} → FinVec R n → FinVec R n → R\n linearCombination α V = ∑ (λ i → α i · V i)\n\n sumDist+ : ∀ {n : ℕ} (α β V : FinVec R n)\n → linearCombination (λ i → α i + β i) V ≡ linearCombination α V + linearCombination β V\n sumDist+ α β V = ∑Ext (λ i → ·Ldist+ (α i) (β i) (V i)) ∙ ∑Split (λ i → α i · V i) (λ i → β i · V i)\n\n dist- : ∀ {n : ℕ} (α V : FinVec R n)\n → linearCombination (λ i → - α i) V ≡ - linearCombination α V\n dist- α V = ∑Ext (λ i → -DistL· (α i) (V i)) ∙ ∑Dist- (λ i → α i · V i)\n\n dist0 : ∀ {n : ℕ} (V : FinVec R n)\n → linearCombination (replicateFinVec n 0r) V ≡ 0r\n dist0 {n = n} V = ∑Ext (λ i → 0LeftAnnihilates (V i)) ∙ ∑0r n\n\n isLinearCombination : {n : ℕ} → FinVec R n → R → Type ℓ\n isLinearCombination V x = ∃[ α ∈ FinVec R _ ] x ≡ linearCombination α V\n\n {- If x and y are linear combinations of l, then (x + y) is\n a linear combination. -}\n isLinearCombination+ : {n : ℕ} {x y : R} (V : FinVec R n)\n → isLinearCombination V x\n → isLinearCombination V y\n → isLinearCombination V (x + y)\n isLinearCombination+ V = map2 λ α β → (λ i → α .fst i + β .fst i)\n , cong₂ (_+_) (α .snd) (β .snd) ∙ sym (sumDist+ _ _ V)\n\n {- If x is a linear combinations of l, then -x is\n a linear combination. -}\n isLinearCombination- : {n : ℕ} {x : R} (V : FinVec R n)\n → isLinearCombination V x → isLinearCombination V (- x)\n isLinearCombination- V = map λ α → (λ i → - α .fst i) , cong (-_) (α .snd) ∙ sym (dist- _ V)\n\n {- 0r is the trivial linear Combination -}\n isLinearCombination0 : {n : ℕ} (V : FinVec R n)\n → isLinearCombination V 0r\n isLinearCombination0 V = ∣ _ , sym (dist0 V) ∣\n\n {- Linear combinations are stable under left multiplication -}\n isLinearCombinationL· : {n : ℕ} (V : FinVec R n) (r : R) {x : R}\n → isLinearCombination V x → isLinearCombination V (r · x)\n isLinearCombinationL· V r = map λ α → (λ i → r · α .fst i) , cong (r ·_) (α .snd)\n ∙∙ ∑Mulrdist r (λ i → α .fst i · V i)\n ∙∙ ∑Ext λ i → ·Assoc r (α .fst i) (V i)\n\n generatedIdeal : {n : ℕ} → FinVec R n → IdealsIn Ring\n generatedIdeal V = makeIdeal Ring\n (λ x → isLinearCombination V x , isPropPropTrunc)\n (isLinearCombination+ V)\n (isLinearCombination0 V)\n λ r → isLinearCombinationL· V r\n\n\nopen CommIdeal.isCommIdeal\ngenIdeal : {n : ℕ} (R : CommRing ℓ) → FinVec (fst R) n → CommIdeal.CommIdeal R\nfst (genIdeal R V) x = isLinearCombination R V x , isPropPropTrunc\n+Closed (snd (genIdeal R V)) = isLinearCombination+ R V\ncontains0 (snd (genIdeal R V)) = isLinearCombination0 R V\n·Closed (snd (genIdeal R V)) r = isLinearCombinationL· R V r\n\nsyntax genIdeal R V = ⟨ V ⟩[ R ]\n\n\nFGIdealIn : (R : CommRing ℓ) → Type (ℓ-suc ℓ)\nFGIdealIn R = Σ[ I ∈ CommIdeal.CommIdeal R ]\n ∃[ nV ∈ Σ[ n ∈ ℕ ] FinVec (fst R) n ] I ≡ ⟨ nV .snd ⟩[ R ]\n\n-- The lattice laws\nmodule _ (R' : CommRing ℓ) where\n open CommRingStr (snd R')\n open RingTheory (CommRing→Ring R')\n open CommIdeal R'\n open Sum (CommRing→Ring R')\n open KroneckerDelta (CommRing→Ring R')\n private\n R = fst R'\n ⟨_⟩ : {n : ℕ} → FinVec R n → CommIdeal\n ⟨ V ⟩ = ⟨ V ⟩[ R' ]\n\n inclOfFGIdeal : {n : ℕ} (V : FinVec R n) (I : CommIdeal)\n → (∀ i → V i ∈ I) → ⟨ V ⟩ ⊆ I\n inclOfFGIdeal V I ∀i→Vi∈I x = elim (λ _ → I .fst x .snd) inclOfFGIdealΣ\n where\n inclOfFGIdealΣ : Σ[ α ∈ FinVec R _ ] x ≡ linearCombination R' α V → x ∈ I\n inclOfFGIdealΣ (α , x≡α·V) = subst-∈ I (sym x≡α·V) (∑Closed I (λ i → α i · V i)\n λ i → ·Closed (I .snd) _ (∀i→Vi∈I i))\n\n indInIdeal : ∀ {n : ℕ} (U : FinVec R n) (i : Fin n) → U i ∈ ⟨ U ⟩\n indInIdeal U i = ∣ (δ i) , sym (∑Mul1r _ U i) ∣\n\n sucIncl : ∀ {n : ℕ} (U : FinVec R (ℕsuc n)) → ⟨ U ∘ suc ⟩ ⊆ ⟨ U ⟩\n sucIncl U x = map λ (α , x≡∑αUsuc) → (λ { zero → 0r ; (suc i) → α i }) , x≡∑αUsuc ∙ path _ _\n where\n path : ∀ s u₀ → s ≡ 0r · u₀ + s\n path = solve R'\n\n emptyFGIdeal : ∀ (V : FinVec R 0) → ⟨ V ⟩ ≡ 0Ideal\n emptyFGIdeal V = CommIdeal≡Char (λ _ → rec (is-set _ _) snd)\n (λ _ x≡0 → ∣ (λ ()) , x≡0 ∣)\n\n 0FGIdealLIncl : {n : ℕ} → ⟨ replicateFinVec n 0r ⟩ ⊆ 0Ideal\n 0FGIdealLIncl x = elim (λ _ → is-set _ _)\n λ (α , x≡∑α0) → subst-∈ 0Ideal (sym x≡∑α0) (∑Closed 0Ideal (λ i → α i · 0r)\n λ i → subst-∈ 0Ideal (sym (0RightAnnihilates _)) refl)\n\n 0FGIdealRIncl : {n : ℕ} → 0Ideal ⊆ ⟨ replicateFinVec n 0r ⟩\n 0FGIdealRIncl x x≡0 = subst-∈ ⟨ replicateFinVec _ 0r ⟩ (sym x≡0)\n (⟨ replicateFinVec _ 0r ⟩ .snd .contains0)\n\n 0FGIdeal : {n : ℕ} → ⟨ replicateFinVec n 0r ⟩ ≡ 0Ideal\n 0FGIdeal = CommIdeal≡Char 0FGIdealLIncl 0FGIdealRIncl\n\n FGIdealAddLemmaLIncl : {n m : ℕ} (U : FinVec R n) (V : FinVec R m)\n → ⟨ U ++Fin V ⟩ ⊆ (⟨ U ⟩ +i ⟨ V ⟩)\n FGIdealAddLemmaLIncl {n = ℕzero} U V x x∈⟨V⟩ =\n ∣ (0r , x) , ⟨ U ⟩ .snd .contains0 , x∈⟨V⟩ , sym (+Lid x) ∣\n FGIdealAddLemmaLIncl {n = ℕsuc n} U V x = rec isPropPropTrunc helperΣ\n where\n helperΣ : Σ[ α ∈ FinVec R _ ] (x ≡ ∑ λ i → α i · (U ++Fin V) i) → x ∈ (⟨ U ⟩ +i ⟨ V ⟩)\n helperΣ (α , p) = subst-∈ (⟨ U ⟩ +i ⟨ V ⟩) (sym p)\n ((⟨ U ⟩ +i ⟨ V ⟩) .snd .+Closed zeroIncl sumIncl)\n where\n zeroIncl : (α zero · U zero) ∈ (⟨ U ⟩ +i ⟨ V ⟩)\n zeroIncl = +iLincl ⟨ U ⟩ ⟨ V ⟩ (α zero · U zero)\n (⟨ U ⟩ .snd .·Closed (α zero) (indInIdeal U zero))\n\n sumIncl : (∑ λ i → (α ∘ suc) i · ((U ∘ suc) ++Fin V) i) ∈ (⟨ U ⟩ +i ⟨ V ⟩)\n sumIncl = let sum = ∑ λ i → (α ∘ suc) i · ((U ∘ suc) ++Fin V) i in\n +iRespLincl ⟨ U ∘ suc ⟩ ⟨ U ⟩ ⟨ V ⟩ (sucIncl U) sum\n (FGIdealAddLemmaLIncl (U ∘ suc) V _ ∣ (α ∘ suc) , refl ∣)\n\n FGIdealAddLemmaRIncl : {n m : ℕ} (U : FinVec R n) (V : FinVec R m)\n → (⟨ U ⟩ +i ⟨ V ⟩) ⊆ ⟨ U ++Fin V ⟩\n FGIdealAddLemmaRIncl U V x = rec isPropPropTrunc (uncurry3 helper)\n where\n helperΣ : ((y , z) : R × R)\n → Σ[ α ∈ FinVec R _ ] (y ≡ ∑ λ i → α i · U i)\n → Σ[ β ∈ FinVec R _ ] (z ≡ ∑ λ i → β i · V i)\n → x ≡ y + z\n → x ∈ ⟨ U ++Fin V ⟩\n helperΣ (y , z) (α , y≡∑αU) (β , z≡∑βV) x≡y+z = ∣ (α ++Fin β) , path ∣\n where\n path : x ≡ ∑ λ i → (α ++Fin β) i · (U ++Fin V) i\n path = x ≡⟨ x≡y+z ⟩\n y + z ≡⟨ cong₂ (_+_) y≡∑αU z≡∑βV ⟩\n (∑ λ i → α i · U i) + (∑ λ i → β i · V i) ≡⟨ sym (∑Split++ (λ i → α i · U i) _) ⟩\n (∑ ((λ i → α i · U i) ++Fin (λ i → β i · V i))) ≡⟨ ∑Ext (mul++dist α U β V) ⟩\n (∑ λ i → (α ++Fin β) i · (U ++Fin V) i) ∎\n\n helper : ((y , z) : R × R)\n → ∃[ α ∈ FinVec R _ ] (y ≡ ∑ λ i → α i · U i)\n → ∃[ β ∈ FinVec R _ ] (z ≡ ∑ λ i → β i · V i)\n → x ≡ y + z\n → x ∈ ⟨ U ++Fin V ⟩\n helper _ = rec2 (isPropΠ (λ _ → isPropPropTrunc)) (helperΣ _)\n\n FGIdealAddLemma : {n m : ℕ} (U : FinVec R n) (V : FinVec R m)\n → ⟨ U ++Fin V ⟩ ≡ ⟨ U ⟩ +i ⟨ V ⟩\n FGIdealAddLemma U V = CommIdeal≡Char (FGIdealAddLemmaLIncl U V) (FGIdealAddLemmaRIncl U V)\n\n\n IdealAddAssoc : {n m k : ℕ} (U : FinVec R n) (V : FinVec R m) (W : FinVec R k)\n → ⟨ U ++Fin (V ++Fin W) ⟩ ≡ ⟨ (U ++Fin V) ++Fin W ⟩\n IdealAddAssoc {n = n} {m = m} {k = k} U V W =\n let genIdealExpl : (n : ℕ) → FinVec R n → CommIdeal\n genIdealExpl _ V = ⟨ V ⟩\n in cong₂ genIdealExpl (+ℕ-assoc n m k) (++FinAssoc U V W)\n\n ++FinComm : ∀ {n m : ℕ} (V : FinVec R n) (W : FinVec R m)\n → ⟨ V ++Fin W ⟩ ≡ ⟨ W ++Fin V ⟩\n ++FinComm V W = FGIdealAddLemma V W ∙∙ +iComm ⟨ V ⟩ ⟨ W ⟩ ∙∙ sym (FGIdealAddLemma W V)\n\n open ProdFin R'\n prodIn··Ideal : {n m : ℕ} (U : FinVec R n) (V : FinVec R m) (x y : R)\n → (x ∈ ⟨ U ⟩) → (y ∈ ⟨ V ⟩) → (x · y) ∈ ⟨ U ··Fin V ⟩\n prodIn··Ideal {n = n} {m = m} U V x y = map2 Σhelper\n where\n Σhelper : Σ[ α ∈ FinVec R n ] x ≡ linearCombination R' α U\n → Σ[ β ∈ FinVec R m ] y ≡ linearCombination R' β V\n → Σ[ γ ∈ FinVec R (n ·ℕ m) ] (x · y) ≡ linearCombination R' γ (U ··Fin V)\n Σhelper (α , x≡∑αU) (β , y≡∑βV) = α ··Fin β , path\n where\n path : x · y ≡ ∑ λ i → (α ··Fin β) i · (U ··Fin V) i\n path = x · y ≡⟨ cong₂ (_·_) x≡∑αU y≡∑βV ⟩\n (∑ λ i → α i · U i) · (∑ λ i → β i · V i) ≡⟨ ∑Dist··Fin (λ i → α i · U i) _ ⟩\n (∑ λ j → ((λ i → α i · U i) ··Fin (λ i → β i · V i)) j) ≡⟨ ∑Ext (·Dist··Fin α U β V) ⟩\n (∑ λ i → (α ··Fin β) i · (U ··Fin V) i) ∎\n\n FGIdealMultLemmaLIncl : {n m : ℕ} (U : FinVec R n) (V : FinVec R m)\n → ⟨ U ··Fin V ⟩ ⊆ (⟨ U ⟩ ·i ⟨ V ⟩)\n FGIdealMultLemmaLIncl U V x = elim (λ _ → isPropPropTrunc)\n λ (α , x≡∑αUV) → subst-∈ (⟨ U ⟩ ·i ⟨ V ⟩) (sym x≡∑αUV) --replace x by ∑αᵢⱼUᵢVⱼ\n (∑Closed (⟨ U ⟩ ·i ⟨ V ⟩) (λ i → α i · (U ··Fin V) i) --show that each αᵢ(U··V)ᵢ is in product\n λ i → (⟨ U ⟩ ·i ⟨ V ⟩) .snd .·Closed (α i) --drop the α's\n (flattenElim {P = _∈ (⟨ U ⟩ ·i ⟨ V ⟩)} (toMatrix U V) --show theat UᵢVⱼ is in product\n (λ j k → prodInProd ⟨ U ⟩ ⟨ V ⟩ (U j) (V k) (indInIdeal U j) (indInIdeal V k)) i))\n\n FGIdealMultLemmaRIncl : {n m : ℕ} (U : FinVec R n) (V : FinVec R m)\n → (⟨ U ⟩ ·i ⟨ V ⟩) ⊆ ⟨ U ··Fin V ⟩\n FGIdealMultLemmaRIncl U V x = elim (λ _ → isPropPropTrunc)\n λ (_ , (α , β) , ∀α∈⟨U⟩ , ∀β∈⟨V⟩ , x≡∑αβ) → subst-∈ ⟨ U ··Fin V ⟩ (sym x≡∑αβ)\n (∑Closed ⟨ U ··Fin V ⟩ _ (λ i → prodIn··Ideal U V (α i) (β i) (∀α∈⟨U⟩ i) (∀β∈⟨V⟩ i)))\n\n FGIdealMultLemma : {n m : ℕ} (U : FinVec R n) (V : FinVec R m)\n → ⟨ U ··Fin V ⟩ ≡ ⟨ U ⟩ ·i ⟨ V ⟩\n FGIdealMultLemma U V = CommIdeal≡Char (FGIdealMultLemmaLIncl U V) (FGIdealMultLemmaRIncl U V)\n", "meta": {"hexsha": "0bd4c5e6fc6f6713798322fb1948d0522172ae76", "size": 11428, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommRing/FGIdeal.agda", "max_stars_repo_name": "dolio/cubical", "max_stars_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/CommRing/FGIdeal.agda", "max_issues_repo_name": "dolio/cubical", "max_issues_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/CommRing/FGIdeal.agda", "max_forks_repo_name": "dolio/cubical", "max_forks_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.712, "max_line_length": 102, "alphanum_fraction": 0.5063878194, "num_tokens": 4590, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8807970842359876, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.6329358510328829}} {"text": "module Automaton.NonDeterministic where\n\nimport Lvl\nopen import Data.Boolean\nimport Data.Boolean.Operators\nopen Data.Boolean.Operators.Programming\nopen import Data.List using (List) renaming (∅ to ε ; _⊰_ to _·_)\nopen import Functional\nopen import Logic\nopen import Sets.ExtensionalPredicateSet\nopen import Structure.Setoid\nopen import Type\n\n-- Non-deterministic Automata\n-- `State` (Q) is the set of states.\n-- `Alphabet` (Σ) is the set of symbols/the alphabet.\n-- `transition` (δ) is the transition function.\n-- `start` (q₀) is the start state.\n-- `Final` (F) is the subset of State which are the final/accepting states.\nrecord NonDeterministic {ℓₚ ℓₛ ℓₑ ℓₐ} (State : Type{ℓₛ}) ⦃ equiv-state : Equiv{ℓₑ}(State) ⦄ (Alphabet : Type{ℓₐ}) : Type{ℓₛ Lvl.⊔ ℓₑ Lvl.⊔ ℓₐ Lvl.⊔ Lvl.𝐒(ℓₚ)} where\n constructor nondeterministic\n field\n transition : State → Alphabet → PredSet{ℓₚ}(State)\n start : State\n Final : PredSet{ℓₚ}(State)\n\n Word = List(Alphabet)\n\n -- Chained transition using a word (list of characters).\n wordTransition : State → Word → PredSet{ℓₑ}(State)\n wordTransition initialState ε = • initialState\n wordTransition initialState (a · l) = {!⋃ ?!} -- wordTransition (transition initialState a) l\n{-\n module LetterNotation where\n Q = State\n Σ = Alphabet\n δ = transition\n δ̂ = wordTransition\n q₀ = start\n F = Final\n\n -- A word is accepted by the automaton when it can transition from the start state to a final state.\n AcceptsWord : Word → Stmt\n AcceptsWord = (_∈ Final) ∘ wordTransition start\n\n -- The subset of State which are the accessible states from the start state by chained transitions.\n Accessible : PredSet(State)\n Accessible = ⊶(wordTransition start)\n\n automatonTransition : Alphabet → NonDeterministic(State)(Alphabet)\n transition (automatonTransition _) = transition\n start (automatonTransition c) = transition start c\n Final (automatonTransition _) = Final\n\n automatonTransitionWord : Word → NonDeterministic(State)(Alphabet)\n transition (automatonTransitionWord _) = transition\n start (automatonTransitionWord w) = wordTransition start w\n Final (automatonTransitionWord _) = Final\n-}\n", "meta": {"hexsha": "e718bcd244899efea71637f16ace86f60742b25b", "size": 2228, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Automaton/NonDeterministic.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Automaton/NonDeterministic.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Automaton/NonDeterministic.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.1333333333, "max_line_length": 164, "alphanum_fraction": 0.7069120287, "num_tokens": 648, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8807970779778825, "lm_q2_score": 0.7185943805178139, "lm_q1q2_score": 0.6329358306114171}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Algebra.Construct.Free.Semilattice.Relation.Unary.All.Def where\n\nopen import Prelude hiding (⊥; ⊤)\nopen import Algebra.Construct.Free.Semilattice.Eliminators\nopen import Algebra.Construct.Free.Semilattice.Definition\nopen import Cubical.Foundations.HLevels\nopen import Data.Empty.UniversePolymorphic\nopen import HITs.PropositionalTruncation.Sugar\nopen import HITs.PropositionalTruncation.Properties\nopen import HITs.PropositionalTruncation\nopen import Data.Unit.UniversePolymorphic\n\nprivate\n variable p : Level\n\ndup-◻ : (P : A → Type p) → (x : A) (xs : Type p) → (∥ P x ∥ × ∥ P x ∥ × xs) ⇔ (∥ P x ∥ × xs)\ndup-◻ P _ _ .fun = snd\ndup-◻ P _ _ .inv (x , xs) = x , x , xs\ndup-◻ P _ _ .rightInv (x , xs) = refl\ndup-◻ P _ _ .leftInv (x₁ , x₂ , xs) i .fst = squash x₂ x₁ i\ndup-◻ P _ _ .leftInv (x₁ , x₂ , xs) i .snd = (x₂ , xs)\n\ncom-◻ : (P : A → Type p) → (x y : A) (xs : Type p) → (∥ P x ∥ × ∥ P y ∥ × xs) ⇔ (∥ P y ∥ × ∥ P x ∥ × xs)\ncom-◻ P _ _ _ .fun (x , y , xs) = y , x , xs\ncom-◻ P _ _ _ .inv (y , x , xs) = x , y , xs\ncom-◻ P _ _ _ .leftInv (x , y , xs) = refl\ncom-◻ P _ _ _ .rightInv (x , y , xs) = refl\n\n◻′ : (P : A → Type p) → A ↘ hProp p\n[ ◻′ P ]-set = isSetHProp\n([ ◻′ P ] x ∷ (xs , hxs)) .fst = ∥ P x ∥ × xs\n([ ◻′ P ] x ∷ (xs , hxs)) .snd y z = ΣProp≡ (λ _ → hxs) (squash (fst y) (fst z))\n[ ◻′ P ][] = ⊤ , λ x y _ → x\n[ ◻′ P ]-dup x xs = ΣProp≡ (λ _ → isPropIsProp) (isoToPath (dup-◻ P x (xs .fst)))\n[ ◻′ P ]-com x y xs = ΣProp≡ (λ _ → isPropIsProp) (isoToPath (com-◻ P x y (xs .fst)))\n\n◻ : (P : A → Type p) → 𝒦 A → Type p\n◻ P xs = [ ◻′ P ]↓ xs .fst\n\nisProp-◻ : ∀ {P : A → Type p} {xs} → isProp (◻ P xs)\nisProp-◻ {P = P} {xs = xs} = [ ◻′ P ]↓ xs .snd\n", "meta": {"hexsha": "f6934fe2b30971240355266172f5d9050538cc9b", "size": 1700, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Algebra/Construct/Free/Semilattice/Relation/Unary/All/Def.agda", "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "agda/Algebra/Construct/Free/Semilattice/Relation/Unary/All/Def.agda", "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Algebra/Construct/Free/Semilattice/Relation/Unary/All/Def.agda", "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.6363636364, "max_line_length": 104, "alphanum_fraction": 0.5617647059, "num_tokens": 754, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289387998695209, "lm_q2_score": 0.7634837635542924, "lm_q1q2_score": 0.6328813146805602}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import Types\nopen import Functions\nopen import Paths\nopen import HLevel\nopen import Equivalences\n\nmodule FiberEquivalences {i j k} {A : Set i} {P : A → Set k} {Q : A → Set j}\n (f : (x : A) → (P x → Q x)) where\n\n-- We want to prove that if [f] induces an equivalence on the total spaces,\n-- then [f] induces an equivalence fiberwise\n\ntotal-map : Σ A P → Σ A Q\ntotal-map (x , y) = (x , f x y)\n\nmodule TotalMapEquiv (e : is-equiv total-map) where\n\n total-equiv : Σ A P ≃ Σ A Q\n total-equiv = (total-map , e)\n\n -- The inverse is propositionally fiberwise\n base-path-inverse : (x : A) (y : Q x) → π₁ ((total-equiv ⁻¹) ☆ (x , y)) ≡ x\n base-path-inverse x y = base-path (inverse-right-inverse total-equiv (x , y))\n\n -- And the action of [total-map] on paths is correct on the base path\n total-map-fiberwise-on-paths : {u v : Σ A P} (p : u ≡ v)\n → base-path (ap total-map p) ≡ base-path p\n total-map-fiberwise-on-paths {u} {.u} refl = refl\n\n -- Here is the fiberwise inverse, we use the inverse of the total map and\n -- transform it into a fiberwise map using [base-path-inverse]\n inv : ((x : A) → (Q x → P x))\n inv x y = transport P (base-path-inverse x y)\n (π₂ ((total-equiv ⁻¹) ☆ (x , y)))\n\n -- We prove that [inv] is a right and left inverse to [f]\n\n inv-right-inverse : (x : A) (y : Q x) → f x (inv x y) ≡ y\n inv-right-inverse x y =\n app-trans _ _ f (base-path (inverse-right-inverse total-equiv (x , y)))\n (π₂ (inverse (_ , e) (x , y)))\n ∘ fiber-path (inverse-right-inverse total-equiv (x , y))\n\n inv-left-inverse : (x : A) (y : P x) → inv x (f x y) ≡ y\n inv-left-inverse x y =\n ap (λ u → transport P (base-path (inverse-right-inverse total-equiv\n (x , f x y))) u)\n (lemma2 x y)\n ∘ (! (trans-concat P (base-path (inverse-right-inverse total-equiv\n (x , f x y)))\n (! (base-path-inverse x (f x y))) y)\n ∘ ap (λ p → transport P p y)\n (opposite-left-inverse (ap π₁\n (inverse-right-inverse total-equiv (x , f x y))))) where\n\n lemma1 : (x : A) (y : P x)\n → base-path-inverse x (f x y)\n ≡ base-path (inverse-left-inverse total-equiv (x , y))\n lemma1 x y = ap base-path (inverse-triangle total-equiv (x , y))\n ∘ total-map-fiberwise-on-paths _\n\n lemma2 : (x : A) (y : P x)\n → π₂ ((total-equiv ⁻¹) ☆ (x , f x y))\n ≡ transport P (! (base-path-inverse x (f x y))) y\n lemma2 x y = ! (fiber-path (! (inverse-left-inverse total-equiv (x , y))))\n ∘ ap (λ p → transport P p y)\n (ap-opposite π₁ (inverse-left-inverse total-equiv (x , y))\n ∘ ! (ap ! (lemma1 x y)))\n\n fiberwise-is-equiv : ((x : A) → is-equiv (f x))\n fiberwise-is-equiv x = iso-is-eq (f x) (inv x) (inv-right-inverse x)\n (inv-left-inverse x)\n\nfiberwise-is-equiv : is-equiv total-map → ((x : A) → is-equiv (f x))\nfiberwise-is-equiv = TotalMapEquiv.fiberwise-is-equiv\n", "meta": {"hexsha": "a3d0ece8e0790fbba6ef116c62b8ccf66130a18b", "size": 3123, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "old/FiberEquivalences.agda", "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 294, "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_issues_repo_path": "old/FiberEquivalences.agda", "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 31, "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_forks_repo_path": "old/FiberEquivalences.agda", "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 50, "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "avg_line_length": 40.0384615385, "max_line_length": 79, "alphanum_fraction": 0.5485110471, "num_tokens": 940, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9005297861178929, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.6326492423274953}} {"text": "module Data.Bin.Rec where\n\nopen import Data.Bin hiding (suc; fromℕ)\nopen import Induction.WellFounded\n\nopen import Data.Nat using (ℕ; zero; suc) renaming (_<_ to _ℕ<_)\nopen import Data.Nat.Properties\n\nopen import Relation.Binary.PropositionalEquality\nopen import Data.Bin.Bijection\n\nimport Induction.Nat\n\nwf : Well-founded _<_\nwf x = go' x where\n P : ℕ → Set\n P x = Acc _<_ (fromℕ x)\n\n podgon : ∀ {y} → P (toℕ y) → Acc _<_ y\n podgon = subst (λ q → Acc _<_ q) (fromToℕ-inverse _)\n\n go'' : (x : ℕ) → ((y : ℕ) → y ℕ< x → P y) → P x\n go'' x rec = acc (λ { y (less ty (Trunc=-equiv [ a⇑₁ ] [ a⇑₂ ])\n (contr-has-all-paths univ-cov-univ [ a⇑₁ ] [ a⇑₂ ])\n\n [path]-has-all-paths :\n ∀ {a⇑₁ a⇑₂ : TotalSpace univ-cov}\n → has-all-paths (a⇑₁ =₀ a⇑₂)\n [path]-has-all-paths {a⇑₁} {a⇑₂} =\n coe (ap has-all-paths $ ua (Trunc=-equiv [ a⇑₁ ] [ a⇑₂ ]))\n $ contr-has-all-paths (raise-level -2 univ-cov-univ [ a⇑₁ ] [ a⇑₂ ])\n\n to : ∀ {a₂} → Fiber univ-cov a₂ → a₁ =₀ a₂\n to {a₂} a⇑₂ = ap₀ fst ([path] (a₁ , a⇑₁) (a₂ , a⇑₂))\n\n from : ∀ {a₂} → a₁ =₀ a₂ → Fiber univ-cov a₂\n from p = cover-trace univ-cov a⇑₁ p\n\n to-from : ∀ {a₂} (p : a₁ =₀ a₂) → to (from p) == p\n to-from = Trunc-elim\n (λ _ → =-preserves-set Trunc-level)\n (λ p → lemma p)\n where\n lemma : ∀ {a₂} (p : a₁ == a₂) → to (from [ p ]) == [ p ]\n lemma idp =\n ap₀ fst ([path] (a₁ , a⇑₁) (a₁ , a⇑₁))\n =⟨ ap (ap₀ fst)\n $ [path]-has-all-paths\n ([path] (a₁ , a⇑₁) (a₁ , a⇑₁))\n (idp₀ :> ((a₁ , a⇑₁) =₀ (a₁ , a⇑₁))) ⟩\n (idp₀ :> (a₁ =₀ a₁))\n ∎\n\n from-to : ∀ {a₂} (a⇑₂ : Fiber univ-cov a₂) → from (to a⇑₂) == a⇑₂\n from-to {a₂} a⇑₂ = Trunc-elim\n (λ p → =-preserves-set\n {x = from (ap₀ fst p)}\n {y = a⇑₂}\n (Fiber-level univ-cov a₂))\n (λ p → to-transp $ snd= p)\n ([path] (a₁ , a⇑₁) (a₂ , a⇑₂))\n\n theorem : ∀ a₂ → Fiber univ-cov a₂ ≃ (a₁ =₀ a₂)\n theorem a₂ = to , is-eq _ from to-from from-to\n", "meta": {"hexsha": "179dd850c42e5b8458411f4467a35d22e41b6de1", "size": 2137, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/homotopy/AnyUniversalCoverIsPathSet.agda", "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "theorems/homotopy/AnyUniversalCoverIsPathSet.agda", "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "theorems/homotopy/AnyUniversalCoverIsPathSet.agda", "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.3787878788, "max_line_length": 76, "alphanum_fraction": 0.4688816097, "num_tokens": 887, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392756357327, "lm_q2_score": 0.7154240018510025, "lm_q1q2_score": 0.6324629163687774}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Lists where all elements satisfy a given property\n------------------------------------------------------------------------\n\nmodule Data.List.All where\n\nopen import Data.List as List hiding (map; all)\nopen import Data.List.Any as Any using (here; there)\nopen Any.Membership-≡ using (_∈_; _⊆_)\nopen import Function\nopen import Level\nopen import Relation.Nullary\nimport Relation.Nullary.Decidable as Dec\nopen import Relation.Unary using (Decidable) renaming (_⊆_ to _⋐_)\nopen import Relation.Binary.PropositionalEquality\n\n-- All P xs means that all elements in xs satisfy P.\n\ninfixr 5 _∷_\n\ndata All {a p} {A : Set a}\n (P : A → Set p) : List A → Set (p ⊔ a) where\n [] : All P []\n _∷_ : ∀ {x xs} (px : P x) (pxs : All P xs) → All P (x ∷ xs)\n\nhead : ∀ {a p} {A : Set a} {P : A → Set p} {x xs} →\n All P (x ∷ xs) → P x\nhead (px ∷ pxs) = px\n\ntail : ∀ {a p} {A : Set a} {P : A → Set p} {x xs} →\n All P (x ∷ xs) → All P xs\ntail (px ∷ pxs) = pxs\n\nlookup : ∀ {a p} {A : Set a} {P : A → Set p} {xs : List A} →\n All P xs → (∀ {x : A} → x ∈ xs → P x)\nlookup [] ()\nlookup (px ∷ pxs) (here refl) = px\nlookup (px ∷ pxs) (there x∈xs) = lookup pxs x∈xs\n\ntabulate : ∀ {a p} {A : Set a} {P : A → Set p} {xs} →\n (∀ {x} → x ∈ xs → P x) → All P xs\ntabulate {xs = []} hyp = []\ntabulate {xs = x ∷ xs} hyp = hyp (here refl) ∷ tabulate (hyp ∘ there)\n\nmap : ∀ {a p q} {A : Set a} {P : A → Set p} {Q : A → Set q} →\n P ⋐ Q → All P ⋐ All Q\nmap g [] = []\nmap g (px ∷ pxs) = g px ∷ map g pxs\n\nall : ∀ {a p} {A : Set a} {P : A → Set p} →\n Decidable P → Decidable (All P)\nall p [] = yes []\nall p (x ∷ xs) with p x\nall p (x ∷ xs) | yes px = Dec.map′ (_∷_ px) tail (all p xs)\nall p (x ∷ xs) | no ¬px = no (¬px ∘ head)\n", "meta": {"hexsha": "4ac8448d0daba9dfbdaa92a6758934084d184977", "size": 1864, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/List/All.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/List/All.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Data/List/All.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.1379310345, "max_line_length": 72, "alphanum_fraction": 0.4973175966, "num_tokens": 675, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392909114835, "lm_q2_score": 0.7154239836484144, "lm_q1q2_score": 0.632462911205613}} {"text": "module Issue180 where\n\nmodule Example₁ where\n\n data C : Set where\n c : C → C\n\n data Indexed : (C → C) → Set where\n i : Indexed c\n\n foo : Indexed c → Set\n foo i = C\n\nmodule Example₂ where\n\n data List (A : Set) : Set where\n nil : List A\n cons : A → List A → List A\n\n postulate\n A : Set\n x : A\n\n T : Set\n T = List A → List A\n\n data P : List T → Set where\n p : (f : T) → P (cons f nil)\n\n data S : (xs : List T) → P xs → Set where\n s : (f : T) → S (cons f nil) (p f)\n\n foo : S (cons (cons x) nil) (p (cons x)) → A\n foo (s ._) = x\n", "meta": {"hexsha": "1101be5536ed582f1e38f73878682d2fca89fe8d", "size": 562, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue180.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue180.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue180.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 16.0571428571, "max_line_length": 46, "alphanum_fraction": 0.5177935943, "num_tokens": 211, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392725805822, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.632462903455181}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Decidable equality over lists parameterised by some setoid\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary\n\nmodule Data.List.Relation.Binary.Equality.DecSetoid\n {a ℓ} (DS : DecSetoid a ℓ) where\n\nimport Data.List.Relation.Binary.Equality.Setoid as SetoidEquality\nimport Data.List.Relation.Binary.Pointwise as PW\nopen import Level\nopen import Relation.Binary using (Decidable)\nopen DecSetoid DS\n\n------------------------------------------------------------------------\n-- Make all definitions from setoid equality available\n\nopen SetoidEquality setoid public\n\n------------------------------------------------------------------------\n-- Additional properties\n\ninfix 4 _≋?_\n\n_≋?_ : Decidable _≋_\n_≋?_ = PW.decidable _≟_\n\n≋-isDecEquivalence : IsDecEquivalence _≋_\n≋-isDecEquivalence = PW.isDecEquivalence isDecEquivalence\n\n≋-decSetoid : DecSetoid a (a ⊔ ℓ)\n≋-decSetoid = PW.decSetoid DS\n", "meta": {"hexsha": "3ce35756a144d88926b78f055140b8dfc17c672c", "size": 1081, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Equality/DecSetoid.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Equality/DecSetoid.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Equality/DecSetoid.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.4473684211, "max_line_length": 72, "alphanum_fraction": 0.5605920444, "num_tokens": 239, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8840392786908831, "lm_q2_score": 0.7154239836484143, "lm_q1q2_score": 0.6324629024627023}} {"text": "{-\n\nThis file contains:\n\n- Definition of set coequalizers as performed in https://1lab.dev/Data.Set.Coequaliser.html\n\n-}\n{-# OPTIONS --safe #-}\nmodule Cubical.HITs.SetCoequalizer.Base where\n\nopen import Cubical.Core.Primitives\n\nprivate\n variable\n ℓ ℓ' ℓ'' : Level\n A : Type ℓ\n B : Type ℓ'\n\n-- Set coequalizers as a higher inductive type\ndata SetCoequalizer {A : Type ℓ} {B : Type ℓ'} (f g : A → B) : Type (ℓ-max ℓ ℓ') where\n inc : B → SetCoequalizer f g\n coeq : (a : A) → inc (f a) ≡ inc (g a)\n squash : (x y : SetCoequalizer f g) → (p q : x ≡ y) → p ≡ q\n", "meta": {"hexsha": "86315a36177e8dc065dc5661ce617f2e1a504c97", "size": 573, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/SetCoequalizer/Base.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/HITs/SetCoequalizer/Base.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/HITs/SetCoequalizer/Base.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.875, "max_line_length": 91, "alphanum_fraction": 0.6265270506, "num_tokens": 210, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8723473779969195, "lm_q2_score": 0.7248702702332476, "lm_q1q2_score": 0.6323386796258921}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Injections\n------------------------------------------------------------------------\n\nmodule Function.Injection where\n\nopen import Function as Fun using () renaming (_∘_ to _⟨∘⟩_)\nopen import Level\nopen import Relation.Binary\nopen import Function.Equality as F\n using (_⟶_; _⟨$⟩_) renaming (_∘_ to _⟪∘⟫_)\nimport Relation.Binary.PropositionalEquality as P\n\n-- Injective functions.\n\nInjective : ∀ {a₁ a₂ b₁ b₂} {A : Setoid a₁ a₂} {B : Setoid b₁ b₂} →\n A ⟶ B → Set _\nInjective {A = A} {B} f = ∀ {x y} → f ⟨$⟩ x ≈₂ f ⟨$⟩ y → x ≈₁ y\n where\n open Setoid A renaming (_≈_ to _≈₁_)\n open Setoid B renaming (_≈_ to _≈₂_)\n\n-- The set of all injections between two setoids.\n\nrecord Injection {f₁ f₂ t₁ t₂}\n (From : Setoid f₁ f₂) (To : Setoid t₁ t₂) :\n Set (f₁ ⊔ f₂ ⊔ t₁ ⊔ t₂) where\n field\n to : From ⟶ To\n injective : Injective to\n\n-- The set of all injections from one set to another.\n\ninfix 3 _↣_\n\n_↣_ : ∀ {f t} → Set f → Set t → Set _\nFrom ↣ To = Injection (P.setoid From) (P.setoid To)\n\n-- Identity and composition.\n\ninfixr 9 _∘_\n\nid : ∀ {s₁ s₂} {S : Setoid s₁ s₂} → Injection S S\nid = record { to = F.id; injective = Fun.id }\n\n_∘_ : ∀ {f₁ f₂ m₁ m₂ t₁ t₂}\n {F : Setoid f₁ f₂} {M : Setoid m₁ m₂} {T : Setoid t₁ t₂} →\n Injection M T → Injection F M → Injection F T\nf ∘ g = record\n { to = to f ⟪∘⟫ to g\n ; injective = (λ {_} → injective g) ⟨∘⟩ injective f\n } where open Injection\n", "meta": {"hexsha": "dfc774397ad32f666efc78bb596a2fe7320fbd8f", "size": 1583, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Function/Injection.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Function/Injection.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Function/Injection.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.7818181818, "max_line_length": 72, "alphanum_fraction": 0.5344283007, "num_tokens": 534, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.872347368040789, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.632338677593853}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Data.List.Base where\n\nopen import Agda.Builtin.List public\nopen import Cubical.Core.Everything\nopen import Cubical.Data.Maybe.Base\nopen import Cubical.Data.Nat.Base\n\nmodule _ {ℓ} {A : Type ℓ} where\n\n infixr 5 _++_\n infixl 5 _∷ʳ_\n\n [_] : A → List A\n [ a ] = a ∷ []\n\n _++_ : List A → List A → List A\n [] ++ ys = ys\n (x ∷ xs) ++ ys = x ∷ xs ++ ys\n\n rev : List A → List A\n rev [] = []\n rev (x ∷ xs) = rev xs ++ [ x ]\n\n _∷ʳ_ : List A → A → List A\n xs ∷ʳ x = xs ++ x ∷ []\n\n length : List A → ℕ\n length [] = 0\n length (x ∷ l) = 1 + length l\n\n map : ∀ {ℓ'} {B : Type ℓ'} → (A → B) → List A → List B\n map f [] = []\n map f (x ∷ xs) = f x ∷ map f xs\n\n map2 : ∀ {ℓ' ℓ''} {B : Type ℓ'} {C : Type ℓ''}\n → (A → B → C) → List A → List B → List C\n map2 f [] _ = []\n map2 f _ [] = []\n map2 f (x ∷ xs) (y ∷ ys) = f x y ∷ map2 f xs ys\n\n foldr : ∀ {ℓ'} {B : Type ℓ'} → (A → B → B) → B → List A → B\n foldr f b [] = b\n foldr f b (x ∷ xs) = f x (foldr f b xs)\n\n foldl : ∀ {ℓ'} {B : Type ℓ'} → (B → A → B) → B → List A → B\n foldl f b [] = b\n foldl f b (x ∷ xs) = foldl f (f b x) xs\n", "meta": {"hexsha": "277cb4f44d38874cc5f4692b791a477e615144da", "size": 1161, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/List/Base.agda", "max_stars_repo_name": "Edlyr/cubical", "max_stars_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/List/Base.agda", "max_issues_repo_name": "Edlyr/cubical", "max_issues_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Data/List/Base.agda", "max_forks_repo_name": "Edlyr/cubical", "max_forks_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.693877551, "max_line_length": 61, "alphanum_fraction": 0.4797588286, "num_tokens": 505, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.837619979547273, "lm_q2_score": 0.7549149868676283, "lm_q1q2_score": 0.6323318758599926}} {"text": "------------------------------------------------------------------------\n-- Binary trees\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Equality\n\nmodule Tree {c⁺} (eq : ∀ {a p} → Equality-with-J a p c⁺) where\n\nopen Derived-definitions-and-properties eq\n\nopen import Prelude hiding (id)\n\nopen import Bag-equivalence eq\nopen import Bijection eq using (_↔_)\nopen import Function-universe eq\nopen import List eq\n\n------------------------------------------------------------------------\n-- Binary trees\n\ndata Tree (A : Type) : Type where\n leaf : Tree A\n node : (l : Tree A) (x : A) (r : Tree A) → Tree A\n\n-- Any.\n\nAnyT : ∀ {A} → (A → Type) → (Tree A → Type)\nAnyT P leaf = ⊥\nAnyT P (node l x r) = AnyT P l ⊎ P x ⊎ AnyT P r\n\n-- Membership.\n\ninfix 4 _∈T_\n\n_∈T_ : ∀ {A} → A → Tree A → Type\nx ∈T t = AnyT (_≡_ x) t\n\n-- Bag equivalence.\n\n_≈-bagT_ : ∀ {A} → Tree A → Tree A → Type\nt₁ ≈-bagT t₂ = ∀ x → x ∈T t₁ ↔ x ∈T t₂\n\n------------------------------------------------------------------------\n-- Singleton\n\n-- Singleton trees.\n\nsingleton : {A : Type} → A → Tree A\nsingleton x = node leaf x leaf\n\n-- Any lemma for singleton.\n\nAny-singleton : ∀ {A : Type} (P : A → Type) {x} →\n AnyT P (singleton x) ↔ P x\nAny-singleton P {x} =\n AnyT P (singleton x) ↔⟨⟩\n ⊥ ⊎ P x ⊎ ⊥ ↔⟨ ⊎-left-identity ⟩\n P x ⊎ ⊥ ↔⟨ ⊎-right-identity ⟩\n P x □\n\n------------------------------------------------------------------------\n-- Flatten\n\n-- Inorder flattening of a tree.\n\nflatten : {A : Type} → Tree A → List A\nflatten leaf = []\nflatten (node l x r) = flatten l ++ x ∷ flatten r\n\n-- Flatten does not add or remove any elements.\n\nflatten-lemma : {A : Type} (t : Tree A) → ∀ z → z ∈ flatten t ↔ z ∈T t\nflatten-lemma leaf = λ z → ⊥ □\nflatten-lemma (node l x r) = λ z →\n z ∈ flatten l ++ x ∷ flatten r ↔⟨ Any-++ (_≡_ z) _ _ ⟩\n z ∈ flatten l ⊎ z ≡ x ⊎ z ∈ flatten r ↔⟨ flatten-lemma l z ⊎-cong (z ≡ x □) ⊎-cong flatten-lemma r z ⟩\n z ∈T l ⊎ z ≡ x ⊎ z ∈T r □\n\n------------------------------------------------------------------------\n-- Bags can (perhaps) be defined as binary trees quotiented by bag\n-- equivalence\n\n-- Agda doesn't support quotients, so the following type is used to\n-- state that two quotients are isomorphic.\n--\n-- Note that this definition may not actually make sense if the\n-- relations _≈A_ and _≈B_ are not /proof-irrelevant/ equivalence\n-- relations.\n\nrecord _/_↔_/_ (A : Type) (_≈A_ : A → A → Type)\n (B : Type) (_≈B_ : B → B → Type) : Type where\n field\n to : A → B\n to-resp : ∀ x y → x ≈A y → to x ≈B to y\n from : B → A\n from-resp : ∀ x y → x ≈B y → from x ≈A from y\n to∘from : ∀ x → to (from x) ≈B x\n from∘to : ∀ x → from (to x) ≈A x\n\n-- Lists quotiented by bag equivalence are isomorphic to binary trees\n-- quotiented by bag equivalence (assuming that one can actually\n-- quotient by bag equivalence, and that the definition of _/_↔_/_\n-- makes sense in this case).\n\nlist-bags↔tree-bags : {A : Type} → List A / _≈-bag_ ↔ Tree A / _≈-bagT_\nlist-bags↔tree-bags {A} = record\n { to = to-tree\n ; to-resp = λ xs ys xs≈ys z →\n z ∈T to-tree xs ↔⟨ to-tree-lemma xs z ⟩\n z ∈ xs ↔⟨ xs≈ys z ⟩\n z ∈ ys ↔⟨ inverse $ to-tree-lemma ys z ⟩\n z ∈T to-tree ys □\n ; from = flatten\n ; from-resp = λ t₁ t₂ t₁≈t₂ z →\n z ∈ flatten t₁ ↔⟨ flatten-lemma t₁ z ⟩\n z ∈T t₁ ↔⟨ t₁≈t₂ z ⟩\n z ∈T t₂ ↔⟨ inverse $ flatten-lemma t₂ z ⟩\n z ∈ flatten t₂ □\n ; to∘from = to∘from\n ; from∘to = from∘to\n }\n where\n to-tree : List A → Tree A\n to-tree = foldr (node leaf) leaf\n\n to-tree-lemma : ∀ xs z → z ∈T to-tree xs ↔ z ∈ xs\n to-tree-lemma [] = λ z → ⊥ □\n to-tree-lemma (x ∷ xs) = λ z →\n ⊥ ⊎ z ≡ x ⊎ z ∈T to-tree xs ↔⟨ id ⊎-cong id ⊎-cong to-tree-lemma xs z ⟩\n ⊥ ⊎ z ≡ x ⊎ z ∈ xs ↔⟨ ⊎-assoc ⟩\n (⊥ ⊎ z ≡ x) ⊎ z ∈ xs ↔⟨ ⊎-left-identity ⊎-cong id ⟩\n z ≡ x ⊎ z ∈ xs □\n\n to-tree-++ : ∀ {P : A → Type} xs {ys} →\n AnyT P (to-tree (xs ++ ys)) ↔\n AnyT P (to-tree xs) ⊎ AnyT P (to-tree ys)\n to-tree-++ {P} [] {ys} =\n AnyT P (to-tree ys) ↔⟨ inverse ⊎-left-identity ⟩\n ⊥ ⊎ AnyT P (to-tree ys) □\n to-tree-++ {P} (x ∷ xs) {ys} =\n ⊥ ⊎ P x ⊎ AnyT P (to-tree (xs ++ ys)) ↔⟨ id ⊎-cong id ⊎-cong to-tree-++ xs ⟩\n ⊥ ⊎ P x ⊎ AnyT P (to-tree xs) ⊎ AnyT P (to-tree ys) ↔⟨ lemma _ _ _ _ ⟩\n (⊥ ⊎ P x ⊎ AnyT P (to-tree xs)) ⊎ AnyT P (to-tree ys) □\n where\n lemma : (A B C D : Type) → A ⊎ B ⊎ C ⊎ D ↔ (A ⊎ B ⊎ C) ⊎ D\n lemma A B C D =\n A ⊎ B ⊎ C ⊎ D ↔⟨ ⊎-assoc ⟩\n (A ⊎ B) ⊎ C ⊎ D ↔⟨ ⊎-assoc ⟩\n ((A ⊎ B) ⊎ C) ⊎ D ↔⟨ inverse ⊎-assoc ⊎-cong id ⟩\n (A ⊎ B ⊎ C) ⊎ D □\n\n to∘from : ∀ t → to-tree (flatten t) ≈-bagT t\n to∘from leaf = λ z → ⊥ □\n to∘from (node l x r) = λ z →\n z ∈T to-tree (flatten l ++ x ∷ flatten r) ↔⟨ to-tree-++ (flatten l) ⟩\n z ∈T to-tree (flatten l) ⊎ ⊥ ⊎ z ≡ x ⊎ z ∈T to-tree (flatten r) ↔⟨ to∘from l z ⊎-cong id ⊎-cong id ⊎-cong to∘from r z ⟩\n z ∈T l ⊎ ⊥ ⊎ z ≡ x ⊎ z ∈T r ↔⟨ id ⊎-cong ⊎-left-identity ⟩\n z ∈T l ⊎ z ≡ x ⊎ z ∈T r □\n\n from∘to : ∀ xs → flatten (to-tree xs) ≈-bag xs\n from∘to [] = λ z → ⊥ □\n from∘to (x ∷ xs) = λ z →\n z ≡ x ⊎ z ∈ flatten (to-tree xs) ↔⟨ id ⊎-cong from∘to xs z ⟩\n z ≡ x ⊎ z ∈ xs □\n", "meta": {"hexsha": "a5c17d263c7a53aedbc5a232feda7eb3962fb421", "size": 5712, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Tree.agda", "max_stars_repo_name": "nad/equality", "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_issues_repo_path": "src/Tree.agda", "max_issues_repo_name": "nad/equality", "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Tree.agda", "max_forks_repo_name": "nad/equality", "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.2035928144, "max_line_length": 124, "alphanum_fraction": 0.4471288515, "num_tokens": 2105, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199552262967, "lm_q2_score": 0.7549149978955811, "lm_q1q2_score": 0.6323318667369565}} {"text": "import Lvl\nopen import Structure.Operator.Vector\nopen import Structure.Setoid\nopen import Type\n\nmodule Structure.Operator.Vector.FiniteDimensional\n {ℓᵥ ℓₛ ℓᵥₑ ℓₛₑ}\n {V : Type{ℓᵥ}} ⦃ equiv-V : Equiv{ℓᵥₑ}(V) ⦄\n {S : Type{ℓₛ}} ⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄\n {_+ᵥ_ : V → V → V}\n {_⋅ₛᵥ_ : S → V → V}\n {_+ₛ_ _⋅ₛ_ : S → S → S}\n ⦃ vectorSpace : VectorSpace(_+ᵥ_)(_⋅ₛᵥ_)(_+ₛ_)(_⋅ₛ_) ⦄\n where\n\nopen VectorSpace(vectorSpace)\n\nopen import Data.Tuple using (_⨯_ ; _,_)\nopen import Functional using (id ; _∘_ ; _∘₂_ ; _$_ ; swap ; _on₂_)\nopen import Function.Equals\nopen import Logic\nopen import Logic.Predicate\nopen import Numeral.CoordinateVector as Vec using () renaming (Vector to Vec)\nopen import Numeral.Finite\nopen import Numeral.Natural\nopen import Sets.ExtensionalPredicateSet as PredSet using (PredSet ; _∈_ ; [∋]-binaryRelator)\nopen import Structure.Function.Domain\nopen import Structure.Operator.Vector.LinearCombination ⦃ vectorSpace = vectorSpace ⦄\nopen import Syntax.Function\n\nprivate variable n : ℕ\n\n-- A sequence of vectors is linearly independent when there is no vector that can be represented as a linear combination by the others.\n-- Note: Equivalent to: `∀{sf} → (linearCombination(vf)(sf) ≡ 𝟎ᵥ) → (sf ⊜ Vec.fill(𝟎ₛ))`.\nLinearlyIndependent : Vec(n)(V) → Stmt\nLinearlyIndependent = Injective ∘ linearCombination\n\n-- A sequence 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.\nSpanning : Vec(n)(V) → Stmt\nSpanning = Surjective ∘ linearCombination\n\n-- A sequence 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.\n-- A sequence of vectors is a basis when they span the vector space and is linearly independent.\nBasis : Vec(n)(V) → Stmt\nBasis = Bijective ∘ linearCombination\n\n-- A finite dimensional vector space is when there are a finite number of vectors that spans the whole space.\nFiniteDimensional : Stmt\nFiniteDimensional = ∃(n ↦ ∃(vf ↦ Spanning{n}(vf)))\n", "meta": {"hexsha": "3b845264657c65f2e349f54def520fc0cdacab28", "size": 2054, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Operator/Vector/FiniteDimensional.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Operator/Vector/FiniteDimensional.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Operator/Vector/FiniteDimensional.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.08, "max_line_length": 157, "alphanum_fraction": 0.7395326193, "num_tokens": 645, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110511888303, "lm_q2_score": 0.7090191214879992, "lm_q1q2_score": 0.6323110880471935}} {"text": "{-# OPTIONS --without-K --safe #-}\n\n-- Defines Restriction Category\n-- https://ncatlab.org/nlab/show/restriction+category\n-- but see also\n-- https://github.com/jmchapman/restriction-categories\n\n-- Notation choice: one of the interpretations is that the\n-- restriction structure captures the \"domain of definedness\"\n-- of a morphism, as a (partial) identity. As this is positive\n-- information, we will use f ↓ (as a postfix operation) to\n-- denote this. Note that computability theory uses the same\n-- notation to mean definedness.\n\n-- Note, as we're working in Setoid-Enriched Categories, we need\n-- to add an explicit axiom, that ↓ preserves ≈\nmodule Categories.Category.Restriction where\n\nopen import Level using (Level; _⊔_)\n\nopen import Categories.Category.Core using (Category)\n\nprivate\n variable\n o ℓ e : Level\n\nrecord Restriction (C : Category o ℓ e) : Set (o ⊔ ℓ ⊔ e) where\n open Category C using (Obj; _⇒_; _∘_; _≈_; id)\n\n field\n _↓ : {A B : Obj} → A ⇒ B → A ⇒ A\n -- partial identity on the right\n pidʳ : {A B : Obj} {f : A ⇒ B} → f ∘ f ↓ ≈ f\n -- the domain-of-definition arrows commute\n ↓-comm : {A B C : Obj} {f : A ⇒ B} {g : A ⇒ C} → f ↓ ∘ g ↓ ≈ g ↓ ∘ f ↓\n -- domain-of-definition denests (on the right)\n ↓-denestʳ : {A B C : Obj} {f : A ⇒ B} {g : A ⇒ C} → (g ∘ f ↓) ↓ ≈ g ↓ ∘ f ↓\n -- domain-of-definition has a skew-commutative law\n ↓-skew-comm : {A B C : Obj} {g : A ⇒ B} {f : C ⇒ A} → g ↓ ∘ f ≈ f ∘ (g ∘ f) ↓\n -- and the new axiom, ↓ is a congruence\n ↓-cong : {A B : Obj} {f g : A ⇒ B} → f ≈ g → f ↓ ≈ g ↓\n\n -- it is convenient to define the total predicate in this context\n total : {A B : Obj} (f : A ⇒ B) → Set e\n total f = f ↓ ≈ id\n", "meta": {"hexsha": "523f8c4d533408799ad349e7c226d9306daf144c", "size": 1698, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Restriction.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/Restriction.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/Restriction.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 36.9130434783, "max_line_length": 81, "alphanum_fraction": 0.6107184923, "num_tokens": 570, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577680940822761, "lm_q2_score": 0.7371581684030623, "lm_q1q2_score": 0.6323107571482762}} {"text": "{-\n\nThis file proves the higher groupoid structure of types\nfor homogeneous and heterogeneous paths\n\n-}\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Foundations.GroupoidLaws where\n\nopen import Cubical.Foundations.Prelude\n\nprivate\n variable\n ℓ : Level\n A : Type ℓ\n x y z w v : A\n\n_⁻¹ : (x ≡ y) → (y ≡ x)\nx≡y ⁻¹ = sym x≡y\n\ninfix 40 _⁻¹\n\n-- homogeneous groupoid laws\n\nsymInvo : (p : x ≡ y) → p ≡ p ⁻¹ ⁻¹\nsymInvo p = refl\n\nrUnit : (p : x ≡ y) → p ≡ p ∙ refl\nrUnit p j i = compPath-filler p refl j i\n\n-- The filler of left unit: lUnit-filler p =\n-- PathP (λ i → PathP (λ j → PathP (λ k → A) x (p (~ j ∨ i)))\n-- (refl i) (λ j → compPath-filler refl p i j)) (λ k i → (p (~ k ∧ i ))) (lUnit p)\n\nlUnit-filler : {x y : A} (p : x ≡ y) → I → I → I → A\nlUnit-filler {x = x} p j k i =\n hfill (λ j → λ { (i = i0) → x\n ; (i = i1) → p (~ k ∨ j )\n ; (k = i0) → p i\n -- ; (k = i1) → compPath-filler refl p j i\n }) (inS (p (~ k ∧ i ))) j\n\nlUnit : (p : x ≡ y) → p ≡ refl ∙ p\nlUnit p j i = lUnit-filler p i1 j i\n\nsymRefl : refl {x = x} ≡ refl ⁻¹\nsymRefl i = refl\n\ncompPathRefl : refl {x = x} ≡ refl ∙ refl\ncompPathRefl = rUnit refl\n\n-- The filler of right cancellation: rCancel-filler p =\n-- PathP (λ i → PathP (λ j → PathP (λ k → A) x (p (~ j ∧ ~ i)))\n-- (λ j → compPath-filler p (p ⁻¹) i j) (refl i)) (λ j i → (p (i ∧ ~ j))) (rCancel p)\n\nrCancel-filler : ∀ {x y : A} (p : x ≡ y) → (k j i : I) → A\nrCancel-filler {x = x} p k j i =\n hfill (λ k → λ { (i = i0) → x\n ; (i = i1) → p (~ k ∧ ~ j)\n -- ; (j = i0) → compPath-filler p (p ⁻¹) k i\n ; (j = i1) → x\n }) (inS (p (i ∧ ~ j))) k\n\nrCancel : (p : x ≡ y) → p ∙ p ⁻¹ ≡ refl\nrCancel {x = x} p j i = rCancel-filler p i1 j i\n\nrCancel-filler' : ∀ {ℓ} {A : Type ℓ} {x y : A} (p : x ≡ y) → (i j k : I) → A\nrCancel-filler' {x = x} {y} p i j k =\n hfill\n (λ i → λ\n { (j = i1) → p (~ i ∧ k)\n ; (k = i0) → x\n ; (k = i1) → p (~ i)\n })\n (inS (p k))\n (~ i)\n\nrCancel' : ∀ {ℓ} {A : Type ℓ} {x y : A} (p : x ≡ y) → p ∙ p ⁻¹ ≡ refl\nrCancel' p j k = rCancel-filler' p i0 j k\n\nlCancel : (p : x ≡ y) → p ⁻¹ ∙ p ≡ refl\nlCancel p = rCancel (p ⁻¹)\n\nassoc : (p : x ≡ y) (q : y ≡ z) (r : z ≡ w) →\n p ∙ q ∙ r ≡ (p ∙ q) ∙ r\nassoc p q r k = (compPath-filler p q k) ∙ compPath-filler' q r (~ k)\n\n\n-- heterogeneous groupoid laws\n\nsymInvoP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) →\n PathP (λ j → PathP (λ i → symInvo (λ i → A i) j i) x y) p (symP (symP p))\nsymInvoP p = refl\n\nrUnitP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) →\n PathP (λ j → PathP (λ i → rUnit (λ i → A i) j i) x y) p (compPathP p refl)\nrUnitP p j i = compPathP-filler p refl j i\n\nlUnitP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) →\n PathP (λ j → PathP (λ i → lUnit (λ i → A i) j i) x y) p (compPathP refl p)\nlUnitP {A = A} {x = x} p k i =\n comp (λ j → lUnit-filler (λ i → A i) j k i)\n (λ j → λ { (i = i0) → x\n ; (i = i1) → p (~ k ∨ j )\n ; (k = i0) → p i\n }) (p (~ k ∧ i ))\n\nrCancelP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) →\n PathP (λ j → PathP (λ i → rCancel (λ i → A i) j i) x x) (compPathP p (symP p)) refl\nrCancelP {A = A} {x = x} p j i =\n comp (λ k → rCancel-filler (λ i → A i) k j i)\n (λ k → λ { (i = i0) → x\n ; (i = i1) → p (~ k ∧ ~ j)\n ; (j = i1) → x\n }) (p (i ∧ ~ j))\n\nlCancelP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) →\n PathP (λ j → PathP (λ i → lCancel (λ i → A i) j i) y y) (compPathP (symP p) p) refl\nlCancelP p = rCancelP (symP p)\n\n\n\nassocP : {A : I → Type ℓ} {x : A i0} {y : A i1} {B_i1 : Type ℓ} {B : (A i1) ≡ B_i1} {z : B i1}\n {C_i1 : Type ℓ} {C : (B i1) ≡ C_i1} {w : C i1} (p : PathP A x y) (q : PathP (λ i → B i) y z) (r : PathP (λ i → C i) z w) →\n PathP (λ j → PathP (λ i → assoc (λ i → A i) B C j i) x w) (compPathP p (compPathP q r)) (compPathP (compPathP p q) r)\nassocP {A = A} {B = B} {C = C} p q r k i =\n comp (\\ j' → hfill (λ j → λ {\n (i = i0) → A i0\n ; (i = i1) → compPath-filler' (λ i₁ → B i₁) (λ i₁ → C i₁) (~ k) j })\n (inS (compPath-filler (λ i₁ → A i₁) (λ i₁ → B i₁) k i)) j')\n (λ j → λ\n { (i = i0) → p i0\n ; (i = i1) →\n comp (\\ j' → hfill ((λ l → λ\n { (j = i0) → B k\n ; (j = i1) → C l\n ; (k = i1) → C (j ∧ l)\n })) (inS (B ( j ∨ k)) ) j')\n (λ l → λ\n { (j = i0) → q k\n ; (j = i1) → r l\n ; (k = i1) → r (j ∧ l)\n })\n (q (j ∨ k))\n })\n (compPathP-filler p q k i)\n\n\n\n-- Loic's code below\n\n-- some exchange law for doubleCompPath and refl\n\ninvSides-filler : {x y z : A} (p : x ≡ y) (q : x ≡ z) → Square p (sym q) q (sym p)\ninvSides-filler {x = x} p q i j =\n hcomp (λ k → λ { (i = i0) → p (k ∧ j)\n ; (i = i1) → q (~ j ∧ k)\n ; (j = i0) → q (i ∧ k)\n ; (j = i1) → p (~ i ∧ k)})\n x\n\nleftright : {ℓ : Level} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : y ≡ z) →\n (refl ∙∙ p ∙∙ q) ≡ (p ∙∙ q ∙∙ refl)\nleftright p q i j =\n hcomp (λ t → λ { (j = i0) → p (i ∧ (~ t))\n ; (j = i1) → q (t ∨ i) })\n (invSides-filler q (sym p) (~ i) j)\n\n-- equating doubleCompPath and a succession of two compPath\n\nsplit-leftright : {ℓ : Level} {A : Type ℓ} {w x y z : A} (p : w ≡ x) (q : x ≡ y) (r : y ≡ z) →\n (p ∙∙ q ∙∙ r) ≡ (refl ∙∙ (p ∙∙ q ∙∙ refl) ∙∙ r)\nsplit-leftright p q r j i =\n hcomp (λ t → λ { (i = i0) → p (~ j ∧ ~ t)\n ; (i = i1) → r t })\n (doubleCompPath-filler p q refl j i)\n\nsplit-leftright' : {ℓ : Level} {A : Type ℓ} {w x y z : A} (p : w ≡ x) (q : x ≡ y) (r : y ≡ z) →\n (p ∙∙ q ∙∙ r) ≡ (p ∙∙ (refl ∙∙ q ∙∙ r) ∙∙ refl)\nsplit-leftright' p q r j i =\n hcomp (λ t → λ { (i = i0) → p (~ t)\n ; (i = i1) → r (j ∨ t) })\n (doubleCompPath-filler refl q r j i)\n\ndoubleCompPath-elim : {ℓ : Level} {A : Type ℓ} {w x y z : A} (p : w ≡ x) (q : x ≡ y)\n (r : y ≡ z) → (p ∙∙ q ∙∙ r) ≡ (p ∙ q) ∙ r\ndoubleCompPath-elim p q r = (split-leftright p q r) ∙ (λ i → (leftright p q (~ i)) ∙ r)\n\ndoubleCompPath-elim' : {ℓ : Level} {A : Type ℓ} {w x y z : A} (p : w ≡ x) (q : x ≡ y)\n (r : y ≡ z) → (p ∙∙ q ∙∙ r) ≡ p ∙ (q ∙ r)\ndoubleCompPath-elim' p q r = (split-leftright' p q r) ∙ (sym (leftright p (q ∙ r)))\n\n\ncong-∙ : ∀ {B : Type ℓ} (f : A → B) (p : x ≡ y) (q : y ≡ z)\n → cong f (p ∙ q) ≡ (cong f p) ∙ (cong f q)\ncong-∙ f p q j i = hcomp (λ k → λ { (j = i0) → f (compPath-filler p q k i)\n ; (i = i0) → f (p i0)\n ; (i = i1) → f (q k) })\n (f (p i))\n\ncong-∙∙ : ∀ {B : Type ℓ} (f : A → B) (p : w ≡ x) (q : x ≡ y) (r : y ≡ z)\n → cong f (p ∙∙ q ∙∙ r) ≡ (cong f p) ∙∙ (cong f q) ∙∙ (cong f r)\ncong-∙∙ f p q r j i = hcomp (λ k → λ { (j = i0) → f (doubleCompPath-filler p q r k i)\n ; (i = i0) → f (p (~ k))\n ; (i = i1) → f (r k) })\n (f (q i))\n\nhcomp-unique : ∀ {ℓ} {A : Type ℓ} {φ} → (u : I → Partial φ A) → (u0 : A [ φ ↦ u i0 ]) →\n (h2 : ∀ i → A [ (φ ∨ ~ i) ↦ (\\ { (φ = i1) → u i 1=1; (i = i0) → outS u0}) ])\n → (hcomp u (outS u0) ≡ outS (h2 i1)) [ φ ↦ (\\ { (φ = i1) → (\\ i → u i1 1=1)}) ]\nhcomp-unique {φ = φ} u u0 h2 = inS (\\ i → hcomp (\\ k → \\ { (φ = i1) → u k 1=1\n ; (i = i1) → outS (h2 k) })\n (outS u0))\n\n\nlid-unique : ∀ {ℓ} {A : Type ℓ} {φ} → (u : I → Partial φ A) → (u0 : A [ φ ↦ u i0 ]) →\n (h1 h2 : ∀ i → A [ (φ ∨ ~ i) ↦ (\\ { (φ = i1) → u i 1=1; (i = i0) → outS u0}) ])\n → (outS (h1 i1) ≡ outS (h2 i1)) [ φ ↦ (\\ { (φ = i1) → (\\ i → u i1 1=1)}) ]\nlid-unique {φ = φ} u u0 h1 h2 = inS (\\ i → hcomp (\\ k → \\ { (φ = i1) → u k 1=1\n ; (i = i0) → outS (h1 k)\n ; (i = i1) → outS (h2 k) })\n (outS u0))\n\n\ntransp-hcomp : ∀ {ℓ} (φ : I) {A' : Type ℓ}\n (A : (i : I) → Type ℓ [ φ ↦ (λ _ → A') ]) (let B = \\ (i : I) → outS (A i))\n → ∀ {ψ} (u : I → Partial ψ (B i0)) → (u0 : B i0 [ ψ ↦ u i0 ]) →\n (transp (\\ i → B i) φ (hcomp u (outS u0)) ≡ hcomp (\\ i o → transp (\\ i → B i) φ (u i o)) (transp (\\ i → B i) φ (outS u0)))\n [ ψ ↦ (\\ { (ψ = i1) → (\\ i → transp (\\ i → B i) φ (u i1 1=1))}) ]\ntransp-hcomp φ A u u0 = inS (sym (outS (hcomp-unique\n ((\\ i o → transp (\\ i → B i) φ (u i o))) (inS (transp (\\ i → B i) φ (outS u0)))\n \\ i → inS (transp (\\ i → B i) φ (hfill u u0 i)))))\n where\n B = \\ (i : I) → outS (A i)\n\n\nhcomp-cong : ∀ {ℓ} {A : Type ℓ} {φ} → (u : I → Partial φ A) → (u0 : A [ φ ↦ u i0 ]) →\n (u' : I → Partial φ A) → (u0' : A [ φ ↦ u' i0 ]) →\n (ueq : ∀ i → PartialP φ (\\ o → u i o ≡ u' i o)) → (outS u0 ≡ outS u0') [ φ ↦ (\\ { (φ = i1) → ueq i0 1=1}) ]\n → (hcomp u (outS u0) ≡ hcomp u' (outS u0')) [ φ ↦ (\\ { (φ = i1) → ueq i1 1=1 }) ]\nhcomp-cong u u0 u' u0' ueq 0eq = inS (\\ j → hcomp (\\ i o → ueq i o j) (outS 0eq j))\n\ncongFunct-filler : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} {x y z : A} (f : A → B) (p : x ≡ y) (q : y ≡ z)\n → I → I → I → B\ncongFunct-filler {x = x} f p q i j z =\n hfill (λ k → λ { (i = i0) → f x\n ; (i = i1) → f (q k)\n ; (j = i0) → f (compPath-filler p q k i)})\n (inS (f (p i)))\n z\n\ncongFunct : ∀ {ℓ} {B : Type ℓ} (f : A → B) (p : x ≡ y) (q : y ≡ z) → cong f (p ∙ q) ≡ cong f p ∙ cong f q\ncongFunct f p q j i = congFunct-filler f p q i j i1\n\n\n-- congFunct for dependent types\ncongFunct-dep : ∀ {ℓ ℓ'} {A : Type ℓ} {B : A → Type ℓ'} {x y z : A} (f : (a : A) → B a) (p : x ≡ y) (q : y ≡ z)\n → PathP (λ i → PathP (λ j → B (compPath-filler p q i j)) (f x) (f (q i))) (cong f p) (cong f (p ∙ q))\ncongFunct-dep {B = B} {x = x} f p q i j = f (compPath-filler p q i j)\n\ncong₂Funct : ∀ {ℓ ℓ'} {A : Type ℓ} {x y : A} {B : Type ℓ'} (f : A → A → B) →\n (p : x ≡ y) →\n {u v : A} (q : u ≡ v) →\n cong₂ f p q ≡ cong (λ x → f x u) p ∙ cong (f y) q\ncong₂Funct {x = x} {y = y} f p {u = u} {v = v} q j i =\n hcomp (λ k → λ { (i = i0) → f x u\n ; (i = i1) → f y (q k)\n ; (j = i0) → f (p i) (q (i ∧ k))})\n (f (p i) u)\n\nsymDistr-filler : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : y ≡ z) → I → I → I → A\nsymDistr-filler {A = A} {z = z} p q i j k =\n hfill (λ k → λ { (i = i0) → q (k ∨ j)\n ; (i = i1) → p (~ k ∧ j) })\n (inS (invSides-filler q (sym p) i j))\n k\n\nsymDistr : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : y ≡ z) → sym (p ∙ q) ≡ sym q ∙ sym p\nsymDistr p q i j = symDistr-filler p q j i i1\n\n\n-- we can not write hcomp-isEquiv : {ϕ : I} → (p : I → Partial ϕ A) → isEquiv (λ (a : A [ ϕ ↦ p i0 ]) → hcomp p a)\n-- due to size issues. But what we can write (compare to hfill) is:\nhcomp-equivFillerSub : {ϕ : I} → (p : I → Partial ϕ A) → (a : A [ ϕ ↦ p i0 ])\n → (i : I)\n → A [ ϕ ∨ i ∨ ~ i ↦ (λ { (i = i0) → outS a\n ; (i = i1) → hcomp (λ i → p (~ i)) (hcomp p (outS a))\n ; (ϕ = i1) → p i0 1=1 }) ]\nhcomp-equivFillerSub {ϕ = ϕ} p a i =\n inS (hcomp (λ k → λ { (i = i1) → hfill (λ j → p (~ j)) (inS (hcomp p (outS a))) k\n ; (i = i0) → outS a\n ; (ϕ = i1) → p (~ k ∧ i) 1=1 })\n (hfill p a i))\n\nhcomp-equivFiller : {ϕ : I} → (p : I → Partial ϕ A) → (a : A [ ϕ ↦ p i0 ])\n → (i : I) → A\nhcomp-equivFiller p a i = outS (hcomp-equivFillerSub p a i)\n\n\npentagonIdentity : (p : x ≡ y) → (q : y ≡ z) → (r : z ≡ w) → (s : w ≡ v)\n →\n (assoc p q (r ∙ s) ∙ assoc (p ∙ q) r s)\n ≡\n cong (p ∙_) (assoc q r s) ∙∙ assoc p (q ∙ r) s ∙∙ cong (_∙ s) (assoc p q r)\n\npentagonIdentity {x = x} {y} p q r s =\n (λ i →\n (λ j → cong (p ∙_) (assoc q r s) (i ∧ j))\n ∙∙ (λ j → lemma₀₀ i j ∙ lemma₀₁ i j)\n ∙∙ (λ j → lemma₁₀ i j ∙ lemma₁₁ i j)\n )\n where\n\n\n lemma₀₀ : ( i j : I) → _ ≡ _\n lemma₀₀ i j i₁ =\n hcomp\n (λ k → λ { (j = i0) → p i₁\n ; (i₁ = i0) → x\n ; (i₁ = i1) → hcomp\n (λ k₁ → λ { (i = i0) → (q (j ∧ k))\n ; (k = i0) → y\n ; (j = i0) → y\n ; (j = i1)(k = i1) → r (k₁ ∧ i)})\n (q (j ∧ k))\n }) (p i₁)\n\n lemma₀₁ : ( i j : I) → hcomp\n (λ k → λ {(i = i0) → q j\n ; (j = i0) → y\n ; (j = i1) → r (k ∧ i)\n })\n (q j) ≡ _\n lemma₀₁ i j i₁ = (hcomp\n (λ k → λ { (j = i1) → hcomp\n (λ k₁ → λ { (i₁ = i0) → r i\n ; (k = i0) → r i\n ; (i = i1) → s (k₁ ∧ k ∧ i₁)\n ; (i₁ = i1)(k = i1) → s k₁ })\n (r ((i₁ ∧ k) ∨ i))\n ; (i₁ = i0) → compPath-filler q r i j\n ; (i₁ = i1) → hcomp\n (λ k₁ → λ { (k = i0) → r i\n ; (k = i1) → s k₁\n ; (i = i1) → s (k ∧ k₁)})\n (r (i ∨ k))})\n (hfill\n (λ k → λ { (j = i1) → r k\n ; (i₁ = i1) → r k\n ; (i₁ = i0)(j = i0) → y })\n (inS (q (i₁ ∨ j))) i))\n\n lemma₁₁ : ( i j : I) → (r (i ∨ j)) ≡ _\n lemma₁₁ i j i₁ =\n hcomp\n (λ k → λ { (i = i1) → s (i₁ ∧ k)\n ; (j = i1) → s (i₁ ∧ k)\n ; (i₁ = i0) → r (i ∨ j)\n ; (i₁ = i1) → s k\n }) (r (i ∨ j ∨ i₁))\n\n\n lemma₁₀-back : I → I → I → _\n lemma₁₀-back i j i₁ =\n hcomp\n (λ k → λ {\n (i₁ = i0) → x\n ; (i₁ = i1) → hcomp\n (λ k₁ → λ { (k = i0) → q (j ∨ ~ i)\n ; (k = i1) → r (k₁ ∧ j)\n ; (j = i0) → q (k ∨ ~ i)\n ; (j = i1) → r (k₁ ∧ k)\n ; (i = i0) → r (k ∧ j ∧ k₁)\n })\n (q (k ∨ j ∨ ~ i))\n ; (i = i0)(j = i0) → (p ∙ q) i₁\n })\n (hcomp\n (λ k → λ { (i₁ = i0) → x\n ; (i₁ = i1) → q ((j ∨ ~ i ) ∧ k)\n ; (j = i0)(i = i1) → p i₁\n })\n (p i₁))\n\n\n lemma₁₀-front : I → I → I → _\n lemma₁₀-front i j i₁ =\n (((λ _ → x) ∙∙ compPath-filler p q j ∙∙\n (λ i₁ →\n hcomp\n (λ k → λ { (i₁ = i0) → q j\n ; (i₁ = i1) → r (k ∧ (j ∨ i))\n ; (j = i0)(i = i0) → q i₁\n ; (j = i1) → r (i₁ ∧ k)\n })\n (q (j ∨ i₁))\n )) i₁)\n\n compPath-filler-in-filler :\n (p : _ ≡ y) → (q : _ ≡ _ )\n → _≡_ {A = Square (p ∙ q) (p ∙ q) (λ _ → x) (λ _ → z)}\n (λ i j → hcomp\n (λ i₂ →\n λ { (j = i0) → x\n ; (j = i1) → q (i₂ ∨ ~ i)\n ; (i = i0) → (p ∙ q) j\n })\n (compPath-filler p q (~ i) j))\n (λ _ → p ∙ q)\n compPath-filler-in-filler p q z i j =\n hcomp\n (λ k → λ {\n (j = i0) → p i0\n ; (j = i1) → q (k ∨ ~ i ∧ ~ z)\n ; (i = i0) → hcomp\n (λ i₂ → λ {\n (j = i0) → p i0\n ;(j = i1) → q ((k ∨ ~ z) ∧ i₂)\n ;(z = i1) (k = i0) → p j\n })\n (p j)\n ; (i = i1) → compPath-filler p (λ i₁ → q (k ∧ i₁)) k j\n ; (z = i0) → hfill\n ((λ i₂ → λ { (j = i0) → p i0\n ; (j = i1) → q (i₂ ∨ ~ i)\n ; (i = i0) → (p ∙ q) j\n }))\n (inS ((compPath-filler p q (~ i) j))) k\n ; (z = i1) → compPath-filler p q k j\n })\n (compPath-filler p q (~ i ∧ ~ z) j)\n\n\n cube-comp₋₀₋ :\n (c : I → I → I → A)\n → {a' : Square _ _ _ _}\n → (λ i i₁ → c i i0 i₁) ≡ a'\n → (I → I → I → A)\n cube-comp₋₀₋ c p i j k =\n hcomp\n (λ l → λ {\n (i = i0) → c i0 j k\n ;(i = i1) → c i1 j k\n ;(j = i0) → p l i k\n ;(j = i1) → c i i1 k\n ;(k = i0) → c i j i0\n ;(k = i1) → c i j i1\n })\n (c i j k)\n\n cube-comp₀₋₋ :\n (c : I → I → I → A)\n → {a' : Square _ _ _ _}\n → (λ i i₁ → c i0 i i₁) ≡ a'\n → (I → I → I → A)\n cube-comp₀₋₋ c p i j k =\n hcomp\n (λ l → λ {\n (i = i0) → p l j k\n ;(i = i1) → c i1 j k\n ;(j = i0) → c i i0 k\n ;(j = i1) → c i i1 k\n ;(k = i0) → c i j i0\n ;(k = i1) → c i j i1\n })\n (c i j k)\n\n\n\n lemma₁₀-back' : _\n lemma₁₀-back' k j i₁ =\n (cube-comp₋₀₋ (lemma₁₀-back)\n (compPath-filler-in-filler p q)) k j i₁\n\n\n lemma₁₀ : ( i j : I) → _ ≡ _\n lemma₁₀ i j i₁ =\n (cube-comp₀₋₋ lemma₁₀-front (sym lemma₁₀-back')) i j i₁\n", "meta": {"hexsha": "0e3686e5f8340df0a230d8c0eb3c39bf966149e9", "size": 18467, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Foundations/GroupoidLaws.agda", "max_stars_repo_name": "knrafto/cubical", "max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Foundations/GroupoidLaws.agda", "max_issues_repo_name": "knrafto/cubical", "max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Foundations/GroupoidLaws.agda", "max_forks_repo_name": "knrafto/cubical", "max_forks_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.5532359081, "max_line_length": 139, "alphanum_fraction": 0.3327557264, "num_tokens": 7503, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951182587158, "lm_q2_score": 0.7490872131147275, "lm_q1q2_score": 0.6321510422975448}} {"text": "{-# OPTIONS --without-K #-}\nmodule HoTT.Identity.Coproduct where\n\nopen import HoTT.Base\nopen import HoTT.Equivalence\n\nopen variables\nprivate variable x y : A + B\n\n_=+_ : {A : 𝒰 i} {B : 𝒰 j} (x y : A + B) → 𝒰 (i ⊔ j)\n_=+_ {j = j} (inl a₁) (inl a₂) = Lift {j} (a₁ == a₂)\n_=+_ (inl _) (inr _) = 𝟎\n_=+_ (inr _) (inl _) = 𝟎\n_=+_ {i} (inr b₁) (inr b₂) = Lift {i} (b₁ == b₂)\n\n=+-equiv : (x == y) ≃ x =+ y\n=+-equiv = f , qinv→isequiv (g , η , ε)\n where\n f : x == y → x =+ y\n f {x = inl a} refl = lift refl\n f {x = inr a} refl = lift refl\n\n g : x =+ y → x == y\n g {x = inl _} {inl _} (lift refl) = refl\n g {x = inl _} {inr _} ()\n g {x = inr _} {inl _} ()\n g {x = inr _} {inr _} (lift refl) = refl\n\n η : {x y : A + B} → g {x = x} {y} ∘ f ~ id\n η {y = inl _} refl = refl\n η {y = inr _} refl = refl\n\n ε : f {x = x} {y} ∘ g ~ id\n ε {x = inl _} {inl _} (lift refl) = refl\n ε {x = inl _} {inr _} ()\n ε {x = inr _} {inl _} ()\n ε {x = inr _} {inr _} (lift refl) = refl\n\n=+-elim : x == y → x =+ y\n=+-elim = pr₁ =+-equiv\n\n=+-intro : x =+ y → x == y\n=+-intro = Iso.g (eqv→iso =+-equiv)\n", "meta": {"hexsha": "f804fd3bd194bd5819f1fe6e338efa6a4741d735", "size": 1083, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "HoTT/Identity/Coproduct.agda", "max_stars_repo_name": "michaelforney/hott", "max_stars_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_stars_repo_licenses": ["0BSD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "HoTT/Identity/Coproduct.agda", "max_issues_repo_name": "michaelforney/hott", "max_issues_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_issues_repo_licenses": ["0BSD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HoTT/Identity/Coproduct.agda", "max_forks_repo_name": "michaelforney/hott", "max_forks_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_forks_repo_licenses": ["0BSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.6136363636, "max_line_length": 52, "alphanum_fraction": 0.4699907664, "num_tokens": 529, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.843895106480586, "lm_q2_score": 0.7490872187162396, "lm_q1q2_score": 0.632151038201787}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- The type for booleans and some operations\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Bool.Base where\n\nopen import Data.Unit.Base using (⊤)\nopen import Data.Empty\nopen import Level using (Level)\n\nprivate\n variable\n a : Level\n A : Set a\n\n------------------------------------------------------------------------\n-- The boolean type\n\nopen import Agda.Builtin.Bool public\n\n------------------------------------------------------------------------\n-- Relations\n\ninfix 4 _≤_ _<_\n\ndata _≤_ : Bool → Bool → Set where\n f≤t : false ≤ true\n b≤b : ∀ {b} → b ≤ b\n\ndata _<_ : Bool → Bool → Set where\n fn : m > n) → Order m n\n\norder? : ∀ m n → Order m n\norder? m₀ n₀ = ind (λ m → Order m n₀) order?-zero order?-suc m₀\n where\n order?-zero : Order zero n₀\n order?-zero = ind (Order zero) (equal refl) (λ _ _ → less (zn) = greater (≤-step m>n)\n\n-- indΔ :\nmodule _ (P : N → N → Set) where\n indΔ : P zero zero →\n (∀ n → P zero (suc n)) →\n (∀ m → P (suc m) zero) →\n (∀ m n → P m n → P (suc m) (suc n)) →\n ∀ m n → P m n\n indΔ Pzz Pzs Psz Pss m n with order? m n\n ... | less mn = {! !}\n", "meta": {"hexsha": "5289f0cb2dc6365e3cf900f3773c6cf93c6878ef", "size": 3137, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "TypeTheory/Nat/Mono/Properties.agda", "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_issues_repo_path": "TypeTheory/Nat/Mono/Properties.agda", "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TypeTheory/Nat/Mono/Properties.agda", "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.7610619469, "max_line_length": 72, "alphanum_fraction": 0.4912336627, "num_tokens": 1420, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951025545426, "lm_q2_score": 0.7490872131147275, "lm_q1q2_score": 0.6321510305337494}} {"text": "module fold-Tree where\n\nopen import map-Tree using (Tree; leaf; node)\n\nfold-Tree : ∀ {A B C : Set} → (A → C) → (C → B → C → C) → Tree A B → C\nfold-Tree f _ (leaf a) = f a\nfold-Tree f g (node treeˡ b treeʳ) = g (fold-Tree f g treeˡ) b (fold-Tree f g treeʳ)\n", "meta": {"hexsha": "aa6bb012a559ced0de1f38500e51275d8f70f493", "size": 268, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/lists/fold-Tree.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/lists/fold-Tree.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/lists/fold-Tree.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.5, "max_line_length": 84, "alphanum_fraction": 0.5746268657, "num_tokens": 106, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8757869916479466, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.6320933061439572}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- A generalisation of the arithmetic operations\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Nat.GeneralisedArithmetic where\n\nopen import Data.Nat\nopen import Data.Nat.Properties\nopen import Function using (_∘′_; _∘_; id)\nopen import Relation.Binary.PropositionalEquality\nopen ≡-Reasoning\n\nmodule _ {a} {A : Set a} where\n\n fold : A → (A → A) → ℕ → A\n fold z s zero = z\n fold z s (suc n) = s (fold z s n)\n\n add : (0# : A) (1+ : A → A) → ℕ → A → A\n add 0# 1+ n z = fold z 1+ n\n\n mul : (0# : A) (1+ : A → A) → (+ : A → A → A) → (ℕ → A → A)\n mul 0# 1+ _+_ n x = fold 0# (λ s → x + s) n\n\n-- Properties\n\nmodule _ {a} {A : Set a} where\n\n fold-+ : ∀ {s : A → A} {z : A} →\n ∀ m {n} → fold z s (m + n) ≡ fold (fold z s n) s m\n fold-+ zero = refl\n fold-+ {s = s} (suc m) = cong s (fold-+ m)\n\n fold-k : ∀ {s : A → A} {z : A} {k} m →\n fold k (s ∘′_) m z ≡ fold (k z) s m\n fold-k zero = refl\n fold-k {s = s} (suc m) = cong s (fold-k m)\n\n fold-* : ∀ {s : A → A} {z : A} m {n} →\n fold z s (m * n) ≡ fold z (fold id (s ∘_) n) m\n fold-* zero = refl\n fold-* {s = s} {z} (suc m) {n} = let +n = fold id (s ∘′_) n in begin\n fold z s (n + m * n) ≡⟨ fold-+ n ⟩\n fold (fold z s (m * n)) s n ≡⟨ cong (λ z → fold z s n) (fold-* m) ⟩\n fold (fold z +n m) s n ≡⟨ sym (fold-k n) ⟩\n fold z +n (suc m) ∎\n\n fold-pull : ∀ {s : A → A} {z : A} (g : A → A → A) (p : A)\n (eqz : g z p ≡ p)\n (eqs : ∀ l → s (g l p) ≡ g (s l) p) →\n ∀ m → fold p s m ≡ g (fold z s m) p\n fold-pull _ _ eqz _ zero = sym eqz\n fold-pull {s = s} {z} g p eqz eqs (suc m) = begin\n s (fold p s m) ≡⟨ cong s (fold-pull g p eqz eqs m) ⟩\n s (g (fold z s m) p) ≡⟨ eqs (fold z s m) ⟩\n g (s (fold z s m)) p ∎\n\nid-is-fold : ∀ m → fold zero suc m ≡ m\nid-is-fold zero = refl\nid-is-fold (suc m) = cong suc (id-is-fold m)\n\n+-is-fold : ∀ m {n} → fold n suc m ≡ m + n\n+-is-fold zero = refl\n+-is-fold (suc m) = cong suc (+-is-fold m)\n\n*-is-fold : ∀ m {n} → fold zero (n +_) m ≡ m * n\n*-is-fold zero = refl\n*-is-fold (suc m) {n} = cong (n +_) (*-is-fold m)\n\n^-is-fold : ∀ {m} n → fold 1 (m *_) n ≡ m ^ n\n^-is-fold zero = refl\n^-is-fold {m} (suc n) = cong (m *_) (^-is-fold n)\n\n*+-is-fold : ∀ m n {p} → fold p (n +_) m ≡ m * n + p\n*+-is-fold m n {p} = begin\n fold p (n +_) m ≡⟨ fold-pull _+_ p refl\n (λ l → sym (+-assoc n l p)) m ⟩\n fold 0 (n +_) m + p ≡⟨ cong (_+ p) (*-is-fold m) ⟩\n m * n + p ∎\n\n^*-is-fold : ∀ m n {p} → fold p (m *_) n ≡ m ^ n * p\n^*-is-fold m n {p} = begin\n fold p (m *_) n ≡⟨ fold-pull _*_ p (*-identityˡ p)\n (λ l → sym (*-assoc m l p)) n ⟩\n fold 1 (m *_) n * p ≡⟨ cong (_* p) (^-is-fold n) ⟩\n m ^ n * p ∎\n", "meta": {"hexsha": "1c08acd0c6c817ac34d1f755abb12b7e783c7b83", "size": 2986, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Nat/GeneralisedArithmetic.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Nat/GeneralisedArithmetic.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Nat/GeneralisedArithmetic.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.8131868132, "max_line_length": 72, "alphanum_fraction": 0.4286671132, "num_tokens": 1232, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127603871312, "lm_q2_score": 0.7401743563075446, "lm_q1q2_score": 0.6320443277623433}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import LogicalFormulae\nopen import Sets.EquivalenceRelations\nopen import Setoids.Setoids\n\nmodule Setoids.DirectSum {m n o p : _} {A : Set m} {B : Set n} (R : Setoid {m} {o} A) (S : Setoid {n} {p} B) where\n\ndirectSumSetoid : Setoid {m ⊔ n} (A || B)\nSetoid._∼_ directSumSetoid (inl x) (inl y) = embedLevel {o} {p} (Setoid._∼_ R x y)\nSetoid._∼_ directSumSetoid (inl x) (inr y) = False'\nSetoid._∼_ directSumSetoid (inr x) (inl y) = False'\nSetoid._∼_ directSumSetoid (inr x) (inr y) = embedLevel {p} {o} (Setoid._∼_ S x y)\nEquivalence.reflexive (Setoid.eq directSumSetoid) {inl x} = Equivalence.reflexive (Setoid.eq R) {x} ,, record {}\nEquivalence.reflexive (Setoid.eq directSumSetoid) {inr x} = Equivalence.reflexive (Setoid.eq S) {x} ,, record {}\nEquivalence.symmetric (Setoid.eq directSumSetoid) {inl x} {inl y} (x=y ,, _) = (Equivalence.symmetric (Setoid.eq R) x=y) ,, record {}\nEquivalence.symmetric (Setoid.eq directSumSetoid) {inr x} {inr y} (x=y ,, _) = (Equivalence.symmetric (Setoid.eq S) x=y) ,, record {}\nEquivalence.transitive (Setoid.eq directSumSetoid) {inl x} {inl y} {inl z} (x=y ,, _) (y=z ,, _) = Equivalence.transitive (Setoid.eq R) x=y y=z ,, record {}\nEquivalence.transitive (Setoid.eq directSumSetoid) {inr x} {inr y} {inr z} (x=y ,, _) (y=z ,, _) = Equivalence.transitive (Setoid.eq S) x=y y=z ,, record {}\n", "meta": {"hexsha": "2920760d05b33f9ce78cf7293983e1e478a34dde", "size": 1442, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Setoids/DirectSum.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Setoids/DirectSum.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Setoids/DirectSum.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 68.6666666667, "max_line_length": 156, "alphanum_fraction": 0.6775312067, "num_tokens": 525, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127529517043, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.6320443271530078}} {"text": "{-# OPTIONS --cubical --safe #-}\nmodule Cubical.Structures.AbGroup where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Data.Sigma\nopen import Cubical.Foundations.SIP renaming (SNS-PathP to SNS)\n\nopen import Cubical.Structures.NAryOp\nopen import Cubical.Structures.Group hiding (⟨_⟩)\n\nprivate\n variable\n ℓ : Level\n\nabelian-group-axioms : (X : Type ℓ) → raw-group-structure X → Type ℓ\nabelian-group-axioms X _·_ = group-axioms X _·_ ×\n ((x y : X) → x · y ≡ y · x)\n\nabelian-group-structure : Type ℓ → Type ℓ\nabelian-group-structure = add-to-structure raw-group-structure abelian-group-axioms\n\nAbGroup : Type (ℓ-suc ℓ)\nAbGroup {ℓ} = TypeWithStr ℓ abelian-group-structure\n\nabelian-group-iso : StrIso abelian-group-structure ℓ\nabelian-group-iso = add-to-iso (nAryFunIso 2) abelian-group-axioms\n\nabelian-group-axioms-isProp : (X : Type ℓ)\n → (s : raw-group-structure X)\n → isProp (abelian-group-axioms X s)\nabelian-group-axioms-isProp X _·_ = isPropΣ (group-axioms-isProp X _·_)\n λ { ((isSetX , _) , _) → isPropΠ2 λ _ _ → isSetX _ _}\n\nabelian-group-is-SNS : SNS {ℓ} abelian-group-structure abelian-group-iso\nabelian-group-is-SNS = add-axioms-SNS _ abelian-group-axioms-isProp raw-group-is-SNS\n\nAbGroupPath : (M N : AbGroup {ℓ}) → (M ≃[ abelian-group-iso ] N) ≃ (M ≡ N)\nAbGroupPath = SIP abelian-group-is-SNS\n\n-- Abelian group is group\n\nAbGroup→Group : AbGroup {ℓ} → Group\nAbGroup→Group (G , _·_ , isGroup , ·comm) = G , _·_ , isGroup\n\n-- Abelian group extractors\n\n⟨_⟩ : AbGroup {ℓ} → Type ℓ\n⟨ G , _ ⟩ = G\n\nmodule _ (G : AbGroup {ℓ}) where\n\n abgroup-operation = group-operation (AbGroup→Group G)\n\n abgroup-is-set = group-is-set (AbGroup→Group G)\n\n abgroup-assoc = group-assoc (AbGroup→Group G)\n\n abgroup-id = group-id (AbGroup→Group G)\n\n abgroup-rid = group-rid (AbGroup→Group G)\n\n abgroup-lid = group-lid (AbGroup→Group G)\n\n abgroup-inv = group-inv (AbGroup→Group G)\n\n abgroup-rinv = group-rinv (AbGroup→Group G)\n\n abgroup-linv = group-linv (AbGroup→Group G)\n\nmodule abgroup-operation-syntax where\n\n abgroup-operation-syntax : (G : AbGroup {ℓ}) → ⟨ G ⟩ → ⟨ G ⟩ → ⟨ G ⟩\n abgroup-operation-syntax G = abgroup-operation G\n infixr 20 abgroup-operation-syntax\n syntax abgroup-operation-syntax G x y = x ·⟨ G ⟩ y\n\nopen abgroup-operation-syntax\n\nabgroup-comm : (G : AbGroup {ℓ}) (x y : ⟨ G ⟩) → x ·⟨ G ⟩ y ≡ y ·⟨ G ⟩ x\nabgroup-comm (_ , _ , _ , P) = P\n\n-- AbGroup ·syntax\n\nmodule abgroup-·syntax (G : AbGroup {ℓ}) where\n open group-·syntax (AbGroup→Group G) public\n", "meta": {"hexsha": "4618dd97e3d0f79a29172ab731d07d5b13fa0c91", "size": 2677, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Structures/AbGroup.agda", "max_stars_repo_name": "cmester0/cubical", "max_stars_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-03-23T23:52:11.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-23T23:52:11.000Z", "max_issues_repo_path": "Cubical/Structures/AbGroup.agda", "max_issues_repo_name": "cmester0/cubical", "max_issues_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Structures/AbGroup.agda", "max_forks_repo_name": "cmester0/cubical", "max_forks_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.4204545455, "max_line_length": 89, "alphanum_fraction": 0.6664176317, "num_tokens": 889, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127529517043, "lm_q2_score": 0.7401743563075446, "lm_q1q2_score": 0.6320443222588311}} {"text": "{-\n Definition of various kinds of categories.\n\n This library follows the UniMath terminology, that is:\n\n Concept Ob C Hom C Univalence\n\n Precategory Type Type No\n Category Type Set No\n Univalent Category Type Set Yes\n\n This file also contains\n - pathToIso : Turns a path between two objects into an isomorphism between them\n - opposite categories\n\n\n-}\n\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\n\nmodule Cubical.Categories.Category where\n\nopen import Cubical.Core.Glue\nopen import Cubical.Foundations.Prelude\n\nprivate\n variable\n ℓ ℓ' : Level\n\n-- Precategories\n\nrecord Precategory ℓ ℓ' : Type (ℓ-suc (ℓ-max ℓ ℓ')) where\n -- no-eta-equality ; NOTE: need eta equality for `opop`\n field\n ob : Type ℓ\n Hom[_,_] : ob → ob → Type ℓ'\n id : ∀ x → Hom[ x , x ]\n _⋆_ : ∀ {x y z} (f : Hom[ x , y ]) (g : Hom[ y , z ]) → Hom[ x , z ]\n ⋆IdL : ∀ {x y : ob} (f : Hom[ x , y ]) → (id x) ⋆ f ≡ f\n ⋆IdR : ∀ {x y} (f : Hom[ x , y ]) → f ⋆ (id y) ≡ f\n ⋆Assoc : ∀ {u v w x} (f : Hom[ u , v ]) (g : Hom[ v , w ]) (h : Hom[ w , x ]) → (f ⋆ g) ⋆ h ≡ f ⋆ (g ⋆ h)\n\n -- composition: alternative to diagramatic order\n _∘_ : ∀ {x y z} (g : Hom[ y , z ]) (f : Hom[ x , y ]) → Hom[ x , z ]\n g ∘ f = f ⋆ g\n\nopen Precategory\n\n\n-- Helpful syntax/notation\n\n_[_,_] : (C : Precategory ℓ ℓ') → (x y : C .ob) → Type ℓ'\n_[_,_] = Hom[_,_]\n\n-- needed to define this in order to be able to make the subsequence syntax declaration\nseq' : ∀ (C : Precategory ℓ ℓ') {x y z} (f : C [ x , y ]) (g : C [ y , z ]) → C [ x , z ]\nseq' = _⋆_\n\ninfix 15 seq'\nsyntax seq' C f g = f ⋆⟨ C ⟩ g\n\n-- composition\ncomp' : ∀ (C : Precategory ℓ ℓ') {x y z} (g : C [ y , z ]) (f : C [ x , y ]) → C [ x , z ]\ncomp' = _∘_\n\ninfix 16 comp'\nsyntax comp' C g f = g ∘⟨ C ⟩ f\n\n\n\n-- Categories\n\nrecord isCategory (C : Precategory ℓ ℓ') : Type (ℓ-max ℓ ℓ') where\n field\n isSetHom : ∀ {x y} → isSet (C [ x , y ])\n\n\n-- Isomorphisms and paths in precategories\n\nrecord CatIso {C : Precategory ℓ ℓ'} (x y : C .Precategory.ob) : Type ℓ' where\n constructor catiso\n field\n mor : C [ x , y ]\n inv : C [ y , x ]\n sec : inv ⋆⟨ C ⟩ mor ≡ C .id y\n ret : mor ⋆⟨ C ⟩ inv ≡ C .id x\n\npathToIso : {C : Precategory ℓ ℓ'} (x y : C .ob) (p : x ≡ y) → CatIso {C = C} x y\npathToIso {C = C} x y p = J (λ z _ → CatIso x z) (catiso (C .id x) idx (C .⋆IdL idx) (C .⋆IdL idx)) p\n where\n idx = C .id x\n\n-- Univalent Categories\n\nrecord isUnivalent (C : Precategory ℓ ℓ') : Type (ℓ-max ℓ ℓ') where\n field\n univ : (x y : C .ob) → isEquiv (pathToIso {C = C} x y)\n\nopen isUnivalent public\n\n-- Opposite Categories\n\n_^op : Precategory ℓ ℓ' → Precategory ℓ ℓ'\n(C ^op) .ob = C .ob\n(C ^op) .Hom[_,_] x y = C .Hom[_,_] y x\n(C ^op) .id = C .id\n(C ^op) ._⋆_ f g = C ._⋆_ g f\n(C ^op) .⋆IdL = C .⋆IdR\n(C ^op) .⋆IdR = C .⋆IdL\n(C ^op) .⋆Assoc f g h = sym (C .⋆Assoc _ _ _)\n\nopen isCategory public\n\n-- opposite of opposite is definitionally equal to itself\ninvolutiveOp : ∀ {C : Precategory ℓ ℓ'} → (C ^op) ^op ≡ C\ninvolutiveOp = refl\n\n-- Other useful operations on categories\n\n-- whisker the parallel morphisms g and g' with f\nlPrecatWhisker : {C : Precategory ℓ ℓ'} {x y z : C .ob} (f : C [ x , y ]) (g g' : C [ y , z ]) (p : g ≡ g') → f ⋆⟨ C ⟩ g ≡ f ⋆⟨ C ⟩ g'\nlPrecatWhisker {C = C} f _ _ p = cong (_⋆_ C f) p\n", "meta": {"hexsha": "ff6c617b103c132560471ddf810fc81652315217", "size": 3320, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Category.agda", "max_stars_repo_name": "apabepa10/cubical", "max_stars_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Categories/Category.agda", "max_issues_repo_name": "apabepa10/cubical", "max_issues_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Categories/Category.agda", "max_forks_repo_name": "apabepa10/cubical", "max_forks_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.7741935484, "max_line_length": 134, "alphanum_fraction": 0.5524096386, "num_tokens": 1351, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872045907347107, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.6318956689450355}} {"text": "\n-- Sums and cocartesian categories\nmodule CategoryTheory.BCCCs.Cocartesian where\n\nopen import CategoryTheory.Categories\n\nopen import Relation.Binary using (IsEquivalence)\n\nmodule _ {n} (ℂ : Category n) where\n\n open Category ℂ\n\n -- Initial object in a category\n record InitialObj : Set (lsuc n) where\n field\n -- | Data\n -- The initial object\n ⊥ : obj\n -- Canonical morphism\n ¡ : {A : obj} -> (⊥ ~> A)\n\n -- | Laws\n -- Need to show that the canonical morphism ! is unique\n ¡-unique : {A : obj} -> (m : ⊥ ~> A)\n -> m ≈ ¡\n\n -- Sum of two objects\n -- Based on github.com/copumpkin/categories\n record Sum (A B : obj) : Set (lsuc n) where\n infix 10 [_⁏_]\n field\n -- | Data\n -- Sum of A and B\n A⊕B : obj\n -- First injection\n ι₁ : A ~> A⊕B\n -- Second injection\n ι₂ : B ~> A⊕B\n -- Canonical mediator\n [_⁏_] : ∀{S} -> (A ~> S) -> (B ~> S) -> (A⊕B ~> S)\n\n -- | Laws\n -- [_⁏_] expresses that given another candidate sum S\n -- and candidate injections to A and B there is a morphism\n -- from A⊕B to S. We need to check that this mediator makes\n -- the sum diagram commute and is unique.\n\n ι₁-comm : ∀{S} -> {i₁ : A ~> S} {i₂ : B ~> S}\n -> [ i₁ ⁏ i₂ ] ∘ ι₁ ≈ i₁\n ι₂-comm : ∀{S} -> {i₁ : A ~> S} {i₂ : B ~> S}\n -> [ i₁ ⁏ i₂ ] ∘ ι₂ ≈ i₂\n ⊕-unique : ∀{S} -> {i₁ : A ~> S} {i₂ : B ~> S} {m : A⊕B ~> S}\n -> m ∘ ι₁ ≈ i₁ -> m ∘ ι₂ ≈ i₂ -> [ i₁ ⁏ i₂ ] ≈ m\n\n -- η-expansion of function sums (via morphisms)\n ⊕-η-exp : ∀{S} -> {m : A⊕B ~> S}\n -> [ m ∘ ι₁ ⁏ m ∘ ι₂ ] ≈ m\n ⊕-η-exp = ⊕-unique r≈ r≈\n\n -- Summing of injection functions is the identity\n ⊕-η-id : [ ι₁ ⁏ ι₂ ] ≈ id\n ⊕-η-id = ⊕-unique id-left id-left\n\n -- Congruence over function summing\n [⁏]-cong : ∀{S} -> {i₁ j₁ : A ~> S} {i₂ j₂ : B ~> S}\n -> i₁ ≈ j₁ -> i₂ ≈ j₂\n -> [ i₁ ⁏ i₂ ] ≈ [ j₁ ⁏ j₂ ]\n [⁏]-cong pr1 pr2 = ⊕-unique (ι₁-comm ≈> pr1 [sym]) (ι₂-comm ≈> pr2 [sym])\n\n-- Type class for cocartesian categories\nrecord Cocartesian {n} (ℂ : Category n) : Set (lsuc n) where\n open Category ℂ\n field\n -- | Data\n -- Initial object\n init : InitialObj ℂ\n -- Binary sums for all pairs of objects\n sum : ∀(A B : obj) -> Sum ℂ A B\n\n open InitialObj init public\n open module S {A} {B} = Sum (sum A B) public\n\n -- Shorthand for sum object\n infixl 22 _⊕_\n _⊕_ : (A B : obj) -> obj\n A ⊕ B = A⊕B {A} {B}\n\n -- Parallel sum of morphisms\n infixl 65 _⊹_\n _⊹_ : {A B P Q : obj} -> (A ~> P) -> (B ~> Q)\n -> (A ⊕ B ~> P ⊕ Q)\n _⊹_ {A} {B} {P} {Q} f g = [ ι₁ ∘ f ⁏ ι₂ ∘ g ]\n\n -- Sum of three morphisms\n [_⁏_⁏_] : ∀{S A B C : obj} -> (A ~> S) -> (B ~> S) -> (C ~> S) -> (A ⊕ B ⊕ C ~> S)\n [ f ⁏ g ⁏ h ] = [ [ f ⁏ g ] ⁏ h ]\n", "meta": {"hexsha": "65cf6fe05b6a412511e28be8ee532682319eafca", "size": 3110, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/CategoryTheory/BCCCs/Cocartesian.agda", "max_stars_repo_name": "DimaSamoz/temporal-type-systems", "max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z", "max_issues_repo_path": "src/CategoryTheory/BCCCs/Cocartesian.agda", "max_issues_repo_name": "DimaSamoz/temporal-type-systems", "max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/CategoryTheory/BCCCs/Cocartesian.agda", "max_forks_repo_name": "DimaSamoz/temporal-type-systems", "max_forks_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.0618556701, "max_line_length": 86, "alphanum_fraction": 0.4411575563, "num_tokens": 1122, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872045847699186, "lm_q2_score": 0.7122321842389469, "lm_q1q2_score": 0.631895659277487}} {"text": "{-# OPTIONS --without-K #-}\r\n\r\nmodule VectorLemmas where\r\n\r\nopen import Level using (Level)\r\n\r\nopen import Data.Vec\r\n using (Vec; tabulate; []; _∷_; lookup; allFin)\r\n renaming (_++_ to _++V_; map to mapV; concat to concatV)\r\nopen import Data.Vec.Properties\r\n using (lookup-++-≥; lookup∘tabulate; tabulate-∘; tabulate∘lookup;\r\n tabulate-allFin)\r\nopen import Function using (id;_∘_;flip)\r\nopen import Relation.Binary.PropositionalEquality\r\n using (_≡_; refl; sym; cong; cong₂; subst; trans; proof-irrelevance; module ≡-Reasoning)\r\nopen import Data.Nat using (ℕ; zero; suc; _+_; z≤n; _*_)\r\nopen import Data.Nat.Properties.Simple using (+-comm; +-right-identity)\r\nopen import Data.Fin using (Fin; zero; suc; inject+; raise; reduce≥)\r\nopen import Data.Fin.Properties using (toℕ-injective)\r\n\r\nopen import Data.Sum using (_⊎_; [_,_]′; inj₁; inj₂) renaming (map to map⊎)\r\n\r\nopen import SubstLemmas\r\nopen import FinNatLemmas\r\nopen import FiniteFunctions\r\n\r\n------------------------------------------------------------------------------\r\n-- Lemmas about map and tabulate\r\n\r\n-- to make things look nicer\r\n_!!_ : ∀ {m} {A : Set} → Vec A m → Fin m → A\r\nv !! i = lookup i v\r\n\r\n-- this is actually in Data.Vec.Properties, but over an arbitrary\r\n-- Setoid. Specialize\r\n\r\nmap-id : ∀ {a n} {A : Set a} (xs : Vec A n) → mapV id xs ≡ xs\r\nmap-id [] = refl\r\nmap-id (x ∷ xs) = cong (_∷_ x) (map-id xs)\r\n\r\nmap-++-commute : ∀ {a b m n} {A : Set a} {B : Set b}\r\n (f : B → A) (xs : Vec B m) {ys : Vec B n} →\r\n mapV f (xs ++V ys) ≡ mapV f xs ++V mapV f ys\r\nmap-++-commute f [] = refl\r\nmap-++-commute f (x ∷ xs) = cong (λ z → f x ∷ z) (map-++-commute f xs)\r\n\r\n-- this is too, but is done \"point free\", this version is more convenient\r\n\r\nmap-∘ : ∀ {a b c n} {A : Set a} {B : Set b} {C : Set c}\r\n (f : B → C) (g : A → B) → (xs : Vec A n) →\r\n mapV (f ∘ g) xs ≡ (mapV f ∘ mapV g) xs\r\nmap-∘ f g [] = refl\r\nmap-∘ f g (x ∷ xs) = cong (_∷_ (f (g x))) (map-∘ f g xs)\r\n\r\n-- this looks trivial, why can't I find it?\r\n\r\nlookup-map : ∀ {a b} {n : ℕ} {A : Set a} {B : Set b} → \r\n (i : Fin n) → (f : A → B) → \r\n (v : Vec A n) → lookup i (mapV f v) ≡ f (lookup i v)\r\nlookup-map {n = 0} () _ _\r\nlookup-map {n = suc n} zero f (x ∷ v) = refl\r\nlookup-map {n = suc n} (suc i) f (x ∷ v) = lookup-map i f v\r\n\r\n-- These are 'generalized' lookup into left/right parts of a Vector which \r\n-- does not depend on the values in the Vector at all.\r\n\r\nlook-left : ∀ {m n} {a b c : Level} {A : Set a} {B : Set b} {C : Set c} →\r\n (i : Fin m) → (f : A → C) → (g : B → C) → (vm : Vec A m) → (vn : Vec B n) → \r\n lookup (inject+ n i) (mapV f vm ++V mapV g vn) ≡ f (lookup i vm)\r\nlook-left {0} () _ _ _ _\r\nlook-left {suc _} zero f g (x ∷ vm) vn = refl\r\nlook-left {suc _} (suc i) f g (x ∷ vm) vn = look-left i f g vm vn\r\n\r\nlook-right : ∀ {m n} {a b c : Level} {A : Set a} {B : Set b} {C : Set c} →\r\n (i : Fin n) → (f : A → C) → (g : B → C) → (vm : Vec A m) → (vn : Vec B n) → \r\n lookup (raise m i) (mapV f vm ++V mapV g vn) ≡ g (lookup i vn)\r\nlook-right {0} i f g vn vm = lookup-map i g vm\r\nlook-right {suc m} {0} () _ _ _ _\r\nlook-right {suc m} {suc n} i f g (x ∷ vn) vm = look-right i f g vn vm\r\n\r\n-- variant\r\nleft!! : ∀ {m n} {C : Set} →\r\n (i : Fin m) → (f : Fin m → C) → {g : Fin n → C} →\r\n (tabulate f ++V tabulate g) !! (inject+ n i) ≡ f i\r\nleft!! {zero} () _\r\nleft!! {suc _} zero f = refl\r\nleft!! {suc _} (suc i) f = left!! i (f ∘ suc)\r\n\r\nright!! : ∀ {m n} {C : Set} →\r\n (i : Fin n) → {f : Fin m → C} → (g : Fin n → C) →\r\n (tabulate f ++V tabulate g) !! (raise m i) ≡ g i\r\nright!! {zero} i g = lookup∘tabulate g i\r\nright!! {suc _} {0} () _\r\nright!! {suc m} {suc _} i g = right!! {m} i g\r\n\r\n-- similar to lookup-++-inject+ from library\r\n\r\nlookup-++-raise : ∀ {m n} {a : Level} {A : Set a} →\r\n (vm : Vec A m) (vn : Vec A n) (i : Fin n) → \r\n lookup (raise m i) (vm ++V vn) ≡ lookup i vn\r\nlookup-++-raise {0} vn vm i = \r\n begin (lookup i (vn ++V vm)\r\n ≡⟨ lookup-++-≥ vn vm i z≤n ⟩ \r\n lookup (reduce≥ i z≤n) vm\r\n ≡⟨ refl ⟩ \r\n lookup i vm ∎)\r\n where open ≡-Reasoning -- \r\nlookup-++-raise {suc m} {0} _ _ () \r\nlookup-++-raise {suc m} {suc n} (x ∷ vn) vm i = lookup-++-raise vn vm i\r\n\r\n-- concat (map (map f) xs) = map f (concat xs)\r\nconcat-map : ∀ {a b m n} {A : Set a} {B : Set b} → \r\n (xs : Vec (Vec A n) m) → (f : A → B) → \r\n concatV (mapV (mapV f) xs) ≡ mapV f (concatV xs)\r\nconcat-map [] f = refl\r\nconcat-map (xs ∷ xss) f = \r\n begin (concatV (mapV (mapV f) (xs ∷ xss))\r\n ≡⟨ refl ⟩\r\n concatV (mapV f xs ∷ mapV (mapV f) xss)\r\n ≡⟨ refl ⟩\r\n mapV f xs ++V concatV (mapV (mapV f) xss)\r\n ≡⟨ cong (_++V_ (mapV f xs)) (concat-map xss f) ⟩\r\n mapV f xs ++V mapV f (concatV xss)\r\n ≡⟨ sym (map-++-commute f xs) ⟩\r\n mapV f (xs ++V concatV xss)\r\n ≡⟨ refl ⟩\r\n mapV f (concatV (xs ∷ xss)) ∎)\r\n where open ≡-Reasoning\r\n\r\nmap-map-map : ∀ {a b c m n} {A : Set a} {B : Set b} {C : Set c} →\r\n (f : B → C) → (g : A → Vec B n) → (xs : Vec A m) →\r\n mapV (mapV f) (mapV g xs) ≡ mapV (mapV f ∘ g) xs\r\nmap-map-map f g xss = sym (map-∘ (mapV f) g xss)\r\n\r\nsplitV+ : ∀ {m n} {a : Level} {A : Set a} {f : Fin (m + n) → A} → Vec A (m + n)\r\nsplitV+ {m} {n} {f = f} = tabulate {m} (f ∘ inject+ n) ++V tabulate {n} (f ∘ raise m)\r\n\r\nsplitVOp+ : ∀ {m} {n} {a : Level} {A : Set a} {f : Fin (n + m) → A} → Vec A (m + n)\r\nsplitVOp+ {m} {n} {f = f} = tabulate {m} (f ∘ raise n) ++V tabulate {n} (f ∘ inject+ m)\r\n\r\n-- f can be implicit since this is mostly used in equational reasoning, where it can be inferred!\r\ntabulate-split : ∀ {m n} {a : Level} {A : Set a} → {f : Fin (m + n) → A} → \r\n tabulate {m + n} f ≡ splitV+ {m} {n} {f = f}\r\ntabulate-split {0} = refl\r\ntabulate-split {suc m} {f = f} = cong (_∷_ (f zero)) (tabulate-split {m} {f = f ∘ suc})\r\n\r\nlookup-subst : ∀ {m m' n} \r\n (i : Fin n) (xs : Vec (Fin m) n) (eq : m ≡ m') → \r\n lookup i (subst (λ s → Vec (Fin s) n) eq xs) ≡ \r\n subst Fin eq (lookup i xs)\r\nlookup-subst i xs refl = refl \r\n\r\n-- lookup is associative on Fin vectors\r\nlookupassoc : ∀ {m₁ m₂ m₃ m₄} → (π₁ : Vec (Fin m₂) m₁) \r\n (π₂ : Vec (Fin m₃) m₂) (π₃ : Vec (Fin m₄) m₃) → (i : Fin m₁) → \r\n lookup (lookup i π₁) (tabulate (λ j → lookup (lookup j π₂) π₃)) ≡\r\n lookup (lookup i (tabulate (λ j → lookup (lookup j π₁) π₂))) π₃\r\nlookupassoc π₁ π₂ π₃ i = \r\n begin (lookup (lookup i π₁) (tabulate (λ j → lookup (lookup j π₂) π₃))\r\n ≡⟨ lookup∘tabulate (λ j → lookup (lookup j π₂) π₃) (lookup i π₁) ⟩ \r\n lookup (lookup (lookup i π₁) π₂) π₃\r\n ≡⟨ cong \r\n (λ x → lookup x π₃) \r\n (sym (lookup∘tabulate (λ j → lookup (lookup j π₁) π₂) i)) ⟩ \r\n lookup (lookup i (tabulate (λ j → lookup (lookup j π₁) π₂))) π₃ ∎)\r\n where open ≡-Reasoning\r\n\r\n-- This should generalize a lot, but that can be done later\r\nsubst-lookup-tabulate-raise : ∀ {m n : ℕ} → (z : Fin n) → \r\n subst Fin (+-comm n m) (lookup z (tabulate (λ i → subst Fin (+-comm m n) (raise m i)))) ≡\r\n raise m z\r\nsubst-lookup-tabulate-raise {m} {n} z = \r\n begin (subst Fin (+-comm n m) (lookup z (tabulate (λ i → subst Fin (+-comm m n) (raise m i))))\r\n ≡⟨ cong (subst Fin (+-comm n m))\r\n (lookup∘tabulate (λ i → subst Fin (+-comm m n) (raise m i)) z) ⟩\r\n subst Fin (+-comm n m) (subst Fin (+-comm m n) (raise m z))\r\n ≡⟨ subst-subst (+-comm n m) (+-comm m n) \r\n (proof-irrelevance (sym (+-comm n m)) (+-comm m n)) (raise m z) ⟩\r\n raise m z\r\n ∎)\r\n where open ≡-Reasoning\r\n\r\nsubst-lookup-tabulate-inject+ : ∀ {m n : ℕ} → (z : Fin m) → \r\n subst Fin (+-comm n m) (lookup z (tabulate (λ i → subst Fin (+-comm m n) (inject+ n i)))) ≡\r\n inject+ n z\r\nsubst-lookup-tabulate-inject+ {m} {n} z = \r\n begin (subst Fin (+-comm n m) (lookup z (tabulate (λ i → subst Fin (+-comm m n) (inject+ n i))))\r\n ≡⟨ cong (subst Fin (+-comm n m))\r\n (lookup∘tabulate (λ i → subst Fin (+-comm m n) (inject+ n i)) z) ⟩\r\n subst Fin (+-comm n m) (subst Fin (+-comm m n) (inject+ n z))\r\n ≡⟨ subst-subst (+-comm n m) (+-comm m n) \r\n (proof-irrelevance (sym (+-comm n m)) (+-comm m n)) (inject+ n z) ⟩\r\n inject+ n z\r\n ∎)\r\n where open ≡-Reasoning\r\n\r\n-- a kind of inverse for splitAt\r\nunSplit : {m n : ℕ} {A : Set} → (f : Fin (m + n) → A) → \r\n tabulate {m} (f ∘ (inject+ n)) ++V tabulate {n} (f ∘ (raise m)) ≡ tabulate f\r\nunSplit {0} {n} f = refl\r\nunSplit {suc m} f = cong (λ x → (f zero) ∷ x) (unSplit {m} (f ∘ suc))\r\n\r\n-- nested tabulate-lookup\r\ndenest-tab-!! : {A B C : Set} {k : ℕ} → (f : B → C) → (g : A → B) → (v : Vec A k) →\r\n tabulate (λ i → f (tabulate (λ j → g (v !! j)) !! i)) ≡ mapV (f ∘ g) v\r\ndenest-tab-!! f g v = \r\n begin ( \r\n tabulate (λ i → f (tabulate (λ j → g (v !! j)) !! i))\r\n ≡⟨ tabulate-∘ f (λ i → tabulate (λ j → g (v !! j)) !! i) ⟩\r\n mapV f (tabulate (λ i → tabulate (λ j → g (v !! j)) !! i) )\r\n ≡⟨ cong (mapV f) (tabulate∘lookup (tabulate (λ j → g (v !! j)))) ⟩\r\n mapV f (tabulate (λ j → g (v !! j)))\r\n ≡⟨ cong (mapV f) (tabulate-∘ g (flip lookup v)) ⟩\r\n mapV f (mapV g (tabulate (flip lookup v)))\r\n ≡⟨ sym (map-∘ f g _) ⟩\r\n mapV (f ∘ g) (tabulate (flip lookup v))\r\n ≡⟨ cong (mapV (f ∘ g)) (tabulate∘lookup v) ⟩\r\n mapV (f ∘ g) v ∎)\r\n where open ≡-Reasoning\r\n\r\ntab++[]≡tab∘̂unite+ : ∀ {m} {A : Set} (f : Fin m → A) (eq : m + 0 ≡ m) →\r\n tabulate f ++V [] ≡ tabulate (λ j → f (subst Fin eq j))\r\ntab++[]≡tab∘̂unite+ {zero} f eq = refl\r\ntab++[]≡tab∘̂unite+ {suc m} f eq = cong₂ _∷_ (cong f pf₁) pf₂\r\n where\r\n pf₁ : zero ≡ subst Fin eq zero\r\n pf₁ = toℕ-injective (sym (toℕ-invariance zero eq))\r\n pf₃ : ∀ j → suc (subst Fin (+-right-identity m) j) ≡ subst Fin eq (suc j)\r\n pf₃ j = toℕ-injective (trans (cong suc (toℕ-invariance j (+-right-identity m)))\r\n (sym (toℕ-invariance (suc j) eq)))\r\n pf₂ : tabulate (f ∘ suc) ++V [] ≡ tabulate (λ j → f (subst Fin eq (suc j)))\r\n pf₂ = trans (tab++[]≡tab∘̂unite+ (f ∘ suc) (+-right-identity m))\r\n (finext (λ j → cong f (pf₃ j)))\r\n \r\n-- Move to its own spot later\r\nmerge-[,] : {A B C D E : Set} → {h : A → C} → {i : B → D} → {f : C → E}\r\n → {g : D → E} → (x : A ⊎ B) →\r\n [ f , g ]′ ( map⊎ h i x ) ≡ [ (f ∘ h) , (g ∘ i) ]′ x\r\nmerge-[,] (inj₁ x) = refl\r\nmerge-[,] (inj₂ y) = refl\r\n", "meta": {"hexsha": "d17b1f0b66b9479fa486cb5f7b5261afc2461209", "size": 10387, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Univalence/Obsolete/VectorLemmas.agda", "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_issues_repo_path": "Univalence/Obsolete/VectorLemmas.agda", "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_forks_repo_path": "Univalence/Obsolete/VectorLemmas.agda", "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "avg_line_length": 43.0995850622, "max_line_length": 98, "alphanum_fraction": 0.5107345721, "num_tokens": 4155, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.766293653760418, "lm_q2_score": 0.824461932846258, "lm_q1q2_score": 0.6317799469071355}} {"text": "open import Common.Prelude\n\ninstance\n tti : ⊤\n tti = record{}\n\nNonZero : Nat → Set\nNonZero zero = ⊥\nNonZero (suc _) = ⊤\n\npred′ : (n : Nat) .{{_ : NonZero n}} → Nat\npred′ zero {{}}\npred′ (suc n) = n\n\ntest : (n : Nat) {{x y : NonZero n}} → Nat\ntest n = pred′ n\n\n_<_ : Nat → Nat → Set\nm < zero = ⊥\nzero < suc n = ⊤\nsuc m < suc n = m < n\n\ninstance\n <-suc : ∀ {m n} → .(m < n) → m < suc n\n <-suc {zero} _ = tt\n <-suc {suc m} {zero} ()\n <-suc {suc m} {suc n} = <-suc {m} {n}\n\n", "meta": {"hexsha": "e38d9250a1cab9b5ca4bb39b62a2c9cf6b661121", "size": 479, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/IrrelevantInstance.agda", "max_stars_repo_name": "alhassy/agda", "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Succeed/IrrelevantInstance.agda", "max_issues_repo_name": "alhassy/agda", "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/IrrelevantInstance.agda", "max_forks_repo_name": "alhassy/agda", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 16.5172413793, "max_line_length": 42, "alphanum_fraction": 0.4947807933, "num_tokens": 213, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8991213826762113, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.6316597965767752}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.AbGroup.Instances.NProd where\n\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Data.Nat using (ℕ)\n\nopen import Cubical.Algebra.Group\nopen import Cubical.Algebra.Group.Instances.NProd\nopen import Cubical.Algebra.AbGroup\n\nprivate variable\n ℓ : Level\n\nopen AbGroupStr\n\nNProd-AbGroup : (G : (n : ℕ) → Type ℓ) → (Gstr : (n : ℕ) → AbGroupStr (G n)) → AbGroup ℓ\nNProd-AbGroup G Gstr = Group→AbGroup (NProd-Group G (λ n → AbGroupStr→GroupStr (Gstr n)))\n λ f g → funExt λ n → +Comm (Gstr n) _ _\n", "meta": {"hexsha": "02c0cdf924c993303c99e982846557b3b2451b55", "size": 583, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/AbGroup/Instances/NProd.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/AbGroup/Instances/NProd.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/AbGroup/Instances/NProd.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.15, "max_line_length": 89, "alphanum_fraction": 0.6740994854, "num_tokens": 179, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9032941988938414, "lm_q2_score": 0.6992544273261176, "lm_q1q2_score": 0.6316324677545173}} {"text": "module #1 where\n\nopen import Level\nopen import Relation.Binary.PropositionalEquality\n\n{-\nExercise 1.1. Given functions f : A → B and g : B → C, define their composite g ◦ f : A → C.\nShow that we have h ◦ (g ◦ f ) ≡ (h ◦ g) ◦ f .\n-}\n\n-- Function composition\n_∘_ : ∀ {a b c}{A : Set a}{B : Set b}{C : Set c} → (B → C) → (A → B) → A → C\nf ∘ g = λ x → f (g x)\n\n-- Proof of associativity of composition\n∘-assoc : ∀ {a b c d}{A : Set a}{B : Set b}{C : Set c}{D : Set d} →\n (h : C → D) → (g : B → C) → (f : A → B) →\n h ∘ (g ∘ f) ≡ (h ∘ g) ∘ f\n∘-assoc _ _ _ = refl\n", "meta": {"hexsha": "ec70a3709984c7365fced018163bc1c184809a65", "size": 579, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Chapter1/#1.agda", "max_stars_repo_name": "CodaFi/HoTT-Exercises", "max_stars_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter1/#1.agda", "max_issues_repo_name": "CodaFi/HoTT-Exercises", "max_issues_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter1/#1.agda", "max_forks_repo_name": "CodaFi/HoTT-Exercises", "max_forks_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.95, "max_line_length": 92, "alphanum_fraction": 0.5008635579, "num_tokens": 239, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9032941988938413, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.6316324677545171}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Algebra.RingSolver.IntAsRawRing where\n\nopen import Cubical.Data.Nat hiding (_+_; _·_)\nopen import Cubical.Data.Int\nopen import Cubical.Data.Int.Base renaming (Int to ℤ) public\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Algebra.RingSolver.RawRing\n\nℤAsRawRing : RawRing {ℓ-zero}\nℤAsRawRing = rawring ℤ (pos zero) (pos (suc zero)) _+_ _·_ (λ k → - k)\n\n+Ridℤ : (k : ℤ) → (pos zero) + k ≡ k\n+Ridℤ k = sym (pos0+ k)\n", "meta": {"hexsha": "92d5c91c25161f0216c9d47df3e532b42e57e2db", "size": 494, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/RingSolver/IntAsRawRing.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/RingSolver/IntAsRawRing.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/RingSolver/IntAsRawRing.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.875, "max_line_length": 70, "alphanum_fraction": 0.7125506073, "num_tokens": 170, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9207896802383028, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.6316151852481933}} {"text": "module Lectures.Three where\n\nopen import Lectures.One\nopen import Lectures.Two\n\n-- Introduce propositional equality\n\ndata _≡_ {A : Set} (x : A) : A → Set where\n refl : x ≡ x\n\n{-# BUILTIN EQUALITY _≡_ #-}\n\n-- Comment on precendences\ninfix 10 _≡_\n\nrecord Equivalence (_~_ : ∀ {A : Set} → A → A → Set) : Set₁ where\n field\n reflexive : ∀ {A} {a : A} → a ~ a\n symmetric : ∀ {A} {a b : A} → a ~ b → b ~ a\n transitive : ∀ {A} {a b c : A} → a ~ b → b ~ c → a ~ c\n\nopen Equivalence\n\nsym : ∀ {A} {a b : A} → a ≡ b → b ≡ a\nsym refl = refl\n\ntrans : ∀ {A} {a b c : A} → a ≡ b → b ≡ c → a ≡ c\ntrans refl refl = refl\n\n-- Comment on copatterns\n≡-Equivalence : Equivalence _≡_\nreflexive ≡-Equivalence = refl\nsymmetric ≡-Equivalence = sym\ntransitive ≡-Equivalence = trans\n\ncong : ∀ {A B} {a b : A} → (f : A → B) → a ≡ b → f a ≡ f b\ncong f refl = refl\n\n-- Leibniz equality?\nsubst : ∀ {A} {x y : A} {P : A → Set} → P x → x ≡ y → P y\nsubst p refl = p\n\n_ : _+_ ≡ _+_\n_ = refl\n\n-- _ : _+_ ≡ λ x y → y + x\n-- _ = {!refl!}\n\n-- Comment on postulates\npostulate\n extensionality : {A B : Set} {f g : A → B} → (∀ x → f x ≡ g x) → f ≡ g\n\n+-idʳ : ∀ x → x ≡ x + 0\n+-idʳ zero = refl\n+-idʳ (suc x) = cong suc (+-idʳ _)\n\n+-suc : ∀ x y → suc (x + y) ≡ x + suc y\n+-suc zero y = refl\n+-suc (suc x) y = cong suc (+-suc _ _)\n\n+-comm : ∀ x y → x + y ≡ y + x\n+-comm zero y = +-idʳ _\n+-comm (suc x) y = trans (cong suc (+-comm x y)) (+-suc _ _)\n\n+-assoc : ∀ x y z → x + (y + z) ≡ (x + y) + z\n+-assoc zero y z = refl\n+-assoc (suc x) y z = cong suc (+-assoc x y z)\n", "meta": {"hexsha": "c4f26ccf189349bdecf799194b0c1e0f4ff079bb", "size": 1533, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Lectures/Three.agda", "max_stars_repo_name": "UoG-Agda/Agda101", "max_stars_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Lectures/Three.agda", "max_issues_repo_name": "UoG-Agda/Agda101", "max_issues_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lectures/Three.agda", "max_forks_repo_name": "UoG-Agda/Agda101", "max_forks_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.5441176471, "max_line_length": 72, "alphanum_fraction": 0.5225048924, "num_tokens": 659, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339596505965, "lm_q2_score": 0.752012562644147, "lm_q1q2_score": 0.6314904869361617}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule LeqLemmas where\n\nopen import Data.Nat\n using (ℕ; suc; _+_; _*_; _<_; _≤_; _≤?_; z≤n; s≤s; module ≤-Reasoning)\nopen import Data.Nat.Properties.Simple using (+-comm)\nopen import Data.Nat.Properties using (n≤m+n)\nopen import Relation.Binary using (Decidable)\n\n------------------------------------------------------------------------------\n-- Proofs and definitions about ≤ on natural numbers\n\n_ List A -> List A\n\n{-# BUILTIN LIST List #-}\n{-# BUILTIN NIL [] #-}\n{-# BUILTIN CONS _::_ #-}\n\ninfixr 30 _++_\n\n_++_ : {A : Set} -> List A -> List A -> List A\n[] ++ ys = ys\n(x :: xs) ++ ys = x :: (xs ++ ys)\n\nsnoc : {A : Set} -> List A -> A -> List A\nsnoc [] e = e :: []\nsnoc (x :: xs) e = x :: snoc xs e\n\nlength : {A : Set} -> List A -> Nat\nlength [] = 0\nlength (x :: xs) = 1 + length xs\n\nzipWith : ∀ {A B C} -> (A -> B -> C) -> List A -> List B -> List C\nzipWith f (x :: xs) (y :: ys) = f x y :: zipWith f xs ys\nzipWith _ _ _ = []\n\nmap : ∀ {A B} -> (A -> B) -> List A -> List B\nmap _ [] = []\nmap f (x :: xs) = f x :: map f xs\n\nmapIgen : ∀ {A B} -> (A -> B) -> List A -> List B\nmapIgen = map\n\n_!_ : ∀ {A} -> (xs : List A) -> Fin (length {A} xs) -> A\n_!_ {A} (x :: xs) (fz .{length xs}) = x\n_!_ {A} (x :: xs) (fs .{length xs} n) = _!_ {A} xs n\n_!_ {A} [] ()\n\n_[_]=_ : {A : Set} -> (xs : List A) -> Fin (length xs) -> A -> List A\n(a :: as) [ fz ]= e = e :: as\n(a :: as) [ fs n ]= e = a :: (as [ n ]= e)\n[] [ () ]= e\n\nlistEq : {A : Set} -> (A -> A -> Bool) -> List A -> List A -> Bool\nlistEq _ [] [] = true\nlistEq _==_ (a :: as) (b :: bs) with a == b\n... | true = listEq _==_ as bs\n... | false = false\nlistEq _ _ _ = false\n\ntail : {A : Set} -> List A -> List A\ntail [] = []\ntail (x :: xs) = xs\n\nreverse : {A : Set} -> List A -> List A\nreverse [] = []\nreverse (x :: xs) = reverse xs ++ (x :: [])\n\ninit : {A : Set} -> List A -> List A\ninit xs = reverse (tail (reverse xs))\n\nfilter : {A : Set} -> (A -> Bool) -> List A -> List A\nfilter p [] = []\nfilter p (a :: as) with p a\n... | true = a :: filter p as\n... | false = filter p as\n", "meta": {"hexsha": "52704b6415551eb49064fe265550c26e80408b2b", "size": 1836, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/epic/Prelude/List.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/epic/Prelude/List.agda", "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/epic/Prelude/List.agda", "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 24.48, "max_line_length": 69, "alphanum_fraction": 0.4635076253, "num_tokens": 707, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424373085146, "lm_q2_score": 0.7461389873857264, "lm_q1q2_score": 0.6311906335599884}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Natural numbers\n------------------------------------------------------------------------\n\nmodule Data.Nat where\n\nopen import Function\nopen import Function.Equality as F using (_⟨$⟩_)\nopen import Function.Injection using (_↣_)\nopen import Data.Sum\nopen import Data.Empty\nimport Level\nopen import Relation.Nullary\nimport Relation.Nullary.Decidable as Dec\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as PropEq\n using (_≡_; refl)\n\n------------------------------------------------------------------------\n-- The types\n\ndata ℕ : Set where\n zero : ℕ\n suc : (n : ℕ) → ℕ\n\n{-# BUILTIN NATURAL ℕ #-}\n\ninfix 4 _≤_ _<_ _≥_ _>_ _≰_ _≮_ _≱_ _≯_\n\ndata _≤_ : Rel ℕ Level.zero where\n z≤n : ∀ {n} → zero ≤ n\n s≤s : ∀ {m n} (m≤n : m ≤ n) → suc m ≤ suc n\n\n_<_ : Rel ℕ Level.zero\nm < n = suc m ≤ n\n\n_≥_ : Rel ℕ Level.zero\nm ≥ n = n ≤ m\n\n_>_ : Rel ℕ Level.zero\nm > n = n < m\n\n_≰_ : Rel ℕ Level.zero\na ≰ b = ¬ a ≤ b\n\n_≮_ : Rel ℕ Level.zero\na ≮ b = ¬ a < b\n\n_≱_ : Rel ℕ Level.zero\na ≱ b = ¬ a ≥ b\n\n_≯_ : Rel ℕ Level.zero\na ≯ b = ¬ a > b\n\n-- The following, alternative definition of _≤_ is more suitable for\n-- well-founded induction (see Induction.Nat).\n\ninfix 4 _≤′_ _<′_ _≥′_ _>′_\n\ndata _≤′_ (m : ℕ) : ℕ → Set where\n ≤′-refl : m ≤′ m\n ≤′-step : ∀ {n} (m≤′n : m ≤′ n) → m ≤′ suc n\n\n_<′_ : Rel ℕ Level.zero\nm <′ n = suc m ≤′ n\n\n_≥′_ : Rel ℕ Level.zero\nm ≥′ n = n ≤′ m\n\n_>′_ : Rel ℕ Level.zero\nm >′ n = n <′ m\n\n------------------------------------------------------------------------\n-- A generalisation of the arithmetic operations\n\nfold : {a : Set} → a → (a → a) → ℕ → a\nfold z s zero = z\nfold z s (suc n) = s (fold z s n)\n\nmodule GeneralisedArithmetic {a : Set} (0# : a) (1+ : a → a) where\n\n add : ℕ → a → a\n add n z = fold z 1+ n\n\n mul : (+ : a → a → a) → (ℕ → a → a)\n mul _+_ n x = fold 0# (λ s → x + s) n\n\n------------------------------------------------------------------------\n-- Arithmetic\n\npred : ℕ → ℕ\npred zero = zero\npred (suc n) = n\n\ninfixl 7 _*_ _⊓_\ninfixl 6 _+_ _+⋎_ _∸_ _⊔_\n\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\nsuc m + n = suc (m + n)\n\n{-# BUILTIN NATPLUS _+_ #-}\n\n-- Argument-swapping addition. Used by Data.Vec._⋎_.\n\n_+⋎_ : ℕ → ℕ → ℕ\nzero +⋎ n = n\nsuc m +⋎ n = suc (n +⋎ m)\n\n_∸_ : ℕ → ℕ → ℕ\nm ∸ zero = m\nzero ∸ suc n = zero\nsuc m ∸ suc n = m ∸ n\n\n{-# BUILTIN NATMINUS _∸_ #-}\n\n_*_ : ℕ → ℕ → ℕ\nzero * n = zero\nsuc m * n = n + m * n\n\n{-# BUILTIN NATTIMES _*_ #-}\n\n-- Max.\n\n_⊔_ : ℕ → ℕ → ℕ\nzero ⊔ n = n\nsuc m ⊔ zero = suc m\nsuc m ⊔ suc n = suc (m ⊔ n)\n\n-- Min.\n\n_⊓_ : ℕ → ℕ → ℕ\nzero ⊓ n = zero\nsuc m ⊓ zero = zero\nsuc m ⊓ suc n = suc (m ⊓ n)\n\n-- Division by 2, rounded downwards.\n\n⌊_/2⌋ : ℕ → ℕ\n⌊ 0 /2⌋ = 0\n⌊ 1 /2⌋ = 0\n⌊ suc (suc n) /2⌋ = suc ⌊ n /2⌋\n\n-- Division by 2, rounded upwards.\n\n⌈_/2⌉ : ℕ → ℕ\n⌈ n /2⌉ = ⌊ suc n /2⌋\n\n------------------------------------------------------------------------\n-- Queries\n\ninfix 4 _≟_\n\n_≟_ : Decidable {A = ℕ} _≡_\nzero ≟ zero = yes refl\nsuc m ≟ suc n with m ≟ n\nsuc m ≟ suc .m | yes refl = yes refl\nsuc m ≟ suc n | no prf = no (prf ∘ PropEq.cong pred)\nzero ≟ suc n = no λ()\nsuc m ≟ zero = no λ()\n\n≤-pred : ∀ {m n} → suc m ≤ suc n → m ≤ n\n≤-pred (s≤s m≤n) = m≤n\n\n_≤?_ : Decidable _≤_\nzero ≤? _ = yes z≤n\nsuc m ≤? zero = no λ()\nsuc m ≤? suc n with m ≤? n\n... | yes m≤n = yes (s≤s m≤n)\n... | no m≰n = no (m≰n ∘ ≤-pred)\n\n-- A comparison view. Taken from \"View from the left\"\n-- (McBride/McKinna); details may differ.\n\ndata Ordering : Rel ℕ Level.zero where\n less : ∀ m k → Ordering m (suc (m + k))\n equal : ∀ m → Ordering m m\n greater : ∀ m k → Ordering (suc (m + k)) m\n\ncompare : ∀ m n → Ordering m n\ncompare zero zero = equal zero\ncompare (suc m) zero = greater zero m\ncompare zero (suc n) = less zero n\ncompare (suc m) (suc n) with compare m n\ncompare (suc .m) (suc .(suc m + k)) | less m k = less (suc m) k\ncompare (suc .m) (suc .m) | equal m = equal (suc m)\ncompare (suc .(suc m + k)) (suc .m) | greater m k = greater (suc m) k\n\n-- If there is an injection from a type to ℕ, then the type has\n-- decidable equality.\n\neq? : ∀ {a} {A : Set a} → A ↣ ℕ → Decidable {A = A} _≡_\neq? inj = Dec.via-injection inj _≟_\n\n------------------------------------------------------------------------\n-- Some properties\n\ndecTotalOrder : DecTotalOrder _ _ _\ndecTotalOrder = record\n { Carrier = ℕ\n ; _≈_ = _≡_\n ; _≤_ = _≤_\n ; isDecTotalOrder = record\n { isTotalOrder = record\n { isPartialOrder = record\n { isPreorder = record\n { isEquivalence = PropEq.isEquivalence\n ; reflexive = refl′\n ; trans = trans\n }\n ; antisym = antisym\n }\n ; total = total\n }\n ; _≟_ = _≟_\n ; _≤?_ = _≤?_\n }\n }\n where\n refl′ : _≡_ ⇒ _≤_\n refl′ {zero} refl = z≤n\n refl′ {suc m} refl = s≤s (refl′ refl)\n\n antisym : Antisymmetric _≡_ _≤_\n antisym z≤n z≤n = refl\n antisym (s≤s m≤n) (s≤s n≤m) with antisym m≤n n≤m\n ... | refl = refl\n\n trans : Transitive _≤_\n trans z≤n _ = z≤n\n trans (s≤s m≤n) (s≤s n≤o) = s≤s (trans m≤n n≤o)\n\n total : Total _≤_\n total zero _ = inj₁ z≤n\n total _ zero = inj₂ z≤n\n total (suc m) (suc n) with total m n\n ... | inj₁ m≤n = inj₁ (s≤s m≤n)\n ... | inj₂ n≤m = inj₂ (s≤s n≤m)\n\nimport Relation.Binary.PartialOrderReasoning as POR\nmodule ≤-Reasoning where\n open POR (DecTotalOrder.poset decTotalOrder) public\n renaming (_≈⟨_⟩_ to _≡⟨_⟩_)\n\n infixr 2 _<⟨_⟩_\n\n _<⟨_⟩_ : ∀ x {y z} → x < y → y IsRelatedTo z → suc x IsRelatedTo z\n x <⟨ x lookup c₁ p ≡ project g₁ p\n refls zero = refl\n refls (suc zero) = refl\n refls (suc (suc zero)) = refl\n refls (suc (suc (suc zero))) = refl\n", "meta": {"hexsha": "a0c973623a96e11509362b262594d514c467d462", "size": 1791, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Example.agda", "max_stars_repo_name": "fangyi-zhou/mpst-in-agda", "max_stars_repo_head_hexsha": "3d12eed9d340207d242d70f43c6b34e01d3620de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-08-14T17:36:53.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-14T17:36:53.000Z", "max_issues_repo_path": "Example.agda", "max_issues_repo_name": "fangyi-zhou/mpst-in-agda", "max_issues_repo_head_hexsha": "3d12eed9d340207d242d70f43c6b34e01d3620de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-08-31T10:15:38.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-24T11:30:17.000Z", "max_forks_repo_path": "Example.agda", "max_forks_repo_name": "fangyi-zhou/mpst-in-agda", "max_forks_repo_head_hexsha": "3d12eed9d340207d242d70f43c6b34e01d3620de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.2755102041, "max_line_length": 70, "alphanum_fraction": 0.594639866, "num_tokens": 796, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357494949105, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.631180733839129}} {"text": "\nopen import Oscar.Prelude\nopen import Oscar.Class\nopen import Oscar.Class.Reflexivity\nopen import Oscar.Class.Symmetry\nopen import Oscar.Class.Transitivity\nopen import Oscar.Class.IsEquivalence\nopen import Oscar.Class.Setoid\nopen import Oscar.Data.Proposequality\n\nmodule Oscar.Property.Setoid.Proposequality where\n\nmodule _ {𝔬} {𝔒 : Ø 𝔬} where\n\n instance\n\n 𝓡eflexivityProposequality : Reflexivity.class Proposequality⟦ 𝔒 ⟧\n 𝓡eflexivityProposequality .⋆ = !\n\n 𝓢ymmetryProposequality : Symmetry.class Proposequality⟦ 𝔒 ⟧\n 𝓢ymmetryProposequality .⋆ ∅ = !\n\n 𝓣ransitivityProposequality : Transitivity.class Proposequality⟦ 𝔒 ⟧\n 𝓣ransitivityProposequality .⋆ ∅ y∼z = y∼z\n\n IsEquivalenceProposequality : IsEquivalence Proposequality⟦ 𝔒 ⟧\n IsEquivalenceProposequality = ∁\n\nmodule _ {𝔬} (𝔒 : Ø 𝔬) where\n\n SetoidProposequality : Setoid _ _\n SetoidProposequality = ∁ Proposequality⟦ 𝔒 ⟧\n", "meta": {"hexsha": "c4ee9314c5f021d633f07b99b69f766be3c27d0c", "size": 904, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-3/src/Oscar/Property/Setoid/Proposequality.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-3/src/Oscar/Property/Setoid/Proposequality.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-3/src/Oscar/Property/Setoid/Proposequality.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.3939393939, "max_line_length": 71, "alphanum_fraction": 0.7688053097, "num_tokens": 304, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9111797027760039, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.6311213163228908}} {"text": "module neq where\n\nopen import eq\nopen import negation\n\n----------------------------------------------------------------------\n-- syntax\n----------------------------------------------------------------------\n\ninfix 4 _≢_ \n\n----------------------------------------------------------------------\n-- defined types\n----------------------------------------------------------------------\n\n_≢_ : ∀ {ℓ}{A : Set ℓ} → A → A → Set ℓ\nx ≢ y = ¬ (x ≡ y)\n\nsym-≢ : ∀{ℓ}{A : Set ℓ}{x y : A} → x ≢ y → y ≢ x \nsym-≢ p₁ p₂ = p₁ (sym p₂)\n", "meta": {"hexsha": "edfd6639074a83d10664749a64a2424f0044e0f0", "size": 516, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "neq.agda", "max_stars_repo_name": "heades/AUGL", "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "neq.agda", "max_issues_repo_name": "heades/AUGL", "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "neq.agda", "max_forks_repo_name": "heades/AUGL", "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.5714285714, "max_line_length": 70, "alphanum_fraction": 0.2286821705, "num_tokens": 121, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9111796979521253, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.63112131298167}} {"text": "\nmodule Oscar.Data.Term.Substitution.Core {𝔣} (FunctionName : Set 𝔣) where\n\nopen import Oscar.Data.Term.Core FunctionName\nopen import Oscar.Data.Term.Substitution.Core.bootstrap FunctionName public hiding (_◃Term_; _◃VecTerm_)\nopen import Oscar.Data.Nat.Core\nopen import Oscar.Data.Fin.Core\nopen import Oscar.Data.Vec.Core\nopen import Oscar.Data.Equality.Core\nopen import Oscar.Data.Product.Core\nopen import Oscar.Function\nopen import Oscar.Level\n\n⊸-Property : {ℓ : Level} → ℕ → Set (lsuc ℓ ⊔ 𝔣)\n⊸-Property {ℓ} m = ∀ {n} → m ⊸ n → Set ℓ\n\n_≐_ : {m n : ℕ} → m ⊸ n → m ⊸ n → Set 𝔣\nf ≐ g = ∀ x → f x ≡ g x\n\n⊸-Extensional : {ℓ : Level} {m : ℕ} → ⊸-Property {ℓ} m → Set (ℓ ⊔ 𝔣)\n⊸-Extensional P = ∀ {m f g} → f ≐ g → P {m} f → P g\n\n⊸-ExtentionalProperty : {ℓ : Level} → ℕ → Set (lsuc ℓ ⊔ 𝔣)\n⊸-ExtentionalProperty {ℓ} m = Σ (⊸-Property {ℓ} m) ⊸-Extensional\n", "meta": {"hexsha": "2f0be843553a02d4f246095c24489a5a0f433539", "size": 849, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-2/Oscar/Data/Term/Core.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-2/Oscar/Data/Term/Core.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-2/Oscar/Data/Term/Core.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.96, "max_line_length": 104, "alphanum_fraction": 0.6595995289, "num_tokens": 332, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9111797075998823, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.6311213081019906}} {"text": "module DeBruijnExSubst where\n\nopen import Prelude -- using (_∘_) -- composition, identity\nopen import Data.Maybe\nopen import Logic.Identity renaming (subst to subst≡)\nimport Logic.ChainReasoning\nmodule Chain = Logic.ChainReasoning.Poly.Homogenous _≡_ (\\x -> refl) (\\x y z -> trans)\nopen Chain\n\nopen import DeBruijn\n\n-- untyped de Bruijn terms \ndata LamE (A : Set) : Set where\n varE : A -> LamE A\n appE : LamE A -> LamE A -> LamE A\n absE : LamE (Maybe A) -> LamE A\n flatE : LamE (LamE A) -> LamE A\n\n-- functoriality of LamE \nlamE : {A B : Set} -> (A -> B) -> LamE A -> LamE B\nlamE f (varE a) = varE (f a)\nlamE f (appE t1 t2) = appE (lamE f t1) (lamE f t2)\nlamE f (absE r) = absE (lamE (fmap f) r)\nlamE f (flatE r) = flatE (lamE (lamE f) r)\n\n{- from TCS 05 paper\neval' : {A B : Set} -> (A -> B) -> LamE A -> Lam B\neval' f (varE a) = var (f a)\neval' f (appE t1 t2) = app (eval' f t1) (eval' f t2)\neval' f (absE r) = abs (eval' (fmap f) r) \neval' f (flatE r) = subst id (eval' (eval' f) r)\n\neval : {A : Set} -> LamE A -> Lam A\neval = eval' id\n-}\n\neval : {A : Set} -> LamE A -> Lam A\neval (varE a) = var a\neval (appE t1 t2) = app (eval t1) (eval t2)\neval (absE r) = abs (eval r)\neval (flatE r) = subst eval (eval r)\n\nevalNAT : {A B : Set}(f : A -> B) -> (t : LamE A) -> \n eval (lamE f t) ≡ lam f (eval t)\nevalNAT f (varE a) = refl\nevalNAT f (appE t1 t2) =\n chain> eval (lamE f (appE t1 t2))\n === eval (appE (lamE f t1) (lamE f t2))\n by refl\n === app (eval (lamE f t1)) (eval (lamE f t2))\n by refl\n === app (lam f (eval t1)) (eval (lamE f t2))\n by cong (\\ x -> app x (eval (lamE f t2))) (evalNAT f t1)\n === app (lam f (eval t1)) (lam f (eval t2))\n by cong (\\ x -> app (lam f (eval t1)) x) (evalNAT f t2)\n === lam f (app (eval t1) (eval t2))\n by refl\n === lam f (eval (appE t1 t2))\n by refl\nevalNAT f (absE r) =\n chain> eval (lamE f (absE r))\n === eval (absE (lamE (fmap f) r)) by refl\n === abs (eval (lamE (fmap f) r)) by refl\n === abs (lam (fmap f) (eval r)) by cong abs (evalNAT (fmap f) r)\n === lam f (abs (eval r)) by refl\n === lam f (eval (absE r)) by refl\nevalNAT f (flatE r) = \n chain> eval (lamE f (flatE r))\n === eval (flatE (lamE (lamE f) r))\n by refl\n === subst eval (eval (lamE (lamE f) r))\n by refl\n === subst eval (lam (lamE f) (eval r))\n by cong (subst eval) (evalNAT (lamE f) r)\n === subst (eval ∘ lamE f) (eval r)\n by substLaw1 (lamE f) eval (eval r)\n === subst (lam f ∘ eval) (eval r)\n by substExt _ _ (evalNAT f) (eval r)\n === lam f (subst eval (eval r))\n by substLaw2 f eval (eval r)\n === lam f (eval (flatE r))\n by refl\n\nevalNATcor : {A : Set}(ee : LamE (LamE A)) ->\n subst id (eval (lamE eval ee)) ≡ eval (flatE ee)\nevalNATcor ee = \n chain> subst id (eval (lamE eval ee))\n === subst id (lam eval (eval ee)) by cong (subst id) (evalNAT eval ee)\n === subst eval (eval ee) by substLaw1 eval id (eval ee)\n === eval (flatE ee) by refl", "meta": {"hexsha": "1c9685761194addcba6e963d9983de929a574621", "size": 3138, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/NestedDataTypes/DeBruijnExSubst.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/NestedDataTypes/DeBruijnExSubst.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/NestedDataTypes/DeBruijnExSubst.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.8666666667, "max_line_length": 86, "alphanum_fraction": 0.5372848948, "num_tokens": 1202, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637648915617, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.6310959513747103}} {"text": "{-# OPTIONS --without-K #-}\nopen import HoTT.Base\nopen import HoTT.Equivalence\nopen import HoTT.Identity\n\nmodule HoTT.Identity.Pi where\n\nopen variables\nprivate variable f g h : Π A P\n\nmodule _ {f g : Π A P} where\n -- Axiom 2.9.3 - function extensionality\n postulate\n happly-isequiv : isequiv (happly {f = f} {g})\n\n module _ where\n open qinv (isequiv→qinv happly-isequiv) renaming (g to happly⁻¹)\n abstract\n funext : f ~ g → f == g\n funext = happly⁻¹\n =Π-η : funext ∘ happly ~ id\n =Π-η = η\n =Π-β : happly ∘ funext ~ id\n =Π-β = ε\n\n=Π-equiv : f == g ≃ f ~ g\n=Π-equiv = happly , happly-isequiv\n\nfunext-∙ₕ : (α : f ~ g) (β : g ~ h) → funext (α ∙ₕ β) == funext α ∙ funext β\nfunext-∙ₕ α β = ap funext (funext λ x → (happly (=Π-β α) x ⋆ happly (=Π-β β) x) ⁻¹) ∙ p\n where\n p : funext (happly (funext α) ∙ₕ happly (funext β)) == funext α ∙ funext β\n p rewrite funext α rewrite funext β = =Π-η refl\n\nfunext-ap : {P : A → 𝒰 i} {Q : A → 𝒰 j} {g h : Π A P}\n (f : {a : A} → P a → Q a) (α : g ~ h) →\n funext (ap f ∘ α) == ap (f ∘_) (funext α)\nfunext-ap f α = ap (λ α → funext (ap f ∘ α)) (=Π-β α) ⁻¹ ∙ p\n where\n p : funext (ap f ∘ happly (funext α)) == ap (f ∘_) (funext α)\n p rewrite funext α = =Π-η refl\n", "meta": {"hexsha": "1512fc1f51f91bb639eab7d8e235215244cf3306", "size": 1260, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "HoTT/Identity/Pi.agda", "max_stars_repo_name": "michaelforney/hott", "max_stars_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_stars_repo_licenses": ["0BSD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "HoTT/Identity/Pi.agda", "max_issues_repo_name": "michaelforney/hott", "max_issues_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_issues_repo_licenses": ["0BSD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HoTT/Identity/Pi.agda", "max_forks_repo_name": "michaelforney/hott", "max_forks_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_forks_repo_licenses": ["0BSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.0, "max_line_length": 87, "alphanum_fraction": 0.5571428571, "num_tokens": 546, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637397236824, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.6310959428999049}} {"text": "{-# OPTIONS --cubical --safe --postfix-projections #-}\n\nmodule Relation.Nullary.Decidable.Logic where\n\nopen import Prelude\nopen import Data.Sum\nopen import Relation.Nullary.Decidable\n\ndisj : (A → C) → (B → C) → (¬ A → ¬ B → ¬ C) → Dec A → Dec B → Dec C\ndisj l r n x y .does = x .does or y .does\ndisj l r n (yes x) y .why = l x\ndisj l r n (no x) (yes y) .why = r y\ndisj l r n (no ¬x) (no ¬y) .why = n ¬x ¬y\n\nconj : (A → B → C) → (¬ A → ¬ C) → (¬ B → ¬ C) → Dec A → Dec B → Dec C\nconj c l r x y .does = x .does and y .does\nconj c l r (no ¬x) y .why = l ¬x\nconj c l r (yes x) (no ¬y) .why = r ¬y\nconj c l r (yes x) (yes y) .why = c x y\n\nnegate : (A → ¬ B) → (¬ A → B) → Dec A → Dec B\nnegate t f d .does = not (d .does)\nnegate t f (yes d) .why = t d\nnegate t f (no ¬d) .why = f ¬d\n\n! : Dec A → Dec (¬ A)\n! = negate (λ x ¬x → ¬x x) id\n\ninfixl 7 _&&_\n_&&_ : Dec A → Dec B → Dec (A × B)\n_&&_ = conj _,_ (_∘ fst) (_∘ snd)\n\ninfixl 6 _||_\n_||_ : Dec A → Dec B → Dec (A ⊎ B)\n_||_ = disj inl inr either\n", "meta": {"hexsha": "634ad7d4048ff021ac31b5b89577b9630db770d8", "size": 992, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Relation/Nullary/Decidable/Logic.agda", "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_issues_repo_path": "Relation/Nullary/Decidable/Logic.agda", "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Relation/Nullary/Decidable/Logic.agda", "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "avg_line_length": 27.5555555556, "max_line_length": 70, "alphanum_fraction": 0.53125, "num_tokens": 431, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972684083609, "lm_q2_score": 0.7248702702332476, "lm_q1q2_score": 0.6310700772154958}} {"text": "------------------------------------------------------------------------------\n-- Properties related with lists using instances of the induction principle\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOT.FOTC.Data.List.Induction.Instances.PropertiesATP where\n\nopen import FOTC.Base\nopen import FOTC.Base.List\nopen import FOTC.Data.List\nopen import FOTC.Data.Nat.Type\n\n------------------------------------------------------------------------------\n-- Totality properties\n\nlengthList-N-ind-instance :\n N (length []) →\n (∀ x {xs} → N (length xs) → N (length (x ∷ xs))) →\n ∀ {xs} → List xs → N (length xs)\nlengthList-N-ind-instance = List-ind (λ as → N (length as))\n\npostulate lengthList-N : ∀ {xs} → List xs → N (length xs)\n{-# ATP prove lengthList-N lengthList-N-ind-instance #-}\n\n++-List-ind-instance :\n ∀ {ys} →\n List ([] ++ ys) →\n (∀ x {xs} → List (xs ++ ys) → List ((x ∷ xs) ++ ys)) →\n ∀ {xs} → List xs → List (xs ++ ys)\n++-List-ind-instance {ys} = List-ind (λ as → List (as ++ ys))\n\npostulate ++-List : ∀ {xs ys} → List xs → List ys → List (xs ++ ys)\n{-# ATP prove ++-List ++-List-ind-instance #-}\n\nmap-List-ind-instance :\n ∀ {f} →\n List (map f []) →\n (∀ x {xs} → List (map f xs) → List (map f (x ∷ xs))) →\n ∀ {xs} → List xs → List (map f xs)\nmap-List-ind-instance {f} = List-ind (λ as → List (map f as))\n\npostulate map-List : ∀ f {xs} → List xs → List (map f xs)\n{-# ATP prove map-List map-List-ind-instance #-}\n\n------------------------------------------------------------------------------\n\n++-assoc-ind-instance :\n ∀ {ys zs} →\n ([] ++ ys) ++ zs ≡ [] ++ ys ++ zs →\n (∀ x {xs} →\n (xs ++ ys) ++ zs ≡ xs ++ ys ++ zs →\n ((x ∷ xs) ++ ys) ++ zs ≡ (x ∷ xs) ++ ys ++ zs) →\n ∀ {xs} → List xs → (xs ++ ys) ++ zs ≡ xs ++ ys ++ zs\n++-assoc-ind-instance {ys} {zs} =\n List-ind (λ as → (as ++ ys) ++ zs ≡ as ++ ys ++ zs )\n\npostulate\n ++-assoc : ∀ {xs} → List xs → ∀ ys zs → (xs ++ ys) ++ zs ≡ xs ++ ys ++ zs\n{-# ATP prove ++-assoc ++-assoc-ind-instance #-}\n\nmap-++-ind-instance :\n ∀ {f} {ys} →\n map f ([] ++ ys) ≡ map f [] ++ map f ys →\n (∀ x {xs} → map f (xs ++ ys) ≡ map f xs ++ map f ys →\n map f ((x ∷ xs) ++ ys) ≡ map f (x ∷ xs) ++ map f ys) →\n ∀ {xs} → List xs → map f (xs ++ ys) ≡ map f xs ++ map f ys\nmap-++-ind-instance {f} {ys} =\n List-ind (λ as → map f (as ++ ys) ≡ map f as ++ map f ys)\n\npostulate\n map-++ : ∀ f {xs} → List xs → ∀ ys →\n map f (xs ++ ys) ≡ map f xs ++ map f ys\n{-# ATP prove map-++ map-++-ind-instance #-}\n", "meta": {"hexsha": "685ac286f2834cc73a923d6380b64ceafcf26b8e", "size": 2681, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/FOTC/Data/List/Induction/Instances/PropertiesATP.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/FOT/FOTC/Data/List/Induction/Instances/PropertiesATP.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/FOT/FOTC/Data/List/Induction/Instances/PropertiesATP.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 34.3717948718, "max_line_length": 78, "alphanum_fraction": 0.4599030213, "num_tokens": 838, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744806385542, "lm_q2_score": 0.7718435083355187, "lm_q1q2_score": 0.6310395554616514}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Cardinality.Finite.ManifestBishop.Isomorphism where\n\nopen import Prelude\nopen import Data.Fin\nopen import Data.Fin.Properties\n\nopen import Container.List.Isomorphism\n\nimport Cardinality.Finite.ManifestBishop.Inductive as 𝕃\nimport Cardinality.Finite.ManifestBishop.Container as ℒ\n\nopen import Cardinality.Finite.SplitEnumerable.Isomorphism\n\nopen import Data.Nat.Properties\n\n∈!ℒ⇒∈!𝕃 : ∀ (x : A) l (xs : Fin l → A) → x ℒ.∈! (l , xs) → x 𝕃.∈! ℒ→𝕃 (l , xs)\n∈!ℒ⇒∈!𝕃 x (suc l) xs ((f0 , p) , u) = (f0 , p) , lemma\n where\n lemma : (y : x 𝕃.∈ ℒ→𝕃 (suc l , xs)) → (f0 , p) ≡ y\n lemma (f0 , q) = cong (∈ℒ⇒∈𝕃 x (suc l , xs)) (u (f0 , q))\n lemma (fs m , q) =\n let o , r = subst (x ℒ.∈_) (ℒ→𝕃→ℒ l (xs ∘ fs)) (m , q)\n in ⊥-elim (znots (cong (FinToℕ ∘ fst) (u (fs o , r))))\n∈!ℒ⇒∈!𝕃 x (suc l) xs ((fs n , p) , u) = 𝕃.push! xs0≢x (∈!ℒ⇒∈!𝕃 x l (xs ∘ fs) ((n , p) , uxss))\n where\n xs0≢x : xs f0 ≢ x\n xs0≢x xs0≡x = snotz (cong (FinToℕ ∘ fst) (u (f0 , xs0≡x)))\n\n uxss : (y : x ℒ.∈ (l , xs ∘ fs)) → (n , p) ≡ y\n uxss (m , q) = cong (λ { (f0 , q) → ⊥-elim (xs0≢x q) ; (fs m , q) → m , q}) (u (fs m , q))\n\n𝕃⇔ℒ⟨ℬ⟩ : 𝕃.ℬ A ⇔ ℒ.ℬ A\n𝕃⇔ℒ⟨ℬ⟩ .fun (sup , cov) = 𝕃→ℒ sup , cov\n𝕃⇔ℒ⟨ℬ⟩ .inv ((l , xs) , cov) = ℒ→𝕃 (l , xs) , λ x → ∈!ℒ⇒∈!𝕃 x l xs (cov x)\n𝕃⇔ℒ⟨ℬ⟩ .rightInv (sup , cov) i .fst = 𝕃⇔ℒ .rightInv sup i\n𝕃⇔ℒ⟨ℬ⟩ .rightInv ((l , xs) , cov) i .snd x =\n J\n (λ ys ys≡ → (zs : x ℒ.∈! ys) → PathP (λ i → x ℒ.∈! sym ys≡ i) zs (cov x))\n (λ _ → isPropIsContr _ _)\n (sym (ℒ→𝕃→ℒ l xs))\n (∈!ℒ⇒∈!𝕃 x l xs (cov x))\n i\n𝕃⇔ℒ⟨ℬ⟩ .leftInv (sup , cov) i .fst = 𝕃⇔ℒ .leftInv sup i\n𝕃⇔ℒ⟨ℬ⟩ .leftInv (sup , cov) i .snd x =\n J\n (λ ys ys≡ → (zs : x 𝕃.∈! ys) → PathP (λ i → x 𝕃.∈! sym ys≡ i) zs (cov x))\n (λ zs → isPropIsContr _ _)\n (sym (𝕃→ℒ→𝕃 sup))\n (∈!ℒ⇒∈!𝕃 x (𝕃.length sup) (sup 𝕃.!_) (cov x))\n i\n", "meta": {"hexsha": "1ffda6cd4e72d922ad53385cd758b1c75fd0648c", "size": 1840, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Cardinality/Finite/ManifestBishop/Isomorphism.agda", "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z", "max_issues_repo_path": "agda/Cardinality/Finite/ManifestBishop/Isomorphism.agda", "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Cardinality/Finite/ManifestBishop/Isomorphism.agda", "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "avg_line_length": 34.7169811321, "max_line_length": 94, "alphanum_fraction": 0.5190217391, "num_tokens": 1036, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744673038222, "lm_q2_score": 0.7718434925908525, "lm_q1q2_score": 0.6310395322968879}} {"text": "module Data.List.Relation.Pairwise.Proofs where\n\nopen import Data.List\nimport Data.List.Functions as List\nopen import Data.List.Relation.Pairwise\nopen import Logic\nimport Lvl\nopen import Type\n\nprivate variable ℓ ℓₗ : Lvl.Level\nprivate variable T A B : Type{ℓ}\nprivate variable x : T\nprivate variable f : A → B\nprivate variable _▫_ : T → T → Type{ℓₗ}\nprivate variable _▫₁_ : A → A → Type{ℓₗ}\nprivate variable _▫₂_ : B → B → Type{ℓₗ}\n\nAdjacentlyPairwise-map : (∀{x y} → (x ▫₁ y) → (f(x) ▫₂ f(y))) → ∀{l} → AdjacentlyPairwise(_▫₁_)(l) → AdjacentlyPairwise(_▫₂_)(List.map f(l))\nAdjacentlyPairwise-map p {∅} s = AdjacentlyPairwise.empty\nAdjacentlyPairwise-map p {x ⊰ ∅} s = AdjacentlyPairwise.single\nAdjacentlyPairwise-map p {x ⊰ y ⊰ l} (AdjacentlyPairwise.step ⦃ s₁ ⦄ ⦃ s₂ ⦄) = AdjacentlyPairwise.step ⦃ p s₁ ⦄ ⦃ AdjacentlyPairwise-map p {y ⊰ l} s₂ ⦄\n\nAdjacentlyPairwise-prepend : (∀{y} → (x ▫ y)) → ∀{l} → AdjacentlyPairwise(_▫_)(l) → AdjacentlyPairwise(_▫_)(x ⊰ l)\nAdjacentlyPairwise-prepend xy {∅} p = AdjacentlyPairwise.single\nAdjacentlyPairwise-prepend xy {_ ⊰ _} p = AdjacentlyPairwise.step ⦃ xy ⦄ ⦃ p ⦄\n", "meta": {"hexsha": "e99f306229e3017b0a5fa5338ee4fb831fbdf1d7", "size": 1120, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/List/Relation/Pairwise/Proofs.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/List/Relation/Pairwise/Proofs.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/List/Relation/Pairwise/Proofs.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.0769230769, "max_line_length": 151, "alphanum_fraction": 0.6964285714, "num_tokens": 441, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511396138365, "lm_q2_score": 0.7371581510799252, "lm_q1q2_score": 0.6308976436773827}} {"text": "module STLC.Type.Relation where\n\nopen import Data.Nat using (ℕ)\nopen import Data.Fin using (Fin)\n\nopen import STLC.Term\nopen import STLC.Type\n\nopen import STLC.Type.Context using (Ctxt)\n\nopen import Data.Vec using (_∷_; lookup)\n\nopen import Relation.Nullary using (¬_)\n\nopen import Relation.Binary.PropositionalEquality as Eq\n using (refl; _≡_; sym; cong)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎)\n\n\ninfix 4 _⊢_⦂_\n\ndata _⊢_⦂_ { m n } (Γ : Ctxt m n) : Term m -> Type n -> Set where\n\n ⊢# : ∀ { x : Fin m } \n -- ---------------\n -> Γ ⊢ # x ⦂ lookup Γ x \n\n ⊢ƛ : ∀ { t τ₁ τ₂ } \n -> τ₁ ∷ Γ ⊢ t ⦂ τ₂\n -- -----------------\n -> Γ ⊢ ƛ t ⦂ τ₁ ⇒ τ₂\n\n ⊢_·_ : ∀ { t₁ t₂ τ₁ τ₂ }\n -> Γ ⊢ t₁ ⦂ τ₁ ⇒ τ₂\n -> Γ ⊢ t₂ ⦂ τ₁\n -- ------------------\n -> Γ ⊢ t₁ · t₂ ⦂ τ₂ \n\n_⊬_⦂_ : ∀ { m n } -> Ctxt m n -> Term m -> Type n -> Set\nΓ ⊬ t ⦂ τ = ¬ (Γ ⊢ t ⦂ τ)\n\nmodule Lemmas₀ where\n\n ⊢-subst : ∀ { m n } { Γ₁ Γ₂ : Ctxt m n } { t₁ t₂ : Term m } { τ₁ τ₂ : Type n } \n -> Γ₁ ≡ Γ₂ -> t₁ ≡ t₂ -> τ₁ ≡ τ₂ -> Γ₁ ⊢ t₁ ⦂ τ₁ -> Γ₂ ⊢ t₂ ⦂ τ₂\n ⊢-subst refl refl refl hyp = hyp\n\n ⊢-Γ-subst : ∀ { m n } { Γ₁ Γ₂ : Ctxt m n } { t : Term m } { τ : Type n }\n -> Γ₁ ≡ Γ₂ -> Γ₁ ⊢ t ⦂ τ -> Γ₂ ⊢ t ⦂ τ\n ⊢-Γ-subst ≡-Γ hyp = ⊢-subst ≡-Γ refl refl hyp\n\n ⊢-τ-subst : ∀ { m n } { Γ : Ctxt m n } { t : Term m } { τ₁ τ₂ : Type n }\n -> τ₁ ≡ τ₂ -> Γ ⊢ t ⦂ τ₁ -> Γ ⊢ t ⦂ τ₂\n ⊢-τ-subst ≡-τ hyp = ⊢-subst refl refl ≡-τ hyp\n \n-- TODO: Substitutions on typing derivations\n-- TODO: Equivalent for Value e.g. value ⦂ τ relation w/ some lemmas :)\n\n\n", "meta": {"hexsha": "22006800de83af86f9d3e258bb447593fb46cc7d", "size": 1540, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/STLC/Type/Relation.agda", "max_stars_repo_name": "johnyob/agda-types", "max_stars_repo_head_hexsha": "aeb2be63381d891fabe5317e3c27553deb6bca6d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/STLC/Type/Relation.agda", "max_issues_repo_name": "johnyob/agda-types", "max_issues_repo_head_hexsha": "aeb2be63381d891fabe5317e3c27553deb6bca6d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/STLC/Type/Relation.agda", "max_forks_repo_name": "johnyob/agda-types", "max_forks_repo_head_hexsha": "aeb2be63381d891fabe5317e3c27553deb6bca6d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.6666666667, "max_line_length": 81, "alphanum_fraction": 0.4967532468, "num_tokens": 678, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920020959544, "lm_q2_score": 0.7879311956428947, "lm_q1q2_score": 0.6308902065531685}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Data.Nat.Coprime where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\n\nopen import Cubical.Data.Sigma\nopen import Cubical.Data.NatPlusOne\n\nopen import Cubical.HITs.PropositionalTruncation as PropTrunc\n\nopen import Cubical.Data.Nat.Base\nopen import Cubical.Data.Nat.Properties\nopen import Cubical.Data.Nat.Divisibility\nopen import Cubical.Data.Nat.GCD\n\nareCoprime : ℕ × ℕ → Type₀\nareCoprime (m , n) = isGCD m n 1\n\n-- Any pair (m , n) can be converted to a coprime pair (m' , n') s.t.\n-- m' ∣ m, n' ∣ n if and only if one of m or n is nonzero\n\nmodule ToCoprime ((m , n) : ℕ × ℕ₊₁) where\n d = gcd m (ℕ₊₁→ℕ n)\n d∣m = gcdIsGCD m (ℕ₊₁→ℕ n) .fst .fst\n d∣n = gcdIsGCD m (ℕ₊₁→ℕ n) .fst .snd\n gr = gcdIsGCD m (ℕ₊₁→ℕ n) .snd\n\n c₁ : ℕ\n p₁ : c₁ · d ≡ m\n c₁ = ∣-untrunc d∣m .fst; p₁ = ∣-untrunc d∣m .snd\n\n c₂ : ℕ₊₁\n p₂ : (ℕ₊₁→ℕ c₂) · d ≡ (ℕ₊₁→ℕ n)\n c₂ = 1+ (∣s-untrunc d∣n .fst); p₂ = ∣s-untrunc d∣n .snd\n\n toCoprime : ℕ × ℕ₊₁\n toCoprime = (c₁ , c₂)\n\n private\n lem : ∀ a {b c d e} → a · b ≡ c → c · d ≡ e → a · (b · d) ≡ e\n lem a p q = ·-assoc a _ _ ∙ cong (_· _) p ∙ q\n\n gr' : ∀ d' → prediv d' c₁ → prediv d' (ℕ₊₁→ℕ c₂) → (d' · d) ∣ d\n gr' d' (b₁ , q₁) (b₂ , q₂) = gr (d' · d) ((∣ b₁ , lem b₁ q₁ p₁ ∣) ,\n (∣ b₂ , lem b₂ q₂ p₂ ∣))\n\n d-1 = m∣sn→z 0 (<=> m > 0 or n > 0)\n d-cancelʳ : ∀ d' → (d' · d) ∣ d → d' ∣ 1\n d-cancelʳ d' div = ∣-cancelʳ d-1 (∣-trans (subst (λ x → (d' · x) ∣ x) q div)\n (∣-refl (sym (·-identityˡ _))))\n\n toCoprimeAreCoprime : areCoprime (c₁ , ℕ₊₁→ℕ c₂)\n fst toCoprimeAreCoprime = ∣-oneˡ c₁ , ∣-oneˡ (ℕ₊₁→ℕ c₂)\n snd toCoprimeAreCoprime d' (d'∣c₁ , d'∣c₂) = PropTrunc.rec isProp∣ (λ a →\n PropTrunc.rec isProp∣ (λ b →\n d-cancelʳ d' (gr' d' a b)) d'∣c₂) d'∣c₁\n\n toCoprime∣ : (c₁ ∣ m) × (ℕ₊₁→ℕ c₂ ∣ ℕ₊₁→ℕ n)\n toCoprime∣ = ∣ d , ·-comm d c₁ ∙ p₁ ∣ , ∣ d , ·-comm d (ℕ₊₁→ℕ c₂) ∙ p₂ ∣\n\n toCoprime-idem : areCoprime (m , ℕ₊₁→ℕ n) → (c₁ , c₂) ≡ (m , n)\n toCoprime-idem cp i = q₁ i , ℕ₊₁→ℕ-inj q₂ i\n where q₁ = sym (·-identityʳ c₁) ∙ cong (c₁ ·_) (sym (isGCD→gcd≡ cp)) ∙ p₁\n q₂ = sym (·-identityʳ (ℕ₊₁→ℕ c₂)) ∙ cong (ℕ₊₁→ℕ c₂ ·_) (sym (isGCD→gcd≡ cp)) ∙ p₂\n\nopen ToCoprime using (toCoprime; toCoprimeAreCoprime; toCoprime∣; toCoprime-idem) public\n\n\ntoCoprime-cancelʳ : ∀ ((m , n) : ℕ × ℕ₊₁) k\n → toCoprime (m · ℕ₊₁→ℕ k , n ·₊₁ k) ≡ toCoprime (m , n)\ntoCoprime-cancelʳ (m , n) (1+ k) i =\n inj-·sm {c₁'} {d-1} {c₁} r₁ i , ℕ₊₁→ℕ-inj (inj-·sm {ℕ₊₁→ℕ c₂'} {d-1} {ℕ₊₁→ℕ c₂} r₂) i\n where open ToCoprime (m , n)\n open ToCoprime (m · suc k , n ·₊₁ (1+ k)) using ()\n renaming (c₁ to c₁'; p₁ to p₁'; c₂ to c₂'; p₂ to p₂')\n\n q₁ : c₁' · d · suc k ≡ m · suc k\n q₁ = sym (·-assoc c₁' (ToCoprime.d (m , n)) (suc k))\n ∙ cong (c₁' ·_) (sym (gcd-factorʳ m (ℕ₊₁→ℕ n) (suc k)))\n ∙ p₁'\n q₂ : ℕ₊₁→ℕ c₂' · (ToCoprime.d (m , n)) · suc k ≡ ℕ₊₁→ℕ n · suc k\n q₂ = sym (·-assoc (ℕ₊₁→ℕ c₂') (ToCoprime.d (m , n)) (suc k))\n ∙ cong (ℕ₊₁→ℕ c₂' ·_) (sym (gcd-factorʳ m (ℕ₊₁→ℕ n) (suc k)))\n ∙ p₂'\n\n r₁ : c₁' · suc d-1 ≡ c₁ · suc d-1\n r₁ = subst (λ z → c₁' · z ≡ c₁ · z) q (inj-·sm q₁ ∙ sym p₁)\n r₂ : ℕ₊₁→ℕ c₂' · suc d-1 ≡ ℕ₊₁→ℕ c₂ · suc d-1\n r₂ = subst (λ z → ℕ₊₁→ℕ c₂' · z ≡ ℕ₊₁→ℕ c₂ · z) q (inj-·sm q₂ ∙ sym p₂)\n", "meta": {"hexsha": "8c578162d2db91140e9de4640ddc5b1151555cbf", "size": 3678, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/Nat/Coprime.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/Nat/Coprime.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/Data/Nat/Coprime.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.3125, "max_line_length": 91, "alphanum_fraction": 0.5, "num_tokens": 1812, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772253241803, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.6308593043887079}} {"text": "\nmodule Datoid where\n\n import Equiv\n import Prelude\n\n open Equiv\n open Prelude\n\n data Datoid : Set1 where\n datoid : (a : Set) -> DecidableEquiv a -> Datoid\n\n El : Datoid -> Set\n El (datoid a _) = a\n\n datoidEq : (a : Datoid) -> DecidableEquiv (El a)\n datoidEq (datoid _ eq) = eq\n\n datoidRel : (a : Datoid) -> El a -> El a -> Set\n datoidRel d = rel' (datoidEq d)\n\n datoidDecRel : (a : Datoid) -> (x y : El a)\n -> Either (datoidRel a x y) (Not (datoidRel a x y))\n datoidDecRel d = decRel (datoidEq d)\n\n dRefl : (a : Datoid) -> {x : El a} -> datoidRel a x x\n dRefl a = refl (datoidEq a)\n\n dSym : (a : Datoid) -> {x y : El a}\n -> datoidRel a x y -> datoidRel a y x\n dSym a = sym (datoidEq a)\n\n dTrans : (a : Datoid) -> {x y z : El a}\n -> datoidRel a x y -> datoidRel a y z -> datoidRel a x z\n dTrans a = trans (datoidEq a)\n\n data Respects (a : Datoid) (P : El a -> Set) : Set where\n respects : ((x y : El a) -> datoidRel a x y -> P x -> P y) -> Respects a P\n\n subst : {a : Datoid} -> {P : El a -> Set} -> Respects a P\n -> (x y : El a) -> datoidRel a x y -> P x -> P y\n subst (respects f) = f\n\n pairDatoid : (a b : Datoid) -> Datoid\n pairDatoid a b = datoid (Pair (El a) (El b))\n (pairEquiv (datoidEq a) (datoidEq b))\n\n", "meta": {"hexsha": "cfb8a7044c604cdf556730997eaacbf0deba2a1c", "size": 1301, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/AIM4/bag/Datoid.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/AIM4/bag/Datoid.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/AIM4/bag/Datoid.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 27.1041666667, "max_line_length": 78, "alphanum_fraction": 0.5480399693, "num_tokens": 495, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772286044095, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.6308592962931389}} {"text": "------------------------------------------------------------------------------\n-- First-order logic theorems\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- This module contains some examples showing the use of the ATPs for\n-- proving first-order logic theorems.\n\nmodule FOL.TheoremsATP where\n\nopen import FOL.Base\n\n------------------------------------------------------------------------------\n-- We postulate some formulae and propositional functions.\npostulate\n A : Set\n A¹ B¹ : D → Set\n A² : D → D → Set\n\n-- The introduction and elimination rules for the quantifiers are theorems.\n{-\n φ(x)\n ----------- ∀-intro\n ∀x.φ(x)\n\n ∀x.φ(x)\n ----------- ∀-elim\n φ(t)\n\n φ(t)\n ----------- ∃-intro\n ∃x.φ(x)\n\n ∃x.φ(x) φ(x) → ψ\n ---------------------- ∃-elim\n ψ\n-}\n\npostulate\n ∀-intro : ((x : D) → A¹ x) → ∀ x → A¹ x\n ∀-intro' : ((x : D) → A¹ x) → ⋀ A¹\n ∀-elim : (t : D) → (∀ x → A¹ x) → A¹ t\n ∀-elim' : (t : D) → ⋀ A¹ → A¹ t\n ∃-intro : (t : D) → A¹ t → ∃ A¹\n ∃-elim : ∃ A¹ → ((x : D) → A¹ x → A) → A\n{-# ATP prove ∀-intro #-}\n{-# ATP prove ∀-intro' #-}\n{-# ATP prove ∀-elim #-}\n{-# ATP prove ∀-elim' #-}\n{-# ATP prove ∃-intro #-}\n{-# ATP prove ∃-elim #-}\n\n-- Generalization of De Morgan's laws.\npostulate\n gDM₁ : ¬ (∀ x → A¹ x) ↔ (∃[ x ] ¬ (A¹ x))\n gDM₂ : ¬ (∃ A¹) ↔ (∀ x → ¬ (A¹ x))\n gDM₃ : (∀ x → A¹ x) ↔ ¬ (∃[ x ] ¬ (A¹ x))\n gDM₄ : ∃ A¹ ↔ ¬ (∀ x → ¬ (A¹ x))\n{-# ATP prove gDM₁ #-}\n{-# ATP prove gDM₂ #-}\n{-# ATP prove gDM₃ #-}\n{-# ATP prove gDM₄ #-}\n\n-- The order of quantifiers of the same sort is irrelevant.\npostulate\n ∀-ord : (∀ x y → A² x y) ↔ (∀ y x → A² x y)\n ∃-ord : (∃[ x ] ∃[ y ] A² x y) ↔ (∃[ y ] ∃[ x ] A² x y)\n{-# ATP prove ∀-ord #-}\n{-# ATP prove ∃-ord #-}\n\n-- Quantification over a variable that does not occur can be erased or\n-- added.\npostulate ∃-erase-add : (∃[ x ] A ∧ A¹ x) ↔ A ∧ (∃[ x ] A¹ x)\n{-# ATP prove ∃-erase-add #-}\n\n-- Distributes laws for the quantifiers.\npostulate\n ∀-dist : (∀ x → A¹ x ∧ B¹ x) ↔ ((∀ x → A¹ x) ∧ (∀ x → B¹ x))\n ∃-dist : (∃[ x ] (A¹ x ∨ B¹ x)) ↔ (∃ A¹ ∨ ∃ B¹)\n{-# ATP prove ∀-dist #-}\n{-# ATP prove ∃-dist #-}\n\n-- Interchange of quantifiers.\n-- The related theorem ∀x∃y.Axy → ∃y∀x.Axy is not (classically) valid.\npostulate ∃∀ : ∃[ x ] (∀ y → A² x y) → ∀ y → ∃[ x ] A² x y\n{-# ATP prove ∃∀ #-}\n\n-- ∃ in terms of ∀ and ¬.\npostulate\n ∃→¬∀¬ : ∃[ x ] A¹ x → ¬ (∀ {x} → ¬ A¹ x)\n ∃¬→¬∀ : ∃[ x ] ¬ A¹ x → ¬ (∀ {x} → A¹ x)\n{-# ATP prove ∃→¬∀¬ #-}\n{-# ATP prove ∃¬→¬∀ #-}\n\n-- ∀ in terms of ∃ and ¬.\npostulate\n ∀→¬∃¬ : (∀ {x} → A¹ x) → ¬ (∃[ x ] ¬ A¹ x)\n ∀¬→¬∃ : (∀ {x} → ¬ A¹ x) → ¬ (∃[ x ] A¹ x)\n{-# ATP prove ∀→¬∃¬ #-}\n{-# ATP prove ∀¬→¬∃ #-}\n\n-- Distribution of ∃ and ∨.\npostulate ∃∨ : ∃[ x ](A¹ x ∨ B¹ x) → (∃[ x ] A¹ x) ∨ (∃[ x ] B¹ x)\n{-# ATP prove ∃∨ #-}\n", "meta": {"hexsha": "4654c5c0aabb153bb23ffe8f91ea69a59caf2f71", "size": 2992, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/FOL/TheoremsATP.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/FOL/TheoremsATP.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/FOL/TheoremsATP.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 27.4495412844, "max_line_length": 78, "alphanum_fraction": 0.4221256684, "num_tokens": 1137, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772253241803, "lm_q2_score": 0.721743200312399, "lm_q1q2_score": 0.6308592939256558}} {"text": "{-# OPTIONS --cubical --no-import-sorts #-}\n\nopen import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc)\nopen import Function.Base using (_∋_; _$_)\n\nopen import MorePropAlgebra.Bundles\nimport Cubical.Structures.CommRing as Std\n\nmodule MorePropAlgebra.Properties.CommRing {ℓ} (assumptions : CommRing {ℓ}) where\nopen CommRing assumptions renaming (Carrier to R)\n\nimport MorePropAlgebra.Properties.Ring\nmodule Ring'Properties = MorePropAlgebra.Properties.Ring (record { CommRing assumptions })\nmodule Ring' = Ring (record { CommRing assumptions })\n( Ring') = Ring ∋ (record { CommRing assumptions })\n\n\nstdIsCommRing : Std.IsCommRing 0r 1r _+_ _·_ (-_)\nstdIsCommRing .Std.IsCommRing.isRing = Ring'Properties.stdIsRing\nstdIsCommRing .Std.IsCommRing.·-comm = ·-comm\n\nstdCommRing : Std.CommRing {ℓ}\nstdCommRing = record { CommRing assumptions ; isCommRing = stdIsCommRing }\n--\n-- module RingTheory' = Std.Theory stdRing\n", "meta": {"hexsha": "b112c7b14de2f4d57f5fda6f5021bef812330651", "size": 1020, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/MorePropAlgebra/Properties/CommRing.agda", "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_issues_repo_path": "agda/MorePropAlgebra/Properties/CommRing.agda", "max_issues_repo_name": "mchristianl/synthetic-reals", "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/MorePropAlgebra/Properties/CommRing.agda", "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.2307692308, "max_line_length": 92, "alphanum_fraction": 0.7019607843, "num_tokens": 273, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.919642528975397, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.6308282856488328}} {"text": "{-# OPTIONS --warning=error --without-K --safe #-}\n\nopen import LogicalFormulae\nopen import Categories.Definition\nopen import Categories.Functor.Definition\n\nmodule Categories.Functor.Lemmas where\n\nfunctorCompose : {a b c d e f : _} {B : Category {a} {b}} {C : Category {c} {d}} {D : Category {e} {f}} → (Functor C D) → (Functor B C) → (Functor B D)\nfunctorCompose G F = record { onObj = λ x → Functor.onObj G (Functor.onObj F x) ; onArrow = λ f → Functor.onArrow G (Functor.onArrow F f) ; mapId = λ {T} → mapIdHelp G F T ; mapCompose = λ r s → mapComposeHelp G F r s }\n where\n mapIdHelp : {a b c d e f : _} {B : Category {a} {b}} {C : Category {c} {d}} {D : Category {e} {f}} → (G : Functor C D) → (F : Functor B C) → (T : Category.objects B) → Functor.onArrow G (Functor.onArrow F (Category.id B T)) ≡ Category.id D (Functor.onObj G (Functor.onObj F T))\n mapIdHelp {B = B} {C} {D} record { onObj = onObjG ; onArrow = onArrowG ; mapId = mapIdG ; mapCompose = mapComposeG } record { onObj = onObj ; onArrow = onArrow ; mapId = mapId ; mapCompose = mapCompose } T rewrite mapId {T} = mapIdG {onObj T}\n mapComposeHelp : {a b c d e f : _} {B : Category {a} {b}} {C : Category {c} {d}} {D : Category {e} {f}} → (G : Functor C D) → (F : Functor B C) → {S T U : Category.objects B} → (r : Category.arrows B S T) → (s : Category.arrows B T U) → (Functor.onArrow G (Functor.onArrow F (Category._∘_ B s r))) ≡ (Category._∘_ D (Functor.onArrow G (Functor.onArrow F s)) (Functor.onArrow G (Functor.onArrow F r)))\n mapComposeHelp {B = record { objects = objectsB ; arrows = arrowsB ; id = idB ; _∘_ = _∘B_ ; rightId = rightIdB ; leftId = leftIdB ; compositionAssociative = associativeB }} {record { objects = objectsC ; arrows = arrowsC ; id = idC ; _∘_ = _∘C_ ; rightId = rightIdC ; leftId = leftIdC ; compositionAssociative = associativeC }} {record { objects = objectsD ; arrows = arrowsD ; id = idD ; _∘_ = _∘D_ ; rightId = rightIdD ; leftId = leftIdD ; compositionAssociative = associativeD }} record { onObj = onObjG ; onArrow = onArrowG ; mapId = mapIdG ; mapCompose = mapComposeG } record { onObj = onObjF ; onArrow = onArrowF ; mapId = mapIdF ; mapCompose = mapComposeF } {S} {T} {U} r s rewrite mapComposeF r s | mapComposeG (onArrowF r) (onArrowF s) = refl\n\nidFunctor : {a b : _} (C : Category {a} {b}) → Functor C C\nFunctor.onObj (idFunctor C) = λ x → x\nFunctor.onArrow (idFunctor C) = λ f → f\nFunctor.mapId (idFunctor C) = refl\nFunctor.mapCompose (idFunctor C) = λ f g → refl\n", "meta": {"hexsha": "1c159f3b42974f373c687e0c1e1eec0fc6eb32f2", "size": 2489, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Functor/Lemmas.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Categories/Functor/Lemmas.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Categories/Functor/Lemmas.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 113.1363636364, "max_line_length": 756, "alphanum_fraction": 0.6532744074, "num_tokens": 871, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835493924954, "lm_q2_score": 0.7549149978955811, "lm_q1q2_score": 0.6307190619314283}} {"text": "open import Algebra using (CommutativeRing)\n\nmodule Algebra.Module.Vec.Recursive {r ℓ} {CR : CommutativeRing r ℓ} where\n\nopen CommutativeRing CR\n\nopen import Algebra.Module using (Module)\nopen import Data.Vec.Recursive\nopen import Data.Product using (_×_; _,_)\nopen import Data.Product.Relation.Binary.Pointwise.NonDependent\nopen import Relation.Binary using (Rel)\nopen import Data.Nat using (zero; suc; ℕ)\nopen import Data.Unit.Polymorphic using (⊤)\nopen import Assume using (assume)\n\n\n_^ᴹ_ : ∀ {m ℓm} → Module CR m ℓm → ℕ → Module CR m ℓm\nM ^ᴹ n =\n record\n { Carrierᴹ = Carrierᴹ ^ n\n ; _≈ᴹ_ = pointwise _≈ᴹ_\n ; _+ᴹ_ = zipWith _+ᴹ_ n\n ; _*ₗ_ = λ s → map (_*ₗ_ s) n\n ; _*ᵣ_ = λ v s → map (λ x → x *ᵣ s) n v\n ; 0ᴹ = replicate n 0ᴹ\n ; -ᴹ_ = map (-ᴹ_) n\n ; isModule = assume\n }\n where\n open Module M\n open import Data.Unit.Polymorphic\n\n pointwise : ∀ {a ℓ n} {A : Set a} (~ : Rel A ℓ) → Rel (A ^ n) ℓ\n pointwise {n = ℕ.zero} ~ .tt .tt = ⊤\n pointwise {n = suc ℕ.zero} ~ x y = ~ x y\n pointwise {n = 2+ n} ~ (x , xs) (y , ys) = ~ x y × pointwise ~ xs ys", "meta": {"hexsha": "eda478ef0947537d89959b3e05158913d11a22a8", "size": 1076, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Algebra/Module/Vec/Recursive.agda", "max_stars_repo_name": "cspollard/reals", "max_stars_repo_head_hexsha": "a193aeebf1326f960975b19d3e31b46fddbbfaa2", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Algebra/Module/Vec/Recursive.agda", "max_issues_repo_name": "cspollard/reals", "max_issues_repo_head_hexsha": "a193aeebf1326f960975b19d3e31b46fddbbfaa2", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Algebra/Module/Vec/Recursive.agda", "max_forks_repo_name": "cspollard/reals", "max_forks_repo_head_hexsha": "a193aeebf1326f960975b19d3e31b46fddbbfaa2", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.8888888889, "max_line_length": 74, "alphanum_fraction": 0.6319702602, "num_tokens": 425, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009480320035, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.6306463564413737}} {"text": "------------------------------------------------------------------------\n-- Properties related to Fin, and operations making use of these\n-- properties (or other properties not available in Data.Fin)\n------------------------------------------------------------------------\n\nmodule Data.Fin.Props where\n\nopen import Data.Fin\nopen import Data.Nat as N\n using (ℕ; zero; suc; s≤s; z≤n)\n renaming (_≤_ to _ℕ≤_; _<_ to _ℕ<_; _+_ to _ℕ+_)\nopen N.≤-Reasoning\nimport Data.Nat.Properties as N\nopen import Data.Function\nopen import Relation.Nullary\nopen import Relation.Unary\nopen import Relation.Binary\nopen import Relation.Binary.FunctionSetoid\nopen import Relation.Binary.PropositionalEquality as PropEq\n using (_≡_; refl; cong; subst)\nopen import Category.Functor\nopen import Category.Applicative\n\n------------------------------------------------------------------------\n-- Properties\n\nprivate\n drop-suc : ∀ {o} {m n : Fin o} →\n suc m ≡ (Fin (suc o) ∶ suc n) → m ≡ n\n drop-suc refl = refl\n\npreorder : ℕ → Preorder\npreorder n = PropEq.preorder (Fin n)\n\nsetoid : ℕ → Setoid\nsetoid n = PropEq.setoid (Fin n)\n\nstrictTotalOrder : ℕ → StrictTotalOrder\nstrictTotalOrder n = record\n { carrier = Fin n\n ; _≈_ = _≡_\n ; _<_ = _<_\n ; isStrictTotalOrder = record\n { isEquivalence = PropEq.isEquivalence\n ; trans = N.<-trans\n ; compare = cmp\n ; <-resp-≈ = PropEq.resp₂ _<_\n }\n }\n where\n cmp : ∀ {n} → Trichotomous _≡_ (_<_ {n})\n cmp zero zero = tri≈ (λ()) refl (λ())\n cmp zero (suc j) = tri< (s≤s z≤n) (λ()) (λ())\n cmp (suc i) zero = tri> (λ()) (λ()) (s≤s z≤n)\n cmp (suc i) (suc j) with cmp i j\n ... | tri< lt ¬eq ¬gt = tri< (s≤s lt) (¬eq ∘ drop-suc) (¬gt ∘ N.≤-pred)\n ... | tri> ¬lt ¬eq gt = tri> (¬lt ∘ N.≤-pred) (¬eq ∘ drop-suc) (s≤s gt)\n ... | tri≈ ¬lt eq ¬gt = tri≈ (¬lt ∘ N.≤-pred) (cong suc eq) (¬gt ∘ N.≤-pred)\n\ndecSetoid : ℕ → DecSetoid\ndecSetoid n = StrictTotalOrder.decSetoid (strictTotalOrder n)\n\ninfix 4 _≟_\n\n_≟_ : {n : ℕ} → Decidable {Fin n} _≡_\n_≟_ {n} = DecSetoid._≟_ (decSetoid n)\n\nto-from : ∀ n → toℕ (fromℕ n) ≡ n\nto-from zero = refl\nto-from (suc n) = cong suc (to-from n)\n\nbounded : ∀ {n} (i : Fin n) → toℕ i ℕ< n\nbounded zero = s≤s z≤n\nbounded (suc i) = s≤s (bounded i)\n\nprop-toℕ-≤ : ∀ {n} (x : Fin n) → toℕ x ℕ≤ N.pred n\nprop-toℕ-≤ zero = z≤n\nprop-toℕ-≤ (suc {n = zero} ())\nprop-toℕ-≤ (suc {n = suc n} i) = s≤s (prop-toℕ-≤ i)\n\nnℕ-ℕi≤n : ∀ n i → n ℕ-ℕ i ℕ≤ n\nnℕ-ℕi≤n n zero = begin n ∎\nnℕ-ℕi≤n zero (suc ())\nnℕ-ℕi≤n (suc n) (suc i) = begin\n n ℕ-ℕ i ≤⟨ nℕ-ℕi≤n n i ⟩\n n ≤⟨ N.n≤1+n n ⟩\n suc n ∎\n\ninject-lemma : ∀ {n} {i : Fin n} (j : Fin′ i) →\n toℕ (inject j) ≡ toℕ j\ninject-lemma {i = zero} ()\ninject-lemma {i = suc i} zero = refl\ninject-lemma {i = suc i} (suc j) = cong suc (inject-lemma j)\n\ninject+-lemma : ∀ m k → m ≡ toℕ (inject+ k (fromℕ m))\ninject+-lemma zero k = refl\ninject+-lemma (suc m) k = cong suc (inject+-lemma m k)\n\ninject₁-lemma : ∀ {m} (i : Fin m) → toℕ (inject₁ i) ≡ toℕ i\ninject₁-lemma zero = refl\ninject₁-lemma (suc i) = cong suc (inject₁-lemma i)\n\ninject≤-lemma : ∀ {m n} (i : Fin m) (le : m ℕ≤ n) →\n toℕ (inject≤ i le) ≡ toℕ i\ninject≤-lemma zero (N.s≤s le) = refl\ninject≤-lemma (suc i) (N.s≤s le) = cong suc (inject≤-lemma i le)\n\n≺⇒<′ : _≺_ ⇒ N._<′_\n≺⇒<′ (n ≻toℕ i) = N.≤⇒≤′ (bounded i)\n\n<′⇒≺ : N._<′_ ⇒ _≺_\n<′⇒≺ {n} N.≤′-refl = subst (λ i → i ≺ suc n) (to-from n)\n (suc n ≻toℕ fromℕ n)\n<′⇒≺ (N.≤′-step m≤′n) with <′⇒≺ m≤′n\n<′⇒≺ (N.≤′-step m≤′n) | n ≻toℕ i =\n subst (λ i → i ≺ suc n) (inject₁-lemma i) (suc n ≻toℕ (inject₁ i))\n\n------------------------------------------------------------------------\n-- Operations\n\ninfixl 6 _+′_\n\n_+′_ : ∀ {m n} (i : Fin m) (j : Fin n) → Fin (N.pred m ℕ+ n)\ni +′ j = inject≤ (i + j) (N._+-mono_ (prop-toℕ-≤ i) ≤-refl)\n where open Poset N.poset renaming (refl to ≤-refl)\n\n-- reverse {n} \"i\" = \"n ∸ 1 ∸ i\".\n\nreverse : ∀ {n} → Fin n → Fin n\nreverse {zero} ()\nreverse {suc n} i = inject≤ (n ℕ- i) (N.n∸m≤n (toℕ i) (suc n))\n\n-- If there is an injection from a set to a finite set, then equality\n-- of the set can be decided.\n\neq? : ∀ {S n} →\n Injection S (PropEq.setoid (Fin n)) → Decidable (Setoid._≈_ S)\neq? inj x y with to ⟨$⟩ x ≟ to ⟨$⟩ y where open Injection inj\n... | yes tox≡toy = yes (Injection.injective inj tox≡toy)\n... | no tox≢toy = no (tox≢toy ∘ pres (Injection.to inj))\n\n-- Quantification over finite sets commutes with applicative functors.\n\nsequence : ∀ {F n} {P : Pred (Fin n)} → RawApplicative F →\n (∀ i → F (P i)) → F (∀ i → P i)\nsequence {F} RA = helper _ _\n where\n open RawApplicative RA\n\n helper : ∀ n (P : Pred (Fin n)) → (∀ i → F (P i)) → F (∀ i → P i)\n helper zero P ∀iPi = pure (λ())\n helper (suc n) P ∀iPi =\n combine <$> ∀iPi zero ⊛ helper n (λ n → P (suc n)) (∀iPi ∘ suc)\n where\n combine : P zero → (∀ i → P (suc i)) → ∀ i → P i\n combine z s zero = z\n combine z s (suc i) = s i\n\nprivate\n\n -- Included just to show that sequence above has an inverse (under\n -- an equivalence relation with two equivalence classes, one with\n -- all inhabited sets and the other with all uninhabited sets).\n\n sequence⁻¹ : ∀ {F A} {P : Pred A} → RawFunctor F →\n F (∀ i → P i) → ∀ i → F (P i)\n sequence⁻¹ RF F∀iPi i = (λ f → f i) <$> F∀iPi\n where open RawFunctor RF\n", "meta": {"hexsha": "66e3aa7c0e241ecaea85d180130d22237d25a798", "size": 5456, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Data/Fin/Props.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Data/Fin/Props.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Data/Fin/Props.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 32.2840236686, "max_line_length": 82, "alphanum_fraction": 0.5276759531, "num_tokens": 2168, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519527982093666, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.630593623784916}} {"text": " {-# OPTIONS --type-in-type #-}\n\nmodule IDescTT where\n\n--********************************************\n-- Prelude\n--********************************************\n\n-- Some preliminary stuffs, to avoid relying on the stdlib\n\n--****************\n-- Sigma and friends\n--****************\n\ndata Sigma (A : Set) (B : A -> Set) : Set where\n _,_ : (x : A) (y : B x) -> Sigma A B\n\n_*_ : (A : Set)(B : Set) -> Set\nA * B = Sigma A \\_ -> B\n\nfst : {A : Set}{B : A -> Set} -> Sigma A B -> A\nfst (a , _) = a\n\nsnd : {A : Set}{B : A -> Set} (p : Sigma A B) -> B (fst p)\nsnd (a , b) = b\n\ndata Zero : Set where\ndata Unit : Set where\n Void : Unit\n\n--****************\n-- Sum and friends\n--****************\n\ndata _+_ (A : Set)(B : Set) : Set where\n l : A -> A + B\n r : B -> A + B\n\n--****************\n-- Equality\n--****************\n\ndata _==_ {A : Set}(x : A) : A -> Set where\n refl : x == x\n\nsubst : forall {x y} -> x == y -> x -> y\nsubst refl x = x\n\ncong : {A B : Set}(f : A -> B){x y : A} -> x == y -> f x == f y\ncong f refl = refl\n\ncong2 : {A B C : Set}(f : A -> B -> C){x y : A}{z t : B} -> \n x == y -> z == t -> f x z == f y t\ncong2 f refl refl = refl\n\npostulate \n reflFun : {A B : Set}(f : A -> B)(g : A -> B)-> ((a : A) -> f a == g a) -> f == g \n\n--****************\n-- Meta-language\n--****************\n\n-- Note that we could define Nat, Bool, and the related operations in\n-- IDesc. But it is awful to code with them, in Agda.\n\ndata Nat : Set where\n ze : Nat\n su : Nat -> Nat\n\ndata Bool : Set where\n true : Bool\n false : Bool\n\nplus : Nat -> Nat -> Nat\nplus ze n' = n'\nplus (su n) n' = su (plus n n')\n\nle : Nat -> Nat -> Bool\nle ze _ = true\nle (su _) ze = false\nle (su n) (su n') = le n n'\n\n\n--********************************************\n-- Desc code\n--********************************************\n\ndata IDesc (I : Set) : Set where\n var : I -> IDesc I\n const : Set -> IDesc I\n prod : IDesc I -> IDesc I -> IDesc I\n sigma : (S : Set) -> (S -> IDesc I) -> IDesc I\n pi : (S : Set) -> (S -> IDesc I) -> IDesc I\n\n\n--********************************************\n-- Desc interpretation\n--********************************************\n\n[|_|] : {I : Set} -> IDesc I -> (I -> Set) -> Set\n[| var i |] P = P i\n[| const X |] P = X\n[| prod D D' |] P = [| D |] P * [| D' |] P\n[| sigma S T |] P = Sigma S (\\s -> [| T s |] P)\n[| pi S T |] P = (s : S) -> [| T s |] P\n\n--********************************************\n-- Fixpoint construction\n--********************************************\n\ndata IMu {I : Set}(R : I -> IDesc I)(i : I) : Set where\n con : [| R i |] (\\j -> IMu R j) -> IMu R i\n\n--********************************************\n-- Predicate: All\n--********************************************\n\nAll : {I : Set}(D : IDesc I)(P : I -> Set) -> [| D |] P -> IDesc (Sigma I P)\nAll (var i) P x = var (i , x)\nAll (const X) P x = const Unit\nAll (prod D D') P (d , d') = prod (All D P d) (All D' P d')\nAll (sigma S T) P (a , b) = All (T a) P b\nAll (pi S T) P f = pi S (\\s -> All (T s) P (f s))\n\nall : {I : Set}(D : IDesc I)(X : I -> Set)\n (R : Sigma I X -> Set)(P : (x : Sigma I X) -> R x) -> \n (xs : [| D |] X) -> [| All D X xs |] R\nall (var i) X R P x = P (i , x)\nall (const K) X R P k = Void\nall (prod D D') X R P (x , y) = ( all D X R P x , all D' X R P y )\nall (sigma S T) X R P (a , b) = all (T a) X R P b\nall (pi S T) X R P f = \\a -> all (T a) X R P (f a)\n\n--********************************************\n-- Elimination principle: induction\n--********************************************\n\n-- One would like to write the following:\n\n{-\nindI : {I : Set}\n (R : I -> IDesc I)\n (P : Sigma I (IMu R) -> Set)\n (m : (i : I)\n (xs : [| R i |] (IMu R))\n (hs : [| All (R i) (IMu R) xs |] P) ->\n P ( i , con xs)) ->\n (i : I)(x : IMu R i) -> P ( i , x )\nindI {I} R P m i (con xs) = m i xs (all (R i) (IMu R) P induct xs)\n where induct : (x : Sigma I (IMu R)) -> P x\n induct (i , xs) = indI R P m i xs\n-}\n\n-- But the termination-checker complains, so here we go\n-- inductive-recursive:\n\nmodule Elim {I : Set}\n (R : I -> IDesc I)\n (P : Sigma I (IMu R) -> Set)\n (m : (i : I)\n (xs : [| R i |] (IMu R))\n (hs : [| All (R i) (IMu R) xs |] P) ->\n P ( i , con xs ))\n where\n\n mutual\n indI : (i : I)(x : IMu R i) -> P (i , x)\n indI i (con xs) = m i xs (hyps (R i) xs)\n\n hyps : (D : IDesc I) -> \n (xs : [| D |] (IMu R)) -> \n [| All D (IMu R) xs |] P\n hyps (var i) x = indI i x\n hyps (const X) x = Void\n hyps (prod D D') (d , d') = hyps D d , hyps D' d'\n hyps (pi S R) f = \\ s -> hyps (R s) (f s)\n hyps (sigma S R) ( a , b ) = hyps (R a) b\n\n\nindI : {I : Set}\n (R : I -> IDesc I)\n (P : Sigma I (IMu R) -> Set)\n (m : (i : I)\n (xs : [| R i |] (IMu R))\n (hs : [| All (R i) (IMu R) xs |] P) ->\n P ( i , con xs)) ->\n (i : I)(x : IMu R i) -> P ( i , x )\nindI = Elim.indI\n\n--********************************************\n-- Examples\n--********************************************\n\n--****************\n-- Nat\n--****************\n\ndata NatConst : Set where\n Ze : NatConst\n Su : NatConst\n\nnatCases : NatConst -> IDesc Unit\nnatCases Ze = const Unit\nnatCases Suc = var Void\n\nNatD : Unit -> IDesc Unit\nNatD Void = sigma NatConst natCases\n\nNatd : Unit -> Set\nNatd x = IMu NatD x\n\nzed : Natd Void\nzed = con (Ze , Void)\n\nsud : Natd Void -> Natd Void\nsud n = con (Su , n)\n\n\n--****************\n-- Desc\n--****************\n\ndata DescDConst : Set where\n lvar : DescDConst\n lconst : DescDConst\n lprod : DescDConst\n lpi : DescDConst\n lsigma : DescDConst\n\ndescDChoice : Set -> DescDConst -> IDesc Unit\ndescDChoice I lvar = const I\ndescDChoice _ lconst = const Set\ndescDChoice _ lprod = prod (var Void) (var Void)\ndescDChoice _ lpi = sigma Set (\\S -> pi S (\\s -> var Void))\ndescDChoice _ lsigma = sigma Set (\\S -> pi S (\\s -> var Void))\n\ndescD : (I : Set) -> IDesc Unit\ndescD I = sigma DescDConst (descDChoice I)\n\nIDescl0 : (I : Set) -> Unit -> Set\nIDescl0 I = IMu (\\_ -> descD I) \n\nIDescl : (I : Set) -> Set\nIDescl I = IDescl0 I _\n\nvarl : {I : Set}(i : I) -> IDescl I\nvarl i = con (lvar , i)\n\nconstl : {I : Set}(X : Set) -> IDescl I\nconstl X = con (lconst , X)\n\nprodl : {I : Set}(D D' : IDescl I) -> IDescl I\nprodl D D' = con (lprod , (D , D'))\n\npil : {I : Set}(S : Set)(T : S -> IDescl I) -> IDescl I\npil S T = con (lpi , ( S , T))\n\nsigmal : {I : Set}(S : Set)(T : S -> IDescl I) -> IDescl I\nsigmal S T = con (lsigma , ( S , T))\n\n--****************\n-- Vec (constraints)\n--****************\n\ndata VecConst : Set where\n Vnil : VecConst\n Vcons : VecConst\n\nvecDChoice : Set -> Nat -> VecConst -> IDesc Nat\nvecDChoice X n Vnil = const (n == ze)\nvecDChoice X n Vcons = sigma Nat (\\m -> prod (var m) (const (n == su m)))\n\nvecD : Set -> Nat -> IDesc Nat\nvecD X n = sigma VecConst (vecDChoice X n)\n\nvec : Set -> Nat -> Set\nvec X n = IMu (vecD X) n\n\n--****************\n-- Vec (de-tagged, forced)\n--****************\n\ndata VecConst2 : Nat -> Set where\n Vnil : VecConst2 ze\n Vcons : {n : Nat} -> VecConst2 (su n)\n\nvecDChoice2 : Set -> (n : Nat) -> VecConst2 n -> IDesc Nat\nvecDChoice2 X ze Vnil = const Unit\nvecDChoice2 X (su n) Vcons = prod (const X) (var n)\n\nvecD2 : Set -> Nat -> IDesc Nat\nvecD2 X n = sigma (VecConst2 n) (vecDChoice2 X n)\n\nvec2 : Set -> Nat -> Set\nvec2 X n = IMu (vecD2 X) n\n\n--****************\n-- Fin (de-tagged)\n--****************\n\ndata FinConst : Nat -> Set where\n Fz : {n : Nat} -> FinConst (su n)\n Fs : {n : Nat} -> FinConst (su n)\n\nfinDChoice : (n : Nat) -> FinConst n -> IDesc Nat\nfinDChoice ze ()\nfinDChoice (su n) Fz = const Unit\nfinDChoice (su n) Fs = var n\n\nfinD : Nat -> IDesc Nat\nfinD n = sigma (FinConst n) (finDChoice n) \n\nfin : Nat -> Set\nfin n = IMu finD n\n\n--********************************************\n-- Enumerations (hard-coded)\n--********************************************\n\n-- Unlike in Desc.agda, we don't carry the levitation of finite sets\n-- here. We hard-code them and manipulate with standard Agda\n-- machinery. Both presentation are isomorph but, in Agda, the coded\n-- one quickly gets unusable.\n\ndata EnumU : Set where\n nilE : EnumU\n consE : EnumU -> EnumU\n\ndata EnumT : (e : EnumU) -> Set where\n EZe : {e : EnumU} -> EnumT (consE e)\n ESu : {e : EnumU} -> EnumT e -> EnumT (consE e)\n\nspi : (e : EnumU)(P : EnumT e -> Set) -> Set\nspi nilE P = Unit\nspi (consE e) P = P EZe * spi e (\\e -> P (ESu e))\n\nswitch : (e : EnumU)(P : EnumT e -> Set)(b : spi e P)(x : EnumT e) -> P x\nswitch nilE P b ()\nswitch (consE e) P b EZe = fst b\nswitch (consE e) P b (ESu n) = switch e (\\e -> P (ESu e)) (snd b) n\n\n_++_ : EnumU -> EnumU -> EnumU\nnilE ++ e' = e'\n(consE e) ++ e' = consE (e ++ e')\n\n-- A special switch, for tagged descriptions. Switching on a\n-- concatenation of finite sets:\nsswitch : (e : EnumU)(e' : EnumU)(P : Set)\n (b : spi e (\\_ -> P))(b' : spi e' (\\_ -> P))(x : EnumT (e ++ e')) -> P\nsswitch nilE nilE P b b' ()\nsswitch nilE (consE e') P b b' EZe = fst b'\nsswitch nilE (consE e') P b b' (ESu n) = sswitch nilE e' P b (snd b') n\nsswitch (consE e) e' P b b' EZe = fst b\nsswitch (consE e) e' P b b' (ESu n) = sswitch e e' P (snd b) b' n\n\n--********************************************\n-- Tagged indexed description\n--********************************************\n\nFixMenu : Set -> Set\nFixMenu I = Sigma EnumU (\\e -> (i : I) -> spi e (\\_ -> IDesc I))\n\nSensitiveMenu : Set -> Set\nSensitiveMenu I = Sigma (I -> EnumU) (\\F -> (i : I) -> spi (F i) (\\_ -> IDesc I))\n\nTagIDesc : Set -> Set\nTagIDesc I = FixMenu I * SensitiveMenu I\n\ntoIDesc : (I : Set) -> TagIDesc I -> (I -> IDesc I)\ntoIDesc I ((E , ED) , (F , FD)) i = sigma (EnumT (E ++ F i)) \n (\\x -> sswitch E (F i) (IDesc I) (ED i) (FD i) x)\n\n--********************************************\n-- Catamorphism\n--********************************************\n\ncata : (I : Set)\n (R : I -> IDesc I)\n (T : I -> Set) ->\n ((i : I) -> [| R i |] T -> T i) ->\n (i : I) -> IMu R i -> T i\ncata I R T phi i x = indI R (\\it -> T (fst it)) (\\i xs ms -> phi i (replace (R i) T xs ms)) i x\n where replace : (D : IDesc I)(T : I -> Set)\n (xs : [| D |] (IMu R))\n (ms : [| All D (IMu R) xs |] (\\it -> T (fst it))) -> \n [| D |] T\n replace (var i) T x y = y\n replace (const Z) T z z' = z\n replace (prod D D') T (x , x') (y , y') = replace D T x y , replace D' T x' y'\n replace (sigma A B) T (a , b) t = a , replace (B a) T b t\n replace (pi A B) T f t = \\s -> replace (B s) T (f s) (t s)\n\n--********************************************\n-- Hutton's razor\n--********************************************\n\n--********************************\n-- Types code\n--********************************\n\ndata Type : Set where\n nat : Type\n bool : Type\n pair : Type -> Type -> Type\n\n--********************************\n-- Typed expressions\n--********************************\n\n\nVal : Type -> Set\nVal nat = Nat\nVal bool = Bool\nVal (pair x y) = (Val x) * (Val y)\n\n\n-- Fix menu:\nexprFixMenu : FixMenu Type\nexprFixMenu = ( consE (consE nilE) , \n \\ty -> (const (Val ty), -- Val t\n (prod (var bool) (prod (var ty) (var ty)), -- if b then t1 else t2\n Void)))\n\n-- Indexed menu:\nchoiceMenu : Type -> EnumU\nchoiceMenu nat = consE nilE\nchoiceMenu bool = consE nilE\nchoiceMenu (pair x y) = nilE\n\nchoiceDessert : (ty : Type) -> spi (choiceMenu ty) (\\ _ -> IDesc Type)\nchoiceDessert nat = (prod (var nat) (var nat) , Void)\nchoiceDessert bool = (prod (var nat) (var nat) , Void )\nchoiceDessert (pair x y) = Void\n\nexprSensitiveMenu : SensitiveMenu Type\nexprSensitiveMenu = ( choiceMenu , choiceDessert )\n\n\n-- Expression:\nexpr : TagIDesc Type\nexpr = exprFixMenu , exprSensitiveMenu\n\nexprIDesc : TagIDesc Type -> (Type -> IDesc Type)\nexprIDesc D = toIDesc Type D\n\n\n--********************************\n-- Closed terms\n--********************************\n\ncloseTerm : Type -> IDesc Type\ncloseTerm = exprIDesc expr\n\n\n--********************************\n-- Closed term evaluation\n--********************************\n\neval : {ty : Type} -> IMu closeTerm ty -> Val ty\neval {ty} term = cata Type closeTerm Val evalOneStep ty term\n where evalOneStep : (ty : Type) -> [| closeTerm ty |] Val -> Val ty\n evalOneStep _ (EZe , t) = t\n evalOneStep _ ((ESu EZe) , (true , ( x , _))) = x\n evalOneStep _ ((ESu EZe) , (false , ( _ , y ))) = y\n evalOneStep nat ((ESu (ESu EZe)) , (x , y)) = plus x y\n evalOneStep nat ((ESu (ESu (ESu ()))) , t) \n evalOneStep bool ((ESu (ESu EZe)) , (x , y) ) = le x y\n evalOneStep bool ((ESu (ESu (ESu ()))) , _) \n evalOneStep (pair x y) (ESu (ESu ()) , _)\n\n--********************************************\n-- Free monad construction\n--********************************************\n\n_**_ : {I : Set} (R : TagIDesc I)(X : I -> Set) -> TagIDesc I\n((E , ED) , FFD) ** X = ((( consE E , \\ i -> ( const (X i) , ED i ))) , FFD) \n\n\n--********************************************\n-- Substitution\n--********************************************\n\napply : {I : Set}\n (R : TagIDesc I)(X Y : I -> Set) ->\n ((i : I) -> X i -> IMu (toIDesc I (R ** Y)) i) ->\n (i : I) -> \n [| toIDesc I (R ** X) i |] (IMu (toIDesc I (R ** Y))) ->\n IMu (toIDesc I (R ** Y)) i\napply (( E , ED) , (F , FD)) X Y sig i (EZe , x) = sig i x\napply (( E , ED) , (F , FD)) X Y sig i (ESu n , t) = con (ESu n , t)\n\nsubstI : {I : Set} (X Y : I -> Set)(R : TagIDesc I)\n (sigma : (i : I) -> X i -> IMu (toIDesc I (R ** Y)) i)\n (i : I)(D : IMu (toIDesc I (R ** X)) i) ->\n IMu (toIDesc I (R ** Y)) i\nsubstI {I} X Y R sig i term = cata I (toIDesc I (R ** X)) (IMu (toIDesc I (R ** Y))) (apply R X Y sig) i term \n\n\n--********************************************\n-- Hutton's razor is free monad\n--********************************************\n\nEmpty : Type -> Set\nEmpty _ = Zero\n\ncloseTerm' : Type -> IDesc Type\ncloseTerm' = toIDesc Type (expr ** Empty)\n\nupdate : {ty : Type} -> IMu closeTerm ty -> IMu closeTerm' ty\nupdate {ty} tm = cata Type closeTerm (IMu closeTerm') (\\ _ tagTm -> con (ESu (fst tagTm) , (snd tagTm))) ty tm\n\n\n--********************************\n-- Closed term' evaluation\n--********************************\n\neval' : {ty : Type} -> IMu closeTerm' ty -> Val ty\neval' {ty} term = cata Type closeTerm' Val evalOneStep ty term\n where evalOneStep : (ty : Type) -> [| closeTerm' ty |] Val -> Val ty\n evalOneStep _ (EZe , ())\n evalOneStep _ (ESu EZe , t) = t\n evalOneStep _ ((ESu (ESu EZe)) , (true , ( x , _))) = x\n evalOneStep _ ((ESu (ESu EZe)) , (false , ( _ , y ))) = y\n evalOneStep nat ((ESu (ESu (ESu EZe))) , (x , y)) = plus x y\n evalOneStep nat (((ESu (ESu (ESu (ESu ()))))) , t) \n evalOneStep bool ((ESu (ESu (ESu EZe))) , (x , y) ) = le x y\n evalOneStep bool ((ESu (ESu (ESu (ESu ())))) , _) \n evalOneStep (pair x y) (ESu (ESu (ESu ())) , _)\n\n\n--********************************\n-- Open terms\n--********************************\n\n-- A context is a snoc-list of types\n-- put otherwise, a context is a type telescope\ndata Context : Set where\n [] : Context\n _,_ : Context -> Type -> Context\n\n-- The environment realizes the context, having a value for each type\nEnv : Context -> Set\nEnv [] = Unit\nEnv (G , S) = Env G * Val S\n\n-- A typed-variable indexes into the context, obtaining a proof that\n-- what we get is what you want (WWGIWYW)\nVar : Context -> Type -> Set\nVar [] T = Zero\nVar (G , S) T = Var G T + (S == T)\n\n-- The lookup gets into the context to extract the value\nlookup : (G : Context) -> Env G -> (T : Type) -> Var G T -> Val T\nlookup [] _ T ()\nlookup (G , .T) (g , t) T (r refl) = t\nlookup (G , S) (g , t) T (l x) = lookup G g T x \n\n-- Open term: holes are either values or variables in a context\nopenTerm : Context -> Type -> IDesc Type\nopenTerm c = toIDesc Type (expr ** (Var c))\n\n--********************************\n-- Evaluation of open terms\n--********************************\n\n-- |discharge| is the local substitution expected by |substI|. It is\n-- just sugar around context lookup\ndischarge : (context : Context) ->\n Env context ->\n (ty : Type) ->\n Var context ty ->\n IMu closeTerm' ty\ndischarge ctxt env ty variable = con (ESu EZe , lookup ctxt env ty variable ) \n\n-- |substExpr| is the specialized |substI| to expressions. We get it\n-- generically from the free monad construction.\nsubstExpr : {ty : Type}\n (context : Context)\n (sigma : (ty : Type) ->\n Var context ty ->\n IMu closeTerm' ty) ->\n IMu (openTerm context) ty ->\n IMu closeTerm' ty\nsubstExpr {ty} c sig term = \n substI (Var c) Empty expr sig ty term\n\n-- By first doing substitution to close the term, we can use\n-- evaluation of closed terms, obtaining evaluation of open terms\n-- under a valid context.\nevalOpen : {ty : Type}(context : Context) ->\n Env context ->\n IMu (openTerm context) ty ->\n Val ty\nevalOpen ctxt env tm = eval' (substExpr ctxt (discharge ctxt env) tm)\n\n--********************************\n-- Tests\n--********************************\n\n-- Test context:\n-- V 0 :-> true, V 1 :-> 2, V 2 :-> ( false , 1 )\ntestContext : Context\ntestContext = (([] , bool) , nat) , pair bool nat\ntestEnv : Env testContext\ntestEnv = ((Void , true ) , su (su ze)) , (false , su ze) \n\n-- V 1\ntest1 : IMu (openTerm testContext) nat\ntest1 = con (EZe , ( l (r refl) ) )\n\ntestSubst1 : IMu closeTerm' nat\ntestSubst1 = substExpr testContext \n (discharge testContext testEnv)\n test1\n-- = 2\ntestEval1 : Val nat\ntestEval1 = evalOpen testContext testEnv test1\n\n-- add 1 (V 1)\ntest2 : IMu (openTerm testContext) nat\ntest2 = con (ESu (ESu (ESu EZe)) , (con (ESu EZe , su ze) , con ( EZe , l (r refl) )) )\n\ntestSubst2 : IMu closeTerm' nat\ntestSubst2 = substExpr testContext \n (discharge testContext testEnv)\n test2\n\n-- = 3\ntestEval2 : Val nat\ntestEval2 = evalOpen testContext testEnv test2\n\n\n-- if (V 0) then (V 1) else 0\ntest3 : IMu (openTerm testContext) nat\ntest3 = con (ESu (ESu EZe) , (con (EZe , l (l (r refl))) ,\n (con (EZe , l (r refl)) ,\n con (ESu EZe , ze))))\n\ntestSubst3 : IMu closeTerm' nat\ntestSubst3 = substExpr testContext \n (discharge testContext testEnv)\n test3\n\n-- = 2\ntestEval3 : Val nat\ntestEval3 = evalOpen testContext testEnv test3\n\n-- V 2\ntest4 : IMu (openTerm testContext) (pair bool nat)\ntest4 = con (EZe , r refl )\n\ntestSubst4 : IMu closeTerm' (pair bool nat)\ntestSubst4 = substExpr testContext \n (discharge testContext testEnv)\n test4\n-- = (false , 1)\ntestEval4 : Val (pair bool nat)\ntestEval4 = evalOpen testContext testEnv test4", "meta": {"hexsha": "0df2ad0ce5f4c3258ce0068bfd7fbce8a4192b4a", "size": 19277, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "models/IDescTT.agda", "max_stars_repo_name": "mietek/epigram", "max_stars_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 48, "max_stars_repo_stars_event_min_datetime": "2016-01-09T17:36:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-11T01:55:28.000Z", "max_issues_repo_path": "models/IDescTT.agda", "max_issues_repo_name": "mietek/epigram", "max_issues_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "models/IDescTT.agda", "max_forks_repo_name": "mietek/epigram", "max_forks_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2016-08-14T21:36:35.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-11T01:57:40.000Z", "avg_line_length": 29.2963525836, "max_line_length": 110, "alphanum_fraction": 0.468797012, "num_tokens": 6242, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519527944504228, "lm_q2_score": 0.7401743563075446, "lm_q1q2_score": 0.6305936112367555}} {"text": "------------------------------------------------------------------------\n-- Up-to techniques for strong bisimilarity\n------------------------------------------------------------------------\n\n{-# OPTIONS --sized-types #-}\n\nopen import Labelled-transition-system\n\nmodule Bisimilarity.Up-to {ℓ} (lts : LTS ℓ) where\n\nopen import Equality.Propositional\nopen import Logical-equivalence using (_⇔_)\nopen import Prelude\nopen import Prelude.Size\n\nopen import Bisimilarity lts\nimport Bisimilarity.Equational-reasoning-instances\nopen import Equational-reasoning\nopen import Relation\nimport Up-to\n\nopen LTS lts\n\n------------------------------------------------------------------------\n-- The general up-to machinery, instantiated with the StepC container\n\nopen Up-to StepC public\n\n------------------------------------------------------------------------\n-- Some examples (based on techniques presented by Pous and Sangiorgi\n-- in \"Enhancements of the bisimulation proof method\")\n\n-- Up to bisimilarity.\n\nUp-to-bisimilarity : Trans₂ ℓ Proc\nUp-to-bisimilarity R = Bisimilarity ∞ ⊙ R ⊙ Bisimilarity ∞\n\n-- Up to bisimilarity is monotone.\n\nup-to-bisimilarity-monotone : Monotone Up-to-bisimilarity\nup-to-bisimilarity-monotone R⊆S =\n Σ-map id (Σ-map id (Σ-map id (Σ-map R⊆S id)))\n\n-- Up to bisimilarity is size-preserving.\n\nup-to-bisimilarity-size-preserving : Size-preserving Up-to-bisimilarity\nup-to-bisimilarity-size-preserving\n R⊆∼i {p₁ , p₄} (p₂ , p₁∼p₂ , p₃ , p₂Rp₃ , p₃∼p₄) =\n p₁ ∼⟨ p₁∼p₂ ⟩\n p₂ ∼⟨ R⊆∼i p₂Rp₃ ⟩\n p₃ ∼⟨ p₃∼p₄ ⟩■\n p₄\n\n-- Up to union with bisimilarity.\n\nUp-to-∪∼ : Trans₂ ℓ Proc\nUp-to-∪∼ R = R ∪ Bisimilarity ∞\n\n-- Up to union with bisimilarity is monotone.\n\nup-to-∪∼-monotone : Monotone Up-to-∪∼\nup-to-∪∼-monotone R⊆S = ⊎-map R⊆S id\n\n-- Up to union with bisimilarity is size-preserving.\n--\n-- The proof is similar to parts of the proof of Corollary 6.3.15 from\n-- Pous and Sangiorgi's \"Enhancements of the bisimulation proof\n-- method\".\n\nup-to-∪∼-size-preserving : Size-preserving Up-to-∪∼\nup-to-∪∼-size-preserving =\n ∪-closure\n id-size-preserving\n (const-size-preserving (Bisimilarity ∞ ⊆⟨ id ⟩∎\n Bisimilarity ∞ ∎))\n\n-- Up to transitive closure.\n\nUp-to-* : Trans₂ ℓ Proc\nUp-to-* R = R *\n\n-- Up to transitive closure is monotone.\n\nup-to-*-monotone : Monotone Up-to-*\nup-to-*-monotone R⊆S = Σ-map id (λ {n} → ^^-mono R⊆S n)\n where\n ^^-mono : ∀ {R S} → R ⊆ S →\n ∀ n → R ^^ n ⊆ S ^^ n\n ^^-mono R⊆S zero = id\n ^^-mono R⊆S (suc n) = Σ-map id (Σ-map R⊆S (^^-mono R⊆S n))\n\n-- Up to transitive closure is size-preserving.\n\nup-to-*-size-preserving : Size-preserving Up-to-*\nup-to-*-size-preserving =\n _⇔_.from (monotone→⇔ up-to-*-monotone) drop-*\n where\n drop-* : ∀ {i} → Bisimilarity i * ⊆ Bisimilarity i\n drop-* {x = p , .p} (zero , refl) = p ■\n drop-* {x = p , r} (suc n , q , p∼q , ∼ⁿqr) =\n p ∼⟨ p∼q ⟩\n q ∼⟨ drop-* (n , ∼ⁿqr) ⟩■\n r\n", "meta": {"hexsha": "6b7aeb0559c91ffa6272d6f474580af28ba06de2", "size": 2929, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Bisimilarity/Up-to.agda", "max_stars_repo_name": "nad/up-to", "max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Bisimilarity/Up-to.agda", "max_issues_repo_name": "nad/up-to", "max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Bisimilarity/Up-to.agda", "max_forks_repo_name": "nad/up-to", "max_forks_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.1634615385, "max_line_length": 72, "alphanum_fraction": 0.5851826562, "num_tokens": 1020, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8774767874818408, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.6305499043836719}} {"text": "module Hwequivalence where\n\nopen import Relation.Binary.PropositionalEquality\nopen import Data.Bool\n\n-- A 1-bit adder\nbit-adder-spec : Bool → Bool → Bool → Bool\nbit-adder-spec A B C = X ∧ Y\n where\n X : Bool\n X = (A ∧ not B ∧ not C)\n ∨\n (not A ∧ B ∧ not C)\n ∨\n (not A ∧ not B ∧ C)\n ∨\n (A ∧ B ∧ C)\n\n Y : Bool\n Y = (A ∧ B)\n ∨\n (A ∧ C)\n ∨\n (B ∧ C)\n\nbit-adder-imp : Bool → Bool → Bool → Bool\nbit-adder-imp A B C = X ∧ Y\n where\n u : Bool\n u = (A ∧ not B)\n ∨\n (not A ∧ B)\n v : Bool\n v = u ∧ C\n w : Bool\n w = A ∧ B\n X : Bool\n X = (u ∧ not C)\n ∨\n (not u ∧ C)\n Y : Bool\n Y = (w ∨ v)\n\ndata _≃_ {A : Set} (f : A → A) (g : A → A) : Set where\n f≃g : ((x y : A) → (x ≡ y) → (f x ≡ g y)) → f ≃ g\n\n-- Prove equivalence of specification and implementation using\n-- ≃ data type.\nequivalence-spec-imp : ∀ (A B : Bool) → (bit-adder-spec A B) ≃ (bit-adder-imp A B)\nequivalence-spec-imp A B = f≃g (λ x y x₁ → prove x y x₁)\n where\n pr1 : (x y : Bool) → (bit-adder-spec x y true) ≡ (bit-adder-imp x y true)\n pr1 true true = refl\n pr1 true false = refl\n pr1 false true = refl\n pr1 false false = refl\n\n\n pr2 : (x y : Bool) → (bit-adder-spec x y false) ≡ (bit-adder-imp x y false)\n pr2 true true = refl\n pr2 true false = refl\n pr2 false true = refl\n pr2 false false = refl\n\n prove : (x y : Bool) → (p : x ≡ y) → (bit-adder-spec A B x) ≡ (bit-adder-imp A B y)\n prove true .true refl = pr1 A B\n prove false .false refl = pr2 A B\n", "meta": {"hexsha": "9cba825deca146ad4552002798019acf058cfab8", "size": 1500, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "HWequivalence.agda", "max_stars_repo_name": "amal029/agda-tutorial-dybjer", "max_stars_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:52:30.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-08T12:52:30.000Z", "max_issues_repo_path": "HWequivalence.agda", "max_issues_repo_name": "amal029/agda-tutorial-dybjer", "max_issues_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HWequivalence.agda", "max_forks_repo_name": "amal029/agda-tutorial-dybjer", "max_forks_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.0588235294, "max_line_length": 85, "alphanum_fraction": 0.5306666667, "num_tokens": 596, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.877476793890012, "lm_q2_score": 0.7185943925708562, "lm_q1q2_score": 0.6305499037004155}} {"text": "{-# OPTIONS --injective-type-constructors #-}\n\nmodule InjectiveTypeConstructors where\n\ndata D (A : Set) : Set where\n\ndata _==_ (A : Set) : Set → Set where\n refl : A == A\n\nD' = D\n\ninjD : ∀ {A B} → D A == D' B → A == B\ninjD refl = refl\n", "meta": {"hexsha": "8f001b68e6846adf85b916abd2d607d35dbe9e1e", "size": 235, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/InjectiveTypeConstructors.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/InjectiveTypeConstructors.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/InjectiveTypeConstructors.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 16.7857142857, "max_line_length": 45, "alphanum_fraction": 0.5872340426, "num_tokens": 84, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.877476793890012, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.630549898412283}} {"text": "------------------------------------------------------------------------------\n-- The Booleans properties\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule LTC-PCF.Data.Bool.Properties where\n\nopen import LTC-PCF.Base\nopen import LTC-PCF.Data.Bool\nopen import LTC-PCF.Data.Nat.Inequalities\nopen import LTC-PCF.Data.Nat.Inequalities.Properties\nopen import LTC-PCF.Data.Nat.Type\n\n------------------------------------------------------------------------------\n-- Congruence properties\n\nnotCong : ∀ {a b} → a ≡ b → not a ≡ not b\nnotCong refl = refl\n\n------------------------------------------------------------------------------\n-- Basic properties\n\nt&&x≡x : ∀ b → true && b ≡ b\nt&&x≡x b = if-true b\n\nf&&x≡f : ∀ b → false && b ≡ false\nf&&x≡f b = if-false false\n\nnot-t : not true ≡ false\nnot-t = if-true false\n\nnot-f : not false ≡ true\nnot-f = if-false true\n\n&&-Bool : ∀ {a b} → Bool a → Bool b → Bool (a && b)\n&&-Bool {b = b} btrue Bb = subst Bool (sym (t&&x≡x b)) Bb\n&&-Bool {b = b} bfalse Bb = subst Bool (sym (f&&x≡f b)) bfalse\n\nnot-Bool : ∀ {b} → Bool b → Bool (not b)\nnot-Bool btrue = subst Bool (sym not-t) bfalse\nnot-Bool bfalse = subst Bool (sym not-f) btrue\n\n&&-comm : ∀ {a b} → Bool a → Bool b → a && b ≡ b && a\n&&-comm btrue btrue = refl\n&&-comm btrue bfalse = trans (t&&x≡x false) (sym (f&&x≡f true))\n&&-comm bfalse btrue = trans (f&&x≡f true) (sym (t&&x≡x false))\n&&-comm bfalse bfalse = refl\n\nx≢not-x : ∀ {b} → Bool b → b ≢ not b\nx≢not-x btrue h = t≢f (trans h not-t)\nx≢not-x bfalse h = t≢f (sym (trans h not-f))\n\nnot-x≢x : ∀ {b} → Bool b → not b ≢ b\nnot-x≢x Bb h = x≢not-x Bb (sym h)\n\nnot-involutive : ∀ {b} → Bool b → not (not b) ≡ b\nnot-involutive btrue = trans (notCong not-t) not-f\nnot-involutive bfalse = trans (notCong not-f) not-t\n\n------------------------------------------------------------------------------\n-- Properties with inequalities\n\nlt-Bool : ∀ {m n} → N m → N n → Bool (lt m n)\nlt-Bool nzero nzero = subst Bool (sym lt-00) bfalse\nlt-Bool nzero (nsucc {n} Nn) = subst Bool (sym (lt-0S n)) btrue\nlt-Bool (nsucc {m} Nm) nzero = subst Bool (sym (lt-S0 m)) bfalse\nlt-Bool (nsucc {m} Nm) (nsucc {n} Nn) = subst Bool (sym (lt-SS m n)) (lt-Bool Nm Nn)\n\nle-Bool : ∀ {m n} → N m → N n → Bool (le m n)\nle-Bool {n = n} nzero Nn = subst Bool (sym (lt-0S n)) btrue\nle-Bool (nsucc Nm) nzero = subst Bool (sym (Sx≰0 Nm)) bfalse\nle-Bool (nsucc {m} Nm) (nsucc {n} Nn) =\n subst Bool (sym (lt-SS m (succ₁ n))) (le-Bool Nm Nn)\n", "meta": {"hexsha": "60b31f9dd2d4333fd6ad21192b9925e2db998c50", "size": 2737, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/LTC-PCF/Data/Bool/Properties.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/LTC-PCF/Data/Bool/Properties.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/LTC-PCF/Data/Bool/Properties.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 35.0897435897, "max_line_length": 84, "alphanum_fraction": 0.4957983193, "num_tokens": 918, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321889812553, "lm_q2_score": 0.7826624840223698, "lm_q1q2_score": 0.6305380902364486}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Universal lifting of predicates over Vectors\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Vec.Functional.Relation.Unary.All where\n\nopen import Data.Fin.Base\nopen import Data.Fin.Properties\nopen import Data.Nat.Base\nopen import Data.Product using (_,_)\nopen import Data.Vec.Functional as VF hiding (map)\nopen import Level using (Level)\nopen import Relation.Unary\n\nprivate\n variable\n a p q ℓ : Level\n A : Set a\n\n------------------------------------------------------------------------\n-- Definition\n\nAll : Pred A ℓ → ∀ {n} → Vector A n → Set ℓ\nAll P xs = ∀ i → P (xs i)\n\n------------------------------------------------------------------------\n-- Operations\n\nmodule _ {P : Pred A p} {Q : Pred A q} where\n\n map : P ⊆ Q → ∀ {n} → All P {n = n} ⊆ All Q\n map p⊆q ps i = p⊆q (ps i)\n\n------------------------------------------------------------------------\n-- Properties of predicates preserved by All\n\nmodule _ {P : Pred A p} where\n\n all : Decidable P → ∀ {n} → Decidable (All P {n = n})\n all p? xs = all? λ i → p? (xs i)\n\n universal : Universal P → ∀ {n} → Universal (All P {n = n})\n universal uni xs i = uni (xs i)\n\n satisfiable : Satisfiable P → ∀ {n} → Satisfiable (All P {n = n})\n satisfiable (x , px) = (λ _ → x) , (λ _ → px)\n", "meta": {"hexsha": "7c6e418a6dd9374fffb258ceeb590f1b94dd0446", "size": 1425, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/Vec/Functional/Relation/Unary/All.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Data/Vec/Functional/Relation/Unary/All.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Data/Vec/Functional/Relation/Unary/All.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 27.9411764706, "max_line_length": 72, "alphanum_fraction": 0.4652631579, "num_tokens": 359, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8289388083214156, "lm_q2_score": 0.7606506526772884, "lm_q1q2_score": 0.6305328455792184}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Algebra.Structures.Bundles.Field\n\nmodule Algebra.Linear.Construct.Matrix\n {k ℓ} (K : Field k ℓ)\n where\n\nopen import Level using (_⊔_)\nopen import Data.Product hiding (map)\nopen import Data.Fin using (Fin; toℕ; fromℕ; _≤_)\nopen import Data.Fin.Properties using (¬Fin0)\nopen import Data.Nat hiding (_⊔_; _≤_) renaming (_+_ to _+ℕ_; _*_ to _*ℕ_)\nopen import Data.Nat.Properties using (1+n≢0)\n\nopen import Relation.Binary\nimport Data.Vec.Relation.Binary.Pointwise.Inductive as PW\nopen import Algebra.Linear.Core\n\nimport Data.Vec.Properties as VP\n\nopen import Algebra.Structures.Field.Utils K\n\nimport Algebra.Linear.Construct.Vector K as V\nopen V\n using (Vec; zipWith; replicate)\n renaming\n ( _+_ to _+v_\n ; _∙_ to _∙v_\n ; -_ to -v_\n )\n\nopen import Relation.Binary.PropositionalEquality as P\n using (_≡_; subst; subst-subst-sym; _≗_)\n renaming\n ( refl to ≡-refl\n ; sym to ≡-sym\n ; trans to ≡-trans\n )\n\nimport Algebra.Linear.Structures.VectorSpace as VS\n\nopen VS.VectorSpaceField K\n\nopen import Data.Nat.Properties\n using\n ( ≤-refl\n ; ≤-reflexive\n ; ≤-antisym\n ; n∸n≡0\n ; m+[n∸m]≡n\n ; m≤m+n\n ; suc-injective\n )\n renaming\n ( +-identityˡ to +ℕ-identityˡ\n ; +-identityʳ to +ℕ-identityʳ \n )\n\nMatrix : ℕ -> ℕ -> Set k\nMatrix n p = Vec (Vec K' p) n\n\nprivate\n M : ℕ -> ℕ -> Set k\n M = Matrix\n\n_≈ʰ_ : ∀ {n p n' p'} (A : M n p) (B : M n' p') → Set (k ⊔ ℓ)\n_≈ʰ_ = PW.Pointwise V._≈ʰ_\n\nmodule _ {n p} where\n setoid : Setoid k (k ⊔ ℓ)\n setoid = record\n { Carrier = M n p\n ; _≈_ = _≈ʰ_ {n} {p}\n ; isEquivalence = PW.isEquivalence (V.≈-isEquiv {p}) n\n }\n\n open Setoid setoid public\n renaming\n ( refl to ≈-refl\n ; sym to ≈-sym\n ; trans to ≈-trans\n ; reflexive to ≈-reflexive\n ; isEquivalence to ≈-isEquiv\n )\n\nimport Algebra.FunctionProperties as FP\n\ntabulate : ∀ {n p} -> (Fin n -> Fin p -> K') -> M n p\ntabulate f = V.tabulate λ i -> V.tabulate λ j -> f i j\n\ntabulate⁺ : ∀ {n p} {f g : Fin n -> Fin p -> K'}\n -> (∀ i j -> f i j ≈ᵏ g i j)\n -> tabulate f ≈ tabulate g\ntabulate⁺ {0} r = PW.[]\ntabulate⁺ {suc n} {p} {f} {g} r =\n (PW.tabulate⁺ (r Fin.zero)) PW.∷ tabulate⁺ {n} {p} λ i j → r (Fin.suc i) j\n\nfromVec : ∀ {n p} -> V.Vec K' (n *ℕ p) -> M n p\nfromVec {0} V.[] = V.[]\nfromVec {suc n} {p} xs =\n let (vp , vnp , _) = V.splitAt p xs\n in vp V.∷ fromVec {n} vnp\n\ntoVec : ∀ {n p} -> M n p -> V.Vec K' (n *ℕ p)\ntoVec {n} {p} = V.concat {m = p} {n = n}\n\nconcat∘fromVec : ∀ {n p} (v : V.Vec K' (n *ℕ p)) -> toVec {n} {p} (fromVec v) V.≈ v\nconcat∘fromVec {0} V.[] = PW.[]\nconcat∘fromVec {suc n} {p} v =\n let (vn , vnp , r) = V.splitAt p v\n in begin\n toVec {suc n} {p} (fromVec v)\n ≡⟨⟩\n vn V.++ toVec {n} {p} (fromVec vnp)\n ≈⟨ V.++-cong {p} {n *ℕ p} V.≈-refl (concat∘fromVec {n} {p} vnp) ⟩\n vn V.++ vnp\n ≈⟨ V.≈-sym (V.≈-reflexive r) ⟩\n v\n ∎\n where open import Relation.Binary.EqReasoning (V.setoid (suc n *ℕ p))\n\n_++_ : ∀ {n p q} -> M n p -> M n q -> M n (p +ℕ q)\n_++_ = zipWith V._++_\n\n_‡_ : ∀ {n m p} -> M n p -> M m p -> M (n +ℕ m) p\n_‡_ = V._++_\n\nlookup : ∀ {n p} -> M n p -> Fin n -> Fin p -> K'\nlookup A i j = V.lookup (V.lookup A i) j\n\n_⟪_,_⟫ : ∀ {n p} -> M n p -> Fin n -> Fin p -> K'\n_⟪_,_⟫ = lookup\n\nlookup-cong : ∀ {n p} {A B : M n p} (i : Fin n) (j : Fin p) -> A ≈ B -> (A ⟪ i , j ⟫) ≈ᵏ (B ⟪ i , j ⟫)\nlookup-cong i j rs = PW.lookup (PW.lookup rs i) j\n\ntabulate∘lookup : ∀ {n p} (A : M n p) → tabulate (lookup A) ≡ A\ntabulate∘lookup A =\n begin\n tabulate (lookup A)\n ≡⟨⟩\n V.tabulate (λ i -> V.tabulate λ j -> V.lookup (V.lookup A i) j)\n ≡⟨ VP.tabulate-cong (λ i → VP.tabulate∘lookup (V.lookup A i)) ⟩\n V.tabulate (λ i -> V.lookup A i)\n ≡⟨ VP.tabulate∘lookup A ⟩\n A\n ∎\n where open import Relation.Binary.PropositionalEquality as Eq\n open Eq.≡-Reasoning\n\nlookup∘tabulate : ∀ {n p} (f : Fin n -> Fin p -> K') (i : Fin n) (j : Fin p)\n -> lookup (tabulate f) i j ≡ f i j\nlookup∘tabulate {suc n} f i j =\n begin\n lookup (tabulate f) i j\n ≡⟨⟩\n V.lookup (V.lookup (V.tabulate λ i′ -> V.tabulate λ j′ -> f i′ j′) i) j\n ≡⟨ cong (λ u → V.lookup u j) (VP.lookup∘tabulate (λ i′ -> V.tabulate λ j′ -> f i′ j′) i) ⟩\n V.lookup (V.tabulate λ j′ -> f i j′) j\n ≡⟨ VP.lookup∘tabulate (λ j′ -> f i j′) j ⟩\n f i j\n ∎\n where open import Relation.Binary.PropositionalEquality as Eq\n open Eq.≡-Reasoning\n\ntabulate-cong-≡ : ∀ {n p} {f g : Fin n -> Fin p -> K'} -> (∀ i j -> f i j ≡ g i j) -> tabulate f ≡ tabulate g\ntabulate-cong-≡ {f = f} {g = g} r = VP.tabulate-cong (λ i → VP.tabulate-cong (λ j → r i j))\n\ntabulate-cong : ∀ {n p} {f g : Fin n -> Fin p -> K'} -> (∀ i j -> f i j ≈ᵏ g i j) -> tabulate f ≈ tabulate g\ntabulate-cong {f = f} {g = g} r = PW.tabulate⁺ (λ i → V.tabulate-cong (λ j → r i j))\n\ntranspose : ∀ {n p} -> M n p -> M p n\ntranspose A = tabulate λ i j -> A ⟪ j , i ⟫\n\n_ᵀ : ∀ {n p} -> M n p -> M p n\n_ᵀ = transpose\n\ntranspose-involutive : ∀ {n p} (A : M n p) -> ((A ᵀ) ᵀ) ≡ A\ntranspose-involutive A =\n begin\n ((A ᵀ)ᵀ)\n ≡⟨⟩\n (tabulate λ i j -> (tabulate λ i′ j′ -> A ⟪ j′ , i′ ⟫) ⟪ j , i ⟫)\n ≡⟨ tabulate-cong-≡ (λ i j → lookup∘tabulate (λ i′ j′ -> A ⟪ j′ , i′ ⟫) j i) ⟩\n (tabulate λ i j -> A ⟪ i , j ⟫)\n ≡⟨ tabulate∘lookup A ⟩\n A\n ∎\n where open import Relation.Binary.PropositionalEquality as Eq\n open Eq.≡-Reasoning\n\nmap : ∀ {n p} -> (K' -> K') -> M n p -> M n p\nmap f = V.map (V.map f)\n\nmapRows : ∀ {n p q} -> (V.Vec K' p -> V.Vec K' q) -> M n p -> M n q\nmapRows = V.map\n\nmapCols : ∀ {n m p} -> (V.Vec K' n -> V.Vec K' m) -> M n p -> M m p\nmapCols f A = (V.map f (A ᵀ)) ᵀ\n\nmap-cong : ∀ {n p} {f g : K' -> K'} -> f ≗ g -> map {n} {p} f ≗ map g\nmap-cong r = VP.map-cong (VP.map-cong r)\n\nmapRows-cong : ∀ {n p q} {f g : V.Vec K' p -> V.Vec K' q}\n -> f ≗ g -> mapRows {n} f ≗ mapRows g\nmapRows-cong = VP.map-cong\n\nmapCols-cong : ∀ {n m p} {f g : V.Vec K' n -> V.Vec K' m}\n -> f ≗ g -> mapCols {n} {m} {p} f ≗ mapCols g\nmapCols-cong r A = P.cong transpose (VP.map-cong r (transpose A))\n\nopen import Data.Nat.DivMod\n\n_+_ : ∀ {n p} -> FP.Op₂ (M n p)\n_+_ = zipWith V._+_\n\n_∙_ : ∀ {n p} -> ScalarMultiplication K' (M n p)\n_∙_ k = V.map (k V.∙_)\n\n-_ : ∀ {n p} -> FP.Op₁ (M n p)\n-_ = V.map V.-_\n\n0# : ∀ {n p} -> M n p\n0# = replicate V.0#\n\n+-cong : ∀ {n p} {A B C D : M n p} -> A ≈ B -> C ≈ D -> (A + C) ≈ (B + D)\n+-cong PW.[] PW.[] = PW.[]\n+-cong (r₁ PW.∷ rs₁) (r₂ PW.∷ rs₂) = V.+-cong r₁ r₂ PW.∷ +-cong rs₁ rs₂\n\n+-assoc : ∀ {n p} (A B C : M n p) -> ((A + B) + C) ≈ (A + (B + C))\n+-assoc V.[] V.[] V.[] = PW.[]\n+-assoc (u V.∷ us) (v V.∷ vs) (w V.∷ ws) =\n V.+-assoc u v w PW.∷ +-assoc us vs ws\n\n+-identityˡ : ∀ {n p} (A : M n p) -> (0# + A) ≈ A\n+-identityˡ V.[] = PW.[]\n+-identityˡ (u V.∷ us) = V.+-identityˡ u PW.∷ +-identityˡ us\n\n+-identityʳ : ∀ {n p} (A : M n p) -> (A + 0#) ≈ A\n+-identityʳ V.[] = PW.[]\n+-identityʳ (u V.∷ us) = V.+-identityʳ u PW.∷ +-identityʳ us\n\n+-identity : ∀ {n p} -> ((∀ (A : M n p) -> ((0# + A) ≈ A)) × (∀ (A : M n p) -> ((A + 0#) ≈ A)))\n+-identity = +-identityˡ , +-identityʳ\n\n+-comm : ∀ {n p} (A B : M n p) -> (A + B) ≈ (B + A)\n+-comm V.[] V.[] = PW.[]\n+-comm (u V.∷ us) (v V.∷ vs) = (V.+-comm u v) PW.∷ (+-comm us vs)\n\n*ᵏ-∙-compat : ∀ {n p} (a b : K') (A : M n p) -> ((a *ᵏ b) ∙ A) ≈ (a ∙ (b ∙ A))\n*ᵏ-∙-compat a b V.[] = PW.[]\n*ᵏ-∙-compat a b (u V.∷ us) = (V.*ᵏ-∙-compat a b u) PW.∷ (*ᵏ-∙-compat a b us)\n\n∙-+-distrib : ∀ {n p} (a : K') (A B : M n p) -> (a ∙ (A + B)) ≈ ((a ∙ A) + (a ∙ B))\n∙-+-distrib a V.[] V.[] = PW.[]\n∙-+-distrib a (u V.∷ us) (v V.∷ vs) = (V.∙-+-distrib a u v) PW.∷ (∙-+-distrib a us vs)\n\n∙-+ᵏ-distrib : ∀ {n p} (a b : K') (A : M n p) -> ((a +ᵏ b) ∙ A) ≈ ((a ∙ A) + (b ∙ A))\n∙-+ᵏ-distrib a b V.[] = PW.[]\n∙-+ᵏ-distrib a b (u V.∷ us) = (V.∙-+ᵏ-distrib a b u) PW.∷ (∙-+ᵏ-distrib a b us)\n\n∙-cong : ∀ {n p} {a b : K'} {A B : M n p} → a ≈ᵏ b -> A ≈ B -> (a ∙ A) ≈ (b ∙ B)\n∙-cong rᵏ PW.[] = PW.[]\n∙-cong rᵏ (r PW.∷ rs) = (V.∙-cong rᵏ r) PW.∷ (∙-cong rᵏ rs)\n\n∙-identity : ∀ {n p} (A : M n p) → (1ᵏ ∙ A) ≈ A\n∙-identity V.[] = PW.[]\n∙-identity (u V.∷ us) = (V.∙-identity u) PW.∷ (∙-identity us)\n\n∙-absorbˡ : ∀ {n p} (A : M n p) → (0ᵏ ∙ A) ≈ 0#\n∙-absorbˡ V.[] = PW.[]\n∙-absorbˡ (u V.∷ us) = (V.∙-absorbˡ u) PW.∷ (∙-absorbˡ us)\n\n-‿inverseˡ : ∀ {n p} (A : M n p) -> ((- A) + A) ≈ 0#\n-‿inverseˡ V.[] = PW.[]\n-‿inverseˡ (u V.∷ us) = (V.-‿inverseˡ u) PW.∷ (-‿inverseˡ us)\n\n-‿inverseʳ : ∀ {n p} (A : M n p) -> (A + (- A)) ≈ 0#\n-‿inverseʳ V.[] = PW.[]\n-‿inverseʳ (u V.∷ us) = (V.-‿inverseʳ u) PW.∷ (-‿inverseʳ us)\n\n-‿inverse : ∀ {n p} → (∀ (A : M n p) -> ((- A) + A) ≈ 0#) × (∀ (A : M n p) -> (A + (- A)) ≈ 0#)\n-‿inverse = -‿inverseˡ , -‿inverseʳ\n\n-‿cong : ∀ {n p} {A B : M n p} -> A ≈ B -> (- A) ≈ (- B)\n-‿cong PW.[] = PW.[]\n-‿cong (r PW.∷ rs) = (V.-‿cong r) PW.∷ (-‿cong rs)\n\nconcat-+ : ∀ {n p} (A B : M n p) -> V.concat (V.zipWith V._+_ A B) V.≈ (V.concat A) +v (V.concat B)\nconcat-+ {0} {p} V.[] V.[] =\n V.≈-trans (PW.concat⁺ {m = p} {p = 0} PW.[]) (V.≈-sym (V.+-identityˡ V.[]))\nconcat-+ {suc n} {p} (u V.∷ us) (v V.∷ vs) =\n begin\n V.concat (V.zipWith V._+_ (u V.∷ us) (v V.∷ vs))\n ≡⟨⟩\n (u V.+ v) V.++ V.concat (V.zipWith V._+_ us vs)\n ≈⟨ V.++-cong V.≈-refl (concat-+ {n} {p} us vs) ⟩\n (u V.+ v) V.++ (V.concat us V.+ V.concat vs)\n ≈⟨ V.≈-sym (V.+-++-distrib u (V.concat us) v (V.concat vs)) ⟩\n (V.concat (u V.∷ us)) V.+ (V.concat (v V.∷ vs))\n ∎\n where open import Relation.Binary.EqReasoning (V.setoid (p +ℕ n *ℕ p))\n\nconcat-0# : ∀ {n p} -> V.concat (0# {n} {p}) V.≈ (V.0# {n *ℕ p})\nconcat-0# {0} = PW.[]\nconcat-0# {suc n} {p} =\n begin\n V.concat (0# {suc n} {p})\n ≡⟨⟩\n V.0# {p} V.++ V.concat (0# {n} {p})\n ≈⟨ PW.++⁺ V.≈-refl (concat-0# {n} {p}) ⟩\n V.0# {p} V.++ V.0# {n *ℕ p}\n ≈⟨ V.0++0≈0 {p} {n *ℕ p} ⟩\n V.0# {p +ℕ n *ℕ p}\n ∎\n where open import Relation.Binary.EqReasoning (V.setoid (p +ℕ n *ℕ p))\n\nconcat-∙ : ∀ {n p} (c : K') (A : M n p) -> V.concat (c ∙ A) V.≈ (c V.∙ V.concat A)\nconcat-∙ {0} c V.[] = PW.[]\nconcat-∙ {suc n} {p} c (u V.∷ us) =\n begin\n V.concat ((c V.∙ u) V.∷ (c ∙ us))\n ≡⟨⟩\n (c V.∙ u) V.++ (V.concat (c ∙ us))\n ≈⟨ V.++-cong V.≈-refl (concat-∙ {n} {p} c us) ⟩\n (c V.∙ u) V.++ (c V.∙ V.concat us)\n ≈⟨ V.≈-sym (V.∙-++-distrib c u (V.concat us)) ⟩\n c V.∙ V.concat (u V.∷ us)\n ∎\n where open import Relation.Binary.EqReasoning (V.setoid (p +ℕ n *ℕ p))\n\nI : ∀ {n p} -> M n p\nI = tabulate δ\n\n_*_ : ∀ {n p q} -> M n p -> M p q -> M n q\nA * B = tabulate λ i j -> V.sum-tab λ k -> (A ⟪ i , k ⟫) *ᵏ (B ⟪ k , j ⟫)\n\n*-cong : ∀ {n p q} {A B : M n p} {C D : M p q}\n -> A ≈ B -> C ≈ D -> (A * C) ≈ (B * D)\n*-cong {n} {q = q} {A} {B} {C} {D} r₁ r₂ =\n begin\n A * C\n ≡⟨⟩\n tabulate (λ i j -> V.sum-tab λ k -> (A ⟪ i , k ⟫) *ᵏ (C ⟪ k , j ⟫))\n ≈⟨ tabulate⁺ (λ i j -> V.sum-tab-cong λ k → *ᵏ-cong (lookup-cong i k r₁) (lookup-cong k j r₂)) ⟩\n B * D\n ∎\n where open import Relation.Binary.EqReasoning (setoid {n} {q})\n\n*-assoc : ∀ {n p q r} (A : M n p) (B : M p q) (C : M q r)\n -> ((A * B) * C) ≈ (A * (B * C))\n*-assoc {n} {r = r} A B C = tabulate⁺ λ i j ->\n begin\n V.sum-tab (λ k′ -> ((A * B) ⟪ i , k′ ⟫) *ᵏ (C ⟪ k′ , j ⟫))\n ≈⟨ V.sum-tab-cong (λ k′ -> *ᵏ-cong (≈ᵏ-reflexive (lookup∘tabulate\n (λ i′ j′ -> V.sum-tab λ k -> (A ⟪ i′ , k ⟫) *ᵏ (B ⟪ k , j′ ⟫)) i k′)) ≈ᵏ-refl) ⟩\n V.sum-tab (λ k′ -> (V.sum-tab λ k -> (A ⟪ i , k ⟫) *ᵏ (B ⟪ k , k′ ⟫)) *ᵏ (C ⟪ k′ , j ⟫))\n ≈⟨ V.sum-tab-cong (λ k′ -> V.*ᵏ-sum-tab-distribʳ (C ⟪ k′ , j ⟫) λ k -> (A ⟪ i , k ⟫) *ᵏ (B ⟪ k , k′ ⟫)) ⟩\n V.sum-tab (λ k′ -> V.sum-tab λ k -> ((A ⟪ i , k ⟫) *ᵏ (B ⟪ k , k′ ⟫)) *ᵏ (C ⟪ k′ , j ⟫))\n ≈⟨ V.sum-tab-cong (λ k′ -> V.sum-tab-cong λ k -> *ᵏ-assoc (A ⟪ i , k ⟫) (B ⟪ k , k′ ⟫) (C ⟪ k′ , j ⟫)) ⟩\n V.sum-tab (λ k′ -> V.sum-tab λ k -> (A ⟪ i , k ⟫) *ᵏ ((B ⟪ k , k′ ⟫) *ᵏ (C ⟪ k′ , j ⟫)))\n ≈⟨ V.sum-tab-cong (λ k′ -> V.sum-tab-cong λ k -> *ᵏ-comm (A ⟪ i , k ⟫) ((B ⟪ k , k′ ⟫) *ᵏ (C ⟪ k′ , j ⟫))) ⟩\n V.sum-tab (λ k′ -> V.sum-tab λ k -> ((B ⟪ k , k′ ⟫) *ᵏ (C ⟪ k′ , j ⟫)) *ᵏ (A ⟪ i , k ⟫))\n ≈⟨ V.sum-tab-swap (λ k k′ -> (B ⟪ k , k′ ⟫) *ᵏ (C ⟪ k′ , j ⟫)) (λ k -> A ⟪ i , k ⟫) ⟩\n V.sum-tab (λ k -> V.sum-tab λ k′ -> ((B ⟪ k , k′ ⟫) *ᵏ (C ⟪ k′ , j ⟫)) *ᵏ (A ⟪ i , k ⟫))\n ≈⟨ V.sum-tab-cong (λ k -> ≈ᵏ-trans\n (≈ᵏ-sym (V.*ᵏ-sum-tab-distribʳ (A ⟪ i , k ⟫) λ k′ -> (B ⟪ k , k′ ⟫) *ᵏ (C ⟪ k′ , j ⟫)))\n (*ᵏ-comm (V.sum-tab λ k′ -> (B ⟪ k , k′ ⟫) *ᵏ (C ⟪ k′ , j ⟫)) (A ⟪ i , k ⟫))) ⟩\n V.sum-tab (λ k -> (A ⟪ i , k ⟫) *ᵏ V.sum-tab (λ k′ -> (B ⟪ k , k′ ⟫) *ᵏ (C ⟪ k′ , j ⟫)))\n ≈⟨ V.sum-tab-cong (λ k -> *ᵏ-cong ≈ᵏ-refl\n (≈ᵏ-sym (≈ᵏ-reflexive (lookup∘tabulate\n (λ i′ j′ -> V.sum-tab λ k′ -> (B ⟪ i′ , k′ ⟫) *ᵏ (C ⟪ k′ , j′ ⟫)) k j)))) ⟩\n V.sum-tab (λ k -> (A ⟪ i , k ⟫) *ᵏ ((B * C) ⟪ k , j ⟫))\n ∎\n where open import Relation.Binary.EqReasoning (Field.setoid K)\n\n*-identityˡ : ∀ {n p} (A : M n p) -> I * A ≈ A\n*-identityˡ {n} {p} A =\n begin\n I * A\n ≡⟨⟩\n tabulate (λ i j -> V.sum-tab λ k -> (I ⟪ i , k ⟫) *ᵏ (A ⟪ k , j ⟫))\n ≈⟨ tabulate-cong (λ i j -> V.sum-tab-cong {n} λ k -> *ᵏ-cong (≈ᵏ-reflexive (lookup∘tabulate δ i k)) ≈ᵏ-refl) ⟩\n tabulate (λ i j -> V.sum-tab λ k -> δ i k *ᵏ (A ⟪ k , j ⟫))\n ≈⟨ tabulate-cong (λ i j -> V.sum-tab-δ (λ k -> A ⟪ k , j ⟫) i) ⟩\n tabulate (λ i j -> A ⟪ i , j ⟫)\n ≡⟨ tabulate∘lookup A ⟩\n A\n ∎\n where open import Relation.Binary.EqReasoning (setoid {n} {p})\n\n*-identityʳ : ∀ {n p} (A : M n p) -> A * I ≈ A\n*-identityʳ {n} {p} A =\n begin\n A * I\n ≡⟨⟩\n tabulate (λ i j -> V.sum-tab λ k -> (A ⟪ i , k ⟫) *ᵏ (I ⟪ k , j ⟫))\n ≈⟨ tabulate-cong (λ i j -> V.sum-tab-cong {p} λ k -> *ᵏ-cong ≈ᵏ-refl (≈ᵏ-reflexive (lookup∘tabulate δ k j))) ⟩\n tabulate (λ i j -> V.sum-tab λ k -> (A ⟪ i , k ⟫) *ᵏ δ k j)\n ≈⟨ tabulate-cong (λ i j -> V.sum-tab-cong {p} λ k -> *ᵏ-cong ≈ᵏ-refl (δ-comm k j)) ⟩\n tabulate (λ i j -> V.sum-tab λ k -> (A ⟪ i , k ⟫) *ᵏ δ j k)\n ≈⟨ tabulate-cong (λ i j -> ≈ᵏ-trans (V.sum-tab-cong {p} (λ k -> *ᵏ-comm ((A ⟪ i , k ⟫)) (δ j k)))\n (V.sum-tab-δ (λ k -> A ⟪ i , k ⟫) j)) ⟩\n tabulate (λ i j -> A ⟪ i , j ⟫)\n ≡⟨ tabulate∘lookup A ⟩\n A\n ∎\n where open import Relation.Binary.EqReasoning (setoid {n} {p})\n\nmodule _ {n p} where\n open IsEquivalence (≈-isEquiv {n} {p}) public\n using ()\n renaming\n ( refl to ≈-refl\n ; sym to ≈-sym\n ; trans to ≈-trans\n )\n\n open FP (_≈_ {n} {p})\n\n open import Algebra.Structures (_≈_ {n} {p})\n open import Algebra.Linear.Structures.Bundles\n\n isMagma : IsMagma _+_\n isMagma = record\n { isEquivalence = ≈-isEquiv\n ; ∙-cong = +-cong\n }\n\n isSemigroup : IsSemigroup _+_\n isSemigroup = record\n { isMagma = isMagma\n ; assoc = +-assoc\n }\n\n isMonoid : IsMonoid _+_ 0#\n isMonoid = record\n { isSemigroup = isSemigroup\n ; identity = +-identity\n }\n\n isGroup : IsGroup _+_ 0# -_\n isGroup = record\n { isMonoid = isMonoid\n ; inverse = -‿inverse\n ; ⁻¹-cong = -‿cong\n }\n\n isAbelianGroup : IsAbelianGroup _+_ 0# -_\n isAbelianGroup = record\n { isGroup = isGroup\n ; comm = +-comm\n }\n\n open VS K\n\n isVectorSpace : VS.IsVectorSpace K (_≈_ {n}) _+_ _∙_ -_ 0#\n isVectorSpace = record\n { isAbelianGroup = isAbelianGroup\n ; *ᵏ-∙-compat = *ᵏ-∙-compat\n ; ∙-+-distrib = ∙-+-distrib\n ; ∙-+ᵏ-distrib = ∙-+ᵏ-distrib\n ; ∙-cong = ∙-cong\n ; ∙-identity = ∙-identity\n ; ∙-absorbˡ = ∙-absorbˡ\n }\n\n vectorSpace : VectorSpace K k (k ⊔ ℓ)\n vectorSpace = record { isVectorSpace = isVectorSpace }\n\n open import Algebra.Linear.Structures.FiniteDimensional K\n open import Algebra.Linear.Morphism.VectorSpace K\n open import Algebra.Linear.Morphism.Bundles K\n\n open import Algebra.Morphism.Definitions (M n p) (Vec K' (n *ℕ p)) V._≈_\n open import Algebra.Linear.Morphism.Definitions K (M n p) (Vec K' (n *ℕ p)) V._≈_\n import Relation.Binary.Morphism.Definitions (M n p) (Vec K' (n *ℕ p)) as R\n open import Function\n open import Relation.Binary.EqReasoning (V.setoid (n *ℕ p))\n\n ⟦_⟧ : M n p -> Vec K' (n *ℕ p)\n ⟦_⟧ = V.concat\n\n ⟦⟧-cong : R.Homomorphic₂ _≈_ (V._≈_ {n *ℕ p}) ⟦_⟧\n ⟦⟧-cong = PW.concat⁺\n\n +-homo : Homomorphic₂ ⟦_⟧ _+_ _+v_\n +-homo = concat-+\n\n 0#-homo : Homomorphic₀ ⟦_⟧ 0# V.0#\n 0#-homo = concat-0# {n} {p}\n\n ∙-homo : ScalarHomomorphism ⟦_⟧ _∙_ _∙v_\n ∙-homo = concat-∙\n\n ⟦⟧-injective : Injective (_≈_ {n} {p}) (V._≈_ {n *ℕ p}) ⟦_⟧\n ⟦⟧-injective {A} {B} r = PW.concat⁻ A B r\n\n ⟦⟧-surjective : Surjective (_≈_ {n} {p}) (V._≈_ {n *ℕ p}) ⟦_⟧\n ⟦⟧-surjective v = fromVec {n} {p} v , concat∘fromVec {n} {p} v\n\n embed : LinearIsomorphism vectorSpace (V.vectorSpace {n *ℕ p})\n embed = record\n { ⟦_⟧ = ⟦_⟧\n ; isLinearIsomorphism = record\n { isLinearMonomorphism = record\n { isLinearMap = record\n { isAbelianGroupMorphism = record\n { gp-homo = record\n { mn-homo = record\n { sm-homo = record\n { ⟦⟧-cong = ⟦⟧-cong\n ; ∙-homo = +-homo\n }\n ; ε-homo = 0#-homo\n }\n }\n }\n ; ∙-homo = ∙-homo\n }\n ; injective = ⟦⟧-injective\n }\n ; surjective = ⟦⟧-surjective\n }\n }\n\n isFiniteDimensional : IsFiniteDimensional _≈_ _+_ _∙_ -_ 0# (n *ℕ p)\n isFiniteDimensional = record\n { isVectorSpace = isVectorSpace\n ; embed = embed\n }\n", "meta": {"hexsha": "e7a6bd35228317af73d23029c9dd306733529e30", "size": 17432, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Algebra/Linear/Construct/Matrix.agda", "max_stars_repo_name": "felko/linear-algebra", "max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z", "max_issues_repo_path": "src/Algebra/Linear/Construct/Matrix.agda", "max_issues_repo_name": "felko/linear-algebra", "max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Algebra/Linear/Construct/Matrix.agda", "max_forks_repo_name": "felko/linear-algebra", "max_forks_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.7054409006, "max_line_length": 112, "alphanum_fraction": 0.4842244149, "num_tokens": 8313, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289388083214156, "lm_q2_score": 0.7606506418255928, "lm_q1q2_score": 0.6305328365838269}} {"text": "module sort where\n\nopen import bool\nopen import eq\nopen import nat\nopen import list\nopen import nondet\nopen import nondet-thms\n\n-- non-deterministic insert.\n--This takes a nondeterministic list because I need to be able to call it with the result of perm\n--\n--implementation in curry:\n-- ndinsert x [] = []\n-- ndinsert x (y:ys) = (x : y : xs) ? (y : insert x ys)\nndinsert : {A : Set} -> A -> ND (list A) -> ND (list A)\nndinsert x (Val [] ) = Val ( x :: [])\nndinsert x (Val (y :: ys)) = (Val ( x :: y :: ys )) ?? ((_::_ y) $* (ndinsert x (Val ys)))\nndinsert x (l ?? r) = (ndinsert x l) ?? (ndinsert x r)\n\n--non-deterministic permutation\n--this is identical to the curry code (except for the Val constructor)\nperm : {A : Set} -> (list A) -> ND (list A)\nperm [] = Val []\nperm (x :: xs) = ndinsert x (perm xs)\n\n--insert a value into a sorted list.\n--this is identical to curry or haskell code.\n--\n--note that the structure here is identical to ndinsert\ninsert : {A : Set} -> (A -> A -> 𝔹) -> A -> list A -> list A\ninsert _ x [] = x :: []\ninsert _<_ x (y :: ys) = if x < y\n then (x :: y :: ys)\n else (y :: insert _<_ x ys)\n\n--simple insertion sort\n--again this is identical to curry or haskell\n--also, note that the structure is identical to perm\nsort : {A : Set} -> (A -> A -> 𝔹) -> list A -> list A\nsort _ [] = []\nsort p (x :: xs) = insert p x (sort p xs)\n\n\n-- Proof: if xs ∈ nxs then x::xs ∈ ndinsert x nxs\ninsId : {A : Set} -> (x : A) -> (xs : list A) -> (x :: xs) ∈ (ndinsert x (Val xs))\ninsId x [] = ndrefl\ninsId x (y :: xs) = left (Val (x :: y :: xs)) ((_::_ y) $* (ndinsert x (Val xs))) ndrefl\n\n--If introduction rule for non-deterministic values.\n--if x and y are both possible values in z then\n--∀ c. if c then x else y will give us either x or y, so it must be a possible value of z.\n--\nifIntro : {A : Set} -> (x : A) -> (y : A) -> (z : ND A) -> (p : x ∈ z) -> (q : y ∈ z) -> (c : 𝔹) -> (if c then x else y) ∈ z\nifIntro x y z p q tt = p\nifIntro x y z p q ff = q\n\n---------------------------------------------------------------------------\n--\n-- this should prove that if xs ∈ nxs then, insert x xs ∈ ndinsert x nxs\n-- parameters:\n-- c : a comparison operator that is needed for insert\n-- x : the value we are inserting into the list\n-- xs : the list\n-- nxs : a non-deterministic list, we know that xs is a possible value for nxs\n-- xs ∈ nxs : the proof that xs is somewhere in nxs\n--\n--retruns: insert c x xs ∈ ndinsert x nxs\n-- a proof that inserting a value in a list is ok with non-deterministic lists\ninsert=ndinsert : {A : Set} -> (c : A -> A -> 𝔹) -> (x : A) -> (xs : list A) -> (nxs : ND (list A)) -> xs ∈ nxs -> (insert c x xs) ∈ (ndinsert x nxs)\n\n--the first two cases are simple, either we are inserting into an empty list, in which case it's trivial\n--or, the list doesn't match the non-deterministic case. This is an imposible case\ninsert=ndinsert _ x [] (Val []) _ = ndrefl\ninsert=ndinsert _ x [] (Val (_ :: _)) ()\n\n--the next two cases are just structural recursion on the non-deterministic tree.\ninsert=ndinsert c x ys (l ?? r) (left .l .r p) = left (ndinsert x l) (ndinsert x r) (insert=ndinsert c x ys l p)\ninsert=ndinsert c x ys (l ?? r) (right .l .r p) = right (ndinsert x l) (ndinsert x r) (insert=ndinsert c x ys r p)\n\n--The final case is the interesting one.\n--We reached a leaf in the non-deterministic tree, so we have a deterministic value.\n--by definition this is equal to the deterministic list (y :: ys)\n--At this point we have two possible cases.\n--Either x is smaller then every element in (y :: ys), in which case it's inserted at the front,\n--or x is larger than y, in which case it's inserted somewhere in ys.\n--Since both of these cases are covered by ndinsert we can invoke the ifIntro lemma, to say that we don't care which case it is.\n--\n--variables:\n-- step : one step of insert\n-- l : the left hand side of insert c x xs (the then branch)\n-- r : the right hand side of insert c x xs (the else branch)\n-- nr : a non-deterministic r\n-- (Val l) : a non-deterministic l (but since ndinsert only has a deterministic value on the left it's not very interesting)\n-- rec : The recursive call. If x isn't inserted into the front, then we need to find it.\n-- l∈step : a proof that l is a possible value for step\n-- r∈step : a proof that r is a possible value for step\ninsert=ndinsert _<_ x (y :: ys) (Val (.y :: .ys)) ndrefl = ifIntro l r step l∈step r∈step (x < y)\n where step = ndinsert x (Val (y :: ys))\n l = ( x :: y :: ys)\n r = y :: insert _<_ x ys\n nr = (_::_ y) $* (ndinsert x (Val ys))\n rec = ∈-$* (_::_ y) (insert _<_ x ys) (ndinsert x (Val ys)) (insert=ndinsert _<_ x ys (Val ys) ndrefl)\n r∈step = right (Val l) nr rec\n l∈step = left (Val l) nr ndrefl\n\n---------------------------------------------------------------------------\n\n-- main theorem. Sorting a list preserves permutations\n--all of the work is really done by insert=ndinsert\nsortPerm : {A : Set} -> (c : A -> A -> 𝔹) -> (xs : list A) -> sort c xs ∈ perm xs\nsortPerm _<_ [] = ndrefl\nsortPerm _<_ (x :: xs) = insert=ndinsert _<_ x (sort _<_ xs) (perm xs) (sortPerm _<_ xs)\n\n", "meta": {"hexsha": "41fcbfd5978bffebb18c1a1cb050c2ed9c91718b", "size": 5297, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "nondet/sort.agda", "max_stars_repo_name": "mihanus/curry-agda", "max_stars_repo_head_hexsha": "b7cfdda11cdadeba882b6b72d75448acd8b0a294", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "nondet/sort.agda", "max_issues_repo_name": "mihanus/curry-agda", "max_issues_repo_head_hexsha": "b7cfdda11cdadeba882b6b72d75448acd8b0a294", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nondet/sort.agda", "max_forks_repo_name": "mihanus/curry-agda", "max_forks_repo_head_hexsha": "b7cfdda11cdadeba882b6b72d75448acd8b0a294", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.0608695652, "max_line_length": 149, "alphanum_fraction": 0.5912780819, "num_tokens": 1623, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289387956435734, "lm_q2_score": 0.7606506472514406, "lm_q1q2_score": 0.6305328314381138}} {"text": "{-# OPTIONS --safe --experimental-lossy-unification #-}\nmodule Cubical.Algebra.CommRing.BinomialThm where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\n\nopen import Cubical.Data.Nat renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_ ; _^_ to _^ℕ_\n ; +-comm to +ℕ-comm\n ; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm\n ; _choose_ to _ℕchoose_ ; snotz to ℕsnotz)\nopen import Cubical.Data.Nat.Order\nopen import Cubical.Data.FinData\nopen import Cubical.Data.Empty as ⊥\n\nopen import Cubical.Algebra.Monoid.BigOp\nopen import Cubical.Algebra.Ring.BigOps\nopen import Cubical.Algebra.CommRing\nopen import Cubical.Algebra.RingSolver.Reflection\n\nprivate\n variable\n ℓ : Level\n\nmodule BinomialThm (R' : CommRing ℓ) where\n open CommRingStr (snd R')\n open Exponentiation R'\n open CommRingTheory R'\n open Sum (CommRing→Ring R')\n private R = fst R'\n\n _choose_ : ℕ → ℕ → R\n n choose zero = 1r\n zero choose suc k = 0r\n suc n choose suc k = n choose (suc k) + n choose k\n\n n Set c -> Set c\nVectorAddition V = V -> V -> V\n\nScalarMultiplication : ∀ {c k} -> Set k -> Set c -> Set (k ⊔ c)\nScalarMultiplication K V = K -> V -> V\n", "meta": {"hexsha": "cbd3b7c6aeb6db17928f32252382022e97c86ec5", "size": 389, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Algebra/Linear/Core.agda", "max_stars_repo_name": "felko/linear-algebra", "max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z", "max_issues_repo_path": "src/Algebra/Linear/Core.agda", "max_issues_repo_name": "felko/linear-algebra", "max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Algebra/Linear/Core.agda", "max_forks_repo_name": "felko/linear-algebra", "max_forks_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.9333333333, "max_line_length": 63, "alphanum_fraction": 0.6606683805, "num_tokens": 111, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8933094174159127, "lm_q2_score": 0.7057850340255387, "lm_q1q2_score": 0.6304844175662242}} {"text": "module Utilities.ExistsSyntax where\n\nopen import Level using (Level ; _⊔_)\nopen import Data.Product using (Σ)\n\nvariable\n a b : Level\n A : Set a\n B : Set b\n\n∃-syntax : (A : Set a) → (A → Set b) → Set (a ⊔ b)\n∃-syntax = Σ\n\nsyntax ∃-syntax A (λ x → B) = ∃ x ∶ A • B\n", "meta": {"hexsha": "29e036e6086afaf8a3bfa714b25c3f4ddb02c530", "size": 266, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Utilities/ExistsSyntax.agda", "max_stars_repo_name": "armkeh/agda-computability", "max_stars_repo_head_hexsha": "f6a6845a54aed7ecc6841ff5ad89643b553cbd77", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Utilities/ExistsSyntax.agda", "max_issues_repo_name": "armkeh/agda-computability", "max_issues_repo_head_hexsha": "f6a6845a54aed7ecc6841ff5ad89643b553cbd77", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Utilities/ExistsSyntax.agda", "max_forks_repo_name": "armkeh/agda-computability", "max_forks_repo_head_hexsha": "f6a6845a54aed7ecc6841ff5ad89643b553cbd77", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.7333333333, "max_line_length": 50, "alphanum_fraction": 0.5939849624, "num_tokens": 103, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8933094060543487, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.6304844040191325}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Categories.Functor where\n\nopen import Prelude\nopen import Categories\n\nrecord Functor {ℓ₁ ℓ₂ ℓ₃ ℓ₄} (C : PreCategory ℓ₁ ℓ₂) (D : PreCategory ℓ₃ ℓ₄) : Type (ℓ₁ ℓ⊔ ℓ₂ ℓ⊔ ℓ₃ ℓ⊔ ℓ₄) where\n private module C = PreCategory C\n private module D = PreCategory D\n field\n F₀ : C.Ob → D.Ob\n F₁ : ∀ {X Y} → (X C.⟶ Y) → (F₀ X D.⟶ F₀ Y)\n\n identity : ∀ {X} → F₁ (C.Id {X}) ≡ D.Id\n homomorphism : ∀ {X Y Z} → (f : X C.⟶ Y) (g : Y C.⟶ Z) →\n F₁ (g C.· f) ≡ F₁ g D.· F₁ f\n", "meta": {"hexsha": "f689fa30d9f7a3ee2a69337fe5ab8893bb5c139c", "size": 524, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Categories/Functor.agda", "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_issues_repo_path": "agda/Categories/Functor.agda", "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Categories/Functor.agda", "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "avg_line_length": 29.1111111111, "max_line_length": 112, "alphanum_fraction": 0.5496183206, "num_tokens": 244, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8933094032139577, "lm_q2_score": 0.7057850154599562, "lm_q1q2_score": 0.6304843909578873}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- An inductive definition of the sublist relation with respect to a\n-- setoid. This is a generalisation of what is commonly known as Order\n-- Preserving Embeddings (OPE).\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary using (Setoid; Rel)\n\nmodule Data.List.Relation.Binary.Sublist.Setoid\n {c ℓ} (S : Setoid c ℓ) where\n\nopen import Level using (_⊔_)\nopen import Data.List.Base using (List; []; _∷_)\nimport Data.List.Relation.Binary.Equality.Setoid as SetoidEquality\nimport Data.List.Relation.Binary.Sublist.Heterogeneous as Heterogeneous\nimport Data.List.Relation.Binary.Sublist.Heterogeneous.Core\n as HeterogeneousCore\nimport Data.List.Relation.Binary.Sublist.Heterogeneous.Properties\n as HeterogeneousProperties\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as P using (_≡_)\n\nopen Setoid S renaming (Carrier to A)\nopen SetoidEquality S\n\n------------------------------------------------------------------------\n-- Definition\n\ninfix 4 _⊆_\n_⊆_ : Rel (List A) (c ⊔ ℓ)\n_⊆_ = Heterogeneous.Sublist _≈_\n\n------------------------------------------------------------------------\n-- Re-export definitions and operations from heterogeneous sublists\n\nopen HeterogeneousCore _≈_ using ([]; _∷_; _∷ʳ_) public\nopen Heterogeneous {R = _≈_} hiding (Sublist; []; _∷_; _∷ʳ_) public\n renaming\n (toAny to to∈; fromAny to from∈)\n\n------------------------------------------------------------------------\n-- Relational properties holding for Setoid case\n\n⊆-reflexive : _≋_ ⇒ _⊆_\n⊆-reflexive = HeterogeneousProperties.fromPointwise\n\n⊆-refl : Reflexive _⊆_\n⊆-refl = HeterogeneousProperties.refl refl\n\n⊆-trans : Transitive _⊆_\n⊆-trans = HeterogeneousProperties.trans trans\n\n⊆-antisym : Antisymmetric _≋_ _⊆_\n⊆-antisym = HeterogeneousProperties.antisym (λ x≈y _ → x≈y)\n\n⊆-isPreorder : IsPreorder _≋_ _⊆_\n⊆-isPreorder = record\n { isEquivalence = ≋-isEquivalence\n ; reflexive = ⊆-reflexive\n ; trans = ⊆-trans\n }\n\n⊆-isPartialOrder : IsPartialOrder _≋_ _⊆_\n⊆-isPartialOrder = record\n { isPreorder = ⊆-isPreorder\n ; antisym = ⊆-antisym\n }\n\n⊆-preorder : Preorder c (c ⊔ ℓ) (c ⊔ ℓ)\n⊆-preorder = record\n { isPreorder = ⊆-isPreorder\n }\n\n⊆-poset : Poset c (c ⊔ ℓ) (c ⊔ ℓ)\n⊆-poset = record\n { isPartialOrder = ⊆-isPartialOrder\n }\n", "meta": {"hexsha": "6140d6dddb1514717e72729d6eb42bb916d2d10d", "size": 2451, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Sublist/Setoid.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Sublist/Setoid.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Sublist/Setoid.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.8902439024, "max_line_length": 72, "alphanum_fraction": 0.6156670747, "num_tokens": 731, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672135527632, "lm_q2_score": 0.7799929104825006, "lm_q1q2_score": 0.6302866977645042}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Experiment.ListConstruction where\n\nopen import Level renaming (zero to lzero; suc to lsuc)\n\ndata ⊥ : Set where\n\nrecord ⊤ : Set where\n constructor tt\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\nmodule Inductive where\n data List (A : Set) : Set where\n [] : List A\n _∷_ : A → List A → List A\n\ndata Bool : Set where\n true false : Bool\n\nrecord Σ {a b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where\n constructor _,_\n field\n fst : A\n snd : B fst\n\n∃ : ∀ {a b} {A : Set a} (B : A → Set b) → Set (a ⊔ b)\n∃ {a} {b} {A} B = Σ A B\n\nif : ∀ {p} {P : Bool → Set p} → ∀ b → P true → P false → P b\nif true t e = t\nif false t e = e\n\n_⊎_ : (A B : Set) → Set\nA ⊎ B = ∃ λ b → if b A B\n\ninj₁ : {A B : Set} → A → A ⊎ B\ninj₁ x = true , x\n\ninj₂ : {A B : Set} → B → A ⊎ B\ninj₂ x = false , x\n\n⊎-elim : ∀ {p} {A B : Set} {P : A ⊎ B → Set p} →\n (∀ x → P (inj₁ x)) → (∀ y → P (inj₂ y)) → ∀ s → P s\n⊎-elim x y (true , snd) = x snd\n⊎-elim x y (false , snd) = y snd\n\n_×_ : (A B : Set) → Set\nA × B = ∀ b → if b A B\n\nproj₁ : {A B : Set} → A × B → A\nproj₁ x = x true\n\nproj₂ : {A B : Set} → A × B → B\nproj₂ x = x false\n\nFin : ℕ → Set\nFin zero = ⊥\nFin (suc n) = ⊤ ⊎ Fin n\n\nVec : Set → ℕ → Set\nVec A n = Fin n → A\n\nmodule VecList where\n List : Set → Set\n List A = ∃ λ n → Vec A n\n", "meta": {"hexsha": "193575727fdad34b4b2885adb10305a1a8334162", "size": 1313, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Experiment/ListConstruction.agda", "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_issues_repo_path": "Experiment/ListConstruction.agda", "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Experiment/ListConstruction.agda", "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.7571428571, "max_line_length": 62, "alphanum_fraction": 0.5041888804, "num_tokens": 571, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677468516187, "lm_q2_score": 0.7431680029241321, "lm_q1q2_score": 0.6301824969717935}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\n\nmodule Categories.Category.Duality {o ℓ e} (C : Category o ℓ e) where\n\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl)\n\nopen import Categories.Category.Cartesian\nopen import Categories.Category.Cocartesian\nopen import Categories.Category.Complete\nopen import Categories.Category.Complete.Finitely\nopen import Categories.Category.Cocomplete\nopen import Categories.Category.Cocomplete.Finitely\n\nopen import Categories.Object.Duality\nopen import Categories.Diagram.Duality\nopen import Categories.Functor\n\nprivate\n module C = Category C\n open C\n\ncoCartesian⇒Cocartesian : Cartesian C.op → Cocartesian C\ncoCartesian⇒Cocartesian Car = record\n { initial = op⊤⇒⊥ C terminal\n ; coproducts = record\n { coproduct = coProduct⇒Coproduct C product\n }\n }\n where open Cartesian Car\n\nCocartesian⇒coCartesian : Cocartesian C → Cartesian C.op\nCocartesian⇒coCartesian Co = record\n { terminal = ⊥⇒op⊤ C initial\n ; products = record\n { product = Coproduct⇒coProduct C coproduct\n }\n }\n where open Cocartesian Co\n\ncoComplete⇒Cocomplete : ∀ {o′ ℓ′ e′} → Complete o′ ℓ′ e′ C.op → Cocomplete o′ ℓ′ e′ C\ncoComplete⇒Cocomplete Com F = coLimit⇒Colimit C (Com F.op)\n where module F = Functor F\n\nCocomplete⇒coComplete : ∀ {o′ ℓ′ e′} → Cocomplete o′ ℓ′ e′ C → Complete o′ ℓ′ e′ C.op\nCocomplete⇒coComplete Coc F = Colimit⇒coLimit C (Coc F.op)\n where module F = Functor F\n\ncoFinitelyComplete⇒FinitelyCocomplete : FinitelyComplete C.op → FinitelyCocomplete C\ncoFinitelyComplete⇒FinitelyCocomplete FC = record\n { cocartesian = coCartesian⇒Cocartesian cartesian\n ; coequalizer = λ f g → coEqualizer⇒Coequalizer C (equalizer f g)\n }\n where open FinitelyComplete FC\n\nFinitelyCocomplete⇒coFinitelyComplete : FinitelyCocomplete C → FinitelyComplete C.op\nFinitelyCocomplete⇒coFinitelyComplete FC = record\n { cartesian = Cocartesian⇒coCartesian cocartesian\n ; equalizer = λ f g → Coequalizer⇒coEqualizer C (coequalizer f g)\n }\n where open FinitelyCocomplete FC\n\n\n\nmodule DualityConversionProperties where\n\n private\n op-involutive : Category.op C.op ≡ C\n op-involutive = refl\n\n coCartesian⇔Cocartesian : ∀(coCartesian : Cartesian C.op)\n → Cocartesian⇒coCartesian (coCartesian⇒Cocartesian coCartesian)\n ≡ coCartesian\n coCartesian⇔Cocartesian _ = refl\n\n coFinitelyComplete⇔FinitelyCocomplete : ∀(coFinComplete : FinitelyComplete C.op) →\n FinitelyCocomplete⇒coFinitelyComplete\n (coFinitelyComplete⇒FinitelyCocomplete coFinComplete) ≡ coFinComplete\n coFinitelyComplete⇔FinitelyCocomplete _ = refl\n", "meta": {"hexsha": "2134f5bed58b293df9bb00ed5683bca7b6137381", "size": 2663, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Duality.agda", "max_stars_repo_name": "bblfish/agda-categories", "max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "src/Categories/Category/Duality.agda", "max_issues_repo_name": "bblfish/agda-categories", "max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Duality.agda", "max_forks_repo_name": "bblfish/agda-categories", "max_forks_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 32.8765432099, "max_line_length": 91, "alphanum_fraction": 0.7450244086, "num_tokens": 820, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8887587875995482, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.6301469857277213}} {"text": "module monad where\n\nopen import eq\n\nrecord Monad (M : Set → Set) : Set₁ where\n field\n return : ∀{A : Set} → A → M A\n bind : ∀{A B : Set} → M A → (A → M B) → M B\n \n monad-left-id : ∀{A B : Set}{a : A}{f : A → M B}\n → bind (return a) f ≡ f a\n \n monad-right-id : ∀{A : Set}{c : M A}\n → bind c return ≡ c\n \n monad-assoc : ∀{A B C : Set}{c : M A}{f : A → M B}{g : B → M C}\n → bind (bind c f) g ≡ bind c (λ a → bind (f a) g)\n\n", "meta": {"hexsha": "ee9d26c8672c84e8b414e84099a5693d02992bdc", "size": 464, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "monads.agda", "max_stars_repo_name": "heades/AUGL", "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "monads.agda", "max_issues_repo_name": "heades/AUGL", "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "monads.agda", "max_forks_repo_name": "heades/AUGL", "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.4210526316, "max_line_length": 67, "alphanum_fraction": 0.4482758621, "num_tokens": 185, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9372107966642554, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.6301165212571892}} {"text": "------------------------------------------------------------------------\n-- Some Vec-related properties\n------------------------------------------------------------------------\n\nmodule Data.Vec.Properties where\n\nopen import Algebra\nopen import Data.Vec\nopen import Data.Nat\nimport Data.Nat.Properties as Nat\nopen import Data.Fin using (Fin; zero; suc)\nopen import Data.Function\nopen import Relation.Binary\n\nmodule UsingVectorEquality (S : Setoid) where\n\n private module SS = Setoid S\n open SS using () renaming (carrier to A)\n import Data.Vec.Equality as VecEq\n open VecEq.Equality S\n\n replicate-lemma : ∀ {m} n x (xs : Vec A m) →\n replicate {n = n} x ++ (x ∷ xs) ≈\n replicate {n = 1 + n} x ++ xs\n replicate-lemma zero x xs = refl (x ∷ xs)\n replicate-lemma (suc n) x xs = SS.refl ∷-cong replicate-lemma n x xs\n\n xs++[]=xs : ∀ {n} (xs : Vec A n) → xs ++ [] ≈ xs\n xs++[]=xs [] = []-cong\n xs++[]=xs (x ∷ xs) = SS.refl ∷-cong xs++[]=xs xs\n\n map-++-commute : ∀ {B m n} (f : B → A) (xs : Vec B m) {ys : Vec B n} →\n map f (xs ++ ys) ≈ map f xs ++ map f ys\n map-++-commute f [] = refl _\n map-++-commute f (x ∷ xs) = SS.refl ∷-cong map-++-commute f xs\n\nopen import Relation.Binary.PropositionalEquality as PropEq\nopen import Relation.Binary.HeterogeneousEquality as HetEq\n\n-- lookup is natural.\n\nlookup-natural : ∀ {A B n} (f : A → B) (i : Fin n) →\n lookup i ∘ map f ≗ f ∘ lookup i\nlookup-natural f zero (x ∷ xs) = refl\nlookup-natural f (suc i) (x ∷ xs) = lookup-natural f i xs\n\n-- map is a congruence.\n\nmap-cong : ∀ {A B n} {f g : A → B} →\n f ≗ g → _≗_ {Vec A n} (map f) (map g)\nmap-cong f≗g [] = refl\nmap-cong f≗g (x ∷ xs) = PropEq.cong₂ _∷_ (f≗g x) (map-cong f≗g xs)\n\n-- map is functorial.\n\nmap-id : ∀ {A n} → _≗_ {Vec A n} (map id) id\nmap-id [] = refl\nmap-id (x ∷ xs) = PropEq.cong (_∷_ x) (map-id xs)\n\nmap-∘ : ∀ {A B C n} (f : B → C) (g : A → B) →\n _≗_ {Vec A n} (map (f ∘ g)) (map f ∘ map g)\nmap-∘ f g [] = refl\nmap-∘ f g (x ∷ xs) = PropEq.cong (_∷_ (f (g x))) (map-∘ f g xs)\n\n-- sum commutes with _++_.\n\nsum-++-commute : ∀ {m n} (xs : Vec ℕ m) {ys : Vec ℕ n} →\n sum (xs ++ ys) ≡ sum xs + sum ys\nsum-++-commute [] = refl\nsum-++-commute (x ∷ xs) {ys} = begin\n x + sum (xs ++ ys)\n ≡⟨ PropEq.cong (λ p → x + p) (sum-++-commute xs) ⟩\n x + (sum xs + sum ys)\n ≡⟨ PropEq.sym (+-assoc x (sum xs) (sum ys)) ⟩\n sum (x ∷ xs) + sum ys\n ∎\n where\n open ≡-Reasoning\n open CommutativeSemiring Nat.commutativeSemiring hiding (_+_; sym)\n\n-- foldr is a congruence.\n\nfoldr-cong : ∀ {A} {B₁} {f₁ : ∀ {n} → A → B₁ n → B₁ (suc n)} {e₁}\n {B₂} {f₂ : ∀ {n} → A → B₂ n → B₂ (suc n)} {e₂} →\n (∀ {n x} {y₁ : B₁ n} {y₂ : B₂ n} →\n y₁ ≅ y₂ → f₁ x y₁ ≅ f₂ x y₂) →\n e₁ ≅ e₂ →\n ∀ {n} (xs : Vec A n) →\n foldr B₁ f₁ e₁ xs ≅ foldr B₂ f₂ e₂ xs\nfoldr-cong _ e₁=e₂ [] = e₁=e₂\nfoldr-cong {B₁ = B₁} f₁=f₂ e₁=e₂ (x ∷ xs) =\n f₁=f₂ (foldr-cong {B₁ = B₁} f₁=f₂ e₁=e₂ xs)\n\n-- foldl is a congruence.\n\nfoldl-cong : ∀ {A} {B₁} {f₁ : ∀ {n} → B₁ n → A → B₁ (suc n)} {e₁}\n {B₂} {f₂ : ∀ {n} → B₂ n → A → B₂ (suc n)} {e₂} →\n (∀ {n x} {y₁ : B₁ n} {y₂ : B₂ n} →\n y₁ ≅ y₂ → f₁ y₁ x ≅ f₂ y₂ x) →\n e₁ ≅ e₂ →\n ∀ {n} (xs : Vec A n) →\n foldl B₁ f₁ e₁ xs ≅ foldl B₂ f₂ e₂ xs\nfoldl-cong _ e₁=e₂ [] = e₁=e₂\nfoldl-cong {B₁ = B₁} f₁=f₂ e₁=e₂ (x ∷ xs) =\n foldl-cong {B₁ = B₁ ∘₀ suc} f₁=f₂ (f₁=f₂ e₁=e₂) xs\n\n-- The (uniqueness part of the) universality property for foldr.\n\nfoldr-universal : ∀ {A} (B : ℕ → Set)\n (f : ∀ {n} → A → B n → B (suc n)) {e}\n (h : ∀ {n} → Vec A n → B n) →\n h [] ≡ e →\n (∀ {n} x → h ∘ _∷_ x ≗ f {n} x ∘ h) →\n ∀ {n} → h ≗ foldr B {n} f e\nfoldr-universal B f h base step [] = base\nfoldr-universal B f {e} h base step (x ∷ xs) = begin\n h (x ∷ xs)\n ≡⟨ step x xs ⟩\n f x (h xs)\n ≡⟨ PropEq.cong (f x) (foldr-universal B f h base step xs) ⟩\n f x (foldr B f e xs)\n ∎\n where open ≡-Reasoning\n\n-- A fusion law for foldr.\n\nfoldr-fusion : ∀ {A} {B : ℕ → Set} {f : ∀ {n} → A → B n → B (suc n)} e\n {C : ℕ → Set} {g : ∀ {n} → A → C n → C (suc n)}\n (h : ∀ {n} → B n → C n) →\n (∀ {n} x → h ∘ f {n} x ≗ g x ∘ h) →\n ∀ {n} → h ∘ foldr B {n} f e ≗ foldr C g (h e)\nfoldr-fusion {B = B} {f} e {C} h fuse =\n foldr-universal C _ _ refl (λ x xs → fuse x (foldr B f e xs))\n\n-- The identity function is a fold.\n\nidIsFold : ∀ {A n} → id ≗ foldr (Vec A) {n} _∷_ []\nidIsFold = foldr-universal _ _ id refl (λ _ _ → refl)\n", "meta": {"hexsha": "9cd26751efd422f334a8d2ef1f16d0ea5d0a09a0", "size": 4803, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Data/Vec/Properties.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Data/Vec/Properties.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Data/Vec/Properties.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 34.5539568345, "max_line_length": 72, "alphanum_fraction": 0.4667915886, "num_tokens": 1925, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891392358015, "lm_q2_score": 0.7662936324115011, "lm_q1q2_score": 0.6300383020342878}} {"text": "{-# OPTIONS --sized-types #-}\nmodule SNat.Properties where\n\nopen import Size\nopen import SNat\nopen import SNat.Order\nopen import SNat.Order.Properties\nopen import SNat.Sum\n\nlemma-≅subtyping : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} → m ≅ n → m ≅ subtyping n\nlemma-≅subtyping z≅z = z≅z\nlemma-≅subtyping (s≅s m≅n) = s≅s (lemma-≅subtyping m≅n)\n\nlemma-subtyping≅ : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} → m ≅ n → subtyping m ≅ n\nlemma-subtyping≅ z≅z = z≅z\nlemma-subtyping≅ (s≅s m≅n) = s≅s (lemma-subtyping≅ m≅n)\n\nlemma-subtyping≅subtyping : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} → m ≅ n → subtyping m ≅ subtyping n\nlemma-subtyping≅subtyping z≅z = z≅z\nlemma-subtyping≅subtyping (s≅s m≅n) = s≅s (lemma-subtyping≅subtyping m≅n)\n\nlemma-≤′subtyping : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} → m ≤′ n → m ≤′ subtyping n\nlemma-≤′subtyping (≤′-eq m≅n) = ≤′-eq (lemma-≅subtyping m≅n)\nlemma-≤′subtyping (≤′-step m≤′n) = ≤′-step (lemma-≤′subtyping m≤′n)\n\nlemma-subtyping≤′ : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} → m ≤′ n → subtyping m ≤′ n\nlemma-subtyping≤′ (≤′-eq m≅n) = ≤′-eq (lemma-subtyping≅ m≅n)\nlemma-subtyping≤′ (≤′-step m≤′n) = ≤′-step (lemma-subtyping≤′ m≤′n)\n\nlemma-subtyping≤subtyping : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} → m ≤ n → subtyping m ≤ subtyping n\nlemma-subtyping≤subtyping (z≤n n) = z≤n (subtyping n)\nlemma-subtyping≤subtyping (s≤s m≤n) = s≤s (lemma-subtyping≤subtyping m≤n)\n\nlemma-subtyping≤′subtyping : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} → m ≤′ n → subtyping m ≤′ subtyping n\nlemma-subtyping≤′subtyping m≤′n = lemma-≤-≤′ (lemma-subtyping≤subtyping (lemma-≤′-≤ m≤′n))\n\n--\n\nlemma-≅-/2 : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} → m ≅ n → m /2 ≅ n /2\nlemma-≅-/2 z≅z = z≅z\nlemma-≅-/2 (s≅s z≅z) = z≅z\nlemma-≅-/2 (s≅s (s≅s m≅n)) = s≅s (lemma-subtyping≅subtyping (lemma-≅-/2 m≅n)) \n\nlemma-n/2≤′sn/2 : {ι : Size}(n : SNat {ι}) → n /2 ≤′ (succ n) /2\nlemma-n/2≤′sn/2 zero = lemma-z≤′n zero\nlemma-n/2≤′sn/2 (succ zero) = lemma-z≤′n (succ zero)\nlemma-n/2≤′sn/2 (succ (succ n)) = lemma-s≤′s (lemma-subtyping≤′subtyping (lemma-n/2≤′sn/2 n))\n\n--\n\nlemma-m≤′m+n : (m n : SNat) → m ≤′ (m + n)\nlemma-m≤′m+n zero n = lemma-z≤′n n\nlemma-m≤′m+n (succ m) n = lemma-s≤′s (lemma-m≤′m+n m n)\n\nlemma-2m≤′m+n+m+n : (m n : SNat) → (m + m) ≤′ ((m + n) + (m + n))\nlemma-2m≤′m+n+m+n m n rewrite +-assoc-left (m + n) m n | +-comm (m + n) m | +-assoc-left m m n | +-assoc-right (m + m) n n = lemma-m≤′m+n (m + m) (n + n)\n\nlemma-2m≅2n : {m n : SNat} → m ≅ n → (m + m) ≅ (n + n)\nlemma-2m≅2n z≅z = z≅z\nlemma-2m≅2n (s≅s {m = m} {n = n} m≅n) rewrite +-assoc-succ m m | +-assoc-succ n n = s≅s (s≅s (lemma-2m≅2n m≅n))\n\nlemma-2m≤′2n : {m n : SNat} → m ≤′ n → (m + m) ≤′ (n + n)\nlemma-2m≤′2n (≤′-eq m≅n) = ≤′-eq (lemma-2m≅2n m≅n)\nlemma-2m≤′2n (≤′-step {n = n} m≤′n) rewrite +-assoc-succ n n = ≤′-step (≤′-step (lemma-2m≤′2n m≤′n))\n\nlemma-n≤′2n : (n : SNat) → n ≤′ (n + n)\nlemma-n≤′2n n = lemma-m≤′m+n n n\n\n+-right-monotony-≅ : {m n : SNat}(k : SNat) → m ≅ n → (m + k) ≅ (n + k)\n+-right-monotony-≅ k z≅z = refl≅\n+-right-monotony-≅ k (s≅s m≅n) = s≅s (+-right-monotony-≅ k m≅n)\n\n+-right-monotony-≤′ : {m n : SNat}(k : SNat) → m ≤′ n → (m + k) ≤′ (n + k)\n+-right-monotony-≤′ k (≤′-eq m≅n) = ≤′-eq (+-right-monotony-≅ k m≅n)\n+-right-monotony-≤′ k (≤′-step m≤′n) = ≤′-step (+-right-monotony-≤′ k m≤′n)\n\n+-left-monotony-≤′ : {m n : SNat}(k : SNat) → m ≤′ n → (k + m) ≤′ (k + n)\n+-left-monotony-≤′ {m} {n} k m≤′n rewrite +-comm k m | +-comm k n = +-right-monotony-≤′ k m≤′n\n\nlemma-4m≤′n+m+n+m : {m n : SNat} → m ≤′ n → ((m + m) + (m + m)) ≤′ ((n + m) + (n + m))\nlemma-4m≤′n+m+n+m {m} {n} m≤′n rewrite +-comm n m = lemma-2m≤′2n (+-left-monotony-≤′ m m≤′n)\n\nlemma-n≤′2n/2 : (n : SNat) → n ≤′ (n + n) /2\nlemma-n≤′2n/2 zero = ≤′-eq z≅z\nlemma-n≤′2n/2 (succ n) rewrite +-assoc-succ (succ n) n = lemma-s≤′s (lemma-≤′subtyping (lemma-n≤′2n/2 n))\n\nlemma-2n/2≤′n : (n : SNat) → (n + n) /2 ≤′ n\nlemma-2n/2≤′n zero = refl≤′\nlemma-2n/2≤′n (succ n) rewrite +-assoc-succ (succ n) n = lemma-s≤′s (lemma-subtyping≤′ (lemma-2n/2≤′n n))\n\nlemma-n+1≤′2n+2/2 : (n : SNat) → succ n ≤′ (succ (succ (n + n))) /2\nlemma-n+1≤′2n+2/2 zero = refl≤′\nlemma-n+1≤′2n+2/2 (succ n) rewrite +-assoc-succ (succ n) n = lemma-s≤′s (lemma-≤′subtyping (lemma-s≤′s (lemma-≤′subtyping (lemma-n≤′2n/2 n))))\n", "meta": {"hexsha": "7cc1e1a14372ced8fd4060957c44d5a04235eebe", "size": 4263, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/SNat/Properties.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/SNat/Properties.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/SNat/Properties.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.3510638298, "max_line_length": 153, "alphanum_fraction": 0.5486746423, "num_tokens": 2210, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891305219504, "lm_q2_score": 0.7662936324115011, "lm_q1q2_score": 0.6300382953569191}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nopen import Cubical.Core.Everything\nopen import Cubical.Foundations.HLevels\n\nmodule Cubical.Algebra.Semigroup.Construct.Right {ℓ} (Aˢ : hSet ℓ) where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Algebra.Semigroup\n\nimport Cubical.Algebra.Magma.Construct.Right Aˢ as RMagma\nopen RMagma public hiding (Right-isMagma; RightMagma)\n\nprivate\n A = ⟨ Aˢ ⟩\n isSetA = Aˢ .snd\n\n▸-assoc : Associative _▸_\n▸-assoc _ _ _ = refl\n\n\nRight-isSemigroup : IsSemigroup A _▸_\nRight-isSemigroup = record\n { isMagma = RMagma.Right-isMagma\n ; assoc = ▸-assoc\n }\n\nRightSemigroup : Semigroup ℓ\nRightSemigroup = record { isSemigroup = Right-isSemigroup }\n", "meta": {"hexsha": "a311c5662eabed22b2e8d086eb330c589c7e5dee", "size": 701, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Semigroup/Construct/Right.agda", "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Semigroup/Construct/Right.agda", "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Semigroup/Construct/Right.agda", "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.3666666667, "max_line_length": 72, "alphanum_fraction": 0.7460770328, "num_tokens": 225, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9184802395624257, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.6300310256603748}} {"text": "module Formalization.LambdaCalculus.Terms.Combinators where\n\nimport Lvl\nopen import Data\nopen import Formalization.LambdaCalculus\nopen import Numeral.Natural\nopen import Numeral.Finite\nopen import Syntax.Number\nopen import Type\n\nmodule _ where\n open ExplicitLambdaSyntax\n\n I = 𝜆 0 0 -- Identity\n K = 𝜆 0 (𝜆 1 0) -- Constant / Left of pair\n 𝈲 = 𝜆 0 (𝜆 1 1) -- Right of pair\n S = 𝜆 0 (𝜆 1 (𝜆 2 ((0 ← 2) ← (1 ← 2)))) -- General composition\n B = 𝜆 0 (𝜆 1 (𝜆 2 (0 ← (1 ← 2)))) -- Composition\n C = 𝜆 0 (𝜆 1 (𝜆 2 ((0 ← 2) ← 1)))\n W = 𝜆 0 (𝜆 1 ((0 ← 1) ← 1))\n U = 𝜆 0 (0 ← 0) -- Self application\n ω = U\n Ω = ω ← ω\n Y = 𝜆 0 ((𝜆 1 (0 ← (1 ← 1))) ← (𝜆 1 (0 ← (1 ← 1))))\n\n-- TODO: Move everything below\n\nopen import Formalization.LambdaCalculus.SyntaxTransformation\n\nmodule Boolean where\n open ExplicitLambdaSyntax\n\n 𝑇 = K\n 𝐹 = 𝈲\n If = 𝜆 0 (𝜆 1 (𝜆 2 (0 ← 1 ← 2)))\n\nmodule Tuple where\n open Boolean\n open ExplicitLambdaSyntax\n\n Pair = 𝜆 0 (𝜆 1 (𝜆 2 (2 ← 0 ← 1)))\n Projₗ = 𝜆 0 (0 ← var-𝐒 K)\n Projᵣ = 𝜆 0 (0 ← var-𝐒 𝈲)\n\n-- Natural numbers (Church numerals).\nmodule Natural where\n open ExplicitLambdaSyntax\n\n λ𝟎 = 𝈲\n λ𝐒 = 𝜆 0 (𝜆 1 (𝜆 2 (1 ← (0 ← 1 ← 2))))\n\n ℕrepr₂ : ℕ → Term(2)\n ℕrepr₂ 𝟎 = 1\n ℕrepr₂ (𝐒(n)) = 0 ← ℕrepr₂ n\n\n ℕrepr = \\n → 𝜆 0 (𝜆 1 (ℕrepr₂ n))\n\n -- TODO: Prove (λ𝐒 ←ⁿ λ𝟎) β-reduces to (ℕrepr n)\n\nmodule β-proofs where\n open import Formalization.LambdaCalculus.Semantics.Reduction\n open import Logic.Propositional hiding (_←_)\n open import Logic.Predicate\n open import ReductionSystem\n open import Relator.ReflexiveTransitiveClosure renaming (trans to _🝖_)\n open import Structure.Relator\n open import Structure.Relator.Properties\n open import Type.Dependent\n\n open ExplicitLambdaSyntax\n\n private variable n : ℕ\n private variable f g h x y z : Term(n)\n\n Ω-self-reduces : Ω β⇴ Ω\n Ω-self-reduces = β\n\n Ω-no-normal-form : ¬ NormalForm(_β⇴_)(Ω)\n Ω-no-normal-form (intro p) = p(Ω-self-reduces)\n\n -- Also called: Church-Rosser's theorem.\n -- TODO: Seems like the proof can be a bit complicated?\n postulate β-star-confluence : ∀{d} → Confluence(_β⇴*_ {d})\n\n I-reduction : ((I ← x) β⇴ x)\n I-reduction = β\n\n K-reduction : ((K ← x ← y) β⇴* x)\n K-reduction {x}{y} = super(cong-applyₗ β) 🝖 super β -- 🝖 substitute₂ₗ(_β⇴*_) (symmetry(_≡_) (substitute-var-𝐒 {0}{x}{y})) refl\n\n 𝈲-reduction : ((𝈲 ← x ← y) β⇴* y)\n 𝈲-reduction {x}{y} = super(cong-applyₗ β) 🝖 super β\n\n B-reduction : ((B ← f ← g ← x) β⇴* (f ← (g ← x)))\n B-reduction = super(cong-applyₗ(cong-applyₗ β)) 🝖 super(cong-applyₗ β) 🝖 super β\n\n C-reduction : ((C ← f ← g ← x) β⇴* ((f ← x) ← g))\n C-reduction = super(cong-applyₗ(cong-applyₗ β)) 🝖 super(cong-applyₗ β) 🝖 super β\n\n S-reduction : ((S ← f ← g ← x) β⇴* ((f ← x) ← (g ← x)))\n S-reduction = super(cong-applyₗ(cong-applyₗ β)) 🝖 super(cong-applyₗ β) 🝖 super β\n\n Y-reduction : ∀{f} → ((Y ← f) β⥈* (f ← (Y ← f)))\n Y-reduction = super([∨]-introᵣ β) 🝖 super([∨]-introᵣ β) 🝖 super([∨]-introₗ(cong-applyᵣ β))\n\n module _ where\n open Boolean\n\n If-𝑇-reduction : ((If ← 𝑇 ← x ← y) β⇴* x)\n If-𝑇-reduction = super(cong-applyₗ(cong-applyₗ β)) 🝖 super(cong-applyₗ β) 🝖 super β 🝖 K-reduction\n\n If-𝐹-reduction : ((If ← 𝐹 ← x ← y) β⇴* y)\n If-𝐹-reduction = super(cong-applyₗ(cong-applyₗ β)) 🝖 super(cong-applyₗ β) 🝖 super β 🝖 𝈲-reduction\n\n module _ where\n open Tuple\n\n Pair-projₗ-reduction : (Projₗ ← (Pair ← x ← y)) β⇴* x\n Pair-projₗ-reduction = super β 🝖 super(cong-applyₗ(cong-applyₗ β)) 🝖 super(cong-applyₗ β) 🝖 super β 🝖 super(cong-applyₗ β) 🝖 super β\n\n Pair-projᵣ-reduction : (Projᵣ ← (Pair ← x ← y)) β⇴* y\n Pair-projᵣ-reduction = super β 🝖 super(cong-applyₗ(cong-applyₗ β)) 🝖 super(cong-applyₗ β) 🝖 super β 🝖 super(cong-applyₗ β) 🝖 super β\n\n module _ where\n open import Function.Iteration\n\n open Natural\n\n {-\n -- λ𝟎 β⇴* ℕrepr 𝟎\n λ𝐒-of-ℕrepr : (λ𝐒 ← ℕrepr(n)) β⇴* ℕrepr(𝐒(n))\n λ𝐒-of-ℕrepr = super {!cong-applyₗ ?!}\n\n ℕrepr-correctness : (((λ𝐒 ←_) ^ n) λ𝟎) β⇴* (ℕrepr n)\n ℕrepr-correctness {𝟎} = refl\n ℕrepr-correctness {𝐒 n} = super {!!} 🝖 super {!ℕrepr-correctness {n}!}\n -}\n", "meta": {"hexsha": "e4829da638f718f2e3639e3e63fe1881be656c97", "size": 4201, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Formalization/LambdaCalculus/Terms/Combinators.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Formalization/LambdaCalculus/Terms/Combinators.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Formalization/LambdaCalculus/Terms/Combinators.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.4420289855, "max_line_length": 136, "alphanum_fraction": 0.5931920971, "num_tokens": 1845, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430562234878, "lm_q2_score": 0.7577943712746406, "lm_q1q2_score": 0.6298355297301612}} {"text": "module Numeral.Sign where\n\nimport Lvl\nopen import Type\n\n-- The set of plus or minus sign\ndata +|− : Type{Lvl.𝟎} where\n ➕ : (+|−)\n ➖ : (+|−)\n\n−|+ = +|−\n\nelim₂ : ∀{ℓ}{P : (+|−) → Type{ℓ}} → P(➖) → P(➕) → ((s : (+|−)) → P(s))\nelim₂ neg pos ➖ = neg\nelim₂ neg pos ➕ = pos\n\n-- The set of signs: plus, minus and neutral\ndata +|0|− : Type{Lvl.𝟎} where\n ➕ : (+|0|−)\n 𝟎 : (+|0|−)\n ➖ : (+|0|−)\n\n−|0|+ = +|0|−\n\nelim₃ : ∀{ℓ}{P : (+|0|−) → Type{ℓ}} → P(➖) → P(𝟎) → P(➕) → ((s : (+|0|−)) → P(s))\nelim₃ neg zero pos ➖ = neg\nelim₃ neg zero pos 𝟎 = zero\nelim₃ neg zero pos ➕ = pos\n\nzeroable : (+|−) → (+|0|−)\nzeroable (➕) = (➕)\nzeroable (➖) = (➖)\n", "meta": {"hexsha": "692b0f532ce889d7bd6637e98e0c6f1044556c93", "size": 639, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Sign.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Sign.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Sign.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.3636363636, "max_line_length": 81, "alphanum_fraction": 0.4507042254, "num_tokens": 327, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382236515259, "lm_q2_score": 0.7310585786300048, "lm_q1q2_score": 0.6298349092181037}} {"text": "\n{-# OPTIONS --cubical-compatible #-}\n\nopen import Agda.Builtin.Nat\nopen import Agda.Builtin.Equality\n\ndata Fin : Nat → Set where\n zero : {n : Nat} → Fin (suc n)\n suc : {n : Nat} (i : Fin n) → Fin (suc n)\n\n-- From Data.Fin.Properties in the standard library (2016-12-30).\nsuc-injective : ∀ {o} {m n : Fin o} → Fin.suc m ≡ suc n → m ≡ n\nsuc-injective refl = refl\n", "meta": {"hexsha": "3406296e9336917a6b842a20046009cdc1661fdc", "size": 365, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1115.agda", "max_stars_repo_name": "KDr2/agda", "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/Succeed/Issue1115.agda", "max_issues_repo_name": "KDr2/agda", "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_forks_repo_path": "test/Succeed/Issue1115.agda", "max_forks_repo_name": "KDr2/agda", "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.0714285714, "max_line_length": 65, "alphanum_fraction": 0.6301369863, "num_tokens": 129, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8615382165412809, "lm_q2_score": 0.7310585844894971, "lm_q1q2_score": 0.6298349090682747}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Induction over _<_ for ℕᵇ.\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Nat.Binary.Induction where\n\nopen import Data.Nat.Binary.Base\nopen import Data.Nat.Binary.Properties\nopen import Data.Nat.Base as ℕ using (ℕ)\nimport Data.Nat.Induction as ℕ\nopen import Induction.WellFounded\n\n------------------------------------------------------------------------\n-- _<_ is wellFounded\n\n<-wellFounded : WellFounded _<_\n<-wellFounded x = Subrelation.accessible <⇒<ℕ toℕ[x]-acc\n where\n toℕ[x]-acc = InverseImage.accessible toℕ (ℕ.<-wellFounded (toℕ x))\n", "meta": {"hexsha": "13bdb874caca60e0436cd801c8172ed14a9bc745", "size": 726, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/Nat/Binary/Induction.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Data/Nat/Binary/Induction.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Data/Nat/Binary/Induction.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 30.25, "max_line_length": 72, "alphanum_fraction": 0.5123966942, "num_tokens": 162, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.86153820232079, "lm_q2_score": 0.7310585669110202, "lm_q1q2_score": 0.6298348835277333}} {"text": "data _≡_ {a} {A : Set a} (x : A) : A → Set a where\n refl : x ≡ x\n\nrecord Σ (A : Set) (B : A → Set) : Set where\n constructor _,_\n field\n proj₁ : A\n proj₂ : B proj₁\n\nopen Σ\n\npostulate\n I : Set\n U : I → Set\n El : ∀ {i} → U i → Set\n Ctxt : Set\n Env : Ctxt → Set\n\nType : Ctxt → Set\nType Γ = Σ I λ i → Env Γ → U i\n\nValue : (Γ : Ctxt) → Type Γ → Set\nValue Γ σ = (γ : Env Γ) → El (proj₂ σ γ)\n\n_/id : ∀ {Γ} → Type Γ → Type Γ\n(i , σ) /id = i , σ\n\ndata [Type] : Set where\n [_] : ∀ {Γ} → Type Γ → [Type]\n\n_≅-Type_ : ∀ {Γ} (σ₁ σ₂ : Type Γ) → Set\nσ₁ ≅-Type σ₂ = [ σ₁ ] ≡ [ σ₂ ]\n\ndata [Value] : Set where\n [_] : ∀ {Γ σ} → Value Γ σ → [Value]\n\n_≅-Value_ : ∀ {Γ σ} (v₁ v₂ : Value Γ σ) → Set\nv₁ ≅-Value v₂ = [Value].[ v₁ ] ≡ [ v₂ ]\n\nFoo : ∀ {Γ} {σ₁ σ₂ : Type Γ} {v : Value Γ (σ₁ /id)} →\n σ₁ ≅-Type σ₂ → v ≅-Value v → Set₁\nFoo refl refl = Set\n", "meta": {"hexsha": "f253ae6615d7c2eefb4b7f9dfb0258f474bb7ed4", "size": 848, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1872.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue1872.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue1872.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 19.7209302326, "max_line_length": 53, "alphanum_fraction": 0.483490566, "num_tokens": 399, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9136765187126079, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.6298023562735733}} {"text": "module Type.Dependent where\n\nimport Lvl\nopen import Type\n\nprivate\n module Module where\n -- Dependent product type (pi-type).\n -- Also called: Dependent function type.\n -- The right-hand side's type is a function type that uses the left-hand side's type as its \"domain\".\n -- And then the type of the resulting function of the two types depends on the argument.\n record Π {ℓ₁ ℓ₂} (A : Type{ℓ₁}) (B : A → Type{ℓ₂}) : Type{ℓ₁ Lvl.⊔ ℓ₂} where\n constructor intro\n field\n apply : (a : A) → B(a)\n\n -- Dependent sum type (sigma-type).\n -- Also called: Dependent pair type.\n -- The right-hand side's type is a function type that uses the left-hand side's type as its \"domain\".\n -- And then the type of the resulting pair depends on the left-hand side.\n record Σ {ℓ₁ ℓ₂} (A : Type{ℓ₁}) (B : A → Type{ℓ₂}) : Type{ℓ₁ Lvl.⊔ ℓ₂} where\n constructor intro\n field\n left : A\n right : B(left)\n\nℰ : ∀{ℓ₁ ℓ₂}{A : Type{ℓ₁}} → (A → Type{ℓ₂}) → Type{ℓ₁ Lvl.⊔ ℓ₂}\nℰ {A = A} B = Module.Σ A B\nmodule ℰ where\n pattern intro {left} right = Module.intro left right\n\nopen Module public\n{-# BUILTIN SIGMA Σ #-}\n", "meta": {"hexsha": "91bae74156478b4cbff5e1fe5d65faa3d0976423", "size": 1157, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Type/Dependent.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Type/Dependent.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Type/Dependent.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.0294117647, "max_line_length": 105, "alphanum_fraction": 0.6309420916, "num_tokens": 379, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681158979306, "lm_q2_score": 0.7341195385342971, "lm_q1q2_score": 0.6297043334124223}} {"text": "-- Andreas, 2016-12-15, issue #2341\n-- `with` needs to abstract also in sort of target type.\n\n-- {-# OPTIONS -v tc.with:100 #-}\n\nopen import Agda.Primitive\n\ndata _≡_ {a}{A : Set a} (x : A) : A → Set a where\n refl : x ≡ x\n\n{-# BUILTIN EQUALITY _≡_ #-}\n\npostulate\n equalLevel : (x y : Level) → x ≡ y\n\nid : ∀ {a} {A : Set a} → A → A\nid x = x\n\nWorks : ∀ β α → Set α → Set β\nWorks β α with equalLevel α β\nWorks β .β | refl = id\n\nCoerce : ∀ β α → Set α → Set β\nCoerce β α rewrite equalLevel α β = id\n\n-- Should succeed\n\n{-\nSet α →{1+β⊔α} Set β\nadded with function .Issue2341.rewrite-42 of type\n (β α w : Level) → w ≡ β → Set w → Set β\n\n (β α : Level) → (w : Level) →{1+β⊔α} w ≡ β →{1+β⊔α} Set w →{1+β⊔α} Set β\n\n raw with func. type = El {_getSort = Inf, unEl =\nPi ru(El {_getSort = Type (Max []), unEl = Def Agda.Primitive.Level []}) (Abs \"\\946\" El {_getSort = Inf, unEl =\nPi ru(El {_getSort = Type (Max []), unEl = Def Agda.Primitive.Level []}) (Abs \"\\945\"\n El {_getSort = Type (Max [Plus 1 (UnreducedLevel (Var 0 [])),Plus 1 (UnreducedLevel (Var 1 []))]), unEl =\nPi ru(El {_getSort = Type (Max []), unEl = Def Agda.Primitive.Level []}) (Abs \"w\"\n El {_getSort = Type (Max [Plus 1 (UnreducedLevel (Var 1 [])),Plus 1 (UnreducedLevel (Var 2 []))]), unEl =\nPi ru(El {_getSort = Type (Max []), unEl = Def Issue2341._≡_ [Apply ru{Level (Max [])},Apply ru{Def Agda.Primitive.Level []},Apply ru(Var 0 []),Apply ru(Var 2 [])]}) (NoAbs \"w\"\n El {_getSort = Type (Max [Plus 1 (UnreducedLevel (Var 1 [])),Plus 1 (UnreducedLevel (Var 2 []))]), unEl =\nPi ru(El {_getSort = Type (Max [Plus 1 (UnreducedLevel (Var 0 []))]), unEl = Sort (Type (Max [Plus 0 (UnreducedLevel (Var 0 []))]))}) (NoAbs \"_\"\n El {_getSort = Type (Max [Plus 1 (UnreducedLevel (Var 2 []))]), unEl =\nSort (Type (Max [Plus 0 (UnreducedLevel (Var 2 []))]))})})})})})}\n-}\n", "meta": {"hexsha": "0177f340255da9d603919f60ffc4f98c6b60f97c", "size": 1827, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue2341.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue2341.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue2341.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 38.8723404255, "max_line_length": 176, "alphanum_fraction": 0.5938697318, "num_tokens": 714, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681158979306, "lm_q2_score": 0.734119526900183, "lm_q1q2_score": 0.6297043234330502}} {"text": "open import Type\n\nmodule Relator.ReflexiveTransitiveClosure {ℓ₁ ℓ₂} {T : Type{ℓ₁}} (_▫_ : T → T → Type{ℓ₂}) where\n\nopen import Graph.Walk\nopen import Graph.Walk.Proofs\nimport Lvl\nopen import Logic\nopen import Logic.Propositional\nimport Structure.Relator.Names as Names\nopen import Structure.Relator.Properties\nopen import Syntax.Function\n\n-- Reflexive closure of a relation.\n-- Constructs a reflexive relation from an existing relation.\n-- Sometimes also notated ((_▫_) ∪ (_▫⁰_)) for a relation (_▫_).\ndata ReflexiveClosure : T → T → Type{ℓ₁ Lvl.⊔ ℓ₂} where\n super : Names.Subrelation(_▫_)(ReflexiveClosure)\n refl : Names.Reflexivity(ReflexiveClosure)\n\n-- Symmetric closure of a relation.\n-- Constructs a symmetric relation from an existing relation.\n-- Sometimes also notated (_▫⁻¹_) or (Converse(_▫_) ∪ (_▫_)) for a relation (_▫_).\nSymmetricClosure : T → T → Type{ℓ₂}\nSymmetricClosure a b = (b ▫ a) ∨ (a ▫ b)\n\n-- Reflexive-transitive closure of a relation.\n-- Constructs a reflexive and transitive relation from an existing relation.\n-- Sometimes also notated (_▫*_) for a relation (_▫_).\ndata ReflexiveTransitiveClosure : T → T → Type{ℓ₁ Lvl.⊔ ℓ₂} where\n super : Names.Subrelation(_▫_)(ReflexiveTransitiveClosure)\n refl : Names.Reflexivity(ReflexiveTransitiveClosure)\n trans : Names.Transitivity(ReflexiveTransitiveClosure)\ninfixl 1000 trans\n\n-- Transitive closure of a relation.\n-- Constructs a transitive relation from an existing relation.\n-- Sometimes also notated (_▫⁺_) for a relation (_▫_).\ndata TransitiveClosure : T → T → Type{ℓ₁ Lvl.⊔ ℓ₂} where\n super : Names.Subrelation(_▫_)(TransitiveClosure)\n trans : Names.Transitivity(TransitiveClosure)\n\nmodule _ where\n open import Numeral.Natural\n\n -- Sometimes also notated (_▫ⁿ_) for a relation (_▫_).\n data FiniteTransitiveClosure : ℕ → T → T → Type{ℓ₁ Lvl.⊔ ℓ₂} where\n base : ∀{a} → (a ▫ a) → (FiniteTransitiveClosure 𝟎 a a)\n step : ∀{a b c} → (a ▫ b) → ∀{n} → (FiniteTransitiveClosure n b c) → (FiniteTransitiveClosure (𝐒(n)) a c)\n\ninstance\n ReflexiveTransitiveClosure-reflexivity : Reflexivity(ReflexiveTransitiveClosure)\n ReflexiveTransitiveClosure-reflexivity = intro refl\n\ninstance\n ReflexiveTransitiveClosure-transitivity : Transitivity(ReflexiveTransitiveClosure)\n ReflexiveTransitiveClosure-transitivity = intro trans\n\n-- The \"prepend\"-property of reflexive-transitive closure\nReflexiveTransitiveClosure-prepend : ∀{a b c} → (a ▫ b) → ReflexiveTransitiveClosure b c → ReflexiveTransitiveClosure a c\nReflexiveTransitiveClosure-prepend ab bc = trans (super ab) bc\n\n-- A reflexive-transitive closure is the same as a path.\nReflexiveTransitiveClosure-Path-equivalence : ∀{a b} → (ReflexiveTransitiveClosure a b) ↔ (Walk(_▫_) a b)\nReflexiveTransitiveClosure-Path-equivalence = [↔]-intro l r where\n r : ∀{a b} → ReflexiveTransitiveClosure a b → Walk(_▫_) a b\n r ReflexiveTransitiveClosure.refl = reflexivity(Walk(_▫_))\n r (ReflexiveTransitiveClosure.super ab) = sub₂(_▫_)(Walk(_▫_)) ab\n r (ReflexiveTransitiveClosure.trans rab1 rb1b) = transitivity(Walk(_▫_)) (r rab1) (r rb1b)\n\n l : ∀{a b} → Walk(_▫_) a b → ReflexiveTransitiveClosure a b\n l Walk.at = ReflexiveTransitiveClosure.refl\n l (Walk.prepend ab1 sb1b) = ReflexiveTransitiveClosure-prepend ab1 (l sb1b)\n", "meta": {"hexsha": "6939d31b0c1d41cd0094013c1c942b7f22758744", "size": 3288, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Relator/ReflexiveTransitiveClosure.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Relator/ReflexiveTransitiveClosure.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Relator/ReflexiveTransitiveClosure.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.4324324324, "max_line_length": 121, "alphanum_fraction": 0.7381386861, "num_tokens": 1019, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577680904463333, "lm_q2_score": 0.7341195385342972, "lm_q1q2_score": 0.6297043147279076}} {"text": "{-# OPTIONS --cubical #-}\n\nmodule Type.Cubical.Path.Category{ℓ} where\n\nopen import Data.Tuple as Tuple using (_,_)\nopen import Data\nopen import Functional\nopen import Function.Axioms\nopen import Logic.Propositional\nopen import Structure.Category\nopen import Structure.Categorical.Properties\nopen import Structure.Operator\nopen import Structure.Relator.Properties\nopen import Type\nopen import Type.Cubical.Path\nopen import Type.Cubical.Path.Equality\nopen import Type.Properties.Singleton\n\n-- The type category is a category containing all types of a single universe level in the language.\n-- The objects are all sets/types.\n-- The morphisms are all functions where the domain/codomain-pair are from these objects.\ntypeFunctionPathCategory : Category{Obj = Type{ℓ}}(_→ᶠ_)\nCategory._∘_ typeFunctionPathCategory = _∘_\nCategory.id typeFunctionPathCategory = id\nMorphism.Associativity.proof (Category.associativity typeFunctionPathCategory) = reflexivity(Path)\nMorphism.Identityₗ.proof (Tuple.left (Category.identity typeFunctionPathCategory)) = reflexivity(Path)\nMorphism.Identityᵣ.proof (Tuple.right (Category.identity typeFunctionPathCategory)) = reflexivity(Path)\n\ntypeFunctionPathCategoryObject : CategoryObject\ntypeFunctionPathCategoryObject = intro typeFunctionPathCategory\n\nEmpty-initialObject : Object.Initial{Obj = Type{ℓ}}(_→ᶠ_) (Empty)\nIsUnit.unit Empty-initialObject = empty\nIsUnit.uniqueness (Empty-initialObject {T}) = functionExtensionality(Empty)(T) \\{}\n\nUnit-terminalObject : Object.Terminal{Obj = Type{ℓ}}(_→ᶠ_) (Unit)\nIsUnit.unit Unit-terminalObject = const <>\nIsUnit.uniqueness Unit-terminalObject = reflexivity(Path)\n", "meta": {"hexsha": "d725a9cb239328bd849ac45ac128ad6e5a9271da", "size": 1658, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Type/Cubical/Path/Category.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Type/Cubical/Path/Category.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Type/Cubical/Path/Category.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.5128205128, "max_line_length": 103, "alphanum_fraction": 0.8009650181, "num_tokens": 388, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9005297754396141, "lm_q2_score": 0.6992544335934766, "lm_q1q2_score": 0.629699438059088}} {"text": "module Cats.Category.Setoids where\n\nopen import Cats.Util.SetoidMorphism public using\n (_⇒_ ; _≈_ ; ≈-intro ; ≈-elim ; ≈-elim′ ; equiv ; _∘_ ; id ; ∘-resp ; assoc ; id-l\n ; id-r)\n\nopen import Level using (_⊔_ ; suc)\nopen import Relation.Binary using (Setoid)\n\nopen import Cats.Category.Base\nopen import Cats.Category.Sets using (Sets)\nopen import Cats.Util.Conv\n\n\ninstance\n HasArrow-⇒ : ∀ {l l≈} {A B : Setoid l l≈}\n → HasArrow (A ⇒ B) (suc l) l l\n HasArrow-⇒ {l} = record { Cat = Sets l ; _⃗ = _⇒_.arr }\n\n\nSetoids : ∀ l l≈ → Category (suc (l ⊔ l≈)) (l ⊔ l≈) (l ⊔ l≈)\nSetoids l l≈ = record\n { Obj = Setoid l l≈\n ; _⇒_ = λ A B → A ⇒ B\n ; _≈_ = _≈_\n ; id = id\n ; _∘_ = _∘_\n ; equiv = equiv\n ; ∘-resp = λ {A} {B} {C} {f} {g} {h} {i} → ∘-resp {f = f} {g} {h} {i}\n ; id-r = λ {A} {B} {f} → id-r {f = f}\n ; id-l = λ {A} {B} {f} → id-l {f = f}\n ; assoc = λ {A} {B} {C} {D} {f} {g} {h} → assoc {f = f} {g} {h}\n }\n", "meta": {"hexsha": "54044f1762c4c279e3b38cd1c27c902f83ce8ddc", "size": 945, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Category/Setoids.agda", "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cats/Category/Setoids.agda", "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cats/Category/Setoids.agda", "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.7941176471, "max_line_length": 84, "alphanum_fraction": 0.5058201058, "num_tokens": 430, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9005297861178929, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.6296994285940911}} {"text": "module Human.List where\n\nopen import Human.Nat\n\ninfixr 5 _,_\ndata List {a} (A : Set a) : Set a where\n end : List A\n _,_ : (x : A) (xs : List A) → List A\n\n{-# BUILTIN LIST List #-}\n\n{-# COMPILE JS List = function(x,v) { if (x.length < 1) { return v[\"[]\"](); } else { return v[\"_∷_\"](x[0], x.slice(1)); } } #-}\n{-# COMPILE JS end = Array() #-}\n{-# COMPILE JS _,_ = function (x) { return function(y) { return Array(x).concat(y); }; } #-}\n\nfoldr : ∀ {A : Set} {B : Set} → (A → B → B) → B → List A → B\nfoldr c n end = n\nfoldr c n (x , xs) = c x (foldr c n xs)\n\nlength : ∀ {A : Set} → List A → Nat\nlength = foldr (λ a n → suc n) zero\n", "meta": {"hexsha": "f83121ae1befbe9c6db4fba920d81f077b94ca04", "size": 637, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Human/List.agda", "max_stars_repo_name": "MaisaMilena/AgdaCalculator", "max_stars_repo_head_hexsha": "e977a5f2a005682cee123568b49462dd7d7b11ad", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-03-29T02:30:10.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-29T02:30:10.000Z", "max_issues_repo_path": "src/Human/List.agda", "max_issues_repo_name": "MaisaMilena/AgdaCalculator", "max_issues_repo_head_hexsha": "e977a5f2a005682cee123568b49462dd7d7b11ad", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Human/List.agda", "max_forks_repo_name": "MaisaMilena/AgdaCalculator", "max_forks_repo_head_hexsha": "e977a5f2a005682cee123568b49462dd7d7b11ad", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.9545454545, "max_line_length": 128, "alphanum_fraction": 0.5290423862, "num_tokens": 236, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513731336204, "lm_q2_score": 0.7025300698514778, "lm_q1q2_score": 0.6296435397720452}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Setoids.Setoids\nopen import Rings.Definition\nopen import Rings.IntegralDomains.Definition\nopen import Vectors\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import Numbers.Naturals.Definition\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\n\nmodule Rings.UniqueFactorisationDomains.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} {R : Ring S _+_ _*_} (intDom : IntegralDomain R) where\n\nopen import Rings.Units.Definition R\nopen import Rings.Irreducibles.Definition intDom\nopen import Rings.Associates.Definition intDom\nopen import Rings.Primes.Definition intDom\nopen Ring R\nopen Setoid S\n\nprivate\n power : A → ℕ → A\n power x zero = 1R\n power x (succ n) = x * power x n\n\n allDistinct : {n : ℕ} → Vec A n → Set (a ⊔ b)\n allDistinct [] = True'\n allDistinct (x ,- xs) = (allDistinct xs) && vecAllTrue (λ n → (n ∼ x) → False) xs\n\nrecord Factorisation {r : A} .(nonzero : (r ∼ 0R) → False) .(nonunit : (Unit r) → False) : Set (a ⊔ b) where\n field\n len : ℕ\n factorise : Vec (A && ℕ) len\n factoriseIsFactorisation : vecFold (λ x y → y * power (_&&_.fst x) (succ (_&&_.snd x))) 1R factorise ∼ r\n factoriseIsIrreducibles : vecAllTrue Irreducible (vecMap _&&_.fst factorise)\n distinct : allDistinct (vecMap _&&_.fst factorise)\n\nprivate\n equality : {n : ℕ} (v1 v2 : Vec (A && ℕ) n) → Set (a ⊔ b)\n equality [] [] = True'\n equality {succ n} ((a ,, an) ,- v1) v2 = Sg ℕ (λ index → Sg (index 1 = (le zero ()) ; pr = pr } pN+2 pN+4\nq1 {succ zero} record { p>1 = (le (succ x) ()) ; pr = pr } pN+2 pN+4\nq1 {succ (succ zero)} pN record { p>1 = p>1 ; pr = pr } pN+4 with pr {2} (divides (record { quot = 2 ; rem = zero ; pr = refl ; remIsSmall = inl (le 1 refl) ; quotSmall = inl (le 1 refl)}) refl) (le 1 refl) (le 1 refl)\nq1 {succ (succ zero)} pN record { p>1 = p>1 ; pr = pr } pN+4 | ()\nq1 {succ (succ (succ n))} pN pN+2 pN+4 with q1Lemma {succ (succ (succ n))} (le n (applyEquality succ (commutative n 2)))\nq1 {succ (succ (succ n))} pN pN+2 pN+4 | inl (inl 3|n) = equalityCommutative (primeDivPrimeImpliesEqual threeIsPrime pN 3|n)\nq1 {succ (succ (succ n))} pN pN+2 pN+4 | inl (inr 3|n+2) with primeDivPrimeImpliesEqual threeIsPrime pN+2 3|n+2\n... | bl rewrite commutative n 2 = exFalso (naughtE (succInjective (succInjective (succInjective bl))))\nq1 {succ (succ (succ n))} pN pN+2 pN+4 | inr 3|n+4 with primeDivPrimeImpliesEqual threeIsPrime pN+4 3|n+4\n... | bl rewrite commutative n 4 = exFalso (naughtE (succInjective (succInjective (succInjective bl))))\n\nq3Differences : ℕ → ℕ\nq3Differences a = 2 *N a\nq3Seq : (start : ℕ) → ℕ → ℕ\nq3Seq start zero = start\nq3Seq start (succ n) = q3Differences (succ n) +N q3Seq start n\nq3SeqFirst : take 5 (funcToSequence (q3Seq 41)) ≡ 41 ,- 43 ,- 47 ,- 53 ,- 61 ,- []\nq3SeqFirst = refl\nq3N : (start : ℕ) (a : ℕ) → q3Seq start a ≡ start +N (a +N (a *N a))\nq3N start zero = equalityCommutative (sumZeroRight start)\nq3N start (succ a) rewrite q3N start a | sumZeroRight a =\n from (succ (plus (plus (const a) (succ (const a))) (plus (const start) (plus (const a) (times (const a) (const a))))))\n to (plus (const start) (succ (plus (const a) (succ (plus (const a) (times (const a) (succ (const a))))))))\n by applyEquality (λ i → succ (succ i)) (transitivity (+Associative (a +N a) start _) (transitivity (transitivity (applyEquality (_+N (a +N a *N a)) (commutative (a +N a) start)) (equalityCommutative (+Associative start _ _))) (applyEquality (start +N_) (equalityCommutative (+Associative a a (a +N a *N a))))))\nq3NDivision : (start : ℕ) → start ∣ (q3Seq start start)\nq3NDivision 0 = aDivA 0\nq3NDivision (succ start) rewrite q3N (succ start) (succ start) = dividesBothImpliesDividesSum {succ start} {succ start} (aDivA (succ start)) (dividesBothImpliesDividesSum {succ start} {succ start} (aDivA (succ start)) (divides (record { quot = succ start ; rem = 0 ; pr = sumZeroRight _ ; remIsSmall = inl (succIsPositive start) ; quotSmall = inl (succIsPositive start) }) refl))\n\nq3 : (start : ℕ) → ((n : ℕ) → Prime (q3Seq start n)) → False\nq3 zero a with a 2\n... | record { p>1 = p>1 ; pr = pr } with pr {2} (divides (record { quot = 3 ; rem = 0 ; pr = refl ; remIsSmall = inl (le 1 refl) ; quotSmall = inl (le 1 refl) }) refl) (le 3 refl) (succIsPositive 1)\n... | ()\nq3 (succ zero) a with a 0\n... | record { p>1 = le zero () ; pr = pr }\n... | record { p>1 = le (succ x) () ; pr = pr }\nq3 (succ (succ start)) a with q3NDivision (succ (succ start))\n... | r with a (succ (succ start))\n... | s = compositeImpliesNotPrime (succ (succ start)) _ (succPreservesInequality (succIsPositive start)) (le (succ (succ start) +N ((start +N succ start) +N q3Seq (succ (succ start)) start)) (applyEquality (λ i → succ (succ i)) (from (succ (plus (plus (const start) (plus (plus (const start) (succ (const start))) (const (q3Seq (succ (succ start)) start)))) (succ (succ (const start))))) to plus (plus (const start) (succ (succ (plus (const start) zero)))) (succ (plus (plus (const start) (succ (plus (const start) zero))) (const (q3Seq (succ (succ start)) start)))) by applyEquality (λ i → succ (succ (succ (succ i)))) (transitivity (commutative _ start) (+Associative start start _))))) r s\n\nq3' : ((n : ℕ) → Prime (q3Seq 41 n)) → False\nq3' = q3 41\n\nq6 : {n : ℕ} → 3 ∣ (n *N n) → 3 ∣ n\nq6 {n} 3|n^2 with primesArePrime {3} {n} {n} threeIsPrime 3|n^2\nq6 {n} 3|n^2 | inl x = x\nq6 {n} 3|n^2 | inr x = x\n\n_*q10_ : {a : ℕ} → {b : ℕ} → (0 )\nopen import Data.Tuple as Tuple using (_⨯_ ; _,_)\nopen import Logic.Propositional\nopen import Structure.Setoid\nopen import Structure.Function\nopen import Structure.Operator\nopen import Structure.Relator.Equivalence\nopen import Structure.Relator.Properties\nopen import Type\n\nprivate variable ℓₒ ℓₒ₁ ℓₒ₂ ℓₒ₃ ℓₒ₄ ℓₑ ℓₑ₁ ℓₑ₂ ℓₑ₃ ℓₑ₄ : Lvl.Level\n\nmodule _ {A : Type{ℓₒ₁}} ⦃ _ : Equiv{ℓₑ₁}(A) ⦄ {B : Type{ℓₒ₂}} ⦃ _ : Equiv{ℓₑ₂}(B) ⦄ where\n instance\n Tuple-equiv : Equiv(A ⨯ B)\n _≡_ ⦃ Tuple-equiv ⦄ (x₁ , y₁) (x₂ , y₂) = (x₁ ≡ x₂) ∧ (y₁ ≡ y₂)\n Equiv-equivalence ⦃ Tuple-equiv ⦄ = intro where\n instance\n [≡]-reflexivity : Reflexivity(_≡_ ⦃ Tuple-equiv ⦄)\n Reflexivity.proof([≡]-reflexivity) = [∧]-intro (reflexivity(_≡_)) (reflexivity(_≡_))\n\n instance\n [≡]-symmetry : Symmetry(_≡_ ⦃ Tuple-equiv ⦄)\n Symmetry.proof([≡]-symmetry) ([∧]-intro l r) = [∧]-intro (symmetry(_≡_) l) (symmetry(_≡_) r)\n\n instance\n [≡]-transitivity : Transitivity(_≡_ ⦃ Tuple-equiv ⦄)\n Transitivity.proof([≡]-transitivity) ([∧]-intro l1 r1) ([∧]-intro l2 r2) = [∧]-intro (transitivity(_≡_) l1 l2) (transitivity(_≡_) r1 r2)\n\n instance\n left-function : Function(Tuple.left)\n Function.congruence left-function = Tuple.left\n\n instance\n right-function : Function(Tuple.right)\n Function.congruence right-function = Tuple.right\n\n instance\n [,]-function : BinaryOperator(_,_)\n BinaryOperator.congruence [,]-function a b = (a , b)\n\nmodule _ {A : Type{ℓₒ₁}} ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄ {B : Type{ℓₒ₂}} ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ where\n instance\n swap-function : Function ⦃ Tuple-equiv ⦃ equiv-A ⦄ ⦃ equiv-B ⦄ ⦄ ⦃ Tuple-equiv ⦄ (Tuple.swap)\n Function.congruence swap-function = Tuple.swap\n\nmodule _ {A : Type{ℓₒ}} ⦃ equiv : Equiv{ℓₑ}(A) ⦄ where\n instance\n repeat-function : Function(Tuple.repeat{A = A})\n Function.congruence repeat-function = Tuple.repeat\n\nmodule _\n {A₁ : Type{ℓₒ₁}} ⦃ equiv-A₁ : Equiv{ℓₑ₁}(A₁) ⦄\n {A₂ : Type{ℓₒ₂}} ⦃ equiv-A₂ : Equiv{ℓₑ₂}(A₂) ⦄\n {B₁ : Type{ℓₒ₃}} ⦃ equiv-B₁ : Equiv{ℓₑ₃}(B₁) ⦄\n {B₂ : Type{ℓₒ₄}} ⦃ equiv-B₂ : Equiv{ℓₑ₄}(B₂) ⦄\n {f : A₁ → A₂} ⦃ func-f : Function(f) ⦄\n {g : B₁ → B₂} ⦃ func-g : Function(g) ⦄\n where\n\n instance\n map-function : Function(Tuple.map f g)\n Function.congruence map-function = Tuple.map (congruence₁(f)) (congruence₁(g))\n\nmodule _\n {A : Type{ℓₒ₁}} ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄\n {B : Type{ℓₒ₂}} ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄\n {C : Type{ℓₒ₃}} ⦃ equiv-C : Equiv{ℓₑ₃}(C) ⦄\n where\n\n instance\n associateLeft-function : Function(Tuple.associateLeft {A = A}{B = B}{C = C})\n Function.congruence associateLeft-function = Tuple.associateLeft\n\n instance\n associateRight-function : Function(Tuple.associateRight {A = A}{B = B}{C = C})\n Function.congruence associateRight-function = Tuple.associateRight\n", "meta": {"hexsha": "17d9f8e8a651f5d4bebf493df6ee33958ab0769e", "size": 2918, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Tuple/Equivalence.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/Tuple/Equivalence.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Tuple/Equivalence.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.024691358, "max_line_length": 144, "alphanum_fraction": 0.6456477039, "num_tokens": 1195, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757869916479466, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.6293356265626624}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import Relation.Binary.PropositionalEquality as P\n\ndata Phantom {i} {A : Set i} (a : A) : Set where\n phantom : Phantom a\n\nmodule _ where\n private\n data #Σ-aux (A : Set) (B : A → Set) : Set where\n #pair : (x : A) → B x → #Σ-aux A B\n\n Σ : (A : Set) → (A → Set) → Set\n Σ A B = #Σ-aux A B\n\n pair : ∀ {A : Set} {B : A → Set} (x : A) → B x → Σ A B\n pair = #pair\n\n module ΣElim {A} {B} {S : Σ A B → Set}\n (pair* : ∀(a : A) (b : B a) → S (pair a b))\n where\n f-aux : Phantom pair* → (x : Σ A B) → S x\n f-aux x (#pair a b) = pair* a b\n\n f : (x : Σ A B) → S x\n f = f-aux phantom\n\nopen ΣElim public renaming (f to Σ-elim)\n\nΣ-rec : ∀ {A} {B} {S : Set} → ((x : A) → B x → S) → Σ A B → S\nΣ-rec f = Σ-elim f\n\nisΣ-hom : ∀ {A B} {S : Set} (α : (a : A) → B a → S) →\n (Σ A B → S) → Set\nisΣ-hom α f = ∀ a b → f (pair a b) ≡ α a b\n\nΣ-rec-unique : ∀ {A B S} {α : (a : A) → B a → S} {f : Σ A B → S} → isΣ-hom α f →\n ∀ x → f x ≡ Σ-rec α x\nΣ-rec-unique f-hom = Σ-elim f-hom\n\nπ₁ : ∀ {A B} → Σ A B → A\nπ₁ = Σ-rec (λ a _ → a)\n\nπ₂ : ∀ {A B} → (x : Σ A B) → B (π₁ x)\nπ₂ = Σ-elim (λ a b → b)\n\nrecord ΣRecStruct (A : Set) (B : A → Set) : Set₁ where\n field\n Carrier : Set\n inj : (a : A) → B a → Carrier\n rec : ∀{S : Set} → ((a : A) → B a → S) → Carrier → S\n rec-hom : ∀ {S : Set} (α : (a : A) → B a → S) →\n (∀ a b → rec α (inj a b) ≡ α a b)\n rec-unique : ∀ {S : Set} {α : (a : A) → B a → S} {f : Carrier → S} →\n (∀ a b → f (inj a b) ≡ α a b) →\n ∀ x → f x ≡ rec α x\n-- open ΣRecStruct public\n\nΣ-ΣRecStruct : ∀ A B → ΣRecStruct A B\nΣ-ΣRecStruct A B = record\n { Carrier = Σ A B\n ; inj = pair\n ; rec = Σ-rec\n ; rec-hom = λ α a b → refl\n ; rec-unique = Σ-rec-unique\n }\n\nΣRecStruct-HasInduction : ∀{A B} → ΣRecStruct A B → Set₁\nΣRecStruct-HasInduction {A} {B} R =\n ∀ {S : Carrier → Set} (inj* : ∀(a : A) (b : B a) → S (inj a b)) →\n (x : Carrier) → S x\n where open ΣRecStruct R\n\n\n-- I don't think that this is provable without resorting to π₂.\n-- But I also conjecture that internally the negation is neither\n-- provable.\n∀ΣRecStruct-haveInduction : ∀{A B} (R : ΣRecStruct A B) →\n ΣRecStruct-HasInduction R\n∀ΣRecStruct-haveInduction R {S} inj* x = {!!}\n where\n open ΣRecStruct R\n\n S-aux : Set\n S-aux = Σ Carrier S\n\n f : Carrier → S-aux\n f = rec (λ a b → pair (inj a b) (inj* a b))\n", "meta": {"hexsha": "b8a9ecd9b2e7e2a58d01ea8dca5ff00360117580", "size": 2454, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "TypeTheory/Sigma-Induction.agda", "max_stars_repo_name": "hbasold/Sandbox", "max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "TypeTheory/Sigma-Induction.agda", "max_issues_repo_name": "hbasold/Sandbox", "max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TypeTheory/Sigma-Induction.agda", "max_forks_repo_name": "hbasold/Sandbox", "max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.5730337079, "max_line_length": 80, "alphanum_fraction": 0.4861450693, "num_tokens": 1064, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757869948899666, "lm_q2_score": 0.7185943925708562, "lm_q1q2_score": 0.6293356236144111}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Category.Monoidal.Construction.Minus2 where\n\n-- Any -2-Category is Monoidal. Of course, One is Monoidal, but\n-- we don't need to shrink to do this, it can be done directly.\n-- The assumptions in the construction of a -2-Category are all\n-- needed to make things work properly.\n\nopen import Data.Product using (proj₁; proj₂)\n\nopen import Categories.Minus2-Category\nopen import Categories.Category.Monoidal\nimport Categories.Morphism as M\n\n-- Doing it manually is just as easy as going through Cartesian here\n-2-Monoidal : ∀ {o ℓ e} → (C : -2-Category {o} {ℓ} {e}) → Monoidal (-2-Category.cat C)\n-2-Monoidal C = record\n { ⊗ = record\n { F₀ = proj₁\n ; F₁ = proj₁\n ; identity = Hom-Conn\n ; homomorphism = Hom-Conn\n ; F-resp-≈ = λ _ → Hom-Conn\n }\n ; unit = proj₁ Obj-Contr\n ; unitorˡ = λ {X} → proj₂ Obj-Contr X\n ; unitorʳ = M.≅.refl cat\n ; associator = M.≅.refl cat\n ; unitorˡ-commute-from = Hom-Conn\n ; unitorˡ-commute-to = Hom-Conn\n ; unitorʳ-commute-from = Hom-Conn\n ; unitorʳ-commute-to = Hom-Conn\n ; assoc-commute-from = Hom-Conn\n ; assoc-commute-to = Hom-Conn\n ; triangle = Hom-Conn\n ; pentagon = Hom-Conn\n }\n where\n open -2-Category C\n", "meta": {"hexsha": "5c8d655828961c270eeeb76b4d5291097b569bf0", "size": 1228, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Monoidal/Construction/Minus2.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/Monoidal/Construction/Minus2.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/Monoidal/Construction/Minus2.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 29.9512195122, "max_line_length": 86, "alphanum_fraction": 0.6701954397, "num_tokens": 406, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9263037241905732, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.6291257584370755}} {"text": "open import Algebra using (CommutativeMonoid)\nopen import Relation.Binary.Structures using (IsEquivalence)\nopen import Relation.Binary.PropositionalEquality using () renaming (cong to ≡-cong)\n\nmodule AKS.Exponentiation {c ℓ} (M : CommutativeMonoid c ℓ) where\n\nopen import AKS.Nat using (ℕ; _+_; _<_)\nopen ℕ\nopen import AKS.Nat using (ℕ⁺; ℕ+; ⟅_⇓⟆)\nopen import AKS.Nat using (Acc; acc; <-well-founded)\nopen import AKS.Binary using (2*; 𝔹; 𝔹⁺; ⟦_⇑⟧; ⟦_⇓⟧; ⟦_⇑⟧⁺; ⟦_⇓⟧⁺; ℕ→𝔹→ℕ; ⌈log₂_⌉)\nopen 𝔹\nopen 𝔹⁺\nopen CommutativeMonoid M\n using (_≈_; isEquivalence; setoid; ε; _∙_; ∙-cong; ∙-congˡ; identityˡ; identityʳ; assoc; comm)\n renaming (Carrier to C)\nopen IsEquivalence isEquivalence using (refl; sym)\nopen import Relation.Binary.Reasoning.Setoid setoid\n\n_^ⁱ_ : C → ℕ → C\nx ^ⁱ zero = ε\nx ^ⁱ suc n = x ∙ x ^ⁱ n\n\n^ⁱ-homo : ∀ x n m → x ^ⁱ (n + m) ≈ x ^ⁱ n ∙ x ^ⁱ m\n^ⁱ-homo x zero m = sym (identityˡ (x ^ⁱ m))\n^ⁱ-homo x (suc n) m = begin\n x ∙ x ^ⁱ (n + m) ≈⟨ ∙-congˡ (^ⁱ-homo x n m) ⟩\n x ∙ (x ^ⁱ n ∙ x ^ⁱ m) ≈⟨ sym (assoc _ _ _) ⟩\n x ∙ x ^ⁱ n ∙ x ^ⁱ m ∎\n\n∙-^ⁱ-dist : ∀ x y n → (x ∙ y) ^ⁱ n ≈ x ^ⁱ n ∙ y ^ⁱ n\n∙-^ⁱ-dist x y zero = sym (identityˡ ε)\n∙-^ⁱ-dist x y (suc n) = begin\n x ∙ y ∙ ((x ∙ y) ^ⁱ n) ≈⟨ ∙-congˡ (∙-^ⁱ-dist x y n) ⟩\n x ∙ y ∙ (x ^ⁱ n ∙ y ^ⁱ n) ≈⟨ assoc _ _ _ ⟩\n x ∙ (y ∙ (x ^ⁱ n ∙ y ^ⁱ n)) ≈⟨ ∙-congˡ (comm _ _) ⟩\n x ∙ (x ^ⁱ n ∙ y ^ⁱ n ∙ y) ≈⟨ ∙-congˡ (assoc _ _ _) ⟩\n x ∙ (x ^ⁱ n ∙ (y ^ⁱ n ∙ y)) ≈⟨ ∙-congˡ (∙-congˡ (comm _ _)) ⟩\n x ∙ (x ^ⁱ n ∙ (y ∙ y ^ⁱ n)) ≈⟨ sym (assoc _ _ _) ⟩\n x ∙ (x ^ⁱ n) ∙ (y ∙ (y ^ⁱ n)) ∎\n\n_^ᵇ⁺_ : C → 𝔹⁺ → C\nx ^ᵇ⁺ 𝕓1ᵇ = x\nx ^ᵇ⁺ (b 0ᵇ) = (x ∙ x) ^ᵇ⁺ b\nx ^ᵇ⁺ (b 1ᵇ) = x ∙ (x ∙ x) ^ᵇ⁺ b\n\n_^ᵇ_ : C → 𝔹 → C\nx ^ᵇ 𝕓0ᵇ = ε\nx ^ᵇ (+ b) = x ^ᵇ⁺ b\n\n_^⁺_ : C → ℕ⁺ → C\nx ^⁺ n = x ^ᵇ⁺ ⟦ n ⇑⟧⁺\n\n_^_ : C → ℕ → C\nx ^ n = x ^ᵇ ⟦ n ⇑⟧\n\nx^n≈x^ⁱn : ∀ x n → x ^ n ≈ x ^ⁱ n\nx^n≈x^ⁱn x n = begin\n x ^ n ≈⟨ loop x ⟦ n ⇑⟧ ⟩\n x ^ⁱ ⟦ ⟦ n ⇑⟧ ⇓⟧ ≡⟨ ≡-cong (λ t → x ^ⁱ t) (ℕ→𝔹→ℕ n) ⟩\n x ^ⁱ n ∎\n where\n even : ∀ x b → (x ∙ x) ^ᵇ⁺ b ≈ x ^ⁱ 2* ⟦ b ⇓⟧⁺\n loop⁺ : ∀ x b → x ^ᵇ⁺ b ≈ x ^ⁱ ⟦ b ⇓⟧⁺\n\n even x b = begin\n (x ∙ x) ^ᵇ⁺ b ≈⟨ loop⁺ (x ∙ x) b ⟩\n (x ∙ x) ^ⁱ ⟦ b ⇓⟧⁺ ≈⟨ ∙-^ⁱ-dist x x ⟦ b ⇓⟧⁺ ⟩\n x ^ⁱ ⟦ b ⇓⟧⁺ ∙ x ^ⁱ ⟦ b ⇓⟧⁺ ≈⟨ sym (^ⁱ-homo x ⟦ b ⇓⟧⁺ ⟦ b ⇓⟧⁺) ⟩\n x ^ⁱ 2* ⟦ b ⇓⟧⁺ ∎\n\n loop⁺ x 𝕓1ᵇ = sym (identityʳ x)\n loop⁺ x (b 0ᵇ) = even x b\n loop⁺ x (b 1ᵇ) = ∙-congˡ (even x b)\n\n loop : ∀ x b → x ^ᵇ b ≈ x ^ⁱ ⟦ b ⇓⟧\n loop x 𝕓0ᵇ = refl\n loop x (+ b) = loop⁺ x b\n\n^-homo : ∀ x n m → x ^ (n + m) ≈ x ^ n ∙ x ^ m\n^-homo x n m = begin\n x ^ (n + m) ≈⟨ x^n≈x^ⁱn x (n + m) ⟩\n x ^ⁱ (n + m) ≈⟨ ^ⁱ-homo x n m ⟩\n x ^ⁱ n ∙ x ^ⁱ m ≈⟨ ∙-cong (sym (x^n≈x^ⁱn x n)) (sym (x^n≈x^ⁱn x m)) ⟩\n x ^ n ∙ x ^ m ∎\n\nx^n≈x^⁺n : ∀ x n → x ^ ⟅ n ⇓⟆ ≈ x ^⁺ n\nx^n≈x^⁺n x (ℕ+ n) = refl\n\n^-^⁺-homo : ∀ x n m → x ^ (n + ⟅ m ⇓⟆) ≈ x ^ n ∙ x ^⁺ m\n^-^⁺-homo x n (ℕ+ m) = ^-homo x n (suc m)\n", "meta": {"hexsha": "e22f1821f0125cf31d31849138b8d8399bf76f83", "size": 2799, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "proofs/AKS/Exponentiation.agda", "max_stars_repo_name": "mckeankylej/thesis", "max_stars_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-12-01T22:38:27.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-01T22:38:27.000Z", "max_issues_repo_path": "proofs/AKS/Exponentiation.agda", "max_issues_repo_name": "mckeankylej/thesis", "max_issues_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "proofs/AKS/Exponentiation.agda", "max_forks_repo_name": "mckeankylej/thesis", "max_forks_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.4239130435, "max_line_length": 96, "alphanum_fraction": 0.459092533, "num_tokens": 1797, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872045937171068, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.6290450325274586}} {"text": "-- Andreas, 2019-07-15, issue #3901, requested by msuperdock\n--\n-- Allow function spaces {A} → B and {{A}} → B.\n\npostulate\n A B : Set\n foo : {{A}} → B\n bar : {A} → B\n\n-- Original feature request:\n\nopen import Agda.Builtin.Unit using (⊤; tt)\n\ndata ⊥ : Set where\n\ndata Nat : Set where\n zero : Nat\n suc : Nat → Nat\n\n_≤_ : Nat → Nat → Set\nzero ≤ _ = ⊤\nsuc m ≤ zero = ⊥\nsuc m ≤ suc n = m ≤ n\n\ndata SList (bound : Nat) : Set where\n [] : SList bound\n scons : (head : Nat)\n → {head ≤ bound} -- here: anonymous binding\n → (tail : SList head)\n → SList bound\n\nxs : SList zero\nxs = scons zero []\n", "meta": {"hexsha": "24ce98700ee5257f9dec3229083b29ad6bd96f4a", "size": 631, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue3901.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue3901.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue3901.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 18.5588235294, "max_line_length": 60, "alphanum_fraction": 0.5499207607, "num_tokens": 225, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8872045847699186, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.62904503163875}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Lists defined in terms of the reflexive-transitive closure, Star\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Star.List where\n\nopen import Data.Star.Nat\nopen import Data.Unit\nopen import Relation.Binary.Construct.Always using (Always)\nopen import Relation.Binary.Construct.Constant using (Const)\nopen import Relation.Binary.Construct.Closure.ReflexiveTransitive\n\n-- Lists.\n\nList : ∀ {a} → Set a → Set a\nList A = Star (Const A) tt tt\n\n-- Nil and cons.\n\n[] : ∀ {a} {A : Set a} → List A\n[] = ε\n\ninfixr 5 _∷_\n\n_∷_ : ∀ {a} {A : Set a} → A → List A → List A\n_∷_ = _◅_\n\n-- The sum of the elements in a list containing natural numbers.\n\nsum : List ℕ → ℕ\nsum = fold (Star Always) _+_ zero\n", "meta": {"hexsha": "379f1b0e682238d5b73fbb8986bc6d8d82d62ba5", "size": 865, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Star/List.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Star/List.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Star/List.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 24.0277777778, "max_line_length": 72, "alphanum_fraction": 0.5664739884, "num_tokens": 217, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467738423873, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.6289627031567191}} {"text": "-- 2018-01-05, Jesper: having a `rewrite` after a `with` caused problems\n-- because the patterns stripped by with-desugaring were not propagated\n-- to the generated rewrite-clause. This should now be fixed.\n\nopen import Agda.Builtin.Equality\n\npostulate\n lem : Set ≡ Set\n\nsimple-test : {A : Set₁} → A ≡ Set → Set₁\nsimple-test {A = A} refl with Set\nsimple-test {A = A} refl | _ rewrite lem = A\n\n\nrecord ⊤ : Set where constructor tt\n\ndata G : Set → Set₁ where\n d : (A : Set) → G A → G A\n\npostulate\n exists : (A : Set) → G A\n unique : (A : Set) (x : G A) → exists A ≡ x\n\ntest : (A : Set) → G A → ⊤\ntest _ (d A x) with unique A x\ntest _ (d A _) | refl rewrite refl {x = tt} = tt\n", "meta": {"hexsha": "f0f03b8d17c62cf0128660ffe31970cee6869b58", "size": 678, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/RewriteAfterWithStripping.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/RewriteAfterWithStripping.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/RewriteAfterWithStripping.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 25.1111111111, "max_line_length": 72, "alphanum_fraction": 0.6371681416, "num_tokens": 230, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467675095292, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.6289626879575427}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Data.FinData.Base where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\n\nimport Cubical.Data.Empty as ⊥\nopen import Cubical.Data.Nat using (ℕ; zero; suc)\nopen import Cubical.Data.Bool.Base\nopen import Cubical.Relation.Nullary\n\nprivate\n variable\n ℓ : Level\n A B : Type ℓ\n\ndata Fin : ℕ → Type₀ where\n zero : {n : ℕ} → Fin (suc n)\n suc : {n : ℕ} (i : Fin n) → Fin (suc n)\n\ntoℕ : ∀ {n} → Fin n → ℕ\ntoℕ zero = 0\ntoℕ (suc i) = suc (toℕ i)\n\nfromℕ : (n : ℕ) → Fin (suc n)\nfromℕ zero = zero\nfromℕ (suc n) = suc (fromℕ n)\n\n¬Fin0 : ¬ Fin 0\n¬Fin0 ()\n\n_==_ : ∀ {n} → Fin n → Fin n → Bool\nzero == zero = true\nzero == suc _ = false\nsuc _ == zero = false\nsuc m == suc n = m == n\n\npredFin : {n : ℕ} → Fin (suc (suc n)) → Fin (suc n)\npredFin zero = zero\npredFin (suc x) = x\n\nfoldrFin : ∀ {n} → (A → B → B) → B → (Fin n → A) → B\nfoldrFin {n = zero} _ b _ = b\nfoldrFin {n = suc n} f b l = f (l zero) (foldrFin f b (l ∘ suc))\n\nelim\n : ∀(P : ∀{k} → Fin k → Type ℓ)\n → (∀{k} → P {suc k} zero)\n → (∀{k} → {fn : Fin k} → P fn → P (suc fn))\n → {k : ℕ} → (fn : Fin k) → P fn\n\nelim P fz fs {zero} = ⊥.rec ∘ ¬Fin0\nelim P fz fs {suc k} zero = fz\nelim P fz fs {suc k} (suc fj) = fs (elim P fz fs fj)\n\n\nrec : ∀{k} → (a0 aS : A) → Fin k → A\nrec a0 aS zero = a0\nrec a0 aS (suc x) = aS\n", "meta": {"hexsha": "eae4309f9369664a7992896cb409095510842237", "size": 1376, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/FinData/Base.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/FinData/Base.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/Data/FinData/Base.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.9333333333, "max_line_length": 64, "alphanum_fraction": 0.5603197674, "num_tokens": 585, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744806385542, "lm_q2_score": 0.7690802423634963, "lm_q1q2_score": 0.6287803797197088}} {"text": "\ndata Nat : Set where\n zero : Nat\n suc : Nat → Nat\n\npattern plus-two n = suc (suc n)\n\nf : Nat → Nat\nf (plus-two n) = f n\nf (suc zero) = plus-two zero\nf zero = zero\n", "meta": {"hexsha": "327c8a660b30169194ff9ee7752ed8243748c195", "size": 167, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue758.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/interaction/Issue758.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/interaction/Issue758.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 13.9166666667, "max_line_length": 32, "alphanum_fraction": 0.5928143713, "num_tokens": 63, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8991213772699436, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.628714598124448}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import HoTT\nopen import cohomology.Exactness\nopen import cohomology.Theory\n\nmodule cohomology.Sn {i} (OT : OrdinaryTheory i) where\n\nopen OrdinaryTheory OT\n\nC-Sphere-≠ : (n : ℤ) (m : ℕ) → (n ≠ ℕ-to-ℤ m)\n → C n (⊙Lift (⊙Sphere m)) == Lift-Unit-group\nC-Sphere-≠ n O neq = C-dimension n neq\nC-Sphere-≠ n (S m) neq =\n C n (⊙Lift (⊙Sphere (S m)))\n =⟨ ! $ ⊙Susp-⊙Lift (⊙Sphere m) |in-ctx C n ⟩\n C n (⊙Susp (⊙Lift (⊙Sphere m)))\n =⟨ ! (succ-pred n) |in-ctx (λ k → C k (⊙Susp (⊙Lift (⊙Sphere m)))) ⟩\n C (succ (pred n)) (⊙Susp (⊙Lift (⊙Sphere m)))\n =⟨ group-ua (C-Susp (pred n) (⊙Lift (⊙Sphere m))) ⟩\n C (pred n) (⊙Lift (⊙Sphere m))\n =⟨ C-Sphere-≠ (pred n) m (λ p → neq (pred-injective n (ℕ-to-ℤ (S m)) p)) ⟩\n Lift-Unit-group\n ∎\n\nC-Sphere-diag : (m : ℕ) → C (ℕ-to-ℤ m) (⊙Lift (⊙Sphere m)) == C 0 (⊙Lift ⊙S⁰)\nC-Sphere-diag O = idp\nC-Sphere-diag (S m) =\n C (ℕ-to-ℤ (S m)) (⊙Lift (⊙Sphere (S m)))\n =⟨ ! $ ⊙Susp-⊙Lift (⊙Sphere m) |in-ctx C (ℕ-to-ℤ (S m)) ⟩\n C (ℕ-to-ℤ (S m)) (⊙Susp (⊙Lift (⊙Sphere m)))\n =⟨ group-ua (C-Susp (ℕ-to-ℤ m) (⊙Lift (⊙Sphere m))) ⟩\n C (ℕ-to-ℤ m) (⊙Lift (⊙Sphere m))\n =⟨ C-Sphere-diag m ⟩\n C 0 (⊙Lift ⊙S⁰)\n ∎\n", "meta": {"hexsha": "76fcca1a137dc97cf374e063f3af451cbb254c66", "size": 1190, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/cohomology/Sn.agda", "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "theorems/cohomology/Sn.agda", "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "theorems/cohomology/Sn.agda", "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.1621621622, "max_line_length": 78, "alphanum_fraction": 0.5327731092, "num_tokens": 638, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9032942067038784, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.6286551288063895}} {"text": "\nmodule Foundation.Semigroup where\n\nopen import Foundation.Primitive\nopen import Foundation.Equivalence\nopen import Agda.Primitive\n\nrecord IsAssociative {a} {A : Set a} {ℓ} ⦃ _ : Equivalence A ℓ ⦄ (_∙_ : A → A → A) : ℞ a ⊔ ℓ where\n field\n associativity : ∀ x y z → ((x ∙ y) ∙ z) ≈ (x ∙ (y ∙ z))\n\nopen IsAssociative ⦃ … ⦄\n\nrecord Semigroup {c} (A : Set c) ℓ : Set (c ⊔ ⟰ ℓ) where\n field\n ⦃ equivalence ⦄ : Equivalence A ℓ\n _∙_ : A → A → A\n isAssociative : IsAssociative _∙_\n\nopen Semigroup ⦃ … ⦄\n\nrecord Monoid {a} (A : Set a) ℓ : Set (a ⊔ ⟰ ℓ) where\n field\n ⦃ semigroup ⦄ : Semigroup A ℓ\n ε : A\n left-identity : ∀ x → ε ∙ x ≈ x\n right-identity : ∀ x → x ∙ ε ≈ x\n\nopen Monoid ⦃ … ⦄\n\nopen import Relation.Binary.Core\nopen import Algebra.FunctionProperties.Core\n\nPowerRightIdentity : ∀ {a ℓ} {A : Set a} → Rel A ℓ → ∀ {b} {B : Set b} → B → (B → A → A) → Set _\nPowerRightIdentity _≈_ e _◃_ = ∀ x → (e ◃ x) ≈ x\n\nPowerAssociative : ∀ {a b ℓ} {A : Set a} {B : Set b} → (A → A → Set ℓ) → (B → A → A) → (B → B → B) → Set _\nPowerAssociative _≈_ _◃_ _∙_ = ∀ x a b → ((b ∙ a) ◃ x) ≈ (b ◃ (a ◃ x))\n\n_over_ : ∀ {f} {F : Set f} {g} → (F → F → Set g) → ∀ {i} {I : Set i} {a} {A : Set a} → (A → I → F) → A → A → Set (i ⊔ g)\n_*_ over f = λ x y → ∀ i → f x i * f y i\n\nrecord IsMonoidTransformer {s ℓˢ} {S : Set s} (≈ˢ : Rel S ℓˢ) {m ℓᵐ} {M : Set m} (≈ᵐ : Rel M ℓᵐ) (∙ : Op₂ M) (ε : M) (◃ : M → S → S) : Set (s ⊔ ℓˢ ⊔ m ⊔ ℓᵐ) where\n field\n ◃-identity : PowerRightIdentity ≈ˢ ε ◃\n ≈ˢ-over-◃-⟶-≈ᵐ : ≈ˢ over ◃ ⇒ ≈ᵐ\n ≈ᵐ-to-≈ˢ-over-◃ : ≈ᵐ ⇒ ≈ˢ over ◃\n ◃-extracts-∙ : PowerAssociative ≈ˢ ◃ ∙\n\nopen IsMonoidTransformer ⦃ … ⦄\n\nrecord MonoidTransformer {s} (S : Set s) ℓˢ {m} (M : Set m) ℓᵐ : Set (s ⊔ m ⊔ lsuc (ℓˢ ⊔ ℓᵐ)) where\n field\n ⦃ base ⦄ : Equivalence S ℓˢ\n ⦃ exponent ⦄ : Monoid M ℓᵐ\n\n infixl 6 _◃_\n field\n _◃_ : M → S → S\n instance isMonoidTransformer : IsMonoidTransformer _≈_ _≈_ _∙_ ε _◃_\n", "meta": {"hexsha": "17c8cc87ac8007ce29afdb572ae3ad184d7cd4b0", "size": 1927, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-1/Foundation/Semigroup.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-1/Foundation/Semigroup.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-1/Foundation/Semigroup.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.5901639344, "max_line_length": 162, "alphanum_fraction": 0.5412558381, "num_tokens": 934, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9032941988938413, "lm_q2_score": 0.6959583124210896, "lm_q1q2_score": 0.6286551062819179}} {"text": "module Structure.Groupoid.Functor where\n\nopen import Functional using (_on₂_)\nopen import Lang.Instance\nimport Lvl\nopen import Logic.Predicate\nopen import Structure.Category\nimport Structure.Category.Functor as Category\nopen import Structure.Function\nopen import Structure.Groupoid\nimport Structure.Relator.Names as Names\nopen import Structure.Setoid\nopen import Syntax.Function\nopen import Type\n\nprivate variable ℓ ℓₒ ℓₘ ℓₗₒ ℓₗₘ ℓᵣₒ ℓᵣₘ ℓₑ ℓₗₑ ℓᵣₑ : Lvl.Level\nprivate variable Obj Objₗ Objᵣ : Type{ℓ}\nprivate variable _⟶_ _⟶ₗ_ _⟶ᵣ_ : Objₗ → Objᵣ → Type{ℓ}\n\nmodule _\n ⦃ morphism-equivₗ : ∀{x y : Objₗ} → Equiv{ℓₗₑ}(x ⟶ₗ y) ⦄\n ⦃ morphism-equivᵣ : ∀{x y : Objᵣ} → Equiv{ℓᵣₑ}(x ⟶ᵣ y) ⦄\n (Groupoidₗ : Groupoid(_⟶ₗ_))\n (Groupoidᵣ : Groupoid(_⟶ᵣ_))\n where\n\n -- A covariant functor.\n -- A mapping which transforms objects and morphisms from one category to another while \"preserving\" the groupoid structure.\n -- A homomorphism between groupoids.\n record Functor (F : Objₗ → Objᵣ) : Type{Lvl.of(Type.of(Groupoidₗ)) Lvl.⊔ Lvl.of(Type.of(Groupoidᵣ))} where\n constructor intro\n open Groupoid ⦃ … ⦄\n\n private instance _ = Groupoidₗ\n private instance _ = Groupoidᵣ\n\n field\n map : Names.Subrelation(_⟶ₗ_) ((_⟶ᵣ_) on₂ F)\n\n field\n ⦃ map-function ⦄ : ∀{x y} → Function(map{x}{y})\n ⦃ op-preserving ⦄ : ∀{x y z : Objₗ}{f : y ⟶ₗ z}{g : x ⟶ₗ y} → (map(f ∘ g) ≡ map(f) ∘ map(g))\n ⦃ inv-preserving ⦄ : ∀{x y : Objₗ}{f : x ⟶ₗ y} → (map(inv f) ≡ inv(map f))\n ⦃ id-preserving ⦄ : ∀{x : Objₗ} → (map(id {x = x}) ≡ id)\n\n categoryFunctor : Category.Functor(category ⦃ r = Groupoidₗ ⦄)(category ⦃ r = Groupoidᵣ ⦄) (F)\n Category.Functor.map categoryFunctor = map\n Category.Functor.map-function categoryFunctor = map-function\n Category.Functor.op-preserving categoryFunctor = op-preserving\n Category.Functor.id-preserving categoryFunctor = id-preserving\n open Category.Functor(categoryFunctor) public hiding (map ; map-function ; op-preserving ; id-preserving)\n\nmodule _\n ⦃ morphism-equiv : ∀{x y : Obj} → Equiv{ℓₑ}(x ⟶ y) ⦄\n (Groupoid : Groupoid(_⟶_))\n where\n\n Endofunctor = Functor(Groupoid)(Groupoid)\n module Endofunctor = Functor{Groupoidₗ = Groupoid}{Groupoidᵣ = Groupoid}\n\n_→ᶠᵘⁿᶜᵗᵒʳ_ : GroupoidObject{ℓₗₒ}{ℓₗₘ}{ℓₗₑ} → GroupoidObject{ℓᵣₒ}{ℓᵣₘ}{ℓᵣₑ} → Type\ngrpₗ →ᶠᵘⁿᶜᵗᵒʳ grpᵣ = ∃(Functor (GroupoidObject.groupoid(grpₗ)) ((GroupoidObject.groupoid(grpᵣ))))\n\n⟲ᶠᵘⁿᶜᵗᵒʳ_ : GroupoidObject{ℓₒ}{ℓₘ}{ℓₑ} → Type\n⟲ᶠᵘⁿᶜᵗᵒʳ grp = grp →ᶠᵘⁿᶜᵗᵒʳ grp\n", "meta": {"hexsha": "fe4a93646b6aa6fbe2ab7b4acbb94d67d2e5b3c9", "size": 2519, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Groupoid/Functor.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Groupoid/Functor.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Groupoid/Functor.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.1666666667, "max_line_length": 125, "alphanum_fraction": 0.6820166733, "num_tokens": 1072, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8947894604912848, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.6286164910355672}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule FinEquivTypeEquiv where\n\n-- The goal is to establish that finite sets and equivalences form a\n-- commutative semiring. \n\nimport Level using (zero)\n\nopen import Data.Nat using (ℕ; _+_; _*_)\nopen import Data.Fin using (Fin)\n\nopen import Relation.Binary using (IsEquivalence)\nopen import Algebra using (CommutativeSemiring)\nopen import Algebra.Structures\n using (IsSemigroup; IsCommutativeMonoid; IsCommutativeSemiring)\n\nopen import Equiv using (_≃_; id≃; sym≃; trans≃; _●_; _⊎≃_; _×≃_) \nopen import TypeEquiv\n using (assocl₊equiv; unite₊equiv; unite₊′equiv; swap₊equiv;\n unite⋆equiv; unite⋆′equiv; swap⋆equiv; assocl⋆equiv; \n distzequiv; distzrequiv; distequiv; distlequiv)\n\nopen import FinEquivPlusTimes using (F0≃⊥; module Plus; Fin1≃⊤; module Times)\nopen Plus using (+≃⊎; ⊎≃+)\nopen Times using (*≃×; ×≃*)\n\n------------------------------------------------------------------------------\n-- This is the relation we are interested in showing is a commutative\n-- semiring.\n\n_fin≃_ : (m n : ℕ) → Set\nm fin≃ n = Fin m ≃ Fin n\n\n------------------------------------------------------------------------------\n-- Additive monoid\n\nmodule PlusE where\n\n infix 9 _+F_\n \n -- additive monoid equivalences\n\n -- unite+\n\n unite+ : {m : ℕ} → Fin (0 + m) ≃ Fin m\n unite+ = unite₊equiv ● F0≃⊥ ⊎≃ id≃ ● +≃⊎\n\n -- and on the other side as well\n\n unite+r : {m : ℕ} → Fin (m + 0) ≃ Fin m\n unite+r = unite₊′equiv ● id≃ ⊎≃ F0≃⊥ ● +≃⊎\n\n -- swap₊\n\n swap+ : {m n : ℕ} → Fin (m + n) ≃ Fin (n + m)\n swap+ {m} = ⊎≃+ ● swap₊equiv ● +≃⊎ {m}\n\n -- associativity\n\n assocl+ : {m n o : ℕ} → Fin (m + (n + o)) ≃ Fin ((m + n) + o)\n assocl+ {m} = ⊎≃+ ● ⊎≃+ ⊎≃ id≃ ● assocl₊equiv ● id≃ ⊎≃ +≃⊎ ● +≃⊎ {m}\n\n -- congruence\n\n _+F_ : {m n o p : ℕ} → (Fin m ≃ Fin n) → (Fin o ≃ Fin p) →\n Fin (m + o) ≃ Fin (n + p)\n Fm≃Fn +F Fo≃Fp = ⊎≃+ ● Fm≃Fn ⊎≃ Fo≃Fp ● +≃⊎\n\n uniti+ : {m : ℕ} → Fin m ≃ Fin (0 + m)\n uniti+ = sym≃ unite+\n\n uniti+r : {m : ℕ} → Fin m ≃ Fin (m + 0)\n uniti+r = sym≃ unite+r\n\n assocr+ : {m n o : ℕ} → Fin ((m + n) + o) ≃ Fin (m + (n + o))\n assocr+ {m} = sym≃ (assocl+ {m})\n\n sswap+ : {m n : ℕ} → Fin (n + m) ≃ Fin (m + n)\n sswap+ {m} {n} = sym≃ (swap+ {m} {n})\n\n-----------------------------------------------------------------------------\n-- Multiplicative monoid\n\nmodule TimesE where\n\n infixl 7 _*F_\n \n -- multiplicative monoid equivalences\n\n -- unite*\n\n unite* : {m : ℕ} → Fin (1 * m) ≃ Fin m\n unite* {m} = unite⋆equiv ● Fin1≃⊤ ×≃ id≃ ● *≃×\n\n -- unite*r\n\n unite*r : {m : ℕ} → Fin (m * 1) ≃ Fin m\n unite*r {m} = unite⋆′equiv ● id≃ ×≃ Fin1≃⊤ ● *≃×\n\n -- swap*\n\n swap* : {m n : ℕ} → Fin (m * n) ≃ Fin (n * m)\n swap* {m} {n} = ×≃* ● swap⋆equiv ● *≃× {m}\n \n -- associativity\n\n assocl* : {m n o : ℕ} → Fin (m * (n * o)) ≃ Fin ((m * n) * o)\n assocl* {m} {n} {o} = ×≃* ● ×≃* ×≃ id≃ ● assocl⋆equiv ● id≃ ×≃ *≃× ● *≃× {m}\n\n -- congruence\n\n _*F_ : {m n o p : ℕ} → Fin m ≃ Fin n → Fin o ≃ Fin p →\n Fin (m * o) ≃ Fin (n * p)\n Fm≃Fn *F Fo≃Fp = ×≃* ● Fm≃Fn ×≃ Fo≃Fp ● *≃×\n\n uniti* : {m : ℕ} → Fin m ≃ Fin (1 * m)\n uniti* = sym≃ unite*\n\n uniti*r : {m : ℕ} → Fin m ≃ Fin (m * 1)\n uniti*r = sym≃ unite*r\n\n assocr* : {m n o : ℕ} → Fin ((m * n) * o) ≃ Fin (m * (n * o))\n assocr* {m} {n} {o} = sym≃ (assocl* {m})\n\n sswap* : {m n : ℕ} → Fin (n * m) ≃ Fin (m * n)\n sswap* {m} {n} = sym≃ (swap* {m} {n})\n\n------------------------------------------------------------------------------\n-- Distributivity of multiplication over addition\n\nmodule PlusTimesE where\n\n -- now that we have two monoids, we need to check distributivity\n\n -- note that the sequence below is \"logically right\", *but* could be\n -- replaced by id≃ !\n distz : {m : ℕ} → Fin (0 * m) ≃ Fin 0\n distz {m} = sym≃ F0≃⊥ ● distzequiv ● F0≃⊥ ×≃ id≃ ● *≃× {0} {m}\n where open Times\n\n distzr : {m : ℕ} → Fin (m * 0) ≃ Fin 0\n distzr {m} = sym≃ F0≃⊥ ● distzrequiv ● id≃ ×≃ F0≃⊥ ● *≃× {m} {0}\n where open Times\n\n dist : {m n o : ℕ} → Fin ((m + n) * o) ≃ Fin ((m * o) + (n * o))\n dist {m} {n} {o} = ⊎≃+ {m * o} {n * o} ● ×≃* {m} ⊎≃ ×≃* ● distequiv ● +≃⊎ ×≃ id≃ ● *≃×\n where open Times\n open Plus\n\n distl : {m n o : ℕ} → Fin (m * (n + o)) ≃ Fin ((m * n) + (m * o))\n distl {m} {n} {o} = ⊎≃+ {m * n} {m * o} ● ×≃* {m} ⊎≃ ×≃* ● distlequiv ● id≃ ×≃ +≃⊎ ● *≃×\n where open Plus\n open Times\n\n factorzr : {n : ℕ} → Fin 0 ≃ Fin (n * 0)\n factorzr {n} = sym≃ (distzr {n})\n\n factorz : {m : ℕ} → Fin 0 ≃ Fin (0 * m)\n factorz {m} = sym≃ (distz {m})\n\n factor : {m n o : ℕ} → Fin ((m * o) + (n * o)) ≃ Fin ((m + n) * o) \n factor {m} = sym≃ (dist {m}) \n\n factorl : {m n o : ℕ} → Fin ((m * n) + (m * o)) ≃ Fin (m * (n + o)) \n factorl {m} = sym≃ (distl {m}) \n\n------------------------------------------------------------------------------\n-- Summarizing... we have a commutative semiring structure\n\nfin≃IsEquiv : IsEquivalence _fin≃_\nfin≃IsEquiv = record {\n refl = id≃ ;\n sym = sym≃ ;\n trans = trans≃ \n }\n\nfinPlusIsSG : IsSemigroup _fin≃_ _+_\nfinPlusIsSG = record {\n isEquivalence = fin≃IsEquiv ; \n assoc = λ m n o → PlusE.assocr+ {m} {n} {o} ;\n ∙-cong = PlusE._+F_\n }\n\nfinTimesIsSG : IsSemigroup _fin≃_ _*_\nfinTimesIsSG = record {\n isEquivalence = fin≃IsEquiv ;\n assoc = λ m n o → TimesE.assocr* {m} {n} {o} ;\n ∙-cong = TimesE._*F_\n }\n\nfinPlusIsCM : IsCommutativeMonoid _fin≃_ _+_ 0\nfinPlusIsCM = record {\n isSemigroup = finPlusIsSG ;\n identityˡ = λ m → id≃ ;\n comm = λ m n → PlusE.swap+ {m} {n} \n }\n\nfinTimesIsCM : IsCommutativeMonoid _fin≃_ _*_ 1\nfinTimesIsCM = record {\n isSemigroup = finTimesIsSG ;\n identityˡ = λ m → TimesE.unite* {m} ;\n comm = λ m n → TimesE.swap* {m} {n}\n }\n\nfinIsCSR : IsCommutativeSemiring _fin≃_ _+_ _*_ 0 1\nfinIsCSR = record {\n +-isCommutativeMonoid = finPlusIsCM ;\n *-isCommutativeMonoid = finTimesIsCM ;\n distribʳ = λ o m n → PlusTimesE.dist {m} {n} {o} ;\n zeroˡ = λ m → PlusTimesE.distz {m}\n }\n\nfinCSR : CommutativeSemiring Level.zero Level.zero\nfinCSR = record {\n Carrier = ℕ ;\n _≈_ = _fin≃_ ;\n _+_ = _+_ ;\n _*_ = _*_ ;\n 0# = 0 ;\n 1# = 1 ;\n isCommutativeSemiring = finIsCSR\n }\n\n------------------------------------------------------------------------------\n", "meta": {"hexsha": "9013106eca5090535b8718d924a17cc5ab0e60c9", "size": 6176, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Univalence/FinEquivTypeEquiv.agda", "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_issues_repo_path": "Univalence/FinEquivTypeEquiv.agda", "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_forks_repo_path": "Univalence/FinEquivTypeEquiv.agda", "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "avg_line_length": 27.3274336283, "max_line_length": 90, "alphanum_fraction": 0.4915803109, "num_tokens": 2608, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916205190225, "lm_q2_score": 0.7279754607093178, "lm_q1q2_score": 0.6285279127198999}} {"text": "open import Data.Product using ( ∃ ; _×_ ; _,_ )\nopen import Relation.Binary.PropositionalEquality using\n ( _≡_ ; refl ; trans ; cong₂ )\nopen import Relation.Unary using ( ∅ ; _∪_ )\nopen import Web.Semantic.DL.Signature using ( Signature ; CN ; RN )\nopen import Web.Semantic.Util using ( id ; _∘_ ; Subset ; ⁅_⁆ )\n\nmodule Web.Semantic.DL.ABox where\n\ninfixr 5 _∼_ _∈₁_ _∈₂_\ninfixr 4 _,_\n\ndata ABox (Σ : Signature) (X : Set) : Set where\n ε : ABox Σ X\n _,_ : (A B : ABox Σ X) → ABox Σ X\n _∼_ : (x y : X) → ABox Σ X\n _∈₁_ : (x : X) → (c : CN Σ) → ABox Σ X\n _∈₂_ : (xy : X × X) → (r : RN Σ) → ABox Σ X\n\n⟨ABox⟩ : ∀ {Σ X Y} → (X → Y) → ABox Σ X → ABox Σ Y\n⟨ABox⟩ f ε = ε\n⟨ABox⟩ f (A , B) = (⟨ABox⟩ f A , ⟨ABox⟩ f B)\n⟨ABox⟩ f (x ∼ y) = (f x ∼ f y)\n⟨ABox⟩ f (x ∈₁ C) = (f x ∈₁ C)\n⟨ABox⟩ f ((x , y) ∈₂ R) = ((f x , f y) ∈₂ R)\n\n⟨ABox⟩-resp-id : ∀ {Σ X} (A : ABox Σ X) → (⟨ABox⟩ id A ≡ A)\n⟨ABox⟩-resp-id ε = refl\n⟨ABox⟩-resp-id (A , B) = cong₂ _,_ (⟨ABox⟩-resp-id A) (⟨ABox⟩-resp-id B)\n⟨ABox⟩-resp-id (x ∼ y) = refl\n⟨ABox⟩-resp-id (x ∈₁ c) = refl\n⟨ABox⟩-resp-id ((x , y) ∈₂ r) = refl\n\n⟨ABox⟩-resp-∘ : ∀ {Σ X Y Z} (f : Y → Z) (g : X → Y) (A : ABox Σ X) → (⟨ABox⟩ f (⟨ABox⟩ g A) ≡ ⟨ABox⟩ (f ∘ g) A)\n⟨ABox⟩-resp-∘ f g ε = refl\n⟨ABox⟩-resp-∘ f g (A , B) = cong₂ _,_ (⟨ABox⟩-resp-∘ f g A) (⟨ABox⟩-resp-∘ f g B)\n⟨ABox⟩-resp-∘ f g (x ∼ y) = refl\n⟨ABox⟩-resp-∘ f g (x ∈₁ c) = refl\n⟨ABox⟩-resp-∘ f g ((x , y) ∈₂ r) = refl\n\n⟨ABox⟩-resp-∘² : ∀ {Σ W X Y Z} (f : Y → Z) (g : X → Y) (h : W → X) →\n ∀ (A : ABox Σ W) → (⟨ABox⟩ f (⟨ABox⟩ g (⟨ABox⟩ h A)) ≡ ⟨ABox⟩ (f ∘ g ∘ h) A)\n⟨ABox⟩-resp-∘² f g h A = \n trans (⟨ABox⟩-resp-∘ f g (⟨ABox⟩ h A)) (⟨ABox⟩-resp-∘ (f ∘ g) h A)\n\nAssertions : ∀ {Σ X} → ABox Σ X → Subset (ABox Σ X)\nAssertions ε = ∅\nAssertions (A , B) = (Assertions A) ∪ (Assertions B)\nAssertions (x ∼ y) = ⁅ x ∼ y ⁆\nAssertions (x ∈₁ c) = ⁅ x ∈₁ c ⁆\nAssertions (xy ∈₂ r) = ⁅ xy ∈₂ r ⁆\n", "meta": {"hexsha": "7edca738a30be61b3ceb81c167424b84a37d682a", "size": 1919, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Web/Semantic/DL/ABox.agda", "max_stars_repo_name": "agda/agda-web-semantic", "max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z", "max_issues_repo_path": "src/Web/Semantic/DL/ABox.agda", "max_issues_repo_name": "agda/agda-web-semantic", "max_issues_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z", "max_forks_repo_path": "src/Web/Semantic/DL/ABox.agda", "max_forks_repo_name": "agda/agda-web-semantic", "max_forks_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z", "avg_line_length": 36.9038461538, "max_line_length": 111, "alphanum_fraction": 0.4986972381, "num_tokens": 1007, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916170039421, "lm_q2_score": 0.7279754489059775, "lm_q1q2_score": 0.6285278999701026}} {"text": "\nopen import Common.Reflect\nopen import Common.Prelude\nopen import Common.Equality\n\ndata Maybe A : Set where\n nothing : Maybe A\n just : A → Maybe A\n\n_<$>_ : ∀ {A B} → (A → B) → Maybe A → Maybe B\nf <$> just x = just (f x)\nf <$> nothing = nothing\n\n_==_ = primQNameEquality\n\n-- This is awkward!\nawkwardUnquoteNat : Term → Maybe Nat\nawkwardUnquoteNat (con z []) =\n if z == quote Nat.zero\n then just 0\n else nothing\nawkwardUnquoteNat (con s (arg _ n ∷ [])) =\n if s == quote Nat.suc\n then suc <$> awkwardUnquoteNat n\n else nothing\nawkwardUnquoteNat v = nothing\n\ntestAwkward : just 10 ≡ awkwardUnquoteNat (quoteTerm 10)\ntestAwkward = refl\n\n-- This is nicer!\npattern `zero = con (quote Nat.zero) []\npattern `suc n = con (quote Nat.suc) (arg _ n ∷ [])\n\nunquoteNat : Term → Maybe Nat\nunquoteNat `zero = just zero\nunquoteNat (`suc n) = suc <$> unquoteNat n\nunquoteNat _ = nothing\n\ntest : just 10 ≡ unquoteNat (quoteTerm 10)\ntest = refl\n", "meta": {"hexsha": "e7f8d09b769c3c0eec083d51f5c4b43239fe4cfd", "size": 945, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/Issue619.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/succeed/Issue619.agda", "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/Issue619.agda", "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 22.5, "max_line_length": 56, "alphanum_fraction": 0.6677248677, "num_tokens": 308, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.863391602943619, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.6285278948299851}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.CommRing.Kernel where\n\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Algebra.CommRing.Base\nopen import Cubical.Algebra.CommRing.Ideal using (IdealsIn; Ideal→CommIdeal)\nopen import Cubical.Algebra.Ring.Kernel using () renaming (kernelIdeal to ringKernelIdeal)\n\nprivate\n variable\n ℓ : Level\n\n\n-- If R and S were implicit, their ·Comm component could (almost?) never be inferred.\nkernelIdeal : (R S : CommRing ℓ) (f : CommRingHom R S) → IdealsIn R\nkernelIdeal _ _ f = Ideal→CommIdeal (ringKernelIdeal f)\n", "meta": {"hexsha": "c77ff6015c789e77c6ad09c27875a33f313d3e64", "size": 566, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommRing/Kernel.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_issues_repo_path": "Cubical/Algebra/CommRing/Kernel.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/CommRing/Kernel.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.4444444444, "max_line_length": 90, "alphanum_fraction": 0.7650176678, "num_tokens": 152, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8633916099737806, "lm_q2_score": 0.727975443004307, "lm_q1q2_score": 0.6285278897568648}} {"text": "module Prelude.Product where\n\nrecord _×_ (A B : Set) : Set where\n constructor _,_\n field\n fst : A\n snd : B\n\nopen _×_ public\n", "meta": {"hexsha": "f6ecd5978340b191160f8885642ae0eaa840271d", "size": 132, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/epic/Prelude/Product.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/epic/Prelude/Product.agda", "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/epic/Prelude/Product.agda", "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 13.2, "max_line_length": 34, "alphanum_fraction": 0.6363636364, "num_tokens": 42, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.863391602943619, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.6285278846390799}} {"text": "module Categories.2-Category.Categories where\n\nopen import Level\nopen import Data.Product\n\nopen import Categories.Category\nopen import Categories.2-Category\nopen import Categories.Functor using (module Functor) renaming (id to idF; _∘_ to _∘F_)\nopen import Categories.Functor.Constant\nopen import Categories.FunctorCategory\nopen import Categories.Bifunctor using (Bifunctor)\nopen import Categories.NaturalTransformation\nopen import Categories.Product using (Product)\n\nCategories : ∀ o ℓ e → 2-Category (suc (o ⊔ ℓ ⊔ e)) (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e) (o ⊔ e)\nCategories o ℓ e = record\n { Obj = Category o ℓ e\n ; _⇒_ = Functors\n ; id = λ {A} → Constant {D = Functors A A} idF\n ; —∘— = my-∘\n ; assoc = {!!}\n ; identityˡ = λ {A B} η → Heterogeneous.≡⇒∼ {C = Functors A B} {f = proj₂ η ∘₁ id} {proj₂ η} (Category.identityʳ B)\n ; identityʳ = λ {A B f g} η → Heterogeneous.≡⇒∼ {_} {_} {_} {C = Functors A B} {proj₁ f} {proj₁ g} {f = record {\n η =\n λ X →\n Category._∘_ B (Functor.F₁ (proj₁ g) (Category.id A))\n (NaturalTransformation.η (proj₁ η) X);\n commute = λ {a} {b} h → let open Category.HomReasoning B in begin\n B [ B [ Functor.F₁ (proj₁ g) (Category.id A) ∘ NaturalTransformation.η (proj₁ η) b ] ∘ {!.Categories.NaturalTransformation.Core.F.F₁ (proj₁ f) (proj₁ g) h!} ]\n ↓⟨ {!!} ⟩\n B [ Functor.F₁ {!!} {!!} ∘ B [ Functor.F₁ (proj₁ g) (Category.id A) ∘ NaturalTransformation.η (proj₁ η) a ] ]\n ∎ }\n } {proj₁ {_} {_} {_} {_} η} (Category.Equiv.trans B (Category.∘-resp-≡ˡ B (Functor.identity (proj₁ g))) (Category.identityˡ B))\n } \n where\n my-∘ : {A B C : Category o ℓ e} → Bifunctor (Functors B C) (Functors A B) (Functors A C)\n my-∘ {A} {B} {C} = record\n { F₀ = uncurry′ _∘F_\n ; F₁ = uncurry′ _∘₀_\n ; identity = λ {Fs} → Category.Equiv.trans C (Category.identityʳ C) (Functor.identity (proj₁ Fs))\n ; homomorphism = λ {_ _ _ f g} → Category.Equiv.sym C (interchange {α = proj₁ g} {proj₂ g} {proj₁ f} {proj₂ f})\n ; F-resp-≡ = λ {_ _ f g} → my-resp {f = f} {g}\n }\n where\n PF = Product (Functors B C) (Functors A B)\n\n .my-resp : ∀ {F G} {f g : PF [ F , G ]} → PF [ f ≡ g ] → Functors A C [ uncurry′ _∘₀_ f ≡ uncurry _∘₀_ g ]\n my-resp {f = f₁ , f₂} {g₁ , g₂} (f₁≡g₁ , f₂≡g₂) = ∘₀-resp-≡ {f = f₁} {g₁} {f₂} {g₂} f₁≡g₁ f₂≡g₂", "meta": {"hexsha": "cf3bc5cb5e3497645ad09ea5dc8c604fad020c47", "size": 2816, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/2-Category/Categories.agda", "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 98, "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_issues_repo_path": "Categories/2-Category/Categories.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_forks_repo_path": "Categories/2-Category/Categories.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 23, "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "avg_line_length": 58.6666666667, "max_line_length": 178, "alphanum_fraction": 0.4943181818, "num_tokens": 917, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278664544911, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.6284935321482502}} {"text": "data Nat : Set where\n zero : Nat\n suc : (n : Nat) → Nat\n\ntest₁ : (n : Nat) → Nat\ntest₁ n with zero\n... | x = {!x!}\n\ndata Tree : Set where\n leaf : Tree\n node : Tree → Tree → Tree\n\ntest₂ : (n : Tree) → Tree\ntest₂ n₁ with leaf\n... | n = {!n!}\n", "meta": {"hexsha": "11c6a9a972de708a31f31dc921cd96e613b7921c", "size": 244, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue1820.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/interaction/Issue1820.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/interaction/Issue1820.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 15.25, "max_line_length": 27, "alphanum_fraction": 0.5368852459, "num_tokens": 93, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.88242786954645, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.6284935235703343}} {"text": "{-# OPTIONS --without-K #-}\nmodule Computability.Function where\n\nopen import Computability.Prelude\nimport Function\n\nvariable\n l₀ l₁ : Level\n\nInjective : {A : Set l₀}{B : Set l₁} → (A → B) → Set _\nInjective = Function.Injective _≡_ _≡_\n\nSurjective : {A : Set l₀}{B : Set l₁} → (A → B) → Set _\nSurjective {A = A} {B = B} = Function.Surjective {A = A} {B = B} _≡_ _≡_\n\nBijective : {A : Set l₀}{B : Set l₁} → (A → B) → Set _\nBijective = Function.Bijective _≡_ _≡_\n", "meta": {"hexsha": "e05e4ede036213ad08609aeebf068482037d83b1", "size": 461, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Computability/Function.agda", "max_stars_repo_name": "jesyspa/computability-in-agda", "max_stars_repo_head_hexsha": "1b5cf338eb0adb90c1897383e05251ddd954efff", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-09-19T15:51:22.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-30T11:15:51.000Z", "max_issues_repo_path": "Computability/Function.agda", "max_issues_repo_name": "jesyspa/computability-in-agda", "max_issues_repo_head_hexsha": "1b5cf338eb0adb90c1897383e05251ddd954efff", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Computability/Function.agda", "max_forks_repo_name": "jesyspa/computability-in-agda", "max_forks_repo_head_hexsha": "1b5cf338eb0adb90c1897383e05251ddd954efff", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.6111111111, "max_line_length": 72, "alphanum_fraction": 0.6290672451, "num_tokens": 171, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8670357460591569, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.6284884458543744}} {"text": "module Nats.Multiply.Distrib where\n\nopen import Nats\nopen import Equality\nopen import Function\n\nopen import Nats.Multiply.Comm\nopen import Nats.Add.Assoc\nopen import Nats.Add.Comm\n\n------------------------------------------------------------------------\n-- internal stuffs\n\nprivate\n\n a*1+b=a+a*b : ∀ a b → a * suc b ≡ a + a * b\n a*1+b=a+a*b a b\n rewrite nat-multiply-comm a $ suc b\n | nat-multiply-comm a b\n = refl\n\n a*c+b*c=/a+b/*c : ∀ a b c → a * c + b * c ≡ (a + b) * c\n a*c+b*c=/a+b/*c a b zero\n rewrite nat-multiply-comm a 0\n | nat-multiply-comm b 0\n | nat-multiply-comm (a + b) 0\n = refl\n a*c+b*c=/a+b/*c a b sc@(suc c)\n rewrite nat-add-comm a b\n | a*1+b=a+a*b a c\n | nat-add-assoc a (a * c) (b * sc)\n | nat-add-comm a $ a * c + b * sc\n | a*1+b=a+a*b b c\n | nat-multiply-comm (b + a) sc\n | nat-add-assoc b a $ c * (b + a)\n | nat-add-comm a $ c * (b + a)\n | sym $ nat-add-assoc b (c * (b + a)) a\n | nat-multiply-comm c $ b + a\n | sym $ a*c+b*c=/a+b/*c b a c\n | sym $ nat-add-assoc (a * c) b (b * c)\n | nat-add-comm (b * c) (a * c)\n | sym $ nat-add-assoc b (b * c) (a * c)\n | sym $ nat-add-assoc b (a * c) (b * c)\n | nat-add-comm b $ a * c\n = refl\n\n------------------------------------------------------------------------\n-- public aliases\n\nnat-multiply-distrib : ∀ a b c → a * c + b * c ≡ (a + b) * c\nnat-multiply-distrib = a*c+b*c=/a+b/*c\n\n", "meta": {"hexsha": "661fcfc4079c23d03ae1450fb800ae640403eaab", "size": 1558, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Nats/Multiply/Distrib.agda", "max_stars_repo_name": "ice1k/Theorems", "max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z", "max_issues_repo_path": "src/Nats/Multiply/Distrib.agda", "max_issues_repo_name": "ice1k/Theorems", "max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Nats/Multiply/Distrib.agda", "max_forks_repo_name": "ice1k/Theorems", "max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.3962264151, "max_line_length": 72, "alphanum_fraction": 0.4306803594, "num_tokens": 510, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637648915617, "lm_q2_score": 0.7310585727705127, "lm_q1q2_score": 0.6284645650241507}} {"text": "module Numeral.Natural.Function.GreatestCommonDivisor.Extended where\n\nimport Lvl\nopen import Data\nopen import Data.Tuple as Tuple using (_⨯_ ; _,_)\nopen import Logic.Propositional\nopen import Numeral.Integer as ℤ\nopen import Numeral.Integer.Oper\nopen import Numeral.Integer.Proofs hiding (_≤_)\nopen import Numeral.Natural as ℕ\nopen import Numeral.Natural.Function.GreatestCommonDivisor\nimport Numeral.Natural.Oper as ℕ\nopen import Numeral.Natural.Oper.FlooredDivision\nopen import Numeral.Natural.Oper.Modulo\nopen import Numeral.Natural.Relation.Order\nopen import Numeral.Natural.Relation.Order.Classical\nopen import Syntax.Number\nopen import Type\n\n-- TODO: Does the same algorithm work in the naturals? https://math.stackexchange.com/questions/237372/finding-positive-b%C3%A9zout-coefficients https://math.stackexchange.com/questions/1230224/positive-solutions-of-893x-2432y-19?rq=1\ngcdExt : ℕ → ℕ → (ℕ ⨯ ℤ ⨯ ℤ)\ngcdExt a b = gcdFold(\\{a (𝐒 b) _ (succ min) _ (x , y) → (y , (x − ((+ₙ(a ⌊/⌋ ℕ.𝐒(b))) ⋅ y)))}) (\\_ _ _ _ _ → Tuple.swap) (1 , 0) a b\n\nopen import Logic.IntroInstances\nopen import Logic.Predicate\nopen import Numeral.Natural.Inductions\nopen import Numeral.Natural.Oper.Proofs\nopen import Numeral.Natural.Oper.DivMod.Proofs\nopen import Numeral.Natural.Oper.Modulo.Proofs\nopen import Numeral.Natural.Relation.Order.Proofs\nopen import Relator.Equals\nopen import Relator.Equals.Proofs.Equiv\nopen import Structure.Function\nopen import Structure.Function.Domain\nopen import Structure.Function.Multi\nopen import Structure.Operator\nopen import Structure.Operator.Proofs.Util\nopen import Structure.Operator.Properties\nopen import Syntax.Function\nopen import Syntax.Transitivity\n\nprivate variable a b d : ℕ\n\ngcd-gcdExt-equal : (gcd a b ≡ Tuple.left(gcdExt a b))\ngcd-gcdExt-equal {a}{b} = Gcd-unique {a}{b} Gcd-gcd Gcd-gcdFold\n\n-- Also called: Bézout's identity, extended Euclid's algorithm.\ngcd-linearCombination-existence : ∃{Obj = ℤ ⨯ ℤ}(\\{(x , y) → (((+ₙ a) ⋅ x) + ((+ₙ b) ⋅ y) ≡ +ₙ(gcd a b))})\ngcd-linearCombination-existence {a}{b} = [ℕ]-strong-induction {φ = b ↦ ∀{a} → ∃{Obj = ℤ ⨯ ℤ}(\\{(x , y) → (((+ₙ a) ⋅ x) + ((+ₙ b) ⋅ y) ≡ +ₙ(gcd a b))})} base step {b}{a} where\n base : ∀{a} → ∃{Obj = ℤ ⨯ ℤ}(\\{(x , y) → (((+ₙ a) ⋅ x) + (0 ⋅ y) ≡ +ₙ(gcd a 0))})\n ∃.witness (base {a}) = (1 , 0)\n ∃.proof (base {ℕ.𝟎}) = [≡]-intro\n ∃.proof (base {ℕ.𝐒 a}) = [≡]-intro\n\n step : ∀{i} → (∀{j} → (j ≤ i) → ∀{a} → ∃{Obj = ℤ ⨯ ℤ}(\\{(x , y) → (((+ₙ a) ⋅ x) + ((+ₙ j) ⋅ y) ≡ +ₙ(gcd a j))})) → ∀{a} → ∃{Obj = ℤ ⨯ ℤ}(\\{(x , y) → (((+ₙ a) ⋅ x) + ((+𝐒ₙ i) ⋅ y) ≡ +ₙ(gcd a (ℕ.𝐒(i))))})\n ∃.witness (step {i} prev {a}) with [≥]-or-[<] {a}{ℕ.𝐒(i)}\n ... | [∨]-introₗ ia with [∃]-intro (x , y) ← prev{a mod ℕ.𝐒(i)} ([≤]-without-[𝐒] (mod-maxᵣ {a = a})) {ℕ.𝐒(i)} = (y , ((x − ((+ₙ(a ⌊/⌋ ℕ.𝐒(i))) ⋅ y))))\n ... | [∨]-introᵣ (succ ai) with [∃]-intro (x , y) ← prev{a} ai {ℕ.𝐒(i)} = (y , x)\n ∃.proof (step {i} prev {a}) with [≥]-or-[<] {a}{ℕ.𝐒(i)}\n ... | [∨]-introₗ ia with [∃]-intro (x , y) ⦃ p ⦄ ← prev{a mod ℕ.𝐒(i)} ([≤]-without-[𝐒] (mod-maxᵣ {a = a})) {ℕ.𝐒(i)} =\n ((+ₙ a) ⋅ y) + ((+𝐒ₙ i) ⋅ (x − ((+ₙ(a ⌊/⌋ ℕ.𝐒(i))) ⋅ y))) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)((+ₙ a) ⋅ y) (distributivityₗ(_⋅_)(_−_) {+𝐒ₙ i}{x}{(+ₙ(a ⌊/⌋ ℕ.𝐒(i))) ⋅ y}) ]\n ((+ₙ a) ⋅ y) + (((+𝐒ₙ i) ⋅ x) − ((+𝐒ₙ i) ⋅ ((+ₙ(a ⌊/⌋ ℕ.𝐒(i))) ⋅ y))) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)((+ₙ a) ⋅ y) (congruence₂ᵣ(_−_)((+𝐒ₙ i) ⋅ x) p1) ]\n ((+ₙ a) ⋅ y) + (((+𝐒ₙ i) ⋅ x) − ((+ₙ(a ℕ.−₀ (a mod ℕ.𝐒(i)))) ⋅ y)) 🝖[ _≡_ ]-[ One.commuteₗ-assocᵣ{a = (+ₙ a) ⋅ y}{b = (+𝐒ₙ i) ⋅ x} ]\n ((+𝐒ₙ i) ⋅ x) + (((+ₙ a) ⋅ y) − ((+ₙ(a ℕ.−₀ (a mod ℕ.𝐒(i)))) ⋅ y)) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)((+𝐒ₙ i) ⋅ x) (distributivityᵣ(_⋅_)(_−_) {+ₙ a}{_}{y}) ]-sym\n ((+𝐒ₙ i) ⋅ x) + (((+ₙ a) − (+ₙ(a ℕ.−₀ (a mod ℕ.𝐒(i))))) ⋅ y) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)((+𝐒ₙ i) ⋅ x) (congruence₂ₗ(_⋅_)(y) p2) ]\n ((+𝐒ₙ i) ⋅ x) + ((+ₙ(a mod ℕ.𝐒(i))) ⋅ y) 🝖[ _≡_ ]-[ p ]\n +ₙ(gcd (ℕ.𝐒(i)) (a mod ℕ.𝐒(i))) 🝖-end\n where\n p0 =\n (ℕ.𝐒 i) ℕ.⋅ (a ⌊/⌋ ℕ.𝐒(i)) 🝖[ _≡_ ]-[ commutativity(ℕ._⋅_) {ℕ.𝐒 i}{a ⌊/⌋ ℕ.𝐒(i)} ]\n (a ⌊/⌋ ℕ.𝐒(i)) ℕ.⋅ (ℕ.𝐒 i) 🝖[ _≡_ ]-[ OneTypeTwoOp.moveᵣ-to-invOp {b = a mod ℕ.𝐒(i)}{c = a} (([⌊/⌋][mod]-is-division-with-remainder {y = i})) ]\n a ℕ.−₀ (a mod ℕ.𝐒(i)) 🝖-end\n\n p1 =\n (+𝐒ₙ i) ⋅ ((+ₙ(a ⌊/⌋ ℕ.𝐒(i))) ⋅ y) 🝖[ _≡_ ]-[ associativity(_⋅_) {+𝐒ₙ i} ]-sym\n ((+𝐒ₙ i) ⋅ (+ₙ(a ⌊/⌋ ℕ.𝐒(i)))) ⋅ y 🝖[ _≡_ ]-[]\n ((+ₙ(ℕ.𝐒 i)) ⋅ (+ₙ(a ⌊/⌋ ℕ.𝐒(i)))) ⋅ y 🝖[ _≡_ ]-[ congruence₂ₗ(_⋅_)(y) (preserving₂(+ₙ_)(ℕ._⋅_)(_⋅_) {ℕ.𝐒 i}) ]-sym\n (+ₙ((ℕ.𝐒 i) ℕ.⋅ (a ⌊/⌋ ℕ.𝐒(i)))) ⋅ y 🝖[ _≡_ ]-[ congruence₂ₗ(_⋅_)(y) (congruence₁(+ₙ_) p0) ]\n (+ₙ(a ℕ.−₀ (a mod ℕ.𝐒(i)))) ⋅ y 🝖-end\n\n p2 =\n (+ₙ a) − (+ₙ(a ℕ.−₀ (a mod ℕ.𝐒(i)))) 🝖[ _≡_ ]-[ congruence₂ᵣ(_−_)(+ₙ a) ([+ₙ][−₀][−]-preserving (mod-maxₗ {a}{ℕ.𝐒(i)})) ]\n (+ₙ a) − ((+ₙ a) − (+ₙ(a mod ℕ.𝐒(i)))) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)(+ₙ a) (preserving₂(−_)(_+_)(_+_) {+ₙ a}{−(+ₙ(a mod ℕ.𝐒(i)))}) ]\n (+ₙ a) + ((−(+ₙ a)) − (−(+ₙ(a mod ℕ.𝐒(i))))) 🝖[ _≡_ ]-[ associativity(_+_) {+ₙ a}{−(+ₙ a)} ]-sym\n ((+ₙ a) − (+ₙ a)) − (−(+ₙ(a mod ℕ.𝐒(i)))) 🝖[ _≡_ ]-[ congruence₂(_+_) (inverseFunctionᵣ(_+_)(−_) {+ₙ a}) (involution(−_)) ]\n 0 + (+ₙ(a mod ℕ.𝐒(i))) 🝖[ _≡_ ]-[ identityₗ(_+_)(0) ]\n +ₙ(a mod ℕ.𝐒(i)) 🝖[ _≡_ ]-end\n ... | [∨]-introᵣ (succ ai) with [∃]-intro (x , y) ⦃ p ⦄ ← prev{a} ai {ℕ.𝐒(i)} = commutativity(_+_) {(+ₙ a) ⋅ y}{(+ₙ ℕ.𝐒(i)) ⋅ x} 🝖 p\n", "meta": {"hexsha": "674853f8ed8f08e05e7de36ad6ef278e447ad112", "size": 5581, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Function/GreatestCommonDivisor/Extended.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Function/GreatestCommonDivisor/Extended.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Function/GreatestCommonDivisor/Extended.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.7078651685, "max_line_length": 234, "alphanum_fraction": 0.5085110195, "num_tokens": 2881, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637577007394, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.6284645648044315}} {"text": "-- Andreas, 2017-06-20, issue #2613, reported by Jonathan Prieto.\n-- Regression introduced by fix of #2458 (which is obsolete since #2403)\n\nmodule _ where\n\nopen import Agda.Builtin.Nat\n\nmodule Prop' (n : Nat) where\n\n data Prop' : Set where\n _∧_ _∨_ : Prop' → Prop' → Prop'\n\nopen Prop' zero\n\ndata DView : Prop' → Set where\n case₁ : (a b c : Prop') → DView ((a ∨ b) ∧ c)\n case₂ : (a : Prop') → DView a\n\ndView : (p : Prop') → DView p\ndView ((a ∨ b) ∧ c) = case₁ _ _ _\ndView a = case₂ _\n\ndist-∧ : Prop' → Prop'\ndist-∧ p with dView p\ndist-∧ .((a ∨ b) ∧ c) | case₁ a b c = dist-∧ (a ∧ c)\ndist-∧ a | case₂ .a = a\n\n-- WAS:\n-- Termination checking failed for the following functions:\n-- dist-∧\n-- Problematic calls:\n-- dist-∧ (a ∧ c)\n\n-- Should succeed.\n", "meta": {"hexsha": "815190f05ed7a2830bf1ee9d9a8711d43cf35215", "size": 785, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue2613.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue2613.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue2613.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 22.4285714286, "max_line_length": 72, "alphanum_fraction": 0.578343949, "num_tokens": 285, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637469145054, "lm_q2_score": 0.7310585727705126, "lm_q1q2_score": 0.6284645518818694}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Diagram.End.Properties where\n\nopen import Level\nopen import Data.Product using (Σ; _,_)\nopen import Function using (_$_)\n\nopen import Categories.Category\nopen import Categories.Category.Product\nopen import Categories.Category.Construction.Functors\nopen import Categories.Functor\nopen import Categories.Functor.Bifunctor\nopen import Categories.NaturalTransformation\nopen import Categories.NaturalTransformation.Dinatural\nopen import Categories.Diagram.End as ∫\n\nimport Categories.Morphism.Reasoning as MR\n\nprivate\n variable\n o ℓ e : Level\n C D E : Category o ℓ e\n\nmodule _ {C : Category o ℓ e}\n (F : Functor E (Functors (Product (Category.op C) C) D)) where\n private\n module C = Category C\n module D = Category D\n module E = Category E\n module NT = NaturalTransformation\n open D\n open HomReasoning\n\n open MR D\n open Functor F\n open End hiding (E)\n open NT using (η)\n\n EndF : (∀ X → End (F₀ X)) → Functor E D\n EndF end = record\n { F₀ = λ X → End.E (end X)\n ; F₁ = F₁′\n ; identity = λ {A} → unique (end A) (id-comm ○ ∘-resp-≈ˡ (⟺ identity))\n ; homomorphism = λ {A B C} {f g} → unique (end C) $ λ {Z} → begin\n dinatural.α (end C) Z ∘ F₁′ g ∘ F₁′ f ≈⟨ pullˡ (universal (end C)) ⟩\n (η (F₁ g) (Z , Z) ∘ dinatural.α (end B) Z) ∘ F₁′ f ≈⟨ pullʳ (universal (end B)) ⟩\n η (F₁ g) (Z , Z) ∘ η (F₁ f) (Z , Z) ∘ dinatural.α (end A) Z ≈˘⟨ pushˡ homomorphism ⟩\n η (F₁ (g E.∘ f)) (Z , Z) ∘ dinatural.α (end A) Z ∎\n ; F-resp-≈ = λ {A B f g} eq → unique (end B) $ λ {Z} → begin\n dinatural.α (end B) Z ∘ F₁′ g ≈⟨ universal (end B) ⟩\n η (F₁ g) (Z , Z) ∘ dinatural.α (end A) Z ≈˘⟨ F-resp-≈ eq ⟩∘⟨refl ⟩\n η (F₁ f) (Z , Z) ∘ dinatural.α (end A) Z ∎\n }\n where F₁′ : ∀ {X Y} → X E.⇒ Y → End.E (end X) ⇒ End.E (end Y)\n F₁′ {X} {Y} f = factor (end Y) $ record\n { E = End.E (end X)\n ; dinatural = F₁ f <∘ dinatural (end X)\n }\n", "meta": {"hexsha": "8cd46bfa289247bc044f2e90064d6f75210215af", "size": 2130, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Diagram/End/Properties.agda", "max_stars_repo_name": "bblfish/agda-categories", "max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "src/Categories/Diagram/End/Properties.agda", "max_issues_repo_name": "bblfish/agda-categories", "max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Diagram/End/Properties.agda", "max_forks_repo_name": "bblfish/agda-categories", "max_forks_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 35.5, "max_line_length": 96, "alphanum_fraction": 0.5530516432, "num_tokens": 748, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637433190939, "lm_q2_score": 0.7310585669110203, "lm_q1q2_score": 0.62846454421622}} {"text": "{-# OPTIONS --warning=error --safe --guardedness --without-K #-}\n\nopen import LogicalFormulae\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Naturals\nopen import Numbers.Naturals.Order\nopen import Numbers.Naturals.EuclideanAlgorithm\nopen import Lists.Lists\nopen import Numbers.Primes.PrimeNumbers\nopen import Decidable.Relations\nopen import Numbers.BinaryNaturals.Definition\nopen import Numbers.BinaryNaturals.Addition\nopen import Numbers.BinaryNaturals.Order\nopen import Sequences\nopen import Vectors\nopen import Orders.Total.Definition\nopen import Setoids.Orders.Partial.Definition\nopen import Setoids.Orders.Partial.Sequences\nopen import Setoids.Orders.Total.Definition\nopen import Setoids.Setoids\nopen import Functions.Definition\nopen import Semirings.Definition\n\nmodule ProjectEuler.Problem2 where\n\nfibUnary : ℕ → ℕ\nfibUnary zero = 1\nfibUnary (succ zero) = 1\nfibUnary (succ (succ n)) = fibUnary (succ n) +N fibUnary n\n\nfibUnaryStrictlyPositive : (a : ℕ) → 0 List Nat -> List Nat\ninsert a [] = a ∷ []\ninsert x (a ∷ b) with x < a\n... | true = x ∷ a ∷ b\n... | false = a ∷ (insert x b)\n\nfoldr : ∀ {a b : Set} → (a → b → b) → b → List a -> b\nfoldr f ini [] = ini\nfoldr f ini (x ∷ l) = f x (foldr f ini l)\n\ninsertSort : List Nat -> List Nat\ninsertSort = foldr insert []\n\natDef : ∀ {a : Set} → a → List a -> Nat -> a\natDef def (x ∷ l) zero = x\natDef def (x ∷ l) (suc ix) = atDef def l ix\natDef def _ _ = def\n\nlst : List Nat\nlst = 4 ∷ 2 ∷ 7 ∷ []\n\nslst : List Nat\nslst = insertSort lst\n\nl0 : Nat\nl0 = atDef 0 slst 0\n\nl1 : Nat\nl1 = atDef 0 slst 1\n\nl2 : Nat\nl2 = atDef 0 slst 2\n", "meta": {"hexsha": "5c1f2bddf098becec4ac38ce962a5726228749f6", "size": 750, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/agda-ocaml/Golden/InsertionSort.agda", "max_stars_repo_name": "agda/agda-ocaml", "max_stars_repo_head_hexsha": "e38b699870ba638221828b07b12948d70a1bdaec", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 48, "max_stars_repo_stars_event_min_datetime": "2017-03-29T14:19:31.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-15T09:08:14.000Z", "max_issues_repo_path": "test/agda-ocaml/Golden/InsertionSort.agda", "max_issues_repo_name": "agda/agda-ocaml", "max_issues_repo_head_hexsha": "e38b699870ba638221828b07b12948d70a1bdaec", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2017-03-29T13:37:52.000Z", "max_issues_repo_issues_event_max_datetime": "2018-11-05T21:28:57.000Z", "max_forks_repo_path": "test/agda-ocaml/Golden/InsertionSort.agda", "max_forks_repo_name": "agda/agda-ocaml", "max_forks_repo_head_hexsha": "e38b699870ba638221828b07b12948d70a1bdaec", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2018-05-24T10:45:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:48.000Z", "avg_line_length": 19.2307692308, "max_line_length": 53, "alphanum_fraction": 0.5893333333, "num_tokens": 302, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972650509008, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.6283476666824547}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.OrderedCommMonoid.Instances where\n\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Algebra.OrderedCommMonoid.Base\n\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Nat.Order\n\nℕ≤+ : OrderedCommMonoid ℓ-zero ℓ-zero\nℕ≤+ .fst = ℕ\nℕ≤+ .snd .OrderedCommMonoidStr._≤_ = _≤_\nℕ≤+ .snd .OrderedCommMonoidStr._·_ = _+_\nℕ≤+ .snd .OrderedCommMonoidStr.ε = 0\nℕ≤+ .snd .OrderedCommMonoidStr.isOrderedCommMonoid =\n makeIsOrderedCommMonoid\n isSetℕ\n +-assoc +-zero (λ _ → refl) +-comm\n (λ _ _ → isProp≤) (λ _ → ≤-refl) (λ _ _ _ → ≤-trans) (λ _ _ → ≤-antisym)\n (λ _ _ _ → ≤-+k) (λ _ _ _ → ≤-k+)\n\nℕ≤· : OrderedCommMonoid ℓ-zero ℓ-zero\nℕ≤· .fst = ℕ\nℕ≤· .snd .OrderedCommMonoidStr._≤_ = _≤_\nℕ≤· .snd .OrderedCommMonoidStr._·_ = _·_\nℕ≤· .snd .OrderedCommMonoidStr.ε = 1\nℕ≤· .snd .OrderedCommMonoidStr.isOrderedCommMonoid =\n makeIsOrderedCommMonoid\n isSetℕ\n ·-assoc ·-identityʳ ·-identityˡ ·-comm\n (λ _ _ → isProp≤) (λ _ → ≤-refl) (λ _ _ _ → ≤-trans) (λ _ _ → ≤-antisym)\n (λ _ _ _ → ≤-·k) lmono\n where lmono : (x y z : ℕ) → x ≤ y → z · x ≤ z · y\n lmono x y z x≤y = subst ((z · x) ≤_) (·-comm y z) (subst (_≤ (y · z)) (·-comm x z) (≤-·k x≤y))\n", "meta": {"hexsha": "ca6dbb984a54e1efe3ca72b88164411edf4db054", "size": 1252, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/OrderedCommMonoid/Instances.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/OrderedCommMonoid/Instances.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/OrderedCommMonoid/Instances.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.7777777778, "max_line_length": 102, "alphanum_fraction": 0.6102236422, "num_tokens": 530, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972684083609, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.6283476638949809}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties of operations on containers\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Container.Properties where\n\nimport Function as F\nopen import Relation.Binary\n\nopen import Data.Container.Core\nopen import Data.Container.Relation.Binary.Equality.Setoid\n\nmodule _ {s p} {C : Container s p} where\n\n map-identity : ∀ {x e} (X : Setoid x e) xs →\n Eq X C (map F.id xs) xs\n map-identity X xs = refl X C\n\n map-compose : ∀ {x y z e} {X : Set x} {Y : Set y} (Z : Setoid z e) g (f : X → Y) xs →\n Eq Z C (map g (map f xs)) (map (g F.∘′ f) xs)\n map-compose Z g f xs = refl Z C\n", "meta": {"hexsha": "c20c6b144e0724153009c2cbbfaa6187fac13082", "size": 785, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Container/Properties.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Container/Properties.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Container/Properties.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 30.1923076923, "max_line_length": 87, "alphanum_fraction": 0.501910828, "num_tokens": 199, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8705972684083609, "lm_q2_score": 0.721743200312399, "lm_q1q2_score": 0.6283476586842831}} {"text": "module Data.Dyck.Sized where\n\nopen import Prelude\nopen import Data.Nat using (_+_)\nopen import Data.Vec.Iterated using (Vec; _∷_; []; foldlN; head; foldl′)\n\nopen import Cubical.Foundations.Prelude using (substRefl)\nopen import Cubical.Data.Sigma.Properties using (Σ≡Prop)\nopen import Data.Nat.Properties using (isSetℕ)\n\nprivate variable\n n m k : ℕ\n n⊙ m⊙ k⊙ : ℕ → ℕ\n\n--------------------------------------------------------------------------------\n-- Tree\n--------------------------------------------------------------------------------\n\ndata Tree : Type where\n ⟨⟩ : Tree\n _*_ : Tree → Tree → Tree\n\nsize⊙ : Tree → ℕ → ℕ\nsize⊙ ⟨⟩ = suc\nsize⊙ (xs * ys) = size⊙ xs ∘ size⊙ ys\n\nsize : Tree → ℕ\nsize t = size⊙ t zero\n\n--------------------------------------------------------------------------------\n-- Dyck Word\n--------------------------------------------------------------------------------\n\ninfixr 6 ⟨_ ⟩_\ndata Dyck : ℕ → ℕ → Type where\n ⟩! : Dyck 1 0\n ⟨_ : Dyck (1 + n) m → Dyck n (1 + m)\n ⟩_ : Dyck (1 + n) m → Dyck (2 + n) m\n\n--------------------------------------------------------------------------------\n-- Tree to Stack\n--------------------------------------------------------------------------------\n\ntree→stack⊙ : (t : Tree) → Dyck (suc m) k → Dyck m (size⊙ t k)\ntree→stack⊙ ⟨⟩ = ⟨_\ntree→stack⊙ (xs * ys) = tree→stack⊙ xs ∘ tree→stack⊙ ys ∘ ⟩_\n\ntree→stack : (t : Tree) → Dyck 0 (size t)\ntree→stack tr = tree→stack⊙ tr ⟩!\n\n--------------------------------------------------------------------------------\n-- Stack to Tree\n--------------------------------------------------------------------------------\n\nstack→tree⊙ : Dyck n m → Vec Tree n → Tree\nstack→tree⊙ ⟩! (v ∷ []) = v\nstack→tree⊙ (⟨ is) st = stack→tree⊙ is (⟨⟩ ∷ st)\nstack→tree⊙ (⟩ is) (t₁ ∷ t₂ ∷ st) = stack→tree⊙ is (t₂ * t₁ ∷ st)\n\nstack→tree : Dyck 0 n → Tree\nstack→tree ds = stack→tree⊙ ds []\n\n--------------------------------------------------------------------------------\n-- Size lemma\n--------------------------------------------------------------------------------\n\nstack→tree-size⊙ : {st : Vec Tree n} (is : Dyck n m) →\n size (stack→tree⊙ is st) ≡ foldl′ size⊙ m st\nstack→tree-size⊙ ⟩! = refl\nstack→tree-size⊙ (⟨ is) = stack→tree-size⊙ is\nstack→tree-size⊙ (⟩ is) = stack→tree-size⊙ is\n\n--------------------------------------------------------------------------------\n-- Roundtrip\n--------------------------------------------------------------------------------\n\ntree→stack→tree⊙ : {is : Dyck (1 + n) m} {st : Vec Tree n} (e : Tree) →\n stack→tree⊙ (tree→stack⊙ e is) st ≡ stack→tree⊙ is (e ∷ st)\ntree→stack→tree⊙ ⟨⟩ = refl\ntree→stack→tree⊙ (xs * ys) = tree→stack→tree⊙ xs ; tree→stack→tree⊙ ys\n\nfoldlNN : ∀ {A : Type a} {p} (P : ℕ → ℕ → Type p) →\n (f : A → ℕ → ℕ) →\n (∀ {n m} → (x : A) → P (suc n) m → P n (f x m)) →\n P n m →\n (xs : Vec A n) → P zero (foldl′ f m xs)\nfoldlNN {n = zero} P f s b xs = b\nfoldlNN {n = suc n} P f s b (x ∷ xs) = foldlNN P f s (s x b) xs\n\n\nstack→tree→stack⊙ : {st : Vec Tree n} (is : Dyck n m) →\n subst (Dyck 0) (stack→tree-size⊙ is) (tree→stack (stack→tree⊙ is st))\n ≡ foldlNN Dyck size⊙ tree→stack⊙ is st\nstack→tree→stack⊙ ⟩! = substRefl {B = Dyck 0} _\nstack→tree→stack⊙ (⟨ is) = stack→tree→stack⊙ is\nstack→tree→stack⊙ (⟩ is) = stack→tree→stack⊙ is\n\n--------------------------------------------------------------------------------\n-- Isomorphism\n--------------------------------------------------------------------------------\n\nSTree : ℕ → Type\nSTree = fiber size\n\ntree-stack : STree n ⇔ Dyck 0 n\ntree-stack .fun (t , n) = subst (Dyck 0) n (tree→stack t)\ntree-stack .inv st .fst = stack→tree st\ntree-stack .inv st .snd = stack→tree-size⊙ st\ntree-stack .leftInv (t , sz≡) =\n Σ≡Prop\n (λ _ → isSetℕ _ _)\n (J\n (λ n sz≡ → stack→tree (subst (Dyck 0) sz≡ (tree→stack t)) ≡ t)\n (cong stack→tree (substRefl {B = Dyck 0} (tree→stack t)) ; tree→stack→tree⊙ t) sz≡)\ntree-stack .rightInv st = stack→tree→stack⊙ st\n\n--------------------------------------------------------------------------------\n-- Finite\n--------------------------------------------------------------------------------\n\nopen import Data.List\n\nsupport-dyck : ∀ n m → List (Dyck n m)\nsupport-dyck = λ n m → sup-k n m id []\n module ListDyck where\n Diff : Type → Type₁\n Diff A = ∀ {B : Type} → (A → B) → List B → List B\n\n infixr 5 _++′_\n _++′_ : Diff A → Diff A → Diff A\n xs ++′ ys = λ k → xs k ∘ ys k\n\n mutual\n sup-k : ∀ n m → Diff (Dyck n m)\n sup-k n m = end n m ++′ lefts n m ++′ rights n m\n\n lefts : ∀ n m → Diff (Dyck n m)\n lefts n zero k = id\n lefts n (suc m) k = sup-k (suc n) m (k ∘ ⟨_)\n\n rights : ∀ n m → Diff (Dyck n m)\n rights (suc (suc n)) m k = sup-k (suc n) m (k ∘ ⟩_)\n rights _ m k = id\n\n end : ∀ n m → Diff (Dyck n m)\n end 1 0 k xs = k ⟩! ∷ xs\n end _ _ k = id\n\nopen import Data.List.Membership\nopen import Data.Fin\n\ncover-dyck : (x : Dyck n m) → x ∈ support-dyck n m\ncover-dyck x = go _ _ x id []\n where\n open ListDyck\n\n mutual\n pushLefts : ∀ n m (k : Dyck n m → B) x xs → x ∈ xs → x ∈ lefts n m k xs\n pushLefts n (suc m) k = pushSup (suc n) m (λ z → k (⟨ z))\n pushLefts _ zero k x xs p = p\n\n pushEnd : ∀ n m (k : Dyck n m → B) x xs → x ∈ xs → x ∈ end n m k xs\n pushEnd 0 m k x xs p = p\n pushEnd 1 0 k x xs (i , p) = fs i , p\n pushEnd 1 (suc m) k x xs p = p\n pushEnd (suc (suc n)) m k x xs p = p\n\n pushRights : ∀ n m (k : Dyck n m → B) x xs → x ∈ xs → x ∈ rights n m k xs\n pushRights (suc (suc n)) m k = pushSup (suc n) m λ z → k (⟩ z)\n pushRights 1 _ _ _ _ p = p\n pushRights 0 _ _ _ _ p = p\n\n pushSup : ∀ n m (k : Dyck n m → B) x xs → x ∈ xs → x ∈ sup-k n m k xs\n pushSup n m k x xs p = pushEnd n m k x (lefts n m k (rights n m k xs)) (pushLefts n m k x (rights n m k xs) (pushRights n m k x xs p))\n\n go : ∀ n m → (x : Dyck n m) → (k : Dyck n m → A) → (xs : List A) → k x ∈ sup-k n m k xs\n go .1 .0 ⟩! k xs = f0 , refl\n go 0 (suc m) (⟨ x) k xs = go 1 m x (k ∘ ⟨_) xs\n go 1 (suc m) (⟨ x) k xs = go 2 m x (k ∘ ⟨_) xs\n go (suc n@(suc _)) (suc m) (⟨ x) k xs = go (suc (suc n)) m x (k ∘ ⟨_) (rights (suc n) (suc m) k xs)\n go (suc n) m (⟩ x) k xs =\n let p = go n m x (k ∘ ⟩_) xs\n in pushEnd (suc n) m k (k (⟩ x)) (lefts (suc n) m k _) (pushLefts (suc n) m k (k (⟩ x)) (rights (suc n) m k xs) p)\n", "meta": {"hexsha": "644a513ea4fd417e70e63e5120e26071575c6100", "size": 6385, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Dyck/Sized.agda", "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_issues_repo_path": "Data/Dyck/Sized.agda", "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Dyck/Sized.agda", "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "avg_line_length": 34.7010869565, "max_line_length": 138, "alphanum_fraction": 0.4319498825, "num_tokens": 2301, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972616934406, "lm_q2_score": 0.7217431943271999, "lm_q1q2_score": 0.6283476486271371}} {"text": "------------------------------------------------------------------------------\n-- Definition of FOTC streams using the Agda co-inductive combinators\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOT.FOTC.Data.Stream.TypeSL where\n\nopen import Codata.Musical.Notation\nopen import Data.Product renaming ( _×_ to _∧_ )\nopen import Relation.Binary.PropositionalEquality\n\n------------------------------------------------------------------------------\n\n-- We add 3 to the fixities of the Agda standard library 0.8.1 (see\n-- Data/List.agda).\ninfixr 8 _∷_\n\ndata D : Set where\n _∷_ : D → D → D\n\ndata Stream : D → Set where\n consS : ∀ x {xs} → ∞ (Stream xs) → Stream (x ∷ xs)\n\nStream-out : ∀ {xs} → Stream xs →\n ∃ λ x' → ∃ λ xs' → Stream xs' ∧ xs ≡ x' ∷ xs'\nStream-out (consS x' {xs'} Sxs') = x' , xs' , ♭ Sxs' , refl\n\n{-# NON_TERMINATING #-}\nStream-coind :\n (A : D → Set) →\n (∀ {xs} → A xs → ∃ λ x' → ∃ λ xs' → xs ≡ x' ∷ xs' ∧ A xs') →\n ∀ {xs} → A xs → Stream xs\nStream-coind A h Axs with h Axs\n... | x' , xs' , prf₁ , Axs' = subst Stream (sym prf₁) prf₂\n where\n prf₂ : Stream (x' ∷ xs')\n prf₂ = consS x' (♯ Stream-coind A h Axs')\n", "meta": {"hexsha": "1e842938634c7b6ccbd0a017609fd36e183bf89f", "size": 1355, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/FOTC/Data/Stream/TypeSL.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/FOT/FOTC/Data/Stream/TypeSL.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/FOT/FOTC/Data/Stream/TypeSL.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 32.2619047619, "max_line_length": 78, "alphanum_fraction": 0.4745387454, "num_tokens": 400, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8558511543206819, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.6282970494854097}} {"text": "\nmodule Haskell.Prim.Maybe where\n\nopen import Agda.Builtin.List public\n\nopen import Haskell.Prim\nopen import Haskell.Prim.List\n\n--------------------------------------------------\n-- Maybe\n\ndata Maybe {ℓ} (a : Set ℓ) : Set ℓ where\n Nothing : Maybe a\n Just : a -> Maybe a\n\nmaybe : ∀ {ℓ₁ ℓ₂} {a : Set ℓ₁} {b : Set ℓ₂} → b → (a → b) → Maybe a → b\nmaybe n j Nothing = n\nmaybe n j (Just x) = j x\n\nmapMaybe : (a -> Maybe b) -> List a -> List b \nmapMaybe _ [] = []\nmapMaybe f (x ∷ xs) = \n case f x of λ where\n Nothing -> mapMaybe f xs\n (Just v) -> v ∷ (mapMaybe f xs)", "meta": {"hexsha": "d68b71e2a1d4be1ab33d4128be05a8e960e1e496", "size": 572, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lib/Haskell/Prim/Maybe.agda", "max_stars_repo_name": "ioanasv/agda2hs", "max_stars_repo_head_hexsha": "17cdbeb36af3d0b735c5db83bb811034c39a19cd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-05-25T09:41:34.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-25T09:41:34.000Z", "max_issues_repo_path": "lib/Haskell/Prim/Maybe.agda", "max_issues_repo_name": "ioanasv/agda2hs", "max_issues_repo_head_hexsha": "17cdbeb36af3d0b735c5db83bb811034c39a19cd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/Haskell/Prim/Maybe.agda", "max_forks_repo_name": "ioanasv/agda2hs", "max_forks_repo_head_hexsha": "17cdbeb36af3d0b735c5db83bb811034c39a19cd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.88, "max_line_length": 71, "alphanum_fraction": 0.5454545455, "num_tokens": 193, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8558511469672594, "lm_q2_score": 0.734119526900183, "lm_q1q2_score": 0.6282970391085835}} {"text": "{-# OPTIONS --type-in-type #-}\n\nU = Set\n\nid : {A : Set} → A → A\nid = λ x → x\n\nid2 : ∀ {A} → A → A\nid2 = id id\n\nid3 : ∀ {A} → A → A\nid3 = λ x → id x\n\nid4 : {A : Set} -> A -> A\nid4 = \\x -> x\n\nthe : (A : Set) → A → A\nthe = λ _ x → x\n\nconstTy = {A B : Set} → A → B → A\n\nconst : constTy\nconst = λ x y → x\n\nconstU = const {Set}\n\nnamedArgTest = const {B = U} U\nnamedArgTest2 = the constTy (λ x y → x) {B = U} U\n\n\n-- Church bools\n--------------------------------------------------------------------------------\nBool = (B : U) → B → B → B\n\ntrue : Bool\ntrue = λ _ t f → t\n\nfalse : Bool\nfalse = λ _ t f → f\n\nand : Bool → Bool → Bool\nand = λ b1 b2 → b1 Bool true b2\n\n\n-- Church natural numbers\n--------------------------------------------------------------------------------\n\nNat : U\nNat = (n : U) → (n → n) → n → n\n\nzero : Nat\nzero = λ n s z → z\n\nsuc : Nat → Nat\nsuc = λ a n s z → s (a n s z)\n\nn2 : Nat\nn2 = λ n s z → s (s z)\n\nn5 : Nat\nn5 = λ n s z → s (s (s (s (s z))))\n\nmul : Nat → Nat → Nat\nmul = λ a b n s z → a n (b n s) z\n\nadd : Nat → Nat → Nat\nadd = λ a b n s z → a n s (b n s z)\n\nn10 = mul n2 n5\nn10b = mul n5 n2\nn100 = mul n10 n10\nn100b = mul n10b n10b\nn10k = mul n100 n100\nn10kb = mul n100b n100b\nn100k = mul n10k n10\nn100kb = mul n10kb n10b\nn1M = mul n10k n100\nn1Mb = mul n10kb n100b\nn10M = mul n1M n10\nn10Mb = mul n1Mb n10b\nn100M = mul n10M n10\nn200M = mul n2 n100M\n\n-- Church lists\n--------------------------------------------------------------------------------\n\nList : U → U\nList = λ a → (l : U) → (a → l → l) → l → l\n\nlnil : ∀{a} → List a\nlnil = λ l c n → n\n\nlcons : ∀{a} → a → List a → List a\nlcons = λ a as l c n → c a (as l c n)\n\nlist1 = lcons true (lcons false (lcons false lnil))\n\nmap : ∀{a b} → (a → b) → List a → List b\nmap = λ f as l c → as l (λ a → c (f a))\n\n\n-- Church vectors\n--------------------------------------------------------------------------------\n\nVec : U → Nat → U\nVec = λ a n → (V : Nat → U) → V zero → (∀{n} → a → V n → V (suc n)) → V n\n\nvnil : ∀{a} → Vec a zero\nvnil = λ V n c → n\n\nvcons : ∀{a n} → a → Vec a n → Vec a (suc n)\nvcons = λ a as V n c → c a (as V n c)\n\nvec1 = vcons true (vcons false (vcons true vnil))\n\n\nvecStress =\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true\n (vcons true (vcons true\n vnil))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))\n ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))\n ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))\n ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))\n ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))\n ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))\n ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))\n ))))))))))))))))))))))))))))))))))))\n\n\n-- Leibniz (Church) propositional equality, useful for testing conversion.\n--------------------------------------------------------------------------------\n\nEq : ∀{A : U} → A → A → U\nEq {A} = λ x y → (P : A → U) → P x → P y\n\nrefl : ∀{A}{x : A} → Eq x x\nrefl = λ P px → px\n\ntrans : ∀{A}{x y z : A} → Eq x y → Eq y z → Eq x z\ntrans = λ p q → q _ p\n\nsym : ∀{A}{x y : A} → Eq x y → Eq y x\nsym {_}{x}{y} = λ p → p (λ y → Eq y x) refl\n\nap : ∀{A B}(f : A → B){x y : A} → Eq x y → Eq (f x) (f y)\nap = λ f {x}{y} p → p (λ y → Eq (f x) (f y)) refl\n\n\n-- Pairs, Top, Bot\n--------------------------------------------------------------------------------\n\nPair : U → U → U\nPair = λ A B → (Pair : U)(pair : A → B → Pair) → Pair\n\npair : ∀{A B} → A → B → Pair A B\npair = λ a b Pair pair → pair a b\n\nproj1 : ∀{A B} → Pair A B → A\nproj1 = λ p → p _ (λ x y → x)\n\nproj2 : ∀{A B} → Pair A B → B\nproj2 = λ p → p _ (λ x y → y)\n\nTop : U\nTop = (Top : U)(tt : Top) → Top\n\ntt : Top\ntt = λ Top tt → tt\n\nBot : U\nBot = (Bot : U) → Bot\n\n\n-- Dependent function composition\n--------------------------------------------------------------------------------\n\ncomp :\n ∀ {A : U}\n {B : A → U}\n {C : ∀{a} → B a → U}\n (f : ∀{a}(b : B a) → C b)\n (g : (a : A) → B a)\n (x : A)\n → C (g x)\ncomp = λ f g a → f (g a)\n\ncompTest1 : Nat → Nat\ncompTest1 = comp suc suc\n\ncompTest2 : ∀{m A} → A → Vec A m → Vec A (suc (suc m))\ncompTest2 = λ a → comp (vcons a) (vcons a)\n\n-- Some stress tests\n--------------------------------------------------------------------------------\n\nnfun : Nat → U\nnfun n = n U (λ A → U → A) U\n\n-- OK\nsynEqTest1 : Eq n1M n1M\nsynEqTest1 = refl\n\n-- fail\n-- synEqTest2 : nfun n10k → nfun n10k\n-- synEqTest2 = λ x → x\n\n-- OK\nidStress : ∀{A} → A → A\nidStress =\n id id id id id id id id id id id id id id id id id id id id\n id id id id id id id id id id id id id id id id id id id id\n\n\n-- fail\n-- pairStress : Top\n-- pairStress =\n-- let x0 = pair tt tt\n-- x1 = pair x0 x0\n-- x2 = pair x1 x1\n-- x3 = pair x2 x2\n-- x4 = pair x3 x3\n-- x5 = pair x4 x4\n-- x6 = pair x5 x5\n-- x7 = pair x6 x6\n-- x8 = pair x7 x7\n-- x9 = pair x8 x8\n-- x10 = pair x9 x9\n-- x11 = pair x10 x10\n-- x12 = pair x11 x11\n-- x13 = pair x12 x12\n-- x14 = pair x13 x13\n-- x15 = pair x14 x14\n-- x16 = pair x15 x15\n-- x17 = pair x16 x16\n-- x18 = pair x17 x17\n-- x19 = pair x18 x18\n-- x20 = pair x19 x19\n-- in tt\n\nforceNat : Nat → Bool\nforceNat n = n _ (λ b → b) true\n\ncomputeTest = forceNat n10M\n\n\n-- Conversion checking tests\n--------------------------------------------------------------------------------\n\n-- conv100k : Eq n100k n100kb\n-- conv100k = refl\n\n-- conv1M : Eq n1M n1Mb\n-- conv1M = refl\n\n-- OOM\n-- conv10M : Eq n10M n1M0b\n-- conv10M = refl\n\n-- convNfun1M : Eq (nfun n1M) (nfun n1Mb)\n-- convNfun1M = refl\n\n-- conv10kmeta : Eq n10k (add n10kb _)\n-- conv10kmeta = refl\n\n-- OOM\n-- conv1Mmeta : Eq n1M (add n1Mb _)\n-- conv1Mmeta = refl\n\n\n--------------------------------------------------------------------------------\n\n-- normalized instantly\nlazyU = const U (forceNat n10M)\n\nlocalCBN : Nat → Bool\nlocalCBN\n = λ n → let m = forceNat (mul n n100k)\n in n _ (λ b → and m b) true\n\ncbnReference = forceNat (mul n10 n100k)\nlocalCBNtest = localCBN n10\n\n\n-- Church-coded simply typed lambda calculus\n--------------------------------------------------------------------------------\n\nTy : U\nTy\n = (Ty : U)\n (ι : Ty)\n (fun : Ty → Ty → Ty)\n → Ty\n\nι : Ty\nι\n = λ _ ι _ → ι\n\nfun : Ty → Ty → Ty\nfun\n = λ A B Ty ι fun → fun (A Ty ι fun) (B Ty ι fun)\n\nCon : U\nCon\n = (Con : U)\n (nil : Con)\n (cons : Con → Ty → Con)\n → Con\n\nnil : Con\nnil\n = λ Con nil cons → nil\n\ncons : Con → Ty → Con\ncons\n = λ Γ A Con nil cons → cons (Γ Con nil cons) A\n\nVar : Con → Ty → U\nVar\n = λ Γ A →\n (Var : Con → Ty → U)\n (vz : ∀{Γ A} → Var (cons Γ A) A)\n (vs : ∀{Γ B A} → Var Γ A → Var (cons Γ B) A)\n → Var Γ A\n\nvz : ∀{Γ A} → Var (cons Γ A) A\nvz\n = λ Var vz vs → vz\n\nvs : ∀{Γ B A} → Var Γ A → Var (cons Γ B) A\nvs\n = λ x Var vz vs → vs (x Var vz vs)\n\nTm : Con → Ty → U\nTm\n = λ Γ A →\n (Tm : Con → Ty → U)\n (var : ∀{Γ A} → Var Γ A → Tm Γ A)\n (lam : ∀{Γ A B} → Tm (cons Γ A) B → Tm Γ (fun A B))\n (app : ∀{Γ A B} → Tm Γ (fun A B) → Tm Γ A → Tm Γ B)\n → Tm Γ A\n\nvar : ∀{Γ A} → Var Γ A → Tm Γ A\nvar\n = λ x Tm var lam app → var x\n\nlam : ∀{Γ A B} → Tm (cons Γ A) B → Tm Γ (fun A B)\nlam\n = λ t Tm var lam app → lam (t Tm var lam app)\n\napp : ∀{Γ A B} → Tm Γ (fun A B) → Tm Γ A → Tm Γ B\napp\n = λ t u Tm var lam app → app (t Tm var lam app) (u Tm var lam app)\n\n\n-- Well-typed interpreter for Church-coded STLC\n--------------------------------------------------------------------------------\n\nEvalTy : Ty → U\nEvalTy\n = λ A → A _ Bot (λ A B → A → B)\n\nEvalCon : Con → U\nEvalCon\n = λ Γ → Γ _ Top (λ Δ A → Pair Δ (EvalTy A))\n\nEvalVar : ∀{Γ A} → Var Γ A → EvalCon Γ → EvalTy A\nEvalVar\n = λ x → x (λ Γ A → EvalCon Γ → EvalTy A)\n (λ env → proj2 env)\n (λ rec env → rec (proj1 env))\n\nEvalTm : ∀{Γ A} → Tm Γ A → EvalCon Γ → EvalTy A\nEvalTm\n = λ t → t (λ Γ A → EvalCon Γ → EvalTy A)\n EvalVar\n (λ t env α → t (pair env α))\n (λ t u env → t env (u env))\n\n-- Large embedded STLC term\n--------------------------------------------------------------------------------\n\nt1 : Tm nil (fun (fun ι ι) (fun ι ι))\nt1\n = lam (lam (\n app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz))\n (var vz))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))\n )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))\n )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))\n ))))))))))))))))))))))))))))))))))))))\n ))\n\n-- test evaluation\nevalTest = EvalTm t1 tt\n", "meta": {"hexsha": "436d12d82f5a7930af700e5958a419abefd98698", "size": 20157, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "bench/Bench.agda", "max_stars_repo_name": "zarybnicky/smalltt", "max_stars_repo_head_hexsha": "783840e3444cbdc7927dd4a940d9c0ad5dc47223", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "bench/Bench.agda", "max_issues_repo_name": "zarybnicky/smalltt", "max_issues_repo_head_hexsha": "783840e3444cbdc7927dd4a940d9c0ad5dc47223", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "bench/Bench.agda", "max_forks_repo_name": "zarybnicky/smalltt", "max_forks_repo_head_hexsha": "783840e3444cbdc7927dd4a940d9c0ad5dc47223", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.1215469613, "max_line_length": 80, "alphanum_fraction": 0.5235898199, "num_tokens": 7488, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511359371249, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.6282970359896813}} {"text": "-- Implementation of Gödel's System T as an example for\n-- Σ-terms (Σ = {Z, S}; α(Z) = 0; α(S) = 1) with primitive recursion\nmodule SystemT where\n\nopen import Data.Vec hiding (_++_)\nopen import Data.Nat\nopen import Data.List\nopen import Data.List.All\n\n-- Not in use yet:\n-- Σ is a vector of given length n of natural numbers denoting the arity of symbols\ndata Σ {n : ℕ} : Set where\n intr : Vec ℕ n → Σ\n \n-- Successor has arity one, Zero has arity 0\nΣ-Nat = intr (1 ∷ 0 ∷ [])\n\n-- Types\ndata Type : Set where\n Nat : Type\n Fun : Type → Type → Type\n\n-- Type environment\nEnv : Set\nEnv = List Type\n\n-- Environment lookup\ndata _∈`_ : Type → Env → Set where\n here : ∀ {φ A} → A ∈` (A ∷ φ)\n there : ∀ {φ A A'} → A ∈` φ → A ∈` (A' ∷ φ)\n\n-- Zero & Successor, Variables, prim. recursion on Σ-Nat, Abstraction, Application\ndata Expr : Env → Type → Set where\n Z : ∀ {φ} → Expr φ Nat\n S : ∀ {φ} → Expr φ Nat → Expr φ Nat\n Var : ∀ {φ A} → A ∈` φ → Expr φ A\n NatRec : ∀ {φ A} → Expr φ A → Expr (A ∷ φ) A → Expr φ Nat → Expr φ A\n Abs : ∀ {φ A B} → Expr (A ∷ φ) B → Expr φ (Fun A B)\n App : ∀ {φ A B} → Expr φ (Fun A B) → Expr φ A → Expr φ B\n\n\n----- Big step semantics using Agda semantics -----\nValue : Type → Set\nValue Nat = ℕ\nValue (Fun A B) = Value A → Value B\n\n-- Lookup in environment of values\naccess : ∀ {A φ} → A ∈` φ → All Value φ → Value A\naccess here (px ∷ p) = px\naccess (there x) (px ∷ p) = access x p\n\n-- Conversion of a natural number to an expression\nnatconv : ∀ {φ} → ℕ → Expr φ Nat\nnatconv zero = Z\nnatconv (suc n) = S (natconv n)\n\nnatrec : ∀ {A : Set} → A → (A → A) → ℕ → A\nnatrec vz vs zero = vz\nnatrec vz vs (suc n) = vs (natrec vz vs n)\n\n-- Evaluation\neval : ∀ {φ A} → Expr φ A → All Value φ → Value A\neval Z ϱ = zero\neval (S x) ϱ = suc (eval x ϱ)\neval (Var x) ϱ = access x ϱ\neval (NatRec ez es enat) ϱ = natrec (eval ez ϱ) (λ v → eval es (v ∷ ϱ)) (eval enat ϱ)\neval (Abs e) ϱ = λ x → eval e (x ∷ ϱ)\neval (App e e₁) ϱ = (eval e ϱ) (eval e₁ ϱ)\n\n----- Small step semantics -----\n----- Substitution: Two methods.\n-- a) Define simultaneous substitution with a map from variables to expression; see LDLC.agda and\n-- the book \"Programming Language Foundations in Agda\"\n-- b) Define singular substitution but \"within\" environments, i.e. for terms of the form (φ' ++ A ∷ φ)\n-- This makes the Var case a tiny bit more tricky. See also type substitution in LDLC.agda\n----- Method b is chosen since it is a bit shorter and (subjectively) easier to understand\n\n-- Lemmas required for substitution, esp. Var case\n-- 0) Insertion: Insert a variable and adjust DeBruijn indices\n-- 0.1) De Bruijn adjustement\ninsdebr : ∀ {φ φ'} {A B} → B ∈` (φ' ++ φ) → B ∈` (φ' ++ (A ∷ φ))\ninsdebr {φ' = []} here = there here\ninsdebr {φ' = []} (there x) = there (there x)\ninsdebr {φ' = y ∷ ys} here = here\ninsdebr {φ' = y ∷ ys} (there x) = there (insdebr x)\n-- 0.2) Insertion\nins : ∀ {φ φ'} {A B} → Expr (φ' ++ φ) B → Expr (φ' ++ A ∷ φ) B\nins Z = Z\nins (S x) = S (ins x)\nins (Var x) = Var (insdebr x)\nins {φ' = φ'} (NatRec{A = A'} ez es en) = NatRec (ins ez) (ins{φ' = A' ∷ φ'} es) (ins en)\nins {φ' = φ'} (Abs{A = A'} x) = Abs (ins{φ' = A' ∷ φ'} x)\nins (App x y) = App (ins x) (ins y)\n-- 1) Variable substitution\nvarsub : ∀ {φ φ'} {A B} → A ∈` (φ' ++ B ∷ φ) → Expr φ B → Expr (φ' ++ φ) A\nvarsub {φ' = []} here M = M\nvarsub {φ' = []} (there x) M = Var x\nvarsub {φ' = z ∷ zs} here M = Var here\nvarsub {φ' = z ∷ zs} (there x) M = ins{φ' = []} (varsub x M)\n\n-- Substitution: Given an expression that binds topmost variable to B and has type A & \n-- an expression of type B => we get an expression of type A by binding the topmost\n-- variable to that expression\n_[[_]] : ∀ {φ φ'} {A B : Type} → Expr (φ' ++ B ∷ φ) A → Expr φ B → Expr (φ' ++ φ) A\nZ [[ M ]] = Z\nS N [[ M ]] = S (N [[ M ]])\nVar x [[ M ]] = varsub x M\nNatRec N N' N'' [[ M ]] = NatRec (N [[ M ]]) (N' [[ M ]]) (N'' [[ M ]])\nAbs N [[ M ]] = Abs (N [[ M ]])\nApp N N' [[ M ]] = App (N [[ M ]]) (N' [[ M ]])\n\n-- Values\ndata Value' {φ} : (t : Type) → Expr φ t → Set where\n VZero : Value' Nat Z\n VSuc : ∀ {x} → Value' Nat x → Value' Nat (S x)\n VFun : ∀ {A B exp} → Value' (Fun A B) (Abs exp)\n\n-- Semantics\ndata _↠_ {φ} : {A : Type} → Expr φ A → Expr φ A → Set where\n -- Basic call-by-value λ-calc. stuff\n -- Application: Elimination & Reduction\n ξ-App1 : ∀ {A B} {L L' : Expr φ (Fun B A)} {M}\n → L ↠ L'\n → App L M ↠ App L' M\n\n ξ-App2 : ∀ {A B} {M M' : Expr φ A} {L : Expr φ (Fun A B)}\n → Value' (Fun A B) L\n → M ↠ M'\n → App L M ↠ App L M'\n\n β-App : ∀ {A B M exp}\n → Value' B M\n → App{B = A} (Abs exp) M ↠ (exp [[ M ]])\n\n -- Elimination for successor\n ξ-Nat : ∀ {L L'}\n → L ↠ L'\n → S L ↠ S L'\n \n -- Interesting cases\n ξ-NatRec : ∀ {A} {Ez : Expr φ A} {Es En En'}\n → En ↠ En'\n → NatRec Ez Es En ↠ NatRec Ez Es En'\n\n β-NatRec-Z : ∀ {A} {Ez : Expr φ A} {Es} \n → NatRec Ez Es Z ↠ Ez\n\n β-NatRec-S : ∀ {A} {Ez : Expr φ A} {Es} {n}\n → Value' Nat n\n → NatRec Ez Es (S n) ↠ (Es [[ NatRec Ez Es n ]])\n\n----- Reflexive & Transitive closure of ↠; defined for chain reasoning\ninfix 1 begin_\ninfix 2 _⇨_\ninfix 2 _⇨⟨_⟩_\ninfix 3 _∎\n\ndata _⇨_ : ∀ {φ} {A} → Expr φ A → Expr φ A → Set where\n -- Reflexivity / end of Reasoning\n _∎ : ∀ {φ} {A} (L : Expr φ A)\n → (L ⇨ L)\n\n -- Transitivity / chain Reasoning\n _⇨⟨_⟩_ : ∀ {φ A} {L' M : Expr φ A}\n → (L : Expr φ A)\n → L ↠ L'\n → L' ⇨ M\n → L ⇨ M\n\n-- Highlight the start of a chain of reasoning\nbegin_ : ∀ {φ} {A} {M N : Expr φ A} → M ⇨ N → M ⇨ N\nbegin x = x\n\n----- Progress Theorem; also used to generate evaluation sequence (since it defines how to evaluate)\n-- Definition: ∀ M : (Value'(M) ∨ (∃ N : M ↠ N))\ndata Progress {A} (M : Expr [] A) : Set where\n step : ∀ {N : Expr [] A} → M ↠ N → Progress M\n done : Value' A M → Progress M\n\n-- Proof\nprogress : ∀ {A} → (M : Expr [] A) → Progress M\nprogress Z = done VZero\nprogress (S L) with progress L\n... | step L↠N = step (ξ-Nat L↠N)\n... | done y = done (VSuc y)\nprogress (NatRec ez es en) with progress en\n... | step en↠en' = step (ξ-NatRec en↠en')\n... | done (VZero) = step (β-NatRec-Z)\n... | done (VSuc x) = step (β-NatRec-S x)\nprogress (Abs L) = done VFun\nprogress (App L N) with progress L\n... | step L↠L' = step (ξ-App1 L↠L')\n... | done VFun with progress N\n... | step N↠N' = step (ξ-App2 VFun N↠N')\n... | done val = step (β-App val)\n\n----- Generation of evaluation sequence (idea & implementation from PLFA)\n-- Used to limit number of steps taken\ndata Gas : Set where\n gas : ℕ → Gas\n\n-- Either enough steps taken or Value' reached\ndata Finished {φ A} (N : Expr φ A) : Set where\n done : Value' A N → Finished N\n out-of-gas : Finished N\n\n-- Encapsulates the steps taken\ndata Steps : ∀ {A} → Expr [] A → Set where\n steps : ∀ {A} {L N : Expr [] A}\n → L ⇨ N\n → Finished N\n → Steps L\n\n-- Generation of evaluation\neval' : ∀ {A} → Gas → (L : Expr [] A) → Steps L\neval' (gas zero) L = steps (L ∎) out-of-gas\neval' (gas (suc m)) L with progress L\n... | done VL = steps (L ∎) (done VL)\n... | step {M} L↠M with eval' (gas m) M\n... | steps M⇨N fin = steps (L ⇨⟨ L↠M ⟩ M⇨N) fin\n \n\n----- Examples\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl)\n\nemptyenv : All Value []\nemptyenv = []\n\n-- Addition of two numbers defined as primitive recursion\n_plus_ : ℕ → ℕ → Expr [] Nat\nn plus m = NatRec (natconv n) (S (Var here)) (natconv m)\n\n-- _ : eval (3 plus 5) emptyenv ≡ 8\n-- _ = refl\n\n_ : eval' (gas 5) (1 plus 2) ≡ steps\n (NatRec (S Z) (S (Var here)) (S (S Z)) ⇨⟨ β-NatRec-S (VSuc VZero) ⟩\n (S (NatRec (S Z) (S (Var here)) (S Z)) ⇨⟨ ξ-Nat (β-NatRec-S VZero) ⟩\n (S (S (NatRec (S Z) (S (Var here)) Z)) ⇨⟨ ξ-Nat (ξ-Nat β-NatRec-Z) ⟩ S (S (S Z)) ∎)))\n (done (VSuc (VSuc (VSuc VZero)))) -- 3\n_ = {!!}\n\n-- Multiplication of two numbers defined as primitive recursion using addition\n_times_ : ℕ → ℕ → Expr [] Nat\nn times m = NatRec Z (NatRec (natconv n) (S (Var here)) (Var here)) (natconv m)\n\n-- _ : eval (50 times 5) emptyenv ≡ 250\n-- _ = refl\n\n_ : eval' (gas 10) (2 times 2) ≡ steps\n (NatRec Z (NatRec (S (S Z)) (S (Var here)) (Var here)) (S (S Z)) ⇨⟨ β-NatRec-S (VSuc VZero) ⟩\n (NatRec (S (S Z)) (S (Var here))\n (NatRec Z (NatRec (S (S Z)) (S (Var here)) (Var here)) (S Z)) ⇨⟨ ξ-NatRec (β-NatRec-S VZero) ⟩\n (NatRec (S (S Z)) (S (Var here))\n (NatRec (S (S Z)) (S (Var here))\n (NatRec Z (NatRec (S (S Z)) (S (Var here)) (Var here)) Z)) ⇨⟨ ξ-NatRec (ξ-NatRec β-NatRec-Z) ⟩\n (NatRec (S (S Z)) (S (Var here))\n (NatRec (S (S Z)) (S (Var here)) Z) ⇨⟨ ξ-NatRec β-NatRec-Z ⟩\n (NatRec (S (S Z)) (S (Var here)) (S (S Z)) ⇨⟨ β-NatRec-S (VSuc VZero) ⟩\n (S (NatRec (S (S Z)) (S (Var here)) (S Z)) ⇨⟨ ξ-Nat (β-NatRec-S VZero) ⟩\n (S (S (NatRec (S (S Z)) (S (Var here)) Z)) ⇨⟨ ξ-Nat (ξ-Nat β-NatRec-Z) ⟩ S (S (S (S Z))) ∎)))))))\n (done (VSuc (VSuc (VSuc (VSuc VZero))))) -- 4\n_ = {!!}\n", "meta": {"hexsha": "f0d849a1870971bf2fea6df3592fe90c578166ea", "size": 9514, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/sigmatypes/SystemT.agda", "max_stars_repo_name": "kcaliban/ldlc", "max_stars_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/sigmatypes/SystemT.agda", "max_issues_repo_name": "kcaliban/ldlc", "max_issues_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/sigmatypes/SystemT.agda", "max_forks_repo_name": "kcaliban/ldlc", "max_forks_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-14T17:52:29.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-14T17:52:29.000Z", "avg_line_length": 35.9018867925, "max_line_length": 103, "alphanum_fraction": 0.5181837292, "num_tokens": 3546, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.855851143290548, "lm_q2_score": 0.7341195152660687, "lm_q1q2_score": 0.6282970264523677}} {"text": "{-# OPTIONS --cubical --safe --postfix-projections #-}\n\nmodule Data.Bool.Properties where\n\nopen import Prelude\nopen import Data.Bool\nopen import Data.Unit.Properties\n\nT? : ∀ x → Dec (T x)\nT? x .does = x\nT? false .why = ofⁿ id\nT? true .why = ofʸ tt\n\nisPropT : ∀ x → isProp (T x)\nisPropT false = isProp⊥\nisPropT true = isProp⊤\n\ndiscreteBool : Discrete Bool\ndiscreteBool false y .does = not y\ndiscreteBool true y .does = y\ndiscreteBool false false .why = ofʸ refl\ndiscreteBool false true .why = ofⁿ λ p → subst (bool ⊤ ⊥) p tt\ndiscreteBool true false .why = ofⁿ λ p → subst (bool ⊥ ⊤) p tt\ndiscreteBool true true .why = ofʸ refl\n", "meta": {"hexsha": "fd7e1d1806d3b77763ebef1094a1ae63c0da358d", "size": 628, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Data/Bool/Properties.agda", "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z", "max_issues_repo_path": "agda/Data/Bool/Properties.agda", "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Data/Bool/Properties.agda", "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "avg_line_length": 25.12, "max_line_length": 62, "alphanum_fraction": 0.6942675159, "num_tokens": 218, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.835483553488848, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.6282941373931298}} {"text": "-- This code is closely based on code due to Andy Morris.\n\ndata _≡⁰_ {A : Set} (@0 x : A) : @0 A → Set where refl : x ≡⁰ x\ndata _≡ʷ_ {A : Set} (@ω x : A) : @ω A → Set where refl : x ≡ʷ x\n\nworks : ∀ {A} {@0 x y : A} → x ≡⁰ y → x ≡ʷ y\nworks refl = refl\n\nalso-works : ∀ {A} {@0 x y : A} → x ≡⁰ y → x ≡ʷ y\nalso-works {x = x} refl = refl {x = x}\n", "meta": {"hexsha": "31ed25b9fa8973cafc749e904058ca84c5cd6234", "size": 341, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue5191.agda", "max_stars_repo_name": "cagix/agda", "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue5191.agda", "max_issues_repo_name": "cagix/agda", "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue5191.agda", "max_forks_repo_name": "cagix/agda", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 31.0, "max_line_length": 63, "alphanum_fraction": 0.5131964809, "num_tokens": 160, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8354835371034369, "lm_q2_score": 0.7520125848754471, "lm_q1q2_score": 0.6282941343580372}} {"text": "module Numeral.Finite.LinearSearch where -- TODO: Maybe move to Numeral.CoordinateVector.LinearSearch\n\nopen import Data.Boolean\nopen import Data.Boolean.Stmt\nopen import Data.List\nimport Data.List.Functions as List\nopen import Data.Option\nimport Data.Option.Functions as Option\nopen import Functional\nopen import Logic\nopen import Numeral.Finite\nopen import Numeral.Finite.Bound\nopen import Numeral.Natural\nopen import Structure.Relator.Ordering\n\nprivate variable n : ℕ\nprivate variable i j min max : 𝕟(n)\nprivate variable f : 𝕟(n) → Bool\n\n-- Finds the maximal argument satisfying the given decidable predicate by searching linearly.\n-- Examples:\n-- findMax{5} (10 ∣?_) = None\n-- findMax{10} (10 ∣?_) = None\n-- findMax{20} (10 ∣?_) = Some 10\n-- findMax{21} (10 ∣?_) = Some 20\n-- findMax{22} (10 ∣?_) = Some 20\n-- findMax{100} (10 ∣?_) = Some 90\n-- findMax{102} (10 ∣?_) = Some 100\n-- Alternative implementation: findMax f = Option.map Wrapping.[−]_ (findMin(f ∘ Wrapping.[−]_))\nfindMax : (𝕟(n) → Bool) → Option(𝕟(n))\nfindMax {𝟎} f = None\nfindMax {𝐒(n)} f with f(maximum)\nfindMax {𝐒(n)} f | 𝑇 = Some maximum\nfindMax {𝐒(n)} f | 𝐹 = Option.map bound-𝐒 (findMax{n} (f ∘ bound-𝐒))\n\n-- Finds the minimal argument satisfying the given decidable predicate by searching linearly.\n-- Examples:\n-- findMin{5} (10 ∣?_) = None\n-- findMin{10} (10 ∣?_) = None\n-- findMin{20} (10 ∣?_) = Some 10\n-- findMin{21} (10 ∣?_) = Some 10\n-- findMin{22} (10 ∣?_) = Some 10\n-- findMin{100} (10 ∣?_) = Some 10\n-- findMax{102} (10 ∣?_) = Some 10\nfindMin : (𝕟(n) → Bool) → Option(𝕟(n))\nfindMin{𝟎} f = None\nfindMin{𝐒(n)} f with f(𝟎)\nfindMin{𝐒(n)} f | 𝑇 = Some 𝟎\nfindMin{𝐒(n)} f | 𝐹 = Option.map 𝐒 (findMin{n} (f ∘ 𝐒))\n\n-- Finds all arguments satisfying the given decidable predicate by searching linearly.\n-- Examples:\n-- findAll{10} (2 ∣?_) = [0,2,4,6,8]\nfindAll : (𝕟(n) → Bool) → List(𝕟(n))\nfindAll{𝟎} f = ∅\nfindAll{𝐒(n)} f = (if f(𝟎) then (𝟎 ⊰_) else id) (List.map 𝐒 (findAll{n} (f ∘ 𝐒)))\n\nopen import Data\nopen import Data.Boolean.Stmt.Proofs\nopen import Data.List.Relation.Membership using (_∈_)\nopen import Data.List.Relation.Membership.Proofs\nopen import Data.List.Relation.Pairwise\nopen import Data.List.Relation.Pairwise.Proofs\nopen import Data.List.Relation.Quantification\nopen import Data.List.Relation.Quantification.Proofs\nopen import Data.List.Sorting\nopen import Data.Option.Equiv.Id\nopen import Lang.Inspect\nopen import Logic.Propositional\nopen import Logic.Propositional.Theorems\nopen import Numeral.Finite.Oper.Comparisons\nopen import Numeral.Finite.Oper.Comparisons.Proofs\nopen import Numeral.Finite.Proofs\nopen import Numeral.Finite.Relation.Order as 𝕟 using (_≤_ ; _>_ ; _<_ ; [≤]-minimum ; [≤]-maximum)\nimport Numeral.Natural.Relation.Order as ℕ\nopen import Numeral.Natural.Relation.Order.Proofs as ℕ\nopen import Relator.Equals\nopen import Relator.Equals.Proofs.Equiv\nopen import Structure.Function\nopen import Structure.Function.Domain\nopen import Structure.Relator.Properties\nopen import Structure.Relator\nopen import Type.Properties.Decidable\nopen import Type.Properties.Decidable.Proofs\n\n{-\nopen import Syntax.Number\ntest : 𝕟(5) → Bool\ntest 𝟎 = 𝐹\ntest (𝐒 𝟎) = 𝐹\ntest (𝐒 (𝐒 𝟎)) = 𝑇\ntest (𝐒 (𝐒 (𝐒 𝟎))) = 𝐹\ntest (𝐒 (𝐒 (𝐒 (𝐒 𝟎)))) = 𝐹\ntest2 : 𝕟(1) → Bool\ntest2 𝟎 = 𝑇\ntest3 : findMax test2 ≡ Some 0\ntest3 = [≡]-intro\ntst4 = {!Option.map bound-𝐒 (findMax (test ∘ bound-𝐒))!}\n-}\n\nfindMax-None-correctness : (findMax f ≡ None) ↔ (∀{i} → IsFalse(f(i)))\nfindMax-None-correctness = [↔]-intro l r where\n l : (findMax f ≡ None) ← (∀{i} → IsFalse(f(i)))\n l {𝟎} {f} p = [≡]-intro\n l {𝐒 n} {f} p with f(maximum) | inspect f(maximum)\n ... | 𝑇 | intro fmax with () ← disjointness p ([↔]-to-[←] IsTrue.is-𝑇 fmax)\n ... | 𝐹 | intro fmax = congruence₁(Option.map bound-𝐒) (l p)\n\n r-result : IsFalse(f(maximum)) → (∀{i : 𝕟(n)} → IsFalse((f ∘ bound-𝐒) i)) → (∀{i : 𝕟(n)} → IsFalse(f(𝐒 i)))\n r-result {𝐒 n} {f} p q {𝐒 i} = r-result {n}{f ∘ 𝐒} p (\\{i} → q{𝐒 i}) {i}\n r-result {𝐒 𝟎} {f} p q {𝟎} = p\n r-result {𝐒 (𝐒 n)} {f} p q {𝟎} = q{𝐒 𝟎}\n\n r : (findMax f ≡ None) → (∀{i} → IsFalse(f(i)))\n r {𝐒 n} {f} p {i} with f(maximum) | inspect f(maximum)\n r {𝐒 n} {f} p {𝐒 i} | 𝐹 | intro fmax = r-result {f = f} ([↔]-to-[←] IsFalse.is-𝐹 fmax) (\\{i} → r {n}{f ∘ bound-𝐒} (map-None p) {i}) {i}\n r {𝐒 𝟎} {f} p {𝟎} | 𝐹 | intro fmax = [↔]-to-[←] IsFalse.is-𝐹 fmax\n r {𝐒 (𝐒 n)} {f} p {𝟎} | 𝐹 | intro fmax = r {𝐒 n} {f ∘ bound-𝐒} (map-None p) {𝟎}\n\nfindMax-Some-correctness : (findMax f ≡ Some(i)) → IsTrue(f(i))\nfindMax-Some-correctness {𝐒 n} {f} {i} eq with f(maximum) | inspect f(maximum)\nfindMax-Some-correctness {𝐒 n} {f} {.maximum} [≡]-intro | 𝑇 | intro fmax = [↔]-to-[←] IsTrue.is-𝑇 fmax\nfindMax-Some-correctness {𝐒 n} {f} {i} eq | 𝐹 | intro fmax with findMax(f ∘ bound-𝐒) | inspect findMax(f ∘ bound-𝐒)\nfindMax-Some-correctness {𝐒 n} {f} {.(_)} [≡]-intro | 𝐹 | intro fmax | Some x | intro p = findMax-Some-correctness {f = f ∘ bound-𝐒} p\n\nfindMin-None-correctness : (findMin f ≡ None) ↔ (∀{i} → IsFalse(f(i)))\nfindMin-None-correctness = [↔]-intro l r where\n l : (findMin f ≡ None) ← (∀{i} → IsFalse(f(i)))\n l {𝟎} {f} p = [≡]-intro\n l {𝐒 n} {f} p with f(𝟎) | inspect f(𝟎)\n ... | 𝑇 | intro f0 with () ← disjointness p ([↔]-to-[←] IsTrue.is-𝑇 f0)\n ... | 𝐹 | intro f0 = congruence₁(Option.map 𝐒) (l p)\n\n r : (findMin f ≡ None) → (∀{i} → IsFalse(f(i)))\n r {𝐒 n} {f} p {i} with f(𝟎) | inspect f(𝟎)\n r {𝐒 n} {f} p {𝟎} | 𝐹 | intro f0 = [↔]-to-[←] IsFalse.is-𝐹 f0\n r {𝐒 n} {f} p {𝐒 i} | 𝐹 | intro f0 = r {f = f ∘ 𝐒} (injective(Option.map 𝐒) ⦃ map-injectivity ⦄ p)\n\nfindMin-Some-correctness : (findMin f ≡ Some(min)) → IsTrue(f(min))\nfindMin-Some-correctness {𝐒 n} {f} {min} eq with f(𝟎) | inspect f(𝟎)\nfindMin-Some-correctness {𝐒 n} {f} {𝟎} [≡]-intro | 𝑇 | intro f0 = [↔]-to-[←] IsTrue.is-𝑇 f0\nfindMin-Some-correctness {𝐒 n} {f} {𝟎} eq | 𝐹 | intro f0 with findMin{n} (f ∘ 𝐒)\nfindMin-Some-correctness {𝐒 n} {f} {𝟎} () | 𝐹 | intro f0 | None\nfindMin-Some-correctness {𝐒 n} {f} {𝟎} () | 𝐹 | intro f0 | Some _\nfindMin-Some-correctness {𝐒 n} {f} {𝐒 min} eq | 𝐹 | intro f0 = findMin-Some-correctness {n} {f ∘ 𝐒} {min} (injective(Option.map 𝐒) ⦃ map-injectivity ⦄ eq)\n\nfindMin-minimal-true : (findMin f ≡ Some(min)) → IsTrue(f(i)) → (min ≤ i)\nfindMin-minimal-true {𝐒 n} {f} {min} {i} eq p with f(𝟎) | inspect f(𝟎)\nfindMin-minimal-true {𝐒 n} {f} {.𝟎} {i} [≡]-intro p | 𝑇 | intro f0 = 𝕟.[≤]-minimum {a = i}\nfindMin-minimal-true {𝐒 n} {f} {𝟎} {i} eq p | 𝐹 | intro f0 with findMin{n} (f ∘ 𝐒)\nfindMin-minimal-true {𝐒 n} {f} {𝟎} {i} () p | 𝐹 | intro f0 | None\nfindMin-minimal-true {𝐒 n} {f} {𝟎} {i} () p | 𝐹 | intro f0 | Some _\nfindMin-minimal-true {𝐒 n} {f} {𝐒 min} {𝟎} eq p | 𝐹 | intro f0 = disjointness p ([↔]-to-[←] IsFalse.is-𝐹 f0)\nfindMin-minimal-true {𝐒 n} {f} {𝐒 min} {𝐒 i} eq p | 𝐹 | intro f0 = findMin-minimal-true {n} {f ∘ 𝐒} {min} {i} (injective(Option.map 𝐒) ⦃ map-injectivity ⦄ eq) p\n\nfindMin-minimal-false : (findMin f ≡ Some(min)) → (min > i) → IsFalse(f(i))\nfindMin-minimal-false {n}{f}{min}{i} eq =\n [↔]-to-[←] false-true-opposites\n ∘ contrapositiveᵣ(findMin-minimal-true{n}{f}{min}{i} eq)\n ∘ [↔]-to-[←] decider-true ∘ substitute₁ₗ(IsTrue) (⋚-elim₃-negation-distribution {x = min}{y = i})\n\n{-\ninstance\n [≤]-with-[𝐒]-injective : ∀{a b} → Injective(\\p → ℕ.[≤]-with-[𝐒] {a}{b} ⦃ p ⦄)\n Injective.proof [≤]-with-[𝐒]-injective [≡]-intro = [≡]-intro\n\nimport Structure.Function.Names as Names\nopen import Function.Equals\nbound-[≤]-injective : ∀{a b} → Injective ⦃ [≡]-equiv ⦄ ⦃ [⊜]-equiv ⦄ (bound-[≤] {a}{b})\nbound-[≤]-injective {a}{b} = intro proof where\n proof : Names.Injective ⦃ [≡]-equiv ⦄ ⦃ [⊜]-equiv ⦄ (bound-[≤] {a}{b})\n proof {ℕ.[≤]-minimum} {ℕ.[≤]-minimum} p = [≡]-intro\n proof {ℕ.[≤]-with-[𝐒] ⦃ x ⦄} {ℕ.[≤]-with-[𝐒] ⦃ y ⦄} (intro p) = {!(injective ⦃ ? ⦄ ⦃ ? ⦄ (𝕟.𝐒) ⦃ ? ⦄ {x = bound-[≤] x}{y = bound-[≤] y} p)!}\n--Injective.proof bound-[≤]-injective {ℕ.[≤]-minimum} {ℕ.[≤]-minimum} p = [≡]-intro\n--Injective.proof bound-[≤]-injective {ℕ.[≤]-with-[𝐒] {y = _} ⦃ x ⦄} {ℕ.[≤]-with-[𝐒] {y = _} ⦃ y ⦄} (intro p) = {!injective(𝐒) ⦃ ? ⦄ p!}\n-- injective(𝐒) ⦃ [≤]-with-[𝐒]-injective ⦄\n\nbound-𝐒-injective : Injective(bound-𝐒 {n})\nInjective.proof bound-𝐒-injective {𝟎} {𝟎} p = [≡]-intro\nInjective.proof bound-𝐒-injective {𝐒 x} {𝐒 y} p = congruence₁(𝐒) (Injective.proof bound-𝐒-injective {x} {y} (injective(𝐒) p))\n-}\n\n-- TODO\npostulate findMax-maximal-true : (findMax f ≡ Some(max)) → IsTrue(f(i)) → (i ≤ max)\n{-findMax-maximal {𝐒 n}{f} eq p with f(maximum) | inspect f(maximum)\nfindMax-maximal {𝐒 n} {f} {i = i} [≡]-intro p | 𝑇 | intro m = [≤]-maximum {𝐒 n}{i} (reflexivity(ℕ._≤_))\nfindMax-maximal {𝐒 n} {f} {i = i} eq p | 𝐹 | intro m with findMax{n} (f ∘ bound-𝐒) | inspect (findMax{n}) (f ∘ bound-𝐒)\nfindMax-maximal {𝐒 n} {f} {i = i} eq p | 𝐹 | intro m | Some x | intro findMax-x = {!findMax-maximal {n} {f ∘ bound-𝐒} {i = ?} !}\n-}\n\n{- TODO\ntest : ∀{i : 𝕟(𝐒(n))} → ¬(maximum{n} < i)\ntest {𝟎} {𝟎} p = p\ntest {𝐒 n} {𝟎} p = p\ntest {𝐒 n} {𝐒 i} p = test {n}{i} p\n\n{-\nfindMax-maximal2 : (findMax f ≡ Some(max)) → (i > max) → IsFalse(f(i))\nfindMax-maximal2 {𝐒 n} {f} {max} {i} eq p with f(maximum) | inspect f(maximum)\nfindMax-maximal2 {𝐒 n} {f} {𝟎} {𝐒 i} eq p | 𝑇 | intro fmax with maximum-0(injective(Some) eq)\nfindMax-maximal2 {𝐒 .0} {f} {𝟎} {𝐒 ()} eq p | 𝑇 | intro fmax | [≡]-intro\nfindMax-maximal2 {𝐒 (𝐒 n)} {f} {𝐒 max} {𝐒 i} eq p | 𝑇 | intro fmax with f(bound-𝐒 maximum) | inspect (f ∘ bound-𝐒)(maximum)\nfindMax-maximal2 {𝐒 (𝐒 n)} {f} {𝐒 .maximum} {𝐒 i} [≡]-intro p | 𝑇 | intro fmax | 𝑇 | intro x with () ← test{n} p\nfindMax-maximal2 {𝐒 (𝐒 n)} {f} {𝐒 {.(𝐒 n)} .(maximum {n})} {𝐒 {.(𝐒 n)} i} ([≡]-intro {x = .(Some (𝐒 {𝐒 n} (maximum {n})))}) p | 𝑇 | intro fmax | 𝐹 | intro x with () ← test{n} p\nfindMax-maximal2 {𝐒 n} {f} {𝟎} {𝐒 i} eq p | 𝐹 | intro fmax = {!!}\nfindMax-maximal2 {𝐒 n} {f} {𝐒 max} {𝐒 i} eq p | 𝐹 | intro fmax = {!!}\n-}\n\n\ntest2 : (bound-𝐒 i ≡ 𝟎) → (i ≡ 𝟎)\ntest2 {i = 𝟎} p = [≡]-intro\n\nfindMax-maximal : (findMax f ≡ Some(max)) → IsTrue(f(i)) → (i ≤ max)\nfindMax-maximal {𝐒 n}{f} eq p with f(maximum) | inspect f(maximum)\nfindMax-maximal {𝐒 n} {f} {_}{i} [≡]-intro p | 𝑇 | intro fmax = [≤]-maximum {𝐒 n}{i} (reflexivity(ℕ._≤_))\nfindMax-maximal {𝐒 n} {f} {max} {𝟎} eq p | 𝐹 | intro fmax = [≤]-minimum {a = max}\nfindMax-maximal {𝐒 (𝐒 n)} {f} {max} {𝐒 i} eq p | 𝐹 | intro fmax with f(bound-𝐒 maximum) | inspect (f ∘ bound-𝐒)(maximum)\nfindMax-maximal {𝐒 (𝐒 n)} {f} {𝟎} {𝐒 i} eq p | 𝐹 | intro fmax | 𝑇 | intro x = {!maximum-0(test2(injective(Some) eq))!}\nfindMax-maximal {𝐒 (𝐒 n)} {f} {𝐒 max} {𝐒 i} eq p | 𝐹 | intro fmax | 𝑇 | intro x = {!!}\n... | 𝐹 | intro x = {!!}\n-- findMax-maximal {f = f ∘ bound-𝐒} {i = i} (injective(Option.map bound-𝐒) ⦃ map-injectivity ⦃ ? ⦄ ⦄ {findMax(f ∘ bound-𝐒)} {Some 𝟎} eq)\n{-findMax-maximal {𝐒 n} {f} {max} {i} eq p with f(maximum) | inspect f(maximum)\nfindMax-maximal {𝐒 n} {f} {.maximum} {i} [≡]-intro p | 𝑇 | intro fmax = [≤]-maximum {𝐒 n}{i}{n = n} (reflexivity(ℕ._≤_))\nfindMax-maximal {𝐒 n} {f} {max} {i} eq p | 𝐹 | intro fmax with findMax{n} (f ∘ bound-𝐒)\nfindMax-maximal {𝐒 n} {f} {max} {i} () p | 𝐹 | intro fmax | None\n-}\n{-findMax-maximal {𝐒 n} {f} {𝟎} {𝟎} eq p | 𝐹 | intro fmax | Some x = <>\nfindMax-maximal {𝐒 n} {f} {𝐒 max} {𝟎} eq p | 𝐹 | intro fmax | Some x = <>\nfindMax-maximal {𝐒(𝐒 n)} {f} {𝟎} {𝐒 i} eq p | 𝐹 | intro fmax | Some 𝟎 = {!findMax-maximal!}\nfindMax-maximal {𝐒 n} {f} {𝐒 max} {𝐒 i} eq p | 𝐹 | intro fmax | Some x = {!!}\n-}\n{-findMax-maximal {𝐒 n} {f} {.(bound-[≤] ([≤]-successor ([≡]-to-[≤] [≡]-intro)) x)} {𝟎} [≡]-intro p | 𝐹 | intro fmax | Some x = [≤]-minimum {a = bound-𝐒(x)}\nfindMax-maximal {𝐒 .(𝐒 _)} {f} {.(bound-[≤] ([≤]-successor ([≡]-to-[≤] [≡]-intro)) 𝟎)} {𝐒 i} [≡]-intro p | 𝐹 | intro fmax | Some 𝟎 = {!!}\nfindMax-maximal {𝐒 .(𝐒 _)} {f} {.(bound-[≤] ([≤]-successor ([≡]-to-[≤] [≡]-intro)) (𝐒 x))} {𝐒 i} [≡]-intro p | 𝐹 | intro fmax | Some (𝐒 x) = {!!}-}\n-}\n\n{-\nopen import Numeral.Finite.Oper\nfindMax-findMin : findMax f ≡ Option.map Wrapping.[−]_ (findMin(f ∘ Wrapping.[−]_))\nfindMax-findMin {𝟎} {f} = [≡]-intro\nfindMax-findMin {𝐒 n} {f} with f(maximum) | inspect f(maximum)\n... | 𝑇 | intro fmax = [≡]-intro\n... | 𝐹 | intro fmax = {!!}\n-}\n\nfindAll-correctness : AllElements(IsTrue ∘ f)(findAll f)\nfindAll-correctness {𝟎} {f} = ∅\nfindAll-correctness {𝐒 n} {f} with f(𝟎) | inspect f(𝟎)\n... | 𝑇 | intro f0 = ([↔]-to-[←] IsTrue.is-𝑇 f0) ⊰ (AllElements-mapᵣ 𝐒 id (findAll-correctness {n}{f ∘ 𝐒}))\n... | 𝐹 | intro _ = AllElements-mapᵣ 𝐒 id (findAll-correctness {n}{f ∘ 𝐒})\n\nfindAll-completeness : IsTrue(f(i)) → (i ∈ findAll f)\nfindAll-completeness {𝐒 n} {f} {i} p with f(𝟎) | inspect f(𝟎)\nfindAll-completeness {𝐒 n} {f} {𝟎} p | 𝑇 | intro _ = • [≡]-intro\nfindAll-completeness {𝐒 n} {f} {𝐒 i} p | 𝑇 | intro _ = ⊰ [∈]-map (findAll-completeness{n}{f ∘ 𝐒}{i} p)\nfindAll-completeness {𝐒 n} {f} {𝟎} p | 𝐹 | intro f0 with () ← disjointness p ([↔]-to-[←] IsFalse.is-𝐹 f0)\nfindAll-completeness {𝐒 n} {f} {𝐒 i} p | 𝐹 | intro _ = [∈]-map (findAll-completeness {n} {f ∘ 𝐒} {i} p)\n\nfindAll-sorted : Sorted(_≤?_)(findAll f)\nfindAll-sorted {𝟎} {f} = AdjacentlyPairwise.empty\nfindAll-sorted {𝐒 𝟎} {f} with f(𝟎) | inspect f(𝟎)\nfindAll-sorted {𝐒 𝟎} {f} | 𝑇 | intro f0 = AdjacentlyPairwise.single\nfindAll-sorted {𝐒 𝟎} {f} | 𝐹 | intro f0 = AdjacentlyPairwise.empty\nfindAll-sorted {𝐒(𝐒 n)} {f} with f(𝟎) | f(𝐒 𝟎) | AdjacentlyPairwise-map {_▫₁_ = IsTrue ∘₂ _≤?_}{f = 𝐒}{_▫₂_ = IsTrue ∘₂ _≤?_} id (findAll-sorted {𝐒 n}{f ∘ 𝐒})\n... | 𝑇 | 𝑇 | prev = AdjacentlyPairwise.step ⦃ <> ⦄ ⦃ prev ⦄\n... | 𝑇 | 𝐹 | prev = AdjacentlyPairwise-prepend (\\{ {𝟎} → <> ; {𝐒 _} → <>}) prev\n... | 𝐹 | 𝑇 | prev = prev\n... | 𝐹 | 𝐹 | prev = prev\n", "meta": {"hexsha": "5f86f6deab3239a8e9108373177831f903dbbc7b", "size": 13820, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Finite/LinearSearch.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Finite/LinearSearch.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Finite/LinearSearch.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.375464684, "max_line_length": 176, "alphanum_fraction": 0.5895803184, "num_tokens": 6453, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8354835248143776, "lm_q2_score": 0.7520125848754472, "lm_q1q2_score": 0.62829412511651}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import lib.Basics\nopen import lib.types.Paths\nopen import lib.types.Pointed\nopen import lib.types.Pushout\nopen import lib.types.PushoutFmap\nopen import lib.types.Sigma\nopen import lib.types.Span\n\nmodule lib.types.Join where\n\nmodule _ {i j} (A : Type i) (B : Type j) where\n\n *-span : Span\n *-span = span A B (A × B) fst snd\n\n infix 80 _*_\n\n _*_ : Type _\n _*_ = Pushout *-span\n\nmodule JoinElim {i j} {A : Type i} {B : Type j} {k} {P : A * B → Type k}\n (left* : (a : A) → P (left a)) (right* : (b : B) → P (right b))\n (glue* : (ab : A × B) → left* (fst ab) == right* (snd ab) [ P ↓ glue ab ])\n = PushoutElim left* right* glue*\nopen JoinElim public using () renaming (f to Join-elim)\n\nmodule JoinRec {i j} {A : Type i} {B : Type j} {k} {D : Type k}\n (left* : (a : A) → D) (right* : (b : B) → D)\n (glue* : (ab : A × B) → left* (fst ab) == right* (snd ab))\n = PushoutRec left* right* glue*\nopen JoinRec public using () renaming (f to Join-rec)\n\nmodule _ {i j} (X : Ptd i) (Y : Ptd j) where\n\n ⊙*-span : ⊙Span\n ⊙*-span = ⊙span X Y (X ⊙× Y) ⊙fst ⊙snd\n\n infix 80 _⊙*_\n\n _⊙*_ : Ptd _\n _⊙*_ = ⊙Pushout ⊙*-span\n\nmodule _ {i i' j j'} {A : Type i} {A' : Type i'} {B : Type j} {B' : Type j'}\n (eqA : A ≃ A') (eqB : B ≃ B') where\n\n *-span-emap : SpanEquiv (*-span A B) (*-span A' B')\n *-span-emap = ( span-map (fst eqA) (fst eqB) (×-fmap (fst eqA) (fst eqB)) (comm-sqr λ _ → idp) (comm-sqr λ _ → idp)\n , snd eqA , snd eqB , ×-isemap (snd eqA) (snd eqB))\n\n *-emap : A * B ≃ A' * B'\n *-emap = Pushout-emap *-span-emap\n\nmodule _ {i i' j j'} {X : Ptd i} {X' : Ptd i'} {Y : Ptd j} {Y' : Ptd j'} where\n\n ⊙*-emap : X ⊙≃ X' → Y ⊙≃ Y' → X ⊙* Y ⊙≃ X' ⊙* Y'\n ⊙*-emap ⊙eqX ⊙eqY = ≃-to-⊙≃ (*-emap (⊙≃-to-≃ ⊙eqX) (⊙≃-to-≃ ⊙eqY)) (ap left (snd (⊙–> ⊙eqX)))\n", "meta": {"hexsha": "29a472d7239454c61c85fb2410c62319807ba89e", "size": 1810, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/types/Join.agda", "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "core/lib/types/Join.agda", "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "core/lib/types/Join.agda", "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "avg_line_length": 30.6779661017, "max_line_length": 117, "alphanum_fraction": 0.5342541436, "num_tokens": 790, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933359135361, "lm_q2_score": 0.7662936430859597, "lm_q1q2_score": 0.6282790513190841}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Equality over lists parameterised by some setoid\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary using (Setoid)\n\nmodule Data.List.Relation.Binary.Equality.Setoid {a ℓ} (S : Setoid a ℓ) where\n\nopen import Data.List.Base using (List)\nopen import Level\nopen import Relation.Binary renaming (Rel to Rel₂)\nopen import Relation.Binary.PropositionalEquality as P using (_≡_)\nopen import Data.List.Relation.Binary.Pointwise as PW using (Pointwise)\n\nopen Setoid S renaming (Carrier to A)\n\n------------------------------------------------------------------------\n-- Definition of equality\n\ninfix 4 _≋_\n\n_≋_ : Rel₂ (List A) (a ⊔ ℓ)\n_≋_ = Pointwise _≈_\n\nopen Pointwise public using ([]; _∷_)\n\n------------------------------------------------------------------------\n-- Relational properties\n\n≋-refl : Reflexive _≋_\n≋-refl = PW.refl refl\n\n≋-reflexive : _≡_ ⇒ _≋_\n≋-reflexive P.refl = ≋-refl\n\n≋-sym : Symmetric _≋_\n≋-sym = PW.symmetric sym\n\n≋-trans : Transitive _≋_\n≋-trans = PW.transitive trans\n\n≋-isEquivalence : IsEquivalence _≋_\n≋-isEquivalence = PW.isEquivalence isEquivalence\n\n≋-setoid : Setoid _ _\n≋-setoid = PW.setoid S\n\n------------------------------------------------------------------------\n-- Operations\n\nopen PW public using\n ( tabulate⁺\n ; tabulate⁻\n ; ++⁺\n ; concat⁺\n )\n", "meta": {"hexsha": "3893da3f99ab7696d4d8eb1ee61e2a6adf596f8e", "size": 1474, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Equality/Setoid.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Equality/Setoid.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Equality/Setoid.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.1639344262, "max_line_length": 77, "alphanum_fraction": 0.5312075984, "num_tokens": 378, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256472515683, "lm_q2_score": 0.7461389930307512, "lm_q1q2_score": 0.6281189407477454}} {"text": "------------------------------------------------------------------------\n-- Yet another implementation of the Fibonacci sequence using tail\n------------------------------------------------------------------------\n\nmodule LargeCombinators where\n\nopen import Codata.Musical.Notation\nopen import Codata.Musical.Stream as S using (Stream; _∷_; _≈_)\nopen import Data.Nat\nimport Relation.Binary.PropositionalEquality as P\n\n-- Stream programs. Note that the destructor tail is encapsulated in a\n-- larger combinator, which also incorporates a constructor. This\n-- ensures that the combinator can be used freely, with no risk of\n-- destroying productivity.\n--\n-- Note that, in the general case, the implementation of whnf for the\n-- \"large combinator\" may be quite tricky. In this case the\n-- implementation turns out to be very simple, though.\n--\n-- The idea to use a \"large combinator\" is due to Thorsten Altenkirch.\n\ninfixr 5 _∷_\n\ndata StreamP (A : Set) : Set where\n _∷_ : (x : A) (xs : ∞ (StreamP A)) → StreamP A\n zipWith : (f : A → A → A) (xs ys : StreamP A) → StreamP A\n\n -- The intention is that ⟦ x ∷zipWith f · xs [tail ys ] ⟧P should be\n -- equal to x ∷ ♯ S.zipWith f ⟦ xs ⟧P (S.tail ⟦ ys ⟧P).\n\n _∷zipWith_·_[tail_] :\n (x : A) (f : A → A → A) (xs ys : StreamP A) → StreamP A\n\n-- WHNFs.\n\ndata StreamW (A : Set) : Set where\n _∷_ : (x : A) (xs : StreamP A) → StreamW A\n\n-- Stream programs can be turned into streams.\n\nwhnf : ∀ {A} → StreamP A → StreamW A\nwhnf (x ∷ xs) = x ∷ ♭ xs\nwhnf (x ∷zipWith f · xs′ [tail ys ]) with whnf ys\n... | _ ∷ ys′ = x ∷ zipWith f xs′ ys′\nwhnf (zipWith f xs ys) with whnf xs | whnf ys\n... | x ∷ xs′ | y ∷ ys′ = f x y ∷ zipWith f xs′ ys′\n\nmutual\n\n ⟦_⟧W : ∀ {A} → StreamW A → Stream A\n ⟦ x ∷ xs ⟧W = x ∷ ♯ ⟦ xs ⟧P\n\n ⟦_⟧P : ∀ {A} → StreamP A → Stream A\n ⟦ xs ⟧P = ⟦ whnf xs ⟧W\n\n-- The Fibonacci sequence.\n\nfib : StreamP ℕ\nfib = 0 ∷ ♯ (1 ∷zipWith _+_ · fib [tail fib ])\n\n-- ⟦_⟧P is homomorphic with respect to zipWith/S.zipWith.\n\nzipWith-hom :\n ∀ {A} (f : A → A → A) (xs ys : StreamP A) →\n ⟦ zipWith f xs ys ⟧P ≈ S.zipWith f ⟦ xs ⟧P ⟦ ys ⟧P\nzipWith-hom f xs ys with whnf xs | whnf ys\n... | x ∷ xs′ | y ∷ ys′ = P.refl ∷ ♯ zipWith-hom f xs′ ys′\n\n-- The stream ⟦ fib ⟧P satisfies its intended defining equation.\n\nfib-correct :\n ⟦ fib ⟧P ≈ 0 ∷ ♯ (1 ∷ ♯ (S.zipWith _+_ ⟦ fib ⟧P (S.tail ⟦ fib ⟧P)))\nfib-correct =\n P.refl ∷ ♯ (P.refl ∷ ♯\n zipWith-hom _+_ fib (1 ∷zipWith _+_ · fib [tail fib ]))\n\n-- For completeness, let us show that _∷zipWith_·_[tail_] is correctly\n-- implemented.\n\nopen import Relation.Binary.PropositionalEquality as P using (_≡_; [_])\n\n_∷zipWith_·_[tail_]-hom :\n ∀ {A} (x : A) (f : A → A → A) (xs ys : StreamP A) →\n ⟦ x ∷zipWith f · xs [tail ys ] ⟧P ≈\n x ∷ ♯ S.zipWith f ⟦ xs ⟧P (S.tail ⟦ ys ⟧P)\nx ∷zipWith f · xs [tail ys ]-hom with whnf ys | P.inspect whnf ys\n... | y ∷ ys′ | [ eq ] = P.refl ∷ ♯ helper eq\n where\n helper : whnf ys ≡ y ∷ ys′ →\n ⟦ zipWith f xs ys′ ⟧P ≈\n S.zipWith f ⟦ xs ⟧P (S.tail ⟦ ys ⟧P)\n helper eq rewrite eq = zipWith-hom f xs ys′\n", "meta": {"hexsha": "58cb4a2b1ba8c42a7d15c67bac8a4aa738b63cb6", "size": 3041, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "LargeCombinators.agda", "max_stars_repo_name": "nad/codata", "max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z", "max_issues_repo_path": "LargeCombinators.agda", "max_issues_repo_name": "nad/codata", "max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LargeCombinators.agda", "max_forks_repo_name": "nad/codata", "max_forks_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.3510638298, "max_line_length": 72, "alphanum_fraction": 0.5810588622, "num_tokens": 1134, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256393148981, "lm_q2_score": 0.7461389986757757, "lm_q1q2_score": 0.6281189395780128}} {"text": "module WellTypedTerms where\n\nopen import Library\nopen import Categories\nopen import Functors\nopen import RMonads\nopen import FunctorCat\nopen import Categories.Sets\nopen import Categories.Families\n\ndata Ty : Set where\n ι : Ty\n _⇒_ : Ty → Ty → Ty\n\ndata Con : Set where\n ε : Con\n _<_ : Con → Ty → Con\n\ndata Var : Con → Ty → Set where\n vz : ∀{Γ σ} → Var (Γ < σ) σ\n vs : ∀{Γ σ τ} → Var Γ σ → Var (Γ < τ) σ\n\ndata Tm : Con → Ty → Set where\n var : ∀{Γ σ} → Var Γ σ → Tm Γ σ\n app : ∀{Γ σ τ} → Tm Γ (σ ⇒ τ) → Tm Γ σ → Tm Γ τ\n lam : ∀{Γ σ τ} → Tm (Γ < σ) τ → Tm Γ (σ ⇒ τ)\n\nRen : Con → Con → Set\nRen Γ Δ = ∀ {σ} → Var Γ σ → Var Δ σ \n\nrenId : ∀{Γ} → Ren Γ Γ\nrenId = id\n\nrenComp : ∀{B Γ Δ} → Ren Γ Δ → Ren B Γ → Ren B Δ\nrenComp f g = f ∘ g\n\nConCat : Cat \nConCat = record{\n Obj = Con; \n Hom = Ren;\n iden = renId;\n comp = renComp;\n idl = iext λ _ → refl;\n idr = iext λ _ → refl;\n ass = iext λ _ → refl}\n\nwk : ∀{Γ Δ σ} → Ren Γ Δ → Ren (Γ < σ) (Δ < σ)\nwk f vz = vz\nwk f (vs i) = vs (f i)\n\nren : ∀{Γ Δ} → Ren Γ Δ → ∀ {σ} → Tm Γ σ → Tm Δ σ\nren f (var x) = var (f x)\nren f (app t u) = app (ren f t) (ren f u)\nren f (lam t) = lam (ren (wk f) t)\n\nwkid : ∀{Γ σ τ}(x : Var (Γ < τ) σ) → wk renId x ≅ renId x\nwkid vz = refl\nwkid (vs x) = refl\n\nrenid : ∀{Γ σ}(t : Tm Γ σ) → ren renId t ≅ id t\nrenid (var x) = refl\nrenid (app t u) = \n proof \n app (ren renId t) (ren renId u) \n ≅⟨ cong₂ app (renid t) (renid u) ⟩ \n app t u \n ∎\nrenid (lam t) = \n proof lam (ren (wk renId) t) \n ≅⟨ cong (λ (f : Ren _ _) → lam (ren f t)) (iext λ _ → ext wkid) ⟩ \n lam (ren renId t) \n ≅⟨ cong lam (renid t) ⟩ \n lam t \n ∎ \n\nwkcomp : ∀ {B Γ Δ}(f : Ren Γ Δ)(g : Ren B Γ){σ τ}(x : Var (B < σ) τ) → \n wk (renComp f g) x ≅ renComp (wk f) (wk g) x \nwkcomp f g vz = refl\nwkcomp f g (vs i) = refl\n\nrencomp : ∀ {B Γ Δ}(f : Ren Γ Δ)(g : Ren B Γ){σ}(t : Tm B σ) → \n ren (renComp f g) t ≅ (ren f ∘ ren g) t\nrencomp f g (var x) = refl\nrencomp f g (app t u) = \n proof\n app (ren (renComp f g) t) (ren (renComp f g) u)\n ≅⟨ cong₂ app (rencomp f g t) (rencomp f g u) ⟩\n app (ren f (ren g t)) (ren f (ren g u)) \n ∎\nrencomp f g (lam t) = \n proof\n lam (ren (wk (renComp f g)) t) \n ≅⟨ cong (λ (f : Ren _ _) → lam (ren f t)) (iext λ _ → ext (wkcomp f g)) ⟩\n lam (ren (renComp (wk f) (wk g)) t)\n ≅⟨ cong lam (rencomp (wk f) (wk g) t) ⟩\n lam (ren (wk f) (ren (wk g) t)) \n ∎\n\nSub : Con → Con → Set\nSub Γ Δ = ∀{σ} → Var Γ σ → Tm Δ σ\n\nlift : ∀{Γ Δ σ} → Sub Γ Δ → Sub (Γ < σ) (Δ < σ)\nlift f vz = var vz\nlift f (vs x) = ren vs (f x)\n\nsub : ∀{Γ Δ} → Sub Γ Δ → ∀{σ} → Tm Γ σ → Tm Δ σ\nsub f (var x) = f x\nsub f (app t u) = app (sub f t) (sub f u)\nsub f (lam t) = lam (sub (lift f) t)\n\nsubId : ∀{Γ} → Sub Γ Γ\nsubId = var\n\nsubComp : ∀{B Γ Δ} → Sub Γ Δ → Sub B Γ → Sub B Δ\nsubComp f g = sub f ∘ g\n\nliftid : ∀{Γ σ τ}(x : Var (Γ < σ) τ) → lift subId x ≅ subId x\nliftid vz = refl\nliftid (vs x) = refl\n\nsubid : ∀{Γ σ}(t : Tm Γ σ) → sub subId t ≅ id t\nsubid (var x) = refl\nsubid (app t u) = \n proof \n app (sub subId t) (sub subId u) \n ≅⟨ cong₂ app (subid t) (subid u) ⟩ \n app t u \n ∎\nsubid (lam t) = \n proof \n lam (sub (lift subId) t)\n ≅⟨ cong (λ (f : Sub _ _) → lam (sub f t)) (iext λ _ → ext liftid) ⟩ \n lam (sub subId t) \n ≅⟨ cong lam (subid t) ⟩ \n lam t \n ∎\n\n-- time for the mysterious four lemmas:\nliftwk : ∀{B Γ Δ}(f : Sub Γ Δ)(g : Ren B Γ){σ τ}(x : Var (B < σ) τ) →\n (lift f ∘ wk g) x ≅ lift (f ∘ g) x\nliftwk f g vz = refl\nliftwk f g (vs x) = refl\n\nsubren : ∀{B Γ Δ}(f : Sub Γ Δ)(g : Ren B Γ){σ}(t : Tm B σ) → \n (sub f ∘ ren g) t ≅ sub (f ∘ g) t\nsubren f g (var x) = refl\nsubren f g (app t u) = \n proof\n app (sub f (ren g t)) (sub f (ren g u))\n ≅⟨ cong₂ app (subren f g t) (subren f g u) ⟩\n app (sub (f ∘ g) t) (sub (f ∘ g) u) \n ∎ \nsubren f g (lam t) = \n proof\n lam (sub (lift f) (ren (wk g) t))\n ≅⟨ cong lam (subren (lift f) (wk g) t) ⟩\n lam (sub (lift f ∘ wk g) t)\n ≅⟨ cong (λ (f : Sub _ _) → lam (sub f t)) (iext (λ _ → ext (liftwk f g))) ⟩\n lam (sub (lift (f ∘ g)) t) ∎ \n\nrenwklift : ∀{B Γ Δ}(f : Ren Γ Δ)(g : Sub B Γ){σ τ}(x : Var (B < σ) τ) →\n (ren (wk f) ∘ lift g) x ≅ lift (ren f ∘ g) x\nrenwklift f g vz = refl\nrenwklift f g (vs x) = \n proof \n ren (wk f) (ren vs (g x)) \n ≅⟨ sym (rencomp (wk f) vs (g x)) ⟩ \n ren (wk f ∘ vs) (g x)\n ≅⟨ rencomp vs f (g x) ⟩ \n ren vs (ren f (g x)) \n ∎\n\nrensub : ∀{B Γ Δ}(f : Ren Γ Δ)(g : Sub B Γ){σ}(t : Tm B σ) →\n (ren f ∘ sub g) t ≅ sub (ren f ∘ g) t\nrensub f g (var x) = refl\nrensub f g (app t u) = \n proof \n app (ren f (sub g t)) (ren f (sub g u)) \n ≅⟨ cong₂ app (rensub f g t) (rensub f g u) ⟩ \n app (sub (ren f ∘ g) t) (sub (ren f ∘ g) u) \n ∎\nrensub f g (lam t) = \n proof\n lam (ren (wk f) (sub (lift g) t))\n ≅⟨ cong lam (rensub (wk f) (lift g) t) ⟩\n lam (sub (ren (wk f) ∘ lift g) t)\n ≅⟨ cong (λ (f₁ : Sub _ _) → lam (sub f₁ t)) \n (iext (λ _ → ext (renwklift f g))) ⟩\n lam (sub (lift (ren f ∘ g)) t) \n ∎\n\nliftcomp : ∀{B Γ Δ}(f : Sub Γ Δ)(g : Sub B Γ){σ τ}(x : Var (B < σ) τ) →\n lift (subComp f g) x ≅ subComp (lift f) (lift g) x\nliftcomp f g vz = refl\nliftcomp f g (vs x) = \n proof \n ren vs (sub f (g x)) \n ≅⟨ rensub vs f (g x) ⟩ \n sub (ren vs ∘ f) (g x)\n ≅⟨ sym (subren (lift f) vs (g x)) ⟩ \n sub (lift f) (ren vs (g x)) \n ∎ \n\nsubcomp : ∀{B Γ Δ}(f : Sub Γ Δ)(g : Sub B Γ){σ}(t : Tm B σ) → \n sub (subComp f g) t ≅ (sub f ∘ sub g) t\nsubcomp f g (var x) = refl\nsubcomp f g (app t u) = \n proof \n app (sub (subComp f g) t) (sub (subComp f g) u)\n ≅⟨ cong₂ app (subcomp f g t) (subcomp f g u) ⟩\n app (sub f (sub g t)) (sub f (sub g u))\n ∎\nsubcomp f g (lam t) = \n proof\n lam (sub (lift (subComp f g)) t) \n ≅⟨ cong (λ (f : Sub _ _) → lam (sub f t))\n (iext λ _ → ext (liftcomp f g)) ⟩\n lam (sub (subComp (lift f) (lift g)) t)\n ≅⟨ cong lam (subcomp (lift f) (lift g) t) ⟩\n lam (sub (lift f) (sub (lift g) t)) ∎ \n\nVarF : Fun ConCat (Fam Ty)\nVarF = record { \n OMap = Var; \n HMap = id; \n fid = refl;\n fcomp = refl }\n\nTmRMonad : RMonad VarF\nTmRMonad = record { \n T = Tm; \n η = var; \n bind = sub; \n law1 = iext λ _ → ext subid ;\n law2 = refl; \n law3 = λ{_ _ _ f g} → iext λ σ → ext (subcomp g f)}\n\n-- not needed here\nsub<< : ∀{Γ Δ σ}(f : Sub Γ Δ)(t : Tm Δ σ) → Sub (Γ < σ) Δ\nsub<< f t vz = t\nsub<< f t (vs x) = f x \n\nlem1 : ∀{B Γ Δ σ}{f : Sub Γ Δ}{g : Ren B Γ}{t : Tm Δ σ}{τ}(x : Var (B < σ) τ) → \n (sub<< f t ∘ wk g) x ≅ (sub<< (f ∘ g) t) x\nlem1 vz = refl\nlem1 (vs x) = refl\n\nlem2 : ∀{B Γ Δ σ}{f : Sub Γ Δ}{g : Sub B Γ}{t : Tm Δ σ}{τ}(x : Var (B < σ) τ) → \n (subComp (sub<< f t) (lift g)) x ≅ (sub<< (subComp f g) t) x\nlem2 vz = refl\nlem2 {f = f}{g = g}{t = t} (vs x) = subren (sub<< f t) vs (g x) \n", "meta": {"hexsha": "a98c591d74763c3fa6320f1d975b8846419e15d5", "size": 6762, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "WellTypedTerms.agda", "max_stars_repo_name": "jmchapman/Relative-Monads", "max_stars_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 21, "max_stars_repo_stars_event_min_datetime": "2015-07-30T01:25:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-13T18:02:18.000Z", "max_issues_repo_path": "WellTypedTerms.agda", "max_issues_repo_name": "jmchapman/Relative-Monads", "max_issues_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:12:33.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-29T09:50:26.000Z", "max_forks_repo_path": "WellTypedTerms.agda", "max_forks_repo_name": "jmchapman/Relative-Monads", "max_forks_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-04T21:33:13.000Z", "avg_line_length": 26.8333333333, "max_line_length": 80, "alphanum_fraction": 0.4931972789, "num_tokens": 3149, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256313782276, "lm_q2_score": 0.7461389930307512, "lm_q1q2_score": 0.6281189289040271}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule sets.int.properties where\n\nopen import equality\nopen import function.core\nimport sets.nat as N\nopen N using (ℕ; suc)\nopen import sets.int.definition\nopen import sets.int.utils\nimport sets.int.core as Z\n\nprivate\n module _ where\n open N\n\n add-right-unit : ∀ n n' → (n + 0) [-] (n' + 0) ≡ n [-] n'\n add-right-unit n n' = ap₂ _[-]_ (+-right-unit n) (+-right-unit n')\n\n add-left-inverse : ∀ n n' → (n' + n) [-] (n + n') ≡ 0 [-] 0\n add-left-inverse n n' = sym\n $ eq-ℤ 0 0 (n' + n)\n · ap₂ _[-]_ (+-right-unit (n' + n))\n (+-right-unit (n' + n) · +-commutativity n' n)\n\nmodule _ where\n open Z\n\n +-left-unit : ∀ n → zero + n ≡ n\n +-left-unit = elim-prop-ℤ (λ n → hℤ (zero + n) n)\n (λ n n' → refl)\n\n +-right-unit : ∀ n → n + zero ≡ n\n +-right-unit = elim-prop-ℤ (λ n → hℤ (n + zero) n)\n add-right-unit\n\n +-left-inverse : ∀ n → negate n + n ≡ zero\n +-left-inverse = elim-prop-ℤ (λ n → hℤ (negate n + n) zero)\n add-left-inverse\n\n +-right-inverse : ∀ n → n + negate n ≡ zero\n +-right-inverse = elim-prop-ℤ (λ n → hℤ (n + negate n) zero)\n (λ n n' → add-left-inverse n' n)\n\n inc-dec : ∀ n → inc (dec n) ≡ n\n inc-dec = elim-prop-ℤ (λ n → hℤ (inc (dec n)) n)\n (λ n n' → sym (eq-ℤ n n' 1))\n\n dec-inc : ∀ n → dec (inc n) ≡ n\n dec-inc = elim-prop-ℤ (λ n → hℤ (dec (inc n)) n)\n (λ n n' → sym (eq-ℤ n n' 1))\n\n +-associativity : ∀ n m p → n + m + p ≡ n + (m + p)\n +-associativity = elim₃-prop-ℤ\n (λ n m p → hℤ (n + m + p) (n + (m + p)))\n (λ n n' m m' p p' → ap₂ _[-]_ (N.+-associativity n m p)\n (N.+-associativity n' m' p'))\n", "meta": {"hexsha": "8ab09c6e70ae74fdb8e5c8c7a6faee64303ccc1f", "size": 1796, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/sets/int/properties.agda", "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 20, "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_issues_repo_path": "src/sets/int/properties.agda", "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_forks_repo_path": "src/sets/int/properties.agda", "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "avg_line_length": 30.9655172414, "max_line_length": 70, "alphanum_fraction": 0.469376392, "num_tokens": 647, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772417253256, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.6281070098452647}} {"text": "{-# OPTIONS --without-K #-}\nmodule distinct where\n\nopen import Type\nopen import Type.Identities\nopen import Algebra.FunctionProperties.Eq\n renaming (Injective to is-injective)\nopen import Function.NP\nopen import Function.Extensionality\nopen import Data.Fin.NP using (Fin; Fin▹ℕ; _==_)\nopen import Data.Vec.NP\nopen import Data.Vec.Properties\nopen import Data.Product renaming (proj₁ to fst; proj₂ to snd) hiding (map)\nopen import Data.Zero\nopen import Data.One\nopen import Data.Two hiding (_==_)\nopen import Data.Sum hiding (map)\nopen import Data.Nat.NP hiding (_==_)\nopen import Data.Nat.Properties\nimport Data.List as L\nimport Data.List.Properties as LP\nopen L using (List; []; _∷_)\nopen import Relation.Binary.PropositionalEquality.NP\nopen import HoTT\nopen Equivalences\n--open import Explore.Fin\n\nis-distinct : {A : Set}{n : ℕ} → Vec A n → Set\nis-distinct {n = n} v = is-injective (_‼_ v)\n-- is-distinct {n = n} v = {p q : Fin n}(e : v ‼ p ≡ v ‼ q) → p ≡ q\n\nDistinct : (A : Set)(n : ℕ) → Set\nDistinct A n = Σ (Vec A n) is-distinct\n\nInjection : (A B : Set) → Set\nInjection A B = Σ (A → B) is-injective\n\nAuto : (A : Set) → Set\nAuto A = Injection A A\n\nPerm : (n : ℕ) → Set\nPerm n = Distinct (Fin n) n\n\nmodule _ {n} {{_ : FunExt}} where\n Perm→Auto : Perm n → Auto (Fin n)\n Perm→Auto (v , v-dist) = _‼_ v , v-dist\n\n tabulate-dist : (f : Fin n → Fin n) (f-inj : Injective f) → is-distinct\n tabulate-dist f f-inj e = f-inj (! lookup∘tabulate f _ ∙ e ∙ lookup∘tabulate f _)\n\n Auto→Perm : Auto (Fin n) → Perm n\n Auto→Perm (f , f-inj)\n = tabulate f , λ e → f-inj (! lookup∘tabulate f _ ∙ e ∙ lookup∘tabulate f _)\n\nGoal: tr is-injective (λ= (lookup∘tabulate f))\n (snd (Auto→Perm (f , f-inj)))\n ≡ f-inj\n Perm→Auto→Perm : ∀ a → Perm→Auto (Auto→Perm a) ≡ a\n Perm→Auto→Perm (f , f-inj) = pair= (λ= (lookup∘tabulate f)) {!!}\n\n Auto→Perm→Auto : ∀ π → Auto→Perm (Perm→Auto π) ≡ π\n Auto→Perm→Auto (v , v-dist) = pair= (tabulate∘lookup v) {!!}\n\n Perm≃Auto : Perm n ≃ Auto (Fin n)\n Perm≃Auto = equiv Perm→Auto Auto→Perm Perm→Auto→Perm Auto→Perm→Auto\n\nArr : (n : ℕ) → Set\nArr n = Vec (Fin n) n\n\nSum : Set → Set\nSum A = (A → ℕ) → ℕ\nProd = Sum\n\npostulate\n sumFin : (n : ℕ) → Sum (Fin n)\n prodFin : (n : ℕ) → Prod (Fin n)\n -- sumVec : (A : Set)(n : ℕ) (f : Vec A n → ℕ) → ℕ\n sumArr : (n : ℕ) → Sum (Arr n)\n prodFinEq : {n : ℕ}(x y : Fin n) → Prod (x ≡ y)\n\ndistinctℕ : (n : ℕ) → (sumArr n λ v →\n prodFin n λ p →\n prodFin n λ q → \n prodFinEq p q λ e →\n 𝟚▹ℕ (p == q)) ≡ {!!}\ndistinctℕ = {!!}\n\n{-\nℕ< : ℕ → Set\nℕ< n = Σ ℕ λ x → x < n\n\nsum< : (n : ℕ) (f : ℕ< n → ℕ) → ℕ\nsum< n f = {!!}\n\nprod< : (n : ℕ) (f : ℕ< n → ℕ) → ℕ\nprod< n f = {!!}\n\n{-\nfoo : ∀ n a x → sumFin n λ i → a i * x ^ i\nfoo = ?\n\nbar : ∀ n a x → sumFin n λ i → a i * x ^ i\nbar = ?\n-}\n\nbaz : ∀ n (u : ℕ< n → ℕ) → (sum< n λ { (i , p) → prod< i (λ { (j , q) → u (j , <-trans q p) }) }) ≡ {!!}\nbaz = {!!}\n\nmodule _ n (u : ℕ< n → Set) {{_ : UA}} {{_ : FunExt}} where\n open ≡-Reasoning\n Baz : _ ≡ _\n Baz = (Σ (ℕ< n) λ { (i , p) → Π (ℕ< i) λ { (j , q) → u (j , <-trans q p) } })\n ≡⟨ ! Σ-assoc ⟩\n (Σ ℕ λ i → Σ (i < n) λ p → Π (ℕ< i) λ { (j , q) → u (j , <-trans q p) })\n ≡⟨ Σ=′ ℕ (λ i → Σ=′ (i < n) λ p → ΠΣ-curry) ⟩\n (Σ ℕ λ i → Σ (i < n) λ p → Π ℕ λ j → Π (j < i) λ q → u (j , <-trans q p))\n ∎\n\nmodule DataVersion (A : ★) where\n open import Data.Tree.Binary\n data T : BinTree A → ★ where\n empty : T empty\n _⊕_ : ∀ {t u} → (𝟙 ⊎ T t × T u) → T (fork t u)\n\nmodule TypeVersion where\n ε = 𝟙\n _⊕_ : ★ → ★ → ★\n _⊕_ = λ u z → ε ⊎ u × z\n \n\nmodule ListVersion where\n open L\n open ≡-Reasoning\n map-∘ = LP.map-compose\n\n sum-lin : ∀ k xs → sum (map (_*_ k) xs) ≡ k * sum xs\n sum-lin k [] = ℕ°.*-comm 0 k\n sum-lin k (x ∷ xs) = k * x + sum (map (_*_ k) xs)\n ≡⟨ ap (_+_ (k * x)) (sum-lin k xs) ⟩\n k * x + k * sum xs\n ≡⟨ ! fst ℕ°.distrib k x (sum xs) ⟩\n k * (x + sum xs)\n ∎\n\n lemma : ∀ x xss → sum (map product (map (_∷_ x) xss)) ≡ x * sum (map product xss)\n lemma x xss = sum (map product (map (_∷_ x) xss))\n ≡⟨ ap sum (! map-∘ xss) ⟩\n sum (map (product ∘ _∷_ x) xss)\n ≡⟨by-definition⟩\n sum (map (_*_ x ∘ product) xss)\n ≡⟨ ap sum (map-∘ xss) ⟩\n sum (map (_*_ x) (map product xss))\n ≡⟨ sum-lin x (map product xss) ⟩\n x * sum (map product xss)\n ∎\n\n ε = 1\n _⊕_ = λ u z → ε + u * z\n t3 = ∀ xs → sum (map product (inits xs)) ≡ foldr _⊕_ ε xs\n t4 : t3\n t4 [] = refl\n t4 (x ∷ xs) = ap suc (lemma x (inits xs) ∙ ap (_*_ x) (t4 xs))\n-- -}\n-- -}\n-- -}\n-- -}\n-- -}\n", "meta": {"hexsha": "24274591ddb7256af1fae1206fe0af13c47a059f", "size": 4922, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "experiments/distinct.agda", "max_stars_repo_name": "crypto-agda/explore", "max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z", "max_issues_repo_path": "experiments/distinct.agda", "max_issues_repo_name": "crypto-agda/explore", "max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z", "max_forks_repo_path": "experiments/distinct.agda", "max_forks_repo_name": "crypto-agda/explore", "max_forks_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.2976190476, "max_line_length": 104, "alphanum_fraction": 0.4904510362, "num_tokens": 1895, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772450055544, "lm_q2_score": 0.7185943925708562, "lm_q1q2_score": 0.6281070069347738}} {"text": "-- Andreas, 2014-11-25, variant of Issue 1366\n\n{-# OPTIONS --copatterns #-}\n\nopen import Common.Prelude using (Nat; zero; suc; Unit; unit)\n\ndata Vec (A : Set) : Nat → Set where\n [] : Vec A zero\n _∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)\n\n-- Singleton type\n\ndata Sg {A : Set} (x : A) : Set where\n sg : Sg x\n\n-- Generalizing Unit → Nat\n\nrecord DNat : Set₁ where\n field\n D : Set\n force : D → Nat\nopen DNat\n\nnonNil : ∀ {n} → Vec Unit n → Nat\nnonNil [] = zero\nnonNil (i ∷ is) = suc (force f i) where\n f : DNat\n D f = Unit\n force f unit = zero\n\ng : ∀ {n} {v : Vec Unit n} → Sg (nonNil v) → Sg v\ng sg = sg\n\none : Sg (suc zero)\none = sg\n\ntest : Sg (unit ∷ [])\ntest = g one\n", "meta": {"hexsha": "298bad9e4988aa3d4cdf4f8174a8417e3eb7e987", "size": 700, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1366a.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue1366a.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue1366a.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 17.9487179487, "max_line_length": 61, "alphanum_fraction": 0.55, "num_tokens": 267, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772351648677, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.6281069945956665}} {"text": "\ndata Bool : Set where\n true false : Bool\n\ndata Nat : Set where\n zero : Nat\n suc : Nat → Nat\n\none : Nat\none = suc zero\n\ntwo : Nat\ntwo = suc one\n\ndata Fin : Nat → Set where\n zero : ∀{n} → Fin (suc n)\n suc : ∀{n} (i : Fin n) → Fin (suc n)\n\n--This part works as expected:\n\ns : ∀ n → (f : (k : Fin n) → Bool) → Fin (suc n)\ns n f = zero\n\nt1 : Fin two\nt1 = s one (λ { zero → true ; (suc ()) })\n\n-- But Agda is not able to infer the 1 in this case:\n\nttwo : Fin two\nttwo = s _ (λ { zero → true ; (suc ()) })\n\n-- Warning:\n-- _142 : Nat\n\n-- The problem gets worse when i add arguments to the ttwo function. This gives an error:\n\nt3 : Set → Fin two\nt3 A = s _ (λ { zero → true ; (suc ()) })\n", "meta": {"hexsha": "4a082d2dbccc4bea95793310b4383b7513713c74", "size": 686, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1922.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue1922.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue1922.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 17.5897435897, "max_line_length": 89, "alphanum_fraction": 0.5655976676, "num_tokens": 246, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9294403999037782, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.6280829270811058}} {"text": "\n-- This module explains how to combine elimination of empty types with pattern\n-- match style definitions without running into problems with decidability.\n\nmodule Introduction.Data.Empty where\n\n-- First we introduce an empty and a singleton type.\ndata Zero : Set where\ndata One : Set where\n one : One\n\n-- There is a special pattern () which matches any element of an (obviously)\n-- empty type. If there is a ()-pattern in a left-hand side the right-hand side\n-- can be omitted.\nelim-Zero : {A : Set} -> Zero -> A\nelim-Zero ()\n\ndata _×_ (A B : Set) : Set where\n pair : A -> B -> A × B\n\n-- The algorithm for checking if a type is empty is very naive. In this example\n-- you cannot replace pair () _ with () because the type checker cannot see\n-- that Zero × B is empty.\nelim-EmptyPair : {A B : Set} -> Zero × B -> A\nelim-EmptyPair (pair () _)\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\n-- For some empty types finite unfolding is not enough.\nConstZero : Nat -> Set\nConstZero zero = Zero\nConstZero (suc n) = ConstZero n\n\n-- We can still define the elimination function but we have to do it\n-- recursively over the n.\nelim-ConstZero : (n : Nat) -> ConstZero n -> {A : Set} -> A\nelim-ConstZero zero ()\nelim-ConstZero (suc n) x = elim-ConstZero n x\n\n", "meta": {"hexsha": "aa85712588c59176821295ff42dd4fe615aa1901", "size": 1268, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/Introduction/Data/Empty.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/Introduction/Data/Empty.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/Introduction/Data/Empty.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 30.1904761905, "max_line_length": 79, "alphanum_fraction": 0.6869085174, "num_tokens": 345, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797100118214, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.6280812861964176}} {"text": "\nmodule Lib.Bool where\n\nopen import Lib.Logic\n\ndata Bool : Set where\n true : Bool\n false : Bool\n\n{-# BUILTIN BOOL Bool #-}\n{-# BUILTIN TRUE true #-}\n{-# BUILTIN FALSE false #-}\n\n{-# COMPILED_DATA Bool Bool True False #-}\n\nisTrue : Bool -> Set\nisTrue true = True\nisTrue false = False\n\nisFalse : Bool -> Set\nisFalse true = False\nisFalse false = True\n\ndata Inspect (b : Bool) : Set where\n itsTrue : .(isTrue b) -> Inspect b\n itsFalse : .(isFalse b) -> Inspect b\n\ninspect : (b : Bool) -> Inspect b\ninspect true = itsTrue _\ninspect false = itsFalse _\n\ninfix 5 if_then_else_\n\nif_then_else_ : {A : Set} -> Bool -> A -> A -> A\nif true then x else y = x\nif false then x else y = y\n\nnot : Bool -> Bool\nnot true = false\nnot false = true\n\ninfixr 25 _&&_\ninfixr 22 _||_\n\n_&&_ : Bool -> Bool -> Bool\nfalse && y = false\ntrue && y = y\n\n_||_ : Bool -> Bool -> Bool\nfalse || y = y\ntrue || y = true\n", "meta": {"hexsha": "d60d5585ba277bdfab5c251e73a8e702b87cd8df", "size": 894, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/simple-lib/Lib/Bool.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/simple-lib/Lib/Bool.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/simple-lib/Lib/Bool.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 17.1923076923, "max_line_length": 48, "alphanum_fraction": 0.6252796421, "num_tokens": 290, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519527944504227, "lm_q2_score": 0.7371581741774411, "lm_q1q2_score": 0.6280239664424424}} {"text": "module Human.List where\n\nopen import Human.Nat\n\ninfixr 5 _,_\ndata List {a} (A : Set a) : Set a where\n end : List A\n _,_ : (x : A) (xs : List A) → List A\n\n{-# BUILTIN LIST List #-}\n\n{-# COMPILE JS List = function(x,v) { if (x.length < 1) { return v[\"[]\"](); } else { return v[\"_∷_\"](x[0], x.slice(1)); } } #-}\n{-# COMPILE JS end = Array() #-}\n{-# COMPILE JS _,_ = function (x) { return function(y) { return Array(x).concat(y); }; } #-}\n\nfoldr : ∀ {A : Set} {B : Set} → (A → B → B) → B → List A → B\nfoldr c n end = n\nfoldr c n (x , xs) = c x (foldr c n xs)\n\nlength : ∀ {A : Set} → List A → Nat\nlength = foldr (λ a n → suc n) zero\n\n-- TODO --\n-- filter\n-- reduce\n\n-- Receives a function that transforms each element of A, a function A and a new list, B.\nmap : ∀ {A : Set} {B : Set} → (f : A → B) → List A → List B\nmap f end = end\nmap f (x , xs) = (f x) , (map f xs) -- f transforms element x, return map to do a new transformation\n\n-- Sum all numbers in a list\nsum : List Nat → Nat\nsum end = zero\nsum (x , l) = x + (sum l)\n\nremove-last : ∀ {A : Set} → List A → List A\nremove-last end = end\nremove-last (x , l) = l\n", "meta": {"hexsha": "21cc7c58c4b6dd20c7f624fa65c4983af33ff34c", "size": 1133, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Human/List.agda", "max_stars_repo_name": "MaisaMilena/JuiceMaker", "max_stars_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-03-29T17:35:20.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-28T05:46:27.000Z", "max_issues_repo_path": "src/Human/List.agda", "max_issues_repo_name": "MaisaMilena/JuiceMaker", "max_issues_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Human/List.agda", "max_forks_repo_name": "MaisaMilena/JuiceMaker", "max_forks_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.325, "max_line_length": 128, "alphanum_fraction": 0.5516328332, "num_tokens": 401, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519527944504228, "lm_q2_score": 0.7371581568543043, "lm_q1q2_score": 0.6280239516839476}} {"text": "{-# OPTIONS --without-K #-}\nmodule AC {a b c} {A : Set a} {B : A → Set b} {C : (x : A) → B x → Set c} where\n\nopen import Equivalence\nopen import FunExt\nopen import Types\n\nleft : Set _\nleft = (x : A) → Σ (B x) λ y → C x y\n\nright : Set _\nright = Σ ((x : A) → B x) λ f → (x : A) → C x (f x)\n\nto : left → right\nto f = π₁ ∘ f , π₂ ∘ f\n\nfrom : right → left\nfrom f x = π₁ f x , π₂ f x\n\nAC∞ : right ≃ left\nAC∞\n = from\n , (to , λ _ → refl)\n , (to , λ _ → refl)\n", "meta": {"hexsha": "9e3f6d2493228816b9dbba9ec35a8c3243d1905b", "size": 455, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/AC.agda", "max_stars_repo_name": "vituscze/HoTT-lectures", "max_stars_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/AC.agda", "max_issues_repo_name": "vituscze/HoTT-lectures", "max_issues_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/AC.agda", "max_forks_repo_name": "vituscze/HoTT-lectures", "max_forks_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.2, "max_line_length": 79, "alphanum_fraction": 0.5098901099, "num_tokens": 193, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8856314798554445, "lm_q2_score": 0.7090191399336401, "lm_q1q2_score": 0.6279296701452641}} {"text": "module Thesis.SIRelBigStep.OpSem where\n\nopen import Data.Nat\nopen import Thesis.SIRelBigStep.Syntax public\n\ndata Val : Type → Set\n\nimport Base.Denotation.Environment\nopen Base.Denotation.Environment Type Val public\nopen import Base.Data.DependentList public\n\ndata Val where\n closure : ∀ {Γ σ τ} → (t : Term (σ • Γ) τ) → (ρ : ⟦ Γ ⟧Context) → Val (σ ⇒ τ)\n natV : ∀ (n : ℕ) → Val nat\n pairV : ∀ {σ τ} → Val σ → Val τ → Val (pair σ τ)\n\neval-const : ∀ {τ} → Const τ → Val τ\neval-const (lit n) = natV n\n\neval : ∀ {Γ τ} (sv : SVal Γ τ) (ρ : ⟦ Γ ⟧Context) → Val τ\neval (var x) ρ = ⟦ x ⟧Var ρ\neval (abs t) ρ = closure t ρ\neval (cons sv1 sv2) ρ = pairV (eval sv1 ρ) (eval sv2 ρ)\neval (const c) ρ = eval-const c\n\neval-primitive : ∀ {σ τ} → Primitive (σ ⇒ τ) → Val σ → Val τ\neval-primitive succ (natV n) = natV (suc n)\neval-primitive add (pairV (natV n1) (natV n2)) = natV (n1 + n2)\n\n-- Yann's idea.\ndata HasIdx : Set where\n true : HasIdx\n false : HasIdx\ndata Idx : HasIdx → Set where\n i' : ℕ → Idx true\n no : Idx false\n\ni : {hasIdx : HasIdx} → ℕ → Idx hasIdx\ni {false} j = no\ni {true} j = i' j\n\nmodule _ {hasIdx : HasIdx} where\n data _⊢_↓[_]_ {Γ} (ρ : ⟦ Γ ⟧Context) : ∀ {τ} → Term Γ τ → Idx hasIdx → Val τ → Set where\n val : ∀ {τ} (sv : SVal Γ τ) →\n ρ ⊢ val sv ↓[ i 0 ] eval sv ρ\n primapp : ∀ {σ τ} (p : Primitive (σ ⇒ τ)) (sv : SVal Γ σ) →\n ρ ⊢ primapp p sv ↓[ i 1 ] eval-primitive p (eval sv ρ)\n app : ∀ n {Γ′ σ τ ρ′} vtv {v} {vs : SVal Γ (σ ⇒ τ)} {vt : SVal Γ σ} {t : Term (σ • Γ′) τ} →\n ρ ⊢ val vs ↓[ i 0 ] closure t ρ′ →\n ρ ⊢ val vt ↓[ i 0 ] vtv →\n (vtv • ρ′) ⊢ t ↓[ i n ] v →\n ρ ⊢ app vs vt ↓[ i (suc n) ] v\n lett :\n ∀ n1 n2 {σ τ} vsv {v} (s : Term Γ σ) (t : Term (σ • Γ) τ) →\n ρ ⊢ s ↓[ i n1 ] vsv →\n (vsv • ρ) ⊢ t ↓[ i n2 ] v →\n ρ ⊢ lett s t ↓[ i (suc n1 + n2) ] v\n", "meta": {"hexsha": "c43657202a477da9b598e6035e8d6a605340f0da", "size": 1831, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Thesis/SIRelBigStep/OpSem.agda", "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_issues_repo_path": "Thesis/SIRelBigStep/OpSem.agda", "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_forks_repo_path": "Thesis/SIRelBigStep/OpSem.agda", "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "avg_line_length": 31.5689655172, "max_line_length": 95, "alphanum_fraction": 0.5412342982, "num_tokens": 796, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8856314677809304, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.6279296506935093}} {"text": "\nmodule Haskell.Prim.Functor where\n\nopen import Haskell.Prim\nopen import Haskell.Prim.Either\nopen import Haskell.Prim.List\nopen import Haskell.Prim.Maybe\nopen import Haskell.Prim.Tuple\n\n--------------------------------------------------\n-- Functor\n\nrecord Functor (f : Set → Set) : Set₁ where\n field\n fmap : (a → b) → f a → f b\n\n infixl 1 _<&>_\n infixl 4 _<$>_ _<$_ _$>_\n\n _<$>_ : (a → b) → f a → f b\n _<$>_ = fmap\n\n _<&>_ : f a → (a → b) → f b\n m <&> f = fmap f m\n\n _<$_ : a → f b → f a\n x <$ m = fmap (const x) m\n\n _$>_ : f a → b → f b\n m $> x = x <$ m\n\n void : f a → f (Tuple [])\n void = [] <$_\n\nopen Functor ⦃ ... ⦄ public\n\ninstance\n iFunctorList : Functor List\n iFunctorList .fmap = map\n\n iFunctorMaybe : Functor Maybe\n iFunctorMaybe .fmap f Nothing = Nothing\n iFunctorMaybe .fmap f (Just x) = Just (f x)\n\n iFunctorEither : Functor (Either a)\n iFunctorEither .fmap f (Left x) = Left x\n iFunctorEither .fmap f (Right y) = Right (f y)\n\n iFunctorFun : Functor (λ b → a → b)\n iFunctorFun .fmap = _∘_\n\n iFunctorTuple₂ : Functor (a ×_)\n iFunctorTuple₂ .fmap f (x , y) = x , f y\n\n iFunctorTuple₃ : Functor (a × b ×_)\n iFunctorTuple₃ .fmap f (x , y , z) = x , y , f z\n\n iFunctorTuple₄ : Functor (λ d → Tuple (a ∷ b ∷ c ∷ d ∷ []))\n iFunctorTuple₄ .fmap f (x ∷ y ∷ z ∷ w ∷ []) = x ∷ y ∷ z ∷ f w ∷ []\n", "meta": {"hexsha": "110e22419bda3212f498bcff730e3b80eecdda9a", "size": 1329, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lib/Haskell/Prim/Functor.agda", "max_stars_repo_name": "flupe/agda2hs", "max_stars_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/Haskell/Prim/Functor.agda", "max_issues_repo_name": "flupe/agda2hs", "max_issues_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/Haskell/Prim/Functor.agda", "max_forks_repo_name": "flupe/agda2hs", "max_forks_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.15, "max_line_length": 68, "alphanum_fraction": 0.5590669676, "num_tokens": 516, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774767842777551, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.6277679472152243}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Groups.Definition\nopen import Rings.Definition\nopen import Rings.IntegralDomains.Definition\nopen import Setoids.Setoids\nopen import Sets.EquivalenceRelations\n\nmodule Fields.FieldOfFractions.Ring {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} {_*_ : A → A → A} {R : Ring S _+_ _*_} (I : IntegralDomain R) where\n\nopen import Fields.FieldOfFractions.Setoid I\nopen import Fields.FieldOfFractions.Addition I\nopen import Fields.FieldOfFractions.Group I\nopen import Fields.FieldOfFractions.Multiplication I\n\nfieldOfFractionsRing : Ring fieldOfFractionsSetoid fieldOfFractionsPlus fieldOfFractionsTimes\nRing.additiveGroup fieldOfFractionsRing = fieldOfFractionsGroup\nRing.*WellDefined fieldOfFractionsRing {a} {b} {c} {d} = fieldOfFractionsTimesWellDefined {a} {b} {c} {d}\nRing.1R fieldOfFractionsRing = record { num = Ring.1R R ; denom = Ring.1R R ; denomNonzero = IntegralDomain.nontrivial I }\nRing.groupIsAbelian fieldOfFractionsRing {record { num = a ; denom = b }} {record { num = c ; denom = d }} = Equivalence.transitive (Setoid.eq S) (Ring.*Commutative R) (Ring.*WellDefined R (Ring.*Commutative R) (Equivalence.transitive (Setoid.eq S) (Group.+WellDefined (Ring.additiveGroup R) (Ring.*Commutative R) (Ring.*Commutative R)) (Ring.groupIsAbelian R)))\nRing.*Associative fieldOfFractionsRing {record { num = a ; denom = b }} {record { num = c ; denom = d }} {record { num = e ; denom = f }} = Equivalence.transitive (Setoid.eq S) (Ring.*WellDefined R (Ring.*Associative R) (Ring.*Associative' R)) (Ring.*Commutative R)\nRing.*Commutative fieldOfFractionsRing {record { num = a ; denom = b }} {record { num = c ; denom = d }} = Equivalence.transitive (Setoid.eq S) (Ring.*Commutative R) (Ring.*WellDefined R (Ring.*Commutative R) (Ring.*Commutative R))\nRing.*DistributesOver+ fieldOfFractionsRing {record { num = a ; denom = b }} {record { num = c ; denom = d }} {record { num = e ; denom = f }} = need\n where\n open Setoid S\n open Ring R\n open Equivalence eq\n inter : b * (a * ((c * f) + (d * e))) ∼ (((a * c) * (b * f)) + ((b * d) * (a * e)))\n inter = transitive *Associative (transitive *DistributesOver+ (Group.+WellDefined additiveGroup (transitive *Associative (transitive (*WellDefined (transitive (*WellDefined (*Commutative) reflexive) (transitive (symmetric *Associative) (transitive (*WellDefined reflexive *Commutative) *Associative))) reflexive) (symmetric *Associative))) (transitive *Associative (transitive (*WellDefined (transitive (symmetric *Associative) (transitive (*WellDefined reflexive *Commutative) *Associative)) reflexive) (symmetric *Associative)))))\n need : ((a * ((c * f) + (d * e))) * ((b * d) * (b * f))) ∼ ((b * (d * f)) * (((a * c) * (b * f)) + ((b * d) * (a * e))))\n need = transitive (Ring.*WellDefined R reflexive (Ring.*WellDefined R reflexive (Ring.*Commutative R))) (transitive (Ring.*WellDefined R reflexive (Ring.*Associative R)) (transitive (Ring.*Commutative R) (transitive (Ring.*WellDefined R (Ring.*WellDefined R (symmetric (Ring.*Associative R)) reflexive) reflexive) (transitive (symmetric (Ring.*Associative R)) (Ring.*WellDefined R reflexive inter)))))\nRing.identIsIdent fieldOfFractionsRing {record { num = a ; denom = b }} = need\n where\n open Setoid S\n open Equivalence eq\n need : (((Ring.1R R) * a) * b) ∼ (((Ring.1R R * b)) * a)\n need = transitive (Ring.*WellDefined R (Ring.identIsIdent R) reflexive) (transitive (Ring.*Commutative R) (Ring.*WellDefined R (symmetric (Ring.identIsIdent R)) reflexive))\n", "meta": {"hexsha": "05c20a00e1de7414cb215425d8de9e7c0b6b4e6a", "size": 3596, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Fields/FieldOfFractions/Ring.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Fields/FieldOfFractions/Ring.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Fields/FieldOfFractions/Ring.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 92.2051282051, "max_line_length": 536, "alphanum_fraction": 0.7027252503, "num_tokens": 1098, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774767778695834, "lm_q2_score": 0.7154239836484143, "lm_q1q2_score": 0.6277679319824322}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nmodule Cubical.Algebra.Group.Properties where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Data.Sigma\nopen import Cubical.Algebra.Semigroup\nopen import Cubical.Algebra.Monoid\nopen import Cubical.Algebra.Group.Base\n\nprivate\n variable\n ℓ ℓ' ℓ'' : Level\n\nmodule GroupLemmas (G : Group {ℓ}) where\n open Group G public\n abstract\n simplL : (a : Carrier) {b c : Carrier} → a + b ≡ a + c → b ≡ c\n simplL a {b} {c} p =\n b\n ≡⟨ sym (lid b) ∙ cong (_+ b) (sym (invl a)) ∙ sym (assoc _ _ _) ⟩\n - a + (a + b)\n ≡⟨ cong (- a +_) p ⟩\n - a + (a + c)\n ≡⟨ assoc _ _ _ ∙ cong (_+ c) (invl a) ∙ lid c ⟩\n c ∎\n\n simplR : {a b : Carrier} (c : Carrier) → a + c ≡ b + c → a ≡ b\n simplR {a} {b} c p =\n a\n ≡⟨ sym (rid a) ∙ cong (a +_) (sym (invr c)) ∙ assoc _ _ _ ⟩\n (a + c) - c\n ≡⟨ cong (_- c) p ⟩\n (b + c) - c\n ≡⟨ sym (assoc _ _ _) ∙ cong (b +_) (invr c) ∙ rid b ⟩\n b ∎\n\n invInvo : (a : Carrier) → - (- a) ≡ a\n invInvo a = simplL (- a) (invr (- a) ∙ sym (invl a))\n\n invId : - 0g ≡ 0g\n invId = simplL 0g (invr 0g ∙ sym (lid 0g))\n\n idUniqueL : {e : Carrier} (x : Carrier) → e + x ≡ x → e ≡ 0g\n idUniqueL {e} x p = simplR x (p ∙ sym (lid _))\n\n idUniqueR : (x : Carrier) {e : Carrier} → x + e ≡ x → e ≡ 0g\n idUniqueR x {e} p = simplL x (p ∙ sym (rid _))\n\n invUniqueL : {g h : Carrier} → g + h ≡ 0g → g ≡ - h\n invUniqueL {g} {h} p = simplR h (p ∙ sym (invl h))\n\n invUniqueR : {g h : Carrier} → g + h ≡ 0g → h ≡ - g\n invUniqueR {g} {h} p = simplL g (p ∙ sym (invr g))\n\n invDistr : (a b : Carrier) → - (a + b) ≡ - b - a\n invDistr a b = sym (invUniqueR γ) where\n γ : (a + b) + (- b - a) ≡ 0g\n γ = (a + b) + (- b - a)\n ≡⟨ sym (assoc _ _ _) ⟩\n a + b + (- b) + (- a)\n ≡⟨ cong (a +_) (assoc _ _ _ ∙ cong (_+ (- a)) (invr b)) ⟩\n a + (0g - a)\n ≡⟨ cong (a +_) (lid (- a)) ∙ invr a ⟩\n 0g ∎\n\nisPropIsGroup : {G : Type ℓ} (0g : G) (_+_ : G → G → G) (-_ : G → G)\n → isProp (IsGroup 0g _+_ -_)\nIsGroup.isMonoid (isPropIsGroup 0g _+_ -_ g1 g2 i) = isPropIsMonoid _ _ (IsGroup.isMonoid g1) (IsGroup.isMonoid g2) i\nIsGroup.inverse (isPropIsGroup 0g _+_ -_ g1 g2 i) = isPropInv (IsGroup.inverse g1) (IsGroup.inverse g2) i\n where\n isSetG : isSet _\n isSetG = IsSemigroup.is-set (IsMonoid.isSemigroup (IsGroup.isMonoid g1))\n\n isPropInv : isProp ((x : _) → ((x + (- x)) ≡ 0g) × (((- x) + x) ≡ 0g))\n isPropInv = isPropΠ λ _ → isProp× (isSetG _ _) (isSetG _ _)\n", "meta": {"hexsha": "6783ed64f60fd1ac08af822adecc1e4111d6ff5f", "size": 2641, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Group/Properties.agda", "max_stars_repo_name": "knrafto/cubical", "max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Group/Properties.agda", "max_issues_repo_name": "knrafto/cubical", "max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Group/Properties.agda", "max_forks_repo_name": "knrafto/cubical", "max_forks_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.858974359, "max_line_length": 117, "alphanum_fraction": 0.5077622113, "num_tokens": 1114, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891348788759, "lm_q2_score": 0.7634837689358857, "lm_q1q2_score": 0.6277280594754594}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import lib.Basics\nopen import lib.types.Span\nopen import lib.types.Pushout\nopen import lib.types.PushoutFlattening\nopen import lib.types.Unit\nopen import lib.types.Pointed\n\n-- Cofiber is defined as a particular case of pushout\n\nmodule lib.types.Cofiber where\n\nmodule _ {i j} {A : Type i} {B : Type j} (f : A → B) where\n\n cofiber-span : Span\n cofiber-span = span Unit B A (λ _ → tt) f\n\n Cofiber : Type (lmax i j)\n Cofiber = Pushout cofiber-span\n\n cfbase' : Cofiber\n cfbase' = left tt\n\n cfcod' : B → Cofiber\n cfcod' b = right b\n\n cfglue' : (a : A) → cfbase' == cfcod' (f a)\n cfglue' a = glue a\n\nmodule _ {i j} {A : Type i} {B : Type j} {f : A → B} where\n\n cfbase : Cofiber f\n cfbase = cfbase' f\n\n cfcod : B → Cofiber f\n cfcod = cfcod' f\n\n cfglue : (a : A) → cfbase == cfcod (f a)\n cfglue = cfglue' f\n\n module CofiberElim {k} {P : Cofiber f → Type k}\n (b : P cfbase) (c : (y : B) → P (cfcod y)) \n (p : (x : A) → b == c (f x) [ P ↓ cfglue x ])\n = PushoutElim (λ _ → b) c p\n\n open CofiberElim public using () renaming (f to Cofiber-elim)\n\n module CofiberRec {k} {C : Type k} (b : C) (c : B → C)\n (p : (x : A) → b == c (f x))\n = PushoutRec {d = cofiber-span f} (λ _ → b) c p\n\n module CofiberRecType {k} (b : Type k) (c : B → Type k)\n (p : (x : A) → b ≃ c (f x))\n = PushoutRecType {d = cofiber-span f} (λ _ → b) c p\n\nmodule _ {i j} {X : Ptd i} {Y : Ptd j} (F : fst (X ⊙→ Y)) where\n\n ⊙cof-span : ⊙Span\n ⊙cof-span = ⊙span ⊙Unit Y X ((λ _ → tt) , idp) F\n\n ⊙Cof : Ptd (lmax i j)\n ⊙Cof = ⊙Pushout ⊙cof-span\n\n ⊙cfcod' : fst (Y ⊙→ ⊙Cof)\n ⊙cfcod' = cfcod , ap cfcod (! (snd F)) ∙ ! (cfglue (snd X))\n\n ⊙cfglue' : ⊙cst == ⊙cfcod' ⊙∘ F\n ⊙cfglue' = ⊙λ= cfglue (lemma cfcod (cfglue (snd X)) (snd F))\n where\n lemma : ∀ {i j} {A : Type i} {B : Type j} (f : A → B)\n {x y : A} {z : B} (p : z == f x) (q : x == y)\n → idp == p ∙ ap f q ∙ ap f (! q) ∙ ! p\n lemma f idp idp = idp\n\nmodule _ {i j} {X : Ptd i} {Y : Ptd j} {F : fst (X ⊙→ Y)} where\n\n ⊙cfcod : fst (Y ⊙→ ⊙Cof F)\n ⊙cfcod = ⊙cfcod' F\n\n ⊙cfglue : ⊙cst == ⊙cfcod ⊙∘ F\n ⊙cfglue = ⊙cfglue' F\n", "meta": {"hexsha": "26f1ba0a04721426da48a594479a23e2d092499d", "size": 2126, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/types/Cofiber.agda", "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "core/lib/types/Cofiber.agda", "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "core/lib/types/Cofiber.agda", "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.6144578313, "max_line_length": 63, "alphanum_fraction": 0.5385700847, "num_tokens": 956, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.822189121808099, "lm_q2_score": 0.7634837689358857, "lm_q1q2_score": 0.6277280494961334}} {"text": "\nmodule Pos where\n\n import Prelude\n import Equiv\n import Datoid\n import Nat\n\n open Prelude\n open Equiv\n open Datoid\n\n abstract\n\n Pos : Set\n Pos = Nat.Nat\n\n one : Pos\n one = Nat.zero\n\n suc : Pos -> Pos\n suc = Nat.suc\n\n suc' : Nat.Nat -> Pos\n suc' n = n\n\n _+_ : Pos -> Pos -> Pos\n m + n = suc (Nat._+_ m n)\n\n -- Returns Nothing if input is 1.\n pred : Pos -> Maybe Pos\n pred Nat.zero = Nothing\n pred (Nat.suc n) = Just n\n\n toNat : Pos -> Nat.Nat\n toNat = suc\n\n decidableEquiv : DecidableEquiv Pos\n decidableEquiv = Nat.decidableEquiv\n\n posDatoid : Datoid\n posDatoid = datoid Pos decidableEquiv\n\n sucPred : Maybe Pos -> Pos\n sucPred Nothing = one\n sucPred (Just p) = suc p\n\n data Pred (p : Pos) (mP : Maybe Pos) : Set where\n ok : datoidRel posDatoid (sucPred mP) p -> Pred p mP\n\n abstract\n\n -- Returns Nothing if input is 1.\n predOK : (p : Pos) -> Pred p (pred p)\n predOK Nat.zero = ok (dRefl posDatoid {one})\n predOK (Nat.suc n) = ok (dRefl posDatoid {n})\n", "meta": {"hexsha": "b4c2069deb5eb561caf6563fcdb9ce2eb6125976", "size": 1044, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/AIM4/bag/Pos.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/AIM4/bag/Pos.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/AIM4/bag/Pos.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 18.3157894737, "max_line_length": 56, "alphanum_fraction": 0.5957854406, "num_tokens": 355, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9196425245706048, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.6277238382588277}} {"text": "------------------------------------------------------------------------------\n-- Well-founded relation on lists based on their length\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOTC.Data.List.WF-Relation.LT-Length where\n\nopen import FOTC.Base\nopen import FOTC.Data.List\nopen import FOTC.Data.Nat.Inequalities\n\n------------------------------------------------------------------------------\n-- Well-founded relation on lists based on their length.\nLTL : D → D → Set\nLTL xs ys = length xs < length ys\n", "meta": {"hexsha": "422a148c5218e4b64a08bc1f62537a29e1b042c9", "size": 716, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/FOTC/Data/List/WF-Relation/LT-Length.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/FOTC/Data/List/WF-Relation/LT-Length.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/FOTC/Data/List/WF-Relation/LT-Length.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 35.8, "max_line_length": 78, "alphanum_fraction": 0.437150838, "num_tokens": 122, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8479677583778258, "lm_q2_score": 0.7401743620390162, "lm_q1q2_score": 0.6276439945869619}} {"text": "module bool-thms2 where\n\nopen import bool\nopen import eq\nopen import product\nopen import sum\n\nff-imp : ∀ (b : 𝔹) → (ff imp b) ≡ tt\nff-imp ff = refl\nff-imp tt = refl\n\nimp-tt : ∀ (b : 𝔹) → (b imp tt) ≡ tt\nimp-tt ff = refl\nimp-tt tt = refl\n\nimp-ff : ∀ (b : 𝔹) → (b imp ff) ≡ ~ b\nimp-ff tt = refl\nimp-ff ff = refl\n\ntt-imp : ∀ (b : 𝔹) → (tt imp b) ≡ b\ntt-imp tt = refl\ntt-imp ff = refl\n\n&&-tt : ∀ (b : 𝔹) → b && tt ≡ b\n&&-tt tt = refl\n&&-tt ff = refl\n\n||-ff : ∀ (b : 𝔹) → b || ff ≡ b\n||-ff tt = refl\n||-ff ff = refl\n\n&&-contra : ∀ (b : 𝔹) → b && ~ b ≡ ff\n&&-contra ff = refl\n&&-contra tt = refl\n\n&&-comm : ∀ (b1 b2 : 𝔹) → b1 && b2 ≡ b2 && b1\n&&-comm ff ff = refl\n&&-comm ff tt = refl\n&&-comm tt ff = refl\n&&-comm tt tt = refl\n\n||-comm : ∀ (b1 b2 : 𝔹) → b1 || b2 ≡ b2 || b1\n||-comm ff ff = refl\n||-comm ff tt = refl\n||-comm tt ff = refl\n||-comm tt tt = refl\n\n&&-assoc : ∀ (b1 b2 b3 : 𝔹) → b1 && (b2 && b3) ≡ (b1 && b2) && b3\n&&-assoc ff _ _ = refl\n&&-assoc tt _ _ = refl\n\n||-assoc : ∀ (b1 b2 b3 : 𝔹) → b1 || (b2 || b3) ≡ (b1 || b2) || b3\n||-assoc tt _ _ = refl\n||-assoc ff _ _ = refl\n\n~-over-&& : ∀ (b1 b2 : 𝔹) → ~ ( b1 && b2 ) ≡ (~ b1 || ~ b2)\n~-over-&& tt _ = refl\n~-over-&& ff _ = refl\n\n~-over-|| : ∀ (b1 b2 : 𝔹) → ~ ( b1 || b2 ) ≡ (~ b1 && ~ b2)\n~-over-|| tt _ = refl\n~-over-|| ff _ = refl\n\n&&-over-||-l : ∀ (a b c : 𝔹) → a && (b || c) ≡ (a && b) || (a && c)\n&&-over-||-l tt _ _ = refl\n&&-over-||-l ff _ _ = refl \n\n&&-over-||-r : ∀ (a b c : 𝔹) → (a || b) && c ≡ (a && c) || (b && c)\n&&-over-||-r tt tt tt = refl\n&&-over-||-r tt tt ff = refl\n&&-over-||-r tt ff tt = refl\n&&-over-||-r tt ff ff = refl\n&&-over-||-r ff tt tt = refl\n&&-over-||-r ff tt ff = refl\n&&-over-||-r ff ff tt = refl\n&&-over-||-r ff ff ff = refl\n\n||-over-&&-l : ∀ (a b c : 𝔹) → a || (b && c) ≡ (a || b) && (a || c)\n||-over-&&-l tt _ _ = refl\n||-over-&&-l ff _ _ = refl \n\n||-over-&&-r : ∀ (a b c : 𝔹) → (a && b) || c ≡ (a || c) && (b || c)\n||-over-&&-r tt _ _ = refl\n||-over-&&-r ff _ ff = refl\n||-over-&&-r ff tt tt = refl\n||-over-&&-r ff ff tt = refl\n\n&&-cong₁ : ∀ {b1 b1' b2 : 𝔹} → b1 ≡ b1' → b1 && b2 ≡ b1' && b2\n&&-cong₁ refl = refl\n\n&&-cong₂ : ∀ {b1 b2 b2' : 𝔹} → b2 ≡ b2' → b1 && b2 ≡ b1 && b2'\n&&-cong₂ refl = refl \n\n&&-intro : ∀ {b1 b2 : 𝔹} → b1 ≡ tt → b2 ≡ tt → b1 && b2 ≡ tt\n&&-intro{tt}{tt} _ _ = refl\n&&-intro{tt}{ff} _ ()\n&&-intro{ff}{tt} () _\n&&-intro{ff}{ff} () _\n\n||-intro1 : ∀ {b1 b2 : 𝔹} → b1 ≡ tt → b1 || b2 ≡ tt\n||-intro1 {tt} p = refl\n||-intro1 {ff} ()\n\n&&-elim : ∀ {b1 b2 : 𝔹} → b1 && b2 ≡ tt → b1 ≡ tt ∧ b2 ≡ tt \n&&-elim{tt}{tt} _ = refl , refl\n&&-elim{ff}{_} ()\n&&-elim{tt}{ff} ()\n\n&&-elim1 : ∀ {b1 b2 : 𝔹} → b1 && b2 ≡ tt → b1 ≡ tt\n&&-elim1 p with &&-elim p\n&&-elim1 _ | p , _ = p\n\n&&-elim2 : ∀ {b1 b2 : 𝔹} → b1 && b2 ≡ tt → b2 ≡ tt\n&&-elim2{b1} p with &&-elim{b1} p\n&&-elim2 _ | _ , p = p\n\n||-elim : ∀ {b1 b2 : 𝔹} → b1 || b2 ≡ tt → b1 ≡ tt ∨ b2 ≡ tt\n||-elim {tt} refl = inj₁ refl\n||-elim {ff} refl = inj₂ refl\n\n~-cong : ∀ {b b' : 𝔹} → b ≡ b' → ~ b ≡ ~ b'\n~-cong refl = refl\n\nite-cong₁ : ∀{ℓ}{A : Set ℓ} {b b' : 𝔹}(x y : A) → b ≡ b' → (if b then x else y) ≡ (if b' then x else y)\nite-cong₁ x y refl = refl\n\nite-cong₂ : ∀{ℓ}{A : Set ℓ} (b : 𝔹){x x' : A}(y : A) → x ≡ x' → (if b then x else y) ≡ (if b then x' else y)\nite-cong₂ b y refl = refl\n\nite-cong₃ : ∀{ℓ}{A : Set ℓ} (b : 𝔹)(x : A){y y' : A} → y ≡ y' → (if b then x else y) ≡ (if b then x else y')\nite-cong₃ b x refl = refl\n\n&&-split : ∀ {b b' : 𝔹} → b || b' ≡ ff → b ≡ ff ⊎ b' ≡ ff\n&&-split {tt} ()\n&&-split {ff}{tt} ()\n&&-split {ff}{ff} p = inj₁ refl\n\n-----------------------------------\n-- Theorems about imp\n-----------------------------------\nimp-same : ∀ (b : 𝔹) → (b imp b) ≡ tt\nimp-same ff = refl\nimp-same tt = refl\n\nimp-to-|| : ∀ (b1 b2 : 𝔹) → (b1 imp b2) ≡ (~ b1 || b2)\nimp-to-|| ff _ = refl\nimp-to-|| tt _ = refl\n\nimp-mp : ∀ {b b' : 𝔹} → (b imp b') ≡ tt → b ≡ tt → b' ≡ tt \nimp-mp {tt} {tt} p refl = refl\nimp-mp {ff} {ff} p q = q\nimp-mp {tt} {ff} p q = p\nimp-mp {ff} {tt} p q = refl\n\nimp-antisymm : ∀ {b1 b2 : 𝔹} → (b1 imp b2) ≡ tt → (b2 imp b1) ≡ tt → b1 ≡ b2\nimp-antisymm{tt}{tt} p q = refl\nimp-antisymm{tt}{ff} () q \nimp-antisymm{ff}{tt} p ()\nimp-antisymm{ff}{ff} p q = refl\n\n-----------------------------------\n-- Theorems about xor\n-----------------------------------\nff-xor : ∀ (b : 𝔹) → ff xor b ≡ b\nff-xor tt = refl\nff-xor ff = refl\n\ntt-xor : ∀ (b : 𝔹) → tt xor b ≡ ~ b\ntt-xor tt = refl\ntt-xor ff = refl\n\n~-xor-distrb : ∀ (a b : 𝔹) → ~ (a xor b) ≡ ~ a xor b\n~-xor-distrb tt tt = refl\n~-xor-distrb tt ff = refl\n~-xor-distrb ff tt = refl\n~-xor-distrb ff ff = refl\n\nxor-distrib-&& : ∀ (x y : 𝔹) → x xor (y && x) ≡ ~ y && x\nxor-distrib-&& tt tt = refl\nxor-distrib-&& tt ff = refl\nxor-distrib-&& ff tt = refl\nxor-distrib-&& ff ff = refl\n\nxor~hop : ∀ (a b : 𝔹) → ~ a xor b ≡ a xor ~ b\nxor~hop tt tt = refl\nxor~hop tt ff = refl\nxor~hop ff tt = refl\nxor~hop ff ff = refl\n\nxor-comm : ∀ (b1 b2 : 𝔹) → b1 xor b2 ≡ b2 xor b1\nxor-comm tt tt = refl\nxor-comm tt ff = refl\nxor-comm ff tt = refl\nxor-comm ff ff = refl\n\nxor-assoc : (b1 b2 b3 : 𝔹) → b1 xor (b2 xor b3) ≡ (b1 xor b2) xor b3\nxor-assoc tt tt tt = refl\nxor-assoc tt tt ff = refl\nxor-assoc tt ff tt = refl\nxor-assoc tt ff ff = refl\nxor-assoc ff tt tt = refl\nxor-assoc ff tt ff = refl\nxor-assoc ff ff tt = refl\nxor-assoc ff ff ff = refl\n\nxor-anti-idem : (b : 𝔹) → b xor b ≡ ff\nxor-anti-idem tt = refl\nxor-anti-idem ff = refl\n\nxor-≡ : {b1 b2 : 𝔹} → b1 xor b2 ≡ ff → b1 ≡ b2\nxor-≡ {tt} {tt} p = refl\nxor-≡ {tt} {ff} ()\nxor-≡ {ff} {tt} ()\nxor-≡ {ff} {ff} p = refl\n\n-----------------------------------\n-- Theorems about nor, nand\n-----------------------------------\n\nnor-not : ∀ (b : 𝔹) → b nor b ≡ ~ b\nnor-not tt = refl\nnor-not ff = refl\n\nnor-or : ∀ (b1 b2 : 𝔹) → (b1 nor b2) nor (b1 nor b2) ≡ b1 || b2\nnor-or tt b2 = refl\nnor-or ff tt = refl\nnor-or ff ff = refl\n\nnor-and : ∀ (b1 b2 : 𝔹) → (b1 nor b1) nor (b2 nor b2) ≡ b1 && b2\nnor-and tt tt = refl\nnor-and tt ff = refl\nnor-and ff b2 = refl\n\nnor-comm : ∀ (b1 b2 : 𝔹) → b1 nor b2 ≡ b2 nor b1\nnor-comm tt tt = refl\nnor-comm tt ff = refl\nnor-comm ff tt = refl\nnor-comm ff ff = refl\n\nnand-comm : ∀ (b1 b2 : 𝔹) → b1 nand b2 ≡ b2 nand b1\nnand-comm tt tt = refl\nnand-comm tt ff = refl\nnand-comm ff tt = refl\nnand-comm ff ff = refl\n\n", "meta": {"hexsha": "56a1c69efe314da0a724848c7b13a671721ab9ce", "size": 6180, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "bool-thms2.agda", "max_stars_repo_name": "heades/AUGL", "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "bool-thms2.agda", "max_issues_repo_name": "heades/AUGL", "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "bool-thms2.agda", "max_forks_repo_name": "heades/AUGL", "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.1219512195, "max_line_length": 108, "alphanum_fraction": 0.4813915858, "num_tokens": 2905, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677430095497, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.6276439880718611}} {"text": "module Sets.IterativeSet.Oper where\n\nimport Lvl\nopen import Data\nopen import Data.Boolean\nopen import Data.Boolean.Stmt\nopen import Data.Either as Either using (_‖_)\nopen import Data.Tuple as Tuple using ()\nopen import Functional\nopen import Logic\nopen import Numeral.Natural\nopen import Relator.Equals using () renaming (_≡_ to Id ; [≡]-intro to intro)\nopen import Sets.IterativeSet\nopen import Syntax.Function\nopen import Type.Dependent\n\nmodule _ where\n private variable {ℓ ℓ₁ ℓ₂} : Lvl.Level\n open Iset\n\n -- The empty set, consisting of no elements.\n -- Index is the empty type, which means that there are no objects pointing to elements in the set.\n ∅ : Iset{ℓ}\n ∅ = set{Index = Empty} empty\n\n -- The singleton set, consisting of one element.\n -- Index is the unit type, which means that there are a single object pointing to a single element in the set.\n singleton : Iset{ℓ} → Iset{ℓ}\n singleton = set{Index = Unit} ∘ const\n\n -- The pair set, consisting of two elements.\n -- Index is the boolean type, which means that there are two objects pointing to two elements in the set.\n pair : Iset{ℓ} → Iset{ℓ} → Iset{ℓ}\n pair A B = set{Index = Lvl.Up(Bool)} ((if_then B else A) ∘ Lvl.Up.obj)\n\n -- The union operator.\n -- 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.\n _∪_ : Iset{ℓ} → Iset{ℓ} → Iset{ℓ}\n A ∪ B = set{Index = Index(A) ‖ Index(B)} (Either.map1 (elem(A)) (elem(B)))\n\n _,_ : Iset{ℓ} → Iset{ℓ} → Iset{ℓ}\n A , B = pair (singleton A) (pair A B)\n\n _⨯_ : Iset{ℓ} → Iset{ℓ} → Iset{ℓ}\n A ⨯ B = set{Index = Index(A) Tuple.⨯ Index(B)} \\{(ia Tuple., ib) → (elem(A)(ia) , elem(B)(ib))}\n\n -- The big union operator.\n -- Index(⋃ A) is the dependent sum type of an Index(A) and the index of the element this index points to.\n ⋃ : Iset{ℓ} → Iset{ℓ}\n ⋃ A = set{Index = Σ(Index(A)) (ia ↦ Index(elem(A)(ia)))} (\\{(intro ia i) → elem(elem(A)(ia))(i)})\n\n indexFilter : (A : Iset{ℓ}) → (Index(A) → Stmt{ℓ}) → Iset{ℓ}\n indexFilter A P = set{Index = Σ(Index(A)) P} (elem(A) ∘ Σ.left)\n\n filter : (A : Iset{ℓ}) → (Iset{ℓ} → Stmt{ℓ}) → Iset{ℓ}\n filter{ℓ} A P = indexFilter A (P ∘ elem(A))\n\n indexFilterBool : (A : Iset{ℓ}) → (Index(A) → Bool) → Iset{ℓ}\n indexFilterBool A f = indexFilter A (Lvl.Up ∘ IsTrue ∘ f)\n\n filterBool : (A : Iset{ℓ}) → (Iset{ℓ} → Bool) → Iset{ℓ}\n filterBool A f = indexFilterBool A (f ∘ elem(A))\n\n mapSet : (Iset{ℓ} → Iset{ℓ}) → (Iset{ℓ} → Iset{ℓ})\n mapSet f(A) = set{Index = Index(A)} (f ∘ elem(A))\n\n -- The power set operator.\n -- 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\".\n -- Note: This only works properly in a classical setting. Trying to use indexFilter instead result in universe level problems.\n ℘ : Iset{ℓ} → Iset{ℓ}\n ℘(A) = set{Index = Index(A) → Bool} (indexFilterBool A)\n\n -- The set of ordinal numbers of the first order.\n ω : Iset{ℓ}\n ω = set{Index = Lvl.Up ℕ} (N ∘ Lvl.Up.obj) where\n N : ℕ → Iset{ℓ}\n N(𝟎) = ∅\n N(𝐒(n)) = N(n) ∪ singleton(N(n))\n", "meta": {"hexsha": "2e9dedbb1f77dc92a93ea030e2d1ff432f1817db", "size": 3160, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Sets/IterativeSet/Oper.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Sets/IterativeSet/Oper.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Sets/IterativeSet/Oper.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.0, "max_line_length": 189, "alphanum_fraction": 0.6462025316, "num_tokens": 1111, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094032139577, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.6275767063115784}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Groups.Lemmas\nopen import Groups.Definition\nopen import Setoids.Orders.Partial.Definition\nopen import Setoids.Orders.Total.Definition\nopen import Setoids.Setoids\nopen import Functions.Definition\nopen import Sets.EquivalenceRelations\nopen import Rings.Definition\nopen import Rings.Orders.Total.Definition\nopen import Rings.Orders.Partial.Definition\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import Orders.Total.Definition\nopen import Rings.IntegralDomains.Definition\n\nmodule Rings.Orders.Total.AbsoluteValue {n m p : _} {A : Set n} {S : Setoid {n} {m} A} {_+_ : A → A → A} {_*_ : A → A → A} {R : Ring S _+_ _*_} {_<_ : Rel {_} {p} A} {pOrder : SetoidPartialOrder S _<_} {pOrderRing : PartiallyOrderedRing R pOrder} (order : TotallyOrderedRing pOrderRing) where\n\nopen Ring R\nopen Group additiveGroup\nopen Setoid S\nopen SetoidPartialOrder pOrder\nopen TotallyOrderedRing order\nopen SetoidTotalOrder total\nopen PartiallyOrderedRing pOrderRing\nopen import Rings.Lemmas R\nopen import Rings.Orders.Partial.Lemmas pOrderRing\nopen import Rings.Orders.Total.Lemmas order\n\nabs : A → A\nabs a with totality 0R a\nabs a | inl (inl 0_ to _>ᴺ_)\nopen import Data.Nat.Properties \nopen import Data.Integer renaming (_+_ to _+ᶻ_ ; _≤_ to _≤ᶻ_ ; _≥_ to _≥ᶻ_ ; _<_ to _<ᶻ_ ; _>_ to _>ᶻ_)\nimport Data.Integer.Properties\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary\nopen import Relation.Nullary.Negation\nopen import Data.Product\nopen import Data.Sum\n\n\n-- natural numbers\n\nn≢m⇒sucn≢sucm : {n m : ℕ} → n ≢ m → ℕ.suc n ≢ ℕ.suc m\nn≢m⇒sucn≢sucm {n} {m} neq = λ x → contradiction (cong Data.Nat.pred x) neq\n\nsucn≢sucm⇒n≢m : {n m : ℕ} → ℕ.suc n ≢ ℕ.suc m → n ≢ m\nsucn≢sucm⇒n≢m {n} {m} neq = λ x → contradiction (cong ℕ.suc x) neq\n\nn+1≡sucn : {n : ℕ} → n +ᴺ 1 ≡ ℕ.suc n\nn+1≡sucn {zero} = refl\nn+1≡sucn {ℕ.suc n} = cong ℕ.suc (n+1≡sucn{n})\n\nn≤sucn : {n : ℕ} → n ≤ᴺ ℕ.suc n\nn≤sucn {zero} = z≤n\nn≤sucn {ℕ.suc n} = s≤s n≤sucn\n\nn nle))\n\nn+m≤n+q+m : {n m q : ℕ} → n +ᴺ m ≤ᴺ n +ᴺ (q +ᴺ m)\nn+m≤n+q+m {n} {m} {q} rewrite (+-comm q m) | (sym (+-assoc n m q)) = m≤m+n (n +ᴺ m) q\n\nm>n⇒m∸n≥1 : {m n : ℕ} → n <ᴺ m → m ∸ n ≥ᴺ 1\nm>n⇒m∸n≥1 {ℕ.suc m} {zero} le = s≤s z≤n\nm>n⇒m∸n≥1 {ℕ.suc m} {ℕ.suc n} (s≤s le) = m>n⇒m∸n≥1 le\n\nm∸n≥q⇒m≥q : {m n q : ℕ} → m ∸ n ≥ᴺ q → m ≥ᴺ q\nm∸n≥q⇒m≥q {m} {n} {q} ge = ≤-trans ge (m∸n≤m m n)\n\n\n-- lists & length\n\n++-assoc : {a : Level} {s : Set a} {Δ ∇ Γ : List s} → ((Δ ++ ∇) ++ Γ) ≡ (Δ ++ (∇ ++ Γ))\n++-assoc {a} {s} {[]} {∇} {Γ} = refl\n++-assoc {a} {s} {x ∷ Δ} {∇} {Γ} = cong (_∷_ x) (++-assoc{a}{s}{Δ}{∇}{Γ})\n\nlength[A]≥0 : {a : Level} {s : Set a} {A : List s} → length A ≥ᴺ 0\nlength[A]≥0 {a} {s} {A} = z≤n\n\nA++[]≡A : {a : Level} {s : Set a} {A : List s} → A ++ [] ≡ A\nA++[]≡A {a} {s} {[]} = refl\nA++[]≡A {a} {s} {x ∷ A} = cong (_∷_ x) (A++[]≡A {a} {s} {A})\n\nn+length[]≡n : {a : Level} {A : Set a} {n : ℕ} → n +ᴺ length{a}{A} [] ≡ n\nn+length[]≡n {a} {A} {zero} = refl\nn+length[]≡n {a} {A} {ℕ.suc n} = cong ℕ.suc (n+length[]≡n{a}{A})\n\nlength[A∷B]≡suc[length[B]] : {a : Level} {s : Set a} {A : s} {B : List s} → length (A ∷ B) ≡ ℕ.suc (length B)\nlength[A∷B]≡suc[length[B]] {a} {s} {A} {B} = refl\n\nlength[A∷B]≥1 : {a : Level} {s : Set a} {A : s} {B : List s} → length (A ∷ B) ≥ᴺ 1\nlength[A∷B]≥1 {a} {s} {A} {B} = s≤s z≤n\n\nlength[A++B]≡length[A]+length[B] : {a : Level} {s : Set a} {A B : List s} → length (A ++ B) ≡ length A +ᴺ length B\nlength[A++B]≡length[A]+length[B] {a} {s} {[]} {B} = refl\nlength[A++B]≡length[A]+length[B] {a} {s} {x ∷ A} {B} rewrite length[A∷B]≡suc[length[B]]{a}{s}{x}{A ++ B} = cong ℕ.suc (length[A++B]≡length[A]+length[B]{a}{s}{A}{B})\n\nlength[A++B∷[]]≡suc[length[A]] : {a : Level} {s : Set a} {A : List s} {B : s} → length (A ++ B ∷ []) ≡ ℕ.suc (length A)\nlength[A++B∷[]]≡suc[length[A]] {a} {s} {A} {B} rewrite (length[A++B]≡length[A]+length[B]{a}{s}{A}{B ∷ []}) = n+1≡sucn\n\nA++B∷[]++C≡A++B∷C : {a : Level} {s : Set a} {A C : List s} {B : s} → ((A ++ B ∷ []) ++ C) ≡ (A ++ B ∷ C)\nA++B∷[]++C≡A++B∷C {a} {s} {[]} {C} {B} = refl\nA++B∷[]++C≡A++B∷C {a} {s} {x ∷ A} {C} {B} = cong (_∷_ x) A++B∷[]++C≡A++B∷C\n\nA++B++D∷[]++C≡A++B++D∷C : {a : Level} {s : Set a} { A B C : List s} {D : s} → (A ++ B ++ D ∷ []) ++ C ≡ (A ++ B ++ D ∷ C)\nA++B++D∷[]++C≡A++B++D∷C {a} {s} {[]} {B} {C} {D} = A++B∷[]++C≡A++B∷C\nA++B++D∷[]++C≡A++B++D∷C {a} {s} {x ∷ A} {B} {C} {D} = cong (_∷_ x) (A++B++D∷[]++C≡A++B++D∷C{a}{s}{A}{B}{C}{D})\n\n-- integers\n\nm≥0⇒n+m≥0 : {n : ℕ} {m : ℤ} → m ≥ᶻ +0 → + n +ᶻ m ≥ᶻ +0\nm≥0⇒n+m≥0 {n} {+_ m} ge = +≤+ z≤n\n\nn>0⇒n>∣n⊖1∣ : {n : ℕ} → n ≥ᴺ 1 → n >ᴺ ∣ n ⊖ 1 ∣\nn>0⇒n>∣n⊖1∣ {.(ℕ.suc _)} (s≤s le) = n0⇒∣n+m∣>n : {n : ℕ} {m : ℤ} → m >ᶻ +0 → ∣ +_ n +ᶻ m ∣ >ᴺ n \nm>0⇒∣n+m∣>n {n} {(+ m)} (+<+ mn⇒m∸n≥1 lt))\n | (sym (+-∸-comm {y ∸ x} x {1} (m>n⇒m∸n≥1 lt)))\n | (m∸n+n≡m {y} {x} (sucn≤m⇒n≤m lt))\n | (Data.Integer.Properties.⊖-≥{y}{1} ((m∸n≥q⇒m≥q{y}{x} (m>n⇒m∸n≥1{y}{x} lt))))\n = refl\n\nk≥0⇒∣+x+k∣≡x+k : {x k : ℕ} → ∣ + x +ᶻ + k ∣ ≡ x +ᴺ k\nk≥0⇒∣+x+k∣≡x+k {x} {k} = refl\n\n\n-- products & sums\n\n-- deMorgan on products and sums\ndm1 : {P Q : Set} → (¬ P × ¬ Q) → ¬ (P ⊎ Q)\ndm1 {P} {Q} (fst , snd) (inj₁ x) = contradiction x fst\ndm1 {P} {Q} (fst , snd) (inj₂ y) = contradiction y snd\n\ndm2 : {P Q : Set} → ¬ (P ⊎ Q) → (¬ P × ¬ Q)\ndm2 {P} {Q} d = (λ x → contradiction (inj₁ x) d) , λ x → contradiction (inj₂ x) d\n", "meta": {"hexsha": "8f0a03dd516775163e440eaf64e9c999e3366301", "size": 7247, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/llc/Auxiliary.agda", "max_stars_repo_name": "kcaliban/ldlc", "max_stars_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/llc/Auxiliary.agda", "max_issues_repo_name": "kcaliban/ldlc", "max_issues_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/llc/Auxiliary.agda", "max_forks_repo_name": "kcaliban/ldlc", "max_forks_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-14T17:52:29.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-14T17:52:29.000Z", "avg_line_length": 37.3556701031, "max_line_length": 164, "alphanum_fraction": 0.4459776459, "num_tokens": 4716, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8807970842359876, "lm_q2_score": 0.7122321903471565, "lm_q1q2_score": 0.6273320365567863}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Relation.Binary.Base where\n\nopen import Cubical.Core.Everything\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function using (_on_)\nopen import Cubical.Foundations.HLevels\n\nopen import Cubical.Classes using (Cast; [_]) public\n\nprivate\n variable\n a b ℓ : Level\n A : Type a\n B : Type b\n\nRawREL : Type a → Type b → (ℓ : Level) → Type _\nRawREL A B ℓ = A → B → Type ℓ\n\nRawRel : Type a → (ℓ : Level) → Type _\nRawRel A ℓ = RawREL A A ℓ\n\n\nREL : Type a → Type b → (ℓ : Level) → Type _\nREL A B ℓ = A → B → hProp ℓ\n\nRel : Type a → (ℓ : Level) → Type _\nRel A ℓ = REL A A ℓ\n\n\nisPropValued : RawREL A B ℓ → Type _\nisPropValued R = ∀ a b → isProp (R a b)\n\n\ninstance\n RelCast : Cast (REL A B ℓ) (RawREL A B ℓ)\n RelCast = record { cast = λ R a b → R a b .fst }\n\nisProp[_] : (R : REL A B ℓ) → isPropValued [ R ]\nisProp[ R ] a b = R a b .snd\n\nfromRaw : (R : RawREL A B ℓ) → isPropValued R → REL A B ℓ\nfromRaw R isPropR a b .fst = R a b\nfromRaw R isPropR a b .snd = isPropR a b\n", "meta": {"hexsha": "130caa516b59267666f27e043625c5499b650efe", "size": 1063, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Relation/Binary/Base.agda", "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Relation/Binary/Base.agda", "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Relation/Binary/Base.agda", "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.1086956522, "max_line_length": 57, "alphanum_fraction": 0.6387582314, "num_tokens": 386, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8807970873650401, "lm_q2_score": 0.7122321720225278, "lm_q1q2_score": 0.6273320226451187}} {"text": "module Numeral.Sign.Oper0 where\n\nopen import Numeral.Sign\n\n-- Negation\n−_ : (+|0|−) → (+|0|−)\n− (➕) = (➖)\n− (𝟎) = (𝟎)\n− (➖) = (➕)\n\n-- Bounded addition\n_+_ : (+|0|−) → (+|0|−) → (+|0|−)\n(➕) + (➕) = (➕)\n(➕) + (➖) = (𝟎)\n(➕) + (𝟎) = (➕)\n(➖) + (➕) = (𝟎)\n(➖) + (➖) = (➖)\n(➖) + (𝟎) = (➖)\n(𝟎) + (➕) = (➕)\n(𝟎) + (➖) = (➖)\n(𝟎) + (𝟎) = (𝟎)\n\n-- Multiplication\n_⨯_ : (+|0|−) → (+|0|−) → (+|0|−)\n(➕) ⨯ (➕) = (➕)\n(➕) ⨯ (➖) = (➖)\n(➕) ⨯ (𝟎) = (𝟎)\n(➖) ⨯ (➕) = (➖)\n(➖) ⨯ (➖) = (➕)\n(➖) ⨯ (𝟎) = (𝟎)\n(𝟎) ⨯ (➕) = (𝟎)\n(𝟎) ⨯ (➖) = (𝟎)\n(𝟎) ⨯ (𝟎) = (𝟎)\n\n_⋚_ : (+|0|−) → (+|0|−) → (+|0|−)\n➕ ⋚ 𝟎 = ➕\n➕ ⋚ ➖ = ➕\n𝟎 ⋚ ➖ = ➕\n➕ ⋚ ➕ = 𝟎\n𝟎 ⋚ 𝟎 = 𝟎\n➖ ⋚ ➖ = 𝟎\n𝟎 ⋚ ➕ = ➖\n➖ ⋚ ➕ = ➖\n➖ ⋚ 𝟎 = ➖\n", "meta": {"hexsha": "9da8accdcdafe2bd3a878bcf308c71f8b9ba0ca7", "size": 651, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Sign/Oper0.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Sign/Oper0.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Sign/Oper0.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 14.4666666667, "max_line_length": 33, "alphanum_fraction": 0.2058371736, "num_tokens": 555, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9525741227833249, "lm_q2_score": 0.6584174871563662, "lm_q1q2_score": 0.6271914602531766}} {"text": "------------------------------------------------------------------------------\n-- First-order logic\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOL.README where\n\n------------------------------------------------------------------------------\n-- Description\n\n-- Formalization of first-order logic using Agda's inductive notions.\n\n------------------------------------------------------------------------------\n-- Definition of the connectives and quantifiers\nopen import FOL.Base\n\n-- Propositional logic theorems\nopen import FOL.ExclusiveDisjunction.TheoremsATP\nopen import FOL.ExclusiveDisjunction.TheoremsI\nopen import FOL.PropositionalLogic.TheoremsATP\nopen import FOL.PropositionalLogic.TheoremsI\n\n-- First-order logic theorems\nopen import FOL.TheoremsATP\nopen import FOL.TheoremsI\n\n-- Logical schemata\nopen import FOL.SchemataATP\n\n-- Non-empty domains\nopen import FOL.NonEmptyDomain.TheoremsATP\nopen import FOL.NonEmptyDomain.TheoremsI\n\n-- Non-intuitionistic logic theorems\nopen import FOL.NonIntuitionistic.TheoremsATP\nopen import FOL.NonIntuitionistic.TheoremsI\n", "meta": {"hexsha": "05e3d8a76afbd7abe5a8df9066711549f0d60e52", "size": 1282, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/FOL/README.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/FOL/README.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/FOL/README.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 31.2682926829, "max_line_length": 78, "alphanum_fraction": 0.5772230889, "num_tokens": 257, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8615382165412809, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.6271786648517798}} {"text": "{-# OPTIONS --without-K #-}\nmodule NTypes.Id where\n\nopen import GroupoidStructure\nopen import NTypes\nopen import PathOperations\nopen import Transport\nopen import Types\n\n-- This should also be derivable from hLevel-suc from\n-- HomotopyTypes.HLevel module.\nId-isSet : ∀ {a} {A : Set a} {x y : A} →\n isSet A → isSet (x ≡ y)\nId-isSet {x = x} {y = y} A-set _ _ pp qq\n = path pp ⁻¹ · path qq\n where\n split-path : {p q : x ≡ y} (pp : p ≡ q) →\n A-set _ _ p q ≡ pp · A-set _ _ q q\n split-path pp = J\n (λ p q pp → A-set _ _ p q ≡ pp · A-set _ _ q q)\n (λ _ → refl) _ _ pp\n\n path : {p q : x ≡ y} (pp : p ≡ q) →\n A-set _ _ p q ≡ pp\n path pp = J\n (λ p q pp → A-set _ _ p q ≡ pp)\n (λ p → split-path (A-set _ _ p p ⁻¹) · p⁻¹·p (A-set _ _ p p))\n _ _ pp\n\n-- From the lectures.\nId-isSet-alt : ∀ {a} {A : Set a} {u v : A} →\n isSet A → isSet (u ≡ v)\nId-isSet-alt {u = u} {v = v} H r s α β\n = id·p α ⁻¹\n · ap (λ z → z · α)\n (p⁻¹·p (H′ r)) ⁻¹\n · p·q·r (H′ r ⁻¹) (H′ r) α ⁻¹\n · ap (λ z → H′ r ⁻¹ · z)\n ( tr-post r α (H′ r) ⁻¹\n · apd H′ α\n · apd H′ β ⁻¹\n · tr-post r β (H′ r)\n )\n · p·q·r (H′ r ⁻¹) (H′ r) β\n · ap (λ z → z · β)\n (p⁻¹·p (H′ r))\n · id·p β\n where\n H′ = λ q → H u v r q\n", "meta": {"hexsha": "39dc0ce27cad3f60eb441c1dc187d82f27a55275", "size": 1218, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/NTypes/Id.agda", "max_stars_repo_name": "vituscze/HoTT-lectures", "max_stars_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/NTypes/Id.agda", "max_issues_repo_name": "vituscze/HoTT-lectures", "max_issues_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/NTypes/Id.agda", "max_forks_repo_name": "vituscze/HoTT-lectures", "max_forks_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.36, "max_line_length": 65, "alphanum_fraction": 0.4917898194, "num_tokens": 561, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8652240791017536, "lm_q2_score": 0.7248702702332476, "lm_q1q2_score": 0.6271752120308008}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Homotopy.HSpace where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Pointed\nopen import Cubical.Foundations.HLevels\nopen import Cubical.HITs.S1\nopen import Cubical.HITs.Sn\n\nrecord HSpace {ℓ : Level} (A : Pointed ℓ) : Type ℓ where\n constructor HSp\n field\n μ : typ A → typ A → typ A\n μₗ : (x : typ A) → μ (pt A) x ≡ x\n μᵣ : (x : typ A) → μ x (pt A) ≡ x\n μₗᵣ : μₗ (pt A) ≡ μᵣ (pt A)\n\nrecord AssocHSpace {ℓ : Level} {A : Pointed ℓ} (e : HSpace A) : Type ℓ where\n constructor AssocHSp\n field\n μ-assoc : (x y z : _)\n → HSpace.μ e (HSpace.μ e x y) z ≡ HSpace.μ e x (HSpace.μ e y z)\n\n μ-assoc-filler : (y z : typ A)\n → PathP (λ i → HSpace.μ e (HSpace.μₗ e y i) z\n ≡ HSpace.μₗ e (HSpace.μ e y z) i)\n (μ-assoc (pt A) y z)\n refl\n\n-- Instances\nopen HSpace\nopen AssocHSpace\n\n-- S¹\nS1-HSpace : HSpace (S₊∙ 1)\nμ S1-HSpace = _·_\nμₗ S1-HSpace x = refl\nμᵣ S1-HSpace base = refl\nμᵣ S1-HSpace (loop i) = refl\nμₗᵣ S1-HSpace x = refl\n\nS1-AssocHSpace : AssocHSpace S1-HSpace\nμ-assoc S1-AssocHSpace base _ _ = refl\nμ-assoc S1-AssocHSpace (loop i) x y j = h x y j i\n where\n h : (x y : S₊ 1) → cong (_· y) (rotLoop x) ≡ rotLoop (x · y)\n h = wedgeconFun _ _ (λ _ _ → isOfHLevelPath 2 (isGroupoidS¹ _ _) _ _)\n (λ x → refl)\n (λ { base → refl ; (loop i) → refl})\n refl\nμ-assoc-filler S1-AssocHSpace _ _ = refl\n", "meta": {"hexsha": "055f37e2acfcc13cc6f5fffb3fad03475d26befe", "size": 1448, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Homotopy/HSpace.agda", "max_stars_repo_name": "FernandoLarrain/cubical", "max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z", "max_issues_repo_path": "Cubical/Homotopy/HSpace.agda", "max_issues_repo_name": "Seanpm2001-web/cubical", "max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Homotopy/HSpace.agda", "max_forks_repo_name": "Seanpm2001-web/cubical", "max_forks_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.8461538462, "max_line_length": 76, "alphanum_fraction": 0.5994475138, "num_tokens": 594, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8652240756264639, "lm_q2_score": 0.7248702702332476, "lm_q1q2_score": 0.6271752095116667}} {"text": "{-# OPTIONS --cubical #-}\n\nopen import Agda.Primitive.Cubical\n\npostulate\n Id : ∀ {ℓ} {A : Set ℓ} → A → A → Set ℓ\n Path : ∀ {ℓ} {A : Set ℓ} → A → A → Set ℓ\n PathP : ∀ {ℓ} (A : I → Set ℓ) → A i0 → A i1 → Set ℓ\n\n{-# BUILTIN PATH Path #-}\n{-# BUILTIN PATHP PathP #-}\n{-# BUILTIN ID Id #-}\n{-# BUILTIN CONID conid #-}\n\nreflPath : ∀ {ℓ} {A : Set ℓ} {x : A} → Path x x\nreflPath {x = x} = λ i → x\n\nreflId : ∀ {ℓ} {A : Set ℓ} {x : A} → Id x x\nreflId {x = x} = conid i1 reflPath\n\nprimitive\n primIdJ : ∀ {ℓ ℓ'} {A : Set ℓ} {x : A} (P : ∀ y → Id x y → Set ℓ')\n → P x reflId → {y : A} (p : Id x y) → P y p\n\nId-comp-Id : ∀ {ℓ ℓ'} {A : Set ℓ} {x : A} (P : ∀ y → Id x y → Set ℓ')\n → (b : P x reflId) → Id (primIdJ P b reflId) b\nId-comp-Id P b = reflId\n\nId-comp-Path : ∀ {ℓ ℓ'} {A : Set ℓ} {x : A} (P : ∀ y → Id x y → Set ℓ')\n → (b : P x reflId) → Path (primIdJ P b reflId) b\nId-comp-Path P b = λ i → b\n", "meta": {"hexsha": "2a26d0a83e1c1a200f2a71afc9c76c1d6d99ae33", "size": 951, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue2846.agda", "max_stars_repo_name": "asr/eagda", "max_stars_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_issues_repo_path": "test/Succeed/Issue2846.agda", "max_issues_repo_name": "asr/eagda", "max_issues_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/Issue2846.agda", "max_forks_repo_name": "asr/eagda", "max_forks_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 29.71875, "max_line_length": 71, "alphanum_fraction": 0.4595162986, "num_tokens": 428, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.865224068675884, "lm_q2_score": 0.7248702702332476, "lm_q1q2_score": 0.6271752044733979}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import lib.Basics\nopen import lib.Equivalences2\nopen import lib.NType2\nopen import lib.types.Group\nopen import lib.types.Pi\nopen import lib.types.Sigma\nopen import lib.types.Truncation\n\nmodule lib.groups.Homomorphisms where\n\nrecord GroupHom {i j} (G : Group i) (H : Group j)\n : Type (lsucc (lmax i j)) where\n constructor group-hom\n\n field\n f : Group.El G → Group.El H\n pres-comp : ∀ g1 g2 → f (Group.comp G g1 g2) == Group.comp H (f g1) (f g2)\n\n abstract\n pres-ident : f (Group.ident G) == Group.ident H\n pres-ident = group-cancel-l H (f (Group.ident G)) $\n Group.comp H (f (Group.ident G)) (f (Group.ident G))\n =⟨ ! (pres-comp (Group.ident G) (Group.ident G)) ⟩\n f (Group.comp G (Group.ident G) (Group.ident G))\n =⟨ ap f (Group.unitl G (Group.ident G)) ⟩\n f (Group.ident G)\n =⟨ ! (Group.unitr H (f (Group.ident G))) ⟩\n Group.comp H (f (Group.ident G)) (Group.ident H) ∎\n\n pres-inv : (g : Group.El G) → f (Group.inv G g) == Group.inv H (f g)\n pres-inv g =\n f (Group.inv G g)\n =⟨ ! (Group.unitr H (f (Group.inv G g))) ⟩\n Group.comp H (f (Group.inv G g)) (Group.ident H)\n =⟨ ! (Group.invr H (f g))\n |in-ctx (λ w → Group.comp H (f (Group.inv G g)) w) ⟩\n Group.comp H (f (Group.inv G g)) (Group.comp H (f g) (Group.inv H (f g)))\n =⟨ ! (Group.assoc H (f (Group.inv G g)) (f g) (Group.inv H (f g))) ⟩\n Group.comp H (Group.comp H (f (Group.inv G g)) (f g)) (Group.inv H (f g))\n =⟨ ! (pres-comp (Group.inv G g) g) ∙ ap f (Group.invl G g) ∙ pres-ident\n |in-ctx (λ w → Group.comp H w (Group.inv H (f g))) ⟩\n Group.comp H (Group.ident H) (Group.inv H (f g))\n =⟨ Group.unitl H (Group.inv H (f g)) ⟩\n Group.inv H (f g) ∎\n\n ⊙f : Σ (Group.El G → Group.El H)\n (λ f → f (Group.ident G) == Group.ident H)\n ⊙f = (f , pres-ident)\n\ninfix 0 _→ᴳ_\n_→ᴳ_ = GroupHom\n\nGroupIso : ∀ {i j} (G : Group i) (H : Group j) → Type (lsucc (lmax i j))\nGroupIso G H = Σ (G →ᴳ H) (λ φ → is-equiv (GroupHom.f φ))\n\ninfix 30 _≃ᴳ_\n_≃ᴳ_ = GroupIso\n\nidhom : ∀ {i} (G : Group i) → (G →ᴳ G)\nidhom G = group-hom (idf _) (λ _ _ → idp)\n\nidiso : ∀ {i} (G : Group i) → (G ≃ᴳ G)\nidiso G = (idhom G , idf-is-equiv _)\n\ninfixr 80 _∘ᴳ_\n\n_∘ᴳ_ : ∀ {i j k} {G : Group i} {H : Group j} {K : Group k}\n → (H →ᴳ K) → (G →ᴳ H) → (G →ᴳ K)\n(group-hom g g-comp) ∘ᴳ (group-hom f f-comp) =\n record {\n f = g ∘ f;\n pres-comp = λ x₁ x₂ → ap g (f-comp x₁ x₂) ∙ g-comp (f x₁) (f x₂)}\n\ninfixr 80 _∘eᴳ_\n\n_∘eᴳ_ : ∀ {i j k} {G : Group i} {H : Group j} {K : Group k}\n → H ≃ᴳ K → G ≃ᴳ H → G ≃ᴳ K\n(φ₂ , ie₂) ∘eᴳ (φ₁ , ie₁) = (φ₂ ∘ᴳ φ₁ , ie₂ ∘ise ie₁)\n\ninfixl 120 _⁻¹ᴳ\n\n_⁻¹ᴳ : ∀ {i j} {G : Group i} {H : Group j} → G ≃ᴳ H → H ≃ᴳ G\n_⁻¹ᴳ {G = G} {H = H} (φ , ie) =\n (record {\n f = is-equiv.g ie;\n pres-comp = λ h₁ h₂ →\n ap2 (λ w₁ w₂ → is-equiv.g ie (Group.comp H w₁ w₂))\n (! (is-equiv.f-g ie h₁)) (! (is-equiv.f-g ie h₂))\n ∙ ! (ap (is-equiv.g ie)\n (GroupHom.pres-comp φ (is-equiv.g ie h₁) (is-equiv.g ie h₂)))\n ∙ is-equiv.g-f ie (Group.comp G (is-equiv.g ie h₁) (is-equiv.g ie h₂))} ,\n snd ((_ , ie) ⁻¹))\n\n{- a homomorphism which is an equivalence gives a path between groups -}\nmodule _ {i} {G H : Group i} (iso : G ≃ᴳ H) where\n private\n module G = Group G\n module H = Group H\n module φ = GroupHom (fst iso)\n ie = snd iso\n\n private\n ap3-lemma : ∀ {i j k l} {C : Type i} {D : C → Type j} {E : C → Type k}\n {F : Type l} {c₁ c₂ : C} {d₁ : D c₁} {d₂ : D c₂} {e₁ : E c₁} {e₂ : E c₂}\n (f : (c : C) → D c → E c → F) (p : c₁ == c₂)\n → (d₁ == d₂ [ D ↓ p ]) → (e₁ == e₂ [ E ↓ p ])\n → (f c₁ d₁ e₁ == f c₂ d₂ e₂)\n ap3-lemma f idp idp idp = idp\n\n ap3-lemma-el : ∀ {i} {G H : Group i}\n (p : Group.El G == Group.El H)\n (q : Group.El-level G == Group.El-level H [ _ ↓ p ])\n (r : Group.group-struct G == Group.group-struct H [ _ ↓ p ])\n → ap Group.El (ap3-lemma group p q r) == p\n ap3-lemma-el idp idp idp = idp\n\n abstract\n group-ua : G == H\n group-ua =\n ap3-lemma group\n (ua (φ.f , ie))\n (prop-has-all-paths-↓ has-level-is-prop)\n (↓-group-structure= (G.El-level) (ua (φ.f , ie)) ident= inv= comp=)\n where\n ident= : G.ident == H.ident [ (λ C → C) ↓ ua (φ.f , ie) ]\n ident= = ↓-idf-ua-in _ φ.pres-ident\n\n inv= : G.inv == H.inv [ (λ C → C → C) ↓ ua (φ.f , ie) ]\n inv= =\n ↓-→-from-transp $ λ= $ λ a →\n transport (λ C → C) (ua (φ.f , ie)) (G.inv a)\n =⟨ to-transp (↓-idf-ua-in _ idp) ⟩\n φ.f (G.inv a)\n =⟨ φ.pres-inv a ⟩\n H.inv (φ.f a)\n =⟨ ap H.inv (! (to-transp (↓-idf-ua-in _ idp))) ⟩\n H.inv (transport (λ C → C) (ua (φ.f , ie)) a) ∎\n\n comp=' : (a : G.El)\n → G.comp a == H.comp (φ.f a) [ (λ C → C → C) ↓ ua (φ.f , ie) ]\n comp=' a =\n ↓-→-from-transp $ λ= $ λ b →\n transport (λ C → C) (ua (φ.f , ie)) (G.comp a b)\n =⟨ to-transp (↓-idf-ua-in _ idp) ⟩\n φ.f (G.comp a b)\n =⟨ φ.pres-comp a b ⟩\n H.comp (φ.f a) (φ.f b)\n =⟨ ! (to-transp (↓-idf-ua-in _ idp))\n |in-ctx (λ w → H.comp (φ.f a) w) ⟩\n H.comp (φ.f a) (transport (λ C → C) (ua (φ.f , ie)) b) ∎\n\n comp= : G.comp == H.comp [ (λ C → C → C → C) ↓ ua (φ.f , ie) ]\n comp= =\n ↓-→-from-transp $ λ= $ λ a →\n transport (λ C → C → C) (ua (φ.f , ie)) (G.comp a)\n =⟨ to-transp (comp=' a) ⟩\n H.comp (φ.f a)\n =⟨ ! (to-transp (↓-idf-ua-in _ idp)) |in-ctx (λ w → H.comp w) ⟩\n H.comp (transport (λ C → C) (ua (φ.f , ie)) a) ∎\n\n group-ua-el : ap Group.El group-ua == ua (φ.f , ie)\n group-ua-el = ap3-lemma-el (ua (φ.f , ie)) _ _\n\n{- equality of homomorphisms -}\nabstract\n hom= : ∀ {i j} {G : Group i} {H : Group j} (φ ψ : (G →ᴳ H))\n → GroupHom.f φ == GroupHom.f ψ → φ == ψ\n hom= {H = H} _ _ p =\n ap (uncurry group-hom)\n (pair= p (prop-has-all-paths-↓\n (Π-level (λ _ → Π-level (λ _ → Group.El-level H _ _)))))\n\n hom=-↓ : ∀ {i j k} {A : Type i} {G : A → Group j} {H : A → Group k} {x y : A}\n {p : x == y} (φ : G x →ᴳ H x) (ψ : G y →ᴳ H y)\n → GroupHom.f φ == GroupHom.f ψ\n [ (λ a → Group.El (G a) → Group.El (H a)) ↓ p ]\n → φ == ψ [ (λ a → G a →ᴳ H a) ↓ p ]\n hom=-↓ {p = idp} = hom=\n\n{- homomorphism from equality of groups -}\ncoeᴳ : ∀ {i} {G H : Group i} → G == H → (G →ᴳ H)\ncoeᴳ idp = idhom _\n\ncoe!ᴳ : ∀ {i} {G H : Group i} → G == H → (H →ᴳ G)\ncoe!ᴳ idp = idhom _\n\ncoeᴳ-fun : ∀ {i} {G H : Group i} (p : G == H)\n → GroupHom.f (coeᴳ p) == coe (ap Group.El p)\ncoeᴳ-fun idp = idp\n\ncoe!ᴳ-fun : ∀ {i} {G H : Group i} (p : G == H)\n → GroupHom.f (coe!ᴳ p) == coe! (ap Group.El p)\ncoe!ᴳ-fun idp = idp\n\ncoeᴳ-β : ∀ {i} {G H : Group i} (iso : G ≃ᴳ H)\n → coeᴳ (group-ua iso) == fst iso\ncoeᴳ-β (φ , ie) = hom= _ _ $\n coeᴳ-fun (group-ua (φ , ie))\n ∙ ap coe (group-ua-el (φ , ie))\n ∙ λ= (coe-β (GroupHom.f φ , ie))\n\n{- algebraic properties -}\n\n∘ᴳ-unit-r : ∀ {i j} {G : Group i} {H : Group j} (φ : G →ᴳ H)\n → φ ∘ᴳ idhom G == φ\n∘ᴳ-unit-r φ = idp\n\n∘ᴳ-unit-l : ∀ {i j} {G : Group i} {H : Group j} (φ : G →ᴳ H)\n → idhom H ∘ᴳ φ == φ\n∘ᴳ-unit-l φ = hom= _ _ $ idp\n\n∘ᴳ-assoc : ∀ {i j k l} {G : Group i} {H : Group j} {K : Group k} {L : Group l}\n (χ : K →ᴳ L) (ψ : H →ᴳ K) (φ : G →ᴳ H)\n → (χ ∘ᴳ ψ) ∘ᴳ φ == χ ∘ᴳ ψ ∘ᴳ φ\n∘ᴳ-assoc χ ψ φ = hom= _ _ $ idp\n\n{- homomorphism with kernel zero is injective -}\nmodule _ {i j} {G : Group i} {H : Group j} (φ : (G →ᴳ H)) where\n\n private\n module G = Group G\n module H = Group H\n module φ = GroupHom φ\n\n zero-kernel-injective : ((g : G.El) → φ.f g == H.ident → g == G.ident)\n → ((g₁ g₂ : G.El) → φ.f g₁ == φ.f g₂ → g₁ == g₂)\n zero-kernel-injective f g₁ g₂ p =\n ! (group-inv-inv G g₁) ∙ group-inv-unique-r G (G.inv g₁) g₂ (f _ $\n φ.f (G.comp (G.inv g₁) g₂)\n =⟨ φ.pres-comp (G.inv g₁) g₂ ⟩\n H.comp (φ.f (G.inv g₁)) (φ.f g₂)\n =⟨ φ.pres-inv g₁ |in-ctx (λ w → H.comp w (φ.f g₂)) ⟩\n H.comp (H.inv (φ.f g₁)) (φ.f g₂)\n =⟨ p |in-ctx (λ w → H.comp (H.inv w) (φ.f g₂)) ⟩\n H.comp (H.inv (φ.f g₂)) (φ.f g₂)\n =⟨ H.invl (φ.f g₂) ⟩\n H.ident ∎)\n\n{- constant homomorphism -}\nmodule _ where\n cst-hom : ∀ {i j} {G : Group i} {H : Group j} → (G →ᴳ H)\n cst-hom {H = H} = group-hom (cst ident) (λ _ _ → ! (unitl _))\n where open Group H\n\n pre∘-cst-hom : ∀ {i j k} {G : Group i} {H : Group j} {K : Group k}\n (φ : H →ᴳ K)\n → φ ∘ᴳ cst-hom {G = G} {H = H} == cst-hom\n pre∘-cst-hom φ = hom= _ _ (λ= (λ g → GroupHom.pres-ident φ))\n\n{- if an injective homomorphism is merely surjective, then it is\n - fully surjective -}\nmodule _ {i j} {G : Group i} {H : Group j} (φ : G →ᴳ H) where\n\n private\n module G = Group G\n module H = Group H\n module φ = GroupHom φ\n\n module _ (inj : (g₁ g₂ : G.El) → φ.f g₁ == φ.f g₂ → g₁ == g₂)\n (msurj : (h : H.El) → Trunc -1 (Σ G.El (λ g → φ.f g == h))) where\n\n\n{- a surjective and injective homomorphism is an isomorphism -}\nmodule _ {i j} {G : Group i} {H : Group j} (φ : G →ᴳ H) where\n\n private\n module G = Group G\n module H = Group H\n module φ = GroupHom φ\n\n module _ (inj : (g₁ g₂ : G.El) → φ.f g₁ == φ.f g₂ → g₁ == g₂)\n (surj : (h : H.El) → Trunc -1 (Σ G.El (λ g → φ.f g == h))) where\n\n private\n image-prop : (h : H.El) → is-prop (Σ G.El (λ g → φ.f g == h))\n image-prop h = all-paths-is-prop $ λ {(g₁ , p₁) (g₂ , p₂) →\n pair= (inj g₁ g₂ (p₁ ∙ ! p₂)) (prop-has-all-paths-↓ (H.El-level _ _))}\n\n surj-inj-is-equiv : is-equiv φ.f\n surj-inj-is-equiv = contr-map-is-equiv\n (λ h → let (g₁ , p₁) = Trunc-rec (image-prop h) (idf _) (surj h) in\n ((g₁ , p₁) , (λ {(g₂ , p₂) →\n pair= (inj g₁ g₂ (p₁ ∙ ! p₂))\n (prop-has-all-paths-↓ (H.El-level _ _))})))\n\n\nmodule _ {i} {G H : Group i} (φ : G →ᴳ H) where\n\n private\n module G = Group G\n module H = Group H\n module φ = GroupHom φ\n\n module _ (inj : (g₁ g₂ : G.El) → φ.f g₁ == φ.f g₂ → g₁ == g₂)\n (surj : (h : H.El) → Trunc -1 (Σ G.El (λ g → φ.f g == h))) where\n\n surj-inj-iso : G ≃ᴳ H\n surj-inj-iso = (φ , surj-inj-is-equiv φ inj surj)\n\n surj-inj-path : G == H\n surj-inj-path = group-ua surj-inj-iso\n\n{- negation is a homomorphism in an abelian gruop -}\ninv-hom : ∀ {i} (G : Group i) (G-abelian : is-abelian G) → GroupHom G G\ninv-hom G G-abelian = record {\n f = Group.inv G;\n pres-comp = λ g₁ g₂ →\n group-inv-comp G g₁ g₂ ∙ G-abelian (Group.inv G g₂) (Group.inv G g₁)}\n\ninv-hom-natural : ∀ {i j} {G : Group i} {H : Group j}\n (G-abelian : is-abelian G) (H-abelian : is-abelian H) (φ : G →ᴳ H)\n → φ ∘ᴳ inv-hom G G-abelian == inv-hom H H-abelian ∘ᴳ φ\ninv-hom-natural _ _ φ = hom= _ _ $ λ= $ GroupHom.pres-inv φ\n\n{- two homomorphisms into an abelian group can be composed with\n - the group operation -}\nmodule _ {i} {G H : Group i} (H-abelian : is-abelian H)\n (φ ψ : G →ᴳ H) where\n\n private\n module G = Group G\n module H = Group H\n module φ = GroupHom φ\n module ψ = GroupHom ψ\n\n comp-hom : G →ᴳ H\n comp-hom = record {\n f = λ g → H.comp (φ.f g) (ψ.f g);\n pres-comp = λ g₁ g₂ →\n H.comp (φ.f (G.comp g₁ g₂)) (ψ.f (G.comp g₁ g₂))\n =⟨ ap2 H.comp (φ.pres-comp g₁ g₂) (ψ.pres-comp g₁ g₂) ⟩\n H.comp (H.comp (φ.f g₁) (φ.f g₂)) (H.comp (ψ.f g₁) (ψ.f g₂))\n =⟨ lemma (φ.f g₁) (φ.f g₂) (ψ.f g₁) (ψ.f g₂) ⟩\n H.comp (H.comp (φ.f g₁) (ψ.f g₁)) (H.comp (φ.f g₂) (ψ.f g₂)) ∎}\n\n where\n lemma : (h₁ h₂ h₃ h₄ : H.El) →\n H.comp (H.comp h₁ h₂) (H.comp h₃ h₄)\n == H.comp (H.comp h₁ h₃) (H.comp h₂ h₄)\n lemma h₁ h₂ h₃ h₄ =\n (h₁ □ h₂) □ (h₃ □ h₄)\n =⟨ H.assoc h₁ h₂ (h₃ □ h₄) ⟩\n h₁ □ (h₂ □ (h₃ □ h₄))\n =⟨ H-abelian h₃ h₄ |in-ctx (λ w → h₁ □ (h₂ □ w)) ⟩\n h₁ □ (h₂ □ (h₄ □ h₃))\n =⟨ ! (H.assoc h₂ h₄ h₃) |in-ctx (λ w → h₁ □ w) ⟩\n h₁ □ ((h₂ □ h₄) □ h₃)\n =⟨ H-abelian (h₂ □ h₄) h₃ |in-ctx (λ w → h₁ □ w) ⟩\n h₁ □ (h₃ □ (h₂ □ h₄))\n =⟨ ! (H.assoc h₁ h₃ (h₂ □ h₄)) ⟩\n (h₁ □ h₃) □ (h₂ □ h₄) ∎\n where\n infix 80 _□_\n _□_ = H.comp\n", "meta": {"hexsha": "153bdbea996365ae9bbfd6451b850d302c9b71c0", "size": 12116, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/groups/Homomorphisms.agda", "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "core/lib/groups/Homomorphisms.agda", "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "core/lib/groups/Homomorphisms.agda", "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.9383753501, "max_line_length": 80, "alphanum_fraction": 0.4928194123, "num_tokens": 5289, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950907764119, "lm_q2_score": 0.7431680199891789, "lm_q1q2_score": 0.6271558436908944}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Category.Monoidal.Instance.Rels where\n\n-- The category of relations is cartesian and (by self-duality) co-cartesian.\n-- Perhaps slightly counter-intuitively if you're used to categories which act\n-- like Sets, the product acts on objects as the disjoint union.\n\nopen import Data.Empty.Polymorphic using (⊥; ⊥-elim)\nimport Data.Product as ×\nopen × using (_,_)\nopen import Data.Sum using (_⊎_; inj₁; inj₂; [_,_]′)\nopen import Function using (case_of_; flip)\nopen import Level using (Lift; lift)\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl)\n\nopen import Categories.Category.Cartesian using (Cartesian; module CartesianMonoidal)\nopen import Categories.Category.Core using (Category)\nopen import Categories.Category.Cocartesian using (Cocartesian)\nopen import Categories.Category.Instance.Rels using (Rels)\n\nmodule _ {o ℓ} where\n\n Rels-Cartesian : Cartesian (Rels o ℓ)\n Rels-Cartesian = record\n { terminal = record\n { ⊤ = ⊥\n ; ⊤-is-terminal = record\n { ! = λ { _ (lift ()) }\n ; !-unique = λ _ → (λ { {_} {lift ()} }) , (λ { {_} {lift ()} })\n }\n }\n ; products = record\n { product = λ {A} {B} → record\n { A×B = A ⊎ B\n ; π₁ = [ (λ x y → Lift ℓ (x ≡ y) ) , (λ _ _ → ⊥) ]′\n ; π₂ = [ (λ _ _ → ⊥) , (λ x y → Lift ℓ (x ≡ y)) ]′\n ; ⟨_,_⟩ = λ L R c → [ L c , R c ]′\n ; project₁ = (λ { (inj₁ x , r , lift refl) → r})\n , λ r → inj₁ _ , r , lift refl\n ; project₂ = (λ { (inj₂ _ , r , lift refl) → r })\n , (λ r → inj₂ _ , r , lift refl)\n ; unique =\n λ { (p , q) (p′ , q′) → (λ { {_} {inj₁ a} r → case (q {_} {a} r) of λ { (inj₁ .a , s , lift refl) → s}\n ; {_} {inj₂ b} r → case (q′ {_} {b} r) of λ { (inj₂ .b , s , lift refl) → s} })\n , λ { {_} {inj₁ a} hxa → p (inj₁ a , hxa , lift refl)\n ; {_} {inj₂ b} hxb → p′ (inj₂ b , hxb , lift refl) } }\n }\n }\n }\n\n module Rels-CartesianMonoidal = CartesianMonoidal _ Rels-Cartesian\n open Rels-CartesianMonoidal renaming (monoidal to Rels-Monoidal) public\n\n -- because Rels is dual to itself, the proof that it is cocartesian resembles the proof that it's cartesian\n -- Rels is not self-dual 'on the nose', so we can't use duality proper.\n Rels-Cocartesian : Cocartesian (Rels o ℓ)\n Rels-Cocartesian = record\n { initial = record\n { ⊥ = ⊥\n ; ⊥-is-initial = record\n { ! = λ ()\n ; !-unique = λ _ → (λ { {()} }) , (λ { {()} })\n }\n }\n ; coproducts = record\n { coproduct = λ {A} {B} → record\n { A+B = A ⊎ B\n ; i₁ = λ a → [ (λ a′ → Lift ℓ (a ≡ a′)) , (λ _ → ⊥) ]′\n ; i₂ = λ b → [ (λ _ → ⊥) , (λ b′ → Lift ℓ (b ≡ b′)) ]′\n ; [_,_] = λ L R a+b c → [ flip L c , flip R c ]′ a+b\n ; inject₁ = (λ { (inj₁ x , lift refl , fxy) → fxy})\n , λ r → inj₁ _ , lift refl , r\n ; inject₂ = (λ { (inj₂ _ , lift refl , r) → r })\n , (λ r → inj₂ _ , lift refl , r)\n ; unique = λ { (p , q) (p′ , q′) → (λ { {inj₁ a} r → case (q {a} r) of λ { (inj₁ .a , lift refl , s) → s}\n ; {inj₂ b} r → case (q′ {b} r) of λ { (inj₂ .b , lift refl , s) → s} })\n , λ { {inj₁ a} hxa → p (inj₁ a , lift refl , hxa)\n ; {inj₂ b} hxb → p′ (inj₂ b , lift refl , hxb) } }\n }\n }\n }\n", "meta": {"hexsha": "72bf57ee45be2920e4680d9dceaccd107133eeae", "size": 3543, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Monoidal/Instance/Rels.agda", "max_stars_repo_name": "TOTBWF/agda-categories", "max_stars_repo_head_hexsha": "f8a33de12956c729c7fb00a302f166a643eb6052", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-04-18T18:21:47.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-18T18:21:47.000Z", "max_issues_repo_path": "src/Categories/Category/Monoidal/Instance/Rels.agda", "max_issues_repo_name": "andrejbauer/agda-categories", "max_issues_repo_head_hexsha": "d07746023503cc8f49670e309a6170dc4b404b95", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Monoidal/Instance/Rels.agda", "max_forks_repo_name": "andrejbauer/agda-categories", "max_forks_repo_head_hexsha": "d07746023503cc8f49670e309a6170dc4b404b95", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.2073170732, "max_line_length": 118, "alphanum_fraction": 0.4885690093, "num_tokens": 1197, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951025545427, "lm_q2_score": 0.7431680086124811, "lm_q1q2_score": 0.6271558428432851}} {"text": "{-\n\nThis file contains:\n\n- Properties of 2-groupoid truncations\n\n-}\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.HITs.2GroupoidTruncation.Properties where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Univalence\n\nopen import Cubical.HITs.2GroupoidTruncation.Base\n\nprivate\n variable\n ℓ : Level\n A : Type ℓ\n\nrec : ∀ {B : Type ℓ} → is2Groupoid B → (A → B) → ∥ A ∥₄ → B\nrec gB f ∣ x ∣₄ = f x\nrec gB f (squash₄ _ _ _ _ _ _ t u i j k l) =\n gB _ _ _ _ _ _ (λ m n o → rec gB f (t m n o)) (λ m n o → rec gB f (u m n o))\n i j k l\n\nelim : {B : ∥ A ∥₄ → Type ℓ}\n (bG : (x : ∥ A ∥₄) → is2Groupoid (B x))\n (f : (x : A) → B ∣ x ∣₄) (x : ∥ A ∥₄) → B x\nelim bG f ∣ x ∣₄ = f x\nelim bG f (squash₄ x y p q r s u v i j k l) =\n isOfHLevel→isOfHLevelDep 4 bG _ _ _ _ _ _\n (λ j k l → elim bG f (u j k l)) (λ j k l → elim bG f (v j k l))\n (squash₄ x y p q r s u v)\n i j k l\n\nelim2 : {B : ∥ A ∥₄ → ∥ A ∥₄ → Type ℓ}\n (gB : ((x y : ∥ A ∥₄) → is2Groupoid (B x y)))\n (g : (a b : A) → B ∣ a ∣₄ ∣ b ∣₄)\n (x y : ∥ A ∥₄) → B x y\nelim2 gB g = elim (λ _ → is2GroupoidΠ (λ _ → gB _ _))\n (λ a → elim (λ _ → gB _ _) (g a))\n\nelim3 : {B : (x y z : ∥ A ∥₄) → Type ℓ}\n (gB : ((x y z : ∥ A ∥₄) → is2Groupoid (B x y z)))\n (g : (a b c : A) → B ∣ a ∣₄ ∣ b ∣₄ ∣ c ∣₄)\n (x y z : ∥ A ∥₄) → B x y z\nelim3 gB g = elim2 (λ _ _ → is2GroupoidΠ (λ _ → gB _ _ _))\n (λ a b → elim (λ _ → gB _ _ _) (g a b))\n\n2GroupoidTruncIs2Groupoid : is2Groupoid ∥ A ∥₄\n2GroupoidTruncIs2Groupoid a b p q r s = squash₄ a b p q r s\n\n2GroupoidTruncIdempotent≃ : is2Groupoid A → ∥ A ∥₄ ≃ A\n2GroupoidTruncIdempotent≃ {A = A} hA = isoToEquiv f\n where\n f : Iso ∥ A ∥₄ A\n Iso.fun f = rec hA (idfun A)\n Iso.inv f x = ∣ x ∣₄\n Iso.rightInv f _ = refl\n Iso.leftInv f = elim (λ _ → isOfHLevelSuc 4 2GroupoidTruncIs2Groupoid _ _) (λ _ → refl)\n\n2GroupoidTruncIdempotent : is2Groupoid A → ∥ A ∥₄ ≡ A\n2GroupoidTruncIdempotent hA = ua (2GroupoidTruncIdempotent≃ hA)\n", "meta": {"hexsha": "edd391dcb605281fbbb5bb68e2acf8dc0ed50fce", "size": 2202, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/2GroupoidTruncation/Properties.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/HITs/2GroupoidTruncation/Properties.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/HITs/2GroupoidTruncation/Properties.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "avg_line_length": 31.9130434783, "max_line_length": 89, "alphanum_fraction": 0.5717529519, "num_tokens": 989, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619091240701, "lm_q2_score": 0.7606506581031359, "lm_q1q2_score": 0.6271274937561918}} {"text": "-- {-# OPTIONS --show-implicit #-}\n-- {-# OPTIONS -v tc.meta:25 #-}\nmodule NoBlockOnLevel where\n\nopen import Common.Level\nopen import Common.Product\n\nBSetoid : ∀ c → Set (lsuc c)\nBSetoid c = Set c\n\ninfixr 0 _⟶_\n\npostulate\n _⟶_ : ∀ {f t} → BSetoid f → BSetoid t → Set (f ⊔ t)\n →-to-⟶ : ∀ {a b} {A : Set a} {B : BSetoid b} →\n (A → B) → A ⟶ B\n\npostulate\n a b p : Level\n A : Set a\n B : Set b\n P : A → B → Set p\n\n-- This will leave unsolved metas if we give up on an unsolved level constraint\n-- when checking argument spines. Since we can't match on levels it's safe to keep\n-- checking later constraints even if they depend on the unsolved levels.\nf : (∃ λ x → ∃ λ y → P x y) ⟶ (∃ λ y → ∃ λ x → P x y)\nf = →-to-⟶ λ p → proj₁ (proj₂ p) , proj₁ p , proj₂ (proj₂ p)\n\n", "meta": {"hexsha": "74f5bb65437897cafbbd0c31f01c6b801537af8c", "size": 777, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/NoBlockOnLevel.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/NoBlockOnLevel.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/NoBlockOnLevel.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 25.9, "max_line_length": 82, "alphanum_fraction": 0.5971685972, "num_tokens": 287, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681049901037, "lm_q2_score": 0.7310585903489892, "lm_q1q2_score": 0.627078741680389}} {"text": "{-\n\nThis file contains:\n\n- Definition of set truncations\n\n-}\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.HITs.SetTruncation.Base where\n\nopen import Cubical.Core.Primitives\n\n-- set truncation as a higher inductive type:\n\ndata ∥_∥₂ {ℓ} (A : Type ℓ) : Type ℓ where\n ∣_∣₂ : A → ∥ A ∥₂\n squash₂ : ∀ (x y : ∥ A ∥₂) (p q : x ≡ y) → p ≡ q\n", "meta": {"hexsha": "0a2e801936bb60cc82a0ad3f42145177152d1121", "size": 355, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/SetTruncation/Base.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/HITs/SetTruncation/Base.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/HITs/SetTruncation/Base.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "avg_line_length": 19.7222222222, "max_line_length": 50, "alphanum_fraction": 0.6281690141, "num_tokens": 133, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8688267694452331, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.6270698234966874}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Categories.Instances.RingAlgebras where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\n\nopen import Cubical.Algebra.Ring\nopen import Cubical.Algebra.Algebra\n\nopen import Cubical.Categories.Category\n\nopen Category\nopen AlgebraHoms\n\nprivate\n variable\n ℓ ℓ' : Level\n\nmodule _ (R : Ring ℓ) where\n AlgebrasCategory : Category (ℓ-suc (ℓ-max ℓ ℓ')) (ℓ-max ℓ ℓ')\n ob AlgebrasCategory = Algebra R _\n Hom[_,_] AlgebrasCategory = AlgebraHom\n id AlgebrasCategory {A} = idAlgebraHom A\n _⋆_ AlgebrasCategory = compAlgebraHom\n ⋆IdL AlgebrasCategory = compIdAlgebraHom\n ⋆IdR AlgebrasCategory = idCompAlgebraHom\n ⋆Assoc AlgebrasCategory = compAssocAlgebraHom\n isSetHom AlgebrasCategory = isSetAlgebraHom _ _\n", "meta": {"hexsha": "3d84499ce129672577d60e93ffc5685cc5ef34dc", "size": 797, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Instances/RingAlgebras.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_issues_repo_path": "Cubical/Categories/Instances/RingAlgebras.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Categories/Instances/RingAlgebras.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.4827586207, "max_line_length": 63, "alphanum_fraction": 0.7590966123, "num_tokens": 251, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802440252811, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.6269304960790663}} {"text": "\nopen import Oscar.Prelude\nopen import Oscar.Data.𝟘\n\nmodule Oscar.Data.Decidable where\n\ndata Decidable {a} (A : Ø a) : Ø a where\n ↑_ : A → Decidable A\n ↓_ : ¬ A → Decidable A\n", "meta": {"hexsha": "51983468e78936d23fd3079b722c0870e9ed9964", "size": 177, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-3/src/Oscar/Data/Decidable.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-3/src/Oscar/Data/Decidable.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-3/src/Oscar/Data/Decidable.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.7, "max_line_length": 40, "alphanum_fraction": 0.6723163842, "num_tokens": 61, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9184802484881361, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.626930487263719}} {"text": "{-# OPTIONS --universe-polymorphism #-}\nmodule Categories.Support.EqReasoning where\n\nopen import Categories.Support.Equivalence using (Setoid; module Setoid)\nopen import Relation.Binary.PropositionalEquality using () renaming (_≡_ to _≣_; trans to ≣-trans; sym to ≣-sym; refl to ≣-refl)\n\nmodule SetoidReasoning {s₁ s₂} (S : Setoid s₁ s₂) where\n open Setoid S\n\n infix 4 _IsRelatedTo_\n infix 1 begin_\n infixr 2 _≈⟨_⟩_ _↓⟨_⟩_ _↑⟨_⟩_ _↓≣⟨_⟩_ _↑≣⟨_⟩_ _↕_\n infix 3 _∎\n \n \n -- This seemingly unnecessary type is used to make it possible to\n -- infer arguments even if the underlying equality evaluates.\n\n data _IsRelatedTo_ (x y : Carrier) : Set s₂ where\n relTo : (x∼y : x ≈ y) → x IsRelatedTo y\n\n .begin_ : ∀ {x y} → x IsRelatedTo y → x ≈ y\n begin relTo x∼y = x∼y\n\n ._↓⟨_⟩_ : ∀ x {y z} → x ≈ y → y IsRelatedTo z → x IsRelatedTo z\n _ ↓⟨ x∼y ⟩ relTo y∼z = relTo (trans x∼y y∼z)\n -- where open IsEquivalence isEquivalence\n\n ._↑⟨_⟩_ : ∀ x {y z} → y ≈ x → y IsRelatedTo z → x IsRelatedTo z\n _ ↑⟨ y∼x ⟩ relTo y∼z = relTo (trans (sym y∼x) y∼z)\n -- where open IsEquivalence isEquivalence\n\n -- the syntax of the ancients, for compatibility\n ._≈⟨_⟩_ : ∀ x {y z} → x ≈ y → y IsRelatedTo z → x IsRelatedTo z\n _≈⟨_⟩_ = _↓⟨_⟩_\n\n ._↓≣⟨_⟩_ : ∀ x {y z} → x ≣ y → y IsRelatedTo z → x IsRelatedTo z\n _ ↓≣⟨ ≣-refl ⟩ y∼z = y∼z\n\n ._↑≣⟨_⟩_ : ∀ x {y z} → y ≣ x → y IsRelatedTo z → x IsRelatedTo z\n _ ↑≣⟨ ≣-refl ⟩ y∼z = y∼z\n\n ._↕_ : ∀ x {z} → x IsRelatedTo z → x IsRelatedTo z\n _ ↕ x∼z = x∼z\n\n ._∎ : ∀ x → x IsRelatedTo x\n _∎ _ = relTo refl\n -- where open IsEquivalence isEquivalence\n\nmodule ≣-reasoning {ℓ} (S : Set ℓ) where\n infix 4 _IsRelatedTo_\n infix 2 _∎\n infixr 2 _≈⟨_⟩_\n infixr 2 _↓⟨_⟩_\n infixr 2 _↑⟨_⟩_\n infixr 2 _↕_\n infix 1 begin_\n\n -- This seemingly unnecessary type is used to make it possible to\n -- infer arguments even if the underlying equality evaluates.\n\n data _IsRelatedTo_ (x y : S) : Set ℓ where\n relTo : (x∼y : x ≣ y) → x IsRelatedTo y\n\n begin_ : ∀ {x y} → x IsRelatedTo y → x ≣ y\n begin relTo x∼y = x∼y\n\n -- the syntax of the ancients, for compatibility\n _≈⟨_⟩_ : ∀ x {y z} → x ≣ y → y IsRelatedTo z → x IsRelatedTo z\n _ ≈⟨ x∼y ⟩ relTo y∼z = relTo (≣-trans x∼y y∼z)\n\n _↓⟨_⟩_ : ∀ x {y z} → x ≣ y → y IsRelatedTo z → x IsRelatedTo z\n _ ↓⟨ x∼y ⟩ relTo y∼z = relTo (≣-trans x∼y y∼z)\n\n _↑⟨_⟩_ : ∀ x {y z} → y ≣ x → y IsRelatedTo z → x IsRelatedTo z\n _ ↑⟨ y∼x ⟩ relTo y∼z = relTo (≣-trans (≣-sym y∼x) y∼z)\n\n _↕_ : ∀ x {z} → x IsRelatedTo z → x IsRelatedTo z\n _ ↕ x∼z = x∼z\n\n _∎ : ∀ x → x IsRelatedTo x\n _∎ _ = relTo ≣-refl\n\n", "meta": {"hexsha": "dcfacdeee67a710d81c1876827ffeac891055452", "size": 2582, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Support/EqReasoning.agda", "max_stars_repo_name": "p-pavel/categories", "max_stars_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-12-29T21:51:57.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-29T21:51:57.000Z", "max_issues_repo_path": "Categories/Support/EqReasoning.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Categories/Support/EqReasoning.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.7380952381, "max_line_length": 128, "alphanum_fraction": 0.6003098373, "num_tokens": 1169, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581097540519, "lm_q2_score": 0.787931188173138, "lm_q1q2_score": 0.6269238397981032}} {"text": "module 060-commutative-group where\n\n-- We need groups.\n\nopen import 050-group\n\nrecord CommutativeGroup\n {M : Set}\n (_==_ : M -> M -> Set)\n (_*_ : M -> M -> M)\n (id : M)\n (invert : M -> M)\n : Set1 where\n\n field\n group : Group _==_ _*_ id invert\n comm : ∀ {r s} -> (r * s) == (s * r)\n\n open Group group public\n\n -- Nothing proven here yet.\n", "meta": {"hexsha": "aa4195bca8fd133ef6a9d7b1feb72e9595391758", "size": 353, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "060-commutative-group.agda", "max_stars_repo_name": "mcmtroffaes/agda-proofs", "max_stars_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-08-09T22:51:55.000Z", "max_stars_repo_stars_event_max_datetime": "2016-08-17T16:15:42.000Z", "max_issues_repo_path": "060-commutative-group.agda", "max_issues_repo_name": "mcmtroffaes/agda-proofs", "max_issues_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "060-commutative-group.agda", "max_forks_repo_name": "mcmtroffaes/agda-proofs", "max_forks_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.0454545455, "max_line_length": 40, "alphanum_fraction": 0.552407932, "num_tokens": 121, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9230391579526935, "lm_q2_score": 0.6791786991753931, "lm_q1q2_score": 0.6269085345862606}} {"text": "-- Andreas, 2017-09-09, re issue #2732\n-- eta-contraction needed in termination checker\n\n-- {-# OPTIONS -v term:30 #-}\n\nopen import Agda.Builtin.Equality\n\ndata O (A : Set) : Set where\n leaf : O A\n node : (A → O A) → O A\n\npostulate\n A : Set\n a : A\n\ntest1 : (t u : O A) → O A\ntest1 leaf leaf = leaf\ntest1 leaf (node g) = test1 leaf (g a)\ntest1 (node f) leaf = test1 (f a) (node f)\ntest1 (node f) (node g) = test1 (node λ x → f x) (g a)\n-- Should pass even with the eta-expansion.\n\ndata Q (A : Set) : Set where\n leaf : Q A\n node : (f g : A → Q A) (p : f ≡ g) → Q A\n\n-- Having various call arguments in eta-expanded form.\ntest : (t u : Q A) → Q A\ntest leaf leaf = leaf\ntest leaf (node f g p) = test leaf (f a)\ntest (node f g p) leaf = test (g a) (node f g p)\ntest (node f .f refl) (node g g' p) = test (node (λ x → f x) _ refl) (g' a)\n", "meta": {"hexsha": "f589490310bf7a82fefec302e8ec05725580b1a4", "size": 853, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue2732-termination.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue2732-termination.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue2732-termination.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 25.8484848485, "max_line_length": 75, "alphanum_fraction": 0.5826494725, "num_tokens": 321, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127603871312, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.6268740366366894}} {"text": "{-\n\nThis module converts between the path equality\nand the inductively define equality types.\n\n- _≡c_ stands for \"c\"ubical equality.\n- _≡p_ stands for \"p\"ropositional equality.\n\nTODO: reconsider naming scheme.\n-}\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nmodule Cubical.Data.Equality where\n\nopen import Cubical.Foundations.Prelude\n renaming ( _≡_ to _≡c_ ; refl to reflc )\n public\nopen import Agda.Builtin.Equality\n renaming ( _≡_ to _≡p_ ; refl to reflp )\n public\n\nopen import Cubical.Foundations.Isomorphism\n\nprivate\n variable\n ℓ : Level\n A : Type ℓ\n x y z : A\n\nptoc : x ≡p y → x ≡c y\nptoc reflp = reflc\n\nctop : x ≡c y → x ≡p y\nctop p = transport (cong (λ u → _ ≡p u) p) reflp\n\nptoc-ctop : (p : x ≡c y) → ptoc (ctop p) ≡c p\nptoc-ctop p =\n J (λ _ h → ptoc (ctop h) ≡c h) (cong ptoc (transportRefl reflp)) p\n\nctop-ptoc : (p : x ≡p y) → ctop (ptoc p) ≡c p\nctop-ptoc {x = x} reflp = transportRefl reflp\n\np≅c : {x y : A} → Iso (x ≡c y) (x ≡p y)\np≅c = iso ctop ptoc ctop-ptoc ptoc-ctop\n\np-c : {x y : A} → (x ≡c y) ≡c (x ≡p y)\np-c = isoToPath p≅c\n\np=c : {x y : A} → (x ≡c y) ≡p (x ≡p y)\np=c = ctop p-c\n", "meta": {"hexsha": "783fef24a4942bfb889019b9422718c9474e87e8", "size": 1115, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/Equality.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/Equality.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/Data/Equality.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "avg_line_length": 21.862745098, "max_line_length": 68, "alphanum_fraction": 0.6295964126, "num_tokens": 472, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127529517044, "lm_q2_score": 0.734119526900183, "lm_q1q2_score": 0.6268740262109381}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\n\nmodule Categories.Diagram.Duality {o ℓ e} (C : Category o ℓ e) where\n\nopen Category C\n\nopen import Level\nopen import Function using (_$_)\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl)\n\nopen import Categories.Functor\nopen import Categories.Functor.Bifunctor\nopen import Categories.NaturalTransformation.Dinatural\n\nopen import Categories.Object.Initial\nopen import Categories.Object.Terminal\nopen import Categories.Object.Duality\nopen import Categories.Diagram.Equalizer op\nopen import Categories.Diagram.Coequalizer C\nopen import Categories.Diagram.Pullback op\nopen import Categories.Diagram.Pushout C\nopen import Categories.Diagram.Cone as Cone\nopen import Categories.Diagram.Cocone as Cocone\nopen import Categories.Diagram.End as End\nopen import Categories.Diagram.Coend as Coend\nopen import Categories.Diagram.Limit as Limit\nopen import Categories.Diagram.Colimit as Colimit\nopen import Categories.Category.Construction.Cocones using (Cocones)\n\nprivate\n variable\n o′ ℓ′ e′ : Level\n D J : Category o′ ℓ′ e′\n A B : Obj\n f g : A ⇒ B\n\nCoequalizer⇒coEqualizer : Coequalizer f g → Equalizer f g\nCoequalizer⇒coEqualizer coe = record\n { arr = arr\n ; equality = equality\n ; equalize = coequalize\n ; universal = universal\n ; unique = unique\n }\n where open Coequalizer coe\n\ncoEqualizer⇒Coequalizer : Equalizer f g → Coequalizer f g\ncoEqualizer⇒Coequalizer e = record\n { arr = arr\n ; equality = equality\n ; coequalize = equalize\n ; universal = universal\n ; unique = unique\n }\n where open Equalizer e\n\ncoPullback⇒Pushout : Pullback f g → Pushout f g\ncoPullback⇒Pushout p = record\n { i₁ = p₁\n ; i₂ = p₂\n ; commute = commute\n ; universal = universal\n ; unique = unique\n ; universal∘i₁≈h₁ = p₁∘universal≈h₁\n ; universal∘i₂≈h₂ = p₂∘universal≈h₂\n }\n where open Pullback p\n\nPushout⇒coPullback : Pushout f g → Pullback f g\nPushout⇒coPullback p = record\n { p₁ = i₁\n ; p₂ = i₂\n ; isPullback = record\n { commute = commute\n ; universal = universal\n ; unique = unique\n ; p₁∘universal≈h₁ = universal∘i₁≈h₁\n ; p₂∘universal≈h₂ = universal∘i₂≈h₂\n }\n }\n where open Pushout p\n\nmodule _ {F : Functor J C} where\n open Functor F renaming (op to Fop)\n\n coApex⇒Coapex : ∀ X → Apex Fop X → Coapex F X\n coApex⇒Coapex X apex = record\n { ψ = ψ\n ; commute = commute\n }\n where open Cone.Apex apex\n\n coCone⇒Cocone : Cone Fop → Cocone F\n coCone⇒Cocone c = record\n { coapex = coApex⇒Coapex _ apex\n }\n where open Cone.Cone c\n\n Coapex⇒coApex : ∀ X → Coapex F X → Apex Fop X\n Coapex⇒coApex X coapex = record\n { ψ = ψ\n ; commute = commute\n }\n where open Cocone.Coapex coapex\n\n Cocone⇒coCone : Cocone F → Cone Fop\n Cocone⇒coCone c = record\n { apex = Coapex⇒coApex _ coapex\n }\n where open Cocone.Cocone c\n\n coCone⇒⇒Cocone⇒ : ∀ {K K′} → Cone⇒ Fop K K′ → Cocone⇒ F (coCone⇒Cocone K′) (coCone⇒Cocone K)\n coCone⇒⇒Cocone⇒ f = record\n { arr = arr\n ; commute = commute\n }\n where open Cone⇒ f\n\n Cocone⇒⇒coCone⇒ : ∀ {K K′} → Cocone⇒ F K K′ → Cone⇒ Fop (Cocone⇒coCone K′) (Cocone⇒coCone K)\n Cocone⇒⇒coCone⇒ f = record\n { arr = arr\n ; commute = commute\n }\n where open Cocone⇒ f\n\n coLimit⇒Colimit : Limit Fop → Colimit F\n coLimit⇒Colimit lim = record\n { initial = op⊤⇒⊥ (Cocones F) $ record\n { ⊤ = coCone⇒Cocone ⊤\n ; ⊤-is-terminal = record\n { ! = coCone⇒⇒Cocone⇒ !\n ; !-unique = λ f → !-unique (Cocone⇒⇒coCone⇒ f)\n }\n }\n }\n where open Limit.Limit lim\n open Terminal terminal\n\n Colimit⇒coLimit : Colimit F → Limit Fop\n Colimit⇒coLimit colim = record\n { terminal = record\n { ⊤ = Cocone⇒coCone ⊥\n ; ⊤-is-terminal = record\n { ! = Cocone⇒⇒coCone⇒ !\n ; !-unique = λ f → !-unique (coCone⇒⇒Cocone⇒ f)\n }\n }\n }\n where open Colimit.Colimit colim\n open Initial initial\n\nmodule _ {F : Bifunctor (Category.op D) D C} where\n open HomReasoning\n open Functor F renaming (op to Fop)\n\n coWedge⇒Cowedge : Wedge Fop → Cowedge F\n coWedge⇒Cowedge W = record\n { E = E\n ; dinatural = DinaturalTransformation.op dinatural\n }\n where open Wedge W\n\n Cowedge⇒coWedge : Cowedge F → Wedge Fop\n Cowedge⇒coWedge W = record\n { E = E\n ; dinatural = DinaturalTransformation.op dinatural\n }\n where open Cowedge W\n\n coEnd⇒Coend : End Fop → Coend F\n coEnd⇒Coend e = record\n { cowedge = coWedge⇒Cowedge wedge\n ; factor = λ W → factor (Cowedge⇒coWedge W)\n ; universal = universal\n ; unique = unique\n }\n where open End.End e\n\n Coend⇒coEnd : Coend F → End Fop\n Coend⇒coEnd e = record\n { wedge = Cowedge⇒coWedge cowedge\n ; factor = λ W → factor (coWedge⇒Cowedge W)\n ; universal = universal\n ; unique = unique\n }\n where open Coend.Coend e\n\n\nmodule DiagramDualityConversionProperties where\n private\n Coequalizer⇔coEqualizer : ∀ (coequalizer : Coequalizer f g) →\n coEqualizer⇒Coequalizer (Coequalizer⇒coEqualizer coequalizer) ≡ coequalizer\n Coequalizer⇔coEqualizer _ = refl\n\n\n coPullback⇔Pushout : ∀ (coPullback : Pullback f g) →\n Pushout⇒coPullback (coPullback⇒Pushout coPullback) ≡ coPullback\n coPullback⇔Pushout _ = refl\n\n module _ {F : Functor J C} where\n open Functor F renaming (op to Fop)\n\n coApex⇔Coapex : ∀ X → (coApex : Apex Fop X) →\n Coapex⇒coApex X (coApex⇒Coapex X coApex) ≡ coApex\n coApex⇔Coapex _ _ = refl\n\n coCone⇔Cocone : ∀ (coCone : Cone Fop) →\n Cocone⇒coCone (coCone⇒Cocone coCone) ≡ coCone\n coCone⇔Cocone _ = refl\n\n coCone⇒⇔Cocone⇒ : ∀ {K K′} → (coCone⇒ : Cone⇒ Fop K K′) →\n Cocone⇒⇒coCone⇒ (coCone⇒⇒Cocone⇒ coCone⇒) ≡ coCone⇒\n coCone⇒⇔Cocone⇒ _ = refl\n\n\n coLimit⇔Colimit : ∀ (coLimit : Limit Fop) →\n Colimit⇒coLimit (coLimit⇒Colimit coLimit) ≡ coLimit\n coLimit⇔Colimit _ = refl\n\n\n module _ {F : Bifunctor (Category.op D) D C} where\n open Functor F renaming (op to Fop)\n\n coWedge⇔Cowedge : ∀ (coWedge : Wedge Fop) →\n Cowedge⇒coWedge (coWedge⇒Cowedge coWedge) ≡ coWedge\n coWedge⇔Cowedge _ = refl\n\n\n coEnd⇔Coend : ∀ (coEnd : End Fop) →\n Coend⇒coEnd (coEnd⇒Coend coEnd) ≡ coEnd\n coEnd⇔Coend _ = refl\n", "meta": {"hexsha": "62da72411f27e4183f08f3498709ce17ce30bffa", "size": 6580, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Diagram/Duality.agda", "max_stars_repo_name": "bolt12/agda-categories", "max_stars_repo_head_hexsha": "b813fa3e685eb4713bace6204b8084a343d549a3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Diagram/Duality.agda", "max_issues_repo_name": "bolt12/agda-categories", "max_issues_repo_head_hexsha": "b813fa3e685eb4713bace6204b8084a343d549a3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Diagram/Duality.agda", "max_forks_repo_name": "bolt12/agda-categories", "max_forks_repo_head_hexsha": "b813fa3e685eb4713bace6204b8084a343d549a3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.1196581197, "max_line_length": 94, "alphanum_fraction": 0.6241641337, "num_tokens": 2415, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473813156295, "lm_q2_score": 0.7185943925708561, "lm_q1q2_score": 0.6268639365872818}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import HoTT\nopen import cohomology.Exactness\n\nmodule cohomology.ExactPairIso where\n\n{- An exact sequence 0 → G → H → 0 implies that G == H -}\n\nmodule _ {i} {G H K L : Group i} {φ : H →ᴳ K}\n (ex : is-exact-seq (G ⟨ cst-hom ⟩→ H ⟨ φ ⟩→ K ⟨ cst-hom ⟩→ L ⊣|)) where\n\n private\n inj : (h₁ h₂ : Group.El H) → GroupHom.f φ h₁ == GroupHom.f φ h₂ → h₁ == h₂\n inj = zero-kernel-injective φ\n (λ h p → Trunc-rec (Group.El-level H _ _) (λ s → ! (snd s))\n (ktoi (exact-get ex 0) h p))\n\n exact-pair-iso : H == K\n exact-pair-iso = surj-inj-= φ inj (λ k → ktoi (exact-get ex 1) k idp)\n\nmodule _ {i} {G H K J : Group i} {φ : G →ᴳ H} {ψ : H →ᴳ K}\n {χ : K →ᴳ J} (p : G == 0ᴳ) (q : J == 0ᴳ)\n (ex : is-exact-seq (G ⟨ φ ⟩→ H ⟨ ψ ⟩→ K ⟨ χ ⟩→ J ⊣|)) where\n\n private\n ex₁ : is-exact-seq (0ᴳ ⟨ cst-hom ⟩→ H ⟨ ψ ⟩→ K ⟨ χ ⟩→ J ⊣|)\n ex₁ = transport\n (λ {(G' , φ') → is-exact-seq (G' ⟨ φ' ⟩→ H ⟨ ψ ⟩→ K ⟨ χ ⟩→ J ⊣|)})\n (pair= p (prop-has-all-paths-↓ {B = λ L → L →ᴳ H}\n (raise-level -2 0ᴳ-hom-out-level)))\n ex\n\n ex₂ : is-exact-seq (0ᴳ ⟨ cst-hom ⟩→ H ⟨ ψ ⟩→ K ⟨ cst-hom ⟩→ 0ᴳ ⊣|)\n ex₂ = transport\n (λ {(J' , χ') → is-exact-seq (0ᴳ ⟨ cst-hom ⟩→ H ⟨ ψ ⟩→ K ⟨ χ' ⟩→ J' ⊣|)})\n (pair= q (prop-has-all-paths-↓ {B = λ L → K →ᴳ L}\n (raise-level _ 0ᴳ-hom-in-level)))\n ex₁\n\n exact-pair-path-iso : H == K\n exact-pair-path-iso = exact-pair-iso ex₂\n", "meta": {"hexsha": "08af547e16523dfef03b68332395108b37c7ea02", "size": 1447, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/cohomology/ExactPairIso.agda", "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "theorems/cohomology/ExactPairIso.agda", "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "theorems/cohomology/ExactPairIso.agda", "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.6511627907, "max_line_length": 79, "alphanum_fraction": 0.4899792674, "num_tokens": 654, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473680407889, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.6268639323052756}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Example showing how to define an indexed container\n------------------------------------------------------------------------\n\n{-# OPTIONS --with-K --safe --guardedness #-}\n\nmodule README.Data.Container.Indexed where\n\nopen import Data.Unit\nopen import Data.Empty\nopen import Data.Nat.Base\nopen import Data.Product\nopen import Function\nopen import Data.W.Indexed\nopen import Data.Container.Indexed\nopen import Data.Container.Indexed.WithK\n\nmodule _ {a} (A : Set a) where\n\n------------------------------------------------------------------------\n-- Vector as an indexed container\n\n-- An indexed container is defined by three things:\n-- 1. Commands the user can emit\n-- 2. Responses the indexed container returns to these commands\n-- 3. Update of the index based on the command and the response issued.\n\n-- For a vector, commands are constructors, responses are the number of subvectors\n-- (0 if the vector is empty, 1 otherwise) and the update corresponds to setting the\n-- size of the tail (if it exists). We can formalize these ideas like so:\n\n-- Depending on the size of the vector, we may have reached the end already (nil)\n-- or we may specify what the head should be (cons). This is the type of commands.\n\n data VecC : ℕ → Set a where\n nil : VecC zero\n cons : ∀ n → A → VecC (suc n)\n\n Vec : Container ℕ ℕ a _\n Command Vec = VecC\n\n-- We then treat each command independently, specifying both the response and the\n-- next index based on that response.\n\n-- In the nil case, the response is the empty type: there won't be any tail. As\n-- a consequence, the next index won't be needed (and we can rely on the fact the\n-- user will never be able to call it).\n\n Response Vec nil = ⊥\n next Vec nil = λ ()\n\n-- In the cons case, the response is the unit type: there is exactly one tail. The\n-- next index is the predecessor of the current one. It is handily handed over to\n-- use by `cons`.\n\n -- cons\n Response Vec (cons n a) = ⊤\n next Vec (cons n a) = λ _ → n\n\n-- Finally we can define the type of Vector as the least fixed point of Vec.\n\n Vector : ℕ → Set a\n Vector = μ Vec\n\nmodule _ {a} {A : Set a} where\n\n-- We can recover the usual constructors by using `sup` to enter the fixpoint\n-- and then using the appropriate pairing of a command & a handler for the\n-- response.\n\n-- For [], the response is ⊥ which makes it easy to conclude.\n\n [] : Vector A 0\n [] = sup (nil , λ ())\n\n-- For _∷_, the response is ⊤ so we need to pass a tail. We give the one we took\n-- as an argument.\n\n infixr 3 _∷_\n _∷_ : ∀ {n} → A → Vector A n → Vector A (suc n)\n x ∷ xs = sup (cons _ x , λ _ → xs)\n\n-- We can now use these constructors to build up vectors:\n\n1⋯3 : Vector ℕ 3\n1⋯3 = 1 ∷ 2 ∷ 3 ∷ []\n\n\n\n\n\n-- Horrible thing to check the definition of _∈_ is not buggy.\n-- Not sure whether we can say anything interesting about it in the case of Vector...\n\nopen import Relation.Binary.HeterogeneousEquality\n\n_ : _∈_ {C = Vec ℕ} {X = Vector ℕ} 1⋯3 (⟦ Vec ℕ ⟧ (Vector ℕ) 4 ∋ cons _ 0 , λ _ → 1⋯3)\n_ = _ , refl\n", "meta": {"hexsha": "0c94e182eca4c07305dd8523c942a46442ee8122", "size": 3124, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/README/Data/Container/Indexed.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/README/Data/Container/Indexed.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/README/Data/Container/Indexed.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 30.9306930693, "max_line_length": 86, "alphanum_fraction": 0.6373239437, "num_tokens": 819, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473713594992, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.6268639241756426}} {"text": "{- Example by Guillaume Brunerie, 17-11-2015 -}\n\n{-# OPTIONS --rewriting --cubical-compatible #-}\n\nopen import Agda.Primitive\n\npostulate\n _↦_ : ∀ {i} {A : Set i} → A → A → Set i\n idr : ∀ {i} {A : Set i} {a : A} → a ↦ a\n{-# BUILTIN REWRITE _↦_ #-}\n\ninfixr 3 _==_\n\ndata _==_ {i} {A : Set i} (a : A) : A → Set i where\n idp : a == a\n\nPathOver : ∀ {i j} {A : Set i} (B : A → Set j)\n {x y : A} (p : x == y) (u : B x) (v : B y) → Set j\nPathOver B idp u v = (u == v)\n\nsyntax PathOver B p u v =\n u == v [ B ↓ p ]\n\npostulate\n PathOver-rewr : ∀ {i j} {A : Set i} {B : Set j} {x y : A} (p : x == y) (u v : B) →\n (PathOver (λ _ → B) p u v) ↦ (u == v)\n {-# REWRITE PathOver-rewr #-}\n\nap : ∀ {i j} {A : Set i} {B : A → Set j} (f : (a : A) → B a) {x y : A}\n → (p : x == y) → PathOver B p (f x) (f y)\nap f idp = idp\n\n\nmodule _ {i j k} {A : Set i} {B : Set j} {C : Set k} (g : B → C) (f : A → B) where\n\n ∘ap : {x y : A} (p : x == y) →\n ap g (ap f p) ↦ ap (λ x → g (f x)) p\n ∘ap idp = idr\n {-# REWRITE ∘ap #-}\n\n ap∘ : {x y : A} (p : x == y) →\n ap (λ x → g (f x)) p ↦ ap g (ap f p)\n ap∘ p = idr\n", "meta": {"hexsha": "9982f1dcd682707b7b199be317567fdac2e05975", "size": 1097, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1652-3.agda", "max_stars_repo_name": "KDr2/agda", "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/Succeed/Issue1652-3.agda", "max_issues_repo_name": "KDr2/agda", "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_forks_repo_path": "test/Succeed/Issue1652-3.agda", "max_forks_repo_name": "KDr2/agda", "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.9318181818, "max_line_length": 84, "alphanum_fraction": 0.4430264357, "num_tokens": 521, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392939666335, "lm_q2_score": 0.7090191460821871, "lm_q1q2_score": 0.626800785311322}} {"text": "module Conway where\n\nopen import Data.Bool renaming (_≟_ to _B≟_)\nopen import Data.Nat renaming (_+_ to _ℕ+_ ; _*_ to _ℕ*_ ; _≟_ to _ℕ≟_)\nopen import Data.Integer \n renaming (_+_ to _ℤ+_ ; _*_ to _ℤ*_ ; -_ to ℤ-_ ; _≟_ to _ℤ≟_)\nopen import Data.Rational renaming (_≟_ to _ℚ≟_)\nopen import Relation.Nullary.Core\nopen import Relation.Nullary.Decidable\n\nopen import Rat -- operations on rationals\n\n------------------------------------------------------------------------------\n-- Universe of games\n\ndata U : Set where\n ZERO : U\n ONE : U\n PLUS : U → U → U\n TIMES : U → U → U\n NEG : U → U\n RECIP : U → U\n\n-- Conversion from the rationals to the universe of games\n\nn2U : ℕ → U\nn2U 0 = ZERO\nn2U (suc n) = PLUS ONE (n2U n) \n\nz2U : ℤ → U\nz2U -[1+ n ] = NEG (n2U (ℕ.suc n))\nz2U (+ n) = n2U n\n\nq2U : ℚ → U\nq2U p = TIMES (z2U (ℚ.numerator p)) (RECIP (n2U (ℕ.suc (ℚ.denominator-1 p))))\n\n-- Conversion from the universe of games to the rationals\n\n-- use meadows?\n\nmutual\n\n u2q : U → ℚ\n u2q ZERO = 0ℚ\n u2q ONE = 1ℚ\n u2q (PLUS g h) = (u2q g) + (u2q h)\n u2q (TIMES g h) = (u2q g) * (u2q h)\n u2q (NEG g) = - (u2q g)\n u2q (RECIP g) = 1/_ (u2q g) {{!!}} \n-- need to know that | numerator (u2q g) | is not 0\n\n u2q≢0 : (u : U) → {u≢0 : False (u2q u ℚ≟ 0ℚ)} → ℚ\n u2q≢0 u {u≢0} with (u2q u ℚ≟ 0ℚ)\n u2q≢0 u {()} | yes _\n u2q≢0 u {_} | no _ = u2q u\n\n------------------------------------------------------------------------------\n-- Small tests\n\nprivate \n\n test₁ = q2U (- (+ 1 ÷ 3))\n {--\n TIMES \n (NEG (PLUS ONE ZERO))\n (RECIP (PLUS ONE (PLUS ONE (PLUS ONE ZERO))))\n --}\n\n------------------------------------------------------------------------------\n", "meta": {"hexsha": "3c73f2642c9c73ad60ad3a40ad069ba4fa7ad4a9", "size": 1696, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Conway.agda", "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_issues_repo_path": "Conway.agda", "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_forks_repo_path": "Conway.agda", "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "avg_line_length": 24.2285714286, "max_line_length": 78, "alphanum_fraction": 0.4858490566, "num_tokens": 653, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392756357327, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.6268007668788055}} {"text": "------------------------------------------------------------------------------\n-- Inductive PA properties\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule PA.Inductive.PropertiesATP where\n\nopen import PA.Inductive.Base\n\n------------------------------------------------------------------------------\n\n+-rightIdentity : ∀ n → n + zero ≡ n\n+-rightIdentity zero = refl\n+-rightIdentity (succ n) = prf (+-rightIdentity n)\n where postulate prf : n + zero ≡ n → succ n + zero ≡ succ n\n -- TODO (21 November 2014). See Apia issue 16\n -- {-# ATP prove prf #-}\n\nx+Sy≡S[x+y] : ∀ m n → m + succ n ≡ succ (m + n)\nx+Sy≡S[x+y] zero _ = refl\nx+Sy≡S[x+y] (succ m) n = prf (x+Sy≡S[x+y] m n)\n where postulate prf : m + succ n ≡ succ (m + n) →\n succ m + succ n ≡ succ (succ m + n)\n -- TODO (21 November 2014). See Apia issue 16\n -- {-# ATP prove prf #-}\n\n+-comm : ∀ m n → m + n ≡ n + m\n+-comm zero n = sym (+-rightIdentity n)\n+-comm (succ m) n = prf (+-comm m n)\n where postulate prf : m + n ≡ n + m → succ m + n ≡ n + succ m\n -- TODO (21 November 2014). See Apia issue 16\n -- {-# ATP prove prf x+Sy≡S[x+y] #-}\n", "meta": {"hexsha": "63b9fcc9f16b60880becd53fde1a70b0cf4473f7", "size": 1381, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/PA/Inductive/PropertiesATP.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/PA/Inductive/PropertiesATP.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/PA/Inductive/PropertiesATP.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 37.3243243243, "max_line_length": 78, "alphanum_fraction": 0.4373642288, "num_tokens": 389, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8840392756357326, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.6268007668788054}} {"text": "{-# OPTIONS --universe-polymorphism #-}\nmodule Categories.Categories where\n\nopen import Level\n\nopen import Categories.Category\nopen import Categories.Functor\n\nCategories : ∀ o ℓ e → Category (suc (o ⊔ ℓ ⊔ e)) (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e)\nCategories o ℓ e = record \n { Obj = Category o ℓ e\n ; _⇒_ = Functor\n ; _≡_ = _≡_\n ; _∘_ = _∘_\n ; id = id\n ; assoc = λ {_} {_} {_} {_} {F} {G} {H} → assoc {F = F} {G} {H}\n ; identityˡ = λ {_} {_} {F} → identityˡ {F = F}\n ; identityʳ = λ {_} {_} {F} → identityʳ {F = F}\n ; equiv = λ {X} {Y} → equiv {C = X} {D = Y}\n ; ∘-resp-≡ = λ {_} {_} {_} {f} {h} {g} {i} → ∘-resp-≡ {F = f} {h} {g} {i}\n }\n\n{-\nmodule Agda where\n open import Category.Agda\n open import Category.Discrete\n\n D : ∀ o → Functor (Agda o) (Categories o o zero)\n D o = record \n { F₀ = Discrete\n ; F₁ = λ f → record \n { F₀ = λ x → f x\n ; F₁ = ≣-cong f\n ; identity = tt\n ; homomorphism = tt\n ; F-resp-≡ = λ _ → tt\n }\n ; identity = λ _ → refl tt\n ; homomorphism = λ _ → refl tt\n ; F-resp-≡ = F-resp-≡′\n }\n where\n F-resp-≡′ : {A B : Set o} {F G : A → B} → (∀ x → F x ≣ G x) → ∀ {X Y : A} (f : X ≣ Y) → [ Discrete B ] ≣-cong F f ∼ ≣-cong G f\n F-resp-≡′ {A} {B} {F} {G} f {x} ≣-refl = helper {F = F} {G} (f x)\n where\n helper : {F G : A → B} → {p q : B} → p ≣ q → [ Discrete B ] ≣-refl {x = p} ∼ ≣-refl {x = q}\n helper ≣-refl = refl tt\n\n Ob : ∀ o → Functor (Categories o o zero) (Agda o)\n Ob o = record \n { F₀ = Category.Obj\n ; F₁ = Functor.F₀\n ; identity = λ _ → ≣-refl\n ; homomorphism = λ _ → ≣-refl\n ; F-resp-≡ = λ {_} {_} {F} {G} → F-resp-≡′ {F = F} {G}\n }\n where\n F-resp-≡′ : {A B : Category o o zero} {F G : Functor A B} \n → ({X Y : Category.Obj A} (f : Category.Hom A X Y) → [ B ] Functor.F₁ F f ∼ Functor.F₁ G f)\n → ((x : Category.Obj A) → Functor.F₀ F x ≣ Functor.F₀ G x)\n F-resp-≡′ {A} {B} {F} {G} F∼G x = helper (F∼G (Category.id A {x}))\n where\n helper : ∀ {X Y} {p : Category.Hom B X X} {q : Category.Hom B Y Y} → [ B ] p ∼ q → X ≣ Y\n helper (refl q) = ≣-refl\n\n open import Category.Adjunction\n\n D⊣Ob : ∀ o → Adjunction (D o) (Ob o)\n D⊣Ob o = record \n { unit = record \n { η = λ _ x → x\n ; commute = λ _ _ → ≣-refl\n }\n ; counit = record \n { η = λ X → record \n { F₀ = λ x → x\n ; F₁ = counit-id′ {X}\n ; identity = IsEquivalence.refl (Category.equiv X)\n ; homomorphism = {!!}\n ; F-resp-≡ = {!!}\n }\n ; commute = {!!}\n }\n ; zig = {!!}\n ; zag = λ _ → ≣-refl\n }\n where\n counit-id′ : {X : Category o o zero} → {A B : Category.Obj X} → A ≣ B → Category.Hom X A B\n counit-id′ {X} ≣-refl = Category.id X\n-}", "meta": {"hexsha": "19a91cb4927c49ec13974e9811c9a1fec42c3987", "size": 2748, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Categories.agda", "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 98, "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_issues_repo_path": "Categories/Categories.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_forks_repo_path": "Categories/Categories.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 23, "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "avg_line_length": 30.5333333333, "max_line_length": 130, "alphanum_fraction": 0.4672489083, "num_tokens": 1156, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9136765304654121, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.6267359239924201}} {"text": "module Categories.PushOuts where\n\nopen import Library\nopen import Categories\n\nopen Cat\n\nrecord Square {a}{b}{C : Cat {a}{b}}{X Y Z}(f : Hom C Z X)(g : Hom C Z Y) : Set (a ⊔ b) where\n constructor square\n field W : Obj C\n h : Hom C X W\n k : Hom C Y W\n scom : comp C h f ≅ comp C k g\n\nrecord SqMap {a}{b}{C : Cat {a}{b}}{X Y Z : Obj C}{f : Hom C Z X}{g : Hom C Z Y}\n (sq sq' : Square {a}{b}{C} f g) : Set (a ⊔ b) where\n constructor sqmap\n open Square\n field sqMor : Hom C (W sq) (W sq')\n leftTr : comp C sqMor (h sq) ≅ h sq'\n rightTr : comp C sqMor (k sq) ≅ k sq'\nopen SqMap\n\nrecord PushOut {a}{b}{C : Cat {a}{b}}{X Y Z}(f : Hom C Z X)(g : Hom C Z Y) : Set (a ⊔ b) where\n constructor pushout\n field sq : Square {a}{b}{C} f g\n uniqPush : (sq' : Square f g) → Σ (SqMap sq sq')\n \\ u → (u' : SqMap sq sq') → sqMor u ≅ sqMor u'\n \n", "meta": {"hexsha": "4dd46dfb2607ce0e84edddee3af5691eda962c5d", "size": 917, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/PushOuts.agda", "max_stars_repo_name": "jmchapman/Relative-Monads", "max_stars_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 21, "max_stars_repo_stars_event_min_datetime": "2015-07-30T01:25:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-13T18:02:18.000Z", "max_issues_repo_path": "Categories/PushOuts.agda", "max_issues_repo_name": "jmchapman/Relative-Monads", "max_issues_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:12:33.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-29T09:50:26.000Z", "max_forks_repo_path": "Categories/PushOuts.agda", "max_forks_repo_name": "jmchapman/Relative-Monads", "max_forks_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-04T21:33:13.000Z", "avg_line_length": 30.5666666667, "max_line_length": 94, "alphanum_fraction": 0.5223555071, "num_tokens": 347, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9136765210631688, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.626735911677062}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Pointwise equality over lists using propositional equality\n------------------------------------------------------------------------\n\n-- Note think carefully about using this module as pointwise\n-- propositional equality can usually be replaced with propositional\n-- equality.\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary\n\nmodule Data.List.Relation.Binary.Equality.Propositional {a} {A : Set a} where\n\nopen import Data.List.Base\nimport Data.List.Relation.Binary.Equality.Setoid as SetoidEquality\nopen import Relation.Binary.PropositionalEquality as P using (_≡_)\n\n------------------------------------------------------------------------\n-- Re-export everything from setoid equality\n\nopen SetoidEquality (P.setoid A) public\n\n------------------------------------------------------------------------\n-- ≋ is propositional\n\n≋⇒≡ : _≋_ ⇒ _≡_\n≋⇒≡ [] = P.refl\n≋⇒≡ (P.refl ∷ xs≈ys) = P.cong (_ ∷_) (≋⇒≡ xs≈ys)\n\n≡⇒≋ : _≡_ ⇒ _≋_\n≡⇒≋ P.refl = ≋-refl\n", "meta": {"hexsha": "1a9c993fbbfd08efbead8128d7623f6ab381ba06", "size": 1079, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Equality/Propositional.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Equality/Propositional.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Equality/Propositional.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 30.8285714286, "max_line_length": 77, "alphanum_fraction": 0.5115848007, "num_tokens": 258, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9005297887874625, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.626731197768347}} {"text": "\n-- (Γ ⇒ Δ ∪ · A) → (Γ ⇒ Δ ∪ · (A ∨ B))\n-- The conclusion (A ∨ B) is the principal/major formula of the rule.\n-- The premiss A is the active/minor formula of the rule\n-- Γ, Δ is the side formulas of the rule.\n\n-- Γ ⇒ Δ\n-- LHS Γ is the antecedent of the sequent.\n-- RHS Γ is the consequent of the sequent.\n", "meta": {"hexsha": "9e907041c8b81d70ecc46e6c4588a83a2b259d07", "size": 305, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Formalization/PredicateLogic/Minimal/SequentCalculus.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Formalization/PredicateLogic/Minimal/SequentCalculus.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Formalization/PredicateLogic/Minimal/SequentCalculus.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.5, "max_line_length": 69, "alphanum_fraction": 0.6295081967, "num_tokens": 104, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.900529778109184, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.6267311903367102}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties of All predicate transformer for fresh lists\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.List.Fresh.Relation.Unary.All.Properties where\n\nopen import Level using (Level; _⊔_; Lift)\nopen import Data.Empty\nopen import Data.Nat.Base using (ℕ; zero; suc)\nopen import Data.Product using (_,_)\nopen import Function using (_∘′_)\nopen import Relation.Nullary\nopen import Relation.Unary as U\nopen import Relation.Binary as B using (Rel)\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl; cong)\n\nopen import Data.List.Fresh using (List#; []; cons; _∷#_; _#_)\nopen import Data.List.Fresh.Relation.Unary.All\n\nprivate\n variable\n a p r : Level\n A : Set a\n\nmodule _ {R : Rel A r} where\n\n fromAll : ∀ {x} {xs : List# A R} → All (R x) xs → x # xs\n fromAll [] = _\n fromAll (p ∷ ps) = p , fromAll ps\n\n toAll : ∀ {x} {xs : List# A R} → x # xs → All (R x) xs\n toAll {xs = []} _ = []\n toAll {xs = a ∷# as} (p , ps) = p ∷ toAll ps\n\nmodule _ {R : Rel A r} {P : Pred A p} where\n\n append⁺ : {xs ys : List# A R} {ps : All (_# ys) xs} →\n All P xs → All P ys → All P (append xs ys ps)\n append⁺ [] pys = pys\n append⁺ (px ∷ pxs) pys = px ∷ append⁺ pxs pys\n", "meta": {"hexsha": "25e8cd006ddb7c84fa1085cf95b10041dd2a7ea9", "size": 1392, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/List/Fresh/Relation/Unary/All/Properties.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Data/List/Fresh/Relation/Unary/All/Properties.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Data/List/Fresh/Relation/Unary/All/Properties.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 30.9333333333, "max_line_length": 73, "alphanum_fraction": 0.555316092, "num_tokens": 410, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8962513759047847, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.6267077425985451}} {"text": "\nmodule Oscar.Data.Term.AlphaConversion {𝔣} (FunctionName : Set 𝔣) where\n\nopen import Oscar.Data.Term FunctionName\n\nopen import Oscar.Class.AlphaConversion\nopen import Oscar.Data.Equality\nopen import Oscar.Data.Fin\nopen import Oscar.Data.Vec\nopen import Oscar.Function\nopen import Oscar.Relation\n\nimport Oscar.Data.Term.AlphaConversion.internal FunctionName as ⋆\n\ninstance AlphaConversionFinTerm : AlphaConversion Fin Term\nAlphaConversion._◂_ AlphaConversionFinTerm = ⋆._◂_\nAlphaConversion.◂-identity AlphaConversionFinTerm = ⋆.◂-identity\nAlphaConversion.◂-associativity AlphaConversionFinTerm = ⋆.◂-associativity\nAlphaConversion.◂-extensionality AlphaConversionFinTerm = ⋆.◂-extensionality\n\ninstance AlphaConversionFinTerms : ∀ {N} → AlphaConversion Fin (Terms N)\nAlphaConversion._◂_ AlphaConversionFinTerms _ = ⋆._◂s_ _\nAlphaConversion.◂-identity AlphaConversionFinTerms = ⋆.◂s-identity\nAlphaConversion.◂-associativity AlphaConversionFinTerms _ _ = ⋆.◂s-associativity _ _\nAlphaConversion.◂-extensionality AlphaConversionFinTerms f≡̇g = ⋆.◂s-extensionality f≡̇g\n", "meta": {"hexsha": "5de82e1272690bbae9dc7de2cca6ba92d03f6ac7", "size": 1063, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-2/Oscar/Data/Term/AlphaConversion.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-2/Oscar/Data/Term/AlphaConversion.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-2/Oscar/Data/Term/AlphaConversion.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.8846153846, "max_line_length": 88, "alphanum_fraction": 0.8174976482, "num_tokens": 303, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8962513786759491, "lm_q2_score": 0.6992544085240402, "lm_q1q2_score": 0.6267077276849063}} {"text": "{-# OPTIONS --without-K #-}\nmodule sets.nat.ordering.properties where\n\nopen import function.isomorphism\nopen import sets.nat.core\nopen import sets.nat.ordering.lt\nopen import sets.nat.ordering.leq\nopen import hott.level.core\n\n<-≤-iso : ∀ {n m} → (n < m) ≅ (suc n ≤ m)\n<-≤-iso = record\n { to = f\n ; from = g\n ; iso₁ = λ _ → h1⇒prop <-level _ _\n ; iso₂ = λ _ → h1⇒prop ≤-level _ _ }\n where\n f : ∀ {n m} → n < m → suc n ≤ m\n f suc< = refl-≤\n f (n 0, then the constant c (s.t. c · m ≡ n) is also > 0\n∣s-untrunc : m ∣ suc n → Σ[ c ∈ ℕ ] (suc c) · m ≡ suc n\n∣s-untrunc ∣p∣ with ∣-untrunc ∣p∣\n... | (zero , p) = ⊥.rec (znots p)\n... | (suc c , p) = (c , p)\n\nm∣sn→m≤sn : m ∣ suc n → m ≤ suc n\nm∣sn→m≤sn {m} {n} = f ∘ ∣s-untrunc\n where f : Σ[ c ∈ ℕ ] (suc c) · m ≡ suc n → Σ[ c ∈ ℕ ] c + m ≡ suc n\n f (c , p) = (c · m) , (+-comm (c · m) m ∙ p)\n\nm∣n→m≤n : {m n : ℕ} → ¬ n ≡ 0 → m ∣ n → m ≤ n\nm∣n→m≤n {m = m} {n = n} p q =\n let n≡sd = suc-predℕ _ p\n m≤sd = m∣sn→m≤sn (subst (λ a → m ∣ a) n≡sd q)\n in subst (λ a → m ≤ a) (sym n≡sd) m≤sd\n\nm∣sn→z _ _ n k≰n\n\nP[1+n,n]≡[1+n]! : ∀ n → P (suc n) n ≡ (suc n) !\nP[1+n,n]≡[1+n]! n = begin-equality\n P (1 + n) n ≡⟨ cong (λ v → P v n) (+-comm 1 n) ⟩\n P (n + 1) n ≡⟨ sym $ *-identityʳ (P (n + 1) n) ⟩\n P (n + 1) n * 1 ≡⟨ sym $ P-split n 1 1 ⟩\n P (n + 1) (n + 1) ≡⟨ P[n,n]≡n! (n + 1) ⟩\n (n + 1) ! ≡⟨ cong (_!) (+-comm n 1) ⟩\n (1 + n) ! ∎\n\nP-split-∸-alternative : ∀ {m n o} → o ≤ m → o ≤ n → P m n ≡ P m o * P (m ∸ o) (n ∸ o)\nP-split-∸-alternative {m} {n} {o} o≤m o≤n = begin-equality\n P m n ≡⟨ sym $ cong₂ P o+p≡m o+q≡n ⟩\n P (o + p) (o + q) ≡⟨ P-split o p q ⟩\n P (o + p) o * P p q ≡⟨ cong (λ v → P v o * P p q) o+p≡m ⟩\n P m o * P p q ∎\n where\n p = m ∸ o\n q = n ∸ o\n o+p≡m : o + p ≡ m\n o+p≡m = m+[n∸m]≡n o≤m\n o+q≡n : o + q ≡ n\n o+q≡n = m+[n∸m]≡n o≤n\n\nP-split-∸ : ∀ m n o → P m (n + o) ≡ P m n * P (m ∸ n) o\nP-split-∸ m n o with n ≤? m\n... | yes n≤m = begin-equality\n P m (n + o) ≡⟨ sym $ cong (λ v → P v (n + o)) n+p≡m ⟩\n P (n + p) (n + o) ≡⟨ P-split n p o ⟩\n P (n + p) n * P p o ≡⟨ cong (λ v → P v n * P p o) n+p≡m ⟩\n P m n * P p o ∎\n where\n p = m ∸ n\n n+p≡m : n + p ≡ m\n n+p≡m = m+[n∸m]≡n n≤m\n... | no n≰m = begin-equality\n P m (n + o) ≡⟨ n n≰m\n m k≰n\n\nP[n,k]≤n^k : ∀ n k → P n k ≤ n ^ k\nP[n,k]≤n^k n 0 = ≤-refl\nP[n,k]≤n^k 0 (suc k) = ≤-refl\nP[n,k]≤n^k (suc n) (suc k) = begin\n suc n * P n k ≤⟨ *-monoʳ-≤ (suc n) $ P[n,k]≤n^k n k ⟩\n suc n * n ^ k ≤⟨ *-monoʳ-≤ (suc n) $ Lemma.^-monoˡ-≤ k $ ≤-step ≤-refl ⟩\n suc n * suc n ^ k ≡⟨⟩\n suc n ^ suc k ∎\n\nk≤n⇒k!≤P[n,k] : ∀ {n k} → k ≤ n → k ! ≤ P n k\nk≤n⇒k!≤P[n,k] {n} {0} k≤n = ≤-refl\nk≤n⇒k!≤P[n,k] {suc n} {suc k} (s≤s k≤n) = begin\n suc k * k ! ≤⟨ *-mono-≤ (s≤s k≤n) (k≤n⇒k!≤P[n,k] k≤n) ⟩\n suc n * P n k ∎\n\nP[n,k]≤n! : ∀ n k → P n k ≤ n !\nP[n,k]≤n! n 0 = 1≤n! n\nP[n,k]≤n! 0 (suc k) = ≤-step ≤-refl\nP[n,k]≤n! (suc n) (suc k) = begin\n suc n * P n k ≤⟨ *-monoʳ-≤ (suc n) (P[n,k]≤n! n k) ⟩\n suc n * n ! ∎\n\nP-monoʳ-< : ∀ {n k r} → 2 ≤ n → r < n → k < r → P n k < P n r\nP-monoʳ-< {suc zero} {k} {r} (s≤s ()) r k≰m) ⟩\n 0 ≤⟨ z≤n ⟩\n P n k ∎\n\nP[n,k]≡product[take[k,downFrom[1+n]]] :\n ∀ {n k} → k ≤ n → P n k ≡ product (take k (downFrom (suc n)))\nP[n,k]≡product[take[k,downFrom[1+n]]] {n} {zero} k≤n = refl\nP[n,k]≡product[take[k,downFrom[1+n]]] {suc n} {suc k} (s≤s k≤n) = begin-equality\n suc n * P n k ≡⟨ cong (suc n *_) $ P[n,k]≡product[take[k,downFrom[1+n]]] k≤n ⟩\n suc n * product (take k (downFrom (suc n))) ∎\n\n------------------------------------------------------------------------\n-- Properties of CRec\n\n-- proved by induction and P[1+n,1+k]≡[1+k]*P[n,k]+P[n,1+k]\nCRec[n,k]*k!≡P[n,k] : ∀ n k → CRec n k * k ! ≡ P n k\nCRec[n,k]*k!≡P[n,k] n 0 = refl\nCRec[n,k]*k!≡P[n,k] 0 (suc k) = refl\nCRec[n,k]*k!≡P[n,k] (suc n) (suc k) = begin-equality\n CRec (suc n) (suc k) * suc k ! ≡⟨⟩\n (CRec n k + CRec n (suc k)) * (suc k * k !) ≡⟨ Lemma.lemma₅ (CRec n k) (CRec n (suc k)) (suc k) (k !) ⟩\n suc k * (CRec n k * k !) + CRec n (suc k) * suc k ! ≡⟨ cong₂ _+_ (cong (suc k *_) $ CRec[n,k]*k!≡P[n,k] n k) (CRec[n,k]*k!≡P[n,k] n (suc k)) ⟩\n suc k * P n k + P n (suc k) ≡⟨ sym $ P[1+n,1+k]≡[1+k]*P[n,k]+P[n,1+k] n k ⟩\n P (suc n) (suc k) ∎\n\n[1+k]*CRec[1+n,1+k]≡[1+n]*CRec[n,k] : ∀ n k → suc k * CRec (suc n) (suc k) ≡ suc n * CRec n k\n[1+k]*CRec[1+n,1+k]≡[1+n]*CRec[n,k] n k = Lemma.*-cancelʳ-≡′\n (suc k * CRec (suc n) (suc k)) (suc n * CRec n k) (False[n!≟0] k) $ begin-equality\n suc k * CRec (suc n) (suc k) * k ! ≡⟨ sym $ Lemma.lemma₈ (CRec (suc n) (suc k)) (suc k) (k !) ⟩\n CRec (suc n) (suc k) * (suc k) ! ≡⟨ CRec[n,k]*k!≡P[n,k] (suc n) (suc k) ⟩\n P (suc n) (suc k) ≡⟨⟩\n suc n * P n k ≡⟨ sym $ cong (suc n *_) $ CRec[n,k]*k!≡P[n,k] n k ⟩\n suc n * (CRec n k * k !) ≡⟨ sym $ *-assoc (suc n) (CRec n k) (k !) ⟩\n suc n * CRec n k * k ! ∎\n\nCRec[1+n,1+k]≡[CRec[n,k]*[1+n]]/[1+k] : ∀ n k →\n CRec (suc n) (suc k) ≡ (CRec n k * suc n) / suc k\nCRec[1+n,1+k]≡[CRec[n,k]*[1+n]]/[1+k] n k = Lemma.m*n≡o⇒m≡o/n\n (CRec (suc n) (suc k)) (suc k) (CRec n k * suc n) tt ( begin-equality\n CRec (suc n) (suc k) * suc k ≡⟨ *-comm (CRec (suc n) (suc k)) (suc k) ⟩\n suc k * CRec (suc n) (suc k) ≡⟨ [1+k]*CRec[1+n,1+k]≡[1+n]*CRec[n,k] n k ⟩\n suc n * CRec n k ≡⟨ *-comm (suc n) (CRec n k) ⟩\n CRec n k * suc n ∎ )\n\n------------------------------------------------------------------------\n-- Properties of C\n\nC[n,k]≡CRec[n,k] : ∀ n k → C n k ≡ CRec n k\nC[n,k]≡CRec[n,k] n zero = refl\nC[n,k]≡CRec[n,k] zero (suc k) = refl\nC[n,k]≡CRec[n,k] (suc n) (suc k) = begin-equality\n (C n k * suc n) / suc k\n ≡⟨ cong (λ v → (v * suc n) / suc k) $ C[n,k]≡CRec[n,k] n k ⟩\n (CRec n k * suc n) / suc k\n ≡⟨ sym $ CRec[1+n,1+k]≡[CRec[n,k]*[1+n]]/[1+k] n k ⟩\n CRec (suc n) (suc k)\n ∎\n\n-- TODO prove directly\n-- P n k ∣ k !\nC[n,k]*k!≡P[n,k] : ∀ n k → C n k * k ! ≡ P n k\nC[n,k]*k!≡P[n,k] n k = trans (cong (_* k !) (C[n,k]≡CRec[n,k] n k)) (CRec[n,k]*k!≡P[n,k] n k)\n\nC[n,k]≡P[n,k]/k! : ∀ n k → C n k ≡ _div_ (P n k) (k !) {False[n!≟0] k}\nC[n,k]≡P[n,k]/k! n k = Lemma.m*n≡o⇒m≡o/n _ _ _ (False[n!≟0] k) (C[n,k]*k!≡P[n,k] n k)\n\nC[1+n,1+k]≡C[n,k]+C[n,1+k] : ∀ n k → C (suc n) (suc k) ≡ C n k + C n (suc k)\nC[1+n,1+k]≡C[n,k]+C[n,1+k] n k = begin-equality\n C (suc n) (suc k) ≡⟨ C[n,k]≡CRec[n,k] (suc n) (suc k) ⟩\n CRec n k + CRec n (suc k) ≡⟨ sym $ cong₂ _+_ (C[n,k]≡CRec[n,k] n k) (C[n,k]≡CRec[n,k] n (suc k)) ⟩\n C n k + C n (suc k) ∎\n\nn k≰n\n\n-- -- C n k = ((n + 1 - k) / k) * C n (k - 1)\nC[n,1+k]≡[C[n,k]*[n∸k]]/[1+k] : ∀ n k → C n (1 + k) ≡ (C n k * (n ∸ k)) / (1 + k)\nC[n,1+k]≡[C[n,k]*[n∸k]]/[1+k] n k =\n Lemma.m*n≡o⇒m≡o/n (C n (suc k)) (suc k) (C n k * (n ∸ k)) tt (C[n,1+k]*[1+k]≡C[n,k]*[n∸k] n k)\n\n-- C n k ≡ (n / k) * C (n - 1) (k - 1)\n-- proved by C[n,k]*k!≡P[n,k]\n[1+k]*C[1+n,1+k]≡[1+n]*C[n,k] : ∀ n k → suc k * C (suc n) (suc k) ≡ suc n * C n k\n[1+k]*C[1+n,1+k]≡[1+n]*C[n,k] n k = Lemma.*-cancelʳ-≡′\n (suc k * C (suc n) (suc k)) (suc n * C n k) (False[n!≟0] k) $ begin-equality\n suc k * C (suc n) (suc k) * k ! ≡⟨ sym $ Lemma.lemma₈ (C (suc n) (suc k)) (suc k) (k !) ⟩\n C (suc n) (suc k) * (suc k) ! ≡⟨ C[n,k]*k!≡P[n,k] (suc n) (suc k) ⟩\n P (suc n) (suc k) ≡⟨⟩\n suc n * P n k ≡⟨ cong (suc n *_) $ sym $ C[n,k]*k!≡P[n,k] n k ⟩\n suc n * (C n k * k !) ≡⟨ sym $ *-assoc (suc n) (C n k) (k !) ⟩\n suc n * C n k * k ! ∎\n\n-- Multiply both sides by n ! * o !\nC[m,n]*C[m∸n,o]≡C[m,o]*C[m∸o,n] : ∀ m n o → C m n * C (m ∸ n) o ≡ C m o * C (m ∸ o) n\nC[m,n]*C[m∸n,o]≡C[m,o]*C[m∸o,n] m n o =\n Lemma.*-cancelʳ-≡′ (C m n * C (m ∸ n) o) (C m o * C (m ∸ o) n) (False[n!≟0] n) $\n Lemma.*-cancelʳ-≡′ (C m n * C (m ∸ n) o * n !) (C m o * C (m ∸ o) n * n !) (False[n!≟0] o) $ begin-equality\n C m n * C (m ∸ n) o * n ! * o ! ≡⟨ Lemma.lemma₁₀ (C m n) (C (m ∸ n) o) (n !) (o !) ⟩\n (C m n * n !) * (C (m ∸ n) o * o !) ≡⟨ cong₂ _*_ (C[n,k]*k!≡P[n,k] m n) (C[n,k]*k!≡P[n,k] (m ∸ n) o) ⟩\n P m n * P (m ∸ n) o ≡⟨ P-slide-∸ m n o ⟩\n P m o * P (m ∸ o) n ≡⟨ sym $ cong₂ _*_ (C[n,k]*k!≡P[n,k] m o) (C[n,k]*k!≡P[n,k] (m ∸ o) n) ⟩\n (C m o * o !) * (C (m ∸ o) n * n !) ≡⟨ Lemma.lemma₁₁ (C m o) (o !) (C (m ∸ o) n) (n !) ⟩\n C m o * C (m ∸ o) n * n ! * o ! ∎\n\nk≤n⇒1≤C[n,k] : ∀ {n k} → k ≤ n → 1 ≤ C n k\nk≤n⇒1≤C[n,k] {n} {k} k≤n = Lemma.*-cancelʳ-≤′ 1 (C n k) (False[n!≟0] k) $ begin\n 1 * k ! ≡⟨ *-identityˡ (k !) ⟩\n k ! ≤⟨ k≤n⇒k!≤P[n,k] k≤n ⟩\n P n k ≡⟨ sym $ C[n,k]*k!≡P[n,k] n k ⟩\n C n k * k ! ∎\n\nk≤n⇒C[n,k]≢0 : ∀ {n k} → k ≤ n → C n k ≢ 0\nk≤n⇒C[n,k]≢0 {n} {k} k≤n = Lemma.1≤n⇒n≢0 $ k≤n⇒1≤C[n,k] k≤n\n\nC[n,k]≡0⇒n k≰n)\n\n------------------------------------------------------------------------\n-- Properties of double factorial\n\n!!-! : ∀ n → suc n !! * n !! ≡ suc n !\n!!-! 0 = refl\n!!-! 1 = refl\n!!-! (suc (suc n)) = begin-equality\n (3 + n) !! * (2 + n) !! ≡⟨⟩\n (3 + n) * (1 + n) !! * ((2 + n) * n !!) ≡⟨ Lemma.lemma₉ (3 + n) (suc n !!) (2 + n) (n !!) ⟩\n (3 + n) * (2 + n) * ((1 + n) !! * n !!) ≡⟨ cong ((3 + n) * (2 + n) *_) $ !!-! n ⟩\n (3 + n) * (2 + n) * (suc n !) ≡⟨ *-assoc (3 + n) (2 + n) (suc n !) ⟩\n (3 + n) ! ∎\n\n[2*n]!!≡n!*2^n : ∀ n → (2 * n) !! ≡ n ! * 2 ^ n\n[2*n]!!≡n!*2^n 0 = refl\n[2*n]!!≡n!*2^n (suc n) = begin-equality\n (2 * (1 + n)) !! ≡⟨ cong (_!!) $ *-distribˡ-+ 2 1 n ⟩\n (2 + (2 * n)) !! ≡⟨⟩\n (2 + 2 * n) * (2 * n) !! ≡⟨ cong ((2 + 2 * n) *_) $ [2*n]!!≡n!*2^n n ⟩\n (2 + 2 * n) * (n ! * 2 ^ n) ≡⟨ cong (_* (n ! * 2 ^ n)) $ trans (sym $ *-distribˡ-+ 2 1 n) (*-comm 2 (suc n)) ⟩\n (suc n * 2) * ((n !) * 2 ^ n) ≡⟨ Lemma.lemma₉ (suc n) 2 (n !) (2 ^ n) ⟩\n (suc n) ! * 2 ^ suc n ∎\n\n------------------------------------------------------------------------\n-- Properties of unsigned Stirling number of the first kind\n\nn & < b > )\n\ntest12 = accept test11 record { state = < a > & < b > ; is-derived = unit } ( a ∷ b ∷ [] )\ntest13 = accept test11 record { state = < a > & < b > ; is-derived = unit } ( a ∷ a ∷ [] )\n\ntest14 = regex-match ( ( < a > & < b > ) * ) ( a ∷ b ∷ a ∷ a ∷ [] )\n\ntest15 = regex-derive ( ( < a > & < b > ) * ∷ [] )\ntest16 = regex-derive test15\ntest17 : regex-derive test16 ≡ test16\ntest17 = refl\n", "meta": {"hexsha": "23621f6e4d1a6eed7aa690d0c0084c8e1992797a", "size": 1593, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/deriveUtil.agda", "max_stars_repo_name": "shinji-kono/automaton-in-agda", "max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/deriveUtil.agda", "max_issues_repo_name": "shinji-kono/automaton-in-agda", "max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/deriveUtil.agda", "max_forks_repo_name": "shinji-kono/automaton-in-agda", "max_forks_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.7571428571, "max_line_length": 91, "alphanum_fraction": 0.578782172, "num_tokens": 597, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339676722393, "lm_q2_score": 0.7461389986757757, "lm_q1q2_score": 0.6265582617930008}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Rational numbers\n------------------------------------------------------------------------\n\nmodule Data.Rational where\n\nimport Algebra\nimport Data.Bool.Properties as Bool\nopen import Function\nopen import Data.Integer as ℤ using (ℤ; ∣_∣; +_; -_)\nopen import Data.Integer.Divisibility as ℤDiv using (Coprime)\nimport Data.Integer.Properties as ℤ\nopen import Data.Nat.Divisibility as ℕDiv using (_∣_)\nimport Data.Nat.Coprimality as C\nopen import Data.Nat as ℕ using (ℕ; zero; suc)\nopen import Data.Sum\nimport Level\nopen import Relation.Nullary.Decidable\nopen import Relation.Nullary\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as P\n using (_≡_; refl; cong; cong₂)\nopen P.≡-Reasoning\n\n------------------------------------------------------------------------\n-- The definition\n\n-- Rational numbers in reduced form. Note that there is exactly one\n-- representative for every rational number. (This is the reason for\n-- using \"True\" below. If Agda had proof irrelevance, then it would\n-- suffice to use \"isCoprime : Coprime numerator denominator\".)\n\nrecord ℚ : Set where\n field\n numerator : ℤ\n denominator-1 : ℕ\n isCoprime : True (C.coprime? ∣ numerator ∣ (suc denominator-1))\n\n denominator : ℤ\n denominator = + suc denominator-1\n\n coprime : Coprime numerator denominator\n coprime = toWitness isCoprime\n\n-- Constructs rational numbers. The arguments have to be in reduced\n-- form.\n\ninfixl 7 _÷_\n\n_÷_ : (numerator : ℤ) (denominator : ℕ)\n {coprime : True (C.coprime? ∣ numerator ∣ denominator)}\n {≢0 : False (ℕ._≟_ denominator 0)} →\n ℚ\n(n ÷ zero) {≢0 = ()}\n(n ÷ suc d) {c} =\n record { numerator = n; denominator-1 = d; isCoprime = c }\n\nprivate\n\n -- Note that the implicit arguments do not need to be given for\n -- concrete inputs:\n\n 0/1 : ℚ\n 0/1 = + 0 ÷ 1\n\n -½ : ℚ\n -½ = - + 1 ÷ 2\n\n------------------------------------------------------------------------\n-- Equality\n\n-- Equality of rational numbers.\n\ninfix 4 _≃_\n\n_≃_ : Rel ℚ Level.zero\np ≃ q = numerator p ℤ.* denominator q ≡\n numerator q ℤ.* denominator p\n where open ℚ\n\n-- _≃_ coincides with propositional equality.\n\n≡⇒≃ : _≡_ ⇒ _≃_\n≡⇒≃ refl = refl\n\n≃⇒≡ : _≃_ ⇒ _≡_\n≃⇒≡ {i = p} {j = q} =\n helper (numerator p) (denominator-1 p) (isCoprime p)\n (numerator q) (denominator-1 q) (isCoprime q)\n where\n open ℚ\n\n helper : ∀ n₁ d₁ c₁ n₂ d₂ c₂ →\n n₁ ℤ.* + suc d₂ ≡ n₂ ℤ.* + suc d₁ →\n (n₁ ÷ suc d₁) {c₁} ≡ (n₂ ÷ suc d₂) {c₂}\n helper n₁ d₁ c₁ n₂ d₂ c₂ eq\n with Poset.antisym ℕDiv.poset 1+d₁∣1+d₂ 1+d₂∣1+d₁\n where\n 1+d₁∣1+d₂ : suc d₁ ∣ suc d₂\n 1+d₁∣1+d₂ = ℤDiv.coprime-divisor (+ suc d₁) n₁ (+ suc d₂)\n (C.sym $ toWitness c₁) $\n ℕDiv.divides ∣ n₂ ∣ (begin\n ∣ n₁ ℤ.* + suc d₂ ∣ ≡⟨ cong ∣_∣ eq ⟩\n ∣ n₂ ℤ.* + suc d₁ ∣ ≡⟨ ℤ.abs-*-commute n₂ (+ suc d₁) ⟩\n ∣ n₂ ∣ ℕ.* suc d₁ ∎)\n\n 1+d₂∣1+d₁ : suc d₂ ∣ suc d₁\n 1+d₂∣1+d₁ = ℤDiv.coprime-divisor (+ suc d₂) n₂ (+ suc d₁)\n (C.sym $ toWitness c₂) $\n ℕDiv.divides ∣ n₁ ∣ (begin\n ∣ n₂ ℤ.* + suc d₁ ∣ ≡⟨ cong ∣_∣ (P.sym eq) ⟩\n ∣ n₁ ℤ.* + suc d₂ ∣ ≡⟨ ℤ.abs-*-commute n₁ (+ suc d₂) ⟩\n ∣ n₁ ∣ ℕ.* suc d₂ ∎)\n\n helper n₁ d c₁ n₂ .d c₂ eq | refl with ℤ.cancel-*-right\n n₁ n₂ (+ suc d) (λ ()) eq\n helper n d c₁ .n .d c₂ eq | refl | refl with Bool.proof-irrelevance c₁ c₂\n helper n d c .n .d .c eq | refl | refl | refl = refl\n\n------------------------------------------------------------------------\n-- Equality is decidable\n\ninfix 4 _≟_\n\n_≟_ : Decidable {A = ℚ} _≡_\np ≟ q with ℚ.numerator p ℤ.* ℚ.denominator q ℤ.≟\n ℚ.numerator q ℤ.* ℚ.denominator p\np ≟ q | yes pq≃qp = yes (≃⇒≡ pq≃qp)\np ≟ q | no ¬pq≃qp = no (¬pq≃qp ∘ ≡⇒≃)\n\n------------------------------------------------------------------------\n-- Ordering\n\ninfix 4 _≤_ _≤?_\n\ndata _≤_ : ℚ → ℚ → Set where\n *≤* : ∀ {p q} →\n ℚ.numerator p ℤ.* ℚ.denominator q ℤ.≤\n ℚ.numerator q ℤ.* ℚ.denominator p →\n p ≤ q\n\ndrop-*≤* : ∀ {p q} → p ≤ q →\n ℚ.numerator p ℤ.* ℚ.denominator q ℤ.≤\n ℚ.numerator q ℤ.* ℚ.denominator p\ndrop-*≤* (*≤* pq≤qp) = pq≤qp\n\n_≤?_ : Decidable _≤_\np ≤? q with ℚ.numerator p ℤ.* ℚ.denominator q ℤ.≤?\n ℚ.numerator q ℤ.* ℚ.denominator p\np ≤? q | yes pq≤qp = yes (*≤* pq≤qp)\np ≤? q | no ¬pq≤qp = no (λ { (*≤* pq≤qp) → ¬pq≤qp pq≤qp })\n\ndecTotalOrder : DecTotalOrder _ _ _\ndecTotalOrder = record\n { Carrier = ℚ\n ; _≈_ = _≡_\n ; _≤_ = _≤_\n ; isDecTotalOrder = record\n { isTotalOrder = record\n { isPartialOrder = record\n { isPreorder = record\n { isEquivalence = P.isEquivalence\n ; reflexive = refl′\n ; trans = trans\n }\n ; antisym = antisym\n }\n ; total = total\n }\n ; _≟_ = _≟_\n ; _≤?_ = _≤?_\n }\n }\n where\n module ℤO = DecTotalOrder ℤ.decTotalOrder\n\n refl′ : _≡_ ⇒ _≤_\n refl′ refl = *≤* ℤO.refl\n\n trans : Transitive _≤_\n trans {i = p} {j = q} {k = r} (*≤* le₁) (*≤* le₂)\n = *≤* (ℤ.cancel-*-+-right-≤ _ _ _\n (lemma\n (ℚ.numerator p) (ℚ.denominator p)\n (ℚ.numerator q) (ℚ.denominator q)\n (ℚ.numerator r) (ℚ.denominator r)\n (ℤ.*-+-right-mono (ℚ.denominator-1 r) le₁)\n (ℤ.*-+-right-mono (ℚ.denominator-1 p) le₂)))\n where\n open Algebra.CommutativeRing ℤ.commutativeRing\n\n lemma : ∀ n₁ d₁ n₂ d₂ n₃ d₃ →\n n₁ ℤ.* d₂ ℤ.* d₃ ℤ.≤ n₂ ℤ.* d₁ ℤ.* d₃ →\n n₂ ℤ.* d₃ ℤ.* d₁ ℤ.≤ n₃ ℤ.* d₂ ℤ.* d₁ →\n n₁ ℤ.* d₃ ℤ.* d₂ ℤ.≤ n₃ ℤ.* d₁ ℤ.* d₂\n lemma n₁ d₁ n₂ d₂ n₃ d₃\n rewrite *-assoc n₁ d₂ d₃\n | *-comm d₂ d₃\n | sym (*-assoc n₁ d₃ d₂)\n | *-assoc n₃ d₂ d₁\n | *-comm d₂ d₁\n | sym (*-assoc n₃ d₁ d₂)\n | *-assoc n₂ d₁ d₃\n | *-comm d₁ d₃\n | sym (*-assoc n₂ d₃ d₁)\n = ℤO.trans\n\n antisym : Antisymmetric _≡_ _≤_\n antisym (*≤* le₁) (*≤* le₂) = ≃⇒≡ (ℤO.antisym le₁ le₂)\n\n total : Total _≤_\n total p q =\n [ inj₁ ∘′ *≤* , inj₂ ∘′ *≤* ]′\n (ℤO.total (ℚ.numerator p ℤ.* ℚ.denominator q)\n (ℚ.numerator q ℤ.* ℚ.denominator p))\n", "meta": {"hexsha": "66be57e0141ea0b7418a1ed2bd05c42ae5c90a10", "size": 6515, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Rational.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Rational.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Rational.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.8853211009, "max_line_length": 76, "alphanum_fraction": 0.4956254797, "num_tokens": 2397, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339596505965, "lm_q2_score": 0.7461389817407016, "lm_q1q2_score": 0.6265582415867834}} {"text": "------------------------------------------------------------------------\n-- Rational numbers\n------------------------------------------------------------------------\n\nmodule Data.Rational where\n\nopen import Data.Bool.Properties\nopen import Data.Function\nopen import Data.Integer hiding (suc) renaming (_*_ to _ℤ*_)\nopen import Data.Integer.Divisibility as ℤDiv using (Coprime)\nimport Data.Integer.Properties as ℤ\nopen import Data.Nat.Divisibility as ℕDiv using (_∣_)\nimport Data.Nat.Coprimality as C\nopen import Data.Nat as ℕ renaming (_*_ to _ℕ*_)\nopen import Relation.Nullary.Decidable\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as PropEq\nopen ≡-Reasoning\n\n------------------------------------------------------------------------\n-- The definition\n\n-- Rational numbers in reduced form.\n\nrecord ℚ : Set where\n field\n numerator : ℤ\n denominator-1 : ℕ\n isCoprime : True (C.coprime? ∣ numerator ∣ (suc denominator-1))\n\n denominator : ℤ\n denominator = + suc denominator-1\n\n coprime : Coprime numerator denominator\n coprime = witnessToTruth isCoprime\n\n-- Constructs rational numbers. The arguments have to be in reduced\n-- form.\n\ninfixl 7 _÷_\n\n_÷_ : (numerator : ℤ) (denominator : ℕ)\n {coprime : True (C.coprime? ∣ numerator ∣ denominator)}\n {≢0 : False (ℕ._≟_ denominator 0)} →\n ℚ\n(n ÷ zero) {≢0 = ()}\n(n ÷ suc d) {c} =\n record { numerator = n; denominator-1 = d; isCoprime = c }\n\nprivate\n\n -- Note that the implicit arguments do not need to be given for\n -- concrete inputs:\n\n 0/1 : ℚ\n 0/1 = + 0 ÷ 1\n\n -½ : ℚ\n -½ = - + 1 ÷ 2\n\n------------------------------------------------------------------------\n-- Equality\n\n-- Equality of rational numbers.\n\ninfix 4 _≃_\n\n_≃_ : Rel ℚ\np ≃ q = P.numerator ℤ* Q.denominator ≡\n Q.numerator ℤ* P.denominator\n where module P = ℚ p; module Q = ℚ q\n\n-- _≃_ coincides with propositional equality.\n\n≡⇒≃ : _≡_ ⇒ _≃_\n≡⇒≃ refl = refl\n\n≃⇒≡ : _≃_ ⇒ _≡_\n≃⇒≡ {p} {q} = helper P.numerator P.denominator-1 P.isCoprime\n Q.numerator Q.denominator-1 Q.isCoprime\n where\n module P = ℚ p; module Q = ℚ q\n\n helper : ∀ n₁ d₁ c₁ n₂ d₂ c₂ →\n n₁ ℤ* + suc d₂ ≡ n₂ ℤ* + suc d₁ →\n (n₁ ÷ suc d₁) {c₁} ≡ (n₂ ÷ suc d₂) {c₂}\n helper n₁ d₁ c₁ n₂ d₂ c₂ eq\n with Poset.antisym ℕDiv.poset 1+d₁∣1+d₂ 1+d₂∣1+d₁\n where\n 1+d₁∣1+d₂ : suc d₁ ∣ suc d₂\n 1+d₁∣1+d₂ = ℤDiv.coprime-divisor (+ suc d₁) n₁ (+ suc d₂)\n (C.sym $ witnessToTruth c₁) $\n ℕDiv.divides ∣ n₂ ∣ (begin\n ∣ n₁ ℤ* + suc d₂ ∣ ≡⟨ cong ∣_∣ eq ⟩\n ∣ n₂ ℤ* + suc d₁ ∣ ≡⟨ ℤ.abs-*-commute n₂ (+ suc d₁) ⟩\n ∣ n₂ ∣ ℕ* suc d₁ ∎)\n\n 1+d₂∣1+d₁ : suc d₂ ∣ suc d₁\n 1+d₂∣1+d₁ = ℤDiv.coprime-divisor (+ suc d₂) n₂ (+ suc d₁)\n (C.sym $ witnessToTruth c₂) $\n ℕDiv.divides ∣ n₁ ∣ (begin\n ∣ n₂ ℤ* + suc d₁ ∣ ≡⟨ cong ∣_∣ (PropEq.sym eq) ⟩\n ∣ n₁ ℤ* + suc d₂ ∣ ≡⟨ ℤ.abs-*-commute n₁ (+ suc d₂) ⟩\n ∣ n₁ ∣ ℕ* suc d₂ ∎)\n\n helper n₁ d c₁ n₂ .d c₂ eq | refl with ℤ.cancel-*-right\n n₁ n₂ (+ suc d) (λ ()) eq\n helper n d c₁ .n .d c₂ eq | refl | refl with proof-irrelevance c₁ c₂\n helper n d c .n .d .c eq | refl | refl | refl = refl\n", "meta": {"hexsha": "1042d936021b1bbbe59051aac054b78ace259a47", "size": 3342, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Data/Rational.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Data/Rational.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Data/Rational.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 30.3818181818, "max_line_length": 74, "alphanum_fraction": 0.5245362059, "num_tokens": 1157, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110396870287, "lm_q2_score": 0.7025300698514777, "lm_q1q2_score": 0.6265240720056472}} {"text": "module Problem1 where\n\n{-\nIf we list all the natural numbers below 10 that are multiples of 3 or\n5, we get 3, 5, 6 and 9. The sum of these multiples is 23.\n\nFind the sum of all the multiples of 3 or 5 below 1000.\n-}\n\nopen import Data.Nat\nopen import Data.Nat.Divisibility\nopen import Data.Nat.DivMod\nopen import Data.Nat.Properties\nopen import Data.List\nopen import Data.Sum\n\nopen import Function.Nary.NonDependent using (congₙ)\n\nopen import Relation.Unary.Properties\nopen import Relation.Binary.PropositionalEquality\n\nproblem′ : ℕ → ℕ\nproblem′ n = sum (filter ((3 ∣?_) ∪? (5 ∣?_)) (upTo n))\n\nexample : ℕ\nexample = problem′ 10\n\nexample-correct : example ≡ 23\nexample-correct = refl\n\n-- this is actually quick enough but I'm sure we can do better\nproblem : ℕ\nproblem = problem′ 1000\n\nmodule Lemmas where\n import Agda.Builtin.Nat\n\n open import Algebra.Definitions\n\n open import Data.Bool using (true; false)\n open import Data.Empty\n open import Data.List.Properties\n open import Data.Nat.LCM\n\n open import Relation.Nullary\n open import Relation.Unary\n\n -- first definition of triangle numbers. This is easiest to work with\n triangle : ℕ → ℕ\n triangle zero = zero\n triangle n@(suc x) = n + triangle x\n\n -- second definition of triangle numbers. This looks pretty but sadly ⌊_/2⌋\n -- is O(n) so this works out pretty slow in practice\n triangle′ : ℕ → ℕ\n triangle′ n = ⌊ n * suc n /2⌋\n\n -- Identity to do with adding to half something\n +-⌊n/2⌋ : ∀ m n → m + ⌊ n /2⌋ ≡ ⌊ 2 * m + n /2⌋\n +-⌊n/2⌋ zero n = refl\n +-⌊n/2⌋ (suc m) n = begin\n suc (m + ⌊ n /2⌋) ≡⟨ cong suc (+-⌊n/2⌋ m n) ⟩\n suc ⌊ 2 * m + n /2⌋ ≡⟨ cong (λ x → suc ⌊ m + x + n /2⌋) (+-identityʳ m) ⟩\n ⌊ suc (suc m + m) + n /2⌋ ≡˘⟨ cong (λ x → ⌊ suc x + n /2⌋) (+-suc m m) ⟩\n ⌊ suc (m + suc m + n) /2⌋ ≡˘⟨ cong (λ x → ⌊ suc (m + suc x + n) /2⌋) (+-identityʳ m) ⟩\n ⌊ 2 * suc m + n /2⌋ ∎\n where\n open ≡-Reasoning\n\n -- The first two definitions of triangle numbers match!\n triangle≗triangle′ : triangle ≗ triangle′\n triangle≗triangle′ zero = refl\n triangle≗triangle′ (suc x) = begin\n triangle (suc x) ≡⟨ cong (suc x +_) (triangle≗triangle′ x) ⟩\n suc x + ⌊ x * suc x /2⌋ ≡⟨ +-⌊n/2⌋ (suc x) (x * suc x) ⟩\n ⌊ 2 * suc x + x * suc x /2⌋ ≡˘⟨ cong ⌊_/2⌋ (*-distribʳ-+ (suc x) 2 x) ⟩\n ⌊ (2 + x) * suc x /2⌋ ≡⟨ cong ⌊_/2⌋ (*-comm (2 + x) _) ⟩\n triangle′ (suc x) ∎\n where\n open ≡-Reasoning\n\n -- the third and final definition of triangle numbers\n -- This uses builtin division under the hood which gets compiled to proper\n -- division operators (I think ultimately GMP integer division) so it's fast\n triangle″ : ℕ → ℕ\n triangle″ n = n * suc n / 2\n\n -- halfing is the same as dividing by 2, as you might expect\n //2 : ∀ n → ⌊ n /2⌋ ≡ n / 2\n //2 zero = refl\n //2 (suc zero) = refl\n //2 (suc (suc n)) = begin\n suc ⌊ n /2⌋ ≡⟨ cong suc (//2 n) ⟩\n suc (n / 2) ≡˘⟨ +-distrib-/ 2 n (m%n _ _ n _ _ m _ _ m _ _ m0 {n} {gcd m n} {gcd≢0} (gcd[m,n]≤n m n-1))\n\n------------------------------------------------------------------------\n-- A formal specification of GCD\n\nmodule GCD where\n\n -- Specification of the greatest common divisor (gcd) of two natural\n -- numbers.\n\n record GCD (m n gcd : ℕ) : Set where\n constructor is\n field\n -- The gcd is a common divisor.\n commonDivisor : gcd ∣ m × gcd ∣ n\n\n -- All common divisors divide the gcd, i.e. the gcd is the\n -- greatest common divisor according to the partial order _∣_.\n greatest : ∀ {d} → d ∣ m × d ∣ n → d ∣ gcd\n\n open GCD public\n\n -- The gcd is unique.\n\n unique : ∀ {d₁ d₂ m n} → GCD m n d₁ → GCD m n d₂ → d₁ ≡ d₂\n unique d₁ d₂ = ∣-antisym (GCD.greatest d₂ (GCD.commonDivisor d₁))\n (GCD.greatest d₁ (GCD.commonDivisor d₂))\n\n -- The gcd relation is \"symmetric\".\n\n sym : ∀ {d m n} → GCD m n d → GCD n m d\n sym g = is (swap $ GCD.commonDivisor g) (GCD.greatest g ∘ swap)\n\n -- The gcd relation is \"reflexive\".\n\n refl : ∀ {n} → GCD n n n\n refl = is (∣-refl , ∣-refl) proj₁\n\n -- The GCD of 0 and n is n.\n\n base : ∀ {n} → GCD 0 n n\n base {n} = is (n ∣0 , ∣-refl) proj₂\n\n -- If d is the gcd of n and k, then it is also the gcd of n and\n -- n + k.\n\n step : ∀ {n k d} → GCD n k d → GCD n (n + k) d\n step g with GCD.commonDivisor g\n step {n} {k} {d} g | (d₁ , d₂) = is (d₁ , ∣m∣n⇒∣m+n d₁ d₂) greatest′\n where\n greatest′ : ∀ {d′} → d′ ∣ n × d′ ∣ n + k → d′ ∣ d\n greatest′ (d₁ , d₂) = GCD.greatest g (d₁ , ∣m+n∣m⇒∣n d₂ d₁)\n\nopen GCD public using (GCD) hiding (module GCD)\n\n-- The function gcd fulfils the conditions required of GCD\n\ngcd-GCD : ∀ m n → GCD m n (gcd m n)\ngcd-GCD m n = record\n { commonDivisor = gcd[m,n]∣m m n , gcd[m,n]∣n m n\n ; greatest = uncurry′ gcd-greatest\n }\n\n-- Calculates the gcd of the arguments.\n\nmkGCD : ∀ m n → ∃ λ d → GCD m n d\nmkGCD m n = gcd m n , gcd-GCD m n\n\n-- gcd as a proposition is decidable\n\ngcd? : (m n d : ℕ) → Dec (GCD m n d)\ngcd? m n d =\n Dec.map′ (λ { P.refl → gcd-GCD m n }) (GCD.unique (gcd-GCD m n))\n (gcd m n ≟ d)\n\nGCD-* : ∀ {m n d c} → GCD (m * suc c) (n * suc c) (d * suc c) → GCD m n d\nGCD-* (GCD.is (dc∣nc , dc∣mc) dc-greatest) =\n GCD.is (*-cancelʳ-∣ _ dc∣nc , *-cancelʳ-∣ _ dc∣mc)\n λ {_} → *-cancelʳ-∣ _ ∘ dc-greatest ∘ map (*-monoˡ-∣ _) (*-monoˡ-∣ _)\n\nGCD-/ : ∀ {m n d c} {≢0} → c ∣ m → c ∣ n → c ∣ d →\n GCD m n d → GCD ((m / c) {≢0}) ((n / c) {≢0}) ((d / c) {≢0})\nGCD-/ {m} {n} {d} {c@(suc c-1)}\n (divides p P.refl) (divides q P.refl) (divides r P.refl) gcd\n rewrite m*n/n≡m p c {_} | m*n/n≡m q c {_} | m*n/n≡m r c {_} = GCD-* gcd\n\nGCD-/gcd : ∀ m n {≢0} → GCD ((m / gcd m n) {≢0}) ((n / gcd m n) {≢0}) 1\nGCD-/gcd m n {≢0} rewrite P.sym (n/n≡1 (gcd m n) {≢0}) =\n GCD-/ {≢0 = ≢0} (gcd[m,n]∣m m n) (gcd[m,n]∣n m n) ∣-refl (gcd-GCD m n)\n\n------------------------------------------------------------------------\n-- Calculating the gcd\n\n-- The calculation also proves Bézout's lemma.\n\nmodule Bézout where\n\n module Identity where\n\n -- If m and n have greatest common divisor d, then one of the\n -- following two equations is satisfied, for some numbers x and y.\n -- The proof is \"lemma\" below (Bézout's lemma).\n --\n -- (If this identity was stated using integers instead of natural\n -- numbers, then it would not be necessary to have two equations.)\n\n data Identity (d m n : ℕ) : Set where\n +- : (x y : ℕ) (eq : d + y * n ≡ x * m) → Identity d m n\n -+ : (x y : ℕ) (eq : d + x * m ≡ y * n) → Identity d m n\n\n -- Various properties about Identity.\n\n sym : ∀ {d} → Symmetric (Identity d)\n sym (+- x y eq) = -+ y x eq\n sym (-+ x y eq) = +- y x eq\n\n refl : ∀ {d} → Identity d d d\n refl = -+ 0 1 P.refl\n\n base : ∀ {d} → Identity d 0 d\n base = -+ 0 1 P.refl\n\n private\n infixl 7 _⊕_\n\n _⊕_ : ℕ → ℕ → ℕ\n m ⊕ n = 1 + m + n\n\n step : ∀ {d n k} → Identity d n k → Identity d n (n + k)\n step {d} {n} (+- x y eq) with compare x y\n ... | equal x = +- (2 * x) x (lem₂ d x eq)\n ... | less x i = +- (2 * x ⊕ i) (x ⊕ i) (lem₃ d x eq)\n ... | greater y i = +- (2 * y ⊕ i) y (lem₄ d y n eq)\n step {d} {n} (-+ x y eq) with compare x y\n ... | equal x = -+ (2 * x) x (lem₅ d x eq)\n ... | less x i = -+ (2 * x ⊕ i) (x ⊕ i) (lem₆ d x eq)\n ... | greater y i = -+ (2 * y ⊕ i) y (lem₇ d y n eq)\n\n open Identity public using (Identity; +-; -+) hiding (module Identity)\n\n module Lemma where\n\n -- This type packs up the gcd, the proof that it is a gcd, and the\n -- proof that it satisfies Bézout's identity.\n\n data Lemma (m n : ℕ) : Set where\n result : (d : ℕ) (g : GCD m n d) (b : Identity d m n) → Lemma m n\n\n -- Various properties about Lemma.\n\n sym : Symmetric Lemma\n sym (result d g b) = result d (GCD.sym g) (Identity.sym b)\n\n base : ∀ d → Lemma 0 d\n base d = result d GCD.base Identity.base\n\n refl : ∀ d → Lemma d d\n refl d = result d GCD.refl Identity.refl\n\n stepˡ : ∀ {n k} → Lemma n (suc k) → Lemma n (suc (n + k))\n stepˡ {n} {k} (result d g b) =\n subst (Lemma n) (+-suc n k) $\n result d (GCD.step g) (Identity.step b)\n\n stepʳ : ∀ {n k} → Lemma (suc k) n → Lemma (suc (n + k)) n\n stepʳ = sym ∘ stepˡ ∘ sym\n\n open Lemma public using (Lemma; result) hiding (module Lemma)\n\n -- Bézout's lemma proved using some variant of the extended\n -- Euclidean algorithm.\n\n lemma : (m n : ℕ) → Lemma m n\n lemma m n = build [ <′-recBuilder ⊗ <′-recBuilder ] P gcd″ (m , n)\n where\n P : ℕ × ℕ → Set\n P (m , n) = Lemma m n\n\n gcd″ : ∀ p → (<′-Rec ⊗ <′-Rec) P p → P p\n gcd″ (zero , n ) rec = Lemma.base n\n gcd″ (suc m , zero ) rec = Lemma.sym (Lemma.base (suc m))\n gcd″ (suc m , suc n ) rec with compare m n\n ... | equal .m = Lemma.refl (suc m)\n ... | less .m k = Lemma.stepˡ $ proj₁ rec (suc k) (lem₁ k m)\n -- \"gcd (suc m) (suc k)\"\n ... | greater .n k = Lemma.stepʳ $ proj₂ rec (suc k) (lem₁ k n) (suc n)\n -- \"gcd (suc k) (suc n)\"\n\n -- Bézout's identity can be recovered from the GCD.\n\n identity : ∀ {m n d} → GCD m n d → Identity d m n\n identity {m} {n} g with lemma m n\n ... | result d g′ b with GCD.unique g g′\n ... | P.refl = b\n", "meta": {"hexsha": "9e46c712f1234fd058cb32b724e768a904fa0ae6", "size": 12172, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/Nat/GCD.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Data/Nat/GCD.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Data/Nat/GCD.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 35.8, "max_line_length": 103, "alphanum_fraction": 0.5068189287, "num_tokens": 4990, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744761936437, "lm_q2_score": 0.7662936324115011, "lm_q1q2_score": 0.6265021151293575}} {"text": "open import Level hiding ( suc ; zero )\nopen import Algebra\nmodule Gutil {n m : Level} (G : Group n m ) where\n\nopen import Data.Unit\nopen import Function.Inverse as Inverse using (_↔_; Inverse; _InverseOf_)\nopen import Function\nopen import Data.Nat hiding (_⊔_) -- using (ℕ; suc; zero)\nopen import Relation.Nullary\nopen import Data.Empty\nopen import Data.Product\nopen import Relation.Binary.PropositionalEquality hiding ( [_] )\n\n\nopen Group G\n\nimport Relation.Binary.Reasoning.Setoid as EqReasoning\n\ngsym = Algebra.Group.sym G\ngrefl = Algebra.Group.refl G\ngtrans = Algebra.Group.trans G\n\nlemma3 : ε ≈ ε ⁻¹\nlemma3 = begin\n ε ≈⟨ gsym (proj₁ inverse _) ⟩\n ε ⁻¹ ∙ ε ≈⟨ proj₂ identity _ ⟩\n ε ⁻¹\n ∎ where open EqReasoning (Algebra.Group.setoid G)\n\nlemma6 : {f : Carrier } → ( f ⁻¹ ) ⁻¹ ≈ f\nlemma6 {f} = begin\n ( f ⁻¹ ) ⁻¹ ≈⟨ gsym ( proj₁ identity _) ⟩\n ε ∙ ( f ⁻¹ ) ⁻¹ ≈⟨ ∙-cong (gsym ( proj₂ inverse _ )) grefl ⟩\n (f ∙ f ⁻¹ ) ∙ ( f ⁻¹ ) ⁻¹ ≈⟨ assoc _ _ _ ⟩\n f ∙ ( f ⁻¹ ∙ ( f ⁻¹ ) ⁻¹ ) ≈⟨ ∙-cong grefl (proj₂ inverse _) ⟩\n f ∙ ε ≈⟨ proj₂ identity _ ⟩\n f\n ∎ where open EqReasoning (Algebra.Group.setoid G)\n\n≡→≈ : {f g : Carrier } → f ≡ g → f ≈ g\n≡→≈ refl = grefl\n\n---\n-- to avoid assoc storm, flatten multiplication according to the template\n--\n\ndata MP : Carrier → Set (Level.suc n) where\n am : (x : Carrier ) → MP x\n _o_ : {x y : Carrier } → MP x → MP y → MP ( x ∙ y )\n\nmpf : {x : Carrier } → (m : MP x ) → Carrier → Carrier\nmpf (am x) y = x ∙ y\nmpf (m o m₁) y = mpf m ( mpf m₁ y )\n\nmp-flatten : {x : Carrier } → (m : MP x ) → Carrier \nmp-flatten m = mpf m ε \n\nmpl1 : Carrier → {x : Carrier } → MP x → Carrier\nmpl1 x (am y) = x ∙ y\nmpl1 x (y o y1) = mpl1 ( mpl1 x y ) y1\n\nmpl : {x z : Carrier } → MP x → MP z → Carrier\nmpl (am x) m = mpl1 x m \nmpl (m o m1) m2 = mpl m (m1 o m2)\n\nmp-flattenl : {x : Carrier } → (m : MP x ) → Carrier\nmp-flattenl m = mpl m (am ε)\n\ntest1 : ( f g : Carrier ) → Carrier\ntest1 f g = mp-flattenl ((am (g ⁻¹) o am (f ⁻¹) ) o ( (am f o am g) o am ((f ∙ g) ⁻¹ ))) \n\ntest2 : ( f g : Carrier ) → test1 f g ≡ g ⁻¹ ∙ f ⁻¹ ∙ f ∙ g ∙ (f ∙ g) ⁻¹ ∙ ε\ntest2 f g = _≡_.refl\n\ntest3 : ( f g : Carrier ) → Carrier\ntest3 f g = mp-flatten ((am (g ⁻¹) o am (f ⁻¹) ) o ( (am f o am g) o am ((f ∙ g) ⁻¹ ))) \n\ntest4 : ( f g : Carrier ) → test3 f g ≡ g ⁻¹ ∙ (f ⁻¹ ∙ (f ∙ (g ∙ ((f ∙ g) ⁻¹ ∙ ε))))\ntest4 f g = _≡_.refl\n\n \n∙-flatten : {x : Carrier } → (m : MP x ) → x ≈ mp-flatten m\n∙-flatten {x} (am x) = gsym (proj₂ identity _)\n∙-flatten {_} (am x o q) = ∙-cong grefl ( ∙-flatten q )\n∙-flatten (_o_ {_} {z} (_o_ {x} {y} p q) r) = lemma9 _ _ _ ( ∙-flatten {x ∙ y } (p o q )) ( ∙-flatten {z} r ) where\n mp-cong : {p q r : Carrier} → (P : MP p) → q ≈ r → mpf P q ≈ mpf P r\n mp-cong (am x) q=r = ∙-cong grefl q=r\n mp-cong (P o P₁) q=r = mp-cong P ( mp-cong P₁ q=r )\n mp-assoc : {p q r : Carrier} → (P : MP p) → mpf P q ∙ r ≈ mpf P (q ∙ r )\n mp-assoc (am x) = assoc _ _ _ \n mp-assoc {p} {q} {r} (P o P₁) = begin\n mpf P (mpf P₁ q) ∙ r ≈⟨ mp-assoc P ⟩\n mpf P (mpf P₁ q ∙ r) ≈⟨ mp-cong P (mp-assoc P₁) ⟩ mpf P ((mpf P₁) (q ∙ r))\n ∎ where open EqReasoning (Algebra.Group.setoid G)\n lemma9 : (x y z : Carrier) → x ∙ y ≈ mpf p (mpf q ε) → z ≈ mpf r ε → x ∙ y ∙ z ≈ mp-flatten ((p o q) o r)\n lemma9 x y z t s = begin\n x ∙ y ∙ z ≈⟨ ∙-cong t grefl ⟩\n mpf p (mpf q ε) ∙ z ≈⟨ mp-assoc p ⟩\n mpf p (mpf q ε ∙ z) ≈⟨ mp-cong p (mp-assoc q ) ⟩\n mpf p (mpf q (ε ∙ z)) ≈⟨ mp-cong p (mp-cong q (proj₁ identity _ )) ⟩\n mpf p (mpf q z) ≈⟨ mp-cong p (mp-cong q s) ⟩\n mpf p (mpf q (mpf r ε))\n ∎ where open EqReasoning (Algebra.Group.setoid G)\n\ngrepl : { x y0 y1 z : Carrier } → x ∙ y0 ≈ y1 → x ∙ ( y0 ∙ z ) ≈ y1 ∙ z \ngrepl eq = gtrans (gsym (assoc _ _ _ )) (∙-cong eq grefl )\n\ngrm : { x y0 y1 z : Carrier } → x ∙ y0 ≈ ε → x ∙ ( y0 ∙ z ) ≈ z \ngrm eq = gtrans ( gtrans (gsym (assoc _ _ _ )) (∙-cong eq grefl )) ( proj₁ identity _ )\n\n-- ∙-flattenl : {x : Carrier } → (m : MP x ) → x ≈ mp-flattenl m\n-- ∙-flattenl (am x) = gsym (proj₂ identity _)\n-- ∙-flattenl (q o am x) with ∙-flattenl q -- x₁ ∙ x ≈ mpl q (am x o am ε) , t : x₁ ≈ mpl q (am ε)\n-- ... | t = {!!}\n-- ∙-flattenl (q o (x o y )) with ∙-flattenl q \n-- ... | t = gtrans (gsym (assoc _ _ _ )) {!!}\n\nlemma5 : (f g : Carrier ) → g ⁻¹ ∙ f ⁻¹ ≈ (f ∙ g) ⁻¹\nlemma5 f g = begin\n g ⁻¹ ∙ f ⁻¹ ≈⟨ gsym (proj₂ identity _) ⟩\n g ⁻¹ ∙ f ⁻¹ ∙ ε ≈⟨ gsym (∙-cong grefl (proj₂ inverse _ )) ⟩\n g ⁻¹ ∙ f ⁻¹ ∙ ( (f ∙ g) ∙ (f ∙ g) ⁻¹ ) ≈⟨ ∙-flatten ((am (g ⁻¹) o am (f ⁻¹) ) o ( (am f o am g) o am ((f ∙ g) ⁻¹ ))) ⟩\n g ⁻¹ ∙ (f ⁻¹ ∙ (f ∙ (g ∙ ((f ∙ g) ⁻¹ ∙ ε)))) ≈⟨ ∙-cong grefl (gsym (assoc _ _ _ )) ⟩\n g ⁻¹ ∙ ((f ⁻¹ ∙ f) ∙ (g ∙ ((f ∙ g) ⁻¹ ∙ ε))) ≈⟨ ∙-cong grefl (gtrans (∙-cong (proj₁ inverse _ ) grefl) (proj₁ identity _)) ⟩\n g ⁻¹ ∙ (g ∙ ((f ∙ g) ⁻¹ ∙ ε)) ≈⟨ gsym (assoc _ _ _) ⟩\n (g ⁻¹ ∙ g ) ∙ ((f ∙ g) ⁻¹ ∙ ε) ≈⟨ gtrans (∙-cong (proj₁ inverse _ ) grefl) (proj₁ identity _) ⟩\n (f ∙ g) ⁻¹ ∙ ε ≈⟨ proj₂ identity _ ⟩\n (f ∙ g) ⁻¹\n ∎ where open EqReasoning (Algebra.Group.setoid G)\n\n", "meta": {"hexsha": "857863b65f8e5f44c23059e6077bda74569eba42", "size": 5323, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Gutil.agda", "max_stars_repo_name": "shinji-kono/Galois", "max_stars_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-16T03:37:05.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-16T03:37:05.000Z", "max_issues_repo_path": "src/Gutil.agda", "max_issues_repo_name": "shinji-kono/Galois", "max_issues_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Gutil.agda", "max_forks_repo_name": "shinji-kono/Galois", "max_forks_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.6335877863, "max_line_length": 133, "alphanum_fraction": 0.4923915085, "num_tokens": 2398, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117983401363, "lm_q2_score": 0.7577943767446202, "lm_q1q2_score": 0.6264775519705877}} {"text": "-- 2014-02-08 Andreas\n-- Eta-equality for records that are recursive via some data type\n\nmodule _ where\n\nopen import Common.Equality\n\nmodule Nested where\n\n data List (A : Set) : Set where\n [] : List A\n _∷_ : (x : A)(xs : List A) → List A\n\n record Tree (A : Set) : Set where\n constructor tree\n field\n elem : A\n subtrees : List (Tree A)\n open Tree\n\n test : ∀ {A} (t : Tree A) → t ≡ tree (elem t) (subtrees t)\n test t = refl\n\n -- we should have eta for Tree!\n\nmodule Mutual where\n\n mutual\n data TreeList (A : Set) : Set where\n [] : TreeList A\n _∷_ : (x : Tree A)(xs : TreeList A) → TreeList A\n\n record Tree (A : Set) : Set where\n constructor tree\n field\n elem : A\n subtrees : TreeList A\n open Tree\n\n test : ∀ {A} (t : Tree A) → t ≡ tree (elem t) (subtrees t)\n test t = refl\n\n", "meta": {"hexsha": "c1ecc7e2708f231b6f3b8234b6284e928a2bf314", "size": 854, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/EtaInductiveRecord.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/succeed/EtaInductiveRecord.agda", "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/EtaInductiveRecord.agda", "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 19.8604651163, "max_line_length": 65, "alphanum_fraction": 0.5725995316, "num_tokens": 279, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117940706734, "lm_q2_score": 0.7577943767446202, "lm_q1q2_score": 0.6264775487352128}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nmodule Cubical.HITs.DunceCap.Base where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.GroupoidLaws\n\nopen import Cubical.HITs.S1 using (S¹; base)\nimport Cubical.HITs.S1 as S¹\n\nopen import Cubical.HITs.MappingCones\n\n-- definition of the dunce cap as a HIT\n\ndata Dunce : Type₀ where\n base : Dunce\n loop : base ≡ base\n surf : PathP (λ i → loop i ≡ loop i) loop refl\n\n-- definition of the dunce cap as a mapping cone\n\ndunceMap : S¹ → S¹\ndunceMap base = base\ndunceMap (S¹.loop i) = (S¹.loop ⁻¹ ∙∙ S¹.loop ∙∙ S¹.loop) i\n\nDunceCone : Type₀\nDunceCone = Cone dunceMap\n", "meta": {"hexsha": "6d2057fbea7d779a13ed30a8fdc7727ad2a00f46", "size": 647, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/DunceCap/Base.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/HITs/DunceCap/Base.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/HITs/DunceCap/Base.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "avg_line_length": 23.1071428571, "max_line_length": 59, "alphanum_fraction": 0.71561051, "num_tokens": 221, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9086179018818865, "lm_q2_score": 0.6893056040203135, "lm_q1q2_score": 0.6263154116803638}} {"text": "------------------------------------------------------------------------------\n-- Agda-Prop Library.\n-- Normal Forms.\n------------------------------------------------------------------------------\n\nopen import Data.Nat\n using (suc; zero; _+_;_*_)\n renaming (_⊔_ to max; ℕ to Nat )\n\nmodule Data.PropFormula.NormalForms (n : Nat) where\n\n------------------------------------------------------------------------------\n\nopen import Data.Bool.Base\n using ( Bool; true; false; if_then_else_; not)\n renaming (_∧_ to _and_; _∨_ to _or_)\n\nopen import Data.Fin using ( Fin; #_ )\nopen import Data.List using ( List; [_]; []; _++_; _∷_ ; concatMap; map )\n\nopen import Data.PropFormula.Properties n using ( subst )\nopen import Data.PropFormula.Syntax n\nopen import Data.PropFormula.Views n\n\nopen import Relation.Nullary using (yes; no)\nopen import Data.PropFormula.Theorems n\n\nopen import Function using ( _∘_; _$_ )\nopen import Relation.Binary.PropositionalEquality using ( _≡_; sym )\n\n------------------------------------------------------------------------------\n\n------------------------------------------------------------------------------\n-- Negation Normal Form (NNF)\n------------------------------------------------------------------------------\n\n-- Def.\nnnf₁ : Nat → PropFormula → PropFormula\nnnf₁ (suc n) φ\n with n-view φ\n... | conj φ₁ φ₂ = nnf₁ n φ₁ ∧ nnf₁ n φ₂\n... | disj φ₁ φ₂ = nnf₁ n φ₁ ∨ nnf₁ n φ₂\n... | impl φ₁ φ₂ = nnf₁ n ((¬ φ₁) ∨ φ₂)\n... | biimpl φ₁ φ₂ = nnf₁ n ((φ₁ ⊃ φ₂) ∧ (φ₂ ⊃ φ₁))\n... | nconj φ₁ φ₂ = nnf₁ n ((¬ φ₁) ∨ (¬ φ₂))\n... | ndisj φ₁ φ₂ = nnf₁ n ((¬ φ₁) ∧ (¬ φ₂))\n... | nneg φ₁ = nnf₁ n φ₁\n... | nimpl φ₁ φ₂ = nnf₁ n (¬ (φ₂ ∨ (¬ φ₁)))\n... | nbiim φ₁ φ₂ = nnf₁ n (¬ ((φ₁ ⊃ φ₂) ∧ (φ₂ ⊃ φ₁)))\n... | ntop = ⊥\n... | nbot = ⊤\n... | other .φ = φ\nnnf₁ zero φ = φ\n\n-- Theorem.\nnnf₁-lem\n : ∀ {Γ} {φ}\n → (n : Nat)\n → Γ ⊢ φ\n → Γ ⊢ nnf₁ n φ\n\n-- Proof.\nnnf₁-lem {Γ} {φ} (suc n) Γ⊢φ\n with n-view φ\n... | conj φ₁ φ₂ =\n ∧-intro\n (nnf₁-lem n (∧-proj₁ Γ⊢φ))\n (nnf₁-lem n (∧-proj₂ Γ⊢φ))\n... | disj φ₁ φ₂ =\n (⊃-elim\n (⊃-intro\n (∨-elim\n (∨-intro₁\n (nnf₁ n φ₂)\n (nnf₁-lem n (assume φ₁)))\n (∨-intro₂\n (nnf₁ n φ₁)\n (nnf₁-lem n (assume φ₂)))))\n Γ⊢φ)\n... | impl φ₁ φ₂ = nnf₁-lem n (⊃-to-¬∨ Γ⊢φ)\n... | biimpl φ₁ φ₂ = nnf₁-lem n (⇔-equiv₁ Γ⊢φ)\n... | nconj φ₁ φ₂ = nnf₁-lem n (¬∧-to-¬∨¬ Γ⊢φ)\n... | ndisj φ₁ φ₂ = nnf₁-lem n (¬∨-to-¬∧¬ Γ⊢φ)\n... | nneg φ₁ = nnf₁-lem n (¬¬-equiv₁ Γ⊢φ)\n... | nimpl φ₁ φ₂ = nnf₁-lem n (subst⊢¬ helper Γ⊢φ)\n where\n helper : Γ ⊢ φ₂ ∨ ¬ φ₁ ⊃ (φ₁ ⊃ φ₂)\n helper = ⊃-intro (¬∨-to-⊃ (∨-comm (assume (φ₂ ∨ ¬ φ₁))))\n... | nbiim φ₁ φ₂ =\n nnf₁-lem n\n (subst⊢¬\n (⊃-intro\n (⇔-equiv₂\n (assume ((φ₁ ⊃ φ₂) ∧ (φ₂ ⊃ φ₁)))))\n Γ⊢φ)\n... | ntop = ¬-elim Γ⊢φ ⊤-intro\n... | nbot = ⊤-intro\n... | other .φ = Γ⊢φ\nnnf₁-lem {Γ} {φ} zero Γ⊢φ = Γ⊢φ\n--------------------------------------------------------------------------- ∎\n\n-- Complexity measure.\nnnf-cm : PropFormula → Nat\nnnf-cm φ with n-view φ\n... | conj φ₁ φ₂ = nnf-cm φ₁ + nnf-cm φ₂ + 1\n... | disj φ₁ φ₂ = nnf-cm φ₁ + nnf-cm φ₂ + 1\n... | impl φ₁ φ₂ = 2 * nnf-cm φ₁ + nnf-cm φ₂ + 1\n... | biimpl φ₁ φ₂ = 2 * (nnf-cm φ₁ + nnf-cm φ₂) + 3\n... | nconj φ₁ φ₂ = nnf-cm (¬ φ₁) + nnf-cm (¬ φ₂) + 1\n... | ndisj φ₁ φ₂ = nnf-cm (¬ φ₁) + nnf-cm (¬ φ₂) + 1\n... | nneg φ₁ = nnf-cm (¬ φ₁) + 1\n... | nimpl φ₁ φ₂ = nnf-cm φ₁ + nnf-cm (¬ φ₂) + 3\n... | nbiim φ₁ φ₂ = nnf-cm φ₁ + nnf-cm φ₂ +\n nnf-cm (¬ φ₁) + nnf-cm (¬ φ₂) + 8\n... | ntop = 1\n... | nbot = 1\n... | other .φ = 1\n\n-- Def.\nnnf : PropFormula → PropFormula\nnnf φ = nnf₁ (nnf-cm φ) φ\n\n-- Theorem.\nnnf-lem\n : ∀ {Γ} {φ}\n → Γ ⊢ φ\n → Γ ⊢ nnf φ\n\n-- Proof.\nnnf-lem {Γ} {φ} Γ⊢φ = nnf₁-lem (nnf-cm φ) Γ⊢φ\n--------------------------------------------------------------------------- ∎\n\n------------------------------------------------------------------------------\n-- Disjunctive Normal Form (DNF)\n------------------------------------------------------------------------------\n\n-- Def.\ndist-∧ : PropFormula → PropFormula\ndist-∧ φ with d-view-aux φ\n... | case₁ φ₁ φ₂ φ₃ = dist-∧ (φ₁ ∧ φ₃) ∨ dist-∧ (φ₂ ∧ φ₃)\n... | case₂ φ₁ φ₂ φ₃ = dist-∧ (φ₁ ∧ φ₂) ∨ dist-∧ (φ₁ ∧ φ₃)\n... | other .φ = φ\n\n-- Theorem.\ndist-∧-lem\n : ∀ {Γ} {φ}\n → Γ ⊢ φ\n → Γ ⊢ dist-∧ φ\n\n-- Proof.\ndist-∧-lem {Γ} {φ} Γ⊢φ with d-view-aux φ\ndist-∧-lem {Γ} {.((φ ∨ ψ) ∧ γ)} Γ⊢⟨φ∨ψ⟩∧γ | case₁ φ ψ γ =\n ⊃-elim\n (⊃-intro\n (∨-elim\n (∨-intro₁ (dist-∧ (ψ ∧ γ))\n (dist-∧-lem\n (∧-intro\n (assume φ)\n (weaken φ (∧-proj₂ Γ⊢⟨φ∨ψ⟩∧γ)))))\n (∨-intro₂ (dist-∧ (φ ∧ γ))\n (dist-∧-lem\n (∧-intro\n (assume ψ)\n (weaken ψ (∧-proj₂ Γ⊢⟨φ∨ψ⟩∧γ)))))))\n (∧-proj₁ Γ⊢⟨φ∨ψ⟩∧γ)\n\ndist-∧-lem {Γ} {.(φ ∧ (ψ ∨ γ))} Γ⊢φ∧⟨ψ∨γ⟩ | case₂ φ ψ γ =\n ⊃-elim\n (⊃-intro\n (∨-elim\n (∨-intro₁ (dist-∧ (φ ∧ γ))\n (dist-∧-lem\n (∧-intro\n (weaken ψ (∧-proj₁ Γ⊢φ∧⟨ψ∨γ⟩))\n (assume ψ))))\n (∨-intro₂ (dist-∧ (φ ∧ ψ))\n (dist-∧-lem\n (∧-intro\n (weaken γ (∧-proj₁ Γ⊢φ∧⟨ψ∨γ⟩))\n (assume γ))))))\n (∧-proj₂ Γ⊢φ∧⟨ψ∨γ⟩)\ndist-∧-lem {Γ} {.φ} Γ⊢φ | other φ = Γ⊢φ\n--------------------------------------------------------------------------- ∎\n\n-- Theorem.\nfrom-dist-∧-lem\n : ∀ {Γ} {φ}\n → Γ ⊢ dist-∧ φ\n → Γ ⊢ φ\n\n-- Proof.\nfrom-dist-∧-lem {Γ} {φ} Γ⊢φ with d-view-aux φ\nfrom-dist-∧-lem {Γ} {.((φ ∨ ψ) ∧ γ)} Γ⊢⟨φ∨ψ⟩∧γ | case₁ φ ψ γ =\n ∧-comm\n (∧-dist₂\n (⊃-elim\n (⊃-intro\n (∨-elim\n (∨-intro₁ (γ ∧ ψ)\n (∧-comm\n (from-dist-∧-lem\n (assume (dist-∧ (φ ∧ γ))))))\n (∨-intro₂ (γ ∧ φ)\n (∧-comm\n (from-dist-∧-lem\n (assume (dist-∧ (ψ ∧ γ))))))))\n Γ⊢⟨φ∨ψ⟩∧γ))\nfrom-dist-∧-lem {Γ} {.(φ ∧ (ψ ∨ γ))} Γ⊢φ∧⟨ψ∨γ⟩ | case₂ φ ψ γ =\n ∧-dist₂\n (⊃-elim\n (⊃-intro\n (∨-elim\n (∨-intro₁ (φ ∧ γ)\n (from-dist-∧-lem (assume (dist-∧ (φ ∧ ψ)))))\n (∨-intro₂ (φ ∧ ψ)\n (from-dist-∧-lem (assume (dist-∧ (φ ∧ γ)))))))\n Γ⊢φ∧⟨ψ∨γ⟩)\nfrom-dist-∧-lem {Γ} {.φ} Γ⊢φ | other φ = Γ⊢φ\n--------------------------------------------------------------------------- ∎\n\n-- Def.\ndnf-dist : PropFormula → PropFormula\ndnf-dist φ with d-view φ\ndnf-dist .(φ ∧ ψ) | conj φ ψ = dist-∧ (dnf-dist φ ∧ dnf-dist ψ)\ndnf-dist .(φ ∨ ψ) | disj φ ψ = dnf-dist φ ∨ dnf-dist ψ\ndnf-dist φ | other .φ = φ\n\n-- Theorem.\ndnf-dist-lem\n : ∀ {Γ} {φ}\n → Γ ⊢ φ\n → Γ ⊢ dnf-dist φ\n\n-- Proof.\ndnf-dist-lem {Γ} {φ} Γ⊢φ with d-view φ\ndnf-dist-lem {Γ} {φ ∧ ψ} Γ⊢φ∧ψ | conj .φ .ψ =\n dist-∧-lem\n (∧-intro\n (dnf-dist-lem (∧-proj₁ Γ⊢φ∧ψ))\n (dnf-dist-lem (∧-proj₂ Γ⊢φ∧ψ)))\ndnf-dist-lem {Γ} {φ ∨ ψ} Γ⊢φ∨ψ | disj .φ .ψ =\n ⊃-elim\n (⊃-intro\n (∨-elim\n (∨-intro₁ (dnf-dist ψ) (dnf-dist-lem (assume φ)))\n (∨-intro₂ (dnf-dist φ) (dnf-dist-lem (assume ψ)))))\n Γ⊢φ∨ψ\ndnf-dist-lem {Γ} {φ} Γ⊢φ | other .φ = Γ⊢φ\n--------------------------------------------------------------------------- ∎\n\n-- Theorem.\nfrom-dnf-dist-lem\n : ∀ {Γ} {φ}\n → Γ ⊢ dnf-dist φ\n → Γ ⊢ φ\n\n-- Proof.\nfrom-dnf-dist-lem {_} {φ} Γ⊢φ with d-view φ\nfrom-dnf-dist-lem {_} {φ ∧ ψ} Γ⊢φ∧ψ | conj .φ .ψ =\n ∧-intro\n (from-dnf-dist-lem {φ = φ}\n (∧-proj₁ (from-dist-∧-lem Γ⊢φ∧ψ)))\n (from-dnf-dist-lem {φ = ψ}\n (∧-proj₂ {φ = dnf-dist φ}\n (from-dist-∧-lem Γ⊢φ∧ψ)))\nfrom-dnf-dist-lem {_} {φ ∨ ψ} Γ⊢φ∨ψ | disj .φ .ψ =\n ⊃-elim\n (⊃-intro\n (∨-elim\n (∨-intro₁ ψ\n (from-dnf-dist-lem (assume (dnf-dist φ))))\n (∨-intro₂ φ\n (from-dnf-dist-lem (assume (dnf-dist ψ))))))\n Γ⊢φ∨ψ\nfrom-dnf-dist-lem {_} {φ} Γ⊢φ | other .φ = Γ⊢φ\n--------------------------------------------------------------------------- ∎\n\n\n-- Def.\ndnf : PropFormula → PropFormula\ndnf = dnf-dist ∘ nnf\n\n-- Theorem.\ndnf-lem\n : ∀ {Γ} {φ}\n → Γ ⊢ φ\n → Γ ⊢ dnf φ\n\n-- Proof.\ndnf-lem = dnf-dist-lem ∘ nnf-lem\n--------------------------------------------------------------------------- ∎\n\n------------------------------------------------------------------------------\n-- Conjunctive Normal Forms (CNF)\n------------------------------------------------------------------------------\n\n-- Def.\ndist-∨ : PropFormula → PropFormula\ndist-∨ φ with c-view-aux φ\ndist-∨ .((φ₁ ∧ φ₂) ∨ φ₃) | case₁ φ₁ φ₂ φ₃ =\n dist-∨ (φ₁ ∨ φ₃) ∧ dist-∨ (φ₂ ∨ φ₃)\ndist-∨ .(φ₁ ∨ (φ₂ ∧ φ₃)) | case₂ φ₁ φ₂ φ₃ =\n dist-∨ (φ₁ ∨ φ₂) ∧ dist-∨ (φ₁ ∨ φ₃)\ndist-∨ φ | other .φ = φ\n\n-- Theorem.\ndist-∨-lem\n : ∀ {Γ} {φ}\n → Γ ⊢ φ\n → Γ ⊢ dist-∨ φ\n\n-- Proof.\ndist-∨-lem {Γ} {φ} Γ⊢φ with c-view-aux φ\ndist-∨-lem {Γ} {.((φ ∧ ψ) ∨ γ)} Γ⊢φ | case₁ φ ψ γ =\n ∧-intro\n (dist-∨-lem (∧-proj₁ helper))\n (dist-∨-lem (∧-proj₂ helper))\n where\n helper : Γ ⊢ (φ ∨ γ) ∧ (ψ ∨ γ)\n helper =\n ∧-intro\n (∨-comm (∧-proj₁ (∨-dist₁ (∨-comm Γ⊢φ))))\n (∨-comm (∧-proj₂ (∨-dist₁ (∨-comm Γ⊢φ))))\ndist-∨-lem {Γ} {.(φ ∨ (ψ ∧ γ))} Γ⊢φ | case₂ φ ψ γ =\n ∧-intro\n (dist-∨-lem (∧-proj₁ (∨-dist₁ Γ⊢φ)))\n (dist-∨-lem (∧-proj₂ (∨-dist₁ Γ⊢φ)))\ndist-∨-lem {Γ} {.φ} Γ⊢φ | other φ = Γ⊢φ\n--------------------------------------------------------------------------- ∎\n\n-- Theorem.\nfrom-dist-∨-lem\n : ∀ {Γ} {φ}\n → Γ ⊢ dist-∨ φ\n → Γ ⊢ φ\n\n-- Proof.\nfrom-dist-∨-lem {Γ} {φ} Γ⊢φ with c-view-aux φ\nfrom-dist-∨-lem {Γ} {.((φ ∧ ψ) ∨ γ)} Γ⊢φ | case₁ φ ψ γ =\n ∨-comm\n (∨-dist₂\n (∧-intro\n (∨-comm\n (from-dist-∨-lem (∧-proj₁ Γ⊢φ)))\n (∨-comm\n (from-dist-∨-lem (∧-proj₂ Γ⊢φ)))))\nfrom-dist-∨-lem {Γ} {.(φ ∨ (ψ ∧ γ))} Γ⊢φ | case₂ φ ψ γ =\n ∨-dist₂\n (∧-intro (from-dist-∨-lem (∧-proj₁ Γ⊢φ))\n (from-dist-∨-lem (∧-proj₂ Γ⊢φ)))\nfrom-dist-∨-lem {Γ} {.φ} Γ⊢φ | other φ = Γ⊢φ\n--------------------------------------------------------------------------- ∎\n\n-- Def.\ncnf-dist : PropFormula → PropFormula\ncnf-dist φ with d-view φ\ncnf-dist .(φ ∧ ψ) | conj φ ψ = cnf-dist φ ∧ cnf-dist ψ\ncnf-dist .(φ ∨ ψ) | disj φ ψ = dist-∨ ((cnf-dist φ) ∨ (cnf-dist ψ))\ncnf-dist φ | other .φ = φ\n\n-- Theorem.\ncnf-dist-lem\n : ∀ {Γ} {φ}\n → Γ ⊢ φ\n → Γ ⊢ cnf-dist φ\n\n-- Proof.\ncnf-dist-lem {_} {φ} Γ⊢φ\n with d-view φ\ncnf-dist-lem {_} {.(φ ∧ ψ)} Γ⊢φ∧ψ | conj φ ψ =\n ∧-intro (cnf-dist-lem (∧-proj₁ Γ⊢φ∧ψ)) (cnf-dist-lem (∧-proj₂ Γ⊢φ∧ψ))\ncnf-dist-lem {_} {.(φ ∨ ψ)} Γ⊢φ∨ψ | disj φ ψ =\n dist-∨-lem\n (⊃-elim\n (⊃-intro\n (∨-elim\n (∨-intro₁ (cnf-dist ψ) (cnf-dist-lem (assume φ)))\n (∨-intro₂ (cnf-dist φ) (cnf-dist-lem (assume ψ)))))\n Γ⊢φ∨ψ)\ncnf-dist-lem {_} {.φ} Γ⊢φ | other φ = Γ⊢φ\n--------------------------------------------------------------------------- ∎\n\n-- Theorem.\nfrom-cnf-dist-lem\n : ∀ {Γ} {φ}\n → Γ ⊢ cnf-dist φ\n → Γ ⊢ φ\n\n-- Proof.\nfrom-cnf-dist-lem {_} {φ} Γ⊢cnfdist\n with d-view φ\nfrom-cnf-dist-lem {_} {.(φ ∧ ψ)} Γ⊢cnfdistφ∧ψ | conj φ ψ =\n ∧-intro\n (from-cnf-dist-lem (∧-proj₁ Γ⊢cnfdistφ∧ψ))\n (from-cnf-dist-lem (∧-proj₂ Γ⊢cnfdistφ∧ψ))\nfrom-cnf-dist-lem {_} {.(φ ∨ ψ)} Γ⊢cnfdistφ∨ψ | disj φ ψ =\n ⊃-elim\n (⊃-intro\n (∨-elim\n (∨-intro₁ ψ (from-cnf-dist-lem (assume (cnf-dist φ))))\n (∨-intro₂ φ (from-cnf-dist-lem (assume (cnf-dist ψ))))))\n (from-dist-∨-lem Γ⊢cnfdistφ∨ψ)\nfrom-cnf-dist-lem {_} {.φ} Γ⊢φ | other φ = Γ⊢φ\n--------------------------------------------------------------------------- ∎\n\n-- Def.\ncnf : PropFormula → PropFormula\ncnf = cnf-dist ∘ nnf\n\n-- Theorem.\ncnf-lem\n : ∀ {Γ} {φ}\n → Γ ⊢ φ\n → Γ ⊢ cnf φ\n\n-- Proof.\ncnf-lem = cnf-dist-lem ∘ nnf-lem -- ▪\n\n----------------------------------------------------------------------------\n-- Testing for a normal form.\n\nis∨ : PropFormula → Bool\nis∨ φ\n with d-view φ\nis∨ .(φ₁ ∧ φ₂) | conj φ₁ φ₂ = false\nis∨ .(φ₁ ∨ φ₂) | disj φ₁ φ₂ = is∨ φ₁ and is∨ φ₂\nis∨ φ | other .φ = true\n\nis∧∨ : PropFormula → Bool\nis∧∨ φ\n with d-view φ\nis∧∨ .(φ₁ ∧ φ₂) | conj φ₁ φ₂ = is∧∨ φ₁ and is∧∨ φ₂\nis∧∨ .(φ₁ ∨ φ₂) | disj φ₁ φ₂ = is∨ φ₁ and is∨ φ₂\nis∧∨ φ | other .φ = true\n\nis∧ : PropFormula → Bool\nis∧ φ\n with d-view φ\nis∧ .(φ₁ ∧ φ₂) | conj φ₁ φ₂ = is∧ φ₁ and is∧ φ₂\nis∧ .(φ₁ ∨ φ₂) | disj φ₁ φ₂ = false\nis∧ φ | other .φ = true\n\nis∨∧ : PropFormula → Bool\nis∨∧ φ\n with d-view φ\nis∨∧ .(φ₁ ∧ φ₂) | conj φ₁ φ₂ = is∧ φ₁ and is∧ φ₂\nis∨∧ .(φ₁ ∨ φ₂) | disj φ₁ φ₂ = is∨∧ φ₁ and is∨∧ φ₂\nis∨∧ φ | other .φ = true\n\n\nisNNF : PropFormula → Bool\nisNNF φ\n with push-neg-view φ\nisNNF φ | yes .φ = false\nisNNF .(φ₁ ∧ φ₂) | no-∧ φ₁ φ₂ = isNNF φ₁ and isNNF φ₂\nisNNF .(φ₁ ∨ φ₂) | no-∨ φ₁ φ₂ = isNNF φ₁ and isNNF φ₂\nisNNF φ | no .φ = true\n\nisCNF : PropFormula → Bool\nisCNF φ = isNNF φ and is∧∨ φ\n\nisDNF : PropFormula → Bool\nisDNF φ = isNNF φ and is∨∧ φ\n", "meta": {"hexsha": "c3028f512c33542af2f891fa4013fae2273a0f90", "size": 12846, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/PropFormula/NormalForms.agda", "max_stars_repo_name": "jonaprieto/agda-prop", "max_stars_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 13, "max_stars_repo_stars_event_min_datetime": "2017-05-01T16:45:41.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T03:33:12.000Z", "max_issues_repo_path": "src/Data/PropFormula/NormalForms.agda", "max_issues_repo_name": "jonaprieto/agda-prop", "max_issues_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 18, "max_issues_repo_issues_event_min_datetime": "2017-03-08T14:33:10.000Z", "max_issues_repo_issues_event_max_datetime": "2017-12-18T16:34:21.000Z", "max_forks_repo_path": "src/Data/PropFormula/NormalForms.agda", "max_forks_repo_name": "jonaprieto/agda-prop", "max_forks_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-03-30T16:41:56.000Z", "max_forks_repo_forks_event_max_datetime": "2017-12-01T17:01:25.000Z", "avg_line_length": 27.6258064516, "max_line_length": 78, "alphanum_fraction": 0.4123462556, "num_tokens": 5650, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321889812553, "lm_q2_score": 0.7772998560157665, "lm_q1q2_score": 0.6262177844967965}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Level\n\n-- This is really a degenerate version of Categories.Category.Instance.Zero\n-- Here EmptySet is not given an explicit name, it is an alias for Lift o ⊥\nmodule Categories.Category.Instance.EmptySet where\n\nopen import Data.Unit\nopen import Data.Empty using (⊥; ⊥-elim)\nopen import Function.Equality using (Π)\nopen Π using (_⟨$⟩_)\n\nopen import Relation.Binary using (Setoid)\nopen import Relation.Binary.PropositionalEquality using (refl)\n\nopen import Categories.Category.Instance.Sets\nopen import Categories.Category.Instance.Setoids\nimport Categories.Object.Initial as Init\n\nmodule _ {o : Level} where\n open Init (Sets o)\n\n EmptySet-⊥ : Initial\n EmptySet-⊥ = record { ⊥ = Lift o ⊥ ; ⊥-is-initial = record { ! = λ { {A} (lift x) → ⊥-elim x } ; !-unique = λ { f {()} } } }\n\nmodule _ {c ℓ : Level} where\n open Init (Setoids c ℓ)\n\n EmptySetoid : Setoid c ℓ\n EmptySetoid = record\n { Carrier = Lift c ⊥\n ; _≈_ = λ _ _ → Lift ℓ ⊤\n }\n\n EmptySetoid-⊥ : Initial\n EmptySetoid-⊥ = record\n { ⊥ = EmptySetoid\n ; ⊥-is-initial = record\n { ! = record\n { _⟨$⟩_ = λ { () }\n ; cong = λ { {()} }\n }\n ; !-unique = λ { _ {()} }\n }\n }\n", "meta": {"hexsha": "021f0ae6f38af81cfac77115dd1a70ea6cf3d6f9", "size": 1249, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Instance/EmptySet.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/Instance/EmptySet.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/Instance/EmptySet.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 26.5744680851, "max_line_length": 126, "alphanum_fraction": 0.6164931946, "num_tokens": 382, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872045937171068, "lm_q2_score": 0.7057850402140659, "lm_q1q2_score": 0.6261757298547321}} {"text": "-- Andreas, 2014-11-08\n-- This used to be a failed test case, but works now.\n\nopen import Common.Prelude\n\npostulate\n some : Nat\n\ndata D : Nat → Set where\n d₀ : D some\n d₁ : D (suc some)\n\nf : (n : Nat) → D n → Nat\nf .some d₀ = zero\nf .(suc some) d₁ = f some d₀\n\n-- Since x < suc x for all x in the structural order,\n-- some < suc some is a valid descent.\n", "meta": {"hexsha": "f97540a5718232a756f27ab86177cb2afc202c3e", "size": 366, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/DotSubTermination.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/DotSubTermination.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/DotSubTermination.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 19.2631578947, "max_line_length": 55, "alphanum_fraction": 0.6174863388, "num_tokens": 128, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8872045996818986, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.6261757175931232}} {"text": "module L.Base.Id.Properties where\n\nopen import L.Base.Id.Core\n\nsym : ∀{a} {A : Set a} {x y : A} → x ≡ y → y ≡ x\nsym {x = x}{y = y} = λ p → J (λ a b _ → b ≡ a) (λ _ → refl) x y p\n\ntran : ∀{a} {A : Set a} {x y z : A} → x ≡ y → y ≡ z → x ≡ z\ntran {x = x}{y = y}{z = z} =\n λ p → J (λ a b p → b ≡ z → a ≡ z) (λ a q → q) x y p\n\nap : ∀{a b} {A : Set a} {B : Set b} {x y : A}\n → (f : A → B) → x ≡ y → (f x) ≡ (f y)\nap {x = x}{y = y} =\n λ f p → J (λ a b p → (f a) ≡ (f b)) (λ u → refl) x y p\n\ntransport : ∀{a b} {A : Set a} {x y : A}\n → (B : (x : A) → Set b) → x ≡ y → B x → B y\ntransport {x = x}{y = y} =\n λ B p → J (λ a b p → B a → B b) (λ a q → q) x y p\n", "meta": {"hexsha": "4637bf04b8f743fd6b1689b03fd3c3f65d08571c", "size": 678, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/L/Base/Id/Properties.agda", "max_stars_repo_name": "borszag/smallib", "max_stars_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/L/Base/Id/Properties.agda", "max_issues_repo_name": "borszag/smallib", "max_issues_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 10, "max_issues_repo_issues_event_min_datetime": "2020-10-19T10:13:16.000Z", "max_issues_repo_issues_event_max_datetime": "2020-11-09T16:40:39.000Z", "max_forks_repo_path": "src/L/Base/Id/Properties.agda", "max_forks_repo_name": "borszag/smallib", "max_forks_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.2857142857, "max_line_length": 65, "alphanum_fraction": 0.3761061947, "num_tokens": 339, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467738423873, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.6261566216303742}} {"text": "{-# OPTIONS --cubical --safe #-}\nmodule Cubical.Foundations.Path where\n\nopen import Cubical.Core.Everything\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.GroupoidLaws\nopen import Cubical.Foundations.Isomorphism\n\nprivate\n variable\n ℓ ℓ' : Level\n A : Type ℓ\n\n-- Less polymorphic version of `cong`, to avoid some unresolved metas\ncong′ : ∀ {B : Type ℓ'} (f : A → B) {x y : A} (p : x ≡ y)\n → Path B (f x) (f y)\ncong′ f = cong f\n\n\n\ntoPathP-isEquiv : ∀ (A : I → Set ℓ){x y} → isEquiv (toPathP {A = A} {x} {y})\ntoPathP-isEquiv A {x} {y} = isoToIsEquiv (iso toPathP fromPathP to-from from-to)\n where\n to-from : ∀ (p : PathP A x y) → toPathP (fromPathP p) ≡ p\n to-from p h i = outS (hcomp-unique (λ { j (i = i0) → x ; j (i = i1) → fromPathP p j })\n (inS (transp (λ j → A (i ∧ j)) (~ i) x))\n \\ h → inS (sq1 h i))\n h\n where\n sq1 : (\\ h → A [ x ≡ transp (\\ j → A (h ∨ j)) h (p h) ]) [ (\\ i → transp (λ j → A (i ∧ j)) (~ i) x) ≡ p ]\n sq1 = \\ h i → comp (\\ z → (hcomp (\\ w →\n \\ { (z = i1) → A (i ∧ (w ∨ h))\n ; (z = i0) → A (i ∧ h)\n ; (i = i0) → A i0\n ; (i = i1) → A (h ∨ (w ∧ z))\n ; (h = i0) → A (i ∧ (w ∧ z))\n ; (h = i1) → A i})\n ((A (i ∧ h)))))\n (\\ z → \\ { (i = i0) → x\n ; (i = i1) → transp (\\ j → A (h ∨ (z ∧ j))) (h ∨ ~ z) (p h)\n ; (h = i0) → transp (λ j → A ((i ∧ z) ∧ j)) (~ (i ∧ z)) x\n ; (h = i1) → p i })\n (p (i ∧ h))\n from-to : ∀ (q : transp A i0 x ≡ y) → fromPathP (toPathP {A = A} q) ≡ q\n from-to q = (\\ h i → outS (transp-hcomp i {A' = A i1} (\\ j → inS (A (i ∨ j)))\n ((λ { j (i = i0) → x ; j (i = i1) → q j }))\n (inS ((transp (λ j → A (i ∧ j)) (~ i) x))))\n h)\n ∙ (\\ h i → outS (hcomp-unique {A = A i1} ((λ { j (i = i0) → transp A i0 x ; j (i = i1) → q j }))\n (inS ((transp (λ j → A (i ∨ j)) i (transp (λ j → A (i ∧ j)) (~ i) x))))\n \\ h → inS (sq2 h i))\n h)\n ∙ sym (lUnit q)\n where\n sq2 : (\\ h → transp A i0 x ≡ q h) [ (\\ i → transp (\\ j → A (i ∨ j)) i (transp (\\ j → A (i ∧ j)) (~ i) x)) ≡ refl ∙ q ]\n sq2 = \\ h i → comp (\\ z → hcomp (\\ w → \\ { (i = i1) → A i1\n ; (i = i0) → A (h ∨ (w ∧ z))\n ; (h = i0) → A (i ∨ (w ∧ z))\n ; (h = i1) → A i1\n ; (z = i0) → A (i ∨ h)\n ; (z = i1) → A ((i ∨ h) ∨ w) })\n (A (i ∨ h)))\n (\\ z → \\ { (i = i0) → transp (λ j → A ((z ∨ h) ∧ j)) (~ z ∧ ~ h) x\n ; (i = i1) → q (z ∧ h)\n ; (h = i1) → compPath-filler refl q z i\n ; (h = i0) → transp (\\ j → A (i ∨ (z ∧ j))) (i ∨ ~ z) (transp (\\ j → A (i ∧ j)) (~ i) x)\n })\n (transp (\\ j → A ((i ∨ h) ∧ j)) (~ (i ∨ h)) x)\n", "meta": {"hexsha": "80b7c0f1d7cfa7316a74b0d7ef14207d63c8f636", "size": 3791, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Foundations/Path.agda", "max_stars_repo_name": "cj-xu/cubical", "max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Foundations/Path.agda", "max_issues_repo_name": "cj-xu/cubical", "max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Foundations/Path.agda", "max_forks_repo_name": "cj-xu/cubical", "max_forks_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.1571428571, "max_line_length": 125, "alphanum_fraction": 0.2798733843, "num_tokens": 1185, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424489603726, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.6261449124809669}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nmodule Cubical.Categories.NaturalTransformation where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Categories.Category\nopen import Cubical.Categories.Functor\n\nprivate\n variable\n ℓC ℓC' ℓD ℓD' : Level\n\nmodule _ {C : Precategory ℓC ℓC'} {D : Precategory ℓD ℓD'} where\n -- syntax for sequencing in category D\n _⋆ᴰ_ : ∀ {x y z} (f : D [ x , y ]) (g : D [ y , z ]) → D [ x , z ]\n f ⋆ᴰ g = f ⋆⟨ D ⟩ g\n\n\n record NatTrans (F G : Functor C D) : Type (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD')) where\n open Precategory\n open Functor\n\n field\n -- components of the natural transformation\n N-ob : (x : C .ob) → D [(F .F-ob x) , (G .F-ob x)]\n -- naturality condition\n N-hom : {x y : C .ob} (f : C [ x , y ]) → (F .F-hom f) ⋆ᴰ (N-ob y) ≡ (N-ob x) ⋆ᴰ (G .F-hom f)\n\n\n open Precategory\n open Functor\n open NatTrans\n\n idTrans : (F : Functor C D) → NatTrans F F\n idTrans F .N-ob x = D .id (F .F-ob x)\n idTrans F .N-hom f =\n (F .F-hom f) ⋆ᴰ (idTrans F .N-ob _)\n ≡⟨ D .⋆IdR _ ⟩\n F .F-hom f\n ≡⟨ sym (D .⋆IdL _) ⟩\n (D .id (F .F-ob _)) ⋆ᴰ (F .F-hom f)\n ∎\n\n\n seqTrans : {F G H : Functor C D} (α : NatTrans F G) (β : NatTrans G H) → NatTrans F H\n seqTrans α β .N-ob x = (α .N-ob x) ⋆ᴰ (β .N-ob x)\n seqTrans {F} {G} {H} α β .N-hom f =\n (F .F-hom f) ⋆ᴰ ((α .N-ob _) ⋆ᴰ (β .N-ob _))\n ≡⟨ sym (D .⋆Assoc _ _ _) ⟩\n ((F .F-hom f) ⋆ᴰ (α .N-ob _)) ⋆ᴰ (β .N-ob _)\n ≡[ i ]⟨ (α .N-hom f i) ⋆ᴰ (β .N-ob _) ⟩\n ((α .N-ob _) ⋆ᴰ (G .F-hom f)) ⋆ᴰ (β .N-ob _)\n ≡⟨ D .⋆Assoc _ _ _ ⟩\n (α .N-ob _) ⋆ᴰ ((G .F-hom f) ⋆ᴰ (β .N-ob _))\n ≡[ i ]⟨ (α .N-ob _) ⋆ᴰ (β .N-hom f i) ⟩\n (α .N-ob _) ⋆ᴰ ((β .N-ob _) ⋆ᴰ (H .F-hom f))\n ≡⟨ sym (D .⋆Assoc _ _ _) ⟩\n ((α .N-ob _) ⋆ᴰ (β .N-ob _)) ⋆ᴰ (H .F-hom f)\n ∎\n\n module _ ⦃ D-category : isCategory D ⦄ {F G : Functor C D} {α β : NatTrans F G} where\n open Precategory\n open Functor\n open NatTrans\n\n makeNatTransPath : α .N-ob ≡ β .N-ob → α ≡ β\n makeNatTransPath p i .N-ob = p i\n makeNatTransPath p i .N-hom f = rem i\n where\n rem : PathP (λ i → (F .F-hom f) ⋆ᴰ (p i _) ≡ (p i _) ⋆ᴰ (G .F-hom f)) (α .N-hom f) (β .N-hom f)\n rem = toPathP (D-category .isSetHom _ _ _ _)\n\n\nmodule _ (C : Precategory ℓC ℓC') (D : Precategory ℓD ℓD') ⦃ _ : isCategory D ⦄ where\n open Precategory\n open NatTrans\n open Functor\n\n FUNCTOR : Precategory (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD')) (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD'))\n FUNCTOR .ob = Functor C D\n FUNCTOR .Hom[_,_] = NatTrans\n FUNCTOR .id = idTrans\n FUNCTOR ._⋆_ = seqTrans\n FUNCTOR .⋆IdL α = makeNatTransPath λ i x → D .⋆IdL (α .N-ob x) i\n FUNCTOR .⋆IdR α = makeNatTransPath λ i x → D .⋆IdR (α .N-ob x) i\n FUNCTOR .⋆Assoc α β γ = makeNatTransPath λ i x → D .⋆Assoc (α .N-ob x) (β .N-ob x) (γ .N-ob x) i\n", "meta": {"hexsha": "d540f18817be25550f844c843e7b3e09587d065a", "size": 2857, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/NaturalTransformation.agda", "max_stars_repo_name": "apabepa10/cubical", "max_stars_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Categories/NaturalTransformation.agda", "max_issues_repo_name": "apabepa10/cubical", "max_issues_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Categories/NaturalTransformation.agda", "max_forks_repo_name": "apabepa10/cubical", "max_forks_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.8390804598, "max_line_length": 103, "alphanum_fraction": 0.5330766538, "num_tokens": 1356, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.84594244507642, "lm_q2_score": 0.7401743563075446, "lm_q1q2_score": 0.6261449047576696}} {"text": "------------------------------------------------------------------------\n-- INCREMENTAL λ-CALCULUS\n--\n-- Delta-observational equivalence - base definitions\n------------------------------------------------------------------------\nmodule Base.Change.Equivalence.Base where\n\nopen import Relation.Binary.PropositionalEquality\nopen import Base.Change.Algebra\nopen import Function\n\nmodule _ {a} {A : Set a} {{ca : ChangeAlgebra A}} {x : A} where\n -- Delta-observational equivalence: these asserts that two changes\n -- give the same result when applied to a base value.\n\n -- To avoid unification problems, use a one-field record (a Haskell \"newtype\")\n -- instead of a \"type synonym\".\n record _≙_ (dx dy : Δ x) : Set a where\n -- doe = Delta-Observational Equivalence.\n constructor doe\n field\n proof : x ⊞ dx ≡ x ⊞ dy\n\n open _≙_ public\n\n -- Same priority as ≡\n infix 4 _≙_\n\n open import Relation.Binary\n\n -- _≙_ is indeed an equivalence relation:\n ≙-refl : ∀ {dx} → dx ≙ dx\n ≙-refl = doe refl\n\n ≙-sym : ∀ {dx dy} → dx ≙ dy → dy ≙ dx\n ≙-sym ≙ = doe $ sym $ proof ≙\n\n ≙-trans : ∀ {dx dy dz} → dx ≙ dy → dy ≙ dz → dx ≙ dz\n ≙-trans ≙₁ ≙₂ = doe $ trans (proof ≙₁) (proof ≙₂)\n\n -- That's standard congruence applied to ≙\n ≙-cong : ∀ {b} {B : Set b}\n (f : A → B) {dx dy} → dx ≙ dy → f (x ⊞ dx) ≡ f (x ⊞ dy)\n ≙-cong f da≙db = cong f $ proof da≙db\n\n ≙-isEquivalence : IsEquivalence (_≙_)\n ≙-isEquivalence = record\n { refl = ≙-refl\n ; sym = ≙-sym\n ; trans = ≙-trans\n }\n\n ≙-setoid : Setoid a a\n ≙-setoid = record\n { Carrier = Δ x\n ; _≈_ = _≙_\n ; isEquivalence = ≙-isEquivalence\n }\n\n≙-syntax : ∀ {a} {A : Set a} {{ca : ChangeAlgebra A}} (x : A) (dx₁ dx₂ : Δ x) → Set a\n≙-syntax x dx₁ dx₂ = _≙_ {x = x} dx₁ dx₂\nsyntax ≙-syntax x dx₁ dx₂ = dx₁ ≙₍ x ₎ dx₂\n", "meta": {"hexsha": "684d6b73d7744fc9211340ce70b39426309b6e9e", "size": 1819, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Base/Change/Equivalence/Base.agda", "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_issues_repo_path": "Base/Change/Equivalence/Base.agda", "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_forks_repo_path": "Base/Change/Equivalence/Base.agda", "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "avg_line_length": 28.873015873, "max_line_length": 85, "alphanum_fraction": 0.5420560748, "num_tokens": 637, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424295406087, "lm_q2_score": 0.7401743677704878, "lm_q1q2_score": 0.6261449029554506}} {"text": "module Numeral.Natural.Relation.Divisibility.Proofs where\n\nimport Lvl\nopen import Data\nopen import Data.Tuple as Tuple using (_⨯_ ; _,_)\nopen import Functional\nopen import Logic.Propositional\nopen import Logic.Propositional.Theorems\nopen import Logic.Predicate\nopen import Logic.Predicate.Theorems\nopen import Numeral.Finite\nopen import Numeral.Natural\nopen import Numeral.Natural.Function\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.Oper.Modulo\nopen import Numeral.Natural.Oper.Proofs\nopen import Numeral.Natural.Oper.Proofs.Multiplication\nopen import Numeral.Natural.Oper.Proofs.Order\nopen import Numeral.Natural.Relation\nopen import Numeral.Natural.Relation.Order\nopen import Numeral.Natural.Relation.Order.Classical\nopen import Numeral.Natural.Relation.Order.Proofs\nopen import Numeral.Natural.Relation.Order.Existence using ([≤]-equivalence)\nopen import Numeral.Natural.Relation.Order.Existence.Proofs using ()\nopen import Numeral.Natural.Relation.Divisibility\nopen import Relator.Equals\nopen import Relator.Equals.Proofs\nopen import Structure.Operator\nopen import Structure.Operator.Proofs.Util\nopen import Structure.Operator.Properties\nopen import Structure.Relator\nopen import Structure.Relator.Properties\nopen import Syntax.Transitivity\nopen import Type\nopen import Type.Properties.MereProposition\n\n{-\ndiv-elim-test : ∀{ℓ ℓ₁}{A : Type{ℓ₁}}{f : A → ℕ}{g : ℕ → ℕ}{P : ∀{y x} → (f(y) ∣ x) → Type{ℓ}} → (∀{y} → P(Div𝟎{f y})) → (∀{y x}{p : f y ∣ g x} → P(p) → P(Div𝐒 p)) → (∀{y x}{p : f(y) ∣ g x} → P(p))\ndiv-elim-test {f = f}{g = g} z s {y}{x}{p = p} with g(x)\n... | 𝟎 = {!p!}\n... | 𝐒 a = {!p!}\n-- div-elim-test z s {p = Div𝟎} = z\n-- div-elim-test{f = f}{P = P} z s {p = Div𝐒 p} = s(div-elim-test{f = f}{P = P} z s {p = p})\n-}\n\n{-\nEven-mereProposition : ∀{n} → MereProposition(Even(n))\nEven-mereProposition = intro proof where\n proof : ∀{n}{p q : Even n} → (p ≡ q)\n proof {𝟎} {Even0} {Even0} = [≡]-intro\n proof {𝐒(𝐒(n))} {Even𝐒 p} {Even𝐒 q} = [≡]-with(Even𝐒) (proof {n} {p} {q})\n\nOdd-mereProposition : ∀{n} → MereProposition(Odd(n))\nOdd-mereProposition = intro proof where\n proof : ∀{n}{p q : Odd n} → (p ≡ q)\n proof {𝐒(𝟎)} {Odd0} {Odd0} = [≡]-intro\n proof {𝐒(𝐒(n))} {Odd𝐒 p} {Odd𝐒 q} = [≡]-with(Odd𝐒) (proof {n} {p} {q})\n-}\n\n{-\n\ndiv-elim-test : ∀{f : ℕ → ℕ}{ℓ}{P : ∀{y x} → (f y ∣ x) → Type{ℓ}} → (∀{y} → P(Div𝟎{f y})) → (∀{y x}{p : f y ∣ x} → P(p) → P(Div𝐒 p)) → (∀{y x}{p : f y ∣ x} → P(p))\ndiv-elim-test z s {p = Div𝟎} = z\ndiv-elim-test{f = f}{P = P} z s {p = Div𝐒 p} = s(div-elim-test{f = f}{P = P} z s {p = p})\n\ndivides-mereProposition : ∀{d n} → MereProposition(𝐒(d) ∣ n)\ndivides-mereProposition = intro proof where\n proof : ∀{d n}{p q : (𝐒(d) ∣ n)} → (p ≡ q)\n proof {d} {.𝟎} {Div𝟎} {Div𝟎} = [≡]-intro\n proof {d} {.(𝐒 d + _)} {Div𝐒 p} {q} = {!div-elim-test{P = Div𝐒 p ≡_} ? ? {?}!}\n --proof{d}{n}{p}{q} = div-elim {P = \\q → ∀{p} → (p ≡ q)} (\\{y}{p} → {!div-elim {P = _≡ Div𝟎} ? ? {p = p}!}) {!!} {p = q}\n -- div-elim{P = {!!}} (div-elim {!!} {!!} {p = p}) (div-elim {!!} {!!} {p = p}) {p = q}\n\n {-\n test : ∀{y x} → (y ∣ x) → ∃{Obj = ℕ ⨯ ℕ}(Tuple.uncurry(_∣_))\n test {y}{.𝟎} Div𝟎 = [∃]-intro (y , 𝟎) ⦃ Div𝟎 ⦄\n test (Div𝐒 p) = [∃]-intro _ ⦃ p ⦄\n -}\n-}\n\nDivN : ∀{y : ℕ} → (n : ℕ) → (y ∣ (y ⋅ n))\nDivN {y}(𝟎) = Div𝟎\nDivN {y}(𝐒(n)) = Div𝐒(DivN{y}(n))\n\ndivides-quotient : ∀{x y} → (y ∣ x) → ℕ\ndivides-quotient = divides-elim 𝟎 𝐒\n\ndivides-quotient-correctness : ∀{x y}{yx : (y ∣ x)} → (y ⋅ (divides-quotient yx) ≡ x)\ndivides-quotient-correctness {yx = Div𝟎} = [≡]-intro\ndivides-quotient-correctness {_}{y} {yx = Div𝐒 yx} = congruence₂ᵣ(_+_)(y) (divides-quotient-correctness {yx = yx})\n\ndivides-[⋅]-existence : ∀{x y} → ∃(n ↦ y ⋅ n ≡ x) ↔ (y ∣ x)\ndivides-[⋅]-existence = [↔]-intro l r where\n l : ∀{x y} → (y ∣ x) → (∃(n ↦ y ⋅ n ≡ x))\n l yx = [∃]-intro (divides-quotient yx) ⦃ divides-quotient-correctness {yx = yx} ⦄\n\n r : ∀{x y} → (∃(n ↦ y ⋅ n ≡ x)) → (y ∣ x)\n r {x}{y} ([∃]-intro n ⦃ y⋅n≡x ⦄) = [≡]-substitutionᵣ y⋅n≡x {y ∣_} (DivN{y}(n))\n\ndivides-[⋅]-existence₊ : ∀{x y} → (y ∣ 𝐒(x)) → ∃(n ↦ y ⋅ 𝐒(n) ≡ 𝐒(x))\ndivides-[⋅]-existence₊ {x}{y} p with [↔]-to-[←] (divides-[⋅]-existence{𝐒(x)}{y}) p\n... | [∃]-intro (𝐒(n)) = [∃]-intro n\n\ninstance\n divides-transitivity : Transitivity(_∣_)\n Transitivity.proof (divides-transitivity) {a}{b}{c} (a-div-b) (b-div-c) with ([↔]-to-[←] divides-[⋅]-existence a-div-b , [↔]-to-[←] divides-[⋅]-existence b-div-c)\n ... | (([∃]-intro (n₁) ⦃ a⋅n₁≡b ⦄),([∃]-intro (n₂) ⦃ b⋅n₂≡c ⦄)) =\n ([↔]-to-[→] divides-[⋅]-existence\n ([∃]-intro\n (n₁ ⋅ n₂)\n ⦃\n (symmetry(_≡_) (associativity(_⋅_) {a}{n₁}{n₂}))\n 🝖 ([≡]-with(expr ↦ expr ⋅ n₂) (a⋅n₁≡b))\n 🝖 (b⋅n₂≡c)\n ⦄\n )\n )\n\ndivides-with-[+] : ∀{a b c} → (a ∣ b) → (a ∣ c) → (a ∣ (b + c))\ndivides-with-[+] {a}{b}{c} (a-div-b) (a-div-c) with ([↔]-to-[←] divides-[⋅]-existence a-div-b , [↔]-to-[←] divides-[⋅]-existence a-div-c)\n... | (([∃]-intro (n₁) ⦃ a⋅n₁≡b ⦄),([∃]-intro (n₂) ⦃ a⋅n₂≡c ⦄)) =\n ([↔]-to-[→] divides-[⋅]-existence\n ([∃]-intro\n (n₁ + n₂)\n ⦃\n (distributivityₗ(_⋅_)(_+_) {a}{n₁}{n₂})\n 🝖 ([≡]-with-op(_+_)\n (a⋅n₁≡b)\n (a⋅n₂≡c)\n )\n ⦄\n )\n )\n\ndivides-with-[−₀] : ∀{a b c} → (a ∣ b) → (a ∣ c) → (a ∣ (b −₀ c))\ndivides-with-[−₀] {a}{b}{c} (a-div-b) (a-div-c) with ([↔]-to-[←] divides-[⋅]-existence a-div-b , [↔]-to-[←] divides-[⋅]-existence a-div-c)\n... | (([∃]-intro (n₁) ⦃ a⋅n₁≡b ⦄),([∃]-intro (n₂) ⦃ a⋅n₂≡c ⦄)) =\n ([↔]-to-[→] divides-[⋅]-existence\n ([∃]-intro\n (n₁ −₀ n₂)\n ⦃\n (distributivityₗ(_⋅_)(_−₀_) {a}{n₁}{n₂})\n 🝖 ([≡]-with-op(_−₀_)\n (a⋅n₁≡b)\n (a⋅n₂≡c)\n )\n ⦄\n )\n )\n\ndivides-without-[+] : ∀{a b c} → (a ∣ (b + c)) → ((a ∣ b) ↔ (a ∣ c))\ndivides-without-[+] {a}{b}{c} abc = [↔]-intro (l abc) (r abc) where\n l : ∀{a b c} → (a ∣ (b + c)) → (a ∣ b) ← (a ∣ c)\n l{a}{b}{c} abc ac = [≡]-substitutionᵣ ([−₀]ₗ[+]ᵣ-nullify{b}{c}) {expr ↦ (a ∣ expr)} (divides-with-[−₀] {a}{b + c}{c} abc ac)\n\n r : ∀{a b c} → (a ∣ (b + c)) → (a ∣ b) → (a ∣ c)\n r{a}{b}{c} abc ab = l {a}{c}{b} ([≡]-substitutionᵣ (commutativity(_+_) {b}{c}) {expr ↦ a ∣ expr} abc) ab\n\ndivides-with-[𝄩] : ∀{a b c} → (a ∣ b) → (a ∣ c) → (a ∣ (b 𝄩 c))\ndivides-with-[𝄩] {a} ab ac\n with [∃]-intro n₁ ⦃ p ⦄ ← [↔]-to-[←] divides-[⋅]-existence ab\n with [∃]-intro n₂ ⦃ q ⦄ ← [↔]-to-[←] divides-[⋅]-existence ac\n = [↔]-to-[→] divides-[⋅]-existence ([∃]-intro (n₁ 𝄩 n₂) ⦃ distributivityₗ(_⋅_)(_𝄩_) {a}{n₁}{n₂} 🝖 congruence₂(_𝄩_) p q ⦄)\n\n-- instance\n-- divides-with-fn : ∀{a b} → (a ∣ b) → ∀{f : ℕ → ℕ} → {_ : ∀{x y : ℕ} → ∃{ℕ → ℕ}(\\g → f(x ⋅ y) ≡ f(x) ⋅ g(y))} → ((f(a)) ∣ (f(b)))\n-- divides-with-fn {a}{b} (a-div-b) {f} ⦃ f-prop ⦄ \n\ninstance\n [1]-divides : ∀{n} → (1 ∣ n)\n [1]-divides {𝟎} = Div𝟎\n [1]-divides {𝐒(n)} =\n [≡]-substitutionₗ\n (commutativity(_+_) {n}{1})\n {expr ↦ (1 ∣ expr)}\n (Div𝐒([1]-divides{n}))\n\n-- TODO: Rename these reflexivity proofs\ninstance\n divides-reflexivity : ∀{n} → (n ∣ n)\n divides-reflexivity = Div𝐒(Div𝟎)\n\ninstance\n divides-reflexivity-instance : Reflexivity(_∣_)\n divides-reflexivity-instance = intro divides-reflexivity\n\ninstance\n [0]-divides-[0] : (0 ∣ 0)\n [0]-divides-[0] = Div𝟎\n\n[0]-only-divides-[0] : ∀{n} → (0 ∣ n) → (n ≡ 0)\n[0]-only-divides-[0] {𝟎} _ = [≡]-intro\n[0]-only-divides-[0] {𝐒(n)} proof with () ← [∃]-proof([↔]-to-[←] divides-[⋅]-existence proof)\n\n[0]-divides-not : ∀{n} → ¬(0 ∣ 𝐒(n))\n[0]-divides-not (0divSn) = [𝐒]-not-0([0]-only-divides-[0] 0divSn)\n\ndivides-not-[1] : ∀{n} → ¬((n + 2) ∣ 1)\ndivides-not-[1] ()\n\n[1]-only-divides-[1] : ∀{n} → (n ∣ 1) → (n ≡ 1)\n[1]-only-divides-[1] {𝟎} ndiv1 = [⊥]-elim ([0]-divides-not ndiv1)\n[1]-only-divides-[1] {𝐒(𝟎)} ndiv1 = [≡]-intro\n[1]-only-divides-[1] {𝐒(𝐒(n))} ()\n\ndivides-with-[⋅] : ∀{a b c} → ((a ∣ b) ∨ (a ∣ c)) → (a ∣ (b ⋅ c))\ndivides-with-[⋅] {a}{b}{c} = [∨]-elim (l{a}{b}{c}) (r{a}{b}{c}) where\n l : ∀{a b c} → (a ∣ b) → (a ∣ (b ⋅ c))\n l Div𝟎 = Div𝟎\n l {a}{a}{c} (Div𝐒 Div𝟎) = DivN{a} c\n l {a} {.(a + x)} {c} (Div𝐒 {.a} {x} ab@(Div𝐒 _)) = [≡]-substitutionₗ (distributivityᵣ(_⋅_)(_+_) {a}{x}{c}) {a ∣_} (divides-with-[+] (l {a}{a}{c} (Div𝐒 Div𝟎)) (l {a}{x}{c} ab))\n\n r : ∀{a b c} → (a ∣ c) → (a ∣ (b ⋅ c))\n r {a}{b}{c} ac = [≡]-substitutionᵣ (commutativity(_⋅_) {c}{b}) {a ∣_} (l {a}{c}{b} ac)\n\ndivides-upper-limit : ∀{a b} → (a ∣ 𝐒(b)) → (a ≤ 𝐒(b))\ndivides-upper-limit {𝟎} {_} (proof) = [⊥]-elim ([0]-divides-not (proof))\ndivides-upper-limit {𝐒(a)}{b} (proof) = ([↔]-to-[→] [≤]-equivalence) (existence2) where\n existence1 : ∃(n ↦ 𝐒(a) + (𝐒(a) ⋅ n) ≡ 𝐒(b))\n existence1 = divides-[⋅]-existence₊(proof)\n\n existence2 : ∃(n ↦ 𝐒(a) + n ≡ 𝐒(b))\n existence2 = [∃]-intro(𝐒(a) ⋅ [∃]-witness(existence1)) ⦃ [∃]-proof(existence1) ⦄\n\ndivides-not-lower-limit : ∀{a b} → (a > 𝐒(b)) → (a ∤ 𝐒(b))\ndivides-not-lower-limit {a}{b} = (contrapositiveᵣ (divides-upper-limit {a}{b})) ∘ [>]-to-[≰]\n\nDiv𝐏 : ∀{x y : ℕ} → (y ∣ (y + x)) → (y ∣ x)\nDiv𝐏 {x}{y} proof = [↔]-to-[→] (divides-without-[+] {y}{y}{x} proof) (divides-reflexivity)\n\nDiv𝐏-monus : ∀{x y : ℕ} → (y ∣ x) → (y ∣ (x −₀ y))\nDiv𝐏-monus Div𝟎 = Div𝟎\nDiv𝐏-monus {.(y + x)}{y} (Div𝐒 {_}{x} yx) = [≡]-substitutionₗ ([−₀]ₗ[+]ₗ-nullify {y}{x}) {y ∣_} yx\n\ndivides-with-[⋅]ₗ-both : ∀{x y z} → (x ∣ y) → (z ⋅ x ∣ z ⋅ y)\ndivides-with-[⋅]ₗ-both {x} {.0} {z} Div𝟎 = Div𝟎\ndivides-with-[⋅]ₗ-both {x} {.(x + _)} {z} (Div𝐒 {_}{y} xy) rewrite distributivityₗ(_⋅_)(_+_) {z}{x}{y} = Div𝐒 (divides-with-[⋅]ₗ-both {x}{y}{z} xy)\n\ndivides-with-[⋅]ᵣ-both : ∀{x y z} → (x ∣ y) → (x ⋅ z ∣ y ⋅ z)\ndivides-with-[⋅]ᵣ-both {x} {.0} {z} Div𝟎 = Div𝟎\ndivides-with-[⋅]ᵣ-both {x} {.(x + _)} {z} (Div𝐒 {_}{y} xy) rewrite distributivityᵣ(_⋅_)(_+_) {x}{y}{z} = Div𝐒 (divides-with-[⋅]ᵣ-both {x}{y}{z} xy)\n\ndivides-with-[⋅]-both : ∀{x₁ y₁ x₂ y₂} → (x₁ ∣ y₁) → (x₂ ∣ y₂) → (x₁ ⋅ x₂ ∣ y₁ ⋅ y₂)\ndivides-with-[⋅]-both {x₁}{y₁}{x₂}{y₂} xy1 xy2\n with [∃]-intro n₁ ⦃ [≡]-intro ⦄ ← [↔]-to-[←] divides-[⋅]-existence xy1\n with [∃]-intro n₂ ⦃ [≡]-intro ⦄ ← [↔]-to-[←] divides-[⋅]-existence xy2\n = [↔]-to-[→] divides-[⋅]-existence ([∃]-intro (n₁ ⋅ n₂) ⦃ One.associate-commute4 {_▫_ = _⋅_} {a = x₁}{x₂}{n₁}{n₂} (commutativity(_⋅_) {x₂}{n₁}) ⦄)\n\ndivides-with-[^] : ∀{a b n} → (a ∣ b) → ((a ^ n) ∣ (b ^ n))\ndivides-with-[^] {n = 𝟎} _ = Div𝐒 Div𝟎\ndivides-with-[^] {n = 𝐒 n} ab = divides-with-[⋅]-both ab (divides-with-[^] {n = n} ab)\n\ndivides-withᵣ-[^] : ∀{a b n} → ⦃ pos : Positive(n) ⦄ → (a ∣ b) → (a ∣ (b ^ n))\ndivides-withᵣ-[^] {a}{b}{𝐒 n} ab = divides-with-[⋅] {a}{b}{b ^ n} ([∨]-introₗ ab)\n\ndivides-without-[⋅]ᵣ-both : ∀{x y z} → (x ⋅ 𝐒(z) ∣ y ⋅ 𝐒(z)) → (x ∣ y)\ndivides-without-[⋅]ᵣ-both {x}{y}{z} p\n with [∃]-intro n ⦃ peq ⦄ ← [↔]-to-[←] divides-[⋅]-existence p\n = [↔]-to-[→] divides-[⋅]-existence ([∃]-intro n ⦃ [⋅]-cancellationᵣ{𝐒(z)} (symmetry(_≡_) (One.commuteᵣ-assocₗ{_▫_ = _⋅_}{x}{𝐒(z)}{n}) 🝖 peq) ⦄)\n\ndivides-without-[⋅]ₗ-both : ∀{x y z} → (𝐒(z) ⋅ x ∣ 𝐒(z) ⋅ y) → (x ∣ y)\ndivides-without-[⋅]ₗ-both {x}{y}{z} p = divides-without-[⋅]ᵣ-both {x}{y}{z} (substitute₂(_∣_) (commutativity(_⋅_) {𝐒(z)}{x}) (commutativity(_⋅_) {𝐒(z)}{y}) p)\n\ndivides-without-[⋅]ᵣ-both' : ∀{x y z} → (z > 0) → (x ⋅ z ∣ y ⋅ z) → (x ∣ y)\ndivides-without-[⋅]ᵣ-both' {x}{y}{𝐒(z)} _ = divides-without-[⋅]ᵣ-both {x}{y}{z}\n\ndivides-without-[⋅]ₗ-both' : ∀{x y z} → (z > 0) → (z ⋅ x ∣ z ⋅ y) → (x ∣ y)\ndivides-without-[⋅]ₗ-both' {x}{y}{𝐒(z)} _ = divides-without-[⋅]ₗ-both {x}{y}{z}\n\ndivides-factorial : ∀{n x} → (𝐒(x) ≤ n) → (𝐒(x) ∣ (n !))\ndivides-factorial {.(𝐒 y)}{.x} (succ {x}{y} xy) with [≥]-or-[<] {x}{y}\n... | [∨]-introₗ yx with [≡]-intro ← antisymmetry(_≤_)(_≡_) xy yx = divides-with-[⋅] {𝐒(x)}{𝐒(x)}{x !} ([∨]-introₗ(reflexivity(_∣_)))\n... | [∨]-introᵣ sxy = divides-with-[⋅] {𝐒(x)}{𝐒(y)}{y !} ([∨]-introᵣ(divides-factorial{y}{x} sxy))\n\ninstance\n divides-antisymmetry : Antisymmetry(_∣_)(_≡_)\n Antisymmetry.proof divides-antisymmetry {𝟎} {𝟎} ab ba = [≡]-intro\n Antisymmetry.proof divides-antisymmetry {𝟎} {𝐒 b} ab ba with () ← [0]-divides-not ab\n Antisymmetry.proof divides-antisymmetry {𝐒 a} {𝟎} ab ba with () ← [0]-divides-not ba\n Antisymmetry.proof divides-antisymmetry {𝐒 a} {𝐒 b} ab ba = antisymmetry(_≤_)(_≡_) (divides-upper-limit ab) (divides-upper-limit ba)\n\ndivides-quotient-positive : ∀{d n}{dn : (d ∣ 𝐒(n))} → (divides-quotient dn ≥ 1)\ndivides-quotient-positive {𝟎} {n} {dn = dn} with () ← [0]-divides-not dn\ndivides-quotient-positive {𝐒 d} {.(d + _)} {dn = Div𝐒 dn} = succ _≤_.min\n\ndivides-quotient-composite : ∀{d n} → (d ≥ 2) → (d < n) → ∀{dn : (d ∣ n)} → (divides-quotient dn ≥ 2)\ndivides-quotient-composite l g {Div𝐒 {x = 𝟎} dn} with () ← irreflexivity(_<_) g\ndivides-quotient-composite l g {Div𝐒 {x = 𝐒 x} dn} = succ (divides-quotient-positive {dn = dn})\n\n", "meta": {"hexsha": "6774d064db4e7ce1a387103014ff31f466594467", "size": 12778, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Relation/Divisibility/Proofs.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Relation/Divisibility/Proofs.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Relation/Divisibility/Proofs.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.0620689655, "max_line_length": 197, "alphanum_fraction": 0.5244169667, "num_tokens": 6425, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424489603726, "lm_q2_score": 0.7401743505760728, "lm_q1q2_score": 0.6261449027839765}} {"text": "module 747Connectives where\n\n-- Library\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl)\nopen Eq.≡-Reasoning\nopen import Data.Nat using (ℕ)\nopen import Function using (_∘_)\n\n-- Copied from 747Isomorphism.\n\npostulate\n extensionality : ∀ {A B : Set} {f g : A → B}\n → (∀ (x : A) → f x ≡ g x)\n -----------------------\n → f ≡ g\n\ninfix 0 _≃_\nrecord _≃_ (A B : Set) : Set where\n constructor mk-≃ -- This has been added, not in PLFA\n field\n to : A → B\n from : B → A\n from∘to : ∀ (x : A) → from (to x) ≡ x\n to∘from : ∀ (y : B) → to (from y) ≡ y\nopen _≃_\n\ninfix 0 _≲_\nrecord _≲_ (A B : Set) : Set where\n field\n to : A → B\n from : B → A\n from∘to : ∀ (x : A) → from (to x) ≡ x\nopen _≲_\n\nrecord _⇔_ (A B : Set) : Set where\n field\n to : A → B\n from : B → A\nopen _⇔_ \n\n-- You may copy over the various reasoning modules if you wish.\n\n-- End of code from 747Isomorphism.\n\n-- Logical AND is Cartesian product.\n\ndata _×_ (A : Set) (B : Set) : Set where\n\n ⟨_,_⟩ : \n A\n → B\n -----\n → A × B\n\n-- Destructors (eliminators) for ×.\n\nproj₁ : ∀ {A B : Set}\n → A × B\n -----\n → A\n\nproj₁ A×B = {!!}\n\nproj₂ : ∀ {A B : Set}\n → A × B\n -----\n → B\n\nproj₂ A×B = {!!}\n\n-- An easier (equivalent) construction using records.\n\nrecord _×′_ (A B : Set) : Set where\n field\n proj₁′ : A\n proj₂′ : B\nopen _×′_\n\n-- Eta-equivalence relates constructors and destructors.\n\nη-× : ∀ {A B : Set} (w : A × B) → ⟨ proj₁ w , proj₂ w ⟩ ≡ w\nη-× A×B = {!!}\n\n-- Bool (Booleans), a type with exactly two members.\n\ninfixr 2 _×_\ndata Bool : Set where\n true : Bool\n false : Bool\n\n-- A type with three members (useful for examples).\n\ndata Tri : Set where\n aa : Tri\n bb : Tri\n cc : Tri\n\n-- Bool × Tri has six members.\n-- Here is a function counting them.\n\n×-count : Bool × Tri → ℕ\n×-count ⟨ true , aa ⟩ = 1\n×-count ⟨ true , bb ⟩ = 2\n×-count ⟨ true , cc ⟩ = 3\n×-count ⟨ false , aa ⟩ = 4\n×-count ⟨ false , bb ⟩ = 5\n×-count ⟨ false , cc ⟩ = 6\n\n-- Cartesian product is commutative and associative up to isomorphism.\n\n×-comm : ∀ {A B : Set} → A × B ≃ B × A\n×-comm = {!!}\n\n×-assoc : ∀ {A B C : Set} → (A × B) × C ≃ A × (B × C)\n×-assoc = {!!}\n\n-- 747/PLFA exercise: IffIsoIfOnlyIf (1 point)\n-- Show A ⇔ B is isomorphic to (A → B) × (B → A).\n\niff-iso-if-onlyif : ∀ {A B : Set} → A ⇔ B ≃ (A → B) × (B → A)\niff-iso-if-onlyif = {!!}\n\n-- Logical True is a type with one member (unit)\n\ndata ⊤ : Set where\n\n tt :\n --\n ⊤\n\nη-⊤ : ∀ (w : ⊤) → tt ≡ w\nη-⊤ w = {!!}\n\n⊤-count : ⊤ → ℕ\n⊤-count tt = 1\n\n-- Unit is the left and right identity of product.\n\n⊤-identityˡ : ∀ {A : Set} → ⊤ × A ≃ A\n⊤-identityˡ = {!!}\n\n⊤-identityʳ : ∀ {A : Set} → (A × ⊤) ≃ A\n⊤-identityʳ = {!!}\n\n-- Logical OR (disjunction) is sum (disjoint union).\n\ndata _⊎_ : Set → Set → Set where\n\n inj₁ : ∀ {A B : Set}\n → A\n -----\n → A ⊎ B\n\n inj₂ : ∀ {A B : Set}\n → B\n -----\n → A ⊎ B\n\n-- One way to eliminate a sum.\n\ncase-⊎ : ∀ {A B C : Set}\n → (A → C)\n → (B → C)\n → A ⊎ B\n -----------\n → C\ncase-⊎ f g s = {!!}\n\n-- We typically use pattern-matching to eliminate sums.\n\n-- Eta equivalence for sums.\n\nη-⊎ : ∀ {A B : Set} (w : A ⊎ B) → case-⊎ inj₁ inj₂ w ≡ w\nη-⊎ w = {!!}\n\n-- A generalization.\n\nuniq-⊎ : ∀ {A B C : Set} (h : A ⊎ B → C) (w : A ⊎ B) →\n case-⊎ (h ∘ inj₁) (h ∘ inj₂) w ≡ h w\nuniq-⊎ h w = {!!}\n\ninfix 1 _⊎_\n\n-- Bool ⊎ Tri has five members\n\n⊎-count : Bool ⊎ Tri → ℕ\n⊎-count (inj₁ true) = 1\n⊎-count (inj₁ false) = 2\n⊎-count (inj₂ aa) = 3\n⊎-count (inj₂ bb) = 4\n⊎-count (inj₂ cc) = 5\n\n-- 747/PLFA exercise: SumCommIso (1 point)\n-- Sum is commutative up to isomorphism.\n\n⊎-comm : ∀ {A B : Set} → A ⊎ B ≃ B ⊎ A\n⊎-comm = {!!}\n\n-- 747/PLFA exercise: SumAssocIso (1 point)\n-- Sum is associative up to isomorphism.\n\n⊎-assoc : ∀ {A B C : Set} → (A ⊎ B) ⊎ C ≃ A ⊎ (B ⊎ C)\n⊎-assoc = {!!}\n\n-- Logical False is the empty type (\"bottom\", \"empty\").\n\ndata ⊥ : Set where\n -- no clauses!\n\n-- Ex falso quodlibet \"from falsehood, anything follows\".\n\n⊥-elim : ∀ {A : Set}\n → ⊥\n --\n → A\n\n⊥-elim w = {!!}\n\nuniq-⊥ : ∀ {C : Set} (h : ⊥ → C) (w : ⊥) → ⊥-elim w ≡ h w\nuniq-⊥ h w = {!!}\n\n⊥-count : ⊥ → ℕ\n⊥-count w = {!!}\n\n-- 747/PLFA exercise: EmptyLeftIdSumIso (1 point)\n-- Empty is the left unit of sum up to isomorphism.\n\n⊎-identityˡ : ∀ {A : Set} → ⊥ ⊎ A ≃ A\n⊎-identityˡ = {!!}\n\n-- 747/PLFA exercise: EmptyRightIdSumIso (1 point)\n-- Empty is the right unit of sum up to isomorphism.\n\n⊎-identityʳ : ∀ {A : Set} → A ⊎ ⊥ ≃ A\n⊎-identityʳ = {!!}\n\n-- Logical implication (if-then) is... the function type constructor!\n-- Eliminating an if-then (modus ponens) is function application.\n\n→-elim : ∀ {A B : Set}\n → (A → B)\n → A\n -------\n → B\n\n→-elim L M = L M\n\n-- This works because eta-reduction for → is built in.\n\nη-→ : ∀ {A B : Set} (f : A → B) → (λ (x : A) → f x) ≡ f\nη-→ f = refl\n\n-- The function space A → B is sometimes called the exponential Bᴬ.\n-- Bool → Tri has 3² or 9 members.\n\n→-count : (Bool → Tri) → ℕ\n→-count f with f true | f false\n... | aa | aa = 1\n... | aa | bb = 2\n... | aa | cc = 3\n... | bb | aa = 4\n... | bb | bb = 5\n... | bb | cc = 6\n... | cc | aa = 7\n... | cc | bb = 8\n... | cc | cc = 9\n\n-- In math, (p ^ n) ^ m = p ^ (n * m).\n-- For types, (A ^ B) ^ C ≃ A ^ (B × C).\n\n-- In a language where functions take multiple parameters,\n-- this is called \"currying\".\n\ncurrying : ∀ {A B C : Set} → (A → B → C) ≃ (A × B → C)\ncurrying = {!!}\n\n-- In math, p ^ (n + m) = (p ^ n) * (p ^ m).\n-- For types, (A ⊎ B → C) ≃ ((A → C) × (B → C)).\n\n→-distrib-⊎ : ∀ {A B C : Set} → (A ⊎ B → C) ≃ ((A → C) × (B → C))\n→-distrib-⊎ = {!!}\n\n-- In math, (p * n) ^ m = (p ^ m) * (n ^ m).\n-- For types, (A → B × C) ≃ (A → B) × (A → C).\n\n→-distrib-× : ∀ {A B C : Set} → (A → B × C) ≃ (A → B) × (A → C)\n→-distrib-× = {!!}\n\n-- More distributive laws.\n\n×-distrib-⊎ : ∀ {A B C : Set} → (A ⊎ B) × C ≃ (A × C) ⊎ (B × C)\n×-distrib-⊎ = {!!}\n\n⊎-distrib-× : ∀ {A B C : Set} → (A × B) ⊎ C ≲ (A ⊎ C) × (B ⊎ C)\n⊎-distrib-× = {!!}\n\n-- Think of a counterexample to show the above isn't an isomorphism.\n\n-- 747/PLFA exercise: ImpProdRightDist (1 point)\n\n×-distrib-→ : ∀ {A B C : Set} → (C → (A × B)) ≃ (C → A) × (C → B)\n×-distrib-→ = {!!}\n\n-- 747/PLFA exercise: ImpSumLeftDist (1 point)\n\n⊎-distrib-→ : ∀ {A B C : Set} → ((A ⊎ B) → C) ≃ (A → C) × (B → C)\n⊎-distrib-→ = {!!}\n\n-- PLFA exercise: a weak distributive law.\n-- ⊎-weak-× : ∀ {A B C : Set} → (A ⊎ B) × C → A ⊎ (B × C)\n-- ⊎-weak-× A⊎B×C = {!!}\n-- State and prove the strong law, and explain the relationship.\n\n-- 747/PLFA exercise: SumOfProdImpProdOfSum (1 point)\n-- A disjunct of conjuncts implies a conjunct of disjuncts.\n\n⊎×-implies-×⊎ : ∀ {A B C D : Set} → (A × B) ⊎ (C × D) → (A ⊎ C) × (B ⊎ D)\n⊎×-implies-×⊎ A×B⊎C×D = {!!}\n\n-- PLFA exercise: Is the converse true? If so, prove it; if not, give a counterexample.\n\n-- See PLFA for a number of slight differences with the standard library.\n\n-- Unicode introduced in this chapter:\n\n{-\n\n × U+00D7 MULTIPLICATION SIGN (\\x)\n ⊎ U+228E MULTISET UNION (\\u+)\n ⊤ U+22A4 DOWN TACK (\\top)\n ⊥ U+22A5 UP TACK (\\bot)\n η U+03B7 GREEK SMALL LETTER ETA (\\eta)\n ₁ U+2081 SUBSCRIPT ONE (\\_1)\n ₂ U+2082 SUBSCRIPT TWO (\\_2)\n ⇔ U+21D4 LEFT RIGHT DOUBLE ARROW (\\<=>, \\iff, \\lr=)\n\n-}\n", "meta": {"hexsha": "b489f113cc9a952fcef86c8c1a652257f344c93b", "size": 7411, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x06-747Connectives.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x06-747Connectives.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x06-747Connectives.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 21.7970588235, "max_line_length": 87, "alphanum_fraction": 0.5000674673, "num_tokens": 3076, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424217727027, "lm_q2_score": 0.7401743735019595, "lm_q1q2_score": 0.6261449020543406}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Refinement type: a value together with an erased proof.\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Refinement where\n\nopen import Level\nopen import Data.Erased as Erased using (Erased)\nopen import Function.Base\nopen import Relation.Unary\n\nprivate\n variable\n a b p q : Level\n A : Set a\n B : Set b\n\nrecord Refinement {a p} (A : Set a) (P : A → Set p) : Set (a ⊔ p) where\n constructor _,_\n field value : A\n proof : Erased (P value)\nopen Refinement public\n\n-- The syntax declaration below is meant to mimick set comprehension.\n-- It is attached to Refinement-syntax, to make it easy to import\n-- Data.Refinement without the special syntax.\n\ninfix 2 Refinement-syntax\nRefinement-syntax = Refinement\nsyntax Refinement-syntax A (λ x → P) = [ x ∈ A ∣ P ]\n\nmodule _ {P : A → Set p} {Q : B → Set q} where\n\n map : (f : A → B) → ∀[ P ⇒ f ⊢ Q ] →\n [ a ∈ A ∣ P a ] → [ b ∈ B ∣ Q b ]\n map f prf (a , p) = f a , Erased.map prf p\n\nmodule _ {P : A → Set p} {Q : A → Set q} where\n\n refine : ∀[ P ⇒ Q ] → [ a ∈ A ∣ P a ] → [ a ∈ A ∣ Q a ]\n refine = map id\n", "meta": {"hexsha": "3cabaea29bd27da2fad7ce0651664df497f8224f", "size": 1252, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/Refinement.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Data/Refinement.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Data/Refinement.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 27.2173913043, "max_line_length": 72, "alphanum_fraction": 0.5431309904, "num_tokens": 361, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424373085145, "lm_q2_score": 0.7401743563075446, "lm_q1q2_score": 0.6261448990080651}} {"text": "\nid : forall {k}{X : Set k} -> X -> X\nid x = x\n\n_o_ : forall {i j k}\n {A : Set i}{B : A -> Set j}{C : (a : A) -> B a -> Set k} ->\n (f : {a : A}(b : B a) -> C a b) ->\n (g : (a : A) -> B a) ->\n (a : A) -> C a (g a)\nf o g = \\ a -> f (g a)\n\ndata List (X : Set) : Set where\n [] : List X\n _,_ : X → List X → List X\n\ndata Nat : Set where\n zero : Nat\n suc : Nat → Nat\n\n{-# BUILTIN NATURAL Nat #-}\n\ndata Vec (X : Set) : Nat -> Set where\n [] : Vec X 0\n _,_ : { n : Nat } → X → Vec X n → Vec X (suc n)\n\nvec : forall { n X } → X → Vec X n\nvec {zero} a = []\nvec {suc n} a = a , vec a\n\nvapp : forall { n S T } → Vec (S → T) n → Vec S n → Vec T n\nvapp [] [] = []\nvapp (x , st) (x₁ , s) = x x₁ , vapp st s\n\nrecord Applicative (F : Set → Set) : Set₁ where\n infixl 2 _⊛_\n field\n pure : forall { X } → X → F X\n _⊛_ : forall { S T } → F (S → T) → F S → F T\n\nopen Applicative {{...}} public\n\ninstance\n applicativeVec : forall { n } → Applicative (λ X → Vec X n)\n applicativeVec = record { pure = vec; _⊛_ = vapp }\n\ninstance\n applicativeComp : forall {F G} {{_ : Applicative F}} {{_ : Applicative G}} → Applicative (F o G)\n applicativeComp {{af}} {{ag}} =\n record\n { pure = λ z → Applicative.pure af (Applicative.pure ag z)\n ; _⊛_ = λ z → {!!}\n }\n\nrecord Traversable (T : Set → Set) : Set1 where\n field\n traverse : forall { F A B } {{ AF : Applicative F }} → (A → F B) → T A → F (T B)\n\nopen Traversable {{...}} public\n\ninstance\n traversableVec : forall {n} → Traversable (\\X → Vec X n)\n traversableVec = record { traverse = vtr } where\n vtr : forall { n F A B } {{ AF : Applicative F }} → (A → F B) → Vec A n → F (Vec B n)\n vtr {{AF}} f [] = Applicative.pure AF []\n vtr {{AF}} f (x , v) =\n Applicative._⊛_ AF (Applicative._⊛_ AF (Applicative.pure AF _,_) (f x)) (vtr f v)\n", "meta": {"hexsha": "bb0da65225f51970fb3dabd76a89b0fcef70c69a", "size": 1804, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/Issue2993.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Fail/Issue2993.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Fail/Issue2993.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 26.9253731343, "max_line_length": 98, "alphanum_fraction": 0.516075388, "num_tokens": 699, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424295406088, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.6261448981069556}} {"text": "\n{-# OPTIONS --no-universe-polymorphism #-}\nopen import Data.Product hiding (map)\nopen import Relation.Binary.Core hiding (Total)\nopen import Relation.Nullary\nopen import Data.Nat\nimport Level as L using (zero)\nopen import Data.List\nopen import Data.Unit using (⊤)\nopen import Data.Empty\n\nopen import DivideEtImpera\nopen import Equivalence\nopen import BagEquality\nopen import Lists\n\nmodule Quicksort where\n\n\nsplitWith : {A : Set} {P Q : A → Set} → (∀ x → P x ⊕ Q x) → List A → List A × List A\nsplitWith _ [] = ([] , [])\nsplitWith decPQ (x ∷ xs) with (decPQ x)\nsplitWith decPQ (x ∷ xs) | (inj₁ _) = (x ∷ (proj₁ res), proj₂ res) where\n res = splitWith decPQ xs\nsplitWith decPQ (x ∷ xs) | (inj₂ _) = (proj₁ res , x ∷ (proj₂ res)) where\n res = splitWith decPQ xs\n\n\nsplitWithProp1 : {A : Set} {P Q : A → Set} → (decPQ : ∀ x → P x ⊕ Q x) → (xs : List A) → (z : A) → z ∈ proj₁ (splitWith decPQ xs) → P z\nsplitWithProp1 decPQ [] z zIn1 = ⊥-elim zIn1\nsplitWithProp1 decPQ (x ∷ xs) z zIn with (decPQ x)\nsplitWithProp1 decPQ (x ∷ xs) .x (inj₁ refl) | (inj₁ pfP) = pfP \nsplitWithProp1 decPQ (x ∷ xs) z (inj₂ zIn) | (inj₁ _ ) = splitWithProp1 decPQ xs z zIn\nsplitWithProp1 decPQ (x ∷ xs) z zIn | (inj₂ _ ) = splitWithProp1 decPQ xs z zIn\n\nsplitWithProp2 : {A : Set} {P Q : A → Set} → (decPQ : ∀ x → P x ⊕ Q x) → (xs : List A) → (z : A) → z ∈ proj₂ (splitWith decPQ xs) → Q z\nsplitWithProp2 decPQ [] z zIn1 = ⊥-elim zIn1\nsplitWithProp2 decPQ (x ∷ xs) z zIn with (decPQ x)\nsplitWithProp2 decPQ (x ∷ xs) .x (inj₁ refl) | (inj₂ pfQ) = pfQ \nsplitWithProp2 decPQ (x ∷ xs) z (inj₂ zIn) | (inj₂ _ ) = splitWithProp2 decPQ xs z zIn\nsplitWithProp2 decPQ (x ∷ xs) z zIn | (inj₁ _ ) = splitWithProp2 decPQ xs z zIn\n\n×-join : {A B C : Set} → (pair : A × B) → (op : A → B → C) → C\n×-join (a , b) op = op a b\n\n\n\nsplitWith-cong : {A : Set} {P Q : A → Set} → (decPQ : ∀ x → P x ⊕ Q x) → (xs : List A) → (proj₁ (splitWith decPQ xs)) ++ (proj₂ (splitWith decPQ xs)) ≈ xs\nsplitWith-cong _ [] z = ⊥ □↔\nsplitWith-cong decPQ (x ∷ xs) z with (decPQ x)\nsplitWith-cong decPQ (x ∷ xs) z | (inj₁ _) = let (res1 , res2) = splitWith decPQ xs\n in (z ≡ x) ⊕ Any (z ≡_) (res1 ++ res2) ↔⟨ ⊕-cong ((z ≡ x) □↔) (splitWith-cong decPQ xs z) ⟩\n (z ≡ x) ⊕ Any (z ≡_) xs □↔ \nsplitWith-cong decPQ (x ∷ xs) z | (inj₂ _) = let (res1 , res2) = splitWith decPQ xs\n in Any (z ≡_) (res1 ++ x ∷ res2) ↔⟨ ++-comm res1 (x ∷ res2) z ⟩\n (z ≡ x) ⊕ Any (z ≡_) (res2 ++ res1) ↔⟨ ⊕-cong ((z ≡ x) □↔) (++-comm res2 res1 z) ⟩\n (z ≡ x) ⊕ Any (z ≡_) (res1 ++ res2) ↔⟨ ⊕-cong ((z ≡ x) □↔) (splitWith-cong decPQ xs z) ⟩\n (z ≡ x) ⊕ Any (z ≡_) xs □↔\n\n≤′-suc : {n m : ℕ} → n ≤′ m → suc n ≤′ suc m\n≤′-suc ≤′-refl = ≤′-refl\n≤′-suc (≤′-step pf) = ≤′-step (≤′-suc pf)\n\n\nsplitWith-length1 : {A : Set} {P Q : A → Set} → (decPQ : ∀ x → P x ⊕ Q x) → (xs : List A) → length (proj₁ (splitWith decPQ xs)) ≤′ length xs\nsplitWith-length1 _ [] = ≤′-refl\nsplitWith-length1 decPQ (x ∷ xs) with (decPQ x)\nsplitWith-length1 decPQ (x ∷ xs) | (inj₁ _) = ≤′-suc (splitWith-length1 decPQ xs)\nsplitWith-length1 decPQ (x ∷ xs) | (inj₂ _) = ≤′-step (splitWith-length1 decPQ xs)\n\n\nsplitWith-length2 : {A : Set} {P Q : A → Set} → (decPQ : ∀ x → P x ⊕ Q x) → (xs : List A) → length (proj₂ (splitWith decPQ xs)) ≤′ length xs\nsplitWith-length2 _ [] = ≤′-refl\nsplitWith-length2 decPQ (x ∷ xs) with (decPQ x)\nsplitWith-length2 decPQ (x ∷ xs) | (inj₁ _) = ≤′-step (splitWith-length2 decPQ xs)\nsplitWith-length2 decPQ (x ∷ xs) | (inj₂ _) = ≤′-suc (splitWith-length2 decPQ xs)\n\n\n\n\n\n\n\n\nqs-DecompCond : {A : Set} → Rel A L.zero → List A → (A × List A × List A) → Set\nqs-DecompCond LEQ xs (piv , ys , zs) = (piv ∷ (ys ++ zs) ≈ xs) × (∀ y → y ∈ ys → LEQ y piv) × (∀ z → z ∈ zs → LEQ piv z)\n\n\nqs-InputCond : {A : Set} → List A → Set\nqs-InputCond x = ⊤\n\nqs-OutputCond : {A : Set} → Rel A L.zero → List A → List A → Set\nqs-OutputCond LEQ xs ys = ys ≈ xs × Ordered LEQ ys\n\nqs-G-InputCond : {A : Set} → A → Set\nqs-G-InputCond x = ⊤\n\nqs-G-OutputCond : {A : Set} → A → A → Set\nqs-G-OutputCond x y = x ≡ y\n\nqs-CompCond : {A : Set} → (A × List A × List A) → List A → Set\nqs-CompCond (piv , xs , ys) zs = xs ++ piv ∷ ys ≡ zs\n\nqs-InductionLemma : {A : Set} → (LEQ : Rel A L.zero) → ∀{x₀ x₁ x₂ x₃ z₀ z₁ z₂ z₃} → qs-DecompCond LEQ x₀ (x₁ , x₂ , x₃ ) → qs-G-OutputCond x₁ z₁ →\n qs-OutputCond LEQ x₂ z₂ → qs-OutputCond LEQ x₃ z₃ → qs-CompCond (z₁ , z₂ , z₃) z₀ → qs-OutputCond LEQ x₀ z₀\nqs-InductionLemma LEQ {xs} {piv} {ys₁} {ys₂} {ws} {.piv} {zs₁} {zs₂} (piv∷ys₁++ys₂≈xs , ltPiv , gtPiv) refl (zs₁≈ys₁ , ord₁) (zs₂≈ys₂ , ord₂) refl\n = (λ x → x ∈ (zs₁ ++ piv ∷ zs₂) ↔⟨ ++-comm zs₁ (piv ∷ zs₂) x ⟩\n (x ∈ ((piv ∷ zs₂) ++ zs₁)) ↔⟨ Any-++ (λ z → x ≡ z) (piv ∷ zs₂) zs₁ ⟩\n ((x ≡ piv) ⊕ x ∈ zs₂) ⊕ x ∈ zs₁ ↔⟨ ↔sym ⊕-assoc ⟩\n (x ≡ piv) ⊕ (x ∈ zs₂ ⊕ x ∈ zs₁) ↔⟨ ⊕-cong ((x ≡ piv) □↔) (⊕-cong (zs₂≈ys₂ x) (zs₁≈ys₁ x)) ⟩\n (x ≡ piv) ⊕ (x ∈ ys₂ ⊕ x ∈ ys₁) ↔⟨ ⊕-cong ((x ≡ piv) □↔) ⊕-comm ⟩\n (x ≡ piv) ⊕ (x ∈ ys₁ ⊕ x ∈ ys₂) ↔⟨ ⊕-cong ((x ≡ piv) □↔) (↔sym (Any-++ (λ z → x ≡ z) ys₁ ys₂)) ⟩\n x ∈ (piv ∷ (ys₁ ++ ys₂)) ↔⟨ piv∷ys₁++ys₂≈xs x ⟩\n x ∈ xs □↔) ,\n ++-Order-cong (λ x x∈zs₁ → ltPiv x (_↔_.to (zs₁≈ys₁ x) x∈zs₁)) ord₁\n (cons-Order-cong (λ x x∈zs₂ → gtPiv x (_↔_.to (zs₂≈ys₂ x) x∈zs₂)) ord₂)\n\n\n\nqs-Decomp : {A : Set} → {LEQ : Rel A L.zero} → Total LEQ → (xs : List A) → ⊤ → ¬ ListPrimitive xs → Σ (A × List A × List A)\n λ y → qs-G-InputCond (proj₁ y) × (qs-InputCond (proj₁ (proj₂ y))) × (qs-InputCond (proj₂ (proj₂ y))) ×\n ((proj₁ (proj₂ y)) _) combinator\n-- as well as a type annotation (_∶_) combinator.\n\nopen import Function.Reasoning\n\n------------------------------------------------------------------------\n-- A simple example\n\nmodule _ {A B C : Set} {A→B : A → B} {B→C : B → C} where\n\n-- Using the combinators we can, starting from a value, chain various\n-- functions whilst tracking the types of the intermediate results.\n\n A→C : A → C\n A→C a =\n a ∶ A\n |> A→B ∶ B\n |> B→C ∶ C\n\n------------------------------------------------------------------------\n-- A more concrete example\n\nopen import Data.Nat\nopen import Data.List.Base\nopen import Data.Char.Base\nopen import Data.String using (String; toList; fromList; _==_)\nopen import Function\nopen import Data.Bool hiding (_≤?_)\nopen import Data.Product as P using (_×_; <_,_>; uncurry; proj₁)\nopen import Agda.Builtin.Equality\n\n-- This can give us for instance this decomposition of a function\n-- collecting all of the substrings of the input which happen to be\n-- palindromes:\n\nsubpalindromes : String → List String\nsubpalindromes str = let Chars = List Char in\n str ∶ String\n -- first generate the substrings\n |> toList ∶ Chars\n |> inits ∶ List Chars\n |> concatMap tails ∶ List Chars\n -- then only keeps the ones which are not singletons\n |> filter (λ cs → 2 ≤? length cs) ∶ List Chars\n -- only keep the ones that are palindromes\n |> map < fromList , fromList ∘ reverse > ∶ List (String × String)\n |> boolFilter (uncurry _==_) ∶ List (String × String)\n |> map proj₁ ∶ List String\n\n-- Test cases\n\n_ : subpalindromes \"doctoresreverse\" ≡ \"eve\" ∷ \"rever\" ∷ \"srevers\" ∷ \"esreverse\" ∷ []\n_ = refl\n\n_ : subpalindromes \"elle-meme\" ≡ \"ll\" ∷ \"elle\" ∷ \"mem\" ∷ \"eme\" ∷ []\n_ = refl\n", "meta": {"hexsha": "15472fa6299397741d635d94de14df9eacc45a12", "size": 2376, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/README/Function/Reasoning.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/README/Function/Reasoning.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/README/Function/Reasoning.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 34.4347826087, "max_line_length": 85, "alphanum_fraction": 0.5538720539, "num_tokens": 594, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8198933315126792, "lm_q2_score": 0.7634837581726991, "lm_q1q2_score": 0.625975242044035}} {"text": "{-# OPTIONS --allow-unsolved-metas #-}\n\nopen import CS410-Prelude\n\n\n------------------------------------------------------------------------------\n-- Vectors\n------------------------------------------------------------------------------\n\ndata Vec (X : Set) : Nat -> Set where\n [] : Vec X zero\n _,-_ : {n : Nat} -> X -> Vec X n -> Vec X (suc n)\n\ninfixr 4 _,-_\n\n\n------------------------------------------------------------------------------\n-- Heads and Tails\n------------------------------------------------------------------------------\n\nvHead : {X : Set}{n : Nat} -> Vec X (suc n) -> X\nvHead (x ,- xs) = x\n\nvTail : {X : Set}{n : Nat} -> Vec X (suc n) -> Vec X n\nvTail (x ,- xs) = xs\n\nvHeadTailFact : {X : Set}{n : Nat}(xs : Vec X (suc n)) -> (vHead xs ,- vTail xs) == xs\nvHeadTailFact (x ,- xs) = refl (x ,- xs)\n\n\n------------------------------------------------------------------------------\n-- Concatenation and its Inverse\n------------------------------------------------------------------------------\n\n_+V_ : {X : Set}{m n : Nat} -> Vec X m -> Vec X n -> Vec X (m +N n)\n[] +V ys = ys\n(x ,- xs) +V ys = x ,- xs +V ys\n\ninfixr 4 _+V_\n\nvChop : {X : Set}(m : Nat){n : Nat} -> Vec X (m +N n) -> Vec X m * Vec X n\nvChop zero xs = [] , xs\nvChop (suc m) (x ,- xs) with vChop m xs\nvChop (suc m) (x ,- xs) | xf , xb = (x ,- xf) , xb\n\nvChopAppendFact : {X : Set}{m n : Nat}(xs : Vec X m)(ys : Vec X n) -> vChop m (xs +V ys) == (xs , ys)\nvChopAppendFact [] ys = refl ([] , ys)\nvChopAppendFact (x ,- xs) ys rewrite vChopAppendFact xs ys = refl ((x ,- xs) , ys)\n\n\n------------------------------------------------------------------------------\n-- Map, take I\n------------------------------------------------------------------------------\n\n-- Implement the higher-order function that takes an operation on\n-- elements and does it to each element of a vector. Use recursion\n-- on the vector.\n-- Note that the type tells you the size remains the same.\n\n-- Show that if the elementwise function \"does nothing\", neither does\n-- its vMap. \"map of identity is identity\"\n\n-- Show that two vMaps in a row can be collapsed to just one, or\n-- \"composition of maps is map of compositions\"\n\nvMap : {X Y : Set} -> (X -> Y) -> {n : Nat} -> Vec X n -> Vec Y n\nvMap f [] = []\nvMap f (x ,- xs) = f x ,- vMap f xs\n\nvMapIdFact : {X : Set}{f : X -> X}(feq : (x : X) -> f x == x) ->\n {n : Nat}(xs : Vec X n) ->\n vMap f xs == xs\nvMapIdFact feq [] = refl []\nvMapIdFact feq (x ,- xs) rewrite vMapIdFact feq xs | feq x\n = refl (x ,- xs)\n\nvMapCpFact : {X Y Z : Set}{f : Y -> Z}{g : X -> Y}{h : X -> Z}(heq : (x : X) -> f (g x) == h x) ->\n {n : Nat}(xs : Vec X n) ->\n vMap f (vMap g xs) == vMap h xs\nvMapCpFact heq [] = refl []\nvMapCpFact {f = f}{g = g}{h = h} heq (x ,- xs) rewrite vMapCpFact {f = f}{g = g}{h = h} heq xs | heq x\n = refl (h x ,- vMap h xs)\n\n\n------------------------------------------------------------------------------\n-- vMap and +V\n------------------------------------------------------------------------------\n\n-- Show that if you've got two vectors of Xs and a function from X to Y,\n-- and you want to concatenate and map, it doesn't matter which you do\n-- first.\n\nvMap+VFact : {X Y : Set}(f : X -> Y) ->\n {m n : Nat}(xs : Vec X m)(xs' : Vec X n) ->\n vMap f (xs +V xs') == (vMap f xs +V vMap f xs')\nvMap+VFact f [] xs' = refl (vMap f xs')\nvMap+VFact f (x ,- xs) xs' rewrite vMap+VFact f xs xs' = refl (f x ,- vMap f xs +V vMap f xs')\n\n\n------------------------------------------------------------------------------\n-- Applicative Structure (giving mapping and zipping cheaply)\n------------------------------------------------------------------------------\n\n-- HINT: you will need to override the default invisibility of n to do this.\nvPure : {X : Set} -> X -> {n : Nat} -> Vec X n\nvPure x {zero} = []\nvPure x {suc n} = x ,- vPure x\n\n_$V_ : {X Y : Set}{n : Nat} -> Vec (X -> Y) n -> Vec X n -> Vec Y n\n[] $V [] = []\nf ,- fs $V x ,- xs = f x ,- (fs $V xs)\n\ninfixl 3 _$V_\n\n-- Pattern matching and recursion are forbidden for the next two tasks.\n\n-- implement vMap again, but as a one-liner\nvec : {X Y : Set} -> (X -> Y) -> {n : Nat} -> Vec X n -> Vec Y n\nvec f xs = vPure f $V xs\n\n-- implement the operation which pairs up corresponding elements\nvZip : {X Y : Set}{n : Nat} -> Vec X n -> Vec Y n -> Vec (X * Y) n\nvZip xs ys = vPure _,_ $V xs $V ys\n\n\n------------------------------------------------------------------------------\n-- Applicative Laws\n------------------------------------------------------------------------------\n\n-- According to \"Applicative programming with effects\" by\n-- Conor McBride and Ross Paterson\n-- some laws should hold for applicative functors.\n-- Check that this is the case.\n\nvIdentity : {X : Set}{f : X -> X}(feq : (x : X) -> f x == x) ->\n {n : Nat}(xs : Vec X n) -> (vPure f $V xs) == xs\nvIdentity feq [] = refl []\nvIdentity feq (x ,- xs) rewrite vIdentity feq xs | feq x = refl (x ,- xs)\n\nvHomomorphism : {X Y : Set}(f : X -> Y)(x : X) -> {n : Nat} ->\n (vPure f $V vPure x) == vPure (f x) {n}\nvHomomorphism f x {zero} = refl []\nvHomomorphism f x {suc n} rewrite vHomomorphism f x {n} = refl (f x ,- vPure (f x))\n\nvInterchange : {X Y : Set}{n : Nat}(fs : Vec (X -> Y) n)(x : X) ->\n (fs $V vPure x) == (vPure (_$ x) $V fs)\nvInterchange [] x = refl []\nvInterchange (f ,- fs) x rewrite vInterchange fs x = refl (f x ,- (vPure (\\ f → f x) $V fs))\n\nvComposition : {X Y Z : Set}{n : Nat}(fs : Vec (Y -> Z) n)(gs : Vec (X -> Y) n)(xs : Vec X n) ->\n (vPure _<<_ $V fs $V gs $V xs) == (fs $V (gs $V xs))\nvComposition [] [] [] = refl []\nvComposition (f ,- fs) (g ,- gs) (x ,- xs) rewrite vComposition fs gs xs = refl (f (g x) ,- (fs $V (gs $V xs)))\n\n\n------------------------------------------------------------------------------\n-- Order-Preserving Embeddings (also known in the business as \"thinnings\")\n------------------------------------------------------------------------------\n\n-- What have these to do with Pascal's Triangle?\n\ndata _<=_ : Nat -> Nat -> Set where\n oz : zero <= zero\n os : {n m : Nat} -> n <= m -> suc n <= suc m\n o' : {n m : Nat} -> n <= m -> n <= suc m\n\n-- Find all the values in each of the following <= types.\n-- This is a good opportunity to learn to use C-c C-a with the -l option\n-- (a.k.a. \"google the type\" without \"I feel lucky\")\n-- The -s n option also helps.\n\nall0<=4 : Vec (0 <= 4) 1\nall0<=4 = o' (o' (o' (o' oz))) ,- []\n\nall1<=4 : Vec (1 <= 4) 4\nall1<=4 = o' (o' (o' (os oz))) ,-\n o' (o' (os (o' oz))) ,-\n o' (os (o' (o' oz))) ,-\n os (o' (o' (o' oz))) ,-\n []\n\nall2<=4 : Vec (2 <= 4) 6\nall2<=4 = os (os (o' (o' oz))) ,-\n os (o' (os (o' oz))) ,-\n os (o' (o' (os oz))) ,-\n o' (os (os (o' oz))) ,-\n o' (os (o' (os oz))) ,-\n o' (o' (os (os oz))) ,-\n []\n\nall3<=4 : Vec (3 <= 4) 4\nall3<=4 = os (os (os (o' oz))) ,-\n os (os (o' (os oz))) ,-\n os (o' (os (os oz))) ,-\n o' (os (os (os oz))) ,-\n []\n\nall4<=4 : Vec (4 <= 4) 1\nall4<=4 = os (os (os (os oz))) ,- []\n\n-- Prove the following. A massive case analysis \"rant\" is fine.\n\nno5<=4 : 5 <= 4 -> Zero\nno5<=4 (os (os (os (os ()))))\nno5<=4 (os (os (os (o' ()))))\nno5<=4 (os (os (o' (os ()))))\nno5<=4 (os (os (o' (o' ()))))\nno5<=4 (os (o' (os (os ()))))\nno5<=4 (os (o' (os (o' ()))))\nno5<=4 (os (o' (o' (os ()))))\nno5<=4 (os (o' (o' (o' ()))))\nno5<=4 (o' (os (os (os ()))))\nno5<=4 (o' (os (os (o' ()))))\nno5<=4 (o' (os (o' (os ()))))\nno5<=4 (o' (os (o' (o' ()))))\nno5<=4 (o' (o' (os (os ()))))\nno5<=4 (o' (o' (os (o' ()))))\nno5<=4 (o' (o' (o' (os ()))))\nno5<=4 (o' (o' (o' (o' ()))))\n\n\n------------------------------------------------------------------------------\n-- Order-Preserving Embeddings Select From Vectors\n------------------------------------------------------------------------------\n\n-- Use n <= m to encode the choice of n elements from an m-Vector.\n-- The os constructor tells you to take the next element of the vector;\n-- the o' constructor tells you to omit the next element of the vector.\n\n_ n <= m -> Vec X m -> Vec X n\noz Y)\n {n m : Nat}(th : n <= m)(xs : Vec X m) ->\n vMap f (th n <= n\noi {zero} = oz\noi {suc n} = os oi\n\noe : {n : Nat} -> 0 <= n\noe {zero} = oz\noe {suc n} = o' oe\n\n-- Show that all empty thinnings are equal to yours.\n\noeUnique : {n : Nat}(th : 0 <= n) -> th == oe\noeUnique oz = refl oz\noeUnique (o' i) with oeUnique i\noeUnique (o' .oe) | refl .oe = refl (o' oe)\n\n\n-- Show that there are no thinnings of form big <= small (TRICKY)\n-- Then show that all the identity thinnings are equal to yours.\n-- Note that you can try the second even if you haven't finished the first.\n-- HINT: you WILL need to expose the invisible numbers.\n-- HINT: check CS410-Prelude for a reminder of >=\n\noTooBig : {n m : Nat} -> n >= m -> suc n <= m -> Zero\noTooBig {_} {zero} n>=m ()\noTooBig {zero} {suc m} n>=m (th) = n>=m\noTooBig {suc n} {suc m} n>=m (os th) with oTooBig {n} {m} n>=m th\noTooBig {suc n} {suc m} n>=m (os th) | ()\noTooBig {suc n} {suc m} n>=m (o' th) with oTooBig {suc n} {m} (trans->= (suc n) n m (suc->= n) n>=m) th\noTooBig {suc n} {suc m} n>=m (o' th) | ()\n\noiUnique : {n : Nat}(th : n <= n) -> th == oi\noiUnique oz = refl oz\noiUnique (os th) with oiUnique th\noiUnique (os .oi) | refl .oi = refl (os oi)\noiUnique {n}(o' th) with oTooBig (refl->= n) th\noiUnique {.(suc _)} (o' th) | ()\n\n\n-- Show that the identity thinning selects the whole vector\n\nid- (oi >_ : {p n m : Nat} -> p <= n -> n <= m -> p <= m\noz o>> th' = th'\nos th o>> os th' with th o>> th'\nos th o>> os th' | p = os p\nos th o>> o' th' with (os th) o>> th'\nos th o>> o' th' | p = o' p\no' th o>> os th' with th o>> th'\no' th o>> os th' | p = o' p\no' th o>> o' th' with (o' th) o>> th'\no' th o>> o' th' | p = o' p\n\ncp-\n {X : Set}(xs : Vec X m) ->\n ((th o>> th') > : {n m : Nat}(th : n <= m) -> (oi o>> th) == th\nidThen-o>> oz = refl oz\nidThen-o>> (os th) rewrite idThen-o>> th = refl (os th)\nidThen-o>> {zero}(o' th) rewrite idThen-o>> th = refl (o' th)\nidThen-o>> {suc n}(o' th) rewrite idThen-o>> th = refl (o' th)\n\nidAfter-o>> : {n m : Nat}(th : n <= m) -> (th o>> oi) == th\nidAfter-o>> oz = refl oz\nidAfter-o>> (os th) rewrite idAfter-o>> th = refl (os th)\nidAfter-o>> (o' th) rewrite idAfter-o>> th = refl (o' th)\n\nassoc-o>> : {q p n m : Nat}(th0 : q <= p)(th1 : p <= n)(th2 : n <= m) ->\n ((th0 o>> th1) o>> th2) == (th0 o>> (th1 o>> th2))\nassoc-o>> oz th1 th2 = refl (th1 o>> th2)\nassoc-o>> (os th0) (os th1) (os th2) rewrite assoc-o>> th0 th1 th2 = refl (os (th0 o>> (th1 o>> th2)))\nassoc-o>> (os th0) (os th1) (o' th2) rewrite assoc-o>> (os th0) (os th1) th2 = refl (o' (os th0 o>> (os th1 o>> th2)))\nassoc-o>> (os th0) (o' th1) (os th2) rewrite assoc-o>> (os th0) th1 th2 = refl (o' (os th0 o>> (th1 o>> th2)))\nassoc-o>> (os th0) (o' th1) (o' th2) rewrite assoc-o>> (os th0) (o' th1) th2 = refl (o' (os th0 o>> (o' th1 o>> th2)))\nassoc-o>> (o' th0) (os th1) (os th2) rewrite assoc-o>> th0 th1 th2 = refl (o' (th0 o>> (th1 o>> th2)))\nassoc-o>> (o' th0) (os th1) (o' th2) rewrite assoc-o>> (o' th0) (os th1) th2 = refl (o' (o' th0 o>> (os th1 o>> th2)))\nassoc-o>> (o' th0) (o' th1) (os th2) rewrite assoc-o>> (o' th0) th1 th2 = refl (o' (o' th0 o>> (th1 o>> th2)))\nassoc-o>> (o' th0) (o' th1) (o' th2) rewrite assoc-o>> (o' th0) (o' th1) th2 = refl (o' (o' th0 o>> (o' th1 o>> th2)))\n\n\n------------------------------------------------------------------------------\n-- Vectors as Arrays\n------------------------------------------------------------------------------\n\n-- We can use 1 <= n as the type of bounded indices into a vector and do\n-- a kind of \"array projection\". First we select a 1-element vector from\n-- the n-element vector, then we take its head to get the element out.\n\nvProject : {n : Nat}{X : Set} -> Vec X n -> 1 <= n -> X\nvProject xs i = vHead (i (1 <= n -> X) -> Vec X n\nvTabulate {zero} f = []\nvTabulate {suc n} f with f (os oe) | vTabulate (f << o')\nvTabulate {suc n} f | x | xs = x ,- xs\n\n-- This should be easy if vTabulate is correct.\nvTabulateProjections : {n : Nat}{X : Set}(xs : Vec X n) -> vTabulate (vProject xs) == xs\nvTabulateProjections [] = refl []\nvTabulateProjections (x ,- xs) rewrite vTabulateProjections xs = refl (x ,- xs)\n\n-- HINT: oeUnique\nvProjectFromTable : {n : Nat}{X : Set}(f : 1 <= n -> X)(i : 1 <= n) -> vProject (vTabulate f) i == f i\nvProjectFromTable f (os i) rewrite oeUnique i = refl (f (os oe))\nvProjectFromTable f (o' i) rewrite vProjectFromTable (f << o') i = refl (f (o' i))\n", "meta": {"hexsha": "55d393c921a749ec29b9ad9a3687815912406008", "size": 15159, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Ex1.agda", "max_stars_repo_name": "m-schmidt/CS410-17-Exercises", "max_stars_repo_head_hexsha": "5db8e95bbcbe8dc0eec810f3e73130ecd78d207c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Ex1.agda", "max_issues_repo_name": "m-schmidt/CS410-17-Exercises", "max_issues_repo_head_hexsha": "5db8e95bbcbe8dc0eec810f3e73130ecd78d207c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Ex1.agda", "max_forks_repo_name": "m-schmidt/CS410-17-Exercises", "max_forks_repo_head_hexsha": "5db8e95bbcbe8dc0eec810f3e73130ecd78d207c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.0695876289, "max_line_length": 118, "alphanum_fraction": 0.4577478726, "num_tokens": 5003, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833841649233, "lm_q2_score": 0.8080672158638528, "lm_q1q2_score": 0.6259154386965508}} {"text": "module plfa-exercises.Practice5 where\n\nopen import Data.Nat using (ℕ; zero; suc)\nopen import Data.String using (String; _≟_)\nopen import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; cong)\nopen import Relation.Nullary using (Dec; yes; no; ¬_)\nopen import plfa.part1.Isomorphism using (_≲_)\n\nId : Set\nId = String\n\ninfix 5 ƛ_⇒_ μ_⇒_\ninfixl 7 _·_\ninfix 8 `suc_\ninfix 9 `_\n\ndata Term : Set where\n `_ : Id → Term\n ƛ_⇒_ : Id → Term → Term\n _·_ : Term → Term → Term\n `zero : Term\n `suc_ : Term → Term\n case_[zero⇒_|suc_⇒_] : Term → Term → Id → Term → Term\n μ_⇒_ : Id → Term → Term\n\n--ƛ \"x\" ⇒ `suc `zero\n\none = `suc `zero\ntwo = `suc one\n\nplus : Term\nplus = μ \"+\" ⇒ ƛ \"m\" ⇒ ƛ \"n\" ⇒\n case ` \"m\"\n [zero⇒ ` \"n\"\n |suc \"m\" ⇒ `suc (` \"+\" · ` \"m\" · ` \"n\") ]\n\n--plus · two · two\n\ntwoᶜ : Term\ntwoᶜ = ƛ \"s\" ⇒ ƛ \"z\" ⇒ ` \"s\" · (` \"s\" · ` \"z\")\n\nplusᶜ : Term\nplusᶜ = ƛ \"m\" ⇒ ƛ \"n\" ⇒ ƛ \"s\" ⇒ ƛ \"z\" ⇒\n ` \"m\" · ` \"s\" · (` \"n\" · ` \"s\" · ` \"z\")\n\nsucᶜ : Term\nsucᶜ = ƛ \"n\" ⇒ `suc (` \"n\")\n\n----- Little detour into the same definitions but working in Agda\n--plus c one two\n--(λ m n s z → m s (n s z)) (λ s z → s z) (λ s z → s (s z)) suc zero\n\nNat : Set₁\nNat = ∀ {A : Set} → (A → A) → A → A\n\n--my_two : ∀ {A : Set} → (A → A) → A → A\nmy_two : Nat\nmy_two = (λ s z → s (s z))\n\n--my_four : ∀ {A : Set} → (A → A) → A → A\nmy_four : Nat\nmy_four = (λ s z → s (s (s (s z))))\n\n--(λ m n s z → m s (n s z)) my_two my_four\n--my_add : ∀ {A : Set} → ((A → A) → A → A) → ((A → A) → A → A) → (A → A) → A → A\nmy_add : Nat → Nat → Nat\nmy_add = (λ m n s z → m s (n s z))\n--my_add = (λ m n s → (m s) ∘ (n s))\n\n-- my_add my_two my_four ≡ λ s z → s (s (s (s (s (s z)))))\n\nsix : ℕ\nsix = my_add my_two my_four suc zero\n--six = 6\n\n--my_mul : ∀ {A : Set} → ((A → A) → A → A) → ((A → A) → A → A) → (A → A) → A → A\nmy_mul : Nat → Nat → Nat\nmy_mul = (λ m n s z → m (n s) z)\n--my_mul = (λ m n s → m (n s))\n\n--my_mul my_two my_four ≡ λ s z → s (s (s (s (s (s (s (s z)))))))\neight_true : my_mul my_two my_four suc zero ≡ 8\neight_true = refl\n----- End of detour\n\n-- Exercises\nmult : Term\nmult = μ \"*\" ⇒ ƛ \"m\" ⇒ ƛ \"n\" ⇒\n case ` \"m\"\n [zero⇒ `zero\n |suc \"m\" ⇒ plus · (` \"*\" · ` \"m\" · ` \"n\") · ` \"n\" ]\n\nmultᶜ : Term\nmultᶜ = ƛ \"m\" ⇒ ƛ \"n\" ⇒ ƛ \"s\" ⇒ ƛ \"z\" ⇒\n ` \"m\" · (` \"n\" · ` \"s\") · ` \"z\"\n--- End Exercises\n\ndata Value : Term → Set where\n V-ƛ : ∀ {x N} → Value (ƛ x ⇒ N)\n V-zero : Value `zero\n V-suc : ∀ {V} → Value V → Value (`suc V)\n\n\n-- Notice that this only works if we are working with _closed_ terms.\n-- Open terms require more care\n\ninfix 9 _[_:=_]\n\n-- Wrote them partly by myself\n_[_:=_] : Term → Id → Term → Term\n(` x) [ x' := V ] with x ≟ x'\n... | yes _ = V\n... | no _ = ` x\n(ƛ x ⇒ M) [ x' := V ] with x ≟ x'\n... | yes _ = ƛ x ⇒ M\n... | no _ = ƛ x ⇒ (M [ x' := V ])\n(M · N) [ x := V ] = (M [ x := V ]) · (N [ x := V ])\n`zero [ _ := _ ] = `zero\n(`suc M) [ x := V ] = `suc (M [ x := V ])\n(case n [zero⇒ M |suc n' ⇒ N ]) [ x := V ] with x ≟ n'\n... | yes _ = case (n [ x := V ]) [zero⇒ (M [ x := V ]) |suc n' ⇒ N ]\n... | no _ = case (n [ x := V ]) [zero⇒ (M [ x := V ]) |suc n' ⇒ (N [ x := V ]) ]\n(μ f ⇒ M) [ x := V ] with f ≟ x\n... | yes _ = μ f ⇒ M\n... | no _ = μ f ⇒ (M [ x := V ])\n\n-- (ƛ \"y\" ⇒ ` \"x\" · (ƛ \"x\" ⇒ ` \"x\")) [ \"x\" := `zero ]\n\n\ninfix 4 _—→_\n\ndata _—→_ : Term → Term → Set where\n\n ξ-·₁ : ∀ {L L′ M}\n → L —→ L′\n -----------------\n → L · M —→ L′ · M\n\n ξ-·₂ : ∀ {V M M′}\n → Value V\n → M —→ M′\n -----------------\n → V · M —→ V · M′\n\n β-ƛ : ∀ {x N V}\n → Value V\n ------------------------------\n → (ƛ x ⇒ N) · V —→ N [ x := V ]\n\n ξ-suc : ∀ {M M′}\n → M —→ M′\n ------------------\n → `suc M —→ `suc M′\n\n ξ-case : ∀ {x L L′ M N}\n → L —→ L′\n -----------------------------------------------------------------\n → case L [zero⇒ M |suc x ⇒ N ] —→ case L′ [zero⇒ M |suc x ⇒ N ]\n\n β-zero : ∀ {x M N}\n ----------------------------------------\n → case `zero [zero⇒ M |suc x ⇒ N ] —→ M\n\n β-suc : ∀ {x V M N}\n → Value V\n ---------------------------------------------------\n → case `suc V [zero⇒ M |suc x ⇒ N ] —→ N [ x := V ]\n\n β-μ : ∀ {x M}\n ------------------------------\n → μ x ⇒ M —→ M [ x := μ x ⇒ M ]\n\n\n_ : (ƛ \"x\" ⇒ `suc (`suc (` \"x\"))) · (`suc `zero) —→ `suc (`suc (`suc `zero))\n_ = β-ƛ (V-suc V-zero)\n\n_ : (ƛ \"x\" ⇒ ` \"x\") · (ƛ \"x\" ⇒ ` \"x\") —→ (ƛ \"x\" ⇒ ` \"x\")\n_ = β-ƛ V-ƛ\n\n_ : (ƛ \"x\" ⇒ ` \"x\") · (ƛ \"x\" ⇒ ` \"x\") · (ƛ \"x\" ⇒ ` \"x\") —→ (ƛ \"x\" ⇒ ` \"x\") · (ƛ \"x\" ⇒ ` \"x\")\n_ = ξ-·₁ (β-ƛ V-ƛ)\n\n_ : twoᶜ · sucᶜ · `zero —→ (ƛ \"z\" ⇒ sucᶜ · (sucᶜ · ` \"z\")) · `zero\n_ = ξ-·₁ (β-ƛ V-ƛ)\n\n--- Detour\nt : ∀ {A B : Set} → A → B → A\nt = λ x y → x -- true\nf : ∀ {A B : Set} → A → B → B\nf = λ x y → y -- false\n--is0 : ∀ {A : Set} → ((A → A → A → A) → (A → A → A) → A → A → A) → A → A → A\n--is0 {A} = λ n → n (λ x → f {A}) (t {A})\n--is0 : ∀ {A B : Set} → ((A → A → A → A) → (A → A → A) → A → A → A) → (A → A) → A → A\n--is0 {A} {B} = λ n → n (λ x → f {A} {B}) (t {A} {B})\n\n-- is0 {ℕ} (λ s z → z) -- returns true\n-- is0 (λ s z → s z) -- returns false\n--- End detour\n\ninfix 2 _—↠_\ninfix 1 begin_\ninfixr 2 _—→⟨_⟩_ _—→⟨⟩_\ninfix 3 _∎\n\ndata _—↠_ : Term → Term → Set where\n _∎ : ∀ M\n ---------\n → M —↠ M\n\n _—→⟨_⟩_ : ∀ L {M N}\n → L —→ M\n → M —↠ N\n ---------\n → L —↠ N\n\nbegin_ : ∀ {M N}\n → M —↠ N\n ------\n → M —↠ N\nbegin M—↠N = M—↠N\n\n_—→⟨⟩_ : ∀ L {N}\n → L —↠ N\n ---------\n → L —↠ N\n_—→⟨⟩_ l l—↠n = l—↠n\n\ntrans : ∀ {L M N}\n → L —↠ M\n → M —↠ N\n → L —↠ N\ntrans (m ∎) m—↠n = m—↠n\ntrans (l —→⟨ l—→o ⟩ o—↠m) m—↠n = l —→⟨ l—→o ⟩ (trans o—↠m m—↠n)\n\n_ : (ƛ \"x\" ⇒ ` \"x\") · (ƛ \"x\" ⇒ ` \"x\") · (ƛ \"x\" ⇒ ` \"x\") · (ƛ \"x\" ⇒ ` \"x\") —↠ (ƛ \"x\" ⇒ ` \"x\")\n_ =\n begin\n (ƛ \"x\" ⇒ ` \"x\") · (ƛ \"x\" ⇒ ` \"x\") · (ƛ \"x\" ⇒ ` \"x\") · (ƛ \"x\" ⇒ ` \"x\") —→⟨ ξ-·₁ (ξ-·₁ (β-ƛ V-ƛ)) ⟩\n (ƛ \"x\" ⇒ ` \"x\") · (ƛ \"x\" ⇒ ` \"x\") · (ƛ \"x\" ⇒ ` \"x\") —→⟨ ξ-·₁ (β-ƛ V-ƛ) ⟩\n (ƛ \"x\" ⇒ ` \"x\") · (ƛ \"x\" ⇒ ` \"x\") —→⟨ β-ƛ V-ƛ ⟩\n ƛ \"x\" ⇒ ` \"x\"\n ∎\n\n\ndata _—↠′_ : Term → Term → Set where\n\n step′ : ∀ {M N}\n → M —→ N\n -------\n → M —↠′ N\n\n refl′ : ∀ {M}\n -------\n → M —↠′ M\n\n trans′ : ∀ {L M N}\n → L —↠′ M\n → M —↠′ N\n -------\n → L —↠′ N\n\n↠≲—↠′ : ∀ t t' → (t —↠ t') ≲ (t —↠′ t')\n↠≲—↠′ t t' = record {\n to = to\n ; from = from\n ; from∘to = from∘to\n }\n where\n to : ∀ {t t'} → t —↠ t' → t —↠′ t'\n to (m ∎) = refl′ {m}\n to (l —→⟨ l—→m ⟩ m—↠n) = trans′ {l} (step′ l—→m) (to m—↠n)\n \n from : ∀ {t t'} → t —↠′ t' → t —↠ t'\n from (step′ {m} {n} m—→n) = m —→⟨ m—→n ⟩ n ∎\n from (refl′ {m}) = m ∎\n from (trans′ {l} {m} {n} l—↠′m m—↠′n) =\n trans (from l—↠′m) (from m—↠′n)\n \n from∘to : ∀ {l n} (x : l —↠ n) → from (to x) ≡ x\n from∘to (n ∎) = refl\n from∘to (l —→⟨ l—→m ⟩ m—↠n) = cong (l —→⟨ l—→m ⟩_) (from∘to m—↠n)\n \n --to∘from : ∀ {l n} (x : l —↠′ n) → to (from x) ≡ x\n --to∘from (step′ {m} {n} m—→n) = ?\n ---- here lies the problem:\n ---- to (from (step′ m—→n)) ≡ step′ m—→n\n ---- is converted into:\n ---- trans′ (step′ m—→n) refl′ ≡ step′ m—→n\n ---- which cannot be true :/, both are constructors, both\n ---- create the same type. Lesson, always make sure your data\n ---- definitions make unique elements\n --to∘from = ?\n\n_ : twoᶜ · sucᶜ · `zero —↠ `suc `suc `zero\n_ = begin\n twoᶜ · sucᶜ · `zero —→⟨⟩ -- def\n (ƛ \"s\" ⇒ ƛ \"z\" ⇒ ` \"s\" · (` \"s\" · ` \"z\")) · sucᶜ · `zero —→⟨ ξ-·₁ (β-ƛ V-ƛ) ⟩\n (ƛ \"z\" ⇒ sucᶜ · (sucᶜ · ` \"z\")) · `zero —→⟨ β-ƛ V-zero ⟩\n sucᶜ · (sucᶜ · `zero) —→⟨⟩\n (ƛ \"n\" ⇒ `suc (` \"n\")) · ((ƛ \"n\" ⇒ `suc (` \"n\")) · `zero) —→⟨ ξ-·₂ V-ƛ (β-ƛ V-zero) ⟩\n (ƛ \"n\" ⇒ `suc (` \"n\")) · `suc `zero —→⟨ β-ƛ (V-suc V-zero) ⟩\n `suc `suc `zero ∎\n\noneᶜ : Term\noneᶜ = ƛ \"s\" ⇒ ƛ \"z\" ⇒ ` \"s\" · ` \"z\"\n\n_ : plusᶜ · oneᶜ · oneᶜ · sucᶜ · `zero —↠ `suc `suc `zero\n_ = begin\n plusᶜ · oneᶜ · oneᶜ · sucᶜ · `zero —→⟨⟩\n plusᶜ · oneᶜ · oneᶜ · sucᶜ · `zero —→⟨⟩\n (ƛ \"m\" ⇒ ƛ \"n\" ⇒ ƛ \"s\" ⇒ ƛ \"z\" ⇒\n ` \"m\" · ` \"s\" · (` \"n\" · ` \"s\" · ` \"z\")) · oneᶜ · oneᶜ · sucᶜ · `zero —→⟨ ξ-·₁ (ξ-·₁ (ξ-·₁ (β-ƛ V-ƛ))) ⟩\n (ƛ \"n\" ⇒ ƛ \"s\" ⇒ ƛ \"z\" ⇒\n oneᶜ · ` \"s\" · (` \"n\" · ` \"s\" · ` \"z\")) · oneᶜ · sucᶜ · `zero —→⟨ ξ-·₁ (ξ-·₁ (β-ƛ V-ƛ)) ⟩\n (ƛ \"s\" ⇒ ƛ \"z\" ⇒ oneᶜ · ` \"s\" · (oneᶜ · ` \"s\" · ` \"z\")) · sucᶜ · `zero —→⟨ ξ-·₁ (β-ƛ V-ƛ) ⟩\n (ƛ \"z\" ⇒ oneᶜ · sucᶜ · (oneᶜ · sucᶜ · ` \"z\")) · `zero —→⟨ β-ƛ V-zero ⟩\n oneᶜ · sucᶜ · (oneᶜ · sucᶜ · `zero) —→⟨⟩\n (ƛ \"s\" ⇒ ƛ \"z\" ⇒ ` \"s\" · ` \"z\") · sucᶜ · (oneᶜ · sucᶜ · `zero) —→⟨ ξ-·₁ (β-ƛ V-ƛ) ⟩\n (ƛ \"z\" ⇒ sucᶜ · ` \"z\") · (oneᶜ · sucᶜ · `zero) —→⟨ ξ-·₂ V-ƛ (ξ-·₁ (β-ƛ V-ƛ)) ⟩\n (ƛ \"z\" ⇒ sucᶜ · ` \"z\") · ((ƛ \"z\" ⇒ sucᶜ · ` \"z\") · `zero) —→⟨ ξ-·₂ V-ƛ (β-ƛ V-zero) ⟩\n (ƛ \"z\" ⇒ sucᶜ · ` \"z\") · (sucᶜ · `zero) —→⟨ ξ-·₂ V-ƛ (β-ƛ V-zero) ⟩\n (ƛ \"z\" ⇒ sucᶜ · ` \"z\") · (`suc `zero) —→⟨ β-ƛ (V-suc V-zero) ⟩\n sucᶜ · (`suc `zero) —→⟨ β-ƛ (V-suc V-zero) ⟩\n `suc `suc `zero ∎\n", "meta": {"hexsha": "6664ef87ab388a92121f165d9589a464778e4ace", "size": 9508, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "proglangs-learning/Agda/plfa-exercises/Practice5.agda", "max_stars_repo_name": "helq/old_code", "max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "proglangs-learning/Agda/plfa-exercises/Practice5.agda", "max_issues_repo_name": "helq/old_code", "max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z", "max_forks_repo_path": "proglangs-learning/Agda/plfa-exercises/Practice5.agda", "max_forks_repo_name": "helq/old_code", "max_forks_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.2553846154, "max_line_length": 113, "alphanum_fraction": 0.3450778292, "num_tokens": 4655, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672089305841, "lm_q2_score": 0.7745833841649233, "lm_q1q2_score": 0.6259154333261561}} {"text": "-- Solutions to ExerciseSession3\n{-# OPTIONS --cubical #-}\nmodule SolutionsSession3 where\n\nopen import Part1\nopen import Part2\nopen import Part3\nopen import Part4 hiding (ℤ)\nopen import ExerciseSession1 hiding (B)\n\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Int hiding (neg)\n\n-- Exercise 1\nassoc-++ : (xs ys zs : FMSet A) → xs ++ (ys ++ zs) ≡ (xs ++ ys) ++ zs\nassoc-++ [] ys zs = refl\nassoc-++ (x ∷ xs) ys zs j = x ∷ assoc-++ xs ys zs j\nassoc-++ (comm x y xs i) ys zs j = comm x y (assoc-++ xs ys zs j) i\nassoc-++ (trunc xs xs' p q i k) ys zs j =\n trunc (assoc-++ xs ys zs j) (assoc-++ xs' ys zs j)\n (λ l → assoc-++ (p l) ys zs j)\n (λ l → assoc-++ (q l) ys zs j) i k\n\n-- Exercise 2\ndata ℤ : Type₀ where\n pos : (n : ℕ) → ℤ\n neg : (n : ℕ) → ℤ\n posneg : pos 0 ≡ neg 0\n\n-- Exercise 3\nInt→ℤ : Int → ℤ\nInt→ℤ (pos n) = pos n\nInt→ℤ (negsuc n) = neg (suc n)\n\nℤ→Int : ℤ → Int\nℤ→Int (pos n) = pos n\nℤ→Int (neg zero) = pos 0\nℤ→Int (neg (suc n)) = negsuc n\nℤ→Int (posneg _) = pos 0\n\nℤ→Int→ℤ : ∀ (n : ℤ) → Int→ℤ (ℤ→Int n) ≡ n\nℤ→Int→ℤ (pos n) _ = pos n\nℤ→Int→ℤ (neg zero) i = posneg i\nℤ→Int→ℤ (neg (suc n)) _ = neg (suc n)\nℤ→Int→ℤ (posneg j) i = posneg (j ∧ i)\n\nInt→ℤ→Int : ∀ (n : Int) → ℤ→Int (Int→ℤ n) ≡ n\nInt→ℤ→Int (pos n) _ = pos n\nInt→ℤ→Int (negsuc n) _ = negsuc n\n\nInt≡ℤ : Int ≡ ℤ\nInt≡ℤ = isoToPath (iso Int→ℤ ℤ→Int ℤ→Int→ℤ Int→ℤ→Int)\n\nisSetℤ : isSet ℤ\nisSetℤ = subst isSet Int≡ℤ isSetInt\n\n-- Exercise 4\nisSurjection : (A → B) → Type _\nisSurjection {A = A} {B = B} f = (b : B) → ∃ A (λ a → f a ≡ b)\n\nisPropIsSurjection : (f : A → B) → isProp (isSurjection f)\nisPropIsSurjection f = isPropΠ (λ _ → squash)\n\nisSurjectionInc : isSurjection {A = A} ∣_∣\nisSurjectionInc x = rec squash (λ y → ∣ (y , squash ∣ y ∣ x) ∣) x\n\n-- Exercise 5\nintLoop : Int → ΩS¹\nintLoop (pos zero) = refl\nintLoop (pos (suc n)) = intLoop (pos n) ∙ loop\nintLoop (negsuc zero) = sym loop\nintLoop (negsuc (suc n)) = intLoop (negsuc n) ∙ sym loop\n\nwindingIntLoop : (n : Int) → winding (intLoop n) ≡ n\nwindingIntLoop (pos zero) = refl\nwindingIntLoop (pos (suc n)) = cong sucInt (windingIntLoop (pos n))\nwindingIntLoop (negsuc zero) = refl\nwindingIntLoop (negsuc (suc n)) = cong predInt (windingIntLoop (negsuc n))\n\n\n-- Exercise 6\n\ndata Susp (A : Type ℓ) : Type ℓ where\n north : Susp A\n south : Susp A\n merid : (a : A) → north ≡ south\n\nSuspBool→S¹ : Susp Bool → S¹\nSuspBool→S¹ north = base\nSuspBool→S¹ south = base\nSuspBool→S¹ (merid false i) = loop i\nSuspBool→S¹ (merid true i) = base\n\nS¹→SuspBool : S¹ → Susp Bool\nS¹→SuspBool base = north\nS¹→SuspBool (loop i) = (merid false ∙ sym (merid true)) i\n\nSuspBool→S¹→SuspBool : (x : Susp Bool) → Path _ (S¹→SuspBool (SuspBool→S¹ x)) x\nSuspBool→S¹→SuspBool north = refl\nSuspBool→S¹→SuspBool south = merid true\nSuspBool→S¹→SuspBool (merid false i) j = hcomp (λ k → (λ { (j = i1) → merid false i\n ; (i = i0) → north\n ; (i = i1) → merid true (j ∨ ~ k)}))\n (merid false i)\nSuspBool→S¹→SuspBool (merid true i) j = merid true (i ∧ j)\n\nS¹→SuspBool→S¹ : (x : S¹) → SuspBool→S¹ (S¹→SuspBool x) ≡ x\nS¹→SuspBool→S¹ base = refl\nS¹→SuspBool→S¹ (loop i) j = hfill (λ k → λ { (i = i0) → base\n ; (i = i1) → base })\n (inS (loop i)) (~ j)\n\nS¹≡SuspBool : S¹ ≡ Susp Bool\nS¹≡SuspBool = isoToPath (iso S¹→SuspBool SuspBool→S¹ SuspBool→S¹→SuspBool S¹→SuspBool→S¹)\n", "meta": {"hexsha": "b2333271a6188a802f31cbfec66b991d03cd39b5", "size": 3608, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "04-cubical-type-theory/material/SolutionsSession3.agda", "max_stars_repo_name": "williamdemeo/EPIT-2020", "max_stars_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "04-cubical-type-theory/material/SolutionsSession3.agda", "max_issues_repo_name": "williamdemeo/EPIT-2020", "max_issues_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "04-cubical-type-theory/material/SolutionsSession3.agda", "max_forks_repo_name": "williamdemeo/EPIT-2020", "max_forks_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-08-02T16:16:34.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-02T16:16:34.000Z", "avg_line_length": 31.1034482759, "max_line_length": 93, "alphanum_fraction": 0.5737250554, "num_tokens": 1447, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835371034369, "lm_q2_score": 0.7490872243177518, "lm_q1q2_score": 0.6258500437719909}} {"text": "module SystemF.Syntax.Type.Constructors where\n\nopen import Prelude\nopen import SystemF.Syntax.Type\nopen import SystemF.Substitutions.Types\n\n-- church numerals\ntnat : Type 0\ntnat = ∀' (((tvar zero) →' (tvar zero)) →' (tvar zero) →' (tvar zero))\n\n-- Type of the polymorphic identity\ntid' : ∀ {n} → Type n\ntid' = ∀' ((tvar zero) →' (tvar zero))\n\n-- Top/terminal/unit type\n⊤' : ∀ {n} → Type n\n⊤' = tid'\n\n-- Bottom/initial/zero type\n⊥' : ∀ {n} → Type n\n⊥' = ∀' (tvar zero)\n\n-- n-ary function type\ninfixr 7 _→ⁿ_\n_→ⁿ_ : ∀ {n k} → Vec (Type n) k → Type n → Type n\n[] →ⁿ z = z\n(a ∷ as) →ⁿ z = as →ⁿ a →' z\n\n-- Record/finite tuple\nrec : ∀ {n k} → Vec (Type n) k → Type n\nrec [] = ⊤'\nrec (a ∷ as) = ∀' ((map tp-weaken (a ∷ as) →ⁿ tvar zero) →' tvar zero)\n\n-- tuple\n_×'_ : ∀ {n} → Type n → Type n → Type n\na ×' b = rec (a ∷ b ∷ [])\n", "meta": {"hexsha": "724fc8f79c6d19df9f573399d2aba2975c6d7699", "size": 832, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/SystemF/Syntax/Type/Constructors.agda", "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_issues_repo_path": "src/SystemF/Syntax/Type/Constructors.agda", "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/SystemF/Syntax/Type/Constructors.agda", "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.4864864865, "max_line_length": 70, "alphanum_fraction": 0.5600961538, "num_tokens": 337, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916170039421, "lm_q2_score": 0.7248702702332475, "lm_q1q2_score": 0.625846914734768}} {"text": "-- Fixed on AIM XIV 2011-09-09 AA, UN\n-- {-# OPTIONS -v tc.lhs.unify:50 #-}\nmodule Issue292 where\n\ndata ⊥ : Set where\n\ninfix 3 ¬_\n\n¬_ : Set → Set\n¬ P = P → ⊥\n\ninfix 4 _≅_\n\ndata _≅_ {A : Set} (x : A) : ∀ {B : Set} → B → Set where\n refl : x ≅ x\n\nrecord Σ (A : Set) (B : A → Set) : Set where\n constructor _,_\n field\n proj₁ : A\n proj₂ : B proj₁\n\nopen Σ public\n\ndata Bool : Set where true false : Bool\n\ndata D : Bool -> Set where\n tt : D true\n ff : D false\n\nP : Set -> Set\nP S = Σ S (\\s → s ≅ tt)\n\npbool : P (D true)\npbool = tt , refl\n\n¬pbool2 : ¬ P (D false)\n¬pbool2 ( ff , () )\n-- Andreas, 2011-09-13 fix of fix: should work again\n{- WAS: expected error\nff ≅ tt should be empty, but that's not obvious to me\nwhen checking that the clause ¬pbool2 (ff , ()) has type\n¬ P (D false)\n-}\n", "meta": {"hexsha": "2ef0cc10a98e74390a5fa8f801b220633c38c2ed", "size": 790, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/Issue292.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "test/succeed/Issue292.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/Issue292.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 17.5555555556, "max_line_length": 56, "alphanum_fraction": 0.582278481, "num_tokens": 301, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.863391595913457, "lm_q2_score": 0.7248702702332475, "lm_q1q2_score": 0.6258468994469024}} {"text": "open import Data.Bool using (Bool; true; false)\nopen import Data.Empty using (⊥)\nopen import Data.Unit using (⊤; tt)\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl; cong)\nopen import Relation.Nullary using (¬_)\n\n--data _≡_ {A : Set} (x : A) : A → Set where\n-- refl : x ≡ x\n\ntrans : ∀ {a} {A : Set a} {x y z : A} → x ≡ y → y ≡ z → x ≡ z\ntrans refl refl = refl\n\n-- This can be done in Coq but not in Agda?\n--disc'' : ∀ {x : Bool} → x ≡ x → x ≡ (¬ x) → ⊥\n--disc'' = ?\n\n-- How to prove this???\ndisc' : ∀ {a} {x : Set a} → x ≡ x → x ≡ (¬ x) → ⊥\ndisc' refl = ?\n\ndisc : ∀ {a} {x : Set a} → ¬ (x ≡ (¬ x))\ndisc {x} x≡¬x = ? -- disc' ? ? -- (refl {x}) x≡¬x\n\n\nopen import Data.Nat using (ℕ; suc; zero; _+_)\n\nright-zero : ∀ n → n + 0 ≡ n\nright-zero 0 = refl\nright-zero (suc n) = cong suc (right-zero n)\n\ncomm : ∀ m n p → m + (n + p) ≡ (m + n) + p\ncomm 0 _ _ = refl\ncomm (suc m) n p = cong suc (comm m n p)\n", "meta": {"hexsha": "873e1c9b1fd72af1bd095292e94a30c5b168d262", "size": 915, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "proglangs-learning/Coq/agdag.agda", "max_stars_repo_name": "helq/old_code", "max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "proglangs-learning/Coq/agdag.agda", "max_issues_repo_name": "helq/old_code", "max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z", "max_forks_repo_path": "proglangs-learning/Coq/agdag.agda", "max_forks_repo_name": "helq/old_code", "max_forks_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.9117647059, "max_line_length": 73, "alphanum_fraction": 0.5366120219, "num_tokens": 374, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637648915616, "lm_q2_score": 0.7279754489059775, "lm_q1q2_score": 0.6258141151551373}} {"text": "\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Data.FinData.Properties where\n\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Data.FinData.Base as Fin\nimport Cubical.Data.Nat as ℕ\nopen import Cubical.Data.Empty as Empty\nopen import Cubical.Relation.Nullary\n\nprivate\n variable\n ℓ : Level\n A : Type ℓ\n\n\nznots : ∀{k} {m : Fin k} → ¬ (zero ≡ (suc m))\nznots {k} {m} x = subst (Fin.rec (Fin k) ⊥) x m\n\nsnotz : ∀{k} {m : Fin k} → ¬ ((suc m) ≡ zero)\nsnotz {k} {m} x = subst (Fin.rec ⊥ (Fin k)) x m\n\nisPropFin0 : isProp (Fin 0)\nisPropFin0 = Empty.rec ∘ ¬Fin0\n\nisContrFin1 : isContr (Fin 1)\nisContrFin1 .fst = zero\nisContrFin1 .snd zero = refl\n\ninjSucFin : ∀ {n} { p q : Fin n} → suc p ≡ suc q → p ≡ q\ninjSucFin {ℕ.suc ℕ.zero} {zero} {zero} pf = refl\ninjSucFin {ℕ.suc (ℕ.suc n)} pf = cong predFin pf\n\n\ndiscreteFin : ∀{k} → Discrete (Fin k)\ndiscreteFin zero zero = yes refl\ndiscreteFin zero (suc y) = no znots\ndiscreteFin (suc x) zero = no snotz\ndiscreteFin (suc x) (suc y) with discreteFin x y\n... | yes p = yes (cong suc p)\n... | no ¬p = no (λ q → ¬p (injSucFin q))\n\nisSetFin : ∀{k} → isSet (Fin k)\nisSetFin = Discrete→isSet discreteFin\n", "meta": {"hexsha": "3cef723fff8264c8f20bf52a0a5760e230fa6da5", "size": 1206, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/FinData/Properties.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/FinData/Properties.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/Data/FinData/Properties.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.6595744681, "max_line_length": 56, "alphanum_fraction": 0.6608623549, "num_tokens": 461, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637433190939, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.6258141045243623}} {"text": "module Numeral.Natural.Oper.Summation.Range where\n\nimport Lvl\nopen import Data.List\nopen import Data.List.Functions\nopen import Numeral.Natural\nopen import Type\n\n_‥_ : ℕ → ℕ → List(ℕ)\n_ ‥ 𝟎 = ∅\n𝟎 ‥ 𝐒 b = 𝟎 ⊰ map 𝐒(𝟎 ‥ b)\n𝐒 a ‥ 𝐒 b = map 𝐒(a ‥ b)\n\n‥_ : ℕ → List(ℕ)\n‥ b = 𝟎 ‥ b\n\n_‥₌_ : ℕ → ℕ → List(ℕ)\na ‥₌ b = a ‥ 𝐒(b)\n\n‥₌_ : ℕ → List(ℕ)\n‥₌ b = 𝟎 ‥₌ b\n", "meta": {"hexsha": "052e0d431aeee23990ef8451247e0da1fae561b5", "size": 362, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Oper/Summation/Range.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Oper/Summation/Range.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Oper/Summation/Range.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.4545454545, "max_line_length": 49, "alphanum_fraction": 0.5524861878, "num_tokens": 200, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8596637505099168, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.6258140996122009}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import HoTT\n\nmodule homotopy.OneSkeleton {i} {A : Type i} {j} {B : Type j} where\n\n private\n module _ (map : A → B) where\n data #OneSkeleton-aux : Type i where\n #point : A → #OneSkeleton-aux\n\n data #OneSkeleton : Type i where\n #one-skeleton : #OneSkeleton-aux → (Unit → Unit) → #OneSkeleton\n\n OneSkeleton : (A → B) → Type i\n OneSkeleton = #OneSkeleton\n\n module _ {map : A → B} where\n\n point : A → OneSkeleton map\n point a = #one-skeleton (#point a) _\n\n postulate -- HIT\n link : ∀ a₁ a₂ → map a₁ == map a₂ → point a₁ == point a₂\n \n module OneSkeletonElim\n {l} {P : OneSkeleton map → Type l}\n (point* : ∀ a → P (point a))\n (link* : ∀ a₁ a₂ p → point* a₁ == point* a₂ [ P ↓ link a₁ a₂ p ]) where\n\n f : Π (OneSkeleton map) P\n f = f-aux phantom where\n\n f-aux : Phantom link* → Π (OneSkeleton map) P\n f-aux phantom (#one-skeleton (#point a) _) = point* a\n\n postulate\n link-β : ∀ a₁ a₂ p → apd f (link a₁ a₂ p) == link* a₁ a₂ p\n\n open OneSkeletonElim public using () renaming (f to OneSkeleton-elim)\n\n module OneSkeletonRec\n {l} {P : Type l}\n (point* : ∀ a → P)\n (link* : ∀ a₁ a₂ p → point* a₁ == point* a₂) where\n \n private\n module M = OneSkeletonElim point*\n (λ a₁ a₂ p → ↓-cst-in (link* a₁ a₂ p))\n\n f : OneSkeleton map → P\n f = M.f\n\n link-β : ∀ a₁ a₂ p → ap f (link a₁ a₂ p) == link* a₁ a₂ p\n link-β a₁ a₂ p = apd=cst-in {f = f} (M.link-β a₁ a₂ p)\n\n open OneSkeletonRec public using () renaming (f to OneSkeleton-rec)\n\n OneSkeleton-lift : OneSkeleton map → B\n OneSkeleton-lift = OneSkeleton-rec map (λ _ _ p → p)\n\n{-\nmodule _ {i} {A B : Set i} where\n skeleton₁ : (A → B) → Set i\n skeleton₁ f = Graveyard.skeleton₁ {i} {A} {B} {f}\n\n-}\n", "meta": {"hexsha": "1216901a0f97074f6668169363b1b78a13fa4488", "size": 1844, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "homotopy/OneSkeleton.agda", "max_stars_repo_name": "danbornside/HoTT-Agda", "max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "homotopy/OneSkeleton.agda", "max_issues_repo_name": "danbornside/HoTT-Agda", "max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "homotopy/OneSkeleton.agda", "max_forks_repo_name": "danbornside/HoTT-Agda", "max_forks_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.1176470588, "max_line_length": 77, "alphanum_fraction": 0.5601952278, "num_tokens": 633, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357701094303, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.6257771766934873}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- \"Finite\" sets indexed on coinductive \"natural\" numbers\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe --sized-types #-}\n\nmodule Codata.Cofin where\n\nopen import Size\nopen import Codata.Thunk\nopen import Codata.Conat as Conat using (Conat; zero; suc; infinity; _ℕ<_; sℕ≤s; _ℕ≤infinity)\nopen import Codata.Conat.Bisimilarity as Bisim using (_⊢_≲_ ; s≲s)\nopen import Data.Nat\nopen import Data.Fin as Fin hiding (fromℕ; fromℕ≤; toℕ)\nopen import Function\nopen import Relation.Binary.PropositionalEquality\n\n------------------------------------------------------------------------\n-- The type\n\n-- Note that `Cofin infnity` is /not/ finite. Note also that this is not a\n-- coinductive type, but it is indexed on a coinductive type.\n\ndata Cofin : Conat ∞ → Set where\n zero : ∀ {n} → Cofin (suc n)\n suc : ∀ {n} → Cofin (n .force) → Cofin (suc n)\n\nsuc-injective : ∀ {n} {p q : Cofin (n .force)} →\n (Cofin (suc n) ∋ suc p) ≡ suc q → p ≡ q\nsuc-injective refl = refl\n\n------------------------------------------------------------------------\n-- Some operations\n\nfromℕ< : ∀ {n k} → k ℕ< n → Cofin n\nfromℕ< {zero} ()\nfromℕ< {suc n} {zero} (sℕ≤s p) = zero\nfromℕ< {suc n} {suc k} (sℕ≤s p) = suc (fromℕ< p)\n\nfromℕ : ℕ → Cofin infinity\nfromℕ k = fromℕ< (suc k ℕ≤infinity)\n\ntoℕ : ∀ {n} → Cofin n → ℕ\ntoℕ zero = zero\ntoℕ (suc i) = suc (toℕ i)\n\nfromFin : ∀ {n} → Fin n → Cofin (Conat.fromℕ n)\nfromFin zero = zero\nfromFin (suc i) = suc (fromFin i)\n\ntoFin : ∀ n → Cofin (Conat.fromℕ n) → Fin n\ntoFin zero ()\ntoFin (suc n) zero = zero\ntoFin (suc n) (suc i) = suc (toFin n i)\n", "meta": {"hexsha": "3e408fb8bfdbeb29d04376ef0dfd0a1cf3c21dab", "size": 1745, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Codata/Cofin.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Codata/Cofin.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Codata/Cofin.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.6140350877, "max_line_length": 93, "alphanum_fraction": 0.5323782235, "num_tokens": 589, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357563664174, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.6257771719639424}} {"text": "open import Relation.Binary.Core\n\nmodule PLRTree.Drop.Heap {A : Set} \n (_≤_ : A → A → Set)\n (tot≤ : Total _≤_) \n (trans≤ : Transitive _≤_) where\n\nopen import PLRTree {A} \nopen import PLRTree.Compound {A} \nopen import PLRTree.Drop _≤_ tot≤\nopen import PLRTree.DropLast.Heap _≤_ tot≤\nopen import PLRTree.Heap _≤_\nopen import PLRTree.Order.Properties {A}\nopen import PLRTree.Push.Heap _≤_ tot≤ trans≤ \n\nlemma-drop-heap : {t : PLRTree} → Heap t → Heap (drop t)\nlemma-drop-heap leaf = leaf\nlemma-drop-heap (node {t} {x} (lf≤* .x) (lf≤* .x) leaf leaf) = leaf\nlemma-drop-heap (node {t} {x} {r = node t' x' l' r'} (lf≤* .x) (nd≤* x≤x' x≤*l' x≤*r') leaf (node x'≤*l' x'≤*r' hl' hr')) \n with dropLast (node t x leaf (node t' x' l' r')) | lemma-dropLast-heap (node {t} (lf≤* x) (nd≤* {t'} x≤x' x≤*l' x≤*r') leaf (node x'≤*l' x'≤*r' hl' hr')) \n... | leaf | leaf = leaf\n... | node t'' x'' l'' r'' | node x''≤*l'' x''≤*r'' hl'' hr'' =\n let z = last (node t x leaf (node t' x' l' r')) compound \n in lemma-push-heap t'' z hl'' hr'' (≺-wf (node t'' z l'' r''))\nlemma-drop-heap (node {t} {x} {l = node t' x' l' r'} {r} (nd≤* x≤x' x≤*l' x≤*r') x≤*r (node x'≤*l' x'≤*r' hl' hr') hr) \n with dropLast (node t x (node t' x' l' r') r) | lemma-dropLast-heap (node {t} (nd≤* {t'} x≤x' x≤*l' x≤*r') x≤*r (node x'≤*l' x'≤*r' hl' hr') hr) \n... | leaf | leaf = leaf\n... | node t'' x'' l'' r'' | node x''≤*l'' x''≤*r'' hl'' hr'' =\n let z = last (node t x (node t' x' l' r') r) compound \n in lemma-push-heap t'' z hl'' hr'' (≺-wf (node t'' z l'' r''))\n", "meta": {"hexsha": "c6d0b84e3b62ede95e26c3b576c7e4b470fda263", "size": 1627, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/PLRTree/Drop/Heap.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/PLRTree/Drop/Heap.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/PLRTree/Drop/Heap.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.4838709677, "max_line_length": 159, "alphanum_fraction": 0.5119852489, "num_tokens": 713, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.894789468908171, "lm_q2_score": 0.6992544085240401, "lm_q1q2_score": 0.625685480834923}} {"text": "module Symmetric where\n\nopen import Level hiding ( suc ; zero )\nopen import Algebra\nopen import Algebra.Structures\nopen import Data.Fin hiding ( _<_ ; _≤_ ; _-_ ; _+_ )\nopen import Data.Fin.Properties hiding ( <-trans ; ≤-trans ) renaming ( <-cmp to <-fcmp )\nopen import Data.Product\nopen import Data.Fin.Permutation\nopen import Function hiding (id ; flip)\nopen import Function.Inverse as Inverse using (_↔_; Inverse; _InverseOf_)\nopen import Function.LeftInverse using ( _LeftInverseOf_ )\nopen import Function.Equality using (Π)\nopen import Data.Nat -- using (ℕ; suc; zero; s≤s ; z≤n )\nopen import Data.Nat.Properties -- using (<-trans)\nopen import Relation.Binary.PropositionalEquality \nopen import Data.List using (List; []; _∷_ ; length ; _++_ ; head ) renaming (reverse to rev )\nopen import nat\n\nfid : {p : ℕ } → Fin p → Fin p\nfid x = x\n\n-- Data.Fin.Permutation.id\npid : {p : ℕ } → Permutation p p\npid = permutation fid fid record { left-inverse-of = λ x → refl ; right-inverse-of = λ x → refl }\n\n-- Data.Fin.Permutation.flip\npinv : {p : ℕ } → Permutation p p → Permutation p p\npinv {p} P = permutation (_⟨$⟩ˡ_ P) (_⟨$⟩ʳ_ P ) record { left-inverse-of = λ x → inverseʳ P ; right-inverse-of = λ x → inverseˡ P }\n\nrecord _=p=_ {p : ℕ } ( x y : Permutation p p ) : Set where\n field\n peq : ( q : Fin p ) → x ⟨$⟩ʳ q ≡ y ⟨$⟩ʳ q\n\nopen _=p=_\n\nprefl : {p : ℕ } { x : Permutation p p } → x =p= x\npeq (prefl {p} {x}) q = refl\n\npsym : {p : ℕ } { x y : Permutation p p } → x =p= y → y =p= x\npeq (psym {p} {x} {y} eq ) q = sym (peq eq q)\n\nptrans : {p : ℕ } { x y z : Permutation p p } → x =p= y → y =p= z → x =p= z\npeq (ptrans {p} {x} {y} x=y y=z ) q = trans (peq x=y q) (peq y=z q)\n\npeqˡ : {p : ℕ }{ x y : Permutation p p } → x =p= y → (q : Fin p) → x ⟨$⟩ˡ q ≡ y ⟨$⟩ˡ q\npeqˡ {p} {x} {y} eq q = begin\n x ⟨$⟩ˡ q\n ≡⟨ sym ( inverseˡ y ) ⟩\n y ⟨$⟩ˡ (y ⟨$⟩ʳ ( x ⟨$⟩ˡ q ))\n ≡⟨ cong (λ k → y ⟨$⟩ˡ k ) (sym (peq eq _ )) ⟩\n y ⟨$⟩ˡ (x ⟨$⟩ʳ ( x ⟨$⟩ˡ q ))\n ≡⟨ cong (λ k → y ⟨$⟩ˡ k ) ( inverseʳ x ) ⟩\n y ⟨$⟩ˡ q\n ∎ where open ≡-Reasoning\n\npresp : { p : ℕ } {x y u v : Permutation p p } → x =p= y → u =p= v → (x ∘ₚ u) =p= (y ∘ₚ v)\npresp {p} {x} {y} {u} {v} x=y u=v = record { peq = λ q → lemma4 q } where\n lemma4 : (q : Fin p) → ((x ∘ₚ u) ⟨$⟩ʳ q) ≡ ((y ∘ₚ v) ⟨$⟩ʳ q)\n lemma4 q = trans (cong (λ k → Inverse.to u Π.⟨$⟩ k) (peq x=y q) ) (peq u=v _ )\npassoc : { p : ℕ } (x y z : Permutation p p) → ((x ∘ₚ y) ∘ₚ z) =p= (x ∘ₚ (y ∘ₚ z))\npassoc x y z = record { peq = λ q → refl }\np-inv : { p : ℕ } {i j : Permutation p p} → i =p= j → (q : Fin p) → pinv i ⟨$⟩ʳ q ≡ pinv j ⟨$⟩ʳ q\np-inv {p} {i} {j} i=j q = begin\n i ⟨$⟩ˡ q ≡⟨ cong (λ k → i ⟨$⟩ˡ k) (sym (inverseʳ j) ) ⟩\n i ⟨$⟩ˡ ( j ⟨$⟩ʳ ( j ⟨$⟩ˡ q )) ≡⟨ cong (λ k → i ⟨$⟩ˡ k) (sym (peq i=j _ )) ⟩\n i ⟨$⟩ˡ ( i ⟨$⟩ʳ ( j ⟨$⟩ˡ q )) ≡⟨ inverseˡ i ⟩\n j ⟨$⟩ˡ q\n ∎ where open ≡-Reasoning\n\nSymmetric : ℕ → Group Level.zero Level.zero\nSymmetric p = record {\n Carrier = Permutation p p\n ; _≈_ = _=p=_\n ; _∙_ = _∘ₚ_\n ; ε = pid\n ; _⁻¹ = pinv\n ; isGroup = record { isMonoid = record { isSemigroup = record { isMagma = record {\n isEquivalence = record {refl = prefl ; trans = ptrans ; sym = psym }\n ; ∙-cong = presp }\n ; assoc = passoc }\n ; identity = ( (λ q → record { peq = λ q → refl } ) , (λ q → record { peq = λ q → refl } )) }\n ; inverse = ( (λ x → record { peq = λ q → inverseʳ x} ) , (λ x → record { peq = λ q → inverseˡ x} )) \n ; ⁻¹-cong = λ i=j → record { peq = λ q → p-inv i=j q }\n }\n } \n\n", "meta": {"hexsha": "3b79dd8b579ee50159a0be1a9a619dfa38a845fb", "size": 3620, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Symmetric.agda", "max_stars_repo_name": "shinji-kono/Galois", "max_stars_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-16T03:37:05.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-16T03:37:05.000Z", "max_issues_repo_path": "src/Symmetric.agda", "max_issues_repo_name": "shinji-kono/Galois", "max_issues_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Symmetric.agda", "max_forks_repo_name": "shinji-kono/Galois", "max_forks_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.1363636364, "max_line_length": 131, "alphanum_fraction": 0.5162983425, "num_tokens": 1513, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256432832333, "lm_q2_score": 0.7431680029241321, "lm_q1q2_score": 0.6256178821291233}} {"text": "------------------------------------------------------------------------------\n-- Agda-Prop Library.\n-- Extension Theorems of the Syntax definitions.\n------------------------------------------------------------------------------\n\nopen import Data.Nat using ( ℕ )\n\nmodule Data.PropFormula.Theorems.Weakening ( n : ℕ ) where\n\n------------------------------------------------------------------------------\n\nopen import Data.PropFormula.Syntax n\nopen import Data.PropFormula.Properties n using ( substΓ )\n\nopen import Data.List using ( List ; [] ; _∷_ ; _++_ ; [_] )\n\nopen import Relation.Binary.PropositionalEquality\n using ( _≡_; refl; cong; trans; sym)\n\n------------------------------------------------------------------------------\n\n-- Theorem.\nweaken-Δ₁\n : ∀ {Γ} {φ}\n → (Δ : Ctxt)\n → Γ ⊢ φ\n → Γ ⨆ Δ ⊢ φ\n\n-- Proof.\nweaken-Δ₁ {[]} {φ} [] Γ⊢φ = Γ⊢φ\nweaken-Δ₁ {x ∷ Γ} {φ} [] Γ⊢φ = substΓ (sym helper) Γ⊢φ\n where\n helper : ∀ {Γ} → Γ ⨆ [] ≡ Γ\n helper {[]} = refl\n helper {x ∷ Γ} rewrite helper {Γ = Γ} = refl\nweaken-Δ₁ {Γ} {φ} (x ∷ []) Γ⊢φ = weaken x Γ⊢φ\nweaken-Δ₁ {Γ} {φ} (x₁ ∷ Δ) Γ⊢φ =\n substΓ\n helper\n (weaken-Δ₁ Δ\n (weaken x₁ Γ⊢φ))\n where\n helper : ∀ {Γ Δ} {x} → (Γ , x ) ⨆ Δ ≡ Γ ⨆ (x ∷ Δ)\n helper {[]} {Δ} = refl\n helper {y ∷ Γ} {Δ} {x} rewrite helper {Γ = Γ} {Δ = Δ} {x = x} = refl\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nweaken-Δ₂\n : ∀ {Γ} {φ}\n → (Δ : Ctxt)\n → Γ ⊢ φ\n → Δ ⨆ Γ ⊢ φ\n\n-- Proof.\nweaken-Δ₂ {_} [] Γ⊢φ = Γ⊢φ\nweaken-Δ₂ {[]} (hyp ∷ []) Γ⊢φ = weaken₂ hyp Γ⊢φ\nweaken-Δ₂ {_} (hyp ∷ []) Γ⊢φ = weaken₂ hyp Γ⊢φ\nweaken-Δ₂ {_} (hyp ∷ hyps) Γ⊢φ = weaken₂ hyp (weaken-Δ₂ hyps Γ⊢φ)\n-------------------------------------------------------------------------- ∎\n", "meta": {"hexsha": "af33ca3dca9e79ededfb1330c90f9f5fc58c4ea4", "size": 1771, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/PropFormula/Theorems/Weakening.agda", "max_stars_repo_name": "jonaprieto/agda-prop", "max_stars_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 13, "max_stars_repo_stars_event_min_datetime": "2017-05-01T16:45:41.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T03:33:12.000Z", "max_issues_repo_path": "src/Data/PropFormula/Theorems/Weakening.agda", "max_issues_repo_name": "jonaprieto/agda-prop", "max_issues_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 18, "max_issues_repo_issues_event_min_datetime": "2017-03-08T14:33:10.000Z", "max_issues_repo_issues_event_max_datetime": "2017-12-18T16:34:21.000Z", "max_forks_repo_path": "src/Data/PropFormula/Theorems/Weakening.agda", "max_forks_repo_name": "jonaprieto/agda-prop", "max_forks_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-03-30T16:41:56.000Z", "max_forks_repo_forks_event_max_datetime": "2017-12-01T17:01:25.000Z", "avg_line_length": 29.0327868852, "max_line_length": 78, "alphanum_fraction": 0.3935629588, "num_tokens": 634, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972751232808, "lm_q2_score": 0.7185943925708561, "lm_q1q2_score": 0.6256063200910564}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Functor.Instance.UnderlyingQuiver where\n\n-- The forgetful functor from categories to its underlying quiver\n-- **except** that this functor only goes from **StrictCats**,\n-- i.e. where Functor equivalence is propositional equality, not\n-- NaturalIsomorphism.\n\nopen import Level using (Level)\n-- open import Function using (_$_; flip)\nopen import Relation.Binary.PropositionalEquality\n using (refl)\nopen import Relation.Binary.PropositionalEquality.Subst.Properties\n using (module Transport)\nopen import Data.Quiver using (Quiver)\nopen import Data.Quiver.Morphism using (Morphism; _≃_)\n\nopen import Categories.Category.Core using (Category)\nopen import Categories.Category.Instance.Quivers using (Quivers)\nopen import Categories.Category.Instance.StrictCats\nopen import Categories.Functor using (Functor)\nopen import Categories.Functor.Equivalence using (_≡F_)\nimport Categories.Morphism.HeterogeneousIdentity as HId\n\nprivate\n variable\n o ℓ e o′ ℓ′ e′ : Level\n A B : Category o ℓ e\n\nUnderlying₀ : Category o ℓ e → Quiver o ℓ e\nUnderlying₀ C = record { Category C }\n\nUnderlying₁ : Functor A B → Morphism (Underlying₀ A) (Underlying₀ B)\nUnderlying₁ F = record { Functor F }\n\nprivate\n ≡F-resp-≃ : {F G : Functor A B} → F ≡F G → Underlying₁ F ≃ Underlying₁ G\n ≡F-resp-≃ {B = B} {F} {G} F≈G = record\n { F₀≡ = λ {X} → eq₀ F≈G X\n ; F₁≡ = λ {x} {y} {f} →\n let open Category B using (_∘_)\n open HId B\n UB = Underlying₀ B\n open Transport (Quiver._⇒_ UB) using (_▸_; _◂_)\n module F = Functor F using (₁)\n module G = Functor G using (₁)\n open Quiver.EdgeReasoning (Underlying₀ B)\n in begin\n F.₁ f ▸ eq₀ F≈G y ≈⟨ hid-subst-cod (F.₁ f) (eq₀ F≈G y) ⟩\n hid (eq₀ F≈G y) ∘ F.₁ f ≈⟨ eq₁ F≈G f ⟩\n G.₁ f ∘ hid (eq₀ F≈G x) ≈˘⟨ hid-subst-dom (eq₀ F≈G x) (G.₁ f) ⟩\n eq₀ F≈G x ◂ G.₁ f ∎\n }\n where open _≡F_\n\nUnderlying : Functor (StrictCats o ℓ e) (Quivers o ℓ e)\nUnderlying = record\n { F₀ = Underlying₀\n ; F₁ = Underlying₁\n ; identity = λ {A} → record { F₀≡ = refl ; F₁≡ = Category.Equiv.refl A }\n ; homomorphism = λ where {Z = Z} → record { F₀≡ = refl ; F₁≡ = Category.Equiv.refl Z }\n ; F-resp-≈ = ≡F-resp-≃\n }\n", "meta": {"hexsha": "eeaddf12374698fd0733f1e455f94513c8d94061", "size": 2279, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Functor/Instance/UnderlyingQuiver.agda", "max_stars_repo_name": "sstucki/agda-categories", "max_stars_repo_head_hexsha": "602ed2ae05dd449d77fc299c07a1cdd02ee5b823", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Functor/Instance/UnderlyingQuiver.agda", "max_issues_repo_name": "sstucki/agda-categories", "max_issues_repo_head_hexsha": "602ed2ae05dd449d77fc299c07a1cdd02ee5b823", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Functor/Instance/UnderlyingQuiver.agda", "max_forks_repo_name": "sstucki/agda-categories", "max_forks_repo_head_hexsha": "602ed2ae05dd449d77fc299c07a1cdd02ee5b823", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.0615384615, "max_line_length": 88, "alphanum_fraction": 0.6516015796, "num_tokens": 767, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972650509008, "lm_q2_score": 0.7185943925708562, "lm_q1q2_score": 0.6256063128531008}} {"text": "{-# OPTIONS --warning=error --without-K --guardedness --safe #-}\n\nopen import LogicalFormulae\nopen import Numbers.Naturals.Definition\nopen import Setoids.Setoids\nopen import Numbers.Naturals.Order\nopen import Vectors\n\nmodule Sequences where\n\nrecord Sequence {a : _} (A : Set a) : Set a where\n coinductive\n field\n head : A\n tail : Sequence A\n\nheadInjective : {a : _} {A : Set a} {s1 s2 : Sequence A} → s1 ≡ s2 → Sequence.head s1 ≡ Sequence.head s2\nheadInjective {s1 = s1} {.s1} refl = refl\n\nconstSequence : {a : _} {A : Set a} (k : A) → Sequence A\nSequence.head (constSequence k) = k\nSequence.tail (constSequence k) = constSequence k\n\nindex : {a : _} {A : Set a} (s : Sequence A) (n : ℕ) → A\nindex s zero = Sequence.head s\nindex s (succ n) = index (Sequence.tail s) n\n\nfuncToSequence : {a : _} {A : Set a} (f : ℕ → A) → Sequence A\nSequence.head (funcToSequence f) = f 0\nSequence.tail (funcToSequence f) = funcToSequence (λ i → f (succ i))\n\nfuncToSequenceReversible : {a : _} {A : Set a} (f : ℕ → A) → (n : ℕ) → index (funcToSequence f) n ≡ f n\nfuncToSequenceReversible f zero = refl\nfuncToSequenceReversible f (succ n) = funcToSequenceReversible (λ i → f (succ i)) n\n\nmap : {a b : _} {A : Set a} {B : Set b} (f : A → B) (s : Sequence A) → Sequence B\nSequence.head (map f s) = f (Sequence.head s)\nSequence.tail (map f s) = map f (Sequence.tail s)\n\napply : {a b c : _} {A : Set a} {B : Set b} {C : Set c} (f : A → B → C) (s1 : Sequence A) (s2 : Sequence B) → Sequence C\nSequence.head (apply f s1 s2) = f (Sequence.head s1) (Sequence.head s2)\nSequence.tail (apply f s1 s2) = apply f (Sequence.tail s1) (Sequence.tail s2)\n\nindexAndConst : {a : _} {A : Set a} (a : A) (n : ℕ) → index (constSequence a) n ≡ a\nindexAndConst a zero = refl\nindexAndConst a (succ n) = indexAndConst a n\n\nmapTwice : {a b c : _} {A : Set a} {B : Set b} {C : Set c} (f : A → B) (g : B → C) (s : Sequence A) → {n : ℕ} → index (map g (map f s)) n ≡ index (map (λ i → g (f i)) s) n\nmapTwice f g s {zero} = refl\nmapTwice f g s {succ n} = mapTwice f g (Sequence.tail s) {n}\n\nmapAndIndex : {a b : _} {A : Set a} {B : Set b} (s : Sequence A) (f : A → B) (n : ℕ) → f (index s n) ≡ index (map f s) n\nmapAndIndex s f zero = refl\nmapAndIndex s f (succ n) = mapAndIndex (Sequence.tail s) f n\n\nindexExtensional : {a b c : _} {A : Set a} {B : Set b} (T : Setoid {_} {c} B) (s : Sequence A) (f g : A → B) → (extension : ∀ {x} → (Setoid._∼_ T (f x) (g x))) → {n : ℕ} → Setoid._∼_ T (index (map f s) n) (index (map g s) n)\nindexExtensional T s f g extension {zero} = extension\nindexExtensional T s f g extension {succ n} = indexExtensional T (Sequence.tail s) f g extension {n}\n\nindexAndApply : {a b c : _} {A : Set a} {B : Set b} {C : Set c} (s1 : Sequence A) (s2 : Sequence B) (f : A → B → C) → {m : ℕ} → index (apply f s1 s2) m ≡ f (index s1 m) (index s2 m)\nindexAndApply s1 s2 f {zero} = refl\nindexAndApply s1 s2 f {succ m} = indexAndApply (Sequence.tail s1) (Sequence.tail s2) f {m}\n\nmapAndApply : {a b c d : _} {A : Set a} {B : Set b} {C : Set c} {D : Set d} (s1 : Sequence A) (s2 : Sequence B) (f : A → B → C) (g : C → D) → (m : ℕ) → index (map g (apply f s1 s2)) m ≡ g (f (index s1 m) (index s2 m))\nmapAndApply s1 s2 f g zero = refl\nmapAndApply s1 s2 f g (succ m) = mapAndApply (Sequence.tail s1) (Sequence.tail s2) f g m\n\nassemble : {a : _} {A : Set a} → (x : A) → (s : Sequence A) → Sequence A\nSequence.head (assemble x s) = x\nSequence.tail (assemble x s) = s\n\nallTrue : {a : _} {A : Set a} {c : _} (pred : A → Set c) (s : Sequence A) → Set c\nallTrue pred s = (n : ℕ) → pred (index s n)\n\ntailFrom : {a : _} {A : Set a} (n : ℕ) → (s : Sequence A) → Sequence A\ntailFrom zero s = s\ntailFrom (succ n) s = tailFrom n (Sequence.tail s)\n\nsubsequence : {a : _} {A : Set a} (x : Sequence A) → (indices : Sequence ℕ) → ((n : ℕ) → index indices n y\n-- ^ ^\n-- ¦ ¦\n-- refl ¦ sq ¦ p\n-- ¦ ¦\n-- ¦ ¦\n-- x --------> x\n-- refl\n--\n-- These operations are very useful, for example let's prove that\n-- singletons are contractible (aka based path induction).\n--\n-- We first need the notion of contractible types. For this we need\n-- to use a Σ-type:\nisContr : Type ℓ → Type ℓ\nisContr A = Σ[ x ∈ A ] ((y : A) → x ≡ y)\n\n-- Σ-types are introduced in the file Agda.Builtin.Sigma as the record\n-- (modulo some renaming):\n--\n-- record Σ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') : Type (ℓ-max ℓ ℓ') where\n-- constructor _,_\n-- field\n-- fst : A\n-- snd : B fst\n--\n-- So the projections are fst/snd and the constructor is _,_. We\n-- also define non-dependent product as a special case of Σ-types in\n-- Cubical.Data.Sigma.Base as:\n--\n-- _×_ : ∀ {ℓ ℓ'} (A : Type ℓ) (B : Type ℓ') → Type (ℓ-max ℓ ℓ')\n-- A × B = Σ A (λ _ → B)\n--\n-- The notation ∀ {ℓ ℓ'} lets us omit the type of ℓ and ℓ' in the\n-- definition.\n\n-- We define the type of singletons as follows\nsingl : {A : Type ℓ} (a : A) → Type ℓ\nsingl {A = A} a = Σ[ x ∈ A ] a ≡ x\n\n-- To show that this type is contractible we need to provide a center\n-- of contraction and the fact that any element of it is path-equal to\n-- the center\nisContrSingl : (x : A) → isContr (singl x)\nisContrSingl x = ctr , prf\n where\n -- The center is just a pair with x and refl\n ctr : singl x\n ctr = x , refl\n\n -- We then need to prove that ctr is equal to any element s : singl x.\n -- This is an equality in a Σ-type, so the first component is a path\n -- and the second is a path over the path we pick as first argument,\n -- so the second component is a square. In fact, we need a square\n -- relating refl and pax, so we can use an _∧_ connection.\n prf : (s : singl x) → ctr ≡ s\n prf (y , pax) i = (pax i) , λ j → pax (i ∧ j)\n\n\n-- As we saw in the second component of prf we often need squares when\n-- proving things. In fact, pax (i ∧ j) is a path relating refl to pax\n-- *over* another path \"λ j → x ≡ pax j\". This notion of path over a\n-- path is very useful when working in HoTT as well as cubically. In\n-- HoTT these are called path-overs and are defined using transport,\n-- but in Cubical Agda they are a primitive notion called PathP (\"Path\n-- of a Path\"). In general PathP A x y has\n--\n-- A : I → Type ℓ\n-- x : A i0\n-- y : A i1\n--\n-- So PathP lets us natively define heteorgeneous paths, i.e. paths\n-- where the endpoints lie in different types. This lets us specify\n-- the type of the second component of prf:\nprf' : (x : A) (s : singl x) → (x , refl) ≡ s\nprf' x (y , pax) i = (pax i) , λ j → goal i j\n where\n goal : PathP (λ j → x ≡ pax j) refl pax\n goal i j = pax (i ∧ j)\n\n\n-- Just like _×_ is a special case of Σ-types we have that _≡_ is a\n-- special case of PathP. In fact, x ≡ y is just short for PathP (λ _ → A) x y:\nreflP : {x : A} → PathP (λ _ → A) x x\nreflP {x = x} = λ _ → x\n\n\n-- Having the primitive notion of equality be heterogeneous is an\n-- easily overlooked, but very important, strength of cubical type\n-- theory. This allows us to work directly with equality in Σ-types\n-- without using transport:\nmodule _ {A : Type ℓ} {B : A → Type ℓ'} {x y : Σ A B} where\n\n ΣPathP : Σ[ p ∈ fst x ≡ fst y ] PathP (λ i → B (p i)) (snd x) (snd y)\n → x ≡ y\n ΣPathP eq i = fst eq i , snd eq i\n\n PathPΣ : x ≡ y\n → Σ[ p ∈ fst x ≡ fst y ] PathP (λ i → B (p i)) (snd x) (snd y)\n PathPΣ eq = (λ i → fst (eq i)) , (λ i → snd (eq i))\n\n -- The fact that these cancel is proved by refl\n\n-- If one looks carefully the proof of prf uses ΣPathP inlined, in\n-- fact this is used all over the place when working cubically and\n-- simplifies many proofs which in HoTT requires long complicated\n-- reasoning about transport.\nisContrΠ : {B : A → Type ℓ'} (h : (x : A) → isContr (B x))\n → isContr ((x : A) → B x)\nisContrΠ h = (λ x → fst (h x)) , (λ f i x → snd (h x) (f x) i)\n\n-- Let us end this session with defining propositions and sets\nisProp : Type ℓ → Type ℓ\nisProp A = (x y : A) → x ≡ y\n\nisSet : Type ℓ → Type ℓ\nisSet A = (x y : A) → isProp (x ≡ y)\n\n-- In the agda/cubical library we call these h-levels following\n-- Voevodsky instead of n-types and index by natural numbers instead\n-- of ℕ₋₂. So isContr is h-level 0, isProp is h-level 1, isSet is\n-- h-level 2, etc. For details see Cubical/Foundations/HLevels.agda\n", "meta": {"hexsha": "cb97159919fc130035d110dfc633edeb9a812887", "size": 12851, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "04-cubical-type-theory/material/Part1.agda", "max_stars_repo_name": "tomdjong/EPIT-2020", "max_stars_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "04-cubical-type-theory/material/Part1.agda", "max_issues_repo_name": "tomdjong/EPIT-2020", "max_issues_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "04-cubical-type-theory/material/Part1.agda", "max_forks_repo_name": "tomdjong/EPIT-2020", "max_forks_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.9971988796, "max_line_length": 92, "alphanum_fraction": 0.6257100615, "num_tokens": 3899, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434873426303, "lm_q2_score": 0.8104789018037399, "lm_q1q2_score": 0.6255628619858239}} {"text": "module Structure.Operator.Vector.Proofs where\n\nopen import Data.Tuple\nopen import Functional\nopen import Function.Equals\nimport Lvl\nopen import Logic\nopen import Logic.Propositional\nopen import Logic.Predicate\nopen import Structure.Setoid\nopen import Structure.Operator\nopen import Structure.Operator.Field\nopen import Structure.Operator.Group\nopen import Structure.Operator.Monoid\nimport Structure.Operator.Names as Names\nopen import Structure.Operator.Proofs\nopen import Structure.Operator.Properties\nopen import Structure.Operator.Vector\nopen import Structure.Relator.Properties\nopen import Syntax.Transitivity\nopen import Type\n\nmodule _\n {ℓᵥ ℓₛ ℓᵥₑ ℓₛₑ : Lvl.Level}\n {V : Type{ℓᵥ}}\n ⦃ equiv-V : Equiv{ℓᵥₑ}(V) ⦄\n {S : Type{ℓₛ}}\n ⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄\n {_+ᵥ_ : V → V → V}\n {_⋅ₛᵥ_ : S → V → V}\n {_+ₛ_ _⋅ₛ_ : S → S → S}\n where\n\n module _ ⦃ vectorSpace : VectorSpace(_+ᵥ_)(_⋅ₛᵥ_)(_+ₛ_)(_⋅ₛ_) ⦄ where\n open VectorSpace(vectorSpace)\n\n [⋅ₛᵥ]-absorberₗ : ∀{v} → (𝟎ₛ ⋅ₛᵥ v ≡ 𝟎ᵥ)\n [⋅ₛᵥ]-absorberₗ {v} = cancellationᵣ(_+ᵥ_) ⦃ One.cancellationᵣ-by-associativity-inverse ⦄ $\n (𝟎ₛ ⋅ₛᵥ v) +ᵥ (𝟎ₛ ⋅ₛᵥ v) 🝖-[ [⋅ₛᵥ][+ₛ][+ᵥ]-distributivityᵣ ]-sym\n (𝟎ₛ +ₛ 𝟎ₛ) ⋅ₛᵥ v 🝖-[ congruence₂ₗ(_⋅ₛᵥ_)(v) (identityₗ(_+ₛ_)(𝟎ₛ)) ]\n 𝟎ₛ ⋅ₛᵥ v 🝖-[ identityₗ(_+ᵥ_)(𝟎ᵥ) ]-sym\n 𝟎ᵥ +ᵥ (𝟎ₛ ⋅ₛᵥ v) 🝖-end\n\n [⋅ₛᵥ]-absorberᵣ : ∀{s} → (s ⋅ₛᵥ 𝟎ᵥ ≡ 𝟎ᵥ)\n [⋅ₛᵥ]-absorberᵣ {s} = cancellationᵣ(_+ᵥ_) ⦃ One.cancellationᵣ-by-associativity-inverse ⦄ $\n (s ⋅ₛᵥ 𝟎ᵥ) +ᵥ (s ⋅ₛᵥ 𝟎ᵥ) 🝖-[ distributivityₗ(_⋅ₛᵥ_)(_+ᵥ_) ]-sym\n s ⋅ₛᵥ (𝟎ᵥ +ᵥ 𝟎ᵥ) 🝖-[ congruence₂ᵣ(_⋅ₛᵥ_)(s) (identityₗ(_+ᵥ_)(𝟎ᵥ)) ]\n s ⋅ₛᵥ 𝟎ᵥ 🝖-[ identityₗ(_+ᵥ_)(𝟎ᵥ) ]-sym\n 𝟎ᵥ +ᵥ (s ⋅ₛᵥ 𝟎ᵥ) 🝖-end\n\n [⋅ₛᵥ]-negation : ∀{v} → ((−ₛ 𝟏ₛ) ⋅ₛᵥ v ≡ −ᵥ v)\n [⋅ₛᵥ]-negation {v} = _⊜_.proof (One.unique-inverseFunctionᵣ-by-id (intro p) [+ᵥ]-inverseᵣ) {v} where\n p : Names.InverseFunctionᵣ(_+ᵥ_) 𝟎ᵥ ((−ₛ 𝟏ₛ) ⋅ₛᵥ_)\n p{v} =\n v +ᵥ ((−ₛ 𝟏ₛ) ⋅ₛᵥ v) 🝖-[ congruence₂ₗ(_+ᵥ_) _ (identityₗ(_⋅ₛᵥ_)(𝟏ₛ)) ]-sym\n (𝟏ₛ ⋅ₛᵥ v) +ᵥ ((−ₛ 𝟏ₛ) ⋅ₛᵥ v) 🝖-[ [⋅ₛᵥ][+ₛ][+ᵥ]-distributivityᵣ ]-sym\n (𝟏ₛ +ₛ (−ₛ 𝟏ₛ))⋅ₛᵥ v 🝖-[ congruence₂ₗ(_⋅ₛᵥ_) v (inverseFunctionᵣ(_+ₛ_) ⦃ [∃]-intro _ ⦃ [+ₛ]-identityᵣ ⦄ ⦄ (−ₛ_)) ]\n 𝟎ₛ ⋅ₛᵥ v 🝖-[ [⋅ₛᵥ]-absorberₗ ]\n 𝟎ᵥ 🝖-end\n", "meta": {"hexsha": "9223da403506565149a14e1112ea3af66e739fd9", "size": 2375, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Operator/Vector/Proofs.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Operator/Vector/Proofs.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Operator/Vector/Proofs.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.5833333333, "max_line_length": 131, "alphanum_fraction": 0.5802105263, "num_tokens": 1399, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8902942319436397, "lm_q2_score": 0.7025300573952052, "lm_q1q2_score": 0.6254584578659853}} {"text": "{-\n Definition of various kinds of categories.\n\n This library follows the UniMath terminology, that is:\n\n Concept Ob C Hom C Univalence\n\n Precategory Type Type No\n Category Type Set No\n Univalent Category Type Set Yes\n\n This file also contains\n - pathToIso : Turns a path between two objects into an isomorphism between them\n - opposite categories\n\n\n-}\n\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\n\nmodule Cubical.Categories.Category where\n\nopen import Cubical.Core.Glue\nopen import Cubical.Foundations.Prelude\n\n-- Precategories\n\nrecord Precategory ℓ ℓ' : Type (ℓ-suc (ℓ-max ℓ ℓ')) where\n no-eta-equality\n field\n ob : Type ℓ\n hom : ob → ob → Type ℓ'\n idn : ∀ x → hom x x\n seq : ∀ {x y z} (f : hom x y) (g : hom y z) → hom x z\n seq-λ : ∀ {x y : ob} (f : hom x y) → seq (idn x) f ≡ f\n seq-ρ : ∀ {x y} (f : hom x y) → seq f (idn y) ≡ f\n seq-α : ∀ {u v w x} (f : hom u v) (g : hom v w) (h : hom w x) → seq (seq f g) h ≡ seq f (seq g h)\n\nopen Precategory public\n\n-- Categories\n\nrecord isCategory {ℓ ℓ'} (𝒞 : Precategory ℓ ℓ') : Type (ℓ-max ℓ ℓ') where\n field\n homIsSet : ∀ {x y} → isSet (𝒞 .hom x y)\n\nopen isCategory public\n\n-- Isomorphisms and paths in precategories\n\nrecord CatIso {ℓ ℓ' : Level} {𝒞 : Precategory ℓ ℓ'} (x y : 𝒞 .ob) : Type ℓ' where\n constructor catiso\n field\n h : 𝒞 .hom x y\n h⁻¹ : 𝒞 .hom y x\n sec : 𝒞 .seq h⁻¹ h ≡ 𝒞 .idn y\n ret : 𝒞 .seq h h⁻¹ ≡ 𝒞 .idn x\n\npathToIso : {ℓ ℓ' : Level} {𝒞 : Precategory ℓ ℓ'} (x y : 𝒞 .ob) (p : x ≡ y) → CatIso {𝒞 = 𝒞} x y\npathToIso {𝒞 = 𝒞} x y p = J (λ z _ → CatIso x z) (catiso (𝒞 .idn x) idx (𝒞 .seq-λ idx) (𝒞 .seq-λ idx)) p\n where\n idx = 𝒞 .idn x\n\n-- Univalent Categories\n\nrecord isUnivalent {ℓ ℓ'} (𝒞 : Precategory ℓ ℓ') : Type (ℓ-max ℓ ℓ') where\n field\n univ : (x y : 𝒞 .ob) → isEquiv (pathToIso {𝒞 = 𝒞} x y)\n\nopen isUnivalent public\n\n-- Opposite Categories\n\n_^op : ∀ {ℓ ℓ'} → Precategory ℓ ℓ' → Precategory ℓ ℓ'\n(𝒞 ^op) .ob = 𝒞 .ob\n(𝒞 ^op) .hom x y = 𝒞 .hom y x\n(𝒞 ^op) .idn = 𝒞 .idn\n(𝒞 ^op) .seq f g = 𝒞 .seq g f\n(𝒞 ^op) .seq-λ = 𝒞 .seq-ρ\n(𝒞 ^op) .seq-ρ = 𝒞 .seq-λ\n(𝒞 ^op) .seq-α f g h = sym (𝒞 .seq-α _ _ _)\n", "meta": {"hexsha": "ae3727b3a91da96c51f4ca451d19ef0e8d329e10", "size": 2184, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Category.agda", "max_stars_repo_name": "ayberkt/cubical", "max_stars_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Categories/Category.agda", "max_issues_repo_name": "ayberkt/cubical", "max_issues_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/Categories/Category.agda", "max_forks_repo_name": "ayberkt/cubical", "max_forks_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "avg_line_length": 26.313253012, "max_line_length": 104, "alphanum_fraction": 0.5773809524, "num_tokens": 940, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8902942348544447, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.6254584543660396}} {"text": "module Data.Num.Bounded where\n\nopen import Data.Num.Core\nopen import Data.Num.Maximum\n\nopen import Data.Nat\nopen import Data.Nat.Properties\nopen import Data.Nat.Properties.Simple\nopen import Data.Nat.Properties.Extra\n\nopen import Data.Fin as Fin\n using (Fin; fromℕ≤; inject≤)\n renaming (zero to z; suc to s)\n\nopen import Data.Fin.Properties using (toℕ-fromℕ≤; bounded)\nopen import Data.Product\n\nopen import Function\nopen import Relation.Nullary.Decidable\nopen import Relation.Nullary\nopen import Relation.Nullary.Negation\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality\n\nopen ≡-Reasoning\nopen ≤-Reasoning renaming (begin_ to start_; _∎ to _□; _≡⟨_⟩_ to _≈⟨_⟩_)\nopen DecTotalOrder decTotalOrder using (reflexive) renaming (refl to ≤-refl)\n\n------------------------------------------------------------------------\n-- a system is bounded if there exists the greatest number\nBounded : ∀ b d o → Set\nBounded b d o = Σ[ xs ∈ Numeral b d o ] Maximum xs\n\nBounded-NullBase : ∀ d o → Bounded 0 (suc d) o\nBounded-NullBase d o = (greatest-digit d ∙) , (Maximum-NullBase-Greatest (greatest-digit d ∙) (greatest-digit-is-the-Greatest d))\n\nBounded-NoDigits : ∀ b o → ¬ (Bounded b 0 o)\nBounded-NoDigits b o (xs , claim) = NoDigits-explode xs\n\nBounded-AllZeros : ∀ b → Bounded (suc b) 1 0\nBounded-AllZeros b = (z ∙) , Maximum-AllZeros (z ∙)\n\nBounded-Proper : ∀ b d o → 2 ≤ suc (d + o) → ¬ (Bounded (suc b) (suc d) o)\nBounded-Proper b d o proper (xs , claim) =\n contradiction claim (Maximum-Proper xs proper)\n\nBounded? : ∀ b d o → Dec (Bounded b d o)\nBounded? b d o with numView b d o\nBounded? _ _ _ | NullBase d o\n = yes (Bounded-NullBase d o)\nBounded? _ _ _ | NoDigits b o\n = no (Bounded-NoDigits b o)\nBounded? _ _ _ | AllZeros b\n = yes (Bounded-AllZeros b)\nBounded? _ _ _ | Proper b d o proper\n = no (Bounded-Proper b d o proper)\n\n\n--------------------------------------------------------------------------------\n-- Misc\n\nMaximum⇒Bounded : ∀ {b d o}\n → (xs : Numeral b d o)\n → Maximum xs\n → Bounded b d o\nMaximum⇒Bounded xs max = xs , max\n\n-- contraposition of Maximum⇒Bounded\n¬Bounded⇒¬Maximum : ∀ {b d o}\n → (xs : Numeral b d o)\n → ¬ (Bounded b d o)\n → ¬ (Maximum xs)\n¬Bounded⇒¬Maximum xs = contraposition (Maximum⇒Bounded xs)\n\n-- begin\n-- {! !}\n-- ≡⟨ {! !} ⟩\n-- {! !}\n-- ≡⟨ {! !} ⟩\n-- {! !}\n-- ≡⟨ {! !} ⟩\n-- {! !}\n-- ≡⟨ {! !} ⟩\n-- {! !}\n-- ∎\n\n-- start\n-- {! !}\n-- ≤⟨ {! !} ⟩\n-- {! !}\n-- ≤⟨ {! !} ⟩\n-- {! !}\n-- ≤⟨ {! !} ⟩\n-- {! !}\n-- □\n", "meta": {"hexsha": "debc6b11db7b9d0f13b4c75458a147bc3dd4f6df", "size": 2560, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Num/Bounded.agda", "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_issues_repo_path": "Data/Num/Bounded.agda", "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Num/Bounded.agda", "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "avg_line_length": 26.6666666667, "max_line_length": 129, "alphanum_fraction": 0.580078125, "num_tokens": 872, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519528057272543, "lm_q2_score": 0.7341195269001831, "lm_q1q2_score": 0.6254351906817756}} {"text": "{-# OPTIONS --universe-polymorphism #-}\n\nopen import Categories.Category\n\nmodule Categories.Object.Products.Properties {o ℓ e} \n (C : Category o ℓ e) where\n\nopen Category C\n\nopen import Level\n\nimport Categories.Object.Terminal\nopen Categories.Object.Terminal C\n\nimport Categories.Object.BinaryProducts\nopen Categories.Object.BinaryProducts C\n\nimport Categories.Object.Products\nopen Categories.Object.Products C\n\nimport Categories.Morphisms\nopen Categories.Morphisms C\n\nmodule Properties (P : Products) where\n open Products P\n \n open Terminal terminal\n open BinaryProducts binary\n open HomReasoning\n open Equiv\n \n unitˡ : ∀ {X} → (⊤ × X) ≅ X\n unitˡ {X} = record\n { f = π₂\n ; g = ⟨ ! , id {X} ⟩\n ; iso = record\n { isoˡ = \n begin\n ⟨ ! , id {X} ⟩ ∘ π₂\n ↓⟨ ⟨⟩∘ ⟩\n ⟨ ! ∘ π₂ , id ∘ π₂ ⟩\n ↓⟨ ⟨⟩-cong₂ (!-unique₂ (! ∘ π₂) π₁) (identityˡ) ⟩\n ⟨ π₁ , π₂ ⟩\n ↓⟨ η ⟩\n id\n ∎\n ; isoʳ = commute₂\n }\n }\n \n .unitˡ-natural : ∀ {X Y} {f : X ⇒ Y} → ⟨ ! , id {Y} ⟩ ∘ f ≡ second f ∘ ⟨ ! , id {X} ⟩\n unitˡ-natural {f = f} = \n begin\n ⟨ ! , id ⟩ ∘ f\n ↓⟨ ⟨⟩∘ ⟩\n ⟨ ! ∘ f , id ∘ f ⟩\n ↑⟨ ⟨⟩-cong₂ (!-unique (! ∘ f)) (id-comm {f = f}) ⟩\n ⟨ ! , f ∘ id ⟩\n ↑⟨ second∘⟨⟩ ⟩\n second f ∘ ⟨ ! , id ⟩\n ∎ \n \n unitʳ : ∀ {X} → (X × ⊤) ≅ X\n unitʳ {X} = record\n { f = π₁\n ; g = ⟨ id {X} , ! ⟩\n ; iso = record\n { isoˡ = \n begin\n ⟨ id {X} , ! ⟩ ∘ π₁\n ↓⟨ ⟨⟩∘ ⟩\n ⟨ id ∘ π₁ , ! ∘ π₁ ⟩\n ↓⟨ ⟨⟩-cong₂ (identityˡ) (!-unique₂ (! ∘ π₁) π₂) ⟩\n ⟨ π₁ , π₂ ⟩\n ↓⟨ η ⟩\n id\n ∎\n ; isoʳ = commute₁\n }\n }\n \n .unitʳ-natural : ∀ {X Y} {f : X ⇒ Y} → ⟨ id , ! ⟩ ∘ f ≡ first f ∘ ⟨ id , ! ⟩\n unitʳ-natural {f = f} =\n begin\n ⟨ id , ! ⟩ ∘ f\n ↓⟨ ⟨⟩∘ ⟩\n ⟨ id ∘ f , ! ∘ f ⟩\n ↑⟨ ⟨⟩-cong₂ (id-comm {f = f}) (!-unique (! ∘ f)) ⟩\n ⟨ f ∘ id , ! ⟩\n ↑⟨ first∘⟨⟩ ⟩\n first f ∘ ⟨ id , ! ⟩\n ∎\n", "meta": {"hexsha": "39715b7dc66fea0d5c2af1fc96e7b58c7e16ca2c", "size": 1989, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Object/Products/Properties.agda", "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 98, "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_issues_repo_path": "Categories/Object/Products/Properties.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_forks_repo_path": "Categories/Object/Products/Properties.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 23, "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "avg_line_length": 21.3870967742, "max_line_length": 87, "alphanum_fraction": 0.4414278532, "num_tokens": 827, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.851952809486198, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.6254351884854313}} {"text": "------------------------------------------------------------------------\n-- Simple regular expression matcher (without soundness proof)\n------------------------------------------------------------------------\n\nopen import Eq\nopen import Setoids\nopen import Prelude\nimport RegExps\n\nmodule BoolMatcher (D : Datoid) where\n\nprivate\n open module D' = Datoid D\n open module S' = Setoid setoid\n open module R = RegExps setoid\n\ninfix 4 _∈‿⟦_⟧¿\n\n------------------------------------------------------------------------\n-- Helper function\n\ndecToBool : forall {x y} -> Dec (x ≈ y) -> Bool\ndecToBool (yes _) = true\ndecToBool (no _) = false\n\n------------------------------------------------------------------------\n-- Regular expression matcher\n\nmatches-⊙¿ : (xs₁ xs₂ : [ carrier ]) -> (re₁ re₂ : RegExp) -> Bool\n\n_∈‿⟦_⟧¿ : (xs : [ carrier ]) -> (re : RegExp) -> Bool\n[] ∈‿⟦ ε ⟧¿ = true\nx ∷ [] ∈‿⟦ • ⟧¿ = true\nx ∷ [] ∈‿⟦ sym y ⟧¿ = decToBool (x ≟ y)\nxs ∈‿⟦ re₁ ∣ re₂ ⟧¿ = xs ∈‿⟦ re₁ ⟧¿ ∨ xs ∈‿⟦ re₂ ⟧¿\nxs ∈‿⟦ re₁ ⊙ re₂ ⟧¿ = matches-⊙¿ [] xs re₁ re₂\n[] ∈‿⟦ re ⋆ ⟧¿ = true\nx ∷ xs ∈‿⟦ re ⋆ ⟧¿ = matches-⊙¿ (x ∷ []) xs re (re ⋆)\n_ ∈‿⟦ _ ⟧¿ = false\n\n\nmatches-⊙¿ xs₁ xs₂ re₁ re₂ with xs₁ ∈‿⟦ re₁ ⟧¿ ∨ xs₂ ∈‿⟦ re₂ ⟧¿\nmatches-⊙¿ xs₁ xs₂ re₁ re₂ | true = true\nmatches-⊙¿ xs₁ [] re₁ re₂ | false = false\nmatches-⊙¿ xs₁ (x ∷ xs₂) re₁ re₂ | false =\n matches-⊙¿ (xs₁ ++ x ∷ []) xs₂ re₁ re₂\n", "meta": {"hexsha": "6bfdf3e1c0164c5b75fe3415ae89dcfd66291b27", "size": 1448, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/AIM6/RegExp/talk/BoolMatcher.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/AIM6/RegExp/talk/BoolMatcher.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/AIM6/RegExp/talk/BoolMatcher.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 30.8085106383, "max_line_length": 72, "alphanum_fraction": 0.4198895028, "num_tokens": 528, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8740772351648677, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.6253358335085095}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Some algebraic structures (not packed up with sets, operations,\n-- etc.)\n------------------------------------------------------------------------\n\n-- The contents of this module should be accessed via `Algebra`, unless\n-- you want to parameterise it via the equality relation.\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary using (Rel; Setoid; IsEquivalence)\n\nmodule Algebra.Structures\n {a ℓ} {A : Set a} -- The underlying set\n (_≈_ : Rel A ℓ) -- The underlying equality relation\n where\n\n-- The file is divided into sections depending on the arities of the\n-- components of the algebraic structure.\n\nopen import Algebra.Core\nopen import Algebra.Definitions _≈_\nimport Algebra.Consequences.Setoid as Consequences\nopen import Data.Product using (_,_; proj₁; proj₂)\nopen import Level using (_⊔_)\n\n------------------------------------------------------------------------\n-- Structures with 1 binary operation\n------------------------------------------------------------------------\n\nrecord IsMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) where\n field\n isEquivalence : IsEquivalence _≈_\n ∙-cong : Congruent₂ ∙\n\n open IsEquivalence isEquivalence public\n\n setoid : Setoid a ℓ\n setoid = record { isEquivalence = isEquivalence }\n\n ∙-congˡ : LeftCongruent ∙\n ∙-congˡ y≈z = ∙-cong refl y≈z\n\n ∙-congʳ : RightCongruent ∙\n ∙-congʳ y≈z = ∙-cong y≈z refl\n\n\nrecord IsSemigroup (∙ : Op₂ A) : Set (a ⊔ ℓ) where\n field\n isMagma : IsMagma ∙\n assoc : Associative ∙\n\n open IsMagma isMagma public\n\n\nrecord IsBand (∙ : Op₂ A) : Set (a ⊔ ℓ) where\n field\n isSemigroup : IsSemigroup ∙\n idem : Idempotent ∙\n\n open IsSemigroup isSemigroup public\n\n\nrecord IsCommutativeSemigroup (∙ : Op₂ A) : Set (a ⊔ ℓ) where\n field\n isSemigroup : IsSemigroup ∙\n comm : Commutative ∙\n\n open IsSemigroup isSemigroup public\n\n\nrecord IsSemilattice (∧ : Op₂ A) : Set (a ⊔ ℓ) where\n field\n isBand : IsBand ∧\n comm : Commutative ∧\n\n open IsBand isBand public\n renaming (∙-cong to ∧-cong; ∙-congˡ to ∧-congˡ; ∙-congʳ to ∧-congʳ)\n\n\nrecord IsSelectiveMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) where\n field\n isMagma : IsMagma ∙\n sel : Selective ∙\n\n open IsMagma isMagma public\n\n\n------------------------------------------------------------------------\n-- Structures with 1 binary operation & 1 element\n------------------------------------------------------------------------\n\nrecord IsMonoid (∙ : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where\n field\n isSemigroup : IsSemigroup ∙\n identity : Identity ε ∙\n\n open IsSemigroup isSemigroup public\n\n identityˡ : LeftIdentity ε ∙\n identityˡ = proj₁ identity\n\n identityʳ : RightIdentity ε ∙\n identityʳ = proj₂ identity\n\n\nrecord IsCommutativeMonoid (∙ : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where\n field\n isMonoid : IsMonoid ∙ ε\n comm : Commutative ∙\n\n open IsMonoid isMonoid public\n\n isCommutativeSemigroup : IsCommutativeSemigroup ∙\n isCommutativeSemigroup = record\n { isSemigroup = isSemigroup\n ; comm = comm\n }\n\n\nrecord IsIdempotentCommutativeMonoid (∙ : Op₂ A)\n (ε : A) : Set (a ⊔ ℓ) where\n field\n isCommutativeMonoid : IsCommutativeMonoid ∙ ε\n idem : Idempotent ∙\n\n open IsCommutativeMonoid isCommutativeMonoid public\n\n\n-- Idempotent commutative monoids are also known as bounded lattices.\n-- Note that the BoundedLattice necessarily uses the notation inherited\n-- from monoids rather than lattices.\n\nIsBoundedLattice = IsIdempotentCommutativeMonoid\n\nmodule IsBoundedLattice {∙ : Op₂ A}\n {ε : A}\n (isIdemCommMonoid : IsIdempotentCommutativeMonoid ∙ ε) =\n IsIdempotentCommutativeMonoid isIdemCommMonoid\n\n\n------------------------------------------------------------------------\n-- Structures with 1 binary operation, 1 unary operation & 1 element\n------------------------------------------------------------------------\n\nrecord IsGroup (_∙_ : Op₂ A) (ε : A) (_⁻¹ : Op₁ A) : Set (a ⊔ ℓ) where\n field\n isMonoid : IsMonoid _∙_ ε\n inverse : Inverse ε _⁻¹ _∙_\n ⁻¹-cong : Congruent₁ _⁻¹\n\n open IsMonoid isMonoid public\n\n infixl 6 _-_\n _-_ : Op₂ A\n x - y = x ∙ (y ⁻¹)\n\n inverseˡ : LeftInverse ε _⁻¹ _∙_\n inverseˡ = proj₁ inverse\n\n inverseʳ : RightInverse ε _⁻¹ _∙_\n inverseʳ = proj₂ inverse\n\n uniqueˡ-⁻¹ : ∀ x y → (x ∙ y) ≈ ε → x ≈ (y ⁻¹)\n uniqueˡ-⁻¹ = Consequences.assoc+id+invʳ⇒invˡ-unique\n setoid ∙-cong assoc identity inverseʳ\n\n uniqueʳ-⁻¹ : ∀ x y → (x ∙ y) ≈ ε → y ≈ (x ⁻¹)\n uniqueʳ-⁻¹ = Consequences.assoc+id+invˡ⇒invʳ-unique\n setoid ∙-cong assoc identity inverseˡ\n\n\nrecord IsAbelianGroup (∙ : Op₂ A)\n (ε : A) (⁻¹ : Op₁ A) : Set (a ⊔ ℓ) where\n field\n isGroup : IsGroup ∙ ε ⁻¹\n comm : Commutative ∙\n\n open IsGroup isGroup public\n\n isCommutativeMonoid : IsCommutativeMonoid ∙ ε\n isCommutativeMonoid = record\n { isMonoid = isMonoid\n ; comm = comm\n }\n\n open IsCommutativeMonoid isCommutativeMonoid public\n using (isCommutativeSemigroup)\n\n\n------------------------------------------------------------------------\n-- Structures with 2 binary operations\n------------------------------------------------------------------------\n\n-- Note that `IsLattice` is not defined in terms of `IsSemilattice`\n-- because the idempotence laws of ∨ and ∧ can be derived from the\n-- absorption laws, which makes the corresponding \"idem\" fields\n-- redundant. The derived idempotence laws are stated and proved in\n-- `Algebra.Properties.Lattice` along with the fact that every lattice\n-- consists of two semilattices.\n\nrecord IsLattice (∨ ∧ : Op₂ A) : Set (a ⊔ ℓ) where\n field\n isEquivalence : IsEquivalence _≈_\n ∨-comm : Commutative ∨\n ∨-assoc : Associative ∨\n ∨-cong : Congruent₂ ∨\n ∧-comm : Commutative ∧\n ∧-assoc : Associative ∧\n ∧-cong : Congruent₂ ∧\n absorptive : Absorptive ∨ ∧\n\n open IsEquivalence isEquivalence public\n\n ∨-absorbs-∧ : ∨ Absorbs ∧\n ∨-absorbs-∧ = proj₁ absorptive\n\n ∧-absorbs-∨ : ∧ Absorbs ∨\n ∧-absorbs-∨ = proj₂ absorptive\n\n ∧-congˡ : LeftCongruent ∧\n ∧-congˡ y≈z = ∧-cong refl y≈z\n\n ∧-congʳ : RightCongruent ∧\n ∧-congʳ y≈z = ∧-cong y≈z refl\n\n ∨-congˡ : LeftCongruent ∨\n ∨-congˡ y≈z = ∨-cong refl y≈z\n\n ∨-congʳ : RightCongruent ∨\n ∨-congʳ y≈z = ∨-cong y≈z refl\n\n\nrecord IsDistributiveLattice (∨ ∧ : Op₂ A) : Set (a ⊔ ℓ) where\n field\n isLattice : IsLattice ∨ ∧\n ∨-distribʳ-∧ : ∨ DistributesOverʳ ∧\n\n open IsLattice isLattice public\n\n ∨-∧-distribʳ = ∨-distribʳ-∧\n {-# WARNING_ON_USAGE ∨-∧-distribʳ\n \"Warning: ∨-∧-distribʳ was deprecated in v1.1.\n Please use ∨-distribʳ-∧ instead.\"\n #-}\n\n------------------------------------------------------------------------\n-- Structures with 2 binary operations & 1 element\n------------------------------------------------------------------------\n\nrecord IsNearSemiring (+ * : Op₂ A) (0# : A) : Set (a ⊔ ℓ) where\n field\n +-isMonoid : IsMonoid + 0#\n *-isSemigroup : IsSemigroup *\n distribʳ : * DistributesOverʳ +\n zeroˡ : LeftZero 0# *\n\n open IsMonoid +-isMonoid public\n renaming\n ( assoc to +-assoc\n ; ∙-cong to +-cong\n ; ∙-congˡ to +-congˡ\n ; ∙-congʳ to +-congʳ\n ; identity to +-identity\n ; identityˡ to +-identityˡ\n ; identityʳ to +-identityʳ\n ; isMagma to +-isMagma\n ; isSemigroup to +-isSemigroup\n )\n\n open IsSemigroup *-isSemigroup public\n using ()\n renaming\n ( assoc to *-assoc\n ; ∙-cong to *-cong\n ; ∙-congˡ to *-congˡ\n ; ∙-congʳ to *-congʳ\n ; isMagma to *-isMagma\n )\n\n\nrecord IsSemiringWithoutOne (+ * : Op₂ A) (0# : A) : Set (a ⊔ ℓ) where\n field\n +-isCommutativeMonoid : IsCommutativeMonoid + 0#\n *-isSemigroup : IsSemigroup *\n distrib : * DistributesOver +\n zero : Zero 0# *\n\n open IsCommutativeMonoid +-isCommutativeMonoid public\n using ()\n renaming\n ( comm to +-comm\n ; isMonoid to +-isMonoid\n ; isCommutativeSemigroup to +-isCommutativeSemigroup\n )\n\n zeroˡ : LeftZero 0# *\n zeroˡ = proj₁ zero\n\n zeroʳ : RightZero 0# *\n zeroʳ = proj₂ zero\n\n isNearSemiring : IsNearSemiring + * 0#\n isNearSemiring = record\n { +-isMonoid = +-isMonoid\n ; *-isSemigroup = *-isSemigroup\n ; distribʳ = proj₂ distrib\n ; zeroˡ = zeroˡ\n }\n\n open IsNearSemiring isNearSemiring public\n hiding (+-isMonoid; zeroˡ)\n\n\nrecord IsCommutativeSemiringWithoutOne\n (+ * : Op₂ A) (0# : A) : Set (a ⊔ ℓ) where\n field\n isSemiringWithoutOne : IsSemiringWithoutOne + * 0#\n *-comm : Commutative *\n\n open IsSemiringWithoutOne isSemiringWithoutOne public\n\n\n------------------------------------------------------------------------\n-- Structures with 2 binary operations & 2 elements\n------------------------------------------------------------------------\n\nrecord IsSemiringWithoutAnnihilatingZero (+ * : Op₂ A)\n (0# 1# : A) : Set (a ⊔ ℓ) where\n field\n -- Note that these structures do have an additive unit, but this\n -- unit does not necessarily annihilate multiplication.\n +-isCommutativeMonoid : IsCommutativeMonoid + 0#\n *-isMonoid : IsMonoid * 1#\n distrib : * DistributesOver +\n\n distribˡ : * DistributesOverˡ +\n distribˡ = proj₁ distrib\n\n distribʳ : * DistributesOverʳ +\n distribʳ = proj₂ distrib\n\n open IsCommutativeMonoid +-isCommutativeMonoid public\n renaming\n ( assoc to +-assoc\n ; ∙-cong to +-cong\n ; ∙-congˡ to +-congˡ\n ; ∙-congʳ to +-congʳ\n ; identity to +-identity\n ; identityˡ to +-identityˡ\n ; identityʳ to +-identityʳ\n ; comm to +-comm\n ; isMagma to +-isMagma\n ; isSemigroup to +-isSemigroup\n ; isMonoid to +-isMonoid\n ; isCommutativeSemigroup to +-isCommutativeSemigroup\n )\n\n open IsMonoid *-isMonoid public\n using ()\n renaming\n ( assoc to *-assoc\n ; ∙-cong to *-cong\n ; ∙-congˡ to *-congˡ\n ; ∙-congʳ to *-congʳ\n ; identity to *-identity\n ; identityˡ to *-identityˡ\n ; identityʳ to *-identityʳ\n ; isMagma to *-isMagma\n ; isSemigroup to *-isSemigroup\n )\n\n\nrecord IsSemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ) where\n field\n isSemiringWithoutAnnihilatingZero :\n IsSemiringWithoutAnnihilatingZero + * 0# 1#\n zero : Zero 0# *\n\n open IsSemiringWithoutAnnihilatingZero\n isSemiringWithoutAnnihilatingZero public\n\n isSemiringWithoutOne : IsSemiringWithoutOne + * 0#\n isSemiringWithoutOne = record\n { +-isCommutativeMonoid = +-isCommutativeMonoid\n ; *-isSemigroup = *-isSemigroup\n ; distrib = distrib\n ; zero = zero\n }\n\n open IsSemiringWithoutOne isSemiringWithoutOne public\n using\n ( isNearSemiring\n ; zeroˡ\n ; zeroʳ\n )\n\n\nrecord IsCommutativeSemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ) where\n field\n isSemiring : IsSemiring + * 0# 1#\n *-comm : Commutative *\n\n open IsSemiring isSemiring public\n\n isCommutativeSemiringWithoutOne :\n IsCommutativeSemiringWithoutOne + * 0#\n isCommutativeSemiringWithoutOne = record\n { isSemiringWithoutOne = isSemiringWithoutOne\n ; *-comm = *-comm\n }\n\n *-isCommutativeSemigroup : IsCommutativeSemigroup *\n *-isCommutativeSemigroup = record\n { isSemigroup = *-isSemigroup\n ; comm = *-comm\n }\n\n *-isCommutativeMonoid : IsCommutativeMonoid * 1#\n *-isCommutativeMonoid = record\n { isMonoid = *-isMonoid\n ; comm = *-comm\n }\n\n\n------------------------------------------------------------------------\n-- Structures with 2 binary operations, 1 unary operation & 2 elements\n------------------------------------------------------------------------\n\nrecord IsRing (+ * : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Set (a ⊔ ℓ) where\n field\n +-isAbelianGroup : IsAbelianGroup + 0# -_\n *-isMonoid : IsMonoid * 1#\n distrib : * DistributesOver +\n zero : Zero 0# *\n\n open IsAbelianGroup +-isAbelianGroup public\n renaming\n ( assoc to +-assoc\n ; ∙-cong to +-cong\n ; ∙-congˡ to +-congˡ\n ; ∙-congʳ to +-congʳ\n ; identity to +-identity\n ; identityˡ to +-identityˡ\n ; identityʳ to +-identityʳ\n ; inverse to -‿inverse\n ; inverseˡ to -‿inverseˡ\n ; inverseʳ to -‿inverseʳ\n ; ⁻¹-cong to -‿cong\n ; comm to +-comm\n ; isMagma to +-isMagma\n ; isSemigroup to +-isSemigroup\n ; isMonoid to +-isMonoid\n ; isCommutativeMonoid to +-isCommutativeMonoid\n ; isCommutativeSemigroup to +-isCommutativeSemigroup\n ; isGroup to +-isGroup\n )\n\n open IsMonoid *-isMonoid public\n using ()\n renaming\n ( assoc to *-assoc\n ; ∙-cong to *-cong\n ; ∙-congˡ to *-congˡ\n ; ∙-congʳ to *-congʳ\n ; identity to *-identity\n ; identityˡ to *-identityˡ\n ; identityʳ to *-identityʳ\n ; isMagma to *-isMagma\n ; isSemigroup to *-isSemigroup\n )\n\n zeroˡ : LeftZero 0# *\n zeroˡ = proj₁ zero\n\n zeroʳ : RightZero 0# *\n zeroʳ = proj₂ zero\n\n isSemiringWithoutAnnihilatingZero\n : IsSemiringWithoutAnnihilatingZero + * 0# 1#\n isSemiringWithoutAnnihilatingZero = record\n { +-isCommutativeMonoid = +-isCommutativeMonoid\n ; *-isMonoid = *-isMonoid\n ; distrib = distrib\n }\n\n isSemiring : IsSemiring + * 0# 1#\n isSemiring = record\n { isSemiringWithoutAnnihilatingZero =\n isSemiringWithoutAnnihilatingZero\n ; zero = zero\n }\n\n open IsSemiring isSemiring public\n using (distribˡ; distribʳ; isNearSemiring; isSemiringWithoutOne)\n\n\nrecord IsCommutativeRing\n (+ * : Op₂ A) (- : Op₁ A) (0# 1# : A) : Set (a ⊔ ℓ) where\n field\n isRing : IsRing + * - 0# 1#\n *-comm : Commutative *\n\n open IsRing isRing public\n\n *-isCommutativeMonoid : IsCommutativeMonoid * 1#\n *-isCommutativeMonoid = record\n { isMonoid = *-isMonoid\n ; comm = *-comm\n }\n\n isCommutativeSemiring : IsCommutativeSemiring + * 0# 1#\n isCommutativeSemiring = record\n { isSemiring = isSemiring\n ; *-comm = *-comm\n }\n\n open IsCommutativeSemiring isCommutativeSemiring public\n using ( isCommutativeSemiringWithoutOne )\n\n\nrecord IsBooleanAlgebra\n (∨ ∧ : Op₂ A) (¬ : Op₁ A) (⊤ ⊥ : A) : Set (a ⊔ ℓ) where\n field\n isDistributiveLattice : IsDistributiveLattice ∨ ∧\n ∨-complementʳ : RightInverse ⊤ ¬ ∨\n ∧-complementʳ : RightInverse ⊥ ¬ ∧\n ¬-cong : Congruent₁ ¬\n\n open IsDistributiveLattice isDistributiveLattice public\n", "meta": {"hexsha": "11341ab0bffb1cc5431e8933d5ddfc3cb330550e", "size": 15125, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Algebra/Structures.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Algebra/Structures.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Algebra/Structures.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 28.3771106942, "max_line_length": 80, "alphanum_fraction": 0.5615206612, "num_tokens": 4863, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772286044095, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.6253358288150003}} {"text": "{-# OPTIONS --safe --warning=error --without-K --guardedness #-}\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import Setoids.Setoids\nopen import Rings.Definition\nopen import Rings.Orders.Partial.Definition\nopen import Rings.Orders.Total.Definition\nopen import Groups.Definition\nopen import Groups.Orders.Archimedean\nopen import Fields.Fields\nopen import Sets.EquivalenceRelations\nopen import Sequences\nopen import Setoids.Orders.Partial.Definition\nopen import Functions.Definition\nopen import LogicalFormulae\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import Fields.Orders.Total.Archimedean\n\nmodule Fields.CauchyCompletion.Archimedean {m n o : _} {A : Set m} {S : Setoid {m} {n} A} {_+_ : A → A → A} {_*_ : A → A → A} {_<_ : Rel {m} {o} A} {pOrder : SetoidPartialOrder S _<_} {R : Ring S _+_ _*_} {pRing : PartiallyOrderedRing R pOrder} (order : TotallyOrderedRing pRing) (F : Field R) (arch : ArchimedeanField {F = F} (record { oRing = pRing })) where\n\nopen import Fields.CauchyCompletion.Group order F\nopen import Fields.CauchyCompletion.Ring order F\nopen import Fields.CauchyCompletion.Comparison order F\nopen import Fields.CauchyCompletion.PartiallyOrderedRing order F\n\nCArchimedean : Archimedean (toGroup CRing CpOrderedRing)\nCArchimedean x y xPos yPos = {!!}\n", "meta": {"hexsha": "d6611c91319abd0ea606ea6cf06aa2df4707d18f", "size": 1320, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Fields/CauchyCompletion/Archimedean.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Fields/CauchyCompletion/Archimedean.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Fields/CauchyCompletion/Archimedean.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 45.5172413793, "max_line_length": 360, "alphanum_fraction": 0.7742424242, "num_tokens": 371, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772351648678, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.625335822901531}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.HITs.ListedFiniteSet.Properties where\n\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.HITs.ListedFiniteSet.Base\n\nprivate\n variable\n A : Type₀\n\n_++_ : ∀ (xs ys : LFSet A) → LFSet A\n[] ++ ys = ys\n(x ∷ xs) ++ ys = x ∷ (xs ++ ys)\n---------------------------------------------\ndup x xs i ++ ys = proof i\n where\n proof :\n -- Need: (x ∷ x ∷ xs) ++ ys ≡ (x ∷ xs) ++ ys\n -- which reduces to:\n x ∷ x ∷ (xs ++ ys) ≡ x ∷ (xs ++ ys)\n proof = dup x (xs ++ ys)\ncomm x y xs i ++ ys = comm x y (xs ++ ys) i\ntrunc xs zs p q i j ++ ys\n = trunc (xs ++ ys) (zs ++ ys) (cong (_++ ys) p) (cong (_++ ys) q) i j\n\n\nassoc-++ : ∀ (xs : LFSet A) ys zs → xs ++ (ys ++ zs) ≡ (xs ++ ys) ++ zs\nassoc-++ [] ys zs = refl\nassoc-++ (x ∷ xs) ys zs\n = cong (x ∷_) (assoc-++ xs ys zs)\n------------------------------------\nassoc-++ (dup x xs i) ys zs j\n = dup x (assoc-++ xs ys zs j) i\nassoc-++ (comm x y xs i) ys zs j\n = comm x y (assoc-++ xs ys zs j) i\nassoc-++ (trunc xs xs' p q i k) ys zs j\n = trunc (assoc-++ xs ys zs j) (assoc-++ xs' ys zs j)\n (cong (\\ xs -> assoc-++ xs ys zs j) p) (cong (\\ xs -> assoc-++ xs ys zs j) q) i k\n", "meta": {"hexsha": "5739152ac8392426a996d4699e39e8754133cc5b", "size": 1271, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/ListedFiniteSet/Properties.agda", "max_stars_repo_name": "mchristianl/cubical", "max_stars_repo_head_hexsha": "cc6ad25d5ffbe4f20ea7020474f266d24b97caa0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/HITs/ListedFiniteSet/Properties.agda", "max_issues_repo_name": "mchristianl/cubical", "max_issues_repo_head_hexsha": "cc6ad25d5ffbe4f20ea7020474f266d24b97caa0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/HITs/ListedFiniteSet/Properties.agda", "max_forks_repo_name": "aljungstrom/cubical", "max_forks_repo_head_hexsha": "69d358f6be7842f77105634712821eda22d9c044", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.775, "max_line_length": 91, "alphanum_fraction": 0.46184107, "num_tokens": 457, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772253241802, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.6253358211647563}} {"text": "module Rationals.Multiply.Comm where\n\nopen import Equality\nopen import Rationals\nopen import Nats.Multiply.Comm\n\n------------------------------------------------------------------------\n-- internal stuffs\n\nprivate\n\n a*b=b*a : ∀ x y → x * y ≡ y * x\n a*b=b*a (a ÷ c) (b ÷ d)\n rewrite nat-multiply-comm a b\n | nat-multiply-comm c d\n = refl\n\n------------------------------------------------------------------------\n-- public aliases\n\nrational-multiply-comm : ∀ x y → x * y ≡ y * x\nrational-multiply-comm = a*b=b*a\n", "meta": {"hexsha": "e1e8ca4d2ed3b555d51509d9a342204627455cf5", "size": 535, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Rationals/Multiply/Comm.agda", "max_stars_repo_name": "ice1k/Theorems", "max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z", "max_issues_repo_path": "src/Rationals/Multiply/Comm.agda", "max_issues_repo_name": "ice1k/Theorems", "max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Rationals/Multiply/Comm.agda", "max_forks_repo_name": "ice1k/Theorems", "max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.2608695652, "max_line_length": 72, "alphanum_fraction": 0.4523364486, "num_tokens": 130, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8740772286044094, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.6253358182080216}} {"text": "\nopen import Everything\n{-\nopen import Oscar.Prelude\nopen import Oscar.Class.HasEquivalence\nopen import Oscar.Class.Symmetrical\nopen import Oscar.Data.Fin\nopen import Oscar.Data.Term\nopen import Oscar.Data.Substitunction\nopen import Oscar.Data.Proposequality\nopen import Oscar.Data.Surjcollation\nopen import Oscar.Data.Surjextenscollation\nimport Oscar.Class.HasEquivalence.ExtensionṖroperty\nimport Oscar.Class.HasEquivalence.Ṗroperty\nimport Oscar.Class.Symmetrical.ExtensionalUnifies\nimport Oscar.Class.Symmetrical.Unifies\nimport Oscar.Property.Setoid.Proposequality -- FIXME see fact1⋆ below; comment this out to observe confusing error messages\nimport Oscar.Property.Functor.SubstitunctionExtensionTerm\nimport Oscar.Class.Surjection.⋆\n-}\nmodule Test.Surjcollation {𝔭} (𝔓 : Ø 𝔭) where\n open Term 𝔓\n open Substitunction 𝔓\n\n module 𝓢 = Surjcollation Substitunction Proposequality\n module 𝓢̇ = Surjextenscollation Substitunction Proposextensequality\n\n fact1⋆ : ∀ {𝓃} (𝓈 𝓉 : Term 𝓃) → 𝓈 𝓢.⟹ 𝓉 ≈ 𝓉 𝓢.⟹ 𝓈\n fact1⋆ 𝓈 𝓉 = symmetrical 𝓈 𝓉\n -- fact1⋆ 𝓈 𝓉 = symmetrical ⦃ r = Oscar.Class.Symmetrical.Unifies.𝓢ymmetricalUnifies₀ ⦃ ! ⦄ ⦃ ! ⦄ ⦃ Oscar.Property.Setoid.Proposequality.𝓢ymmetryProposequality ⦄ ⦄ 𝓈 𝓉 -- FIXME I wish Agda would tell us that this is how the instances were resolved\n\n fact1⋆s : ∀ {N 𝓃} (𝓈 𝓉 : Terms N 𝓃) → 𝓈 𝓢.⟹ 𝓉 ≈ 𝓉 𝓢.⟹ 𝓈\n fact1⋆s 𝓈 𝓉 = symmetrical 𝓈 𝓉\n\n fact1 : ∀ {𝓃} (𝓈 𝓉 : Term 𝓃) → 𝓈 𝓢̇.⟹ 𝓉 ≈ 𝓉 𝓢̇.⟹ 𝓈\n fact1 𝓈 𝓉 = symmetrical 𝓈 𝓉\n", "meta": {"hexsha": "87202123de403913315fe9a5d637a737bc9d424f", "size": 1463, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-3/src/Test/Surjcollation.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-3/src/Test/Surjcollation.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-3/src/Test/Surjcollation.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.5405405405, "max_line_length": 249, "alphanum_fraction": 0.7573479152, "num_tokens": 585, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677468516187, "lm_q2_score": 0.7371581626286833, "lm_q1q2_score": 0.6250863462375237}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import lib.Basics\nopen import lib.types.Nat\nopen import lib.types.Group\nopen import lib.types.TLevel\n\nmodule lib.types.Int where\n\ndata ℤ : Type₀ where\n O : ℤ\n pos : (n : ℕ) → ℤ\n neg : (n : ℕ) → ℤ\n\nInt = ℤ\n\nsucc : ℤ → ℤ\nsucc O = pos O\nsucc (pos n) = pos (S n)\nsucc (neg O) = O\nsucc (neg (S n)) = neg n\n\npred : ℤ → ℤ\npred O = neg O\npred (pos O) = O\npred (pos (S n)) = pos n\npred (neg n) = neg (S n)\n\nabstract\n succ-pred : (n : ℤ) → succ (pred n) == n\n succ-pred O = idp\n succ-pred (pos O) = idp\n succ-pred (pos (S n)) = idp\n succ-pred (neg n) = idp\n\n pred-succ : (n : ℤ) → pred (succ n) == n\n pred-succ O = idp\n pred-succ (pos n) = idp\n pred-succ (neg O) = idp\n pred-succ (neg (S n)) = idp\n\nsucc-equiv : ℤ ≃ ℤ\nsucc-equiv = equiv succ pred succ-pred pred-succ\n\npred-injective : (z₁ z₂ : ℤ) → pred z₁ == pred z₂ → z₁ == z₂\npred-injective z₁ z₂ p = ! (succ-pred z₁) ∙ ap succ p ∙ succ-pred z₂\n\nsucc-injective : (z₁ z₂ : ℤ) → succ z₁ == succ z₂ → z₁ == z₂\nsucc-injective z₁ z₂ p = ! (pred-succ z₁) ∙ ap pred p ∙ pred-succ z₂\n\n{- Converting between ℤ, ℕ, and ℕ₋₂ -}\n\nℤ-to-ℕ₋₂ : ℤ → ℕ₋₂\nℤ-to-ℕ₋₂ O = ⟨0⟩\nℤ-to-ℕ₋₂ (pos m) = S ⟨ m ⟩\nℤ-to-ℕ₋₂ (neg O) = ⟨-1⟩\nℤ-to-ℕ₋₂ (neg _) = ⟨-2⟩\n\nℕ-to-ℤ : ℕ → ℤ\nℕ-to-ℤ n = pred (pos n)\n\n\n{- Proof that [ℤ] has decidable equality and hence is a set -}\n\nprivate\n ℤ-get-pos : ℤ → ℕ\n ℤ-get-pos O = 0\n ℤ-get-pos (pos n) = n\n ℤ-get-pos (neg n) = 0\n\n ℤ-get-neg : ℤ → ℕ\n ℤ-get-neg O = 0\n ℤ-get-neg (pos n) = 0\n ℤ-get-neg (neg n) = n\n\n ℤ-neg≠O≠pos-type : ℤ → Type₀\n ℤ-neg≠O≠pos-type O = Unit\n ℤ-neg≠O≠pos-type (pos n) = Empty\n ℤ-neg≠O≠pos-type (neg n) = Empty\n\n ℤ-neg≠pos-type : ℤ → Type₀\n ℤ-neg≠pos-type O = Unit\n ℤ-neg≠pos-type (pos n) = Empty\n ℤ-neg≠pos-type (neg n) = Unit\n\nabstract\n pos-injective : (n m : ℕ) (p : pos n == pos m) → n == m\n pos-injective n m p = ap ℤ-get-pos p\n\n neg-injective : (n m : ℕ) (p : neg n == neg m) → n == m\n neg-injective n m p = ap ℤ-get-neg p\n\n ℤ-O≠pos : (n : ℕ) → O ≠ pos n\n ℤ-O≠pos n p = transport ℤ-neg≠O≠pos-type p unit\n\n ℤ-pos≠O : (n : ℕ) → pos n ≠ O\n ℤ-pos≠O n p = transport ℤ-neg≠O≠pos-type (! p) unit\n\n ℤ-O≠neg : (n : ℕ) → O ≠ neg n\n ℤ-O≠neg n p = transport ℤ-neg≠O≠pos-type p unit\n\n ℤ-neg≠O : (n : ℕ) → neg n ≠ O\n ℤ-neg≠O n p = transport ℤ-neg≠O≠pos-type (! p) unit\n\n ℤ-neg≠pos : (n m : ℕ) → neg n ≠ pos m\n ℤ-neg≠pos n m p = transport ℤ-neg≠pos-type p unit\n\n ℤ-pos≠neg : (n m : ℕ) → pos n ≠ neg m\n ℤ-pos≠neg n m p = transport ℤ-neg≠pos-type (! p) unit\n\n ℤ-has-dec-eq : has-dec-eq ℤ\n ℤ-has-dec-eq O O = inl idp\n ℤ-has-dec-eq O (pos n) = inr (ℤ-O≠pos n)\n ℤ-has-dec-eq O (neg n) = inr (ℤ-O≠neg n)\n ℤ-has-dec-eq (pos n) O = inr (ℤ-pos≠O n)\n ℤ-has-dec-eq (pos n) (pos m) with ℕ-has-dec-eq n m\n ℤ-has-dec-eq (pos n) (pos m) | inl p = inl (ap pos p)\n ℤ-has-dec-eq (pos n) (pos m) | inr p⊥ = inr (λ p → p⊥ (pos-injective n m p))\n ℤ-has-dec-eq (pos n) (neg m) = inr (ℤ-pos≠neg n m)\n ℤ-has-dec-eq (neg n) O = inr (ℤ-neg≠O n)\n ℤ-has-dec-eq (neg n) (pos m) = inr (ℤ-neg≠pos n m)\n ℤ-has-dec-eq (neg n) (neg m) with ℕ-has-dec-eq n m\n ℤ-has-dec-eq (neg n) (neg m) | inl p = inl (ap neg p)\n ℤ-has-dec-eq (neg n) (neg m) | inr p⊥ = inr (λ p → p⊥ (neg-injective n m p))\n\n ℤ-is-set : is-set ℤ\n ℤ-is-set = dec-eq-is-set ℤ-has-dec-eq\n\nℤ-level = ℤ-is-set\n\n{-\n ℤ is also a group!\n-}\n\n-- inv\nℤ~ : ℤ → ℤ\nℤ~ O = O\nℤ~ (pos n) = neg n\nℤ~ (neg n) = pos n\n\n-- comp\n_ℤ+_ : ℤ → ℤ → ℤ\nO ℤ+ z = z\npos O ℤ+ z = succ z\npos (S n) ℤ+ z = succ (pos n ℤ+ z)\nneg O ℤ+ z = pred z\nneg (S n) ℤ+ z = pred (neg n ℤ+ z)\n\n-- unit-l\nℤ+-unit-l : ∀ z → O ℤ+ z == z\nℤ+-unit-l _ = idp\n\n-- unit-r\nprivate\n ℤ+-unit-r-pos : ∀ n → pos n ℤ+ O == pos n\n ℤ+-unit-r-pos O = idp\n ℤ+-unit-r-pos (S n) = ap succ $ ℤ+-unit-r-pos n\n\n ℤ+-unit-r-neg : ∀ n → neg n ℤ+ O == neg n\n ℤ+-unit-r-neg O = idp\n ℤ+-unit-r-neg (S n) = ap pred $ ℤ+-unit-r-neg n\n\nℤ+-unit-r : ∀ z → z ℤ+ O == z\nℤ+-unit-r O = idp\nℤ+-unit-r (pos n) = ℤ+-unit-r-pos n\nℤ+-unit-r (neg n) = ℤ+-unit-r-neg n\n\n-- assoc\nsucc-ℤ+ : ∀ z₁ z₂ → succ z₁ ℤ+ z₂ == succ (z₁ ℤ+ z₂)\nsucc-ℤ+ O _ = idp\nsucc-ℤ+ (pos n) _ = idp\nsucc-ℤ+ (neg O) _ = ! $ succ-pred _\nsucc-ℤ+ (neg (S n)) _ = ! $ succ-pred _\n\npred-ℤ+ : ∀ z₁ z₂ → pred z₁ ℤ+ z₂ == pred (z₁ ℤ+ z₂)\npred-ℤ+ O _ = idp\npred-ℤ+ (neg n) _ = idp\npred-ℤ+ (pos O) _ = ! $ pred-succ _\npred-ℤ+ (pos (S n)) _ = ! $ pred-succ _\n\nprivate\n ℤ+-assoc-pos : ∀ n₁ z₂ z₃ → (pos n₁ ℤ+ z₂) ℤ+ z₃ == pos n₁ ℤ+ (z₂ ℤ+ z₃)\n ℤ+-assoc-pos O z₂ z₃ = succ-ℤ+ z₂ z₃\n ℤ+-assoc-pos (S n₁) z₂ z₃ =\n succ (pos n₁ ℤ+ z₂) ℤ+ z₃ =⟨ succ-ℤ+ (pos n₁ ℤ+ z₂) z₃ ⟩\n succ ((pos n₁ ℤ+ z₂) ℤ+ z₃) =⟨ ap succ $ ℤ+-assoc-pos n₁ z₂ z₃ ⟩\n succ (pos n₁ ℤ+ (z₂ ℤ+ z₃)) ∎\n\n ℤ+-assoc-neg : ∀ n₁ z₂ z₃ → (neg n₁ ℤ+ z₂) ℤ+ z₃ == neg n₁ ℤ+ (z₂ ℤ+ z₃)\n ℤ+-assoc-neg O z₂ z₃ = pred-ℤ+ z₂ z₃\n ℤ+-assoc-neg (S n₁) z₂ z₃ =\n pred (neg n₁ ℤ+ z₂) ℤ+ z₃ =⟨ pred-ℤ+ (neg n₁ ℤ+ z₂) z₃ ⟩\n pred ((neg n₁ ℤ+ z₂) ℤ+ z₃) =⟨ ap pred $ ℤ+-assoc-neg n₁ z₂ z₃ ⟩\n pred (neg n₁ ℤ+ (z₂ ℤ+ z₃)) ∎\n\nℤ+-assoc : ∀ z₁ z₂ z₃ → (z₁ ℤ+ z₂) ℤ+ z₃ == z₁ ℤ+ (z₂ ℤ+ z₃)\nℤ+-assoc O _ _ = idp\nℤ+-assoc (pos n₁) _ _ = ℤ+-assoc-pos n₁ _ _\nℤ+-assoc (neg n₁) _ _ = ℤ+-assoc-neg n₁ _ _\n\nprivate\n pos-S-ℤ+-neg-S : ∀ n₁ n₂ → pos (S n₁) ℤ+ neg (S n₂) == pos n₁ ℤ+ neg n₂\n pos-S-ℤ+-neg-S O n₂ = idp\n pos-S-ℤ+-neg-S (S n₁) n₂ = ap succ $ pos-S-ℤ+-neg-S n₁ n₂\n\n neg-S-ℤ+-pos-S : ∀ n₁ n₂ → neg (S n₁) ℤ+ pos (S n₂) == neg n₁ ℤ+ pos n₂\n neg-S-ℤ+-pos-S O n₂ = idp\n neg-S-ℤ+-pos-S (S n₁) n₂ = ap pred $ neg-S-ℤ+-pos-S n₁ n₂\n\n ℤ~-inv-r-pos : ∀ n → pos n ℤ+ neg n == O\n ℤ~-inv-r-pos O = idp\n ℤ~-inv-r-pos (S n) =\n pos (S n) ℤ+ neg (S n) =⟨ pos-S-ℤ+-neg-S n n ⟩\n pos n ℤ+ neg n =⟨ ℤ~-inv-r-pos n ⟩\n O ∎\n\n ℤ~-inv-r-neg : ∀ n → neg n ℤ+ pos n == O\n ℤ~-inv-r-neg O = idp\n ℤ~-inv-r-neg (S n) =\n neg (S n) ℤ+ pos (S n) =⟨ neg-S-ℤ+-pos-S n n ⟩\n neg n ℤ+ pos n =⟨ ℤ~-inv-r-neg n ⟩\n O ∎\n\nℤ~-inv-r : ∀ z → z ℤ+ ℤ~ z == O\nℤ~-inv-r O = idp\nℤ~-inv-r (pos n) = ℤ~-inv-r-pos n\nℤ~-inv-r (neg n) = ℤ~-inv-r-neg n\n\nℤ~-inv-l : ∀ z → ℤ~ z ℤ+ z == O\nℤ~-inv-l O = idp\nℤ~-inv-l (pos n) = ℤ~-inv-r-neg n\nℤ~-inv-l (neg n) = ℤ~-inv-r-pos n\n\nℤ-group-structure : GroupStructure ℤ\nℤ-group-structure = record\n { ident = O\n ; inv = ℤ~\n ; comp = _ℤ+_\n ; unitl = ℤ+-unit-l\n ; unitr = ℤ+-unit-r\n ; assoc = ℤ+-assoc\n ; invr = ℤ~-inv-r\n ; invl = ℤ~-inv-l\n }\n\nℤ-group : Group₀\nℤ-group = group _ ℤ-is-set ℤ-group-structure\n", "meta": {"hexsha": "e4898826768711adcc3df81fd4bea3d51dae60c7", "size": 6492, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lib/types/Int.agda", "max_stars_repo_name": "danbornside/HoTT-Agda", "max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/types/Int.agda", "max_issues_repo_name": "danbornside/HoTT-Agda", "max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/types/Int.agda", "max_forks_repo_name": "danbornside/HoTT-Agda", "max_forks_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.1774193548, "max_line_length": 78, "alphanum_fraction": 0.5207948244, "num_tokens": 3309, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677506936878, "lm_q2_score": 0.7371581510799253, "lm_q1q2_score": 0.6250863392767619}} {"text": "------------------------------------------------------------------------\n-- Code related to the paper \"Higher Inductive Type Eliminators\n-- Without Paths\"\n--\n-- Nils Anders Danielsson\n------------------------------------------------------------------------\n\n-- Note that the code does not follow the paper exactly, and that some\n-- of the code has been changed after the paper was published.\n\n{-# OPTIONS --cubical --safe #-}\n\nmodule README.HITs-without-paths where\n\nimport Equality\nimport Equality.Id\nimport Equality.Instances-related\nimport Equality.Path\nimport Equality.Path.Isomorphisms\nimport Equality.Propositional\nimport Function-universe\nimport H-level\nimport H-level.Truncation.Propositional\nimport Quotient\nimport Suspension\n\n------------------------------------------------------------------------\n-- 1: Introduction\n\n-- The propositional truncation operator.\n\n∥_∥ = H-level.Truncation.Propositional.∥_∥\n\n-- Equality defined as an inductive family with a single constructor\n-- refl.\n\n_≡_ = Equality.Propositional._≡_\n\n------------------------------------------------------------------------\n-- 2: An Axiomatisation of Equality With J\n\n-- The code uses an axiomatisation of \"equality with J\", as discussed\n-- in the text. The axiomatisation is a little convoluted in order to\n-- support using equality at all universe levels. Furthermore, also as\n-- discussed in the text, the axiomatisation supports choosing\n-- specific definitions for other functions, like cong, to make the\n-- code more usable when it is instantiated with Cubical Agda paths\n-- (for which the canonical definition of cong computes in a different\n-- way than typical definitions obtained using J).\n\n-- Equality and reflexivity.\n\n≡-refl = Equality.Reflexive-relation\n\n-- The J rule and its computation rule.\n\nJ-J-refl = Equality.Equality-with-J₀\n\n-- Extended variants of the two definitions above.\n\nEquivalence-relation⁺ = Equality.Equivalence-relation⁺\nEquality-with-J = Equality.Equality-with-J\nEquality-with-paths = Equality.Path.Equality-with-paths\n\n-- The extended variants are inhabited for all universe levels if the\n-- basic ones are inhabited for all universe levels.\n\nJ₀⇒Equivalence-relation⁺ = Equality.J₀⇒Equivalence-relation⁺\nJ₀⇒J = Equality.J₀⇒J\nEquality-with-J₀⇒Equality-with-paths =\n Equality.Path.Equality-with-J₀⇒Equality-with-paths\n\n-- To see how the code is axiomatised, see the module header of, say,\n-- Circle.\n\nimport Circle\n\n-- Any two notions of equality satisfying the axioms are pointwise\n-- isomorphic, and the isomorphisms map canonical proofs of\n-- reflexivity to canonical proofs of reflexivity.\n--\n-- Note that in some cases the code uses bijections (_↔_) instead of\n-- equivalences (_≃_).\n\ninstances-isomorphic =\n Equality.Instances-related.all-equality-types-isomorphic\n\n-- Cubical Agda paths, the Cubical Agda identity type family, and a\n-- definition of equality as an inductive family with a single\n-- constructor refl are instances of the axioms. (The last instance is\n-- for Equality-with-J rather than Equality-with-paths, because the\n-- latter definition is defined in Cubical Agda, and the instance is\n-- not.)\n\npaths-instance = Equality.Path.equality-with-paths\nid-instance = Equality.Id.equality-with-paths\ninductive-family-instance = Equality.Propositional.equality-with-J\n\n------------------------------------------------------------------------\n-- 3: Homogeneous Paths\n\n-- The path type constructor.\n\nPath = Equality.Path._≡_\n\n-- Zero and one.\n\n0̲ = Equality.Path.0̲\n1̲ = Equality.Path.1̲\n\n-- Reflexivity.\n\nreflᴾ = Equality.Path.refl\n\n-- Minimum, maximum and negation.\n\nmin = Equality.Path.min\nmax = Equality.Path.max\n-_ = Equality.Path.-_\n\n-- The primitive transport operation.\n\nopen Equality.Path using (transport)\n\n-- The J rule and transport-refl.\n\nJᴾ = Equality.Path.elim\ntransport-refl = Equality.Path.transport-refl\n\n-- Transitivity (more general than in the paper).\n\ntransᴾ = Equality.Path.htransʳ\n\n------------------------------------------------------------------------\n-- 4: Heterogeneous Paths\n\n-- Pathᴴ.\n\nPathᴴ = Equality.Path.[_]_≡_\n\n-- The eliminator elimᴾ for the propositional truncation operator.\n\nmodule ∥_∥ where\n\n elimᴾ = H-level.Truncation.Propositional.elimᴾ′\n\n-- Pathᴴ≡Path and Pathᴴ≃Path.\n\nPathᴴ≡Path = Equality.Path.heterogeneous≡homogeneous\nPathᴴ≃Path = Equality.Path.heterogeneous↔homogeneous\n\n-- The lemma substᴾ.\n\nsubstᴾ = Equality.Path.subst\n\n-- The lemmas subst and subst-refl from the axiomatisation.\n\nsubst = Equality.Equality-with-J.subst\nsubst-refl = Equality.Equality-with-J.subst-refl\n\n-- The axiomatisation makes it possible to choose the implementations\n-- of to-path and from-path.\n\nto-path = Equality.Path.Equality-with-paths.to-path\nfrom-path = Equality.Path.Equality-with-paths.from-path\n\n-- The code mostly uses a pointwise isomorphism between the arbitrary\n-- notion of equality and paths instead of from-path and to-path.\n\n≡↔≡ = Equality.Path.Derived-definitions-and-properties.≡↔≡\n\n-- The lemmas subst≡substᴾ, subst≡≃Pathᴴ, subst≡→Pathᴴ and\n-- subst≡→substᴾ≡ (which is formulated as a bijection).\n\nsubst≡substᴾ = Equality.Path.Isomorphisms.subst≡subst\nsubst≡≃Pathᴴ = Equality.Path.Isomorphisms.subst≡↔[]≡\nsubst≡→Pathᴴ = Equality.Path.Isomorphisms.subst≡→[]≡\nsubst≡→substᴾ≡ = Equality.Path.Isomorphisms.subst≡↔subst≡\n\n-- The lemmas congᴰ and congᴰ-refl from the axiomatisation.\n\ncongᴰ = Equality.Equality-with-J.dcong\ncongᴰ-refl = Equality.Equality-with-J.dcong-refl\n\n-- The lemmas congᴴ and congᴰᴾ.\n\ncongᴴ = Equality.Path.hcong\ncongᴰᴾ = Equality.Path.dcong\n\n-- The proofs congᴰ≡congᴰᴾ, congᴰᴾ≡congᴴ, congᴰ≡congᴴ and\n-- dependent‐computation‐rule‐lemma.\n\ncongᴰ≡congᴰᴾ = Equality.Path.Isomorphisms.dcong≡dcong\ncongᴰᴾ≡congᴴ = Equality.Path.dcong≡hcong\ncongᴰ≡congᴴ = Equality.Path.Isomorphisms.dcong≡hcong\ndependent‐computation‐rule‐lemma =\n Equality.Path.Isomorphisms.dcong-subst≡→[]≡\n\n------------------------------------------------------------------------\n-- 5: The Circle Without Paths\n\n-- The circle and loop.\n\n𝕊¹ = Circle.𝕊¹\nloop = Circle.loop\n\n-- The lemmas cong and cong-refl from the axiomatisation.\n\ncong = Equality.Equality-with-J.cong\ncong-refl = Equality.Equality-with-J.cong-refl\n\n-- The lemma non-dependent-computation-rule-lemma.\n\nnon-dependent-computation-rule-lemma =\n Equality.Path.Isomorphisms.cong-≡↔≡\n\n-- The lemma trans, which is actually a part of the axiomatisation\n-- that I use, but which can be proved using the J rule.\n\ntrans = Equality.Equivalence-relation⁺.trans\nJ₀⇒trans = Equality.J₀⇒Equivalence-relation⁺\n\n-- The lemma subst-const.\n\nsubst-const = Equality.Derived-definitions-and-properties.subst-const\n\n-- The lemma congᴰ≡→cong≡.\n\ncongᴰ≡→cong≡ = Equality.Derived-definitions-and-properties.dcong≡→cong≡\n\n-- Eliminators and computation rules.\n\nmodule 𝕊¹ where\n\n elimᴾ = Circle.elimᴾ\n recᴾ = Circle.recᴾ\n elim = Circle.elim\n elim-loop = Circle.elim-loop\n rec = Circle.rec\n rec-loop = Circle.rec-loop\n rec′ = Circle.rec′\n rec′-loop = Circle.rec′-loop\n\n------------------------------------------------------------------------\n-- 6: Set Quotients Without Paths\n\n-- The definition of h-levels.\n\nContractible = Equality.Derived-definitions-and-properties.Contractible\nH-level = H-level.H-level\nIs-proposition = Equality.Derived-definitions-and-properties.Is-proposition\nIs-set = Equality.Derived-definitions-and-properties.Is-set\n\n-- Set quotients.\n\n_/_ = Quotient._/_\n\n-- Some lemmas.\n\nH-levelᴾ-suc≃H-levelᴾ-Pathᴴ = Equality.Path.H-level-suc↔H-level[]≡\nindex-irrelevant = Equality.Path.index-irrelevant\ntransport-transport = Equality.Path.transport∘transport\nheterogeneous-irrelevance = Equality.Path.heterogeneous-irrelevance\nheterogeneous-UIP = Equality.Path.heterogeneous-UIP\nH-level≃H-levelᴾ = Equality.Path.Isomorphisms.H-level↔H-level\n\n-- A generalisation of Π-cong. Note that equality is provably\n-- extensional in Cubical Agda.\n\nΠ-cong = Function-universe.Π-cong\nextensionality = Equality.Path.ext\n\n-- Variants of the constructors.\n\n[]-respects-relation = Quotient.[]-respects-relation\n/-is-set = Quotient./-is-set\n\n-- Eliminators.\n\nmodule _/_ where\n\n elimᴾ′ = Quotient.elimᴾ′\n elimᴾ = Quotient.elimᴾ\n recᴾ = Quotient.recᴾ\n elim = Quotient.elim\n rec = Quotient.rec\n\n------------------------------------------------------------------------\n-- 7: More Examples\n\n-- Suspensions.\n\nmodule Susp where\n\n Susp = Suspension.Susp\n elimᴾ = Suspension.elimᴾ\n recᴾ = Suspension.recᴾ\n meridian = Suspension.meridian\n elim = Suspension.elim\n elim-meridian = Suspension.elim-meridian\n rec = Suspension.rec\n rec-meridian = Suspension.rec-meridian\n\n-- The propositional truncation operator.\n\nmodule Propositional-truncation where\n\n elimᴾ′ = H-level.Truncation.Propositional.elimᴾ′\n elimᴾ = H-level.Truncation.Propositional.elimᴾ\n recᴾ = H-level.Truncation.Propositional.recᴾ\n trivial = H-level.Truncation.Propositional.truncation-is-proposition\n elim = H-level.Truncation.Propositional.elim\n rec = H-level.Truncation.Propositional.rec\n\n------------------------------------------------------------------------\n-- 8: An Alternative Approach\n\n-- Circle and Circleᴾ, combined into a single definition.\n\nCircle = Circle.Circle\n\n-- Circleᴾ≃Circle, circleᴾ and circle.\n\nCircleᴾ≃Circle = Circle.Circle≃Circle\ncircleᴾ = Circle.circleᴾ\ncircle = Circle.circle\n\n-- The computation rule for the higher constructor.\n\nelim-loop-circle = Circle.elim-loop-circle\n\n-- Alternative definitions of Circleᴾ≃Circle and circle that (at the\n-- time of writing) do not give the \"correct\" computational behaviour\n-- for the point constructor.\n\nCircleᴾ≃Circle′ = Circle.Circle≃Circle′\ncircle′ = Circle.circle′\n\n------------------------------------------------------------------------\n-- 9: Discussion\n\n-- The interval.\n\nimport Interval\n\n-- Pushouts.\n\nimport Pushout\n\n-- A general truncation operator.\n\nimport H-level.Truncation\n\n-- The torus.\n\nimport Torus\n", "meta": {"hexsha": "5d006937c70cf5a3f5935763713f458ff30f42a6", "size": 10170, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "README/HITs-without-paths.agda", "max_stars_repo_name": "nad/equality", "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_issues_repo_path": "README/HITs-without-paths.agda", "max_issues_repo_name": "nad/equality", "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "README/HITs-without-paths.agda", "max_forks_repo_name": "nad/equality", "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.487394958, "max_line_length": 75, "alphanum_fraction": 0.679252704, "num_tokens": 2760, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314798554445, "lm_q2_score": 0.705785040214066, "lm_q1q2_score": 0.6250654496246176}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Category.Lift where\n\nopen import Level\nopen import Categories.Category\nopen import Categories.Functor using (Functor)\n\nliftC : ∀ {o ℓ e} o′ ℓ′ e′ → Category o ℓ e → Category (o ⊔ o′) (ℓ ⊔ ℓ′) (e ⊔ e′)\nliftC o′ ℓ′ e′ C = record\n { Obj = Lift o′ Obj\n ; _⇒_ = λ X Y → Lift ℓ′ (lower X ⇒ lower Y)\n ; _≈_ = λ f g → Lift e′ (lower f ≈ lower g)\n ; id = lift id\n ; _∘_ = λ f g → lift (lower f ∘ lower g)\n ; assoc = lift assoc\n ; sym-assoc = lift sym-assoc\n ; identityˡ = lift identityˡ\n ; identityʳ = lift identityʳ\n ; identity² = lift identity²\n ; equiv = record\n { refl = lift Equiv.refl\n ; sym = λ eq → lift (Equiv.sym (lower eq))\n ; trans = λ eq eq′ → lift (Equiv.trans (lower eq) (lower eq′))\n }\n ; ∘-resp-≈ = λ eq eq′ → lift (∘-resp-≈ (lower eq) (lower eq′))\n }\n where open Category C\n\nliftF : ∀ {o ℓ e} o′ ℓ′ e′ (C : Category o ℓ e) → Functor C (liftC o′ ℓ′ e′ C)\nliftF o′ ℓ′ e′ C = record\n { F₀ = lift\n ; F₁ = lift\n ; identity = lift refl\n ; homomorphism = lift refl\n ; F-resp-≈ = lift\n }\n where open Category C\n open Equiv\n\nunliftF : ∀ {o ℓ e} o′ ℓ′ e′ (C : Category o ℓ e) → Functor (liftC o′ ℓ′ e′ C) C\nunliftF o′ ℓ′ e′ C = record\n { F₀ = lower\n ; F₁ = lower\n ; identity = refl\n ; homomorphism = refl\n ; F-resp-≈ = lower\n }\n where open Category C\n open Equiv\n", "meta": {"hexsha": "a36534426e01626c52469d74e82d913d6ed9950d", "size": 1470, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Lift.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/Lift.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/Lift.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 28.8235294118, "max_line_length": 81, "alphanum_fraction": 0.5346938776, "num_tokens": 560, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314738181874, "lm_q2_score": 0.7057850278370111, "lm_q1q2_score": 0.6250654344021026}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Endomorphisms on a Set\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Function.Endomorphism.Propositional {a} (A : Set a) where\n\nopen import Algebra using (Magma; Semigroup; Monoid)\nopen import Algebra.FunctionProperties.Core using (Op₂)\nopen import Algebra.Morphism; open Definitions\nopen import Algebra.Structures using (IsMagma; IsSemigroup; IsMonoid)\n\nopen import Data.Nat.Base using (ℕ; zero; suc; _+_)\nopen import Data.Nat.Properties using (+-0-monoid; +-semigroup)\nopen import Data.Product using (_,_)\n\nopen import Function\nopen import Function.Equality using (_⟨$⟩_)\nopen import Relation.Binary using (_Preserves_⟶_)\nopen import Relation.Binary.PropositionalEquality as P using (_≡_; refl)\n\nimport Function.Endomorphism.Setoid (P.setoid A) as Setoid\n\nEndo : Set a\nEndo = A → A\n\n------------------------------------------------------------------------\n-- Conversion back and forth with the Setoid-based notion of Endomorphism\n\nfromSetoidEndo : Setoid.Endo → Endo\nfromSetoidEndo = _⟨$⟩_\n\ntoSetoidEndo : Endo → Setoid.Endo\ntoSetoidEndo f = record\n { _⟨$⟩_ = f\n ; cong = P.cong f\n }\n\n------------------------------------------------------------------------\n-- N-th composition\n\n_^_ : Endo → ℕ → Endo\nf ^ zero = id\nf ^ suc n = f ∘′ (f ^ n)\n\n^-homo : ∀ f → Homomorphic₂ ℕ Endo _≡_ (f ^_) _+_ _∘′_\n^-homo f zero n = refl\n^-homo f (suc m) n = P.cong (f ∘′_) (^-homo f m n)\n\n------------------------------------------------------------------------\n-- Structures\n\n∘-isMagma : IsMagma _≡_ (Op₂ Endo ∋ _∘′_)\n∘-isMagma = record\n { isEquivalence = P.isEquivalence\n ; ∙-cong = P.cong₂ _∘′_\n }\n\n∘-magma : Magma _ _\n∘-magma = record { isMagma = ∘-isMagma }\n\n∘-isSemigroup : IsSemigroup _≡_ (Op₂ Endo ∋ _∘′_)\n∘-isSemigroup = record\n { isMagma = ∘-isMagma\n ; assoc = λ _ _ _ → refl\n }\n\n∘-semigroup : Semigroup _ _\n∘-semigroup = record { isSemigroup = ∘-isSemigroup }\n\n∘-id-isMonoid : IsMonoid _≡_ _∘′_ id\n∘-id-isMonoid = record\n { isSemigroup = ∘-isSemigroup\n ; identity = (λ _ → refl) , (λ _ → refl)\n }\n\n∘-id-monoid : Monoid _ _\n∘-id-monoid = record { isMonoid = ∘-id-isMonoid }\n\n------------------------------------------------------------------------\n-- Homomorphism\n\n^-isSemigroupMorphism : ∀ f → IsSemigroupMorphism +-semigroup ∘-semigroup (f ^_)\n^-isSemigroupMorphism f = record\n { ⟦⟧-cong = P.cong (f ^_)\n ; ∙-homo = ^-homo f\n }\n\n^-isMonoidMorphism : ∀ f → IsMonoidMorphism +-0-monoid ∘-id-monoid (f ^_)\n^-isMonoidMorphism f = record\n { sm-homo = ^-isSemigroupMorphism f\n ; ε-homo = refl\n }\n", "meta": {"hexsha": "8864357f71d633031eeebae0b23d050cde91373e", "size": 2702, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Function/Endomorphism/Propositional.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Function/Endomorphism/Propositional.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Function/Endomorphism/Propositional.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.8556701031, "max_line_length": 80, "alphanum_fraction": 0.5569948187, "num_tokens": 845, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314647623016, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.6250654334913486}} {"text": "{-# OPTIONS --no-auto-inline #-}\nmodule Where where\n\nopen import Haskell.Prelude hiding (_+_; _*_; _-_)\nopen import Agda.Builtin.Nat\n\npostulate\n bool2nat : Bool → Nat\n\n-- no outer arguments\nex1 : Nat\nex1 = mult num + bool2nat true\n where\n num : Nat\n num = 42\n\n mult : Nat → Nat\n mult = _* 100\n\n-- nested where\nex2 : Nat\nex2 = mult num + bool2nat true\n where\n num : Nat\n num = 42\n\n mult : Nat → Nat\n mult = _⊗ 100\n where\n _⊗_ = _*_\n\n-- with outer arguments\nex3 : Nat → Bool → Nat\nex3 n b = mult num + bool2nat b\n where\n num = 42 + bool2nat b\n\n mult : Nat → Nat\n mult = _* n\n\n-- nested where with outer arguments\nex4 : Bool → Nat\nex4 b = mult 42\n where\n mult : Nat → Nat\n mult n = bump n (bool2nat b)\n where\n bump : Nat → Nat → Nat\n bump x y = x * y + (n - bool2nat b)\n\nex4' : Bool → Nat\nex4' b = mult (bool2nat b)\n where\n mult : Nat → Nat\n mult n = bump n (bool2nat b)\n where\n bump : Nat → Nat → Nat\n bump x y = go (x * y) (n - bool2nat b)\n where\n go : Nat → Nat → Nat\n go z w = z + x + w + y + n + bool2nat b\n\n-- with pattern matching and multiple clauses\nex5 : List Nat → Nat\nex5 [] = zro\n where\n zro : Nat\n zro = 0\nex5 (n ∷ ns) = mult num + 1\n where\n num = 42 + ex5 ns\n\n mult : Nat → Nat\n mult = _* n\n\n-- mix of patterns + inner multiple clauses + nested where\nex6 : List Nat → Bool → Nat\nex6 [] b = zro\n where\n zro : Nat\n zro = 0\nex6 (n ∷ ns) b = mult (num ∷ 1 ∷ [])\n where\n mult : List Nat → Nat\n mult [] = bump 5 (bool2nat b)\n where\n bump : Nat → Nat → Nat\n bump x y = x * y + n\n mult (m ∷ ms) = bump n m\n where\n bump : Nat → Nat → Nat\n bump x y = x * y + (m - n)\n\n num = 42 + ex6 ns true\n\nex7 : Nat → Nat\nex7 n₀ = go₁ n₀\n where\n go₁ : Nat → Nat\n go₁ n₁ = go₂ (n₀ + n₁)\n where\n go₂ : Nat → Nat\n go₂ n₂ = n₀ + n₁ + n₂\n\nex7' : Nat → Nat\nex7' n₀ = go₁ n₀\n where\n go₁ : Nat → Nat\n go₁ n₁ = go₂ (n₀ + n₁)\n where\n go₂ : Nat → Nat\n go₂ n₂ = go₃ (n₀ + n₁ + n₂)\n where\n go₃ : Nat → Nat\n go₃ n₃ = n₀ + n₁ + n₂ + n₃\n\nex8 : Nat\nex8 = n₂\n where\n n₁ : Nat\n n₁ = 1\n n₂ = n₁ + 1\n\n{-# COMPILE AGDA2HS bool2nat #-}\n{-# COMPILE AGDA2HS ex1 #-}\n{-# COMPILE AGDA2HS ex2 #-}\n{-# COMPILE AGDA2HS ex3 #-}\n{-# COMPILE AGDA2HS ex4 #-}\n{-# COMPILE AGDA2HS ex4' #-}\n{-# COMPILE AGDA2HS ex5 #-}\n{-# COMPILE AGDA2HS ex6 #-}\n{-# COMPILE AGDA2HS ex7 #-}\n{-# COMPILE AGDA2HS ex7' #-}\n{-# COMPILE AGDA2HS ex8 #-}\n", "meta": {"hexsha": "9003207b99756d6c531173a78db65ca53286e794", "size": 2584, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Where.agda", "max_stars_repo_name": "dxts/agda2hs", "max_stars_repo_head_hexsha": "8c8f24a079ed9677dbe6893cf786e7ed52dfe8b6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 55, "max_stars_repo_stars_event_min_datetime": "2020-10-20T13:36:25.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T21:57:56.000Z", "max_issues_repo_path": "test/Where.agda", "max_issues_repo_name": "seanpm2001/agda2hs", "max_issues_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 63, "max_issues_repo_issues_event_min_datetime": "2020-10-22T05:19:27.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-25T15:47:30.000Z", "max_forks_repo_path": "test/Where.agda", "max_forks_repo_name": "seanpm2001/agda2hs", "max_forks_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 18, "max_forks_repo_forks_event_min_datetime": "2020-10-21T22:19:09.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:42:52.000Z", "avg_line_length": 19.1407407407, "max_line_length": 58, "alphanum_fraction": 0.5193498452, "num_tokens": 965, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430394931455, "lm_q2_score": 0.7520125793176222, "lm_q1q2_score": 0.6250300209111287}} {"text": "{-# OPTIONS --cubical #-}\n\nopen import Cubical.Core.Everything\n\nSq : {A : Set} {a0 a1 b0 b1 : A}\n (u : a0 ≡ a1) (v : b0 ≡ b1)\n (r0 : a0 ≡ b0) (r1 : a1 ≡ b1)\n → Set\nSq u v r0 r1 = PathP (λ i → r0 i ≡ r1 i) u v\n\nConstSq : {A : Set} {a : A} (p : a ≡ a) →\n Sq p p p p\nConstSq {A} p i j = compCCHM (λ _ → A)\n (~ i ∨ i ∨ ~ j ∨ j)\n (λ k → λ { (i = i0) → p j\n ; (i = i1) → p (k ∧ j)\n ; (j = i0) → p i\n ; (j = i1) → p (k ∧ i)\n })\n (p (i ∨ j))\n", "meta": {"hexsha": "e63973a5e2ef010e1608ff0256510fdb00b4dd7b", "size": 500, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "testData/parse/agda/ConstSquare.agda", "max_stars_repo_name": "dubinsky/intellij-dtlc", "max_stars_repo_head_hexsha": "ee25a3a81dacebfe4449de7a9aaff029171456be", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 30, "max_stars_repo_stars_event_min_datetime": "2019-05-11T16:26:38.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-29T13:18:34.000Z", "max_issues_repo_path": "testData/parse/agda/ConstSquare.agda", "max_issues_repo_name": "dubinsky/intellij-dtlc", "max_issues_repo_head_hexsha": "ee25a3a81dacebfe4449de7a9aaff029171456be", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 16, "max_issues_repo_issues_event_min_datetime": "2019-03-30T04:29:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-15T17:04:36.000Z", "max_forks_repo_path": "testData/parse/agda/ConstSquare.agda", "max_forks_repo_name": "dubinsky/intellij-dtlc", "max_forks_repo_head_hexsha": "ee25a3a81dacebfe4449de7a9aaff029171456be", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-10-07T01:38:12.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-12T21:33:35.000Z", "avg_line_length": 23.8095238095, "max_line_length": 44, "alphanum_fraction": 0.368, "num_tokens": 244, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797075998823, "lm_q2_score": 0.6859494421679929, "lm_q1q2_score": 0.6250232121429342}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Algebra.RingSolver.Examples where\n\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Data.FinData\nopen import Cubical.Data.Nat using (ℕ)\nopen import Cubical.Data.Vec.Base\n\nopen import Cubical.Algebra.RingSolver.AlmostRing\nopen import Cubical.Algebra.RingSolver.NatAsAlmostRing\nopen import Cubical.Algebra.RingSolver.RingExpression\nopen import Cubical.Algebra.RingSolver.RawRing renaming (⟨_⟩ to ⟨_⟩ᵣ)\nopen import Cubical.Algebra.RingSolver.HornerForms\nopen import Cubical.Algebra.RingSolver.Solver\n\nprivate\n variable\n ℓ : Level\n\nmodule MultivariateSolving where\n open AlmostRing ℕAsAlmostRing\n ℕAsRawRing = AlmostRing→RawRing ℕAsAlmostRing\n open EqualityToNormalform ℕAsAlmostRing\n ℕ[X₀,X₁] = IteratedHornerOperations.asRawRing ℕAsRawRing 2\n\n X₀ : ⟨ ℕ[X₀,X₁] ⟩ᵣ\n X₀ = Variable 2 ℕAsRawRing (Fin.zero)\n\n X₁ : ⟨ ℕ[X₀,X₁] ⟩ᵣ\n X₁ = Variable 2 ℕAsRawRing (suc Fin.zero)\n\n Two : ⟨ ℕ[X₀,X₁] ⟩ᵣ\n Two = Constant 2 ℕAsRawRing 2\n\n _ : eval 2 X₀ (1 ∷ 0 ∷ []) ≡ 1\n _ = refl\n\n _ : eval 2 X₁ (0 ∷ 1 ∷ []) ≡ 1\n _ = refl\n\n X : Expr ℕ 3\n X = ∣ Fin.zero\n\n Y : Expr ℕ 3\n Y = ∣ (suc Fin.zero)\n\n Z : Expr ℕ 3\n Z = ∣ (suc (suc Fin.zero))\n\n {-\n 'normalize' maps an expression to its Horner Normalform.\n Two expressions evaluating to the same ring element\n have the same Horner Normal form.\n This means equality of the represented ring elements\n can be checked by agda's unification (so refl is a proof)\n\n -}\n _ : normalize 3 ((K 2) ⊗ X) ≡\n normalize 3 (X ⊕ X)\n _ = refl\n\n\n _ : normalize 3 ((K 2) ⊗ X) ≡ normalize 3 (X ⊕ X)\n _ = refl\n\n _ : normalize 3 (((K 2) ⊗ X) ⊗ Y) ≡ normalize 3 (Y ⊗ (X ⊕ X))\n _ = refl\n\n _ : normalize 3 (Z ⊗ (((K 2) ⊗ X) ⊗ Y)) ≡ normalize 3 (Z ⊗ (Y ⊗ (X ⊕ X)))\n _ = refl\n\n\n {-\n The solver needs to produce an equality between\n actual ring elements. So we need a proof that\n those actual ring elements are equal to a normal form:\n -}\n _ : (x y z : ℕ) →\n eval 3 (normalize 3 ((K 2) ⊗ X ⊗ Y)) (x ∷ y ∷ z ∷ [])\n ≡ 2 · x · y\n _ = λ x y z → isEqualToNormalform 3 ((K 2) ⊗ X ⊗ Y) (x ∷ y ∷ z ∷ [])\n\n {-\n Now two of these proofs can be plugged together\n to solve an equation:\n -}\n open Eval ℕAsRawRing\n _ : (x y z : ℕ) → 3 + x + y · y ≡ y · y + x + 1 + 2\n _ = let\n lhs = (K 3) ⊕ X ⊕ (Y ⊗ Y)\n rhs = Y ⊗ Y ⊕ X ⊕ (K 1) ⊕ (K 2)\n in (λ x y z →\n ⟦ lhs ⟧ (x ∷ y ∷ z ∷ [])\n ≡⟨ sym (isEqualToNormalform 3 lhs (x ∷ y ∷ z ∷ [])) ⟩\n eval 3 (normalize 3 lhs) (x ∷ y ∷ z ∷ [])\n ≡⟨ refl ⟩\n eval 3 (normalize 3 rhs) (x ∷ y ∷ z ∷ [])\n ≡⟨ isEqualToNormalform 3 rhs (x ∷ y ∷ z ∷ []) ⟩\n ⟦ rhs ⟧ (x ∷ y ∷ z ∷ []) ∎)\n\n {-\n Parts of that can be automated easily:\n -}\n _ : (x y z : ℕ) → (x + y) · (x + y) ≡ x · x + 2 · x · y + y · y\n _ = λ x y z → let\n lhs = (X ⊕ Y) ⊗ (X ⊕ Y)\n rhs = X ⊗ X ⊕ (K 2) ⊗ X ⊗ Y ⊕ Y ⊗ Y\n in solve lhs rhs (x ∷ y ∷ z ∷ []) refl\n\n {-\n A bigger example\n -}\n _ : (x y z : ℕ) → (x + y) · (x + y) · (x + y) · (x + y)\n ≡ x · x · x · x + 4 · x · x · x · y + 6 · x · x · y · y\n + 4 · x · y · y · y + y · y · y · y\n _ = λ x y z → let\n lhs = (X ⊕ Y) ⊗ (X ⊕ Y) ⊗ (X ⊕ Y) ⊗ (X ⊕ Y)\n rhs = X ⊗ X ⊗ X ⊗ X\n ⊕ (K 4) ⊗ X ⊗ X ⊗ X ⊗ Y\n ⊕ (K 6) ⊗ X ⊗ X ⊗ Y ⊗ Y\n ⊕ (K 4) ⊗ X ⊗ Y ⊗ Y ⊗ Y\n ⊕ Y ⊗ Y ⊗ Y ⊗ Y\n in solve lhs rhs (x ∷ y ∷ z ∷ []) refl\n {-\n this one cannot work so far:\n\n _ : (x y z : ℕ) → (x + y) · (x - y) ≡ (x · x - (y · y))\n _ = λ x y z → let\n lhs = (X ⊕ Y) ⊗ (X ⊕ (⊝ Y))\n rhs = (X ⊗ X) ⊕ (⊝ (Y ⊗ Y))\n in solve lhs rhs (x ∷ y ∷ z ∷ []) {!!}\n -}\n\nmodule ExamplesForArbitraryRings (R : AlmostRing {ℓ}) where\n open AlmostRing R\n open EqualityToNormalform R\n\n X : Expr ⟨ R ⟩ 4\n X = ∣ Fin.zero\n\n Y : Expr ⟨ R ⟩ 4\n Y = ∣ (suc Fin.zero)\n\n A : Expr ⟨ R ⟩ 4\n A = ∣ (suc (suc Fin.zero))\n\n B : Expr ⟨ R ⟩ 4\n B = ∣ (suc (suc (suc Fin.zero)))\n\n _ : (x y a b : ⟨ R ⟩) → (x + y) + (a + b) ≡ (y + b) + (x + a)\n _ = λ x y a b → let\n lhs = (X ⊕ Y) ⊕ (A ⊕ B)\n rhs = (Y ⊕ B) ⊕ (X ⊕ A)\n in solve lhs rhs (x ∷ y ∷ a ∷ b ∷ []) refl\n\n _ : (x y a b : ⟨ R ⟩) → (x + y) · (x + y) ≡ x · x + x · y + x · y + y · y\n _ = λ x y a b →\n let\n lhs = (X ⊕ Y) ⊗ (X ⊕ Y)\n rhs = (X ⊗ X) ⊕ (X ⊗ Y) ⊕ (X ⊗ Y) ⊕ (Y ⊗ Y)\n in solve lhs rhs (x ∷ y ∷ a ∷ b ∷ []) refl\n\n _ : (x y a b : ⟨ R ⟩) → x · a ≡ a · x\n _ = λ x y a b →\n let\n lhs = X ⊗ A\n rhs = A ⊗ X\n in solve lhs rhs (x ∷ y ∷ a ∷ b ∷ []) refl\n\n{-\n this one should work, but doesn't:\n\n _ : (x y a b : ⟨ R ⟩) → x · (a + b) ≡ a · x + b · x\n _ = λ x y a b →\n let\n lhs = X ⊗ (A ⊕ B)\n rhs = (A ⊗ X) ⊕ (B ⊗ X)\n in solve lhs rhs (x ∷ y ∷ a ∷ b ∷ []) refl\n\n the reason ist, that lhs and rhs evaluate to definitionally different things:\n\n(0r · x +\n (0r · y +\n ((0r · a + (0r · b + 1r · 1r)) · a +\n ((0r · b + 1r · 1r) · b + 1r · 0r))))\n· x\n+ 0r\n\n(0r · x +\n (0r · y +\n ((0r · a + (0r · b + 1r · 1r)) · a +\n ((0r · b + 1r · 1r) · b + (0r + 0r · 1r)))))\n· x\n+ 0r\n-}\n{-\n '-' is problematic...\n\n _ : (x y a b : ⟨ R ⟩) → (x + y) · (x - y) ≡ (x · x - (y · y))\n _ = λ x y a b → let\n lhs = (X ⊕ Y) ⊗ (X ⊕ (⊝ Y))\n rhs = (X ⊗ X) ⊕ (⊝ (Y ⊗ Y))\n in solve lhs rhs (x ∷ y ∷ a ∷ b ∷ []) {!!}\n-}\n", "meta": {"hexsha": "454b40ddcfc3f30ae4555400f2d591a2e4618493", "size": 5632, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/RingSolver/Examples.agda", "max_stars_repo_name": "apabepa10/cubical", "max_stars_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/RingSolver/Examples.agda", "max_issues_repo_name": "apabepa10/cubical", "max_issues_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/RingSolver/Examples.agda", "max_forks_repo_name": "apabepa10/cubical", "max_forks_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.3398058252, "max_line_length": 79, "alphanum_fraction": 0.4477982955, "num_tokens": 2369, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199592797929, "lm_q2_score": 0.7461390043208003, "lm_q1q2_score": 0.6249809224162539}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Data.Bool where\n\nopen import Level\nopen import Agda.Builtin.Bool using (Bool; true; false) public\nopen import Data.Unit\nopen import Data.Empty\n\nbool : ∀ {ℓ} {P : Bool → Type ℓ} (f : P false) (t : P true) → (x : Bool) → P x\nbool f t false = f\nbool f t true = t\n\nnot : Bool → Bool\nnot false = true\nnot true = false\n\ninfixl 6 _or_\n_or_ : Bool → Bool → Bool\nfalse or y = y\ntrue or y = true\n\ninfixl 7 _and_\n_and_ : Bool → Bool → Bool\nfalse and y = false\ntrue and y = y\n\ninfixr 0 if_then_else_\nif_then_else_ : ∀ {a} {A : Set a} → Bool → A → A → A\nif true then x else _ = x\nif false then _ else x = x\n\nT : Bool → Type₀\nT true = ⊤\nT false = ⊥\n", "meta": {"hexsha": "a67435de8ee60d58b75ffe63eeccabc6282d4ac1", "size": 680, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Data/Bool.agda", "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z", "max_issues_repo_path": "agda/Data/Bool.agda", "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Data/Bool.agda", "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "avg_line_length": 18.8888888889, "max_line_length": 78, "alphanum_fraction": 0.6352941176, "num_tokens": 245, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8376199795472731, "lm_q2_score": 0.7461389817407016, "lm_q1q2_score": 0.6249809186250697}} {"text": "module sv20.assign2.Second where\n-- The solution for the second task starts in line 53\n\nopen import Data.Unit using (⊤; tt)\nopen import Data.Product using (_×_ ; ∃) renaming (_,_ to ⟨_,_⟩)\nopen import Relation.Nullary using (¬_)\nopen import Data.Sum using (_⊎_; inj₁; inj₂)\nopen import Function using (_∘_)\n\n-- For the second task. We took one common definition of Subset mentioned in\n-- https://stackoverflow.com/q/34183349\n\n-- Notice that this definition is equivalent to the definition presented in the\n-- Standard Library where Subset is a \"record\".\n\nSubset : (A : Set) -> Set _\nSubset A = A → Set\n\n-- Because, we are using a different definition from the standard library, we\n-- need to define what it means to be included in a subset, what is a relation,\n-- what is the range and domain of a relation, and so forth.\n\n_∈_ : ∀ {A} → A → Subset A → Set\na ∈ P = P a\n\nRelation : ∀ A B → Set₁\nRelation A B = Subset (A × B)\n\nRange : ∀ {A B} → Relation A B → Subset B\nRange R b = ∃ (R ∘ ⟨_, b ⟩) -- equivalent to ∃ \\a → R ⟨ a , b ⟩\n\nDom : ∀ {A B} → Relation A B → Subset A\nDom R a = ∃ (R ∘ ⟨ a ,_⟩) -- equivalent to ∃ \\b → R ⟨ a , b ⟩\n\n_⊆_ : ∀ {A} → Subset A → Subset A → Set\nA ⊆ B = ∀ x → x ∈ A → x ∈ B\n\n_∩_ : ∀ {A} → Subset A → Subset A → Subset A\nA ∩ B = λ x → x ∈ A × x ∈ B\n\n_∪_ : ∀ {A} → Subset A → Subset A → Subset A\nA ∪ B = λ x → x ∈ A ⊎ x ∈ B\n\n_/_ : ∀ {A} → Subset A → Subset A → Subset A\nA / B = λ x → x ∈ A × ¬ (x ∈ B)\n\n-- Practice theorem\n∪-range-⊆ : ∀ {A B} {F G : Relation A B}\n → (Range F ∪ Range G) ⊆ Range (F ∪ G)\n∪-range-⊆ _ (inj₁ ⟨ a , fab ⟩) = ⟨ a , inj₁ fab ⟩\n∪-range-⊆ _ (inj₂ ⟨ a , gab ⟩) = ⟨ a , inj₂ gab ⟩\n\n-- =========== SOLUTION TO TASK 2 STARTS HERE ===========\n\n-- range-theorem-2\nrange-∩-⊆ : ∀ {A B} {F G : Relation A B}\n → Range (F ∩ G) ⊆ (Range F ∩ Range G)\nrange-∩-⊆ b b∈RangeF∩G = -- Given \"b ∈ Range (F ∩ G)\", we need to prove that \"b ∈ (Range F ∩ Range G)\"\n let\n ⟨ a , a,b∈F∩G ⟩ = b∈RangeF∩G -- (1) if \"b ∈ Range (F ∩ G)\" then there exists 'a' such that \"(a,b) ∈ (F ∩ G)\"\n ⟨ a,b∈F , a,b∈G ⟩ = a,b∈F∩G -- (2) per definition of intersection, if \"(a,b) ∈ (F ∩ G)\" then \"(a,b) ∈ F\" and \"(a,b) ∈ G\"\n b∈RangeF = ⟨ a , a,b∈F ⟩ -- (3) from (1) we know there is an 'a' such that \"(a,b) ∈ F\" (2), so \"b ∈ Range F\", per definition of Range\n b∈RangeG = ⟨ a , a,b∈G ⟩ -- (4) as above, \"b ∈ Range G\" because of 'a' (1) and \"(a,b) ∈ F\" (2)\n b∈RangeF∩RangeG = ⟨ b∈RangeF , b∈RangeG ⟩ -- (5) given \"b ∈ Range F\" (3) and \"b ∈ Range G\" (4), and definition of ∩ \"b ∈ Range F ∩ Range G\". QED\n in b∈RangeF∩RangeG\n\n-- dom-theorem-3\ndom-/-⊆ : ∀ {A B} {F G : Relation A B}\n → (Dom F / Dom G) ⊆ Dom (F / G)\ndom-/-⊆ a a∈DomF/DomG = -- Given \"a ∈ (Dom F / Dom G)\", we need to prove that \"a ∈ Dom (F / G)\"\n let\n ⟨ a∈DomF , ¬a∈DomG ⟩ = a∈DomF/DomG -- (1) per definition of '/', \"a ∈ (Dom F / Dom G)\" is the same as \"a ∈ Dom F\" and \"¬ a ∈ Dom G\"\n ⟨ b , a,b∈F ⟩ = a∈DomF -- (2) per definition of 'Dom', if \"a ∈ Dom F\" then there exists 'b' such that \"(a,b) ∈ F\"\n ¬a,b∈G = -- (3) From \"¬ a ∈ Dom G\" we can prove that \"¬ (a, b₁) ∈ G\" for any 'b₁'\n λ{ a,b∈G → -- (a) By contradiction, suposse that \"(a, b₁) ∈ G\" for some 'b₁'\n let a∈DomG = ⟨ _ , a,b∈G ⟩ -- (b) per definition of 'Dom', \"a ∈ Dom G\"\n in ¬a∈DomG a∈DomG } -- We know that \"¬ a ∈ Dom G\" (3) and \"a ∈ Dom G\" (b). Nonesense! So, \"¬ (a, b₁) ∈ G\" for all 'b₁'\n a,b∈F/G = ⟨ a,b∈F , ¬a,b∈G ⟩ -- (4) per definition of '/' and given (2) and (3), \"(a, b) ∈ F/G\"\n a∈DomF/G = ⟨ b , a,b∈F/G ⟩ -- (5) per definition of 'Dom' and given (4) and 'b', we have that \"a ∈ Dom (F / G)\". QED\n in a∈DomF/G\n\n-- range-theorem-3\n/-range-⊆ : ∀ {A B} {F G : Relation A B}\n → (Range F / Range G) ⊆ Range (F / G)\n/-range-⊆ b b∈RangeF/RangeG = -- Given \"b ∈ (Range F / Range G)\", we need to prove that \"b ∈ Range (F / G)\"\n let\n ⟨ b∈RangeF , ¬b∈RangeG ⟩ = b∈RangeF/RangeG -- (1) per definition of '/', \"b ∈ Range F\" and \"¬ b ∈ Range G\"\n ⟨ a , a,b∈F ⟩ = b∈RangeF -- (2) per definition of 'Range', there exists 'a' such that \"(a,b) ∈ F\"\n ¬a,b∈G = -- (3) by contradiction, we will prove that \"¬ (a, b) ∈ G\" given (1)\n λ{ a,b∈G → -- (a) suppose that there exists 'a₁' such that \"(a₁, b) ∈ G\"\n let b∈RangeG = ⟨ _ , a,b∈G ⟩ -- (b) per definition of Range and given (a), \"b ∈ Range G\"\n in ¬b∈RangeG b∈RangeG } -- (c) we know from (1) that \"¬ b ∈ Range G\" but (b) says \"b ∈ Range G\". Nonesense!\n a,b∈F/G = ⟨ a,b∈F , ¬a,b∈G ⟩ -- (4) per definition of '/' and given (2) and (3), then \"(a, b) ∈ F / G\"\n b∈RangeF/G = ⟨ a , a,b∈F/G ⟩ -- (5) per definition of 'Range' and given 'a' and (4), we know that \"b ∈ Range (F / G)\". QED\n in b∈RangeF/G\n\n-- Class exercise\n-- This is not really an exercise at all because this is the definition of `⊆`!\nexercise103a : ∀ {a} {A B : Subset a}\n → (∀ x → x ∈ A → x ∈ B)\n → A ⊆ B\nexercise103a x→x∈A→x∈B = x→x∈A→x∈B\n\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; cong)\n\nexercise103id→ : ∀ {a} {A B : Subset a}\n → A ≡ B → A ⊆ B × B ⊆ A\nexercise103id→ refl = ⟨ (λ{_ p → p}) , (λ{_ p → p}) ⟩\n\n--exercise103id← : ∀ {a} {A B : Subset a}\n-- → A ⊆ B × B ⊆ A → A ≡ B\n--exercise103id← ⟨ A⊆B , B⊆A ⟩ = ? -- Probably impossible to prove without unification. Possibly, impossible to prove. Needs `postulate`\n\nexercise108a : ∀ {a} {A B : Subset a} (z : a)\n → (z ∈ A) × (z ∈ B) → z ∈ (A ∩ B)\nexercise108a _ ⟨ z∈A , z∈B ⟩ = ⟨ z∈A , z∈B ⟩ -- How to explain this?\n", "meta": {"hexsha": "991d20417ec37f543576c568e56e2425f33025b2", "size": 5773, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "proglangs-learning/Agda/sv20/assign2/Second.agda", "max_stars_repo_name": "helq/old_code", "max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "proglangs-learning/Agda/sv20/assign2/Second.agda", "max_issues_repo_name": "helq/old_code", "max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z", "max_forks_repo_path": "proglangs-learning/Agda/sv20/assign2/Second.agda", "max_forks_repo_name": "helq/old_code", "max_forks_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.3418803419, "max_line_length": 148, "alphanum_fraction": 0.5084011779, "num_tokens": 2263, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199511728004, "lm_q2_score": 0.7461389986757757, "lm_q1q2_score": 0.6249809116389254}} {"text": "{-# OPTIONS --without-K #-}\nmodule equality.reasoning where\n\nopen import equality.core\n\nmodule ≡-Reasoning {i} {X : Set i} where\n infix 4 _IsRelatedTo_\n infix 2 _∎\n infixr 2 _≡⟨_⟩_\n infix 1 begin_\n\n -- This seemingly unnecessary type is used to make it possible to\n -- infer arguments even if the underlying equality evaluates.\n\n data _IsRelatedTo_ (x y : X) : Set i where\n relTo : x ≡ y → x IsRelatedTo y\n\n begin_ : ∀ {x y} → x IsRelatedTo y → x ≡ y\n begin relTo p = p\n\n _≡⟨_⟩_ : ∀ x {y z} → x ≡ y → y IsRelatedTo z → x IsRelatedTo z\n _ ≡⟨ p ⟩ relTo q = relTo (p · q)\n\n _∎ : ∀ x → x IsRelatedTo x\n _∎ _ = relTo refl\n", "meta": {"hexsha": "2b9cf9cb14075781e0330ad98ce3f86c1e4bf0b9", "size": 636, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "equality/reasoning.agda", "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_issues_repo_path": "equality/reasoning.agda", "max_issues_repo_name": "HoTT/M-types", "max_issues_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-02-11T11:14:59.000Z", "max_issues_repo_issues_event_max_datetime": "2015-02-11T15:20:34.000Z", "max_forks_repo_path": "equality/reasoning.agda", "max_forks_repo_name": "HoTT/M-types", "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z", "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z", "avg_line_length": 24.4615384615, "max_line_length": 67, "alphanum_fraction": 0.6289308176, "num_tokens": 238, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.877476793890012, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.6249672188910835}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- The universal binary relation\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Relation.Binary.Construct.Always where\n\nopen import Relation.Binary\nopen import Relation.Binary.Construct.Constant using (Const)\nopen import Data.Unit using (⊤; tt)\nopen import Level using (Lift; lift)\n\n------------------------------------------------------------------------\n-- Definition\n\nAlways : ∀ {a ℓ} {A : Set a} → Rel A ℓ\nAlways = Const (Lift _ ⊤)\n\n------------------------------------------------------------------------\n-- Properties\n\nmodule _ {a} (A : Set a) ℓ where\n\n refl : Reflexive {ℓ = ℓ} {A} Always\n refl = lift tt\n\n sym : Symmetric {ℓ = ℓ} {A} Always\n sym _ = lift tt\n\n trans : Transitive {ℓ = ℓ} {A} Always\n trans _ _ = lift tt\n\n isEquivalence : IsEquivalence {ℓ = ℓ} {A} Always\n isEquivalence = record {}\n\n setoid : Setoid a ℓ\n setoid = record\n { isEquivalence = isEquivalence\n }\n\n------------------------------------------------------------------------\n-- DEPRECATED NAMES\n------------------------------------------------------------------------\n-- Please use the new names as continuing support for the old names is\n-- not guaranteed.\n\n-- Version 0.17\n\nAlways-setoid = setoid\n{-# WARNING_ON_USAGE Always-setoid\n\"Warning: Always-setoid was deprecated in v0.14.\nPlease use setoid instead.\"\n#-}\n", "meta": {"hexsha": "dbfcad5ce678e1392ddef21332816ddcdd45c391", "size": 1485, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Always.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Always.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Always.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.0526315789, "max_line_length": 72, "alphanum_fraction": 0.4801346801, "num_tokens": 328, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8774767874818408, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.6249672143269777}} {"text": "\nmodule Numeric.Nat.GCD.Properties where\n\nopen import Prelude\nopen import Numeric.Nat.Properties\nopen import Numeric.Nat.Divide\nopen import Numeric.Nat.Divide.Properties\nopen import Numeric.Nat.GCD\nopen import Numeric.Nat.GCD.Extended\nopen import Tactic.Nat\nopen import Tactic.Cong\n\ngcd-is-gcd : ∀ d a b → gcd! a b ≡ d → IsGCD d a b\ngcd-is-gcd d a b refl with gcd a b\n... | gcd-res _ isgcd = isgcd\n\ngcd-divides-l : ∀ a b → gcd! a b Divides a\ngcd-divides-l a b with gcd a b\n... | gcd-res _ i = IsGCD.d|a i\n\ngcd-divides-r : ∀ a b → gcd! a b Divides b\ngcd-divides-r a b with gcd a b\n... | gcd-res _ i = IsGCD.d|b i\n\nis-gcd-unique : ∀ {a b} d₁ d₂ (g₁ : IsGCD d₁ a b) (g₂ : IsGCD d₂ a b) → d₁ ≡ d₂\nis-gcd-unique d d′ (is-gcd d|a d|b gd) (is-gcd d′|a d′|b gd′) =\n divides-antisym (gd′ d d|a d|b)\n (gd d′ d′|a d′|b)\n\ngcd-unique : ∀ a b d → IsGCD d a b → gcd! a b ≡ d\ngcd-unique a b d pd with gcd a b\n... | gcd-res d′ pd′ = is-gcd-unique d′ d pd′ pd\n\nis-gcd-commute : ∀ {d a b} → IsGCD d a b → IsGCD d b a\nis-gcd-commute (is-gcd d|a d|b g) = is-gcd d|b d|a (flip ∘ g)\n\ngcd-commute : ∀ a b → gcd! a b ≡ gcd! b a\ngcd-commute a b with gcd b a\ngcd-commute a b | gcd-res d p = gcd-unique a b d (is-gcd-commute p)\n\ngcd-factor-l : ∀ {a b} → a Divides b → gcd! a b ≡ a\ngcd-factor-l {a} (factor! b) =\n gcd-unique a (b * a) a\n (is-gcd divides-refl (divides-mul-r b divides-refl) λ _ k|a _ → k|a)\n\ngcd-factor-r : ∀ {a b} → b Divides a → gcd! a b ≡ b\ngcd-factor-r {a} {b} b|a = gcd-commute a b ⟨≡⟩ gcd-factor-l b|a\n\ngcd-idem : ∀ a → gcd! a a ≡ a\ngcd-idem a = gcd-factor-l divides-refl\n\ngcd-zero-l : ∀ n → gcd! 0 n ≡ n\ngcd-zero-l n = gcd-unique 0 n n (is-gcd (factor! 0) divides-refl λ _ _ k|n → k|n)\n\ngcd-zero-r : ∀ n → gcd! n 0 ≡ n\ngcd-zero-r n = gcd-commute n 0 ⟨≡⟩ gcd-zero-l n\n\nzero-is-gcd-l : ∀ {a b} → IsGCD 0 a b → a ≡ 0\nzero-is-gcd-l (is-gcd 0|a _ _) = divides-zero 0|a\n\nzero-is-gcd-r : ∀ {a b} → IsGCD 0 a b → b ≡ 0\nzero-is-gcd-r (is-gcd _ 0|b _) = divides-zero 0|b\n\nzero-gcd-l : ∀ a b → gcd! a b ≡ 0 → a ≡ 0\nzero-gcd-l a b eq with gcd a b\nzero-gcd-l a b refl | gcd-res .0 p = zero-is-gcd-l p\n\nzero-gcd-r : ∀ a b → gcd! a b ≡ 0 → b ≡ 0\nzero-gcd-r a b eq with gcd a b\nzero-gcd-r a b refl | gcd-res .0 p = zero-is-gcd-r p\n\nnonzero-is-gcd-l : ∀ {a b d} {{_ : NonZero a}} → IsGCD d a b → NonZero d\nnonzero-is-gcd-l {0} {{}} _\nnonzero-is-gcd-l {a@(suc _)} {d = suc _} _ = _\nnonzero-is-gcd-l {a@(suc _)} {d = 0} (is-gcd (factor q eq) _ _) = refute eq\n\nnonzero-is-gcd-r : ∀ {a b d} {{_ : NonZero b}} → IsGCD d a b → NonZero d\nnonzero-is-gcd-r isgcd = nonzero-is-gcd-l (is-gcd-commute isgcd)\n\nnonzero-gcd-l : ∀ a b {{_ : NonZero a}} → NonZero (gcd! a b)\nnonzero-gcd-l a b = nonzero-is-gcd-l (GCD.isGCD (gcd a b))\n\nnonzero-gcd-r : ∀ a b {{_ : NonZero b}} → NonZero (gcd! a b)\nnonzero-gcd-r a b = nonzero-is-gcd-r (GCD.isGCD (gcd a b))\n\nprivate\n _|>_ = divides-trans\n\ngcd-assoc : ∀ a b c → gcd! a (gcd! b c) ≡ gcd! (gcd! a b) c\ngcd-assoc a b c with gcd a b | gcd b c\n... | gcd-res ab (is-gcd ab|a ab|b gab)\n | gcd-res bc (is-gcd bc|b bc|c gbc) with gcd ab c\n... | gcd-res ab-c (is-gcd abc|ab abc|c gabc) =\n gcd-unique a bc ab-c\n (is-gcd (abc|ab |> ab|a)\n (gbc ab-c (abc|ab |> ab|b) abc|c)\n λ k k|a k|bc → gabc k (gab k k|a (k|bc |> bc|b))\n (k|bc |> bc|c))\n\n-- Coprimality properties\n\ncoprime-sym : ∀ a b → Coprime a b → Coprime b a\ncoprime-sym a b p = gcd-commute b a ⟨≡⟩ p\n\ncoprimeByDivide : ∀ a b → (∀ k → k Divides a → k Divides b → k Divides 1) → Coprime a b\ncoprimeByDivide a b g = gcd-unique a b 1 (is-gcd one-divides one-divides g)\n\ndivide-coprime : ∀ d a b → Coprime a b → d Divides a → d Divides b → d Divides 1\ndivide-coprime d a b p d|a d|b with gcd a b\ndivide-coprime d a b refl d|a d|b | gcd-res _ (is-gcd _ _ g) =\n g d d|a d|b\n\nmul-coprime-l : ∀ a b c → Coprime a (b * c) → Coprime a b\nmul-coprime-l a b c a⊥bc =\n coprimeByDivide a b λ k k|a k|b →\n divide-coprime k a (b * c) a⊥bc k|a (divides-mul-l c k|b)\n\nmul-coprime-r : ∀ a b c → Coprime a (b * c) → Coprime a c\nmul-coprime-r a b c a⊥bc = mul-coprime-l a c b (transport (Coprime a) auto a⊥bc)\n\nis-gcd-factors-coprime : ∀ {a b d} (p : IsGCD d a b) {{_ : NonZero d}} →\n Coprime (is-gcd-factor₁ p) (is-gcd-factor₂ p)\nis-gcd-factors-coprime {a} {b} {0} _ {{}}\nis-gcd-factors-coprime {a} {b} {d@(suc _)} p@(is-gcd (factor qa refl) (factor qb refl) g) with gcd qa qb\n... | gcd-res j (is-gcd j|qa j|qb gj) = lem₃ j lem₂\n where\n lem : IsGCD (j * d) a b\n lem = is-gcd (divides-mul-cong-r d j|qa) (divides-mul-cong-r d j|qb) λ k k|a k|b →\n divides-mul-r j (g k k|a k|b)\n\n lem₂ : d ≡ j * d\n lem₂ = is-gcd-unique d (j * d) p lem\n\n lem₃ : ∀ j → d ≡ j * d → j ≡ 1\n lem₃ 0 ()\n lem₃ 1 _ = refl\n lem₃ (suc (suc n)) eq = refute eq\n\nprivate\n mul-gcd-distr-l' : ∀ a b c ⦃ a>0 : NonZero a ⦄ ⦃ b>0 : NonZero b ⦄ → gcd! (a * b) (a * c) ≡ a * gcd! b c\n mul-gcd-distr-l' a b c with gcd b c | gcd (a * b) (a * c)\n ... | gcd-res d gcd-bc@(is-gcd (factor! b′) (factor! c′) _)\n | gcd-res δ gcd-abac@(is-gcd (factor u uδ=ab) (factor v vδ=ac) g) =\n let instance _ = nonzero-is-gcd-l gcd-bc\n _ : NonZero (d * a)\n _ = mul-nonzero d a\n in case g (d * a) (factor b′ auto) (factor c′ auto) of λ where\n (factor w wda=δ) →\n let dab′=dauw =\n d * a * b′ ≡⟨ by uδ=ab ⟩\n u * δ ≡⟨ u *_ $≡ wda=δ ⟩ʳ\n u * (w * (d * a)) ≡⟨ auto ⟩\n d * a * (u * w) ∎\n dac′=davw =\n d * a * c′ ≡⟨ by vδ=ac ⟩\n v * δ ≡⟨ v *_ $≡ wda=δ ⟩ʳ\n v * (w * (d * a)) ≡⟨ auto ⟩\n d * a * (v * w) ∎\n\n uw=b′ : u * w ≡ b′\n uw=b′ = sym (mul-inj₂ (d * a) b′ (u * w) dab′=dauw)\n vw=c′ : v * w ≡ c′\n vw=c′ = sym (mul-inj₂ (d * a) c′ (v * w) dac′=davw)\n w=1 : w ≡ 1\n w=1 = divides-one (divide-coprime w b′ c′ (is-gcd-factors-coprime gcd-bc)\n (factor u uw=b′)\n (factor v vw=c′))\n in case w=1 of λ where refl → by wda=δ\n\nmul-gcd-distr-l : ∀ a b c → gcd! (a * b) (a * c) ≡ a * gcd! b c\nmul-gcd-distr-l zero b c = refl\nmul-gcd-distr-l a zero c = (λ z → gcd! z (a * c)) $≡ mul-zero-r a\nmul-gcd-distr-l a@(suc _) b@(suc _) c = mul-gcd-distr-l' a b c\n\nmul-gcd-distr-r : ∀ a b c → gcd! (a * c) (b * c) ≡ gcd! a b * c\nmul-gcd-distr-r a b c =\n gcd! (a * c) (b * c)\n ≡⟨ gcd! $≡ mul-commute a c *≡ mul-commute b c ⟩\n gcd! (c * a) (c * b)\n ≡⟨ mul-gcd-distr-l c a b ⟩\n c * gcd! a b\n ≡⟨ auto ⟩\n gcd! a b * c ∎\n\n-- Divide two numbers by their gcd and return the result, the gcd, and some useful properties.\n-- Continuation-passing for efficiency reasons.\ngcdReduce' : ∀ {a} {A : Set a} (a b : Nat) ⦃ _ : NonZero b ⦄ →\n ((a′ b′ d : Nat) → (⦃ _ : NonZero a ⦄ → NonZero a′) →\n ⦃ nzb : NonZero b′ ⦄ → ⦃ nzd : NonZero d ⦄ →\n a′ * d ≡ a → b′ * d ≡ b →\n Coprime a′ b′ → A) → A\ngcdReduce' a b ret with gcd a b\ngcdReduce' a b ret | gcd-res d isgcd@(is-gcd d|a@(factor a′ eqa) d|b@(factor b′ eqb) g)=\n let instance _ = nonzero-is-gcd-r isgcd in\n ret a′ b′ d (nonzero-factor d|a) ⦃ nonzero-factor d|b ⦄\n eqa eqb\n (is-gcd-factors-coprime isgcd)\n\n-- Both arguments are non-zero.\ngcdReduce : ∀ {a} {A : Set a} (a b : Nat) ⦃ _ : NonZero a ⦄ ⦃ _ : NonZero b ⦄ →\n ((a′ b′ d : Nat) ⦃ a′>0 : NonZero a′ ⦄ ⦃ b′>0 : NonZero b′ ⦄ ⦃ nzd : NonZero d ⦄ →\n a′ * d ≡ a → b′ * d ≡ b → Coprime a′ b′ → A) → A\ngcdReduce a b k = gcdReduce' a b λ a′ b′ d a′>0 eq₁ eq₂ a′⊥b′ →\n let instance _ = a′>0 in k a′ b′ d eq₁ eq₂ a′⊥b′\n\n-- Only the right argument is guaranteed to be non-zero.\ngcdReduce-r : ∀ {a} {A : Set a} (a b : Nat) ⦃ _ : NonZero b ⦄ →\n ((a′ b′ d : Nat) ⦃ nzb : NonZero b′ ⦄ ⦃ nzd : NonZero d ⦄ →\n a′ * d ≡ a → b′ * d ≡ b → Coprime a′ b′ → A) → A\ngcdReduce-r a b k = gcdReduce' a b λ a′ b′ d _ eq₁ eq₂ a′⊥b′ →\n k a′ b′ d eq₁ eq₂ a′⊥b′\n\n--- Properties ---\n\ncoprime-divide-mul-l : ∀ a b c → Coprime a b → a Divides (b * c) → a Divides c\ncoprime-divide-mul-l a b c p a|bc with extendedGCD a b\ncoprime-divide-mul-l a b c p a|bc | gcd-res d i e with gcd-unique _ _ _ i ʳ⟨≡⟩ p\ncoprime-divide-mul-l a b c p (factor q qa=bc) | gcd-res d i (bézoutL x y ax=1+by) | refl =\n factor (x * c - y * q) $\n (x * c - y * q) * a\n ≡⟨ auto ⟩\n a * x * c - y * (q * a)\n ≡⟨ by-cong ax=1+by ⟩\n suc (b * y) * c - y * (q * a)\n ≡⟨ by-cong qa=bc ⟩\n suc (b * y) * c - y * (b * c)\n ≡⟨ auto ⟩\n c ∎\ncoprime-divide-mul-l a b c p (factor q qa=bc) | gcd-res d i (bézoutR x y by=1+ax) | refl =\n factor (y * q - x * c) $\n (y * q - x * c) * a\n ≡⟨ auto ⟩\n y * (q * a) - a * x * c\n ≡⟨ by-cong qa=bc ⟩\n y * (b * c) - a * x * c\n ≡⟨ auto ⟩\n (b * y) * c - a * x * c\n ≡⟨ by-cong by=1+ax ⟩\n suc (a * x) * c - a * x * c\n ≡⟨ auto ⟩\n c ∎\n\ncoprime-divide-mul-r : ∀ a b c → Coprime a c → a Divides (b * c) → a Divides b\ncoprime-divide-mul-r a b c p a|bc =\n coprime-divide-mul-l a c b p (transport (a Divides_) auto a|bc)\n\nis-gcd-by-coprime-factors : ∀ d a b (d|a : d Divides a) (d|b : d Divides b) ⦃ nzd : NonZero d ⦄ →\n Coprime (get-factor d|a) (get-factor d|b) →\n IsGCD d a b\nis-gcd-by-coprime-factors d a b d|a@(factor! q) d|b@(factor! r) q⊥r =\n is-gcd d|a d|b λ k k|a k|b →\n let lem : ∀ j → j Divides q → j Divides r → j ≡ 1\n lem j j|q j|r = divides-one (divide-coprime j q r q⊥r j|q j|r)\n in\n case gcd k d of λ where\n (gcd-res g isgcd@(is-gcd (factor k′ k′g=k@refl) (factor d′ d′g=d@refl) sup)) →\n let instance g>0 = nonzero-is-gcd-r isgcd\n k′⊥d′ : Coprime k′ d′\n k′⊥d′ = is-gcd-factors-coprime isgcd\n k′|qd′ : k′ Divides (q * d′)\n k′|qd′ = cancel-mul-divides-r k′ (q * d′) g\n (transport ((k′ * g) Divides_) {x = q * (d′ * g)} {q * d′ * g} auto k|a)\n k′|rd′ : k′ Divides (r * d′)\n k′|rd′ = cancel-mul-divides-r k′ (r * d′) g\n (transport ((k′ * g) Divides_) {x = r * (d′ * g)} {r * d′ * g} auto k|b)\n k′|q : k′ Divides q\n k′|q = coprime-divide-mul-r k′ q d′ k′⊥d′ k′|qd′\n k′|r : k′ Divides r\n k′|r = coprime-divide-mul-r k′ r d′ k′⊥d′ k′|rd′\n k′=1 = lem k′ k′|q k′|r\n k=g : k ≡ g\n k=g = case k′=1 of λ where refl → auto\n in factor d′ (d′ *_ $≡ k=g ⟨≡⟩ d′g=d)\n", "meta": {"hexsha": "546e05440b1350f625df2c71511a89829666644c", "size": 10784, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Numeric/Nat/GCD/Properties.agda", "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 111, "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_issues_repo_path": "src/Numeric/Nat/GCD/Properties.agda", "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_forks_repo_path": "src/Numeric/Nat/GCD/Properties.agda", "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "avg_line_length": 39.3576642336, "max_line_length": 106, "alphanum_fraction": 0.5026891691, "num_tokens": 4584, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059414036511, "lm_q2_score": 0.7879312056025699, "lm_q1q2_score": 0.62491292058074}} {"text": "-- Andreas, 2012-09-15\n-- Positive effects of making Agda recognize constant functions.\n-- Arguments to constant functions are ignored in definitional equality.\n{-# OPTIONS --copatterns #-}\nmodule NonvariantPolarity where\n\nopen import Common.Equality\n\ndata ⊥ : Set where\nrecord ⊤ : Set where\n constructor trivial\n\ndata Bool : Set where\n true false : Bool\n\nTrue : Bool → Set\nTrue true = ⊤\nTrue false = ⊥\n\nmodule IgnoreArg where\n\n -- A function ignoring its first argument\n knot : Bool → Bool → Bool\n knot x true = false\n knot x false = true\n\n test : (y : Bool) → knot true y ≡ knot false y\n test y = refl\n\nmodule UnusedModulePar where\n\n -- An unused module parameter\n module M (x : Bool) where\n\n not : Bool → Bool\n not true = false\n not false = true\n\n open M true\n open M false renaming (not to not′)\n\n test : (y : Bool) → not y ≡ not′ y\n test y = refl\n\nmodule Absurd where\n\n -- Absurd patterns do not count as matches; abort is constant in its 2nd arg.\n abort : (A : Set) → ⊥ → A\n abort A ()\n\n test : (x y : ⊥) → abort Bool x ≡ abort Bool y\n test x y = refl\n\nmodule ProofIrrelevance where\n\n -- Record and absurd patterns do not count as match.\n fun : (b : Bool) → True b → Bool\n fun true trivial = true\n fun false ()\n\n -- This gives us a kind of proof irrelevance.\n test : (b : Bool) → (x y : True b) → fun b x ≡ fun b y\n test b x y = refl\n\nmodule CoinductiveUnit where\n\n record Unit : Set where\n coinductive\n constructor delay\n field force : Unit\n open Unit\n\n -- The identity on Unit does not match on its argument, so it is constant.\n id : Unit → Unit\n force (id x) = id (force x)\n\n idConst : (x y : Unit) → id x ≡ id y\n idConst x y = refl\n\n -- That does not imply x ≡ y (needs bisimulation).\n\n", "meta": {"hexsha": "781e0e82139ebf59070138bcf9e6b226166a1ed2", "size": 1752, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/NonvariantPolarity.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "test/succeed/NonvariantPolarity.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/NonvariantPolarity.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 21.3658536585, "max_line_length": 79, "alphanum_fraction": 0.654109589, "num_tokens": 520, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.7879311931529758, "lm_q1q2_score": 0.624912918413223}} {"text": "\nopen import Oscar.Prelude\nopen import Oscar.Class\nopen import Oscar.Class.Leftunit\nopen import Oscar.Class.Reflexivity\nopen import Oscar.Class.Transitivity\nopen import Oscar.Class.Transleftidentity\n\nmodule Oscar.Class.Transleftidentity.ToLeftunit where\n\nmodule _\n {𝔬} {𝔒 : Ø 𝔬}\n {𝔯} {_∼_ : 𝔒 → 𝔒 → Ø 𝔯}\n {ℓ} {_∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ}\n {ε : Reflexivity.type _∼_}\n {transitivity : Transitivity.type _∼_}\n where\n instance\n toLeftunitFromTransleftidentity :\n ⦃ _ : Transleftidentity.class _∼_ _∼̇_ ε transitivity ⦄\n → ∀ {x y} {f : x ∼ y} → Leftunit.class _∼̇_ ε (flip transitivity) f\n toLeftunitFromTransleftidentity .⋆ = transleftidentity\n", "meta": {"hexsha": "53aa3d8f69e51d639420f0de3a4ffaa7e636a1d5", "size": 673, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Transleftidentity/ToLeftunit.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Transleftidentity/ToLeftunit.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Transleftidentity/ToLeftunit.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.2608695652, "max_line_length": 73, "alphanum_fraction": 0.690936107, "num_tokens": 244, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9390248242542284, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.6248370267535459}} {"text": "open import Level\nopen import Ordinals\nmodule OrdUtil {n : Level} (O : Ordinals {n} ) where\n\nopen import logic\nopen import nat\nopen import Data.Nat renaming ( zero to Zero ; suc to Suc ; ℕ to Nat ; _⊔_ to _n⊔_ ) \nopen import Data.Empty\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary\nopen import Relation.Binary hiding (_⇔_)\n\nopen Ordinals.Ordinals O\nopen Ordinals.IsOrdinals isOrdinal \nopen Ordinals.IsNext isNext \n\no<-dom : { x y : Ordinal } → x o< y → Ordinal \no<-dom {x} _ = x\n\no<-cod : { x y : Ordinal } → x o< y → Ordinal \no<-cod {_} {y} _ = y\n\no<-subst : {Z X z x : Ordinal } → Z o< X → Z ≡ z → X ≡ x → z o< x\no<-subst df refl refl = df\n\no<¬≡ : { ox oy : Ordinal } → ox ≡ oy → ox o< oy → ⊥\no<¬≡ {ox} {oy} eq lt with trio< ox oy\no<¬≡ {ox} {oy} eq lt | tri< a ¬b ¬c = ¬b eq\no<¬≡ {ox} {oy} eq lt | tri≈ ¬a b ¬c = ¬a lt\no<¬≡ {ox} {oy} eq lt | tri> ¬a ¬b c = ¬b eq\n\no<> : {x y : Ordinal } → y o< x → x o< y → ⊥\no<> {ox} {oy} lt tl with trio< ox oy\no<> {ox} {oy} lt tl | tri< a ¬b ¬c = ¬c lt\no<> {ox} {oy} lt tl | tri≈ ¬a b ¬c = ¬a tl\no<> {ox} {oy} lt tl | tri> ¬a ¬b c = ¬a tl\n\nosuc-< : { x y : Ordinal } → y o< osuc x → x o< y → ⊥\nosuc-< {x} {y} y x x < osuc x -> y = x ∨ x < y → ⊥\nosucc {ox} {oy} oy ¬a ¬b c with osuc-≡< c\nosucc {ox} {oy} oy ¬a ¬b c | case1 eq = ⊥-elim (o<¬≡ (sym eq) oy ¬a ¬b c | case2 lt = ⊥-elim (o<> lt oy ¬a ¬b c = ⊥-elim (o<> (osucc c) oy ¬a ¬b c = ⊥-elim ( o<¬≡ refl (a→b c ) )\n\nmaxα : Ordinal → Ordinal → Ordinal\nmaxα x y with trio< x y\nmaxα x y | tri< a ¬b ¬c = y\nmaxα x y | tri> ¬a ¬b c = x\nmaxα x y | tri≈ ¬a refl ¬c = x\n\nomin : Ordinal → Ordinal → Ordinal\nomin x y with trio< x y\nomin x y | tri< a ¬b ¬c = x\nomin x y | tri> ¬a ¬b c = y\nomin x y | tri≈ ¬a refl ¬c = x\n\nmin1 : {x y z : Ordinal } → z o< x → z o< y → z o< omin x y\nmin1 {x} {y} {z} z ¬a ¬b c = z ¬a ¬b c = osuc x\nomax x y | tri≈ ¬a refl ¬c = osuc x\n\nomax< : ( x y : Ordinal ) → x o< y → osuc y ≡ omax x y\nomax< x y lt with trio< x y\nomax< x y lt | tri< a ¬b ¬c = refl\nomax< x y lt | tri≈ ¬a b ¬c = ⊥-elim (¬a lt )\nomax< x y lt | tri> ¬a ¬b c = ⊥-elim (¬a lt )\n\nomax≤ : ( x y : Ordinal ) → x o≤ y → osuc y ≡ omax x y\nomax≤ x y le with trio< x y\nomax≤ x y le | tri< a ¬b ¬c = refl\nomax≤ x y le | tri≈ ¬a refl ¬c = refl\nomax≤ x y le | tri> ¬a ¬b c with osuc-≡< le\nomax≤ x y le | tri> ¬a ¬b c | case1 eq = ⊥-elim (¬b eq)\nomax≤ x y le | tri> ¬a ¬b c | case2 x ¬a ¬b c = ⊥-elim (¬b eq )\n\nomax-x : ( x y : Ordinal ) → x o< omax x y\nomax-x x y with trio< x y\nomax-x x y | tri< a ¬b ¬c = ordtrans a <-osuc\nomax-x x y | tri> ¬a ¬b c = <-osuc\nomax-x x y | tri≈ ¬a refl ¬c = <-osuc\n\nomax-y : ( x y : Ordinal ) → y o< omax x y\nomax-y x y with trio< x y\nomax-y x y | tri< a ¬b ¬c = <-osuc\nomax-y x y | tri> ¬a ¬b c = ordtrans c <-osuc\nomax-y x y | tri≈ ¬a refl ¬c = <-osuc\n\nomxx : ( x : Ordinal ) → omax x x ≡ osuc x\nomxx x with trio< x x\nomxx x | tri< a ¬b ¬c = ⊥-elim (¬b refl )\nomxx x | tri> ¬a ¬b c = ⊥-elim (¬b refl )\nomxx x | tri≈ ¬a refl ¬c = refl\n\nomxxx : ( x : Ordinal ) → omax x (omax x x ) ≡ osuc (osuc x)\nomxxx x = trans ( cong ( λ k → omax x k ) (omxx x )) (sym ( omax< x (osuc x) <-osuc ))\n\nopen _∧_\n\no≤-refl : { i j : Ordinal } → i ≡ j → i o≤ j\no≤-refl {i} {j} eq = subst (λ k → i o< osuc k ) eq <-osuc\nOrdTrans : Transitive _o≤_\nOrdTrans a≤b b≤c with osuc-≡< a≤b | osuc-≡< b≤c\nOrdTrans a≤b b≤c | case1 refl | case1 refl = <-osuc\nOrdTrans a≤b b≤c | case1 refl | case2 a≤c = ordtrans a≤c <-osuc\nOrdTrans a≤b b≤c | case2 a≤c | case1 refl = ordtrans a≤c <-osuc\nOrdTrans a≤b b≤c | case2 a ¬a ¬b c = ⊥-elim ( ¬x<0 c )\n\nnext< : {x y z : Ordinal} → x o< next z → y o< next x → y o< next z\nnext< {x} {y} {z} x ¬a ¬b c = ⊥-elim (¬nx osuc x o< next x o< next (osuc x) -> next x ≡ osuc z -> z o o< next x -> osuc z o< next x -> next x o< next x\nnexto≡ {x} | tri< a ¬b ¬c = ⊥-elim (¬nx osuc x o< next (osuc x) o< next x -> next (osuc x) ≡ osuc z -> z o o< next (osuc x) ...\nnexto≡ {x} | tri> ¬a ¬b c = ⊥-elim (¬nx ¬a ¬b c = -- x < y < next y < next x\n ⊥-elim ( ¬nx ¬a ¬b c with osuc-≡< x≤y\n≤next {x} {y} x≤y | tri> ¬a ¬b c | case1 refl = o≤-refl refl -- x = y < next x\n≤next {x} {y} x≤y | tri> ¬a ¬b c | case2 x ¬a ¬b c = o≤-refl (sym ( x ¬a ¬b c = subst (λ k → osuc x o< k ) nexto≡ (osuc ¬a ¬b c = osuc ¬a ¬b c = subst (λ k → x o< k ) nexto≡ xnx\n\nrecord OrdinalSubset (maxordinal : Ordinal) : Set (suc n) where\n field\n os→ : (x : Ordinal) → x o< maxordinal → Ordinal\n os← : Ordinal → Ordinal\n os←limit : (x : Ordinal) → os← x o< maxordinal\n os-iso← : {x : Ordinal} → os→ (os← x) (os←limit x) ≡ x\n os-iso→ : {x : Ordinal} → (lt : x o< maxordinal ) → os← (os→ x lt) ≡ x\n\nmodule o≤-Reasoning {n : Level} (O : Ordinals {n} ) where\n\n -- open inOrdinal O\n\n resp-o< : _o<_ Respects₂ _≡_\n resp-o< = resp₂ _o<_\n\n trans1 : {i j k : Ordinal} → i o< j → j o< osuc k → i o< k\n trans1 {i} {j} {k} i\n\nmodule Data.Nat where\n\nopen import Algebra.Group\nopen import Classes\nopen import Core\nopen import Data.Nat.Core\nopen import Data.Nat.Core public\n using (ℕ; ℕ-Number; ℕ-Plus; ℕ-Times;\n ℕ,≤; module ℕ,≤;\n suc; zero)\n\n\nℕ,+ : Monoid\nℕ,+ =\n record {\n semigroup = record {\n A = ℕ;\n Eq = PropEq ℕ;\n semigroupOver = record {\n _⋄_ = _+_;\n ⋄-cong = cong2 _+_;\n assoc = Props.+-assoc\n }\n };\n isMonoid = record {\n id = 0;\n left-id = Props.+-left-id;\n right-id = Props.+-right-id\n }\n }\n\nmodule ℕ,+ = Monoid ℕ,+\n\n\nℕ,* : Monoid\nℕ,* =\n record {\n semigroup = record {\n A = ℕ;\n Eq = PropEq ℕ;\n semigroupOver = record {\n _⋄_ = _*_;\n ⋄-cong = cong2 _*_;\n assoc = Props.*-assoc\n }\n };\n isMonoid = record {\n id = 1;\n left-id = Props.*-left-id;\n right-id = Props.*-right-id\n }\n }\n\nmodule ℕ,* = Monoid ℕ,*\n", "meta": {"hexsha": "48dd0d0ffda7fbe708019bab8cba90d1ecaadbd1", "size": 1050, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Nat.agda", "max_stars_repo_name": "esoeylemez/agda-simple", "max_stars_repo_head_hexsha": "d9245e5a8b2e902781736de09bd17e81022f6f13", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-10-07T17:36:42.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-07T17:36:42.000Z", "max_issues_repo_path": "Data/Nat.agda", "max_issues_repo_name": "esoeylemez/agda-simple", "max_issues_repo_head_hexsha": "d9245e5a8b2e902781736de09bd17e81022f6f13", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Nat.agda", "max_forks_repo_name": "esoeylemez/agda-simple", "max_forks_repo_head_hexsha": "d9245e5a8b2e902781736de09bd17e81022f6f13", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.7966101695, "max_line_length": 48, "alphanum_fraction": 0.5219047619, "num_tokens": 356, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094145755219, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.6246505631140359}} {"text": "\nopen import Oscar.Prelude\nopen import Oscar.Class\n\nmodule Oscar.Class.Symmetry where\n\nmodule Symmetry'\n {𝔬} {𝔒 : Ø 𝔬}\n {𝔯} (_∼_ : 𝔒 → 𝔒 → Ø 𝔯)\n x y\n = ℭLASS (x ,, y ,, _∼_) (x ∼ y → y ∼ x)\n\nmodule Symmetry\n {𝔬} {𝔒 : Ø 𝔬}\n {𝔯} (_∼_ : 𝔒 → 𝔒 → Ø 𝔯)\n where\n class = ∀ {x y} → Symmetry'.class _∼_ x y\n type = ∀ {x y} → Symmetry'.type _∼_ x y\n method : ⦃ _ : class ⦄ → type\n method {x = x} {y} = Symmetry'.method _∼_ x y\n\nmodule _\n {𝔬} {𝔒 : Ø 𝔬}\n {𝔯} {_∼_ : 𝔒 → 𝔒 → Ø 𝔯}\n where\n symmetry = Symmetry.method _∼_\n syntax symmetry {x} {y} x∼y = x ⟨∼ x∼y ∼⟩ y\n\nmodule _\n {𝔬} {𝔒 : Ø 𝔬}\n {𝔯} (_∼_ : 𝔒 → 𝔒 → Ø 𝔯)\n ⦃ _ : Symmetry.class _∼_ ⦄\n where\n symmetry[_] = λ {x y} (x∼y : x ∼ y) → Symmetry.method _∼_ x∼y\n", "meta": {"hexsha": "80bba44ec7dd8e6429b8bb5a0357973306bee958", "size": 719, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Symmetry.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Symmetry.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Symmetry.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.5428571429, "max_line_length": 63, "alphanum_fraction": 0.5173852573, "num_tokens": 396, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094117351309, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.6246505611278799}} {"text": "--------------------------------------------------------------------------------\n-- This is part of Agda Inference Systems\n\n{-# OPTIONS --sized-types #-}\n\nopen import Data.Nat\nopen import Data.Vec\nopen import Data.Fin\nopen import Data.Product\nopen import Data.Sum\nopen import Data.Unit\nopen import Data.Empty\nopen import Relation.Nullary\nopen import Relation.Binary.PropositionalEquality\nopen import Size\n\nopen import is-lib.SInfSys\nopen import Examples.Lambda.Lambda\n\nmodule Examples.Lambda.BigStep where\n\n data Value∞ : Set where\n res : Value → Value∞\n div : Value∞\n\n U : Set\n U = Term 0 × Value∞\n\n data BigStepRN : Set where\n VAL APP L-DIV R-DIV : BigStepRN\n\n data BigStepCoRN : Set where\n COA : BigStepCoRN\n\n coa-r : FinMetaRule U\n coa-r .Ctx = Term 0\n coa-r .comp t =\n [] ,\n -------------------------\n (t , div)\n\n val-r : FinMetaRule U\n val-r .Ctx = Value\n val-r .comp v =\n [] ,\n -------------------------\n (term v , res v)\n\n app-r : FinMetaRule U\n app-r .Ctx = Term 0 × Term 1 × Term 0 × Value × Value∞\n app-r .comp (t1 , t , t2 , v , v∞) =\n (t1 , res (lambda t)) ∷ (t2 , res v) ∷ (subst-0 t (term v) , v∞) ∷ [] ,\n -------------------------\n (app t1 t2 , v∞)\n \n l-div-r : FinMetaRule U\n l-div-r .Ctx = Term 0 × Term 0\n l-div-r .comp (t1 , t2) =\n (t1 , div) ∷ [] ,\n -------------------------\n (app t1 t2 , div)\n \n r-div-r : FinMetaRule U\n r-div-r .Ctx = Term 0 × Term 0 × Value\n r-div-r .comp (t1 , t2 , v) =\n (t1 , res v) ∷ (t2 , div) ∷ [] ,\n -------------------------\n (app t1 t2 , div)\n \n BigStepIS : IS U\n BigStepIS .Names = BigStepRN\n BigStepIS .rules VAL = from val-r\n BigStepIS .rules APP = from app-r\n BigStepIS .rules L-DIV = from l-div-r\n BigStepIS .rules R-DIV = from r-div-r\n \n BigStepCOIS : IS U\n BigStepCOIS .Names = BigStepCoRN\n BigStepCOIS .rules COA = from coa-r\n \n _⇓_ : Term 0 → Value∞ → Size → Set\n (t ⇓ v∞) i = SFCoInd⟦ BigStepIS , BigStepCOIS ⟧ (t , v∞) i\n \n _⇓ᵢ_ : Term 0 → Value∞ → Set\n t ⇓ᵢ v∞ = Ind⟦ BigStepIS ∪ BigStepCOIS ⟧ (t , v∞)\n \n {- Properties -}\n \n val-not-reduce⇓ : ∀{v} → ¬ (∀{i} → ((term v) ⇓ div) i)\n val-not-reduce⇓ {lambda _} bs with bs\n val-not-reduce⇓ {lambda _} bs | (sfold (VAL , _ , () , _))\n \n val-⇓ᵢ-≡ : ∀{v v'} → term v ⇓ᵢ res v' → v ≡ v'\n val-⇓ᵢ-≡ {lambda x} {lambda .x} (fold (inj₁ VAL , .(lambda x) , refl , _)) = refl\n val-⇓ᵢ-≡ {lambda x} {lambda x₁} (fold (inj₁ APP , _ , () , _))\n val-⇓ᵢ-≡ {v} {v'} (fold (inj₂ COA , _ , () , _))\n \n val-⇓-≡ : ∀{v v'} → (∀{i} → (term v ⇓ res v') i) → v ≡ v'\n val-⇓-≡ bs = val-⇓ᵢ-≡ (sfcoind-to-ind bs)", "meta": {"hexsha": "020b85631672ef1ee561fb51980761f5a536d861", "size": 2604, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Examples/Lambda/BigStep.agda", "max_stars_repo_name": "LcicC/inference-systems-agda", "max_stars_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2022-03-10T15:53:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-25T15:48:52.000Z", "max_issues_repo_path": "Examples/Lambda/BigStep.agda", "max_issues_repo_name": "LcicC/inference-systems-agda", "max_issues_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Examples/Lambda/BigStep.agda", "max_forks_repo_name": "LcicC/inference-systems-agda", "max_forks_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.303030303, "max_line_length": 83, "alphanum_fraction": 0.5195852535, "num_tokens": 1026, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094060543488, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.6246505459581863}} {"text": "open import Prelude\nopen import Nat\nopen import Agda.Primitive using (Level; lzero; lsuc) renaming (_⊔_ to lmax)\n\nmodule List where\n\n -- definitions\n\n data List (A : Set) : Set where\n [] : List A\n _::_ : A → List A → List A\n\n _++_ : {A : Set} → List A → List A → List A\n [] ++ l₂ = l₂\n (h :: l₁) ++ l₂ = h :: (l₁ ++ l₂)\n\n infixl 50 _++_\n\n ∥_∥ : {A : Set} → List A → Nat\n ∥ [] ∥ = Z\n ∥ a :: as ∥ = 1+ ∥ as ∥\n\n _⟦_⟧ : {A : Set} → List A → Nat → Maybe A\n [] ⟦ i ⟧ = None\n (a :: as) ⟦ Z ⟧ = Some a\n (a :: as) ⟦ 1+ i ⟧ = as ⟦ i ⟧\n\n data _In_ : {A : Set} → A → List A → Set where\n LInH : ∀{A} {a : A} {l : List A} → a In (a :: l)\n LInT : ∀{A} {a a' : A} {l : List A} → a In l → a In (a' :: l)\n\n _⫇_ : {A : Set} → List A → List A → Set\n _⫇_ {A} l1 l2 = (i1 : Nat) (a : A) →\n l1 ⟦ i1 ⟧ == Some a →\n Σ[ i2 ∈ Nat ] (l2 ⟦ i2 ⟧ == Some a)\n\n _≈_ : {A : Set} → List A → List A → Set\n _≈_ {A} l1 l2 = l1 ⫇ l2 ∧ l2 ⫇ l1\n\n reverse : {A : Set} → List A → List A\n reverse [] = []\n reverse (a :: as) = reverse as ++ (a :: [])\n\n map : {A B : Set} → (A → B) → List A → List B\n map f [] = []\n map f (a :: as) = f a :: map f as\n\n foldl : {A B : Set} → (B → A → B) → B → List A → B\n foldl f b [] = b\n foldl f b (a :: as) = foldl f (f b a) as\n\n foldr : {A B : Set} → (B → A → B) → B → List A → B\n foldr f b = foldl f b ⊙ reverse\n\n concat : {A : Set} → List (List A) → List A\n concat [] = []\n concat (l1 :: rest) = l1 ++ (concat rest)\n\n -- if the lists aren't the same length,\n -- the extra elements of the longer list are ignored\n zip : {A B : Set} → List A → List B → List (A ∧ B)\n zip [] _ = []\n zip (a :: as) [] = []\n zip (a :: as) (b :: bs) = (a , b) :: zip as bs\n\n unzip : {A B : Set} → List (A ∧ B) → (List A ∧ List B)\n unzip [] = ([] , [])\n unzip ((a , b) :: rest)\n with unzip rest\n ... | (as , bs) = (a :: as , b :: bs)\n\n -- theorems\n\n list-==-dec : {A : Set} →\n (l1 l2 : List A) →\n ((a1 a2 : A) → a1 == a2 ∨ a1 ≠ a2) →\n l1 == l2 ∨ l1 ≠ l2\n list-==-dec [] [] A-==-dec = Inl refl\n list-==-dec [] (_ :: _) A-==-dec = Inr (λ ())\n list-==-dec (_ :: _) [] A-==-dec = Inr (λ ())\n list-==-dec (h1 :: t1) (h2 :: t2) A-==-dec\n with A-==-dec h1 h2\n ... | Inr ne = Inr (λ where refl → ne refl)\n ... | Inl refl\n with list-==-dec t1 t2 A-==-dec\n ... | Inr ne = Inr (λ where refl → ne refl)\n ... | Inl refl = Inl refl\n\n -- if the items of two lists are equal, then the lists are equal\n ==-per-elem : {A : Set} → {l1 l2 : List A} →\n ((i : Nat) → l1 ⟦ i ⟧ == l2 ⟦ i ⟧) →\n l1 == l2\n ==-per-elem {l1 = []} {[]} items== = refl\n ==-per-elem {l1 = []} {h2 :: t2} items== = abort (somenotnone (! (items== Z)))\n ==-per-elem {l1 = h1 :: t1} {[]} items== = abort (somenotnone (items== Z))\n ==-per-elem {l1 = h1 :: t1} {h2 :: t2} items==\n rewrite someinj (items== Z) | ==-per-elem {l1 = t1} {t2} (λ i → items== (1+ i))\n = refl\n\n -- _++_ theorems\n ++assc : ∀{A a1 a2 a3} → (_++_ {A} a1 a2) ++ a3 == a1 ++ (a2 ++ a3)\n ++assc {A} {[]} {a2} {a3} = refl\n ++assc {A} {x :: a1} {a2} {a3} with a1 ++ a2 ++ a3 | ++assc {A} {a1} {a2} {a3}\n ++assc {A} {x :: a1} {a2} {a3} | _ | refl = refl\n\n l++[]==l : {A : Set} (l : List A) →\n l ++ [] == l\n l++[]==l [] = refl\n l++[]==l (a :: as)\n rewrite l++[]==l as\n = refl\n\n -- ∥_∥ theorem\n ∥-++-comm : ∀{A a1 a2} → ∥ a1 ∥ + (∥_∥ {A} a2) == ∥ a1 ++ a2 ∥\n ∥-++-comm {A} {[]} {a2} = refl\n ∥-++-comm {A} {a :: a1} {a2} = 1+ap (∥-++-comm {A} {a1})\n\n -- _⟦_⟧ and ++ theorem\n ⦇l1++[a]++l2⦈⟦∥l1∥⟧==a : {A : Set} {l1 l2 : List A} {a : A} →\n (l1 ++ (a :: []) ++ l2) ⟦ ∥ l1 ∥ ⟧ == Some a\n ⦇l1++[a]++l2⦈⟦∥l1∥⟧==a {l1 = []} = refl\n ⦇l1++[a]++l2⦈⟦∥l1∥⟧==a {l1 = a1 :: l1rest} {l2} {a} = ⦇l1++[a]++l2⦈⟦∥l1∥⟧==a {l1 = l1rest} {l2}\n\n -- packaging of list indexing results\n list-index-dec : {A : Set} (l : List A) (i : Nat) →\n l ⟦ i ⟧ == None ∨ Σ[ a ∈ A ] (l ⟦ i ⟧ == Some a)\n list-index-dec l i\n with l ⟦ i ⟧\n ... | None = Inl refl\n ... | Some a = Inr (a , refl)\n\n -- theorems characterizing the partiality of list indexing\n list-index-some : {A : Set} {l : List A} {i : Nat} →\n i < ∥ l ∥ →\n Σ[ a ∈ A ] (l ⟦ i ⟧ == Some a)\n list-index-some {l = []} {Z} i<∥l∥ = abort (n≮0 i<∥l∥)\n list-index-some {l = a :: as} {Z} i<∥l∥ = _ , refl\n list-index-some {l = a :: as} {1+ i} i<∥l∥ = list-index-some (1+n<1+m→n_\ndata Ty : Set where\n UNIT : Ty\n _=>_ : Ty -> Ty -> Ty\n BOX : Ty -> Ty\n\n\n-- Context and truth/validity judgements\n\nCx : Set\nCx = List Ty\n\nisTrue : Ty -> Cx -> Set\nisTrue a tc = LMem a tc\n\nisValid : Ty -> Cx -> Set\nisValid a vc = LMem a vc\n\n\n-- Terms\n\nmodule BoxMp where\n infixl 1 _$_\n infixr 0 lam=>_\n data Tm (vc tc : Cx) : Ty -> Set where\n var : forall {a} -> isTrue a tc -> Tm vc tc a\n lam=>_ : forall {a b} -> Tm vc (tc , a) b -> Tm vc tc (a => b)\n _$_ : forall {a b} -> Tm vc tc (a => b) -> Tm vc tc a -> Tm vc tc b\n var# : forall {a} -> isValid a vc -> Tm vc tc a\n box : forall {a} -> Tm vc [] a -> Tm vc tc (BOX a)\n unbox' : forall {a b} -> Tm vc tc (BOX a) -> Tm (vc , a) tc b -> Tm vc tc b\n\n syntax unbox' x' x = unbox x' => x\n\n v0 : forall {vc tc a} -> Tm vc (tc , a) a\n v0 = var lzero\n\n v1 : forall {vc tc a b} -> Tm vc (tc , a , b) a\n v1 = var (lsuc lzero)\n\n v2 : forall {vc tc a b c} -> Tm vc (tc , a , b , c) a\n v2 = var (lsuc (lsuc lzero))\n\n v0# : forall {vc tc a} -> Tm (vc , a) tc a\n v0# = var# lzero\n\n v1# : forall {vc tc a b} -> Tm (vc , a , b) tc a\n v1# = var# (lsuc lzero)\n\n v2# : forall {vc tc a b c} -> Tm (vc , a , b , c) tc a\n v2# = var# (lsuc (lsuc lzero))\n\n Thm : Ty -> Set\n Thm a = forall {vc tc} -> Tm vc tc a\nopen BoxMp public\n\n\n-- Example theorems\n\nrNec : forall {a} -> Thm a -> Thm (BOX a)\nrNec x =\n box x\n\naK : forall {a b} -> Thm (BOX (a => b) => BOX a => BOX b)\naK =\n lam=>\n lam=>\n (unbox v1 =>\n unbox v0 =>\n box (v1# $ v0#))\n\naT : forall {a} -> Thm (BOX a => a)\naT =\n lam=>\n (unbox v0 => v0#)\n\na4 : forall {a} -> Thm (BOX a => BOX (BOX a))\na4 =\n lam=>\n (unbox v0 => box (box v0#))\n\nt1 : forall {a} -> Thm (a => BOX (a => a))\nt1 =\n lam=> box (lam=> v0)\n", "meta": {"hexsha": "dc2928fee3f2c57256a46b24f9eb4fc51a369d01", "size": 2055, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Bi/BoxMp.agda", "max_stars_repo_name": "mietek/formal-logic", "max_stars_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_stars_repo_licenses": ["X11"], "max_stars_count": 26, "max_stars_repo_stars_event_min_datetime": "2015-08-31T09:49:52.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-13T12:37:44.000Z", "max_issues_repo_path": "src/Bi/BoxMp.agda", "max_issues_repo_name": "mietek/formal-logic", "max_issues_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_issues_repo_licenses": ["X11"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Bi/BoxMp.agda", "max_forks_repo_name": "mietek/formal-logic", "max_forks_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_forks_repo_licenses": ["X11"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.8617021277, "max_line_length": 81, "alphanum_fraction": 0.4875912409, "num_tokens": 817, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382200964034, "lm_q2_score": 0.7248702642896702, "lm_q1q2_score": 0.6245034372969319}} {"text": "-- Type interpretation and soundness of typing.\n\n-- Proof of strong normalization for well-typed terms.\n\nmodule Soundness where\n\nopen import Library\nopen import Terms\nopen import Substitution\nopen import SN\nopen import SN.AntiRename\nopen import DeclSN using (sn; fromSN)\nopen import SAT3\n\n-- Type interpretation\n\n⟦_⟧ : (a : Ty) → SAT a\n⟦ base ⟧ = ⟦⊥⟧\n⟦ a →̂ b ⟧ = ⟦ a ⟧ ⟦→⟧ ⟦ b ⟧\n\n-- Context interpretation (semantic substitutions)\n\n⟦_⟧C : ∀ Γ → ∀ {Δ} (σ : Subst Γ Δ) → Set\n⟦ Γ ⟧C σ = ∀ {a} (x : Var Γ a) → σ x ∈ ⟦ a ⟧\n\nExt : ∀ {a Δ Γ} {t : Tm Δ a} → (𝒕 : t ∈ (⟦ a ⟧)) →\n ∀ {σ : Subst Γ Δ} (θ : ⟦ Γ ⟧C σ) → ⟦ a ∷ Γ ⟧C (t ∷s σ)\nExt {a} 𝒕 θ (zero) = 𝒕\nExt {a} 𝒕 θ (suc x) = θ x\n\nRename : ∀ {Δ Δ'} → (ρ : Ren Δ Δ') →\n ∀ {Γ}{σ : Subst Γ Δ} (θ : ⟦ Γ ⟧C σ) →\n ⟦ Γ ⟧C (ρ •s σ)\nRename ρ θ {a} x = ↿ SAT.satRename ⟦ a ⟧ ρ (⇃ θ x)\n\n\nsound : ∀ {a Γ} (t : Tm Γ a) {Δ} {σ : Subst Γ Δ} → (θ : ⟦ Γ ⟧C σ) → subst σ t ∈ (⟦ a ⟧)\nsound (var x) θ = θ x\nsound (abs t) {σ = σ} θ = ⟦abs⟧ {𝓐 = ⟦ _ ⟧} {𝓑 = ⟦ _ ⟧} (λ ρ {u} 𝑢 →\n let open ≡-Reasoning\n eq : subst (u ∷s (ρ •s σ)) t ≡ subst0 u (subst (lifts ρ) (subst (lifts σ) t))\n eq = begin\n\n subst (u ∷s (ρ •s σ)) t\n\n ≡⟨ subst-ext (cons-to-sgs u _) t ⟩\n\n subst (sgs u •s lifts (ρ •s σ)) t\n\n ≡⟨ subst-∙ _ _ t ⟩\n\n subst0 u (subst (lifts (ρ •s σ)) t)\n\n ≡⟨ ≡.cong (subst0 u) (subst-ext (lifts-∙ ρ σ) t) ⟩\n\n subst0 u (subst (lifts ρ •s lifts σ) t)\n\n ≡⟨ ≡.cong (subst0 u) (subst-∙ (lifts ρ) (lifts σ) t) ⟩\n\n subst0 u (subst (lifts ρ) (subst (lifts σ) t))\n ∎\n in (≡.subst (_∈ ⟦ _ ⟧) eq (↿ (⇃ sound t (Ext (↿ (⇃ 𝑢)) ((Rename ρ θ)))))))\n\nsound (app t u) θ = ↿ (⇃ ⟦app⟧ {𝓐 = ⟦ _ ⟧} {𝓑 = ⟦ _ ⟧} (sound t θ) (↿ (⇃ sound u θ)))\n\n-- Identity environment.\n\nid-θ : ∀{Γ} → ⟦ Γ ⟧C ids\nid-θ {Γ} {a} x = ⟦var⟧ ⟦ a ⟧ x\n\n-- Any well-typed term inhabits its semantic type.\n\nsound' : ∀ {a Γ} (t : Tm Γ a) → t ∈ ⟦ a ⟧\nsound' t rewrite ≡.sym (subst-id {vt = `Tm} t) = sound t id-θ\n\n-- Any well-typed term is strongly normalizing.\n\nstrong-normalization : ∀ a {Γ} (t : Tm Γ a) → sn t\nstrong-normalization a t = fromSN (satSN ⟦ a ⟧ (⇃ sound' t))\n\n-- Q.E.D.\n", "meta": {"hexsha": "36243774e22a30d7c6b90f02c705e33eadbe8f70", "size": 2205, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-aplas14/Soundness.agda", "max_stars_repo_name": "ryanakca/strong-normalization", "max_stars_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 32, "max_stars_repo_stars_event_min_datetime": "2017-05-22T14:33:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-05T12:12:03.000Z", "max_issues_repo_path": "agda-aplas14/Soundness.agda", "max_issues_repo_name": "ryanakca/strong-normalization", "max_issues_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-02-14T16:42:36.000Z", "max_issues_repo_issues_event_max_datetime": "2018-02-20T14:54:18.000Z", "max_forks_repo_path": "agda-aplas14/Soundness.agda", "max_forks_repo_name": "ryanakca/strong-normalization", "max_forks_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2017-11-10T16:44:52.000Z", "max_forks_repo_forks_event_max_datetime": "2018-02-23T18:22:17.000Z", "avg_line_length": 26.8902439024, "max_line_length": 87, "alphanum_fraction": 0.4861678005, "num_tokens": 1029, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615381952105442, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.6245034294991504}} {"text": "module #12 where\n\n{-\n Using the propositions as types interpretation, derive the following tautologies.\n (i) If A, then (if B then A).\n (ii) If A, then not (not A).\n (iii) If (not A or not B), then not (A and B).\n-}\n\nopen import Data.Product\nopen import Data.Sum\nopen import Relation.Nullary\n\nconst : {A B : Set} → A → (B → A)\nconst = λ z _ → z\n\ndouble-negation : {A : Set} → A → ¬ (¬ A)\ndouble-negation = λ z z₁ → z₁ z\n\ndemorgans-law₁ : {A B C : Set} → ((¬ A) ⊎ (¬ B)) → (¬ (A × B))\ndemorgans-law₁ (inj₁ ¬x) (a , _) = ¬x a\ndemorgans-law₁ (inj₂ ¬y) (_ , b) = ¬y b\n", "meta": {"hexsha": "d99a9794dd73ee73b466763a7a19f9ba124f429a", "size": 570, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Chapter1/#12.agda", "max_stars_repo_name": "CodaFi/HoTT-Exercises", "max_stars_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter1/#12.agda", "max_issues_repo_name": "CodaFi/HoTT-Exercises", "max_issues_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter1/#12.agda", "max_forks_repo_name": "CodaFi/HoTT-Exercises", "max_forks_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.7826086957, "max_line_length": 83, "alphanum_fraction": 0.5877192982, "num_tokens": 218, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9241418241572634, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.6245023310866479}} {"text": "module #13 where\n\n{-\n Using propositions-as-types, derive the double negation of the principle of excluded\n middle, i.e. prove not (not (P or not P)).\n-}\n\nopen import Data.Sum\nopen import Relation.Nullary\n\nexcluded-middle : (P : Set) → ¬ (¬ (P ⊎ (¬ P)))\nexcluded-middle P z = z (inj₂ (λ x → z (inj₁ x)))\n", "meta": {"hexsha": "0dee53a0240d0e12611ed56c29e8f11cac048c0b", "size": 306, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Chapter1/#13.agda", "max_stars_repo_name": "CodaFi/HoTT-Exercises", "max_stars_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter1/#13.agda", "max_issues_repo_name": "CodaFi/HoTT-Exercises", "max_issues_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter1/#13.agda", "max_forks_repo_name": "CodaFi/HoTT-Exercises", "max_forks_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.5384615385, "max_line_length": 86, "alphanum_fraction": 0.6568627451, "num_tokens": 96, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9149009642742805, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.6244873737098073}} {"text": "\nmodule Pullback where\n\nopen import Logic.Equivalence\nopen import Logic.Relations\nopen import Logic.Base\nopen import Category\nopen import Unique\n\nmodule Pull (ℂ : Cat) where\n\n private open module CC = Category.Category ℂ\n private open module U = Uniq ℂ\n\n record isPull {A B C D A' : Obj}(f : A ─→ B)(g : A ─→ C)(f' : C ─→ D)(g' : B ─→ D)(h₁ : A' ─→ C)(h₂ : A' ─→ B)(commut : f' ∘ h₁ == g' ∘ h₂) : Set1 where\n field unique : ∃! \\(h : A' ─→ A) -> (g ∘ h == h₁) /\\ (f ∘ h == h₂)\n\n record pullback {B C D : Obj}(g' : B ─→ D)(f' : C ─→ D) : Set1 where\n field\n A : Obj\n f : A ─→ B\n g : A ─→ C\n comm : g' ∘ f == f' ∘ g\n pull : (forall {A' : Obj}(h₁ : A' ─→ C)(h₂ : A' ─→ B)(commut : f' ∘ h₁ == g' ∘ h₂) -> isPull f g f' g' h₁ h₂ commut)\n\n record PullCat : Set2 where\n field pull : {B C D : Obj}(g' : B ─→ D)(f' : C ─→ D) -> pullback g' f'\n", "meta": {"hexsha": "a4389ad4e3261b2384497feca6a6c370d95215f1", "size": 881, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/Pullback.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/Pullback.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/Pullback.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 31.4642857143, "max_line_length": 154, "alphanum_fraction": 0.5085130533, "num_tokens": 379, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.914900950352329, "lm_q2_score": 0.6825737473266735, "lm_q1q2_score": 0.6244873701147241}} {"text": "module Logic.Propositional.Equiv where\n\nimport Lvl\nopen import Logic\nopen import Logic.Propositional\nimport Logic.Propositional.Theorems as Theorems\nopen import Structure.Relator.Equivalence\nopen import Structure.Relator.Properties\nopen import Structure.Setoid\nopen import Type\n\nprivate variable ℓ ℓ₁ ℓ₂ ℓₑ ℓₑ₁ ℓₑ₂ : Lvl.Level\nprivate variable T A B : Type{ℓ}\n\ninstance\n [↔]-reflexivity : Reflexivity{ℓ₂ = ℓ}(_↔_)\n [↔]-reflexivity = intro Theorems.[↔]-reflexivity\n\ninstance\n [↔]-symmetry : Symmetry{ℓ₂ = ℓ}(_↔_)\n [↔]-symmetry = intro Theorems.[↔]-symmetry\n\ninstance\n [↔]-transitivity : Transitivity{ℓ₂ = ℓ}(_↔_)\n [↔]-transitivity = intro Theorems.[↔]-transitivity\n\ninstance\n [↔]-equivalence : Equivalence{ℓ₂ = ℓ}(_↔_)\n [↔]-equivalence = intro\n\ninstance\n [↔]-equiv : Equiv(Stmt{ℓ})\n [↔]-equiv = intro(_↔_) ⦃ [↔]-equivalence ⦄\n", "meta": {"hexsha": "5934f78cdb3ea6c9c4cb99278bbffa5ffaf2d11d", "size": 845, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Logic/Propositional/Equiv.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Logic/Propositional/Equiv.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Logic/Propositional/Equiv.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.8529411765, "max_line_length": 52, "alphanum_fraction": 0.7076923077, "num_tokens": 313, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8887587846530937, "lm_q2_score": 0.7025300698514777, "lm_q1q2_score": 0.6243797710634523}} {"text": "open import Signature\n\nmodule Program (Σ : Sig) (V : Set) where\n\nopen import Function\nopen import Data.Empty\nopen import Data.Unit\nopen import Data.Product as Prod renaming (Σ to ⨿)\nopen import Data.Nat\nopen import Data.Fin\nopen import Data.List\nopen import Terms Σ\n\nFinFam : Set → Set\nFinFam X = ⨿ ℕ λ n → (Fin n → X)\n\ndom : ∀{X} → FinFam X → Set\ndom (n , _) = Fin n\n\nget : ∀{X} (F : FinFam X) → dom F → X\nget (_ , f) k = f k\n\ndomEmpty : ∀{X} → FinFam X → Set\ndomEmpty (zero , _) = ⊤\ndomEmpty (suc _ , _) = ⊥\n\nrecord Clause : Set where\n constructor _⊢_\n field\n body : FinFam (T V)\n head : T V\nopen Clause public\n\n-- | A program consists of two finite sets of inductive and coinductive clauses.\nProgram : Set\nProgram = FinFam Clause × FinFam Clause\n\ndom-μ : Program → Set\ndom-μ = dom ∘ proj₁\n\ndom-ν : Program → Set\ndom-ν = dom ∘ proj₂\n\ngeth-μ : (P : Program) → dom-μ P → T V\ngeth-μ P = head ∘ get (proj₁ P)\n\ngetb-μ : (P : Program) → dom-μ P → FinFam (T V)\ngetb-μ P = body ∘ get (proj₁ P)\n\ngeth-ν : (P : Program) → dom-ν P → T V\ngeth-ν P = head ∘ get (proj₂ P)\n\ngetb-ν : (P : Program) → dom-ν P → FinFam (T V)\ngetb-ν P = body ∘ get (proj₂ P)\n", "meta": {"hexsha": "eec07889d6b27d394d1b08b8b22d5d8cb1adf683", "size": 1150, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "LP/Program.agda", "max_stars_repo_name": "hbasold/Sandbox", "max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LP/Program.agda", "max_issues_repo_name": "hbasold/Sandbox", "max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LP/Program.agda", "max_forks_repo_name": "hbasold/Sandbox", "max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.9090909091, "max_line_length": 80, "alphanum_fraction": 0.627826087, "num_tokens": 438, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8887587846530938, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.624379748922209}} {"text": "------------------------------------------------------------------------\n-- Operations on nullary relations (like negation and decidability)\n------------------------------------------------------------------------\n\n-- Some operations on/properties of nullary relations, i.e. sets.\n\nmodule Relation.Nullary where\n\nopen import Data.Product\nimport Relation.Nullary.Core as Core\nopen import Relation.Binary\nopen import Relation.Binary.FunctionSetoid\nimport Relation.Binary.EqReasoning as EqReasoning\n\n------------------------------------------------------------------------\n-- Negation\n\nopen Core public using (¬_)\n\n------------------------------------------------------------------------\n-- Equivalence\n\ninfix 3 _⇔_\n\n_⇔_ : Set → Set → Set\nP ⇔ Q = (P → Q) × (Q → P)\n\n------------------------------------------------------------------------\n-- Decidable relations\n\nopen Core public using (Dec; yes; no)\n\n------------------------------------------------------------------------\n-- Injections\n\nInjective : ∀ {A B} → A ⟶ B → Set\nInjective {A} {B} f = ∀ {x y} → f ⟨$⟩ x ≈₂ f ⟨$⟩ y → x ≈₁ y\n where\n open Setoid A renaming (_≈_ to _≈₁_)\n open Setoid B renaming (_≈_ to _≈₂_)\n\n_LeftInverseOf_ : ∀ {A B} → B ⟶ A → A ⟶ B → Set\n_LeftInverseOf_ {A} f g = ∀ x → f ⟨$⟩ (g ⟨$⟩ x) ≈₁ x\n where open Setoid A renaming (_≈_ to _≈₁_)\n\nrecord Injection (From To : Setoid) : Set where\n field\n to : From ⟶ To\n injective : Injective to\n\nrecord LeftInverse (From To : Setoid) : Set where\n field\n to : From ⟶ To\n from : To ⟶ From\n left-inverse : from LeftInverseOf to\n\n open Setoid From\n open EqReasoning From\n\n injective : Injective to\n injective {x} {y} eq = begin\n x ≈⟨ sym (left-inverse x) ⟩\n from ⟨$⟩ (to ⟨$⟩ x) ≈⟨ pres from eq ⟩\n from ⟨$⟩ (to ⟨$⟩ y) ≈⟨ left-inverse y ⟩\n y ∎\n\n injection : Injection From To\n injection = record { to = to; injective = injective }\n", "meta": {"hexsha": "7b1ddc54dfc35b68071e5c3cee04edfe7ef50f76", "size": 1947, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Relation/Nullary.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Relation/Nullary.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Relation/Nullary.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 28.2173913043, "max_line_length": 72, "alphanum_fraction": 0.4750898819, "num_tokens": 520, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267762381844, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.6243340547561761}} {"text": "{-# OPTIONS --without-K #-}\r\n\r\nmodule PiG where\r\n\r\nimport Level as L\r\nopen import Data.Empty\r\nopen import Data.Unit\r\nopen import Data.Sum\r\nopen import Data.Product\r\nopen import Data.Nat\r\nopen import Function\r\nopen import Relation.Binary.PropositionalEquality\r\nopen import Relation.Binary\r\n\r\n------------------------------------------------------------------------------\r\n-- Reasoning about paths\r\n\r\npathInd : ∀ {u u'} → {A : Set u} → \r\n (C : (x y : A) → (x ≡ y) → Set u') → \r\n (c : (x : A) → C x x refl) → \r\n ((x y : A) (p : x ≡ y) → C x y p)\r\npathInd C c x .x refl = c x\r\n\r\ntrans' : {A : Set} → {x y z : A} → (x ≡ y) → (y ≡ z) → (x ≡ z)\r\ntrans' {A} {x} {y} {z} p q = \r\n pathInd \r\n (λ x y p → ((z : A) → (q : y ≡ z) → (x ≡ z)))\r\n (pathInd (λ x z q → x ≡ z) (λ _ → refl))\r\n x y p z q\r\n\r\nap : {A B : Set} {x y : A} → (f : A → B) → (x ≡ y) → (f x ≡ f y)\r\nap {A} {B} {x} {y} f p = \r\n pathInd \r\n (λ x y p → f x ≡ f y) \r\n (λ x → refl) \r\n x y p\r\n\r\nap× : {A B : Set} {x y : A} {z w : B} → (x ≡ y) → (z ≡ w) → \r\n ((x , z) ≡ (y , w))\r\nap× {A} {B} {x} {y} {z} {w} p₁ p₂ = \r\n pathInd \r\n (λ x y p₁ → ((z : B) (w : B) (p₂ : z ≡ w) → ((x , z) ≡ (y , w))))\r\n (λ x → pathInd\r\n (λ z w p₂ → ((x , z) ≡ (x , w)))\r\n (λ z → refl))\r\n x y p₁ z w p₂\r\n\r\ntransport : {A : Set} {x y : A} {P : A → Set} → (p : x ≡ y) → P x → P y\r\ntransport {A} {x} {y} {P} p = \r\n pathInd\r\n (λ x y p → (P x → P y))\r\n (λ x → id)\r\n x y p\r\n\r\n------------------------------------------------------------------------------\r\n-- Codes for our types\r\n\r\ndata B : Set where\r\n -- no zero because we map types to POINTED SETS\r\n ONE : B\r\n PLUS : B → B → B\r\n TIMES : B → B → B\r\n HALF : B -- used to explore fractionals\r\n\r\n{--\r\n\r\nNow let's define groups/groupoids\r\n\r\nThe type 1/2 is modeled by the group { refl , loop } \r\nwhere loop is self-inverse, i.e., loop . loop = refl\r\n\r\nWe always get refl, inverses, and associativity for free. We need to\r\nexplicitly add the new element 'loop' and the new equation \r\n'loop . loop = refl'\r\n\r\n--}\r\n\r\ncut-path : {A : Set} → {x : A} → (f g : ( x ≡ x) → (x ≡ x)) → x ≡ x → Set\r\ncut-path f g a = f a ≡ g a\r\n\r\nrecord GroupoidVal : Set₁ where\r\n constructor •[_,_,_,_,_,_]\r\n field\r\n ∣_∣ : Set \r\n • : ∣_∣\r\n path : • ≡ • -- the additional path (loop)\r\n -- truncate : trans' path path ≡ refl -- the equivalence used to truncate\r\n -- truncate : (f : • ≡ • → • ≡ •) → (b : • ≡ •) → f b ≡ refl\r\n path-rel₁ : • ≡ • → • ≡ •\r\n path-rel₂ : • ≡ • → • ≡ • \r\n truncate : cut-path path-rel₁ path-rel₂ path\r\n\r\nopen GroupoidVal public\r\n\r\n-- Example:\r\n\r\nconst-loop : {A : Set} {x : A} → (y : x ≡ x) → x ≡ x\r\nconst-loop _ = refl\r\n\r\npostulate iloop : tt ≡ tt\r\n itruncate : (f : tt ≡ tt → tt ≡ tt) → cut-path f const-loop iloop\r\n -- (trans' iloop iloop) ≡ refl\r\n\r\n2loop : {A : Set} → {x : A} → x ≡ x → x ≡ x\r\n2loop x = trans' x x\r\n\r\nhalf : GroupoidVal\r\nhalf = •[ ⊤ , tt , iloop , 2loop , const-loop , itruncate 2loop ]\r\n\r\n-- Interpretations of types\r\n\r\n⟦_⟧ : B → GroupoidVal\r\n⟦ ONE ⟧ = •[ ⊤ , tt , refl , id , id , refl ]\r\n⟦ PLUS b₁ b₂ ⟧ with ⟦ b₁ ⟧ | ⟦ b₂ ⟧ \r\n... | •[ B₁ , x₁ , p₁ , f₁ , g₁ , t₁ ] | •[ B₂ , x₂ , p₂ , f₂ , g₂ , t₂ ] = \r\n •[ B₁ ⊎ B₂ , inj₁ x₁ , ap inj₁ p₁ , id , id , refl ]\r\n⟦ TIMES b₁ b₂ ⟧ with ⟦ b₁ ⟧ | ⟦ b₂ ⟧ \r\n... | •[ B₁ , x₁ , p₁ , f₁ , g₁ , t₁ ] | •[ B₂ , x₂ , p₂ , f₂ , g₂ , t₂ ] = \r\n •[ B₁ × B₂ , (x₁ , x₂) , ap× p₁ p₂ , id , id , refl ]\r\n⟦ HALF ⟧ = half\r\n\r\n-- Combinators\r\n\r\ndata _⟷_ : B → B → Set₁ where\r\n swap× : {b₁ b₂ : B} → TIMES b₁ b₂ ⟷ TIMES b₂ b₁\r\n\r\nrecord GFunctor (G₁ G₂ : GroupoidVal) : Set where\r\n field \r\n fun : ∣ G₁ ∣ → ∣ G₂ ∣\r\n baseP : fun (• G₁) ≡ (• G₂)\r\n -- dependent paths??\r\n isoP : {x y : ∣ G₁ ∣} (p : x ≡ y) → (fun x ≡ fun y)\r\n\r\neval : {b₁ b₂ : B} → (b₁ ⟷ b₂) → GFunctor ⟦ b₁ ⟧ ⟦ b₂ ⟧\r\neval swap× = \r\n record {\r\n fun = swap; \r\n baseP = refl; \r\n isoP = λ p → ap swap p\r\n }\r\n\r\n------------------------------------------------------------------------------\r\n\r\n{-\r\n Some old scribblings\r\nA-2 : Set\r\nA-2 = ⊤\r\n\r\npostulate \r\n S⁰ : Set\r\n S¹ : Set\r\n\r\nrecord Trunc-1 (A : Set) : Set where\r\n field\r\n embed : A → Trunc-1 A\r\n hub : (r : S⁰ → Trunc-1 A) → Trunc-1 A\r\n spoke : (r : S⁰ → Trunc-1 A) → (x : S⁰) → r x ≡ hub r\r\n\r\n-}\r\n\r\n--------------------\r\n\r\nrecord 2Groupoid : Set₁ where\r\n constructor ²[_,_,_]\r\n field\r\n obj : Set \r\n hom : Rel obj L.zero -- paths (loop)\r\n 2path : ∀ {a b} → hom a b → hom a b → Set -- 2paths, i.e. path eqns\r\n\r\nopen 2Groupoid public\r\n\r\nhom⊤ : Rel ⊤ L.zero\r\nhom⊤ = _≡_\r\n\r\n2path⊤ : Rel (hom⊤ tt tt) L.zero\r\n2path⊤ = _≡_\r\n\r\nhalf' : 2Groupoid\r\nhalf' = ²[ ⊤ , hom⊤ , 2path⊤ ]\r\n", "meta": {"hexsha": "7e6281c0965cd8b17efa592abbe1101351f9a784", "size": 4722, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "PiG.agda", "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_issues_repo_path": "PiG.agda", "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_forks_repo_path": "PiG.agda", "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "avg_line_length": 26.2333333333, "max_line_length": 79, "alphanum_fraction": 0.4434561626, "num_tokens": 1864, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267830311354, "lm_q2_score": 0.7185943925708561, "lm_q1q2_score": 0.6243340544015498}} {"text": "\nmodule Prelude.Bool where\n\nopen import Prelude.Unit\nopen import Prelude.Empty\nopen import Prelude.Equality\nopen import Prelude.Decidable\nopen import Prelude.Function\n\nopen import Agda.Builtin.Bool public\n\ninfix 0 if_then_else_\nif_then_else_ : ∀ {a} {A : Set a} → Bool → A → A → A\nif true then x else y = x\nif false then x else y = y\n{-# INLINE if_then_else_ #-}\n\ninfixr 3 _&&_\ninfixr 2 _||_\n\n_||_ : Bool → Bool → Bool\ntrue || _ = true\nfalse || x = x\n{-# INLINE _||_ #-}\n\n_&&_ : Bool → Bool → Bool\ntrue && x = x\nfalse && _ = false\n{-# INLINE _&&_ #-}\n\nnot : Bool → Bool\nnot true = false\nnot false = true\n{-# INLINE not #-}\n\ndata IsTrue : Bool → Set where\n instance true : IsTrue true\n\ndata IsFalse : Bool → Set where\n instance false : IsFalse false\n\ninstance\n EqBool : Eq Bool\n _==_ {{EqBool}} false false = yes refl\n _==_ {{EqBool}} false true = no λ ()\n _==_ {{EqBool}} true false = no λ ()\n _==_ {{EqBool}} true true = yes refl\n\ndecBool : ∀ b → Dec (IsTrue b)\ndecBool false = no λ ()\ndecBool true = yes true\n{-# INLINE decBool #-}\n\nisYes : ∀ {a} {A : Set a} → Dec A → Bool\nisYes (yes _) = true\nisYes (no _) = false\n\nisNo : ∀ {a} {A : Set a} → Dec A → Bool\nisNo = not ∘ isYes\n\ninfix 0 if′_then_else_\nif′_then_else_ : ∀ {a} {A : Set a} (b : Bool) → ({{_ : IsTrue b}} → A) → ({{_ : IsFalse b}} → A) → A\nif′ true then x else _ = x\nif′ false then _ else y = y\n", "meta": {"hexsha": "5abd0bec9a543697ef54903d3066d63722d99b6a", "size": 1376, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Prelude/Bool.agda", "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Prelude/Bool.agda", "max_issues_repo_name": "lclem/agda-prelude", "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Prelude/Bool.agda", "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.1692307692, "max_line_length": 100, "alphanum_fraction": 0.6155523256, "num_tokens": 474, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127529517043, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.6242602434469074}} {"text": "{-# OPTIONS --allow-unsolved-metas #-} \n\nmodule fin where\n\nopen import Data.Fin hiding (_<_ ; _≤_ ; _>_ ; _+_ )\nopen import Data.Fin.Properties hiding (≤-trans ; <-trans ; ≤-refl ) renaming ( <-cmp to <-fcmp )\nopen import Data.Nat\nopen import Data.Nat.Properties\nopen import logic\nopen import nat\nopen import Relation.Binary.PropositionalEquality\n\n\n-- toℕ 0 → Data.Nat.pred (toℕ f) < n\npred ¬a ¬b c = fin-phase2 q qs\nfin-phase1 : { n : ℕ } (q : Fin n) (qs : List (Fin n) ) → Bool\nfin-phase1 q [] = false\nfin-phase1 q (x ∷ qs) with <-fcmp q x\n... | tri< a ¬b ¬c = fin-phase1 q qs\n... | tri≈ ¬a b ¬c = fin-phase2 q qs\n... | tri> ¬a ¬b c = fin-phase1 q qs\n\nfin-dup-in-list : { n : ℕ} (q : Fin n) (qs : List (Fin n) ) → Bool\nfin-dup-in-list {n} q qs = fin-phase1 q qs\n\nrecord FDup-in-list (n : ℕ ) (qs : List (Fin n)) : Set where\n field\n dup : Fin n\n is-dup : fin-dup-in-list dup qs ≡ true\n\nlist-less : {n : ℕ } → List (Fin (suc n)) → List (Fin n)\nlist-less [] = []\nlist-less {n} (i ∷ ls) with <-fcmp (fromℕ< a a (subst (λ k → toℕ i < suc k ) (sym fin ¬a ¬b c = xn : {n : ℕ } → (qs : List (Fin n)) → (len> : length qs > n ) → FDup-in-list n qs\nfin-dup-in-list>n {zero} [] ()\nfin-dup-in-list>n {zero} (() ∷ qs) lt\nfin-dup-in-list>n {suc n} qs lt = fdup-phase0 where\n open import Level using ( Level )\n -- make a dup from one level below\n fdup+1 : (qs : List (Fin (suc n))) (i : Fin n) → fin-dup-in-list (fromℕ< a a (subst (λ k → toℕ x < suc k ) (sym fin ¬a₁ ¬b c = f1-phase2 qs p (case2 q1)\n -- two fcmp is only different in the size of Fin, but to develop both f1-phase and list-less both fcmps are required\n f1-phase2 (x ∷ qs) p (case1 q1) | tri> ¬a ¬b c with <-fcmp i (fromℕ< (≤-trans c (fin≤n (fromℕ< a ¬a₁ ¬b₂ c₁ = ⊥-elim ( ¬a₁ (subst₂ (λ j k → j < k) (sym fin+1-toℕ) (toℕ-fromℕ< _) a ))\n ... | tri≈ ¬a₁ b ¬c | tri< a ¬b₁ ¬c₁ = ⊥-elim ( ¬a₁ (subst₂ (λ j k → j < k) fin+1-toℕ (sym (toℕ-fromℕ< _)) a ))\n ... | tri≈ ¬a₁ b ¬c | tri≈ ¬a₂ b₁ ¬c₁ = refl\n ... | tri≈ ¬a₁ b ¬c | tri> ¬a₂ ¬b₁ c₁ = ⊥-elim ( ¬c (subst₂ (λ j k → j > k) fin+1-toℕ (sym (toℕ-fromℕ< _)) c₁ ))\n ... | tri> ¬a₁ ¬b₁ c₁ | tri< a ¬b₂ ¬c = ⊥-elim ( ¬c (subst₂ (λ j k → j > k) (sym fin+1-toℕ) (toℕ-fromℕ< _) c₁ ))\n ... | tri> ¬a₁ ¬b₁ c₁ | tri≈ ¬a₂ b ¬c = ⊥-elim ( ¬c (subst₂ (λ j k → j > k) (sym fin+1-toℕ) (toℕ-fromℕ< _) c₁ ))\n ... | tri> ¬a₁ ¬b₁ c₁ | tri> ¬a₂ ¬b₂ c₂ = f1-phase2 qs p (case1 q1)\n f1-phase2 (x ∷ qs) p (case2 q1) with <-fcmp (fromℕ< a a (subst (λ k → toℕ x < suc k ) (sym fin ¬a₁ ¬b c = ⊥-elim ( ¬-bool q1 refl )\n f1-phase2 (x ∷ qs) p (case2 q1) | tri> ¬a ¬b c with <-fcmp i (fromℕ< (≤-trans c (fin≤n (fromℕ< a ¬a₁ ¬b₂ c₁ = ⊥-elim ( ¬a₁ (subst₂ (λ j k → j < k) (sym fin+1-toℕ) (toℕ-fromℕ< _) a ))\n ... | tri≈ ¬a₁ b ¬c | tri< a ¬b₁ ¬c₁ = ⊥-elim ( ¬a₁ (subst₂ (λ j k → j < k) fin+1-toℕ (sym (toℕ-fromℕ< _)) a ))\n ... | tri≈ ¬a₁ b ¬c | tri≈ ¬a₂ b₁ ¬c₁ = refl\n ... | tri≈ ¬a₁ b ¬c | tri> ¬a₂ ¬b₁ c₁ = ⊥-elim ( ¬c (subst₂ (λ j k → j > k) fin+1-toℕ (sym (toℕ-fromℕ< _)) c₁ ))\n ... | tri> ¬a₁ ¬b₁ c₁ | tri< a ¬b₂ ¬c = ⊥-elim ( ¬c (subst₂ (λ j k → j > k) (sym fin+1-toℕ) (toℕ-fromℕ< _) c₁ ))\n ... | tri> ¬a₁ ¬b₁ c₁ | tri≈ ¬a₂ b ¬c = ⊥-elim ( ¬c (subst₂ (λ j k → j > k) (sym fin+1-toℕ) (toℕ-fromℕ< _) c₁ ))\n ... | tri> ¬a₁ ¬b₁ c₁ | tri> ¬a₂ ¬b₂ c₂ = f1-phase2 qs p (case2 q1 )\n f1-phase1 : (qs : List (Fin (suc n)) ) → fin-phase1 i (list-less qs) ≡ true\n → (fin-phase1 (fromℕ< a a (subst (λ k → toℕ x < suc k ) (sym fin ¬a₁ ¬b c = f1-phase1 qs p (case2 q1)\n f1-phase1 (x ∷ qs) p (case1 q1) | tri> ¬a ¬b c with <-fcmp i (fromℕ< (≤-trans c (fin≤n (fromℕ< a ¬a₁ ¬b₂ c₁ = ⊥-elim ( ¬a₁ (subst₂ (λ j k → j < k) (sym fin+1-toℕ) (toℕ-fromℕ< _) a ))\n ... | tri≈ ¬a₁ b ¬c | tri< a ¬b₁ ¬c₁ = ⊥-elim ( ¬a₁ (subst₂ (λ j k → j < k) fin+1-toℕ (sym (toℕ-fromℕ< _)) a ))\n ... | tri≈ ¬a₁ b ¬c | tri≈ ¬a₂ b₁ ¬c₁ = f1-phase2 qs p (case1 q1)\n ... | tri≈ ¬a₁ b ¬c | tri> ¬a₂ ¬b₁ c₁ = ⊥-elim ( ¬c (subst₂ (λ j k → j > k) fin+1-toℕ (sym (toℕ-fromℕ< _)) c₁ ))\n ... | tri> ¬a₁ ¬b₁ c₁ | tri< a ¬b₂ ¬c = ⊥-elim ( ¬c (subst₂ (λ j k → j > k) (sym fin+1-toℕ) (toℕ-fromℕ< _) c₁ ))\n ... | tri> ¬a₁ ¬b₁ c₁ | tri≈ ¬a₂ b ¬c = ⊥-elim ( ¬c (subst₂ (λ j k → j > k) (sym fin+1-toℕ) (toℕ-fromℕ< _) c₁ ))\n ... | tri> ¬a₁ ¬b₁ c₁ | tri> ¬a₂ ¬b₂ c₂ = f1-phase1 qs p (case1 q1)\n f1-phase1 (x ∷ qs) p (case2 q1) with <-fcmp (fromℕ< a a (subst (λ k → toℕ x < suc k ) (sym fin ¬a ¬b c with <-fcmp i (fromℕ< (≤-trans c (fin≤n (fromℕ< a ¬a₁ ¬b₂ c₁ = ⊥-elim ( ¬a₁ (subst₂ (λ j k → j < k) (sym fin+1-toℕ) (toℕ-fromℕ< _) a ))\n ... | tri≈ ¬a₁ b ¬c | tri< a ¬b₁ ¬c₁ = ⊥-elim ( ¬a₁ (subst₂ (λ j k → j < k) fin+1-toℕ (sym (toℕ-fromℕ< _)) a ))\n ... | tri≈ ¬a₁ b ¬c | tri≈ ¬a₂ b₁ ¬c₁ = f1-phase2 qs p (case2 q1)\n ... | tri≈ ¬a₁ b ¬c | tri> ¬a₂ ¬b₁ c₁ = ⊥-elim ( ¬c (subst₂ (λ j k → j > k) fin+1-toℕ (sym (toℕ-fromℕ< _)) c₁ ))\n ... | tri> ¬a₁ ¬b₁ c₁ | tri< a ¬b₂ ¬c = ⊥-elim ( ¬c (subst₂ (λ j k → j > k) (sym fin+1-toℕ) (toℕ-fromℕ< _) c₁ ))\n ... | tri> ¬a₁ ¬b₁ c₁ | tri≈ ¬a₂ b ¬c = ⊥-elim ( ¬c (subst₂ (λ j k → j > k) (sym fin+1-toℕ) (toℕ-fromℕ< _) c₁ ))\n ... | tri> ¬a₁ ¬b₁ c₁ | tri> ¬a₂ ¬b₂ c₂ = f1-phase1 qs p (case2 q1)\n fdup-phase0 : FDup-in-list (suc n) qs \n fdup-phase0 with fin-dup-in-list (fromℕ< a suc n → fin-dup-in-list (fromℕ< a n1 → fin-phase2 (fromℕ< a a (subst (λ k → toℕ x < suc k ) (sym fin ¬a ¬b c = s≤s z≤n \n fl-phase2 (suc n1) (x ∷ qs) (s≤s lt) p with <-fcmp (fromℕ< a a (subst (λ k → toℕ x < suc k ) (sym fin ¬a ¬b c = s≤s ( fl-phase2 n1 qs lt p )\n fl-phase1 : (n1 : ℕ) (qs : List (Fin (suc n))) → length qs > suc n1 → fin-phase1 (fromℕ< a a (subst (λ k → toℕ x < suc k ) (sym fin ¬a ¬b c = s≤s z≤n\n fl-phase1 (suc n1) (x ∷ qs) (s≤s lt) p with <-fcmp (fromℕ< a a (subst (λ k → toℕ x < suc k ) (sym fin ¬a ¬b c = s≤s ( fl-phase1 n1 qs lt p )\n -- if the list without the max element is only one length shorter, we can recurse\n fdup : FDup-in-list n (list-less qs)\n fdup = fin-dup-in-list>n (list-less qs) (fless qs lt ne)\n", "meta": {"hexsha": "00718934399ad12be87558781600828b061375f1", "size": 16472, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fin.agda", "max_stars_repo_name": "shinji-kono/automaton-in-agda", "max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/fin.agda", "max_issues_repo_name": "shinji-kono/automaton-in-agda", "max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/fin.agda", "max_forks_repo_name": "shinji-kono/automaton-in-agda", "max_forks_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 56.8, "max_line_length": 151, "alphanum_fraction": 0.4784482759, "num_tokens": 7671, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245953120233, "lm_q2_score": 0.7490872187162397, "lm_q1q2_score": 0.6242328033901196}} {"text": "{-\n\nFinite Types\n\nThis file formalize the notion of Rijke finite type,\nwhich is a direct generalization of Bishop finite set.\nBasically, a type is (Rijke) n-finite if its i-th order\nhomotopy groups πᵢ are Bishop finite for i ≤ n.\n\nReferrences:\n https://github.com/EgbertRijke/OEIS-A000001\n\n-}\n{-# OPTIONS --safe #-}\n\nmodule Cubical.Data.FinType.Base where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Structure\n\nopen import Cubical.HITs.SetTruncation\n\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Sigma\nopen import Cubical.Data.FinSet\n\nprivate\n variable\n ℓ ℓ' : Level\n n : ℕ\n X : Type ℓ\n\n-- the (Rijke) finite type\n\nisFinType : (n : ℕ) → Type ℓ → Type ℓ\nisFinType 0 X = isFinSet ∥ X ∥₂\nisFinType (suc n) X = (isFinType 0 X) × ((a b : X) → isFinType n (a ≡ b))\n\nisPropIsFinType : isProp (isFinType n X)\nisPropIsFinType {n = 0} = isPropIsFinSet\nisPropIsFinType {n = suc n} = isProp× isPropIsFinSet (isPropΠ2 (λ _ _ → isPropIsFinType {n = n}))\n\n-- the type of finite types\n\nFinType : (ℓ : Level)(n : ℕ) → Type (ℓ-suc ℓ)\nFinType ℓ n = TypeWithStr ℓ (isFinType n)\n\n-- basic numerical implications\n\nisFinTypeSuc→isFinType : isFinType (suc n) X → isFinType n X\nisFinTypeSuc→isFinType {n = 0} p = p .fst\nisFinTypeSuc→isFinType {n = suc n} p .fst = p .fst\nisFinTypeSuc→isFinType {n = suc n} p .snd a b = isFinTypeSuc→isFinType {n = n} (p .snd a b)\n\nisFinType→isFinType0 : isFinType n X → isFinType 0 X\nisFinType→isFinType0 {n = 0} p = p\nisFinType→isFinType0 {n = suc n} p = p .fst\n\nisFinTypeSuc→isFinType1 : isFinType (suc n) X → isFinType 1 X\nisFinTypeSuc→isFinType1 {n = 0} p = p\nisFinTypeSuc→isFinType1 {n = suc n} p .fst = p .fst\nisFinTypeSuc→isFinType1 {n = suc n} p .snd a b = isFinType→isFinType0 {n = suc n} (p .snd a b)\n", "meta": {"hexsha": "b700e887f35f8cc4b60fddf3397031974846b4cf", "size": 1808, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/FinType/Base.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_issues_repo_path": "Cubical/Data/FinType/Base.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Data/FinType/Base.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.25, "max_line_length": 97, "alphanum_fraction": 0.7079646018, "num_tokens": 677, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245870332531, "lm_q2_score": 0.7490872243177518, "lm_q1q2_score": 0.6242328018564763}} {"text": "module Structure.Operator.Names where\n\nopen import Functional.Dependent\nopen import Function.Names\nimport Lvl\nopen import Logic\nopen import Logic.Propositional\nopen import Logic.Predicate\nopen import Structure.Function.Names\nopen import Structure.Setoid\nopen import Syntax.Function\nopen import Syntax.Transitivity\nopen import Type\n\nprivate variable ℓ ℓₑ ℓ₁ ℓ₂ ℓ₃ ℓᵣ₂ ℓᵣ₃ ℓᵣ ℓₑ₁ ℓₑ₂ ℓₑ₃ ℓₑᵣ : Lvl.Level\n\nmodule _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ where\n -- Definition of commutativity of specific elements.\n -- The binary operation swapped yields the same result.\n -- Example: For any x, (x ▫ x) always commutes.\n Commuting : (T₁ → T₁ → T₂) → T₁ → T₁ → Stmt\n Commuting(_▫_) = pointwise₂,₂(_≡_) (_▫_) (swap(_▫_))\n\n -- Definition of commutativity.\n -- Order of application for the operation does not matter for equality.\n -- Example: Addition of the natural numbers (_+_ : ℕ → ℕ → ℕ).\n Commutativity : (T₁ → T₁ → T₂) → Stmt\n Commutativity = ∀² ∘ Commuting\n\n -- Definition of an left identity element.\n -- Example: Top implies a proposition in boolean logic (⊤ →_).\n Identityₗ : (T₁ → T₂ → T₂) → T₁ → Stmt\n Identityₗ (_▫_) id = ∀{x : T₂} → (id ▫ x) ≡ x\n\n -- Definition of a right absorber element\n -- Also called \"right neutral element\" or \"right annihilator\"\n -- Applying the operation on this element to the right always yields itself.\n -- Example: A proposition implies top in boolean logic (_→ ⊤).\n Absorberᵣ : (T₁ → T₂ → T₂) → T₂ → Stmt\n Absorberᵣ (_▫_) null = ∀{x : T₁} → (x ▫ null) ≡ null\n\n ConverseAbsorberᵣ : (T₁ → T₂ → T₂) → T₂ → Stmt\n ConverseAbsorberᵣ (_▫_)(a) = ∀{x y} → (x ▫ y ≡ a) → (y ≡ a)\n\nmodule _ {T₁ : Type{ℓ₁}} ⦃ _ : Equiv{ℓₑ₁}(T₁) ⦄ {T₂ : Type{ℓ₂}} where\n -- Definition of an right identity element\n -- Example: Subtracting 0 for integers (_− 0).\n Identityᵣ : (T₁ → T₂ → T₁) → T₂ → Stmt\n Identityᵣ(_▫_) id = Identityₗ(swap(_▫_)) id\n\n -- Definition of a left absorber element\n -- Also called \"left neutral element\" or \"left annihilator\"\n -- Example: Subtraction (monus) of 0 for natural numbers (0 − ).\n Absorberₗ : (T₁ → T₂ → T₁) → T₁ → Stmt\n Absorberₗ(_▫_) null = Absorberᵣ(swap(_▫_)) null\n\n ConverseAbsorberₗ : (T₁ → T₂ → T₁) → T₁ → Stmt\n ConverseAbsorberₗ (_▫_)(a) = ∀{x y} → (x ▫ y ≡ a) → (x ≡ a)\n\nmodule _ {T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ where\n -- Definition of an identity element\n -- Example: 0 for addition of integers, 1 for multiplication of integers.\n Identity : (T → T → T) → T → Stmt\n Identity (_▫_) id = (Identityₗ (_▫_) id) ∧ (Identityᵣ (_▫_) id)\n\n -- Definition of idempotence.\n Idempotence : (T → T → T) → Stmt\n Idempotence (_▫_) = ∀{x : T} → (x ▫ x ≡ x)\n\n -- Example: 0 for addition of natural numbers, 1 for multiplication of natural numbers.\n ConverseAbsorber : (T → T → T) → T → Stmt\n ConverseAbsorber (_▫_)(a) = ∀{x y} → (x ▫ y ≡ a) → (x ≡ a)∧(y ≡ a)\n\n -- Example: 0 for multiplication of natural numbers.\n WeakConverseAbsorber : (T → T → T) → T → Stmt\n WeakConverseAbsorber (_▫_)(a) = ∀{x y} → (x ▫ y ≡ a) → (x ≡ a)∨(y ≡ a)\n\nmodule _ {T₊ : Type{ℓ₁}} {T₋ : Type{ℓ₂}} {Tᵣ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑᵣ}(Tᵣ) ⦄ where\n -- Definition of a left inverse element.\n InverseElementₗ : (T₋ → T₊ → Tᵣ) → Tᵣ → T₊ → T₋ → Stmt\n InverseElementₗ (_▫_) id x x⁻¹ = ((x⁻¹ ▫ x) ≡ id)\n\n -- Definition of a right inverse element\n InverseElementᵣ : (T₊ → T₋ → Tᵣ) → Tᵣ → T₊ → T₋ → Stmt\n InverseElementᵣ (_▫_) id x x⁻¹ = ((x ▫ x⁻¹) ≡ id)\n\n -- Definition of a left inverse function\n InverseFunctionₗ : (T₋ → T₊ → Tᵣ) → Tᵣ → (T₊ → T₋) → Stmt\n InverseFunctionₗ (_▫_) id inv = ∀{x : T₊} → InverseElementₗ(_▫_) id x (inv x)\n\n -- Definition of a right inverse function\n InverseFunctionᵣ : (T₊ → T₋ → Tᵣ) → Tᵣ → (T₊ → T₋) → Stmt\n InverseFunctionᵣ (_▫_) id inv = ∀{x : T₊} → InverseElementᵣ(_▫_) id x (inv x)\n\nmodule _ {T : Type{ℓ₁}} {Tᵣ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑᵣ}(Tᵣ) ⦄ where\n -- Definition of an invertible element\n InverseElement : (T → T → Tᵣ) → Tᵣ → T → T → Stmt\n InverseElement (_▫_) id x x⁻¹ = (InverseElementₗ(_▫_) id x x⁻¹) ∧ (InverseElementᵣ(_▫_) id x x⁻¹)\n\n -- Definition of a function which returns the inverse element of the other side of the operation\n InverseFunction : (T → T → Tᵣ) → Tᵣ → (T → T) → Stmt\n InverseFunction (_▫_) id inv = (InverseFunctionₗ (_▫_) id inv) ∧ (InverseFunctionᵣ (_▫_) id inv)\n\nmodule _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ {T₃ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑ₃}(T₃) ⦄ where\n -- Definition of right cancellation of a specific object\n -- ∀{a b : T₂} → ((x ▫ a) ≡ (x ▫ b)) → (a ≡ b)\n CancellationOnₗ : (T₁ → T₂ → T₃) → T₁ → Stmt\n CancellationOnₗ (_▫_) (x) = Injective(x ▫_)\n\n -- Definition of left cancellation (Injectivity for the right param)\n -- ∀{x : T₁}{a b : T₂} → ((x ▫ a) ≡ (x ▫ b)) → (a ≡ b)\n Cancellationₗ : (T₁ → T₂ → T₃) → Stmt\n Cancellationₗ (_▫_) = (∀{x : T₁} → CancellationOnₗ(_▫_)(x))\n\nmodule _ {T₁ : Type{ℓ₁}} ⦃ _ : Equiv{ℓₑ₁}(T₁) ⦄ {T₂ : Type{ℓ₂}} {T₃ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑ₃}(T₃) ⦄ where\n -- Definition of right cancellation of a specific object\n -- ∀{a b : T₁} → ((a ▫ x) ≡ (b ▫ x)) → (a ≡ b)\n CancellationOnᵣ : (T₁ → T₂ → T₃) → T₂ → Stmt\n CancellationOnᵣ (_▫_) (x) = Injective(_▫ x)\n\n -- Definition of right cancellation (Injectivity for the left param)\n -- ∀{x : T₂}{a b : T₁} → ((a ▫ x) ≡ (b ▫ x)) → (a ≡ b)\n Cancellationᵣ : (T₁ → T₂ → T₃) → Stmt\n Cancellationᵣ (_▫_) = (∀{x : T₂} → CancellationOnᵣ (_▫_)(x))\n\nmodule _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} {T₃ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ where\n -- Definition of the left inverse property\n InverseOperatorOnₗ : (T₁ → T₂ → T₃) → (T₁ → T₃ → T₂) → T₁ → T₂ → Stmt\n InverseOperatorOnₗ (_▫₁_) (_▫₂_) x y = (x ▫₂ (x ▫₁ y) ≡ y)\n\n InverseOperatorₗ : (T₁ → T₂ → T₃) → (T₁ → T₃ → T₂) → Stmt\n InverseOperatorₗ (_▫₁_)(_▫₂_) = ∀{x y} → InverseOperatorOnₗ(_▫₁_)(_▫₂_) x y\n\nmodule _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} {T₃ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑ₁}(T₁) ⦄ where\n -- Definition of the right inverse property\n InverseOperatorOnᵣ : (T₁ → T₂ → T₃) → (T₃ → T₂ → T₁) → T₁ → T₂ → Stmt\n InverseOperatorOnᵣ (_▫₁_) (_▫₂_) x y = ((x ▫₁ y) ▫₂ y ≡ x)\n\n InverseOperatorᵣ : (T₁ → T₂ → T₃) → (T₃ → T₂ → T₁) → Stmt\n InverseOperatorᵣ (_▫₁_)(_▫₂_) = ∀{x y} → InverseOperatorOnᵣ(_▫₁_)(_▫₂_) x y\n\nmodule _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ where\n InversePropertyₗ : (T₁ → T₂ → T₂) → (T₁ → T₁) → Stmt\n InversePropertyₗ (_▫_) inv = InverseOperatorₗ(_▫_)(a ↦ b ↦ inv(a) ▫ b)\n\n InversePropertyᵣ : (T₂ → T₁ → T₂) → (T₁ → T₁) → Stmt\n InversePropertyᵣ (_▫_) inv = InverseOperatorᵣ(_▫_)(a ↦ b ↦ a ▫ inv(b))\n\n---------------------------------------------------------\n-- Patterns\n\nmodule _ {T₁ : Type{ℓ₁}}{T₂ : Type{ℓ₂}}{T₃ : Type{ℓ₃}}{Tᵣ₂ : Type{ℓᵣ₂}}{Tᵣ₃ : Type{ℓᵣ₃}}{Tᵣ : Type{ℓᵣ}} ⦃ _ : Equiv{ℓₑᵣ}(Tᵣ) ⦄ where\n AssociativityPattern : (T₁ → T₂ → Tᵣ₃) → (Tᵣ₃ → T₃ → Tᵣ) → (T₁ → Tᵣ₂ → Tᵣ) → (T₂ → T₃ → Tᵣ₂)→ Stmt\n AssociativityPattern (_▫₁_) (_▫₂_) (_▫₃_) (_▫₄_) =\n ∀{x : T₁}{y : T₂}{z : T₃} → ((x ▫₁ y) ▫₂ z) ≡ (x ▫₃ (y ▫₄ z))\n\nmodule _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} {T₃ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑ₃}(T₃) ⦄ where\n DistributivityPatternₗ : (T₁ → T₂ → T₃) → (T₂ → T₂ → T₂) → (T₃ → T₃ → T₃) → Stmt\n DistributivityPatternₗ (_▫₁_) (_▫₂_) (_▫₃_) =\n ∀{x : T₁} {y z : T₂} → (x ▫₁ (y ▫₂ z)) ≡ ((x ▫₁ y) ▫₃ (x ▫₁ z))\n\n DistributivityPatternᵣ : (T₁ → T₂ → T₃) → (T₁ → T₁ → T₁) → (T₃ → T₃ → T₃) → Stmt\n DistributivityPatternᵣ (_▫₁_) (_▫₂_) (_▫₃_) =\n ∀{x y : T₁} {z : T₂} → ((x ▫₂ y) ▫₁ z) ≡ ((x ▫₁ z) ▫₃ (y ▫₁ z))\n\n---------------------------------------------------------\n-- Derived\n\nmodule _ {T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ where\n -- Definition of associativity for a binary operation\n Associativity : (T → T → T) → Stmt\n Associativity (_▫_) = AssociativityPattern (_▫_) (_▫_) (_▫_) (_▫_)\n -- {x y z : T} → ((x ▫ y) ▫ z) ≡ (x ▫ (y ▫ z))\n\nmodule _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ where\n -- Definition of compatibility for a binary operation\n Compatibility : (T₁ → T₁ → T₁) → (T₁ → T₂ → T₂) → Stmt -- TODO: https://en.wikipedia.org/wiki/Semigroup_action\n Compatibility (_▫₁_) (_▫₂_) = AssociativityPattern (_▫₁_) (_▫₂_) (_▫₂_) (_▫₂_)\n -- {x₁ x₂ : T₁}{y : T₂} → ((x₁ ▫₁ x₂) ▫₂ y) ≡ (x₁ ▫₂ (x₂ ▫₂ y))\n\n -- Definition of left distributivity for a binary operation\n Distributivityₗ : (T₁ → T₂ → T₂) → (T₂ → T₂ → T₂) → Stmt\n Distributivityₗ (_▫₁_) (_▫₂_) = DistributivityPatternₗ (_▫₁_) (_▫₂_) (_▫₂_)\n -- ∀{x : T₁} {y z : T₂} → (x ▫₁ (y ▫₂ z)) ≡ (x ▫₁ y) ▫₂ (x ▫₁ z)\n\n -- Definition of right distributivity for a binary operation\n Distributivityᵣ : (T₂ → T₁ → T₂) → (T₂ → T₂ → T₂) → Stmt\n Distributivityᵣ (_▫₁_) (_▫₂_) = DistributivityPatternᵣ (_▫₁_) (_▫₂_) (_▫₂_)\n -- ∀{x y : T₂} {z : T₁} → ((x ▫₂ y) ▫₁ z) ≡ (x ▫₁ z) ▫₂ (y ▫₁ z)\n\nmodule _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} {T₃ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑ₁}(T₁) ⦄ where\n -- Definition of left absorption for two binary operators\n Absorptionₗ : (T₁ → T₃ → T₁) → (T₁ → T₂ → T₃) → Stmt\n Absorptionₗ (_▫₁_)(_▫₂_) = ∀{x : T₁}{y : T₂} → (x ▫₁ (x ▫₂ y) ≡ x)\n\nmodule _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} {T₃ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ where\n -- Definition of right absorption for two binary operators\n Absorptionᵣ : (T₃ → T₂ → T₂) → (T₁ → T₂ → T₃) → Stmt\n Absorptionᵣ (_▫₁_)(_▫₂_) = ∀{x : T₁}{y : T₂} → ((x ▫₂ y) ▫₁ y ≡ y)\n\n---------------------------------------------------------\n-- Functions (TODO: Move to Structure.Operator.Proofs)\n{-\nopen import Relator.Equals{ℓ₁}{ℓ₂}\nopen import Relator.Equals.Proofs{ℓ₁}{ℓ₂}\n\n-- Returns a commuted LHS of an equality\ncommuteₗ : ∀{T}{_▫_}{x y z} → ⦃ _ : Commutativity {T} {T} (_▫_) ⦄ → ((x ▫ y) ≡ z) → ((y ▫ x) ≡ z)\ncommuteₗ ⦃ comm ⦄ stmt = comm 🝖 stmt\n\n-- Returns a commuted RHS of an equality\ncommuteᵣ : ∀{T}{_▫_}{x y z} → ⦃ _ : Commutativity {T} {T} (_▫_) ⦄ → (z ≡ (x ▫ y)) → (z ≡ (y ▫ x))\ncommuteᵣ ⦃ comm ⦄ stmt = stmt 🝖 comm\n\ncommuteBoth : ∀{T₁ T₂}{_▫_}{a₁ a₂ b₁ b₂} → Commutativity{T₁}{T₂}(_▫_) → (a₁ ▫ a₂ ≡ b₁ ▫ b₂) → (a₂ ▫ a₁ ≡ b₂ ▫ b₁)\ncommuteBoth {_}{_} {a₁} {a₂} {b₁} {b₂} commutativity (a₁▫a₂≡b₁▫b₂) =\n (symmetry ⦃ [≡]-symmetry ⦄ (commutativity {a₁} {a₂}))\n 🝖' (a₁▫a₂≡b₁▫b₂)\n 🝖' (commutativity {b₁} {b₂})\n where\n _🝖'_ = _🝖_ ⦃ [≡]-transitivity ⦄\n infixl 1000 _🝖'_\n-}\n", "meta": {"hexsha": "1bd287c63f25bc032e51f34dae6ba4fe8dd8e406", "size": 10167, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Operator/Names.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Operator/Names.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Operator/Names.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.3883928571, "max_line_length": 132, "alphanum_fraction": 0.5766696174, "num_tokens": 4786, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245787544824, "lm_q2_score": 0.7490872131147275, "lm_q1q2_score": 0.6242327863191994}} {"text": "-- Andreas, AIM XXIII 2016-04-21 Overloaded projections\n\n-- Milestone 1: Check overloaded projections on rhs (without postponing).\n\nmodule _ (A : Set) (a : A) where\n\nmodule RecDefs where\n\n record R B : Set where\n field f : B\n open R public\n\n record S B : Set where\n field f : B\n open S public\n\n record T B : Set where\n field f : B → B\n open T public\n\nopen RecDefs public\n\nr : R A\nR.f r = a\n\ns : S A\nS.f s = f r\n\nt : R A → S A\nS.f (t r) = f r\n\nu : _\nu = f s\n\nv = f s\n\nw : ∀{A} → T A → A → A\nw t x = f t x\n", "meta": {"hexsha": "342e0dffa82548de24ce8323a588fc656b558816", "size": 519, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1944-1.agda", "max_stars_repo_name": "pthariensflame/agda", "max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Succeed/Issue1944-1.agda", "max_issues_repo_name": "pthariensflame/agda", "max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/Issue1944-1.agda", "max_forks_repo_name": "pthariensflame/agda", "max_forks_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 13.3076923077, "max_line_length": 73, "alphanum_fraction": 0.5857418112, "num_tokens": 192, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744761936438, "lm_q2_score": 0.7634837689358857, "lm_q1q2_score": 0.6242048424701057}} {"text": "open import prelude\n\n-- Copied pretty much verbatim\n\ndata Term : Set where\n true : Term\n false : Term\n if_then_else_end : Term → Term → Term → Term\n zero : Term\n succ : Term → Term\n iszero : Term → Term\n \ndata NValue : Term → Set where\n zero : NValue zero\n succ : ∀ {t} → NValue(t) → NValue(succ t)\n \ndata Value : Term → Set where\n true : Value true\n false : Value false\n nv : ∀ {t} → NValue(t) → Value(t)\n \ndata _⟶_ : Term → Term → Set where\n\n E─IfTrue : ∀ {t₂ t₃} →\n\n -----------------------------------\n if true then t₂ else t₃ end ⟶ t₂\n\n E─IfFalse : ∀ {t₂ t₃} →\n \n -----------------------------------\n if false then t₂ else t₃ end ⟶ t₃\n\n E─IfCong : ∀ {t₁ t₁′ t₂ t₃} →\n \n (t₁ ⟶ t₁′) →\n ----------------------------------------------------------\n (if t₁ then t₂ else t₃ end ⟶ if t₁′ then t₂ else t₃ end)\n\n E─SuccCong : ∀ {t₁ t₁′} →\n \n (t₁ ⟶ t₁′) →\n ----------------------\n (succ t₁ ⟶ succ t₁′)\n\n E─IsZero : \n \n ----------------------\n (iszero zero ⟶ true)\n\n E─IsSucc : ∀ {n} →\n \n --------------------------\n (iszero (succ n) ⟶ false)\n\n E─IsCong : ∀ {t₁ t₁′} →\n \n (t₁ ⟶ t₁′) →\n --------------------------\n (iszero t₁ ⟶ iszero t₁′)\n \ndata Redex : Term → Set where\n\n redex : ∀ {t t′} →\n \n t ⟶ t′ →\n --------\n Redex(t)\n\n-- Types\n\ndata Type : Set where\n bool : Type\n nat : Type\n\ndata _∈_ : Term → Type → Set where\n\n T-True :\n\n -----------\n true ∈ bool\n \n T-False :\n\n -----------\n false ∈ bool\n \n T-If : ∀ {t₁ t₂ t₃ T} →\n\n t₁ ∈ bool →\n t₂ ∈ T →\n t₃ ∈ T →\n -----------------------------\n if t₁ then t₂ else t₃ end ∈ T\n\n T-Zero :\n\n ----------\n zero ∈ nat\n \n T-Succ : ∀ {t₁} →\n\n t₁ ∈ nat →\n -------------\n succ t₁ ∈ nat\n \n T-IsZero : ∀ {t₁} →\n\n t₁ ∈ nat →\n -------------\n iszero t₁ ∈ bool\n \n \n-- Proving that well-typed terms stay well-typed\n\npreservation : ∀ {t t′ T} → (t ∈ T) → (t ⟶ t′) → (t′ ∈ T)\npreservation (T-If p₁ p₂ p₃) E─IfTrue = p₂\npreservation (T-If p₁ p₂ p₃) E─IfFalse = p₃\npreservation (T-If p₁ p₂ p₃) (E─IfCong q) = T-If (preservation p₁ q) p₂ p₃\npreservation (T-Succ p) (E─SuccCong q) = T-Succ (preservation p q)\npreservation (T-IsZero p) E─IsZero = T-True\npreservation (T-IsZero p) E─IsSucc = T-False\npreservation (T-IsZero p) (E─IsCong q) = T-IsZero (preservation p q)\n\n-- Proving that every term is a value or a redex\n\ndata ValueOrRedex : Term → Set where\n\n value : ∀ {t} →\n\n (Value(t)) →\n ---------------\n ValueOrRedex(t)\n\n redex : ∀ {t t′} →\n \n t ⟶ t′ →\n ---------------\n ValueOrRedex(t)\n\nprogress : ∀ {t T} → (t ∈ T) → ValueOrRedex(t)\nprogress T-True = value true\nprogress T-False = value false\nprogress (T-If p₁ p₂ p₃) = helper (progress p₁) p₁ where\n\n helper : ∀ {t₀ t₁ t₂} → ValueOrRedex(t₀) → t₀ ∈ bool → ValueOrRedex(if t₀ then t₁ else t₂ end)\n helper (value true) p = redex E─IfTrue\n helper (value false) p = redex E─IfFalse\n helper (redex r) p = redex (E─IfCong r)\n helper (value (nv ())) T-True\n helper (value (nv ())) T-False\n helper (value (nv ())) (T-If p p₁ p₂)\n\nprogress T-Zero = value (nv zero)\nprogress (T-Succ p) = helper (progress p) p where\n\n helper : ∀ {t₀} → ValueOrRedex(t₀) → t₀ ∈ nat → ValueOrRedex(succ t₀)\n helper (value (nv n)) p = value (nv (succ n))\n helper (redex r) p = redex (E─SuccCong r)\n\nprogress (T-IsZero p) = helper (progress p) p where\n\n helper : ∀ {t₀} → ValueOrRedex(t₀) → t₀ ∈ nat → ValueOrRedex(iszero t₀)\n helper (value (nv zero)) p = redex E─IsZero\n helper (value (nv (succ x))) p = redex E─IsSucc\n helper (redex r) p = redex (E─IsCong r)\n\n-- Interpreter\n\ndata _⟶*_ : Term → Term → Set where\n\n done : ∀ {t} →\n\n --------\n t ⟶* t\n\n redex : ∀ {t t′ t″} →\n\n t ⟶ t′ →\n t′ ⟶* t″ →\n ----------\n t ⟶* t″\n\n-- An interpreter result\n\ndata Result : Term → Set where\n\n result : ∀ {t t′} →\n \n t ⟶* t′ →\n Value(t′) →\n ---------\n Result(t)\n\n-- The interpreter just calls `progress` until it is a value.\n-- This might bot terminate!\n\n{-# NON_TERMINATING #-}\ninterp : ∀ {t T} → (t ∈ T) → Result(t)\ninterp p = helper₂ p (progress p) where\n\n helper₁ : ∀ {t t′} → (t ⟶ t′) → Result(t′) → Result(t)\n helper₁ r (result s v) = result (redex r s) v\n\n helper₂ : ∀ {t T} → (t ∈ T) → ValueOrRedex(t) → Result(t)\n helper₂ p (value v) = result done v\n helper₂ p (redex r) = helper₁ r (interp (preservation p r))\n\nex = if (iszero zero) then (succ zero) else (zero) end\n\nexNat : (ex ∈ nat)\nexNat = T-If (T-IsZero T-Zero) (T-Succ T-Zero) T-Zero\n\n-- Normalize (C-N) interp exNat\n-- result\n-- (redex (E─IfCong E─IsZero)\n-- (redex E─IfTrue\n-- done))\n-- (nv (succ zero))\n", "meta": {"hexsha": "4a3e1bbe23385d1d1181721ce5116d801f9123df", "size": 4656, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "ch8.agda", "max_stars_repo_name": "asajeffrey/tapl", "max_stars_repo_head_hexsha": "de2ae6c24d001b85a5032c9e06cc731557dbc5e5", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-03-12T22:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-15T12:09:59.000Z", "max_issues_repo_path": "ch8.agda", "max_issues_repo_name": "asajeffrey/tapl", "max_issues_repo_head_hexsha": "de2ae6c24d001b85a5032c9e06cc731557dbc5e5", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ch8.agda", "max_forks_repo_name": "asajeffrey/tapl", "max_forks_repo_head_hexsha": "de2ae6c24d001b85a5032c9e06cc731557dbc5e5", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.1636363636, "max_line_length": 96, "alphanum_fraction": 0.5120274914, "num_tokens": 1721, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744673038222, "lm_q2_score": 0.7634837635542925, "lm_q1q2_score": 0.6242048312830181}} {"text": "------------------------------------------------------------------------\n-- Unary relations (variant for Set₁)\n------------------------------------------------------------------------\n\n-- I want universe polymorphism.\n\nmodule Relation.Unary1 where\n\n------------------------------------------------------------------------\n-- Unary relations\n\nPred : Set → Set₂\nPred a = a → Set₁\n\n------------------------------------------------------------------------\n-- Unary relations can be seen as sets\n\n-- I.e., they can be seen as subsets of the universe of discourse.\n\nprivate\n module Dummy {a : Set} -- The universe of discourse.\n where\n\n -- Set membership.\n\n infix 4 _∈_\n\n _∈_ : a → Pred a → Set₁\n x ∈ P = P x\n\n -- The property of being universal.\n\n Universal : Pred a → Set₁\n Universal P = ∀ x → x ∈ P\n\n -- P ⊆ Q means that P is a subset of Q. _⊆′_ is a variant of _⊆_.\n\n infix 4 _⊆_ _⊇_ _⊆′_ _⊇′_\n\n _⊆_ : Pred a → Pred a → Set₁\n P ⊆ Q = ∀ {x} → x ∈ P → x ∈ Q\n\n _⊆′_ : Pred a → Pred a → Set₁\n P ⊆′ Q = ∀ x → x ∈ P → x ∈ Q\n\n _⊇_ : Pred a → Pred a → Set₁\n Q ⊇ P = P ⊆ Q\n\n _⊇′_ : Pred a → Pred a → Set₁\n Q ⊇′ P = P ⊆′ Q\n\nopen Dummy public\n", "meta": {"hexsha": "3339ecaf5eceb27d2fa77267e4ba9896b7784d86", "size": 1156, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Relation/Unary1.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Relation/Unary1.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Relation/Unary1.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 21.8113207547, "max_line_length": 72, "alphanum_fraction": 0.4230103806, "num_tokens": 347, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9099069987088003, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.6241502157141354}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Algebra\nopen import Relation.Unary\nopen import Relation.Binary hiding (Decidable)\n\nmodule Data.FingerTree.Split\n {r m}\n (ℳ : Monoid r m)\n {s}\n {ℙ : Pred (Monoid.Carrier ℳ) s}\n (ℙ-resp : ℙ Respects (Monoid._≈_ ℳ))\n (ℙ? : Decidable ℙ)\n where\n\nopen import Relation.Nullary using (¬_; yes; no; Dec)\nopen import Level using (_⊔_)\nopen import Data.Product\nopen import Function\nopen import Data.List as List using (List; _∷_; [])\n\nopen import Data.FingerTree.Measures ℳ\nopen import Data.FingerTree.Structures ℳ\nopen import Data.FingerTree.Reasoning ℳ\nopen import Data.FingerTree.View ℳ using (deepₗ; deepᵣ)\nopen import Data.FingerTree.Cons ℳ using (listToTree)\n\nopen import Relation.Nullary using (Dec; yes; no)\nopen import Relation.Nullary.Decidable using (True; toWitness; False; toWitnessFalse)\n\nopen σ ⦃ ... ⦄\n\nopen Monoid ℳ renaming (Carrier to 𝓡)\n\nopen import Data.FingerTree.Relation.Binary.Reasoning.FasterInference.Setoid setoid\n\nopen import Data.FingerTree.Split.Point ℳ ℙ-resp ℙ?\nopen import Data.FingerTree.Split.StoredPredicate ℳ ℙ-resp ℙ?\nopen import Data.FingerTree.Split.Intermediate ℳ ℙ-resp ℙ?\nopen import Data.FingerTree.Split.Structures ℳ ℙ-resp ℙ?\n\nrecord Split {a} (Σ : Set a) ⦃ _ : σ Σ ⦄ : Set (a ⊔ r ⊔ m ⊔ s) where\n constructor _∷⟨_⟩∷_[_]\n field\n left : Tree Σ\n focus : Σ\n right : Tree Σ\n is-split : μ left ∣ μ focus\nopen Split public\n\ninstance\n σ-Split : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → σ (Split Σ)\n μ ⦃ σ-Split ⦄ (l ∷⟨ x ⟩∷ r [ _ ]) = μ l ∙ (μ x ∙ μ r)\n\n\nsplit : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄\n → {¬ℙ⟨ε⟩ : False (ℙ? ε)}\n → (xs : Tree Σ)\n → {ℙ⟨xs⟩ : True (ℙ? (μ xs))}\n → μ⟨ Split Σ ⟩≈ μ xs\nsplit {¬ℙ⟨ε⟩ = ¬ℙ⟨ε⟩} xs {ℙ⟨xs⟩} with splitTree ε xs (init-ℙ ¬ℙ⟨ε⟩ ℙ⟨xs⟩) ≈[ identityˡ _ ]\n... | xs′ ∷⟨ x ⟩∷ ys [ p ] ⇑[ p₂ ] = xs′ ∷⟨ x ⟩∷ ys [ Relation.Nullary.recompute (_ ∣? _) p ≈◄⟅ identityˡ _ ⟆ ] ⇑[ sym (identityˡ _) ⍮ p₂ ]\n", "meta": {"hexsha": "92b6a451de209ab3ecf05c5fb76da8c53e863bda", "size": 1931, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/FingerTree/Split.agda", "max_stars_repo_name": "oisdk/agda-indexed-fingertree", "max_stars_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-02-26T07:04:54.000Z", "max_stars_repo_stars_event_max_datetime": "2019-02-26T07:04:54.000Z", "max_issues_repo_path": "src/Data/FingerTree/Split.agda", "max_issues_repo_name": "oisdk/agda-indexed-fingertree", "max_issues_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/FingerTree/Split.agda", "max_forks_repo_name": "oisdk/agda-indexed-fingertree", "max_forks_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.6507936508, "max_line_length": 140, "alphanum_fraction": 0.6447436561, "num_tokens": 759, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9099070035949656, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.6241502132241041}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\nopen import Categories.Monad\n\nmodule Categories.Category.Construction.EilenbergMoore {o ℓ e} {C : Category o ℓ e} (M : Monad C) where\n\nopen import Level\n\nopen import Categories.Morphism.Reasoning C\n\nprivate\n module C = Category C\n module M = Monad M\n open C\n open M.F\n open HomReasoning\n\nrecord Module : Set (o ⊔ ℓ ⊔ e) where\n field\n A : Obj\n action : F₀ A ⇒ A\n commute : action ∘ F₁ action ≈ action ∘ M.μ.η A\n identity : action ∘ M.η.η A ≈ C.id\n\nrecord Module⇒ (X Y : Module) : Set (ℓ ⊔ e) where\n private\n module X = Module X\n module Y = Module Y\n field\n arr : X.A ⇒ Y.A\n commute : arr ∘ X.action ≈ Y.action ∘ F₁ arr\n\nEilenbergMoore : Category (o ⊔ ℓ ⊔ e) (ℓ ⊔ e) e\nEilenbergMoore = record\n { Obj = Module\n ; _⇒_ = Module⇒\n ; _≈_ = λ f g → Module⇒.arr f ≈ Module⇒.arr g\n ; id = record\n { arr = C.id\n ; commute = id-comm-sym ○ ∘-resp-≈ʳ (⟺ identity)\n }\n ; _∘_ = compose\n ; assoc = assoc\n ; sym-assoc = sym-assoc\n ; identityˡ = identityˡ\n ; identityʳ = identityʳ\n ; identity² = identity²\n ; equiv = record\n { refl = refl\n ; sym = sym\n ; trans = trans\n }\n ; ∘-resp-≈ = ∘-resp-≈\n }\n where compose : ∀ {X Y Z} → Module⇒ Y Z → Module⇒ X Y → Module⇒ X Z\n compose {X} {Y} {Z} f g = record\n { arr = f.arr ∘ g.arr\n ; commute = begin\n (f.arr ∘ g.arr) ∘ Module.action X ≈⟨ pullʳ g.commute ⟩\n f.arr ∘ Module.action Y ∘ F₁ g.arr ≈⟨ pullˡ f.commute ⟩\n (Module.action Z ∘ F₁ f.arr) ∘ F₁ g.arr ≈˘⟨ pushʳ homomorphism ⟩\n Module.action Z ∘ F₁ (f.arr ∘ g.arr) ∎\n }\n where module f = Module⇒ f\n module g = Module⇒ g\n", "meta": {"hexsha": "9208c3e16cc79f7a5758d2f2eb669d23156a0847", "size": 1812, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Construction/EilenbergMoore.agda", "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Category/Construction/EilenbergMoore.agda", "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Construction/EilenbergMoore.agda", "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.0447761194, "max_line_length": 103, "alphanum_fraction": 0.5397350993, "num_tokens": 668, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339516289534, "lm_q2_score": 0.7431680086124811, "lm_q1q2_score": 0.6240634085963788}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Subsets of finite sets\n------------------------------------------------------------------------\n\nmodule Data.Fin.Subset where\n\nopen import Algebra\nimport Algebra.Properties.BooleanAlgebra as BoolAlgProp\nimport Algebra.Properties.BooleanAlgebra.Expression as BAExpr\nimport Data.Bool.Properties as BoolProp\nopen import Data.Fin\nopen import Data.List as List using (List)\nopen import Data.Nat\nopen import Data.Product\nopen import Data.Vec using (Vec; _∷_; _[_]=_)\nimport Relation.Binary.Vec.Pointwise as Pointwise\nopen import Relation.Nullary\n\ninfix 4 _∈_ _∉_ _⊆_ _⊈_\n\n------------------------------------------------------------------------\n-- Definitions\n\n-- Sides.\n\nopen import Data.Bool public\n using () renaming (Bool to Side; true to inside; false to outside)\n\n-- Partitions a finite set into two parts, the inside and the outside.\n\nSubset : ℕ → Set\nSubset = Vec Side\n\n------------------------------------------------------------------------\n-- Membership and subset predicates\n\n_∈_ : ∀ {n} → Fin n → Subset n → Set\nx ∈ p = p [ x ]= inside\n\n_∉_ : ∀ {n} → Fin n → Subset n → Set\nx ∉ p = ¬ (x ∈ p)\n\n_⊆_ : ∀ {n} → Subset n → Subset n → Set\np₁ ⊆ p₂ = ∀ {x} → x ∈ p₁ → x ∈ p₂\n\n_⊈_ : ∀ {n} → Subset n → Subset n → Set\np₁ ⊈ p₂ = ¬ (p₁ ⊆ p₂)\n\n------------------------------------------------------------------------\n-- Set operations\n\n-- Pointwise lifting of the usual boolean algebra for booleans gives\n-- us a boolean algebra for subsets.\n--\n-- The underlying equality of the returned boolean algebra is\n-- propositional equality.\n\nbooleanAlgebra : ℕ → BooleanAlgebra _ _\nbooleanAlgebra n =\n BoolAlgProp.replace-equality\n (BAExpr.lift BoolProp.booleanAlgebra n)\n Pointwise.Pointwise-≡\n\nprivate\n open module BA {n} = BooleanAlgebra (booleanAlgebra n) public\n using\n ( ⊥ -- The empty subset.\n ; ⊤ -- The subset containing all elements.\n )\n renaming\n ( _∨_ to _∪_ -- Binary union.\n ; _∧_ to _∩_ -- Binary intersection.\n ; ¬_ to ∁ -- Complement.\n )\n\n-- A singleton subset, containing just the given element.\n\n⁅_⁆ : ∀ {n} → Fin n → Subset n\n⁅ zero ⁆ = inside ∷ ⊥\n⁅ suc i ⁆ = outside ∷ ⁅ i ⁆\n\n-- N-ary union.\n\n⋃ : ∀ {n} → List (Subset n) → Subset n\n⋃ = List.foldr _∪_ ⊥\n\n-- N-ary intersection.\n\n⋂ : ∀ {n} → List (Subset n) → Subset n\n⋂ = List.foldr _∩_ ⊤\n\n------------------------------------------------------------------------\n-- Properties\n\nNonempty : ∀ {n} (p : Subset n) → Set\nNonempty p = ∃ λ f → f ∈ p\n\nEmpty : ∀ {n} (p : Subset n) → Set\nEmpty p = ¬ Nonempty p\n\n-- Point-wise lifting of properties.\n\nLift : ∀ {n} → (Fin n → Set) → (Subset n → Set)\nLift P p = ∀ {x} → x ∈ p → P x\n", "meta": {"hexsha": "73578d7b0fbb9a52d3c9c47e4f2930cbe560d300", "size": 2745, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Fin/Subset.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Fin/Subset.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Fin/Subset.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.6542056075, "max_line_length": 72, "alphanum_fraction": 0.5391621129, "num_tokens": 769, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321983146848, "lm_q2_score": 0.7745833893685269, "lm_q1q2_score": 0.6240293187550058}} {"text": "module Category.Core where\n\nopen import Level\nopen import Data.Product\n-- open import Relation.Binary as B using ()\nopen import Relation.Binary as B using ()\nopen import Relation.Binary.Indexed\nopen import Relation.Binary.PropositionalEquality as PropEq using (_≡_; refl)\n\nrecord IsMorphism {𝒸 ℓ : Level}\n {Object : Set 𝒸}\n {Carrier : (Object × Object) → Set 𝒸}\n (_≈_ : Rel Carrier ℓ)\n (_∘_ : ∀ {a b c} → Carrier (b , c) → Carrier (a , b) → Carrier (a , c))\n (id : (a : Object) → Carrier (a , a))\n : Set (suc (𝒸 ⊔ ℓ)) where\n _⇒_ = curry Carrier\n field\n assoc : ∀ {a b c d : Object}\n → (f : a ⇒ b) → (g : b ⇒ c) → (h : c ⇒ d)\n → ((h ∘ g) ∘ f) ≈ (h ∘ (g ∘ f))\n left-identity : ∀ {a b : Object}\n → (f : a ⇒ b)\n → (id b ∘ f) ≈ f\n right-identity : ∀ {a b : Object}\n → (f : a ⇒ b)\n → (f ∘ id a) ≈ f\n cong : ∀ {a b c a' b' c' : Object}\n {x : Carrier (b , c)} {y : Carrier (b' , c')}\n {u : Carrier (a , b)} {v : Carrier (a' , b')}\n → x ≈ y → u ≈ v → (x ∘ u) ≈ (y ∘ v)\n\nrecord MorphismStructure (𝒸 ℓ : Level) (Object : Set 𝒸) : Set (suc (𝒸 ⊔ ℓ)) where\n infixr 9 _∘_\n infix 4 _≈_\n field\n Carrier : (Object × Object) → Set 𝒸\n _≈_ : Rel Carrier ℓ\n isEquivalence : IsEquivalence Carrier _≈_\n\n setoid : Setoid (Object × Object) _ _\n setoid = record { isEquivalence = isEquivalence }\n\n -- Arrows\n _⇒_ : Object → Object → Set 𝒸\n _⇒_ = curry Carrier\n\n field\n _∘_ : ∀ {a b c : Object}\n → b ⇒ c\n → a ⇒ b\n → a ⇒ c\n id : (a : Object) → a ⇒ a\n isMorphism : IsMorphism _≈_ _∘_ id\n\n\nrecord Category (𝒸 ℓ : Level) : Set (suc (𝒸 ⊔ ℓ)) where\n\n field\n Objects : B.Setoid 𝒸 ℓ\n\n Object : Set 𝒸\n Object = B.Setoid.Carrier Objects\n\n _≈o_ : Object → Object → Set ℓ\n _≈o_ = B.Setoid._≈_ Objects\n\n field\n Morphisms : MorphismStructure 𝒸 ℓ Object\n\n open MorphismStructure Morphisms public\n\n hom[-,_] : Object → Set 𝒸\n hom[-, b ] = Σ[ a ∈ Object ] a ⇒ b\n\n -- hom[_,_] : Object → Object → Set 𝒸\n -- hom[ a , b ] = a ⇒ b\n\nrecord IsFunctor {𝒸₀ ℓ₀ 𝒸₁ ℓ₁ : Level}\n {C : Category 𝒸₀ ℓ₀} {D : Category 𝒸₁ ℓ₁}\n (mapObject : Category.Object C → Category.Object D)\n (mapMorphism : ∀ {a b}\n → (Category._⇒_ C) a b\n → (Category._⇒_ D) (mapObject a) (mapObject b))\n : Set (𝒸₀ ⊔ ℓ₀ ⊔ 𝒸₁ ⊔ ℓ₁) where\n\n module C = Category C\n open Category D\n\n field\n preserve-id : (a : C.Object)\n → mapMorphism (C.id a) ≈ id (mapObject a)\n preserve-∘ : {a b c : C.Object} (f : a C.⇒ b) (g : b C.⇒ c)\n → mapMorphism (C._∘_ g f) ≈ mapMorphism g ∘ mapMorphism f\n\n\nrecord Functor {𝒸₀ ℓ₀ 𝒸₁ ℓ₁ : Level}\n (C : Category 𝒸₀ ℓ₀) (D : Category 𝒸₁ ℓ₁) : Set (𝒸₀ ⊔ ℓ₀ ⊔ 𝒸₁ ⊔ ℓ₁) where\n module C = Category C\n module D = Category D\n field\n mapObject : C.Object → D.Object\n mapMorphism : ∀ {a b} → a C.⇒ b → mapObject a D.⇒ mapObject b\n isFunctor : IsFunctor {𝒸₀} {ℓ₀} {𝒸₁} {ℓ₁} {C} {D} mapObject mapMorphism\n", "meta": {"hexsha": "1509c4baa38e5341910d3ba95e6708dafa18d056", "size": 3248, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Category/Core.agda", "max_stars_repo_name": "banacorn/categories", "max_stars_repo_head_hexsha": "9f6d933b227aecab338ecaef1d86566a54fdac68", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-01-04T23:19:30.000Z", "max_stars_repo_stars_event_max_datetime": "2018-01-04T23:19:30.000Z", "max_issues_repo_path": "src/Category/Core.agda", "max_issues_repo_name": "banacorn/categories", "max_issues_repo_head_hexsha": "9f6d933b227aecab338ecaef1d86566a54fdac68", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Category/Core.agda", "max_forks_repo_name": "banacorn/categories", "max_forks_repo_head_hexsha": "9f6d933b227aecab338ecaef1d86566a54fdac68", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.9333333333, "max_line_length": 91, "alphanum_fraction": 0.4963054187, "num_tokens": 1203, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392725805822, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.6239416826072974}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Data.List.Any.Membership instantiated with propositional equality,\n-- along with some additional definitions.\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.List.Membership.Propositional {a} {A : Set a} where\n\nopen import Data.List.Relation.Unary.Any using (Any)\nopen import Relation.Binary.PropositionalEquality using (setoid; subst)\n\nimport Data.List.Membership.Setoid as SetoidMembership\n\n------------------------------------------------------------------------\n-- Re-export contents of setoid membership\n\nopen SetoidMembership (setoid A) public hiding (lose)\n\n------------------------------------------------------------------------\n-- Other operations\n\nlose : ∀ {p} {P : A → Set p} {x xs} → x ∈ xs → P x → Any P xs\nlose = SetoidMembership.lose (setoid A) (subst _)\n", "meta": {"hexsha": "2c485fa2a844d5c7afe2f38dd3364872e36458bd", "size": 953, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Membership/Propositional.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Membership/Propositional.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Membership/Propositional.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.2962962963, "max_line_length": 72, "alphanum_fraction": 0.5099685205, "num_tokens": 175, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8757869884059266, "lm_q2_score": 0.7122321781307375, "lm_q1q2_score": 0.6237636743309121}} {"text": "open import Data.Product using ( _×_ ; _,_ )\nopen import FRP.LTL.ISet.Core using ( ISet ; MSet ; [_] ; _⇛_ ; _,_ )\nopen import FRP.LTL.Time using ( _+_ ; +-resp-≤ ; +-resp-< )\nopen import FRP.LTL.Time.Bound using\n ( Time∞ ; +∞ ; fin ; _≼_ ; _≺_ ; +∞-top ; ≤-impl-≼ ; t≺+∞ ; ≺-impl-⋡ ; ≺-impl-< ; <-impl-≺ )\nopen import FRP.LTL.Time.Interval using ( Interval ; [_⟩ ; _⊑_ ; _~_ ; _⌢_∵_ ; _,_ )\nopen import FRP.LTL.Util using ( ⊥-elim )\nopen import Relation.Binary.PropositionalEquality using ( refl )\n\nmodule FRP.LTL.ISet.Next where\n\n-- ○ A is \"A holds at the next point in time\"\n\nnext : Time∞ → Time∞\nnext +∞ = +∞\nnext (fin t) = fin (t + 1)\n\nnext-resp-≼ : ∀ {t u} → (t ≼ u) → (next t ≼ next u)\nnext-resp-≼ +∞-top = +∞-top\nnext-resp-≼ (≤-impl-≼ t≤u) = ≤-impl-≼ (+-resp-≤ t≤u 1)\n\nnext-resp-≺ : ∀ {t u} → (t ≺ u) → (next t ≺ next u)\nnext-resp-≺ {+∞} t≺u = ⊥-elim (≺-impl-⋡ t≺u +∞-top)\nnext-resp-≺ {fin t} {+∞} t≺u = t≺+∞\nnext-resp-≺ {fin t} {fin u} t≺u = <-impl-≺ (+-resp-< (≺-impl-< t≺u) 1)\n\nNext : MSet → MSet\nNext (A , split , subsum) = (○A , ○split , ○subsum) where\n\n ○A : Interval → Set\n ○A [ s≺t ⟩ = A [ next-resp-≺ s≺t ⟩\n\n ○split : ∀ i j i~j → ○A (i ⌢ j ∵ i~j) → (○A i × ○A j)\n ○split [ s≺t ⟩ [ t≺u ⟩ refl = \n split [ next-resp-≺ s≺t ⟩ [ next-resp-≺ t≺u ⟩ refl\n\n ○subsum : ∀ i j → (i ⊑ j) → ○A j → ○A i\n ○subsum [ s≺t ⟩ [ r≺u ⟩ (r≼s , t≼u) = \n subsum [ next-resp-≺ s≺t ⟩ [ next-resp-≺ r≺u ⟩ (next-resp-≼ r≼s , next-resp-≼ t≼u)\n\n○ : ISet → ISet\n○ ([ A ]) = [ Next A ]\n○ (A ⇛ B) = Next A ⇛ ○ B\n", "meta": {"hexsha": "eeabcebf589e6e22d457fbd884cd864e07c3073c", "size": 1537, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/FRP/LTL/ISet/Next.agda", "max_stars_repo_name": "agda/agda-frp-ltl", "max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 21, "max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z", "max_issues_repo_path": "src/FRP/LTL/ISet/Next.agda", "max_issues_repo_name": "agda/agda-frp-ltl", "max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z", "max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z", "max_forks_repo_path": "src/FRP/LTL/ISet/Next.agda", "max_forks_repo_name": "agda/agda-frp-ltl", "max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z", "avg_line_length": 34.9318181818, "max_line_length": 95, "alphanum_fraction": 0.4983734548, "num_tokens": 796, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513703624558, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.6237536025263913}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nmodule Cubical.Categories.Type where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Categories.Category\n\nopen Precategory\n\nmodule _ ℓ where\n TYPE : Precategory (ℓ-suc ℓ) ℓ\n TYPE .ob = Type ℓ\n TYPE .Hom[_,_] A B = A → B\n TYPE .id A = λ x → x\n TYPE ._⋆_ f g = λ x → g (f x)\n TYPE .⋆IdL f = refl\n TYPE .⋆IdR f = refl\n TYPE .⋆Assoc f g h = refl\n", "meta": {"hexsha": "e73bdbe19a2d728cf10865a78505288428a4e499", "size": 416, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Type.agda", "max_stars_repo_name": "apabepa10/cubical", "max_stars_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Categories/Type.agda", "max_issues_repo_name": "apabepa10/cubical", "max_issues_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Categories/Type.agda", "max_forks_repo_name": "apabepa10/cubical", "max_forks_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.8947368421, "max_line_length": 50, "alphanum_fraction": 0.6466346154, "num_tokens": 154, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8962513675912913, "lm_q2_score": 0.6959583124210896, "lm_q1q2_score": 0.6237535892939288}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Convenient syntax for \"equational reasoning\" using a preorder\n------------------------------------------------------------------------\n\n-- I think that the idea behind this library is originally Ulf\n-- Norell's. I have adapted it to my tastes and mixfix operators,\n-- though.\n\n-- If you need to use several instances of this module in a given\n-- file, then you can use the following approach:\n--\n-- import Relation.Binary.PreorderReasoning as Pre\n--\n-- f x y z = begin\n-- ...\n-- ∎\n-- where open Pre preorder₁\n--\n-- g i j = begin\n-- ...\n-- ∎\n-- where open Pre preorder₂\n\nopen import Relation.Binary\n\nmodule Relation.Binary.PreorderReasoning\n {p₁ p₂ p₃} (P : Preorder p₁ p₂ p₃) where\n\nopen Preorder P\n\ninfix 4 _IsRelatedTo_\ninfix 2 _∎\ninfixr 2 _∼⟨_⟩_ _≈⟨_⟩_ _≈⟨⟩_\ninfix 1 begin_\n\n-- This seemingly unnecessary type is used to make it possible to\n-- infer arguments even if the underlying equality evaluates.\n\ndata _IsRelatedTo_ (x y : Carrier) : Set p₃ where\n relTo : (x∼y : x ∼ y) → x IsRelatedTo y\n\nbegin_ : ∀ {x y} → x IsRelatedTo y → x ∼ y\nbegin relTo x∼y = x∼y\n\n_∼⟨_⟩_ : ∀ x {y z} → x ∼ y → y IsRelatedTo z → x IsRelatedTo z\n_ ∼⟨ x∼y ⟩ relTo y∼z = relTo (trans x∼y y∼z)\n\n_≈⟨_⟩_ : ∀ x {y z} → x ≈ y → y IsRelatedTo z → x IsRelatedTo z\n_ ≈⟨ x≈y ⟩ relTo y∼z = relTo (trans (reflexive x≈y) y∼z)\n\n_≈⟨⟩_ : ∀ x {y} → x IsRelatedTo y → x IsRelatedTo y\n_ ≈⟨⟩ x∼y = x∼y\n\n_∎ : ∀ x → x IsRelatedTo x\n_∎ _ = relTo refl\n", "meta": {"hexsha": "2bd974aa8a2edbad2580f77405a21cd8a91c843b", "size": 1563, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Relation/Binary/PreorderReasoning.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Relation/Binary/PreorderReasoning.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Relation/Binary/PreorderReasoning.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.9482758621, "max_line_length": 72, "alphanum_fraction": 0.5770953295, "num_tokens": 541, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933183101078, "lm_q2_score": 0.7606506635289835, "lm_q1q2_score": 0.6236523965955636}} {"text": "{-# OPTIONS --allow-unsolved-metas #-}\n\nopen import Agda.Primitive using (Level)\nmodule Tutorials.Monday where\n\n\n-- Two dashes to comment out the rest of the line\n{-\n Opening {-\n and closing -}\n for a multi-line comment\n-}\n\n-- In Agda all the tokens are tokenised using whitespace (with the exception of parentheses and some other symbols)\n-- Agda offers unicode support\n-- We can input unicode using the backslash \\ and (most of the time) typing what one would type in LaTeX\n-- If in emacs, we can put the cursor over a characted and use M-x describe-char to see how that character is inputted\n-- ⊥ is written using \\bot\ndata ⊥ : Set where\n -- AKA the empty set, bottom, falsehood, the absurd type, the empty type, the initial object\n -- ⊥ : Set means ⊥ is a Type (Set = Type, for historical reasons)\n -- The data keyword creates a data type where we list all the constructors of the types\n -- ⊥ has no constructors: there is no way of making something of type ⊥\n\nrecord ⊤ : Set where\n -- AKA the singleton set, top, truth, the trivial type, the unit type, the terminal object\n -- The record keyword creates a record type\n -- Records have a single constructor\n -- To create a record you must populate all of its fields\n -- ⊤ has no fields: it is trivial to make one, and contains no information\n constructor tt\n\ndata Bool : Set where\n -- Bool has two constructors: one bit worth of information\n true : Bool\n false : Bool\n\n--------\n-- Simple composite types\n--------\n\nmodule Simple where\n record _×_ (A : Set) (B : Set) : Set where\n -- AKA logical and, product type\n\n -- Agda offers support for mixfix notation\n -- We use the underscores to specify where the arguments goal\n -- In this case the arguments are the type parameters A and B, so we can write A × B\n\n -- A × B models a type packing up *both* an A *and* a B\n -- A and B are type parameters, both of type Set, i.e. types\n -- A × B itself is of type Set, i.e. a type\n -- We use the single record constructor _,_ to make something of type A × B\n -- The constructor _,_ takes two parameters: the fields fst and snd, of type A and B, respectively\n -- If we have a of type A and b of type B, then (a , b) is of type A × B\n constructor _,_\n field\n fst : A\n snd : B\n\n -- Agda has a very expressive module system (more on modules later)\n -- Every record has a module automatically attached to it\n -- Opening a record exposes its constructor and it fields\n -- The fields are projection functions out of the record\n -- In the case of _×_, it exposes\n -- fst : A × B → A\n -- snd : A × B → B\n open _×_\n\n data _⊎_ (A B : Set) : Set where\n -- AKA logical or, sum type, disjoint union\n -- A ⊎ B models a type packing *either* an A *or* a B\n -- A and B are type parameters, both of type Set, i.e. types\n -- A ⊎ B itself is of type Set, i.e. a type\n -- A ⊎ B has two constructors: inl and inr\n -- The constructor inl takes something of type A as an argument and returns something of type A ⊎ B\n -- The constructor inr takes something of type B as an argument and returns something of type A ⊎ B\n -- We can make something of type A ⊎ B either by using inl and supplying an A, or by using inr and supplying a B\n inl : A → A ⊎ B\n inr : B → A ⊎ B\n\n\n --------\n -- Some simple proofs!\n --------\n\n -- In constructive mathematics logical implication is modelled as function types\n -- An object of type A → B shows that assuming an object of type A, we can construct an object of type B\n -- Below we want to show that assuming an object of type A × B, we can construct an object of type A\n -- We want to show that this is the case regardless of what A and B actually are\n -- We do this using a polymorphic function that is parametrised over A and B, both of type Set\n -- We use curly braces {} to make these function parameters implicit\n -- When we call this function we won't have to supply the arguments A and B unless we want to\n -- When we define this function we won't have to accept A and B as arguments unless we want to\n -- The first line below gives the type of the function get-fst\n -- The second line gives its definition\n get-fst : {A : Set} {B : Set} → A × B → A\n get-fst x = {!!}\n\n -- Agda is an *interactive* proof assistant\n -- We don't provide our proofs/programs all at once: we develop them iteratively\n -- We write ? where we don't yet have a program to provide, and we reload the file\n -- What we get back is a hole where we can place the cursor and have a conversation with Agda\n -- ctrl+c is the prefix that we use to communicate with Agda\n -- ctrl+c ctrl+l reload the file\n -- ctrl+c ctrl+, shows the goal and the context\n -- ctrl+c ctrl+. shows the goal, the context, and what we have so far\n -- ctrl+c ctrl+c pattern matches against a given arguments\n -- ctrl+c ctrl+space fill in hole\n -- ctrl+c ctrl+r refines the goal: it will ask Agda to insert the first constructor we need\n -- ctrl+c ctrl+a try to automatically fulfill the goal\n -- key bindings: https://agda.readthedocs.io/en/v2.6.1.3/getting-started/quick-guide.html\n get-snd : ∀ {A B} → A × B → B\n get-snd x = {!!}\n\n -- The variable keyword enables us to declare convention for notation\n -- Unless said otherwise, whenever we refer to A, B or C and these are not bound, we will refer to objects of type Set\n variable\n ℓ : Level\n A B C : Set ℓ\n\n -- Notice how we don't have to declare A, B and C anymore\n curry : (A → B → C) → (A × B → C)\n curry f = {!!}\n\n uncurry : (A × B → C) → (A → B → C)\n uncurry f = {!!}\n\n ×-comm : A × B → B × A\n ×-comm = {!!}\n\n ×-assoc : (A × B) × C → A × (B × C)\n ×-assoc = {!!}\n\n -- Pattern matching has to be exhaustive: all cases must be addressed\n ⊎-comm : A ⊎ B → B ⊎ A\n ⊎-comm = {!!}\n\n ⊎-assoc : (A ⊎ B) ⊎ C → A ⊎ (B ⊎ C)\n ⊎-assoc = {!!}\n\n -- If there are no cases to be addressed there is nothing for us left to do\n -- If you believe ⊥ exist you believe anything\n absurd : ⊥ → A\n absurd a = {!!}\n\n -- In constructive mathematics all proofs are constructions\n -- How do we show that an object of type A cannot possibly be constructed, while using a construction to show so?\n -- We take the cannonically impossible-to-construct object ⊥, and show that if we were to assume the existence of A, we could use it to construct ⊥\n ¬_ : Set ℓ → Set ℓ\n ¬ A = A → ⊥\n\n -- In classical logic double negation can be eliminated: ¬ ¬ A ⇒ A\n -- That is however not the case in constructive mathematics:\n -- The proof ¬ ¬ A is a function that takes (A → ⊥) into ⊥, and offers no witness for A\n -- The opposite direction is however constructive:\n ⇒¬¬ : A → ¬ ¬ A\n ⇒¬¬ = {!!}\n\n -- Moreover, double negation can be eliminated from non-witnesses\n ¬¬¬⇒¬ : ¬ ¬ ¬ A → ¬ A\n ¬¬¬⇒¬ = {!!}\n\n -- Here we have a choice of two programs to write\n ×-⇒-⊎₁ : A × B → A ⊎ B\n ×-⇒-⊎₁ = {!!}\n\n ×-⇒-⊎₂ : A × B → A ⊎ B\n ×-⇒-⊎₂ = {!!}\n\n -- A little more involved\n -- Show that the implication (A ⊎ B → A × B) is not always true for all A and Bs\n ⊎-⇏-× : ¬ (∀ {A B} → A ⊎ B → A × B)\n ⊎-⇏-× f = {!!}\n\nvariable\n ℓ : Level\n A B C : Set ℓ\n\n--------\n-- Inductive data types\n--------\n\ndata ℕ : Set where\n -- The type of unary natural numbers\n -- The zero constructor takes no arguments; the base case\n -- The suc constructor takes one argument: an existing natural number; the inductive case\n -- We represent natural numbers by using ticks: ||| ≈ 3\n -- zero: no ticks\n -- suc: one more tick\n -- suc (suc (suc zero)) ≈ ||| ≈ 3\n zero : ℕ\n suc : ℕ → ℕ\n\nthree : ℕ\nthree = suc (suc (suc zero))\n\n-- Compiler pragmas allow us to give instructions to Agda\n-- They are introduced with an opening {-# and a closing #-}\n-- Here we the pragma BUILTIN to tell Agda to use ℕ as the builtin type for natural numbers\n-- This allows us to say 3 instead of suc (suc (suc zero))\n{-# BUILTIN NATURAL ℕ #-}\nthree' : ℕ\nthree' = 3\n\n-- Whenever we say n or m and they haven't been bound, they refer to natural numbers\nvariable\n n m l : ℕ\n\n-- Brief interlude: we declare the fixity of certain functions\n-- By default, all definitions have precedence 20\n-- The higher the precedence, the tighter they bind\n-- Here we also declare that _+_ is left associative, i.e. 1 + 2 + 3 is parsed as (1 + 2) + 3\ninfixl 20 _+_\n\n-- Define addition of natural numbers by structural recursion\n_+_ : ℕ → ℕ → ℕ\nx + y = {!!}\n\n-- In functions recursion must always occur on structurally smaller values (otherwise the computation might never terminate)\n-- In Agda *all computations must terminate*\n-- We can tell Agda to ignore non-termination with this pragma\n{-# TERMINATING #-}\nnon-terminating : ℕ → ℕ\nnon-terminating n = non-terminating n\n\n-- However, doing so would allow us to define elements of the type ⊥\n-- This is not considered safe: running Agda with the --safe option will make type-checking fail\n{-# TERMINATING #-}\nloop : ⊥\nloop = loop\n\n-- Use structural recursion to define multiplication\n_*_ : ℕ → ℕ → ℕ\nx * y = {!!}\n\n-- The module keyword allows us to define modules (namespaces)\nmodule List where\n infixr 15 _∷_ _++_\n data List (A : Set) : Set where\n -- Lists are another example of inductive types\n -- The type parameter A is the type of every element in the list\n -- They are like natural numbers, but the successor case contains an A\n [] : List A\n _∷_ : A → List A → List A\n\n -- List concatenation by structural recursion\n _++_ : List A → List A → List A\n [] ++ ys = ys\n (x ∷ xs) ++ ys = x ∷ (xs ++ ys)\n\n -- Apply a function (A → B) to every element of a list\n map : (A → B) → List A → List B\n map = {!!}\n\n -- A base case B and an inductive case A → B → B is all we need to take a List A and make a B\n foldr : (A → B → B) → B → List A → B\n foldr f b [] = b\n foldr f b (x ∷ xs) = f x (foldr f b xs)\n\n--------\n-- Dependent Types\n--------\n\n-- Dependent types are types that depend on values, objects of another type\n-- Dependent types allow us to model predicates on types\n-- A predicate P on a type A is a function taking elements of A into types\nPred : Set → Set₁\nPred A = A → Set\n\n-- Let us define a predicate on ℕ that models the even numbers\n-- Even numbers are taken to the type ⊤, which is trivial to satisfy\n-- Odd numbers are taken to the type ⊥, which is impossible to satisfy\nEven : Pred ℕ\nEven x = {!!}\n\n-- We can now use Even as a precondition on a previous arguments\n-- Here we bind the first argument of type ℕ to the name n\n-- We then use n as an argument to the type Even\n-- As we expose the constructors of n, Even will compute\nhalf : (n : ℕ) → Even n → ℕ\nhalf n n-even = {!!}\n\n-- There is an alternative way of definiting dependent types\n-- EvenData is a data type indexed by elements of the type ℕ\n-- That is, for every (n : ℕ), EvenData n is a type\n-- The constructor zero constructs an element of the type EvenData zero\n-- The constructor 2+_ takes an element of the type EvenData n and constructs one of type EvenData (suc (suc n))\n-- Note that there is no constructors that constructs elements of the type Evendata (suc zero)\ndata EvenData : ℕ → Set where -- Pred ℕ\n zero : EvenData zero\n 2+_ : EvenData n → EvenData (suc (suc n))\n\n-- We can use EvenData as a precondition too\n-- The difference is that while Even n computes automatically, we have to take EvenData n appart by pattern matching\n-- It leaves a trace of *why* n is even\nhalf-data : (n : ℕ) → EvenData n → ℕ\nhalf-data n n-even = {!!}\n\n-- Function composition: (f ∘ g) composes two functions f and g\n-- The result takes the input, feeds it through g, then feeds the result through f\ninfixr 20 _∘_\n_∘_ : (B → C) → (A → B) → (A → C)\n(f ∘ g) x = f (g x)\n\n--------\n-- Example of common uses of dependent types\n--------\n\nmodule Fin where\n -- The type Fin n has n distinct inhabitants\n data Fin : ℕ → Set where\n zero : Fin (suc n)\n suc : Fin n → Fin (suc n)\n\n -- Note that there is no constructor for Fin zero\n Fin0 : Fin zero → ⊥\n Fin0 x = {!!}\n\n -- We can erase the type level information to get a ℕ back\n to-ℕ : Fin n → ℕ\n to-ℕ zero = zero\n to-ℕ (suc x) = suc (to-ℕ x)\n\nmodule Vec where\n open Fin\n\n -- Vectors are like lists, but they keep track of their length\n -- The type Vec A n is the type of lists of length n containing values of type A\n -- Notice that while A is a parameter (remains unchanged in all constructors), n is an index\n -- We can bind parameters to names (since they don't change) but we cannot bind indices\n data Vec (A : Set) : ℕ → Set where\n [] : Vec A zero\n _∷_ : A → Vec A n → Vec A (suc n)\n\n -- Now we can define concatenation, but giving more assurances about the resulting length\n _++_ : Vec A n → Vec A m → Vec A (n + m)\n xs ++ ys = {!!}\n\n map : (A → B) → Vec A n → Vec B n\n map = {!!}\n\n -- Given a vector and a fin, we can use the latter as a lookup index into the former\n -- Question: what happens if there vector is empty?\n _!_ : Vec A n → Fin n → A\n xs ! i = {!!}\n\n -- A vector Vec A n is just the inductive form of a function Fin n → A\n tabulate : ∀ {n} → (Fin n → A) → Vec A n\n tabulate {n = zero} f = []\n tabulate {n = suc n} f = f zero ∷ tabulate (f ∘ suc)\n\n untabulate : Vec A n → (Fin n → A)\n untabulate [] ()\n untabulate (x ∷ xs) zero = x\n untabulate (x ∷ xs) (suc i) = untabulate xs i\n\n-- Predicates need not be unary, they can be binary! (i.e. relations)\nRel : Set → Set₁\nRel A = A → A → Set\n\n-- Question: how many proofs are there for any n ≤ m\ndata _≤_ : Rel ℕ where\n z≤n : zero ≤ n\n s≤s : n ≤ m → suc n ≤ suc m\n\n_<_ : ℕ → ℕ → Set\nn < m = suc n ≤ m\n\n-- _≤_ is reflexive and transitive\n≤-refl : ∀ n → n ≤ n\n≤-refl n = {!!}\n\n≤-trans : n ≤ m → m ≤ l → n ≤ l\n≤-trans a b = {!!}\n\n-----------\n-- Propositional Equality\n-----------\n\n-- Things get interesting: we can use type indices to define propositional equality\n-- For any (x y : A) the type x ≡ y is a proof showing that x and y are in fact definitionally equal\n-- It has a single constructor refl which limits the ways of making something of type x ≡ y to those where x and y are in fact the same, i.e. x ≡ x\n-- When we pattern match against something of type x ≡ y, the constructor refl will make x and y unify: Agda will internalise the equality\ninfix 10 _≡_\n-- \\== ≡\ndata _≡_ (x : A) : A → Set where\n refl : x ≡ x\n\n{-# BUILTIN EQUALITY _≡_ #-}\n\n-- Definitional equality holds when the two sides compute to the same symbols\n2+2≡4 : 2 + 2 ≡ 4\n2+2≡4 = {!!}\n\n-- Because of the way in which defined _+_, zero + x ≡ x holds definitionally (the first case in the definition)\n+-idˡ : ∀ x → (zero + x) ≡ x\n+-idˡ x = {!!}\n\n-- We show that equality respects congruence\ncong : {x y : A} (f : A → B) → x ≡ y → f x ≡ f y\ncong f p = {!!}\n\n-- However this does not hold definitionally\n-- We need to use proof by induction\n-- We miss some pieces to prove this\n+-idʳ : ∀ x → (x + zero) ≡ x\n+-idʳ x = {!!}\n\n-- Propositional equality is reflexive by construction, here we show it is also symmetric and transitive\nsym : {x y : A} → x ≡ y → y ≡ x\nsym p = {!!}\n\ntrans : {x y z : A} → x ≡ y → y ≡ z → x ≡ z\ntrans p q = {!!}\n\n-- A binary version that will come in use later on\ncong₂ : {x y : A} {w z : B} (f : A → B → C) → x ≡ y → w ≡ z → f x w ≡ f y z\ncong₂ f refl refl = refl\n\n-- Leibniz equality, transport\nsubst : {x y : A} {P : Pred A} → x ≡ y → P x → P y\nsubst eq p = {!!}\n\n-- Now we can start proving slightly more interesting things!\n+-assoc : ∀ x y z → (x + y) + z ≡ x + (y + z)\n+-assoc x y z = {!!}\n\n-- Introduce underscores on the RHS\n+-comm : ∀ x y → x + y ≡ y + x\n+-comm x zero = {!!}\n+-comm x (suc y) = {!!}\n -- The keyword where allows us to introduce local definitions\n where\n +-suc : ∀ x y → x + suc y ≡ suc (x + y)\n +-suc x y = {!!}\n\n\n-----------\n-- Some tooling for equational reasoning\n-----------\n\ninfix 3 _∎\ninfixr 2 step-≡\ninfix 1 begin_\n\nbegin_ : ∀{x y : A} → x ≡ y → x ≡ y\nbegin_ x≡y = x≡y\n\nstep-≡ : ∀ (x {y z} : A) → y ≡ z → x ≡ y → x ≡ z\nstep-≡ _ y≡z x≡y = trans x≡y y≡z\n\nsyntax step-≡ x y≡z x≡y = x ≡⟨ x≡y ⟩ y≡z\n\n_∎ : ∀ (x : A) → x ≡ x\n_∎ _ = refl\n\n-- The equational resoning style allows us to explicitly write down the goals at each stage\n-- This starts to look like what one would do on the whiteboard\n+-comm′ : ∀ x y → x + y ≡ y + x\n+-comm′ x zero = {!!}\n+-comm′ x (suc y) = begin\n (x + suc y) ≡⟨ {!!} ⟩\n suc (x + y) ≡⟨ {!!} ⟩\n suc (y + x) ∎\n", "meta": {"hexsha": "e0cd7a0fe38b08839562c63e873e369d803be0f5", "size": 16325, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Tutorials/Monday.agda", "max_stars_repo_name": "poncev/agda-bcam", "max_stars_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2021-09-23T17:59:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-03T22:53:51.000Z", "max_issues_repo_path": "Tutorials/Monday.agda", "max_issues_repo_name": "poncev/agda-bcam", "max_issues_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Tutorials/Monday.agda", "max_forks_repo_name": "poncev/agda-bcam", "max_forks_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-11-23T08:50:13.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-24T10:50:55.000Z", "avg_line_length": 35.0321888412, "max_line_length": 149, "alphanum_fraction": 0.6409188361, "num_tokens": 5005, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933315126791, "lm_q2_score": 0.7606506418255927, "lm_q1q2_score": 0.6236523888436428}} {"text": "module Common where\n ∗ : Set₁\n ∗ = Set\n\n _∘_ : {A B C : ∗} → (B → C) → (A → B) → (A → C)\n f ∘ g = λ a → f (g a)\n\n infixr 2 _×_\n infixr 1 _⊎_\n\n data _×_ (A B : ∗) : ∗ where\n _,_ : A → B → A × B\n\n proj₁ : ∀ {A B} → A × B → A\n proj₁ (a , b) = a\n\n proj₂ : ∀ {A B} → A × B → B\n proj₂ (a , b) = b\n\n uncurry : {A B C : ∗} → (A → B → C) → (A × B → C)\n uncurry f (a , b) = f a b\n\n data _⊎_ (A B : ∗) : ∗ where\n inj₁ : (x : A) → A ⊎ B\n inj₂ : (y : B) → A ⊎ B\n", "meta": {"hexsha": "2b7ec3285a75c604497a89685cbf13886752478f", "size": 472, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "papers/unraveling-recursion/Common.agda", "max_stars_repo_name": "AriFordsham/plutus", "max_stars_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1299, "max_stars_repo_stars_event_min_datetime": "2018-10-02T13:41:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-28T01:10:02.000Z", "max_issues_repo_path": "papers/unraveling-recursion/Common.agda", "max_issues_repo_name": "AriFordsham/plutus", "max_issues_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 2493, "max_issues_repo_issues_event_min_datetime": "2018-09-28T19:28:17.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T15:31:31.000Z", "max_forks_repo_path": "papers/unraveling-recursion/Common.agda", "max_forks_repo_name": "AriFordsham/plutus", "max_forks_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 399, "max_forks_repo_forks_event_min_datetime": "2018-10-05T09:36:10.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T11:18:25.000Z", "avg_line_length": 18.1538461538, "max_line_length": 51, "alphanum_fraction": 0.3665254237, "num_tokens": 257, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8918110511888303, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.6236028258821484}} {"text": "\n-- Integers modulo N\nmodule Numeric.Nat.Modulo where\n\nopen import Prelude\nopen import Numeric.Nat.DivMod\nopen import Tactic.Nat\n\ndata IntMod (n : Nat) : Set where\n modn : ∀ k → k < n → IntMod n\n\n{-# DISPLAY modn k (LessNat.diff _ refl) = k #-}\n\nnegIntMod : ∀ {n} → IntMod n → IntMod n\nnegIntMod (modn 0 lt) = modn 0 lt\nnegIntMod (modn (suc k) (diff j eq)) = modn (suc j) (by (sym eq))\n\n{-# DISPLAY negIntMod a = negate a #-}\n\ninstance\n NumberIntMod : ∀ {n} → Number (IntMod (suc n))\n Number.Constraint NumberIntMod _ = ⊤\n fromNat {{NumberIntMod {n}}} k with k divmod suc n\n ... | qr _ r lt _ = modn r lt\n\n NegativeIntMod : ∀ {n} → Negative (IntMod (suc n))\n Negative.Constraint NegativeIntMod _ = ⊤\n fromNeg {{NegativeIntMod}} k = negIntMod (fromNat k)\n\naddIntMod : ∀ {n} → IntMod (suc n) → IntMod (suc n) → IntMod (suc n)\naddIntMod {n} (modn a _) (modn b _) = force (a + b) λ a+b → fromNat a+b ofType IntMod (suc n)\n\nmulIntMod : ∀ {n} → IntMod (suc n) → IntMod (suc n) → IntMod (suc n)\nmulIntMod {n} (modn a _) (modn b _) = force (a * b) λ a*b → fromNat a*b ofType IntMod (suc n)\n\nsubIntMod : ∀ {n} → IntMod (suc n) → IntMod (suc n) → IntMod (suc n)\nsubIntMod a b = addIntMod a (negIntMod b)\n\n{-# DISPLAY addIntMod a b = a + b #-}\n{-# DISPLAY mulIntMod a b = a * b #-}\n{-# DISPLAY subIntMod a b = a - b #-}\n\ninstance\n SemiringIntMod : ∀ {n} → Semiring (IntMod (suc n))\n zro {{SemiringIntMod}} = 0\n one {{SemiringIntMod}} = 1\n _+_ {{SemiringIntMod}} = addIntMod\n _*_ {{SemiringIntMod}} = mulIntMod\n\n SubtractiveIntMod : ∀ {n} → Subtractive (IntMod (suc n))\n _-_ {{SubtractiveIntMod}} = subIntMod\n negate {{SubtractiveIntMod}} = negIntMod\n", "meta": {"hexsha": "e6c73af8673d20bbb0caa0dae02e485b6728cef7", "size": 1658, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Numeric/Nat/Modulo.agda", "max_stars_repo_name": "t-more/agda-prelude", "max_stars_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 111, "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_issues_repo_path": "src/Numeric/Nat/Modulo.agda", "max_issues_repo_name": "t-more/agda-prelude", "max_issues_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_forks_repo_path": "src/Numeric/Nat/Modulo.agda", "max_forks_repo_name": "t-more/agda-prelude", "max_forks_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "avg_line_length": 31.2830188679, "max_line_length": 93, "alphanum_fraction": 0.6338962606, "num_tokens": 613, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110425624792, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.6236028142608342}} {"text": "\n{- Lemmas and operations involving rewriting and heterogeneous equality. -}\nmodule TemporalOps.Common.Rewriting where\n\nopen import Relation.Binary.HeterogeneousEquality as ≅\nopen import Relation.Binary.PropositionalEquality as ≡\n\n\n-- | Rewriting and heterogeneous equality\n\n-- Substitution with identity predicate – explicit rewriting\nrew : ∀{ℓ}{x y : Set ℓ} -> x ≡ y -> x -> y\nrew refl x = x\n\n-- Rewriting preserves heterogeneous equality\nrew-to-≅ : ∀{ℓ}{A B : Set ℓ}{v : A} -> (p : A ≡ B) -> v ≅ rew p v\nrew-to-≅ {A = A} {.A} {v} refl = ≅.refl\n\n-- Heterogenous equality with differently typed arguments\n-- can be converted to homogeneous equality via rewriting of the types\n≅-to-rew-≡ : ∀ {P Q : Set} {x : P} {y : Q}\n -> (p : x ≅ y) -> (e : P ≡ Q)\n -> rew e x ≡ y\n≅-to-rew-≡ ≅.refl refl = refl\n\n-- Rewriting by p is cancelled out by rewriting by (sym p)\nrew-cancel : ∀ {P Q : Set}\n -> (v : P) -> (p : P ≡ Q)\n -> rew (≡.sym p) (rew p v) ≡ v\nrew-cancel v refl = refl\n\n-- | Equality of equality proofs and functions\n-- Two propositional equality proofs are propositionally (heterogeneously) equal\n-- if given two heterogeneously equal values, rewriting each with\n-- the respective proofs gives propositionally (heterogeneously) equal terms.\n\n-- Propositional equality of equality proofs\nProof-≅ : ∀{p1 p2 q1 q2 : Set} -> p1 ≡ q1 -> p2 ≡ q2 -> Set\nProof-≅ {p1}{p2} pf1 pf2 =\n (v : p1) (v′ : p2) -> v ≅ v′ -> rew pf1 v ≅ rew pf2 v′\n\n-- Propositional equality of equality proofs\nProof-≡ : ∀{p1 p2 q : Set} -> p1 ≡ q -> p2 ≡ q -> Set\nProof-≡ {p1}{p2} pf1 pf2 =\n (v : p1) (v′ : p2) -> v ≅ v′ -> rew pf1 v ≡ rew pf2 v′\n\n-- Propositional equality of functions\nFun-≅ : ∀{a1 a2 b1 b2 : Set} -> (a1 -> b1) -> (a2 -> b2) -> Set\nFun-≅ {a1}{a2} f1 f2 =\n (v : a1) (v′ : a2) -> v ≅ v′ -> f1 v ≅ f2 v′\n\n\n-- | Other lemmas\n\n-- Heterogeneous congruence of three arguments\n≅-cong₃ : ∀ {a b c d} {A : Set a} {B : A → Set b} {C : ∀ (x : A) → B x → Set c}\n {D : ∀ (x : A) -> (y : B x) -> C x y -> Set d} {x y z w u v}\n -> (f : (x : A) (y : B x) (z : C x y) → D x y z)\n -> x ≅ y -> z ≅ w -> u ≅ v -> f x z u ≅ f y w v\n≅-cong₃ f ≅.refl ≅.refl ≅.refl = ≅.refl\n", "meta": {"hexsha": "bdcfca9b006b6d7a4c7d0ed042edf5be34412263", "size": 2223, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/TemporalOps/Common/Rewriting.agda", "max_stars_repo_name": "DimaSamoz/temporal-type-systems", "max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z", "max_issues_repo_path": "src/TemporalOps/Common/Rewriting.agda", "max_issues_repo_name": "DimaSamoz/temporal-type-systems", "max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/TemporalOps/Common/Rewriting.agda", "max_forks_repo_name": "DimaSamoz/temporal-type-systems", "max_forks_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.4426229508, "max_line_length": 80, "alphanum_fraction": 0.5699505173, "num_tokens": 837, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424373085146, "lm_q2_score": 0.7371581626286834, "lm_q1q2_score": 0.6235933727759748}} {"text": "module Cats.Category.Constructions.Mono where\n\nopen import Level\n\nopen import Cats.Category.Base\n\nmodule Build {lo la l≈} (Cat : Category lo la l≈) where\n\n private open module Cat = Category Cat\n open Cat.≈-Reasoning\n\n\n IsMono : ∀ {A B} → A ⇒ B → Set (lo ⊔ la ⊔ l≈)\n IsMono {A} f = ∀ {C} {g h : C ⇒ A} → f ∘ g ≈ f ∘ h → g ≈ h\n", "meta": {"hexsha": "21ac19de552de4a3588a86e161ea144b5a45ee72", "size": 330, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Category/Constructions/Mono.agda", "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cats/Category/Constructions/Mono.agda", "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cats/Category/Constructions/Mono.agda", "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.0, "max_line_length": 60, "alphanum_fraction": 0.6121212121, "num_tokens": 122, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9046505376715775, "lm_q2_score": 0.6893056231680121, "lm_q1q2_score": 0.623580702618984}} {"text": "\nmodule Oscar.Property.Symmetry where\n\nopen import Oscar.Level\n\nrecord Symmetry {𝔬} {⋆ : Set 𝔬} {𝔮} (_≒_ : ⋆ → ⋆ → Set 𝔮) : Set (𝔬 ⊔ 𝔮) where\n field\n symmetry : ∀ {x y} → x ≒ y → y ≒ x\n\nopen Symmetry ⦃ … ⦄ public\n", "meta": {"hexsha": "4c2663e0732aba96d9bb19bf2f54e7a52a118747", "size": 217, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-2/Oscar/Property/Symmetry.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-2/Oscar/Property/Symmetry.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-2/Oscar/Property/Symmetry.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.7272727273, "max_line_length": 77, "alphanum_fraction": 0.5760368664, "num_tokens": 103, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9046505402422644, "lm_q2_score": 0.6893056040203135, "lm_q1q2_score": 0.623580687068997}} {"text": "\nmodule List where\n\n data List (a : Set) : Set where\n nil : List a\n _::_ : a -> List a -> List a\n\n nil2 : (\\x -> x) ({a : Set} -> List a)\n nil2 = nil {_}\n\n tt : Set1 -> Set2\n tt _ = Set1\n\n map : {a b : Set} -> (a -> b) -> List a -> List b\n map f nil = nil\n map f (x :: xs) = f x :: map f xs\n", "meta": {"hexsha": "516ebe51c7c83dc0eacf0cfafb8b1bdb62230b58", "size": 312, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tests/covered/List.agda", "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_issues_repo_path": "tests/covered/List.agda", "max_issues_repo_name": "andrejtokarcik/agda-semantics", "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/covered/List.agda", "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.3529411765, "max_line_length": 51, "alphanum_fraction": 0.4519230769, "num_tokens": 123, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9046505248181418, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.6235806822110548}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Category.Instance.StrictGroupoids where\n\n-- The 'strict' category of groupoids.\n-- The difference here is that _≈_ is not |NaturalIsomorphism| but |_≡F_|\n\nopen import Level\nopen import Relation.Binary.PropositionalEquality using (refl)\n\nopen import Categories.Category using (Category)\nopen import Categories.Category.Groupoid using (Groupoid)\nopen import Categories.Category.Instance.Groupoids using (F-resp-⁻¹)\nopen import Categories.Functor using (Functor; id; _∘F_)\nopen import Categories.Functor.Equivalence\n\nprivate\n variable\n o ℓ e : Level\n\nopen Groupoid using (category)\n\nGroupoids : ∀ o ℓ e → Category (suc (o ⊔ ℓ ⊔ e)) (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e)\nGroupoids o ℓ e = record\n { Obj = Groupoid o ℓ e\n ; _⇒_ = λ G H → Functor (category G) (category H)\n ; _≈_ = _≡F_\n ; id = id\n ; _∘_ = _∘F_\n ; assoc = λ {_ _ _ _ F G H} → ≡F-assoc {F = F} {G} {H}\n ; sym-assoc = λ {_ _ _ _ F G H} → ≡F-sym-assoc {F = F} {G} {H}\n ; identityˡ = ≡F-identityˡ\n ; identityʳ = ≡F-identityʳ\n ; identity² = ≡F-identity²\n ; equiv = ≡F-equiv\n ; ∘-resp-≈ = ∘F-resp-≡F\n }\n", "meta": {"hexsha": "d0ee96ab8ae2f32f73f6a4a56b76e66e06c50392", "size": 1159, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Instance/StrictGroupoids.agda", "max_stars_repo_name": "bblfish/agda-categories", "max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "src/Categories/Category/Instance/StrictGroupoids.agda", "max_issues_repo_name": "bblfish/agda-categories", "max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Instance/StrictGroupoids.agda", "max_forks_repo_name": "bblfish/agda-categories", "max_forks_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 31.3243243243, "max_line_length": 73, "alphanum_fraction": 0.6350301984, "num_tokens": 412, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467706759584, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.6233318872201052}} {"text": "module Ual.Either where\n\ninfix 10 _∨_\ndata _∨_ (A B : Set) : Set where\n orL : A → A ∨ B\n orR : B → A ∨ B\n", "meta": {"hexsha": "199476c1802e31da8805087f59e1079b7870c558", "size": 107, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Either.agda", "max_stars_repo_name": "brunoczim/ual", "max_stars_repo_head_hexsha": "ea0260e1a0612ba581e4283dfb187f531a944dfd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Either.agda", "max_issues_repo_name": "brunoczim/ual", "max_issues_repo_head_hexsha": "ea0260e1a0612ba581e4283dfb187f531a944dfd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Either.agda", "max_forks_repo_name": "brunoczim/ual", "max_forks_repo_head_hexsha": "ea0260e1a0612ba581e4283dfb187f531a944dfd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 15.2857142857, "max_line_length": 32, "alphanum_fraction": 0.5607476636, "num_tokens": 52, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467738423873, "lm_q2_score": 0.7090191214879991, "lm_q1q2_score": 0.623331873248738}} {"text": "module Issue857 where\n\ndata _≡_ {A : Set} (x : A) : A → Set where\n refl : x ≡ x\n\ndata ⊤ : Set where\n tt : ⊤\n\ndata ⊥ : Set where\n\n⊥-elim : {A : Set} → ⊥ → A\n⊥-elim = λ ()\n\nbad : (x : ⊥) → ⊥-elim x ≡ tt\nbad x = {!!} -- Goal type: x ≡ tt, with x : ⊥.\n", "meta": {"hexsha": "f0a506e5d21172c3240925535a049ca8c063bcd9", "size": 251, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue857.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/interaction/Issue857.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/interaction/Issue857.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 15.6875, "max_line_length": 47, "alphanum_fraction": 0.4661354582, "num_tokens": 118, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467706759583, "lm_q2_score": 0.7090191214879991, "lm_q1q2_score": 0.6233318710036793}} {"text": "------------------------------------------------------------------------------\n-- Agda-Prop Library.\n-- Theorems with different connectives.\n------------------------------------------------------------------------------\n\nopen import Data.Nat using ( ℕ )\n\nmodule Data.PropFormula.Theorems.Mixies ( n : ℕ ) where\n\n------------------------------------------------------------------------------\n\nopen import Data.PropFormula.Syntax n\nopen import Data.PropFormula.Theorems.Classical n\nopen import Data.PropFormula.Theorems.Biimplication n\n using ( ⇔-¬-to-¬; ⊃-⇔-¬∨ )\nopen import Data.PropFormula.Theorems.Disjunction n\n using ( ∨-dmorgan; ∨-dmorgan₁ )\nopen import Data.PropFormula.Theorems.Implication n\n using ( vanDalen244e; ⊃-equiv )\nopen import Data.PropFormula.Theorems.Weakening n\n\nopen import Function using ( _$_ ; _∘_ )\n\n------------------------------------------------------------------------------\n\n-- Theorem.\ne245b\n : ∀ {Γ Δ} {φ ψ}\n → Γ ⊢ φ → Δ , φ ⊢ ψ\n → Γ ⨆ Δ ⊢ ψ\n\n-- Proof.\ne245b {Γ}{Δ} Γ⊢φ Δ,φ⊢ψ =\n ⊃-elim\n (weaken-Δ₂ Γ $ ⊃-intro Δ,φ⊢ψ)\n (weaken-Δ₁ Δ Γ⊢φ)\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n¬⊃-to-∧¬\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ ¬ (φ ⊃ ψ)\n → Γ ⊢ φ ∧ ¬ ψ\n\n-- Proof.\n¬⊃-to-∧¬ {Γ}{φ}{ψ} Γ⊢¬⟪φ⊃ψ⟫ =\n ∧-intro\n (⊃-elim vanDalen244e (∧-proj₁ p2))\n (∧-proj₂ p2)\n where\n p1 : Γ ⊢ ¬ (¬ φ ∨ ψ)\n p1 = ⇔-¬-to-¬ ⊃-⇔-¬∨ Γ⊢¬⟪φ⊃ψ⟫\n\n p2 : Γ ⊢ ¬ (¬ φ) ∧ ¬ ψ\n p2 = ∨-dmorgan₁ p1\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n⊃¬∧¬⊃-to-¬⇔\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ (φ ⊃ ¬ ψ) ∧ (¬ ψ ⊃ φ)\n → Γ ⊢ ¬ (φ ⇔ ψ)\n\n-- Proof.\n⊃¬∧¬⊃-to-¬⇔ {Γ}{φ}{ψ} thm =\n ¬-intro\n (¬-elim\n (¬-intro\n (¬-elim\n (⊃-elim\n (weaken ψ (weaken (φ ⇔ ψ) (∧-proj₁ thm)))\n (⇔-elim₂\n (assume {Γ = Γ , φ ⇔ ψ} ψ)\n (weaken ψ (assume (φ ⇔ ψ)))))\n (assume {Γ = Γ , φ ⇔ ψ} ψ)))\n (RAA\n (¬-elim\n (¬-intro\n (¬-elim\n (⊃-elim\n (weaken φ (weaken (¬ ψ ) (weaken (φ ⇔ ψ) (∧-proj₁ thm))))\n (assume {Γ = Γ , φ ⇔ ψ , ¬ ψ} φ))\n (⇔-elim₁\n (assume {Γ = Γ , φ ⇔ ψ , ¬ ψ} φ)\n (weaken φ (weaken (¬ ψ) (assume (φ ⇔ ψ)))))))\n (⊃-elim\n (weaken (¬ ψ) (weaken (φ ⇔ ψ) (∧-proj₂ thm)))\n (assume {Γ = Γ , φ ⇔ ψ} (¬ ψ))))))\n-------------------------------------------------------------------------- ∎\n", "meta": {"hexsha": "3f0750f19f6c352e6483988b562e887487b0a4cc", "size": 2452, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/PropFormula/Theorems/Mixies.agda", "max_stars_repo_name": "jonaprieto/agda-prop", "max_stars_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 13, "max_stars_repo_stars_event_min_datetime": "2017-05-01T16:45:41.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T03:33:12.000Z", "max_issues_repo_path": "src/Data/PropFormula/Theorems/Mixies.agda", "max_issues_repo_name": "jonaprieto/agda-prop", "max_issues_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 18, "max_issues_repo_issues_event_min_datetime": "2017-03-08T14:33:10.000Z", "max_issues_repo_issues_event_max_datetime": "2017-12-18T16:34:21.000Z", "max_forks_repo_path": "src/Data/PropFormula/Theorems/Mixies.agda", "max_forks_repo_name": "jonaprieto/agda-prop", "max_forks_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-03-30T16:41:56.000Z", "max_forks_repo_forks_event_max_datetime": "2017-12-01T17:01:25.000Z", "avg_line_length": 27.2444444444, "max_line_length": 78, "alphanum_fraction": 0.3568515498, "num_tokens": 938, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872046026642944, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.6232879059566682}} {"text": "\nmodule Prelude.Decidable where\n\nopen import Prelude.Empty\n\ndata Dec {a} (P : Set a) : Set a where\n yes : P → Dec P\n no : ¬ P → Dec P\n\ninfix 0 ifYes_then_else_ ifNo_then_else_\nifYes_then_else_ : ∀ {a b} {A : Set a} {B : Set b} → Dec A → B → B → B\nifYes yes _ then x else _ = x\nifYes no _ then _ else y = y\n\nifNo_then_else_ : ∀ {a b} {A : Set a} {B : Set b} → Dec A → B → B → B\nifNo d then x else y = ifYes d then y else x\n\nFromDec : ∀ {a} {P : Set a} → Dec P → Set a\nFromDec {P = P} (yes _) = P\nFromDec {P = P} (no _) = ¬ P\n\nfromDec : ∀ {a} {P : Set a} (d : Dec P) → FromDec d\nfromDec (yes x) = x\nfromDec (no x) = x\n", "meta": {"hexsha": "43edde66b34467fc61856e6a7b1ef060e0b5bb79", "size": 622, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Prelude/Decidable.agda", "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 111, "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_issues_repo_path": "src/Prelude/Decidable.agda", "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_forks_repo_path": "src/Prelude/Decidable.agda", "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "avg_line_length": 24.88, "max_line_length": 70, "alphanum_fraction": 0.577170418, "num_tokens": 256, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872045847699186, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.6232878768084379}} {"text": "\nopen import Agda.Builtin.Nat\n\ndata D : Set where\n c : D → D\n\nrecord R : Set where\n constructor mkR\n field f : Nat\n\nf : D → R\nf (c x) = mkR zero\n\nf' : D → Nat → R\nf' (c x) n = mkR n\n\npostulate\n P : (A : Set) → A → Set\n g : (x : D) → P R (f x) → P D x\n g' : (n : Nat) (x : D) → P R (f' x n) → P D x\n\nh : (x : D) → P R (mkR zero) → P D (c x)\nh x = g _\n\nh' : (n : Nat) (x : D) → P R (mkR n) → P D (c x)\nh' n x = g' n _\n", "meta": {"hexsha": "95c5e3d970f51be2ff500335c82796ef22a57c7e", "size": 424, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue2944.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue2944.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue2944.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 15.7037037037, "max_line_length": 48, "alphanum_fraction": 0.4504716981, "num_tokens": 207, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916134888614, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.6231470365774777}} {"text": "{-\n\nThis file contains:\n - the abelianization of groups as a HIT as proposed in https://arxiv.org/abs/2007.05833\n\nThe definition of the abelianization is not as a set-quotient, since the relation of abelianization is cumbersome to work with.\n\n-}\n{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.Group.Abelianization.Base where\n\nopen import Cubical.Data.Sigma\n\nopen import Cubical.Algebra.Group.Base\nopen import Cubical.Algebra.Group.Properties\n\nprivate\n variable\n ℓ : Level\n\nmodule _ (G : Group ℓ) where\n open GroupStr {{...}}\n open GroupTheory G\n private\n instance\n _ = snd G\n\n {-\n The definition of the abelianization of a group as a higher inductive type.\n The generality of the comm relation will be needed to define the group structure on the abelianization.\n -}\n data Abelianization : Type ℓ where\n η : (g : fst G) → Abelianization\n comm : (a b c : fst G) → η (a · (b · c)) ≡ η (a · (c · b))\n isset : (x y : Abelianization) → (p q : x ≡ y) → p ≡ q\n", "meta": {"hexsha": "868d98c3c273baa2116d59ffe2d33646b5a41464", "size": 987, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Group/Abelianization/Base.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Group/Abelianization/Base.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Group/Abelianization/Base.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.4166666667, "max_line_length": 127, "alphanum_fraction": 0.6849037487, "num_tokens": 289, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8633916099737806, "lm_q2_score": 0.7217431943271999, "lm_q1q2_score": 0.6231470185377803}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Algebra.Construct.Free.Semilattice.Homomorphism where\n\nopen import Prelude\nopen import Algebra\nopen import Path.Reasoning\n\nopen import Algebra.Construct.Free.Semilattice.Definition\nopen import Algebra.Construct.Free.Semilattice.Eliminators\nopen import Algebra.Construct.Free.Semilattice.Union\n\nmodule _ {b} (semilattice : Semilattice b) where\n open Semilattice semilattice\n module _ (sIsSet : isSet 𝑆) (h : A → 𝑆) where\n μ′ : A ↘ 𝑆\n [ μ′ ]-set = sIsSet\n [ μ′ ] x ∷ xs = h x ∙ xs\n [ μ′ ][] = ε\n [ μ′ ]-dup x xs =\n h x ∙ (h x ∙ xs) ≡˘⟨ assoc (h x) (h x) xs ⟩\n (h x ∙ h x) ∙ xs ≡⟨ cong (_∙ xs) (idem (h x)) ⟩\n h x ∙ xs ∎\n [ μ′ ]-com x y xs =\n h x ∙ (h y ∙ xs) ≡˘⟨ assoc (h x) (h y) xs ⟩\n (h x ∙ h y) ∙ xs ≡⟨ cong (_∙ xs) (comm (h x) (h y)) ⟩\n (h y ∙ h x) ∙ xs ≡⟨ assoc (h y) (h x) xs ⟩\n h y ∙ (h x ∙ xs) ∎\n\n μ : 𝒦 A → 𝑆\n μ = [ μ′ ]↓\n\n ∙-hom′ : ∀ ys → xs ∈𝒦 A ⇒∥ μ xs ∙ μ ys ≡ μ (xs ∪ ys) ∥\n ∥ ∙-hom′ ys ∥-prop = sIsSet _ _\n ∥ ∙-hom′ ys ∥[] = ε∙ _\n ∥ ∙-hom′ ys ∥ x ∷ xs ⟨ Pxs ⟩ =\n μ (x ∷ xs) ∙ μ ys ≡⟨⟩\n (h x ∙ μ xs) ∙ μ ys ≡⟨ assoc (h x) (μ xs) (μ ys) ⟩\n h x ∙ (μ xs ∙ μ ys) ≡⟨ cong (h x ∙_) Pxs ⟩\n h x ∙ μ (xs ∪ ys) ≡⟨⟩\n μ ((x ∷ xs) ∪ ys) ∎\n\n ∙-hom : ∀ xs ys → μ xs ∙ μ ys ≡ μ (xs ∪ ys)\n ∙-hom xs ys = ∥ ∙-hom′ ys ∥⇓ xs\n", "meta": {"hexsha": "e91d6906322d886c7c5e279fbc457cf56b58fc0b", "size": 1363, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Algebra/Construct/Free/Semilattice/Homomorphism.agda", "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_issues_repo_path": "agda/Algebra/Construct/Free/Semilattice/Homomorphism.agda", "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Algebra/Construct/Free/Semilattice/Homomorphism.agda", "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "avg_line_length": 30.2888888889, "max_line_length": 60, "alphanum_fraction": 0.4827586207, "num_tokens": 658, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637612961505, "lm_q2_score": 0.7248702880639791, "lm_q1q2_score": 0.6231447182889044}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- An inductive definition of the heterogeneous prefix relation\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.List.Relation.Binary.Prefix.Heterogeneous where\n\nopen import Level\nopen import Data.List.Base as List using (List; []; _∷_)\nopen import Data.List.Relation.Binary.Pointwise\n using (Pointwise; []; _∷_)\nopen import Data.Product using (∃; _×_; _,_; uncurry)\nopen import Relation.Binary using (REL; _⇒_)\n\nmodule _ {a b r} {A : Set a} {B : Set b} (R : REL A B r) where\n\n data Prefix : REL (List A) (List B) (a ⊔ b ⊔ r) where\n [] : ∀ {bs} → Prefix [] bs\n _∷_ : ∀ {a b as bs} → R a b → Prefix as bs → Prefix (a ∷ as) (b ∷ bs)\n\n data PrefixView (as : List A) : List B → Set (a ⊔ b ⊔ r) where\n _++_ : ∀ {cs} → Pointwise R as cs → ∀ ds → PrefixView as (cs List.++ ds)\n\nmodule _ {a b r} {A : Set a} {B : Set b} {R : REL A B r} {a b as bs} where\n\n head : Prefix R (a ∷ as) (b ∷ bs) → R a b\n head (r ∷ rs) = r\n\n tail : Prefix R (a ∷ as) (b ∷ bs) → Prefix R as bs\n tail (r ∷ rs) = rs\n\n uncons : Prefix R (a ∷ as) (b ∷ bs) → R a b × Prefix R as bs\n uncons (r ∷ rs) = r , rs\n\nmodule _ {a b r s} {A : Set a} {B : Set b} {R : REL A B r} {S : REL A B s} where\n\n map : R ⇒ S → Prefix R ⇒ Prefix S\n map R⇒S [] = []\n map R⇒S (r ∷ rs) = R⇒S r ∷ map R⇒S rs\n\nmodule _ {a b r} {A : Set a} {B : Set b} {R : REL A B r} where\n\n toView : ∀ {as bs} → Prefix R as bs → PrefixView R as bs\n toView [] = [] ++ _\n toView (r ∷ rs) with toView rs\n ... | rs′ ++ ds = (r ∷ rs′) ++ ds\n\n fromView : ∀ {as bs} → PrefixView R as bs → Prefix R as bs\n fromView ([] ++ ds) = []\n fromView ((r ∷ rs) ++ ds) = r ∷ fromView (rs ++ ds)\n", "meta": {"hexsha": "ba86166a74245cb13c2ea1ee43d398bb89ee698e", "size": 1821, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Prefix/Heterogeneous.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Prefix/Heterogeneous.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Prefix/Heterogeneous.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 33.7222222222, "max_line_length": 80, "alphanum_fraction": 0.5052169138, "num_tokens": 653, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637541053281, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.6231447028575352}} {"text": "module plfa-code.Relations where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong; sym; trans)\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_)\nopen import Data.Nat.Properties using (+-comm)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_)\n\nopen import plfa-code.Reasoning-legacy\nopen import Function\n\ndata _≤_ : ℕ → ℕ → Set where\n z≤n : ∀ {n : ℕ}\n ---------\n → zero ≤ n\n\n s≤s : ∀ {m n : ℕ}\n → m ≤ n\n --------------\n → suc m ≤ suc n\n\ninfix 4 _≤_\n\n_ : 2 ≤ 4\n_ = s≤s (s≤s z≤n)\n\ninv-s≤s : ∀ {m n : ℕ}\n → suc m ≤ suc n\n -------------\n → m ≤ n\ninv-s≤s (s≤s m≤n) = m≤n\n\ninv-z≤n : ∀ {m : ℕ}\n → m ≤ zero\n ---------\n → m ≡ zero\ninv-z≤n z≤n = refl\n\n≤-refl : ∀ {n : ℕ}\n ------\n → n ≤ n\n≤-refl {zero} = z≤n\n≤-refl {suc n} = s≤s ≤-refl\n\n≤-trans : ∀ {m n p : ℕ}\n → m ≤ n\n → n ≤ p\n ------\n → m ≤ p\n≤-trans z≤n _ = z≤n\n≤-trans (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans m≤n n≤p)\n\n≤-trans′ : ∀ (m n p : ℕ)\n → m ≤ n\n → n ≤ p\n ------\n → m ≤ p\n≤-trans′ zero _ _ z≤n _ = z≤n\n≤-trans′ (suc m) (suc n) (suc p) (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans′ m n p m≤n n≤p)\n\n≤-antisym : ∀ {m n : ℕ}\n → m ≤ n\n → n ≤ m\n -------\n → m ≡ n\n≤-antisym z≤n z≤n = refl\n≤-antisym (s≤s m≤n) (s≤s n≤m) = cong suc (≤-antisym m≤n n≤m)\n\n-- when m is zero there is no instance for `n ≤ m`, the same as when n is zero\n\ndata Total (m n : ℕ) : Set where\n forward :\n m ≤ n\n ----------\n → Total m n\n\n flipped :\n n ≤ m\n ----------\n → Total m n\n\n\n≤-total : ∀ (m n : ℕ) → Total m n\n≤-total zero n = forward z≤n\n≤-total (suc m) zero = flipped z≤n\n≤-total (suc m) (suc n) with ≤-total m n\n... | forward m≤n = forward (s≤s m≤n)\n... | flipped n≤m = flipped (s≤s n≤m)\n\n≤-total′ : ∀ (m n : ℕ) → Total m n\n≤-total′ zero n = forward z≤n\n≤-total′ (suc m) zero = flipped z≤n\n≤-total′ (suc m) (suc n) = helper (≤-total′ m n)\n where\n helper : Total m n → Total (suc m) (suc n)\n helper (forward m≤n) = forward (s≤s m≤n)\n helper (flipped n≤m) = flipped (s≤s n≤m)\n\n+-monoʳ-≤ : ∀ (n p q : ℕ)\n → p ≤ q\n --------------\n → n + p ≤ n + q\n+-monoʳ-≤ zero p q p≤q = p≤q\n+-monoʳ-≤ (suc n) p q p≤q = s≤s (+-monoʳ-≤ n p q p≤q)\n\n+-monoˡ-≤ : ∀ (m n p : ℕ)\n → m ≤ n\n --------------\n → m + p ≤ n + p\n+-monoˡ-≤ m n p m≤n rewrite +-comm m p | +-comm n p = +-monoʳ-≤ p m n m≤n\n\n+-mono-≤ : ∀ (m n p q : ℕ)\n → m ≤ n\n → p ≤ q\n --------------\n → m + p ≤ n + q\n+-mono-≤ m n p q m≤n p≤q = ≤-trans (+-monoˡ-≤ m n p m≤n) (+-monoʳ-≤ n p q p≤q)\n\n---------- practice ----------\n*-mono-≤ : ∀ (m n p q : ℕ) → m ≤ n → p ≤ q → m * p ≤ n * q\n*-mono-≤ zero n p q m≤n p≤q = z≤n\n*-mono-≤ (suc m) (suc n) p q m≤n p≤q = +-mono-≤ p q (m * p) (n * q) p≤q (*-mono-≤ m n p q (inv-s≤s m≤n) p≤q)\n------------------------------\n\ninfix 4 _<_\n\ndata _<_ : ℕ → ℕ → Set where\n z List A -> List A\n\ninfixr 40 _::_\n\nmap : {A B : Set} -> (A -> B) -> List A -> List B\nmap f [] = []\nmap f (x :: xs) = f x :: map f xs\n\n-- More boring types: Bool and Maybe\n\ndata Bool : Set where\n false : Bool\n true : Bool\n\ndata Maybe (A : Set) : Set where\n nothing : Maybe A\n just : A -> Maybe A\n\nfmap : forall {A B} -> (A -> B) -> Maybe A -> Maybe B\nfmap f nothing = nothing\nfmap f (just x) = just (f x)\n\n-- The intensional equality type\n\ndata _==_ {A : Set}(x : A) : A -> Set where\n refl : x == x\n\n-- Sigma types\n\ndata Σ {A : Set}(B : A -> Set) : Set where\n _,_ : (x : A) -> B x -> Σ B\n\nfst : {A : Set}{B : A -> Set} -> Σ B -> A\nfst (x , y) = x\n\nsnd : {A : Set}{B : A -> Set}(p : Σ B) -> B (fst p)\nsnd (x , y) = y\n\n_×_ : Set -> Set -> Set\nA × B = Σ {A} (\\_ -> B)\n\n-- A more interesting type\n\ninfix 20 _∈_\ndata _∈_ {A : Set} : A -> List A -> Set where\n first : forall {x xs} -> x ∈ x :: xs\n later : forall {x y xs} -> x ∈ xs -> x ∈ y :: xs\n\nmodule Map (K V : Set)\n (_=?=_ : (x y : K) -> Maybe (x == y))\n where\n\n Map : Set\n Map = List (K × V)\n\n HasKey : K -> Map -> Set\n HasKey k m = k ∈ map fst m\n\n member : (x : K)(m : Map) -> Maybe (HasKey x m)\n member x [] = nothing\n member x ((y , v) :: m) with x =?= y\n ... | nothing = fmap later (member x m)\n member x ((.x , v) :: m) | just refl = just first\n\n lookup : (x : K)(m : Map) -> HasKey x m -> Σ \\v -> (x , v) ∈ m\n lookup x [] ()\n lookup x ((.x , u) :: m) first = u , first\n lookup x (e :: m) (later p) with lookup x m p\n ... | v , q = v , later q\n", "meta": {"hexsha": "16f5fd33efd676e8abe8615279786b00460fa0d2", "size": 1767, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/DTP08/ulf/Talk.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/DTP08/ulf/Talk.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/DTP08/ulf/Talk.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 20.5465116279, "max_line_length": 64, "alphanum_fraction": 0.4850028297, "num_tokens": 675, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.855851154320682, "lm_q2_score": 0.7279754489059774, "lm_q1q2_score": 0.6230386282632975}} {"text": "{-# OPTIONS --universe-polymorphism #-}\n\nopen import Categories.Category\n\nmodule Categories.Object.SubobjectClassifier {o ℓ e} (C : Category o ℓ e) where\n\nopen Category C\n\nopen import Level\n\nopen import Categories.Object.Terminal\nopen import Categories.Morphisms\nopen import Categories.Pullback\n\nrecord SubobjectClassifier : Set (o ⊔ ℓ ⊔ e) where\n field\n Ω : Obj\n χ : ∀ {U X} → (j : U ⇒ X) → (X ⇒ Ω)\n terminal : Terminal C\n\n open Terminal terminal\n\n field\n ⊤⇒Ω : ⊤ ⇒ Ω\n .j-pullback : ∀ {U X} → (j : U ⇒ X) → Mono C j → Pullback C ⊤⇒Ω (χ j)\n .χ-unique : ∀ {U X} → (j : U ⇒ X) → (χ′ : X ⇒ Ω) → Mono C j → Pullback C ⊤⇒Ω χ′ → χ′ ≡ χ j\n\n", "meta": {"hexsha": "b61eaf788cc99db072c3c097bb008ca43857477b", "size": 654, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Object/SubobjectClassifier.agda", "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 98, "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_issues_repo_path": "Categories/Object/SubobjectClassifier.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_forks_repo_path": "Categories/Object/SubobjectClassifier.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 23, "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "avg_line_length": 23.3571428571, "max_line_length": 94, "alphanum_fraction": 0.6100917431, "num_tokens": 241, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9314625107731765, "lm_q2_score": 0.6688802735722128, "lm_q1q2_score": 0.6230368990282226}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\nopen import homotopy.Bouquet\nopen import homotopy.DisjointlyPointedSet\nopen import cohomology.Theory\n\nmodule cohomology.DisjointlyPointedSet {i} (OT : OrdinaryTheory i) where\n\n open OrdinaryTheory OT\n open import cohomology.Bouquet OT\n\n module _ (X : Ptd i)\n (X-is-set : is-set (de⊙ X)) (X-sep : is-separable X)\n (ac : has-choice 0 (de⊙ X) i) where\n\n C-set : C 0 X ≃ᴳ Πᴳ (MinusPoint X) (λ _ → C2 0)\n C-set = C-Bouquet-diag 0 (MinusPoint X) (MinusPoint-has-choice X-sep ac)\n ∘eᴳ C-emap 0 (Bouquet-⊙equiv-X X-sep)\n\n module _ {n : ℤ} (n≠0 : n ≠ 0) (X : Ptd i)\n (X-is-set : is-set (de⊙ X)) (X-sep : is-separable X)\n (ac : has-choice 0 (de⊙ X) i) where\n\n abstract\n C-set-≠-is-trivial : is-trivialᴳ (C n X)\n C-set-≠-is-trivial = iso-preserves'-trivial\n (C-emap n (Bouquet-⊙equiv-X X-sep))\n (C-Bouquet-≠-is-trivial n (MinusPoint X) 0 n≠0 (MinusPoint-has-choice X-sep ac))\n", "meta": {"hexsha": "af02bce1308d0c09c318e2de40088f5229d08cd5", "size": 979, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/cohomology/DisjointlyPointedSet.agda", "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 294, "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_issues_repo_path": "theorems/cohomology/DisjointlyPointedSet.agda", "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 31, "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_forks_repo_path": "theorems/cohomology/DisjointlyPointedSet.agda", "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 50, "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "avg_line_length": 32.6333333333, "max_line_length": 88, "alphanum_fraction": 0.6302349336, "num_tokens": 390, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9362849986365572, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.6230139178766018}} {"text": "module Cats.Category.Setoids.Facts.Initial where\n\nopen import Data.Empty using (⊥)\nopen import Level\n\nopen import Cats.Category\nopen import Cats.Category.Setoids using (Setoids ; ≈-intro)\n\n\nmodule Build {l} {l≈} where\n\n open Category (Setoids l l≈)\n\n\n Zero : Obj\n Zero = record\n { Carrier = Lift l ⊥\n ; _≈_ = λ()\n ; isEquivalence = record\n { refl = λ{}\n ; sym = λ{}\n ; trans = λ{}\n }\n }\n\n\n isInitial : IsInitial Zero\n isInitial X = ∃!-intro\n (record { arr = λ() ; resp = λ{} })\n _\n λ _ → ≈-intro λ {}\n\n\nopen Build\n\n\ninstance\n hasInitial : ∀ l l≈ → HasInitial (Setoids l l≈)\n hasInitial l l≈ = record\n { Zero = Zero\n ; isInitial = isInitial\n }\n", "meta": {"hexsha": "b15b0a1ed9f64c2f39074cd555e405d5717ef409", "size": 736, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Category/Setoids/Facts/Initial.agda", "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cats/Category/Setoids/Facts/Initial.agda", "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cats/Category/Setoids/Facts/Initial.agda", "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.1162790698, "max_line_length": 59, "alphanum_fraction": 0.5529891304, "num_tokens": 222, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026528034425, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.6230124224811792}} {"text": "module Luau.Type where\n\nopen import FFI.Data.Maybe using (Maybe; just; nothing)\n\ndata Type : Set where\n nil : Type\n _⇒_ : Type → Type → Type\n none : Type\n any : Type\n number : Type\n _∪_ : Type → Type → Type\n _∩_ : Type → Type → Type\n\nsrc : Type → Type\nsrc nil = none\nsrc (S ⇒ T) = S\nsrc none = none\nsrc any = any\nsrc number = none\nsrc (S ∪ T) = (src S) ∪ (src T)\nsrc (S ∩ T) = (src S) ∩ (src T)\n\ntgt : Type → Type\ntgt nil = none\ntgt (S ⇒ T) = T\ntgt none = none\ntgt any = any\ntgt number = none\ntgt (S ∪ T) = (tgt S) ∪ (tgt T)\ntgt (S ∩ T) = (tgt S) ∩ (tgt T)\n\noptional : Type → Type\noptional nil = nil\noptional (T ∪ nil) = (T ∪ nil)\noptional T = (T ∪ nil)\n\nnormalizeOptional : Type → Type\nnormalizeOptional (S ∪ T) with normalizeOptional S | normalizeOptional T\nnormalizeOptional (S ∪ T) | (S′ ∪ nil) | (T′ ∪ nil) = (S′ ∪ T′) ∪ nil\nnormalizeOptional (S ∪ T) | S′ | (T′ ∪ nil) = (S′ ∪ T′) ∪ nil\nnormalizeOptional (S ∪ T) | (S′ ∪ nil) | T′ = (S′ ∪ T′) ∪ nil\nnormalizeOptional (S ∪ T) | S′ | nil = optional S′\nnormalizeOptional (S ∪ T) | nil | T′ = optional T′\nnormalizeOptional (S ∪ T) | S′ | T′ = S′ ∪ T′\nnormalizeOptional T = T\n", "meta": {"hexsha": "af5f857cbdb76050fe4d8cb4ee853eb7694262b7", "size": 1195, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "prototyping/Luau/Type.agda", "max_stars_repo_name": "Tr4shh/Roblox-Luau", "max_stars_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "prototyping/Luau/Type.agda", "max_issues_repo_name": "Tr4shh/Roblox-Luau", "max_issues_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "prototyping/Luau/Type.agda", "max_forks_repo_name": "Tr4shh/Roblox-Luau", "max_forks_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.9782608696, "max_line_length": 72, "alphanum_fraction": 0.5548117155, "num_tokens": 456, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9511422199928904, "lm_q2_score": 0.6548947223065754, "lm_q1q2_score": 0.6228980200363036}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Indexed binary relations\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Relation.Binary.Indexed.Heterogeneous where\n\nopen import Function\nopen import Level using (suc; _⊔_)\nopen import Relation.Binary using (_⇒_)\nopen import Relation.Binary.PropositionalEquality.Core as P using (_≡_)\n\n------------------------------------------------------------------------\n-- Publically export core definitions\n\nopen import Relation.Binary.Indexed.Heterogeneous.Core public\n\n------------------------------------------------------------------------\n-- Equivalences\n\nrecord IsIndexedEquivalence {i a ℓ} {I : Set i} (A : I → Set a)\n (_≈_ : IRel A ℓ) : Set (i ⊔ a ⊔ ℓ) where\n field\n refl : Reflexive A _≈_\n sym : Symmetric A _≈_\n trans : Transitive A _≈_\n\n reflexive : ∀ {i} → _≡_ ⟨ _⇒_ ⟩ _≈_ {i}\n reflexive P.refl = refl\n\nrecord IndexedSetoid {i} (I : Set i) c ℓ : Set (suc (i ⊔ c ⊔ ℓ)) where\n infix 4 _≈_\n field\n Carrier : I → Set c\n _≈_ : IRel Carrier ℓ\n isEquivalence : IsIndexedEquivalence Carrier _≈_\n\n open IsIndexedEquivalence isEquivalence public\n\n------------------------------------------------------------------------\n-- Preorders\n\nrecord IsIndexedPreorder {i a ℓ₁ ℓ₂} {I : Set i} (A : I → Set a)\n (_≈_ : IRel A ℓ₁) (_∼_ : IRel A ℓ₂) :\n Set (i ⊔ a ⊔ ℓ₁ ⊔ ℓ₂) where\n field\n isEquivalence : IsIndexedEquivalence A _≈_\n reflexive : ∀ {i j} → (_≈_ {i} {j}) ⟨ _⇒_ ⟩ _∼_\n trans : Transitive A _∼_\n\n module Eq = IsIndexedEquivalence isEquivalence\n\n refl : Reflexive A _∼_\n refl = reflexive Eq.refl\n\nrecord IndexedPreorder {i} (I : Set i) c ℓ₁ ℓ₂ :\n Set (suc (i ⊔ c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _∼_\n field\n Carrier : I → Set c\n _≈_ : IRel Carrier ℓ₁ -- The underlying equality.\n _∼_ : IRel Carrier ℓ₂ -- The relation.\n isPreorder : IsIndexedPreorder Carrier _≈_ _∼_\n\n open IsIndexedPreorder isPreorder public\n\n------------------------------------------------------------------------\n-- DEPRECATED NAMES\n------------------------------------------------------------------------\n-- Please use the new names as continuing support for the old names is\n-- not guaranteed.\n\n-- Version 0.17\n\nREL = IREL\n{-# WARNING_ON_USAGE REL\n\"Warning: REL was deprecated in v0.17.\nPlease use IREL instead.\"\n#-}\nRel = IRel\n{-# WARNING_ON_USAGE Rel\n\"Warning: Rel was deprecated in v0.17.\nPlease use IRel instead.\"\n#-}\nSetoid = IndexedSetoid\n{-# WARNING_ON_USAGE Setoid\n\"Warning: Setoid was deprecated in v0.17.\nPlease use IndexedSetoid instead.\"\n#-}\nIsEquivalence = IsIndexedEquivalence\n{-# WARNING_ON_USAGE IsEquivalence\n\"Warning: IsEquivalence was deprecated in v0.17.\nPlease use IsIndexedEquivalence instead.\"\n#-}\n", "meta": {"hexsha": "ffadc8c9549413ac17b043482f2c01f7c9da0279", "size": 2960, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Indexed/Heterogeneous.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Indexed/Heterogeneous.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Indexed/Heterogeneous.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.2040816327, "max_line_length": 72, "alphanum_fraction": 0.5341216216, "num_tokens": 808, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972616934408, "lm_q2_score": 0.7154240079185319, "lm_q1q2_score": 0.6228461822436203}} {"text": "open import Prelude\nopen import Nat\nopen import dynamics-core\nopen import contexts\nopen import lemmas-disjointness\n\nmodule exchange where\n -- exchanging just two disequal elements produces the same context\n swap-little : {A : Set} {x y : Nat} {τ1 τ2 : A} → (x ≠ y) →\n ((■ (x , τ1)) ,, (y , τ2)) == ((■ (y , τ2)) ,, (x , τ1))\n swap-little {A} {x} {y} {τ1} {τ2} neq = ∪comm (■ (y , τ2))\n (■ (x , τ1))\n (disjoint-singles (flip neq))\n\n -- really the dynamics-core of all the exchange arguments: contexts with two\n -- disequal elements exchanged are the same. we reassociate the unions,\n -- swap as above, and then associate them back.\n --\n -- note that this is generic in the contents of the context. the proofs\n -- below show the exchange properties that we actually need in the\n -- various other proofs; the remaning exchange properties for both Δ and\n -- Γ positions for all the other hypothetical judgements are exactly in\n -- this pattern.\n swap : {A : Set} {x y : Nat} {τ1 τ2 : A} (Γ : A ctx) (x≠y : x == y → ⊥) →\n ((Γ ,, (x , τ1)) ,, (y , τ2)) == ((Γ ,, (y , τ2)) ,, (x , τ1))\n swap {A} {x} {y} {τ1} {τ2} Γ neq = funext eq\n where\n eq : (z : Nat) → ((Γ ,, (x , τ1)) ,, (y , τ2)) z == ((Γ ,, (y , τ2)) ,, (x , τ1)) z\n eq z with natEQ y z\n ... | Inr y≠z with natEQ x z\n ... | Inl refl = refl\n ... | Inr x≠z with natEQ y z\n ... | Inl refl = abort (y≠z refl)\n ... | Inr y≠z' = refl\n eq z | Inl refl with natEQ x z\n ... | Inl refl = abort (neq refl)\n ... | Inr x≠z with natEQ z z\n ... | Inl refl = refl\n ... | Inr z≠z = abort (z≠z refl)\n\n \n \n -- (∪assoc Γ (■ (x , τ1)) (■ (y , τ2)) (disjoint-singles neq)) ·\n -- (ap1 (λ qq → Γ ∪ qq) (swap-little neq) ·\n -- the above exchange principle used via transport in the judgements we needed\n exchange-subst-Γ : ∀{Δ Γ x y τ1 τ2 σ Γ'} →\n x ≠ y →\n Δ , (Γ ,, (x , τ1) ,, (y , τ2)) ⊢ σ :s: Γ' →\n Δ , (Γ ,, (y , τ2) ,, (x , τ1)) ⊢ σ :s: Γ'\n exchange-subst-Γ {Δ} {Γ} {x} {y} {τ1} {τ2} {σ} {Γ'} x≠y =\n tr (λ qq → Δ , qq ⊢ σ :s: Γ') (swap Γ x≠y)\n\n exchange-synth : ∀{Γ x y τ τ1 τ2 e}\n → x ≠ y\n → (Γ ,, (x , τ1) ,, (y , τ2)) ⊢ e => τ\n → (Γ ,, (y , τ2) ,, (x , τ1)) ⊢ e => τ\n exchange-synth {Γ} {x} {y} {τ} {τ1} {τ2} {e} neq =\n tr (λ qq → qq ⊢ e => τ) (swap Γ neq)\n\n exchange-ana : ∀{Γ x y τ τ1 τ2 e}\n → x ≠ y\n → (Γ ,, (x , τ1) ,, (y , τ2)) ⊢ e <= τ\n → (Γ ,, (y , τ2) ,, (x , τ1)) ⊢ e <= τ\n exchange-ana {Γ} {x} {y} {τ} {τ1} {τ2} {e} neq =\n tr (λ qq → qq ⊢ e <= τ) (swap Γ neq)\n\n exchange-elab-synth : ∀{Γ x y τ1 τ2 e τ d Δ} →\n x ≠ y →\n (Γ ,, (x , τ1) ,, (y , τ2)) ⊢ e ⇒ τ ~> d ⊣ Δ →\n (Γ ,, (y , τ2) ,, (x , τ1)) ⊢ e ⇒ τ ~> d ⊣ Δ\n exchange-elab-synth {Γ = Γ} {e = e} {τ = τ} {d = d } {Δ = Δ} neq =\n tr (λ qq → qq ⊢ e ⇒ τ ~> d ⊣ Δ) (swap Γ neq)\n\n exchange-elab-ana : ∀ {Γ x y τ1 τ2 τ τ' d e Δ} →\n x ≠ y →\n (Γ ,, (x , τ1) ,, (y , τ2)) ⊢ e ⇐ τ ~> d :: τ' ⊣ Δ →\n (Γ ,, (y , τ2) ,, (x , τ1)) ⊢ e ⇐ τ ~> d :: τ' ⊣ Δ\n exchange-elab-ana {Γ = Γ} {τ = τ} {τ' = τ'} {d = d} {e = e} {Δ = Δ} neq =\n tr (λ qq → qq ⊢ e ⇐ τ ~> d :: τ' ⊣ Δ) (swap Γ neq)\n\n exchange-ta-Γ : ∀{Γ x y τ1 τ2 d τ Δ } →\n x ≠ y →\n Δ , (Γ ,, (x , τ1) ,, (y , τ2)) ⊢ d :: τ →\n Δ , (Γ ,, (y , τ2) ,, (x , τ1)) ⊢ d :: τ\n exchange-ta-Γ {Γ = Γ} {d = d} {τ = τ} {Δ = Δ} neq =\n tr (λ qq → Δ , qq ⊢ d :: τ) (swap Γ neq)\n", "meta": {"hexsha": "2a28bd68fcc11649b22689e5659b3bdb47155bc7", "size": 3851, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "exchange.agda", "max_stars_repo_name": "hazelgrove/hazelnut-agda", "max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "exchange.agda", "max_issues_repo_name": "hazelgrove/hazelnut-agda", "max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "exchange.agda", "max_forks_repo_name": "hazelgrove/hazelnut-agda", "max_forks_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.2643678161, "max_line_length": 90, "alphanum_fraction": 0.4069072968, "num_tokens": 1508, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972684083609, "lm_q2_score": 0.7154240018510025, "lm_q1q2_score": 0.622846181765261}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\n\n-- The core of a category.\n-- See https://ncatlab.org/nlab/show/core\n\nmodule Categories.Category.Construction.Core {o ℓ e} (𝒞 : Category o ℓ e) where\n\nopen import Level using (_⊔_)\nopen import Function using (flip)\n\nopen import Categories.Category.Groupoid using (Groupoid; IsGroupoid)\nopen import Categories.Morphism 𝒞\nopen import Categories.Morphism.IsoEquiv 𝒞\n\nopen Category 𝒞\nopen _≃_\n\nCore : Category o (ℓ ⊔ e) e\nCore = record\n { Obj = Obj\n ; _⇒_ = _≅_\n ; _≈_ = _≃_\n ; id = ≅.refl\n ; _∘_ = flip ≅.trans\n ; assoc = ⌞ assoc ⌟\n ; sym-assoc = ⌞ sym-assoc ⌟\n ; identityˡ = ⌞ identityˡ ⌟\n ; identityʳ = ⌞ identityʳ ⌟\n ; identity² = ⌞ identity² ⌟\n ; equiv = ≃-isEquivalence\n ; ∘-resp-≈ = λ where ⌞ eq₁ ⌟ ⌞ eq₂ ⌟ → ⌞ ∘-resp-≈ eq₁ eq₂ ⌟\n }\n\nCore-isGroupoid : IsGroupoid Core\nCore-isGroupoid = record\n { _⁻¹ = ≅.sym\n ; iso = λ {_ _ f} → record { isoˡ = ⌞ isoˡ f ⌟ ; isoʳ = ⌞ isoʳ f ⌟ }\n }\n where open _≅_\n\nCoreGroupoid : Groupoid o (ℓ ⊔ e) e\nCoreGroupoid = record { category = Core; isGroupoid = Core-isGroupoid }\n", "meta": {"hexsha": "e7cdf188e4674c690cc0e291125db13dfa80d1f7", "size": 1139, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Construction/Core.agda", "max_stars_repo_name": "bblfish/agda-categories", "max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "src/Categories/Category/Construction/Core.agda", "max_issues_repo_name": "bblfish/agda-categories", "max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Construction/Core.agda", "max_forks_repo_name": "bblfish/agda-categories", "max_forks_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 25.3111111111, "max_line_length": 79, "alphanum_fraction": 0.6163301141, "num_tokens": 449, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972549785201, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.6228461668748562}} {"text": "{-# OPTIONS --without-K --safe #-}\n\n-- Verbatim dual of Categories.Category.Construction.Kleisli\nmodule Categories.Category.Construction.CoKleisli where\n\nopen import Level\n\nopen import Categories.Category\nopen import Categories.Functor using (Functor; module Functor)\nopen import Categories.NaturalTransformation hiding (id)\nopen import Categories.Comonad\nimport Categories.Morphism.Reasoning as MR\n\nprivate\n variable\n o ℓ e : Level\n\nCoKleisli : {𝒞 : Category o ℓ e} → Comonad 𝒞 → Category o ℓ e\nCoKleisli {𝒞 = 𝒞} M =\n record\n { Obj = Obj\n ; _⇒_ = λ A B → (F₀ A ⇒ B)\n ; _≈_ = _≈_\n ; _∘_ = λ f g → f ∘ F₁ g ∘ δ.η _\n ; id = ε.η _\n ; assoc = assoc′\n ; sym-assoc = sym assoc′\n ; identityˡ = identityˡ′\n ; identityʳ = identityʳ′\n ; identity² = identity²′\n ; equiv = equiv\n ; ∘-resp-≈ = λ f≈h g≈i → ∘-resp-≈ f≈h (∘-resp-≈ (F≈ g≈i) refl)\n }\n where\n module M = Comonad M\n open M using (ε; δ; F)\n open Functor F\n open Category 𝒞\n open HomReasoning\n open Equiv\n open MR 𝒞\n \n -- useful lemma\n trihom : {X Y Z W : Obj} {f : X ⇒ Y} {g : Y ⇒ Z} {h : Z ⇒ W} → F₁ (h ∘ g ∘ f) ≈ F₁ h ∘ F₁ g ∘ F₁ f\n trihom {X} {Y} {Z} {W} {f} {g} {h} = begin \n F₁ (h ∘ g ∘ f) ≈⟨ homomorphism ⟩ \n F₁ h ∘ F₁ (g ∘ f) ≈⟨ refl⟩∘⟨ homomorphism ⟩ \n F₁ h ∘ F₁ g ∘ F₁ f ∎\n -- shorthands to make the proofs nicer\n F≈ = F-resp-≈\n\n assoc′ : {A B C D : Obj} {f : F₀ A ⇒ B} {g : F₀ B ⇒ C} {h : F₀ C ⇒ D} → (h ∘ F₁ g ∘ δ.η B) ∘ F₁ f ∘ δ.η A ≈ h ∘ F₁ (g ∘ F₁ f ∘ δ.η A) ∘ δ.η A\n assoc′ {A} {B} {C} {D} {f} {g} {h} =\n begin\n (h ∘ F₁ g ∘ δ.η B) ∘ (F₁ f ∘ δ.η A) ≈⟨ assoc²' ⟩\n h ∘ (F₁ g ∘ (δ.η B ∘ (F₁ f ∘ δ.η A))) ≈⟨ ((refl⟩∘⟨ (refl⟩∘⟨ sym assoc))) ⟩\n h ∘ (F₁ g ∘ ((δ.η B ∘ F₁ f) ∘ δ.η A)) ≈⟨ ((refl⟩∘⟨ (refl⟩∘⟨ pushˡ (δ.commute f)))) ⟩\n h ∘ (F₁ g ∘ (F₁ (F₁ f) ∘ (δ.η (F₀ A) ∘ δ.η A))) ≈⟨ refl⟩∘⟨ (refl⟩∘⟨ pushʳ (Comonad.assoc M)) ⟩\n h ∘ (F₁ g ∘ ((F₁ (F₁ f) ∘ F₁ (δ.η A)) ∘ δ.η A)) ≈⟨ pull-center (sym trihom) ⟩\n h ∘ (F₁ (g ∘ (F₁ f ∘ δ.η A)) ∘ δ.η A)\n ∎\n\n identityˡ′ : ∀ {A B : Obj} {f : F₀ A ⇒ B} → ε.η B ∘ F₁ f ∘ δ.η A ≈ f\n identityˡ′ {A} {B} {f} =\n begin\n ε.η B ∘ F₁ f ∘ δ.η A ≈⟨ pullˡ (ε.commute f) ⟩\n (f ∘ ε.η (F₀ A)) ∘ δ.η A ≈⟨ trans (pullʳ (Comonad.identityʳ M)) identityʳ ⟩\n f\n ∎\n\n identityʳ′ : ∀ {A B : Obj} {f : F₀ A ⇒ B} → f ∘ F₁ (ε.η A) ∘ δ.η A ≈ f\n identityʳ′ {A} {B} {f} = elimʳ (Comonad.identityˡ M)\n\n identity²′ : {A : Obj} → ε.η A ∘ F₁ (ε.η A) ∘ δ.η A ≈ ε.η A\n identity²′ = elimʳ (Comonad.identityˡ M)", "meta": {"hexsha": "ba29c71bf5f25789f97ed16422fa1b8372226a96", "size": 2566, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Construction/CoKleisli.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-05-21T17:07:19.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-22T03:54:24.000Z", "max_issues_repo_path": "src/Categories/Category/Construction/CoKleisli.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Construction/CoKleisli.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.2133333333, "max_line_length": 143, "alphanum_fraction": 0.4996102884, "num_tokens": 1263, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519527944504227, "lm_q2_score": 0.7310585903489891, "lm_q1q2_score": 0.6228274089548081}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category using (Category; module Commutation)\n\n-- Defines the induced Monoidal structure of a Cartesian Category\n\nmodule Categories.Category.Cartesian.Monoidal {o ℓ e} {𝒞 : Category o ℓ e} where\n\nopen Category 𝒞\nopen HomReasoning\n\nopen import Categories.Category.BinaryProducts 𝒞 using (BinaryProducts; module BinaryProducts)\nopen import Categories.Category.Cartesian using (Cartesian)\nopen import Categories.Object.Terminal 𝒞 using (Terminal)\nopen import Categories.Object.Product.Core 𝒞 using (module Product)\nopen import Categories.Morphism 𝒞 using (_≅_; module ≅)\nopen import Categories.Morphism.Reasoning 𝒞 using (cancelˡ; pullʳ; pullˡ)\nopen import Categories.Category.Monoidal using (Monoidal)\n\nopen import Categories.Functor using (Functor) renaming (id to idF)\nopen import Categories.NaturalTransformation using (ntHelper)\nopen import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism)\n\nprivate\n variable\n A B C D W X Y Z : Obj\n f f′ g g′ h i : A ⇒ B\n\n-- The cartesian structure induces a monoidal one: 𝒞 is cartesian monoidal.\n\nmodule CartesianMonoidal (cartesian : Cartesian 𝒞) where\n open Commutation 𝒞\n open Terminal (Cartesian.terminal cartesian) using (⊤; !; !-unique; !-unique₂)\n open BinaryProducts (Cartesian.products cartesian) using (π₁; π₂; ⟨_,_⟩; _×_; _⁂_;\n _×-; -×_; ⟨⟩∘; ⟨⟩-cong₂; -×-; ×-assoc; assocˡ∘⁂; assocʳ∘⁂; ⁂∘⟨⟩;\n first∘⟨⟩; second∘⟨⟩; ⟨⟩-congˡ; ⟨⟩-congʳ; π₁∘⁂; π₂∘⁂; assocˡ∘⟨⟩;\n assocˡ; assocʳ;\n η; unique; project₁; project₂)\n\n ⊤×A≅A : ⊤ × A ≅ A\n ⊤×A≅A = record\n { from = π₂\n ; to = ⟨ ! , id ⟩\n ; iso = record\n { isoˡ = begin\n ⟨ ! , id ⟩ ∘ π₂ ≈˘⟨ unique !-unique₂ (cancelˡ project₂) ⟩\n ⟨ π₁ , π₂ ⟩ ≈⟨ η ⟩\n id ∎\n ; isoʳ = project₂\n }\n }\n\n A×⊤≅A : A × ⊤ ≅ A\n A×⊤≅A = record\n { from = π₁\n ; to = ⟨ id , ! ⟩\n ; iso = record\n { isoˡ = begin\n ⟨ id , ! ⟩ ∘ π₁ ≈˘⟨ unique (cancelˡ project₁) !-unique₂ ⟩\n ⟨ π₁ , π₂ ⟩ ≈⟨ η ⟩\n id ∎\n ; isoʳ = project₁\n }\n }\n\n ⊤×--id : NaturalIsomorphism (⊤ ×-) idF\n ⊤×--id = record\n { F⇒G = ntHelper record\n { η = λ _ → π₂\n ; commute = λ _ → project₂\n }\n ; F⇐G = ntHelper record\n { η = λ _ → ⟨ ! , id ⟩\n ; commute = λ f → begin\n ⟨ ! , id ⟩ ∘ f ≈⟨ ⟨⟩∘ ⟩\n ⟨ ! ∘ f , id ∘ f ⟩ ≈⟨ ⟨⟩-cong₂ (⟺ (!-unique _)) identityˡ ⟩\n ⟨ ! , f ⟩ ≈˘⟨ ⟨⟩-cong₂ identityˡ identityʳ ⟩\n ⟨ id ∘ ! , f ∘ id ⟩ ≈˘⟨ ⟨⟩-cong₂ (pullʳ project₁) (pullʳ project₂) ⟩\n ⟨ (id ∘ π₁) ∘ ⟨ ! , id ⟩ , (f ∘ π₂) ∘ ⟨ ! , id ⟩ ⟩ ≈˘⟨ ⟨⟩∘ ⟩\n ⟨ id ∘ π₁ , f ∘ π₂ ⟩ ∘ ⟨ ! , id ⟩ ∎\n }\n ; iso = λ _ → _≅_.iso ⊤×A≅A\n }\n\n -×⊤-id : NaturalIsomorphism (-× ⊤) idF\n -×⊤-id = record\n { F⇒G = ntHelper record\n { η = λ _ → π₁\n ; commute = λ _ → project₁\n }\n ; F⇐G = ntHelper record\n { η = λ _ → ⟨ id , ! ⟩\n ; commute = λ f → begin\n ⟨ id , ! ⟩ ∘ f ≈⟨ ⟨⟩∘ ⟩\n ⟨ id ∘ f , ! ∘ f ⟩ ≈⟨ ⟨⟩-cong₂ identityˡ (⟺ (!-unique _)) ⟩\n ⟨ f , ! ⟩ ≈˘⟨ ⟨⟩-cong₂ identityʳ identityˡ ⟩\n ⟨ f ∘ id , id ∘ ! ⟩ ≈˘⟨ ⟨⟩-cong₂ (pullʳ project₁) (pullʳ project₂) ⟩\n ⟨ (f ∘ π₁) ∘ ⟨ id , ! ⟩ , (id ∘ π₂) ∘ ⟨ id , ! ⟩ ⟩ ≈˘⟨ ⟨⟩∘ ⟩\n ⟨ f ∘ π₁ , id ∘ π₂ ⟩ ∘ ⟨ id , ! ⟩ ∎\n }\n ; iso = λ _ → _≅_.iso A×⊤≅A\n }\n private\n infixr 7 _⊗₀_\n infixr 8 _⊗₁_\n\n _⊗₀_ = _×_\n _⊗₁_ = _⁂_\n α⇒ = assocˡ\n\n private\n pentagon : [ ((X ⊗₀ Y) ⊗₀ Z) ⊗₀ W ⇒ X ⊗₀ Y ⊗₀ Z ⊗₀ W ]⟨\n α⇒ ⊗₁ id ⇒⟨ (X ⊗₀ Y ⊗₀ Z) ⊗₀ W ⟩\n α⇒ ⇒⟨ X ⊗₀ (Y ⊗₀ Z) ⊗₀ W ⟩\n id ⊗₁ α⇒\n ≈ α⇒ ⇒⟨ (X ⊗₀ Y) ⊗₀ Z ⊗₀ W ⟩\n α⇒\n ⟩\n pentagon = begin\n (id ⁂ α⇒) ∘ α⇒ ∘ (α⇒ ⁂ id) ≈⟨ pullˡ second∘⟨⟩ ⟩\n ⟨ π₁ ∘ π₁ , α⇒ ∘ ⟨ π₂ ∘ π₁ , π₂ ⟩ ⟩ ∘ (α⇒ ⁂ id) ≈⟨ ⟨⟩∘ ⟩\n ⟨ (π₁ ∘ π₁) ∘ (α⇒ ⁂ id) , (α⇒ ∘ ⟨ π₂ ∘ π₁ , π₂ ⟩) ∘ (α⇒ ⁂ id) ⟩ ≈⟨ ⟨⟩-cong₂ (pullʳ π₁∘⁂) (pullʳ ⟨⟩∘) ⟩\n ⟨ π₁ ∘ α⇒ ∘ π₁ , α⇒ ∘ ⟨ (π₂ ∘ π₁) ∘ (α⇒ ⁂ id) , π₂ ∘ (α⇒ ⁂ id) ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ (pullˡ project₁) ( refl⟩∘⟨ ⟨⟩-cong₂ (pullʳ π₁∘⁂) π₂∘⁂) ⟩\n ⟨ (π₁ ∘ π₁) ∘ π₁ , α⇒ ∘ ⟨ π₂ ∘ α⇒ ∘ π₁ , id ∘ π₂ ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ assoc (refl⟩∘⟨ ⟨⟩-cong₂ (pullˡ project₂) identityˡ) ⟩\n ⟨ π₁₁₁ , α⇒ ∘ ⟨ ⟨ π₂ ∘ π₁ , π₂ ⟩ ∘ π₁ , π₂ ⟩ ⟩ ≈⟨ ⟨⟩-congˡ (refl⟩∘⟨ ⟨⟩-congʳ ⟨⟩∘) ⟩\n ⟨ π₁₁₁ , α⇒ ∘ ⟨ ⟨ (π₂ ∘ π₁) ∘ π₁ , π₂ ∘ π₁ ⟩ , π₂ ⟩ ⟩ ≈⟨ ⟨⟩-congˡ assocˡ∘⟨⟩ ⟩\n ⟨ π₁₁₁ , ⟨ (π₂ ∘ π₁) ∘ π₁ , ⟨ π₂ ∘ π₁ , π₂ ⟩ ⟩ ⟩ ≈˘⟨ ⟨⟩-congˡ (⟨⟩-cong₂ (Equiv.trans (pullʳ project₁) sym-assoc) project₂) ⟩\n ⟨ π₁₁₁ , ⟨ (π₂ ∘ π₁) ∘ α⇒ , π₂ ∘ α⇒ ⟩ ⟩ ≈˘⟨ ⟨⟩-cong₂ (pullʳ project₁) ⟨⟩∘ ⟩\n ⟨ (π₁ ∘ π₁) ∘ α⇒ , ⟨ π₂ ∘ π₁ , π₂ ⟩ ∘ α⇒ ⟩ ≈˘⟨ ⟨⟩∘ ⟩\n α⇒ ∘ α⇒ ∎\n where\n π₁₁₁ = π₁ ∘ π₁ ∘ π₁\n\n monoidal : Monoidal 𝒞\n monoidal = record\n { ⊗ = -×-\n ; unit = ⊤\n ; unitorˡ = ⊤×A≅A\n ; unitorʳ = A×⊤≅A\n ; associator = ≅.sym ×-assoc\n ; unitorˡ-commute-from = project₂\n ; unitorˡ-commute-to = let open NaturalIsomorphism ⊤×--id in ⇐.commute _\n ; unitorʳ-commute-from = project₁\n ; unitorʳ-commute-to = let open NaturalIsomorphism -×⊤-id in ⇐.commute _\n ; assoc-commute-from = assocˡ∘⁂\n ; assoc-commute-to = assocʳ∘⁂\n ; triangle = begin\n (id ⁂ π₂) ∘ assocˡ ≈⟨ ⁂∘⟨⟩ ⟩\n ⟨ id ∘ π₁ ∘ π₁ , π₂ ∘ ⟨ π₂ ∘ π₁ , π₂ ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ (pullˡ identityˡ) (project₂ ○ (⟺ identityˡ)) ⟩\n π₁ ⁂ id ∎\n ; pentagon = pentagon\n }\n", "meta": {"hexsha": "296616c5a5165f3a1ce24c2f4182f096c80fa623", "size": 6219, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Cartesian/Monoidal.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/Cartesian/Monoidal.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/Cartesian/Monoidal.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 40.6470588235, "max_line_length": 151, "alphanum_fraction": 0.4230583695, "num_tokens": 2698, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519528132451416, "lm_q2_score": 0.7310585727705126, "lm_q1q2_score": 0.6228274077188163}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Functor.Duality where\n\nopen import Level\nopen import Data.Product using (Σ; _,_)\n\nopen import Categories.Category\nopen import Categories.Category.Construction.Cones as Con\nopen import Categories.Category.Construction.Cocones as Coc\nopen import Categories.Functor\nopen import Categories.Functor.Limits\nopen import Categories.Object.Initial\nopen import Categories.Object.Terminal\nopen import Categories.Diagram.Limit as Lim\nopen import Categories.Diagram.Colimit as Col\nopen import Categories.Diagram.Duality\nopen import Categories.Morphism.Duality as MorD\n\nprivate\n variable\n o ℓ e : Level\n C D E J : Category o ℓ e\n\nmodule _ (G : Functor C D) {J : Category o ℓ e} where\n private\n module C = Category C\n module D = Category D\n module G = Functor G\n module J = Category J\n\n coPreservesLimit⇒PreservesCoLimit : ∀ {F : Functor J C} (L : Limit (Functor.op F)) →\n PreservesLimit G.op L →\n PreservesColimit G (coLimit⇒Colimit C L)\n coPreservesLimit⇒PreservesCoLimit L is⊤ = record\n { ! = λ {K} → coCone⇒⇒Cocone⇒ _ (! {Cocone⇒coCone _ K})\n ; !-unique = λ f → !-unique (Cocone⇒⇒coCone⇒ _ f)\n }\n where open IsTerminal is⊤\n\n PreservesColimit⇒coPreservesLimit : ∀ {F : Functor J C} (L : Colimit F) →\n PreservesColimit G L →\n PreservesLimit G.op (Colimit⇒coLimit C L)\n PreservesColimit⇒coPreservesLimit L is⊥ = record\n { ! = λ {K} → Cocone⇒⇒coCone⇒ _ (! {coCone⇒Cocone _ K})\n ; !-unique = λ f → !-unique (coCone⇒⇒Cocone⇒ _ f)\n }\n where open IsInitial is⊥\n\nmodule _ {o ℓ e} (G : Functor C D) where\n private\n module G = Functor G\n\n coContinuous⇒Cocontinuous : Continuous o ℓ e G.op → Cocontinuous o ℓ e G\n coContinuous⇒Cocontinuous Con L =\n coPreservesLimit⇒PreservesCoLimit G (Colimit⇒coLimit C L) (Con (Colimit⇒coLimit C L))\n\n Cocontinuous⇒coContinuous : Cocontinuous o ℓ e G → Continuous o ℓ e G.op\n Cocontinuous⇒coContinuous Coc L =\n PreservesColimit⇒coPreservesLimit G (coLimit⇒Colimit C L) (Coc (coLimit⇒Colimit C L))\n", "meta": {"hexsha": "eb225bf824730ff52ce5d0377f8d4d3c919fcf0c", "size": 2199, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Functor/Duality.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Functor/Duality.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Functor/Duality.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 36.0491803279, "max_line_length": 89, "alphanum_fraction": 0.6580263756, "num_tokens": 694, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519527944504227, "lm_q2_score": 0.7310585727705126, "lm_q1q2_score": 0.6228273939787758}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Binary.Operations.Addition where\n\nopen import Data.Binary.Definitions\nopen import Data.Binary.Operations.Unary\n\nadd : Bit → 𝔹⁺ → 𝔹⁺ → 𝔹⁺\nadd c (x ∷ xs) (y ∷ ys) = sumᵇ c x y ∷ add (carryᵇ c x y) xs ys\nadd O 1ᵇ ys = inc⁺⁺ ys\nadd O (O ∷ xs) 1ᵇ = I ∷ xs\nadd O (I ∷ xs) 1ᵇ = O ∷ inc⁺⁺ xs\nadd I 1ᵇ 1ᵇ = I ∷ 1ᵇ\nadd I 1ᵇ (y ∷ ys) = y ∷ inc⁺⁺ ys\nadd I (x ∷ xs) 1ᵇ = x ∷ inc⁺⁺ xs\n\n_+_ : 𝔹 → 𝔹 → 𝔹\n0ᵇ + ys = ys\n(0< xs) + 0ᵇ = 0< xs\n(0< xs) + (0< ys) = 0< add O xs ys\n", "meta": {"hexsha": "1a9e6c9dcd4fdea44eb143289967b318154f7477", "size": 505, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Binary/Operations/Addition.agda", "max_stars_repo_name": "oisdk/agda-binary", "max_stars_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-03-21T21:30:10.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-21T21:30:10.000Z", "max_issues_repo_path": "Data/Binary/Operations/Addition.agda", "max_issues_repo_name": "oisdk/agda-binary", "max_issues_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Binary/Operations/Addition.agda", "max_forks_repo_name": "oisdk/agda-binary", "max_forks_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.0476190476, "max_line_length": 63, "alphanum_fraction": 0.5564356436, "num_tokens": 283, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278633625322, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.6228043795684082}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Function.Biconditional where\n\nopen import Level\nopen import Relation.Binary\nopen import Path as ≡ using (_;_; cong)\nopen import Function\n\ninfix 4 _↔_\nrecord _↔_ {a b} (A : Type a) (B : Type b) : Type (a ℓ⊔ b) where\n constructor _iff_\n field\n fun : A → B\n inv : B → A\nopen _↔_ public\n\nsym-↔ : (A ↔ B) → (B ↔ A)\nfun (sym-↔ A↔B) = inv A↔B\ninv (sym-↔ A↔B) = fun A↔B\n\nrefl-↔ : A ↔ A\nfun refl-↔ = id\ninv refl-↔ = id\n\ntrans-↔ : A ↔ B → B ↔ C → A ↔ C\nfun (trans-↔ A↔B B↔C) = fun B↔C ∘ fun A↔B\ninv (trans-↔ A↔B B↔C) = inv A↔B ∘ inv B↔C\n", "meta": {"hexsha": "b7d9617eee7dcaa23b3975e3c642041059a564e2", "size": 576, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Function/Biconditional.agda", "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z", "max_issues_repo_path": "agda/Function/Biconditional.agda", "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Function/Biconditional.agda", "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "avg_line_length": 19.8620689655, "max_line_length": 64, "alphanum_fraction": 0.5746527778, "num_tokens": 267, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8824278788223264, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.6228043795578413}} {"text": "module Data.Either.Equiv where\n\nimport Lvl\nopen import Data.Either as Either\nopen import Structure.Function.Domain\nopen import Structure.Function\nopen import Structure.Operator\nopen import Structure.Setoid\nopen import Type\n\nprivate variable ℓ ℓₑ ℓₑ₁ ℓₑ₂ : Lvl.Level\nprivate variable A B : Type{ℓ}\n\nrecord Extensionality ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄ ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ (equiv : Equiv{ℓₑ}(A ‖ B)) : Type{Lvl.of(A) Lvl.⊔ Lvl.of(B) Lvl.⊔ ℓₑ₁ Lvl.⊔ ℓₑ₂ Lvl.⊔ ℓₑ} where\n constructor intro\n private instance _ = equiv\n field\n ⦃ Left-function ⦄ : Function Left\n ⦃ Right-function ⦄ : Function Right\n ⦃ Left-injective ⦄ : Injective Left\n ⦃ Right-injective ⦄ : Injective Right\n Left-Right-inequality : ∀{x : A}{y : B} → (Left x ≢ Right y)\n", "meta": {"hexsha": "b4572dc7b1dcde98cf39b02ae61e0fccc441e7ca", "size": 768, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Either/Equiv.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/Either/Equiv.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Either/Equiv.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.3913043478, "max_line_length": 173, "alphanum_fraction": 0.6875, "num_tokens": 293, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8824278664544912, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.6228043708288085}} {"text": "------------------------------------------------------------------------------\n-- Agda-Prop Library.\n-- Classical Propositional Logic.\n------------------------------------------------------------------------------\n\nopen import Data.Nat using ( ℕ )\n\nmodule Data.PropFormula.Theorems.Classical ( n : ℕ ) where\n\n------------------------------------------------------------------------------\n\nopen import Data.PropFormula.Syntax n\n\n------------------------------------------------------------------------------\n\npostulate\n PEM : ∀ {Γ} {φ}\n → Γ ⊢ φ ∨ ¬ φ\n\n-- Theorem.\nRAA\n : ∀ {Γ} {φ}\n → Γ , ¬ φ ⊢ ⊥\n → Γ ⊢ φ\n\n-- Proof.\nRAA {φ = φ} Γ¬φ⊢⊥ =\n ⊃-elim\n (⊃-intro\n (∨-elim\n (assume φ)\n (⊥-elim φ Γ¬φ⊢⊥)))\n PEM\n-------------------------------------------------------------------------- ∎\n", "meta": {"hexsha": "51a89b8f7bdf5fe1b87a8d702060d5cc43a39772", "size": 811, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/PropFormula/Theorems/Classical.agda", "max_stars_repo_name": "jonaprieto/agda-prop", "max_stars_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 13, "max_stars_repo_stars_event_min_datetime": "2017-05-01T16:45:41.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T03:33:12.000Z", "max_issues_repo_path": "src/Data/PropFormula/Theorems/Classical.agda", "max_issues_repo_name": "jonaprieto/agda-prop", "max_issues_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 18, "max_issues_repo_issues_event_min_datetime": "2017-03-08T14:33:10.000Z", "max_issues_repo_issues_event_max_datetime": "2017-12-18T16:34:21.000Z", "max_forks_repo_path": "src/Data/PropFormula/Theorems/Classical.agda", "max_forks_repo_name": "jonaprieto/agda-prop", "max_forks_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-03-30T16:41:56.000Z", "max_forks_repo_forks_event_max_datetime": "2017-12-01T17:01:25.000Z", "avg_line_length": 23.1714285714, "max_line_length": 78, "alphanum_fraction": 0.2675709001, "num_tokens": 185, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9263037343628703, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.6227833697619582}} {"text": "module Dave.Structures.Definitions where\n open import Dave.Equality public\n\n op₁ : Set → Set\n op₁ A = A → A\n\n op₂ : Set → Set\n op₂ A = A → A → A\n\n associative : {A : Set} → op₂ A → Set\n associative _·_ = ∀ m n p → (m · n) · p ≡ m · (n · p)\n\n commutative : {A : Set} → op₂ A → Set\n commutative _·_ = ∀ m n → m · n ≡ n · m\n\n left-identity : {A : Set} → op₂ A → (e : A) → Set\n left-identity _·_ e = ∀ m → e · m ≡ m\n\n right-identity : {A : Set} → op₂ A → (e : A) → Set\n right-identity _·_ e = ∀ m → m · e ≡ m ", "meta": {"hexsha": "af9e804f95385034508198bd150ed74f0496bccc", "size": 547, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Dave/Structures/Definitions.agda", "max_stars_repo_name": "DavidStahl97/formal-proofs", "max_stars_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Dave/Structures/Definitions.agda", "max_issues_repo_name": "DavidStahl97/formal-proofs", "max_issues_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Dave/Structures/Definitions.agda", "max_forks_repo_name": "DavidStahl97/formal-proofs", "max_forks_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.35, "max_line_length": 57, "alphanum_fraction": 0.4936014625, "num_tokens": 217, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9263037262250327, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.6227833582089803}} {"text": "-- 2010-09-24\n-- example originally stolen from Andrea Vezzosi's post on the Agda list\n\n{-# OPTIONS --no-irrelevant-projections #-}\n\nmodule IrrelevantRecordFields where\n\nopen import Common.Equality\n\nrecord SemiG : Set1 where\n constructor _,_,_,_,_,_\n field\n M : Set\n unit : M\n _+_ : M -> M -> M\n .assoc : ∀ {x y z} -> x + (y + z) ≡ (x + y) + z\n .leftUnit : ∀ {x} -> unit + x ≡ x\n .rightUnit : ∀ {x} -> x + unit ≡ x\n\ndual : SemiG -> SemiG\ndual (M , e , _+_ , assoc , leftUnit , rightUnit) =\n M , e , (λ x y -> y + x) , sym assoc , rightUnit , leftUnit\n\nopen SemiG\n\n-- trivId : ∀ (M : SemiG) -> M ≡ M\n-- trivId M = refl\n\ndual∘dual≡id : ∀ M -> dual (dual M) ≡ M\ndual∘dual≡id M = refl {x = M}\n", "meta": {"hexsha": "c87a8ea7f9c986b9bf4dc6e0e3188342663e2cec", "size": 712, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/IrrelevantRecordFields.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "test/succeed/IrrelevantRecordFields.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/IrrelevantRecordFields.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 22.9677419355, "max_line_length": 72, "alphanum_fraction": 0.5646067416, "num_tokens": 276, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8991213745668094, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.6227692119587848}} {"text": "module Numeral.Finite.Oper.Comparisons where\n\nimport Lvl\nopen import Data.Boolean\nimport Data.Boolean.Operators\nopen Data.Boolean.Operators.Programming\nopen import Functional\nopen import Numeral.Finite\nopen import Numeral.Sign\n\n-- Compare\n_⋚?_ : ∀{a b} → 𝕟(a) → 𝕟(b) → (−|0|+)\n𝟎 ⋚? 𝟎 = 𝟎\n𝟎 ⋚? 𝐒(b) = ➖\n𝐒(a) ⋚? 𝟎 = ➕\n𝐒(a) ⋚? 𝐒(b) = a ⋚? b\n\n-- Equality check\n_≡?_ : ∀{a b} → 𝕟(a) → 𝕟(b) → Bool\n_≡?_ = elim₃ 𝐹 𝑇 𝐹 ∘₂ (_⋚?_)\n\n-- Non-equality check\n_≢?_ : ∀{a b} → 𝕟(a) → 𝕟(b) → Bool\n_≢?_ = elim₃ 𝑇 𝐹 𝑇 ∘₂ (_⋚?_)\n\n-- Lesser-than check\n_?_ : ∀{a b} → 𝕟(a) → 𝕟(b) → Bool\n_>?_ = elim₃ 𝐹 𝐹 𝑇 ∘₂ (_⋚?_)\n\n-- Greater-than or equals check\n_≥?_ : ∀{a b} → 𝕟(a) → 𝕟(b) → Bool\n_≥?_ = elim₃ 𝐹 𝑇 𝑇 ∘₂ (_⋚?_)\n", "meta": {"hexsha": "4bd709efb9d55ffb7d305e7561d897a7530e2f1d", "size": 903, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Finite/Oper/Comparisons.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Finite/Oper/Comparisons.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Finite/Oper/Comparisons.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.0243902439, "max_line_length": 46, "alphanum_fraction": 0.5337763012, "num_tokens": 513, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.894789468908171, "lm_q2_score": 0.6959583187272712, "lm_q1q2_score": 0.6227361743961987}} {"text": "open import Agda.Builtin.Bool\n\nrecord ⊤ : Set where constructor tt\ndata ⊥ : Set where\n\nrecord Σ (A : Set) (B : A → Set) : Set where\n field\n fst : A\n snd : B fst\nopen Σ\n\nT : Bool → Set\nT false = ⊥\nT true = ⊤\n\nFoo : Bool → Set\nFoo false = Bool → Bool\nFoo true = Σ Bool T\n\nfoo : (x : Bool) → Foo x\nfoo false x = x\nfoo true .fst = true\nfoo true .snd = tt\n", "meta": {"hexsha": "c88cebf34793f3be05c14c2f1c38fef23218584a", "size": 367, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue2964b.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue2964b.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue2964b.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 15.2916666667, "max_line_length": 44, "alphanum_fraction": 0.5858310627, "num_tokens": 137, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9032942145139149, "lm_q2_score": 0.6893056295505783, "lm_q1q2_score": 0.6226457872049093}} {"text": "module Data.List.Relation.Quantification.Proofs where\n\nimport Lvl\nopen import Data.List\nopen import Data.List.Functions\nopen import Data.List.Equiv.Id\nopen import Data.List.Relation.Permutation\nopen import Data.List.Relation.Quantification\nopen import Functional\nopen import Logic.Propositional\nopen import Logic\nopen import Structure.Relator.Properties\nopen import Type.Dependent\nopen import Type\n\nprivate variable ℓ : Lvl.Level\nprivate variable T A B C : Type{ℓ}\nprivate variable l l₁ l₂ : List(T)\nprivate variable ll : List(List(T))\nprivate variable x : T\nprivate variable P Q : T → Stmt{ℓ}\nprivate variable Q₂ : A → B → Stmt{ℓ}\nprivate variable _▫_ : T → T → Stmt{ℓ}\n\nAllElements-map : (f : A → B) → (g : A → C) → (∀{x} → P(f(x)) → Q(g(x))) → (AllElements P(map f(l)) → AllElements Q(map g(l)))\nAllElements-map {l = ∅} f g pq ∅ = ∅\nAllElements-map {l = x ⊰ l} f g pq (p ⊰ ap) = pq p ⊰ AllElements-map f g pq ap\n\nAllElements-mapᵣ : (f : A → B) → (∀{x} → P(x) → Q(f(x))) → (AllElements P l → AllElements Q (map f(l)))\nAllElements-mapᵣ = AllElements-map id\n\nAllElements-mapₗ : (f : A → B) → (∀{x} → P(f(x)) → Q(x)) → (AllElements P (map f(l)) → AllElements Q l)\nAllElements-mapₗ f = AllElements-map f id\n\nAllElements-fn : (∀{x} → P(x) → Q(x)) → (AllElements P l → AllElements Q l)\nAllElements-fn = AllElements-map id id\n\nAllElements-[++] : AllElements P l₁ → AllElements P l₂ → AllElements P (l₁ ++ l₂)\nAllElements-[++] {l₁ = ∅} p q = q\nAllElements-[++] {l₁ = _ ⊰ _} (x ⊰ p) q = x ⊰ AllElements-[++] p q\n\nAllElements-concat : (AllElements (AllElements P) l → AllElements P (concat l))\nAllElements-concat ∅ = ∅\nAllElements-concat (p ⊰ pl) = AllElements-[++] p (AllElements-concat pl)\n\nAllElements-concatMap : (f : A → List(B)) → (∀{x} → P(x) → AllElements Q(f(x))) → (AllElements P(l) → AllElements Q(concatMap f(l)))\nAllElements-concatMap f pq ∅ = ∅\nAllElements-concatMap f pq (x ⊰ p) = AllElements-[++] (pq x) (AllElements-concatMap f pq p)\n\nAllElements-order-independent : ∀{P : T → Type{ℓ}}{l₁ l₂} → (l₁ permutes l₂) → (AllElements P(l₁) → AllElements P(l₂))\nAllElements-order-independent _permutes_.empty ∅ = ∅\nAllElements-order-independent (_permutes_.prepend perm) (x ⊰ p) = x ⊰ AllElements-order-independent perm p\nAllElements-order-independent _permutes_.swap (x ⊰ y ⊰ p) = y ⊰ x ⊰ p\nAllElements-order-independent (trans perm₁ perm₂) = AllElements-order-independent perm₂ ∘ AllElements-order-independent perm₁\n\nAllElements-of-transitive-binary-relationₗ : ⦃ trans : Transitivity(_▫_) ⦄ → (l₁ ▫ l₂) → (AllElements (_▫ l₁) ll → AllElements (_▫ l₂) ll)\nAllElements-of-transitive-binary-relationₗ _ ∅ = ∅\nAllElements-of-transitive-binary-relationₗ {_▫_ = _▫_} p (a ⊰ al) = transitivity(_▫_) a p ⊰ AllElements-of-transitive-binary-relationₗ p al\n\nAllElements-of-transitive-binary-relationᵣ : ⦃ trans : Transitivity(_▫_) ⦄ → (l₂ ▫ l₁) → (AllElements (l₁ ▫_) ll → AllElements (l₂ ▫_) ll)\nAllElements-of-transitive-binary-relationᵣ _ ∅ = ∅\nAllElements-of-transitive-binary-relationᵣ {_▫_ = _▫_} p (a ⊰ al) = (transitivity(_▫_) p a) ⊰ AllElements-of-transitive-binary-relationᵣ p al\n\nAllElements-sigma : Σ(List(T)) (AllElements(P)) ↔ List(Σ T P)\nAllElements-sigma = [↔]-intro L R where\n L : Σ(List(T)) (AllElements(P)) ← List(Σ T P)\n L ∅ = intro ∅ ∅\n L ((intro x p) ⊰ sl) =\n let (intro l pl) = L sl\n in intro (x ⊰ l) (p ⊰ pl)\n\n R : Σ(List(T)) (AllElements(P)) → List(Σ T P)\n R (intro ∅ ∅) = ∅\n R (intro (x ⊰ l) (p ⊰ pl)) = intro x p ⊰ R(intro l pl)\n", "meta": {"hexsha": "d023c80feddbba23408f4094d9f4d13944c7b5f4", "size": 3619, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/List/Relation/Quantification/Proofs.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/List/Relation/Quantification/Proofs.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/List/Relation/Quantification/Proofs.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.2533333333, "max_line_length": 143, "alphanum_fraction": 0.6407847472, "num_tokens": 1241, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430478583168, "lm_q2_score": 0.7490872019117029, "lm_q1q2_score": 0.622598620108551}} {"text": "------------------------------------------------------------------------\n-- Small prelude\n------------------------------------------------------------------------\n\nmodule Prelude where\n\ninfixl 6 _+_\ninfixr 5 _∷_ _++_\ninfixr 3 _∨_\ninfix 2 ¬_\n\n------------------------------------------------------------------------\n-- Some \"logic\"\n\ndata ⊥ : Set where\n\n¬_ : Set -> Set\n¬ a = a -> ⊥\n\n------------------------------------------------------------------------\n-- Maybe and Dec\n\ndata Maybe (a : Set) : Set where\n just : a -> Maybe a\n nothing : Maybe a\n\ndata Dec (a : Set) : Set where\n yes : a -> Dec a\n no : ¬ a -> Dec a\n\n------------------------------------------------------------------------\n-- Lists\n\ndata [_] (a : Set) : Set where\n [] : [ a ]\n _∷_ : a -> [ a ] -> [ a ]\n\n_++_ : forall {a} -> [ a ] -> [ a ] -> [ a ]\n[] ++ ys = ys\n(x ∷ xs) ++ ys = x ∷ (xs ++ ys)\n\n------------------------------------------------------------------------\n-- Natural numbers\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ -> ℕ\n\n_+_ : ℕ -> ℕ -> ℕ\nzero + n = n\nsuc m + n = suc (m + n)\n\n{-# BUILTIN NATURAL ℕ #-}\n{-# BUILTIN ZERO zero #-}\n{-# BUILTIN SUC suc #-}\n{-# BUILTIN NATPLUS _+_ #-}\n\n------------------------------------------------------------------------\n-- Booleans\n\ndata Bool : Set where\n true : Bool\n false : Bool\n\n_∨_ : Bool -> Bool -> Bool\ntrue ∨ _ = true\nfalse ∨ b = b\n", "meta": {"hexsha": "852853bb07f57c66a289c7a3f10c0398df7a280b", "size": 1398, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/AIM6/RegExp/talk/Prelude.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T07:26:06.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T07:26:06.000Z", "max_issues_repo_path": "examples/AIM6/RegExp/talk/Prelude.agda", "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/AIM6/RegExp/talk/Prelude.agda", "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.5588235294, "max_line_length": 72, "alphanum_fraction": 0.3061516452, "num_tokens": 359, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772450055544, "lm_q2_score": 0.7122321964553657, "lm_q1q2_score": 0.6225459560819608}} {"text": "------------------------------------------------------------------------------\n-- Agda-Prop Library.\n-- Normal Forms.\n------------------------------------------------------------------------------\n\nopen import Data.Nat using (ℕ)\n\nmodule Data.PropFormula.NormalForms (n : ℕ) where\n\n------------------------------------------------------------------------------\n\nopen import Data.Nat.Base public\nopen import Data.Fin using ( Fin; #_ )\nopen import Data.List using ( List; [_]; []; _++_; _∷_ ; concatMap; map )\n\nopen import Data.PropFormula.Properties n using ( subst )\nopen import Data.PropFormula.Syntax n\nopen import Data.PropFormula.Theorems n\n\nopen import Relation.Nullary using (yes; no)\n\nopen import Function using ( _∘_; _$_ )\nopen import Relation.Binary.PropositionalEquality using ( _≡_; sym )\n\n------------------------------------------------------------------------------\n\ndata Literal : Set where\n Var : Fin n → Literal\n ¬l_ : Literal → Literal\n\nClause : Set\nClause = List Literal\n\n------------------------------------------------------------------------------\n-- Conjunctive Normal Form (CNF)\n------------------------------------------------------------------------------\n\nCnf : Set\nCnf = List Clause\n\nvarCnf_ : Literal → Cnf\nvarCnf l = [ [ l ] ]\n\n_∧Cnf_ : (φ ψ : Cnf) → Cnf\nφ ∧Cnf ψ = φ ++ ψ\n\n_∨Cnf_ : (φ ψ : Cnf) → Cnf\n[] ∨Cnf ψ = ψ\nφ ∨Cnf [] = []\ncls ∨Cnf (x ∷ ψ) = (cls ∨⋆ x) ∧Cnf (cls ∨Cnf ψ)\n where\n _∨⋆_ : Cnf → Clause → Cnf\n xs ∨⋆ ys = concatMap (λ x → [ x ++ ys ]) xs\n\n¬Cnf₀_ : Literal → Literal\n¬Cnf₀ Var x = ¬l Var x\n¬Cnf₀ (¬l lit) = lit\n\n¬Cnf₁ : Clause → Cnf\n¬Cnf₁ [] = [] -- ¬ ⊥ → ⊤\n¬Cnf₁ cls = map (λ lit → [ ¬Cnf₀ lit ]) cls\n\n¬Cnf : Cnf → Cnf\n¬Cnf [] = [ [] ]\n¬Cnf fm = concatMap (λ cl → ¬Cnf₁ cl) fm\n\n_⊃Cnf_ : (φ ψ : Cnf) → Cnf\nφ ⊃Cnf ψ = (¬Cnf φ) ∨Cnf ψ\n\n_⇔Cnf_ : (φ ψ : Cnf) → Cnf\nφ ⇔Cnf ψ = (φ ⊃Cnf ψ) ∧Cnf (ψ ⊃Cnf φ)\n\ntoCnf : PropFormula → Cnf\ntoCnf (Var x) = varCnf Var x\ntoCnf ⊤ = []\ntoCnf ⊥ = [ [] ]\ntoCnf (φ ∧ ψ) = toCnf φ ∧Cnf toCnf ψ\ntoCnf (φ ∨ ψ) = toCnf φ ∨Cnf toCnf ψ\ntoCnf (φ ⊃ ψ) = toCnf φ ⊃Cnf toCnf ψ\ntoCnf (φ ⇔ ψ) = toCnf φ ⇔Cnf toCnf ψ\ntoCnf (¬ φ) = ¬Cnf (toCnf φ)\n\ntoPropLiteral : Literal → PropFormula\ntoPropLiteral (Var x) = Var x\ntoPropLiteral (¬l lit) = ¬ toPropLiteral lit\n\ntoPropClause : Clause → PropFormula\ntoPropClause [] = ⊥\ntoPropClause (l ∷ []) = toPropLiteral l\ntoPropClause (l ∷ ls) = toPropLiteral l ∨ toPropClause ls\n\ntoProp : Cnf → PropFormula\ntoProp [] = ⊤\ntoProp (fm ∷ [] ) = toPropClause fm\ntoProp (fm ∷ fms) = toPropClause fm ∧ toProp fms\n\ncnf : PropFormula → PropFormula\ncnf = toProp ∘ toCnf\n", "meta": {"hexsha": "6498295209ca303935cf6de4b9e15c9d00c448a3", "size": 2623, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/NormalForms.agda", "max_stars_repo_name": "jonaprieto/agda-prop", "max_stars_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 13, "max_stars_repo_stars_event_min_datetime": "2017-05-01T16:45:41.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T03:33:12.000Z", "max_issues_repo_path": "notes/NormalForms.agda", "max_issues_repo_name": "jonaprieto/agda-prop", "max_issues_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 18, "max_issues_repo_issues_event_min_datetime": "2017-03-08T14:33:10.000Z", "max_issues_repo_issues_event_max_datetime": "2017-12-18T16:34:21.000Z", "max_forks_repo_path": "notes/NormalForms.agda", "max_forks_repo_name": "jonaprieto/agda-prop", "max_forks_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-03-30T16:41:56.000Z", "max_forks_repo_forks_event_max_datetime": "2017-12-01T17:01:25.000Z", "avg_line_length": 26.4949494949, "max_line_length": 78, "alphanum_fraction": 0.4979031643, "num_tokens": 912, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772482857833, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.6225459424011047}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Data.Sum.Base where\n\nopen import Cubical.Relation.Nullary\n\nopen import Cubical.Core.Everything\n\nprivate\n variable\n ℓ ℓ' : Level\n A B C D : Type ℓ\n\ndata _⊎_ (A : Type ℓ)(B : Type ℓ') : Type (ℓ-max ℓ ℓ') where\n inl : A → A ⊎ B\n inr : B → A ⊎ B\n\nrec : {C : Type ℓ} → (A → C) → (B → C) → A ⊎ B → C\nrec f _ (inl x) = f x\nrec _ g (inr y) = g y\n\nelim : {C : A ⊎ B → Type ℓ} → ((a : A) → C (inl a)) → ((b : B) → C (inr b))\n → (x : A ⊎ B) → C x\nelim f _ (inl x) = f x\nelim _ g (inr y) = g y\n\nmap : (A → C) → (B → D) → A ⊎ B → C ⊎ D\nmap f _ (inl x) = inl (f x)\nmap _ g (inr y) = inr (g y)\n\n_⊎?_ : {P Q : Type ℓ} → Dec P → Dec Q → Dec (P ⊎ Q)\nP? ⊎? Q? with P? | Q?\n... | yes p | _ = yes (inl p)\n... | no _ | yes q = yes (inr q)\n... | no ¬p | no ¬q = no λ\n { (inl p) → ¬p p\n ; (inr q) → ¬q q\n }\n", "meta": {"hexsha": "33b5fb021693171e147b35fbf486f42d4d35c2f6", "size": 870, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/Sum/Base.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/Sum/Base.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/Data/Sum/Base.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.8947368421, "max_line_length": 76, "alphanum_fraction": 0.4689655172, "num_tokens": 414, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677737461007, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.6225096959564119}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule EnumEquiv where\n\nopen import Data.Empty using (⊥; ⊥-elim)\nopen import Data.Nat using (ℕ; _+_) \nopen import Data.Fin using (Fin; inject+; raise)\nopen import Data.Sum using (_⊎_; inj₁; inj₂)\nopen import Data.Product using (_,_; proj₁; proj₂) \n\nopen import Function using (_∘_)\nopen import Relation.Binary.PropositionalEquality\n using (_≡_; refl; cong; module ≡-Reasoning)\n\nopen import Equiv using (_≃_; trans≃; _⊎≃_; iseq; module isequiv) \nopen import FinEquiv using (Fin0-⊥; module Plus) \n\nopen Plus using (+≃⊎; ⊎≃+)\n\n------------------------------------------------------------------------------\n-- An equivalence between a set 'A' and a finite set 'Fin n' is an\n-- enumeration of A.\n\nEnum : ∀ {ℓ} → (A : Set ℓ) → (n : ℕ) → Set ℓ\nEnum A n = A ≃ Fin n\n\n-- We only need some additive equivalences...\n\n0E : Enum ⊥ 0\n0E = ⊥-elim , iseq Fin0-⊥ (λ { () }) Fin0-⊥ (λ { () })\n\n_⊕e_ : {A : Set} {B : Set} {n m : ℕ} →\n Enum A n → Enum B m → Enum (A ⊎ B) (n + m)\neA ⊕e eB = trans≃ (eA ⊎≃ eB) ⊎≃+\n\n-- shorthand to select the element indexed by i in the enumeration\n\nselect : {A B : Set} (eq : A ≃ B) → (B → A)\nselect (_ , iseq g _ _ _) = g\n\n-- The enumeration of (A ⊎ B) is an enumeration of A followed by an\n-- enumeration of B; in other words if we have an equivalence between\n-- (A ⊎ B) and Fin (m + n) and we are given an index i < m then this\n-- index selects an element of A.\n\n-- evaluating an ⊕e on the left component\n\neval-left : {A B : Set} {m n : ℕ} {eA : Enum A m} {eB : Enum B n} (i : Fin m) →\n select (eA ⊕e eB) (inject+ n i) ≡ inj₁ (select eA i)\neval-left {m = m} {n} {eA} {eB} i =\n let (fwd , iseq bwd _ _ bwd∘fwd~id) = ⊎≃+ {m} {n} in \n begin (\n select (eA ⊕e eB) (inject+ n i)\n ≡⟨ refl ⟩ -- β reduce ⊕e, reverse-β Plus.fwd\n select (trans≃ (eA ⊎≃ eB) ⊎≃+) (fwd (inj₁ i))\n ≡⟨ refl ⟩ -- expand qinv.g and trans≃\n select (eA ⊎≃ eB) (select ⊎≃+ (fwd (inj₁ i)))\n ≡⟨ refl ⟩ -- expand rhs\n select (eA ⊎≃ eB) ((bwd ∘ fwd) (inj₁ i))\n ≡⟨ cong (select (eA ⊎≃ eB)) (bwd∘fwd~id (inj₁ i)) ⟩\n select (eA ⊎≃ eB) (inj₁ i)\n ≡⟨ refl ⟩ -- by definition of path⊎\n inj₁ (select eA i) ∎)\n where open ≡-Reasoning\n\neval-right : {A B : Set} {m n : ℕ} {eA : Enum A m} {eB : Enum B n} →\n (i : Fin n) → select (eA ⊕e eB) (raise m i) ≡ inj₂ (select eB i)\neval-right {eA = eA} {eB} i = \n cong (select (eA ⊎≃ eB)) (isequiv.β (proj₂ ⊎≃+) (inj₂ i))\n\n------------------------------------------------------------------------------\n-- We can also do the same for multiplication but it's not needed\n\n-- _⊛e_ : {A B : Set} {n m : ℕ} → Enum A n → Enum B m → Enum (A × B) (n * m)\n-- eA ⊛e eB = trans≃ (path× eA eB) Times.fwd-iso\n-- \n-- etc.\n\n------------------------------------------------------------------------------\n", "meta": {"hexsha": "8323d65618d1d2702fc86e5b370955d3fd4ee1df", "size": 2776, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Univalence/EnumEquiv.agda", "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_issues_repo_path": "Univalence/EnumEquiv.agda", "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_forks_repo_path": "Univalence/EnumEquiv.agda", "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "avg_line_length": 34.7, "max_line_length": 79, "alphanum_fraction": 0.52629683, "num_tokens": 1067, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199592797929, "lm_q2_score": 0.7431680029241322, "lm_q1q2_score": 0.6224923523473567}} {"text": "\nmodule Data.Integer where\n\nimport Prelude\nimport Data.Nat as Nat\nimport Data.Bool\n\nopen Nat using (Nat; suc; zero)\n renaming ( _+_ to _+'_\n ; _*_ to _*'_\n ; _<_ to _<'_\n ; _-_ to _-'_\n ; _==_ to _=='_\n ; div to div'\n ; mod to mod'\n ; gcd to gcd'\n ; lcm to lcm'\n )\nopen Data.Bool\nopen Prelude\n\ndata Int : Set where\n pos : Nat -> Int\n neg : Nat -> Int -- neg n = -(n + 1)\n\ninfix 40 _==_ _<_ _>_ _≤_ _≥_\ninfixl 60 _+_ _-_\ninfixl 70 _*_\ninfix 90 -_\n\n-_ : Int -> Int\n- pos zero = pos zero\n- pos (suc n) = neg n\n- neg n = pos (suc n)\n\n_+_ : Int -> Int -> Int\npos n + pos m = pos (n +' m)\nneg n + neg m = neg (n +' m +' 1)\npos n + neg m =\n ! m <' n => pos (n -' m -' 1)\n ! otherwise neg (m -' n)\nneg n + pos m = pos m + neg n\n\n_-_ : Int -> Int -> Int\nx - y = x + - y\n\n!_! : Int -> Nat\n! pos n ! = n\n! neg n ! = suc n\n\n_*_ : Int -> Int -> Int\npos 0 * _ = pos 0\n_ * pos 0 = pos 0\npos n * pos m = pos (n *' m)\nneg n * neg m = pos (suc n *' suc m)\npos n * neg m = neg (n *' suc m -' 1)\nneg n * pos m = neg (suc n *' m -' 1)\n\ndiv : Int -> Int -> Int\ndiv _ (pos 0) = pos 0\ndiv (pos n) (pos m) = pos (div' n m)\ndiv (neg n) (neg m) = pos (div' (suc n) (suc m))\ndiv (pos 0) (neg _) = pos 0\ndiv (pos (suc n)) (neg m) = neg (div' n (suc m))\ndiv (neg n) (pos (suc m)) = div (pos (suc n)) (neg m)\n\nmod : Int -> Int -> Int\nmod _ (pos 0) = pos 0\nmod (pos n) (pos m) = pos (mod' n m)\nmod (neg n) (pos m) = adjust (mod' (suc n) m)\n where\n adjust : Nat -> Int\n adjust 0 = pos 0\n adjust n = pos (m -' n)\nmod n (neg m) = adjust (mod n (pos (suc m)))\n where\n adjust : Int -> Int\n adjust (pos 0) = pos 0\n adjust (neg n) = neg n -- impossible\n adjust x = x + neg m\n\ngcd : Int -> Int -> Int\ngcd a b = pos (gcd' ! a ! ! b !)\n\nlcm : Int -> Int -> Int\nlcm a b = pos (lcm' ! a ! ! b !)\n\n_==_ : Int -> Int -> Bool\npos n == pos m = n ==' m\nneg n == neg m = n ==' m\npos _ == neg _ = false\nneg _ == pos _ = false\n\n_<_ : Int -> Int -> Bool\npos _ < neg _ = false\nneg _ < pos _ = true\npos n < pos m = n <' m\nneg n < neg m = m <' n\n\n_≤_ : Int -> Int -> Bool\nx ≤ y = x == y || x < y\n\n_≥_ = flip _≤_\n_>_ = flip _<_\n\n", "meta": {"hexsha": "eb2c43b839c22d699b035e2512244d762761de52", "size": 2372, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Integer.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Integer.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Integer.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 22.3773584906, "max_line_length": 60, "alphanum_fraction": 0.4468802698, "num_tokens": 910, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9073122113355092, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.6223703168878705}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import lib.Basics\nopen import lib.types.Truncation\nopen import lib.types.Groupoid\nopen import lib.types.PathSet\n\nmodule lib.types.FundamentalGroupoid {i} (A : Type i) where\n\n fundamental-groupoid : Groupoid\n fundamental-groupoid = record\n { El = A\n ; Arr = _=₀_ {A = A}\n ; Arr-level = λ _ _ → Trunc-level\n ; groupoid-struct = record\n { id = idp₀\n ; inv = !₀\n ; comp = _∙₀_\n ; unit-l = ∙₀-unit-l\n ; unit-r = ∙₀-unit-r\n ; assoc = ∙₀-assoc\n ; inv-l = !₀-inv-l\n ; inv-r = !₀-inv-r\n }\n }\n", "meta": {"hexsha": "105f8c2c9617253bab2eb82db3d3e97aa504b00b", "size": 579, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lib/types/FundamentalGroupoid.agda", "max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda", "max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_issues_repo_path": "lib/types/FundamentalGroupoid.agda", "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/types/FundamentalGroupoid.agda", "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.2692307692, "max_line_length": 59, "alphanum_fraction": 0.5699481865, "num_tokens": 189, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9207896802383029, "lm_q2_score": 0.6757646140788307, "lm_q1q2_score": 0.6222370829140067}} {"text": "module PosFunction where\n\ndata Functor : Set1 where\n |Id| : Functor\n |K| : Set -> Functor\n _|+|_ : Functor -> Functor -> Functor\n _|x|_ : Functor -> Functor -> Functor\n\ndata _⊕_ (A B : Set) : Set where\n inl : A -> A ⊕ B\n inr : B -> A ⊕ B\n\ndata _×_ (A B : Set) : Set where\n _,_ : A -> B -> A × B\n\n-- The positivity checker can see that [_] is positive in its second argument.\n[_] : Functor -> Set -> Set\n[ |Id| ] X = X\n[ |K| A ] X = A\n[ F |+| G ] X = [ F ] X ⊕ [ G ] X\n[ F |x| G ] X = [ F ] X × [ G ] X\n\ndata μ_ (F : Functor) : Set where\n <_> : [ F ] (μ F) -> μ F\n", "meta": {"hexsha": "a666ed6cfba836d2b9065ca1c857ae36aa32b917", "size": 579, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/PosFunction.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/PosFunction.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/PosFunction.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 23.16, "max_line_length": 78, "alphanum_fraction": 0.5008635579, "num_tokens": 230, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9399133515091156, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.6221501424122567}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\n\n{- Maybe it is actually easier to prove [sum-subindicator]\n and then derive the other lemma. -}\n\nmodule groups.SumOfSubIndicator where\n\nmodule _ {i} (G : Group i) where\n\n open Group G\n\n abstract\n sum-ident : ∀ {I} (f : Fin I → El)\n → (∀ p p p) f == f b*\n subsum-r-subindicator =\n sum-subindicator G\n (Coprod-rec (λ _ → ident) f ∘ –> p)\n (<– p (inr b*))\n sub-indicator'\n ∙ ap (Coprod-rec (λ _ → ident) f) (<–-inv-r p (inr b*))\n", "meta": {"hexsha": "f3ef87ccb536ebe7b97dd225cc33730f37de4429", "size": 1851, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/groups/SumOfSubIndicator.agda", "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 294, "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_issues_repo_path": "theorems/groups/SumOfSubIndicator.agda", "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 31, "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_forks_repo_path": "theorems/groups/SumOfSubIndicator.agda", "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 50, "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "avg_line_length": 29.380952381, "max_line_length": 72, "alphanum_fraction": 0.4840626688, "num_tokens": 714, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.877476793890012, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.6221478309252098}} {"text": "{-# OPTIONS --cubical --safe --postfix-projections #-}\n\nmodule Data.Fin.Properties where\n\nopen import Prelude\nopen import Data.Fin.Base\nimport Data.Nat.Properties as ℕ\nopen import Data.Nat.Properties using (+-comm)\nopen import Data.Nat\nopen import Function.Injective\nopen import Agda.Builtin.Nat renaming (_<_ to _<ᵇ_)\n\nprivate\n variable\n n m : ℕ\n\nsuc-natfin : Σ[ m ⦂ ℕ ] (m ℕ.< n) → Σ[ m ⦂ ℕ ] (m ℕ.< suc n)\nsuc-natfin (m , p) = suc m , p\n\n\nFin-to-Nat-lt : Fin n → Σ[ m ⦂ ℕ ] (m ℕ.< n)\nFin-to-Nat-lt {n = suc n} f0 = zero , tt\nFin-to-Nat-lt {n = suc n} (fs x) = suc-natfin (Fin-to-Nat-lt x)\n\nFin-from-Nat-lt : ∀ m → m ℕ.< n → Fin n\nFin-from-Nat-lt {n = suc n} zero p = f0\nFin-from-Nat-lt {n = suc n} (suc m) p = fs (Fin-from-Nat-lt m p)\n\nFin-Nat-lt-rightInv : ∀ m → (p : m ℕ.< n) → Fin-to-Nat-lt {n = n} (Fin-from-Nat-lt m p) ≡ (m , p)\nFin-Nat-lt-rightInv {n = suc n} zero p = refl\nFin-Nat-lt-rightInv {n = suc n} (suc m) p = cong (suc-natfin {n = n}) (Fin-Nat-lt-rightInv {n = n} m p)\n\nFin-Nat-lt-leftInv : (x : Fin n) → uncurry Fin-from-Nat-lt (Fin-to-Nat-lt x) ≡ x\nFin-Nat-lt-leftInv {n = suc n} f0 = refl\nFin-Nat-lt-leftInv {n = suc n} (fs x) = cong fs (Fin-Nat-lt-leftInv x)\n\nFin-Nat-lt : Fin n ⇔ Σ[ m ⦂ ℕ ] (m ℕ.< n)\nFin-Nat-lt .fun = Fin-to-Nat-lt\nFin-Nat-lt .inv = uncurry Fin-from-Nat-lt\nFin-Nat-lt .rightInv = uncurry Fin-Nat-lt-rightInv\nFin-Nat-lt .leftInv = Fin-Nat-lt-leftInv\n\n\nFinToℕ : Fin n → ℕ\nFinToℕ {n = suc n} f0 = zero\nFinToℕ {n = suc n} (fs x) = suc (FinToℕ x)\n\nFinToℕ-injective : ∀ {k} {m n : Fin k} → FinToℕ m ≡ FinToℕ n → m ≡ n\nFinToℕ-injective {suc k} {f0} {f0} _ = refl\nFinToℕ-injective {suc k} {f0} {fs x} p = ⊥-elim (ℕ.znots p)\nFinToℕ-injective {suc k} {fs m} {f0} p = ⊥-elim (ℕ.snotz p)\nFinToℕ-injective {suc k} {fs m} {fs x} p = cong fs (FinToℕ-injective (ℕ.injSuc p))\n\npred : Fin (suc n) → Fin (suc (ℕ.pred n))\npred f0 = f0\npred {n = suc n} (fs m) = m\n\ndiscreteFin : ∀ {k} → Discrete (Fin k)\ndiscreteFin {k = suc _} f0 f0 = yes refl\ndiscreteFin {k = suc _} f0 (fs fk) = no (ℕ.znots ∘ cong FinToℕ)\ndiscreteFin {k = suc _} (fs fj) f0 = no (ℕ.snotz ∘ cong FinToℕ)\ndiscreteFin {k = suc _} (fs fj) (fs fk) =\n ⟦yes cong fs ,no cong (λ { f0 → fk ; (fs x) → x}) ⟧ (discreteFin fj fk)\n\nisSetFin : isSet (Fin n)\nisSetFin = Discrete→isSet discreteFin\n\nFinFromℕ : (n m : ℕ) → T (n <ᵇ m) → Fin m\nFinFromℕ zero (suc m) p = f0\nFinFromℕ (suc n) (suc m) p = fs (FinFromℕ n m p)\n\ninfix 4 _≢ᶠ_ _≡ᶠ_\n_≢ᶠ_ _≡ᶠ_ : Fin n → Fin n → Type _\nn ≢ᶠ m = T (not (discreteFin n m .does))\nn ≡ᶠ m = T (discreteFin n m .does)\n\n_F↣_ : ℕ → ℕ → Type₀\nn F↣ m = Σ[ f ⦂ (Fin n → Fin m) ] ∀ {x y} → x ≢ᶠ y → f x ≢ᶠ f y\n\nshift : (x y : Fin (suc n)) → x ≢ᶠ y → Fin n\nshift f0 (fs y) x≢y = y\nshift {suc _} (fs x) f0 x≢y = f0\nshift {suc _} (fs x) (fs y) x≢y = fs (shift x y x≢y)\n\nshift-inj : ∀ (x y z : Fin (suc n)) x≢y x≢z → y ≢ᶠ z → shift x y x≢y ≢ᶠ shift x z x≢z\nshift-inj f0 (fs y) (fs z) x≢y x≢z x+y≢x+z = x+y≢x+z\nshift-inj {suc _} (fs x) f0 (fs z) x≢y x≢z x+y≢x+z = tt\nshift-inj {suc _} (fs x) (fs y) f0 x≢y x≢z x+y≢x+z = tt\nshift-inj {suc _} (fs x) (fs y) (fs z) x≢y x≢z x+y≢x+z = shift-inj x y z x≢y x≢z x+y≢x+z\n\nshrink : suc n F↣ suc m → n F↣ m\nshrink (f , inj) .fst x = shift (f f0) (f (fs x)) (inj tt)\nshrink (f , inj) .snd p = shift-inj (f f0) (f (fs _)) (f (fs _)) (inj tt) (inj tt) (inj p)\n\n¬plus-inj : ∀ n m → ¬ (suc (n + m) F↣ m)\n¬plus-inj zero zero (f , _) = f f0\n¬plus-inj zero (suc m) inj = ¬plus-inj zero m (shrink inj)\n¬plus-inj (suc n) m (f , p) = ¬plus-inj n m (f ∘ fs , p)\n\ntoFin-inj : (Fin n ↣ Fin m) → n F↣ m\ntoFin-inj f .fst = f .fst\ntoFin-inj (f , inj) .snd {x} {y} x≢ᶠy with discreteFin x y | discreteFin (f x) (f y)\n... | no ¬p | yes p = ¬p (inj _ _ p)\n... | no _ | no _ = tt\n\nn≢sn+m : ∀ n m → Fin n ≢ Fin (suc (n + m))\nn≢sn+m n m n≡m =\n ¬plus-inj m n\n (toFin-inj\n (subst\n (_↣ Fin n)\n (n≡m ; cong (Fin ∘ suc) (+-comm n m))\n refl-↣))\n\nFin-inj : Injective Fin\nFin-inj n m eq with compare n m\n... | equal _ = refl\n... | less n k = ⊥-elim (n≢sn+m n k eq)\n... | greater m k = ⊥-elim (n≢sn+m m k (sym eq))\n", "meta": {"hexsha": "1de8ae5e9502f474d75aa8a0193760375f9fd681", "size": 4170, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Data/Fin/Properties.agda", "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z", "max_issues_repo_path": "agda/Data/Fin/Properties.agda", "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Data/Fin/Properties.agda", "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "avg_line_length": 34.75, "max_line_length": 103, "alphanum_fraction": 0.5544364508, "num_tokens": 1992, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031738010682209, "lm_q2_score": 0.7745833841649232, "lm_q1q2_score": 0.6221250809040274}} {"text": "{-# OPTIONS --without-K --exact-split #-}\n\nmodule rings-with-properties where\n\nimport rings\nopen rings public\n\n--------------------------------------------------------------------------------\n\n{- Commutative rings -}\n\nis-commutative-Ring :\n { l : Level} → Ring l → UU l\nis-commutative-Ring R =\n (x y : type-Ring R) → Id (mul-Ring R x y) (mul-Ring R y x)\n\nis-prop-is-commutative-Ring :\n { l : Level} (R : Ring l) → is-prop (is-commutative-Ring R)\nis-prop-is-commutative-Ring R =\n is-prop-Π\n ( λ x →\n is-prop-Π\n ( λ y →\n is-set-type-Ring R (mul-Ring R x y) (mul-Ring R y x)))\n\nComm-Ring :\n ( l : Level) → UU (lsuc l)\nComm-Ring l = Σ (Ring l) is-commutative-Ring\n\nring-Comm-Ring :\n { l : Level} → Comm-Ring l → Ring l\nring-Comm-Ring = pr1\n\nis-commutative-Comm-Ring :\n { l : Level} (R : Comm-Ring l) → is-commutative-Ring (ring-Comm-Ring R)\nis-commutative-Comm-Ring = pr2\n\nhom-Comm-Ring :\n { l1 l2 : Level} → Comm-Ring l1 → Comm-Ring l2 → UU (l1 ⊔ l2)\nhom-Comm-Ring R1 R2 = hom-Ring (ring-Comm-Ring R1) (ring-Comm-Ring R2)\n\niso-Comm-Ring :\n { l1 l2 : Level} → Comm-Ring l1 → Comm-Ring l2 → UU (l1 ⊔ l2)\niso-Comm-Ring R1 R2 = iso-Ring (ring-Comm-Ring R1) (ring-Comm-Ring R2)\n\nis-contr-total-iso-Comm-Ring :\n { l1 : Level} (R1 : Comm-Ring l1) →\n is-contr (Σ (Comm-Ring l1) (iso-Comm-Ring R1))\nis-contr-total-iso-Comm-Ring R1 =\n is-contr-total-Eq-substructure\n ( is-contr-total-iso-Ring (ring-Comm-Ring R1))\n ( is-prop-is-commutative-Ring)\n ( ring-Comm-Ring R1)\n ( id-iso-Ring (ring-Comm-Ring R1))\n ( is-commutative-Comm-Ring R1)\n\n--------------------------------------------------------------------------------\n\n{- Division rings -}\n\nzero-neq-one-Ring :\n { l : Level} → Ring l → UU l\nzero-neq-one-Ring R = ¬ (Id (zero-Ring R) (unit-Ring R))\n\nhas-left-inverse-Ring :\n { l : Level} (R : Ring l) → type-Ring R → UU l\nhas-left-inverse-Ring R x =\n Σ (type-Ring R) (λ y → Id (mul-Ring R y x) (unit-Ring R))\n\nhas-right-inverse-Ring :\n {l : Level} (R : Ring l) → type-Ring R → UU l\nhas-right-inverse-Ring R x =\n Σ (type-Ring R) (λ y → Id (mul-Ring R x y) (unit-Ring R))\n\nhas-two-sided-inverse-Ring :\n {l : Level} (R : Ring l) → type-Ring R → UU l\nhas-two-sided-inverse-Ring R x =\n ( has-left-inverse-Ring R x) × (has-right-inverse-Ring R x)\n \nis-invertible-Ring :\n {l : Level} (R : Ring l) → type-Ring R → UU l\nis-invertible-Ring R x =\n Σ ( type-Ring R)\n ( λ y →\n Id (mul-Ring R y x) (unit-Ring R) ×\n Id (mul-Ring R x y) (unit-Ring R))\n\nis-division-Ring :\n { l : Level} → Ring l → UU l\nis-division-Ring R =\n (zero-neq-one-Ring R) ×\n ((x : type-Ring R) → ¬ (Id (zero-Ring R) x) → is-invertible-Ring R x)\n\n--------------------------------------------------------------------------------\n\n{- Fields -}\n\nis-field-Comm-Ring :\n { l : Level} → Comm-Ring l → UU l\nis-field-Comm-Ring R = is-division-Ring (ring-Comm-Ring R)\n", "meta": {"hexsha": "3face78a0305a7c727a5716fa9ce9138d3be8be3", "size": 2875, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/rings-with-properties.agda", "max_stars_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_stars_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 333, "max_stars_repo_stars_event_min_datetime": "2018-09-26T08:33:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:50:15.000Z", "max_issues_repo_path": "Agda/rings-with-properties.agda", "max_issues_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_issues_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2019-06-18T04:16:04.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-16T15:27:01.000Z", "max_forks_repo_path": "Agda/rings-with-properties.agda", "max_forks_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_forks_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 30, "max_forks_repo_forks_event_min_datetime": "2018-09-26T09:08:57.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-16T00:33:50.000Z", "avg_line_length": 28.4653465347, "max_line_length": 80, "alphanum_fraction": 0.5593043478, "num_tokens": 1024, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951104066293, "lm_q2_score": 0.7371581568543043, "lm_q1q2_score": 0.6220841641657106}} {"text": "module Cats.Category.Constructions.Initial where\n\nopen import Data.Product using (proj₁ ; proj₂)\nopen import Level\n\nopen import Cats.Category.Base\n\nimport Cats.Category.Constructions.Iso as Iso\nimport Cats.Category.Constructions.Unique as Unique\n\n\nmodule Build {lo la l≈} (Cat : Category lo la l≈) where\n\n open Category Cat\n open Iso.Build Cat\n open Unique.Build Cat\n\n\n IsInitial : Obj → Set (lo ⊔ la ⊔ l≈)\n IsInitial Zero = ∀ X → ∃! Zero X\n\n\n initial→id-unique : ∀ {A} → IsInitial A → IsUnique (id {A})\n initial→id-unique {A} init id′ with init A\n ... | ∃!-intro id″ _ id″-uniq = ≈.trans (≈.sym (id″-uniq _)) (id″-uniq _)\n\n\n initial-unique : ∀ {A B} → IsInitial A → IsInitial B → A ≅ B\n initial-unique {A} {B} A-init B-init = record\n { forth = ∃!′.arr (A-init B)\n ; back = ∃!′.arr (B-init A)\n ; back-forth = ≈.sym (initial→id-unique A-init _)\n ; forth-back = ≈.sym (initial→id-unique B-init _)\n }\n\n\n Initial⇒X-unique : ∀ {Zero} → IsInitial Zero → ∀ {X} {f g : Zero ⇒ X} → f ≈ g\n Initial⇒X-unique init {X} {f} {g} with init X\n ... | ∃!-intro x _ x-uniq = ≈.trans (≈.sym (x-uniq _)) (x-uniq _)\n\n\nrecord HasInitial {lo la l≈} (Cat : Category lo la l≈)\n : Set (lo ⊔ la ⊔ l≈) where\n open Category Cat\n open Build Cat\n\n field\n Zero : Obj\n isInitial : IsInitial Zero\n", "meta": {"hexsha": "0a152a9463ec2f2d73b87cb00a4ac2f8c47c86c8", "size": 1309, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Category/Constructions/Initial.agda", "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cats/Category/Constructions/Initial.agda", "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cats/Category/Constructions/Initial.agda", "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.18, "max_line_length": 79, "alphanum_fraction": 0.6165011459, "num_tokens": 464, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9111797003640646, "lm_q2_score": 0.6825737279551493, "lm_q1q2_score": 0.6219473249145554}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Tables, basic types and operations\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Table.Base where\n\nopen import Data.Nat\nopen import Data.Fin\nopen import Data.Product using (_×_ ; _,_)\nopen import Data.List as List using (List)\nopen import Data.Vec as Vec using (Vec)\nopen import Function using (_∘_; flip)\n\n------------------------------------------------------------------------\n-- Type\n\nrecord Table {a} (A : Set a) n : Set a where\n constructor tabulate\n field lookup : Fin n → A\nopen Table public\n\n------------------------------------------------------------------------\n-- Basic operations\n\nmodule _ {a} {A : Set a} where\n\n head : ∀ {n} → Table A (suc n) → A\n head t = lookup t zero\n\n tail : ∀ {n} → Table A (suc n) → Table A n\n tail t = tabulate (lookup t ∘ suc)\n\n uncons : ∀ {n} → Table A (suc n) → A × Table A n\n uncons t = head t , tail t\n\n remove : ∀ {n} → Fin (suc n) → Table A (suc n) → Table A n\n remove i t = tabulate (lookup t ∘ punchIn i)\n\n------------------------------------------------------------------------\n-- Operations for transforming tables\n\nmodule _ {a} {A : Set a} where\n\n rearrange : ∀ {m n} → (Fin m → Fin n) → Table A n → Table A m\n rearrange f t = tabulate (lookup t ∘ f)\n\nmodule _ {a b} {A : Set a} {B : Set b} where\n\n map : ∀ {n} → (A → B) → Table A n → Table B n\n map f t = tabulate (f ∘ lookup t)\n\n _⊛_ : ∀ {n} → Table (A → B) n → Table A n → Table B n\n fs ⊛ xs = tabulate λ i → lookup fs i (lookup xs i)\n\n------------------------------------------------------------------------\n-- Operations for reducing tables\n\nmodule _ {a b} {A : Set a} {B : Set b} where\n\n foldr : ∀ {n} → (A → B → B) → B → Table A n → B\n foldr {n = zero} f z t = z\n foldr {n = suc n} f z t = f (head t) (foldr f z (tail t))\n\n foldl : ∀ {n} → (B → A → B) → B → Table A n → B\n foldl {n = zero} f z t = z\n foldl {n = suc n} f z t = foldl f (f z (head t)) (tail t)\n\n------------------------------------------------------------------------\n-- Operations for building tables\n\nmodule _ {a} {A : Set a} where\n\n replicate : ∀ {n} → A → Table A n\n replicate x = tabulate (λ _ → x)\n\n------------------------------------------------------------------------\n-- Operations for converting tables\n\nmodule _ {a} {A : Set a} where\n\n toList : ∀ {n} → Table A n → List A\n toList = List.tabulate ∘ lookup\n\n fromList : ∀ (xs : List A) → Table A (List.length xs)\n fromList = tabulate ∘ List.lookup\n\n fromVec : ∀ {n} → Vec A n → Table A n\n fromVec = tabulate ∘ Vec.lookup\n\n toVec : ∀ {n} → Table A n → Vec A n\n toVec = Vec.tabulate ∘ lookup\n", "meta": {"hexsha": "1e4eec31ec7a6fe62b67ceea11a122db3bf3dba3", "size": 2742, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Table/Base.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Table/Base.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Table/Base.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.5625, "max_line_length": 72, "alphanum_fraction": 0.4631655726, "num_tokens": 791, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744761936437, "lm_q2_score": 0.7606506472514406, "lm_q1q2_score": 0.6218885544929525}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Lists where at least one element satisfies a given property\n------------------------------------------------------------------------\n\nmodule Data.List.Any where\n\nopen import Data.Empty\nopen import Data.Fin\nopen import Function\nopen import Function.Equality using (_⟨$⟩_)\nopen import Function.Equivalence as Equiv using (module Equivalence)\nopen import Function.Related as Related hiding (_∼[_]_)\nopen import Data.List as List using (List; []; _∷_)\nopen import Data.Product as Prod using (∃; _×_; _,_)\nopen import Level using (Level; _⊔_)\nopen import Relation.Nullary\nimport Relation.Nullary.Decidable as Dec\nopen import Relation.Unary using (Decidable) renaming (_⊆_ to _⋐_)\nopen import Relation.Binary hiding (Decidable)\nimport Relation.Binary.InducedPreorders as Ind\nopen import Relation.Binary.List.Pointwise as ListEq using ([]; _∷_)\nopen import Relation.Binary.PropositionalEquality as PropEq\n using (_≡_)\n\n-- Any P xs means that at least one element in xs satisfies P.\n\ndata Any {a p} {A : Set a}\n (P : A → Set p) : List A → Set (a ⊔ p) where\n here : ∀ {x xs} (px : P x) → Any P (x ∷ xs)\n there : ∀ {x xs} (pxs : Any P xs) → Any P (x ∷ xs)\n\n-- Map.\n\nmap : ∀ {a p q} {A : Set a} {P : A → Set p} → {Q : A → Set q} →\n P ⋐ Q → Any P ⋐ Any Q\nmap g (here px) = here (g px)\nmap g (there pxs) = there (map g pxs)\n\n-- If the head does not satisfy the predicate, then the tail will.\n\ntail : ∀ {a p} {A : Set a} {x : A} {xs : List A} {P : A → Set p} →\n ¬ P x → Any P (x ∷ xs) → Any P xs\ntail ¬px (here px) = ⊥-elim (¬px px)\ntail ¬px (there pxs) = pxs\n\n-- Decides Any.\n\nany : ∀ {a p} {A : Set a} {P : A → Set p} →\n Decidable P → Decidable (Any P)\nany p [] = no λ()\nany p (x ∷ xs) with p x\nany p (x ∷ xs) | yes px = yes (here px)\nany p (x ∷ xs) | no ¬px = Dec.map′ there (tail ¬px) (any p xs)\n\n-- index x∈xs is the list position (zero-based) which x∈xs points to.\n\nindex : ∀ {a p} {A : Set a} {P : A → Set p} {xs} →\n Any P xs → Fin (List.length xs)\nindex (here px) = zero\nindex (there pxs) = suc (index pxs)\n\n------------------------------------------------------------------------\n-- List membership and some related definitions\n\nmodule Membership {c ℓ : Level} (S : Setoid c ℓ) where\n\n private\n open module S = Setoid S using (_≈_) renaming (Carrier to A)\n open module LS = Setoid (ListEq.setoid S)\n using () renaming (_≈_ to _≋_)\n\n -- If a predicate P respects the underlying equality then Any P\n -- respects the list equality.\n\n lift-resp : ∀ {p} {P : A → Set p} →\n P Respects _≈_ → Any P Respects _≋_\n lift-resp resp [] ()\n lift-resp resp (x≈y ∷ xs≈ys) (here px) = here (resp x≈y px)\n lift-resp resp (x≈y ∷ xs≈ys) (there pxs) =\n there (lift-resp resp xs≈ys pxs)\n\n -- List membership.\n\n infix 4 _∈_ _∉_\n\n _∈_ : A → List A → Set _\n x ∈ xs = Any (_≈_ x) xs\n\n _∉_ : A → List A → Set _\n x ∉ xs = ¬ x ∈ xs\n\n -- Subsets.\n\n infix 4 _⊆_ _⊈_\n\n _⊆_ : List A → List A → Set _\n xs ⊆ ys = ∀ {x} → x ∈ xs → x ∈ ys\n\n _⊈_ : List A → List A → Set _\n xs ⊈ ys = ¬ xs ⊆ ys\n\n -- Equality is respected by the predicate which is used to define\n -- _∈_.\n\n ∈-resp-≈ : ∀ {x} → (_≈_ x) Respects _≈_\n ∈-resp-≈ = flip S.trans\n\n -- List equality is respected by _∈_.\n\n ∈-resp-list-≈ : ∀ {x} → _∈_ x Respects _≋_\n ∈-resp-list-≈ = lift-resp ∈-resp-≈\n\n -- _⊆_ is a preorder.\n\n ⊆-preorder : Preorder _ _ _\n ⊆-preorder = Ind.InducedPreorder₂ (ListEq.setoid S) _∈_ ∈-resp-list-≈\n\n module ⊆-Reasoning where\n import Relation.Binary.PreorderReasoning as PreR\n open PreR ⊆-preorder public\n renaming (_∼⟨_⟩_ to _⊆⟨_⟩_)\n\n infix 1 _∈⟨_⟩_\n\n _∈⟨_⟩_ : ∀ x {xs ys} → x ∈ xs → xs IsRelatedTo ys → x ∈ ys\n x ∈⟨ x∈xs ⟩ xs⊆ys = (begin xs⊆ys) x∈xs\n\n -- A variant of List.map.\n\n map-with-∈ : ∀ {b} {B : Set b}\n (xs : List A) → (∀ {x} → x ∈ xs → B) → List B\n map-with-∈ [] f = []\n map-with-∈ (x ∷ xs) f = f (here S.refl) ∷ map-with-∈ xs (f ∘ there)\n\n -- Finds an element satisfying the predicate.\n\n find : ∀ {p} {P : A → Set p} {xs} →\n Any P xs → ∃ λ x → x ∈ xs × P x\n find (here px) = (_ , here S.refl , px)\n find (there pxs) = Prod.map id (Prod.map there id) (find pxs)\n\n lose : ∀ {p} {P : A → Set p} {x xs} →\n P Respects _≈_ → x ∈ xs → P x → Any P xs\n lose resp x∈xs px = map (flip resp px) x∈xs\n\n-- The code above instantiated (and slightly changed) for\n-- propositional equality, along with some additional definitions.\n\nmodule Membership-≡ where\n\n private\n open module M {a} {A : Set a} = Membership (PropEq.setoid A) public\n hiding (lift-resp; lose; ⊆-preorder; module ⊆-Reasoning)\n\n lose : ∀ {a p} {A : Set a} {P : A → Set p} {x xs} →\n x ∈ xs → P x → Any P xs\n lose {P = P} = M.lose (PropEq.subst P)\n\n -- _⊆_ is a preorder.\n\n ⊆-preorder : ∀ {a} → Set a → Preorder _ _ _\n ⊆-preorder A = Ind.InducedPreorder₂ (PropEq.setoid (List A)) _∈_\n (PropEq.subst (_∈_ _))\n\n -- Set and bag equality and related preorders.\n\n open Related public\n using (Kind; Symmetric-kind)\n renaming ( implication to subset\n ; reverse-implication to superset\n ; equivalence to set\n ; injection to subbag\n ; reverse-injection to superbag\n ; bijection to bag\n )\n\n [_]-Order : Kind → ∀ {a} → Set a → Preorder _ _ _\n [ k ]-Order A = Related.InducedPreorder₂ k (_∈_ {A = A})\n\n [_]-Equality : Symmetric-kind → ∀ {a} → Set a → Setoid _ _\n [ k ]-Equality A = Related.InducedEquivalence₂ k (_∈_ {A = A})\n\n infix 4 _∼[_]_\n\n _∼[_]_ : ∀ {a} {A : Set a} → List A → Kind → List A → Set _\n _∼[_]_ {A = A} xs k ys = Preorder._∼_ ([ k ]-Order A) xs ys\n\n -- Bag equality implies the other relations.\n\n bag-=⇒ : ∀ {k a} {A : Set a} {xs ys : List A} →\n xs ∼[ bag ] ys → xs ∼[ k ] ys\n bag-=⇒ xs≈ys = ↔⇒ xs≈ys\n\n -- \"Equational\" reasoning for _⊆_.\n\n module ⊆-Reasoning where\n import Relation.Binary.PreorderReasoning as PreR\n private\n open module PR {a} {A : Set a} = PreR (⊆-preorder A) public\n renaming (_∼⟨_⟩_ to _⊆⟨_⟩_; _≈⟨_⟩_ to _≡⟨_⟩_)\n\n infixr 2 _∼⟨_⟩_\n infix 1 _∈⟨_⟩_\n\n _∈⟨_⟩_ : ∀ {a} {A : Set a} x {xs ys : List A} →\n x ∈ xs → xs IsRelatedTo ys → x ∈ ys\n x ∈⟨ x∈xs ⟩ xs⊆ys = (begin xs⊆ys) x∈xs\n\n _∼⟨_⟩_ : ∀ {k a} {A : Set a} xs {ys zs : List A} →\n xs ∼[ ⌊ k ⌋→ ] ys → ys IsRelatedTo zs → xs IsRelatedTo zs\n xs ∼⟨ xs≈ys ⟩ ys≈zs = xs ⊆⟨ ⇒→ xs≈ys ⟩ ys≈zs\n\n------------------------------------------------------------------------\n-- Another function\n\n-- If any element satisfies P, then P is satisfied.\n\nsatisfied : ∀ {a p} {A : Set a} {P : A → Set p} {xs} →\n Any P xs → ∃ P\nsatisfied = Prod.map id Prod.proj₂ ∘ Membership-≡.find\n", "meta": {"hexsha": "89a0255c3bf8075bcc8b74931042744c7f3d602e", "size": 6905, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/List/Any.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/List/Any.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Data/List/Any.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.9641255605, "max_line_length": 72, "alphanum_fraction": 0.5429398986, "num_tokens": 2476, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321889812553, "lm_q2_score": 0.7718435030872968, "lm_q1q2_score": 0.6218219709431791}} {"text": "{-\n\nDefinition of finite sets\n\nThere are may different formulations of finite sets in constructive mathematics,\nand we will use Bishop finiteness as is usually called in the literature.\n\n-}\n{-# OPTIONS --safe #-}\n\nmodule Cubical.Data.FinSet.Base where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Structure\nopen import Cubical.Foundations.Equiv renaming (_∙ₑ_ to _⋆_)\nopen import Cubical.Foundations.Univalence\n\nopen import Cubical.HITs.PropositionalTruncation as Prop\n\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Fin renaming (Fin to Finℕ) hiding (isSetFin)\nopen import Cubical.Data.SumFin\nopen import Cubical.Data.Sigma\n\nprivate\n variable\n ℓ ℓ' ℓ'' : Level\n A : Type ℓ\n\n-- definition of (Bishop) finite sets\n\n-- this definition makes cardinality computation more efficient\nisFinSet : Type ℓ → Type ℓ\nisFinSet A = Σ[ n ∈ ℕ ] ∥ A ≃ Fin n ∥\n\nisFinOrd : Type ℓ → Type ℓ\nisFinOrd A = Σ[ n ∈ ℕ ] A ≃ Fin n\n\nisFinOrd→isFinSet : isFinOrd A → isFinSet A\nisFinOrd→isFinSet (_ , p) = _ , ∣ p ∣\n\n-- finite sets are sets\n\nisFinSet→isSet : isFinSet A → isSet A\nisFinSet→isSet p = rec isPropIsSet (λ e → isOfHLevelRespectEquiv 2 (invEquiv e) isSetFin) (p .snd)\n\n-- isFinSet is proposition\n\nisPropIsFinSet : isProp (isFinSet A)\nisPropIsFinSet p q = Σ≡PropEquiv (λ _ → isPropPropTrunc) .fst (\n Prop.elim2\n (λ _ _ → isSetℕ _ _)\n (λ p q → Fin-inj _ _ (ua (invEquiv (SumFin≃Fin _) ⋆ (invEquiv p) ⋆ q ⋆ SumFin≃Fin _)))\n (p .snd) (q .snd))\n\n-- isFinOrd is Set\n-- ordering can be seen as extra structures over finite sets\n\nisSetIsFinOrd : isSet (isFinOrd A)\nisSetIsFinOrd = isOfHLevelΣ 2 isSetℕ (λ _ → isOfHLevel⁺≃ᵣ 1 isSetFin)\n\n-- alternative definition of isFinSet\n\nisFinSet' : Type ℓ → Type ℓ\nisFinSet' A = ∥ Σ[ n ∈ ℕ ] A ≃ Fin n ∥\n\nisFinSet→isFinSet' : isFinSet A → isFinSet' A\nisFinSet→isFinSet' (_ , p) = Prop.rec isPropPropTrunc (λ p → ∣ _ , p ∣) p\n\nisFinSet'→isFinSet : isFinSet' A → isFinSet A\nisFinSet'→isFinSet = Prop.rec isPropIsFinSet (λ (n , p) → _ , ∣ p ∣ )\n\nisFinSet≡isFinSet' : isFinSet A ≡ isFinSet' A\nisFinSet≡isFinSet' = hPropExt isPropIsFinSet isPropPropTrunc isFinSet→isFinSet' isFinSet'→isFinSet\n\n-- the type of finite sets/propositions\n\nFinSet : (ℓ : Level) → Type (ℓ-suc ℓ)\nFinSet ℓ = TypeWithStr _ isFinSet\n\nFinProp : (ℓ : Level) → Type (ℓ-suc ℓ)\nFinProp ℓ = Σ[ P ∈ FinSet ℓ ] isProp (P .fst)\n\n-- cardinality of finite sets\n\ncard : FinSet ℓ → ℕ\ncard X = X .snd .fst\n\n-- equality between finite sets/propositions\n\nFinSet≡ : (X Y : FinSet ℓ) → (X .fst ≡ Y .fst) ≃ (X ≡ Y)\nFinSet≡ _ _ = Σ≡PropEquiv (λ _ → isPropIsFinSet)\n\nFinProp≡ : (X Y : FinProp ℓ) → (X .fst .fst ≡ Y .fst .fst) ≃ (X ≡ Y)\nFinProp≡ X Y = compEquiv (FinSet≡ (X .fst) (Y .fst)) (Σ≡PropEquiv (λ _ → isPropIsProp))\n\n-- hlevels of FinSet and FinProp\n\nisGroupoidFinSet : isGroupoid (FinSet ℓ)\nisGroupoidFinSet X Y =\n isOfHLevelRespectEquiv 2 (FinSet≡ X Y)\n (isOfHLevel≡ 2 (isFinSet→isSet (X .snd)) (isFinSet→isSet (Y .snd)))\n\nisSetFinProp : isSet (FinProp ℓ)\nisSetFinProp X Y =\n isOfHLevelRespectEquiv 1 (FinProp≡ X Y) (isOfHLevel≡ 1 (X .snd) (Y .snd))\n", "meta": {"hexsha": "40dce365801e2e49423b345687176cc5516096d1", "size": 3118, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/FinSet/Base.agda", "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/FinSet/Base.agda", "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Data/FinSet/Base.agda", "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.8703703704, "max_line_length": 98, "alphanum_fraction": 0.6994868505, "num_tokens": 1190, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321796478255, "lm_q2_score": 0.7718434925908525, "lm_q1q2_score": 0.6218219552829588}} {"text": "open import Agda.Builtin.Coinduction\nopen import Agda.Builtin.Equality\nopen import Agda.Builtin.List\nopen import Agda.Builtin.Nat\n\ninfixr 5 _∷_\n\ndata Stream (A : Set) : Set where\n _∷_ : (x : A) (xs : ∞ (Stream A)) → Stream A\n\nhead : ∀ {A} → Stream A → A\nhead (x ∷ xs) = x\n\ntail : ∀ {A} → Stream A → Stream A\ntail (x ∷ xs) = ♭ xs\n\ntake : ∀ {A} n → Stream A → List A\ntake zero xs = []\ntake (suc n) (x ∷ xs) = x ∷ take n (♭ xs)\n\naccepted : ∀ {A} {n} (xs : Stream A) →\n take (suc n) xs ≡ take (suc n) (head xs ∷ ♯ tail xs)\naccepted (x ∷ xs) = refl\n\nprivate\n rejected : ∀ {A} {n} (xs : Stream A) →\n take (suc n) xs ≡ take (suc n) (head xs ∷ ♯ tail xs)\n rejected (x ∷ xs) = refl\n", "meta": {"hexsha": "febfc6685ecf314ff948dc264dbaec51468e40b7", "size": 707, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue2321.agda", "max_stars_repo_name": "pthariensflame/agda", "max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Succeed/Issue2321.agda", "max_issues_repo_name": "pthariensflame/agda", "max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/Issue2321.agda", "max_forks_repo_name": "pthariensflame/agda", "max_forks_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.3793103448, "max_line_length": 65, "alphanum_fraction": 0.5544554455, "num_tokens": 281, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382094310357, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.6218093496226471}} {"text": "-- Andreas, 2015-02-07\n\n-- {-# OPTIONS -v tc.with:40 #-}\n\nopen import Common.Prelude hiding (not)\n\nnot : Bool → Bool\nnot true = false\nnot false = true\n\nT : Bool → Set → Set\nT true A = A → A\nT false A = Bool\n\ntest : (b : Bool) → (A : Set) → T (not b) A\ntest b with not b\ntest b | true = λ A a → a\ntest b | false = λ A → false\n\n-- should be able to abstract (not b) under Binder (A : Set)\n-- and succeed\n", "meta": {"hexsha": "5e6fd3c1fb48600cd9b220fbb0c47573874653d8", "size": 406, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/WithAbstractUnderBinder.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/WithAbstractUnderBinder.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/WithAbstractUnderBinder.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 18.4545454545, "max_line_length": 60, "alphanum_fraction": 0.5935960591, "num_tokens": 141, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.833324611869563, "lm_q2_score": 0.7461389930307512, "lm_q1q2_score": 0.6217759867680972}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties of the extensional sublist relation over setoid equality.\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary hiding (Decidable)\n\nmodule Data.List.Relation.Binary.Subset.Setoid.Properties where\n\nopen import Data.Bool using (Bool; true; false)\nopen import Data.List\nopen import Data.List.Relation.Unary.Any using (here; there)\nimport Data.List.Membership.Setoid as Membership\nopen import Data.List.Membership.Setoid.Properties\nimport Data.List.Relation.Binary.Subset.Setoid as Sublist\nimport Data.List.Relation.Binary.Equality.Setoid as Equality\nopen import Relation.Nullary using (¬_; yes; no)\nopen import Relation.Unary using (Pred; Decidable)\nimport Relation.Binary.Reasoning.Preorder as PreorderReasoning\n\nopen Setoid using (Carrier)\n\n------------------------------------------------------------------------\n-- Relational properties\n\nmodule _ {a ℓ} (S : Setoid a ℓ) where\n\n open Equality S\n open Sublist S\n open Membership S\n\n ⊆-reflexive : _≋_ ⇒ _⊆_\n ⊆-reflexive xs≋ys = ∈-resp-≋ S xs≋ys\n\n ⊆-refl : Reflexive _⊆_\n ⊆-refl x∈xs = x∈xs\n\n ⊆-trans : Transitive _⊆_\n ⊆-trans xs⊆ys ys⊆zs x∈xs = ys⊆zs (xs⊆ys x∈xs)\n\n ⊆-isPreorder : IsPreorder _≋_ _⊆_\n ⊆-isPreorder = record\n { isEquivalence = ≋-isEquivalence\n ; reflexive = ⊆-reflexive\n ; trans = ⊆-trans\n }\n\n ⊆-preorder : Preorder _ _ _\n ⊆-preorder = record\n { isPreorder = ⊆-isPreorder\n }\n\n -- Reasoning over subsets\n module ⊆-Reasoning where\n open PreorderReasoning ⊆-preorder public\n renaming\n ( _∼⟨_⟩_ to _⊆⟨_⟩_\n ; _≈⟨_⟩_ to _≋⟨_⟩_\n ; _≈˘⟨_⟩_ to _≋˘⟨_⟩_\n ; _≈⟨⟩_ to _≋⟨⟩_\n )\n\n infix 1 _∈⟨_⟩_\n _∈⟨_⟩_ : ∀ x {xs ys} → x ∈ xs → xs IsRelatedTo ys → x ∈ ys\n x ∈⟨ x∈xs ⟩ xs⊆ys = (begin xs⊆ys) x∈xs\n\n------------------------------------------------------------------------\n-- filter\n\nmodule _ {a p ℓ} (S : Setoid a ℓ)\n {P : Pred (Carrier S) p} (P? : Decidable P) where\n\n open Setoid S renaming (Carrier to A)\n open Sublist S\n\n filter⁺ : ∀ xs → filter P? xs ⊆ xs\n filter⁺ [] ()\n filter⁺ (x ∷ xs) y∈f[x∷xs] with P? x\n ... | no _ = there (filter⁺ xs y∈f[x∷xs])\n ... | yes _ with y∈f[x∷xs]\n ... | here y≈x = here y≈x\n ... | there y∈f[xs] = there (filter⁺ xs y∈f[xs])\n", "meta": {"hexsha": "b24c92f8c15cf8aef9312167e7e3baae4a65eafb", "size": 2436, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Subset/Setoid/Properties.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Subset/Setoid/Properties.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Subset/Setoid/Properties.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.3255813953, "max_line_length": 72, "alphanum_fraction": 0.5566502463, "num_tokens": 823, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333246035907933, "lm_q2_score": 0.7461389986757757, "lm_q1q2_score": 0.6217759852951222}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- An inductive definition for the permutation relation\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.List.Relation.Binary.Permutation.Propositional\n {a} {A : Set a} where\n\nopen import Data.List.Base using (List; []; _∷_)\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl)\nimport Relation.Binary.Reasoning.Setoid as EqReasoning\n\n------------------------------------------------------------------------\n-- An inductive definition of permutation\n\n-- Note that one would expect that this would be defined in terms of\n-- `Permutation.Setoid`. This is not currently the case as it involves\n-- adding in a bunch of trivial `_≡_` proofs to the constructors which\n-- a) adds noise and b) prevents easy access to the variables `x`, `y`.\n-- This may be changed in future when a better solution is found.\n\ninfix 3 _↭_\n\ndata _↭_ : Rel (List A) a where\n refl : ∀ {xs} → xs ↭ xs\n prep : ∀ {xs ys} x → xs ↭ ys → x ∷ xs ↭ x ∷ ys\n swap : ∀ {xs ys} x y → xs ↭ ys → x ∷ y ∷ xs ↭ y ∷ x ∷ ys\n trans : ∀ {xs ys zs} → xs ↭ ys → ys ↭ zs → xs ↭ zs\n\n------------------------------------------------------------------------\n-- _↭_ is an equivalence\n\n↭-reflexive : _≡_ ⇒ _↭_\n↭-reflexive refl = refl\n\n↭-refl : Reflexive _↭_\n↭-refl = refl\n\n↭-sym : ∀ {xs ys} → xs ↭ ys → ys ↭ xs\n↭-sym refl = refl\n↭-sym (prep x xs↭ys) = prep x (↭-sym xs↭ys)\n↭-sym (swap x y xs↭ys) = swap y x (↭-sym xs↭ys)\n↭-sym (trans xs↭ys ys↭zs) = trans (↭-sym ys↭zs) (↭-sym xs↭ys)\n\n-- A smart version of trans that avoids unnecessary `refl`s (see #1113).\n↭-trans : Transitive _↭_\n↭-trans refl ρ₂ = ρ₂\n↭-trans ρ₁ refl = ρ₁\n↭-trans ρ₁ ρ₂ = trans ρ₁ ρ₂\n\n↭-isEquivalence : IsEquivalence _↭_\n↭-isEquivalence = record\n { refl = refl\n ; sym = ↭-sym\n ; trans = ↭-trans\n }\n\n↭-setoid : Setoid _ _\n↭-setoid = record\n { isEquivalence = ↭-isEquivalence\n }\n\n------------------------------------------------------------------------\n-- A reasoning API to chain permutation proofs and allow \"zooming in\"\n-- to localised reasoning.\n\nmodule PermutationReasoning where\n\n private\n module Base = EqReasoning ↭-setoid\n\n open EqReasoning ↭-setoid public\n hiding (step-≈; step-≈˘)\n\n infixr 2 step-↭ step-↭˘ step-swap step-prep\n\n step-↭ = Base.step-≈\n step-↭˘ = Base.step-≈˘\n\n -- Skip reasoning on the first element\n step-prep : ∀ x xs {ys zs : List A} → (x ∷ ys) IsRelatedTo zs →\n xs ↭ ys → (x ∷ xs) IsRelatedTo zs\n step-prep x xs rel xs↭ys = relTo (trans (prep x xs↭ys) (begin rel))\n\n -- Skip reasoning about the first two elements\n step-swap : ∀ x y xs {ys zs : List A} → (y ∷ x ∷ ys) IsRelatedTo zs →\n xs ↭ ys → (x ∷ y ∷ xs) IsRelatedTo zs\n step-swap x y xs rel xs↭ys = relTo (trans (swap x y xs↭ys) (begin rel))\n\n syntax step-↭ x y↭z x↭y = x ↭⟨ x↭y ⟩ y↭z\n syntax step-↭˘ x y↭z y↭x = x ↭˘⟨ y↭x ⟩ y↭z\n syntax step-prep x xs y↭z x↭y = x ∷ xs <⟨ x↭y ⟩ y↭z\n syntax step-swap x y xs y↭z x↭y = x ∷ y ∷ xs <<⟨ x↭y ⟩ y↭z\n", "meta": {"hexsha": "b0ae5f6ec63bf37ced67409bf83d1e4faed3681b", "size": 3160, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Permutation/Propositional.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Permutation/Propositional.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Permutation/Propositional.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 32.2448979592, "max_line_length": 73, "alphanum_fraction": 0.5474683544, "num_tokens": 1101, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245787544824, "lm_q2_score": 0.7461389873857265, "lm_q1q2_score": 0.6217759573555066}} {"text": "{-\nThis second-order equational theory was created from the following second-order syntax description:\n\nsyntax STLC | Λ\n\ntype\n N : 0-ary\n _↣_ : 2-ary | r30\n\nterm\n app : α ↣ β α -> β | _$_ l20\n lam : α.β -> α ↣ β | ƛ_ r10\n\ntheory\n (ƛβ) b : α.β a : α |> app (lam(x.b[x]), a) = b[a]\n (ƛη) f : α ↣ β |> lam (x. app(f, x)) = f\n-}\n\nmodule STLC.Equality where\n\nopen import SOAS.Common\nopen import SOAS.Context\nopen import SOAS.Variable\nopen import SOAS.Families.Core\nopen import SOAS.Families.Build\nopen import SOAS.ContextMaps.Inductive\n\nopen import STLC.Signature\nopen import STLC.Syntax\n\nopen import SOAS.Metatheory.SecondOrder.Metasubstitution Λ:Syn\nopen import SOAS.Metatheory.SecondOrder.Equality Λ:Syn\n\nprivate\n variable\n α β γ τ : ΛT\n Γ Δ Π : Ctx\n\ninfix 1 _▹_⊢_≋ₐ_\n\n-- Axioms of equality\ndata _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ Λ) α Γ → (𝔐 ▷ Λ) α Γ → Set where\n ƛβ : ⁅ α ⊩ β ⁆ ⁅ α ⁆̣ ▹ ∅ ⊢ (ƛ 𝔞⟨ x₀ ⟩) $ 𝔟 ≋ₐ 𝔞⟨ 𝔟 ⟩\n ƛη : ⁅ α ↣ β ⁆̣ ▹ ∅ ⊢ ƛ (𝔞 $ x₀) ≋ₐ 𝔞\n\nopen EqLogic _▹_⊢_≋ₐ_\nopen ≋-Reasoning\n", "meta": {"hexsha": "4b46deeed527412324205b2ed3afc2a4d489b881", "size": 1030, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "out/STLC/Equality.agda", "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_issues_repo_path": "out/STLC/Equality.agda", "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_forks_repo_path": "out/STLC/Equality.agda", "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "avg_line_length": 21.4583333333, "max_line_length": 99, "alphanum_fraction": 0.6155339806, "num_tokens": 476, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8652240860523328, "lm_q2_score": 0.7185943925708562, "lm_q1q2_score": 0.6217451765544503}} {"text": "{-# OPTIONS --rewriting --cubical #-}\n\nopen import Common.Prelude\nopen import Common.Path\n\n{-# BUILTIN REWRITE _≡_ #-}\n\npostulate is-refl : ∀ {A : Set} {x : A} → (x ≡ x) → Bool\npostulate is-refl-true : ∀ {A}{x} → is-refl {A} {x} refl ≡ true\n\n{-# REWRITE is-refl-true #-}\n\ntest₁ : ∀ {x} → is-refl {Nat} {x} refl ≡ true\ntest₁ = refl\n\ntest₂ : is-refl {Nat} (λ _ → 42) ≡ true\ntest₂ = refl\n\npostulate\n Cl : Set\n\n\nmodule M (A B C : Set)(f : C -> A)(g : C -> B) where\n data PO : Set where\n inl : A → PO\n inr : B → PO\n push : (c : C) → inl (f c) ≡ inr (g c)\n\n -- elimination under clocks\n module E (D : (Cl → PO) → Set)\n (l : (x : Cl → A) → D (\\ k → inl (x k)))\n (r : (x : Cl → B) → D (\\ k → inr (x k)))\n (p : (x : Cl → C) → PathP (\\ i → D (\\ k → push (x k) i)) (l \\ k → (f (x k))) (r \\ k → (g (x k))))\n where\n\n postulate\n elim : (h : Cl → PO) → D h\n beta1 : (x : Cl → A) → elim (\\ k → inl (x k)) ≡ l x\n beta2 : (x : Cl → B) → elim (\\ k → inr (x k)) ≡ r x\n\n {-# REWRITE beta1 beta2 #-}\n\n _ : {x : Cl → A} → elim (\\ k → inl (x k)) ≡ l x\n _ = refl\n _ : {x : Cl → B} → elim (\\ k → inr (x k)) ≡ r x\n _ = refl\n\n\n postulate\n beta3 : (x : Cl → C)(i : I) → elim (\\ k → push (x k) i) ≡ p x i\n\n {-# REWRITE beta3 #-}\n\n _ : {x : Cl → C}{i : I} → elim (\\ k → push (x k) i) ≡ p x i\n _ = refl\n\n\n-- Testing outside the module too\n\nopen M\nopen E\n\nvariable\n A B C : Set\n f : C → A\n g : C → B\n\n_ : {x : Cl → A} →\n elim A B C f g (\\ h → (k : Cl) → h k ≡ h k) (\\ x k → refl) (\\ _ _ → refl)\n (\\ c i k → refl) (\\ k → inl (x k)) ≡ \\ k → refl\n_ = refl\n\n_ : {c : Cl → C}{i : I} →\n elim A B C f g (\\ h → (k : Cl) → h k ≡ h k) (\\ x k → refl) (\\ _ _ → refl)\n (\\ c i k → refl) (\\ k → push (c k) i) ≡ \\ k → refl\n_ = refl\n", "meta": {"hexsha": "26185a98214adf1184cc698208e6f692dc613a05", "size": 1801, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/HigherOrderPathRewriting.agda", "max_stars_repo_name": "cagix/agda", "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/HigherOrderPathRewriting.agda", "max_issues_repo_name": "cagix/agda", "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/HigherOrderPathRewriting.agda", "max_forks_repo_name": "cagix/agda", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 23.3896103896, "max_line_length": 108, "alphanum_fraction": 0.4297612438, "num_tokens": 757, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8652240756264638, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.6217451742767703}} {"text": "-- Andreas, 2015-11-18, issue 1692 reported by m0davis\n\n-- {-# OPTIONS -v tc.with.top:20 #-}\n\nopen import Common.Level\nopen import Common.Equality\nopen import Common.Product\n\npostulate\n Key : Set\n Value : Key → Set\n anyOf : ∀{A : Set} → A → A → A\n\ndata Tree : Set where\n node : (k : Key) (v : Value k) → Tree\n\ndata _∼_∈_ ( k : Key ) ( v : Value k ) : Tree → Set where\n here : k ∼ v ∈ node k v\n\npostulate\n k₁≡k₂ : ∀ ( k₁ k₂ : Key ) → k₁ ≡ k₂\n ∈→v₁≡v₂ : ∀ { k } { v₁ v₂ : Value k } → k ∼ v₁ ∈ node k v₂ → v₁ ≡ v₂\n\nlem : ( t₁ t₂ : Tree )\n ( t₁→t₂ : ∀ {k} {v : Value k} → k ∼ v ∈ t₁ → k ∼ v ∈ t₂ )\n ( t₂→t₁ : ∀ {k} {v : Value k} → k ∼ v ∈ t₂ → k ∼ v ∈ t₁ ) →\n ∃ λ t → ∀ {k} {v : Value k} → k ∼ v ∈ t → k ∼ v ∈ t\nlem (node k₁ v₁) (node k₂ v₂) t₁→t₂ t₂→t₁ rewrite k₁≡k₂ k₁ k₂\n | ∈→v₁≡v₂ (t₁→t₂ here) -- equivalent to v₂ ≡ v₁\n = _ , anyOf t₁→t₂ t₂→t₁\n\n-- PROBLEM WAS:\n\n-- When the second rewrite expression is commented-out, then we get the following types:\n {-\n t₂→t₁ : {k : Key} {v : Value k} →\n k ∼ v ∈ node k₂ v₂ → k ∼ v ∈ node k₂ v₁\n t₁→t₂ : {k : Key} {v : Value k} →\n k ∼ v ∈ node k₂ v₁ → k ∼ v ∈ node k₂ v₂\n -}\n-- With both rewrite expressions, we get:\n {-\n t₂→t₁ : {k : Key} {v : Value k} →\n k ∼ v ∈ node k₂ v₂ → k ∼ v ∈ node k₂ v₂\n t₁→t₂ : {k : Key} {v : Value k} →\n k ∼ v ∈ node k₂ v₁ → k ∼ v ∈ node k₂ v₂\n -}\n-- The unexpected behavior here is that v₁ has been rewritten to v₂ in t₂→t₁ but not in t₁→t₂.\n\n-- Should be symmetric now, test case passes.\n\n-- Dual case:\n\nlem′ : ( t₁ t₂ : Tree )\n ( t₁→t₂ : ∀ {k} {v : Value k} → k ∼ v ∈ t₁ → k ∼ v ∈ t₂ )\n ( t₂→t₁ : ∀ {k} {v : Value k} → k ∼ v ∈ t₂ → k ∼ v ∈ t₁ ) →\n ∃ λ t → ∀ {k} {v : Value k} → k ∼ v ∈ t → k ∼ v ∈ t\nlem′ (node k₁ v₁) (node k₂ v₂) t₁→t₂ t₂→t₁ rewrite k₁≡k₂ k₁ k₂\n | ∈→v₁≡v₂ (t₂→t₁ here) -- equivalent to v₁ ≡ v₂\n = _ , anyOf t₁→t₂ t₂→t₁\n", "meta": {"hexsha": "7829c769c63f468394011aa0affc71291ea86e2d", "size": 1957, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/Issue1692.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Fail/Issue1692.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Fail/Issue1692.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 32.0819672131, "max_line_length": 94, "alphanum_fraction": 0.4915687276, "num_tokens": 869, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8652240895276223, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.6217451738374826}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\nopen import homotopy.HSpace\nopen import homotopy.EilenbergMacLane1 using (EM₁-level₁)\n\nmodule homotopy.EM1HSpace where\n\nmodule EM₁HSpace {i} (G : AbGroup i) where\n\n private\n module G = AbGroup G\n\n emloop-commutes : (g g' : G.El) → emloop g ∙ emloop g' == emloop g' ∙ emloop g\n emloop-commutes g g' =\n emloop g ∙ emloop g'\n =⟨ ! (emloop-comp' G.grp g g') ⟩\n emloop (G.comp g g')\n =⟨ ap (emloop' G.grp) (G.comm g g') ⟩\n emloop (G.comp g' g)\n =⟨ emloop-comp' G.grp g' g ⟩\n emloop g' ∙ emloop g =∎\n\n mult-loop : G.El → (x : EM₁ G.grp) → x == x\n mult-loop g = EM₁-set-elim\n {P = λ x → x == x}\n {{λ x → has-level-apply (EM₁-level₁ G.grp) x x}}\n (emloop g)\n (λ g' → ↓-idf=idf-in' (emloop-commutes g g' ∙ ∙=∙' (emloop g') (emloop g)))\n\n private\n EM₁-endo-Ω-group : Group i\n EM₁-endo-Ω-group = Ω^S-group 0 ⊙[ (EM₁ G.grp → EM₁ G.grp) , (λ x → x) ]\n\n mult-hom : GroupHom G.grp EM₁-endo-Ω-group\n mult-hom = record {f = λ= ∘ mult-loop; pres-comp = pres-comp}\n where\n abstract\n pres-comp' : (g₁ g₂ : G.El) (x : EM₁ G.grp) →\n mult-loop (G.comp g₁ g₂) x == mult-loop g₁ x ∙ mult-loop g₂ x\n pres-comp' g₁ g₂ =\n EM₁-prop-elim\n {P = λ x → mult-loop (G.comp g₁ g₂) x == mult-loop g₁ x ∙ mult-loop g₂ x}\n {{λ x → has-level-apply (has-level-apply (EM₁-level₁ G.grp) _ _) _ _}}\n (emloop-comp g₁ g₂)\n\n pres-comp : (g₁ g₂ : G.El)\n → λ= (mult-loop (G.comp g₁ g₂)) ==\n Group.comp EM₁-endo-Ω-group (λ= (mult-loop g₁)) (λ= (mult-loop g₂))\n pres-comp g₁ g₂ =\n ap λ= (λ= (pres-comp' g₁ g₂)) ∙\n =ₛ-out (λ=-∙ (mult-loop g₁) (mult-loop g₂))\n\n module MultRec = EM₁Level₁Rec {G = G.grp} {C = EM₁ G.grp → EM₁ G.grp} (λ x → x) mult-hom\n\n abstract\n mult : EM₁ G.grp → EM₁ G.grp → EM₁ G.grp\n mult = MultRec.f\n\n mult-embase-β : mult embase ↦ (λ x → x)\n mult-embase-β = MultRec.embase-β\n {-# REWRITE mult-embase-β #-}\n\n mult-emloop-β : ∀ g y → ap (λ x → mult x y) (emloop g) == mult-loop g y\n mult-emloop-β g y =\n ap (λ x → mult x y) (emloop g)\n =⟨ ap-∘ (λ f → f y) mult (emloop g) ⟩\n app= (ap mult (emloop g)) y\n =⟨ ap (λ w → app= w y) (MultRec.emloop-β g) ⟩\n app= (λ= (mult-loop g)) y\n =⟨ app=-β (mult-loop g) y ⟩\n mult-loop g y =∎\n\n H-⊙EM₁ : HSpaceStructure (⊙EM₁ G.grp)\n H-⊙EM₁ = from-alt-h-space $ record { μ = mult; unit-l = unit-l; unit-r = unit-r; coh = coh }\n where\n unit-l : (x : EM₁ G.grp) → mult embase x == x\n unit-l x = idp\n\n unit-r : (x : EM₁ G.grp) → mult x embase == x\n unit-r = EM₁-set-elim\n {P = λ x → mult x embase == x}\n {{λ x → has-level-apply (EM₁-level₁ G.grp) (mult x embase) x}}\n idp\n (λ g → ↓-app=idf-in $\n idp ∙' emloop g\n =⟨ ∙'-unit-l (emloop g) ⟩\n emloop g\n =⟨ ! (mult-emloop-β g embase) ⟩\n ap (λ z → mult z embase) (emloop g)\n =⟨ ! (∙-unit-r (ap (λ z → mult z embase) (emloop g))) ⟩\n ap (λ z → mult z embase) (emloop g) ∙ idp ∎)\n\n coh : unit-l embase == unit-r embase\n coh = idp\n\n open HSpaceStructure H-⊙EM₁\n", "meta": {"hexsha": "3cfecb41745c606125b68202cabbaf6823e0bc22", "size": 3233, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/homotopy/EM1HSpace.agda", "max_stars_repo_name": "AntoineAllioux/HoTT-Agda", "max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 294, "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_issues_repo_path": "theorems/homotopy/EM1HSpace.agda", "max_issues_repo_name": "AntoineAllioux/HoTT-Agda", "max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 31, "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_forks_repo_path": "theorems/homotopy/EM1HSpace.agda", "max_forks_repo_name": "AntoineAllioux/HoTT-Agda", "max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 50, "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "avg_line_length": 32.9897959184, "max_line_length": 94, "alphanum_fraction": 0.5202598206, "num_tokens": 1260, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094003735664, "lm_q2_score": 0.6959583376458152, "lm_q1q2_score": 0.6217061252873672}} {"text": "{-# OPTIONS --without-K --safe #-}\n\n-- Adjoint Functor Theorem\nmodule Categories.Adjoint.AFT where\n\nopen import Level\nopen import Data.Product\nopen import Data.Product using (Σ)\n\nopen import Categories.Category\nopen import Categories.Category.Complete\nopen import Categories.Category.Complete.Properties\nopen import Categories.Category.Construction.Cones\nopen import Categories.Category.Construction.Comma\nopen import Categories.Functor\nopen import Categories.Functor.Limits\nopen import Categories.Functor.Properties\nopen import Categories.Adjoint\nopen import Categories.Adjoint.Properties\nopen import Categories.Diagram.Limit as Lim\nopen import Categories.Diagram.Cone.Properties\nopen import Categories.Morphism as Mor\nopen import Categories.Morphism.Universal\n\nimport Categories.Adjoint.AFT.SolutionSet as SS\nimport Categories.Morphism.Reasoning as MR\n\nprivate\n variable\n o ℓ e : Level\n C D : Category o ℓ e\n\nmodule _ {R : Functor C D} where\n private\n module C = Category C\n module D = Category D\n module R = Functor R\n\n o-level : Level\n o-level = C.o-level ⊔ C.ℓ-level ⊔ D.ℓ-level ⊔ D.e-level\n\n ℓ-level : Level\n ℓ-level = C.o-level ⊔ C.ℓ-level ⊔ D.ℓ-level ⊔ D.e-level\n\n e-level : Level\n e-level = C.o-level ⊔ C.ℓ-level ⊔ D.ℓ-level ⊔ D.e-level\n\n open SS R using (SolutionSet′)\n\n module _ {L : Functor D C} (L⊣R : L ⊣ R) where\n private\n module L = Functor L\n open Adjoint L⊣R\n\n L⊣R⇒solutionSet′ : SolutionSet′\n L⊣R⇒solutionSet′ = record\n { S₀ = λ {_ X} _ → L.₀ X\n ; S₁ = Radjunct\n ; ϕ = λ _ → unit.η _\n ; commute = λ _ → LRadjunct≈id\n }\n\n module _ (Com : Complete o-level ℓ-level e-level C)\n (Rcon : Continuous o-level ℓ-level e-level R)\n (s : SolutionSet′) where\n open SolutionSet′ s\n open D.Equiv\n open D.HomReasoning\n open MR D\n\n private\n module _ X where\n X↙R : Category (C.o-level ⊔ D.ℓ-level) (C.ℓ-level ⊔ D.e-level) C.e-level\n X↙R = X ↙ R\n module X↙R = Category X↙R\n\n s′ : SolutionSet X↙R \n s′ = record\n { D = D′\n ; arr = arr′\n }\n where D′ : X↙R.Obj → X↙R.Obj\n D′ Z = record\n { f = ϕ Z.f\n }\n where module Z = CommaObj Z\n\n arr′ : ∀ Z → X↙R [ D′ Z , Z ]\n arr′ Z = record\n { h = S₁ Z.f\n ; commute = commute _ ○ ⟺ D.identityʳ\n }\n where module Z = CommaObj Z\n open D.HomReasoning\n\n module _ {J : Category o-level ℓ-level e-level} (F : Functor J X↙R) where\n module J = Category J\n module F = Functor F\n\n F′ : Functor J C\n F′ = Cod _ _ ∘F F\n\n LimF′ : Limit F′\n LimF′ = Com F′\n module LimF′ = Limit LimF′\n\n RLimF′ : Cone (R ∘F F′)\n RLimF′ = F-map-Coneˡ R LimF′.limit\n module RLimF′ = Cone _ RLimF′\n\n LimRF′ : Limit (R ∘F F′)\n LimRF′ = record\n { terminal = record\n { ⊤ = RLimF′\n ; ⊤-is-terminal = Rcon LimF′\n }\n }\n module LimRF′ = Limit LimRF′\n\n coneF : Cone (R ∘F F′)\n coneF = record\n { N = X\n ; apex = record\n { ψ = λ j → CommaObj.f (F.₀ j)\n ; commute = λ f → Comma⇒.commute (F.₁ f) ○ D.identityʳ\n }\n }\n\n ⊤-arr : Cone⇒ (R ∘F F′) coneF RLimF′\n ⊤-arr = LimRF′.rep-cone coneF\n module ⊤-arr = Cone⇒ (R ∘F F′) ⊤-arr\n\n ⊤ : Cone F\n ⊤ = record\n { N = record\n { f = ⊤-arr.arr\n }\n ; apex = record\n { ψ = λ j → record\n { h = LimF′.proj j\n ; commute = begin\n R.₁ (LimF′.proj j) D.∘ ⊤-arr.arr ≈⟨ ⊤-arr.commute ⟩\n CommaObj.f (F.₀ j) ≈˘⟨ D.identityʳ ⟩\n CommaObj.f (F.₀ j) D.∘ D.id ∎\n }\n ; commute = λ f → -, LimF′.limit-commute f\n }\n }\n\n K-conv : Cone F → Cone F′\n K-conv = F-map-Coneˡ (Cod _ _)\n\n K-conv′ : Cone F → Cone (R ∘F F′)\n K-conv′ K = F-map-Coneˡ R (K-conv K)\n\n ! : (K : Cone F) → Cones F [ K , ⊤ ]\n ! K = record\n { arr = record\n { h = LimF′.rep (K-conv K)\n ; commute = ⟺ (LimRF′.terminal.!-unique (record\n { arr = R.₁ (LimF′.rep (K-conv K)) D.∘ CommaObj.f N\n ; commute = λ {j} → begin\n LimRF′.proj j D.∘ R.₁ (LimF′.rep (K-conv K)) D.∘ CommaObj.f N\n ≈⟨ pullˡ ([ R ]-resp-∘ LimF′.commute) ⟩\n R.₁ (Comma⇒.h (ψ j)) D.∘ CommaObj.f N\n ≈⟨ Comma⇒.commute (ψ j) ⟩\n CommaObj.f (F.F₀ j) D.∘ D.id\n ≈⟨ D.identityʳ ⟩\n CommaObj.f (F.₀ j)\n ∎\n })) ○ ⟺ D.identityʳ\n }\n ; commute = -, LimF′.commute\n }\n where open Cone _ K\n\n !-unique : {K : Cone F} (f : Cones F [ K , ⊤ ]) → Cones F [ ! K ≈ f ]\n !-unique f = -, LimF′.terminal.!-unique record\n { arr = Comma⇒.h f.arr\n ; commute = proj₂ f.commute\n }\n where module f = Cone⇒ _ f\n\n complete : Limit F\n complete = record\n { terminal = record\n { ⊤ = ⊤\n ; ⊤-is-terminal = record\n { ! = ! _\n ; !-unique = !-unique\n }\n }\n }\n\n solutionSet′⇒universalMorphism : UniversalMorphism X R\n solutionSet′⇒universalMorphism = record\n { initial = SolutionSet⇒Initial {o′ = 0ℓ} {0ℓ} {0ℓ} {C = X ↙ R} complete s′\n }\n\n solutionSet⇒adjoint : Σ (Functor D C) (λ L → L ⊣ R)\n solutionSet⇒adjoint = universalMophisms⇒adjoint solutionSet′⇒universalMorphism\n", "meta": {"hexsha": "19d378cebdddfb5e5bad83cdfed9f424ddc89b59", "size": 6120, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Adjoint/AFT.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Adjoint/AFT.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Adjoint/AFT.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 30.297029703, "max_line_length": 85, "alphanum_fraction": 0.4709150327, "num_tokens": 1919, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9019206659843132, "lm_q2_score": 0.6893056104028797, "lm_q1q2_score": 0.6216989752012888}} {"text": "{-# OPTIONS --universe-polymorphism #-}\n\nopen import Categories.Category\n\nmodule Categories.Slice {o ℓ e} (C : Category o ℓ e) where\n\nopen Category C\nopen Equiv\n\nopen import Level\nopen import Relation.Binary using (Rel)\n\nrecord SliceObj (X : Obj) : Set (o ⊔ ℓ) where\n constructor sliceobj\n field\n {Y} : Obj\n arr : Y ⇒ X\n\nrecord Slice⇒ {A : Obj} (X Y : SliceObj A) : Set (ℓ ⊔ e) where\n constructor slicearr\n module X = SliceObj X\n module Y = SliceObj Y\n field\n {h} : X.Y ⇒ Y.Y\n .triangle : Y.arr ∘ h ≡ X.arr\n\nslice : Obj → Category _ _ _\nslice x = record \n { Obj = Obj′\n ; _⇒_ = _⇒′_\n ; _≡_ = _≡′_\n ; _∘_ = _∘′_\n ; id = slicearr identityʳ\n ; assoc = λ {_} {_} {_} {_} {f} {g} {h} → assoc′ {f = f} {g} {h}\n ; identityˡ = identityˡ\n ; identityʳ = identityʳ\n ; equiv = record \n { refl = refl\n ; sym = sym\n ; trans = trans\n }\n ; ∘-resp-≡ = λ {_} {_} {_} {f} {h} {g} {i} → ∘-resp-≡′ {f = f} {h} {g} {i}\n }\n where\n Obj′ = SliceObj x\n\n _⇒′_ : Rel Obj′ _\n _⇒′_ = Slice⇒\n\n infixr 9 _∘′_\n infix 4 _≡′_\n\n _≡′_ : ∀ {A B} → Rel (A ⇒′ B) _\n slicearr {f} _ ≡′ slicearr {g} _ = f ≡ g\n\n _∘′_ : ∀ {A B C} → (B ⇒′ C) → (A ⇒′ B) → (A ⇒′ C)\n _∘′_ {sliceobj a⇒x} {sliceobj b⇒x} {sliceobj c⇒x} (slicearr {b⇒c} pf₁) (slicearr {a⇒b} pf₂) = slicearr pf\n where\n .pf : c⇒x ∘ (b⇒c ∘ a⇒b) ≡ a⇒x\n pf = begin\n c⇒x ∘ (b⇒c ∘ a⇒b)\n ↑⟨ assoc ⟩\n (c⇒x ∘ b⇒c) ∘ a⇒b\n ↓⟨ ∘-resp-≡ˡ pf₁ ⟩\n b⇒x ∘ a⇒b\n ↓⟨ pf₂ ⟩\n a⇒x\n ∎\n where \n open HomReasoning\n\n\n .assoc′ : ∀ {A B C D} {f : A ⇒′ B} {g : B ⇒′ C} {h : C ⇒′ D}\n → (h ∘′ g) ∘′ f ≡′ h ∘′ (g ∘′ f)\n assoc′ = assoc\n\n .∘-resp-≡′ : ∀ {A B C} {f h : B ⇒′ C} {g i : A ⇒′ B}\n → f ≡′ h \n → g ≡′ i \n → f ∘′ g ≡′ h ∘′ i\n ∘-resp-≡′ f≡h g≡i = ∘-resp-≡ f≡h g≡i\n", "meta": {"hexsha": "65764aa8f757493c141fa86699cdfda9c8c2ba8f", "size": 1836, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Slice.agda", "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 98, "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_issues_repo_path": "Categories/Slice.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_forks_repo_path": "Categories/Slice.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 23, "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "avg_line_length": 22.3902439024, "max_line_length": 107, "alphanum_fraction": 0.4537037037, "num_tokens": 908, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267118111485244, "lm_q2_score": 0.7520125848754471, "lm_q1q2_score": 0.6216976860488643}} {"text": "import Lvl\n\nmodule Structure.Groupoid {ℓₒ ℓₘ ℓₑ : Lvl.Level} where\n\nopen import Functional using (swap)\nopen import Logic\nopen import Logic.Predicate\nopen import Logic.Propositional\nimport Structure.Categorical.Names as Names\nopen import Structure.Categorical.Properties\nopen import Structure.Category{ℓₒ}{ℓₘ}{ℓₑ}\nopen import Structure.Operator\nopen import Structure.Relator.Equivalence\nimport Structure.Relator.Names as Names\nopen import Structure.Relator.Properties\nopen import Structure.Setoid\nopen import Type\n\n{- TODO: It would be nice if groupoids were defined using a category as a record field and if categories were defined using a semicategory as a record field (they are \"substructures\" of each other) so that no code-duplication is necessary, but the problem is how long the projections/copatterns become with this approach.\npostulate A B C : Type{Lvl.𝟎}\n\nrecord R : Type{Lvl.𝟎} where\n field\n a : A\n b : B\n\nrecord R2 : Type{Lvl.𝟎} where\n field\n r : R\n c : C\n open R(r) public\n -- a = R.a r\n\n-- This is not possible, but would be nice:\nr2 : R2\nR2.a r2 = ?\nR2.b r2 = ?\nR2.c r2 = ?\n\n-- One must write this:\nr2 : R2\nR2.r(R.a r2) = ?\nR2.r(R.b r2) = ?\nR2.c r2 = ?\n\nwhich means that the copatterns would be longer and longer for each nesting a record has.\nIf Agda had support for \"copattern/projection synonyms\" or if the example above worked, then \n-}\n\n-- Obj is the collection of objects.\n-- _⟶_ is the collection of morphisms.\nmodule _\n {Obj : Type{ℓₒ}}\n (_⟶_ : Obj → Obj → Type{ℓₘ})\n ⦃ morphism-equiv : ∀{x y} → Equiv{ℓₑ}(x ⟶ y) ⦄\n where\n\n -- A groupoid is a structure on a relation called a morphism.\n --\n -- It can be seen as a generalization of the structure in invertible functions between a collection of types/sets.\n -- More specifically, the algebraic properties of functions regarding composition and the identity function together with an function inverter.\n -- In this case, sets are objects and functions are morphisms.\n --\n -- It can also be seen as a generalized algebraic structure, or more specifically a generalization of groups.\n -- The type of a group's operator is usually restricted to a single type, but a groupoid allows it to vary (depending on the rules of morphism instead).\n -- (One can loosely call a groupoid to be a group without the \"closed\" property of algebraic structures).\n -- In this case, the binary operation is (_∘_) and the laws are the usual identity, associative and inverse laws.\n --\n -- An alternative interpretation of the definition:\n -- A type (Obj) and a binary relation (Morphism) on this type is a groupoid when:\n -- • The relator is transitive.\n -- • The relator is reflexive.\n -- • The relator is symmetric.\n -- • The reflexivity proof inside the transitivity proof does not result in a new proof.\n -- • Chains of the transitivity proofs can be applied in any order and the resulting proof will be the same.\n -- • Transitivity of a proof of a pair and its symmetry is the reflexivity proof.\n -- In other words, this is a specialized equivalence relation/setoid on `Obj`. If the morphism equivalence is trivial (always true) for a groupoid, then the groupoid describes the same structure as an equivalence relation does.\n -- See `Relator.Equals.Category` for an example of this kind of binary relation.\n --\n -- A groupoid is the common pattern seen in all the examples above.\n record Groupoid : Stmt{ℓₒ Lvl.⊔ ℓₘ Lvl.⊔ ℓₑ} where\n field\n _∘_ : Names.SwappedTransitivity(_⟶_)\n id : Names.Reflexivity(_⟶_)\n inv : Names.Symmetry(_⟶_)\n infixr 20 _∘_\n\n field\n ⦃ binaryOperator ⦄ : ∀{x y z} → BinaryOperator(_∘_ {x}{y}{z})\n ⦃ associativity ⦄ : Morphism.Associativity(\\{x} → _∘_ {x})\n ⦃ identity ⦄ : Morphism.Identity(_∘_)(\\{x} → id{x})\n ⦃ inverter ⦄ : Polymorphism.Inverter(_∘_)(\\{x} → id{x})(inv)\n\n -- This can be interpreted as proof of symmetry when `Morphism` is interpreted as a binary relation.\n morphism-symmetry : Symmetry(_⟶_)\n morphism-symmetry = intro inv\n\n category : Category(_⟶_)\n Category._∘_ category = _∘_\n Category.id category = id\n Category.binaryOperator category = binaryOperator\n Category.associativity category = associativity\n Category.identity category = identity\n\n open Category(category) hiding (_∘_ ; id ; binaryOperator ; associativity ; identity) public\n open Polymorphism.Inverter(_∘_)(\\{x} → id{x})(inv)(inverter) renaming (left to inverterₗ ; right to inverterᵣ) public\n\n morphism-equivalence : Equivalence(_⟶_)\n Equivalence.reflexivity morphism-equivalence = morphism-reflexivity\n Equivalence.symmetry morphism-equivalence = morphism-symmetry\n Equivalence.transitivity morphism-equivalence = morphism-transitivity\n\n object-equiv : Equiv(Obj)\n object-equiv = intro(_⟶_) ⦃ morphism-equivalence ⦄\n\n morphism-setoid : Setoid\n morphism-setoid = [∃]-intro Obj ⦃ object-equiv ⦄\n\n-- A category object can be used when one refers to a category as an object.\n-- Examples of usage are in functors (morphism between categories) or in equivalences of categories.\nrecord GroupoidObject : Stmt{Lvl.𝐒(ℓₒ Lvl.⊔ ℓₘ Lvl.⊔ ℓₑ)} where\n constructor intro\n field\n {Object} : Type{ℓₒ}\n {Morphism} : Object → Object → Type{ℓₘ}\n ⦃ morphism-equiv ⦄ : ∀{x y} → Equiv{ℓₑ}(Morphism x y)\n groupoid : Groupoid(Morphism)\n\n open Groupoid(groupoid) public\n instance\n groupoid-instance = groupoid\n", "meta": {"hexsha": "3aedbaa78187115e94d2b9d60d4e86278c4a4d33", "size": 5489, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Groupoid.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Groupoid.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Groupoid.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.5833333333, "max_line_length": 321, "alphanum_fraction": 0.7086901075, "num_tokens": 1559, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8539127641048443, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.6216275227362564}} {"text": "\nmodule Oscar.Category.Morphism where\n\nopen import Oscar.Category.Setoid\nopen import Oscar.Level\nopen import Oscar.Property\nopen import Oscar.Data.Nat\n\nrecord Morphism\n {𝔬} (⋆ : Set 𝔬) 𝔪 𝔮\n : Set (𝔬 ⊔ lsuc (𝔪 ⊔ 𝔮))\n where\n constructor #_\n\n field\n _⇒_ : ⋆ → ⋆ → Setoid 𝔪 𝔮\n\n _↦_ : ⋆ → ⋆ → Set 𝔪\n _↦_ x y = Setoid.⋆ (x ⇒ y)\n\n infix 4 _≞_\n _≞_ : ∀ {x y} → x ↦ y → x ↦ y → Set 𝔮\n _≞_ {x} {y} = Setoid._≋_ (x ⇒ y)\n\n instance IsSetoid↦ : ∀ {x y} → IsSetoid (_≞_ {x} {y})\n IsSetoid↦ {x} {y} = Setoid.isSetoid (x ⇒ y)\n\n -- IsSetoid↦ : ∀ {x y} → IsSetoid (x ↦ y) 𝔮\n -- IsSetoid↦ {x} {y} = Setoid.isSetoid (x ⇒ y)\n\n -- ⦃ isMorphism ⦄ : IsMorphism (λ {x} {y} → _≞_ {x} {y})\n\n-- record Morphism 𝔬 𝔪 𝔮 : Set (lsuc (𝔬 ⊔ 𝔪 ⊔ 𝔮)) where\n-- constructor ↑_\n-- infix 4 _≞_\n-- field\n-- {⋆} : Set 𝔬\n-- {_↦_} : ⋆ → ⋆ → Set 𝔪\n-- _≞_ : ∀ {x y} → x ↦ y → x ↦ y → Set 𝔮\n-- ⦃ isSetoid ⦄ : ∀ {x} {y} → IsSetoid (_≞_ {x} {y})\n\n-- instance IsSetoid↦ : ∀ {x y} → IsSetoid (_≞_ {x} {y})\n-- IsSetoid↦ {x} {y} = Setoid.isSetoid (x ⇒ y)\n\n-- setoid : ∀ {x y} → Setoid 𝔪 𝔮\n-- setoid {x} {y} = ↑ _≞_ {x} {y}\n", "meta": {"hexsha": "e8e0be3c0c5860468d5d7e02257b95dcc5add131", "size": 1119, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-2/Oscar/Category/Morphism.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-2/Oscar/Category/Morphism.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-2/Oscar/Category/Morphism.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.8085106383, "max_line_length": 60, "alphanum_fraction": 0.4968722073, "num_tokens": 588, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127566694177, "lm_q2_score": 0.7279754371026367, "lm_q1q2_score": 0.6216275122839368}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Bundles for homogeneous binary relations\n------------------------------------------------------------------------\n\n-- The contents of this module should be accessed via `Relation.Binary`.\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Relation.Binary.Bundles where\n\nopen import Level\nopen import Relation.Nullary using (¬_)\nopen import Relation.Binary.Core\nopen import Relation.Binary.Definitions\nopen import Relation.Binary.Structures\n\n------------------------------------------------------------------------\n-- Setoids\n------------------------------------------------------------------------\n\nrecord PartialSetoid a ℓ : Set (suc (a ⊔ ℓ)) where\n field\n Carrier : Set a\n _≈_ : Rel Carrier ℓ\n isPartialEquivalence : IsPartialEquivalence _≈_\n\n open IsPartialEquivalence isPartialEquivalence public\n\n _≉_ : Rel Carrier _\n x ≉ y = ¬ (x ≈ y)\n\n\nrecord Setoid c ℓ : Set (suc (c ⊔ ℓ)) where\n infix 4 _≈_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ\n isEquivalence : IsEquivalence _≈_\n\n open IsEquivalence isEquivalence public\n\n partialSetoid : PartialSetoid c ℓ\n partialSetoid = record\n { isPartialEquivalence = isPartialEquivalence\n }\n\n open PartialSetoid partialSetoid public using (_≉_)\n\n\nrecord DecSetoid c ℓ : Set (suc (c ⊔ ℓ)) where\n infix 4 _≈_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ\n isDecEquivalence : IsDecEquivalence _≈_\n\n open IsDecEquivalence isDecEquivalence public\n\n setoid : Setoid c ℓ\n setoid = record\n { isEquivalence = isEquivalence\n }\n\n open Setoid setoid public using (partialSetoid; _≉_)\n\n\n------------------------------------------------------------------------\n-- Preorders\n------------------------------------------------------------------------\n\nrecord Preorder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _∼_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ₁ -- The underlying equality.\n _∼_ : Rel Carrier ℓ₂ -- The relation.\n isPreorder : IsPreorder _≈_ _∼_\n\n open IsPreorder isPreorder public\n hiding (module Eq)\n\n module Eq where\n setoid : Setoid c ℓ₁\n setoid = record\n { isEquivalence = isEquivalence\n }\n\n open Setoid setoid public\n\n------------------------------------------------------------------------\n-- Partial orders\n------------------------------------------------------------------------\n\nrecord Poset c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _≤_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ₁\n _≤_ : Rel Carrier ℓ₂\n isPartialOrder : IsPartialOrder _≈_ _≤_\n\n open IsPartialOrder isPartialOrder public\n hiding (module Eq)\n\n preorder : Preorder c ℓ₁ ℓ₂\n preorder = record\n { isPreorder = isPreorder\n }\n\n open Preorder preorder public\n using (module Eq)\n\n\nrecord DecPoset c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _≤_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ₁\n _≤_ : Rel Carrier ℓ₂\n isDecPartialOrder : IsDecPartialOrder _≈_ _≤_\n\n private\n module DPO = IsDecPartialOrder isDecPartialOrder\n open DPO public hiding (module Eq)\n\n poset : Poset c ℓ₁ ℓ₂\n poset = record\n { isPartialOrder = isPartialOrder\n }\n\n open Poset poset public\n using (preorder)\n\n module Eq where\n decSetoid : DecSetoid c ℓ₁\n decSetoid = record\n { isDecEquivalence = DPO.Eq.isDecEquivalence\n }\n\n open DecSetoid decSetoid public\n\n\nrecord StrictPartialOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _<_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ₁\n _<_ : Rel Carrier ℓ₂\n isStrictPartialOrder : IsStrictPartialOrder _≈_ _<_\n\n open IsStrictPartialOrder isStrictPartialOrder public\n hiding (module Eq)\n\n module Eq where\n setoid : Setoid c ℓ₁\n setoid = record\n { isEquivalence = isEquivalence\n }\n\n open Setoid setoid public\n\n\nrecord DecStrictPartialOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _<_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ₁\n _<_ : Rel Carrier ℓ₂\n isDecStrictPartialOrder : IsDecStrictPartialOrder _≈_ _<_\n\n private\n module DSPO = IsDecStrictPartialOrder isDecStrictPartialOrder\n open DSPO public hiding (module Eq)\n\n strictPartialOrder : StrictPartialOrder c ℓ₁ ℓ₂\n strictPartialOrder = record\n { isStrictPartialOrder = isStrictPartialOrder\n }\n\n module Eq where\n\n decSetoid : DecSetoid c ℓ₁\n decSetoid = record\n { isDecEquivalence = DSPO.Eq.isDecEquivalence\n }\n\n open DecSetoid decSetoid public\n\n\n------------------------------------------------------------------------\n-- Total orders\n------------------------------------------------------------------------\n\nrecord TotalOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _≤_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ₁\n _≤_ : Rel Carrier ℓ₂\n isTotalOrder : IsTotalOrder _≈_ _≤_\n\n open IsTotalOrder isTotalOrder public\n hiding (module Eq)\n\n poset : Poset c ℓ₁ ℓ₂\n poset = record\n { isPartialOrder = isPartialOrder\n }\n\n open Poset poset public\n using (module Eq; preorder)\n\n\nrecord DecTotalOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _≤_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ₁\n _≤_ : Rel Carrier ℓ₂\n isDecTotalOrder : IsDecTotalOrder _≈_ _≤_\n\n private\n module DTO = IsDecTotalOrder isDecTotalOrder\n open DTO public hiding (module Eq)\n\n totalOrder : TotalOrder c ℓ₁ ℓ₂\n totalOrder = record\n { isTotalOrder = isTotalOrder\n }\n\n open TotalOrder totalOrder public using (poset; preorder)\n\n decPoset : DecPoset c ℓ₁ ℓ₂\n decPoset = record\n { isDecPartialOrder = isDecPartialOrder\n }\n\n open DecPoset decPoset public using (module Eq)\n\n\n-- Note that these orders are decidable. The current implementation\n-- of `Trichotomous` subsumes irreflexivity and asymmetry. Any reasonable\n-- definition capturing these three properties implies decidability\n-- as `Trichotomous` necessarily separates out the equality case.\n\nrecord StrictTotalOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _<_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ₁\n _<_ : Rel Carrier ℓ₂\n isStrictTotalOrder : IsStrictTotalOrder _≈_ _<_\n\n open IsStrictTotalOrder isStrictTotalOrder public\n hiding (module Eq)\n\n strictPartialOrder : StrictPartialOrder c ℓ₁ ℓ₂\n strictPartialOrder = record\n { isStrictPartialOrder = isStrictPartialOrder\n }\n\n open StrictPartialOrder strictPartialOrder public\n using (module Eq)\n\n decSetoid : DecSetoid c ℓ₁\n decSetoid = record\n { isDecEquivalence = isDecEquivalence\n }\n {-# WARNING_ON_USAGE decSetoid\n \"Warning: decSetoid was deprecated in v1.3.\n Please use Eq.decSetoid instead.\"\n #-}\n", "meta": {"hexsha": "136980fe558d0dc65061016063fc98aee879ece2", "size": 7066, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Relation/Binary/Bundles.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Relation/Binary/Bundles.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Relation/Binary/Bundles.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 25.6945454545, "max_line_length": 73, "alphanum_fraction": 0.586328899, "num_tokens": 2027, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267762381844, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.6215795291716275}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\n\n-- Lifts a 1-Category into a bicategory\n\nmodule Categories.Bicategory.Construction.1-Category\n {o ℓ e} b (C : Category o ℓ e) where\n\nopen import Level using (Lift; lift)\nopen import Data.Unit using (⊤; tt)\nopen import Data.Product using (uncurry)\nopen import Relation.Binary using (Setoid)\n\nopen import Categories.Bicategory\nopen import Categories.Category.Construction.0-Groupoid using (0-Groupoid)\nopen import Categories.Category.Instance.Cats using (Cats)\nopen import Categories.Category.Monoidal using (Monoidal)\nopen import Categories.Category.Monoidal.Instance.Cats using (module Product)\nopen import Categories.Category.Groupoid using (Groupoid; IsGroupoid)\nopen import Categories.Functor using (Functor; _∘F_) renaming (id to idF)\nopen import Categories.Functor.Construction.Constant using (const)\nopen import Categories.Functor.Bifunctor using (Bifunctor)\n\nprivate module C = Category C\nopen C hiding (id)\n\n1-Category : Bicategory ℓ e b o\n1-Category = record\n { enriched = record\n { Obj = Obj\n ; hom = hom\n ; id = id\n ; ⊚ = ⊚\n ; ⊚-assoc = ⊚-assoc\n ; unitˡ = unitˡ\n ; unitʳ = unitʳ\n }\n ; triangle = lift tt\n ; pentagon = lift tt\n }\n where\n open Monoidal (Product.Cats-Monoidal {ℓ} {e} {b})\n open Category.Commutation (Cats ℓ e b)\n\n -- Since we are doing Setoid-enriched category theory, we don't\n -- lift homsets to discrete hom-categories, but hom-setoids to\n -- thin hom-groupoids.\n\n hom : C.Obj → C.Obj → Category ℓ e b\n hom A B = Groupoid.category (0-Groupoid b (hom-setoid {A} {B}))\n\n id : ∀ {A} → Functor unit (hom A A)\n id = const C.id\n\n ⊚ : ∀ {A B C} → Bifunctor (hom B C) (hom A B) (hom A C)\n ⊚ {A} {B} {C} = record\n { F₀ = uncurry _∘_\n ; F₁ = uncurry ∘-resp-≈\n ; identity = lift tt\n ; homomorphism = lift tt\n ; F-resp-≈ = λ _ → lift tt\n }\n\n ⊚-assoc : ∀ {A B C D} →\n [ (hom C D ⊗₀ hom B C) ⊗₀ hom A B ⇒ hom A D ]⟨\n ⊚ ⊗₁ idF ⇒⟨ hom B D ⊗₀ hom A B ⟩\n ⊚\n ≈ associator.from ⇒⟨ hom C D ⊗₀ (hom B C ⊗₀ hom A B) ⟩\n idF ⊗₁ ⊚ ⇒⟨ hom C D ⊗₀ hom A C ⟩\n ⊚\n ⟩\n ⊚-assoc = record\n { F⇒G = record { η = λ _ → assoc ; commute = λ _ → lift tt }\n ; F⇐G = record { η = λ _ → sym-assoc ; commute = λ _ → lift tt }\n ; iso = λ _ → record { isoˡ = lift tt ; isoʳ = lift tt }\n }\n\n unitˡ : ∀ {A B} →\n [ unit ⊗₀ hom A B ⇒ hom A B ]⟨\n id ⊗₁ idF ⇒⟨ hom B B ⊗₀ hom A B ⟩\n ⊚\n ≈ unitorˡ.from\n ⟩\n unitˡ = record\n { F⇒G = record { η = λ _ → identityˡ ; commute = λ _ → lift tt }\n ; F⇐G = record { η = λ _ → Equiv.sym identityˡ ; commute = λ _ → lift tt }\n ; iso = λ _ → record { isoˡ = lift tt ; isoʳ = lift tt }\n }\n\n unitʳ : ∀ {A B} →\n [ hom A B ⊗₀ unit ⇒ hom A B ]⟨\n idF ⊗₁ id ⇒⟨ hom A B ⊗₀ hom A A ⟩\n ⊚\n ≈ unitorʳ.from\n ⟩\n unitʳ = record\n { F⇒G = record { η = λ _ → identityʳ ; commute = λ _ → lift tt }\n ; F⇐G = record { η = λ _ → Equiv.sym identityʳ ; commute = λ _ → lift tt }\n ; iso = λ _ → record { isoˡ = lift tt ; isoʳ = lift tt }\n }\n\nopen Bicategory 1-Category\n\n-- The hom-categories are hom-groupoids\n\nhom-isGroupoid : ∀ {A B} → IsGroupoid (hom A B)\nhom-isGroupoid = Groupoid.isGroupoid (0-Groupoid b hom-setoid)\n", "meta": {"hexsha": "d22f24d67337d0a8ce23a987fedb6e9f4299eaa2", "size": 3430, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Bicategory/Construction/1-Category.agda", "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Bicategory/Construction/1-Category.agda", "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Bicategory/Construction/1-Category.agda", "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.4678899083, "max_line_length": 80, "alphanum_fraction": 0.5720116618, "num_tokens": 1194, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267660487573, "lm_q2_score": 0.7154240079185319, "lm_q1q2_score": 0.6215795271534986}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Some algebraic structures (not packed up with sets, operations,\n-- etc.)\n------------------------------------------------------------------------\n\nopen import Relation.Binary\n\nmodule Algebra.Structures where\n\nimport Algebra.FunctionProperties as FunctionProperties\nopen import Data.Product\nopen import Function\nopen import Level using (_⊔_)\nimport Relation.Binary.EqReasoning as EqR\n\nopen FunctionProperties using (Op₁; Op₂)\n\n------------------------------------------------------------------------\n-- One binary operation\n\nrecord IsSemigroup {a ℓ} {A : Set a} (≈ : Rel A ℓ)\n (∙ : Op₂ A) : Set (a ⊔ ℓ) where\n open FunctionProperties ≈\n field\n isEquivalence : IsEquivalence ≈\n assoc : Associative ∙\n ∙-cong : ∙ Preserves₂ ≈ ⟶ ≈ ⟶ ≈\n\n open IsEquivalence isEquivalence public\n\nrecord IsMonoid {a ℓ} {A : Set a} (≈ : Rel A ℓ)\n (∙ : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where\n open FunctionProperties ≈\n field\n isSemigroup : IsSemigroup ≈ ∙\n identity : Identity ε ∙\n\n open IsSemigroup isSemigroup public\n\nrecord IsCommutativeMonoid {a ℓ} {A : Set a} (≈ : Rel A ℓ)\n (_∙_ : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where\n open FunctionProperties ≈\n field\n isSemigroup : IsSemigroup ≈ _∙_\n identityˡ : LeftIdentity ε _∙_\n comm : Commutative _∙_\n\n open IsSemigroup isSemigroup public\n\n identity : Identity ε _∙_\n identity = (identityˡ , identityʳ)\n where\n open EqR (record { isEquivalence = isEquivalence })\n\n identityʳ : RightIdentity ε _∙_\n identityʳ = λ x → begin\n (x ∙ ε) ≈⟨ comm x ε ⟩\n (ε ∙ x) ≈⟨ identityˡ x ⟩\n x ∎\n\n isMonoid : IsMonoid ≈ _∙_ ε\n isMonoid = record\n { isSemigroup = isSemigroup\n ; identity = identity\n }\n\nrecord IsGroup {a ℓ} {A : Set a} (≈ : Rel A ℓ)\n (_∙_ : Op₂ A) (ε : A) (_⁻¹ : Op₁ A) : Set (a ⊔ ℓ) where\n open FunctionProperties ≈\n infixl 7 _-_\n field\n isMonoid : IsMonoid ≈ _∙_ ε\n inverse : Inverse ε _⁻¹ _∙_\n ⁻¹-cong : _⁻¹ Preserves ≈ ⟶ ≈\n\n open IsMonoid isMonoid public\n\n _-_ : FunctionProperties.Op₂ A\n x - y = x ∙ (y ⁻¹)\n\nrecord IsAbelianGroup\n {a ℓ} {A : Set a} (≈ : Rel A ℓ)\n (∙ : Op₂ A) (ε : A) (⁻¹ : Op₁ A) : Set (a ⊔ ℓ) where\n open FunctionProperties ≈\n field\n isGroup : IsGroup ≈ ∙ ε ⁻¹\n comm : Commutative ∙\n\n open IsGroup isGroup public\n\n isCommutativeMonoid : IsCommutativeMonoid ≈ ∙ ε\n isCommutativeMonoid = record\n { isSemigroup = isSemigroup\n ; identityˡ = proj₁ identity\n ; comm = comm\n }\n\n------------------------------------------------------------------------\n-- Two binary operations\n\nrecord IsNearSemiring {a ℓ} {A : Set a} (≈ : Rel A ℓ)\n (+ * : Op₂ A) (0# : A) : Set (a ⊔ ℓ) where\n open FunctionProperties ≈\n field\n +-isMonoid : IsMonoid ≈ + 0#\n *-isSemigroup : IsSemigroup ≈ *\n distribʳ : * DistributesOverʳ +\n zeroˡ : LeftZero 0# *\n\n open IsMonoid +-isMonoid public\n renaming ( assoc to +-assoc\n ; ∙-cong to +-cong\n ; isSemigroup to +-isSemigroup\n ; identity to +-identity\n )\n\n open IsSemigroup *-isSemigroup public\n using ()\n renaming ( assoc to *-assoc\n ; ∙-cong to *-cong\n )\n\nrecord IsSemiringWithoutOne {a ℓ} {A : Set a} (≈ : Rel A ℓ)\n (+ * : Op₂ A) (0# : A) : Set (a ⊔ ℓ) where\n open FunctionProperties ≈\n field\n +-isCommutativeMonoid : IsCommutativeMonoid ≈ + 0#\n *-isSemigroup : IsSemigroup ≈ *\n distrib : * DistributesOver +\n zero : Zero 0# *\n\n open IsCommutativeMonoid +-isCommutativeMonoid public\n hiding (identityˡ)\n renaming ( assoc to +-assoc\n ; ∙-cong to +-cong\n ; isSemigroup to +-isSemigroup\n ; identity to +-identity\n ; isMonoid to +-isMonoid\n ; comm to +-comm\n )\n\n open IsSemigroup *-isSemigroup public\n using ()\n renaming ( assoc to *-assoc\n ; ∙-cong to *-cong\n )\n\n isNearSemiring : IsNearSemiring ≈ + * 0#\n isNearSemiring = record\n { +-isMonoid = +-isMonoid\n ; *-isSemigroup = *-isSemigroup\n ; distribʳ = proj₂ distrib\n ; zeroˡ = proj₁ zero\n }\n\nrecord IsSemiringWithoutAnnihilatingZero\n {a ℓ} {A : Set a} (≈ : Rel A ℓ)\n (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ) where\n open FunctionProperties ≈\n field\n -- Note that these structures do have an additive unit, but this\n -- unit does not necessarily annihilate multiplication.\n +-isCommutativeMonoid : IsCommutativeMonoid ≈ + 0#\n *-isMonoid : IsMonoid ≈ * 1#\n distrib : * DistributesOver +\n\n open IsCommutativeMonoid +-isCommutativeMonoid public\n hiding (identityˡ)\n renaming ( assoc to +-assoc\n ; ∙-cong to +-cong\n ; isSemigroup to +-isSemigroup\n ; identity to +-identity\n ; isMonoid to +-isMonoid\n ; comm to +-comm\n )\n\n open IsMonoid *-isMonoid public\n using ()\n renaming ( assoc to *-assoc\n ; ∙-cong to *-cong\n ; isSemigroup to *-isSemigroup\n ; identity to *-identity\n )\n\nrecord IsSemiring {a ℓ} {A : Set a} (≈ : Rel A ℓ)\n (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ) where\n open FunctionProperties ≈\n field\n isSemiringWithoutAnnihilatingZero :\n IsSemiringWithoutAnnihilatingZero ≈ + * 0# 1#\n zero : Zero 0# *\n\n open IsSemiringWithoutAnnihilatingZero\n isSemiringWithoutAnnihilatingZero public\n\n isSemiringWithoutOne : IsSemiringWithoutOne ≈ + * 0#\n isSemiringWithoutOne = record\n { +-isCommutativeMonoid = +-isCommutativeMonoid\n ; *-isSemigroup = *-isSemigroup\n ; distrib = distrib\n ; zero = zero\n }\n\n open IsSemiringWithoutOne isSemiringWithoutOne public\n using (isNearSemiring)\n\nrecord IsCommutativeSemiringWithoutOne\n {a ℓ} {A : Set a} (≈ : Rel A ℓ)\n (+ * : Op₂ A) (0# : A) : Set (a ⊔ ℓ) where\n open FunctionProperties ≈\n field\n isSemiringWithoutOne : IsSemiringWithoutOne ≈ + * 0#\n *-comm : Commutative *\n\n open IsSemiringWithoutOne isSemiringWithoutOne public\n\nrecord IsCommutativeSemiring\n {a ℓ} {A : Set a} (≈ : Rel A ℓ)\n (_+_ _*_ : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ) where\n open FunctionProperties ≈\n field\n +-isCommutativeMonoid : IsCommutativeMonoid ≈ _+_ 0#\n *-isCommutativeMonoid : IsCommutativeMonoid ≈ _*_ 1#\n distribʳ : _*_ DistributesOverʳ _+_\n zeroˡ : LeftZero 0# _*_\n\n private\n module +-CM = IsCommutativeMonoid +-isCommutativeMonoid\n open module *-CM = IsCommutativeMonoid *-isCommutativeMonoid public\n using () renaming (comm to *-comm)\n open EqR (record { isEquivalence = +-CM.isEquivalence })\n\n distrib : _*_ DistributesOver _+_\n distrib = (distribˡ , distribʳ)\n where\n distribˡ : _*_ DistributesOverˡ _+_\n distribˡ x y z = begin\n (x * (y + z)) ≈⟨ *-comm x (y + z) ⟩\n ((y + z) * x) ≈⟨ distribʳ x y z ⟩\n ((y * x) + (z * x)) ≈⟨ *-comm y x ⟨ +-CM.∙-cong ⟩ *-comm z x ⟩\n ((x * y) + (x * z)) ∎\n\n zero : Zero 0# _*_\n zero = (zeroˡ , zeroʳ)\n where\n zeroʳ : RightZero 0# _*_\n zeroʳ x = begin\n (x * 0#) ≈⟨ *-comm x 0# ⟩\n (0# * x) ≈⟨ zeroˡ x ⟩\n 0# ∎\n\n isSemiring : IsSemiring ≈ _+_ _*_ 0# 1#\n isSemiring = record\n { isSemiringWithoutAnnihilatingZero = record\n { +-isCommutativeMonoid = +-isCommutativeMonoid\n ; *-isMonoid = *-CM.isMonoid\n ; distrib = distrib\n }\n ; zero = zero\n }\n\n open IsSemiring isSemiring public\n hiding (distrib; zero; +-isCommutativeMonoid)\n\n isCommutativeSemiringWithoutOne :\n IsCommutativeSemiringWithoutOne ≈ _+_ _*_ 0#\n isCommutativeSemiringWithoutOne = record\n { isSemiringWithoutOne = isSemiringWithoutOne\n ; *-comm = *-CM.comm\n }\n\nrecord IsRing\n {a ℓ} {A : Set a} (≈ : Rel A ℓ)\n (_+_ _*_ : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Set (a ⊔ ℓ) where\n open FunctionProperties ≈\n field\n +-isAbelianGroup : IsAbelianGroup ≈ _+_ 0# -_\n *-isMonoid : IsMonoid ≈ _*_ 1#\n distrib : _*_ DistributesOver _+_\n\n open IsAbelianGroup +-isAbelianGroup public\n renaming ( assoc to +-assoc\n ; ∙-cong to +-cong\n ; isSemigroup to +-isSemigroup\n ; identity to +-identity\n ; isMonoid to +-isMonoid\n ; inverse to -‿inverse\n ; ⁻¹-cong to -‿cong\n ; isGroup to +-isGroup\n ; comm to +-comm\n ; isCommutativeMonoid to +-isCommutativeMonoid\n )\n\n open IsMonoid *-isMonoid public\n using ()\n renaming ( assoc to *-assoc\n ; ∙-cong to *-cong\n ; isSemigroup to *-isSemigroup\n ; identity to *-identity\n )\n\n zero : Zero 0# _*_\n zero = (zeroˡ , zeroʳ)\n where\n open EqR (record { isEquivalence = isEquivalence })\n\n zeroˡ : LeftZero 0# _*_\n zeroˡ x = begin\n 0# * x ≈⟨ sym $ proj₂ +-identity _ ⟩\n (0# * x) + 0# ≈⟨ refl ⟨ +-cong ⟩ sym (proj₂ -‿inverse _) ⟩\n (0# * x) + ((0# * x) + - (0# * x)) ≈⟨ sym $ +-assoc _ _ _ ⟩\n ((0# * x) + (0# * x)) + - (0# * x) ≈⟨ sym (proj₂ distrib _ _ _) ⟨ +-cong ⟩ refl ⟩\n ((0# + 0#) * x) + - (0# * x) ≈⟨ (proj₂ +-identity _ ⟨ *-cong ⟩ refl)\n ⟨ +-cong ⟩\n refl ⟩\n (0# * x) + - (0# * x) ≈⟨ proj₂ -‿inverse _ ⟩\n 0# ∎\n\n zeroʳ : RightZero 0# _*_\n zeroʳ x = begin\n x * 0# ≈⟨ sym $ proj₂ +-identity _ ⟩\n (x * 0#) + 0# ≈⟨ refl ⟨ +-cong ⟩ sym (proj₂ -‿inverse _) ⟩\n (x * 0#) + ((x * 0#) + - (x * 0#)) ≈⟨ sym $ +-assoc _ _ _ ⟩\n ((x * 0#) + (x * 0#)) + - (x * 0#) ≈⟨ sym (proj₁ distrib _ _ _) ⟨ +-cong ⟩ refl ⟩\n (x * (0# + 0#)) + - (x * 0#) ≈⟨ (refl ⟨ *-cong ⟩ proj₂ +-identity _)\n ⟨ +-cong ⟩\n refl ⟩\n (x * 0#) + - (x * 0#) ≈⟨ proj₂ -‿inverse _ ⟩\n 0# ∎\n\n isSemiringWithoutAnnihilatingZero\n : IsSemiringWithoutAnnihilatingZero ≈ _+_ _*_ 0# 1#\n isSemiringWithoutAnnihilatingZero = record\n { +-isCommutativeMonoid = +-isCommutativeMonoid\n ; *-isMonoid = *-isMonoid\n ; distrib = distrib\n }\n\n isSemiring : IsSemiring ≈ _+_ _*_ 0# 1#\n isSemiring = record\n { isSemiringWithoutAnnihilatingZero =\n isSemiringWithoutAnnihilatingZero\n ; zero = zero\n }\n\n open IsSemiring isSemiring public\n using (isNearSemiring; isSemiringWithoutOne)\n\nrecord IsCommutativeRing\n {a ℓ} {A : Set a} (≈ : Rel A ℓ)\n (+ * : Op₂ A) (- : Op₁ A) (0# 1# : A) : Set (a ⊔ ℓ) where\n open FunctionProperties ≈\n field\n isRing : IsRing ≈ + * - 0# 1#\n *-comm : Commutative *\n\n open IsRing isRing public\n\n isCommutativeSemiring : IsCommutativeSemiring ≈ + * 0# 1#\n isCommutativeSemiring = record\n { +-isCommutativeMonoid = +-isCommutativeMonoid\n ; *-isCommutativeMonoid = record\n { isSemigroup = *-isSemigroup\n ; identityˡ = proj₁ *-identity\n ; comm = *-comm\n }\n ; distribʳ = proj₂ distrib\n ; zeroˡ = proj₁ zero\n }\n\n open IsCommutativeSemiring isCommutativeSemiring public\n using ( *-isCommutativeMonoid\n ; isCommutativeSemiringWithoutOne\n )\n\nrecord IsLattice {a ℓ} {A : Set a} (≈ : Rel A ℓ)\n (∨ ∧ : Op₂ A) : Set (a ⊔ ℓ) where\n open FunctionProperties ≈\n field\n isEquivalence : IsEquivalence ≈\n ∨-comm : Commutative ∨\n ∨-assoc : Associative ∨\n ∨-cong : ∨ Preserves₂ ≈ ⟶ ≈ ⟶ ≈\n ∧-comm : Commutative ∧\n ∧-assoc : Associative ∧\n ∧-cong : ∧ Preserves₂ ≈ ⟶ ≈ ⟶ ≈\n absorptive : Absorptive ∨ ∧\n\n open IsEquivalence isEquivalence public\n\nrecord IsDistributiveLattice {a ℓ} {A : Set a} (≈ : Rel A ℓ)\n (∨ ∧ : Op₂ A) : Set (a ⊔ ℓ) where\n open FunctionProperties ≈\n field\n isLattice : IsLattice ≈ ∨ ∧\n ∨-∧-distribʳ : ∨ DistributesOverʳ ∧\n\n open IsLattice isLattice public\n\nrecord IsBooleanAlgebra\n {a ℓ} {A : Set a} (≈ : Rel A ℓ)\n (∨ ∧ : Op₂ A) (¬ : Op₁ A) (⊤ ⊥ : A) : Set (a ⊔ ℓ) where\n open FunctionProperties ≈\n field\n isDistributiveLattice : IsDistributiveLattice ≈ ∨ ∧\n ∨-complementʳ : RightInverse ⊤ ¬ ∨\n ∧-complementʳ : RightInverse ⊥ ¬ ∧\n ¬-cong : ¬ Preserves ≈ ⟶ ≈\n\n open IsDistributiveLattice isDistributiveLattice public\n", "meta": {"hexsha": "6c1d8dd4bd9a655d37e6e0754f6238e886d1703f", "size": 13596, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Algebra/Structures.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Algebra/Structures.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Algebra/Structures.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.9200968523, "max_line_length": 90, "alphanum_fraction": 0.5035304501, "num_tokens": 4432, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267762381843, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.6215795238999954}} {"text": "{-# OPTIONS --safe --experimental-lossy-unification #-}\nmodule Cubical.Algebra.Polynomials.Multivariate.Equiv.Poly0-A where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Isomorphism\n\nopen import Cubical.Data.Nat renaming (_+_ to _+n_; _·_ to _·n_)\nopen import Cubical.Data.Vec\n\nopen import Cubical.Algebra.Ring\nopen import Cubical.Algebra.CommRing\n\nopen import Cubical.Algebra.Polynomials.Univariate.Base\n\nopen import Cubical.Algebra.Polynomials.Multivariate.Base\nopen import Cubical.Algebra.Polynomials.Multivariate.Properties\nopen import Cubical.Algebra.CommRing.Instances.MultivariatePoly\n\nprivate variable\n ℓ : Level\n\nmodule Equiv-Poly0-A (A' : CommRing ℓ) where\n A = fst A'\n cra = snd A'\n\n open CommRingStr cra renaming (is-set to isSetA)\n open Nth-Poly-structure A' 0\n\n\n-----------------------------------------------------------------------------\n-- Equivalence\n\n Poly0→A : Poly A' 0 → A\n Poly0→A = Poly-Rec-Set.f A' 0 A isSetA\n 0r\n (λ v a → a)\n _+_\n +Assoc\n +Rid\n +Comm\n (λ _ → refl)\n λ _ a b → refl\n\n A→Poly0 : A → Poly A' 0\n A→Poly0 a = base [] a\n\n e-sect : (a : A) → Poly0→A (A→Poly0 a) ≡ a\n e-sect a = refl\n\n e-retr : (P : Poly A' 0) → A→Poly0 (Poly0→A P) ≡ P\n e-retr = Poly-Ind-Prop.f A' 0\n (λ P → A→Poly0 (Poly0→A P) ≡ P)\n (λ _ → trunc _ _)\n (base-0P [])\n (λ { [] a → refl })\n λ {U V} ind-U ind-V → (sym (base-Poly+ [] (Poly0→A U) (Poly0→A V))) ∙ (cong₂ _Poly+_ ind-U ind-V)\n\n\n-----------------------------------------------------------------------------\n-- Ring homomorphism\n\n map-0P : Poly0→A 0P ≡ 0r\n map-0P = refl\n\n Poly0→A-gmorph : (P Q : Poly A' 0) → Poly0→A ( P Poly+ Q) ≡ Poly0→A P + Poly0→A Q\n Poly0→A-gmorph P Q = refl\n\n map-1P : Poly0→A 1P ≡ 1r\n map-1P = refl\n\n Poly0→A-rmorph : (P Q : Poly A' 0) → Poly0→A ( P Poly* Q) ≡ Poly0→A P · Poly0→A Q\n Poly0→A-rmorph = Poly-Ind-Prop.f A' 0\n (λ P → (Q : Poly A' 0) → Poly0→A (P Poly* Q) ≡ Poly0→A P · Poly0→A Q)\n (λ P p q i Q j → isSetA (Poly0→A (P Poly* Q)) (Poly0→A P · Poly0→A Q) (p Q) (q Q) i j)\n (λ Q → sym (RingTheory.0LeftAnnihilates (CommRing→Ring A') (Poly0→A Q)))\n (λ v a → Poly-Ind-Prop.f A' 0\n (λ P → Poly0→A (base v a Poly* P) ≡ Poly0→A (base v a) · Poly0→A P)\n (λ _ → isSetA _ _)\n (sym (RingTheory.0RightAnnihilates (CommRing→Ring A') (Poly0→A (base v a))))\n (λ v' a' → refl)\n λ {U V} ind-U ind-V → (cong₂ _+_ ind-U ind-V) ∙ (sym (·Rdist+ _ _ _)))\n λ {U V} ind-U ind-V Q → (cong₂ _+_ (ind-U Q) (ind-V Q)) ∙ (sym (·Ldist+ _ _ _))\n\n\n-----------------------------------------------------------------------------\n-- Ring Equivalence\n\nmodule _ (A' : CommRing ℓ) where\n\n open Equiv-Poly0-A A'\n\n CRE-Poly0-A : CommRingEquiv (PolyCommRing A' 0) A'\n fst CRE-Poly0-A = isoToEquiv is\n where\n is : Iso (Poly A' 0) (A' .fst)\n Iso.fun is = Poly0→A\n Iso.inv is = A→Poly0\n Iso.rightInv is = e-sect\n Iso.leftInv is = e-retr\n snd CRE-Poly0-A = makeIsRingHom map-1P Poly0→A-gmorph Poly0→A-rmorph\n", "meta": {"hexsha": "86bd3e98ea35b7119f2590cb1d79950be726eea0", "size": 3314, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Polynomials/Multivariate/Equiv/Poly0-A.agda", "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Polynomials/Multivariate/Equiv/Poly0-A.agda", "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Polynomials/Multivariate/Equiv/Poly0-A.agda", "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.8118811881, "max_line_length": 108, "alphanum_fraction": 0.5144840072, "num_tokens": 1130, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267830311354, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.6215795234882036}} {"text": "\nmodule ModuleInstInLet where\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\nmodule List (Elem : Set) where\n\n data List : Set where\n [] : List\n _::_ : Elem -> List -> List\n\nxs : let open List Nat\n in List\nxs = List._::_ zero List.[]\n\n", "meta": {"hexsha": "762c6f7e998fc3544d4e68552df4109dc04ae88a", "size": 257, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/ModuleInstInLet.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/ModuleInstInLet.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/ModuleInstInLet.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 14.2777777778, "max_line_length": 31, "alphanum_fraction": 0.5875486381, "num_tokens": 81, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8688267694452331, "lm_q2_score": 0.7154239957834734, "lm_q1q2_score": 0.6215795190401552}} {"text": "\nmodule Haskell.Prim.Foldable where\n\nopen import Haskell.Prim\nopen import Haskell.Prim.Num\nopen import Haskell.Prim.Eq\nopen import Haskell.Prim.List\nopen import Haskell.Prim.Int\nopen import Haskell.Prim.Bool\nopen import Haskell.Prim.Maybe\nopen import Haskell.Prim.Either\nopen import Haskell.Prim.Tuple\nopen import Haskell.Prim.Monoid\n\n--------------------------------------------------\n-- Foldable\n\nrecord Foldable (t : Set → Set) : Set₁ where\n field\n foldMap : ⦃ Monoid b ⦄ → (a → b) → t a → b\n\n foldr : (a → b → b) → b → t a → b\n foldr f z t = foldMap ⦃ MonoidEndo ⦄ f t z\n\n foldl : (b → a → b) → b → t a → b\n foldl f z t = foldMap ⦃ MonoidEndoᵒᵖ ⦄ (flip f) t z\n\n any : (a → Bool) → t a → Bool\n any = foldMap ⦃ MonoidDisj ⦄\n\n all : (a → Bool) → t a → Bool\n all = foldMap ⦃ MonoidConj ⦄\n\n and : t Bool → Bool\n and = all id\n\n or : t Bool → Bool\n or = any id\n\n null : t a → Bool\n null = all (const false)\n\n concat : t (List a) → List a\n concat = foldMap id\n\n concatMap : (a → List b) → t a → List b\n concatMap = foldMap\n\n elem : ⦃ Eq a ⦄ → a → t a → Bool\n elem x = foldMap ⦃ MonoidDisj ⦄ (x ==_)\n\n notElem : ⦃ Eq a ⦄ → a → t a → Bool\n notElem x t = not (elem x t)\n\n toList : t a → List a\n toList = foldr _∷_ []\n\n sum : ⦃ iNum : Num a ⦄ → t a → a\n sum = foldMap ⦃ MonoidSum ⦄ id\n\n product : ⦃ iNum : Num a ⦄ → t a → a\n product = foldMap ⦃ MonoidProduct ⦄ id\n\n length : t a → Int\n length = foldMap ⦃ MonoidSum ⦄ (const 1)\n\nopen Foldable ⦃ ... ⦄ public\n\ninstance\n iFoldableList : Foldable List\n iFoldableList .foldMap f [] = mempty\n iFoldableList .foldMap f (x ∷ xs) = f x <> foldMap f xs\n\n iFoldableMaybe : Foldable Maybe\n iFoldableMaybe .foldMap _ Nothing = mempty\n iFoldableMaybe .foldMap f (Just x) = f x\n\n iFoldableEither : Foldable (Either a)\n iFoldableEither .foldMap _ (Left _) = mempty\n iFoldableEither .foldMap f (Right x) = f x\n\n iFoldablePair : Foldable (a ×_)\n iFoldablePair .foldMap f (_ , x) = f x\n", "meta": {"hexsha": "f12a519a12e060d11dd2b1f2d83d8eab50b7a585", "size": 1961, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lib/Haskell/Prim/Foldable.agda", "max_stars_repo_name": "flupe/agda2hs", "max_stars_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/Haskell/Prim/Foldable.agda", "max_issues_repo_name": "flupe/agda2hs", "max_issues_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/Haskell/Prim/Foldable.agda", "max_forks_repo_name": "flupe/agda2hs", "max_forks_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.3452380952, "max_line_length": 57, "alphanum_fraction": 0.6104028557, "num_tokens": 743, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267762381844, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.6215795186283635}} {"text": "{-# OPTIONS --without-K --safe #-}\n-- verbatim dual of Categories.Category.Construction.Properties.EilenbergMoore\nmodule Categories.Category.Construction.Properties.CoEilenbergMoore where\n\nopen import Level\nimport Relation.Binary.PropositionalEquality.Core as ≡\n\nopen import Categories.Adjoint\nopen import Categories.Adjoint.Properties\nopen import Categories.Category\nopen import Categories.Functor using (Functor; _∘F_)\nopen import Categories.Functor.Equivalence\nopen import Categories.Comonad\n\nopen import Categories.NaturalTransformation.Core renaming (id to idN)\nopen import Categories.Morphism.HeterogeneousIdentity\nopen import Categories.Morphism.Reasoning\n\nopen import Categories.Adjoint.Construction.CoEilenbergMoore\nopen import Categories.Category.Construction.CoEilenbergMoore\n\nprivate\n variable\n o ℓ e : Level\n 𝒞 𝒟 : Category o ℓ e\n\nmodule _ {F : Functor 𝒟 𝒞} {G : Functor 𝒞 𝒟} (F⊣G : Adjoint F G) where\n private\n T : Comonad 𝒞\n T = adjoint⇒comonad F⊣G\n\n coEM𝒞 : Category _ _ _\n coEM𝒞 = CoEilenbergMoore T\n\n module 𝒞 = Category 𝒞\n module 𝒟 = Category 𝒟\n module coEM𝒞 = Category coEM𝒞\n\n open 𝒞.HomReasoning\n\n module T = Comonad T\n module F = Functor F\n module G = Functor G\n module FG = Functor (F ∘F G)\n\n open Adjoint F⊣G\n open NaturalTransformation\n open Category.Equiv\n\n -- Maclane's Comparison Functor\n ComparisonF : Functor 𝒟 coEM𝒞\n ComparisonF = record\n { F₀ = λ X → record\n { A = F.F₀ X\n ; coaction = F.F₁ (unit.η X)\n ; commute = commute-obj\n ; identity = zig\n }\n ; F₁ = λ {A} {B} f → record\n { arr = F.F₁ f\n ; commute = commute-mor\n }\n ; identity = F.identity\n ; homomorphism = F.homomorphism\n ; F-resp-≈ = F.F-resp-≈\n }\n where\n commute-obj : {X : Category.Obj 𝒟} → T.F.F₁ (F.F₁ (unit.η X)) 𝒞.∘ F.F₁ (unit.η X) 𝒞.≈ T.δ.η (F.F₀ X) 𝒞.∘ F.F₁ (unit.η X)\n commute-obj {X} = begin\n F.F₁ (G.F₁ (F.F₁ (unit.η X))) 𝒞.∘ F.F₁ (unit.η X) ≈⟨ sym 𝒞 (F.homomorphism) ⟩\n F.F₁ (G.F₁ (F.F₁ (unit.η X)) 𝒟.∘ unit.η X) ≈⟨ Functor.F-resp-≈ F (unit.sym-commute (unit.η X)) ⟩\n F.F₁ (unit.η (G.F₀ (F.F₀ X)) 𝒟.∘ unit.η X) ≈⟨ F.homomorphism ⟩\n T.δ.η (F.F₀ X) 𝒞.∘ F.F₁ (unit.η X) ∎\n commute-mor : {A B : Category.Obj 𝒟} {f : 𝒟 [ A , B ]} → F.F₁ (unit.η B) 𝒞.∘ F.F₁ f 𝒞.≈ T.F.F₁ (F.F₁ f) 𝒞.∘ F.F₁ (unit.η A)\n commute-mor {A} {B} {f} = begin\n F.F₁ (unit.η B) 𝒞.∘ F.F₁ f ≈⟨ sym 𝒞 (F.homomorphism) ⟩\n F.F₁ (unit.η B 𝒟.∘ f) ≈⟨ Functor.F-resp-≈ F (unit.commute f) ⟩\n F.F₁ (G.F₁ (F.F₁ f) 𝒟.∘ unit.η A) ≈⟨ F.homomorphism ⟩\n T.F.F₁ (F.F₁ f) 𝒞.∘ F.F₁ (unit.η A) ∎\n\n Comparison∘F≡Free : (ComparisonF ∘F G) ≡F Cofree T\n Comparison∘F≡Free = record\n { eq₀ = λ X → ≡.refl\n ; eq₁ = λ f → id-comm-sym 𝒞\n }\n\n Forgetful∘ComparisonF≡G : (Forgetful T ∘F ComparisonF) ≡F F\n Forgetful∘ComparisonF≡G = record\n { eq₀ = λ X → ≡.refl\n ; eq₁ = λ f → id-comm-sym 𝒞\n }", "meta": {"hexsha": "512231851f960e360819d8798ffdc2529238d5b8", "size": 2940, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Construction/Properties/CoEilenbergMoore.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-05-21T17:07:19.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-22T03:54:24.000Z", "max_issues_repo_path": "src/Categories/Category/Construction/Properties/CoEilenbergMoore.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Construction/Properties/CoEilenbergMoore.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.3076923077, "max_line_length": 127, "alphanum_fraction": 0.6234693878, "num_tokens": 1182, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267626522813, "lm_q2_score": 0.7154239836484143, "lm_q1q2_score": 0.6215795036370505}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Adjoint.Equivalence where\n\nopen import Level\n\nopen import Categories.Adjoint\nopen import Categories.Category\nopen import Categories.Functor renaming (id to idF)\nopen import Categories.Functor.Properties\nopen import Categories.NaturalTransformation.NaturalIsomorphism as ≃ using (_≃_; NaturalIsomorphism)\nopen import Categories.NaturalTransformation.NaturalIsomorphism.Properties\nimport Categories.Morphism.Reasoning as MR\n\nprivate\n variable\n o ℓ e : Level\n C D E : Category o ℓ e\n\nrecord ⊣Equivalence (L : Functor C D) (R : Functor D C) : Set (levelOfTerm L ⊔ levelOfTerm R) where\n field\n unit : idF ≃ (R ∘F L)\n counit : (L ∘F R) ≃ idF\n\n module unit = NaturalIsomorphism unit\n module counit = NaturalIsomorphism counit\n\n private\n module C = Category C\n module D = Category D\n module L = Functor L\n module R = Functor R\n module ℱ = Functor\n\n field\n zig : ∀ {A : C.Obj} → counit.⇒.η (L.F₀ A) D.∘ L.F₁ (unit.⇒.η A) D.≈ D.id\n\n zag : ∀ {B : D.Obj} → R.F₁ (counit.⇒.η B) C.∘ unit.⇒.η (R.F₀ B) C.≈ C.id\n zag {B} = F≃id⇒id (≃.sym unit) helper\n where open C\n open HomReasoning\n helper : R.F₁ (L.F₁ (R.F₁ (counit.⇒.η B) ∘ unit.⇒.η (R.F₀ B))) ≈ id\n helper = begin\n R.F₁ (L.F₁ (R.F₁ (counit.⇒.η B) ∘ unit.⇒.η (R.F₀ B))) ≈⟨ ℱ.homomorphism (R ∘F L) ⟩\n R.F₁ (L.F₁ (R.F₁ (counit.⇒.η B))) ∘ R.F₁ (L.F₁ (unit.⇒.η (R.F₀ B))) ≈˘⟨ R.F-resp-≈ (F≃id-comm₁ counit) ⟩∘⟨refl ⟩\n R.F₁ (counit.⇒.η (L.F₀ (R.F₀ B))) ∘ R.F₁ (L.F₁ (unit.⇒.η (R.F₀ B))) ≈˘⟨ R.homomorphism ⟩\n R.F₁ (counit.⇒.η (L.F₀ (R.F₀ B)) D.∘ L.F₁ (unit.⇒.η (R.F₀ B))) ≈⟨ R.F-resp-≈ zig ⟩\n R.F₁ D.id ≈⟨ R.identity ⟩\n id ∎\n\n L⊣R : L ⊣ R\n L⊣R = record\n { unit = unit.F⇒G\n ; counit = counit.F⇒G\n ; zig = zig\n ; zag = zag\n }\n\n module L⊣R = Adjoint L⊣R\n open L⊣R hiding (unit; counit; zig; zag) public\n\n R⊣L : R ⊣ L\n R⊣L = record\n { unit = counit.F⇐G\n ; counit = unit.F⇐G\n ; zig = λ {X} →\n let open C.HomReasoning\n open MR C\n in begin\n unit.⇐.η (R.F₀ X) C.∘ R.F₁ (counit.⇐.η X)\n ≈˘⟨ elimʳ zag ⟩\n (unit.⇐.η (R.F₀ X) C.∘ R.F₁ (counit.⇐.η X)) C.∘ (R.F₁ (counit.⇒.η X) C.∘ unit.⇒.η (R.F₀ X))\n ≈⟨ center ([ R ]-resp-∘ (counit.iso.isoˡ _) ○ R.identity) ⟩\n unit.⇐.η (R.F₀ X) C.∘ C.id C.∘ unit.⇒.η (R.F₀ X)\n ≈⟨ refl⟩∘⟨ C.identityˡ ⟩\n unit.⇐.η (R.F₀ X) C.∘ unit.⇒.η (R.F₀ X)\n ≈⟨ unit.iso.isoˡ _ ⟩\n C.id\n ∎\n ; zag = λ {X} →\n let open D.HomReasoning\n open MR D\n in begin\n L.F₁ (unit.⇐.η X) D.∘ counit.⇐.η (L.F₀ X)\n ≈˘⟨ elimʳ zig ⟩\n (L.F₁ (unit.⇐.η X) D.∘ counit.⇐.η (L.F₀ X)) D.∘ counit.⇒.η (L.F₀ X) D.∘ L.F₁ (unit.⇒.η X)\n ≈⟨ center (counit.iso.isoˡ _) ⟩\n L.F₁ (unit.⇐.η X) D.∘ D.id D.∘ L.F₁ (unit.⇒.η X)\n ≈⟨ refl⟩∘⟨ D.identityˡ ⟩\n L.F₁ (unit.⇐.η X) D.∘ L.F₁ (unit.⇒.η X)\n ≈⟨ ([ L ]-resp-∘ (unit.iso.isoˡ _)) ○ L.identity ⟩\n D.id\n ∎\n }\n\n module R⊣L = Adjoint R⊣L\n", "meta": {"hexsha": "76ec79068b5302911a1db7212615d3569009e0ba", "size": 3266, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Adjoint/Equivalence.agda", "max_stars_repo_name": "Taneb/agda-categories", "max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Categories/Adjoint/Equivalence.agda", "max_issues_repo_name": "Taneb/agda-categories", "max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Categories/Adjoint/Equivalence.agda", "max_forks_repo_name": "Taneb/agda-categories", "max_forks_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.6701030928, "max_line_length": 124, "alphanum_fraction": 0.4990814452, "num_tokens": 1453, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.839733983715524, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.6215495656791197}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.Group.Instances.Bool where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Structure\n\nopen import Cubical.Relation.Nullary\n\nopen import Cubical.Data.Bool\nopen import Cubical.Data.Empty as ⊥\nopen import Cubical.Data.Sum hiding (map ; rec)\n\nopen import Cubical.Algebra.Group.Base\nopen import Cubical.Algebra.Group.Morphisms\nopen import Cubical.Algebra.Group.MorphismProperties\nopen import Cubical.Algebra.Monoid\nopen import Cubical.Algebra.Semigroup\n\nopen GroupStr\nopen IsGroup\nopen IsMonoid\nopen IsSemigroup\n\n\n\nBoolGroup : Group₀\nfst BoolGroup = Bool\n1g (snd BoolGroup) = true\n(snd BoolGroup · false) false = true\n(snd BoolGroup · false) true = false\n(snd BoolGroup · true) y = y\ninv (snd BoolGroup) x = x\nis-set (isSemigroup (isMonoid (isGroup (snd BoolGroup)))) = isSetBool\n·Assoc (isSemigroup (isMonoid (isGroup (snd BoolGroup)))) false false false = refl\n·Assoc (isSemigroup (isMonoid (isGroup (snd BoolGroup)))) false false true = refl\n·Assoc (isSemigroup (isMonoid (isGroup (snd BoolGroup)))) false true false = refl\n·Assoc (isSemigroup (isMonoid (isGroup (snd BoolGroup)))) false true true = refl\n·Assoc (isSemigroup (isMonoid (isGroup (snd BoolGroup)))) true false false = refl\n·Assoc (isSemigroup (isMonoid (isGroup (snd BoolGroup)))) true false true = refl\n·Assoc (isSemigroup (isMonoid (isGroup (snd BoolGroup)))) true true false = refl\n·Assoc (isSemigroup (isMonoid (isGroup (snd BoolGroup)))) true true true = refl\n·IdR (isMonoid (isGroup (snd BoolGroup))) false = refl\n·IdR (isMonoid (isGroup (snd BoolGroup))) true = refl\n·IdL (isMonoid (isGroup (snd BoolGroup))) false = refl\n·IdL (isMonoid (isGroup (snd BoolGroup))) true = refl\n·InvR (isGroup (snd BoolGroup)) false = refl\n·InvR (isGroup (snd BoolGroup)) true = refl\n·InvL (isGroup (snd BoolGroup)) false = refl\n·InvL (isGroup (snd BoolGroup)) true = refl\n\n-- Proof that any Group equivalent to Bool as types is also isomorphic to Bool as groups.\nopen GroupStr renaming (·Assoc to ·AssocG)\n\nmodule _ {ℓ : Level} {A : Group ℓ} (e : Iso (fst A) Bool) where\n private\n discreteA : Discrete (typ A)\n discreteA = isoPresDiscrete (invIso e) _≟_\n\n _·A_ = GroupStr._·_ (snd A)\n -A_ = GroupStr.inv (snd A)\n\n IsoABool : Iso Bool (typ A)\n IsoABool with (Iso.fun e (1g (snd A))) ≟ true\n ... | yes p = invIso e\n ... | no p = compIso notIso (invIso e)\n\n true→1 : Iso.fun IsoABool true ≡ 1g (snd A)\n true→1 with (Iso.fun e (1g (snd A))) ≟ true\n ... | yes p = sym (cong (Iso.inv e) p) ∙ Iso.leftInv e _\n ... | no p = sym (cong (Iso.inv e) (¬true→false (Iso.fun e (1g (snd A))) p))\n ∙ Iso.leftInv e (1g (snd A))\n\n decA : (x : typ A) → (x ≡ 1g (snd A)) ⊎ (x ≡ Iso.fun IsoABool false)\n decA x with (Iso.inv IsoABool x) ≟ false | discreteA x (1g (snd A))\n ... | yes p | yes q = inl q\n ... | yes p | no q = inr (sym (Iso.rightInv IsoABool x) ∙ cong (Iso.fun (IsoABool)) p)\n ... | no p | no q = inr (⊥.rec (q (sym (Iso.rightInv IsoABool x)\n ∙∙ cong (Iso.fun IsoABool) (¬false→true _ p)\n ∙∙ true→1)))\n ... | no p | yes q = inl q\n\n ≅Bool : GroupIso BoolGroup A\n ≅Bool .fst = IsoABool\n ≅Bool .snd = makeIsGroupHom homHelp\n where\n homHelp : _\n homHelp false false with discreteA (Iso.fun IsoABool false) (1g (snd A))\n | (decA ((Iso.fun IsoABool false) ·A Iso.fun IsoABool false))\n ... | yes p | _ = true→1 ∙∙ sym (GroupStr.·IdR (snd A) (1g (snd A))) ∙∙ cong₂ (_·A_) (sym p) (sym p)\n ... | no p | inl x = true→1 ∙ sym x\n ... | no p | inr x = true→1 ∙∙ sym (helper _ x) ∙∙ sym x\n where\n helper : (x : typ A) → x ·A x ≡ x → x ≡ (1g (snd A))\n helper x p = sym (GroupStr.·IdR (snd A) x)\n ∙∙ cong (x ·A_) (sym ((snd A) .·InvR x))\n ∙∙ ·AssocG (snd A) x x (-A x) ∙∙ cong (_·A (-A x)) p\n ∙∙ (snd A) .·InvR x\n homHelp false true = sym (GroupStr.·IdR (snd A) _) ∙ cong (Iso.fun IsoABool false ·A_) (sym true→1)\n homHelp true y = sym (GroupStr.·IdL (snd A) _) ∙ cong (_·A (Iso.fun IsoABool y)) (sym true→1)\n", "meta": {"hexsha": "57c5847ec68766c394f3d59972450e6dadca26a0", "size": 4210, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Group/Instances/Bool.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Group/Instances/Bool.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Group/Instances/Bool.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.6831683168, "max_line_length": 108, "alphanum_fraction": 0.6311163895, "num_tokens": 1427, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339516289534, "lm_q2_score": 0.7401743677704878, "lm_q1q2_score": 0.621549546742374}} {"text": "------------------------------------------------------------------------------\n-- From ListN as the least fixed-point to ListN using data\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- We want to represent the total lists of total natural numbers data\n-- type\n--\n-- data ListN : D → Set where\n-- lnnil : ListN []\n-- lncons : ∀ {n ns} → N n → ListN ns → ListN (n ∷ ns)\n--\n-- using the representation of ListN as the least fixed-point.\n\nmodule LFPs.ListN where\n\nopen import FOTC.Base\nopen import FOTC.Base.List\nopen import FOTC.Data.Nat.Type\nopen import FOTC.Data.Nat.UnaryNumbers\n\n------------------------------------------------------------------------------\n-- ListN is a least fixed-point of a functor\n\n-- The functor.\n-- ListNF : (D → Set) → D → Set\n-- ListNF P ns = ns ≡ [] ∨ (∃[ n' ] ∃[ ns' ] N n' ∧ ns ≡ n' ∷ ns' ∧ P ns')\n\n-- List is the least fixed-point of ListF.\npostulate\n ListN : D → Set\n\n -- ListN is a pre-fixed point of ListNF.\n --\n -- Peter: It corresponds to the introduction rules.\n ListN-in : ∀ {ns} →\n ns ≡ [] ∨ (∃[ n' ] ∃[ ns' ] N n' ∧ ns ≡ n' ∷ ns' ∧ ListN ns') →\n ListN ns\n\n -- ListN is the least pre-fixed point of ListFN.\n --\n -- Peter: It corresponds to the elimination rule of an inductively\n -- defined predicate.\n ListN-ind :\n (A : D → Set) →\n (∀ {ns} → ns ≡ [] ∨ (∃[ n' ] ∃[ ns' ] N n' ∧ ns ≡ n' ∷ ns' ∧ A ns') → A ns) →\n ∀ {ns} → ListN ns → A ns\n\n------------------------------------------------------------------------------\n-- The data constructors of List.\nlnnil : ListN []\nlnnil = ListN-in (inj₁ refl)\n\nlncons : ∀ {n ns} → N n → ListN ns → ListN (n ∷ ns)\nlncons {n} {ns} Nn LNns = ListN-in (inj₂ (n , ns , Nn , refl , LNns))\n\n------------------------------------------------------------------------------\n-- The induction principle for List.\nListN-ind' : (A : D → Set) →\n A [] →\n (∀ n {ns} → N n → A ns → A (n ∷ ns)) →\n ∀ {ns} → ListN ns → A ns\nListN-ind' A A[] is = ListN-ind A prf\n where\n prf : ∀ {ns} → ns ≡ [] ∨ (∃[ n' ] ∃[ ns' ] N n' ∧ ns ≡ n' ∷ ns' ∧ A ns') →\n A ns\n prf (inj₁ ns≡[]) = subst A (sym ns≡[]) A[]\n prf (inj₂ (n' , ns' , Nn' , h₁ , Ans')) = subst A (sym h₁) (is n' Nn' Ans')\n\n------------------------------------------------------------------------------\n-- Example\n\nys : D\nys = 0' ∷ 1' ∷ 2' ∷ []\n\nys-ListN : ListN ys\nys-ListN =\n lncons nzero (lncons (nsucc nzero) (lncons (nsucc (nsucc nzero)) lnnil))\n", "meta": {"hexsha": "e598eb24a306ac530b11366dd813ee492c87e563", "size": 2684, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/fixed-points/LFPs/ListN.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/fixed-points/LFPs/ListN.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/fixed-points/LFPs/ListN.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 32.3373493976, "max_line_length": 81, "alphanum_fraction": 0.4370342772, "num_tokens": 815, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.839733963661418, "lm_q2_score": 0.7401743563075446, "lm_q1q2_score": 0.6215495460226731}} {"text": "-- With functions are now inlined before termination checking.\nmodule Issue59 where\n\nopen import Common.Prelude\nopen import Common.Equality\n\nmodule Order (A : Set) (_≤_ : A → A → Bool) where\n\n -- This now termination checks.\n merge : List A → List A → List A\n merge [] ys = ys\n merge xs [] = xs\n merge (x ∷ xs) (y ∷ ys) with x ≤ y\n merge (x ∷ xs) (y ∷ ys) | false = y ∷ merge (x ∷ xs) ys\n merge (x ∷ []) (y ∷ ys) | true = x ∷ y ∷ ys\n merge (x ∷ x₁ ∷ xs) (y ∷ ys) | true = x ∷ merge (x₁ ∷ xs) (y ∷ ys)\n\ndata Ordering : Nat → Nat → Set where\n eq : ∀ n → Ordering n n\n lt : ∀ n d → Ordering n (n + suc d)\n gt : ∀ n d → Ordering (n + suc d) n\n\n-- Just make sure we didn't mess anything up when there are dot patterns.\n-- Andreas, 2013-11-11: But there are no recursive calls in the clauses\n-- with dot patterns!\n\ncompare : ∀ n m → Ordering n m\ncompare zero zero = eq zero\ncompare zero (suc m) = lt zero m\ncompare (suc n) zero = gt zero n\ncompare (suc n) (suc m) with compare n m\ncompare (suc n) (suc .(n + suc d)) | lt .n d = lt (suc n) d\ncompare (suc .(m + suc d)) (suc m) | gt .m d = gt (suc m) d\ncompare (suc n) (suc .n) | eq .n = eq (suc n)\n\n-- Rewrite\n\nplus-zero : ∀ n → n + 0 ≡ n\nplus-zero zero = refl\nplus-zero (suc n) rewrite plus-zero n = refl\n\nplus-suc : ∀ n m → n + suc m ≡ suc n + m\nplus-suc zero m = refl\nplus-suc (suc n) m rewrite plus-suc n m = refl\n\ncommute : ∀ m n → m + n ≡ n + m\ncommute m zero = plus-zero m\ncommute m (suc n) rewrite plus-suc m n | commute m n = refl\n", "meta": {"hexsha": "eba9c20436f17700dc9efbd568b4e783bb72972f", "size": 1516, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue59.agda", "max_stars_repo_name": "alhassy/agda", "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Succeed/Issue59.agda", "max_issues_repo_name": "alhassy/agda", "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/Issue59.agda", "max_forks_repo_name": "alhassy/agda", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 30.9387755102, "max_line_length": 73, "alphanum_fraction": 0.5949868074, "num_tokens": 557, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672135527632, "lm_q2_score": 0.7690802423634961, "lm_q1q2_score": 0.6214685284451541}} {"text": "module Helper.Fin where\n\nopen import Data.Fin hiding (_+_)\nopen import Data.Nat\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary\nopen import Relation.Nullary.Negation\n\n------------------------------------------------------------------------\n-- Fin magic\n------------------------------------------------------------------------\n\n+₁ : (x y : ℕ) (i : Fin x) -> Fin (x + y)\n+₁ zero y ()\n+₁ (suc x) y zero = zero\n+₁ (suc x) y (suc i) = suc (+₁ x y i)\n \n+₂ : (x y : ℕ) (j : Fin y) -> Fin (x + y)\n+₂ zero y j = j\n+₂ (suc x) y j = suc (+₂ x y j)\n\ndata Fin+ (x y : ℕ) : Fin (x + y) -> Set where\n is+₁ : (i : Fin x) -> Fin+ x y (+₁ x y i)\n is+₂ : (j : Fin y) -> Fin+ x y (+₂ x y j)\n\n⨁ : (x y : ℕ) (i : Fin (x + y)) -> Fin+ x y i\n⨁ zero y i = is+₂ i\n⨁ (suc x) y zero = is+₁ zero\n⨁ (suc x) y (suc i) with ⨁ x y i\n⨁ (suc x) y (suc ._) | is+₁ i = is+₁ (suc i)\n⨁ (suc x) y (suc ._) | is+₂ j = is+₂ j\n\n[_,_] : {X : Set} {x y : ℕ} (l : Fin x -> X) (r : Fin y -> X) -> {s : Fin (x + y)} -> Fin+ x y s -> X\n[_,_] l r {._} (is+₁ i) = l i\n[_,_] l r {._} (is+₂ j) = r j\n\n{-\n[_,_] : {X : Set} {x y : ℕ} (l : Fin x -> X) (r : Fin y -> X) -> (s : Fin (x + y)) -> X\n[_,_] {X} {x} {y} l r s with ⨁ x y s \n[_,_] l r ._ | is+₁ i = l i\n[_,_] l r ._ | is+₂ j = r j\n-}\n\n× : (x y : ℕ) (i : Fin x) (j : Fin y) -> Fin (x * y)\n× zero _ () _ \n× (suc x) y zero j = +₁ y (x * y) j\n× (suc x) y (suc i) j = +₂ y (x * y) (× x y i j)\n\ndata Fin* (x y : ℕ) : Fin (x * y) -> Set where\n is× : (i : Fin x) (j : Fin y) -> Fin* x y (× x y i j)\n\n⨂ : (x y : ℕ) (i : Fin (x * y)) -> Fin* x y i\n⨂ zero y ()\n⨂ (suc x) y i with ⨁ y (x * y) i\n⨂ (suc x) y ._ | is+₁ i = is× zero i\n⨂ (suc x) y ._ | is+₂ j with ⨂ x y j\n⨂ (suc x) y ._ | is+₂ ._ | is× i j = is× (suc i) j\n\n------------------------------------------------------------------------\n-- Fin lemma's\n------------------------------------------------------------------------\n\nsuc-eq : {n : ℕ} {x x₁ : Fin n} -> ((Data.Fin.suc x) ≡ (Data.Fin.suc x₁)) -> (x ≡ x₁)\nsuc-eq refl = refl\n\n+-eq : {n n₁ : ℕ} {x x₁ : Fin n} -> (m : Fin n₁) -> ((m Data.Fin.+ x) ≡ (m Data.Fin.+ x₁)) -> (x ≡ x₁)\n+-eq zero p = p\n+-eq (suc m) p = +-eq m (suc-eq p)\n\n+-eq₁ : {n n₁ : ℕ} {x x₁ : Fin n} -> (+₁ n n₁ x ≡ +₁ n n₁ x₁) -> (x ≡ x₁)\n+-eq₁ {x = zero} {x₁ = zero} p = refl\n+-eq₁ {x = zero} {suc x₁} ()\n+-eq₁ {x = suc x} {zero} ()\n+-eq₁ {x = suc x} {x₁ = suc x₁} p with +-eq (fromℕ 1) p\n... | p1 with +-eq₁ p1\n... | p2 = cong suc p2\n\n+-eq₂ : {n n₁ : ℕ} {x x₁ : Fin n₁} -> (+₂ n n₁ x ≡ +₂ n n₁ x₁) -> (x ≡ x₁)\n+-eq₂ {zero} refl = refl\n+-eq₂ {suc n} {suc n₁} {zero} {zero} refl = refl\n+-eq₂ {suc n} {suc n₁} {zero} {suc x₁} p with suc-eq p\n... | p1 = +-eq₂ {n} {suc n₁} p1\n+-eq₂ {suc n} {suc n₁} {suc x} {zero} p with suc-eq p\n... | p1 = +-eq₂ {n} {suc n₁} p1\n+-eq₂ {suc n} {suc n₁} {suc x} {suc x₁} p with suc-eq p\n... | p1 = +-eq₂ {n} {suc n₁} p1\n\n¬+-eq₁ : {n m : ℕ} {x : Fin n} {y : Fin m} -> ¬( (+₁ n m) x ≡ (+₂ n m) y)\n¬+-eq₁ {zero} {zero} {()}\n¬+-eq₁ {zero} {suc m} {()}\n¬+-eq₁ {suc n} {zero} {y = ()}\n¬+-eq₁ {suc n} {suc m} {zero} ()\n¬+-eq₁ {suc n} {suc m} {suc x} {zero} with ¬+-eq₁ {n} {suc m} {x} {zero}\n... | p1 = contraposition suc-eq p1\n¬+-eq₁ {suc n} {suc m} {suc x} {suc y} with ¬+-eq₁ {n} {suc m} {x} {suc y}\n... | p1 = contraposition suc-eq p1\n\n¬+-eq₂ : {n m : ℕ} {x : Fin n} {y : Fin m} -> ¬( (+₂ n m) y ≡ (+₁ n m) x)\n¬+-eq₂ {zero} {zero} {()} x₁\n¬+-eq₂ {zero} {suc m} {()} x₁\n¬+-eq₂ {suc n} {zero} {zero} ()\n¬+-eq₂ {suc n} {zero} {suc x} {()}\n¬+-eq₂ {suc n} {suc m} {zero} {zero} ()\n¬+-eq₂ {suc n} {suc m} {zero} {suc y} ()\n¬+-eq₂ {suc n} {suc m} {suc x} {zero} with ¬+-eq₂ {n} {suc m} {x} {zero}\n... | p1 = contraposition suc-eq p1\n¬+-eq₂ {suc n} {suc m} {suc x} {suc y} = contraposition suc-eq (¬+-eq₂ {n} {suc m} {x} {suc y})\n\n×-equal₁ : ∀ {n m : ℕ} {x₁ x₂ : Fin n} {y₁ y₂ : Fin m} -> (× n m x₁ y₁) ≡ (× n m x₂ y₂) -> (y₁ ≡ y₂)\n×-equal₁ {zero} {x₁ = ()} x \n×-equal₁ {suc n} {zero} {y₁ = ()} x\n×-equal₁ {suc n} {suc m} {zero} {zero} p = +-eq₁ p\n×-equal₁ {suc n} {suc m} {zero} {suc x₂} {zero} ()\n×-equal₁ {suc n} {suc m} {zero} {suc x₂} {suc y₁} p with suc-eq p\n... | p1 with ¬+-eq₁ {m} {(n * suc m)} p1\n×-equal₁ {suc n} {suc m} {zero} {suc x₂} {suc y₁} p | p1 | ()\n×-equal₁ {suc n} {suc m} {suc x₁} {zero} {zero} {zero} p = refl\n×-equal₁ {suc n} {suc m} {suc x₁} {zero} {zero} {suc y₂} p with suc-eq p\n... | p1 with ¬+-eq₂ p1\n×-equal₁ {suc n} {suc m} {suc x₁} {zero} {zero} {suc y₂} p | p1 | ()\n×-equal₁ {suc n} {suc m} {suc x₁} {zero} {suc y₁} {zero} ()\n×-equal₁ {suc n} {suc m} {suc x₁} {zero} {suc y₁} {suc y₂} p with suc-eq p\n... | p1 with ¬+-eq₂ p1\n×-equal₁ {suc n} {suc m} {suc x₁} {zero} {suc y₁} {suc y₂} p | p1 | ()\n×-equal₁ {suc n} {suc m} {suc x₁} {suc x₂} p with suc-eq p\n... | p2 with +-eq₂ {suc m} {(n * suc m)} p\n... | p3 = ×-equal₁ {n} {suc m} p3\n\n×-equal₂ : ∀ {n m : ℕ} {x₁ x₂ : Fin n} {y₁ y₂ : Fin m} -> (× n m x₁ y₁) ≡ (× n m x₂ y₂) -> (x₁ ≡ x₂)\n×-equal₂ {zero} {x₁ = ()} x \n×-equal₂ {suc n} {zero} {y₁ = ()} x\n×-equal₂ {suc n} {suc m} {zero} {zero} x = refl\n×-equal₂ {suc n} {suc m} {zero} {suc x₂} {zero} {zero} ()\n×-equal₂ {suc n} {suc m} {zero} {suc x₂} {zero} {suc y₂} ()\n×-equal₂ {suc n} {suc m} {zero} {suc x₂} {suc y₁} {zero} p with suc-eq p\n... | p1 with ¬+-eq₁ p1\n×-equal₂ {suc n} {suc m} {zero} {suc x₂} {suc y₁} {zero} p | p1 | ()\n×-equal₂ {suc n} {suc m} {zero} {suc x₂} {suc y₁} {suc y₂} p with suc-eq p\n... | p1 with ¬+-eq₁ p1\n×-equal₂ {suc n} {suc m} {zero} {suc x₂} {suc y₁} {suc y₂} p | p1 | ()\n×-equal₂ {suc n} {suc m} {suc x₁} {zero} {y₂ = zero} ()\n×-equal₂ {suc n} {suc m} {suc x₁} {zero} {zero} {suc y₂} p with suc-eq p\n... | p1 with ¬+-eq₂ p1\n×-equal₂ {suc n} {suc m} {suc x₁} {zero} {zero} {suc y₂} p | p1 | ()\n×-equal₂ {suc n} {suc m} {suc x₁} {zero} {suc y₁} {suc y₂} p with suc-eq p\n... | p1 with ¬+-eq₂ p1\n×-equal₂ {suc n} {suc m} {suc x₁} {zero} {suc y₁} {suc y₂} p | p1 | ()\n×-equal₂ {suc n} {suc m} {suc x₁} {suc x₂} p with suc-eq p\n... | p1 with +-eq₂ {m} {(n * suc m)} p1\n... | p2 with ×-equal₂ {n} {suc m} p2\n... | p3 = cong suc p3\n", "meta": {"hexsha": "ca93689d17690a9bc79ba18543f81833c0259019", "size": 6021, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Helper/Fin.agda", "max_stars_repo_name": "mathijsb/generic-in-agda", "max_stars_repo_head_hexsha": "cb95986b772b7a01195619be5e8e590f2429c759", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-06-09T09:59:27.000Z", "max_stars_repo_stars_event_max_datetime": "2016-08-04T16:05:24.000Z", "max_issues_repo_path": "Helper/Fin.agda", "max_issues_repo_name": "mathijsb/generic-in-agda", "max_issues_repo_head_hexsha": "cb95986b772b7a01195619be5e8e590f2429c759", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Helper/Fin.agda", "max_forks_repo_name": "mathijsb/generic-in-agda", "max_forks_repo_head_hexsha": "cb95986b772b7a01195619be5e8e590f2429c759", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.6118421053, "max_line_length": 102, "alphanum_fraction": 0.4580634446, "num_tokens": 3021, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8887587993853654, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.6214685252952614}} {"text": "open import Relation.Nullary using (yes; no; ¬_)\nopen import Relation.Nullary.Decidable using (True; False)\nopen import Relation.Nullary.Negation using (contradiction)\nopen import Relation.Binary using (Antisymmetric; Irrelevant; Decidable)\nopen import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; sym; cong; cong₂; module ≡-Reasoning)\nopen import Relation.Binary.PropositionalEquality.WithK using (≡-irrelevant)\nopen ≡-Reasoning\nopen import Function using (_$_)\n\nmodule AKS.Nat.GCD where\n\nopen import AKS.Nat.Base using (ℕ; _+_; _*_; zero; suc; _<_; _≤_; lte; _≟_; _∸_)\nopen import AKS.Nat.Properties using (≢⇒¬≟; ≤-antisym; <⇒≱)\nopen import Data.Nat.Properties using (*-distribʳ-∸; m+n∸n≡m)\nopen import AKS.Nat.Divisibility\n using (modₕ; _/_; _%_; n%m N\n nrec : N α (α,N).α -> α\n\ntheory\n (zeβ) z : α s : (α,N).α |> nrec (ze, z, r m. s[r,m]) = z\n (suβ) z : α s : (α,N).α n : N |> nrec (su (n), z, r m. s[r,m]) = s[nrec (n, z, r m. s[r,m]), n]\n-}\n\nmodule Naturals.Equality where\n\nopen import SOAS.Common\nopen import SOAS.Context\nopen import SOAS.Variable\nopen import SOAS.Families.Core\nopen import SOAS.Families.Build\nopen import SOAS.ContextMaps.Inductive\n\nopen import Naturals.Signature\nopen import Naturals.Syntax\n\nopen import SOAS.Metatheory.SecondOrder.Metasubstitution Nat:Syn\nopen import SOAS.Metatheory.SecondOrder.Equality Nat:Syn\n\nprivate\n variable\n α β γ τ : NatT\n Γ Δ Π : Ctx\n\ninfix 1 _▹_⊢_≋ₐ_\n\n-- Axioms of equality\ndata _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ Nat) α Γ → (𝔐 ▷ Nat) α Γ → Set where\n zeβ : ⁅ α ⁆ ⁅ α · N ⊩ α ⁆̣ ▹ ∅ ⊢ nrec ze 𝔞 (𝔟⟨ x₀ ◂ x₁ ⟩) ≋ₐ 𝔞\n suβ : ⁅ α ⁆ ⁅ α · N ⊩ α ⁆ ⁅ N ⁆̣ ▹ ∅ ⊢ nrec (su 𝔠) 𝔞 (𝔟⟨ x₀ ◂ x₁ ⟩) ≋ₐ 𝔟⟨ (nrec 𝔠 𝔞 (𝔟⟨ x₀ ◂ x₁ ⟩)) ◂ 𝔠 ⟩\n\nopen EqLogic _▹_⊢_≋ₐ_\nopen ≋-Reasoning\n", "meta": {"hexsha": "285aa4132da76121ad42dc2ba15173c052b52c8d", "size": 1177, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "out/Naturals/Equality.agda", "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_issues_repo_path": "out/Naturals/Equality.agda", "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_forks_repo_path": "out/Naturals/Equality.agda", "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "avg_line_length": 24.5208333333, "max_line_length": 107, "alphanum_fraction": 0.5981308411, "num_tokens": 539, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8499711908591638, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.621378730665953}} {"text": "\nopen import Oscar.Prelude\nopen import Oscar.Class.IsPrecategory\nopen import Oscar.Class.Transitivity\n\nmodule Oscar.Class.Precategory where\n\nrecord Precategory 𝔬 𝔯 ℓ : Ø ↑̂ (𝔬 ∙̂ 𝔯 ∙̂ ℓ) where\n constructor ∁\n infix 4 _∼̇_\n field\n {𝔒} : Ø 𝔬\n _∼_ : 𝔒 → 𝔒 → Ø 𝔯\n _∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ\n _↦_ : Transitivity.type _∼_\n ⦃ `IsPrecategory ⦄ : IsPrecategory _∼_ _∼̇_ _↦_\n", "meta": {"hexsha": "d0afccfbfa6f68adec2b7f43f1dc521223a90b26", "size": 393, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Precategory.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Precategory.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Precategory.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.1176470588, "max_line_length": 51, "alphanum_fraction": 0.6183206107, "num_tokens": 185, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9241418241572634, "lm_q2_score": 0.6723316991792861, "lm_q1q2_score": 0.621329842918298}} {"text": "\nmodule Sets where\n\n import Equality\n open Equality public\n\n infixr 10 _$_\n infixr 40 _[+]_ _<+>_ _>+<_\n infixr 60 _[×]_ _<×>_ _>×<_\n infixr 90 _∘_\n\n id : {A : Set} -> A -> A\n id x = x\n\n _∘_ : {A B C : Set} -> (B -> C) -> (A -> B) -> A -> C\n f ∘ g = \\x -> f (g x)\n\n _$_ : {A B : Set} -> (A -> B) -> A -> B\n f $ x = f x\n\n data _[+]_ (A B : Set) : Set where\n inl : A -> A [+] B\n inr : B -> A [+] B\n\n _<+>_ : {A₁ A₂ B₁ B₂ : Set} -> (A₁ -> A₂) -> (B₁ -> B₂) -> A₁ [+] B₁ -> A₂ [+] B₂\n (f <+> g) (inl x) = inl (f x)\n (f <+> g) (inr y) = inr (g y)\n\n _>+<_ : {A B C : Set} -> (A -> C) -> (B -> C) -> A [+] B -> C\n (f >+< g) (inl x) = f x\n (f >+< g) (inr y) = g y\n\n data _[×]_ (A B : Set) : Set where\n <_,_> : A -> B -> A [×] B\n\n -- sections\n <∙,_> : {A B : Set} -> B -> A -> A [×] B\n <∙, x > = \\y -> < y , x >\n\n <_,∙> : {A B : Set} -> A -> B -> A [×] B\n < x ,∙> = \\y -> < x , y >\n\n _<×>_ : {A₁ A₂ B₁ B₂ : Set} -> (A₁ -> A₂) -> (B₁ -> B₂) -> A₁ [×] B₁ -> A₂ [×] B₂\n (f <×> g) < x , y > = < f x , g y >\n\n _>×<_ : {A B C : Set} -> (A -> B) -> (A -> C) -> A -> B [×] C\n (f >×< g) x = < f x , g x >\n\n fst : {A B : Set} -> A [×] B -> A\n fst < a , b > = a\n\n snd : {A B : Set} -> A [×] B -> B\n snd < a , b > = b\n\n η-[×] : {A B : Set}(p : A [×] B) -> p == < fst p , snd p >\n η-[×] < a , b > = refl\n\n data [1] : Set where\n <> : [1]\n\n data [0] : Set where\n\n data List (A : Set) : Set where\n [] : List A\n _::_ : A -> List A -> List A\n\n", "meta": {"hexsha": "49a371521358f6f6b0a209ddab83df9877a91d13", "size": 1474, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/clowns/Sets.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/clowns/Sets.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/outdated-and-incorrect/clowns/Sets.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 22.0, "max_line_length": 83, "alphanum_fraction": 0.3385345997, "num_tokens": 745, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473813156294, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.6213138861380367}} {"text": "module examples.Vec where\n {- Computed datatypes -}\n data One : Set where\n unit : One\n\n data Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\n data _*_ (A B : Set) : Set where\n pair : A -> B -> A * B\n\n infixr 20 _=>_\n data _=>_ (A B : Set) : Set where\n lam : (A -> B) -> A => B\n\n lam2 : {A B C : Set} -> (A -> B -> C) -> (A => B => C)\n lam2 f = lam (\\x -> lam (f x))\n\n app : {A B : Set} -> (A => B) -> A -> B\n app (lam f) x = f x\n\n Vec : Nat -> Set -> Set\n Vec zero X = One\n Vec (suc n) X = X * Vec n X\n\n {- ... construct the vectors of a given length -}\n\n vHead : {X : Set} -> (n : Nat)-> Vec (suc n) X -> X\n vHead n (pair a b) = a\n\n vTail : {X : Set} -> (n : Nat)-> Vec (suc n) X -> Vec n X\n vTail n (pair a b) = b\n\n {- safe destructors for nonempty vectors -}\n\n {- useful vector programming operators -}\n\n vec : {X : Set} -> (n : Nat) -> X -> Vec n X\n vec zero x = unit\n vec (suc n) x = pair x (vec n x)\n\n vapp : {S T : Set} -> (n : Nat) -> Vec n (S => T) -> Vec n S -> Vec n T\n vapp zero unit unit = unit\n vapp (suc n) (pair f fs) (pair s ss) = pair (app f s) (vapp n fs ss)\n\n {- mapping and zipping come from these -}\n\n vMap : {S T : Set} -> (n : Nat) -> (S -> T) -> Vec n S -> Vec n T\n vMap n f ss = vapp n (vec n (lam f)) ss\n\n {- transposition gets the type it deserves -}\n\n transpose : {X : Set} -> (m n : Nat)-> Vec m (Vec n X) -> Vec n (Vec m X)\n transpose zero n xss = vec n unit\n transpose (suc m) n (pair xs xss) =\n vapp n (vapp n (vec n (lam2 pair)) xs)\n\t (transpose m n xss)\n\n {- Sets of a given finite size may be computed as follows... -}\n\n {- Resist the temptation to mention idioms. -}\n\n data Zero : Set where\n\n data _+_ (A B : Set) : Set where\n inl : A -> A + B\n inr : B -> A + B\n\n Fin : Nat -> Set\n Fin zero = Zero\n Fin (suc n) = One + Fin n\n\n {- We can use these sets to index vectors safely. -}\n\n vProj : {X : Set} -> (n : Nat)-> Vec n X -> Fin n -> X\n -- vProj zero () we can pretend that there is an exhaustiveness check\n vProj (suc n) (pair x xs) (inl unit) = x\n vProj (suc n) (pair x xs) (inr i) = vProj n xs i\n\n {- We can also tabulate a function as a vector. Resist\n the temptation to mention logarithms. -}\n\n vTab : {X : Set} -> (n : Nat)-> (Fin n -> X) -> Vec n X\n vTab zero _ = unit\n vTab (suc n) f = pair (f (inl unit)) (vTab n (\\x -> f (inr x)))\n\n {- Question to ponder in your own time:\n if we use functional vectors what are vec and vapp -}\n\n {- Answer: K and S -}\n\n {- Inductive datatypes of the unfocused variety -}\n\n {- Every constructor must target the whole family rather\n than focusing on specific indices. -}\n\n data Tm (n : Nat) : Set where\n evar : Fin n -> Tm n\n eapp : Tm n -> Tm n -> Tm n\n elam : Tm (suc n) -> Tm n\n\n {- Renamings -}\n\n Ren : Nat -> Nat -> Set\n Ren m n = Vec m (Fin n)\n\n _`Ren`_ = Ren\n\n {- identity and composition -}\n\n idR : (n : Nat) -> n `Ren` n\n idR n = vTab n (\\i -> i)\n\n coR : (l m n : Nat) -> m `Ren` n -> l `Ren` m -> l `Ren` n\n coR l m n m2n l2m = vMap l (vProj m m2n) l2m\n\n {- what theorems should we prove -}\n\n {- the lifting functor for Ren -}\n\n liftR : (m n : Nat) -> m `Ren` n -> suc m `Ren` suc n\n liftR m n m2n = pair (inl unit) (vMap m inr m2n)\n\n {- what theorems should we prove -}\n\n {- the functor from Ren to Tm-arrows -}\n\n rename : {m n : Nat} -> (m `Ren` n) -> Tm m -> Tm n\n rename {m}{n} m2n (evar i) = evar (vProj m m2n i)\n rename {m}{n} m2n (eapp f s) = eapp (rename m2n f) (rename m2n s)\n rename {m}{n} m2n (elam t) = elam (rename (liftR m n m2n) t)\n\n {- Substitutions -}\n\n Sub : Nat -> Nat -> Set\n Sub m n = Vec m (Tm n)\n\n _`Sub`_ = Sub\n\n {- identity; composition must wait; why -}\n\n idS : (n : Nat) -> n `Sub` n\n idS n = vTab n (evar {n})\n\n {- functor from renamings to substitutions -}\n\n Ren2Sub : (m n : Nat) -> m `Ren` n -> m `Sub` n\n Ren2Sub m n m2n = vMap m evar m2n\n\n {- lifting functor for substitution -}\n\n liftS : (m n : Nat) -> m `Sub` n -> suc m `Sub` suc n\n liftS m n m2n = pair (evar (inl unit))\n\t\t (vMap m (rename (vMap n inr (idR n))) m2n)\n\n {- functor from Sub to Tm-arrows -}\n\n subst : {m n : Nat} -> m `Sub` n -> Tm m -> Tm n\n subst {m}{n} m2n (evar i) = vProj m m2n i\n subst {m}{n} m2n (eapp f s) = eapp (subst m2n f) (subst m2n s)\n subst {m}{n} m2n (elam t) = elam (subst (liftS m n m2n) t)\n\n {- and now we can define composition -}\n\n coS : (l m n : Nat) -> m `Sub` n -> l `Sub` m -> l `Sub` n\n coS l m n m2n l2m = vMap l (subst m2n) l2m\n\n", "meta": {"hexsha": "afe5ee1d7b10e1db5673712b7bdc987f0459cd69", "size": 4519, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/Alonzo/Vec.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "examples/outdated-and-incorrect/Alonzo/Vec.agda", "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/Alonzo/Vec.agda", "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 26.7396449704, "max_line_length": 75, "alphanum_fraction": 0.5399424651, "num_tokens": 1743, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473813156294, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.6213138861380367}} {"text": "module TestVec where\nopen import PreludeNatType\nopen import PreludeShow\n\ninfixr 40 _::_\n\ndata Vec (A : Set) : Nat -> Set where\n [] : Vec A zero\n _::_ : {n : Nat} -> A -> Vec A n -> Vec A (suc n)\n\nhead : {A : Set}{n : Nat} -> Vec A (suc n) -> A\nhead (x :: _) = x -- no need for a [] case\n\nlength : {A : Set}{n : Nat} -> Vec A n -> Nat\nlength {A} {n} v = n\n\nthree : Vec Nat 3\nthree = 1 :: 2 :: 3 :: []\n\nmainS = showNat (length three)", "meta": {"hexsha": "aa159c7cfd74a63487046b0f8303921d129eb729", "size": 441, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/Alonzo/TestVec.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/Alonzo/TestVec.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/Alonzo/TestVec.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.05, "max_line_length": 53, "alphanum_fraction": 0.5442176871, "num_tokens": 164, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.872347368040789, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.6213138766832681}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Binary Trees\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Tree.Binary where\n\nopen import Level using (Level; _⊔_)\nopen import Data.List.Base using (List)\nopen import Data.DifferenceList as DiffList using (DiffList; []; _∷_; _∷ʳ_; _++_)\nopen import Data.Nat.Base using (ℕ; zero; suc; _+_)\nopen import Function.Base\nopen import Relation.Binary.PropositionalEquality\n\nprivate\n variable\n a b : Level\n A : Set a\n B : Set b\n\ndata Tree (A : Set a) : Set a where\n leaf : Tree A\n node : Tree A → A → Tree A → Tree A\n\nmap : (A → B) → Tree A → Tree B\nmap f leaf = leaf\nmap f (node l m r) = node (map f l) (f m) (map f r)\n\nsize : Tree A → ℕ\nsize leaf = 0\nsize (node l m r) = size l + suc (size r)\n\nfoldr : (B → A → B → B) → B → Tree A → B\nfoldr nd lf leaf = lf\nfoldr nd lf (node l m r) = nd (foldr nd lf l) m (foldr nd lf r)\n\n------------------------------------------------------------------------\n-- Extraction to lists, depth first and left to right.\n\nmodule Prefix where\n\n toDiffList : Tree A → DiffList A\n toDiffList = foldr (λ l m r → m ∷ l ++ r) []\n\n toList : Tree A → List A\n toList = DiffList.toList ∘′ toDiffList\n\nmodule Infix where\n\n toDiffList : Tree A → DiffList A\n toDiffList = foldr (λ l m r → l ++ m ∷ r) []\n\n toList : Tree A → List A\n toList = DiffList.toList ∘′ toDiffList\n\nmodule Suffix where\n\n toDiffList : Tree A → DiffList A\n toDiffList = foldr (λ l m r → l ++ r ∷ʳ m) []\n\n toList : Tree A → List A\n toList = DiffList.toList ∘′ toDiffList\n", "meta": {"hexsha": "15e82a66b5b59d83134401830640d86b7af1ec6b", "size": 1682, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/Tree/Binary.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Data/Tree/Binary.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Data/Tree/Binary.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 25.4848484848, "max_line_length": 81, "alphanum_fraction": 0.5434007134, "num_tokens": 499, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933535169629, "lm_q2_score": 0.7577943712746406, "lm_q1q2_score": 0.6213105683406435}} {"text": "{-\n\nTheory about isomorphisms\n\n- Definitions of [section] and [retract]\n- Definition of isomorphisms ([Iso])\n- Any isomorphism is an equivalence ([isoToEquiv])\n\n-}\n{-# OPTIONS --safe #-}\nmodule Cubical.Foundations.Isomorphism where\n\nopen import Cubical.Core.Everything\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.Equiv.Base\n\nprivate\n variable\n ℓ ℓ' : Level\n A B C : Type ℓ\n\n-- Section and retract\nmodule _ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} where\n section : (f : A → B) → (g : B → A) → Type ℓ'\n section f g = ∀ b → f (g b) ≡ b\n\n -- NB: `g` is the retraction!\n retract : (f : A → B) → (g : B → A) → Type ℓ\n retract f g = ∀ a → g (f a) ≡ a\n\nrecord Iso {ℓ ℓ'} (A : Type ℓ) (B : Type ℓ') : Type (ℓ-max ℓ ℓ') where\n no-eta-equality\n constructor iso\n field\n fun : A → B\n inv : B → A\n rightInv : section fun inv\n leftInv : retract fun inv\n\nisIso : (A → B) → Type _\nisIso {A = A} {B = B} f = Σ[ g ∈ (B → A) ] Σ[ _ ∈ section f g ] retract f g\n\nisoFunInjective : (f : Iso A B) → (x y : A) → Iso.fun f x ≡ Iso.fun f y → x ≡ y\nisoFunInjective f x y h = sym (Iso.leftInv f x) ∙∙ cong (Iso.inv f) h ∙∙ Iso.leftInv f y\n\nisoInvInjective : (f : Iso A B) → (x y : B) → Iso.inv f x ≡ Iso.inv f y → x ≡ y\nisoInvInjective f x y h = sym (Iso.rightInv f x) ∙∙ cong (Iso.fun f) h ∙∙ Iso.rightInv f y\n\n-- Any iso is an equivalence\nmodule _ (i : Iso A B) where\n open Iso i renaming ( fun to f\n ; inv to g\n ; rightInv to s\n ; leftInv to t)\n\n private\n module _ (y : B) (x0 x1 : A) (p0 : f x0 ≡ y) (p1 : f x1 ≡ y) where\n fill0 : I → I → A\n fill0 i = hfill (λ k → λ { (i = i1) → t x0 k\n ; (i = i0) → g y })\n (inS (g (p0 (~ i))))\n\n fill1 : I → I → A\n fill1 i = hfill (λ k → λ { (i = i1) → t x1 k\n ; (i = i0) → g y })\n (inS (g (p1 (~ i))))\n\n fill2 : I → I → A\n fill2 i = hfill (λ k → λ { (i = i1) → fill1 k i1\n ; (i = i0) → fill0 k i1 })\n (inS (g y))\n\n p : x0 ≡ x1\n p i = fill2 i i1\n\n sq : I → I → A\n sq i j = hcomp (λ k → λ { (i = i1) → fill1 j (~ k)\n ; (i = i0) → fill0 j (~ k)\n ; (j = i1) → t (fill2 i i1) (~ k)\n ; (j = i0) → g y })\n (fill2 i j)\n\n sq1 : I → I → B\n sq1 i j = hcomp (λ k → λ { (i = i1) → s (p1 (~ j)) k\n ; (i = i0) → s (p0 (~ j)) k\n ; (j = i1) → s (f (p i)) k\n ; (j = i0) → s y k })\n (f (sq i j))\n\n lemIso : (x0 , p0) ≡ (x1 , p1)\n lemIso i .fst = p i\n lemIso i .snd = λ j → sq1 i (~ j)\n\n isoToIsEquiv : isEquiv f\n isoToIsEquiv .equiv-proof y .fst .fst = g y\n isoToIsEquiv .equiv-proof y .fst .snd = s y\n isoToIsEquiv .equiv-proof y .snd z = lemIso y (g y) (fst z) (s y) (snd z)\n\n\nisoToEquiv : Iso A B → A ≃ B\nisoToEquiv i .fst = i .Iso.fun\nisoToEquiv i .snd = isoToIsEquiv i\n\nisoToPath : Iso A B → A ≡ B\nisoToPath {A = A} {B = B} f i =\n Glue B (λ { (i = i0) → (A , isoToEquiv f)\n ; (i = i1) → (B , idEquiv B) })\n\nopen Iso\n\ninvIso : Iso A B → Iso B A\nfun (invIso f) = inv f\ninv (invIso f) = fun f\nrightInv (invIso f) = leftInv f\nleftInv (invIso f) = rightInv f\n\ncompIso : Iso A B → Iso B C → Iso A C\nfun (compIso i j) = fun j ∘ fun i\ninv (compIso i j) = inv i ∘ inv j\nrightInv (compIso i j) b = cong (fun j) (rightInv i (inv j b)) ∙ rightInv j b\nleftInv (compIso i j) a = cong (inv i) (leftInv j (fun i a)) ∙ leftInv i a\n\ncomposesToId→Iso : (G : Iso A B) (g : B → A) → G .fun ∘ g ≡ idfun B → Iso B A\nfun (composesToId→Iso _ g _) = g\ninv (composesToId→Iso j _ _) = fun j\nrightInv (composesToId→Iso i g path) b =\n sym (leftInv i (g (fun i b))) ∙∙ cong (λ g → inv i (g (fun i b))) path ∙∙ leftInv i b\nleftInv (composesToId→Iso _ _ path) b i = path i b\n\nidIso : Iso A A\nfun idIso = idfun _\ninv idIso = idfun _\nrightInv idIso _ = refl\nleftInv idIso _ = refl\n\nLiftIso : Iso A (Lift {i = ℓ} {j = ℓ'} A)\nfun LiftIso = lift\ninv LiftIso = lower\nrightInv LiftIso _ = refl\nleftInv LiftIso _ = refl\n\nisContr→Iso : isContr A → isContr B → Iso A B\nfun (isContr→Iso _ Bctr) _ = Bctr .fst\ninv (isContr→Iso Actr _) _ = Actr .fst\nrightInv (isContr→Iso _ Bctr) = Bctr .snd\nleftInv (isContr→Iso Actr _) = Actr .snd\n\nisProp→Iso : (Aprop : isProp A) (Bprop : isProp B) (f : A → B) (g : B → A) → Iso A B\nfun (isProp→Iso _ _ f _) = f\ninv (isProp→Iso _ _ _ g) = g\nrightInv (isProp→Iso _ Bprop f g) b = Bprop (f (g b)) b\nleftInv (isProp→Iso Aprop _ f g) a = Aprop (g (f a)) a\n\ndomIso : ∀ {ℓ} {C : Type ℓ} → Iso A B → Iso (A → C) (B → C)\nfun (domIso e) f b = f (inv e b)\ninv (domIso e) f a = f (fun e a)\nrightInv (domIso e) f i x = f (rightInv e x i)\nleftInv (domIso e) f i x = f (leftInv e x i)\n\n-- Helpful notation\n_Iso⟨_⟩_ : ∀ {ℓ ℓ' ℓ''} {B : Type ℓ'} {C : Type ℓ''} (X : Type ℓ) → Iso X B → Iso B C → Iso X C\n_ Iso⟨ f ⟩ g = compIso f g\n\n_∎Iso : ∀ {ℓ} (A : Type ℓ) → Iso A A\nA ∎Iso = idIso {A = A}\n\ninfixr 0 _Iso⟨_⟩_\ninfix 1 _∎Iso\n\ncodomainIsoDep : ∀ {ℓ ℓ' ℓ''} {A : Type ℓ} {B : A → Type ℓ'} {C : A → Type ℓ''}\n → ((a : A) → Iso (B a) (C a))\n → Iso ((a : A) → B a) ((a : A) → C a)\nfun (codomainIsoDep is) f a = fun (is a) (f a)\ninv (codomainIsoDep is) f a = inv (is a) (f a)\nrightInv (codomainIsoDep is) f = funExt λ a → rightInv (is a) (f a)\nleftInv (codomainIsoDep is) f = funExt λ a → leftInv (is a) (f a)\n\ncodomainIso : ∀ {ℓ ℓ' ℓ''} {A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''}\n → Iso B C\n → Iso (A → B) (A → C)\ncodomainIso z = codomainIsoDep λ _ → z\n\n\nIso≡Set : isSet A → isSet B → (f g : Iso A B)\n → ((x : A) → f .fun x ≡ g .fun x)\n → ((x : B) → f .inv x ≡ g .inv x)\n → f ≡ g\nfun (Iso≡Set hA hB f g hfun hinv i) x = hfun x i\ninv (Iso≡Set hA hB f g hfun hinv i) x = hinv x i\nrightInv (Iso≡Set hA hB f g hfun hinv i) x j =\n isSet→isSet' hB (rightInv f x) (rightInv g x) (λ i → hfun (hinv x i) i) refl i j\nleftInv (Iso≡Set hA hB f g hfun hinv i) x j =\n isSet→isSet' hA (leftInv f x) (leftInv g x) (λ i → hinv (hfun x i) i) refl i j\n", "meta": {"hexsha": "52d9c36f3612005abb9081d14d88b654bd473ebb", "size": 6323, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Foundations/Isomorphism.agda", "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Foundations/Isomorphism.agda", "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Foundations/Isomorphism.agda", "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.2602040816, "max_line_length": 95, "alphanum_fraction": 0.5090937846, "num_tokens": 2547, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789040926008, "lm_q2_score": 0.7662936430859597, "lm_q1q2_score": 0.6210648320614353}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Decidable setoid membership over vectors.\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary using (DecSetoid)\n\nmodule Data.Vec.Membership.DecSetoid {c ℓ} (DS : DecSetoid c ℓ) where\n\nopen import Data.Vec using (Vec)\nopen import Data.Vec.Relation.Unary.Any using (any)\nopen import Relation.Nullary using (Dec)\nopen DecSetoid DS renaming (Carrier to A)\n\n------------------------------------------------------------------------\n-- Re-export contents of propositional membership\n\nopen import Data.Vec.Membership.Setoid setoid public\n\n------------------------------------------------------------------------\n-- Other operations\n\ninfix 4 _∈?_\n\n_∈?_ : ∀ x {n} (xs : Vec A n) → Dec (x ∈ xs)\nx ∈? xs = any (x ≟_) xs\n", "meta": {"hexsha": "f8b7abd5d88df66cde09f50297bd4f2e03152026", "size": 902, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/Membership/DecSetoid.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/Membership/DecSetoid.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/Membership/DecSetoid.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.0666666667, "max_line_length": 72, "alphanum_fraction": 0.4822616408, "num_tokens": 185, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8840392756357326, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.621064168557904}} {"text": "{-# OPTIONS --without-K --safe #-}\n\n\nmodule Loop.Bundles where\n\nopen import Algebra.Core\nopen import Relation.Binary\nopen import Level\nopen import Loop.Structures\nopen import Algebra.Bundles\nopen import Algebra.Structures\n\nrecord LeftBolLoop c ℓ : Set (suc (c ⊔ ℓ)) where\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ\n _∙_ : Op₂ Carrier\n _\\\\_ : Op₂ Carrier\n _//_ : Op₂ Carrier\n ε : Carrier\n isLeftBolLoop : IsLeftBolLoop _≈_ _∙_ _\\\\_ _//_ ε\n\n open IsLeftBolLoop isLeftBolLoop public\n\n loop : Loop _ _\n loop = record { isLoop = isLoop }\n\n open Loop loop public\n using (quasigroup)\n\nrecord RightBolLoop c ℓ : Set (suc (c ⊔ ℓ)) where\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ\n _∙_ : Op₂ Carrier\n _\\\\_ : Op₂ Carrier\n _//_ : Op₂ Carrier\n ε : Carrier\n isRightBolLoop : IsRightBolLoop _≈_ _∙_ _\\\\_ _//_ ε\n\n open IsRightBolLoop isRightBolLoop public\n\n loop : Loop _ _\n loop = record { isLoop = isLoop }\n\n open Loop loop public\n using (quasigroup)\n\nrecord MoufangLoop c ℓ : Set (suc (c ⊔ ℓ)) where\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ\n _∙_ : Op₂ Carrier\n _\\\\_ : Op₂ Carrier\n _//_ : Op₂ Carrier\n ε : Carrier\n isMoufangLoop : IsMoufangLoop _≈_ _∙_ _\\\\_ _//_ ε\n\n open IsMoufangLoop isMoufangLoop public\n\n loop : Loop _ _\n loop = record { isLoop = isLoop }\n\n open Loop loop public\n using (quasigroup)\n", "meta": {"hexsha": "d16e8a77750c9c89f39b03ea7940dbb574d1cb43", "size": 1448, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Loop/Bundles.agda", "max_stars_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra", "max_stars_repo_head_hexsha": "443e831e536b756acbd1afd0d6bae7bc0d288048", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-08-15T06:16:13.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-17T09:14:03.000Z", "max_issues_repo_path": "src/Loop/Bundles.agda", "max_issues_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra", "max_issues_repo_head_hexsha": "443e831e536b756acbd1afd0d6bae7bc0d288048", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-10-04T05:30:30.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-09T08:24:56.000Z", "max_forks_repo_path": "src/Loop/Bundles.agda", "max_forks_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra", "max_forks_repo_head_hexsha": "443e831e536b756acbd1afd0d6bae7bc0d288048", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.9393939394, "max_line_length": 56, "alphanum_fraction": 0.6243093923, "num_tokens": 505, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392909114835, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.6210641682777439}} {"text": "-- Andreas, 2015-12-10, issue reported by Andrea Vezzosi\n\nopen import Common.Equality\nopen import Common.Bool\n\nid : Bool → Bool\nid true = true\nid false = false\n\nis-id : ∀ x → x ≡ id x\nis-id true = refl\nis-id false = refl\n\npostulate\n P : Bool → Set\n b : Bool\n p : P (id b)\n\nproof : P b\nproof rewrite is-id b = p\n", "meta": {"hexsha": "478dc932ec6e61f96c2ecca03135ebf691c10ea2", "size": 316, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue520.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue520.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue520.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 15.0476190476, "max_line_length": 56, "alphanum_fraction": 0.6487341772, "num_tokens": 109, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8840392695254319, "lm_q2_score": 0.7025300636233415, "lm_q1q2_score": 0.621064164265234}} {"text": "{-# OPTIONS --cubical-compatible --rewriting --confluence-check #-}\n\npostulate\n _↦_ : {A : Set} → A → A → Set\n{-# BUILTIN REWRITE _↦_ #-}\n\ndata _==_ {A : Set} (a : A) : A → Set where\n idp : a == a\n\nPathOver : {A : Set} (B : A → Set)\n {x y : A} (p : x == y) (u : B x) (v : B y) → Set\nPathOver B idp u v = (u == v)\n\ninfix 30 PathOver\nsyntax PathOver B p u v =\n u == v [ B ↓ p ]\n\napd : {A : Set} {B : A → Set} (f : (a : A) → B a) {x y : A}\n → (p : x == y) → f x == f y [ B ↓ p ]\napd f idp = idp\n\nmodule Disk where\n\nmodule _ where\n\n postulate -- HIT\n Disk : Set\n baseD : Disk\n loopD : baseD == baseD\n drumD : loopD == idp\n\n module DiskElim {P : Disk → Set}\n (baseD* : P baseD )\n (loopD* : baseD* == baseD* [ P ↓ loopD ] )\n (drumD* : loopD* == idp [ ((λ p → baseD* == baseD* [ P ↓ p ] ) ) ↓ drumD ] ) where\n\n postulate\n f : (x : Disk) → P x\n baseD-β : f baseD ↦ baseD*\n {-# REWRITE baseD-β #-}\n\n postulate\n loopD-ι : apd f loopD ↦ loopD*\n {-# REWRITE loopD-ι #-}\n\n postulate\n drumD-ι : apd (apd f) drumD ↦ drumD*\n {-# REWRITE drumD-ι #-}\n\n loopD-β : apd f loopD == loopD*\n loopD-β = idp\n\n drumD-β : apd (apd f) drumD == drumD*\n drumD-β = idp\n", "meta": {"hexsha": "d5d3791987707f96c39ff37161420e4b4b7a8d82", "size": 1217, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue2549.agda", "max_stars_repo_name": "KDr2/agda", "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/Succeed/Issue2549.agda", "max_issues_repo_name": "KDr2/agda", "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_forks_repo_path": "test/Succeed/Issue2549.agda", "max_forks_repo_name": "KDr2/agda", "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.1272727273, "max_line_length": 86, "alphanum_fraction": 0.4954806902, "num_tokens": 498, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392909114836, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.6210641627718266}} {"text": "{-# OPTIONS --without-K --safe #-}\nopen import Categories.Category\n\n-- Properties relating Initial and Terminal Objects,\n-- Product / Coproduct, Zero objects, and Kernel / Cokernel via op\nmodule Categories.Object.Duality {o ℓ e} (C : Category o ℓ e) where\n\nopen Category C\n\nopen import Level\nopen import Relation.Binary.PropositionalEquality as ≡ using (_≡_)\n\nopen import Categories.Morphism C\nopen import Categories.Object.Terminal op\nopen import Categories.Object.Initial C\nopen import Categories.Object.Product op\nopen import Categories.Object.Coproduct C\n\nopen import Categories.Object.Zero\n\nimport Categories.Object.Kernel as Kernels\nimport Categories.Object.Cokernel as Cokernels\n\nprivate\n variable\n A B X Z : Obj\n f g k : A ⇒ B\n\nIsInitial⇒coIsTerminal : IsInitial X → IsTerminal X\nIsInitial⇒coIsTerminal is⊥ = record\n { ! = !\n ; !-unique = !-unique\n }\n where open IsInitial is⊥\n\n⊥⇒op⊤ : Initial → Terminal\n⊥⇒op⊤ i = record\n { ⊤ = ⊥\n ; ⊤-is-terminal = IsInitial⇒coIsTerminal ⊥-is-initial\n }\n where open Initial i\n\ncoIsTerminal⇒IsInitial : IsTerminal X → IsInitial X\ncoIsTerminal⇒IsInitial is⊤ = record\n { ! = !\n ; !-unique = !-unique\n }\n where open IsTerminal is⊤\n\nop⊤⇒⊥ : Terminal → Initial\nop⊤⇒⊥ t = record\n { ⊥ = ⊤\n ; ⊥-is-initial = coIsTerminal⇒IsInitial ⊤-is-terminal\n }\n where open Terminal t\n\nCoproduct⇒coProduct : Coproduct A B → Product A B\nCoproduct⇒coProduct A+B = record\n { A×B = A+B.A+B\n ; π₁ = A+B.i₁\n ; π₂ = A+B.i₂\n ; ⟨_,_⟩ = A+B.[_,_]\n ; project₁ = A+B.inject₁\n ; project₂ = A+B.inject₂\n ; unique = A+B.unique\n }\n where\n module A+B = Coproduct A+B\n\ncoProduct⇒Coproduct : ∀ {A B} → Product A B → Coproduct A B\ncoProduct⇒Coproduct A×B = record\n { A+B = A×B.A×B\n ; i₁ = A×B.π₁\n ; i₂ = A×B.π₂\n ; [_,_] = A×B.⟨_,_⟩\n ; inject₁ = A×B.project₁\n ; inject₂ = A×B.project₂\n ; unique = A×B.unique\n }\n where\n module A×B = Product A×B\n\n-- Zero objects are autodual\nIsZero⇒coIsZero : IsZero C Z → IsZero op Z\nIsZero⇒coIsZero is-zero = record\n { isInitial = record { ! = ! ; !-unique = !-unique }\n ; isTerminal = record { ! = ¡ ; !-unique = ¡-unique }\n }\n where\n open IsZero is-zero\n\ncoIsZero⇒IsZero : IsZero op Z → IsZero C Z\ncoIsZero⇒IsZero co-is-zero = record\n { isInitial = record { ! = ! ; !-unique = !-unique }\n ; isTerminal = record { ! = ¡ ; !-unique = ¡-unique }\n }\n where\n open IsZero co-is-zero\n\ncoZero⇒Zero : Zero op → Zero C\ncoZero⇒Zero zero = record\n { 𝟘 = 𝟘\n ; isZero = coIsZero⇒IsZero isZero\n }\n where\n open Zero zero\n\nZero⇒coZero : Zero C → Zero op\nZero⇒coZero zero = record\n { 𝟘 = 𝟘\n ; isZero = IsZero⇒coIsZero isZero\n }\n where\n open Zero zero\n\n-- Tests to ensure that dualities are involutive up to definitional equality.\nprivate\n coIsTerminal⟺IsInitial : (⊥ : IsInitial X) → coIsTerminal⇒IsInitial (IsInitial⇒coIsTerminal ⊥) ≡ ⊥\n coIsTerminal⟺IsInitial _ = ≡.refl\n\n IsInitial⟺coIsTerminal : (⊤ : IsTerminal X) → IsInitial⇒coIsTerminal (coIsTerminal⇒IsInitial ⊤) ≡ ⊤\n IsInitial⟺coIsTerminal _ = ≡.refl\n\n ⊥⟺op⊤ : (⊤ : Terminal) → ⊥⇒op⊤ (op⊤⇒⊥ ⊤) ≡ ⊤\n ⊥⟺op⊤ _ = ≡.refl\n\n op⊤⟺⊥ : (⊥ : Initial) → op⊤⇒⊥ (⊥⇒op⊤ ⊥) ≡ ⊥\n op⊤⟺⊥ _ = ≡.refl\n\n Coproduct⟺coProduct : (p : Product A B) → Coproduct⇒coProduct (coProduct⇒Coproduct p) ≡ p\n Coproduct⟺coProduct _ = ≡.refl\n\n coProduct⟺Coproduct : (p : Coproduct A B) → coProduct⇒Coproduct (Coproduct⇒coProduct p) ≡ p\n coProduct⟺Coproduct _ = ≡.refl\n\n coIsZero⟺IsZero : {zero : IsZero op Z} → IsZero⇒coIsZero (coIsZero⇒IsZero zero) ≡ zero\n coIsZero⟺IsZero = ≡.refl\n\n IsZero⟺coIsZero : ∀ {Z} {zero : IsZero C Z} → coIsZero⇒IsZero (IsZero⇒coIsZero zero) ≡ zero\n IsZero⟺coIsZero = ≡.refl\n\n coZero⟺Zero : ∀ {zero : Zero op} → Zero⇒coZero (coZero⇒Zero zero) ≡ zero\n coZero⟺Zero = ≡.refl\n\n Zero⟺coZero : ∀ {zero : Zero C} → coZero⇒Zero (Zero⇒coZero zero) ≡ zero\n Zero⟺coZero = ≡.refl\n\nmodule _ (𝟎 : Zero C) where\n open Kernels (Zero⇒coZero 𝟎)\n open Cokernels 𝟎\n\n coIsKernel⇒IsCokernel : IsKernel k f → IsCokernel f k\n coIsKernel⇒IsCokernel isKernel = record\n { commute = commute\n ; universal = universal\n ; factors = factors\n ; unique = unique\n }\n where\n open IsKernel isKernel\n\n IsCokernel⇒coIsKernel : IsCokernel f k → IsKernel k f\n IsCokernel⇒coIsKernel isCokernel = record\n { commute = commute\n ; universal = universal\n ; factors = factors\n ; unique = unique\n }\n where\n open IsCokernel isCokernel\n\n coKernel⇒Cokernel : Kernel f → Cokernel f\n coKernel⇒Cokernel k = record\n { cokernel⇒ = kernel⇒\n ; isCokernel = coIsKernel⇒IsCokernel isKernel\n }\n where\n open Kernel k\n\n Cokernel⇒coKernel : Cokernel f → Kernel f\n Cokernel⇒coKernel k = record\n { kernel⇒ = cokernel⇒\n ; isKernel = IsCokernel⇒coIsKernel isCokernel\n }\n where\n open Cokernel k\n\n private\n coIsKernel⟺IsCokernel : ∀ {isKernel : IsKernel k f} → IsCokernel⇒coIsKernel (coIsKernel⇒IsCokernel isKernel) ≡ isKernel\n coIsKernel⟺IsCokernel = ≡.refl\n\n IsCokernel⟺coIsKernel : ∀ {isCokernel : IsCokernel f k} → coIsKernel⇒IsCokernel (IsCokernel⇒coIsKernel isCokernel) ≡ isCokernel\n IsCokernel⟺coIsKernel = ≡.refl\n\n coKernel⟺Cokernel : ∀ {kernel : Kernel f} → Cokernel⇒coKernel (coKernel⇒Cokernel kernel) ≡ kernel\n coKernel⟺Cokernel = ≡.refl\n\n Cokernel⟺coKernel : ∀ {cokernel : Cokernel f} → coKernel⇒Cokernel (Cokernel⇒coKernel cokernel) ≡ cokernel\n Cokernel⟺coKernel = ≡.refl\n", "meta": {"hexsha": "4cbf00fe7210e4912a4e94d691b41b9f2faa614b", "size": 5462, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Object/Duality.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Object/Duality.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Object/Duality.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 27.31, "max_line_length": 131, "alphanum_fraction": 0.6552544855, "num_tokens": 2197, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424411924673, "lm_q2_score": 0.7341195385342971, "lm_q1q2_score": 0.6210228745547909}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.HITs.Rationals.QuoQ.Base where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\n\nopen import Cubical.Data.Nat as ℕ using (discreteℕ)\nopen import Cubical.Data.NatPlusOne\nopen import Cubical.Data.Sigma\n\nopen import Cubical.HITs.Ints.QuoInt\nopen import Cubical.HITs.SetQuotients as SetQuotient\n using ([_]; eq/; discreteSetQuotients) renaming (_/_ to _//_) public\n\nopen import Cubical.Relation.Nullary\nopen import Cubical.Relation.Binary.Base\n\n\nℕ₊₁→ℤ : ℕ₊₁ → ℤ\nℕ₊₁→ℤ n = pos (ℕ₊₁→ℕ n)\n\nprivate\n ℕ₊₁→ℤ-hom : ∀ m n → ℕ₊₁→ℤ (m ·₊₁ n) ≡ ℕ₊₁→ℤ m · ℕ₊₁→ℤ n\n ℕ₊₁→ℤ-hom _ _ = refl\n\n\n-- ℚ as a set quotient of ℤ × ℕ₊₁ (as in the HoTT book)\n\n_∼_ : ℤ × ℕ₊₁ → ℤ × ℕ₊₁ → Type₀\n(a , b) ∼ (c , d) = a · ℕ₊₁→ℤ d ≡ c · ℕ₊₁→ℤ b\n\nℚ : Type₀\nℚ = (ℤ × ℕ₊₁) // _∼_\n\n\nisSetℚ : isSet ℚ\nisSetℚ = SetQuotient.squash/\n\n[_/_] : ℤ → ℕ₊₁ → ℚ\n[ a / b ] = [ a , b ]\n\n\nisEquivRel∼ : isEquivRel _∼_\nisEquivRel.reflexive isEquivRel∼ (a , b) = refl\nisEquivRel.symmetric isEquivRel∼ (a , b) (c , d) = sym\nisEquivRel.transitive isEquivRel∼ (a , b) (c , d) (e , f) p q = ·-injʳ _ _ _ r\n where r = (a · ℕ₊₁→ℤ f) · ℕ₊₁→ℤ d ≡[ i ]⟨ ·-comm a (ℕ₊₁→ℤ f) i · ℕ₊₁→ℤ d ⟩\n (ℕ₊₁→ℤ f · a) · ℕ₊₁→ℤ d ≡⟨ sym (·-assoc (ℕ₊₁→ℤ f) a (ℕ₊₁→ℤ d)) ⟩\n ℕ₊₁→ℤ f · (a · ℕ₊₁→ℤ d) ≡[ i ]⟨ ℕ₊₁→ℤ f · p i ⟩\n ℕ₊₁→ℤ f · (c · ℕ₊₁→ℤ b) ≡⟨ ·-assoc (ℕ₊₁→ℤ f) c (ℕ₊₁→ℤ b) ⟩\n (ℕ₊₁→ℤ f · c) · ℕ₊₁→ℤ b ≡[ i ]⟨ ·-comm (ℕ₊₁→ℤ f) c i · ℕ₊₁→ℤ b ⟩\n (c · ℕ₊₁→ℤ f) · ℕ₊₁→ℤ b ≡[ i ]⟨ q i · ℕ₊₁→ℤ b ⟩\n (e · ℕ₊₁→ℤ d) · ℕ₊₁→ℤ b ≡⟨ sym (·-assoc e (ℕ₊₁→ℤ d) (ℕ₊₁→ℤ b)) ⟩\n e · (ℕ₊₁→ℤ d · ℕ₊₁→ℤ b) ≡[ i ]⟨ e · ·-comm (ℕ₊₁→ℤ d) (ℕ₊₁→ℤ b) i ⟩\n e · (ℕ₊₁→ℤ b · ℕ₊₁→ℤ d) ≡⟨ ·-assoc e (ℕ₊₁→ℤ b) (ℕ₊₁→ℤ d) ⟩\n (e · ℕ₊₁→ℤ b) · ℕ₊₁→ℤ d ∎\n\neq/⁻¹ : ∀ x y → Path ℚ [ x ] [ y ] → x ∼ y\neq/⁻¹ = SetQuotient.effective (λ _ _ → isSetℤ _ _) isEquivRel∼\n\ndiscreteℚ : Discrete ℚ\ndiscreteℚ = discreteSetQuotients (discreteΣ discreteℤ (λ _ → subst Discrete 1+Path discreteℕ))\n (λ _ _ → isSetℤ _ _) isEquivRel∼ (λ _ _ → discreteℤ _ _)\n\n\n-- Natural number and negative integer literals for ℚ\n\nopen import Cubical.Data.Nat.Literals public\n\ninstance\n fromNatℚ : HasFromNat ℚ\n fromNatℚ = record { Constraint = λ _ → Unit ; fromNat = λ n → [ pos n / 1 ] }\n\ninstance\n fromNegℚ : HasFromNeg ℚ\n fromNegℚ = record { Constraint = λ _ → Unit ; fromNeg = λ n → [ neg n / 1 ] }\n", "meta": {"hexsha": "52dbe194f0d7de6c045733c2998466f751ec5387", "size": 2479, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/Rationals/QuoQ/Base.agda", "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/HITs/Rationals/QuoQ/Base.agda", "max_issues_repo_name": "Schippmunk/cubical", "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/HITs/Rationals/QuoQ/Base.agda", "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.1948051948, "max_line_length": 94, "alphanum_fraction": 0.5530455829, "num_tokens": 1267, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.84594244507642, "lm_q2_score": 0.7341195152660688, "lm_q1q2_score": 0.6210228577224944}} {"text": "------------------------------------------------------------------------\n-- INCREMENTAL λ-CALCULUS\n--\n-- Congruence of application.\n--\n-- If f ≡ g and x ≡ y, then (f x) ≡ (g y).\n------------------------------------------------------------------------\n\nmodule Theorem.CongApp where\n\nopen import Relation.Binary.PropositionalEquality public\n\ninfixl 0 _⟨$⟩_\n\n_⟨$⟩_ : ∀ {a b} {A : Set a} {B : Set b}\n {f g : A → B} {x y : A} →\n f ≡ g → x ≡ y → f x ≡ g y\n\n_⟨$⟩_ = cong₂ (λ x y → x y)\n", "meta": {"hexsha": "0ac84a34b127befa5eba3c3039b84d88b69fe0bc", "size": 481, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Theorem/CongApp.agda", "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_issues_repo_path": "Theorem/CongApp.agda", "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_forks_repo_path": "Theorem/CongApp.agda", "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "avg_line_length": 24.05, "max_line_length": 72, "alphanum_fraction": 0.3866943867, "num_tokens": 152, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8459424217727027, "lm_q2_score": 0.7341195269001831, "lm_q1q2_score": 0.6210228504565717}} {"text": "{-# OPTIONS --without-K --exact-split --safe #-}\n\nmodule Fragment.Equational.Theory.Bundles where\n\nopen import Fragment.Algebra.Signature\nopen import Fragment.Equational.Theory.Base\nopen import Fragment.Equational.Theory.Combinators\n\nopen import Data.Nat using (ℕ)\n\nmodule _ where\n\n data MagmaOp : ℕ → Set where\n • : MagmaOp 2\n\n Σ-magma : Signature\n Σ-magma = record { ops = MagmaOp }\n\n import Fragment.Equational.Theory.Laws Σ-magma as L\n\n data MagmaEq : ℕ → Set where\n\n magma-eqs : ∀ {n} → MagmaEq n → Eq Σ-magma n\n magma-eqs ()\n\n data SemigroupEq : ℕ → Set where\n assoc : SemigroupEq 3\n\n semigroup-eqs : ∀ {n} → SemigroupEq n → Eq Σ-magma n\n semigroup-eqs assoc = L.assoc •\n\n data CSemigroupEq : ℕ → Set where\n comm : CSemigroupEq 2\n assoc : CSemigroupEq 3\n\n csemigroup-eqs : ∀ {n} → CSemigroupEq n → Eq Σ-magma n\n csemigroup-eqs comm = L.comm •\n csemigroup-eqs assoc = L.assoc •\n\nΘ-magma : Theory\nΘ-magma = record { Σ = Σ-magma\n ; eqs = MagmaEq\n ; _⟦_⟧ₑ = magma-eqs\n }\n\nΘ-semigroup : Theory\nΘ-semigroup = record { Σ = Σ-magma\n ; eqs = SemigroupEq\n ; _⟦_⟧ₑ = semigroup-eqs\n }\n\nΘ-csemigroup : Theory\nΘ-csemigroup = record { Σ = Σ-magma\n ; eqs = CSemigroupEq\n ; _⟦_⟧ₑ = csemigroup-eqs\n }\n\nΘ-monoid : Theory\nΘ-monoid = AddId Θ-semigroup •\n\nΘ-cmonoid : Theory\nΘ-cmonoid = AddId Θ-csemigroup •\n", "meta": {"hexsha": "de3694eff24782578045ed3d674031cae5119c5b", "size": 1509, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Fragment/Equational/Theory/Bundles.agda", "max_stars_repo_name": "yallop/agda-fragment", "max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 18, "max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z", "max_issues_repo_path": "src/Fragment/Equational/Theory/Bundles.agda", "max_issues_repo_name": "yallop/agda-fragment", "max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z", "max_forks_repo_path": "src/Fragment/Equational/Theory/Bundles.agda", "max_forks_repo_name": "yallop/agda-fragment", "max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z", "avg_line_length": 23.9523809524, "max_line_length": 56, "alphanum_fraction": 0.5897945659, "num_tokens": 502, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289388125473628, "lm_q2_score": 0.7490872075132152, "lm_q1q2_score": 0.6209474602904246}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nopen import Cubical.Relation.Binary.Base\nopen import Cubical.Core.Everything\n\nmodule Cubical.Relation.Binary.Raw.Structures\n {a ℓ} {A : Type a} -- The underlying type\n (_<>_ : RawRel A ℓ) -- The relation\n where\n\nopen import Cubical.Foundations.Prelude using (refl; sym)\nopen import Cubical.Foundations.Function using (_∘_)\n\nopen import Cubical.Data.Prod.Base using (proj₁; proj₂; _,_)\nopen import Cubical.Relation.Nullary.Decidable\nopen import Cubical.Relation.Binary.Raw.Definitions\nopen import Cubical.Relation.Binary.Raw.Properties\n\nprivate\n variable\n ℓ₂ : Level\n\n\n------------------------------------------------------------------------\n-- Preorders\n------------------------------------------------------------------------\n\nrecord IsPreorder : Type (ℓ-max a ℓ) where\n constructor ispreorder\n field\n reflexive : Reflexive _<>_\n transitive : Transitive _<>_\n\n fromEq : FromEq _<>_\n fromEq = reflx→fromeq _<>_ reflexive\n\n\n------------------------------------------------------------------------\n-- Equivalences\n------------------------------------------------------------------------\n\nrecord IsPartialEquivalence : Type (ℓ-max a ℓ) where\n constructor ispartialeq\n field\n symmetric : Symmetric _<>_\n transitive : Transitive _<>_\n\n\nrecord IsEquivalence : Type (ℓ-max a ℓ) where\n constructor isequivalence\n field\n reflexive : Reflexive _<>_\n isPartialEquivalence : IsPartialEquivalence\n\n open IsPartialEquivalence isPartialEquivalence public\n\n from-≡ : FromEq _<>_\n from-≡ = reflx→fromeq _<>_ reflexive\n\n isPreorder : IsPreorder\n isPreorder = record\n { reflexive = reflexive\n ; transitive = transitive\n }\n\n\nrecord IsDecEquivalence : Type (ℓ-max a ℓ) where\n constructor isdeceq\n infix 4 _≟_\n field\n isEquivalence : IsEquivalence\n _≟_ : Decidable _<>_\n\n open IsEquivalence isEquivalence public\n\n------------------------------------------------------------------------\n-- Partial orders\n------------------------------------------------------------------------\n\nrecord IsPartialOrder : Type (ℓ-max a ℓ) where\n constructor ispartialorder\n field\n isPreorder : IsPreorder\n antisym : Antisymmetric _<>_\n\n open IsPreorder isPreorder public\n\n\nrecord IsDecPartialOrder : Type (ℓ-max a ℓ) where\n constructor isdecpartialorder\n infix 4 _≤?_\n field\n isPartialOrder : IsPartialOrder\n _≤?_ : Decidable _<>_\n\n open IsPartialOrder isPartialOrder public\n\n private\n lemma : ∀ {x y} → ¬ x <> y → ¬ x ≡ y\n lemma x≰y x≡y = x≰y (fromEq x≡y)\n\n _≟_ : Discrete A\n _≟_ x y with x ≤? y\n ... | no ¬p = no (lemma ¬p)\n ... | yes p with y ≤? x\n ... | no ¬q = no (lemma ¬q ∘ sym)\n ... | yes q = yes (antisym p q)\n\nrecord IsStrictPartialOrder : Type (ℓ-max a ℓ) where\n constructor isstrictpartialorder\n field\n irrefl : Irreflexive _<>_\n transitive : Transitive _<>_\n\n asym : Asymmetric _<>_\n asym {x} {y} = trans∧irr→asym _<>_ transitive irrefl\n\n\nrecord IsDecStrictPartialOrder : Type (ℓ-max a ℓ) where\n constructor isdecstrictpartialorder\n infix 4 __\n\n open IsStrictPartialOrder isStrictPartialOrder public\n\n------------------------------------------------------------------------\n-- Total orders\n------------------------------------------------------------------------\n\nrecord IsTotalOrder : Type (ℓ-max a ℓ) where\n constructor istotalorder\n field\n isPartialOrder : IsPartialOrder\n total : PropTotal _<>_\n\n open IsPartialOrder isPartialOrder public\n\n\nrecord IsDecTotalOrder : Type (ℓ-max a ℓ) where\n constructor isdectotalorder\n infix 4 _≤?_\n field\n isTotalOrder : IsTotalOrder\n _≤?_ : Decidable _<>_\n\n open IsTotalOrder isTotalOrder public\n\n isDecPartialOrder : IsDecPartialOrder\n isDecPartialOrder = record\n { isPartialOrder = isPartialOrder\n ; _≤?_ = _≤?_\n }\n\n open IsDecPartialOrder isDecPartialOrder public using (_≟_)\n\n-- Note that these orders are decidable. The current implementation\n-- of `Trichotomous` subsumes irreflexivity and asymmetry. Any reasonable\n-- definition capturing these three properties implies decidability\n-- as `Trichotomous` necessarily separates out the equality case.\n\nrecord IsStrictTotalOrder : Type (ℓ-max a ℓ) where\n constructor isstricttotalorder\n field\n transitive : Transitive _<>_\n compare : Trichotomous _<>_\n\n infix 4 __\n __ compare\n\n _≟_ : Discrete A\n _≟_ = tri→dec≡ _<>_ compare\n\n isStrictPartialOrder : IsStrictPartialOrder\n isStrictPartialOrder = record\n { irrefl = tri→irr _<>_ compare\n ; transitive = transitive\n }\n\n isDecStrictPartialOrder : IsDecStrictPartialOrder\n isDecStrictPartialOrder = record\n { isStrictPartialOrder = isStrictPartialOrder\n ; _₁ t2) ◆t = (t1 ◆t) ==> t2\n (t1 ==>₂ t2) ◆t = t1 ==> (t2 ◆t)\n (t1 ⊕₁ t2) ◆t = (t1 ◆t) ⊕ t2\n (t1 ⊕₂ t2) ◆t = t1 ⊕ (t2 ◆t)\n (t1 ⊠₁ t2) ◆t = (t1 ◆t) ⊠ t2\n (t1 ⊠₂ t2) ◆t = t1 ⊠ (t2 ◆t)\n \n --cursor erasure for expressions, as written in the paper\n _◆e : zexp → hexp\n ▹ x ◃ ◆e = x\n (e ·:₁ t) ◆e = (e ◆e) ·: t\n (e ·:₂ t) ◆e = e ·: (t ◆t)\n ·λ x e ◆e = ·λ x (e ◆e)\n (·λ x ·[ t ]₁ e) ◆e = ·λ x ·[ t ◆t ] e\n (·λ x ·[ t ]₂ e) ◆e = ·λ x ·[ t ] (e ◆e)\n (e1 ∘₁ e2) ◆e = (e1 ◆e) ∘ e2\n (e1 ∘₂ e2) ◆e = e1 ∘ (e2 ◆e)\n (e1 ·+₁ e2) ◆e = (e1 ◆e) ·+ e2\n (e1 ·+₂ e2) ◆e = e1 ·+ (e2 ◆e)\n ⦇⌜ e ⌟⦈[ u ] ◆e = ⦇⌜ e ◆e ⌟⦈[ u ]\n (inl e) ◆e = inl (e ◆e)\n (inr e) ◆e = inr (e ◆e)\n (case₁ e x e1 y e2) ◆e = case (e ◆e) x e1 y e2\n (case₂ e x e1 y e2) ◆e = case e x (e1 ◆e) y e2\n (case₃ e x e1 y e2) ◆e = case e x e1 y (e2 ◆e)\n ⟨ e1 , e2 ⟩₁ ◆e = ⟨ e1 ◆e , e2 ⟩\n ⟨ e1 , e2 ⟩₂ ◆e = ⟨ e1 , e2 ◆e ⟩\n fst e ◆e = fst (e ◆e)\n snd e ◆e = snd (e ◆e)\n\n -- this pair of theorems moves from the judgmental form to the function form\n erase-t◆ : {t : ztyp} {tr : htyp} → (erase-t t tr) → (t ◆t == tr)\n erase-t◆ ETTop = refl\n erase-t◆ (ETArrL p) = ap1 (λ x → x ==> _) (erase-t◆ p)\n erase-t◆ (ETArrR p) = ap1 (λ x → _ ==> x) (erase-t◆ p)\n erase-t◆ (ETPlusL p) = ap1 (λ x → x ⊕ _) (erase-t◆ p)\n erase-t◆ (ETPlusR p) = ap1 (λ x → _ ⊕ x) (erase-t◆ p)\n erase-t◆ (ETProdL p) = ap1 (λ x → x ⊠ _) (erase-t◆ p)\n erase-t◆ (ETProdR p) = ap1 (λ x → _ ⊠ x) (erase-t◆ p)\n \n erase-e◆ : {e : zexp} {er : hexp} → (erase-e e er) → (e ◆e == er)\n erase-e◆ EETop = refl\n erase-e◆ (EEPlusL p) = ap1 (λ x → x ·+ _) (erase-e◆ p)\n erase-e◆ (EEPlusR p) = ap1 (λ x → _ ·+ x) (erase-e◆ p)\n erase-e◆ (EEAscL p) = ap1 (λ x → x ·: _) (erase-e◆ p)\n erase-e◆ (EEAscR p) = ap1 (λ x → _ ·: x) (erase-t◆ p)\n erase-e◆ (EELam p) = ap1 (λ x → ·λ _ x) (erase-e◆ p)\n erase-e◆ (EEHalfLamL p) = ap1 (λ x → ·λ _ ·[ x ] _) (erase-t◆ p)\n erase-e◆ (EEHalfLamR p) = ap1 (λ x → ·λ _ ·[ _ ] x) (erase-e◆ p)\n erase-e◆ (EEApL p) = ap1 (λ x → x ∘ _) (erase-e◆ p)\n erase-e◆ (EEApR p) = ap1 (λ x → _ ∘ x) (erase-e◆ p)\n erase-e◆ (EEInl p) = ap1 inl (erase-e◆ p)\n erase-e◆ (EEInr p) = ap1 inr (erase-e◆ p)\n erase-e◆ (EECase1 p) = ap1 (λ x → case x _ _ _ _) (erase-e◆ p)\n erase-e◆ (EECase2 p) = ap1 (λ x → case _ _ x _ _) (erase-e◆ p)\n erase-e◆ (EECase3 p) = ap1 (λ x → case _ _ _ _ x) (erase-e◆ p)\n erase-e◆ (EEPairL p) = ap1 (λ x → ⟨ x , _ ⟩ ) (erase-e◆ p)\n erase-e◆ (EEPairR p) = ap1 (λ x → ⟨ _ , x ⟩ ) (erase-e◆ p)\n erase-e◆ (EEFst p) = ap1 fst (erase-e◆ p)\n erase-e◆ (EESnd p) = ap1 snd (erase-e◆ p)\n erase-e◆ (EENEHole p) = ap1 (λ x → ⦇⌜ x ⌟⦈[ _ ]) (erase-e◆ p)\n \n -- this pair of theorems moves back from judgmental form to the function form\n ◆erase-t : (t : ztyp) (tr : htyp) → (t ◆t == tr) → (erase-t t tr)\n ◆erase-t ▹ x ◃ .x refl = ETTop\n ◆erase-t (t ==>₁ x) (.(t ◆t) ==> .x) refl with ◆erase-t t (t ◆t) refl\n ... | ih = ETArrL ih\n ◆erase-t (x ==>₂ t) (.x ==> .(t ◆t)) refl with ◆erase-t t (t ◆t) refl\n ... | ih = ETArrR ih\n ◆erase-t (t1 ⊕₁ t2) (.(t1 ◆t) ⊕ .t2) refl = ETPlusL (◆erase-t t1 (t1 ◆t) refl)\n ◆erase-t (t1 ⊕₂ t2) (.t1 ⊕ .(t2 ◆t)) refl = ETPlusR (◆erase-t t2 (t2 ◆t) refl)\n ◆erase-t (t1 ⊠₁ t2) (.(t1 ◆t) ⊠ .t2) refl = ETProdL (◆erase-t t1 (t1 ◆t) refl)\n ◆erase-t (t1 ⊠₂ t2) (.t1 ⊠ .(t2 ◆t)) refl = ETProdR (◆erase-t t2 (t2 ◆t) refl)\n \n ◆erase-e : (e : zexp) (er : hexp) → (e ◆e == er) → (erase-e e er)\n ◆erase-e ▹ x ◃ .x refl = EETop\n ◆erase-e (e ·:₁ x) .((e ◆e) ·: x) refl with ◆erase-e e (e ◆e) refl\n ... | ih = EEAscL ih\n ◆erase-e (x ·:₂ x₁) .(x ·: (x₁ ◆t)) refl = EEAscR (◆erase-t x₁ (x₁ ◆t) refl)\n ◆erase-e (·λ x e) .(·λ x (e ◆e)) refl = EELam (◆erase-e e (e ◆e) refl)\n ◆erase-e (·λ x ·[ x₁ ]₁ x₂) _ refl = EEHalfLamL (◆erase-t x₁ (x₁ ◆t) refl)\n ◆erase-e (·λ x ·[ x₁ ]₂ e) _ refl = EEHalfLamR (◆erase-e e (e ◆e) refl)\n ◆erase-e (e ∘₁ x) .((e ◆e) ∘ x) refl = EEApL (◆erase-e e (e ◆e) refl)\n ◆erase-e (x ∘₂ e) .(x ∘ (e ◆e)) refl = EEApR (◆erase-e e (e ◆e) refl)\n ◆erase-e (e ·+₁ x) .((e ◆e) ·+ x) refl = EEPlusL (◆erase-e e (e ◆e) refl)\n ◆erase-e (x ·+₂ e) .(x ·+ (e ◆e)) refl = EEPlusR (◆erase-e e (e ◆e) refl)\n ◆erase-e ⦇⌜ e ⌟⦈[ u ] .(⦇⌜ e ◆e ⌟⦈[ u ]) refl = EENEHole (◆erase-e e (e ◆e) refl)\n ◆erase-e (inl e) _ refl = EEInl (◆erase-e e (e ◆e) refl)\n ◆erase-e (inr e) _ refl = EEInr (◆erase-e e (e ◆e) refl)\n ◆erase-e (case₁ e _ _ _ _) _ refl = EECase1 (◆erase-e e (e ◆e) refl)\n ◆erase-e (case₂ _ _ e _ _) _ refl = EECase2 (◆erase-e e (e ◆e) refl)\n ◆erase-e (case₃ _ _ _ _ e) _ refl = EECase3 (◆erase-e e (e ◆e) refl)\n ◆erase-e ⟨ e , x ⟩₁ .(⟨ (e ◆e) , x ⟩) refl = EEPairL (◆erase-e e (e ◆e) refl)\n ◆erase-e ⟨ x , e ⟩₂ .(⟨ x , (e ◆e) ⟩) refl = EEPairR (◆erase-e e (e ◆e) refl)\n ◆erase-e (fst e) _ refl = EEFst (◆erase-e e (e ◆e) refl)\n ◆erase-e (snd e) _ refl = EESnd (◆erase-e e (e ◆e) refl)\n \n -- jugemental erasure for both types and terms only has one proof for\n -- relating the a term to its non-judgemental erasure\n t-contr : (t : ztyp) → (x y : erase-t t (t ◆t)) → x == y\n t-contr ▹ x ◃ ETTop ETTop = refl\n t-contr (t ==>₁ x) (ETArrL y) (ETArrL z) = ap1 ETArrL (t-contr t y z)\n t-contr (x ==>₂ t) (ETArrR y) (ETArrR z) = ap1 ETArrR (t-contr t y z)\n t-contr (x ⊕₁ x₁) (ETPlusL y) (ETPlusL z) = ap1 ETPlusL (t-contr x y z)\n t-contr (x₁ ⊕₂ x) (ETPlusR y) (ETPlusR z) = ap1 ETPlusR (t-contr x y z)\n t-contr (x ⊠₁ x₁) (ETProdL y) (ETProdL z) = ap1 ETProdL (t-contr x y z)\n t-contr (x₁ ⊠₂ x) (ETProdR y) (ETProdR z) = ap1 ETProdR (t-contr x y z)\n \n e-contr : (e : zexp) → (x y : erase-e e (e ◆e)) → x == y\n e-contr ▹ x ◃ EETop EETop = refl\n e-contr (e ·:₁ x) (EEAscL x₁) (EEAscL y) = ap1 EEAscL (e-contr e x₁ y)\n e-contr (x₁ ·:₂ x) (EEAscR x₂) (EEAscR x₃) = ap1 EEAscR (t-contr x x₂ x₃)\n e-contr (·λ x e) (EELam x₁) (EELam y) = ap1 EELam (e-contr e x₁ y)\n e-contr (·λ x ·[ x₁ ]₁ x₂) (EEHalfLamL x₃) (EEHalfLamL x₄) = ap1 EEHalfLamL (t-contr x₁ x₃ x₄)\n e-contr (·λ x ·[ x₁ ]₂ x₂) (EEHalfLamR y) (EEHalfLamR z) = ap1 EEHalfLamR (e-contr x₂ y z)\n e-contr (e ∘₁ x) (EEApL x₁) (EEApL y) = ap1 EEApL (e-contr e x₁ y)\n e-contr (x ∘₂ e) (EEApR x₁) (EEApR y) = ap1 EEApR (e-contr e x₁ y)\n e-contr (e ·+₁ x) (EEPlusL x₁) (EEPlusL y) = ap1 EEPlusL (e-contr e x₁ y)\n e-contr (x ·+₂ e) (EEPlusR x₁) (EEPlusR y) = ap1 EEPlusR (e-contr e x₁ y)\n e-contr ⦇⌜ e ⌟⦈[ u ] (EENEHole x) (EENEHole y) = ap1 EENEHole (e-contr e x y)\n e-contr (inl x) (EEInl y) (EEInl z) = ap1 EEInl (e-contr x y z)\n e-contr (inr x) (EEInr y) (EEInr z) = ap1 EEInr (e-contr x y z)\n e-contr (case₁ x x₁ x₂ x₃ x₄) (EECase1 y) (EECase1 z) = ap1 EECase1 (e-contr x y z)\n e-contr (case₂ x₁ x₂ x x₃ x₄) (EECase2 y) (EECase2 z) = ap1 EECase2 (e-contr x y z)\n e-contr (case₃ x₁ x₂ x₃ x₄ x) (EECase3 y) (EECase3 z) = ap1 EECase3 (e-contr x y z)\n e-contr ⟨ e , x ⟩₁ (EEPairL x₁) (EEPairL y) = ap1 EEPairL (e-contr e x₁ y)\n e-contr ⟨ x , e ⟩₂ (EEPairR x₁) (EEPairR y) = ap1 EEPairR (e-contr e x₁ y)\n e-contr (fst x) (EEFst y) (EEFst z) = ap1 EEFst (e-contr x y z)\n e-contr (snd x) (EESnd y) (EESnd z) = ap1 EESnd (e-contr x y z)\n \n -- taken together, these four theorems demonstrate that both round-trips\n -- of the above functions are stable up to ==\n erase-trt1 : (t : ztyp) (tr : htyp) →\n (x : t ◆t == tr) →\n (erase-t◆ (◆erase-t t tr x)) == x\n erase-trt1 ▹ x ◃ .x refl = refl\n erase-trt1 (t ==>₁ x) (.(t ◆t) ==> .x) refl with erase-t◆ (◆erase-t t (t ◆t) refl)\n erase-trt1 (t ==>₁ x) (.(t ◆t) ==> .x) refl | refl = refl\n erase-trt1 (x ==>₂ t) (.x ==> .(t ◆t)) refl with erase-t◆ (◆erase-t t (t ◆t) refl)\n erase-trt1 (x ==>₂ t) (.x ==> .(t ◆t)) refl | refl = refl\n erase-trt1 (x ⊕₁ x₁) .((x ◆t) ⊕ x₁) refl with erase-t◆ (◆erase-t x (x ◆t) refl)\n erase-trt1 (x ⊕₁ x₁) .((x ◆t) ⊕ x₁) refl | refl = refl\n erase-trt1 (x ⊕₂ x₁) .(x ⊕ (x₁ ◆t)) refl with erase-t◆ (◆erase-t x₁ (x₁ ◆t) refl)\n erase-trt1 (x ⊕₂ x₁) .(x ⊕ (x₁ ◆t)) refl | refl = refl\n erase-trt1 (x ⊠₁ x₁) .((x ◆t) ⊠ x₁) refl with erase-t◆ (◆erase-t x (x ◆t) refl)\n erase-trt1 (x ⊠₁ x₁) .((x ◆t) ⊠ x₁) refl | refl = refl\n erase-trt1 (x ⊠₂ x₁) .(x ⊠ (x₁ ◆t)) refl with erase-t◆ (◆erase-t x₁ (x₁ ◆t) refl)\n erase-trt1 (x ⊠₂ x₁) .(x ⊠ (x₁ ◆t)) refl | refl = refl\n \n erase-trt2 : (t : ztyp) (tr : htyp) →\n (x : erase-t t tr) →\n ◆erase-t t tr (erase-t◆ x) == x\n erase-trt2 .(▹ tr ◃) tr ETTop = refl\n erase-trt2 _ _ (ETArrL ETTop) = refl\n erase-trt2 (t1 ==>₁ t2) _ (ETArrL x) with erase-t◆ x\n erase-trt2 (t1 ==>₁ t2) _ (ETArrL x) | refl =\n ap1 ETArrL (t-contr _ (◆erase-t t1 (t1 ◆t) refl) x)\n erase-trt2 (t1 ==>₂ t2) _ (ETArrR x) with erase-t◆ x\n erase-trt2 (t1 ==>₂ t2) _ (ETArrR x) | refl =\n ap1 ETArrR (t-contr _ (◆erase-t t2 (t2 ◆t) refl) x)\n erase-trt2 (t1 ⊕₁ t2) _ (ETPlusL x) with erase-t◆ x\n erase-trt2 (t1 ⊕₁ t2) _ (ETPlusL x) | refl =\n ap1 ETPlusL (t-contr _ (◆erase-t t1 (t1 ◆t) refl) x)\n erase-trt2 (t1 ⊕₂ t2) _ (ETPlusR x) with erase-t◆ x\n erase-trt2 (t1 ⊕₂ t2) _ (ETPlusR x) | refl =\n ap1 ETPlusR (t-contr _ (◆erase-t t2 (t2 ◆t) refl) x)\n erase-trt2 (t1 ⊠₁ t2) _ (ETProdL x) with erase-t◆ x\n erase-trt2 (t1 ⊠₁ t2) _ (ETProdL x) | refl =\n ap1 ETProdL (t-contr _ (◆erase-t t1 (t1 ◆t) refl) x)\n erase-trt2 (t1 ⊠₂ t2) _ (ETProdR x) with erase-t◆ x\n erase-trt2 (t1 ⊠₂ t2) _ (ETProdR x) | refl =\n ap1 ETProdR (t-contr _ (◆erase-t t2 (t2 ◆t) refl) x)\n\n erase-ert1 : (e : zexp) (er : hexp) →\n (x : e ◆e == er) →\n (erase-e◆ (◆erase-e e er x)) == x\n erase-ert1 ▹ x ◃ .x refl = refl\n erase-ert1 (e ·:₁ x) .((e ◆e) ·: x) refl with erase-e◆ (◆erase-e e (e ◆e) refl)\n erase-ert1 (e ·:₁ x) .((e ◆e) ·: x) refl | refl = refl\n erase-ert1 (x ·:₂ t) .(x ·: (t ◆t)) refl = ap1 (λ a → ap1 (_·:_ x) a) (erase-trt1 t _ refl)\n erase-ert1 (·λ x e) .(·λ x (e ◆e)) refl = ap1 (λ a → ap1 (·λ x) a) (erase-ert1 e _ refl)\n erase-ert1 (·λ x ·[ t ]₁ e) .((·λ x ·[ t ]₁ e) ◆e) refl =\n ap1 (λ a → ap1 (λ b → ·λ x ·[ b ] e) a) (erase-trt1 t _ refl)\n erase-ert1 (·λ x ·[ t ]₂ e) .((·λ x ·[ t ]₂ e) ◆e) refl =\n ap1 (λ a → ap1 (λ b → ·λ x ·[ t ] b) a) (erase-ert1 e _ refl)\n erase-ert1 (e ∘₁ x) .((e ◆e) ∘ x) refl =\n ap1 (λ a → ap1 (λ x₁ → x₁ ∘ x) a) (erase-ert1 e _ refl)\n erase-ert1 (x ∘₂ e) .(x ∘ (e ◆e)) refl =\n ap1 (λ a → ap1 (_∘_ x) a) (erase-ert1 e _ refl)\n erase-ert1 (e ·+₁ x) .((e ◆e) ·+ x) refl =\n ap1 (λ a → ap1 (λ x₁ → x₁ ·+ x) a) (erase-ert1 e _ refl)\n erase-ert1 (x ·+₂ e) .(x ·+ (e ◆e)) refl =\n ap1 (λ a → ap1 (_·+_ x) a) (erase-ert1 e _ refl)\n erase-ert1 ⦇⌜ e ⌟⦈[ u ] .(⦇⌜ e ◆e ⌟⦈[ u ]) refl =\n ap1 (λ a → ap1 ⦇⌜_⌟⦈[ u ] a) (erase-ert1 e _ refl)\n erase-ert1 (inl x) .(inl (x ◆e)) refl = ap1 (λ a → ap1 inl a) (erase-ert1 x _ refl)\n erase-ert1 (inr x) .(inr (x ◆e)) refl = ap1 (λ a → ap1 inr a) (erase-ert1 x _ refl)\n erase-ert1 (case₁ x x₁ x₂ x₃ x₄) .(case (x ◆e) x₁ x₂ x₃ x₄) refl =\n ap1 (ap1 (λ a → case a x₁ x₂ x₃ x₄)) (erase-ert1 x _ refl)\n erase-ert1 (case₂ x x₁ x₂ x₃ x₄) .(case x x₁ (x₂ ◆e) x₃ x₄) refl =\n ap1 (ap1 (λ a → case x x₁ a x₃ x₄)) (erase-ert1 x₂ _ refl)\n erase-ert1 (case₃ x x₁ x₂ x₃ x₄) .(case x x₁ x₂ x₃ (x₄ ◆e)) refl =\n ap1 (ap1 (λ a → case x x₁ x₂ x₃ a)) (erase-ert1 x₄ _ refl)\n erase-ert1 ⟨ e , x ⟩₁ .(⟨ (e ◆e) , x ⟩) refl =\n ap1 (λ a → ap1 (λ x₁ → ⟨ x₁ , x ⟩) a) (erase-ert1 e _ refl)\n erase-ert1 ⟨ x , e ⟩₂ .(⟨ x , (e ◆e) ⟩) refl =\n ap1 (λ a → ap1 (⟨_,_⟩ x) a) (erase-ert1 e _ refl)\n erase-ert1 (fst x) .(fst (x ◆e)) refl = ap1 (λ a → ap1 fst a) (erase-ert1 x _ refl)\n erase-ert1 (snd x) .(snd (x ◆e)) refl = ap1 (λ a → ap1 snd a) (erase-ert1 x _ refl)\n \n erase-ert2 : (e : zexp) (er : hexp) →\n (b : erase-e e er) →\n ◆erase-e e er (erase-e◆ b) == b\n erase-ert2 .(▹ er ◃) er EETop = refl\n erase-ert2 (e ·:₁ x) _ (EEAscL b) with erase-e◆ b\n erase-ert2 (e ·:₁ x) _ (EEAscL b) | refl =\n ap1 EEAscL (e-contr _ (◆erase-e e (e ◆e) refl) b)\n erase-ert2 (e ·:₂ x) _ (EEAscR b) with erase-t◆ b\n erase-ert2 (e ·:₂ x) .(e ·: (x ◆t)) (EEAscR b) | refl =\n ap1 EEAscR (t-contr _ (◆erase-t x (x ◆t) refl) b)\n erase-ert2 (·λ x e) _ (EELam b) with erase-e◆ b\n erase-ert2 (·λ x e) .(·λ x (e ◆e)) (EELam b) | refl =\n ap1 EELam (e-contr _ (◆erase-e e (e ◆e) refl) b)\n erase-ert2 (·λ x ·[ t ]₁ e) _ (EEHalfLamL b) with erase-t◆ b\n erase-ert2 (·λ x ·[ t ]₁ e) .(·λ x ·[ t ◆t ] e) (EEHalfLamL b) | refl =\n ap1 EEHalfLamL (t-contr _ (◆erase-t t (t ◆t) refl) b)\n erase-ert2 (·λ x ·[ t ]₂ e) _ (EEHalfLamR b) with erase-e◆ b\n erase-ert2 (·λ x ·[ t ]₂ e) .(·λ x ·[ t ] (e ◆e)) (EEHalfLamR b) | refl =\n ap1 EEHalfLamR (e-contr _ (◆erase-e e (e ◆e) refl) b)\n erase-ert2 (e ∘₁ x) _ (EEApL b) with erase-e◆ b\n erase-ert2 (e ∘₁ x) .((e ◆e) ∘ x) (EEApL b) | refl =\n ap1 EEApL (e-contr e (◆erase-e e (e ◆e) refl) b)\n erase-ert2 (e1 ∘₂ e) _ (EEApR b) with erase-e◆ b\n erase-ert2 (e1 ∘₂ e) .(e1 ∘ (e ◆e)) (EEApR b) | refl =\n ap1 EEApR (e-contr e (◆erase-e e (e ◆e) refl) b)\n erase-ert2 (e ·+₁ x) _ (EEPlusL b) with erase-e◆ b\n erase-ert2 (e ·+₁ x) .((e ◆e) ·+ x) (EEPlusL b) | refl =\n ap1 EEPlusL (e-contr e (◆erase-e e (e ◆e) refl) b)\n erase-ert2 (e1 ·+₂ e) _ (EEPlusR b) with erase-e◆ b\n erase-ert2 (e1 ·+₂ e) .(e1 ·+ (e ◆e)) (EEPlusR b) | refl =\n ap1 EEPlusR (e-contr e (◆erase-e e (e ◆e) refl) b)\n erase-ert2 ⦇⌜ e ⌟⦈[ u ] _ (EENEHole b) with erase-e◆ b\n erase-ert2 ⦇⌜ e ⌟⦈[ u ] .(⦇⌜ e ◆e ⌟⦈[ u ]) (EENEHole b) | refl =\n ap1 EENEHole (e-contr e (◆erase-e e (e ◆e) refl) b)\n erase-ert2 (inl x) _ (EEInl z) with erase-e◆ z\n erase-ert2 (inl x) .(inl (x ◆e)) (EEInl z) | refl = ap1 EEInl (e-contr x _ z)\n erase-ert2 (inr x) _ (EEInr z) with erase-e◆ z\n erase-ert2 (inr x) .(inr (x ◆e)) (EEInr z) | refl = ap1 EEInr (e-contr x _ z)\n erase-ert2 (case₁ x x₁ x₂ x₃ x₄) _ (EECase1 z) with erase-e◆ z\n erase-ert2 (case₁ x x₁ x₂ x₃ x₄) .(case (x ◆e) x₁ x₂ x₃ x₄) (EECase1 z) | refl =\n ap1 EECase1 (e-contr x _ z)\n erase-ert2 (case₂ e x₁ x₂ x₃ x₄) _ (EECase2 z) with erase-e◆ z\n erase-ert2 (case₂ e x₁ x₂ x₃ x₄) .(case e x₁ (x₂ ◆e) x₃ x₄) (EECase2 z) | refl =\n ap1 EECase2 (e-contr x₂ _ z)\n erase-ert2 (case₃ e x₁ x₂ x₃ x₄) _ (EECase3 z) with erase-e◆ z\n erase-ert2 (case₃ e x₁ x₂ x₃ x₄) .(case e x₁ x₂ x₃ (x₄ ◆e)) (EECase3 z) | refl =\n ap1 EECase3 (e-contr x₄ _ z)\n erase-ert2 ⟨ e , x ⟩₁ _ (EEPairL b) with erase-e◆ b\n erase-ert2 ⟨ e , x ⟩₁ .(⟨ (e ◆e) , x ⟩) (EEPairL b) | refl =\n ap1 EEPairL (e-contr e (◆erase-e e (e ◆e) refl) b)\n erase-ert2 ⟨ e1 , e ⟩₂ _ (EEPairR b) with erase-e◆ b\n erase-ert2 ⟨ e1 , e ⟩₂ .(⟨ e1 , (e ◆e) ⟩) (EEPairR b) | refl =\n ap1 EEPairR (e-contr e (◆erase-e e (e ◆e) refl) b)\n erase-ert2 (fst x) _ (EEFst z) with erase-e◆ z\n erase-ert2 (fst x) .(fst (x ◆e)) (EEFst z) | refl = ap1 EEFst (e-contr x _ z)\n erase-ert2 (snd x) _ (EESnd z) with erase-e◆ z\n erase-ert2 (snd x) .(snd (x ◆e)) (EESnd z) | refl = ap1 EESnd (e-contr x _ z)\n \n -- since both round trips are stable, these functions demonstrate\n -- isomorphisms between the jugemental and non-judgemental definitions of\n -- erasure\n erase-e-iso : (e : zexp) (er : hexp) → (e ◆e == er) ≃ (erase-e e er)\n erase-e-iso e er = (◆erase-e e er) , (erase-e◆ , erase-ert1 e er , erase-ert2 e er)\n\n erase-t-iso : (t : ztyp) (tr : htyp) → (t ◆t == tr) ≃ (erase-t t tr)\n erase-t-iso t tr = (◆erase-t t tr) , (erase-t◆ , erase-trt1 t tr , erase-trt2 t tr)\n\n -- this isomorphism supplies the argument that the judgement has mode (∀,\n -- !∃), where uniqueness comes from erase-e◆.\n erase-e-mode : (e : zexp) → Σ[ er ∈ hexp ] (erase-e e er)\n erase-e-mode e = (e ◆e) , (◆erase-e e (e ◆e) refl)\n\n -- some translations and lemmas to move between the different\n -- forms. these are not needed to show that this is an ok encoding pair,\n -- but they are helpful when actually using it.\n\n -- even more specifically, the relation relates an expression to its\n -- functional erasure.\n rel◆t : (t : ztyp) → (erase-t t (t ◆t))\n rel◆t t = ◆erase-t t (t ◆t) refl\n\n rel◆ : (e : zexp) → (erase-e e (e ◆e))\n rel◆ e = ◆erase-e e (e ◆e) refl\n\n lem-erase-synth : ∀{e e' Γ t} → erase-e e e' → Γ ⊢ e' => t → Γ ⊢ (e ◆e) => t\n lem-erase-synth er wt = tr (λ x → _ ⊢ x => _) (! (erase-e◆ er)) wt\n\n lem-erase-ana : ∀{e e' Γ t} → erase-e e e' → Γ ⊢ e' <= t → Γ ⊢ (e ◆e) <= t\n lem-erase-ana er wt = tr (λ x → _ ⊢ x <= _) (! (erase-e◆ er)) wt\n\n lem-synth-erase : ∀{Γ e t e' } → Γ ⊢ e ◆e => t → erase-e e e' → Γ ⊢ e' => t\n lem-synth-erase d1 d2 with erase-e◆ d2\n ... | refl = d1\n\n eraset-det : ∀{t t' t''} → erase-t t t' → erase-t t t'' → t' == t''\n eraset-det e1 e2 with erase-t◆ e1\n ... | refl = erase-t◆ e2\n\n erasee-det : ∀{e e' e''} → erase-e e e' → erase-e e e'' → e' == e''\n erasee-det e1 e2 with erase-e◆ e1\n ... | refl = erase-e◆ e2\n\n erase-in-hole : ∀ {e e' u} → erase-e e e' → erase-e ⦇⌜ e ⌟⦈[ u ] ⦇⌜ e' ⌟⦈[ u ]\n erase-in-hole (EENEHole er) = EENEHole (erase-in-hole er)\n erase-in-hole x = EENEHole x\n\n eq-er-trans : ∀{e e◆ e'} →\n (e ◆e) == (e' ◆e) →\n erase-e e e◆ →\n erase-e e' e◆\n eq-er-trans {e} {e◆} {e'} eq er =\n tr (λ f → erase-e e' f) (erasee-det (◆erase-e e (e' ◆e) eq) er) (rel◆ e')\n\n eq-ert-trans : ∀{t t' t1 t2} →\n (t ◆t) == (t' ◆t) →\n erase-t t t1 →\n erase-t t' t2 →\n t1 == t2\n eq-ert-trans eq er1 er2 = ! (erase-t◆ er1) · (eq · (erase-t◆ er2))\n", "meta": {"hexsha": "cc6b9d99caa7b5b945657f9e3cec165aa5cb3a6b", "size": 18567, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "judgemental-erase.agda", "max_stars_repo_name": "hazelgrove/hazelnut-agda", "max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "judgemental-erase.agda", "max_issues_repo_name": "hazelgrove/hazelnut-agda", "max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "judgemental-erase.agda", "max_forks_repo_name": "hazelgrove/hazelnut-agda", "max_forks_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.7186629526, "max_line_length": 96, "alphanum_fraction": 0.5419292293, "num_tokens": 9151, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289387998695209, "lm_q2_score": 0.7490872075132152, "lm_q1q2_score": 0.6209474507936154}} {"text": "----------------------------------------------------------------------\n-- --\n-- Author : Jan Stolarek --\n-- License : Public Domain --\n-- --\n-- This module contains Agda implementation of code presented in --\n-- \"Why Dependent Types Matter\" by Thorsten Altenkirch, Conor --\n-- McBride and James McKinna. Original code in the paper was --\n-- written in Epigram but with its official web page offline --\n-- Epigram seems to be dead. Original paper elides details of some --\n-- proofs. I supplied the missing parts so that this module is --\n-- complete and self-contained. I avoided using the standard --\n-- library to show how the proofs are constructed from --\n-- scratch. This means I have to reinvent some of basic things like --\n-- natural numbers, lists or vector. Some of the code below is not --\n-- mine, in which case I refer to the original source. If you're --\n-- reading \"Why Dependent Types Matter\" I encourage you to try and --\n-- implement all the code by yourself. I assure you that this will --\n-- be very rewarding. --\n-- --\n-- This code was written and tested in Agda 2.3.2.1. YMMV --\n-- --\n----------------------------------------------------------------------\n\nmodule WhyDependentTypesMatter where\n\n-- Reinventing the wheel: we will need a type of pairs to implement\n-- deal function that splits list into a pair of lists. Sg is in fact\n-- type of dependent pairs. This code is taken from Conor McBride:\n-- https://github.com/pigworker/MetaprogAgda/blob/master/Basics.agda\nrecord Sg (S : Set)(T : S → Set) : Set where\n constructor _,_\n field\n fst : S\n snd : T fst\nopen Sg public\n_×_ : Set → Set → Set\nS × T = Sg S λ _ → T\ninfixr 4 _,_ _×_\n\n-- Section 1 : Introduction\n-- ~~~~~~~~~~~~~~~~~~~~~~~~\n-- Standard implementation of merge sort with no dependent types. This\n-- implements code shown in the paper in Figure 1.\n\ndata Nat : Set where\n zero : Nat\n suc : Nat → Nat\n\ndata Order : Set where\n le ge : Order\n\ndata List (X : Set) : Set where\n nil : List X\n _::_ : X → List X → List X\n\norder : Nat → Nat → Order\norder zero y = le\norder (suc x) zero = ge\norder (suc x) (suc y) = order x y\n\n-- deal splits a list into a pair of lists. If the input list has even length\n-- then the output lists have the same length. If input has odd length then\n-- first output list is longer by one.\ndeal : {X : Set} → List X → List X × List X\ndeal nil = nil , nil\ndeal (x :: nil) = x :: nil , nil\ndeal (y :: (z :: xs)) with deal xs\ndeal (y :: (z :: xs)) | ys , zs = y :: ys , z :: zs\n\n-- We have a small problem with merge and sort functions - Agda's termination\n-- checker complains about merge and sort. The problem is that it doesn't see\n-- that parameteres to merge are actually getting smaller in the recursive\n-- calls. This results from the usage of \"with\" pattern, which is desugared to\n-- an auxiliary function (say, \"go\"). Here's an explanation from Andreas Abel:\n--\n-- the termination checker refutes this call pattern.\n--\n-- merge (x :: xs) (y :: ys)\n-- --> go x xs y ys ...\n-- --> merge xs (y :: ys)\n--\n-- The termination checker sees that in merge-->go, the arguments all become\n-- smaller, but in go--->merge, one argument becomes bigger. Since it has\n-- simplistic, it cannot remember where y and ys came from and that taken\n-- together, they are actually the same as we started out.\n--\n-- See Andreas' full explanation on Agda mailing list here:\n-- https://lists.chalmers.se/pipermail/agda/2013/005948.html\n--\n-- I could rewrite the code to avoid this problem, but I'm leaving it as-is\n-- because IMO it teaches something important about Agda's termination checker.\nmerge : List Nat → List Nat → List Nat\nmerge nil ys = ys\nmerge xs nil = xs\nmerge (x :: xs) (y :: ys) with order x y\nmerge (x :: xs) (y :: ys) | le = x :: merge xs (y :: ys)\nmerge (x :: xs) (y :: ys) | ge = y :: merge (x :: xs) ys\n\n-- After I posted the original code I realized that it is not obvious that this\n-- function is total. We know that (deal xs) is smaller than xs, but I think\n-- that this isn't obvious.\nsort : List Nat → List Nat\nsort xs with deal xs\nsort xs | ys , nil = ys\nsort xs | ys , zs = merge (sort ys) (sort zs)\n\n-- Section 3.1 : Totality is Good for more than the Soul\n-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n-- Here we reinvent another wheel - refl\n\ndata _≡_ {S : Set} (s : S) : S → Set where\n refl : s ≡ s\n\ninfixl 1 _≡_\n\n-- Section 3.2 : Defusing General Recursion\n-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n-- Merge sort with explicit structure of recursion.\n\ndata Parity : Set where\n p0 p1 : Parity\n\ndata DealT (X : Set) : Set where\n empT : DealT X\n leafT : X → DealT X\n nodeT : Parity → DealT X → DealT X → DealT X\n\ninsertT : {X : Set} → X → DealT X → DealT X\ninsertT x empT = leafT x\ninsertT x (leafT y) = nodeT p0 (leafT y) (leafT x)\ninsertT x (nodeT p0 l r) = nodeT p1 (insertT x l) r\ninsertT x (nodeT p1 l r) = nodeT p0 l (insertT x r)\n\ndealT : {X : Set} → List X → DealT X\ndealT nil = empT\ndealT (x :: xs) = insertT x (dealT xs)\n\nmergeT : DealT Nat → List Nat\nmergeT empT = nil\nmergeT (leafT x) = x :: nil\nmergeT (nodeT p l r) = merge (mergeT l) (mergeT r)\n\n-- In the paper this function is called sort. Here and in other places I rename\n-- functions to avoid name clashes.\nsortT : List Nat → List Nat\nsortT xs = mergeT (dealT xs)\n\n-- Section 4 : Maintaining Invariants by Static Indexing\n-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n-- Note that I'm using (suc n) instead of (1 + n). Why?\n-- becuase I'm not using Agda's BUILTIN pragmas, so I'd\n-- have to write (suc zero) instead of 1. This doesn't\n-- change much in the proofs we'll be doing.\ndata Vec (X : Set) : Nat → Set where\n vnil : Vec X zero\n vcons : {n : Nat} → X → Vec X n → Vec X (suc n)\n\nvtail : {X : Set} {n : Nat} → Vec X (suc n) → Vec X n\nvtail (vcons x xs) = xs\n\n-- @ is a reserved sign in Agda, so I'm using vapp to denote\n-- vectorized application.\nvapp : {A B : Set} {n : Nat} → Vec (A → B) n → Vec A n → Vec B n\nvapp vnil vnil = vnil\nvapp (vcons f fs) (vcons s ss) = vcons (f s) (vapp fs ss)\n\n_+_ : Nat → Nat → Nat\nzero + n = n\nsuc m + n = suc (m + n)\n\ninfixl 4 _+_\n\n_++_ : {X : Set} {n m : Nat} → Vec X n → Vec X m → Vec X (n + m)\nvnil ++ ys = ys\nvcons x xs ++ ys = vcons x (xs ++ ys)\n\nvec : {X : Set} {n : Nat} → X → Vec X n\nvec {X} {zero} x = vnil\nvec {X} {suc n} x = vcons x (vec x)\n\nxpose : {X : Set} {n m : Nat} → Vec (Vec X n) m → Vec (Vec X m) n\nxpose vnil = vec vnil\nxpose (vcons xj xi'j) = vapp (vapp (vec vcons) xj) (xpose xi'j)\n\n-- Section 4.1 : Static Indexing and Proofs\n-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n-- This section is the one that is missing some of the proofs.\n\nvrevacc : {X : Set} {n m : Nat} → Vec X n → Vec X m → Vec X (n + m)\nvrevacc vnil ys = ys\nvrevacc (vcons x xs) ys = {!!} -- vrevacc xs (vcons x ys)\n-- We can't fill in the correct code, because Agda doesn't know that m + (1 + n)\n-- eqauls 1 + (m + n). We will have to prove it.\n\n-- To conduct a proof we will need three properties:\n-- a) symmetry: if a equals b then b equals a\nsym : {A : Set} → {a b : A} → a ≡ b → b ≡ a\nsym refl = refl\n\n-- b) congruence: if a equals b, then (f a) equals (f b)\ncong : {A B : Set} (f : A → B) → ∀ {x y} → x ≡ y → f x ≡ f y\ncong f refl = refl\n\n-- c) substitution: if we have a proposition that is true for a\n-- and a equals b, then proposition is also true for b\nsubst : {A : Set}(P : A → Set) → {a b : A} → a ≡ b → P a → P b\nsubst prp refl p = p\n\n-- These three properties were taken from Thorsten Altenkirch's course\n-- on Computer Aided Formal Reasoning: http://www.cs.nott.ac.uk/~txa/g53cfr/\n-- If you don't know how they work and why do we need them now is a good moment\n-- to stop reading \"Why Dependent Types Matter\" and go through lectures 1-9\n-- of Thorsten's course.\n\nplusSuc : (m n : Nat) → suc (m + n) ≡ m + (suc n)\nplusSuc zero n = refl\nplusSuc (suc m) n = cong suc (plusSuc m n)\n\nvrevacc2 : {X : Set} {n m : Nat} → Vec X n → Vec X m → Vec X (n + m)\nvrevacc2 vnil ys = ys\nvrevacc2 {X} {suc n} {m} (vcons x xs) ys =\n subst (Vec X) (sym (plusSuc n m)) (vrevacc2 xs (vcons x ys))\n\n-- Last line corresponds to\n--\n-- {[plusSuc m' n⟩} vrevacc2 xs (vcons x ys)\n--\n-- in the paper. Call to vrevacc2 produces Vec with index n + (suc m). The\n-- problem is we need index suc (n + m). We need to prove their equality. we\n-- already proved with plusSuc that suc (n + m) equals n + (suc m). Since now\n-- we're proving something opposite we make use of symmetry: we apply sym to\n-- plusSuc. Having a proof is not enough - we must apply it to convert from the\n-- result produced by vrevacc2 to the result expected by the typechecker. To do\n-- this we use subst function. Our proposition is (Vec X). Look at the type\n-- signature of subst - the proposition is something that will take an element\n-- of Set (in this case Nat) and produce an element of Set. Vec X will return an\n-- element of Set (ie a type) when we pass it an index of type Nat. subst\n-- replaces (substitutes) index n + (suc m) produced by vrevacc2 with\n-- suc (n + m).\n\nplusZero : (n : Nat) → n + zero ≡ n\nplusZero zero = refl\nplusZero (suc n) = cong suc (plusZero n)\n\nvrev : {X : Set} {n : Nat} → Vec X n → Vec X n\nvrev {X} {n} xs = subst (Vec X) (plusZero n) (vrevacc2 xs vnil)\n\n-- Section 4.2 : Sized Merge-Sort\n-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n-- note that mergeS is a renamed merge from the paper\nmergeS : {n m : Nat} → Vec Nat n → Vec Nat m → Vec Nat (n + m)\nmergeS {zero } {_ } vnil ys = ys\nmergeS {suc n} {zero } (vcons x xs) vnil =\n subst (Vec Nat) (sym (plusZero (suc n))) (vcons x xs)\nmergeS {suc n} {suc m} (vcons x xs) (vcons y ys) with order x y\nmergeS {suc n} {suc m} (vcons x xs) (vcons y ys) | le =\n vcons x (mergeS xs (vcons y ys))\nmergeS {suc n} {suc m} (vcons x xs) (vcons y ys) | ge =\n subst (Vec Nat) (plusSuc (suc n) m) (vcons y (mergeS (vcons x xs) ys))\n\np2n : Parity → Nat\np2n p0 = zero\np2n p1 = suc zero\n\n-- Data types and functions below have S (mnemonic for Sized) appended to their\n-- name to avoid name clash.\ndata DealTS (X : Set) : Nat → Set where\n empT : DealTS X zero\n leafT : X → DealTS X (suc zero)\n nodeT : {n : Nat} → (p : Parity) → DealTS X (p2n p + n) → DealTS X n\n → DealTS X ((p2n p + n) + n)\n\nmergeTS : {n : Nat} → DealTS Nat n → Vec Nat n\nmergeTS empT = vnil\nmergeTS (leafT x) = vcons x vnil\nmergeTS (nodeT p l r) = mergeS (mergeTS l) (mergeTS r)\n\ninsertTS : {n : Nat} {X : Set} → X → DealTS X n → DealTS X (suc n)\ninsertTS x empT = leafT x\ninsertTS x (leafT y ) = nodeT p0 (leafT y) (leafT x)\ninsertTS x (nodeT p0 l r) = nodeT p1 (insertTS x l) r\ninsertTS {.(p2n p1 + n + n)} {X} x (nodeT {n} p1 l r) =\n subst (DealTS X) (sym (cong suc (plusSuc n n))) (nodeT p0 l (insertTS x r))\n-- | | |\n-- | | +---- suc (n + n) ≡ n + suc n\n-- | +-------------- suc (suc (n + n)) ≡ suc (n + suc n))\n-- +------------------- suc (n + suc n)) ≡ suc (suc (n + n))\n--\n-- It took me a while to figure out this proof (though in retrospect it is\n-- simple). The expected size of the resulting vector is:\n--\n-- suc (suc (n + n))\n--\n-- First suc comes from the type signature of insertTS, second suc comes from\n-- p2n p1 (which is suc zero), and n + n comes from nodeT definition. The actual\n-- size produced by recursive call to nodeT is:\n--\n-- suc (n + suc n))\n--\n-- Outer suc comes from type signature, n is size of l, suc n is size of new r\n-- (ie. r with x inserted into it).\n\ndealTS : {X : Set} {n : Nat} → Vec X n → DealTS X n\ndealTS vnil = empT\ndealTS (vcons x xs) = insertTS x (dealTS xs)\n\nsortTS : {n : Nat} → Vec Nat n → Vec Nat n\nsortTS xs = mergeTS (dealTS xs)\n\n-- Section 5.1 : Evidence of Ordering\n-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\ndata _≤_ : Nat → Nat → Set where\n le0 : {y : Nat} → zero ≤ y\n leS : {x : Nat} {y : Nat} → x ≤ y → suc x ≤ suc y\n\ndata OrderD : Nat → Nat → Set where\n le : {x : Nat} {y : Nat} → x ≤ y → OrderD x y\n ge : {x : Nat} {y : Nat} → y ≤ x → OrderD x y\n\norderD : (x : Nat) → (y : Nat) → OrderD x y\norderD zero y = le le0\norderD (suc x) zero = ge le0\norderD (suc x) (suc y) with orderD x y\norderD (suc x) (suc y) | le xley = le (leS xley)\norderD (suc x) (suc y) | ge ylex = ge (leS ylex)\n\nleRefl : {x : Nat} → x ≤ x\nleRefl {zero} = le0\nleRefl {suc x} = leS leRefl\n\nleTrans : {x y z : Nat} → x ≤ y → y ≤ z → x ≤ z\nleTrans le0 yz = le0\nleTrans (leS xy) (leS yz) = leS (leTrans xy yz)\n\nleASym : {x y : Nat} → x ≤ y → y ≤ x → x ≡ x\nleASym le0 le0 = refl\nleASym (leS xy) (leS yx) = refl\n\n-- Second equation for leASym is surprisingly simple. I admit I don't fully\n-- understand why I could simply use refl here, without doing inductive proof.\n\n-- Section 5.2 : Locally Sorted Lists\n-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n-- LNat = Nat lifted with infinity\ndata LNat : Set where\n zero : LNat\n suc : LNat → LNat\n inf : LNat\n\nlift : Nat → LNat\nlift zero = zero\nlift (suc x) = suc (lift x)\n\n-- In the paper ≤ is used for comparisons on lifted Nats. I'm using ≤' to avoid\n-- name clash.\ndata _≤'_ : LNat → LNat → Set where\n le0 : {y : LNat} → zero ≤' y\n leS : {x : LNat} {y : LNat} → x ≤' y → suc x ≤' suc y\n leI : {x : LNat} → x ≤' inf\n\ndata CList : LNat → Set where\n cnil : CList inf\n ccons : {y : LNat} → (x : Nat) → (lift x) ≤' y → CList y → CList (lift x)\n-- |\n-- +---------------------------+\n-- +--> Paper compares lifted and unlifted Nat using ≤.\n-- This seems incorrect or at least unprecise.\n\n-- The problem with CList is that we can't create it if we don't know the least\n-- element. That's why the paper says sort is bound by min.\nclist : CList zero\nclist = ccons zero le0 (\n ccons (suc (suc zero)) (leS (leS le0)) (\n ccons (suc (suc zero)) leI cnil))\n\ndata OList : Nat → Set where\n onil : {b : Nat} → OList b\n ocons : {b : Nat} → (x : Nat) → b ≤ x → OList x → OList b\n\n-- With OList we can just create the list by saying it is bound by zero.\nolist : OList zero\nolist = ocons (suc zero) le0 onil\n\nolist2 : OList zero\nolist2 = ocons (suc zero) le0 (ocons (suc (suc zero)) (leS le0) onil)\n\n-- mergeO (ie. merge for open-bounds lists) has the same problem that we've seen\n-- earlier with merge and sort - termination checker complains because we use\n-- \"with\" pattern.\nmergeO : {b : Nat} → OList b → OList b → OList b\nmergeO onil ys = ys\nmergeO (ocons x blex xs) onil = ocons x blex xs\nmergeO (ocons x blex xs) (ocons y bley ys) with orderD x y\nmergeO (ocons x blex xs) (ocons y bley ys) | le xley =\n ocons x blex (mergeO xs (ocons y xley ys))\nmergeO (ocons x blex xs) (ocons y bley ys) | ge ylex =\n ocons y bley (mergeO (ocons x ylex xs) ys)\n\n-- The important thing here is that both lists passed to mergeO must share their\n-- lower bound. That's why we have to replace old evidence of ordering (bley in\n-- the first case) with the new one (xley).\n\nmergeTO : DealT Nat → OList zero\nmergeTO empT = onil\nmergeTO (leafT x) = ocons x le0 onil\nmergeTO (nodeT p l r) = mergeO (mergeTO l) (mergeTO r)\n\nsortO : List Nat → OList zero\nsortO xs = mergeTO (dealT xs)\n", "meta": {"hexsha": "b3575cd034c9ba5f5be3f04aaf79f2c5eb2c920e", "size": 15785, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tests/beyond/WhyDependentTypesMatter.agda", "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_issues_repo_path": "tests/beyond/WhyDependentTypesMatter.agda", "max_issues_repo_name": "andrejtokarcik/agda-semantics", "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/beyond/WhyDependentTypesMatter.agda", "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.0361445783, "max_line_length": 80, "alphanum_fraction": 0.5861260691, "num_tokens": 5044, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.78793120560257, "lm_q2_score": 0.7879312006227324, "lm_q1q2_score": 0.62083558083855}} {"text": "------------------------------------------------------------------------------\n-- FOT (First-Order Theories)\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- Code accompanying the PhD thesis \"Reasoning about Functional\n-- Programs by Combining Interactive and Automatic Proofs\" by Andrés\n-- Sicard-Ramírez.\n\n-- The code presented here does not match the thesis exactly.\n\nmodule README where\n\n------------------------------------------------------------------------------\n-- Description\n\n-- Examples of the formalization of first-order theories showing the\n-- combination of interactive proofs with automatics proofs carried\n-- out by first-order automatic theorem provers (ATPs).\n\n------------------------------------------------------------------------------\n-- For the thesis, prerequisites, tested versions of the ATPs and use,\n-- see https://github.com/asr/fotc/.\n\n------------------------------------------------------------------------------\n-- Conventions\n\n-- If the module's name ends in 'I' the module contains interactive\n-- proofs, if it ends in 'ATP' the module contains combined proofs,\n-- otherwise the module contains definitions and/or interactive proofs\n-- that are used by the interactive and combined proofs.\n\n------------------------------------------------------------------------------\n-- First-order theories\n------------------------------------------------------------------------------\n\n-- • First-order logic with equality\n\n-- First-order logic (FOL)\nopen import FOL.README\n\n-- Propositional equality\nopen import Common.FOL.Relation.Binary.PropositionalEquality\n\n-- Equality reasoning\nopen import Common.FOL.Relation.Binary.EqReasoning\n\n-- • Group theory\n\nopen import GroupTheory.README\n\n-- • Distributive laws on a binary operation (Stanovský example)\n\nopen import DistributiveLaws.README\n\n-- • First-order Peano arithmetic (PA)\n\nopen import PA.README\n\n-- • First-Order Theory of Combinators (FOTC)\n\nopen import FOTC.README\n\n-- • Logical Theory of Constructions for PCF (LTC-PCF)\n\nopen import LTC-PCF.README\n\n------------------------------------------------------------------------------\n-- Agsy examples\n------------------------------------------------------------------------------\n\n-- We cannot import the Agsy examples because some modules contain\n-- unsolved metas, therefore see examples/Agsy/README.txt\n", "meta": {"hexsha": "dc7d8982d7ba282219a9b44f6502362add1fa184", "size": 2544, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/README.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/README.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/README.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 32.6153846154, "max_line_length": 78, "alphanum_fraction": 0.5330188679, "num_tokens": 437, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428947, "lm_q2_score": 0.787931185683219, "lm_q1q2_score": 0.6208355612197024}} {"text": "------------------------------------------------------------------------------\n-- Equivalent approaches for implement the inductive predicate N\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOTC.EquivalenceInductivePredicateN where\n\nopen import FOTC.Base\n\n------------------------------------------------------------------------------\n-- Using succ : D instead of succ₁ : D → D.\n\nmodule Constant where\n\n module LFP where\n\n NatF : (D → Set) → D → Set\n NatF A n = n ≡ zero ∨ (∃[ n' ] n ≡ succ · n' ∧ A n')\n\n postulate\n N : D → Set\n N-in-ho : ∀ {n} → NatF N n → N n\n N-ind'-ho : (A : D → Set) → (∀ {n} → NatF A n → A n) → ∀ {n} → N n → A n\n\n N-in : ∀ {n} → n ≡ zero ∨ (∃[ n' ] n ≡ succ · n' ∧ N n') → N n\n N-in = N-in-ho\n\n N-ind' : (A : D → Set) →\n (∀ {n} → n ≡ zero ∨ (∃[ n' ] n ≡ succ · n' ∧ A n') → A n) →\n ∀ {n} → N n → A n\n N-ind' = N-ind'-ho\n\n --------------------------------------------------------------------------\n -- The data constructors of N using LFP.\n\n nzero : N zero\n nzero = N-in (inj₁ refl)\n\n nsucc : ∀ {n} → N n → N (succ · n)\n nsucc Nn = N-in (inj₂ (_ , refl , Nn))\n\n --------------------------------------------------------------------------\n -- The induction principle of N using LFP.\n N-ind : (A : D → Set) →\n A zero →\n (∀ {n} → A n → A (succ · n)) →\n ∀ {n} → N n → A n\n N-ind A A0 h = N-ind' A h'\n where\n h' : ∀ {m} → m ≡ zero ∨ (∃[ m' ] m ≡ succ · m' ∧ A m') → A m\n h' (inj₁ m≡0) = subst A (sym m≡0) A0\n h' (inj₂ (m' , prf , Am')) = subst A (sym prf) (h Am')\n\n ----------------------------------------------------------------------------\n module Data where\n\n data N : D → Set where\n nzero : N zero\n nsucc : ∀ {n} → N n → N (succ · n)\n\n N-ind : (A : D → Set) →\n A zero →\n (∀ {n} → A n → A (succ · n)) →\n ∀ {n} → N n → A n\n N-ind A A0 h nzero = A0\n N-ind A A0 h (nsucc Nn) = h (N-ind A A0 h Nn)\n\n --------------------------------------------------------------------------\n -- The introduction rule of N using data.\n N-in : ∀ {n} → n ≡ zero ∨ (∃[ n' ] n ≡ succ · n' ∧ N n') → N n\n N-in {n} h = case prf₁ prf₂ h\n where\n prf₁ : n ≡ zero → N n\n prf₁ n≡0 = subst N (sym n≡0) nzero\n\n prf₂ : ∃[ n' ] n ≡ succ · n' ∧ N n' → N n\n prf₂ (n' , prf , Nn') = subst N (sym prf) (nsucc Nn')\n\n --------------------------------------------------------------------------\n -- The induction principle for N using data.\n N-ind' :\n (A : D → Set) →\n (∀ {n} → n ≡ zero ∨ (∃[ n' ] n ≡ succ · n' ∧ A n') → A n) →\n ∀ {n} → N n → A n\n N-ind' A h = N-ind A h₁ h₂\n where\n h₁ : A zero\n h₁ = h (inj₁ refl)\n\n h₂ : ∀ {m} → A m → A (succ · m)\n h₂ {m} Am = h (inj₂ (m , refl , Am))\n\n------------------------------------------------------------------------------\n-- Using succ₁ : D → D instead of succ : D.\n\nmodule UnaryFunction where\n\n module LFP where\n\n NatF : (D → Set) → D → Set\n NatF A n = n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ A n')\n\n postulate\n N : D → Set\n N-in-ho : ∀ {n} → NatF N n → N n\n N-ind'-ho : (A : D → Set) → (∀ {n} → NatF A n → A n) → ∀ {n} → N n → A n\n\n N-in : ∀ {n} → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ N n') → N n\n N-in = N-in-ho\n\n N-ind' : (A : D → Set) →\n (∀ {n} → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ A n') → A n) →\n ∀ {n} → N n → A n\n N-ind' = N-ind'-ho\n\n --------------------------------------------------------------------------\n -- The data constructors of N using LFP.\n\n nzero : N zero\n nzero = N-in (inj₁ refl)\n\n nsucc : ∀ {n} → N n → N (succ₁ n)\n nsucc Nn = N-in (inj₂ (_ , refl , Nn))\n\n --------------------------------------------------------------------------\n -- The induction principle of N using LFP.\n N-ind : (A : D → Set) →\n A zero →\n (∀ {n} → A n → A (succ₁ n)) →\n ∀ {n} → N n → A n\n N-ind A A0 h = N-ind' A h'\n where\n h' : ∀ {m} → m ≡ zero ∨ (∃[ m' ] m ≡ succ₁ m' ∧ A m') → A m\n h' (inj₁ m≡0) = subst A (sym m≡0) A0\n h' (inj₂ (m' , prf , Am')) = subst A (sym prf) (h Am')\n\n ----------------------------------------------------------------------------\n module Data where\n\n data N : D → Set where\n nzero : N zero\n nsucc : ∀ {n} → N n → N (succ₁ n)\n\n N-ind : (A : D → Set) →\n A zero →\n (∀ {n} → A n → A (succ₁ n)) →\n ∀ {n} → N n → A n\n N-ind A A0 h nzero = A0\n N-ind A A0 h (nsucc Nn) = h (N-ind A A0 h Nn)\n\n --------------------------------------------------------------------------\n -- The introduction rule of N using data.\n N-in : ∀ {n} → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ N n') → N n\n N-in {n} h = case prf₁ prf₂ h\n where\n prf₁ : n ≡ zero → N n\n prf₁ n≡0 = subst N (sym n≡0) nzero\n\n prf₂ : ∃[ n' ] n ≡ succ₁ n' ∧ N n' → N n\n prf₂ (n' , prf , Nn') = subst N (sym prf) (nsucc Nn')\n\n --------------------------------------------------------------------------\n -- The induction principle for N using data.\n N-ind' :\n (A : D → Set) →\n (∀ {n} → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ A n') → A n) →\n ∀ {n} → N n → A n\n N-ind' A h = N-ind A h₁ h₂\n where\n h₁ : A zero\n h₁ = h (inj₁ refl)\n\n h₂ : ∀ {m} → A m → A (succ₁ m)\n h₂ {m} Am = h (inj₂ (m , refl , Am))\n\nmodule EsikProposition2Dot1 where\n\n postulate\n N : D → Set\n\n N-ind' : (A : D → Set) →\n (∀ {n} → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ A n') → A n) →\n ∀ {n} → N n → A n\n", "meta": {"hexsha": "4c1e567ae37cde8899edf047cb073b495b442cba", "size": 5919, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/thesis/report/FOTC/EquivalenceInductivePredicateN.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/thesis/report/FOTC/EquivalenceInductivePredicateN.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/thesis/report/FOTC/EquivalenceInductivePredicateN.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 31.4840425532, "max_line_length": 78, "alphanum_fraction": 0.3367122825, "num_tokens": 2009, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303087996142, "lm_q2_score": 0.7853085909370422, "lm_q1q2_score": 0.6208102428964498}} {"text": "module Relation.Binary.Lattice.Residuated where\n\nopen import Level\nopen import Algebra.FunctionProperties using (Op₂)\nopen import Algebra.Structures using (IsMonoid)\nopen import Algebra using (Monoid)\nopen import Relation.Binary\nopen import Relation.Binary.Core\nopen import Relation.Binary.Lattice using (Lattice; IsLattice)\nopen import Data.Product\n\n\nLeftResidual : ∀ {c ℓ₂} {L : Set c}\n → (_≤_ : Rel L ℓ₂) -- The partial order.\n → (_∙_ : Op₂ L) -- The monoid operation.\n → (_◁_ : Op₂ L) -- The left residual.\n → Set (c ⊔ ℓ₂)\nLeftResidual _≤_ _∙_ _◁_ = ∀ y z → (((z ◁ y) ∙ y) ≤ z) × (Maximum _≤_ (z ◁ y))\n\nRightResidual : ∀ {c ℓ₂} {L : Set c}\n → (_≤_ : Rel L ℓ₂) -- The partial order.\n → (_∙_ : Op₂ L) -- The monoid operation.\n → (_▷_ : Op₂ L) -- The right residual.\n → Set (c ⊔ ℓ₂)\nRightResidual _≤_ _∙_ _▷_ = ∀ x z → ((x ∙ (x ▷ z)) ≤ z) × (Maximum _≤_ (x ▷ z))\n\n\nrecord IsResiduated {c ℓ₁ ℓ₂} {L : Set c}\n (_≈_ : Rel L ℓ₁) -- The underlying equality.\n (_≤_ : Rel L ℓ₂) -- The partial order.\n (_∨_ : Op₂ L) -- The join operation.\n (_∧_ : Op₂ L) -- The meet operation.\n (_∙_ : Op₂ L) -- The monoid operation.\n (ε : L) -- The identity element.\n (_▷_ : Op₂ L) -- The right residual.\n (_◁_ : Op₂ L) -- The left residual.\n : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n field\n isLattice : IsLattice _≈_ _≤_ _∨_ _∧_\n isMonoid : IsMonoid _≈_ _∙_ ε\n isLeftResidual : LeftResidual _≤_ _∙_ _◁_\n isRightResidual : RightResidual _≤_ _∙_ _▷_\n ∙-monotonic : _∙_ Preserves₂ _≤_ ⟶ _≤_ ⟶ _≤_\n\n\n -- ∀ x y x\n -- y ≤ x ▷ z\n -- ⇔ x ∙ y ≤ z\n -- ⇔ x ≤ z ◁ y\n\n module Pre = IsPreorder (IsPartialOrder.isPreorder (IsLattice.isPartialOrder isLattice))\n\n -- theorems about the residuals, requires _∙_ to be monotonic\n ∙-at-left : ∀ x y z\n → y ≤ (x ▷ z)\n → (x ∙ y) ≤ z\n ∙-at-left x y z P = Pre.trans (∙-monotonic Pre.refl P) (proj₁ (isRightResidual x z))\n\n ∙-at-right : ∀ x y z\n → x ≤ (z ◁ y)\n → (x ∙ y) ≤ z\n ∙-at-right x y z P = Pre.trans (∙-monotonic P Pre.refl) (proj₁ (isLeftResidual y z))\n\n apply-▷ : ∀ x y z\n → (x ∙ y) ≤ z\n → y ≤ (x ▷ z)\n apply-▷ x y z P = proj₂ (isRightResidual x z) y\n\n apply-◁ : ∀ x y z\n → (x ∙ y) ≤ z\n → x ≤ (z ◁ y)\n apply-◁ x y z P = proj₂ (isLeftResidual y z) x\n\n \n\n -- other modules\n\n monoid : Monoid c ℓ₁\n monoid = record { isMonoid = isMonoid }\n\n lattice : Lattice c ℓ₁ ℓ₂\n lattice = record { isLattice = isLattice }\n\n\nrecord Residuated c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _≤_\n infixr 6 _∨_\n infixr 7 _∧_\n infixr 5 _∙_\n infixr 8 _▷_ _◁_\n\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ₁ -- The underlying equality.\n _≤_ : Rel Carrier ℓ₂ -- The partial order.\n _∨_ : Op₂ Carrier -- The join operation.\n _∧_ : Op₂ Carrier -- The meet operation.\n _∙_ : Op₂ Carrier -- The monoid operation.\n ε : Carrier -- The identity element.\n\n _▷_ : Op₂ Carrier -- The right residual.\n _◁_ : Op₂ Carrier -- The left residual.\n isResiduated : IsResiduated _≈_ _≤_ _∨_ _∧_ _∙_ ε _▷_ _◁_\n", "meta": {"hexsha": "e937c2aa64ecece20e0ca45ec450bec989074ac7", "size": 3557, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Relation/Binary/Lattice/Residuated.agda", "max_stars_repo_name": "banacorn/relalg", "max_stars_repo_head_hexsha": "cf4b37b85b13aced9a36f3216d676ee5599059f6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Relation/Binary/Lattice/Residuated.agda", "max_issues_repo_name": "banacorn/relalg", "max_issues_repo_head_hexsha": "cf4b37b85b13aced9a36f3216d676ee5599059f6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Relation/Binary/Lattice/Residuated.agda", "max_forks_repo_name": "banacorn/relalg", "max_forks_repo_head_hexsha": "cf4b37b85b13aced9a36f3216d676ee5599059f6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.2019230769, "max_line_length": 92, "alphanum_fraction": 0.4984537532, "num_tokens": 1267, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513731336202, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.6207813227881548}} {"text": "\nrecord ⊤ : Set where\n instance constructor tt\n\ndata ⊥ : Set where\n\ndata Inf : Set where\n -∞ ∞ : Inf\n\nLess : Inf → Inf → Set\nLess ∞ _ = ⊥\nLess _ ∞ = ⊤\nLess _ _ = ⊥\n\ndata Bounded : Inf → Set where\n bound : ∀ {b} {{lt : Less -∞ b}} → Bounded b\n\n-- The first time around the target type is Less -∞ _b which results in no\n-- candidates. Once _b gets solved candidates need to be recomputed.\nfoo : Bounded ∞\nfoo = bound\n", "meta": {"hexsha": "fedeb9eacb4deb1e780d437e4b5f1e255f8989fa", "size": 418, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/RecomputeInstanceCandidates.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/RecomputeInstanceCandidates.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/RecomputeInstanceCandidates.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 19.0, "max_line_length": 74, "alphanum_fraction": 0.6315789474, "num_tokens": 142, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8962513648201266, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.6207813227162263}} {"text": "-- Agda program using the Iowa Agda library\n\nopen import bool\n\nmodule PROOF-appendAddLengths\n (Choice : Set)\n (choose : Choice → 𝔹)\n (lchoice : Choice → Choice)\n (rchoice : Choice → Choice)\n where\n\nopen import eq\nopen import nat\nopen import list\nopen import maybe\n\n---------------------------------------------------------------------------\n-- Translated Curry operations:\n\n++ : {a : Set} → 𝕃 a → 𝕃 a → 𝕃 a\n++ [] x = x\n++ (y :: z) u = y :: (++ z u)\n\nappend : {a : Set} → 𝕃 a → 𝕃 a → 𝕃 a\nappend x y = ++ x y\n\n---------------------------------------------------------------------------\n\nappendAddLengths : {a : Set} → (x : 𝕃 a) → (y : 𝕃 a)\n → ((length x) + (length y)) ≡ (length (append x y))\nappendAddLengths [] y = refl\nappendAddLengths (x :: xs) y rewrite appendAddLengths xs y = refl\n\n---------------------------------------------------------------------------\n", "meta": {"hexsha": "5294fa52d2ede43be95445194e5d3a6b5420f42b", "size": 884, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "currypp/.cpm/packages/currycheck/examples/withVerification/PROOF-appendAddLengths.agda", "max_stars_repo_name": "phlummox/curry-tools", "max_stars_repo_head_hexsha": "7905bc4f625a94a725f9f6d8a2de1140bea5e471", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "currypp/.cpm/packages/currycheck/examples/withVerification/PROOF-appendAddLengths.agda", "max_issues_repo_name": "phlummox/curry-tools", "max_issues_repo_head_hexsha": "7905bc4f625a94a725f9f6d8a2de1140bea5e471", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "currypp/.cpm/packages/currycheck/examples/withVerification/PROOF-appendAddLengths.agda", "max_forks_repo_name": "phlummox/curry-tools", "max_forks_repo_head_hexsha": "7905bc4f625a94a725f9f6d8a2de1140bea5e471", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.2571428571, "max_line_length": 75, "alphanum_fraction": 0.4389140271, "num_tokens": 239, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9005297887874625, "lm_q2_score": 0.6893056295505783, "lm_q1q2_score": 0.6207402529891911}} {"text": "\nmodule Prelude where\n\ndata _==_ {A : Set}(x : A) : A → Set where\n refl : x == x\n\nJ : {A : Set} {x y : A} (P : (x y : A) → x == y -> Set) →\n (∀ z → P z z refl) → (p : x == y) → P x y p\nJ P h refl = h _\n", "meta": {"hexsha": "ad29bea2628f2f232232bf5421ae0017bbb352e7", "size": 206, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/prototyping/term/examples/Prelude.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_issues_repo_path": "src/prototyping/term/examples/Prelude.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/prototyping/term/examples/Prelude.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 20.6, "max_line_length": 57, "alphanum_fraction": 0.4174757282, "num_tokens": 93, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.900529786117893, "lm_q2_score": 0.6893056231680121, "lm_q1q2_score": 0.620740245401351}} {"text": "\nmodule _ where\n\nopen import Common.Prelude\nopen import Common.Equality\n\nrecord Functor (F : Set → Set) : Set₁ where\n field\n fmap : ∀ {A B} → (A → B) → F A → F B\n\nopen Functor {{...}} public\n\nrecord Applicative (F : Set → Set) : Set₁ where\n field\n pure : ∀ {A} → A → F A\n _<*>_ : ∀ {A B} → F (A → B) → F A → F B\n instance Fun : Functor F\n\n defaultApplicativeFunctor : Functor F\n fmap {{defaultApplicativeFunctor}} f x = pure f <*> x\n\nopen Applicative {{...}} public hiding (Fun)\n\n-- Concrete instances --\n\ndata Vec (A : Set) : Nat → Set where\n [] : Vec A zero\n _∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)\n\nvmap : ∀ {A B n} → (A → B) → Vec A n → Vec B n\nvmap f [] = []\nvmap f (x ∷ xs) = f x ∷ vmap f xs\n\nit : ∀ {a} {A : Set a} {{_ : A}} → A\nit {{x}} = x\n\npureV : ∀ {n A} → A → Vec A n\npureV {zero} _ = []\npureV {suc n} x = x ∷ pureV x\n\ninstance\n FunctorVec : ∀ {n} → Functor (λ A → Vec A n)\n fmap {{FunctorVec}} = vmap\n\n ApplicativeVec : ∀ {n} → Applicative (λ A → Vec A n)\n pure {{ApplicativeVec}} x = pureV x\n _<*>_ {{ApplicativeVec}} [] [] = []\n _<*>_ {{ApplicativeVec}} (f ∷ fs) (x ∷ xs) = f x ∷ (fs <*> xs)\n Applicative.Fun ApplicativeVec = FunctorVec\n\n-- In this case there are two candidates for Functor Vec:\n-- FunctorVec and Applicative.Fun ApplicativeVec\n-- but since they are equal everything works out.\ntestVec : ∀ {n} → Vec Nat n → Vec Nat n → Vec Nat n\ntestVec xs ys = fmap _+_ xs <*> ys\n\nwhat : ∀ {n} → FunctorVec {n} ≡ it\nwhat = refl\n", "meta": {"hexsha": "8c3d375edd349d7207a42cffbaef0859220f8e70", "size": 1488, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/SuperClasses.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/Succeed/SuperClasses.agda", "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/SuperClasses.agda", "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.2203389831, "max_line_length": 64, "alphanum_fraction": 0.5698924731, "num_tokens": 539, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256393148981, "lm_q2_score": 0.7371581741774411, "lm_q1q2_score": 0.6205586512531274}} {"text": "{-# OPTIONS --without-K #-}\nmodule function.extensionality.proof where\n\nopen import level\nopen import sum\nopen import equality\nopen import function.extensionality.core\nopen import hott.univalence\nopen import hott.level.core\nopen import hott.level.closure.core\nopen import hott.equivalence.core\nopen import sets.unit\n\ntop : ∀ {i} → Set i\ntop = ↑ _ ⊤\n\n⊤-contr' : ∀ {i} → contr (↑ i ⊤)\n⊤-contr' {i} = lift tt , λ { (lift tt) → refl }\n\n-- this uses definitional η for ⊤\ncontr-exp-⊤ : ∀ {i j}{A : Set i} → contr (A → top {j})\ncontr-exp-⊤ = (λ _ → lift tt) , (λ f → refl)\n\nmodule Weak where\n →-contr : ∀ {i j}{A : Set i}{B : Set j}\n → contr B\n → contr (A → B)\n →-contr {A = A}{B = B} hB = subst contr p contr-exp-⊤\n where\n p : (A → top) ≡ (A → B)\n p = ap (λ X → A → X) (unique-contr ⊤-contr' hB)\n\n funext : ∀ {i j}{A : Set i}{B : Set j}\n → (f : A → B)(b : B)(h : (x : A) → b ≡ f x)\n → (λ _ → b) ≡ f\n funext f b h =\n ap (λ u x → proj₁ (u x))\n (contr⇒prop (→-contr (singl-contr b))\n (λ _ → (b , refl))\n (λ x → f x , h x))\n\nabstract\n Π-contr : ∀ {i j}{A : Set i}{B : A → Set j}\n → ((x : A) → contr (B x))\n → contr ((x : A) → B x)\n Π-contr {i}{j}{A}{B} hB = subst contr p contr-exp-⊤\n where\n p₀ : (λ _ → top) ≡ B\n p₀ = Weak.funext B top (λ x → unique-contr ⊤-contr' (hB x))\n\n p : (A → top {j}) ≡ ((x : A) → B x)\n p = ap (λ Z → (x : A) → Z x) p₀\n\n private\n funext₀ : ∀ {i j} → Extensionality' i j\n funext₀ {i}{j}{X = X}{Y = Y}{f = f}{g = g} h = ap (λ u x → proj₁ (u x)) lem\n where\n C : X → Set j\n C x = Σ (Y x) λ y → f x ≡ y\n\n f' g' : (x : X) → C x\n f' x = (f x , refl)\n g' x = (g x , h x)\n\n lem : f' ≡ g'\n lem = contr⇒prop (Π-contr (λ x → singl-contr (f x))) f' g'\n\nabstract\n funext : ∀ {i j} → Extensionality' i j\n funext h = funext₀ h · sym (funext₀ (λ _ → refl))\n\n funext-id : ∀ {i j}{X : Set i}{Y : X → Set j}\n → (f : (x : X) → Y x)\n → funext (λ x → refl {x = f x}) ≡ refl\n funext-id _ = left-inverse (funext₀ (λ _ → refl))\n", "meta": {"hexsha": "e0736ddd514f059bf5e59e35d35dc87b168048bc", "size": 2140, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "function/extensionality/proof.agda", "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_issues_repo_path": "function/extensionality/proof.agda", "max_issues_repo_name": "HoTT/M-types", "max_issues_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-02-11T11:14:59.000Z", "max_issues_repo_issues_event_max_datetime": "2015-02-11T15:20:34.000Z", "max_forks_repo_path": "function/extensionality/proof.agda", "max_forks_repo_name": "HoTT/M-types", "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z", "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z", "avg_line_length": 28.1578947368, "max_line_length": 79, "alphanum_fraction": 0.4738317757, "num_tokens": 843, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256432832333, "lm_q2_score": 0.7371581684030623, "lm_q1q2_score": 0.6205586493173979}} {"text": " {-# OPTIONS --type-in-type #-}\n\nmodule RevisedHutton where\n\n--********************************************\n-- Prelude\n--********************************************\n\n-- Some preliminary stuffs, to avoid relying on the stdlib\n\n--****************\n-- Sigma and friends\n--****************\n\ndata Sigma (A : Set) (B : A -> Set) : Set where\n _,_ : (x : A) (y : B x) -> Sigma A B\n\n_*_ : (A : Set)(B : Set) -> Set\nA * B = Sigma A \\_ -> B\n\nfst : {A : Set}{B : A -> Set} -> Sigma A B -> A\nfst (a , _) = a\n\nsnd : {A : Set}{B : A -> Set} (p : Sigma A B) -> B (fst p)\nsnd (a , b) = b\n\ndata Zero : Set where\ndata Unit : Set where\n Void : Unit\n\n--****************\n-- Sum and friends\n--****************\n\ndata _+_ (A : Set)(B : Set) : Set where\n l : A -> A + B\n r : B -> A + B\n\n--****************\n-- Equality\n--****************\n\ndata _==_ {A : Set}(x : A) : A -> Set where\n refl : x == x\n\nsubst : forall {x y} -> x == y -> x -> y\nsubst refl x = x\n\ncong : {A B : Set}(f : A -> B){x y : A} -> x == y -> f x == f y\ncong f refl = refl\n\ncong2 : {A B C : Set}(f : A -> B -> C){x y : A}{z t : B} -> \n x == y -> z == t -> f x z == f y t\ncong2 f refl refl = refl\n\npostulate \n reflFun : {A B : Set}(f : A -> B)(g : A -> B)-> ((a : A) -> f a == g a) -> f == g \n\n--****************\n-- Meta-language\n--****************\n\n-- Note that we could define Nat, Bool, and the related operations in\n-- IDesc. But it is awful to code with them, in Agda.\n\ndata Nat : Set where\n ze : Nat\n su : Nat -> Nat\n\ndata Bool : Set where\n true : Bool\n false : Bool\n\nplus : Nat -> Nat -> Nat\nplus ze n' = n'\nplus (su n) n' = su (plus n n')\n\nle : Nat -> Nat -> Bool\nle ze _ = true\nle (su _) ze = false\nle (su n) (su n') = le n n'\n\ndata Vec (A : Set) : Nat -> Set where\n vnil : Vec A ze\n vcons : {n : Nat} -> A -> Vec A n -> Vec A (su n)\n\ndata Fin : Nat -> Set where\n fze : {n : Nat} -> Fin (su n)\n fsu : {n : Nat} -> Fin n -> Fin (su n)\n\n\n\n--********************************************\n-- Desc code\n--********************************************\n\ndata IDesc (I : Set) : Set where\n var : I -> IDesc I\n const : Set -> IDesc I\n prod : IDesc I -> IDesc I -> IDesc I\n sigma : (S : Set) -> (S -> IDesc I) -> IDesc I\n pi : (S : Set) -> (S -> IDesc I) -> IDesc I\n\n\n--********************************************\n-- Desc interpretation\n--********************************************\n\n[|_|] : {I : Set} -> IDesc I -> (I -> Set) -> Set\n[| var i |] P = P i\n[| const X |] P = X\n[| prod D D' |] P = [| D |] P * [| D' |] P\n[| sigma S T |] P = Sigma S (\\s -> [| T s |] P)\n[| pi S T |] P = (s : S) -> [| T s |] P\n\n--********************************************\n-- Fixpoint construction\n--********************************************\n\ndata IMu {I : Set}(R : I -> IDesc I)(i : I) : Set where\n con : [| R i |] (\\j -> IMu R j) -> IMu R i\n\n--********************************************\n-- Predicate: All\n--********************************************\n\nAll : {I : Set}(D : IDesc I)(P : I -> Set) -> [| D |] P -> IDesc (Sigma I P)\nAll (var i) P x = var (i , x)\nAll (const X) P x = const Unit\nAll (prod D D') P (d , d') = prod (All D P d) (All D' P d')\nAll (sigma S T) P (a , b) = All (T a) P b\nAll (pi S T) P f = pi S (\\s -> All (T s) P (f s))\n\n--********************************************\n-- Elimination principle: induction\n--********************************************\n\nmodule Elim {I : Set}\n (R : I -> IDesc I)\n (P : Sigma I (IMu R) -> Set)\n (m : (i : I)\n (xs : [| R i |] (IMu R))\n (hs : [| All (R i) (IMu R) xs |] P) ->\n P ( i , con xs ))\n where\n\n mutual\n indI : (i : I)(x : IMu R i) -> P (i , x)\n indI i (con xs) = m i xs (hyps (R i) xs)\n\n hyps : (D : IDesc I) -> \n (xs : [| D |] (IMu R)) -> \n [| All D (IMu R) xs |] P\n hyps (var i) x = indI i x\n hyps (const X) x = Void\n hyps (prod D D') (d , d') = hyps D d , hyps D' d'\n hyps (pi S R) f = \\ s -> hyps (R s) (f s)\n hyps (sigma S R) ( a , b ) = hyps (R a) b\n\n\nindI : {I : Set}\n (R : I -> IDesc I)\n (P : Sigma I (IMu R) -> Set)\n (m : (i : I)\n (xs : [| R i |] (IMu R))\n (hs : [| All (R i) (IMu R) xs |] P) ->\n P ( i , con xs)) ->\n (i : I)(x : IMu R i) -> P ( i , x )\nindI = Elim.indI\n\n\n--********************************************\n-- Enumerations (hard-coded)\n--********************************************\n\n-- Unlike in Desc.agda, we don't carry the levitation of finite sets\n-- here. We hard-code them and manipulate with standard Agda\n-- machinery. Both presentation are isomorph but, in Agda, the coded\n-- one quickly gets unusable.\n\ndata EnumU : Set where\n nilE : EnumU\n consE : EnumU -> EnumU\n\ndata EnumT : (e : EnumU) -> Set where\n EZe : {e : EnumU} -> EnumT (consE e)\n ESu : {e : EnumU} -> EnumT e -> EnumT (consE e)\n\nspi : (e : EnumU)(P : EnumT e -> Set) -> Set\nspi nilE P = Unit\nspi (consE e) P = P EZe * spi e (\\e -> P (ESu e))\n\nswitch : (e : EnumU)(P : EnumT e -> Set)(b : spi e P)(x : EnumT e) -> P x\nswitch nilE P b ()\nswitch (consE e) P b EZe = fst b\nswitch (consE e) P b (ESu n) = switch e (\\e -> P (ESu e)) (snd b) n\n\n_++_ : EnumU -> EnumU -> EnumU\nnilE ++ e' = e'\n(consE e) ++ e' = consE (e ++ e')\n\n-- A special switch, for tagged descriptions. Switching on a\n-- concatenation of finite sets:\nsswitch : (e : EnumU)(e' : EnumU)(P : Set)\n (b : spi e (\\_ -> P))(b' : spi e' (\\_ -> P))(x : EnumT (e ++ e')) -> P\nsswitch nilE nilE P b b' ()\nsswitch nilE (consE e') P b b' EZe = fst b'\nsswitch nilE (consE e') P b b' (ESu n) = sswitch nilE e' P b (snd b') n\nsswitch (consE e) e' P b b' EZe = fst b\nsswitch (consE e) e' P b b' (ESu n) = sswitch e e' P (snd b) b' n\n\n--********************************************\n-- Tagged indexed description\n--********************************************\n\nFixMenu : Set -> Set\nFixMenu I = Sigma EnumU (\\e -> (i : I) -> spi e (\\_ -> IDesc I))\n\nSensitiveMenu : Set -> Set\nSensitiveMenu I = Sigma (I -> EnumU) (\\F -> (i : I) -> spi (F i) (\\_ -> IDesc I))\n\nTagIDesc : Set -> Set\nTagIDesc I = FixMenu I * SensitiveMenu I\n\ntoIDesc : (I : Set) -> TagIDesc I -> (I -> IDesc I)\ntoIDesc I ((E , ED) , (F , FD)) i = sigma (EnumT (E ++ F i)) \n (\\x -> sswitch E (F i) (IDesc I) (ED i) (FD i) x)\n\n--********************************************\n-- Catamorphism\n--********************************************\n\ncata : (I : Set)\n (R : I -> IDesc I)\n (T : I -> Set) ->\n ((i : I) -> [| R i |] T -> T i) ->\n (i : I) -> IMu R i -> T i\ncata I R T phi i x = indI R (\\it -> T (fst it)) (\\i xs ms -> phi i (replace (R i) T xs ms)) i x\n where replace : (D : IDesc I)(T : I -> Set)\n (xs : [| D |] (IMu R))\n (ms : [| All D (IMu R) xs |] (\\it -> T (fst it))) -> \n [| D |] T\n replace (var i) T x y = y\n replace (const Z) T z z' = z\n replace (prod D D') T (x , x') (y , y') = replace D T x y , replace D' T x' y'\n replace (sigma A B) T (a , b) t = a , replace (B a) T b t\n replace (pi A B) T f t = \\s -> replace (B s) T (f s) (t s)\n\n--********************************************\n-- Hutton's razor\n--********************************************\n\n--********************************\n-- Types code\n--********************************\n\ndata Type : Set where\n nat : Type\n bool : Type\n pair : Type -> Type -> Type\n\n\n--********************************************\n-- Free monad construction\n--********************************************\n\n_**_ : {I : Set} (R : TagIDesc I)(X : I -> Set) -> TagIDesc I\n((E , ED) , FFD) ** X = ((( consE E , \\ i -> ( const (X i) , ED i ))) , FFD) \n\n\n--********************************************\n-- Substitution\n--********************************************\n\napply : {I : Set}\n (R : TagIDesc I)(X Y : I -> Set) ->\n ((i : I) -> X i -> IMu (toIDesc I (R ** Y)) i) ->\n (i : I) -> \n [| toIDesc I (R ** X) i |] (IMu (toIDesc I (R ** Y))) ->\n IMu (toIDesc I (R ** Y)) i\napply (( E , ED) , (F , FD)) X Y sig i (EZe , x) = sig i x\napply (( E , ED) , (F , FD)) X Y sig i (ESu n , t) = con (ESu n , t)\n\nsubstI : {I : Set} (X Y : I -> Set)(R : TagIDesc I)\n (sigma : (i : I) -> X i -> IMu (toIDesc I (R ** Y)) i)\n (i : I)(D : IMu (toIDesc I (R ** X)) i) ->\n IMu (toIDesc I (R ** Y)) i\nsubstI {I} X Y R sig i term = cata I (toIDesc I (R ** X)) (IMu (toIDesc I (R ** Y))) (apply R X Y sig) i term \n\n\n--********************************************\n-- Hutton's razor is free monad\n--********************************************\n\n-- Fix menu:\nexprFreeFixMenu : FixMenu Type\nexprFreeFixMenu = ( consE nilE , \n \\ty -> (prod (var bool) (prod (var ty) (var ty)), -- if b then t1 else t2\n Void))\n\n-- Index-dependent menu:\nchoiceFreeMenu : Type -> EnumU\nchoiceFreeMenu nat = consE nilE\nchoiceFreeMenu bool = consE nilE\nchoiceFreeMenu (pair x y) = nilE\n\nchoiceFreeDessert : (ty : Type) -> spi (choiceFreeMenu ty) (\\ _ -> IDesc Type)\nchoiceFreeDessert nat = (prod (var nat) (var nat) , Void) -- plus x y\nchoiceFreeDessert bool = (prod (var nat) (var nat) , Void ) -- le x y\nchoiceFreeDessert (pair x y) = Void\n\nexprFreeSensitiveMenu : SensitiveMenu Type\nexprFreeSensitiveMenu = ( choiceFreeMenu , choiceFreeDessert )\n\n-- Tagged description of expressions\nexprFree : TagIDesc Type\nexprFree = exprFreeFixMenu , exprFreeSensitiveMenu\n\n-- Free monadic expressions\nexprFreeC : (Type -> Set) -> TagIDesc Type\nexprFreeC X = exprFree ** X\n\n--********************************\n-- Closed terms\n--********************************\n\nVal : Type -> Set\nVal nat = Nat\nVal bool = Bool\nVal (pair x y) = (Val x) * (Val y)\n\ncloseTerm : Type -> IDesc Type\ncloseTerm = toIDesc Type (exprFree ** Val)\n\n--********************************\n-- Closed term evaluation\n--********************************\n\neval : {ty : Type} -> IMu closeTerm ty -> Val ty\neval {ty} term = cata Type closeTerm Val evalOneStep ty term\n where evalOneStep : (ty : Type) -> [| closeTerm ty |] Val -> Val ty\n evalOneStep _ (EZe , t) = t\n evalOneStep _ ((ESu EZe) , (true , ( x , _))) = x\n evalOneStep _ ((ESu EZe) , (false , ( _ , y ))) = y\n evalOneStep nat ((ESu (ESu EZe)) , (x , y)) = plus x y\n evalOneStep nat ((ESu (ESu (ESu ()))) , t) \n evalOneStep bool ((ESu (ESu EZe)) , (x , y) ) = le x y\n evalOneStep bool ((ESu (ESu (ESu ()))) , _) \n evalOneStep (pair x y) (ESu (ESu ()) , _)\n\n\n--********************************\n-- [Open terms]\n--********************************\n\n-- A context is a snoc-list of types\n-- put otherwise, a context is a type telescope\ndata Context : Set where\n [] : Context\n _,_ : Context -> Type -> Context\n\n-- The environment realizes the context, having a value for each type\nEnv : Context -> Set\nEnv [] = Unit\nEnv (G , S) = Env G * Val S\n\n-- A typed-variable indexes into the context, obtaining a proof that\n-- what we get is what you want (WWGIWYW)\nVar : Context -> Type -> Set\nVar [] T = Zero\nVar (G , S) T = Var G T + (S == T)\n\n-- The lookup gets into the context to extract the value\nlookup : (G : Context) -> Env G -> (T : Type) -> Var G T -> Val T\nlookup [] _ T ()\nlookup (G , .T) (g , t) T (r refl) = t\nlookup (G , S) (g , t) T (l x) = lookup G g T x \n\n-- Open term: holes are either values or variables in a context\nopenTerm : Context -> Type -> IDesc Type\nopenTerm c = toIDesc Type (exprFree ** (\\ty -> Val ty + Var c ty))\n\n--********************************\n-- Evaluation of open terms\n--********************************\n\n-- |discharge| is the local substitution expected by |substI|. It is\n-- just sugar around context lookup\ndischarge : (context : Context) ->\n Env context ->\n (ty : Type) ->\n (Val ty + Var context ty) ->\n IMu closeTerm ty\ndischarge ctxt env ty (l value) = con (EZe , value)\ndischarge ctxt env ty (r variable) = con (EZe , lookup ctxt env ty variable ) \n\n-- |substExpr| is the specialized |substI| to expressions. We get it\n-- generically from the free monad construction.\nsubstExpr : {ty : Type}\n (context : Context)\n (sigma : (ty : Type) ->\n (Val ty + Var context ty) ->\n IMu closeTerm ty) ->\n IMu (openTerm context) ty ->\n IMu closeTerm ty\nsubstExpr {ty} c sig term = \n substI (\\ty -> Val ty + Var c ty) Val exprFree sig ty term\n\n-- By first doing substitution to close the term, we can use\n-- evaluation of closed terms, obtaining evaluation of open terms\n-- under a valid context.\nevalOpen : {ty : Type}(context : Context) ->\n Env context ->\n IMu (openTerm context) ty ->\n Val ty\nevalOpen ctxt env tm = eval (substExpr ctxt (discharge ctxt env) tm)\n\n--********************************\n-- Tests\n--********************************\n\n-- Test context:\n-- V 0 :-> true, V 1 :-> 2, V 2 :-> ( false , 1 )\ntestContext : Context\ntestContext = (([] , bool) , nat) , pair bool nat\ntestEnv : Env testContext\ntestEnv = ((Void , true ) , su (su ze)) , (false , su ze) \n\n-- V 1\ntest1 : IMu (openTerm testContext) nat\ntest1 = con (EZe , r ( l (r refl) ) )\n\ntestSubst1 : IMu closeTerm nat\ntestSubst1 = substExpr testContext \n (discharge testContext testEnv)\n test1\n-- = 2\ntestEval1 : Val nat\ntestEval1 = evalOpen testContext testEnv test1\n\n-- add 1 (V 1)\ntest2 : IMu (openTerm testContext) nat\ntest2 = con (ESu (ESu EZe) , (con (EZe , l (su ze)) , con ( EZe , r (l (r refl)) )) )\n\ntestSubst2 : IMu closeTerm nat\ntestSubst2 = substExpr testContext \n (discharge testContext testEnv)\n test2\n\n-- = 3\ntestEval2 : Val nat\ntestEval2 = evalOpen testContext testEnv test2\n\n\n-- if (V 0) then (V 1) else 0\ntest3 : IMu (openTerm testContext) nat\ntest3 = con (ESu EZe , (con (EZe , r (l (l (r refl)))) ,\n (con (EZe , r (l (r refl))) ,\n con (EZe , l ze))))\n\ntestSubst3 : IMu closeTerm nat\ntestSubst3 = substExpr testContext \n (discharge testContext testEnv)\n test3\n\n-- = 2\ntestEval3 : Val nat\ntestEval3 = evalOpen testContext testEnv test3\n\n-- V 2\ntest4 : IMu (openTerm testContext) (pair bool nat)\ntest4 = con (EZe , r ( r refl ) )\n\ntestSubst4 : IMu closeTerm (pair bool nat)\ntestSubst4 = substExpr testContext \n (discharge testContext testEnv)\n test4\n-- = (false , 1)\ntestEval4 : Val (pair bool nat)\ntestEval4 = evalOpen testContext testEnv test4", "meta": {"hexsha": "5e61d5837325517d6c0071636379581e50a97fe1", "size": 14679, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "models/RevisedHutton.agda", "max_stars_repo_name": "mietek/epigram", "max_stars_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 48, "max_stars_repo_stars_event_min_datetime": "2016-01-09T17:36:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-11T01:55:28.000Z", "max_issues_repo_path": "models/RevisedHutton.agda", "max_issues_repo_name": "mietek/epigram", "max_issues_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "models/RevisedHutton.agda", "max_forks_repo_name": "mietek/epigram", "max_forks_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2016-08-14T21:36:35.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-11T01:57:40.000Z", "avg_line_length": 30.58125, "max_line_length": 110, "alphanum_fraction": 0.4627018189, "num_tokens": 4638, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256551882382, "lm_q2_score": 0.7371581568543043, "lm_q1q2_score": 0.6205586483712288}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Definitions for types of functions.\n------------------------------------------------------------------------\n\n-- The contents of this file should usually be accessed from `Function`.\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary\n\nmodule Function.Definitions\n {a b ℓ₁ ℓ₂} {A : Set a} {B : Set b}\n (_≈₁_ : Rel A ℓ₁) -- Equality over the domain\n (_≈₂_ : Rel B ℓ₂) -- Equality over the codomain\n where\n\nopen import Data.Product using (∃; _×_)\nimport Function.Definitions.Core1 as Core₁\nimport Function.Definitions.Core2 as Core₂\nopen import Level using (_⊔_)\n\n------------------------------------------------------------------------\n-- Definitions\n\nCongruent : (A → B) → Set (a ⊔ ℓ₁ ⊔ ℓ₂)\nCongruent f = ∀ {x y} → x ≈₁ y → f x ≈₂ f y\n\nInjective : (A → B) → Set (a ⊔ ℓ₁ ⊔ ℓ₂)\nInjective f = ∀ {x y} → f x ≈₂ f y → x ≈₁ y\n\nopen Core₂ _≈₂_ public\n using (Surjective)\n\nBijective : (A → B) → Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂)\nBijective f = Injective f × Surjective f\n\nopen Core₂ _≈₂_ public\n using (Inverseˡ)\n\nopen Core₁ _≈₁_ public\n using (Inverseʳ)\n\nInverseᵇ : (A → B) → (B → A) → Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂)\nInverseᵇ f g = Inverseˡ f g × Inverseʳ f g\n", "meta": {"hexsha": "2c139cf3184c7b13677dcf2f8ed143808d375efe", "size": 1259, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Function/Definitions.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Function/Definitions.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Function/Definitions.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 26.7872340426, "max_line_length": 72, "alphanum_fraction": 0.5313741064, "num_tokens": 404, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8418256393148982, "lm_q2_score": 0.7371581568543044, "lm_q1q2_score": 0.6205586366700668}} {"text": "open import Mockingbird.Forest using (Forest)\n\nmodule Mockingbird.Forest.Extensionality {b ℓ} (forest : Forest {b} {ℓ}) where\n\nopen import Algebra using (RightCongruent)\nopen import Relation.Binary using (Rel; IsEquivalence; Setoid)\nopen import Level using (_⊔_)\n\nopen Forest forest\n\n-- TODO: if the arguments to the predicates is{Mockingbird,Thrush,Cardinal,...}\n-- are made implicit, then x can be implicit too.\nSimilar : Rel Bird (b ⊔ ℓ)\nSimilar A₁ A₂ = ∀ x → A₁ ∙ x ≈ A₂ ∙ x\n\ninfix 4 _≋_\n_≋_ = Similar\n\n-- A forest is called extensional if similarity implies equality.\nIsExtensional : Set (b ⊔ ℓ)\nIsExtensional = ∀ {A₁ A₂} → A₁ ≋ A₂ → A₁ ≈ A₂\n\n-- A record to be used as an instance argument.\nrecord Extensional : Set (b ⊔ ℓ) where\n field\n ext : IsExtensional\n\nopen Extensional ⦃ ... ⦄ public\n\next′ : ⦃ _ : Extensional ⦄ → ∀ {A₁ A₂} → (∀ {x} → A₁ ∙ x ≈ A₂ ∙ x) → A₁ ≈ A₂\next′ A₁≋A₂ = ext λ _ → A₁≋A₂\n\n-- Similarity is an equivalence relation.\n≋-isEquivalence : IsEquivalence _≋_\n≋-isEquivalence = record\n { refl = λ _ → refl\n ; sym = λ x≋y z → sym (x≋y z)\n ; trans = λ x≋y y≋z w → trans (x≋y w) (y≋z w)\n }\n\n≋-congʳ : RightCongruent _≋_ _∙_\n≋-congʳ {w} {x} {y} x≋y = λ _ → congʳ (x≋y w)\n", "meta": {"hexsha": "f083a16eb484e1c6f5f98b7bcb056260aa09c85d", "size": 1197, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Mockingbird/Forest/Extensionality.agda", "max_stars_repo_name": "splintah/combinatory-logic", "max_stars_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-02-28T23:44:42.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-28T23:44:42.000Z", "max_issues_repo_path": "Mockingbird/Forest/Extensionality.agda", "max_issues_repo_name": "splintah/combinatory-logic", "max_issues_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Mockingbird/Forest/Extensionality.agda", "max_forks_repo_name": "splintah/combinatory-logic", "max_forks_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.8372093023, "max_line_length": 79, "alphanum_fraction": 0.6532999165, "num_tokens": 468, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467738423873, "lm_q2_score": 0.705785040214066, "lm_q1q2_score": 0.6204886411304157}} {"text": "{-\nThis second-order signature was created from the following second-order syntax description:\n\nsyntax CTLC | ΛC\n\ntype\n N : 0-ary\n _↣_ : 2-ary | r30\n ¬_ : 1-ary | r30\n\nterm\n app : α ↣ β α -> β | _$_ l20\n lam : α.β -> α ↣ β | ƛ_ r10\n throw : α ¬ α -> β\n callcc : ¬ α.α -> α\n\ntheory\n (ƛβ) b : α.β a : α |> app (lam(x.b[x]), a) = b[a]\n (ƛη) f : α ↣ β |> lam (x. app(f, x)) = f\n-}\n\nmodule CTLC.Signature where\n\nopen import SOAS.Context\n\n-- Type declaration\ndata ΛCT : Set where\n N : ΛCT\n _↣_ : ΛCT → ΛCT → ΛCT\n ¬_ : ΛCT → ΛCT\ninfixr 30 _↣_\ninfixr 30 ¬_\n\n\nopen import SOAS.Syntax.Signature ΛCT public\nopen import SOAS.Syntax.Build ΛCT public\n\n-- Operator symbols\ndata ΛCₒ : Set where\n appₒ lamₒ throwₒ : {α β : ΛCT} → ΛCₒ\n callccₒ : {α : ΛCT} → ΛCₒ\n\n-- Term signature\nΛC:Sig : Signature ΛCₒ\nΛC:Sig = sig λ\n { (appₒ {α}{β}) → (⊢₀ α ↣ β) , (⊢₀ α) ⟼₂ β\n ; (lamₒ {α}{β}) → (α ⊢₁ β) ⟼₁ α ↣ β\n ; (throwₒ {α}{β}) → (⊢₀ α) , (⊢₀ ¬ α) ⟼₂ β\n ; (callccₒ {α}) → (¬ α ⊢₁ α) ⟼₁ α\n }\n\nopen Signature ΛC:Sig public\n", "meta": {"hexsha": "d5e083a5fb66f3048f61e64b90b310f072f5ad64", "size": 1054, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "out/CTLC/Signature.agda", "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_issues_repo_path": "out/CTLC/Signature.agda", "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_forks_repo_path": "out/CTLC/Signature.agda", "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "avg_line_length": 19.8867924528, "max_line_length": 91, "alphanum_fraction": 0.5407969639, "num_tokens": 516, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.879146780175245, "lm_q2_score": 0.7057850278370111, "lm_q1q2_score": 0.620488634718804}} {"text": "------------------------------------------------------------------------------\n-- Division program\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- This module define a division program using repeated subtraction\n-- (Dybjer 1985).\n\n-- Peter Dybjer. Program verification in a logical theory of\n-- constructions. In Jean-Pierre Jouannaud, editor. Functional\n-- Programming Languages and Computer Architecture, volume 201 of\n-- LNCS, 1985, pages 334-349. Appears in revised form as Programming\n-- Methodology Group Report 26, June 1986.\n\nmodule FOTC.Program.Division.Division where\n\nopen import FOTC.Base\nopen import FOTC.Data.Nat\nopen import FOTC.Data.Nat.Inequalities\n\n------------------------------------------------------------------------------\n\npostulate\n div : D → D → D\n div-eq : ∀ i j → div i j ≡ (if (lt i j) then zero else succ₁ (div (i ∸ j) j))\n{-# ATP axiom div-eq #-}\n", "meta": {"hexsha": "962d0ef64f2c94e6517f1038790f7b630d9e439d", "size": 1091, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/FOTC/Program/Division/Division.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/FOTC/Program/Division/Division.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/FOTC/Program/Division/Division.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 35.1935483871, "max_line_length": 79, "alphanum_fraction": 0.5279560037, "num_tokens": 232, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467675095294, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.6204886257795317}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Some Vec-related properties that depend on the K rule or make use\n-- of heterogeneous equality\n------------------------------------------------------------------------\n\n{-# OPTIONS --with-K --safe #-}\n\nmodule Data.Vec.Properties.WithK where\n\nopen import Data.Nat\nopen import Data.Nat.Properties using (+-assoc)\nopen import Data.Vec\nopen import Relation.Binary.PropositionalEquality as P using (_≡_; refl)\nopen import Relation.Binary.HeterogeneousEquality as H using (_≅_; refl)\n\n------------------------------------------------------------------------\n-- _[_]=_\n\nmodule _ {a} {A : Set a} where\n\n []=-irrelevant : ∀ {n} {xs : Vec A n} {i x} →\n (p q : xs [ i ]= x) → p ≡ q\n []=-irrelevant here here = refl\n []=-irrelevant (there xs[i]=x) (there xs[i]=x') =\n P.cong there ([]=-irrelevant xs[i]=x xs[i]=x')\n\n------------------------------------------------------------------------\n-- _++_\n\nmodule _ {a} {A : Set a} where\n\n ++-assoc : ∀ {m n k} (xs : Vec A m) (ys : Vec A n) (zs : Vec A k) →\n (xs ++ ys) ++ zs ≅ xs ++ (ys ++ zs)\n ++-assoc [] ys zs = refl\n ++-assoc {suc m} (x ∷ xs) ys zs =\n H.icong (Vec A) (+-assoc m _ _) (x ∷_) (++-assoc xs ys zs)\n\n------------------------------------------------------------------------\n-- foldr\n\nfoldr-cong : ∀ {a b} {A : Set a}\n {B : ℕ → Set b} {f : ∀ {n} → A → B n → B (suc n)} {d}\n {C : ℕ → Set b} {g : ∀ {n} → A → C n → C (suc n)} {e} →\n (∀ {n x} {y : B n} {z : C n} → y ≅ z → f x y ≅ g x z) →\n d ≅ e → ∀ {n} (xs : Vec A n) →\n foldr B f d xs ≅ foldr C g e xs\nfoldr-cong _ d≅e [] = d≅e\nfoldr-cong f≅g d≅e (x ∷ xs) = f≅g (foldr-cong f≅g d≅e xs)\n\n------------------------------------------------------------------------\n-- foldl\n\nfoldl-cong : ∀ {a b} {A : Set a}\n {B : ℕ → Set b} {f : ∀ {n} → B n → A → B (suc n)} {d}\n {C : ℕ → Set b} {g : ∀ {n} → C n → A → C (suc n)} {e} →\n (∀ {n x} {y : B n} {z : C n} → y ≅ z → f y x ≅ g z x) →\n d ≅ e → ∀ {n} (xs : Vec A n) →\n foldl B f d xs ≅ foldl C g e xs\nfoldl-cong _ d≅e [] = d≅e\nfoldl-cong f≅g d≅e (x ∷ xs) = foldl-cong f≅g (f≅g d≅e) xs\n\n------------------------------------------------------------------------\n-- DEPRECATED NAMES\n------------------------------------------------------------------------\n-- Please use the new names as continuing support for the old names is\n-- not guaranteed.\n\n-- Version 1.0\n\n[]=-irrelevance = []=-irrelevant\n{-# WARNING_ON_USAGE []=-irrelevance\n\"Warning: []=-irrelevance was deprecated in v1.0.\nPlease use []=-irrelevant instead.\"\n#-}\n", "meta": {"hexsha": "030ceb02f4681d84f9ba89efda2309b36fdf0359", "size": 2773, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/Properties/WithK.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/Properties/WithK.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/Properties/WithK.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.012987013, "max_line_length": 72, "alphanum_fraction": 0.3901911287, "num_tokens": 853, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.863391617003942, "lm_q2_score": 0.7185943985973773, "lm_q1q2_score": 0.6204283797749648}} {"text": "{-# OPTIONS --warning=error --safe --without-K #-}\n\nopen import LogicalFormulae\nopen import Lists.Lists\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Naturals\nopen import Numbers.BinaryNaturals.Definition\nopen import Numbers.BinaryNaturals.Addition\nopen import Semirings.Definition\n\nmodule Numbers.BinaryNaturals.Multiplication where\n\n_*Binherit_ : BinNat → BinNat → BinNat\na *Binherit b = NToBinNat (binNatToN a *N binNatToN b)\n\n_*B_ : BinNat → BinNat → BinNat\n[] *B b = []\n(zero :: a) *B b = zero :: (a *B b)\n(one :: a) *B b = (zero :: (a *B b)) +B b\n\nprivate\n contr : {a : _} {A : Set a} {l1 l2 : List A} → {x : A} → l1 ≡ [] → l1 ≡ x :: l2 → False\n contr {l1 = []} p1 ()\n contr {l1 = x :: l1} () p2\n\n *BEmpty : (a : BinNat) → canonical (a *B []) ≡ []\n *BEmpty [] = refl\n *BEmpty (zero :: a) rewrite *BEmpty a = refl\n *BEmpty (one :: a) rewrite *BEmpty a = refl\n\ncanonicalDistributesPlus : (a b : BinNat) → canonical (a +B b) ≡ canonical a +B canonical b\ncanonicalDistributesPlus a b = transitivity ans (+BIsInherited (canonical a) (canonical b) (canonicalIdempotent a) (canonicalIdempotent b))\n where\n ans : canonical (a +B b) ≡ NToBinNat (binNatToN (canonical a) +N binNatToN (canonical b))\n ans rewrite binNatToNIsCanonical a | binNatToNIsCanonical b = equalityCommutative (+BIsInherited' a b)\n\nincrPullsOut : (a b : BinNat) → incr (a +B b) ≡ (incr a) +B b\nincrPullsOut [] [] = refl\nincrPullsOut [] (zero :: b) = refl\nincrPullsOut [] (one :: b) = refl\nincrPullsOut (zero :: a) [] = refl\nincrPullsOut (zero :: a) (zero :: b) = refl\nincrPullsOut (zero :: a) (one :: b) = refl\nincrPullsOut (one :: a) [] = refl\nincrPullsOut (one :: a) (zero :: b) = applyEquality (zero ::_) (incrPullsOut a b)\nincrPullsOut (one :: a) (one :: b) = applyEquality (one ::_) (incrPullsOut a b)\n\ntimesZero : (a b : BinNat) → canonical a ≡ [] → canonical (a *B b) ≡ []\ntimesZero [] b pr = refl\ntimesZero (zero :: a) b pr with inspect (canonical a)\ntimesZero (zero :: a) b pr | [] with≡ prA rewrite prA | timesZero a b prA = refl\ntimesZero (zero :: a) b pr | (a1 :: as) with≡ prA rewrite prA = exFalso (nonEmptyNotEmpty pr)\n\ntimesZero'' : (a b : BinNat) → canonical (a *B b) ≡ [] → (canonical a ≡ []) || (canonical b ≡ [])\ntimesZero'' [] b pr = inl refl\ntimesZero'' (x :: a) [] pr = inr refl\ntimesZero'' (zero :: as) (zero :: bs) pr with inspect (canonical as)\ntimesZero'' (zero :: as) (zero :: bs) pr | y with≡ x with inspect (canonical bs)\ntimesZero'' (zero :: as) (zero :: bs) pr | [] with≡ prAs | y₁ with≡ prBs rewrite prAs = inl refl\ntimesZero'' (zero :: as) (zero :: bs) pr | (a1 :: a's) with≡ prAs | [] with≡ prBs rewrite prBs = inr refl\ntimesZero'' (zero :: as) (zero :: bs) pr | (a1 :: a's) with≡ prAs | (x :: y) with≡ prBs with inspect (canonical (as *B (zero :: bs)))\ntimesZero'' (zero :: as) (zero :: bs) pr | (a1 :: a's) with≡ prAs | (b1 :: b's) with≡ prBs | [] with≡ pr' with timesZero'' as (zero :: bs) pr'\ntimesZero'' (zero :: as) (zero :: bs) pr | (a1 :: a's) with≡ prAs | (b1 :: b's) with≡ prBs | [] with≡ pr' | inl x rewrite prAs | prBs | pr' | x = exFalso (nonEmptyNotEmpty x)\ntimesZero'' (zero :: as) (zero :: bs) pr | (a1 :: a's) with≡ prAs | (b1 :: b's) with≡ prBs | [] with≡ pr' | inr x rewrite prBs | pr' | x = exFalso (nonEmptyNotEmpty x)\ntimesZero'' (zero :: as) (zero :: bs) pr | (a1 :: a's) with≡ prAs | (b1 :: b's) with≡ prBs | (x :: y) with≡ pr' rewrite prAs | prBs | pr' = exFalso (nonEmptyNotEmpty pr)\ntimesZero'' (zero :: as) (one :: bs) pr with inspect (canonical as)\ntimesZero'' (zero :: as) (one :: bs) pr | [] with≡ x rewrite x = inl refl\ntimesZero'' (zero :: as) (one :: bs) pr | (a1 :: a's) with≡ x with inspect (canonical (as *B (one :: bs)))\ntimesZero'' (zero :: as) (one :: bs) pr | (a1 :: a's) with≡ x | [] with≡ pr' with timesZero'' as (one :: bs) pr'\ntimesZero'' (zero :: as) (one :: bs) pr | (a1 :: a's) with≡ x | [] with≡ pr' | inl pr'' rewrite x | pr' | pr'' = exFalso (nonEmptyNotEmpty pr'')\ntimesZero'' (zero :: as) (one :: bs) pr | (a1 :: a's) with≡ x | (x₁ :: y) with≡ pr' rewrite x | pr' = exFalso (nonEmptyNotEmpty pr)\ntimesZero'' (one :: as) (zero :: bs) pr with inspect (canonical bs)\ntimesZero'' (one :: as) (zero :: bs) pr | [] with≡ x rewrite x = inr refl\ntimesZero'' (one :: as) (zero :: bs) pr | (b1 :: b's) with≡ prB with inspect (canonical ((as *B (zero :: bs)) +B bs))\ntimesZero'' (one :: as) (zero :: bs) pr | (b1 :: b's) with≡ prB | [] with≡ x rewrite equalityCommutative (+BIsInherited' (as *B (zero :: bs)) bs) = exFalso (nonEmptyNotEmpty (transitivity (equalityCommutative prB) v))\n where\n t : binNatToN (as *B (zero :: bs)) +N binNatToN bs ≡ 0\n t = transitivity (equalityCommutative (nToN _)) (applyEquality binNatToN x)\n u : (binNatToN (as *B (zero :: bs)) ≡ 0) && (binNatToN bs ≡ 0)\n u = sumZeroImpliesSummandsZero t\n v : canonical bs ≡ []\n v with u\n ... | fst ,, snd = binNatToNZero bs snd\ntimesZero'' (one :: as) (zero :: bs) pr | (b1 :: b's) with≡ prB | (x₁ :: y) with≡ x rewrite prB | x = exFalso (nonEmptyNotEmpty pr)\n\nlemma : {i : Bit} → (a b : BinNat) → canonical a ≡ canonical b → canonical (i :: a) ≡ canonical (i :: b)\nlemma {zero} a b pr with inspect (canonical a)\nlemma {zero} a b pr | [] with≡ x rewrite x | equalityCommutative pr = refl\nlemma {zero} a b pr | (a1 :: as) with≡ x rewrite x | equalityCommutative pr = refl\nlemma {one} a b pr = applyEquality (one ::_) pr\n\nbinNatToNDistributesPlus : (a b : BinNat) → binNatToN (a +B b) ≡ binNatToN a +N binNatToN b\nbinNatToNDistributesPlus a b = transitivity (equalityCommutative (binNatToNIsCanonical (a +B b))) (transitivity (applyEquality binNatToN (equalityCommutative (+BIsInherited' a b))) (nToN (binNatToN a +N binNatToN b)))\n\n+BAssociative : (a b c : BinNat) → canonical (a +B (b +B c)) ≡ canonical ((a +B b) +B c)\n+BAssociative a b c rewrite equalityCommutative (+BIsInherited' a (b +B c)) | equalityCommutative (+BIsInherited' (a +B b) c) | binNatToNDistributesPlus a b | binNatToNDistributesPlus b c | equalityCommutative (Semiring.+Associative ℕSemiring (binNatToN a) (binNatToN b) (binNatToN c)) = refl\n\ntimesOne : (a b : BinNat) → (canonical b) ≡ (one :: []) → canonical (a *B b) ≡ canonical a\ntimesOne [] b pr = refl\ntimesOne (zero :: a) b pr with inspect (canonical (a *B b))\ntimesOne (zero :: a) b pr | [] with≡ prAB with timesZero'' a b prAB\ntimesOne (zero :: a) b pr | [] with≡ prAB | inl a=0 rewrite a=0 | prAB = refl\ntimesOne (zero :: a) b pr | [] with≡ prAB | inr b=0 = exFalso (nonEmptyNotEmpty (transitivity (equalityCommutative pr) b=0))\ntimesOne (zero :: a) b pr | (ab1 :: abs) with≡ prAB with inspect (canonical a)\ntimesOne (zero :: a) b pr | (ab1 :: abs) with≡ prAB | [] with≡ x = exFalso (nonEmptyNotEmpty (transitivity (equalityCommutative prAB) (timesZero a b x)))\ntimesOne (zero :: a) b pr | (ab1 :: abs) with≡ prAB | (x₁ :: y) with≡ x rewrite prAB | x | timesOne a b pr = applyEquality (zero ::_) (transitivity (equalityCommutative prAB) x)\ntimesOne (one :: a) (zero :: b) pr with canonical b\ntimesOne (one :: a) (zero :: b) () | []\ntimesOne (one :: a) (zero :: b) () | x :: bl\ntimesOne (one :: a) (one :: b) pr rewrite canonicalDistributesPlus (a *B (one :: b)) b | ::Inj pr | +BCommutative (canonical (a *B (one :: b))) [] | timesOne a (one :: b) pr = refl\n\ntimesZero' : (a b : BinNat) → canonical b ≡ [] → canonical (a *B b) ≡ []\ntimesZero' [] b pr = refl\ntimesZero' (zero :: a) b pr with inspect (canonical (a *B b))\ntimesZero' (zero :: a) b pr | [] with≡ x rewrite x = refl\ntimesZero' (zero :: a) b pr | (ab1 :: abs) with≡ prAB rewrite prAB = exFalso (nonEmptyNotEmpty (transitivity (equalityCommutative prAB) (timesZero' a b pr)))\ntimesZero' (one :: a) b pr rewrite canonicalDistributesPlus (zero :: (a *B b)) b | pr | +BCommutative (canonical (zero :: (a *B b))) [] = ans\n where\n ans : canonical (zero :: (a *B b)) ≡ []\n ans with inspect (canonical (a *B b))\n ans | [] with≡ x rewrite x = refl\n ans | (x₁ :: y) with≡ x rewrite x = exFalso (nonEmptyNotEmpty (transitivity (equalityCommutative x) (timesZero' a b pr)))\n\ncanonicalDistributesTimes : (a b : BinNat) → canonical (a *B b) ≡ canonical ((canonical a) *B (canonical b))\ncanonicalDistributesTimes [] b = refl\ncanonicalDistributesTimes (zero :: a) b with inspect (canonical a)\ncanonicalDistributesTimes (zero :: a) b | [] with≡ x rewrite timesZero a b x | x = refl\ncanonicalDistributesTimes (zero :: a) b | (a1 :: as) with≡ prA with inspect (canonical b)\ncanonicalDistributesTimes (zero :: a) b | (a1 :: as) with≡ prA | [] with≡ prB rewrite prA | prB = ans\n where\n ans : canonical (zero :: (a *B b)) ≡ canonical (zero :: ((a1 :: as) *B []))\n ans with inspect (canonical ((a1 :: as) *B []))\n ans | [] with≡ x rewrite x | timesZero' a b prB = refl\n ans | (x₁ :: y) with≡ x = exFalso (nonEmptyNotEmpty (equalityCommutative (transitivity (equalityCommutative (timesZero' (a1 :: as) [] refl)) x)))\ncanonicalDistributesTimes (zero :: a) b | (a1 :: as) with≡ prA | (b1 :: bs) with≡ prB with inspect (canonical (a *B b))\ncanonicalDistributesTimes (zero :: a) b | (a1 :: as) with≡ prA | (b1 :: bs) with≡ prB | [] with≡ x with timesZero'' a b x\ncanonicalDistributesTimes (zero :: a) b | (a1 :: as) with≡ prA | (b1 :: bs) with≡ prB | [] with≡ x | inl a=0 = exFalso (nonEmptyNotEmpty (transitivity (equalityCommutative prA) a=0))\ncanonicalDistributesTimes (zero :: a) b | (a1 :: as) with≡ prA | (b1 :: bs) with≡ prB | [] with≡ x | inr b=0 = exFalso (nonEmptyNotEmpty (transitivity (equalityCommutative prB) b=0))\ncanonicalDistributesTimes (zero :: a) b | (a1 :: as) with≡ prA | (b1 :: bs) with≡ prB | (ab1 :: abs) with≡ x rewrite prA | prB | x = ans\n where\n ans : zero :: ab1 :: abs ≡ canonical (zero :: ((a1 :: as) *B (b1 :: bs)))\n ans rewrite equalityCommutative prA | equalityCommutative prB | equalityCommutative (canonicalDistributesTimes a b) | x = refl\ncanonicalDistributesTimes (one :: a) b = transitivity (canonicalDistributesPlus (zero :: (a *B b)) b) (transitivity (transitivity (applyEquality (_+B canonical b) (transitivity (equalityCommutative (canonicalAscends'' (a *B b))) (transitivity (applyEquality (λ i → canonical (zero :: i)) (canonicalDistributesTimes a b)) (canonicalAscends'' (canonical a *B canonical b))))) (applyEquality (λ i → canonical (zero :: (canonical a *B canonical b)) +B i) (canonicalIdempotent b))) (equalityCommutative (canonicalDistributesPlus (zero :: (canonical a *B canonical b)) (canonical b))))\n\nNToBinNatDistributesPlus : (a b : ℕ) → NToBinNat (a +N b) ≡ NToBinNat a +B NToBinNat b\nNToBinNatDistributesPlus zero b = refl\nNToBinNatDistributesPlus (succ a) b with inspect (NToBinNat a)\n... | bl with≡ prA with inspect (NToBinNat (a +N b))\n... | q with≡ prAB = transitivity (applyEquality incr (NToBinNatDistributesPlus a b)) (incrPullsOut (NToBinNat a) (NToBinNat b))\n\ntimesCommutative : (a b : BinNat) → canonical (a *B b) ≡ canonical (b *B a)\ntimesCommLemma : (a b : BinNat) → canonical (zero :: (b *B a)) ≡ canonical (b *B (zero :: a))\ntimesCommLemma a b rewrite timesCommutative b (zero :: a) | equalityCommutative (canonicalAscends'' {zero} (b *B a)) | equalityCommutative (canonicalAscends'' {zero} (a *B b)) | timesCommutative b a = refl\n\ntimesCommutative [] b rewrite timesZero' b [] refl = refl\ntimesCommutative (x :: a) [] rewrite timesZero' (x :: a) [] refl = refl\ntimesCommutative (zero :: as) (zero :: b) rewrite equalityCommutative (canonicalAscends'' {zero} (as *B (zero :: b))) | timesCommutative as (zero :: b) | canonicalAscends'' {zero} (zero :: b *B as) | equalityCommutative (canonicalAscends'' {zero} (b *B (zero :: as))) | timesCommutative b (zero :: as) | canonicalAscends'' {zero} (zero :: (as *B b)) = ans\n where\n ans : canonical (zero :: zero :: (b *B as)) ≡ canonical (zero :: zero :: (as *B b))\n ans rewrite equalityCommutative (canonicalAscends'' {zero} (zero :: (b *B as))) | equalityCommutative (canonicalAscends'' {zero} (b *B as)) | timesCommutative b as | canonicalAscends'' {zero} (as *B b) | canonicalAscends'' {zero} (zero :: (as *B b)) = refl\ntimesCommutative (zero :: as) (one :: b) = transitivity (equalityCommutative (canonicalAscends'' (as *B (one :: b)))) (transitivity (applyEquality (λ i → canonical (zero :: i)) (timesCommutative as (one :: b))) (transitivity (applyEquality (λ i → canonical (zero :: i)) ans) (canonicalAscends'' ((b *B (zero :: as)) +B as))))\n where\n ans : canonical ((zero :: (b *B as)) +B as) ≡ canonical ((b *B (zero :: as)) +B as)\n ans rewrite canonicalDistributesPlus (zero :: (b *B as)) as | canonicalDistributesPlus (b *B (zero :: as)) as = applyEquality (_+B canonical as) (timesCommLemma as b)\ntimesCommutative (one :: as) (zero :: bs) = transitivity (equalityCommutative (canonicalAscends'' ((as *B (zero :: bs)) +B bs))) (transitivity (applyEquality (λ i → canonical (zero :: i)) ans) (canonicalAscends'' (bs *B (one :: as))))\n where\n ans : canonical ((as *B (zero :: bs)) +B bs) ≡ canonical (bs *B (one :: as))\n ans rewrite timesCommutative bs (one :: as) | canonicalDistributesPlus (as *B (zero :: bs)) bs | canonicalDistributesPlus (zero :: (as *B bs)) bs = applyEquality (_+B canonical bs) (equalityCommutative (timesCommLemma bs as))\ntimesCommutative (one :: as) (one :: bs) = applyEquality (one ::_) (transitivity (canonicalDistributesPlus (as *B (one :: bs)) bs) (transitivity (transitivity (applyEquality (_+B canonical bs) (timesCommutative as (one :: bs))) (transitivity ans (equalityCommutative (applyEquality (_+B canonical as) (timesCommutative bs (one :: as)))))) (equalityCommutative (canonicalDistributesPlus (bs *B (one :: as)) as))))\n where\n ans : canonical ((zero :: (bs *B as)) +B as) +B canonical bs ≡ canonical ((zero :: (as *B bs)) +B bs) +B canonical as\n ans rewrite equalityCommutative (canonicalDistributesPlus ((zero :: (bs *B as)) +B as) bs) | equalityCommutative (canonicalDistributesPlus ((zero :: (as *B bs)) +B bs) as) | equalityCommutative (+BAssociative (zero :: (bs *B as)) as bs) | equalityCommutative (+BAssociative (zero :: (as *B bs)) bs as) | canonicalDistributesPlus (zero :: (bs *B as)) (as +B bs) | canonicalDistributesPlus (zero :: (as *B bs)) (bs +B as) | equalityCommutative (canonicalAscends'' {zero} (bs *B as)) | timesCommutative bs as | canonicalAscends'' {zero} (as *B bs) | +BCommutative as bs = refl\n\n*BIsInherited : (a b : BinNat) → a *Binherit b ≡ canonical (a *B b)\n*BIsInherited a b = transitivity (applyEquality NToBinNat t) (transitivity (binToBin (canonical (a *B b))) (equalityCommutative (canonicalIdempotent (a *B b))))\n where\n ans : (a b : BinNat) → binNatToN a *N binNatToN b ≡ binNatToN (a *B b)\n ans [] b = refl\n ans (zero :: a) b rewrite equalityCommutative (ans a b) = equalityCommutative (Semiring.*Associative ℕSemiring 2 (binNatToN a) (binNatToN b))\n ans (one :: a) b rewrite binNatToNDistributesPlus (zero :: (a *B b)) b | Semiring.commutative ℕSemiring (binNatToN b) ((2 *N (binNatToN a)) *N (binNatToN b)) | equalityCommutative (ans a b) = applyEquality (_+N binNatToN b) (equalityCommutative (Semiring.*Associative ℕSemiring 2 (binNatToN a) (binNatToN b)))\n t : (binNatToN a *N binNatToN b) ≡ binNatToN (canonical (a *B b))\n t = transitivity (ans a b) (equalityCommutative (binNatToNIsCanonical (a *B b)))\n", "meta": {"hexsha": "df629bb46167d73aa1b55ddffa3f0c080b4f56b1", "size": 15233, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numbers/BinaryNaturals/Multiplication.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Numbers/BinaryNaturals/Multiplication.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Numbers/BinaryNaturals/Multiplication.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 83.2404371585, "max_line_length": 579, "alphanum_fraction": 0.6480666973, "num_tokens": 5289, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916134888613, "lm_q2_score": 0.7185943865443349, "lm_q1q2_score": 0.6204283668425519}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Dodo.Binary.Irreflexive where\n\n-- Stdlib imports\nopen import Level using (Level)\nopen import Relation.Binary using (Rel; Irreflexive)\n-- Local imports\nopen import Dodo.Binary.Equality\n\n\nmodule _ {a ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a}\n {≈ : Rel A ℓ₁} {P : Rel A ℓ₂} {Q : Rel A ℓ₃} where\n\n irreflexive-⊆₂ : Irreflexive ≈ Q → P ⊆₂ Q → Irreflexive ≈ P\n irreflexive-⊆₂ irreflexiveQ P⊆Q x≈y Pxy = irreflexiveQ x≈y (⊆₂-apply P⊆Q Pxy)\n", "meta": {"hexsha": "4ce04d913569bc5dcfd7f0219a9a852a98d4ef0c", "size": 469, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Dodo/Binary/Irreflexive.agda", "max_stars_repo_name": "sourcedennis/agda-dodo", "max_stars_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Dodo/Binary/Irreflexive.agda", "max_issues_repo_name": "sourcedennis/agda-dodo", "max_issues_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Dodo/Binary/Irreflexive.agda", "max_forks_repo_name": "sourcedennis/agda-dodo", "max_forks_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.5882352941, "max_line_length": 79, "alphanum_fraction": 0.6737739872, "num_tokens": 195, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8872045907347108, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.6203817268944432}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Algebra.Structures.Bundles.Field\n\nmodule Algebra.Linear.Category.Vect\n {k ℓᵏ} (K : Field k ℓᵏ)\n {a ℓ}\n where\n\nopen import Relation.Binary using (Setoid)\nopen import Algebra.Linear.Structures.Bundles\nopen import Algebra.Linear.Morphism.Bundles K\nopen import Categories.Category\n\nopen LinearMap\n\nid : ∀ {V : VectorSpace K a ℓ} -> LinearMap V V\nid {V = V} = record\n { ⟦_⟧ = λ u -> u\n ; isLinearMap = record\n { isAbelianGroupMorphism = record\n { gp-homo = record\n { mn-homo = record\n { sm-homo = record\n { ⟦⟧-cong = λ r -> r\n ; ∙-homo = λ x y → VectorSpace.refl V }\n ; ε-homo = VectorSpace.refl V } } }\n ; ∙-homo = λ c u → VectorSpace.refl V } }\n\n_∘_ : ∀ {U V W : VectorSpace K a ℓ} -> LinearMap V W -> LinearMap U V -> LinearMap U W\n_∘_ {U = U} {V} {W} f g = record\n { ⟦_⟧ = λ u → f ⟪$⟫ g ⟪$⟫ u\n ; isLinearMap = record\n { isAbelianGroupMorphism = record\n { gp-homo = record\n { mn-homo = record\n { sm-homo = record\n { ⟦⟧-cong = λ r → ⟦⟧-cong f (⟦⟧-cong g r)\n ; ∙-homo = λ u v → VectorSpace.trans W (⟦⟧-cong f (+-homo g u v)) (+-homo f (g ⟪$⟫ u) (g ⟪$⟫ v))\n }\n ; ε-homo = VectorSpace.trans W (⟦⟧-cong f (0#-homo g)) (0#-homo f)\n }\n }\n }\n ; ∙-homo = λ c u → VectorSpace.trans W (⟦⟧-cong f (∙-homo g c u)) (∙-homo f c (g ⟪$⟫ u))\n }\n }\n\nprivate\n module Assoc\n {U V W X : VectorSpace K a ℓ}\n {f : LinearMap U V} {g : LinearMap V W} {h : LinearMap W X}\n where\n\n open Setoid (linearMap-setoid U X)\n open import Relation.Binary.EqReasoning (linearMap-setoid U X)\n\n right : ((h ∘ g) ∘ f) ≈ (h ∘ (g ∘ f))\n right r = ⟦⟧-cong h (⟦⟧-cong g (⟦⟧-cong f r))\n\n left : (h ∘ (g ∘ f)) ≈ ((h ∘ g) ∘ f)\n left r = ⟦⟧-cong h (⟦⟧-cong g (⟦⟧-cong f r))\n\nVect : Category _ _ _\nVect = record\n { Obj = VectorSpace K a ℓ\n ; _⇒_ = λ V W → LinearMap V W\n ; _≈_ = λ {V} {W} -> Setoid._≈_ (linearMap-setoid V W)\n ; id = id\n ; _∘_ = _∘_\n ; assoc = λ {U} {V} {W} {X} {f} {g} {h} -> Assoc.right {U} {V} {W} {X} {f} {g} {h}\n ; sym-assoc = λ {U} {V} {W} {X} {f} {g} {h} -> Assoc.left {U} {V} {W} {X} {f} {g} {h}\n ; identityˡ = λ {U} {V} {f} -> ⟦⟧-cong f\n ; identityʳ = λ {U} {V} {f} → ⟦⟧-cong f\n ; equiv = λ {V} {W} -> Setoid.isEquivalence (linearMap-setoid V W)\n ; ∘-resp-≈ = λ {U} {V} {W} {f} {h} {g} {i} rf rg rx →\n VectorSpace.trans W (rf (⟦⟧-cong g rx)) (⟦⟧-cong h (rg (VectorSpace.refl U)))\n }\n", "meta": {"hexsha": "2d3de69349451a5c270a1252711527e25f363fda", "size": 2500, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Algebra/Linear/Category/Vect.agda", "max_stars_repo_name": "felko/linear-algebra", "max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z", "max_issues_repo_path": "src/Algebra/Linear/Category/Vect.agda", "max_issues_repo_name": "felko/linear-algebra", "max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Algebra/Linear/Category/Vect.agda", "max_forks_repo_name": "felko/linear-algebra", "max_forks_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.6455696203, "max_line_length": 108, "alphanum_fraction": 0.5132, "num_tokens": 1080, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511543206819, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.6203810676855045}} {"text": "\n-- NBE for Gödel System T\nmodule NBE where\n\nmodule Prelude where\n\n -- Zero and One -----------------------------------------------------------\n\n data Zero : Set where\n\n data One : Set where\n unit : One\n\n -- Natural numbers --------------------------------------------------------\n\n data Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\n (+) : Nat -> Nat -> Nat\n zero + m = m\n suc n + m = suc (n + m)\n\n-- Props ------------------------------------------------------------------\n\n data True : Prop where\n tt : True\n\n data False : Prop where\n\n postulate\n falseE : (A:Set) -> False -> A\n\n infix 3 /\\\n\n data (/\\)(P Q:Prop) : Prop where\n andI : P -> Q -> P /\\ Q\n\nmodule Fin where\n\n open Prelude\n\n -- Finite sets ------------------------------------------------------------\n\n data Suc (A:Set) : Set where\n fzero_ : Suc A\n fsuc_ : A -> Suc A\n\n mutual\n\n data Fin (n:Nat) : Set where\n finI : Fin_ n -> Fin n\n\n Fin_ : Nat -> Set\n Fin_ zero = Zero\n Fin_ (suc n) = Suc (Fin n)\n\n fzero : {n:Nat} -> Fin (suc n)\n fzero = finI fzero_\n\n fsuc : {n:Nat} -> Fin n -> Fin (suc n)\n fsuc i = finI (fsuc_ i)\n\n finE : {n:Nat} -> Fin n -> Fin_ n\n finE (finI i) = i\n\nmodule Vec where\n\n open Prelude\n open Fin\n\n infixr 15 ::\n\n -- Vectors ----------------------------------------------------------------\n\n data Nil : Set where\n nil_ : Nil\n\n data Cons (A As:Set) : Set where\n cons_ : A -> As -> Cons A As\n\n mutual\n\n data Vec (A:Set)(n:Nat) : Set where\n vecI : Vec_ A n -> Vec A n\n\n Vec_ : Set -> Nat -> Set\n Vec_ A zero = Nil\n Vec_ A (suc n) = Cons A (Vec A n)\n\n nil : {A:Set} -> Vec A zero\n nil = vecI nil_\n\n (::) : {A:Set} -> {n:Nat} -> A -> Vec A n -> Vec A (suc n)\n x :: xs = vecI (cons_ x xs)\n\n vecE : {A:Set} -> {n:Nat} -> Vec A n -> Vec_ A n\n vecE (vecI xs) = xs\n\n vec : {A:Set} -> (n:Nat) -> A -> Vec A n\n vec zero _ = nil\n vec (suc n) x = x :: vec n x\n\n map : {n:Nat} -> {A B:Set} -> (A -> B) -> Vec A n -> Vec B n\n map {zero} f (vecI nil_)\t = nil\n map {suc n} f (vecI (cons_ x xs)) = f x :: map f xs\n\n (!) : {n:Nat} -> {A:Set} -> Vec A n -> Fin n -> A\n (!) {suc n} (vecI (cons_ x _ )) (finI fzero_) = x\n (!) {suc n} (vecI (cons_ _ xs)) (finI (fsuc_ i)) = xs ! i\n\n tabulate : {n:Nat} -> {A:Set} -> (Fin n -> A) -> Vec A n\n tabulate {zero} f = nil\n tabulate {suc n} f = f fzero :: tabulate (\\x -> f (fsuc x))\n\nmodule Syntax where\n\n open Prelude\n open Fin\n\n -- Types ------------------------------------------------------------------\n\n infixr 8 =>\n\n data Type : Set where\n nat : Type\n (=>) : Type -> Type -> Type\n\n -- Terms ------------------------------------------------------------------\n\n data Term (n:Nat) : Set where\n eZero : Term n\n eSuc : Term n\n eApp : Term n -> Term n -> Term n\n eLam : Term (suc n) -> Term n\n eVar : Fin n -> Term n\n\nmodule NormalForms where\n\n open Prelude\n open Syntax\n open Fin\n\n mutual\n\n -- Normal terms -----------------------------------------------------------\n\n data Normal (n:Nat) : Set where\n nZero : Normal n\n nSuc : Normal n -> Normal n\n nLam : Normal (suc n) -> Normal n\n nNeutral : Neutral n -> Normal n\n nStuck : Normal n\t\t-- type error\n\n -- Neutral terms ----------------------------------------------------------\n\n data Neutral (n:Nat) : Set where\n uVar : Fin n -> Neutral n\n uApp : Neutral n -> Normal n -> Neutral n\n\n nVar : {n:Nat} -> Fin n -> Normal n\n nVar i = nNeutral (uVar i)\n\n nApp : {n:Nat} -> Neutral n -> Normal n -> Normal n\n nApp u n = nNeutral (uApp u n)\n\nmodule Rename where\n\n open Prelude\n open Fin\n open Vec\n open NormalForms\n\n -- Renamings --------------------------------------------------------------\n\n Ren : Nat -> Nat -> Set\n Ren m n = Vec (Fin n) m\n\n id : {n:Nat} -> Ren n n\n id = tabulate (\\i -> i)\n\n compose : {l m n:Nat} -> Ren m n -> Ren l m -> Ren l n\n compose {l}{m}{n} ρ γ = map (\\i -> ρ ! i) γ\n\n lift : {m n:Nat} -> Ren m n -> Ren (suc m) (suc n)\n lift ρ = fzero :: map fsuc ρ\n\n mutual\n\n rename : {m n:Nat} -> Ren m n -> Normal m -> Normal n\n rename ρ nZero\t = nZero\n rename ρ (nSuc n)\t = nSuc (rename ρ n)\n rename ρ (nLam n)\t = nLam (rename (lift ρ) n)\n rename ρ (nNeutral u) = nNeutral (renameNe ρ u)\n rename ρ nStuck\t = nStuck\n\n renameNe : {m n:Nat} -> Ren m n -> Neutral m -> Neutral n\n renameNe ρ (uVar i)\t = uVar (ρ ! i)\n renameNe ρ (uApp u n) = uApp (renameNe ρ u) (rename ρ n)\n\n up : {n:Nat} -> Ren n (suc n)\n up = map fsuc id\n\nmodule Subst where\n\n open Prelude\n open Fin\n open Vec\n open NormalForms\n open Rename using (Ren; rename; up)\n\n -- Substitutions ----------------------------------------------------------\n\n Sub : Nat -> Nat -> Set\n Sub m n = Vec (Normal n) m\n\n id : {n:Nat} -> Sub n n\n id = tabulate nVar\n\n ren2sub : {m n:Nat} -> Ren m n -> Sub m n\n ren2sub ρ = map nVar ρ\n\n lift : {m n:Nat} -> Sub m n -> Sub (suc m) (suc n)\n lift σ = nVar fzero :: map (rename up) σ\n\n mutual\n\n app : {n:Nat} -> Normal n -> Normal n -> Normal n\n app nZero\t _ = nStuck\n app (nSuc _) _ = nStuck\n app nStuck\t _ = nStuck\n app (nLam u) v = subst (v :: id) u\n app (nNeutral n) v = nApp n v\n\n subst : {m n:Nat} -> Sub m n -> Normal m -> Normal n\n subst σ nZero\t = nZero\n subst σ (nSuc v)\t = nSuc (subst σ v)\n subst σ (nLam v)\t = nLam (subst (lift σ) v)\n subst σ (nNeutral n) = substNe σ n\n subst σ nStuck\t = nStuck\n\n substNe : {m n:Nat} -> Sub m n -> Neutral m -> Normal n\n substNe σ (uVar i)\t = σ ! i\n substNe σ (uApp n v) = substNe σ n `app` subst σ v\n\n compose : {l m n:Nat} -> Sub m n -> Sub l m -> Sub l n\n compose σ δ = map (subst σ) δ\n\nmodule TypeSystem where\n\n open Prelude\n open Fin\n open Vec\n open Syntax\n\n mutual\n EqType : Type -> Type -> Prop\n EqType nat\t nat\t = True\n EqType (τ => τ') (σ => σ') = τ == σ /\\ τ' == σ'\n EqType _\t _\t = False\n\n infix 5 ==\n data (==) (τ0 τ1:Type) : Prop where\n eqTypeI : EqType τ0 τ1 -> τ0 == τ1\n\n eqSubst : {σ τ:Type} -> (C:Type -> Set) -> σ == τ -> C τ -> C σ\n eqSubst {nat}{nat} C _ x = x\n eqSubst {σ => τ}{σ' => τ'} C (eqTypeI (andI eqσ eqτ)) x =\n eqSubst (\\μ -> C (μ => τ)) eqσ (\n eqSubst (\\η -> C (σ' => η)) eqτ x\n )\n\n Context : Nat -> Set\n Context n = Vec Type n\n\n mutual\n\n HasType : {n:Nat} -> Context n -> Term n -> Type -> Set\n HasType Γ eZero\t τ = ZeroType Γ τ\n HasType Γ eSuc\t τ = SucType Γ τ\n HasType Γ (eVar i)\t τ = VarType Γ i τ\n HasType Γ (eApp e1 e2) τ = AppType Γ e1 e2 τ\n HasType Γ (eLam e)\t τ = LamType Γ e τ\n\n data ZeroType {n:Nat}(Γ:Context n)(τ:Type) : Set where\n zeroType : τ == nat -> HasType Γ eZero τ\n\n data SucType {n:Nat}(Γ:Context n)(τ:Type) : Set where\n sucType : τ == (nat => nat) -> HasType Γ eSuc τ\n\n data VarType {n:Nat}(Γ:Context n)(i:Fin n)(τ:Type) : Set where\n varType : τ == (Γ ! i) -> HasType Γ (eVar i) τ\n\n data AppType {n:Nat}(Γ:Context n)(e1 e2:Term n)(τ:Type) : Set where\n appType : (σ:Type) -> HasType Γ e1 (σ => τ) -> HasType Γ e2 σ -> HasType Γ (eApp e1 e2) τ\n\n data LamType {n:Nat}(Γ:Context n)(e:Term (suc n))(τ:Type) : Set where\n lamType : (τ0 τ1:Type) -> τ == (τ0 => τ1) -> HasType (τ0 :: Γ) e τ1 -> HasType Γ (eLam e) τ\n\nmodule NBE where\n\n open Prelude\n open Syntax\n open Fin\n open Vec\n open TypeSystem\n\n mutual\n\n D_ : Nat -> Type -> Set\n D_ n nat = NatD n\n D_ n (σ => τ) = FunD n σ τ\n\n data D (n:Nat)(τ:Type) : Set where\n dI : D_ n τ -> D n τ\n\n data NatD (n:Nat) : Set where\n zeroD_ :\t\t D_ n nat\n sucD_ : D n nat -> D_ n nat\n neD_ : Term n -> D_ n nat\n\n -- Will this pass the positivity check?\n data FunD (n:Nat)(σ τ:Type) : Set where\n lamD_ : (D n σ -> D n τ) -> D_ n (σ => τ)\n\n zeroD : {n:Nat} -> D n nat\n zeroD = dI zeroD_\n\n sucD : {n:Nat} -> D n nat -> D n nat\n sucD d = dI (sucD_ d)\n\n neD : {n:Nat} -> Term n -> D n nat\n neD t = dI (neD_ t)\n\n lamD : {n:Nat} -> {σ τ:Type} -> (D n σ -> D n τ) -> D n (σ => τ)\n lamD f = dI (lamD_ f)\n\n coerce : {n:Nat} -> {τ0 τ1:Type} -> τ0 == τ1 -> D n τ1 -> D n τ0\n coerce {n} = eqSubst (D n)\n\n mutual\n\n down : {τ:Type} -> {n:Nat} -> D n τ -> Term n\n down {σ => τ} (dI (lamD_ f)) = eLam (down {τ} ?) -- doesn't work!\n down {nat}\t (dI zeroD_) = eZero\n down {nat}\t (dI (sucD_ d)) = eSuc `eApp` down d\n down {nat}\t (dI (neD_ t)) = t\n\n up : {n:Nat} -> (τ:Type) -> Term n -> D n τ\n up (σ => τ) t = lamD (\\d -> up τ (t `eApp` down d))\n up nat\tt = neD t\n\n Valuation : {m:Nat} -> Nat -> Context m -> Set\n Valuation {zero} n _\t\t = Nil\n Valuation {suc m} n (vecI (cons_ τ Γ)) = Cons (D n τ) (Valuation n Γ)\n\n (!!) : {m n:Nat} -> {Γ:Context m} -> Valuation n Γ -> (i:Fin m) -> D n (Γ ! i)\n (!!) {suc _} {_} {vecI (cons_ _ _)} (cons_ v ξ) (finI fzero_) = v\n (!!) {suc _} {_} {vecI (cons_ _ _)} (cons_ v ξ) (finI (fsuc_ i)) = ξ !! i\n\n ext : {m n:Nat} -> {τ:Type} -> {Γ:Context m} -> Valuation n Γ -> D n τ -> Valuation n (τ :: Γ)\n ext ξ v = cons_ v ξ\n\n app : {σ τ:Type} -> {n:Nat} -> D n (σ => τ) -> D n σ -> D n τ\n --app (dI (lamD_ f)) d = f d\n app (lamD f) d = f d\n\n eval : {n:Nat} -> {Γ:Context n} -> (e:Term n) -> (τ:Type) -> HasType Γ e τ -> Valuation n Γ -> D n τ\n eval (eVar i) τ (varType eq)\t ξ = coerce eq (ξ !! i)\n eval (eApp r s) τ (appType σ dr ds)\t ξ = eval r (σ => τ) dr ξ `app` eval s σ ds ξ\n eval (eLam r)\t τ (lamType τ0 τ1 eq dr) ξ = coerce eq (lamD (\\d -> ?)) -- doesn't work either\n eval eZero\t τ (zeroType eq)\t ξ = coerce eq zeroD\n eval eSuc\t τ (sucType eq)\t ξ = coerce eq (lamD sucD)\n\nmodule Eval where\n\n open Prelude\n open Fin\n open Vec\n open Syntax\n open NormalForms\n open Rename using (up; rename)\n open Subst\n open TypeSystem\n\n eval : {n:Nat} -> (Γ:Context n) -> (e:Term n) -> (τ:Type) -> HasType Γ e τ -> Normal n\n eval Γ eZero\t τ _\t\t = nZero\n eval Γ eSuc\t τ _\t\t = nLam (nSuc (nVar fzero))\n eval Γ (eVar i) τ _\t\t = nVar i\n eval Γ (eApp e1 e2) τ (appType σ d1 d2) = eval Γ e1 (σ => τ) d1 `app` eval Γ e2 σ d2\n eval Γ (eLam e) τ (lamType τ0 τ1 _ d) = nLam (eval (τ0 :: Γ) e τ1 d)\n\nopen Prelude\nopen Fin\nopen Vec\nopen Syntax\n\n", "meta": {"hexsha": "7f2012cdca2b7882dc725d0624648ccf4e2908db", "size": 10298, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/NBE.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/NBE.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/NBE.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 25.8743718593, "max_line_length": 102, "alphanum_fraction": 0.4896096329, "num_tokens": 3875, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.867035763237924, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.620298195483614}} {"text": "open import MLib.Algebra.PropertyCode\nopen import MLib.Algebra.PropertyCode.Structures\n\nmodule MLib.Matrix.Pow {c ℓ} (struct : Struct bimonoidCode c ℓ) where\n\nopen import MLib.Prelude\nopen import MLib.Matrix.Core\nopen import MLib.Matrix.Equality struct\nopen import MLib.Matrix.Mul struct\nopen import MLib.Matrix.Plus struct\nopen import MLib.Matrix.Bimonoid struct\n\nopen FunctionProperties\n\nmodule _ {n} where\n open import MLib.Algebra.Operations (matrixStruct n)\n\n pow : Matrix S n n → ℕ → Matrix S n n\n pow M zero = 1●\n pow M (suc p) = M ⊗ pow M p\n\n pstar : Matrix S n n → ℕ → Matrix S n n\n pstar M zero = 0●\n pstar M (suc p) = 1● ⊕ M ⊗ pstar M p\n\n pstar′ : Matrix S n n → ℕ → Matrix S n n\n pstar′ M p = ∑[ q < p ] pow M (Fin.toℕ q)\n\n pstar′-unfold : ∀ {M : Matrix S n n} {p} → pstar′ M (suc p) ≈ 1● ⊕ M ⊗ pstar′ M p\n pstar′-unfold {M} {p} =\n begin\n pstar′ M (suc p) ≡⟨⟩\n pow M (Fin.toℕ (zero {p})) ⊕ ∑[ q < p ] pow M (Fin.toℕ (suc q)) ≡⟨⟩\n 1● ⊕ ∑[ q < p ] pow M (suc (Fin.toℕ q)) ≡⟨⟩\n 1● ⊕ ∑[ q < p ] (M ⊗ pow M (Fin.toℕ q)) ≈⟨ ⊕-cong refl (sym (sumDistribˡ ⦃ {!!} ⦄ {p} M _)) ⟩\n 1● ⊕ M ⊗ ∑[ q < p ] pow M (Fin.toℕ q) ≡⟨⟩\n 1● ⊕ M ⊗ pstar′ M p ∎\n where open EqReasoning setoid\n\n -- pstar-pstar′ : ∀ {M : Matrix S n n} {p} → pstar M p ≈ pstar′ M p\n -- pstar-pstar′ {p = zero} _ _ = S.refl\n -- pstar-pstar′ {M = M} {suc p} =\n -- begin\n -- ((1● ⊕ M) ⊗ pstar M p) ≈⟨ {!!} ⟩\n -- pow M (Fin.toℕ (zero {p})) ⊕ (Table.foldr {n = p} _⊕_ 0● (tabulate (pow M ∘ Fin.toℕ ∘ suc))) ≡⟨⟩\n -- pstar′ M (suc p) ∎\n -- where open EqReasoning setoid\n", "meta": {"hexsha": "831e34795080f77adb1ec39322788dfad68db6f4", "size": 1781, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/MLib/Matrix/Pow.agda", "max_stars_repo_name": "bch29/agda-matrices", "max_stars_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/MLib/Matrix/Pow.agda", "max_issues_repo_name": "bch29/agda-matrices", "max_issues_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/MLib/Matrix/Pow.agda", "max_forks_repo_name": "bch29/agda-matrices", "max_forks_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.1041666667, "max_line_length": 124, "alphanum_fraction": 0.5070185289, "num_tokens": 706, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357666736772, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.6202981874201043}} {"text": "open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl)\nopen import Relation.Nullary.Decidable using (False; toWitnessFalse)\nopen import Data.Fin using (Fin; _≟_)\nopen import Data.Nat using (ℕ; suc)\nopen import Data.Product using (_×_; _,_)\n\nopen import Common\n\ndata Global (n : ℕ) : Set where\n endG : Global n\n msgSingle : (p q : Fin n) -> p ≢ q -> Label -> Global n -> Global n\n\nprivate\n variable\n n : ℕ\n p p′ q q′ r s : Fin n\n l l′ : Label\n g gSub gSub′ : Global n\n\nmsgSingle′ : (p q : Fin n) -> {False (p ≟ q)} -> Label -> Global n -> Global n\nmsgSingle′ p q {p≢q} l gSub = msgSingle p q (toWitnessFalse p≢q) l gSub\n\nsize-g : ∀ { n : ℕ } -> (g : Global n) -> ℕ\nsize-g endG = 0\nsize-g (msgSingle _ _ _ _ gSub) = suc (size-g gSub)\n\nsize-g-reduces :\n ∀ { p≢q }\n -> g ≡ msgSingle {n} p q p≢q l gSub\n -> size-g g ≡ suc (size-g gSub)\nsize-g-reduces {g = endG} ()\nsize-g-reduces {g = msgSingle _ _ _ _ gSub} refl = refl\n\nmsgSingle-subst-left :\n ∀ { p≢q }\n -> g ≡ msgSingle {n} p q p≢q l gSub\n -> (p≡p′ : p ≡ p′)\n -> g ≡ msgSingle {n} p′ q (≢-subst-left p≢q p≡p′) l gSub\nmsgSingle-subst-left refl refl = refl\n\nmsgSingle-subst-right :\n ∀ { p≢q }\n -> g ≡ msgSingle {n} p q p≢q l gSub\n -> (q≡q′ : q ≡ q′)\n -> g ≡ msgSingle {n} p q′ (≢-subst-right p≢q q≡q′) l gSub\nmsgSingle-subst-right refl refl = refl\n\nmsgSingle-injective :\n ∀ { p≢q p′≢q′ }\n -> msgSingle {n} p q p≢q l gSub ≡ msgSingle p′ q′ p′≢q′ l′ gSub′\n -> p ≡ p′ × q ≡ q′ × l ≡ l′ × gSub ≡ gSub′\nmsgSingle-injective refl = refl , refl , refl , refl\n\ndata _-_→g_ {n : ℕ} : Global n -> Action n -> Global n -> Set where\n →g-prefix :\n ∀ { p≢q p≢q′ }\n -> (msgSingle p q p≢q l gSub) - (action p q p≢q′ l) →g gSub\n →g-cont :\n ∀ { p≢q r≢s }\n -> gSub - (action p q p≢q l) →g gSub′\n -> p ≢ r\n -> q ≢ r\n -> p ≢ s\n -> q ≢ s\n -> (msgSingle r s r≢s l′ gSub) - (action p q p≢q l) →g (msgSingle r s r≢s l′ gSub′)\n", "meta": {"hexsha": "90e5b93b79d30e94cf42808b65b801e073370704", "size": 1923, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Global.agda", "max_stars_repo_name": "fangyi-zhou/mpst-in-agda", "max_stars_repo_head_hexsha": "3d12eed9d340207d242d70f43c6b34e01d3620de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-08-14T17:36:53.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-14T17:36:53.000Z", "max_issues_repo_path": "Global.agda", "max_issues_repo_name": "fangyi-zhou/mpst-in-agda", "max_issues_repo_head_hexsha": "3d12eed9d340207d242d70f43c6b34e01d3620de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-08-31T10:15:38.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-24T11:30:17.000Z", "max_forks_repo_path": "Global.agda", "max_forks_repo_name": "fangyi-zhou/mpst-in-agda", "max_forks_repo_head_hexsha": "3d12eed9d340207d242d70f43c6b34e01d3620de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.1363636364, "max_line_length": 87, "alphanum_fraction": 0.5631825273, "num_tokens": 815, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357735451834, "lm_q2_score": 0.7154239836484143, "lm_q1q2_score": 0.6202981870753795}} {"text": "module Isos.NatLike where\n\nopen import Isos.Isomorphism\n\nopen import Nats\nopen import Data.Product\n\nopen import Equality\nopen import Data.Unit\n\n------------------------------------------------------------------------\n-- internal stuffs\n\nprivate\n\n module WithList where\n\n open import Lists\n\n list→ℕ : List ⊤ → ℕ\n list→ℕ [] = zero\n list→ℕ (tt ∷ a) = suc (list→ℕ a)\n\n ℕ→list : ℕ → List ⊤\n ℕ→list zero = []\n ℕ→list (suc a) = tt ∷ ℕ→list a\n\n proofListL : ∀ n → list→ℕ (ℕ→list n) ≡ n\n proofListL zero = refl\n proofListL (suc n) rewrite proofListL n = refl\n\n proofListR : ∀ n → ℕ→list (list→ℕ n) ≡ n\n proofListR [] = refl\n proofListR (tt ∷ l) rewrite proofListR l = refl\n\n module WithVec where\n\n open import Vecs\n\n vec→ℕ′ : ∀ {n} → Vec ⊤ n → ℕ\n vec→ℕ′ {n} [] = n\n vec→ℕ′ {n} (tt ∷ a) = n\n\n vec→ℕ : ∀ {n} → Vec ⊤ n → ∃ (λ m → n ≡ m)\n vec→ℕ [] = zero , refl\n vec→ℕ (tt ∷ a) with vec→ℕ a\n ... | m , refl = suc m , refl\n\n ℕ→vec : ∀ {n} → ∃ (λ m → n ≡ m) → Vec ⊤ n\n ℕ→vec (zero , refl) = []\n ℕ→vec ((suc a) , refl) = tt ∷ ℕ→vec (a , refl)\n\n proofVecL : ∀ {n} (m : ∃ (λ m → n ≡ m)) → vec→ℕ (ℕ→vec m) ≡ m\n proofVecL (zero , refl) = refl\n proofVecL (suc a , refl) rewrite proofVecL (a , refl) = refl\n\n -- how to prove?\n -- proofVecR : ∀ n → ℕ→vec (vec→ℕ n) ≡ n\n\n------------------------------------------------------------------------\n-- public aliases\n\niso-nat-list : ℕ ⇔ List ⊤\niso-nat-list = ∧-intro ℕ→list list→ℕ\n\niso-nat-vec : ∀ {n} → ∃ (λ m → n ≡ m) ⇔ Vec ⊤ n\niso-nat-vec = ∧-intro ℕ→vec vec→ℕ\n", "meta": {"hexsha": "a32329232d49ba29e63e27c8fba70dc8274a00c2", "size": 1554, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Isos/NatLike.agda", "max_stars_repo_name": "ice1k/Theorems", "max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z", "max_issues_repo_path": "src/Isos/NatLike.agda", "max_issues_repo_name": "ice1k/Theorems", "max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Isos/NatLike.agda", "max_forks_repo_name": "ice1k/Theorems", "max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.8529411765, "max_line_length": 72, "alphanum_fraction": 0.4916344916, "num_tokens": 614, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357632379241, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.6202981849620841}} {"text": "module Data.Vec.Extra where\n\nopen import Data.Product hiding (map; zip)\nopen import Data.Nat\nopen import Data.Fin\nopen import Data.Vec\nopen import Relation.Binary.PropositionalEquality\nopen import Function\n\nmap-with-∈ : ∀ {a}{A : Set a}{b n}{B : Set b}\n (xs : Vec A n) → (∀ i {x} → lookup i xs ≡ x → B) → Vec B n\nmap-with-∈ [] f = []\nmap-with-∈ (x ∷ xs) f = f zero refl ∷ map-with-∈ xs (λ i x → f (suc i) refl)\n", "meta": {"hexsha": "677734b1d26b0ec36c862f9b940ce17bf7179d87", "size": 429, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Vec/Extra.agda", "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_issues_repo_path": "src/Data/Vec/Extra.agda", "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_forks_repo_path": "src/Data/Vec/Extra.agda", "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "avg_line_length": 30.6428571429, "max_line_length": 76, "alphanum_fraction": 0.6153846154, "num_tokens": 149, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8519528170040852, "lm_q2_score": 0.727975443004307, "lm_q1q2_score": 0.6202007293773163}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Relation.Nullary.Discrete.FromBoolean where\n\nopen import Prelude\nopen import Relation.Nullary.Discrete\n\nmodule _ {a} {A : Type a}\n (_≡ᴮ_ : A → A → Bool)\n (sound : ∀ x y → T (x ≡ᴮ y) → x ≡ y)\n (complete : ∀ x → T (x ≡ᴮ x))\n where\n\n from-bool-eq : Discrete A\n from-bool-eq x y =\n iff-dec (sound x y iff flip (subst (λ z → T (x ≡ᴮ z))) (complete x)) (T? (x ≡ᴮ y))\n", "meta": {"hexsha": "de39b5a2ce0ed793101de9f43e947226a4c986d8", "size": 444, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Relation/Nullary/Discrete/FromBoolean.agda", "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_issues_repo_path": "Relation/Nullary/Discrete/FromBoolean.agda", "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Relation/Nullary/Discrete/FromBoolean.agda", "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "avg_line_length": 26.1176470588, "max_line_length": 86, "alphanum_fraction": 0.545045045, "num_tokens": 163, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8519528019683105, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.6202007284875306}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nopen import Cubical.Core.Everything\nopen import Cubical.Relation.Binary\nopen import Cubical.Algebra.Magma\n\nmodule Cubical.Algebra.Magma.Construct.Quotient {c ℓ} (M : Magma c) {R : Rel ⟨ M ⟩ ℓ} (isEq : IsEquivalence R)\n (closed : Congruent₂ R (Magma._•_ M)) where\n\nopen import Cubical.Algebra.Properties\nopen import Cubical.HITs.SetQuotients\n\nopen Magma M\nopen IsEquivalence isEq\n\nCarrier/R = Carrier / R\n\n_•ᴿ_ : Op₂ Carrier/R\n_•ᴿ_ = rec2 squash/ (λ x y → [ x • y ]) (λ _ _ _ eq → eq/ _ _ (cong₂⇒rcong R reflexive _•_ closed eq))\n (λ _ _ _ eq → eq/ _ _ (cong₂⇒lcong R reflexive _•_ closed eq))\n\nM/R-isMagma : IsMagma Carrier/R _•ᴿ_\nM/R-isMagma = record { is-set = squash/ }\n\nM/R : Magma (ℓ-max c ℓ)\nM/R = record { isMagma = M/R-isMagma }\n", "meta": {"hexsha": "4f304fed8d3c161e6198666c49415f66dd0b0c76", "size": 879, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Magma/Construct/Quotient.agda", "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Magma/Construct/Quotient.agda", "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Magma/Construct/Quotient.agda", "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.5555555556, "max_line_length": 110, "alphanum_fraction": 0.6177474403, "num_tokens": 295, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9086178969328286, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.6201987169304175}} {"text": "-- {-# OPTIONS --no-coverage-check #-}\n-- {-# OPTIONS -v tc.lhs:40 #-}\nmodule FlexibleFunArity where\n\nopen import Common.Equality\n\ndata Bool : Set where true false : Bool\n\ndata Maybe (A : Set) : Set where\n nothing : Maybe A\n just : A → Maybe A\n\nCase : {A : Set} → Maybe A → Set → Set → Set\nCase nothing B C = B\nCase (just _) B C = C\n\nsample : {A : Set} (m : Maybe A) → Case m Bool (Maybe A → Bool)\nsample (just a) (just b) = true\nsample (just a) nothing = false\nsample nothing = true\n\ng : Bool -> Bool -> Bool\ng false true = false\ng true = \\ x -> true\ng false false = true\n-- g true false = false -- Unreachable clause\n\ntestg1 : ∀ {x} → g true x ≡ true\ntestg1 = refl\n\ntestg2 : g false true ≡ false\ntestg2 = refl\n\ntestg3 : g false false ≡ true\ntestg3 = refl\n\n\nT : Bool -> Set\nT true = Bool\nT false = Bool -> Bool\n\nf : (b : Bool) -> T b\nf false true = false\nf false false = true\nf true = true\n\ntestf1 : f true ≡ true\ntestf1 = refl\n\ntestf2 : f false true ≡ false\ntestf2 = refl\n\ntestf3 : f false false ≡ true\ntestf3 = refl\n\n\n{- checking clause\n\n f false true\n\nstarts with\n\n f (b : Bool) : T b\n\nsplits on b\n\n f true -- no match, discard\n f false -- matches\n\ninstantiate type\n\n f false : T false = Bool -> Bool\n\nextend clause\n\n f false (y : Bool) : Bool\n\nsplit on y\n\n f false true -- matches\n f false false -- no match, discard\n\ndone\n-}\n\n\n{- coverage check starts with\n\n f (x : Bool)\n\nsplits on x\n\n f true -- finds clause 1\n f false\n\nNEW: remaing clauses have bigger arity, so expands to\n\n f false (y : Bool)\n\nsplits on y\n\n f false true -- finds clause 2\n f false false -- finds clause 3\n\ndone\n-}\n", "meta": {"hexsha": "1bb0ce1b708d94069f5c7cec134dff49c00b7cd8", "size": 1629, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/FlexibleFunArity.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_issues_repo_path": "test/succeed/FlexibleFunArity.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/FlexibleFunArity.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 15.2242990654, "max_line_length": 63, "alphanum_fraction": 0.6249232658, "num_tokens": 533, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.815232480373843, "lm_q2_score": 0.7606506635289836, "lm_q1q2_score": 0.6201071271267428}} {"text": "------------------------------------------------------------------------\n-- The cubical identity type\n------------------------------------------------------------------------\n\n{-# OPTIONS --erased-cubical --safe #-}\n\nmodule Equality.Id where\n\nopen import Equality\nimport Equality.Path as P\nopen import Prelude\n\nimport Agda.Builtin.Cubical.Id as Id\n\n------------------------------------------------------------------------\n-- Equality\n\ninfix 4 _≡_\n\n_≡_ : ∀ {a} {A : Type a} → A → A → Type a\n_≡_ = Id.Id\n\nrefl : ∀ {a} {A : Type a} {x : A} → x ≡ x\nrefl = Id.conid P.1̲ P.refl\n\n------------------------------------------------------------------------\n-- Various derived definitions and properties\n\nreflexive-relation : ∀ ℓ → Reflexive-relation ℓ\nReflexive-relation._≡_ (reflexive-relation _) = _≡_\nReflexive-relation.refl (reflexive-relation _) = λ _ → refl\n\nequality-with-J₀ : ∀ {a p} → Equality-with-J₀ a p reflexive-relation\nEquality-with-J₀.elim equality-with-J₀ = λ P r → Id.primIdJ\n (λ _ → P) (r _)\nEquality-with-J₀.elim-refl equality-with-J₀ = λ _ _ → refl\n\nequivalence-relation⁺ : ∀ ℓ → Equivalence-relation⁺ ℓ\nequivalence-relation⁺ _ = J₀⇒Equivalence-relation⁺ equality-with-J₀\n\nequality-with-paths :\n ∀ {a p} → P.Equality-with-paths a p equivalence-relation⁺\nequality-with-paths =\n P.Equality-with-J₀⇒Equality-with-paths equality-with-J₀\n\nopen P.Derived-definitions-and-properties equality-with-paths public\n hiding (_≡_; refl; reflexive-relation; equality-with-J₀)\n\nopen import Equality.Path.Isomorphisms equality-with-paths public\n", "meta": {"hexsha": "985f847397b0f90ddff871e24676d9ccf2f8bb1e", "size": 1603, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Equality/Id.agda", "max_stars_repo_name": "nad/equality", "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_issues_repo_path": "src/Equality/Id.agda", "max_issues_repo_name": "nad/equality", "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Equality/Id.agda", "max_forks_repo_name": "nad/equality", "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.06, "max_line_length": 72, "alphanum_fraction": 0.5601996257, "num_tokens": 419, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972684083609, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.6200673993887381}} {"text": "\nmodule _ where\n\nopen import Agda.Builtin.List\nopen import Agda.Builtin.Nat\nopen import Agda.Builtin.Equality\n\nvariable\n a b : Set\n\n{-# FOREIGN AGDA2HS\n import Prelude hiding (map, sum)\n #-}\n\ndata Exp (v : Set) : Set where\n Plus : Exp v → Exp v → Exp v\n Int : Nat → Exp v\n Var : v → Exp v\n\n{-# COMPILE AGDA2HS Exp #-}\n\neval : (a → Nat) → Exp a → Nat\neval env (Plus a b) = eval env a + eval env b\neval env (Int n) = n\neval env (Var x) = env x\n\n{-# COMPILE AGDA2HS eval #-}\n\nsum : List Nat → Nat\nsum [] = 0\nsum (x ∷ xs) = x + sum xs\n\n{-# COMPILE AGDA2HS sum #-}\n\n{-# FOREIGN AGDA2HS -- comment #-}\n\nappend : List a → List a → List a\nappend [] ys = ys\nappend (x ∷ xs) ys = x ∷ append xs ys\n\n{-# COMPILE AGDA2HS append #-}\n\nmap : (a → b) → List a → List b\nmap f [] = []\nmap f (x ∷ xs) = f x ∷ map f xs\n\n{-# COMPILE AGDA2HS map #-}\n\nassoc : (a b c : Nat) → a + (b + c) ≡ (a + b) + c\nassoc zero b c = refl\nassoc (suc a) b c rewrite assoc a b c = refl\n\nthm : ∀ xs ys → sum (append xs ys) ≡ sum xs + sum ys\nthm [] ys = refl\nthm (x ∷ xs) ys rewrite thm xs ys | assoc x (sum xs) (sum ys) = refl\n\n", "meta": {"hexsha": "57d613fced6e5a76a86bb1cdd06767a73fc30c42", "size": 1112, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Test.agda", "max_stars_repo_name": "jmchapman/agda2hs", "max_stars_repo_head_hexsha": "0f8b0b8a17ecad9e9be7ef5cae564187787df31d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Test.agda", "max_issues_repo_name": "jmchapman/agda2hs", "max_issues_repo_head_hexsha": "0f8b0b8a17ecad9e9be7ef5cae564187787df31d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Test.agda", "max_forks_repo_name": "jmchapman/agda2hs", "max_forks_repo_head_hexsha": "0f8b0b8a17ecad9e9be7ef5cae564187787df31d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.5087719298, "max_line_length": 68, "alphanum_fraction": 0.5710431655, "num_tokens": 402, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619350028204, "lm_q2_score": 0.7520125848754472, "lm_q1q2_score": 0.6200057508728839}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule Pifextensional where\n\nopen import Relation.Binary.PropositionalEquality \n using (_≡_; refl; sym; trans; cong; cong₂; module ≡-Reasoning)\nopen ≡-Reasoning\n\nopen import Data.Empty using (⊥)\nopen import Data.Unit using (⊤; tt)\nopen import Data.Sum using (_⊎_; inj₁; inj₂)\nopen import Data.Product using (_×_; _,_)\n\nopen import Groupoid\n\n------------------------------------------------------------------------------\n-- Level 0: \n\n-- ZERO is a type with no elements\n-- ONE is a type with one element 'tt'\n-- PLUS ONE ONE is a type with elements 'false' and 'true'\n-- and so on for all finite types built from ZERO, ONE, PLUS, and TIMES\n-- \n-- We also have that U is a type with elements ZERO, ONE, PLUS ONE ONE, \n-- TIMES BOOL BOOL, etc.\n\ndata U : Set where\n ZERO : U\n ONE : U\n PLUS : U → U → U\n TIMES : U → U → U\n\n⟦_⟧ : U → Set \n⟦ ZERO ⟧ = ⊥ \n⟦ ONE ⟧ = ⊤\n⟦ PLUS t₁ t₂ ⟧ = ⟦ t₁ ⟧ ⊎ ⟦ t₂ ⟧\n⟦ TIMES t₁ t₂ ⟧ = ⟦ t₁ ⟧ × ⟦ t₂ ⟧\n\n-- Abbreviations for examples\n\nBOOL BOOL² : U\nBOOL = PLUS ONE ONE \nBOOL² = TIMES BOOL BOOL\n\nfalse⟷ true⟷ : ⟦ BOOL ⟧\nfalse⟷ = inj₁ tt\ntrue⟷ = inj₂ tt\n\n-- For any finite type (t : U) there is no non-trivial path structure\n-- between the elements of t. All such finite types are discrete\n-- groupoids\n--\n-- For U, there are non-trivial paths between its points. In the\n-- conventional HoTT presentation, a path between t₁ and t₂ is\n-- postulated by univalence for each equivalence between t₁ and t₂. In\n-- the context of finite types, an equivalence corresponds to a\n-- permutation as each permutation has a unique inverse\n-- permutation. Thus instead of the detour using univalence, we can\n-- give an inductive definition of all possible permutations between\n-- finite types which naturally induces paths between the points. More\n-- precisely, two types t₁ and t₂ have a path between them if there is\n-- a permutation (c : t₁ ⟷ t₂). The fact that c is a permutation\n-- guarantees, by construction, that (c ◎ ! c ∼ id⟷) and (! c ◎ c ∼\n-- id⟷). A complete set of generators for all possible permutations\n-- between finite types is given by the following definition. Note\n-- that these permutations do not reach inside the types and hence do\n-- not generate paths between the points within the types. The paths\n-- are just between the types themselves.\n\ninfix 30 _⟷_\ninfixr 50 _◎_\n\ndata _⟷_ : U → U → Set where\n unite₊ : {t : U} → PLUS ZERO t ⟷ t\n uniti₊ : {t : U} → t ⟷ PLUS ZERO t\n swap₊ : {t₁ t₂ : U} → PLUS t₁ t₂ ⟷ PLUS t₂ t₁\n assocl₊ : {t₁ t₂ t₃ : U} → PLUS t₁ (PLUS t₂ t₃) ⟷ PLUS (PLUS t₁ t₂) t₃\n assocr₊ : {t₁ t₂ t₃ : U} → PLUS (PLUS t₁ t₂) t₃ ⟷ PLUS t₁ (PLUS t₂ t₃)\n unite⋆ : {t : U} → TIMES ONE t ⟷ t\n uniti⋆ : {t : U} → t ⟷ TIMES ONE t\n swap⋆ : {t₁ t₂ : U} → TIMES t₁ t₂ ⟷ TIMES t₂ t₁\n assocl⋆ : {t₁ t₂ t₃ : U} → TIMES t₁ (TIMES t₂ t₃) ⟷ TIMES (TIMES t₁ t₂) t₃\n assocr⋆ : {t₁ t₂ t₃ : U} → TIMES (TIMES t₁ t₂) t₃ ⟷ TIMES t₁ (TIMES t₂ t₃)\n distz : {t : U} → TIMES ZERO t ⟷ ZERO\n factorz : {t : U} → ZERO ⟷ TIMES ZERO t\n dist : {t₁ t₂ t₃ : U} → \n TIMES (PLUS t₁ t₂) t₃ ⟷ PLUS (TIMES t₁ t₃) (TIMES t₂ t₃) \n factor : {t₁ t₂ t₃ : U} → \n PLUS (TIMES t₁ t₃) (TIMES t₂ t₃) ⟷ TIMES (PLUS t₁ t₂) t₃\n id⟷ : {t : U} → t ⟷ t\n _◎_ : {t₁ t₂ t₃ : U} → (t₁ ⟷ t₂) → (t₂ ⟷ t₃) → (t₁ ⟷ t₃)\n _⊕_ : {t₁ t₂ t₃ t₄ : U} → \n (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (PLUS t₁ t₂ ⟷ PLUS t₃ t₄)\n _⊗_ : {t₁ t₂ t₃ t₄ : U} → \n (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (TIMES t₁ t₂ ⟷ TIMES t₃ t₄)\n\n-- Nicer syntax that shows intermediate values instead of the above\n-- point-free notation of permutations\n\ninfixr 2 _⟷⟨_⟩_ \ninfix 2 _□ \n\n_⟷⟨_⟩_ : (t₁ : U) {t₂ : U} {t₃ : U} → \n (t₁ ⟷ t₂) → (t₂ ⟷ t₃) → (t₁ ⟷ t₃) \n_ ⟷⟨ α ⟩ β = α ◎ β\n\n_□ : (t : U) → {t : U} → (t ⟷ t)\n_□ t = id⟷\n\n-- Many ways of negating a BOOL. Again, it is absolutely critical that there\n-- is NO path between false⟷ and true⟷. These permutations instead are based\n-- on paths between x and neg (neg x) which are the trivial paths on each of\n-- the two points in BOOL.\n\nneg₁ neg₂ neg₃ neg₄ neg₅ : BOOL ⟷ BOOL\nneg₁ = swap₊\nneg₂ = id⟷ ◎ swap₊\nneg₃ = swap₊ ◎ swap₊ ◎ swap₊\nneg₄ = swap₊ ◎ id⟷\nneg₅ = uniti⋆ ◎ swap⋆ ◎ (swap₊ ⊗ id⟷) ◎ swap⋆ ◎ unite⋆\n\n-- CNOT\n\nCNOT : BOOL² ⟷ BOOL²\nCNOT = TIMES (PLUS x y) BOOL\n ⟷⟨ dist ⟩\n PLUS (TIMES x BOOL) (TIMES y BOOL)\n ⟷⟨ id⟷ ⊕ (id⟷ ⊗ swap₊) ⟩\n PLUS (TIMES x BOOL) (TIMES y BOOL)\n ⟷⟨ factor ⟩\n TIMES (PLUS x y) BOOL □\n where x = ONE; y = ONE\n\n-- TOFFOLI\n\nTOFFOLI : TIMES BOOL BOOL² ⟷ TIMES BOOL BOOL²\nTOFFOLI = TIMES (PLUS x y) BOOL² \n ⟷⟨ dist ⟩\n PLUS (TIMES x BOOL²) (TIMES y BOOL²)\n ⟷⟨ id⟷ ⊕ (id⟷ ⊗ CNOT) ⟩ \n PLUS (TIMES x BOOL²) (TIMES y BOOL²)\n ⟷⟨ factor ⟩\n TIMES (PLUS x y) BOOL² □\n where x = ONE; y = ONE\n\n-- Every permutation has an inverse. There are actually many syntactically\n-- different inverses but they are all equivalent.\n\n! : {t₁ t₂ : U} → (t₁ ⟷ t₂) → (t₂ ⟷ t₁)\n! unite₊ = uniti₊\n! uniti₊ = unite₊\n! swap₊ = swap₊\n! assocl₊ = assocr₊\n! assocr₊ = assocl₊\n! unite⋆ = uniti⋆\n! uniti⋆ = unite⋆\n! swap⋆ = swap⋆\n! assocl⋆ = assocr⋆\n! assocr⋆ = assocl⋆\n! distz = factorz\n! factorz = distz\n! dist = factor \n! factor = dist\n! id⟷ = id⟷\n! (c₁ ◎ c₂) = ! c₂ ◎ ! c₁ \n! (c₁ ⊕ c₂) = (! c₁) ⊕ (! c₂)\n! (c₁ ⊗ c₂) = (! c₁) ⊗ (! c₂)\n\n!! : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → ! (! c) ≡ c\n!! {c = unite₊} = refl\n!! {c = uniti₊} = refl\n!! {c = swap₊} = refl\n!! {c = assocl₊} = refl\n!! {c = assocr₊} = refl\n!! {c = unite⋆} = refl\n!! {c = uniti⋆} = refl\n!! {c = swap⋆} = refl\n!! {c = assocl⋆} = refl\n!! {c = assocr⋆} = refl\n!! {c = distz} = refl\n!! {c = factorz} = refl\n!! {c = dist} = refl\n!! {c = factor} = refl\n!! {c = id⟷} = refl\n!! {c = c₁ ◎ c₂} = \n begin (! (! (c₁ ◎ c₂))\n ≡⟨ refl ⟩\n ! (! c₂ ◎ ! c₁)\n ≡⟨ refl ⟩ \n ! (! c₁) ◎ ! (! c₂)\n ≡⟨ cong₂ _◎_ (!! {c = c₁}) (!! {c = c₂}) ⟩ \n c₁ ◎ c₂ ∎)\n!! {c = c₁ ⊕ c₂} = \n begin (! (! (c₁ ⊕ c₂))\n ≡⟨ refl ⟩\n ! (! c₁) ⊕ ! (! c₂)\n ≡⟨ cong₂ _⊕_ (!! {c = c₁}) (!! {c = c₂}) ⟩ \n c₁ ⊕ c₂ ∎)\n!! {c = c₁ ⊗ c₂} = \n begin (! (! (c₁ ⊗ c₂))\n ≡⟨ refl ⟩\n ! (! c₁) ⊗ ! (! c₂)\n ≡⟨ cong₂ _⊗_ (!! {c = c₁}) (!! {c = c₂}) ⟩ \n c₁ ⊗ c₂ ∎)\n\n------------------------------------------------------------------------------\n-- Extensional view of 2paths.\n-- \n-- There is a 2path between two permutations p and q if for each x, the\n-- result of p(x) and q(x) are identical. \n\n-- First we define the extensional view of a permutation as a function.\n\nap : {t₁ t₂ : U} → (t₁ ⟷ t₂) → ⟦ t₁ ⟧ → ⟦ t₂ ⟧\nap unite₊ (inj₁ ()) -- absurd\nap unite₊ (inj₂ v) = v\nap uniti₊ v = inj₂ v\nap swap₊ (inj₁ v) = inj₂ v\nap swap₊ (inj₂ v) = inj₁ v\nap assocl₊ (inj₁ v) = inj₁ (inj₁ v)\nap assocl₊ (inj₂ (inj₁ v)) = inj₁ (inj₂ v) \nap assocl₊ (inj₂ (inj₂ v)) = inj₂ v\nap assocr₊ (inj₁ (inj₁ v)) = inj₁ v\nap assocr₊ (inj₁ (inj₂ v)) = inj₂ (inj₁ v)\nap assocr₊ (inj₂ v) = inj₂ (inj₂ v)\nap unite⋆ (tt , v) = v\nap uniti⋆ v = (tt , v)\nap swap⋆ (v₁ , v₂) = (v₂ , v₁)\nap assocl⋆ (v₁ , (v₂ , v₃)) = ((v₁ , v₂) , v₃)\nap assocr⋆ ((v₁ , v₂) , v₃) = (v₁ , (v₂ , v₃))\nap distz (() , _) -- absurd\nap factorz () -- absurd\nap dist (inj₁ v₁ , v₃) = inj₁ (v₁ , v₃)\nap dist (inj₂ v₂ , v₃) = inj₂ (v₂ , v₃)\nap factor (inj₁ (v₁ , v₃)) = (inj₁ v₁ , v₃)\nap factor (inj₂ (v₂ , v₃)) = (inj₂ v₂ , v₃)\nap id⟷ v = v\nap (c₁ ◎ c₂) v = ap c₂ (ap c₁ v)\nap (c₁ ⊕ c₂) (inj₁ v) = inj₁ (ap c₁ v)\nap (c₁ ⊕ c₂) (inj₂ v) = inj₂ (ap c₂ v)\nap (c₁ ⊗ c₂) (v₁ , v₂) = (ap c₁ v₁ , ap c₂ v₂)\n\nα◎!α : {t₁ t₂ : U} {α : t₁ ⟷ t₂} {v : ⟦ t₁ ⟧} → ap (α ◎ ! α) v ≡ v\nα◎!α {α = unite₊} {inj₁ ()}\nα◎!α {α = unite₊} {inj₂ v} = refl\nα◎!α {α = uniti₊} {v} = refl\nα◎!α {α = swap₊} {inj₁ v} = refl\nα◎!α {α = swap₊} {inj₂ v} = refl\nα◎!α {α = assocl₊} {inj₁ v} = refl\nα◎!α {α = assocl₊} {inj₂ (inj₁ v)} = refl\nα◎!α {α = assocl₊} {inj₂ (inj₂ v)} = refl\nα◎!α {α = assocr₊} {inj₁ (inj₁ v)} = refl\nα◎!α {α = assocr₊} {inj₁ (inj₂ v)} = refl\nα◎!α {α = assocr₊} {inj₂ v} = refl\nα◎!α {α = unite⋆} {v} = refl\nα◎!α {α = uniti⋆} {v} = refl\nα◎!α {α = swap⋆} {v} = refl\nα◎!α {α = assocl⋆} {v} = refl\nα◎!α {α = assocr⋆} {v} = refl\nα◎!α {α = distz} {(() , _)}\nα◎!α {α = factorz} {()}\nα◎!α {α = dist} {(inj₁ v₁ , v₂)} = refl\nα◎!α {α = dist} {(inj₂ v₁ , v₂)} = refl\nα◎!α {α = factor} {inj₁ v} = refl\nα◎!α {α = factor} {inj₂ v} = refl\nα◎!α {α = id⟷} {v} = refl\nα◎!α {α = α₁ ◎ α₂} {v} = \n begin \n ap ((α₁ ◎ α₂) ◎ ! (α₁ ◎ α₂)) v\n ≡⟨ refl ⟩\n ap (! α₁) (ap (α₂ ◎ ! α₂) (ap α₁ v))\n ≡⟨ cong (λ v' → ap (! α₁) v') (α◎!α {α = α₂} {v = ap α₁ v}) ⟩ \n ap (! α₁) (ap α₁ v)\n ≡⟨ α◎!α {α = α₁} {v = v} ⟩\n v ∎\nα◎!α {α = α₁ ⊕ α₂} {inj₁ v} = \n begin \n ap ((α₁ ⊕ α₂) ◎ ! (α₁ ⊕ α₂)) (inj₁ v)\n ≡⟨ refl ⟩\n inj₁ (ap (! α₁) (ap α₁ v))\n ≡⟨ cong inj₁ (α◎!α {α = α₁} {v}) ⟩\n inj₁ v ∎\nα◎!α {α = α₁ ⊕ α₂} {inj₂ v} = \n begin \n ap ((α₁ ⊕ α₂) ◎ ! (α₁ ⊕ α₂)) (inj₂ v)\n ≡⟨ refl ⟩\n inj₂ (ap (! α₂) (ap α₂ v))\n ≡⟨ cong inj₂ (α◎!α {α = α₂} {v}) ⟩\n inj₂ v ∎\nα◎!α {α = α₁ ⊗ α₂} {(v₁ , v₂)} = \n begin \n ap ((α₁ ⊗ α₂) ◎ ! (α₁ ⊗ α₂)) (v₁ , v₂) \n ≡⟨ refl ⟩\n (ap (! α₁) (ap α₁ v₁) , ap (! α₂) (ap α₂ v₂))\n ≡⟨ cong₂ (_,_) (α◎!α {α = α₁} {v = v₁}) (α◎!α {α = α₂} {v = v₂}) ⟩\n (v₁ , v₂) ∎\n\n!α◎α : {t₁ t₂ : U} {α : t₁ ⟷ t₂} {v : ⟦ t₂ ⟧} → ap (! α ◎ α) v ≡ v\n!α◎α {α = unite₊} {v} = refl\n!α◎α {α = uniti₊} {inj₁ ()} \n!α◎α {α = uniti₊} {inj₂ v} = refl\n!α◎α {α = swap₊} {inj₁ v} = refl\n!α◎α {α = swap₊} {inj₂ v} = refl\n!α◎α {α = assocl₊} {inj₁ (inj₁ v)} = refl\n!α◎α {α = assocl₊} {inj₁ (inj₂ v)} = refl\n!α◎α {α = assocl₊} {inj₂ v} = refl\n!α◎α {α = assocr₊} {inj₁ v} = refl\n!α◎α {α = assocr₊} {inj₂ (inj₁ v)} = refl\n!α◎α {α = assocr₊} {inj₂ (inj₂ v)} = refl\n!α◎α {α = unite⋆} {v} = refl\n!α◎α {α = uniti⋆} {v} = refl\n!α◎α {α = swap⋆} {v} = refl\n!α◎α {α = assocl⋆} {v} = refl\n!α◎α {α = assocr⋆} {v} = refl\n!α◎α {α = distz} {()}\n!α◎α {α = factorz} {(() , _)}\n!α◎α {α = dist} {inj₁ v} = refl\n!α◎α {α = dist} {inj₂ v} = refl\n!α◎α {α = factor} {(inj₁ v₁ , v₂)} = refl\n!α◎α {α = factor} {(inj₂ v₁ , v₂)} = refl\n!α◎α {α = id⟷} {v} = refl\n!α◎α {α = α₁ ◎ α₂} {v} = \n begin \n ap (! (α₁ ◎ α₂) ◎ (α₁ ◎ α₂)) v\n ≡⟨ refl ⟩\n ap α₂ (ap (! α₁ ◎ α₁) (ap (! α₂) v))\n ≡⟨ cong (λ v' → ap α₂ v') (!α◎α {α = α₁} {v = ap (! α₂) v}) ⟩ \n ap α₂ (ap (! α₂) v)\n ≡⟨ !α◎α {α = α₂} {v = v} ⟩\n v ∎\n!α◎α {α = α₁ ⊕ α₂} {inj₁ v} = \n begin \n ap (! (α₁ ⊕ α₂) ◎ (α₁ ⊕ α₂)) (inj₁ v)\n ≡⟨ refl ⟩\n inj₁ (ap α₁ (ap (! α₁) v))\n ≡⟨ cong inj₁ (!α◎α {α = α₁} {v}) ⟩\n inj₁ v ∎\n!α◎α {α = α₁ ⊕ α₂} {inj₂ v} = \n begin \n ap (! (α₁ ⊕ α₂) ◎ (α₁ ⊕ α₂)) (inj₂ v)\n ≡⟨ refl ⟩\n inj₂ (ap α₂ (ap (! α₂) v))\n ≡⟨ cong inj₂ (!α◎α {α = α₂} {v}) ⟩\n inj₂ v ∎\n!α◎α {α = α₁ ⊗ α₂} {(v₁ , v₂)} = \n begin \n ap (! (α₁ ⊗ α₂) ◎ (α₁ ⊗ α₂)) (v₁ , v₂) \n ≡⟨ refl ⟩\n (ap α₁ (ap (! α₁) v₁) , ap α₂ (ap (! α₂) v₂))\n ≡⟨ cong₂ (_,_) (!α◎α {α = α₁} {v = v₁}) (!α◎α {α = α₂} {v = v₂}) ⟩\n (v₁ , v₂) ∎\n\n-- Two permutations, viewed extensionally, are equivalent if they map\n-- each value x to the same value. Generally we would only require\n-- that the resulting values y and z have a path between them, but\n-- because the internals of each type are discrete groupoids, this\n-- reduces to saying that y and z are identical.\n\ninfix 10 _∼_ \n\n_∼_ : ∀ {t₁ t₂} → (p q : t₁ ⟷ t₂) → Set\n_∼_ {t₁} {t₂} p q = (x : ⟦ t₁ ⟧) → ap p x ≡ ap q x\n\nα◎!α∼id⟷ : {t₁ t₂ : U} {α : t₁ ⟷ t₂} → α ◎ ! α ∼ id⟷ \nα◎!α∼id⟷ {α = α} v = α◎!α {α = α} {v}\n\n!α◎α∼id⟷ : {t₁ t₂ : U} {α : t₁ ⟷ t₂} → ! α ◎ α ∼ id⟷ \n!α◎α∼id⟷ {t₁} {t₂} {α} v = !α◎α {α = α} {v}\n\nresp◎ : {t₁ t₂ t₃ : U} {p q : t₁ ⟷ t₂} {r s : t₂ ⟷ t₃} → \n (α : p ∼ q) → (β : r ∼ s) → (p ◎ r) ∼ (q ◎ s)\nresp◎ {t₁} {t₂} {t₃} {p} {q} {r} {s} α β v = \n begin \n ap (p ◎ r) v \n ≡⟨ refl ⟩\n ap r (ap p v)\n ≡⟨ cong (λ v → ap r v) (α v) ⟩ \n ap r (ap q v)\n ≡⟨ β (ap q v) ⟩ \n ap (q ◎ s) v ∎\n\n-- Because we representing combinators semantically as functions (not as\n-- permutations), we have to use function extensionality to compare the\n-- semantic representation. This need to be changed by making use of a proper\n-- representation of permutations instead of plain functions.\n\npostulate\n funExtP : {A B : Set} {f g : A → B} → ((x : A) → f x ≡ g x) → (f ≡ g)\n\n-- Two extensionally equivalent combinators are semantically\n-- equivalent. Again, if we had a proper representation of permutations, this\n-- would reduce to comparing the two representations without involving\n-- function extensionality.\n\next2id : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → ap c₁ ≡ ap c₂\next2id {t₁} {t₂} {c₁} {c₂} c₁∼c₂ = \n funExtP {⟦ t₁ ⟧} {⟦ t₂ ⟧} {ap c₁} {ap c₂} c₁∼c₂\n \n-- The equivalence ∼ of paths makes U a 1groupoid: the points are\n-- types (t : U); the 1paths are ⟷; and the 2paths between them are\n-- based on extensional equivalence ∼\n\nG : 1Groupoid\nG = record\n { set = U\n ; _↝_ = _⟷_\n ; _≈_ = _∼_\n ; id = id⟷\n ; _∘_ = λ p q → q ◎ p\n ; _⁻¹ = !\n ; lneutr = λ _ _ → refl\n ; rneutr = λ _ _ → refl\n ; assoc = λ _ _ _ _ → refl \n ; equiv = record { \n refl = λ _ → refl\n ; sym = λ α x → sym (α x)\n ; trans = λ α β x → trans (α x) (β x)\n }\n ; linv = λ {t₁} {t₂} α → α◎!α∼id⟷ {t₁} {t₂} {α}\n ; rinv = λ {t₁} {t₂} α → !α◎α∼id⟷ {t₁} {t₂} {α}\n ; ∘-resp-≈ = λ {t₁} {t₂} {t₃} {p} {q} {r} {s} p∼q r∼s → \n resp◎ {t₁} {t₂} {t₃} {r} {s} {p} {q} r∼s p∼q \n }\n\n------------------------------------------------------------------------------\n-- Picture so far:\n--\n-- path p\n-- =====================\n-- || || ||\n-- || ||2path ||\n-- || || ||\n-- || || path q ||\n-- t₁ =================t₂\n-- || ... ||\n-- =====================\n--\n-- The types t₁, t₂, etc are discrete groupoids. The paths between\n-- them correspond to permutations. Each syntactically different\n-- permutation corresponds to a path but equivalent permutations are\n-- connected by 2paths. But now we want an alternative definition of\n-- 2paths that is structural, i.e., that looks at the actual\n-- construction of the path t₁ ⟷ t₂ in terms of combinators... The\n-- theorem we want is that α ∼ β iff we can rewrite α to β using\n-- various syntactic structural rules. We start with a collection of\n-- simplication rules and then try to show they are complete.\n\n-- Simplification rules\n\ninfix 30 _⇔_\n\ndata _⇔_ : {t₁ t₂ : U} → (t₁ ⟷ t₂) → (t₁ ⟷ t₂) → Set where\n assoc◎l : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} → \n (c₁ ◎ (c₂ ◎ c₃)) ⇔ ((c₁ ◎ c₂) ◎ c₃)\n assoc◎r : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} → \n ((c₁ ◎ c₂) ◎ c₃) ⇔ (c₁ ◎ (c₂ ◎ c₃))\n assoc⊕l : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (c₁ ⊕ (c₂ ⊕ c₃)) ⇔ (assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊)\n assoc⊕r : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊) ⇔ (c₁ ⊕ (c₂ ⊕ c₃))\n assoc⊗l : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (c₁ ⊗ (c₂ ⊗ c₃)) ⇔ (assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆)\n assoc⊗r : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆) ⇔ (c₁ ⊗ (c₂ ⊗ c₃))\n dist⇔ : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n ((c₁ ⊕ c₂) ⊗ c₃) ⇔ (dist ◎ ((c₁ ⊗ c₃) ⊕ (c₂ ⊗ c₃)) ◎ factor)\n factor⇔ : {t₁ t₂ t₃ t₄ t₅ t₆ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} → \n (dist ◎ ((c₁ ⊗ c₃) ⊕ (c₂ ⊗ c₃)) ◎ factor) ⇔ ((c₁ ⊕ c₂) ⊗ c₃)\n idl◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (id⟷ ◎ c) ⇔ c\n idl◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ id⟷ ◎ c\n idr◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (c ◎ id⟷) ⇔ c\n idr◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ (c ◎ id⟷) \n linv◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (c ◎ ! c) ⇔ id⟷\n linv◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ⇔ (c ◎ ! c) \n rinv◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (! c ◎ c) ⇔ id⟷\n rinv◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ⇔ (! c ◎ c) \n unitel₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} → \n (unite₊ ◎ c₂) ⇔ ((c₁ ⊕ c₂) ◎ unite₊)\n uniter₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} → \n ((c₁ ⊕ c₂) ◎ unite₊) ⇔ (unite₊ ◎ c₂)\n unitil₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} → \n (uniti₊ ◎ (c₁ ⊕ c₂)) ⇔ (c₂ ◎ uniti₊)\n unitir₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} → \n (c₂ ◎ uniti₊) ⇔ (uniti₊ ◎ (c₁ ⊕ c₂))\n unitial₊⇔ : {t₁ t₂ : U} → (uniti₊ {PLUS t₁ t₂} ◎ assocl₊) ⇔ (uniti₊ ⊕ id⟷)\n unitiar₊⇔ : {t₁ t₂ : U} → (uniti₊ {t₁} ⊕ id⟷ {t₂}) ⇔ (uniti₊ ◎ assocl₊)\n swapl₊⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} → \n (swap₊ ◎ (c₁ ⊕ c₂)) ⇔ ((c₂ ⊕ c₁) ◎ swap₊)\n swapr₊⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} → \n ((c₂ ⊕ c₁) ◎ swap₊) ⇔ (swap₊ ◎ (c₁ ⊕ c₂))\n unitel⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} → \n (unite⋆ ◎ c₂) ⇔ ((c₁ ⊗ c₂) ◎ unite⋆)\n uniter⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} → \n ((c₁ ⊗ c₂) ◎ unite⋆) ⇔ (unite⋆ ◎ c₂)\n unitil⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} → \n (uniti⋆ ◎ (c₁ ⊗ c₂)) ⇔ (c₂ ◎ uniti⋆)\n unitir⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} → \n (c₂ ◎ uniti⋆) ⇔ (uniti⋆ ◎ (c₁ ⊗ c₂))\n unitial⋆⇔ : {t₁ t₂ : U} → (uniti⋆ {TIMES t₁ t₂} ◎ assocl⋆) ⇔ (uniti⋆ ⊗ id⟷)\n unitiar⋆⇔ : {t₁ t₂ : U} → (uniti⋆ {t₁} ⊗ id⟷ {t₂}) ⇔ (uniti⋆ ◎ assocl⋆)\n swapl⋆⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} → \n (swap⋆ ◎ (c₁ ⊗ c₂)) ⇔ ((c₂ ⊗ c₁) ◎ swap⋆)\n swapr⋆⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} → \n ((c₂ ⊗ c₁) ◎ swap⋆) ⇔ (swap⋆ ◎ (c₁ ⊗ c₂))\n swapfl⋆⇔ : {t₁ t₂ t₃ : U} → \n (swap₊ {TIMES t₂ t₃} {TIMES t₁ t₃} ◎ factor) ⇔ \n (factor ◎ (swap₊ {t₂} {t₁} ⊗ id⟷))\n swapfr⋆⇔ : {t₁ t₂ t₃ : U} → \n (factor ◎ (swap₊ {t₂} {t₁} ⊗ id⟷)) ⇔ \n (swap₊ {TIMES t₂ t₃} {TIMES t₁ t₃} ◎ factor)\n id⇔ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ c\n trans⇔ : {t₁ t₂ : U} {c₁ c₂ c₃ : t₁ ⟷ t₂} → \n (c₁ ⇔ c₂) → (c₂ ⇔ c₃) → (c₁ ⇔ c₃)\n resp◎⇔ : {t₁ t₂ t₃ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₁ ⟷ t₂} {c₄ : t₂ ⟷ t₃} → \n (c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ◎ c₂) ⇔ (c₃ ◎ c₄)\n resp⊕⇔ : {t₁ t₂ t₃ t₄ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₁ ⟷ t₂} {c₄ : t₃ ⟷ t₄} → \n (c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ⊕ c₂) ⇔ (c₃ ⊕ c₄)\n resp⊗⇔ : {t₁ t₂ t₃ t₄ : U} \n {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₁ ⟷ t₂} {c₄ : t₃ ⟷ t₄} → \n (c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ⊗ c₂) ⇔ (c₃ ⊗ c₄)\n\n-- better syntax for writing 2paths\n\ninfix 2 _▤ \ninfixr 2 _⇔⟨_⟩_ \n\n_⇔⟨_⟩_ : {t₁ t₂ : U} (c₁ : t₁ ⟷ t₂) {c₂ : t₁ ⟷ t₂} {c₃ : t₁ ⟷ t₂} → \n (c₁ ⇔ c₂) → (c₂ ⇔ c₃) → (c₁ ⇔ c₃)\n_ ⇔⟨ α ⟩ β = trans⇔ α β\n\n_▤ : {t₁ t₂ : U} → (c : t₁ ⟷ t₂) → (c ⇔ c)\n_▤ c = id⇔\n\n-- Inverses for 2paths\n\n2! : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ⇔ c₂) → (c₂ ⇔ c₁)\n2! assoc◎l = assoc◎r\n2! assoc◎r = assoc◎l\n2! assoc⊕l = assoc⊕r\n2! assoc⊕r = assoc⊕l\n2! assoc⊗l = assoc⊗r\n2! assoc⊗r = assoc⊗l\n2! dist⇔ = factor⇔ \n2! factor⇔ = dist⇔\n2! idl◎l = idl◎r\n2! idl◎r = idl◎l\n2! idr◎l = idr◎r\n2! idr◎r = idr◎l\n2! linv◎l = linv◎r\n2! linv◎r = linv◎l\n2! rinv◎l = rinv◎r\n2! rinv◎r = rinv◎l\n2! unitel₊⇔ = uniter₊⇔\n2! uniter₊⇔ = unitel₊⇔\n2! unitil₊⇔ = unitir₊⇔\n2! unitir₊⇔ = unitil₊⇔\n2! swapl₊⇔ = swapr₊⇔\n2! swapr₊⇔ = swapl₊⇔\n2! unitial₊⇔ = unitiar₊⇔ \n2! unitiar₊⇔ = unitial₊⇔ \n2! unitel⋆⇔ = uniter⋆⇔\n2! uniter⋆⇔ = unitel⋆⇔\n2! unitil⋆⇔ = unitir⋆⇔\n2! unitir⋆⇔ = unitil⋆⇔\n2! unitial⋆⇔ = unitiar⋆⇔ \n2! unitiar⋆⇔ = unitial⋆⇔ \n2! swapl⋆⇔ = swapr⋆⇔\n2! swapr⋆⇔ = swapl⋆⇔\n2! swapfl⋆⇔ = swapfr⋆⇔\n2! swapfr⋆⇔ = swapfl⋆⇔\n2! id⇔ = id⇔\n2! (trans⇔ α β) = trans⇔ (2! β) (2! α)\n2! (resp◎⇔ α β) = resp◎⇔ (2! α) (2! β)\n2! (resp⊕⇔ α β) = resp⊕⇔ (2! α) (2! β)\n2! (resp⊗⇔ α β) = resp⊗⇔ (2! α) (2! β) \n\n-- a nice example of 2 paths\n\nnegEx : neg₅ ⇔ neg₁\nnegEx = uniti⋆ ◎ (swap⋆ ◎ ((swap₊ ⊗ id⟷) ◎ (swap⋆ ◎ unite⋆)))\n ⇔⟨ resp◎⇔ id⇔ assoc◎l ⟩\n uniti⋆ ◎ ((swap⋆ ◎ (swap₊ ⊗ id⟷)) ◎ (swap⋆ ◎ unite⋆))\n ⇔⟨ resp◎⇔ id⇔ (resp◎⇔ swapl⋆⇔ id⇔) ⟩\n uniti⋆ ◎ (((id⟷ ⊗ swap₊) ◎ swap⋆) ◎ (swap⋆ ◎ unite⋆))\n ⇔⟨ resp◎⇔ id⇔ assoc◎r ⟩\n uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ (swap⋆ ◎ (swap⋆ ◎ unite⋆)))\n ⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ assoc◎l) ⟩\n uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ ((swap⋆ ◎ swap⋆) ◎ unite⋆))\n ⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ (resp◎⇔ linv◎l id⇔)) ⟩\n uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ (id⟷ ◎ unite⋆))\n ⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ idl◎l) ⟩\n uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ unite⋆)\n ⇔⟨ assoc◎l ⟩\n (uniti⋆ ◎ (id⟷ ⊗ swap₊)) ◎ unite⋆\n ⇔⟨ resp◎⇔ unitil⋆⇔ id⇔ ⟩\n (swap₊ ◎ uniti⋆) ◎ unite⋆\n ⇔⟨ assoc◎r ⟩\n swap₊ ◎ (uniti⋆ ◎ unite⋆)\n ⇔⟨ resp◎⇔ id⇔ linv◎l ⟩\n swap₊ ◎ id⟷\n ⇔⟨ idr◎l ⟩\n swap₊ ▤\n\n-- The equivalence ⇔ of paths is rich enough to make U a 1groupoid:\n-- the points are types (t : U); the 1paths are ⟷; and the 2paths\n-- between them are based on the simplification rules ⇔ \n\nG' : 1Groupoid\nG' = record\n { set = U\n ; _↝_ = _⟷_\n ; _≈_ = _⇔_\n ; id = id⟷\n ; _∘_ = λ p q → q ◎ p\n ; _⁻¹ = !\n ; lneutr = λ _ → idr◎l\n ; rneutr = λ _ → idl◎l\n ; assoc = λ _ _ _ → assoc◎l\n ; equiv = record { \n refl = id⇔\n ; sym = 2!\n ; trans = trans⇔\n }\n ; linv = λ {t₁} {t₂} α → linv◎l\n ; rinv = λ {t₁} {t₂} α → rinv◎l\n ; ∘-resp-≈ = λ p∼q r∼s → resp◎⇔ r∼s p∼q \n }\n\n------------------------------------------------------------------------------\n-- Soundness and completeness\n-- \n-- Proof of soundness and completeness: now we want to verify that ⇔\n-- is sound and complete with respect to ∼. The statement to prove is\n-- that for all c₁ and c₂, we have c₁ ∼ c₂ iff c₁ ⇔ c₂\n\npostulate -- to do eventually but should be fairly easy\n soundnessP : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ⇔ c₂) → (c₁ ∼ c₂)\n\n-- postulate -- proved below\n-- completenessP : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₁ ⇔ c₂)\n\n-- The idea is to invert evaluation and use that to extract from each\n-- extensional representation of a combinator, a canonical syntactic\n-- representative\n\npostulate\n invertP : {t₁ t₂ : U} → (⟦ t₁ ⟧ → ⟦ t₂ ⟧) → (t₁ ⟷ t₂)\n\ncanonical : {t₁ t₂ : U} → (t₁ ⟷ t₂) → (t₁ ⟷ t₂)\ncanonical c = invertP (ap c)\n\n-- Note that if c₁ ⇔ c₂, then by soundness c₁ ∼ c₂ and hence their\n-- canonical representatives are identical. \n\ncanonicalWellDefined : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → \n (c₁ ⇔ c₂) → (canonical c₁ ≡ canonical c₂)\ncanonicalWellDefined {t₁} {t₂} {c₁} {c₂} α = \n cong invertP (ext2id {t₁} {t₂} {c₁} {c₂} (soundnessP α))\n\n-- If we can prove that every combinator is equal to its normal form\n-- then we can prove completeness.\n\npostulate \n inversionP : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ canonical c\n\nresp≡⇔ : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ≡ c₂) → (c₁ ⇔ c₂)\nresp≡⇔ {t₁} {t₂} {c₁} {c₂} p rewrite p = id⇔ \n\ncompleteness : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₁ ⇔ c₂)\ncompleteness {t₁} {t₂} {c₁} {c₂} c₁∼c₂ = \n c₁\n ⇔⟨ inversionP ⟩\n canonical c₁\n ⇔⟨ resp≡⇔ (cong invertP (ext2id {t₁} {t₂} {c₁} {c₂} c₁∼c₂)) ⟩\n canonical c₂\n ⇔⟨ 2! inversionP ⟩\n c₂ ▤\n\n-- To summarize, completeness can be proved if we can define the following\n-- two functions:\n-- \n-- * a function that extracts a canonical combinator out of the \n-- semantic representation of a permutation:\n-- invertP : {t₁ t₂ : U} → (⟦ t₁ ⟧ → ⟦ t₂ ⟧) → (t₁ ⟷ t₂)\n-- * a function that proves that every combinator can be rewritten to this\n-- canonical form:\n-- inversionP : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ canonical c\n--\n-- This all uses function extensionality. It is possible to get rid of \n-- that if we use an accurate representation of permutations.\n\n------------------------------------------------------------------------------\n", "meta": {"hexsha": "db32387d4ac09d9deee83452ab34304995cd78ad", "size": 24313, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Univalence/Pifextensional.agda", "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_issues_repo_path": "Univalence/Pifextensional.agda", "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_forks_repo_path": "Univalence/Pifextensional.agda", "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "avg_line_length": 34.6833095578, "max_line_length": 78, "alphanum_fraction": 0.476699708, "num_tokens": 12342, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619220634456, "lm_q2_score": 0.7520125793176222, "lm_q1q2_score": 0.6200057365600962}} {"text": "{-# OPTIONS --show-implicit #-}\n\nmodule AgdaFeatureTerminationViaExplicitness where\n\ndata Nat : Set where\n zero : Nat\n suc : (n : Nat) → Nat\n\nid : {A : Set} → A → A\nid = λ x → x\n\ndata Pat (n : Nat) : Set where\n pzero : Pat n\n psuc : Pat n → Pat n\n\ndata Cat : Nat → Set where\n cat : ∀ {n} → Cat (suc n)\n\npostulate\n up : ∀ {n} → (Cat n → Cat n) → Cat (suc n)\n down : ∀ {n} → Cat (suc n) → Cat n\n rectify-works : ∀ {x y} → Pat x → Pat y\n rectify-fails : ∀ {x y} → Pat x → Pat (id y)\n\ntest-works1 : ∀ {n} → Pat n → Cat n → Cat n\ntest-works1 (psuc t) acc = down (up (test-works1 t))\ntest-works1 t cat = up (test-works1 (rectify-works t))\n\n{-# TERMINATING #-}\ntest-fails2 : ∀ {n} → Pat n → Cat n → Cat n\ntest-fails2 (psuc t) acc = down (up (test-fails2 t))\ntest-fails2 t cat = up (test-fails2 (rectify-fails t))\n\ntest-works3 : ∀ {n} → Pat n → Cat n → Cat n\ntest-works3 (psuc t) cat = down (up (test-works3 t))\ntest-works3 t@pzero (cat {n = n}) = up (test-works3 {n = n} (rectify-fails t))\n", "meta": {"hexsha": "f15399ce784adc45a8d4c655f7f93cef516a65d7", "size": 993, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-3/src/AgdaFeatureTerminationViaExplicitness.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-3/src/AgdaFeatureTerminationViaExplicitness.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-3/src/AgdaFeatureTerminationViaExplicitness.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.8378378378, "max_line_length": 78, "alphanum_fraction": 0.5850956697, "num_tokens": 389, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026618464795, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.6198806732862835}} {"text": "module InstanceMeta where\n\ndata Bool : Set where\n true false : Bool\n\ndata Maybe (A : Set) : Set where\n Nothing : Maybe A\n Just : A → Maybe A\n\nrecord Eq (A : Set) : Set where\n constructor eq\n field\n _==_ : A → A → Bool\nopen Eq {{...}} public\n\ninstance\n eq-Bool : Eq Bool\n eq-Bool = eq aux where\n\n aux : Bool → Bool → Bool\n aux true true = true\n aux false false = true\n aux _ _ = false\n\n eq-Maybe : {A : Set} {{_ : Eq A}} → Eq (Maybe A)\n eq-Maybe {A} = eq aux where\n\n aux : Maybe A → Maybe A → Bool\n aux Nothing Nothing = true\n aux (Just y) (Just z) = (y == z)\n aux _ _ = false\n\ntest : Bool\ntest = {!!} == {!!}\n-- This should not loop, only produce unsolved metas\n", "meta": {"hexsha": "b71396b035fd8146a89bb09f39f98d1557e634c2", "size": 700, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/InstanceMeta.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Fail/InstanceMeta.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Fail/InstanceMeta.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 19.4444444444, "max_line_length": 52, "alphanum_fraction": 0.5814285714, "num_tokens": 228, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9219218348550491, "lm_q2_score": 0.6723316860482763, "lm_q1q2_score": 0.6198372616328157}} {"text": "module Categories.SubCategory where\n\nopen import Categories.Category\nopen import Data.Product\n\nsub-category : ∀ {o ℓ e o′ ℓ′} -> (C : Category o ℓ e) -> let module C = Category C in \n {A : Set o′} (U : A -> C.Obj) (R : ∀ {a b} -> U a C.⇒ U b -> Set ℓ′) -> \n (∀ {a} -> R (C.id {U a})) -> (∀ {a b c} {f : U b C.⇒ U c} {g : U a C.⇒ U b} -> R f -> R g -> R (f C.∘ g)) →\n Category _ _ _\nsub-category C {A} U R Rid R∘ = record \n { Obj = A\n ; _⇒_ = λ a b → Σ (U a C.⇒ U b) R\n ; _≡_ = λ f g → proj₁ f C.≡ proj₁ g\n ; id = C.id , Rid\n ; _∘_ = λ f g → (proj₁ f C.∘ proj₁ g) , R∘ (proj₂ f) (proj₂ g)\n ; assoc = C.assoc\n ; identityˡ = C.identityˡ\n ; identityʳ = C.identityʳ\n ; equiv = record \n { refl = C.Equiv.refl\n ; sym = C.Equiv.sym\n ; trans = C.Equiv.trans \n }\n ; ∘-resp-≡ = C.∘-resp-≡ \n }\n where\n module C = Category C\n", "meta": {"hexsha": "8364da7e9f0e6e8711655444b841ae45eb305ce8", "size": 891, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/SubCategory.agda", "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 98, "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_issues_repo_path": "Categories/SubCategory.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_forks_repo_path": "Categories/SubCategory.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 23, "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "avg_line_length": 31.8214285714, "max_line_length": 122, "alphanum_fraction": 0.4758698092, "num_tokens": 378, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9314625012602593, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.6198049772348824}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Structures for homogeneous binary relations\n------------------------------------------------------------------------\n\n-- The contents of this module should be accessed via `Relation.Binary`.\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary.Core\n\nmodule Relation.Binary.Structures\n {a ℓ} {A : Set a} -- The underlying set\n (_≈_ : Rel A ℓ) -- The underlying equality relation\n where\n\nopen import Data.Product using (proj₁; proj₂; _,_)\nopen import Level using (Level; _⊔_)\nopen import Relation.Nullary using (¬_)\nopen import Relation.Binary.PropositionalEquality.Core as P using (_≡_)\nopen import Relation.Binary.Consequences\nopen import Relation.Binary.Definitions\n\nprivate\n variable\n ℓ₂ : Level\n\n------------------------------------------------------------------------\n-- Equivalences\n------------------------------------------------------------------------\n-- Note all the following equivalences refer to the equality provided\n-- as a module parameter at the top of this file.\n\nrecord IsPartialEquivalence : Set (a ⊔ ℓ) where\n field\n sym : Symmetric _≈_\n trans : Transitive _≈_\n\n-- The preorders of this library are defined in terms of an underlying\n-- equivalence relation, and hence equivalence relations are not\n-- defined in terms of preorders.\n\n-- To preserve backwards compatability, equivalence relations are\n-- not defined in terms of their partial counterparts.\n\nrecord IsEquivalence : Set (a ⊔ ℓ) where\n field\n refl : Reflexive _≈_\n sym : Symmetric _≈_\n trans : Transitive _≈_\n\n reflexive : _≡_ ⇒ _≈_\n reflexive P.refl = refl\n\n isPartialEquivalence : IsPartialEquivalence\n isPartialEquivalence = record\n { sym = sym\n ; trans = trans\n }\n\n\nrecord IsDecEquivalence : Set (a ⊔ ℓ) where\n infix 4 _≟_\n field\n isEquivalence : IsEquivalence\n _≟_ : Decidable _≈_\n\n open IsEquivalence isEquivalence public\n\n\n------------------------------------------------------------------------\n-- Preorders\n------------------------------------------------------------------------\n\nrecord IsPreorder (_∼_ : Rel A ℓ₂) : Set (a ⊔ ℓ ⊔ ℓ₂) where\n field\n isEquivalence : IsEquivalence\n -- Reflexivity is expressed in terms of the underlying equality:\n reflexive : _≈_ ⇒ _∼_\n trans : Transitive _∼_\n\n module Eq = IsEquivalence isEquivalence\n\n refl : Reflexive _∼_\n refl = reflexive Eq.refl\n\n ∼-respˡ-≈ : _∼_ Respectsˡ _≈_\n ∼-respˡ-≈ x≈y x∼z = trans (reflexive (Eq.sym x≈y)) x∼z\n\n ∼-respʳ-≈ : _∼_ Respectsʳ _≈_\n ∼-respʳ-≈ x≈y z∼x = trans z∼x (reflexive x≈y)\n\n ∼-resp-≈ : _∼_ Respects₂ _≈_\n ∼-resp-≈ = ∼-respʳ-≈ , ∼-respˡ-≈\n\n------------------------------------------------------------------------\n-- Partial orders\n------------------------------------------------------------------------\n\nrecord IsPartialOrder (_≤_ : Rel A ℓ₂) : Set (a ⊔ ℓ ⊔ ℓ₂) where\n field\n isPreorder : IsPreorder _≤_\n antisym : Antisymmetric _≈_ _≤_\n\n open IsPreorder isPreorder public\n renaming\n ( ∼-respˡ-≈ to ≤-respˡ-≈\n ; ∼-respʳ-≈ to ≤-respʳ-≈\n ; ∼-resp-≈ to ≤-resp-≈\n )\n\n\nrecord IsDecPartialOrder (_≤_ : Rel A ℓ₂) : Set (a ⊔ ℓ ⊔ ℓ₂) where\n infix 4 _≟_ _≤?_\n field\n isPartialOrder : IsPartialOrder _≤_\n _≟_ : Decidable _≈_\n _≤?_ : Decidable _≤_\n\n open IsPartialOrder isPartialOrder public\n hiding (module Eq)\n\n module Eq where\n\n isDecEquivalence : IsDecEquivalence\n isDecEquivalence = record\n { isEquivalence = isEquivalence\n ; _≟_ = _≟_\n }\n\n open IsDecEquivalence isDecEquivalence public\n\n\nrecord IsStrictPartialOrder (_<_ : Rel A ℓ₂) : Set (a ⊔ ℓ ⊔ ℓ₂) where\n field\n isEquivalence : IsEquivalence\n irrefl : Irreflexive _≈_ _<_\n trans : Transitive _<_\n <-resp-≈ : _<_ Respects₂ _≈_\n\n module Eq = IsEquivalence isEquivalence\n\n asym : Asymmetric _<_\n asym {x} {y} = trans∧irr⟶asym Eq.refl trans irrefl {x = x} {y}\n\n <-respʳ-≈ : _<_ Respectsʳ _≈_\n <-respʳ-≈ = proj₁ <-resp-≈\n\n <-respˡ-≈ : _<_ Respectsˡ _≈_\n <-respˡ-≈ = proj₂ <-resp-≈\n\n asymmetric = asym\n {-# WARNING_ON_USAGE asymmetric\n \"Warning: asymmetric was deprecated in v0.16.\n Please use asym instead.\"\n #-}\n\n\nrecord IsDecStrictPartialOrder (_<_ : Rel A ℓ₂) : Set (a ⊔ ℓ ⊔ ℓ₂) where\n infix 4 _≟_ _ runMaybeT m\n\n FunctorZeroMaybeT : {{_ : Monad M}} → FunctorZero {a = a} (MaybeT M)\n runMaybeT (empty {{FunctorZeroMaybeT}}) = return nothing\n\n AlternativeMaybeT : {{_ : Monad M}} → Alternative {a = a} (MaybeT M)\n runMaybeT (_<|>_ {{AlternativeMaybeT {{monadM}}}} mx my) = do\n just x ← runMaybeT mx\n where nothing → runMaybeT my\n return (just x)\n\n module _ {{_ : Monad M}} where\n\n private\n bindMaybeT : ∀ {A B} → MaybeT M A → (A → MaybeT M B) → MaybeT M B\n runMaybeT (bindMaybeT m f) = do\n just x ← runMaybeT m\n where nothing → return nothing\n runMaybeT (f x)\n\n instance\n ApplicativeMaybeT : Applicative {a = a} (MaybeT M)\n runMaybeT (pure {{ApplicativeMaybeT}} x) = pure (just x)\n _<*>_ {{ApplicativeMaybeT}} = monadAp bindMaybeT\n\n MonadMaybeT : Monad {a = a} (MaybeT M)\n _>>=_ {{MonadMaybeT}} = bindMaybeT\n\n liftMaybeT : {A : Set a} → M A → MaybeT M A\n runMaybeT (liftMaybeT m) = just <$> m\n\ninstance\n TransformerMaybeT : ∀ {a} → Transformer {a} MaybeT\n lift {{TransformerMaybeT}} = liftMaybeT\n", "meta": {"hexsha": "8e6b1bd8c3c04f29413692efedc0e381189beb14", "size": 1553, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Control/Monad/Maybe.agda", "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 111, "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_issues_repo_path": "src/Control/Monad/Maybe.agda", "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_forks_repo_path": "src/Control/Monad/Maybe.agda", "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "avg_line_length": 29.3018867925, "max_line_length": 72, "alphanum_fraction": 0.6252414681, "num_tokens": 498, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314647623016, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.619281711613213}} {"text": "module Numeral.Natural.Oper.DivMod.Proofs where\n\nimport Lvl\nopen import Data\nopen import Data.Boolean.Stmt\nopen import Logic.Predicate\nopen import Numeral.Finite\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.Oper.Comparisons\nopen import Numeral.Natural.Oper.FlooredDivision\nopen import Numeral.Natural.Oper.FlooredDivision.Proofs.DivisibilityWithRemainder\nopen import Numeral.Natural.Oper.Modulo\nopen import Numeral.Natural.Oper.Modulo.Proofs.DivisibilityWithRemainder\nopen import Numeral.Natural.Oper.Proofs\nopen import Numeral.Natural.Relation.DivisibilityWithRemainder\nopen import Numeral.Natural.Relation.DivisibilityWithRemainder.Proofs\nopen import Relator.Equals\nopen import Relator.Equals.Proofs\nopen import Structure.Operator\nopen import Structure.Operator.Proofs.Util\nopen import Structure.Operator.Properties\nopen import Syntax.Transitivity\n\n-- The division theorem.\n[⌊/⌋][mod]-is-division-with-remainder : ∀{x y} → (((x ⌊/⌋ 𝐒(y)) ⋅ 𝐒(y)) + (x mod 𝐒(y)) ≡ x)\n[⌊/⌋][mod]-is-division-with-remainder {x}{y} with [∃]-intro r ⦃ p ⦄ ← [∣ᵣₑₘ]-existence-alt {x}{y} =\n ((x ⌊/⌋ 𝐒(y)) ⋅ 𝐒(y)) + (x mod 𝐒(y)) 🝖[ _≡_ ]-[ congruence₂(_+_) (congruence₂ₗ(_⋅_)(𝐒(y)) ([⌊/⌋][∣ᵣₑₘ]-quotient-equality {x}{y}{r}{p})) ([mod][∣ᵣₑₘ]-remainder-equality {x}{y}{r}{p}) ]\n (([∣ᵣₑₘ]-quotient p) ⋅ 𝐒(y)) + (𝕟-to-ℕ ([∣ᵣₑₘ]-remainder p)) 🝖[ _≡_ ]-[ [∣ᵣₑₘ]-is-division-with-remainder {x}{𝐒(y)}{r} p ]\n x 🝖-end\n\n[⌊/⌋][mod]-is-division-with-remainder-pred-commuted : ∀{x y} ⦃ _ : IsTrue(positive?(y)) ⦄ → ((y ⋅ (x ⌊/⌋ y)) + (x mod y) ≡ x)\n[⌊/⌋][mod]-is-division-with-remainder-pred-commuted {x} {𝐒 y} = [≡]-with(_+ (x mod 𝐒(y))) (commutativity(_⋅_) {𝐒(y)}{x ⌊/⌋ 𝐒(y)}) 🝖 [⌊/⌋][mod]-is-division-with-remainder {x}{y}\n\n-- Floored division and multiplication is not inverse operators for all numbers.\n-- This shows why it is not exactly.\n[⌊/⌋][⋅]-semiInverseOperatorᵣ : ∀{a b} → ((a ⌊/⌋ 𝐒(b)) ⋅ 𝐒(b) ≡ a −₀ (a mod 𝐒(b)))\n[⌊/⌋][⋅]-semiInverseOperatorᵣ {a}{b} =\n (a ⌊/⌋ 𝐒(b)) ⋅ 𝐒(b) 🝖[ _≡_ ]-[ OneTypeTwoOp.moveᵣ-to-invOp {b = a mod 𝐒(b)}{c = a} (([⌊/⌋][mod]-is-division-with-remainder {y = b})) ]\n a −₀ (a mod 𝐒(b)) 🝖-end\n\n-- Floored division and multiplication is not inverse operators for all numbers.\n-- This theorem shows that modulo is the error term (difference between the actual value for it to be inverse and value of the operation).\n[⌊/⌋][⋅]-inverseOperatorᵣ-error : ∀{a b} → (a mod 𝐒(b) ≡ a −₀ (a ⌊/⌋ 𝐒(b) ⋅ 𝐒(b)))\n[⌊/⌋][⋅]-inverseOperatorᵣ-error {a}{b} =\n (a mod 𝐒(b)) 🝖[ _≡_ ]-[ OneTypeTwoOp.moveᵣ-to-invOp {a = a mod 𝐒(b)}{b = (a ⌊/⌋ 𝐒(b)) ⋅ 𝐒(b)}{c = a} (commutativity(_+_) {a mod 𝐒(b)}{(a ⌊/⌋ 𝐒(b)) ⋅ 𝐒(b)} 🝖 [⌊/⌋][mod]-is-division-with-remainder {y = b}) ]\n a −₀ (a ⌊/⌋ 𝐒(b) ⋅ 𝐒(b)) 🝖-end\n", "meta": {"hexsha": "c8e6532287da60d411a339ae80f5f911b75079bb", "size": 2824, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Oper/DivMod/Proofs.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Oper/DivMod/Proofs.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Oper/DivMod/Proofs.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 58.8333333333, "max_line_length": 219, "alphanum_fraction": 0.6338526912, "num_tokens": 1235, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382129861583, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.6190965340294474}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Convenient syntax for reasoning with a partial setoid\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary\n\nmodule Relation.Binary.Reasoning.PartialSetoid\n {s₁ s₂} (S : PartialSetoid s₁ s₂) where\n\nopen PartialSetoid S\nimport Relation.Binary.Reasoning.Base.Partial _≈_ trans as Base\n\n------------------------------------------------------------------------\n-- Re-export the contents of the base module\n\nopen Base public\n hiding (step-∼)\n\n------------------------------------------------------------------------\n-- Additional reasoning combinators\n\ninfixr 2 step-≈ step-≈˘\n\n-- A step using an equality\n\nstep-≈ = Base.step-∼\nsyntax step-≈ x y≈z x≈y = x ≈⟨ x≈y ⟩ y≈z\n\n-- A step using a symmetric equality\n\nstep-≈˘ : ∀ x {y z} → y IsRelatedTo z → y ≈ x → x IsRelatedTo z\nstep-≈˘ x y∼z y≈x = x ≈⟨ sym y≈x ⟩ y∼z\nsyntax step-≈˘ x y≈z y≈x = x ≈˘⟨ y≈x ⟩ y≈z\n", "meta": {"hexsha": "be686b19ea8b4f1eda398dab940dd037d9d6fae8", "size": 1043, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Relation/Binary/Reasoning/PartialSetoid.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Relation/Binary/Reasoning/PartialSetoid.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Relation/Binary/Reasoning/PartialSetoid.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 27.4473684211, "max_line_length": 72, "alphanum_fraction": 0.4851390221, "num_tokens": 294, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.86153820232079, "lm_q2_score": 0.7185943925708561, "lm_q1q2_score": 0.6190965211732955}} {"text": "\nmodule Lattice where\n\nopen import Prelude\nopen import PartialOrder as PO\nopen import SemiLattice as SL\nimport Chain\nopen POrder using (Dual)\n\nrecord Lattice (A : Set) : Set1 where\n field\n sl : SemiLattice A\n _⊔_ : A -> A -> A\n prf : IsSemiLattice (Dual (SemiLat.po sl)) _⊔_\n\nmodule Lat {A : Set}(L : Lattice A) where\n\n private\n module LL = Lattice L\n module SLL = SemiLat LL.sl\n\n private\n sl' : SemiLattice A\n sl' = record { po = Dual SLL.po; _⊓_ = LL._⊔_; prf = LL.prf }\n\n module SLL' = SemiLat sl'\n hiding ( Monotone\n ; Antitone\n ; _==_; ==-refl; ==-sym; ==-trans\n ; po\n )\n renaming ( _≤_ to _≥_\n ; ≤-refl to ≥-refl\n ; ≤-trans to ≥-trans\n ; ≤-antisym to ≥-antisym\n ; ==≤-L to ==≥-R\n ; ==≤-R to ==≥-L\n ; _⊓_ to _⊔_\n ; ⊓-lbL to ⊔-ubL\n ; ⊓-lbR to ⊔-ubR\n ; ⊓-glb to ⊔-lub\n ; ⊓-commute to ⊔-commute\n ; ⊓-assoc to ⊔-assoc\n ; ⊓-idem to ⊔-idem\n ; ≤⊓-L to ≥⊔-L\n ; ≤⊓-R to ≥⊔-R\n ; ⊓-monotone-R to ⊔-monotone-R\n ; ⊓-monotone-L to ⊔-monotone-L\n ; ≤⊓-compat to ≥⊔-compat\n ; ⊓-cong to ⊔-cong\n ; ⊓-cong-L to ⊔-cong-L\n ; ⊓-cong-R to ⊔-cong-R\n )\n\n open SLL public\n open SLL' public\n\n DualLattice : Lattice A\n DualLattice = record { sl = sl'; _⊔_ = _⊓_; prf = SemiLattice.prf LL.sl }\n\nmodule MeetJoin {A : Set}(L : Lattice A) where \n\n private module L = Lat L\n open L\n\n open module C== = Chain _==_ (\\x -> ==-refl) (\\x y z -> ==-trans)\n\n -- Experiment with very explicit proof\n ⊓⊔-absorb-LL = \\{x y} ->\n (x ⊓ (x ⊔ y)) == x from\n ≤-antisym\n ((x ⊓ (x ⊔ y)) ≤ x from ⊓-lbL)\n (x ≤ (x ⊓ (x ⊔ y)) from\n ⊓-glb (x ≤ x from ≤-refl)\n (x ≤ (x ⊔ y) from ⊔-ubL)\n )\n\n ⊓⊔-eq : forall {x y} -> (x ⊓ y) == (x ⊔ y) -> x == y\n ⊓⊔-eq {x}{y} p =\n chain> x\n === x ⊓ (x ⊔ y) by ==-sym ⊓⊔-absorb-LL\n === x ⊓ (x ⊓ y) by ==-sym (⊓-cong-R p)\n === (x ⊓ x) ⊓ y by {!!} -- ⊓-assoc\n === x ⊓ y by ⊓-cong-L ⊓-idem\n === y ⊓ x by ⊓-commute\n === (y ⊓ y) ⊓ x by ⊓-cong-L (==-sym ⊓-idem)\n === y ⊓ (y ⊓ x) by ==-sym ⊓-assoc\n === y ⊓ (x ⊓ y) by ⊓-cong-R ⊓-commute\n === y ⊓ (x ⊔ y) by {! !} -- ⊓-cong-R p\n === y ⊓ (y ⊔ x) by ⊓-cong-R ⊔-commute\n === y by ⊓⊔-absorb-LL\n\nmodule JoinMeet {A : Set}(L : Lattice A) =\n MeetJoin (Lat.DualLattice L)\n hiding (⊓⊔-eq)\n renaming (⊓⊔-absorb-LL to ⊔⊓-absorb-LL)\n", "meta": {"hexsha": "6d9aa14c5e011d56c1249b3ac8e9e12cc60e1585", "size": 2818, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/lattice/Lattice.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/lattice/Lattice.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/lattice/Lattice.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.0515463918, "max_line_length": 75, "alphanum_fraction": 0.4041873669, "num_tokens": 1134, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681158979307, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.619088310228022}} {"text": "-- We show by allowing the reminder of integer division to be\n-- negative, we can get more precise estimation of the rank of the\n-- remainder: rank reminder ≤ (rank divisor) / 2.\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Integer.EucDomain2 where\n\n-- ----------------------------------------------------------------------\n-- ℕ is an \"Euclidean SemiRing\".\nmodule NatESR where\n -- ℕ satisfy the euc-eq and euc-rank property with the usual div and\n -- mod function. Still we need to do the translation from non-equality\n -- to NonZero predicate.\n\n -- imports form stdlib.\n open import Relation.Nullary using (¬_)\n open import Relation.Binary.PropositionalEquality using (_≡_ ; refl)\n \n open import Data.Nat as Nat using (ℕ ; zero ; suc)\n\n import Data.Nat.DivMod as NDM\n import Data.Nat.Properties as NatP\n\n -- imports from local.\n open import Instances\n \n -- We already make ℕ an instance of Rank. For convinence we restate it\n -- here.\n rank' : ℕ -> ℕ\n rank' x = x\n\n -- Division with the annoying translation from ¬ d ≡ 0 to NonZero\n -- predicate.\n div : ∀ (n d : ℕ) -> ¬ d ≡ 0 -> ℕ\n div n zero n0 with n0 refl\n ... | ()\n div n (suc d) n0 = NDM._/_ n (suc d)\n\n -- Reminder.\n mod : ∀ (n d : ℕ) -> ¬ d ≡ 0 -> ℕ\n mod n zero n0 with n0 refl\n ... | ()\n mod n (suc d) n0 = NDM._%_ n (suc d)\n\n -- Dividend = reminder + quotient * divisor.\n euc-eq : ∀ (n d : ℕ) (n0 : ¬ d ≡ 0) ->\n let r = mod n d n0 in let q = div n d n0 in \n n ≡ r + q * d \n euc-eq n zero n0 with n0 refl\n ... | () \n euc-eq n (suc d) n0 = NDM.m≡m%n+[m/n]*n n (suc d)\n\n -- rank reminder < rank divisor.\n euc-rank : ∀ (n d : ℕ) (n0 : ¬ d ≡ 0) ->\n let r = mod n d n0 in let q = div n d n0 in \n rank r < rank d\n euc-rank n zero n0 with n0 refl\n ... | () \n euc-rank n (suc d) n0 = NDM.m%n 0, an easy calculation shows if ∣ r ∣ ≤ ∣ d ∣\n-- / 2, we let q' = q and r' = r, and if ∣ r ∣ > ∣ d ∣ / 2, we let q'\n-- = q + 1 and r' = r - d. The case when d < 0 is similar. \n\n-- imports from stdlib.\nopen import Relation.Nullary using (yes ; no ; ¬_)\nopen import Relation.Binary.PropositionalEquality as PE\n using (_≡_ ; refl ; sym ; cong ; trans)\n\nopen import Data.Empty using (⊥-elim)\nopen import Data.Sum using (_⊎_ ; inj₁ ; inj₂)\nopen import Data.Bool using (T ; not)\nopen import Data.Nat as Nat using (ℕ ; suc ; s≤s ; zero ; z≤n)\nimport Data.Nat.DivMod as NDM\nimport Data.Nat.Properties as NatP\nopen import Data.Integer as Int\n using (ℤ ; ∣_∣ ; +_ ; +[1+_] ; -[1+_] ; 1ℤ ; _◃_ ; +<+ ; -<- ; -≤- ; -<+ ; -≤+ ; +≤+ ; 0ℤ)\nimport Data.Integer.Properties as IntP\nopen import Data.Integer.DivMod\n using (_div_ ; _mod_ ; a≡a%n+[a/n]*n ; n%d ¬ d ≡ 0ℤ -> ℤ\ndiv' n (+_ zero) n0 with n0 refl\n... | ()\ndiv' n d@(+[1+ e ]) n0 with n mod d ≤? ∣ d ∣ / 2\n... | yes pr = n div d\n... | no np = 1ℤ + n div d\ndiv' n d@(-[1+ e ]) n0 with n mod d ≤? ∣ d ∣ / 2\n... | yes pr = n div d\n... | no np = - 1ℤ + n div d\n\n-- Another integer mod allowing negative reminder. \nmod' : ∀ (n d : ℤ) -> ¬ d ≡ 0ℤ -> ℤ\nmod' n (+_ zero) n0 with n0 refl\n... | ()\nmod' n d@(+[1+ e ]) n0 with n mod d ≤? ∣ d ∣ / 2\n... | yes pr = + (n mod d)\n... | no np = + (n mod d) - d\nmod' n d@(-[1+ e ]) n0 with n mod d ≤? ∣ d ∣ / 2\n... | yes pr = + (n mod d)\n... | no np = + (n mod d) + d\n\n-- Dividend = reminder + quotient * divisor.\neuc-eq' : ∀ (n d : ℤ) (n0 : ¬ d ≡ 0ℤ) ->\n let r = mod' n d n0 in let q = div' n d n0 in \n n ≡ r + q * d \neuc-eq' n (+_ zero) n0 with n0 refl\n... | ()\neuc-eq' n d@(+[1+ e ]) n0 with n mod d ≤? ∣ d ∣ / 2\n... | yes pr = a≡a%n+[a/n]*n n d \n... | no np = claim\n where\n claim : n ≡ (+ (n mod d) - d) + (1ℤ + n div d) * d\n claim = begin\n n ≡⟨ a≡a%n+[a/n]*n n d ⟩ \n + (n mod d) + (n div d) * d ≡⟨ solve 3 (\\ x y z -> x :+ y :* z := x :- z :+ (con 1ℤ :+ y) :* z) refl (+ (n mod d)) (n div d) d ⟩ \n (+ (n mod d) - d) + (1ℤ + n div d) * d ∎\n where\n open +-*-Solver\n open PE.≡-Reasoning\neuc-eq' n d@(-[1+ e ]) n0 with n mod d ≤? ∣ d ∣ / 2\n... | yes pr = a≡a%n+[a/n]*n n d \n... | no np = claim \n where\n claim : n ≡ (+ (n mod d) + d) + (- 1ℤ + n div d) * d\n claim = begin\n n ≡⟨ a≡a%n+[a/n]*n n d ⟩ \n + (n mod d) + (n div d) * d ≡⟨ solve 3 (\\ x y z -> x :+ y :* z := x :+ z :+ (con (- 1ℤ) :+ y) :* z) refl (+ (n mod d)) (n div d) d ⟩ \n (+ (n mod d) + d) + (- 1ℤ + n div d) * d ∎\n where\n open +-*-Solver\n open PE.≡-Reasoning\n\n-- rank reminder ≤ (rank divisor) / 2.\neuc-rank' : ∀ (n d : ℤ) (n0 : ¬ d ≡ 0ℤ) ->\n let r = mod' n d n0 in let q = div' n d n0 in \n ∣ r ∣ ≤ ∣ d ∣ / 2\neuc-rank' n (+_ zero) n0 with n0 refl\n... | ()\neuc-rank' n d@(+[1+ e ]) n0 with n mod d ≤? ∣ d ∣ / 2\n... | yes pr = pr \n... | no ¬p = claim \n where\n r = + (n mod d) - d\n\n d≠0 : ¬ ∣ d ∣ ≡ 0\n d≠0 = λ () \n \n -- We follow the steps to show ∣ r ∣ ≤ ∣ d ∣ / 2, in the current case, i.e. ∣\n -- n % d - d ∣ ≤ d / 2. We follows the steps below:\n -- 1) d / 2 < n % d\n -- 2) d / 2 - d < n % d - d\n -- 3) n % d - d < 0, hence d / 2 - d < n % d - d < 0\n -- 4) ∣ d / 2 - d ∣ > ∣ n % d - d ∣\n -- 5) d / 2 - d ≡ - d / 2 or d / 2 - d ≡ - (d / 2 + 1)\n -- 6) ∣ d / 2 - d ∣ ≡ d / 2 or ∣ d / 2 - d ∣ ≡ d / 2 + 1\n -- 7) d / 2 > ∣ n % d - d ∣ or d / 2 + 1 > ∣ n % d - d ∣\n -- 8) d / 2 ≥ ∣ n % d - d ∣\n\n -- By negate ¬p, we can show ∣ d ∣ / 2 < n mod d.\n -- By negation of ¬p (we are using the decidable order).\n open import Relation.Binary using (tri< ; tri≈ ; tri>)\n step1 : ∣ d ∣ / 2 < n mod d\n step1 with NatP.<-cmp (n mod d) (∣ d ∣ / 2)\n ... | tri< a ¬b ¬c = ⊥-elim (¬p (NatP.<⇒≤ a)) \n ... | tri≈ ¬a b ¬c = ⊥-elim (¬p (NatP.≤-reflexive b)) \n ... | tri> ¬a ¬b c = c\n where\n notle : ¬ (n mod d ≤ ∣ d ∣ / 2)\n notle = ¬p\n\n -- Step 2. ∣ d ∣ / 2 - ∣ d ∣ < n mod d - ∣ d ∣. Subtracting ∣ d ∣\n -- from both sides of step1 preserves the inequality.\n step2 : + (∣ d ∣ / 2) - + ∣ d ∣ < + (n mod d) - + ∣ d ∣\n step2 = IntP.+-monoʳ-< (- (+ ∣ d ∣)) (+<+ step1)\n\n -- Step 3. n mod d - ∣ d ∣ < 0\n\n -- Some auxillary. \n n-n=0 : ∀ {n} -> n - n ≡ 0ℤ\n n-n=0 {n} = IntP.+-inverseʳ n\n\n step3 : + (n mod d) - (+ ∣ d ∣) < 0ℤ\n step3 rewrite (sym (n-n=0 {+ ∣ d ∣})) = r-d ∣ n % d - d ∣. By 2, we have\n -- d / 2 - d < n % d - d < 0. By taking absolute values, we show\n -- ∣ d / 2 - d ∣ > ∣ n % d - d ∣.\n\n -- Some lemmas about take absolute value of negative and nonpositive\n -- numbers.\n lemma-∣neg∣ : ∀ {a : ℤ} -> a < 0ℤ -> + ∣ a ∣ ≡ - a\n lemma-∣neg∣ -<+ = refl\n\n lemma-∣non-pos∣ : ∀ {a : ℤ} -> a ≤ 0ℤ -> + ∣ a ∣ ≡ - a\n lemma-∣non-pos∣ {.(-[1+ _ ])} -≤+ = refl\n lemma-∣non-pos∣ {.(+ zero)} (+≤+ z≤n) = refl\n\n -- The injection of natural numbers into integers reflect order.\n lemma-inj-reflect-ord : ∀ {a b} -> + a < + b -> a < b \n lemma-inj-reflect-ord (+<+ m + a ≤ + b -> a ≤ b \n lemma-inj-reflect-ord' (+≤+ m a < 0ℤ -> b < a -> ∣ a ∣ < ∣ b ∣\n lemma-∣neg a * 2 ≡ a + a\n *2+ {zero} = refl\n *2+ {suc a} rewrite *2+ {a} | NatP.+-comm a (suc a) = refl\n\n -- Either d / 2 + d / 2 ≡ d or d / 2 + d / 2 + 1 ≡ d. \n lemma-div-by-2 : ∀ d -> let hd = d / 2 in\n hd + hd ≡ d ⊎ suc (hd + hd) ≡ d \n lemma-div-by-2 d with d / 2 | d % 2 | NatESR.euc-eq d 2 (λ { ()}) | NatESR.euc-rank d 2 (λ { ()})\n ... | hd | zero | proj₁₁ | pr rewrite *2+ {hd} = inj₁ (sym proj₁₁)\n ... | hd | suc zero | proj₁₁ | pr rewrite *2+ {hd} = inj₂ (sym proj₁₁)\n ... | hd | suc (suc r₁) | proj₁₁ | pr = ⊥-elim ((c1 r₁) pr )\n where\n c1 : ∀ a -> ¬ (suc (suc (suc a)) ≤ 2)\n c1 a = λ { (s≤s (s≤s ()))} \n\n -- Next we need inject naturals to integers. We do the two\n -- identities separately.\n\n -- Step 5a. If (d / 2) + (d / 2) ≡ d, we show d / 2 - d ≡ - d / 2.\n step5a : ∀ d -> (d / 2) + (d / 2) ≡ d -> let -_ = λ x -> - (+ x) in\n + (d / 2) - (+ d) ≡ - (d / 2)\n step5a d hyp = sym claim4\n where\n open PE.≡-Reasoning\n claim : + (d / 2 + d / 2) ≡ + d\n claim = cong +_ hyp\n\n claim2 : + (d / 2) + + (d / 2) ≡ + d\n claim2 = begin\n + (d / 2) + + (d / 2) ≡⟨ IntP.pos-+-commute (d / 2) (d / 2) ⟩\n + (d / 2 + d / 2) ≡⟨ cong +_ hyp ⟩\n + d ∎\n\n claim3 : + (d / 2) ≡ + d - + (d / 2)\n claim3 = begin\n + (d / 2) ≡⟨ (solve 1 (λ a -> a := a :+ a :- a) refl) (+ (d / 2)) ⟩\n + (d / 2) + + (d / 2) - + (d / 2) ≡⟨ cong (_- + (d / 2)) claim2 ⟩\n + d - + (d / 2) ∎\n where open +-*-Solver\n\n claim4 : let -_ = λ x -> - (+ x) in\n - (d / 2) ≡ + (d / 2) - + d\n claim4 = begin\n - (+ (d / 2)) ≡⟨ cong -_ claim3 ⟩ \n - (+ d - + (d / 2)) ≡⟨ (solve 2 (λ a b -> :- (a :- b) := b :- a) refl) (+ d) (+ (d / 2)) ⟩\n + (d / 2) - + d ∎\n where open +-*-Solver\n\n -- Step 5b. If (d / 2) + (d / 2) + 1 ≡ d, we show d / 2 - d ≡ - (d\n -- / 2 + 1). (Note that we change the sign of the equality)\n step5b : ∀ d -> suc ((d / 2) + (d / 2)) ≡ d -> let -_ = λ x -> - (+ x) in\n (+ d) - + (d / 2) ≡ + (d / 2) + 1ℤ\n step5b d hyp = begin\n + d - + (d / 2) ≡⟨ cong (λ x → + x - + (d / 2)) (sym hyp) ⟩ \n + (suc (d / 2 + d / 2)) - + (d / 2) ≡⟨ refl ⟩\n + (1 + (d / 2 + d / 2)) - + (d / 2) ≡⟨ cong (_- + (d / 2)) (IntP.pos-+-commute 1 (d / 2 + d / 2)) ⟩\n + 1 + + (d / 2 + d / 2) - + (d / 2) ≡⟨ cong (λ x → + 1 + x - + (d / 2)) (IntP.pos-+-commute (d / 2) (d / 2)) ⟩\n + 1 + + (d / 2) + + (d / 2) - + (d / 2) ≡⟨ solve 1 (λ x → (con 1ℤ) :+ (x :+ x) :- x := x :+ con 1ℤ) refl (+ (d / 2)) ⟩\n + (d / 2) + 1ℤ ∎\n where\n open +-*-Solver\n open PE.≡-Reasoning\n\n -- Goal 5. \n step5 : let -_ = λ x -> - (+ x) in\n + (∣ d ∣ / 2) - d ≡ - (∣ d ∣ / 2) ⊎ d - + (∣ d ∣ / 2) ≡ + (∣ d ∣ / 2) + 1ℤ\n step5 with step5-nat\n ... | inj₁ x = inj₁ (step5a ∣ d ∣ x)\n ... | inj₂ y = inj₂ (step5b ∣ d ∣ y)\n\n\n -- Step 6. ∣ d / 2 - d ∣ ≡ d / 2 or ∣ d / 2 - d ∣ ≡ d / 2 + 1\n step6 : let -_ = λ x -> - (+ x) in\n ∣ + (∣ d ∣ / 2) - d ∣ ≡ ∣ d ∣ / 2 ⊎ ∣ d - + (∣ d ∣ / 2) ∣ ≡ ∣ d ∣ / 2 + 1\n step6 with step5\n ... | inj₁ x rewrite x = inj₁ (trans ∣-d/2∣≡∣d/2∣ ∣d/2∣≡d/2)\n where\n ∣-d/2∣≡∣d/2∣ : ∣ - (+ (∣ d ∣ / 2)) ∣ ≡ ∣ + (∣ d ∣ / 2) ∣\n ∣-d/2∣≡∣d/2∣ = IntP.∣-i∣≡∣i∣ (+ (∣ d ∣ / 2))\n ∣d/2∣≡d/2 : ∣ + (∣ d ∣ / 2) ∣ ≡ (∣ d ∣ / 2)\n ∣d/2∣≡d/2 = refl\n ... | inj₂ y rewrite y = inj₂ claim\n where\n claim : ∣ + (∣ d ∣ / 2) + 1ℤ ∣ ≡ ∣ d ∣ / 2 + 1\n claim = begin\n ∣ + (∣ d ∣ / 2) + 1ℤ ∣ ≡⟨ refl ⟩ \n ∣ + ((∣ d ∣ / 2) + 1) ∣ ≡⟨ refl ⟩ \n ∣ d ∣ / 2 + 1 ∎\n where\n open PE.≡-Reasoning\n\n -- Step 7. d / 2 > ∣ n % d - d ∣ or d / 2 + 1 > ∣ n % d - d ∣\n step7 : ∣ + (n mod d) - d ∣ < ∣ d ∣ / 2 ⊎ ∣ + (n mod d) - d ∣ < ∣ d ∣ / 2 + 1\n step7 with step6\n ... | inj₁ x = inj₁ claim\n where\n claim : ∣ + (n mod d) - d ∣ < ∣ d ∣ / 2\n claim = begin-strict\n ∣ + (n mod d) - d ∣ <⟨ step4 ⟩ \n ∣ + (∣ d ∣ / 2) - d ∣ ≡⟨ x ⟩ \n ∣ d ∣ / 2 ∎\n where\n open NatP.≤-Reasoning\n ... | inj₂ y = inj₂ claim\n where\n claim : ∣ + (n mod d) - d ∣ < ∣ d ∣ / 2 + 1\n claim = begin-strict\n ∣ + (n mod d) - d ∣ <⟨ step4 ⟩ \n ∣ + (∣ d ∣ / 2) - d ∣ ≡⟨ IntP.∣i-j∣≡∣j-i∣ (+ (∣ d ∣ / 2)) d ⟩ \n ∣ d - + (∣ d ∣ / 2) ∣ ≡⟨ y ⟩ \n ∣ d ∣ / 2 + 1 ∎\n where\n open NatP.≤-Reasoning\n\n -- Step 8. d / 2 ≥ ∣ n % d - d ∣\n step8 : ∣ + (n mod d) - d ∣ ≤ ∣ d ∣ / 2\n step8 with step7\n ... | inj₁ x = NatP.<⇒≤ x\n ... | inj₂ y = m a + 1 ≡ suc a \n lemma-+1 {zero} = refl\n lemma-+1 {suc a} = cong suc (lemma-+1 {a})\n\n claim : ∣ + (n mod d) - d ∣ < suc (∣ d ∣ / 2)\n claim = begin-strict\n ∣ + (n mod d) - d ∣ <⟨ y ⟩ \n ∣ d ∣ / 2 + 1 ≡⟨ lemma-+1 ⟩ \n suc (∣ d ∣ / 2) ∎\n where\n open NatP.≤-Reasoning\n \n claim : ∣ r ∣ ≤ ∣ d ∣ / 2\n claim = step8\n\n-- This case is solved by recursive call with argument n and - d. \neuc-rank' n d@(-[1+ e ]) n0 with n mod d ≤? ∣ d ∣ / 2 | euc-rank' n (+[1+ e ]) (λ {()}) \n... | yes pr | hyp = pr \n... | no ¬p | hyp = hyp\n\n\n-- We can relax the estimation.\neuc-rank'' : ∀ (n d : ℤ) (n0 : ¬ d ≡ 0ℤ) ->\n let r = mod' n d n0 in let q = div' n d n0 in \n ∣ r ∣ < ∣ d ∣\neuc-rank'' n d n0 = let r = mod' n d n0 in let q = div' n d n0 in\n begin-strict\n ∣ r ∣ ≤⟨ euc-rank' n d n0 ⟩ \n ∣ d ∣ / 2 <⟨ aux ∣ d ∣ ∣d∣≠0 ⟩ \n ∣ d ∣ ∎\n where\n open NatP.≤-Reasoning\n aux : ∀ n -> ¬ n ≡ 0 -> n / 2 < n\n aux zero n0 with n0 refl\n ... | ()\n aux (suc n) n0 = NDM.m/n .{{NonZero x}} -> ¬ x ≡ 0#\nnz +[1+ n ] ()\n\n\n-- We use the newly defined div and mod function.\ninstance\n new-DMℤ : DivMod ℤ\n new-DMℤ .NZT = NZTℤ\n new-DMℤ ._/_ n d = div' n d (nz d)\n new-DMℤ ._%_ n d = mod' n d (nz d)\n\n", "meta": {"hexsha": "34678a23735c93bcd85c0bc75be53012962f5a4d", "size": 16533, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Integer/EucDomain2.agda", "max_stars_repo_name": "onestruggler/EucDomain", "max_stars_repo_head_hexsha": "7e268e8354065fde734c9c2d9998d2cfd4a21f71", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Integer/EucDomain2.agda", "max_issues_repo_name": "onestruggler/EucDomain", "max_issues_repo_head_hexsha": "7e268e8354065fde734c9c2d9998d2cfd4a21f71", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Integer/EucDomain2.agda", "max_forks_repo_name": "onestruggler/EucDomain", "max_forks_repo_head_hexsha": "7e268e8354065fde734c9c2d9998d2cfd4a21f71", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.0196078431, "max_line_length": 139, "alphanum_fraction": 0.4171656687, "num_tokens": 7131, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681122619885, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.6190883076038055}} {"text": "module Reasoning where\n\nopen import Algebra\n\n-- Standard syntax sugar for writing equational proofs\ninfix 4 _≈_\ndata _≈_ {A} (x y : Graph A) : Set where\n prove : x ≡ y -> x ≈ y\n\ninfix 1 begin_\nbegin_ : ∀ {A} {x y : Graph A} -> x ≈ y -> x ≡ y\nbegin prove p = p\n\ninfixr 2 _≡⟨_⟩_\n_≡⟨_⟩_ : ∀ {A} (x : Graph A) {y z : Graph A} -> x ≡ y -> y ≈ z -> x ≈ z\n_ ≡⟨ p ⟩ prove q = prove (transitivity p q)\n\ninfix 3 _∎\n_∎ : ∀ {A} (x : Graph A) -> x ≈ x\n_∎ _ = prove reflexivity\n\ninfixl 8 _>>_\n_>>_ : ∀ {A} {x y z : Graph A} -> x ≡ y -> y ≡ z -> x ≡ z\n_>>_ = transitivity\n\ndata BinaryOperator : Set where\n +op : BinaryOperator\n *op : BinaryOperator\n\napply : ∀ {A} -> BinaryOperator -> Graph A -> Graph A -> Graph A\napply +op a b = a + b\napply *op a b = a * b\n\nL : ∀ {op : BinaryOperator} -> ∀ {A} {x y z : Graph A} -> x ≡ y -> apply op x z ≡ apply op y z\nL {+op} {x} {y} {z} eq = +left-congruence {x} {y} {z} eq\nL {*op} {x} {y} {z} eq = *left-congruence {x} {y} {z} eq\n\nR : ∀ {op : BinaryOperator} -> ∀ {A} {x y z : Graph A} -> x ≡ y -> apply op z x ≡ apply op z y\nR {+op} {x} {y} {z} eq = +right-congruence {x} {y} {z} eq\nR {*op} {x} {y} {z} eq = *right-congruence {x} {y} {z} eq\n", "meta": {"hexsha": "5a051d2c44f2f866c4bc3ae01783dfc1ea546347", "size": 1171, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Reasoning.agda", "max_stars_repo_name": "asr/alga", "max_stars_repo_head_hexsha": "01f5f9f53ea81f692215300744aa77e26d8bf332", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Reasoning.agda", "max_issues_repo_name": "asr/alga", "max_issues_repo_head_hexsha": "01f5f9f53ea81f692215300744aa77e26d8bf332", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Reasoning.agda", "max_forks_repo_name": "asr/alga", "max_forks_repo_head_hexsha": "01f5f9f53ea81f692215300744aa77e26d8bf332", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.5609756098, "max_line_length": 94, "alphanum_fraction": 0.5345858241, "num_tokens": 520, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681049901036, "lm_q2_score": 0.721743200312399, "lm_q1q2_score": 0.6190882972214593}} {"text": "-- Product of two functors\n{-# OPTIONS --safe #-}\n\nmodule Cubical.Categories.Functor.BinProduct where\n\nopen import Cubical.Categories.Category.Base\nopen import Cubical.Categories.Constructions.BinProduct\nopen import Cubical.Categories.Functor.Base\nopen import Cubical.Data.Sigma.Properties\nopen import Cubical.Foundations.Prelude\n\nprivate\n variable\n ℓA ℓA' ℓB ℓB' ℓC ℓC' ℓD ℓD' : Level\n A : Category ℓA ℓA'\n B : Category ℓB ℓB'\n C : Category ℓC ℓC'\n D : Category ℓD ℓD'\n\nopen Functor\n\n_×F_ : Functor A C → Functor B D → Functor (A × B) (C × D)\n(G ×F H) .F-ob (a , b) = (G ⟅ a ⟆ , H ⟅ b ⟆)\n(G ×F H) .F-hom (g , h) = (G ⟪ g ⟫ , H ⟪ h ⟫)\n(G ×F H) .F-id = ≡-× (G .F-id) (H .F-id)\n(G ×F H) .F-seq _ _ = ≡-× (G .F-seq _ _) (H .F-seq _ _)\n", "meta": {"hexsha": "8b15074431c491fede85aa9de504fb68ebc5bfab", "size": 748, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Functor/BinProduct.agda", "max_stars_repo_name": "FernandoLarrain/cubical", "max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z", "max_issues_repo_path": "Cubical/Categories/Functor/BinProduct.agda", "max_issues_repo_name": "Seanpm2001-web/cubical", "max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Categories/Functor/BinProduct.agda", "max_forks_repo_name": "Seanpm2001-web/cubical", "max_forks_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.7037037037, "max_line_length": 58, "alphanum_fraction": 0.6243315508, "num_tokens": 297, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577680977182187, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.6190882919730257}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule decidable where\n\nopen import level using (Level)\nopen import sets.empty using (⊥; ¬_)\nopen import sets.unit using (⊤; tt)\n\n-- Decidable relations.\n\ndata Dec {i} (P : Set i) : Set i where\n yes : ( p : P) → Dec P\n no : (¬p : ¬ P) → Dec P\n\nTrue : ∀ {i}{P : Set i} → Dec P → Set\nTrue (yes _) = ⊤\nTrue (no _) = ⊥\n\nwitness : ∀ {i}{P : Set i}{d : Dec P} → True d → P\nwitness {d = yes x} _ = x\nwitness {d = no _} ()\n\ndecide : ∀ {i} {P : Set i} {d : Dec P} → P → True d\ndecide {d = yes p} = λ _ → tt\ndecide {d = no f} = f\n", "meta": {"hexsha": "70539bc8e1f05928d40dc8163593db471169e081", "size": 555, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "decidable.agda", "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_issues_repo_path": "decidable.agda", "max_issues_repo_name": "HoTT/M-types", "max_issues_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-02-11T11:14:59.000Z", "max_issues_repo_issues_event_max_datetime": "2015-02-11T15:20:34.000Z", "max_forks_repo_path": "decidable.agda", "max_forks_repo_name": "HoTT/M-types", "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z", "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z", "avg_line_length": 21.3461538462, "max_line_length": 51, "alphanum_fraction": 0.5351351351, "num_tokens": 219, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8652240895276224, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.6190020753779693}} {"text": "module Prelude.Monoid where\n\nopen import Prelude.Function\nopen import Prelude.Maybe\n\nopen import Prelude.List\n\nopen import Prelude.Semiring\nopen import Prelude.Semigroup public\n\nopen import Prelude.Applicative\nopen import Prelude.Functor\nopen import Prelude.Equality\n\nopen import Prelude.Variables\n\nrecord Monoid {a} (A : Set a) : Set a where\n field\n {{super}} : Semigroup A\n mempty : A\nopen Monoid {{...}} public hiding (super)\n\n{-# DISPLAY Monoid.mempty _ = mempty #-}\n\n\nrecord Monoid/Laws {ℓ} (A : Set ℓ) : Set ℓ where\n field\n overlap {{super}} : Monoid A\n left-identity : (e : A) → mempty <> e ≡ e\n right-identity : (e : A) → e <> mempty ≡ e\n -- Using Semigroup/Laws instance creates inference problems\n -- Maby we can do this in a better way?\n monoid-assoc : (a b c : A) → (a <> b) <> c ≡ a <> (b <> c)\nopen Monoid/Laws {{...}} public hiding (super)\n\n\nmconcat : ∀ {a} {A : Set a} {{MonA : Monoid A}} → List A → A\nmconcat = foldr _<>_ mempty\n\n--- Instances ---\n\ninstance\n\n MonoidList : ∀ {a} {A : Set a} → Monoid (List A)\n Monoid.super MonoidList = it\n mempty {{MonoidList}} = []\n\n MonoidFun : ∀ {a b} {A : Set a} {B : A → Set b} {{_ : ∀ {x} → Monoid (B x)}} → Monoid (∀ x → B x)\n Monoid.super (MonoidFun {a} {b} {A} {B} {{SG}}) =\n SemigroupFun {a} {b} {A} {B} {{Monoid.super SG}}\n mempty {{MonoidFun}} _ = mempty\n\n MonoidMaybe : ∀ {a} {A : Set a} → Monoid (Maybe A)\n Monoid.super MonoidMaybe = it\n mempty {{MonoidMaybe}} = nothing\n\n\n -- Temporarily here, better version comes in the list update\n Monoid/LawsList : Monoid/Laws (List A)\n Monoid/Laws.super Monoid/LawsList = it\n left-identity {{Monoid/LawsList}} _ = refl\n right-identity {{Monoid/LawsList}} [] = refl\n right-identity {{Monoid/LawsList}} (x ∷ xs) =\n cong (x ∷_) (right-identity xs)\n monoid-assoc {{Monoid/LawsList}} [] ys zs = refl\n monoid-assoc {{Monoid/LawsList}} (x ∷ xs) ys zs =\n cong (x ∷_) (monoid-assoc xs ys zs)\n\nrecord Sum {a} (A : Set a) : Set a where\n constructor mkSum\n field getSum : A\nopen Sum public\n\ninstance\n SemigroupSum : ∀ {a} {A : Set a} {{_ : Semiring A}} → Semigroup (Sum A)\n getSum (_<>_ {{SemigroupSum}} x y) = getSum x + getSum y\n\n MonoidSum : ∀ {a} {A : Set a} {{_ : Semiring A}} → Monoid (Sum A)\n Monoid.super MonoidSum = it\n getSum (mempty {{MonoidSum}}) = zro\n\nrecord Product {a} (A : Set a) : Set a where\n constructor mkProduct\n field getProduct : A\n\nopen Product public\n\ninstance\n SemigroupProduct : ∀ {a} {A : Set a} {{_ : Semiring A}} → Semigroup (Product A)\n getProduct (_<>_ {{SemigroupProduct}} x y) = getProduct x * getProduct y\n\n MonoidProduct : ∀ {a} {A : Set a} {{_ : Semiring A}} → Monoid (Product A)\n Monoid.super MonoidProduct = it\n getProduct (mempty {{MonoidProduct}}) = one\n\nrecord Const {a b} (A : Set a) (B : Set b) : Set a where\n constructor mkConst\n field getConst : A\n\nopen Const public\n\nmodule _ {a b} {A : Set a} {{MonA : Monoid A}} where\n instance\n FunctorConst : Functor {a = b} (Const A)\n getConst (fmap {{FunctorConst}} f x) = getConst x\n\n ApplicativeConst : Applicative (Const A)\n getConst (pure {{ApplicativeConst}} x) = mempty\n getConst (_<*>_ {{ApplicativeConst}} wf wx) = getConst wf <> getConst wx\n", "meta": {"hexsha": "8cab9b38ab60c3a2800eef333c2fbf4d9403a3c8", "size": 3223, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Prelude/Monoid.agda", "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 111, "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_issues_repo_path": "src/Prelude/Monoid.agda", "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_forks_repo_path": "src/Prelude/Monoid.agda", "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "avg_line_length": 29.3, "max_line_length": 99, "alphanum_fraction": 0.6341917468, "num_tokens": 1084, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127678225575, "lm_q2_score": 0.7248702702332476, "lm_q1q2_score": 0.6189759787671577}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nmodule Cubical.Categories.Morphism where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Data.Sigma\nopen import Cubical.Categories.Category\n\nprivate\n variable\n ℓ ℓ' : Level\n\nmodule _ {C : Precategory ℓ ℓ'} where\n open Precategory C\n private\n variable\n x y z w : ob\n\n isMonic : (Hom[ x , y ]) → Type (ℓ-max ℓ ℓ')\n isMonic {x} {y} f = ∀ {z : ob} {a a' : Hom[ z , x ]}\n → (f ∘ a ≡ f ∘ a') → (a ≡ a')\n\n isEpic : (Hom[ x , y ]) → Type (ℓ-max ℓ ℓ')\n isEpic {x} {y} g = ∀ {z : ob} {b b' : Hom[ y , z ]}\n → (b ∘ g ≡ b' ∘ g) → (b ≡ b')\n\n -- A morphism is split monic if it has a *retraction*\n isSplitMon : (Hom[ x , y ]) → Type ℓ'\n isSplitMon {x} {y} f = ∃[ r ∈ Hom[ y , x ] ] r ∘ f ≡ id x\n\n -- A morphism is split epic if it has a *section*\n isSplitEpi : (Hom[ x , y ]) → Type ℓ'\n isSplitEpi {x} {y} g = ∃[ s ∈ Hom[ y , x ] ] g ∘ s ≡ id y\n\n record areInv (f : Hom[ x , y ]) (g : Hom[ y , x ]) : Type ℓ' where\n field\n sec : g ⋆ f ≡ id y\n ret : f ⋆ g ≡ id x\n\n open areInv\n\n symAreInv : ∀ {f : Hom[ x , y ]} {g : Hom[ y , x ]}\n → areInv f g\n → areInv g f\n symAreInv record { sec = sec ; ret = ret } = record { sec = ret ; ret = sec }\n\n -- equational reasoning with inverses\n invMoveR : ∀ {f : Hom[ x , y ]} {g : Hom[ y , x ]} {h : Hom[ z , x ]} {k : Hom[ z , y ]}\n → areInv f g\n → h ⋆ f ≡ k\n → h ≡ k ⋆ g\n invMoveR {f = f} {g} {h} {k} ai p\n = h\n ≡⟨ sym (⋆IdR _) ⟩\n (h ⋆ id _)\n ≡⟨ cong (h ⋆_) (sym (ai .ret)) ⟩\n (h ⋆ (f ⋆ g))\n ≡⟨ sym (⋆Assoc _ _ _) ⟩\n ((h ⋆ f) ⋆ g)\n ≡⟨ cong (_⋆ g) p ⟩\n k ⋆ g\n ∎\n\n invMoveL : ∀ {f : Hom[ x , y ]} {g : Hom[ y , x ]} {h : Hom[ y , z ]} {k : Hom[ x , z ]}\n → areInv f g\n → f ⋆ h ≡ k\n → h ≡ g ⋆ k\n invMoveL {f = f} {g} {h} {k} ai p\n = h\n ≡⟨ sym (⋆IdL _) ⟩\n id _ ⋆ h\n ≡⟨ cong (_⋆ h) (sym (ai .sec)) ⟩\n (g ⋆ f) ⋆ h\n ≡⟨ ⋆Assoc _ _ _ ⟩\n g ⋆ (f ⋆ h)\n ≡⟨ cong (g ⋆_) p ⟩\n (g ⋆ k)\n ∎\n\n record isIso (f : Hom[ x , y ]) : Type ℓ' where\n field\n inv : Hom[ y , x ]\n sec : inv ⋆ f ≡ id y\n ret : f ⋆ inv ≡ id x\n\n open isIso\n\n isIso→areInv : ∀ {f : Hom[ x , y ]}\n → (isI : isIso f)\n → areInv f (isI .inv)\n isIso→areInv record { inv = inv ; sec = sec ; ret = ret } = record { sec = sec ; ret = ret }\n\n open CatIso\n\n -- isIso agrees with CatIso\n isIso→CatIso : ∀ {f : C [ x , y ]}\n → isIso f\n → CatIso {C = C} x y\n isIso→CatIso {f = f} record { inv = f⁻¹ ; sec = sec ; ret = ret } = catiso f f⁻¹ sec ret\n\n CatIso→isIso : (cIso : CatIso {C = C} x y)\n → isIso (cIso .mor)\n CatIso→isIso (catiso mor inv sec ret) = record { inv = inv ; sec = sec ; ret = ret }\n\n CatIso→areInv : (cIso : CatIso {C = C} x y)\n → areInv (cIso .mor) (cIso .inv)\n CatIso→areInv cIso = isIso→areInv (CatIso→isIso cIso)\n\n -- reverse of an iso is also an iso\n symCatIso : ∀ {x y}\n → CatIso {C = C} x y\n → CatIso {C = C} y x\n symCatIso (catiso mor inv sec ret) = catiso inv mor ret sec\n", "meta": {"hexsha": "0b0b3cd4157eb2397de86eb04ab0596df4bcf880", "size": 3170, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Morphism.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Categories/Morphism.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Categories/Morphism.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.8070175439, "max_line_length": 94, "alphanum_fraction": 0.4605678233, "num_tokens": 1350, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.819893340314393, "lm_q2_score": 0.7549149813536518, "lm_q1q2_score": 0.6189497657154233}} {"text": "------------------------------------------------------------------------------\n-- The division specification\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOTC.Program.Division.Specification where\n\nopen import FOTC.Base\nopen import FOTC.Data.Nat\nopen import FOTC.Data.Nat.Inequalities\n\n------------------------------------------------------------------------------\n-- Specification: The division is total and the result is correct.\ndivSpec : D → D → D → Set\ndivSpec i j q = N q ∧ (∃[ r ] N r ∧ r < j ∧ i ≡ j * q + r)\n{-# ATP definition divSpec #-}\n", "meta": {"hexsha": "fae57cd7ce8ae6570d1dad67b898d1a1edaa690c", "size": 762, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/FOTC/Program/Division/Specification.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/FOTC/Program/Division/Specification.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/FOTC/Program/Division/Specification.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 36.2857142857, "max_line_length": 78, "alphanum_fraction": 0.4265091864, "num_tokens": 142, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8688267898240861, "lm_q2_score": 0.712232184238947, "lm_q1q2_score": 0.6188064022417213}} {"text": "------------------------------------------------------------------------\n-- Code related to the paper \"Isomorphism Is Equality\" by Thierry\n-- Coquand and Nils Anders Danielsson\n--\n-- The code is written by Nils Anders Danielsson\n------------------------------------------------------------------------\n\n-- Note that the code has been changed after the paper was published.\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule README.Isomorphism-is-equality where\n\n---=====================================================================\n-- 2: Preliminaries\n\n------------------------------------------------------------------------\n-- 2.1: Hierarchy of Types\n\n-- The lifting operator ↑. (Note that Agda is universe-polymorphic.)\n\nimport Prelude\n\n------------------------------------------------------------------------\n-- 2.2: Quantifiers\n\n-- Σ, ∃ and _×_. (The code sometimes uses ∃ instead of Σ.)\n\nimport Prelude\n\n------------------------------------------------------------------------\n-- 2.3: Equality\n\n-- Axiomatisations of equality, used in order to ensure that the\n-- elimination rule (J) does not compute. J is called elim in the\n-- code.\n\nimport Equality\n\n-- Bijections (_↔_), the key property of equality of Σ-types\n-- (Σ-≡,≡↔≡).\n\nimport Bijection\n\n-- Extensionality.\n\nimport Equality\n\n-- \"∀ x. f x ≡ g x is in bijective correspondence with f ≡ g\"\n-- (extensionality-isomorphism).\n\nimport Equivalence\n\n------------------------------------------------------------------------\n-- 2.4: More Types\n\n-- ⊤, ⊥, _+_ (called _⊎_ in the code), ℕ.\n\nimport Prelude\n\n-- Logical equivalences (_⇔_).\n\nimport Logical-equivalence\n\n------------------------------------------------------------------------\n-- 2.5: Univalent Foundations\n\n-- Contractible.\n\nimport Equality\n\n-- H-level, Is-proposition, Is-set.\n\nimport H-level\n\n-- Results that can be used to establish that a type has a certain\n-- h-level.\n\nimport H-level\nimport H-level.Closure\nimport Equality.Decidable-UIP\n\n-- Propositional second components of pairs can be dropped\n-- (ignore-propositional-component).\n\nimport Function-universe\n\n-- Is-equivalence, subst P eq is an equivalence\n-- (subst-is-equivalence), _≃_, _≃_ is logically equivalent to _↔_ and\n-- related properties (_≃_.bijection, ↔⇒≃, ↔↔≃, ⇔↔≃), Σ and Π preserve\n-- equivalences (Σ-preserves, Π-preserves).\n\nimport Equivalence\n\n-- More congruence properties (including _⊎-cong_ and →-cong).\n\nimport Function-universe\n\n-- ≡⇒≃, Univalence, ≃⇒≡, the univalence axiom implies extensionality\n-- (dependent-extensionality), the transport theorem\n-- (transport-theorem), resp eq is an equivalence\n-- (resp-is-equivalence), resp eq preserves compositions\n-- (resp-preserves-compositions).\n\nimport Univalence-axiom\n\n---=====================================================================\n-- 3: Isomorphism Is Equality\n\n------------------------------------------------------------------------\n-- 3.1: Parameters\n\n-- The parameters are represented using a record type called Universe.\n\nimport Univalence-axiom.Isomorphism-is-equality.Simple\n\n------------------------------------------------------------------------\n-- 3.2: Codes for Structures\n\n-- Code, Instance, Is-isomorphism, Isomorphic, Carrier, element,\n-- equality-pair-lemma.\n\nimport Univalence-axiom.Isomorphism-is-equality.Simple\n\n------------------------------------------------------------------------\n-- 3.3: Main Theorem\n\n-- The main result (isomorphism-is-equality), isomorphism is equal to\n-- equality (isomorphic≡≡), the right-to-left direction of the\n-- bijection is equal to a simple function\n-- (from-isomorphism-is-equality).\n\nimport Univalence-axiom.Isomorphism-is-equality.Simple\n\n------------------------------------------------------------------------\n-- 3.4: A Universe\n\n-- U, El, cast, resp, resp-id, Is-isomorphism′,\n-- isomorphism-definitions-isomorphic.\n\nimport Univalence-axiom.Isomorphism-is-equality.Simple\n\n-- The operators _→-eq_ (→-cong-⇔), _×-eq_ (_×-cong_) and _+-eq_\n-- (_⊎-cong_).\n\nimport Function-universe\n\n-- The operators _→-rel_, _×-rel_ and _+-rel_ (_⊎-rel_).\n\nimport Prelude\n\n------------------------------------------------------------------------\n-- 3.5: Examples\n\n-- Monoids, posets, discrete fields, fixpoint operators.\n\nimport Univalence-axiom.Isomorphism-is-equality.Simple\n\n---=====================================================================\n-- 4: Related Work\n\n-- Aczel's structure identity principle (structure-identity-principle).\n\nimport Structure-identity-principle\n\n-- The structure identity principle can be used to prove a slightly\n-- restricted variant of our main theorem (isomorphism-is-equality′,\n-- from-isomorphism-is-equality′).\n\nimport\n Univalence-axiom.Isomorphism-is-equality.Structure-identity-principle\n", "meta": {"hexsha": "013704c2505f8ea75106840763ced62646591c04", "size": 4727, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "README/Isomorphism-is-equality.agda", "max_stars_repo_name": "nad/equality", "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_issues_repo_path": "README/Isomorphism-is-equality.agda", "max_issues_repo_name": "nad/equality", "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "README/Isomorphism-is-equality.agda", "max_forks_repo_name": "nad/equality", "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.4825581395, "max_line_length": 72, "alphanum_fraction": 0.5629363232, "num_tokens": 1073, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267864276107, "lm_q2_score": 0.712232184238947, "lm_q1q2_score": 0.6188063998226423}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Binary.Operations.Multiplication where\n\nopen import Data.Binary.Definitions\nopen import Data.Binary.Operations.Addition\n\nmul : 𝔹⁺ → 𝔹⁺ → 𝔹⁺\nmul 1ᵇ ys = ys\nmul (O ∷ xs) ys = O ∷ (mul xs ys)\nmul (I ∷ xs) ys = add O (O ∷ mul ys xs) ys\n\n_*_ : 𝔹 → 𝔹 → 𝔹\n0ᵇ * ys = 0ᵇ\n(0< _) * 0ᵇ = 0ᵇ\n(0< xs) * (0< ys) = 0< mul xs ys\n{-# INLINE _*_ #-}\n", "meta": {"hexsha": "f554b8e2d2d517c35e2b6276853292bac2b162c1", "size": 380, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Binary/Operations/Multiplication.agda", "max_stars_repo_name": "oisdk/agda-binary", "max_stars_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-03-21T21:30:10.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-21T21:30:10.000Z", "max_issues_repo_path": "Data/Binary/Operations/Multiplication.agda", "max_issues_repo_name": "oisdk/agda-binary", "max_issues_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Binary/Operations/Multiplication.agda", "max_forks_repo_name": "oisdk/agda-binary", "max_forks_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.1111111111, "max_line_length": 50, "alphanum_fraction": 0.5921052632, "num_tokens": 173, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267830311354, "lm_q2_score": 0.7122321842389469, "lm_q1q2_score": 0.6188063974035631}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Codiscrete where\n\nopen import Level using (Level; 0ℓ; lift; lower)\nopen import Data.Nat using (ℕ; suc)\nopen import Data.Fin hiding (lift)\nopen import Data.Unit\nopen import Function renaming (id to idf)\nopen import Relation.Binary.PropositionalEquality\n using (_≡_; refl; sym; trans)\n\nopen import Categories.Category.Groupoid\nopen import Categories.Category.Instance.One\nopen import Categories.Category.Equivalence using (StrongEquivalence; WeakInverse)\nopen import Categories.Functor using (Functor; _∘F_) renaming (id to idF)\nopen import Categories.Category using (Category)\nopen import Categories.NaturalTransformation using (NaturalTransformation)\nopen import Categories.NaturalTransformation.NaturalIsomorphism using (_≃_)\n\n-- Codiscrete Groupoid on (n+1) points\nCodiscreteGroupoid : (n : ℕ) → Groupoid 0ℓ 0ℓ 0ℓ\nCodiscreteGroupoid n = record\n { category = record\n { Obj = Fin (suc n)\n ; _⇒_ = λ _ _ → ⊤\n ; _≈_ = _≡_\n ; assoc = refl\n ; sym-assoc = refl\n ; identityˡ = refl\n ; identityʳ = refl\n ; equiv = record { refl = refl ; sym = sym ; trans = trans }\n ; ∘-resp-≈ = λ _ _ → refl\n }\n ; isGroupoid = record\n { _⁻¹ = idf\n ; iso = record { isoˡ = refl ; isoʳ = refl }\n }\n }\n\nopen Groupoid\n\nContractible : (n : ℕ) → (k : Fin (suc n)) →\n StrongEquivalence (category (CodiscreteGroupoid n)) (One {0ℓ} {0ℓ} {0ℓ})\nContractible n k = record\n { F = F\n ; G = G\n ; weak-inverse = record\n { F∘G≈id = F∘G≃id\n ; G∘F≈id = G∘F≃id\n }\n }\n where\n C : Category _ _ _\n C = category (CodiscreteGroupoid n)\n O : Category 0ℓ 0ℓ 0ℓ\n O = One\n F : Functor C O\n F = record\n { F₀ = λ _ → lift tt -- This is our 'GC' function\n ; F₁ = lift\n ; identity = lift tt\n ; homomorphism = lift tt\n ; F-resp-≈ = λ _ → lift tt\n }\n -- This is where 'k' is used:\n G : Functor O C\n G = record\n { F₀ = λ _ → k\n ; F₁ = lower\n ; identity = refl\n ; homomorphism = refl\n ; F-resp-≈ = λ _ → refl\n }\n F∘G≃id : F ∘F G ≃ idF\n F∘G≃id = record\n { F⇒G = record { η = idf ; commute = idf }\n ; F⇐G = record { η = idf ; commute = idf }\n }\n G∘F≃id : G ∘F F ≃ idF\n G∘F≃id = record\n { F⇒G = record { η = λ _ → tt ; commute = λ _ → refl }\n ; F⇐G = record { η = λ _ → tt ; commute = λ _ → refl }\n ; iso = λ X → record { isoˡ = refl ; isoʳ = refl }\n }\n", "meta": {"hexsha": "b67c42b9ad51c8c500c683778ef942a586f9211b", "size": 2361, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "fracGC/Codiscrete.agda", "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_issues_repo_path": "fracGC/Codiscrete.agda", "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_forks_repo_path": "fracGC/Codiscrete.agda", "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "avg_line_length": 27.4534883721, "max_line_length": 82, "alphanum_fraction": 0.6077933079, "num_tokens": 857, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8688267762381843, "lm_q2_score": 0.7122321842389469, "lm_q1q2_score": 0.6188063925654047}} {"text": "{-# OPTIONS --universe-polymorphism #-}\nmodule Categories.Category.Construction.F-Algebras where\n\nopen import Level\nopen import Data.Product using (proj₁; proj₂)\n\nopen import Categories.Category\nopen import Categories.Functor hiding (id)\nopen import Categories.Functor.Algebra\nopen import Categories.Object.Initial\nimport Categories.Morphism.Reasoning as MR\nimport Categories.Morphism as Mor using (_≅_)\n\nprivate\n variable\n o ℓ e : Level\n 𝒞 : Category o ℓ e\n\nF-Algebras : {𝒞 : Category o ℓ e} → Endofunctor 𝒞 → Category (ℓ ⊔ o) (e ⊔ ℓ) e\nF-Algebras {𝒞 = 𝒞} F = record\n { Obj = F-Algebra F\n ; _⇒_ = F-Algebra-Morphism\n ; _≈_ = λ α₁ α₂ → f α₁ ≈ f α₂\n ; _∘_ = λ α₁ α₂ → record { f = f α₁ ∘ f α₂ ; commutes = commut α₁ α₂ }\n ; id = record { f = id ; commutes = identityˡ ○ ⟺ identityʳ ○ ⟺ (∘-resp-≈ʳ identity) }\n ; assoc = assoc\n ; sym-assoc = sym-assoc\n ; identityˡ = identityˡ\n ; identityʳ = identityʳ\n ; identity² = identity²\n ; equiv = record\n { refl = refl\n ; sym = sym\n ; trans = trans\n }\n ; ∘-resp-≈ = ∘-resp-≈\n }\n where\n open Category 𝒞\n open Equiv\n open HomReasoning using (⟺; _○_; begin_; _≈⟨_⟩_; _∎)\n open Functor F\n open F-Algebra-Morphism\n open F-Algebra\n commut : {A B C : F-Algebra F} (α₁ : F-Algebra-Morphism B C) (α₂ : F-Algebra-Morphism A B) →\n (f α₁ ∘ f α₂) ∘ α A ≈ α C ∘ F₁ (f α₁ ∘ f α₂)\n commut {A} {B} {C} α₁ α₂ = begin\n (f α₁ ∘ f α₂) ∘ α A ≈⟨ assoc ○ ∘-resp-≈ʳ (commutes α₂) ⟩\n f α₁ ∘ (α B ∘ F₁ (f α₂)) ≈⟨ ⟺ assoc ○ ∘-resp-≈ˡ (commutes α₁) ⟩\n (α C ∘ F₁ (f α₁)) ∘ F₁ (f α₂) ≈⟨ assoc ○ ∘-resp-≈ʳ (⟺ homomorphism) ⟩\n α C ∘ F₁ (f α₁ ∘ f α₂) ∎\n\n\nmodule Lambek {𝒞 : Category o ℓ e} {F : Endofunctor 𝒞} (I : Initial (F-Algebras F)) where\n open Category 𝒞\n open Functor F\n open F-Algebra using (α)\n\n open MR 𝒞 using (glue)\n open Mor 𝒞\n open Initial I -- so ⊥ is an F-Algebra, which is initial\n\n -- While an expert might be able to decipher the proof at the nLab\n -- (https://ncatlab.org/nlab/show/initial+algebra+of+an+endofunctor)\n -- I (JC) have found that the notes at\n -- http://www.cs.ru.nl/~jrot/coalgebra/ak-algebras.pdf\n -- are easier to follow, and lead to the full proof below.\n private\n module ⊥ = F-Algebra ⊥\n A = ⊥.A\n a : F₀ A ⇒ A\n a = ⊥.α\n\n -- The F-Algebra structure that will make things work\n F⊥ : F-Algebra F\n F⊥ = iterate ⊥\n\n -- By initiality, we get the following morphism\n f : F-Algebra-Morphism ⊥ F⊥\n f = !\n\n module FAM = F-Algebra-Morphism f\n\n i : A ⇒ F₀ A\n i = FAM.f\n\n a∘f : F-Algebra-Morphism ⊥ ⊥\n a∘f = record\n { f = a ∘ i\n ; commutes = glue triv FAM.commutes ○ ∘-resp-≈ʳ (⟺ homomorphism)\n }\n where\n open HomReasoning using (_○_; ⟺)\n triv : CommutativeSquare (α F⊥) (α F⊥) a a\n triv = Equiv.refl\n\n lambek : A ≅ F₀ A\n lambek = record\n { from = i\n ; to = a\n ; iso = record\n { isoˡ = ⊥-id a∘f\n ; isoʳ = begin\n i ∘ a ≈⟨ F-Algebra-Morphism.commutes f ⟩\n F₁ a ∘ F₁ i ≈˘⟨ homomorphism ⟩\n F₁ (a ∘ i) ≈⟨ F-resp-≈ (⊥-id a∘f) ⟩\n F₁ id ≈⟨ identity ⟩\n id ∎\n }\n }\n where\n open HomReasoning\n", "meta": {"hexsha": "2f3beba717ddf80935dac0bf41e1380191d37dad", "size": 3245, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Category/Construction/F-Algebras.agda", "max_stars_repo_name": "Taneb/agda-categories", "max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Categories/Category/Construction/F-Algebras.agda", "max_issues_repo_name": "Taneb/agda-categories", "max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Categories/Category/Construction/F-Algebras.agda", "max_forks_repo_name": "Taneb/agda-categories", "max_forks_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.7168141593, "max_line_length": 96, "alphanum_fraction": 0.5651771957, "num_tokens": 1306, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8807970873650401, "lm_q2_score": 0.7025300698514778, "lm_q1q2_score": 0.6187864393115399}} {"text": "module Issue2845 where\n\nopen import Agda.Builtin.Nat\nopen import Agda.Primitive.Cubical\nopen import Agda.Builtin.Equality\n\nEx1 : Nat\nEx1 = primComp (λ i → Nat) i0 (λ i → isOneEmpty) zero\n\ntest1 : Ex1 ≡ zero\ntest1 = refl\n\nEx2 : (i : I) → Nat\nEx2 i = primComp (λ i → Nat) i (λ { _ (i = i1) → zero}) zero\n\ntest2 : ∀ i → Ex2 i ≡ zero\ntest2 i = refl\n\nEx3 : (i : I) (p : I → Nat) → Nat\nEx3 i p = primComp (λ i → Nat) i (λ { k (i = i1) → suc (p k)}) (suc (p i0))\n\ntest3 : ∀ i p → Ex3 i p ≡ suc _\ntest3 i p = refl\n", "meta": {"hexsha": "fe914c88c71a258a3d42187d261e30adb1ddd74c", "size": 506, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue2845.agda", "max_stars_repo_name": "alhassy/agda", "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_issues_repo_path": "test/Succeed/Issue2845.agda", "max_issues_repo_name": "alhassy/agda", "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/Issue2845.agda", "max_forks_repo_name": "alhassy/agda", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 21.0833333333, "max_line_length": 75, "alphanum_fraction": 0.5968379447, "num_tokens": 212, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8807970779778825, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.6187864162596067}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Closures of a unary relation with respect to a strict partial order\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary\n\nmodule Relation.Unary.Closure.StrictPartialOrder\n {a r e} (P : StrictPartialOrder a e r) where\n\nopen StrictPartialOrder P renaming (_<_ to _∼_)\nopen import Relation.Unary using (Pred)\n\n-- Specialising the results proven generically in `Base`.\nimport Relation.Unary.Closure.Base _∼_ as Base\nopen Base public using (□; map; Closed)\n\nmodule _ {t} {T : Pred Carrier t} where\n\n reindex : ∀ {x y} → x ∼ y → □ T x → □ T y\n reindex = Base.reindex trans\n\n duplicate : ∀ {x} → □ T x → □ (□ T) x\n duplicate = Base.duplicate trans\n\n□-closed : ∀ {t} {T : Pred Carrier t} → Closed (□ T)\n□-closed = Base.□-closed trans\n", "meta": {"hexsha": "54741cf27cbf9a64dedd81db0089f470fda86885", "size": 929, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Unary/Closure/StrictPartialOrder.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Unary/Closure/StrictPartialOrder.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Unary/Closure/StrictPartialOrder.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 29.9677419355, "max_line_length": 72, "alphanum_fraction": 0.5683530678, "num_tokens": 242, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8976952975813454, "lm_q2_score": 0.6893056167854461, "lm_q1q2_score": 0.6187864107847039}} {"text": "------------------------------------------------------------------------\n-- Some boring lemmas used by the ring solver\n------------------------------------------------------------------------\n\n-- Note that these proofs use all \"almost commutative ring\" properties\n-- except for zero and -‿pres-≈.\n\nopen import Algebra\nopen import Algebra.RingSolver.AlmostCommutativeRing\n\nmodule Algebra.RingSolver.Lemmas\n (coeff : RawRing)\n (r : AlmostCommutativeRing)\n (morphism : coeff -Raw-AlmostCommutative⟶ r)\n where\n\nprivate\n module C = RawRing coeff\nopen AlmostCommutativeRing r\nopen import Algebra.Morphism\nopen _-RawRing⟶_ morphism\nimport Relation.Binary.EqReasoning as EqR; open EqR setoid\nopen import Data.Function\nopen import Data.Product\n\nlemma₀ : ∀ x → x + ⟦ C.0# ⟧ ≈ x\nlemma₀ x = begin\n x + ⟦ C.0# ⟧ ≈⟨ refl ⟨ +-pres-≈ ⟩ 0-homo ⟩\n x + 0# ≈⟨ proj₂ +-identity _ ⟩\n x ∎\n\nlemma₁ : ∀ a b c d x →\n (a + b) * x + (c + d) ≈ (a * x + c) + (b * x + d)\nlemma₁ a b c d x = begin\n (a + b) * x + (c + d) ≈⟨ proj₂ distrib _ _ _ ⟨ +-pres-≈ ⟩ refl ⟩\n (a * x + b * x) + (c + d) ≈⟨ +-assoc _ _ _ ⟩\n a * x + (b * x + (c + d)) ≈⟨ refl ⟨ +-pres-≈ ⟩ sym (+-assoc _ _ _) ⟩\n a * x + ((b * x + c) + d) ≈⟨ refl ⟨ +-pres-≈ ⟩ (+-comm _ _ ⟨ +-pres-≈ ⟩ refl) ⟩\n a * x + ((c + b * x) + d) ≈⟨ refl ⟨ +-pres-≈ ⟩ +-assoc _ _ _ ⟩\n a * x + (c + (b * x + d)) ≈⟨ sym $ +-assoc _ _ _ ⟩\n (a * x + c) + (b * x + d) ∎\n\nlemma₂ : ∀ x y z → x + (y + z) ≈ y + (x + z)\nlemma₂ x y z = begin\n x + (y + z) ≈⟨ sym $ +-assoc _ _ _ ⟩\n (x + y) + z ≈⟨ +-comm _ _ ⟨ +-pres-≈ ⟩ refl ⟩\n (y + x) + z ≈⟨ +-assoc _ _ _ ⟩\n y + (x + z) ∎\n\nlemma₃ : ∀ a b c x → a * c * x + b * c ≈ (a * x + b) * c\nlemma₃ a b c x = begin\n a * c * x + b * c ≈⟨ lem ⟨ +-pres-≈ ⟩ refl ⟩\n a * x * c + b * c ≈⟨ sym $ proj₂ distrib _ _ _ ⟩\n (a * x + b) * c ∎\n where\n lem = begin\n a * c * x ≈⟨ *-assoc _ _ _ ⟩\n a * (c * x) ≈⟨ refl ⟨ *-pres-≈ ⟩ *-comm _ _ ⟩\n a * (x * c) ≈⟨ sym $ *-assoc _ _ _ ⟩\n a * x * c ∎\n\nlemma₄ : ∀ a b c x → a * b * x + a * c ≈ a * (b * x + c)\nlemma₄ a b c x = begin\n a * b * x + a * c ≈⟨ *-assoc _ _ _ ⟨ +-pres-≈ ⟩ refl ⟩\n a * (b * x) + a * c ≈⟨ sym $ proj₁ distrib _ _ _ ⟩\n a * (b * x + c) ∎\n\nlemma₅ : ∀ a b c d x →\n a * c * x * x + ((a * d + b * c) * x + b * d) ≈\n (a * x + b) * (c * x + d)\nlemma₅ a b c d x = begin\n a * c * x * x +\n ((a * d + b * c) * x + b * d) ≈⟨ lem₁ ⟨ +-pres-≈ ⟩\n (lem₂ ⟨ +-pres-≈ ⟩ refl) ⟩\n a * x * (c * x) +\n (a * x * d + b * (c * x) + b * d) ≈⟨ refl ⟨ +-pres-≈ ⟩ +-assoc _ _ _ ⟩\n a * x * (c * x) +\n (a * x * d + (b * (c * x) + b * d)) ≈⟨ sym $ +-assoc _ _ _ ⟩\n a * x * (c * x) + a * x * d +\n (b * (c * x) + b * d) ≈⟨ sym $ proj₁ distrib _ _ _\n ⟨ +-pres-≈ ⟩\n proj₁ distrib _ _ _ ⟩\n a * x * (c * x + d) + b * (c * x + d) ≈⟨ sym $ proj₂ distrib _ _ _ ⟩\n (a * x + b) * (c * x + d) ∎\n where\n lem₁' = begin\n a * c * x ≈⟨ *-assoc _ _ _ ⟩\n a * (c * x) ≈⟨ refl ⟨ *-pres-≈ ⟩ *-comm _ _ ⟩\n a * (x * c) ≈⟨ sym $ *-assoc _ _ _ ⟩\n a * x * c ∎\n\n lem₁ = begin\n a * c * x * x ≈⟨ lem₁' ⟨ *-pres-≈ ⟩ refl ⟩\n a * x * c * x ≈⟨ *-assoc _ _ _ ⟩\n a * x * (c * x) ∎\n\n lem₂ = begin\n (a * d + b * c) * x ≈⟨ proj₂ distrib _ _ _ ⟩\n a * d * x + b * c * x ≈⟨ *-assoc _ _ _ ⟨ +-pres-≈ ⟩ *-assoc _ _ _ ⟩\n a * (d * x) + b * (c * x) ≈⟨ (refl ⟨ *-pres-≈ ⟩ *-comm _ _)\n ⟨ +-pres-≈ ⟩ refl ⟩\n a * (x * d) + b * (c * x) ≈⟨ sym $ *-assoc _ _ _ ⟨ +-pres-≈ ⟩ refl ⟩\n a * x * d + b * (c * x) ∎\n\nlemma₆ : ∀ a b x → - a * x + - b ≈ - (a * x + b)\nlemma₆ a b x = begin\n - a * x + - b ≈⟨ -‿*-distribˡ _ _ ⟨ +-pres-≈ ⟩ refl ⟩\n - (a * x) + - b ≈⟨ -‿+-comm _ _ ⟩\n - (a * x + b) ∎\n\nlemma₇ : ∀ x → ⟦ C.1# ⟧ * x + ⟦ C.0# ⟧ ≈ x\nlemma₇ x = begin\n ⟦ C.1# ⟧ * x + ⟦ C.0# ⟧ ≈⟨ (1-homo ⟨ *-pres-≈ ⟩ refl) ⟨ +-pres-≈ ⟩ 0-homo ⟩\n 1# * x + 0# ≈⟨ proj₂ +-identity _ ⟩\n 1# * x ≈⟨ proj₁ *-identity _ ⟩\n x ∎\n", "meta": {"hexsha": "9b8c74a2fec83299ce8f1885dcd9d7a2fbabcc90", "size": 4192, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Algebra/RingSolver/Lemmas.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Algebra/RingSolver/Lemmas.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Algebra/RingSolver/Lemmas.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 35.8290598291, "max_line_length": 82, "alphanum_fraction": 0.3728530534, "num_tokens": 1923, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8976952811593496, "lm_q2_score": 0.6893056104028797, "lm_q1q2_score": 0.6187863937353302}} {"text": "module Numeral.Natural.LinearSearchDecidable where -- TODO: Maybe move and rename to Numeral.Natural.Sequence.BoundedSearch\n-- TODO: Maybe more natural to use 𝕟 (finite naturals) instead of ℕ (naturals)?\n\nopen import Data.Boolean\nopen import Data.Boolean.Stmt\nopen import Data.List\nimport Data.List.Functions as List\nopen import Data.List.Relation.Membership using (_∈_)\nopen import Data.List.Relation.Membership.Proofs\nopen import Data.List.Relation.Quantification\nopen import Data.List.Relation.Quantification.Proofs\nopen import Data.List.Sorting\nopen import Data.Option\nimport Data.Option.Functions as Option\nopen import Functional\nopen import Logic.Propositional\nopen import Numeral.Finite\nimport Numeral.Finite.LinearSearch as 𝕟\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.Oper.Comparisons\nopen import Numeral.Natural.Oper.Proofs.Order\nopen import Numeral.Natural.Relation.Order\nopen import Relator.Equals\nopen import Relator.Equals.Proofs.Equiv\nopen import Structure.Function\n\nprivate variable a b n i j : ℕ\nprivate variable f : ℕ → Bool\n\n{-\nopen import Data.Boolean\nopen import Data.Boolean.Stmt\nopen import Data.Option\nimport Data.Option.Functions as Option\nopen import Functional\nopen import Logic\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.Relation.Order\nopen import Structure.Relator.Ordering\n\n-- Finds the maximal argument satisfying the given argument within the given search upper bound by searching linearly.\n-- Examples:\n-- findUpperBoundedMax(10 ∣?_) 5 = None\n-- findUpperBoundedMax(10 ∣?_) 20 = Some 20\n-- findUpperBoundedMax(10 ∣?_) 22 = Some 20\n-- findUpperBoundedMax(10 ∣?_) 100 = Some 100\n-- findUpperBoundedMax(10 ∣?_) 102 = Some 100\nfindUpperBoundedMax : (ℕ → Bool) → ℕ → Option(ℕ)\nfindUpperBoundedMax f(i) with f(i)\nfindUpperBoundedMax f(i) | 𝑇 = Some i\nfindUpperBoundedMax f(𝟎) | 𝐹 = None\nfindUpperBoundedMax f(𝐒(i)) | 𝐹 = findUpperBoundedMax f(i)\n\nfindMaxIndexInRange : (ℕ → Bool) → ℕ → ℕ → Option(ℕ)\nfindMaxIndexInRange f min max = Option.map (_+ min) (findUpperBoundedMax (f ∘ (_+ min)) (max −₀ min))\n\n-- Finds the minimal argument satisfying the given argument within the given search upper bound by searching linearly.\n-- Examples:\n-- findUpperBoundedMin(10 ∣?_) 5 = None\n-- findUpperBoundedMin(10 ∣?_) 20 = Some 10\n-- findUpperBoundedMin(10 ∣?_) 22 = Some 10\n-- findUpperBoundedMin(10 ∣?_) 100 = Some 10\n-- findUpperBoundedMax(10 ∣?_) 102 = Some 10\nfindUpperBoundedMin : (ℕ → Bool) → ℕ → Option(ℕ)\nfindUpperBoundedMin f(i) with f(𝟎)\nfindUpperBoundedMin f(i) | 𝑇 = Some 𝟎\nfindUpperBoundedMin f(𝟎) | 𝐹 = None\nfindUpperBoundedMin f(𝐒(i)) | 𝐹 = Option.map 𝐒 (findUpperBoundedMin (f ∘ 𝐒)(i))\n\nopen import Data\nopen import Data.Boolean.Stmt.Proofs\nopen import Data.Option.Equiv.Id\nopen import Lang.Inspect\nopen import Logic.Predicate\nopen import Logic.Propositional\nopen import Numeral.Natural.Oper.Proofs\nopen import Numeral.Natural.Relation.Order.Proofs\nopen import Relator.Equals\nopen import Relator.Equals.Proofs.Equiv\nopen import Structure.Function.Domain\nopen import Structure.Relator.Properties\nopen import Structure.Relator\n\nfindUpperBoundedMax-correctness : ∀{f}{max i} → (findUpperBoundedMax f(max) ≡ Some(i)) → ((i ≤ max) ∧ IsTrue(f(i)))\nfindUpperBoundedMax-correctness {f} {max} {i} p with f(max) | inspect f(max)\nfindUpperBoundedMax-correctness {f} {max} {.max} [≡]-intro | 𝑇 | intro eq = [∧]-intro (reflexivity(_≤_)) (substitute₁ₗ(IsTrue) eq <>)\nfindUpperBoundedMax-correctness {f} {𝟎} {i} () | 𝐹 | _\nfindUpperBoundedMax-correctness {f} {𝐒(max)} {i} p | 𝐹 | intro eq with findUpperBoundedMax-correctness {f} {max} {i} p\n... | [∧]-intro a b = [∧]-intro ([≤]-successor a) b\n\nfindUpperBoundedMin-correctness : ∀{f}{max i} → (findUpperBoundedMin f(max) ≡ Some(i)) → ((i ≤ max) ∧ IsTrue(f(i)))\nfindUpperBoundedMin-correctness {f} {max} {i} p with f(𝟎) | inspect f(𝟎)\nfindUpperBoundedMin-correctness {f} {max} {.𝟎} [≡]-intro | 𝑇 | intro eq = [∧]-intro [≤]-minimum ([↔]-to-[←] IsTrue.is-𝑇 eq)\nfindUpperBoundedMin-correctness {f} {𝐒 max} {𝟎} p | 𝐹 | intro eq with findUpperBoundedMin (f ∘ 𝐒) max\nfindUpperBoundedMin-correctness {f} {𝐒 max} {𝟎} () | 𝐹 | intro eq | None\nfindUpperBoundedMin-correctness {f} {𝐒 max} {𝟎} () | 𝐹 | intro eq | Some _\nfindUpperBoundedMin-correctness {f} {𝐒 max} {𝐒 i} p | 𝐹 | intro eq = [∧]-map (\\p → [≤]-with-[𝐒] ⦃ p ⦄) id (findUpperBoundedMin-correctness {f ∘ 𝐒} {max} {i} (injective(Option.map 𝐒) ⦃ map-injectivity ⦄ p))\n\nfindUpperBoundedMin-minimal : ∀{f}{max i j} → (findUpperBoundedMin f(max) ≡ Some(i)) → IsTrue(f(j)) → (i ≤ j)\nfindUpperBoundedMin-minimal {i = 𝟎} {_} p q = [≤]-minimum\nfindUpperBoundedMin-minimal {i = 𝐒 i} {𝟎} p q = {!!}\nfindUpperBoundedMin-minimal {i = 𝐒 i} {𝐒 j} p q = [≤]-with-[𝐒] ⦃ findUpperBoundedMin-minimal {i = i}{j} {!!} q ⦄\n\n-- foldRange : ()\n\n{-\nsearchUntilUpperBound : (f : ℕ → Bool) → ∃(IsTrue ∘ f) → ℕ\nsearchUntilUpperBound f ([∃]-intro upperBound ⦃ proof ⦄) = {!fold!}\n\nsearchUntilUpperBoundProof : ∀{f}{upperBound} → (IsTrue ∘ f)(searchUntilUpperBound f upperBound)\nsearchUntilUpperBoundProof = {!!}\n\nbruteforceMinExistence : ∀{ℓ} → (P : ℕ → Stmt{ℓ}) → ⦃ ComputablyDecidable(P) ⦄ → ∃(P) → ∃(Weak.Properties.MinimumOf(_≤_)(P))\n∃.witness (bruteforceMinExistence P upperBound) = {!!}\n∃.proof (bruteforceMinExistence P upperBound) = {!!}\n-}\n-}\n", "meta": {"hexsha": "2ca1cda55d54f80972ee2282565b7767d15ef288", "size": 5467, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/LinearSearchDecidable.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/LinearSearchDecidable.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/LinearSearchDecidable.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.5583333333, "max_line_length": 213, "alphanum_fraction": 0.7106274008, "num_tokens": 1881, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8499711642563823, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.6187581348404266}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Numbers.Naturals.Definition\n\nmodule Numbers.Integers.Definition where\n\ndata ℤ : Set where\n nonneg : ℕ → ℤ\n negSucc : ℕ → ℤ\n{-# BUILTIN INTEGER ℤ #-}\n{-# BUILTIN INTEGERPOS nonneg #-}\n{-# BUILTIN INTEGERNEGSUC negSucc #-}\n\nnonnegInjective : {a b : ℕ} → nonneg a ≡ nonneg b → a ≡ b\nnonnegInjective refl = refl\n\nnegSuccInjective : {a b : ℕ} → negSucc a ≡ negSucc b → a ≡ b\nnegSuccInjective refl = refl\n\nℤDecideEquality : (a b : ℤ) → ((a ≡ b) || ((a ≡ b) → False))\nℤDecideEquality (nonneg x) (nonneg y) with ℕDecideEquality x y\nℤDecideEquality (nonneg x) (nonneg y) | inl eq = inl (applyEquality nonneg eq)\nℤDecideEquality (nonneg x) (nonneg y) | inr non = inr λ i → non (nonnegInjective i)\nℤDecideEquality (nonneg x) (negSucc y) = inr λ ()\nℤDecideEquality (negSucc x) (nonneg x₁) = inr λ ()\nℤDecideEquality (negSucc x) (negSucc y) with ℕDecideEquality x y\nℤDecideEquality (negSucc x) (negSucc y) | inl eq = inl (applyEquality negSucc eq)\nℤDecideEquality (negSucc x) (negSucc y) | inr non = inr λ i → non (negSuccInjective i)\n", "meta": {"hexsha": "5db7fe32675fac185ac2ea21663b28a11da49637", "size": 1132, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numbers/Integers/Definition.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Numbers/Integers/Definition.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Numbers/Integers/Definition.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 37.7333333333, "max_line_length": 86, "alphanum_fraction": 0.6872791519, "num_tokens": 414, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711604559846, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.6187581320738305}} {"text": "{-# OPTIONS --allow-unsolved-metas --warning=error --without-K --guardedness #-}\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import Setoids.Setoids\nopen import Rings.Definition\nopen import Rings.Lemmas\nopen import Rings.Orders.Partial.Definition\nopen import Rings.Orders.Total.Definition\nopen import Groups.Definition\nopen import Groups.Groups\nopen import Fields.Fields\nopen import Sets.EquivalenceRelations\nopen import Sequences\nopen import Setoids.Orders.Partial.Definition\nopen import Setoids.Orders.Total.Definition\nopen import Functions.Definition\nopen import LogicalFormulae\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\n\nmodule Fields.CauchyCompletion.Field {m n o : _} {A : Set m} {S : Setoid {m} {n} A} {_+_ : A → A → A} {_*_ : A → A → A} {_<_ : Rel {m} {o} A} {pOrder : SetoidPartialOrder S _<_} {R : Ring S _+_ _*_} {pRing : PartiallyOrderedRing R pOrder} (order : TotallyOrderedRing pRing) (F : Field R) where\n\nopen Setoid S\nopen PartiallyOrderedRing pRing\nopen SetoidPartialOrder pOrder\nopen Equivalence eq\nopen SetoidTotalOrder (TotallyOrderedRing.total order)\nopen Field F\nopen Group (Ring.additiveGroup R)\n\nopen import Rings.Orders.Total.Cauchy order\nopen import Rings.Orders.Total.Lemmas order\nopen import Rings.Orders.Total.AbsoluteValue order\nopen import Fields.CauchyCompletion.Definition order F\nopen import Fields.CauchyCompletion.Multiplication order F\nopen import Fields.CauchyCompletion.Addition order F\nopen import Fields.CauchyCompletion.Setoid order F\nopen import Fields.CauchyCompletion.Group order F\nopen import Fields.CauchyCompletion.Ring order F\nopen import Fields.CauchyCompletion.Comparison order F\n\nCnontrivial : (pr : Setoid._∼_ cauchyCompletionSetoid (injection (Ring.0R R)) (injection (Ring.1R R))) → False\nCnontrivial pr with pr (Ring.1R R) (0<1 nontrivial)\nCnontrivial pr | N , b with b {succ N} (le 0 refl)\n... | bl rewrite indexAndApply (constSequence 0G) (map inverse (constSequence (Ring.1R R))) _+_ {N} | indexAndConst 0G N | equalityCommutative (mapAndIndex (constSequence (Ring.1R R)) inverse N) | indexAndConst (Ring.1R R) N = irreflexive {Ring.1R R} (; +-∸-assoc; ∸-mono)\nopen import Data.Nat.Properties\nopen import Data.Fin using (Fin)\n renaming (zero to Fzero; suc to Fsuc; toℕ to F→N; fromℕ≤ to N→F)\nopen import Data.Fin.Properties using (bounded)\nopen import Function\nopen import Relation.Nullary\n-- open import Relation.Nullary.Decidable using (True; False; toWitness; toWitnessFalse; fromWitness; fromWitnessFalse)\n\nopen import Relation.Binary.PropositionalEquality as PropEq\n using (_≡_; _≢_; refl; cong; sym; trans; inspect)\nopen PropEq.≡-Reasoning\nopen import Relation.Binary\n\nℕ-isDecTotalOrder = DecTotalOrder.isDecTotalOrder decTotalOrder\nℕ-isTotalOrder = IsDecTotalOrder.isTotalOrder ℕ-isDecTotalOrder\nℕ-isPartialOrder = IsTotalOrder.isPartialOrder ℕ-isTotalOrder\nℕ-isPreorder = IsPartialOrder.isPreorder ℕ-isPartialOrder\n≤-refl = IsPreorder.reflexive ℕ-isPreorder\n≤-antisym = IsPartialOrder.antisym ℕ-isPartialOrder\n≤-total = IsTotalOrder.total ℕ-isTotalOrder\n\n\ndata Digit : (base : ℕ) → Set where\n D : ∀ {base} → Fin base → Digit base\n\ninfixl 6 _D+_\n\n_D+_ : ∀ {b} → Digit b → Digit b → Digit b\nD x D+ D {b} y with b ≤? (F→N x + F→N y)\nD x D+ D {b} y | yes p = D $ N→F {F→N x + F→N y ∸ b} $\n start\n suc (F→N x + F→N y ∸ b)\n ≤⟨ ≤-refl (sym (+-∸-assoc 1 p)) ⟩\n (suc (F→N x) + F→N y) ∸ b\n ≤⟨ ∸-mono {suc (F→N x) + F→N y} {b + b} {b} {b} (bounded x +-mono (\n start\n F→N y\n ≤⟨ n≤1+n (F→N y) ⟩\n suc (F→N y)\n ≤⟨ bounded y ⟩\n b\n □\n )) (≤-refl refl) ⟩\n b + b ∸ b\n ≤⟨ ≤-refl (m+n∸n≡m b b) ⟩\n b\n □\nD x D+ D {b} y | no ¬p = D $ N→F (≰⇒> ¬p)\n\n-- start\n-- {! !}\n-- ≤⟨ {! !} ⟩\n-- {! !}\n-- ≤⟨ {! !} ⟩\n-- {! !}\n-- ≤⟨ {! !} ⟩\n-- {! !}\n-- ≤⟨ {! !} ⟩\n-- {! !}\n-- □\n\n-- begin\n-- {! !}\n-- ≡⟨ {! !} ⟩\n-- {! !}\n-- ≡⟨ {! !} ⟩\n-- {! !}\n-- ≡⟨ {! !} ⟩\n-- {! !}\n-- ≡⟨ {! !} ⟩\n-- {! !}\n-- ∎\n", "meta": {"hexsha": "af7255a4e407aeb96bd20a3b0b95c5b9c3e69197", "size": 2139, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Num/Sandbox/_Standard.agda", "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_issues_repo_path": "Data/Num/Sandbox/_Standard.agda", "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Num/Sandbox/_Standard.agda", "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "avg_line_length": 26.7375, "max_line_length": 119, "alphanum_fraction": 0.5189340813, "num_tokens": 836, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289387998695209, "lm_q2_score": 0.7461389817407016, "lm_q1q2_score": 0.6185035520600035}} {"text": "open import Relation.Binary using (Rel; Setoid; IsEquivalence)\n\nmodule GGT.Structures\n {a b ℓ₁ ℓ₂}\n {G : Set a} -- The underlying group carrier\n {Ω : Set b} -- The underlying set space\n (_≈_ : Rel G ℓ₁) -- The underlying group equality\n (_≋_ : Rel Ω ℓ₂) -- The underlying space equality\n where\n\nopen import Level using (_⊔_)\nopen import Algebra.Core\nopen import Algebra.Structures {a} {ℓ₁} {G} using (IsGroup)\nopen import GGT.Definitions\n\nrecord IsAction\n (· : Opᵣ G Ω)\n (∙ : Op₂ G)\n (ε : G)\n (⁻¹ : Op₁ G)\n : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂)\n where\n\n field\n isEquivalence : IsEquivalence _≋_\n isGroup : IsGroup _≈_ ∙ ε ⁻¹\n actAssoc : ActAssoc _≈_ _≋_ · ∙\n actId : ActLeftIdentity _≈_ _≋_ ε ·\n ·-cong : ·-≋-Congruence _≈_ _≋_ ·\n G-ext : ≈-Ext _≈_ _≋_ ·\n\n setoid : Setoid b ℓ₂\n setoid = record\n { Carrier = Ω;\n _≈_ = _≋_;\n isEquivalence = isEquivalence }\n", "meta": {"hexsha": "25fd6560135285a52d92c864259fbeb554e25f10", "size": 932, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/ggt/Structures.agda", "max_stars_repo_name": "zampino/ggt", "max_stars_repo_head_hexsha": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-04-17T11:10:00.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-28T05:48:39.000Z", "max_issues_repo_path": "src/ggt/Structures.agda", "max_issues_repo_name": "zampino/ggt", "max_issues_repo_head_hexsha": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/ggt/Structures.agda", "max_forks_repo_name": "zampino/ggt", "max_forks_repo_head_hexsha": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.1891891892, "max_line_length": 62, "alphanum_fraction": 0.589055794, "num_tokens": 364, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9343951698485603, "lm_q2_score": 0.6619228691808011, "lm_q1q2_score": 0.618497531774841}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Container combinators\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Container.Combinator where\n\nopen import Level using (Level; _⊔_; Lift)\nopen import Data.Empty using (⊥)\nopen import Data.Product as P using (_,_; proj₁; proj₂; ∃)\nopen import Data.Sum.Base as S using ([_,_]′)\nopen import Data.Unit.Base using (⊤)\nimport Function as F\n\nopen import Data.Container.Core\nopen import Data.Container.Relation.Unary.Any\n\n------------------------------------------------------------------------\n-- Combinators\n\nmodule _ {s p : Level} where\n\n-- Identity.\n\n id : Container s p\n id .Shape = Lift s ⊤\n id .Position = F.const (Lift p ⊤)\n\n-- Constant.\n\n const : Set s → Container s p\n const X .Shape = X\n const X .Position = F.const (Lift p ⊥)\n\n-- Composition.\n\ninfixr 9 _∘_\n\n_∘_ : ∀ {s₁ s₂ p₁ p₂} → Container s₁ p₁ → Container s₂ p₂ →\n Container (s₁ ⊔ s₂ ⊔ p₁) (p₁ ⊔ p₂)\n(C₁ ∘ C₂) .Shape = ⟦ C₁ ⟧ (Shape C₂)\n(C₁ ∘ C₂) .Position = ◇ C₁ (Position C₂)\n\n-- Product. (Note that, up to isomorphism, this is a special case of\n-- indexed product.)\n\ninfixr 2 _×_\n\n_×_ : ∀ {s₁ s₂ p₁ p₂} → Container s₁ p₁ → Container s₂ p₂ →\n Container (s₁ ⊔ s₂) (p₁ ⊔ p₂)\n(C₁ × C₂) .Shape = Shape C₁ P.× Shape C₂\n(C₁ × C₂) .Position = P.uncurry λ s₁ s₂ → (Position C₁ s₁) S.⊎ (Position C₂ s₂)\n\n-- Indexed product.\n\nΠ : ∀ {i s p} (I : Set i) → (I → Container s p) → Container (i ⊔ s) (i ⊔ p)\nΠ I C .Shape = ∀ i → Shape (C i)\nΠ I C .Position = λ s → ∃ λ i → Position (C i) (s i)\n\n-- Constant exponentiation. (Note that this is a special case of\n-- indexed product.)\n\ninfix 0 const[_]⟶_\n\nconst[_]⟶_ : ∀ {i s p} → Set i → Container s p → Container (i ⊔ s) (i ⊔ p)\nconst[ X ]⟶ C = Π X (F.const C)\n\n-- Sum. (Note that, up to isomorphism, this is a special case of\n-- indexed sum.)\n\ninfixr 1 _⊎_\n\n_⊎_ : ∀ {s₁ s₂ p} → Container s₁ p → Container s₂ p → Container (s₁ ⊔ s₂) p\n(C₁ ⊎ C₂) .Shape = (Shape C₁ S.⊎ Shape C₂)\n(C₁ ⊎ C₂) .Position = [ Position C₁ , Position C₂ ]′\n\n-- Indexed sum.\n\nΣ : ∀ {i s p} (I : Set i) → (I → Container s p) → Container (i ⊔ s) p\nΣ I C .Shape = ∃ λ i → Shape (C i)\nΣ I C .Position = λ s → Position (C (proj₁ s)) (proj₂ s)\n", "meta": {"hexsha": "2d8f8d4034f314af9d3f2e70096e88af96e6f726", "size": 2325, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Container/Combinator.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Container/Combinator.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Container/Combinator.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 27.3529411765, "max_line_length": 79, "alphanum_fraction": 0.5505376344, "num_tokens": 805, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424528443251, "lm_q2_score": 0.731058584489497, "lm_q1q2_score": 0.6184334921359455}} {"text": "{-# OPTIONS --without-K #-}\n-- Two equivalent approached to define the advantage in\n-- a (bit) guessing game\nopen import Data.Two\nopen import Data.Nat.NP hiding (_==_)\nopen import Data.Nat.Distance\nopen import Data.Product.NP\n\nopen import Function\n\nopen import Explore.Core\nopen import Explore.Properties\nopen import Explore.Summable\nopen import Explore.Sum\nopen import Explore.Product\nopen import Explore.Two\n\nopen import Relation.Binary.PropositionalEquality.NP\n\nmodule Explore.GuessingGameFlipping\n (R : Set)(sum : Sum R)(sum-ind : SumInd sum)(⅁ : 𝟚 → R → 𝟚) where\n open Operators\n X Y : R → 𝟚\n X = ⅁ 0₂\n Y = ⅁ 1₂\n R' = 𝟚 × R\n sum' : Sum R'\n sum' = 𝟚ˢ ×ˢ sum\n\n open FromSum sum' renaming (count to #'_)\n open FromSumInd sum-ind renaming (count to #_)\n\n G : R' → 𝟚\n G (b , r) = b == ⅁ b r\n\n 1/2 : R' → 𝟚\n 1/2 = fst\n\n -- TODO use the library\n lemma : ∀ X → sum (const 1) ≡ #(not ∘ X) + # X\n lemma X = sum-ind P refl (λ {a}{b} → part1 {a}{b}) part2\n where\n count = FromSum.count\n\n P = λ s → s (const 1) ≡ count s (not ∘ X) + count s X\n\n part1 : ∀ {s₀ s₁} → P s₀ → P s₁ → P (λ f → s₀ f + s₁ f)\n part1 {s₀} {s₁} Ps₀ Ps₁ rewrite Ps₀ | Ps₁ = +-interchange (count s₀ (not ∘ X)) (count s₀ X) (count s₁ (not ∘ X)) (count s₁ X)\n\n part2 : ∀ x → P (λ f → f x)\n part2 x with X x\n part2 x | 0₂ = refl\n part2 x | 1₂ = refl\n\n thm : dist (#' G) (#' 1/2) ≡ dist (# Y) (# X)\n thm = dist (#' G) (#' 1/2)\n ≡⟨ cong (dist (#' G)) helper ⟩\n dist (#' G) (#(not ∘ X) + # X)\n ≡⟨ refl ⟩ -- #' definition\n dist (# (_==_ 0₂ ∘ X) + # (_==_ 1₂ ∘ Y)) (# (not ∘ X) + # X)\n ≡⟨ refl ⟩ -- #' definition\n dist (# (not ∘ X) + # Y) (# (not ∘ X) + # X)\n ≡⟨ dist-x+ (# (not ∘ X)) (# Y) (# X) ⟩\n dist (# Y) (# X)\n ∎\n where\n open ≡-Reasoning\n\n helper = #' 1/2\n ≡⟨ refl ⟩\n sum (const 0) + sum (const 1)\n ≡⟨ cong (λ p → p + sum (const 1)) sum-zero ⟩\n sum (const 1)\n ≡⟨ lemma X ⟩\n # (not ∘ X) + # X\n ∎\n", "meta": {"hexsha": "55b8ad5fa85c3fb7ba5fb4f876202850558c946c", "size": 2096, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lib/Explore/GuessingGameFlipping.agda", "max_stars_repo_name": "crypto-agda/explore", "max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z", "max_issues_repo_path": "lib/Explore/GuessingGameFlipping.agda", "max_issues_repo_name": "crypto-agda/explore", "max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z", "max_forks_repo_path": "lib/Explore/GuessingGameFlipping.agda", "max_forks_repo_name": "crypto-agda/explore", "max_forks_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.2207792208, "max_line_length": 131, "alphanum_fraction": 0.5004770992, "num_tokens": 814, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898178450965, "lm_q2_score": 0.6825737279551493, "lm_q1q2_score": 0.6184048474559342}} {"text": "{-# OPTIONS --cubical --no-exact-split --safe #-}\nmodule Cubical.Data.Nat.Base where\n\nopen import Cubical.Core.Primitives\n\nopen import Agda.Builtin.Nat public\n using (zero; suc; _+_; _*_)\n renaming (Nat to ℕ)\n\npredℕ : ℕ → ℕ\npredℕ zero = 0\npredℕ (suc n) = n\n\ncaseNat : ∀ {ℓ} → {A : Type ℓ} → (a0 aS : A) → ℕ → A\ncaseNat a0 aS 0 = a0\ncaseNat a0 aS (suc n) = aS\n\ndoubleℕ : ℕ → ℕ\ndoubleℕ 0 = 0\ndoubleℕ (suc x) = suc (suc (doubleℕ x))\n\n-- doublesℕ n m = 2^n * m\ndoublesℕ : ℕ → ℕ → ℕ\ndoublesℕ 0 m = m\ndoublesℕ (suc n) m = doublesℕ n (doubleℕ m)\n\n-- iterate\niter : ∀ {ℓ} {A : Type ℓ} → ℕ → (A → A) → A → A\niter zero f z = z\niter (suc n) f z = f (iter n f z)\n", "meta": {"hexsha": "71d01c34189dba51f2508e281646f7bb47aeadc9", "size": 665, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/Nat/Base.agda", "max_stars_repo_name": "cj-xu/cubical", "max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/Nat/Base.agda", "max_issues_repo_name": "cj-xu/cubical", "max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Data/Nat/Base.agda", "max_forks_repo_name": "cj-xu/cubical", "max_forks_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.4516129032, "max_line_length": 52, "alphanum_fraction": 0.584962406, "num_tokens": 292, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835534888481, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.6184035061976985}} {"text": "------------------------------------------------------------------------------\n-- From ListP as the least fixed-point to ListP using data\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- We want to represent the polymorphic total lists data type\n--\n-- data ListP (A : D → Set) : D → Set where\n-- lnil : ListP A []\n-- lcons : ∀ {x xs} → A x → ListP A xs → ListP A (x ∷ xs)\n--\n-- using the representation of ListP as the least fixed-point.\n\nmodule LFPs.ListP where\n\nopen import FOTC.Base\nopen import FOTC.Base.List\nopen import FOTC.Data.Nat.Type\nopen import FOTC.Data.Nat.UnaryNumbers\n\n------------------------------------------------------------------------------\n-- ListP is a least fixed-point of a functor\n\n-- The functor.\n-- ListPF : (D → Set) → (D → Set) → D → Set\n-- ListPF A B xs = xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] A x' ∧ xs ≡ x' ∷ xs' ∧ B xs')\n\n-- ListP is the least fixed-point of ListPF.\npostulate\n ListP : (D → Set) → D → Set\n\n -- ListP is a pre-fixed point of ListPF.\n --\n -- Peter: It corresponds to the introduction rules.\n ListP-in :\n (A : D → Set) →\n ∀ {xs} → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] A x' ∧ xs ≡ x' ∷ xs' ∧ ListP A xs') →\n ListP A xs\n\n -- ListP is the least pre-fixed point of ListPF.\n --\n -- Peter: It corresponds to the elimination rule of an inductively\n -- defined predicate.\n ListP-ind :\n (A B : D → Set) →\n (∀ {xs} → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] A x' ∧ xs ≡ x' ∷ xs' ∧ B xs') → B xs) →\n ∀ {xs} → ListP A xs → B xs\n\n------------------------------------------------------------------------------\n-- The data constructors of ListP.\nlnil : (A : D → Set) → ListP A []\nlnil A = ListP-in A (inj₁ refl)\n\nlcons : (A : D → Set) → ∀ {x xs} → A x → ListP A xs → ListP A (x ∷ xs)\nlcons A {n} {ns} An LPns = ListP-in A (inj₂ (n , ns , An , refl , LPns))\n\n------------------------------------------------------------------------------\n-- The induction principle for ListP.\nListP-ind' : (A B : D → Set) →\n B [] →\n (∀ x {xs} → A x → B xs → B (x ∷ xs)) →\n ∀ {xs} → ListP A xs → B xs\nListP-ind' A B B[] is = ListP-ind A B prf\n where\n prf : ∀ {xs} →\n xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] A x' ∧ xs ≡ x' ∷ xs' ∧ B xs') →\n B xs\n prf (inj₁ xs≡[]) = subst B (sym xs≡[]) B[]\n prf (inj₂ (x' , xs' , Ax' , h₁ , Bxs')) = subst B (sym h₁) (is x' Ax' Bxs')\n\n------------------------------------------------------------------------------\n-- Examples\n\n-- \"Heterogeneous\" total lists\nxs : D\nxs = 0' ∷ true ∷ 1' ∷ false ∷ []\n\nList : D → Set\nList = ListP (λ d → d ≡ d)\n\nxs-ListP : List xs\nxs-ListP =\n lcons A refl (lcons A refl (lcons A refl (lcons A refl (lnil A))))\n where\n A : D → Set\n A d = d ≡ d\n\n-- Total lists of total natural numbers\nys : D\nys = 0' ∷ 1' ∷ 2' ∷ []\n\nListN : D → Set\nListN = ListP N\n\nys-ListP : ListN ys\nys-ListP =\n lcons N nzero (lcons N (nsucc nzero) (lcons N (nsucc (nsucc nzero)) (lnil N)))\n", "meta": {"hexsha": "7d8d8f04d91a3ad233282e93288d8cee8b92d5a0", "size": 3115, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/fixed-points/LFPs/ListP.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/fixed-points/LFPs/ListP.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/fixed-points/LFPs/ListP.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 30.5392156863, "max_line_length": 81, "alphanum_fraction": 0.449117175, "num_tokens": 1010, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835330070838, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.6184034958261718}} {"text": "{-# OPTIONS --allow-unsolved-metas #-}\n\nopen import Tutorials.Monday-Complete\nopen import Tutorials.Tuesday\nopen List using (List; []; _∷_; _++_)\nopen Vec using (Vec; []; _∷_; _!_)\nopen Fin using (Fin; zero; suc)\nmodule Tutorials.Wednesday where\n\n-----------\n-- Interfaces, isomorphisms\n-----------\n\nmodule Isomorphism where\n -- Why can we import _,_ from both modules without resulting in a nameclash?\n open Simple using (_⊎_; _×_; _,_; inl; inr)\n open Product using (Σ-syntax; Σ-⊎; Σ-×; Π-×; Π-→; _,_)\n\n infix 2 _≅_\n record _≅_ (A B : Set) : Set where\n constructor Mk≅\n field\n to : A → B\n from : B → A\n from∘to : ∀ a → from (to a) ≡ a\n to∘from : ∀ b → to (from b) ≡ b\n\n open _≅_\n\n -- We can use copattern matching to construct a record by defining how to construct each of its fields\n Σ-⊎-≅ : Σ-⊎ A B ≅ A ⊎ B\n Σ-⊎-≅ = {!!}\n\n Σ-×-≅ : Σ-× A B ≅ A × B\n Σ-×-≅ = {!!}\n\n Π-→-≅ : Π-→ A B ≅ (A → B)\n to Π-→-≅ = {!!}\n from Π-→-≅ = {!!}\n -- Needs η laws for functions (∀ x → f x) ≡ f\n from∘to Π-→-≅ = {!!}\n to∘from Π-→-≅ = {!!}\n\n -- The following isomorphism needs of function extensionality\n -- Function extensionality claims that if two functions give the same output on the same input, then they are equal\n -- This does not hold internally in Agda and we therefore need to postulate it as an axiom\n postulate\n extensionality : {P : A → Set} {f g : (a : A) → P a} → (∀ x → f x ≡ g x) → f ≡ g\n\n Π-×-≅ : Π-× A B ≅ A × B\n Π-×-≅ = {!!}\n\n curry : Π-→ A (Π-→ B C) → Π-→ (Σ-× A B) C\n curry f (a , b) = f a b\n\n uncurry : Π-→ (Σ-× A B) C → Π-→ A (Π-→ B C)\n uncurry f a b = f (a , b)\n\n curry-uncurry : Π-→ A (Π-→ B C) ≅ Π-→ (Σ-× A B) C\n curry-uncurry = {!!}\n\n Fin-≤-≅ : Fin m ≅ Σ[ n ∈ ℕ ] n < m\n Fin-≤-≅ = {!!}\n\n _iso-∘_ : B ≅ C → A ≅ B → A ≅ C\n x iso-∘ y = {!!}\n\n-----------\n-- Decidability\n-----------\n\nmodule Dec where\n open Product using (_×_; _,_; fst; snd)\n open Simple using (¬_)\n\n data Dec (A : Set) : Set where\n yes : A → Dec A\n no : ¬ A → Dec A\n\n DecEq : Set → Set\n DecEq A = (x y : A) → Dec (x ≡ y)\n\n map : (A → B) → (¬ A → B) → Dec A → B\n map f g (yes x) = f x\n map f g (no x) = g x\n\n infix 5 _×-dec_\n _×-dec_ : Dec A → Dec B → Dec (A × B)\n yes x ×-dec yes y = yes (x , y)\n yes x ×-dec no ¬y = no (¬y ∘ snd)\n no ¬x ×-dec B? = no (¬x ∘ fst)\n\n _ℕ-≟_ : (n m : ℕ) → Dec (n ≡ m)\n n ℕ-≟ m = {!!}\n\n suc-injective : {i j : Fin n} → _≡_ {A = Fin (suc n)} (suc i) (suc j) → i ≡ j\n suc-injective refl = refl\n\n _Fin-≟_ : (i j : Fin n) → Dec (i ≡ j)\n zero Fin-≟ zero = yes refl\n zero Fin-≟ suc j = no λ ()\n suc i Fin-≟ zero = no λ ()\n suc i Fin-≟ suc j = map\n (yes ∘ cong suc)\n (no ∘ (λ neq → neq ∘ suc-injective))\n (i Fin-≟ j)\n\n ∷-injective : {x y : A} {xs ys : List A} → _≡_ {A = List A} (x ∷ xs) (y ∷ ys) → x ≡ y × xs ≡ ys\n ∷-injective refl = refl , refl\n\n List-≟ : (_A-≟_ : (x y : A) → Dec (x ≡ y)) → (xs ys : List A) → Dec (xs ≡ ys)\n List-≟ _A-≟_ [] [] = yes refl\n List-≟ _A-≟_ [] (y ∷ ys) = no λ ()\n List-≟ _A-≟_ (x ∷ xs) [] = no λ ()\n List-≟ _A-≟_ (x ∷ xs) (y ∷ ys) = map\n (yes ∘ Isomorphism.curry (cong₂ _∷_))\n (no ∘ (λ neq → neq ∘ ∷-injective))\n (x A-≟ y ×-dec List-≟ _A-≟_ xs ys)\n\n-----------\n-- Interfaces\n-----------\n\n-- We define what it is to be a monoid on a carrier set C\nrecord Monoid (C : Set) : Set where\n constructor MkMonoid\n field\n ε : C\n _∙_ : C → C → C\n -- Including the algebraic laws\n idˡ : (x : C) → ε ∙ x ≡ x\n idʳ : (x : C) → x ∙ ε ≡ x\n assoc : (x y z : C) → (x ∙ y) ∙ z ≡ x ∙ (y ∙ z)\n\nmodule MonoidSolver (Symbol : Set) (symbol-≟ : Dec.DecEq Symbol) where\n -- The syntax for an expression tree of symbolic monoidal operations\n infixl 20 _‵∙_\n infix 25 ‵_\n data Expr : Set where\n ‵ε : Expr\n ‵_ : Symbol → Expr\n _‵∙_ : Expr → Expr → Expr\n\n -- And define equations on monoids\n infix 10 _‵≡_\n record Eqn : Set where\n constructor _‵≡_\n field\n lhs : Expr\n rhs : Expr\n\n -- The canonical normal form for expression trees\n NormalForm : Set\n NormalForm = List Symbol\n\n normalise : Expr → NormalForm\n normalise ‵ε = []\n normalise (‵ x) = x ∷ []\n normalise (xs ‵∙ ys) = normalise xs ++ normalise ys\n\n module Eval (M : Monoid C) where\n open Monoid M\n\n -- An environment maps symbols to values in the carrier set\n Env : Set\n Env = Symbol → C\n\n -- Evaluate the syntax in a given environment\n ⟦_⟧ : Expr → Env → C\n ⟦ ‵ε ⟧ Γ = ε\n ⟦ ‵ x ⟧ Γ = Γ x\n ⟦ x ‵∙ y ⟧ Γ = ⟦ x ⟧ Γ ∙ ⟦ y ⟧ Γ\n\n -- Evaluate the normal form in a given environment\n ⟦_⟧⇓ : NormalForm → Env → C\n ⟦ [] ⟧⇓ Γ = ε\n ⟦ x ∷ xs ⟧⇓ Γ = Γ x ∙ ⟦ xs ⟧⇓ Γ\n\n -- The evaluation of normal forms distributes over list concatenation\n ++-homo : ∀ Γ (xs ys : NormalForm) → ⟦ xs ++ ys ⟧⇓ Γ ≡ ⟦ xs ⟧⇓ Γ ∙ ⟦ ys ⟧⇓ Γ\n ++-homo Γ [] ys = sym (idˡ _)\n ++-homo Γ (x ∷ xs) ys = begin\n Γ x ∙ ⟦ xs ++ ys ⟧⇓ Γ\n ≡⟨ cong (_ ∙_) (++-homo Γ xs ys) ⟩\n Γ x ∙ (⟦ xs ⟧⇓ Γ ∙ ⟦ ys ⟧⇓ Γ)\n ≡⟨ sym (assoc _ _ _) ⟩\n (Γ x ∙ ⟦ xs ⟧⇓ Γ) ∙ ⟦ ys ⟧⇓ Γ\n ∎\n\n -- Normalising and then evaluating the normal form is equal to evaluating the original expression\n correct : ∀ Γ (expr : Expr) → ⟦ normalise expr ⟧⇓ Γ ≡ ⟦ expr ⟧ Γ\n correct Γ ‵ε = refl\n correct Γ (‵ x) = idʳ _\n correct Γ (le ‵∙ re) = begin\n ⟦ normalise le ++ normalise re ⟧⇓ Γ ≡⟨ ++-homo Γ (normalise le) (normalise re) ⟩\n ⟦ normalise le ⟧⇓ Γ ∙ ⟦ normalise re ⟧⇓ Γ ≡⟨ cong₂ _∙_ (correct Γ le) (correct Γ re) ⟩\n ⟦ le ⟧ Γ ∙ ⟦ re ⟧ Γ ∎\n\n -- We describe what it is to be a solution to an equation\n -- If both sides normalise to the same symbols in the same order,\n -- we claim that the monoid laws make the equations hold in any environment\n Solution : Eqn → Set\n Solution (lhs ‵≡ rhs) =\n Dec.map\n -- Both sides normalise to a common list of symbols, we must now show that the equation holds under any environment\n (λ _ → ∀ (Γ : Env) → ⟦ lhs ⟧ Γ ≡ ⟦ rhs ⟧ Γ)\n -- Both sides do *not* normalise to a common list of symbols, we claim only the trivial\n (λ _ → ⊤)\n (Dec.List-≟ symbol-≟ (normalise lhs) (normalise rhs))\n\n -- Now that we have described what a solution is, we show that we can provide one\n solve : (eqn : Eqn) → Solution eqn\n -- Pattern matching using with makes the goal type compute\n solve (lhs ‵≡ rhs) with Dec.List-≟ symbol-≟ (normalise lhs) (normalise rhs)\n solve (lhs ‵≡ rhs) | Dec.no _ = tt\n solve (lhs ‵≡ rhs) | Dec.yes lhs⇓≡rhs⇓ = λ Γ → begin\n ⟦ lhs ⟧ Γ ≡⟨ sym (correct Γ lhs) ⟩\n ⟦ normalise lhs ⟧⇓ Γ ≡⟨ cong (λ ● → ⟦ ● ⟧⇓ Γ) lhs⇓≡rhs⇓ ⟩\n ⟦ normalise rhs ⟧⇓ Γ ≡⟨ correct Γ rhs ⟩\n ⟦ rhs ⟧ Γ ∎\n\nopen MonoidSolver\n\n-- An example instance of a monoid: natural numbers with addition\nNAT-MONOID : Monoid ℕ\nMonoid.ε NAT-MONOID = zero\nMonoid._∙_ NAT-MONOID = _+_\nMonoid.idˡ NAT-MONOID = +-idˡ\nMonoid.idʳ NAT-MONOID = +-idʳ\nMonoid.assoc NAT-MONOID = +-assoc\n\n-- An example usage of the monoid solver\n-- We first need to \"quote\" the goal, i.e. describe it in terms of the expression language / syntax\n-- NAT-MONOID describes how to interpret the syntax back and evaluate the expression into a value of the carrier set\neqn₁-auto : (x y z : ℕ) → (0 + x) + y + (y + z) ≡ x + (0 + y + 0) + (y + z + 0)\neqn₁-auto x y z =\n let\n ‵x = zero\n ‵y = suc zero\n ‵z = suc (suc zero)\n lhs = (‵ε ‵∙ ‵ ‵x) ‵∙ ‵ ‵y ‵∙ (‵ ‵y ‵∙ ‵ ‵z)\n rhs = ‵ ‵x ‵∙ (‵ε ‵∙ ‵ ‵y ‵∙ ‵ε) ‵∙ (‵ ‵y ‵∙ ‵ ‵z ‵∙ ‵ε)\n in\n Eval.solve (Fin 3) Dec._Fin-≟_ NAT-MONOID (lhs ‵≡ rhs) λ where\n zero → x\n (suc zero) → y\n (suc (suc zero)) → z\n", "meta": {"hexsha": "2e99df9de532ca0021bdb82c2ac3f6543e323c99", "size": 7638, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Tutorials/Wednesday.agda", "max_stars_repo_name": "poncev/agda-bcam", "max_stars_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2021-09-23T17:59:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-03T22:53:51.000Z", "max_issues_repo_path": "Tutorials/Wednesday.agda", "max_issues_repo_name": "poncev/agda-bcam", "max_issues_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Tutorials/Wednesday.agda", "max_forks_repo_name": "poncev/agda-bcam", "max_forks_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-11-23T08:50:13.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-24T10:50:55.000Z", "avg_line_length": 30.7983870968, "max_line_length": 123, "alphanum_fraction": 0.5305053679, "num_tokens": 3181, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375734, "lm_q2_score": 0.760650658103136, "lm_q1q2_score": 0.6183080602636812}} {"text": "open import Data.Sum using (_⊎_; inj₁; inj₂)\nopen import Data.List using (List; []; _∷_; [_]; _++_)\nopen import Data.List.Any using (Any; here; there)\nopen import Data.List.Any.Membership.Propositional using (_∈_)\nopen import Data.Nat using (ℕ)\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl)\n-- open import Data.List.Any.Membership.Propositional.Properties using (∈-++⁺ˡ; ∈-++⁺ʳ; ∈-++⁻)\n\nId = ℕ\n\n_⊆_ : List Id → List Id → Set\nxs ⊆ ys = ∀ {w} → w ∈ xs → w ∈ ys\n\nlemma : ∀ {x : Id} → x ∈ [ x ]\nlemma = here refl\n", "meta": {"hexsha": "697dca35087c7711af76b2f0b8a5f7493fd1c802", "size": 531, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "extra/extra/Membership.agda", "max_stars_repo_name": "manikdv/plfa.github.io", "max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1003, "max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z", "max_issues_repo_path": "extra/extra/Membership.agda", "max_issues_repo_name": "manikdv/plfa.github.io", "max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 323, "max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z", "max_forks_repo_path": "extra/extra/Membership.agda", "max_forks_repo_name": "manikdv/plfa.github.io", "max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 304, "max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z", "avg_line_length": 33.1875, "max_line_length": 94, "alphanum_fraction": 0.6534839925, "num_tokens": 178, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8221891392358015, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.6182965707140674}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- An explanation about how to use the solver in Tactic.MonoidSolver.\n------------------------------------------------------------------------\n\nopen import Algebra\n\nmodule README.Tactic.MonoidSolver {a ℓ} (M : Monoid a ℓ) where\n\nopen Monoid M\n\nopen import Data.Nat as Nat using (ℕ; suc; zero; _+_)\nopen import Data.Nat.Properties as Properties using (+-0-monoid; +-comm)\nopen import Relation.Binary.Reasoning.Setoid setoid\n\nopen import Tactic.MonoidSolver using (solve; solve-macro)\n\n-- The monoid solver is capable to of solving equations without having\n-- to specify the equation itself in the proof.\n\nexample₁ : ∀ x y z → (x ∙ y) ∙ z ≈ x ∙ (y ∙ z) ∙ ε\nexample₁ x y z = solve M\n\n-- The solver can also be used in equational reasoning.\n\nexample₂ : ∀ w x y z → w ≈ x → (w ∙ y) ∙ z ≈ x ∙ (y ∙ z) ∙ ε\nexample₂ w x y z w≈x = begin\n (w ∙ y) ∙ z ≈⟨ ∙-congʳ (∙-congʳ w≈x) ⟩\n (x ∙ y) ∙ z ≈⟨ solve M ⟩\n x ∙ (y ∙ z) ∙ ε ∎\n", "meta": {"hexsha": "530091bc97a85a9a89d7ea42e5b5aa52ffa5ca10", "size": 1032, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/README/Tactic/MonoidSolver.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/README/Tactic/MonoidSolver.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/README/Tactic/MonoidSolver.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 32.25, "max_line_length": 72, "alphanum_fraction": 0.5571705426, "num_tokens": 326, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9149009480320036, "lm_q2_score": 0.6757646140788307, "lm_q1q2_score": 0.6182576860672032}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Categories.Instances.TypePrecategory where\n\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Categories.Category.Precategory\n\nopen Precategory\n\n-- TYPE precategory has types as objects\nmodule _ ℓ where\n TYPE : Precategory (ℓ-suc ℓ) ℓ\n TYPE .ob = Type ℓ\n TYPE .Hom[_,_] A B = A → B\n TYPE .id = λ x → x\n TYPE ._⋆_ f g = λ x → g (f x)\n TYPE .⋆IdL f = refl\n TYPE .⋆IdR f = refl\n TYPE .⋆Assoc f g h = refl\n", "meta": {"hexsha": "41f62ef709d3b05ef63a8bf2b20616547562bc5d", "size": 496, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Instances/TypePrecategory.agda", "max_stars_repo_name": "FernandoLarrain/cubical", "max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z", "max_issues_repo_path": "Cubical/Categories/Instances/TypePrecategory.agda", "max_issues_repo_name": "Seanpm2001-web/cubical", "max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Categories/Instances/TypePrecategory.agda", "max_forks_repo_name": "Seanpm2001-web/cubical", "max_forks_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.8, "max_line_length": 57, "alphanum_fraction": 0.627016129, "num_tokens": 164, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8840392725805823, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.6181683752821326}} {"text": "\nmodule Numeric.Nat.Divide.Properties where\n\nopen import Prelude\nopen import Numeric.Nat.Properties\nopen import Numeric.Nat.DivMod\nopen import Numeric.Nat.Divide\nopen import Tactic.Nat\n\ndivides-add : ∀ {a b d} → d Divides a → d Divides b → d Divides (a + b)\ndivides-add (factor! q) (factor! q₁) = factor (q + q₁) auto\n\ndivides-mul-r : ∀ a {b d} → d Divides b → d Divides (a * b)\ndivides-mul-r a (factor! q) = factor (a * q) auto\n\ndivides-mul-l : ∀ {a} b {d} → d Divides a → d Divides (a * b)\ndivides-mul-l b (factor! q) = factor (b * q) auto\n\ndivides-mul : ∀ {a b c d} → c Divides a → d Divides b → (c * d) Divides (a * b)\ndivides-mul (factor! q) (factor! r) = factor (q * r) auto\n\nmul-divides-l : (a b c : Nat) → (a * b) Divides c → a Divides c\nmul-divides-l a b c (factor! q) = factor (q * b) auto\n\nmul-divides-r : (a b c : Nat) → (a * b) Divides c → b Divides c\nmul-divides-r a b c (factor! q) = factor (q * a) auto\n\ndivides-flip-mul : ∀ {a b c d} → c Divides b → d Divides a → (c * d) Divides (a * b)\ndivides-flip-mul {a} {b} {c} {d} c|b d|a =\n transport ((c * d) Divides_) (mul-commute b a) (divides-mul c|b d|a)\n\ndivides-sub-l : ∀ {a b d} → d Divides (a + b) → d Divides a → d Divides b\ndivides-sub-l {b = b} {d} (factor q₁ eq) (factor! q) = factor (q₁ - q) $ by eq\n\ndivides-sub-r : ∀ {a b d} → d Divides (a + b) → d Divides b → d Divides a\ndivides-sub-r {a} {b} d|ab d|b rewrite add-commute a b = divides-sub-l d|ab d|b\n\ndivides-mul-cong-l : ∀ {a b} c → a Divides b → (c * a) Divides (c * b)\ndivides-mul-cong-l {a} {b} c (factor q eq) = factor q (by (c *_ $≡ eq))\n\ndivides-mul-cong-r : ∀ {a b} c → a Divides b → (a * c) Divides (b * c)\ndivides-mul-cong-r {a} {b} c (factor q eq) = factor q (by (c *_ $≡ eq))\n\ndivides-nonzero : ∀ {a b} {{_ : NonZero b}} → a Divides b → NonZero a\ndivides-nonzero {zero} {{nzb}} (factor! b) = transport NonZero (mul-zero-r b) nzb\ndivides-nonzero {suc _} _ = _\n\ndivides-refl : ∀ {a} → a Divides a\ndivides-refl = factor 1 auto\n\ndivides-antisym : ∀ {a b} → a Divides b → b Divides a → a ≡ b\ndivides-antisym (factor! q) (factor! 0) = auto\ndivides-antisym (factor! q) (factor 1 eq) = by eq\ndivides-antisym {zero} (factor! q) (factor (suc (suc q₁)) eq) = auto\ndivides-antisym {suc a} (factor! 0) (factor (suc (suc q₁)) eq) = by eq\ndivides-antisym {suc a} (factor! (suc q)) (factor (suc (suc q₁)) eq) = refute eq\n\ndivides-trans : ∀ {a b c} → a Divides b → b Divides c → a Divides c\ndivides-trans (factor! q) (factor! q′) = factor (q′ * q) auto\n\ndivides-zero : ∀ {a} → 0 Divides a → a ≡ 0\ndivides-zero (factor! q) = auto\n\none-divides : ∀ {a} → 1 Divides a\none-divides {a} = factor a auto\n\ndivides-one : ∀ {a} → a Divides 1 → a ≡ 1\ndivides-one {0} (factor k eq) = refute eq\ndivides-one {1} _ = refl\ndivides-one {suc (suc a)} (factor zero ())\ndivides-one {suc (suc a)} (factor (suc k) eq) = refute eq\n\nmul=1-l : (a b : Nat) → a * b ≡ 1 → a ≡ 1\nmul=1-l a b eq =\n divides-one (transport (a Divides_) eq (divides-mul-l b divides-refl))\n\nmul=1-r : (a b : Nat) → a * b ≡ 1 → b ≡ 1\nmul=1-r a b eq = mul=1-l b a (by eq)\n\ndivides-less : ∀ {a b} {{_ : NonZero b}} → a Divides b → a ≤ b\ndivides-less {{}} (factor! 0)\ndivides-less {a} (factor! (suc q)) = auto\n\nnonzero-factor : ∀ {a b} ⦃ nzb : NonZero b ⦄ (a|b : a Divides b) → NonZero (get-factor a|b)\nnonzero-factor ⦃ () ⦄ (factor! zero)\nnonzero-factor (factor! (suc _)) = _\n\ncancel-mul-divides-r : ∀ a b c ⦃ _ : NonZero c ⦄ → (a * c) Divides (b * c) → a Divides b\ncancel-mul-divides-r a b c (factor q qac=bc) =\n factor q (mul-inj₁ (q * a) b c (by qac=bc))\n\ncancel-mul-divides-l : ∀ a b c ⦃ _ : NonZero a ⦄ → (a * b) Divides (a * c) → b Divides c\ncancel-mul-divides-l a b c rewrite mul-commute a b | mul-commute a c = cancel-mul-divides-r b c a\n", "meta": {"hexsha": "ec7b39a7d3bea429f0c5aeab633b6ee1c30b909a", "size": 3786, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Numeric/Nat/Divide/Properties.agda", "max_stars_repo_name": "t-more/agda-prelude", "max_stars_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 111, "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_issues_repo_path": "src/Numeric/Nat/Divide/Properties.agda", "max_issues_repo_name": "t-more/agda-prelude", "max_issues_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_forks_repo_path": "src/Numeric/Nat/Divide/Properties.agda", "max_forks_repo_name": "t-more/agda-prelude", "max_forks_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "avg_line_length": 40.2765957447, "max_line_length": 97, "alphanum_fraction": 0.5940306392, "num_tokens": 1529, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757869916479466, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.6181173462795383}} {"text": "open import Data.Product\n\nopen import Relation.Binary.PropositionalEquality hiding ([_] ; Extensionality)\nopen import Relation.Nullary\nopen import Relation.Nullary.Negation\n\nopen import EffectAnnotations\n\nmodule Types where\n\n-- BASE AND GROUND TYPES\n\npostulate BType : Set -- set of base types\n\npostulate dec-bty : (B B' : BType) → Dec (B ≡ B')\n\nGType = BType\n\n\n-- VALUE AND COMPUTATION TYPES\n\nmutual\n\n data VType : Set where\n `` : GType → VType\n _⇒_ : VType → CType → VType\n ⟨_⟩ : VType → VType\n\n data CType : Set where\n _!_ : VType → O × I → CType\n\ninfix 30 _⇒_\ninfix 30 _!_\n\n\n-- PROCESS TYPES\n\ndata PTypeShape : Set where\n _!_ : VType → I → PTypeShape\n _∥_ : PTypeShape → PTypeShape → PTypeShape\n\ndata PType : O → Set where\n\n _‼_,_ : (X : VType) →\n (o : O) →\n (i : I) →\n ---------------\n PType o\n \n _∥_ : {o o' : O} →\n (PP : PType o) →\n (QQ : PType o') →\n ---------------------------\n PType (o ∪ₒ o')\n\n\n-- ACTION OF INTERRUPTS ON PROCESS TYPES\n\n_↓ₚₚ_ : (op : Σₛ) → {o : O} →\n PType o → Σ[ o' ∈ O ] PType o'\nop ↓ₚₚ (X ‼ o , i) with op ↓ₑ (o , i)\n... | (o' , i') =\n o' , (X ‼ o' , i')\nop ↓ₚₚ (PP ∥ QQ) with op ↓ₚₚ PP | op ↓ₚₚ QQ\n... | (o'' , PP') | (o''' , QQ') =\n (o'' ∪ₒ o''') , (PP' ∥ QQ')\n\n\n_↓ₚ_ : (op : Σₛ) → {o : O} →\n (PP : PType o) → PType (proj₁ (op ↓ₚₚ PP))\n\nop ↓ₚ PP = proj₂ (op ↓ₚₚ PP)\n\n\n-- ACTION OF INTERRUPTS ON PROCESS TYPES PRESERVES SIGNAL ANNOTATIONS\n\n{- LEMMA 4.1 -}\n\n↓ₚₚ-⊑ₒ : {op : Σₛ}\n {o : O} →\n (PP : PType o) →\n ----------------------\n o ⊑ₒ proj₁ (op ↓ₚₚ PP)\n\n↓ₚₚ-⊑ₒ (X ‼ o , i) =\n ↓ₑ-⊑ₒ\n↓ₚₚ-⊑ₒ (PP ∥ QQ) =\n ∪ₒ-fun (↓ₚₚ-⊑ₒ PP) (↓ₚₚ-⊑ₒ QQ)\n", "meta": {"hexsha": "d5a572f03b40ab6b451351a905c2fd2ecba60fcb", "size": 1704, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Types.agda", "max_stars_repo_name": "danelahman/aeff-agda", "max_stars_repo_head_hexsha": "71ebed9f90a3eb37ae6cd209457bae23a4d122d1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2020-07-17T00:15:00.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-22T22:48:48.000Z", "max_issues_repo_path": "Types.agda", "max_issues_repo_name": "danelahman/aeff-agda", "max_issues_repo_head_hexsha": "71ebed9f90a3eb37ae6cd209457bae23a4d122d1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Types.agda", "max_forks_repo_name": "danelahman/aeff-agda", "max_forks_repo_head_hexsha": "71ebed9f90a3eb37ae6cd209457bae23a4d122d1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.1460674157, "max_line_length": 79, "alphanum_fraction": 0.4970657277, "num_tokens": 715, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757869884059266, "lm_q2_score": 0.7057850154599563, "lm_q1q2_score": 0.6181173331517055}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nopen import Cubical.Core.Everything\nopen import Cubical.Foundations.HLevels\n\nmodule Cubical.Algebra.Group.Construct.Free {ℓ} (Aˢ : hSet ℓ) where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Univalence\nopen import Cubical.Foundations.Path\nopen import Cubical.Algebra.Group\n\nopen import Cubical.Data.Empty.Polymorphic\nopen import Cubical.Data.Prod\n\nopen import Cubical.Relation.Binary.Reasoning.Equality\n\nA = ⟨ Aˢ ⟩\nisSetA = Aˢ .snd\n\ndata FreeG : Type ℓ where\n inj : A → FreeG\n _•_ : Op₂ FreeG\n ε : FreeG\n _⁻¹ : Op₁ FreeG\n\n •-assoc : Associative _•_\n •-identityˡ : LeftIdentity ε _•_\n •-identityʳ : RightIdentity ε _•_\n •-inverseˡ : LeftInverse ε _⁻¹ _•_\n •-inverseʳ : RightInverse ε _⁻¹ _•_\n\n squash : isSet FreeG\n\n•-identity : Identity ε _•_\n•-identity = •-identityˡ , •-identityʳ\n\n•-inverse : Inverse ε _⁻¹ _•_\n•-inverse = •-inverseˡ , •-inverseʳ\n\n\nelim : ∀ {ℓ′} {B : FreeG → Type ℓ′} →\n (∀ x → isSet (B x)) →\n (∀ x → B (inj x)) →\n (op : ∀ {x y} → B x → B y → B (x • y)) →\n (e : B ε) →\n (inv : ∀ {x} → B x → B (x ⁻¹)) →\n (∀ {x y z} (a : B x) (b : B y) (c : B z) → PathP (λ i → B (•-assoc x y z i)) (op (op a b) c) (op a (op b c))) →\n (∀ {x} (a : B x) → PathP (λ i → B (•-identityˡ x i)) (op e a) a) →\n (∀ {x} (a : B x) → PathP (λ i → B (•-identityʳ x i)) (op a e) a) →\n (∀ {x} (a : B x) → PathP (λ i → B (•-inverseˡ x i)) (op (inv a) a) e) →\n (∀ {x} (a : B x) → PathP (λ i → B (•-inverseʳ x i)) (op a (inv a)) e) →\n (x : FreeG) → B x\nelim isSetB f op e inv assc idˡ idʳ invˡ invʳ (inj x) = f x\nelim isSetB f op e inv assc idˡ idʳ invˡ invʳ (x • y) = op (elim isSetB f op e inv assc idˡ idʳ invˡ invʳ x)\n (elim isSetB f op e inv assc idˡ idʳ invˡ invʳ y)\nelim isSetB f op e inv assc idˡ idʳ invˡ invʳ ε = e\nelim isSetB f op e inv assc idˡ idʳ invˡ invʳ (x ⁻¹) = inv (elim isSetB f op e inv assc idˡ idʳ invˡ invʳ x)\nelim isSetB f op e inv assc idˡ idʳ invˡ invʳ (•-assoc x y z i) = assc (elim isSetB f op e inv assc idˡ idʳ invˡ invʳ x)\n (elim isSetB f op e inv assc idˡ idʳ invˡ invʳ y)\n (elim isSetB f op e inv assc idˡ idʳ invˡ invʳ z) i\nelim isSetB f op e inv assc idˡ idʳ invˡ invʳ (•-identityˡ x i) = idˡ (elim isSetB f op e inv assc idˡ idʳ invˡ invʳ x) i\nelim isSetB f op e inv assc idˡ idʳ invˡ invʳ (•-identityʳ x i) = idʳ (elim isSetB f op e inv assc idˡ idʳ invˡ invʳ x) i\nelim isSetB f op e inv assc idˡ idʳ invˡ invʳ (•-inverseˡ x i) = invˡ (elim isSetB f op e inv assc idˡ idʳ invˡ invʳ x) i\nelim isSetB f op e inv assc idˡ idʳ invˡ invʳ (•-inverseʳ x i) = invʳ (elim isSetB f op e inv assc idˡ idʳ invˡ invʳ x) i\nelim isSetB f op e inv assc idˡ idʳ invˡ invʳ (squash x y p q i j) =\n isOfHLevel→isOfHLevelDep 2 isSetB\n (elim isSetB f op e inv assc idˡ idʳ invˡ invʳ x) (elim isSetB f op e inv assc idˡ idʳ invˡ invʳ y)\n (cong (elim isSetB f op e inv assc idˡ idʳ invˡ invʳ) p) (cong (elim isSetB f op e inv assc idˡ idʳ invˡ invʳ) q) (squash x y p q) i j\n\n\nFreeG-isGroup : IsGroup FreeG _•_ ε _⁻¹\nFreeG-isGroup = record\n { isMonoid = record\n { isSemigroup = record\n { isMagma = record { is-set = squash }\n ; assoc = •-assoc\n }\n ; identity = •-identity\n }\n ; inverse = •-inverse\n }\n\nFreeGroup : Group ℓ\nFreeGroup = record { isGroup = FreeG-isGroup }\n", "meta": {"hexsha": "bb51c05f773434a3b1ba4787231ae823938f0c4e", "size": 3642, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Group/Construct/Free.agda", "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Group/Construct/Free.agda", "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Group/Construct/Free.agda", "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.8620689655, "max_line_length": 138, "alphanum_fraction": 0.586490939, "num_tokens": 1500, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.841825635346563, "lm_q2_score": 0.7341195327172401, "lm_q1q2_score": 0.6180006420500125}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Agda.Builtin.Bool\nopen import Data.Maybe.Base using (Maybe; just; nothing)\nopen import Relation.Nullary\nopen import Data.Rational.Unnormalised.Base using (ℚᵘ; 0ℚᵘ; _≃_)\nopen import Data.Rational.Unnormalised.Properties using (+-*-commutativeRing; _≃?_)\n\nisZero? : ∀ (p : ℚᵘ) -> Maybe (0ℚᵘ ≃ p)\nisZero? p with 0ℚᵘ ≃? p\n... | .true because ofʸ p₁ = just p₁\n... | .false because ofⁿ ¬p = nothing\n\nopen import Tactic.RingSolver.Core.AlmostCommutativeRing using (fromCommutativeRing)\nopen import Tactic.RingSolver.NonReflective (fromCommutativeRing +-*-commutativeRing isZero?) public\n", "meta": {"hexsha": "7c7105b9f9dd9d53b6edb027eedcb201d67bc38c", "size": 628, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "NonReflectiveQ.agda", "max_stars_repo_name": "z-murray/AnalysisAgda", "max_stars_repo_head_hexsha": "6fbaca08b1d63b5765d184f6284fb0e58c9f5e52", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "NonReflectiveQ.agda", "max_issues_repo_name": "z-murray/AnalysisAgda", "max_issues_repo_head_hexsha": "6fbaca08b1d63b5765d184f6284fb0e58c9f5e52", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "NonReflectiveQ.agda", "max_forks_repo_name": "z-murray/AnalysisAgda", "max_forks_repo_head_hexsha": "6fbaca08b1d63b5765d184f6284fb0e58c9f5e52", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.25, "max_line_length": 100, "alphanum_fraction": 0.7436305732, "num_tokens": 208, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9334308165850442, "lm_q2_score": 0.661922862511608, "lm_q1q2_score": 0.6178591980705203}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Data.FinData.Base where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Data.Nat\nopen import Cubical.Relation.Nullary\n\ndata Fin : ℕ → Type₀ where\n zero : {n : ℕ} → Fin (suc n)\n suc : {n : ℕ} (i : Fin n) → Fin (suc n)\n\ntoℕ : ∀ {n} → Fin n → ℕ\ntoℕ zero = 0\ntoℕ (suc i) = suc (toℕ i)\n\nfromℕ : (n : ℕ) → Fin (suc n)\nfromℕ zero = zero\nfromℕ (suc n) = suc (fromℕ n)\n\n¬Fin0 : ¬ Fin 0\n¬Fin0 ()\n", "meta": {"hexsha": "82b2a9dade3422f1d463547b46dc5f598432be4f", "size": 474, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/FinData/Base.agda", "max_stars_repo_name": "RobertHarper/cubical", "max_stars_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/FinData/Base.agda", "max_issues_repo_name": "RobertHarper/cubical", "max_issues_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Data/FinData/Base.agda", "max_forks_repo_name": "RobertHarper/cubical", "max_forks_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "avg_line_length": 21.5454545455, "max_line_length": 50, "alphanum_fraction": 0.6139240506, "num_tokens": 189, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8962513731336202, "lm_q2_score": 0.6893056231680122, "lm_q1q2_score": 0.6177911112730567}} {"text": "module Example where\n\nopen import Data.List\n\n-- reverse\nrev : ∀ {a} {A : Set a} → List A → List A\nrev [] = []\nrev (x ∷ xs) = rev xs ++ [ x ]\n\n-- https://code.google.com/p/agda/issues/detail?id=1252 暫定対策\nrev' = rev\n{-# COMPILED_EXPORT rev' rev' #-}\n\nprivate\n open import Relation.Binary.PropositionalEquality\n\n -- reverse2回で元に戻る証明\n lemma : ∀ {a} {A : Set a} (x : A) (xs : List A) → rev (xs ∷ʳ x) ≡ x ∷ rev xs\n lemma x [] = refl\n lemma x (_ ∷ xs)\n rewrite lemma x xs\n = refl\n\n revrev-is-id : ∀ {a} {A : Set a} (xs : List A) → rev (rev xs) ≡ xs\n revrev-is-id [] = refl\n revrev-is-id (x ∷ xs)\n rewrite lemma x (rev xs)\n | revrev-is-id xs\n = refl\n\nopen import Data.Empty\n\nhead : ∀ {a} {A : Set a} (xs : List A) → {xs≢[] : xs ≢ []} → A\nhead [] {xs≠[]} = ⊥-elim (xs≠[] refl)\nhead (x ∷ xs) = x\n{-\n{-# COMPILED_EXPORT head safeHead' #-}\n-- エラーになる\n-- The type _≡_ cannot be translated to a Haskell type.\n-- when checking the pragma COMPILED_EXPORT head' safeHead\n--\n-- つまり,証明オブジェクトを取るような関数は,\n-- そのままではCOMPILED_EXPORTできないことが多い\n-}\n\nopen import Data.Maybe\n\nhead' : ∀ {a} {A : Set a} (xs : List A) → Maybe A\nhead' = go where\n go : ∀ {a} {A : Set a} (xs : List A) → Maybe A\n go [] = nothing\n go (x ∷ xs) = just (head (x ∷ xs) {λ ()})\n{-# COMPILED_EXPORT head' safeHead' #-}\n-- つまり,安全なheadを使うには,\n-- 安全なものだけ渡せるようにしてjustで結果が得られ,\n-- それ以外についてはnothingになるように,\n-- 適切にラップしないとCOMPILED_EXPORTできない.\n", "meta": {"hexsha": "39944a3437468127a76da36bdc6b24df553b4319", "size": 1416, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Example.agda", "max_stars_repo_name": "notogawa/agda-haskell-example", "max_stars_repo_head_hexsha": "9ad77d2aed8f950151e009135a9dfc02bc32ce65", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2015-07-28T05:04:58.000Z", "max_stars_repo_stars_event_max_datetime": "2017-11-07T01:35:46.000Z", "max_issues_repo_path": "src/Example.agda", "max_issues_repo_name": "notogawa/agda-haskell-example", "max_issues_repo_head_hexsha": "9ad77d2aed8f950151e009135a9dfc02bc32ce65", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Example.agda", "max_forks_repo_name": "notogawa/agda-haskell-example", "max_forks_repo_head_hexsha": "9ad77d2aed8f950151e009135a9dfc02bc32ce65", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.4137931034, "max_line_length": 78, "alphanum_fraction": 0.5918079096, "num_tokens": 600, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031738010682209, "lm_q2_score": 0.7690802476562641, "lm_q1q2_score": 0.6177051058365703}} {"text": "module Class.Listable where\n\nopen import Class.Equality\n\nopen import Data.List\nopen import Data.List.Relation.Unary.Any\nopen import Data.List.Relation.Unary.All.Properties\nopen import Data.List.Relation.Unary.Unique.Propositional\nopen import Data.List.Membership.Propositional\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary\n\nrecord Listable (A : Set) : Set where\n field\n listing : List A\n unique : Unique listing\n complete : (a : A) → a ∈ listing\n\n Listable→Eq : Eq A\n Listable→Eq ._≟_ a b = helper (complete a) (complete b) unique\n where\n helper : ∀ {a b} {l : List A} → (a ∈ l) → (b ∈ l) → Unique l → Dec (a ≡ b)\n helper {a} {b} {l} h h' u with l | h | h' | u\n ... | ._ | here refl | here refl | _ = yes refl\n ... | ._ | here refl | there h | h' ∷ _ = no λ where refl → All¬⇒¬Any h' h\n ... | ._ | there h | here refl | h' ∷ _ = no λ where refl → All¬⇒¬Any h' h\n ... | ._ | there h | there h' | _ ∷ u = helper h h' u\n", "meta": {"hexsha": "7270677fbe3b419c8f1c37c44ac31715f0320a5e", "size": 1011, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "stdlib-exts/Class/Listable.agda", "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 35, "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_issues_repo_path": "stdlib-exts/Class/Listable.agda", "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 10, "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_forks_repo_path": "stdlib-exts/Class/Listable.agda", "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "avg_line_length": 36.1071428571, "max_line_length": 82, "alphanum_fraction": 0.6122650841, "num_tokens": 326, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.863391602943619, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.617691065265168}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Environments (heterogeneous collections)\n------------------------------------------------------------------------\n\nmodule Data.Star.Environment (Ty : Set) where\n\nopen import Data.Star\nopen import Data.Star.List\nopen import Data.Star.Decoration\nopen import Data.Star.Pointer as Pointer hiding (lookup)\nopen import Data.Unit\nopen import Relation.Binary.PropositionalEquality\n\n-- Contexts, listing the types of all the elements in an environment.\n\nCtxt : Set\nCtxt = List Ty\n\n-- Variables (de Bruijn indices); pointers into environments.\n\ninfix 4 _∋_\n\n_∋_ : Ctxt → Ty → Set\nΓ ∋ σ = Any (λ _ → ⊤) (_≡_ σ) Γ\n\nvz : ∀ {Γ σ} → Γ ▻ σ ∋ σ\nvz = this refl\n\nvs : ∀ {Γ σ τ} → Γ ∋ τ → Γ ▻ σ ∋ τ\nvs = that tt\n\n-- Environments. The T function maps types to element types.\n\nEnv : (Ty → Set) → Ctxt → Set\nEnv T Γ = All T Γ\n\n-- A safe lookup function for environments.\n\nlookup : ∀ {Γ σ} {T : Ty → Set} → Γ ∋ σ → Env T Γ → T σ\nlookup i ρ with Pointer.lookup i ρ\n... | result refl x = x\n", "meta": {"hexsha": "826d8e74f0da0cf276c5e7077017eda3a8f4c860", "size": 1072, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Star/Environment.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Star/Environment.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Star/Environment.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.3636363636, "max_line_length": 72, "alphanum_fraction": 0.5802238806, "num_tokens": 303, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8311430645886584, "lm_q2_score": 0.7431680143008301, "lm_q1q2_score": 0.6176789409102599}} {"text": "{-# OPTIONS --cubical #-}\n\nmodule Equality where\n\nimport Algebra.FunctionProperties\nimport Algebra.Structures\nopen import Cubical.Core.Everything public hiding (module Σ)\nopen import Data.Empty\nopen import Data.Nat as ℕ\nopen import Data.Nat.Properties\nopen import Data.Product as Σ\nopen import Data.Unit\nopen import Function\nopen import Quotient\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as ♥ public using () renaming (refl to ♥)\n\nopen module FunctionProperties {a} {A : Set a} =\n Algebra.FunctionProperties {A = A} _≡_\n\nopen module Structures {a} {A : Set a} =\n Algebra.Structures {A = A} _≡_\n\ncoe : ∀ {ℓ} {A B : Set ℓ} → A ≡ B → A → B\ncoe = subst id\n\ninfix 1 _$⃗_\n_$⃗_ : ∀ {ℓ} {A B : Set ℓ} → A ≡ B → A → B\n_$⃗_ = coe\n\ninfix 1 _$⃖_\n_$⃖_ : ∀ {ℓ} {A B : Set ℓ} → A ≡ B → B → A\np $⃖ x = sym p $⃗ x\n\n≡-isEquivalence : ∀ {ℓ} {A : Set ℓ} → IsEquivalence {A = A} _≡_\n≡-isEquivalence = record\n { refl = refl\n ; sym = sym\n ; trans = compPath\n }\n\n≡-isPreorder : ∀ {ℓ} {A : Set ℓ} → IsPreorder {A = A} _≡_ _≡_\n≡-isPreorder = record\n { isEquivalence = ≡-isEquivalence\n ; reflexive = id\n ; trans = compPath\n }\n\nmodule _ {ℓ} {A : Set ℓ} {a b : A} where\n ⟨_⟩ : a ♥.≡ b → a ≡ b\n ⟨ ♥ ⟩ = refl\n\n ⟪_⟫ : a ≡ b → a ♥.≡ b\n ⟪_⟫ = J (λ x _ → _ ♥.≡ x) ♥\n\ninfixl 5 _≫_\n_≫_ : ∀ {ℓ} {A : Set ℓ} {a b c : A} → a ≡ b → b ≡ c → a ≡ c\n_≫_ = compPath\n\nmodule _ {ℓ₁ ℓ₂} {A : Set ℓ₁} {B : Set ℓ₂} {f f′ : A → B} where\n happly : ∀ a → f ≡ f′ → f a ≡ f′ a\n happly a = cong λ g → g a\n\n congApp : ∀ {a a′} → f ≡ f′ → a ≡ a′ → f a ≡ f′ a′\n congApp p q = compPath (happly _ p) (cong f′ q)\n\ncong₂ : ∀\n {ℓ₁ ℓ₂ ℓ₃} {A : Set ℓ₁} {B : Set ℓ₂} {C : Set ℓ₃}\n {a a′} {b b′}\n (f : A → B → C) →\n a ≡ a′ → b ≡ b′ →\n f a b ≡ f a′ b′\ncong₂ f p q = congApp (cong f p) q\n", "meta": {"hexsha": "6285edc9a85b5fa42131b4a24ece8bf3b40441ca", "size": 1776, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Equality.agda", "max_stars_repo_name": "kcsmnt0/numbers", "max_stars_repo_head_hexsha": "67ea7b96228c592daf79e800ebe4a7c12ed7221e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2019-05-20T01:29:41.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-16T07:16:26.000Z", "max_issues_repo_path": "src/Equality.agda", "max_issues_repo_name": "kcsmnt0/numbers", "max_issues_repo_head_hexsha": "67ea7b96228c592daf79e800ebe4a7c12ed7221e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Equality.agda", "max_forks_repo_name": "kcsmnt0/numbers", "max_forks_repo_head_hexsha": "67ea7b96228c592daf79e800ebe4a7c12ed7221e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.0, "max_line_length": 91, "alphanum_fraction": 0.5636261261, "num_tokens": 800, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430645886583, "lm_q2_score": 0.7431680029241322, "lm_q1q2_score": 0.6176789314545962}} {"text": "{-# OPTIONS --prop --without-K --rewriting #-}\n\n-- Common cost monoids.\n\nmodule Calf.CostMonoids where\n\nopen import Calf.CostMonoid\nopen import Data.Product\nopen import Relation.Binary.PropositionalEquality\n\nℕ-CostMonoid : CostMonoid\nℕ-CostMonoid = record\n { ℂ = ℕ\n ; _+_ = _+_\n ; zero = zero\n ; _≤_ = _≤_\n ; isCostMonoid = record\n { isMonoid = +-0-isMonoid\n ; isCancellative = record { ∙-cancel-≡ = +-cancel-≡ }\n ; isPreorder = ≤-isPreorder\n ; isMonotone = record { ∙-mono-≤ = +-mono-≤ }\n }\n }\n where\n open import Data.Nat\n open import Data.Nat.Properties\n\nℕ-Work-ParCostMonoid : ParCostMonoid\nℕ-Work-ParCostMonoid = record\n { ℂ = ℕ\n ; _⊕_ = _+_\n ; 𝟘 = 0\n ; _⊗_ = _+_\n ; 𝟙 = 0\n ; _≤_ = _≤_\n ; isParCostMonoid = record\n { isMonoid = +-0-isMonoid\n ; isCommutativeMonoid = +-0-isCommutativeMonoid\n ; isCancellative = record { ∙-cancel-≡ = +-cancel-≡ }\n ; isPreorder = ≤-isPreorder\n ; isMonotone-⊕ = record { ∙-mono-≤ = +-mono-≤ }\n ; isMonotone-⊗ = record { ∙-mono-≤ = +-mono-≤ }\n }\n }\n where\n open import Data.Nat\n open import Data.Nat.Properties\n\nℕ-Span-ParCostMonoid : ParCostMonoid\nℕ-Span-ParCostMonoid = record\n { ℂ = ℕ\n ; _⊕_ = _+_\n ; 𝟘 = 0\n ; _⊗_ = _⊔_\n ; 𝟙 = 0\n ; _≤_ = _≤_\n ; isParCostMonoid = record\n { isMonoid = +-0-isMonoid\n ; isCommutativeMonoid = ⊔-0-isCommutativeMonoid\n ; isPreorder = ≤-isPreorder\n ; isCancellative = record { ∙-cancel-≡ = +-cancel-≡ }\n ; isMonotone-⊕ = record { ∙-mono-≤ = +-mono-≤ }\n ; isMonotone-⊗ = record { ∙-mono-≤ = ⊔-mono-≤ }\n }\n }\n where\n open import Data.Nat\n open import Data.Nat.Properties\n\ncombineParCostMonoids : ParCostMonoid → ParCostMonoid → ParCostMonoid\ncombineParCostMonoids pcm₁ pcm₂ = record\n { ℂ = ℂ pcm₁ × ℂ pcm₂\n ; _⊕_ = λ (a₁ , a₂) (b₁ , b₂) → _⊕_ pcm₁ a₁ b₁ , _⊕_ pcm₂ a₂ b₂\n ; 𝟘 = 𝟘 pcm₁ , 𝟘 pcm₂\n ; _⊗_ = λ (a₁ , a₂) (b₁ , b₂) → _⊗_ pcm₁ a₁ b₁ , _⊗_ pcm₂ a₂ b₂\n ; 𝟙 = 𝟙 pcm₁ , 𝟙 pcm₂\n ; _≤_ = λ (a₁ , a₂) (b₁ , b₂) → _≤_ pcm₁ a₁ b₁ × _≤_ pcm₂ a₂ b₂\n ; isParCostMonoid = record\n { isMonoid = record\n { isSemigroup = record\n { isMagma = record\n { isEquivalence = isEquivalence\n ; ∙-cong = λ h₁ h₂ →\n cong₂ _,_\n (cong₂ (_⊕_ pcm₁) (cong proj₁ h₁) (cong proj₁ h₂))\n (cong₂ (_⊕_ pcm₂) (cong proj₂ h₁) (cong proj₂ h₂))\n }\n ; assoc = λ (a₁ , a₂) (b₁ , b₂) (c₁ , c₂) → cong₂ _,_ (⊕-assoc pcm₁ a₁ b₁ c₁) (⊕-assoc pcm₂ a₂ b₂ c₂)\n }\n ; identity =\n (λ (a₁ , a₂) → cong₂ _,_ (⊕-identityˡ pcm₁ a₁) (⊕-identityˡ pcm₂ a₂)) ,\n (λ (a₁ , a₂) → cong₂ _,_ (⊕-identityʳ pcm₁ a₁) (⊕-identityʳ pcm₂ a₂))\n }\n ; isCommutativeMonoid = record\n { isMonoid = record\n { isSemigroup = record\n { isMagma = record\n { isEquivalence = isEquivalence\n ; ∙-cong = λ h₁ h₂ →\n cong₂ _,_\n (cong₂ (_⊗_ pcm₁) (cong proj₁ h₁) (cong proj₁ h₂))\n (cong₂ (_⊗_ pcm₂) (cong proj₂ h₁) (cong proj₂ h₂))\n }\n ; assoc = λ (a₁ , a₂) (b₁ , b₂) (c₁ , c₂) → cong₂ _,_ (⊗-assoc pcm₁ a₁ b₁ c₁) (⊗-assoc pcm₂ a₂ b₂ c₂)\n }\n ; identity =\n (λ (a₁ , a₂) → cong₂ _,_ (⊗-identityˡ pcm₁ a₁) (⊗-identityˡ pcm₂ a₂)) ,\n (λ (a₁ , a₂) → cong₂ _,_ (⊗-identityʳ pcm₁ a₁) (⊗-identityʳ pcm₂ a₂))\n }\n ; comm = λ (a₁ , a₂) (b₁ , b₂) → cong₂ _,_ (⊗-comm pcm₁ a₁ b₁) (⊗-comm pcm₂ a₂ b₂)\n }\n ; isCancellative = record\n { ∙-cancel-≡ =\n (λ (x₁ , x₂) h → cong₂ _,_ (⊕-cancelˡ-≡ pcm₁ x₁ (cong proj₁ h)) (⊕-cancelˡ-≡ pcm₂ x₂ (cong proj₂ h))) ,\n (λ (y₁ , y₂) (z₁ , z₂) h → cong₂ _,_ (⊕-cancelʳ-≡ pcm₁ y₁ z₁ (cong proj₁ h)) (⊕-cancelʳ-≡ pcm₂ y₂ z₂ (cong proj₂ h)))\n }\n ; isPreorder = record\n { isEquivalence = isEquivalence\n ; reflexive = λ { refl → ≤-refl pcm₁ , ≤-refl pcm₂ }\n ; trans = λ (h₁ , h₂) (h₁' , h₂') → ≤-trans pcm₁ h₁ h₁' , ≤-trans pcm₂ h₂ h₂'\n }\n ; isMonotone-⊕ = record\n { ∙-mono-≤ = λ (h₁ , h₂) (h₁' , h₂') → ⊕-mono-≤ pcm₁ h₁ h₁' , ⊕-mono-≤ pcm₂ h₂ h₂'\n }\n ; isMonotone-⊗ = record\n { ∙-mono-≤ = λ (h₁ , h₂) (h₁' , h₂') → ⊗-mono-≤ pcm₁ h₁ h₁' , ⊗-mono-≤ pcm₂ h₂ h₂'\n }\n }\n }\n where open ParCostMonoid\n\nℕ²-ParCostMonoid : ParCostMonoid\nℕ²-ParCostMonoid = combineParCostMonoids ℕ-Work-ParCostMonoid ℕ-Span-ParCostMonoid\n", "meta": {"hexsha": "1331be2d113fc8d95ee85205b6575fe19a92d783", "size": 4394, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Calf/CostMonoids.agda", "max_stars_repo_name": "jonsterling/agda-calf", "max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 29, "max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z", "max_issues_repo_path": "src/Calf/CostMonoids.agda", "max_issues_repo_name": "jonsterling/agda-calf", "max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Calf/CostMonoids.agda", "max_forks_repo_name": "jonsterling/agda-calf", "max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z", "avg_line_length": 32.7910447761, "max_line_length": 127, "alphanum_fraction": 0.5407373691, "num_tokens": 1960, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619263765707, "lm_q2_score": 0.7490872243177518, "lm_q1q2_score": 0.617593895985092}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Category.Finite where\n\nopen import Level\nopen import Data.Product using (Σ; _,_; ∃₂)\nopen import Function.Equality using (Π; _⟶_)\nopen import Function.Inverse\nopen import Data.Nat as ℕ hiding (_⊔_)\nimport Data.Fin as Fin\nopen import Data.Vec as Vec\nopen import Relation.Binary using (Setoid)\nimport Relation.Binary.PropositionalEquality as ≡\n\nopen import Categories.Category\nopen Π\n\nFiniteSetoid : ∀ {c ℓ} n (S : Setoid c ℓ) → Set _\nFiniteSetoid n S = Inverse (≡.setoid (Fin.Fin n)) S\n\nrecord Finite {o ℓ e} (C : Category o ℓ e) : Set (o ⊔ ℓ ⊔ e) where\n open Category C\n \n field\n ∣Obj∣ : ℕ\n ∣_⇒_∣ : Obj → Obj → ℕ\n\n Obj-finite : FiniteSetoid ∣Obj∣ (≡.setoid Obj)\n ⇒-finite : ∀ A B → FiniteSetoid ∣ A ⇒ B ∣ (hom-setoid {A} {B})\n\n module Obj-finite = Inverse Obj-finite\n module ⇒-finite A B = Inverse (⇒-finite A B)\n\n private\n Fins : ∀ n → Vec (Fin.Fin n) n\n Fins ℕ.zero = []\n Fins (ℕ.suc n) = Fin.fromℕ n ∷ Vec.map (Fin.raise 1) (Fins n)\n\n -- enumeration of all objects\n Objs : Vec Obj ∣Obj∣\n Objs = Vec.map (Obj-finite.to ⟨$⟩_) (Fins ∣Obj∣)\n\n private\n ObjPairs : ∀ {a} {A : Set a} → (Obj → Obj → A) → Vec A (∣Obj∣ * ∣Obj∣)\n ObjPairs {_} {A} f = Objs >>= ap\n where ap : Obj → Vec A ∣Obj∣\n ap X = Vec.map (f X) Objs\n\n -- enumeration of all morphisms of a given pair of objects\n ⟦_⇒_⟧ : ∀ A B → Vec (A ⇒ B) ∣ A ⇒ B ∣\n ⟦ A ⇒ B ⟧ = Vec.map (⇒-finite.to A B ⟨$⟩_) (Fins ∣ A ⇒ B ∣)\n\n -- number of all morphisms\n ∣-⇒-| : ℕ\n ∣-⇒-| = foldr (λ _ → ℕ) _+_ 0 (ObjPairs ∣_⇒_∣)\n", "meta": {"hexsha": "8efac41273f4576215209ec04e7bd5e81555df59", "size": 1582, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Category/Finite.agda", "max_stars_repo_name": "Taneb/agda-categories", "max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Categories/Category/Finite.agda", "max_issues_repo_name": "Taneb/agda-categories", "max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Categories/Category/Finite.agda", "max_forks_repo_name": "Taneb/agda-categories", "max_forks_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.25, "max_line_length": 74, "alphanum_fraction": 0.5948166877, "num_tokens": 620, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619263765707, "lm_q2_score": 0.7490872187162397, "lm_q1q2_score": 0.6175938913668585}} {"text": "module Data.Bool.Instance where\n\nopen import Class.Equality\nopen import Class.Show\nopen import Data.Bool\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary\n\ninstance\n Bool-Eq : Eq Bool\n Bool-Eq = record { _≟_ = helper }\n where\n helper : ∀ (x y : Bool) → Dec (x ≡ y)\n helper false false = yes refl\n helper false true = no (λ ())\n helper true false = no (λ ())\n helper true true = yes refl\n\n Bool-Show : Show Bool\n Bool-Show = record { show = λ { false → \"false\" ; true → \"true\" } }\n", "meta": {"hexsha": "7f01124a4460d6ab72bde7de683d4b2a22ce6ba7", "size": 541, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "stdlib-exts/Data/Bool/Instance.agda", "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 35, "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_issues_repo_path": "stdlib-exts/Data/Bool/Instance.agda", "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 10, "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_forks_repo_path": "stdlib-exts/Data/Bool/Instance.agda", "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "avg_line_length": 25.7619047619, "max_line_length": 69, "alphanum_fraction": 0.6506469501, "num_tokens": 148, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8244619091240701, "lm_q2_score": 0.7490872187162397, "lm_q1q2_score": 0.6175938784432309}} {"text": "{-# OPTIONS --prop --rewriting #-}\n\nopen import Calf.CostMonoid\nopen import Data.Nat using (ℕ)\n\nmodule Examples.Sorting.Comparable\n (costMonoid : CostMonoid) (fromℕ : ℕ → CostMonoid.ℂ costMonoid) where\n\nopen CostMonoid costMonoid using (ℂ)\n\nopen import Calf costMonoid\nopen import Calf.Types.Bool\nopen import Calf.Types.Bounded costMonoid\n\nopen import Relation.Nullary\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as Eq using (_≡_; refl; module ≡-Reasoning)\nopen import Data.Product using (_×_; _,_; proj₁; proj₂; ∃)\nopen import Function\n\n\nrecord Comparable : Set₁ where\n field\n A : tp pos\n _≤_ : val A → val A → Set\n _≤ᵇ_ : val A → val A → cmp (F bool)\n ≤ᵇ-reflects-≤ : ∀ {x y b} → ◯ ((x ≤ᵇ y) ≡ ret b → Reflects (x ≤ y) b)\n ≤-refl : Reflexive _≤_\n ≤-trans : Transitive _≤_\n ≤-total : Total _≤_\n ≤-antisym : Antisymmetric _≡_ _≤_\n h-cost : (x y : val A) → IsBounded bool (x ≤ᵇ y) (fromℕ 1)\n\nNatComparable : Comparable\nNatComparable = record\n { A = nat\n ; _≤_ = _≤_\n ; _≤ᵇ_ = λ x y → step (F bool) (fromℕ 1) (ret (x ≤ᵇ y))\n ; ≤ᵇ-reflects-≤ = reflects\n ; ≤-refl = ≤-refl\n ; ≤-trans = ≤-trans\n ; ≤-total = ≤-total\n ; ≤-antisym = ≤-antisym\n ; h-cost = λ _ _ →\n bound/relax\n (λ u → CostMonoid.≤-reflexive costMonoid (CostMonoid.+-identityʳ costMonoid (fromℕ 1)))\n (bound/step (fromℕ 1) (CostMonoid.zero costMonoid) bound/ret)\n }\n where\n open import Calf.Types.Nat\n\n open import Data.Nat\n open import Data.Nat.Properties\n\n ret-injective : ∀ {𝕊 v₁ v₂} → ret {U (meta 𝕊)} v₁ ≡ ret {U (meta 𝕊)} v₂ → v₁ ≡ v₂\n ret-injective {𝕊} = Eq.cong (λ e → bind {U (meta 𝕊)} (meta 𝕊) e id)\n\n reflects : ∀ {m n b} → ◯ (step (F bool) (fromℕ 1) (ret (m ≤ᵇ n)) ≡ ret {bool} b → Reflects (m ≤ n) b)\n reflects {m} {n} {b} u h with ret-injective (Eq.subst (_≡ ret b) (step/ext (F bool) (ret (m ≤ᵇ n)) (fromℕ 1) u) h)\n ... | refl = ≤ᵇ-reflects-≤ m n\n", "meta": {"hexsha": "395aa45da6e443c6d6a7400031f40cf1c078fbd9", "size": 1937, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Examples/Sorting/Comparable.agda", "max_stars_repo_name": "jonsterling/agda-calf", "max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 29, "max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z", "max_issues_repo_path": "src/Examples/Sorting/Comparable.agda", "max_issues_repo_name": "jonsterling/agda-calf", "max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Examples/Sorting/Comparable.agda", "max_forks_repo_name": "jonsterling/agda-calf", "max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z", "avg_line_length": 31.7540983607, "max_line_length": 118, "alphanum_fraction": 0.6179659267, "num_tokens": 770, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8519528094861981, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.6175552683018822}} {"text": "\nmodule FamilyPattern where\n\ndata _==_ {A : Set}(x : A) : A -> Set where\n refl : x == x\n\npostulate C : {A : Set} -> A -> Set\n\n-- We can't solve unify x = y since the type is a meta variable.\nsubst : {A : Set}{x y : A} -> x == y -> C y -> C x\nsubst refl cx = cx\n-- subst {A} refl cx = cx -- works\n-- subst {x = x} .{x} refl cx = cx -- works\n\n", "meta": {"hexsha": "c4f29572ec642c806fe4eabcd5062ef15bffb7f0", "size": 351, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/bugs/FamilyPattern.agda", "max_stars_repo_name": "alhassy/agda", "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/bugs/FamilyPattern.agda", "max_issues_repo_name": "alhassy/agda", "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/bugs/FamilyPattern.agda", "max_forks_repo_name": "alhassy/agda", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 23.4, "max_line_length": 64, "alphanum_fraction": 0.5270655271, "num_tokens": 123, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8519527944504227, "lm_q2_score": 0.7248702702332475, "lm_q1q2_score": 0.6175552523392482}} {"text": "{-# OPTIONS --cubical #-}\n\nmodule Type.Cubical.InductiveInterval where\n\nopen import Functional\nimport Lvl\nopen import Type\nimport Type.Cubical as Cubical\nimport Type.Cubical.Path as Cubical\nimport Type.Cubical.Path.Proofs as Cubical\n\nprivate variable ℓ ℓ₁ ℓ₂ : Lvl.Level\nprivate variable A B P : Type{ℓ}\n\ndata Interval : Type{Lvl.𝟎} where\n 𝟎 : Interval\n 𝟏 : Interval\n segment : Cubical.Path 𝟎 𝟏\n\nelim : (P : Interval → Type{ℓ}) → (p0 : P(𝟎)) → (p1 : P(𝟏)) → (Cubical.PathP(\\i → P(segment i)) p0 p1) → ((i : Interval) → P(i))\nelim(P) p0 _ _ 𝟎 = p0\nelim(P) _ p1 _ 𝟏 = p1\nelim(P) _ _ ps (segment i) = ps(i)\n\nflip : Interval → Interval\nflip 𝟎 = 𝟏\nflip 𝟏 = 𝟎\nflip (segment i) = segment(Cubical.Interval.flip i)\n\nmin : Interval → Interval → Interval\nmin 𝟎 𝟎 = 𝟎\nmin 𝟎 𝟏 = 𝟎\nmin 𝟏 𝟎 = 𝟎\nmin 𝟏 𝟏 = 𝟏\nmin 𝟎 (segment i) = 𝟎\nmin 𝟏 (segment i) = segment i\nmin (segment i) 𝟎 = 𝟎\nmin (segment i) 𝟏 = segment i\nmin (segment i) (segment j) = segment(Cubical.Interval.min i j)\n\nmax : Interval → Interval → Interval\nmax = flip ∘₂ (min on₂ flip)\n\nopen import Structure.Relator.Properties\nopen import Type.Cubical.Path.Equality\nopen import Type.Properties.Singleton\n\ninstance\n Interval-unit : IsUnit(Interval)\n IsUnit.unit Interval-unit = 𝟏\n IsUnit.uniqueness Interval-unit {𝟎} = segment\n IsUnit.uniqueness Interval-unit {𝟏} = reflexivity(Cubical.Path)\n IsUnit.uniqueness Interval-unit {segment i} j = segment(Cubical.Interval.max i j)\n\ntransp : (P : Interval → Type{ℓ}) → P(𝟎) → P(𝟏)\ntransp(P) = sub₂(Cubical.Path)(_→ᶠ_) (Cubical.map P(segment))\n", "meta": {"hexsha": "b11defe370581e21fd703922185b4853dc12bd4d", "size": 1640, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Type/Cubical/InductiveInterval.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Type/Cubical/InductiveInterval.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Type/Cubical/InductiveInterval.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.7719298246, "max_line_length": 128, "alphanum_fraction": 0.6493902439, "num_tokens": 619, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357666736772, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.6175307832073191}} {"text": "\nopen import Oscar.Prelude\nopen import Oscar.Class.IsCategory\nopen import Oscar.Class.IsPrefunctor\nopen import Oscar.Class.Reflexivity\nopen import Oscar.Class.Smap\nopen import Oscar.Class.Surjection\nopen import Oscar.Class.Surjidentity\nopen import Oscar.Class.Transitivity\n\nmodule Oscar.Class.IsFunctor where\n\nmodule _\n {𝔬₁} {𝔒₁ : Ø 𝔬₁}\n {𝔯₁} (_∼₁_ : 𝔒₁ → 𝔒₁ → Ø 𝔯₁)\n {ℓ₁} (_∼̇₁_ : ∀ {x y} → x ∼₁ y → x ∼₁ y → Ø ℓ₁)\n (ε₁ : Reflexivity.type _∼₁_)\n (_↦₁_ : Transitivity.type _∼₁_)\n {𝔬₂} {𝔒₂ : Ø 𝔬₂}\n {𝔯₂} (_∼₂_ : 𝔒₂ → 𝔒₂ → Ø 𝔯₂)\n {ℓ₂} (_∼̇₂_ : ∀ {x y} → x ∼₂ y → x ∼₂ y → Ø ℓ₂)\n (ε₂ : Reflexivity.type _∼₂_)\n (_↦₂_ : Transitivity.type _∼₂_)\n {surjection : Surjection.type 𝔒₁ 𝔒₂}\n (smap : Smap.type _∼₁_ _∼₂_ surjection surjection)\n where\n record IsFunctor : Ø 𝔬₁ ∙̂ 𝔯₁ ∙̂ ℓ₁ ∙̂ 𝔬₂ ∙̂ 𝔯₂ ∙̂ ℓ₂ where\n constructor ∁\n field\n ⦃ `IsPrefunctor ⦄ : IsPrefunctor _∼₁_ _∼̇₁_ _↦₁_ _∼₂_ _∼̇₂_ _↦₂_ smap\n overlap ⦃ `IsCategory₁ ⦄ : IsCategory _∼₁_ _∼̇₁_ ε₁ _↦₁_\n overlap ⦃ `IsCategory₂ ⦄ : IsCategory _∼₂_ _∼̇₂_ ε₂ _↦₂_\n overlap ⦃ `𝒮urjidentity ⦄ : Surjidentity.class _∼₁_ _∼₂_ _∼̇₂_ smap ε₁ ε₂\n", "meta": {"hexsha": "b0135d27b39ab0abfa37dd3e339be2da659dd8db", "size": 1121, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/IsFunctor.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/IsFunctor.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/IsFunctor.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.9705882353, "max_line_length": 79, "alphanum_fraction": 0.643175736, "num_tokens": 566, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9046505248181418, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.617490687063188}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\nopen import homotopy.CircleHSpace\nopen import homotopy.LoopSpaceCircle\nopen import homotopy.Pi2HSusp\nopen import homotopy.IterSuspensionStable\n\n-- This summerizes all [πₙ Sⁿ]\nmodule homotopy.PinSn where\n\n private\n π1S¹-iso-ℤ : πS 0 ⊙S¹ ≃ᴳ ℤ-group\n π1S¹-iso-ℤ = ΩS¹-iso-ℤ ∘eᴳ unTrunc-iso ΩS¹-group-structure ΩS¹-is-set\n\n private\n πS-SphereS'-iso-ℤ : ∀ n → πS n (⊙Susp^ n ⊙S¹) ≃ᴳ ℤ-group\n πS-SphereS'-iso-ℤ 0 = π1S¹-iso-ℤ\n πS-SphereS'-iso-ℤ 1 =\n πS 1 ⊙S²\n ≃ᴳ⟨ Pi2HSusp.π₂-Susp S¹-level S¹-conn ⊙S¹-hSpace ⟩\n πS 0 ⊙S¹\n ≃ᴳ⟨ πS-SphereS'-iso-ℤ O ⟩\n ℤ-group\n ≃ᴳ∎\n πS-SphereS'-iso-ℤ (S (S n)) =\n πS (S (S n)) (⊙Susp^ (S (S n)) ⊙S¹)\n ≃ᴳ⟨ Susp^StableSucc.stable ⊙S¹ S¹-conn\n (S n) (S n) (≤-ap-S $ ≤-ap-S $ *2-increasing n) ⟩\n πS (S n) (⊙Susp^ (S n) ⊙S¹)\n ≃ᴳ⟨ πS-SphereS'-iso-ℤ (S n) ⟩\n ℤ-group\n ≃ᴳ∎\n\n πS-SphereS-iso-ℤ : ∀ n → πS n (⊙Sphere (S n)) ≃ᴳ ℤ-group\n πS-SphereS-iso-ℤ n = πS-SphereS'-iso-ℤ n\n ∘eᴳ πS-emap n (⊙Susp^-Susp-split-iso n ⊙S⁰)\n", "meta": {"hexsha": "9bf8061456b36e73cab5a0a6a2b3dba538965948", "size": 1117, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/homotopy/PinSn.agda", "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "theorems/homotopy/PinSn.agda", "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "theorems/homotopy/PinSn.agda", "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "avg_line_length": 29.3947368421, "max_line_length": 73, "alphanum_fraction": 0.5684870188, "num_tokens": 571, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872045937171068, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.6174574230053425}} {"text": "{-# OPTIONS --without-K #-}\nmodule hott.level.closure.core where\n\nopen import level\nopen import decidable\nopen import equality\nopen import function.isomorphism.core\n-- open import function.isomorphism.properties\nopen import sum\nopen import hott.level.core\nopen import hott.equivalence.core\nopen import hott.univalence\nopen import sets.nat.core\n-- open import sets.nat.ordering.leq.core\n-- open import sets.nat.ordering.leq.decide\nopen import sets.empty\nopen import sets.unit\n\nΣ-contr : ∀ {i j}{X : Set i}{Y : X → Set j}\n → contr X → ((x : X) → contr (Y x))\n → contr (Σ X Y)\nΣ-contr {X = X}{Y = Y} (x₀ , cx) hY\n = (x₀ , proj₁ (hY x₀)) , λ { (x , y) → c x y }\n where\n c : (x : X)(y : Y x) → (x₀ , proj₁ (hY x₀)) ≡ (x , y)\n c x y = ap (λ x → (x , proj₁ (hY x))) (cx x)\n · ap (_,_ x) (proj₂ (hY x) y)\n\n×-contr : ∀ {i j}{X : Set i}{Y : Set j}\n → contr X → contr Y\n → contr (X × Y)\n×-contr hX hY = Σ-contr hX (λ _ → hY)\n\nunique-contr : ∀ {i}{A B : Set i}\n → contr A\n → contr B\n → A ≡ B\nunique-contr {i}{A}{B} hA hB = ≈⇒≡ (f , f-we)\n where\n f : A → B\n f _ = proj₁ hB\n\n f-we : weak-equiv f\n f-we b = ×-contr hA (h↑ hB _ _)\n\n-- h-≤ : ∀ {i n m}{X : Set i}\n-- → n ≤ m → h n X → h m X\n-- h-≤ {m = 0} z≤n hX = hX\n-- h-≤ {m = suc m} z≤n hX = λ x y\n-- → h-≤ {m = m} z≤n (h↑ hX x y)\n-- h-≤ (s≤s p) hX = λ x y\n-- → h-≤ p (hX x y)\n-- \n-- h! : ∀ {i n m}{X : Set i}\n-- → {p : True (n ≤? m)}\n-- → h n X → h m X\n-- h! {p = p} = h-≤ (witness p)\n\nabstract\n -- retractions preserve levels\n retract-level : ∀ {i j n} {X : Set i}{Y : Set j}\n → (f : X → Y)(g : Y → X)\n → ((y : Y) → f (g y) ≡ y)\n → h n X → h n Y\n retract-level {n = 0}{X}{Y} f g r (x , c) = (f x , c')\n where\n c' : (y : Y) → f x ≡ y\n c' y = ap f (c (g y)) · r y\n retract-level {n = suc n}{X}{Y} f g r hX = λ y y'\n → retract-level f' g' r' (hX (g y) (g y'))\n where\n f' : {y y' : Y} → g y ≡ g y' → y ≡ y'\n f' {y}{y'} p = sym (r y) · ap f p · r y'\n\n g' : {y y' : Y} → y ≡ y' → g y ≡ g y'\n g' = ap g\n\n r' : {y y' : Y}(p : y ≡ y') → f' (g' p) ≡ p\n r' {y}{.y} refl = ap (λ α → α · r y) (left-unit (sym (r y)))\n · right-inverse (r y)\n\n iso-level : ∀ {i j n}{X : Set i}{Y : Set j}\n → X ≅ Y → h n X → h n Y\n iso-level (iso f g H K) = retract-level f g K\n", "meta": {"hexsha": "693c40d24ec296db40d4f8ae61fa0ac253335ead", "size": 2435, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "hott/level/closure/core.agda", "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_issues_repo_path": "hott/level/closure/core.agda", "max_issues_repo_name": "HoTT/M-types", "max_issues_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-02-11T11:14:59.000Z", "max_issues_repo_issues_event_max_datetime": "2015-02-11T15:20:34.000Z", "max_forks_repo_path": "hott/level/closure/core.agda", "max_forks_repo_name": "HoTT/M-types", "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z", "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z", "avg_line_length": 28.6470588235, "max_line_length": 66, "alphanum_fraction": 0.4492813142, "num_tokens": 1016, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677699040321, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.6172997229581145}} {"text": "{-# OPTIONS --cubical --safe #-}\nmodule Cubical.Structures.Semigroup where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Data.Sigma\n\nopen import Cubical.Foundations.SIP renaming (SNS-PathP to SNS)\nopen import Cubical.Structures.NAryOp\n\nprivate\n variable\n ℓ ℓ' : Level\n\nraw-semigroup-structure : Type ℓ → Type ℓ\nraw-semigroup-structure X = X → X → X\n\nraw-semigroup-is-SNS : SNS {ℓ} raw-semigroup-structure _\nraw-semigroup-is-SNS = nAryFunSNS 2\n\nsemigroup-axioms : (X : Type ℓ) → raw-semigroup-structure X → Type ℓ\nsemigroup-axioms X _·_ = isSet X ×\n ((x y z : X) → (x · (y · z)) ≡ ((x · y) · z))\n\nsemigroup-structure : Type ℓ → Type ℓ\nsemigroup-structure = add-to-structure (raw-semigroup-structure) semigroup-axioms\n\nSemigroup : Type (ℓ-suc ℓ)\nSemigroup {ℓ} = TypeWithStr ℓ semigroup-structure\n\n-- Operations for extracting components\n\n⟨_⟩ : Semigroup → Type ℓ\n⟨ G , _ ⟩ = G\n\nsemigroup-operation : (G : Semigroup {ℓ}) → ⟨ G ⟩ → ⟨ G ⟩ → ⟨ G ⟩\nsemigroup-operation (_ , f , _) = f\n\nmodule semigroup-operation-syntax where\n\n semigroup-operation-syntax : (G : Semigroup {ℓ}) → ⟨ G ⟩ → ⟨ G ⟩ → ⟨ G ⟩\n semigroup-operation-syntax = semigroup-operation\n\n infixl 20 semigroup-operation-syntax\n syntax semigroup-operation-syntax G x y = x ·⟨ G ⟩ y\n\nopen semigroup-operation-syntax\n\nsemigroup-isSet : (G : Semigroup {ℓ}) → isSet ⟨ G ⟩\nsemigroup-isSet (_ , _ , P , _) = P\n\nsemigroup-assoc : (G : Semigroup {ℓ})\n → (x y z : ⟨ G ⟩) → (x ·⟨ G ⟩ (y ·⟨ G ⟩ z)) ≡ ((x ·⟨ G ⟩ y) ·⟨ G ⟩ z)\nsemigroup-assoc (_ , _ , _ , P) = P\n\n-- Semigroup equivalences\n\nsemigroup-iso : StrIso semigroup-structure ℓ\nsemigroup-iso = add-to-iso (nAryFunIso 2) semigroup-axioms\n\nsemigroup-axiom-isProp : (X : Type ℓ)\n → (s : raw-semigroup-structure X)\n → isProp (semigroup-axioms X s)\nsemigroup-axiom-isProp X _·_ = isPropΣ isPropIsSet\n λ isSetX → isPropΠ (λ x → isPropΠ (λ y → isPropΠ (λ z → isSetX _ _)))\n\nsemigroup-is-SNS : SNS {ℓ} semigroup-structure semigroup-iso\nsemigroup-is-SNS = add-axioms-SNS _ semigroup-axiom-isProp (nAryFunSNS 2)\n\nSemigroupPath : (M N : Semigroup {ℓ}) → (M ≃[ semigroup-iso ] N) ≃ (M ≡ N)\nSemigroupPath = SIP semigroup-is-SNS\n\n-- Semigroup ·syntax\n\nmodule semigroup-·syntax (G : Semigroup {ℓ}) where\n\n infixr 18 _·_\n\n _·_ : ⟨ G ⟩ → ⟨ G ⟩ → ⟨ G ⟩\n _·_ = semigroup-operation G\n", "meta": {"hexsha": "0fb0e0ad6bb657f87ee1f1c9d1cb9f3520948a4a", "size": 2482, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Structures/Semigroup.agda", "max_stars_repo_name": "cmester0/cubical", "max_stars_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-03-23T23:52:11.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-23T23:52:11.000Z", "max_issues_repo_path": "Cubical/Structures/Semigroup.agda", "max_issues_repo_name": "cmester0/cubical", "max_issues_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Structures/Semigroup.agda", "max_forks_repo_name": "cmester0/cubical", "max_forks_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.2682926829, "max_line_length": 101, "alphanum_fraction": 0.64544722, "num_tokens": 862, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677622198946, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.617299717364251}} {"text": "------------------------------------------------------------------------------\n-- Agda-Prop Library.\n-- Theorems of ∨ connective.\n------------------------------------------------------------------------------\n\nopen import Data.Nat using ( ℕ )\n\nmodule Data.PropFormula.Theorems.Disjunction ( n : ℕ ) where\n\n------------------------------------------------------------------------------\n\nopen import Data.PropFormula.Syntax n\nopen import Data.PropFormula.Theorems.Classical n\nopen import Data.PropFormula.Properties n\n\nopen import Data.PropFormula.Theorems.Conjunction n using ( ∧-dmorgan₁ )\nopen import Data.PropFormula.Theorems.Implication n using ( vanDalen244e )\n\nopen import Function using ( _$_; _∘_ )\nopen import Relation.Binary.PropositionalEquality using ( _≡_ )\n\n------------------------------------------------------------------------------\n\n-- Theorem.\n∨-assoc₁\n : ∀ {Γ} {φ ψ γ}\n → Γ ⊢ φ ∨ (ψ ∨ γ)\n → Γ ⊢ (φ ∨ ψ) ∨ γ\n\n-- Proof.\n∨-assoc₁ {Γ}{φ}{ψ}{γ} =\n ⊃-elim\n (⊃-intro\n (∨-elim\n (∨-intro₁ γ\n (∨-intro₁ ψ\n (assume φ)))\n (⊃-elim\n (⊃-intro\n (∨-elim {Γ = Γ , ψ ∨ γ}\n (∨-intro₁ γ\n (∨-intro₂ φ (assume {Γ = Γ , ψ ∨ γ} ψ)))\n (∨-intro₂ (φ ∨ ψ) (assume {Γ = Γ , ψ ∨ γ} γ))))\n (assume (ψ ∨ γ)))))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n∨-assoc₂\n : ∀ {Γ} {φ ψ γ}\n → Γ ⊢ (φ ∨ ψ) ∨ γ\n → Γ ⊢ φ ∨ (ψ ∨ γ)\n\n-- Proof.\n∨-assoc₂ {Γ}{φ}{ψ}{γ} =\n ⊃-elim\n (⊃-intro\n (∨-elim\n (⊃-elim\n (⊃-intro\n (∨-elim {Γ = Γ , φ ∨ ψ}\n (∨-intro₁ (ψ ∨ γ)\n (assume {Γ = Γ , φ ∨ ψ} φ))\n (∨-intro₂ φ\n (∨-intro₁ γ\n (assume {Γ = Γ , φ ∨ ψ} ψ)))))\n (assume (φ ∨ ψ)))\n (∨-intro₂ φ\n (∨-intro₂ ψ\n (assume γ)))))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n∨-assoc\n : ∀ {Γ} {φ ψ γ}\n → Γ ⊢ (φ ∨ (ψ ∨ γ)) ⇔ ((φ ∨ ψ) ∨ γ)\n\n-- Proof.\n∨-assoc {φ = φ}{ψ}{γ} =\n ⇔-intro\n (∨-assoc₁ (assume (φ ∨ (ψ ∨ γ))))\n (∨-assoc₂ (assume (φ ∨ ψ ∨ γ)))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n∨-comm\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ φ ∨ ψ\n → Γ ⊢ ψ ∨ φ\n\n-- Proof.\n∨-comm {φ = φ}{ψ} =\n ⊃-elim $\n ⊃-intro\n (∨-elim\n (∨-intro₂ ψ\n (assume φ))\n (∨-intro₁ φ $\n assume ψ))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n∨-dist₁\n : ∀ {Γ} {φ ψ γ}\n → Γ ⊢ φ ∨ (ψ ∧ γ)\n → Γ ⊢ (φ ∨ ψ) ∧ (φ ∨ γ)\n\n-- Proof.\n∨-dist₁ {Γ}{φ}{ψ}{γ} =\n ⊃-elim\n (⊃-intro\n (∨-elim\n (∧-intro\n (∨-intro₁ ψ\n (assume φ))\n (∨-intro₁ γ\n (assume φ)))\n (∧-intro\n (∨-intro₂ φ\n (∧-proj₁\n (assume (ψ ∧ γ))))\n (∨-intro₂ φ\n (∧-proj₂\n (assume (ψ ∧ γ)))))))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n∨-dist₂\n : ∀ {Γ} {φ ψ γ}\n → Γ ⊢ (φ ∨ ψ) ∧ (φ ∨ γ)\n → Γ ⊢ φ ∨ (ψ ∧ γ)\n\n-- Proof.\n∨-dist₂ {Γ}{φ}{ψ}{γ} Γ⊢⟪φ∨ψ⟫∧⟪φ∨γ⟫ =\n ⊃-elim\n (⊃-intro\n (∨-elim\n (∨-intro₁ (ψ ∧ γ)\n (assume φ))\n (⊃-elim\n (⊃-intro\n (∨-elim\n (∨-intro₁ (ψ ∧ γ)\n (assume {Γ = Γ , ψ} φ))\n (∨-intro₂ φ\n (∧-intro\n (weaken γ\n (assume ψ))\n (assume {Γ = Γ , ψ} γ)))))\n (∧-proj₂\n (weaken ψ Γ⊢⟪φ∨ψ⟫∧⟪φ∨γ⟫)))))\n (∧-proj₁ Γ⊢⟪φ∨ψ⟫∧⟪φ∨γ⟫)\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n∨-dist\n : ∀ {Γ} {φ ψ γ}\n → Γ ⊢ (φ ∨ (ψ ∧ γ)) ⇔ ((φ ∨ ψ) ∧ (φ ∨ γ))\n\n-- Proof.\n∨-dist {φ = φ}{ψ}{γ} =\n ⇔-intro\n (∨-dist₁ (assume (φ ∨ (ψ ∧ γ))))\n (∨-dist₂ (assume (φ ∨ ψ ∧ (φ ∨ γ))))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n∨-equiv\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ φ ∨ ψ\n → Γ ⊢ ¬ (¬ φ ∧ ¬ ψ)\n∨-to-¬¬∧¬ = ∨-equiv\n\n-- Proof.\n∨-equiv {Γ}{φ}{ψ} Γ⊢φ∨ψ =\n ¬-intro\n (⊃-elim\n (⊃-intro\n (∨-elim {Γ = Γ , ¬ φ ∧ ¬ ψ}\n (¬-elim\n (weaken φ\n (∧-proj₁\n (assume (¬ φ ∧ ¬ ψ))))\n (assume {Γ = Γ , ¬ φ ∧ ¬ ψ } φ))\n (¬-elim\n (weaken ψ\n (∧-proj₂\n (assume (¬ φ ∧ ¬ ψ))))\n (assume {Γ = Γ , ¬ φ ∧ ¬ ψ} ψ))))\n (weaken (¬ φ ∧ ¬ ψ) Γ⊢φ∨ψ))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n∨-dmorgan₁\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ ¬ (φ ∨ ψ)\n → Γ ⊢ ¬ φ ∧ ¬ ψ\n¬∨-to-¬∧¬ = ∨-dmorgan₁\n\n-- Proof.\n∨-dmorgan₁ {Γ}{φ}{ψ} =\n ⊃-elim $\n ⊃-intro $\n ∧-intro\n (¬-intro $\n ¬-elim\n (weaken φ $\n assume (¬ (φ ∨ ψ)))\n (∨-intro₁ ψ $\n assume {Γ = Γ , ¬ (φ ∨ ψ)} φ))\n (¬-intro $\n ¬-elim\n (weaken ψ $\n assume (¬ (φ ∨ ψ)))\n (∨-intro₂ φ $\n assume {Γ = Γ , ¬ (φ ∨ ψ)} ψ))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n∨-dmorgan₂\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ ¬ φ ∧ ¬ ψ\n → Γ ⊢ ¬ (φ ∨ ψ)\n¬∧¬-to-¬∨ = ∨-dmorgan₂\n\n-- Proof.\n∨-dmorgan₂ {φ = φ}{ψ} Γ⊢¬φ∧¬ψ =\n ¬-intro\n (∨-elim\n (¬-elim\n (weaken φ\n (∧-proj₁ Γ⊢¬φ∧¬ψ ))\n (assume φ))\n (¬-elim\n (weaken ψ\n (∧-proj₂ Γ⊢¬φ∧¬ψ ))\n (assume ψ)))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n∨-dmorgan\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ ¬ (φ ∨ ψ) ⇔ (¬ φ ∧ ¬ ψ)\n¬∨-⇔-¬∧¬ = ∨-dmorgan\n\n-- Proof.\n∨-dmorgan {φ = φ}{ψ} =\n ⇔-intro\n (∨-dmorgan₁\n (assume (¬ (φ ∨ ψ))))\n (∨-dmorgan₂\n (assume (¬ φ ∧ ¬ ψ)))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nlem1\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ ¬ ¬ φ ∨ ¬ ¬ ψ\n → Γ ⊢ φ ∨ ψ\n¬¬∨¬¬-to-∨ = lem1\n\n-- Proof.\nlem1 {φ = φ}{ψ} =\n ⊃-elim $\n ⊃-intro $\n ∨-elim\n (∨-intro₁ ψ $\n ⊃-elim vanDalen244e $ assume $ ¬ ¬ φ)\n (∨-intro₂ φ $\n ⊃-elim vanDalen244e $ assume $ ¬ ¬ ψ)\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nlem2\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ (φ ∨ ψ) ∧ ¬ ψ\n → Γ ⊢ φ\n\n-- Proof.\nlem2 {φ = φ}{ψ} Γ⊢⟪φ∨ψ⟫∧¬ψ =\n ⊃-elim\n (⊃-intro $\n (∨-elim\n (assume φ)\n (⊥-elim φ\n (¬-elim\n (weaken ψ (∧-proj₂ Γ⊢⟪φ∨ψ⟫∧¬ψ))\n (assume ψ)))))\n (∧-proj₁ Γ⊢⟪φ∨ψ⟫∧¬ψ)\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nresolve₀\n : ∀ {Γ} {φ ψ γ}\n → Γ ⊢ φ ∨ ψ → Γ ⊢ ¬ φ ∨ γ\n → Γ ⊢ ψ ∨ γ\n\n-- Proof.\nresolve₀ {Γ}{φ}{ψ}{γ} Γ⊢φ∨ψ Γ⊢¬φ∨γ =\n lem1 $\n ∧-dmorgan₁ $\n ¬-intro $\n ¬-elim\n (lem2 {Γ = Γ , ¬ ψ ∧ ¬ γ} $\n ∧-intro\n (weaken (¬ ψ ∧ ¬ γ) Γ⊢¬φ∨γ)\n (∧-proj₂ $ assume $ ¬ ψ ∧ ¬ γ))\n (lem2 $\n ∧-intro\n (weaken (¬ ψ ∧ ¬ γ) Γ⊢φ∨ψ)\n (∧-proj₁ $ assume $ ¬ ψ ∧ ¬ γ))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nresolve₁\n : ∀ {Γ} {φ ψ γ}\n → Γ ⊢ ψ ∨ φ → Γ ⊢ ¬ φ ∨ γ\n → Γ ⊢ ψ ∨ γ\n\n-- Proof.\nresolve₁ = resolve₀ ∘ ∨-comm\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nresolve₂\n : ∀ {Γ} {φ ψ γ}\n → Γ ⊢ φ ∨ ψ → Γ ⊢ γ ∨ ¬ φ\n → Γ ⊢ ψ ∨ γ\n\n-- Proof.\nresolve₂ Γ⊢φ∨ψ Γ⊢γ∨¬φ = resolve₀ Γ⊢φ∨ψ (∨-comm Γ⊢γ∨¬φ)\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nresolve₃\n : ∀ {Γ} {φ ψ γ}\n → Γ ⊢ ψ ∨ φ → Γ ⊢ γ ∨ ¬ φ\n → Γ ⊢ ψ ∨ γ\n\n-- Proof.\nresolve₃ Γ⊢ψ∨φ Γ⊢γ∨¬φ = resolve₀ (∨-comm Γ⊢ψ∨φ) (∨-comm Γ⊢γ∨¬φ)\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nresolve₄\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ ¬ φ ∨ ψ → Γ ⊢ φ\n → Γ ⊢ ψ\n\n-- Proof.\nresolve₄ {φ = φ}{ψ} Γ⊢¬φ∨ψ Γ⊢φ =\n ⊃-elim\n (⊃-intro $\n ∨-elim\n (assume ψ)\n (assume ψ))\n (resolve₀\n (∨-intro₁ ψ Γ⊢φ)\n Γ⊢¬φ∨ψ)\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nresolve₅\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ ψ ∨ ¬ φ\n → Γ ⊢ φ\n → Γ ⊢ ψ\n\n-- Proof.\nresolve₅ = resolve₄ ∘ ∨-comm\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nresolve₆\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ ψ ∨ φ → Γ ⊢ ¬ φ\n → Γ ⊢ ψ\n\n-- Proof.\nresolve₆ {φ = φ}{ψ} Γ⊢ψ∨φ Γ⊢¬φ =\n ⊃-elim\n (⊃-intro $\n ∨-elim\n (assume ψ)\n (assume ψ))\n (resolve₀ (∨-comm Γ⊢ψ∨φ) (∨-intro₁ ψ Γ⊢¬φ))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nresolve₇\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ φ ∨ ψ → Γ ⊢ ¬ φ\n → Γ ⊢ ψ\n\n-- Proof.\nresolve₇ Γ⊢φ∨ψ Γ⊢¬φ = resolve₆ (∨-comm Γ⊢φ∨ψ) Γ⊢¬φ\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nresolve₈\n : ∀ {Γ} {φ}\n → Γ ⊢ φ → Γ ⊢ ¬ φ\n → Γ ⊢ ⊥\n\n-- Proof.\nresolve₈ Γ⊢φ Γ⊢¬φ = ¬-elim Γ⊢¬φ Γ⊢φ\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nresolve₉\n : ∀ {Γ} {φ}\n → Γ ⊢ ¬ φ → Γ ⊢ φ\n → Γ ⊢ ⊥\n\n-- Proof.\nresolve₉ = ¬-elim\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nsubst⊢∨₁\n : ∀ {Γ} {φ ψ γ}\n → Γ ⊢ φ ⊃ γ\n → Γ ⊢ φ ∨ ψ\n → Γ ⊢ γ ∨ ψ\n\n-- Proof.\nsubst⊢∨₁ {φ = φ}{ψ}{γ} Γ⊢φ⊃γ Γ⊢φ∨ψ =\n ⊃-elim\n (⊃-intro\n (∨-elim\n (∨-intro₁ ψ (⊃-elim (weaken φ Γ⊢φ⊃γ) (assume φ)))\n (∨-intro₂ γ (assume ψ))))\n Γ⊢φ∨ψ\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nsubst⊢∨₂\n : ∀ {Γ} {φ ψ γ}\n → Γ ⊢ ψ ⊃ γ\n → Γ ⊢ φ ∨ ψ\n → Γ ⊢ φ ∨ γ\n\n-- Proof.\nsubst⊢∨₂ {φ = φ}{ψ}{γ} Γ⊢ψ⊃γ Γ⊢φ∨ψ =\n ⊃-elim\n (⊃-intro\n (∨-elim\n (∨-intro₁ γ (assume φ))\n (∨-intro₂ φ (⊃-elim (weaken ψ Γ⊢ψ⊃γ) (assume ψ)))))\n Γ⊢φ∨ψ\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n∨-to-¬⊃\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ φ ∨ ψ\n → Γ ⊢ ¬ φ ⊃ ψ\n\n-- Proof.\n∨-to-¬⊃ {Γ}{φ}{ψ} Γ⊢φ∨ψ =\n ⊃-intro\n (⊃-elim\n (⊃-intro\n (∨-elim {Γ = Γ , ¬ φ}\n (⊥-elim ψ\n (¬-elim\n (weaken φ\n (assume (¬ φ)))\n (assume {Γ = Γ , ¬ φ} φ)))\n (assume {Γ = Γ , ¬ φ} ψ)))\n (weaken (¬ φ) Γ⊢φ∨ψ))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nφ∨⊥-to-φ\n : ∀ {Γ} {φ}\n → Γ ⊢ φ ∨ ⊥\n → Γ ⊢ φ\n\n-- Proof.\nφ∨⊥-to-φ {φ = φ} Γ⊢φ∨⊥ =\n ⊃-elim\n (⊃-intro\n (∨-elim\n (assume φ)\n (⊥-elim φ (assume ⊥))))\n Γ⊢φ∨⊥\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nsubst⊢∨₁≡\n : ∀ {Γ} {φ ψ γ}\n → φ ≡ γ\n → Γ ⊢ φ ∨ ψ\n → Γ ⊢ γ ∨ ψ\n\n-- Proof.\nsubst⊢∨₁≡ {φ = φ}{ψ}{γ} φ≡γ Γ⊢φ∨ψ =\n ⊃-elim\n (⊃-intro\n (∨-elim\n (∨-intro₁ ψ (subst φ≡γ (assume φ)))\n (∨-intro₂ γ (assume ψ))))\n Γ⊢φ∨ψ\n-------------------------------------------------------------------------- ∎\n", "meta": {"hexsha": "d8eecff313d154bedc39c7874c68f2e6f5d2f370", "size": 10938, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/PropFormula/Theorems/Disjunction.agda", "max_stars_repo_name": "jonaprieto/agda-prop", "max_stars_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 13, "max_stars_repo_stars_event_min_datetime": "2017-05-01T16:45:41.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T03:33:12.000Z", "max_issues_repo_path": "src/Data/PropFormula/Theorems/Disjunction.agda", "max_issues_repo_name": "jonaprieto/agda-prop", "max_issues_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 18, "max_issues_repo_issues_event_min_datetime": "2017-03-08T14:33:10.000Z", "max_issues_repo_issues_event_max_datetime": "2017-12-18T16:34:21.000Z", "max_forks_repo_path": "src/Data/PropFormula/Theorems/Disjunction.agda", "max_forks_repo_name": "jonaprieto/agda-prop", "max_forks_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-03-30T16:41:56.000Z", "max_forks_repo_forks_event_max_datetime": "2017-12-01T17:01:25.000Z", "avg_line_length": 21.6594059406, "max_line_length": 78, "alphanum_fraction": 0.2833241909, "num_tokens": 4470, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677660619633, "lm_q2_score": 0.7279754371026367, "lm_q1q2_score": 0.6172997051479041}} {"text": "-- Andreas and James, Nov 2011 and Oct 2012\n-- function with flexible arity\n-- {-# OPTIONS --no-coverage-check #-}\n-- {-# OPTIONS -v tc.cover:20 #-}\nmodule FlexibleInterpreter where\n\nopen import Common.Prelude using (Nat; zero; suc)\nopen import Common.MAlonzo hiding (main)\nopen import Common.Equality\n\ndata Ty : Set where\n nat : Ty\n arr : Ty -> Ty -> Ty\n\ndata Exp : Ty -> Set where\n zero : Exp nat\n suc : Exp (arr nat nat)\n pred : Exp (arr nat nat)\n app : {a b : Ty} -> Exp (arr a b) -> Exp a -> Exp b\n\nSem : Ty -> Set\nSem nat = Nat\nSem (arr a b) = Sem a -> Sem b\n\nmodule Flex where\n -- Haskell does not seem to handle this\n\n eval' : (a : Ty) -> Exp a -> Sem a\n eval' ._ zero = zero\n eval' ._ suc = suc\n eval' b (app f e) = eval' _ f (eval' _ e)\n eval' .(arr nat nat) pred zero = zero\n eval' ._ pred (suc n) = n\n\n eval : {a : Ty} -> Exp a -> Sem a\n eval zero = zero\n eval suc = suc\n eval pred zero = zero\n eval pred (suc n) = n\n eval (app f e) = eval f (eval e)\n\n testEvalSuc : ∀ {n} → eval suc n ≡ suc n\n testEvalSuc = refl\n\n testEvalPredZero : eval pred zero ≡ zero\n testEvalPredZero = refl\n\n testEvalPredSuc : ∀ {n} → eval pred (suc n) ≡ n\n testEvalPredSuc = refl\n\nmodule Rigid where\n -- This executes fine\n\n eval : {a : Ty} -> Exp a -> Sem a\n eval zero = zero\n eval suc = suc\n eval pred = λ { zero -> zero\n ; (suc n) -> n\n }\n eval (app f e) = eval f (eval e)\n\nopen Flex\n\nexpr = (app pred (app suc (app suc zero)))\ntest = eval expr\nmain = mainPrintNat test\n-- should print 1\n", "meta": {"hexsha": "e4279f86f7c43d0cd26a32e113f7f62ecf9a9e9a", "size": 1595, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/FlexibleInterpreter.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_issues_repo_path": "test/succeed/FlexibleInterpreter.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/FlexibleInterpreter.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 23.4558823529, "max_line_length": 54, "alphanum_fraction": 0.5774294671, "num_tokens": 523, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677468516187, "lm_q2_score": 0.7279754489059775, "lm_q1q2_score": 0.6172997011720974}} {"text": "------------------------------------------------------------------------\n-- Library stuff\n\ndata ⊥ : Set where\n\nrecord ⊤ : Set where\n constructor tt\n\ndata Bool : Set where\n true false : Bool\n\nif_then_else_ : ∀ {A : Set} → Bool → A → A → A\nif true then t else f = t\nif false then t else f = f\n\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n{-# BUILTIN NATURAL ℕ #-}\n\n_∸_ : ℕ → ℕ → ℕ\nm ∸ zero = m\nzero ∸ suc n = zero\nsuc m ∸ suc n = m ∸ n\n\n_≤_ : ℕ → ℕ → Bool\nzero ≤ n = true\nsuc m ≤ zero = false\nsuc m ≤ suc n = m ≤ n\n\ndata _⊎_ (A : Set) (B : Set) : Set where\n inj₁ : (x : A) → A ⊎ B\n inj₂ : (y : B) → A ⊎ B\n\n[_,_]₁ : ∀ {A : Set} {B : Set} {C : A ⊎ B → Set₁} →\n ((x : A) → C (inj₁ x)) → ((x : B) → C (inj₂ x)) →\n ((x : A ⊎ B) → C x)\n[ f , g ]₁ (inj₁ x) = f x\n[ f , g ]₁ (inj₂ y) = g y\n\ndata _≡_ {A : Set}(x : A) : A → Set where\n refl : x ≡ x\n\nrecord Σ (X : Set) (Y : X → Set) : Set where\n constructor _,_\n field\n proj₁ : X\n proj₂ : Y proj₁\n\n_×_ : Set → Set → Set\nX × Y = Σ X λ _ → Y\n\nrecord Sig : Set₁ where\n constructor _◃_\n field\n Parameter : Set\n Arity : Parameter → Set\n\nopen Sig public\n\n⟦_⟧ : Sig → Set → Set\n⟦ P ◃ A ⟧ X = Σ P λ p → A p → X\n\nAlg : Sig → Set → Set\nAlg Σ X = ⟦ Σ ⟧ X → X\n\ndata μ (C : Sig) : Set where\n sup : Alg C (μ C)\n\nconst^C : Set → Sig\nconst^C X = X ◃ λ _ → ⊥\n\n_⊎^C_ : Sig → Sig → Sig\n(P₁ ◃ A₁) ⊎^C (P₂ ◃ A₂) = (P₁ ⊎ P₂) ◃ [ A₁ , A₂ ]₁\n\n_⋆^C_ : Sig → Set → Sig\nC ⋆^C X = const^C X ⊎^C C\n\n_⋆_ : Sig → Set → Set\nC ⋆ X = μ (C ⋆^C X)\n\ndo : ∀ {C X} → Alg C (C ⋆ X)\ndo (p , k) = sup (inj₂ p , k)\n\nrecord Monad (T : Set → Set) : Set₁ where\n infixl 1 _>>=_\n field\n return : ∀ {X} → X → T X\n _>>=_ : ∀ {X Y} → T X → (X → T Y) → T Y\n\nmonad : ∀ {Σ} → Monad (_⋆_ Σ)\nmonad {Σ} = record\n { return = λ x → sup (inj₁ x , λ ())\n ; _>>=_ = _>>=_\n }\n where\n _>>=_ : ∀ {X Y} → Σ ⋆ X → (X → Σ ⋆ Y) → Σ ⋆ Y\n sup (inj₁ x , _) >>= f = f x\n sup (inj₂ p , k) >>= f = do (p , λ a → k a >>= f)\n\ngeneric : ∀ {Σ} (p : Parameter Σ) → Σ ⋆ Arity Σ p\ngeneric p = do (p , return)\n where\n open Monad monad\n\n------------------------------------------------------------------------\n-- Example\n\nΠ : (X : Set) → (X → Set) → Set\nΠ X Y = (x : X) → (X ◃ Y) ⋆ Y x\n\ncall : ∀ {X Y} → Π X Y\ncall x = generic x\n\ndom : ∀ {X Y} → ∀ {x} → (X ◃ Y) ⋆ Y x → (X → Set) → Set\ndom (sup (inj₁ _ , _)) R = ⊤\ndom {Y = Y} (sup (inj₂ x , k)) R\n = R x × ((y : Y x) → dom (k y) R)\n\ndata Dom {X}{Y} (f : (x : X) → (X ◃ Y) ⋆ Y x) : X → Set\n where\n ⟨_⟩ : ∀ {x} → dom (f x) (Dom f) → Dom f x\n\ndom-map : ∀ {X Y} {R₁ R₂ : X → Set} {x}\n {w : (X ◃ Y) ⋆ Y x} →\n (∀ {x} → R₁ x → R₂ x) → dom w R₁ → dom w R₂\ndom-map {w = sup (inj₁ _ , _)} f _ = tt\ndom-map {w = sup (inj₂ _ , _)} f (y₁ , k) =\n f y₁ , λ y₂ → dom-map f (k y₂)\n\n{-# TERMINATING #-}\nbove-capretta : ∀ {X Y} (f : Π X Y) → (x : X) → Dom f x → Y x\nbove-capretta {X}{Y} f x ⟨ d ⟩\n = helper (f x) (dom-map (λ {x′} → bove-capretta f x′) d)\n where\n helper : ∀ {x} (w : (X ◃ Y) ⋆ Y x) → dom w Y → Y x\n helper (sup (inj₁ y , _)) _ = y\n helper (sup (inj₂ _ , k)) (d , dk) = helper (k d) (dk d)\n\nmodule _ where\n open Monad monad\n gcd : Π (ℕ × ℕ) (λ _ → ℕ)\n gcd (0 , n) = return n\n gcd (m , 0) = return m\n gcd (suc m , suc n) = if m ≤ n\n then call (suc m , (n ∸ m))\n else call ((m ∸ n) , suc n)\n\nacc : Dom gcd (8 , 12)\nacc = ⟨ ⟨ ⟨ ⟨ _ ⟩ , _ ⟩ , _ ⟩ , _ ⟩ -- ⟨ ⟨ ⟨ ⟨ tt ⟩ , (λ _ → tt) ⟩ , (λ _ → tt) ⟩ , (λ _ → tt) ⟩\n\ntest-gcd′ : bove-capretta gcd (8 , 12) acc ≡ 4\ntest-gcd′ = refl\n", "meta": {"hexsha": "14ecde1b1af4cf9bbbbf493fc70359ec938fc88b", "size": 3595, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1324.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Succeed/Issue1324.agda", "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/Issue1324.agda", "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.0448717949, "max_line_length": 96, "alphanum_fraction": 0.4183588317, "num_tokens": 1647, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677468516187, "lm_q2_score": 0.7279754489059774, "lm_q1q2_score": 0.6172997011720973}} {"text": "{-# OPTIONS --rewriting --confluence-check #-}\n\nopen import Agda.Builtin.Nat using (Nat; zero; suc)\nopen import Agda.Builtin.Equality\nopen import Agda.Builtin.Equality.Rewrite\n\nvariable\n k l m n : Nat\n\npostulate\n max : Nat → Nat → Nat\n max-0l : max 0 n ≡ n\n max-0r : max m 0 ≡ m\n max-diag : max m m ≡ m\n max-ss : max (suc m) (suc n) ≡ suc (max m n)\n max-assoc : max (max k l) m ≡ max k (max l m)\n\n{-# REWRITE max-0l #-}\n{-# REWRITE max-0r #-}\n{-# REWRITE max-diag #-}\n{-# REWRITE max-ss #-}\n--{-# REWRITE max-assoc #-} -- not confluent!\n\npostulate\n _+_ : Nat → Nat → Nat\n plus-0l : 0 + n ≡ n\n plus-0r : m + 0 ≡ m\n plus-suc-l : (suc m) + n ≡ suc (m + n)\n plus-suc-r : m + (suc n) ≡ suc (m + n)\n plus-assoc : (k + l) + m ≡ k + (l + m)\n\n{-# REWRITE plus-0l #-}\n{-# REWRITE plus-0r #-}\n{-# REWRITE plus-suc-l #-}\n{-# REWRITE plus-suc-r #-}\n{-# REWRITE plus-assoc #-}\n\npostulate\n _*_ : Nat → Nat → Nat\n mult-0l : 0 * n ≡ 0\n mult-0r : m * 0 ≡ 0\n mult-suc-l : (suc m) * n ≡ n + (m * n)\n mult-suc-r : m * (suc n) ≡ (m * n) + m\n plus-mult-distr-l : k * (l + m) ≡ (k * l) + (k * m)\n plus-mult-distr-r : (k + l) * m ≡ (k * m) + (l * m)\n mult-assoc : (k * l) * m ≡ k * (l * m)\n\n{-# REWRITE mult-0l #-}\n{-# REWRITE mult-0r #-}\n{-# REWRITE mult-suc-l #-}\n{-# REWRITE mult-suc-r #-} -- requires rule plus-assoc!\n--{-# REWRITE plus-mult-distr-l #-}\n--{-# REWRITE plus-mult-distr-r #-}\n--{-# REWRITE mult-assoc #-}\n", "meta": {"hexsha": "f2da81c32b999eb10a60abf7269033db0633d45c", "size": 1419, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/RewritingConfluence.agda", "max_stars_repo_name": "hborum/agda", "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_issues_repo_path": "test/Succeed/RewritingConfluence.agda", "max_issues_repo_name": "hborum/agda", "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_forks_repo_path": "test/Succeed/RewritingConfluence.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-09-15T14:36:15.000Z", "max_forks_repo_forks_event_max_datetime": "2015-09-15T14:36:15.000Z", "avg_line_length": 25.8, "max_line_length": 55, "alphanum_fraction": 0.532769556, "num_tokens": 572, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972684083609, "lm_q2_score": 0.709019146082187, "lm_q1q2_score": 0.6172701318283806}} {"text": "module Lvl.Decidable where\n\nopen import Data.Boolean.Stmt\nopen import Logic.Propositional\nopen import Logic.Propositional.Theorems\nimport Lvl\nopen import Type.Properties.Decidable\nopen import Type.Properties.Decidable.Proofs\nopen import Type\n\nprivate variable ℓ ℓ₁ : Lvl.Level\n\n-- Changing classical propositions' universe levels by using their boolean representation.\nmodule _ (P : Type{ℓ}) ⦃ dec : Decidable(0)(P) ⦄ where\n Convert : Type{ℓ₁}\n Convert = Lvl.Up(IsTrue(decide(0)(P)))\n\n -- LvlConvert is satisfied whenever its proposition is.\n Convert-correctness : P ↔ Convert{ℓ₁}\n Convert-correctness = [↔]-transitivity decider-true ([↔]-intro Lvl.Up.obj Lvl.up)\n", "meta": {"hexsha": "4daf49118700d03a4a444d9972030d1970d95eac", "size": 674, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Lvl/Decidable.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Lvl/Decidable.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lvl/Decidable.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.0952380952, "max_line_length": 90, "alphanum_fraction": 0.7596439169, "num_tokens": 187, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8705972784807408, "lm_q2_score": 0.7090191214879992, "lm_q1q2_score": 0.6172701175582578}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\n\n-- an attempt to speed up [QuotGroup (quot-of-sub (ker-prop ...) (im-nprop ...))]\n-- which removes most intermediate constructions\n\nmodule groups.KernelImage {i j k}\n {G : Group i} {H : Group j} {K : Group k}\n (ψ : H →ᴳ K) (φ : G →ᴳ H) (H-ab : is-abelian H) where\n\n -- G ---φ--→ᴳ H ---ψ--→ᴳ K\n\n private\n module G = Group G\n module H = AbGroup (H , H-ab)\n module K = Group K\n module ψ = GroupHom ψ\n module φ = GroupHom φ\n\n ker-El : Type (lmax j k)\n ker-El = Σ H.El (λ h → ψ.f h == K.ident)\n\n ker-subtype : SubtypeProp H.El k\n ker-subtype = (λ h → ψ.f h == K.ident) , level\n where abstract level : ∀ h → is-prop (ψ.f h == K.ident)\n level h = K.El-is-set _ _\n\n ker-El=-out = Subtype=-out ker-subtype\n\n ker/im-rel' : Rel H.El (lmax i j)\n ker/im-rel' h₁ h₂ = Trunc -1 (hfiber φ.f (H.diff h₁ h₂))\n\n ker/im-rel : Rel ker-El (lmax i j)\n ker/im-rel (h₁ , _) (h₂ , _) = Trunc -1 (hfiber φ.f (H.diff h₁ h₂))\n\n private\n ker/im-El : Type (lmax (lmax i j) k)\n ker/im-El = SetQuot ker/im-rel\n\n ker/im-struct : GroupStructure ker/im-El\n ker/im-struct = record {M} where\n module M where\n ident : ker/im-El\n ident = q[ H.ident , lemma ]\n where abstract lemma = ψ.pres-ident\n\n inv : ker/im-El → ker/im-El\n inv = SetQuot-rec SetQuot-level inv' inv-rel\n where\n inv' : ker-El → ker/im-El\n inv' (h , ψh=0) = q[ H.inv h , lemma ]\n where abstract lemma = ψ.pres-inv h ∙ ap K.inv ψh=0 ∙ K.inv-ident\n\n abstract\n inv-rel : ∀ {ker₁ ker₂} → ker/im-rel ker₁ ker₂ → inv' ker₁ == inv' ker₂\n inv-rel {h₁ , _} {h₂ , _} = Trunc-rec (SetQuot-level _ _)\n λ{(g , φg=h₁h₂⁻¹) → quot-rel\n [ G.inv g , φ.pres-inv g ∙ ap H.inv φg=h₁h₂⁻¹\n ∙ H.inv-diff h₁ h₂ ∙ H.comm h₂ (H.inv h₁)\n ∙ ap (H.comp (H.inv h₁)) (! (H.inv-inv h₂)) ]}\n\n comp : ker/im-El → ker/im-El → ker/im-El\n comp = SetQuot-rec level comp' comp-rel where\n abstract\n level : is-set (ker/im-El → ker/im-El)\n level = →-is-set SetQuot-level\n\n comp' : ker-El → ker/im-El → ker/im-El\n comp' (h₁ , ψh₁=0) = SetQuot-rec SetQuot-level comp'' comp'-rel where\n\n comp'' : ker-El → ker/im-El\n comp'' (h₂ , ψh₂=0) = q[ H.comp h₁ h₂ , lemma ]\n where abstract lemma = ψ.pres-comp h₁ h₂ ∙ ap2 K.comp ψh₁=0 ψh₂=0\n ∙ K.unit-l K.ident\n\n abstract\n comp'-rel : ∀ {ker₂ ker₂'} → ker/im-rel ker₂ ker₂' → comp'' ker₂ == comp'' ker₂'\n comp'-rel {h₂ , _} {h₂' , _} = Trunc-rec (SetQuot-level _ _)\n λ{(g , φg=h₂h₂'⁻¹) → quot-rel\n [ g , ! ( ap (H.comp (H.comp h₁ h₂)) (H.inv-comp h₁ h₂')\n ∙ H.assoc h₁ h₂ (H.comp (H.inv h₂') (H.inv h₁))\n ∙ ap (H.comp h₁) (! $ H.assoc h₂ (H.inv h₂') (H.inv h₁))\n ∙ H.comm h₁ (H.comp (H.comp h₂ (H.inv h₂')) (H.inv h₁))\n ∙ H.assoc (H.comp h₂ (H.inv h₂')) (H.inv h₁) h₁\n ∙ ap2 H.comp (! φg=h₂h₂'⁻¹) (H.inv-l h₁)\n ∙ H.unit-r (φ.f g) )]}\n\n abstract\n comp-rel : ∀ {ker₁ ker₁'} → ker/im-rel ker₁ ker₁' → comp' ker₁ == comp' ker₁'\n comp-rel {h₁ , _} {h₁' , _} = Trunc-rec (level _ _)\n λ{(g , φg=h₁h₁'⁻¹) → λ= $ SetQuot-elim (λ _ → =-preserves-set SetQuot-level)\n (λ{(h₂ , _) → quot-rel\n [ g , ! ( ap (H.comp (H.comp h₁ h₂)) (H.inv-comp h₁' h₂)\n ∙ H.assoc h₁ h₂ (H.comp (H.inv h₂) (H.inv h₁'))\n ∙ ap (H.comp h₁) ( ! (H.assoc h₂ (H.inv h₂) (H.inv h₁'))\n ∙ ap (λ h → H.comp h (H.inv h₁')) (H.inv-r h₂)\n ∙ H.unit-l (H.inv h₁'))\n ∙ ! φg=h₁h₁'⁻¹ )]})\n (λ _ → prop-has-all-paths-↓ (SetQuot-level _ _))}\n\n abstract\n unit-l : ∀ k/i → comp ident k/i == k/i\n unit-l = SetQuot-elim\n (λ _ → =-preserves-set SetQuot-level)\n (λ{(h , _) → ap q[_] $ ker-El=-out (H.unit-l h)})\n (λ _ → prop-has-all-paths-↓ (SetQuot-level _ _))\n\n assoc : ∀ k/i₁ k/i₂ k/i₃ → comp (comp k/i₁ k/i₂) k/i₃ == comp k/i₁ (comp k/i₂ k/i₃)\n assoc = SetQuot-elim\n (λ _ → Π-is-set λ _ → Π-is-set λ _ → =-preserves-set SetQuot-level)\n (λ{(h₁ , _) → SetQuot-elim\n (λ _ → Π-is-set λ _ → =-preserves-set SetQuot-level)\n (λ{(h₂ , _) → SetQuot-elim\n (λ _ → =-preserves-set SetQuot-level)\n (λ{(h₃ , _) → ap q[_] $ ker-El=-out (H.assoc h₁ h₂ h₃)})\n (λ _ → prop-has-all-paths-↓ (SetQuot-level _ _))})\n (λ _ → prop-has-all-paths-↓ (Π-is-prop λ _ → SetQuot-level _ _))})\n (λ _ → prop-has-all-paths-↓ (Π-is-prop λ _ → Π-is-prop λ _ → SetQuot-level _ _))\n\n inv-l : ∀ k/i → comp (inv k/i) k/i == ident\n inv-l = SetQuot-elim\n (λ _ → =-preserves-set SetQuot-level)\n (λ{(h , _) → ap q[_] $ ker-El=-out (H.inv-l h)})\n (λ _ → prop-has-all-paths-↓ (SetQuot-level _ _))\n\n Ker/Im : Group (lmax i (lmax j k))\n Ker/Im = group _ SetQuot-level ker/im-struct\n\n module Ker/Im = Group Ker/Im\n\n {- correctness -}\n\n Ker/Im-β : Ker/Im ≃ᴳ QuotGroup (quot-of-sub (ker-propᴳ ψ) (im-npropᴳ φ H-ab))\n Ker/Im-β = ≃-to-≃ᴳ (ide _) to-pres-comp where\n abstract\n to-pres-comp : preserves-comp Ker/Im.comp\n (QuotGroup.comp (quot-of-sub (ker-propᴳ ψ) (im-npropᴳ φ H-ab))) (idf _)\n to-pres-comp = SetQuot-elim\n (λ _ → Π-is-set λ _ → =-preserves-set SetQuot-level)\n (λ _ → SetQuot-elim\n (λ _ → =-preserves-set SetQuot-level)\n (λ _ → ap q[_] $ ker-El=-out idp)\n (λ _ → prop-has-all-paths-↓ (SetQuot-level _ _)))\n (λ _ → prop-has-all-paths-↓ (Π-is-prop λ _ → SetQuot-level _ _))\n", "meta": {"hexsha": "3e1a6a4397cf0f4c8aca358aeab6cfdd056ac3f1", "size": 6023, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/groups/KernelImage.agda", "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "theorems/groups/KernelImage.agda", "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "theorems/groups/KernelImage.agda", "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "avg_line_length": 41.2534246575, "max_line_length": 92, "alphanum_fraction": 0.4874647186, "num_tokens": 2154, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972684083609, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.6172701157696561}} {"text": "open import Prelude\nopen import core\n\nmodule lemmas-ground where\n -- not ground types aren't hole to hole\n ground-arr-not-hole : ∀{τ} →\n (τ ground → ⊥) →\n (τ ≠ (⦇·⦈ ==> ⦇·⦈))\n ground-arr-not-hole notg refl = notg GHole\n\n ground-prod-not-hole : ∀{τ} →\n (τ ground → ⊥) →\n (τ ≠ (⦇·⦈ ⊗ ⦇·⦈))\n ground-prod-not-hole notg refl = notg GProd\n\n -- not ground types either have to be hole or an arrow or a prod\n notground : ∀{τ} →\n (τ ground → ⊥) →\n (τ == ⦇·⦈) +\n (Σ[ τ1 ∈ typ ] Σ[ τ2 ∈ typ ] (τ == (τ1 ==> τ2))) +\n (Σ[ τ1 ∈ typ ] Σ[ τ2 ∈ typ ] (τ == (τ1 ⊗ τ2)))\n notground {b} gnd = abort (gnd GBase)\n notground {⦇·⦈} gnd = Inl refl\n notground {τ ==> τ₁} gnd = Inr (Inl (τ , τ₁ , refl))\n notground {τ ⊗ τ₁} gnd = Inr (Inr (τ , τ₁ , refl))\n\n ground-arr-lem :\n (τ : typ) →\n ((τ ground) → ⊥) →\n (τ ≠ ⦇·⦈) →\n Σ[ τ1 ∈ typ ] Σ[ τ2 ∈ typ ]\n (((τ == (τ1 ==> τ2)) × ((τ1 ==> τ2) ≠ (⦇·⦈ ==> ⦇·⦈))) +\n ((τ == (τ1 ⊗ τ2)) × ((τ1 ⊗ τ2) ≠ (⦇·⦈ ⊗ ⦇·⦈))))\n ground-arr-lem b ng nh = abort (ng GBase)\n ground-arr-lem ⦇·⦈ ng nh = abort (nh refl)\n ground-arr-lem (τ1 ==> τ2) ng nh = τ1 , τ2 , Inl (refl , λ x → ng (lem' x))\n where\n lem' : ∀{τ1 τ2} → τ1 ==> τ2 == ⦇·⦈ ==> ⦇·⦈ → (τ1 ==> τ2) ground\n lem' refl = GHole\n ground-arr-lem (τ1 ⊗ τ2) ng nh = τ1 , τ2 , Inr (refl , (λ x → ng (lem' x)))\n where\n lem' : ∀{τ1 τ2} → τ1 ⊗ τ2 == ⦇·⦈ ⊗ ⦇·⦈ → (τ1 ⊗ τ2) ground\n lem' refl = GProd\n", "meta": {"hexsha": "8f29d13602179f65ba312b258b2180b41a9f5a24", "size": 1643, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lemmas-ground.agda", "max_stars_repo_name": "hazelgrove/hazel-palette-agda", "max_stars_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2020-10-04T06:45:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-19T15:38:31.000Z", "max_issues_repo_path": "lemmas-ground.agda", "max_issues_repo_name": "hazelgrove/hazel-palette-agda", "max_issues_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2020-09-30T20:27:56.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-20T20:44:13.000Z", "max_forks_repo_path": "lemmas-ground.agda", "max_forks_repo_name": "hazelgrove/hazelnut-livelits-agda", "max_forks_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.3409090909, "max_line_length": 77, "alphanum_fraction": 0.405356056, "num_tokens": 700, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972616934406, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.6172701110086491}} {"text": "{-# OPTIONS --without-K #-}\nmodule sets.fin.properties where\n\nopen import sum\nopen import decidable\nopen import equality\nopen import function.core\nopen import function.extensionality\nopen import function.isomorphism\nopen import function.overloading\nopen import sets.core\nopen import sets.nat.core\n hiding (_≟_; pred)\nopen import sets.nat.ordering\nopen import sets.fin.core\nopen import sets.empty\nopen import sets.properties\nopen import hott.level.core\nopen import hott.level.closure\nopen import hott.level.sets\n\npred : ∀ {n}(i : Fin (suc n))\n → ¬ (i ≡ zero) → Fin n\npred zero u = ⊥-elim (u refl)\npred (suc j) _ = j\n\npred-β : ∀ {n}(i : Fin (suc n))\n → (u : ¬ (i ≡ zero))\n → suc (pred i u) ≡ i\npred-β zero u = ⊥-elim (u refl)\npred-β (suc i) u = refl\n\npred-inj : ∀ {n}{i j : Fin (suc n)}\n → (u : ¬ (i ≡ zero))\n → (v : ¬ (j ≡ zero))\n → pred i u ≡ pred j v\n → i ≡ j\npred-inj {n} {zero} u v p = ⊥-elim (u refl)\npred-inj {n} {suc i} {zero} u v p = ⊥-elim (v refl)\npred-inj {n} {suc i} {suc j} u v p = ap suc p\n\ntoℕ : ∀ {n} → Fin n → ℕ\ntoℕ zero = 0\ntoℕ (suc i) = suc (toℕ i)\n\ntoℕ-sound : ∀ {n}(i : Fin n) → suc (toℕ i) ≤ n\ntoℕ-sound {zero} ()\ntoℕ-sound {suc n} zero = s≤s z≤n\ntoℕ-sound {suc n} (suc i) = s≤s (toℕ-sound i)\n\nfromℕ : ∀ {n i} → (suc i ≤ n) → Fin n\nfromℕ {zero} ()\nfromℕ {suc n} {0} _ = zero\nfromℕ {suc n} {suc i} (s≤s p) = suc (fromℕ p)\n\ntoℕ-iso : ∀ {n} → Fin n ≅ (Σ ℕ λ i → suc i ≤ n)\ntoℕ-iso {n} = record\n { to = λ i → toℕ i , toℕ-sound i\n ; from = λ { (_ , p) → fromℕ p }\n ; iso₁ = α\n ; iso₂ = λ { (i , p) → unapΣ (β i p , h1⇒prop ≤-level _ _) } }\n where\n α : ∀ {n} (i : Fin n) → fromℕ (toℕ-sound i) ≡ i\n α zero = refl\n α (suc i) = ap suc (α i)\n\n β : ∀ {n} (i : ℕ)(p : suc i ≤ n) → toℕ (fromℕ p) ≡ i\n β {0} _ ()\n β {suc n} 0 _ = refl\n β {suc n} (suc i) (s≤s p) = ap suc (β i p)\n\ntoℕ-inj : ∀ {n} → injective (toℕ {n = n})\ntoℕ-inj p = iso⇒inj toℕ-iso (unapΣ (p , h1⇒prop ≤-level _ _))\n\n#_ : ∀ {n} i {p : True (suc i ≤? n)} → Fin n\n#_ {n} i {p} = fromℕ (witness p)\n\ntranspose : ∀ {n} → Fin n → Fin n → Fin n → Fin n\ntranspose i j k with i ≟ k\n... | yes _ = j\n... | no _ with j ≟ k\n... | yes _ = i\n... | no _ = k\n\ntranspose-β₂ : ∀ {n}(i j : Fin n)\n → transpose i j j ≡ i\ntranspose-β₂ i j with i ≟ j\n... | yes p = sym p\n... | no u with j ≟ j\n... | yes p = refl\n... | no v = ⊥-elim (v refl)\n\nabstract\n transpose-invol : ∀ {n}(i j k : Fin n)\n → transpose i j (transpose i j k) ≡ k\n transpose-invol i j k with i ≟ k\n transpose-invol i j k | yes p with i ≟ j\n transpose-invol i j k | yes p | yes p' = sym p' · p\n transpose-invol i j k | yes p | no u with j ≟ j\n transpose-invol i j k | yes p | no u | yes p' = p\n transpose-invol i j k | yes p | no u | no v = ⊥-elim (v refl)\n transpose-invol i j k | no u with j ≟ k\n transpose-invol i j k | no u | yes p with i ≟ i\n transpose-invol i j k | no u | yes p | yes p' = p\n transpose-invol i j k | no u | yes p | no v = ⊥-elim (v refl)\n transpose-invol i j k | no u | no v with i ≟ k\n transpose-invol i j k | no u | no v | yes p = ⊥-elim (u p)\n transpose-invol i j k | no u | no v | no w with j ≟ k\n transpose-invol i j k | no u | no v | no w | yes p = ⊥-elim (v p)\n transpose-invol i j k | no u | no v | no w | no z = refl\n\ntranspose-iso : ∀ {n}(i j : Fin n) → Fin n ≅ Fin n\ntranspose-iso i j = record\n { to = transpose i j\n ; from = transpose i j\n ; iso₁ = transpose-invol i j\n ; iso₂ = transpose-invol i j }\n\nfin-remove₀-iso : ∀ {n} → (Fin (suc n) minus zero) ≅ Fin n\nfin-remove₀-iso = record\n { to = uncurry pred\n ; from = λ i → suc i , λ p → fin-disj _ (sym p)\n ; iso₁ = λ { (i , u) → unapΣ (pred-β _ u , h1⇒prop ¬-h1 _ _) }\n ; iso₂ = λ _ → refl }\n\nfin-remove-iso : ∀ {n}(i : Fin (suc n))\n → (Σ (Fin (suc n)) λ j → ¬ (j ≡ i))\n ≅ Fin n\nfin-remove-iso {n} i = begin\n (Σ (Fin (suc n)) λ j → ¬ (j ≡ i))\n ≅⟨ ( Σ-ap-iso (transpose-iso zero i) λ _\n → Π-ap-iso lem λ _ → refl≅ ) ⟩\n (Σ (Fin (suc n)) λ j → ¬ (j ≡ zero))\n ≅⟨ fin-remove₀-iso ⟩\n Fin n\n ∎\n where\n open ≅-Reasoning\n\n lem : ∀ {x} → (x ≡ i) ≅ (transpose zero i x ≡ zero)\n lem {x} = begin\n (x ≡ i)\n ≅⟨ iso≡ (transpose-iso zero i) ⟩\n ( transpose zero i x ≡ transpose zero i i )\n ≅⟨ trans≡-iso' (transpose-β₂ zero i) ⟩\n ( transpose zero i x ≡ zero )\n ∎ where open ≅-Reasoning\n\ntranspose-inj : ∀ {n m}(i j : Fin m)\n → (f : Fin n → Fin m)\n → injective f\n → injective (transpose i j ∘' f)\ntranspose-inj i j f inj = inj ∘' iso⇒inj (transpose-iso i j)\n\ntranspose-inj-iso' : ∀ {n} (i j : Fin n)\n → (Fin n ↣ Fin n)\n ≅ (Fin n ↣ Fin n)\ntranspose-inj-iso' {n} i j\n = Σ-ap-iso (Π-ap-iso refl≅ λ _ → tiso) λ f\n → mk-prop-iso (inj-level f (fin-set _))\n (inj-level _ (fin-set _))\n (transpose-inj i j f)\n (λ inj p → inj (ap (apply tiso) p))\n where\n tiso : Fin n ≅ Fin n\n tiso = transpose-iso i j\n\n\ntranspose-inj-iso : ∀ {n} (i j : Fin n)\n → (Fin n ↣ Fin n)\n ≅ (Fin n ↣ Fin n)\ntranspose-inj-iso {n} i j\n = Σ-ap-iso (Π-ap-iso tiso λ _ → refl≅) λ f\n → mk-prop-iso (inj-level f (fin-set _))\n (inj-level _ (fin-set _))\n (λ inj → iso⇒inj tiso ∘' inj)\n (λ inj p → iso⇒inj tiso (inj (\n ap f (_≅_.iso₁ tiso _)\n · p\n · sym (ap f (_≅_.iso₁ tiso _)))))\n where\n tiso : Fin n ≅ Fin n\n tiso = transpose-iso i j\n\ninj-nonsurj : ∀ {n i}{A : Set i}\n → (f : A → Fin (suc n))\n → injective f\n → {i : Fin (suc n)}\n → ((x : A) → ¬ (f x ≡ i))\n → A ↣ Fin n\ninj-nonsurj {n}{i}{A} f inj {z} u = g , g-inj\n where\n f' : A → Σ (Fin (suc n)) λ k → ¬ (k ≡ z)\n f' i = f i , u i\n\n inj' : injective f'\n inj' p = inj (ap proj₁ p)\n\n abstract\n φ : (Σ (Fin (suc n)) λ k → ¬ (k ≡ z)) ≅ Fin n\n φ = fin-remove-iso z\n\n g : A → Fin n\n g = apply φ ∘' f'\n\n g-inj : injective g\n g-inj p = inj' (iso⇒inj φ p)\n\npreimage : ∀ {i n}{A : Set i}\n → (f : Fin n → A)\n → (dec : (x y : A) → Dec (x ≡ y))\n → (x : A)\n → ( (Σ (Fin n) λ i → f i ≡ x)\n ⊎ ((i : Fin n) → ¬ (f i ≡ x)) )\npreimage {n = 0} f dec x = inj₂ (λ ())\npreimage {n = suc n} f dec x with dec (f zero) x\n... | yes p = inj₁ (zero , p)\n... | no u with preimage (λ i → f (suc i)) dec x\n... | inj₁ (i , p) = inj₁ (suc i , p)\n... | inj₂ v = inj₂ λ { zero → u ; (suc i) → v i }\n\nfin-inj-remove₀ : ∀ {n m}\n → (f : Fin (suc n) ↣ Fin (suc m))\n → (apply f zero ≡ zero)\n → Fin n ↣ Fin m\nfin-inj-remove₀ {n}{m} (f , inj) p = g , g-inj\n where\n nz : {i : Fin n} → ¬ (f (suc i) ≡ zero)\n nz q = fin-disj _ (inj (p · sym q))\n\n g : Fin n → Fin m\n g i = pred (f (suc i)) nz\n\n g-inj : injective g\n g-inj q = fin-suc-inj (inj (pred-inj nz nz q))\n\nfin-inj-remove : ∀ {n m}\n → (Fin (suc n) ↣ Fin (suc m))\n → (Fin n ↣ Fin m)\nfin-inj-remove {n}{m} (f , f-inj)\n = fin-inj-remove₀\n ( transpose zero (f zero) ∘' f\n , transpose-inj zero (f zero) f f-inj)\n ( transpose-β₂ zero (f zero))\n\nfin-inj-add : ∀ {n m}\n → (Fin n ↣ Fin m)\n → (Fin (suc n) ↣ Fin (suc m))\nfin-inj-add {n}{m} (f , f-inj) = g , g-inj\n where\n g : Fin (suc n) → Fin (suc m)\n g zero = zero\n g (suc i) = suc (f i)\n\n g-inj : injective g\n g-inj {zero} {zero} p = refl\n g-inj {zero} {suc x'} p = ⊥-elim (fin-disj _ p)\n g-inj {suc x} {zero} p = ⊥-elim (fin-disj _ (sym p))\n g-inj {suc x} {suc x'} p = ap suc (f-inj (fin-suc-inj p))\n\nfin-lt : ∀ {n m}(f : Fin n ↣ Fin m) → n ≤ m\nfin-lt {0} _ = z≤n\nfin-lt {suc n} {0} (f , _) with f zero\n... | ()\nfin-lt {suc n}{suc m} f = s≤s (fin-lt (fin-inj-remove f))\n\ninj⇒retr : ∀ {n}(f : Fin n → Fin n)\n → injective f\n → retraction f\ninj⇒retr {0} f inj ()\ninj⇒retr {suc n} f inj y with preimage f _≟_ y\n... | inj₁ t = t\n... | inj₂ u = ⊥-elim (suc≰ (fin-lt (inj-nonsurj f inj u)))\n\ninj⇒iso : ∀ {n}(f : Fin n → Fin n)\n → injective f\n → Fin n ≅ Fin n\ninj⇒iso f inj = inj+retr⇒iso f inj (inj⇒retr f inj)\n\nFin-inj : ∀ {n m} → Fin n ≅ Fin m → n ≡ m\nFin-inj {n}{m} isoF\n = antisym≤ (fin-lt (_ , iso⇒inj isoF))\n (fin-lt (_ , iso⇒inj (sym≅ isoF)))\n", "meta": {"hexsha": "7aac9d0022666348133defac6da54d47d77c4cf0", "size": 8428, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/sets/fin/properties.agda", "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 20, "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_issues_repo_path": "src/sets/fin/properties.agda", "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_forks_repo_path": "src/sets/fin/properties.agda", "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "avg_line_length": 29.676056338, "max_line_length": 67, "alphanum_fraction": 0.4876601804, "num_tokens": 3497, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744761936437, "lm_q2_score": 0.7549149813536518, "lm_q1q2_score": 0.6171992204509461}} {"text": "{-# OPTIONS --cubical --safe #-}\nmodule Cubical.HITs.AssocList.Properties where\n\nopen import Cubical.HITs.AssocList.Base as AL\nopen import Cubical.Foundations.Everything\nopen import Cubical.HITs.FiniteMultiset as FMS\nopen import Cubical.Data.Nat using (ℕ; zero; suc; _+_)\n\nprivate\n variable\n ℓ : Level\n A : Type₀\n\n\n\nmultiPer : (a b : A) (m n : ℕ) (xs : AssocList A)\n → ⟨ a , m ⟩∷ ⟨ b , n ⟩∷ xs ≡ ⟨ b , n ⟩∷ ⟨ a , m ⟩∷ xs\nmultiPer a b zero n xs = del a (⟨ b , n ⟩∷ xs) ∙ cong (λ ys → ⟨ b , n ⟩∷ ys) (sym (del a xs))\nmultiPer a b (suc m) zero xs = cong (λ ys → ⟨ a , suc m ⟩∷ ys) (del b xs) ∙ sym (del b (⟨ a , suc m ⟩∷ xs))\nmultiPer a b (suc m) (suc n) xs =\n\n ⟨ a , suc m ⟩∷ ⟨ b , suc n ⟩∷ xs ≡⟨ sym (agg a 1 m (⟨ b , suc n ⟩∷ xs)) ⟩\n ⟨ a , 1 ⟩∷ ⟨ a , m ⟩∷ ⟨ b , suc n ⟩∷ xs ≡⟨ cong (λ ys → ⟨ a , 1 ⟩∷ ys) (multiPer a b m (suc n) xs) ⟩\n ⟨ a , 1 ⟩∷ ⟨ b , suc n ⟩∷ ⟨ a , m ⟩∷ xs ≡⟨ cong (λ ys → ⟨ a , 1 ⟩∷ ys) (sym (agg b 1 n (⟨ a , m ⟩∷ xs))) ⟩\n ⟨ a , 1 ⟩∷ ⟨ b , 1 ⟩∷ ⟨ b , n ⟩∷ ⟨ a , m ⟩∷ xs ≡⟨ per a b (⟨ b , n ⟩∷ ⟨ a , m ⟩∷ xs) ⟩\n ⟨ b , 1 ⟩∷ ⟨ a , 1 ⟩∷ ⟨ b , n ⟩∷ ⟨ a , m ⟩∷ xs ≡⟨ cong (λ ys → ⟨ b , 1 ⟩∷ ⟨ a , 1 ⟩∷ ys) (multiPer b a n m xs) ⟩\n ⟨ b , 1 ⟩∷ ⟨ a , 1 ⟩∷ ⟨ a , m ⟩∷ ⟨ b , n ⟩∷ xs ≡⟨ cong (λ ys → ⟨ b , 1 ⟩∷ ys) (agg a 1 m (⟨ b , n ⟩∷ xs)) ⟩\n ⟨ b , 1 ⟩∷ ⟨ a , suc m ⟩∷ ⟨ b , n ⟩∷ xs ≡⟨ cong (λ ys → ⟨ b , 1 ⟩∷ ys) (multiPer a b (suc m) n xs) ⟩\n ⟨ b , 1 ⟩∷ ⟨ b , n ⟩∷ ⟨ a , suc m ⟩∷ xs ≡⟨ agg b 1 n (⟨ a , suc m ⟩∷ xs) ⟩\n ⟨ b , suc n ⟩∷ ⟨ a , suc m ⟩∷ xs ∎\n\n\n\n\n\n-- Show that association lists and finite multisets are equivalent\nmulti-∷ : A → ℕ → FMSet A → FMSet A\nmulti-∷ x zero xs = xs\nmulti-∷ x (suc n) xs = x ∷ multi-∷ x n xs\n\nmulti-∷-agg : (x : A) (m n : ℕ) (b : FMSet A) → multi-∷ x m (multi-∷ x n b) ≡ multi-∷ x (m + n) b\nmulti-∷-agg x zero n b = refl\nmulti-∷-agg x (suc m) n b i = x ∷ (multi-∷-agg x m n b i)\n\nAL→FMS : AssocList A → FMSet A\nAL→FMS = AL.Rec.f FMS.trunc [] multi-∷ comm multi-∷-agg λ _ _ → refl\n\n\nFMS→AL : FMSet A → AssocList A\nFMS→AL = FMS.Rec.f AL.trunc ⟨⟩ (λ x xs → ⟨ x , 1 ⟩∷ xs) per\n\n\n\nAL→FMS∘FMS→AL≡id : section {A = AssocList A} AL→FMS FMS→AL\nAL→FMS∘FMS→AL≡id = FMS.ElimProp.f (FMS.trunc _ _) refl (λ x p → cong (λ ys → x ∷ ys) p)\n\n\n-- need a little lemma for other direction\nmulti-∷-id : (x : A) (n : ℕ) (u : FMSet A)\n → FMS→AL (multi-∷ x n u) ≡ ⟨ x , n ⟩∷ FMS→AL u\nmulti-∷-id x zero u = sym (del x (FMS→AL u))\nmulti-∷-id x (suc n) u = FMS→AL (multi-∷ x (suc n) u) ≡⟨ cong (λ ys → ⟨ x , 1 ⟩∷ ys) (multi-∷-id x n u) ⟩\n ⟨ x , 1 ⟩∷ ⟨ x , n ⟩∷ (FMS→AL u) ≡⟨ agg x 1 n (FMS→AL u) ⟩\n ⟨ x , (suc n) ⟩∷ (FMS→AL u) ∎\n\nFMS→AL∘AL→FMS≡id : retract {A = AssocList A} AL→FMS FMS→AL\nFMS→AL∘AL→FMS≡id = AL.ElimProp.f (AL.trunc _ _) refl (λ x n {xs} p → (multi-∷-id x n (AL→FMS xs)) ∙ cong (λ ys → ⟨ x , n ⟩∷ ys) p)\n\n\n\n\nAssocList≃FMSet : AssocList A ≃ FMSet A\nAssocList≃FMSet = isoToEquiv (iso AL→FMS FMS→AL AL→FMS∘FMS→AL≡id FMS→AL∘AL→FMS≡id)\n\n\nAssocList≡FMSet : AssocList A ≡ FMSet A\nAssocList≡FMSet = ua AssocList≃FMSet\n", "meta": {"hexsha": "e0f5bec1dee9bcf35beaa94cbea39571b7af64bd", "size": 3089, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/AssocList/Properties.agda", "max_stars_repo_name": "borsiemir/cubical", "max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/HITs/AssocList/Properties.agda", "max_issues_repo_name": "borsiemir/cubical", "max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/HITs/AssocList/Properties.agda", "max_forks_repo_name": "borsiemir/cubical", "max_forks_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.6025641026, "max_line_length": 130, "alphanum_fraction": 0.4907737132, "num_tokens": 1553, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672135527632, "lm_q2_score": 0.7634837689358857, "lm_q1q2_score": 0.6169462017567828}} {"text": "module Lectures.Four where\n\nopen import Lectures.One public\nopen import Lectures.Two public\nopen import Lectures.Three public\n\n_∘_ : {A B C : Set} → (B → C) → (A → B) → (A → C)\n(f ∘ g) x = f (g x)\n\nrecord _↔_ (A B : Set) : Set where\n constructor Isomorphism\n field\n to : A → B\n from : B → A\n from∘to : ∀ x → (from ∘ to) x ≡ x\n to∘from : ∀ y → (to ∘ from) y ≡ y\n\nopen List\n\nfoldr-List : {A B : Set} → (A → B → B) → B → List A → B\nfoldr-List f z [] = z\nfoldr-List f z (x ∷ xs) = f x (foldr-List f z xs)\n\nfoldr-ℕ : {A : Set} → (A → A) → A → ℕ → A\nfoldr-ℕ f z zero = z\nfoldr-ℕ f z (suc n) = f (foldr-ℕ f z n)\n\nℕ↔List⊤ : ℕ ↔ List ⊤\nℕ↔List⊤ = Isomorphism to from from∘to to∘from\n where\n\n to : ℕ → List ⊤\n to = foldr-ℕ (tt ∷_) []\n\n from : List ⊤ → ℕ\n from = foldr-List (λ _ → suc) 0\n\n from∘to : ∀ x → (from ∘ to) x ≡ x\n from∘to zero = refl\n from∘to (suc x) = cong suc (from∘to x)\n\n to∘from : ∀ x → (to ∘ from) x ≡ x\n to∘from [] = refl\n to∘from (tt ∷ xs) = cong (tt ∷_) (to∘from xs)\n\nℕ↔Even : ℕ ↔ Σ ℕ _isEven\nℕ↔Even = Isomorphism to from from∘to to∘from\n where\n\n to : ℕ → Σ ℕ _isEven\n to zero = zero , tt\n to (suc n) with to n\n to (suc n) | (2n , 2nEven) = (suc (suc 2n) , 2nEven)\n\n from : (Σ ℕ _isEven) → ℕ\n from (n , nEven) = half n nEven\n\n from∘to : ∀ x → (from ∘ to) x ≡ x\n from∘to zero = refl\n from∘to (suc n) with to n | from∘to n\n from∘to (suc .(half (proj₁ q) (proj₂ q))) | q | refl = refl\n\n to∘from : ∀ x → (to ∘ from) x ≡ x\n to∘from (zero , tt) = refl\n to∘from (suc (suc n) , nEven) rewrite to∘from (n , nEven) = refl\n\ndata Fin : ℕ → Set where\n zero : ∀ {n} → Fin (suc n)\n suc : ∀ {n} → Fin n → Fin (suc n)\n\nnoFin0 : Fin 0 → ⊥\nnoFin0 ()\n\nopen Vec\nlookup : ∀ {n} {A : Set} → Vec A n → Fin n → A\nlookup (x ∷ xs) zero = x\nlookup (x ∷ xs) (suc i) = lookup xs i\n\n-- For next time:\n-- Fin\n-- Constructive leq\n", "meta": {"hexsha": "687fe23c64f77281b72cb710ac0cc2e4fdbac9f1", "size": 1846, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Lectures/Four.agda", "max_stars_repo_name": "UoG-Agda/Agda101", "max_stars_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Lectures/Four.agda", "max_issues_repo_name": "UoG-Agda/Agda101", "max_issues_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lectures/Four.agda", "max_forks_repo_name": "UoG-Agda/Agda101", "max_forks_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.512195122, "max_line_length": 66, "alphanum_fraction": 0.5411700975, "num_tokens": 857, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.808067204308405, "lm_q2_score": 0.7634837635542924, "lm_q1q2_score": 0.6169461903501763}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Cubical.Data.Strict2Group.Explicit.Notation where\n\nopen import Cubical.Foundations.Prelude hiding (comp)\nopen import Cubical.Data.Group.Base\n\nmodule S2GBaseNotation {ℓ : Level} (C₀ C₁ : Group ℓ) (s t : morph C₁ C₀) (i : morph C₀ C₁) (∘ : (g f : Group.type C₁) → (s .fst) g ≡ (t .fst f) → Group.type C₁) where\n\n -- group operations of the object group\n TC₀ = Group.type C₀\n 1₀ = isGroup.id (Group.groupStruc C₀)\n _∙₀_ = isGroup.comp (Group.groupStruc C₀)\n C₀⁻¹ = isGroup.inv (Group.groupStruc C₀)\n rUnit₀ = isGroup.rUnit (Group.groupStruc C₀)\n lUnit₀ = isGroup.lUnit (Group.groupStruc C₀)\n assoc₀ = isGroup.assoc (Group.groupStruc C₀)\n lCancel₀ = isGroup.lCancel (Group.groupStruc C₀)\n rCancel₀ = isGroup.lCancel (Group.groupStruc C₀)\n\n -- group operation of the morphism group\n TC₁ = Group.type C₁\n 1₁ = isGroup.id (Group.groupStruc C₁)\n C₁⁻¹ = isGroup.inv (Group.groupStruc C₁)\n _∙₁_ = isGroup.comp (Group.groupStruc C₁)\n rUnit₁ = isGroup.rUnit (Group.groupStruc C₁)\n lUnit₁ = isGroup.lUnit (Group.groupStruc C₁)\n assoc₁ = isGroup.assoc (Group.groupStruc C₁)\n lCancel₁ = isGroup.lCancel (Group.groupStruc C₁)\n rCancel₁ = isGroup.lCancel (Group.groupStruc C₁)\n\n -- interface for source, target and identity map\n src = fst s\n src∙₁ = snd s\n tar = fst t\n tar∙₁ = snd t\n id = fst i\n id∙₀ = snd i\n\n ∙c : {g f g' f' : Group.type C₁} → (coh1 : s .fst g ≡ t .fst f) → (coh2 : s .fst g' ≡ t .fst f') → s .fst (g ∙₁ g') ≡ t .fst (f ∙₁ f')\n ∙c {g} {f} {g'} {f'} coh1 coh2 = (s .snd g g') ∙ ((cong (_∙₀ (s .fst g')) coh1) ∙ (cong ((t .fst f) ∙₀_) coh2) ∙ (sym (t .snd f f')))\n\n -- for two morphisms the condition for them to be composable\n CohCond : (g f : TC₁) → Type ℓ\n CohCond g f = src g ≡ tar f\n", "meta": {"hexsha": "a0e026bb9c1aa1872d184687aa1606ea78dafe39", "size": 1762, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/Strict2Group/Explicit/Notation.agda", "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/Strict2Group/Explicit/Notation.agda", "max_issues_repo_name": "Schippmunk/cubical", "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Data/Strict2Group/Explicit/Notation.agda", "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.3043478261, "max_line_length": 166, "alphanum_fraction": 0.6549375709, "num_tokens": 680, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950907764118, "lm_q2_score": 0.7310585903489891, "lm_q1q2_score": 0.6169367554654358}} {"text": "\nmodule Basic.Axiomatic.TotalImpliesPartial where\n\nopen import Basic.AST\nopen import Basic.BigStep\nopen import Basic.Axiomatic.Total as T\n renaming (〈_〉_〈_〉 to total〈_〉_〈_〉) \nopen import Basic.Axiomatic.Partial as P\n renaming (〈_〉_〈_〉 to partial〈_〉_〈_〉) hiding (_==>_; _∧_)\n\nopen import Function\nopen import Data.Product\n\n{-\nThe proof that total correctness implies partial correctness (exercise 6.33)\nis fortunately really simple.\n\nWe already proved soundness and completeness for both systems, so instead of\ntrying to construct the partial proof directly from the total proof, we can\njust take a detour and prove the analoguous implication about the *validity*\nof triples.\n-}\n\n{-\nThe total validity of Hoare triples implies partial validity, if the language semantics is\ndeterministic. \n-}\nP==>wp→P==>wlp : ∀{n S}{P Q : State n → Set} → (P ==> wp S Q) → (P ==> wlp S Q)\nP==>wp→P==>wlp pwp ps runS with pwp ps\n... | _ , runS' , qs' rewrite deterministic runS runS' = qs'\n\n{- And now we just do an excursion to semantics-land and then back -}\ntotal→partial : ∀ {n S}{P Q : State n → Set} → total〈 P 〉 S 〈 Q 〉 → partial〈 P 〉 S 〈 Q 〉\ntotal→partial = P.complete _ ∘ P==>wp→P==>wlp ∘ T.sound\n", "meta": {"hexsha": "3001b51e6643bad7ff71d0c9a4c0b8e749fa4cc5", "size": 1190, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Basic/Axiomatic/TotalImpliesPartial.agda", "max_stars_repo_name": "AndrasKovacs/SemanticsWithApplications", "max_stars_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2016-09-12T04:25:39.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-02T10:01:52.000Z", "max_issues_repo_path": "Basic/Axiomatic/TotalImpliesPartial.agda", "max_issues_repo_name": "AndrasKovacs/SemanticsWithApplications", "max_issues_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Basic/Axiomatic/TotalImpliesPartial.agda", "max_forks_repo_name": "AndrasKovacs/SemanticsWithApplications", "max_forks_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.0, "max_line_length": 90, "alphanum_fraction": 0.7067226891, "num_tokens": 404, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8438950947024555, "lm_q2_score": 0.7310585844894971, "lm_q1q2_score": 0.6169367533908072}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Math.NumberTheory.Summation.Nat.Properties where\n\n-- agda-stdlib\nopen import Algebra\nimport Algebra.Operations.CommutativeMonoid as CommutativeMonoidOperations\nopen import Data.Nat\nopen import Data.Nat.Properties\nopen import Data.Nat.Solver\nopen import Relation.Binary.PropositionalEquality\nopen import Function.Base\n\n-- agda-misc\nopen import Math.NumberTheory.Summation.Generic\nopen import Math.NumberTheory.Summation.Generic.Properties\nimport Math.NumberTheory.Summation.Nat.Properties.Lemma as Lemma\n\n-- DO NOT change this line\nopen MonoidSummation (Semiring.+-monoid *-+-semiring)\nopen CommutativeMonoidOperations (Semiring.+-commutativeMonoid *-+-semiring)\n\n-- TODO? rename _≈_ to _≡_ this is tedious\nopen SemiringSummationProperties *-+-semiring public\n renaming\n ( Σ<-const to Σ<-const-×\n ; Σ≤-const to Σ≤-const-×\n ; Σ u = unit\n-}\n\nmodule Unit.Equality where\n\nopen import SOAS.Common\nopen import SOAS.Context\nopen import SOAS.Variable\nopen import SOAS.Families.Core\nopen import SOAS.Families.Build\nopen import SOAS.ContextMaps.Inductive\n\nopen import Unit.Signature\nopen import Unit.Syntax\n\nopen import SOAS.Metatheory.SecondOrder.Metasubstitution U:Syn\nopen import SOAS.Metatheory.SecondOrder.Equality U:Syn\n\nprivate\n variable\n α β γ τ : UT\n Γ Δ Π : Ctx\n\ninfix 1 _▹_⊢_≋ₐ_\n\n-- Axioms of equality\ndata _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ U) α Γ → (𝔐 ▷ U) α Γ → Set where\n 𝟙η : ⁅ 𝟙 ⁆̣ ▹ ∅ ⊢ 𝔞 ≋ₐ unit\n\nopen EqLogic _▹_⊢_≋ₐ_\nopen ≋-Reasoning\n", "meta": {"hexsha": "71c0b94c154a1ac3e17689db096bef9b1534d96a", "size": 798, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "out/Unit/Equality.agda", "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_issues_repo_path": "out/Unit/Equality.agda", "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_forks_repo_path": "out/Unit/Equality.agda", "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "avg_line_length": 18.1363636364, "max_line_length": 99, "alphanum_fraction": 0.7105263158, "num_tokens": 313, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8947894717137996, "lm_q2_score": 0.6893056040203135, "lm_q1q2_score": 0.6167833972706979}} {"text": "{-# OPTIONS --warning=error --safe --without-K #-}\n\nopen import LogicalFormulae\nopen import Orders.WellFounded.Definition\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import Semirings.Definition\n\nmodule Numbers.Naturals.Order.WellFounded where\nopen Semiring ℕSemiring\n\n Nat\n\npostulate IsEven : Nat -> Prop\n\ndata Even : Set where\n even : (n : Nat) -> IsEven n -> Even\n\n", "meta": {"hexsha": "cb192eab5daae544a3fcbd5ab29bbc048cf81a94", "size": 187, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/Introduction/Universes.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/Introduction/Universes.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/Introduction/Universes.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 14.3846153846, "max_line_length": 38, "alphanum_fraction": 0.6417112299, "num_tokens": 57, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9219218370002789, "lm_q2_score": 0.668880247169804, "lm_q1q2_score": 0.6166553062039862}} {"text": "module Cxt (K : Set) where\n\nopen import Basics\nopen import Pr\nopen import Nom\n\nmutual\n data Cxt : Set where\n EC : Cxt\n _[_-_] : (G : Cxt)(x : Nom) -> K -> {p : [| G Hasn't x |]} -> Cxt\n\n HAS : Cxt -> Nom -> Bool\n HAS EC x = false\n HAS (G [ y - S ]) x with nomEq y x\n HAS (G [ y - S ]) .y | yes refl = true\n ... | no n = HAS G x\n\n _Has_ : Cxt -> Nom -> Pr\n G Has x = So (HAS G x)\n\n _Hasn't_ : Cxt -> Nom -> Pr\n G Hasn't x = So (not (HAS G x))\n\nGooN : (G : Cxt)(T : K) -> Nom -> Pr\nGooN EC T y = ff\nGooN (G [ x - S ]) T y with nomEq x y\nGooN (G [ x - S ]) T .x | yes refl = S eq T\nGooN (G [ x - S ]) T y | no n = GooN G T y\n\n_?-_ : (G : Cxt)(x : Nom){p : [| G Has x |]} -> K :- \\ T -> GooN G T x\n(EC ?- y) {}\n((G [ x - S ]) ?- y) {_} with nomEq x y\n((G [ x - S ]) ?- .x) {_} | yes refl = [ S / refl ]\n((G [ x - S ]) ?- y) {p} | no n = (G ?- y) {p}\n\ntopGooN : (G : Cxt)(x : Nom){p : [| G Hasn't x |]}(S : K) ->\n [| GooN ((G [ x - S ]) {p}) S x |]\ntopGooN G x S with nomEq x x \ntopGooN G x S | yes refl = refl\ntopGooN G x S | no n = magic (n refl)\n\n", "meta": {"hexsha": "5b495bb9e80bf057fea05226778b834b6ba1b25f", "size": 1121, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "benchmark/Syntacticosmos/Cxt.agda", "max_stars_repo_name": "masondesu/agda", "max_stars_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_issues_repo_path": "benchmark/Syntacticosmos/Cxt.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "benchmark/Syntacticosmos/Cxt.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.6904761905, "max_line_length": 70, "alphanum_fraction": 0.4362176628, "num_tokens": 489, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8902942319436395, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.6166551623868592}} {"text": "module tests.Mutual where\n\nopen import Prelude.IO\nopen import Prelude.String\nopen import Prelude.Unit\n\nmutual\n data G : Set where\n GA : {g : G}(f : F g) -> G\n GB : G\n\n data F : G -> Set where\n FA : (g : G) -> F g\n FB : F GB\n\nmutual\n incG : G -> G\n incG GB = GA FB\n incG (GA f) = GA (incF f)\n\n incF : {g : G} -> F g -> F (incG g)\n incF FB = FA (GA FB)\n incF (FA g) = FA (incG g)\n\n\n\n\nmutual\n PrintF : {g : G} -> F g -> String\n PrintF FB = \"FB\"\n PrintF (FA g) = \"(FA \" +S+ PrintG g +S+ \")\"\n\n PrintG : G -> String\n PrintG GB = \"GB\"\n PrintG (GA f) = \"(GA \" +S+ PrintF f +S+ \")\"\n\nmain : IO Unit\nmain =\n putStrLn (PrintF (FA (GA (FA GB)))) ,,\n putStrLn (PrintG (incG (GA (incF FB)))) ,, --\n return unit\n", "meta": {"hexsha": "9f6cdb8e1c525ee2c0c776171f87c718aa2faff0", "size": 743, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/epic/tests/Mutual.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/epic/tests/Mutual.agda", "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/epic/tests/Mutual.agda", "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 17.6904761905, "max_line_length": 49, "alphanum_fraction": 0.5154777927, "num_tokens": 288, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8902942203004185, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.616655148673725}} {"text": "{-# OPTIONS --cubical-compatible --universe-polymorphism #-}\n\nmodule WithoutK where\n\nopen import Common.Level\n\n-- Propositional equality.\n\ndata _≡_ {A : Set} : A → A → Set where\n refl : ∀ x → x ≡ x\n\n-- The J rule.\n\nJ : {A : Set} (P : {x y : A} → x ≡ y → Set) →\n (∀ x → P (refl x)) →\n ∀ {x y} (x≡y : x ≡ y) → P x≡y\nJ P p (refl x) = p x\n\n-- Christine Paulin-Mohring's version of the J rule.\n\nJ′ : {A : Set} {x : A} (P : {y : A} → x ≡ y → Set) →\n P (refl x) →\n ∀ {y} (x≡y : x ≡ y) → P x≡y\nJ′ P p (refl x) = p\n\n-- A variant of _≡_.\n\ndata _≡′_ {A : Set} (x : A) : A → Set where\n refl : x ≡′ x\n\n-- We normalise before checking index well-formedness.\n\nconst : ∀ {a b} {A : Set a} {B : Set b} → A → B → A\nconst x _ = x\n\nid : {A : Set} {x y : A} → const x y ≡′ const y x → x ≡′ y\nid refl = refl\n\n-- We can handle more complicated indices as well.\n\ndata ⊥ : Set where\n\ndata Bool : Set where\n true false : Bool\n\ntrue≢false : true ≡ false → ⊥\ntrue≢false ()\n\ndata D : Set where\n c₀ : D\n c₂ : (i₁ i₂ : D) → D\n\nf : ∀ {x y z} → x ≡ y → c₂ y c₀ ≡ c₂ c₀ z → x ≡ z\nf x≡y (refl .(c₂ c₀ c₀)) = x≡y\n\n-- The indices can contain literals.\n\ndata ℕ : Set where\n zero : ℕ\n suc : (n : ℕ) → ℕ\n\n{-# BUILTIN NATURAL ℕ #-}\n\ng : 2 ≡ 3 → 3 ≡ 5\ng ()\n\nh : ∀ {n} → 2 ≡ suc n → n ≡ 1\nh (refl .2) = refl _\n", "meta": {"hexsha": "c2e66af9ce56f66f2052f7037266fa866a5f3b6d", "size": 1292, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/WithoutK.agda", "max_stars_repo_name": "KDr2/agda", "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/Succeed/WithoutK.agda", "max_issues_repo_name": "KDr2/agda", "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_forks_repo_path": "test/Succeed/WithoutK.agda", "max_forks_repo_name": "KDr2/agda", "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.7246376812, "max_line_length": 60, "alphanum_fraction": 0.5116099071, "num_tokens": 560, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.819893340314393, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.616570101058344}} {"text": "module Function.Equals where\n\nimport Lvl\nopen import Functional\nimport Function.Names as Names\nopen import Logic\nopen import Logic.Propositional\nopen import Structure.Setoid\nopen import Structure.Relator.Equivalence\nopen import Structure.Relator.Properties\nopen import Type\n\nmodule Dependent {ℓ₁ ℓ₂ ℓₑ₂} {A : Type{ℓ₁}} {B : A → Type{ℓ₂}} ⦃ equiv-B : ∀{a} → Equiv{ℓₑ₂}(B(a)) ⦄ where\n infixl 15 _⊜_\n\n -- Function equivalence. When the types and all their values are shared/equivalent.\n record _⊜_ (f : (a : A) → B(a)) (g : (a : A) → B(a)) : Stmt{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓₑ₂} where\n constructor intro\n field\n proof : (f Names.⊜ g)\n\n instance\n [⊜]-reflexivity : Reflexivity(_⊜_)\n Reflexivity.proof([⊜]-reflexivity) = intro(reflexivity(_≡_) ⦃ Equiv.reflexivity(equiv-B) ⦄)\n\n instance\n [⊜]-symmetry : Symmetry(_⊜_)\n Symmetry.proof([⊜]-symmetry) (intro fg) = intro(symmetry(_≡_) ⦃ Equiv.symmetry(equiv-B) ⦄ fg)\n\n instance\n [⊜]-transitivity : Transitivity(_⊜_)\n Transitivity.proof([⊜]-transitivity) (intro fg) (intro gh) = intro(transitivity(_≡_) ⦃ Equiv.transitivity(equiv-B) ⦄ fg gh)\n\n instance\n [⊜]-equivalence : Equivalence(_⊜_)\n [⊜]-equivalence = record{}\n\n instance\n [⊜]-equiv : Equiv((a : A) → B(a))\n [⊜]-equiv = intro(_⊜_) ⦃ [⊜]-equivalence ⦄\n\n instance\n [⊜]-sub : (_≡_) ⊆₂ (_⊜_)\n _⊆₂_.proof [⊜]-sub (intro proof) = intro proof\n\nmodule _ {ℓ₁ ℓ₂ ℓₑ₂} {A : Type{ℓ₁}} {B : Type{ℓ₂}} ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ where\n private module D = Dependent {A = A} {B = const B} ⦃ equiv-B ⦄\n open D using (module _⊜_ ; intro) public\n _⊜_ = D._⊜_\n [⊜]-reflexivity = D.[⊜]-reflexivity\n [⊜]-symmetry = D.[⊜]-symmetry\n [⊜]-transitivity = D.[⊜]-transitivity\n [⊜]-equivalence = D.[⊜]-equivalence\n [⊜]-equiv = D.[⊜]-equiv\n [⊜]-sub = D.[⊜]-sub\n", "meta": {"hexsha": "c83a8952163633a19bb5d3028b827c80ee6e137a", "size": 1827, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Function/Equals.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Function/Equals.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Function/Equals.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.625, "max_line_length": 127, "alphanum_fraction": 0.614668856, "num_tokens": 761, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933447152497, "lm_q2_score": 0.7520125682019722, "lm_q1q2_score": 0.6165700998110197}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\nopen import homotopy.Bouquet\nopen import homotopy.SphereEndomorphism\nopen import groups.SphereEndomorphism\nopen import groups.CoefficientExtensionality\nopen import cw.CW\nopen import cw.FinCW\nopen import cw.WedgeOfCells\nopen import cw.DegreeByProjection {lzero}\n\nmodule cw.FinBoundary where\n\n fdegree-last : ∀ {n} (fin-skel : FinSkeleton (S n))\n → cells-last (FinSkeleton-realize fin-skel)\n → cells-last (cw-init (FinSkeleton-realize fin-skel)) → ℤ\n fdegree-last fin-skel = degree-last (FinSkeleton-realize fin-skel) (FinSkeleton-has-cells-with-dec-eq fin-skel)\n\n fdegree-nth : ∀ {m n} (Sm≤n : S m ≤ n) (fin-skel : FinSkeleton n)\n → cells-nth Sm≤n (FinSkeleton-realize fin-skel)\n → cells-last (cw-init (cw-take Sm≤n (FinSkeleton-realize fin-skel))) → ℤ\n fdegree-nth Sm≤n fin-skel = degree-nth Sm≤n (FinSkeleton-realize fin-skel) (FinSkeleton-has-cells-with-dec-eq fin-skel)\n\n FinSkeleton-has-degrees-with-finite-support : ∀ {n} (fin-skel : FinSkeleton n)\n → has-degrees-with-finite-support\n (FinSkeleton-realize fin-skel)\n (FinSkeleton-has-cells-with-dec-eq fin-skel)\n FinSkeleton-has-degrees-with-finite-support {n = O} _ = _\n FinSkeleton-has-degrees-with-finite-support {n = S O} _ = _ , (λ _ → Fin→-has-finite-support _)\n FinSkeleton-has-degrees-with-finite-support {n = S (S n)} (attached-fin-skeleton skel _ _) =\n FinSkeleton-has-degrees-with-finite-support {n = S n} skel , (λ _ → Fin→-has-finite-support _)\n\n fboundary'-last : ∀ {n} (fin-skel : FinSkeleton (S n))\n → cells-last (FinSkeleton-realize fin-skel)\n → FreeAbGroup.El (cells-last (cw-init (FinSkeleton-realize fin-skel)))\n fboundary'-last fin-skel upper = boundary'-last\n (FinSkeleton-realize fin-skel)\n (FinSkeleton-has-cells-with-dec-eq fin-skel)\n (FinSkeleton-has-degrees-with-finite-support fin-skel)\n upper\n\n fboundary-last : ∀ {n} (fin-skel : FinSkeleton (S n))\n → FreeAbGroup.grp (cells-last (FinSkeleton-realize fin-skel))\n →ᴳ FreeAbGroup.grp (cells-last (cw-init (FinSkeleton-realize fin-skel)))\n fboundary-last fin-skel = FreeAbGroup-extend\n (FreeAbGroup (cells-last (cw-init (FinSkeleton-realize fin-skel))))\n (fboundary'-last fin-skel)\n", "meta": {"hexsha": "db142b2848fef7863fd185be282eb9239c1b0364", "size": 2246, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/cw/FinBoundary.agda", "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "theorems/cw/FinBoundary.agda", "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "theorems/cw/FinBoundary.agda", "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.8367346939, "max_line_length": 121, "alphanum_fraction": 0.7110418522, "num_tokens": 697, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.819893335913536, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.6165700977488442}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Some properties about subsets\n------------------------------------------------------------------------\n\nmodule Data.Fin.Subset.Properties where\n\nopen import Algebra\nimport Algebra.Properties.BooleanAlgebra as BoolProp\nopen import Data.Empty using (⊥-elim)\nopen import Data.Fin using (Fin); open Data.Fin.Fin\nopen import Data.Fin.Subset\nopen import Data.Nat using (ℕ)\nopen import Data.Product\nopen import Data.Sum as Sum\nopen import Data.Vec hiding (_∈_)\nopen import Function\nopen import Function.Equality using (_⟨$⟩_)\nopen import Function.Equivalence\n using (_⇔_; equivalence; module Equivalence)\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as P using (_≡_)\n\n------------------------------------------------------------------------\n-- Constructor mangling\n\ndrop-there : ∀ {s n x} {p : Subset n} → suc x ∈ s ∷ p → x ∈ p\ndrop-there (there x∈p) = x∈p\n\ndrop-∷-⊆ : ∀ {n s₁ s₂} {p₁ p₂ : Subset n} → s₁ ∷ p₁ ⊆ s₂ ∷ p₂ → p₁ ⊆ p₂\ndrop-∷-⊆ p₁s₁⊆p₂s₂ x∈p₁ = drop-there $ p₁s₁⊆p₂s₂ (there x∈p₁)\n\ndrop-∷-Empty : ∀ {n s} {p : Subset n} → Empty (s ∷ p) → Empty p\ndrop-∷-Empty ¬∃∈ (x , x∈p) = ¬∃∈ (suc x , there x∈p)\n\n------------------------------------------------------------------------\n-- Properties involving ⊥\n\n∉⊥ : ∀ {n} {x : Fin n} → x ∉ ⊥\n∉⊥ (there p) = ∉⊥ p\n\n⊥⊆ : ∀ {n} {p : Subset n} → ⊥ ⊆ p\n⊥⊆ x∈⊥ with ∉⊥ x∈⊥\n... | ()\n\nEmpty-unique : ∀ {n} {p : Subset n} →\n Empty p → p ≡ ⊥\nEmpty-unique {p = []} ¬∃∈ = P.refl\nEmpty-unique {p = s ∷ p} ¬∃∈ with Empty-unique (drop-∷-Empty ¬∃∈)\nEmpty-unique {p = outside ∷ .⊥} ¬∃∈ | P.refl = P.refl\nEmpty-unique {p = inside ∷ .⊥} ¬∃∈ | P.refl =\n ⊥-elim (¬∃∈ (zero , here))\n\n------------------------------------------------------------------------\n-- Properties involving ⊤\n\n∈⊤ : ∀ {n} {x : Fin n} → x ∈ ⊤\n∈⊤ {x = zero} = here\n∈⊤ {x = suc x} = there ∈⊤\n\n⊆⊤ : ∀ {n} {p : Subset n} → p ⊆ ⊤\n⊆⊤ = const ∈⊤\n\n------------------------------------------------------------------------\n-- A property involving ⁅_⁆\n\nx∈⁅y⁆⇔x≡y : ∀ {n} {x y : Fin n} → x ∈ ⁅ y ⁆ ⇔ x ≡ y\nx∈⁅y⁆⇔x≡y {x = x} {y} =\n equivalence (to y) (λ x≡y → P.subst (λ y → x ∈ ⁅ y ⁆) x≡y (x∈⁅x⁆ x))\n where\n\n to : ∀ {n x} (y : Fin n) → x ∈ ⁅ y ⁆ → x ≡ y\n to (suc y) (there p) = P.cong suc (to y p)\n to zero here = P.refl\n to zero (there p) with ∉⊥ p\n ... | ()\n\n x∈⁅x⁆ : ∀ {n} (x : Fin n) → x ∈ ⁅ x ⁆\n x∈⁅x⁆ zero = here\n x∈⁅x⁆ (suc x) = there (x∈⁅x⁆ x)\n\n------------------------------------------------------------------------\n-- A property involving _∪_\n\n∪⇔⊎ : ∀ {n} {p₁ p₂ : Subset n} {x} → x ∈ p₁ ∪ p₂ ⇔ (x ∈ p₁ ⊎ x ∈ p₂)\n∪⇔⊎ = equivalence (to _ _) from\n where\n to : ∀ {n} (p₁ p₂ : Subset n) {x} → x ∈ p₁ ∪ p₂ → x ∈ p₁ ⊎ x ∈ p₂\n to [] [] ()\n to (inside ∷ p₁) (s₂ ∷ p₂) here = inj₁ here\n to (outside ∷ p₁) (inside ∷ p₂) here = inj₂ here\n to (s₁ ∷ p₁) (s₂ ∷ p₂) (there x∈p₁∪p₂) =\n Sum.map there there (to p₁ p₂ x∈p₁∪p₂)\n\n ⊆∪ˡ : ∀ {n p₁} (p₂ : Subset n) → p₁ ⊆ p₁ ∪ p₂\n ⊆∪ˡ [] ()\n ⊆∪ˡ (s ∷ p₂) here = here\n ⊆∪ˡ (s ∷ p₂) (there x∈p₁) = there (⊆∪ˡ p₂ x∈p₁)\n\n ⊆∪ʳ : ∀ {n} (p₁ p₂ : Subset n) → p₂ ⊆ p₁ ∪ p₂\n ⊆∪ʳ p₁ p₂ rewrite BooleanAlgebra.∨-comm (booleanAlgebra _) p₁ p₂\n = ⊆∪ˡ p₁\n\n from : ∀ {n} {p₁ p₂ : Subset n} {x} → x ∈ p₁ ⊎ x ∈ p₂ → x ∈ p₁ ∪ p₂\n from (inj₁ x∈p₁) = ⊆∪ˡ _ x∈p₁\n from (inj₂ x∈p₂) = ⊆∪ʳ _ _ x∈p₂\n\n------------------------------------------------------------------------\n-- _⊆_ is a partial order\n\n-- The \"natural poset\" associated with the boolean algebra.\n\nmodule NaturalPoset where\n private\n open module BA {n} = BoolProp (booleanAlgebra n) public\n using (poset)\n open module Po {n} = Poset (poset {n = n}) public\n\n -- _⊆_ is equivalent to the natural lattice order.\n\n orders-equivalent : ∀ {n} {p₁ p₂ : Subset n} → p₁ ⊆ p₂ ⇔ p₁ ≤ p₂\n orders-equivalent = equivalence (to _ _) (from _ _)\n where\n to : ∀ {n} (p₁ p₂ : Subset n) → p₁ ⊆ p₂ → p₁ ≤ p₂\n to [] [] p₁⊆p₂ = P.refl\n to (inside ∷ p₁) (_ ∷ p₂) p₁⊆p₂ with p₁⊆p₂ here\n to (inside ∷ p₁) (.inside ∷ p₂) p₁⊆p₂ | here = P.cong (_∷_ inside) (to p₁ p₂ (drop-∷-⊆ p₁⊆p₂))\n to (outside ∷ p₁) (_ ∷ p₂) p₁⊆p₂ = P.cong (_∷_ outside) (to p₁ p₂ (drop-∷-⊆ p₁⊆p₂))\n\n from : ∀ {n} (p₁ p₂ : Subset n) → p₁ ≤ p₂ → p₁ ⊆ p₂\n from [] [] p₁≤p₂ x = x\n from (.inside ∷ _) (_ ∷ _) p₁≤p₂ here rewrite P.cong head p₁≤p₂ = here\n from (_ ∷ p₁) (_ ∷ p₂) p₁≤p₂ (there xs[i]=x) =\n there (from p₁ p₂ (P.cong tail p₁≤p₂) xs[i]=x)\n\n-- _⊆_ is a partial order.\n\nposet : ℕ → Poset _ _ _\nposet n = record\n { Carrier = Subset n\n ; _≈_ = _≡_\n ; _≤_ = _⊆_\n ; isPartialOrder = record\n { isPreorder = record\n { isEquivalence = P.isEquivalence\n ; reflexive = λ i≡j → from ⟨$⟩ reflexive i≡j\n ; trans = λ x⊆y y⊆z → from ⟨$⟩ trans (to ⟨$⟩ x⊆y) (to ⟨$⟩ y⊆z)\n }\n ; antisym = λ x⊆y y⊆x → antisym (to ⟨$⟩ x⊆y) (to ⟨$⟩ y⊆x)\n }\n }\n where\n open NaturalPoset\n open module E {p₁ p₂} =\n Equivalence (orders-equivalent {n = n} {p₁ = p₁} {p₂ = p₂})\n", "meta": {"hexsha": "722a0767a0fa15bad8487eb9de07922695cc4cb7", "size": 5265, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Fin/Subset/Properties.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Fin/Subset/Properties.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Fin/Subset/Properties.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.5350318471, "max_line_length": 100, "alphanum_fraction": 0.4564102564, "num_tokens": 2227, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933315126791, "lm_q2_score": 0.752012562644147, "lm_q1q2_score": 0.6165700853256969}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Algebra.Structures.Bundles.Field\n\nmodule Algebra.Linear.Construct.Vector\n {k ℓ} (K : Field k ℓ)\n where\n\nopen import Level using (_⊔_)\nopen import Data.Product using (_×_; _,_)\nopen import Data.Vec public hiding (sum)\nimport Data.Vec.Properties as VP\nimport Data.Vec.Relation.Binary.Pointwise.Inductive as PW\nopen import Data.Nat hiding (_⊔_) renaming (_+_ to _+ℕ_)\nopen import Data.Fin using (Fin)\n\nopen import Relation.Binary\nopen import Algebra.Linear.Core\nopen import Algebra.FunctionProperties\n\nopen import Relation.Binary.PropositionalEquality as P\n using (_≡_; subst; subst-subst-sym)\n renaming\n ( refl to ≡-refl\n ; sym to ≡-sym\n ; trans to ≡-trans\n )\n\nopen import Algebra.Structures.Field.Utils K\nimport Algebra.Linear.Structures.VectorSpace as VS\n\nopen VS.VectorSpaceField K\n\nopen import Data.Nat.Properties\n using\n ( ≤-refl\n ; ≤-reflexive\n ; ≤-antisym\n ; n∸n≡0\n ; m+[n∸m]≡n\n ; m≤m+n\n ; suc-injective\n )\n renaming\n ( +-identityˡ to +ℕ-identityˡ\n ; +-identityʳ to +ℕ-identityʳ \n )\n\nprivate\n V : ℕ -> Set k\n V = Vec K'\n\nsplitAt' : ∀ {n} (i : ℕ) (j : ℕ) -> i +ℕ j ≡ n -> V n → V i × V j\nsplitAt' {0} 0 0 r [] = ([] , [])\nsplitAt' {suc n} 0 (suc j) r u = ([] , subst V (≡-sym r) u)\nsplitAt' {suc n} (suc i) j r (x ∷ xs) =\n let (xs₁ , xs₂) = splitAt' {n} i j (suc-injective r) xs\n in (x ∷ xs₁ , xs₂)\n\nopen PW public\n using ()\n renaming\n ( _∷_ to ≈-cons\n ; [] to ≈-null\n ; head to ≈-head\n ; tail to ≈-tail\n ; uncons to ≈-uncons\n ; lookup to ≈-lookup\n ; map to ≈-map\n )\n\n_≈ʰ_ : ∀ {m n} (xs : Vec K' m) (ys : Vec K' n) → Set (k ⊔ ℓ)\n_≈ʰ_ = PW.Pointwise _≈ᵏ_\n\n_≈_ : ∀ {n} (xs : Vec K' n) (ys : Vec K' n) → Set (k ⊔ ℓ)\n_≈_ = _≈ʰ_\n\n≈-isEquiv : ∀ {n} -> IsEquivalence (_≈_ {n})\n≈-isEquiv {n} = PW.isEquivalence ≈ᵏ-isEquiv n\n\nsetoid : ℕ -> Setoid k (k ⊔ ℓ)\nsetoid n = record { isEquivalence = ≈-isEquiv {n} }\n\nmodule _ {n} where\n open IsEquivalence (≈-isEquiv {n}) public\n using ()\n renaming\n ( refl to ≈-refl\n ; sym to ≈-sym\n ; trans to ≈-trans\n ; reflexive to ≈-reflexive\n )\n\n0# : ∀ {n} → V n\n0# {0} = []\n0# {suc n} = 0ᵏ ∷ 0# {n}\n\n-_ : ∀ {n} → V n → V n\n-_ = map (-ᵏ_)\n\ninfixr 25 _+_\n_+_ : ∀ {n} → Op₂ (V n)\n_+_ = zipWith _+ᵏ_\n\ninfixr 35 _∙_\n_∙_ : ∀ {n} → K' → V n → V n\n_∙_ k = map (k *ᵏ_)\n\n{-\nmodule HeterogeneousEquivalence where\n import Relation.Binary.Indexed.Heterogeneous as IH\n\n data _≈ʰ_ : IH.IRel V (k ⊔ ℓ) where\n ≈ʰ-null : ∀ {n p} {u : V n} {v : V p} -> n ≡ 0 -> p ≡ 0 -> u ≈ʰ v\n ≈ʰ-cons : ∀ {n p} {x y : K'} {u : V n} {v : V p} -> n ≡ p -> x ≈ᵏ y -> u ≈ʰ v -> (x ∷ u) ≈ʰ (y ∷ v)\n\n pattern ≈ʰ-zero = ≈ʰ-null ≡-refl ≡-refl\n\n ≈ʰ-refl : IH.Reflexive V _≈ʰ_\n ≈ʰ-refl {0} {[]} = ≈ʰ-zero\n ≈ʰ-refl {suc n} {x ∷ xs} = ≈ʰ-cons (≡-refl) ≈ᵏ-refl (≈ʰ-refl {n} {xs})\n\n ≈ʰ-sym : IH.Symmetric V _≈ʰ_\n ≈ʰ-sym {0} ≈ʰ-zero = ≈ʰ-zero\n ≈ʰ-sym {suc n} (≈ʰ-cons rn r rs) = ≈ʰ-cons (≡-sym rn) (≈ᵏ-sym r) (≈ʰ-sym rs)\n\n ≈ʰ-trans : IH.Transitive V _≈ʰ_\n ≈ʰ-trans (≈ʰ-null rn rp) (≈ʰ-null rn' rp') = ≈ʰ-null rn rp'\n ≈ʰ-trans (≈ʰ-cons rn r rs) (≈ʰ-cons rn' r' rs') = ≈ʰ-cons (≡-trans rn rn') (≈ᵏ-trans r r') (≈ʰ-trans rs rs')\n\n ≈ʰ-isEquiv : IH.IsIndexedEquivalence V _≈ʰ_\n ≈ʰ-isEquiv = record\n { refl = ≈ʰ-refl\n ; sym = ≈ʰ-sym\n ; trans = ≈ʰ-trans\n }\n\n ≈-to-≈ʰ : ∀ {n} {u v : V n} -> u ≈ v -> u ≈ʰ v\n ≈-to-≈ʰ {0} ≈-null = ≈ʰ-zero\n ≈-to-≈ʰ {suc n} (≈-cons r rs) = ≈ʰ-cons ≡-refl r (≈-to-≈ʰ rs)\n\n ≈ʰ-to-≈ : ∀ {n} {u v : V n} -> u ≈ʰ v -> u ≈ v\n ≈ʰ-to-≈ {0} {[]} {[]} ≈ʰ-zero = ≈-null\n ≈ʰ-to-≈ {suc n} (≈ʰ-cons _ r rs) = ≈-cons r (≈ʰ-to-≈ rs)\n\n ≈ʰ-tail : ∀ {n p} {x y : K'} {u : V n} {v : V p} -> (x ∷ u) ≈ʰ (x ∷ v) -> u ≈ʰ v\n ≈ʰ-tail (≈ʰ-cons _ _ r) = r\n\n indexedSetoid : IH.IndexedSetoid ℕ k (ℓ ⊔ k)\n indexedSetoid = record\n { Carrier = V\n ; _≈_ = _≈ʰ_\n ; isEquivalence = ≈ʰ-isEquiv\n }\nsetoid : ℕ -> Setoid k (k ⊔ ℓ)\nsetoid n = record\n { Carrier = V n\n ; _≈_ = _≈_\n ; isEquivalence = ≈-isEquiv\n }\n-}\n\n++-identityˡ : ∀ {n} (u : V n) -> ([] ++ u) ≈ u\n++-identityˡ _ = ≈-refl\n\n++-cong : ∀ {n p} {u₁ v₁ : V n} {u₂ v₂ : V p}\n -> u₁ ≈ v₁ -> u₂ ≈ v₂ -> (u₁ ++ u₂) ≈ (v₁ ++ v₂)\n++-cong ≈-null r₂ = r₂\n++-cong (≈-cons r₁ rs₁) r₂ = ≈-cons r₁ (++-cong rs₁ r₂)\n\n++-split : ∀ {n p} {u₁ v₁ : V n} {u₂ v₂ : V p}\n -> (u₁ ++ u₂) ≈ (v₁ ++ v₂) -> (u₁ ≈ v₁ × u₂ ≈ v₂)\n++-split {0} {p} {[]} {[]} r = ≈-null , r\n++-split {suc n} {p} {x ∷ xs} {y ∷ ys} (≈-cons r rs) =\n let (r₁ , r₂) = ++-split {n} {p} rs\n in (≈-cons r r₁) , r₂\n\n0++0≈0 : ∀ {n p} -> (0# {n} ++ 0# {p}) ≈ 0# {n +ℕ p}\n0++0≈0 {zero} = ++-identityˡ 0#\n0++0≈0 {suc n} = ≈-cons ≈ᵏ-refl (0++0≈0 {n})\n\n{-\nopen HeterogeneousEquivalence\n\n++-identityʳ-≈ʰ : ∀ {n} (u : V n) -> (u ++ []) ≈ʰ u\n++-identityʳ-≈ʰ [] = ≈ʰ-refl\n++-identityʳ-≈ʰ {suc n} (x ∷ xs) = ≈ʰ-cons (+ℕ-identityʳ n) ≈ᵏ-refl (++-identityʳ-≈ʰ {n} xs)\n\n++-cong-≈ʰ : ∀ {n p} {u₁ v₁ : V n} {u₂ v₂ : V p}\n -> u₁ ≈ʰ v₁ -> u₂ ≈ʰ v₂ -> (u₁ ++ u₂) ≈ʰ (v₁ ++ v₂)\n++-cong-≈ʰ r₁ r₂ = ≈-to-≈ʰ (++-cong (≈ʰ-to-≈ r₁) (≈ʰ-to-≈ r₂))\n\nsplitAt-identityˡ : ∀ {n} (u : V n) -> let (x₁ , x₂) = splitAt 0 z≤n u in (x₁ ≈ʰ []) × (x₂ ≈ʰ u)\nsplitAt-identityˡ {0}_ = ≈ʰ-zero , ≈ʰ-zero\nsplitAt-identityˡ {suc n} _ = ≈ʰ-zero , ≈ʰ-refl\n\nsplitAt-identityʳ : ∀ {n} (u : V n) -> let (x₁ , x₂) = splitAt n ≤-refl u in (x₁ ≈ʰ u) × (x₂ ≈ʰ [])\nsplitAt-identityʳ {0} [] = ≈ʰ-refl , ≈ʰ-refl\nsplitAt-identityʳ {suc n} (x ∷ xs) = ≈ʰ-cons ≡-refl ≈ᵏ-refl (proj₁ (splitAt-identityʳ xs))\n , ≈ʰ-null (n∸n≡0 (suc n)) ≡-refl\n\n++-splitAt : ∀ {n} (k : ℕ) (r : k ≤ n) (u : V n) -> let (x₁ , x₂, _) = splitAt n u in (x₁ ++ x₂) ≡ u\n++-splitAt {0} 0 r u = ≈ʰ-null (m+[n∸m]≡n r) ≡-refl\n++-splitAt {suc n} 0 r (x ∷ xs) = ≈ʰ-refl\n++-splitAt {suc n} (suc k) sk≤sn (x ∷ xs) =\n let k≤n = ≤-pred sk≤sn\n in ≈ʰ-cons (m+[n∸m]≡n k≤n) ≈ᵏ-refl (++-splitAt k k≤n xs)\n\nsplitAt-++ : ∀ {n p} (u : Vec n) (v : Vec p) ->\n let (u' , v') = splitAt n (m≤m+n n p) (u ++ v) in (u ≈ʰ u') × (v ≈ʰ v')\nsplitAt-++ {0} {0} [] [] = ≈ʰ-zero , ≈ʰ-zero\nsplitAt-++ {0} {suc p} [] (y ∷ ys) = ≈ʰ-zero , ≈ʰ-refl\nsplitAt-++ {suc n} {0} (x ∷ xs) [] =\n let (rxs , rv) = splitAt-++ xs []\n in ≈ʰ-cons ≡-refl ≈ᵏ-refl rxs , rv\nsplitAt-++ {suc n} {suc p} (x ∷ xs) (y ∷ ys) =\n let (u' , v') = splitAt (suc n) (m≤m+n (suc n) (suc p)) (x ∷ xs ++ y ∷ ys)\n (ru , rys) = splitAt-++ {suc n} {p} (x ∷ xs) ys\n (rxs , rv) = splitAt-++ {n} {suc p} xs (y ∷ ys)\n in ≈ʰ-cons ≡-refl ≈ᵏ-refl rxs , rv\n\n++-splitAt' : ∀ {n p} (u : Vec (n +ℕ p)) -> let (x₁ , x₂) = splitAt' n p ≡-refl u in x₁ ++ x₂ ≈ u\n++-splitAt' {0} [] = ≈-null\n++-splitAt' {0} (x ∷ xs) = ≈-refl\n++-splitAt' {suc n} (x ∷ xs) = ≈-cons ≈ᵏ-refl (++-splitAt' {n} xs)\n\nsplitAt'-++ : ∀ {n p} (u : Vec n) (v : Vec p) ->\n let (u' , v') = splitAt' n p ≡-refl (u ++ v) in (u ≈ u') × (v ≈ v')\nsplitAt'-++ {0} {0} [] [] = ≈-null , ≈-null\nsplitAt'-++ {0} {suc p} [] (y ∷ ys) = ≈-null , ≈-refl\nsplitAt'-++ {suc n} {0} (x ∷ xs) [] =\n let (rxs , rv) = splitAt'-++ xs []\n in ≈-cons ≈ᵏ-refl rxs , rv\nsplitAt'-++ {suc n} {suc p} (x ∷ xs) (y ∷ ys) =\n let (u' , v') = splitAt' (suc n) (suc p) ≡-refl (x ∷ xs ++ y ∷ ys)\n (ru , rys) = splitAt'-++ {suc n} {p} (x ∷ xs) ys\n (rxs , rv) = splitAt'-++ {n} {suc p} xs (y ∷ ys)\n in ≈-cons ≈ᵏ-refl rxs , rv\n-}\n\n+-cong : ∀ {n} → Congruent₂ (_≈_ {n}) _+_\n+-cong ≈-null ≈-null = ≈-null\n+-cong (≈-cons r₁ rs₁) (≈-cons r₂ rs₂) = ≈-cons (+ᵏ-cong r₁ r₂) (+-cong rs₁ rs₂)\n\n+-assoc : ∀ {n} → Associative (_≈_ {n}) _+_\n+-assoc [] [] [] = ≈-null\n+-assoc (x ∷ xs) (y ∷ ys) (z ∷ zs) = ≈-cons (+ᵏ-assoc x y z) (+-assoc xs ys zs)\n\n+-identityˡ : ∀ {n} → LeftIdentity (_≈_ {n}) 0# _+_\n+-identityˡ [] = ≈-null\n+-identityˡ (x ∷ xs) = ≈-cons (+ᵏ-identityˡ x) (+-identityˡ xs)\n\n+-identityʳ : ∀ {n} → RightIdentity (_≈_ {n}) 0# _+_\n+-identityʳ [] = ≈-null\n+-identityʳ (x ∷ xs) = ≈-cons (+ᵏ-identityʳ x) (+-identityʳ xs)\n\n+-identity : ∀ {n} → Identity (_≈_ {n}) 0# _+_\n+-identity = +-identityˡ , +-identityʳ\n\n+-comm : ∀ {n} -> Commutative (_≈_ {n}) _+_\n+-comm [] [] = ≈-null\n+-comm (x ∷ xs) (y ∷ ys) = ≈-cons (+ᵏ-comm x y) (+-comm xs ys)\n\n*ᵏ-∙-compat : ∀ {n} (a b : K') (u : V n) -> ((a *ᵏ b) ∙ u) ≈ (a ∙ (b ∙ u))\n*ᵏ-∙-compat a b [] = ≈-null\n*ᵏ-∙-compat a b (x ∷ xs) = ≈-cons (*ᵏ-assoc a b x) (*ᵏ-∙-compat a b xs)\n\n∙-+-distrib : ∀ {n} (a : K') (u v : V n) -> (a ∙ (u + v)) ≈ ((a ∙ u) + (a ∙ v))\n∙-+-distrib a [] [] = ≈-null\n∙-+-distrib a (x ∷ xs) (y ∷ ys) = ≈-cons (*ᵏ-+ᵏ-distribˡ a x y) (∙-+-distrib a xs ys)\n\n∙-+ᵏ-distrib : ∀ {n} (a b : K') (u : V n) -> ((a +ᵏ b) ∙ u) ≈ ((a ∙ u) + (b ∙ u))\n∙-+ᵏ-distrib a b [] = ≈-null\n∙-+ᵏ-distrib a b (x ∷ u) = ≈-cons (*ᵏ-+ᵏ-distribʳ x a b) (∙-+ᵏ-distrib a b u)\n\n∙-cong : ∀ {n} {a b : K'} {u v : V n} → a ≈ᵏ b -> u ≈ v -> (a ∙ u) ≈ (b ∙ v)\n∙-cong rᵏ ≈-null = ≈-null\n∙-cong rᵏ (≈-cons r rs) = ≈-cons (*ᵏ-cong rᵏ r) (∙-cong rᵏ rs)\n\n∙-identity : ∀ {n} (x : V n) → (1ᵏ ∙ x) ≈ x\n∙-identity [] = ≈-null\n∙-identity (x ∷ xs) = ≈-cons (*ᵏ-identityˡ x) (∙-identity xs)\n\n∙-absorbˡ : ∀ {n} (x : V n) → (0ᵏ ∙ x) ≈ 0#\n∙-absorbˡ [] = ≈-null\n∙-absorbˡ (x ∷ xs) = ≈-cons (*ᵏ-zeroˡ x) (∙-absorbˡ xs)\n\n-‿inverseˡ : ∀ {n} → LeftInverse (_≈_ {n}) 0# -_ _+_\n-‿inverseˡ [] = ≈-null\n-‿inverseˡ (x ∷ xs) = ≈-cons (-ᵏ‿inverseˡ x) (-‿inverseˡ xs)\n\n-‿inverseʳ : ∀ {n} → RightInverse (_≈_ {n}) 0# -_ _+_\n-‿inverseʳ [] = ≈-null\n-‿inverseʳ (x ∷ xs) = ≈-cons (-ᵏ‿inverseʳ x) (-‿inverseʳ xs)\n\n-‿inverse : ∀ {n} → Inverse (_≈_ {n}) 0# -_ _+_\n-‿inverse = -‿inverseˡ , -‿inverseʳ\n\n-‿cong : ∀ {n} -> Congruent₁ (_≈_ {n}) -_\n-‿cong ≈-null = ≈-null\n-‿cong (≈-cons r rs) = ≈-cons (-ᵏ‿cong r) (-‿cong rs)\n\n+-++-distrib : ∀ {n p}\n (u₁ : V n) (u₂ : V p)\n (v₁ : V n) (v₂ : V p)\n -> ((u₁ ++ u₂) + (v₁ ++ v₂)) ≈ ((u₁ + v₁) ++ (u₂ + v₂))\n+-++-distrib [] [] [] [] = ≈-null\n+-++-distrib (x₁ ∷ xs₁) [] (y₁ ∷ ys₁) [] = ++-cong ≈-refl (+-++-distrib xs₁ [] ys₁ [])\n+-++-distrib {0} {suc p} [] (x₂ ∷ xs₂) [] (y₂ ∷ ys₂) = ++-identityˡ ((x₂ +ᵏ y₂) ∷ (xs₂ + ys₂))\n+-++-distrib (x₁ ∷ xs₁) u₂ (y₁ ∷ ys₁) v₂ =\n ≈-cons ≈ᵏ-refl (++-cong ≈-refl (+-++-distrib xs₁ u₂ ys₁ v₂))\n\n∙-++-distrib : ∀ {n p} (a : K') (u : V n) (v : V p) -> (a ∙ (u ++ v)) ≈ ((a ∙ u) ++ (a ∙ v))\n∙-++-distrib a [] v = ≈-refl\n∙-++-distrib a (x ∷ xs) v = ≈-cons ≈ᵏ-refl (∙-++-distrib a xs v)\n\nsum : ∀ {n} -> V n -> K'\nsum = foldr _ _+ᵏ_ 0ᵏ\n\nsum-tab : ∀ {n} -> (Fin n -> K') -> K'\nsum-tab f = sum (tabulate f)\n\nsum-cong : ∀ {n} {u v : V n} -> u ≈ v -> sum u ≈ᵏ sum v\nsum-cong {0} PW.[] = ≈ᵏ-refl\nsum-cong {suc n} (r PW.∷ rs) = +ᵏ-cong r (sum-cong {n} rs)\n\ntabulate-cong-≡ : ∀ {n} {f g : Fin n -> K'} -> (∀ i -> f i ≡ g i) -> tabulate f ≡ tabulate g\ntabulate-cong-≡ = VP.tabulate-cong\n\ntabulate-cong : ∀ {n} {f g : Fin n -> K'} -> (∀ i -> f i ≈ᵏ g i) -> tabulate f ≈ tabulate g\ntabulate-cong {0} r = PW.[]\ntabulate-cong {suc n} r = r Fin.zero PW.∷ tabulate-cong (λ i → r (Fin.suc i))\n\nsum-tab-cong : ∀ {n} {f g : Fin n -> K'} -> (∀ i -> f i ≈ᵏ g i) -> sum-tab f ≈ᵏ sum-tab g\nsum-tab-cong r = sum-cong (tabulate-cong r)\n\n*ᵏ-sum-tab-distribʳ : ∀ {n} (a : K') (f : Fin n -> K')\n → (sum-tab f *ᵏ a) ≈ᵏ sum-tab (λ k -> f k *ᵏ a)\n*ᵏ-sum-tab-distribʳ {0} a f = *ᵏ-zeroˡ a\n*ᵏ-sum-tab-distribʳ {suc n} a f =\n begin\n sum-tab f *ᵏ a\n ≈⟨ *ᵏ-+ᵏ-distribʳ a (f Fin.zero) (sum-tab (λ k -> f (Fin.suc k))) ⟩\n (f Fin.zero *ᵏ a) +ᵏ (sum-tab (λ k -> f (Fin.suc k)) *ᵏ a)\n ≈⟨ +ᵏ-cong ≈ᵏ-refl (*ᵏ-sum-tab-distribʳ a (λ k -> f (Fin.suc k))) ⟩\n sum-tab (λ k -> f k *ᵏ a)\n ∎\n where open import Relation.Binary.EqReasoning (Field.setoid K)\n\nsum-assoc : ∀ {n} (f g : Fin n -> K')\n -> (sum-tab f +ᵏ sum-tab g) ≈ᵏ sum-tab (λ k -> f k +ᵏ g k)\nsum-assoc {0} f g = +ᵏ-identityˡ 0ᵏ\nsum-assoc {suc n} f g =\n begin\n sum-tab f +ᵏ sum-tab g\n ≡⟨⟩\n (f Fin.zero +ᵏ sum-tab {n} (λ k -> f (Fin.suc k))) +ᵏ (g Fin.zero +ᵏ sum-tab {n} (λ k -> g (Fin.suc k)))\n ≈⟨ +ᵏ-assoc (f Fin.zero) (sum-tab {n} (λ k -> f (Fin.suc k))) (g Fin.zero +ᵏ sum-tab {n} (λ k -> g (Fin.suc k))) ⟩\n f Fin.zero +ᵏ (sum-tab (λ k → f (Fin.suc k)) +ᵏ (g Fin.zero +ᵏ sum-tab (λ k → g (Fin.suc k))))\n ≈⟨ +ᵏ-cong ≈ᵏ-refl (+ᵏ-comm (sum-tab (λ k -> f (Fin.suc k))) ((g Fin.zero +ᵏ sum-tab (λ k → g (Fin.suc k))))) ⟩\n f Fin.zero +ᵏ ((g Fin.zero +ᵏ sum-tab (λ k → g (Fin.suc k))) +ᵏ sum-tab (λ k → f (Fin.suc k)))\n ≈⟨ +ᵏ-cong ≈ᵏ-refl (+ᵏ-assoc (g Fin.zero) (sum-tab (λ k -> g (Fin.suc k))) (sum-tab (λ k -> f (Fin.suc k)))) ⟩\n f Fin.zero +ᵏ (g Fin.zero +ᵏ (sum-tab (λ k → g (Fin.suc k)) +ᵏ sum-tab (λ k → f (Fin.suc k))))\n ≈⟨ ≈ᵏ-sym (+ᵏ-assoc (f Fin.zero) (g Fin.zero) (sum-tab (λ k → g (Fin.suc k)) +ᵏ sum-tab (λ k → f (Fin.suc k)))) ⟩\n (f Fin.zero +ᵏ g Fin.zero) +ᵏ (sum-tab (λ k → g (Fin.suc k)) +ᵏ sum-tab (λ k → f (Fin.suc k)))\n ≈⟨ +ᵏ-cong ≈ᵏ-refl (+ᵏ-comm (sum-tab λ k -> g (Fin.suc k)) (sum-tab λ k -> f (Fin.suc k))) ⟩\n (f Fin.zero +ᵏ g Fin.zero) +ᵏ (sum-tab (λ k → f (Fin.suc k)) +ᵏ sum-tab (λ k → g (Fin.suc k)))\n ≈⟨ +ᵏ-cong ≈ᵏ-refl (sum-assoc {n} (λ k -> f (Fin.suc k)) (λ k -> g (Fin.suc k))) ⟩\n sum-tab (λ k -> f k +ᵏ g k)\n ∎\n where open import Relation.Binary.EqReasoning (Field.setoid K)\n\nsum-tab-0ᵏ : ∀ {n} -> sum-tab {n} (λ k -> 0ᵏ) ≈ᵏ 0ᵏ\nsum-tab-0ᵏ {0} = ≈ᵏ-refl\nsum-tab-0ᵏ {suc n} = ≈ᵏ-trans (+ᵏ-identityˡ (sum-tab {n} λ k -> 0ᵏ)) (sum-tab-0ᵏ {n})\n\nsum-tab-swap : ∀ {n p} (f : Fin n -> Fin p -> K') (g : Fin n -> K')\n -> sum-tab (λ k′ -> sum-tab λ k -> f k k′ *ᵏ g k)\n ≈ᵏ sum-tab (λ k -> sum-tab λ k′ -> f k k′ *ᵏ g k)\nsum-tab-swap {n} {0} f g = ≈ᵏ-sym (sum-tab-0ᵏ {n})\nsum-tab-swap {n} {suc p} f g =\n begin\n sum-tab (λ k′ -> sum-tab λ k -> f k k′ *ᵏ g k)\n ≡⟨⟩\n (sum-tab λ k -> f k Fin.zero *ᵏ g k) +ᵏ (sum-tab λ k′ -> sum-tab λ k -> f k (Fin.suc k′) *ᵏ g k)\n ≈⟨ +ᵏ-cong ≈ᵏ-refl (sum-tab-swap {n} {p} (λ k k′ -> f k (Fin.suc k′)) g) ⟩\n sum-tab (λ k → f k Fin.zero *ᵏ g k) +ᵏ sum-tab (λ k → sum-tab (λ k′ → f k (Fin.suc k′) *ᵏ g k))\n ≈⟨ +ᵏ-cong ≈ᵏ-refl (sum-tab-cong λ k -> ≈ᵏ-sym (*ᵏ-sum-tab-distribʳ {p} (g k) λ k′ -> f k (Fin.suc k′))) ⟩\n sum-tab (λ k → f k Fin.zero *ᵏ g k) +ᵏ sum-tab (λ k → sum-tab (λ k′ → f k (Fin.suc k′)) *ᵏ g k)\n ≈⟨ sum-assoc (λ k -> f k Fin.zero *ᵏ g k) (λ k -> sum-tab (λ k′ -> f k (Fin.suc k′)) *ᵏ g k) ⟩\n sum-tab (λ k -> (f k Fin.zero *ᵏ g k) +ᵏ (sum-tab (λ k′ -> f k (Fin.suc k′)) *ᵏ g k))\n ≈⟨ sum-tab-cong (λ k -> ≈ᵏ-sym (*ᵏ-+ᵏ-distribʳ (g k) (f k Fin.zero) (sum-tab λ k′ -> f k (Fin.suc k′)))) ⟩\n sum-tab (λ k -> sum-tab (λ k′ -> f k k′) *ᵏ g k)\n ≈⟨ sum-tab-cong (λ k -> *ᵏ-sum-tab-distribʳ {suc p} (g k) (λ k′ -> f k k′)) ⟩\n sum-tab (λ k -> sum-tab λ k′ -> f k k′ *ᵏ g k)\n ∎\n where open import Relation.Binary.EqReasoning (Field.setoid K)\n\nsum-tab-δ : ∀ {n} (f : Fin n -> K') (i : Fin n) -> sum-tab (λ k -> δ i k *ᵏ f k) ≈ᵏ f i\nsum-tab-δ {suc n} f i@Fin.zero =\n begin\n sum-tab (λ k -> δ i k *ᵏ f k)\n ≡⟨⟩\n (δ i i *ᵏ f i) +ᵏ sum-tab (λ k -> δ i (Fin.suc k) *ᵏ f (Fin.suc k))\n ≈⟨ +ᵏ-cong (*ᵏ-identityˡ (f i))\n (sum-tab-cong (λ k -> ≈ᵏ-trans (*ᵏ-cong (δ-cancelˡ {n} k) ≈ᵏ-refl) (*ᵏ-zeroˡ (f (Fin.suc k))))) ⟩\n f i +ᵏ sum-tab {n} (λ k -> 0ᵏ)\n ≈⟨ ≈ᵏ-trans (+ᵏ-cong ≈ᵏ-refl (sum-tab-0ᵏ {n})) (+ᵏ-identityʳ (f i)) ⟩\n f i\n ∎\n where open import Relation.Binary.EqReasoning (Field.setoid K)\nsum-tab-δ {suc n} f (Fin.suc i) =\n begin\n sum-tab (λ k -> δ (Fin.suc i) k *ᵏ f k)\n ≡⟨⟩\n (δ (Fin.suc i) (Fin.zero {suc n}) *ᵏ f Fin.zero) +ᵏ sum-tab (λ k -> δ (Fin.suc i) (Fin.suc k) *ᵏ f (Fin.suc k))\n ≈⟨ +ᵏ-cong (≈ᵏ-trans (*ᵏ-cong (δ-cancelʳ {p = suc n} (Fin.suc i)) ≈ᵏ-refl) (*ᵏ-zeroˡ (f Fin.zero))) ≈ᵏ-refl ⟩\n 0ᵏ +ᵏ sum-tab (λ k → δ (Fin.suc i) (Fin.suc k) *ᵏ f (Fin.suc k))\n ≈⟨ +ᵏ-identityˡ (sum-tab λ k -> δ (Fin.suc i) (Fin.suc k) *ᵏ f (Fin.suc k)) ⟩\n sum-tab (λ k → δ (Fin.suc i) (Fin.suc k) *ᵏ f (Fin.suc k))\n ≈⟨ sum-tab-δ (λ k -> f (Fin.suc k)) i ⟩\n f (Fin.suc i)\n ∎\n where open import Relation.Binary.EqReasoning (Field.setoid K)\n\nmodule _ {n} where\n open import Algebra.Structures (_≈_ {n})\n open import Algebra.Linear.Structures.Bundles\n\n isMagma : IsMagma _+_\n isMagma = record\n { isEquivalence = ≈-isEquiv\n ; ∙-cong = +-cong\n }\n\n isSemigroup : IsSemigroup _+_\n isSemigroup = record\n { isMagma = isMagma\n ; assoc = +-assoc\n }\n\n isMonoid : IsMonoid _+_ 0#\n isMonoid = record\n { isSemigroup = isSemigroup\n ; identity = +-identity\n }\n\n isGroup : IsGroup _+_ 0# -_\n isGroup = record\n { isMonoid = isMonoid\n ; inverse = -‿inverse\n ; ⁻¹-cong = -‿cong\n }\n\n isAbelianGroup : IsAbelianGroup _+_ 0# -_\n isAbelianGroup = record\n { isGroup = isGroup\n ; comm = +-comm\n }\n\n open VS K\n\n isVectorSpace : VS.IsVectorSpace K (_≈_ {n}) _+_ _∙_ -_ 0#\n isVectorSpace = record\n { isAbelianGroup = isAbelianGroup\n ; *ᵏ-∙-compat = *ᵏ-∙-compat\n ; ∙-+-distrib = ∙-+-distrib\n ; ∙-+ᵏ-distrib = ∙-+ᵏ-distrib\n ; ∙-cong = ∙-cong\n ; ∙-identity = ∙-identity\n ; ∙-absorbˡ = ∙-absorbˡ\n }\n\n vectorSpace : VectorSpace K k (k ⊔ ℓ)\n vectorSpace = record { isVectorSpace = isVectorSpace }\n\n open import Algebra.Linear.Morphism.VectorSpace K\n\n open import Algebra.Linear.Morphism.Bundles K\n\n open import Function\n\n embed : LinearIsomorphism vectorSpace vectorSpace\n embed = record\n { ⟦_⟧ = id\n ; isLinearIsomorphism = record\n { isLinearMonomorphism = record\n { isLinearMap = record\n { isAbelianGroupMorphism = record\n { gp-homo = record\n { mn-homo = record\n { sm-homo = record\n { ⟦⟧-cong = id\n ; ∙-homo = λ x y → ≈-refl\n }\n ; ε-homo = ≈-refl\n }\n }\n }\n ; ∙-homo = λ c u → ≈-refl\n }\n ; injective = id\n }\n ; surjective = λ y → y , ≈-refl\n }\n }\n", "meta": {"hexsha": "a498026e396e5eadd84c927dd4bd93a6ef85d189", "size": 17937, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Algebra/Linear/Construct/Vector.agda", "max_stars_repo_name": "felko/linear-algebra", "max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z", "max_issues_repo_path": "src/Algebra/Linear/Construct/Vector.agda", "max_issues_repo_name": "felko/linear-algebra", "max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Algebra/Linear/Construct/Vector.agda", "max_forks_repo_name": "felko/linear-algebra", "max_forks_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.3786982249, "max_line_length": 116, "alphanum_fraction": 0.4882087306, "num_tokens": 8975, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568416, "lm_q2_score": 0.7931059560743422, "lm_q1q2_score": 0.616481141370259}} {"text": "open import Algebra.Apartness using (HeytingField)\n\nmodule Data.Real.Abstract.Structures {c ℓ₁ ℓ₂} (f : HeytingField c ℓ₁ ℓ₂) where\n\nopen HeytingField f\n\nopen import Relation.Binary using (Rel; IsStrictTotalOrder)\nopen import Level using (_⊔_)\nopen import Data.Product using (_×_; ∃-syntax)\n\nimport Data.Nat as ℕ\nopen ℕ using (ℕ; zero; suc)\n\nrecord IsOrderedHeytingField\n {r} (_<_ : Rel Carrier r) : Set (c ⊔ ℓ₁ ⊔ r)\n where\n\n field\n isStrictTotalOrder : IsStrictTotalOrder _≈_ _<_\n ordered : ∀ a b c → a < b → (a + c) < (b + c) × (c + a) < (c + b)\n \n\n_ℕ*_ : ℕ → Carrier → Carrier\nzero ℕ* x = 1#\nsuc n ℕ* x = x * (n ℕ* x)\n\nrecord IsArchimedanHeytingField\n {r} (_<_ : Rel Carrier r) : Set (c ⊔ ℓ₁ ⊔ r)\n where\n\n field\n dense : ∀ a b → a < b → ∃[ c ] (a < c) × (c < b)\n archimedan : ∀ a b → 0# < a → 0# < b → ∃[ n ] (b < (n ℕ* a))\n", "meta": {"hexsha": "f45defd4d933f9af13c5106893649f46c95e1c75", "size": 848, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Real/Abstract/Structures.agda", "max_stars_repo_name": "cspollard/reals", "max_stars_repo_head_hexsha": "a193aeebf1326f960975b19d3e31b46fddbbfaa2", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Data/Real/Abstract/Structures.agda", "max_issues_repo_name": "cspollard/reals", "max_issues_repo_head_hexsha": "a193aeebf1326f960975b19d3e31b46fddbbfaa2", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/Real/Abstract/Structures.agda", "max_forks_repo_name": "cspollard/reals", "max_forks_repo_head_hexsha": "a193aeebf1326f960975b19d3e31b46fddbbfaa2", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.9411764706, "max_line_length": 79, "alphanum_fraction": 0.6002358491, "num_tokens": 327, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9362850110816423, "lm_q2_score": 0.6584175139669998, "lm_q1q2_score": 0.6164664493609397}} {"text": "{-# OPTIONS --without-K --safe #-}\nopen import Categories.Category\nopen import Categories.Functor hiding (id)\n\n-- category of cones \"over a Functor F\"\n\nmodule Categories.Category.Construction.Cones\n {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {J : Category o′ ℓ′ e′} (F : Functor J C) where\n\nopen import Data.Product\nimport Categories.Diagram.Cone as Co\nimport Categories.Morphism as Mor\nimport Categories.Morphism.IsoEquiv as IsoEquiv\nimport Categories.Morphism.Reasoning as Reas\n\nopen Category C\nopen HomReasoning\nopen Mor C using (_≅_)\nopen IsoEquiv C using (_≃_; ⌞_⌟)\nopen Reas C\n\nopen Co F public\nopen Apex\nopen Cone\nopen Cone⇒\n\nCones : Category _ _ _\nCones = record\n { Obj = Cone\n ; _⇒_ = Cone⇒\n ; _≈_ = λ f g → arr f ≈ arr g\n ; id = record\n { arr = id\n ; commute = identityʳ\n }\n ; _∘_ = λ {A B C} f g → record\n { arr = arr f ∘ arr g\n ; commute = λ {X} → begin\n ψ C X ∘ arr f ∘ arr g ≈⟨ pullˡ (commute f) ⟩\n ψ B X ∘ arr g ≈⟨ commute g ⟩\n ψ A X ∎\n }\n ; assoc = assoc\n ; sym-assoc = sym-assoc\n ; identityˡ = identityˡ\n ; identityʳ = identityʳ\n ; identity² = identity²\n ; equiv = record\n { refl = refl\n ; sym = sym\n ; trans = trans\n }\n ; ∘-resp-≈ = ∘-resp-≈\n }\n\nmodule Cones = Category Cones\n\nprivate\n variable\n K K′ : Cone\n X : Obj\n module CM = Mor Cones\n module CI = IsoEquiv Cones\n\nopen CM using () renaming (_≅_ to _⇔_)\nopen CI using () renaming (_≃_ to _↮_)\n\ncone-resp-iso : ∀ (κ : Cone) → Cone.N κ ≅ X → Σ[ κ′ ∈ Cone ] κ ⇔ κ′\ncone-resp-iso {X = X} κ κ≅X = record\n { apex = record\n { ψ = λ Y → Cone.ψ κ Y ∘ to\n ; commute = λ f → pullˡ (Cone.commute κ f)\n }\n } , record\n { from = record\n { arr = from\n ; commute = cancelʳ isoˡ\n }\n ; to = record\n { arr = to\n ; commute = refl\n }\n ; iso = record\n { isoˡ = isoˡ\n ; isoʳ = isoʳ\n }\n }\n where open _≅_ κ≅X\n open Cone\n open Apex\n\niso-cone⇒iso-apex : K ⇔ K′ → N K ≅ N K′\niso-cone⇒iso-apex K⇔K′ = record\n { from = arr from\n ; to = arr to\n ; iso = record\n { isoˡ = isoˡ\n ; isoʳ = isoʳ\n }\n }\n where open _⇔_ K⇔K′\n\n\n↮⇒-≃ : ∀ {i₁ i₂ : K ⇔ K′} → i₁ ↮ i₂ → iso-cone⇒iso-apex i₁ ≃ iso-cone⇒iso-apex i₂\n↮⇒-≃ i₁↮i₂ = ⌞ from-≈ ⌟\n where open _↮_ i₁↮i₂\n\n-- -- .up-to-iso-cone-unique : ∀ L L′ → (i : proj-cone L ⇿ proj-cone L′) → up-to-iso-cone L L′ ≜ⁱ i\n-- -- up-to-iso-cone-unique L L′ i = T.up-to-iso-unique (Cones F) (terminal L) (terminal L′) i\n\n-- -- -- XXX probably not true -- what is? only the above?\n-- -- -- .up-to-iso-unique : ∀ L L′ → (i : vertex L ≅ vertex L′) → up-to-iso L L′ ≡ⁱ i\n-- -- -- up-to-iso-unique L L′ i = ≜ⁱ⇒≡ⁱ {!up-to-iso-unique-cone L L′ !}\n\n-- -- .up-to-iso-cone-invˡ : ∀ {L κ} {i : proj-cone L ⇿ κ} → up-to-iso-cone L (transport-by-iso-cone L i) ≜ⁱ i\n-- -- up-to-iso-cone-invˡ {L} {i = i} = up-to-iso-cone-unique L (transport-by-iso-cone L i) i\n\n-- -- .up-to-iso-invˡ : ∀ {L X} {i : vertex L ≅ X} → up-to-iso L (transport-by-iso L i) ≡ⁱ i\n-- -- up-to-iso-invˡ {L₁} {i = i} = ≜ⁱ⇒≡ⁱ (up-to-iso-cone-invˡ {L₁} {i = proj₂ (cone-resp-iso (proj-cone L₁) i)})\n\n-- -- up-to-iso-cone-invʳ : ∀ {L L′} → proj-cone (transport-by-iso-cone L (up-to-iso-cone L L′)) ≜ proj-cone L′\n-- -- up-to-iso-cone-invʳ {L} {L′} = ≜-refl\n\n-- -- up-to-iso-invʳ : ∀ {L L′} → vertex (transport-by-iso L (up-to-iso L L′)) ≣ vertex L′\n-- -- up-to-iso-invʳ {t} {t′} = ≣-refl\n", "meta": {"hexsha": "1610b81697c951bee055dc1d83de3be548d10583", "size": 3445, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Construction/Cones.agda", "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Category/Construction/Cones.agda", "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Construction/Cones.agda", "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.3412698413, "max_line_length": 113, "alphanum_fraction": 0.5468795356, "num_tokens": 1456, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339756938818, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.6164651138431828}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Natural numbers represented in binary natively in Agda.\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Nat.Binary where\n\nopen import Data.Nat.Binary.Base public\nopen import Data.Nat.Binary.Properties public using (_≟_)\n\n", "meta": {"hexsha": "9b84b0102e4814c473d7725f63986e13e9c913d6", "size": 403, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/Nat/Binary.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Data/Nat/Binary.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Data/Nat/Binary.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 28.7857142857, "max_line_length": 72, "alphanum_fraction": 0.4739454094, "num_tokens": 62, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8397339596505965, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.6164650922959329}} {"text": "import Lvl\nopen import Structure.Setoid\nopen import Type\n\nmodule Automaton.Deterministic.Finite where\n\nopen import Automaton.Deterministic\nopen import Data.Boolean\nopen import Data.Boolean.Stmt\nopen import Data.List renaming (∅ to ε ; _⊰_ to _·_)\nopen import Data.List.Setoid\nopen import Data.List.Functions using (postpend ; _++_)\nopen import Data.List.Proofs\nopen import Functional\nopen import Logic.Propositional\nopen import Logic\nopen import Sets.ExtensionalPredicateSet using (PredSet ; intro ; _∈_ ; _∋_ ; ⊶ ; [∋]-binaryRelator)\nimport Structure.Function.Names as Names\nopen import Structure.Operator\nopen import Structure.Relator.Properties\nopen import Type.Size.Finite\n\nprivate variable ℓₚ ℓₛ ℓₑ₁ ℓₐ ℓₑ₂ : Lvl.Level\n\nmodule _\n {ℓₚ}\n (State : Type{ℓₛ}) ⦃ equiv-state : Equiv{ℓₑ₁}(State) ⦄\n (Alphabet : Type{ℓₐ}) ⦃ equiv-alphabet : Equiv{ℓₑ₂}(Alphabet) ⦄\n where\n\n record DFA : Type{ℓₛ Lvl.⊔ ℓₑ₁ Lvl.⊔ ℓₑ₂ Lvl.⊔ ℓₐ Lvl.⊔ Lvl.𝐒(ℓₚ)} where\n field\n ⦃ State-finite ⦄ : Finite(State)\n ⦃ Alphabet-finite ⦄ : Finite(Alphabet)\n automata : Deterministic{ℓₚ = ℓₚ}(State)(Alphabet)\n open Deterministic(automata) hiding (transitionedAutomaton ; wordTransitionedAutomaton) public\n\n transitionedAutomaton : Alphabet → DFA\n transitionedAutomaton c = record{automata = Deterministic.transitionedAutomaton(automata) c}\n\n wordTransitionedAutomaton : Word → DFA\n wordTransitionedAutomaton w = record{automata = Deterministic.wordTransitionedAutomaton(automata) w}\n\n postulate isFinal : State → Bool\n postulate isFinal-correctness : ∀{s} → IsTrue(isFinal s) ↔ (s ∈ Final)\n\n isWordAccepted : Word → Bool\n isWordAccepted(w) = isFinal(wordTransition(start)(w))\n\n pattern dfa {fin-Q} {fin-Σ} δ {δ-op} q₀ F = record{State-finite = fin-Q ; Alphabet-finite = fin-Σ ; automata = deterministic δ ⦃ δ-op ⦄ q₀ F}\n", "meta": {"hexsha": "ac426f2af553f6813c636fd6360964004826e517", "size": 1848, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Automaton/Deterministic/Finite.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Automaton/Deterministic/Finite.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Automaton/Deterministic/Finite.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.2352941176, "max_line_length": 143, "alphanum_fraction": 0.7321428571, "num_tokens": 606, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8774767778695834, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.6164538056546333}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Lists where every consecutative pair of elements is related.\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.List.Relation.Unary.Linked {a} {A : Set a} where\n\nopen import Data.List.Base using (List; []; _∷_)\nopen import Data.List.Relation.Unary.All as All using (All; []; _∷_)\nopen import Data.Product as Prod using (_,_; _×_; uncurry; <_,_>)\nopen import Function using (id; _∘_)\nopen import Level using (Level; _⊔_)\nopen import Relation.Binary as B using (Rel; _⇒_)\nopen import Relation.Binary.Construct.Intersection renaming (_∩_ to _∩ᵇ_)\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Unary as U renaming (_∩_ to _∩ᵘ_) hiding (_⇒_)\nopen import Relation.Nullary using (yes; no)\nopen import Relation.Nullary.Decidable as Dec using (map′)\nopen import Relation.Nullary.Product using (_×-dec_)\n\nprivate\n variable\n p q r ℓ : Level\n\n------------------------------------------------------------------------\n-- Definition\n\n-- Linked R xs means that every consecutative pair of elements\n-- in xs is a member of relation R.\n\ninfixr 5 _∷_\n\ndata Linked (R : Rel A ℓ) : List A → Set (a ⊔ ℓ) where\n [] : Linked R []\n [-] : ∀ {x} → Linked R (x ∷ [])\n _∷_ : ∀ {x y xs} → R x y → Linked R (y ∷ xs) → Linked R (x ∷ y ∷ xs)\n\n------------------------------------------------------------------------\n-- Operations\n\nmodule _ {R : Rel A p} {x y xs} where\n\n head : Linked R (x ∷ y ∷ xs) → R x y\n head (Rxy ∷ Rxs) = Rxy\n\n tail : Linked R (x ∷ y ∷ xs) → Linked R (y ∷ xs)\n tail (Rxy ∷ Rxs) = Rxs\n\nmodule _ {R : Rel A p} {S : Rel A q} where\n\n map : R ⇒ S → Linked R ⊆ Linked S\n map R⇒S [] = []\n map R⇒S [-] = [-]\n map R⇒S (x~xs ∷ pxs) = R⇒S x~xs ∷ map R⇒S pxs\n\nmodule _ {P : Rel A p} {Q : Rel A q} {R : Rel A r} where\n\n zipWith : P ∩ᵇ Q ⇒ R → Linked P ∩ᵘ Linked Q ⊆ Linked R\n zipWith f ([] , []) = []\n zipWith f ([-] , [-]) = [-]\n zipWith f (px ∷ pxs , qx ∷ qxs) = f (px , qx) ∷ zipWith f (pxs , qxs)\n\n unzipWith : R ⇒ P ∩ᵇ Q → Linked R ⊆ Linked P ∩ᵘ Linked Q\n unzipWith f [] = [] , []\n unzipWith f [-] = [-] , [-]\n unzipWith f (rx ∷ rxs) = Prod.zip _∷_ _∷_ (f rx) (unzipWith f rxs)\n\nmodule _ {P : Rel A p} {Q : Rel A q} where\n\n zip : Linked P ∩ᵘ Linked Q ⊆ Linked (P ∩ᵇ Q)\n zip = zipWith id\n\n unzip : Linked (P ∩ᵇ Q) ⊆ Linked P ∩ᵘ Linked Q\n unzip = unzipWith id\n\n------------------------------------------------------------------------\n-- Properties of predicates preserved by Linked\n\nmodule _ {R : Rel A ℓ} where\n\n linked? : B.Decidable R → U.Decidable (Linked R)\n linked? R? [] = yes []\n linked? R? (x ∷ []) = yes [-]\n linked? R? (x ∷ y ∷ xs) =\n map′ (uncurry _∷_) < head , tail > (R? x y ×-dec linked? R? (y ∷ xs))\n\n irrelevant : B.Irrelevant R → U.Irrelevant (Linked R)\n irrelevant irr [] [] = refl\n irrelevant irr [-] [-] = refl\n irrelevant irr (px₁ ∷ pxs₁) (px₂ ∷ pxs₂) =\n cong₂ _∷_ (irr px₁ px₂) (irrelevant irr pxs₁ pxs₂)\n\n satisfiable : U.Satisfiable (Linked R)\n satisfiable = [] , []\n", "meta": {"hexsha": "173de514b7166cf5626bd75c43b16dd514dab80f", "size": 3228, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/List/Relation/Unary/Linked.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Data/List/Relation/Unary/Linked.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Data/List/Relation/Unary/Linked.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 32.9387755102, "max_line_length": 73, "alphanum_fraction": 0.5151796778, "num_tokens": 1054, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681195338728, "lm_q2_score": 0.7185944046238981, "lm_q1q2_score": 0.616387371161804}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Functor.Duality where\n\nopen import Level\nopen import Data.Product using (Σ; _,_)\n\nopen import Categories.Category\nopen import Categories.Category.Construction.Cones as Con\nopen import Categories.Category.Construction.Cocones as Coc\nopen import Categories.Functor\nopen import Categories.Functor.Continuous\nopen import Categories.Functor.Cocontinuous\nopen import Categories.Diagram.Limit as Lim\nopen import Categories.Diagram.Colimit as Col\nopen import Categories.Diagram.Duality\nopen import Categories.Morphism.Duality as MorD\n\nprivate\n variable\n o ℓ e : Level\n C D E J : Category o ℓ e\n\nmodule _ (G : Functor C D) {J : Category o ℓ e} where\n private\n module C = Category C\n module D = Category D\n module G = Functor G\n module J = Category J\n\n coLimitPreserving⇒ColimitPreserving : ∀ {F : Functor J C} (L : Limit (Functor.op F)) →\n LimitPreserving G.op L →\n ColimitPreserving G (coLimit⇒Colimit C L)\n coLimitPreserving⇒ColimitPreserving L (L′ , iso) = coLimit⇒Colimit D L′ , op-≅⇒≅ D iso\n\n ColimitPreserving⇒coLimitPreserving : ∀ {F : Functor J C} (L : Colimit F) →\n ColimitPreserving G L →\n LimitPreserving G.op (Colimit⇒coLimit C L)\n ColimitPreserving⇒coLimitPreserving L (L′ , iso) = Colimit⇒coLimit D L′ , op-≅⇒≅ D.op iso\n\nmodule _ {o ℓ e} (G : Functor C D) where\n private\n module G = Functor G\n\n coContinuous⇒Cocontinuous : Continuous o ℓ e G.op → Cocontinuous o ℓ e G\n coContinuous⇒Cocontinuous Con L =\n coLimitPreserving⇒ColimitPreserving G (Colimit⇒coLimit C L) (Con (Colimit⇒coLimit C L))\n\n Cocontinuous⇒coContinuous : Cocontinuous o ℓ e G → Continuous o ℓ e G.op\n Cocontinuous⇒coContinuous Coc L =\n ColimitPreserving⇒coLimitPreserving G (coLimit⇒Colimit C L) (Coc (coLimit⇒Colimit C L))\n", "meta": {"hexsha": "495c876bc556ea466abc9f53c8264398b5afd8b0", "size": 1952, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Functor/Duality.agda", "max_stars_repo_name": "laMudri/agda-categories", "max_stars_repo_head_hexsha": "5a49c6ac87cbb7e20511c28f28205163fe69f48f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Functor/Duality.agda", "max_issues_repo_name": "laMudri/agda-categories", "max_issues_repo_head_hexsha": "5a49c6ac87cbb7e20511c28f28205163fe69f48f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Functor/Duality.agda", "max_forks_repo_name": "laMudri/agda-categories", "max_forks_repo_head_hexsha": "5a49c6ac87cbb7e20511c28f28205163fe69f48f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.5384615385, "max_line_length": 91, "alphanum_fraction": 0.6772540984, "num_tokens": 578, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681049901037, "lm_q2_score": 0.7185944046238982, "lm_q1q2_score": 0.616387360710733}} {"text": "------------------------------------------------------------------------\n-- INCREMENTAL λ-CALCULUS\n--\n-- Bags of integers, for Nehemiah plugin.\n--\n-- This module imports postulates about bags of integers\n-- with negative multiplicities as a group under additive union.\n------------------------------------------------------------------------\n\nmodule Structure.Bag.Nehemiah where\n\nopen import Postulate.Bag-Nehemiah public\n\nopen import Relation.Binary.PropositionalEquality\nopen import Algebra using (CommutativeRing)\nopen import Algebra.Structures\nopen import Data.Integer\nopen import Data.Integer.Properties\n using ()\n renaming (+-*-commutativeRing to ℤ-is-commutativeRing)\nopen import Data.Product\n\ninfixl 9 _\\\\_ -- same as Data.Map.(\\\\)\n_\\\\_ : Bag → Bag → Bag\nd \\\\ b = d ++ (negateBag b)\n\n-- Useful properties of abelian groups\ncommutative : ∀ {A : Set} {f : A → A → A} {z} →\n IsCommutativeMonoid _≡_ f z → (m n : A) → f m n ≡ f n m\ncommutative = IsCommutativeMonoid.comm\n\nassociative : ∀ {A : Set} {f : A → A → A} {z} →\n IsCommutativeMonoid _≡_ f z → (k m n : A) → f (f k m) n ≡ f k (f m n)\nassociative abelian = IsCommutativeMonoid.assoc abelian\n\nleft-inverse : ∀ {A : Set} {f : A → A → A} {z neg} →\n IsAbelianGroup _≡_ f z neg → (n : A) → f (neg n) n ≡ z\nleft-inverse abelian = proj₁ (IsAbelianGroup.inverse abelian)\nright-inverse : ∀ {A : Set} {f : A → A → A} {z neg} →\n IsAbelianGroup _≡_ f z neg → (n : A) → f n (neg n) ≡ z\nright-inverse abelian = proj₂ (IsAbelianGroup.inverse abelian)\n\nleft-identity : ∀ {A : Set} {f : A → A → A} {z neg} →\n IsAbelianGroup _≡_ f z neg → (n : A) → f z n ≡ n\nleft-identity abelian = proj₁ (IsMonoid.identity\n (IsGroup.isMonoid (IsAbelianGroup.isGroup abelian)))\nright-identity : ∀ {A : Set} {f : A → A → A} {z neg} →\n IsAbelianGroup _≡_ f z neg → (n : A) → f n z ≡ n\nright-identity abelian = proj₂ (IsMonoid.identity\n (IsGroup.isMonoid (IsAbelianGroup.isGroup abelian)))\n\ninstance\n abelian-int : IsAbelianGroup _≡_ _+_ (+ 0) (-_)\n abelian-int =\n CommutativeRing.+-isAbelianGroup ℤ-is-commutativeRing\n\n abelian→comm-monoid :\n ∀ {A : Set} {f : A → A → A} {z neg} →\n {{abel : IsAbelianGroup _≡_ f z neg}} → IsCommutativeMonoid _≡_ f z\n abelian→comm-monoid {{abel}} = IsAbelianGroup.isCommutativeMonoid abel\n\n comm-monoid-int : IsCommutativeMonoid _≡_ _+_ (+ 0)\n comm-monoid-int = IsAbelianGroup.isCommutativeMonoid abelian-int\n comm-monoid-bag : IsCommutativeMonoid _≡_ _++_ emptyBag\n comm-monoid-bag = IsAbelianGroup.isCommutativeMonoid abelian-bag\n\n import Data.Nat as N\n import Data.Nat.Properties as NP\n comm-monoid-nat : IsCommutativeMonoid _≡_ N._+_ 0\n comm-monoid-nat = IsCommutativeSemiring.+-isCommutativeMonoid NP.isCommutativeSemiring\n\ncommutative-int : (m n : ℤ) → m + n ≡ n + m\ncommutative-int = commutative comm-monoid-int\nassociative-int : (k m n : ℤ) → (k + m) + n ≡ k + (m + n)\nassociative-int = associative comm-monoid-int\nright-inv-int : (n : ℤ) → n - n ≡ + 0\nright-inv-int = right-inverse abelian-int\nleft-id-int : (n : ℤ) → (+ 0) + n ≡ n\nleft-id-int = left-identity abelian-int\nright-id-int : (n : ℤ) → n + (+ 0) ≡ n\nright-id-int = right-identity abelian-int\n\ncommutative-bag : (a b : Bag) → a ++ b ≡ b ++ a\ncommutative-bag = commutative comm-monoid-bag\nassociative-bag : (a b c : Bag) → (a ++ b) ++ c ≡ a ++ (b ++ c)\nassociative-bag = associative comm-monoid-bag\nright-inv-bag : (b : Bag) → b \\\\ b ≡ emptyBag\nright-inv-bag = right-inverse abelian-bag\nleft-id-bag : (b : Bag) → emptyBag ++ b ≡ b\nleft-id-bag = left-identity abelian-bag\nright-id-bag : (b : Bag) → b ++ emptyBag ≡ b\nright-id-bag = right-identity abelian-bag\n", "meta": {"hexsha": "0ba86bf0e345499cf3caf1883fb0485859edbb68", "size": 3612, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Bag/Nehemiah.agda", "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_issues_repo_path": "Structure/Bag/Nehemiah.agda", "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_forks_repo_path": "Structure/Bag/Nehemiah.agda", "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "avg_line_length": 38.8387096774, "max_line_length": 88, "alphanum_fraction": 0.6456256921, "num_tokens": 1250, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577680977182187, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.6163873399771246}} {"text": "postulate\n A : Set\n\ndata B (a : A) : Set where\n conB : B a → B a\n\ndata C (a : A) : B a → Set where\n conC : (b : B a) → C a (conB b)\n\ngoo : (a1 a2 a3 : A) (c : C a1 _) → Set\ngoo a1 a2 a3 (conC b) = {!!}\n", "meta": {"hexsha": "eb185f26a5d4682896c1bf4f3c1568962a62ae92", "size": 205, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/Issue2679c.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Fail/Issue2679c.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Fail/Issue2679c.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 17.0833333333, "max_line_length": 39, "alphanum_fraction": 0.4829268293, "num_tokens": 98, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.86153820232079, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.6163650979970416}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import lib.Basics\nopen import lib.NType2\nopen import lib.types.Group\nopen import lib.types.Sigma\nopen import lib.types.Truncation\nopen import lib.groups.Homomorphisms\n\nmodule lib.groups.PropSubgroup where\n\nmodule _ {i} (G : Group i) where\n\n private\n module G = Group G\n\n module PropSubgroup {j} (P : G.El → Type j)\n (P-level : ∀ g → has-level -1 (P g))\n (P-ident : P G.ident) (P-inv : ∀ {g} → P g → P (G.inv g))\n (P-comp : ∀ {g₁ g₂} → P g₁ → P g₂ → P (G.comp g₁ g₂)) where\n\n struct : GroupStructure (Σ G.El P)\n struct = record {\n ident = (G.ident , P-ident);\n inv = λ {(g , p) → (G.inv g , P-inv p)};\n comp = λ {(g₁ , p₁) (g₂ , p₂) → (G.comp g₁ g₂ , P-comp p₁ p₂)};\n unitl = λ {(g , _) →\n pair= (G.unitl g) (prop-has-all-paths-↓ (P-level _))};\n unitr = λ {(g , _) →\n pair= (G.unitr g) (prop-has-all-paths-↓ (P-level _))};\n assoc = λ {(g₁ , _) (g₂ , _) (g₃ , _) →\n pair= (G.assoc g₁ g₂ g₃) (prop-has-all-paths-↓ (P-level _))};\n invl = λ {(g , _) →\n pair= (G.invl g) (prop-has-all-paths-↓ (P-level _))};\n invr = λ {(g , _) →\n pair= (G.invr g) (prop-has-all-paths-↓ (P-level _))}}\n\n Subgroup : Group (lmax i j)\n Subgroup = group _ (Σ-level G.El-level (raise-level _ ∘ P-level)) struct\n\n inj : Subgroup →ᴳ G\n inj = record {\n f = λ {(g , _) → g};\n pres-comp = λ _ _ → idp}\n\n module _ {j} {H : Group j} (φ : H →ᴳ G) where\n\n private\n module H = Group H\n module φ = GroupHom φ\n\n prop-hom : Π H.El (P ∘ φ.f) → (H →ᴳ Subgroup)\n prop-hom p = record {\n f = λ g → (φ.f g , p g);\n pres-comp = λ g₁ g₂ →\n pair= (φ.pres-comp g₁ g₂) (prop-has-all-paths-↓ (P-level _))}\n\nmodule _ {i} {j} {G : Group i} {H : Group j} (φ : G →ᴳ H) where\n\n private\n module G = Group G\n module H = Group H\n module φ = GroupHom φ\n\n module Ker = PropSubgroup G (λ g → φ.f g == H.ident)\n (λ g → H.El-level _ _) φ.pres-ident\n (λ p → φ.pres-inv _ ∙ ap H.inv p ∙ group-inv-ident H)\n (λ p₁ p₂ → φ.pres-comp _ _ ∙ ap2 H.comp p₁ p₂ ∙ H.unitl _)\n\n module Im = PropSubgroup H (λ h → Trunc -1 (Σ G.El (λ g → φ.f g == h)))\n (λ h → Trunc-level) ([ G.ident , φ.pres-ident ])\n (Trunc-fmap (λ {(g , p) →\n (G.inv g , φ.pres-inv g ∙ ap H.inv p)}))\n (Trunc-fmap2 (λ {(g₁ , p₁) (g₂ , p₂) →\n (G.comp g₁ g₂ , φ.pres-comp g₁ g₂ ∙ ap2 H.comp p₁ p₂)}))\n\n open Ker public renaming\n (struct to ker-struct; Subgroup to Ker;\n inj to ker-inj; prop-hom to ker-hom)\n\n\n open Im public renaming\n (struct to im-struct; Subgroup to Im;\n inj to im-inj; prop-hom to im-out-hom)\n\n im-in-hom : G →ᴳ Im\n im-in-hom = record {\n f = λ g → (φ.f g , [ g , idp ]);\n pres-comp = λ g₁ g₂ →\n pair= (φ.pres-comp g₁ g₂) (prop-has-all-paths-↓ Trunc-level)}\n\n im-in-surj : (h : Group.El Im)\n → Trunc -1 (Σ G.El (λ g → GroupHom.f im-in-hom g == h))\n im-in-surj (_ , s) = Trunc-fmap (λ {(g , p) →\n (g , pair= p (prop-has-all-paths-↓ Trunc-level))}) s\n", "meta": {"hexsha": "f61360ad081b4a59d2a0ed5c871a167ab09698c1", "size": 3058, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/groups/PropSubgroup.agda", "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "core/lib/groups/PropSubgroup.agda", "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "core/lib/groups/PropSubgroup.agda", "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.8541666667, "max_line_length": 76, "alphanum_fraction": 0.5281229562, "num_tokens": 1147, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382094310357, "lm_q2_score": 0.7154239836484143, "lm_q1q2_score": 0.6163650978564734}} {"text": "-- Intuitionistic propositional logic, de Bruijn approach, final encoding\n\nmodule Bf.Ip where\n\nopen import Lib using (List; _,_; LMem; lzero; lsuc)\n\n\n-- Types\n\ninfixl 2 _&&_\ninfixl 1 _||_\ninfixr 0 _=>_\ndata Ty : Set where\n UNIT : Ty\n _=>_ : Ty -> Ty -> Ty\n _&&_ : Ty -> Ty -> Ty\n _||_ : Ty -> Ty -> Ty\n FALSE : Ty\n\ninfixr 0 _<=>_\n_<=>_ : Ty -> Ty -> Ty\na <=> b = (a => b) && (b => a)\n\nNOT : Ty -> Ty\nNOT a = a => FALSE\n\nTRUE : Ty\nTRUE = FALSE => FALSE\n\n\n-- Context and truth judgement\n\nCx : Set\nCx = List Ty\n\nisTrue : Ty -> Cx -> Set\nisTrue a tc = LMem a tc\n\n\n-- Terms\n\nTmRepr : Set1\nTmRepr = Cx -> Ty -> Set\n\nmodule ArrMp where\n record Tm (tr : TmRepr) : Set1 where\n infixl 1 _$_\n infixr 0 lam=>_\n field\n var : forall {tc a} -> isTrue a tc -> tr tc a\n lam=>_ : forall {tc a b} -> tr (tc , a) b -> tr tc (a => b)\n _$_ : forall {tc a b} -> tr tc (a => b) -> tr tc a -> tr tc b\n\n v0 : forall {tc a} -> tr (tc , a) a\n v0 = var lzero\n\n v1 : forall {tc a b} -> tr (tc , a , b) a\n v1 = var (lsuc lzero)\n\n v2 : forall {tc a b c} -> tr (tc , a , b , c) a\n v2 = var (lsuc (lsuc lzero))\n open Tm {{...}} public\n\nmodule Mp where\n record Tm (tr : TmRepr) : Set1 where\n field\n pair' : forall {tc a b} -> tr tc a -> tr tc b -> tr tc (a && b)\n fst : forall {tc a b} -> tr tc (a && b) -> tr tc a\n snd : forall {tc a b} -> tr tc (a && b) -> tr tc b\n left : forall {tc a b} -> tr tc a -> tr tc (a || b)\n right : forall {tc a b} -> tr tc b -> tr tc (a || b)\n case' : forall {tc a b c} -> tr tc (a || b) -> tr (tc , a) c -> tr (tc , b) c -> tr tc c\n\n isArrMp : ArrMp.Tm tr\n open ArrMp.Tm isArrMp public\n\n syntax pair' x y = [ x , y ]\n syntax case' xy x y = case xy => x => y\n open Tm {{...}} public\n\nmodule Ip where\n record Tm (tr : TmRepr) : Set1 where\n field\n abort : forall {tc a} -> tr tc FALSE -> tr tc a\n\n isMp : Mp.Tm tr\n open Mp.Tm isMp public\n open Tm {{...}} public\n\n Thm : Ty -> Set1\n Thm a = forall {tr tc} {{_ : Tm tr}} -> tr tc a\nopen Ip public\n\n\n-- Example theorems\n\nt1 : forall {a b} -> Thm (a => NOT a => b)\nt1 =\n lam=>\n lam=> abort (v0 $ v1)\n\nt2 : forall {a b} -> Thm (NOT a => a => b)\nt2 =\n lam=>\n lam=> abort (v1 $ v0)\n\nt3 : forall {a} -> Thm (a => NOT (NOT a))\nt3 =\n lam=>\n lam=> v0 $ v1\n\nt4 : forall {a} -> Thm (NOT a <=> NOT (NOT (NOT a)))\nt4 =\n [ lam=>\n lam=> v0 $ v1\n , lam=>\n lam=> v1 $ (lam=> v0 $ v1)\n ]\n", "meta": {"hexsha": "39ab03b9e8d049b3e7158a5936781b2fb9ee678c", "size": 2600, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Bf/Ip.agda", "max_stars_repo_name": "mietek/formal-logic", "max_stars_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_stars_repo_licenses": ["X11"], "max_stars_count": 26, "max_stars_repo_stars_event_min_datetime": "2015-08-31T09:49:52.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-13T12:37:44.000Z", "max_issues_repo_path": "src/Bf/Ip.agda", "max_issues_repo_name": "mietek/formal-logic", "max_issues_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_issues_repo_licenses": ["X11"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Bf/Ip.agda", "max_forks_repo_name": "mietek/formal-logic", "max_forks_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_forks_repo_licenses": ["X11"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.8487394958, "max_line_length": 94, "alphanum_fraction": 0.4742307692, "num_tokens": 987, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314677809303, "lm_q2_score": 0.6959583376458153, "lm_q1q2_score": 0.6163626040836396}} {"text": "{-# OPTIONS --enable-prop #-}\n\ndata _≡P_ {A : Set} (x : A) : A → Prop where\n refl : x ≡P x\n\nJ-P : {A : Set} (x : A) (P : (y : A) → x ≡P y → Set)\n → P x refl → (y : A) (e : x ≡P y) → P y e\nJ-P x P p .x refl = p\n", "meta": {"hexsha": "ae1ed31848b14ee0dc2a26f9d3fc683a1419ef5b", "size": 214, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/Prop-EqNoEliminator.agda", "max_stars_repo_name": "asr/eagda", "max_stars_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_issues_repo_path": "test/Fail/Prop-EqNoEliminator.agda", "max_issues_repo_name": "asr/eagda", "max_issues_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Fail/Prop-EqNoEliminator.agda", "max_forks_repo_name": "asr/eagda", "max_forks_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 23.7777777778, "max_line_length": 52, "alphanum_fraction": 0.4205607477, "num_tokens": 103, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8856314738181876, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.6163626027003666}} {"text": "\nmodule _ where\n\nid : {A : Set} → A → A\nid x = x\n\nconst : {A : Set₁} {B : Set} → A → (B → A)\nconst x = λ _ → x\n\n{-# DISPLAY const x y = x #-}\n\ninfixr 4 _,_\ninfixr 2 _×_\n\nrecord Σ (A : Set) (B : A → Set) : Set where\n constructor _,_\n field\n proj₁ : A\n proj₂ : B proj₁\n\nopen Σ public\n\n_×_ : (A B : Set) → Set\nA × B = Σ A (const B)\n\nΣ-map : ∀ {A B : Set} {P : A → Set} {Q : B → Set} →\n (f : A → B) → (∀ {x} → P x → Q (f x)) →\n Σ A P → Σ B Q\nΣ-map f g = λ p → (f (proj₁ p) , g (proj₂ p))\n\nfoo : {A B : Set} → A × B → A × B\nfoo = Σ-map id {!!}\n", "meta": {"hexsha": "609de0dafd419061710a51ef71ae7a0521e71ce3", "size": 561, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue1873.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/interaction/Issue1873.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/interaction/Issue1873.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 17.0, "max_line_length": 51, "alphanum_fraction": 0.4456327986, "num_tokens": 254, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314738181874, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.6163626027003664}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Dodo.Binary.Disjoint where\n\n-- Stdlib imports\nopen import Level using (Level; _⊔_) renaming (suc to ℓsuc)\nopen import Data.Empty using (⊥)\nopen import Data.Product using (_,_)\nopen import Relation.Unary using (Pred)\nopen import Relation.Binary using (REL)\nopen import Data.List using (List; _∷_; []; all; map)\nopen import Data.List.Relation.Unary.Any using (Any; here; there)\nopen import Relation.Nullary using (¬_)\n-- Local imports\nopen import Dodo.Binary.Empty\nopen import Dodo.Binary.Equality\nopen import Dodo.Binary.Intersection\n\n\n-- # Definitions\n\n-- | Predicate stating two binary relations are never inhabited for the same elements.\nDisjoint₂ : ∀ {a b ℓ₁ ℓ₂ : Level} {A : Set a} {B : Set b}\n → REL A B ℓ₁ → REL A B ℓ₂ → Set _\nDisjoint₂ P Q = Empty₂ (P ∩₂ Q)\n\n-- | Given a predicate `P`, `Any₂ P xs` states that /at least two/ elements in\n-- `xs` satisfy `P`.\ndata Any₂ {a ℓ : Level} {A : Set a} (P : Pred A ℓ) : Pred (List A) (a ⊔ ℓ) where\n here : ∀ {x xs} (px : P x) → Any P xs → Any₂ P (x ∷ xs)\n there : ∀ {x xs} (pxs : Any₂ P xs) → Any₂ P (x ∷ xs)\n\n-- | A predicate stating any two predicates in the list cannot be inhabitated for the same elements.\nPairwiseDisjoint₁ : {a ℓ : Level} {A : Set a} → List (Pred A ℓ) → Set (a ⊔ ℓsuc ℓ)\nPairwiseDisjoint₁ Ps = ∀ {x} → Any₂ (λ{P → P x}) Ps → ⊥\n\n-- | A predicate stating any two binary relations in the list cannot be inhabitated for the same elements.\nPairwiseDisjoint₂ : {a b ℓ : Level} {A : Set a} {B : Set b} → List (REL A B ℓ) → Set (a ⊔ b ⊔ ℓsuc ℓ)\nPairwiseDisjoint₂ Rs = ∀ {x y} → Any₂ (λ{R → R x y}) Rs → ⊥\n\n\n-- # Properties\n\nmodule _ {a b ℓ₁ ℓ₂ : Level} {A : Set a} {B : Set b} {P : REL A B ℓ₁} {Q : REL A B ℓ₂} where\n\n -- | If P is disjoint with Q, then Q is surely also disjoint with P.\n disjoint₂-sym : Disjoint₂ P Q → Disjoint₂ Q P\n disjoint₂-sym disjointPQ x y [Q∩P]xy =\n let [P∩Q]xy = ⇔₂-apply-⊆₂ (∩₂-comm {P = Q} {Q = P}) [Q∩P]xy\n in disjointPQ x y [P∩Q]xy\n\n\nmodule _ {a b ℓ : Level} {A : Set a} {B : Set b} {P : REL A B ℓ} where\n\n -- | Every relation is disjoint with its negation.\n disjoint₂-neg : Disjoint₂ P (¬₂ P)\n disjoint₂-neg x y (Pxy , ¬Pxy) = ¬Pxy Pxy\n\n\nmodule _ {a b ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {B : Set b} {P : REL A B ℓ₁} {Q : REL A B ℓ₂} {R : REL A B ℓ₃} where\n\n -- | If two relations P and Q are disjoint, then any subset R of P is also disjoint with Q.\n disjoint₂-⊆ˡ : R ⊆₂ P → Disjoint₂ P Q → Disjoint₂ R Q\n disjoint₂-⊆ˡ R⊆P disjointPQ x y [R∩Q]xy = disjointPQ x y (⊆₂-apply (∩₂-substˡ-⊆₂ {R = Q} R⊆P) [R∩Q]xy)\n\n -- | If two relations P and Q are disjoint, then any subset R of Q is also disjoint with P.\n disjoint₂-⊆ʳ : R ⊆₂ Q → Disjoint₂ P Q → Disjoint₂ P R\n disjoint₂-⊆ʳ R⊆Q disjointPQ x y [P∩R]xy = disjointPQ x y (⊆₂-apply (∩₂-substʳ-⊆₂ {R = P} R⊆Q) [P∩R]xy)\n", "meta": {"hexsha": "3b7d002837fa4a411055d6f058efba8d58e87976", "size": 2818, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Dodo/Binary/Disjoint.agda", "max_stars_repo_name": "sourcedennis/agda-dodo", "max_stars_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Dodo/Binary/Disjoint.agda", "max_issues_repo_name": "sourcedennis/agda-dodo", "max_issues_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Dodo/Binary/Disjoint.agda", "max_forks_repo_name": "sourcedennis/agda-dodo", "max_forks_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.8405797101, "max_line_length": 112, "alphanum_fraction": 0.6359119943, "num_tokens": 1097, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314647623016, "lm_q2_score": 0.6959583376458152, "lm_q1q2_score": 0.6163626019827998}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Rose trees\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe --sized-types #-}\n\nmodule Data.Tree.Rose where\n\nopen import Level using (Level)\nopen import Size\nopen import Data.List.Base as List using (List; []; _∷_)\nopen import Data.Nat.Base as ℕ using (ℕ; zero; suc)\nimport Data.Nat.Properties as ℕₚ\nopen import Data.List.Extrema.Nat\nopen import Function.Base using (_∘_)\n\nprivate\n variable\n a b : Level\n A : Set a\n B : Set b\n i : Size\n\n------------------------------------------------------------------------\n-- Type and basic constructions\n\ndata Rose (A : Set a) : Size → Set a where\n node : (a : A) (ts : List (Rose A i)) → Rose A (↑ i)\n\nleaf : A → Rose A ∞\nleaf a = node a []\n\n------------------------------------------------------------------------\n-- Transforming rose trees\n\nmap : (A → B) → Rose A i → Rose B i\nmap f (node a ts) = node (f a) (List.map (map f) ts)\n\n------------------------------------------------------------------------\n-- Reducing rose trees\n\nfoldr : (A → List B → B) → Rose A i → B\nfoldr n (node a ts) = n a (List.map (foldr n) ts)\n\ndepth : Rose A i → ℕ\ndepth (node a ts) = suc (max 0 (List.map depth ts))\n", "meta": {"hexsha": "c3bc5f2ee857ba23af44d59f510b42c950a50506", "size": 1310, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/Tree/Rose.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Data/Tree/Rose.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Data/Tree/Rose.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 26.7346938776, "max_line_length": 72, "alphanum_fraction": 0.4526717557, "num_tokens": 318, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.853912760387131, "lm_q2_score": 0.7217431943271999, "lm_q1q2_score": 0.6163057233585648}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nmodule Cubical.Algebra.Group.Semidirect where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Structure\nopen import Cubical.Algebra.Group.Base\nopen import Cubical.Algebra.Group.Morphism\nopen import Cubical.Algebra.Group.Notation\nopen import Cubical.Algebra.Group.MorphismProperties\nopen import Cubical.Algebra.Group.Action\nopen import Cubical.Data.Sigma\n\nprivate\n variable\n ℓ ℓ' : Level\n\nmodule _ where\n\n semidirectProd : (G : Group {ℓ}) (H : Group {ℓ'}) (Act : GroupAction H G) → Group {ℓ-max ℓ ℓ'}\n semidirectProd G H Act = makeGroup-left {A = sd-carrier} sd-0 _+sd_ -sd_ sd-set sd-assoc sd-lId sd-lCancel\n where\n open ActionNotationα Act\n open ActionLemmas Act\n open GroupNotationG G\n open GroupNotationᴴ H\n -- sd stands for semidirect\n sd-carrier = ⟨ G ⟩ × ⟨ H ⟩\n sd-0 = 0ᴳ , 0ᴴ\n\n module _ ((g , h) : sd-carrier) where\n -sd_ = (-ᴴ h) α (-ᴳ g) , -ᴴ h\n\n _+sd_ = λ (g' , h') → g +ᴳ (h α g') , h +ᴴ h'\n\n abstract\n sd-set = isSetΣ setᴳ (λ _ → setᴴ)\n sd-lId = λ ((g , h) : sd-carrier) → ΣPathP (lIdᴳ (0ᴴ α g) ∙ (α-id g) , lIdᴴ h)\n sd-lCancel = λ ((g , h) : sd-carrier) → ΣPathP ((sym (α-hom (-ᴴ h) (-ᴳ g) g) ∙∙ cong ((-ᴴ h) α_) (lCancelᴳ g) ∙∙ actOnUnit (-ᴴ h)) , lCancelᴴ h)\n\n\n sd-assoc = λ (a , x) (b , y) (c , z) → ΣPathP ((a +ᴳ (x α (b +ᴳ (y α c)))\n ≡⟨ cong (a +ᴳ_) (α-hom x b (y α c)) ⟩\n a +ᴳ ((x α b) +ᴳ (x α (y α c)))\n ≡⟨ assocᴳ a (x α b) (x α (y α c)) ⟩\n (a +ᴳ (x α b)) +ᴳ (x α (y α c))\n ≡⟨ cong ((a +ᴳ (x α b)) +ᴳ_) (sym (α-assoc x y c)) ⟩\n (a +ᴳ (x α b)) +ᴳ ((x +ᴴ y) α c) ∎) , assocᴴ x y z)\n\n -- this syntax declaration is the reason we can't unify semidirectProd with\n -- the projections module\n syntax semidirectProd G H α = G ⋊⟨ α ⟩ H\n\nmodule _ {G : Group {ℓ}} {H : Group {ℓ'}} (Act : GroupAction H G) where\n open ActionNotationα Act\n open ActionLemmas Act\n open GroupNotationG G\n open GroupNotationᴴ H\n\n π₁ : ⟨ G ⋊⟨ Act ⟩ H ⟩ → ⟨ G ⟩\n π₁ = fst\n\n ι₁ : GroupHom G (G ⋊⟨ Act ⟩ H)\n ι₁ = grouphom (λ g → g , 0ᴴ) λ g g' → ΣPathP (cong (g +ᴳ_) (sym (α-id g')), sym (lIdᴴ 0ᴴ))\n\n π₂ : GroupHom (G ⋊⟨ Act ⟩ H) H\n -- π₂ = grouphom snd λ _ _ → refl\n π₂ = grouphom snd λ (g , h) (g' , h') → refl {x = h +ᴴ h'}\n\n ι₂ : GroupHom H (G ⋊⟨ Act ⟩ H)\n ι₂ = grouphom (λ h → 0ᴳ , h) λ h h' → ΣPathP (sym (actOnUnit h) ∙ sym (lIdᴳ (h α 0ᴳ)) , refl)\n\n π₂-hasSec : isGroupSplitEpi ι₂ π₂\n π₂-hasSec = GroupMorphismExt (λ _ → refl)\n", "meta": {"hexsha": "3ecaecf6262036d2db2e79ab7e10f4c9b51b48fe", "size": 2748, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Group/Semidirect.agda", "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Group/Semidirect.agda", "max_issues_repo_name": "Schippmunk/cubical", "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Group/Semidirect.agda", "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.1578947368, "max_line_length": 152, "alphanum_fraction": 0.5429403202, "num_tokens": 1136, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8652240930029118, "lm_q2_score": 0.7122321781307375, "lm_q1q2_score": 0.6162404403306556}} {"text": "{-\n Copyright 2019 Lisandra Silva\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n-}\n\nopen import Prelude\nopen import Relation.Binary.HeterogeneousEquality\n using (_≅_)\n renaming (cong to ≅-cong; refl to ≅-refl)\n\nopen import StateMachineModel\n\nmodule Examples.SMCounter where\n\n data MyEvent : Set where\n inc : MyEvent\n inc2 : MyEvent\n\n data MyEnabled : MyEvent → ℕ → Set where\n tt : ∀ {e} {n} → MyEnabled e n\n\n\n MyEventSet : EventSet {Event = MyEvent}\n MyEventSet inc = ⊤\n MyEventSet inc2 = ⊤\n\n\n MyAction : {preSt : ℕ} {ev : MyEvent} → MyEnabled ev preSt → ℕ\n MyAction {preSt} {inc} enEv = suc preSt\n MyAction {preSt} {inc2} enEv = suc (suc preSt)\n\n\n data MyWeakFairness : EventSet → Set where\n w0 : MyWeakFairness MyEventSet\n\n -- Another way of modelling the WeakFairness\n MyWeakFairness2 : EventSet {Event = MyEvent} → Set\n MyWeakFairness2 MyEventSet = ⊤\n\n\n MyStateMachine : StateMachine ℕ MyEvent\n MyStateMachine = record { initial = 2 ≡_\n ; enabled = MyEnabled\n ; action = MyAction }\n\n mySystem : System ℕ MyEvent\n mySystem = record { stateMachine = MyStateMachine\n ; weakFairness = MyWeakFairness }\n\n myInvariant : Invariant MyStateMachine (2 ≤_)\n myInvariant (init x) = ≤-reflexive x\n myInvariant (step {ps} {inc} rs enEv) = ≤-stepsˡ 1 (myInvariant rs)\n myInvariant (step {ps} {inc2} rs enEv) = ≤-stepsˡ 2 (myInvariant rs)\n\n\n open LeadsTo ℕ MyEvent mySystem\n\n\n -- A state equals to n leads to a state equals to (1 + n) or equals to (2 + n)\n progressDumb : ∀ {n : ℕ} → (n ≡_) l-t ((1 + n ≡_) ∪ (2 + n ≡_))\n progressDumb = viaEvSet MyEventSet w0\n ( λ { inc ⊤ → hoare λ { refl enEv → inj₁ refl}\n ; inc2 ⊤ → hoare λ { refl enEv → inj₂ refl} })\n ( λ { inc ⊥ → ⊥-elim (⊥ tt)\n ; inc2 ⊥ → ⊥-elim (⊥ tt)} )\n λ rs n≡s → inc , tt , tt\n\n n Ty -> Ty\n\ndata Tm : Ty -> Set where\n K : {σ τ : Ty} -> Tm (σ ⟶ τ ⟶ σ)\n S : {σ τ ρ : Ty} -> Tm ((σ ⟶ τ ⟶ ρ) ⟶ (σ ⟶ τ) ⟶ σ ⟶ ρ)\n _$_ : {σ τ : Ty} -> Tm (σ ⟶ τ) -> Tm σ -> Tm τ\n\ndata Nf : Ty -> Set where\n Kⁿ : {σ τ : Ty} -> Nf (σ ⟶ τ ⟶ σ)\n Kⁿ¹ : {σ τ : Ty} -> Nf σ -> Nf (τ ⟶ σ)\n Sⁿ : {σ τ ρ : Ty} -> Nf ((σ ⟶ τ ⟶ ρ) ⟶ (σ ⟶ τ) ⟶ σ ⟶ ρ)\n Sⁿ¹ : {σ τ ρ : Ty} -> Nf (σ ⟶ τ ⟶ ρ) -> Nf ((σ ⟶ τ) ⟶ σ ⟶ ρ)\n Sⁿ² : {σ τ ρ : Ty} -> Nf (σ ⟶ τ ⟶ ρ) -> Nf (σ ⟶ τ) -> Nf (σ ⟶ ρ)\n\n_$$_ : {σ τ : Ty} -> Nf (σ ⟶ τ) -> Nf σ -> Nf τ\nKⁿ $$ x = Kⁿ¹ x\nKⁿ¹ x $$ y = x\nSⁿ $$ x = Sⁿ¹ x\nSⁿ¹ x $$ y = Sⁿ² x y\nSⁿ² x y $$ z = (x $$ z) $$ (y $$ z)\n\nnf : {σ : Ty} -> Tm σ -> Nf σ\nnf K = Kⁿ\nnf S = Sⁿ\nnf (t $ u) = nf t $$ nf u\n\ndata _$ⁿ_⇓_ : {σ τ : Ty} -> Nf (σ ⟶ τ) -> Nf σ -> Nf τ -> Set where\n rKⁿ : {σ τ : Ty} -> {x : Nf σ} -> Kⁿ {σ} {τ} $ⁿ x ⇓ Kⁿ¹ x\n rKⁿ¹ : {σ τ : Ty} -> {x : Nf σ} -> {y : Nf τ} -> Kⁿ¹ x $ⁿ y ⇓ x\n rSⁿ : {σ τ ρ : Ty} -> {x : Nf (σ ⟶ τ ⟶ ρ)} -> Sⁿ $ⁿ x ⇓ Sⁿ¹ x\n rSⁿ¹ : {σ τ ρ : Ty} -> {x : Nf (σ ⟶ τ ⟶ ρ)} -> {y : Nf (σ ⟶ τ)} ->\n Sⁿ¹ x $ⁿ y ⇓ Sⁿ² x y\n rSⁿ² : {σ τ ρ : Ty} -> {x : Nf (σ ⟶ τ ⟶ ρ)} -> {y : Nf (σ ⟶ τ)} ->\n {z : Nf σ} -> {u : Nf (τ ⟶ ρ)} -> x $ⁿ z ⇓ u -> {v : Nf τ} ->\n y $ⁿ z ⇓ v -> {w : Nf ρ} -> u $ⁿ v ⇓ w -> Sⁿ² x y $ⁿ z ⇓ w\n\ndata _⇓_ : {σ : Ty} -> Tm σ -> Nf σ -> Set where\n rK : {σ τ : Ty} -> K {σ} {τ} ⇓ Kⁿ\n rS : {σ τ ρ : Ty} -> S {σ} {τ} {ρ} ⇓ Sⁿ\n r$ : {σ τ : Ty} -> {t : Tm (σ ⟶ τ)} -> {f : Nf (σ ⟶ τ)} -> t ⇓ f ->\n {u : Tm σ} -> {a : Nf σ} -> u ⇓ a -> {v : Nf τ} -> f $ⁿ a ⇓ v ->\n t $ u ⇓ v\n\ndata _==_ {A : Set}(a : A) : {B : Set} -> (b : B) -> Set where\n refl : a == a\n\ndata Σ {A : Set}(B : A -> Set) : Set where\n sig : (a : A) -> (b : B a) -> Σ B\n\nσ₀ : {A : Set} -> {B : A -> Set} -> Σ B -> A\nσ₀ (sig x _) = x\n\nσ₁ : {A : Set} -> {B : A -> Set} -> (s : Σ B) -> B (σ₀ s)\nσ₁ (sig _ y) = y\n\n\n_$$⁼_&_ : {σ τ : Ty} -> (f : Nf (σ ⟶ τ)) -> (a : Nf σ) -> {n : Nf τ} ->\n f $ⁿ a ⇓ n -> Σ \\(n' : Nf τ) -> n' == n\nKⁿ $$⁼ x & rKⁿ = sig (Kⁿ¹ x) refl\nKⁿ¹ x $$⁼ y & rKⁿ¹ = sig x refl\nSⁿ $$⁼ x & rSⁿ = sig (Sⁿ¹ x) refl\nSⁿ¹ x $$⁼ y & rSⁿ¹ = sig (Sⁿ² x y) refl\nSⁿ² x y $$⁼ z & (rSⁿ² p q r) with x $$⁼ z & p | y $$⁼ z & q\nSⁿ² x y $$⁼ z & (rSⁿ² p q r) | sig u refl | sig v refl with u $$⁼ v & r\nSⁿ² x y $$⁼ z & (rSⁿ² p q r) | sig u refl | sig v refl | sig w refl =\n sig w refl\n\nnf⁼ : {σ : Ty} -> (t : Tm σ) -> {n : Nf σ} -> t ⇓ n ->\n Σ \\(n' : Nf σ) -> n' == n\nnf⁼ K rK = sig Kⁿ refl\nnf⁼ S rS = sig Sⁿ refl\nnf⁼ (t $ u) (r$ p q r) with nf⁼ t p | nf⁼ u q\nnf⁼ (t $ u) (r$ p q r) | sig f refl | sig a refl with f $$⁼ a & r\nnf⁼ (t $ u) (r$ p q r) | sig f refl | sig a refl | sig v refl =\n sig v refl\n\nproof : {σ : Ty} -> (t : Tm σ) -> Σ \\(n : Nf σ) -> t ⇓ n\nproof = {! !}\n\nnf⇓ : {σ : Ty} -> Tm σ -> Nf σ\nnf⇓ t = σ₀ (nf⁼ t (σ₁ (proof t)))\n\n", "meta": {"hexsha": "d08b4abb76e3ba1061ba10698fbda63be2a97dbd", "size": 2897, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/Termination/comb.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/Termination/comb.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/outdated-and-incorrect/Termination/comb.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 32.5505617978, "max_line_length": 76, "alphanum_fraction": 0.3696927856, "num_tokens": 1678, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424217727026, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.6158253192310661}} {"text": "module DecidableOrder where\n\nopen import Logic.Relations\nopen import Logic.Identity using (_≡_)\n\nopen module Antisym = PolyEq _≡_ using (Antisymmetric)\n\nrecord DecidableOrder (A : Set) : Set1 where\n field\n _≤_ : Rel A\n refl : Reflexive _≤_\n antisym : Antisymmetric _≤_\n trans : Transitive _≤_\n total : Total _≤_\n decide : forall x y -> Decidable (x ≤ y)\n\n infix 80 _≤_ _≥_\n\n _≥_ = \\(x y : A) -> y ≤ x\n", "meta": {"hexsha": "6710b704fb102be30e4787387e9800cfab5f1801", "size": 434, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/order/DecidableOrder.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/order/DecidableOrder.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/order/DecidableOrder.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 21.7, "max_line_length": 54, "alphanum_fraction": 0.633640553, "num_tokens": 151, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8887587817066392, "lm_q2_score": 0.6926419767901476, "lm_q1q2_score": 0.6155916394508899}} {"text": "module plfa-code.Isomorphism where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong; cong-app)\nopen Eq.≡-Reasoning\nopen import Data.Nat using (ℕ; zero; suc; _+_)\nopen import Data.Nat.Properties using (+-comm)\n\n_∘_ : ∀ {A B C : Set} → (B → C) → (A → B) → (A → C)\n(g ∘ f) x = g (f x)\n\n_∘′_ : ∀ {A B C : Set} → (B → C) → (A → B) → (A → C)\ng ∘′ f = λ x → g (f x)\n\npostulate\n extensionality : ∀ {A B : Set} {f g : A → B}\n → (∀ (x : A) → f x ≡ g x)\n -----------------------\n → f ≡ g\n\n_+′_ : ℕ → ℕ → ℕ\nm +′ zero = m\nm +′ suc n = suc (m +′ n)\n\nsame-app : ∀ (m n : ℕ) → m +′ n ≡ m + n\nsame-app m n rewrite +-comm m n = helper m n\n where\n helper : ∀ (m n : ℕ) → m +′ n ≡ n + m\n helper m zero = refl\n helper m (suc n) = cong suc (helper m n)\n\nsame : _+′_ ≡ _+_\nsame = extensionality (λ m → extensionality (λ n → same-app m n))\n\ninfix 0 _≃_\nrecord _≃_ (A B : Set) : Set where\n field\n to : A → B\n from : B → A\n from∘to : ∀ (x : A) → from (to x) ≡ x\n to∘from : ∀ (y : B) → to (from y) ≡ y\nopen _≃_\n\n-- equal to\ndata _≃′_ (A B : Set): Set where\n mk-≃′ : ∀ (to : A → B) →\n ∀ (from : B → A) →\n ∀ (from∘to : (∀ (x : A) → from (to x) ≡ x)) →\n ∀ (to∘from : (∀ (y : B) → to (from y) ≡ y)) →\n A ≃′ B\n\nto′ : ∀ {A B : Set} → (A ≃′ B) → (A → B)\nto′ (mk-≃′ f g g∘f f∘g) = f\n\nfrom′ : ∀ {A B : Set} → (A ≃′ B) → (B → A)\nfrom′ (mk-≃′ f g g∘f f∘g) = g\n\nfrom∘to′ : ∀ {A B : Set} → (A≃B : A ≃′ B) → (∀ (x : A) → from′ A≃B (to′ A≃B x) ≡ x)\nfrom∘to′ (mk-≃′ f g g∘f f∘g) = g∘f\n\nto∘from′ : ∀ {A B : Set} → (A≃B : A ≃′ B) → (∀ (y : B) → to′ A≃B (from′ A≃B y) ≡ y)\nto∘from′ (mk-≃′ f g g∘f f∘g) = f∘g\n-- which means `field record` will take the field\n\n≃-refl : ∀ {A : Set}\n -----\n → A ≃ A\n≃-refl =\n record\n { to = λ{x → x}\n ; from = λ{y → y}\n ; from∘to = λ{x → refl}\n ; to∘from = λ{y → refl}\n }\n\n≃-sym : ∀ {A B : Set}\n → A ≃ B\n -----\n → B ≃ A\n≃-sym A≃B =\n record\n { to = from A≃B\n ; from = to A≃B\n ; from∘to = to∘from A≃B\n ; to∘from = from∘to A≃B\n }\n\n≃-trans : ∀ {A B C : Set}\n → A ≃ B\n → B ≃ C\n -----\n → A ≃ C\n≃-trans A≃B B≃C =\n record\n { to = to B≃C ∘ to A≃B\n ; from = from A≃B ∘ from B≃C\n ; from∘to = λ{x →\n begin\n (from A≃B ∘ from B≃C) ((to B≃C ∘ to A≃B) x)\n ≡⟨⟩\n from A≃B (from B≃C (to B≃C (to A≃B x)))\n ≡⟨ cong (from A≃B) (from∘to B≃C (to A≃B x)) ⟩\n from A≃B (to A≃B x)\n ≡⟨ from∘to A≃B x ⟩\n x\n ∎\n }\n ; to∘from = λ{y →\n begin\n (to B≃C ∘ to A≃B) ((from A≃B ∘ from B≃C) y)\n ≡⟨⟩\n to B≃C (to A≃B (from A≃B (from B≃C y)))\n ≡⟨ cong (to B≃C) (to∘from A≃B (from B≃C y)) ⟩\n to B≃C (from B≃C y)\n ≡⟨ to∘from B≃C y ⟩\n y\n ∎}\n }\n\nmodule ≃-Reasoning where\n\n infix 1 ≃-begin_\n infixr 2 _≃⟨_⟩_\n infix 3 _≃-∎\n\n ≃-begin_ : ∀ {A B : Set}\n → A ≃ B\n -----\n → A ≃ B\n ≃-begin A≃B = A≃B\n\n _≃⟨_⟩_ : ∀ (A : Set) {B C : Set}\n → A ≃ B\n → B ≃ C\n -----\n → A ≃ C\n A ≃⟨ A≃B ⟩ B≃C = ≃-trans A≃B B≃C\n\n _≃-∎ : ∀ (A : Set)\n -----\n → A ≃ A\n A ≃-∎ = ≃-refl\n\nopen ≃-Reasoning\n\ninfix 0 _≲_\nrecord _≲_ (A B : Set) : Set where\n field\n to : A → B\n from : B → A\n from∘to : ∀ (x : A) → from (to x) ≡ x\nopen _≲_\n\n≲-refl : ∀ {A : Set} → A ≲ A\n≲-refl =\n record\n { to = λ{x → x}\n ; from = λ{y → y}\n ; from∘to = λ{x → refl}\n }\n\n≲-trans : ∀ {A B C : Set} → A ≲ B → B ≲ C → A ≲ C\n≲-trans A≲B B≲C =\n record\n { to = λ{x → to B≲C (to A≲B x)}\n ; from = λ{y → from A≲B (from B≲C y)}\n ; from∘to = λ{x →\n begin\n from A≲B (from B≲C (to B≲C (to A≲B x)))\n ≡⟨ cong (from A≲B) (from∘to B≲C (to A≲B x)) ⟩\n from A≲B (to A≲B x)\n ≡⟨ from∘to A≲B x ⟩\n x\n ∎}\n }\n\n≲-antisym : ∀ {A B : Set}\n → (A≲B : A ≲ B)\n → (B≲A : B ≲ A)\n → (to A≲B ≡ from B≲A)\n → (from A≲B ≡ to B≲A)\n -------------------\n → A ≃ B\n≲-antisym A≲B B≲A to≡from from≡to =\n record\n { to = to A≲B\n ; from = from A≲B\n ; from∘to = from∘to A≲B\n ; to∘from = λ{y →\n begin\n to A≲B (from A≲B y)\n ≡⟨ cong (to A≲B) (cong-app from≡to y) ⟩\n to A≲B (to B≲A y)\n ≡⟨ cong-app to≡from (to B≲A y) ⟩\n from B≲A (to B≲A y)\n ≡⟨ from∘to B≲A y ⟩\n y\n ∎\n }\n }\n\nmodule ≲-Reasoning where\n\n infix 1 ≲-begin_\n infixr 2 _≲⟨_⟩_\n infix 3 _≲-∎\n\n ≲-begin_ : ∀ {A B : Set}\n → A ≲ B\n -----\n → A ≲ B\n ≲-begin A≲B = A≲B\n\n _≲⟨_⟩_ : ∀ (A : Set) {B C : Set}\n → A ≲ B\n → B ≲ C\n -----\n → A ≲ C\n A ≲⟨ A≲B ⟩ B≲C = ≲-trans A≲B B≲C\n\n _≲-∎ : ∀ (A : Set)\n -----\n → A ≲ A\n A ≲-∎ = ≲-refl\n\nopen ≲-Reasoning\n\n---------- practice ----------\n\n≃-implies-≲ : ∀ {A B : Set}\n → A ≃ B\n -----\n → A ≲ B\n\n≃-implies-≲ A≃B =\n record\n { to = to A≃B\n ; from = from A≃B\n ; from∘to = from∘to A≃B\n }\n\nrecord _⇔_ (A B : Set) : Set where\n field\n to : A → B\n from : B → A\n\nopen _⇔_\n\n⇔-refl : ∀ {A : Set} → A ⇔ A\n⇔-refl = record { to = λ z → z ; from = λ z → z }\n\n⇔-sym : ∀ {A B : Set} → A ⇔ B → B ⇔ A\n⇔-sym A⇔B = record { to = from A⇔B ; from = to A⇔B }\n\n⇔-trans : ∀ {A B C : Set} → A ⇔ B → B ⇔ C → A ⇔ C\n⇔-trans A⇔B B⇔C =\n record\n { to = to B⇔C ∘ to A⇔B\n ; from = from A⇔B ∘ from B⇔C\n }\n\ndata Bin : Set where\n nil : Bin\n x0_ : Bin → Bin\n x1_ : Bin → Bin\n\npostulate\n toB : ℕ → Bin\n fromB : Bin → ℕ\n from-to-const : ∀ (n : ℕ) → fromB (toB n) ≡ n\n\nℕ-embedding-Bin : ℕ ≲ Bin\nℕ-embedding-Bin =\n record\n { to = toB\n ; from = fromB\n ; from∘to = from-to-const\n }\n", "meta": {"hexsha": "c23c3d3d881197bd7693ea7073d60d43b49e492b", "size": 5599, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/plfa-code/Isomorphism.agda", "max_stars_repo_name": "chirsz-ever/plfa-code", "max_stars_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/plfa-code/Isomorphism.agda", "max_issues_repo_name": "chirsz-ever/plfa-code", "max_issues_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/plfa-code/Isomorphism.agda", "max_forks_repo_name": "chirsz-ever/plfa-code", "max_forks_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.0681003584, "max_line_length": 83, "alphanum_fraction": 0.4023932845, "num_tokens": 2852, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569014, "lm_q2_score": 0.7662936537604181, "lm_q1q2_score": 0.6154669830149561}} {"text": "{-# OPTIONS --universe-polymorphism #-}\nmodule Categories.Functor where\n\nopen import Level\nopen import Relation.Binary using (IsEquivalence)\nopen import Relation.Binary.PropositionalEquality\n using ()\n renaming (_≡_ to _≣_)\nopen import Relation.Nullary using (¬_)\nopen import Data.Product using (Σ; _×_; ∃; proj₁)\nopen import Categories.Category\nopen import Categories.Functor.Core public\nimport Categories.Morphisms as Morphisms\n\ninfix 4 _≡_\n\n_≡_ : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → (F G : Functor C D) → Set (e′ ⊔ ℓ′ ⊔ ℓ ⊔ o)\n_≡_ {C = C} {D} F G = ∀ {A B} → (f : C [ A , B ]) → Functor.F₁ F f ∼ Functor.F₁ G f\n where open Heterogeneous D\n\n≡⇒≣ : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′}\n → (F G : Functor C D)\n → F ≡ G\n → (∀ x → Functor.F₀ F x ≣ Functor.F₀ G x)\n≡⇒≣ {C = C} {D} F G F≡G x = domain-≣ (F≡G (Category.id C {x}))\n where\n open Heterogeneous D\n\n.assoc : ∀ {o₀ ℓ₀ e₀ o₁ ℓ₁ e₁ o₂ ℓ₂ e₂ o₃ ℓ₃ e₃} \n {C₀ : Category o₀ ℓ₀ e₀} {C₁ : Category o₁ ℓ₁ e₁} {C₂ : Category o₂ ℓ₂ e₂} {C₃ : Category o₃ ℓ₃ e₃} \n {F : Functor C₀ C₁} {G : Functor C₁ C₂} {H : Functor C₂ C₃} \n → (H ∘ G) ∘ F ≡ H ∘ (G ∘ F)\nassoc {C₃ = C₃} f = refl\n where open Heterogeneous C₃\n\n.identityˡ : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {F : Functor C D} → id ∘ F ≡ F\nidentityˡ {C = C} {D} {F} f = refl\n where open Heterogeneous D\n\n.identityʳ : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {F : Functor C D} → F ∘ id ≡ F\nidentityʳ {C = C} {D} {F} f = refl\n where open Heterogeneous D\n\n.equiv : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → IsEquivalence (_≡_ {C = C} {D = D})\nequiv {C = C} {D} = record \n { refl = λ f → refl\n ; sym = λ F∼G f → sym (F∼G f)\n ; trans = λ F∼G G∼H f → trans (F∼G f) (G∼H f)\n }\n where open Heterogeneous D\n\n\n.∘-resp-≡ : ∀ {o₀ ℓ₀ e₀ o₁ ℓ₁ e₁ o₂ ℓ₂ e₂}\n {A : Category o₀ ℓ₀ e₀} {B : Category o₁ ℓ₁ e₁} {C : Category o₂ ℓ₂ e₂}\n {F H : Functor B C} {G I : Functor A B} \n → F ≡ H → G ≡ I → F ∘ G ≡ H ∘ I\n∘-resp-≡ {B = B} {C} {F} {I = I} F≡H G≡I q = helper (G≡I q) (F≡H (Functor.F₁ I q))\n where \n open Heterogeneous C\n module C = Category C\n helper : ∀ {a b c d} {z w} {f : B [ a , b ]} {h : B [ c , d ]} {i : C [ z , w ]} \n → B [ f ∼ h ] → C [ Functor.F₁ F h ∼ i ] → C [ Functor.F₁ F f ∼ i ]\n helper (≡⇒∼ f≡h) (≡⇒∼ g≡i) = ≡⇒∼ (C.Equiv.trans (Functor.F-resp-≡ F f≡h) g≡i)\n\n\nFaithful : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → Functor C D → Set (o ⊔ ℓ ⊔ e ⊔ e′)\nFaithful {C = C} {D} F = ∀ {X Y} → (f g : C [ X , Y ]) → D [ F₁ f ≡ F₁ g ] → C [ f ≡ g ]\n where \n module C = Category C\n module D = Category D\n open Functor F\n\n-- Is this convoluted double-negated definition really necessary? A naive constructive definition of surjectivity\n-- requires a right inverse, which would probably restrict the things we can provide proofs for\nFull : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → Functor C D → Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′)\nFull {C = C} {D} F = ∀ {X Y} → ¬ Σ (D [ F₀ X , F₀ Y ]) (λ f → ¬ Σ (C [ X , Y ]) (λ g → D [ F₁ g ≡ f ]))\n where\n module C = Category C\n module D = Category D\n open Functor F\n\nFullyFaithful : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → Functor C D → Set (o ⊔ ℓ ⊔ e ⊔ ℓ′ ⊔ e′)\nFullyFaithful F = Full F × Faithful F\n\n{-\n[02:22:21 AM] copumpkin: So I think the normal statement is fine. You should be requiring F_1 to be a setoid function, i.e. forall x ~ x'. f(x) ~ f(x'). The function that would be required by the forall y.exists x. ... is not a setoid function and thus doesn't necessarily produce an inverse. That is, you'll have a function g such that f(g(y)) ~ y but not necessarily f(g(y)) = y and it is not necessary that for y ~ y' that\n[02:22:22 AM] g(y) ~ g(y'), they could be different w.r.t. the domain setoid as long as f still maps them to equivalent elements in the codomain.\n[02:27:53 AM] For example, let f : 2/= -> 2/~ (where True ~ False). Then, we need g(True) and g(False) and we could use g = not, even though True /= False and f(g(y)) /= y (assuming say f is id on the carrier), because it is still the case that f(g(y)) ~ y.\n[02:28:55 AM] So g isn't an inverse on the carrier sets, and g isn't a setoid function inverse because it's not even a setoid function.\n-}\n\nEssentiallySurjective : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → Functor C D → Set _\nEssentiallySurjective {D = D} F = ∀ d → ∃ (λ c → F₀ c ≅ d)\n where\n open Functor F\n open Morphisms D", "meta": {"hexsha": "f2fd56a6dfdde5b8ceea432a8ff83f02a9b7c84a", "size": 4662, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Functor.agda", "max_stars_repo_name": "p-pavel/categories", "max_stars_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-12-29T21:51:57.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-29T21:51:57.000Z", "max_issues_repo_path": "Categories/Functor.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Categories/Functor.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.5625, "max_line_length": 438, "alphanum_fraction": 0.5765765766, "num_tokens": 1949, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256472515684, "lm_q2_score": 0.731058584489497, "lm_q1q2_score": 0.6154238660666862}} {"text": "{-# OPTIONS --universe-polymorphism #-}\n\nmodule Categories.Free where\n\nopen import Categories.Category\nopen import Categories.Free.Core\nopen import Categories.Free.Functor\nopen import Categories.Graphs.Underlying\nopen import Categories.Functor\n using (Functor)\nopen import Graphs.Graph\nopen import Graphs.GraphMorphism\n using (GraphMorphism; module GraphMorphism)\nopen import Data.Star\n\n-- Exports from other modules:\n-- Free₀, Free₁ and Free\nopen Categories.Free.Core public\n using (Free₀)\nopen Categories.Free.Functor public\n using (Free)\n\n-- TODO:\n-- Prove Free⊣Underlying : Adjunction Free Underlying\n-- Define Adjunction.left and Adjunction.right as conveniences\n-- (or whatever other names make sense for the hom-set maps\n-- C [ F _ , _ ] → D [ _ , G _ ] and inverse, respectively)\n-- Let Cata = Adjunction.left Free⊣Underlying\nCata : ∀{o₁ ℓ₁ e₁}{G : Graph o₁ ℓ₁ e₁}\n {o₂ ℓ₂ e₂}{C : Category o₂ ℓ₂ e₂}\n → (F : GraphMorphism G (Underlying₀ C))\n → Functor (Free₀ G) C\nCata {G = G} {C = C} F = record\n { F₀ = F₀\n ; F₁ = F₁*\n ; identity = refl\n ; homomorphism = λ{X}{Y}{Z}{f}{g} → homomorphism {X}{Y}{Z}{f}{g}\n ; F-resp-≡ = F₁*-resp-≡\n }\n where\n open Category C\n open GraphMorphism F\n open Equiv\n open HomReasoning\n open PathEquality using (ε-cong; _◅-cong_)\n \n F₁* : ∀ {A B} → Free₀ G [ A , B ] → C [ F₀ A , F₀ B ]\n F₁* ε = id\n F₁* (f ◅ fs) = F₁* fs ∘ F₁ f\n \n .homomorphism : ∀ {X Y Z} {f : Free₀ G [ X , Y ]} {g : Free₀ G [ Y , Z ]}\n → C [ F₁* (Free₀ G [ g ∘ f ]) ≡ C [ F₁* g ∘ F₁* f ] ]\n homomorphism {f = ε} = sym identityʳ\n homomorphism {f = f ◅ fs}{gs} =\n begin\n F₁* (fs ◅◅ gs) ∘ F₁ f\n ↓⟨ homomorphism {f = fs}{gs} ⟩∘⟨ refl ⟩\n (F₁* gs ∘ F₁* fs) ∘ F₁ f\n ↓⟨ assoc ⟩\n F₁* gs ∘ F₁* fs ∘ F₁ f\n ∎\n \n .F₁*-resp-≡ : ∀ {A B} {f g : Free₀ G [ A , B ]} → Free₀ G [ f ≡ g ] → C [ F₁* f ≡ F₁* g ]\n F₁*-resp-≡ {f = ε}{.ε} ε-cong = refl\n F₁*-resp-≡ {f = f ◅ fs}{g ◅ gs} (f≈g ◅-cong fs≈gs) = \n begin\n F₁* fs ∘ F₁ f\n ↓⟨ F₁*-resp-≡ fs≈gs ⟩∘⟨ F-resp-≈ f≈g ⟩\n F₁* gs ∘ F₁ g\n ∎\n F₁*-resp-≡ {f = f ◅ fs}{ε} ()\n", "meta": {"hexsha": "acd1abd5288a6e060bb1dd458367fb0ca822a1ba", "size": 2205, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Free.agda", "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 98, "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_issues_repo_path": "Categories/Free.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_forks_repo_path": "Categories/Free.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 23, "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "avg_line_length": 30.625, "max_line_length": 93, "alphanum_fraction": 0.5523809524, "num_tokens": 870, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256393148982, "lm_q2_score": 0.7310585727705127, "lm_q1q2_score": 0.6154238503991738}} {"text": "module Pi.AuxLemmas where\nopen import Data.Empty\nopen import Data.Unit\nopen import Data.Sum\nopen import Data.Product\nopen import Relation.Binary.PropositionalEquality\nopen import Pi.Syntax\nopen import Pi.Opsem\n\nLemma₁ : ∀ {A B C D v v' κ κ'} {c : A ↔ B} {c' : C ↔ D}\n → ⟨ c ∣ v ∣ κ ⟩ ↦ [ c' ∣ v' ∣ κ' ]\n → A ≡ C × B ≡ D\nLemma₁ ↦₁ = refl , refl\nLemma₁ ↦₂ = refl , refl\n\nLemma₂ : ∀ {A B v v' κ κ'} {c c' : A ↔ B}\n → ⟨ c ∣ v ∣ κ ⟩ ↦ [ c' ∣ v' ∣ κ' ]\n → c ≡ c' × κ ≡ κ'\nLemma₂ ↦₁ = refl , refl\nLemma₂ ↦₂ = refl , refl\n\nLemma₃ : ∀ {A B v v' κ} {c : A ↔ B}\n → (r : ⟨ c ∣ v ∣ κ ⟩ ↦ [ c ∣ v' ∣ κ ])\n → base c ⊎ A ≡ B\nLemma₃ (↦₁ {b = b}) = inj₁ b\nLemma₃ ↦₂ = inj₂ refl\n\nLemma₄ : ∀ {A v v' κ} {c : A ↔ A}\n → (r : ⟨ c ∣ v ∣ κ ⟩ ↦ [ c ∣ v' ∣ κ ])\n → base c ⊎ c ≡ id↔\nLemma₄ {c = swap₊} ↦₁ = inj₁ tt\nLemma₄ {c = swap⋆} ↦₁ = inj₁ tt\nLemma₄ ↦₂ = inj₂ refl\n", "meta": {"hexsha": "058369b751660c841bade8cc0f8c93a99a794599", "size": 921, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Pi/AuxLemmas.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "Pi/AuxLemmas.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Pi/AuxLemmas.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 27.0882352941, "max_line_length": 55, "alphanum_fraction": 0.4657980456, "num_tokens": 423, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898203834277, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.6153289817908686}} {"text": "{-# OPTIONS --cubical --safe --no-import-sorts #-}\n\nmodule Cubical.Data.Fin.Recursive.Base where\n\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Data.Empty as Empty hiding (rec; elim)\nopen import Cubical.Data.Nat hiding (elim)\n\ndata FinF (X : Type₀) : Type₀ where\n zero : FinF X\n suc : X → FinF X\n\nFin : ℕ → Type₀\nFin zero = ⊥\nFin (suc k) = FinF (Fin k)\n\nprivate\n variable\n ℓ : Level\n k : ℕ\n R : Type ℓ\n\nrec : R → (R → R) → Fin k → R\nrec {k = suc k} z _ zero = z\nrec {k = suc k} z s (suc x) = s (rec z s x)\n\nelim\n : ∀(P : ∀{k} → Fin k → Type ℓ)\n → (∀{k} → P {suc k} zero)\n → (∀{k} (fn : Fin k) → P fn → P {suc k} (suc fn))\n → (fn : Fin k) → P fn\nelim {k = suc k} P fz fs zero = fz\nelim {k = suc k} P fz fs (suc x) = fs x (elim P fz fs x)\n", "meta": {"hexsha": "042c0c105f6cbd4342f7f1c55ac0b98e602b28ef", "size": 768, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/Fin/Recursive/Base.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/Fin/Recursive/Base.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Data/Fin/Recursive/Base.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.9428571429, "max_line_length": 58, "alphanum_fraction": 0.5703125, "num_tokens": 304, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757869916479466, "lm_q2_score": 0.7025300698514778, "lm_q1q2_score": 0.6152666964174476}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- The binary relation defined by a constant\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Relation.Binary.Construct.Constant where\n\nopen import Relation.Binary\n\n------------------------------------------------------------------------\n-- Definition\n\nConst : ∀ {a b c} {A : Set a} {B : Set b} → Set c → REL A B c\nConst I = λ _ _ → I\n\n------------------------------------------------------------------------\n-- Properties\n\nmodule _ {a c} (A : Set a) {C : Set c} where\n\n refl : C → Reflexive {A = A} (Const C)\n refl c = c\n\n sym : Symmetric {A = A} (Const C)\n sym c = c\n\n trans : Transitive {A = A} (Const C)\n trans c d = c\n\n isEquivalence : C → IsEquivalence {A = A} (Const C)\n isEquivalence c = record\n { refl = λ {x} → refl c {x}\n ; sym = λ {x} {y} → sym {x} {y}\n ; trans = λ {x} {y} {z} → trans {x} {y} {z}\n }\n\n setoid : C → Setoid a c\n setoid x = record { isEquivalence = isEquivalence x }\n", "meta": {"hexsha": "93e9461310b2814c67d0fc8eda4ac781304a1a09", "size": 1092, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Constant.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Constant.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Constant.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 26.0, "max_line_length": 72, "alphanum_fraction": 0.4194139194, "num_tokens": 289, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757869948899665, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.6152666768769809}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nopen import Prelude\nopen import Categories\n\nmodule Categories.Coequalizer {ℓ₁ ℓ₂} (C : Category ℓ₁ ℓ₂) where\n\nopen Category C\n\n\nprivate\n variable\n h i : X ⟶ Y\n\nrecord Coequalizer (f g : X ⟶ Y) : Type (ℓ₁ ℓ⊔ ℓ₂) where\n field\n {obj} : Ob\n arr : Y ⟶ obj\n\n equality : arr · f ≡ arr · g\n coequalize : ∀ {H} {h : Y ⟶ H} → h · f ≡ h · g → obj ⟶ H\n universal : ∀ {H} {h : Y ⟶ H} {eq : h · f ≡ h · g} → h ≡ coequalize eq · arr\n unique : ∀ {H} {h : Y ⟶ H} {i : obj ⟶ H} {eq : h · f ≡ h · g} → h ≡ i · arr → i ≡ coequalize eq\n", "meta": {"hexsha": "31c82f794054c4950cbffab2de3886443b694563", "size": 581, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Categories/Coequalizer.agda", "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_issues_repo_path": "agda/Categories/Coequalizer.agda", "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Categories/Coequalizer.agda", "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "avg_line_length": 24.2083333333, "max_line_length": 103, "alphanum_fraction": 0.5163511188, "num_tokens": 247, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8840392786908831, "lm_q2_score": 0.6959583376458152, "lm_q1q2_score": 0.6152545068113124}} {"text": "module API.Theorems where\r\n\r\nopen import Algebra\r\nopen import Algebra.Theorems\r\nopen import API\r\nopen import Prelude\r\nopen import Reasoning\r\n\r\n-- vertices [x] == vertex x\r\nvertices-vertex : ∀ {A} {x : A} -> vertices [ x ] ≡ vertex x\r\nvertices-vertex = +identity >> reflexivity\r\n\r\n-- edge x y == clique [x, y]\r\nedge-clique : ∀ {A} {x y : A} -> edge x y ≡ clique (x :: [ y ])\r\nedge-clique = symmetry (R *right-identity)\r\n\r\n-- vertices xs ⊆ clique xs\r\nvertices-clique : ∀ {A} {xs : List A} -> vertices xs ⊆ clique xs\r\nvertices-clique {_} {[]} = ⊆reflexivity\r\nvertices-clique {a} {_ :: t} = ⊆transitivity (⊆right-monotony (vertices-clique {a} {t})) ⊆connect\r\n\r\n-- clique (xs ++ ys) == connect (clique xs) (clique ys)\r\nconnect-clique : ∀ {A} {xs ys : List A} -> clique (xs ++ ys) ≡ connect (clique xs) (clique ys)\r\nconnect-clique {_} {[]} = symmetry *left-identity\r\nconnect-clique {a} {_ :: t} = R (connect-clique {a} {t}) >> *associativity\r\n", "meta": {"hexsha": "520acc88c581f4874f9233e6bd2b65d3f09f8eed", "size": 945, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/API/Theorems.agda", "max_stars_repo_name": "asr/alga", "max_stars_repo_head_hexsha": "01f5f9f53ea81f692215300744aa77e26d8bf332", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/API/Theorems.agda", "max_issues_repo_name": "asr/alga", "max_issues_repo_head_hexsha": "01f5f9f53ea81f692215300744aa77e26d8bf332", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/API/Theorems.agda", "max_forks_repo_name": "asr/alga", "max_forks_repo_head_hexsha": "01f5f9f53ea81f692215300744aa77e26d8bf332", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.3461538462, "max_line_length": 98, "alphanum_fraction": 0.6201058201, "num_tokens": 301, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430562234877, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.6151907861670511}} {"text": "import Relation.Binary.EqReasoning as EqReasoning\nopen import SemiNearRingRecords\nmodule ZeroLemmas (snr : SemiNearRing) where\n open SemiNearRing snr -- public\n open import CommAssocLemmas s _≃s_ _+s_ zers isCommMon hiding (_<+>_) renaming (SA to Ss)\n\n zeroˡLemma : ∀ x y → zers *s x +s zers *s y ≃s zers\n zeroˡLemma x y = begin\n zers *s x +s zers *s y\n ≈⟨ zeroˡ x <+> zeroˡ y ⟩\n zers +s zers\n ≈⟨ identityˡs zers ⟩\n zers\n ∎\n where open EqReasoning Ss\n\n zeroʳLemma : ∀ x y → x *s zers +s y *s zers ≃s zers\n zeroʳLemma x y =\n begin\n x *s zers +s y *s zers\n ≈⟨ zeroʳ x <+> zeroʳ y ⟩\n zers +s zers\n ≈⟨ identityˡs zers ⟩\n zers\n ∎\n where open EqReasoning Ss\n\n zeroˡʳLemma : ∀ w x y → w +s (zers *s x +s y *s zers) ≃s w\n zeroˡʳLemma w x y = begin\n w +s (zers *s x +s y *s zers)\n ≈⟨ refls <+> (zeroˡ x <+> zeroʳ y) ⟩\n w +s (zers +s zers)\n ≈⟨ refls <+> identityˡs zers ⟩\n w +s zers\n ≈⟨ identityʳs w ⟩\n w\n ∎\n where open EqReasoning Ss\n\n\n -- Some lemmas are needed to eliminate the zers and massage the terms.\n zeroLemma01 = lemmaCommAssoc01\n\n zeroLemma10 : ∀ {a b c d e} → a +s ( ((zers *s b) +s c) +s (d +s (e *s zers)))\n ≃s a +s ( c +s d )\n zeroLemma10 {a} {b} {c} {d} {e} = refls <+>\n (begin\n ((zers *s b) +s c) +s (d +s (e *s zers))\n ≈⟨ (zeroˡ b <+> refls) <+> (refls <+> zeroʳ e) ⟩\n ( zers +s c) +s (d +s zers)\n ≈⟨ identityˡs c <+> identityʳs d ⟩\n c +s d\n ∎)\n where open EqReasoning Ss\n\n zeroLemma00 : ∀ {a b c d e} → a +s ((c +s b) +s (d +s (e *s zers)) )\n ≃s (a +s b) +s (c +s d)\n zeroLemma00 {a} {b} {c} {d} {e} =\n (begin\n a +s ((c +s b) +s (d +s (e *s zers)) )\n ≈⟨ refls <+> (comms c b <+> (refls <+> zeroʳ e)) ⟩\n a +s ((b +s c) +s (d +s zers) )\n ≈⟨ refls <+> (refls <+> identityʳs d) ⟩\n a +s ((b +s c) +s d)\n ≈⟨ refls <+> assocs b c d ⟩\n a +s (b +s (c +s d))\n ≈⟨ syms (assocs a b _) ⟩\n (a +s b) +s (c +s d)\n ∎)\n where open EqReasoning Ss\n\n zeroLemma11 : ∀ {a b c d e} → a +s (((zers *s e) +s c) +s (b +s d))\n ≃s (a +s b) +s (c +s d)\n zeroLemma11 {a} {b} {c} {d} {e} =\n (begin\n a +s (((zers *s e) +s c) +s (b +s d))\n ≈⟨ refls <+> ((zeroˡ e <+> refls) <+> refls) ⟩\n a +s ((zers +s c) +s (b +s d))\n ≈⟨ refls <+> (identityˡs c <+> refls) ⟩\n a +s ( c +s (b +s d))\n ≈⟨ refls <+> syms (assocs c b d) ⟩\n a +s ((c +s b) +s d)\n ≈⟨ refls <+> (comms c b <+> refls) ⟩\n a +s ((b +s c) +s d)\n ≈⟨ refls <+> (assocs _ _ _) ⟩\n a +s (b +s (c +s d))\n ≈⟨ syms (assocs _ _ _) ⟩\n (a +s b) +s (c +s d)\n ∎)\n where open EqReasoning Ss\n", "meta": {"hexsha": "f2e61d0f3f1dd2dbf57a3f67dc5b187ab0caf8a9", "size": 3047, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "code/ZeroLemmas.agda", "max_stars_repo_name": "DSLsofMath/ValiantAgda", "max_stars_repo_head_hexsha": "43729ff822a0b05c6cb74016b04bdc93c627b0b1", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2016-10-23T00:41:14.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-15T03:04:31.000Z", "max_issues_repo_path": "code/ZeroLemmas.agda", "max_issues_repo_name": "DSLsofMath/ValiantAgda", "max_issues_repo_head_hexsha": "43729ff822a0b05c6cb74016b04bdc93c627b0b1", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "code/ZeroLemmas.agda", "max_forks_repo_name": "DSLsofMath/ValiantAgda", "max_forks_repo_head_hexsha": "43729ff822a0b05c6cb74016b04bdc93c627b0b1", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-04-29T04:53:48.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-29T04:53:48.000Z", "avg_line_length": 33.4835164835, "max_line_length": 91, "alphanum_fraction": 0.4227108631, "num_tokens": 1325, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637612961506, "lm_q2_score": 0.7154240018510025, "lm_q1q2_score": 0.6150240883527771}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Orders.Total.Definition\nopen import Orders.Partial.Definition\nopen import Setoids.Setoids\nopen import Setoids.Orders.Partial.Definition\nopen import Setoids.Orders.Total.Definition\nopen import Functions.Definition\nopen import Sets.EquivalenceRelations\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\n\nmodule Setoids.Orders.Total.Lemmas {a b : _} {A : Set a} {S : Setoid {a} {b} A} {c : _} {_<_ : A → A → Set c} {P : SetoidPartialOrder S _<_} (T : SetoidTotalOrder P) where\n\nopen SetoidTotalOrder T\nopen SetoidPartialOrder P\nopen Setoid S\nopen Equivalence eq\n\nmaxInequalitiesR : {a b c : A} → (a < b) → (a < c) → (a < max b c)\nmaxInequalitiesR {a} {b} {c} a ((a *ᵏ b) ∙ u) ≈ (a ∙ (b ∙ u))\n ∙-+-distrib : ∀ (a : K') (u v : V) -> (a ∙ (u + v)) ≈ ((a ∙ u) + (a ∙ v))\n ∙-+ᵏ-distrib : ∀ (a b : K') (u : V) -> ((a +ᵏ b) ∙ u) ≈ ((a ∙ u) + (b ∙ u))\n ∙-cong : ∀ {a b : K'} {u v : V} -> a ≈ᵏ b -> u ≈ v -> (a ∙ u) ≈ (b ∙ v)\n ∙-identity : ∀ (x : V) → (1ᵏ ∙ x) ≈ x\n ∙-absorbˡ : ∀ (x : V) → (0ᵏ ∙ x) ≈ 0#\n\n open IsAbelianGroup isAbelianGroup public\n renaming\n ( assoc to +-assoc\n ; ∙-cong to +-cong\n ; identity to +-identity\n ; identityˡ to +-identityˡ\n ; identityʳ to +-identityʳ\n ; comm to +-comm\n ; inverse to -‿inverse\n ; inverseˡ to -‿inverseˡ\n ; inverseʳ to -‿inverseʳ\n ; ⁻¹-cong to -‿cong\n )\n\n open import Algebra.Properties.AbelianGroup (record { isAbelianGroup = isAbelianGroup }) public\n renaming\n ( ε⁻¹≈ε to -0≈0\n ; ∙-cancelˡ to +-cancelˡ\n ; ∙-cancelʳ to +-cancelʳ\n ; ∙-cancel to +-cancel\n ; identityˡ-unique to +-identityˡ-unique\n ; identityʳ-unique to +-identityʳ-unique\n ; identity-unique to +-identity-unique\n ; inverseˡ-unique to +-inverseˡ-unique\n ; inverseʳ-unique to +-inverseʳ-unique\n ; xyx⁻¹≈y to x+y-x≈y\n ; ⁻¹-∙-comm to -‿+-comm\n )\n\n open import Relation.Binary.EqReasoning setoid\n\n ∙-absorbʳ : ∀ (a : K') -> (a ∙ 0#) ≈ 0#\n ∙-absorbʳ a =\n begin\n a ∙ 0#\n ≈⟨ trans (∙-cong ≈ᵏ-refl (sym (∙-absorbˡ 0#))) (sym (*ᵏ-∙-compat a 0ᵏ 0#)) ⟩\n (a *ᵏ 0ᵏ) ∙ 0#\n ≈⟨ ∙-cong (*ᵏ-zeroʳ a) refl ⟩\n 0ᵏ ∙ 0#\n ≈⟨ ∙-absorbˡ 0# ⟩\n 0#\n ∎\n\n ∙-∙-comm : ∀ (a b : K') (u : V) -> (a ∙ (b ∙ u)) ≈ (b ∙ (a ∙ u))\n ∙-∙-comm a b u =\n begin\n a ∙ (b ∙ u)\n ≈⟨ sym (*ᵏ-∙-compat a b u) ⟩\n (a *ᵏ b) ∙ u\n ≈⟨ ∙-cong (*ᵏ-comm a b) refl ⟩\n (b *ᵏ a) ∙ u\n ≈⟨ *ᵏ-∙-compat b a u ⟩\n b ∙ (a ∙ u)\n ∎\n\n private\n lemma-inverseʳ : ∀ (u : V) -> (u + ((-ᵏ 1ᵏ) ∙ u)) ≈ 0#\n lemma-inverseʳ u =\n begin\n u + ((-ᵏ 1ᵏ) ∙ u)\n ≈⟨ +-cong (sym (∙-identity u)) refl ⟩\n (1ᵏ ∙ u) + ((-ᵏ 1ᵏ) ∙ u)\n ≈⟨ sym (∙-+ᵏ-distrib 1ᵏ (-ᵏ 1ᵏ) u) ⟩\n (1ᵏ +ᵏ (-ᵏ 1ᵏ)) ∙ u\n ≈⟨ ∙-cong (-ᵏ‿inverseʳ 1ᵏ) refl ⟩\n 0ᵏ ∙ u\n ≈⟨ ∙-absorbˡ u ⟩\n 0#\n ∎\n\n -1∙u≈-u : ∀ (u : V) -> ((-ᵏ 1ᵏ) ∙ u) ≈ (- u)\n -1∙u≈-u u =\n begin\n ((-ᵏ 1ᵏ) ∙ u)\n ≈⟨ +-inverseʳ-unique u ((-ᵏ 1ᵏ) ∙ u) (lemma-inverseʳ u) ⟩\n - u\n ∎\n", "meta": {"hexsha": "01b143e40d17a11ca95562b2a38838343a2cad90", "size": 4825, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Algebra/Linear/Structures/VectorSpace.agda", "max_stars_repo_name": "felko/linear-algebra", "max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z", "max_issues_repo_path": "src/Algebra/Linear/Structures/VectorSpace.agda", "max_issues_repo_name": "felko/linear-algebra", "max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Algebra/Linear/Structures/VectorSpace.agda", "max_forks_repo_name": "felko/linear-algebra", "max_forks_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.15625, "max_line_length": 106, "alphanum_fraction": 0.4391709845, "num_tokens": 2226, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519528019683105, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.6148911469068309}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Well-founded induction\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary\n\nmodule Induction.WellFounded where\n\nopen import Data.Product\nopen import Function\nopen import Induction\nopen import Level\nopen import Relation.Binary.PropositionalEquality hiding (trans)\nopen import Relation.Unary\n\nprivate\n variable\n a b ℓ ℓ₁ ℓ₂ r : Level\n A : Set a\n B : Set b\n\n------------------------------------------------------------------------\n-- Definitions\n\n-- When using well-founded recursion you can recurse arbitrarily, as\n-- long as the arguments become smaller, and \"smaller\" is\n-- well-founded.\n\nWfRec : Rel A r → ∀ {ℓ} → RecStruct A ℓ _\nWfRec _<_ P x = ∀ y → y < x → P y\n\n-- The accessibility predicate: x is accessible if everything which is\n-- smaller than x is also accessible (inductively).\n\ndata Acc {A : Set a} (_<_ : Rel A ℓ) (x : A) : Set (a ⊔ ℓ) where\n acc : (rs : WfRec _<_ (Acc _<_) x) → Acc _<_ x\n\nacc-inverse : ∀ {_<_ : Rel A ℓ} {x : A} (q : Acc _<_ x) →\n (y : A) → y < x → Acc _<_ y\nacc-inverse (acc rs) y y ∣ a + b ∣ ≡ ∣ a ∣ + ∣ b ∣\ntri-eq (+_ a) (+_ b) = begin\n ∣ + a + + b ∣ ≡⟨ refl ⟩ \n ∣ + (a + b) ∣ ≡⟨ refl ⟩\n a + b ≡⟨ refl ⟩\n ∣ + a ∣ + ∣ + b ∣ ∎\n where\n open PE.≡-Reasoning\n\n-- For all a, a * a is always non-negative.\na*a=+b : ∀ a -> ∃ λ b → a * a ≡ + b\na*a=+b (+_ a) = (a * a) , IntP.pos-distrib-* a a\na*a=+b (-[1+_] a) = suc a * suc a , refl\n\n0≤a*a : ∀ {a} → 0ℤ ≤ a * a \n0≤a*a {a} rewrite proj₂ $ a*a=+b a = +≤+ Nat.z≤n \n\n\n-- For non-zero natrual number a, a * a is always positive.\na*a-pos : ∀ (a : ℕ) .{{_ : Nat.NonZero a}} -> ∃ λ n → a * a ≡ suc n\na*a-pos (suc b) = b * b + 2 * b , claim\n where\n claim : suc b * suc b ≡ suc (b * b + 2 * b)\n claim = \n begin\n suc b * suc b ≡⟨ refl ⟩ \n (1 + b) * (1 + b) ≡⟨ solve 1 (λ b → (con 1 :+ b) :* (con 1 :+ b) := con 1 :+ (b :* b :+ con 2 :* b)) refl b ⟩ \n 1 + (b * b + 2 * b) ≡⟨ refl ⟩ \n suc (b * b + 2 * b) ∎\n where\n open NS.+-*-Solver\n open PE.≡-Reasoning\n\na*a-pos' : ∀ (a : ℤ) .{{_ : NonZero a}} -> ∃ λ n → a * a ≡ + (suc n)\na*a-pos' +[1+ n ] rewrite proj₂ $ a*a-pos (suc n) = (proj₁ $ a*a-pos (suc n)) , refl\na*a-pos' -[1+ n ] rewrite proj₂ $ a*a-pos (suc n) = (proj₁ $ a*a-pos (suc n)) , refl\n\n-- For an non-zero integer a, ∣ a * a ∣ is always positive.\n∣a*a∣-pos : ∀ (a : ℤ) .{{_ : NonZero a}} -> ∃ λ n → ∣ a * a ∣ ≡ suc n\n∣a*a∣-pos (+ (suc b)) = b * b + 2 * b , claim\n where\n claim : suc b * suc b ≡ suc (b * b + 2 * b)\n claim = proj₂ $ a*a-pos (suc b)\n∣a*a∣-pos (-[1+_] b) = b * b + 2 * b , claim\n where\n claim : suc b * suc b ≡ suc (b * b + 2 * b)\n claim = proj₂ $ a*a-pos (suc b)\n\n+∣a*a∣=a*a : ∀ (a : ℤ) -> + ∣ a * a ∣ ≡ a * a \n+∣a*a∣=a*a a = IntP.0≤i⇒+∣i∣≡i (0≤a*a {a}) \n\npos : ∀ {a : ℤ} -> ¬ a ≡ 0ℤ -> 0ℤ < a * a \npos {+_ zero} n0 with n0 refl\n... | ()\npos {a@(+[1+ n ])} n0 rewrite proj₂ $ a*a-pos' a = +<+ (Nat.s≤s Nat.z≤n)\npos {a@(-[1+ n ])} n0 rewrite proj₂ $ a*a-pos' a = +<+ (Nat.s≤s Nat.z≤n)\n\npos' : ∀ {a} -> 0ℤ < a -> Nat.NonZero ∣ a ∣\npos' {(+_ zero)} (+<+ ())\npos' {+[1+ n ]} l = record { nonZero = _ }\n\n\n-- ∣ a * a + b * b ∣ is not zero if one of a and b is.\n∣aa+bb∣-nonzero : ∀ a b -> ¬ a ≡ 0ℤ ⊎ ¬ b ≡ 0ℤ -> Nat.NonZero ∣ a * a + b * b ∣\n∣aa+bb∣-nonzero a b (inj₁ x) = pos' (IntP.+-mono-<-≤ (pos x) (0≤a*a {b}))\n∣aa+bb∣-nonzero a b (inj₂ y) = pos' (IntP.+-mono-≤-< (0≤a*a {a}) (pos y))\n\n\n-- ----------------------------------------------------------------------\n-- Properties of aa + bb\n\n-- A special case of tri-eq. \ntri-eq' : ∀ a b -> ∣ a * a + b * b ∣ ≡ ∣ a * a ∣ + ∣ b * b ∣\ntri-eq' a b = begin\n let (sa , sae) = (a*a=+b a) in let (sb , sbe) = a*a=+b b in\n ∣ a * a + b * b ∣ ≡⟨ cong (λ x → ∣ x ∣) (cong₂ _+_ sae sbe) ⟩\n ∣ + sa + + sb ∣ ≡⟨ (tri-eq (+ sa) (+ sb)) ⟩\n ∣ + sa ∣ + ∣ + sb ∣ ≡⟨ cong₂ _+_ (cong ∣_∣ (sym sae)) (cong ∣_∣ (sym sbe)) ⟩\n ∣ a * a ∣ + ∣ b * b ∣ ∎\n where\n open PE.≡-Reasoning\n\n\n-- A property of a pair of integers.\na=0×b=0⇒aa+bb=0 : ∀ {a b : ℤ} -> a ≡ 0ℤ × b ≡ 0ℤ -> a * a + b * b ≡ 0ℤ\na=0×b=0⇒aa+bb=0 {.0ℤ} {.0ℤ} (refl , refl) = refl\n\naa+bb=0⇒a=0×b=0 : ∀ {a b : ℤ} -> a * a + b * b ≡ 0ℤ -> a ≡ 0ℤ × b ≡ 0ℤ\naa+bb=0⇒a=0×b=0 {a} {b} eq = P.map x^2=0⇒x=0 x^2=0⇒x=0 $ z+z (0≤a*a {a}) (0≤a*a {b}) eq \n where\n z+z : ∀ {x y} -> 0ℤ ≤ x -> 0ℤ ≤ y -> x + y ≡ 0ℤ -> x ≡ 0ℤ × y ≡ 0ℤ\n z+z {.+0} {.(+ _)} (+≤+ {n = zero} z≤n) (+≤+ z≤n) x+y=0 = (refl , x+y=0)\n z+z {.(+[1+ n ])} {.+0} (+≤+ {n = ℕ.suc n} z≤n) (+≤+ {n = zero} m≤n) ()\n z+z {.(+[1+ n ])} {.(+[1+ n₁ ])} (+≤+ {n = ℕ.suc n} z≤n) (+≤+ {n = ℕ.suc n₁} m≤n) ()\n\n x^2=0⇒x=0 : ∀ {x} -> x * x ≡ 0ℤ -> x ≡ 0ℤ\n x^2=0⇒x=0 {+_ zero} eq = refl\n", "meta": {"hexsha": "115ce55a06e2e614ed2670dce7fc24ddbf032672", "size": 4453, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Integer/Properties.agda", "max_stars_repo_name": "onestruggler/EucDomain", "max_stars_repo_head_hexsha": "7e268e8354065fde734c9c2d9998d2cfd4a21f71", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Integer/Properties.agda", "max_issues_repo_name": "onestruggler/EucDomain", "max_issues_repo_head_hexsha": "7e268e8354065fde734c9c2d9998d2cfd4a21f71", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Integer/Properties.agda", "max_forks_repo_name": "onestruggler/EucDomain", "max_forks_repo_head_hexsha": "7e268e8354065fde734c9c2d9998d2cfd4a21f71", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.5, "max_line_length": 118, "alphanum_fraction": 0.4423983831, "num_tokens": 2198, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513648201266, "lm_q2_score": 0.685949467848392, "lm_q1q2_score": 0.6147831467567608}} {"text": "{-# OPTIONS --without-K --safe #-}\nopen import Categories.Category\n\n-- Properties relating Initial and Terminal Objects,\n-- and Product / Coproduct via op\n\nmodule Categories.Object.Duality {o ℓ e} (C : Category o ℓ e) where\n\nopen Category C\n\nopen import Level\n\nopen import Categories.Morphism C\nopen import Categories.Object.Terminal op\nopen import Categories.Object.Initial C\nopen import Categories.Object.Product op\nopen import Categories.Object.Coproduct C\n\n\nIsInitial⇒coIsTerminal : ∀ {X} → IsInitial X → IsTerminal X\nIsInitial⇒coIsTerminal is⊥ = record\n { ! = !\n ; !-unique = !-unique\n }\n where open IsInitial is⊥\n\n⊥⇒op⊤ : Initial → Terminal\n⊥⇒op⊤ i = record\n { ⊤ = ⊥\n ; ⊤-is-terminal = IsInitial⇒coIsTerminal ⊥-is-initial\n }\n where open Initial i\n\ncoIsTerminal⇒IsInitial : ∀ {X} → IsTerminal X → IsInitial X\ncoIsTerminal⇒IsInitial is⊤ = record\n { ! = !\n ; !-unique = !-unique\n }\n where open IsTerminal is⊤\n\nop⊤⇒⊥ : Terminal → Initial\nop⊤⇒⊥ t = record\n { ⊥ = ⊤\n ; ⊥-is-initial = coIsTerminal⇒IsInitial ⊤-is-terminal\n }\n where open Terminal t\n\nCoproduct⇒coProduct : ∀ {A B} → Coproduct A B → Product A B\nCoproduct⇒coProduct A+B = record\n { A×B = A+B.A+B\n ; π₁ = A+B.i₁\n ; π₂ = A+B.i₂\n ; ⟨_,_⟩ = A+B.[_,_]\n ; project₁ = A+B.inject₁\n ; project₂ = A+B.inject₂\n ; unique = A+B.unique\n }\n where\n module A+B = Coproduct A+B\n\ncoProduct⇒Coproduct : ∀ {A B} → Product A B → Coproduct A B\ncoProduct⇒Coproduct A×B = record\n { A+B = A×B.A×B\n ; i₁ = A×B.π₁\n ; i₂ = A×B.π₂\n ; [_,_] = A×B.⟨_,_⟩\n ; inject₁ = A×B.project₁\n ; inject₂ = A×B.project₂\n ; unique = A×B.unique\n }\n where\n module A×B = Product A×B\n", "meta": {"hexsha": "efc7bdd5fa1bc1a4a6b2d2d7f50c3f9177be5a3e", "size": 1707, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Object/Duality.agda", "max_stars_repo_name": "bond15/agda-categories", "max_stars_repo_head_hexsha": "6cbfdf3f1be15ef513435e3b85faae92cb1ac36f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Object/Duality.agda", "max_issues_repo_name": "bond15/agda-categories", "max_issues_repo_head_hexsha": "6cbfdf3f1be15ef513435e3b85faae92cb1ac36f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Object/Duality.agda", "max_forks_repo_name": "bond15/agda-categories", "max_forks_repo_head_hexsha": "6cbfdf3f1be15ef513435e3b85faae92cb1ac36f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.3835616438, "max_line_length": 67, "alphanum_fraction": 0.6203866432, "num_tokens": 639, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513648201266, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.6147831410027377}} {"text": "{-# OPTIONS --type-in-type #-}\n\nmodule DescFix where\n\nopen import DescTT\n\n\naux : (C : Desc)(D : Desc)(P : Mu C -> Set)(x : [| D |] (Mu C)) -> Set\naux C id P (con y) = P (con y) * aux C C P y \naux C (const K) P k = Unit\naux C (prod D D') P (s , t) = aux C D P s * aux C D' P t\naux C (sigma S T) P (s , t) = aux C (T s) P t\naux C (pi S T) P f = (s : S) -> aux C (T s) P (f s)\n\n\ngen : (C : Desc)(D : Desc)(P : Mu C -> Set)\n (rec : (y : [| C |] Mu C) -> aux C C P y -> P (con y))\n (x : [| D |] Mu C) -> aux C D P x\ngen C id P rec (con x) = rec x (gen C C P rec x) , gen C C P rec x\ngen C (const K) P rec k = Void\ngen C (prod D D') P rec (s , t) = gen C D P rec s , gen C D' P rec t\ngen C (sigma S T) P rec (s , t) = gen C (T s) P rec t\ngen C (pi S T) P rec f = \\ s -> gen C (T s) P rec (f s)\n\n\nfix : (D : Desc)(P : Mu D -> Set)\n (rec : (y : [| D |] Mu D) -> aux D D P y -> P (con y))\n (x : Mu D) -> P x\nfix D P rec (con x) = rec x (gen D D P rec x)\n\n\n\nplus : Nat -> Nat -> Nat\nplus (con (Ze , Void)) n = n\nplus (con (Suc , m)) n = suc (plus m n)\n\nfib : Nat -> Nat\nfib = fix NatD (\\ _ -> Nat) help\n where\n help : (m : [| NatD |] Nat) -> aux NatD NatD (\\ _ -> Nat) m -> Nat\n help (Ze , x) a = suc ze\n help (Suc , con (Ze , _)) a = suc ze\n help (Suc , con (Suc , con n)) (fib-n , (fib-sn , a)) = plus fib-n fib-sn", "meta": {"hexsha": "0178a67fd129f47ed17d7eba8efcc324ffd95217", "size": 1375, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "models/DescFix.agda", "max_stars_repo_name": "mietek/epigram", "max_stars_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 48, "max_stars_repo_stars_event_min_datetime": "2016-01-09T17:36:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-11T01:55:28.000Z", "max_issues_repo_path": "models/DescFix.agda", "max_issues_repo_name": "mietek/epigram", "max_issues_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "models/DescFix.agda", "max_forks_repo_name": "mietek/epigram", "max_forks_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2016-08-14T21:36:35.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-11T01:57:40.000Z", "avg_line_length": 31.976744186, "max_line_length": 77, "alphanum_fraction": 0.464, "num_tokens": 561, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467706759583, "lm_q2_score": 0.6992544085240401, "lm_q1q2_score": 0.6147472551348371}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Data.NatPlusOne.MoreNats.AssocNat.Base where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\n\nopen import Cubical.Data.Empty\nopen import Cubical.Data.Unit\nopen import Cubical.Data.Nat hiding (_+_)\n\ninfixl 6 _+₁_\n\ndata ℕ₊₁ : Type where\n one : ℕ₊₁\n _+₁_ : ℕ₊₁ → ℕ₊₁ → ℕ₊₁\n assoc : (a b c : ℕ₊₁) → a +₁ (b +₁ c) ≡ a +₁ b +₁ c\n trunc : isSet ℕ₊₁\n\nmodule Elim {ℓ'} {B : ℕ₊₁ → Type ℓ'}\n (one* : B one) (_+₁*_ : {m n : ℕ₊₁} → B m → B n → B (m +₁ n))\n (assoc* : {x y z : ℕ₊₁} (x' : B x) (y' : B y) (z' : B z)\n → PathP (λ i → B (assoc x y z i))\n (x' +₁* (y' +₁* z')) ((x' +₁* y') +₁* z'))\n (trunc* : (n : ℕ₊₁) → isSet (B n)) where\n\n f : (n : ℕ₊₁) → B n\n f one = one*\n f (m +₁ n) = f m +₁* f n\n f (assoc x y z i) = assoc* (f x) (f y) (f z) i\n f (trunc m n p q i j) =\n isOfHLevel→isOfHLevelDep 2 trunc* (f m) (f n)\n (cong f p) (cong f q) (trunc m n p q) i j\n\nmodule ElimProp {ℓ'} {B : ℕ₊₁ → Type ℓ'} (BProp : {n : ℕ₊₁} → isProp (B n))\n (one* : B one) (_+₁*_ : {m n : ℕ₊₁} → B m → B n → B (m +₁ n)) where\n\n f : (n : ℕ₊₁) → B n\n f = Elim.f {B = B} one* _+₁*_\n (λ {x} {y} {z} x' y' z' →\n toPathP (BProp (transport (λ i → B (assoc x y z i))\n (x' +₁* (y' +₁* z'))) ((x' +₁* y') +₁* z')))\n λ n → isProp→isSet BProp\n\nmodule Rec {ℓ'} {B : Type ℓ'} (BType : isSet B)\n (one* : B) (_+₁*_ : B → B → B)\n (assoc* : (a b c : B) → a +₁* (b +₁* c) ≡ (a +₁* b) +₁* c) where\n\n f : ℕ₊₁ → B\n f = Elim.f one* (λ m n → m +₁* n) assoc* λ _ → BType\n\nprivate\n constraintNumber : ℕ → Type\n constraintNumber zero = ⊥\n constraintNumber (suc _) = Unit\n\n fromNat' : (n : ℕ) ⦃ _ : constraintNumber n ⦄ → ℕ₊₁\n fromNat' zero ⦃ () ⦄\n fromNat' (suc zero) = one\n fromNat' (suc (suc n)) = fromNat' (suc n) +₁ one\n\ninstance\n NumN : HasFromNat ℕ₊₁\n NumN = record { Constraint = constraintNumber ; fromNat = fromNat' }\n", "meta": {"hexsha": "1790953d309132aedc61155008e4c8705b3a9249", "size": 1927, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/NatPlusOne/MoreNats/AssocNat/Base.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_issues_repo_path": "Cubical/Data/NatPlusOne/MoreNats/AssocNat/Base.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Data/NatPlusOne/MoreNats/AssocNat/Base.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.109375, "max_line_length": 75, "alphanum_fraction": 0.5106382979, "num_tokens": 880, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357494949105, "lm_q2_score": 0.7090191276365463, "lm_q1q2_score": 0.6147449307365805}} {"text": "module Structure.Numeral.Natural where\n\nopen import Lang.Instance\nimport Lvl\nopen import Logic.Predicate\nopen import Logic.Propositional\nopen import Structure.Setoid\nopen import Structure.Function.Domain\nopen import Structure.Function\nopen import Structure.Operator\nopen import Structure.Relator\nopen import Structure.Setoid\nopen import Syntax.Function\nopen import Type\n\nprivate variable ℓₒ ℓₗ ℓₑ ℓₗ₁ ℓₗ₂ : Lvl.Level\nprivate variable N : Type{ℓₒ}\n\nmodule _ ⦃ equiv : Equiv{ℓₑ}(N) ⦄ where\n private variable 𝟎 : N\n private variable 𝐒 : N → N\n private variable _+_ _⋅_ _^_ : N → N → N\n\n module _ {ℓ} (𝟎 : N) (𝐒 : N → N) where\n record Induction : Type{ℓₑ Lvl.⊔ Lvl.of(N) Lvl.⊔ Lvl.𝐒(ℓ)} where\n constructor intro\n field proof : (P : N → Type{ℓ}) ⦃ rel : UnaryRelator(P) ⦄ → P(𝟎) → ((n : N) → P(n) → P(𝐒(n))) → ((n : N) → P(n))\n induction = inst-fn Induction.proof\n\n record Elemental (𝟎 : N) (𝐒 : N → N) : Type{ℓₑ Lvl.⊔ Lvl.of(N)} where\n constructor intro\n field\n ⦃ 𝐒-function ⦄ : Function(𝐒)\n ⦃ 𝐒-injectivity ⦄ : Injective(𝐒)\n 𝐒-positivity : ∀{x} → (𝐒(x) ≢ 𝟎)\n\n record Addition ⦃ elemn : Elemental(𝟎)(𝐒) ⦄ (_+_ : N → N → N) : Type{ℓₑ Lvl.⊔ Lvl.of(N)} where\n constructor intro\n field\n ⦃ operator ⦄ : BinaryOperator(_+_)\n base : ∀{a} → (a + 𝟎 ≡ a)\n step : ∀{a b} → (a + 𝐒(b) ≡ 𝐒(a + b))\n\n record Multiplication ⦃ elemn : Elemental(𝟎)(𝐒) ⦄ ⦃ addi : Addition(_+_) ⦄ (_⋅_ : N → N → N) : Type{ℓₑ Lvl.⊔ Lvl.of(N)} where\n constructor intro\n field\n ⦃ operator ⦄ : BinaryOperator(_⋅_)\n base : ∀{a} → (a ⋅ 𝟎 ≡ 𝟎)\n step : ∀{a b} → (a ⋅ 𝐒(b) ≡ a + (a ⋅ b))\n\n record Exponentiation ⦃ elemn : Elemental(𝟎)(𝐒) ⦄ ⦃ addi : Addition(_+_) ⦄ ⦃ multi : Multiplication(_⋅_) ⦄ (_^_ : N → N → N) : Type{ℓₑ Lvl.⊔ Lvl.of(N)} where\n constructor intro\n field\n ⦃ operator ⦄ : BinaryOperator(_^_)\n base : ∀{a} → (a ^ 𝟎 ≡ 𝐒(𝟎))\n step : ∀{a b} → (a ^ 𝐒(b) ≡ a ⋅ (a ^ b))\n\n record WeakOrdering ⦃ elemn : Elemental(𝟎)(𝐒) ⦄ {_+_ : N → N → N} ⦃ addi : Addition(_+_) ⦄ (_≤_ : N → N → Type{ℓₗ}) : Type{ℓₑ Lvl.⊔ Lvl.of(N) Lvl.⊔ ℓₗ} where\n constructor intro\n field\n ⦃ relator ⦄ : BinaryRelator(_≤_)\n proof : ∀{a b} → (a ≤ b) ↔ ∃(c ↦ a + c ≡ b)\n\n module _ ⦃ ind : Induction(𝟎)(𝐒) ⦄ ⦃ elem : Elemental(𝟎)(𝐒) ⦄ where\n open import Structure.Relator.Proofs\n open import Structure.Relator.Properties\n\n open Elemental(elem)\n open Induction(ind)\n\n 𝟎-or-𝐒 : ∀{x} → (x ≡ 𝟎) ∨ ∃(y ↦ x ≡ 𝐒(y))\n 𝟎-or-𝐒 {x} = induction(𝟎)(𝐒)\n (x ↦ (x ≡ 𝟎) ∨ ∃(y ↦ x ≡ 𝐒(y))) ⦃ [∨]-unaryRelator ⦃ rel-P = BinaryRelator.left [≡]-binaryRelator ⦄ ⦃ rel-Q = [∃]-unaryRelator ⦃ rel-P = BinaryRelator.left [≡]-binaryRelator ⦄ ⦄ ⦄\n ([∨]-introₗ (reflexivity(_≡_)))\n (x ↦ [∨]-elim\n (p ↦ [∨]-introᵣ([∃]-intro 𝟎 ⦃ congruence₁(𝐒) p ⦄))\n (\\{([∃]-intro y ⦃ p ⦄) → [∨]-introᵣ([∃]-intro (𝐒(y)) ⦃ congruence₁(𝐒) p ⦄)})\n )\n x\n\n{-\n module _ ⦃ ind : Induction(𝟎)(𝐒) ⦄ where\n import Data.Either as Either\n open import Functional\n open import Numeral.Natural as ℕ using (ℕ)\n open import Relator.Equals renaming (_≡_ to _≡ₑ_)\n open import Structure.Relator.Proofs\n open import Syntax.Number\n\n from-ℕ : ℕ → N\n from-ℕ (ℕ.𝟎) = 𝟎\n from-ℕ (ℕ.𝐒(n)) = 𝐒(from-ℕ n)\n-}\n\n -- TODO: Also include the definition of a \"naturally ordered semigroup\" here\n\n{-\n module _ (_<_ : T → T → Stmt{ℓₗ}) where\n record Minimal : Type{Lvl.of(T) Lvl.⊔ ℓₗ} where\n open From-[<][≡] (_<_) (_≡_)\n\n field\n ⦃ elemental ⦄ : Elemental\n [<]ₗ-𝟎 : ∀{x} → (𝟎 < x) ↔ (x ≢ 𝟎)\n [<]ᵣ-𝟎 : ∀{x} → (𝟎 ≤ x) -- Minimum in the order (TODO: Is (∀x. x≥0) neccessary? Which means (0-is-inj (GroupIso.f-equiv (Coker-β ψ₂ G-ab))) φ₂-is-inj\n\n open import groups.PropQuotUniqueFactorization\n (ker-propᴳ ψ₁) (im-npropᴳ ψ₂ G-ab) φ₁ φ₁-is-surj φ₂' φ₂'-is-inj φ-comm\n open import groups.KernelImage ψ₁ ψ₂ G-ab\n\n H-iso-Ker/Im : H ≃ᴳ Ker/Im\n H-iso-Ker/Im = Ker/Im-β ⁻¹ᴳ ∘eᴳ H-iso-P/Q\n", "meta": {"hexsha": "266e4722edd6c75da566d63f74a1f0d3e555b2bf", "size": 1357, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/groups/KernelImageUniqueFactorization.agda", "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 294, "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_issues_repo_path": "theorems/groups/KernelImageUniqueFactorization.agda", "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 31, "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_forks_repo_path": "theorems/groups/KernelImageUniqueFactorization.agda", "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 50, "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "avg_line_length": 26.0961538462, "max_line_length": 86, "alphanum_fraction": 0.5276344878, "num_tokens": 594, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.89181104831338, "lm_q2_score": 0.6893056104028797, "lm_q1q2_score": 0.6147303590216865}} {"text": "{-# OPTIONS --safe #-}\n\nmodule Cubical.Algebra.MonoidSolver.Examples where\n\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Algebra.Monoid.Base\nopen import Cubical.Algebra.CommMonoid.Base\nopen import Cubical.Algebra.MonoidSolver.Reflection\n\nprivate\n variable\n ℓ : Level\n\nmodule ExamplesMonoid (M : Monoid ℓ) where\n open MonoidStr (snd M)\n\n _ : ε ≡ ε\n _ = solveMonoid M\n\n _ : ε · ε · ε ≡ ε\n _ = solveMonoid M\n\n _ : ∀ x → ε · x ≡ x\n _ = solveMonoid M\n\n _ : ∀ x y z → (x · y) · z ≡ x · (y · z)\n _ = solveMonoid M\n\n _ : ∀ x y z → z · (x · y) · ε · z ≡ z · x · (y · z)\n _ = solveMonoid M\n\nmodule ExamplesCommMonoid (M : CommMonoid ℓ) where\n open CommMonoidStr (snd M)\n\n _ : ε ≡ ε\n _ = solveCommMonoid M\n\n _ : ε · ε · ε ≡ ε\n _ = solveCommMonoid M\n\n _ : ∀ x → ε · x ≡ x\n _ = solveCommMonoid M\n\n _ : ∀ x y z → (x · z) · y ≡ x · (y · z)\n _ = solveCommMonoid M\n\n _ : ∀ x y → (x · y) · y · x · (x · y) ≡ x · x · x · (y · y · y)\n _ = solveCommMonoid M\n", "meta": {"hexsha": "22f266cf5df1086cda99d274685ff6a54b130af9", "size": 982, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/MonoidSolver/Examples.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_issues_repo_path": "Cubical/Algebra/MonoidSolver/Examples.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/MonoidSolver/Examples.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.64, "max_line_length": 66, "alphanum_fraction": 0.5763747454, "num_tokens": 388, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110396870287, "lm_q2_score": 0.6893056040203135, "lm_q1q2_score": 0.6147303473834511}} {"text": "{-\n\nℚ is a Commutative Ring\n\n-}\n{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.CommRing.Instances.QuoQ where\n\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Algebra.CommRing\nopen import Cubical.HITs.Rationals.QuoQ\n renaming (ℚ to ℚType ; _+_ to _+ℚ_; _·_ to _·ℚ_; -_ to -ℚ_)\n\nopen CommRingStr\n\n\nℚCommRing : CommRing ℓ-zero\nℚCommRing .fst = ℚType\nℚCommRing .snd .0r = 0\nℚCommRing .snd .1r = 1\nℚCommRing .snd ._+_ = _+ℚ_\nℚCommRing .snd ._·_ = _·ℚ_\nℚCommRing .snd .-_ = -ℚ_\nℚCommRing .snd .isCommRing = isCommRingℚ\n where\n abstract\n isCommRingℚ : IsCommRing 0 1 _+ℚ_ _·ℚ_ -ℚ_\n isCommRingℚ = makeIsCommRing\n isSetℚ +-assoc +-identityʳ\n +-inverseʳ +-comm ·-assoc\n ·-identityʳ (λ x y z → sym (·-distribˡ x y z)) ·-comm\n", "meta": {"hexsha": "ac9b1a86ced624aed4d58148384973c137296d31", "size": 750, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommRing/Instances/QuoQ.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/CommRing/Instances/QuoQ.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/CommRing/Instances/QuoQ.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.7272727273, "max_line_length": 61, "alphanum_fraction": 0.6866666667, "num_tokens": 309, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.900529778109184, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.6146779794083654}} {"text": "{-# OPTIONS --universe-polymorphism #-}\n-- {-# OPTIONS --verbose tc.constr.findInScope:15 #-}\n-- {-# OPTIONS --verbose tc.term.args.ifs:15 #-}\n-- {-# OPTIONS --verbose tc.checkArgs:15 #-}\n\nmodule 12-constraintFamilies where\n\nopen import Level\nopen import Function\nopen import Data.Unit\nopen import Data.List\nopen import Data.Product hiding (map)\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality\n\nrecord ConstrainedFunctor {c} (Constraint : Set → Set c)\n (f : (A : Set) → Set) : Set (suc c) where\n field\n fmap : ∀ {A B : Set} → {{cA : Constraint A}} → {{cB : Constraint B}} →\n (A → B) → f A → f B\n\nlistConstrainedFunctor : ConstrainedFunctor (const ⊤) List\nlistConstrainedFunctor = record { fmap = map }\n\npostulate\n sort : {A : Set} → {{ordA : ∃ λ (_<_ : A → A → Set) → IsStrictTotalOrder {A = A} _≡_ _<_}} →\n List A → List A\n\n⋯ : ∀ {a} {A : Set a} {{a : A}} → A\n⋯ {{a}} = a\n\nsortedListConstrainedFunctor : ConstrainedFunctor (λ A → ∃ λ (_<_ : A → A → Set) → IsStrictTotalOrder _≡_ _<_) List\nsortedListConstrainedFunctor = record { fmap = λ {{x}} {{y}} → map' {{x}} {{y}} } where\n map' : {A B : Set} → {{ordA : ∃ λ (_<_ : A → A → Set) → (IsStrictTotalOrder _≡_ _<_)}} →\n {{ordB : ∃ λ (_<_ : B → B → Set) → (IsStrictTotalOrder _≡_ _<_)}} →\n (A → B) → List A → List B\n map' f = sort ∘′ map f\n", "meta": {"hexsha": "01e6cff6eb138b7b2c372c495036a2ef49c4d407", "size": 1355, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/instance-arguments/12-constraintFamilies.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/instance-arguments/12-constraintFamilies.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/instance-arguments/12-constraintFamilies.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 35.6578947368, "max_line_length": 115, "alphanum_fraction": 0.6022140221, "num_tokens": 466, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677737461007, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.6146666393843453}} {"text": "\nmodule Lib.List where\n\nopen import Lib.Prelude\nopen import Lib.Id\n\ninfix 30 _∈_\ninfixr 40 _::_ _++_\ninfix 45 _!_\n\ndata List (A : Set) : Set where\n [] : List A\n _::_ : A -> List A -> List A\n\n{-# COMPILED_DATA List [] [] (:) #-}\n{-# BUILTIN LIST List #-}\n{-# BUILTIN NIL [] #-}\n{-# BUILTIN CONS _::_ #-}\n\n_++_ : {A : Set} -> List A -> List A -> List A\n[] ++ ys = ys\n(x :: xs) ++ ys = x :: (xs ++ ys)\n\nfoldr : {A B : Set} -> (A -> B -> B) -> B -> List A -> B\nfoldr f z [] = z\nfoldr f z (x :: xs) = f x (foldr f z xs)\n\nmap : {A B : Set} -> (A -> B) -> List A -> List B\nmap f [] = []\nmap f (x :: xs) = f x :: map f xs\n\nmap-id : forall {A}(xs : List A) -> map id xs ≡ xs\nmap-id [] = refl\nmap-id (x :: xs) with map id xs | map-id xs\n... | .xs | refl = refl\n\ndata _∈_ {A : Set} : A -> List A -> Set where\n hd : forall {x xs} -> x ∈ x :: xs\n tl : forall {x y xs} -> x ∈ xs -> x ∈ y :: xs\n\ndata All {A : Set}(P : A -> Set) : List A -> Set where\n [] : All P []\n _::_ : forall {x xs} -> P x -> All P xs -> All P (x :: xs)\n\nhead : forall {A}{P : A -> Set}{x xs} -> All P (x :: xs) -> P x\nhead (x :: xs) = x\n\ntail : forall {A}{P : A -> Set}{x xs} -> All P (x :: xs) -> All P xs\ntail (x :: xs) = xs\n\n_!_ : forall {A}{P : A -> Set}{x xs} -> All P xs -> x ∈ xs -> P x\nxs ! hd = head xs\nxs ! tl n = tail xs ! n\n\ntabulate : forall {A}{P : A -> Set}{xs} -> ({x : A} -> x ∈ xs -> P x) -> All P xs\ntabulate {xs = []} f = []\ntabulate {xs = x :: xs} f = f hd :: tabulate (f ∘ tl)\n\nmapAll : forall {A B}{P : A -> Set}{Q : B -> Set}{xs}(f : A -> B) ->\n ({x : A} -> P x -> Q (f x)) -> All P xs -> All Q (map f xs)\nmapAll f h [] = []\nmapAll f h (x :: xs) = h x :: mapAll f h xs\n\nmapAll- : forall {A}{P Q : A -> Set}{xs} ->\n ({x : A} -> P x -> Q x) -> All P xs -> All Q xs\nmapAll- {xs = xs} f zs with map id xs | map-id xs | mapAll id f zs\n... | .xs | refl | r = r\n\ninfix 20 _⊆_\n\ndata _⊆_ {A : Set} : List A -> List A -> Set where\n stop : [] ⊆ []\n drop : forall {xs y ys} -> xs ⊆ ys -> xs ⊆ y :: ys\n keep : forall {x xs ys} -> xs ⊆ ys -> x :: xs ⊆ x :: ys\n\n⊆-refl : forall {A}{xs : List A} -> xs ⊆ xs\n⊆-refl {xs = []} = stop\n⊆-refl {xs = x :: xs} = keep ⊆-refl\n\n_∣_ : forall {A}{P : A -> Set}{xs ys} -> All P ys -> xs ⊆ ys -> All P xs\n[] ∣ stop = []\n(x :: xs) ∣ drop p = xs ∣ p\n(x :: xs) ∣ keep p = x :: (xs ∣ p)\n", "meta": {"hexsha": "fd2f1a3719d7f4fb59eb0ea129f740a7b26224b3", "size": 2357, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/simple-lib/Lib/List.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "examples/simple-lib/Lib/List.agda", "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/simple-lib/Lib/List.agda", "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 28.0595238095, "max_line_length": 81, "alphanum_fraction": 0.450572762, "num_tokens": 952, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677660619633, "lm_q2_score": 0.7248702880639791, "lm_q1q2_score": 0.6146666388543043}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Indexed universes\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Universe.Indexed where\n\nopen import Data.Product\nopen import Data.Universe\nopen import Function\nopen import Level\n\n------------------------------------------------------------------------\n-- Definitions\n\nrecord IndexedUniverse i u e : Set (suc (i ⊔ u ⊔ e)) where\n field\n I : Set i -- Index set.\n U : I → Set u -- Codes.\n El : ∀ {i} → U i → Set e -- Decoding function.\n\n -- An indexed universe can be turned into an unindexed one.\n\n unindexed-universe : Universe (i ⊔ u) e\n unindexed-universe = record\n { U = ∃ λ i → U i\n ; El = El ∘ proj₂\n }\n", "meta": {"hexsha": "8012079769e580190d77a383c763125321e23434", "size": 845, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/Universe/Indexed.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Data/Universe/Indexed.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Data/Universe/Indexed.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 26.40625, "max_line_length": 72, "alphanum_fraction": 0.4461538462, "num_tokens": 187, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8872045877523147, "lm_q2_score": 0.6926419894793248, "lm_q1q2_score": 0.6145151507359474}} {"text": "module Cats.Util.Monad where\n\nopen import Category.Monad public\n\nopen import Data.List using (List ; [] ; _∷_ ; map)\nopen import Data.Unit using (⊤)\nopen import Function using (_∘_)\nopen import Level using (Lift ; lift)\n\nopen RawMonad {{...}} public\n\n\nprivate\n _<*>_ = _⊛_\n\n\nmodule _ {f} {M : Set f → Set f} {{_ : RawMonad M}} where\n\n sequence : ∀ {A} → List (M A) → M (List A)\n sequence [] = return []\n sequence (mx ∷ mxs) = ⦇ mx ∷ sequence mxs ⦈\n\n\n void : ∀ {A} → M A → M (Lift f ⊤)\n void m = m >>= λ _ → return _\n\n\n mapM : ∀ {a} {A : Set a} {B} → (A → M B) → List A → M (List B)\n mapM f = sequence ∘ map f\n\n\n mapM′ : ∀ {a} {A : Set a} {B} → (A → M B) → List A → M (Lift f ⊤)\n mapM′ f = void ∘ mapM f\n", "meta": {"hexsha": "6d2685e922e4cfe3f7188934ce6b55045a96e255", "size": 713, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Util/Monad.agda", "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cats/Util/Monad.agda", "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cats/Util/Monad.agda", "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.9705882353, "max_line_length": 67, "alphanum_fraction": 0.5497896213, "num_tokens": 275, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8872045877523147, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.6145151451069992}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\nimport homotopy.ConstantToSetExtendsToProp as ConstExt\nopen import homotopy.Pigeonhole\n\nmodule homotopy.FinSet where\n\n-- the explicit type of finite sets, carrying the cardinality on its sleeve\nFinSet-exp : Type₁\nFinSet-exp = Σ ℕ λ n → BAut (Fin n)\n\nFinSet-prop : SubtypeProp Type₀ (lsucc lzero)\nFinSet-prop = (λ A → Trunc -1 (Σ ℕ λ n → Fin n == A)) , λ A → Trunc-level\n\n-- the implicit type of finite sets, hiding the cardinality in prop. trunc.\nFinSet : Type₁\nFinSet = Subtype FinSet-prop\n\nFinSet= : {A B : FinSet} → fst A == fst B → A == B\nFinSet= = Subtype=-out FinSet-prop\n\nFinFS : ℕ → FinSet\nFinFS n = Fin n , [ n , idp ]\n\nUnitFS : FinSet\nUnitFS = ⊤ , [ S O , ua Fin-equiv-Coprod ∙ ap (λ C → C ⊔ ⊤) (ua Fin-equiv-Empty)\n ∙ ua (Coprod-unit-l ⊤) ]\n\nFin-inj-lemma : {n m : ℕ} → n < m → Fin m == Fin n → ⊥\nFin-inj-lemma {n} {m} n Set where\n refl : x == x\n\npostulate\n Nat : Set\n\ndata G : Nat -> Nat -> Set where\n I : (place : Nat) -> G place place\n s : (n m : Nat) -> G n m\n\nmul : (l m n : Nat) -> G m n -> G l m -> G l n\nmul a b .b (I .b) x = x\nmul a .a b x (I .a) = x\nmul a b c (s .b .c) (s .a .b) = s a c\n\npostulate\n a b c : Nat\n f : G a b\n\nbad : mul a a b (s a b) (I a) == s a b\nbad = refl\n", "meta": {"hexsha": "489c49fd0562b178ad7fe3a42723ff0bff4f3912", "size": 464, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue451.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue451.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue451.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 17.8461538462, "max_line_length": 50, "alphanum_fraction": 0.463362069, "num_tokens": 203, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802507195635, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.6143533153094536}} {"text": "{-# OPTIONS --without-K --safe #-}\n\n-- Singleton type and its 'inverse'\n\nmodule Singleton where\n\nopen import Data.Unit using (⊤; tt)\nopen import Data.Sum\nopen import Data.Product\nopen import Relation.Binary.PropositionalEquality\n using (_≡_; refl; sym; trans; subst; cong ; cong₂ ; inspect ; [_])\n-- open import Level\n-- using (zero)\n-- open import Axiom.Extensionality.Propositional\n-- using (Extensionality)\n\nis-contr : Set → Set\nis-contr A = Σ A (λ a → (x : A) → a ≡ x)\n\nis-prop : Set → Set\nis-prop A = (x y : A) → x ≡ y\n\nis-set : Set → Set\nis-set A = (x y : A) → is-prop (x ≡ y)\n\ncontr-prop : {A : Set} → is-contr A → is-prop A\ncontr-prop (a , ϕ) x y = trans (sym (ϕ x)) (ϕ y)\n\napd : ∀ {a b} {A : Set a} {B : A → Set b} (f : (x : A) → B x) {x y} → (p : x ≡ y) → subst B p (f x) ≡ f y\napd f refl = refl\n\nprop-set : {A : Set} → is-prop A → is-set A\nprop-set {A} ϕ x y p q = trans (l p) (sym (l q))\n where g : (z : A) → x ≡ z\n g z = ϕ x z\n unitr : {y z : A} (p : y ≡ z) → refl ≡ trans (sym p) p\n unitr refl = refl\n l : {y z : A} (p : y ≡ z) → p ≡ trans (sym (g y)) (g z)\n l refl = unitr (g _)\n\nprop-contr : {A : Set} → is-prop A → A → is-contr A\nprop-contr ϕ a = a , ϕ a\n\n------------------------------------------------------------------------------\n-- Singleton type: A type with a distinguished point\n-- The 'interesting' part is that the point is both a parameter\n-- and a field.\n\n{--\nrecord Singleton (A : Set) (v : A) : Set where\n constructor ⇑\n field\n ● : A\n v≡● : v ≡ ●\n\nopen Singleton public\n--}\n\nSingleton : (A : Set) → (v : A) → Set\nSingleton A v = ∃ (λ ● → v ≡ ●)\n\n-- Singleton types are contractible:\npointed-contr : {A : Set} {v : A} → is-contr (Singleton A v)\n--pointed-contr {A} {v} = ⇑ v refl , λ { (⇑ ● refl) → refl }\npointed-contr {A} {v} = (v , refl) , λ { ( ● , refl) → refl }\n\n-- and thus have all paths between them:\npointed-all-paths : {A : Set} {v : A} {p q : Singleton A v} → p ≡ q\npointed-all-paths = contr-prop pointed-contr _ _\n\n-- What does Singleton of Singleton do?\n-- Values of type Singleton A v are of the form (w , p) where p : v ≡ w\n-- Values of type Singleton (Singleton A v) x\n\nssv : (A : Set) (v : A) (x : Singleton A v) → Singleton (Singleton A v) x\nssv A v (.v , refl) = (v , refl) , refl\n\n{--\nss=s : (A : Set) (v : A) (x : Singleton A v) → Singleton (Singleton A v) x ≡ Singleton A v\nss=s A v (.v , refl) with pointed-contr {A} {v}\n... | (.v , refl) , f = let p = f (v , refl) in {!!} -- ??\n--}\n------------------------------------------------------------------------------\n-- The 'reciprocal' of a Singleton type is a function that accepts exactly\n-- that point, and returns no information. It acts as a 'witness' that\n-- the right point has been fed to it.\n{--\nRecip : (A : Set) → (v : A) → Set\nRecip A v = (w : A) → (v ≡ w) → ⊤\n--}\n\nRecip : (A : Set) → (v : A) → Set\nRecip A v = Singleton A v → ⊤\n\n-- Recip A v = Singleton A v → ⊤\n\n-- Recip is also contractible, if we're thinking of homotopy types.\n-- We need funext to prove it which is not --safe\n\n-- posulate\n-- funext : Extensionality zero zero\n\n-- recip-contr : {A : Set} {v : A} → is-contr (Recip A v)\n-- recip-contr = (λ _ _ → tt) , λ r → funext λ _ → funext λ _ → refl\n\n\n------------------------------------------------------------------------------\n\n-- Recip' : {A : Set} {v : A} → Singleton A v → Set\n-- Recip' {A} {v} (⇑ w v≡w) = v ≡ w\n\n-- Recip'-ptd : {A : Set} {v : A} → (p : Singleton A v) → Singleton (Recip' p) (v≡● p)\n-- Recip'-ptd (⇑ w v≡w) = ⇑ v≡w refl\n\n-- family of path types from arbitrary w to a fixed v\n\nRecip' : (A : Set) → (v : A) → Set\nRecip' A v = (w : A) → v ≡ w\n\n-- If A is a n-type, Recip' is a (n-1)-type\n\n-- recip'-contr : {A : Set} {v : A} → is-prop A → is-contr (Recip' A v)\n-- recip'-contr {A} {v} ϕ = (λ w → ϕ v w) , λ r → funext λ x → prop-set ϕ v x (ϕ v x) (r x)\n\n-- recip'-prop : {A : Set} {v : A} → is-set A → is-prop (Recip' A v)\n-- recip'-prop ϕ r s = funext (λ x → ϕ _ x (r x) (s x))\n\n------------------------------------------------------------------------------\n-- Singleton is an idempotent bimonad on pointed sets\n-- (need to check some coherences)\n\n∙Set = Σ Set (λ X → X)\n\n∙Set[_,_] : ∙Set → ∙Set → Set\n∙Set[ (A , a) , (B , b) ] = Σ (A → B) λ f → f a ≡ b\n\n_∙×_ : ∙Set → ∙Set → ∙Set\n(A , a) ∙× (B , b) = (A × B) , (a , b)\n\n-- left version, there's also a right version\n-- note that this isn't a coproduct\n-- wedge sum is the coproduct\n_∙+_ : ∙Set → ∙Set → ∙Set\n(A , a) ∙+ (B , b) = (A ⊎ B) , inj₁ a\n\n∙id : ∀{∙A} → ∙Set[ ∙A , ∙A ]\n∙id = (λ a → a) , refl\n\n_∘_ : ∀ {∙A ∙B ∙C} → ∙Set[ ∙A , ∙B ] → ∙Set[ ∙B , ∙C ] → ∙Set[ ∙A , ∙C ]\n(f , p) ∘ (g , q) = (λ x → g (f x)) , trans (cong g p) q\n\n-- terminal and initial\n∙1 : ∙Set\n∙1 = ⊤ , tt\n\n∙![_] : ∀ ∙A → ∙Set[ ∙A , ∙1 ]\n∙![ (A , a) ] = (λ _ → tt) , refl\n\n∙!-uniq : ∀ {∙A} {x : ∙A .proj₁} → (∙f : ∙Set[ ∙A , ∙1 ]) → (∙f .proj₁) x ≡ (∙![ ∙A ] .proj₁) x\n∙!-uniq {A , a} {x} (f , p) = refl\n\n∙¡[_] : ∀ ∙A → ∙Set[ ∙1 , ∙A ]\n∙¡[ A , a ] = (λ _ → a) , refl\n\n∙¡-uniq : ∀ {∙A} → (∙f : ∙Set[ ∙1 , ∙A ]) → (∙f .proj₁) tt ≡ (∙¡[ ∙A ] .proj₁) tt\n∙¡-uniq (f , p) = p\n\nrecord ∙Iso[_,_] (∙A ∙B : ∙Set) : Set where\n constructor iso\n field\n ∙f : ∙Set[ ∙A , ∙B ]\n ∙g : ∙Set[ ∙B , ∙A ]\n f = ∙f .proj₁\n g = ∙g .proj₁\n field\n f-g : ∀ b → f (g b) ≡ b\n g-f : ∀ a → g (f a) ≡ a\n\nopen ∙Iso[_,_]\n\n∙Iso⁻¹ : ∀ {∙A ∙B} → ∙Iso[ ∙A , ∙B ] → ∙Iso[ ∙B , ∙A ]\n∙Iso⁻¹ (iso ∙f ∙g f-g g-f) = iso ∙g ∙f g-f f-g\n\nSing : ∙Set → ∙Set\nSing (A , a) = Singleton A a , a , refl\n\nSing[_,_] : ∀ ∙A ∙B → ∙Set[ ∙A , ∙B ] → ∙Set[ Sing ∙A , Sing ∙B ]\nSing[ (A , a) , (B , .(f a)) ] (f , refl) = (λ { (x , refl) → f x , refl }) , refl\n\n-- monad\nη[_] : ∀ ∙A → ∙Set[ ∙A , Sing ∙A ]\nη[ (A , a) ] = (λ x → a , refl) , refl\n\n-- Sing(A) is terminal\nη-uniq : ∀ {∙A} {x : ∙A .proj₁} → (∙f : ∙Set[ ∙A , Sing ∙A ]) → (∙f .proj₁) x ≡ (η[ ∙A ] .proj₁) x\nη-uniq {A , a} (f , p) = pointed-all-paths\n\nSing≃1 : ∀ {∙A} → ∙Iso[ Sing ∙A , ∙1 ]\nSing≃1 {∙A@(A , a)} = iso ∙![ Sing ∙A ] ( ((λ _ → a) , refl) ∘ η[ ∙A ]) (λ _ → refl) (λ _ → pointed-all-paths)\n\nμ[_] : ∀ ∙A → ∙Iso[ Sing (Sing ∙A) , Sing ∙A ]\nμ[ (A , a) ] = iso ((λ { (.(a , refl) , refl) → a , refl }) , refl)\n ((λ { (a , refl) → (a , refl) , refl }) , refl)\n (λ { (a , refl) → refl})\n (λ { ((a , refl) , refl) → refl })\n\n-- check\nSη-μ : ∀ {∙A} → ((Sing[ ∙A , Sing ∙A ] η[ ∙A ] ∘ (μ[ ∙A ] .∙f)) .proj₁) (∙A .proj₂ , refl) ≡ (∙A .proj₂ , refl)\nSη-μ = refl\n\nηS-μ : ∀ {∙A} → ((Sing[ Sing ∙A , Sing (Sing ∙A) ] η[ Sing ∙A ] ∘ (μ[ Sing ∙A ] .∙f)) .proj₁) ((∙A .proj₂ , refl) , refl) ≡ ((∙A .proj₂ , refl) , refl)\nηS-μ = refl\n\n-- strength\nσ×[_,_] : ∀ ∙A ∙B → ∙Set[ Sing ∙A ∙× ∙B , Sing (∙A ∙× ∙B) ]\nσ×[ (A , a) , (B , b) ] = (λ { ((a , refl) , _) → (a , b) , refl }) , refl\n\nτ×[_,_] : ∀ ∙A ∙B → ∙Set[ ∙A ∙× Sing ∙B , Sing (∙A ∙× ∙B) ]\nτ×[ (A , a) , (B , b) ] = (λ { (_ , (b , refl)) → (a , b) , refl }) , refl\n\nσ+[_,_] : ∀ ∙A ∙B → ∙Set[ Sing ∙A ∙+ ∙B , Sing (∙A ∙+ ∙B) ]\nσ+[ (A , a) , (B , b) ] = (λ _ → inj₁ a , refl) , refl\n\nτ+[_,_] : ∀ ∙A ∙B → ∙Set[ ∙A ∙+ Sing ∙B , Sing (∙A ∙+ ∙B) ]\nτ+[ (A , a) , (B , b) ] = (λ _ → inj₁ a , refl) , refl\n\n-- comonad\nε[_] : ∀ ∙A → ∙Set[ Sing ∙A , ∙A ]\nε[ (A , a) ] = (λ { (x , refl) → x }) , refl\n\nδ[_] : ∀ ∙A → ∙Iso[ Sing ∙A , Sing (Sing ∙A) ]\nδ[ ∙A ] = ∙Iso⁻¹ μ[ ∙A ]\n\n-- check\nδ-Sε : ∀ {∙A} → ((δ[ ∙A ] .∙f ∘ Sing[ Sing ∙A , ∙A ] ε[ ∙A ]) .proj₁) (∙A .proj₂ , refl) ≡ (∙A .proj₂ , refl)\nδ-Sε = refl\n\nδ-εS : ∀ {∙A} → ((δ[ Sing ∙A ] .∙f ∘ Sing[ Sing (Sing ∙A) , Sing ∙A ] ε[ Sing ∙A ]) .proj₁) ((∙A .proj₂ , refl) , refl) ≡ ((∙A .proj₂ , refl) , refl)\nδ-εS = refl\n\n-- costrength\nσ'×[_,_] : ∀ ∙A ∙B → ∙Set[ Sing (∙A ∙× ∙B) , Sing ∙A ∙× ∙B ]\nσ'×[ (A , a) , (B , b) ] = (λ { (.(a , b) , refl) → (a , refl) , b }) , refl\n\nτ'×[_,_] : ∀ ∙A ∙B → ∙Set[ Sing (∙A ∙× ∙B) , ∙A ∙× Sing ∙B ]\nτ'×[ (A , a) , (B , b) ] = (λ { (.(a , b) , refl) → a , (b , refl) }) , refl\n\nσ'+[_,_] : ∀ ∙A ∙B → ∙Set[ Sing (∙A ∙+ ∙B) , Sing ∙A ∙+ ∙B ]\nσ'+[ (A , a) , (B , b) ] = (λ _ → inj₁ (a , refl)) , refl\n\nτ'+[_,_] : ∀ ∙A ∙B → ∙Set[ Sing (∙A ∙+ ∙B) , ∙A ∙+ Sing ∙B ]\nτ'+[ (A , a) , (B , b) ] = (λ _ → inj₁ a) , refl\n\n-- even better, strong monoidal functor\nν×[_,_] : ∀ ∙A ∙B → ∙Iso[ Sing ∙A ∙× Sing ∙B , Sing (∙A ∙× ∙B) ]\nν×[ (A , a) , (B , b) ] = iso ((λ _ → (a , b) , refl) , refl)\n ((λ _ → (a , refl) , b , refl) , refl)\n (λ { (.(a , b) , refl) → refl })\n (λ { ((a , refl) , (b , refl)) → refl })\n\n-- this one is only lax\nν+[_,_] : ∀ ∙A ∙B → ∙Set[ Sing ∙A ∙+ Sing ∙B , Sing (∙A ∙+ ∙B) ]\nν+[ (A , a) , (B , b) ] = (λ _ → inj₁ a , refl) , refl\n\n-- free pointed set\nU : ∙Set → Set\nU = proj₁\n\nU[_,_] : ∀ ∙A ∙B → ∙Set[ ∙A , ∙B ] → (U ∙A → U ∙B)\nU[ _ , _ ] = proj₁\n\nF : Set → ∙Set\nF A = (A ⊎ ⊤) , inj₂ tt\n\nF[_,_] : ∀ A B → (A → B) → ∙Set[ F A , F B ]\nF[ A , B ] f = (λ { (inj₁ a) → inj₁ (f a) ; (inj₂ tt) → inj₂ tt }) , refl\n\n->adj : ∀ {A ∙B} → (A → U ∙B) → ∙Set[ F A , ∙B ]\n->adj f = (λ { (inj₁ a) → f a ; (inj₂ tt) → _ }) , refl\n\n<-adj : ∀ {A ∙B} → ∙Set[ F A , ∙B ] → (A → U ∙B)\n<-adj (f , refl) a = f (inj₁ a)\n\nη-adj : ∀ {A} → (A → U (F A))\nη-adj = <-adj ∙id\n\nε-adj : ∀ {∙A} → ∙Set[ F (U ∙A), ∙A ]\nε-adj = ->adj λ x → x\n\n-- maybe monad\nT : Set → Set\nT A = U (F A)\n\nT-η[_] : ∀ A → (A → T A)\nT-η[ A ] = η-adj\n\nT-μ[_] : ∀ A → (T (T A) → T A)\nT-μ[ A ] = U[ F (T A) , F A ] ε-adj\n\n-- comaybe comonad\nD : ∙Set → ∙Set\nD ∙A = F (U ∙A)\n\nD-ε[_] : ∀ ∙A → ∙Set[ D ∙A , ∙A ]\nD-ε[ ∙A ] = ε-adj\n\nD-δ[_] : ∀ ∙A → ∙Set[ D ∙A , D (D ∙A) ]\nD-δ[ ∙A ] = F[ U ∙A , U (D ∙A) ] η-adj\n\n-- but also\nD-η[_] : ∀ ∙A → ∙Set[ ∙A , D ∙A ]\nD-η[ ∙A ] = (λ _ → inj₂ tt) , refl\n-- D ∙A is not contractible\n\n-- distributive laws?\n-- same as ∙Set[ ∙1 , D ∙1 ] so follows D-η\nΛ : ∀ {∙A} → ∙Set[ Sing (D ∙A) , D (Sing ∙A) ]\nΛ = (λ { (.(inj₂ tt) , refl) → inj₂ tt }) , refl\n", "meta": {"hexsha": "0ec54904ef9ae3e6f8039e3004035d13472975ae", "size": 9825, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "fracGC/Singleton.agda", "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_issues_repo_path": "fracGC/Singleton.agda", "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_forks_repo_path": "fracGC/Singleton.agda", "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "avg_line_length": 30.7993730408, "max_line_length": 151, "alphanum_fraction": 0.4375572519, "num_tokens": 4565, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951104066293, "lm_q2_score": 0.727975443004307, "lm_q1q2_score": 0.6143349168474346}} {"text": "------------------------------------------------------------------------\n-- Products\n------------------------------------------------------------------------\n\nmodule Data.Product where\n\nopen import Data.Function\nopen import Relation.Nullary.Core\n\ninfixr 4 _,_\ninfix 4 ,_\ninfixr 2 _×_ _-×-_ _-,-_\n\n------------------------------------------------------------------------\n-- Definition\n\ndata Σ (A : Set) (B : A → Set) : Set where\n _,_ : (x : A) (y : B x) → Σ A B\n\n∃ : {A : Set} → (A → Set) → Set\n∃ = Σ _\n\n∄ : {A : Set} → (A → Set) → Set\n∄ P = ¬ ∃ P\n\n∃₂ : {A : Set} {B : A → Set} (C : (x : A) → B x → Set) → Set\n∃₂ C = ∃ λ a → ∃ λ b → C a b\n\n_×_ : (A B : Set) → Set\nA × B = Σ A (λ _ → B)\n\n------------------------------------------------------------------------\n-- Functions\n\n-- Sometimes the first component can be inferred.\n\n,_ : ∀ {A} {B : A → Set} {x} → B x → ∃ B\n, y = _ , y\n\nproj₁ : ∀ {A B} → Σ A B → A\nproj₁ (x , y) = x\n\nproj₂ : ∀ {A B} → (p : Σ A B) → B (proj₁ p)\nproj₂ (x , y) = y\n\n<_,_> : ∀ {A} {B : A → Set} {C : ∀ {x} → B x → Set}\n (f : (x : A) → B x) → ((x : A) → C (f x)) →\n ((x : A) → Σ (B x) C)\n< f , g > x = (f x , g x)\n\nmap : ∀ {A B P Q} →\n (f : A → B) → (∀ {x} → P x → Q (f x)) →\n Σ A P → Σ B Q\nmap f g = < f ∘ proj₁ , g ∘ proj₂ >\n\nzip : ∀ {A B C P Q R} →\n (_∙_ : A → B → C) →\n (∀ {x y} → P x → Q y → R (x ∙ y)) →\n Σ A P → Σ B Q → Σ C R\nzip _∙_ _∘_ p₁ p₂ = (proj₁ p₁ ∙ proj₁ p₂ , proj₂ p₁ ∘ proj₂ p₂)\n\nswap : ∀ {A B} → A × B → B × A\nswap = < proj₂ , proj₁ >\n\n_-×-_ : ∀ {A B} → (A → B → Set) → (A → B → Set) → (A → B → Set)\nf -×- g = f -[ _×_ ]₁- g\n\n_-,-_ : ∀ {A B C D} → (A → B → C) → (A → B → D) → (A → B → C × D)\nf -,- g = f -[ _,_ ]- g\n\ncurry : {A : Set} {B : A → Set} {C : Σ A B → Set} →\n ((p : Σ A B) → C p) →\n ((x : A) → (y : B x) → C (x , y))\ncurry f x y = f (x , y)\n\nuncurry : {A : Set} {B : A → Set} {C : Σ A B → Set} →\n ((x : A) → (y : B x) → C (x , y)) →\n ((p : Σ A B) → C p)\nuncurry f (p₁ , p₂) = f p₁ p₂\n", "meta": {"hexsha": "3e5484bbefd5c0465f9e8081b7690117ecf479bd", "size": 2006, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Data/Product.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Data/Product.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Data/Product.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 25.075, "max_line_length": 72, "alphanum_fraction": 0.3250249252, "num_tokens": 861, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950947024555, "lm_q2_score": 0.7279754371026368, "lm_q1q2_score": 0.6143349004347911}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Utils.Product where\n\nopen import Level\nopen import Data.Product using (_×_; Σ; _,_; proj₁; proj₂)\nopen import Relation.Binary.PropositionalEquality\n\n-- \"very dependent\" versions of map and zipWith\nmap⁎ : ∀ {a b p q} {A : Set a} {B : A → Set b} {P : A → Set p} {Q : {x : A} → P x → B x → Set q} →\n (f : (x : A) → B x) → (∀ {x} → (y : P x) → Q y (f x)) → (v : Σ A P) → Σ (B (proj₁ v)) (Q (proj₂ v))\nmap⁎ f g (x , y) = (f x , g y)\n\nmap⁎′ : ∀ {a b p q} {A : Set a} {B : A → Set b} {P : Set p} {Q : P → Set q} → (f : (x : A) → B x) → ((x : P) → Q x) → (v : A × P) → B (proj₁ v) × Q (proj₂ v)\nmap⁎′ f g (x , y) = (f x , g y)\n\nzipWith : ∀ {a b c p q r s} {A : Set a} {B : Set b} {C : Set c} {P : A → Set p} {Q : B → Set q} {R : C → Set r} {S : (x : C) → R x → Set s} (_∙_ : A → B → C) → (_∘_ : ∀ {x y} → P x → Q y → R (x ∙ y)) → (_*_ : (x : C) → (y : R x) → S x y) → (x : Σ A P) → (y : Σ B Q) → S (proj₁ x ∙ proj₁ y) (proj₂ x ∘ proj₂ y)\nzipWith _∙_ _∘_ _*_ (a , p) (b , q) = (a ∙ b) * (p ∘ q)\nsyntax zipWith f g h = f -< h >- g\n", "meta": {"hexsha": "86543bbcbd8256cadfa5d13a278893f72aa6ce65", "size": 1079, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Utils/Product.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Utils/Product.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Utils/Product.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 56.7894736842, "max_line_length": 309, "alphanum_fraction": 0.4522706209, "num_tokens": 510, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950868503681, "lm_q2_score": 0.7279754371026367, "lm_q1q2_score": 0.6143348947186642}} {"text": "{-# OPTIONS --without-K #-}\nopen import HoTT.Base\nopen import HoTT.Equivalence\n\nmodule HoTT.Identity.Universe {i} {A B : 𝒰 i} where\n\n-- Axiom 2.10.3 - univalence\npostulate\n idtoeqv-equiv : isequiv (idtoeqv {A = A} {B = B})\n\n=𝒰-equiv : (A == B) ≃ (A ≃ B)\n=𝒰-equiv = idtoeqv , idtoeqv-equiv\n\nmodule _ where\n open qinv (isequiv→qinv idtoeqv-equiv)\n abstract\n ua : A ≃ B → A == B\n ua = g\n =𝒰-η : ua ∘ idtoeqv ~ id\n =𝒰-η = η\n =𝒰-β : idtoeqv ∘ ua ~ id\n =𝒰-β = ε\n\n_=𝒰_ = _≃_\n", "meta": {"hexsha": "263911ee88276a4d9e5d195aded8395f449ebc05", "size": 489, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "HoTT/Identity/Universe.agda", "max_stars_repo_name": "michaelforney/hott", "max_stars_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_stars_repo_licenses": ["0BSD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "HoTT/Identity/Universe.agda", "max_issues_repo_name": "michaelforney/hott", "max_issues_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_issues_repo_licenses": ["0BSD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HoTT/Identity/Universe.agda", "max_forks_repo_name": "michaelforney/hott", "max_forks_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_forks_repo_licenses": ["0BSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.56, "max_line_length": 51, "alphanum_fraction": 0.5807770961, "num_tokens": 224, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.913676530465412, "lm_q2_score": 0.6723316926137811, "lm_q1q2_score": 0.6142936882292974}} {"text": "{-\n\nThe Inductive Version of James Construction\n\nThis file contains:\n - An inductive family 𝕁, and its direct colimit is equivalence to James;\n (KANG Rongji, Feb. 2022)\n - The family 𝕁 can be iteratively constructed as pushouts;\n - Special cases of 𝕁 n for n = 0, 1 and 2;\n - Connectivity of inclusion maps.\n\nThis file is the summary of the main results.\nThe proof is divided into parts and put inside the fold Cubical.HITs.James.Inductive\n\n-}\n{-# OPTIONS --safe #-}\nmodule Cubical.HITs.James.Inductive where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Pointed\n\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Unit\nopen import Cubical.Data.Sigma\n\nopen import Cubical.HITs.Wedge\nopen import Cubical.HITs.Pushout\nopen import Cubical.HITs.Pushout.PushoutProduct\nopen import Cubical.HITs.SequentialColimit\n\nopen import Cubical.HITs.James.Base\nopen import Cubical.HITs.James.Inductive.Base\nopen import Cubical.HITs.James.Inductive.PushoutFormula\n renaming (isConnectedIncl to connIncl ; isConnectedInl to connInl)\nopen import Cubical.HITs.James.Inductive.Reduced\nopen import Cubical.HITs.James.Inductive.ColimitEquivalence\n\nopen import Cubical.Homotopy.Connected\n\nprivate\n variable\n ℓ : Level\n\nmodule JamesInd\n (X∙@(X , x₀) : Pointed ℓ) where\n\n -- The family 𝕁 n is equivalence to Brunerie's J n, as will be shown latter.\n -- Instead of his inductive procedure, 𝕁 is defined directly as an indexed HIT.\n\n 𝕁 : ℕ → Type ℓ\n 𝕁 = 𝕁ames (X , x₀)\n\n -- This family forms a direct system.\n\n 𝕁Seq : Sequence ℓ\n 𝕁Seq = 𝕁amesSeq (X , x₀)\n\n -- The inductive construction of James is called 𝕁∞.\n -- It is the direct colimit of 𝕁 n.\n\n 𝕁∞ : Type ℓ\n 𝕁∞ = Lim→ 𝕁Seq\n\n -- And of course it is equivalent to James.\n\n J≃𝕁∞ : James (X , x₀) ≃ 𝕁∞\n J≃𝕁∞ = compEquiv (James≃𝕁Red∞ _) (invEquiv (𝕁ames∞≃𝕁Red∞ _))\n\n -- Special cases of 𝕁 n for n = 0, 1 and 2:\n\n 𝕁₀≃Unit : 𝕁 0 ≃ Unit\n 𝕁₀≃Unit = 𝕁ames0≃ _\n\n 𝕁₁≃X : 𝕁 1 ≃ X\n 𝕁₁≃X = 𝕁ames1≃ _\n\n 𝕁₂≃P[X×X←X⋁X→X] : 𝕁 2 ≃ Pushout ⋁↪ fold⋁\n 𝕁₂≃P[X×X←X⋁X→X] = 𝕁ames2≃ _\n\n -- The following is defined as pushouts of 𝕁 n.\n\n 𝕁Push : ℕ → Type ℓ\n 𝕁Push = 𝕁amesPush (X , x₀)\n\n -- Brunerie uses f and g to denote the following maps, so do I.\n\n module _\n {n : ℕ} where\n\n f : 𝕁Push n → X × 𝕁 (1 + n)\n f = leftMap _\n\n g : 𝕁Push n → 𝕁 (1 + n)\n g = rightMap _\n\n -- Here we show that 𝕁 (n+2) can be made as double pushouts invoving only X, 𝕁 n and 𝕁 (n+1).\n -- In particular, our 𝕁 is exactly what Brunerie had defined.\n\n 𝕁ₙ₊₂≃Pushout : (n : ℕ) → 𝕁 (2 + n) ≃ Pushout f g\n 𝕁ₙ₊₂≃Pushout = 𝕁ames2+n≃ _\n\n -- Connectivity of inclusion maps:\n\n module _\n (d : ℕ)(conn : isConnected (1 + d) X) where\n\n -- Warning:\n -- The connectivity is shifted by 2 from the convention of usual homotopy theory.\n\n -- If X is (d+1)-connected, the transition incl : 𝕁 n → 𝕁 (n+1) will be (n+1)d-connected.\n\n isConnectedIncl : (n : ℕ) → isConnectedFun ((1 + n) · d) (incl {n = n})\n isConnectedIncl = connIncl X∙ d conn\n\n -- If X is (d+1)-connected, the inclusion inl : 𝕁 n → 𝕁∞ will be (n+1)d-connected.\n\n inl∞ : (n : ℕ) → 𝕁 n → 𝕁∞\n inl∞ _ = inl\n\n isConnectedInl : (n : ℕ) → isConnectedFun ((1 + n) · d) (inl∞ n)\n isConnectedInl = connInl X∙ d conn\n", "meta": {"hexsha": "f9ff07564f28547aa827f396f8873daa18e78c2b", "size": 3283, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/James/Inductive.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_issues_repo_path": "Cubical/HITs/James/Inductive.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/HITs/James/Inductive.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.6910569106, "max_line_length": 95, "alphanum_fraction": 0.6710325921, "num_tokens": 1257, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8333246035907933, "lm_q2_score": 0.7371581741774411, "lm_q1q2_score": 0.6142920432801291}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category.Core using (Category)\n\nmodule Categories.Diagram.Coequalizer {o ℓ e} (𝒞 : Category o ℓ e) where\n\nopen Category 𝒞\nopen HomReasoning\nopen Equiv\n\nopen import Categories.Morphism 𝒞\nopen import Categories.Morphism.Reasoning 𝒞\n\nopen import Level\nopen import Function using (_$_)\n\nprivate\n variable\n A B C : Obj\n h i j k : A ⇒ B\n\nrecord IsCoequalizer {E} (f g : A ⇒ B) (arr : B ⇒ E) : Set (o ⊔ ℓ ⊔ e) where\n field\n equality : arr ∘ f ≈ arr ∘ g\n coequalize : {h : B ⇒ C} → h ∘ f ≈ h ∘ g → E ⇒ C\n universal : {h : B ⇒ C} {eq : h ∘ f ≈ h ∘ g} → h ≈ coequalize eq ∘ arr\n unique : {h : B ⇒ C} {i : E ⇒ C} {eq : h ∘ f ≈ h ∘ g} → h ≈ i ∘ arr → i ≈ coequalize eq\n\n unique′ : (eq eq′ : h ∘ f ≈ h ∘ g) → coequalize eq ≈ coequalize eq′\n unique′ eq eq′ = unique universal\n\n id-coequalize : id ≈ coequalize equality\n id-coequalize = unique (⟺ identityˡ)\n\n coequalize-resp-≈ : ∀ {eq : h ∘ f ≈ h ∘ g} {eq′ : i ∘ f ≈ i ∘ g} →\n h ≈ i → coequalize eq ≈ coequalize eq′\n coequalize-resp-≈ {h = h} {i = i} {eq = eq} {eq′ = eq′} h≈i = unique $ begin\n i ≈˘⟨ h≈i ⟩\n h ≈⟨ universal ⟩\n coequalize eq ∘ arr ∎\n\n coequalize-resp-≈′ : (eq : h ∘ f ≈ h ∘ g) → (eq′ : i ∘ f ≈ i ∘ g) →\n h ≈ i → j ≈ coequalize eq → k ≈ coequalize eq′ → j ≈ k\n coequalize-resp-≈′ {j = j} {k = k} eq eq′ h≈i eqj eqk = begin\n j ≈⟨ eqj ⟩\n coequalize eq ≈⟨ coequalize-resp-≈ h≈i ⟩\n coequalize eq′ ≈˘⟨ eqk ⟩\n k ∎\n\n-- This could be proved via duality, but is easier to just write by hand,\n-- as it makes the dependency graph a lot cleaner.\nIsCoequalizer⇒Epi : IsCoequalizer h i j → Epi j\nIsCoequalizer⇒Epi coeq _ _ eq =\n coequalize-resp-≈′ (extendˡ equality) (extendˡ equality) eq (unique refl) (unique refl)\n where\n open IsCoequalizer coeq\n\nrecord Coequalizer (f g : A ⇒ B) : Set (o ⊔ ℓ ⊔ e) where\n field\n {obj} : Obj\n arr : B ⇒ obj\n isCoequalizer : IsCoequalizer f g arr\n\n open IsCoequalizer isCoequalizer public\n\nCoequalizer⇒Epi : (e : Coequalizer h i) → Epi (Coequalizer.arr e)\nCoequalizer⇒Epi coeq = IsCoequalizer⇒Epi isCoequalizer\n where\n open Coequalizer coeq\n\n-- Proving this via duality arguments is kind of annoying, as ≅ does not behave nicely in\n-- concert with op.\nup-to-iso : (coe₁ coe₂ : Coequalizer h i) → Coequalizer.obj coe₁ ≅ Coequalizer.obj coe₂\nup-to-iso coe₁ coe₂ = record\n { from = repack coe₁ coe₂\n ; to = repack coe₂ coe₁\n ; iso = record\n { isoˡ = repack-cancel coe₂ coe₁\n ; isoʳ = repack-cancel coe₁ coe₂\n }\n }\n where\n open Coequalizer\n\n repack : (coe₁ coe₂ : Coequalizer h i) → obj coe₁ ⇒ obj coe₂\n repack coe₁ coe₂ = coequalize coe₁ (equality coe₂)\n\n repack∘ : (coe₁ coe₂ coe₃ : Coequalizer h i) → repack coe₂ coe₃ ∘ repack coe₁ coe₂ ≈ repack coe₁ coe₃\n repack∘ coe₁ coe₂ coe₃ = unique coe₁ (⟺ (glueTrianglesˡ (⟺ (universal coe₂)) (⟺ (universal coe₁)))) -- unique e₃ (⟺ (glueTrianglesʳ (⟺ (universal e₃)) (⟺ (universal e₂))))\n\n repack-cancel : (e₁ e₂ : Coequalizer h i) → repack e₁ e₂ ∘ repack e₂ e₁ ≈ id\n repack-cancel coe₁ coe₂ = repack∘ coe₂ coe₁ coe₂ ○ ⟺ (id-coequalize coe₂)\n\nIsCoequalizer⇒Coequalizer : IsCoequalizer h i k → Coequalizer h i\nIsCoequalizer⇒Coequalizer {k = k} is-coe = record\n { arr = k\n ; isCoequalizer = is-coe\n }\n", "meta": {"hexsha": "fe7161ba8ea84e59d5a849592fb1cc859481e079", "size": 3355, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Diagram/Coequalizer.agda", "max_stars_repo_name": "maxsnew/agda-categories", "max_stars_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Diagram/Coequalizer.agda", "max_issues_repo_name": "maxsnew/agda-categories", "max_issues_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Diagram/Coequalizer.agda", "max_forks_repo_name": "maxsnew/agda-categories", "max_forks_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.8888888889, "max_line_length": 175, "alphanum_fraction": 0.6140089419, "num_tokens": 1395, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933447152497, "lm_q2_score": 0.7490872187162397, "lm_q1q2_score": 0.6141716252367015}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- W-types\n------------------------------------------------------------------------\n\nmodule Data.W where\n\nopen import Level\nopen import Relation.Nullary\n\n-- The family of W-types.\n\ndata W {a b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where\n sup : (x : A) (f : B x → W A B) → W A B\n\n-- Projections.\n\nhead : ∀ {a b} {A : Set a} {B : A → Set b} →\n W A B → A\nhead (sup x f) = x\n\ntail : ∀ {a b} {A : Set a} {B : A → Set b} →\n (x : W A B) → B (head x) → W A B\ntail (sup x f) = f\n\n-- If B is always inhabited, then W A B is empty.\n\ninhabited⇒empty : ∀ {a b} {A : Set a} {B : A → Set b} →\n (∀ x → B x) → ¬ W A B\ninhabited⇒empty b (sup x f) = inhabited⇒empty b (f (b x))\n", "meta": {"hexsha": "4d47f7b1749217bb1f56e83b4acfcc9dcbef3a7b", "size": 799, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/W.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/W.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Data/W.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.96875, "max_line_length": 72, "alphanum_fraction": 0.4130162703, "num_tokens": 270, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8824278664544911, "lm_q2_score": 0.6959583250334525, "lm_q1q2_score": 0.6141330199005107}} {"text": "import Lvl\n\nmodule Function.Names where\n\nopen import Functional.Dependent\nopen import Logic.Predicate\nopen import Structure.Setoid\nopen import Type\n\nprivate variable ℓ ℓₒ ℓₒ₁ ℓₒ₂ ℓₒ₃ ℓₗ ℓₗ₁ ℓₗ₂ ℓₗ₃ : Lvl.Level\n\nmodule _ {A : Type{ℓₒ₁}} {B : A → Type{ℓₒ₂}} ⦃ _ : ∀{a} → Equiv{ℓₗ₃}(B(a)) ⦄ where\n -- Extensional equality on functions.\n -- Alternative definition: f ⊜ g = (∀{x} → (f(x) ≡ g(x)))\n _⊜_ : ((a : A) → B(a)) → ((a : A) → B(a)) → Type\n _⊜_ = ∀¹ ∘₂ pointwise₂,₁(_≡_)\n _⊜₁_ = _⊜_\n\nmodule _ {A : Type{ℓₒ₁}} {B : A → Type{ℓₒ₂}} ⦃ _ : ∀{a} → Equiv{ℓₗ₃}(B(a)) ⦄ where\n _⊜ᵢ_ : ({a : A} → B(a)) → ({a : A} → B(a)) → Type\n _⊜ᵢ_ f g = (∀{x} → (f{x} ≡ g{x}))\n\nmodule _ {A : Type{ℓₒ₁}} {B : A → Type{ℓₒ₂}} ⦃ _ : ∀{a} → Equiv{ℓₗ₃}(B(a)) ⦄ where\n _⦃⊜⦄_ : (⦃ a : A ⦄ → B(a)) → (⦃ a : A ⦄ → B(a)) → Type\n _⦃⊜⦄_ f g = (∀{x} → (f ⦃ x ⦄ ≡ g ⦃ x ⦄))\n\nmodule _ {A₁ : Type{ℓₒ₁}} {A₂ : A₁ → Type{ℓₒ₂}} {B : (a₁ : A₁) → A₂(a₁) → Type{ℓₒ₂}} ⦃ _ : ∀{a₁}{a₂} → Equiv{ℓₗ₃}(B(a₁)(a₂)) ⦄ where\n -- Alternative definition: f ⊜ g = (∀{x}{y} → (f(x)(y) ≡ g(x)(y)))\n _⊜₂_ : (f g : ∀(a₁)(a₂) → B(a₁)(a₂)) → Type\n _⊜₂_ = ∀¹ ∘₂ (∀¹ ∘₃ pointwise₂,₂(_≡_))\n\nmodule _ {A₁ : Type{ℓₒ₁}} {A₂ : A₁ → Type{ℓₒ₂}} {A₃ : (a₁ : A₁) → A₂(a₁) → Type{ℓₒ₂}} {B : (a₁ : A₁) → (a₂ : A₂(a₁)) → A₃(a₁)(a₂) → Type{ℓₒ₂}} ⦃ _ : ∀{a₁}{a₂}{a₃} → Equiv{ℓₗ₃}(B(a₁)(a₂)(a₃)) ⦄ where\n -- Alternative definition: f ⊜ g = (∀{x}{y}{z} → (f(x)(y)(z) ≡ g(x)(y)(z)))\n _⊜₃_ : (f g : ∀(a₁)(a₂)(a₃) → B(a₁)(a₂)(a₃)) → Type\n _⊜₃_ = ∀¹ ∘₂ (∀¹ ∘₃ (∀¹ ∘₄ pointwise₂,₃(_≡_)))\n", "meta": {"hexsha": "1dcf737765b94986b7daab4dddcf4349d1a81817", "size": 1522, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Function/Names.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Function/Names.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Function/Names.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.2777777778, "max_line_length": 198, "alphanum_fraction": 0.4888304862, "num_tokens": 921, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772482857833, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.6140655339621821}} {"text": "firstTrue : (f : ℕ → Bool) → ∃ (λ n → f n ≡ true) → ℕ\nfirstTrue f prf = mp-ℕ\n\nfirstTrue-true : firstTrue f prf ≡ n → f n ≡ true\nfirstTrue-true = ?\n\nfirstTrue-false : firstTrue f prf ≡ n → ∀ m → m < n → f m ≡ false\nfirstTrue-false = ?\n", "meta": {"hexsha": "743f305dd37374a8d92ba50399b13e4a334ee0ce", "size": 234, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Experiment/Search.agda", "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_issues_repo_path": "Experiment/Search.agda", "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Experiment/Search.agda", "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.0, "max_line_length": 65, "alphanum_fraction": 0.5897435897, "num_tokens": 96, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8740772351648677, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.6140655247443447}} {"text": "module BBHeap {A : Set}(_≤_ : A → A → Set) where\n\nopen import BHeap _≤_ hiding (forget ; # ; flatten)\nopen import Bound.Lower A \nopen import Bound.Lower.Order _≤_\nopen import BTree {A} hiding (flatten)\nopen import Data.Nat\nopen import Data.List\n\nmutual\n data BBHeap : Bound → Set where\n leaf : {b : Bound} → BBHeap b\n left : {b : Bound}{x : A}{l r : BBHeap (val x)} \n → LeB b (val x) \n → l ⋘ r \n → BBHeap b\n right : {b : Bound}{x : A}{l r : BBHeap (val x)} \n → LeB b (val x) \n → l ⋙ r \n → BBHeap b\n\n data _≃_ : {b b' : Bound} → BBHeap b → BBHeap b' → Set where\n ≃lf : {b b' : Bound} → leaf {b} ≃ leaf {b'}\n ≃nd : {b b' : Bound}{x x' : A}{l r : BBHeap (val x)}{l' r' : BBHeap (val x')}\n → (b≤x : LeB b (val x)) \n → (b'≤x' : LeB b' (val x'))\n → (l⋘r : l ⋘ r)\n → (l'⋘r' : l' ⋘ r')\n → l ≃ r \n → l' ≃ r'\n → l ≃ l'\n → (left b≤x l⋘r) ≃ (left b'≤x' l'⋘r')\n\n data _⋘_ : {b b' : Bound} → BBHeap b → BBHeap b' → Set where\n lf⋘ : {b b' : Bound}\n → leaf {b} ⋘ leaf {b'}\n ll⋘ : {b b' : Bound}{x x' : A}{l r : BBHeap (val x)}{l' r' : BBHeap (val x')}\n → (b≤x : LeB b (val x)) \n → (b'≤x' : LeB b' (val x')) \n → (l⋘r : l ⋘ r)\n → (l'⋘r' : l' ⋘ r')\n → (l'≃r' : l' ≃ r')\n → r ≃ l'\n → (left b≤x l⋘r) ⋘ (left b'≤x' l'⋘r')\n lr⋘ : {b b' : Bound}{x x' : A}{l r : BBHeap (val x)}{l' r' : BBHeap (val x')}\n → (b≤x : LeB b (val x)) \n → (b'≤x' : LeB b' (val x')) \n → (l⋙r : l ⋙ r)\n → (l'⋘r' : l' ⋘ r')\n → (l'≃r' : l' ≃ r')\n → l ⋗ l'\n → (right b≤x l⋙r) ⋘ (left b'≤x' l'⋘r')\n\n data _⋙_ : {b b' : Bound} → BBHeap b → BBHeap b' → Set where\n ⋙lf : {b b' : Bound}{x : A}\n → (b≤x : LeB b (val x)) \n → (left b≤x lf⋘) ⋙ leaf {b'}\n ⋙rl : {b b' : Bound}{x x' : A}{l r : BBHeap (val x)}{l' r' : BBHeap (val x')}\n → (b≤x : LeB b (val x)) \n → (b'≤x' : LeB b' (val x')) \n → (l⋘r : l ⋘ r)\n → (l≃r : l ≃ r)\n → (l'⋘r' : l' ⋘ r')\n → l ⋗ r'\n → (left b≤x l⋘r) ⋙ (left b'≤x' l'⋘r')\n ⋙rr : {b b' : Bound}{x x' : A}{l r : BBHeap (val x)}{l' r' : BBHeap (val x')}\n → (b≤x : LeB b (val x)) \n → (b'≤x' : LeB b' (val x')) \n → (l⋘r : l ⋘ r)\n → (l≃r : l ≃ r)\n → (l'⋙r' : l' ⋙ r')\n → l ≃ l'\n → (left b≤x l⋘r) ⋙ (right b'≤x' l'⋙r')\n\n data _⋗_ : {b b' : Bound} → BBHeap b → BBHeap b' → Set where\n ⋗lf : {b b' : Bound}{x : A} \n → (b≤x : LeB b (val x)) \n → (left b≤x lf⋘) ⋗ (leaf {b'})\n ⋗nd : {b b' : Bound}{x x' : A}{l r : BBHeap (val x)}{l' r' : BBHeap (val x')}\n → (b≤x : LeB b (val x)) \n → (b'≤x' : LeB b' (val x')) \n → (l⋘r : l ⋘ r)\n → (l'⋘r' : l' ⋘ r') \n → l ≃ r\n → l' ≃ r'\n → l ⋗ l'\n → (left b≤x l⋘r) ⋗ (left b'≤x' l'⋘r')\n\n# : {b : Bound} → BBHeap b → ℕ\n# leaf = zero\n# (left {l = l} {r = r} _ _) = suc (# l + # r)\n# (right {l = l} {r = r} _ _) = suc (# l + # r)\n\nrelax : {b : Bound}(h : BBHeap b) → BHeap b\nrelax leaf = lf\nrelax (left {l = l} {r = r} b≤x _) = nd b≤x (relax l) (relax r) \nrelax (right {l = l} {r = r} b≤x _) = nd b≤x (relax l) (relax r)\n\nforget : {b : Bound}(h : BBHeap b) → BTree\nforget leaf = leaf\nforget (left {x = x} {l = l} {r = r} _ _) = node x (forget l) (forget r)\nforget (right {x = x} {l = l} {r = r} _ _) = node x (forget l) (forget r)\n\nflatten : {b : Bound} → BBHeap b → List A\nflatten leaf = []\nflatten (left {x = x} {l = l} {r = r} _ _) = x ∷ flatten l ++ flatten r\nflatten (right {x = x} {l = l} {r = r} _ _) = x ∷ flatten l ++ flatten r\n\n\n", "meta": {"hexsha": "65a3372e09b90d5a4e875297bec5dc541c49656d", "size": 4201, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/BBHeap.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/BBHeap.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/BBHeap.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.1909090909, "max_line_length": 81, "alphanum_fraction": 0.344203761, "num_tokens": 1758, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9086178895092415, "lm_q2_score": 0.6757646010190475, "lm_q1q2_score": 0.6140118055829815}} {"text": "\n-- Empty, unit and equality.\n\n⊥ = (X : Set) → X\n⊤ = (X : Set) → X → X\n\ndata _≡_ {l}{A : Set l}(x : A) : A → Set l where\n <> : x ≡ x\n\n-- The fixpoint of the identity functor as a data definition.\n\nmodule Data where\n\n data μId : Set where\n In : μId → μId\n\n-- μId can be proved empty. Here are both a direct proof and one that\n-- relies on the eliminator for μId.\n\n ¬μId : μId → ⊥\n ¬μId (In x) = ¬μId x\n\n μId-elim : ∀ {l}(P : μId → Set l) → (∀ x → P x → P (In x)) → ∀ x → P x\n μId-elim P m (In x) = m x (μId-elim P m x)\n\n ¬Id' : μId → ⊥\n ¬Id' = μId-elim (λ _ → ⊥) (λ _ p → p)\n\n-- To prove ∀ x → ¬ (x ≡ In x) it is enough to call ¬μId (or ¬μId'): the\n-- equality proof is not inspected.\n\n ¬id≡In-empty : ∀ {x} → x ≡ In x → ⊥\n ¬id≡In-empty {x} _ = ¬μId x -- or ¬Id' x\n\n-- Alternatively, one could use an absurd pattern which relies on the\n-- presence of a cycle.\n\n ¬id≡In-pm : ∀ {x} → x ≡ In x → ⊥\n ¬id≡In-pm ()\n\n-- The case of inductive records is a bit different. Here is the fixpoint\n-- of the identity functor as an inductive record definition.\n\nmodule Record where\n\n record μId : Set where\n inductive\n constructor In\n field Out : μId\n open μId\n\n-- It does not seem possible to prove Record.μId empty, as Agda does not\n-- consider the following definitions as terminating.\n\n {-# NON_TERMINATING #-}\n ¬μId : μId → ⊥\n ¬μId (In x) = ¬μId x\n\n {-# NON_TERMINATING #-}\n μId-elim : ∀ {l}(P : μId → Set l) → (∀ x → P x → P (In x)) → ∀ x → P x\n μId-elim P m (In x) = m x (μId-elim P m x)\n\n ¬Id' : μId → ⊥\n ¬Id' = μId-elim (λ _ → ⊥) (λ _ p → p)\n\n ¬id≡In-empty : ∀ {x} → x ≡ In x → ⊥\n ¬id≡In-empty {x} _ = ¬μId x -- or ¬Id' x\n\n-- However, we can still use an absurd pattern as in Data.¬id≡In-pm.\n\n ¬id≡In-pm : ∀ {x} → x ≡ In x → ⊥\n ¬id≡In-pm ()\n\n-- This should not be possible.\n", "meta": {"hexsha": "41195b61c8fe11ca3c23c4d1fa7381274c80826e", "size": 1811, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/Issue1271a.agda", "max_stars_repo_name": "hborum/agda", "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Fail/Issue1271a.agda", "max_issues_repo_name": "hborum/agda", "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Fail/Issue1271a.agda", "max_forks_repo_name": "hborum/agda", "max_forks_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 24.1466666667, "max_line_length": 73, "alphanum_fraction": 0.559911651, "num_tokens": 713, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339837155239, "lm_q2_score": 0.7310585844894971, "lm_q1q2_score": 0.6138947374827973}} {"text": "module Structure.Setoid.Size where\n\nimport Lvl\nopen import Logic\nopen import Logic.Propositional\nopen import Logic.Predicate\nopen import Structure.Setoid\nopen import Structure.Function.Domain\nopen import Structure.Function\nopen import Syntax.Function\nopen import Type\n\nprivate variable ℓ ℓ₁ ℓ₂ ℓₑ₁ ℓₑ₂ : Lvl.Level\n\n_≍_ : (A : Setoid{ℓₑ₁}{ℓ₁}) → (B : Setoid{ℓₑ₂}{ℓ₂}) → Stmt\n_≍_ A B = ∃{Obj = Setoid.Type(A) → Setoid.Type(B)} (f ↦ Function(f) ∧ Bijective(f))\n\n_≼_ : (A : Setoid{ℓₑ₁}{ℓ₁}) → (B : Setoid{ℓₑ₂}{ℓ₂}) → Stmt\n_≼_ A B = ∃{Obj = Setoid.Type(A) → Setoid.Type(B)} (f ↦ Function(f) ∧ Injective(f))\n\n_≽_ : (A : Setoid{ℓₑ₁}{ℓ₁}) → (B : Setoid{ℓₑ₂}{ℓ₂}) → Stmt\n_≽_ A B = ∃{Obj = Setoid.Type(A) → Setoid.Type(B)} (f ↦ Function(f) ∧ Surjective(f))\n\n_≭_ : (A : Setoid{ℓₑ₁}{ℓ₁}) → (B : Setoid{ℓₑ₂}{ℓ₂}) → Stmt\n_≭_ A B = ¬(A ≍ B)\n\n_≺_ : (A : Setoid{ℓₑ₁}{ℓ₁}) → (B : Setoid{ℓₑ₂}{ℓ₂}) → Stmt\n_≺_ A B = (A ≼ B) ∧ (A ≭ B)\n\n_≻_ : (A : Setoid{ℓₑ₁}{ℓ₁}) → (B : Setoid{ℓₑ₂}{ℓ₂}) → Stmt\n_≻_ A B = (A ≽ B) ∧ (A ≭ B)\n", "meta": {"hexsha": "8e1f549f415a62f5bf006343d17eaa480838a090", "size": 1007, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Setoid/Size.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Setoid/Size.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Setoid/Size.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.46875, "max_line_length": 84, "alphanum_fraction": 0.6087388282, "num_tokens": 484, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8947894717137996, "lm_q2_score": 0.6859494485880927, "lm_q1q2_score": 0.6137803447245116}} {"text": "module Dave.Logic.Bool where\n \n data Bool : Set where\n false : Bool\n true : Bool \n\n ¬_ : Bool → Bool\n ¬ true = false\n ¬ false = true\n\n _∧_ : Bool → Bool → Bool\n a ∧ true = a\n a ∧ false = false\n\n if_then_else_ : {A : Set} → Bool → A → A → A\n if false then a else b = b\n if true then a else b = a\n\n identity : {A : Set} → A → A\n identity a = a\n", "meta": {"hexsha": "18749005038c4224dd0b5dabb5fc0301239f4ae8", "size": 398, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Dave/Logic/Bool.agda", "max_stars_repo_name": "DavidStahl97/formal-proofs", "max_stars_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Dave/Logic/Bool.agda", "max_issues_repo_name": "DavidStahl97/formal-proofs", "max_issues_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Dave/Logic/Bool.agda", "max_forks_repo_name": "DavidStahl97/formal-proofs", "max_forks_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.9523809524, "max_line_length": 48, "alphanum_fraction": 0.4974874372, "num_tokens": 128, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.894789454880027, "lm_q2_score": 0.6859494421679929, "lm_q1q2_score": 0.613780327432757}} {"text": "module Ord where\n\ndata Nat : Set where\n Z : Nat\n S : Nat -> Nat\n\n\ndata Ord : Set where\n z : Ord\n lim : (Nat -> Ord) -> Ord\n\nzp : Ord -> Ord\nzp z = z\nzp (lim f) = lim (\\x -> zp (f x))\n\n", "meta": {"hexsha": "db67c85c0e9d73db8f06947d96ef1f45bad9b7d2", "size": 190, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/Termination/Ord.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/Termination/Ord.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/Termination/Ord.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 11.875, "max_line_length": 33, "alphanum_fraction": 0.5105263158, "num_tokens": 73, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8991213772699435, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.6137166419788813}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\n\nmodule Categories.Functor.Construction.SubCategory {o ℓ e} (C : Category o ℓ e) where\n\nopen import Categories.Category.SubCategory C\n\nopen Category C\nopen Equiv\n\nopen import Level\nopen import Function.Base using () renaming (id to id→)\nopen import Data.Product\n\nopen import Categories.Functor using (Functor)\n\nprivate\n variable\n ℓ′ i : Level\n I : Set i\n U : I → Obj\n\nSub : ∀ (sub : SubCat {i} {ℓ′} I) → Functor (SubCategory sub) C\nSub (record {U = U}) = record\n { F₀ = U\n ; F₁ = proj₁\n ; identity = refl\n ; homomorphism = refl\n ; F-resp-≈ = id→\n }\n\nFullSub : Functor (FullSubCategory U) C\nFullSub {U = U} = record\n { F₀ = U\n ; F₁ = id→\n ; identity = refl\n ; homomorphism = refl\n ; F-resp-≈ = id→\n }\n", "meta": {"hexsha": "5992cb2243f111147c2a5930dff6166d30989518", "size": 790, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Functor/Construction/SubCategory.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Functor/Construction/SubCategory.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Functor/Construction/SubCategory.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 19.2682926829, "max_line_length": 85, "alphanum_fraction": 0.6455696203, "num_tokens": 260, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8991213826762113, "lm_q2_score": 0.6825737214979745, "lm_q1q2_score": 0.613716628251706}} {"text": "{-# OPTIONS --universe-polymorphism #-}\nmodule Categories.Profunctor where\n\nopen import Level hiding (lift)\n\nopen import Categories.Category\nopen import Categories.Agda\nopen import Categories.Bifunctor using (Functor; Bifunctor; _∘_)\nopen import Categories.Functor.Hom\nopen import Categories.Lan\nopen import Categories.Yoneda\n\nProfunctor : ∀ {o ℓ e} {o′ ℓ′ e′} → Category o ℓ e → Category o′ ℓ′ e′ → Set _\nProfunctor {ℓ = ℓ} {e} {ℓ′ = ℓ′} {e′} C D = Bifunctor (Category.op D) C (ISetoids (ℓ ⊔ ℓ′) (e ⊔ e′))\n\nid : ∀ {o ℓ e} → {C : Category o ℓ e} → Profunctor C C\nid {C = C} = Hom[ C ][-,-]\n\n{-\n_∘_ : ∀ {o ℓ e} {o′ ℓ′ e′} {o′′ ℓ′′ e′′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {E : Category o′′ ℓ′′ e′′} \n → Profunctor D E → Profunctor C D → Profunctor C E\nF ∘ G = {!!}\n-}", "meta": {"hexsha": "7a75c3c4c6a4c5be43831b63186fc173bfc15b08", "size": 778, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Profunctor.agda", "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 98, "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_issues_repo_path": "Categories/Profunctor.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_forks_repo_path": "Categories/Profunctor.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 23, "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "avg_line_length": 33.8260869565, "max_line_length": 113, "alphanum_fraction": 0.618251928, "num_tokens": 315, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8902942261220292, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.6136848106575667}} {"text": "\nmodule SimpleTermUnification where\n\nopen import OscarPrelude\n\ndata Term (n : Nat) : Set where\n var : Fin n → Term n\n leaf : Term n\n _fork_ : Term n → Term n → Term n\n\n|> : ∀ {m n} → (r : Fin m → Fin n) → Fin m → Term n\n|> r = var ∘ r\n\n_<|_ : ∀ {m n} → (f : Fin m → Term n) → Term m → Term n\nf <| var x = f x\nf <| leaf = leaf\nf <| (t₁ fork t₂) = (f <| t₁) fork (f <| t₂)\n\n<|-assoc : ∀ {m n o} (f : Fin n → Term o) (g : Fin m → Term n) (x : Term m) → f <| (g <| x) ≡ (λ y → f <| g y) <| x\n<|-assoc f g (var x) = refl\n<|-assoc f g leaf = refl\n<|-assoc f g (x₁ fork x₂) rewrite <|-assoc f g x₁ | <|-assoc f g x₂ = refl\n\n_≗_ : ∀ {m n} → (f g : Fin m → Term n) → Set\nf ≗ g = ∀ x → f x ≡ g x\n\ninfixr 9 _⋄_\n_⋄_ : ∀ {l m n} → (f : Fin m → Term n) → (g : Fin l → Term m) → Fin l → Term n\n(f ⋄ g) = (f <|_) ∘ g\n\n⋄-assoc : ∀ {l m n o} (f : Fin n → Term o) (g : Fin m → Term n) (h : Fin l → Term m) → (f ⋄ (g ⋄ h)) ≗ ((f ⋄ g) ⋄ h)\n⋄-assoc f g h x = <|-assoc f g (h x)\n\n⋄-assoc' : ∀ {l m n o} (f : Fin n → Term o) (g : Fin m → Term n) (h : Fin l → Term m) → (f ⋄ (g ⋄ h)) ≡ ((f ⋄ g) ⋄ h)\n⋄-assoc' f g h = {!⋄-assoc f g h!}\n\nthin : ∀ {n} → (x : Fin (suc n)) → (y : Fin n) → Fin (suc n)\nthin {n} zero y = suc y\nthin {zero} (suc x) ()\nthin {suc n} (suc x) zero = zero\nthin {suc n} (suc x) (suc y) = suc (thin x y)\n\nthick : ∀ {n} → (x y : Fin (suc n)) → Maybe (Fin n)\nthick {n} zero zero = nothing\nthick {n} zero (suc y) = just y\nthick {zero} (suc ()) zero\nthick {suc n} (suc x) zero = just zero\nthick {zero} (suc ()) (suc y)\nthick {suc n} (suc x) (suc y) = suc <$> thick x y\n\ncheck : ∀ {n} → (x : Fin (suc n)) (t : Term (suc n)) → Maybe (Term n)\ncheck x (var y) = var <$> thick x y\ncheck x leaf = just leaf\ncheck x (t₁ fork t₂) = _fork_ <$> check x t₁ <*> check x t₂\n\n_for_ : ∀ {n} → (t' : Term n) (x : Fin (suc n)) → Fin (suc n) → Term n\n(t' for x) y with thick x y\n… | just y' = var y'\n… | nothing = t'\n\ndata AList (n : Nat) : Nat → Set where\n anil : AList n n\n _asnoc_/_ : ∀ {m} → (σ : AList n m) → (t' : Term m) → (x : Fin (suc m)) → AList n (suc m)\n\nsub : ∀ {n m} → (σ : AList n m) → Fin m → Term n\nsub anil = var\nsub (σ asnoc t' / x) = sub σ ⋄ (t' for x)\n\nflexFlex : ∀ {m} → (x y : Fin m) → ∃ (flip AList m)\nflexFlex {zero} () _\nflexFlex {suc m} x y with thick x y\n… | just y' = m , (anil asnoc var y' / x)\n… | nothing = suc m , anil\n\nflexRigid : ∀ {m} → (x : Fin m) (t : Term m) → Maybe (∃ (flip AList m))\nflexRigid {zero} () _\nflexRigid {suc m} x t with check x t\n… | just t' = just $ m , anil asnoc t' / x\n… | nothing = nothing\n\namgu : ∀ {m} → (s t : Term m) (acc : ∃ (flip AList m)) → Maybe (∃ (flip AList m))\namgu {m} leaf leaf acc = just acc\namgu {m} leaf (_ fork _) _ = nothing\namgu {m} (_ fork _) leaf _ = nothing\namgu {m} (s₁ fork s₂) (t₁ fork t₂) acc = amgu s₁ t₁ acc >>= amgu s₂ t₂\namgu {m} (var x) (var y) (.m , anil) = just $ flexFlex x y\namgu {m} (var x) t (.m , anil) = flexRigid x t\namgu {m} t (var x) (.m , anil) = flexRigid x t\namgu {suc m} s t (n , (σ asnoc r / z)) = amgu ((r for z) <| s) ((r for z) <| t) (n , σ) >>= λ {(n' , σ') → just $ n' , σ' asnoc r / z}\n\nmgu : ∀ {m} → (s t : Term m) → Maybe (∃ (flip AList m))\nmgu {m} s t = amgu s t (m , anil)\n\nf : Fin 4 → Term 5\nf n = var (thin (suc n) n) fork var (thin (suc n) n)\n\ng : Fin 4 → Term 5\ng n = var (suc n)\n\nfs : Term 5\nfs = f 0 fork (f 1 fork (f 2 fork f 3))\n\ngs : Term 5\ngs = g 0 fork (g 1 fork (g 2 fork g 3))\n\nfoo : Set\nfoo = {!mgu fs gs!}\n\nProperty : Nat → Set₁\nProperty m = ∀ {n} → (Fin m → Term n) → Set\n\nUnifies : ∀ {m} → (s t : Term m) → Property m\nUnifies s t f = f <| s ≡ f <| t\n\n_∧_ : ∀ {m} → (P Q : Property m) → Property m\n(P ∧ Q) f = P f × Q f\n\n_⇔_ : ∀ {m} → (P Q : Property m) → Property m\n(P ⇔ Q) f = (P f → Q f) × (Q f → P f)\n\nNothing : ∀ {m} (P : Property m) → Set\nNothing {m} P = ∀ {n} → (f : Fin m → Term n) → ¬ P f\n\ninfixl 3 _[-⋄_]_\n_[-⋄_]_ : ∀ {m n} (P : Property m) (f : Fin m → Term n) → Property n\n(P [-⋄ f ] g) = P (g ⋄ f)\n\n_≤ₛ_ : ∀ {m n n'} (f : Fin m → Term n) (g : Fin m → Term n') → Set\nf ≤ₛ g = ∃ λ f' → f ≗ (f' ⋄ g)\n\nMax : ∀ {m} (P : Property m) → Property m\nMax {m} P f = P f × ∀ {n} → (f' : Fin m → Term n) → P f' → f' ≤ₛ f\n\nDClosed : ∀ {m} (P : Property m) → Set\nDClosed {m} P = ∀ {n n'} (f : Fin m → Term n) (g : Fin m → Term n') → f ≤ₛ g → P g → P f\n\nLemma1 : ∀ {l} {P Q : Property l} {m n o}\n {p : Fin m → Term n}\n {q : Fin n → Term o}\n {a : Fin l → Term m}\n → DClosed P\n → Max (P [-⋄ a ]_) p\n → Max (Q [-⋄ (p ⋄ a)]_) q\n → Max ((P ∧ Q) [-⋄ a ]_) (q ⋄ p)\nLemma1 {P = P} {Q} {p = p} {q} {a} DCP maxP maxQ =\n let Qqpa : Q (q ⋄ p ⋄ a)\n Qqpa = fst maxQ\n Qqpa' : Q ((q ⋄ p) ⋄ a)\n Qqpa' = {!⋄-assoc q p a!}\n Pqpa : P (q ⋄ p ⋄ a)\n Pqpa = DCP (λ z → q <| (p <| a z)) (λ z → p <| a z) (q , (λ x → refl)) (fst maxP)\n lem3 : ∀ {n} → {f : Fin _ → Term n} → P (f ⋄ a) → Q (f ⋄ a) → f ≤ₛ (q ⋄ p)\n lem3 = {!!}\n in ({!!} , {!maxQ!}) , {!!}\n where\n Ppa : P (p ⋄ a)\n Ppa = fst maxP\n\n pMax : ∀ {n} {p' : Fin _ → Term n} → P (p' ⋄ a) → p' ≤ₛ p\n pMax {n} {p'} Pp'a = snd maxP p' Pp'a\n\ndata Step (n : Nat) : Set where\n left : Term n → Step n\n right : Term n → Step n\n\n_+ₛ_ : ∀ {n} → (ps : List (Step n)) → (t : Term n) → Term n\n[] +ₛ t = t\n(left r ∷ ps) +ₛ t = (ps +ₛ t) fork r\n(right l ∷ ps) +ₛ t = l fork (ps +ₛ t)\n\ntheorem-6 : ∀ m → (s t : Term m) → (r : Maybe (∃ (flip AList m))) → mgu s t ≡ r → Either (∃ λ n → ∃ λ σ → Max (Unifies s t) (sub σ) × r ≡ just (n , σ)) (Nothing (Unifies s t) × r ≡ nothing)\ntheorem-6 = {!!}\n", "meta": {"hexsha": "0dd0d6d058fe47ee506f719e6f71736ba7e264a0", "size": 5518, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-1/SimpleTermUnification.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-1/SimpleTermUnification.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-1/SimpleTermUnification.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.8959537572, "max_line_length": 189, "alphanum_fraction": 0.473359913, "num_tokens": 2572, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681158979307, "lm_q2_score": 0.7154239836484143, "lm_q1q2_score": 0.6136678825222923}} {"text": "module Cats.Util.SetoidMorphism where\n\nopen import Data.Product using (∃-syntax ; _,_ ; proj₁ ; proj₂)\nopen import Level using (_⊔_ ; suc)\nopen import Relation.Binary using (Rel ; Setoid ; IsEquivalence ; _Preserves_⟶_)\nopen import Relation.Binary.SetoidReasoning\n\nopen import Cats.Util.Function using () renaming (_∘_ to _⊚_)\n\nopen Setoid renaming (_≈_ to eq)\n\n\ninfixr 9 _∘_\n\n\nrecord _⇒_ {l l≈} (A : Setoid l l≈) {l′ l≈′} (B : Setoid l′ l≈′)\n : Set (l ⊔ l′ ⊔ l≈ ⊔ l≈′)\n where\n field\n arr : Carrier A → Carrier B\n resp : arr Preserves eq A ⟶ eq B\n\nopen _⇒_ public using (arr ; resp)\n\n\nmodule _ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′} where\n\n infixr 4 _≈_\n\n\n record _≈_ (f g : A ⇒ B) : Set (l ⊔ l≈ ⊔ l≈′) where\n constructor ≈-intro\n field\n ≈-elim : ∀ {x y} → eq A x y → eq B (arr f x) (arr g y)\n\n ≈-elim′ : ∀ {x} → eq B (arr f x) (arr g x)\n ≈-elim′ = ≈-elim (refl A)\n\n open _≈_ public\n\n\n equiv : IsEquivalence _≈_\n equiv = record\n { refl = λ {f} → ≈-intro (resp f)\n ; sym = λ eq → ≈-intro λ x≈y → sym B (≈-elim eq (sym A x≈y))\n ; trans = λ eq₁ eq₂ → ≈-intro (λ x≈y → trans B (≈-elim eq₁ x≈y) (≈-elim′ eq₂))\n }\n\n\n setoid : Setoid (l ⊔ l≈ ⊔ l′ ⊔ l≈′) (l ⊔ l≈ ⊔ l≈′)\n setoid = record\n { Carrier = A ⇒ B\n ; _≈_ = _≈_\n ; isEquivalence = equiv\n }\n\n\nid : ∀ {l l≈} {A : Setoid l l≈} → A ⇒ A\nid = record { arr = λ x → x ; resp = λ x → x }\n\n\n_∘_ : ∀ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′}\n → ∀ {l″ l≈″} {C : Setoid l″ l≈″}\n → B ⇒ C → A ⇒ B → A ⇒ C\n_∘_ f g = record\n { arr = arr f ⊚ arr g\n ; resp = resp f ⊚ resp g\n }\n\n\n∘-resp : ∀ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′}\n → ∀ {l″ l≈″} {C : Setoid l″ l≈″}\n → {f f′ : B ⇒ C} {g g′ : A ⇒ B}\n → f ≈ f′ → g ≈ g′ → f ∘ g ≈ f′ ∘ g′\n∘-resp f≈f′ g≈g′ = ≈-intro (≈-elim f≈f′ ⊚ ≈-elim g≈g′)\n\n\nid-l : ∀ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′}\n → {f : A ⇒ B}\n → id ∘ f ≈ f\nid-l {f = f} = ≈-intro (resp f)\n\n\nid-r : ∀ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′}\n → {f : A ⇒ B}\n → f ∘ id ≈ f\nid-r {f = f} = ≈-intro (resp f)\n\n\nassoc : ∀ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′}\n → ∀ {l″ l≈″} {C : Setoid l″ l≈″} {l‴ l≈‴} {D : Setoid l‴ l≈‴}\n → {f : C ⇒ D} {g : B ⇒ C} {h : A ⇒ B}\n → (f ∘ g) ∘ h ≈ f ∘ (g ∘ h)\nassoc {f = f} {g} {h} = ≈-intro (resp f ⊚ resp g ⊚ resp h)\n\n\nmodule _ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′} where\n\n IsInjective : A ⇒ B → Set (l ⊔ l≈ ⊔ l≈′)\n IsInjective f = ∀ {a b} → eq B (arr f a) (arr f b) → eq A a b\n\n\n IsSurjective : A ⇒ B → Set (l ⊔ l′ ⊔ l≈′)\n IsSurjective f = ∀ b → ∃[ a ] (eq B b (arr f a))\n", "meta": {"hexsha": "db4832b6dea3a3b911a0700f73b7c83bedaa8eea", "size": 2642, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Util/SetoidMorphism.agda", "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cats/Util/SetoidMorphism.agda", "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cats/Util/SetoidMorphism.agda", "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.1619047619, "max_line_length": 84, "alphanum_fraction": 0.4674489023, "num_tokens": 1325, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.853912760387131, "lm_q2_score": 0.7185944046238981, "lm_q1q2_score": 0.6136169316511398}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Algebra.Semigroup.Morphism where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Functions.Embedding\n\nopen import Cubical.Algebra\nopen import Cubical.Algebra.Magma.Morphism\n\nprivate\n variable\n s t : Level\n\nIsSemigroupHom : (S : Semigroup s) (T : Semigroup t) → (⟨ S ⟩ → ⟨ T ⟩) → Type (ℓ-max s t)\nIsSemigroupHom S T fun = Homomorphic₂ fun (Semigroup._•_ S) (Semigroup._•_ T)\n\nrecord SemigroupHom (S : Semigroup s) (T : Semigroup t) : Type (ℓ-max s t) where\n constructor semigrouphom\n field\n fun : ⟨ S ⟩ → ⟨ T ⟩\n isHom : IsSemigroupHom S T fun\n\nrecord SemigroupEquiv (S : Semigroup s) (T : Semigroup t) : Type (ℓ-max s t) where\n constructor semigroupequiv\n field\n eq : ⟨ S ⟩ ≃ ⟨ T ⟩\n isHom : IsSemigroupHom S T (equivFun eq)\n\n hom : SemigroupHom S T\n hom = record { isHom = isHom }\n\n\ninstance\n SemigroupHomOperators : HomOperators (Semigroup s) (Semigroup t) (ℓ-max s t)\n SemigroupHomOperators = record { _⟶ᴴ_ = SemigroupHom; _≃ᴴ_ = SemigroupEquiv }\n\n\nprivate\n variable\n S : Semigroup s\n T : Semigroup t\n\n\nSemigroupHom→MagmaHom : (S ⟶ᴴ T) → (Semigroup.magma S ⟶ᴴ Semigroup.magma T)\nSemigroupHom→MagmaHom hom .MagmaHom.fun = hom .SemigroupHom.fun\nSemigroupHom→MagmaHom hom .MagmaHom.isHom = hom .SemigroupHom.isHom\n\nMagmaHom→SemigroupHom : (Semigroup.magma S ⟶ᴴ Semigroup.magma T) → (S ⟶ᴴ T)\nMagmaHom→SemigroupHom hom .SemigroupHom.fun = hom .MagmaHom.fun\nMagmaHom→SemigroupHom hom .SemigroupHom.isHom = hom .MagmaHom.isHom\n\nSemigroupHom≃MagmaHom : (S ⟶ᴴ T) ≃ (Semigroup.magma S ⟶ᴴ Semigroup.magma T)\nSemigroupHom≃MagmaHom = isoToEquiv (iso SemigroupHom→MagmaHom MagmaHom→SemigroupHom (λ _ → refl) (λ _ → refl))\n\n\nSemigroupEquiv→MagmaEquiv : S ≃ᴴ T → Semigroup.magma S ≃ᴴ Semigroup.magma T\nSemigroupEquiv→MagmaEquiv eq .MagmaEquiv.eq = eq .SemigroupEquiv.eq\nSemigroupEquiv→MagmaEquiv eq .MagmaEquiv.isHom = eq .SemigroupEquiv.isHom\n\nMagmaEquiv→SemigroupEquiv : Semigroup.magma S ≃ᴴ Semigroup.magma T → S ≃ᴴ T\nMagmaEquiv→SemigroupEquiv eq .SemigroupEquiv.eq = eq .MagmaEquiv.eq\nMagmaEquiv→SemigroupEquiv eq .SemigroupEquiv.isHom = eq .MagmaEquiv.isHom\n\nSemigroupEquiv≃MagmaEquiv : (S ≃ᴴ T) ≃ (Semigroup.magma S ≃ᴴ Semigroup.magma T)\nSemigroupEquiv≃MagmaEquiv = isoToEquiv (iso SemigroupEquiv→MagmaEquiv MagmaEquiv→SemigroupEquiv (λ _ → refl) (λ _ → refl))\n", "meta": {"hexsha": "1c57c0465453855531c5fa9a73bb78818ccd2d0e", "size": 2444, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Semigroup/Morphism.agda", "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Semigroup/Morphism.agda", "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Semigroup/Morphism.agda", "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.9411764706, "max_line_length": 122, "alphanum_fraction": 0.7393617021, "num_tokens": 891, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.853912760387131, "lm_q2_score": 0.7185943805178139, "lm_q1q2_score": 0.6136169110666468}} {"text": "{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- Tested with the development version of the Agda standard library on\n-- 27 May 2011.\n\n-- Nils' idea about databases in the Agda mailing list.\n-- http://thread.gmane.org/gmane.comp.lang.agda/2911/focus=2917\n\nmodule FOT.Agsy.DataBase where\n\nopen import Data.Nat\nopen import Data.Product\n\nopen import Relation.Binary.PropositionalEquality\nopen ≡-Reasoning\n\npostulate\n right-identity : ∀ n → n + 0 ≡ n\n move-suc : ∀ m n → suc (m + n) ≡ m + suc n\n\ndb = right-identity ,′ move-suc\n\ncomm : ∀ m n → m + n ≡ n + m -- Via auto {!-c db!}\ncomm zero n = sym (proj₁ db n)\ncomm (suc n) n' =\n begin\n suc (n + n') ≡⟨ cong suc (comm n n') ⟩\n suc (n' + n) ≡⟨ proj₂ db n' n ⟩ (n' + suc n)\n ∎\n", "meta": {"hexsha": "4e3531d045577139ec7843147485a2de19a88c09", "size": 868, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/Agsy/DataBase.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/FOT/Agsy/DataBase.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/FOT/Agsy/DataBase.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 26.303030303, "max_line_length": 70, "alphanum_fraction": 0.5944700461, "num_tokens": 282, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382129861583, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.6136152485029064}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Data.List.Kleene.Properties where\n\nopen import Data.List.Kleene.Base\n\nopen import Relation.Binary\nopen import Relation.Unary\n\nopen import Function\n\nmodule _ {a r} {A : Set a} {R : Rel A r} where\n infix 4 _≈_\n _≈_ = R\n\n open import Algebra.FunctionProperties _≈_\n\n foldr-universal : Transitive _≈_\n → ∀ {b} {B : Set b} (h : B ⋆ → A) f e\n → ∀[ f ⊢ Congruent₁ ]\n → (h [] ≈ e)\n → (∀ x xs → h (∹ x & xs) ≈ f x (h xs))\n → ∀ xs → h xs ≈ foldr⋆ f e xs\n foldr-universal trans h f e cong-f base cons [] = base\n foldr-universal trans h f e cong-f base cons (∹ x & xs) =\n (cons x xs) ⟨ trans ⟩ cong-f (foldr-universal trans h f e cong-f base cons xs)\n\n foldr-fusion : Transitive _≈_\n → Reflexive _≈_\n → ∀ {b c} {B : Set b} {C : Set c} (f : C → A) {_⊕_ : B → C → C} {_⊗_ : B → A → A} e\n → ∀[ _⊗_ ⊢ Congruent₁ ]\n → (∀ x y → f (x ⊕ y) ≈ x ⊗ f y)\n → ∀ xs → f (foldr⋆ _⊕_ e xs) ≈ foldr⋆ _⊗_ (f e) xs\n foldr-fusion trans refl h {f} {g} e cong-g fuse =\n foldr-universal trans (h ∘ foldr⋆ f e) g (h e) cong-g refl (λ x xs → fuse x (foldr⋆ f e xs))\n", "meta": {"hexsha": "b3279d0c8b668ed1d75122eb081dc31e9a8771aa", "size": 1240, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/List/Kleene/Properties.agda", "max_stars_repo_name": "oisdk/agda-kleene-lists", "max_stars_repo_head_hexsha": "a7e99bc288e12e83440c891dbd3e5077d9b1657e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Data/List/Kleene/Properties.agda", "max_issues_repo_name": "oisdk/agda-kleene-lists", "max_issues_repo_head_hexsha": "a7e99bc288e12e83440c891dbd3e5077d9b1657e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/List/Kleene/Properties.agda", "max_forks_repo_name": "oisdk/agda-kleene-lists", "max_forks_repo_head_hexsha": "a7e99bc288e12e83440c891dbd3e5077d9b1657e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.4444444444, "max_line_length": 98, "alphanum_fraction": 0.5008064516, "num_tokens": 460, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.86153820232079, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.6136152409066878}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nmodule Cubical.Homotopy.EilenbergSteenrod where\n\n{-\nThis module contains the Eilenberg-Steenrod axioms for ordinary\nreduced cohomology theories with binary additivity.\nThe axioms are based on the ones given in Cavallo's MSc thesis\n(https://www.cs.cmu.edu/~ecavallo/works/thesis15.pdf) and\nBuchholtz/Favonia (2018)\n-}\n\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Pointed\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.Equiv\nopen import Cubical.HITs.Wedge\nopen import Cubical.HITs.Pushout\nopen import Cubical.HITs.Susp\n\nopen import Cubical.Data.Empty\nopen import Cubical.Relation.Nullary\n\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Bool\nopen import Cubical.Data.Sigma\nopen import Cubical.Data.Int\n\nopen import Cubical.Algebra.Group\nopen import Cubical.Algebra.AbGroup\nopen GroupEquiv\nopen GroupHom\n\nrecord coHomTheory {ℓ ℓ' : Level} (H : (n : Int) → Pointed ℓ → AbGroup {ℓ'}) : Type (ℓ-suc (ℓ-max ℓ ℓ'))\n where\n Boolℓ : Pointed ℓ\n Boolℓ = Lift Bool , lift true\n field\n Hmap : (n : Int) → {A B : Pointed ℓ} (f : A →∙ B) → AbGroupHom (H n B) (H n A)\n Suspension : Σ[ F ∈ ((n : Int) {A : Pointed ℓ} → AbGroupEquiv (H (sucInt n) (Susp (typ A) , north)) (H n A)) ]\n ({A B : Pointed ℓ} (f : A →∙ B) (n : Int)\n → fun (Hmap (sucInt n) (suspFun (fst f) , refl)) ∘ invEq (eq (F n {A = B}))\n ≡ invEq (eq (F n {A = A})) ∘ fun (Hmap n f))\n Exactness : {A B : Pointed ℓ} (f : A →∙ B) (n : Int)\n → Ker (Hmap n f)\n ≡ Im (Hmap n {B = _ , inr (pt B)} (cfcod (fst f) , refl))\n Dimension : (n : Int) → ¬ n ≡ 0 → isContr (fst (H n Boolℓ))\n BinaryWedge : (n : Int) {A B : Pointed ℓ} → AbGroupEquiv (H n (A ⋁ B , (inl (pt A)))) (dirProdAb (H n A) (H n B))\n", "meta": {"hexsha": "ffcef42b61207e2053f4ef319dbe9ad305975846", "size": 1844, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Homotopy/EilenbergSteenrod.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Homotopy/EilenbergSteenrod.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Homotopy/EilenbergSteenrod.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.88, "max_line_length": 117, "alphanum_fraction": 0.6415401302, "num_tokens": 652, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615381987656672, "lm_q2_score": 0.7122321903471565, "lm_q1q2_score": 0.613615238374615}} {"text": "module Algebra.Module.Morphism.Module where\n\nopen import Assume using (assume)\nopen import Algebra.Core using (Op₁; Op₂)\nopen import Algebra.Bundles using (CommutativeRing)\nopen import Algebra.Module.Bundles using (Module)\nopen import Algebra.Module.Structures using (IsModule)\nopen import Algebra.Module.Normed using (IsNormedModule; NormedModule)\nopen import Relation.Binary.Core using (Rel)\nopen import Data.Product using (Σ-syntax; ∃-syntax; _×_; _,_; proj₁)\n\nopen import Algebra.Module.Morphism.Structures\n using (IsModuleHomomorphism; IsModuleMonomorphism; IsModuleIsomorphism)\n\nopen import Level using (_⊔_; suc)\n\nprivate\n module toModule\n {a} (A : Set a)\n {r ℓr} {CR : CommutativeRing r ℓr}\n {mb ℓmb} (MB : Module CR mb ℓmb)\n where\n\n private\n module CR = CommutativeRing CR\n module MB = Module MB\n\n Carrierᴹ : Set _\n Carrierᴹ = A → MB.Carrierᴹ\n\n _≈ᴹ_ : Rel Carrierᴹ _\n f ≈ᴹ g = ∀ a → f a MB.≈ᴹ g a\n\n _+ᴹ_ : Op₂ Carrierᴹ\n f +ᴹ g = λ a → f a MB.+ᴹ g a\n\n _*ₗ_ : CR.Carrier → Carrierᴹ → Carrierᴹ\n s *ₗ f = λ a → s MB.*ₗ f a\n\n _*ᵣ_ : Carrierᴹ → CR.Carrier → Carrierᴹ\n f *ᵣ s = λ a → f a MB.*ᵣ s\n\n 0ᴹ : Carrierᴹ\n 0ᴹ _ = MB.0ᴹ\n\n -ᴹ_ : Op₁ Carrierᴹ\n -ᴹ_ f = λ a → MB.-ᴹ f a\n\n isModule : IsModule CR _≈ᴹ_ _+ᴹ_ 0ᴹ -ᴹ_ _*ₗ_ _*ᵣ_ \n isModule = assume\n\n\n→-module\n : ∀ {a} (A : Set a)\n {r ℓr} {CR : CommutativeRing r ℓr}\n {mb ℓmb} (MB : Module CR mb ℓmb)\n → Module CR (a ⊔ mb) (a ⊔ ℓmb)\n→-module A MB = record { toModule A MB }\n\n→-module'\n : ∀ {r ℓr} {CR : CommutativeRing r ℓr}\n {ma ℓma} (MA : Module CR ma ℓma)\n {mb ℓmb} (MB : Module CR mb ℓmb)\n → Module CR (ma ⊔ mb) (ma ⊔ ℓmb)\n→-module' MA MB = →-module (Carrierᴹ MA) MB\n where open Module\n\n\nmodule _ \n {r ℓr} {CR : CommutativeRing r ℓr}\n {ma ℓma} (MA : Module CR ma ℓma)\n {mb ℓmb} (MB : Module CR mb ℓmb)\n where\n\n private\n module MA = Module MA\n module MB = Module MB\n\n _⊸_ : Set _\n _⊸_ = ∃[ f ] IsModuleHomomorphism MA MB f\n\n ⊸-module : Module CR (r ⊔ ma ⊔ ℓma ⊔ mb ⊔ ℓmb) (ma ⊔ ℓmb)\n ⊸-module =\n record\n { Carrierᴹ = _⊸_\n ; _≈ᴹ_ = λ f g → ∀ x → proj₁ f x MB.≈ᴹ proj₁ g x\n ; _+ᴹ_ = λ f g → (λ x → proj₁ f x MB.+ᴹ proj₁ g x) , assume\n ; _*ₗ_ = λ s f → (λ x → s MB.*ₗ proj₁ f x) , assume\n ; _*ᵣ_ = λ f s → (λ x → proj₁ f x MB.*ᵣ s) , assume\n ; 0ᴹ = (λ x → MB.0ᴹ) , assume\n ; -ᴹ_ = λ f → (λ x → MB.-ᴹ proj₁ f x) , assume\n ; isModule = assume\n }\n\nmodule _\n {r ℓr} {CR : CommutativeRing r ℓr}\n (open CommutativeRing CR using () renaming (Carrier to S))\n {rel} {_≤_ : Rel S rel}\n {ma ℓma} (MA : NormedModule CR _≤_ ma ℓma)\n {mb ℓmb} (MB : NormedModule CR _≤_ mb ℓmb)\n where\n\n private\n module MB = NormedModule MB\n module MA = NormedModule MA\n\n ⊸-normed : NormedModule CR _≤_ _ _\n ⊸-normed =\n record\n { M = ⊸-module MA.M MB.M\n ; ∥_∥ = λ f → MB.∥ proj₁ f MA.0ᴹ ∥\n ; isNormedModule = assume\n }\n\n", "meta": {"hexsha": "3a20d06351d8a0d44584e7e48de0f8daff8f1dc3", "size": 2930, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Algebra/Module/Morphism/Module.agda", "max_stars_repo_name": "cspollard/reals", "max_stars_repo_head_hexsha": "a193aeebf1326f960975b19d3e31b46fddbbfaa2", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Algebra/Module/Morphism/Module.agda", "max_issues_repo_name": "cspollard/reals", "max_issues_repo_head_hexsha": "a193aeebf1326f960975b19d3e31b46fddbbfaa2", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Algebra/Module/Morphism/Module.agda", "max_forks_repo_name": "cspollard/reals", "max_forks_repo_head_hexsha": "a193aeebf1326f960975b19d3e31b46fddbbfaa2", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.4782608696, "max_line_length": 73, "alphanum_fraction": 0.5924914676, "num_tokens": 1244, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382058759129, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.6136152329138491}} {"text": "\nopen import Agda.Builtin.Nat\nopen import Agda.Builtin.Unit\n\ndata ⊥ : Set where\n\ndata _⊎_ (A B : Set) : Set where\n inj₁ : A → A ⊎ B\n inj₂ : B → A ⊎ B\n\nFin : Nat → Set\nFin zero = ⊥\nFin (suc n) = ⊤ ⊎ Fin n\n\nn = 49\n\npostulate\n P : Nat → Set\n Q : Set → Set\n f : (n : Nat) → Q (Fin n) → P n\n q : Q (Fin n)\n\np : P n\np = f _ q\n", "meta": {"hexsha": "64fbcc7741221dbf9e07352e04c00ddf8de2f592", "size": 329, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue2945.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue2945.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue2945.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 13.16, "max_line_length": 33, "alphanum_fraction": 0.5227963526, "num_tokens": 149, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774767874818408, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.6135795285225759}} {"text": "{-# OPTIONS --safe --experimental-lossy-unification #-}\nmodule Cubical.Algebra.Polynomials.Multivariate.EquivCarac.Polyn-nPoly where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\n\nopen import Cubical.Data.Nat renaming (_+_ to _+n_; _·_ to _·n_)\nopen import Cubical.Data.Vec\nopen import Cubical.Data.Sigma\n\nopen import Cubical.Algebra.Ring\nopen import Cubical.Algebra.CommRing\n\nopen import Cubical.Algebra.CommRing.Instances.UnivariatePoly\nopen import Cubical.Algebra.CommRing.Instances.MultivariatePoly\n\nopen import Cubical.Algebra.Polynomials.Multivariate.EquivCarac.Poly0-A\nopen import Cubical.Algebra.Polynomials.Multivariate.EquivCarac.Poly1-1Poly\nopen import Cubical.Algebra.Polynomials.Multivariate.EquivCarac.An[Am[X]]-Anm[X]\nopen import Cubical.Algebra.Polynomials.Multivariate.EquivCarac.AB-An[X]Bn[X]\n\nopen CommRingEquivs renaming (compCommRingEquiv to _∘-ecr_ ; invCommRingEquiv to inv-ecr)\n\nprivate variable\n ℓ : Level\n\n\n-----------------------------------------------------------------------------\n-- Definition\n\nEquiv-Polyn-nPoly : (A' : CommRing ℓ) → (n : ℕ) → CommRingEquiv (PolyCommRing A' n) (nUnivariatePoly A' n)\nEquiv-Polyn-nPoly A' zero = CRE-Poly0-A A'\nEquiv-Polyn-nPoly A' (suc n) = inv-ecr _ _ (CRE-PolyN∘M-PolyN+M A' 1 n)\n ∘-ecr (lift-equiv-poly _ _ (Equiv-Polyn-nPoly A' n) 1\n ∘-ecr CRE-Poly1-Poly: (nUnivariatePoly A' n))\n", "meta": {"hexsha": "d9b39329fcc39afe713650ab478281e3eeaa8794", "size": 1444, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Polynomials/Multivariate/EquivCarac/Polyn-nPoly.agda", "max_stars_repo_name": "guilhermehas/cubical", "max_stars_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_issues_repo_path": "Cubical/Algebra/Polynomials/Multivariate/EquivCarac/Polyn-nPoly.agda", "max_issues_repo_name": "guilhermehas/cubical", "max_issues_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Polynomials/Multivariate/EquivCarac/Polyn-nPoly.agda", "max_forks_repo_name": "guilhermehas/cubical", "max_forks_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.1111111111, "max_line_length": 106, "alphanum_fraction": 0.7091412742, "num_tokens": 428, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8774767906859264, "lm_q2_score": 0.6992544210587586, "lm_q1q2_score": 0.613579525263585}} {"text": "{-# OPTIONS --without-K #-}\nopen import Data.Nat.Base using (ℕ)\nopen import Data.Product\nopen import HoTT\nopen import Function.Extensionality\nopen import Algebra.Group\nopen import Algebra.Group.Homomorphism\nopen import Algebra.Group.Isomorphism\nopen import Function using (id; _∘_ ; flip)\nopen import Relation.Binary.PropositionalEquality.NP\n\nopen import Explore.Core\nopen import Explore.Properties\nimport Explore.Explorable as E\n\nopen Equivalences\n\nmodule Explore.Group where\n\nmodule FromGroupHomomorphism\n {ℓ}{A B : Set ℓ}(𝔾+ : Group A)(𝔾* : Group B)\n (φ : A → B)(φ-hom : GroupHomomorphism 𝔾+ 𝔾* φ)\n where\n\n open Additive-Group 𝔾+\n open Multiplicative-Group 𝔾*\n\n module LiftGroupHomomorphism\n {i}{I : Set i}\n {explore : ∀ {ℓ} → Explore ℓ I}\n (explore-ind : ∀ {p ℓ} → ExploreInd {ℓ} p explore)\n (g : I → A)\n where\n open GroupHomomorphism φ-hom\n\n Σᴵ = explore 0# _+_\n Πᴵ = explore 1# _*_\n\n lift-hom : φ (Σᴵ g) ≡ Πᴵ (φ ∘ g)\n lift-hom = E.FromExploreInd.LiftHom.lift-hom explore-ind _≡_ refl trans 0# _+_ 1# _*_ *= φ g 0-hom-1 hom\n\n module FromExplore\n {ℓx} {X : Set ℓx}(z : X)(_⊕_ : X → X → X)\n (exploreᴬ : Explore ℓx A)\n (exploreᴬ= : ExploreExt exploreᴬ)\n (let [⊕] = exploreᴬ z _⊕_)\n (O : B → X)\n (sui : ∀ {k} → [⊕] (O ∘ φ) ≡ [⊕] (O ∘ _*_ k ∘ φ))\n where\n\n +-stable : ∀ {k} → [⊕] (O ∘ φ) ≡ [⊕] (O ∘ φ ∘ _+_ k)\n +-stable = Algebra.Group.Homomorphism.Stability.+-stable 𝔾+ 𝔾* φ φ-hom\n ([⊕] ∘ _∘_ O) (exploreᴬ= _ _ ∘ _∘_ (ap O)) sui\n\nmodule FromGroupIsomorphism\n {ℓa}{ℓb}{A : Set ℓa}{B : Set ℓb}(𝔾+ : Group A)(𝔾* : Group B)\n (φ : A → B)(φ-iso : GroupIsomorphism 𝔾+ 𝔾* φ) where\n open GroupIsomorphism φ-iso\n\n open Additive-Group 𝔾+\n open Multiplicative-Group 𝔾*\n\n module FromBigOp\n {ℓx}{X : Set ℓx}(F : BigOp X A)\n (F= : ∀ {g₀ g₁ : A → X} → g₀ ≗ g₁ → F g₀ ≡ F g₁)\n (O : B → X)\n (sui : ∀ {k} → F (O ∘ φ) ≡ F (O ∘ φ ∘ _+_ k))\n where\n\n _≈_ : (g₀ g₁ : B → B) → Set ℓx\n g₀ ≈ g₁ = F (O ∘ g₀ ∘ φ) ≡ F (O ∘ g₁ ∘ φ)\n\n -- The core of the proof is there:\n open Algebra.Group.Isomorphism.Stability 𝔾+ 𝔾* φ φ-iso\n\n id≈k* : ∀ {k} → id ≈ _*_ k\n id≈k* = *-stable (F ∘ _∘_ O)\n (F= ∘ _∘_ (ap O))\n sui\n\n k₀*≈k₁* : ∀ {k₀ k₁} → _*_ k₀ ≈ _*_ k₁\n k₀*≈k₁* = ! id≈k* ∙ id≈k*\n\n module FromExplore\n {ℓx}{X : Set ℓx}(z : X)(_⊕_ : X → X → X)\n (exploreᴬ : Explore ℓx A)\n (exploreᴬ= : ExploreExt exploreᴬ)\n = FromBigOp (exploreᴬ z _⊕_) (exploreᴬ= z _⊕_)\n\nmodule FromAdequate-sum\n {ℓb}{A : Set}{B : Set ℓb}(𝔾+ : Group A)(𝔾* : Group B)\n (φ : A → B)(φ-iso : GroupIsomorphism 𝔾+ 𝔾* φ)\n {sum : Sum A}\n (open Adequacy _≡_)\n (sum-adq : Adequate-sum sum)\n {{_ : UA}}{{_ : FunExt}}\n (open E.FromAdequate-sum sum-adq)\n (O : B → ℕ)\n (open Additive-Group 𝔾+)\n (open FromGroupIsomorphism 𝔾+ 𝔾* φ φ-iso)\n = FromBigOp sum sum-ext O (! (sumStableUnder (_ , +-is-equiv) (O ∘ φ)))\n\n-- -}\n-- -}\n-- -}\n-- -}\n", "meta": {"hexsha": "be92544f5bb2c083bf1e8936e338d8e3772ea901", "size": 2885, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lib/Explore/Group.agda", "max_stars_repo_name": "crypto-agda/explore", "max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z", "max_issues_repo_path": "lib/Explore/Group.agda", "max_issues_repo_name": "crypto-agda/explore", "max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z", "max_forks_repo_path": "lib/Explore/Group.agda", "max_forks_repo_name": "crypto-agda/explore", "max_forks_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.9626168224, "max_line_length": 106, "alphanum_fraction": 0.5746967071, "num_tokens": 1287, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774767906859264, "lm_q2_score": 0.6992544210587586, "lm_q1q2_score": 0.613579525263585}} {"text": "\nmodule Oscar.Data.Term.Injectivity {𝔣} (FunctionName : Set 𝔣) where\n\nopen import Oscar.Data.Term FunctionName\n\nopen import Data.Fin\nopen import Data.Nat\nopen import Data.Vec\nopen import Relation.Binary.PropositionalEquality\n\nTerm-i-inj : ∀ {m} {𝑥₁ 𝑥₂ : Fin m} → i 𝑥₁ ≡ i 𝑥₂ → 𝑥₁ ≡ 𝑥₂\nTerm-i-inj refl = refl\n\nTerm-functionName-inj : ∀ {fn₁ fn₂} {n N₁ N₂} {ts₁ : Vec (Term n) N₁} {ts₂ : Vec (Term n) N₂} → Term.function fn₁ ts₁ ≡ Term.function fn₂ ts₂ → fn₁ ≡ fn₂\nTerm-functionName-inj refl = refl\n\nTerm-functionArity-inj : ∀ {fn₁ fn₂} {n N₁ N₂} {ts₁ : Vec (Term n) N₁} {ts₂ : Vec (Term n) N₂} → Term.function fn₁ ts₁ ≡ Term.function fn₂ ts₂ → N₁ ≡ N₂\nTerm-functionArity-inj refl = refl\n\nTerm-functionTerms-inj : ∀ {fn₁ fn₂} {n N} {ts₁ : Vec (Term n) N} {ts₂ : Vec (Term n) N} → Term.function fn₁ ts₁ ≡ Term.function fn₂ ts₂ → ts₁ ≡ ts₂\nTerm-functionTerms-inj refl = refl\n\nTerm-forkLeft-inj : ∀ {n} {l₁ r₁ l₂ r₂ : Term n} → l₁ fork r₁ ≡ l₂ fork r₂ → l₁ ≡ l₂\nTerm-forkLeft-inj refl = refl\n\nTerm-forkRight-inj : ∀ {n} {l₁ r₁ l₂ r₂ : Term n} → l₁ fork r₁ ≡ l₂ fork r₂ → r₁ ≡ r₂\nTerm-forkRight-inj refl = refl\n", "meta": {"hexsha": "b4091b9dc51de4b83cfd32b9b9ab87f09b667836", "size": 1105, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-2/Oscar/Data/Term/Injectivity.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-2/Oscar/Data/Term/Injectivity.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-2/Oscar/Data/Term/Injectivity.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.4642857143, "max_line_length": 153, "alphanum_fraction": 0.6733031674, "num_tokens": 448, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.877476793890012, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.6135795220045938}} {"text": "{-# OPTIONS --without-K #-}\r\n\r\nmodule Circle where\r\n\r\nopen import Agda.Prim\r\nopen import Data.Product\r\nopen import Function renaming (_∘_ to _○_)\r\n\r\ninfixr 8 _∘_ -- path composition\r\ninfix 4 _≡_ -- propositional equality\r\ninfix 4 _∼_ -- homotopy between two functions \r\ninfix 4 _≃_ -- type of equivalences\r\ninfix 2 _∎ -- equational reasoning\r\ninfixr 2 _≡⟨_⟩_ -- equational reasoning\r\n\r\n------------------------------------------------------------------------------\r\n-- Identity types\r\n\r\n-- Our own version of refl that makes 'a' explicit\r\n\r\ndata _≡_ {ℓ} {A : Set ℓ} : (a b : A) → Set ℓ where\r\n refl : (a : A) → (a ≡ a)\r\n\r\npathInd : ∀ {u ℓ} → {A : Set u} → \r\n (C : {x y : A} → x ≡ y → Set ℓ) → \r\n (c : (x : A) → C (refl x)) → \r\n ({x y : A} (p : x ≡ y) → C p)\r\npathInd C c (refl x) = c x\r\n\r\n------------------------------------------------------------------------------\r\n-- Ch. 2\r\n\r\n-- Lemma 2.1.1\r\n\r\n! : ∀ {u} → {A : Set u} {x y : A} → (x ≡ y) → (y ≡ x)\r\n! = pathInd (λ {x} {y} _ → y ≡ x) refl\r\n\r\n-- Lemma 2.1.2\r\n\r\n_∘_ : ∀ {u} → {A : Set u} → {x y z : A} → (x ≡ y) → (y ≡ z) → (x ≡ z)\r\n_∘_ {u} {A} {x} {y} {z} p q = \r\n pathInd \r\n (λ {x} {y} p → ((z : A) → (q : y ≡ z) → (x ≡ z)))\r\n (λ x z q → pathInd (λ {x} {z} _ → x ≡ z) refl {x} {z} q)\r\n {x} {y} p z q\r\n\r\n-- Lemma 2.1.4\r\n\r\n-- p = p . refl\r\n\r\nunitTransR : {A : Set} {x y : A} → (p : x ≡ y) → (p ≡ p ∘ refl y) \r\nunitTransR {A} {x} {y} p = \r\n pathInd\r\n (λ {x} {y} p → p ≡ p ∘ (refl y)) \r\n (λ x → refl (refl x))\r\n {x} {y} p \r\n\r\n-- p = refl . p\r\n\r\nunitTransL : {A : Set} {x y : A} → (p : x ≡ y) → (p ≡ refl x ∘ p) \r\nunitTransL {A} {x} {y} p = \r\n pathInd\r\n (λ {x} {y} p → p ≡ (refl x) ∘ p)\r\n (λ x → refl (refl x))\r\n {x} {y} p \r\n\r\n-- ! p . p = refl\r\n\r\ninvTransL : {A : Set} {x y : A} → (p : x ≡ y) → (! p ∘ p ≡ refl y)\r\ninvTransL {A} {x} {y} p = \r\n pathInd \r\n (λ {x} {y} p → ! p ∘ p ≡ refl y)\r\n (λ x → refl (refl x))\r\n {x} {y} p\r\n\r\n-- p . ! p = refl\r\n\r\ninvTransR : ∀ {ℓ} {A : Set ℓ} {x y : A} → (p : x ≡ y) → (p ∘ ! p ≡ refl x)\r\ninvTransR {ℓ} {A} {x} {y} p = \r\n pathInd\r\n (λ {x} {y} p → p ∘ ! p ≡ refl x)\r\n (λ x → refl (refl x))\r\n {x} {y} p\r\n\r\n-- ! (! p) = p\r\n\r\ninvId : {A : Set} {x y : A} → (p : x ≡ y) → (! (! p) ≡ p)\r\ninvId {A} {x} {y} p =\r\n pathInd \r\n (λ {x} {y} p → ! (! p) ≡ p)\r\n (λ x → refl (refl x))\r\n {x} {y} p\r\n\r\n-- p . (q . r) = (p . q) . r\r\n\r\nassocP : {A : Set} {x y z w : A} → (p : x ≡ y) → (q : y ≡ z) → (r : z ≡ w) →\r\n (p ∘ (q ∘ r) ≡ (p ∘ q) ∘ r)\r\nassocP {A} {x} {y} {z} {w} p q r =\r\n pathInd\r\n (λ {x} {y} p → (z : A) → (w : A) → (q : y ≡ z) → (r : z ≡ w) → \r\n p ∘ (q ∘ r) ≡ (p ∘ q) ∘ r)\r\n (λ x z w q r → \r\n pathInd\r\n (λ {x} {z} q → (w : A) → (r : z ≡ w) → \r\n (refl x) ∘ (q ∘ r) ≡ ((refl x) ∘ q) ∘ r)\r\n (λ x w r → \r\n pathInd\r\n (λ {x} {w} r → \r\n (refl x) ∘ ((refl x) ∘ r) ≡ \r\n ((refl x) ∘ (refl x)) ∘ r)\r\n (λ x → (refl (refl x)))\r\n {x} {w} r)\r\n {x} {z} q w r)\r\n {x} {y} p z w q r\r\n\r\n-- ! (p ∘ q) ≡ ! q ∘ ! p\r\n\r\ninvComp : {A : Set} {x y z : A} → (p : x ≡ y) → (q : y ≡ z) → \r\n ! (p ∘ q) ≡ ! q ∘ ! p\r\ninvComp {A} {x} {y} {z} p q = \r\n pathInd\r\n (λ {x} {y} p → (z : A) → (q : y ≡ z) → ! (p ∘ q) ≡ ! q ∘ ! p)\r\n (λ x z q → \r\n pathInd \r\n (λ {x} {z} q → ! (refl x ∘ q) ≡ ! q ∘ ! (refl x))\r\n (λ x → refl (refl x)) \r\n {x} {z} q)\r\n {x} {y} p z q\r\n\r\n-- Introduce equational reasoning syntax to simplify proofs\r\n\r\n_≡⟨_⟩_ : ∀ {u} → {A : Set u} (x : A) {y z : A} → (x ≡ y) → (y ≡ z) → (x ≡ z)\r\n_ ≡⟨ p ⟩ q = p ∘ q\r\n\r\nbydef : ∀ {u} → {A : Set u} {x : A} → (x ≡ x)\r\nbydef {u} {A} {x} = refl x\r\n\r\n_∎ : ∀ {u} → {A : Set u} (x : A) → x ≡ x\r\n_∎ x = refl x\r\n\r\n------------------------------------------------------------------------------\r\n-- Functions are functors\r\n\r\n-- Lemma 2.2.1\r\n-- computation rule: ap f (refl x) = refl (f x)\r\n\r\nap : ∀ {ℓ ℓ'} → {A : Set ℓ} {B : Set ℓ'} {x y : A} → \r\n (f : A → B) → (x ≡ y) → (f x ≡ f y)\r\nap {ℓ} {ℓ'} {A} {B} {x} {y} f p = \r\n pathInd \r\n (λ {x} {y} p → f x ≡ f y) \r\n (λ x → refl (f x))\r\n {x} {y} p\r\n\r\n-- Lemma 2.2.2\r\n\r\n-- f (p ∘ q) ≡ f p ∘ f q\r\n\r\napfTrans : ∀ {u} → {A B : Set u} {x y z : A} → \r\n (f : A → B) → (p : x ≡ y) → (q : y ≡ z) → ap f (p ∘ q) ≡ (ap f p) ∘ (ap f q)\r\napfTrans {u} {A} {B} {x} {y} {z} f p q = \r\n pathInd {u}\r\n (λ {x} {y} p → (z : A) → (q : y ≡ z) → \r\n ap f (p ∘ q) ≡ (ap f p) ∘ (ap f q))\r\n (λ x z q → \r\n pathInd {u}\r\n (λ {x} {z} q → \r\n ap f (refl x ∘ q) ≡ (ap f (refl x)) ∘ (ap f q))\r\n (λ x → refl (refl (f x)))\r\n {x} {z} q)\r\n {x} {y} p z q\r\n\r\n-- f (! p) ≡ ! (f p)\r\n\r\napfInv : ∀ {u} → {A B : Set u} {x y : A} → (f : A → B) → (p : x ≡ y) → \r\n ap f (! p) ≡ ! (ap f p) \r\napfInv {u} {A} {B} {x} {y} f p =\r\n pathInd {u}\r\n (λ {x} {y} p → ap f (! p) ≡ ! (ap f p))\r\n (λ x → refl (ap f (refl x)))\r\n {x} {y} p\r\n\r\n-- g (f p) ≡ (g ○ f) p\r\n\r\napfComp : {A B C : Set} {x y : A} → (f : A → B) → (g : B → C) → (p : x ≡ y) → \r\n ap g (ap f p) ≡ ap (g ○ f) p \r\napfComp {A} {B} {C} {x} {y} f g p =\r\n pathInd \r\n (λ {x} {y} p → ap g (ap f p) ≡ ap (g ○ f) p)\r\n (λ x → refl (ap g (ap f (refl x))))\r\n {x} {y} p\r\n\r\n-- id p ≡ p\r\n\r\napfId : {A : Set} {x y : A} → (p : x ≡ y) → ap id p ≡ p\r\napfId {A} {x} {y} p = \r\n pathInd \r\n (λ {x} {y} p → ap id p ≡ p)\r\n (λ x → refl (refl x))\r\n {x} {y} p\r\n\r\n-- Transport\r\n\r\n-- Lemma 2.3.1\r\n\r\ntransport : ∀ {ℓ ℓ'} → {A : Set ℓ} {x y : A} → \r\n (P : A → Set ℓ') → (p : x ≡ y) → P x → P y\r\ntransport {ℓ} {ℓ'} {A} {x} {y} P p = \r\n pathInd \r\n (λ {x} {y} p → (P x → P y))\r\n (λ _ → id)\r\n {x} {y} p\r\n\r\n-------------------------------------------------------------------------------\r\n-- Homotopies and equivalences\r\n\r\n_∼_ : ∀ {ℓ ℓ'} → {A : Set ℓ} {P : A → Set ℓ'} → \r\n (f g : (x : A) → P x) → Set (_⊔_ ℓ ℓ')\r\n_∼_ {ℓ} {ℓ'} {A} {P} f g = (x : A) → f x ≡ g x\r\n\r\n-- Quasi-inverses\r\n\r\nrecord qinv {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B) : \r\n Set (_⊔_ ℓ ℓ') where\r\n constructor mkqinv\r\n field\r\n g : B → A \r\n α : (f ○ g) ∼ id\r\n β : (g ○ f) ∼ id\r\n\r\n-- Example 2.4.7\r\n\r\nidqinv : ∀ {ℓ} → {A : Set ℓ} → qinv {ℓ} {ℓ} {A} {A} id\r\nidqinv = record {\r\n g = id ;\r\n α = λ b → refl b ; \r\n β = λ a → refl a\r\n } \r\n\r\n-- Equivalences\r\n\r\nrecord isequiv {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B) : \r\n Set (_⊔_ ℓ ℓ') where\r\n constructor mkisequiv\r\n field\r\n g : B → A \r\n α : (f ○ g) ∼ id\r\n h : B → A\r\n β : (h ○ f) ∼ id\r\n\r\nequiv₁ : ∀ {ℓ ℓ'} → {A : Set ℓ} {B : Set ℓ'} {f : A → B} → qinv f → isequiv f\r\nequiv₁ (mkqinv qg qα qβ) = mkisequiv qg qα qg qβ\r\n \r\n_≃_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Set (_⊔_ ℓ ℓ')\r\nA ≃ B = Σ (A → B) isequiv\r\n\r\n-- Lemma 2.4.12\r\n\r\nidequiv : ∀ {ℓ} {A : Set ℓ} → A ≃ A\r\nidequiv = (id , equiv₁ idqinv)\r\n\r\n------------------------------------------------------------------------------\r\n-- Sec. 2.10: Universes; univalence\r\n\r\nidtoeqv : {A B : Set} → (A ≡ B) → (A ≃ B)\r\nidtoeqv {A} {B} p = \r\n pathInd \r\n (λ {A} {B} p → A ≃ B)\r\n (λ A → idequiv)\r\n {A} {B} p\r\n\r\npostulate \r\n univalence : {A B : Set} → (A ≡ B) ≃ (A ≃ B)\r\n\r\n------------------------------------------------------------------------------\r\n-- Sec. 2.11: Identity types\r\n\r\n-- Thm 2.11.3\r\n\r\ntransportId : {A B : Set} {y z : A} → (f g : A → B) → \r\n (p : y ≡ z) → (q : f y ≡ g y) → \r\n transport (λ x → f x ≡ g x) p q ≡ ! (ap f p) ∘ q ∘ (ap g p)\r\ntransportId {A} {B} {y} {z} f g p q = \r\n pathInd \r\n (λ {y} {z} p → (q : f y ≡ g y) → \r\n transport (λ x → f x ≡ g x) p q ≡ ! (ap f p) ∘ q ∘ (ap g p))\r\n (λ y q → q \r\n ≡⟨ unitTransR q ⟩\r\n q ∘ refl (g y)\r\n ≡⟨ unitTransL (q ∘ refl (g y)) ⟩\r\n refl (f y) ∘ q ∘ refl (g y) ∎)\r\n {y} {z} p q \r\n\r\n------------------------------------------------------------------------------\r\n-- Exercise: let's show that the following two definitions of the\r\n-- circle are \"the same\"\r\n\r\n{--\r\n\r\ndata S¹ where\r\n base : S¹\r\n loop : base ≡ base\r\n\r\ndata S¹' where\r\n south : S¹'\r\n north : S¹'\r\n east : south ≡ north\r\n west : south ≡ north\r\n\r\n--}\r\n\r\nmodule Circle1 where\r\n private \r\n data S¹* : Set where\r\n base* : S¹*\r\n\r\n S¹ : Set\r\n S¹ = S¹*\r\n\r\n base : S¹\r\n base = base*\r\n\r\n postulate \r\n loop : base ≡ base\r\n\r\n recS¹ : {C : Set} → (cbase : C) → (cloop : cbase ≡ cbase) → S¹ → C\r\n recS¹ cbase cloop base* = cbase\r\n\r\n postulate\r\n βrecS¹ : {C : Set} → (cbase : C) → (cloop : cbase ≡ cbase) → \r\n ap (recS¹ cbase cloop) loop ≡ cloop\r\n \r\n indS¹ : {C : S¹ → Set} → \r\n (cbase : C base) → (cloop : transport C loop cbase ≡ cbase) → \r\n (circle : S¹) → C circle\r\n indS¹ cbase cloop base* = cbase\r\n\r\nopen Circle1 public\r\n\r\n--\r\n\r\nmodule Circle2 where\r\n private \r\n data S¹'* : Set where\r\n south* : S¹'*\r\n north* : S¹'*\r\n\r\n S¹' : Set\r\n S¹' = S¹'*\r\n\r\n south : S¹'\r\n south = south*\r\n\r\n north : S¹'\r\n north = north*\r\n\r\n postulate \r\n east : south ≡ north\r\n west : south ≡ north\r\n\r\n recS¹' : {C : Set} → \r\n (csouth cnorth : C) → (ceast cwest : csouth ≡ cnorth) → S¹' → C\r\n recS¹' csouth cnorth ceast cwest south* = csouth\r\n recS¹' csouth cnorth ceast cwest north* = cnorth\r\n\r\n postulate\r\n βreceastS¹' : {C : Set} → \r\n (csouth cnorth : C) → (ceast cwest : csouth ≡ cnorth) → \r\n ap (recS¹' csouth cnorth ceast cwest) east ≡ ceast\r\n βrecwestS¹' : {C : Set} → \r\n (csouth cnorth : C) → (ceast cwest : csouth ≡ cnorth) → \r\n ap (recS¹' csouth cnorth ceast cwest) west ≡ cwest\r\n \r\n indS¹' : {C : S¹' → Set} → \r\n (csouth : C south) → (cnorth : C north) → \r\n (ceast : transport C east csouth ≡ cnorth) → \r\n (cwest : transport C west csouth ≡ cnorth) → \r\n (circle : S¹') → C circle\r\n indS¹' csouth cnorth ceast cwest south* = csouth\r\n indS¹' csouth cnorth ceast cwest north* = cnorth\r\n\r\nopen Circle2 public\r\n\r\n-- Maps between Circle1 and Circle2 and back\r\n\r\n-- fcircle (base) = south\r\n-- fcircle (loop) = east ∘ ! west\r\n\r\nfcircle : S¹ → S¹'\r\nfcircle = recS¹ south (east ∘ ! west)\r\n\r\nfloop : ap fcircle loop ≡ (east ∘ ! west)\r\nfloop = βrecS¹ south (east ∘ ! west)\r\n\r\n-- gcircle (south) = base\r\n-- gcircle (north) = base\r\n-- gcircle (east) = loop\r\n-- gcircle (west) = refl base\r\n\r\ngcircle : S¹' → S¹\r\ngcircle = recS¹' base base loop (refl base)\r\n\r\ngeast : ap gcircle east ≡ loop\r\ngeast = βreceastS¹' base base loop (refl base)\r\n\r\ngwest : ap gcircle west ≡ (refl base)\r\ngwest = βrecwestS¹' base base loop (refl base)\r\n\r\n-- compose both ways\r\n\r\n-- gf (base) = base\r\n-- gf (loop) = loop\r\n\r\ngf : S¹ → S¹\r\ngf = gcircle ○ fcircle\r\n\r\ngfloop : ap gf loop ≡ loop\r\ngfloop = ap gf loop\r\n ≡⟨ ! (apfComp fcircle gcircle loop) ⟩ \r\n ap gcircle (ap fcircle loop)\r\n ≡⟨ ap (ap gcircle) floop ⟩\r\n ap gcircle (east ∘ ! west)\r\n ≡⟨ apfTrans gcircle east (! west) ⟩\r\n ap gcircle east ∘ ap gcircle (! west) \r\n ≡⟨ ap (λ x → ap gcircle east ∘ x) (apfInv gcircle west) ⟩\r\n ap gcircle east ∘ ! (ap gcircle west)\r\n ≡⟨ ap (λ x → ap gcircle east ∘ ! x) gwest ⟩\r\n ap gcircle east ∘ (refl base)\r\n ≡⟨ ! (unitTransR (ap gcircle east)) ⟩ \r\n ap gcircle east\r\n ≡⟨ geast ⟩ \r\n loop ∎\r\n\r\nαloop : transport (λ x → gf x ≡ x) loop (refl base) ≡ refl base\r\nαloop = transport (λ x → gf x ≡ x) loop (refl base) \r\n ≡⟨ transportId gf id loop (refl base) ⟩ -- Thm 2.11.3\r\n ! (ap gf loop) ∘ refl base ∘ ap id loop\r\n ≡⟨ ap (λ x → ! (ap gf loop) ∘ refl base ∘ x) (apfId loop) ⟩\r\n ! (ap gf loop) ∘ refl base ∘ loop\r\n ≡⟨ ap (λ x → ! (ap gf loop) ∘ x) (! (unitTransL loop)) ⟩ \r\n ! (ap gf loop) ∘ loop\r\n ≡⟨ ap (λ x → ! x ∘ loop) gfloop ⟩ \r\n ! loop ∘ loop\r\n ≡⟨ invTransL loop ⟩ \r\n refl base ∎\r\n\r\nβcircle : gf ∼ id\r\nβcircle = \r\n indS¹ {λ x → gf x ≡ x}\r\n (refl base) \r\n αloop\r\n\r\n-- fg (south) = south \r\n-- fg (north) = south\r\n-- fg (east) = east ∘ ! west\r\n-- fg (west) = refl south\r\n\r\nfg : S¹' → S¹'\r\nfg = fcircle ○ gcircle\r\n\r\nfgeast : ap fg east ≡ east ∘ ! west\r\nfgeast = ap fg east \r\n ≡⟨ ! (apfComp gcircle fcircle east) ⟩\r\n ap fcircle (ap gcircle east)\r\n ≡⟨ ap (ap fcircle) geast ⟩\r\n ap fcircle loop\r\n ≡⟨ floop ⟩\r\n (east ∘ ! west) ∎\r\n\r\nfgwest : ap fg west ≡ refl south\r\nfgwest = ap fg west\r\n ≡⟨ ! (apfComp gcircle fcircle west) ⟩ \r\n ap fcircle (ap gcircle west) \r\n ≡⟨ ap (ap fcircle) gwest ⟩\r\n ap fcircle (refl base)\r\n ≡⟨ bydef ⟩\r\n refl south ∎\r\n\r\nαeast : transport (λ x → fg x ≡ x) east (refl south) ≡ west\r\nαeast = transport (λ x → fg x ≡ x) east (refl south) \r\n ≡⟨ transportId fg id east (refl south) ⟩ -- Thm 2.11.3\r\n ! (ap fg east) ∘ refl south ∘ ap id east\r\n ≡⟨ ap (λ x → ! (ap fg east) ∘ refl south ∘ x) (apfId east) ⟩\r\n ! (ap fg east) ∘ refl south ∘ east\r\n ≡⟨ ap (λ x → ! (ap fg east) ∘ x) (! (unitTransL east)) ⟩\r\n ! (ap fg east) ∘ east\r\n ≡⟨ ap (λ x → ! x ∘ east) fgeast ⟩\r\n ! (east ∘ ! west) ∘ east\r\n ≡⟨ ap (λ x → x ∘ east) (invComp east (! west)) ⟩\r\n (! (! west) ∘ ! east) ∘ east\r\n ≡⟨ ! (assocP (! (! west)) (! east) east) ⟩ \r\n ! (! west) ∘ ! east ∘ east\r\n ≡⟨ ap (λ x → ! (! west) ∘ x) (invTransL east) ⟩\r\n ! (! west) ∘ refl north\r\n ≡⟨ ! (unitTransR (! (! west))) ⟩\r\n ! (! west)\r\n ≡⟨ invId west ⟩\r\n west ∎\r\n\r\nαwest : transport (λ x → fg x ≡ x) west (refl south) ≡ west\r\nαwest = transport (λ x → fg x ≡ x) west (refl south) \r\n ≡⟨ transportId fg id west (refl south) ⟩ -- Thm 2.11.3\r\n ! (ap fg west) ∘ refl south ∘ ap id west\r\n ≡⟨ ap (λ x → ! (ap fg west) ∘ refl south ∘ x) (apfId west) ⟩\r\n ! (ap fg west) ∘ refl south ∘ west\r\n ≡⟨ ap (λ x → ! (ap fg west) ∘ x) (! (unitTransL west)) ⟩\r\n ! (ap fg west) ∘ west\r\n ≡⟨ ap (λ x → ! x ∘ west) fgwest ⟩\r\n ! (refl south) ∘ west\r\n ≡⟨ ! (unitTransL west) ⟩\r\n west ∎\r\n\r\nαcircle : fg ∼ id\r\nαcircle = \r\n indS¹' {λ x → fg x ≡ x}\r\n (refl south) west\r\n αeast\r\n αwest\r\n\r\n--\r\n\r\nsequiv : S¹ ≃ S¹'\r\nsequiv = (fcircle , equiv₁ (mkqinv gcircle αcircle βcircle))\r\n\r\nspath : S¹ ≡ S¹'\r\nspath with univalence \r\n... | (_ , eq) = isequiv.g eq sequiv\r\n\r\n------------------------------------------------------------------------------\r\n", "meta": {"hexsha": "f55b6f716648fff6d73eb9b7de0612b23a5c70ce", "size": 14484, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "OBT/Circle.agda", "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_issues_repo_path": "OBT/Circle.agda", "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_forks_repo_path": "OBT/Circle.agda", "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "avg_line_length": 27.3283018868, "max_line_length": 80, "alphanum_fraction": 0.4136978735, "num_tokens": 6050, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289388252252041, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.6135592708814764}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Simple implementation of sets of ℕ.\n--\n-- Since ℕ is represented as unary numbers, simply having an ordered list of\n-- numbers to represent a set is quite inefficient. For instance, to see if\n-- 6 is in the set {1, 3, 4}, we have to do a comparison with 1, then 3, and\n-- then 4. But 4 is equal to suc 3, so we should be able to share the work\n-- accross those two comparisons.\n--\n-- This module defines a type that represents {1, 3, 4} as:\n--\n-- 1 ∷ 1 ∷ 0 ∷ []\n--\n-- i.e. we only store the gaps. When checking if a number (the needle) is in the\n-- set (the haystack), we subtract each successive member of the haystack from the\n-- needle as we go. For example, to check if 6 is in the above set, we do the\n-- following:\n--\n-- start: 6 ∈? (1 ∷ 1 ∷ 0 ∷ [])\n-- test head: 6 ≟ 1\n-- not equal, so continue: (6 - 1 - 1) ∈? (1 ∷ 0 ∷ [])\n-- compute: 4 ∈? (1 ∷ 0 ∷ [])\n-- test head: 4 ≟ 1\n-- not equal, so continue: (4 - 1 - 1) ∈? (0 ∷ [])\n-- compute: 2 ∈? (0 ∷ [])\n-- test head: 2 ≟ 0\n-- not equal, so continue: (2 - 1 - 1) ∈? []\n-- empty list: false\n--\n-- In this way, we change the membership test from O(n²) to O(n).\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Tactic.RingSolver.Core.NatSet where\n\nopen import Data.Nat as ℕ using (ℕ; suc; zero)\nopen import Data.List as List using (List; _∷_; [])\nopen import Data.Maybe.Base as Maybe using (Maybe; just; nothing)\nopen import Data.Bool as Bool using (Bool)\nopen import Function\nopen import Relation.Binary.PropositionalEquality\n\n------------------------------------------------------------------------\n-- Helper methods\n\npara : ∀ {a b} {A : Set a} {B : Set b} →\n (A → List A → B → B) → B → List A → B\npara f b [] = b\npara f b (x ∷ xs) = f x xs (para f b xs)\n\n------------------------------------------------------------------------\n-- Definition\n\nNatSet : Set\nNatSet = List ℕ\n\n------------------------------------------------------------------------\n-- Functions\n\ninsert : ℕ → NatSet → NatSet\ninsert x xs = para f (_∷ []) xs x\n where\n f : ℕ → NatSet → (ℕ → NatSet) → ℕ → NatSet\n f y ys c x with ℕ.compare x y\n ... | ℕ.less x k = x ∷ k ∷ ys\n ... | ℕ.equal x = x ∷ ys\n ... | ℕ.greater y k = y ∷ c k\n\ndelete : ℕ → NatSet → NatSet\ndelete x xs = para f (const []) xs x\n where\n f : ℕ → NatSet → (ℕ → NatSet) → ℕ → NatSet\n f y ys c x with ℕ.compare x y\n f y ys c x | ℕ.less x k = y ∷ ys\n f y [] c x | ℕ.equal x = []\n f y₁ (y₂ ∷ ys) c x | ℕ.equal x = suc x ℕ.+ y₂ ∷ ys\n f y ys c x | ℕ.greater y k = y ∷ c k\n\n-- Returns the position of the element, if it's present.\nlookup : ℕ → NatSet → Maybe ℕ\nlookup x xs = List.foldr f (const (const nothing)) xs x 0\n where\n f : ℕ → (ℕ → ℕ → Maybe ℕ) → ℕ → ℕ → Maybe ℕ\n f y ys x i with ℕ.compare x y\n ... | ℕ.less x k = nothing\n ... | ℕ.equal y = just i\n ... | ℕ.greater y k = ys k (suc i)\n\n\nmember : ℕ → NatSet → Bool\nmember x = Maybe.is-just ∘ lookup x\n\nfromList : List ℕ → NatSet\nfromList = List.foldr insert []\n\ntoList : NatSet → List ℕ\ntoList = List.drop 1 ∘ List.map ℕ.pred ∘ List.scanl (λ x y → suc (y ℕ.+ x)) 0\n\n------------------------------------------------------------------------\n-- Tests\n\nprivate\n example₁ : fromList (4 ∷ 3 ∷ 1 ∷ 0 ∷ 2 ∷ []) ≡ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ [])\n example₁ = refl\n\n example₂ : lookup 3 (fromList (4 ∷ 3 ∷ 1 ∷ 0 ∷ 2 ∷ [])) ≡ just 3\n example₂ = refl\n\n example₃ : toList (fromList (4 ∷ 3 ∷ 1 ∷ 0 ∷ 2 ∷ [])) ≡ (0 ∷ 1 ∷ 2 ∷ 3 ∷ 4 ∷ [])\n example₃ = refl\n\n example₄ : delete 3 (fromList (4 ∷ 3 ∷ 1 ∷ 2 ∷ [])) ≡ fromList (4 ∷ 1 ∷ 2 ∷ [])\n example₄ = refl\n\n example₅ : delete 3 (fromList (4 ∷ 1 ∷ 2 ∷ [])) ≡ fromList (4 ∷ 1 ∷ 2 ∷ [])\n example₅ = refl\n", "meta": {"hexsha": "d23c5e3d46bd6d7b014e30209566d311d652fc0b", "size": 3956, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Tactic/RingSolver/Core/NatSet.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Tactic/RingSolver/Core/NatSet.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Tactic/RingSolver/Core/NatSet.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 32.9666666667, "max_line_length": 82, "alphanum_fraction": 0.489635996, "num_tokens": 1319, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289387998695209, "lm_q2_score": 0.7401743735019594, "lm_q1q2_score": 0.6135592568648887}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties satisfied by meet semilattices\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary.Lattice\n\nmodule Relation.Binary.Properties.MeetSemilattice\n {c ℓ₁ ℓ₂} (M : MeetSemilattice c ℓ₁ ℓ₂) where\n\nopen MeetSemilattice M\n\nimport Algebra.FunctionProperties as P; open P _≈_\nopen import Data.Product\nopen import Function using (flip)\nopen import Relation.Binary\nopen import Relation.Binary.Properties.Poset poset\nimport Relation.Binary.Properties.JoinSemilattice as J\n\n-- The dual construction is a join semilattice.\n\ndualIsJoinSemilattice : IsJoinSemilattice _≈_ (flip _≤_) _∧_\ndualIsJoinSemilattice = record\n { isPartialOrder = invIsPartialOrder\n ; supremum = infimum\n }\n\ndualJoinSemilattice : JoinSemilattice c ℓ₁ ℓ₂\ndualJoinSemilattice = record\n { _∨_ = _∧_\n ; isJoinSemilattice = dualIsJoinSemilattice\n }\n\nopen J dualJoinSemilattice public\n using (isAlgSemilattice; algSemilattice)\n renaming\n ( ∨-monotonic to ∧-monotonic\n ; ∨-cong to ∧-cong\n ; ∨-comm to ∧-comm\n ; ∨-assoc to ∧-assoc\n ; ∨-idempotent to ∧-idempotent\n ; x≤y⇒x∨y≈y to y≤x⇒x∧y≈y\n )\n", "meta": {"hexsha": "2509e1d93ec2bad2c914129a7e98a7e0a3ba6284", "size": 1316, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Properties/MeetSemilattice.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Properties/MeetSemilattice.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Properties/MeetSemilattice.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.0, "max_line_length": 72, "alphanum_fraction": 0.6329787234, "num_tokens": 389, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.84997116805678, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.6134609160938148}} {"text": "module Groups.Symm.S3 where\n\nopen import Equality\n\n------------------------------------------------------------------------\n-- definitions\n\nbin-op : ∀ {a} (A : Set a) → Set a\nbin-op A = A → A → A\n\n------------------------------------------------------------------------\n-- internal stuffs\n\nprivate\n\n record S₃ {a} (A : Set a) : Set a where\n constructor ⟨_,_,_⟩-⟨_,_,_⟩-⟨_,_,_⟩\n infixl 5 _×_\n field\n x y {e} : A\n _×_ : bin-op A\n assoc : ∀ a b c → a × b × c ≡ a × (b × c) \n idₗ : ∀ n → n × e ≡ n\n idᵣ : ∀ n → e × n ≡ n\n law-xxx=e : x × x × x ≡ e\n law-yy=e : y × y ≡ e\n law-yx=xxy : y × x ≡ x × x × y\n\n law-xyx=y : Set a\n law-xyx=y = x × y × x ≡ y\n\n xyx=y : law-xyx=y\n xyx=y\n rewrite assoc x y x\n | law-yx=xxy\n | sym (assoc x (x × x) y)\n | sym (assoc x x x)\n | law-xxx=e\n = idᵣ y\n\n------------------------------------------------------------------------\n-- public aliases\n\ns3-property-1 : ∀ {a} (A : S₃ (Set a)) → S₃.law-xyx=y A\ns3-property-1 = S₃.xyx=y\n", "meta": {"hexsha": "618d09ccc57448b5ee9b03a921577a9d6b44a549", "size": 1080, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Groups/Symm/S3.agda", "max_stars_repo_name": "ice1k/Theorems", "max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z", "max_issues_repo_path": "src/Groups/Symm/S3.agda", "max_issues_repo_name": "ice1k/Theorems", "max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Groups/Symm/S3.agda", "max_forks_repo_name": "ice1k/Theorems", "max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.4782608696, "max_line_length": 72, "alphanum_fraction": 0.3518518519, "num_tokens": 368, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8652240791017535, "lm_q2_score": 0.709019146082187, "lm_q1q2_score": 0.6134604377344718}} {"text": "\nmodule Eq where\n\n import Prelude\n open Prelude\n\n abstract\n data _=^=_ {a : Set} (x y : a) : Set1 where\n leibniz : ((P : a -> Set) -> P x <-> P y) -> x =^= y\n\n leibnizSubst : {a : Set} -> {x y : a}\n -> x =^= y -> (P : a -> Set) -> P x -> P y\n leibnizSubst (leibniz f) P p = iffLeft (f P) p\n\n leibnizRefl : {a : Set} -> {x : a} -> x =^= x\n leibnizRefl = leibniz (\\_ -> iff id id)\n\n leibnizSym : {a : Set} -> {x y : a} -> x =^= y -> y =^= x\n leibnizSym (leibniz f) =\n leibniz (\\P -> iff (iffRight (f P)) (iffLeft (f P)))\n\n", "meta": {"hexsha": "844fb89834b4aeb056afb03d76a381077567fb9d", "size": 571, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/AIM4/bag/Eq.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/AIM4/bag/Eq.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/AIM4/bag/Eq.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 25.9545454545, "max_line_length": 61, "alphanum_fraction": 0.4570928196, "num_tokens": 247, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9219218262741297, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.6134565175419517}} {"text": "module Structure.Relator.Apartness.Proofs where\n\nopen import Data\nopen import Data.Either as Either\nopen import Data.Tuple as Tuple\nopen import Functional\nopen import Logic.Classical\nopen import Logic.Propositional\nopen import Logic.Propositional.Theorems\nimport Lvl\nopen import Structure.Relator.Apartness\nopen import Structure.Relator.Equivalence\nopen import Structure.Relator.Properties\nopen import Syntax.Implication\nopen import Type\n\nprivate variable ℓ ℓ₁ ℓ₂ ℓ₃ ℓₗ ℓₗ₁ ℓₗ₂ ℓₗ₃ ℓₗ₄ ℓₑ ℓₑ₁ ℓₑ₂ ℓₑ₃ ℓₑ₄ : Lvl.Level\nprivate variable T A B : Type{ℓ}\nprivate variable _▫_ : T → T → Type{ℓ}\n\nmodule _ {_▫_ : T → T → Type{ℓ}} where\n instance\n -- The negation of an apartness relation is an equivalence relation.\n -- This is a reason for using an apartness relation in constructive real mathematics. Both the apartness properties and the equivalence properties are sought after and by starting with an apartness relation, one gets both.\n apartness-equivalenceᵣ : ⦃ apart : Apartness(_▫_) ⦄ → Equivalence((¬_) ∘₂ (_▫_))\n Reflexivity.proof (Equivalence.reflexivity apartness-equivalenceᵣ) = irreflexivity(_▫_)\n Symmetry.proof (Equivalence.symmetry apartness-equivalenceᵣ) = contrapositiveᵣ(symmetry(_▫_))\n Transitivity.proof (Equivalence.transitivity apartness-equivalenceᵣ) nxy nyz = [∨]-elim nxy nyz ∘ cotransitivity(_▫_)\n\n module _ ⦃ classical : Classical₂(_▫_) ⦄ where\n equivalence-apartnessᵣ : ⦃ equi : Equivalence(_▫_) ⦄ → Apartness((¬_) ∘₂ (_▫_))\n Irreflexivity.proof (Apartness.irreflexivity equivalence-apartnessᵣ) = [¬¬]-intro (reflexivity(_▫_))\n Symmetry.proof (Apartness.symmetry equivalence-apartnessᵣ) = contrapositiveᵣ(symmetry(_▫_))\n CoTransitivity.proof (Apartness.cotransitivity equivalence-apartnessᵣ) {x}{y}{z} nxz with excluded-middle(x ▫ y) | excluded-middle(y ▫ z)\n ... | Left xy | Left yz with () ← nxz(transitivity(_▫_) xy yz)\n ... | Left xy | Right nyz = [∨]-introᵣ nyz\n ... | Right nxy | Left yz = [∨]-introₗ nxy\n ... | Right nxy | Right nyz = [∨]-introₗ nxy\n\n equivalence-apartnessₗ : ⦃ apart : Apartness((¬_) ∘₂ (_▫_)) ⦄ → Equivalence(_▫_)\n Reflexivity.proof (Equivalence.reflexivity equivalence-apartnessₗ) = [¬¬]-elim(irreflexivity((¬_) ∘₂ (_▫_)))\n Symmetry.proof (Equivalence.symmetry equivalence-apartnessₗ) = contrapositiveₗ(symmetry((¬_) ∘₂ (_▫_)))\n Transitivity.proof (Equivalence.transitivity equivalence-apartnessₗ) {x}{y}{z} xy yz with excluded-middle(x ▫ z)\n ... | Left xz = xz\n ... | Right nxz with cotransitivity((¬_) ∘₂ (_▫_)) nxz\n ... | Left nxy with () ← nxy xy\n ... | Right nyz with () ← nyz yz\n\n apartness-equivalenceₗ : ⦃ equi : Equivalence((¬_) ∘₂ (_▫_)) ⦄ → Apartness(_▫_)\n Irreflexivity.proof (Apartness.irreflexivity apartness-equivalenceₗ) = reflexivity((¬_) ∘₂ (_▫_))\n Symmetry.proof (Apartness.symmetry apartness-equivalenceₗ) = contrapositiveₗ(symmetry((¬_) ∘₂ (_▫_)))\n CoTransitivity.proof (Apartness.cotransitivity apartness-equivalenceₗ) {x}{y}{z} =\n (x ▫ z) ⇒-[ [¬¬]-intro ]\n ¬¬(x ▫ z) ⇒-[ contrapositiveᵣ(uncurry(transitivity((¬_) ∘₂ (_▫_)))) ]\n ¬(¬(x ▫ y) ∧ ¬(y ▫ z)) ⇒-[ [¬]-preserves-[∧][∨]ᵣ ]\n ¬¬(x ▫ y) ∨ ¬¬(y ▫ z) ⇒-[ Either.map [¬¬]-elim [¬¬]-elim ]\n (x ▫ y) ∨ (y ▫ z) ⇒-end\n", "meta": {"hexsha": "aec653fb4d9fb3a16987ff7ff841dc1c95c1d135", "size": 3325, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Relator/Apartness/Proofs.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Relator/Apartness/Proofs.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Relator/Apartness/Proofs.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 57.3275862069, "max_line_length": 226, "alphanum_fraction": 0.6709774436, "num_tokens": 1178, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.885631470799559, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.6134255382611397}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Algebra.Solver.Ring.AlmostCommutativeRing\n\n-- Some specialised tools for equaltional reasoning.\nmodule Polynomial.Reasoning\n {a ℓ}\n (ring : AlmostCommutativeRing a ℓ)\n where\n\nopen AlmostCommutativeRing ring\nopen import Relation.Binary.Reasoning.Inference setoid public\n\ninfixr 1 ≪+_ +≫_ ≪*_ *≫_\n≪+_ : ∀ {x₁ x₂ y} → x₁ ≈ x₂ → x₁ + y ≈ x₂ + y\n≪+ prf = +-cong prf refl\n\n+≫_ : ∀ {x y₁ y₂} → y₁ ≈ y₂ → x + y₁ ≈ x + y₂\n+≫_ = +-cong refl\n\n≪*_ : ∀ {x₁ x₂ y} → x₁ ≈ x₂ → x₁ * y ≈ x₂ * y\n≪* prf = *-cong prf refl\n\n*≫_ : ∀ {x y₁ y₂} → y₁ ≈ y₂ → x * y₁ ≈ x * y₂\n*≫_ = *-cong refl\n{-# INLINE ≪*_ #-}\n{-# INLINE ≪+_ #-}\n{-# INLINE *≫_ #-}\n{-# INLINE +≫_ #-}\n\n-- transitivity as an operator\ninfixr 0 _⊙_\n_⊙_ : ∀ {x y z} → x ≈ y → y ≈ z → x ≈ z\n_⊙_ = trans\n{-# INLINE _⊙_ #-}\n", "meta": {"hexsha": "d95b216d5114f74b7388a131ed18a2b4ad4fd5b9", "size": 811, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Polynomial/Reasoning.agda", "max_stars_repo_name": "mckeankylej/agda-ring-solver", "max_stars_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2019-01-25T16:40:52.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-15T00:57:55.000Z", "max_issues_repo_path": "src/Polynomial/Reasoning.agda", "max_issues_repo_name": "mckeankylej/agda-ring-solver", "max_issues_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2019-04-17T20:48:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T01:55:42.000Z", "max_forks_repo_path": "src/Polynomial/Reasoning.agda", "max_forks_repo_name": "mckeankylej/agda-ring-solver", "max_forks_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2019-04-16T02:23:16.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-20T07:07:11.000Z", "avg_line_length": 22.5277777778, "max_line_length": 61, "alphanum_fraction": 0.5672009864, "num_tokens": 361, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314617436728, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.61342553760762}} {"text": "module Algebra.Theorems where\n\nopen import Algebra\nopen import Reasoning\n\n+pre-idempotence : ∀ {A} {x : Graph A} -> x + x + ε ≡ x\n+pre-idempotence {_} {x} =\n begin\n (x + x) + ε ≡⟨ L (L (symmetry *right-identity)) ⟩\n (x * ε + x) + ε ≡⟨ L (R (symmetry *right-identity)) ⟩\n (x * ε + x * ε) + ε ≡⟨ R (symmetry *right-identity) ⟩\n (x * ε + x * ε) + ε * ε ≡⟨ symmetry decomposition ⟩\n (x * ε) * ε ≡⟨ *right-identity ⟩\n x * ε ≡⟨ *right-identity ⟩\n x\n ∎\n\n+identity : ∀ {A} {x : Graph A} -> x + ε ≡ x\n+identity {_} {x} =\n begin\n x + ε ≡⟨ symmetry +pre-idempotence ⟩\n ((x + ε) + (x + ε)) + ε ≡⟨ L +associativity ⟩\n (((x + ε) + x) + ε) + ε ≡⟨ L (L (symmetry +associativity)) ⟩\n ((x + (ε + x)) + ε) + ε ≡⟨ L (L (R +commutativity)) ⟩\n ((x + (x + ε)) + ε) + ε ≡⟨ L (L +associativity) ⟩\n (((x + x) + ε) + ε) + ε ≡⟨ L (symmetry +associativity) ⟩\n ((x + x) + (ε + ε)) + ε ≡⟨ symmetry +associativity ⟩\n (x + x) + ((ε + ε) + ε) ≡⟨ R +pre-idempotence ⟩\n (x + x) + ε ≡⟨ +pre-idempotence ⟩\n x\n ∎\n\n+idempotence : ∀ {A} {x : Graph A} -> x + x ≡ x\n+idempotence = transitivity (symmetry +identity) +pre-idempotence\n\nsaturation : ∀ {A} {x : Graph A} -> x * x * x ≡ x * x\nsaturation {_} {x} =\n begin\n (x * x) * x ≡⟨ decomposition ⟩\n (x * x + x * x) + x * x ≡⟨ L +idempotence ⟩\n x * x + x * x ≡⟨ +idempotence ⟩\n x * x\n ∎\n\nabsorption : ∀ {A} {x y : Graph A} -> x * y + x + y ≡ x * y\nabsorption {_} {x} {y} =\n begin\n (x * y + x) + y ≡⟨ L (R (symmetry *right-identity)) ⟩\n (x * y + x * ε) + y ≡⟨ R (symmetry *right-identity) ⟩\n (x * y + x * ε) + y * ε ≡⟨ symmetry decomposition ⟩\n (x * y) * ε ≡⟨ *right-identity ⟩\n x * y\n ∎\n\n-- Subgraph relation\n⊆reflexivity : ∀ {A} {x : Graph A} -> x ⊆ x\n⊆reflexivity = +idempotence\n\n⊆antisymmetry : ∀ {A} {x y : Graph A} -> x ⊆ y -> y ⊆ x -> x ≡ y\n⊆antisymmetry p q = symmetry q -- x = y + x\n >> +commutativity -- y + x = x + y\n >> p -- x + y = y\n\n⊆transitivity : ∀ {A} {x y z : Graph A} -> x ⊆ y -> y ⊆ z -> x ⊆ z\n⊆transitivity p q = symmetry\n (symmetry q -- z = y + z\n >> L (symmetry p) -- y + z = (x + y) + z\n >> symmetry +associativity -- (x + y) + z = x + (y + z)\n >> R q) -- x + (y + z) = x + z\n\n⊆least-element : ∀ {A} {x : Graph A} -> ε ⊆ x\n⊆least-element = +commutativity >> +identity\n\n⊆overlay : ∀ {A} {x y : Graph A} -> x ⊆ (x + y)\n⊆overlay = +associativity >> L +idempotence\n\n⊆connect : ∀ {A} {x y : Graph A} -> (x + y) ⊆ (x * y)\n⊆connect = +commutativity >> +associativity >> absorption\n\n⊆left-overlay-monotony : ∀ {A} {x y z : Graph A} -> x ⊆ y -> (x + z) ⊆ (y + z)\n⊆left-overlay-monotony {_} {x} {y} {z} p =\n begin\n (x + z) + (y + z) ≡⟨ symmetry +associativity ⟩\n x + (z + (y + z)) ≡⟨ R +commutativity ⟩\n x + ((y + z) + z) ≡⟨ R (symmetry +associativity) ⟩\n x + (y + (z + z)) ≡⟨ R (R +idempotence) ⟩\n x + (y + z) ≡⟨ +associativity ⟩\n (x + y) + z ≡⟨ L p ⟩\n y + z\n ∎\n\n⊆right-overlay-monotony : ∀ {A} {x y z : Graph A} -> x ⊆ y -> (z + x) ⊆ (z + y)\n⊆right-overlay-monotony {_} {x} {y} {z} p =\n begin\n (z + x) + (z + y) ≡⟨ +associativity ⟩\n ((z + x) + z) + y ≡⟨ L +commutativity ⟩\n (z + (z + x)) + y ≡⟨ L +associativity ⟩\n ((z + z) + x) + y ≡⟨ L (L +idempotence) ⟩\n (z + x) + y ≡⟨ symmetry +associativity ⟩\n z + (x + y) ≡⟨ R p ⟩\n z + y\n ∎\n\n⊆left-connect-monotony : ∀ {A} {x y z : Graph A} -> x ⊆ y -> (x * z) ⊆ (y * z)\n⊆left-connect-monotony {_} {x} {y} {z} p =\n begin\n (x * z) + (y * z) ≡⟨ symmetry right-distributivity ⟩\n (x + y) * z ≡⟨ L p ⟩\n y * z\n ∎\n\n⊆right-connect-monotony : ∀ {A} {x y z : Graph A} -> x ⊆ y -> (z * x) ⊆ (z * y)\n⊆right-connect-monotony {_} {x} {y} {z} p =\n begin\n (z * x) + (z * y) ≡⟨ symmetry left-distributivity ⟩\n z * (x + y) ≡⟨ R p ⟩\n z * y\n ∎\n\n⊆left-monotony : ∀ {A} {op : BinaryOperator} {x y z : Graph A} -> x ⊆ y -> apply op x z ⊆ apply op y z\n⊆left-monotony {_} {+op} {x} {y} {z} p = ⊆left-overlay-monotony p\n⊆left-monotony {_} {*op} {x} {y} {z} p = ⊆left-connect-monotony p\n\n⊆right-monotony : ∀ {A} {op : BinaryOperator} {x y z : Graph A} -> x ⊆ y -> apply op z x ⊆ apply op z y\n⊆right-monotony {_} {+op} {x} {y} {z} p = ⊆right-overlay-monotony p\n⊆right-monotony {_} {*op} {x} {y} {z} p = ⊆right-connect-monotony p\n", "meta": {"hexsha": "1dbdaea0b8d485ac67631dde40b76b12e98c95a2", "size": 4860, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Algebra/Theorems.agda", "max_stars_repo_name": "asr/alga", "max_stars_repo_head_hexsha": "01f5f9f53ea81f692215300744aa77e26d8bf332", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Algebra/Theorems.agda", "max_issues_repo_name": "asr/alga", "max_issues_repo_head_hexsha": "01f5f9f53ea81f692215300744aa77e26d8bf332", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Algebra/Theorems.agda", "max_forks_repo_name": "asr/alga", "max_forks_repo_head_hexsha": "01f5f9f53ea81f692215300744aa77e26d8bf332", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.2677165354, "max_line_length": 103, "alphanum_fraction": 0.4172839506, "num_tokens": 2035, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835371034368, "lm_q2_score": 0.7341195327172401, "lm_q1q2_score": 0.613344783851322}} {"text": "{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule LeibnizEquality where\n\n------------------------------------------------------------------------------\n-- The identity type.\ndata _≡_ {A : Set}(x : A) : A → Set where\n refl : x ≡ x\n\n-- Leibniz equality (see [Luo 1994, sec. 5.1.3])\n\n-- (From Agda/examples/lib/Logic/Leibniz.agda)\n_≐_ : {A : Set} → A → A → Set₁\nx ≐ y = (P : _ → Set) → P x → P y\n\n-- Properties\n≐-refl : {A : Set}{x : A} → x ≐ x\n≐-refl P Px = Px\n\n≐-sym : {A : Set}{x y : A} → x ≐ y → y ≐ x\n≐-sym {x = x} {y} h P Py = h (λ z → P z → P x) (λ Px → Px) Py\n\n≐-trans : {A : Set}{x y z : A} → x ≐ y → y ≐ z → x ≐ z\n≐-trans h₁ h₂ P Px = h₂ P (h₁ P Px)\n\n≐-subst : {A : Set}(P : A → Set){x y : A} → x ≐ y → P x → P y\n≐-subst P h = h P\n\n------------------------------------------------------------------------------\n-- Leibniz's equality and the identity type\n\n-- \"In the presence of a type of propositions \"Prop\" one can also\n-- define propositional equality by Leibniz's principle.\" [Hofmman\n-- 1995, p. 4]\n\n≐→≡ : {A : Set}{x y : A} → x ≐ y → x ≡ y\n≐→≡ {x = x} h = h (λ z → x ≡ z) refl\n\n≡→≐ : {A : Set}{x y : A} → x ≡ y → x ≐ y\n≡→≐ refl P Px = Px\n\n------------------------------------------------------------------------------\n-- References\n--\n-- Hofmann, Martin (1995). Extensional concepts in intensional type\n-- theory. PhD thesis. University of Edinburgh.\n\n-- Luo, Zhaohui (1994). Computation and Reasoning. A Type Theory for\n-- Computer Science. Oxford University Press.\n", "meta": {"hexsha": "a9f9539f45553719c5e6588ee4a93c67795c73eb", "size": 1611, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/setoids/LeibnizEquality.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/setoids/LeibnizEquality.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/setoids/LeibnizEquality.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 30.3962264151, "max_line_length": 78, "alphanum_fraction": 0.4636871508, "num_tokens": 556, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835411997897, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.6133447771384237}} {"text": "\nmodule Issue133 where\n\ndata Nat : Set where\n zz : Nat\n ss : Nat → Nat\n\ndata _==_ {X : Set}(x : X) : X → Set where\n refl : x == x\n\ndata Zero : Set where\n\ndata Eq? (x : Nat) : Nat → Set where\n same : Eq? x x\n diff : {y : Nat} → (x == y → Zero) → Eq? x y\n\n-- This failed before due to absurd lambda checking not getting\n-- postponed.\nioo : {y : Nat} → Eq? zz (ss y)\nioo {y} = diff λ ()\n\nfoo : {y : Nat} → zz == ss y → Zero\nfoo ()\n\ngoo : {y : Nat} → zz == ss y → Zero\ngoo = λ ()\n\nhoo : {y : Nat}{X : Set} → ((zz == ss y → Zero) → X) → X\nhoo boo = boo λ ()\n\n", "meta": {"hexsha": "1c2f030b97274f8c50775b169eba2f6f1df89364", "size": 559, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue133.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue133.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue133.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 18.0322580645, "max_line_length": 63, "alphanum_fraction": 0.5205724508, "num_tokens": 210, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267626522814, "lm_q2_score": 0.7057850154599562, "lm_q1q2_score": 0.6132049101105641}} {"text": "-- exercises\n-- * basic logic properties (implication, and, or, bot, not, forall, exists)\n-- * data types\n-- * records\n-- * non-dep, non-rec, non-indexed case splits\n-- * including elimination constants as hints\n-- * hidden arguments\n\nopen import Auto.Prelude\n\n\nh0 : (A : Set) → A → A\nh0 = {!!}\n--h0 = λ A z → z\n\nh1 : (A B : Set) → A → (A → B) → B\nh1 = {!!}\n--h1 = λ A B z z₁ → z₁ z\n\nh2 : ∀ A B → A ∧ B → B ∧ A\nh2 = {!!}\n--h2 = λ A B z → ∧-i (_∧_.snd z) (_∧_.fst z)\n\nh3 : ∀ A B C → (A ∧ B) ∧ C → A ∧ (B ∧ C)\nh3 = {!!}\n--h3 = λ A B C z →\n-- ∧-i (_∧_.fst (_∧_.fst z)) (∧-i (_∧_.snd (_∧_.fst z)) (_∧_.snd z))\n\n\nh4 : (A B C : Set) → A ∨ B → (A → C) → (B → C) → C\nh4 A B C x h₁ h₂ = {!-c!}\n\n\nh5 : ∀ A B → A ∨ B → B ∨ A\nh5 A B x = {!-c!}\n--h5 A B (∨-i₁ x) = ∨-i₂ x\n--h5 A B (∨-i₂ x) = ∨-i₁ x\n\nh6 : ∀ A B C → (A ∨ B) ∨ C → A ∨ (B ∨ C)\nh6 A B C x = {!-c!}\n--h6 A B C (∨-i₁ (∨-i₁ x)) = ∨-i₁ x\n--h6 A B C (∨-i₁ (∨-i₂ x)) = ∨-i₂ (∨-i₁ x)\n--h6 A B C (∨-i₂ x) = ∨-i₂ (∨-i₂ x)\n\nh7 : (A : Set) → ⊥ → A\nh7 A x = {!-c!}\n\n\n\nh8 : ∀ A → A → ¬ (¬ A)\nh8 = {!!}\n--h8 = λ A z z₁ → z₁ z\n\nh9 : ∀ A → ¬ (¬ (¬ A)) → ¬ A\nh9 = {!!}\n--h9 = λ A z z₁ → z (λ z₂ → z₂ z₁)\n\nh10 : (∀ A → ¬ (¬ A) → A) →\n (∀ A → A ∨ ¬ A)\nh10 = {!!}\n--h10 = λ z A →\n-- z (A ∨ ((x : A) → ⊥)) (λ z₁ → z₁ (∨-i₂ (λ x → z₁ (∨-i₁ x))))\n\nh11 : (∀ A → A ∨ ¬ A) →\n (∀ A → ¬ (¬ A) → A)\nh11 = {!∨-e ⊥-e!}\n--h11 = λ z A z₁ →\n-- ∨-e A ((x : A) → ⊥) A (z A) (λ z₂ → z₂) (λ z₂ → ⊥-e A (z₁ z₂))\n\n\nh12 : {X : Set} {P Q : X → Set} → ((x : X) → P x ∧ Q x) → ((x : X) → P x) ∧ ((x : X) → Q x)\nh12 = {!!}\n--h12 = λ {X} {P} {Q} z → ∧-i (λ x → _∧_.fst (z x)) (λ x → _∧_.snd (z x))\n\nh13 : {X : Set} {P Q : X → Set} → ((x : X) → P x) ∧ ((x : X) → Q x) → ((x : X) → P x ∧ Q x)\nh13 = {!!}\n--h13 = λ {X} {P} {Q} z x → ∧-i (_∧_.fst z x) (_∧_.snd z x)\n\n\n\nn0 : {X : Set} {P Q : X → Set} → Σ X (λ x → P x ∨ Q x) → Σ X P ∨ Σ X Q\n--n0 = {!∨-e!} -- no solution found, not even for the two subproofs\nn0 = λ h → ∨-e _ _ _ (Σ.prf h) (λ x → ∨-i₁ (Σ-i (Σ.wit h) x)) (λ x → ∨-i₂ (Σ-i (Σ.wit h) x))\n\nn1 : {X : Set} {P Q : X → Set} → Σ X P ∨ Σ X Q → Σ X (λ x → P x ∨ Q x)\n--n1 = {!∨-e!} -- no solution found, not even for the two subproofs\nn1 = λ h → ∨-e _ _ _ h (λ x → Σ-i (Σ.wit x) (∨-i₁ (Σ.prf x))) (λ x → Σ-i (Σ.wit x) (∨-i₂ (Σ.prf x)))\n\nh14 : {X : Set} → (x : X) → Σ X (λ x → ⊤)\nh14 = {!!}\n--h14 = λ {X} x → Σ-i x (record {})\n\nh15 : {X : Set} → Σ (X → X) (λ x → ⊤)\nh15 = {!!}\n--h15 = λ {X} → Σ-i (λ x → x) (record {})\n\nh16 : {X : Set} {P : X → Set} → Σ (X → X) (λ f → (x : X) → P (f x) → P x)\nh16 = {!!}\n--h16 = λ {X} {P} → Σ-i (λ x → x) (λ x x₁ → x₁)\n\nmodule Drink where\n\n postulate RAA : (A : Set) → (¬ A → ⊥) → A\n\n drink : (A : Set) → (a : A)\n → (Drink : A → Set) → Σ A (λ x → (Drink x) → Π A Drink)\n drink A a Drink = {!RAA!} -- h17\n{-\n drink A a Drink = RAA (Σ A (λ z → (x : Drink z) → Π A Drink))\n (λ z →\n z\n (Σ-i a\n (λ x →\n fun\n (λ a₁ →\n RAA (Drink a₁)\n (λ z₁ →\n z (Σ-i a₁ (λ x₁ → fun (λ a₂ → RAA (Drink a₂) (λ _ → z₁ x₁))))))))) -- h17\n-}\n", "meta": {"hexsha": "f81ac51a24e1c85115a97cafbf8dcb0a8f9808e1", "size": 3239, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Auto-BasicLogic.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/interaction/Auto-BasicLogic.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/interaction/Auto-BasicLogic.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 26.9916666667, "max_line_length": 108, "alphanum_fraction": 0.3599876505, "num_tokens": 1607, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.84594244507642, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.6131985388201673}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Operations on and properties of decidable relations\n--\n-- This file contains some core definitions which are re-exported by\n-- Relation.Nullary.Decidable\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Relation.Nullary.Decidable.Core where\n\nopen import Level using (Level; Lift)\nopen import Data.Bool.Base using (Bool; false; true; not; T)\nopen import Data.Unit.Base using (⊤)\nopen import Data.Empty\nopen import Data.Product\nopen import Function.Base\n\nopen import Agda.Builtin.Equality\nopen import Relation.Nullary.Reflects\nopen import Relation.Nullary\n\nprivate\n variable\n p q : Level\n P : Set p\n Q : Set q\n\n-- `isYes` is a stricter version of `does`. The lack of computation means that\n-- we can recover the proposition `P` from `isYes P?` by unification. This is\n-- useful when we are using the decision procedure for proof automation.\n\nisYes : Dec P → Bool\nisYes ( true because _) = true\nisYes (false because _) = false\n\nisYes≗does : (P? : Dec P) → isYes P? ≡ does P?\nisYes≗does ( true because _) = refl\nisYes≗does (false because _) = refl\n\n-- The traditional name for isYes is ⌊_⌋, indicating the stripping of evidence.\n⌊_⌋ = isYes\n\nisNo : Dec P → Bool\nisNo = not ∘ isYes\n\nTrue : Dec P → Set\nTrue Q = T (isYes Q)\n\nFalse : Dec P → Set\nFalse Q = T (isNo Q)\n\n-- Gives a witness to the \"truth\".\n\ntoWitness : {Q : Dec P} → True Q → P\ntoWitness {Q = true because [p]} _ = invert [p]\ntoWitness {Q = false because _ } ()\n\n-- Establishes a \"truth\", given a witness.\n\nfromWitness : {Q : Dec P} → P → True Q\nfromWitness {Q = true because _ } = const _\nfromWitness {Q = false because [¬p]} = invert [¬p]\n\n-- Variants for False.\n\ntoWitnessFalse : {Q : Dec P} → False Q → ¬ P\ntoWitnessFalse {Q = true because _ } ()\ntoWitnessFalse {Q = false because [¬p]} _ = invert [¬p]\n\nfromWitnessFalse : {Q : Dec P} → ¬ P → False Q\nfromWitnessFalse {Q = true because [p]} = flip _$_ (invert [p])\nfromWitnessFalse {Q = false because _ } = const _\n\n-- If a decision procedure returns \"yes\", then we can extract the\n-- proof using from-yes.\n\nmodule _ {p} {P : Set p} where\n\n From-yes : Dec P → Set p\n From-yes (true because _) = P\n From-yes (false because _) = Lift p ⊤\n\n from-yes : (p : Dec P) → From-yes p\n from-yes (true because [p]) = invert [p]\n from-yes (false because _ ) = _\n\n-- If a decision procedure returns \"no\", then we can extract the proof\n-- using from-no.\n\n From-no : Dec P → Set p\n From-no (false because _) = ¬ P\n From-no (true because _) = Lift p ⊤\n\n from-no : (p : Dec P) → From-no p\n from-no (false because [¬p]) = invert [¬p]\n from-no (true because _ ) = _\n\n------------------------------------------------------------------------\n-- Result of decidability\n\ndec-true : (p? : Dec P) → P → does p? ≡ true\ndec-true (true because _ ) p = refl\ndec-true (false because [¬p]) p = ⊥-elim (invert [¬p] p)\n\ndec-false : (p? : Dec P) → ¬ P → does p? ≡ false\ndec-false (false because _ ) ¬p = refl\ndec-false (true because [p]) ¬p = ⊥-elim (¬p (invert [p]))\n\ndec-yes : (p? : Dec P) → P → ∃ λ p′ → p? ≡ yes p′\ndec-yes p? p with dec-true p? p\ndec-yes (yes p′) p | refl = p′ , refl\n\ndec-no : (p? : Dec P) → ¬ P → ∃ λ ¬p′ → p? ≡ no ¬p′\ndec-no p? ¬p with dec-false p? ¬p\ndec-no (no ¬p′) ¬p | refl = ¬p′ , refl\n\ndec-yes-irr : (p? : Dec P) → Irrelevant P → (p : P) → p? ≡ yes p\ndec-yes-irr p? irr p with dec-yes p? p\n... | p′ , eq rewrite irr p p′ = eq\n\n------------------------------------------------------------------------\n-- Maps\n\nmap′ : (P → Q) → (Q → P) → Dec P → Dec Q\ndoes (map′ P→Q Q→P p?) = does p?\nproof (map′ P→Q Q→P (true because [p])) = ofʸ (P→Q (invert [p]))\nproof (map′ P→Q Q→P (false because [¬p])) = ofⁿ (invert [¬p] ∘ Q→P)\n", "meta": {"hexsha": "11734ac9c79b41c60ccbcd50b2f0069bdcda6122", "size": 3863, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Relation/Nullary/Decidable/Core.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Relation/Nullary/Decidable/Core.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Relation/Nullary/Decidable/Core.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 29.4885496183, "max_line_length": 79, "alphanum_fraction": 0.5762360859, "num_tokens": 1227, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.815232489352, "lm_q2_score": 0.7520125682019722, "lm_q1q2_score": 0.6130650779992844}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- The reflexive, symmetric and transitive closure of a binary\n-- relation (aka the equivalence closure).\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Relation.Binary.Construct.Closure.Equivalence where\n\nopen import Function using (flip; id; _∘_)\nopen import Level using (_⊔_)\nopen import Relation.Binary\nopen import Relation.Binary.Construct.Closure.ReflexiveTransitive as Star\n using (Star; ε; _◅◅_; reverse)\nopen import Relation.Binary.Construct.Closure.Symmetric as SC using (SymClosure)\n\n------------------------------------------------------------------------\n-- Definition\n\nEqClosure : ∀ {a ℓ} {A : Set a} → Rel A ℓ → Rel A (a ⊔ ℓ)\nEqClosure _∼_ = Star (SymClosure _∼_)\n\n------------------------------------------------------------------------\n-- Equivalence closures are equivalences.\n\nmodule _ {a ℓ} {A : Set a} (_∼_ : Rel A ℓ) where\n\n reflexive : Reflexive (EqClosure _∼_)\n reflexive = ε\n\n transitive : Transitive (EqClosure _∼_)\n transitive = _◅◅_\n\n symmetric : Symmetric (EqClosure _∼_)\n symmetric = reverse (SC.symmetric _∼_)\n\n isEquivalence : IsEquivalence (EqClosure _∼_)\n isEquivalence = record\n { refl = reflexive\n ; sym = symmetric\n ; trans = transitive\n }\n\n setoid : Setoid a (a ⊔ ℓ)\n setoid = record\n { _≈_ = EqClosure _∼_\n ; isEquivalence = isEquivalence\n }\n\n------------------------------------------------------------------------\n-- Operations\n\nmodule _ {a ℓ₁ ℓ₂} {A : Set a} where\n\n -- A generalised variant of map which allows the index type to change.\n\n gmap : ∀ {b} {B : Set b} {P : Rel A ℓ₁} {Q : Rel B ℓ₂} →\n (f : A → B) → P =[ f ]⇒ Q → EqClosure P =[ f ]⇒ EqClosure Q\n gmap {Q = Q} f = Star.gmap f ∘ SC.gmap {Q = Q} f\n\n map : ∀ {P : Rel A ℓ₁} {Q : Rel A ℓ₂} →\n P ⇒ Q → EqClosure P ⇒ EqClosure Q\n map = gmap id\n", "meta": {"hexsha": "9c1167ba912b65ba9a517076168cbc0fa1c953d2", "size": 1982, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Closure/Equivalence.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Closure/Equivalence.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Closure/Equivalence.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 30.0303030303, "max_line_length": 80, "alphanum_fraction": 0.5252270434, "num_tokens": 548, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152324713956854, "lm_q2_score": 0.7520125793176223, "lm_q1q2_score": 0.6130650735577492}} {"text": "{-# OPTIONS --safe --experimental-lossy-unification #-}\nmodule Cubical.Algebra.CommRing.Instances.Polynomials.MultivariatePoly where\n\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Data.Nat using (ℕ)\nopen import Cubical.Data.Sigma\nopen import Cubical.Data.Vec\nopen import Cubical.Data.Vec.OperationsNat\n\nopen import Cubical.Algebra.Monoid.Instances.NatVec\nopen import Cubical.Algebra.Ring\nopen import Cubical.Algebra.CommRing\nopen import Cubical.Algebra.GradedRing.DirectSumHIT\nopen import Cubical.Algebra.GradedRing.Instances.Polynomials\nopen import Cubical.Algebra.CommRing.Instances.Int\n\nprivate variable\n ℓ : Level\n\n-----------------------------------------------------------------------------\n-- General Nth polynome\n\nopen GradedRing-⊕HIT-index\nopen GradedRing-⊕HIT-⋆\nopen ExtensionCommRing\n\nmodule _\n (ACommRing@(A , Astr) : CommRing ℓ)\n (n : ℕ)\n where\n\n open CommRingStr Astr\n open RingTheory (CommRing→Ring ACommRing)\n\n PolyCommRing : CommRing ℓ\n PolyCommRing = ⊕HITgradedRing-CommRing\n (NatVecMonoid n)\n (λ _ → A)\n (λ _ → snd (Ring→AbGroup (CommRing→Ring ACommRing)))\n 1r _·_ 0LeftAnnihilates 0RightAnnihilates\n (λ a b c → ΣPathP ((+n-vec-assoc _ _ _) , (·Assoc _ _ _)))\n (λ a → ΣPathP ((+n-vec-rid _) , (·IdR _)))\n (λ a → ΣPathP((+n-vec-lid _) , (·IdL _)))\n ·DistR+\n ·DistL+\n λ x y → ΣPathP ((+n-vec-comm _ _) , (·Comm _ _))\n\n\n-----------------------------------------------------------------------------\n-- Notation and syntax in the case 1,2,3 and ℤ\n\nmodule _\n (Ar@(A , Astr) : CommRing ℓ)\n (n : ℕ)\n where\n\n Poly : Type ℓ\n Poly = fst (PolyCommRing Ar n)\n\n-- Possible renaming when you import\n-- (PolyCommRing to A[X1,···,Xn] ; Poly to A[x1,···,xn])\n", "meta": {"hexsha": "90e1be9faf8bad5d4eecf5fa8236b5823a1e30fe", "size": 1848, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials/MultivariatePoly.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials/MultivariatePoly.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials/MultivariatePoly.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.3333333333, "max_line_length": 77, "alphanum_fraction": 0.5957792208, "num_tokens": 539, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473779969194, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.6128502480996342}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.Group.Instances.Int where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Data.Int\n renaming (ℤ to ℤType ; _+_ to _+ℤ_ ; _-_ to _-ℤ_; -_ to -ℤ_ ; _·_ to _·ℤ_)\nopen import Cubical.Algebra.Group.Base\nopen import Cubical.Algebra.Group.Morphisms\nopen import Cubical.Algebra.Group.MorphismProperties\nopen import Cubical.Algebra.Group.Properties\n\nopen GroupStr\n\nℤ : Group₀\nfst ℤ = ℤType\n1g (snd ℤ) = 0\n_·_ (snd ℤ) = _+ℤ_\ninv (snd ℤ) = _-ℤ_ 0\nisGroup (snd ℤ) = isGroupℤ\n where\n abstract\n isGroupℤ : IsGroup (pos 0) _+ℤ_ (_-ℤ_ (pos 0))\n isGroupℤ = makeIsGroup isSetℤ +Assoc (λ _ → refl) (+Comm 0)\n (λ x → +Comm x (pos 0 -ℤ x) ∙ minusPlus x 0)\n (λ x → minusPlus x 0)\n\nℤHom : (n : ℤType) → GroupHom ℤ ℤ\nfst (ℤHom n) x = n ·ℤ x\nsnd (ℤHom n) =\n makeIsGroupHom λ x y → ·DistR+ n x y\n\nnegEquivℤ : GroupEquiv ℤ ℤ\nfst negEquivℤ =\n isoToEquiv\n (iso (GroupStr.inv (snd ℤ))\n (GroupStr.inv (snd ℤ))\n (GroupTheory.invInv ℤ)\n (GroupTheory.invInv ℤ))\nsnd negEquivℤ =\n makeIsGroupHom λ x y\n → +Comm (pos 0) (-ℤ (x +ℤ y))\n ∙ -Dist+ x y\n ∙ cong₂ _+ℤ_ (+Comm (-ℤ x) (pos 0)) (+Comm (-ℤ y) (pos 0))\n", "meta": {"hexsha": "2878504172a660d724dfa793980df10711bc3156", "size": 1274, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Group/Instances/Int.agda", "max_stars_repo_name": "MatthiasHu/cubical", "max_stars_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z", "max_issues_repo_path": "Cubical/Algebra/Group/Instances/Int.agda", "max_issues_repo_name": "Seanpm2001-web/cubical", "max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Group/Instances/Int.agda", "max_forks_repo_name": "Seanpm2001-web/cubical", "max_forks_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.3111111111, "max_line_length": 76, "alphanum_fraction": 0.6248037677, "num_tokens": 499, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473779969194, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.6128502426665358}} {"text": "\nopen import Agda.Builtin.Equality\n\nrecord IsGroup (G : Set) : Set where\n field _∙_ : G → G → G\n\nopen IsGroup ⦃ ... ⦄\n\nrecord Group : Set₁ where\n field G : Set\n ⦃ IsG ⦄ : IsGroup G\n\nopen Group using () renaming (G to [_])\n\nvariable\n G : Group\n\npostulate\n works : ∀ {G} → (x : [ G ]) → (x ∙ x) ≡ x\n fails : (x : [ G ]) → (x ∙ x) ≡ x\n -- WAS: No instance of type IsGroup [ G ]\n", "meta": {"hexsha": "61eb9548f42135ea741162b4f5c03f0f4089308a", "size": 394, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue3358.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue3358.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue3358.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 17.9090909091, "max_line_length": 43, "alphanum_fraction": 0.538071066, "num_tokens": 152, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8418256393148982, "lm_q2_score": 0.7279754489059774, "lm_q1q2_score": 0.6128283976808244}} {"text": "{-# OPTIONS --universe-polymorphism #-}\nmodule Categories.Monad.Strong where\n\nopen import Categories.Category\nopen import Categories.Monoidal\n\nopen import Categories.Functor\n renaming (id to idF; _∘_ to _∘F_; _≡_ to _≡F_)\nopen import Categories.Functor.Constant\nopen import Categories.NaturalTransformation\n renaming (id to idN; _≡_ to _≡N_)\nopen import Categories.NaturalIsomorphism\n using (module NaturalIsomorphism)\nopen import Categories.Monad\n\nopen import Categories.Product\n\nopen import Data.Fin using (Fin)\nopen import Function using (flip)\nopen import Data.Nat using ()\nopen import Data.Product using (_,_)\nopen import Data.Vec \n using (Vec; _∷_; []; [_]; lookup)\n\nopen import Level\n\nrecord Strength\n {o ℓ e}(C : Category o ℓ e)\n (monoidal : Monoidal C)\n (M : Monad C)\n : Set (o ⊔ ℓ ⊔ e) where\n open Category C\n \n open Monoidal monoidal \n using (⊗)\n renaming (id to idObj)\n open NaturalIsomorphism (Monoidal.identityˡ monoidal) using () renaming (F⇒G to υˡ)\n open NaturalIsomorphism (Monoidal.identityʳ monoidal) using () renaming (F⇒G to υʳ)\n open NaturalIsomorphism (Monoidal.assoc monoidal) using ()\n renaming (F⇒G to αʳ; F⇐G to αˡ)\n \n module υˡ = NaturalTransformation υˡ\n open Functor ⊗\n using ()\n renaming (F₀ to ⊗₀; F₁ to ⊗₁)\n \n unitorˡ : ∀ A → ⊗₀ (idObj , A) ⇒ A\n unitorˡ A = υˡ.η (flip lookup [ A ])\n \n associatorʳ : ∀ A B C → ⊗₀ (⊗₀ (A , B) , C) ⇒ ⊗₀ (A , ⊗₀ (B , C))\n associatorʳ A B C = NaturalTransformation.η αʳ (flip lookup (A ∷ B ∷ C ∷ []))\n \n associatorˡ : ∀ A B C → ⊗₀ (A , ⊗₀ (B , C)) ⇒ ⊗₀ (⊗₀ (A , B) , C)\n associatorˡ A B C = NaturalTransformation.η αˡ (flip lookup (A ∷ B ∷ C ∷ []))\n \n \n module M = Monad M\n open M using (F)\n open Functor F\n using (F₀; F₁)\n open NaturalTransformation M.η\n using (η)\n open NaturalTransformation M.μ\n using ()\n renaming (η to μ)\n \n field\n σ : NaturalTransformation (⊗ ∘F (idF {C = C} ⁂ F)) (F ∘F ⊗)\n \n module σ = NaturalTransformation σ\n \n field\n .identity₁ : ∀ {A} \n → F₁ (unitorˡ A) ∘ σ.η (idObj , A) \n ≡ unitorˡ (F₀ A)\n \n .identity₂ : ∀ {A B}\n → σ.η (A , B) ∘ ⊗₁ (id , η B)\n ≡ η (⊗₀ (A , B))\n \n α-assoc : ∀ {A B C}\n → F₁ (associatorʳ A B C) ∘ σ.η (⊗₀ (A , B) , C)\n ≡ σ.η (A , ⊗₀ (B , C)) ∘ ⊗₁ (id , σ.η (B , C)) ∘ associatorʳ A B (F₀ C)\n \n μ-assoc : ∀ {A B}\n → μ (⊗₀ (A , B)) ∘ F₁ (σ.η (A , B)) ∘ σ.η (A , F₀ B)\n ≡ σ.η (A , B) ∘ ⊗₁ (id , μ B)\n ", "meta": {"hexsha": "cc69ecebe1af9d924b4828483f8b9cef8c191ba2", "size": 2450, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Monad/Strong.agda", "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 98, "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_issues_repo_path": "Categories/Monad/Strong.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_forks_repo_path": "Categories/Monad/Strong.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 23, "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "avg_line_length": 27.8409090909, "max_line_length": 85, "alphanum_fraction": 0.5951020408, "num_tokens": 947, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8933094060543488, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.6127650945015373}} {"text": "open import Data.Nat\nopen import Data.Product\nopen import Data.Empty\nopen import Relation.Binary.PropositionalEquality\n\nmodule Stream where\n\n record Stream (A : Set) : Set where\n coinductive\n field\n head : A\n tail : Stream A\n open Stream public\n\n\n get : ∀ {A : Set} → Stream A → ℕ → A\n get s zero = head s\n get s (suc i) = get s i\n\n\n{-\n natsFrom : ℕ → Stream ℕ\n head (natsFrom x) = x\n tail (natsFrom x) = natsFrom (suc x)\n\n nats : Stream ℕ\n nats = natsFrom 0\n\n complicated-way-to-say-2 : head (tail (tail nats)) ≡ 2\n complicated-way-to-say-2 = refl\n\n -- thread a relation R through the elements of a stream\n record Trans {A : Set}(R : A → A → Set)(as : Stream A) : Set where\n coinductive\n field\n trans-head : R (head as) (head (tail as))\n trans-tail : Trans R (tail as)\n open Trans\n\n -- We can prove our generation of natural numbers to be correct!\n nats-correct : (n : ℕ) → Trans (λ x y → suc x ≡ y) (natsFrom n)\n trans-head (nats-correct n) = refl\n trans-tail (nats-correct n) = nats-correct (suc n)\n\n -----------------------------\n -- Talking Distr. Systems! --\n\n -- I hope I got the names right\n postulate\n State : Set\n Event : Set\n Enabled : State → Event → Set\n \n action : (s : State)(e : Event)\n → (enev : Enabled s e)\n → State\n\n _l-t_ : (State → Set) → (State → Set) → Set\n \n\n -- indicates a given post-state is a possible\n -- outcome from a given pre-state; witnesses the\n -- translation to the relational scheme I mentioned\n _⟶_ : State → State → Set \n s ⟶ s' = ∃[ e ] (Σ (Enabled s e) (λ enev → action s e enev ≡ s'))\n\n -- A Behavior, then, is a stream of states\n -- such that it starts at s₀ and all states\n -- are linked through the _⟶_ relation.\n -- You might want to have this in a single Beh record\n -- instead of assembling it from primitives\n Beh : State → Set\n Beh s₀ = Σ (Stream State) \n (λ st → head st ≡ s₀ × Trans _⟶_ st)\n\n \n module Absurd-DO-NOT-TRY-AT-HOME where\n\n data HeadOrTail {A : Set}(P : A → Set)(Q : Stream A → Set)\n : Stream A → Set where\n on-head : ∀{s} → P (head s) → HeadOrTail P Q s\n\n -- there might be a case for including (¬ P (head s)) here...\n on-tail : ∀{s} → Q (tail s) → HeadOrTail P Q s\n\n record Any {A : Set}(P : A → Set)(as : Stream A) : Set where\n coinductive\n field\n any : HeadOrTail P (Any P) as\n open Any public\n\n -- Witness is a proof by induction that places us \n -- at the position where P 'holds'; but as we shall see,\n -- this might never be the case and; even though the\n -- 'recursive' call makes 'progress' by traversing to the tail,\n -- it is not enough and we broke math anyway\n --\n -- Exercise to the reader: mark this function as\n -- NON_TERMINATING instead to see how Agda would stop us\n -- from breaking math! NON_TERMINATING definitions never reduce\n -- during typechecking; rendering them almost useless. They are only used\n -- when doing actual user IO AFAIC\n {-# TERMINATING #-}\n witness : {A : Set}{P : A → Set}{as : Stream A}\n → Any P as → Stream A\n witness x with any x\n ...| on-head {s} _ = s\n ...| on-tail {s} x' = witness {as = tail s} x'\n\n {-# NON_TERMINATING #-}\n witness-satP : {A : Set}{P : A → Set}{as : Stream A}\n → (x : Any P as) → P (head (witness x))\n witness-satP x with any x\n ...| on-head {s} p = p\n ...| on-tail x' = witness-satP x'\n\n never : {A : Set}(P : A → Set)(as : Stream A) → Any P as\n any (never P as) = on-tail (never P (tail as))\n\n -- This is why induction and coinduction can't be mixed! xD\n -- note that even marking one of them as non-terminating we still\n -- run into trouble\n oh-no! : ⊥\n oh-no! = witness-satP (never (λ _ → ⊥) nats)\n\n -----------------------------------------\n -- Trying Again; with naturals to help -- \n\n mutual\n data AtF {A : Set}(P : A → Set)\n : Stream A → ℕ → Set where\n on-head : ∀{s} → P (head s) → AtF P s 0\n\n on-tail : ∀{s n} → At P (tail s) n → AtF P s (suc n)\n\n record At {A : Set}(P : A → Set)(as : Stream A)(i : ℕ) : Set where\n coinductive\n field\n α : AtF P as i\n\n open At\n\n _satisfies_at_ : ∀{s₀}(σ : Beh s₀)(P : State → Set) → ℕ → Set\n σ satisfies P at i = At P (proj₁ σ) i\n\n -- Now, we can prove that a for all finite prefixes\n -- of an infinite behaviour such that they satisfy P\n -- at some observable point, they will satisfy Q at\n -- some future obervable point.\n\n -- Note the use of the word observable here! I like to think of coinduction\n -- in terms of dominos-chain-reaction. Imagine we want to knock a domino\n -- x₀ and we want to reason whether or not it knocks over a domino x'.\n -- Now sawy we reason like this:\n -- that we x₀ will knock x₁; which in turn will knock x₂; ... and\n -- eventually will knock x'. Well; it is induction that guarantees\n -- this for us, and induction requires the number of dominoes between\n -- x and x' to be countable (isomorphic to ℕ).\n --\n -- If there truly is an infinite number of dominoes between x and x',\n -- it means that no matter how far we get, there will always be \n -- at least one domino between where we are and x'; and the wave of\n -- knocks will never reach x', hence, that type of reasoning is plain invalid.\n --\n -- Behaviors are pottentially plain infinite; some systems never stop.\n -- We still want to guarantee certain invariants.\n -- \n\n -- Soundness, as I see it, is a proof that given any behavior σ\n -- that eventually satisfy P; and given that P leads to Q;\n -- any behaviour that forks of the point where σ satisfied P\n -- must satisfy Q; A first sketch in agda could be: \n soundness : {P Q : State → Set} \n → ∀{s₀ i}(σ : Beh s₀)(prf : σ satisfies P at i)\n → P l-t Q\n → Σ ℕ (λ j → σ satisfies Q at (j + i)) -- j + i already guarantess it is the future\n soundness = {! may-the-force-be-with-us !}\n-}\n", "meta": {"hexsha": "c093fddc44a369b8f21aa09b62397e9b550df7a6", "size": 6002, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Stream.agda", "max_stars_repo_name": "lisandrasilva/agda-liveness", "max_stars_repo_head_hexsha": "391e148f391dc2d246249193788a0d203285b38e", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Stream.agda", "max_issues_repo_name": "lisandrasilva/agda-liveness", "max_issues_repo_head_hexsha": "391e148f391dc2d246249193788a0d203285b38e", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Stream.agda", "max_forks_repo_name": "lisandrasilva/agda-liveness", "max_forks_repo_head_hexsha": "391e148f391dc2d246249193788a0d203285b38e", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.530726257, "max_line_length": 95, "alphanum_fraction": 0.6032989004, "num_tokens": 1827, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.831143060406073, "lm_q2_score": 0.7371581510799253, "lm_q1q2_score": 0.6126838816918515}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Functor.Instance.Core where\n\n-- Core Functor (from Cats to Groupoids).\n-- This is the right-adjoint of the forgetful functor from Groupoids to\n-- Cats (see Categories.Functor.Adjoint.Instance.Core)\n\nopen import Level using (_⊔_)\n\nopen import Categories.Category using (Category)\nimport Categories.Category.Construction.Core as C\nopen import Categories.Category.Groupoid using (Groupoid)\nopen import Categories.Category.Instance.Cats using (Cats)\nopen import Categories.Category.Instance.Groupoids using (Groupoids)\nopen import Categories.Functor using (Functor; _∘F_; id)\nopen import Categories.Functor.Properties using ([_]-resp-≅; [_]-resp-≃)\nopen import Categories.NaturalTransformation.NaturalIsomorphism\n using (NaturalIsomorphism)\nimport Categories.Morphism as Morphism\nopen import Categories.Morphism.IsoEquiv using (⌞_⌟)\nimport Categories.Morphism.Reasoning as MR\n\nCore : ∀ {o ℓ e} → Functor (Cats o ℓ e) (Groupoids o (ℓ ⊔ e) e)\nCore {o} {ℓ} {e} = record\n { F₀ = CoreGrpd\n ; F₁ = CoreFunctor\n ; identity = CoreId\n ; homomorphism = λ {A B C F G} → CoreHom {A} {B} {C} {F} {G}\n ; F-resp-≈ = CoreRespNI\n }\n where\n CoreGrpd : Category o ℓ e → Groupoid o (ℓ ⊔ e) e\n CoreGrpd C = record\n { category = C.Core C\n ; isGroupoid = C.Core-isGroupoid C\n }\n\n CoreFunctor : {A B : Category o ℓ e} →\n Functor A B → Functor (C.Core A) (C.Core B)\n CoreFunctor {A} {B} F = record\n { F₀ = F₀\n ; F₁ = [ F ]-resp-≅\n ; identity = ⌞ identity ⌟\n ; homomorphism = ⌞ homomorphism ⌟\n ; F-resp-≈ = [ F ]-resp-≃\n }\n where open Functor F\n\n CoreId : {A : Category o ℓ e} → NaturalIsomorphism (CoreFunctor {A} id) id\n CoreId {A} = record\n { F⇒G = record { η = λ _ → ≅.refl ; commute = λ _ → ⌞ MR.id-comm-sym A ⌟ ; sym-commute = λ _ → ⌞ MR.id-comm A ⌟ }\n ; F⇐G = record { η = λ _ → ≅.refl ; commute = λ _ → ⌞ MR.id-comm-sym A ⌟ ; sym-commute = λ _ → ⌞ MR.id-comm A ⌟ }\n ; iso = λ _ → record { isoˡ = ⌞ identity² ⌟ ; isoʳ = ⌞ identity² ⌟ }\n }\n where\n open Category A\n open Morphism A\n\n CoreHom : {A B C : Category o ℓ e}\n {F : Functor A B} {G : Functor B C} →\n NaturalIsomorphism (CoreFunctor (G ∘F F))\n (CoreFunctor G ∘F CoreFunctor F)\n CoreHom {A} {B} {C} {F} {G} = record\n { F⇒G = record { η = λ _ → ≅.refl ; commute = λ _ → ⌞ MR.id-comm-sym C ⌟ ; sym-commute = λ _ → ⌞ MR.id-comm C ⌟ }\n ; F⇐G = record { η = λ _ → ≅.refl ; commute = λ _ → ⌞ MR.id-comm-sym C ⌟ ; sym-commute = λ _ → ⌞ MR.id-comm C ⌟ }\n ; iso = λ _ → record { isoˡ = ⌞ identity² ⌟ ; isoʳ = ⌞ identity² ⌟ }\n }\n where\n open Category C\n open Morphism C\n\n CoreRespNI : {A B : Category o ℓ e} {F G : Functor A B} →\n NaturalIsomorphism F G →\n NaturalIsomorphism (CoreFunctor F) (CoreFunctor G)\n CoreRespNI {A} {B} {F} {G} μ = record\n { F⇒G = record { η = λ _ → FX≅GX ; commute = λ _ → ⌞ ⇒.commute _ ⌟ ; sym-commute = λ _ → ⌞ ⇒.sym-commute _ ⌟ }\n ; F⇐G = record { η = λ _ → ≅.sym FX≅GX ; commute = λ _ → ⌞ ⇐.commute _ ⌟ ; sym-commute = λ _ → ⌞ ⇐.sym-commute _ ⌟ }\n ; iso = λ X → record { isoˡ = ⌞ iso.isoˡ X ⌟ ; isoʳ = ⌞ iso.isoʳ X ⌟ }\n }\n where\n open NaturalIsomorphism μ\n open Morphism B\n", "meta": {"hexsha": "de66da1b4a2364b52e7ca12c93ac5ea1fecfd93d", "size": 3473, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Functor/Instance/Core.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Functor/Instance/Core.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Functor/Instance/Core.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 41.3452380952, "max_line_length": 123, "alphanum_fraction": 0.5655053268, "num_tokens": 1231, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797075998822, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.6126150010683138}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category.Core\nopen import Categories.Object.Zero\n\n-- Normal Mono and Epimorphisms\n-- https://ncatlab.org/nlab/show/normal+monomorphism\nmodule Categories.Morphism.Normal {o ℓ e} (𝒞 : Category o ℓ e) (𝒞-Zero : Zero 𝒞) where\n\nopen import Level\n\nopen import Categories.Object.Kernel 𝒞-Zero\nopen import Categories.Object.Kernel.Properties 𝒞-Zero\nopen import Categories.Morphism 𝒞\n\nopen Category 𝒞\n\nrecord IsNormalMonomorphism {A K : Obj} (k : K ⇒ A) : Set (o ⊔ ℓ ⊔ e) where\n field\n {B} : Obj\n arr : A ⇒ B\n isKernel : IsKernel k arr\n\n open IsKernel isKernel public\n\n mono : Mono k\n mono = Kernel-Mono (IsKernel⇒Kernel isKernel)\n\nrecord NormalMonomorphism (K A : Obj) : Set (o ⊔ ℓ ⊔ e) where\n field\n mor : K ⇒ A\n isNormalMonomorphism : IsNormalMonomorphism mor\n\n open IsNormalMonomorphism isNormalMonomorphism public\n", "meta": {"hexsha": "37c5fcfc18d398e85bd315be37b6a9c5f13aea56", "size": 890, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Morphism/Normal.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Morphism/Normal.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Morphism/Normal.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 25.4285714286, "max_line_length": 86, "alphanum_fraction": 0.7202247191, "num_tokens": 278, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9019206870747658, "lm_q2_score": 0.6791787121629466, "lm_q1q2_score": 0.6125653307205594}} {"text": "----------------------------------------------------------------\n-- This file contains the definition of natural isomorphisms. --\n----------------------------------------------------------------\nmodule Category.NatIsomorphism where\n\nopen import Category.NatTrans public\nopen import Category.Iso public\n\nrecord NatIso {l₁ l₂ : Level} \n {ℂ₁ : Cat {l₁}}\n {ℂ₂ : Cat {l₂}} \n (F G : Functor ℂ₁ ℂ₂) : Set (l₁ ⊔ l₂) where\n field\n -- The natural transformation.\n natt : NatTrans F G\n\n -- Each component of (η natt) is an iso.\n η-iso-ax : ∀{A : Obj ℂ₁} → Iso {l₂}{ℂ₂}{A = omap F A}{omap G A} (η natt A)\n \nopen NatIso public\n", "meta": {"hexsha": "9179e2536ee5406a42782420a3ea6900191eca90", "size": 669, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "setoid-cats/Category/NatIsomorphism.agda", "max_stars_repo_name": "heades/AUGL", "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "setoid-cats/Category/NatIsomorphism.agda", "max_issues_repo_name": "heades/AUGL", "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "setoid-cats/Category/NatIsomorphism.agda", "max_forks_repo_name": "heades/AUGL", "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.8571428571, "max_line_length": 78, "alphanum_fraction": 0.4872944694, "num_tokens": 183, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9019206659843132, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.6125653105395015}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Level using (Level)\nopen import Relation.Binary.PropositionalEquality using (_≡_; _≢_)\nopen import Data.Nat using (ℕ; suc; zero)\nopen import Data.Empty using (⊥)\nopen import Data.Vec using (Vec)\n renaming ([] to []ⱽ; _∷_ to _∷ⱽ_)\n\nmodule FLA.Data.Vec+.Base where\n\nprivate\n variable\n ℓ : Level\n A : Set ℓ\n n : ℕ\n\n-- TODO: Can this be replaced with something like the List⁺ definition so that\n-- the proofs from Vec can be transferred? This definition is convenient because\n-- the size is correct (it is not n - 1).\ndata Vec⁺ (A : Set ℓ) : ℕ → Set ℓ where\n [_] : A → Vec⁺ A 1\n _∷_ : ∀ {n} (x : A) (xs : Vec⁺ A n) → Vec⁺ A (suc n)\n\ninfixr 5 _∷_\n\n-- Want to prove that is it not possible to construct an empty vector\nemptyVecImpossible : Vec⁺ A 0 → ⊥\nemptyVecImpossible = λ ()\n\nVec⁺→Vec : Vec⁺ A n → Vec A n\nVec⁺→Vec [ v ] = v ∷ⱽ []ⱽ\nVec⁺→Vec (v ∷ vs⁺) = v ∷ⱽ Vec⁺→Vec vs⁺\n\nVec⁺→n≢0 : Vec⁺ A n → n ≢ 0\nVec⁺→n≢0 {ℓ} {A} {suc n} v = suc≢0\n where\n suc≢0 : {n : ℕ} → suc n ≢ 0\n suc≢0 {zero} ()\n suc≢0 {suc n} = λ ()\n\n-- Closer maybe but still buggered\n-- Vec→Vec⁺ : ∀ {ℓ} → {A : Set ℓ} {n : ℕ} → (n ≢ 0) → Vec A n → Vec⁺ A n\n-- Vec→Vec⁺ {ℓ} {A} {0} p []ⱽ = ⊥-elim (p refl)\n-- Vec→Vec⁺ {ℓ} {A} {1} p (x ∷ⱽ []ⱽ) = [ x ]\n-- Vec→Vec⁺ {ℓ} {A} {suc n} p (x ∷ⱽ xs) = x ∷ (Vec→Vec⁺ {!!} xs)\n", "meta": {"hexsha": "ee7b9bddcc276ff08b5650cf0f56d28d2c6b7cf2", "size": 1365, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/FLA/Data/Vec+/Base.agda", "max_stars_repo_name": "turion/functional-linear-algebra", "max_stars_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 21, "max_stars_repo_stars_event_min_datetime": "2020-09-22T20:49:34.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-07T05:28:00.000Z", "max_issues_repo_path": "src/FLA/Data/Vec+/Base.agda", "max_issues_repo_name": "turion/functional-linear-algebra", "max_issues_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2020-09-01T01:42:12.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-07T05:27:53.000Z", "max_forks_repo_path": "src/FLA/Data/Vec+/Base.agda", "max_forks_repo_name": "turion/functional-linear-algebra", "max_forks_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-04-12T20:34:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-07T19:55:59.000Z", "avg_line_length": 29.0425531915, "max_line_length": 80, "alphanum_fraction": 0.5655677656, "num_tokens": 593, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085808877581, "lm_q2_score": 0.7799929053683038, "lm_q1q2_score": 0.6125351216173021}} {"text": "module Relations where\n\n-- Imports\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong)\nopen import Data.Nat using (ℕ; zero; suc; _+_)\nopen import Data.Nat.Properties using (+-comm)\n\n-- Defining relations\n\ndata _≤_ : ℕ → ℕ → Set where\n\n z≤n : ∀ {n : ℕ}\n --------\n → zero ≤ n\n\n s≤s : ∀ {m n : ℕ}\n → m ≤ n\n -------------\n → suc m ≤ suc n\n\n_ : 2 ≤ 4\n_ = s≤s (s≤s z≤n)\n\n-- Implicit arguments\n\n_ : 2 ≤ 4\n_ = s≤s {1} {3} (s≤s {0} {2} (z≤n {2}))\n\n_ : 2 ≤ 4\n_ = s≤s {m = 1} {n = 3} (s≤s {m = 0} {n = 2} (z≤n {n = 2}))\n\n_ : 2 ≤ 4\n_ = s≤s {n = 3} (s≤s {n = 2} z≤n)\n\n-- Precedence\n\ninfix 4 _≤_\n\n-- Inversion\n\ninv-s≤s : ∀ {m n : ℕ}\n → suc m ≤ suc n\n -------------\n → m ≤ n\ninv-s≤s (s≤s m≤n) = m≤n\n\ninv-z≤n : ∀ {m : ℕ}\n → m ≤ zero\n --------\n → m ≡ zero\ninv-z≤n z≤n = refl\n\n-- Reflexivity (反射律)\n\n≤-refl : ∀ {n : ℕ}\n -----\n → n ≤ n\n≤-refl {zero} = z≤n\n≤-refl {suc n} = s≤s ≤-refl\n\n-- Transitivity (推移律)\n\n≤-trans : ∀ {m n p : ℕ}\n → m ≤ n\n → n ≤ p\n -----\n → m ≤ p\n≤-trans z≤n _ = z≤n\n≤-trans (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans m≤n n≤p)\n\n≤-trans′ : ∀ (m n p : ℕ)\n → m ≤ n\n → n ≤ p\n -----\n → m ≤ p\n≤-trans′ zero _ _ z≤n _ = z≤n\n≤-trans′ (suc m) (suc n) (suc p) (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans′ m n p m≤n n≤p)\n\n-- Anti-symmetry (非対称律)\n\n≤-antisym : ∀ {m n : ℕ}\n → m ≤ n\n → n ≤ m\n -----\n → m ≡ n\n≤-antisym z≤n z≤n = refl\n≤-antisym (s≤s m≤n) (s≤s n≤m) = cong suc (≤-antisym m≤n n≤m)\n\n-- Total (全順序)\n\ndata Total (m n : ℕ) : Set where\n\n forward :\n m ≤ n\n ---------\n → Total m n\n\n flipped :\n n ≤ m\n ---------\n → Total m n\n\ndata Total′ : ℕ → ℕ → Set where\n\n forward′ : ∀ {m n : ℕ}\n → m ≤ n\n ----------\n → Total′ m n\n\n flipped′ : ∀ {m n : ℕ}\n → n ≤ m\n ----------\n → Total′ m n\n\n≤-total : ∀ (m n : ℕ) → Total m n\n≤-total zero n = forward z≤n\n≤-total (suc m) zero = flipped z≤n\n≤-total (suc m) (suc n) with ≤-total m n\n... | forward m≤n = forward (s≤s m≤n)\n... | flipped n≤m = flipped (s≤s n≤m)\n\n≤-total′ : ∀ (m n : ℕ) → Total m n\n≤-total′ zero n = forward z≤n\n≤-total′ (suc m) zero = flipped z≤n\n≤-total′ (suc m) (suc n) = helper (≤-total′ m n)\n where\n helper : Total m n → Total (suc m) (suc n)\n helper (forward m≤n) = forward (s≤s m≤n)\n helper (flipped n≤m) = flipped (s≤s n≤m)\n\n≤-total″ : ∀ (m n : ℕ) → Total m n\n≤-total″ m zero = flipped z≤n\n≤-total″ zero (suc n) = forward z≤n\n≤-total″ (suc m) (suc n) with ≤-total″ m n\n... | forward m≤n = forward (s≤s m≤n)\n... | flipped n≤m = flipped (s≤s n≤m)\n\n-- Monotonicity (単調性)\n\n+-monoʳ-≤ : ∀ (n p q : ℕ)\n → p ≤ q\n -------------\n → n + p ≤ n + q\n+-monoʳ-≤ zero p q p≤q = p≤q\n+-monoʳ-≤ (suc n) p q p≤q = s≤s (+-monoʳ-≤ n p q p≤q)\n\n+-monoˡ-≤ : ∀ (m n p : ℕ)\n → m ≤ n\n -------------\n → m + p ≤ n + p\n+-monoˡ-≤ m n p m≤n rewrite +-comm m p | +-comm n p = +-monoʳ-≤ p m n m≤n\n\n+-mono-≤ : ∀ (m n p q : ℕ)\n → m ≤ n\n → p ≤ q\n -------------\n → m + p ≤ n + q\n+-mono-≤ m n p q m≤n p≤q = ≤-trans (+-monoˡ-≤ m n p m≤n) (+-monoʳ-≤ n p q p≤q)\n\n-- Strict inequality\n\ninfix 4 _<_\n\ndata _<_ : ℕ → ℕ → Set where\n\n z (l1 : ValidLens a b)\n -> (l2 : ValidLens b c)\n -> ViewSet ((toLens l1) ∘ (toLens l2))\nprop-Composition-ViewSet vl1@(CValidLens l1 vs1 sv1 ss1) vl2@(CValidLens l2 vs2 sv2 ss2) v s = \n begin \n view (l1 ∘ l2) (set (l1 ∘ l2) v s) \n =⟨ prop-view-compose vl1 vl2 (set (l1 ∘ l2) v s) ⟩\n view l2 ( view l1 (set (l1 ∘ l2) v s))\n =⟨ cong (view l2 ∘ view l1) (prop-set-compose-dir vl1 vl2 s v) ⟩\n view l2 ( view l1 (set l1 ((set l2 v) (view l1 s)) s))\n =⟨ cong (view l2) (vs1 ((set l2 v) (view l1 s)) s) ⟩\n view l2 (set l2 v (view l1 s))\n =⟨ vs2 v (view l1 s) ⟩\n v \n end\n\nprop-Composition-SetView : {a b c : Set} \n -> (l1 : ValidLens a b)\n -> (l2 : ValidLens b c)\n -> SetView ((toLens l1) ∘ (toLens l2))\nprop-Composition-SetView vl1@(CValidLens l1 vs1 sv1 ss1) vl2@(CValidLens l2 vs2 sv2 ss2) s = \n begin \n set (l1 ∘ l2) (view (l1 ∘ l2) s) s\n =⟨ cong (λ x -> set (l1 ∘ l2) x s) (prop-view-compose vl1 vl2 s) ⟩\n set (l1 ∘ l2) (view l2 (view l1 s)) s \n =⟨ prop-set-compose-dir vl1 vl2 s (view l2 (view l1 s)) ⟩\n set l1 (set l2 (view l2 (view l1 s)) (view l1 s)) s\n =⟨ cong (λ x -> set l1 x s) (sv2 (view l1 s)) ⟩\n set l1 (view l1 s) s\n =⟨ sv1 s ⟩\n s \n end\n\nprop-Composition-SetSet : {a b c : Set} \n -> (l1 : ValidLens a b)\n -> (l2 : ValidLens b c)\n -> SetSet ((toLens l1) ∘ (toLens l2))\nprop-Composition-SetSet vl1@(CValidLens l1 vs1 sv1 ss1) vl2@(CValidLens l2 vs2 sv2 ss2) v1 v2 s =\n begin \n set (l1 ∘ l2) v2 (set (l1 ∘ l2) v1 s)\n =⟨ cong (set (l1 ∘ l2) v2) (prop-set-compose-dir vl1 vl2 s v1) ⟩\n set (l1 ∘ l2) v2 (set l1 (set l2 v1 (view l1 s)) s)\n =⟨ prop-set-compose-dir vl1 vl2 (set l1 ((set l2 v1) (view l1 s)) s) v2 ⟩\n set l1 \n (set l2 \n v2 \n (view l1 \n (set l1 ((set l2 v1) (view l1 s)) s)\n )\n ) \n (set l1 (set l2 v1 (view l1 s)) s)\n =⟨ cong (λ x -> set l1 (set l2 v2 x) (set l1 ((set l2 v1) (view l1 s)) s)) (vs1 ((set l2 v1) (view l1 s)) s) ⟩\n set l1 \n (set l2 \n v2 \n (set l2 v1 (view l1 s))\n ) \n (set l1 (set l2 v1 (view l1 s)) s)\n =⟨ cong (λ x -> set l1 x (set l1 (set l2 v1 (view l1 s)) s)) (ss2 v1 v2 (view l1 s)) ⟩\n set l1 \n (set l2 \n v2 \n (view l1 s)\n ) \n (set l1 (set l2 v1 (view l1 s)) s)\n =⟨ ss1 ((set l2 v1 (view l1 s))) ((set l2 v2 (view l1 s))) s ⟩\n set l1 \n (set l2 \n v2 \n (view l1 s)\n ) \n s\n =⟨ sym (prop-set-compose-dir vl1 vl2 s v2) ⟩\n set (l1 ∘ l2) v2 s\n end\n\n-- Create a function that does the composition\ncomposeLens : {a b c : Set} -> (ValidLens a b) -> (ValidLens b c) -> (ValidLens a c)\ncomposeLens vl1@(CValidLens l1 vs1 sv1 ss1) vl2@(CValidLens l2 vs2 sv2 ss2) \n = CValidLens (l1 ∘ l2) (prop-Composition-ViewSet vl1 vl2) (prop-Composition-SetView vl1 vl2) (prop-Composition-SetSet vl1 vl2)", "meta": {"hexsha": "769bb9537f617ed1d0a701b81203b415efae6ff4", "size": 3525, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Lens/Proofs/LensComposition.agda", "max_stars_repo_name": "JonathanBrouwer/research-project", "max_stars_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-05-25T09:10:20.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-25T09:10:20.000Z", "max_issues_repo_path": "src/Data/Lens/Proofs/LensComposition.agda", "max_issues_repo_name": "JonathanBrouwer/research-project", "max_issues_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/Lens/Proofs/LensComposition.agda", "max_forks_repo_name": "JonathanBrouwer/research-project", "max_forks_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.9032258065, "max_line_length": 130, "alphanum_fraction": 0.5265248227, "num_tokens": 1394, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519527944504226, "lm_q2_score": 0.7185944046238982, "lm_q1q2_score": 0.6122085110957678}} {"text": "{-# OPTIONS --without-K --safe #-}\nopen import Categories.Category\n\n-- Exponential Object\n\n-- TODO: Where is the notation from? It is neither from Wikipedia nor the nLab.\nmodule Categories.Object.Exponential {o ℓ e} (𝒞 : Category o ℓ e) where\n\nopen Category 𝒞\n\nopen import Level\nopen import Function using (_$_)\n\nopen import Categories.Morphism.Reasoning 𝒞\nopen import Categories.Object.Product 𝒞\n hiding (repack; repack≡id; repack∘; repack-cancel; up-to-iso; transport-by-iso)\nopen import Categories.Morphism 𝒞\n\nopen HomReasoning\n\nprivate\n variable\n A B C D X Y : Obj\n\nrecord Exponential (A B : Obj) : Set (o ⊔ ℓ ⊔ e) where\n field\n B^A : Obj\n product : Product B^A A\n\n module product = Product product\n\n B^A×A : Obj\n B^A×A = product.A×B\n\n field\n eval : B^A×A ⇒ B\n λg : ∀ (X×A : Product X A) → (Product.A×B X×A ⇒ B) → (X ⇒ B^A)\n β : ∀ (X×A : Product X A) {g : Product.A×B X×A ⇒ B} →\n (eval ∘ [ X×A ⇒ product ] λg X×A g ×id ≈ g)\n λ-unique : ∀ (X×A : Product X A) {g : Product.A×B X×A ⇒ B} {h : X ⇒ B^A} →\n (eval ∘ [ X×A ⇒ product ] h ×id ≈ g) → (h ≈ λg X×A g)\n\n η : ∀ (X×A : Product X A) {f : X ⇒ B^A } → λg X×A (eval ∘ [ X×A ⇒ product ] f ×id) ≈ f\n η X×A {f} = sym (λ-unique X×A refl)\n\n λ-cong : ∀ {X : Obj} (X×A : Product X A) {f g} →\n f ≈ g → λg X×A f ≈ λg X×A g\n λ-cong X×A {f = f} {g = g} f≡g = λ-unique X×A (trans (β X×A) f≡g)\n\n subst : ∀ (p₂ : Product C A) (p₃ : Product D A) {f g} →\n λg p₃ f ∘ g ≈ λg p₂ (f ∘ [ p₂ ⇒ p₃ ] g ×id)\n subst p₂ p₃ {f} {g} = λ-unique p₂ (begin\n eval ∘ [ p₂ ⇒ product ] λg p₃ f ∘ g ×id\n ≈˘⟨ refl⟩∘⟨ [ p₂ ⇒ p₃ ⇒ product ]×id∘×id ⟩\n eval ∘ [ p₃ ⇒ product ] λg p₃ f ×id ∘ [ p₂ ⇒ p₃ ] g ×id\n ≈⟨ pullˡ (β p₃) ⟩\n f ∘ [ p₂ ⇒ p₃ ] g ×id ∎)\n\n η-id : λg product eval ≈ id\n η-id = begin\n λg product eval ≈˘⟨ identityʳ ⟩\n λg product eval ∘ id ≈⟨ subst _ _ ⟩\n λg product (eval ∘ [ product ⇒ product ] id ×id) ≈⟨ η product ⟩\n id ∎\n \n λ-unique′ : ∀ (X×A : Product X A) {h i : X ⇒ B^A} →\n eval ∘ [ X×A ⇒ product ] h ×id ≈ eval ∘ [ X×A ⇒ product ] i ×id → h ≈ i\n λ-unique′ p eq = trans (λ-unique p eq) (sym (λ-unique p refl))\n\n-- some aliases to make proof signatures less ugly\n[_]eval : ∀{A B}(e₁ : Exponential A B) → Exponential.B^A×A e₁ ⇒ B\n[ e₁ ]eval = Exponential.eval e₁\n\n[_]λ : ∀{A B}(e₁ : Exponential A B)\n → {X : Obj} → (X×A : Product X A) → (Product.A×B X×A ⇒ B) → (X ⇒ Exponential.B^A e₁)\n[ e₁ ]λ = Exponential.λg e₁\n\n{-\n D×C --id × f--> D×A --g--> B\n\n D --λ (g ∘ id × f)--> B^C\n \\ ^\n \\ /\n λ g λ (e ∘ id × f)\n \\ /\n v /\n B^A\n-}\nλ-distrib : ∀ (e₁ : Exponential C B) (e₂ : Exponential A B)\n (p₃ : Product D C) (p₄ : Product D A) (p₅ : Product (Exponential.B^A e₂) C)\n {f} {g : Product.A×B p₄ ⇒ B} →\n [ e₁ ]λ p₃ (g ∘ [ p₃ ⇒ p₄ ]id× f)\n ≈ [ e₁ ]λ p₅ ([ e₂ ]eval ∘ [ p₅ ⇒ Exponential.product e₂ ]id× f) ∘ [ e₂ ]λ p₄ g\nλ-distrib e₁ e₂ p₃ p₄ p₅ {f} {g} = sym $ e₁.λ-unique p₃ $ begin\n [ e₁ ]eval ∘ ([ p₃ ⇒ p₁ ] [ e₁ ]λ p₅ ([ e₂ ]eval ∘ [ p₅ ⇒ p₂ ]id× f) ∘ [ e₂ ]λ p₄ g ×id)\n ≈˘⟨ refl⟩∘⟨ [ p₃ ⇒ p₅ ⇒ p₁ ]×id∘×id ⟩\n [ e₁ ]eval ∘ [ p₅ ⇒ p₁ ] [ e₁ ]λ p₅ ([ e₂ ]eval ∘ [ p₅ ⇒ p₂ ]id× f) ×id\n ∘ [ p₃ ⇒ p₅ ] [ e₂ ]λ p₄ g ×id\n ≈⟨ pullˡ (e₁.β p₅) ⟩\n ([ e₂ ]eval ∘ [ p₅ ⇒ p₂ ]id× f)\n ∘ [ p₃ ⇒ p₅ ] [ e₂ ]λ p₄ g ×id\n ≈⟨ assoc ⟩\n [ e₂ ]eval ∘ [ p₅ ⇒ p₂ ]id× f\n ∘ [ p₃ ⇒ p₅ ] [ e₂ ]λ p₄ g ×id\n ≈˘⟨ refl⟩∘⟨ [ p₄ ⇒ p₂ , p₃ ⇒ p₅ ]first↔second ⟩\n [ e₂ ]eval ∘ [ p₄ ⇒ p₂ ] [ e₂ ]λ p₄ g ×id ∘ [ p₃ ⇒ p₄ ]id× f\n ≈⟨ pullˡ (e₂.β p₄) ⟩\n g ∘ [ p₃ ⇒ p₄ ]id× f ∎\n where module e₁ = Exponential e₁\n module e₂ = Exponential e₂\n p₁ = e₁.product\n p₂ = e₂.product\n\nrepack : ∀{A B} (e₁ e₂ : Exponential A B) → Exponential.B^A e₁ ⇒ Exponential.B^A e₂\nrepack e₁ e₂ = e₂.λg e₁.product e₁.eval\n where\n module e₁ = Exponential e₁\n module e₂ = Exponential e₂\n\nrepack≡id : ∀{A B} (e : Exponential A B) → repack e e ≈ id\nrepack≡id = Exponential.η-id\n\nrepack∘ : ∀ (e₁ e₂ e₃ : Exponential A B) → repack e₂ e₃ ∘ repack e₁ e₂ ≈ repack e₁ e₃\nrepack∘ e₁ e₂ e₃ =\n let p₁ = product e₁ in\n let p₂ = product e₂ in\n begin\n [ e₃ ]λ p₂ [ e₂ ]eval\n ∘ [ e₂ ]λ p₁ [ e₁ ]eval\n ≈⟨ λ-cong e₃ p₂ (introʳ (second-id p₂)) ⟩∘⟨refl ⟩\n [ e₃ ]λ p₂ ([ e₂ ]eval ∘ [ p₂ ⇒ p₂ ]id× id)\n ∘ [ e₂ ]λ p₁ [ e₁ ]eval\n ≈˘⟨ λ-distrib e₃ e₂ p₁ p₁ p₂ ⟩\n [ e₃ ]λ p₁ ([ e₁ ]eval ∘ [ p₁ ⇒ p₁ ]id× id)\n ≈⟨ λ-cong e₃ p₁ (⟺ (introʳ (second-id (product e₁)))) ⟩\n [ e₃ ]λ p₁ [ e₁ ]eval\n ∎\n where open Exponential\n\nrepack-cancel : ∀{A B} (e₁ e₂ : Exponential A B) → repack e₁ e₂ ∘ repack e₂ e₁ ≈ id\nrepack-cancel e₁ e₂ = repack∘ e₂ e₁ e₂ ○ repack≡id e₂\n\nup-to-iso : ∀{A B} (e₁ e₂ : Exponential A B) → Exponential.B^A e₁ ≅ Exponential.B^A e₂\nup-to-iso e₁ e₂ = record\n { from = repack e₁ e₂\n ; to = repack e₂ e₁\n ; iso = record\n { isoˡ = repack-cancel e₂ e₁\n ; isoʳ = repack-cancel e₁ e₂\n }\n }\n\ntransport-by-iso : ∀ (e : Exponential A B) → Exponential.B^A e ≅ X → Exponential A B\ntransport-by-iso {X = X} e e≅X = record\n { B^A = X\n ; product = X×A\n ; eval = e.eval\n ; λg = λ Y×A Y×A⇒B → from ∘ (e.λg Y×A Y×A⇒B)\n ; β = λ Y×A {h} → begin\n e.eval ∘ [ Y×A ⇒ X×A ] from ∘ e.λg Y×A h ×id ≈⟨ refl⟩∘⟨ e.product.⟨⟩-cong₂ (pullˡ (cancelˡ isoˡ))\n (elimˡ refl) ⟩\n e.eval ∘ [ Y×A ⇒ e.product ] e.λg Y×A h ×id ≈⟨ e.β Y×A ⟩\n h ∎\n ; λ-unique = λ Y×A {h} {i} eq →\n switch-tofromˡ e≅X $ e.λ-unique Y×A $ begin\n e.eval ∘ [ Y×A ⇒ e.product ] to ∘ i ×id ≈⟨ refl⟩∘⟨ e.product.⟨⟩-cong₂ assoc (introˡ refl) ⟩\n e.eval ∘ [ Y×A ⇒ X×A ] i ×id ≈⟨ eq ⟩\n h ∎\n }\n where module e = Exponential e\n X×A = Mobile e.product e≅X ≅.refl\n open _≅_ e≅X\n", "meta": {"hexsha": "da9c270b118836628d8378fac35adf31d54e9551", "size": 6329, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Object/Exponential.agda", "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Object/Exponential.agda", "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Object/Exponential.agda", "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.5838150289, "max_line_length": 101, "alphanum_fraction": 0.4675304155, "num_tokens": 2751, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519527982093666, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.6122085086626124}} {"text": "open import Functional hiding (Domain)\nimport Structure.Logic.Classical.NaturalDeduction\nimport Structure.Logic.Classical.SetTheory.ZFC\n\nmodule Structure.Logic.Classical.SetTheory.ZFC.BinaryRelatorSet {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} ⦃ classicLogic : _ ⦄ (_∈_ : Domain → Domain → Formula) ⦃ signature : _ ⦄ where\nopen Structure.Logic.Classical.NaturalDeduction.ClassicalLogic {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} (classicLogic)\nopen Structure.Logic.Classical.SetTheory.ZFC.Signature {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} ⦃ classicLogic ⦄ {_∈_} (signature)\n\nopen import Structure.Logic.Classical.SetTheory.SetBoundedQuantification ⦃ classicLogic ⦄ (_∈_)\n\n-- Like:\n-- (x,f(x)) = (x , y)\n-- f = {(x , y)}\n-- = {{{x},{x,y}}}\n-- ⋃f = {{x},{x,y}}\n-- ⋃²f = {x,y}\nlefts : Domain → Domain\nlefts(s) = filter(⋃(⋃ s)) (x ↦ ∃ₗ(y ↦ (x , y) ∈ s))\n\nrights : Domain → Domain\nrights(s) = filter(⋃(⋃ s)) (y ↦ ∃ₗ(x ↦ (x , y) ∈ s))\n\nleftsOfMany : Domain → Domain → Domain\nleftsOfMany f(S) = filter(⋃(⋃ f)) (a ↦ ∃ₛ(S)(y ↦ (a , y) ∈ f))\n\nrightsOfMany : Domain → Domain → Domain\nrightsOfMany f(S) = filter(⋃(⋃ f)) (a ↦ ∃ₛ(S)(x ↦ (x , a) ∈ f))\n\nleftsOf : Domain → Domain → Domain\nleftsOf f(y) = leftsOfMany f(singleton(y))\n\nrightsOf : Domain → Domain → Domain\nrightsOf f(x) = rightsOfMany f(singleton(x))\n\n-- swap : Domain → Domain\n-- swap(s) = filter(rights(s) ⨯ left(s)) (xy ↦ )\n", "meta": {"hexsha": "dd807214f9bfc86abcbe44e4e52c766fa6341bbb", "size": 1397, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "old/Structure/Logic/Classical/SetTheory/ZFC/BinaryRelatorSet.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "old/Structure/Logic/Classical/SetTheory/ZFC/BinaryRelatorSet.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "old/Structure/Logic/Classical/SetTheory/ZFC/BinaryRelatorSet.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.7567567568, "max_line_length": 185, "alphanum_fraction": 0.6342161775, "num_tokens": 551, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916134888613, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.6121611792217904}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Various forms of induction for natural numbers\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Induction.Nat where\n\nopen import Function\nopen import Data.Nat\nopen import Data.Nat.Properties using (≤⇒≤′)\nopen import Data.Fin using (_≺_)\nopen import Data.Fin.Properties\nopen import Data.Product\nopen import Data.Unit\nopen import Induction\nopen import Induction.WellFounded as WF\nopen import Level using (Lift)\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Unary\n\n------------------------------------------------------------------------\n-- Ordinary induction\n\nRec : ∀ ℓ → RecStruct ℕ ℓ ℓ\nRec ℓ P zero = Lift ℓ ⊤\nRec ℓ P (suc n) = P n\n\nrecBuilder : ∀ {ℓ} → RecursorBuilder (Rec ℓ)\nrecBuilder P f zero = _\nrecBuilder P f (suc n) = f n (recBuilder P f n)\n\nrec : ∀ {ℓ} → Recursor (Rec ℓ)\nrec = build recBuilder\n\n------------------------------------------------------------------------\n-- Complete induction\n\nCRec : ∀ ℓ → RecStruct ℕ ℓ ℓ\nCRec ℓ P zero = Lift ℓ ⊤\nCRec ℓ P (suc n) = P n × CRec ℓ P n\n\ncRecBuilder : ∀ {ℓ} → RecursorBuilder (CRec ℓ)\ncRecBuilder P f zero = _\ncRecBuilder P f (suc n) = f n ih , ih\n where ih = cRecBuilder P f n\n\ncRec : ∀ {ℓ} → Recursor (CRec ℓ)\ncRec = build cRecBuilder\n\n------------------------------------------------------------------------\n-- Complete induction based on _<′_\n\n<′-Rec : ∀ {ℓ} → RecStruct ℕ ℓ ℓ\n<′-Rec = WfRec _<′_\n\nmutual\n\n <′-wellFounded : WellFounded _<′_\n <′-wellFounded n = acc (<′-wellFounded′ n)\n\n <′-wellFounded′ : ∀ n → <′-Rec (Acc _<′_) n\n <′-wellFounded′ zero _ ()\n <′-wellFounded′ (suc n) .n ≤′-refl = <′-wellFounded n\n <′-wellFounded′ (suc n) m (≤′-step m_ = _<=_ -- ...and \"thinnings\" as arrows.\n ; id~> = oi\n ; _>~>_ = _o>>_\n ; law-id~>>~> = idThen-o>>\n ; law->~>id~> = idAfter-o>>\n ; law->~>>~> = assoc-o>>\n }\n\nVEC : Nat -> SET => SET -- Vectors of length n...\nVEC n = record\n { F-Obj = \\ X -> Vec X n -- ...give a functor from SET to SET...\n ; F-map = \\ f xs -> vMap f xs -- ...doing vMap to arrows.\n\n -- Now prove the laws.\n ; F-map-id~> = extensionality \\ xs -> {!!}\n ; F-map->~> = \\ f g -> extensionality \\ xs -> {!!}\n }\n\n\n\nOp : Category -> Category -- Every category has an opposite...\nOp C = record\n { Obj = Obj -- ...with the same objects, but...\n ; _~>_ = \\ S T -> T ~> S -- ...arrows that go backwards!\n -- Now, find the rest!\n ; id~> = id~>\n ; _>~>_ = \\ f g -> g >~> f\n ; law-id~>>~> = law->~>id~>\n ; law->~>id~> = law-id~>>~>\n ; law->~>>~> = {!!}\n } where open Category C\n\nCHOOSE : Set -> OPE => Op SET -- Show that thinnings from n to m...\nCHOOSE X = record -- ...act by selection...\n { F-Obj = Vec X -- ...to cut vectors down from m to n.\n ; F-map = {!!}\n ; F-map-id~> = extensionality {!!}\n ; F-map->~> = \\ f g -> extensionality {!!}\n }\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- The List Monad (a warm-up)\n------------------------------------------------------------------------------\n\n-- The declaration of List has been added to the CS410-Prelude file:\n\n-- data List (X : Set) : Set where\n-- [] : List X\n-- _,-_ : (x : X)(xs : List X) -> List X\n-- infixr 4 _,-_\n\n-- Appending two lists is rather well known, so I'll not ask you to write it.\n\n_+L_ : {X : Set} -> List X -> List X -> List X\n[] +L ys = ys\n(x ,- xs) +L ys = x ,- (xs +L ys)\ninfixr 4 _+L_\n\n-- But I will ask you to find some structure for it.\n\n\n--??--2.2---------------------------------------------------------------------\n\nLIST-MONOID : Set -> Category\nLIST-MONOID X = -- Show that _+L_ is the operation of a monoid,...\n record\n { Obj = One -- ... i.e., a category with one object.\n ; _~>_ = {!!}\n ; id~> = {!!}\n ; _>~>_ = {!!}\n ; law-id~>>~> = {!!}\n ; law->~>id~> = {!!}\n ; law->~>>~> = {!!}\n } where\n -- useful helper proofs (lemmas) go here\n\n--??--------------------------------------------------------------------------\n\n-- Next, functoriality of lists. Given a function on elements, show how to\n-- apply that function to all the elements of a list. (Haskell calls this\n-- operation \"map\".)\n\n--??--2.3---------------------------------------------------------------------\n\nlist : {X Y : Set} -> (X -> Y) -> List X -> List Y\nlist f xs = {!!}\n\nLIST : SET => SET\nLIST = record\n { F-Obj = List\n ; F-map = list\n ; F-map-id~> = extensionality {!!}\n ; F-map->~> = \\ f g -> extensionality {!!}\n } where\n -- useful helper proofs (lemmas) go here\n\n--??--------------------------------------------------------------------------\n\n\n-- Moreover, applying a function elementwise should respect appending.\n\n--??--2.4---------------------------------------------------------------------\n\nLIST+L : {X Y : Set}(f : X -> Y) -> LIST-MONOID X => LIST-MONOID Y\nLIST+L {X}{Y} f = record\n { F-Obj = id\n ; F-map = list f -- this yellow will go once LIST-MONOID has arrows!\n ; F-map-id~> = {!!}\n ; F-map->~> = {!!}\n } where\n -- useful helper proofs (lemmas) go here\n\n\n--??--------------------------------------------------------------------------\n\n\n-- Next, we have two very important \"natural transformations\".\n\n--??--2.5---------------------------------------------------------------------\n\nSINGLE : ID ~~> LIST\nSINGLE = record\n { xf = \\ x -> x ,- [] -- turn a value into a singleton list\n ; naturality = \\ f -> {!!}\n }\n\n--??--------------------------------------------------------------------------\n\n-- Here, naturality means that it doesn't matter\n-- whether you apply a function f, then make a singleton list\n-- or you make a singleton list, then apply f to all (one of) its elements.\n\n\n-- Now, define the operation that concatenates a whole list of lists, and\n-- show that it, too, is natural. That is, it doesn't matter whether you\n-- transform the elements (two layers inside) then concatenate, or you\n-- concatenate, then transform the elements.\n\n--??--2.6---------------------------------------------------------------------\n\nconcat : {X : Set} -> List (List X) -> List X\nconcat xss = {!!}\n\nCONCAT : (LIST >=> LIST) ~~> LIST\nCONCAT = record\n { xf = concat\n ; naturality = {!!}\n } where\n -- useful helper proofs (lemmas) go here\n\n--??--------------------------------------------------------------------------\n\n\n-- You've nearly built your first monad! You just need to prove that\n-- single and concat play nicely with each other.\n\n--??--2.7---------------------------------------------------------------------\n\nmodule LIST-MONAD where\n open MONAD LIST public\n ListMonad : Monad\n ListMonad = record\n { unit = SINGLE\n ; mult = CONCAT\n ; unitMult = {!!}\n ; multUnit = {!!}\n ; multMult = {!!}\n } where\n -- useful helper proofs (lemmas) go here\n\n-- open LIST-MONAD\n\n--??--------------------------------------------------------------------------\n\n-- More monads to come...\n\n\n------------------------------------------------------------------------------\n-- Categories of Indexed Sets\n------------------------------------------------------------------------------\n\n-- We can think of some\n-- P : I -> Set\n-- as a collection of sets indexed by I, such that\n-- P i\n-- means \"exactly the P-things which fit with i\".\n\n-- You've met\n-- Vec X : Nat -> Set\n-- where\n-- Vec X n\n-- means \"exactly the vectors which fit with n\".\n\n-- Now, given two such collections, S and T, we can make a collection\n-- of function types: the functions which fit with i map the\n-- S-things which fit with i to the T-things which fit with i.\n\n_-:>_ : {I : Set} -> (I -> Set) -> (I -> Set) -> (I -> Set)\n(S -:> T) i = S i -> T i\n\n-- So, (Vec X -:> Vec Y) n contains the functions which turn\n-- n Xs into n Ys.\n\n-- Next, if we know such a collection of sets, we can claim to have\n-- one for each index.\n\n[_] : {I : Set} -> (I -> Set) -> Set\n[ P ] = forall i -> P i -- [_] {I} P = (i : I) -> P i\n\n-- E.g., [ Vec X -:> Vec Y ] is the type of functions from X-vectors\n-- to Y-vectors which preserve length.\n\n-- For any such I, we get a category of indexed sets with index-preserving\n-- functions.\n\n_->SET : Set -> Category\nI ->SET = record\n { Obj = I -> Set -- I-indexed sets\n ; _~>_ = \\ S T -> [ S -:> T ] -- index-respecting functions\n ; id~> = \\ i -> id -- the identity at every index\n ; _>~>_ = \\ f g i -> f i >> g i -- composition at every index\n ; law-id~>>~> = refl -- and the laws are very boring\n ; law->~>id~> = refl\n ; law->~>>~> = \\ f g h -> refl _\n }\n\n-- In fact, we didn't need to choose SET here. We could do this construction\n-- for any category: index the objects; index the morphisms.\n-- But SET is plenty to be getting on with.\n\n-- Now, let me define an operation that makes types from lists.\n\nAll : {X : Set} -> (X -> Set) -> (List X -> Set)\nAll P [] = One\nAll P (x ,- xs) = P x * All P xs\n\n-- The idea is that we get a tuple of P-things: one for each list element.\n-- So\n-- All P (1 ,- 2 ,- 3 ,- [])\n-- = P 1 * P 2 * P 3 * One\n\n-- Note that if you think of List One as a version of Nat,\n-- All becomes a lot like Vec.\n\ncopy : Nat -> List One\ncopy zero = []\ncopy (suc n) = <> ,- copy n\n\nVecCopy : Set -> Nat -> Set\nVecCopy X n = All (\\ _ -> X) (copy n)\n\n-- Now, your turn...\n\n--??--2.8---------------------------------------------------------------------\n\n-- Show that, for any X, All induces a functor\n-- from (X ->SET) to (List X ->SET)\n\nall : {X : Set}{S T : X -> Set} ->\n [ S -:> T ] -> [ All S -:> All T ]\nall f xs ss = {!!}\n\nALL : (X : Set) -> (X ->SET) => (List X ->SET)\nALL X = record\n { F-Obj = All\n ; F-map = all\n ; F-map-id~> = {!!}\n ; F-map->~> = {!!}\n } where\n -- useful helper facts go here\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Cutting Things Up\n------------------------------------------------------------------------------\n\n-- Next, we're going to develop a very general technique for building\n-- data structures.\n\n-- We may think of an I |> O as a way to \"cut O-shapes into I-shaped pieces\".\n-- The pointy end points to the type being cut; the flat end to the type of\n-- pieces.\n\nrecord _|>_ (I O : Set) : Set where\n field\n Cuts : O -> Set -- given o : O, how may we cut it?\n inners : {o : O} -> Cuts o -> List I -- given how we cut it, what are\n -- the shapes of its pieces?\n\n-- Let us have some examples right away!\n\nVecCut : One |> Nat -- cut numbers into boring pieces\nVecCut = record\n { Cuts = \\ n -> One -- there is one way to cut n\n ; inners = \\ {n} _ -> copy n -- and you get n pieces\n }\n\n-- Here's a less boring example. You can cut a number into *two* pieces\n-- by finding two numbers that add to it.\n\nNatCut : Nat |> Nat\nNatCut = record\n { Cuts = \\ mn -> Sg Nat \\ m -> Sg Nat \\ n -> (m +N n) == mn\n ; inners = \\ { (m , n , _) -> m ,- n ,- [] }\n }\n\n-- The point is that we can make data structures that record how we\n-- built an O-shaped thing from I-shaped pieces.\n\nrecord Cutting {I O}(C : I |> O)(P : I -> Set)(o : O) : Set where\n constructor _8><_ -- \"scissors\"\n open _|>_ C\n field\n cut : Cuts o -- we decide how to cut o\n pieces : All P (inners cut) -- then we give all the pieces.\ninfixr 3 _8><_\n\n-- For example...\n\nVecCutting : Set -> Nat -> Set\nVecCutting X = Cutting VecCut (\\ _ -> X)\n\nmyVecCutting : VecCutting Char 5\nmyVecCutting = <> 8>< 'h' , 'e' , 'l' , 'l' , 'o' , <>\n\n-- Or, if you let me fiddle about with strings for a moment,...\nlength : {X : Set} -> List X -> Nat\nlength [] = zero\nlength (x ,- xs) = suc (length xs)\n\nlistVec : {X : Set}(xs : List X) -> Vec X (length xs)\nlistVec [] = []\nlistVec (x ,- xs) = x ,- listVec xs\n\nstrVec : (s : String) -> Vec Char (length (primStringToList s))\nstrVec s = listVec (primStringToList s)\n\n-- ...an example of cutting a number in two, with vector pieces.\n\nfootprints : Cutting NatCut (Vec Char) 10\nfootprints = (4 , 6 , refl 10) 8>< strVec \"foot\"\n , strVec \"prints\"\n , <>\n\n-- Now, let me direct you to the =$ operator, now in CS410-Prelude.agda,\n-- which you may find helps with the proofs in the following.\n\n--??--2.9---------------------------------------------------------------------\n\n-- Using what you already built for ALL, show that every Cutting C gives us\n-- a functor between categories of indexed sets.\n\nCUTTING : {I O : Set}(C : I |> O) -> (I ->SET) => (O ->SET)\nCUTTING {I}{O} C = record\n { F-Obj = Cutting C\n ; F-map = {!!}\n ; F-map-id~> = extensionality \\ o -> extensionality \\ { (c 8>< ps) ->\n {!!} }\n ; F-map->~> = \\ f g ->\n extensionality \\ o -> extensionality \\ { (c 8>< ps) ->\n {!!} }\n } where\n open _|>_ C\n open _=>_ (ALL I)\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Interiors\n------------------------------------------------------------------------------\n\n-- Next, let me define the notion of an algebra for a given functor in C => C\n\nmodule ALGEBRA {C : Category}(F : C => C) where\n open Category C\n open _=>_ F\n\n Algebra : (X : Obj) -> Set -- we call X the \"carrier\" of the algebra...\n Algebra X = F-Obj X ~> X -- ...and we explain how to turn a bunch of Xs\n -- into one\nopen ALGEBRA\n\n-- Some week, we'll build categories whose objects are algebras. Not this week.\n\n-- Instead, let's work with them a bit.\n\n-- If we know a way to cut I-shapes into I-shaped pieces, we can build the\n-- ways to \"tile\" an I with I-shaped T-tiles.\n\ndata Interior {I}(C : I |> I)(T : I -> Set)(i : I) : Set where\n -- either...\n tile : T i -> Interior C T i -- we have a tile that fits, or...\n <_> : Cutting C (Interior C T) i -> -- ...we cut, then tile the pieces.\n Interior C T i\n\n-- Let me give you an example of an interior.\n\nsubbookkeeper : Interior NatCut (Vec Char) 13\nsubbookkeeper = < (3 , 10 , refl _)\n 8>< tile (strVec \"sub\")\n , < (4 , 6 , refl _)\n 8>< tile (strVec \"book\")\n , tile (strVec \"keeper\")\n , <> >\n , <> >\n\n-- We make a 13-interior from\n-- a 3-tile and a 10-interior made from a 4-tile and a 6-tile.\n\n-- Guess what? Interior C is always a Monad! We'll get there.\n\nmodule INTERIOR {I : Set}{C : I |> I} where -- fix some C...\n\n open _|>_ C -- ...and open it\n\n open module I->SET {I : Set} = Category (I ->SET) -- work in I ->SET\n\n -- tile gives us an arrow from T into Interior C T\n\n tile' : {T : I -> Set} -> [ T -:> Interior C T ]\n tile' i = tile\n\n -- <_> gives us an algebra!\n\n cut' : {T : I -> Set} -> Algebra (CUTTING C) (Interior C T)\n cut' i = <_>\n\n -- Now, other (CUTTING C) algebras give us operators on interiors.\n\n module INTERIORFOLD {P Q : I -> Set} where\n\n interiorFold :\n [ P -:> Q ] -> -- if we can turn a P into a Q...\n Algebra (CUTTING C) Q -> -- ...and a bunch of Qs into a Q...\n [ Interior C P -:> Q ] -- ...we can turn an interior of Ps into a Q\n\n allInteriorFold : -- annoyingly, we'll need a specialized \"all\"\n [ P -:> Q ] ->\n Algebra (CUTTING C) Q ->\n [ All (Interior C P) -:> All Q ]\n\n interiorFold pq qalg i (tile p) = pq i p\n interiorFold pq qalg i < c 8>< pis > =\n qalg i (c 8>< allInteriorFold pq qalg (inners c) pis)\n\n -- recursively turn all the sub-interiors into Qs\n allInteriorFold pq qalg [] <> = <>\n allInteriorFold pq qalg (i ,- is) (pi , pis) =\n interiorFold pq qalg i pi , allInteriorFold pq qalg is pis\n\n -- The trouble is that if you use\n -- all (interiorFold pq qalg)\n -- to process the sub-interiors, the termination checker complains.\n\n -- But if you've built \"all\" correctly, you should be able to prove this:\n\n--??--2.10--------------------------------------------------------------------\n\n allInteriorFoldLaw : (pq : [ P -:> Q ])(qalg : Algebra (CUTTING C) Q) ->\n allInteriorFold pq qalg == all (interiorFold pq qalg)\n allInteriorFoldLaw pq qalg = extensionality \\ is -> extensionality \\ ps ->\n {!!}\n where\n -- helper lemmas go here\n\n--??--------------------------------------------------------------------------\n\n -- Now, do me a favour and prove this extremely useful fact.\n -- Its purpose is to bottle the inductive proof method for functions\n -- built with interiorFold.\n\n--??--2.11--------------------------------------------------------------------\n\n interiorFoldLemma :\n (pq : [ P -:> Q ])(qalg : Algebra (CUTTING C) Q)\n (f : [ Interior C P -:> Q ]) ->\n ((i : I)(p : P i) -> pq i p == f i (tile p)) ->\n ((i : I)(c : Cuts i)(ps : All (Interior C P) (inners c)) ->\n qalg i (c 8>< all f (inners c) ps) == f i < c 8>< ps >) ->\n (i : I)(pi : Interior C P i) -> interiorFold pq qalg i pi == f i pi\n\n interiorFoldLemma pq qalg f base step i pi = {!!}\n\n--??--------------------------------------------------------------------------\n\n -- We'll use it in this form:\n\n interiorFoldLaw : (pq : [ P -:> Q ])(qalg : Algebra (CUTTING C) Q)\n (f : [ Interior C P -:> Q ]) ->\n ((i : I)(p : P i) -> pq i p == f i (tile p)) ->\n ((i : I)(c : Cuts i)(ps : All (Interior C P) (inners c)) ->\n qalg i (c 8>< all f (inners c) ps) == f i < c 8>< ps >) ->\n interiorFold pq qalg == f\n\n interiorFoldLaw pq qalg f base step =\n extensionality \\ i -> extensionality \\ pi ->\n interiorFoldLemma pq qalg f base step i pi\n\n open INTERIORFOLD\n\n -- Let me pay you back immediately!\n -- An interiorBind is an interiorFold which computes an Interior,\n -- rewrapping each layer with < ... >\n\n interiorBind : {X Y : I -> Set} ->\n [ X -:> Interior C Y ] -> [ Interior C X -:> Interior C Y ]\n interiorBind f = interiorFold f (\\ i -> <_>)\n\n -- Because an interiorBind *makes* an interior, we can say something useful\n -- about what happens if we follow it with an interiorFold.\n\n interiorBindFusion : {X Y Z : I -> Set} ->\n (f : [ X -:> Interior C Y ])\n (yz : [ Y -:> Z ])(zalg : Algebra (CUTTING C) Z) ->\n (interiorBind f >~> interiorFold yz zalg) ==\n interiorFold (f >~> interiorFold yz zalg) zalg\n\n -- That is, we can \"fuse\" the two together, making one interiorFold.\n\n -- I'll do the proof as it's a bit hairy. You've given me all I need.\n -- Note that I don't use extensionality, just laws that relate functions.\n\n interiorBindFusion f yz zalg =\n (interiorBind f >~> interiorFold yz zalg)\n =< interiorFoldLaw\n (f >~> interiorFold yz zalg) zalg\n (interiorBind f >~> interiorFold yz zalg)\n (\\ i p -> refl (interiorFold yz zalg i (f i p)))\n (\\ i c ps -> refl (zalg i) =$= (refl (c 8><_) =$= (\n ((all (interiorBind f >~> interiorFold yz zalg)\n =[ F-map->~> (interiorBind f) (interiorFold yz zalg) >=\n (all (interiorBind f) >~> all (interiorFold yz zalg))\n =< refl _>~>_\n =$= allInteriorFoldLaw f cut'\n =$= allInteriorFoldLaw yz zalg ]=\n allInteriorFold f (\\ i -> <_>) >~> allInteriorFold yz zalg [QED])\n =$ inners c =$= refl ps))))\n ]=\n interiorFold (f >~> interiorFold yz zalg) zalg [QED]\n where open _=>_ (ALL I)\n\n -- You should find that a very useful piece of kit. In fact, you should\n -- not need extensionality, either.\n\n -- We need Interior C to be a functor.\n\n--??--2.12--------------------------------------------------------------------\n\n -- using interiorBind, implement the \"F-map\" for Interiors as a one-liner\n\n interior : {X Y : I -> Set} ->\n [ X -:> Y ] -> [ Interior C X -:> Interior C Y ]\n interior f = {!!}\n\n -- using interiorBindFusion, prove the following law for \"fold after map\"\n\n interiorFoldFusion : {P Q R : I -> Set}\n (pq : [ P -:> Q ])(qr : [ Q -:> R ])(ralg : Algebra (CUTTING C) R) ->\n (interior pq >~> interiorFold qr ralg) == interiorFold (pq >~> qr) ralg\n interiorFoldFusion pq qr ralg =\n interior pq >~> interiorFold qr ralg\n =[ {!!} >=\n interiorFold (pq >~> qr) ralg [QED]\n where open _=>_ (ALL I)\n\n -- and now, using interiorFoldFusion if it helps,\n -- complete the functor construction\n\n INTERIOR : (I ->SET) => (I ->SET)\n INTERIOR = record\n { F-Obj = Interior C\n ; F-map = interior\n ; F-map-id~> = {!!}\n ; F-map->~> = {!!}\n } where open _=>_ (ALL I)\n\n--??--------------------------------------------------------------------------\n\n -- Now let's build the Monad.\n -- You should find that all the laws you have to prove follow from the\n -- fusion laws you already have.\n\n open MONAD INTERIOR\n\n--??--2.13--------------------------------------------------------------------\n\n WRAP : ID ~~> INTERIOR\n WRAP = record\n { xf = {!!}\n ; naturality = {!!}\n }\n\n -- use interiorBind to define the following\n FLATTEN : (INTERIOR >=> INTERIOR) ~~> INTERIOR\n FLATTEN = record\n { xf = {!!}\n ; naturality = {!!}\n }\n\n INTERIOR-Monad : Monad\n INTERIOR-Monad = record\n { unit = WRAP\n ; mult = FLATTEN\n ; unitMult = {!!}\n ; multUnit = {!!}\n ; multMult = {!!}\n } where\n open _=>_ INTERIOR\n\n--??--------------------------------------------------------------------------\n\nopen INTERIOR\nopen INTERIORFOLD\n\n\n-- You should be able to define an algebra on vectors for NatCut, using +V\n\n--??--2.14--------------------------------------------------------------------\n\nNatCutVecAlg : {X : Set} -> Algebra (CUTTING NatCut) (Vec X)\nNatCutVecAlg n xsc = {!!}\n\n--??--------------------------------------------------------------------------\n\n-- Check that it puts things together suitably when you evaluate this:\n\ntest1 : Vec Char 13\ntest1 = interiorFold (\\ _ -> id) NatCutVecAlg 13 subbookkeeper\n\n\n------------------------------------------------------------------------------\n-- Cutting Up Pairs\n------------------------------------------------------------------------------\n\nmodule CHOICE where\n open _|>_\n\n--??--2.15--------------------------------------------------------------------\n\n -- Show that if you can cut up I and cut up J, then you can cut up I * J.\n -- You now have two dimensions (I and J). The idea is that you choose one\n -- dimension in which to make a cut, and keep everything in the other\n -- dimension the same.\n\n _+C_ : {I J : Set} -> I |> I -> J |> J -> (I * J) |> (I * J)\n Cuts (P +C Q) (i , j) = Cuts P i + Cuts Q j\n inners (P +C Q) = {!!}\n\n--??--------------------------------------------------------------------------\n\nopen CHOICE\n\n-- That should get us the ability to cut up *rectangules* by cutting either\n-- vertically or horizontally.\n\nNatCut2D : (Nat * Nat) |> (Nat * Nat)\nNatCut2D = NatCut +C NatCut\n\nMatrix : Set -> Nat * Nat -> Set\nMatrix X (w , h) = Vec (Vec X w) h\n\n-- If you've done it right, you should find that the following typechecks.\n-- It's the interior of a rectangle, tiled with matrices of characters.\n\nrectangle : Interior NatCut2D (Matrix Char) (15 , 6)\nrectangle = < inr (4 , 2 , refl _)\n 8>< < inl (7 , 8 , refl _)\n 8>< tile (strVec \"seventy\"\n ,- strVec \"kitchen\"\n ,- strVec \"program\"\n ,- strVec \"mistake\"\n ,- [])\n , tile (strVec \"thousand\"\n ,- strVec \"soldiers\"\n ,- strVec \"probably\"\n ,- strVec \"undefine\"\n ,- [])\n , <> >\n , tile (strVec \"acknowledgement\"\n ,- strVec \"procrastination\"\n ,- [])\n , <> >\n\n-- Later, we'll use rectangular interiors as the underlying data structure\n-- for a window manager.\n\n-- But for now, one last thing.\n\n--??--2.16--------------------------------------------------------------------\n\n-- Show that if you have a vector of n Ps for every element of a list,\n-- then you can make a vector of n (All P)s .\n-- Hint: Ex1 provides some useful equipment for this job.\n\nvecAll : {I : Set}{P : I -> Set}{is : List I}{n : Nat} ->\n All (\\ i -> Vec (P i) n) is -> Vec (All P is) n\nvecAll {is = is} pss = {!!}\n\n-- Given vecAll, show that algebra for any cutting can be lifted\n-- to an algebra on vectors.\n\nVecLiftAlg : {I : Set}(C : I |> I){X : I -> Set}\n (alg : Algebra (CUTTING C) X){n : Nat} ->\n Algebra (CUTTING C) (\\ i -> Vec (X i) n)\nVecLiftAlg C alg i (c 8>< pss) = {!!}\n\n-- Now show that you can build an algebra for matrices\n-- which handles cuts in either dimension,\n-- combining them either horizontally or vertically!\n\nNatCut2DMatAlg : {X : Set} -> Algebra (CUTTING NatCut2D) (Matrix X)\nNatCut2DMatAlg _ (inl c 8>< ms) = {!!}\nNatCut2DMatAlg _ (inr c 8>< ms) = {!!}\n\n--??--------------------------------------------------------------------------\n\n-- And that should give you a way to glue pictures together from interiors.\n\npicture : [ Interior NatCut2D (Matrix Char) -:> Matrix Char ]\npicture = interiorFold (\\ _ -> id) NatCut2DMatAlg\n\n-- You should be able to check that the following gives you something\n-- sensible:\n\ntest2 = picture _ rectangle\n", "meta": {"hexsha": "a1c1f6c9018ccdd7cf1fe32c9045b45da4762624", "size": 25443, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Ex2.agda", "max_stars_repo_name": "m-schmidt/CS410-17-Exercises", "max_stars_repo_head_hexsha": "5db8e95bbcbe8dc0eec810f3e73130ecd78d207c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Ex2.agda", "max_issues_repo_name": "m-schmidt/CS410-17-Exercises", "max_issues_repo_head_hexsha": "5db8e95bbcbe8dc0eec810f3e73130ecd78d207c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Ex2.agda", "max_forks_repo_name": "m-schmidt/CS410-17-Exercises", "max_forks_repo_head_hexsha": "5db8e95bbcbe8dc0eec810f3e73130ecd78d207c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.3460026212, "max_line_length": 79, "alphanum_fraction": 0.4711708525, "num_tokens": 6768, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789132480439, "lm_q2_score": 0.7549149923816048, "lm_q1q2_score": 0.6118426826200983}} {"text": "\ndata Tm : Set where\n tzero : Tm\n tsucc : Tm → Tm\n tdiff : Tm → Tm → Tm\n\nvariable\n m n n' : Tm\n\ndata NotZero : Tm → Set where\n nzsucc : NotZero (tsucc n)\n nzdiff : NotZero (tdiff m n)\n\ndata Equal : Tm → Tm → Set where\n esucc : NotZero n → Equal (tsucc (tdiff tzero n)) n\n ediff : Equal n n' → Equal (tdiff m n) (tdiff m n')\n\ndata Foo : Tm → Set where\n fleft : Foo m → Foo (tdiff m n)\n frght : Foo n → Foo (tdiff m (tsucc n))\n\nfoo : Foo n → Equal n n' → Foo n'\nfoo (fleft f) e = {!!}\nfoo (frght (frght f)) (ediff (esucc nz)) = {!nz!} -- case-split on nz replaces nz with nzsucc\n", "meta": {"hexsha": "0ba222165823f2d8c10f51b2c77908b03df20a66", "size": 587, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue3650.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/interaction/Issue3650.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/interaction/Issue3650.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 23.48, "max_line_length": 93, "alphanum_fraction": 0.5962521295, "num_tokens": 235, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9099070109242131, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.6117593327238202}} {"text": "{-\nJoseph Eremondi\nUtrecht University Capita Selecta\nUU# 4229924\nJuly 22, 2015\n-}\n\nmodule SemiLinRE where\n\nopen import Data.Vec\nopen import Data.Nat\nimport Data.Fin as Fin\n\nopen import Data.List\nimport Data.List.All\nopen import Data.Bool\nopen import Data.Char\n\nopen import Data.Maybe\n\nopen import Data.Product\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality\n\nopen import Relation.Nullary\nopen import Relation.Nullary.Decidable\nopen import Relation.Binary.Core\n\nopen import Category.Monad\n\nopen import Data.Nat.Properties.Simple\n\nopen import Data.Maybe\nopen import Relation.Binary.PropositionalEquality\nopen ≡-Reasoning\n\nopen import Utils\n\nopen import Function\n\nimport RETypes\n\nopen import Data.Sum\n\nopen import SemiLin\n\nopen import Data.Vec.Equality\nopen import Data.Nat.Properties.Simple\n\n\nmodule VecNatEq = Data.Vec.Equality.DecidableEquality (Relation.Binary.PropositionalEquality.decSetoid Data.Nat._≟_)\n\n\n--Find the Parikh vector of a given word\n--Here cmap is the mapping of each character to its position\n--in the Parikh vector\nwordParikh : {n : ℕ} -> (Char -> Fin.Fin n) -> (w : List Char) -> Parikh n\nwordParikh cmap [] = v0\nwordParikh cmap (x ∷ w) = (basis (cmap x)) +v (wordParikh cmap w)\n\n--Show that the Parikh of concatenating two words\n--Is the sum of their Parikhs\nwordParikhPlus : {n : ℕ} \n -> (cmap : Char -> Fin.Fin n) \n -> (u : List Char) \n -> (v : List Char)\n -> wordParikh cmap (u Data.List.++ v) ≡ (wordParikh cmap u) +v (wordParikh cmap v)\nwordParikhPlus cmap [] v = sym v0identLeft\nwordParikhPlus {n} cmap (x ∷ u) v = \n begin\n basis (cmap x) +v wordParikh cmap (u ++l v)\n ≡⟨ cong (λ y → basis (cmap x) +v y) (wordParikhPlus cmap u v) ⟩ \n basis (cmap x) +v (wordParikh cmap u +v wordParikh cmap v) \n ≡⟨ sym vAssoc ⟩ \n ((basis (cmap x) +v wordParikh cmap u) +v wordParikh cmap v ∎)\n where\n _++l_ = Data.List._++_\n \n\n\n--The algorithm mapping regular expressions to the Parikh set of\n--the language matched by the RE\n--We prove this correct below\nreSemiLin : {n : ℕ} {null? : RETypes.Null?} -> (Char -> Fin.Fin n) -> RETypes.RE null? -> SemiLinSet n \nreSemiLin cmap RETypes.ε = Data.List.[ v0 , 0 , [] ]\nreSemiLin cmap RETypes.∅ = []\nreSemiLin cmap (RETypes.Lit x) = Data.List.[ basis (cmap x ) , 0 , [] ]\nreSemiLin cmap (r1 RETypes.+ r2) = reSemiLin cmap r1 Data.List.++ reSemiLin cmap r2\nreSemiLin cmap (r1 RETypes.· r2) = reSemiLin cmap r1 +s reSemiLin cmap r2\nreSemiLin cmap (r RETypes.*) = starSemiLin (reSemiLin cmap r)\n\n\n\n{-\nShow that s* ⊆ s +v s*\nNot implemented due to time restrictions,\nbut should be possible, given that linStarExtend is implemented\nin SemiLin.agda\n-}\nstarExtend \n : {n : ℕ}\n -> (v1 v2 : Parikh n )\n -> ( s ss : SemiLinSet n)\n -> ss ≡ starSemiLin s\n -> InSemiLin v1 s\n -> InSemiLin v2 ss\n -> InSemiLin (v1 +v v2) (starSemiLin s)\nstarExtend v1 v2 s ss spf inS inSS = {!!}\n\n{-\nShow that s* ⊇ s +v s*\nNot completely implemented due to time restrictions,\nbut should be possible, given that linStarDecomp is implemented\nin SemiLin.agda.\n\nThere are also some hard parts, for example, dealing with the proofs\nthat the returned vectors are non-zero (otherwise, we'd just trivially return v0 and v)\n-}\nstarDecomp\n : {n : ℕ}\n -> (v : Parikh n)\n -> (s ss : SemiLinSet n)\n -> v ≢ v0\n -> ss ≡ starSemiLin s\n -> InSemiLin v ss\n -> (∃ λ v1 -> ∃ λ v2 -> v1 +v v2 ≡ v × InSemiLin v1 s × InSemiLin v2 ss × v1 ≢ v0 ) \nstarDecomp v s ss vpf spf inSemi = {!!}\n{-\nstarDecomp v sh st .(sh ∷ st) .((v0 , 0 , []) ∷ starSum sh st ∷ []) vnz refl refl (InHead .v .(v0 , 0 , []) .(starSum sh st ∷ []) x) with emptyCombZero v x | vnz (emptyCombZero v x)\nstarDecomp .v0 sh st .(sh ∷ st) .((v0 , zero , []) ∷ [] Data.List.++ starSum sh st ∷ []) vnz refl refl (InHead .v0 .(v0 , zero , []) .(starSum sh st ∷ []) x) | refl | ()\nstarDecomp v sh [] .(sh ∷ []) .((v0 , 0 , []) ∷ (proj₁ sh , suc (proj₁ (proj₂ sh)) , proj₁ sh ∷ proj₂ (proj₂ sh)) ∷ []) vnz refl refl (InTail .v .(v0 , 0 , []) .((proj₁ sh , suc (proj₁ (proj₂ sh)) , proj₁ sh ∷ proj₂ (proj₂ sh)) ∷ []) (InHead .v .(proj₁ sh , suc (proj₁ (proj₂ sh)) , proj₁ sh ∷ proj₂ (proj₂ sh)) .[] starComb)) with linStarDecomp v sh _ vnz {!!} refl starComb\nstarDecomp v sh [] .(sh ∷ []) .((v0 , zero , []) ∷ [] Data.List.++ starSum sh [] ∷ []) vnz refl refl (InTail .v .(v0 , zero , []) .(starSum sh [] ∷ []) (InHead .v .(proj₁ sh , suc (proj₁ (proj₂ sh)) , proj₁ sh ∷ proj₂ (proj₂ sh)) .[] starComb)) | inj₁ lComb = v , v0 , v0identRight , InHead v sh [] lComb , InHead v0 (v0 , zero , []) _ (v0 , refl) , vnz\nstarDecomp v sh [] .(sh ∷ []) .((v0 , zero , []) ∷ [] Data.List.++ starSum sh [] ∷ []) vnz refl refl (InTail .v .(v0 , zero , []) .(starSum sh [] ∷ []) (InHead .v .(proj₁ sh , suc (proj₁ (proj₂ sh)) , proj₁ sh ∷ proj₂ (proj₂ sh)) .[] starComb)) | inj₂ (v1 , v2 , sumPf , comb1 , comb2 , zpf ) = v1 , v2 , sumPf , InHead v1 sh [] comb1 , InTail v2 (v0 , zero , []) _ (InHead v2 _ [] comb2) , zpf\nstarDecomp v sh [] .(sh ∷ []) .((v0 , 0 , []) ∷ (proj₁ sh , suc (proj₁ (proj₂ sh)) , proj₁ sh ∷ proj₂ (proj₂ sh)) ∷ []) vnz refl refl (InTail .v .(v0 , 0 , []) .((proj₁ sh , suc (proj₁ (proj₂ sh)) , proj₁ sh ∷ proj₂ (proj₂ sh)) ∷ []) (InTail .v .(proj₁ sh , suc (proj₁ (proj₂ sh)) , proj₁ sh ∷ proj₂ (proj₂ sh)) .[] ()))\nstarDecomp v sh (x ∷ st) .(sh ∷ x ∷ st) .((v0 , 0 , []) ∷ (proj₁ x +v proj₁ (starSum sh st) , suc (proj₁ (proj₂ x) + proj₁ (proj₂ (starSum sh st))) , proj₁ x ∷ proj₂ (proj₂ x) Data.Vec.++ proj₂ (proj₂ (starSum sh st))) ∷ []) vnz refl refl (InTail .v .(v0 , 0 , []) .((proj₁ x +v proj₁ (starSum sh st) , suc (proj₁ (proj₂ x) + proj₁ (proj₂ (starSum sh st))) , proj₁ x ∷ proj₂ (proj₂ x) Data.Vec.++ proj₂ (proj₂ (starSum sh st))) ∷ []) inSemi) = {!!} -}\n\n\n\n\n--Stolen from the stdlib\nlistIdentity : {A : Set} -> (x : List A) -> (x Data.List.++ [] ) ≡ x\nlistIdentity [] = refl\nlistIdentity (x ∷ xs) = cong (_∷_ x) (listIdentity xs)\n\n\n{-\nShow that +s is actually the sum of two sets, that is,\nif v1 is in S1, and v2 is in S2, then v1 +v v2\nis in S1 +s S2\n-}\nsumPreserved : \n {n : ℕ} \n -> (u : Parikh n) \n -> (v : Parikh n)\n -- -> (uv : Parikh n)\n -> (su : SemiLinSet n) \n -> (sv : SemiLinSet n)\n -- -> (suv : SemiLinSet n)\n -- -> (uv ≡ u +v v)\n -- -> (suv ≡ su +s sv)\n -> InSemiLin u su\n -> InSemiLin v sv\n -> InSemiLin (u +v v) (su +s sv)\nsumPreserved u v .((ub , um , uvecs) ∷ st) .((vb , vm , vvecs) ∷ st₁) (InHead .u (ub , um , uvecs) st (uconsts , upf)) (InHead .v (vb , vm , vvecs) st₁ (vconsts , vpf))\n rewrite upf | vpf \n = InHead (u +v v) (ub +v vb , um + vm , uvecs Data.Vec.++ vvecs) (Data.List.map (_+l_ (ub , um , uvecs)) st₁ Data.List.++\n Data.List.foldr Data.List._++_ []\n (Data.List.map\n (λ z → z +l (vb , vm , vvecs) ∷ Data.List.map (_+l_ z) st₁) st)) \n ((uconsts Data.Vec.++ vconsts) , trans (combSplit ub vb um vm uvecs vvecs uconsts vconsts) \n (sym (subst (λ x → u +v v ≡ x +v applyLinComb vb vm vvecs vconsts) (sym upf) (cong (λ x → u +v x) (sym vpf)))) )\n\nsumPreserved u v .(sh ∷ st) .(sh₁ ∷ st₁) (InHead .u sh st x) (InTail .v sh₁ st₁ vIn) = \n let\n subCall1 : InSemiLin (u +v v) ((sh ∷ []) +s st₁)\n subCall1 = sumPreserved u v (sh ∷ []) ( st₁) (InHead u sh [] x) vIn\n \n\n eqTest : (sh ∷ []) +s ( st₁) ≡ Data.List.map (λ l2 → sh +l l2) st₁\n eqTest = \n begin \n (sh ∷ []) +s (st₁) \n ≡⟨ refl ⟩ \n Data.List.map (λ l2 → sh +l l2) ( st₁) Data.List.++ [] \n ≡⟨ listIdentity (Data.List.map (_+l_ sh) st₁) ⟩ \n Data.List.map (λ l2 → sh +l l2) (st₁) \n ≡⟨ refl ⟩ \n (Data.List.map (λ l2 → sh +l l2) st₁ ∎)\n \n newCall = slExtend (u +v v) (Data.List.map (_+l_ sh) st₁) (subst (InSemiLin (u +v v)) eqTest subCall1) (sh +l sh₁) -- \n in slConcatRight (u +v v) (Data.List.map (λ l2 → sh +l l2) (sh₁ ∷ st₁)) newCall (Data.List.foldr Data.List._++_ []\n (Data.List.map (λ z → z +l sh₁ ∷ Data.List.map (_+l_ z) st₁) st))\nsumPreserved u v .(sh ∷ st) sv (InTail .u sh st uIn) vIn = \n (slConcatLeft (u +v v) (st +s sv) (sumPreserved u v st sv uIn vIn) (Data.List.map (λ x → sh +l x) sv)) \n\n\n--A useful lemma, avoids having to dig into the List monoid instance\nrightCons : {A : Set} -> (l : List A) -> (l Data.List.++ [] ≡ l)\nrightCons [] = refl\nrightCons (x ∷ l) rewrite rightCons l = refl\n\n\n\n\n{-\nShow that, if a vector is in the union of two semi-linear sets,\nthen it must be in one of those sets.\nUsed in the proof for Union.\nCalled concat because we represent semi-linear sets as lists,\nso union is just concatenating two semi-linear sets\n-}\ndecomposeConcat \n : {n : ℕ} \n -> (v : Parikh n) \n -> (s1 s2 s3 : SemiLinSet n) \n -> (s3 ≡ s1 Data.List.++ s2 ) \n -> InSemiLin v s3 \n -> InSemiLin v s1 ⊎ InSemiLin v s2\ndecomposeConcat v [] s2 .s2 refl inSemi = inj₂ inSemi\ndecomposeConcat v (x ∷ s1) s2 .(x ∷ s1 Data.List.++ s2) refl (InHead .v .x .(s1 Data.List.++ s2) x₁) = inj₁ (InHead v x s1 x₁)\ndecomposeConcat v (x ∷ s1) s2 .(x ∷ s1 Data.List.++ s2) refl (InTail .v .x .(s1 Data.List.++ s2) inSemi) with decomposeConcat v s1 s2 _ refl inSemi\ndecomposeConcat v (x₁ ∷ s1) s2 .(x₁ ∷ s1 Data.List.++ s2) refl (InTail .v .x₁ .(s1 Data.List.++ s2) inSemi) | inj₁ x = inj₁ (InTail v x₁ s1 x)\ndecomposeConcat v (x ∷ s1) s2 .(x ∷ s1 Data.List.++ s2) refl (InTail .v .x .(s1 Data.List.++ s2) inSemi) | inj₂ y = inj₂ y\n\nconcatEq : {n : ℕ} -> (l : LinSet n) -> (s : SemiLinSet n) -> (l ∷ []) +s s ≡ (Data.List.map (_+l_ l) s)\nconcatEq l [] = refl\nconcatEq l (x ∷ s) rewrite concatEq l s | listIdentity (l ∷ []) = refl \n\n\n{-\nShow that if v is in l1 +l l2, then v = v1 +v v2 for some\nv1 in l1 and v2 in l2.\nThis is the other half of the correcness proof of our sum functions, +l and +s\n-}\ndecomposeLin\n : {n : ℕ} \n -> (v : Parikh n) \n -> (l1 l2 l3 : LinSet n) \n -> (l3 ≡ l1 +l l2 ) \n -> LinComb v l3 \n -> ∃ λ v1 → ∃ λ v2 -> (v1 +v v2 ≡ v) × (LinComb v1 l1) × (LinComb v2 l2 )\ndecomposeLin .(applyLinComb (b1 +v b2) (m1 + m2) (vecs1 Data.Vec.++ vecs2) coeffs) (b1 , m1 , vecs1) (b2 , m2 , vecs2) .(b1 +v b2 , m1 + m2 , vecs1 Data.Vec.++ vecs2) refl (coeffs , refl) with Data.Vec.splitAt m1 coeffs \ndecomposeLin .(applyLinComb (b1 +v b2) (m1 + m2) (vecs1 Data.Vec.++ vecs2) (coeffs1 Data.Vec.++ coeffs2)) (b1 , m1 , vecs1) (b2 , m2 , vecs2) .(b1 +v b2 , m1 + m2 , vecs1 Data.Vec.++ vecs2) refl (.(coeffs1 Data.Vec.++ coeffs2) , refl) | coeffs1 , coeffs2 , refl rewrite combSplit b1 b2 m1 m2 vecs1 vecs2 coeffs1 coeffs2 \n = applyLinComb b1 m1 vecs1 coeffs1 , (applyLinComb b2 m2 vecs2 coeffs2 , (refl , ((coeffs1 , refl) , (coeffs2 , refl))))\n\n\n\n\n{-\nShow that our Parikh function is a superset of the actual Parikh image of a Regular Expression.\n\nWe do this by showing that, for every word matching an RE, its Parikh vector\nis in the Parikh Image of the RE\n-}\nreParikhCorrect : \n {n : ℕ} \n -> {null? : RETypes.Null?} \n -> (cmap : Char -> Fin.Fin n) \n -> (r : RETypes.RE null?) \n -> (w : List Char ) \n -> RETypes.REMatch w r\n -> (wordPar : Parikh n)\n -> (wordParikh cmap w ≡ wordPar)\n -> (langParikh : SemiLinSet n)\n -> (langParikh ≡ reSemiLin cmap r )\n -> (InSemiLin wordPar langParikh ) \nreParikhCorrect cmap .RETypes.ε .[] RETypes.EmptyMatch .v0 refl .((v0 , 0 , []) ∷ []) refl = InHead v0 (v0 , zero , []) [] ([] , refl) \nreParikhCorrect cmap .(RETypes.Lit c) .(c ∷ []) (RETypes.LitMatch c) .(basis (cmap c) +v v0) refl .((basis (cmap c) , 0 , []) ∷ []) refl = \n InHead (basis (cmap c) +v v0) (basis (cmap c) , zero , []) [] (subst (λ x → LinComb x (basis (cmap c) , zero , [])) (sym v0identRight) (v0 , (v0apply (basis (cmap c)) []))) \nreParikhCorrect cmap (r1 RETypes.+ .r2) w (RETypes.LeftPlusMatch r2 match) wordPar wpf langParikh lpf =\n let\n leftParikh = reSemiLin cmap r1\n leftInSemi = reParikhCorrect cmap r1 w match wordPar wpf leftParikh refl\n --Idea: show that langParikh is leftParikh ++ rightParikh\n --And that this means that it must be in the concatentation\n extendToConcat : InSemiLin wordPar ((reSemiLin cmap r1 ) Data.List.++ (reSemiLin cmap r2))\n extendToConcat = slConcatRight wordPar (reSemiLin cmap r1) leftInSemi (reSemiLin cmap r2)\n in subst (λ x → InSemiLin wordPar x) (sym lpf) extendToConcat\nreParikhCorrect cmap (.r1 RETypes.+ r2) w (RETypes.RightPlusMatch r1 match) wordPar wpf langParikh lpf = let\n rightParikh = reSemiLin cmap r2\n rightInSemi = reParikhCorrect cmap r2 w match wordPar wpf rightParikh refl\n --Idea: show that langParikh is leftParikh ++ rightParikh\n --And that this means that it must be in the concatentation\n extendToConcat : InSemiLin wordPar ((reSemiLin cmap r1 ) Data.List.++ (reSemiLin cmap r2))\n extendToConcat = slConcatLeft wordPar (reSemiLin cmap r2) rightInSemi (reSemiLin cmap r1)\n in subst (λ x → InSemiLin wordPar x) (sym lpf) extendToConcat\nreParikhCorrect cmap (r1 RETypes.· r2) s3 (RETypes.ConcatMatch {s1 = s1} {s2 = s2} {spf = spf} match1 match2) .(wordParikh cmap s3) refl ._ refl rewrite (sym spf) | (wordParikhPlus cmap s1 s2) =\n let\n leftParikh = reSemiLin cmap r1\n leftInSemi : InSemiLin (wordParikh cmap s1) leftParikh\n leftInSemi = reParikhCorrect cmap r1 s1 match1 (wordParikh cmap s1) refl (reSemiLin cmap r1) refl \n\n rightParikh = reSemiLin cmap r2\n rightInSemi : InSemiLin (wordParikh cmap s2) rightParikh\n rightInSemi = reParikhCorrect cmap r2 s2 match2 (wordParikh cmap s2) refl (reSemiLin cmap r2) refl\n\n wordParikhIsPlus : (wordParikh cmap s1) +v (wordParikh cmap s2) ≡ (wordParikh cmap (s1 Data.List.++ s2 )) \n wordParikhIsPlus = sym (wordParikhPlus cmap s1 s2)\n\n in sumPreserved (wordParikh cmap s1) (wordParikh cmap s2) leftParikh rightParikh leftInSemi rightInSemi\nreParikhCorrect cmap (r RETypes.*) [] RETypes.EmptyStarMatch .v0 refl .(starSemiLin (reSemiLin cmap r)) refl = zeroInStar (reSemiLin cmap r) (starSemiLin (reSemiLin cmap r)) refl\nreParikhCorrect cmap (r RETypes.*) .(s1 Data.List.++ s2 ) (RETypes.StarMatch {s1 = s1} {s2 = s2} {spf = refl} m1 m2) ._ refl .(starSemiLin (reSemiLin cmap r)) refl rewrite wordParikhPlus cmap s1 s2 = \n starExtend (wordParikh cmap s1) (wordParikh cmap s2) (reSemiLin cmap r) _ refl (reParikhCorrect cmap r s1 m1 (wordParikh cmap s1) refl (reSemiLin cmap r) refl) (reParikhCorrect cmap (r RETypes.*) s2 m2 (wordParikh cmap s2) refl (starSemiLin (reSemiLin cmap r)) refl) \n\n\n\n{-\nShow that if v is in s1 +s s2, then v = v1 +v v2 for some\nv1 in s1 and v2 in s2.\nThis is the other half of the correcness proof of our sum functions, +l and +s\n-}\ndecomposeSum \n : {n : ℕ} \n -> (v : Parikh n) \n -> (s1 s2 s3 : SemiLinSet n) \n -> (s3 ≡ s1 +s s2 ) \n -> InSemiLin v s3 \n -> ∃ λ (v1 : Parikh n) → ∃ λ (v2 : Parikh n) -> (v1 +v v2 ≡ v) × (InSemiLin v1 s1) × (InSemiLin v2 s2 )\ndecomposeSum v [] [] .[] refl ()\ndecomposeSum v [] (x ∷ s2) .[] refl ()\ndecomposeSum v (x ∷ s1) [] .(Data.List.foldr Data.List._++_ [] (Data.List.map (λ l1 → []) s1)) refl ()\ndecomposeSum v ((b1 , m1 , vecs1) ∷ s1) ((b2 , m2 , vecs2) ∷ s2) ._ refl (InHead .v .(b1 +v b2 , m1 + m2 , vecs1 Data.Vec.++ vecs2) ._ lcomb) =\n let\n (v1 , v2 , plusPf , comb1 , comb2 ) = decomposeLin v (b1 , m1 , vecs1) (b2 , m2 , vecs2) (b1 +v b2 , m1 + m2 , vecs1 Data.Vec.++ vecs2) refl lcomb\n in v1 , v2 , plusPf , InHead v1 (b1 , m1 , vecs1) s1 comb1 , InHead v2 (b2 , m2 , vecs2) s2 comb2\ndecomposeSum v ((b1 , m1 , vecs1) ∷ s1) ((b2 , m2 , vecs2) ∷ s2) ._ refl (InTail .v .(b1 +v b2 , m1 + m2 , vecs1 Data.Vec.++ vecs2) ._ inSemi) with decomposeConcat v (Data.List.map (_+l_ (b1 , m1 , vecs1)) s2) (Data.List.foldr Data.List._++_ []\n (Data.List.map\n (λ z → z +l (b2 , m2 , vecs2) ∷ Data.List.map (_+l_ z) s2) s1)) (Data.List.map (_+l_ (b1 , m1 , vecs1)) s2 Data.List.++\n Data.List.foldr Data.List._++_ []\n (Data.List.map\n (λ z → z +l (b2 , m2 , vecs2) ∷ Data.List.map (_+l_ z) s2) s1)) refl inSemi\ndecomposeSum v ((b1 , m1 , vecs1) ∷ s1) ((b2 , m2 , vecs2) ∷ s2) .((b1 , m1 , vecs1) +l (b2 , m2 , vecs2) ∷ Data.List.map (_+l_ (b1 , m1 , vecs1)) s2 Data.List.++ Data.List.foldr Data.List._++_ [] (Data.List.map _ s1)) refl (InTail .v .(b1 +v b2 , m1 + m2 , vecs1 Data.Vec.++ vecs2) .(Data.List.map (_+l_ (b1 , m1 , vecs1)) s2 Data.List.++ Data.List.foldr Data.List._++_ [] (Data.List.map _ s1)) inSemi) | inj₁ inSub = \n let\n subCall1 = decomposeSum v ((b1 , m1 , vecs1) ∷ []) s2 _ refl (subst (λ x → InSemiLin v x) (sym (concatEq (b1 , m1 , vecs1) s2)) inSub)\n v1 , v2 , pf , xIn , yIn = subCall1\n in v1 , (v2 , (pf , (slCons v1 s1 (b1 , m1 , vecs1) xIn , slExtend v2 s2 yIn (b2 , m2 , vecs2))))\ndecomposeSum v ((b1 , m1 , vecs1) ∷ s1) ((b2 , m2 , vecs2) ∷ s2) .((b1 , m1 , vecs1) +l (b2 , m2 , vecs2) ∷ Data.List.map (_+l_ (b1 , m1 , vecs1)) s2 Data.List.++ Data.List.foldr Data.List._++_ [] (Data.List.map _ s1)) refl (InTail .v .(b1 +v b2 , m1 + m2 , vecs1 Data.Vec.++ vecs2) .(Data.List.map (_+l_ (b1 , m1 , vecs1)) s2 Data.List.++ Data.List.foldr Data.List._++_ [] (Data.List.map _ s1)) inSemi) | inj₂ inSub = \n let \n subCall1 = decomposeSum v s1 ((b2 , m2 , vecs2) ∷ s2) _ refl inSub \n v1 , v2 , pf , xIn , yIn = subCall1\n in v1 , v2 , pf , slExtend v1 s1 xIn (b1 , m1 , vecs1) , yIn\n\n\n\n\n\n{-\nShow that the generated Parikh image is a subset of the actual Parikh image.\n\nWe do this by showing that, for every vector in the generated Parikh image,\nthere's some word matched by the RE whose Parikh vector is that vector.\n-}\n--We have to convince the compiler that this is terminating\n--Since I didn't have time to implement the proofs of non-zero vectors\n--Which show that we only recurse on strictly smaller vectors in the Star case\n{-# TERMINATING #-}\nreParikhComplete : {n : ℕ} -> {null? : RETypes.Null?}\n -> (cmap : Char -> Fin.Fin n)\n-- -> (imap : Fin.Fin n -> Char)\n-- -> (invPf1 : (x : Char ) -> imap (cmap x) ≡ x)\n-- -> (invPf2 : (x : Fin.Fin n ) -> cmap (imap x) ≡ x )\n -> (r : RETypes.RE null?)\n -> (v : Parikh n )\n -> (langParikh : SemiLinSet n)\n -> langParikh ≡ (reSemiLin cmap r )\n -> (InSemiLin v langParikh )\n -> ∃ (λ w -> (v ≡ wordParikh cmap w) × (RETypes.REMatch w r) ) \nreParikhComplete cmap RETypes.ε .v0 .((v0 , 0 , []) ∷ []) refl (InHead .v0 .(v0 , 0 , []) .[] (combConsts , refl)) = [] , refl , RETypes.EmptyMatch\nreParikhComplete cmap RETypes.ε v .((v0 , 0 , []) ∷ []) refl (InTail .v .(v0 , 0 , []) .[] ())\n\n--reParikhComplete cmap RETypes.ε v .(sh ∷ st) lpf (InTail .v sh st inSemi) = {!!}\nreParikhComplete cmap RETypes.∅ v [] lpf ()\nreParikhComplete cmap RETypes.∅ v (h ∷ t) () inSemi \nreParikhComplete cmap (RETypes.Lit x) langParikh [] inSemi ()\nreParikhComplete cmap (RETypes.Lit x) .(basis (cmap x)) .((basis (cmap x) , 0 , []) ∷ []) refl (InHead .(basis (cmap x)) .(basis (cmap x) , 0 , []) .[] (consts , refl)) = (x ∷ []) , (sym v0identRight , RETypes.LitMatch x)\nreParikhComplete cmap (RETypes.Lit x) v .((basis (cmap x) , 0 , []) ∷ []) refl (InTail .v .(basis (cmap x) , 0 , []) .[] ())\n--reParikhComplete cmap (RETypes.Lit x) v .((basis (cmap x) , 0 , []) ∷ []) refl (InTail .v .(basis (cmap x) , 0 , []) .[] ())\nreParikhComplete {null? = null?} cmap (r1 RETypes.+ r2) v langParikh lpf inSemi with decomposeConcat v (reSemiLin cmap r1) (reSemiLin cmap r2) langParikh lpf inSemi\n... | inj₁ in1 = \n let\n (subw , subPf , subMatch) = reParikhComplete cmap r1 v (reSemiLin cmap r1) refl in1\n in subw , (subPf , (RETypes.LeftPlusMatch r2 subMatch))\n... | inj₂ in2 = \n let\n (subw , subPf , subMatch) = reParikhComplete cmap r2 v (reSemiLin cmap r2) refl in2\n in subw , (subPf , (RETypes.RightPlusMatch r1 subMatch))\nreParikhComplete cmap (r1 RETypes.· r2) v ._ refl inSemi with decomposeSum v (reSemiLin cmap r1) (reSemiLin cmap r2) (reSemiLin cmap r1 +s reSemiLin cmap r2) refl inSemi | reParikhComplete cmap r1 (proj₁ (decomposeSum v (reSemiLin cmap r1) (reSemiLin cmap r2)\n (reSemiLin cmap r1 +s reSemiLin cmap r2) refl inSemi)) (reSemiLin cmap r1) refl (proj₁ (proj₂ (proj₂ (proj₂ (decomposeSum v (reSemiLin cmap r1) (reSemiLin cmap r2)\n (reSemiLin cmap r1 +s reSemiLin cmap r2) refl inSemi))))) | reParikhComplete cmap r2 (proj₁ (proj₂ (decomposeSum v (reSemiLin cmap r1) (reSemiLin cmap r2)\n (reSemiLin cmap r1 +s reSemiLin cmap r2) refl inSemi))) (reSemiLin cmap r2) refl (proj₂ (proj₂ (proj₂ (proj₂ (decomposeSum v (reSemiLin cmap r1) (reSemiLin cmap r2)\n (reSemiLin cmap r1 +s reSemiLin cmap r2) refl inSemi))))) \nreParikhComplete cmap (r1 RETypes.· r2) .(wordParikh cmap w1 +v wordParikh cmap w2) .(Data.List.foldr Data.List._++_ [] (Data.List.map _ (reSemiLin cmap r1))) refl inSemi | .(wordParikh cmap w1) , .(wordParikh cmap w2) , refl , inSemi1 , inSemi2 | w1 , refl , match1 | w2 , refl , match2 = (w1 Data.List.++ w2) , ((sym (wordParikhPlus cmap w1 w2)) , (RETypes.ConcatMatch match1 match2))\n\nreParikhComplete cmap (r RETypes.*) v langParikh lpf inSemi with (reSemiLin cmap r )\nreParikhComplete cmap (r RETypes.*) v .((v0 , 0 , []) ∷ []) refl (InHead .v .(v0 , 0 , []) .[] x) | [] = [] , ((sym (proj₂ x)) , RETypes.EmptyStarMatch)\nreParikhComplete cmap (r RETypes.*) v .((v0 , 0 , []) ∷ []) refl (InTail .v .(v0 , 0 , []) .[] ()) | []\nreParikhComplete cmap (r RETypes.*) v .((v0 , 0 , []) ∷ starSum x rsl ∷ []) refl inSemi | x ∷ rsl = \n let\n --The first hole is the non-zero proofs that I couldn't work out\n --I'm not totally sure about the second, but I think I just need to apply some associativity to inSemi to get it to fit\n --into the second hole. \n splitVec = starDecomp v (reSemiLin cmap r) _ {!!} refl {!!}\n v1 , v2 , vpf , inS , inSS , _ = splitVec\n subCall1 = reParikhComplete cmap r v1 _ refl inS\n w1 , wpf1 , match = subCall1\n subCall2 = reParikhComplete cmap (r RETypes.*) v2 _ refl inSS\n w2 , wpf2 , match2 = subCall2\n in (w1 Data.List.++ w2) , (trans (sym vpf) (sym (wordParikhPlus cmap w1 w2)) , RETypes.StarMatch match match2)\n\n", "meta": {"hexsha": "18ee8850dd3be541c6427a92ba88311a3e42ed04", "size": 24693, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "SemiLinRE.agda", "max_stars_repo_name": "JoeyEremondi/agda-parikh", "max_stars_repo_head_hexsha": "1e28103ff7dd1d4f3351ef21397833aa4490b7ea", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "SemiLinRE.agda", "max_issues_repo_name": "JoeyEremondi/agda-parikh", "max_issues_repo_head_hexsha": "1e28103ff7dd1d4f3351ef21397833aa4490b7ea", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "SemiLinRE.agda", "max_forks_repo_name": "JoeyEremondi/agda-parikh", "max_forks_repo_head_hexsha": "1e28103ff7dd1d4f3351ef21397833aa4490b7ea", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 60.2268292683, "max_line_length": 590, "alphanum_fraction": 0.5539221642, "num_tokens": 8494, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933403143929, "lm_q2_score": 0.7461390043208003, "lm_q1q2_score": 0.6117544005914362}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Propositional (intensional) equality\n------------------------------------------------------------------------\n\nmodule Relation.Binary.PropositionalEquality where\n\nopen import Function\nopen import Function.Equality using (Π; _⟶_; ≡-setoid)\nopen import Data.Product\nopen import Data.Unit.Core\nopen import Level\nopen import Relation.Binary\nimport Relation.Binary.Indexed as I\nopen import Relation.Binary.Consequences\nopen import Relation.Binary.HeterogeneousEquality.Core as H using (_≅_)\n\n-- Some of the definitions can be found in the following modules:\n\nopen import Relation.Binary.Core public using (_≡_; refl; _≢_)\nopen import Relation.Binary.PropositionalEquality.Core public\n\n------------------------------------------------------------------------\n-- Some properties\n\nsubst₂ : ∀ {a b p} {A : Set a} {B : Set b} (P : A → B → Set p)\n {x₁ x₂ y₁ y₂} → x₁ ≡ x₂ → y₁ ≡ y₂ → P x₁ y₁ → P x₂ y₂\nsubst₂ P refl refl p = p\n\ncong : ∀ {a b} {A : Set a} {B : Set b}\n (f : A → B) {x y} → x ≡ y → f x ≡ f y\ncong f refl = refl\n\ncong-app : ∀ {a b} {A : Set a} {B : A → Set b} {f g : (x : A) → B x} →\n f ≡ g → (x : A) → f x ≡ g x\ncong-app refl x = refl\n\ncong₂ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c}\n (f : A → B → C) {x y u v} → x ≡ y → u ≡ v → f x u ≡ f y v\ncong₂ f refl refl = refl\n\nproof-irrelevance : ∀ {a} {A : Set a} {x y : A} (p q : x ≡ y) → p ≡ q\nproof-irrelevance refl refl = refl\n\nsetoid : ∀ {a} → Set a → Setoid _ _\nsetoid A = record\n { Carrier = A\n ; _≈_ = _≡_\n ; isEquivalence = isEquivalence\n }\n\ndecSetoid : ∀ {a} {A : Set a} → Decidable (_≡_ {A = A}) → DecSetoid _ _\ndecSetoid dec = record\n { _≈_ = _≡_\n ; isDecEquivalence = record\n { isEquivalence = isEquivalence\n ; _≟_ = dec\n }\n }\n\nisPreorder : ∀ {a} {A : Set a} → IsPreorder {A = A} _≡_ _≡_\nisPreorder = record\n { isEquivalence = isEquivalence\n ; reflexive = id\n ; trans = trans\n }\n\npreorder : ∀ {a} → Set a → Preorder _ _ _\npreorder A = record\n { Carrier = A\n ; _≈_ = _≡_\n ; _∼_ = _≡_\n ; isPreorder = isPreorder\n }\n\n------------------------------------------------------------------------\n-- Pointwise equality\n\ninfix 4 _≗_\n\n_→-setoid_ : ∀ {a b} (A : Set a) (B : Set b) → Setoid _ _\nA →-setoid B = ≡-setoid A (Setoid.indexedSetoid (setoid B))\n\n_≗_ : ∀ {a b} {A : Set a} {B : Set b} (f g : A → B) → Set _\n_≗_ {A = A} {B} = Setoid._≈_ (A →-setoid B)\n\n:→-to-Π : ∀ {a b₁ b₂} {A : Set a} {B : I.Setoid _ b₁ b₂} →\n ((x : A) → I.Setoid.Carrier B x) → Π (setoid A) B\n:→-to-Π {B = B} f = record { _⟨$⟩_ = f; cong = cong′ }\n where\n open I.Setoid B using (_≈_)\n\n cong′ : ∀ {x y} → x ≡ y → f x ≈ f y\n cong′ refl = I.Setoid.refl B\n\n→-to-⟶ : ∀ {a b₁ b₂} {A : Set a} {B : Setoid b₁ b₂} →\n (A → Setoid.Carrier B) → setoid A ⟶ B\n→-to-⟶ = :→-to-Π\n\n------------------------------------------------------------------------\n-- The old inspect idiom\n\n-- The old inspect idiom has been deprecated, and may be removed in\n-- the future. Use inspect on steroids instead.\n\nmodule Deprecated-inspect where\n\n -- The inspect idiom can be used when you want to pattern match on\n -- the result r of some expression e, and you also need to\n -- \"remember\" that r ≡ e.\n\n -- The inspect idiom has a problem: sometimes you can only pattern\n -- match on the p part of p with-≡ eq if you also pattern match on\n -- the eq part, and then you no longer have access to the equality.\n -- Inspect on steroids solves this problem.\n\n data Inspect {a} {A : Set a} (x : A) : Set a where\n _with-≡_ : (y : A) (eq : x ≡ y) → Inspect x\n\n inspect : ∀ {a} {A : Set a} (x : A) → Inspect x\n inspect x = x with-≡ refl\n\n -- Example usage:\n\n -- f x y with inspect (g x)\n -- f x y | c z with-≡ eq = ...\n\n------------------------------------------------------------------------\n-- Inspect on steroids\n\n-- Inspect on steroids can be used when you want to pattern match on\n-- the result r of some expression e, and you also need to \"remember\"\n-- that r ≡ e.\n\ndata Reveal_is_ {a} {A : Set a} (x : Hidden A) (y : A) : Set a where\n [_] : (eq : reveal x ≡ y) → Reveal x is y\n\ninspect : ∀ {a b} {A : Set a} {B : A → Set b}\n (f : (x : A) → B x) (x : A) → Reveal (hide f x) is (f x)\ninspect f x = [ refl ]\n\n-- Example usage:\n\n-- f x y with g x | inspect g x\n-- f x y | c z | [ eq ] = ...\n\n------------------------------------------------------------------------\n-- Convenient syntax for equational reasoning\n\nimport Relation.Binary.EqReasoning as EqR\n\n-- Relation.Binary.EqReasoning is more convenient to use with _≡_ if\n-- the combinators take the type argument (a) as a hidden argument,\n-- instead of being locked to a fixed type at module instantiation\n-- time.\n\nmodule ≡-Reasoning where\n module _ {a} {A : Set a} where\n open EqR (setoid A) public\n hiding (_≡⟨_⟩_) renaming (_≈⟨_⟩_ to _≡⟨_⟩_)\n\n infixr 2 _≅⟨_⟩_\n\n _≅⟨_⟩_ : ∀ {a} {A : Set a} (x : A) {y z : A} →\n x ≅ y → y IsRelatedTo z → x IsRelatedTo z\n _ ≅⟨ x≅y ⟩ y≡z = _ ≡⟨ H.≅-to-≡ x≅y ⟩ y≡z\n\n------------------------------------------------------------------------\n-- Functional extensionality\n\n-- If _≡_ were extensional, then the following statement could be\n-- proved.\n\nExtensionality : (a b : Level) → Set _\nExtensionality a b =\n {A : Set a} {B : A → Set b} {f g : (x : A) → B x} →\n (∀ x → f x ≡ g x) → f ≡ g\n\n-- If extensionality holds for a given universe level, then it also\n-- holds for lower ones.\n\nextensionality-for-lower-levels :\n ∀ {a₁ b₁} a₂ b₂ →\n Extensionality (a₁ ⊔ a₂) (b₁ ⊔ b₂) → Extensionality a₁ b₁\nextensionality-for-lower-levels a₂ b₂ ext f≡g =\n cong (λ h → lower ∘ h ∘ lift) $\n ext (cong (lift {ℓ = b₂}) ∘ f≡g ∘ lower {ℓ = a₂})\n\n-- Functional extensionality implies a form of extensionality for\n-- Π-types.\n\n∀-extensionality :\n ∀ {a b} →\n Extensionality a (suc b) →\n {A : Set a} (B₁ B₂ : A → Set b) →\n (∀ x → B₁ x ≡ B₂ x) → (∀ x → B₁ x) ≡ (∀ x → B₂ x)\n∀-extensionality ext B₁ B₂ B₁≡B₂ with ext B₁≡B₂\n∀-extensionality ext B .B B₁≡B₂ | refl = refl\n", "meta": {"hexsha": "9db5feef519f3a89014877b9c28701a7816c415d", "size": 6139, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Relation/Binary/PropositionalEquality.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Relation/Binary/PropositionalEquality.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Relation/Binary/PropositionalEquality.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.695, "max_line_length": 72, "alphanum_fraction": 0.5310311126, "num_tokens": 2129, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.8198933337131076, "lm_q1q2_score": 0.6117543864093237}} {"text": "module functions where\n\nopen import level\nopen import eq\n\n{- Note that the Agda standard library has an interesting generalization\n of the following basic composition operator, with more dependent typing. -}\n\n_∘_ : ∀{ℓ ℓ' ℓ''}{A : Set ℓ}{B : Set ℓ'}{C : Set ℓ''} →\n (B → C) → (A → B) → (A → C)\nf ∘ g = λ x → f (g x)\n\n∘-assoc : ∀{ℓ ℓ' ℓ'' ℓ'''}{A : Set ℓ}{B : Set ℓ'}{C : Set ℓ''}{D : Set ℓ'''}\n (f : C → D)(g : B → C)(h : A → B) → (f ∘ g) ∘ h ≡ f ∘ (g ∘ h)\n∘-assoc f g h = refl\n\nid : ∀{ℓ}{A : Set ℓ} → A → A\nid = λ x → x\n\n∘-id : ∀{ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'}(f : A → B) → f ∘ id ≡ f\n∘-id f = refl\n\nid-∘ : ∀{ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'}(f : A → B) → id ∘ f ≡ f\nid-∘ f = refl\n\nextensionality : {ℓ₁ ℓ₂ : Level} → Set (lsuc ℓ₁ ⊔ lsuc ℓ₂)\nextensionality {ℓ₁}{ℓ₂} = ∀{A : Set ℓ₁}{B : Set ℓ₂}{f g : A → B} → (∀{a : A} → f a ≡ g a) → f ≡ g\n\nrecord Iso {ℓ₁ ℓ₂ : Level} (A : Set ℓ₁) (B : Set ℓ₂) : Set (ℓ₁ ⊔ ℓ₂) where\n constructor isIso\n field\n l-inv : A → B\n r-inv : B → A\n l-cancel : r-inv ∘ l-inv ≡ id\n r-cancel : l-inv ∘ r-inv ≡ id \n", "meta": {"hexsha": "a89b389e21976bbc9da520156279740b511ed1e2", "size": 1053, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "functions.agda", "max_stars_repo_name": "rfindler/ial", "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 29, "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_issues_repo_path": "functions.agda", "max_issues_repo_name": "rfindler/ial", "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_forks_repo_path": "functions.agda", "max_forks_repo_name": "rfindler/ial", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 17, "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "avg_line_length": 29.25, "max_line_length": 97, "alphanum_fraction": 0.4909781576, "num_tokens": 509, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.819893335913536, "lm_q2_score": 0.7461389873857264, "lm_q1q2_score": 0.611754383422831}} {"text": "------------------------------------------------------------------------\n-- Descending lists\n--\n-- We present some simple examples to demonstrate\n--\n-- 1. the concatenation operation on sorted lists obtained by\n-- transporting the one on finite multisets, and\n--\n-- 2. \"sorting\" finite multisets by converting into sorted lists.\n------------------------------------------------------------------------\n\n{-# OPTIONS --cubical --safe #-}\n\nmodule Cubical.Data.DescendingList.Examples where\n\nopen import Cubical.Foundations.Everything\n\nopen import Cubical.Data.Empty\nopen import Cubical.Data.Nat\n\nopen import Cubical.Relation.Nullary\nopen import Cubical.Relation.Nullary.DecidableEq\n\nopen import Cubical.HITs.FiniteMultiset\n\n\n------------------------------------------------------------------------\n-- The ordering relation on natural numbers\n--\n-- we work with the definition from the standard library.\n\ninfix 4 _≤_ _≥_\n\ndata _≤_ : ℕ → ℕ → Set where\n z≤n : ∀ {n} → zero ≤ n\n s≤s : ∀ {m n} (m≤n : m ≤ n) → suc m ≤ suc n\n\n_≥_ : ℕ → ℕ → Set\nm ≥ n = n ≤ m\n\n≤pred : {n m : ℕ} → suc n ≤ suc m → n ≤ m\n≤pred (s≤s r) = r\n\n≥isPropValued : {n m : ℕ} → isProp (n ≥ m)\n≥isPropValued z≤n z≤n = refl\n≥isPropValued (s≤s p) (s≤s q) = cong s≤s (≥isPropValued p q)\n\n≥dec : (x y : ℕ) → Dec (x ≥ y)\n≥dec zero zero = yes z≤n\n≥dec zero (suc y) = no (λ ())\n≥dec (suc x) zero = yes z≤n\n≥dec (suc x) (suc y) with ≥dec x y\n≥dec (suc x) (suc y) | yes p = yes (s≤s p)\n≥dec (suc x) (suc y) | no ¬p = no (λ r → ¬p (≤pred r))\n\n≰→≥ : {x y : ℕ} → ¬ (x ≥ y) → y ≥ x\n≰→≥ {zero} {y} f = z≤n\n≰→≥ {suc x} {zero} f = ⊥-elim (f z≤n)\n≰→≥ {suc x} {suc y} f = s≤s (≰→≥ λ g → f (s≤s g))\n\n≥trans : {x y z : ℕ} → x ≥ y → y ≥ z → x ≥ z\n≥trans z≤n z≤n = z≤n\n≥trans (s≤s r) z≤n = z≤n\n≥trans (s≤s r) (s≤s s) = s≤s (≥trans r s)\n\n≤≥→≡ : {x y : ℕ} → x ≥ y → y ≥ x → x ≡ y\n≤≥→≡ z≤n z≤n = refl\n≤≥→≡ (s≤s r) (s≤s s) = cong suc (≤≥→≡ r s)\n\n\nopen import Cubical.Data.DescendingList.Base ℕ _≥_\nopen import Cubical.Data.DescendingList.Properties ℕ _≥_\nopen isSetDL ≥isPropValued discreteℕ\nopen IsoToFMSet discreteℕ ≥dec ≥isPropValued ≥trans ≰→≥ ≤≥→≡\n\n------------------------------------------------------------------------\n-- A simple example of concatenating sorted lists\n\nl1 : DL\nl1 = cons 4 (cons 3 (cons 2 [] ≥ᴴ[]) (≥ᴴcons (s≤s (s≤s z≤n)))) (≥ᴴcons (s≤s (s≤s (s≤s z≤n))))\n\nl2 : DL\nl2 = cons 2 (cons 0 [] ≥ᴴ[]) (≥ᴴcons z≤n)\n\nl3 : DL\nl3 = l1 ++ᴰᴸ l2\n\nValueOfl3 : l3 ≡ cons 4 (cons 3 (cons 2 (cons 2 (cons 0 _ _) _) _) _) _\nValueOfl3 = refl\n\nl3=l2++l1 : l3 ≡ l2 ++ᴰᴸ l1\nl3=l2++l1 = refl\n\nLongerExample : l1 ++ᴰᴸ l2 ++ᴰᴸ l1 ++ᴰᴸ l1 ++ᴰᴸ l2\n ≡ l2 ++ᴰᴸ l1 ++ᴰᴸ l2 ++ᴰᴸ l1 ++ᴰᴸ l1\nLongerExample = refl\n\n\n------------------------------------------------------------------------\n-- A simple example of sorting finite multisets\n\nm1 : FMSet ℕ\nm1 = 13 ∷ 9 ∷ 78 ∷ 31 ∷ 86 ∷ 3 ∷ 0 ∷ 99 ∷ []\n\nm2 : FMSet ℕ\nm2 = 3 ∷ 1 ∷ 4 ∷ 1 ∷ 5 ∷ 9 ∷ []\n\nm3 : FMSet ℕ\nm3 = toFMSet (toDL (m1 ++ m2))\n\nValueOfm3 :\n m3 ≡ 99 ∷ 86 ∷ 78 ∷ 31 ∷ 13 ∷ 9 ∷ 9 ∷ 5 ∷ 4 ∷ 3 ∷ 3 ∷ 1 ∷ 1 ∷ 0 ∷ []\nValueOfm3 = refl\n\nValueOfm1++m2 :\n m1 ++ m2 ≡ 13 ∷ 9 ∷ 78 ∷ 31 ∷ 86 ∷ 3 ∷ 0 ∷ 99 ∷ 3 ∷ 1 ∷ 4 ∷ 1 ∷ 5 ∷ 9 ∷ []\nValueOfm1++m2 = refl\n\nm3=m1++m2 : m3 ≡ m1 ++ m2\nm3=m1++m2 = toFMSet∘toDL≡id (m1 ++ m2)\n", "meta": {"hexsha": "6f697ebf034d03e5225944756fbd8e072cc89ab3", "size": 3235, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/DescendingList/Examples.agda", "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/DescendingList/Examples.agda", "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Data/DescendingList/Examples.agda", "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.7355371901, "max_line_length": 93, "alphanum_fraction": 0.5007727975, "num_tokens": 1459, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933315126791, "lm_q2_score": 0.7461389873857264, "lm_q1q2_score": 0.61175438013918}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import HoTT\nopen import homotopy.SuspAdjointLoop\nopen import cohomology.WithCoefficients\n\nmodule cohomology.SuspAdjointLoopIso where\n\nmodule SuspAdjointLoopIso {i j} (X : Ptd i) (Y : Ptd j) where\n\n module ΣAΩ = SuspAdjointLoop X (⊙Ω Y)\n GSΣ = →Ω-group-structure (⊙Susp X) Y\n GSΩ = →Ω-group-structure X (⊙Ω Y)\n open GroupStructure\n\n comp-path : (p q : fst (⊙Ω (⊙Ω Y))) → ap2 _∙_ p q == p ∙ q\n comp-path p q = ap2-out _∙_ p q ∙ ap2 _∙_ (lemma p) (ap-idf q)\n where\n lemma : ∀ {i} {A : Type i} {x y : A} {p q : x == y} (α : p == q)\n → ap (λ r → r ∙ idp) α == ∙-unit-r p ∙ α ∙' ! (∙-unit-r q)\n lemma {p = idp} idp = idp\n\n pres-comp-inner : (H₁ H₂ : fst (⊙Susp X ⊙→ ⊙Ω Y))\n → ΣAΩ.R (comp GSΣ H₁ H₂) == comp GSΩ (ΣAΩ.R H₁) (ΣAΩ.R H₂)\n pres-comp-inner H₁ H₂ =\n transport\n (λ {(op , op-path) →\n ΣAΩ.R (comp GSΣ H₁ H₂) ==\n transport (λ b → Σ (fst X → _) (λ h → h (snd X) == b)) op-path\n (ΣAΩ.comp-lift (snd X) idp idp op (ΣAΩ.R H₁) (ΣAΩ.R H₂))})\n (pair= (λ= (λ p → λ= (comp-path p)))\n {b = idp} {b' = idp} (↓-app=cst-in snd-path))\n (ΣAΩ.pres-comp _∙_ H₁ H₂)\n where\n snd-path : idp == ap (λ f → f idp idp) (λ= (λ p → λ= (comp-path p))) ∙ idp\n snd-path =\n idp\n =⟨ ! (app=-β (comp-path idp) idp) ⟩\n app= (λ= (comp-path idp)) idp\n =⟨ ap (λ q → app= q idp) (! (app=-β (λ p → λ= (comp-path p)) idp)) ⟩\n app= (app= (λ= (λ p → λ= (comp-path p))) idp) idp\n =⟨ ∘-ap (λ z → z idp) (λ z → z idp) (λ= (λ p → λ= (comp-path p))) ⟩\n ap (λ f → f idp idp) (λ= (λ p → λ= (comp-path p)))\n =⟨ ! (∙-unit-r _) ⟩\n ap (λ f → f idp idp) (λ= (λ p → λ= (comp-path p))) ∙ idp ∎\n\n iso : →Ω-Group (⊙Susp X) Y ≃ᴳ →Ω-Group X (⊙Ω Y)\n iso = Trunc-Group-iso ΣAΩ.R pres-comp-inner (snd (ΣAΩ.eqv))\n", "meta": {"hexsha": "b35fccdbda6307c87512714a3a241170ac2235a1", "size": 1836, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "cohomology/SuspAdjointLoopIso.agda", "max_stars_repo_name": "danbornside/HoTT-Agda", "max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "cohomology/SuspAdjointLoopIso.agda", "max_issues_repo_name": "danbornside/HoTT-Agda", "max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cohomology/SuspAdjointLoopIso.agda", "max_forks_repo_name": "danbornside/HoTT-Agda", "max_forks_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.4693877551, "max_line_length": 78, "alphanum_fraction": 0.5021786492, "num_tokens": 856, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110483133801, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.6117373025608479}} {"text": "------------------------------------------------------------------------\n-- The \"circle\"\n------------------------------------------------------------------------\n\n{-# OPTIONS --erased-cubical --safe #-}\n\n-- Partly following the HoTT book.\n\n-- The module is parametrised by a notion of equality. The higher\n-- constructor of the HIT defining the circle uses path equality, but\n-- the supplied notion of equality is used for many other things.\n\nimport Equality.Path as P\n\nmodule Circle {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where\n\nopen P.Derived-definitions-and-properties eq hiding (elim)\n\nopen import Logical-equivalence using (_⇔_)\nopen import Prelude\n\nopen import Bijection equality-with-J as Bijection using (_↔_)\nimport Bijection P.equality-with-J as PB\nopen import Equality.Groupoid equality-with-J\nopen import Equality.Path.Isomorphisms eq\nopen import Equality.Path.Isomorphisms.Univalence eq\nimport Equality.Path.Isomorphisms P.equality-with-paths as PI\nopen import Equality.Tactic equality-with-J hiding (module Eq)\nopen import Equivalence equality-with-J as Eq using (_≃_)\nimport Equivalence P.equality-with-J as PE\nimport Erased.Cubical eq as E\nopen import Function-universe equality-with-J as F hiding (id; _∘_)\nopen import Group equality-with-J as G using (_≃ᴳ_)\nimport Group.Cyclic eq as C\nopen import Groupoid equality-with-J\nopen import H-level equality-with-J as H-level\nopen import H-level.Closure equality-with-J\nopen import H-level.Truncation eq as T using (∥_∥[1+_])\nopen import H-level.Truncation.Propositional eq as Trunc\n using (∥_∥; ∣_∣)\nopen import H-level.Truncation.Propositional.One-step eq as O\n using (∥_∥¹)\nopen import Integer equality-with-J as Int\n using (ℤ; +_; -[1+_]; ℤ-group)\nopen import Nat equality-with-J\nopen import Pointed-type equality-with-J as PT using (_≃ᴮ_)\nopen import Pointed-type.Homotopy-group eq\nopen import Sphere eq as Sphere using (𝕊)\nopen import Suspension eq as Suspension\n using (Susp; north; south; meridian)\nopen import Univalence-axiom equality-with-J as Univ using (Univalence)\n\nprivate\n variable\n a p : Level\n A : Type p\n P : A → Type p\n f : (x : A) → P x\n b ℓ x : A\n\n------------------------------------------------------------------------\n-- The type and some eliminators\n\n-- The circle.\n\ndata 𝕊¹ : Type where\n base : 𝕊¹\n loopᴾ : base P.≡ base\n\nloop : base ≡ base\nloop = _↔_.from ≡↔≡ loopᴾ\n\n-- A dependent eliminator, expressed using paths.\n\nelimᴾ :\n (P : 𝕊¹ → Type p)\n (b : P base) →\n P.[ (λ i → P (loopᴾ i)) ] b ≡ b →\n (x : 𝕊¹) → P x\nelimᴾ P b ℓ base = b\nelimᴾ P b ℓ (loopᴾ i) = ℓ i\n\n-- A non-dependent eliminator, expressed using paths.\n\nrecᴾ : (b : A) → b P.≡ b → 𝕊¹ → A\nrecᴾ = elimᴾ _\n\n-- A dependent eliminator.\n\nelim :\n (P : 𝕊¹ → Type p)\n (b : P base) →\n subst P loop b ≡ b →\n (x : 𝕊¹) → P x\nelim P b ℓ = elimᴾ P b (subst≡→[]≡ ℓ)\n\n-- A \"computation\" rule.\n\nelim-loop : dcong (elim P b ℓ) loop ≡ ℓ\nelim-loop = dcong-subst≡→[]≡ (refl _)\n\n-- Every dependent function of type (x : 𝕊¹) → P x can be expressed\n-- using elim.\n\nη-elim :\n {f : (x : 𝕊¹) → P x} →\n f ≡ elim P (f base) (dcong f loop)\nη-elim {P = P} {f = f} =\n ⟨ext⟩ $ elim _ (refl _)\n (subst (λ x → f x ≡ elim P (f base) (dcong f loop) x) loop (refl _) ≡⟨ subst-in-terms-of-trans-and-dcong ⟩\n\n trans (sym (dcong f loop))\n (trans (cong (subst P loop) (refl _))\n (dcong (elim P (f base) (dcong f loop)) loop)) ≡⟨ cong (trans (sym (dcong f loop))) $\n trans (cong (flip trans _) $ cong-refl _) $\n trans-reflˡ _ ⟩\n trans (sym (dcong f loop))\n (dcong (elim P (f base) (dcong f loop)) loop) ≡⟨ cong (trans (sym (dcong f loop))) elim-loop ⟩\n\n trans (sym (dcong f loop)) (dcong f loop) ≡⟨ trans-symˡ _ ⟩∎\n\n refl _ ∎)\n\n-- A non-dependent eliminator.\n\nrec : (b : A) → b ≡ b → 𝕊¹ → A\nrec b ℓ = recᴾ b (_↔_.to ≡↔≡ ℓ)\n\n-- A \"computation\" rule.\n\nrec-loop : cong (rec b ℓ) loop ≡ ℓ\nrec-loop = cong-≡↔≡ (refl _)\n\n-- Every function from 𝕊¹ to A can be expressed using rec.\n\nη-rec : {f : 𝕊¹ → A} → f ≡ rec (f base) (cong f loop)\nη-rec {f = f} =\n ⟨ext⟩ $ elim _ (refl _)\n (subst (λ x → f x ≡ rec (f base) (cong f loop) x) loop (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩\n\n trans (sym (cong f loop))\n (trans (refl _) (cong (rec (f base) (cong f loop)) loop)) ≡⟨ cong (trans (sym (cong f loop))) $ trans-reflˡ _ ⟩\n\n trans (sym (cong f loop)) (cong (rec (f base) (cong f loop)) loop) ≡⟨ cong (trans (sym (cong f loop))) rec-loop ⟩\n\n trans (sym (cong f loop)) (cong f loop) ≡⟨ trans-symˡ _ ⟩∎\n\n refl _ ∎)\n\n-- An alternative non-dependent eliminator.\n\nrec′ : (b : A) → b ≡ b → 𝕊¹ → A\nrec′ {A = A} b ℓ = elim\n (const A)\n b\n (subst (const A) loop b ≡⟨ subst-const _ ⟩\n b ≡⟨ ℓ ⟩∎\n b ∎)\n\n-- A \"computation\" rule.\n\nrec′-loop : cong (rec′ b ℓ) loop ≡ ℓ\nrec′-loop = dcong≡→cong≡ elim-loop\n\n------------------------------------------------------------------------\n-- Some equivalences\n\n-- The circle can be expressed as a suspension.\n\n𝕊¹≃Susp-Bool : 𝕊¹ ≃ Susp Bool\n𝕊¹≃Susp-Bool = Eq.↔→≃ to from to∘from from∘to\n where\n north≡north =\n north ≡⟨ meridian false ⟩\n south ≡⟨ sym $ meridian true ⟩∎\n north ∎\n\n to : 𝕊¹ → Susp Bool\n to = rec north north≡north\n\n module From = Suspension.Rec base base (if_then refl base else loop)\n\n from : Susp Bool → 𝕊¹\n from = From.rec\n\n to∘from : ∀ x → to (from x) ≡ x\n to∘from = Suspension.elim _\n (to (from north) ≡⟨⟩\n north ∎)\n (to (from south) ≡⟨⟩\n north ≡⟨ meridian true ⟩∎\n south ∎)\n (λ b →\n subst (λ x → to (from x) ≡ x) (meridian b) (refl north) ≡⟨ subst-in-terms-of-trans-and-cong ⟩\n\n trans (sym (cong (to ∘ from) (meridian b)))\n (trans (refl _) (cong id (meridian b))) ≡⟨ cong₂ (trans ∘ sym)\n (trans (sym $ cong-∘ _ _ _) $\n cong (cong to) From.rec-meridian)\n (trans (trans-reflˡ _) $\n sym $ cong-id _) ⟩\n trans (sym (cong to (if b then refl base else loop)))\n (meridian b) ≡⟨ lemma b ⟩∎\n\n meridian true ∎)\n where\n lemma : (b : Bool) → _ ≡ _\n lemma true =\n trans (sym (cong to (if true ⦂ Bool then refl base else loop)))\n (meridian true) ≡⟨⟩\n\n trans (sym (cong to (refl base))) (meridian true) ≡⟨ prove (Trans (Sym (Cong _ Refl)) (Lift _)) (Lift _) (refl _) ⟩∎\n\n meridian true ∎\n\n lemma false =\n trans (sym (cong to (if false ⦂ Bool then refl base else loop)))\n (meridian false) ≡⟨⟩\n\n trans (sym (cong to loop)) (meridian false) ≡⟨ cong (λ p → trans (sym p) (meridian false)) rec-loop ⟩\n\n trans (sym north≡north) (meridian false) ≡⟨ prove (Trans (Sym (Trans (Lift _) (Sym (Lift _)))) (Lift _))\n (Trans (Trans (Lift _) (Sym (Lift _))) (Lift _))\n (refl _) ⟩\n trans (trans (meridian true) (sym $ meridian false))\n (meridian false) ≡⟨ trans-[trans-sym]- _ _ ⟩∎\n\n meridian true ∎\n\n from∘to : ∀ x → from (to x) ≡ x\n from∘to = elim _\n (from (to base) ≡⟨⟩\n base ∎)\n (subst (λ x → from (to x) ≡ x) loop (refl base) ≡⟨ subst-in-terms-of-trans-and-cong ⟩\n\n trans (sym (cong (from ∘ to) loop))\n (trans (refl base) (cong id loop)) ≡⟨ cong₂ (trans ∘ sym)\n (trans (sym $ cong-∘ _ to _) $\n cong (cong from) rec-loop)\n (trans (trans-reflˡ _) $\n sym $ cong-id _) ⟩\n\n trans (sym (cong from north≡north)) loop ≡⟨ prove (Trans (Sym (Cong _ (Trans (Lift _) (Sym (Lift _))))) (Lift _))\n (Trans (Trans (Cong from (Lift (meridian true)))\n (Sym (Cong from (Lift (meridian false)))))\n (Lift _))\n (refl _) ⟩\n trans (trans (cong from (meridian true))\n (sym $ cong from (meridian false)))\n loop ≡⟨ cong₂ (λ p q → trans (trans p (sym q)) loop)\n From.rec-meridian\n From.rec-meridian ⟩\n trans (trans (if true ⦂ Bool then refl base else loop)\n (sym $ if false ⦂ Bool then refl base else loop))\n loop ≡⟨⟩\n\n trans (trans (refl base) (sym loop)) loop ≡⟨ trans-[trans-sym]- _ _ ⟩∎\n\n refl base ∎)\n\n-- The circle is equivalent to the 1-dimensional sphere.\n\n𝕊¹≃𝕊¹ : 𝕊¹ ≃ 𝕊 1\n𝕊¹≃𝕊¹ =\n 𝕊¹ ↝⟨ 𝕊¹≃Susp-Bool ⟩\n Susp Bool ↔⟨ Suspension.cong-↔ Sphere.Bool↔𝕊⁰ ⟩\n Susp (𝕊 0) ↔⟨⟩\n 𝕊 1 □\n\n------------------------------------------------------------------------\n-- The loop space of the circle\n\n-- The function trans is commutative for the loop space of the circle.\n\ntrans-commutative : (p q : base ≡ base) → trans p q ≡ trans q p\ntrans-commutative =\n flip $ Transitivity-commutative.commutative base _∙_ ∙-base base-∙\n where\n _∙_ : 𝕊¹ → 𝕊¹ → 𝕊¹\n x ∙ y = rec x (elim (λ x → x ≡ x) loop lemma x) y\n where\n lemma : subst (λ x → x ≡ x) loop loop ≡ loop\n lemma = ≡⇒↝ _ (sym [subst≡]≡[trans≡trans]) (refl _)\n\n base-∙ : ∀ x → x ∙ base ≡ x\n base-∙ _ = refl _\n\n ∙-base : ∀ y → base ∙ y ≡ y\n ∙-base =\n elim _ (refl _)\n (subst (λ x → rec base loop x ≡ x) loop (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩\n\n trans (sym (cong (rec base loop) loop))\n (trans (refl _) (cong id loop)) ≡⟨ cong (trans _) $ trans-reflˡ _ ⟩\n\n trans (sym (cong (rec base loop) loop)) (cong id loop) ≡⟨ cong₂ (trans ∘ sym)\n rec-loop\n (sym $ cong-id _) ⟩\n\n trans (sym loop) loop ≡⟨ trans-symˡ _ ⟩∎\n\n refl _ ∎)\n\n-- The loop space is equivalent to x ≡ x, for any x : 𝕊¹.\n\nbase≡base≃≡ : {x : 𝕊¹} → (base ≡ base) ≃ (x ≡ x)\nbase≡base≃≡ = elim\n (λ x → (base ≡ base) ≃ (x ≡ x))\n Eq.id\n (Eq.lift-equality ext $ ⟨ext⟩ λ eq →\n _≃_.to (subst (λ x → (base ≡ base) ≃ (x ≡ x)) loop Eq.id) eq ≡⟨ cong (_$ eq) Eq.to-subst ⟩\n subst (λ x → base ≡ base → x ≡ x) loop id eq ≡⟨ subst-→ ⟩\n subst (λ x → x ≡ x) loop (subst (λ _ → base ≡ base) (sym loop) eq) ≡⟨ cong (subst (λ x → x ≡ x) loop) $ subst-const _ ⟩\n subst (λ x → x ≡ x) loop eq ≡⟨ ≡⇒↝ _ (sym [subst≡]≡[trans≡trans]) (\n\n trans eq loop ≡⟨ trans-commutative _ _ ⟩∎\n trans loop eq ∎) ⟩∎\n\n eq ∎)\n _\n\nprivate\n\n -- Definitions used to define base≡base≃ℤ and Fundamental-group≃ℤ.\n\n module base≡base≃ℤ (univ : Univalence lzero) where\n\n -- The universal cover of the circle.\n\n Cover : 𝕊¹ → Type\n Cover = rec ℤ (Univ.≃⇒≡ univ Int.successor)\n\n to : base ≡ x → Cover x\n to = flip (subst Cover) (+ 0)\n\n ≡⇒≃-cong-Cover-loop : Univ.≡⇒≃ (cong Cover loop) ≡ Int.successor\n ≡⇒≃-cong-Cover-loop =\n Univ.≡⇒≃ (cong Cover loop) ≡⟨ cong Univ.≡⇒≃ rec-loop ⟩\n Univ.≡⇒≃ (Univ.≃⇒≡ univ Int.successor) ≡⟨ _≃_.right-inverse-of (Univ.≡≃≃ univ) _ ⟩∎\n Int.successor ∎\n\n subst-Cover-loop :\n ∀ i → subst Cover loop i ≡ Int.suc i\n subst-Cover-loop i =\n subst Cover loop i ≡⟨ subst-in-terms-of-≡⇒↝ equivalence _ _ _ ⟩\n Univ.≡⇒→ (cong Cover loop) i ≡⟨ cong (λ eq → _≃_.to eq _) ≡⇒≃-cong-Cover-loop ⟩∎\n _≃_.to Int.successor i ∎\n\n subst-Cover-sym-loop :\n ∀ i → subst Cover (sym loop) i ≡ Int.pred i\n subst-Cover-sym-loop i =\n subst Cover (sym loop) i ≡⟨ subst-in-terms-of-inverse∘≡⇒↝ equivalence _ _ _ ⟩\n _≃_.from (Univ.≡⇒≃ (cong Cover loop)) i ≡⟨ cong (λ eq → _≃_.from eq _) ≡⇒≃-cong-Cover-loop ⟩∎\n _≃_.from Int.successor i ∎\n\n module 𝕊¹-G = Groupoid (groupoid 𝕊¹)\n\n loops : ℤ → base ≡ base\n loops = loop 𝕊¹-G.^_\n\n to-loops : ∀ i → to (loops i) ≡ i\n to-loops (+ zero) =\n subst Cover (refl _) (+ 0) ≡⟨ subst-refl _ _ ⟩∎\n + zero ∎\n to-loops (+ suc n) =\n subst Cover (trans (loops (+ n)) loop) (+ 0) ≡⟨ sym $ subst-subst _ _ _ _ ⟩\n subst Cover loop (subst Cover (loops (+ n)) (+ 0)) ≡⟨⟩\n subst Cover loop (to (loops (+ n))) ≡⟨ cong (subst Cover loop) $ to-loops (+ n) ⟩\n subst Cover loop (+ n) ≡⟨ subst-Cover-loop _ ⟩∎\n + suc n ∎\n to-loops -[1+ zero ] =\n subst Cover (trans (refl _) (sym loop)) (+ 0) ≡⟨ cong (flip (subst Cover) _) $ trans-reflˡ _ ⟩\n subst Cover (sym loop) (+ 0) ≡⟨ subst-Cover-sym-loop _ ⟩∎\n -[1+ zero ] ∎\n to-loops -[1+ suc n ] =\n subst Cover (trans (loops -[1+ n ]) (sym loop)) (+ 0) ≡⟨ sym $ subst-subst _ _ _ _ ⟩\n subst Cover (sym loop) (subst Cover (loops -[1+ n ]) (+ 0)) ≡⟨⟩\n subst Cover (sym loop) (to (loops -[1+ n ])) ≡⟨ cong (subst Cover (sym loop)) $ to-loops -[1+ n ] ⟩\n subst Cover (sym loop) -[1+ n ] ≡⟨ subst-Cover-sym-loop _ ⟩∎\n -[1+ suc n ] ∎\n\n loops-pred-loop :\n ∀ i → trans (loops (Int.pred i)) loop ≡ loops i\n loops-pred-loop i =\n trans (loops (Int.pred i)) loop ≡⟨ cong (flip trans _ ∘ loops) $ Int.pred≡-1+ i ⟩\n trans (loops (Int.-[ 1 ] Int.+ i)) loop ≡⟨ cong (flip trans _) $ sym $ 𝕊¹-G.^∘^ {j = i} Int.-[ 1 ] ⟩\n trans (trans (loops i) (loops (Int.-[ 1 ]))) loop ≡⟨⟩\n trans (trans (loops i) (trans (refl _) (sym loop))) loop ≡⟨ cong (flip trans _) $ cong (trans _) $ trans-reflˡ _ ⟩\n trans (trans (loops i) (sym loop)) loop ≡⟨ trans-[trans-sym]- _ _ ⟩∎\n loops i ∎\n\n from : ∀ x → Cover x → base ≡ x\n from = elim _\n loops\n (⟨ext⟩ λ i →\n subst (λ x → Cover x → base ≡ x) loop loops i ≡⟨ subst-→ ⟩\n subst (base ≡_) loop (loops (subst Cover (sym loop) i)) ≡⟨ sym trans-subst ⟩\n trans (loops (subst Cover (sym loop) i)) loop ≡⟨ cong (flip trans _ ∘ loops) $ subst-Cover-sym-loop _ ⟩\n trans (loops (Int.pred i)) loop ≡⟨ loops-pred-loop i ⟩∎\n loops i ∎)\n\n from-to : (eq : base ≡ x) → from x (to eq) ≡ eq\n from-to = elim¹\n (λ {x} eq → from x (to eq) ≡ eq)\n (from base (to (refl base)) ≡⟨⟩\n loops (subst Cover (refl base) (+ 0)) ≡⟨ cong loops $ subst-refl _ _ ⟩\n loops (+ 0) ≡⟨⟩\n refl base ∎)\n\n loops-+ : ∀ i j → loops (i Int.+ j) ≡ trans (loops i) (loops j)\n loops-+ i j =\n loops (i Int.+ j) ≡⟨ cong loops $ Int.+-comm i ⟩\n loops (j Int.+ i) ≡⟨ sym $ 𝕊¹-G.^∘^ j ⟩∎\n trans (loops i) (loops j) ∎\n\n-- The loop space of the circle is equivalent to the type of integers\n-- (assuming univalence).\n--\n-- The proof is based on the one presented by Licata and Shulman in\n-- \"Calculating the Fundamental Group of the Circle in Homotopy Type\n-- Theory\".\n\nbase≡base≃ℤ :\n Univalence lzero →\n (base ≡ base) ≃ ℤ\nbase≡base≃ℤ univ = Eq.↔→≃ to loops to-loops from-to\n where\n open base≡base≃ℤ univ\n\n-- The circle's fundamental group is equivalent to the group of\n-- integers (assuming univalence).\n\nFundamental-group≃ℤ :\n Univalence lzero →\n Fundamental-group (𝕊¹ , base) ≃ᴳ ℤ-group\nFundamental-group≃ℤ univ = G.≃ᴳ-sym λ where\n .G.Homomorphic.related → inverse\n (∥ base ≡ base ∥[1+ 1 ] ↝⟨ T.∥∥-cong $ base≡base≃ℤ univ ⟩\n ∥ ℤ ∥[1+ 1 ] ↔⟨ _⇔_.to (T.+⇔∥∥↔ {n = 1}) Int.ℤ-set ⟩□\n ℤ □)\n .G.Homomorphic.homomorphic i j → cong T.∣_∣ (loops-+ i j)\n where\n open base≡base≃ℤ univ\n\n-- The circle is a groupoid (assuming univalence).\n\n𝕊¹-groupoid :\n Univalence lzero →\n H-level 3 𝕊¹\n𝕊¹-groupoid univ {x = x} {y = y} =\n $⟨ (λ {_ _} → Int.ℤ-set) ⟩\n Is-set ℤ ↝⟨ H-level-cong _ 2 (inverse $ base≡base≃ℤ univ) ⦂ (_ → _) ⟩\n Is-set (base ≡ base) ↝⟨ (λ s →\n elim\n (λ x → ∀ y → Is-set (x ≡ y))\n (elim _ s (H-level-propositional ext 2 _ _))\n ((Π-closure ext 1 λ _ →\n H-level-propositional ext 2)\n _ _)\n x y) ⟩□\n Is-set (x ≡ y) □\n\n-- The type of endofunctions on 𝕊¹ is equivalent to\n-- ∃ λ (x : 𝕊¹) → x ≡ x.\n\n𝕊¹→𝕊¹≃Σ𝕊¹≡ : (𝕊¹ → 𝕊¹) ≃ ∃ λ (x : 𝕊¹) → x ≡ x\n𝕊¹→𝕊¹≃Σ𝕊¹≡ = Eq.↔→≃ to from to-from from-to\n where\n to : (𝕊¹ → 𝕊¹) → ∃ λ (x : 𝕊¹) → x ≡ x\n to f = f base , cong f loop\n\n from : (∃ λ (x : 𝕊¹) → x ≡ x) → (𝕊¹ → 𝕊¹)\n from = uncurry rec\n\n to-from : ∀ p → to (from p) ≡ p\n to-from (x , eq) = cong (x ,_)\n (cong (rec x eq) loop ≡⟨ rec-loop ⟩∎\n eq ∎)\n\n from-to : ∀ f → from (to f) ≡ f\n from-to f =\n rec (f base) (cong f loop) ≡⟨ sym η-rec ⟩∎\n f ∎\n\n-- The type of endofunctions on 𝕊¹ is equivalent to 𝕊¹ × ℤ (assuming\n-- univalence).\n--\n-- This result was pointed out to me by Paolo Capriotti.\n\n𝕊¹→𝕊¹≃𝕊¹×ℤ :\n Univalence lzero →\n (𝕊¹ → 𝕊¹) ≃ (𝕊¹ × ℤ)\n𝕊¹→𝕊¹≃𝕊¹×ℤ univ =\n (𝕊¹ → 𝕊¹) ↝⟨ 𝕊¹→𝕊¹≃Σ𝕊¹≡ ⟩\n (∃ λ (x : 𝕊¹) → x ≡ x) ↝⟨ (∃-cong λ _ → inverse base≡base≃≡) ⟩\n 𝕊¹ × base ≡ base ↝⟨ (∃-cong λ _ → base≡base≃ℤ univ) ⟩□\n 𝕊¹ × ℤ □\n\n-- The forward direction of 𝕊¹→𝕊¹≃𝕊¹×ℤ maps the identity function to\n-- base , + 1.\n\n𝕊¹→𝕊¹≃𝕊¹×ℤ-id :\n (univ : Univalence lzero) →\n _≃_.to (𝕊¹→𝕊¹≃𝕊¹×ℤ univ) id ≡ (base , + 1)\n𝕊¹→𝕊¹≃𝕊¹×ℤ-id univ = _≃_.from-to (𝕊¹→𝕊¹≃𝕊¹×ℤ univ)\n (rec base (trans (refl base) loop) ≡⟨ cong (rec base) $ trans-reflˡ _ ⟩\n rec base loop ≡⟨ cong (rec base) $ cong-id _ ⟩\n rec base (cong id loop) ≡⟨ sym η-rec ⟩∎\n id ∎)\n\n-- The forward direction of 𝕊¹→𝕊¹≃𝕊¹×ℤ maps the constant function\n-- returning base to base , + 0.\n\n𝕊¹→𝕊¹≃𝕊¹×ℤ-const :\n (univ : Univalence lzero) →\n _≃_.to (𝕊¹→𝕊¹≃𝕊¹×ℤ univ) (const base) ≡ (base , + 0)\n𝕊¹→𝕊¹≃𝕊¹×ℤ-const univ = _≃_.from-to (𝕊¹→𝕊¹≃𝕊¹×ℤ univ)\n (rec base (refl base) ≡⟨ cong (rec base) $ sym $ cong-const _ ⟩\n rec base (cong (const base) loop) ≡⟨ sym η-rec ⟩∎\n const base ∎)\n\n------------------------------------------------------------------------\n-- A conversion function\n\n-- The one-step truncation of the unit type is equivalent to the\n-- circle.\n--\n-- Paolo Capriotti informed me about this result.\n\n∥⊤∥¹≃𝕊¹ : ∥ ⊤ ∥¹ ≃ 𝕊¹\n∥⊤∥¹≃𝕊¹ = _↔_.from ≃↔≃ $ PE.↔→≃\n (O.recᴾ λ where\n .O.∣∣ʳ _ → base\n .O.∣∣-constantʳ _ _ → loopᴾ)\n (recᴾ O.∣ _ ∣ (O.∣∣-constantᴾ _ _))\n (elimᴾ _ P.refl (λ _ → P.refl))\n (O.elimᴾ λ where\n .O.∣∣ʳ _ → P.refl\n .O.∣∣-constantʳ _ _ _ → P.refl)\n\n------------------------------------------------------------------------\n-- Some negative results\n\n-- The equality loop is not equal to refl base.\n\nloop≢refl : loop ≢ refl base\nloop≢refl =\n E.Stable-¬\n E.[ loop ≡ refl base →⟨ Type-set ⟩\n Is-set Type →⟨ Univ.¬-Type-set univ ⟩□\n ⊥ □\n ]\n where\n module _ (loop≡refl : loop ≡ refl base) where\n\n refl≡ : (A : Type) (A≡A : A ≡ A) → refl A ≡ A≡A\n refl≡ A A≡A =\n refl A ≡⟨⟩\n refl (rec A A≡A base) ≡⟨ sym $ cong-refl _ ⟩\n cong (rec A A≡A) (refl base) ≡⟨ cong (cong (rec A A≡A)) $ sym loop≡refl ⟩\n cong (rec A A≡A) loop ≡⟨ rec-loop ⟩∎\n A≡A ∎\n\n Type-set : Is-set Type\n Type-set {x = A} {y = B} =\n elim¹ (λ p → ∀ q → p ≡ q)\n (refl≡ A)\n\n-- Thus the circle is not a set.\n\n¬-𝕊¹-set : ¬ Is-set 𝕊¹\n¬-𝕊¹-set =\n Is-set 𝕊¹ ↝⟨ (λ h → h) ⟩\n Is-proposition (base ≡ base) ↝⟨ (λ h → h _ _) ⟩\n loop ≡ refl base ↝⟨ loop≢refl ⟩□\n ⊥ □\n\n-- It is not necessarily the case that the one-step truncation of a\n-- proposition is a proposition.\n\n¬-Is-proposition-∥∥¹ :\n ¬ ({A : Type a} → Is-proposition A → Is-proposition ∥ A ∥¹)\n¬-Is-proposition-∥∥¹ {a = a} =\n ({A : Type a} → Is-proposition A → Is-proposition ∥ A ∥¹) ↝⟨ _$ H-level.mono₁ 0 (↑-closure 0 ⊤-contractible) ⟩\n Is-proposition ∥ ↑ a ⊤ ∥¹ ↝⟨ H-level-cong _ 1 (O.∥∥¹-cong-↔ Bijection.↑↔) ⟩\n Is-proposition ∥ ⊤ ∥¹ ↝⟨ H-level-cong _ 1 ∥⊤∥¹≃𝕊¹ ⟩\n Is-proposition 𝕊¹ ↝⟨ ¬-𝕊¹-set ∘ H-level.mono₁ 1 ⟩□\n ⊥ □\n\n-- A function with the type of refl (for 𝕊¹) that is not equal to\n-- refl.\n\nnot-refl : (x : 𝕊¹) → x ≡ x\nnot-refl = elim _\n loop\n (subst (λ z → z ≡ z) loop loop ≡⟨ ≡⇒↝ _ (sym [subst≡]≡[trans≡trans]) (refl _) ⟩∎\n loop ∎)\n\n-- The function not-refl is not equal to refl.\n\nnot-refl≢refl : not-refl ≢ refl\nnot-refl≢refl =\n not-refl ≡ refl ↝⟨ cong (_$ _) ⟩\n loop ≡ refl base ↝⟨ loop≢refl ⟩□\n ⊥ □\n\n-- There is a value with the type of refl that is not equal to refl.\n\n∃≢refl : ∃ λ (f : (x : 𝕊¹) → x ≡ x) → f ≢ refl\n∃≢refl = not-refl , not-refl≢refl\n\n-- For every universe level there is a type A such that\n-- (x : A) → x ≡ x is not a proposition.\n\n¬-type-of-refl-propositional :\n ∃ λ (A : Type a) → ¬ Is-proposition ((x : A) → x ≡ x)\n¬-type-of-refl-propositional {a = a} =\n ↑ _ 𝕊¹\n , (Is-proposition (∀ x → x ≡ x) ↝⟨ (λ prop → prop _ _) ⟩\n\n cong lift ∘ proj₁ ∃≢refl ∘ lower ≡ cong lift ∘ refl ∘ lower ↝⟨ cong (_∘ lift) ⟩\n\n cong lift ∘ proj₁ ∃≢refl ≡ cong lift ∘ refl ↝⟨ cong (cong lower ∘_) ⟩\n\n cong lower ∘ cong lift ∘ proj₁ ∃≢refl ≡\n cong lower ∘ cong lift ∘ refl ↝⟨ ≡⇒↝ _ (cong₂ _≡_ (⟨ext⟩ λ _ → cong-∘ _ _ _) (⟨ext⟩ λ _ → cong-∘ _ _ _)) ⟩\n\n cong id ∘ proj₁ ∃≢refl ≡ cong id ∘ refl ↝⟨ ≡⇒↝ _ (sym $ cong₂ _≡_ (⟨ext⟩ λ _ → cong-id _) (⟨ext⟩ λ _ → cong-id _)) ⟩\n\n proj₁ ∃≢refl ≡ refl ↝⟨ proj₂ ∃≢refl ⟩□\n\n ⊥ □)\n\n-- Every element of the circle is /merely/ equal to the base point.\n--\n-- This lemma was mentioned by Mike Shulman in a blog post\n-- (http://homotopytypetheory.org/2013/07/24/cohomology/).\n\nall-points-on-the-circle-are-merely-equal :\n (x : 𝕊¹) → ∥ x ≡ base ∥\nall-points-on-the-circle-are-merely-equal =\n elim _\n ∣ refl base ∣\n (Trunc.truncation-is-proposition _ _)\n\n-- Thus every element of the circle is not not equal to the base\n-- point.\n\nall-points-on-the-circle-are-¬¬-equal :\n (x : 𝕊¹) → ¬ ¬ x ≡ base\nall-points-on-the-circle-are-¬¬-equal x =\n x ≢ base ↝⟨ Trunc.rec ⊥-propositional ⟩\n ¬ ∥ x ≡ base ∥ ↝⟨ _$ all-points-on-the-circle-are-merely-equal x ⟩□\n ⊥ □\n\n-- It is not the case that every point on the circle is equal to the\n-- base point.\n\n¬-all-points-on-the-circle-are-equal :\n ¬ ((x : 𝕊¹) → x ≡ base)\n¬-all-points-on-the-circle-are-equal =\n ((x : 𝕊¹) → x ≡ base) ↝⟨ (λ hyp x y → x ≡⟨ hyp x ⟩\n base ≡⟨ sym (hyp y) ⟩∎\n y ∎) ⟩\n Is-proposition 𝕊¹ ↝⟨ mono₁ 1 ⟩\n Is-set 𝕊¹ ↝⟨ ¬-𝕊¹-set ⟩□\n ⊥ □\n\n-- Thus double-negation shift for Type-valued predicates over 𝕊¹ does\n-- not hold in general.\n\n¬-double-negation-shift :\n ¬ ({P : 𝕊¹ → Type} → ((x : 𝕊¹) → ¬ ¬ P x) → ¬ ¬ ((x : 𝕊¹) → P x))\n¬-double-negation-shift =\n ({P : 𝕊¹ → Type} → ((x : 𝕊¹) → ¬ ¬ P x) → ¬ ¬ ((x : 𝕊¹) → P x)) ↝⟨ _$ all-points-on-the-circle-are-¬¬-equal ⟩\n ¬ ¬ ((x : 𝕊¹) → x ≡ base) ↝⟨ _$ ¬-all-points-on-the-circle-are-equal ⟩□\n ⊥ □\n\n-- Furthermore excluded middle for arbitrary types (in Type) does not\n-- hold.\n\n¬-excluded-middle : ¬ ({A : Type} → Dec A)\n¬-excluded-middle =\n ({A : Type} → Dec A) ↝⟨ (λ em ¬¬a → [ id , ⊥-elim ∘ ¬¬a ] em) ⟩\n ({A : Type} → ¬ ¬ A → A) ↝⟨ (λ dne → flip _$_ ∘ (dne ∘_)) ⟩\n ({P : 𝕊¹ → Type} → ((x : 𝕊¹) → ¬ ¬ P x) → ¬ ¬ ((x : 𝕊¹) → P x)) ↝⟨ ¬-double-negation-shift ⟩□\n ⊥ □\n\n-- H-level.Closure.proj₁-closure cannot be generalised by replacing\n-- the assumption ∀ a → B a with ∀ a → ∥ B a ∥.\n--\n-- This observation is due to Andrea Vezzosi.\n\n¬-generalised-proj₁-closure :\n ¬ ({A : Type} {B : A → Type} →\n (∀ a → ∥ B a ∥) →\n ∀ n → H-level n (Σ A B) → H-level n A)\n¬-generalised-proj₁-closure generalised-proj₁-closure =\n $⟨ singleton-contractible _ ⟩\n Contractible (Σ 𝕊¹ (_≡ base)) ↝⟨ generalised-proj₁-closure\n all-points-on-the-circle-are-merely-equal\n 0 ⟩\n Contractible 𝕊¹ ↝⟨ mono (zero≤ 2) ⟩\n Is-set 𝕊¹ ↝⟨ ¬-𝕊¹-set ⟩□\n ⊥ □\n\n-- There is no based equivalence between the circle and the product of\n-- the circle with itself.\n--\n-- This result was pointed out to me by Paolo Capriotti.\n\n𝕊¹≄ᴮ𝕊¹×𝕊¹ : ¬ (𝕊¹ , base) ≃ᴮ ((𝕊¹ , base) PT.× (𝕊¹ , base))\n𝕊¹≄ᴮ𝕊¹×𝕊¹ =\n E.Stable-¬\n E.[ (𝕊¹ , base) ≃ᴮ ((𝕊¹ , base) PT.× (𝕊¹ , base)) ↝⟨ ≃ᴮ→≃ᴳ (𝕊¹ , base) ((𝕊¹ , base) PT.× (𝕊¹ , base)) 0 ⟩\n\n Fundamental-group (𝕊¹ , base) ≃ᴳ\n Fundamental-group ((𝕊¹ , base) PT.× (𝕊¹ , base)) ↝⟨ flip G.↝ᴳ-trans (Homotopy-group-[1+ 0 ]-× (𝕊¹ , base) (𝕊¹ , base)) ⟩\n\n Fundamental-group (𝕊¹ , base) ≃ᴳ\n (Fundamental-group (𝕊¹ , base) G.× Fundamental-group (𝕊¹ , base)) ↝⟨ flip G.↝ᴳ-trans\n (G.↝-× (Fundamental-group≃ℤ univ) (Fundamental-group≃ℤ univ)) ∘\n G.↝ᴳ-trans (G.≃ᴳ-sym (Fundamental-group≃ℤ univ)) ⟩\n\n ℤ-group ≃ᴳ (ℤ-group G.× ℤ-group) ↝⟨ C.ℤ≄ᴳℤ×ℤ ⟩□\n\n ⊥ □\n ]\n\n-- 𝕊¹ is not equivalent to 𝕊¹ × 𝕊¹.\n--\n-- This result was pointed out to me by Paolo Capriotti.\n\n𝕊¹≄𝕊¹×𝕊¹ : ¬ 𝕊¹ ≃ (𝕊¹ × 𝕊¹)\n𝕊¹≄𝕊¹×𝕊¹ hyp =\n let x , y = _≃_.to hyp base in\n all-points-on-the-circle-are-¬¬-equal x λ x≡base →\n all-points-on-the-circle-are-¬¬-equal y λ y≡base →\n 𝕊¹≄ᴮ𝕊¹×𝕊¹ (hyp , cong₂ _,_ x≡base y≡base)\n\n------------------------------------------------------------------------\n-- An alternative approach to defining eliminators and proving\n-- computation rules for arbitrary notions of equality, based on an\n-- anonymous reviewer's suggestion\n\n-- Circle eq p is an axiomatisation of the circle, for the given\n-- notion of equality eq, eliminating into Type p.\n--\n-- Note that the statement of the computation rule for \"loop\" is more\n-- complicated than above (elim-loop). The reason is that the\n-- computation rule for \"base\" does not hold definitionally.\n\nCircle :\n ∀ {e⁺} →\n (∀ {a p} → P.Equality-with-paths a p e⁺) →\n (p : Level) → Type (lsuc p)\nCircle eq p =\n ∃ λ (𝕊¹ : Type) →\n ∃ λ (base : 𝕊¹) →\n ∃ λ (loop : base ≡.≡ base) →\n (P : 𝕊¹ → Type p)\n (b : P base)\n (ℓ : ≡.subst P loop b ≡.≡ b) →\n ∃ λ (elim : (x : 𝕊¹) → P x) →\n ∃ λ (elim-base : elim base ≡.≡ b) →\n ≡.subst (λ b → ≡.subst P loop b ≡.≡ b)\n elim-base\n (≡.dcong elim loop)\n ≡.≡\n ℓ\n where\n module ≡ = P.Derived-definitions-and-properties eq\n\n-- A circle defined for paths (P.equality-with-J) is equivalent to one\n-- defined for eq.\n\nCircle≃Circle : Circle P.equality-with-paths p ≃ Circle eq p\nCircle≃Circle =\n ∃-cong λ _ →\n ∃-cong λ _ →\n Σ-cong (inverse ≡↔≡) λ loop →\n ∀-cong ext λ P →\n ∀-cong ext λ b →\n Π-cong-contra ext subst≡↔subst≡ λ ℓ →\n ∃-cong λ f →\n Σ-cong (inverse ≡↔≡) λ f-base →\n let lemma = P.elim¹\n (λ eq → _↔_.from subst≡↔subst≡\n (P.subst\n (λ b → P.subst P loop b P.≡ b)\n eq\n (P.dcong f loop)) ≡\n P.subst\n (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b)\n eq\n (_↔_.from subst≡↔subst≡ (P.dcong f loop)))\n (_↔_.from subst≡↔subst≡\n (P.subst\n (λ b → P.subst P loop b P.≡ b)\n P.refl\n (P.dcong f loop)) ≡⟨ cong (_↔_.from subst≡↔subst≡) $ _↔_.from ≡↔≡ $\n P.subst-refl (λ b → P.subst P loop b P.≡ b) _ ⟩\n\n _↔_.from subst≡↔subst≡ (P.dcong f loop) ≡⟨ sym $ _↔_.from ≡↔≡ $\n P.subst-refl (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b) _ ⟩∎\n P.subst\n (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b)\n P.refl\n (_↔_.from subst≡↔subst≡ (P.dcong f loop)) ∎)\n _\n in\n P.subst\n (λ b → P.subst P loop b P.≡ b)\n f-base\n (P.dcong f loop) P.≡\n _↔_.to subst≡↔subst≡ ℓ ↔⟨ ≡↔≡ F.∘ inverse (from≡↔≡to (Eq.↔⇒≃ subst≡↔subst≡)) F.∘ inverse ≡↔≡ ⟩\n\n _↔_.from subst≡↔subst≡\n (P.subst\n (λ b → P.subst P loop b P.≡ b)\n f-base\n (P.dcong f loop)) P.≡\n ℓ ↝⟨ ≡⇒↝ _ (cong (P._≡ _) lemma) ⟩\n\n P.subst\n (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b)\n f-base\n (_↔_.from subst≡↔subst≡ (P.dcong f loop)) P.≡\n ℓ ↝⟨ ≡⇒↝ _ $ cong (λ eq → P.subst (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b) f-base eq P.≡ ℓ) $\n _↔_.from-to (inverse subst≡↔subst≡) dcong≡dcong ⟩\n P.subst\n (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b)\n f-base\n (dcong f (_↔_.from ≡↔≡ loop)) P.≡\n ℓ ↔⟨ inverse subst≡↔subst≡ ⟩□\n\n subst\n (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b)\n (_↔_.from ≡↔≡ f-base)\n (dcong f (_↔_.from ≡↔≡ loop)) ≡\n ℓ □\n\n-- An implemention of the circle for paths (P.equality-with-paths).\n\ncircleᴾ : Circle P.equality-with-paths p\ncircleᴾ =\n 𝕊¹\n , base\n , loopᴾ\n , λ P b ℓ →\n let elim = elimᴾ P b (PI.subst≡→[]≡ {B = P} ℓ)\n in\n elim\n , P.refl\n , (P.subst (λ b → P.subst P loopᴾ b P.≡ b) P.refl\n (P.dcong elim loopᴾ) P.≡⟨ P.subst-refl (λ b → P.subst P loopᴾ b P.≡ b) _ ⟩\n\n P.dcong elim loopᴾ P.≡⟨ PI.dcong-subst≡→[]≡ {f = elim} {eq₂ = ℓ} P.refl ⟩∎\n\n ℓ ∎)\n\n-- An implementation of the circle for eq.\n\ncircle : Circle eq p\ncircle = _≃_.to Circle≃Circle circleᴾ\n\n-- The latter implementation computes in the right way for \"base\".\n\n_ :\n let _ , base′ , _ , elim′ = circle {p = p} in\n ∀ {P b ℓ} →\n proj₁ (elim′ P b ℓ) base′ ≡ b\n_ = refl _\n\n-- The usual computation rule for \"loop\" can be derived.\n\nelim-loop-circle :\n let _ , _ , loop′ , elim′ = circle {p = p} in\n ∀ {P b ℓ} →\n dcong (proj₁ (elim′ P b ℓ)) loop′ ≡ ℓ\nelim-loop-circle {P = P} {b = b} {ℓ = ℓ} =\n let _ , _ , loop′ , elim′ = circle\n elim″ , elim″-base , elim″-loop = elim′ P b ℓ\n\n lemma =\n refl _ ≡⟨ sym from-≡↔≡-refl ⟩\n _↔_.from ≡↔≡ P.refl ≡⟨⟩\n elim″-base ∎\n in\n dcong elim″ loop′ ≡⟨ sym $ subst-refl _ _ ⟩\n subst (λ b → subst P loop′ b ≡ b) (refl _) (dcong elim″ loop′) ≡⟨ cong (λ eq → subst (λ b → subst P loop′ b ≡ b) eq (dcong elim″ loop′)) lemma ⟩\n subst (λ b → subst P loop′ b ≡ b) elim″-base (dcong elim″ loop′) ≡⟨ elim″-loop ⟩∎\n ℓ ∎\n\n-- An alternative to Circle≃Circle that does not give the \"right\"\n-- computational behaviour for circle′ below.\n\nCircle≃Circle′ : Circle P.equality-with-paths p ≃ Circle eq p\nCircle≃Circle′ =\n ∃-cong λ _ →\n ∃-cong λ _ →\n Σ-cong (inverse ≡↔≡) λ loop →\n ∀-cong ext λ P →\n ∀-cong ext λ b →\n Π-cong ext (inverse subst≡↔subst≡) λ ℓ →\n ∃-cong λ f →\n Σ-cong (inverse ≡↔≡) λ f-base →\n let lemma = P.elim¹\n (λ eq → _↔_.from subst≡↔subst≡\n (P.subst\n (λ b → P.subst P loop b P.≡ b)\n eq\n (P.dcong f loop)) ≡\n P.subst\n (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b)\n eq\n (_↔_.from subst≡↔subst≡ (P.dcong f loop)))\n (_↔_.from subst≡↔subst≡\n (P.subst\n (λ b → P.subst P loop b P.≡ b)\n P.refl\n (P.dcong f loop)) ≡⟨ cong (_↔_.from subst≡↔subst≡) $ _↔_.from ≡↔≡ $\n P.subst-refl (λ b → P.subst P loop b P.≡ b) _ ⟩\n\n _↔_.from subst≡↔subst≡ (P.dcong f loop) ≡⟨ sym $ _↔_.from ≡↔≡ $\n P.subst-refl (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b) _ ⟩∎\n P.subst\n (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b)\n P.refl\n (_↔_.from subst≡↔subst≡ (P.dcong f loop)) ∎)\n _\n in\n P.subst\n (λ b → P.subst P loop b P.≡ b)\n f-base\n (P.dcong f loop) P.≡\n ℓ ↔⟨ ≡↔≡ F.∘ from-isomorphism (inverse $ Eq.≃-≡ $ Eq.↔⇒≃ $ inverse subst≡↔subst≡) F.∘ inverse ≡↔≡ ⟩\n\n _↔_.from subst≡↔subst≡\n (P.subst\n (λ b → P.subst P loop b P.≡ b)\n f-base\n (P.dcong f loop)) P.≡\n _↔_.from subst≡↔subst≡ ℓ ↝⟨ ≡⇒↝ _ (cong (P._≡ _↔_.from subst≡↔subst≡ ℓ) lemma) ⟩\n\n P.subst\n (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b)\n f-base\n (_↔_.from subst≡↔subst≡ (P.dcong f loop)) P.≡\n _↔_.from subst≡↔subst≡ ℓ ↝⟨ ≡⇒↝ _ $ cong (λ eq → P.subst (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b) f-base eq P.≡ _↔_.from subst≡↔subst≡ ℓ) $\n _↔_.from-to (inverse subst≡↔subst≡) dcong≡dcong ⟩\n P.subst\n (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b)\n f-base\n (dcong f (_↔_.from ≡↔≡ loop)) P.≡\n _↔_.from subst≡↔subst≡ ℓ ↔⟨ inverse subst≡↔subst≡ ⟩□\n\n subst\n (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b)\n (_↔_.from ≡↔≡ f-base)\n (dcong f (_↔_.from ≡↔≡ loop)) ≡\n _↔_.from subst≡↔subst≡ ℓ □\n\n-- An alternative implementation of the circle for eq.\n\ncircle′ : Circle eq p\ncircle′ = _≃_.to Circle≃Circle′ circleᴾ\n\n-- This implementation does not compute in the right way for \"base\".\n-- The following code is (at the time of writing) rejected by Agda.\n\n-- _ :\n-- let _ , base′ , _ , elim′ = circle′ {p = p} in\n-- ∀ {P b ℓ} →\n-- proj₁ (elim′ P b ℓ) base′ ≡ b\n-- _ = refl _\n", "meta": {"hexsha": "da10986f4dd94fc15ac1bedc512bee610b289fa0", "size": 37315, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Circle.agda", "max_stars_repo_name": "nad/equality", "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_issues_repo_path": "src/Circle.agda", "max_issues_repo_name": "nad/equality", "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Circle.agda", "max_forks_repo_name": "nad/equality", "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.1934493347, "max_line_length": 166, "alphanum_fraction": 0.4536781455, "num_tokens": 13443, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8438951182587158, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.6117144874364695}} {"text": "module Issue826-2 where\n\nopen import Common.Coinduction\n\ndata _≡_ {A : Set} (x y : A) : Set where\n\ndata D : Set where\n c : ∞ D → D\n\ndelay : D → ∞ D\ndelay x = ♯ x\n\ndata P : D → Set where\n o : (x : ∞ D) → P (♭ x) → P (c x)\n\npostulate\n h : (x : D) → P x → P x\n\nf : (x : D) → P (c (delay x)) → P x\nf x (o .(delay x) p) = h x p\n\ng : (x : D) → P x → P (c (delay x))\ng x p = h (c (delay x)) (o (delay x) p)\n\npostulate\n bar : (x : ∞ D) (p : P (♭ x)) →\n h (c x) (o x (h (♭ x) p)) ≡ o x p\n\nfoo : (x : D) (p : P (c (delay x))) → g x (f x p) ≡ p\nfoo x (o .(delay x) p) = goal\n where\n x′ = _\n\n goal : _ ≡ o x′ p\n goal = bar x′ p\n\n-- The following error message seems to indicate that an expression is\n-- not forced properly:\n--\n-- Bug.agda:30,26-30\n-- ♭ (.Bug.♯-0 x) != x of type D\n-- when checking that the expression goal has type\n-- g x (f x (o (.Bug.♯-0 x) p)) ≡ o (.Bug.♯-0 x) p\n--\n-- Thus it seems as if this problem affects plain type-checking as\n-- well.\n", "meta": {"hexsha": "0ef9241cac1dfc31468ddf49de11acb4d652493c", "size": 973, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue826-2.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Succeed/Issue826-2.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_forks_repo_path": "test/Succeed/Issue826-2.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 20.7021276596, "max_line_length": 70, "alphanum_fraction": 0.5097636177, "num_tokens": 417, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951104066293, "lm_q2_score": 0.7248702702332475, "lm_q1q2_score": 0.6117144767289696}} {"text": "-- Andreas, 2012-02-24 example by Ramana Kumar\n{-# OPTIONS --sized-types #-}\n-- {-# OPTIONS --show-implicit -v tc.size.solve:20 -v tc.conv.size:15 #-}\nmodule SizeInconsistentMeta4 where\n\nopen import Data.Nat using (ℕ;zero;suc) renaming (_<_ to _N<_)\nopen import Data.Product using (_,_;_×_)\nopen import Data.List using (List)\nopen import Relation.Binary using (Rel;_Respects₂_;Transitive;IsEquivalence)\nopen import Relation.Binary.Product.StrictLex using (×-Lex;×-transitive)\nopen import Relation.Binary.List.StrictLex using (Lex-<) renaming (transitive to Lex<-trans)\n\nopen import Relation.Binary.PropositionalEquality as PropEq using (_≡_)\n\nimport Level\nopen import Size using (Size;↑_)\n\n-- keeping the definition of Vec for the positivity check\ninfixr 5 _∷_\ndata Vec {a} (A : Set a) : ℕ → Set a where\n [] : Vec A zero\n _∷_ : ∀ {n} (x : A) (xs : Vec A n) → Vec A (suc n)\n\n{- produces different error\ndata Lex-< {A : _} (_≈_ _<_ : Rel A Level.zero) : Rel (List A) Level.zero where\npostulate\n Lex<-trans : ∀ {P _≈_ _<_} →\n IsEquivalence _≈_ → _<_ Respects₂ _≈_ → Transitive _<_ →\n Transitive (Lex-< _≈_ _<_)\n-}\n\npostulate\n N<-trans : Transitive _N<_\n -- Vec : ∀ {a} (A : Set a) → ℕ → Set a\n Vec→List : ∀ {a n} {A : Set a} → Vec A n → List A\n\ndata Type : {z : Size} → Set where\n TyApp : {z : Size} (n : ℕ) → (as : Vec (Type {z}) n) → Type {↑ z}\n\ninfix 4 _<_\ndata _<_ : {z : Size} → Rel (Type {z}) Level.zero where\n TyApp Dec (x ≡ y)\n\nopen Eq {{...}} public\n\nrecord EqB (A : Set) : Set where\n field\n _≣_ : (x y : A) -> Bool\n\n decCase_of_default_ : ∀ {b} {B : Set b} -> A -> List (A × B) -> B -> B\n decCase a of [] default d = d\n decCase a of x ∷ xs default d = if a ≣ proj₁ x then proj₂ x else (decCase a of xs default d)\n\nopen EqB {{...}} public\n\nEq→EqB : ∀ {A} -> {{_ : Eq A}} -> EqB A\nEq→EqB = record { _≣_ = λ x y -> ⌊ x ≟ y ⌋ }\n", "meta": {"hexsha": "63dcc46b069c2eee28f1e7f7053b3dfc4752eb28", "size": 726, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "stdlib-exts/Class/Equality.agda", "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 35, "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_issues_repo_path": "stdlib-exts/Class/Equality.agda", "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 10, "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_forks_repo_path": "stdlib-exts/Class/Equality.agda", "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "avg_line_length": 25.9285714286, "max_line_length": 94, "alphanum_fraction": 0.6212121212, "num_tokens": 253, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8740772253241803, "lm_q2_score": 0.6992544335934766, "lm_q1q2_score": 0.6112023751110174}} {"text": "module Inductive.Examples.Product where\n\nopen import Inductive\nopen import Tuple\n\nopen import Data.Fin\nopen import Data.Product hiding (_×_; <_,_>)\nopen import Data.List\nopen import Data.Vec\n\n_×_ : Set → Set → Set\nA × B = Inductive (((A ∷ (B ∷ [])) , []) ∷ [])\n\n<_,_> : {A B : Set} → A → B → A × B\n< a , b > = construct zero (a ∷ (b ∷ [])) []\n\nfst : {A B : Set} → A × B → A\nfst = rec ((λ a b → a) ∷ [])\n\nsnd : {A B : Set} → A × B → B\nsnd = rec ((λ a b → b) ∷ [])\n", "meta": {"hexsha": "3b0e2d6618a04bf2b38aa70b60e4fa05cd38d433", "size": 463, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Inductive/Examples/Product.agda", "max_stars_repo_name": "mr-ohman/general-induction", "max_stars_repo_head_hexsha": "dc157acda597a2c758e82b5637e4fd6717ccec3f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Inductive/Examples/Product.agda", "max_issues_repo_name": "mr-ohman/general-induction", "max_issues_repo_head_hexsha": "dc157acda597a2c758e82b5637e4fd6717ccec3f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Inductive/Examples/Product.agda", "max_forks_repo_name": "mr-ohman/general-induction", "max_forks_repo_head_hexsha": "dc157acda597a2c758e82b5637e4fd6717ccec3f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.0454545455, "max_line_length": 46, "alphanum_fraction": 0.5313174946, "num_tokens": 171, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8740772286044095, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.6112023609702646}} {"text": "{-# OPTIONS --without-K #-}\nmodule NTypes.Coproduct where\n\nopen import NTypes\nopen import PathOperations\nopen import PathStructure.Coproduct\nopen import Types\n\n⊎-isSet : ∀ {A : Set} {B : Set} →\n isSet A → isSet B → isSet (A ⊎ B)\n⊎-isSet {A = A} {B = B} A-set B-set x y p q =\n case (λ x → (y : A ⊎ B) (p q : x ≡ y) → p ≡ q)\n (λ a y p q → case\n (λ y → (p q : inl a ≡ y) → p ≡ q)\n (λ a′ p q\n → split-eq p ⁻¹\n · ap (ap inl)\n (A-set _ _\n (lower (tr (F (inl a)) p (lift refl)))\n (lower (tr (F (inl a)) q (lift refl)))\n )\n · split-eq q\n )\n (λ _ p q → 0-elim\n (lower (split-path p)))\n y p q)\n (λ b y p q → case\n (λ y → (p q : inr b ≡ y) → p ≡ q)\n (λ _ p q → 0-elim\n (lower (split-path p)))\n (λ b′ p q\n → split-eq p ⁻¹\n · ap (ap inr)\n (B-set _ _\n (lower (tr (F (inr b)) p (lift refl)))\n (lower (tr (F (inr b)) q (lift refl)))\n )\n · split-eq q\n )\n y p q)\n x y p q\n where\n split-eq : {x y : A ⊎ B} → _\n split-eq {x = x} {y = y} =\n π₂ (π₂ (π₂ (split-merge-eq {x = x} {y = y})))\n", "meta": {"hexsha": "b4120f96cc779f36814a12aedc2f87eeb3553842", "size": 1117, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/NTypes/Coproduct.agda", "max_stars_repo_name": "vituscze/HoTT-lectures", "max_stars_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/NTypes/Coproduct.agda", "max_issues_repo_name": "vituscze/HoTT-lectures", "max_issues_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/NTypes/Coproduct.agda", "max_forks_repo_name": "vituscze/HoTT-lectures", "max_forks_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.2826086957, "max_line_length": 49, "alphanum_fraction": 0.4440465533, "num_tokens": 463, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8740772253241803, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.6112023586765498}} {"text": "module _ where\n\nopen import Agda.Builtin.Equality\n\npostulate\n A : Set\n P : A → Set\n\ndata Id (A : Set) : Set where\n id : A → Id A\n\ndata Flat (@♭ A : Set) : Set where\n con : (@♭ x : A) → Flat A\n\ncounit : {@♭ A : Set} → Flat A → A\ncounit (con x) = x\n\ntest2 : (@♭ x : Id A) → Flat A\ntest2 (id x) = con x\n\ntest3 : (@♭ x : A) (@♭ y : A) (@♭ p : x ≡ y) → P x → P y\ntest3 x y refl p = p\n\ntest4 : (@♭ x : A) (@♭ y : A) → Flat (x ≡ y) → P x → P y\ntest4 x y (con refl) p = p\n\ntest6 : (@♭ x y : A) → (eq : con x ≡ con y) → P x → P y\ntest6 x .x refl p = p\n", "meta": {"hexsha": "5ad1c8a05c63c5a243f80e74b028fcc6a5209eb7", "size": 547, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/FlatSplit.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/FlatSplit.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/FlatSplit.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 18.8620689655, "max_line_length": 56, "alphanum_fraction": 0.4844606947, "num_tokens": 252, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.918480252950991, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.6111664583140339}} {"text": "{-# OPTIONS --without-K --exact-split #-}\n\nmodule abelian-subgroups where\n\nimport abelian-groups\nimport subgroups\nopen abelian-groups public\nopen subgroups public\n\n{- Subsets of abelian groups -}\n\nsubset-Ab :\n (l : Level) {l1 : Level} (A : Ab l1) → UU ((lsuc l) ⊔ l1)\nsubset-Ab l A = subset-Group l (group-Ab A)\n\nis-set-subset-Ab :\n (l : Level) {l1 : Level} (A : Ab l1) → is-set (subset-Ab l A)\nis-set-subset-Ab l A = is-set-subset-Group l (group-Ab A)\n\n{- Defining subgroups -}\n\ncontains-zero-subset-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : subset-Ab l2 A) → UU l2\ncontains-zero-subset-Ab A = contains-unit-subset-Group (group-Ab A)\n\nis-prop-contains-zero-subset-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : subset-Ab l2 A) →\n is-prop (contains-zero-subset-Ab A P)\nis-prop-contains-zero-subset-Ab A =\n is-prop-contains-unit-subset-Group (group-Ab A)\n\nclosed-under-add-subset-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : subset-Ab l2 A) → UU (l1 ⊔ l2)\nclosed-under-add-subset-Ab A =\n closed-under-mul-subset-Group (group-Ab A)\n\nis-prop-closed-under-add-subset-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : subset-Ab l2 A) →\n is-prop (closed-under-add-subset-Ab A P)\nis-prop-closed-under-add-subset-Ab A =\n is-prop-closed-under-mul-subset-Group (group-Ab A)\n\nclosed-under-neg-subset-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : subset-Ab l2 A) → UU (l1 ⊔ l2)\nclosed-under-neg-subset-Ab A =\n closed-under-inv-subset-Group (group-Ab A)\n\nis-prop-closed-under-neg-subset-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : subset-Ab l2 A) →\n is-prop (closed-under-neg-subset-Ab A P)\nis-prop-closed-under-neg-subset-Ab A =\n is-prop-closed-under-inv-subset-Group (group-Ab A)\n \nis-subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : subset-Ab l2 A) → UU (l1 ⊔ l2)\nis-subgroup-Ab A = is-subgroup-Group (group-Ab A)\n\nis-prop-is-subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : subset-Ab l2 A) →\n is-prop (is-subgroup-Ab A P)\nis-prop-is-subgroup-Ab A = is-prop-is-subgroup-Group (group-Ab A)\n\n{- Introducing the type of all subgroups of a group G -}\n\nSubgroup-Ab :\n (l : Level) {l1 : Level} (A : Ab l1) → UU ((lsuc l) ⊔ l1)\nSubgroup-Ab l A = Subgroup l (group-Ab A)\n\nsubset-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) →\n ( Subgroup-Ab l2 A) → ( subset-Ab l2 A)\nsubset-Subgroup-Ab A = subset-Subgroup (group-Ab A)\n\nis-emb-subset-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) → is-emb (subset-Subgroup-Ab {l2 = l2} A)\nis-emb-subset-Subgroup-Ab A = is-emb-subset-Subgroup (group-Ab A)\n\ntype-subset-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) →\n (type-Ab A → UU l2)\ntype-subset-Subgroup-Ab A = type-subset-Subgroup (group-Ab A)\n\nis-prop-type-subset-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) →\n (x : type-Ab A) → is-prop (type-subset-Subgroup-Ab A P x)\nis-prop-type-subset-Subgroup-Ab A =\n is-prop-type-subset-Subgroup (group-Ab A)\n\nis-subgroup-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) →\n is-subgroup-Ab A (subset-Subgroup-Ab A P)\nis-subgroup-Subgroup-Ab A = is-subgroup-Subgroup (group-Ab A)\n\ncontains-zero-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) →\n contains-zero-subset-Ab A (subset-Subgroup-Ab A P)\ncontains-zero-Subgroup-Ab A = contains-unit-Subgroup (group-Ab A)\n\nclosed-under-add-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) →\n closed-under-add-subset-Ab A (subset-Subgroup-Ab A P)\nclosed-under-add-Subgroup-Ab A = closed-under-mul-Subgroup (group-Ab A)\n\nclosed-under-neg-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) →\n closed-under-neg-subset-Ab A (subset-Subgroup-Ab A P)\nclosed-under-neg-Subgroup-Ab A = closed-under-inv-Subgroup (group-Ab A)\n\n{- Given a subgroup of an abelian group, we construct an abelian group -}\n\ntype-ab-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → UU (l1 ⊔ l2)\ntype-ab-Subgroup-Ab A = type-group-Subgroup (group-Ab A)\n\nincl-ab-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) →\n type-ab-Subgroup-Ab A P → type-Ab A\nincl-ab-Subgroup-Ab A = incl-group-Subgroup (group-Ab A)\n\nis-emb-incl-ab-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) →\n is-emb (incl-ab-Subgroup-Ab A P)\nis-emb-incl-ab-Subgroup-Ab A = is-emb-incl-group-Subgroup (group-Ab A)\n\neq-subgroup-ab-eq-ab :\n {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) →\n {x y : type-ab-Subgroup-Ab A P} →\n Id (incl-ab-Subgroup-Ab A P x) (incl-ab-Subgroup-Ab A P y) → Id x y\neq-subgroup-ab-eq-ab A =\n eq-subgroup-eq-group (group-Ab A)\n\nset-ab-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) → Subgroup-Ab l2 A → UU-Set (l1 ⊔ l2)\nset-ab-Subgroup-Ab A = set-group-Subgroup (group-Ab A)\n\nzero-ab-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → type-ab-Subgroup-Ab A P\nzero-ab-Subgroup-Ab A = unit-group-Subgroup (group-Ab A)\n\nadd-ab-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) →\n ( x y : type-ab-Subgroup-Ab A P) → type-ab-Subgroup-Ab A P\nadd-ab-Subgroup-Ab A = mul-group-Subgroup (group-Ab A)\n\nneg-ab-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) →\n type-ab-Subgroup-Ab A P → type-ab-Subgroup-Ab A P\nneg-ab-Subgroup-Ab A = inv-group-Subgroup (group-Ab A)\n\nis-associative-add-ab-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) →\n ( x y z : type-ab-Subgroup-Ab A P) →\n Id (add-ab-Subgroup-Ab A P (add-ab-Subgroup-Ab A P x y) z)\n (add-ab-Subgroup-Ab A P x (add-ab-Subgroup-Ab A P y z))\nis-associative-add-ab-Subgroup-Ab A =\n is-associative-mul-group-Subgroup (group-Ab A)\n\nleft-zero-law-ab-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) →\n ( x : type-ab-Subgroup-Ab A P) →\n Id (add-ab-Subgroup-Ab A P (zero-ab-Subgroup-Ab A P) x) x\nleft-zero-law-ab-Subgroup-Ab A =\n left-unit-law-group-Subgroup (group-Ab A)\n\nright-zero-law-ab-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) →\n ( x : type-ab-Subgroup-Ab A P) →\n Id (add-ab-Subgroup-Ab A P x (zero-ab-Subgroup-Ab A P)) x\nright-zero-law-ab-Subgroup-Ab A =\n right-unit-law-group-Subgroup (group-Ab A)\n\nleft-neg-law-ab-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) →\n ( x : type-ab-Subgroup-Ab A P) →\n Id ( add-ab-Subgroup-Ab A P (neg-ab-Subgroup-Ab A P x) x)\n ( zero-ab-Subgroup-Ab A P)\nleft-neg-law-ab-Subgroup-Ab A =\n left-inverse-law-group-Subgroup (group-Ab A)\n\nright-neg-law-ab-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) →\n ( x : type-ab-Subgroup-Ab A P) →\n Id ( add-ab-Subgroup-Ab A P x (neg-ab-Subgroup-Ab A P x))\n ( zero-ab-Subgroup-Ab A P)\nright-neg-law-ab-Subgroup-Ab A = right-inverse-law-group-Subgroup (group-Ab A)\n\nis-commutative-add-ab-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) →\n ( x y : type-ab-Subgroup-Ab A P) →\n Id ( add-ab-Subgroup-Ab A P x y) (add-ab-Subgroup-Ab A P y x)\nis-commutative-add-ab-Subgroup-Ab A P (pair x p) (pair y q) =\n eq-subgroup-ab-eq-ab A P (is-commutative-add-Ab A x y)\n\nab-Subgroup-Ab :\n {l1 l2 : Level} (A : Ab l1) → Subgroup-Ab l2 A → Ab (l1 ⊔ l2)\nab-Subgroup-Ab A P =\n pair\n (group-Subgroup (group-Ab A) P) (is-commutative-add-ab-Subgroup-Ab A P)\n\n{- We show that the inclusion from ab-Subgroup-Ab A P → A is a group \n homomorphism -}\n\npreserves-add-incl-ab-Subgroup-Ab :\n { l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) →\n preserves-add (ab-Subgroup-Ab A P) A (incl-ab-Subgroup-Ab A P)\npreserves-add-incl-ab-Subgroup-Ab A =\n preserves-mul-incl-group-Subgroup (group-Ab A)\n\nhom-ab-Subgroup-Ab :\n { l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) →\n hom-Ab (ab-Subgroup-Ab A P) A\nhom-ab-Subgroup-Ab A = hom-group-Subgroup (group-Ab A)\n\n{- We define another type of subgroups of A as the type of group inclusions -}\n\nemb-Ab :\n { l1 l2 : Level} (A : Ab l1) (B : Ab l2) → UU (l1 ⊔ l2)\nemb-Ab A B = emb-Group (group-Ab A) (group-Ab B)\n\nemb-Ab-Slice :\n (l : Level) {l1 : Level} (A : Ab l1) → UU ((lsuc l) ⊔ l1)\nemb-Ab-Slice l A = emb-Group-Slice l (group-Ab A)\n\nemb-ab-slice-Subgroup-Ab :\n { l1 l2 : Level} (A : Ab l1) →\n Subgroup-Ab l2 A → emb-Ab-Slice (l1 ⊔ l2) A\nemb-ab-slice-Subgroup-Ab A = emb-group-slice-Subgroup (group-Ab A)\n", "meta": {"hexsha": "53dcabfb8484fe79464ad82826ff837d764e9e5c", "size": 8120, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/abelian-subgroups.agda", "max_stars_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_stars_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 333, "max_stars_repo_stars_event_min_datetime": "2018-09-26T08:33:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:50:15.000Z", "max_issues_repo_path": "Agda/abelian-subgroups.agda", "max_issues_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_issues_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2019-06-18T04:16:04.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-16T15:27:01.000Z", "max_forks_repo_path": "Agda/abelian-subgroups.agda", "max_forks_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_forks_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 30, "max_forks_repo_forks_event_min_datetime": "2018-09-26T09:08:57.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-16T00:33:50.000Z", "avg_line_length": 35.6140350877, "max_line_length": 78, "alphanum_fraction": 0.6455665025, "num_tokens": 3273, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.828938825225204, "lm_q2_score": 0.7371581568543044, "lm_q1q2_score": 0.6110590165479838}} {"text": "module SystemF.WellTyped where\n\nopen import Prelude hiding (id; erase)\n\nopen import SystemF.Syntax public\nopen import SystemF.Substitutions\nopen import Data.Vec hiding ([_])\nopen import Data.Vec.Properties\nopen import Data.Product\n\ninfix 4 _⊢_∈_\ndata _⊢_∈_ {ν n} (Γ : Ctx ν n) : Term ν n → Type ν → Set where\n var : (x : Fin n) → Γ ⊢ var x ∈ lookup x Γ\n Λ : ∀ {t a} → (ctx-weaken Γ) ⊢ t ∈ a → Γ ⊢ Λ t ∈ ∀' a\n λ' : ∀ {t b} → (a : Type ν) → a ∷ Γ ⊢ t ∈ b → Γ ⊢ λ' a t ∈ a →' b\n _[_] : ∀ {t a} → Γ ⊢ t ∈ ∀' a → (b : Type ν) → Γ ⊢ t [ b ] ∈ a tp[/tp b ]\n _·_ : ∀ {f t a b} → Γ ⊢ f ∈ (a →' b) → Γ ⊢ t ∈ a → Γ ⊢ f · t ∈ b\n\n_⊢_∉_ : ∀ {ν n} → (Γ : Ctx ν n) → Term ν n → Type ν → Set\n_⊢_∉_ Γ t τ = ¬ Γ ⊢ t ∈ τ\n\nerase : ∀ {ν n} {Γ : Ctx ν n} {t τ} → Γ ⊢ t ∈ τ → Term ν n\nerase (var x) = var x\nerase (Λ {t} x) = Λ t\nerase (λ' {t} a x) = λ' a t\nerase (_[_] {t} x b) = t\nerase (_·_ {f} x x₁) = f\n\n⊢f·a-inversion : ∀ {ν n f t b} {Γ : Ctx ν n} → Γ ⊢ f · t ∈ b →\n ∃ λ a → Γ ⊢ f ∈ a →' b × Γ ⊢ t ∈ a\n⊢f·a-inversion (_·_ f∈a→b t∈a) = , (f∈a→b , t∈a)\n\n⊢tc[a]-inversion : ∀ {ν n tc a' b} {Γ : Ctx ν n} → Γ ⊢ tc [ b ] ∈ a' → ∃ λ a → Γ ⊢ tc ∈ ∀' a\n⊢tc[a]-inversion (_[_] tc∈∀'a b) = , tc∈∀'a\n\nunique-type : ∀ {ν n} {Γ : Ctx ν n} {t τ τ'} → Γ ⊢ t ∈ τ → Γ ⊢ t ∈ τ' → τ ≡ τ'\nunique-type (var x) (var .x) = refl\nunique-type (Λ l) (Λ r) = cong ∀' (unique-type l r)\nunique-type (λ' a l) (λ' .a r) = cong (λ b → a →' b) (unique-type l r)\nunique-type (l [ b ]) (r [ .b ]) = cong (λ{ (∀' fa) → fa tp[/tp b ]; a → a}) (unique-type l r)\nunique-type (f · e) (f' · e') = cong (λ{ (a →' b) → b; a → a }) (unique-type f f')\n\nunique-type′ : ∀ {ν n} {Γ : Ctx ν n} {t τ τ'} → Γ ⊢ t ∈ τ → τ ≢ τ' → Γ ⊢ t ∉ τ'\nunique-type′ ⊢t∈τ neq ⊢t∈τ' = neq $ unique-type ⊢t∈τ ⊢t∈τ'\n\n-- Collections of typing derivations for well-typed terms.\ndata _⊢ⁿ_∈_ {m n} (Γ : Ctx n m) :\n ∀ {k} → Vec (Term n m) k → Vec (Type n) k → Set where\n [] : Γ ⊢ⁿ [] ∈ []\n _∷_ : ∀ {t a k} {ts : Vec (Term n m) k} {as : Vec (Type n) k} →\n Γ ⊢ t ∈ a → Γ ⊢ⁿ ts ∈ as → Γ ⊢ⁿ t ∷ ts ∈ (a ∷ as)\n\n-- Lookup a well-typed term in a collection thereof.\nlookup-⊢ : ∀ {m n k} {Γ : Ctx n m} {ts : Vec (Term n m) k}\n {as : Vec (Type n) k} →\n (x : Fin k) → Γ ⊢ⁿ ts ∈ as → Γ ⊢ lookup x ts ∈ lookup x as\nlookup-⊢ zero (⊢t ∷ ⊢ts) = ⊢t\nlookup-⊢ (suc x) (⊢t ∷ ⊢ts) = lookup-⊢ x ⊢ts\n", "meta": {"hexsha": "97d86f080a0ffeb1144dfc28d4c98e103501b665", "size": 2354, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/SystemF/WellTyped.agda", "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_issues_repo_path": "src/SystemF/WellTyped.agda", "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/SystemF/WellTyped.agda", "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.8983050847, "max_line_length": 94, "alphanum_fraction": 0.4668649108, "num_tokens": 1163, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289387998695209, "lm_q2_score": 0.7371581684030624, "lm_q1q2_score": 0.6110590074300487}} {"text": "{-# OPTIONS --safe --experimental-lossy-unification #-}\nmodule Cubical.Algebra.CommRing.Instances.Polynomials.MultivariatePoly-notationZ where\n\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Data.Nat\nopen import Cubical.Data.FinData\n\nopen import Cubical.Relation.Nullary\n\nopen import Cubical.Algebra.Ring\nopen import Cubical.Algebra.CommRing\nopen import Cubical.Algebra.CommRing.FGIdeal\nopen import Cubical.Algebra.CommRing.QuotientRing\nopen import Cubical.Algebra.CommRing.Instances.Int\n\nopen import Cubical.Algebra.CommRing.Instances.Polynomials.MultivariatePoly\n renaming (PolyCommRing to A[X1,···,Xn] ; Poly to A[x1,···,xn])\nopen import Cubical.Algebra.CommRing.Instances.Polynomials.MultivariatePoly-Quotient\n\n\n\n-- Notations for ℤ polynomial rings\n\nℤ[X] : CommRing ℓ-zero\nℤ[X] = A[X1,···,Xn] ℤCommRing 1\n\nℤ[x] : Type ℓ-zero\nℤ[x] = fst ℤ[X]\n\nℤ[X,Y] : CommRing ℓ-zero\nℤ[X,Y] = A[X1,···,Xn] ℤCommRing 2\n\nℤ[x,y] : Type ℓ-zero\nℤ[x,y] = fst ℤ[X,Y]\n\nℤ[X,Y,Z] : CommRing ℓ-zero\nℤ[X,Y,Z] = A[X1,···,Xn] ℤCommRing 3\n\nℤ[x,y,z] : Type ℓ-zero\nℤ[x,y,z] = fst ℤ[X,Y,Z]\n\nℤ[X1,···,Xn] : (n : ℕ) → CommRing ℓ-zero\nℤ[X1,···,Xn] n = A[X1,···,Xn] ℤCommRing n\n\nℤ[x1,···,xn] : (n : ℕ) → Type ℓ-zero\nℤ[x1,···,xn] n = fst (ℤ[X1,···,Xn] n)\n\n\n\n-- Notation for quotiented ℤ polynomial ring\n\n : FinVec ℤ[x] 1\n = ℤCommRing 1 0 1\n\n : FinVec ℤ[x] 1\n = ℤCommRing 1 0 2\n\n : FinVec ℤ[x] 1\n = ℤCommRing 1 0 3\n\n : (k : ℕ) → FinVec ℤ[x] 1\n k = ℤCommRing 1 0 k\n\nℤ[X]/X : CommRing ℓ-zero\nℤ[X]/X = A[X1,···,Xn]/ ℤCommRing 1 0 1\n\nℤ[x]/x : Type ℓ-zero\nℤ[x]/x = fst ℤ[X]/X\n\nℤ[X]/X² : CommRing ℓ-zero\nℤ[X]/X² = A[X1,···,Xn]/ ℤCommRing 1 0 2\n\nℤ[x]/x² : Type ℓ-zero\nℤ[x]/x² = fst ℤ[X]/X²\n\nℤ[X]/X³ : CommRing ℓ-zero\nℤ[X]/X³ = A[X1,···,Xn]/ ℤCommRing 1 0 3\n\nℤ[x]/x³ : Type ℓ-zero\nℤ[x]/x³ = fst ℤ[X]/X³\n\nℤ[X1,···,Xn]/ : (n : ℕ) → CommRing ℓ-zero\nℤ[X1,···,Xn]/ n = A[X1,···,Xn]/ ℤCommRing n\n\nℤ[x1,···,xn]/ : (n : ℕ) → Type ℓ-zero\nℤ[x1,···,xn]/ n = fst (ℤ[X1,···,Xn]/ n)\n\n\n-- Warning there is two possible definitions of ℤ[X]\n-- they only holds up to a path\n\nℤ'[X]/X : CommRing ℓ-zero\nℤ'[X]/X = A[X1,···,Xn]/ ℤCommRing 1\n\n-- there is a unification problem that keep pop in up everytime I modify something\n-- equivℤ[X] : ℤ'[X]/X ≡ ℤ[X]/X\n-- equivℤ[X] = cong₂ _/_ refl (cong (λ X → genIdeal (A[X1,···,Xn] ℤCommRing {!!}) X) {!!})\n", "meta": {"hexsha": "edeb3ebf1eefab1f23a3433937ff6c1b8e1ba6d2", "size": 2446, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials/MultivariatePoly-notationZ.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials/MultivariatePoly-notationZ.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials/MultivariatePoly-notationZ.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.7070707071, "max_line_length": 90, "alphanum_fraction": 0.6259198692, "num_tokens": 1155, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289387956435734, "lm_q2_score": 0.7371581684030623, "lm_q1q2_score": 0.6110590043148569}} {"text": "------------------------------------------------------------------------------\n-- Properties of the divisibility relation\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOTC.Data.Nat.Divisibility.NotBy0.PropertiesATP where\n\nopen import FOTC.Base\nopen import FOTC.Base.PropertiesATP\nopen import FOTC.Data.Nat\nopen import FOTC.Data.Nat.Divisibility.NotBy0\nopen import FOTC.Data.Nat.Inequalities\nopen import FOTC.Data.Nat.Inequalities.PropertiesATP\nopen import FOTC.Data.Nat.PropertiesATP\n\n------------------------------------------------------------------------------\n-- Any positive number divides 0.\npostulate S∣0 : ∀ n → succ₁ n ∣ zero\n{-# ATP prove S∣0 #-}\n\n-- 0 doesn't divide any number.\npostulate 0∤x : ∀ {n} → ¬ (zero ∣ n)\n{-# ATP prove 0∤x #-}\n\n-- The divisibility relation is reflexive for positive numbers.\n--\n-- For the proof using the ATPs we added the helper hypothesis\n--\n-- N (succ zero).\npostulate ∣-refl-S-ah : ∀ {n} → N n → N (succ₁ zero) → succ₁ n ∣ succ₁ n\n{-# ATP prove ∣-refl-S-ah *-leftIdentity #-}\n\n∣-refl-S : ∀ {n} → N n → succ₁ n ∣ succ₁ n\n∣-refl-S Nn = ∣-refl-S-ah Nn (nsucc nzero)\n\n-- If x divides y and z then x divides y ∸ z.\npostulate\n x∣y→x∣z→x∣y∸z-helper : ∀ {m n o k k'} → N m → N k → N k' →\n n ≡ k * succ₁ m →\n o ≡ k' * succ₁ m →\n n ∸ o ≡ (k ∸ k') * succ₁ m\n{-# ATP prove x∣y→x∣z→x∣y∸z-helper *∸-leftDistributive #-}\n\nx∣y→x∣z→x∣y∸z : ∀ {m n o} → N m → N n → N o → m ∣ n → m ∣ o → m ∣ n ∸ o\nx∣y→x∣z→x∣y∸z nzero _ _ (0≢0 , _) m∣o = ⊥-elim (0≢0 refl)\nx∣y→x∣z→x∣y∸z (nsucc Nm) Nn No\n (_ , k , Nk , h₁)\n (_ , k' , Nk' , h₂) =\n (λ S≡0 → ⊥-elim (S≢0 S≡0))\n , k ∸ k' , ∸-N Nk Nk' , x∣y→x∣z→x∣y∸z-helper Nm Nk Nk' h₁ h₂\n\n-- If x divides y and z then x divides y + z.\npostulate\n x∣y→x∣z→x∣y+z-helper : ∀ {m n o k k'} → N m → N k → N k' →\n n ≡ k * succ₁ m →\n o ≡ k' * succ₁ m →\n n + o ≡ (k + k') * succ₁ m\n{-# ATP prove x∣y→x∣z→x∣y+z-helper *+-leftDistributive #-}\n\nx∣y→x∣z→x∣y+z : ∀ {m n o} → N m → N n → N o → m ∣ n → m ∣ o → m ∣ n + o\nx∣y→x∣z→x∣y+z nzero _ _ (0≢0 , _) m∣o = ⊥-elim (0≢0 refl)\nx∣y→x∣z→x∣y+z (nsucc Nm) Nn No\n (_ , k , Nk , h₁)\n (_ , k' , Nk' , h₂) =\n (λ S≡0 → ⊥-elim (S≢0 S≡0))\n , k + k' , +-N Nk Nk' , x∣y→x∣z→x∣y+z-helper Nm Nk Nk' h₁ h₂\n\n-- If x divides y and y is positive, then x ≤ y.\npostulate x∣S→x≤S-ah₁ : ∀ {m n} → succ₁ n ≡ zero * succ₁ m → ⊥\n{-# ATP prove x∣S→x≤S-ah₁ #-}\n\n-- Nice proof by the ATP.\npostulate x∣S→x≤S-ah₂ : ∀ {m n o} → N m → N n → N o →\n succ₁ n ≡ succ₁ o * succ₁ m →\n succ₁ m ≤ succ₁ n\n{-# ATP prove x∣S→x≤S-ah₂ x≤x+y *-N #-}\n\nx∣S→x≤S : ∀ {m n} → N m → N n → m ∣ (succ₁ n) → m ≤ succ₁ n\nx∣S→x≤S nzero Nn (0≢0 , _) = ⊥-elim (0≢0 refl)\nx∣S→x≤S (nsucc Nm) Nn (_ , .zero , nzero , Sn≡0*Sm) = ⊥-elim (x∣S→x≤S-ah₁ Sn≡0*Sm)\nx∣S→x≤S (nsucc {m} Nm) Nn (_ , .(succ₁ k) , nsucc {k} Nk , Sn≡Sk*Sm) =\n x∣S→x≤S-ah₂ Nm Nn Nk Sn≡Sk*Sm\n", "meta": {"hexsha": "9169fb48e1123a53df32bf0cea8620ef5a3d9f26", "size": 3258, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/FOTC/Data/Nat/Divisibility/NotBy0/PropertiesATP.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/FOTC/Data/Nat/Divisibility/NotBy0/PropertiesATP.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/FOTC/Data/Nat/Divisibility/NotBy0/PropertiesATP.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 37.4482758621, "max_line_length": 82, "alphanum_fraction": 0.47053407, "num_tokens": 1375, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891392358015, "lm_q2_score": 0.7431680029241321, "lm_q1q2_score": 0.6110246606317817}} {"text": "module Numeral.Natural.Oper.Proofs where\n\nimport Lvl\nopen import Functional\nopen import Logic\nopen import Logic.Propositional\nopen import Logic.Predicate\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.Induction\nopen import Relator.Equals\nopen import Relator.Equals.Proofs\nopen import Structure.Function\nopen import Structure.Function.Domain\nopen import Structure.Operator\nopen import Structure.Operator.Proofs.Util\nopen import Structure.Operator.Properties\nimport Structure.Operator.Names as Names\nopen import Structure.Relator.Properties\nopen import Syntax.Transitivity\n\n-- TODO: For old code\nopen import Numeral.Natural.Proofs public\nopen import Numeral.Natural.Oper.Proofs.Rewrite public\n\ninstance\n [+]-identityₗ : Identityₗ(_+_)(0)\n Identityₗ.proof([+]-identityₗ) = [+]-baseₗ\n\ninstance\n [+]-identityᵣ : Identityᵣ(_+_)(0)\n Identityᵣ.proof([+]-identityᵣ) {x} = ℕ-elim [≡]-intro (x ↦ [≡]-with(𝐒) {x + 𝟎}{x}) x\n\ninstance\n [+]-identity : Identity (_+_) (0)\n [+]-identity = intro\n\ninstance\n [+]-associativity : Associativity(_+_)\n Associativity.proof([+]-associativity) {x}{y}{z} = ℕ-elim [≡]-intro (i ↦ [≡]-with(𝐒) {(x + y) + i} {x + (y + i)}) z\n\ninstance\n [+]-commutativity : Commutativity (_+_)\n Commutativity.proof([+]-commutativity) {x}{y} = ℕ-elim base next y where\n base = identityᵣ(_+_)(𝟎) 🝖 symmetry(_≡_) (identityₗ(_+_)(𝟎))\n next = \\i eq → ([≡]-with(𝐒) {x + i}{i + x} eq) 🝖 symmetry(_≡_) ([+]-stepₗ {i}{x})\n\n[+1]-and-[𝐒] : ∀{x : ℕ} → (x + 1 ≡ 𝐒(x))\n[+1]-and-[𝐒] {x} = [≡]-intro\n\n[1+]-and-[𝐒] : ∀{x : ℕ} → (1 + x ≡ 𝐒(x))\n[1+]-and-[𝐒] {x} = [+1]-and-[𝐒] {x} 🝖 commutativity(_+_) {x}{1}\n\n[⋅]-absorberₗ-raw : Names.Absorberₗ(_⋅_)(0)\n[⋅]-absorberₗ-raw {x} = ℕ-elim [≡]-intro (\\i → [≡]-with(0 +_) {0 ⋅ i}{0}) x\n{-# REWRITE [⋅]-absorberₗ-raw #-}\ninstance\n [⋅]-absorberₗ : Absorberₗ(_⋅_)(0)\n Absorberₗ.proof([⋅]-absorberₗ) {x} = [⋅]-absorberₗ-raw {x}\n\ninstance\n [⋅]-absorberᵣ : Absorberᵣ(_⋅_)(0)\n Absorberᵣ.proof([⋅]-absorberᵣ) {x} = [≡]-intro\n\ninstance\n [⋅]-absorber : Absorber(_⋅_)(0)\n [⋅]-absorber = intro\n\n[⋅]-identityₗ-raw : Names.Identityₗ(_⋅_)(1)\n[⋅]-identityₗ-raw {x} = ℕ-elim [≡]-intro (\\i eq → (commutativity(_+_) {1} {1 ⋅ i}) 🝖 ([≡]-with(𝐒) {_}{i} eq)) x\n{-# REWRITE [⋅]-identityₗ-raw #-}\ninstance\n [⋅]-identityₗ : Identityₗ(_⋅_)(1)\n Identityₗ.proof([⋅]-identityₗ) {x} = [⋅]-identityₗ-raw {x}\n\ninstance\n [⋅]-identityᵣ : Identityᵣ(_⋅_)(1)\n Identityᵣ.proof([⋅]-identityᵣ) = [≡]-intro\n\ninstance\n [⋅]-identity : Identity(_⋅_)(1)\n [⋅]-identity = intro\n\ninstance\n [⋅][+]-distributivityᵣ : Distributivityᵣ(_⋅_)(_+_)\n Distributivityᵣ.proof([⋅][+]-distributivityᵣ) {x}{y}{z} = ℕ-elim [≡]-intro next z where\n next : ∀(z : ℕ) → ((x + y) ⋅ z) ≡ ((x ⋅ z) + (y ⋅ z)) → ((x + y) ⋅ 𝐒(z)) ≡ ((x ⋅ 𝐒(z)) + (y ⋅ 𝐒(z)))\n next z proof = ([≡]-with((x + y) +_) proof) 🝖 (One.associate-commute4 {a = x}{y}{x ⋅ z}{y ⋅ z} (commutativity(_+_){x = y}))\n\n[⋅]-with-[𝐒]ₗ : ∀{x y} → (𝐒(x) ⋅ y ≡ (x ⋅ y) + y)\n[⋅]-with-[𝐒]ₗ {x}{y} = (distributivityᵣ(_⋅_)(_+_) {x}{1}{y}) 🝖 ([≡]-with(expr ↦ (x ⋅ y) + expr) ([⋅]-identityₗ-raw {y}))\n\n[⋅]-with-[𝐒]ᵣ : ∀{x y} → (x ⋅ 𝐒(y) ≡ x + (x ⋅ y))\n[⋅]-with-[𝐒]ᵣ = [≡]-intro\n\ninstance\n [⋅][+]-distributivityₗ : Distributivityₗ(_⋅_)(_+_)\n Distributivityₗ.proof([⋅][+]-distributivityₗ) {x}{y}{z} = p{x}{y}{z} where\n p : Names.Distributivityₗ(_⋅_)(_+_)\n p {𝟎} {y} {z} = [≡]-intro\n p {𝐒 x} {𝟎} {z} = [≡]-intro\n p {𝐒 x} {𝐒 y} {𝟎} = [≡]-intro\n p {𝐒 x} {𝐒 y} {𝐒 z} = [≡]-with(𝐒 ∘ 𝐒) $\n x + (x + (𝐒 x ⋅ (y + z))) 🝖[ _≡_ ]-[ [≡]-with((x +_) ∘ (x +_)) (p {𝐒 x} {y} {z}) ]\n x + (x + ((𝐒 x ⋅ y) + (𝐒 x ⋅ z))) 🝖[ _≡_ ]-[ [≡]-with(x +_) (One.commuteₗ-assocᵣ ⦃ comm = intro(\\{x y} → commutativity(_+_) {x}{y}) ⦄ {a = x}{b = 𝐒 x ⋅ y}{c = 𝐒 x ⋅ z}) ]\n x + ((𝐒 x ⋅ y) + (x + (𝐒 x ⋅ z))) 🝖[ _≡_ ]-[ associativity(_+_) {x = x}{y = 𝐒 x ⋅ y} ]-sym\n (x + (𝐒 x ⋅ y)) + (x + (𝐒 x ⋅ z)) 🝖-end\n\ninstance\n [⋅]-associativity : Associativity (_⋅_)\n Associativity.proof([⋅]-associativity) {x}{y}{z} = p{x}{y}{z} where\n p : Names.Associativity(_⋅_)\n p {𝟎} {𝟎} {𝟎} = [≡]-intro\n p {𝟎} {𝟎} {𝐒 z} = [≡]-intro\n p {𝟎} {𝐒 y} {𝟎} = [≡]-intro\n p {𝟎} {𝐒 y} {𝐒 z} = [≡]-intro\n p {𝐒 x} {𝟎} {𝟎} = [≡]-intro\n p {𝐒 x} {𝟎} {𝐒 z} = [≡]-intro\n p {𝐒 x} {𝐒 y} {𝟎} = [≡]-intro\n p {𝐒 x} {𝐒 y} {𝐒 z} = [≡]-with(𝐒) $\n (x + (𝐒 x ⋅ y)) + (𝐒(x + 𝐒 x ⋅ y) ⋅ z) 🝖[ _≡_ ]-[ associativity(_+_) {x = x}{y = 𝐒 x ⋅ y} ]\n x + ((𝐒 x ⋅ y) + (𝐒(x + 𝐒 x ⋅ y) ⋅ z)) 🝖[ _≡_ ]-[]\n x + ((𝐒 x ⋅ y) + ((𝐒 x + 𝐒 x ⋅ y) ⋅ z)) 🝖[ _≡_ ]-[]\n x + ((𝐒 x ⋅ y) + ((𝐒 x ⋅ 𝐒 y) ⋅ z)) 🝖[ _≡_ ]-[ [≡]-with(expr ↦ x + ((𝐒 x ⋅ y) + expr)) (p{𝐒 x}{𝐒 y}{z}) ]\n x + ((𝐒 x ⋅ y) + (𝐒 x ⋅ (𝐒 y ⋅ z))) 🝖[ _≡_ ]-[ [≡]-with(x +_) (distributivityₗ(_⋅_)(_+_) {x = 𝐒 x}{y = y}{z = 𝐒 y ⋅ z}) ]-sym\n x + (𝐒 x ⋅ (y + (𝐒 y ⋅ z))) 🝖-end\n\ninstance\n [⋅]-commutativity : Commutativity (_⋅_)\n Commutativity.proof([⋅]-commutativity) {x}{y} = p {x}{y} where\n p : Names.Commutativity(_⋅_)\n p {𝟎} {𝟎} = [≡]-intro\n p {𝟎} {𝐒 y} = [≡]-intro\n p {𝐒 x} {𝟎} = [≡]-intro\n p {𝐒 x} {𝐒 y} = [≡]-with(𝐒) $\n x + (𝐒 x ⋅ y) 🝖-[ [≡]-with(x +_) ([⋅]-with-[𝐒]ₗ {x}{y}) ]\n x + ((x ⋅ y) + y) 🝖-[ [≡]-with(x +_) (commutativity(_+_) {x ⋅ y}{y}) ]\n x + (y + (x ⋅ y)) 🝖-[ One.commuteₗ-assocᵣ ⦃ comm = intro(\\{x y} → commutativity(_+_) {x}{y}) ⦄ {a = x}{b = y}{c = x ⋅ y} ]\n y + (x + (x ⋅ y)) 🝖-[ [≡]-with(expr ↦ y + (x + expr)) (p {x} {y}) ]\n y + (x + (y ⋅ x)) 🝖-[ [≡]-with(y +_) (commutativity(_+_) {x}{y ⋅ x}) ]\n y + ((y ⋅ x) + x) 🝖-[ [≡]-with(y +_) ([⋅]-with-[𝐒]ₗ {y}{x}) ]-sym\n y + (𝐒 y ⋅ x) 🝖-end\n\n[𝐏][𝐒]-inverses : ∀{n} → (𝐏(𝐒(n)) ≡ n)\n[𝐏][𝐒]-inverses = [≡]-intro\n\n[+]-sum-is-0 : ∀{a b} → (a + b ≡ 0) → (a ≡ 0)∧(b ≡ 0)\n[+]-sum-is-0 {a}{b} proof = [∧]-intro (l{a}{b} proof) r where\n l = \\{a b} → ℕ-elim{T = \\b → (a + b ≡ 0) → (a ≡ 0)} id (\\_ p → p ∘ [≡]-with(𝐏)) b\n r = l{b}{a} (commutativity(_+_) {b}{a} 🝖 proof)\n\n[⋅]-product-is-1ₗ : ∀{a b} → (a ⋅ b ≡ 1) → (a ≡ 1)\n[⋅]-product-is-1ₗ {𝟎} {_} p = p\n[⋅]-product-is-1ₗ {𝐒 a} {𝟎} ()\n[⋅]-product-is-1ₗ {𝐒 a} {𝐒 b} p = [≡]-with(𝐒) ([∧]-elimₗ ([+]-sum-is-0 (injective(𝐒) p)))\n\n[⋅]-product-is-1ᵣ : ∀{a b} → (a ⋅ b ≡ 1) → (b ≡ 1)\n[⋅]-product-is-1ᵣ {a}{b} = [⋅]-product-is-1ₗ {b}{a} ∘ (commutativity(_⋅_) {b}{a} 🝖_)\n\n[⋅]-product-is-0 : ∀{a b} → (a ⋅ b ≡ 0) → ((a ≡ 0)∨(b ≡ 0))\n[⋅]-product-is-0 {_} {0} _ = [∨]-introᵣ [≡]-intro\n[⋅]-product-is-0 {0} {𝐒(_)} _ = [∨]-introₗ [≡]-intro\n[⋅]-product-is-0 {𝐒(a)}{𝐒(b)} ab0 with () ← [𝐒]-not-0 {(𝐒(a) ⋅ b) + a} (commutativity(_+_) {𝐒(a) ⋅ b}{𝐒(a)} 🝖 ab0)\n\n[⋅]-product-is-positive : ∀{a b n} → (a ⋅ b ≡ 𝐒(n)) → (∃(n₁ ↦ a ≡ 𝐒(n₁)) ∧ ∃(n₂ ↦ b ≡ 𝐒(n₂)))\n[⋅]-product-is-positive {_} {0} p with () ← [𝐒]-not-0 (symmetry(_≡_) p)\n[⋅]-product-is-positive {0} {𝐒(_)} p with () ← [𝐒]-not-0 (symmetry(_≡_) p)\n[⋅]-product-is-positive {𝐒(a)}{𝐒(b)} p = [∧]-intro ([∃]-intro a) ([∃]-intro b)\n\ninstance\n [+]-cancellationᵣ : Cancellationᵣ(_+_)\n Cancellationᵣ.proof([+]-cancellationᵣ) {a}{x}{y} = ℕ-elim{T = \\a → (x + a ≡ y + a) → (x ≡ y)} id (\\_ → _∘ injective(𝐒)) a\n\ninstance\n [+]-cancellationₗ : Cancellationₗ(_+_)\n Cancellationₗ.proof([+]-cancellationₗ) {a}{x}{y} = cancellationᵣ(_+_) ∘ One.commuteBothTemp {a₁ = a}{x}{a}{y}\n\n[^]-of-𝟎ₗ : ∀{x} → (𝟎 ^ 𝐒(x) ≡ 𝟎)\n[^]-of-𝟎ₗ = [≡]-intro\n\n[^]-of-𝟏ₗ : ∀{x} → (𝟏 ^ x ≡ 𝟏)\n[^]-of-𝟏ₗ {𝟎} = [≡]-intro\n[^]-of-𝟏ₗ {𝐒 x} = [^]-of-𝟏ₗ {x}\n\n[−₀]-absorberₗ-raw : ∀{x} → ((𝟎 −₀ x) ≡ 𝟎)\n[−₀]-absorberₗ-raw {n} = ℕ-elim{T = \\n → ((𝟎 −₀ n) ≡ 𝟎)} [≡]-intro (\\_ _ → [≡]-intro) n\n{-# REWRITE [−₀]-absorberₗ-raw #-}\ninstance\n [−₀]-absorberₗ : Absorberₗ (_−₀_) (𝟎)\n Absorberₗ.proof([−₀]-absorberₗ) {x} = [−₀]-absorberₗ-raw {x}\n\ninstance\n [−₀]-identityᵣ : Identityᵣ (_−₀_) (𝟎)\n Identityᵣ.proof([−₀]-identityᵣ) {x} = [≡]-intro\n\n[−₀]-self : ∀{x} → ((x −₀ x) ≡ 𝟎)\n[−₀]-self {n} = ℕ-elim{T = \\n → ((n −₀ n) ≡ 𝟎)} [≡]-intro (\\_ p → p) n\n{-# REWRITE [−₀]-self #-}\n\n[−₀]-with-[𝐒]ᵣ : ∀{x y} → ((x −₀ 𝐒(y)) ≡ 𝐏(x −₀ y))\n[−₀]-with-[𝐒]ᵣ {𝟎} {𝟎} = [≡]-intro\n[−₀]-with-[𝐒]ᵣ {𝟎} {𝐒 y} = [≡]-intro\n[−₀]-with-[𝐒]ᵣ {𝐒 x} {𝟎} = [≡]-intro\n[−₀]-with-[𝐒]ᵣ {𝐒 x} {𝐒 y} = [−₀]-with-[𝐒]ᵣ {x} {y}\n\n[−₀][−₀]-to-[−₀][+] : ∀{x y z} → ((x −₀ y) −₀ z ≡ x −₀ (y + z))\n[−₀][−₀]-to-[−₀][+] {x}{y}{𝟎} = [≡]-intro\n[−₀][−₀]-to-[−₀][+] {x}{y}{𝐒 z} =\n (x −₀ y) −₀ 𝐒(z) 🝖[ _≡_ ]-[ [−₀]-with-[𝐒]ᵣ {x −₀ y}{z} ]\n 𝐏((x −₀ y) −₀ z) 🝖[ _≡_ ]-[ congruence₁(𝐏) ([−₀][−₀]-to-[−₀][+] {x}{y}{z}) ]\n 𝐏(x −₀ (y + z)) 🝖[ _≡_ ]-[ [−₀]-with-[𝐒]ᵣ {x}{y + z} ]-sym\n x −₀ 𝐒(y + z) 🝖[ _≡_ ]-[]\n x −₀ (y + 𝐒(z)) 🝖-end\n\n[−₀]ₗ[+]ᵣ-nullify : ∀{x y} → ((x + y) −₀ y ≡ x)\n[−₀]ₗ[+]ᵣ-nullify{𝟎} {𝟎} = [≡]-intro\n[−₀]ₗ[+]ᵣ-nullify{𝟎} {𝐒(y)} = [≡]-intro\n[−₀]ₗ[+]ᵣ-nullify{𝐒(x)}{𝐒(y)} = [≡]-intro 🝖 ([−₀]ₗ[+]ᵣ-nullify{𝐒(x)}{y})\n[−₀]ₗ[+]ᵣ-nullify{𝐒(x)}{𝟎} = [≡]-intro\ninstance\n [+][−₀]-inverseOperatorᵣ : InverseOperatorᵣ(_+_)(_−₀_)\n InverseOperatorᵣ.proof [+][−₀]-inverseOperatorᵣ {x} {y} = [−₀]ₗ[+]ᵣ-nullify {x}{y}\n\n[−₀]ₗ[+]ₗ-nullify : ∀{x y} → ((x + y) −₀ x ≡ y)\n[−₀]ₗ[+]ₗ-nullify {x}{y} = [≡]-substitutionᵣ (commutativity(_+_) {y}{x}) {expr ↦ (expr −₀ x ≡ y)} ([−₀]ₗ[+]ᵣ-nullify {y}{x})\n\n[−₀][+]ᵣ-nullify : ∀{x₁ x₂ y} → ((x₁ + y) −₀ (x₂ + y) ≡ x₁ −₀ x₂)\n[−₀][+]ᵣ-nullify {_} {_} {𝟎} = [≡]-intro\n[−₀][+]ᵣ-nullify {x₁}{x₂}{𝐒(y)} = [−₀][+]ᵣ-nullify {x₁}{x₂}{y}\n\n[−₀][+]ₗ-nullify : ∀{x y₁ y₂} → ((x + y₁) −₀ (x + y₂) ≡ y₁ −₀ y₂)\n[−₀][+]ₗ-nullify {x}{y₁}{y₂} =\n [≡]-with-op(_−₀_) (commutativity(_+_) {x}{y₁}) (commutativity(_+_) {x}{y₂})\n 🝖 [−₀][+]ᵣ-nullify{y₁}{y₂}{x}\n\n[−₀]-cases : ∀{x y} → ((x −₀ y) + y ≡ x) ∨ (x −₀ y ≡ 𝟎)\n[−₀]-cases {𝟎} {𝟎} = [∨]-introᵣ [≡]-intro\n[−₀]-cases {𝟎} {𝐒(_)} = [∨]-introᵣ [≡]-intro\n[−₀]-cases {𝐒(_)}{𝟎} = [∨]-introₗ [≡]-intro\n[−₀]-cases {𝐒(x)}{𝐒(y)} with [−₀]-cases {x}{y}\n... | [∨]-introₗ proof = [∨]-introₗ ([≡]-with(𝐒) (proof))\n... | [∨]-introᵣ proof = [∨]-introᵣ proof\n\n[−₀]-cases-commuted : ∀{x y} → (y + (x −₀ y) ≡ x) ∨ (x −₀ y ≡ 𝟎)\n[−₀]-cases-commuted {x}{y} with [−₀]-cases{x}{y}\n... | [∨]-introₗ proof = [∨]-introₗ (commutativity(_+_) {y}{x −₀ y} 🝖 proof)\n... | [∨]-introᵣ proof = [∨]-introᵣ proof\n\n[𝄩]-𝐒-cases : ∀{x y} → (𝐒(x 𝄩 y) ≡ 𝐒(x) 𝄩 y) ∨ (𝐒(x 𝄩 y) ≡ x 𝄩 𝐒(y))\n[𝄩]-𝐒-cases {𝟎} {𝟎} = [∨]-introₗ [≡]-intro\n[𝄩]-𝐒-cases {𝟎} {𝐒 y} = [∨]-introᵣ [≡]-intro\n[𝄩]-𝐒-cases {𝐒 x} {𝟎} = [∨]-introₗ [≡]-intro\n[𝄩]-𝐒-cases {𝐒 x} {𝐒 y} = [𝄩]-𝐒-cases {x}{y}\n\n[𝄩]-identityₗ-raw : Names.Identityₗ(_𝄩_)(0)\n[𝄩]-identityₗ-raw {𝟎} = [≡]-intro\n[𝄩]-identityₗ-raw {𝐒(_)} = [≡]-intro\n{-# REWRITE [𝄩]-identityₗ-raw #-}\ninstance\n [𝄩]-identityₗ : Identityₗ(_𝄩_)(𝟎)\n Identityₗ.proof([𝄩]-identityₗ) {x} = [𝄩]-identityₗ-raw {x}\n\n[𝄩]-identityᵣ-raw : Names.Identityᵣ (_𝄩_) (0)\n[𝄩]-identityᵣ-raw {𝟎} = [≡]-intro\n[𝄩]-identityᵣ-raw {𝐒(_)} = [≡]-intro\n{-# REWRITE [𝄩]-identityᵣ-raw #-}\ninstance\n [𝄩]-identityᵣ : Identityᵣ(_𝄩_)(𝟎)\n Identityᵣ.proof([𝄩]-identityᵣ) {x} = [𝄩]-identityᵣ-raw {x}\n\ninstance\n [𝄩]-identity : Identity(_𝄩_)(𝟎)\n [𝄩]-identity = intro\n\n[𝄩]-self : ∀{x} → (x 𝄩 x ≡ 𝟎)\n[𝄩]-self {𝟎} = [≡]-intro\n[𝄩]-self {𝐒(x)} = [𝄩]-self {x}\n{-# REWRITE [𝄩]-self #-}\n\ninstance\n [𝄩]-inverseFunctionₗ : InverseFunctionₗ(_𝄩_) ⦃ [∃]-intro 𝟎 ⦄ (id)\n [𝄩]-inverseFunctionₗ = intro \\{x} → [𝄩]-self {x}\n\ninstance\n [𝄩]-inverseFunctionᵣ : InverseFunctionᵣ(_𝄩_) ⦃ [∃]-intro 𝟎 ⦄ (id)\n [𝄩]-inverseFunctionᵣ = intro \\{x} → [𝄩]-self {x}\n\ninstance\n [𝄩]-commutativity : Commutativity(_𝄩_)\n Commutativity.proof([𝄩]-commutativity) {x}{y} = p{x}{y} where\n p : Names.Commutativity (_𝄩_)\n p{𝟎} {𝟎} = [≡]-intro\n p{𝟎} {𝐒(y)} = [≡]-intro\n p{𝐒(x)}{𝟎} = [≡]-intro\n p{𝐒(x)}{𝐒(y)} = p{x}{y}\n\ninstance\n [+][𝄩]-inverseOperatorᵣ : InverseOperatorᵣ(_+_)(_𝄩_)\n InverseOperatorᵣ.proof [+][𝄩]-inverseOperatorᵣ {x}{y} = p{x}{y} where\n p : ∀{x y} → ((x + y) 𝄩 y ≡ x)\n p{𝟎} {𝟎} = [≡]-intro\n p{𝟎} {𝐒(y)} = [≡]-intro\n p{𝐒(x)}{𝐒(y)} = [≡]-intro 🝖 (p{𝐒(x)}{y})\n p{𝐒(x)}{𝟎} = [≡]-intro\n\ninstance\n [swap+][𝄩]-inverseOperatorᵣ : InverseOperatorᵣ(swap(_+_))(_𝄩_)\n InverseOperatorᵣ.proof [swap+][𝄩]-inverseOperatorᵣ {x}{y} = congruence₂ₗ(_𝄩_)(y) (commutativity(_+_) {y}{x}) 🝖 inverseOperᵣ(_+_)(_𝄩_) {x}{y}\n\ninstance\n [swap+][𝄩]-inverseOperatorₗ : InverseOperatorₗ(swap(_+_))(_𝄩_)\n InverseOperatorₗ.proof [swap+][𝄩]-inverseOperatorₗ {x}{y} = commutativity(_𝄩_) {x}{y + x} 🝖 inverseOperᵣ(_+_)(_𝄩_) {y}{x}\n\ninstance\n [+][𝄩]-inverseOperatorₗ : InverseOperatorₗ(_+_)(_𝄩_)\n InverseOperatorₗ.proof [+][𝄩]-inverseOperatorₗ {x}{y} = commutativity(_𝄩_) {x}{x + y} 🝖 inverseOperᵣ(swap(_+_))(_𝄩_) {y}{x}\n\n[𝄩]-with-[+]ᵣ : ∀{x y z} → ((x + z) 𝄩 (y + z) ≡ x 𝄩 y)\n[𝄩]-with-[+]ᵣ {𝟎} {𝟎} {𝟎} = [≡]-intro\n[𝄩]-with-[+]ᵣ {𝟎} {𝐒(y)}{𝟎} = [≡]-intro\n[𝄩]-with-[+]ᵣ {𝟎} {𝟎} {𝐒(z)} = [≡]-intro\n[𝄩]-with-[+]ᵣ {𝟎} {𝐒(y)}{𝐒(z)} = inverseOperₗ(swap(_+_))(_𝄩_) {z}{_}\n[𝄩]-with-[+]ᵣ {𝐒(x)}{𝟎} {𝟎} = [≡]-intro\n[𝄩]-with-[+]ᵣ {𝐒(x)}{𝐒(y)}{𝟎} = [≡]-intro\n[𝄩]-with-[+]ᵣ {𝐒(x)}{𝟎} {𝐒(z)} = inverseOperᵣ(_+_)(_𝄩_) {𝐒(x)}{z}\n[𝄩]-with-[+]ᵣ {𝐒(x)}{𝐒(y)}{𝐒(z)} = [𝄩]-with-[+]ᵣ {𝐒(x)}{𝐒(y)}{z}\n\n[𝄩]-with-[+]ₗ : ∀{x y z} → ((z + x) 𝄩 (z + y) ≡ x 𝄩 y)\n[𝄩]-with-[+]ₗ {𝟎} {𝟎} {𝟎} = [≡]-intro\n[𝄩]-with-[+]ₗ {𝟎} {𝐒(y)}{𝟎} = [≡]-intro\n[𝄩]-with-[+]ₗ {𝟎} {𝟎} {𝐒(z)} = [≡]-intro\n[𝄩]-with-[+]ₗ {𝟎} {𝐒(y)}{𝐒(z)} = inverseOperₗ(_+_)(_𝄩_) {z}{𝐒(y)}\n[𝄩]-with-[+]ₗ {𝐒(x)}{𝟎} {𝟎} = [≡]-intro\n[𝄩]-with-[+]ₗ {𝐒(x)}{𝐒(y)}{𝟎} = [≡]-intro\n[𝄩]-with-[+]ₗ {𝐒(x)}{𝟎} {𝐒(z)} = inverseOperᵣ(swap(_+_))(_𝄩_) {𝐒(x)}{z}\n[𝄩]-with-[+]ₗ {𝐒(x)}{𝐒(y)}{𝐒(z)} = [𝄩]-with-[+]ₗ {𝐒(x)}{𝐒(y)}{z}\n\n[𝄩]-equality : ∀{x y} → (x 𝄩 y ≡ 𝟎) → (x ≡ y)\n[𝄩]-equality {𝟎} {𝟎} [≡]-intro = [≡]-intro\n[𝄩]-equality {𝟎} {𝐒(y)} ()\n[𝄩]-equality {𝐒(x)}{𝟎} ()\n[𝄩]-equality {𝐒(x)}{𝐒(y)} proof = [≡]-with(𝐒) ([𝄩]-equality {x}{y} proof)\n\ninstance\n [⋅][𝄩]-distributivityᵣ : Distributivityᵣ(_⋅_)(_𝄩_)\n Distributivityᵣ.proof [⋅][𝄩]-distributivityᵣ {x}{y}{z} = p{x}{y}{z} where\n p : Names.Distributivityᵣ(_⋅_)(_𝄩_)\n p {𝟎} {𝟎} {z} = [≡]-intro\n p {𝟎} {𝐒 y} {z} = [≡]-intro\n p {𝐒 x} {𝟎} {z} = [≡]-intro\n p {𝐒 x} {𝐒 y} {z} =\n (𝐒(x) 𝄩 𝐒(y)) ⋅ z 🝖[ _≡_ ]-[]\n (x 𝄩 y) ⋅ z 🝖[ _≡_ ]-[ p{x}{y}{z} ]\n (x ⋅ z) 𝄩 (y ⋅ z) 🝖[ _≡_ ]-[ [𝄩]-with-[+]ᵣ {x ⋅ z}{y ⋅ z}{z} ]-sym\n ((x ⋅ z) + z) 𝄩 ((y ⋅ z) + z) 🝖[ _≡_ ]-[ congruence₂(_𝄩_) ([⋅]-with-[𝐒]ₗ {x}{z}) ([⋅]-with-[𝐒]ₗ {y}{z}) ]-sym\n (𝐒(x) ⋅ z) 𝄩 (𝐒(y) ⋅ z) 🝖-end\n\ninstance\n [⋅][𝄩]-distributivityₗ : Distributivityₗ(_⋅_)(_𝄩_)\n Distributivityₗ.proof [⋅][𝄩]-distributivityₗ {x}{y}{z} =\n x ⋅ (y 𝄩 z) 🝖[ _≡_ ]-[ commutativity(_⋅_) {x}{y 𝄩 z} ]\n (y 𝄩 z) ⋅ x 🝖[ _≡_ ]-[ distributivityᵣ(_⋅_)(_𝄩_) {y}{z}{x} ]\n (y ⋅ x) 𝄩 (z ⋅ x) 🝖[ _≡_ ]-[ congruence₂(_𝄩_) (commutativity(_⋅_) {y}{x}) (commutativity(_⋅_) {z}{x}) ]\n (x ⋅ y) 𝄩 (x ⋅ z) 🝖-end\n", "meta": {"hexsha": "118ae9240b278078f3c9d52327002aca08e96c0a", "size": 14756, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Oper/Proofs.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Oper/Proofs.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Oper/Proofs.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.4273972603, "max_line_length": 176, "alphanum_fraction": 0.473231228, "num_tokens": 8712, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891348788759, "lm_q2_score": 0.7431680029241321, "lm_q1q2_score": 0.6110246573938541}} {"text": "-- Minimal propositional logic, vector-based de Bruijn approach, initial encoding\n\nmodule Vi.Mp where\n\nopen import Lib using (Nat; suc; _+_; Fin; fin; Vec; _,_; proj; VMem; mem)\n\n\n-- Types\n\ninfixl 2 _&&_\ninfixl 1 _||_\ninfixr 0 _=>_\ndata Ty : Set where\n UNIT : Ty\n _=>_ : Ty -> Ty -> Ty\n _&&_ : Ty -> Ty -> Ty\n _||_ : Ty -> Ty -> Ty\n FALSE : Ty\n\ninfixr 0 _<=>_\n_<=>_ : Ty -> Ty -> Ty\na <=> b = (a => b) && (b => a)\n\nNOT : Ty -> Ty\nNOT a = a => FALSE\n\nTRUE : Ty\nTRUE = FALSE => FALSE\n\n\n-- Context and truth judgement\n\nCx : Nat -> Set\nCx n = Vec Ty n\n\nisTrue : forall {tn} -> Ty -> Fin tn -> Cx tn -> Set\nisTrue a i tc = VMem a i tc\n\n\n-- Terms\n\nmodule Mp where\n infixl 1 _$_\n infixr 0 lam=>_\n data Tm {tn} (tc : Cx tn) : Ty -> Set where\n var : forall {a i} -> isTrue a i tc -> Tm tc a\n lam=>_ : forall {a b} -> Tm (tc , a) b -> Tm tc (a => b)\n _$_ : forall {a b} -> Tm tc (a => b) -> Tm tc a -> Tm tc b\n pair' : forall {a b} -> Tm tc a -> Tm tc b -> Tm tc (a && b)\n fst : forall {a b} -> Tm tc (a && b) -> Tm tc a\n snd : forall {a b} -> Tm tc (a && b) -> Tm tc b\n left : forall {a b} -> Tm tc a -> Tm tc (a || b)\n right : forall {a b} -> Tm tc b -> Tm tc (a || b)\n case' : forall {a b c} -> Tm tc (a || b) -> Tm (tc , a) c -> Tm (tc , b) c -> Tm tc c\n\n syntax pair' x y = [ x , y ]\n syntax case' xy x y = case xy => x => y\n\n v : forall {tn} (k : Nat) {tc : Cx (suc (k + tn))} -> Tm tc (proj tc (fin k))\n v i = var (mem i)\n\n Thm : Ty -> Set\n Thm a = forall {tn} {tc : Cx tn} -> Tm tc a\nopen Mp public\n\n\n-- Example theorems\n\nc1 : forall {a b} -> Thm (a && b <=> b && a)\nc1 =\n [ lam=> [ snd (v 0) , fst (v 0) ]\n , lam=> [ snd (v 0) , fst (v 0) ]\n ]\n\nc2 : forall {a b} -> Thm (a || b <=> b || a)\nc2 =\n [ lam=>\n (case v 0\n => right (v 0)\n => left (v 0))\n , lam=>\n (case v 0\n => right (v 0)\n => left (v 0))\n ]\n\ni1 : forall {a} -> Thm (a && a <=> a)\ni1 =\n [ lam=> fst (v 0)\n , lam=> [ v 0 , v 0 ]\n ]\n\ni2 : forall {a} -> Thm (a || a <=> a)\ni2 =\n [ lam=>\n (case v 0\n => v 0\n => v 0)\n , lam=> left (v 0)\n ]\n\nl3 : forall {a} -> Thm ((a => a) <=> TRUE)\nl3 =\n [ lam=> lam=> v 0\n , lam=> lam=> v 0\n ]\n\nl1 : forall {a b c} -> Thm (a && (b && c) <=> (a && b) && c)\nl1 =\n [ lam=>\n [ [ fst (v 0) , fst (snd (v 0)) ]\n , snd (snd (v 0))\n ]\n , lam=>\n [ fst (fst (v 0))\n , [ snd (fst (v 0)) , snd (v 0) ]\n ]\n ]\n\nl2 : forall {a} -> Thm (a && TRUE <=> a)\nl2 =\n [ lam=> fst (v 0)\n , lam=> [ v 0 , lam=> v 0 ]\n ]\n\nl4 : forall {a b c} -> Thm (a && (b || c) <=> (a && b) || (a && c))\nl4 =\n [ lam=>\n (case snd (v 0)\n => left [ fst (v 1) , v 0 ]\n => right [ fst (v 1) , v 0 ])\n , lam=>\n (case v 0\n => [ fst (v 0) , left (snd (v 0)) ]\n => [ fst (v 0) , right (snd (v 0)) ])\n ]\n\nl6 : forall {a b c} -> Thm (a || (b && c) <=> (a || b) && (a || c))\nl6 =\n [ lam=>\n (case v 0\n => [ left (v 0) , left (v 0) ]\n => [ right (fst (v 0)) , right (snd (v 0)) ])\n , lam=>\n (case fst (v 0)\n => left (v 0)\n =>\n case snd (v 1)\n => left (v 0)\n => right [ v 1 , v 0 ])\n ]\n\nl7 : forall {a} -> Thm (a || TRUE <=> TRUE)\nl7 =\n [ lam=> lam=> v 0\n , lam=> right (v 0)\n ]\n\nl9 : forall {a b c} -> Thm (a || (b || c) <=> (a || b) || c)\nl9 =\n [ lam=>\n (case v 0\n => left (left (v 0))\n =>\n case v 0\n => left (right (v 0))\n => right (v 0))\n , lam=>\n (case v 0\n =>\n case v 0\n => left (v 0)\n => right (left (v 0))\n => right (right (v 0)))\n ]\n\nl11 : forall {a b c} -> Thm ((a => (b && c)) <=> (a => b) && (a => c))\nl11 =\n [ lam=>\n [ lam=> fst (v 1 $ v 0)\n , lam=> snd (v 1 $ v 0)\n ]\n , lam=>\n lam=> [ fst (v 1) $ v 0 , snd (v 1) $ v 0 ]\n ]\n\nl12 : forall {a} -> Thm ((a => TRUE) <=> TRUE)\nl12 =\n [ lam=> lam=> v 0\n , lam=> lam=> v 1\n ]\n\nl13 : forall {a b c} -> Thm ((a => (b => c)) <=> ((a && b) => c))\nl13 =\n [ lam=>\n lam=> v 1 $ fst (v 0) $ snd (v 0)\n , lam=>\n lam=>\n lam=> v 2 $ [ v 1 , v 0 ]\n ]\n\nl16 : forall {a b c} -> Thm (((a && b) => c) <=> (a => (b => c)))\nl16 =\n [ lam=>\n lam=>\n lam=> v 2 $ [ v 1 , v 0 ]\n , lam=>\n lam=> v 1 $ fst (v 0) $ snd (v 0)\n ]\n\nl17 : forall {a} -> Thm ((TRUE => a) <=> a)\nl17 =\n [ lam=> v 0 $ (lam=> v 0)\n , lam=> lam=> v 1\n ]\n\nl19 : forall {a b c} -> Thm (((a || b) => c) <=> (a => c) && (b => c))\nl19 =\n [ lam=>\n [ lam=> v 1 $ left (v 0)\n , lam=> v 1 $ right (v 0)\n ]\n , lam=>\n lam=>\n (case v 0\n => fst (v 2) $ (v 0)\n => snd (v 2) $ (v 0))\n ]\n", "meta": {"hexsha": "08fbda97d4013fb034c90dd5ddea0c768526e8d2", "size": 4866, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Vi/Mp.agda", "max_stars_repo_name": "mietek/formal-logic", "max_stars_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_stars_repo_licenses": ["X11"], "max_stars_count": 26, "max_stars_repo_stars_event_min_datetime": "2015-08-31T09:49:52.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-13T12:37:44.000Z", "max_issues_repo_path": "src/Vi/Mp.agda", "max_issues_repo_name": "mietek/formal-logic", "max_issues_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_issues_repo_licenses": ["X11"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Vi/Mp.agda", "max_forks_repo_name": "mietek/formal-logic", "max_forks_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_forks_repo_licenses": ["X11"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.2489082969, "max_line_length": 90, "alphanum_fraction": 0.3715577476, "num_tokens": 2029, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127566694177, "lm_q2_score": 0.7154240079185319, "lm_q1q2_score": 0.6109096867891969}} {"text": "module Data.Fin.Extra where\n\nopen import Data.Nat\n renaming (suc to S; zero to Z; _+_ to _ℕ+_; _*_ to _ℕ*_)\nopen import Data.Fin\n\nopen import Function\nopen import Relation.Nullary.Negation\nopen import Relation.Binary.PropositionalEquality\n\ninject-1 : ∀ {n} → (i : Fin (S n)) → toℕ i ≢ n → Fin n\ninject-1 {Z} zero p = contradiction refl p\ninject-1 {Z} (suc i) p = i\ninject-1 {S n} zero p = zero\ninject-1 {S n} (suc i) p = suc (inject-1 i (p ∘ cong S))\n", "meta": {"hexsha": "8edc61d10fc62799ffb86b6292fae10c16325484", "size": 464, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Fin/Extra.agda", "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_issues_repo_path": "Data/Fin/Extra.agda", "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Fin/Extra.agda", "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "avg_line_length": 29.0, "max_line_length": 60, "alphanum_fraction": 0.6573275862, "num_tokens": 170, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8539127380808499, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.610909663128208}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Homomorphism proofs for negation over polynomials\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Tactic.RingSolver.Core.Polynomial.Parameters\n\nmodule Tactic.RingSolver.Core.Polynomial.Homomorphism.Negation\n {r₁ r₂ r₃ r₄}\n (homo : Homomorphism r₁ r₂ r₃ r₄)\n where\n\nopen import Data.Product using (_,_)\nopen import Data.Vec using (Vec)\nopen import Data.Nat using (_<′_)\nopen import Data.Nat.Induction\n\nopen import Function\n\nopen Homomorphism homo\nopen import Tactic.RingSolver.Core.Polynomial.Homomorphism.Lemmas homo\nopen import Tactic.RingSolver.Core.Polynomial.Reasoning to\nopen import Tactic.RingSolver.Core.Polynomial.Base from\nopen import Tactic.RingSolver.Core.Polynomial.Semantics homo\n\n⊟-step-hom : ∀ {n} (a : Acc _<′_ n) → (xs : Poly n) → ∀ ρ → ⟦ ⊟-step a xs ⟧ ρ ≈ - (⟦ xs ⟧ ρ)\n⊟-step-hom (acc _ ) (Κ x ⊐ i≤n) ρ = -‿homo x\n⊟-step-hom (acc wf) (⅀ xs ⊐ i≤n) ρ′ =\n let (ρ , ρs) = drop-1 i≤n ρ′\n neg-zero =\n begin\n 0#\n ≈⟨ sym (zeroʳ _) ⟩\n - 0# * 0#\n ≈⟨ -‿*-distribˡ 0# 0# ⟩\n - (0# * 0#)\n ≈⟨ -‿cong (zeroˡ 0#) ⟩\n - 0#\n ∎\n in\n begin\n ⟦ poly-map (⊟-step (wf _ i≤n)) xs ⊐↓ i≤n ⟧ ρ′\n ≈⟨ ⊐↓-hom (poly-map (⊟-step (wf _ i≤n)) xs) i≤n ρ′ ⟩\n ⅀?⟦ poly-map (⊟-step (wf _ i≤n)) xs ⟧ (ρ , ρs)\n ≈⟨ poly-mapR ρ ρs (⊟-step (wf _ i≤n)) -_ (-‿cong) (λ x y → *-comm x (- y) ⟨ trans ⟩ -‿*-distribˡ y x ⟨ trans ⟩ -‿cong (*-comm _ _)) (λ x y → sym (-‿+-comm x y)) (flip (⊟-step-hom (wf _ i≤n)) ρs) (sym neg-zero ) xs ⟩\n - ⅀⟦ xs ⟧ (ρ , ρs)\n ∎\n\n⊟-hom : ∀ {n}\n → (xs : Poly n)\n → (Ρ : Vec Carrier n)\n → ⟦ ⊟ xs ⟧ Ρ ≈ - ⟦ xs ⟧ Ρ\n⊟-hom = ⊟-step-hom (<′-wellFounded _)\n", "meta": {"hexsha": "f179f9b677298d3f85747235dca9ad4eee927723", "size": 1873, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Tactic/RingSolver/Core/Polynomial/Homomorphism/Negation.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Tactic/RingSolver/Core/Polynomial/Homomorphism/Negation.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Tactic/RingSolver/Core/Polynomial/Homomorphism/Negation.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 32.8596491228, "max_line_length": 217, "alphanum_fraction": 0.507741591, "num_tokens": 764, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127455162773, "lm_q2_score": 0.7154239836484143, "lm_q1q2_score": 0.6109096580854098}} {"text": "module maryjohn2 where\n\n\npostulate Person : Set\npostulate john : Person\npostulate mary : Person\npostulate barbara : Person\npostulate IsStudent : Person -> Set\npostulate maryIsStudent : IsStudent mary\npostulate implication : IsStudent mary -> IsStudent john\n\nLemma1 : Set\nLemma1 = IsStudent john\n\n\nproof-lemma1 : Lemma1\nproof-lemma1 = implication maryIsStudent\n\nLemma2 : Set\nLemma2 = IsStudent john -> IsStudent barbara\n\nproof-lemma2 : Lemma2\nproof-lemma2 = \\(x : IsStudent john) -> _\n", "meta": {"hexsha": "c33a4305d9fda6dcc53d917e8be8907ee740f248", "size": 521, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tests/covered/maryjohn2.agda", "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_issues_repo_path": "tests/covered/maryjohn2.agda", "max_issues_repo_name": "andrejtokarcik/agda-semantics", "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/covered/maryjohn2.agda", "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.7083333333, "max_line_length": 58, "alphanum_fraction": 0.7159309021, "num_tokens": 137, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9086178919837706, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.6108926052566144}} {"text": "open import Data.Nat using (ℕ; suc)\nopen import Data.Fin using (Fin; zero; suc)\n\n\ninfix 9 #_\ninfixl 7 _·_\ninfix 6 ƛ_\n\ndata Term : ℕ → Set where\n #_ : ∀ {n : ℕ} → Fin n → Term n\n ƛ_ : ∀ {n : ℕ} → Term (suc n) → Term n\n _·_ : ∀ {n : ℕ} → Term n → Term n → Term n\n\n\nRename : ℕ → ℕ → Set\nRename n m = Fin n → Fin m\n\nSubst : ℕ → ℕ → Set\nSubst n m = Fin n → Term m\n\next : ∀ {n m} → Rename n m → Rename (suc n) (suc m)\next ρ zero = zero\next ρ (suc x) = suc (ρ x)\n\nrename : ∀ {n m} → Rename n m → (Term n → Term m)\nrename ρ (# x) = # (ρ x)\nrename ρ (ƛ M) = ƛ (rename (ext ρ) M)\nrename ρ (M · N) = rename ρ M · rename ρ N\n\nexts : ∀ {n m} → Subst n m → Subst (suc n) (suc m)\nexts σ zero = # zero\nexts σ (suc x) = rename suc (σ x)\n\nsubst : ∀ {n m} → Subst n m → (Term n → Term m)\nsubst σ (# x) = σ x\nsubst σ (ƛ M) = ƛ (subst (exts σ) M)\nsubst σ (M · N) = subst σ M · subst σ N\n\nsubst-zero : ∀ {n} → Term n → Subst (suc n) n\nsubst-zero M zero = M\nsubst-zero M (suc x) = # x\n\n\ninfix 8 _[_]\n\n_[_] : ∀ {n} → Term (suc n) → Term n → Term n\nM [ N ] = subst (subst-zero N) M\n", "meta": {"hexsha": "e209ed8c789f5ffb5bed8bb851625b7bf2f27d63", "size": 1097, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "DeBruijn.agda", "max_stars_repo_name": "iwilare/church-rosser", "max_stars_repo_head_hexsha": "2fa17f7738cc7da967375be928137adc4be38696", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-06-02T07:27:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-22T01:43:09.000Z", "max_issues_repo_path": "DeBruijn.agda", "max_issues_repo_name": "iwilare/church-rosser", "max_issues_repo_head_hexsha": "2fa17f7738cc7da967375be928137adc4be38696", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "DeBruijn.agda", "max_forks_repo_name": "iwilare/church-rosser", "max_forks_repo_head_hexsha": "2fa17f7738cc7da967375be928137adc4be38696", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.8541666667, "max_line_length": 51, "alphanum_fraction": 0.5195989061, "num_tokens": 479, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382129861583, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.6108470827914113}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Binary.Proofs.Multiplication where\n\nopen import Relation.Binary.PropositionalEquality\nopen import Data.Binary.Operations.Unary\nopen import Data.Binary.Operations.Addition\nopen import Data.Binary.Operations.Multiplication\nopen import Data.Binary.Proofs.Unary\nopen import Data.Binary.Proofs.Addition\nopen import Data.Binary.Definitions\nopen import Data.Binary.Operations.Semantics\nopen import Data.Nat as ℕ using (ℕ; suc; zero)\nopen import Relation.Binary.PropositionalEquality.FasterReasoning\nimport Data.Nat.Properties as ℕ\nopen import Function\nopen import Data.Nat.Reasoning\n\nmul-homo : ∀ xs ys → ⟦ mul xs ys ⇓⟧⁺ ≡ ⟦ xs ⇓⟧⁺ ℕ.* ⟦ ys ⇓⟧⁺\nmul-homo 1ᵇ ys = sym (ℕ.+-identityʳ _)\nmul-homo (O ∷ xs) ys = cong 2* (mul-homo xs ys) ⟨ trans ⟩ sym (ℕ.*-distribʳ-+ ⟦ ys ⇓⟧⁺ ⟦ xs ⇓⟧⁺ _)\nmul-homo (I ∷ xs) ys =\n begin\n ⟦ add O (O ∷ mul ys xs) ys ⇓⟧⁺\n ≡⟨ add₀-homo (O ∷ mul ys xs) ys ⟩\n 2* ⟦ mul ys xs ⇓⟧⁺ ℕ.+ ⟦ ys ⇓⟧⁺\n ≡⟨ ⟦ ys ⇓⟧⁺ ≪+ cong 2* (mul-homo ys xs) ⟩\n 2* (⟦ ys ⇓⟧⁺ ℕ.* ⟦ xs ⇓⟧⁺) ℕ.+ ⟦ ys ⇓⟧⁺\n ≡⟨ ℕ.+-comm _ ⟦ ys ⇓⟧⁺ ⟩\n ⟦ ys ⇓⟧⁺ ℕ.+ 2* (⟦ ys ⇓⟧⁺ ℕ.* ⟦ xs ⇓⟧⁺)\n ≡˘⟨ ⟦ ys ⇓⟧⁺ +≫ ℕ.*-distribˡ-+ ⟦ ys ⇓⟧⁺ _ _ ⟩\n ⟦ ys ⇓⟧⁺ ℕ.+ ⟦ ys ⇓⟧⁺ ℕ.* (2* ⟦ xs ⇓⟧⁺)\n ≡⟨ ⟦ ys ⇓⟧⁺ +≫ ℕ.*-comm ⟦ ys ⇓⟧⁺ _ ⟩\n ⟦ ys ⇓⟧⁺ ℕ.+ (2* ⟦ xs ⇓⟧⁺) ℕ.* ⟦ ys ⇓⟧⁺\n ∎\n\n*-homo : ∀ xs ys → ⟦ xs * ys ⇓⟧ ≡ ⟦ xs ⇓⟧ ℕ.* ⟦ ys ⇓⟧\n*-homo 0ᵇ ys = refl\n*-homo (0< x) 0ᵇ = sym (ℕ.*-zeroʳ ⟦ x ⇓⟧⁺)\n*-homo (0< xs) (0< ys) = mul-homo xs ys\n", "meta": {"hexsha": "054e7bb1a243b5e8f6795ea01de3e891c6fb07ea", "size": 1458, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Binary/Proofs/Multiplication.agda", "max_stars_repo_name": "oisdk/agda-binary", "max_stars_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-03-21T21:30:10.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-21T21:30:10.000Z", "max_issues_repo_path": "Data/Binary/Proofs/Multiplication.agda", "max_issues_repo_name": "oisdk/agda-binary", "max_issues_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Binary/Proofs/Multiplication.agda", "max_forks_repo_name": "oisdk/agda-binary", "max_forks_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.5609756098, "max_line_length": 98, "alphanum_fraction": 0.5713305898, "num_tokens": 727, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711832583695, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.6107845312586491}} {"text": "------------------------------------------------------------------------\n-- The equality can be turned into a groupoid which is sometimes\n-- commutative\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Equality\n\nmodule Equality.Groupoid\n {reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where\n\nopen import Bijection eq using (_↔_)\nopen Derived-definitions-and-properties eq\nopen import Equality.Tactic eq\nopen import Groupoid eq\nopen import Pointed-type eq\nopen import Prelude hiding (id; _∘_)\n\n------------------------------------------------------------------------\n-- _≡_ comes with a groupoid structure\n\ngroupoid : ∀ {a} (A : Type a) → Groupoid a a\ngroupoid A = record\n { Object = A\n ; _∼_ = _≡_\n\n ; id = refl _\n ; _∘_ = flip trans\n ; _⁻¹ = sym\n\n ; left-identity = trans-reflʳ\n ; right-identity = trans-reflˡ\n ; assoc = λ z≡u y≡z x≡y → trans-assoc x≡y y≡z z≡u\n ; left-inverse = trans-symʳ\n ; right-inverse = trans-symˡ\n }\n\n------------------------------------------------------------------------\n-- In some cases transitivity is commutative\n\n-- This proof is based on an informal proof due to Thierry Coquand,\n-- based on a result from homotopy theory.\n\nmodule Transitivity-commutative\n {a} {A : Type a} (e : A) (_∙_ : A → A → A)\n (left-identity : ∀ x → (e ∙ x) ≡ x)\n (right-identity : ∀ x → (x ∙ e) ≡ x)\n where\n\n open Groupoid (groupoid A) hiding (left-identity; right-identity)\n\n abstract\n\n commutative : (p q : e ≡ e) → p ∘ q ≡ q ∘ p\n commutative p q =\n p ∘ q ≡⟨ cong (_∘_ p) (lem₁ _) ⟩\n p ∘ (ri ∘ li ⁻¹ ∘ q′ ∘ li ∘ ri ⁻¹) ≡⟨ prove (Trans (Trans (Trans (Trans (Trans (Sym (Lift ri)) (Lift li)) (Lift q′))\n (Sym (Lift li))) (Lift ri)) (Lift p))\n (Trans (Trans (Sym (Lift ri))\n (Trans (Trans (Lift li) (Lift q′)) (Sym (Lift li))))\n (Trans (Lift ri) (Lift p)))\n (refl _) ⟩\n (p ∘ ri) ∘ (li ⁻¹ ∘ q′ ∘ li) ∘ ri ⁻¹ ≡⟨ cong₂ (λ p q → p ∘ q ∘ ri ⁻¹) (lem₂ _) (lem₃ _) ⟩\n (ri ∘ lc p) ∘ rc q′ ∘ ri ⁻¹ ≡⟨ prove (Trans (Trans (Sym (Lift ri)) (Lift (rc q′))) (Trans (Lift (lc p)) (Lift ri)))\n (Trans (Trans (Sym (Lift ri)) (Trans (Lift (rc q′)) (Lift (lc p)))) (Lift ri))\n (refl _) ⟩\n ri ∘ (lc p ∘ rc q′) ∘ ri ⁻¹ ≡⟨ cong (λ p → ri ∘ p ∘ ri ⁻¹) (lem₄ _ _) ⟩\n ri ∘ (rc q′ ∘ lc p) ∘ ri ⁻¹ ≡⟨ prove (Trans (Trans (Sym (Lift ri)) (Trans (Lift (lc p)) (Lift (rc q′)))) (Lift ri))\n (Trans (Trans (Trans (Sym (Lift ri)) (Lift (lc p))) (Lift (rc q′))) (Lift ri))\n (refl _) ⟩\n ri ∘ rc q′ ∘ (lc p ∘ ri ⁻¹) ≡⟨ cong₂ (λ p q → ri ∘ p ∘ q) (sym (lem₃ _)) (lem₅ _) ⟩\n ri ∘ (li ⁻¹ ∘ q′ ∘ li) ∘ (ri ⁻¹ ∘ p) ≡⟨ prove (Trans (Trans (Trans (Lift p) (Sym (Lift ri)))\n (Trans (Trans (Lift li) (Lift q′)) (Sym (Lift li))))\n (Lift ri))\n (Trans (Lift p) (Trans (Trans (Trans (Trans (Sym (Lift ri)) (Lift li)) (Lift q′))\n (Sym (Lift li)))\n (Lift ri)))\n (refl _) ⟩\n (ri ∘ li ⁻¹ ∘ q′ ∘ li ∘ ri ⁻¹) ∘ p ≡⟨ cong (λ q → q ∘ p) (sym (lem₁ _)) ⟩∎\n q ∘ p ∎\n where\n\n -- Abbreviations.\n\n li : ∀ {x} → (e ∙ x) ≡ x\n li = left-identity _\n\n ri : ∀ {x} → (x ∙ e) ≡ x\n ri = right-identity _\n\n q′ : e ≡ e\n q′ = li ∘ ri ⁻¹ ∘ q ∘ ri ∘ li ⁻¹\n\n lc : ∀ {x y} → x ≡ y → (x ∙ e) ≡ (y ∙ e)\n lc = cong (λ x → (x ∙ e))\n\n rc : ∀ {x y} → x ≡ y → (e ∙ x) ≡ (e ∙ y)\n rc = cong (λ y → (e ∙ y))\n\n -- Lemmas.\n\n lem₁ : (p : e ≡ e) →\n p ≡ ri ∘ li ⁻¹ ∘ (li ∘ ri ⁻¹ ∘ p ∘ ri ∘ li ⁻¹) ∘ li ∘ ri ⁻¹\n lem₁ p =\n p ≡⟨ prove (Lift p) (Trans (Trans Refl (Lift p)) Refl) (refl _) ⟩\n refl _ ∘ p ∘ refl _ ≡⟨ sym (cong₂ (λ q r → q ∘ p ∘ r)\n (right-inverse _) (right-inverse _)) ⟩\n (ri ∘ ri ⁻¹) ∘ p ∘ (ri ∘ ri ⁻¹) ≡⟨ prove (Trans (Trans (Trans (Sym (Lift ri)) (Lift ri)) (Lift p))\n (Trans (Sym (Lift ri)) (Lift ri)))\n (Trans (Trans (Trans (Trans (Trans (Trans\n (Sym (Lift ri)) Refl) (Lift ri)) (Lift p))\n (Sym (Lift ri))) Refl) (Lift ri))\n (refl _) ⟩\n ri ∘ refl _ ∘ ri ⁻¹ ∘ p ∘ ri ∘ refl _ ∘ ri ⁻¹ ≡⟨ sym (cong₂ (λ q r → ri ∘ q ∘ ri ⁻¹ ∘ p ∘ ri ∘ r ∘ ri ⁻¹)\n (left-inverse _) (left-inverse _)) ⟩\n ri ∘ (li ⁻¹ ∘ li) ∘ ri ⁻¹ ∘ p ∘ ri ∘ (li ⁻¹ ∘ li) ∘ ri ⁻¹ ≡⟨ prove (Trans (Trans (Trans (Trans (Trans (Trans\n (Sym (Lift ri)) (Trans (Lift li) (Sym (Lift li))))\n (Lift ri)) (Lift p)) (Sym (Lift ri)))\n (Trans (Lift li) (Sym (Lift li)))) (Lift ri))\n (Trans (Trans (Trans (Trans\n (Sym (Lift ri)) (Lift li))\n (Trans (Trans (Trans (Trans\n (Sym (Lift li)) (Lift ri)) (Lift p)) (Sym (Lift ri)))\n (Lift li))) (Sym (Lift li))) (Lift ri))\n (refl _) ⟩∎\n ri ∘ li ⁻¹ ∘ (li ∘ ri ⁻¹ ∘ p ∘ ri ∘ li ⁻¹) ∘ li ∘ ri ⁻¹ ∎\n\n lem₂ : ∀ {x y} (p : x ≡ y) → p ∘ ri ≡ ri ∘ lc p\n lem₂ = elim (λ p → p ∘ ri ≡ ri ∘ lc p) λ _ →\n prove (Trans (Lift ri) Refl)\n (Trans (Cong (λ x → (x ∙ e)) Refl) (Lift ri))\n (refl _)\n\n lem₃ : ∀ {x y} (p : x ≡ y) → li ⁻¹ ∘ p ∘ li ≡ rc p\n lem₃ = elim (λ p → li ⁻¹ ∘ p ∘ li ≡ rc p) λ x →\n li ⁻¹ ∘ refl x ∘ li ≡⟨ prove (Trans (Trans (Lift li) Refl) (Sym (Lift li)))\n (Trans (Lift li) (Sym (Lift li)))\n (refl _) ⟩\n li ⁻¹ ∘ li ≡⟨ left-inverse _ ⟩\n refl (e ∙ x) ≡⟨ prove Refl (Cong (λ y → (e ∙ y)) Refl) (refl _) ⟩∎\n rc (refl x) ∎\n\n lem₄ : (p q : e ≡ e) → lc p ∘ rc q ≡ rc q ∘ lc p\n lem₄ p q = elim\n (λ {x y} x≡y → lc x≡y ∘ cong (λ z → (x ∙ z)) q ≡\n cong (λ z → (y ∙ z)) q ∘ lc x≡y)\n (λ x → prove (Trans (Cong (λ z → x ∙ z) (Lift q))\n (Cong (λ x → x ∙ e) Refl))\n (Trans (Cong (λ x → x ∙ e) Refl)\n (Cong (λ z → x ∙ z) (Lift q)))\n (refl _))\n p\n\n lem₅ : ∀ {x y} (p : x ≡ y) → lc p ∘ ri ⁻¹ ≡ ri ⁻¹ ∘ p\n lem₅ = elim (λ p → lc p ∘ ri ⁻¹ ≡ ri ⁻¹ ∘ p) λ _ →\n prove (Trans (Sym (Lift ri)) (Cong (λ x → (x ∙ e)) Refl))\n (Trans Refl (Sym (Lift ri)))\n (refl _)\n\n-- In particular, transitivity is commutative for proofs in\n-- proj₁ (Ω[ 2 + n ] X).\n\nΩ[2+n]-commutative :\n ∀ {x} {X : Pointed-type x} n →\n (p q : proj₁ (Ω[ 2 + n ] X)) → trans p q ≡ trans q p\nΩ[2+n]-commutative {X = X} n p q =\n Transitivity-commutative.commutative\n id _∘_ left-identity right-identity q p\n where\n open Groupoid (groupoid (proj₁ (Ω[ n ] X)))\n", "meta": {"hexsha": "19487340df17ceacb6700c8808a3e7ab2be3d724", "size": 8810, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Equality/Groupoid.agda", "max_stars_repo_name": "nad/equality", "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_issues_repo_path": "src/Equality/Groupoid.agda", "max_issues_repo_name": "nad/equality", "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Equality/Groupoid.agda", "max_forks_repo_name": "nad/equality", "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.2209302326, "max_line_length": 135, "alphanum_fraction": 0.3328036322, "num_tokens": 2694, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8499711870587668, "lm_q2_score": 0.7185943925708561, "lm_q1q2_score": 0.6107845288672241}} {"text": "module Data.Collection.Equivalence where\n\nopen import Data.Collection.Core\n\nopen import Function using (id; _∘_)\nopen import Function.Equality using (_⟨$⟩_)\nopen import Function.Equivalence using (_⇔_; equivalence)\nopen Function.Equivalence.Equivalence\nopen import Relation.Binary.PropositionalEquality\n\n\nopen import Level using (zero)\n\nopen import Relation.Nullary\nopen import Relation.Unary\nopen import Relation.Binary\n\nnach : ∀ {f t} {A : Set f} {B : Set t} → (A ⇔ B) → A → B\nnach = _⟨$⟩_ ∘ to\n\nvon : ∀ {f t} {A : Set f} {B : Set t} → (A ⇔ B) → B → A\nvon = _⟨$⟩_ ∘ from\n\n\ninfixr 5 _≋_\n\n_≋_ : Rel Membership _\nA ≋ B = {x : Element} → x ∈ A ⇔ x ∈ B\n\n≋-Reflexive : Reflexive _≋_\n≋-Reflexive = equivalence id id\n\n≋-Symmetric : Symmetric _≋_\n≋-Symmetric z = record\n { to = from z\n ; from = to z\n }\n\n≋-Transitive : Transitive _≋_\n≋-Transitive P≋Q Q≋R = equivalence (nach Q≋R ∘ nach P≋Q) (von P≋Q ∘ von Q≋R)\n\n≋-IsEquivalence : IsEquivalence _≋_\n≋-IsEquivalence = record\n { refl = equivalence id id\n ; sym = ≋-Symmetric\n ; trans = ≋-Transitive\n }\n\n≋-Setoid : Setoid _ _\n≋-Setoid = record\n { Carrier = Pred Element zero\n ; _≈_ = _≋_\n ; isEquivalence = ≋-IsEquivalence\n }\n\n--------------------------------------------------------------------------------\n-- Conditional Equivalence\n--------------------------------------------------------------------------------\n\n_≋[_]_ : ∀ {a} → Membership → Pred Element a → Membership → Set a\nA ≋[ P ] B = {x : Element} → P x → x ∈ A ⇔ x ∈ B\n\n-- prefix version of _≋[_]_, with the predicate being the first argument\n[_]≋ : ∀ {a} → Pred Element a → Membership → Membership → Set a\n[_]≋ P A B = A ≋[ P ] B\n\n≋[]-Reflexive : ∀ {a} {P : Pred Element a} → Reflexive [ P ]≋\n≋[]-Reflexive A = equivalence id id\n\n≋[]-Symmetric : ∀ {a} {P : Pred Element a} → Symmetric [ P ]≋\n≋[]-Symmetric z ∈P = record\n { to = from (z ∈P)\n ; from = to (z ∈P)\n }\n\n≋[]-Transitive : ∀ {a} {P : Pred Element a} → Transitive [ P ]≋\n≋[]-Transitive P≋Q Q≋R ∈P = equivalence (nach (Q≋R ∈P) ∘ nach (P≋Q ∈P)) (von (P≋Q ∈P) ∘ von (Q≋R ∈P))\n\n≋[]-IsEquivalence : ∀ {a} {P : Pred Element a} → IsEquivalence [ P ]≋\n≋[]-IsEquivalence {p} = record\n { refl = λ _ → equivalence id id\n ; sym = ≋[]-Symmetric\n ; trans = ≋[]-Transitive\n }\n", "meta": {"hexsha": "2fcfa3f6ed97b0f21b28f47d89fa793270e01fdc", "size": 2278, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Collection/Equivalence.agda", "max_stars_repo_name": "banacorn/lambda-calculus", "max_stars_repo_head_hexsha": "f81b116473582ab7956adc4bf1d7ebf1ae2a213a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Data/Collection/Equivalence.agda", "max_issues_repo_name": "banacorn/lambda-calculus", "max_issues_repo_head_hexsha": "f81b116473582ab7956adc4bf1d7ebf1ae2a213a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Collection/Equivalence.agda", "max_forks_repo_name": "banacorn/lambda-calculus", "max_forks_repo_head_hexsha": "f81b116473582ab7956adc4bf1d7ebf1ae2a213a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.8, "max_line_length": 101, "alphanum_fraction": 0.559262511, "num_tokens": 822, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711756575749, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.6107845257967607}} {"text": "-- {-# OPTIONS -v tc.size.solve:100 #-}\n\nopen import Agda.Builtin.Size\n\ndata Cx (U : Set) : Set where\n ⌀ : Cx U\n _,_ : Cx U → U → Cx U\n\nmodule _ {U : Set} where\n data _⊆_ : Cx U → Cx U → Set where\n done : ⌀ ⊆ ⌀\n skip : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊆ (Γ′ , A)\n keep : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → (Γ , A) ⊆ (Γ′ , A)\n\n data _∈_ (A : U) : Cx U → Set where\n top : ∀ {Γ} → A ∈ (Γ , A)\n pop : ∀ {C Γ} → A ∈ Γ → A ∈ (Γ , C)\n\n mono∈ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → A ∈ Γ → A ∈ Γ′\n mono∈ done ()\n mono∈ (skip η) i = pop (mono∈ η i)\n mono∈ (keep η) top = top\n mono∈ (keep η) (pop i) = pop (mono∈ η i)\n\n refl⊆ : ∀ {Γ} → Γ ⊆ Γ\n refl⊆ {⌀} = done\n refl⊆ {Γ , A} = keep refl⊆\n\ninfixr 3 _⊃_\ndata Ty : Set where\n ι : Ty\n _⊃_ : Ty → Ty → Ty\n\ninfix 1 _⊢⟨_⟩_\ndata _⊢⟨_⟩_ (Γ : Cx Ty) : Size → Ty → Set where\n var : ∀ {p A} → A ∈ Γ → Γ ⊢⟨ p ⟩ A\n lam : ∀ {n A B} {o : Size< n} → Γ , A ⊢⟨ o ⟩ B → Γ ⊢⟨ n ⟩ A ⊃ B\n app : ∀ {m A B} {l k : Size< m} → Γ ⊢⟨ k ⟩ A ⊃ B → Γ ⊢⟨ l ⟩ A → Γ ⊢⟨ m ⟩ B\n\nmono⊢ : ∀ {m A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢⟨ m ⟩ A → Γ′ ⊢⟨ m ⟩ A\nmono⊢ η (var i) = var (mono∈ η i)\nmono⊢ η (lam t) = lam (mono⊢ (keep η) t)\nmono⊢ η (app t u) = app (mono⊢ η t) (mono⊢ η u)\n\ndet : ∀ {i A B Γ} {j : Size< i} → Γ ⊢⟨ j ⟩ A ⊃ B → Γ , A ⊢⟨ i ⟩ B\ndet t = app (mono⊢ (skip refl⊆) t) (var top)\n\nccont : ∀ {m A B Γ} → Γ ⊢⟨ ↑ ↑ ↑ ↑ m ⟩ (A ⊃ A ⊃ B) ⊃ A ⊃ B\nccont = lam (lam (app (app (var (pop top)) (var top)) (var top)))\n\ncont : ∀ {m A B Γ} {m′ : Size< m} → (Γ , A) , A ⊢⟨ ↑ ↑ m′ ⟩ B → Γ , A ⊢⟨ ↑ ↑ ↑ ↑ ↑ m ⟩ B\ncont t = det (app ccont (lam (lam t)))\n\ncont′ : ∀ {q A B Γ} {r : Size< q} → (Γ , A) , A ⊢⟨ {!q!} ⟩ B → Γ , A ⊢⟨ {!!} ⟩ B\ncont′ t = det (app ccont (lam (lam t)))\n", "meta": {"hexsha": "e6911f55ed4785c25e0f69f4b9fe1fb2b251065f", "size": 1695, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue2096.agda", "max_stars_repo_name": "pthariensflame/agda", "max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/interaction/Issue2096.agda", "max_issues_repo_name": "pthariensflame/agda", "max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/interaction/Issue2096.agda", "max_forks_repo_name": "pthariensflame/agda", "max_forks_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.2678571429, "max_line_length": 88, "alphanum_fraction": 0.4005899705, "num_tokens": 923, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774767906859265, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.6106872775015069}} {"text": "module VecSN where\r\n\r\nopen import Data.Bool\r\n\r\ninfixr 20 _◎_\r\n\r\n------------------------------------------------------------------------------\r\n-- fix a field F_3 = {0, 1, -1} \r\n-- types B (ZERO,ONE,PLUS,TIMES) determine the DIMENSION of a vector space over F_3\r\n-- values of type B are INDICES for B-dimensional vectors\r\n-- we do not allow superpositions (we have AT MOST one entry in the\r\n-- vector that is non-zero), so we can identify the INDICES with the vectors\r\n--\r\n-- in particular: \r\n-- - ZERO is not the empty type! it is like the 0-dimensional vector space\r\n-- (i.e, the type containing one \"annihilating value\")\r\n-- - ONE is like a 1-dimensional vector space; it is isomorphic to \r\n-- the scalars (0,+1,-1)\r\n-- - PLUS gives the direct sum of vector spaces (dimension is the sum)\r\n-- - TIMES gives the tensor product of vector spaces (dimension is the product)\r\n-- - DUAL gives the dual space (functionals that map vectors to scalars; i.e.\r\n-- that maps values to scalars)\r\n\r\ndata B : Set where\r\n ZERO : B\r\n ONE : B\r\n PLUS : B → B → B \r\n TIMES : B → B → B \r\n DUAL : B → B\r\n\r\n-- now we describe the vectors for each B-dimensional vector space\r\n-- the zero vector is everywhere\r\n\r\ndata BVAL : B → Set where\r\n zero : {b : B} → BVAL b\r\n unit : BVAL ONE\r\n left : {b₁ b₂ : B} → BVAL b₁ → BVAL (PLUS b₁ b₂)\r\n right : {b₁ b₂ : B} → BVAL b₂ → BVAL (PLUS b₁ b₂)\r\n pair : {b₁ b₂ : B} → BVAL b₁ → BVAL b₂ → BVAL (TIMES b₁ b₂)\r\n dual : {b : B} → BVAL b → BVAL (DUAL b)\r\n\r\n-- syntactic equality on vectors\r\n\r\nb= : { b : B } → BVAL b → BVAL b → Bool\r\nb= zero zero = true\r\nb= unit unit = true\r\nb= (left v₁) (left v₂) = b= v₁ v₂\r\nb= (right v₁) (right v₂) = b= v₁ v₂\r\nb= (pair v₁ v₂) (pair v₁' v₂') = b= v₁ v₁' ∧ b= v₂ v₂'\r\nb= (dual v₁) (dual v₂) = b= v₁ v₂\r\nb= _ _ = false\r\n\r\ndata Iso : B → B → Set where\r\n -- (+,0) commutative monoid\r\n unite₊ : { b : B } → Iso (PLUS ZERO b) b\r\n uniti₊ : { b : B } → Iso b (PLUS ZERO b)\r\n swap₊ : { b₁ b₂ : B } → Iso (PLUS b₁ b₂) (PLUS b₂ b₁)\r\n assocl₊ : { b₁ b₂ b₃ : B } → Iso (PLUS b₁ (PLUS b₂ b₃)) (PLUS (PLUS b₁ b₂) b₃)\r\n assocr₊ : { b₁ b₂ b₃ : B } → Iso (PLUS (PLUS b₁ b₂) b₃) (PLUS b₁ (PLUS b₂ b₃))\r\n -- (*,1) commutative monoid\r\n unite⋆ : { b : B } → Iso (TIMES ONE b) b\r\n uniti⋆ : { b : B } → Iso b (TIMES ONE b)\r\n swap⋆ : { b₁ b₂ : B } → Iso (TIMES b₁ b₂) (TIMES b₂ b₁)\r\n assocl⋆ : { b₁ b₂ b₃ : B } → Iso (TIMES b₁ (TIMES b₂ b₃)) (TIMES (TIMES b₁ b₂) b₃)\r\n assocr⋆ : { b₁ b₂ b₃ : B } → Iso (TIMES (TIMES b₁ b₂) b₃) (TIMES b₁ (TIMES b₂ b₃))\r\n -- * distributes over + \r\n dist : { b₁ b₂ b₃ : B } → \r\n Iso (TIMES (PLUS b₁ b₂) b₃) (PLUS (TIMES b₁ b₃) (TIMES b₂ b₃))\r\n factor : { b₁ b₂ b₃ : B } → \r\n Iso (PLUS (TIMES b₁ b₃) (TIMES b₂ b₃)) (TIMES (PLUS b₁ b₂) b₃)\r\n -- closure\r\n id⟷ : { b : B } → Iso b b\r\n sym : { b₁ b₂ : B } → Iso b₁ b₂ → Iso b₂ b₁\r\n _◎_ : { b₁ b₂ b₃ : B } → Iso b₁ b₂ → Iso b₂ b₃ → Iso b₁ b₃\r\n _⊕_ : { b₁ b₂ b₃ b₄ : B } → \r\n Iso b₁ b₃ → Iso b₂ b₄ → Iso (PLUS b₁ b₂) (PLUS b₃ b₄)\r\n _⊗_ : { b₁ b₂ b₃ b₄ : B } → \r\n Iso b₁ b₃ → Iso b₂ b₄ → Iso (TIMES b₁ b₂) (TIMES b₃ b₄)\r\n -- multiplicative duality\r\n refe⋆ : { b : B } → Iso (DUAL (DUAL b)) b\r\n refi⋆ : { b : B } → Iso b (DUAL (DUAL b))\r\n rile⋆ : { b : B } → Iso (TIMES b (TIMES b (DUAL b))) b\r\n rili⋆ : { b : B } → Iso b (TIMES b (TIMES b (DUAL b)))\r\n -- negatives: we have a circuit that requires the value to choose\r\n -- the incoming value : b₁ can go left or right\r\n choose : { b₁ b₂ : B } → Iso b₁ b₂ → Iso b₁ b₂ → Iso b₁ b₂ \r\n\r\nmutual \r\n\r\n eval : {b₁ b₂ : B} → Iso b₁ b₂ → BVAL b₁ → BVAL b₂\r\n eval unite₊ (left _) = zero\r\n eval unite₊ (right v) = v\r\n eval uniti₊ v = right v\r\n eval swap₊ (left v) = right v\r\n eval swap₊ (right v) = left v\r\n eval assocl₊ (left v) = left (left v)\r\n eval assocl₊ (right (left v)) = left (right v)\r\n eval assocl₊ (right (right v)) = right v\r\n eval assocr₊ (left (left v)) = left v\r\n eval assocr₊ (left (right v)) = right (left v)\r\n eval assocr₊ (right v) = right (right v)\r\n eval unite⋆ (pair unit v) = v\r\n eval uniti⋆ v = pair unit v\r\n eval swap⋆ (pair v1 v2) = pair v2 v1\r\n eval assocl⋆ (pair v1 (pair v2 v3)) = pair (pair v1 v2) v3\r\n eval assocr⋆ (pair (pair v1 v2) v3) = pair v1 (pair v2 v3)\r\n eval dist (pair (left v1) v3) = left (pair v1 v3)\r\n eval dist (pair (right v2) v3) = right (pair v2 v3)\r\n eval factor (left (pair v1 v3)) = pair (left v1) v3\r\n eval factor (right (pair v2 v3)) = pair (right v2) v3\r\n eval id⟷ v = v\r\n eval (sym c) v = evalB c v\r\n eval (c₁ ◎ c₂) v = eval c₂ (eval c₁ v)\r\n eval (c₁ ⊕ c₂) (left v) = left (eval c₁ v)\r\n eval (c₁ ⊕ c₂) (right v) = right (eval c₂ v)\r\n eval (c₁ ⊗ c₂) (pair v₁ v₂) = pair (eval c₁ v₁) (eval c₂ v₂)\r\n eval refe⋆ (dual (dual v)) = v\r\n eval refi⋆ v = dual (dual v)\r\n eval rile⋆ (pair v (pair v₁ (dual v₂))) with b= v₁ v₂\r\n eval rile⋆ (pair v (pair v₁ (dual v₂))) | true = v\r\n eval rile⋆ (pair v (pair v₁ (dual v₂))) | false = zero\r\n eval rili⋆ v = pair v (pair v (dual v))\r\n-- choose : { b₁ b₂ : B } → Iso b₁ b₂ → Iso b₁ b₂ → Iso b₁ b₂ \r\n eval (choose c₁ c₂) v = {!!} \r\n eval _ _ = zero\r\n\r\n evalB : {b₁ b₂ : B} → Iso b₁ b₂ → BVAL b₂ → BVAL b₁\r\n evalB unite₊ v = right v\r\n evalB uniti₊ (left _) = zero\r\n evalB uniti₊ (right v) = v\r\n evalB swap₊ (left v) = right v\r\n evalB swap₊ (right v) = left v\r\n evalB assocl₊ (left (left v)) = left v\r\n evalB assocl₊ (left (right v)) = right (left v)\r\n evalB assocl₊ (right v) = right (right v)\r\n evalB assocr₊ (left v) = left (left v)\r\n evalB assocr₊ (right (left v)) = left (right v)\r\n evalB assocr₊ (right (right v)) = right v\r\n evalB unite⋆ v = pair unit v\r\n evalB uniti⋆ (pair unit v) = v\r\n evalB swap⋆ (pair v1 v2) = pair v2 v1\r\n evalB assocl⋆ (pair (pair v1 v2) v3) = pair v1 (pair v2 v3)\r\n evalB assocr⋆ (pair v1 (pair v2 v3)) = pair (pair v1 v2) v3\r\n evalB dist (left (pair v1 v3)) = pair (left v1) v3\r\n evalB dist (right (pair v2 v3)) = pair (right v2) v3\r\n evalB factor (pair (left v1) v3) = left (pair v1 v3)\r\n evalB factor (pair (right v2) v3) = right (pair v2 v3)\r\n evalB id⟷ v = v\r\n evalB (sym c) v = eval c v\r\n evalB (c₁ ◎ c₂) v = evalB c₁ (evalB c₂ v)\r\n evalB (c₁ ⊕ c₂) (left v) = left (evalB c₁ v)\r\n evalB (c₁ ⊕ c₂) (right v) = right (evalB c₂ v)\r\n evalB (c₁ ⊗ c₂) (pair v₁ v₂) = pair (evalB c₁ v₁) (evalB c₂ v₂)\r\n evalB refe⋆ v = dual (dual v)\r\n evalB refi⋆ (dual (dual v)) = v\r\n evalB rile⋆ v = pair v (pair v (dual v))\r\n evalB rili⋆ (pair v (pair v₁ (dual v₂))) with b= v₁ v₂\r\n evalB rili⋆ (pair v (pair v₁ (dual v₂))) | true = v\r\n evalB rili⋆ (pair v (pair v₁ (dual v₂))) | false = zero\r\n evalB _ _ = zero\r\n\r\n------------------------------------------------------------------------------\r\n-- example with duals\r\n\r\npibool : B\r\npibool = PLUS ONE ONE\r\n\r\npitrue : BVAL pibool\r\npitrue = left unit\r\n\r\npifalse : BVAL pibool\r\npifalse = right unit\r\n\r\n-- swap clause 1 = (T => F)\r\nclause1 : BVAL (TIMES (DUAL pibool) pibool)\r\nclause1 = pair (dual pitrue) pifalse\r\n\r\n-- swap clause 2 = (F => T)\r\nclause2 : BVAL (TIMES (DUAL pibool) pibool)\r\nclause2 = pair (dual pifalse) pitrue\r\n\r\n-- swap clause 1 applied to true\r\nex1 : BVAL (TIMES pibool (TIMES (DUAL pibool) pibool))\r\nex1 = pair pitrue clause1\r\n\r\n-- swap clause 1 applied to false\r\nex2 : BVAL (TIMES pibool (TIMES (DUAL pibool) pibool))\r\nex2 = pair pifalse clause1\r\n\r\n-- swap clause 1 applied to true\r\nex3 : BVAL (TIMES pibool (TIMES (DUAL pibool) pibool))\r\nex3 = pair pitrue clause2\r\n\r\n-- swap clause 1 applied to false\r\nex4 : BVAL (TIMES pibool (TIMES (DUAL pibool) pibool))\r\nex4 = pair pifalse clause2\r\n\r\n-- applies one of the clauses to a value \r\nc : Iso (TIMES pibool (TIMES (DUAL pibool) pibool)) pibool\r\nc = -- (v,(1/t,f))\r\n assocl⋆ ◎ -- ((v,1/t),f)\r\n swap⋆ ◎ -- (f,(v,1/t))\r\n rile⋆ -- f or zero\r\n\r\n-- \r\nv1 = eval c ex1\r\nv2 = eval c ex2\r\nv3 = eval c ex3\r\nv4 = eval c ex4\r\n\r\n-- generalize\r\n\r\n-- applies one of the clauses of a function : b -> b to a value : b\r\napply : {b : B} → Iso (TIMES b (TIMES (DUAL b) b)) b\r\napply = assocl⋆ ◎ swap⋆ ◎ rile⋆\r\n\r\n\r\n\r\n{--\r\nwant:\r\n\r\nvalue is True\r\nin parallel apply clause1 to value and apply clause2 to value\r\none of these will return False and the other will return zero\r\nmerge the results to get False\r\n\r\nbetter:\r\n\r\nvalue is True\r\nwe create a new logic variable ALPHA which can be unified with either clause1 or clause2\r\nwe create a value (ALPHA - ALPHA) which we apply to evaluate \r\n\r\n\r\n--}\r\n\r\n------------------------------------------------------------------------------\r\n", "meta": {"hexsha": "7fa1bf113127a7b2c5ae5617b730614ab48613ff", "size": 8541, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/VecSN.agda", "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_issues_repo_path": "agda/VecSN.agda", "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_forks_repo_path": "agda/VecSN.agda", "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "avg_line_length": 36.0379746835, "max_line_length": 89, "alphanum_fraction": 0.5682004449, "num_tokens": 3418, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774768002981829, "lm_q2_score": 0.6959583124210896, "lm_q1q2_score": 0.6106872731241808}} {"text": "{-\n\n Types Summer School 2007\n\n Bertinoro\n Aug 19 - 31, 2007\n\n\n Agda\n\n Ulf Norell\n\n-}\n\n{-\n\n Learn more about Agda on the Agda wiki:\n\n http://www.cs.chalmers.se/~ulfn/Agda\n\n This is where you find the exercises for the afternoon.\n\n-}\n\n-- Each Agda file contains a top-level module, whose\n-- name corresponds to the file name.\n\nmodule Basics where\n\n{-\n\n Expressions (types and terms)\n\n-}\n\n-- The expression language of Agda is your favorite dependently\n-- typed λ-calculus.\n\n-- For instance:\nid₁ : (A : Set) -> A -> A\nid₁ = \\ A x -> x\n\nid₂ : (A : Set) -> A -> A\nid₂ = \\ A x -> id₁ A (id₁ A x)\n\n-- Note: Agda likes white space. This is not correct:\n-- id:(A:Set)->A->A\n\n-- Why not? In Agda the following strings are valid identifiers:\n-- id:\n-- A:Set\n-- ->A->A\n\n-- Another useful function, featuring telescopes\n-- and typed λs.\ncompose : (A B C : Set) -> (B -> C) -> (A -> B) -> A -> C\ncompose = \\(A B C : Set) f g x -> f (g x)\n\ncompose' : (A B : Set)(C : B -> Set)\n (f : (x : B) -> C x)(g : A -> B) ->\n (x : A) -> C (g x)\ncompose' = \\A B C f g x -> f (g x)\n\n{-\n\n Implicit arguments\n\n-}\n\n-- Writing down type arguments explicitly soon gets old.\n-- Enter implicit arguments.\n\n-- Note the curlies in the telescope. And A mysteriously disappeares\n-- in the definition.\nid₃ : {A : Set} -> A -> A\nid₃ = \\ x -> x\n\n-- And it's not there when applying the function.\nid₄ : {A : Set} -> A -> A\nid₄ = \\ x -> (id₃ (id₃ x))\n\n-- If you think the type checker should figure out the value of\n-- something explicit, you write _.\nid₆ : {A : Set} -> A -> A\nid₆ x = id₁ _ x\n\n-- Interesting though it is, eventually you'll get bored\n-- with the λ-calculus...\n\n-- Move on to: Datatypes.agda\n", "meta": {"hexsha": "8c5e08ebe8e50a82b9ac4f88a7cce743acc79d05", "size": 1771, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/SummerSchool07/Lecture/Basics.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/SummerSchool07/Lecture/Basics.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/SummerSchool07/Lecture/Basics.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 19.4615384615, "max_line_length": 68, "alphanum_fraction": 0.5753811406, "num_tokens": 556, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152324983301568, "lm_q2_score": 0.7490872243177518, "lm_q1q2_score": 0.6106802493477633}} {"text": "module Common where\n\nopen import Data.Bool\nopen import Data.Maybe\nopen import Data.Sum\nopen import Data.Product\n\n\nBoolQ : Set₁\nBoolQ = (A : Set) -> A -> A -> A\n\nunBoolQ : {A : Set} -> A -> A -> BoolQ -> A\nunBoolQ a a' q = q _ a a'\n\ntrueQ : BoolQ\ntrueQ = \\_ a a' -> a\n\nfalseQ : BoolQ\nfalseQ = \\_ a a' -> a'\n\nfromBoolQ : BoolQ -> Bool\nfromBoolQ q = unBoolQ true false q\n\ntoBoolQ : Bool -> BoolQ\ntoBoolQ true = trueQ\ntoBoolQ false = falseQ\n\n\nMaybeQ : Set -> Set₁\nMaybeQ A = (B : Set) -> (A -> B) -> B -> B\n\nunMaybeQ : {A B : Set} -> (A -> B) -> B -> MaybeQ A -> B\nunMaybeQ f b q = q _ f b\n\njustQ : {A : Set} -> A -> MaybeQ A\njustQ a = \\_ f b -> f a\n\nnothingQ : {A : Set} -> MaybeQ A\nnothingQ = \\_ f b -> b\n\nfromMaybeQ : {A : Set} -> MaybeQ A -> Maybe A\nfromMaybeQ q = unMaybeQ just nothing q\n\ntoMaybeQ : {A : Set} -> Maybe A -> MaybeQ A\ntoMaybeQ (just a) = justQ a\ntoMaybeQ nothing = nothingQ\n\n\nEitherQ : Set -> Set -> Set₁\nEitherQ A B = (C : Set) -> (A -> C) -> (B -> C) -> C\n\nunEitherQ : {A B C : Set} -> (A -> C) -> (B -> C) -> EitherQ A B -> C\nunEitherQ f g q = q _ f g\n\nleftQ : {A B : Set} -> A -> EitherQ A B\nleftQ a = \\_ f g -> f a\n\nrightQ : {A B : Set} -> B -> EitherQ A B\nrightQ b = \\_ f g -> g b\n\nfromEitherQ : {A B : Set} -> EitherQ A B -> A ⊎ B\nfromEitherQ q = unEitherQ inj₁ inj₂ q\n\ntoEitherQ : {A B : Set} -> A ⊎ B -> EitherQ A B\ntoEitherQ (inj₁ a) = leftQ a\ntoEitherQ (inj₂ b) = rightQ b\n\n\nPairQ : Set -> Set -> Set₁\nPairQ A B = (C : Set) -> (A -> B -> C) -> C\n\nunPairQ : {A B C : Set} -> (A -> B -> C) -> PairQ A B -> C\nunPairQ f q = q _ f\n\npairQ : {A B : Set} -> A -> B -> PairQ A B\npairQ a b = \\_ f -> f a b\n\nfromPairQ : {A B : Set} -> PairQ A B -> A × B\nfromPairQ q = unPairQ (\\a b -> (a , b)) q\n\ntoPairQ : {A B : Set} -> A × B -> PairQ A B\ntoPairQ (a , b) = pairQ a b\n\nfstQ : {A B : Set} -> PairQ A B -> A\nfstQ q = unPairQ (\\a b -> a) q\n\nsndQ : {A B : Set} -> PairQ A B -> B\nsndQ q = unPairQ (\\a b -> b) q\n", "meta": {"hexsha": "7a77f33f5fdcb611d02fbb5e2907c604feb9f072", "size": 1925, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-explicit/Common.agda", "max_stars_repo_name": "mietek/scott-encoding", "max_stars_repo_head_hexsha": "14e819383dd8730e1c3cbd9c2ce53335bd95188b", "max_stars_repo_licenses": ["X11", "MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-27T19:33:52.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-08T16:31:59.000Z", "max_issues_repo_path": "agda-explicit/Common.agda", "max_issues_repo_name": "mietek/scott-encoding", "max_issues_repo_head_hexsha": "14e819383dd8730e1c3cbd9c2ce53335bd95188b", "max_issues_repo_licenses": ["X11", "MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-explicit/Common.agda", "max_forks_repo_name": "mietek/scott-encoding", "max_forks_repo_head_hexsha": "14e819383dd8730e1c3cbd9c2ce53335bd95188b", "max_forks_repo_licenses": ["X11", "MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.6292134831, "max_line_length": 69, "alphanum_fraction": 0.5423376623, "num_tokens": 797, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152324983301568, "lm_q2_score": 0.749087201911703, "lm_q1q2_score": 0.6106802310816242}} {"text": "-- Example by Simon Huber\n\n{-# OPTIONS --cubical-compatible #-}\n\ndata _≡_ {A : Set} (a : A) : A → Set where\n refl : a ≡ a\n\nap : {A B : Set} (f : A → B) {a b : A} (p : a ≡ b) → f a ≡ f b\nap f refl = refl\n\n-- \\bub\n_•_ : {A : Set} {a b c : A} → a ≡ b → b ≡ c → a ≡ c\np • refl = p\n\ninfixr 30 _•_\n\n! : {A : Set} {a b : A} → a ≡ b → b ≡ a\n! refl = refl\n\n-- \\. (NB: not • aka \\bub)\n_∙_ : {A : Set} {B : A → Set}\n {f g : (a : A) → B a} →\n f ≡ g →\n (x : A) → f x ≡ g x\nrefl ∙ x = refl\n\ninfix 30 _∙_\n\ndotap : {A B : Set} {f g : A → B}\n (p : f ≡ g) (x : A)\n → p  ∙ x ≡ ap (λ F → F x) p\ndotap refl x = refl\n\napcomp : {A B C : Set} (f : B → C) (g : A → B)\n {x y : A} (p : x ≡ y)\n → ap (λ a → f (g a)) p ≡ ap f (ap g p)\napcomp f g refl = refl\n\n-- combinators for equality reasoning\n_≡⟨_⟩_ : {A : Set} (x : A) {y z : A} → x ≡ y → y ≡ z → x ≡ z\nx ≡⟨ p ⟩ q = p • q\n\ninfixr 2 _≡⟨_⟩_\n\n_□ : {A : Set} (x : A) → x ≡ x\nx □ = refl\n\nmodule Wrong (A B : Set) (a0 : A) where\n const : B → (A → B)\n const = λ x _ → x\n\n to : {x y : B} → x ≡ y → const x ≡ const y\n to = ap const\n\n from : {x y : B} → const x ≡ const y → x ≡ y\n from = ap (λ F → F a0)\n\n -- This lemma should not typecheck:\n lem : {x y : B} (p : const x ≡ const y) (a : A)\n → p ∙ a ≡ to (from p) ∙ a\n lem p a = p ∙ a\n ≡⟨ dotap p a ⟩\n ap (λ F → F a) p\n ≡⟨ refl ⟩\n ap (λ F → const (F a) a) p\n ≡⟨ apcomp _ _ p ⟩\n ap (λ G → G a) (ap (λ F → const (F a)) p)\n ≡⟨ ap (ap (λ G → G a)) (apcomp const (λ F → F a) p) ⟩\n ap(λ G → G a) (ap const (ap (λ (F : A → B) → F a) p))\n ≡⟨ ! (dotap (ap const (ap (λ F → F a) p)) a) ⟩\n (to (from p) ∙ a) □\n", "meta": {"hexsha": "17431420bf8f568fa5243e34d5552f66f4f8c9a3", "size": 1732, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/Issue2480.agda", "max_stars_repo_name": "KDr2/agda", "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/Fail/Issue2480.agda", "max_issues_repo_name": "KDr2/agda", "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_forks_repo_path": "test/Fail/Issue2480.agda", "max_forks_repo_name": "KDr2/agda", "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.0555555556, "max_line_length": 65, "alphanum_fraction": 0.3937644342, "num_tokens": 821, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8652240930029118, "lm_q2_score": 0.7057850216484837, "lm_q1q2_score": 0.6106622052108498}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties of products\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Product.Properties where\n\nopen import Data.Product\nopen import Function using (_∘_)\nopen import Relation.Binary using (Decidable)\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary.Product\nimport Relation.Nullary.Decidable as Dec\n\n------------------------------------------------------------------------\n-- Equality (dependent)\n\nmodule _ {a b} {A : Set a} {B : A → Set b} where\n\n ,-injectiveˡ : ∀ {a c} {b : B a} {d : B c} → (a , b) ≡ (c , d) → a ≡ c\n ,-injectiveˡ refl = refl\n\n -- See also Data.Product.Properties.WithK.,-injectiveʳ.\n\n------------------------------------------------------------------------\n-- Equality (non-dependent)\n\nmodule _ {a b} {A : Set a} {B : Set b} where\n\n ,-injectiveʳ : ∀ {a c : A} {b d : B} → (a , b) ≡ (c , d) → b ≡ d\n ,-injectiveʳ refl = refl\n\n ,-injective : ∀ {a c : A} {b d : B} → (a , b) ≡ (c , d) → a ≡ c × b ≡ d\n ,-injective refl = refl , refl\n\n ≡-dec : Decidable {A = A} _≡_ → Decidable {A = B} _≡_ →\n Decidable {A = A × B} _≡_\n ≡-dec dec₁ dec₂ (a , b) (c , d) =\n Dec.map′ (uncurry (cong₂ _,_)) ,-injective (dec₁ a c ×-dec dec₂ b d)\n", "meta": {"hexsha": "34e345c3fa464373d0e926d91f1d956d031e314b", "size": 1374, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/Product/Properties.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Data/Product/Properties.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Data/Product/Properties.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 31.9534883721, "max_line_length": 73, "alphanum_fraction": 0.4701601164, "num_tokens": 400, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8459424528443251, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.6105532182591178}} {"text": "------------------------------------------------------------------------------\n-- Well-founded induction on the lexicographic order on natural numbers\n------------------------------------------------------------------------------\n\n{-# OPTIONS --allow-unsolved-metas #-}\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- From the thesis: The induction principle $\\Conid{Lexi-wfind}$ is\n-- proved by well-founded induction on the usual order $\\Conid{LT}$ on\n-- (partial) natural numbers which, in turn, can be proved by pattern\n-- matching on the proof that the numbers are total.\n\nmodule FOT.FOTC.Data.Nat.Induction.NonAcc.LexicographicI where\n\nopen import FOTC.Base\nopen import FOTC.Data.Nat.Inequalities\nopen import FOTC.Data.Nat.Inequalities.EliminationPropertiesI\nopen import FOTC.Data.Nat.Inequalities.PropertiesI\n\nopen import FOTC.Data.Nat.Induction.NonAcc.WF-I\nopen module WFI = FOTC.Data.Nat.Induction.NonAcc.WF-I.WFInd\n\nopen import FOTC.Data.Nat.Type\n\n------------------------------------------------------------------------------\n\nLexi-wfind :\n (A : D → D → Set) →\n (∀ {m₁ n₁} → N m₁ → N n₁ →\n (∀ {m₂ n₂} → N m₂ → N n₂ → Lexi m₂ n₂ m₁ n₁ → A m₂ n₂) → A m₁ n₁) →\n ∀ {m n} → N m → N n → A m n\nLexi-wfind A h {m} Nm Nn = <-wfind {!!} {!!} {!!}\n", "meta": {"hexsha": "e17e6c48cb3157a95f0b325ab979cb67a5ef4ac1", "size": 1387, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/FOTC/Data/Nat/Induction/NonAcc/LexicographicI.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/FOT/FOTC/Data/Nat/Induction/NonAcc/LexicographicI.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/FOT/FOTC/Data/Nat/Induction/NonAcc/LexicographicI.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 38.5277777778, "max_line_length": 78, "alphanum_fraction": 0.5479452055, "num_tokens": 369, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.84594244507642, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.6105532177158188}} {"text": "-- labeled λ-calculus\n\nmodule IntrinsicallyTypedLLC where\n\nopen import Data.List\nopen import Data.List.Relation.Unary.All\nopen import Data.List.Base\nopen import Data.Vec hiding (_++_)\nopen import Data.Unit hiding (_≤_)\nopen import Data.Nat hiding (_≤_)\nopen import Data.Fin.Subset\nopen import Data.Fin.Subset.Properties\nopen import Data.Fin hiding (_≤_)\nopen import Data.Product\nopen import Data.Empty\nopen import Relation.Binary\n\n-- definitions\n\ndata Ty (nl : ℕ) : Set where -- nl ~ (max.) number of labels\n Tunit : Ty nl\n Tlabel : Subset nl → Ty nl\n Tfun : Ty nl → Ty nl → Ty nl\n\nTEnv : ℕ → Set\nTEnv nl = List (Ty nl)\n\ndata _≤_ {nl} : Ty nl → Ty nl → Set where\n Sunit : Tunit ≤ Tunit\n Slabel : ∀ {snl snl'} → snl ⊆ snl' → (Tlabel snl) ≤ (Tlabel snl')\n Sfun : ∀ {A A' B B'} → A' ≤ A → B ≤ B' → (Tfun A B) ≤ (Tfun A' B')\n\ndata _∈`_ {nl : ℕ} : Ty nl → TEnv nl → Set where\n here : ∀ {lt φ} → lt ∈` (lt ∷ φ)\n there : ∀ {lt lt' φ} → lt ∈` φ → lt ∈` (lt' ∷ φ)\n\ndata Exp {nl : ℕ} : TEnv nl → Ty nl → Set where\n Unit : ∀ {φ} → Exp φ Tunit\n Var : ∀ {φ t} → (x : t ∈` φ) → Exp φ t -- t ∈` φ gives us the position of \"x\" in env\n SubType : ∀ {A A' φ} → Exp φ A → A ≤ A'\n → Exp φ A'\n Lab-I : ∀ {l snl φ} → l ∈ snl → Exp φ (Tlabel snl)\n Lab-E : ∀ {snl φ B} → Exp φ (Tlabel snl)\n → (∀ l → l ∈ snl → Exp φ B) \n → Exp φ B\n Abs : ∀ {B A φ} → Exp (A ∷ φ) B\n → Exp φ (Tfun A B)\n App : ∀ {A B φ} → Exp φ (Tfun A B)\n → (ex : Exp φ A)\n → Exp φ B\n\n-- subtyping properties\n\n≤-trans : ∀ {nl} {t t' t'' : Ty nl} → t ≤ t' → t' ≤ t'' → t ≤ t''\n≤-trans Sunit Sunit = Sunit \n≤-trans (Slabel snl⊆snl') (Slabel snl'⊆snl'') = Slabel (⊆-trans snl⊆snl' snl'⊆snl'')\n≤-trans (Sfun a'≤a b≤b') (Sfun a''≤a' b'≤b'') = Sfun (≤-trans a''≤a' a'≤a) (≤-trans b≤b' b'≤b'')\n\n≤-refl : ∀ {nl} → (t : Ty nl) → t ≤ t\n≤-refl Tunit = Sunit\n≤-refl (Tlabel x) = Slabel (⊆-refl)\n≤-refl (Tfun t t') = Sfun (≤-refl t) (≤-refl t')\n \n-- big-step semantics\n\nVal : ∀ {nl} → Ty nl → Set\nVal Tunit = Data.Unit.⊤\nVal {nl} (Tlabel snl) = Σ (Fin nl) (λ l → l ∈ snl)\nVal (Tfun ty ty₁) = (Val ty) → (Val ty₁)\n\ncoerce : ∀ {nl} {t t' : Ty nl} → t ≤ t' → Val t → Val t' -- supertype of a Value is also a Value\ncoerce Sunit t = tt\ncoerce (Slabel snl⊆snl') (Finnl , Finnl∈snl) = (Finnl , (snl⊆snl' Finnl∈snl))\ncoerce (Sfun A'≤A B≤B') f = λ x → coerce B≤B' (f (coerce A'≤A x))\n\naccess : ∀ {nl} {t : Ty nl} {φ} → t ∈` φ → All Val φ → Val t\naccess here (px ∷ ρ) = px\naccess (there x) (px ∷ ρ) = access x ρ\n\neval : ∀ {nl φ t} → Exp {nl} φ t → All Val φ → Val t\neval Unit ϱ = tt\neval (Var x) ϱ = access x ϱ\neval (SubType e a≤a') ϱ = coerce a≤a' (eval e ϱ)\neval (Lab-I {l} l∈snl) ϱ = l , (l∈snl)\neval (Lab-E e case) ϱ with eval e ϱ\n... | lab , lab∈nl = eval (case lab lab∈nl) ϱ\neval (Abs e) ϱ = λ x → eval e (x ∷ ϱ)\neval (App e e₁) ϱ = (eval e ϱ) (eval e₁ ϱ)\n\n\n-- small-step semantics\n-- substitution taken from PLFA\n\next : ∀ {nl φ ψ} → (∀ {A : Ty nl} → A ∈` φ → A ∈` ψ)\n → (∀ {A B} → A ∈` (B ∷ φ) → A ∈` (B ∷ ψ))\next ϱ here = here\next ϱ (there x) = there (ϱ x)\n\nrename : ∀ {nl φ ψ} → (∀ {A : Ty nl} → A ∈` φ → A ∈` ψ)\n → (∀ {A} → Exp φ A → Exp ψ A)\nrename ϱ Unit = Unit\nrename ϱ (Var x) = Var (ϱ x)\nrename ϱ (SubType expr:A' A'≤A) = SubType (rename ϱ expr:A') A'≤A\nrename {ψ} ϱ (Lab-I l∈snl) = Lab-I {ψ} l∈snl\nrename ϱ (Lab-E expr:snl case) = Lab-E (rename ϱ expr:snl)\n λ l l∈snl → (rename ϱ (case l l∈snl))\nrename ϱ (Abs expr:B) = Abs (rename (ext ϱ) expr:B)\nrename ϱ (App expr:A->B expr:A) = App (rename ϱ expr:A->B) (rename ϱ expr:A)\n\nexts : ∀ {nl φ ψ} → (∀ {A : Ty nl} → A ∈` φ → Exp ψ A)\n → (∀ {A B} → A ∈` (B ∷ φ) → Exp (B ∷ ψ) A)\nexts ϱ here = Var (here)\nexts ϱ (there x) = rename there (ϱ x)\n\nsubst : ∀ {nl φ ψ} → (∀ {A : Ty nl} → A ∈` φ → Exp ψ A) -- simult. substitution\n → (∀ {A : Ty nl} → Exp φ A → Exp ψ A)\nsubst ϱ Unit = Unit\nsubst ϱ (Var x) = ϱ x\nsubst ϱ (SubType expr:A' A'≤A) = SubType (subst ϱ expr:A') A'≤A\nsubst {ψ} ϱ (Lab-I l∈snl) = Lab-I {ψ} l∈snl\nsubst ϱ (Lab-E expr:snl case) = Lab-E (subst ϱ expr:snl)\n λ l l∈snl → (subst ϱ (case l l∈snl))\nsubst ϱ (Abs expr:B) = Abs (subst (exts ϱ) expr:B)\nsubst ϱ (App expr:A→B expr:A) = App (subst ϱ expr:A→B) (subst ϱ expr:A)\n\n_[[_]] : ∀ {nl φ} {A B : Ty nl} → Exp (B ∷ φ) A → Exp φ B → Exp φ A -- single substitution\n_[[_]] {nl} {φ} {A} {B} N M = subst {nl} {B ∷ φ} {φ} ϱ {A} N\n where\n ϱ : ∀ {A} → A ∈` (B ∷ φ) → Exp φ A\n ϱ here = M\n ϱ (there x) = Var x \n\nexpansionlemma : ∀ {nl} {lt : Ty nl} {φ φ'} → lt ∈` φ' → lt ∈` (φ' ++ φ)\nexpansionlemma here = here\nexpansionlemma (there x) = there (expansionlemma x)\n\nextensionlemma : ∀ {nl} {lt : Ty nl} {φ φ'} → lt ∈` φ → lt ∈` (φ' ++ φ)\nextensionlemma {φ' = []} here = here\nextensionlemma {φ' = x ∷ xs} here = there (extensionlemma{φ' = xs} here)\nextensionlemma {φ' = []} (there y) = there y\nextensionlemma {φ' = x ∷ xs} (there y) = there (extensionlemma {φ' = xs} (there y))\n\ninextdebr : ∀ {nl} {B A : Ty nl} {φ' φ} → B ∈` (φ' ++ φ) → B ∈` (φ' ++ (A ∷ φ))\ninextdebr {φ' = []} here = there here\ninextdebr {φ' = []} (there x) = there (there x)\ninextdebr {φ' = x ∷ xs} here = here\ninextdebr {φ' = x ∷ xs} (there y) = there (inextdebr{φ' = xs} y)\n\ninext : ∀ {nl} {φ φ'} {A B : Ty nl} → Exp (φ' ++ φ) B → Exp (φ' ++ (A ∷ φ)) B\ninext Unit = Unit\ninext {φ' = φ'} (Var x) = Var (inextdebr{φ' = φ'} x)\ninext {φ = φ}{φ' = φ'} (SubType expr b≤b') = SubType (inext{φ = φ}{φ' = φ'} expr) b≤b'\ninext (Lab-I x) = Lab-I x\ninext {φ = φ} {φ' = φ'} (Lab-E x x₁) = Lab-E (inext{φ = φ}{φ' = φ'} x) λ l x₂ → inext{φ = φ}{φ' = φ'} (x₁ l x₂)\ninext {nl} {φ} {φ'} (Abs{A = A°} x) = Abs (inext{φ = φ}{φ' = A° ∷ φ'} x)\ninext {φ = φ} {φ' = φ'} (App x x₁) = App (inext{φ = φ}{φ' = φ'} x) (inext{φ = φ}{φ' = φ'} x₁)\n\ndebrsub : ∀ {nl} {B B' A A' : Ty nl} {φ' φ} → B ∈` (φ' ++ (A ∷ φ)) → A' ≤ A → B ≤ B' → Exp (φ' ++ (A' ∷ φ)) B'\ndebrsub {φ' = []} here a'≤a b≤b' = SubType (Var here) (≤-trans a'≤a b≤b')\ndebrsub {φ' = []} (there x) a'≤a b≤b' = SubType (Var (there x)) b≤b'\ndebrsub {φ' = x ∷ xs} here a'≤a b≤b' = SubType (Var (here)) b≤b'\ndebrsub {φ' = x ∷ xs} (there z) a'≤a b≤b' = inext{φ' = []}{A = x} (debrsub{φ' = xs} z a'≤a b≤b')\n\ntypesub : ∀ {nl φ φ' A B A' B'} → Exp{nl} (φ' ++ (A ∷ φ)) B → A' ≤ A → B ≤ B' → Exp (φ' ++ (A' ∷ φ)) B' -- subtyping \"substitution\"\ntypesub Unit a'≤a Sunit = Unit\ntypesub {φ = φ} {φ'} {A} {B} {A'} {B'} (Var x) a'≤a b≤b' = debrsub{φ' = φ'}{φ = φ} x a'≤a b≤b'\ntypesub {nl} {φ} {φ'} (SubType expr x) a'≤a b≤b' = typesub{nl}{φ}{φ'} expr a'≤a (≤-trans x b≤b')\ntypesub (Lab-I l∈snl) a'≤a b≤b' = SubType (Lab-I l∈snl) b≤b'\ntypesub {nl} {φ} {φ'} (Lab-E{snl = snl} expr cases) a'≤a b≤b' = Lab-E (typesub{nl}{φ}{φ'} expr a'≤a (≤-refl (Tlabel snl))) λ l x → typesub{nl}{φ}{φ'} (cases l x) a'≤a b≤b'\ntypesub {φ' = φ'}{A = A}{B = A°→B°}{A' = A'}{B' = A°°→B°°} (Abs{A = A°} expr) a'≤a (Sfun{A = .A°}{A' = A°°}{B = B°}{B' = B°°} A°°≤A° B°≤B°°)\n = SubType (Abs (typesub{φ' = A° ∷ φ'} expr a'≤a B°≤B°°)) (Sfun A°°≤A° (≤-refl B°°))\ntypesub {nl}{φ}{φ'}{A}{B}{A'}{B'} (App{A = A°}{B = .B} expr expr') a'≤a b≤b' = SubType (App (typesub{nl}{φ}{φ'} expr a'≤a (≤-refl (Tfun A° B))) (typesub{nl}{φ}{φ'} expr' a'≤a (≤-refl A°))) b≤b'\n\n-- we force values to have type SubType, since Lab-I results in expressions with type {l}\n-- and we want to keep the information about which subset l is in\ndata Val' {n φ} : (t : Ty n) → Exp {n} φ t → Set where\n Vunit : Val' (Tunit) Unit\n Vlab : ∀ {l snl l∈snl} → Val' (Tlabel snl) (Lab-I{l = l}{snl} l∈snl)\n Vfun : ∀ {A B exp} → Val' (Tfun A B) (Abs exp)\n\ndata _~>_ {n φ} : {A : Ty n} → Exp {n} φ A → Exp {n} φ A → Set where -- small-steps semantics relation (call-by-value)\n\n ξ-App1 : ∀ {A B} {L L' : (Exp φ (Tfun B A))} {M}\n → L ~> L'\n → App L M ~> App L' M\n \n ξ-App2 : ∀ {A B} {M M' : Exp φ A} {L : Exp φ (Tfun A B)}\n → Val' (Tfun A B) L\n → M ~> M'\n → App L M ~> App L M'\n\n β-App : ∀ {A B M exp} \n → Val' B M\n → App{B = A} (Abs exp) M\n ~>\n (exp [[ M ]])\n\n ξ-SubType : ∀ {A A' A≤A' } {L L' : Exp φ A}\n → L ~> L'\n → SubType{A = A}{A'} L A≤A' ~> SubType{A = A} L' A≤A'\n\n ξ-Lab-E : ∀ {A snl} {L L' : Exp φ (Tlabel snl)} {cases}\n → L ~> L'\n → Lab-E{B = A} L cases ~> Lab-E L' cases\n\n β-Lab-E : ∀ {A l snl l∈snl cases}\n → Lab-E{B = A} (Lab-I{l = l}{snl} l∈snl) cases\n ~>\n cases l (l∈snl)\n\n γ-Lab-I : ∀ {l snl snl'} {l∈snl : l ∈ snl} {snl⊆snl' : snl ⊆ snl'}\n → SubType (Lab-I{l = l}{snl = snl} l∈snl) (Slabel snl⊆snl')\n ~>\n Lab-I (snl⊆snl' l∈snl)\n\n γ-Abs : ∀ {A B A' B' e} {A'≤A : A' ≤ A} {B≤B' : B ≤ B'}\n → SubType (Abs{B = B}{A = A} e) (Sfun A'≤A B≤B')\n ~>\n Abs{B = B'}{A = A'} (typesub{φ' = []} e A'≤A B≤B')\n\n γ-SubType : ∀ {A A' A'' A≤A' A'≤A'' expr}\n → SubType{A = A'}{A' = A''} (SubType{A = A} expr A≤A') A'≤A''\n ~>\n SubType expr (≤-trans A≤A' A'≤A'')\n\n -- either we define Unit values to be SubTypes of Unit≤Unit; or we introducte the following rule\n β-SubType-Unit : SubType Unit Sunit\n ~>\n Unit\n\n-- properties of small-step evaluation\ninfix 2 _~>>_ -- refl. transitive closure\ninfix 1 begin_\ninfixr 2 _~>⟨_⟩_\ninfix 3 _∎\n\ndata _~>>_ : ∀ {n} {φ} {A : Ty n} → Exp φ A → Exp φ A → Set where\n _∎ : ∀ {n φ} {A : Ty n} (L : Exp φ A)\n → L ~>> L\n\n _~>⟨_⟩_ : ∀ {n φ} {A : Ty n} (L : Exp φ A) {M N : Exp φ A}\n → L ~> M\n → M ~>> N\n → L ~>> N\n\nbegin_ : ∀ {n φ} {A : Ty n} {M N : Exp φ A} → M ~>> N → M ~>> N\nbegin M~>>N = M~>>N\n\n\n-- progress theorem\ndata Progress {n A} (M : Exp{n} [] A) : Set where\n step : ∀ {N : Exp [] A} → M ~> N → Progress M\n done : Val' A M → Progress M\n\n-- proof\nprogress : ∀ {n A} → (M : Exp{n} [] A) → Progress M\nprogress Unit = done Vunit\nprogress (Var ()) -- Var requires a proof for A ∈ [] which cannot exist\nprogress (SubType Unit Sunit) = step β-SubType-Unit\nprogress (SubType (Var ()) A'≤A)\nprogress (SubType (SubType expr:A' x) A'≤A) = step γ-SubType\nprogress (SubType (Lab-I{l}{snl} l∈snl) (Slabel{snl' = snl'} snl⊆snl')) = step γ-Lab-I\nprogress (SubType (Lab-E expr:A' x) A'≤A) with progress (Lab-E expr:A' x)\n... | step a = step (ξ-SubType a)\n... | done () -- Lab-E without SubType can't be a value\nprogress (SubType (Abs expr:A') (Sfun A'≤A B≤B')) with progress (Abs expr:A')\n... | step a = step (ξ-SubType a)\n... | done Vfun = step γ-Abs\nprogress (SubType (App expr:A' expr:A'') A'≤A) with progress (expr:A')\n... | step a = step (ξ-SubType (ξ-App1 a))\n... | done Vfun with progress (expr:A'')\n... | step b = step (ξ-SubType (ξ-App2 Vfun b))\n... | done val = step (ξ-SubType (β-App val))\nprogress (Lab-I l∈snl) = done Vlab \nprogress (Lab-E expr cases) with progress expr\n... | step expr~>expr' = step (ξ-Lab-E expr~>expr')\n... | done Vlab = step (β-Lab-E)\nprogress (Abs expr) = done Vfun\nprogress (App L M) with progress L\n... | step L~>L' = step (ξ-App1 L~>L')\n... | done Vfun with progress M\n... | step M~>M' = step (ξ-App2 Vfun M~>M')\n... | done x = step (β-App x)\n\n-- generation of evaluation sequences\n-- taken from plfa\n\ndata Gas : Set where\n gas : ℕ → Gas\n\ndata Finished {n φ A} (N : Exp{n} φ A) : Set where\n done : Val' A N → Finished N\n out-of-gas : Finished N\n\ndata Steps : ∀ {n A} → Exp{n} [] A → Set where\n steps : ∀ {n A} {L N : Exp{n} [] A}\n → L ~>> N\n → Finished N\n → Steps L\n\neval' : ∀ {n A} → Gas → (L : Exp{n} [] A) → Steps L\neval' (gas zero) L = steps (L ∎) out-of-gas\neval' (gas (suc m)) L with progress L\n... | done VL = steps (L ∎) (done VL)\n... | step {M} L~>M with eval' (gas m) M\n... | steps M~>>N fin = steps (L ~>⟨ L~>M ⟩ M~>>N) fin \n\n\n-- examples\n-- (λ (x : Unit) → x) (Unit)\nex0 : Exp{suc zero} [] Tunit\nex0 = App (Abs (Unit{φ = (Tunit ∷ [])})) (Unit)\n\n_ : ex0 ~>> Unit\n_ =\n begin\n App (Abs (Unit)) (Unit)\n ~>⟨ β-App (Vunit) ⟩\n Unit\n ∎\n\n\nex1 : Exp{suc zero} [] Tunit\nex1 = Lab-E (Lab-I (x∈⁅x⁆ zero)) λ l x → Unit\n\n_ : ex1 ~>> Unit\n_ =\n begin\n Lab-E (Lab-I (x∈⁅x⁆ zero)) (λ l x → Unit)\n ~>⟨ β-Lab-E ⟩\n Unit\n ∎\n\nex2 : Exp{suc zero} [] Tunit\nex2 = App (SubType (Abs Unit) (Sfun Sunit Sunit)) Unit\n\n-- proof that {inside, outside} ⊆ {inside, inside}\n-- i.e. {0} ⊆ {0, 1}\nx⊆y : (inside ∷ outside ∷ []) ⊆ (inside ∷ inside ∷ [])\nx⊆y {.zero} here = here\nx⊆y {.(suc (suc _))} (there (there ()))\n\n-- proof that zero is in (inside ∷ outside ∷ [])\n-- i.e. 0 ∈ {0}\nl∈snl : (zero) ∈ (inside ∷ outside ∷ [])\nl∈snl = here\n\n-- [({0, 1}→{0, 1} <: {0}→{0, 1}) (λ x : {0, 1} . x)] 0\nex3 : Exp{suc (suc zero)} [] (Tlabel (inside ∷ inside ∷ []))\nex3 = App (SubType (Abs{A = Tlabel (inside ∷ inside ∷ [])} (Var here)) (Sfun (Slabel{snl = (inside ∷ outside ∷ [])} x⊆y) (≤-refl (Tlabel (inside ∷ inside ∷ [])))))\n (Lab-I l∈snl)\n\n\n", "meta": {"hexsha": "f392b403d10abf124168fc910aeeae3f6cf99473", "size": 15050, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/llc/IntrinsicallyTypedLLC.agda", "max_stars_repo_name": "kcaliban/ldlc", "max_stars_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/llc/IntrinsicallyTypedLLC.agda", "max_issues_repo_name": "kcaliban/ldlc", "max_issues_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/llc/IntrinsicallyTypedLLC.agda", "max_forks_repo_name": "kcaliban/ldlc", "max_forks_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-14T17:52:29.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-14T17:52:29.000Z", "avg_line_length": 42.5141242938, "max_line_length": 196, "alphanum_fraction": 0.4336877076, "num_tokens": 5861, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424295406088, "lm_q2_score": 0.7217432182679956, "lm_q1q2_score": 0.6105532115660861}} {"text": "open import Data.List using (List; _∷_; [])\nopen import Data.Product using (_×_; _,_; Σ)\nopen import Data.Unit using (⊤; tt)\nopen import Relation.Binary.PropositionalEquality using (_≡_)\n\nmodule SystemT where\n\n data _∈_ {A : Set} : (x : A) (l : List A) → Set where -- type \\in\n i0 : {x : A} {xs : List A} → x ∈ (x ∷ xs)\n iS : {x y : A} {xs : List A} → x ∈ xs → x ∈ (y ∷ xs)\n\n\n data TType : Set where\n base : TType\n _⟶_ : TType → TType → TType\n\n Context = List TType\n _,,_ : Context → TType → Context\n Γ ,, τ = τ ∷ Γ\n\n infixr 10 _⟶_\n infixr 9 _,,_\n infixr 8 _⊢_\n\n data _⊢_ (Γ : Context) : TType → Set where\n -- Some constant of the base type whose type is immediate.\n c : Γ ⊢ base\n -- Variable.\n var : {τ : TType} → τ ∈ Γ → Γ ⊢ τ\n -- Function introduction.\n lam : {τ₁ τ₂ : TType} → Γ ,, τ₁ ⊢ τ₂ → Γ ⊢ τ₁ ⟶ τ₂\n -- Function application.\n app : {τ₁ τ₂ : TType} → (Γ ⊢ τ₁ ⟶ τ₂) → Γ ⊢ τ₁ → Γ ⊢ τ₂\n\n module Semantics (B : Set) (elB : B) where\n\n -- Interpretation of System T types to Agda types.\n ⟦_⟧t : TType → Set\n ⟦ base ⟧t = B\n ⟦ τ₁ ⟶ τ₂ ⟧t = ⟦ τ₁ ⟧t → ⟦ τ₂ ⟧t\n\n -- Interpretation of System T contexts to Agda types.\n ⟦_⟧c : Context → Set\n ⟦ [] ⟧c = ⊤\n ⟦ τ ∷ Γ ⟧c = ⟦ Γ ⟧c × ⟦ τ ⟧t\n\n -- Interpretation of terms.\n ⟦_⟧ : {Γ : Context} {τ : TType} → (Γ ⊢ τ) → ⟦ Γ ⟧c → ⟦ τ ⟧t\n ⟦ c ⟧ γ = elB\n ⟦ var x ⟧ γ = {! !}\n ⟦ lam e ⟧ γ x = {! !}\n ⟦ app e₁ e₂ ⟧ γ = {! !}\n", "meta": {"hexsha": "77a237e4e8229b2e2c63b9e5d8db0dcf495e2d4c", "size": 1454, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "SystemT.agda", "max_stars_repo_name": "ayberkt/system-t-normalization", "max_stars_repo_head_hexsha": "785c3d1f93ce2dac7801504b806abfd59f3875f6", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2016-06-24T14:36:42.000Z", "max_stars_repo_stars_event_max_datetime": "2016-06-25T03:40:58.000Z", "max_issues_repo_path": "SystemT.agda", "max_issues_repo_name": "ayberkt/system-t-normalization", "max_issues_repo_head_hexsha": "785c3d1f93ce2dac7801504b806abfd59f3875f6", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "SystemT.agda", "max_forks_repo_name": "ayberkt/system-t-normalization", "max_forks_repo_head_hexsha": "785c3d1f93ce2dac7801504b806abfd59f3875f6", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.4339622642, "max_line_length": 67, "alphanum_fraction": 0.507565337, "num_tokens": 618, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424373085145, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.6105532070462519}} {"text": "data Unit : Set where\n unit : Unit\n\ndata Maybe (A : Set) : Set where\n nothing : Maybe A\n just : A → Maybe A\n\ndata Test : Set where\n map : (Unit → Maybe Test) → Test\n\n-- Accepted:\nfoo : Test → Unit\nfoo-aux : Maybe Test → Unit\nfoo (map f) = foo-aux (f unit)\nfoo-aux nothing = unit\nfoo-aux (just x) = foo x\n\ntest : Test → Unit\ntest (map f) with f unit\ntest (map f) | nothing = unit\ntest (map f) | just x = test x\n\n-- WAS: Termination checker complains\n-- SHOULD: succeed\n", "meta": {"hexsha": "ba8c120f8486d8a87d5ef7b23d349edea29300ae", "size": 472, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1381.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue1381.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue1381.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 18.88, "max_line_length": 37, "alphanum_fraction": 0.6398305085, "num_tokens": 153, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7799928900257127, "lm_q2_score": 0.7826624789529375, "lm_q1q2_score": 0.6104711688731903}} {"text": "{-# OPTIONS --sized-types #-}\n\nmodule Lang.Size where\n\n-- Some stuff about sizes that seems to :\n-- • Types:\n-- • SizeU : TYPE\n-- • Size : TYPE\n-- • <ˢⁱᶻᵉ_ : Size → TYPE\n-- • 𝐒ˢⁱᶻᵉ : Size → Size\n-- • ∞ˢⁱᶻᵉ : Size\n-- • _⊔ˢⁱᶻᵉ_ : Size → Size → Size\n-- • Subtyping : ∀s₁∀s₂. (s₁: <ˢⁱᶻᵉ s₂) → (s₁: Size)\n-- • Almost irreflexivity: ∀(s: Size). (s ≠ ∞ˢⁱᶻᵉ) → ¬(s: <ˢⁱᶻᵉ s)\n-- • Transitivity : ∀s₁∀s₂∀s₃. (s₁: <ˢⁱᶻᵉ s₂) → (s₂: <ˢⁱᶻᵉ s₃) → (s₁: <ˢⁱᶻᵉ s₃)\n-- • Successor : ∀(s: Size). s: <ˢⁱᶻᵉ 𝐒ˢⁱᶻᵉ(s)\n-- • Maximum : ∀(s: Size). s: <ˢⁱᶻᵉ ∞ˢⁱᶻᵉ\n-- • Successor of maximum: 𝐒ˢⁱᶻᵉ(∞ˢⁱᶻᵉ) = ∞ˢⁱᶻᵉ\n-- • Max function left : ∀(s₁: Size)∀(s₂: Size)∀(s₃: Size). ((s₁: <ˢⁱᶻᵉ s₃) ∧ (s₂: <ˢⁱᶻᵉ s₃)) → (((s₁ ⊔ˢⁱᶻᵉ s₂)): <ˢⁱᶻᵉ s₃)\n-- • Max function right : ∀(s₁: Size)∀(s₂: Size)∀(s₃: Size). ((s₁: <ˢⁱᶻᵉ s₂) ∨ (s₁: <ˢⁱᶻᵉ s₃)) → (s₁: <ˢⁱᶻᵉ (s₂ ⊔ˢⁱᶻᵉ s₃))\n-- • Max of maximum left : ∀(s: Size). s ⊔ˢⁱᶻᵉ ∞ˢⁱᶻᵉ = ∞ˢⁱᶻᵉ\n-- • Max of maximum right: ∀(s: Size). ∞ˢⁱᶻᵉ ⊔ˢⁱᶻᵉ s = ∞ˢⁱᶻᵉ\n-- TODO: What is SizeU? See https://github.com/agda/agda/blob/cabe234d3c784e20646636ad082cc1e04ddf007b/src/full/Agda/TypeChecking/Rules/Builtin.hs#L294 , https://github.com/agda/agda/blob/1eec63b1c5566b252c0a4a815ce1df99a772c475/src/full/Agda/TypeChecking/Primitive/Base.hs#L134\n\n{-# BUILTIN SIZEUNIV SizeU #-}\n{-# BUILTIN SIZE Size #-}\n{-# BUILTIN SIZELT <ˢⁱᶻᵉ_ #-}\n{-# BUILTIN SIZESUC 𝐒ˢⁱᶻᵉ #-}\n{-# BUILTIN SIZEINF ∞ˢⁱᶻᵉ #-}\n{-# BUILTIN SIZEMAX _⊔ˢⁱᶻᵉ_ #-}\n\n{-\nprivate\n module Test where\n open import Relator.Equals\n\n types-SizeU : TYPE\n types-SizeU = SizeU\n\n types-Size : TYPE\n types-Size = Size\n\n types-<ˢⁱᶻᵉ : Size → TYPE\n types-<ˢⁱᶻᵉ = <ˢⁱᶻᵉ_\n\n types-𝐒ˢⁱᶻᵉ : Size → Size\n types-𝐒ˢⁱᶻᵉ = 𝐒ˢⁱᶻᵉ\n\n types-∞ˢⁱᶻᵉ : Size\n types-∞ˢⁱᶻᵉ = ∞ˢⁱᶻᵉ\n\n types-_⊔ˢⁱᶻᵉ_ : Size → Size → Size\n types-_⊔ˢⁱᶻᵉ_ = _⊔ˢⁱᶻᵉ_\n\n subtyping : ∀{s₂ : Size}{s₁ : <ˢⁱᶻᵉ s₂} → Size\n subtyping {s₁ = s₁} = s₁\n\n reflexivity-of-maximum : <ˢⁱᶻᵉ ∞ˢⁱᶻᵉ\n reflexivity-of-maximum = ∞ˢⁱᶻᵉ\n\n transitivity : ∀{s₃ : Size}{s₂ : <ˢⁱᶻᵉ s₃}{s₁ : <ˢⁱᶻᵉ s₂} → (<ˢⁱᶻᵉ s₃)\n transitivity {s₁ = s₁} = s₁\n\n maximum : ∀{s : Size} → <ˢⁱᶻᵉ ∞ˢⁱᶻᵉ\n maximum{s} = s\n\n successor-of-maximum : 𝐒ˢⁱᶻᵉ ∞ˢⁱᶻᵉ ≡ ∞ˢⁱᶻᵉ\n successor-of-maximum = [≡]-intro\n\n max-of-maximumₗ : ∀{s : Size} → (∞ˢⁱᶻᵉ ⊔ˢⁱᶻᵉ s ≡ ∞ˢⁱᶻᵉ)\n max-of-maximumₗ = [≡]-intro\n\n max-of-maximumᵣ : ∀{s : Size} → (s ⊔ˢⁱᶻᵉ ∞ˢⁱᶻᵉ ≡ ∞ˢⁱᶻᵉ)\n max-of-maximumᵣ = [≡]-intro\n\n max-function-left : ∀{s₃ : Size}{s₁ : <ˢⁱᶻᵉ s₃}{s₂ : <ˢⁱᶻᵉ s₃} → (<ˢⁱᶻᵉ s₃)\n max-function-left {s₁ = s₁}{s₂ = s₂} = s₁ ⊔ˢⁱᶻᵉ s₂\n\n max-function-rightₗ : ∀{s₂ s₃ : Size}{s₁ : <ˢⁱᶻᵉ s₂} → (<ˢⁱᶻᵉ (s₂ ⊔ˢⁱᶻᵉ s₃))\n max-function-rightₗ {s₁ = s₁} = s₁\n\n max-function-rightᵣ : ∀{s₂ s₃ : Size}{s₁ : <ˢⁱᶻᵉ s₃} → (<ˢⁱᶻᵉ (s₂ ⊔ˢⁱᶻᵉ s₃))\n max-function-rightᵣ {s₁ = s₁} = s₁\n\n -- TODO: Is this supposed to not work? This is: ∀(sₗ₁ : Size)∀(sₗ₂ : Size)∀(sᵣ : Size) → (sₗ₁ <ˢⁱᶻᵉ sₗ₂) → ((sₗ₁ ⊔ˢⁱᶻᵉ sᵣ) <ˢⁱᶻᵉ (sₗ₂ ⊔ˢⁱᶻᵉ sᵣ))\n max-should-work? : ∀{sₗ₂ sᵣ : Size}{sₗ₁ : <ˢⁱᶻᵉ sₗ₂} → (<ˢⁱᶻᵉ (sₗ₂ ⊔ˢⁱᶻᵉ sᵣ))\n max-should-work? {sᵣ = sᵣ}{sₗ₁ = sₗ₁} = sₗ₁ ⊔ˢⁱᶻᵉ sᵣ\n-}\n", "meta": {"hexsha": "294007603f07b216ddbc52a483c5464d7e58d3f1", "size": 3143, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Lang/Size.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Lang/Size.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lang/Size.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.3146067416, "max_line_length": 278, "alphanum_fraction": 0.5711104041, "num_tokens": 2115, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267898240861, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.6103769399327789}} {"text": "{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOT.Common.FOL.Existential.Syntax where\n\n-- We add 3 to the fixities of the Agda standard library 0.8.1 (see\n-- Relation.Binary.Core).\ninfix 7 _≡_\n\npostulate\n D : Set\n _≡_ : D → D → Set\n refl : ∀ {d} → d ≡ d\n d : D\n\nmodule ∃₁ where\n\n -- We add 3 to the fixities of the Agda standard library 0.8.1 (see\n -- Data/Product.agda, Data/Sum.agda and Relation/Nullary/Core.agda).\n infixr 7 _,_\n infix 5 ∃\n\n data ∃ (P : D → Set) : Set where\n _,_ : (x : D) → P x → ∃ P\n\n syntax ∃ (λ x → e) = ∃[ x ] e\n\n t₁ : ∃ λ x → x ≡ x\n t₁ = d , refl\n\n t₂ : ∃[ x ] x ≡ x\n t₂ = d , refl\n\n t₃ : ∃ λ x → ∃ λ y → x ≡ y\n t₃ = d , d , refl\n\n t₄ : ∃[ x ] ∃[ y ] x ≡ y\n t₄ = d , d , refl\n\nmodule ∃₂ where\n infixr 7 _,_,_\n\n data ∃₂ (P : D → D → Set) : Set where\n _,_,_ : (x y : D) → P x y → ∃₂ P\n\n -- Agda issue: 536\n -- syntax ∃₂ (λ x y → e) = ∃₂[ x , y ] e\n\n t₁ : ∃₂ λ x y → x ≡ y\n t₁ = d , d , refl\n", "meta": {"hexsha": "7c1f9ed4bf1ee29126f97c0215b073851f7f8edf", "size": 1089, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/Common/FOL/Existential/Syntax.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/FOT/Common/FOL/Existential/Syntax.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/FOT/Common/FOL/Existential/Syntax.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 20.5471698113, "max_line_length": 70, "alphanum_fraction": 0.4931129477, "num_tokens": 459, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428946, "lm_q2_score": 0.7745833841649232, "lm_q1q2_score": 0.6103184120101875}} {"text": "module Stack where\n\nopen import Prelude public\n\n\n-- Stacks, or snoc-lists.\n\ndata Stack (X : Set) : Set where\n ∅ : Stack X\n _,_ : Stack X → X → Stack X\n\n\n-- Stack membership, or de Bruijn indices.\n\nmodule _ {X : Set} where\n infix 3 _∈_\n data _∈_ (A : X) : Stack X → Set where\n top : ∀ {Γ} → A ∈ Γ , A\n pop : ∀ {Γ B} → A ∈ Γ → A ∈ Γ , B\n\n ⌊_⌋∈ : ∀ {Γ A} → A ∈ Γ → Nat\n ⌊ top ⌋∈ = zero\n ⌊ pop i ⌋∈ = suc ⌊ i ⌋∈\n\n i₀ : ∀ {Γ A} → A ∈ Γ , A\n i₀ = top\n\n i₁ : ∀ {Γ A B} → A ∈ Γ , A , B\n i₁ = pop i₀\n\n i₂ : ∀ {Γ A B C} → A ∈ Γ , A , B , C\n i₂ = pop i₁\n\n\n-- Stack inclusion, or order-preserving embeddings.\n\nmodule _ {X : Set} where\n infix 3 _⊆_\n data _⊆_ : Stack X → Stack X → Set where\n bot : ∀ {Γ} → ∅ ⊆ Γ\n skip : ∀ {Γ Γ′ A} → Γ ⊆ Γ′ → Γ ⊆ Γ′ , A\n keep : ∀ {Γ Γ′ A} → Γ ⊆ Γ′ → Γ , A ⊆ Γ′ , A\n\n refl⊆ : ∀ {Γ} → Γ ⊆ Γ\n refl⊆ {∅} = bot\n refl⊆ {Γ , A} = keep refl⊆\n\n trans⊆ : ∀ {Γ Γ′ Γ″} → Γ ⊆ Γ′ → Γ′ ⊆ Γ″ → Γ ⊆ Γ″\n trans⊆ bot η′ = bot\n trans⊆ η (skip η′) = skip (trans⊆ η η′)\n trans⊆ (skip η) (keep η′) = skip (trans⊆ η η′)\n trans⊆ (keep η) (keep η′) = keep (trans⊆ η η′)\n\n weak⊆ : ∀ {Γ A} → Γ ⊆ Γ , A\n weak⊆ = skip refl⊆\n\n\n-- Monotonicity of stack membership with respect to stack inclusion.\n\nmodule _ {X : Set} where\n mono∈ : ∀ {Γ Γ′ : Stack X} {A} → Γ ⊆ Γ′ → A ∈ Γ → A ∈ Γ′\n mono∈ bot ()\n mono∈ (skip η) i = pop (mono∈ η i)\n mono∈ (keep η) top = top\n mono∈ (keep η) (pop i) = pop (mono∈ η i)\n\n\n-- Pairs of stacks.\n\ninfixl 4 _⁏_\nrecord Stack² (X Y : Set) : Set where\n constructor _⁏_\n field\n π₁ : Stack X\n π₂ : Stack Y\n\nopen Stack² public\n\n\n-- Stack pair inclusion.\n\nmodule _ {X Y : Set} where\n infix 3 _⊆²_\n _⊆²_ : Stack² X Y → Stack² X Y → Set\n Γ ⁏ Δ ⊆² Γ′ ⁏ Δ′ = Γ ⊆ Γ′ ∧ Δ ⊆ Δ′\n\n refl⊆² : ∀ {Γ Δ} → Γ ⁏ Δ ⊆² Γ ⁏ Δ\n refl⊆² = refl⊆ , refl⊆\n\n trans⊆² : ∀ {Γ Γ′ Γ″ Δ Δ′ Δ″} → Γ ⁏ Δ ⊆² Γ′ ⁏ Δ′ → Γ′ ⁏ Δ′ ⊆² Γ″ ⁏ Δ″ → Γ ⁏ Δ ⊆² Γ″ ⁏ Δ″\n trans⊆² (η , ρ) (η′ , ρ′) = trans⊆ η η′ , trans⊆ ρ ρ′\n", "meta": {"hexsha": "28b5fea58fcca6b618a58d2c7d739b3f5eb4665e", "size": 1991, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Stack.agda", "max_stars_repo_name": "mietek/imla2017", "max_stars_repo_head_hexsha": "accc6c57390c435728d568ae590a02b2776b8891", "max_stars_repo_licenses": ["X11"], "max_stars_count": 17, "max_stars_repo_stars_event_min_datetime": "2017-02-27T05:04:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-17T13:02:58.000Z", "max_issues_repo_path": "src/Stack.agda", "max_issues_repo_name": "mietek/imla2017", "max_issues_repo_head_hexsha": "accc6c57390c435728d568ae590a02b2776b8891", "max_issues_repo_licenses": ["X11"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Stack.agda", "max_forks_repo_name": "mietek/imla2017", "max_forks_repo_head_hexsha": "accc6c57390c435728d568ae590a02b2776b8891", "max_forks_repo_licenses": ["X11"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.6413043478, "max_line_length": 90, "alphanum_fraction": 0.4691109995, "num_tokens": 1005, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256393148982, "lm_q2_score": 0.7248702880639791, "lm_q1q2_score": 0.6102143936698337}} {"text": "module sv20.assign2.Second_old4 where\n\nopen import Data.Bool as Bool using (Bool; true; false; T; _∨_; _∧_)\n--open import Relation.Nullary using (¬_)\nopen import Data.Unit using (⊤; tt)\nopen import Data.Empty using (⊥; ⊥-elim)\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_)\nopen import Level using (Level; _⊔_; 0ℓ) renaming (suc to lsuc)\n--open import Data.Sum using (_⊎_; inj₁; inj₂)\nopen import Data.Product using (_×_; ∃-syntax) renaming (_,_ to ⟨_,_⟩)\nopen import Function using (_∘_)\n--import Relation.Binary.PropositionalEquality as Eq\n--open Eq using (_≡_; refl; subst)\n\nSubset : ∀ {α} (A : Set α) -> Set _\nSubset A = A → Bool \n\n_∈_ : ∀ {α} {A : Set α} → A → Subset A → Set\na ∈ p = T (p a)\n\n--odd : Subset ℕ\n--odd 0 = false\n--odd 1 = true\n--odd (suc (suc n)) = odd n\n--\n--_ : 3 ∈ odd\n--_ = tt\n--\n--_ : Subset Set -- I'm not actually sure, what this is\n--_ = λ _ → true\n\n-- _ : true ∈ odd -- Doesn't make sense. Type inference fails\n--_ = ?\n\n--∈or∉ : ∀ {A : Set} (SubA : Subset A) (a : A) → (a ∈ SubA) ⊎ ¬ (a ∈ SubA)\n--∈or∉ subset a with subset a\n--... | true = inj₁ tt\n--... | false = inj₂ ⊥-elim\n--\n--empty-⊥ : ∀ (sub : Subset ⊥) (a : ⊥) → ¬ (a ∈ sub)\n--empty-⊥ _ ()\n\n--¬⊥ : ∀ (A : Set) → ¬ (⊥ ∈ A) -- doesn't make any sense\n--¬⊥ = ?\n\nRelation : ∀ {α β} (A : Set α) (B : Set β) → Set (α ⊔ β)\nRelation A B = Subset (A × B)\n\n--equalℕ : Relation ℕ ℕ\n--equalℕ ⟨ zero , zero ⟩ = true\n--equalℕ ⟨ zero , (suc n) ⟩ = false\n--equalℕ ⟨ (suc m) , zero ⟩ = false\n--equalℕ ⟨ (suc m) , (suc n) ⟩ = equalℕ ⟨ m , n ⟩\n\n--_ : equalℕ ⟨ 3 , 4 ⟩ ≡ false\n--_ = refl\n\n_∪_ : ∀ {A : Set} → Subset A → Subset A → Subset A\nA ∪ B = λ x → (A x) ∨ (B x)\n\n_∩_ : ∀ {A : Set} → Subset A → Subset A → Subset A\nA ∩ B = λ x → (A x) ∧ (B x)\n\n_⊆_ : ∀ {A : Set} → Subset A → Subset A → Set\nA ⊆ B = ∀ x → x ∈ A → x ∈ B\n\nwholeSet : ∀ (A : Set) → Subset A\nwholeSet _ = λ _ → true\n\n--odd⊆ℕ : odd ⊆ wholeSet ℕ\n----odd⊆ℕ zero ()\n----odd⊆ℕ 1 tt = tt\n----odd⊆ℕ (suc (suc n)) _ = tt\n---- or, simply\n--odd⊆ℕ _ _ = tt\n\n-- In general\n∀subset⊆set : ∀ {A : Set} {sub : Subset A} → sub ⊆ wholeSet A\n∀subset⊆set = λ _ _ → tt\n\nrecord _⇔_ (A B : Set) : Set where\n field\n to : A → B\n from : B → A\n\nrecord Range (A B : Set) : Set where\n field\n range : Relation A B → Subset B\n def : ∀ (rel : Relation A B) (b : B)\n → (∃[ a ] (⟨ a , b ⟩ ∈ rel))\n ⇔ (b ∈ range rel)\n\n--lemma : ∀ {A B : Set}\n-- (F G : Relation A B)\n-- (b : B)\n-- → ∃[ a ] (⟨ a , b ⟩ ∈ (F ∩ G))\n-- → ∃[ a ] ((⟨ a , b ⟩ ∈ F) × (⟨ a , b ⟩ ∈ G))\n--lemma f g b ⟨ a , f∩ga ⟩ with f ⟨ a , b ⟩ | g ⟨ a , b ⟩\n--... | true | true = ⟨ ? , ⟨ ? , ? ⟩ ⟩\n--... | true | false = ⊥-elim f∩ga\n--... | false | true = ⊥-elim f∩ga\n--... | false | false = ⊥-elim f∩ga\n-- \n--module range-props {A B : Set} (rng : Range A B) where\n-- range = Range.range rng\n-- def = Range.def rng\n--\n-- range-∩-⊆ : (F G : Relation A B)\n-- → range (F ∩ G) ⊆ (range F ∩ range G)\n-- range-∩-⊆ f g b = ?\n-- where\n-- --def-rngf-→ = _⇔_.to (def f b)\n--\n-- -- b ∈ range (f ∩ g) → ∃[ a ] (⟨ a , b ⟩ ∈ (f ∩ g))\n-- def-rngf-← = _⇔_.from (def (f ∩ g) b)\n-- -- b ∈ range (f ∩ g) → ∃[ a ] ((⟨ a , b ⟩ ∈ F) × (⟨ a , b ⟩ ∈ G))\n-- lemma' = (lemma f g b) ∘ def-rngf-←\n\n-- Class exercise\n-- Dammit! All definitions of subset I have found for agda make this problem not a problem\nexercise103a : ∀ {a} {A B : Subset a}\n → (∀ x → x ∈ A → x ∈ B)\n → A ⊆ B\nexercise103a ∀x→x∈A→x∈B = ∀x→x∈A→x∈B\n", "meta": {"hexsha": "b6bb0c61d46835f14d2342fccfce4645a6d2589b", "size": 3666, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "proglangs-learning/Agda/sv20/assign2/Second_old4.agda", "max_stars_repo_name": "helq/old_code", "max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "proglangs-learning/Agda/sv20/assign2/Second_old4.agda", "max_issues_repo_name": "helq/old_code", "max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z", "max_forks_repo_path": "proglangs-learning/Agda/sv20/assign2/Second_old4.agda", "max_forks_repo_name": "helq/old_code", "max_forks_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.328, "max_line_length": 90, "alphanum_fraction": 0.464811784, "num_tokens": 1510, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434873426303, "lm_q2_score": 0.7905303285397349, "lm_q1q2_score": 0.6101656856302242}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- A bunch of properties\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Bool.Properties where\n\nopen import Algebra.Bundles\nopen import Data.Bool.Base\nopen import Data.Empty\nopen import Data.Product\nopen import Data.Sum.Base\nopen import Function.Base\nopen import Function.Equality using (_⟨$⟩_)\nopen import Function.Equivalence\n using (_⇔_; equivalence; module Equivalence)\nopen import Level using (Level; 0ℓ)\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality hiding ([_])\nopen import Relation.Nullary using (ofʸ; ofⁿ; does; proof; yes; no)\nopen import Relation.Nullary.Decidable using (True)\nimport Relation.Unary as U\n\nopen import Algebra.Definitions {A = Bool} _≡_\nopen import Algebra.Structures {A = Bool} _≡_\nopen ≡-Reasoning\n\nprivate\n variable\n a b : Level\n A : Set a\n B : Set b\n\n------------------------------------------------------------------------\n-- Properties of _≡_\n\ninfix 4 _≟_\n\n_≟_ : Decidable {A = Bool} _≡_\ntrue ≟ true = yes refl\nfalse ≟ false = yes refl\ntrue ≟ false = no λ()\nfalse ≟ true = no λ()\n\n≡-setoid : Setoid 0ℓ 0ℓ\n≡-setoid = setoid Bool\n\n≡-decSetoid : DecSetoid 0ℓ 0ℓ\n≡-decSetoid = decSetoid _≟_\n\n------------------------------------------------------------------------\n-- Properties of _≤_\n\n-- Relational properties\n\n≤-reflexive : _≡_ ⇒ _≤_\n≤-reflexive refl = b≤b\n\n≤-refl : Reflexive _≤_\n≤-refl = ≤-reflexive refl\n\n≤-trans : Transitive _≤_\n≤-trans b≤b p = p\n≤-trans f≤t b≤b = f≤t\n\n≤-antisym : Antisymmetric _≡_ _≤_\n≤-antisym b≤b _ = refl\n\n≤-minimum : Minimum _≤_ false\n≤-minimum false = b≤b\n≤-minimum true = f≤t\n\n≤-maximum : Maximum _≤_ true\n≤-maximum false = f≤t\n≤-maximum true = b≤b\n\n≤-total : Total _≤_\n≤-total false b = inj₁ (≤-minimum b)\n≤-total true b = inj₂ (≤-maximum b)\n\ninfix 4 _≤?_\n\n_≤?_ : Decidable _≤_\nfalse ≤? b = yes (≤-minimum b)\ntrue ≤? false = no λ ()\ntrue ≤? true = yes b≤b\n\n≤-irrelevant : Irrelevant _≤_\n≤-irrelevant {_} f≤t f≤t = refl\n≤-irrelevant {false} b≤b b≤b = refl\n≤-irrelevant {true} b≤b b≤b = refl\n\n-- Structures\n\n≤-isPreorder : IsPreorder _≡_ _≤_\n≤-isPreorder = record\n { isEquivalence = isEquivalence\n ; reflexive = ≤-reflexive\n ; trans = ≤-trans\n }\n\n≤-isPartialOrder : IsPartialOrder _≡_ _≤_\n≤-isPartialOrder = record\n { isPreorder = ≤-isPreorder\n ; antisym = ≤-antisym\n }\n\n≤-isTotalOrder : IsTotalOrder _≡_ _≤_\n≤-isTotalOrder = record\n { isPartialOrder = ≤-isPartialOrder\n ; total = ≤-total\n }\n\n≤-isDecTotalOrder : IsDecTotalOrder _≡_ _≤_\n≤-isDecTotalOrder = record\n { isTotalOrder = ≤-isTotalOrder\n ; _≟_ = _≟_\n ; _≤?_ = _≤?_\n }\n\n-- Bundles\n\n≤-poset : Poset 0ℓ 0ℓ 0ℓ\n≤-poset = record\n { isPartialOrder = ≤-isPartialOrder\n }\n\n≤-preorder : Preorder 0ℓ 0ℓ 0ℓ\n≤-preorder = record\n { isPreorder = ≤-isPreorder\n }\n\n≤-totalOrder : TotalOrder 0ℓ 0ℓ 0ℓ\n≤-totalOrder = record\n { isTotalOrder = ≤-isTotalOrder\n }\n\n≤-decTotalOrder : DecTotalOrder 0ℓ 0ℓ 0ℓ\n≤-decTotalOrder = record\n { isDecTotalOrder = ≤-isDecTotalOrder\n }\n\n------------------------------------------------------------------------\n-- Properties of _<_\n\n-- Relational properties\n\n<-irrefl : Irreflexive _≡_ _<_\n<-irrefl refl ()\n\n<-asym : Asymmetric _<_\n<-asym f (λ()) (λ()) f[c]\n ‖ ^\n ‖ | emloop h ^\n ‖ | j |\n [a]— — — >[b] ∙ — >\n emloop g i\n\n We use this to give another constructor-like construction:\n -}\n\n emloop-comp : (g h : G) → emloop (g · h) ≡ emloop g ∙ emloop h\n emloop-comp g h i = compPath-unique refl (emloop g) (emloop h)\n (emloop (g · h) , emcomp g h)\n (emloop g ∙ emloop h , compPath-filler (emloop g) (emloop h)) i .fst\n\n emloop-1g : emloop 1g ≡ refl\n emloop-1g =\n lUnit (emloop 1g)\n ∙∙ cong (_∙ emloop 1g) (sym (lCancel (emloop 1g)) )\n ∙∙ sym (assoc∙ _ _ _)\n ∙∙ cong (sym (emloop 1g) ∙_) (sym (emloop-comp 1g 1g) ∙ cong emloop (·IdL 1g))\n ∙∙ rCancel _\n\n emloop-sym : (g : G) → emloop (inv g) ≡ sym (emloop g)\n emloop-sym g =\n rUnit _\n ∙∙ cong (emloop (inv g) ∙_) (sym (rCancel (emloop g)))\n ∙∙ assoc∙ _ _ _\n ∙∙ cong (_∙ sym (emloop g)) (sym (emloop-comp (inv g) g) ∙∙ cong emloop (·InvL g) ∙∙ emloop-1g)\n ∙∙ sym (lUnit _)\n", "meta": {"hexsha": "d8c02d368ddd4640cc678ca27660572b3c2aad0e", "size": 1745, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/EilenbergMacLane1/Base.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/HITs/EilenbergMacLane1/Base.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/HITs/EilenbergMacLane1/Base.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.1451612903, "max_line_length": 99, "alphanum_fraction": 0.5570200573, "num_tokens": 679, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430394931456, "lm_q2_score": 0.734119526900183, "lm_q1q2_score": 0.6101583349390882}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Categories.Limits.Initial where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Isomorphism renaming (Iso to _≅_)\nopen import Cubical.HITs.PropositionalTruncation.Base\n\nopen import Cubical.Data.Sigma\n\nopen import Cubical.Categories.Category\nopen import Cubical.Categories.Functor\nopen import Cubical.Categories.Adjoint\n\nprivate\n variable\n ℓ ℓ' : Level\n ℓC ℓC' ℓD ℓD' : Level\n\nmodule _ (C : Category ℓ ℓ') where\n open Category C\n\n isInitial : (x : ob) → Type (ℓ-max ℓ ℓ')\n isInitial x = ∀ (y : ob) → isContr (C [ x , y ])\n\n Initial : Type (ℓ-max ℓ ℓ')\n Initial = Σ[ x ∈ ob ] isInitial x\n\n initialOb : Initial → ob\n initialOb = fst\n\n initialArrow : (T : Initial) (y : ob) → C [ initialOb T , y ]\n initialArrow T y = T .snd y .fst\n\n initialArrowUnique : {T : Initial} {y : ob} (f : C [ initialOb T , y ])\n → initialArrow T y ≡ f\n initialArrowUnique {T} {y} f = T .snd y .snd f\n\n initialEndoIsId : (T : Initial) (f : C [ initialOb T , initialOb T ])\n → f ≡ id\n initialEndoIsId T f = isContr→isProp (T .snd (initialOb T)) f id\n\n hasInitial : Type (ℓ-max ℓ ℓ')\n hasInitial = ∥ Initial ∥₁\n\n -- Initiality of an object is a proposition.\n isPropIsInitial : (x : ob) → isProp (isInitial x)\n isPropIsInitial _ = isPropΠ λ _ → isPropIsContr\n\n open CatIso\n\n -- Objects that are initial are isomorphic.\n initialToIso : (x y : Initial) → CatIso C (initialOb x) (initialOb y)\n mor (initialToIso x y) = initialArrow x (initialOb y)\n inv (initialToIso x y) = initialArrow y (initialOb x)\n sec (initialToIso x y) = initialEndoIsId y _\n ret (initialToIso x y) = initialEndoIsId x _\n\n open isUnivalent\n\n -- The type of initial objects of a univalent category is a proposition,\n -- i.e. all initial objects are equal.\n isPropInitial : (hC : isUnivalent C) → isProp Initial\n isPropInitial hC x y =\n Σ≡Prop isPropIsInitial (CatIsoToPath hC (initialToIso x y))\n\nmodule _ {C : Category ℓC ℓC'} {D : Category ℓD ℓD'} (F : Functor C D) where\n open Category\n open Functor\n open NaturalBijection\n open _⊣_\n open _≅_\n\n preservesInitial : Type (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD'))\n preservesInitial = ∀ (x : ob C) → isInitial C x → isInitial D (F-ob F x)\n\n isLeftAdjoint→preservesInitial : isLeftAdjoint F → preservesInitial\n fst (isLeftAdjoint→preservesInitial (G , F⊣G) x initX y) = _♯ F⊣G (fst (initX (F-ob G y)))\n snd (isLeftAdjoint→preservesInitial (G , F⊣G) x initX y) ψ =\n _♯ F⊣G (fst (initX (F-ob G y)))\n ≡⟨ cong (F⊣G ♯) (snd (initX (F-ob G y)) (_♭ F⊣G ψ)) ⟩\n _♯ F⊣G (_♭ F⊣G ψ)\n ≡⟨ leftInv (adjIso F⊣G) ψ ⟩\n ψ ∎\n", "meta": {"hexsha": "a5c06b6a42e24235610d503ff8d1bd9fab2691c8", "size": 2700, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Limits/Initial.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_issues_repo_path": "Cubical/Categories/Limits/Initial.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Categories/Limits/Initial.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.7647058824, "max_line_length": 92, "alphanum_fraction": 0.6577777778, "num_tokens": 967, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8807970748488297, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.610077038250863}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import HoTT\n\nmodule homotopy.PathSetIsInital {i} (A : Type i)\n -- (A-conn : is-connected 0 A)\n where\n\n open Cover\n\n module _\n (a₁ : A)\n -- And an arbitrary covering.\n {k} (cov : Cover A k)\n -- (cov-conn : is-connected 0 (Cover.TotalSpace cov))\n (a↑₁ : Fiber cov a₁)\n where\n\n private\n univ-cover = path-set-cover ⊙[ A , a₁ ]\n\n -- Weak initiality by transport.\n quotient-cover : CoverHom univ-cover cov\n quotient-cover _ p = cover-trace cov a↑₁ p\n\n -- Strong initiality by path induction.\n module Uniqueness\n (cover-hom : CoverHom univ-cover cov)\n (pres-a↑₁ : cover-hom a₁ idp₀ == a↑₁)\n where\n\n private\n lemma₁ : ∀ a p → cover-hom a [ p ] == quotient-cover a [ p ]\n lemma₁ ._ idp = pres-a↑₁\n\n lemma₂ : ∀ a p → cover-hom a p == quotient-cover a p\n lemma₂ a = Trunc-elim\n (λ p → =-preserves-level 0 (Cover.Fiber-level cov a))\n (lemma₁ a)\n\n theorem : cover-hom == quotient-cover\n theorem = λ= λ a → λ= $ lemma₂ a\n", "meta": {"hexsha": "92f3d4fd81ada2fb934079d55f9e635573dcb68d", "size": 1063, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/homotopy/PathSetIsInital.agda", "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "theorems/homotopy/PathSetIsInital.agda", "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "theorems/homotopy/PathSetIsInital.agda", "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.7209302326, "max_line_length": 68, "alphanum_fraction": 0.5738476011, "num_tokens": 329, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8807970717197768, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.6100770360835496}} {"text": "-- There was a bug where f (suc n) didn't reduce for neutral n.\nmodule Issue26 where\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\n{-# BUILTIN NATURAL Nat #-}\n{-# BUILTIN ZERO zero #-}\n{-# BUILTIN SUC suc #-}\n\nf : Nat -> Nat\nf 0 = 0\nf (suc n) = f n\n\ndata _==_ {A : Set}(x : A) : A -> Set where\n refl : x == x\n\nlem : (n : Nat) -> f (suc n) == f n\nlem n = refl\n\n", "meta": {"hexsha": "e3ae17a782ee8f889e9dc6a08f5d4582a74f999e", "size": 386, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/Issue26.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "test/succeed/Issue26.agda", "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/Issue26.agda", "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.5454545455, "max_line_length": 63, "alphanum_fraction": 0.5284974093, "num_tokens": 140, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.808067204308405, "lm_q2_score": 0.7549149923816048, "lm_q1q2_score": 0.6100220473843042}} {"text": "open import Categories\nopen import Monads\n\nmodule Monads.Kleisli {a b}{C : Cat {a}{b}}(M : Monad C) where\n\nopen import Library\nopen Cat C\nopen Monad M\n\nKl : Cat\nKl = record{\n Obj = Obj;\n Hom = λ X Y → Hom X (T Y);\n iden = η;\n comp = λ f g → comp (bind f) g;\n idl = λ{X}{Y}{f} → \n proof\n comp (bind η) f \n ≅⟨ cong (λ g → comp g f) law1 ⟩ \n comp iden f \n ≅⟨ idl ⟩ \n f \n ∎;\n idr = law2;\n ass = λ{_}{_}{_}{_}{f}{g}{h} → \n proof\n comp (bind (comp (bind f) g)) h \n ≅⟨ cong (λ f → comp f h) law3 ⟩\n comp (comp (bind f) (bind g)) h\n ≅⟨ ass ⟩\n comp (bind f) (comp (bind g) h) \n ∎}\n", "meta": {"hexsha": "688e8e6c71a1c6df9991fcb5d24f0e6521138b09", "size": 626, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Monads/Kleisli.agda", "max_stars_repo_name": "jmchapman/Relative-Monads", "max_stars_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 21, "max_stars_repo_stars_event_min_datetime": "2015-07-30T01:25:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-13T18:02:18.000Z", "max_issues_repo_path": "Monads/Kleisli.agda", "max_issues_repo_name": "jmchapman/Relative-Monads", "max_issues_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:12:33.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-29T09:50:26.000Z", "max_forks_repo_path": "Monads/Kleisli.agda", "max_forks_repo_name": "jmchapman/Relative-Monads", "max_forks_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-04T21:33:13.000Z", "avg_line_length": 18.9696969697, "max_line_length": 62, "alphanum_fraction": 0.5, "num_tokens": 275, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9314625088705931, "lm_q2_score": 0.6548947425132314, "lm_q1q2_score": 0.6100098999075356}} {"text": "module Cats.Category.Product.Binary where\n\nopen import Level using (_⊔_)\nopen import Relation.Binary using (Rel ; IsEquivalence ; _Preserves₂_⟶_⟶_)\nopen import Relation.Binary.Product.Pointwise using (×-isEquivalence ; Pointwise)\n\n\nopen import Cats.Category.Base\nopen import Cats.Util.Logic.Constructive using (_∧_ ; _,_)\n\n\nmodule Build {lo la l≈ lo′ la′ l≈′}\n (C : Category lo la l≈)\n (D : Category lo′ la′ l≈′)\n where\n\n infixr 9 _∘_\n infixr 4 _≈_\n\n\n private\n module C = Category C\n module D = Category D\n\n\n Obj : Set (lo ⊔ lo′)\n Obj = C.Obj ∧ D.Obj\n\n\n _⇒_ : Obj → Obj → Set (la ⊔ la′)\n (A , A′) ⇒ (B , B′) = (A C.⇒ B) ∧ (A′ D.⇒ B′)\n\n\n _≈_ : ∀ {A B} → Rel (A ⇒ B) (l≈ ⊔ l≈′)\n _≈_ = Pointwise C._≈_ D._≈_\n\n\n id : {A : Obj} → A ⇒ A\n id = C.id , D.id\n\n\n _∘_ : ∀ {A B C} → B ⇒ C → A ⇒ B → A ⇒ C\n (f , f′) ∘ (g , g′) = f C.∘ g , f′ D.∘ g′\n\n\n equiv : ∀ {A B} → IsEquivalence (_≈_ {A} {B})\n equiv = ×-isEquivalence C.equiv D.equiv\n\n\n ∘-resp : ∀ {A B C} → _∘_ {A} {B} {C} Preserves₂ _≈_ ⟶ _≈_ ⟶ _≈_\n ∘-resp (eq₁ , eq₁′) (eq₂ , eq₂′) = C.∘-resp eq₁ eq₂ , D.∘-resp eq₁′ eq₂′\n\n\n id-r : ∀ {A B} {f : A ⇒ B} → f ∘ id ≈ f\n id-r = C.id-r , D.id-r\n\n\n id-l : ∀ {A B} {f : A ⇒ B} → id ∘ f ≈ f\n id-l = C.id-l , D.id-l\n\n\n assoc : ∀ {A B C D} {f : C ⇒ D} {g : B ⇒ C} {h : A ⇒ B}\n → (f ∘ g) ∘ h ≈ f ∘ (g ∘ h)\n assoc = C.assoc , D.assoc\n\n\n _×_ : Category (lo ⊔ lo′) (la ⊔ la′) (l≈ ⊔ l≈′)\n _×_ = record\n { Obj = Obj\n ; _⇒_ = _⇒_\n ; _≈_ = _≈_\n ; id = id\n ; _∘_ = _∘_\n ; equiv = equiv\n ; ∘-resp = ∘-resp\n ; id-r = id-r\n ; id-l = id-l\n ; assoc = assoc\n }\n\nopen Build public using (_×_)\n", "meta": {"hexsha": "af2bedf7cb8e5449678973207e7e5e791cd4f0ca", "size": 1652, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Category/Product/Binary.agda", "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cats/Category/Product/Binary.agda", "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cats/Category/Product/Binary.agda", "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.1463414634, "max_line_length": 81, "alphanum_fraction": 0.4812348668, "num_tokens": 763, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473746782093, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.6099927639100533}} {"text": "\nmodule list where\n\nmodule List (A : Set) where\n\n data List : Set where\n nil : List\n _::_ : A -> List -> List\n\n _++_ : List -> List -> List\n nil ++ ys = ys\n (x :: xs) ++ ys = x :: (xs ++ ys)\n\n", "meta": {"hexsha": "072c344d4459e6737f9677502e12f0210ac9604b", "size": 209, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/list.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/list.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/list.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 14.9285714286, "max_line_length": 35, "alphanum_fraction": 0.4736842105, "num_tokens": 72, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8723473614033683, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.609992754627562}} {"text": "{-# OPTIONS --cubical #-}\n\nmodule Numeral.Natural.Equiv.Path where\n\nopen import Data.Boolean.Equiv.Path\nopen import Functional\nopen import Logic.Propositional\nopen import Numeral.Natural.Oper.Comparisons\nopen import Numeral.Natural\nopen import Relator.Equals.Proofs.Equivalence using () renaming ([≡]-equiv to Id-equiv ; [≡]-symmetry to Id-symmetry ; [≡]-to-function to Id-to-function ; [≡]-function to Id-function)\nopen import Structure.Function.Domain\nopen import Structure.Function\nopen import Structure.Relator.Properties\nopen import Type.Cubical.Path.Equality\nopen import Type.Cubical.Path\nopen import Type.Identity\n\ninstance\n 𝐒-injective : Injective(𝐒)\n Injective.proof 𝐒-injective p = congruence₁(𝐏) p\n\nℕ-Path-to-Id : ∀{x y : ℕ} → (Path x y) → (Id x y)\nℕ-Path-to-Id {𝟎} {𝟎} p = intro\nℕ-Path-to-Id {𝟎} {𝐒 y} = [⊥]-elim ∘ Bool-different-values ∘ congruence₁(positive?)\nℕ-Path-to-Id {𝐒 x} {𝟎} = [⊥]-elim ∘ Bool-different-values ∘ symmetry(Path) ∘ congruence₁(positive?)\nℕ-Path-to-Id {𝐒 x} {𝐒 y} p = congruence₁ ⦃ Id-equiv ⦄ ⦃ Id-equiv ⦄ (ℕ.𝐒) ⦃ Id-function ⦄ (ℕ-Path-to-Id {x}{y} (injective(ℕ.𝐒) p))\n", "meta": {"hexsha": "a473a3045719932ff810e434f7793386f779b558", "size": 1118, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Equiv/Path.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Equiv/Path.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Equiv/Path.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.4074074074, "max_line_length": 183, "alphanum_fraction": 0.7110912343, "num_tokens": 410, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8723473680407889, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.6099927483341794}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.HITs.Wedge.Base where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Pointed\nopen import Cubical.HITs.Pushout.Base\nopen import Cubical.Data.Sigma\nopen import Cubical.Data.Unit\n\n_⋁_ : ∀ {ℓ ℓ'} → Pointed ℓ → Pointed ℓ' → Type (ℓ-max ℓ ℓ')\n_⋁_ (A , ptA) (B , ptB) = Pushout {A = Unit} {B = A} {C = B} (λ _ → ptA) (λ _ → ptB)\n\n\n-- Pointed versions\n_⋁∙ₗ_ : ∀ {ℓ ℓ'} → Pointed ℓ → Pointed ℓ' → Pointed (ℓ-max ℓ ℓ')\nA ⋁∙ₗ B = (A ⋁ B) , (inl (snd A))\n\n_⋁∙ᵣ_ : ∀ {ℓ ℓ'} → Pointed ℓ → Pointed ℓ' → Pointed (ℓ-max ℓ ℓ')\nA ⋁∙ᵣ B = (A ⋁ B) , (inr (snd B))\n\n-- Wedge sums of functions\n_∨→_ : ∀ {ℓ ℓ' ℓ''} {A : Pointed ℓ} {B : Pointed ℓ'} {C : Pointed ℓ''}\n → (f : A →∙ C) (g : B →∙ C)\n → A ⋁ B → fst C\n(f ∨→ g) (inl x) = fst f x\n(f ∨→ g) (inr x) = fst g x\n(f ∨→ g) (push a i₁) = (snd f ∙ sym (snd g)) i₁\n\n-- Pointed version\n∨→∙ : ∀ {ℓ ℓ' ℓ''} {A : Pointed ℓ} {B : Pointed ℓ'} {C : Pointed ℓ''}\n → (f : A →∙ C) (g : B →∙ C) → ((A ⋁∙ₗ B) →∙ C)\nfst (∨→∙ {A = A} f g) = f ∨→ g\nsnd (∨→∙ {A = A} f g) = snd f\n\n-- Wedge sum of Units is contractible\nisContr-Unit⋁Unit : isContr ((Unit , tt) ⋁ (Unit , tt))\nfst isContr-Unit⋁Unit = inl tt\nsnd isContr-Unit⋁Unit (inl tt) = refl\nsnd isContr-Unit⋁Unit (inr tt) = push tt\nsnd isContr-Unit⋁Unit (push tt i) j = push tt (i ∧ j)\n\n⋁↪ : ∀ {ℓ ℓ'} {A : Pointed ℓ} {B : Pointed ℓ'}\n → A ⋁ B → typ A × typ B\n⋁↪ {B = B} (inl x) = x , pt B\n⋁↪ {A = A} (inr x) = pt A , x\n⋁↪ {A = A} {B = B} (push a i) = pt A , pt B\n", "meta": {"hexsha": "f2094d066e3e87cb27b992a647b030fb4b85f8e2", "size": 1506, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/Wedge/Base.agda", "max_stars_repo_name": "lpw25/cubical", "max_stars_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/HITs/Wedge/Base.agda", "max_issues_repo_name": "lpw25/cubical", "max_issues_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/HITs/Wedge/Base.agda", "max_forks_repo_name": "lpw25/cubical", "max_forks_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.0425531915, "max_line_length": 84, "alphanum_fraction": 0.5258964143, "num_tokens": 762, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.7690802370707281, "lm_q1q2_score": 0.6099621129588821}} {"text": "module Numeral.Finite.Functions where\n\nimport Lvl\nopen import Syntax.Number\nopen import Lang.Instance\nopen import Logic.Propositional\nopen import Logic.Predicate\nopen import Numeral.Finite\nopen import Numeral.Finite.Bound\nopen import Numeral.Natural hiding (𝐏)\nimport Numeral.Natural.Function as ℕ\nimport Numeral.Natural.Function.Proofs as ℕ\nopen import Numeral.Natural.Oper\n\n-- Maximum function.\n-- Returns the greatest number.\nmax : ∀{a b} → 𝕟(a) → 𝕟(b) → 𝕟(ℕ.max a b)\nmax 𝟎 𝟎 = 𝟎\nmax {a}{b} (𝐒(x)) 𝟎 = bound-[≤] (ℕ.max-orderₗ {a}{b}) (𝐒(x))\nmax {a}{b} 𝟎 (𝐒(y)) = bound-[≤] (ℕ.max-orderᵣ {a}{b}) (𝐒(y))\nmax (𝐒(x)) (𝐒(y)) = 𝐒(max x y)\n\n-- Minimum function.\n-- Returns the smallest number.\nmin : ∀{a b} → 𝕟(a) → 𝕟(b) → 𝕟(ℕ.min a b)\nmin 𝟎 𝟎 = 𝟎\nmin (𝐒(_)) 𝟎 = 𝟎\nmin 𝟎 (𝐒(_)) = 𝟎\nmin (𝐒(x)) (𝐒(y)) = 𝐒(min x y)\n", "meta": {"hexsha": "cd4b727778bd627f3651e0c9f13706d461d133ae", "size": 873, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Finite/Functions.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Finite/Functions.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Finite/Functions.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.1, "max_line_length": 65, "alphanum_fraction": 0.6093928981, "num_tokens": 371, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9263037221561136, "lm_q2_score": 0.6584175139669997, "lm_q1q2_score": 0.6098945939204067}} {"text": "\nopen import Agda.Builtin.Coinduction\nopen import Agda.Builtin.Nat\nopen import Agda.Builtin.List\nopen import Agda.Builtin.Equality\n\ndata Colist (A : Set) : Set where\n [] : Colist A\n _∷_ : A → ∞ (Colist A) → Colist A\n\nfrom : Nat → Colist Nat\nfrom n = let sn = suc n in n ∷ ♯ (from sn)\n\ntake : {A : Set} → Nat → Colist A → List A\ntake zero xs = []\ntake (suc n) [] = []\ntake (suc n) (x ∷ xs) = x ∷ take n (♭ xs)\n\ncheck : take 3 (from 5) ≡ 5 ∷ 6 ∷ 7 ∷ []\ncheck = refl\n", "meta": {"hexsha": "99935dd0d5c1232fb3df9b32c58cf9c0f4e555a5", "size": 469, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue140.agda", "max_stars_repo_name": "alhassy/agda", "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Succeed/Issue140.agda", "max_issues_repo_name": "alhassy/agda", "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/Issue140.agda", "max_forks_repo_name": "alhassy/agda", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 22.3333333333, "max_line_length": 42, "alphanum_fraction": 0.6012793177, "num_tokens": 186, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8376199633332891, "lm_q2_score": 0.7279754548076478, "lm_q1q2_score": 0.6097667737635164}} {"text": "module Computability.Recursive where\n\nopen import Data.Empty using (⊥; ⊥-elim)\nopen import Data.Unit using (⊤)\nopen import Data.Bool using (Bool; false; true)\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_; pred)\nopen import Data.Product using (_×_)\nopen import Data.Fin using (Fin; zero; suc; punchIn; punchOut)\nopen import Data.Sum using (_⊎_)\nopen import Data.Vec using (Vec; _∷_; []; lookup) renaming (map to map-Vec)\nopen import Function using (Bijective)\nopen import Relation.Binary.PropositionalEquality using (_≡_)\nopen import Level renaming (zero to lzero; suc to lsuc)\n\nvariable\n n m : ℕ\n b : Bool\n\ndata RecFun : (use-mu : Bool) → ℕ → Set where\n Var : Fin n → RecFun b n\n Bind : Vec (RecFun b m) n → RecFun b n → RecFun b m\n Zero : RecFun b 0\n Suc : RecFun b 1\n Rec : RecFun b n → RecFun b (2 + n) → RecFun b (suc n)\n Mu : RecFun b (suc n) → RecFun true n\n\nmutual\n eval-no-mu : Vec ℕ n → RecFun false n → ℕ\n eval-no-mu v (Var i) = lookup v i\n eval-no-mu v (Bind xs r) = eval-no-mu (eval-bindings v xs) r\n eval-no-mu v Zero = zero\n eval-no-mu (x ∷ []) Suc = suc x\n eval-no-mu (x ∷ v) (Rec base rec) = eval-no-mu-rec x v base rec\n\n eval-bindings : ∀{n m} → Vec ℕ m → Vec (RecFun false m) n → Vec ℕ n\n eval-bindings v [] = []\n eval-bindings v (x ∷ xs) = eval-no-mu v x ∷ eval-bindings v xs\n\n eval-no-mu-rec : ℕ → Vec ℕ n → RecFun false n → RecFun false (2 + n) → ℕ\n eval-no-mu-rec zero v base rec = eval-no-mu v base\n eval-no-mu-rec (suc k) v base rec = eval-no-mu (k ∷ result ∷ v) rec\n where result = eval-no-mu-rec k v base rec\n\npostulate\n enum-RecFun : ∀ vars → ℕ → RecFun true vars\n enum-RecFun-Surj : ∀ vars → ℕ → Bijective {A = ℕ} {B = RecFun true vars} _≡_ _≡_ (enum-RecFun vars)\n \n", "meta": {"hexsha": "cae34b4ef5deaa9afd7742e64c083ac7963e7d7c", "size": 1726, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Computability/Recursive.agda", "max_stars_repo_name": "jesyspa/computability-in-agda", "max_stars_repo_head_hexsha": "1b5cf338eb0adb90c1897383e05251ddd954efff", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-09-19T15:51:22.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-30T11:15:51.000Z", "max_issues_repo_path": "Computability/Recursive.agda", "max_issues_repo_name": "jesyspa/computability-in-agda", "max_issues_repo_head_hexsha": "1b5cf338eb0adb90c1897383e05251ddd954efff", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Computability/Recursive.agda", "max_forks_repo_name": "jesyspa/computability-in-agda", "max_forks_repo_head_hexsha": "1b5cf338eb0adb90c1897383e05251ddd954efff", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.9583333333, "max_line_length": 101, "alphanum_fraction": 0.6477404403, "num_tokens": 615, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.837619963333289, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.6097667737635163}} {"text": "\nmodule Issue739 where\n\nrecord ⊤ : Set where\n constructor tt\n\nrecord Σ (A : Set) (B : A → Set) : Set where\n constructor _,_\n field\n fst : A\n snd : B fst\n\nuncurry : {A : Set} {B : A → Set} →\n ((x : A) → B x → Set) →\n Σ A B → Set\nuncurry f (x , y) = f x y\n\ndata U : Set₁\n\nEl : U → Set\n\ninfixl 5 _▻_\n\ndata U where\n ε : U\n _▻_ : (u : U) → (El u → Set) → U\n\nEl ε = ⊤\nEl (u ▻ P) = Σ (El u) P\n\nId : ∀ u → (El u → Set) → El u → Set\nId u P = P\n\n-- Type-checks:\n\nworks : U\nworks =\n ε\n ▻ (λ _ → ⊤)\n ▻ (λ { (_ , _) → ⊤ })\n\n-- Type-checks:\n\nworks′ : U\nworks′ =\n ε\n ▻ (λ _ → ⊤)\n ▻ Id (_ ▻ _) (λ { (_ , _) → ⊤ })\n\n-- Type-checks:\n\nworks″ : U\nworks″ =\n ε\n ▻ (λ _ → ⊤)\n ▻ Id _ (uncurry λ _ _ → ⊤)\n\n-- Type-checks:\n\nworks‴ : U\nworks‴ =\n ε\n ▻ (λ _ → ⊤)\n ▻ Id _ const-⊤\n where\n const-⊤ : _ → _\n const-⊤ (_ , _) = ⊤\n\n-- Type-checks:\n\nworks⁗ : U\nworks⁗ =\n ε\n ▻ (λ _ → ⊤)\n ▻ Id _ const-⊤\n where\n const-⊤ : _ → _\n const-⊤ = λ { (_ , _) → ⊤ }\n\n-- Type-checks:\n\nworks′́ : U\nworks′́ =\n ε\n ▻ (λ _ → ⊤)\n ▻ Id _ (λ { _ → ⊤ })\n\n-- Doesn't type-check (but I want to write something like this):\n\nfails : U\nfails =\n ε\n ▻ (λ _ → ⊤)\n ▻ Id _ (λ { (_ , _) → ⊤ })\n\n-- Given all the working examples I'm led to believe that there is\n-- something wrong with pattern-matching lambdas. Please correct me if\n-- I'm wrong.\n\n-- Andreas, 2012-10-29 should work now.\n", "meta": {"hexsha": "797e7796ebb4b5dad3a466c477b7126e9ca6cfe9", "size": 1383, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue739.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/succeed/Issue739.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/Issue739.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 13.6930693069, "max_line_length": 70, "alphanum_fraction": 0.4750542299, "num_tokens": 598, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956580903722561, "lm_q2_score": 0.7662936324115011, "lm_q1q2_score": 0.6097077282289545}} {"text": "module Numeral.Natural.Coprime.Proofs where\n\nopen import Functional\nopen import Logic\nopen import Logic.Classical\nopen import Logic.Propositional\nopen import Logic.Propositional.Theorems\nimport Lvl\nopen import Numeral.Finite\nopen import Numeral.Natural\nopen import Numeral.Natural.Coprime\nopen import Numeral.Natural.Decidable\nopen import Numeral.Natural.Function.GreatestCommonDivisor\nopen import Numeral.Natural.Relation.Divisibility.Proofs\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.Prime\nopen import Numeral.Natural.Prime.Proofs\nopen import Numeral.Natural.Relation.Divisibility\nopen import Numeral.Natural.Relation.Order\nopen import Numeral.Natural.Relation.Order.Proofs\nopen import Relator.Equals\nopen import Structure.Relator.Properties\nopen import Type.Properties.Decidable.Proofs\nopen import Type\n\nprivate variable n x y d p : ℕ\n\n-- 1 is the only number coprime to itself because it does not have any divisors except for itself.\nCoprime-reflexivity-condition : Coprime(n)(n) ↔ (n ≡ 1)\nCoprime-reflexivity-condition {n} = [↔]-intro l (r{n}) where\n l : Coprime(n)(n) ← (n ≡ 1)\n Coprime.proof(l [≡]-intro) {a} a1 _ = [1]-only-divides-[1] (a1)\n\n r : ∀{n} → Coprime(n)(n) → (n ≡ 1)\n r {𝟎} (intro z1) = z1 Div𝟎 Div𝟎\n r {𝐒(𝟎)} _ = [≡]-intro\n r {𝐒(𝐒(n))} (intro ssn1) = ssn1 {𝐒(𝐒(n))} divides-reflexivity divides-reflexivity\n\ninstance\n Coprime-symmetry : Symmetry(Coprime)\n Coprime.proof(Symmetry.proof Coprime-symmetry (intro proof)) {n} nx ny = proof {n} ny nx\n\n-- The only number coprime to 0 is 1 because while all numbers divide 0, only 1 divides 1.\nCoprime-of-0-condition : ∀{x} → Coprime(0)(x) → (x ≡ 1)\nCoprime-of-0-condition {0} (intro n1) = n1 Div𝟎 Div𝟎\nCoprime-of-0-condition {1} (intro n1) = [≡]-intro\nCoprime-of-0-condition {𝐒(𝐒(x))} (intro n1) = n1 Div𝟎 divides-reflexivity\n\n-- 1 is coprime to all numbers because only 1 divides 1.\nCoprime-of-1 : Coprime(1)(x)\nCoprime.proof (Coprime-of-1 {x}) {n} n1 nx = [1]-only-divides-[1] n1\n\nCoprime-of-[+] : Coprime(x)(y) → Coprime(x)(x + y)\nCoprime.proof (Coprime-of-[+] {x}{y} (intro proof)) {n} nx nxy = proof {n} nx ([↔]-to-[→] (divides-without-[+] nxy) nx)\n\n-- Coprimality is obviously equivalent to the greatest common divisor being 1 by definition.\nCoprime-gcd : Coprime(x)(y) ↔ (gcd(x)(y) ≡ 1)\nCoprime-gcd = [↔]-transitivity ([↔]-intro l r) Gcd-gcd-value where\n l : Coprime(x)(y) ← Gcd(x)(y) 1\n Coprime.proof (l p) nx ny = [1]-only-divides-[1] (Gcd.maximum₂ p nx ny)\n\n r : Coprime(x)(y) → Gcd(x)(y) 1\n Gcd.divisor(r (intro coprim)) 𝟎 = [1]-divides\n Gcd.divisor(r (intro coprim)) (𝐒 𝟎) = [1]-divides\n Gcd.maximum(r (intro coprim)) dv with [≡]-intro ← coprim (dv 𝟎) (dv(𝐒 𝟎)) = [1]-divides\n\n-- A smaller number and a greater prime number is coprime.\n-- If the greater number is prime, then no smaller number will divide it except for 1, and greater numbers never divide smaller ones.\n-- Examples (y = 7):\n-- The prime factors of 7 is only itself (because it is prime).\n-- Then the only alternatives for x are:\n-- x ∈ {1,2,3,4,5,6}\n-- None of them is able to have 7 as a prime factor because it is greater:\n-- 1=1, 2=2, 3=3, 4=2⋅2, 5=5, 6=2⋅3\nCoprime-of-Prime : (𝐒(x) < y) → Prime(y) → Coprime(𝐒(x))(y)\nCoprime.proof (Coprime-of-Prime (succ(succ lt)) prim) nx ny with prime-only-divisors prim ny\nCoprime.proof (Coprime-of-Prime (succ(succ lt)) prim) nx ny | [∨]-introₗ n1 = n1\nCoprime.proof (Coprime-of-Prime (succ(succ lt)) prim) nx ny | [∨]-introᵣ [≡]-intro with () ← [≤]-to-[≯] lt ([≤]-without-[𝐒] (divides-upper-limit nx))\n\n-- A prime number either divides a number or forms a coprime pair.\n-- If a prime number does not divide a number, then it cannot share any divisors because by definition, a prime only has 1 as a divisor.\nPrime-to-div-or-coprime : Prime(x) → ((x ∣ y) ∨ Coprime(x)(y))\nPrime-to-div-or-coprime {y = y} (intro {x} prim) = [¬→]-disjunctive-formᵣ ⦃ decider-to-classical ⦄ (intro ∘ coprim) where\n coprim : (𝐒(𝐒(x)) ∤ y) → ∀{n} → (n ∣ 𝐒(𝐒(x))) → (n ∣ y) → (n ≡ 1)\n coprim nxy {𝟎} nx ny with () ← [0]-divides-not nx\n coprim nxy {𝐒 n} nx ny with prim nx\n ... | [∨]-introₗ [≡]-intro = [≡]-intro\n ... | [∨]-introᵣ [≡]-intro with () ← nxy ny\n\ndivides-to-converse-coprime : ∀{x y z} → (x ∣ y) → Coprime(y)(z) → Coprime(x)(z)\ndivides-to-converse-coprime xy (intro yz) = intro(nx ↦ nz ↦ yz (transitivity(_∣_) nx xy) nz)\n", "meta": {"hexsha": "413ff184849b348eb82f57f9e41d58bf8017ec31", "size": 4391, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Coprime/Proofs.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Coprime/Proofs.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Coprime/Proofs.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.7282608696, "max_line_length": 149, "alphanum_fraction": 0.6731951719, "num_tokens": 1672, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8887587964389112, "lm_q2_score": 0.6859494485880927, "lm_q1q2_score": 0.6096436063450881}} {"text": "{-# OPTIONS --exact-split #-}\nmodule ExactSplitBerry where\n\ndata Bool : Set where\n true false : Bool\n\nmaj : Bool → Bool → Bool → Bool\nmaj true true true = true\nmaj x true false = x\nmaj false y true = y\nmaj true false z = z\nmaj false false false = false\n", "meta": {"hexsha": "90365403132d02fc0b4b8972e44caeee343a622e", "size": 272, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/ExactSplitBerry.agda", "max_stars_repo_name": "alhassy/agda", "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Fail/ExactSplitBerry.agda", "max_issues_repo_name": "alhassy/agda", "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Fail/ExactSplitBerry.agda", "max_forks_repo_name": "alhassy/agda", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 20.9230769231, "max_line_length": 31, "alphanum_fraction": 0.6433823529, "num_tokens": 78, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8558511616741041, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.609564737034869}} {"text": "module Data.Option.Equiv where\n\nimport Lvl\nopen import Data.Option\nopen import Structure.Function\nopen import Structure.Function.Domain\nopen import Structure.Setoid\nopen import Type\n\nprivate variable ℓ ℓₑ ℓₑₐ : Lvl.Level\nprivate variable A : Type{ℓ}\n\nrecord Extensionality ⦃ equiv-A : Equiv{ℓₑₐ}(A) ⦄ (equiv : Equiv{ℓₑ}(Option(A))) : Type{Lvl.of(A) Lvl.⊔ ℓₑₐ Lvl.⊔ ℓₑ} where\n constructor intro\n private instance _ = equiv\n field\n ⦃ Some-function ⦄ : Function Some\n ⦃ Some-injective ⦄ : Injective Some\n cases-inequality : ∀{x : A} → (None ≢ Some(x))\n", "meta": {"hexsha": "657dbb105cd24ccc4b7df6f712dda4d104842062", "size": 566, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Option/Equiv.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/Option/Equiv.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Option/Equiv.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.3, "max_line_length": 123, "alphanum_fraction": 0.7102473498, "num_tokens": 199, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8596637612961506, "lm_q2_score": 0.7090191337850933, "lm_q1q2_score": 0.609518055380632}} {"text": "module Data.Option.Equiv.Id where\n\nimport Lvl\nopen import Data.Option\nopen import Data.Option.Functions\nopen import Data.Option.Equiv\nopen import Relator.Equals\nopen import Relator.Equals.Proofs.Equiv\nopen import Structure.Function\nopen import Structure.Function.Domain\nopen import Type\n\nprivate variable ℓ : Lvl.Level\nprivate variable T A B : Type{ℓ}\nprivate variable f : A → B\nprivate variable o : Option T\n\ninstance\n Some-injectivity : Injective {B = Option(T)} (Some)\n Injective.proof Some-injectivity [≡]-intro = [≡]-intro\n\ninstance\n Id-Option-extensionality : Extensionality{A = T} ([≡]-equiv)\n Extensionality.cases-inequality Id-Option-extensionality ()\n\nmap-injectivity : ⦃ inj-f : Injective(f) ⦄ → Injective(map f)\nInjective.proof map-injectivity {None} {None} [≡]-intro = [≡]-intro\nInjective.proof (map-injectivity {f = f}) {Some x} {Some y} p = congruence₁(Some) (injective f(injective(Some) p))\n\n-- TODO: Generalize and move\nmap-None : (map f o ≡ None) → (o ≡ None)\nmap-None {o = None} p = [≡]-intro\n", "meta": {"hexsha": "5dca841df02d0a87fd2a9e90cce886ef41a7b00a", "size": 1043, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Option/Equiv/Id.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/Option/Equiv/Id.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Option/Equiv/Id.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.6060606061, "max_line_length": 122, "alphanum_fraction": 0.711409396, "num_tokens": 311, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637397236824, "lm_q2_score": 0.7090191399336401, "lm_q1q2_score": 0.6095180453710219}} {"text": "module examplesPaperJFP.safeFibStackMachineObjectOriented where\n\nopen import Data.Nat\nopen import Data.List\nopen import Data.Vec\nopen import Data.Sum\nopen import Data.Fin renaming (_+_ to _+f_)\nopen import Data.Product\nopen import examplesPaperJFP.StatefulObject\nopen import examplesPaperJFP.StackBisim\n\nopen import examplesPaperJFP.triangleRightOperator\n\n\n\n{- Object based version of safe stack\n it is essentially the last part of safeFibStackMachine.agda\n with the names simplified -}\n\n\n{- the state is what we are computing right now:\n fib n menas we need to compute fib n\n val k means we have computed the value k\n-}\n\n\n\ndata FibState : Set where\n fib : ℕ → FibState\n val : ℕ → FibState\n\ndata FibStackEl : Set where\n _+• : ℕ → FibStackEl\n •+fib_ : ℕ → FibStackEl\n\nFibStack : ℕ → Set\nFibStack = Objectˢ (StackInterfaceˢ FibStackEl)\n\nFibStackmachine : Set\nFibStackmachine = Σ[ n ∈ ℕ ] (FibState × FibStack n)\n\nreduce : FibStackmachine → FibStackmachine ⊎ ℕ\nreduce (n , fib 0 , stack) = inj₁ (n , val 1 , stack)\nreduce (n , fib 1 , stack) = inj₁ (n , val 1 , stack)\nreduce (n , fib (suc (suc m)) , stack) =\n objectMethod stack (push (•+fib m)) ▹ λ { (_ , stack₁) →\n inj₁ ( suc n , fib (suc m) , stack₁) }\nreduce (0 , val k , stack) = inj₂ k\nreduce (suc n , val k , stack) =\n objectMethod stack pop ▹ λ { (k′ +• , stack₁) →\n inj₁ (n , val (k′ + k) , stack₁)\n ; (•+fib m , stack₁) →\n objectMethod stack₁ (push (k +•)) ▹ λ { (_ , stack₂) →\n inj₁ (suc n , fib m , stack₂) }}\n\niter : (m : ℕ) → FibStackmachine → FibStackmachine ⊎ ℕ\niter 0 s = inj₁ s\niter (suc n) s with reduce s\n... | inj₁ s′ = iter n s′\n... | inj₂ m = inj₂ m\n\ncomputeFib : ℕ → ℕ → FibStackmachine ⊎ ℕ\ncomputeFib n m = iter n (0 , fib m , stack [])\n\nfibO0 : FibStackmachine ⊎ ℕ\nfibO0 = computeFib 2 0\n\n-- evaluates to inj₂ 1\n\nfibO1 : FibStackmachine ⊎ ℕ\nfibO1 = computeFib 2 1\n-- evaluates to inj₂ 1\n\nfibO2 : FibStackmachine ⊎ ℕ\nfibO2 = computeFib 10 2\n-- evaluates to inj₂ 2\n\nfibO3 : FibStackmachine ⊎ ℕ\nfibO3 = computeFib 14 3\n-- evaluates to inj₂ 3\n\nfibO4 : FibStackmachine ⊎ ℕ\nfibO4 = computeFib 30 4\n-- evaluates to inj₂ 5\n\nfibO5 : FibStackmachine ⊎ ℕ\nfibO5 = computeFib 30 5\n-- evaluates to inj₂ 8\n\n{-# TERMINATING #-}\ncomputeFibRec : FibStackmachine → ℕ\ncomputeFibRec s with reduce s\n... | inj₁ s′ = computeFibRec s′\n... | inj₂ k = k\n\n\nfibUsingStack : ℕ → ℕ\nfibUsingStack m = computeFibRec (0 , fib m , stack [])\n\n\ntest : List ℕ\ntest = fibUsingStack 0 ∷ fibUsingStack 1 ∷ fibUsingStack 2 ∷ fibUsingStack 3 ∷ fibUsingStack 4 ∷ fibUsingStack 5 ∷ fibUsingStack 6 ∷ []\n\ntestExpected : List ℕ\ntestExpected = 1 ∷ 1 ∷ 2 ∷ 3 ∷ 5 ∷ 8 ∷ 13 ∷ []\n", "meta": {"hexsha": "16bda22826dd3c8092fa971b018b4bbe11d5a2fd", "size": 2935, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/examplesPaperJFP/safeFibStackMachineObjectOriented.agda", "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 23, "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_issues_repo_path": "examples/examplesPaperJFP/safeFibStackMachineObjectOriented.agda", "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/examplesPaperJFP/safeFibStackMachineObjectOriented.agda", "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "avg_line_length": 27.6886792453, "max_line_length": 136, "alphanum_fraction": 0.606132879, "num_tokens": 1037, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637469145054, "lm_q2_score": 0.7090191337850933, "lm_q1q2_score": 0.6095180451837703}} {"text": "{-# OPTIONS --safe --without-K #-}\nopen import Relation.Binary\n\nmodule Data.List.Membership.Setoid.Distinct where\n\nopen import Data.List as List using (List; []; _∷_; _++_)\nopen import Data.List.Any as Any hiding (map; head; tail)\nopen import Data.List.Any.Properties\n\nopen import Relation.Binary.PropositionalEquality as P using (_≡_)\nopen import Function\nopen import Function.Equivalence using (_⇔_; equivalence)\nopen import Function.Equality using (_⟨$⟩_)\nopen import Function.Inverse using ()\nopen import Function.Injection using (_↣_; Injection)\nopen import Data.Product hiding (map)\nopen import Data.Sum hiding (map)\nimport Level as L\nopen import Data.Fin as Fin using (Fin)\nopen import Data.Nat as ℕ\n\nmodule _ {a p} {S : Setoid a p} where\n open Setoid S renaming (Carrier to A)\n open import Data.List.Membership.Setoid (S)\n open import Data.List.Membership.Setoid.Properties\n open import Data.List.Membership.Setoid.Disjoint (S) renaming (Disjoint to _⋈_) \n open import Data.List.Membership.Setoid.Trans (S)\n open import Data.Empty\n data Distinct : List A → Set (a L.⊔ p) where\n distinct-[] : Distinct []\n _distinct-∷_by_ : ∀ x {xs} → Distinct xs → x ∉ xs → Distinct (x ∷ xs)\n \n head : ∀ {x}{xs : List A} → Distinct (x ∷ xs) → A\n head (x distinct-∷ _ by _) = x\n \n tail : ∀ {x}{xs : List A} → Distinct (x ∷ xs) → Distinct xs\n tail (_ distinct-∷ dis by _) = dis\n\n head∉tail : ∀ {x}{xs : List A} → Distinct (x ∷ xs) → x ∉ xs\n head∉tail (_ distinct-∷ _ by x∉xs) = x∉xs\n\n distinct-[_] : ∀ x → Distinct (List.[ x ])\n distinct-[ x ] = x distinct-∷ distinct-[] by (λ ())\n \n ⋈-++ : ∀ (xs ys : List A) →\n Distinct (xs ++ ys) ⇔ (Distinct xs × Distinct ys × xs ⋈ ys)\n ⋈-++ xs ys = equivalence to from\n where\n to : ∀ {xs ys : List A} → Distinct (xs ++ ys) → (Distinct xs × Distinct ys × xs ⋈ ys)\n to {[]} dys = distinct-[] , dys , disjoint-[]ʳ \n to {x ∷ xs} {ys} (.x distinct-∷ dis by x∉xsys) with to {xs = xs} dis\n ... | dxs , dys , xs⋈ys = x distinct-∷ dxs by (λ x∈xs → x∉xsys (++⁺ˡ x∈xs)) , dys ,\n λ { (here px) ∈ys → x∉xsys (++⁺ʳ xs (≈-trans-∈ (sym px) ∈ys)) ; (there ∈xs) ∈ys → xs⋈ys ∈xs ∈ys}\n \n from : ∀ {xs ys : List A} →\n (Distinct xs × Distinct ys × xs ⋈ ys) → Distinct (xs ++ ys)\n from (distinct-[] , dys , xs⋈ys) = dys\n from {xs = .x ∷ xs} ((x distinct-∷ dxs by x∉xs) , dys , xxs⋈ys) with from (dxs , dys , xxs⋈ys ∘ there)\n ... | dxsys = x distinct-∷ dxsys by λ x∈xsys → case ++⁻ xs x∈xsys of λ { (inj₁ x∈xs) → x∉xs x∈xs\n ; (inj₂ x∈ys) → xxs⋈ys (here refl) x∈ys}\n\n lookup-injective : {xs : List A}(dxs : Distinct xs) → ∀ {i j} → List.lookup xs i ≡ List.lookup xs j → i ≡ j\n lookup-injective distinct-[] {()} {()} _\n lookup-injective (x distinct-∷ dxs by x∉xs) {Fin.zero} {Fin.zero} _ = P.refl\n lookup-injective (x distinct-∷ dxs by x∉xs) {Fin.suc i} {Fin.suc j} eq = P.cong Fin.suc (lookup-injective dxs eq)\n lookup-injective {xs} (x distinct-∷ dxs by x∉xs) {Fin.zero} {Fin.suc j} eq rewrite eq = ⊥-elim (x∉xs (∈-lookup S _ j))\n lookup-injective (x distinct-∷ dxs by x∉xs) {Fin.suc i} {Fin.zero} eq rewrite P.sym eq = ⊥-elim (x∉xs (∈-lookup S _ i))\n \nmodule _ {a₁ a₂ p₁ p₂}{S₁ : Setoid a₁ p₁} {S₂ : Setoid a₂ p₂} where\n open Setoid S₁ renaming (Carrier to A) using ()\n open Setoid S₂ renaming (Carrier to B) using ()\n open import Data.List.Membership.Setoid (S₂) renaming (_∉_ to _∉₂_) using ()\n open import Data.List.Membership.Setoid.Properties\n open import Data.List.Membership.Setoid.Trans (S₁) \n map : (f : Injection S₁ S₂) → ∀ {xs : List A} → Distinct {S = S₁} xs → Distinct {S = S₂} (List.map (Injection.to f ⟨$⟩_) xs) \n map f {[]} distinct-[] = distinct-[]\n map f {.x ∷ xs} (x distinct-∷ dis by x∉xs) = fx distinct-∷ map f dis by lemma\n where\n fx = Injection.to f ⟨$⟩ x\n\n lemma : fx ∉₂ List.map (Injection.to f ⟨$⟩_) xs\n lemma p with ∈-map⁻ S₁ S₂ p\n ... | _ , y∈xs , fx≈fy = x∉xs (≈-trans-∈ (Injection.injective f fx≈fy) y∈xs) \n\n", "meta": {"hexsha": "3f688f384bbed4e8ea1c1fa10a98678740095c96", "size": 4080, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/List/Membership/Setoid/Distinct.agda", "max_stars_repo_name": "tizmd/agda-distinct-disjoint", "max_stars_repo_head_hexsha": "d4cd2a3442a9b58e6139499d16a2b31268f27f80", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Data/List/Membership/Setoid/Distinct.agda", "max_issues_repo_name": "tizmd/agda-distinct-disjoint", "max_issues_repo_head_hexsha": "d4cd2a3442a9b58e6139499d16a2b31268f27f80", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/List/Membership/Setoid/Distinct.agda", "max_forks_repo_name": "tizmd/agda-distinct-disjoint", "max_forks_repo_head_hexsha": "d4cd2a3442a9b58e6139499d16a2b31268f27f80", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.0, "max_line_length": 136, "alphanum_fraction": 0.5965686275, "num_tokens": 1466, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637469145054, "lm_q2_score": 0.7090191276365463, "lm_q1q2_score": 0.6095180398980874}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Algebra.Structures.Bundles.Field\n\nmodule Algebra.Linear.Morphism\n {k ℓᵏ} (K : Field k ℓᵏ)\n where\n\nopen import Algebra.Linear.Morphism.Definitions K public\nopen import Algebra.Linear.Morphism.Bundles K public\nopen import Algebra.Linear.Morphism.VectorSpace K public\n", "meta": {"hexsha": "d5a326c6b68eb0f98ec84fc7f31d8ed7a1aa68ca", "size": 319, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Algebra/Linear/Morphism.agda", "max_stars_repo_name": "felko/linear-algebra", "max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z", "max_issues_repo_path": "src/Algebra/Linear/Morphism.agda", "max_issues_repo_name": "felko/linear-algebra", "max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Algebra/Linear/Morphism.agda", "max_forks_repo_name": "felko/linear-algebra", "max_forks_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.5833333333, "max_line_length": 56, "alphanum_fraction": 0.7680250784, "num_tokens": 81, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8757870046160257, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.6095112623415054}} {"text": "module Numeral.Natural.Function.Proofs where\n\nimport Lvl\nopen import Data.Tuple\nopen import Functional\nopen import Logic.Propositional\nopen import Logic.Propositional.Theorems\nopen import Numeral.Natural\nopen import Numeral.Natural.Function\nopen import Numeral.Natural.Relation.Order as ≤ using (_≤_ ; _≥_)\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.Oper.Proofs\nopen import Numeral.Natural.Oper.Proofs.Order\nopen import Numeral.Natural.Relation.Order.Proofs\nopen import Relator.Equals\nopen import Relator.Equals.Proofs\nopen import Structure.Function.Domain\nimport Structure.Operator.Names as Names\nopen import Structure.Operator.Properties\nopen import Structure.Relator.Properties\nopen import Syntax.Transitivity\n\nmax-0ₗ : ∀{b} → (max 𝟎 b ≡ b)\nmax-0ₗ {𝟎} = [≡]-intro\nmax-0ₗ {𝐒 b} = [≡]-intro\n{-# REWRITE max-0ₗ #-}\n\nmax-0ᵣ : ∀{a} → (max a 𝟎 ≡ a)\nmax-0ᵣ {𝟎} = [≡]-intro\nmax-0ᵣ {𝐒 a} = [≡]-intro\n{-# REWRITE max-0ᵣ #-}\n\nmin-0ₗ : ∀{b} → (min 𝟎 b ≡ 𝟎)\nmin-0ₗ {𝟎} = [≡]-intro\nmin-0ₗ {𝐒 b} = [≡]-intro\n{-# REWRITE min-0ₗ #-}\n\nmin-0ᵣ : ∀{a} → (min a 𝟎 ≡ 𝟎)\nmin-0ᵣ {𝟎} = [≡]-intro\nmin-0ᵣ {𝐒 a} = [≡]-intro\n{-# REWRITE min-0ᵣ #-}\n\ninstance\n min-idempotence : Idempotence(min)\n min-idempotence = intro proof where\n proof : Names.Idempotence(min)\n proof{𝟎} = [≡]-intro\n proof{𝐒 x} = [≡]-with(𝐒) (proof{x})\n\ninstance\n max-idempotence : Idempotence(max)\n max-idempotence = intro proof where\n proof : Names.Idempotence(max)\n proof{𝟎} = [≡]-intro\n proof{𝐒 x} = [≡]-with(𝐒) (proof{x})\n\nmax-elementary : ∀{a b} → (max(a)(b) ≡ a + (b −₀ a))\nmax-elementary {𝟎} {𝟎} = [≡]-intro\nmax-elementary {𝟎} {𝐒(b)} = [≡]-intro\nmax-elementary {𝐒(a)} {𝟎} = [≡]-intro\nmax-elementary {𝐒(a)} {𝐒(b)} = [≡]-with(𝐒) (max-elementary {a} {b})\n\nmin-elementary : ∀{a b} → (min(a)(b) ≡ b −₀ (b −₀ a))\nmin-elementary {𝟎} {𝟎} = [≡]-intro\nmin-elementary {𝟎} {𝐒(b)} = [≡]-intro\nmin-elementary {𝐒(a)} {𝟎} = [≡]-intro\nmin-elementary {𝐒(a)} {𝐒(b)} = ([≡]-with(𝐒) (min-elementary {a} {b})) 🝖 (symmetry(_≡_) ([↔]-to-[→] [−₀][𝐒]ₗ-equality ([−₀]-lesser {b}{a})))\n\ninstance\n min-commutativity : Commutativity(min)\n Commutativity.proof(min-commutativity) = proof where\n proof : Names.Commutativity(min)\n proof{𝟎} {𝟎} = [≡]-intro\n proof{𝟎} {𝐒(b)} = [≡]-intro\n proof{𝐒(a)}{𝟎} = [≡]-intro\n proof{𝐒(a)}{𝐒(b)} = [≡]-with(𝐒) (proof{a}{b})\n\ninstance\n min-associativity : Associativity(min)\n Associativity.proof(min-associativity) = proof where\n proof : Names.Associativity(min)\n proof{𝟎} {𝟎} {𝟎} = [≡]-intro\n proof{𝟎} {𝟎} {𝐒(c)} = [≡]-intro\n proof{𝟎} {𝐒(b)}{𝟎} = [≡]-intro\n proof{𝐒(a)}{𝟎} {𝟎} = [≡]-intro\n proof{𝟎} {𝐒(b)}{𝐒(c)} = [≡]-intro\n proof{𝐒(a)}{𝟎} {𝐒(c)} = [≡]-intro\n proof{𝐒(a)}{𝐒(b)}{𝟎} = [≡]-intro\n proof{𝐒(a)}{𝐒(b)}{𝐒(c)} = [≡]-with(𝐒) (proof{a}{b}{c})\n -- min(min(𝐒x)(𝐒y))(𝐒z)\n -- = min(𝐒min(x)(y))(𝐒z)\n -- = 𝐒(min(min(x)(y))(z))\n -- = 𝐒(min(x)(min(y)(z)))\n -- = min(𝐒x)(𝐒min(y)(z))\n -- = min(𝐒x)(min(𝐒y)(𝐒z)\n\ninstance\n min-orderₗ : ∀{a b} → (min(a)(b) ≤ a)\n min-orderₗ {𝟎} {𝟎} = [≤]-minimum {𝟎}\n min-orderₗ {𝐒(a)}{𝟎} = [≤]-minimum {𝐒(a)}\n min-orderₗ {𝟎} {𝐒(b)} = [≤]-minimum {𝟎}\n min-orderₗ {𝐒(a)}{𝐒(b)} = [≤]-with-[𝐒] ⦃ min-orderₗ {a}{b} ⦄\n\ninstance\n min-orderᵣ : ∀{a b} → (min(a)(b) ≤ b)\n min-orderᵣ {𝟎} {𝟎} = [≤]-minimum {𝟎}\n min-orderᵣ {𝐒(a)}{𝟎} = [≤]-minimum {𝟎}\n min-orderᵣ {𝟎} {𝐒(b)} = [≤]-minimum {𝐒(b)}\n min-orderᵣ {𝐒(a)}{𝐒(b)} = [≤]-with-[𝐒] ⦃ min-orderᵣ {a}{b} ⦄\n\nmin-arg : ∀{a b} → (min(a)(b) ≡ a) ∨ (min(a)(b) ≡ b)\nmin-arg {𝟎} {𝟎} = [∨]-introₗ([≡]-intro)\nmin-arg {𝟎} {𝐒(b)} = [∨]-introₗ([≡]-intro)\nmin-arg {𝐒(a)}{𝟎} = [∨]-introᵣ([≡]-intro)\nmin-arg {𝐒(a)}{𝐒(b)} = constructive-dilemma ([≡]-with(𝐒)) ([≡]-with(𝐒)) (min-arg {a}{b})\n\nmin-defₗ : ∀{a b} → (a ≤ b) ↔ (min(a)(b) ≡ a)\nmin-defₗ {a}{b} = [↔]-intro (l{a}{b}) (r{a}{b}) where\n l : ∀{a b} → (a ≤ b) ← (min(a)(b) ≡ a)\n l {𝟎} {𝟎} _ = [≤]-minimum {𝟎}\n l {𝟎} {𝐒(b)} _ = [≤]-minimum {𝐒(b)}\n l {𝐒(_)}{𝟎} ()\n l {𝐒(a)}{𝐒(b)} minaba = [≤]-with-[𝐒] ⦃ l{a}{b} (injective(𝐒) (minaba)) ⦄\n\n r : ∀{a b} → (a ≤ b) → (min(a)(b) ≡ a)\n r {𝟎} {𝟎} _ = [≡]-intro\n r {𝟎} {𝐒(b)} _ = [≡]-intro\n r {𝐒(_)}{𝟎} ()\n r {𝐒(a)}{𝐒(b)} (≤.succ ab) = [≡]-with(𝐒) (r{a}{b} (ab))\n\nmin-defᵣ : ∀{a b} → (b ≤ a) ↔ (min(a)(b) ≡ b)\nmin-defᵣ {a}{b} = [≡]-substitutionᵣ (commutativity(min)) {expr ↦ (b ≤ a) ↔ (expr ≡ b)} (min-defₗ{b}{a})\n\n\ninstance\n max-commutativity : Commutativity(max)\n Commutativity.proof(max-commutativity) = proof where\n proof : Names.Commutativity(max)\n proof{𝟎} {𝟎} = [≡]-intro\n proof{𝟎} {𝐒(b)} = [≡]-intro\n proof{𝐒(a)}{𝟎} = [≡]-intro\n proof{𝐒(a)}{𝐒(b)} = [≡]-with(𝐒) (proof{a}{b})\n\ninstance\n max-associativity : Associativity(max)\n Associativity.proof(max-associativity) = proof where\n proof : Names.Associativity(max)\n proof{𝟎} {𝟎} {𝟎} = [≡]-intro\n proof{𝟎} {𝟎} {𝐒(c)} = [≡]-intro\n proof{𝟎} {𝐒(b)}{𝟎} = [≡]-intro\n proof{𝐒(a)}{𝟎} {𝟎} = [≡]-intro\n proof{𝟎} {𝐒(b)}{𝐒(c)} = [≡]-intro\n proof{𝐒(a)}{𝟎} {𝐒(c)} = [≡]-intro\n proof{𝐒(a)}{𝐒(b)}{𝟎} = [≡]-intro\n proof{𝐒(a)}{𝐒(b)}{𝐒(c)} = [≡]-with(𝐒) (proof{a}{b}{c})\n\n-- max-[+]-distributivityₗ : Distributivityₗ(max)\n-- max-[+]-distributivityᵣ : Distributivityᵣ(max)\n\ninstance\n max-orderₗ : ∀{a b} → (max(a)(b) ≥ a)\n max-orderₗ {𝟎} {𝟎} = [≤]-minimum {max(𝟎)(𝟎)}\n max-orderₗ {𝐒(a)}{𝟎} = reflexivity(_≥_)\n max-orderₗ {𝟎} {𝐒(b)} = [≤]-minimum {max(𝟎)(𝐒(b))}\n max-orderₗ {𝐒(a)}{𝐒(b)} = [≤]-with-[𝐒] ⦃ max-orderₗ {a}{b} ⦄\n\ninstance\n max-orderᵣ : ∀{a b} → (max(a)(b) ≥ b)\n max-orderᵣ {𝟎} {𝟎} = [≤]-minimum {max(𝟎)(𝟎)}\n max-orderᵣ {𝐒(a)}{𝟎} = [≤]-minimum {max(𝐒(a))(𝟎)}\n max-orderᵣ {𝟎} {𝐒(b)} = reflexivity(_≥_)\n max-orderᵣ {𝐒(a)}{𝐒(b)} = [≤]-with-[𝐒] ⦃ max-orderᵣ {a}{b} ⦄\n\nmax-arg : ∀{a b} → (max(a)(b) ≡ a)∨(max(a)(b) ≡ b)\nmax-arg {𝟎} {𝟎} = [∨]-introₗ([≡]-intro)\nmax-arg {𝟎} {𝐒(b)} = [∨]-introᵣ([≡]-intro)\nmax-arg {𝐒(a)}{𝟎} = [∨]-introₗ([≡]-intro)\nmax-arg {𝐒(a)}{𝐒(b)} = constructive-dilemma ([≡]-with(𝐒)) ([≡]-with(𝐒)) (max-arg {a}{b})\n\nmax-defₗ : ∀{a b} → (a ≥ b) ↔ (max(a)(b) ≡ a)\nmax-defₗ {a}{b} = [↔]-intro (l{a}{b}) (r{a}{b}) where\n l : ∀{a b} → (a ≥ b) ← (max(a)(b) ≡ a)\n l {𝟎} {𝟎} _ = [≤]-minimum {𝟎}\n l {𝟎} {𝐒(_)} ()\n l {𝐒(a)}{𝟎} _ = [≤]-minimum {𝐒(a)}\n l {𝐒(a)}{𝐒(b)} maxaba = [≤]-with-[𝐒] ⦃ l{a}{b}(injective(𝐒) (maxaba)) ⦄\n\n r : ∀{a b} → (a ≥ b) → (max(a)(b) ≡ a)\n r {𝟎} {𝟎} _ = [≡]-intro\n r {𝟎} {𝐒(_)} ()\n r {𝐒(_)}{𝟎} _ = [≡]-intro\n r {𝐒(a)}{𝐒(b)} (≤.succ ab) = [≡]-with(𝐒) (r{a}{b} (ab))\n\nmax-defᵣ : ∀{a b} → (b ≥ a) ↔ (max(a)(b) ≡ b)\nmax-defᵣ {a}{b} = [≡]-substitutionᵣ (commutativity(max)) {expr ↦ (b ≥ a) ↔ (expr ≡ b)} (max-defₗ{b}{a})\n\nmin-with-max : ∀{a b} → (min(a)(b) ≡ (a + b) −₀ max(a)(b))\nmin-with-max {a}{b} =\n min(a)(b) 🝖-[ min-elementary{a}{b} ]\n b −₀ (b −₀ a) 🝖-[ [−₀][+]ₗ-nullify {a}{b}{b −₀ a} ]-sym\n (a + b) −₀ (a + (b −₀ a)) 🝖-[ [≡]-with((a + b) −₀_) (max-elementary{a}{b}) ]-sym\n (a + b) −₀ max(a)(b) 🝖-end\n\nmax-with-min : ∀{a b} → (max(a)(b) ≡ (a + b) −₀ min(a)(b))\nmax-with-min {a}{b} with [≤][>]-dichotomy {a}{b}\n... | [∨]-introₗ ab =\n max(a)(b) 🝖-[ [↔]-to-[→] max-defᵣ ab ]\n b 🝖-[ [−₀]ₗ[+]ₗ-nullify {a}{b} ]-sym\n (a + b) −₀ a 🝖-[ [≡]-with((a + b) −₀_) ([↔]-to-[→] min-defₗ ab) ]-sym\n (a + b) −₀ min(a)(b) 🝖-end\n... | [∨]-introᵣ 𝐒ba with ba ← [≤]-predecessor 𝐒ba =\n max(a)(b) 🝖-[ [↔]-to-[→] max-defₗ ba ]\n a 🝖-[ [−₀]ₗ[+]ᵣ-nullify {a}{b} ]-sym\n (a + b) −₀ b 🝖-[ [≡]-with((a + b) −₀_) ([↔]-to-[→] min-defᵣ ba) ]-sym\n (a + b) −₀ min(a)(b) 🝖-end\n\n[≤]-conjunction-min : ∀{a b c} → ((a ≤ b) ∧ (a ≤ c)) ↔ (a ≤ min b c)\n[≤]-conjunction-min {a}{b}{c} = [↔]-intro (a≤bc ↦ [∧]-intro (a≤bc 🝖 min-orderₗ) (a≤bc 🝖 min-orderᵣ)) (uncurry r) where\n r : ∀{a b c} → (a ≤ b) → (a ≤ c) → (a ≤ min b c)\n r {.0} {b} {c} ≤.min ≤.min = ≤.min\n r {.(𝐒 a)} {.(𝐒 b)} {.(𝐒 c)} (≤.succ {a} {b} ab) (≤.succ {y = c} ac) = [≤]-with-[𝐒] ⦃ r {a}{b}{c} ab ac ⦄\n\n[≤]-conjunction-max : ∀{a b c} → ((a ≤ c) ∧ (b ≤ c)) ↔ (max a b ≤ c)\n[≤]-conjunction-max {a}{b}{c} = [↔]-intro (ab≤c ↦ [∧]-intro (max-orderₗ 🝖 ab≤c) ((max-orderᵣ 🝖 ab≤c))) (uncurry r) where\n r : ∀{a b c} → (a ≤ c) → (b ≤ c) → (max a b ≤ c)\n r {.0} {b@(𝐒 _)}{c} ≤.min bc = bc\n r {a} {.0} {c} ac ≤.min = ac\n r {𝐒 a} {𝐒 b} {𝐒 c} (≤.succ ac) (≤.succ bc) = [≤]-with-[𝐒] ⦃ r {a}{b}{c} ac bc ⦄\n\n[≤]-disjunction-min : ∀{a b c} → ((a ≤ c) ∨ (b ≤ c)) ↔ (min a b ≤ c)\n[≤]-disjunction-min = [↔]-intro\n (ab≤c ↦ [∨]-elim2\n ((_🝖 ab≤c) ∘ [≡]-to-[≤] ∘ symmetry(_≡_))\n ((_🝖 ab≤c) ∘ [≡]-to-[≤] ∘ symmetry(_≡_))\n min-arg\n )\n ([∨]-elim\n (min-orderₗ 🝖_)\n (min-orderᵣ 🝖_)\n )\n\n[≤]-disjunction-max : ∀{a b c} → ((a ≤ b) ∨ (a ≤ c)) ↔ (a ≤ max b c)\n[≤]-disjunction-max = [↔]-intro\n (a≤bc ↦ [∨]-elim2\n ((_🝖 a≤bc) ∘ [≡]-to-[≤])\n ((_🝖 a≤bc) ∘ [≡]-to-[≤])\n max-arg\n )\n ([∨]-elim\n (_🝖 max-orderₗ)\n (_🝖 max-orderᵣ)\n )\n\nmin-order-max : ∀{a b} → (min(a)(b) ≤ max(a)(b))\nmin-order-max {𝟎} {b} = [≤]-minimum\nmin-order-max {𝐒 a} {𝟎} = [≤]-minimum\nmin-order-max {𝐒 a} {𝐒 b} = [≤]-with-[𝐒] ⦃ min-order-max {a}{b} ⦄\n\nmax-order-[+] : ∀{a b} → (max(a)(b) ≤ a + b)\nmax-order-[+] {a}{b} = [↔]-to-[→] [≤]-conjunction-max ([∧]-intro [≤]-of-[+]ₗ ([≤]-of-[+]ᵣ {a}{b}))\n", "meta": {"hexsha": "6674d008ff7223f85161b50f5914d3e0c8a07cc6", "size": 9545, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Function/Proofs.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Function/Proofs.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Function/Proofs.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.5708812261, "max_line_length": 139, "alphanum_fraction": 0.474908329, "num_tokens": 5074, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519528132451416, "lm_q2_score": 0.7154239957834732, "lm_q1q2_score": 0.6095074858708103}} {"text": "open import Nat\nopen import Prelude\nopen import contexts\nopen import core\n\nmodule canonical-value-forms where\n canonical-value-forms-b : ∀{Δ d} →\n Δ , ∅ ⊢ d :: b →\n d val →\n d == c\n canonical-value-forms-b TAConst VConst = refl\n canonical-value-forms-b (TAVar x₁) ()\n canonical-value-forms-b (TAAp wt wt₁) ()\n canonical-value-forms-b (TAEHole x x₁) ()\n canonical-value-forms-b (TANEHole x wt x₁) ()\n canonical-value-forms-b (TACast wt x) ()\n canonical-value-forms-b (TAFailedCast wt x x₁ x₂) ()\n\n canonical-value-forms-arr : ∀{Δ d τ1 τ2} →\n Δ , ∅ ⊢ d :: (τ1 ==> τ2) →\n d val →\n Σ[ x ∈ Nat ] Σ[ d' ∈ ihexp ]\n ((d == (·λ x [ τ1 ] d')) ×\n (Δ , ■ (x , τ1) ⊢ d' :: τ2))\n canonical-value-forms-arr (TAVar x₁) ()\n canonical-value-forms-arr (TALam _ wt) VLam = _ , _ , refl , wt\n canonical-value-forms-arr (TAAp wt wt₁) ()\n canonical-value-forms-arr (TAEHole x x₁) ()\n canonical-value-forms-arr (TANEHole x wt x₁) ()\n canonical-value-forms-arr (TACast wt x) ()\n canonical-value-forms-arr (TAFailedCast x x₁ x₂ x₃) ()\n\n -- this argues (somewhat informally, because you still have to inspect\n -- the types of the theorems above and manually verify this property)\n -- that we didn't miss any cases above; this intentionally will make this\n -- file fail to typecheck if we added more types, hopefully forcing us to\n -- remember to add canonical forms lemmas as appropriate\n canonical-value-forms-coverage1 : ∀{Δ d τ} →\n Δ , ∅ ⊢ d :: τ →\n d val →\n τ ≠ b →\n ((τ1 : htyp) (τ2 : htyp) → τ ≠ (τ1 ==> τ2)) →\n ⊥\n canonical-value-forms-coverage1 TAConst VConst = λ z _ → z refl\n canonical-value-forms-coverage1 (TAVar x₁) ()\n canonical-value-forms-coverage1 (TALam _ wt) VLam = λ _ z → z _ _ refl\n canonical-value-forms-coverage1 (TAAp wt wt₁) ()\n canonical-value-forms-coverage1 (TAEHole x x₁) ()\n canonical-value-forms-coverage1 (TANEHole x wt x₁) ()\n canonical-value-forms-coverage1 (TACast wt x) ()\n canonical-value-forms-coverage1 (TAFailedCast wt x x₁ x₂) ()\n\n canonical-value-forms-coverage2 : ∀{Δ d} →\n Δ , ∅ ⊢ d :: ⦇-⦈ →\n d val →\n ⊥\n canonical-value-forms-coverage2 (TAVar x₁) ()\n canonical-value-forms-coverage2 (TAAp wt wt₁) ()\n canonical-value-forms-coverage2 (TAEHole x x₁) ()\n canonical-value-forms-coverage2 (TANEHole x wt x₁) ()\n canonical-value-forms-coverage2 (TACast wt x) ()\n canonical-value-forms-coverage2 (TAFailedCast wt x x₁ x₂) ()\n", "meta": {"hexsha": "1df293a9034f351e3b1264e0b97cddd4f43f9820", "size": 2877, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "canonical-value-forms.agda", "max_stars_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_stars_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 16, "max_stars_repo_stars_event_min_datetime": "2018-03-12T14:32:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-19T02:50:23.000Z", "max_issues_repo_path": "canonical-value-forms.agda", "max_issues_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_issues_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 54, "max_issues_repo_issues_event_min_datetime": "2017-06-29T20:53:34.000Z", "max_issues_repo_issues_event_max_datetime": "2018-11-29T16:32:40.000Z", "max_forks_repo_path": "canonical-value-forms.agda", "max_forks_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_forks_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-09-13T18:20:02.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-13T18:20:02.000Z", "avg_line_length": 45.6666666667, "max_line_length": 80, "alphanum_fraction": 0.5505735141, "num_tokens": 845, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9207896845856297, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.6094917622148532}} {"text": "\nmodule Example where\n\nopen import Prelude\nimport Typed\n\ndata Data : Set where\n nat : Data\n bool : Data\n\nDatatype : Data -> List (List Data)\nDatatype nat = ε ◄ ε ◄ (ε ◄ nat)\nDatatype bool = ε ◄ ε ◄ ε\n\ndata Effect : Set where\n\ndata _⊆_ : Effect -> Effect -> Set where\n refl⊆ : forall {M} -> M ⊆ M\n\nMonad : Effect -> Set -> Set\nMonad e A = A\n\nreturn : forall {M A} -> A -> Monad M A\nreturn x = x\n\nmap : forall {M A B} -> (A -> B) -> Monad M A -> Monad M B\nmap f m = f m\n\njoin : forall {M A} -> Monad M (Monad M A) -> Monad M A\njoin m = m\n\nmorph : forall {M N} -> M ⊆ N -> (A : Set) -> Monad M A -> Monad N A\nmorph _ A x = x\n\nopen module TT =\n Typed Data Datatype\n Effect _⊆_\n Monad\n (\\{M A} -> return {M}{A})\n (\\{M A B} -> map {M}{A}{B})\n (\\{M A} -> join {M}{A})\n morph\n\nzero : forall {M Γ} -> InV M Γ (TyCon nat)\nzero = con (tl hd) ⟨⟩\n\nsuc : forall {M Γ} -> InV M Γ (TyCon nat) -> InV M Γ (TyCon nat)\nsuc n = con hd (⟨⟩ ◃ n)\n\ntrue : forall {M Γ} -> InV M Γ (TyCon bool)\ntrue = con hd ⟨⟩\n\nfalse : forall {M Γ} -> InV M Γ (TyCon bool)\nfalse = con (tl hd) ⟨⟩\n", "meta": {"hexsha": "3744b73b7ebd8664ff76da3e6d94b91c1af190ac", "size": 1145, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/sinatra/Example.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/sinatra/Example.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/sinatra/Example.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 20.8181818182, "max_line_length": 69, "alphanum_fraction": 0.5161572052, "num_tokens": 415, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9207896824119663, "lm_q2_score": 0.6619228625116081, "lm_q1q2_score": 0.6094917423532833}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import lib.Basics\nopen import lib.types.Pi\n\nmodule lib.types.Group where\n\nrecord GroupStructure {i} (El : Type i) --(El-level : has-level 0 El)\n : Type i where\n constructor group-structure\n field\n ident : El\n inv : El → El\n comp : El → El → El\n unitl : ∀ a → comp ident a == a\n unitr : ∀ a → comp a ident == a\n assoc : ∀ a b c → comp (comp a b) c == comp a (comp b c)\n invl : ∀ a → (comp (inv a) a) == ident\n invr : ∀ a → (comp a (inv a)) == ident\n\nrecord Group i : Type (lsucc i) where\n constructor group\n field\n El : Type i\n El-level : has-level 0 El\n group-struct : GroupStructure El\n open GroupStructure group-struct public\n\n ⊙El : Σ (Type i) (λ A → A)\n ⊙El = (El , ident)\n\nGroup₀ : Type (lsucc lzero)\nGroup₀ = Group lzero\n\nis-abelian : ∀ {i} → Group i → Type i\nis-abelian G = (a b : Group.El G) → Group.comp G a b == Group.comp G b a\n\nmodule _ where\n open GroupStructure\n\n abstract\n group-structure= : ∀ {i} {A : Type i} (pA : has-level 0 A)\n {id₁ id₂ : A} {inv₁ inv₂ : A → A} {comp₁ comp₂ : A → A → A}\n → ∀ {unitl₁ unitl₂} → ∀ {unitr₁ unitr₂} → ∀ {assoc₁ assoc₂}\n → ∀ {invr₁ invr₂} → ∀ {invl₁ invl₂}\n → (id₁ == id₂) → (inv₁ == inv₂) → (comp₁ == comp₂)\n → Path {A = GroupStructure A}\n (group-structure id₁ inv₁ comp₁ unitl₁ unitr₁ assoc₁ invl₁ invr₁)\n (group-structure id₂ inv₂ comp₂ unitl₂ unitr₂ assoc₂ invl₂ invr₂)\n group-structure= pA {id₁ = id₁} {inv₁ = inv₁} {comp₁ = comp₁} idp idp idp =\n ap5 (group-structure id₁ inv₁ comp₁)\n (prop-has-all-paths (Π-level (λ _ → pA _ _)) _ _)\n (prop-has-all-paths (Π-level (λ _ → pA _ _)) _ _)\n (prop-has-all-paths\n (Π-level (λ _ → Π-level (λ _ → Π-level (λ _ → pA _ _)))) _ _)\n (prop-has-all-paths (Π-level (λ _ → pA _ _)) _ _)\n (prop-has-all-paths (Π-level (λ _ → pA _ _)) _ _)\n where\n ap5 : ∀ {j} {C D E F G H : Type j}\n {c₁ c₂ : C} {d₁ d₂ : D} {e₁ e₂ : E} {f₁ f₂ : F} {g₁ g₂ : G}\n (f : C → D → E → F → G → H)\n → (c₁ == c₂) → (d₁ == d₂) → (e₁ == e₂) → (f₁ == f₂) → (g₁ == g₂)\n → f c₁ d₁ e₁ f₁ g₁ == f c₂ d₂ e₂ f₂ g₂\n ap5 f idp idp idp idp idp = idp\n\n ↓-group-structure= : ∀ {i} {A B : Type i}\n (A-level : has-level 0 A)\n {GS : GroupStructure A} {HS : GroupStructure B} (p : A == B)\n → (ident GS == ident HS [ (λ C → C) ↓ p ])\n → (inv GS == inv HS [ (λ C → C → C) ↓ p ])\n → (comp GS == comp HS [ (λ C → C → C → C) ↓ p ])\n → GS == HS [ GroupStructure ↓ p ]\n ↓-group-structure= A-level idp = group-structure= A-level\n\nmodule _ {i} (G : Group i) where\n private\n open Group G\n infix 80 _⊙_\n _⊙_ = comp\n\n group-inv-unique-l : (g h : El) → (g ⊙ h == ident) → inv h == g\n group-inv-unique-l g h p =\n inv h =⟨ ! (unitl (inv h)) ⟩\n ident ⊙ inv h =⟨ ! p |in-ctx (λ w → w ⊙ inv h) ⟩\n (g ⊙ h) ⊙ inv h =⟨ assoc g h (inv h) ⟩\n g ⊙ (h ⊙ inv h) =⟨ invr h |in-ctx (λ w → g ⊙ w) ⟩\n g ⊙ ident =⟨ unitr g ⟩\n g ∎\n\n group-inv-unique-r : (g h : El) → (g ⊙ h == ident) → inv g == h\n group-inv-unique-r g h p =\n inv g =⟨ ! (unitr (inv g)) ⟩\n inv g ⊙ ident =⟨ ! p |in-ctx (λ w → inv g ⊙ w) ⟩\n inv g ⊙ (g ⊙ h) =⟨ ! (assoc (inv g) g h) ⟩\n (inv g ⊙ g) ⊙ h =⟨ invl g |in-ctx (λ w → w ⊙ h) ⟩\n ident ⊙ h =⟨ unitl h ⟩\n h ∎\n\n group-inv-ident : inv ident == ident\n group-inv-ident =\n group-inv-unique-l ident ident (unitl ident)\n\n group-inv-comp : (g₁ g₂ : El) → inv (g₁ ⊙ g₂) == inv g₂ ⊙ inv g₁\n group-inv-comp g₁ g₂ =\n group-inv-unique-r (g₁ ⊙ g₂) (inv g₂ ⊙ inv g₁) $\n (g₁ ⊙ g₂) ⊙ (inv g₂ ⊙ inv g₁)\n =⟨ assoc g₁ g₂ (inv g₂ ⊙ inv g₁) ⟩\n g₁ ⊙ (g₂ ⊙ (inv g₂ ⊙ inv g₁))\n =⟨ ! (assoc g₂ (inv g₂) (inv g₁)) |in-ctx (λ w → g₁ ⊙ w) ⟩\n g₁ ⊙ ((g₂ ⊙ inv g₂) ⊙ inv g₁)\n =⟨ invr g₂ |in-ctx (λ w → g₁ ⊙ (w ⊙ inv g₁)) ⟩\n g₁ ⊙ (ident ⊙ inv g₁)\n =⟨ unitl (inv g₁) |in-ctx (λ w → g₁ ⊙ w) ⟩\n g₁ ⊙ inv g₁\n =⟨ invr g₁ ⟩\n ident ∎\n\n group-inv-inv : (g : El) → inv (inv g) == g\n group-inv-inv g = group-inv-unique-r (inv g) g (invl g)\n\n group-cancel-l : (g : El) {h k : El} → g ⊙ h == g ⊙ k → h == k\n group-cancel-l g {h} {k} p =\n h =⟨ ! (unitl h) ⟩\n ident ⊙ h =⟨ ap (λ w → w ⊙ h) (! (invl g)) ⟩\n (inv g ⊙ g) ⊙ h =⟨ assoc (inv g) g h ⟩\n inv g ⊙ (g ⊙ h) =⟨ ap (λ w → inv g ⊙ w) p ⟩\n inv g ⊙ (g ⊙ k) =⟨ ! (assoc (inv g) g k) ⟩\n (inv g ⊙ g) ⊙ k =⟨ ap (λ w → w ⊙ k) (invl g) ⟩\n ident ⊙ k =⟨ unitl k ⟩\n k ∎\n\n group-cancel-r : (g : El) {h k : El} → h ⊙ g == k ⊙ g → h == k\n group-cancel-r g {h} {k} p =\n h =⟨ ! (unitr h) ⟩\n h ⊙ ident =⟨ ap (λ w → h ⊙ w) (! (invr g)) ⟩\n h ⊙ (g ⊙ inv g) =⟨ ! (assoc h g (inv g)) ⟩\n (h ⊙ g) ⊙ inv g =⟨ ap (λ w → w ⊙ inv g) p ⟩\n (k ⊙ g) ⊙ inv g =⟨ assoc k g (inv g) ⟩\n k ⊙ (g ⊙ inv g) =⟨ ap (λ w → k ⊙ w) (invr g) ⟩\n k ⊙ ident =⟨ unitr k ⟩\n k ∎\n", "meta": {"hexsha": "41ea9411d3aa8703445d85791a28a1a2da5e8f5d", "size": 5101, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/types/Group.agda", "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "core/lib/types/Group.agda", "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "core/lib/types/Group.agda", "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.9225352113, "max_line_length": 79, "alphanum_fraction": 0.4665751813, "num_tokens": 2173, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789086703225, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.6094903300872009}} {"text": "{-# OPTIONS --cubical #-}\n\nmodule Type.Cubical where\n\nimport Lvl\nopen import Type\n\nopen import Agda.Primitive public\n using (SSet)\n\nopen import Agda.Primitive.Cubical public\n using ()\n renaming (I to Interval) -- _ : SSet(Lvl.𝟎). Inhabitants can be seen as points on a closed unit interval.\n\nmodule Interval where\n open Agda.Primitive.Cubical public\n using (\n Partial ; -- _ : ∀{ℓ} → Interval → Type{ℓ} → SSet(ℓ)\n PartialP -- _ : ∀{ℓ} → (i : Interval) → (.(Is-𝟏 i) → Type{ℓ}) → SSet(ℓ)\n )\n renaming (\n i0 to 𝟎 ; -- _ : Interval. 0 (the initial point) in the interval.\n i1 to 𝟏 ; -- _ : Interval. 1 (the terminal point) in the interval.\n primIMin to min ; -- _ : Interval → Interval → Interval. Chooses the point nearest 𝟎. Also called: _∧_ (from lattice structure).\n primIMax to max ; -- _ : Interval → Interval → Interval. Chooses the point nearest 𝟏. Also called: _∨_ (from lattice structure).\n primINeg to flip ; -- _ : Interval → Interval. Flips a point in the interval around the point of symmetry (the middle). Essentially (p ↦ 𝟏 − p).\n IsOne to Is-𝟏 ; -- _ : Interval → SSet(Lvl.𝟎). The predicate stating that a point is 𝟏.\n itIsOne to 𝟏-is-𝟏 ; -- _ : Is-𝟏(𝟏). Proof of 𝟏 being 𝟏.\n primComp to comp ; -- _ : ∀{ℓ : Interval → Lvl.Level} → (P : (i : Interval) → Type{ℓ(i)}) → ∀{i : Interval} → ((j : Interval) → .(Is-𝟏 i) → P(j)) → (P(𝟎) → P(𝟏))\n primHComp to hComp ; -- _ : ∀{ℓ}{A : Type{ℓ}}{i : Interval} → (Interval → .(Is-𝟏 i) → A) → (A → A)\n primTransp to transp -- _ : ∀{ℓ : Interval → Lvl.Level}(A : (i : Interval) → Type{ℓ(i)}) → Interval → A(𝟎)→ A(𝟏).\n )\n\n -- The distance to the nearest boundary.\n nearBound : Interval → Interval\n nearBound x = min x (flip x)\n\n -- The distance to the furthest boundary.\n farBound : Interval → Interval\n farBound x = max x (flip x)\n\n -- Proof of maximum of 𝟏 being 𝟏.\n maxₗ-is-𝟏 : ∀{x y} → Is-𝟏(x) → Is-𝟏(max x y)\n maxₗ-is-𝟏 {x}{y} = Agda.Primitive.Cubical.IsOne1 x y\n\n -- Proof of maximum of 𝟏 being 𝟏.\n maxᵣ-is-𝟏 : ∀{x y} → Is-𝟏(y) → Is-𝟏(max x y)\n maxᵣ-is-𝟏 {x}{y} = Agda.Primitive.Cubical.IsOne2 x y\n\n -- The predicate stating that a point is 𝟎.\n Is-𝟎 : Interval → SSet(Lvl.𝟎)\n Is-𝟎 i = Is-𝟏(flip i)\n\n -- Proof of 𝟎 being 𝟎.\n 𝟎-is-𝟎 : Is-𝟎(𝟎)\n 𝟎-is-𝟎 = 𝟏-is-𝟏\n\n -- Proof of minimum of 𝟎 being 𝟎.\n minₗ-is-𝟎 : ∀{x y} → Is-𝟎(x) → Is-𝟎(min x y)\n minₗ-is-𝟎 {x}{y} = maxₗ-is-𝟏 {flip x} {flip y}\n\n -- Proof of minimum of 𝟎 being 𝟎.\n minᵣ-is-𝟎 : ∀{x y} → Is-𝟎(y) → Is-𝟎(min x y)\n minᵣ-is-𝟎 {x}{y} = maxᵣ-is-𝟏 {flip x} {flip y}\n", "meta": {"hexsha": "73343828fd85fd51d3d988887800e0fb074fa060", "size": 2577, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Type/Cubical.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Type/Cubical.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Type/Cubical.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.6461538462, "max_line_length": 167, "alphanum_fraction": 0.5956538611, "num_tokens": 1079, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916099737806, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.6093688768227093}} {"text": "{-# OPTIONS --postfix-projections #-}\n\nmodule StateSized.StackStateDependent where\n\nopen import Data.Product\nopen import Function\nopen import Data.String.Base as Str\nopen import Data.Nat.Base as N\nopen import Data.Vec as Vec using (Vec; []; _∷_; head; tail)\n\nopen import Relation.Binary using (Rel)\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Binary.Product.Pointwise\n\nopen import NativeIO\n\nopen import SizedIO.Base\nopen import SizedIO.Console hiding (main)\n\nopen import StateSizedIO.GUI.BaseStateDependent\nopen import StateSizedIO.Object\nopen import StateSizedIO.IOObject\n\n\nopen import Size\n\nStackStateˢ = ℕ\n\ndata StackMethodˢ (A : Set) : StackStateˢ → Set where\n push : {n : StackStateˢ} → A → StackMethodˢ A n\n pop : {n : StackStateˢ} → StackMethodˢ A (suc n)\n\nStackResultˢ : (A : Set) → (s : StackStateˢ) → StackMethodˢ A s → Set\nStackResultˢ A .n (push { n } x₁) = Unit\nStackResultˢ A (suc .n) (pop {n} ) = A\n\nnˢ : (A : Set) → (s : StackStateˢ) → (m : StackMethodˢ A s) → (r : StackResultˢ A s m) → StackStateˢ\nnˢ A .n (push { n } x) r = suc n\nnˢ A (suc .n) (pop { n }) r = n\n\n\nStackInterfaceˢ : (A : Set) → Interfaceˢ\nStackInterfaceˢ A .Stateˢ = StackStateˢ\nStackInterfaceˢ A .Methodˢ = StackMethodˢ A\nStackInterfaceˢ A .Resultˢ = StackResultˢ A\nStackInterfaceˢ A .nextˢ = nˢ A\n\nstackP : ∀{n : ℕ} → (i : Size) → (v : Vec String n) → IOObjectˢ consoleI (StackInterfaceˢ String) i n\nmethod (stackP { n } i es) {j} (push e) = return (_ , stackP j (e ∷ es))\nmethod (stackP {suc n} i (x ∷ xs)){j} pop = return (x , stackP j xs)\n\n\n\n-- UNSIZED Version, without IO\n\nstackP' : ∀{n : ℕ} → (v : Vec String n) → Objectˢ (StackInterfaceˢ String) n\nstackP' es .objectMethod (push e) = (_ , stackP' (e ∷ es))\nstackP' (x ∷ xs) .objectMethod pop = x , stackP' xs\n\n\n\nstackO : ∀{E : Set} {n : ℕ} (v : Vec E n) → Objectˢ (StackInterfaceˢ E) n\nobjectMethod (stackO es) (push e) = _ , stackO (e ∷ es)\nobjectMethod (stackO (e ∷ es)) pop = e , stackO es\n\nstackF : ∀{E : Set} (n : ℕ) (f : ℕ → E) → Objectˢ (StackInterfaceˢ E) n\nobjectMethod (stackF n f) (push x) = _ , stackF (suc n)\n \\{ zero → x\n ; (suc m) → f m\n }\nobjectMethod (stackF (suc n) f) pop = (f zero) , stackF n (f ∘ suc)\n\ntabulate : ∀{E : Set} (n : ℕ) (f : ℕ → E) → Vec E n\ntabulate zero f = []\ntabulate (suc n) f = f zero ∷ tabulate n λ m → f (suc m)\n\nmodule _ {E : Set} where\n private\n I = StackInterfaceˢ E\n S = Stateˢ I\n O = Objectˢ I\n open Bisim I\n\n _≡×≅'_ : ∀{s} → (o o' : E × O s) → Set\n _≡×≅'_ = _≡_ ×-Rel _≅_\n\n Eq×Bisim : ∀ (s : S) → (o o' : E × O s) → Set\n Eq×Bisim s = _≡_ ×-Rel _≅_\n\n pop-after-push : ∀{n}{v : Vec E n} (e : E) (let stack = stackO v) →\n (objectMethod stack (push e) ▹ λ { (_ , stack₁) →\n objectMethod stack₁ pop ▹ λ { (e₁ , stack₂) →\n ( e₁ , stack₂ ) }})\n ≡×≅' (e , stack)\n pop-after-push e = refl , refl≅ _\n\n\n push-after-pop : ∀{n}{v : Vec E n} (e : E) (let stack = stackO (e ∷ v)) →\n (objectMethod stack pop ▹ λ { (e₁ , stack₁) →\n objectMethod stack₁ (push e₁) ▹ λ { (_ , stack₂) →\n stack₂ }})\n ≅ stack\n push-after-pop e = refl≅ _\n\n\n -- The implementations of stacks with either vectors or functions are bisimilar.\n\n impl-bisim : ∀{n : ℕ} {f : ℕ → E} (v : Vec E n) (p : tabulate n f ≡ v)\n → stackF n f ≅ stackO v\n\n bisimMethod (impl-bisim v p) (push e) =\n bisim (impl-bisim (e ∷ v) (cong (_∷_ e) p))\n\n bisimMethod (impl-bisim (x ∷ v) p) pop rewrite cong head p =\n bisim (impl-bisim v (cong tail p))\n\nprogram : IOConsole ∞ Unit\nprogram = \n exec getLine λ str₀ →\n method s₀ (push str₀) >>= λ{ (_ , s₁) → -- empty\n exec getLine λ str₁ →\n method s₁ (push str₁) >>= λ{ (_ , s₂) → -- full\n method s₂ pop >>= λ{ (str₂ , s₃) →\n exec (putStrLn (\"first pop: \" Str.++ str₂) ) λ _ →\n exec getLine λ str₃ →\n method s₃ (push str₃) >>= λ{ (_ , s₄) →\n method s₄ pop >>= λ{ (str₄ , s₅) →\n exec (putStrLn (\"second pop: \" Str.++ str₄) ) λ _ →\n method s₅ pop >>= λ{ (str₅ , s₅) →\n exec (putStrLn (\"third pop: \" Str.++ str₅) ) λ _ →\n return unit\n }}}}}}\n where\n s₀ = stackP ∞ []\n\nmain : NativeIO Unit\nmain = translateIOConsole program\n\n", "meta": {"hexsha": "107369c48245284a2df888f218e9a191640e8ed7", "size": 4270, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/StateSized/StackStateDependent.agda", "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 23, "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_issues_repo_path": "examples/StateSized/StackStateDependent.agda", "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/StateSized/StackStateDependent.agda", "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "avg_line_length": 30.7194244604, "max_line_length": 101, "alphanum_fraction": 0.5866510539, "num_tokens": 1633, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.863391617003942, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.6093688710982466}} {"text": "module Cats.Category.Discrete {li} (I : Set li) where\n\nopen import Data.Unit using (⊤)\nopen import Level\n\nopen import Cats.Category.Base\nopen import Cats.Functor using (Functor)\n\n\nObj : Set li\nObj = I\n\n\ndata _⇒_ : Obj → Obj → Set where\n id : ∀ {A} → A ⇒ A\n\n\n_∘_ : ∀ {A B C} → B ⇒ C → A ⇒ B → A ⇒ C\nid ∘ id = id\n\n\nDiscrete : Category li zero zero\nDiscrete = record\n { Obj = Obj\n ; _⇒_ = _⇒_\n ; _≈_ = λ _ _ → ⊤\n ; id = id\n ; _∘_ = _∘_\n ; equiv = _\n ; ∘-resp = _\n ; id-r = _\n ; id-l = _\n ; assoc = _\n }\n\n\nfunctor : ∀ {lo la l≈} {C : Category lo la l≈}\n → (I → Category.Obj C)\n → Functor Discrete C\nfunctor {C = C} f = record\n { fobj = f\n ; fmap = λ { id → C.id }\n ; fmap-resp = λ { {_} {_} {id} {id} _ → C.≈.refl }\n ; fmap-id = C.≈.refl\n ; fmap-∘ = λ { {f = id} {id} → C.id-l }\n }\n where\n module C = Category C\n", "meta": {"hexsha": "b3b0061aac42c5e6feac8e192eaf82d865213acd", "size": 866, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Category/Discrete.agda", "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cats/Category/Discrete.agda", "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cats/Category/Discrete.agda", "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.6734693878, "max_line_length": 54, "alphanum_fraction": 0.4976905312, "num_tokens": 349, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9304582574225517, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.6093522146469021}} {"text": "{-# OPTIONS --warning=error --safe --without-K #-}\n\nopen import LogicalFormulae\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import Functions.Definition\nopen import Setoids.Setoids\nopen import Setoids.Subset\nopen import Graphs.Definition\n\nmodule Graphs.Bipartite where\n\nBipartite : {a b : _} {c : _} {V' : Set a} {V : Setoid {a} {b} V'} (G : Graph c V) → Set _\nBipartite {V' = V'} {V = V} G = Sg (V' → Set) (λ partition → ((x y : V') → (Setoid._∼_ V x y) → partition x → partition y) & ((x : V') → (partition x) || ((partition x) → False)) & ((x y : V') → (Graph._<->_ G x y) → (partition x) → ((partition y) → False)))\n", "meta": {"hexsha": "48214f7e5ffaee47f442620769c3349eb156a3ef", "size": 639, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Graphs/Bipartite.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Graphs/Bipartite.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Graphs/Bipartite.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 45.6428571429, "max_line_length": 258, "alphanum_fraction": 0.6228482003, "num_tokens": 224, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9304582497090322, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.6093522095953589}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import lib.Basics\nopen import lib.NType2\nopen import lib.types.Group\nopen import lib.types.Word\nopen import lib.groups.GeneratedAbelianGroup\nopen import lib.groups.GeneratedGroup\nopen import lib.groups.GroupProduct\nopen import lib.groups.Homomorphism\nopen import lib.groups.Isomorphism\n\nmodule lib.groups.FreeAbelianGroup {i} where\n\nmodule FreeAbelianGroup (A : Type i) where\n\n private\n module Gen = GeneratedAbelianGroup A empty-rel\n open Gen hiding (GenAbGroup; module HomomorphismEquiv) public\n\n CommutativityRel : Rel (Word A) i\n CommutativityRel = AbGroupRel\n\n FormalSumRel : Rel (Word A) i\n FormalSumRel = QuotWordRel\n\n FormalSum : Type i\n FormalSum = QuotWord\n\n FreeGroup : Group i\n FreeGroup = Gen.GenGroup\n\n FreeAbGroup : AbGroup i\n FreeAbGroup = Gen.GenAbGroup\n\n module FreeAbGroup = AbGroup FreeAbGroup\n\n {- Universal Property -}\n module Freeness {j} (G : AbGroup j) where\n\n private\n module G = AbGroup G\n\n extend-equiv : (A → G.El) ≃ (FreeAbGroup.grp →ᴳ G.grp)\n extend-equiv =\n Gen.HomomorphismEquiv.extend-equiv G ∘e every-function-respects-empty-rel-equiv A G.grp\n\n extend : (A → G.El) → (FreeAbGroup.grp →ᴳ G.grp)\n extend = –> extend-equiv\n\n extend-is-equiv : is-equiv extend\n extend-is-equiv = snd extend-equiv\n\n extend-hom : Πᴳ A (λ _ → G.grp) →ᴳ hom-group FreeAbGroup.grp G\n extend-hom = record {M} where\n module M where\n f : (A → G.El) → (FreeAbGroup.grp →ᴳ G.grp)\n f = extend\n abstract\n pres-comp : preserves-comp (Group.comp (Πᴳ A (λ _ → G.grp))) (Group.comp (hom-group FreeAbGroup.grp G)) f\n pres-comp = λ f₁ f₂ → group-hom= $ λ= $\n QuotWord-elim\n (Word-extendᴳ-comp G f₁ f₂)\n (λ _ → prop-has-all-paths-↓)\n\n extend-iso : Πᴳ A (λ _ → G.grp) ≃ᴳ hom-group FreeAbGroup.grp G\n extend-iso = extend-hom , snd extend-equiv\n", "meta": {"hexsha": "882f7b00bee85ff5c5995ead5702c8b3fb799bd5", "size": 1925, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/groups/FreeAbelianGroup.agda", "max_stars_repo_name": "AntoineAllioux/HoTT-Agda", "max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 294, "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_issues_repo_path": "core/lib/groups/FreeAbelianGroup.agda", "max_issues_repo_name": "AntoineAllioux/HoTT-Agda", "max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 31, "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_forks_repo_path": "core/lib/groups/FreeAbelianGroup.agda", "max_forks_repo_name": "AntoineAllioux/HoTT-Agda", "max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 50, "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "avg_line_length": 28.3088235294, "max_line_length": 115, "alphanum_fraction": 0.6722077922, "num_tokens": 583, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677583778258, "lm_q2_score": 0.7185944046238981, "lm_q1q2_score": 0.6093448864717752}} {"text": "{-\nThis second-order signature was created from the following second-order syntax description:\n\nsyntax Unit | U\n\ntype\n 𝟙 : 0-ary\n\nterm\n unit : 𝟙\n\ntheory\n (𝟙η) u : 𝟙 |> u = unit\n-}\n\nmodule Unit.Signature where\n\nopen import SOAS.Context\n\n-- Type declaration\ndata UT : Set where\n 𝟙 : UT\n\n\n\nopen import SOAS.Syntax.Signature UT public\nopen import SOAS.Syntax.Build UT public\n\n-- Operator symbols\ndata Uₒ : Set where\n unitₒ : Uₒ\n\n-- Term signature\nU:Sig : Signature Uₒ\nU:Sig = sig λ\n { unitₒ → ⟼₀ 𝟙\n }\n\nopen Signature U:Sig public\n", "meta": {"hexsha": "9a24aee6ee405e2e043fc6c03b32bf0ad6fb3975", "size": 535, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "out/Unit/Signature.agda", "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_issues_repo_path": "out/Unit/Signature.agda", "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_forks_repo_path": "out/Unit/Signature.agda", "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "avg_line_length": 13.375, "max_line_length": 91, "alphanum_fraction": 0.6934579439, "num_tokens": 181, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8479677699040321, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.6093448794235559}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Streams\n------------------------------------------------------------------------\n\nmodule Data.Stream where\n\nopen import Coinduction\nopen import Data.Colist using (Colist; []; _∷_)\nopen import Data.Vec using (Vec; []; _∷_)\nopen import Data.Nat using (ℕ; zero; suc)\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as P using (_≡_)\n\n------------------------------------------------------------------------\n-- The type\n\ninfixr 5 _∷_\n\ndata Stream (A : Set) : Set where\n _∷_ : (x : A) (xs : ∞ (Stream A)) → Stream A\n\n{-# IMPORT Data.FFI #-}\n{-# COMPILED_DATA Stream Data.FFI.AgdaStream Data.FFI.Cons #-}\n\n------------------------------------------------------------------------\n-- Some operations\n\nhead : ∀ {A} → Stream A → A\nhead (x ∷ xs) = x\n\ntail : ∀ {A} → Stream A → Stream A\ntail (x ∷ xs) = ♭ xs\n\nmap : ∀ {A B} → (A → B) → Stream A → Stream B\nmap f (x ∷ xs) = f x ∷ ♯ map f (♭ xs)\n\nzipWith : ∀ {A B C} →\n (A → B → C) → Stream A → Stream B → Stream C\nzipWith _∙_ (x ∷ xs) (y ∷ ys) = (x ∙ y) ∷ ♯ zipWith _∙_ (♭ xs) (♭ ys)\n\ntake : ∀ {A} n → Stream A → Vec A n\ntake zero xs = []\ntake (suc n) (x ∷ xs) = x ∷ take n (♭ xs)\n\ndrop : ∀ {A} → ℕ → Stream A → Stream A\ndrop zero xs = xs\ndrop (suc n) (x ∷ xs) = drop n (♭ xs)\n\nrepeat : ∀ {A} → A → Stream A\nrepeat x = x ∷ ♯ repeat x\n\niterate : ∀ {A} → (A → A) → A → Stream A\niterate f x = x ∷ ♯ iterate f (f x)\n\n-- Interleaves the two streams.\n\ninfixr 5 _⋎_\n\n_⋎_ : ∀ {A} → Stream A → Stream A → Stream A\n(x ∷ xs) ⋎ ys = x ∷ ♯ (ys ⋎ ♭ xs)\n\nmutual\n\n -- Takes every other element from the stream, starting with the\n -- first one.\n\n evens : ∀ {A} → Stream A → Stream A\n evens (x ∷ xs) = x ∷ ♯ odds (♭ xs)\n\n -- Takes every other element from the stream, starting with the\n -- second one.\n\n odds : ∀ {A} → Stream A → Stream A\n odds (x ∷ xs) = evens (♭ xs)\n\ntoColist : ∀ {A} → Stream A → Colist A\ntoColist (x ∷ xs) = x ∷ ♯ toColist (♭ xs)\n\nlookup : ∀ {A} → ℕ → Stream A → A\nlookup zero (x ∷ xs) = x\nlookup (suc n) (x ∷ xs) = lookup n (♭ xs)\n\ninfixr 5 _++_\n\n_++_ : ∀ {A} → Colist A → Stream A → Stream A\n[] ++ ys = ys\n(x ∷ xs) ++ ys = x ∷ ♯ (♭ xs ++ ys)\n\n------------------------------------------------------------------------\n-- Equality and other relations\n\n-- xs ≈ ys means that xs and ys are equal.\n\ninfix 4 _≈_\n\ndata _≈_ {A} : Stream A → Stream A → Set where\n _∷_ : ∀ {x y xs ys}\n (x≡ : x ≡ y) (xs≈ : ∞ (♭ xs ≈ ♭ ys)) → x ∷ xs ≈ y ∷ ys\n\n-- x ∈ xs means that x is a member of xs.\n\ninfix 4 _∈_\n\ndata _∈_ {A} : A → Stream A → Set where\n here : ∀ {x xs} → x ∈ x ∷ xs\n there : ∀ {x y xs} (x∈xs : x ∈ ♭ xs) → x ∈ y ∷ xs\n\n-- xs ⊑ ys means that xs is a prefix of ys.\n\ninfix 4 _⊑_\n\ndata _⊑_ {A} : Colist A → Stream A → Set where\n [] : ∀ {ys} → [] ⊑ ys\n _∷_ : ∀ x {xs ys} (p : ∞ (♭ xs ⊑ ♭ ys)) → x ∷ xs ⊑ x ∷ ys\n\n------------------------------------------------------------------------\n-- Some proofs\n\nsetoid : Set → Setoid _ _\nsetoid A = record\n { Carrier = Stream A\n ; _≈_ = _≈_ {A}\n ; isEquivalence = record\n { refl = refl\n ; sym = sym\n ; trans = trans\n }\n }\n where\n refl : Reflexive _≈_\n refl {_ ∷ _} = P.refl ∷ ♯ refl\n\n sym : Symmetric _≈_\n sym (x≡ ∷ xs≈) = P.sym x≡ ∷ ♯ sym (♭ xs≈)\n\n trans : Transitive _≈_\n trans (x≡ ∷ xs≈) (y≡ ∷ ys≈) = P.trans x≡ y≡ ∷ ♯ trans (♭ xs≈) (♭ ys≈)\n\nhead-cong : ∀ {A} {xs ys : Stream A} → xs ≈ ys → head xs ≡ head ys\nhead-cong (x≡ ∷ _) = x≡\n\ntail-cong : ∀ {A} {xs ys : Stream A} → xs ≈ ys → tail xs ≈ tail ys\ntail-cong (_ ∷ xs≈) = ♭ xs≈\n\nmap-cong : ∀ {A B} (f : A → B) {xs ys} →\n xs ≈ ys → map f xs ≈ map f ys\nmap-cong f (x≡ ∷ xs≈) = P.cong f x≡ ∷ ♯ map-cong f (♭ xs≈)\n\nzipWith-cong : ∀ {A B C} (_∙_ : A → B → C) {xs xs′ ys ys′} →\n xs ≈ xs′ → ys ≈ ys′ →\n zipWith _∙_ xs ys ≈ zipWith _∙_ xs′ ys′\nzipWith-cong _∙_ (x≡ ∷ xs≈) (y≡ ∷ ys≈) =\n P.cong₂ _∙_ x≡ y≡ ∷ ♯ zipWith-cong _∙_ (♭ xs≈) (♭ ys≈)\n\ninfixr 5 _⋎-cong_\n\n_⋎-cong_ : ∀ {A} {xs xs′ ys ys′ : Stream A} →\n xs ≈ xs′ → ys ≈ ys′ → xs ⋎ ys ≈ xs′ ⋎ ys′\n(x ∷ xs≈) ⋎-cong ys≈ = x ∷ ♯ (ys≈ ⋎-cong ♭ xs≈)\n", "meta": {"hexsha": "bc8dc41dde4b2028d090cc713357827ab8c7df40", "size": 4253, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Stream.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Stream.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Stream.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.2530864198, "max_line_length": 72, "alphanum_fraction": 0.4512109099, "num_tokens": 1678, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933403143929, "lm_q2_score": 0.7431680029241321, "lm_q1q2_score": 0.6093184963322431}} {"text": "{-\n Definition of function fixpoint and Kraus' lemma\n-}\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Functions.Fixpoint where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.GroupoidLaws\nopen import Cubical.Foundations.Path\n\nprivate\n variable\n ℓ : Level\n A : Type ℓ\n\nFixpoint : (A → A) → Type _\nFixpoint {A = A} f = Σ A (λ x → f x ≡ x)\n\nfixpoint : {f : A → A} → Fixpoint f → A\nfixpoint = fst\n\nfixpointPath : {f : A → A} → (p : Fixpoint f) → f (fixpoint p) ≡ fixpoint p\nfixpointPath = snd\n\n-- Kraus' lemma\n-- a version not using cubical features can be found at\n-- https://www.cs.bham.ac.uk/~mhe/GeneralizedHedberg/html/GeneralizedHedberg.html#21576\n2-Constant→isPropFixpoint : (f : A → A) → 2-Constant f → isProp (Fixpoint f)\n2-Constant→isPropFixpoint f fconst (x , p) (y , q) i = s i , t i where\n noose : ∀ x y → f x ≡ f y\n noose x y = sym (fconst x x) ∙ fconst x y\n -- the main idea is that for any path p, cong f p does not depend on p\n -- but only on its endpoints and the structure of 2-Constant f\n KrausInsight : ∀ {x y} → (p : x ≡ y) → noose x y ≡ cong f p\n KrausInsight {x} = J (λ y p → noose x y ≡ cong f p) (lCancel (fconst x x))\n -- Need to solve for a path s : x ≡ y, such that:\n -- transport (λ i → cong f s i ≡ s i) p ≡ q\n s : x ≡ y\n s = sym p ∙∙ noose x y ∙∙ q\n t' : PathP (λ i → noose x y i ≡ s i) p q\n t' i j = doubleCompPath-filler (sym p) (noose x y) q j i\n t : PathP (λ i → cong f s i ≡ s i) p q\n t = subst (λ kraus → PathP (λ i → kraus i ≡ s i) p q) (KrausInsight s) t'\n", "meta": {"hexsha": "e6c3eac08db1d0c4a94964b22e04510e770e3b78", "size": 1600, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Functions/Fixpoint.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Functions/Fixpoint.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/Functions/Fixpoint.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "avg_line_length": 35.5555555556, "max_line_length": 87, "alphanum_fraction": 0.635, "num_tokens": 609, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933315126792, "lm_q2_score": 0.7431680086124812, "lm_q1q2_score": 0.6093184944549307}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Nullary relations (some core definitions)\n------------------------------------------------------------------------\n\n-- The definitions in this file are reexported by Relation.Nullary.\n\nmodule Relation.Nullary.Core where\n\nopen import Data.Empty\nopen import Level\n\n-- Negation.\n\ninfix 3 ¬_\n\n¬_ : ∀ {ℓ} → Set ℓ → Set ℓ\n¬ P = P → ⊥\n\n-- Decidable relations.\n\ndata Dec {p} (P : Set p) : Set p where\n yes : ( p : P) → Dec P\n no : (¬p : ¬ P) → Dec P\n", "meta": {"hexsha": "d8b07577332150a3feaa3e519906ed1e04614879", "size": 555, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Relation/Nullary/Core.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Relation/Nullary/Core.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Relation/Nullary/Core.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.3461538462, "max_line_length": 72, "alphanum_fraction": 0.4666666667, "num_tokens": 136, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8198933271118221, "lm_q2_score": 0.7431680086124812, "lm_q1q2_score": 0.6093184911843544}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Adjoint where\n\n-- Adjoints\n\nopen import Level\n\nopen import Data.Product using (_,_; _×_)\nopen import Function using (_$_) renaming (_∘_ to _∙_)\nopen import Function.Equality using (Π; _⟶_)\nimport Function.Inverse as FI\nopen import Relation.Binary using (Rel; IsEquivalence; Setoid)\n\n-- be explicit in imports to 'see' where the information comes from\nopen import Categories.Category using (Category)\nopen import Categories.Category.Product using (Product; _⁂_)\nopen import Categories.Category.Instance.Setoids\nopen import Categories.Morphism\nopen import Categories.Functor using (Functor; _∘F_) renaming (id to idF)\nopen import Categories.Functor.Bifunctor using (Bifunctor)\nopen import Categories.Functor.Hom using (Hom[_][-,-])\nopen import Categories.Functor.Construction.LiftSetoids\nopen import Categories.NaturalTransformation using (NaturalTransformation; ntHelper; _∘ₕ_; _∘ᵥ_; _∘ˡ_; _∘ʳ_)\n renaming (id to idN)\nopen import Categories.NaturalTransformation.NaturalIsomorphism\n using (NaturalIsomorphism; unitorˡ; unitorʳ; associator; _≃_)\nimport Categories.Morphism.Reasoning as MR\n\nprivate\n variable\n o o′ o″ ℓ ℓ′ ℓ″ e e′ e″ : Level\n C D E : Category o ℓ e\n\nrecord Adjoint (L : Functor C D) (R : Functor D C) : Set (levelOfTerm L ⊔ levelOfTerm R) where\n private\n module C = Category C\n module D = Category D\n module L = Functor L\n module R = Functor R\n\n field\n unit : NaturalTransformation idF (R ∘F L)\n counit : NaturalTransformation (L ∘F R) idF\n\n module unit = NaturalTransformation unit\n module counit = NaturalTransformation counit\n\n field\n zig : ∀ {A : C.Obj} → counit.η (L.F₀ A) D.∘ L.F₁ (unit.η A) D.≈ D.id\n zag : ∀ {B : D.Obj} → R.F₁ (counit.η B) C.∘ unit.η (R.F₀ B) C.≈ C.id\n\n private\n variable\n A : C.Obj\n B : D.Obj\n\n Ladjunct : L.F₀ A D.⇒ B → A C.⇒ R.F₀ B\n Ladjunct f = R.F₁ f C.∘ unit.η _\n\n Radjunct : A C.⇒ R.F₀ B → L.F₀ A D.⇒ B\n Radjunct f = counit.η _ D.∘ L.F₁ f\n\n RLadjunct≈id : ∀ {f : L.F₀ A D.⇒ B} → Radjunct (Ladjunct f) D.≈ f\n RLadjunct≈id {f = f} = begin\n Radjunct (Ladjunct f) ≈⟨ refl⟩∘⟨ L.homomorphism ⟩\n counit.η _ D.∘ L.F₁ (R.F₁ f) D.∘ L.F₁ (unit.η _) ≈⟨ pullˡ (counit.commute f) ⟩\n (f D.∘ counit.η _) D.∘ L.F₁ (unit.η _) ≈⟨ pullʳ zig ⟩\n f D.∘ D.id ≈⟨ D.identityʳ ⟩\n f ∎\n where open D.HomReasoning\n open MR D\n\n LRadjunct≈id : ∀ {f : A C.⇒ R.F₀ B} → Ladjunct (Radjunct f) C.≈ f\n LRadjunct≈id {f = f} = begin\n Ladjunct (Radjunct f) ≈⟨ R.homomorphism ⟩∘⟨refl ⟩\n (R.F₁ (counit.η _) C.∘ R.F₁ (L.F₁ f)) C.∘ unit.η _ ≈˘⟨ pushʳ (unit.commute f) ⟩\n R.F₁ (counit.η _) C.∘ unit.η _ C.∘ f ≈⟨ pullˡ zag ⟩\n C.id C.∘ f ≈⟨ C.identityˡ ⟩\n f ∎\n where open C.HomReasoning\n open MR C\n\n Hom[L-,-] : Bifunctor C.op D (Setoids _ _)\n Hom[L-,-] = Hom[ D ][-,-] ∘F (L.op ⁂ idF)\n\n Hom[-,R-] : Bifunctor C.op D (Setoids _ _)\n Hom[-,R-] = Hom[ C ][-,-] ∘F (idF ⁂ R)\n\n module Hom[L-,-] = Functor Hom[L-,-]\n module Hom[-,R-] = Functor Hom[-,R-]\n\n -- Inverse is more 'categorical' than bijection defined via injection/surjection\n Hom-inverse : ∀ A B → FI.Inverse (Hom[L-,-].F₀ (A , B)) (Hom[-,R-].F₀ (A , B))\n Hom-inverse A B = record\n { to = record\n { _⟨$⟩_ = Ladjunct {A} {B}\n ; cong = C.∘-resp-≈ˡ ∙ R.F-resp-≈\n }\n ; from = record\n { _⟨$⟩_ = Radjunct {A} {B}\n ; cong = D.∘-resp-≈ʳ ∙ L.F-resp-≈\n }\n ; inverse-of = record\n { left-inverse-of = λ _ → RLadjunct≈id\n ; right-inverse-of = λ _ → LRadjunct≈id\n }\n }\n\n module Hom-inverse {A} {B} = FI.Inverse (Hom-inverse A B)\n\n op : Adjoint R.op L.op\n op = record\n { unit = counit.op\n ; counit = unit.op\n ; zig = zag\n ; zag = zig\n }\n\n -- naturality condition on the two hom functors.\n -- these conditions are separated out because a complication due to the\n -- universe level in Agda.\n module _ where\n open C\n open HomReasoning\n open MR C\n\n Ladjunct-comm : ∀ {X Y A B} {h i : L.F₀ X D.⇒ Y} {f : A ⇒ X} {g : Y D.⇒ B} →\n h D.≈ i →\n R.F₁ (g D.∘ h D.∘ L.F₁ f) ∘ unit.η A ≈ R.F₁ g ∘ (R.F₁ i ∘ unit.η X) ∘ f\n Ladjunct-comm {X} {Y} {A} {B} {h} {i} {f} {g} eq = begin\n R.F₁ (g D.∘ h D.∘ L.F₁ f) ∘ unit.η A ≈⟨ R.homomorphism ⟩∘⟨refl ⟩\n (R.F₁ g ∘ R.F₁ (h D.∘ L.F₁ f)) ∘ unit.η A ≈⟨ (refl⟩∘⟨ R.homomorphism) ⟩∘⟨refl ⟩\n (R.F₁ g ∘ R.F₁ h ∘ R.F₁ (L.F₁ f)) ∘ unit.η A ≈⟨ pullʳ assoc ⟩\n R.F₁ g ∘ R.F₁ h ∘ R.F₁ (L.F₁ f) ∘ unit.η A ≈˘⟨ refl⟩∘⟨ ⟺ (R.F-resp-≈ eq) ⟩∘⟨ unit.commute f ⟩\n R.F₁ g ∘ R.F₁ i ∘ unit.η X ∘ f ≈˘⟨ refl⟩∘⟨ assoc ⟩\n R.F₁ g ∘ (R.F₁ i ∘ unit.η X) ∘ f ∎\n\n Ladjunct-comm′ : ∀ {X A B} {f : A ⇒ X} {g : L.F₀ X D.⇒ B} →\n Ladjunct (g D.∘ L.F₁ f) ≈ Ladjunct g ∘ f\n Ladjunct-comm′ = ∘-resp-≈ˡ R.homomorphism ○ (pullʳ (⟺ (unit.commute _))) ○ ⟺ assoc\n\n Ladjunct-resp-≈ : ∀ {A B} {f g : L.F₀ A D.⇒ B} → f D.≈ g → Ladjunct f ≈ Ladjunct g\n Ladjunct-resp-≈ eq = ∘-resp-≈ˡ (R.F-resp-≈ eq)\n\n module _ where\n open D\n open HomReasoning\n open MR D\n\n Radjunct-comm : ∀ {X Y A B} {h i : X C.⇒ R.F₀ Y} {f : A C.⇒ X} {g : Y ⇒ B} →\n h C.≈ i →\n counit.η B ∘ L.F₁ (R.F₁ g C.∘ h C.∘ f) ≈ g ∘ (counit.η Y ∘ L.F₁ i) ∘ L.F₁ f\n Radjunct-comm {X} {Y} {A} {B} {h} {i} {f} {g} eq = begin\n counit.η B ∘ L.F₁ (R.F₁ g C.∘ h C.∘ f) ≈⟨ refl⟩∘⟨ L.homomorphism ⟩\n counit.η B ∘ L.F₁ (R.F₁ g) ∘ L.F₁ (h C.∘ f) ≈⟨ pullˡ (counit.commute g) ⟩\n (g ∘ counit.η Y) ∘ L.F₁ (h C.∘ f) ≈⟨ refl⟩∘⟨ L.homomorphism ⟩\n (g ∘ counit.η Y) ∘ L.F₁ h ∘ L.F₁ f ≈⟨ refl ⟩∘⟨ L.F-resp-≈ eq ⟩∘⟨ refl ⟩\n (g ∘ counit.η Y) ∘ L.F₁ i ∘ L.F₁ f ≈⟨ pullʳ (⟺ assoc) ⟩\n g ∘ (counit.η Y ∘ L.F₁ i) ∘ L.F₁ f ∎\n\n Radjunct-comm′ : ∀ {Y A B} {f : A C.⇒ R.F₀ Y} {g : Y ⇒ B} →\n Radjunct (R.F₁ g C.∘ f) ≈ g ∘ Radjunct f\n Radjunct-comm′ = ∘-resp-≈ʳ L.homomorphism ○ pullˡ (counit.commute _) ○ assoc\n\n Radjunct-resp-≈ : ∀ {A B} {f g : A C.⇒ R.F₀ B} → f C.≈ g → Radjunct f ≈ Radjunct g\n Radjunct-resp-≈ eq = ∘-resp-≈ʳ (L.F-resp-≈ eq)\n\n -- a complication: the two hom functors do not live in the same Setoids,\n -- so they need to be mapped to the same Setoids first before establishing\n -- natural isomorphism!\n module _ where\n private\n levelℓ : Category o ℓ e → Level\n levelℓ {ℓ = ℓ} _ = ℓ\n\n levele : Category o ℓ e → Level\n levele {e = e} _ = e\n\n\n Hom[L-,-]′ : Bifunctor C.op D (Setoids _ _)\n Hom[L-,-]′ = LiftSetoids (levelℓ C) (levele C) ∘F Hom[ D ][-,-] ∘F (L.op ⁂ idF)\n\n Hom[-,R-]′ : Bifunctor C.op D (Setoids _ _)\n Hom[-,R-]′ = LiftSetoids (levelℓ D) (levele D) ∘F Hom[ C ][-,-] ∘F (idF ⁂ R)\n\n Hom-NI : NaturalIsomorphism Hom[L-,-]′ Hom[-,R-]′\n Hom-NI = record\n { F⇒G = ntHelper record\n { η = λ _ → record\n { _⟨$⟩_ = λ f → lift (Ladjunct (lower f))\n ; cong = λ eq → lift (Ladjunct-resp-≈ (lower eq))\n }\n ; commute = λ _ eq → lift $ Ladjunct-comm (lower eq)\n }\n ; F⇐G = ntHelper record\n { η = λ _ → record\n { _⟨$⟩_ = λ f → lift (Radjunct (lower f))\n ; cong = λ eq → lift (Radjunct-resp-≈ (lower eq))\n }\n ; commute = λ _ eq → lift $ Radjunct-comm (lower eq)\n }\n ; iso = λ X → record\n { isoˡ = λ eq → let open D.HomReasoning in lift (RLadjunct≈id ○ lower eq)\n ; isoʳ = λ eq → let open C.HomReasoning in lift (LRadjunct≈id ○ lower eq)\n }\n }\n\n module Hom-NI = NaturalIsomorphism Hom-NI\n\ninfix 5 _⊣_\n_⊣_ = Adjoint\n\n-- a special case of the natural isomorphism in which homsets in C and D have the same\n-- universe level. therefore there is no need to lift Setoids to the saem level.\n-- this is helpful when combining with Yoneda lemma.\nmodule _ {C : Category o ℓ e} {D : Category o′ ℓ e} {L : Functor C D} {R : Functor D C} where\n private\n module C = Category C\n module D = Category D\n module L = Functor L\n module R = Functor R\n\n module _ (adjoint : L ⊣ R) where\n open Adjoint adjoint\n\n -- in this case, the hom functors are naturally isomorphism directly\n Hom-NI′ : NaturalIsomorphism Hom[L-,-] Hom[-,R-]\n Hom-NI′ = record\n { F⇒G = ntHelper record\n { η = λ _ → Hom-inverse.to\n ; commute = λ _ eq → Ladjunct-comm eq\n }\n ; F⇐G = ntHelper record\n { η = λ _ → Hom-inverse.from\n ; commute = λ _ eq → Radjunct-comm eq\n }\n ; iso = λ _ → record\n { isoˡ = λ eq → let open D.HomReasoning in RLadjunct≈id ○ eq\n ; isoʳ = λ eq → let open C.HomReasoning in LRadjunct≈id ○ eq\n }\n }\n\n -- now goes from natural isomorphism back to adjoint.\n -- for simplicity, just construct the case in which homsetoids of C and D\n -- are compatible.\n\n private\n Hom[L-,-] : Bifunctor C.op D (Setoids _ _)\n Hom[L-,-] = Hom[ D ][-,-] ∘F (L.op ⁂ idF)\n\n Hom[-,R-] : Bifunctor C.op D (Setoids _ _)\n Hom[-,R-] = Hom[ C ][-,-] ∘F (idF ⁂ R)\n\n module _ (Hni : NaturalIsomorphism Hom[L-,-] Hom[-,R-]) where\n open NaturalIsomorphism Hni\n open NaturalTransformation\n open Functor\n open Π\n\n private\n unitη : ∀ X → F₀ Hom[L-,-] (X , L.F₀ X) ⟶ F₀ Hom[-,R-] (X , L.F₀ X)\n unitη X = ⇒.η (X , L.F₀ X)\n\n unit : NaturalTransformation idF (R ∘F L)\n unit = ntHelper record\n { η = λ X → unitη X ⟨$⟩ D.id\n ; commute = λ {X} {Y} f → begin\n (unitη Y ⟨$⟩ D.id) ∘ f ≈⟨ introˡ R.identity ⟩\n R.F₁ D.id ∘ (unitη Y ⟨$⟩ D.id) ∘ f ≈˘⟨ ⇒.commute (f , D.id) D.Equiv.refl ⟩\n ⇒.η (X , L.F₀ Y) ⟨$⟩ (D.id D.∘ D.id D.∘ L.F₁ f) ≈⟨ cong (⇒.η (X , L.F₀ Y)) (D.Equiv.trans D.identityˡ D.identityˡ) ⟩\n ⇒.η (X , L.F₀ Y) ⟨$⟩ L.F₁ f ≈⟨ cong (⇒.η (X , L.F₀ Y)) (MR.introʳ D (MR.elimʳ D L.identity)) ⟩\n ⇒.η (X , L.F₀ Y) ⟨$⟩ (L.F₁ f D.∘ D.id D.∘ L.F₁ id) ≈⟨ ⇒.commute (C.id , L.F₁ f) D.Equiv.refl ⟩\n R.F₁ (L.F₁ f) ∘ (unitη X ⟨$⟩ D.id) ∘ id ≈⟨ refl⟩∘⟨ identityʳ ⟩\n R.F₁ (L.F₁ f) ∘ (unitη X ⟨$⟩ D.id) ∎\n }\n where open C\n open HomReasoning\n open MR C\n\n counitη : ∀ X → F₀ Hom[-,R-] (R.F₀ X , X) ⟶ F₀ Hom[L-,-] (R.F₀ X , X)\n counitη X = ⇐.η (R.F₀ X , X)\n\n counit : NaturalTransformation (L ∘F R) idF\n counit = ntHelper record\n { η = λ X → counitη X ⟨$⟩ C.id\n ; commute = λ {X} {Y} f → begin\n (counitη Y ⟨$⟩ C.id) ∘ L.F₁ (R.F₁ f) ≈˘⟨ identityˡ ⟩\n id ∘ (counitη Y ⟨$⟩ C.id) ∘ L.F₁ (R.F₁ f) ≈˘⟨ ⇐.commute (R.F₁ f , D.id) C.Equiv.refl ⟩\n ⇐.η (R.F₀ X , Y) ⟨$⟩ (R.F₁ id C.∘ C.id C.∘ R.F₁ f) ≈⟨ cong (⇐.η (R.F₀ X , Y)) (C.Equiv.trans (MR.elimˡ C R.identity) C.identityˡ) ⟩\n ⇐.η (R.F₀ X , Y) ⟨$⟩ R.F₁ f ≈⟨ cong (⇐.η (R.F₀ X , Y)) (MR.introʳ C C.identityˡ) ⟩\n ⇐.η (R.F₀ X , Y) ⟨$⟩ (R.F₁ f C.∘ C.id C.∘ C.id) ≈⟨ ⇐.commute (C.id , f) C.Equiv.refl ⟩\n f ∘ (counitη X ⟨$⟩ C.id) ∘ L.F₁ C.id ≈⟨ refl⟩∘⟨ elimʳ L.identity ⟩\n f ∘ (counitη X ⟨$⟩ C.id) ∎\n }\n where open D\n open HomReasoning\n open MR D\n\n Hom-NI⇒Adjoint : L ⊣ R\n Hom-NI⇒Adjoint = record\n { unit = unit\n ; counit = counit\n ; zig = λ {A} →\n let open D\n open HomReasoning\n open MR D\n in begin\n η counit (L.F₀ A) ∘ L.F₁ (η unit A) ≈˘⟨ identityˡ ⟩\n id ∘ η counit (L.F₀ A) ∘ L.F₁ (η unit A) ≈˘⟨ ⇐.commute (η unit A , id) C.Equiv.refl ⟩\n ⇐.η (A , L.F₀ A) ⟨$⟩ (R.F₁ id C.∘ C.id C.∘ η unit A)\n ≈⟨ cong (⇐.η (A , L.F₀ A)) (C.Equiv.trans (MR.elimˡ C R.identity) C.identityˡ) ⟩\n ⇐.η (A , L.F₀ A) ⟨$⟩ η unit A ≈⟨ isoˡ refl ⟩\n id\n ∎\n ; zag = λ {B} →\n let open C\n open HomReasoning\n open MR C\n in begin\n R.F₁ (η counit B) ∘ η unit (R.F₀ B) ≈˘⟨ refl⟩∘⟨ identityʳ ⟩\n R.F₁ (η counit B) ∘ η unit (R.F₀ B) ∘ id ≈˘⟨ ⇒.commute (id , η counit B) D.Equiv.refl ⟩\n ⇒.η (R.F₀ B , B) ⟨$⟩ (η counit B D.∘ D.id D.∘ L.F₁ id)\n ≈⟨ cong (⇒.η (R.F₀ B , B)) (MR.elimʳ D (MR.elimʳ D L.identity)) ⟩\n ⇒.η (R.F₀ B , B) ⟨$⟩ η counit B ≈⟨ isoʳ refl ⟩\n id ∎\n }\n where module i {X} = Iso (iso X)\n open i\n\n-- the general case from isomorphic Hom setoids to adjoint functors\nmodule _ {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {L : Functor C D} {R : Functor D C} where\n private\n module C = Category C\n module D = Category D\n module L = Functor L\n module R = Functor R\n open Functor\n open Π\n \n Hom[L-,-] : Bifunctor C.op D (Setoids _ _)\n Hom[L-,-] = LiftSetoids ℓ e ∘F Hom[ D ][-,-] ∘F (L.op ⁂ idF)\n\n Hom[-,R-] : Bifunctor C.op D (Setoids _ _)\n Hom[-,R-] = LiftSetoids ℓ′ e′ ∘F Hom[ C ][-,-] ∘F (idF ⁂ R)\n\n module _ (Hni : Hom[L-,-] ≃ Hom[-,R-]) where\n open NaturalIsomorphism Hni\n private\n unitη : ∀ X → F₀ Hom[L-,-] (X , L.F₀ X) ⟶ F₀ Hom[-,R-] (X , L.F₀ X)\n unitη X = ⇒.η (X , L.F₀ X)\n \n unit : NaturalTransformation idF (R ∘F L)\n unit = ntHelper record\n { η = λ X → lower (unitη X ⟨$⟩ lift D.id)\n ; commute = λ {X Y} f → begin\n lower (unitη Y ⟨$⟩ lift D.id) ∘ f\n ≈⟨ introˡ R.identity ⟩\n R.F₁ D.id ∘ lower (unitη Y ⟨$⟩ lift D.id) ∘ f\n ≈˘⟨ lower (⇒.commute (f , D.id) (lift D.Equiv.refl)) ⟩\n lower (⇒.η (X , L.F₀ Y) ⟨$⟩ lift (D.id D.∘ D.id D.∘ L.F₁ f))\n ≈⟨ lower (cong (⇒.η (X , L.F₀ Y)) (lift (D.Equiv.trans D.identityˡ D.identityˡ))) ⟩\n lower (⇒.η (X , L.F₀ Y) ⟨$⟩ lift (L.F₁ f))\n ≈⟨ lower (cong (⇒.η (X , L.F₀ Y)) (lift (MR.introʳ D (MR.elimʳ D L.identity)))) ⟩\n lower (⇒.η (X , L.F₀ Y) ⟨$⟩ lift (L.F₁ f D.∘ D.id D.∘ L.F₁ id))\n ≈⟨ lower (⇒.commute (C.id , L.F₁ f) (lift D.Equiv.refl)) ⟩\n R.F₁ (L.F₁ f) ∘ lower (⇒.η (X , L.F₀ X) ⟨$⟩ lift D.id) ∘ id\n ≈⟨ refl⟩∘⟨ identityʳ ⟩\n F₁ (R ∘F L) f ∘ lower (unitη X ⟨$⟩ lift D.id) ∎\n }\n where open C\n open HomReasoning\n open MR C\n \n\n counitη : ∀ X → F₀ Hom[-,R-] (R.F₀ X , X) ⟶ F₀ Hom[L-,-] (R.F₀ X , X)\n counitη X = ⇐.η (R.F₀ X , X)\n\n counit : NaturalTransformation (L ∘F R) idF\n counit = ntHelper record\n { η = λ X → lower (counitη X ⟨$⟩ lift C.id)\n ; commute = λ {X} {Y} f → begin\n lower (⇐.η (R.F₀ Y , Y) ⟨$⟩ lift C.id) ∘ L.F₁ (R.F₁ f)\n ≈˘⟨ identityˡ ⟩\n id ∘ lower (⇐.η (R.F₀ Y , Y) ⟨$⟩ lift C.id) ∘ L.F₁ (R.F₁ f)\n ≈˘⟨ lower (⇐.commute (R.F₁ f , D.id) (lift C.Equiv.refl)) ⟩\n lower (⇐.η (R.F₀ X , Y) ⟨$⟩ lift (R.F₁ id C.∘ C.id C.∘ R.F₁ f))\n ≈⟨ lower (cong (⇐.η (R.F₀ X , Y)) (lift (C.Equiv.trans (MR.elimˡ C R.identity) C.identityˡ))) ⟩\n lower (⇐.η (R.F₀ X , Y) ⟨$⟩ lift (R.F₁ f))\n ≈⟨ lower (cong (⇐.η (R.F₀ X , Y)) (lift (MR.introʳ C C.identityˡ))) ⟩\n lower (⇐.η (R.F₀ X , Y) ⟨$⟩ lift (R.F₁ f C.∘ C.id C.∘ C.id))\n ≈⟨ lower (⇐.commute (C.id , f) (lift C.Equiv.refl)) ⟩\n f ∘ lower (⇐.η (R.F₀ X , X) ⟨$⟩ lift C.id) ∘ L.F₁ C.id\n ≈⟨ refl⟩∘⟨ elimʳ L.identity ⟩\n f ∘ lower (⇐.η (R.F₀ X , X) ⟨$⟩ lift C.id)\n ∎\n }\n where open D\n open HomReasoning\n open MR D\n\n Hom-NI′⇒Adjoint : L ⊣ R\n Hom-NI′⇒Adjoint = record\n { unit = unit\n ; counit = counit\n ; zig = λ {A} →\n let open D\n open HomReasoning\n open MR D\n in begin\n lower (counitη (L.F₀ A) ⟨$⟩ lift C.id) ∘ L.F₁ (η unit A)\n ≈˘⟨ identityˡ ⟩\n id ∘ lower (counitη (L.F₀ A) ⟨$⟩ lift C.id) ∘ L.F₁ (η unit A)\n ≈˘⟨ lower (⇐.commute (η unit A , id) (lift C.Equiv.refl)) ⟩\n lower (⇐.η (A , L.F₀ A) ⟨$⟩ lift (R.F₁ id C.∘ C.id C.∘ lower (⇒.η (A , L.F₀ A) ⟨$⟩ lift id)))\n ≈⟨ lower (cong (⇐.η (A , L.F₀ A)) (lift (C.Equiv.trans (MR.elimˡ C R.identity) C.identityˡ))) ⟩\n lower (⇐.η (A , L.F₀ A) ⟨$⟩ (⇒.η (A , L.F₀ A) ⟨$⟩ lift id))\n ≈⟨ lower (isoˡ (lift refl)) ⟩\n id ∎\n ; zag = λ {B} →\n let open C\n open HomReasoning\n open MR C\n in begin\n R.F₁ (lower (⇐.η (R.F₀ B , B) ⟨$⟩ lift id)) ∘ lower (⇒.η (R.F₀ B , L.F₀ (R.F₀ B)) ⟨$⟩ lift D.id)\n ≈˘⟨ refl⟩∘⟨ identityʳ ⟩\n R.F₁ (lower (⇐.η (R.F₀ B , B) ⟨$⟩ lift id)) ∘ lower (⇒.η (R.F₀ B , L.F₀ (R.F₀ B)) ⟨$⟩ lift D.id) ∘ id\n ≈˘⟨ lower (⇒.commute (id , η counit B) (lift D.Equiv.refl)) ⟩\n lower (⇒.η (R.F₀ B , B) ⟨$⟩ lift (lower (⇐.η (R.F₀ B , B) ⟨$⟩ lift id) D.∘ D.id D.∘ L.F₁ id))\n ≈⟨ lower (cong (⇒.η (R.F₀ B , B)) (lift (MR.elimʳ D (MR.elimʳ D L.identity)))) ⟩\n lower (⇒.η (R.F₀ B , B) ⟨$⟩ lift (lower (⇐.η (R.F₀ B , B) ⟨$⟩ lift id)))\n ≈⟨ lower (isoʳ (lift refl)) ⟩\n id ∎\n }\n where open NaturalTransformation\n module _ {X} where\n open Iso (iso X) public\n\n⊣-id : idF {C = C} ⊣ idF {C = C}\n⊣-id {C = C} = record\n { unit = F⇐G unitorˡ\n ; counit = F⇒G unitorʳ\n ; zig = identityˡ\n ; zag = identityʳ\n }\n where open Category C\n open NaturalIsomorphism\n\n-- Adjoints compose; we can't be sloppy, so associators and unitors must be inserted.\n-- Use single letters in pairs, so L & M on the left, and R & S on the right\n_∘⊣_ : {L : Functor C D} {R : Functor D C} {M : Functor D E} {S : Functor E D} →\n L ⊣ R → M ⊣ S → (M ∘F L) ⊣ (R ∘F S)\n_∘⊣_ {C = C} {D = D} {E = E} {L = L} {R} {M} {S} LR MS = record\n { unit = ((F⇐G (associator _ S R) ∘ᵥ R ∘ˡ (F⇒G (associator L M S))) ∘ᵥ\n (R ∘ˡ (MSη′ ∘ʳ L)) ∘ᵥ (R ∘ˡ (F⇐G unitorˡ))) ∘ᵥ LRη′\n ; counit = MSε′ ∘ᵥ (((F⇒G (unitorʳ {F = M}) ∘ʳ S) ∘ᵥ ((M ∘ˡ LRε′) ∘ʳ S)) ∘ᵥ\n (F⇒G (associator R L M) ∘ʳ S) ) ∘ᵥ F⇐G (associator S R (M ∘F L) )\n ; zig = λ {A} → zig′ {A}\n ; zag = λ {B} → zag′ {B}\n }\n where\n open Functor\n open NaturalTransformation\n open NaturalIsomorphism\n module LR = Adjoint LR renaming (unit to LRη′; counit to LRε′)\n module MS = Adjoint MS renaming (unit to MSη′; counit to MSε′)\n module LRη = NaturalTransformation (Adjoint.unit LR) renaming (η to ηLR)\n module MSη = NaturalTransformation (Adjoint.unit MS) renaming (η to ηMS)\n module LRε = NaturalTransformation (Adjoint.counit LR) renaming (η to εLR)\n module MSε = NaturalTransformation (Adjoint.counit MS) renaming (η to εMS)\n module C = Category C\n module D = Category D\n module E = Category E\n module L = Functor L renaming (F₀ to L₀; F₁ to L₁)\n module M = Functor M renaming (F₀ to M₀; F₁ to M₁)\n module R = Functor R renaming (F₀ to R₀; F₁ to R₁)\n module S = Functor S renaming (F₀ to S₀; F₁ to S₁)\n open LR; open MS; open LRη; open LRε; open MSε; open MSη; open L; open M; open R; open S\n\n zig′ : {A : C.Obj} → (εMS (M₀ (L₀ A)) E.∘\n ((E.id E.∘ M₁ (εLR (S₀ (M₀ (L₀ A))))) E.∘ E.id) E.∘ E.id)\n E.∘ M₁ (L₁ (((C.id C.∘ R₁ D.id) C.∘ R₁ (ηMS (L₀ A)) C.∘ R₁ D.id) C.∘ ηLR A))\n E.≈ E.id\n -- use \"inverted\" format here, where rules are out-dented\n zig′ {A} = begin\n (εMS (M₀ (L₀ A)) E.∘ ((E.id E.∘ M₁ (εLR (S₀ (M₀ (L₀ A))))) E.∘ E.id) E.∘ E.id)\n E.∘ M₁ (L₁ (((C.id C.∘ R₁ D.id) C.∘ R₁ (ηMS (L₀ A)) C.∘ R₁ D.id) C.∘ ηLR A))\n ≈⟨ ( refl⟩∘⟨ (E.identityʳ ○ E.identityʳ ○ E.identityˡ)) ⟩∘⟨refl ⟩ -- get rid of those pesky E.id\n (εMS (M₀ (L₀ A)) E.∘ M₁ (εLR (S₀ (M₀ (L₀ A)))))\n E.∘ M₁ (L₁ (((C.id C.∘ R₁ D.id) C.∘ R₁ (ηMS (L₀ A)) C.∘ R₁ D.id) C.∘ ηLR A))\n ≈⟨ E.assoc ○ E.∘-resp-≈ʳ (⟺ M.homomorphism) ⟩\n εMS (M₀ (L₀ A)) E.∘\n M₁ (εLR (S₀ (M₀ (L₀ A))) D.∘ L₁ (((C.id C.∘ R₁ D.id) C.∘ R₁ (ηMS (L₀ A)) C.∘ R₁ D.id) C.∘ ηLR A))\n -- below: get rid of lots of pesky id. Nasty bit of nested equational reasoning, but nothing deep\n ≈⟨ refl⟩∘⟨ M.F-resp-≈ (D.∘-resp-≈ʳ (L.F-resp-≈\n (C.∘-resp-≈ˡ (C.∘-resp-≈ C.identityˡ (C.∘-resp-≈ʳ R.identity) C.HomReasoning.○\n let _⊚_ = C.HomReasoning._○_ in C.∘-resp-≈ R.identity C.identityʳ ⊚ C.identityˡ)))) ⟩\n εMS (M₀ (L₀ A)) E.∘ M₁ (εLR (S₀ (M₀ (L₀ A))) D.∘ L₁ ((R₁ (ηMS (L₀ A))) C.∘ ηLR A))\n ≈⟨ refl⟩∘⟨ M.F-resp-≈ (D.∘-resp-≈ʳ L.homomorphism) ⟩\n εMS (M₀ (L₀ A)) E.∘ M₁ (εLR (S₀ (M₀ (L₀ A))) D.∘ L₁ (R₁ (ηMS (L₀ A))) D.∘ L₁ (ηLR A))\n ≈˘⟨ refl⟩∘⟨ M.F-resp-≈ D.assoc ⟩\n εMS (M₀ (L₀ A)) E.∘ M₁ ((εLR (S₀ (M₀ (L₀ A))) D.∘ L₁ (R₁ (ηMS (L₀ A)))) D.∘ L₁ (ηLR A))\n ≈⟨ refl⟩∘⟨ M.F-resp-≈ (D.∘-resp-≈ˡ (LRε.commute _)) ⟩\n εMS (M₀ (L₀ A)) E.∘ M₁ ( (_ D.∘ εLR _) D.∘ L₁ (ηLR A))\n ≈⟨ refl⟩∘⟨ M.homomorphism ⟩\n εMS (M₀ (L₀ A)) E.∘ M₁ (_ D.∘ εLR _) E.∘ M₁ (L₁ (ηLR A))\n ≈⟨ refl⟩∘⟨ ( M.homomorphism ⟩∘⟨refl ) ⟩\n εMS (M₀ (L₀ A)) E.∘ (M₁ (ηMS (L₀ A)) E.∘ M₁ (εLR _)) E.∘ M₁ (L₁ (ηLR A))\n ≈˘⟨ E.assoc ○ E.∘-resp-≈ʳ (⟺ E.assoc) ⟩\n (εMS (M₀ (L₀ A)) E.∘ M₁ (ηMS (L₀ A))) E.∘ (M₁ (εLR _) E.∘ M₁ (L₁ (ηLR A)))\n ≈⟨ MS.zig ⟩∘⟨refl ⟩\n E.id E.∘ (M₁ (εLR _) E.∘ M₁ (L₁ (ηLR A)))\n ≈⟨ E.identityˡ ⟩\n M₁ (εLR _) E.∘ M₁ (L₁ (ηLR A))\n ≈˘⟨ M.homomorphism ⟩\n M₁ (εLR _ D.∘ L₁ (ηLR A))\n ≈⟨ M.F-resp-≈ LR.zig ○ M.identity ⟩\n E.id ∎\n where open E.HomReasoning\n\n zag′ : {B : E.Obj} → R₁ (S₁ (εMS B E.∘ ((E.id E.∘ M₁ (εLR (S₀ B))) E.∘ E.id) E.∘ E.id))\n C.∘ ((C.id C.∘ R₁ D.id) C.∘ R₁ (ηMS (L₀ (R₀ (S₀ B)))) C.∘ R₁ D.id) C.∘\n ηLR (R₀ (S₀ B)) C.≈ C.id\n zag′ {B} =\n let _⊚_ = E.HomReasoning._○_ in\n begin\n R₁ (S₁ (εMS B E.∘ ((E.id E.∘ M₁ (εLR (S₀ B))) E.∘ E.id) E.∘ E.id))\n C.∘ ((C.id C.∘ R₁ D.id) C.∘ R₁ (ηMS (L₀ (R₀ (S₀ B)))) C.∘ R₁ D.id) C.∘\n ηLR (R₀ (S₀ B)) -- get rid of all those id\n ≈⟨ R.F-resp-≈ (S.F-resp-≈ (E.∘-resp-≈ʳ (E.identityʳ ⊚ (E.identityʳ ⊚ E.identityˡ)))) ⟩∘⟨\n C.∘-resp-≈ˡ (C.∘-resp-≈ C.identityˡ (C.∘-resp-≈ʳ R.identity) ○\n C.∘-resp-≈ R.identity C.identityʳ ○ C.identityˡ) ⟩\n R₁ (S₁ (εMS B E.∘ M₁ (εLR (S₀ B)))) C.∘ R₁ (ηMS (L₀ (R₀ (S₀ B)))) C.∘ ηLR (R₀ (S₀ B))\n ≈˘⟨ C.assoc ⟩\n (R₁ (S₁ (εMS B E.∘ M₁ (εLR (S₀ B)))) C.∘ R₁ (ηMS (L₀ (R₀ (S₀ B))))) C.∘ ηLR (R₀ (S₀ B))\n ≈˘⟨ R.homomorphism ⟩∘⟨refl ⟩\n R₁ (S₁ (εMS B E.∘ M₁ (εLR (S₀ B))) D.∘ ηMS (L₀ (R₀ (S₀ B)))) C.∘ ηLR (R₀ (S₀ B))\n ≈⟨ R.F-resp-≈ (D.∘-resp-≈ˡ S.homomorphism) ⟩∘⟨refl ⟩\n R₁ ((S₁ (εMS B) D.∘ (S₁ (M₁ (εLR (S₀ B))))) D.∘ ηMS (L₀ (R₀ (S₀ B)))) C.∘ ηLR (R₀ (S₀ B))\n ≈⟨ R.F-resp-≈ D.assoc ⟩∘⟨refl ⟩\n R₁ (S₁ (εMS B) D.∘ S₁ (M₁ (εLR (S₀ B))) D.∘ ηMS (L₀ (R₀ (S₀ B)))) C.∘ ηLR (R₀ (S₀ B))\n ≈⟨ R.F-resp-≈ (D.∘-resp-≈ʳ (D.HomReasoning.⟺ (MSη.commute (εLR (S₀ B))))) ⟩∘⟨refl ⟩\n R₁ (S₁ (εMS B) D.∘ ηMS (S₀ B) D.∘ εLR (S₀ B)) C.∘ ηLR (R₀ (S₀ B))\n ≈˘⟨ R.F-resp-≈ D.assoc ⟩∘⟨refl ⟩\n R₁ ((S₁ (εMS B) D.∘ ηMS (S₀ B)) D.∘ εLR (S₀ B)) C.∘ ηLR (R₀ (S₀ B))\n ≈⟨ R.F-resp-≈ (D.∘-resp-≈ˡ MS.zag) ⟩∘⟨refl ⟩\n R₁ (D.id D.∘ εLR (S₀ B)) C.∘ ηLR (R₀ (S₀ B))\n ≈⟨ C.∘-resp-≈ˡ (R.F-resp-≈ D.identityˡ) ⟩\n R₁ (εLR (S₀ B)) C.∘ ηLR (R₀ (S₀ B))\n ≈⟨ LR.zag ⟩\n C.id ∎\n where open C.HomReasoning\n", "meta": {"hexsha": "ebf3758cc2490bdc5eea1af014c8bf95ae653886", "size": 23852, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Adjoint.agda", "max_stars_repo_name": "Taneb/agda-categories", "max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Categories/Adjoint.agda", "max_issues_repo_name": "Taneb/agda-categories", "max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Categories/Adjoint.agda", "max_forks_repo_name": "Taneb/agda-categories", "max_forks_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.2101449275, "max_line_length": 141, "alphanum_fraction": 0.4841941976, "num_tokens": 10578, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933271118221, "lm_q2_score": 0.7431680086124811, "lm_q1q2_score": 0.6093184911843543}} {"text": "{-# OPTIONS --universe-polymorphism #-}\nmodule Categories.Monad where\n\nopen import Level\n\nopen import Categories.Category\nopen import Categories.Functor hiding (_≡_; assoc; identityˡ; identityʳ)\nopen import Categories.NaturalTransformation renaming (id to idN)\n\nrecord Monad {o ℓ e} (C : Category o ℓ e) : Set (o ⊔ ℓ ⊔ e) where\n field\n F : Endofunctor C\n η : NaturalTransformation id F\n μ : NaturalTransformation (F ∘ F) F\n\n open Functor F\n\n field\n .assoc : μ ∘₁ (F ∘ˡ μ) ≡ μ ∘₁ (μ ∘ʳ F)\n .identityˡ : μ ∘₁ (F ∘ˡ η) ≡ idN\n .identityʳ : μ ∘₁ (η ∘ʳ F) ≡ idN", "meta": {"hexsha": "c1eca3a8e73a374b58d06af33d78bfbc5068c632", "size": 580, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Monad.agda", "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 98, "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_issues_repo_path": "Categories/Monad.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_forks_repo_path": "Categories/Monad.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 23, "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "avg_line_length": 27.619047619, "max_line_length": 72, "alphanum_fraction": 0.6568965517, "num_tokens": 207, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9353465116437761, "lm_q2_score": 0.6513548511303336, "lm_q1q2_score": 0.6092424878470087}} {"text": "module Categories.Functor.Discrete where\n\nopen import Categories.Category\nopen import Categories.Functor\nopen import Categories.Agda\nopen import Categories.Categories\nopen import Categories.Support.PropositionalEquality\nimport Categories.Discrete as D\n\nDiscrete : ∀ {o} -> Functor (Sets o) (Categories o o _)\nDiscrete {o} = record {\n F₀ = D.Discrete;\n F₁ = F₁;\n identity = λ f → Heterogeneous.≡⇒∼ _;\n homomorphism = λ f → Heterogeneous.≡⇒∼ _;\n F-resp-≡ = F-resp-≡}\n where\n F₁ : {A B : Category.Obj (Sets o)} → Sets o [ A , B ] →\n Categories o o _ [ D.Discrete A , D.Discrete B ]\n F₁ f = record {\n F₀ = f;\n F₁ = ≣-cong f;\n identity = _;\n homomorphism = _;\n F-resp-≡ = _ }\n \n F-resp-≡ : {A B : Set o} {F G : Sets o [ A , B ]} →\n Sets o [ F ≡ G ] → Categories o o _ [ F₁ F ≡ F₁ G ]\n F-resp-≡ F≡G {a} ≣-refl rewrite F≡G {a} = Heterogeneous.≡⇒∼ _\n", "meta": {"hexsha": "7f6e9dd815b71b6bf3a7726fd0779844a4af83a6", "size": 1016, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Functor/Discrete.agda", "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 98, "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_issues_repo_path": "Categories/Functor/Discrete.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_forks_repo_path": "Categories/Functor/Discrete.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 23, "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "avg_line_length": 33.8666666667, "max_line_length": 72, "alphanum_fraction": 0.531496063, "num_tokens": 328, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898279984214, "lm_q2_score": 0.6723316991792861, "lm_q1q2_score": 0.6091256804973278}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Relation.Binary.Base where\n\nopen import Cubical.Core.Everything\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Data.Sigma\nopen import Cubical.HITs.SetQuotients.Base\nopen import Cubical.HITs.PropositionalTruncation.Base\n\nRel : ∀ {ℓ} (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))\nRel A B ℓ' = A → B → Type ℓ'\n\nPropRel : ∀ {ℓ} (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))\nPropRel A B ℓ' = Σ[ R ∈ Rel A B ℓ' ] ∀ a b → isProp (R a b)\n\nidPropRel : ∀ {ℓ} (A : Type ℓ) → PropRel A A ℓ\nidPropRel A .fst a a' = ∥ a ≡ a' ∥\nidPropRel A .snd _ _ = squash\n\ninvPropRel : ∀ {ℓ ℓ'} {A B : Type ℓ}\n → PropRel A B ℓ' → PropRel B A ℓ'\ninvPropRel R .fst b a = R .fst a b\ninvPropRel R .snd b a = R .snd a b\n\ncompPropRel : ∀ {ℓ ℓ' ℓ''} {A B C : Type ℓ}\n → PropRel A B ℓ' → PropRel B C ℓ'' → PropRel A C (ℓ-max ℓ (ℓ-max ℓ' ℓ''))\ncompPropRel R S .fst a c = ∥ Σ[ b ∈ _ ] (R .fst a b × S .fst b c) ∥\ncompPropRel R S .snd _ _ = squash\n\ngraphRel : ∀ {ℓ} {A B : Type ℓ} → (A → B) → Rel A B ℓ\ngraphRel f a b = f a ≡ b\n\nmodule BinaryRelation {ℓ ℓ' : Level} {A : Type ℓ} (R : Rel A A ℓ') where\n isRefl : Type (ℓ-max ℓ ℓ')\n isRefl = (a : A) → R a a\n\n isSym : Type (ℓ-max ℓ ℓ')\n isSym = (a b : A) → R a b → R b a\n\n isTrans : Type (ℓ-max ℓ ℓ')\n isTrans = (a b c : A) → R a b → R b c → R a c\n\n record isEquivRel : Type (ℓ-max ℓ ℓ') where\n constructor equivRel\n field\n reflexive : isRefl\n symmetric : isSym\n transitive : isTrans\n\n isPropValued : Type (ℓ-max ℓ ℓ')\n isPropValued = (a b : A) → isProp (R a b)\n\n isEffective : Type (ℓ-max ℓ ℓ')\n isEffective =\n (a b : A) → isEquiv (eq/ {R = R} a b)\n\nEquivRel : ∀ {ℓ} (A : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))\nEquivRel A ℓ' = Σ[ R ∈ Rel A A ℓ' ] BinaryRelation.isEquivRel R\n\nEquivPropRel : ∀ {ℓ} (A : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))\nEquivPropRel A ℓ' = Σ[ R ∈ PropRel A A ℓ' ] BinaryRelation.isEquivRel (R .fst)\n\n", "meta": {"hexsha": "be51c02b7d27169d2918a6db3250cfc876bc93e6", "size": 2028, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Relation/Binary/Base.agda", "max_stars_repo_name": "apabepa10/cubical", "max_stars_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Relation/Binary/Base.agda", "max_issues_repo_name": "apabepa10/cubical", "max_issues_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/Relation/Binary/Base.agda", "max_forks_repo_name": "apabepa10/cubical", "max_forks_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.2, "max_line_length": 78, "alphanum_fraction": 0.5892504931, "num_tokens": 879, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357701094303, "lm_q2_score": 0.7025300573952052, "lm_q1q2_score": 0.6091186893386741}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties satisfied by preorders\n------------------------------------------------------------------------\n\nopen import Relation.Binary\n\nmodule Relation.Binary.Properties.Preorder\n {p₁ p₂ p₃} (P : Preorder p₁ p₂ p₃) where\n\nopen import Function\nopen import Data.Product as Prod\n\nopen Relation.Binary.Preorder P\n\n------------------------------------------------------------------------\n-- For every preorder there is an induced equivalence\n\nInducedEquivalence : Setoid _ _\nInducedEquivalence = record\n { _≈_ = λ x y → x ∼ y × y ∼ x\n ; isEquivalence = record\n { refl = (refl , refl)\n ; sym = swap\n ; trans = Prod.zip trans (flip trans)\n }\n }\n", "meta": {"hexsha": "716300e30c5b2ef926c563d1f0d8953e81a5a784", "size": 783, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Relation/Binary/Properties/Preorder.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Relation/Binary/Properties/Preorder.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Relation/Binary/Properties/Preorder.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.0, "max_line_length": 72, "alphanum_fraction": 0.4827586207, "num_tokens": 165, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8438950947024555, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.6090755564802453}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Some basic properties of Rings\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Algebra\n\nmodule Algebra.Properties.Ring {r₁ r₂} (R : Ring r₁ r₂) where\n\nopen Ring R\n\nimport Algebra.Properties.AbelianGroup as AbelianGroupProperties\nopen import Function using (_$_)\nopen import Relation.Binary.Reasoning.Setoid setoid\n\n------------------------------------------------------------------------\n-- Export properties of abelian groups\n\nopen AbelianGroupProperties +-abelianGroup public\n renaming\n ( ε⁻¹≈ε to -0#≈0#\n ; ∙-cancelˡ to +-cancelˡ\n ; ∙-cancelʳ to +-cancelʳ\n ; ∙-cancel to +-cancel\n ; ⁻¹-involutive to -‿involutive\n ; ⁻¹-injective to -‿injective\n ; ⁻¹-anti-homo-∙ to -‿anti-homo-+\n ; identityˡ-unique to +-identityˡ-unique\n ; identityʳ-unique to +-identityʳ-unique\n ; identity-unique to +-identity-unique\n ; inverseˡ-unique to +-inverseˡ-unique\n ; inverseʳ-unique to +-inverseʳ-unique\n ; ⁻¹-∙-comm to -‿+-comm\n -- DEPRECATED\n ; left-identity-unique to +-left-identity-unique\n ; right-identity-unique to +-right-identity-unique\n ; left-inverse-unique to +-left-inverse-unique\n ; right-inverse-unique to +-right-inverse-unique\n )\n\n------------------------------------------------------------------------\n-- Properties of -_\n\n-‿distribˡ-* : ∀ x y → - (x * y) ≈ - x * y\n-‿distribˡ-* x y = sym $ begin\n - x * y ≈⟨ sym $ +-identityʳ _ ⟩\n - x * y + 0# ≈⟨ +-congˡ $ sym (-‿inverseʳ _) ⟩\n - x * y + (x * y + - (x * y)) ≈⟨ sym $ +-assoc _ _ _ ⟩\n - x * y + x * y + - (x * y) ≈⟨ +-congʳ $ sym (distribʳ _ _ _) ⟩\n (- x + x) * y + - (x * y) ≈⟨ +-congʳ $ *-congʳ $ -‿inverseˡ _ ⟩\n 0# * y + - (x * y) ≈⟨ +-congʳ $ zeroˡ _ ⟩\n 0# + - (x * y) ≈⟨ +-identityˡ _ ⟩\n - (x * y) ∎\n\n-‿distribʳ-* : ∀ x y → - (x * y) ≈ x * - y\n-‿distribʳ-* x y = sym $ begin\n x * - y ≈⟨ sym $ +-identityˡ _ ⟩\n 0# + x * - y ≈⟨ +-congʳ $ sym (-‿inverseˡ _) ⟩\n - (x * y) + x * y + x * - y ≈⟨ +-assoc _ _ _ ⟩\n - (x * y) + (x * y + x * - y) ≈⟨ +-congˡ $ sym (distribˡ _ _ _) ⟩\n - (x * y) + x * (y + - y) ≈⟨ +-congˡ $ *-congˡ $ -‿inverseʳ _ ⟩\n - (x * y) + x * 0# ≈⟨ +-congˡ $ zeroʳ _ ⟩\n - (x * y) + 0# ≈⟨ +-identityʳ _ ⟩\n - (x * y) ∎\n\n\n------------------------------------------------------------------------\n-- DEPRECATED NAMES\n------------------------------------------------------------------------\n-- Please use the new names as continuing support for the old names is\n-- not guaranteed.\n\n-- Version 1.1\n\n-‿*-distribˡ : ∀ x y → - x * y ≈ - (x * y)\n-‿*-distribˡ x y = sym (-‿distribˡ-* x y)\n{-# WARNING_ON_USAGE -‿*-distribˡ\n\"Warning: -‿*-distribˡ was deprecated in v1.1.\nPlease use -‿distribˡ-* instead.\nNOTE: the equality is flipped so you will need sym (-‿distribˡ-* ...).\"\n#-}\n-‿*-distribʳ : ∀ x y → x * - y ≈ - (x * y)\n-‿*-distribʳ x y = sym (-‿distribʳ-* x y)\n{-# WARNING_ON_USAGE -‿*-distribʳ\n\"Warning: -‿*-distribʳ was deprecated in v1.1.\nPlease use -‿distribʳ-* instead.\nNOTE: the equality is flipped so you will need sym (-‿distribʳ-* ...).\"\n#-}\n", "meta": {"hexsha": "a16f302cd11d2409538d58165a44e540572965ec", "size": 3385, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Algebra/Properties/Ring.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Algebra/Properties/Ring.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Algebra/Properties/Ring.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 36.7934782609, "max_line_length": 72, "alphanum_fraction": 0.458788774, "num_tokens": 1207, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8438950947024555, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.6090755514293653}} {"text": "-- This file gives the definition of Gaussian Integers, the addition\n-- and multiplication on them, and shows that they form a commutative\n-- ring, and other properties. All the proofs are straightforward.\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule GauInt.Properties where\n\n-- imports from local.\nopen import GauInt.Instances\nopen import Instances\nopen import GauInt.Base using (𝔾 ; _+_i ; _ᶜ ; Re ; Im ; _+0i ; _+0i' ; 0𝔾)\nopen import Integer.Properties\n\n-- imports from stdlib and Agda.\nopen import Level using (0ℓ)\nopen import Relation.Nullary using (yes; no; ¬_)\nopen import Relation.Binary using (DecidableEquality ; Setoid ; DecSetoid ; tri< ; tri≈ ; tri>)\nopen import Relation.Binary.PropositionalEquality\nopen ≡-Reasoning\n\nopen import Data.Product using (proj₁; proj₂; _,_ ; _×_)\nopen import Data.Sum using (_⊎_ ; inj₁ ; inj₂) renaming ([_,_]′ to ⊎-elim)\nopen import Data.Nat as Nat using (ℕ; suc; zero)\nimport Data.Nat.Properties as NatP\nopen import Data.Integer.Properties as IntP\n using (+-assoc ; +-identityˡ ; +-identityʳ ; *-identityˡ ; +-inverseˡ ; +-inverseʳ ; +-comm ; 0≤i⇒+∣i∣≡i ; +-mono-≤ ; +-mono-<-≤ ; +-mono-≤-<)\nopen import Data.Integer as Int\n using (ℤ ; +_ ; NonNegative ; -[1+_] ; +[1+_] ; +≤+ ; +<+ ; ∣_∣ ; 0ℤ ; +0)\nimport Data.Integer.Solver as IS\nopen IS.+-*-Solver\n\nopen import Algebra.Bundles as B\nimport Algebra.Morphism as Morphism\nopen import Algebra.Structures {A = 𝔾} _≡_\nopen import Function.Base using (_$_)\nmodule 𝔾toℕ = Morphism.Definitions 𝔾 ℕ _≡_\nmodule ℕto𝔾 = Morphism.Definitions ℕ 𝔾 _≡_\n\n\nopen import Algebra.Definitions (_≡_ {A = 𝔾}) using (AlmostLeftCancellative)\n\n\n-- ----------------------------------------------------------------------\n-- Equality\n\n-- Injections are injective.\n+0i'-injective : ∀ {a b} -> a +0i' ≡ b +0i' → a ≡ b\n+0i'-injective refl = refl\n\n+0i-injective : ∀ {m n} -> m +0i ≡ n +0i → m ≡ n\n+0i-injective refl = refl\n\n-- Decidable equality on 𝔾.\ninfix 4 _≟_\n_≟_ : DecidableEquality 𝔾\n_≟_ x@(a + b i) y@(c + d i) with a Int.≟ c | b Int.≟ d\n... | yes p | yes q = yes (cong₂ _+_i p q)\n... | yes p | no ¬q = no (λ { refl → ¬q refl})\n... | no ¬p | hyp = no (λ { refl → ¬p refl})\n\n\n≡-setoid : Setoid 0ℓ 0ℓ\n≡-setoid = setoid 𝔾\n\n≡-decSetoid : DecSetoid 0ℓ 0ℓ\n≡-decSetoid = decSetoid _≟_\n\n\n-- ----------------------------------------------------------------------\n-- Properties of _+_\n\n-- Associativity of addition. \nassoc-+ : ∀ (x y z : 𝔾) -> ((x + y) + z) ≡ (x + (y + z))\nassoc-+ x@(a + b i) y@(c + d i) z@(e + f i) = begin\n (((a + b i) + (c + d i)) + (e + f i)) ≡⟨ refl ⟩\n ((a + c + e) + (b + d + f) i) ≡⟨ cong₂ _+_i (+-assoc a c e) (+-assoc b d f) ⟩\n ((a + (c + e)) + (b + (d + f)) i) ≡⟨ refl ⟩\n (x + (y + z)) ∎\n\n-- Left additive identity.\nleftId-+ : ∀ (x : 𝔾) -> 0# + x ≡ x\nleftId-+ x@(a + b i) = begin\n (0# + 0# i) + (a + b i) ≡⟨ refl ⟩\n -- cannot parse if remove the outer layer parenthese.\n ((0# + a) + (0# + b) i) ≡⟨ cong₂ _+_i (+-identityˡ a) (+-identityˡ b) ⟩\n (a + b i) ∎ \n\n-- Right additive identity.\nrightId-+ : ∀ (x : 𝔾) -> (x + 0#) ≡ x\nrightId-+ x@(a + b i) = begin\n (a + b i) + (0# + 0# i) ≡⟨ refl ⟩\n ((a + 0#) + (b + 0#) i) ≡⟨ cong₂ _+_i (+-identityʳ a) (+-identityʳ b) ⟩\n (a + b i) ∎ \n\n-- Left additive inverse. \nleftInv-+ : ∀ (x : 𝔾) -> (- x) + x ≡ 0#\nleftInv-+ x@(a + b i) = cong₂ _+_i (+-inverseˡ a) (+-inverseˡ b) \n\n-- Right additive inverse. \nrightInv-+ : ∀ (x : 𝔾) -> x + (- x) ≡ 0#\nrightInv-+ x@(a + b i) = cong₂ _+_i (+-inverseʳ a) (+-inverseʳ b)\n\n-- Addition is commutative. \ncomm-+ : (x y : 𝔾) → (x + y) ≡ (y + x)\ncomm-+ x@(a + b i) y@(c + d i) = cong₂ _+_i (+-comm a c) (+-comm b d) \n\n-- ----------------------------------------------------------------------\n-- Structures for addition \n\n+-isMagma : IsMagma _+_\n+-isMagma = record\n { isEquivalence = isEquivalence\n ; ∙-cong = cong₂ _+_\n }\n\n+-isSemigroup : IsSemigroup _+_\n+-isSemigroup = record\n { isMagma = +-isMagma\n ; assoc = assoc-+\n }\n\n+-isCommutativeSemigroup : IsCommutativeSemigroup _+_\n+-isCommutativeSemigroup = record\n { isSemigroup = +-isSemigroup\n ; comm = comm-+\n }\n\n+-0-isMonoid : IsMonoid _+_ 0#\n+-0-isMonoid = record\n { isSemigroup = +-isSemigroup\n ; identity = leftId-+ , rightId-+ \n }\n\n+-0-isCommutativeMonoid : IsCommutativeMonoid _+_ 0#\n+-0-isCommutativeMonoid = record\n { isMonoid = +-0-isMonoid\n ; comm = comm-+\n }\n\n+-0-isGroup : IsGroup _+_ 0# (-_)\n+-0-isGroup = record\n { isMonoid = +-0-isMonoid\n ; inverse = leftInv-+ , rightInv-+ \n ; ⁻¹-cong = cong (-_)\n }\n\n+-isAbelianGroup : IsAbelianGroup _+_ 0# (-_)\n+-isAbelianGroup = record\n { isGroup = +-0-isGroup\n ; comm = comm-+\n }\n\n-- ----------------------------------------------------------------------\n-- Bundles for addition \n\n+-magma : Magma 0ℓ 0ℓ\n+-magma = record\n { isMagma = +-isMagma\n }\n\n+-semigroup : Semigroup 0ℓ 0ℓ\n+-semigroup = record\n { isSemigroup = +-isSemigroup\n }\n\n+-commutativeSemigroup : CommutativeSemigroup 0ℓ 0ℓ\n+-commutativeSemigroup = record\n { isCommutativeSemigroup = +-isCommutativeSemigroup\n }\n\n+-0-monoid : Monoid 0ℓ 0ℓ\n+-0-monoid = record\n { isMonoid = +-0-isMonoid\n }\n\n+-0-commutativeMonoid : CommutativeMonoid 0ℓ 0ℓ\n+-0-commutativeMonoid = record\n { isCommutativeMonoid = +-0-isCommutativeMonoid\n }\n\n+-0-abelianGroup : AbelianGroup 0ℓ 0ℓ\n+-0-abelianGroup = record\n { isAbelianGroup = +-isAbelianGroup\n }\n\n\n-- ----------------------------------------------------------------------\n-- Properties of multiplication \n\n-- Associativity of multiplication.\nassoc-* : ∀ (x y z : 𝔾) -> ((x * y) * z) ≡ (x * (y * z))\nassoc-* x@(a + b i) y@(c + d i) z@(e + f i) = begin\n (((a + b i) * (c + d i)) * (e + f i)) ≡⟨ refl ⟩\n ((a * c - b * d) + (a * d + b * c) i) * (e + f i) ≡⟨ refl ⟩\n ((a * c - b * d) * e - (a * d + b * c) * f) + ((a * c - b * d) * f + (a * d + b * c) * e) i ≡⟨ cong₂ _+_i (let _*_ = _:*_ in let _+_ = _:+_ in let _-_ = _:-_ in (solve 6 (\\ a b c d e f -> (((a * c) - (b * d)) * e) - (((a * d) + (b * c)) * f) := (a * ((c * e) - (d * f))) - (b * ((c * f) + (d * e)))) refl a b c d e f)) ((let _*_ = _:*_ in let _+_ = _:+_ in let _-_ = _:-_ in\n (solve 6 (\\ a b c d e f -> (((a * c) - (b * d)) * f) + (((a * d) + (b * c)) * e) := (a * ((c * f) + (d * e))) + (b * ((c * e) - (d * f)))) refl a b c d e f))) ⟩\n ((a * (c * e - d * f) - b * (c * f + d * e) ) + (a * (c * f + d * e) + b * (c * e - d * f)) i ) ≡⟨ refl ⟩\n ((a + b i) * ((c * e - d * f) + (c * f + d * e) i) ) ≡⟨ refl ⟩\n (x * (y * z)) ∎ \n\n-- Left multiplicative identity.\nleftId-* : ∀ (x : 𝔾) -> (1# * x) ≡ x\nleftId-* x@(a + b i) = begin\n (1# + 0# i) * (a + b i) ≡⟨ refl ⟩\n ((1# * a - 0# * b) + (1# * b + 0# * a) i) ≡⟨ cong₂ _+_i (let _*_ = _:*_ in let _-_ = _:-_ in (solve 2 (\\ a b -> (con 1# * a) - (con 0# * b) := con 1# * a) refl a b)) ( (let _*_ = _:*_ in let _+_ = _:+_ in (solve 2 (\\ a b -> (con 1# * b) + (con 0# * a) := con 1# * b) refl a b))) ⟩\n ((1# * a) + (1# * b) i) ≡⟨ cong₂ _+_i (*-identityˡ a) (*-identityˡ b) ⟩\n (a + b i) ∎ \n\n-- Right multiplicative identity.\nrightId-* : ∀ (x : 𝔾) -> (x * 1#) ≡ x\nrightId-* x@(a + b i) = begin\n (a + b i) * (1# + 0# i) ≡⟨ refl ⟩\n (( a * 1# - b * 0#) + ( a * 0# + b * 1# ) i) ≡⟨ cong₂ _+_i ((let _*_ = _:*_ in let _-_ = _:-_ in (solve 2 (\\ a b -> (a * con 1# ) - (b * con 0# ) := con 1# * a) refl a b))) ((let _*_ = _:*_ in let _+_ = _:+_ in (solve 2 (\\ a b -> (a * con 0#) + (b * con 1# ) := con 1# * b) refl a b))) ⟩\n ((1# * a) + (1# * b) i) ≡⟨ cong₂ _+_i (*-identityˡ a) (*-identityˡ b) ⟩\n (a + b i) ∎ \n\n-- Zero leftly times any number is zero. \nleftZero : ∀ x -> (0# + 0# i) * x ≡ (0# + 0# i)\nleftZero x@(a + b i) = begin\n (0# + 0# i) * (a + b i) ≡⟨ refl ⟩\n (0# * a - 0# * b) + (0# * a - 0# * b) i ≡⟨ refl ⟩\n 0# + 0# i ∎ \n\n-- Zero rightly times any number is zero. \nrightZero : ∀ x -> x * (0# + 0# i) ≡ (0# + 0# i)\nrightZero x@(a + b i) = begin\n (a + b i) * (0# + 0# i) ≡⟨ refl ⟩\n (a * 0# - b * 0# ) + (a * 0# + b * 0# ) i ≡⟨ cong₂ _+_i ((let _*_ = _:*_ in let _+_ = _:+_ in let _-_ = _:-_ in (solve 2 (\\ a b -> (a * con 0#) - (b * con 0# ) := con 0#) refl a b))) ((let _*_ = _:*_ in let _+_ = _:+_ in let _-_ = _:-_ in (solve 2 (\\ a b -> (a * con 0#) + (b * con 0# ) := con 0#) refl a b))) ⟩\n 0# + 0# i ∎ \n\n-- Left multiplication is distributive over addition. \n*-DistributesOver-+ˡ : ∀ (x y z : 𝔾) -> (x * (y + z)) ≡ ((x * y) + (x * z))\n*-DistributesOver-+ˡ x@(a + b i) y@(c + d i) z@(e + f i) = begin\n x * (y + z) ≡⟨ refl ⟩\n (a * (c + e) - b * (d + f) + (a * (d + f) + b * (c + e)) i) ≡⟨ cong₂ _+_i ((let _*_ = _:*_ in let _+_ = _:+_ in let _-_ = _:-_ in (solve 6 (\\ a b c d e f -> (a * (c + e)) - (b * (d + f) ) := ((a * c) - (b * d)) + ((a * e) - (b * f)) ) refl a b c d e f))) ((let _*_ = _:*_ in let _+_ = _:+_ in let _-_ = _:-_ in (solve 6 (\\ a b c d e f -> (a * (d + f)) + (b * (c + e) ) := ((a * d) + (b * c)) + ((a * f) + (b * e)) ) refl a b c d e f))) ⟩\n ((a * c - b * d) + (a * e - b * f)) + ((a * d + b * c) + (a * f + b * e)) i ≡⟨ refl ⟩ \n ((x * y) + (x * z)) ∎ \n\n-- Right multiplication is distributive over addition. \n*-DistributesOver-+ʳ : ∀ (x y z : 𝔾) -> ((y + z) * x) ≡ (y * x) + (z * x)\n*-DistributesOver-+ʳ x@(a + b i) y@(c + d i) z@(e + f i) = begin\n (y + z) * x ≡⟨ refl ⟩\n ((c + e) * a - (d + f) * b + ( (c + e) * b + (d + f) * a ) i) ≡⟨ cong₂ _+_i ((let _*_ = _:*_ in let _+_ = _:+_ in let _-_ = _:-_ in (solve 6 (\\ a b c d e f -> ((c + e) * a) - ((d + f) * b ) := ((c * a ) - (d * b)) + ((e * a) - (f * b )) ) refl a b c d e f))) ((let _*_ = _:*_ in let _+_ = _:+_ in let _-_ = _:-_ in (solve 6 (\\ a b c d e f -> ((c + e) * b) + ((d + f) * a ) := ((c * b ) + (d * a)) + ((e * b) + (f * a )) ) refl a b c d e f))) ⟩\n ((c * a - d * b) + (e * a - f * b)) + ((c * b + d * a ) + (e * b + f * a )) i ≡⟨ refl ⟩ \n ((y * x) + (z * x)) ∎ \n\n\n-- Multiplicaton is commutative. \ncomm-* : ∀ (x y : 𝔾) -> x * y ≡ y * x\ncomm-* x@(a + b i) y@(c + d i) = begin\n x * y ≡⟨ refl ⟩\n (a * c - b * d) + (a * d + b * c) i ≡⟨ cong₂ _+_i ((let _*_ = _:*_ in let _+_ = _:+_ in let _-_ = _:-_ in (solve 4 (\\ a b c d -> (a * c) - (b * d) := (c * a ) - (d * b)) refl a b c d))) ((let _*_ = _:*_ in let _+_ = _:+_ in let _-_ = _:-_ in (solve 4 (\\ a b c d -> (a * d) + (b * c) := (c * b) + (d * a)) refl a b c d))) ⟩\n (c * a - d * b) + (c * b + d * a) i ≡⟨ refl ⟩ \n (y * x) ∎ \n\n\n-- ----------------------------------------------------------------------\n-- Structures for multiplication\n\n*-isMagma : IsMagma _*_\n*-isMagma = record\n { isEquivalence = isEquivalence\n ; ∙-cong = cong₂ _*_\n }\n\n*-isSemigroup : IsSemigroup _*_\n*-isSemigroup = record\n { isMagma = *-isMagma\n ; assoc = assoc-*\n }\n\n*-isCommutativeSemigroup : IsCommutativeSemigroup _*_\n*-isCommutativeSemigroup = record\n { isSemigroup = *-isSemigroup\n ; comm = comm-*\n }\n\n*-1-isMonoid : IsMonoid _*_ 1#\n*-1-isMonoid = record\n { isSemigroup = *-isSemigroup\n ; identity = leftId-* , rightId-* \n }\n\n*-1-isCommutativeMonoid : IsCommutativeMonoid _*_ 1#\n*-1-isCommutativeMonoid = record\n { isMonoid = *-1-isMonoid\n ; comm = comm-*\n }\n\n-- ----------------------------------------------------------------------\n-- Structures for multiplication and addition\n\n+-*-isSemiring : IsSemiring _+_ _*_ 0# 1#\n+-*-isSemiring = record\n { isSemiringWithoutAnnihilatingZero = record\n { +-isCommutativeMonoid = +-0-isCommutativeMonoid\n ; *-isMonoid = *-1-isMonoid\n ; distrib = *-DistributesOver-+ˡ , *-DistributesOver-+ʳ \n }\n ; zero = leftZero , rightZero \n }\n\n+-*-isCommutativeSemiring : IsCommutativeSemiring _+_ _*_ 0# 1#\n+-*-isCommutativeSemiring = record\n { isSemiring = +-*-isSemiring\n ; *-comm = comm-*\n }\n\n+-*-isRing : IsRing _+_ _*_ -_ 0# 1#\n+-*-isRing = record\n { +-isAbelianGroup = +-isAbelianGroup\n ; *-isMonoid = *-1-isMonoid\n ; distrib = *-DistributesOver-+ˡ , *-DistributesOver-+ʳ\n ; zero = leftZero , rightZero\n }\n\n+-*-isCommutativeRing : IsCommutativeRing _+_ _*_ -_ 0# 1#\n+-*-isCommutativeRing = record\n { isRing = +-*-isRing\n ; *-comm = comm-*\n }\n\n------------------------------------------------------------------------\n-- Bundles for multiplication \n\n*-magma : Magma 0ℓ 0ℓ\n*-magma = record\n { isMagma = *-isMagma\n }\n\n*-semigroup : Semigroup 0ℓ 0ℓ\n*-semigroup = record\n { isSemigroup = *-isSemigroup\n }\n\n*-commutativeSemigroup : CommutativeSemigroup 0ℓ 0ℓ\n*-commutativeSemigroup = record\n { isCommutativeSemigroup = *-isCommutativeSemigroup\n }\n\n*-1-monoid : Monoid 0ℓ 0ℓ\n*-1-monoid = record\n { isMonoid = *-1-isMonoid\n }\n\n*-1-commutativeMonoid : CommutativeMonoid 0ℓ 0ℓ\n*-1-commutativeMonoid = record\n { isCommutativeMonoid = *-1-isCommutativeMonoid\n }\n\n------------------------------------------------------------------------\n-- Bundles for multiplication and addition\n\n+-*-semiring : Semiring 0ℓ 0ℓ\n+-*-semiring = record\n { isSemiring = +-*-isSemiring\n }\n\n+-*-commutativeSemiring : CommutativeSemiring 0ℓ 0ℓ\n+-*-commutativeSemiring = record\n { isCommutativeSemiring = +-*-isCommutativeSemiring\n }\n\n+-*-ring : B.Ring 0ℓ 0ℓ\n+-*-ring = record\n { isRing = +-*-isRing\n }\n\n+-*-commutativeRing : CommutativeRing 0ℓ 0ℓ\n+-*-commutativeRing = record\n { isCommutativeRing = +-*-isCommutativeRing\n }\n\n\n-- ----------------------------------------------------------------------\n-- Properties of Re and Im\n\n-- Re x + Im x i = x\nRe+Im*i : ∀ {x} -> Re x + Im x i ≡ x\nRe+Im*i {x + x₁ i} = refl\n\n-- Re (y * y ᶜ) ≡ + rank y \nRe[yyᶜ]=rank : ∀ {y : 𝔾} -> Re (y * y ᶜ) ≡ + rank y \nRe[yyᶜ]=rank {y@(a + b i)} = sym $ begin\n + (rank y) ≡⟨ refl ⟩\n + (rank (a + b i)) ≡⟨ refl ⟩\n + ∣ a * a + b * b ∣ ≡⟨ cong +_ (tri-eq' a b) ⟩\n + (∣ a * a ∣ + ∣ b * b ∣) ≡⟨ refl ⟩\n + ∣ a * a ∣ + + ∣ b * b ∣ ≡⟨ cong₂ _+_ (+∣a*a∣=a*a a) (+∣a*a∣=a*a b) ⟩\n a * a + b * b ≡⟨ solve 2 (\\ a b -> a :* a :+ b :* b := a :* a :- b :* (:- b)) refl a b ⟩\n a * a - b * (- b) ≡⟨ refl ⟩\n Re ((a * a - b * (- b)) + 0ℤ i) ≡⟨ refl ⟩\n Re ((a * a - b * (- b)) + (a * (- b) + b * a) i) ≡⟨ refl ⟩\n Re (y * y ᶜ) ∎\n\n-- Im y * y ᶜ = 0\nIm[yyᶜ]=0 : ∀ {y : 𝔾} -> Im (y * y ᶜ) ≡ 0#\nIm[yyᶜ]=0 {y@(a + b i)} = begin\n Im (y * y ᶜ) ≡⟨ refl ⟩\n Im ((a * a - b * (- b)) + (a * (- b) + b * a) i) ≡⟨ refl ⟩\n a * (- b) + b * a ≡⟨ solve 2 (\\ a b -> a :* (:- b) :+ b :* a := con 0#) refl a b ⟩\n 0# ∎\n\n\n-- ----------------------------------------------------------------------\n-- Properties of conjugation\n\n-- Conjugation is injective.\nᶜ-injective : ∀ {x} -> x ᶜ ≡ 0# -> x ≡ 0#\nᶜ-injective {+ 0 + + 0 i} eq = refl\n\n-- y * y ᶜ = rank y\ny*yᶜ=rank : ∀ {y : 𝔾} -> y * y ᶜ ≡ rank y +0i\ny*yᶜ=rank {y@(a + b i)} = begin\n y * y ᶜ ≡⟨ sym $ Re+Im*i ⟩\n Re (y * y ᶜ) + Im (y * y ᶜ) i ≡⟨ cong₂ _+_i (Re[yyᶜ]=rank {y}) (Im[yyᶜ]=0 {y}) ⟩\n + rank y + 0# i ∎\n\n\n-- ----------------------------------------------------------------------\n-- Properties of rank\n\n-- rank on 𝔾 is homomorphic in multiplication.\nrank-*-commute : 𝔾toℕ.Homomorphic₂ rank _*_ Nat._*_\nrank-*-commute x@(a + b i) y@(c + d i) = claim\n where\n claim : rank (x * y) ≡ rank x * rank y\n claim = begin\n rank (x * y) ≡⟨ refl ⟩ \n rank ((a * c - b * d) + (a * d + b * c) i) ≡⟨ refl ⟩\n ∣ (a * c - b * d)^2 + (a * d + b * c)^2 ∣ ≡⟨ cong ∣_∣ (solve 4 (λ a b c d → (a :* c :- b :* d) :* (a :* c :- b :* d) :+ (a :* d :+ b :* c) :* (a :* d :+ b :* c) := (a :* a :+ b :* b) :* (c :* c :+ d :* d)) refl a b c d) ⟩\n ∣ (a ^2 + b ^2) * (c ^2 + d ^2) ∣ ≡⟨ IntP.abs-*-commute ((a ^2 + b ^2)) ((c ^2 + d ^2)) ⟩\n ∣ a ^2 + b ^2 ∣ * ∣ c ^2 + d ^2 ∣ ≡⟨ refl ⟩\n rank x * rank y ∎\n\nrank=∣Re[y*yᶜ]∣ : ∀ (x : 𝔾) -> rank x ≡ ∣ Re (x * x ᶜ) ∣\nrank=∣Re[y*yᶜ]∣ x@(a + b i) = begin\n rank (a + b i) ≡⟨ refl ⟩\n ∣ a * a + b * b ∣ ≡⟨ cong ∣_∣ (solve 2 (λ a b → a :* a :+ b :* b := a :* a :- b :* (:- b)) refl a b) ⟩\n ∣ a * a - b * (- b) ∣ ≡⟨ refl ⟩\n ∣ Re ((a * a - b * (- b)) + 0ℤ i) ∣ ≡⟨ refl ⟩\n ∣ Re ((a * a - b * (- b)) + (a * (- b) + b * a) i) ∣ ≡⟨ refl ⟩\n ∣ Re (x * x ᶜ) ∣ ∎\n\n-- rank y + 0 i = y * y ᶜ\nrank+0i=y*yᶜ : ∀ {y : 𝔾} -> (rank y) +0i ≡ y * y ᶜ \nrank+0i=y*yᶜ {y} = sym $ begin\n y * y ᶜ ≡⟨ sym $ Re+Im*i ⟩\n Re (y * y ᶜ) + Im (y * y ᶜ) i ≡⟨ cong₂ _+_i (Re[yyᶜ]=rank {y}) (Im[yyᶜ]=0 {y}) ⟩\n + rank y + 0# i ∎\n\n-- ----------------------------------------------------------------------\n-- Injection preserves SemiRing Structure\n\n+0i-+-commute : ℕto𝔾.Homomorphic₂ _+0i Nat._+_ _+_\n+0i-+-commute a b = refl \n\n+0i-*-commute : ℕto𝔾.Homomorphic₂ _+0i Nat._*_ _*_\n+0i-*-commute a b rewrite NatP.*-zeroˡ a | NatP.*-zeroˡ b | NatP.*-zeroʳ a | NatP.*-zeroʳ b | sym (IntP.pos-distrib-* a b) | IntP.+-identityʳ (+ a * + b) = refl\n\n0+0i=0 : 0 +0i ≡ 0#\n0+0i=0 = refl \n\n1+0i=1 : 1 +0i ≡ 1#\n1+0i=1 = refl \n\n\n\n-- ----------------------------------------------------------------------\n-- Domain Structrue on 𝔾 \n\n-- Some auxillaries.\n\n-- Zero is unique. \nunique0 : ∀ {a b} -> (a + b i) ≡ 0# -> a ≡ 0ℤ × b ≡ 0ℤ\nunique0 {.+0} {.+0} refl = refl , refl\n\n-- Conversely, if a + bi ≠ 0 then at least one of a and b is not zero.\nunique0' : ∀ {a b} -> ¬ (a + b i) ≡ 0# -> ¬ a ≡ 0ℤ ⊎ ¬ b ≡ 0ℤ\nunique0' {a@(+_ zero)} {b@(+_ zero)} neq with neq refl\n... | ()\nunique0' {+_ zero} {+[1+ n ]} neq = inj₂ (λ ())\nunique0' {+_ zero} { -[1+_] n} neq = inj₂ (λ ())\nunique0' {+[1+ n ]} {b} neq = inj₁ (λ ())\nunique0' { -[1+_] n} {b} neq = inj₁ (λ ())\n\n\n-- Make an equation onesided.\noneside : ∀ {a b : 𝔾} -> a ≡ b -> a - b ≡ 0#\noneside {a} {b} eq rewrite eq = rightInv-+ b \n\n-- Make an equation twosided. \ntwoside : ∀ {a b : 𝔾} -> a - b ≡ 0# -> a ≡ b\ntwoside {a} {b} eq = sym $ -‿injective $ +-inverseʳ-unique a (- b) eq\n where\n open import Algebra.Properties.Ring +-*-ring\n\n-- Make an equation twosided, ℤ version.\ntwosideℤ : ∀ {a b : ℤ} -> a - b ≡ 0# -> a ≡ b\ntwosideℤ {a} {b} eq = sym (PRI.-‿injective (PRI.+-inverseʳ-unique a (- b) eq ))\n where\n import Algebra.Properties.Ring IntP.+-*-ring as PRI\n\n\n-- We show zero divisor is necessary zero (equivalent to left or right\n-- cancellation in a commutative ring), which makes 𝔾 an integral\n-- domain.\nzero-divisor-is-zero : ∀ {x y : 𝔾} -> x * y ≡ 0# -> ¬ x ≡ 0# -> y ≡ 0#\nzero-divisor-is-zero {x@(a + b i)} {y@(c + d i)} eq neq = cong₂ _+_i (proj₁ step6) (proj₂ step6)\n where\n open ≡-Reasoning\n open IS.+-*-Solver\n -- 0 = x * y = (a * c - b * d) + (a * d + b * c) i, together with\n -- c + d i ≠ 0, we can derive a = 0 and b = 0, contradicting x ≠\n -- 0. The proof idea is:\n --\n -- step0 : a * c - b * d = 0 and a * d + b * c = 0\n -- step1 : a * c * c - b * d * c = 0\n -- step2 : a * d * d + b * c * d = 0\n -- s1,s2 ⇒ step1&2 : a * (c * c + d * d) = 0\n -- step3 : a * c * d - b * d * d = 0\n -- step4 : a * d * c + b * c * c = 0\n -- s3,s4 ⇒ step3&4 : b * (c * c + d * d) = 0\n -- one of a b nonzero ⇒ step5 : (c * c + d * d) = 0\n -- step5 ⇒ step6 : c = 0 and d = 0\n\n -- step0 : a * c - b * d = 0 and a * d + b * c = 0\n step0 : a * c - b * d ≡ 0# × a * d + b * c ≡ 0#\n step0 = unique0 eq\n \n -- step1 : a * c * c - b * d * c = 0\n step1 : a * c * c - b * d * c ≡ 0#\n step1 = begin\n a * c * c - b * d * c ≡⟨ solve 4 (\\ a b c d -> a :* c :* c :- b :* d :* c := (a :* c :- b :* d) :* c) refl a b c d ⟩\n (a * c - b * d) * c ≡⟨ cong (_* c) (proj₁ step0) ⟩\n 0ℤ * c ≡⟨ refl ⟩\n 0ℤ ∎\n\n -- step2 : a * d * d + b * c * d = 0\n step2 : a * d * d + b * c * d ≡ 0#\n step2 = begin\n a * d * d + b * c * d ≡⟨ solve 4 (\\ a b c d -> a :* d :* d :+ b :* c :* d := (a :* d :+ b :* c) :* d) refl a b c d ⟩\n (a * d + (b * c)) * d ≡⟨ cong (_* d) (proj₂ step0) ⟩\n 0ℤ * d ≡⟨ refl ⟩\n 0ℤ ∎ \n\n -- c1,c2 ⇒ step1&2 : a * (c * c + d * d) = 0\n step1&2 : a * (c * c + d * d) ≡ 0#\n step1&2 = begin\n a * (c * c + d * d) ≡⟨ solve 4 (\\ a b c d -> a :* (c :* c :+ d :* d) := (a :* c :* c :- b :* d :* c) :+ (a :* d :* d :+ b :* c :* d) ) refl a b c d ⟩\n (a * c * c - b * d * c) + (a * d * d + b * c * d) ≡⟨ cong₂ _+_ step1 step2 ⟩\n 0# ∎ \n\n -- step3 : a * c * d - b * d * d = 0\n step3 : a * c * d - b * d * d ≡ 0#\n step3 = begin\n a * c * d - b * d * d ≡⟨ solve 4 (\\ a b c d -> a :* c :* d :- b :* d :* d := (a :* c :- b :* d) :* d) refl a b c d ⟩\n (a * c - b * d) * d ≡⟨ cong (_* d) (proj₁ step0) ⟩\n 0ℤ * d ≡⟨ refl ⟩\n 0ℤ ∎\n\n -- step4 : a * d * c + b * c * c = 0\n step4 : a * d * c + b * c * c ≡ 0#\n step4 = begin\n a * d * c + b * c * c ≡⟨ solve 4 (\\ a b c d -> a :* d :* c :+ b :* c :* c := (a :* d :+ b :* c) :* c) refl a b c d ⟩\n (a * d + (b * c)) * c ≡⟨ cong (_* c) (proj₂ step0) ⟩\n 0ℤ * c ≡⟨ refl ⟩\n 0ℤ ∎ \n\n -- s3,s4 ⇒ step3&4 : b * (c * c + d * d) = 0\n step3&4 : b * (c * c + d * d) ≡ 0#\n step3&4 = begin\n b * (c * c + d * d) ≡⟨ solve 4 (\\ a b c d -> b :* (c :* c :+ d :* d) := :- (a :* c :* d :- b :* d :* d) :+ (a :* d :* c :+ b :* c :* c) ) refl a b c d ⟩\n - (a * c * d - b * d * d) + (a * d * c + b * c * c) ≡⟨ cong₂ (\\x y -> (- x) + y) step3 step4 ⟩\n 0# ∎\n\n -- one of a b nonzero ⇒ step5 : (c * c + d * d) = 0\n -- some auxillary lemma.\n aux : ∀ {a : ℤ} -> a * 0# ≡ 0#\n aux {a} rewrite IntP.*-comm a 0# = refl\n\n step1&2' : a * (c * c + d * d) ≡ a * 0#\n step1&2' rewrite aux {a} = step1&2\n \n step3&4' : b * (c * c + d * d) ≡ b * 0#\n step3&4' rewrite aux {b} = step3&4\n\n\n step5 : c * c + d * d ≡ 0#\n step5 = ⊎-elim (λ x₁ → IntP.*-cancelˡ-≡ a (c * c + d * d) 0# {{myins2 {a} {x₁}}} step1&2') (λ x₁ → IntP.*-cancelˡ-≡ b (c * c + d * d) 0# {{myins2 {b} {x₁}}} step3&4') (unique0' neq)\n where\n -- We need a translation from non-equality to NonZero predicate.\n open import Agda.Builtin.Unit\n myins2 : ∀ {x : ℤ} -> {n0 : ¬ x ≡ 0ℤ} -> NonZero x\n myins2 {+_ zero} {n0} with n0 refl\n ... | ()\n myins2 {+[1+ n ]} {n0} = record { nonZero = tt }\n myins2 { -[1+_] n} {n0} = record { nonZero = tt }\n\n -- step5 ⇒ step6 : c = 0 and d = 0\n step6 : c ≡ 0# × d ≡ 0#\n step6 = aa+bb=0⇒a=0×b=0 step5 \n\n\n-- Almost left cancellative.\n*-alc-𝔾 : AlmostLeftCancellative 0𝔾 _*_\n*-alc-𝔾 {x@(a + b i)} y@(c + d i) z@(e + f i) neq eq = y=z\n where\n onesided-eq : x * (y + (- z)) ≡ 0#\n onesided-eq = begin\n x * (y + (- z)) ≡⟨ *-DistributesOver-+ˡ x y (- z) ⟩\n x * y + x * (- z) ≡⟨ refl ⟩ \n x * y + (a + b i) * (- e + - f i) ≡⟨ cong (λ t → x * y + t) refl ⟩\n x * y + ((a * - e - b * - f ) + (a * - f + b * - e) i) ≡⟨ cong (λ t → x * y + t) (cong₂ _+_i (solve 4 (\\a e b f -> a :* :- e :- b :* :- f := :- (a :* e :- b :* f)) refl a e b f) (solve 4 (\\a e b f -> a :* :- f :+ b :* :- e := :- (a :* f :+ b :* e)) refl a e b f)) ⟩\n x * y + (- (a * e - b * f) + - (a * f + b * e) i) ≡⟨ cong (λ t → x * y + t) refl ⟩\n x * y + (- (x * z)) ≡⟨ oneside eq ⟩\n 0# ∎\n where\n open ≡-Reasoning\n open IS.+-*-Solver\n\n y-z=0 : (y + (- z)) ≡ 0#\n y-z=0 = zero-divisor-is-zero onesided-eq neq\n\n y=z : y ≡ z\n y=z = twoside y-z=0\n\n\n-- Multiplication commutativity plus left cancellative implies 𝔾 is an\n-- commutative Domain. Knowing this, we can show e.g.\ny≠0⇒y*yᶜ≠0 : ∀ {y} -> ¬ y ≡ 0# -> ¬ y * y ᶜ ≡ 0#\ny≠0⇒y*yᶜ≠0 {y} n0 eq = ⊥-elim (n0' e0)\n where\n open import Data.Empty\n n0' : ¬ y ᶜ ≡ 0#\n n0' x with n0 (ᶜ-injective {y} x)\n ... | ()\n\n eq' : y * y ᶜ ≡ y * 0#\n eq' = begin \n y * y ᶜ ≡⟨ eq ⟩\n 0# ≡⟨ sym $ rightZero y ⟩\n y * 0# ∎\n where\n open IS.+-*-Solver\n open ≡-Reasoning\n\n e0 : y ᶜ ≡ 0#\n e0 = *-alc-𝔾 {y} (y ᶜ) 0# n0 eq'\n\n\ny≠0#⇒rank≠0 : ∀ {y : 𝔾} -> ¬ y ≡ 0# -> ¬ rank y ≡ 0#\ny≠0#⇒rank≠0 {y} n0 = rank≠0\n where\n open import Data.Empty\n y*yᶜ≠0 : ¬ y * y ᶜ ≡ 0#\n y*yᶜ≠0 = y≠0⇒y*yᶜ≠0 n0\n rank≠0 : ¬ rank y ≡ 0#\n rank≠0 e = ⊥-elim (y*yᶜ≠0 y*yᶜ=0) \n where\n y*yᶜ=0 : y * y ᶜ ≡ 0#\n y*yᶜ=0 = begin \n y * y ᶜ ≡⟨ sym $ Re+Im*i ⟩\n Re (y * y ᶜ) + Im (y * y ᶜ) i ≡⟨ cong₂ _+_i (Re[yyᶜ]=rank {y}) refl ⟩\n + rank y + Im (y * y ᶜ) i ≡⟨ cong₂ _+_i (cong +_ e) (Im[yyᶜ]=0 {y}) ⟩\n 0# ∎\n where\n open IS.+-*-Solver\n open ≡-Reasoning\n\n\nrank=0⇒y=0 : ∀ {y : 𝔾} -> rank y ≡ 0# -> y ≡ 0# \nrank=0⇒y=0 {y@(a + b i)} eq0 = y=0\n where\n eq0' : a * a + b * b ≡ 0#\n eq0' = IntP.∣i∣≡0⇒i≡0 eq0\n s1 : a ≡ 0ℤ × b ≡ 0ℤ\n s1 = aa+bb=0⇒a=0×b=0 eq0'\n y=0 : y ≡ 0#\n y=0 with s1\n ... | fst , snd rewrite fst | snd = refl\n\n\nrank≥1 : ∀ {y : 𝔾} -> ¬ y ≡ 0# -> 1# ≤ rank y\nrank≥1 {y} n0 = aux (rank y) (y≠0#⇒rank≠0 {y} n0)\n where\n aux : ∀ (n : ℕ) -> ¬ n ≡ 0 -> 1 ≤ n\n aux zero n0' with n0' refl\n ... | ()\n aux (suc n) n0' = Nat.s≤s Nat.z≤n\n\n\nranky<1⇒y=0 : ∀ (y : 𝔾) -> rank y < 1# -> y ≡ 0#\nranky<1⇒y=0 y r = rank=0⇒y=0 {y} ranky=0\n where\n aux : ∀ (n : ℕ) -> n < 1 -> n ≡ 0\n aux .zero (Nat.s≤s Nat.z≤n) = refl\n\n ranky=0 : rank y ≡ 0\n ranky=0 = aux (rank y) r\n\n \n-- ----------------------------------------------------------------------\n-- Properties of NonZero\n\n\n\n\n", "meta": {"hexsha": "1c186540eede2928925622247536273631451904", "size": 24950, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "GauInt/Properties.agda", "max_stars_repo_name": "onestruggler/EucDomain", "max_stars_repo_head_hexsha": "7e268e8354065fde734c9c2d9998d2cfd4a21f71", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "GauInt/Properties.agda", "max_issues_repo_name": "onestruggler/EucDomain", "max_issues_repo_head_hexsha": "7e268e8354065fde734c9c2d9998d2cfd4a21f71", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "GauInt/Properties.agda", "max_forks_repo_name": "onestruggler/EucDomain", "max_forks_repo_head_hexsha": "7e268e8354065fde734c9c2d9998d2cfd4a21f71", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.1408450704, "max_line_length": 446, "alphanum_fraction": 0.448256513, "num_tokens": 11276, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950907764119, "lm_q2_score": 0.721743200312399, "lm_q1q2_score": 0.60907554354489}} {"text": "\nmodule Prelude.Smashed where\n\nopen import Prelude.Equality\nopen import Prelude.Unit\nopen import Prelude.Empty\nopen import Prelude.Nat.Core\nopen import Prelude.Function\nopen import Prelude.Ord\n\nrecord Smashed {a} (A : Set a) : Set a where\n field\n smashed : ∀ {x y : A} → x ≡ y\n\nopen Smashed {{...}} public\n{-# DISPLAY Smashed.smashed _ = smashed #-}\n\ninstance\n Smash⊤ : Smashed ⊤\n smashed {{Smash⊤}} = refl\n\n Smash⊥ : Smashed ⊥\n smashed {{Smash⊥}} {}\n\n Smash≡ : ∀ {a} {A : Set a} {a b : A} → Smashed (a ≡ b)\n smashed {{Smash≡}} {x = refl} {refl} = refl\n\n-- Can't be instance, since this would interfere with the ⊤ and ⊥ instances.\nSmashNonZero : ∀ {n : Nat} → Smashed (NonZero n)\nSmashNonZero {zero} = it\nSmashNonZero {suc n} = it\n", "meta": {"hexsha": "7ffee0a17595991e7cb460dd51fd4fa9bac918a7", "size": 742, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Prelude/Smashed.agda", "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 111, "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_issues_repo_path": "src/Prelude/Smashed.agda", "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_forks_repo_path": "src/Prelude/Smashed.agda", "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "avg_line_length": 23.1875, "max_line_length": 76, "alphanum_fraction": 0.6522911051, "num_tokens": 252, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467770088163, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.6089339670938981}} {"text": "{-# OPTIONS --without-K #-}\nmodule Sigma {a b} {A : Set a} {B : A → Set b} where\n\nopen import Equivalence\nopen import Types\n\n-- Projections for the positive sigma.\nπ₁′ : (p : Σ′ A B) → A\nπ₁′ p = split (λ _ → A) (λ a _ → a) p\n\nπ₂′ : (p : Σ′ A B) → B (π₁′ p)\nπ₂′ p = split (λ p → B (π₁′ p)) (λ _ b → b) p\n\n-- Induction principle for the negative sigma.\nsplit′ : ∀ {p} (P : Σ A B → Set p)\n (f : (a : A) (b : B a) → P (a , b)) → ∀ z → P z\nsplit′ P f p = f (π₁ p) (π₂ p)\n\nΣ→Σ′ : Σ A B → Σ′ A B\nΣ→Σ′ p = π₁ p , π₂ p\n\nΣ′→Σ : Σ′ A B → Σ A B\nΣ′→Σ = split _ _,_\n\nΣ≃Σ′ : Σ A B ≃ Σ′ A B\nΣ≃Σ′\n = Σ→Σ′\n , (Σ′→Σ , split\n (λ p → Σ→Σ′ (Σ′→Σ p) ≡ p)\n (λ _ _ → refl))\n , (Σ′→Σ , λ _ → refl)\n", "meta": {"hexsha": "6703383638fb6100788a370a5a1bf396a17a2eeb", "size": 686, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Sigma.agda", "max_stars_repo_name": "vituscze/HoTT-lectures", "max_stars_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Sigma.agda", "max_issues_repo_name": "vituscze/HoTT-lectures", "max_issues_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Sigma.agda", "max_forks_repo_name": "vituscze/HoTT-lectures", "max_forks_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.4375, "max_line_length": 52, "alphanum_fraction": 0.4620991254, "num_tokens": 361, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467738423874, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.6089339649006965}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Equivalence (coinhabitance)\n------------------------------------------------------------------------\n\nmodule Function.Equivalence where\n\nopen import Function using (flip)\nopen import Function.Equality as F\n using (_⟶_; _⟨$⟩_) renaming (_∘_ to _⟪∘⟫_)\nopen import Level\nopen import Relation.Binary\nimport Relation.Binary.PropositionalEquality as P\n\n-- Setoid equivalence.\n\nrecord Equivalence {f₁ f₂ t₁ t₂}\n (From : Setoid f₁ f₂) (To : Setoid t₁ t₂) :\n Set (f₁ ⊔ f₂ ⊔ t₁ ⊔ t₂) where\n field\n to : From ⟶ To\n from : To ⟶ From\n\n-- Set equivalence.\n\ninfix 3 _⇔_\n\n_⇔_ : ∀ {f t} → Set f → Set t → Set _\nFrom ⇔ To = Equivalence (P.setoid From) (P.setoid To)\n\nequivalence : ∀ {f t} {From : Set f} {To : Set t} →\n (From → To) → (To → From) → From ⇔ To\nequivalence to from = record { to = P.→-to-⟶ to; from = P.→-to-⟶ from }\n\n------------------------------------------------------------------------\n-- Map and zip\n\nmap : ∀ {f₁ f₂ t₁ t₂} {From : Setoid f₁ f₂} {To : Setoid t₁ t₂}\n {f₁′ f₂′ t₁′ t₂′}\n {From′ : Setoid f₁′ f₂′} {To′ : Setoid t₁′ t₂′} →\n ((From ⟶ To) → (From′ ⟶ To′)) →\n ((To ⟶ From) → (To′ ⟶ From′)) →\n Equivalence From To → Equivalence From′ To′\nmap t f eq = record { to = t to; from = f from }\n where open Equivalence eq\n\nzip : ∀ {f₁₁ f₂₁ t₁₁ t₂₁}\n {From₁ : Setoid f₁₁ f₂₁} {To₁ : Setoid t₁₁ t₂₁}\n {f₁₂ f₂₂ t₁₂ t₂₂}\n {From₂ : Setoid f₁₂ f₂₂} {To₂ : Setoid t₁₂ t₂₂}\n {f₁ f₂ t₁ t₂} {From : Setoid f₁ f₂} {To : Setoid t₁ t₂} →\n ((From₁ ⟶ To₁) → (From₂ ⟶ To₂) → (From ⟶ To)) →\n ((To₁ ⟶ From₁) → (To₂ ⟶ From₂) → (To ⟶ From)) →\n Equivalence From₁ To₁ → Equivalence From₂ To₂ →\n Equivalence From To\nzip t f eq₁ eq₂ =\n record { to = t (to eq₁) (to eq₂); from = f (from eq₁) (from eq₂) }\n where open Equivalence\n\n------------------------------------------------------------------------\n-- Equivalence is an equivalence relation\n\n-- Identity and composition (reflexivity and transitivity).\n\nid : ∀ {s₁ s₂} → Reflexive (Equivalence {s₁} {s₂})\nid {x = S} = record\n { to = F.id\n ; from = F.id\n }\n\ninfixr 9 _∘_\n\n_∘_ : ∀ {f₁ f₂ m₁ m₂ t₁ t₂} →\n TransFlip (Equivalence {f₁} {f₂} {m₁} {m₂})\n (Equivalence {m₁} {m₂} {t₁} {t₂})\n (Equivalence {f₁} {f₂} {t₁} {t₂})\nf ∘ g = record\n { to = to f ⟪∘⟫ to g\n ; from = from g ⟪∘⟫ from f\n } where open Equivalence\n\n-- Symmetry.\n\nsym : ∀ {f₁ f₂ t₁ t₂} →\n Sym (Equivalence {f₁} {f₂} {t₁} {t₂})\n (Equivalence {t₁} {t₂} {f₁} {f₂})\nsym eq = record\n { from = to\n ; to = from\n } where open Equivalence eq\n\n-- For fixed universe levels we can construct setoids.\n\nsetoid : (s₁ s₂ : Level) → Setoid (suc (s₁ ⊔ s₂)) (s₁ ⊔ s₂)\nsetoid s₁ s₂ = record\n { Carrier = Setoid s₁ s₂\n ; _≈_ = Equivalence\n ; isEquivalence = record {refl = id; sym = sym; trans = flip _∘_}\n }\n\n⇔-setoid : (ℓ : Level) → Setoid (suc ℓ) ℓ\n⇔-setoid ℓ = record\n { Carrier = Set ℓ\n ; _≈_ = _⇔_\n ; isEquivalence = record {refl = id; sym = sym; trans = flip _∘_}\n }\n", "meta": {"hexsha": "f32f8f5bfd2bf319052ad1acb4a6eee59be2e5e9", "size": 3208, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Function/Equivalence.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Function/Equivalence.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Function/Equivalence.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.7037037037, "max_line_length": 72, "alphanum_fraction": 0.5049875312, "num_tokens": 1172, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673087708699, "lm_q2_score": 0.7490872243177518, "lm_q1q2_score": 0.6089085160658118}} {"text": "module PointedFrac where\n\nopen import Data.Sum\nopen import Data.Product\n\nrecord ∙_ (A : Set) : Set where\n constructor ⇡ \n field\n focus : A\n\nopen ∙_\n\n-- Paths between values---identical to dynamic semantics?\ndata _⟷_ : {A B : Set} → ∙ A → ∙ B → Set1 where\n id : {A : Set} → (x : A) → (⇡ x) ⟷ (⇡ x)\n swap₊₁ : {A B : Set} → {x : A} → _⟷_ {A ⊎ B} {B ⊎ A} (⇡ (inj₁ x)) (⇡ (inj₂ x))\n swap₊₂ : {A B : Set} → {y : B} → _⟷_ {A ⊎ B} {B ⊎ A} (⇡ (inj₂ y)) (⇡ (inj₁ y))\n swap× : {A B : Set} → {x : A} → {y : B} ‌→ ⇡ (x , y) ⟷ ⇡ (y , x)\n -- ...and so on\n\n-- shorter arrow for a shorter definition!\ndata _↔_ : Set → Set → Set1 where\n id : {A : Set} → A ↔ A\n swap₊ : {A B : Set} → (A ⊎ B) ↔ (B ⊎ A)\n swap× : {A B : Set} → (A × B) ↔ (B × A)\n\n-- Theorem, equivalent to stepping: if c : A ↔ B and v : A, then there exists v' : B and c' : (∙ v) ⟷ (∙ v')\neval : {A B : Set} → (A ↔ B) → (v : A) → Σ[ v' ∈ B ] ((⇡ v) ⟷ (⇡ v'))\neval id v = v , id v\neval swap₊ (inj₁ x) = inj₂ x , swap₊₁\neval swap₊ (inj₂ y) = inj₁ y , swap₊₂\neval swap× (x , y) = (y , x) , swap×\n\n-- Theorem, equivalent to backwards stepping: \n-- if c : A ↔ B and v' : B, then there exists v : A and c' : (∙ v) ⟷ (∙ v')\nevalB : {A B : Set} → (A ↔ B) → (v' : B) → Σ[ v ∈ A ] ((⇡ v) ⟷ (⇡ v'))\nevalB id v = v , id v\nevalB swap₊ (inj₁ x) = inj₂ x , swap₊₂\nevalB swap₊ (inj₂ y) = inj₁ y , swap₊₁\nevalB swap× (x , y) = (y , x) , swap×\n\n-- if c : A ↔ B and v : A, then evalB c (eval c v) ⟷ v\nright-inv : {A B : Set} → (c : A ↔ B) → (v : A) → ⇡ (proj₁ (evalB c (proj₁ (eval c v)))) ⟷ ⇡ v\nright-inv id v = id v\nright-inv swap₊ (inj₁ x) = id (inj₁ x)\nright-inv swap₊ (inj₂ y) = id (inj₂ y)\nright-inv swap× v = id v\n\n-- left-inv should be just as easy.\n\n-- we should also be able to make a statement about proj₂ associated with back-and-forth\n\n-- and create a function that maps c to its inverse, and 'prove' eval c = evalB @ inverse c\n\n-- \"forget\" the extra structure\n↓ : {A B : Set} → {x : A} → {y : B} → (⇡ x) ⟷ (⇡ y) → A ↔ B\n↓ {A} {.A} {x} (id .x) = id\n↓ swap₊₁ = swap₊\n↓ swap₊₂ = swap₊\n↓ swap× = swap×\n\n", "meta": {"hexsha": "5e5db90c8ba503142c58fbeaf7ada8d5adceed2b", "size": 2052, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "PointedFrac.agda", "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_issues_repo_path": "PointedFrac.agda", "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_forks_repo_path": "PointedFrac.agda", "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "avg_line_length": 33.0967741935, "max_line_length": 108, "alphanum_fraction": 0.5082846004, "num_tokens": 931, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972583359805, "lm_q2_score": 0.6992544273261176, "lm_q1q2_score": 0.6087689873094141}} {"text": "{-# OPTIONS --without-K #-}\nmodule Homotopy where\n\nopen import GroupoidStructure\nopen import PathOperations\nopen import Types\n\ninfix 1 _∼_\n\n_∼_ : ∀ {a b} {A : Set a} {B : Set b}\n (f g : A → B) → Set _\nf ∼ g = ∀ x → f x ≡ g x\n\nnaturality : ∀ {a b} {A : Set a} {B : Set b} {x y : A}\n (f g : A → B) (H : f ∼ g) (p : x ≡ y) →\n H x · ap g p ≡ ap f p · H y\nnaturality f g H = J\n (λ x y p → H x · ap g p ≡ ap f p · H y)\n (λ _ → p·id _) _ _\n", "meta": {"hexsha": "01ff81d2d11e8d7c15ce158970eb7a4c279fe19c", "size": 439, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Homotopy.agda", "max_stars_repo_name": "vituscze/HoTT-lectures", "max_stars_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Homotopy.agda", "max_issues_repo_name": "vituscze/HoTT-lectures", "max_issues_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Homotopy.agda", "max_forks_repo_name": "vituscze/HoTT-lectures", "max_forks_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.95, "max_line_length": 54, "alphanum_fraction": 0.5056947608, "num_tokens": 197, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8918110569397307, "lm_q2_score": 0.6825737473266734, "lm_q1q2_score": 0.6087268150427133}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Propositional equality\n------------------------------------------------------------------------\n\n-- This file contains some core definitions which are reexported by\n-- Relation.Binary.PropositionalEquality.\n\nmodule Relation.Binary.PropositionalEquality.Core where\n\nopen import Level\nopen import Relation.Binary.Core\nopen import Relation.Binary.Consequences.Core\n\n------------------------------------------------------------------------\n-- Some properties\n\nsym : ∀ {a} {A : Set a} → Symmetric (_≡_ {A = A})\nsym refl = refl\n\ntrans : ∀ {a} {A : Set a} → Transitive (_≡_ {A = A})\ntrans refl eq = eq\n\nsubst : ∀ {a p} {A : Set a} → Substitutive (_≡_ {A = A}) p\nsubst P refl p = p\n\nresp₂ : ∀ {a ℓ} {A : Set a} (∼ : Rel A ℓ) → ∼ Respects₂ _≡_\nresp₂ _∼_ = subst⟶resp₂ _∼_ subst\n\nisEquivalence : ∀ {a} {A : Set a} → IsEquivalence (_≡_ {A = A})\nisEquivalence = record\n { refl = refl\n ; sym = sym\n ; trans = trans\n }\n", "meta": {"hexsha": "cd2e308f4372b0d5147ab32f2b4ee57a740cc502", "size": 1020, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Relation/Binary/PropositionalEquality/Core.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Relation/Binary/PropositionalEquality/Core.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Relation/Binary/PropositionalEquality/Core.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.5675675676, "max_line_length": 72, "alphanum_fraction": 0.512745098, "num_tokens": 273, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8918110511888302, "lm_q2_score": 0.6825737473266735, "lm_q1q2_score": 0.6087268111172996}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import lib.Basics\nopen import lib.types.TLevel\nopen import lib.types.Group\nopen import lib.types.LoopSpace\nopen import lib.groups.Homomorphism\nopen import lib.groups.Isomorphism\n\nmodule lib.groups.LoopSpace where\n\n{- A loop space is a pregroup, and a group if it has the right level -}\nmodule _ {i} (n : ℕ) (X : Ptd i) where\n\n Ω^S-group-structure : GroupStructure (Ω^ (S n) X)\n Ω^S-group-structure = record {\n ident = idp^ (S n);\n inv = Ω^S-! n;\n comp = Ω^S-∙ n;\n unit-l = Ω^S-∙-unit-l n;\n assoc = Ω^S-∙-assoc n;\n inv-l = Ω^S-!-inv-l n\n }\n\n Ω^S-group : has-level ⟨ S n ⟩ (de⊙ X) → Group i\n Ω^S-group pX = group\n (Ω^ (S n) X)\n (Ω^-level 0 (S n) X $\n transport (λ t → has-level t (de⊙ X)) (! (+2+0 ⟨ S n ⟩₋₂)) pX)\n Ω^S-group-structure\n\nmodule _ {i j} (n : ℕ) {X : Ptd i} {Y : Ptd j} where\n Ω^S-group-structure-fmap : X ⊙→ Y\n → GroupStructureHom (Ω^S-group-structure n X) (Ω^S-group-structure n Y)\n Ω^S-group-structure-fmap F = group-structure-hom (Ω^-fmap (S n) F) (Ω^S-fmap-∙ n F)\n\n Ω^S-group-structure-isemap : {F : X ⊙→ Y}\n → is-equiv (fst F) → is-equiv (GroupStructureHom.f (Ω^S-group-structure-fmap F))\n Ω^S-group-structure-isemap {F} F-is-equiv = Ω^-isemap (S n) F F-is-equiv\n\n Ω^S-group-structure-emap : X ⊙≃ Y\n → Ω^S-group-structure n X ≃ᴳˢ Ω^S-group-structure n Y\n Ω^S-group-structure-emap (F , F-is-equiv) =\n Ω^S-group-structure-fmap F , Ω^S-group-structure-isemap F-is-equiv\n\nmodule _ {i j} (n : ℕ) {X : Ptd i} {Y : Ptd j}\n (X-level : has-level ⟨ S n ⟩ (de⊙ X))\n (Y-level : has-level ⟨ S n ⟩ (de⊙ Y))\n where\n\n Ω^S-group-fmap : X ⊙→ Y → Ω^S-group n X X-level →ᴳ Ω^S-group n Y Y-level\n Ω^S-group-fmap = →ᴳˢ-to-→ᴳ ∘ Ω^S-group-structure-fmap n\n\n Ω^S-group-emap : X ⊙≃ Y → Ω^S-group n X X-level ≃ᴳ Ω^S-group n Y Y-level\n Ω^S-group-emap = ≃ᴳˢ-to-≃ᴳ ∘ Ω^S-group-structure-emap n\n", "meta": {"hexsha": "5d85023bbb2df73ad20d5f8dc5eaec84357f9dc2", "size": 1892, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/groups/LoopSpace.agda", "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "core/lib/groups/LoopSpace.agda", "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "core/lib/groups/LoopSpace.agda", "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "avg_line_length": 33.7857142857, "max_line_length": 85, "alphanum_fraction": 0.605179704, "num_tokens": 810, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110511888303, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.6087267938415605}} {"text": "{-# OPTIONS --without-K --safe #-}\n\n-- Bundled version of Monoidal Category\nmodule Categories.Category.Monoidal.Bundle where\n\nopen import Level\n\nopen import Categories.Category.Core using (Category)\nopen import Categories.Category.Monoidal.Core using (Monoidal)\nopen import Categories.Category.Monoidal.Braided using (Braided)\nopen import Categories.Category.Monoidal.Symmetric using (Symmetric)\n\nrecord MonoidalCategory o ℓ e : Set (suc (o ⊔ ℓ ⊔ e)) where\n field\n U : Category o ℓ e\n monoidal : Monoidal U\n\n open Category U public\n open Monoidal monoidal public\n\nrecord BraidedMonoidalCategory o ℓ e : Set (suc (o ⊔ ℓ ⊔ e)) where\n field\n U : Category o ℓ e\n monoidal : Monoidal U\n braided : Braided monoidal\n\n monoidalCategory : MonoidalCategory o ℓ e\n monoidalCategory = record { U = U ; monoidal = monoidal }\n\n open Category U public\n open Braided braided public\n\nrecord SymmetricMonoidalCategory o ℓ e : Set (suc (o ⊔ ℓ ⊔ e)) where\n field\n U : Category o ℓ e\n monoidal : Monoidal U\n symmetric : Symmetric monoidal\n\n open Category U public\n open Symmetric symmetric public\n\n braidedMonoidalCategory : BraidedMonoidalCategory o ℓ e\n braidedMonoidalCategory = record\n { U = U\n ; monoidal = monoidal\n ; braided = braided\n }\n\n open BraidedMonoidalCategory braidedMonoidalCategory public\n using (monoidalCategory)\n", "meta": {"hexsha": "4ed249bb467a7acc8a9f255fd53bf0938eb760f5", "size": 1400, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Monoidal/Bundle.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/Monoidal/Bundle.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/Monoidal/Bundle.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 27.4509803922, "max_line_length": 68, "alphanum_fraction": 0.715, "num_tokens": 384, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513675912912, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.6087148379748201}} {"text": "{-# OPTIONS --without-K #-}\nmodule TypeEquivalences where\n\nopen import Data.Empty\nopen import Data.Unit\nopen import Data.Unit.Core\nopen import Data.Nat renaming (_⊔_ to _⊔ℕ_)\nopen import Data.Sum renaming (map to _⊎→_)\nopen import Data.Product renaming (map to _×→_)\nopen import Function renaming (_∘_ to _○_)\n\n-- explicit using to show how little of HoTT is needed\nopen import SimpleHoTT using (refl; ap; ap2) \nopen import Equivalences\n\n------------------------------------------------------------------------------\n-- Type Equivalences\n\n-- for each type combinator, define two functions that are inverses, and\n-- establish an equivalence. These are all in the 'semantic space' with\n-- respect to Pi combinators.\n\n-- swap₊\n\nswap₊ : {A B : Set} → A ⊎ B → B ⊎ A\nswap₊ (inj₁ a) = inj₂ a\nswap₊ (inj₂ b) = inj₁ b\n\nswapswap₊ : {A B : Set} → swap₊ ○ swap₊ {A} {B} ∼ id\nswapswap₊ (inj₁ a) = refl (inj₁ a)\nswapswap₊ (inj₂ b) = refl (inj₂ b)\n\nswap₊equiv : {A B : Set} → (A ⊎ B) ≃ (B ⊎ A)\nswap₊equiv = (swap₊ , equiv₁ (mkqinv swap₊ swapswap₊ swapswap₊))\n\n-- unite₊ and uniti₊\n\nunite₊ : {A : Set} → ⊥ ⊎ A → A\nunite₊ (inj₁ ())\nunite₊ (inj₂ y) = y\n\nuniti₊ : {A : Set} → A → ⊥ ⊎ A\nuniti₊ a = inj₂ a\n\nuniti₊∘unite₊ : {A : Set} → uniti₊ ○ unite₊ ∼ id {A = ⊥ ⊎ A}\nuniti₊∘unite₊ (inj₁ ())\nuniti₊∘unite₊ (inj₂ y) = refl (inj₂ y)\n\n-- this is so easy, Agda can figure it out by itself (see below)\nunite₊∙uniti₊ : {A : Set} → unite₊ ○ uniti₊ ∼ id {A = A}\nunite₊∙uniti₊ = refl\n\nunite₊equiv : {A : Set} → (⊥ ⊎ A) ≃ A\nunite₊equiv = (unite₊ , mkisequiv uniti₊ refl uniti₊ uniti₊∘unite₊)\n\nuniti₊equiv : {A : Set} → A ≃ (⊥ ⊎ A)\nuniti₊equiv = uniti₊ , mkisequiv unite₊ uniti₊∘unite₊ unite₊ unite₊∙uniti₊\n\n-- unite⋆ and uniti⋆\n\nunite⋆ : {A : Set} → ⊤ × A → A\nunite⋆ (tt , x) = x\n\nuniti⋆ : {A : Set} → A → ⊤ × A\nuniti⋆ x = tt , x\n\nuniti⋆∘unite⋆ : {A : Set} → uniti⋆ ○ unite⋆ ∼ id {A = ⊤ × A}\nuniti⋆∘unite⋆ (tt , x) = refl (tt , x)\n\nunite⋆equiv : {A : Set} → (⊤ × A) ≃ A\nunite⋆equiv = unite⋆ , mkisequiv uniti⋆ refl uniti⋆ uniti⋆∘unite⋆\n\nuniti⋆equiv : {A : Set} → A ≃ (⊤ × A)\nuniti⋆equiv = uniti⋆ , mkisequiv unite⋆ uniti⋆∘unite⋆ unite⋆ refl\n\n-- swap⋆\n\nswap⋆ : {A B : Set} → A × B → B × A\nswap⋆ (a , b) = (b , a)\n\nswapswap⋆ : {A B : Set} → swap⋆ ○ swap⋆ ∼ id {A = A × B}\nswapswap⋆ (a , b) = refl (a , b) \n\nswap⋆equiv : {A B : Set} → (A × B) ≃ (B × A)\nswap⋆equiv = swap⋆ , mkisequiv swap⋆ swapswap⋆ swap⋆ swapswap⋆\n\n-- assocl₊ and assocr₊\n\nassocl₊ : {A B C : Set} → (A ⊎ (B ⊎ C)) → ((A ⊎ B) ⊎ C)\nassocl₊ (inj₁ a) = inj₁ (inj₁ a)\nassocl₊ (inj₂ (inj₁ b)) = inj₁ (inj₂ b)\nassocl₊ (inj₂ (inj₂ c)) = inj₂ c\n\nassocr₊ : {A B C : Set} → ((A ⊎ B) ⊎ C) → (A ⊎ (B ⊎ C))\nassocr₊ (inj₁ (inj₁ a)) = inj₁ a\nassocr₊ (inj₁ (inj₂ b)) = inj₂ (inj₁ b)\nassocr₊ (inj₂ c) = inj₂ (inj₂ c)\n\nassocl₊∘assocr₊ : {A B C : Set} → assocl₊ ○ assocr₊ ∼ id {A = ((A ⊎ B) ⊎ C)}\nassocl₊∘assocr₊ (inj₁ (inj₁ a)) = refl (inj₁ (inj₁ a))\nassocl₊∘assocr₊ (inj₁ (inj₂ b)) = refl (inj₁ (inj₂ b))\nassocl₊∘assocr₊ (inj₂ c) = refl (inj₂ c)\n\nassocr₊∘assocl₊ : {A B C : Set} → assocr₊ ○ assocl₊ ∼ id {A = (A ⊎ (B ⊎ C))}\nassocr₊∘assocl₊ (inj₁ a) = refl (inj₁ a)\nassocr₊∘assocl₊ (inj₂ (inj₁ b)) = refl (inj₂ (inj₁ b))\nassocr₊∘assocl₊ (inj₂ (inj₂ c)) = refl (inj₂ (inj₂ c))\n\nassocl₊equiv : {A B C : Set} → (A ⊎ (B ⊎ C)) ≃ ((A ⊎ B) ⊎ C)\nassocl₊equiv = \n assocl₊ , mkisequiv assocr₊ assocl₊∘assocr₊ assocr₊ assocr₊∘assocl₊\n\nassocr₊equiv : {A B C : Set} → ((A ⊎ B) ⊎ C) ≃ (A ⊎ (B ⊎ C))\nassocr₊equiv = \n assocr₊ , mkisequiv assocl₊ assocr₊∘assocl₊ assocl₊ assocl₊∘assocr₊\n\n-- assocl⋆ and assocr⋆\n\nassocl⋆ : {A B C : Set} → (A × (B × C)) → ((A × B) × C)\nassocl⋆ (a , (b , c)) = ((a , b) , c)\n\nassocr⋆ : {A B C : Set} → ((A × B) × C) → (A × (B × C))\nassocr⋆ ((a , b) , c) = (a , (b , c))\n\nassocl⋆∘assocr⋆ : {A B C : Set} → assocl⋆ ○ assocr⋆ ∼ id {A = ((A × B) × C)}\nassocl⋆∘assocr⋆ x = refl x\n\nassocr⋆∘assocl⋆ : {A B C : Set} → assocr⋆ ○ assocl⋆ ∼ id {A = (A × (B × C))}\nassocr⋆∘assocl⋆ x = refl x\n\nassocl⋆equiv : {A B C : Set} → (A × (B × C)) ≃ ((A × B) × C)\nassocl⋆equiv = \n assocl⋆ , mkisequiv assocr⋆ assocl⋆∘assocr⋆ assocr⋆ assocr⋆∘assocl⋆\n\nassocr⋆equiv : {A B C : Set} → ((A × B) × C) ≃ (A × (B × C))\nassocr⋆equiv = \n assocr⋆ , mkisequiv assocl⋆ assocr⋆∘assocl⋆ assocl⋆ assocl⋆∘assocr⋆\n\n-- distz and factorz\n\ndistz : { A : Set} → (⊥ × A) → ⊥\ndistz (() , _)\n\nfactorz : {A : Set} → ⊥ → (⊥ × A)\nfactorz ()\n \ndistz∘factorz : {A : Set} → distz ○ factorz {A} ∼ id\ndistz∘factorz ()\n\nfactorz∘distz : {A : Set} → factorz {A} ○ distz ∼ id\nfactorz∘distz (() , proj₂)\n\ndistzequiv : {A : Set} → (⊥ × A) ≃ ⊥\ndistzequiv {A} = \n distz , mkisequiv factorz (distz∘factorz {A}) factorz factorz∘distz\n\nfactorzequiv : {A : Set} → ⊥ ≃ (⊥ × A)\nfactorzequiv {A} = \n factorz , mkisequiv distz factorz∘distz distz (distz∘factorz {A})\n\n-- dist and factor\n\ndist : {A B C : Set} → ((A ⊎ B) × C) → (A × C) ⊎ (B × C)\ndist (inj₁ x , c) = inj₁ (x , c)\ndist (inj₂ y , c) = inj₂ (y , c)\n\nfactor : {A B C : Set} → (A × C) ⊎ (B × C) → ((A ⊎ B) × C)\nfactor (inj₁ (a , c)) = inj₁ a , c\nfactor (inj₂ (b , c)) = inj₂ b , c\n\ndist∘factor : {A B C : Set} → dist {A} {B} {C} ○ factor ∼ id\ndist∘factor (inj₁ x) = refl (inj₁ x)\ndist∘factor (inj₂ y) = refl (inj₂ y)\n\nfactor∘dist : {A B C : Set} → factor {A} {B} {C} ○ dist ∼ id\nfactor∘dist (inj₁ x , c) = refl (inj₁ x , c)\nfactor∘dist (inj₂ y , c) = refl (inj₂ y , c)\n\ndistequiv : {A B C : Set} → ((A ⊎ B) × C) ≃ ((A × C) ⊎ (B × C))\ndistequiv = dist , mkisequiv factor dist∘factor factor factor∘dist\n\nfactorequiv : {A B C : Set} → ((A × C) ⊎ (B × C)) ≃ ((A ⊎ B) × C)\nfactorequiv = factor , (mkisequiv dist factor∘dist dist dist∘factor)\n\n-- ⊕\n\n_⊎∼_ : {A B C D : Set} {f : A → C} {finv : C → A} {g : B → D} {ginv : D → B} →\n (α : f ○ finv ∼ id) → (β : g ○ ginv ∼ id) → \n (f ⊎→ g) ○ (finv ⊎→ ginv) ∼ id {A = C ⊎ D}\n_⊎∼_ α β (inj₁ x) = ap inj₁ (α x) \n_⊎∼_ α β (inj₂ y) = ap inj₂ (β y)\n\npath⊎ : {A B C D : Set} → A ≃ C → B ≃ D → (A ⊎ B) ≃ (C ⊎ D)\npath⊎ (fp , eqp) (fq , eqq) = \n Data.Sum.map fp fq , \n mkisequiv (P.g ⊎→ Q.g) (P.α ⊎∼ Q.α) (P.h ⊎→ Q.h) (P.β ⊎∼ Q.β)\n where module P = isequiv eqp\n module Q = isequiv eqq\n \n-- ⊗\n\n_×∼_ : {A B C D : Set} {f : A → C} {finv : C → A} {g : B → D} {ginv : D → B} →\n (α : f ○ finv ∼ id) → (β : g ○ ginv ∼ id) → \n (f ×→ g) ○ (finv ×→ ginv) ∼ id {A = C × D}\n_×∼_ α β (x , y) = ap2 _,_ (α x) (β y)\n \npath× : {A B C D : Set} → A ≃ C → B ≃ D → (A × B) ≃ (C × D)\npath× {A} {B} {C} {D} (fp , eqp) (fq , eqq) = \n Data.Product.map fp fq , \n mkisequiv \n (P.g ×→ Q.g) \n (_×∼_ {A} {B} {C} {D} {fp} {P.g} {fq} {Q.g} P.α Q.α) \n (P.h ×→ Q.h) \n (_×∼_ {C} {D} {A} {B} {P.h} {fp} {Q.h} {fq} P.β Q.β)\n where module P = isequiv eqp\n module Q = isequiv eqq\n\nidequiv : {A : Set} → A ≃ A\nidequiv = id≃\n", "meta": {"hexsha": "ad9aa1f41c9676b1dc21aeb2f86b8d32b31a3319", "size": 6683, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Univalence/OldUnivalence/TypeEquivalences.agda", "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_issues_repo_path": "Univalence/OldUnivalence/TypeEquivalences.agda", "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_forks_repo_path": "Univalence/OldUnivalence/TypeEquivalences.agda", "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "avg_line_length": 30.3772727273, "max_line_length": 78, "alphanum_fraction": 0.5256621278, "num_tokens": 3409, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737869342624, "lm_q2_score": 0.7577943658046608, "lm_q1q2_score": 0.6086405705007771}} {"text": "{-# OPTIONS --allow-unsolved-metas #-}\nmodule gcd where\n\nopen import Data.Nat \nopen import Data.Nat.Properties\nopen import Data.Empty\nopen import Data.Unit using (⊤ ; tt)\nopen import Relation.Nullary\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Binary.Definitions\nopen import nat\nopen import logic\n\nopen Factor\n\ngcd1 : ( i i0 j j0 : ℕ ) → ℕ\ngcd1 zero i0 zero j0 with <-cmp i0 j0\n... | tri< a ¬b ¬c = i0\n... | tri≈ ¬a refl ¬c = i0\n... | tri> ¬a ¬b c = j0\ngcd1 zero i0 (suc zero) j0 = 1\ngcd1 zero zero (suc (suc j)) j0 = j0\ngcd1 zero (suc i0) (suc (suc j)) j0 = gcd1 i0 (suc i0) (suc j) (suc (suc j))\ngcd1 (suc zero) i0 zero j0 = 1\ngcd1 (suc (suc i)) i0 zero zero = i0\ngcd1 (suc (suc i)) i0 zero (suc j0) = gcd1 (suc i) (suc (suc i)) j0 (suc j0)\ngcd1 (suc i) i0 (suc j) j0 = gcd1 i i0 j j0 \n\ngcd : ( i j : ℕ ) → ℕ\ngcd i j = gcd1 i i j j \n\ngcd20 : (i : ℕ) → gcd i 0 ≡ i\ngcd20 zero = refl\ngcd20 (suc i) = gcd201 (suc i) where\n gcd201 : (i : ℕ ) → gcd1 i i zero zero ≡ i\n gcd201 zero = refl\n gcd201 (suc zero) = refl\n gcd201 (suc (suc i)) = refl\n\ngcd22 : ( i i0 o o0 : ℕ ) → gcd1 (suc i) i0 (suc o) o0 ≡ gcd1 i i0 o o0\ngcd22 zero i0 zero o0 = refl\ngcd22 zero i0 (suc o) o0 = refl\ngcd22 (suc i) i0 zero o0 = refl\ngcd22 (suc i) i0 (suc o) o0 = refl \n\ngcdmm : (n m : ℕ) → gcd1 n m n m ≡ m\ngcdmm zero m with <-cmp m m\n... | tri< a ¬b ¬c = refl\n... | tri≈ ¬a refl ¬c = refl\n... | tri> ¬a ¬b c = refl\ngcdmm (suc n) m = subst (λ k → k ≡ m) (sym (gcd22 n m n m )) (gcdmm n m )\n\ngcdsym2 : (i j : ℕ) → gcd1 zero i zero j ≡ gcd1 zero j zero i\ngcdsym2 i j with <-cmp i j | <-cmp j i\n... | tri< a ¬b ¬c | tri< a₁ ¬b₁ ¬c₁ = ⊥-elim (nat-<> a a₁) \n... | tri< a ¬b ¬c | tri≈ ¬a b ¬c₁ = ⊥-elim (nat-≡< (sym b) a) \n... | tri< a ¬b ¬c | tri> ¬a ¬b₁ c = refl\n... | tri≈ ¬a b ¬c | tri< a ¬b ¬c₁ = ⊥-elim (nat-≡< (sym b) a) \n... | tri≈ ¬a refl ¬c | tri≈ ¬a₁ refl ¬c₁ = refl\n... | tri≈ ¬a b ¬c | tri> ¬a₁ ¬b c = ⊥-elim (nat-≡< b c) \n... | tri> ¬a ¬b c | tri< a ¬b₁ ¬c = refl\n... | tri> ¬a ¬b c | tri≈ ¬a₁ b ¬c = ⊥-elim (nat-≡< b c) \n... | tri> ¬a ¬b c | tri> ¬a₁ ¬b₁ c₁ = ⊥-elim (nat-<> c c₁) \ngcdsym1 : ( i i0 j j0 : ℕ ) → gcd1 i i0 j j0 ≡ gcd1 j j0 i i0\ngcdsym1 zero zero zero zero = refl\ngcdsym1 zero zero zero (suc j0) = refl\ngcdsym1 zero (suc i0) zero zero = refl\ngcdsym1 zero (suc i0) zero (suc j0) = gcdsym2 (suc i0) (suc j0)\ngcdsym1 zero zero (suc zero) j0 = refl\ngcdsym1 zero zero (suc (suc j)) j0 = refl\ngcdsym1 zero (suc i0) (suc zero) j0 = refl\ngcdsym1 zero (suc i0) (suc (suc j)) j0 = gcdsym1 i0 (suc i0) (suc j) (suc (suc j))\ngcdsym1 (suc zero) i0 zero j0 = refl\ngcdsym1 (suc (suc i)) i0 zero zero = refl\ngcdsym1 (suc (suc i)) i0 zero (suc j0) = gcdsym1 (suc i) (suc (suc i))j0 (suc j0) \ngcdsym1 (suc i) i0 (suc j) j0 = subst₂ (λ j k → j ≡ k ) (sym (gcd22 i _ _ _)) (sym (gcd22 j _ _ _)) (gcdsym1 i i0 j j0 )\n\ngcdsym : { n m : ℕ} → gcd n m ≡ gcd m n\ngcdsym {n} {m} = gcdsym1 n n m m \n\ngcd11 : ( i : ℕ ) → gcd i i ≡ i\ngcd11 i = gcdmm i i \n\n\ngcd203 : (i : ℕ) → gcd1 (suc i) (suc i) i i ≡ 1\ngcd203 zero = refl\ngcd203 (suc i) = gcd205 (suc i) where\n gcd205 : (j : ℕ) → gcd1 (suc j) (suc (suc i)) j (suc i) ≡ 1\n gcd205 zero = refl\n gcd205 (suc j) = subst (λ k → k ≡ 1) (gcd22 (suc j) (suc (suc i)) j (suc i)) (gcd205 j)\n\ngcd204 : (i : ℕ) → gcd1 1 1 i i ≡ 1\ngcd204 zero = refl\ngcd204 (suc zero) = refl\ngcd204 (suc (suc zero)) = refl\ngcd204 (suc (suc (suc i))) = gcd204 (suc (suc i)) \n\ngcd+j : ( i j : ℕ ) → gcd (i + j) j ≡ gcd i j\ngcd+j i j = gcd200 i i j j refl refl where\n gcd202 : (i j1 : ℕ) → (i + suc j1) ≡ suc (i + j1)\n gcd202 zero j1 = refl\n gcd202 (suc i) j1 = cong suc (gcd202 i j1)\n gcd201 : (i i0 j j0 j1 : ℕ) → gcd1 (i + j1) (i0 + suc j) j1 j0 ≡ gcd1 i (i0 + suc j) zero j0\n gcd201 i i0 j j0 zero = subst (λ k → gcd1 k (i0 + suc j) zero j0 ≡ gcd1 i (i0 + suc j) zero j0 ) (+-comm zero i) refl\n gcd201 i i0 j j0 (suc j1) = begin\n gcd1 (i + suc j1) (i0 + suc j) (suc j1) j0 ≡⟨ cong (λ k → gcd1 k (i0 + suc j) (suc j1) j0 ) (gcd202 i j1) ⟩\n gcd1 (suc (i + j1)) (i0 + suc j) (suc j1) j0 ≡⟨ gcd22 (i + j1) (i0 + suc j) j1 j0 ⟩\n gcd1 (i + j1) (i0 + suc j) j1 j0 ≡⟨ gcd201 i i0 j j0 j1 ⟩\n gcd1 i (i0 + suc j) zero j0 ∎ where open ≡-Reasoning\n gcd200 : (i i0 j j0 : ℕ) → i ≡ i0 → j ≡ j0 → gcd1 (i + j) (i0 + j) j j0 ≡ gcd1 i i j0 j0\n gcd200 i .i zero .0 refl refl = subst (λ k → gcd1 k k zero zero ≡ gcd1 i i zero zero ) (+-comm zero i) refl \n gcd200 (suc (suc i)) i0 (suc j) (suc j0) i=i0 j=j0 = gcd201 (suc (suc i)) i0 j (suc j0) (suc j)\n gcd200 zero zero (suc zero) .1 i=i0 refl = refl\n gcd200 zero zero (suc (suc j)) .(suc (suc j)) i=i0 refl = begin\n gcd1 (zero + suc (suc j)) (zero + suc (suc j)) (suc (suc j)) (suc (suc j)) ≡⟨ gcdmm (suc (suc j)) (suc (suc j)) ⟩\n suc (suc j) ≡⟨ sym (gcd20 (suc (suc j))) ⟩\n gcd1 zero zero (suc (suc j)) (suc (suc j)) ∎ where open ≡-Reasoning\n gcd200 zero (suc i0) (suc j) .(suc j) () refl\n gcd200 (suc zero) .1 (suc j) .(suc j) refl refl = begin\n gcd1 (1 + suc j) (1 + suc j) (suc j) (suc j) ≡⟨ gcd203 (suc j) ⟩\n 1 ≡⟨ sym ( gcd204 (suc j)) ⟩\n gcd1 1 1 (suc j) (suc j) ∎ where open ≡-Reasoning\n gcd200 (suc (suc i)) i0 (suc j) zero i=i0 ()\n\nopen _∧_\n\ngcd-gt : ( i i0 j j0 k : ℕ ) → k > 1 → (if : Factor k i) (i0f : Dividable k i0 ) (jf : Factor k j ) (j0f : Dividable k j0)\n → Dividable k (i - j) ∧ Dividable k (j - i)\n → Dividable k ( gcd1 i i0 j j0 ) \ngcd-gt zero i0 zero j0 k k>1 if i0f jf j0f i-j with <-cmp i0 j0\n... | tri< a ¬b ¬c = i0f \n... | tri≈ ¬a refl ¬c = i0f\n... | tri> ¬a ¬b c = j0f\ngcd-gt zero i0 (suc zero) j0 k k>1 if i0f jf j0f i-j = ⊥-elim (div1 k>1 (proj2 i-j)) -- can't happen\ngcd-gt zero zero (suc (suc j)) j0 k k>1 if i0f jf j0f i-j = j0f\ngcd-gt zero (suc i0) (suc (suc j)) j0 k k>1 if i0f jf j0f i-j = \n gcd-gt i0 (suc i0) (suc j) (suc (suc j)) k k>1 (decf (DtoF i0f)) i0f (decf jf) (proj2 i-j) (div-div k>1 i0f (proj2 i-j))\ngcd-gt (suc zero) i0 zero j0 k k>1 if i0f jf j0f i-j = ⊥-elim (div1 k>1 (proj1 i-j)) -- can't happen\ngcd-gt (suc (suc i)) i0 zero zero k k>1 if i0f jf j0f i-j = i0f\ngcd-gt (suc (suc i)) i0 zero (suc j0) k k>1 if i0f jf j0f i-j = -- \n gcd-gt (suc i) (suc (suc i)) j0 (suc j0) k k>1 (decf if) (proj1 i-j) (decf (DtoF j0f)) j0f (div-div k>1 (proj1 i-j) j0f )\ngcd-gt (suc zero) i0 (suc j) j0 k k>1 if i0f jf j0f i-j = \n gcd-gt zero i0 j j0 k k>1 (decf if) i0f (decf jf) j0f i-j\ngcd-gt (suc (suc i)) i0 (suc j) j0 k k>1 if i0f jf j0f i-j = \n gcd-gt (suc i) i0 j j0 k k>1 (decf if) i0f (decf jf) j0f i-j \n\ngcd-div : ( i j k : ℕ ) → k > 1 → (if : Dividable k i) (jf : Dividable k j ) \n → Dividable k ( gcd i j ) \ngcd-div i j k k>1 if jf = gcd-gt i i j j k k>1 (DtoF if) if (DtoF jf) jf (div-div k>1 if jf)\n\ndi-next : {i i0 j j0 : ℕ} → Dividable i0 ((j0 + suc i) - suc j ) ∧ Dividable j0 ((i0 + suc j) - suc i) →\n Dividable i0 ((j0 + i) - j ) ∧ Dividable j0 ((i0 + j) - i) \ndi-next {i} {i0} {j} {j0} x =\n ⟪ ( subst (λ k → Dividable i0 (k - suc j)) ( begin\n j0 + suc i ≡⟨ sym (+-assoc j0 1 i ) ⟩ \n (j0 + 1) + i ≡⟨ cong (λ k → k + i) (+-comm j0 _ ) ⟩ \n suc (j0 + i) ∎ ) (proj1 x) ) ,\n ( subst (λ k → Dividable j0 (k - suc i)) ( begin\n i0 + suc j ≡⟨ sym (+-assoc i0 1 j ) ⟩ \n (i0 + 1) + j ≡⟨ cong (λ k → k + j) (+-comm i0 _ ) ⟩ \n suc (i0 + j) ∎ ) (proj2 x) ) ⟫ \n where open ≡-Reasoning\n\ndi-next1 : {i0 j j0 : ℕ} → Dividable (suc i0) ((j0 + 0) - (suc (suc j))) ∧ Dividable j0 (suc (i0 + suc (suc j)))\n → Dividable (suc i0) ((suc (suc j) + i0) - suc j) ∧ Dividable (suc (suc j)) ((suc i0 + suc j) - i0)\ndi-next1 {i0} {j} {j0} x = \n ⟪ record { factor = 1 ; is-factor = begin\n 1 * suc i0 + 0 ≡⟨ cong suc ( trans (+-comm _ 0) (+-comm _ 0) ) ⟩\n suc i0 ≡⟨ sym (minus+y-y {suc i0} {j}) ⟩\n (suc i0 + j) - j ≡⟨ cong (λ k → k - j ) (+-comm (suc i0) _ ) ⟩\n (suc j + suc i0 ) - suc j ≡⟨ cong (λ k → k - suc j) (sym (+-assoc (suc j) 1 i0 )) ⟩\n ((suc j + 1) + i0) - suc j ≡⟨ cong (λ k → (k + i0) - suc j) (+-comm _ 1) ⟩\n (suc (suc j) + i0) - suc j ∎ } , \n subst (λ k → Dividable (suc (suc j)) k) ( begin\n suc (suc j) ≡⟨ sym ( minus+y-y {suc (suc j)}{i0} ) ⟩ \n (suc (suc j) + i0 ) - i0 ≡⟨ cong (λ k → (k + i0) - i0) (cong suc (+-comm 1 _ )) ⟩ \n ((suc j + 1) + i0 ) - i0 ≡⟨ cong (λ k → k - i0) (+-assoc (suc j) 1 _ ) ⟩ \n (suc j + suc i0 ) - i0 ≡⟨ cong (λ k → k - i0) (+-comm (suc j) _) ⟩ \n ((suc i0 + suc j) - i0) ∎ ) div= ⟫ \n where open ≡-Reasoning\n\ngcd>0 : ( i j : ℕ ) → 0 < i → 0 < j → 0 < gcd i j \ngcd>0 i j 001 i i j j 001 : ( i i0 j j0 : ℕ ) → 0 < i0 → 0 < j0 → gcd1 i i0 j j0 > 0\n gcd>01 zero i0 zero j0 0 ¬a ¬b c = 001 zero i0 (suc zero) j0 001 zero zero (suc (suc j)) j0 001 zero (suc i0) (suc (suc j)) j0 001 i0 (suc i0) (suc j) (suc (suc j)) 001 (suc zero) i0 zero j0 001 (suc (suc i)) i0 zero zero 001 (suc (suc i)) i0 zero (suc j0) 001 (suc i) (suc (suc i)) j0 (suc j0) (s≤s z≤n) 001 (suc i) i0 (suc j) j0 001 i i0 j j0 0 1 → Dividable k n → gcd n k ≡ k\ndiv→gcd {n} {k} k>1 = n-induction {_} {_} {ℕ} {λ m → Dividable k m → gcd m k ≡ k } (λ x → x) I n where\n decl : {m : ℕ } → 0 < m → m - k < m\n decl {m} 01 ) 01 d div= )\n ... | tri> ¬a ¬b c = subst (λ g → g ≡ k) ind1 ( prev (proj2 (div-div k>1 div= d))) where\n ind1 : gcd (m - k) k ≡ gcd m k\n ind1 = begin\n gcd (m - k) k ≡⟨ sym (gcd+j (m - k) _) ⟩\n gcd (m - k + k) k ≡⟨ cong (λ g → gcd g k) (minus+n {m} {k} c) ⟩\n gcd m k ∎ where open ≡-Reasoning\n ... | tri< a ¬b ¬c with <-cmp 0 m \n ... | tri< a₁ ¬b₁ ¬c₁ = ⊥-elim ( div1 a₁ (<-trans a1 (s≤s z≤n) a d )\n ... | tri≈ ¬a refl ¬c = gcdmm k k\n ... | tri> ¬a ¬b c = ⊥-elim ( nat-≡< (sym eq) (minus>0 c) )\n I : Ninduction ℕ _ (λ x → x)\n I = record {\n pnext = λ p → p - k\n ; fzero = λ {m} eq → fzero m eq\n ; decline = λ {m} lt → decl lt \n ; ind = λ {p} prev → ind p prev\n } \n\nGCDi : {i j : ℕ } → GCD i i j j\nGCDi {i} {j} = record { i ¬a ¬b c = {!!}\n-- gcd-dividable1 zero i0 (suc zero) j0 = {!!}\n-- gcd-dividable1 i i0 j j0 = {!!}\n\ngcd-dividable : ( i j : ℕ )\n → Dividable ( gcd i j ) i ∧ Dividable ( gcd i j ) j\ngcd-dividable i j = f-induction {_} {_} {ℕ ∧ ℕ}\n {λ p → Dividable ( gcd (proj1 p) (proj2 p) ) (proj1 p) ∧ Dividable ( gcd (proj1 p) (proj2 p) ) (proj2 p)} F I ⟪ i , j ⟫ where\n F : ℕ ∧ ℕ → ℕ\n F ⟪ 0 , 0 ⟫ = 0\n F ⟪ 0 , suc j ⟫ = 0\n F ⟪ suc i , 0 ⟫ = 0\n F ⟪ suc i , suc j ⟫ with <-cmp i j\n ... | tri< a ¬b ¬c = suc j\n ... | tri≈ ¬a b ¬c = 0\n ... | tri> ¬a ¬b c = suc i\n F0 : { i j : ℕ } → F ⟪ i , j ⟫ ≡ 0 → (i ≡ j) ∨ (i ≡ 0 ) ∨ (j ≡ 0)\n F0 {zero} {zero} p = case1 refl\n F0 {zero} {suc j} p = case2 (case1 refl)\n F0 {suc i} {zero} p = case2 (case2 refl)\n F0 {suc i} {suc j} p with <-cmp i j\n ... | tri< a ¬b ¬c = ⊥-elim ( nat-≡< (sym p) (s≤s z≤n ))\n ... | tri≈ ¬a refl ¬c = case1 refl\n ... | tri> ¬a ¬b c = ⊥-elim ( nat-≡< (sym p) (s≤s z≤n ))\n F00 : {p : ℕ ∧ ℕ} → F p ≡ zero → Dividable (gcd (proj1 p) (proj2 p)) (proj1 p) ∧ Dividable (gcd (proj1 p) (proj2 p)) (proj2 p)\n F00 {⟪ i , j ⟫} eq with F0 {i} {j} eq\n ... | case1 refl = ⟪ subst (λ k → Dividable k i) (sym (gcdmm i i)) div= , subst (λ k → Dividable k i) (sym (gcdmm i i)) div= ⟫\n ... | case2 (case1 refl) = ⟪ subst (λ k → Dividable k i) (sym (trans (gcdsym {0} {j} ) (gcd20 j)))div0\n , subst (λ k → Dividable k j) (sym (trans (gcdsym {0} {j}) (gcd20 j))) div= ⟫\n ... | case2 (case2 refl) = ⟪ subst (λ k → Dividable k i) (sym (gcd20 i)) div=\n , subst (λ k → Dividable k j) (sym (gcd20 i)) div0 ⟫\n Fsym : {i j : ℕ } → F ⟪ i , j ⟫ ≡ F ⟪ j , i ⟫\n Fsym {0} {0} = refl\n Fsym {0} {suc j} = refl\n Fsym {suc i} {0} = refl\n Fsym {suc i} {suc j} with <-cmp i j | <-cmp j i\n ... | tri< a ¬b ¬c | tri< a₁ ¬b₁ ¬c₁ = ⊥-elim (nat-<> a a₁)\n ... | tri< a ¬b ¬c | tri≈ ¬a b ¬c₁ = ⊥-elim (¬b (sym b))\n ... | tri< a ¬b ¬c | tri> ¬a ¬b₁ c = refl\n ... | tri≈ ¬a refl ¬c | tri< a ¬b ¬c₁ = ⊥-elim (¬b refl)\n ... | tri≈ ¬a refl ¬c | tri≈ ¬a₁ refl ¬c₁ = refl\n ... | tri≈ ¬a refl ¬c | tri> ¬a₁ ¬b c = ⊥-elim (¬b refl)\n ... | tri> ¬a ¬b c | tri< a ¬b₁ ¬c = refl\n ... | tri> ¬a ¬b c | tri≈ ¬a₁ b ¬c = ⊥-elim (¬b (sym b))\n ... | tri> ¬a ¬b c | tri> ¬a₁ ¬b₁ c₁ = ⊥-elim (nat-<> c c₁)\n\n record Fdec ( i j : ℕ ) : Set where\n field\n ni : ℕ \n nj : ℕ \n fdec : 0 < F ⟪ i , j ⟫ → F ⟪ ni , nj ⟫ < F ⟪ i , j ⟫\n\n fd1 : ( i j k : ℕ ) → i < j → k ≡ j - i → F ⟪ suc i , k ⟫ < F ⟪ suc i , suc j ⟫\n fd1 i j 0 i0 {i} {j} i ¬a ¬b₁ c = ⊥-elim (⊥-elim (¬a i ¬a₁ ¬b c = s≤s z≤n -- i > j\n ... | tri> ¬a ¬b c | tri< a ¬b₁ ¬c = fd4 where\n fd4 : suc i < suc j\n fd4 = s≤s a\n ... | tri> ¬a ¬b c | tri≈ ¬a₁ b ¬c = ⊥-elim (¬a₁ i ¬a ¬b c | tri> ¬a₁ ¬b₁ c₁ = ⊥-elim (¬a₁ i ¬a ¬b c = ⊥-elim ( ¬b refl )\n ... | tri> ¬a ¬b c = record { ni = i - j ; nj = suc j ; fdec = λ lt →\n subst₂ (λ s t → s < t) (Fsym {suc j} {i - j}) (Fsym {suc j} {suc i}) (fd1 j i (i - j) c refl ) } \n\n ind3 : {i j : ℕ } → i < j \n → Dividable (gcd (suc i) (j - i)) (suc i) \n → Dividable (gcd (suc i) (suc j)) (suc i) \n ind3 {i} {j} a prev = \n subst (λ k → Dividable k (suc i)) ( begin\n gcd (suc i) (j - i) ≡⟨ gcdsym {suc i} {j - i} ⟩\n gcd (j - i ) (suc i) ≡⟨ sym (gcd+j (j - i) (suc i)) ⟩\n gcd ((j - i) + suc i) (suc i) ≡⟨ cong (λ k → gcd k (suc i)) ( begin\n (suc j - suc i) + suc i ≡⟨ minus+n {suc j} {suc i} (<-trans ( s≤s a) a ¬a ¬b c = ⟪ ind8 c (proj1 prev) (proj2 prev) , ind10 c (proj2 prev) ⟫ where\n ind9 : {i j : ℕ} → i < j → gcd (j - i) (suc i) ≡ gcd (suc j) (suc i)\n ind9 {i} {j} i0 : { k i : ℕ } → (d : Dividable k i ) → 0 < i → 0 < Dividable.factor d \nf-div>0 {k} {i} d 00 d (s≤s z≤n)) ⟩\n gcd (suc i) (suc j) * f ≡⟨ +-comm 0 _ ⟩\n gcd (suc i) (suc j) * f + 0 ≡⟨ cong (λ k → k + 0) (*-comm (gcd (suc i) (suc j)) _ ) ⟩\n Dividable.factor (proj1 (gcd-dividable (suc i) (suc j))) * gcd (suc i) (suc j) + 0 ≡⟨ Dividable.is-factor (proj1 (gcd-dividable (suc i) (suc j))) ⟩\n suc i ∎ where\n d = proj1 (gcd-dividable (suc i) (suc j))\n f = Dividable.factor (proj1 (gcd-dividable (suc i) (suc j)))\n open ≤-Reasoning\n\ngcd-≤ : { i j : ℕ } → 0 < i → 0 < j → gcd i j ≤ i\ngcd-≤ {i} {j} 0 ¬a ¬b c = ≤-trans (subst (λ k → k ≤ j) (gcdsym {j} {i}) (gcd-≤i j i 0 eqb * j → (eqa * i) - (eqb * j) ≡ gcd \n is-equ> : eqb * j > eqa * i → (eqb * j) - (eqa * i) ≡ gcd \n is-equ= : eqa * i ≡ eqb * j → 0 ≡ gcd \n\nge3 : {a b c d : ℕ } → b > a → b - a ≡ d - c → d > c\nge3 {a} {b} {c} {d} b>a eq = minus>0→x0 b>a))\n\nge01 : ( i0 j j0 ea eb : ℕ ) \n → ( di : GCD 0 (suc i0) (suc (suc j)) j0 )\n → (((ea + eb * (Dividable.factor (GCD.div-i di))) * suc i0) ≡ (ea * suc i0) + (eb * (Dividable.factor (GCD.div-i di)) ) * suc i0 )\n ∧ ( (eb * j0) ≡ (eb * suc (suc j) + (eb * (Dividable.factor (GCD.div-i di)) ) * suc i0) )\nge01 i0 j j0 ea eb di = ⟪ ge011 , ge012 ⟫ where\n f = Dividable.factor (GCD.div-i di)\n ge4 : suc (j0 + 0) > suc (suc j)\n ge4 = subst (λ k → k > suc (suc j)) (+-comm 0 _ ) ( s≤s (GCD.j = λ () ; is-equ= = ge21 } where\n ge21 : 1 * i0 ≡ 0 * j0 → 0 ≡ i0\n ge21 eq = trans (sym eq) (+-comm i0 0) \n... | tri≈ ¬a refl ¬c = record { eqa = 1 ; eqb = 0 ; is-equ< = λ _ → +-comm _ 0 ; is-equ> = λ () ; is-equ= = λ eq → trans (sym eq) (+-comm i0 0) } \n... | tri> ¬a ¬b c = record { eqa = 0 ; eqb = 1 ; is-equ< = λ () ; is-equ> = λ _ → +-comm _ 0 ; is-equ= = ge22 } where\n ge22 : 0 * i0 ≡ 1 * j0 → 0 ≡ j0\n ge22 eq = trans eq (+-comm j0 0) \n-- i = λ _ → ge6\n ; is-equ= = λ eq → ⊥-elim (nat-≡< (sym (minus<=0 (subst (λ k → k ≤ 1 * i0) eq refl-≤ ))) (subst (λ k → 0 < k) (sym ge6) a Dividable.factor (GCD.div-j di) * j0 )\n ge7 lt = ⊥-elim ( nat-≡< (sym ( minus<=0 ( = λ _ → +-comm _ 0\n ; is-equ= = λ eq → subst (λ k → 0 ≡ k) (+-comm _ 0) eq } \ngcd-euclid1 zero (suc i0) (suc (suc j)) j0 di with gcd-euclid1 i0 (suc i0) (suc j) (suc (suc j)) ( gcd-next1 di )\n... | e = record { eqa = ea + eb * f ; eqb = eb \n ; is-equ= = λ eq → Euclid.is-equ= e (ge23 eq) \n ; is-equ< = λ lt → subst (λ k → ((ea + eb * f) * suc i0) - (eb * j0) ≡ k ) (Euclid.is-equ< e (ge3 lt (ge1 ))) (ge1 )\n ; is-equ> = λ lt → subst (λ k → (eb * j0) - ((ea + eb * f) * suc i0) ≡ k ) (Euclid.is-equ> e (ge3 lt (ge2 ))) (ge2 ) } where\n ea = Euclid.eqa e \n eb = Euclid.eqb e\n f = Dividable.factor (GCD.div-i di)\n ge1 : ((ea + eb * f) * suc i0) - (eb * j0) ≡ (ea * suc i0) - (eb * suc (suc j)) \n ge1 = begin\n ((ea + eb * f) * suc i0) - (eb * j0) ≡⟨ cong₂ (λ j k → j - k ) (proj1 (ge01 i0 j j0 ea eb di)) (proj2 (ge01 i0 j j0 ea eb di)) ⟩\n (ea * suc i0 + (eb * f ) * suc i0 ) - ( eb * suc (suc j) + ((eb * f) * (suc i0)) ) ≡⟨ minus+xy-zy {ea * suc i0} {(eb * f ) * suc i0} {eb * suc (suc j)} ⟩\n (ea * suc i0) - (eb * suc (suc j)) ∎ where open ≡-Reasoning\n ge2 : (eb * j0) - ((ea + eb * f) * suc i0) ≡ (eb * suc (suc j)) - (ea * suc i0)\n ge2 = begin\n (eb * j0) - ((ea + eb * f) * suc i0) ≡⟨ cong₂ (λ j k → j - k ) (proj2 (ge01 i0 j j0 ea eb di)) (proj1 (ge01 i0 j j0 ea eb di)) ⟩\n ( eb * suc (suc j) + ((eb * f) * (suc i0)) ) - (ea * suc i0 + (eb * f ) * suc i0 ) ≡⟨ minus+xy-zy {eb * suc (suc j)}{(eb * f ) * suc i0} {ea * suc i0} ⟩\n (eb * suc (suc j)) - (ea * suc i0) ∎ where open ≡-Reasoning\n ge23 : (ea + eb * f) * suc i0 ≡ eb * j0 → ea * suc i0 ≡ eb * suc (suc j)\n ge23 eq = begin\n ea * suc i0 ≡⟨ sym (minus+y-y {_} {(eb * f ) * suc i0} ) ⟩\n (ea * suc i0 + ((eb * f ) * suc i0 )) - ((eb * f ) * suc i0 ) ≡⟨ cong (λ k → k - ((eb * f ) * suc i0 )) (sym ( proj1 (ge01 i0 j j0 ea eb di))) ⟩\n ((ea + eb * f) * suc i0) - ((eb * f ) * suc i0 ) ≡⟨ cong (λ k → k - ((eb * f ) * suc i0 )) eq ⟩\n (eb * j0) - ((eb * f ) * suc i0 ) ≡⟨ cong (λ k → k - ((eb * f ) * suc i0 )) ( proj2 (ge01 i0 j j0 ea eb di)) ⟩\n (eb * suc (suc j) + ((eb * f ) * suc i0 )) - ((eb * f ) * suc i0 ) ≡⟨ minus+y-y {_} {(eb * f ) * suc i0 } ⟩\n eb * suc (suc j) ∎ where open ≡-Reasoning\ngcd-euclid1 (suc zero) i0 zero j0 di = record { eqb = 1 ; eqa = Dividable.factor (GCD.div-i di) ; is-equ> = λ lt → ⊥-elim ( ge7' lt) ; is-equ< = λ _ → ge6'\n ; is-equ= = λ eq → ⊥-elim (nat-≡< (sym (minus<=0 (subst (λ k → k ≤ 1 * j0) (sym eq) refl-≤ ))) (subst (λ k → 0 < k) (sym ge6') a Dividable.factor (GCD.div-i di) * i0 )\n ge7' lt = ⊥-elim ( nat-≡< (sym ( minus<=0 ( = λ () ; is-equ< = λ _ → +-comm _ 0\n ; is-equ= = λ eq → subst (λ k → 0 ≡ k) (+-comm _ 0) (sym eq) }\ngcd-euclid1 (suc (suc i)) i0 zero (suc j0) di with gcd-euclid1 (suc i) (suc (suc i)) j0 (suc j0) (GCD-sym (gcd-next1 (GCD-sym di)))\n... | e = record { eqa = ea ; eqb = eb + ea * f\n ; is-equ= = λ eq → Euclid.is-equ= e (ge24 eq)\n ; is-equ< = λ lt → subst (λ k → ((ea * i0) - ((eb + ea * f) * suc j0)) ≡ k ) (Euclid.is-equ< e (ge3 lt ge4)) ge4 \n ; is-equ> = λ lt → subst (λ k → (((eb + ea * f) * suc j0) - (ea * i0)) ≡ k ) (Euclid.is-equ> e (ge3 lt ge5)) ge5 } where\n ea = Euclid.eqa e \n eb = Euclid.eqb e\n f = Dividable.factor (GCD.div-j di)\n ge5 : (((eb + ea * f) * suc j0) - (ea * i0)) ≡ ((eb * suc j0) - (ea * suc (suc i)))\n ge5 = begin\n ((eb + ea * f) * suc j0) - (ea * i0) ≡⟨ cong₂ (λ j k → j - k ) (proj1 (ge01 j0 i i0 eb ea (GCD-sym di) )) (proj2 (ge01 j0 i i0 eb ea (GCD-sym di) )) ⟩\n ( eb * suc j0 + (ea * f )* suc j0) - (ea * suc (suc i) + (ea * f )* suc j0) ≡⟨ minus+xy-zy {_} {(ea * f )* suc j0} {ea * suc (suc i)} ⟩\n (eb * suc j0) - (ea * suc (suc i)) ∎ where open ≡-Reasoning\n ge4 : ((ea * i0) - ((eb + ea * f) * suc j0)) ≡ ((ea * suc (suc i)) - (eb * suc j0))\n ge4 = begin\n (ea * i0) - ((eb + ea * f) * suc j0) ≡⟨ cong₂ (λ j k → j - k ) (proj2 (ge01 j0 i i0 eb ea (GCD-sym di) )) (proj1 (ge01 j0 i i0 eb ea (GCD-sym di) )) ⟩\n (ea * suc (suc i) + (ea * f )* suc j0) - ( eb * suc j0 + (ea * f )* suc j0) ≡⟨ minus+xy-zy {ea * suc (suc i)} {(ea * f )* suc j0} { eb * suc j0} ⟩\n (ea * suc (suc i)) - (eb * suc j0) ∎ where open ≡-Reasoning\n ge24 : ea * i0 ≡ (eb + ea * f) * suc j0 → ea * suc (suc i) ≡ eb * suc j0\n ge24 eq = begin\n ea * suc (suc i) ≡⟨ sym ( minus+y-y {_} {(ea * f ) * suc j0 }) ⟩\n (ea * suc (suc i) + (ea * f ) * suc j0 ) - ((ea * f ) * suc j0) ≡⟨ cong (λ k → k - ((ea * f ) * suc j0 )) (sym (proj2 (ge01 j0 i i0 eb ea (GCD-sym di) ))) ⟩\n (ea * i0) - ((ea * f ) * suc j0) ≡⟨ cong (λ k → k - ((ea * f ) * suc j0 )) eq ⟩\n ((eb + ea * f) * suc j0) - ((ea * f ) * suc j0) ≡⟨ cong (λ k → k - ((ea * f ) * suc j0 )) ((proj1 (ge01 j0 i i0 eb ea (GCD-sym di)))) ⟩\n ( eb * suc j0 + (ea * f ) * suc j0 ) - ((ea * f ) * suc j0) ≡⟨ minus+y-y {_} {(ea * f ) * suc j0 } ⟩\n eb * suc j0 ∎ where open ≡-Reasoning\ngcd-euclid1 (suc zero) i0 (suc j) j0 di =\n gcd-euclid1 zero i0 j j0 (gcd-next di)\ngcd-euclid1 (suc (suc i)) i0 (suc j) j0 di = \n gcd-euclid1 (suc i) i0 j j0 (gcd-next di)\n\nge12 : (p x : ℕ) → 0 < x → 1 < p → ((i : ℕ ) → i < p → 0 < i → gcd p i ≡ 1) → ( gcd p x ≡ 1 ) ∨ ( Dividable p x )\nge12 p x 0 a (s≤s (gcd>0 p x (<-trans a ¬a ¬b c = ⊥-elim ( nat-≡< (sym (prime (gcd p x) ge13 ( ¬a ¬b c = ⊥-elim ( nat-≤> (gcd-≤ (<-trans a 1\n ge18 = subst (λ k → 1 < k ) (sym (div→gcd {p} {gcd p x} c ge19 )) c\n\ngcd-euclid : ( p a b : ℕ ) → 1 < p → 0 < a → 0 < b → ((i : ℕ ) → i < p → 0 < i → gcd p i ≡ 1) → Dividable p (a * b) → Dividable p a ∨ Dividable p b\ngcd-euclid p a b 1

( eb * a ) → ((b * ea) - (f * eb)) * p + 0 ≡ b\n ge14 lt = begin\n (((b * ea) - (f * eb)) * p) + 0 ≡⟨ +-comm _ 0 ⟩\n ((b * ea) - ((f * eb)) * p) ≡⟨ distr-minus-* {_} {f * eb} {p} ⟩\n ((b * ea) * p) - (((f * eb) * p)) ≡⟨ cong (λ k → ((b * ea) * p) - k ) ge18 ⟩\n ((b * ea) * p) - (b * (a * eb )) ≡⟨ cong (λ k → k - (b * (a * eb)) ) (*-assoc b _ p) ⟩\n (b * (ea * p)) - (b * (a * eb )) ≡⟨ sym ( distr-minus-*' {b} {ea * p} {a * eb} ) ⟩\n b * (( ea * p) - (a * eb) ) ≡⟨ cong (λ k → b * ( ( ea * p) - k)) (*-comm a (eb)) ⟩\n (b * ( (ea * p)) - (eb * a) ) ≡⟨ cong (b *_) (Euclid.is-equ< ge11 lt )⟩\n b * gcd p a ≡⟨ cong (b *_) ge10 ⟩\n b * 1 ≡⟨ m*1=m ⟩\n b ∎ where open ≡-Reasoning\n ge15 : ( ea * p ) < ( eb * a ) → ((f * eb) - (b * ea ) ) * p + 0 ≡ b\n ge15 lt = begin\n ((f * eb) - (b * ea) ) * p + 0 ≡⟨ +-comm _ 0 ⟩\n ((f * eb) - (b * ea) ) * p ≡⟨ distr-minus-* {_} {b * ea} {p} ⟩\n ((f * eb) * p) - ((b * ea) * p) ≡⟨ cong (λ k → k - ((b * ea) * p) ) ge18 ⟩\n (b * (a * eb )) - ((b * ea) * p ) ≡⟨ cong (λ k → (b * (a * eb)) - k ) (*-assoc b _ p) ⟩\n (b * (a * eb )) - (b * (ea * p) ) ≡⟨ sym ( distr-minus-*' {b} {a * eb} {ea * p} ) ⟩\n b * ( (a * eb) - (ea * p) ) ≡⟨ cong (λ k → b * ( k - ( ea * p) )) (*-comm a (eb)) ⟩\n b * ( (eb * a) - (ea * p) ) ≡⟨ cong (b *_) (Euclid.is-equ> ge11 lt) ⟩\n b * gcd p a ≡⟨ cong (b *_) ge10 ⟩\n b * 1 ≡⟨ m*1=m ⟩\n b ∎ where open ≡-Reasoning\n ge17 : (x y : ℕ ) → x ≡ y → x ≤ y\n ge17 x x refl = refl-≤\n ge16 : Dividable p b\n ge16 with <-cmp ( ea * p ) ( eb * a )\n ... | tri< a ¬b ¬c = record { factor = (f * eb) - (b * ea) ; is-factor = ge15 a }\n ... | tri≈ ¬a eq ¬c = record { factor = (b * ea) - ( f * eb) ; is-factor = ge19 eq }\n ... | tri> ¬a ¬b c = record { factor = (b * ea) - (f * eb) ; is-factor = ge14 c } \n\n\n\ngcdmul+1 : ( m n : ℕ ) → gcd (m * n + 1) n ≡ 1\ngcdmul+1 zero n = gcd204 n\ngcdmul+1 (suc m) n = begin\n gcd (suc m * n + 1) n ≡⟨⟩\n gcd (n + m * n + 1) n ≡⟨ cong (λ k → gcd k n ) (begin\n n + m * n + 1 ≡⟨ cong (λ k → k + 1) (+-comm n _) ⟩\n m * n + n + 1 ≡⟨ +-assoc (m * n) _ _ ⟩\n m * n + (n + 1) ≡⟨ cong (λ k → m * n + k) (+-comm n _) ⟩\n m * n + (1 + n) ≡⟨ sym ( +-assoc (m * n) _ _ ) ⟩\n m * n + 1 + n ∎ \n ) ⟩\n gcd (m * n + 1 + n) n ≡⟨ gcd+j (m * n + 1) n ⟩\n gcd (m * n + 1) n ≡⟨ gcdmul+1 m n ⟩\n 1 ∎ where open ≡-Reasoning\n\nm*n=m→n : {m n : ℕ } → 0 < m → m * n ≡ m * 1 → n ≡ 1\nm*n=m→n {suc m} {n} (s≤s lt) eq = *-cancelˡ-≡ m eq \n\n", "meta": {"hexsha": "6d0919825d4923f005613119e17436c6c8df4e91", "size": 39670, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/gcd.agda", "max_stars_repo_name": "shinji-kono/automaton-in-agda", "max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/gcd.agda", "max_issues_repo_name": "shinji-kono/automaton-in-agda", "max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/gcd.agda", "max_forks_repo_name": "shinji-kono/automaton-in-agda", "max_forks_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 56.7525035765, "max_line_length": 165, "alphanum_fraction": 0.4469372322, "num_tokens": 18378, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9099070060380482, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.6086188411180687}} {"text": "open import Haskell.Prelude\n\nmutual\n\n data Map (k : Set) (a : Set) : Set where\n Bin : (sz : Nat) → (kx : k) → (x : a)\n → (l : Map k a) → (r : Map k a)\n → {{szVal : sz ≡ (size l) + (size r) + 1}}\n → Map k a\n Tip : Map k a\n {-# COMPILE AGDA2HS Map #-}\n\n size : {k a : Set} → Map k a → Nat\n size Tip = 0\n size (Bin sz _ _ _ _) = sz\n {-# COMPILE AGDA2HS size #-}\n", "meta": {"hexsha": "997e717b466d692129dde9de9042e2199ecaaa35", "size": 398, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Issue69.agda", "max_stars_repo_name": "dxts/agda2hs", "max_stars_repo_head_hexsha": "8c8f24a079ed9677dbe6893cf786e7ed52dfe8b6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 55, "max_stars_repo_stars_event_min_datetime": "2020-10-20T13:36:25.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T21:57:56.000Z", "max_issues_repo_path": "test/Issue69.agda", "max_issues_repo_name": "seanpm2001/agda2hs", "max_issues_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 63, "max_issues_repo_issues_event_min_datetime": "2020-10-22T05:19:27.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-25T15:47:30.000Z", "max_forks_repo_path": "test/Issue69.agda", "max_forks_repo_name": "seanpm2001/agda2hs", "max_forks_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 18, "max_forks_repo_forks_event_min_datetime": "2020-10-21T22:19:09.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:42:52.000Z", "avg_line_length": 23.4117647059, "max_line_length": 52, "alphanum_fraction": 0.4623115578, "num_tokens": 156, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9099069987088003, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.6086188302097453}} {"text": "{-\n\nSome theory about Bi-Invertible Equivalences\n\n- BiInvEquiv to Iso\n- BiInvEquiv to Equiv\n- BiInvEquiv to HAEquiv\n- Iso to BiInvEquiv\n\n-}\n{-# OPTIONS --cubical --safe #-}\nmodule Cubical.Foundations.BiInvEquiv where\n\nopen import Cubical.Core.Glue\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.HAEquiv\n\n\nrecord BiInvEquiv {ℓ ℓ'} (A : Type ℓ) (B : Type ℓ') : Type (ℓ-max ℓ ℓ') where\n constructor biInvEquiv\n field\n fun : A → B\n invr : B → A\n invr-rightInv : section fun invr\n invl : B → A\n invl-leftInv : retract fun invl\n\n invr≡invl : ∀ b → invr b ≡ invl b\n invr≡invl b = invr b ≡⟨ sym (invl-leftInv (invr b)) ⟩\n invl (fun (invr b)) ≡⟨ cong invl (invr-rightInv b) ⟩\n invl b ∎\n\n invr-leftInv : retract fun invr\n invr-leftInv a = invr≡invl (fun a) □ (invl-leftInv a)\n\n invr≡invl-leftInv : ∀ a → PathP (λ j → invr≡invl (fun a) j ≡ a) (invr-leftInv a) (invl-leftInv a)\n invr≡invl-leftInv a j i = compPath'-filler (invr≡invl (fun a)) (invl-leftInv a) (~ j) i\n\n invl-rightInv : section fun invl\n invl-rightInv a = sym (cong fun (invr≡invl a)) □ (invr-rightInv a)\n\n invr≡invl-rightInv : ∀ a → PathP (λ j → fun (invr≡invl a j) ≡ a) (invr-rightInv a) (invl-rightInv a)\n invr≡invl-rightInv a j i = compPath'-filler (sym (cong fun (invr≡invl a))) (invr-rightInv a) j i\n\n\nmodule _ {ℓ} {A B : Type ℓ} (e : BiInvEquiv A B) where\n open BiInvEquiv e\n\n biInvEquiv→Iso-right : Iso A B\n Iso.fun biInvEquiv→Iso-right = fun\n Iso.inv biInvEquiv→Iso-right = invr\n Iso.rightInv biInvEquiv→Iso-right = invr-rightInv\n Iso.leftInv biInvEquiv→Iso-right = invr-leftInv\n\n biInvEquiv→Iso-left : Iso A B\n Iso.fun biInvEquiv→Iso-left = fun\n Iso.inv biInvEquiv→Iso-left = invl\n Iso.rightInv biInvEquiv→Iso-left = invl-rightInv\n Iso.leftInv biInvEquiv→Iso-left = invl-leftInv\n\n biInvEquiv→Equiv-right biInvEquiv→Equiv-left : A ≃ B\n biInvEquiv→Equiv-right = fun , isoToIsEquiv biInvEquiv→Iso-right\n biInvEquiv→Equiv-left = fun , isoToIsEquiv biInvEquiv→Iso-left\n\n -- since Iso.rightInv ends up getting modified during iso→HAEquiv, in some sense biInvEquiv→Iso-left\n -- is the most natural choice for forming a HAEquiv from a BiInvEquiv\n biInvEquiv→HAEquiv : HAEquiv A B\n biInvEquiv→HAEquiv = iso→HAEquiv biInvEquiv→Iso-left\n\n\nmodule _ {ℓ} {A B : Type ℓ} (i : Iso A B) where\n open Iso i\n\n iso→BiInvEquiv : BiInvEquiv A B\n BiInvEquiv.fun iso→BiInvEquiv = fun\n BiInvEquiv.invr iso→BiInvEquiv = inv\n BiInvEquiv.invr-rightInv iso→BiInvEquiv = rightInv\n BiInvEquiv.invl iso→BiInvEquiv = inv\n BiInvEquiv.invl-leftInv iso→BiInvEquiv = leftInv\n\n", "meta": {"hexsha": "082ad5be861c82063fca67db3b99b751b895f101", "size": 2811, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Foundations/BiInvEquiv.agda", "max_stars_repo_name": "cj-xu/cubical", "max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Foundations/BiInvEquiv.agda", "max_issues_repo_name": "cj-xu/cubical", "max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Foundations/BiInvEquiv.agda", "max_forks_repo_name": "cj-xu/cubical", "max_forks_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.0705882353, "max_line_length": 102, "alphanum_fraction": 0.6823194593, "num_tokens": 1052, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891479496523, "lm_q2_score": 0.7401743505760728, "lm_q1q2_score": 0.6085633186343286}} {"text": "open import Agda.Builtin.Nat\n\ndata D : Nat → Set where\n c : (n : Nat) → D n\n\nfoo : (m : Nat) → D (suc m) → Nat\nfoo m (c (suc n)) = m + n\n", "meta": {"hexsha": "847b9d231c20943d05d01c298bedda93aa0603e9", "size": 138, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue2896.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue2896.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue2896.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 17.25, "max_line_length": 33, "alphanum_fraction": 0.5289855072, "num_tokens": 60, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9005297754396141, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.6085461444057233}} {"text": "module Structure.Function.Proofs where\n\nimport Lvl\nopen import Functional\nopen import Structure.Function\nopen import Structure.Operator\nopen import Structure.Operator.Properties\nopen import Structure.Setoid\nopen import Syntax.Transitivity\nopen import Type\n\nprivate variable ℓ ℓₑ₁ ℓₑ₂ ℓₑ₃ ℓₑ₄ : Lvl.Level\nprivate variable T A B C D : Type{ℓ}\n\nmodule _\n ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄\n ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄\n ⦃ equiv-C : Equiv{ℓₑ₃}(C) ⦄\n ⦃ equiv-D : Equiv{ℓₑ₄}(D) ⦄\n {f : C → D} ⦃ func : Function(f) ⦄\n {_▫_ : A → B → C} ⦃ oper : BinaryOperator(_▫_) ⦄\n where\n\n [∘₂]-function : BinaryOperator(f ∘₂ (_▫_))\n BinaryOperator.congruence [∘₂]-function = congruence₁(f) ∘₂ congruence₂(_▫_)\n\nmodule _\n ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄\n ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄\n ⦃ equiv-C : Equiv{ℓₑ₃}(C) ⦄\n {_▫_ : A → B → C}\n ⦃ funcₗ : ∀{x} → Function(x ▫_) ⦄\n ⦃ funcᵣ : ∀{y} → Function(_▫ y) ⦄\n where\n\n binaryOperator-from-function : BinaryOperator(_▫_)\n BinaryOperator.congruence binaryOperator-from-function xy1 xy2 = congruence₁(_▫ _) xy1 🝖 congruence₁(_ ▫_) xy2\n\nmodule _\n ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄\n ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄\n {_▫_ : A → A → B}\n ⦃ funcᵣ : ∀{y} → Function(_▫ y) ⦄\n ⦃ comm : Commutativity(_▫_) ⦄\n where\n\n functionₗ-from-commutative-functionᵣ : ∀{x} → Function(x ▫_)\n Function.congruence (functionₗ-from-commutative-functionᵣ{a}) {x}{y} xy = commutativity(_▫_) {a}{x} 🝖 congruence₁(_▫ a) xy 🝖 commutativity(_▫_) {y}{a}\n\nmodule _\n ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄\n ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄\n {_▫_ : A → A → B}\n ⦃ funcᵣ : ∀{x} → Function(x ▫_) ⦄\n ⦃ comm : Commutativity(_▫_) ⦄\n where\n\n functionᵣ-from-commutative-functionₗ : ∀{y} → Function(_▫ y)\n Function.congruence (functionᵣ-from-commutative-functionₗ{a}) {x}{y} xy = commutativity(_▫_) {x}{a} 🝖 congruence₁(a ▫_) xy 🝖 commutativity(_▫_) {a}{y}\n", "meta": {"hexsha": "e37c0f5064a99ad87891fad6bb08d5aa9cf98ad2", "size": 1830, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Function/Proofs.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Function/Proofs.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Function/Proofs.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.5, "max_line_length": 152, "alphanum_fraction": 0.637704918, "num_tokens": 852, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.82893881677331, "lm_q2_score": 0.7341195327172401, "lm_q1q2_score": 0.6085401768208043}} {"text": "\nmodule Product where\n\nopen import Base\nopen import Category\nopen import Unique\nopen import Dual\n\nmodule Prod (ℂ : Cat) where\n\n private\n ℂ' = η-Cat ℂ\n open module C = Cat ℂ'\n open module U = Uniq ℂ'\n\n data _×_ (A B : Obj) : Set1 where\n prod : (AB : Obj)\n\t (π₀ : AB ─→ A)\n\t (π₁ : AB ─→ B) ->\n\t ((X : Obj)(f : X ─→ A)(g : X ─→ B) ->\n\t ∃! \\(h : X ─→ AB) -> π₀ ∘ h == f /\\ π₁ ∘ h == g\n\t ) -> A × B\n\n Product : {A B : Obj} -> A × B -> Obj\n Product (prod AB _ _ _) = AB\n\n π₀ : {A B : Obj}(p : A × B) -> Product p ─→ A\n π₀ (prod _ p _ _) = p\n\n π₁ : {A B : Obj}(p : A × B) -> Product p ─→ B\n π₁ (prod _ _ q _) = q\n\nmodule Sum (ℂ : Cat) = Prod (η-Cat ℂ op)\n renaming ( _×_ to _+_\n\t ; prod to sum\n\t ; Product to Sum\n\t ; π₀ to inl\n\t ; π₁ to inr\n\t )\n\n", "meta": {"hexsha": "216685119fee4c540020c7a8da72d038c0e51e15", "size": 810, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/cat/Product.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "examples/outdated-and-incorrect/cat/Product.agda", "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/cat/Product.agda", "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 19.756097561, "max_line_length": 52, "alphanum_fraction": 0.4617283951, "num_tokens": 333, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9241418158002492, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.6084711445237354}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties related to propositional list membership, that rely on\n-- the K rule\n------------------------------------------------------------------------\n\n{-# OPTIONS --with-K --safe #-}\n\nmodule Data.List.Membership.Propositional.Properties.WithK where\n\nopen import Data.List.Base\nopen import Data.List.Relation.Unary.Unique.Propositional\nopen import Data.List.Membership.Propositional\nimport Data.List.Membership.Setoid.Properties as Membershipₛ\nopen import Relation.Unary using (Irrelevant)\nopen import Relation.Binary.PropositionalEquality as P using (_≡_)\nopen import Relation.Binary.PropositionalEquality.WithK\n\n------------------------------------------------------------------------\n-- Irrelevance\n\nunique⇒irrelevant : ∀ {a} {A : Set a} {xs : List A} →\n Unique xs → Irrelevant (_∈ xs)\nunique⇒irrelevant = Membershipₛ.unique⇒irrelevant (P.setoid _) ≡-irrelevant\n", "meta": {"hexsha": "5909ec3e723ad7c5287c22ffe2ff9bda01100461", "size": 994, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/List/Membership/Propositional/Properties/WithK.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Data/List/Membership/Propositional/Properties/WithK.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Data/List/Membership/Propositional/Properties/WithK.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 38.2307692308, "max_line_length": 75, "alphanum_fraction": 0.5935613682, "num_tokens": 199, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8740772351648678, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.6083213230231229}} {"text": "module Data.ListSized.Functions where\n\nimport Lvl\nopen import Data.ListSized\nopen import Functional\nopen import Numeral.Finite\nopen import Numeral.Natural\nopen import Numeral.Natural.Function\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.Oper.Proofs\nopen import Type\n\nprivate variable ℓ ℓ₁ ℓ₂ : Lvl.Level\nprivate variable T A A₁ A₂ B B₁ B₂ Result : Type{ℓ}\nprivate variable a b n n₁ n₂ : ℕ\n\n-- List concatenation\n_++_ : List(T)(a) → List(T)(b) → List(T)(a + b)\n_++_ x y = elim _ (\\{a} → const(List _ (a + _))) y (const ∘ (_⊰_)) x\ninfixl 1000 _++_\n\n-- The first element of the list\nhead : List(T)(𝐒(n)) → T\nhead (x ⊰ _) = x\n\n-- The list without its first element\ntail : List(T)(𝐒(n)) → List(T)(n)\ntail (_ ⊰ l) = l\n\ntail₀ : List(T)(n) → List(T)(𝐏(n))\ntail₀ ∅ = ∅\ntail₀ (_ ⊰ l) = l\n\n-- The nth element in the list\nindex : 𝕟(n) → List(T)(n) → T\nindex 𝟎 (x ⊰ _) = x\nindex (𝐒(n)) (_ ⊰ l) = index n l\n\n-- The sublist with the first n elements in the list\nfirst : (k : 𝕟₌(n)) → List(T)(n) → List(T)(𝕟-to-ℕ k)\nfirst 𝟎 _ = ∅\nfirst (𝐒(n)) (x ⊰ l) = x ⊰ (first n l)\n\n-- skip : ∀{n} → (k : 𝕟₌(n)) → List(T)(n) → List(T)(n − k)\n-- last : ∀{n} → (k : 𝕟₌(n)) → List(T)(n) → List(T)(𝕟-to-ℕ k)\n\n-- Length of the list (number of elements in the list)\nlength : List(T)(n) → ℕ\nlength {n = n} _ = n\n\n-- The list with an element repeated n times\nrepeat : T → (n : ℕ) → List(T)(n)\nrepeat _ 𝟎 = ∅\nrepeat x (𝐒(n)) = x ⊰ (repeat x n)\n\n-- A list constructed from a function\nfromFn : (𝕟(n) → T) → List(T)(n)\nfromFn {n = 𝟎} _ = ∅\nfromFn {n = 𝐒(n)} f = f(𝟎) ⊰ fromFn {n = n} (f ∘ 𝐒)\n\n-- The list with a list concatenated (repeated) n times\n_++^_ : List(T)(n) → (k : ℕ) → List(T)(n ⋅ k)\n_++^_ _ 𝟎 = ∅\n_++^_ l (𝐒(k)) = l ++ (l ++^ k)\n\n-- Applies a function to each element in the list\nmap : (A → B) → List(A)(n) → List(B)(n)\nmap f = elim _ (\\{n} _ → List(_)(n)) ∅ (const ∘ (_⊰_) ∘ f)\n\n-- Applies a binary operator to each element in the list starting with the initial element.\n-- Example:\n-- foldₗ(▫)(init)[] = init\n-- foldₗ(▫)(init)[a] = init▫a\n-- foldₗ(▫)(init)[a,b] = (init▫a)▫b\n-- foldₗ(▫)(init)[a,b,c,d,e] = ((((init▫a)▫b)▫c)▫d)▫e\nfoldₗ : (Result → T → Result) → Result → List(T)(n) → Result\nfoldₗ _ result ∅ = result\nfoldₗ(_▫_) result (elem ⊰ l) = foldₗ(_▫_) (result ▫ elem) l\n\n-- Applies a binary operator to each element in the list starting with the initial element.\n-- Example:\n-- foldᵣ(▫)(init)[] = init\n-- foldᵣ(▫)(init)[a] = a▫init\n-- foldᵣ(▫)(init)[a,b] = a▫(b▫init)\n-- foldᵣ(▫)(init)[a,b,c,d,e] = a▫(b▫(c▫(d▫(e▫init))))\nfoldᵣ : (T → Result → Result) → Result → List(T)(n) → Result\nfoldᵣ(_▫_) init = elim _ _ init (const ∘ (_▫_))\n\n-- Example:\n-- reduceₗ(▫)[a] = a\n-- reduceₗ(▫)[a,b] = a▫b\n-- reduceₗ(▫)[a,b,c] = (a▫b)▫c\n-- reduceₗ(▫)[a,b,c,d,e] = (((a▫b)▫c)▫d)▫e\nreduceₗ : (T → T → T) → List(T)(𝐒(n)) → T\nreduceₗ(_▫_) (elem ⊰ l) = foldₗ(_▫_) elem l\n\n-- Example:\n-- reduceᵣ(▫)[a] = a\n-- reduceᵣ(▫)[a,b] = a▫b\n-- reduceᵣ(▫)[a,b,c] = a▫(b▫c)\n-- reduceᵣ(▫)[a,b,c,d,e] = a▫(b▫(c▫(d▫e)))\nreduceᵣ : (T → T → T) → List(T)(𝐒(n)) → T\nreduceᵣ(_▫_) (elem ⊰ l) = foldᵣ(_▫_) elem l\n\nmap₂ : (A₁ → A₂ → B) → (List(A₁)(n₁) → List(B)(n₁)) → (List(A₂)(n₂) → List(B)(n₂)) → (List(A₁)(n₁) → List(A₂)(n₂) → List(B)(max n₁ n₂))\nmap₂ f g₁ g₂ ∅ ∅ = ∅\nmap₂ f g₁ g₂ ∅ l₂@(_ ⊰ _) = g₂ l₂\nmap₂ f g₁ g₂ l₁@(_ ⊰ _) ∅ = g₁ l₁\nmap₂ f g₁ g₂ (x₁ ⊰ l₁) (x₂ ⊰ l₂) = f x₁ x₂ ⊰ map₂ f (tail ∘ g₁ ∘ (x₁ ⊰_)) ((tail ∘ g₂ ∘ (x₂ ⊰_))) l₁ l₂\n\nmap₂₌ : (A₁ → A₂ → B) → (List(A₁)(n) → List(A₂)(n) → List(B)(n))\nmap₂₌ f ∅ ∅ = ∅\nmap₂₌ f (x₁ ⊰ l₁) (x₂ ⊰ l₂) = f x₁ x₂ ⊰ map₂₌ f l₁ l₂\n\n-- Accumulates the results of every step in `_^_` into a list.\n-- Example:\n-- accumulateIterate₀ 0 f(x) = []\n-- accumulateIterate₀ 1 f(x) = [x]\n-- accumulateIterate₀ 2 f(x) = [x , f(x)]\n-- accumulateIterate₀ 3 f(x) = [x , f(x) , f(f(x))]\n-- accumulateIterate₀ 4 f(x) = [x , f(x) , f(f(x)) , f(f(f(x)))]\naccumulateIterate₀ : (n : ℕ) → (T → T) → (T → List(T)(n))\naccumulateIterate₀ 𝟎 f(x) = ∅\naccumulateIterate₀ (𝐒(n)) f(x) = x ⊰ accumulateIterate₀ n f (f(x))\n\n-- Accumulates the results of every step in `_^_` into a list.\n-- Example:\n-- accumulateIterate 0 f(x) = [x]\n-- accumulateIterate 1 f(x) = [x , f(x)]\n-- accumulateIterate 2 f(x) = [x , f(x) , f(f(x))]\n-- accumulateIterate 3 f(x) = [x , f(x) , f(f(x)) , f(f(f(x)))]\n-- accumulateIterate 4 f(x) = [x , f(x) , f(f(x)) , f(f(f(x))) , f(f(f(f(x))))]\naccumulateIterate : (n : ℕ) → (T → T) → (T → List(T)(𝐒(n)))\naccumulateIterate n = accumulateIterate₀(𝐒(n))\n", "meta": {"hexsha": "46660575cc8ee23fea43d425bcb3b46545037974", "size": 4682, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/ListSized/Functions.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/ListSized/Functions.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/ListSized/Functions.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.6814814815, "max_line_length": 135, "alphanum_fraction": 0.5322511747, "num_tokens": 2099, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085808877581, "lm_q2_score": 0.7745833737577158, "lm_q1q2_score": 0.6082869700249237}} {"text": "{-# OPTIONS --cubical #-}\nmodule Multidimensional.Data.Dir.Base where\n\nopen import Cubical.Core.Primitives\n\n-- \"Direction\" type for determining direction in spatial structures.\n-- We interpret ↓ as 0 and ↑ as 1 when used in numerals in\n-- numerical types.\ndata Dir : Type₀ where\n ↓ : Dir\n ↑ : Dir\n\ncaseDir : ∀ {ℓ} → {A : Type ℓ} → (ad au : A) → Dir → A\ncaseDir ad au ↓ = ad\ncaseDir ad au ↑ = au\n", "meta": {"hexsha": "48ec0b1ae766bf52c2e96f964570f9039c33f10a", "size": 397, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Multidimensional/Data/Dir/Base.agda", "max_stars_repo_name": "wrrnhttn/agda-cubical-multidimensional", "max_stars_repo_head_hexsha": "55709dd950e319c4a105ace33ddaf8b955354add", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Multidimensional/Data/Dir/Base.agda", "max_issues_repo_name": "wrrnhttn/agda-cubical-multidimensional", "max_issues_repo_head_hexsha": "55709dd950e319c4a105ace33ddaf8b955354add", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-06-19T20:40:07.000Z", "max_issues_repo_issues_event_max_datetime": "2019-07-02T16:24:01.000Z", "max_forks_repo_path": "Multidimensional/Data/Dir/Base.agda", "max_forks_repo_name": "wrrnhttn/agda-cubical-multidimensional", "max_forks_repo_head_hexsha": "55709dd950e319c4a105ace33ddaf8b955354add", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.8125, "max_line_length": 68, "alphanum_fraction": 0.6649874055, "num_tokens": 120, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8824278757303677, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.6082624855168377}} {"text": "\nmodule Control.Monad.Identity where\n\nopen import Prelude\nopen import Container.Foldable\nopen import Container.Traversable\n\nrecord Identity {a} (A : Set a) : Set a where\n constructor mkIdentity\n field\n runIdentity : A\n\nopen Identity public\n\ninstance\n FunctorId : ∀ {a} → Functor (Identity {a})\n runIdentity (fmap {{FunctorId}} f m) = f (runIdentity m)\n\n ApplicativeId : ∀ {a} → Applicative (Identity {a})\n runIdentity (pure {{ApplicativeId}} x) = x\n runIdentity (_<*>_ {{ApplicativeId}} mf mx) = runIdentity mf (runIdentity mx)\n\n MonadId : ∀ {a} → Monad (Identity {a})\n _>>=_ {{MonadId}} m f = f (runIdentity m)\n\n FunctorId′ : ∀ {a b} → Functor′ {a} {b} Identity\n runIdentity (fmap′ {{FunctorId′}} f m) = f (runIdentity m)\n\n ApplicativeId′ : ∀ {a b} → Applicative′ {a} {b} Identity\n runIdentity (_<*>′_ {{ApplicativeId′}} mf mx) = runIdentity mf (runIdentity mx)\n\n MonadId′ : ∀ {a b} → Monad′ {a} {b} Identity\n _>>=′_ {{MonadId′}} m f = f (runIdentity m)\n\n FoldableId : ∀ {a w} → Foldable {w = w} (Identity {a})\n foldMap {{FoldableId}} f m = f (runIdentity m)\n\n TraversableId : ∀ {a} → Traversable (Identity {a})\n traverse {{TraversableId}} f m = pure mkIdentity <*> f (runIdentity m)\n", "meta": {"hexsha": "861ceac126452c5a7272fad4afb1f3d65a9890ac", "size": 1207, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Control/Monad/Identity.agda", "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 111, "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_issues_repo_path": "src/Control/Monad/Identity.agda", "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_forks_repo_path": "src/Control/Monad/Identity.agda", "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "avg_line_length": 30.175, "max_line_length": 81, "alphanum_fraction": 0.6487158244, "num_tokens": 395, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278695464501, "lm_q2_score": 0.6893056104028797, "lm_q1q2_score": 0.6082624812542285}} {"text": "\nmodule Logic.Equivalence where\n\nimport Logic.Relations\nopen Logic.Relations\n\nrecord Equivalence (A : Set) : Set1 where\n field\n _==_ : Rel A\n refl : Reflexive _==_\n sym : Symmetric _==_\n trans : Transitive _==_\n\n", "meta": {"hexsha": "3b73efb29af6afb40f7b47e7668b6959ecf405ed", "size": 231, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Equivalence.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Equivalence.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Equivalence.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 16.5, "max_line_length": 41, "alphanum_fraction": 0.658008658, "num_tokens": 70, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9046505351008906, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.6082252373673195}} {"text": "module RMonads where\n\nopen import Library\nopen import Categories\nopen import Functors\n\n\nrecord RMonad {a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}(J : Fun C D) : \n Set (a ⊔ b ⊔ c ⊔ d) where\n constructor rmonad\n open Cat\n open Fun\n field T : Obj C → Obj D\n η : ∀{X} → Hom D (OMap J X) (T X)\n bind : ∀{X Y} → Hom D (OMap J X) (T Y) → Hom D (T X) (T Y)\n law1 : ∀{X} → bind (η {X}) ≅ iden D {T X}\n law2 : ∀{X Y}{f : Hom D (OMap J X) (T Y)} → comp D (bind f) η ≅ f\n law3 : ∀{X Y Z}\n {f : Hom D (OMap J X) (T Y)}{g : Hom D (OMap J Y) (T Z)} →\n bind (comp D (bind g) f) ≅ comp D (bind g) (bind f)\n\nopen import Functors\n\nTFun : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}{J : Fun C D} → \n RMonad J → Fun C D\nTFun {C = C}{D}{J} M = let open RMonad M; open Cat; open Fun in record { \n OMap = T; \n HMap = bind ∘ comp D η ∘ HMap J; \n fid = \n proof \n bind (comp D η (HMap J (iden C)))\n ≅⟨ cong (bind ∘ comp D η) (fid J) ⟩ \n bind (comp D η (iden D))\n ≅⟨ cong bind (idr D) ⟩ \n bind η\n ≅⟨ law1 ⟩ \n iden D \n ∎;\n fcomp = λ{_ _ _ f g} → \n proof\n bind (comp D η (HMap J (comp C f g))) \n ≅⟨ cong (bind ∘ comp D η) (fcomp J) ⟩\n bind (comp D η (comp D (HMap J f) (HMap J g)))\n ≅⟨ cong bind (sym (ass D)) ⟩\n bind (comp D (comp D η (HMap J f)) (HMap J g))\n ≅⟨ cong (λ f → bind (comp D f (HMap J g))) (sym law2) ⟩\n bind (comp D (comp D (bind (comp D η (HMap J f))) η) (HMap J g))\n ≅⟨ cong bind (ass D) ⟩\n bind (comp D (bind (comp D η (HMap J f))) (comp D η (HMap J g)))\n ≅⟨ law3 ⟩\n comp D (bind (comp D η (HMap J f))) (bind (comp D η (HMap J g)))\n ∎}\n\n-- any functor is a rel monad over itself\ntrivRM : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}(J : Fun C D) → RMonad J\ntrivRM {D = D} J = rmonad OMap (iden D) id refl (idr D) refl \n where open Fun J; open Cat\n", "meta": {"hexsha": "a3bc2b55da5cf9bedb1eff932ec896a2525fbb01", "size": 1886, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "RMonads.agda", "max_stars_repo_name": "jmchapman/Relative-Monads", "max_stars_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 21, "max_stars_repo_stars_event_min_datetime": "2015-07-30T01:25:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-13T18:02:18.000Z", "max_issues_repo_path": "RMonads.agda", "max_issues_repo_name": "jmchapman/Relative-Monads", "max_issues_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:12:33.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-29T09:50:26.000Z", "max_forks_repo_path": "RMonads.agda", "max_forks_repo_name": "jmchapman/Relative-Monads", "max_forks_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-04T21:33:13.000Z", "avg_line_length": 32.5172413793, "max_line_length": 75, "alphanum_fraction": 0.4957582185, "num_tokens": 826, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9046505325302034, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.6082252237599902}} {"text": "-- Andreas, 2016-11-03, issue #2211\n-- The occurs check did not take variables labeled as `UnusedArg`\n-- on the left hand side into consideration.\n\n-- {-# OPTIONS -v tc.check.term:40 #-}\n-- {-# OPTIONS -v tc.meta:45 #-}\n-- {-# OPTIONS -v tc.polarity:20 #-}\n\nopen import Agda.Builtin.Equality\nopen import Common.Nat\n\ncong : ∀{A B : Set}(f : A → B) (x y : A) → x ≡ y → f x ≡ f y\ncong _ _ _ refl = refl\n\ndata ⊥ : Set where\n\n⊥-elim : ∀{A : Set} → ⊥ {- unused arg -} → A\n⊥-elim ()\n\ndata Fin : Nat → Set where\n zero : {n : Nat} → Fin (suc n)\n suc : {n : Nat} (i : Fin n) → Fin (suc n)\n\ntoNat : ∀ {n} → Fin n → Nat\ntoNat zero = 0\ntoNat (suc i) = suc (toNat i)\n\ntighten : ∀ n (x : Fin (suc n)) (neq : (toNat x ≡ n → ⊥) {- unused arg x-}) → Fin n\ntighten zero zero neq = ⊥-elim (neq refl)\ntighten (suc n) zero neq = zero\ntighten zero (suc ())\ntighten (suc n) (suc x) neq = suc (tighten n x (λ p → neq (cong suc _ _ p)))\n\ntighten-correct : ∀ n (x : Fin (suc n)) (neq : toNat x ≡ n → ⊥) →\n toNat (tighten n x neq) ≡ toNat x\ntighten-correct zero zero neq = ⊥-elim (neq refl)\ntighten-correct (suc n) zero neq = refl\ntighten-correct zero (suc ())\ntighten-correct (suc n) (suc x) neq =\n cong suc _ _ (tighten-correct n x (λ p → neq (cong Nat.suc _ _ p)))\n\n-- ERROR WAS:\n-- Cannot instantiate ... because it contains the variable neg ...\n\n-- Should succeed.\n\n{-\nterm _62 n x neq\n (toNat (tighten n x (λ p → neq (cong suc p)))) := suc\n (toNat\n (tighten n x (λ p → neq (cong suc p))))\nterm _62 n x neq (toNat x) := toNat (suc x)\n\nafter kill analysis\n metavar = _62\n kills = [False,False,True,False]\n kills' = [ru(False),ru(False),ru(True),ru(False)]\n oldType = (n₁ : Nat) (x₁ : Fin (suc n₁))\n (neq₁ : toNat (suc x₁) ≡ suc n₁ → ⊥) →\n Nat → Nat\n newType = (n₁ : Nat) → Fin (suc n₁) → Nat → Nat\nactual killing\n new meta: _69\n kills : [ru(False),ru(False),ru(True),ru(False)]\n inst : _62 := _69 @3 n neq\n\nterm _69 n x (toNat (tighten n x (λ p → neq (cong suc p)))) := suc\n (toNat\n (tighten n x\n (λ p → neq (cong suc p))))\n\nHere, the variable neq on the lhs was not considered eligible for occurrence on the rhs\nsince it is contained in an unused arg only.\n-}\n", "meta": {"hexsha": "4a3ea03d92ba84874d98a5ac2169f34552095cd8", "size": 2510, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue2211.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue2211.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue2211.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 33.4666666667, "max_line_length": 95, "alphanum_fraction": 0.5179282869, "num_tokens": 838, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127641048444, "lm_q2_score": 0.7122321842389469, "lm_q1q2_score": 0.6081841531279099}} {"text": "{-# OPTIONS --safe --experimental-lossy-unification #-}\nmodule Cubical.Algebra.CommRing.Instances.Polynomials.UnivariatePolyHIT where\n\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Data.Empty as ⊥\nopen import Cubical.Data.Nat hiding (_·_) renaming (_+_ to _+n_)\nopen import Cubical.Data.Nat.Order\nopen import Cubical.Data.Sigma\n\nopen import Cubical.Algebra.Monoid\nopen import Cubical.Algebra.Monoid.Instances.Nat\nopen import Cubical.Algebra.Ring\nopen import Cubical.Algebra.CommRing\nopen import Cubical.Algebra.GradedRing.DirectSumHIT\n\nprivate variable\n ℓ : Level\n\nopen GradedRing-⊕HIT-index\nopen GradedRing-⊕HIT-⋆\nopen ExtensionCommRing\n\nmodule _\n (ACommRing@(A , Astr) : CommRing ℓ)\n where\n\n open CommRingStr Astr\n open RingTheory (CommRing→Ring ACommRing)\n\n UnivariatePolyHIT-CommRing : CommRing ℓ\n UnivariatePolyHIT-CommRing = ⊕HITgradedRing-CommRing\n NatMonoid\n (λ _ → A)\n (λ _ → snd (Ring→AbGroup (CommRing→Ring ACommRing)))\n 1r _·_ 0LeftAnnihilates 0RightAnnihilates\n (λ a b c → ΣPathP ((+-assoc _ _ _) , (·Assoc _ _ _)))\n (λ a → ΣPathP ((+-zero _) , (·IdR _)))\n (λ a → ΣPathP (refl , (·IdL _)))\n ·DistR+\n ·DistL+\n λ x y → ΣPathP ((+-comm _ _) , (·Comm _ _))\n\nnUnivariatePolyHIT : (A' : CommRing ℓ) → (n : ℕ) → CommRing ℓ\nnUnivariatePolyHIT A' zero = A'\nnUnivariatePolyHIT A' (suc n) = UnivariatePolyHIT-CommRing (nUnivariatePolyHIT A' n)\n", "meta": {"hexsha": "49d4a48d9a265d82a457030288b637beaf59f8f0", "size": 1548, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials/UnivariatePolyHIT.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials/UnivariatePolyHIT.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials/UnivariatePolyHIT.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.9361702128, "max_line_length": 84, "alphanum_fraction": 0.6518087855, "num_tokens": 478, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127529517044, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.6081841504001626}} {"text": "--------------------------------------------------------------------------------\n-- This is part of Agda Inference Systems\n\n{-# OPTIONS --sized-types --guardedness #-}\n\nopen import Data.Product\nopen import Data.Vec\nopen import Codata.Colist as Colist\nopen import Agda.Builtin.Equality\nopen import Size\nopen import Codata.Thunk\nopen import Data.Fin\nopen import Data.Nat\nopen import Data.Maybe\nopen import Examples.Colists.Auxiliary.Colist_member\n\nopen import is-lib.InfSys\n\nmodule Examples.Colists.member {A : Set} where\n\n U = A × Colist A ∞\n\n data memberRN : Set where\n mem-h mem-t : memberRN\n \n mem-h-r : FinMetaRule U\n mem-h-r .Ctx = A × Thunk (Colist A) ∞\n mem-h-r .comp (x , xs) = \n [] , \n ----------------\n (x , x ∷ xs)\n\n mem-t-r : FinMetaRule U\n mem-t-r .Ctx = A × A × Thunk (Colist A) ∞\n mem-t-r .comp (x , y , xs) =\n ((x , xs .force) ∷ []) ,\n ----------------\n (x , y ∷ xs)\n\n memberIS : IS U\n memberIS .Names = memberRN\n memberIS .rules mem-h = from mem-h-r\n memberIS .rules mem-t = from mem-t-r\n\n _member_ : A → Colist A ∞ → Set\n x member xs = Ind⟦ memberIS ⟧ (x , xs)\n \n memSpec : U → Set\n memSpec (x , xs) = Σ[ i ∈ ℕ ] (Colist.lookup i xs ≡ just x)\n\n memSpecClosed : ISClosed memberIS memSpec\n memSpecClosed mem-h _ _ = zero , refl\n memSpecClosed mem-t _ pr =\n let (i , proof) = pr Fin.zero in\n (suc i) , proof\n\n memberSound : ∀{x xs} → x member xs → memSpec (x , xs)\n memberSound = ind[ memberIS ] memSpec memSpecClosed\n\n -- Completeness using memSpec does not terminate\n -- Product implemented as record. Record projections do not decrease\n memSpec' : U → ℕ → Set\n memSpec' (x , xs) i = Colist.lookup i xs ≡ just x\n\n memberCompl : ∀{x xs i} → memSpec' (x , xs) i → x member xs\n memberCompl {.x} {x ∷ _} {zero} refl = apply-ind mem-h _ λ ()\n memberCompl {x} {y ∷ xs} {suc i} eq = apply-ind mem-t _ λ{zero → memberCompl eq}\n\n memberComplete : ∀{x xs} → memSpec (x , xs) → x member xs\n memberComplete (i , eq) = memberCompl eq\n\n {- Correctness wrt to Agda DataType -}\n\n ∈-sound : ∀{x xs} → x ∈ xs → x member xs\n ∈-sound here = apply-ind mem-h _ λ ()\n ∈-sound (there mem) = apply-ind mem-t _ λ{zero → ∈-sound mem}\n\n ∈-complete : ∀{x xs} → x member xs → x ∈ xs\n ∈-complete (fold (mem-h , _ , refl , _)) = here\n ∈-complete (fold (mem-t , _ , refl , prem)) = there (∈-complete (prem zero))", "meta": {"hexsha": "b6b83f1de4cc9b67683f078537046fbcfc313bf4", "size": 2361, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Examples/Colists/member.agda", "max_stars_repo_name": "LcicC/inference-systems-agda", "max_stars_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2022-03-10T15:53:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-25T15:48:52.000Z", "max_issues_repo_path": "Examples/Colists/member.agda", "max_issues_repo_name": "LcicC/inference-systems-agda", "max_issues_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Examples/Colists/member.agda", "max_forks_repo_name": "LcicC/inference-systems-agda", "max_forks_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.5125, "max_line_length": 82, "alphanum_fraction": 0.5938161796, "num_tokens": 778, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127455162773, "lm_q2_score": 0.7122321903471562, "lm_q1q2_score": 0.608184145104412}} {"text": "module Cats.Category.Setoids.Facts.Products where\n\nopen import Data.Product as P using (_,_ ; <_,_>)\nopen import Relation.Binary using (Setoid)\nopen import Relation.Binary.Product.Pointwise using (×-setoid)\n\nopen import Cats.Category\nopen import Cats.Category.Setoids as Setoids using (Setoids ; ≈-intro ; ≈-elim)\nopen import Cats.Util.Conv\n\nopen Setoid using (Carrier ; refl ; sym ; trans) renaming (_≈_ to _≣_)\n\n\n-- The existence of binary products, proven below, already follows from the\n-- existence of general products, proven further below. We still construct them\n-- explicitly because the definitions in this module are much easier to work\n-- with.\nmodule BuildBinary l l≈ where\n\n infixr 2 _×_\n\n\n open Category (Setoids l l≈)\n open Setoids._⇒_ using (resp)\n\n\n _×_ : Obj → Obj → Obj\n _×_ = ×-setoid\n\n\n projl : ∀ {A B} → A × B ⇒ A\n projl {A} {B} = record\n { arr = P.proj₁\n ; resp = λ { (eq₁ , eq₂) → eq₁ }\n }\n\n\n projr : ∀ {A B} → A × B ⇒ B\n projr {A} {B} = record\n { arr = P.proj₂\n ; resp = λ { (eq₁ , eq₂) → eq₂ }\n }\n\n\n ⟨_,_⟩ : ∀ {X A B} → X ⇒ A → X ⇒ B → X ⇒ A × B\n ⟨_,_⟩ {A = A} {B} xl xr = record\n { arr = < xl ⃗ , xr ⃗ >\n ; resp = λ eq → resp xl eq , resp xr eq\n }\n\n\n isBinaryProduct : ∀ {A B} → IsBinaryProduct (A × B) projl projr\n isBinaryProduct xl xr = record\n { arr = ⟨ xl , xr ⟩\n ; prop = (≈-intro λ eq → resp xl eq) , (≈-intro λ eq → resp xr eq)\n ; unique = λ { (eq₁ , eq₂) → ≈-intro λ x≈y → ≈-elim eq₁ x≈y , ≈-elim eq₂ x≈y }\n }\n\n\n _×′_ : ∀ A B → BinaryProduct A B\n A ×′ B = mkBinaryProduct projl projr isBinaryProduct\n\n\ninstance\n hasBinaryProducts : ∀ l l≈ → HasBinaryProducts (Setoids l l≈)\n hasBinaryProducts l l≈ .HasBinaryProducts._×′_ = BuildBinary._×′_ l l≈\n\n\nmodule Build l {I : Set l} where\n\n open Category (Setoids l l)\n open Setoids._⇒_ using (resp)\n\n\n Π : (O : I → Obj) → Obj\n Π O = record\n { Carrier = ∀ i → Carrier (O i)\n ; _≈_ = λ f g → ∀ i → _≣_ (O i) (f i) (g i)\n ; isEquivalence = record\n { refl = λ i → refl (O i)\n ; sym = λ eq i → sym (O i) (eq i)\n ; trans = λ eq₁ eq₂ i → trans (O i) (eq₁ i) (eq₂ i)\n }\n }\n\n\n proj : ∀ {O : I → Obj} i → Π O ⇒ O i\n proj i = record\n { arr = λ f → f i\n ; resp = λ eq → eq i\n }\n\n\n isProduct : ∀ {O : I → Obj} → IsProduct O (Π O) proj\n isProduct x = record\n { arr = record\n { arr = λ a i → (x i ⃗) a\n ; resp = λ eq i → resp (x i) eq\n }\n ; prop = λ i → ≈-intro λ eq → resp (x i) eq\n ; unique = λ x-candidate → ≈-intro λ eq i → ≈-elim (x-candidate i) eq\n }\n\n\n Π′ : (O : I → Obj) → Product O\n Π′ O = record { prod = Π O ; proj = proj ; isProduct = isProduct }\n\n\ninstance\n hasProducts : ∀ l → HasProducts l (Setoids l l)\n hasProducts l = record { Π′ = Build.Π′ l }\n", "meta": {"hexsha": "dc8cd2fb2f65dab5377307fbe9196079bc72d32d", "size": 2832, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Category/Setoids/Facts/Products.agda", "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cats/Category/Setoids/Facts/Products.agda", "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cats/Category/Setoids/Facts/Products.agda", "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.2857142857, "max_line_length": 82, "alphanum_fraction": 0.5508474576, "num_tokens": 1017, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127417985637, "lm_q2_score": 0.712232184238947, "lm_q1q2_score": 0.608184137240659}} {"text": "module STLC.Type where\n\nopen import Data.Fin using (Fin)\nopen import Data.Fin.Substitution\nopen import Data.Fin.Substitution.Lemmas using (TermLemmas)\n\nopen import Data.Nat using (ℕ; _+_)\n\nopen import Relation.Binary.Construct.Closure.ReflexiveTransitive \n using (Star; ε; _◅_)\n\nopen import Data.Vec using (Vec; []; _∷_; lookup)\n\nopen import Relation.Binary.PropositionalEquality as Eq\n using (refl; _≡_; sym; cong₂)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎)\n\n\n-- --------------------------------------------------------------------\n-- Types \n-- --------------------------------------------------------------------\n-- Recall that STLC types are defined as:\n-- τ ::= α | τ -> τ \n-- where α denotes a type variable. \n\ninfix 9 `_ \ninfixr 7 _⇒_ \n\ndata Type (n : ℕ) : Set where\n `_ : Fin n -> Type n\n _⇒_ : Type n -> Type n -> Type n\n\n\n-- --------------------------------------------------------------------\n\nmodule Substitution where\n\n -- This sub module defines application of the subtitution\n module Application₀ { T : ℕ -> Set } ( l : Lift T Type ) where\n open Lift l hiding (var)\n\n\n -- Application of substitution to type \n infixl 8 _/_\n\n _/_ : ∀ { m n : ℕ } -> Type m -> Sub T m n -> Type n \n ` x / ρ = lift (lookup ρ x) \n (τ₁ ⇒ τ₂) / ρ = (τ₁ / ρ) ⇒ (τ₂ / ρ)\n\n open Application (record { _/_ = _/_ }) using (_/✶_)\n\n -- The application of sequences of substitutions is defined\n -- by (_/✶_). We use this to prove some generic lemmas on\n -- the lifting of sets\n\n ⇒-/✶-lift : ∀ k { m n τ₁ τ₂ } (ρs : Subs T m n) -> \n (τ₁ ⇒ τ₂) /✶ ρs ↑✶ k ≡ (τ₁ /✶ ρs ↑✶ k) ⇒ (τ₂ /✶ ρs ↑✶ k)\n ⇒-/✶-lift k ε = refl\n ⇒-/✶-lift k (ρ ◅ ρs) = cong₂ _/_ (⇒-/✶-lift k ρs) refl \n\n t = record\n {var = `_\n ; app = Application₀._/_\n }\n\n open TermSubst t public hiding (var)\n\n infix 8 _[/_]\n\n -- Shorthand for single-variable type substitutions\n _[/_] : ∀ { n } → Type (1 + n) → Type n → Type n\n τ₁ [/ τ₂ ] = τ₁ / sub τ₂\n\n\nmodule Lemmas where\n \n module Lemmas₀ { T₁ T₂ } { l₁ : Lift T₁ Type} { l₂ : Lift T₂ Type } where\n open Substitution\n\n open Lifted l₁ using () renaming (_↑✶_ to _↑✶₁_; _/✶_ to _/✶₁_)\n open Lifted l₂ using () renaming (_↑✶_ to _↑✶₂_; _/✶_ to _/✶₂_)\n \n /✶-↑✶ : ∀ {m n} (ρs₁ : Subs T₁ m n) (ρs₂ : Subs T₂ m n) \n -> (∀ k x -> ` x /✶₁ ρs₁ ↑✶₁ k ≡ ` x /✶₂ ρs₂ ↑✶₂ k) \n -> ∀ k τ -> τ /✶₁ ρs₁ ↑✶₁ k ≡ τ /✶₂ ρs₂ ↑✶₂ k\n /✶-↑✶ ρs₁ ρs₂ hyp k (` x) = hyp k x\n /✶-↑✶ ρs₁ ρs₂ hyp k (τ₁ ⇒ τ₂) = \n begin\n (τ₁ ⇒ τ₂) /✶₁ ρs₁ ↑✶₁ k\n ≡⟨ Application₀.⇒-/✶-lift _ k ρs₁ ⟩\n (τ₁ /✶₁ ρs₁ ↑✶₁ k) ⇒ (τ₂ /✶₁ ρs₁ ↑✶₁ k)\n ≡⟨ cong₂ (_⇒_) (/✶-↑✶ ρs₁ ρs₂ hyp k τ₁) (/✶-↑✶ ρs₁ ρs₂ hyp k τ₂) ⟩\n (τ₁ /✶₂ ρs₂ ↑✶₂ k) ⇒ (τ₂ /✶₂ ρs₂ ↑✶₂ k)\n ≡⟨ sym (Application₀.⇒-/✶-lift _ k ρs₂) ⟩\n (τ₁ ⇒ τ₂) /✶₂ ρs₂ ↑✶₂ k\n ∎\n\n t : TermLemmas Type\n t = record\n { termSubst = Substitution.t \n ; app-var = refl\n ; /✶-↑✶ = Lemmas₀./✶-↑✶\n }\n\n open TermLemmas t public hiding (var)\n\n\n\n\n\nmodule Operators where\n\n infixr 7 _⇒ⁿ_\n\n -- n-ary function type\n _⇒ⁿ_ : ∀ { n k } -> Vec (Type n) k -> Type n -> Type n\n [] ⇒ⁿ τ = τ\n (τ ∷ τs) ⇒ⁿ σ = τ ⇒ (τs ⇒ⁿ σ)\n\n\n\n", "meta": {"hexsha": "c46d06890f3961e43281f074dd12e43781b8a4eb", "size": 3171, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/STLC/Type.agda", "max_stars_repo_name": "johnyob/agda-types", "max_stars_repo_head_hexsha": "aeb2be63381d891fabe5317e3c27553deb6bca6d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/STLC/Type.agda", "max_issues_repo_name": "johnyob/agda-types", "max_issues_repo_head_hexsha": "aeb2be63381d891fabe5317e3c27553deb6bca6d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/STLC/Type.agda", "max_forks_repo_name": "johnyob/agda-types", "max_forks_repo_head_hexsha": "aeb2be63381d891fabe5317e3c27553deb6bca6d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.9918032787, "max_line_length": 75, "alphanum_fraction": 0.5011037528, "num_tokens": 1305, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321843145404, "lm_q2_score": 0.7549149758396752, "lm_q1q2_score": 0.608183800957476}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category using (Category)\nopen import Categories.Category.Monoidal.Core using (Monoidal)\n\nmodule Categories.Category.Monoidal.Utilities {o ℓ e} {C : Category o ℓ e} (M : Monoidal C) where\n\nopen import Level\nopen import Function using (_$_)\nopen import Data.Product using (_×_; _,_; curry′)\n\nopen import Categories.Category.Product\nopen import Categories.Functor renaming (id to idF)\nopen import Categories.Functor.Bifunctor using (Bifunctor; appˡ; appʳ)\nopen import Categories.Functor.Properties using ([_]-resp-≅)\nopen import Categories.NaturalTransformation renaming (id to idN)\nopen import Categories.NaturalTransformation.NaturalIsomorphism\n hiding (unitorˡ; unitorʳ; associator; _≃_)\n\ninfixr 10 _⊗ᵢ_\n\nopen import Categories.Morphism C using (_≅_; module ≅)\nopen import Categories.Morphism.IsoEquiv C using (_≃_; ⌞_⌟)\nopen import Categories.Morphism.Isomorphism C using (_∘ᵢ_; lift-triangle′; lift-pentagon′)\nopen import Categories.Morphism.Reasoning C\n\nprivate\n module C = Category C\n\nopen C hiding (id; identityˡ; identityʳ; assoc)\nopen Commutation\n\nprivate\n variable\n X Y Z W A B : Obj\n f g h i a b : X ⇒ Y\n\nopen Monoidal M\nmodule ⊗ = Functor ⊗\n\n-- for exporting, it makes sense to use the above long names, but for\n-- internal consumption, the traditional (short!) categorical names are more\n-- convenient. However, they are not symmetric, even though the concepts are, so\n-- we'll use ⇒ and ⇐ arrows to indicate that\n\nmodule Shorthands where\n\n λ⇒ = unitorˡ.from\n λ⇐ = unitorˡ.to\n ρ⇒ = unitorʳ.from\n ρ⇐ = unitorʳ.to\n -- eta expansion fixes a problem in 2.6.1, will be reported\n α⇒ = λ {X} {Y} {Z} → associator.from {X} {Y} {Z}\n α⇐ = λ {X} {Y} {Z} → associator.to {X} {Y} {Z}\n\nopen Shorthands\n\nprivate\n [x⊗y]⊗z : Bifunctor (Product C C) C C\n [x⊗y]⊗z = ⊗ ∘F (⊗ ⁂ idF)\n\n -- note how this one needs re-association to typecheck (i.e. be correct)\n x⊗[y⊗z] : Bifunctor (Product C C) C C\n x⊗[y⊗z] = ⊗ ∘F (idF ⁂ ⊗) ∘F assocˡ _ _ _\n\nunitor-coherenceʳ : [ (A ⊗₀ unit) ⊗₀ unit ⇒ A ⊗₀ unit ]⟨ ρ⇒ ⊗₁ C.id ≈ ρ⇒ ⟩\nunitor-coherenceʳ = cancel-fromˡ unitorʳ unitorʳ-commute-from\n\nunitor-coherenceˡ : [ unit ⊗₀ unit ⊗₀ A ⇒ unit ⊗₀ A ]⟨ C.id ⊗₁ λ⇒ ≈ λ⇒ ⟩\nunitor-coherenceˡ = cancel-fromˡ unitorˡ unitorˡ-commute-from\n\n-- All the implicits below can be inferred, but being explicit is clearer\nunitorˡ-naturalIsomorphism : NaturalIsomorphism (unit ⊗-) idF\nunitorˡ-naturalIsomorphism = record\n { F⇒G = ntHelper record\n { η = λ X → λ⇒ {X}\n ; commute = λ f → unitorˡ-commute-from {f = f}\n }\n ; F⇐G = ntHelper record\n { η = λ X → λ⇐ {X}\n ; commute = λ f → unitorˡ-commute-to {f = f}\n }\n ; iso = λ X → unitorˡ.iso {X}\n }\n\nunitorʳ-naturalIsomorphism : NaturalIsomorphism (-⊗ unit) idF\nunitorʳ-naturalIsomorphism = record\n { F⇒G = ntHelper record\n { η = λ X → ρ⇒ {X}\n ; commute = λ f → unitorʳ-commute-from {f = f}\n }\n ; F⇐G = ntHelper record\n { η = λ X → ρ⇐ {X}\n ; commute = λ f → unitorʳ-commute-to {f = f}\n }\n ; iso = λ X → unitorʳ.iso {X}\n }\n\n-- skipping the explicit arguments here, it does not increase understandability\nassociator-naturalIsomorphism : NaturalIsomorphism [x⊗y]⊗z x⊗[y⊗z]\nassociator-naturalIsomorphism = record\n { F⇒G = ntHelper record\n { η = λ { ((X , Y) , Z) → α⇒ {X} {Y} {Z}}\n ; commute = λ _ → assoc-commute-from\n }\n ; F⇐G = ntHelper record\n { η = λ _ → α⇐\n ; commute = λ _ → assoc-commute-to\n }\n ; iso = λ _ → associator.iso\n }\n\nmodule unitorˡ-natural = NaturalIsomorphism unitorˡ-naturalIsomorphism\nmodule unitorʳ-natural = NaturalIsomorphism unitorʳ-naturalIsomorphism\nmodule associator-natural = NaturalIsomorphism associator-naturalIsomorphism\n\n_⊗ᵢ_ : X ≅ Y → Z ≅ W → X ⊗₀ Z ≅ Y ⊗₀ W\nf ⊗ᵢ g = [ ⊗ ]-resp-≅ record\n { from = from f , from g\n ; to = to f , to g\n ; iso = record\n { isoˡ = isoˡ f , isoˡ g\n ; isoʳ = isoʳ f , isoʳ g\n }\n }\n where open _≅_\n\ntriangle-iso : ≅.refl ⊗ᵢ unitorˡ ∘ᵢ associator ≃ unitorʳ {X} ⊗ᵢ ≅.refl {Y}\ntriangle-iso = lift-triangle′ triangle\n\npentagon-iso :\n ≅.refl ⊗ᵢ associator ∘ᵢ associator ∘ᵢ associator {X} {Y} {Z} ⊗ᵢ ≅.refl {W}\n ≃ associator ∘ᵢ associator\npentagon-iso = lift-pentagon′ pentagon\n\nrefl⊗refl≃refl : ≅.refl {A} ⊗ᵢ ≅.refl {B} ≃ ≅.refl\nrefl⊗refl≃refl = ⌞ ⊗.identity ⌟\n", "meta": {"hexsha": "6f359ee0ea1d7f593ee8e0aec229809161ec75fe", "size": 4320, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Monoidal/Utilities.agda", "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Category/Monoidal/Utilities.agda", "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Monoidal/Utilities.agda", "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.3043478261, "max_line_length": 97, "alphanum_fraction": 0.6592592593, "num_tokens": 1688, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681195338728, "lm_q2_score": 0.7090191460821871, "lm_q1q2_score": 0.6081740196484299}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nmodule Naturals where\n\ndata ℕ : Set where\n zero : ℕ\n succ : ℕ → ℕ\n\n{-# BUILTIN NATURAL ℕ #-}\n\n_+N_ : ℕ → ℕ → ℕ\nzero +N b = b\nsucc a +N b = succ (a +N b)\n", "meta": {"hexsha": "1b4bde6a241f8f98f571c54e921ebf12a8ccd178", "size": 207, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Naturals.agda", "max_stars_repo_name": "Smaug123/CubicalTutorial", "max_stars_repo_head_hexsha": "3d56e649152d2cd906281943860ca19da1d1f344", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-26T17:02:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-16T23:14:13.000Z", "max_issues_repo_path": "Naturals.agda", "max_issues_repo_name": "Smaug123/CubicalTutorial", "max_issues_repo_head_hexsha": "3d56e649152d2cd906281943860ca19da1d1f344", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Naturals.agda", "max_forks_repo_name": "Smaug123/CubicalTutorial", "max_forks_repo_head_hexsha": "3d56e649152d2cd906281943860ca19da1d1f344", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 14.7857142857, "max_line_length": 50, "alphanum_fraction": 0.5603864734, "num_tokens": 73, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8577680977182187, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.6081739989066861}} {"text": "------------------------------------------------------------------------\n-- Semi-heterogeneous vector equality\n------------------------------------------------------------------------\n\nmodule Data.Vec.Equality where\n\nopen import Data.Vec\nopen import Data.Nat using (suc)\nopen import Data.Function\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as PropEq using (_≡_)\n\nmodule Equality (S : Setoid) where\n\n private\n open module SS = Setoid S\n using () renaming (_≈_ to _≊_; carrier to A)\n\n infix 4 _≈_\n\n data _≈_ : ∀ {n¹} → Vec A n¹ →\n ∀ {n²} → Vec A n² → Set where\n []-cong : [] ≈ []\n _∷-cong_ : ∀ {x¹ n¹} {xs¹ : Vec A n¹}\n {x² n²} {xs² : Vec A n²}\n (x¹≈x² : x¹ ≊ x²) (xs¹≈xs² : xs¹ ≈ xs²) →\n x¹ ∷ xs¹ ≈ x² ∷ xs²\n\n length-equal : ∀ {n¹} {xs¹ : Vec A n¹}\n {n²} {xs² : Vec A n²} →\n xs¹ ≈ xs² → n¹ ≡ n²\n length-equal []-cong = PropEq.refl\n length-equal (_ ∷-cong eq₂) = PropEq.cong suc $ length-equal eq₂\n\n refl : ∀ {n} (xs : Vec A n) → xs ≈ xs\n refl [] = []-cong\n refl (x ∷ xs) = SS.refl ∷-cong refl xs\n\n sym : ∀ {n m} {xs : Vec A n} {ys : Vec A m} →\n xs ≈ ys → ys ≈ xs\n sym []-cong = []-cong\n sym (x¹≡x² ∷-cong xs¹≈xs²) = SS.sym x¹≡x² ∷-cong sym xs¹≈xs²\n\n trans : ∀ {n m l} {xs : Vec A n} {ys : Vec A m} {zs : Vec A l} →\n xs ≈ ys → ys ≈ zs → xs ≈ zs\n trans []-cong []-cong = []-cong\n trans (x≈y ∷-cong xs≈ys) (y≈z ∷-cong ys≈zs) =\n SS.trans x≈y y≈z ∷-cong trans xs≈ys ys≈zs\n\n _++-cong_ : ∀ {n₁¹ n₂¹} {xs₁¹ : Vec A n₁¹} {xs₂¹ : Vec A n₂¹}\n {n₁² n₂²} {xs₁² : Vec A n₁²} {xs₂² : Vec A n₂²} →\n xs₁¹ ≈ xs₁² → xs₂¹ ≈ xs₂² →\n xs₁¹ ++ xs₂¹ ≈ xs₁² ++ xs₂²\n []-cong ++-cong eq₃ = eq₃\n (eq₁ ∷-cong eq₂) ++-cong eq₃ = eq₁ ∷-cong (eq₂ ++-cong eq₃)\n\nmodule DecidableEquality (D : DecSetoid) where\n\n private module DS = DecSetoid D\n open DS using () renaming (_≟_ to _≟′_ ; carrier to A)\n open Equality DS.setoid\n open import Relation.Nullary\n\n _≟_ : ∀ {n m} (xs : Vec A n) (ys : Vec A m) → Dec (xs ≈ ys)\n _≟_ [] [] = yes []-cong\n _≟_ [] (y ∷ ys) = no (λ())\n _≟_ (x ∷ xs) [] = no (λ())\n _≟_ (x ∷ xs) (y ∷ ys) with xs ≟ ys | x ≟′ y\n ... | yes xs≈ys | yes x≊y = yes (x≊y ∷-cong xs≈ys)\n ... | no ¬xs≈ys | _ = no helper\n where\n helper : ¬ (x ∷ xs ≈ y ∷ ys)\n helper (_ ∷-cong xs≈ys) = ¬xs≈ys xs≈ys\n ... | _ | no ¬x≊y = no helper\n where\n helper : ¬ (x ∷ xs ≈ y ∷ ys)\n helper (x≊y ∷-cong _) = ¬x≊y x≊y\n\nmodule HeterogeneousEquality {A : Set} where\n\n open import Relation.Binary.HeterogeneousEquality as HetEq\n using (_≅_)\n open Equality (PropEq.setoid A)\n\n to-≅ : ∀ {n m} {xs : Vec A n} {ys : Vec A m} →\n xs ≈ ys → xs ≅ ys\n to-≅ []-cong = HetEq.refl\n to-≅ (PropEq.refl ∷-cong xs¹≈xs²) with length-equal xs¹≈xs²\n ... | PropEq.refl = HetEq.cong (_∷_ _) $ to-≅ xs¹≈xs²\n", "meta": {"hexsha": "174907047a161fd236757c0c3214199e4bc016e0", "size": 3023, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Data/Vec/Equality.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Data/Vec/Equality.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Data/Vec/Equality.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 33.5888888889, "max_line_length": 72, "alphanum_fraction": 0.4806483626, "num_tokens": 1246, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.84997116805678, "lm_q2_score": 0.7154239957834732, "lm_q1q2_score": 0.6080897693519275}} {"text": "import Lvl\nopen import Structure.Category\nopen import Structure.Setoid\nopen import Type\n\n-- TODO: Deprecate this file and use Relator.Equals.Category instead\nmodule Structure.Category.Morphism.IdTransport where\n\nimport Functional.Dependent as Fn\nimport Function.Equals\nopen Function.Equals.Dependent\nopen import Logic\nopen import Logic.Propositional\nopen import Logic.Predicate\nopen import Relator.Equals using ([≡]-intro) renaming (_≡_ to _≡ₑ_)\nopen import Relator.Equals.Proofs\nimport Structure.Categorical.Names as Names\nopen import Structure.Category.Functor\nopen import Structure.Categorical.Properties\nopen import Structure.Function\nopen import Structure.Relator.Equivalence\nopen import Structure.Relator.Properties\nopen import Syntax.Transitivity\n\nmodule _\n {ℓₒ ℓₘ ℓₑ : Lvl.Level}\n (cat : CategoryObject{ℓₒ}{ℓₘ}{ℓₑ})\n where\n\n open CategoryObject(cat)\n open Category(category) using (_∘_ ; id ; identityₗ ; identityᵣ)\n open Category.ArrowNotation(category)\n open Morphism.OperModule ⦃ morphism-equiv ⦄ (\\{x} → _∘_ {x})\n open Morphism.IdModule ⦃ morphism-equiv ⦄ (\\{x} → _∘_ {x})(id)\n\n private variable a b c : Object\n\n -- Essentially the identity morphism masquerading as a morphism between two arbitrary but identical objects.\n transport : (a ≡ₑ b) → (a ⟶ b)\n transport = sub₂(_≡ₑ_)(_⟶_) ⦃ [≡]-sub-of-reflexive ⦃ intro id ⦄ ⦄\n\n transport-function : Function ⦃ [≡]-equiv ⦄ ⦃ morphism-equiv ⦄ (transport {a = a}{b = b})\n Function.congruence transport-function xy = sub₂(_≡ₑ_)(_≡_) ⦃ [≡]-sub-of-reflexive ⦃ Equiv.reflexivity(morphism-equiv) ⦄ ⦄ ([≡]-with(transport) xy)\n\n transport-of-reflexivity : (transport(reflexivity(_≡ₑ_)) ≡ id{a})\n transport-of-reflexivity = reflexivity(_≡_) ⦃ Equiv.reflexivity morphism-equiv ⦄\n\n -- transport-of-symmetry : ∀{ab : (a ≡ₑ b)}{ba : (b ≡ₑ a)} → (transitivity(_≡ₑ_) ab ba ≡ reflexivity(_≡ₑ_)) → (transport(symmetry(_≡ₑ_) ab) ≡ transport ba)\n\n transport-of-transitivity : ∀{ab : (a ≡ₑ b)}{bc : (b ≡ₑ c)} → (transport(transitivity(_≡ₑ_) ab bc) ≡ transport(bc) ∘ transport(ab))\n transport-of-transitivity {ab = [≡]-intro} {bc = [≡]-intro} = symmetry(_≡_) ⦃ Equiv.symmetry morphism-equiv ⦄ (Morphism.identityₗ(_∘_)(id))\n\n [∘]-on-transport-inverseₗ : ∀{ab : (a ≡ₑ b)} → ((transport (symmetry(_≡ₑ_) ab)) ∘ (transport ab) ≡ id)\n [∘]-on-transport-inverseₗ {ab = [≡]-intro} = Morphism.identityₗ(_∘_)(id)\n\n instance\n transport-inverseₗ : ∀{ab : (a ≡ₑ b)} → Inverseₗ(transport ab) (transport(symmetry(_≡ₑ_) ab))\n transport-inverseₗ {ab = ab} = Morphism.intro ([∘]-on-transport-inverseₗ {ab = ab})\n\n [∘]-on-transport-inverseᵣ : ∀{ab : (a ≡ₑ b)} → ((transport ab) ∘ (transport (symmetry(_≡ₑ_) ab)) ≡ id)\n [∘]-on-transport-inverseᵣ {ab = [≡]-intro} = Morphism.identityᵣ(_∘_)(id)\n\n instance\n transport-inverseᵣ : ∀{ab : (a ≡ₑ b)} → Inverseᵣ(transport ab) (transport(symmetry(_≡ₑ_) ab))\n transport-inverseᵣ {ab = ab} = Morphism.intro ([∘]-on-transport-inverseᵣ {ab = ab})\n\n instance\n transport-isomorphism : ∀{ab : (a ≡ₑ b)} → Isomorphism(transport ab)\n transport-isomorphism {ab = ab} = [∃]-intro (transport(symmetry(_≡_) ab)) ⦃ [∧]-intro (transport-inverseₗ {ab = ab}) (transport-inverseᵣ {ab = ab}) ⦄\n\n transport-congruence-symmetry-involution : ∀{ab : (a ≡ₑ b)} → ((transport Fn.∘ symmetry(_≡ₑ_) Fn.∘ symmetry(_≡ₑ_)) ab ≡ transport ab)\n transport-congruence-symmetry-involution {ab = [≡]-intro} = reflexivity(_≡_) ⦃ Equiv.reflexivity morphism-equiv ⦄\n\nmodule _\n {ℓₒₗ ℓₘₗ ℓₑₗ ℓₒᵣ ℓₘᵣ ℓₑᵣ : Lvl.Level}\n {catₗ : CategoryObject{ℓₒₗ}{ℓₘₗ}{ℓₑₗ}}\n {catᵣ : CategoryObject{ℓₒᵣ}{ℓₘᵣ}{ℓₑᵣ}}\n where\n\n open CategoryObject\n open Category using (_∘_ ; id ; identityₗ ; identityᵣ)\n open Category.ArrowNotation\n\n private open module Equivᵣ {x}{y} = Equivalence (Equiv-equivalence ⦃ morphism-equiv(catᵣ){x}{y} ⦄) using ()\n\n transport-of-congruenced-functor : (([∃]-intro F ⦃ intro map ⦄) : catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ) → ∀{a b : Object(catₗ)}{ab : (a ≡ₑ b)} → (transport(catᵣ)(congruence₁ F ab) ≡ map(transport(catₗ)(ab)))\n transport-of-congruenced-functor ([∃]-intro F functor@⦃ intro map ⦄) {ab = [≡]-intro} =\n transport catᵣ (congruence₁ F [≡]-intro) 🝖[ _≡_ ]-[]\n transport catᵣ [≡]-intro 🝖[ _≡_ ]-[]\n id(category(catᵣ)) 🝖[ _≡_ ]-[ Functor.id-preserving functor ]-sym\n map(id(category(catₗ))) 🝖[ _≡_ ]-[]\n map(transport catₗ [≡]-intro) 🝖-end\n\n -- transport-of-congruenced-bifunctor : ∀{ab : (a ≡ₑ b)}{[∃]-intro F : Bifunctor} → (F(transport(ab)(cd)) ≡ transport(congruence₂ F ab cd))\n", "meta": {"hexsha": "f5d3ee566a64066a123dffc61601f67b34135300", "size": 4556, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Category/Morphism/IdTransport.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Category/Morphism/IdTransport.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Category/Morphism/IdTransport.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.9578947368, "max_line_length": 191, "alphanum_fraction": 0.6650570676, "num_tokens": 1732, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382129861583, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.6080607663034318}} {"text": "------------------------------------------------------------------------------\n-- Totality properties of the division\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOTC.Program.Division.TotalityATP where\n\nopen import FOTC.Base\nopen import FOTC.Data.Nat\nopen import FOTC.Data.Nat.Inequalities\nopen import FOTC.Program.Division.Division\nopen import FOTC.Program.Division.Specification\n\n------------------------------------------------------------------------------\n-- The division is total when the dividend is less than the divisor.\npostulate div-x_\ninfixr 4 _,_\ninfixr 5 _≤-trans_ _<-transˡ_ _<-transʳ_ _≤-asym_ _≤-total_ \ninfixl 6 _+_ _∸_\n\n-- Time has a cancellative action _+_ which respects the monoid structure of ℕ\n\npostulate\n\n Time : Set\n _+_ : Time → ℕ → Time\n\n +-unit : ∀ t → (t + 0 ≡ t)\n +-assoc : ∀ t m n → ((t + m) + n ≡ t + (m +ℕ n))\n +-cancelˡ : ∀ t {m n} → (t + m ≡ t + n) → (m ≡ n)\n +-cancelʳ : ∀ {s t} n → (s + n ≡ t + n) → (s ≡ t)\n\n-- The order on time is derived from +\n\ndata _≤_ (t u : Time) : Set where\n _,_ : ∀ n → (t + n ≡ u) → (t ≤ u)\n\n-- Floored subtraction t ∸ u is the smallest n such that t ≤ u + n\n\npostulate\n\n _∸_ : Time → Time → ℕ\n t≤u+t∸u : ∀ {t u} → (t ≤ u + (t ∸ u))\n ∸-min : ∀ {t u n} → (t ≤ u + n) → (t ∸ u ≤ℕ n)\n\n-- End of postulates.\n\nsuc-cancelʳ : ∀ {t u m n} → (t + suc m ≡ u + suc n) → (t + m ≡ u + n)\nsuc-cancelʳ {t} {u} {m} {n} t+1+m≡u+1+n = \n +-cancelʳ 1 \n (+-assoc t m 1 trans \n cong₂ _+_ refl (+ℕ-comm m 1) trans \n t+1+m≡u+1+n trans \n cong₂ _+_ refl (+ℕ-comm 1 n) trans \n sym (+-assoc u n 1))\n\n-- Syntax sugar for ≤\n\n_≥_ : Time → Time → Set\nt ≥ u = u ≤ t\n\n_≰_ : Time → Time → Set\nt ≰ u = ¬(t ≤ u)\n\n_≱_ : Time → Time → Set\nt ≱ u = u ≰ t\n\n_<_ : Time → Time → Set\nt < u = (t ≤ u) × (u ≰ t)\n\n_>_ : Time → Time → Set\nt > u = u < t\n\n-- ≤ is a decidable total order\n\n≤-refl : ∀ {t} → (t ≤ t)\n≤-refl {t} = (0 , +-unit t)\n\n_≤-trans_ : ∀ {t u v} → (t ≤ u) → (u ≤ v) → (t ≤ v)\n_≤-trans_ {t} {u} {v} (m , t+m≡u) (n , u+n≡v) =\n (m +ℕ n , (sym (+-assoc t m n)) trans (cong₂ _+_ t+m≡u refl) trans u+n≡v)\n\n≡-impl-≤ : ∀ {t u} → (t ≡ u) → (t ≤ u)\n≡-impl-≤ refl = ≤-refl\n\n≡-impl-≥ : ∀ {t u} → (t ≡ u) → (t ≥ u)\n≡-impl-≥ refl = ≤-refl\n\n_≤-asym_ : ∀ {t u} → (t ≤ u) → (u ≤ t) → (t ≡ u)\n(m , t+m≡u) ≤-asym (n , u+n≡t) = \n sym (+-unit _) trans cong₂ _+_ refl (sym m≡0) trans t+m≡u where\n\n m≡0 : m ≡ 0\n m≡0 = m+n≡0-impl-m≡0 m n (+-cancelˡ _ \n (sym (+-assoc _ m n) trans \n cong₂ _+_ t+m≡u refl trans \n u+n≡t trans sym (+-unit _)))\n\n≤-impl-∸≡0 : ∀ {t u} → (t ≤ u) → (t ∸ u ≡ 0)\n≤-impl-∸≡0 t≤u with (∸-min (t≤u ≤-trans ≡-impl-≤ (sym (+-unit _))))\n≤-impl-∸≡0 t≤u | t∸u≤0 = ≤0-impl-≡0 t∸u≤0\n\n∸≡0-impl-≤ : ∀ {t u} → (t ∸ u ≡ 0) → (t ≤ u)\n∸≡0-impl-≤ t∸u≡0 = t≤u+t∸u ≤-trans ≡-impl-≤ (cong₂ _+_ refl t∸u≡0 trans +-unit _)\n\n∸≢0-impl-≰ : ∀ {t u n} → (t ∸ u ≡ suc n) → (t ≰ u)\n∸≢0-impl-≰ t∸u≡1+n t≤u \n with sym t∸u≡1+n trans ≤0-impl-≡0 (∸-min (t≤u ≤-trans ≡-impl-≤ (sym (+-unit _))))\n∸≢0-impl-≰ t∸u≡1+n t≤u \n | ()\n\nt∸u≢0-impl-u∸t≡0 : ∀ t u {n} → (t ∸ u ≡ suc n) → (u ∸ t ≡ 0)\nt∸u≢0-impl-u∸t≡0 t u {n} t∸u≡1+n with t≤u+t∸u {t} {u}\nt∸u≢0-impl-u∸t≡0 t u {n} t∸u≡1+n | (zero , t+0≡u+t∸u) =\n ≤-impl-∸≡0 (t ∸ u , sym t+0≡u+t∸u trans +-unit t)\nt∸u≢0-impl-u∸t≡0 t u {n} t∸u≡1+n | (suc m , t+1+m≡u+t∸u) = \n ⊥-elim (1+n≰n n (subst₂ _≤ℕ_ t∸u≡1+n refl \n (∸-min (m , suc-cancelʳ (t+1+m≡u+t∸u trans cong₂ _+_ refl t∸u≡1+n)))))\n\n_≤-total_ : ∀ t u → (t ≤ u) ⊎ (u < t)\nt ≤-total u with t ∸ u | inspect (_∸_ t) u\nt ≤-total u | zero | [ t∸u≡0 ] = inj₁ (∸≡0-impl-≤ t∸u≡0)\nt ≤-total u | suc n | [ t∸u≡1+n ] with t∸u≢0-impl-u∸t≡0 t u t∸u≡1+n\nt ≤-total u | suc n | [ t∸u≡1+n ] | u∸t≡0 = inj₂ (∸≡0-impl-≤ u∸t≡0 , ∸≢0-impl-≰ t∸u≡1+n)\n\n-- Case analysis on ≤\n\ndata _≤-Case_ (t u : Time) : Set where\n lt : .(t < u) → (t ≤-Case u)\n eq : .(t ≡ u) → (t ≤-Case u)\n gt : .(u < t) → (t ≤-Case u)\n\n_≤-case_ : ∀ t u → (t ≤-Case u)\nt ≤-case u with (t ∸ u) | inspect (_∸_ t) u | u ∸ t | inspect (_∸_ u) t\nt ≤-case u | zero | [ t∸u≡0 ] | zero | [ u∸t≡0 ] = eq (∸≡0-impl-≤ t∸u≡0 ≤-asym ∸≡0-impl-≤ u∸t≡0)\nt ≤-case u | suc n | [ t∸u≡1+n ] | zero | [ u∸t≡0 ] = gt (∸≡0-impl-≤ u∸t≡0 , ∸≢0-impl-≰ t∸u≡1+n)\nt ≤-case u | zero | [ t∸u≡0 ] | suc w₁ | [ u∸t≡1+n ] = lt (∸≡0-impl-≤ t∸u≡0 , ∸≢0-impl-≰ u∸t≡1+n)\nt ≤-case u | suc m | [ t∸u≡1+m ] | suc n | [ u∸t≡1+n ] with sym u∸t≡1+n trans t∸u≢0-impl-u∸t≡0 t u t∸u≡1+m\nt ≤-case u | suc m | [ t∸u≡1+m ] | suc n | [ u∸t≡1+n ] | ()\n\n-- + is monotone\n\n+-resp-≤ : ∀ {t u} → (t ≤ u) → ∀ n → (t + n ≤ u + n)\n+-resp-≤ (m , t+m≡u) n =\n ( m \n , +-assoc _ n m trans \n cong₂ _+_ refl (+ℕ-comm n m) trans \n sym (+-assoc _ m n) trans \n cong₂ _+_ t+m≡u refl )\n\n+-refl-≤ : ∀ {t u} n → (t + n ≤ u + n) → (t ≤ u)\n+-refl-≤ n (m , t+n+m≡u+n) = \n ( m \n , +-cancelʳ n \n (+-assoc _ m n trans \n cong₂ _+_ refl (+ℕ-comm m n) trans \n sym (+-assoc _ n m) trans \n t+n+m≡u+n) )\n\n-- Lemmas about <\n\n<-impl-≤ : ∀ {t u} → (t < u) → (t ≤ u)\n<-impl-≤ (t≤u , u≰t) = t≤u\n\n<-impl-≱ : ∀ {t u} → (t < u) → (u ≰ t)\n<-impl-≱ (t≤u , u≰t) = u≰t\n\n_<-transˡ_ : ∀ {t u v} → (t < u) → (u ≤ v) → (t < v)\n_<-transˡ_ (t≤u , u≰t) u≤v = (t≤u ≤-trans u≤v , λ v≤t → u≰t (u≤v ≤-trans v≤t))\n\n_<-transʳ_ : ∀ {t u v} → (t ≤ u) → (u < v) → (t < v)\n_<-transʳ_ t≤u (u≤v , v≰u) = (t≤u ≤-trans u≤v , λ v≤t → v≰u (v≤t ≤-trans t≤u))\n\n≤-proof-irrel′ : ∀ {t u m n} → (m ≡ n) → (t+m≡u : t + m ≡ u) → (t+n≡u : t + n ≡ u) → \n (t ≤ u) ∋ (m , t+m≡u) ≡ (n , t+n≡u)\n≤-proof-irrel′ refl refl refl = refl\n\nt≤t+1 : ∀ {t} → (t ≤ t + 1)\nt≤t+1 = (1 , refl)\n\nt≱t+1 : ∀ {t} → (t ≱ t + 1)\nt≱t+1 {t} (m , t+1+m≡t) with +-cancelˡ t (sym (+-assoc t 1 m) trans t+1+m≡t trans sym (+-unit t))\nt≱t+1 (m , t+1+m≡t) | ()\n\nt_\n field\n _<>_ : a → a → a\n\nopen Semigroup ⦃ ... ⦄ public\n\ninstance\n iSemigroupList : Semigroup (List a)\n iSemigroupList ._<>_ = _++_\n\n iSemigroupMaybe : ⦃ Semigroup a ⦄ → Semigroup (Maybe a)\n iSemigroupMaybe ._<>_ Nothing m = m\n iSemigroupMaybe ._<>_ m Nothing = m\n iSemigroupMaybe ._<>_ (Just x) (Just y) = Just (x <> y)\n\n iSemigroupEither : Semigroup (Either a b)\n iSemigroupEither ._<>_ (Left _) e = e\n iSemigroupEither ._<>_ e _ = e\n\n iSemigroupFun : ⦃ Semigroup b ⦄ → Semigroup (a → b)\n iSemigroupFun ._<>_ f g x = f x <> g x\n\n iSemigroupUnit : Semigroup ⊤\n iSemigroupUnit ._<>_ _ _ = tt\n\n iSemigroupTuple₀ : Semigroup (Tuple [])\n iSemigroupTuple₀ ._<>_ _ _ = []\n\n iSemigroupTuple : ∀ {as} → ⦃ Semigroup a ⦄ → ⦃ Semigroup (Tuple as) ⦄ → Semigroup (Tuple (a ∷ as))\n iSemigroupTuple ._<>_ (x ∷ xs) (y ∷ ys) = x <> y ∷ xs <> ys\n\n\n--------------------------------------------------\n-- Monoid\n\nrecord Monoid (a : Set) : Set where\n field\n mempty : a\n overlap ⦃ super ⦄ : Semigroup a\n\n mappend : a → a → a\n mappend = _<>_\n\n mconcat : List a → a\n mconcat [] = mempty\n mconcat (x ∷ xs) = x <> mconcat xs\n\nopen Monoid ⦃ ... ⦄ public\n\ninstance\n iMonoidList : Monoid (List a)\n iMonoidList .mempty = []\n\n iMonoidMaybe : ⦃ Semigroup a ⦄ → Monoid (Maybe a)\n iMonoidMaybe .mempty = Nothing\n\n iMonoidFun : ⦃ Monoid b ⦄ → Monoid (a → b)\n iMonoidFun .mempty _ = mempty\n\n iMonoidUnit : Monoid ⊤\n iMonoidUnit .mempty = tt\n\n iMonoidTuple₀ : Monoid (Tuple [])\n iMonoidTuple₀ .mempty = []\n\n iMonoidTuple : ∀ {as} → ⦃ Monoid a ⦄ → ⦃ Monoid (Tuple as) ⦄ → Monoid (Tuple (a ∷ as))\n iMonoidTuple .mempty = mempty ∷ mempty\n\nMonoidEndo : Monoid (a → a)\nMonoidEndo .mempty = id\nMonoidEndo .super ._<>_ = _∘_\n\nMonoidEndoᵒᵖ : Monoid (a → a)\nMonoidEndoᵒᵖ .mempty = id\nMonoidEndoᵒᵖ .super ._<>_ = flip _∘_\n\nMonoidConj : Monoid Bool\nMonoidConj .mempty = true\nMonoidConj .super ._<>_ = _&&_\n\nMonoidDisj : Monoid Bool\nMonoidDisj .mempty = false\nMonoidDisj .super ._<>_ = _||_\n", "meta": {"hexsha": "f29f527d256ff21296e033e95a3d427ced476f88", "size": 2405, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lib/Haskell/Prim/Monoid.agda", "max_stars_repo_name": "flupe/agda2hs", "max_stars_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/Haskell/Prim/Monoid.agda", "max_issues_repo_name": "flupe/agda2hs", "max_issues_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/Haskell/Prim/Monoid.agda", "max_forks_repo_name": "flupe/agda2hs", "max_forks_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.05, "max_line_length": 100, "alphanum_fraction": 0.6103950104, "num_tokens": 880, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.877476793890012, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.607777266674688}} {"text": "{-# OPTIONS --exact-split #-}\n\npostulate\n I : Set\n P : I → Set\n\nrecord ∃ (P : I → Set) : Set where\n constructor _,_\n field\n fst : I\n snd : P fst\n\nopen ∃\n\ndata S : ∃ P → Set where\n s : (i : I) (x : P i) → S (i , x)\n\nFoo : (p : ∃ P) → S p → Set\nFoo p (s .(fst p) .(snd p)) = I\n", "meta": {"hexsha": "c20cec77a525f306c9b44fbd3d0eef3a38a16252", "size": 279, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1380b.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue1380b.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue1380b.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 13.95, "max_line_length": 34, "alphanum_fraction": 0.4802867384, "num_tokens": 115, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8774767906859264, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.6077772644554038}} {"text": "-- Andreas, Jesper, 2017-05-13, issue #2578 reported by nad\n-- Jesper, 2017-07-06, absurd clauses are no longer highlighted as catchall,\n-- so the test case had to be changed to reproduce the intended behaviour.\n\ndata _⊎_ (A B : Set) : Set where\n inj₁ : A → A ⊎ B\n inj₂ : B → A ⊎ B\n\nrecord ⊤ : Set where\n constructor tt\n\ndata ⊥ : Set where\n\nMaybe : Set → Set\nMaybe A = ⊤ ⊎ A\n\npattern nothing = inj₁ tt\npattern just x = inj₂ x\n\nBool : Set\nBool = ⊤ ⊎ ⊤\n\npattern true = inj₁ tt\npattern false = inj₂ tt\n\nx : Maybe ⊥\nx = nothing\n\n_∋_ : ∀ {ℓ} → (A : Set ℓ) (a : A) → A\nA ∋ a = a\n\nA : Set₁\nA with Bool ∋ false\nA | true = Set\nA | false with x | x\n... | nothing | nothing = Set\n... | just x | _ = {!!}\n... | _ | just y = {!!}\n", "meta": {"hexsha": "8641276269e6c0c9512ca406adb385624f40d081", "size": 722, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue2578.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/interaction/Issue2578.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/interaction/Issue2578.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 18.5128205128, "max_line_length": 76, "alphanum_fraction": 0.5941828255, "num_tokens": 269, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.877476784277755, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.6077772600168353}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category using (Category; _[_,_]; _[_∘_]; _[_≈_])\n\n-- Bundled versions of Idempotents, as well as maps between idempotents.\nmodule Categories.Morphism.Idempotent.Bundles {o ℓ e} (𝒞 : Category o ℓ e) where\n\nopen import Level\n\nimport Categories.Morphism.Idempotent 𝒞 as Idem\nopen import Categories.Morphism.Reasoning 𝒞\n\nprivate\n module 𝒞 = Category 𝒞\n open 𝒞.HomReasoning\n open 𝒞.Equiv\n\n--------------------------------------------------------------------------------\n-- Bundled Idempotents, and maps between them\n\nrecord Idempotent : Set (o ⊔ ℓ ⊔ e) where\n field\n {obj} : 𝒞.Obj\n isIdempotent : Idem.Idempotent obj\n\n open Idem.Idempotent isIdempotent public\n\nopen Idempotent\n\nrecord Idempotent⇒ (I J : Idempotent) : Set (ℓ ⊔ e) where\n private\n module I = Idempotent I\n module J = Idempotent J\n field\n hom : 𝒞 [ I.obj , J.obj ]\n absorbˡ : 𝒞 [ 𝒞 [ J.idem ∘ hom ] ≈ hom ]\n absorbʳ : 𝒞 [ 𝒞 [ hom ∘ I.idem ] ≈ hom ]\n\nopen Idempotent⇒\n\n--------------------------------------------------------------------------------\n-- Identity and Composition of maps between Idempotents\n\nid : ∀ {I} → Idempotent⇒ I I\nid {I} = record\n { hom = idem I\n ; absorbˡ = idempotent I\n ; absorbʳ = idempotent I\n }\n\n_∘_ : ∀ {I J K} → (f : Idempotent⇒ J K) → (g : Idempotent⇒ I J) → Idempotent⇒ I K\n_∘_ {I} {J} {K} f g = record\n { hom = 𝒞 [ f.hom ∘ g.hom ]\n ; absorbˡ = pullˡ f.absorbˡ\n ; absorbʳ = pullʳ g.absorbʳ\n }\n where\n module f = Idempotent⇒ f\n module g = Idempotent⇒ g\n", "meta": {"hexsha": "c838d7bd073f9e90714acfc9ff870147c061cffb", "size": 1549, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Morphism/Idempotent/Bundles.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Morphism/Idempotent/Bundles.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Morphism/Idempotent/Bundles.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 25.8166666667, "max_line_length": 81, "alphanum_fraction": 0.5816655907, "num_tokens": 547, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774767746654976, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.6077772422245239}} {"text": "-- Functors on Set\n\nmodule Control.Functor where\n\nopen import Function using (id; flip) renaming (_∘′_ to _∘_)\nopen import Relation.Binary.PropositionalEquality\nopen ≡-Reasoning\n\n\n-- Operations of a functor.\n\nmodule T-FunctorOps (F : Set → Set) where\n\n -- Type of the map function.\n T-map = ∀ {A B} → (A → B) → F A → F B\n T-for = ∀ {A B} → F A → (A → B) → F B\n\nrecord FunctorOps (F : Set → Set) : Set₁ where\n open T-FunctorOps F\n\n -- The map function.\n field\n map : T-map\n\n -- Alternative notations.\n for : T-for\n for = flip map\n\n infixr 5 _<$>_ _<&>_\n _<$>_ = map\n _<&>_ = for\n\n\n-- Laws of a functor.\n\nmodule T-FunctorLaws {F : Set → Set} (ops : FunctorOps F) where\n open FunctorOps ops public\n\n -- First functor law: identity. ∀ (m : F A) → id <$> m ≡ m\n T-map-id = ∀ {A : Set} →\n\n map {A = A} id ≡ id\n\n -- Second functor law: composition. ∀ (m : F A) → (g ∘ f) <$> m ≡ g <$> (f <$> m)\n T-map-∘ = ∀ {A B C} {f : A → B} {g : B → C} →\n\n map (g ∘ f) ≡ map g ∘ map f\n\nrecord FunctorLaws {F : Set → Set} (ops : FunctorOps F) : Set₁ where\n open T-FunctorLaws ops\n\n field\n map-id : T-map-id\n map-∘ : T-map-∘\n\n\n-- Functoriality.\n\nrecord IsFunctor (F : Set → Set) : Set₁ where\n\n field\n ops : FunctorOps F\n laws : FunctorLaws ops\n\n open FunctorOps ops public\n open FunctorLaws laws public\n\nrecord Functor : Set₁ where\n constructor functor\n field\n F : Set → Set\n F! : IsFunctor F\n\n open IsFunctor F! public\n\n-- Id is a functor.\n\nidIsFunctor : IsFunctor (λ A → A)\nidIsFunctor = record\n { ops = record { map = λ f → f }\n ; laws = record { map-id = refl ; map-∘ = refl }\n }\n\nId : Functor\nId = record { F = λ A → A ; F! = idIsFunctor }\n\n-- Functors compose.\n\n-- open FunctorOps {{...}}\n-- open FunctorLaws {{...}}\n\ncompIsFunctor : ∀ {F G} → IsFunctor F → IsFunctor G → IsFunctor (λ A → F (G A))\ncompIsFunctor f g = record\n { ops = record { map = λ h → F.map (G.map h) }\n ; laws = record { map-id = trans (cong F.map G.map-id) F.map-id\n ; map-∘ = map-comp\n }\n }\n where\n module F = IsFunctor f\n module G = IsFunctor g\n\n map-comp : ∀ {A B C} {h : A → B} {i : B → C} →\n F.map (G.map (i ∘ h)) ≡ F.map (G.map i) ∘ F.map (G.map h)\n map-comp {h = h}{i = i} = begin\n F.map (G.map (i ∘ h))\n ≡⟨ cong F.map G.map-∘ ⟩\n F.map (G.map i ∘ G.map h)\n ≡⟨ F.map-∘ ⟩\n F.map (G.map i) ∘ F.map (G.map h)\n ∎\n\nComp : Functor → Functor → Functor\nComp (functor F F!) (functor G G!) = functor (λ A → F (G A)) (compIsFunctor F! G!)\n\n-- The constant functor.\n\nconstIsFunctor : ∀ A → IsFunctor (λ _ → A)\nconstIsFunctor A = record\n { ops = record { map = λ f x → x }\n ; laws = record { map-id = refl ; map-∘ = refl }\n }\n\nConst : (A : Set) → Functor\nConst A = functor (λ _ → A) (constIsFunctor A)\n\n\n\n", "meta": {"hexsha": "4ff78b180de6dc3f377f6eaa723dc9baf5ef2f74", "size": 2827, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Control/Functor.agda", "max_stars_repo_name": "andreasabel/cubical", "max_stars_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Control/Functor.agda", "max_issues_repo_name": "andreasabel/cubical", "max_issues_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Control/Functor.agda", "max_forks_repo_name": "andreasabel/cubical", "max_forks_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.9147286822, "max_line_length": 83, "alphanum_fraction": 0.5504067917, "num_tokens": 1030, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619263765707, "lm_q2_score": 0.7371581684030623, "lm_q1q2_score": 0.6077588435658132}} {"text": "open import Data.Nat\nopen import Data.Nat.Properties\nopen import Data.Bool\nopen import Function.Base\nopen import Data.Product\n\n-- Sizes are ordinals up to ω, i.e. naturals\n\n𝕊 : Set\n𝕊 = ℕ\n\nhat : 𝕊 → 𝕊\nhat = suc\n\n-- Sized naturals and lists indexed by a size\n\ndata SNat : (k : 𝕊) → Set where\n SZero : (k : 𝕊) → SNat k\n SSucc : (k : 𝕊) → SNat k → SNat (hat k)\n\ndata SList (A : Set) : (k : 𝕊) → Set where\n SNil : (k : 𝕊) → SList A k\n SCons : (k : 𝕊) → A → SList A k → SList A (hat k)\n\n-- Helpers to shift the size of lists up as needed\n\nshift : ∀ {A k} → SList A k → SList A (suc k)\nshift (SNil k) = SNil (suc k)\nshift (SCons k hd tl) = SCons (suc k) hd (shift tl)\n\nshiftBy : ∀ {A} → (k offset : 𝕊) → SList A k → SList A (k + offset)\nshiftBy _ offset (SNil k) = SNil (k + offset)\nshiftBy _ offset (SCons k hd tl) = SCons (k + offset) hd (shiftBy k offset tl)\n\n-- Minus and div functions, no unrolling needed\n-- Minus is size-preserving in the first argument, with an arbitrary second argument size\n-- Div is the same, also happening to be size-preesrving in the first argument\n\nminus : (k l : 𝕊) → SNat k → SNat l → SNat k\nminus _ _ (SZero k) _ = SZero k\nminus _ _ k (SZero l) = k\nminus _ _ (SSucc k n) (SSucc l m) = SSucc k (minus k l n m)\n\ndiv : (k l : 𝕊) → SNat k → SNat l → SNat k\ndiv _ _ (SZero k) _ = SZero k\ndiv _ _ (SSucc k n) m = SSucc _ (div k _ (minus k _ n m) m)\n\n-- Size-preserving filter\n\nfilter : ∀ {A} → (k : 𝕊) → (A → Bool) → SList A k → SList A k\nfilter zero _ ls = ls\nfilter (suc k) _ (SNil _) = SNil _\nfilter (suc k) pred (SCons k hd tl) =\n if (pred hd)\n then SCons k hd (filter k pred tl)\n else shift (filter k pred tl)\n\n-- Two appends: First one explicitly returns a list whose size is the sum of the input list sizes,\n-- while the second one returns a list with *some* size, which we don't know is the sum of the sizes\n\nappend : ∀ {A} → (k l : 𝕊) → SList A k → SList A l → SList A (k + l)\nappend zero _ _ ls = ls\nappend k l (SNil _) ls rewrite (+-comm k l) = shiftBy l k ls\nappend (suc k) l (SCons k hd tl) ls = SCons (k + l) hd (append k l tl ls)\n\nappend' : ∀ {A} → (k l : 𝕊) → SList A k → SList A l → ∃[ kl ] SList A kl\nappend' zero l _ ls = l , ls\nappend' k l (SNil _) ls = l , ls\nappend' (suc k) l (SCons k hd tl) ls =\n let kl , kls = append' k l tl ls\n in suc kl , SCons kl hd kls\n\n-- Qsort returning a list of some size\n-- The most specific size we could give it would probably be exponential\nqsort : (k : 𝕊) → SList ℕ k → ∃[ k ] (SList ℕ k)\nqsort zero ls = zero , ls\nqsort k (SNil _) = k , SNil _\nqsort (suc k) (SCons k hd tl) =\n let k1 , q1 = qsort k (filter k (_<ᵇ hd) tl)\n k2 , q2 = qsort k (filter k (not ∘ _<ᵇ_ hd) tl)\n in suc (k1 + k2) , SCons (k1 + k2) hd (append k1 k2 q1 q2)\n\n-- Longer example: base 2 logarithm\n\ndata LogDom : (s : 𝕊) → (p : ℕ) → Set where\n LogDom1 : (s : 𝕊) → LogDom s (suc zero)\n LogDom2 : (s : 𝕊) → (p : ℕ) → LogDom s (suc ⌊ p /2⌋) → LogDom (hat s) (suc (suc p))\n\npostulate logdomInv : (s : 𝕊) → (p : ℕ) → LogDom (hat s) (suc (suc p)) → LogDom s (suc ⌊ p /2⌋)\n", "meta": {"hexsha": "6a1e92ffba61ecc8af886ab8b22d1b5431c6b367", "size": 3035, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "code/InftyPair.agda", "max_stars_repo_name": "ionathanch/msc-thesis", "max_stars_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "code/InftyPair.agda", "max_issues_repo_name": "ionathanch/msc-thesis", "max_issues_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "code/InftyPair.agda", "max_forks_repo_name": "ionathanch/msc-thesis", "max_forks_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.7222222222, "max_line_length": 100, "alphanum_fraction": 0.6115321252, "num_tokens": 1203, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8902942319436397, "lm_q2_score": 0.682573740869499, "lm_q1q2_score": 0.6076914643723075}} {"text": "------------------------------------------------------------------------\n-- A library for working with dependently typed syntax\n-- Nils Anders Danielsson\n------------------------------------------------------------------------\n\n-- This library is leaning heavily on two of Conor McBride's papers:\n--\n-- * Type-Preserving Renaming and Substitution.\n--\n-- * Outrageous but Meaningful Coincidences: Dependent type-safe\n-- syntax and evaluation.\n\n-- This module gives a brief overview of the modules in the library.\n\nmodule README where\n\n------------------------------------------------------------------------\n-- The library\n\n-- Contexts, variables, context morphisms, context extensions, etc.\n\nimport deBruijn.Context\n\n-- Parallel substitutions (defined using an inductive family).\n\nimport deBruijn.Substitution.Data.Basics\n\n-- A map function for the substitutions.\n\nimport deBruijn.Substitution.Data.Map\n\n-- Some simple substitution combinators. (Given a term type which\n-- supports weakening and transformation of variables to terms various\n-- substitutions are defined and various lemmas proved.)\n\nimport deBruijn.Substitution.Data.Simple\n\n-- Given an operation which applies a substitution to a term,\n-- satisfying some properties, more operations and lemmas are\n-- defined/proved.\n--\n-- (This module reexports various other modules.)\n\nimport deBruijn.Substitution.Data.Application\n\n-- A module which repackages (and reexports) the development under\n-- deBruijn.Substitution.Data.\n\nimport deBruijn.Substitution.Data\n\n-- Some modules mirroring the development under\n-- deBruijn.Substitution.Data, but using substitutions defined as\n-- functions rather than data.\n--\n-- The functional version of substitutions is in some respects easier\n-- to work with than the one based on data, but in other respects more\n-- awkward. I maintain both developments so that they can be compared.\n\nimport deBruijn.Substitution.Function.Basics\nimport deBruijn.Substitution.Function.Map\nimport deBruijn.Substitution.Function.Simple\n\n-- The two definitions of substitutions are isomorphic (assuming\n-- extensionality).\n\nimport deBruijn.Substitution.Isomorphic\n\n------------------------------------------------------------------------\n-- An example showing how the library can be used\n\n-- A well-typed representation of a dependently typed language.\n\nimport README.DependentlyTyped.Term\n\n-- Normal and neutral terms.\n\nimport README.DependentlyTyped.NormalForm\n\n-- Instantiation of deBruijn.Substitution.Data for terms.\n\nimport README.DependentlyTyped.Term.Substitution\n\n-- Instantiation of deBruijn.Substitution.Data for normal and neutral\n-- terms.\n\nimport README.DependentlyTyped.NormalForm.Substitution\n\n-- Normalisation by evaluation.\n\nimport README.DependentlyTyped.NBE\n\n-- Various equality checkers (some complete, all sound).\n\nimport README.DependentlyTyped.Equality-checker\n\n-- Raw terms.\n\nimport README.DependentlyTyped.Raw-term\n\n-- A type-checker (sound).\n\nimport README.DependentlyTyped.Type-checker\n\n-- A definability result: A \"closed value\" is the semantics of a\n-- closed term if and only if it satisfies all \"Kripke predicates\".\n\nimport README.DependentlyTyped.Definability\n\n-- An observation: There is a term without a corresponding syntactic\n-- type (given some assumptions).\n\nimport README.DependentlyTyped.Term-without-type\n\n-- Another observation: If the \"Outrageous but Meaningful\n-- Coincidences\" approach is used to formalise a language, then you\n-- can end up with an extensional type theory (with equality\n-- reflection).\n\nimport README.DependentlyTyped.Extensional-type-theory\n\n-- Inductively defined beta-eta-equality.\n\nimport README.DependentlyTyped.Beta-Eta\n\n-- TODO: Add an untyped example.\n", "meta": {"hexsha": "1ab7ef005ad76d30967e51bf2afc5d0b7ba32ca6", "size": 3702, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "README.agda", "max_stars_repo_name": "nad/dependently-typed-syntax", "max_stars_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-04-16T12:14:44.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-08T22:51:36.000Z", "max_issues_repo_path": "README.agda", "max_issues_repo_name": "nad/dependently-typed-syntax", "max_issues_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "README.agda", "max_forks_repo_name": "nad/dependently-typed-syntax", "max_forks_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.380952381, "max_line_length": 72, "alphanum_fraction": 0.7296056186, "num_tokens": 757, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672135527632, "lm_q2_score": 0.7520125848754471, "lm_q1q2_score": 0.6076767140169134}} {"text": "{-# OPTIONS --type-in-type #-}\n\nmodule Lec6 where\n\nopen import Lec1Done\n\nListF : Set -> Set -> Set\nListF X T = One + (X * T)\n\ndata List (X : Set) : Set where\n <_> : (ListF X) (List X) -> (List X)\ninfixr 4 _,-_\n\nlistF : {X T U : Set} -> (T -> U) -> (ListF X) T -> (ListF X) U\nlistF g (inl <>) = inl <>\nlistF g (inr (x , t)) = inr (x , g t)\n\npattern [] = < inl <> >\npattern _,-_ x xs = < inr (x , xs) >\n\n{-(-}\nmkList : {X : Set} -> (ListF X) (List X) -> List X\nmkList = <_>\n{-\nmkList (inl <>) = []\nmkList (inr (x , xs)) = x ,- xs\n-}\n{-)-}\n\n{-(-}\nfoldr : {X T : Set} -> ((ListF X) T -> T) -> List X -> T\nfoldr alg [] = alg (inl <>)\nfoldr alg (x ,- xs) = alg (inr (x , foldr alg xs))\n\nex1 = foldr mkList (1 ,- 2 ,- 3 ,- [])\n{-)-}\n\n{-(-}\nlength : {X : Set} -> List X -> Nat\nlength = foldr \\ { (inl <>) -> zero ; (inr (x , n)) -> suc n }\n{-)-}\n\nrecord CoList (X : Set) : Set where\n coinductive\n field\n force : (ListF X) (CoList X)\nopen CoList\n\n{-(-}\n[]~ : {X : Set} -> CoList X\nforce []~ = inl <>\n\n_,~_ : {X : Set} -> X -> CoList X -> CoList X\nforce (x ,~ xs) = inr (x , xs)\ninfixr 4 _,~_\n{-)-}\n\n{-(-}\nunfoldr : {X S : Set} -> (S -> (ListF X) S) -> S -> CoList X\nforce (unfoldr coalg s) with coalg s\nforce (unfoldr coalg s) | inl <> = inl <>\nforce (unfoldr coalg s) | inr (x , s') = inr (x , unfoldr coalg s')\n\nex2 = unfoldr force (1 ,~ 2 ,~ 3 ,~ []~)\n{-)-}\n\n{-(-}\nrepeat : {X : Set} -> X -> CoList X\nrepeat = unfoldr \\ x -> inr (x , x)\n{-)-}\n\n{-(-}\nprefix : {X : Set} -> Nat -> CoList X -> List X\nprefix zero xs = []\nprefix (suc n) xs with force xs\nprefix (suc n) xs | inl <> = []\nprefix (suc n) xs | inr (x , xs') = x ,- prefix n xs'\n\nex2' = prefix 3 ex2\n{-)-}\n\nStreamF : Set -> Set -> Set\nStreamF X S = X * S\n\ndata Funny (X : Set) : Set where\n <_> : (StreamF X) (Funny X) -> Funny X\n\nfunny : {X : Set} -> Funny X -> Zero\nfunny < x , xf > = funny xf\n\nrecord Stream (X : Set) : Set where\n coinductive\n field\n hdTl : (StreamF X) (Stream X)\nopen Stream\n\n{-(-}\nforever : {X : Set} -> X -> Stream X\nfst (hdTl (forever x)) = x\nsnd (hdTl (forever x)) = forever x\n{-)-}\n\nnatsFrom : Nat -> Stream Nat\nfst (hdTl (natsFrom n)) = n\nsnd (hdTl (natsFrom n)) = natsFrom (suc n)\n\nsprefix : {X : Set} -> Nat -> Stream X -> List X -- could be Vec X n\nsprefix zero xs = []\nsprefix (suc n) xs with hdTl xs\nsprefix (suc n) xs | x , xs' = x ,- sprefix n xs'\n\n{-(-}\nunfold : {X S : Set} -> (S -> X * S) -> S -> Stream X\nhdTl (unfold coalg s) with coalg s\nhdTl (unfold coalg s) | x , s' = x , unfold coalg s'\n{-)-}\n\nnatsFrom' : Nat -> Stream Nat\nnatsFrom' = unfold \\ n -> n , suc n\n\ndata Two : Set where tt ff : Two\n\nSo : Two -> Set\nSo tt = One\nSo ff = Zero\n\nisSuc : Nat -> Two\nisSuc zero = ff\nisSuc (suc n) = tt\n\n{-\ndiv : (x y : Nat) -> So (isSuc y) -> Nat\ndiv x zero ()\ndiv x (suc y) p = {!!}\n-}\n\ndata Poly (X : Set) : Set where\n var' : X -> Poly X\n konst' : Two -> Poly X\n _+'_ _*'_ : Poly X -> Poly X -> Poly X\n\nEval : {X : Set} -> (X -> Set) -> Poly X -> Set\nEval var (var' x) = var x\nEval var (konst' b) = So b\nEval var (p +' q) = Eval var p + Eval var q\nEval var (p *' q) = Eval var p * Eval var q\n\neval : {X : Set}(u v : X -> Set)(p : Poly X) ->\n ((x : X) -> u x -> v x) ->\n Eval u p -> Eval v p\neval u v (var' i) f x = f i x\neval u v (konst' b) f x = x\neval u v (p +' q) f (inl x) = inl (eval u v p f x)\neval u v (p +' q) f (inr x) = inr (eval u v q f x)\neval u v (p *' q) f (x , y) = eval u v p f x , eval u v q f y\n\ndata Mu (p : Poly One) : Set where\n <_> : Eval (\\ _ -> Mu p) p -> Mu p\n\nNatP : Poly One\nNatP = konst' tt +' var' <>\n\nNAT = Mu NatP\n\nze : NAT\nze = < (inl <>) >\n\nsu : NAT -> NAT\nsu n = < (inr n) >\n\nTreeP : Poly One\nTreeP = konst' tt +' (var' <> *' var' <>)\n\n-- What's a one-hole context in a Mu P?\n\nDiff : Poly One -> Poly One\nDiff (var' x) = konst' tt\nDiff (konst' x) = konst' ff\nDiff (p +' q) = Diff p +' Diff q\nDiff (p *' q) = (Diff p *' q) +' (p *' Diff q)\n\nplug : {X : Set}(p : Poly One) ->\n X -> Eval (\\ _ -> X) (Diff p) ->\n Eval (\\ _ -> X) p\nplug (var' <>) x <> = x\nplug (konst' b) x ()\nplug (p +' q) x (inl xp') = inl (plug p x xp')\nplug (p +' q) x (inr xq') = inr (plug q x xq')\nplug (p *' q) x (inl (xp' , xq)) = plug p x xp' , xq\nplug (p *' q) x (inr (xp , xq')) = xp , plug q x xq'\n\nContext : Poly One -> Set\nContext p = List (Eval (\\ _ -> Mu p) (Diff p))\n\nplugs : (p : Poly One) -> Mu p -> Context p -> Mu p\nplugs p t [] = t\nplugs p t (t' ,- t's) = plugs p < plug p t t' > t's\n\n\nTernaryP : Poly One\nTernaryP = konst' tt +' (var' <> *' (var' <> *' var' <>))\n\n\n\n\nfold : (p : Poly One){T : Set}\n -> (Eval (\\ _ -> T) p -> T)\n -> Mu p -> T\nfold p {T} alg < x > = alg (evalFold p x)\n where\n evalFold : (q : Poly One) -> Eval (\\ _ -> Mu p) q -> Eval (\\ _ -> T) q\n evalFold (var' <>) x = fold p alg x\n evalFold (konst' b) x = x\n evalFold (q +' r) (inl y) = inl (evalFold q y)\n evalFold (q +' r) (inr y) = inr (evalFold r y)\n evalFold (q *' r) (y , z) = evalFold q y , evalFold r z\n\nrecord Nu (p : Poly One) : Set where\n coinductive\n field\n out : Eval (\\ _ -> Nu p) p\n\n\n\n\n-- What's the connection between polynomials and containers?\n\n_-:>_ : {I : Set} -> (I -> Set) -> (I -> Set) -> (I -> Set)\n(S -:> T) i = S i -> T i\n\n[_] : {I : Set} -> (I -> Set) -> Set\n[ P ] = forall i -> P i -- [_] {I} P = (i : I) -> P i\n\nAll : {X : Set} -> (X -> Set) -> (List X -> Set)\nAll P [] = One\nAll P (x ,- xs) = P x * All P xs\n\nrecord _|>_ (I O : Set) : Set where\n field\n Cuts : O -> Set -- given o : O, how may we cut it?\n inners : {o : O} -> Cuts o -> List I -- given how we cut it, what are\n -- the shapes of its pieces?\n\nrecord Cutting {I O}(C : I |> O)(P : I -> Set)(o : O) : Set where\n constructor _8><_ -- \"scissors\"\n open _|>_ C\n field\n cut : Cuts o -- we decide how to cut o\n pieces : All P (inners cut) -- then we give all the pieces.\ninfixr 3 _8><_\n\ndata Interior {I}(C : I |> I)(T : I -> Set)(i : I) : Set where\n -- either...\n tile : T i -> Interior C T i -- we have a tile that fits, or...\n <_> : Cutting C (Interior C T) i -> -- ...we cut, then tile the pieces.\n Interior C T i\n\n\n_+L_ : {X : Set} -> List X -> List X -> List X\n[] +L ys = ys\n(x ,- xs) +L ys = x ,- (xs +L ys)\n\npolyCon : {I : Set} -> Poly I -> I |> One\n_|>_.Cuts (polyCon p) <> = Eval (\\ _ -> One) p\n_|>_.inners (polyCon (var' i)) <> = i ,- []\n_|>_.inners (polyCon (konst' x)) s = []\n_|>_.inners (polyCon (p +' q)) (inl xp) = _|>_.inners (polyCon p) xp\n_|>_.inners (polyCon (p +' q)) (inr xq) = _|>_.inners (polyCon q) xq\n_|>_.inners (polyCon (p *' q)) (sp , sq) =\n _|>_.inners (polyCon p) sp +L _|>_.inners (polyCon q) sq\n\n\nChoose : {I J : Set} -> (I -> Set) -> (J -> Set) -> (I + J) -> Set\nChoose X Y (inl i) = X i\nChoose X Y (inr j) = Y j\n\ndata MU {I -- what sorts of \"elements\" do we store?\n J -- what sorts of \"nodes\" do we have?\n : Set}\n (F : J -> Poly (I + J)) -- what is the structure of each sort of node?\n (X : I -> Set) -- what are the elements?\n (j : J) -- what sort is the outermost node?\n : Set where\n <_> : Eval (Choose X (MU F X)) -- subnodes in recursive positions\n (F j)\n -> MU F X j\n \nVecF : Nat -> Poly (One + Nat)\nVecF zero = konst' tt\nVecF (suc n) = (var' (inl <>)) *' (var' (inr n))\n\nVEC : Nat -> Set -> Set\nVEC n X = MU VecF (\\ _ -> X) n\n\nvnil : {X : Set} -> VEC zero X\nvnil = < <> >\n\nvcons : {X : Set}{n : Nat} -> X -> VEC n X -> VEC (suc n) X\nvcons x xs = < (x , xs) >\n\ngmap : {I -- what sorts of \"elements\" do we store?\n J -- what sorts of \"nodes\" do we have?\n : Set}\n {F : J -> Poly (I + J)} -- what is the structure of each sort of node?\n {X Y : I -> Set} -> -- what are the elements?\n ((i : I) -> X i -> Y i) ->\n (j : J) ->\n MU F X j -> MU F Y j\ngmapHelp : ∀ {I J} (F : J → Poly (I + J)) {X Y : I → Set}\n (w : Poly (I + J)) →\n ((i : I) → X i → Y i) →\n Eval (Choose X (MU F X)) w →\n Eval (Choose Y (MU F Y)) w\ngmap {F = F} f j < xt > = < gmapHelp F (F j) f xt >\ngmapHelp F (var' (inl i)) f x = f i x\ngmapHelp F (var' (inr j)) f t = gmap f j t\ngmapHelp F (konst' x) f v = v\ngmapHelp F (p +' q) f (inl xp) = inl (gmapHelp F p f xp)\ngmapHelp F (p +' q) f (inr xq) = inr (gmapHelp F q f xq)\ngmapHelp F (p *' q) f (xp , xq) = (gmapHelp F p f xp) , (gmapHelp F q f xq)\n", "meta": {"hexsha": "19534027526ee6c0d06cace1adfb2dc71022b2e9", "size": 8604, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec6.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec6.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec6.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 26.8037383178, "max_line_length": 81, "alphanum_fraction": 0.4815202232, "num_tokens": 3341, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430436757312, "lm_q2_score": 0.731058584489497, "lm_q1q2_score": 0.6076142570178723}} {"text": "module imper-nouni where\n\n--\n-- TO-DOs\n--\n-- * change use of =string\n-- * prove that =string can't be both tt and ff\n-- * prove reverse theorems for passes/fails/chck\n-- * prove semantic equivalence for execs and execsTo\n-- + this would be s-thm and s-det\n\nopen import lib\nopen import eq-reas-nouni\n\n_=nat_ = _=ℕ_\n\n_-nat_ = _∸_\n\ncross = _×_\n\nequiv = _≡_\n\nbottom = ⊥\n\nbottom-elim = ⊥-elim\n\n--\n-- inspect/with-eq idiom\n--\n\ndata Singleton {a} {A : Set a} (x : A) : Set a where\n _with-eq_ : (y : A) → equiv x y → Singleton x\n\ninspect : forall {a} {A : Set a} (x : A) -> Singleton x\ninspect x = x with-eq refl\n\n--\n-- variable identifiers\n--\nId : Set\nId = string\n\n_=Id_ : Id -> Id -> bool\n_=Id_ = _=string_\n\n--\n-- values (just natural numbers here)\n--\n\nVal : Set\nVal = nat\n\n--\n-- value and variable expressions\n--\ndata Expn : Set where\n val : Val -> Expn\n var : Id -> Expn\n plus : Expn -> Expn -> Expn\n minus : Expn -> Expn -> Expn\n scaleBy : Expn -> Val -> Expn\n\n--\n-- conditions on values and variables\n--\ndata Cond : Set where\n true : Cond\n false : Cond\n and : Cond -> Cond -> Cond\n or : Cond -> Cond -> Cond\n not : Cond -> Cond\n less : Expn -> Expn -> Cond\n equal : Expn -> Expn -> Cond\n\n--\n-- stack frames containing variable bindings\n--\nFrm : Set\nFrm = list (cross Id Val)\n\n--\n-- program statements that transform a frame\n--\ndata Stmt : Set where\n skip : Stmt\n assign : Id -> Expn -> Stmt\n seq : Stmt -> Stmt -> Stmt\n ifThenElse : Cond -> Stmt -> Stmt -> Stmt\n repeatBy : Id -> Stmt -> Stmt\n returns : Expn -> Stmt\n\n--\n-- functional SEMANTICS of frames\n--\n\nlkup : Id -> Frm -> Val\nlkup x [] = 0\nlkup x ((y , w) :: F) = if (x =Id y) then w else (lkup x F)\n\nupdate : Id -> Val -> Frm -> Frm\nupdate x v [] = (x , v) :: []\nupdate x v ((y , w) :: F) \n = if (x =Id y)\n then (y , v) :: F\n else (y , w) :: (update x v F)\n--\n-- functional SEMANTICS of expressions\n--\neval : Expn -> Frm -> Val\neval (val v) F = v\neval (var x) F = lkup x F\neval (plus e1 e2) F = (eval e1 F) + (eval e2 F)\neval (minus e1 e2) F = (eval e1 F) -nat (eval e2 F)\neval (scaleBy e1 v2) F = (eval e1 F) * v2\n\n--\n-- functional SEMANTICS of conditions\n--\nchck : Cond -> Frm -> bool\nchck true F = tt\nchck false F = ff\nchck (and c1 c2) F = (chck c1 F) && (chck c2 F)\nchck (or c1 c2) F = (chck c1 F) || (chck c2 F)\nchck (not c) F = ~ (chck c F)\nchck (less e1 e2) F = (eval e1 F) < (eval e2 F)\nchck (equal e1 e2) F = (eval e1 F) =nat (eval e2 F)\n\n--\n-- functional SEMANTICS of program execution\n--\nexec : Stmt -> Frm -> Frm\nrepeatedly : Stmt -> Id -> nat -> Frm -> Frm\nrepeatedly s x 0 F = F\nrepeatedly s x (suc n) F = repeatedly s x n (update x n (exec s F))\nexec skip F = F\nexec (seq s1 s2) F = (exec s2 (exec s1 F))\nexec (assign x e) F = (update x (eval e F) F)\nexec (ifThenElse c s1 s2) F = if (chck c F) then (exec s1 F) else (exec s2 F)\nexec (repeatBy x s) F = repeatedly s x (lkup x F) F\nexec (returns e) F = (update \"retval\" (eval e F) F)\n\n--\n-- SEMANTICS of stack bindings as a relation\n--\ndata mapsTo : Frm -> Id -> Val -> Set where\n\n var-undef : forall {x : Id}\n ----------------\n -> (mapsTo [] x 0)\n\n var-match : forall {x y : Id} {F : Frm} {v : Val}\n -> (equiv (x =string y) tt)\n ---------------------------\n -> (mapsTo ((y , v) :: F) x v) \n\n var-mismatch : forall {x y : Id} {F : Frm} {v w : Val}\n -> (equiv (x =string y) ff)\n -> (mapsTo F x v)\n ----------------------------\n -> (mapsTo ((y , w) :: F) x v)\n\n--\n-- THEOREM: mapsTo agrees with lookup\n--\nvar-thm : forall (x : Id) (F : Frm) -> mapsTo F x (lkup x F)\nvar-thm x [] = var-undef\nvar-thm x ((y , w) :: F)\n with (inspect (x =string y))\n... | tt with-eq match =\n let lkup-is-w : (equiv (lkup x ((y , w) :: F)) w)\n lkup-is-w = cong3 if_then_else_ match refl refl\n in cong-pred (mapsTo ((y , w) :: F) x) (sym lkup-is-w) (var-match match)\n... | ff with-eq mismatch = \n let lkup-is-lkup : (equiv (lkup x ((y , w) :: F)) (lkup x F))\n lkup-is-lkup = cong3 if_then_else_ mismatch refl refl\n in cong-pred (mapsTo ((y , w) :: F) x) (sym lkup-is-lkup) (var-mismatch mismatch (var-thm x F))\n\npostulate\n =Id-det : ∀ {x y : Id} -> (equiv (x =string y) tt) -> (equiv (x =string y) ff) -> bottom\n \nvar-det : forall{x : Id}{F : Frm}{u1 u2 : Val}\n -> mapsTo F x u1 -> mapsTo F x u2 -> equiv u1 u2\nvar-det{x}{[]}{u1}{u2} var-undef var-undef =\n refl\nvar-det{x}{(y , w) :: F}{u1}{u2} (var-match _) (var-match _) =\n refl\nvar-det{x}{(y , w) :: F}{u1}{u2} (var-mismatch _ lkup-is-u1) (var-mismatch _ lkup-is-u2) =\n var-det lkup-is-u1 lkup-is-u2\nvar-det{x}{(y , w) :: F}{u1}{u2} (var-match{.x}{.y}{.F}{.u1} same) (var-mismatch{.x}{.y}{.F}{.u2} diff _) =\n bottom-elim (=Id-det{x}{y} same diff)\nvar-det{x}{(y , w) :: F}{u1}{u2} (var-mismatch{.x}{.y}{.F}{.u1} diff _) (var-match{.x}{.y}{.F}{.u2} same) =\n bottom-elim (=Id-det{x}{y} same diff)\n\n--\n-- SEMANTICS of expression evaluation as a relation\n--\n\ndata evalsTo : Frm -> Expn -> Val -> Set where\n\n e-val : forall {v : Val} {F : Frm}\n ------------------------\n -> (evalsTo F (val v) v)\n\n e-var : forall {x : Id} {F : Frm} {v : Val}\n -> (mapsTo F x v)\n ------------------------\n -> (evalsTo F (var x) v) \n\n e-add : forall {e1 e2 : Expn} {F : Frm} {v1 v2 : Val}\n -> (evalsTo F e1 v1) \n -> (evalsTo F e2 v2) \n -------------------------------------\n -> (evalsTo F (plus e1 e2) (v1 + v2))\n\n e-sub : forall {e1 e2 : Expn} {F : Frm} {v1 v2 : Val}\n -> (evalsTo F e1 v1) \n -> (evalsTo F e2 v2) \n -----------------------------------------\n -> (evalsTo F (minus e1 e2) (v1 -nat v2))\n\n e-scale : forall {e1 : Expn} {F : Frm} {v1 v2 : Val}\n -> (evalsTo F e1 v1) \n ----------------------------------------\n -> (evalsTo F (scaleBy e1 v2) (v1 * v2))\n\n\ne-thm : forall (e : Expn) -> (F : Frm) -> (evalsTo F e (eval e F))\ne-thm (val e) F = e-val\ne-thm (var x) F = e-var (var-thm x F)\ne-thm (plus e1 e2) F = (e-add (e-thm e1 F) (e-thm e2 F))\ne-thm (minus e1 e2) F = (e-sub (e-thm e1 F) (e-thm e2 F))\ne-thm (scaleBy e1 v2) F = (e-scale (e-thm e1 F))\n\ne-det : forall {e : Expn}{F : Frm}{u w : Val}\n -> (evalsTo F e u) -> (evalsTo F e w) -> (equiv u w)\ne-det{val v}{F}{u}{w} e-val e-val = refl \ne-det{var x}{F}{u}{w} (e-var var-lkup-u) (e-var var-lkup-v) =\n var-det var-lkup-u var-lkup-v\ne-det{plus e1 e2}{F}{u}{w} (e-add e-u1 e-u2) (e-add e-w1 e-w2) =\n cong2 _+_ (e-det e-u1 e-w1) (e-det e-u2 e-w2)\ne-det{minus e1 e2}{F}{u}{w} (e-sub e-u1 e-u2) (e-sub e-w1 e-w2) =\n cong2 _-nat_ (e-det e-u1 e-w1) (e-det e-u2 e-w2)\ne-det{scaleBy e1 v2}{F}{u}{w} (e-scale e-u1) (e-scale e-w1) =\n cong2 _*_ (e-det e-u1 e-w1) refl\n\ne-thm-fwd : forall {e : Expn}{F : Frm}{v : Val}\n -> (evalsTo F e v) -> (equiv v (eval e F))\ne-thm-fwd{e}{F}{v} ev =\n let\n p1 : evalsTo F e (eval e F)\n p1 = e-thm e F\n in e-det ev p1 \n\ne-thm-rev : forall {e : Expn}{F : Frm}{v : Val}\n -> (equiv v (eval e F)) -> (evalsTo F e v)\ne-thm-rev{e}{F}{v} v-is = cong-pred (evalsTo F e) (sym v-is) (e-thm e F)\n\n--\n-- SEMANTICS of conditions as a decidable relation\n--\n\ndata passes : Frm -> Cond -> Set\ndata fails : Frm -> Cond -> Set\n\ndata passes where\n\n c-tt : forall {F : Frm}\n ----------------\n -> passes F true\n\n c-and : forall {c1 c2 : Cond} {F : Frm}\n -> passes F c1\n -> passes F c2\n -----------------------\n -> passes F (and c1 c2)\n\n c-or1 : forall {c1 c2 : Cond} {F : Frm}\n -> passes F c1\n ----------------------\n -> passes F (or c1 c2)\n\n c-or2 : forall {c1 c2 : Cond} {F : Frm}\n -> passes F c2\n ----------------------\n -> passes F (or c1 c2)\n\n c-less : forall {e1 e2 : Expn} {F : Frm} {v1 v2 : Val}\n -> equiv (v1 < v2) tt\n -> evalsTo F e1 v1\n -> evalsTo F e2 v2\n -------------------------\n -> passes F (less e1 e2)\n\n c-eq : forall {e1 e2 : Expn} {F : Frm} {v1 v2 : Val}\n -> equiv (v1 =nat v2) tt\n -> evalsTo F e1 v1\n -> evalsTo F e2 v2\n --------------------------\n -> passes F (equal e1 e2)\n\n c-not : forall {c : Cond} {F : Frm}\n -> fails F c\n -------------------\n -> passes F (not c)\n\ndata fails where\n\n ~c-ff : forall {F : Frm}\n ----------------\n -> fails F false\n\n ~c-or : forall {c1 c2 : Cond} {F : Frm}\n -> fails F c1\n -> fails F c2\n -----------------------\n -> fails F (or c1 c2)\n\n ~c-and1 : forall {c1 c2 : Cond} {F : Frm}\n -> fails F c1\n ----------------------\n -> fails F (and c1 c2)\n\n ~c-and2 : forall {c1 c2 : Cond} {F : Frm}\n -> fails F c2\n ----------------------\n -> fails F (and c1 c2)\n\n ~c-less : forall {e1 e2 : Expn} {F : Frm} {v1 v2 : Val}\n -> equiv (v1 < v2) ff\n -> evalsTo F e1 v1\n -> evalsTo F e2 v2\n -------------------------\n -> fails F (less e1 e2)\n\n ~c-eq : forall {e1 e2 : Expn} {F : Frm} {v1 v2 : Val}\n -> equiv (v1 =nat v2) ff\n -> evalsTo F e1 v1\n -> evalsTo F e2 v2\n --------------------------\n -> fails F (equal e1 e2)\n\n ~c-not : forall {c : Cond} {F : Frm}\n -> passes F c\n -------------------\n -> fails F (not c)\n\nc-thm-fwd : forall {c : Cond}{F : Frm} -> (passes F c) -> (equiv (chck c F) tt)\n~c-thm-fwd : forall {c : Cond}{F : Frm} -> (fails F c) -> (equiv (chck c F) ff)\n\nc-thm-fwd (c-tt{F}) = refl\nc-thm-fwd (c-and{c1}{c2}{F} passes-c1 passes-c2) =\n cong2 _&&_ (c-thm-fwd passes-c1) (c-thm-fwd passes-c2)\nc-thm-fwd (c-or1{c1}{c2}{F} passes-c1) =\n cong2 _||_ (c-thm-fwd passes-c1) refl\nc-thm-fwd (c-or2{c1}{c2}{F} passes-c2) =\n trans (cong2 _||_ refl (c-thm-fwd passes-c2)) (||-tt (chck c1 F))\nc-thm-fwd (c-less{e1}{e2}{F}{v1}{v2} v1-less-v2 evalsTo-e1-v1 evalsTo-e2-v2) =\n let\n eval-e1-is-v1 : (equiv (eval e1 F) v1)\n eval-e1-is-v1 = sym (e-thm-fwd evalsTo-e1-v1)\n eval-e2-is-v2 : (equiv (eval e2 F) v2)\n eval-e2-is-v2 = sym (e-thm-fwd evalsTo-e2-v2)\n in\n begin\n chck (less e1 e2) F\n equiv[ refl ]\n (eval e1 F) < (eval e2 F)\n equiv[ cong2 _<_ eval-e1-is-v1 eval-e2-is-v2 ]\n v1 < v2\n equiv[ v1-less-v2 ]\n tt\n qed\nc-thm-fwd (c-eq{e1}{e2}{F}{v1}{v2} v1-equals-v2 evalsTo-e1-v1 evalsTo-e2-v2) =\n let\n eval-e1-is-v1 : (equiv (eval e1 F) v1)\n eval-e1-is-v1 = sym (e-thm-fwd evalsTo-e1-v1)\n eval-e2-is-v2 : (equiv (eval e2 F) v2)\n eval-e2-is-v2 = sym (e-thm-fwd evalsTo-e2-v2)\n in\n begin\n chck (equal e1 e2) F\n equiv[ refl ]\n (eval e1 F) =nat (eval e2 F)\n equiv[ cong2 _=nat_ eval-e1-is-v1 eval-e2-is-v2 ]\n v1 =nat v2\n equiv[ v1-equals-v2 ]\n tt\n qed\nc-thm-fwd (c-not{c}{F} c-fails) = cong ~_ (~c-thm-fwd c-fails)\n\n~c-thm-fwd (~c-ff{F}) =\n refl\n~c-thm-fwd (~c-or{c1}{c2}{F} fails-c1 fails-c2) =\n cong2 _||_ (~c-thm-fwd fails-c1) (~c-thm-fwd fails-c2)\n~c-thm-fwd (~c-and1{c1}{c2}{F} fails-c1) =\n cong2 _&&_ (~c-thm-fwd fails-c1) refl\n~c-thm-fwd (~c-and2{c1}{c2}{F} fails-c2) =\n trans (cong2 _&&_ refl (~c-thm-fwd fails-c2)) (&&-ff (chck c1 F))\n~c-thm-fwd (~c-less{e1}{e2}{F}{v1}{v2} v1-not-less-v2 evalsTo-e1-v1 evalsTo-e2-v2) =\n let\n eval-e1-is-v1 : (equiv (eval e1 F) v1)\n eval-e1-is-v1 = sym (e-thm-fwd evalsTo-e1-v1)\n eval-e2-is-v2 : (equiv (eval e2 F) v2)\n eval-e2-is-v2 = sym (e-thm-fwd evalsTo-e2-v2)\n in begin\n chck (less e1 e2) F\n equiv[ refl ]\n (eval e1 F) < (eval e2 F)\n equiv[ cong2 _<_ eval-e1-is-v1 eval-e2-is-v2 ]\n v1 < v2\n equiv[ v1-not-less-v2 ]\n ff\n qed\n~c-thm-fwd (~c-eq{e1}{e2}{F}{v1}{v2} v1-not-equals-v2 evalsTo-e1-v1 evalsTo-e2-v2) =\n let\n eval-e1-is-v1 : (equiv (eval e1 F) v1)\n eval-e1-is-v1 = sym (e-thm-fwd evalsTo-e1-v1)\n eval-e2-is-v2 : (equiv (eval e2 F) v2)\n eval-e2-is-v2 = sym (e-thm-fwd evalsTo-e2-v2)\n in\n begin\n chck (equal e1 e2) F\n equiv[ refl ]\n (eval e1 F) =nat (eval e2 F)\n equiv[ cong2 _=nat_ eval-e1-is-v1 eval-e2-is-v2 ]\n v1 =nat v2\n equiv[ v1-not-equals-v2 ]\n ff\n qed\n~c-thm-fwd (~c-not{c}{F} c-passes) =\n cong ~_ (c-thm-fwd c-passes)\n\n-- These can probably be shown just by using\n-- the contrapositives of ~c-thm-fwd and ~~c-thm-fwd\npostulate\n c-thm-rev : forall {c : Cond}{F : Frm} -> (equiv (chck c F) tt) -> (passes F c)\n ~c-thm-rev : forall {c : Cond}{F : Frm} -> (equiv (chck c F) ff) -> (fails F c)\n\n--\n-- SEMANTICS of program statements\n-- as a state transformation relation\n--\n\ndata execsTo : Frm -> Stmt -> Frm -> Set where\n\n s-skip : forall {F : Frm}\n -------------------\n -> execsTo F skip F\n\n s-assign : forall {x : Id} {e : Expn} {F : Frm} {v : Val}\n -> evalsTo F e v\n ----------------------------------------\n -> execsTo F (assign x e) (update x v F)\n\n s-seq : forall {s1 s2 : Stmt} {F0 F1 F2 : Frm}\n -> (execsTo F0 s1 F1)\n -> (execsTo F1 s2 F2)\n ------------------------------\n -> (execsTo F0 (seq s1 s2) F2)\n\n s-if-then : forall {c : Cond} {s1 s2 : Stmt} {F F' : Frm}\n -> (passes F c)\n -> (execsTo F s1 F')\n --------------------------------------\n -> (execsTo F (ifThenElse c s1 s2) F')\n\n s-if-else : forall {c : Cond} {s1 s2 : Stmt} {F F' : Frm}\n -> (fails F c)\n -> (execsTo F s2 F')\n --------------------------------------\n -> (execsTo F (ifThenElse c s1 s2) F')\n\n s-repeat-0 : forall {s : Stmt} {x : Id} {F : Frm}\n -> (mapsTo F x 0)\n -------------------------------\n -> (execsTo F (repeatBy x s) F)\n\n s-repeat-suc : forall {n : nat} {s : Stmt} {x : Id} {F F' : Frm}\n -> (mapsTo F x (suc n))\n -> (execsTo F (seq (seq s (assign x (val n))) (repeatBy x s)) F')\n -----------------------------------------------------------------\n -> (execsTo F (repeatBy x s) F')\n\n --\n -- A lil cheat: \"returns\" is just assign; doesn't exit\n\n s-return : forall {e : Expn} {F : Frm} {rv : Val}\n -> (evalsTo F e rv)\n -------------------------------------------------\n -> (execsTo F (returns e) (update \"retval\" rv F))\n\npostulate\n frm-compare : Frm -> Frm -> bool\n frm-iso : Frm -> Frm -> Set\n frm-not-iso : Frm -> Frm -> Set\n\npostulate\n s-thm : forall {s : Stmt}{F Ff Fr : Frm}\n -> execsTo F s Fr\n -> equiv (exec s F) Ff\n ----------------------\n -> frm-iso Ff Fr\n\n", "meta": {"hexsha": "2b1095b86b3765d8a2004a442beddfff01262c8b", "size": 14573, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "imper-nouni.agda", "max_stars_repo_name": "JimFixGroupResearch/imper-ial", "max_stars_repo_head_hexsha": "80d9411b2869614cae488cd4a6272894146c9f3c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "imper-nouni.agda", "max_issues_repo_name": "JimFixGroupResearch/imper-ial", "max_issues_repo_head_hexsha": "80d9411b2869614cae488cd4a6272894146c9f3c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "imper-nouni.agda", "max_forks_repo_name": "JimFixGroupResearch/imper-ial", "max_forks_repo_head_hexsha": "80d9411b2869614cae488cd4a6272894146c9f3c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.9146825397, "max_line_length": 108, "alphanum_fraction": 0.4914568037, "num_tokens": 5466, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430478583168, "lm_q2_score": 0.7310585727705126, "lm_q1q2_score": 0.6076142503354349}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Some algebraic structures (not packed up with sets, operations,\n-- etc.)\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary using (Rel; Setoid; IsEquivalence)\n\n-- The structures are parameterised by an equivalence relation\n\nmodule Algebra.Structures {a ℓ} {A : Set a} (_≈_ : Rel A ℓ) where\n\nopen import Algebra.FunctionProperties _≈_\nimport Algebra.FunctionProperties.Consequences as Consequences\nopen import Data.Product using (_,_; proj₁; proj₂)\nopen import Level using (_⊔_)\n\n------------------------------------------------------------------------\n-- Semigroups\n\nrecord IsMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) where\n field\n isEquivalence : IsEquivalence _≈_\n ∙-cong : Congruent₂ ∙\n\n open IsEquivalence isEquivalence public\n\n setoid : Setoid a ℓ\n setoid = record { isEquivalence = isEquivalence }\n\n ∙-congˡ : LeftCongruent ∙\n ∙-congˡ y≈z = ∙-cong refl y≈z\n\n ∙-congʳ : RightCongruent ∙\n ∙-congʳ y≈z = ∙-cong y≈z refl\n\nrecord IsSemigroup (∙ : Op₂ A) : Set (a ⊔ ℓ) where\n field\n isMagma : IsMagma ∙\n assoc : Associative ∙\n\n open IsMagma isMagma public\n\nrecord IsBand (∙ : Op₂ A) : Set (a ⊔ ℓ) where\n field\n isSemigroup : IsSemigroup ∙\n idem : Idempotent ∙\n\n open IsSemigroup isSemigroup public\n\nrecord IsSemilattice (∧ : Op₂ A) : Set (a ⊔ ℓ) where\n field\n isBand : IsBand ∧\n comm : Commutative ∧\n\n open IsBand isBand public\n renaming (∙-cong to ∧-cong; ∙-congˡ to ∧-congˡ; ∙-congʳ to ∧-congʳ)\n\n------------------------------------------------------------------------\n-- Monoids\n\nrecord IsMonoid (∙ : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where\n field\n isSemigroup : IsSemigroup ∙\n identity : Identity ε ∙\n\n open IsSemigroup isSemigroup public\n\n identityˡ : LeftIdentity ε ∙\n identityˡ = proj₁ identity\n\n identityʳ : RightIdentity ε ∙\n identityʳ = proj₂ identity\n\nrecord IsCommutativeMonoid (∙ : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where\n field\n isSemigroup : IsSemigroup ∙\n identityˡ : LeftIdentity ε ∙\n comm : Commutative ∙\n\n open IsSemigroup isSemigroup public\n\n identityʳ : RightIdentity ε ∙\n identityʳ = Consequences.comm+idˡ⇒idʳ setoid comm identityˡ\n\n identity : Identity ε ∙\n identity = (identityˡ , identityʳ)\n\n isMonoid : IsMonoid ∙ ε\n isMonoid = record\n { isSemigroup = isSemigroup\n ; identity = identity\n }\n\nrecord IsIdempotentCommutativeMonoid (∙ : Op₂ A)\n (ε : A) : Set (a ⊔ ℓ) where\n field\n isCommutativeMonoid : IsCommutativeMonoid ∙ ε\n idem : Idempotent ∙\n\n open IsCommutativeMonoid isCommutativeMonoid public\n\n------------------------------------------------------------------------\n-- Groups\n\nrecord IsGroup (_∙_ : Op₂ A) (ε : A) (_⁻¹ : Op₁ A) : Set (a ⊔ ℓ) where\n field\n isMonoid : IsMonoid _∙_ ε\n inverse : Inverse ε _⁻¹ _∙_\n ⁻¹-cong : Congruent₁ _⁻¹\n\n open IsMonoid isMonoid public\n\n infixl 7 _-_\n _-_ : Op₂ A\n x - y = x ∙ (y ⁻¹)\n\n inverseˡ : LeftInverse ε _⁻¹ _∙_\n inverseˡ = proj₁ inverse\n\n inverseʳ : RightInverse ε _⁻¹ _∙_\n inverseʳ = proj₂ inverse\n\n uniqueˡ-⁻¹ : ∀ x y → (x ∙ y) ≈ ε → x ≈ (y ⁻¹)\n uniqueˡ-⁻¹ = Consequences.assoc+id+invʳ⇒invˡ-unique\n setoid ∙-cong assoc identity inverseʳ\n\n uniqueʳ-⁻¹ : ∀ x y → (x ∙ y) ≈ ε → y ≈ (x ⁻¹)\n uniqueʳ-⁻¹ = Consequences.assoc+id+invˡ⇒invʳ-unique\n setoid ∙-cong assoc identity inverseˡ\n\nrecord IsAbelianGroup (∙ : Op₂ A)\n (ε : A) (⁻¹ : Op₁ A) : Set (a ⊔ ℓ) where\n field\n isGroup : IsGroup ∙ ε ⁻¹\n comm : Commutative ∙\n\n open IsGroup isGroup public\n\n isCommutativeMonoid : IsCommutativeMonoid ∙ ε\n isCommutativeMonoid = record\n { isSemigroup = isSemigroup\n ; identityˡ = identityˡ\n ; comm = comm\n }\n\n------------------------------------------------------------------------\n-- Semirings\n\nrecord IsNearSemiring (+ * : Op₂ A) (0# : A) : Set (a ⊔ ℓ) where\n field\n +-isMonoid : IsMonoid + 0#\n *-isSemigroup : IsSemigroup *\n distribʳ : * DistributesOverʳ +\n zeroˡ : LeftZero 0# *\n\n open IsMonoid +-isMonoid public\n renaming\n ( assoc to +-assoc\n ; ∙-cong to +-cong\n ; ∙-congˡ to +-congˡ\n ; ∙-congʳ to +-congʳ\n ; identity to +-identity\n ; identityˡ to +-identityˡ\n ; identityʳ to +-identityʳ\n ; isMagma to +-isMagma\n ; isSemigroup to +-isSemigroup\n )\n\n open IsSemigroup *-isSemigroup public\n using ()\n renaming\n ( assoc to *-assoc\n ; ∙-cong to *-cong\n ; ∙-congˡ to *-congˡ\n ; ∙-congʳ to *-congʳ\n ; isMagma to *-isMagma\n )\n\nrecord IsSemiringWithoutOne (+ * : Op₂ A) (0# : A) : Set (a ⊔ ℓ) where\n field\n +-isCommutativeMonoid : IsCommutativeMonoid + 0#\n *-isSemigroup : IsSemigroup *\n distrib : * DistributesOver +\n zero : Zero 0# *\n\n open IsCommutativeMonoid +-isCommutativeMonoid public\n using ()\n renaming\n ( isMonoid to +-isMonoid\n ; comm to +-comm\n )\n\n zeroˡ : LeftZero 0# *\n zeroˡ = proj₁ zero\n\n zeroʳ : RightZero 0# *\n zeroʳ = proj₂ zero\n\n isNearSemiring : IsNearSemiring + * 0#\n isNearSemiring = record\n { +-isMonoid = +-isMonoid\n ; *-isSemigroup = *-isSemigroup\n ; distribʳ = proj₂ distrib\n ; zeroˡ = zeroˡ\n }\n\n open IsNearSemiring isNearSemiring public\n hiding (+-isMonoid; zeroˡ)\n\nrecord IsSemiringWithoutAnnihilatingZero (+ * : Op₂ A)\n (0# 1# : A) : Set (a ⊔ ℓ) where\n field\n -- Note that these structures do have an additive unit, but this\n -- unit does not necessarily annihilate multiplication.\n +-isCommutativeMonoid : IsCommutativeMonoid + 0#\n *-isMonoid : IsMonoid * 1#\n distrib : * DistributesOver +\n\n distribˡ : * DistributesOverˡ +\n distribˡ = proj₁ distrib\n\n distribʳ : * DistributesOverʳ +\n distribʳ = proj₂ distrib\n\n open IsCommutativeMonoid +-isCommutativeMonoid public\n renaming\n ( assoc to +-assoc\n ; ∙-cong to +-cong\n ; ∙-congˡ to +-congˡ\n ; ∙-congʳ to +-congʳ\n ; identity to +-identity\n ; identityˡ to +-identityˡ\n ; identityʳ to +-identityʳ\n ; comm to +-comm\n ; isMagma to +-isMagma\n ; isSemigroup to +-isSemigroup\n ; isMonoid to +-isMonoid\n )\n\n open IsMonoid *-isMonoid public\n using ()\n renaming\n ( assoc to *-assoc\n ; ∙-cong to *-cong\n ; ∙-congˡ to *-congˡ\n ; ∙-congʳ to *-congʳ\n ; identity to *-identity\n ; identityˡ to *-identityˡ\n ; identityʳ to *-identityʳ\n ; isMagma to *-isMagma\n ; isSemigroup to *-isSemigroup\n )\n\nrecord IsSemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ) where\n field\n isSemiringWithoutAnnihilatingZero :\n IsSemiringWithoutAnnihilatingZero + * 0# 1#\n zero : Zero 0# *\n\n open IsSemiringWithoutAnnihilatingZero\n isSemiringWithoutAnnihilatingZero public\n\n isSemiringWithoutOne : IsSemiringWithoutOne + * 0#\n isSemiringWithoutOne = record\n { +-isCommutativeMonoid = +-isCommutativeMonoid\n ; *-isSemigroup = *-isSemigroup\n ; distrib = distrib\n ; zero = zero\n }\n\n open IsSemiringWithoutOne isSemiringWithoutOne public\n using\n ( isNearSemiring\n ; zeroˡ\n ; zeroʳ\n )\n\nrecord IsCommutativeSemiringWithoutOne\n (+ * : Op₂ A) (0# : A) : Set (a ⊔ ℓ) where\n field\n isSemiringWithoutOne : IsSemiringWithoutOne + * 0#\n *-comm : Commutative *\n\n open IsSemiringWithoutOne isSemiringWithoutOne public\n\nrecord IsCommutativeSemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ) where\n field\n +-isCommutativeMonoid : IsCommutativeMonoid + 0#\n *-isCommutativeMonoid : IsCommutativeMonoid * 1#\n distribʳ : * DistributesOverʳ +\n zeroˡ : LeftZero 0# *\n\n private\n module +-CM = IsCommutativeMonoid +-isCommutativeMonoid\n open module *-CM = IsCommutativeMonoid *-isCommutativeMonoid public\n using () renaming (comm to *-comm)\n\n distribˡ : * DistributesOverˡ +\n distribˡ = Consequences.comm+distrʳ⇒distrˡ\n +-CM.setoid +-CM.∙-cong *-comm distribʳ\n\n distrib : * DistributesOver +\n distrib = (distribˡ , distribʳ)\n\n zeroʳ : RightZero 0# *\n zeroʳ = Consequences.comm+zeˡ⇒zeʳ +-CM.setoid *-comm zeroˡ\n\n zero : Zero 0# *\n zero = (zeroˡ , zeroʳ)\n\n isSemiring : IsSemiring + * 0# 1#\n isSemiring = record\n { isSemiringWithoutAnnihilatingZero = record\n { +-isCommutativeMonoid = +-isCommutativeMonoid\n ; *-isMonoid = *-CM.isMonoid\n ; distrib = distrib\n }\n ; zero = zero\n }\n\n open IsSemiring isSemiring public\n hiding\n ( distrib; distribʳ; distribˡ\n ; zero; zeroˡ; zeroʳ\n ; +-isCommutativeMonoid\n )\n\n isCommutativeSemiringWithoutOne :\n IsCommutativeSemiringWithoutOne + * 0#\n isCommutativeSemiringWithoutOne = record\n { isSemiringWithoutOne = isSemiringWithoutOne\n ; *-comm = *-CM.comm\n }\n\n------------------------------------------------------------------------\n-- Rings\n\nrecord IsRing (+ * : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Set (a ⊔ ℓ) where\n field\n +-isAbelianGroup : IsAbelianGroup + 0# -_\n *-isMonoid : IsMonoid * 1#\n distrib : * DistributesOver +\n\n open IsAbelianGroup +-isAbelianGroup public\n renaming\n ( assoc to +-assoc\n ; ∙-cong to +-cong\n ; ∙-congˡ to +-congˡ\n ; ∙-congʳ to +-congʳ\n ; identity to +-identity\n ; identityˡ to +-identityˡ\n ; identityʳ to +-identityʳ\n ; inverse to -‿inverse\n ; inverseˡ to -‿inverseˡ\n ; inverseʳ to -‿inverseʳ\n ; ⁻¹-cong to -‿cong\n ; comm to +-comm\n ; isMagma to +-isMagma\n ; isSemigroup to +-isSemigroup\n ; isMonoid to +-isMonoid\n ; isCommutativeMonoid to +-isCommutativeMonoid\n ; isGroup to +-isGroup\n )\n\n open IsMonoid *-isMonoid public\n using ()\n renaming\n ( assoc to *-assoc\n ; ∙-cong to *-cong\n ; ∙-congˡ to *-congˡ\n ; ∙-congʳ to *-congʳ\n ; identity to *-identity\n ; identityˡ to *-identityˡ\n ; identityʳ to *-identityʳ\n ; isMagma to *-isMagma\n ; isSemigroup to *-isSemigroup\n )\n\n zeroˡ : LeftZero 0# *\n zeroˡ = Consequences.assoc+distribʳ+idʳ+invʳ⇒zeˡ setoid\n +-cong *-cong +-assoc (proj₂ distrib) +-identityʳ -‿inverseʳ\n\n zeroʳ : RightZero 0# *\n zeroʳ = Consequences.assoc+distribˡ+idʳ+invʳ⇒zeʳ setoid\n +-cong *-cong +-assoc (proj₁ distrib) +-identityʳ -‿inverseʳ\n\n zero : Zero 0# *\n zero = (zeroˡ , zeroʳ)\n\n isSemiringWithoutAnnihilatingZero\n : IsSemiringWithoutAnnihilatingZero + * 0# 1#\n isSemiringWithoutAnnihilatingZero = record\n { +-isCommutativeMonoid = +-isCommutativeMonoid\n ; *-isMonoid = *-isMonoid\n ; distrib = distrib\n }\n\n isSemiring : IsSemiring + * 0# 1#\n isSemiring = record\n { isSemiringWithoutAnnihilatingZero =\n isSemiringWithoutAnnihilatingZero\n ; zero = zero\n }\n\n open IsSemiring isSemiring public\n using (distribˡ; distribʳ; isNearSemiring; isSemiringWithoutOne)\n\nrecord IsCommutativeRing\n (+ * : Op₂ A) (- : Op₁ A) (0# 1# : A) : Set (a ⊔ ℓ) where\n field\n isRing : IsRing + * - 0# 1#\n *-comm : Commutative *\n\n open IsRing isRing public\n\n *-isCommutativeMonoid : IsCommutativeMonoid * 1#\n *-isCommutativeMonoid = record\n { isSemigroup = *-isSemigroup\n ; identityˡ = *-identityˡ\n ; comm = *-comm\n }\n\n isCommutativeSemiring : IsCommutativeSemiring + * 0# 1#\n isCommutativeSemiring = record\n { +-isCommutativeMonoid = +-isCommutativeMonoid\n ; *-isCommutativeMonoid = *-isCommutativeMonoid\n ; distribʳ = distribʳ\n ; zeroˡ = zeroˡ\n }\n\n open IsCommutativeSemiring isCommutativeSemiring public\n using ( isCommutativeSemiringWithoutOne )\n\n------------------------------------------------------------------------\n-- Lattices\n\n-- Note that this record is not defined in terms of IsSemilattice\n-- because the idempotence laws of ∨ and ∧ can be derived from the\n-- absorption laws, which makes the corresponding \"idem\" fields\n-- redundant. The derived idempotence laws are stated and proved in\n-- Algebra.Properties.Lattice along with the fact that every lattice\n-- consists of two semilattices.\n\nrecord IsLattice (∨ ∧ : Op₂ A) : Set (a ⊔ ℓ) where\n field\n isEquivalence : IsEquivalence _≈_\n ∨-comm : Commutative ∨\n ∨-assoc : Associative ∨\n ∨-cong : Congruent₂ ∨\n ∧-comm : Commutative ∧\n ∧-assoc : Associative ∧\n ∧-cong : Congruent₂ ∧\n absorptive : Absorptive ∨ ∧\n\n open IsEquivalence isEquivalence public\n\n ∨-absorbs-∧ : ∨ Absorbs ∧\n ∨-absorbs-∧ = proj₁ absorptive\n\n ∧-absorbs-∨ : ∧ Absorbs ∨\n ∧-absorbs-∨ = proj₂ absorptive\n\n ∧-congˡ : LeftCongruent ∧\n ∧-congˡ y≈z = ∧-cong refl y≈z\n\n ∧-congʳ : RightCongruent ∧\n ∧-congʳ y≈z = ∧-cong y≈z refl\n\n ∨-congˡ : LeftCongruent ∨\n ∨-congˡ y≈z = ∨-cong refl y≈z\n\n ∨-congʳ : RightCongruent ∨\n ∨-congʳ y≈z = ∨-cong y≈z refl\n\nrecord IsDistributiveLattice (∨ ∧ : Op₂ A) : Set (a ⊔ ℓ) where\n field\n isLattice : IsLattice ∨ ∧\n ∨-∧-distribʳ : ∨ DistributesOverʳ ∧\n\n open IsLattice isLattice public\n\nrecord IsBooleanAlgebra\n (∨ ∧ : Op₂ A) (¬ : Op₁ A) (⊤ ⊥ : A) : Set (a ⊔ ℓ) where\n field\n isDistributiveLattice : IsDistributiveLattice ∨ ∧\n ∨-complementʳ : RightInverse ⊤ ¬ ∨\n ∧-complementʳ : RightInverse ⊥ ¬ ∧\n ¬-cong : Congruent₁ ¬\n\n open IsDistributiveLattice isDistributiveLattice public\n", "meta": {"hexsha": "38c3919c242189b4a5dce1ca6bde8eabbfffb444", "size": 13970, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Structures.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Structures.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Structures.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.2222222222, "max_line_length": 74, "alphanum_fraction": 0.579599141, "num_tokens": 4802, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430394931456, "lm_q2_score": 0.7310585727705126, "lm_q1q2_score": 0.6076142442200048}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Category.Construction.LT-Models where\n\n-- Given a fixed Lawvere Theory LT and a fixed category C,\n-- the Functors [LT , C] form a category.\n\n-- The proof is basically the same as that of Functors.\n\nopen import Level\n\nopen import Categories.Category.Core using (Category)\nopen import Categories.Category.Cartesian.Bundle using (CartesianCategory)\nopen import Categories.Category.Monoidal.Instance.Setoids using (Setoids-CartesianCategory)\nopen import Categories.NaturalTransformation\n using (NaturalTransformation; _∘ᵥ_) renaming (id to idN)\nopen import Categories.NaturalTransformation.Equivalence using (_≃_; ≃-isEquivalence)\nopen import Categories.Theory.Lawvere using (LawvereTheory; ModelsOf_In_)\n\nprivate\n variable\n o ℓ e o′ ℓ′ e′ : Level\n\n-- The reason the proofs below are so easy is that _∘ᵥ_ 'computes' all the way down into\n-- expressions in C, from which the properties follow.\nLT-Models : LawvereTheory ℓ e → CartesianCategory o′ ℓ′ e′ → Category (ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) (ℓ ⊔ ℓ′ ⊔ e′) e′\nLT-Models LT C = record\n { Obj = ModelsOf LT In C\n ; _⇒_ = λ m₁ m₂ → NaturalTransformation (ModelsOf_In_.mod m₁) (ModelsOf_In_.mod m₂)\n ; _≈_ = _≃_\n ; id = idN\n ; _∘_ = _∘ᵥ_\n ; assoc = assoc\n ; sym-assoc = sym-assoc\n ; identityˡ = identityˡ\n ; identityʳ = identityʳ\n ; identity² = identity²\n ; equiv = ≃-isEquivalence\n ; ∘-resp-≈ = λ eq eq′ → ∘-resp-≈ eq eq′\n }\n where\n module C = CartesianCategory C using (U)\n open Category C.U\n\nLT-SetoidsModels : {ℓ′ e′ : Level} → LawvereTheory ℓ e → Category (ℓ ⊔ e ⊔ suc (ℓ′ ⊔ e′)) (ℓ ⊔ ℓ′ ⊔ e′) (ℓ′ ⊔ e′)\nLT-SetoidsModels {ℓ′ = ℓ′} {e′} LT = LT-Models LT (Setoids-CartesianCategory ℓ′ e′)\n", "meta": {"hexsha": "dfac09952cde29acbeeda4165ead2fa1142bab6d", "size": 1746, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Construction/LT-Models.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/Construction/LT-Models.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/Construction/LT-Models.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 37.9565217391, "max_line_length": 113, "alphanum_fraction": 0.6798396334, "num_tokens": 583, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744717487331, "lm_q2_score": 0.74316801430083, "lm_q1q2_score": 0.607595196712556}} {"text": "{-# OPTIONS --without-K --no-pattern-matching #-}\n\nmodule Ch2-6 where\n\nopen import Level hiding (lift)\n\nopen import Ch2-1\nopen import Ch2-2\nopen import Ch2-3\nopen import Ch2-4\nopen import Ch2-5\n\nopen import Data.Product\nopen import Function using (id; _∘_)\n\n-- Definition 2.6.1\nDefinition-2-6-1 : ∀ {a b} {A : Set a} {B : Set b} {x y : A × B}\n → (p : x ≡ y)\n → proj₁ x ≡ proj₁ y × proj₂ x ≡ proj₂ y\nDefinition-2-6-1 {_} {_} {A} {B} {x} {y} p = J (A × B) D d x y p\n where\n D : (x y : A × B) (p : x ≡ y) → Set _\n D x y p = proj₁ x ≡ proj₁ y × proj₂ x ≡ proj₂ y\n\n d : (x : A × B) → D x x refl\n d x = refl , refl\n\n-- Definition 2.6.3\nDefinition-2-6-3 : ∀ {i j} {A : Set i} {B : Set j} {x y : A × B}\n → proj₁ x ≡ proj₁ y × proj₂ x ≡ proj₂ y → x ≡ y\nDefinition-2-6-3 {_} {_} {A} {B} {x} {y} p\n = J A D d (proj₁ x) (proj₁ y) (proj₁ p) (proj₂ x) (proj₂ y) (proj₂ p)\n where\n D : (a b : A) (fst : a ≡ b) → Set _\n D a b fst = (a' b' : B) (snd : a' ≡ b') → (a , a') ≡ (b , b')\n\n d : (x : A) → D x x refl\n d x a' b' snd = J B E e a' b' snd x\n\n where\n E : (a' b' : B) (snd : a' ≡ b') → Set _\n E a' b' snd = (x : A) → (x , a') ≡ (x , b')\n\n e : (x : B) → E x x refl\n e x y = refl\n\npair≡ : ∀ {a b} {A : Set a} {B : Set b} {x y : A × B}\n → proj₁ x ≡ proj₁ y × proj₂ x ≡ proj₂ y → x ≡ y\npair≡ = Definition-2-6-3\n\n-- Theorem 2.6.2\nTheorem-2-6-2 : ∀ {a b} {A : Set a} {B : Set b} (x y : A × B)\n → (x ≡ y) ≅ (proj₁ x ≡ proj₁ y × proj₂ x ≡ proj₂ y)\nTheorem-2-6-2 {_} {_} {A} {B} a b = Definition-2-6-1 , it-isequiv\n --\n where\n it-isequiv : isequiv Definition-2-6-1\n it-isequiv = (Definition-2-6-3 , α) , (Definition-2-6-3 , β)\n\n where\n α : Definition-2-6-1 ∘ Definition-2-6-3 ~ id\n α p = J A D d (proj₁ a) (proj₁ b) (proj₁ p) (proj₂ a) (proj₂ b) (proj₂ p)\n where\n D : (x y : A) (p : x ≡ y) → Set _\n D x y p = (x' y' : B) (snd : x' ≡ y')\n → (Definition-2-6-1 ∘ Definition-2-6-3) (p , snd) ≡ ((p , snd))\n\n d : (x : A) → D x x refl\n d x x' y' q = J B E e x' y' q\n where\n E : (x' y' : B) (q : x' ≡ y') → Set _\n E x' y' q = (Definition-2-6-1 ∘ Definition-2-6-3) (refl , q) ≡ ((refl , q))\n\n e : (x' : B) → E x' x' refl\n e x' = refl\n\n β : Definition-2-6-3 ∘ Definition-2-6-1 ~ id\n β p = J (A × B) D d a b p\n where\n D : (x y : A × B) (p : x ≡ y) → Set _\n D x y p = (Definition-2-6-3 ∘ Definition-2-6-1) p ≡ id p\n\n d : (x : A × B) → D x x refl\n d x = refl\n\n-- Definition 2.6.4\n_X_ : {a b : Level} {Z : Set a}\n → (A B : Z → Set b)\n → Z → Set _\n_X_ {a} {b} {Z} A B z = A z × B z\n\n\n-- Theorem 2.6.4\nTheorem-2-6-4 : {a b : Level} {Z : Set a}\n → (A B : Z → Set b)\n → {z w : Z} (p : z ≡ w)\n → (x : (A X B) z)\n → transport (A X B) p x ≡ ((transport A p (proj₁ x)) , transport B p (proj₂ x))\nTheorem-2-6-4 {_} {_} {Z} A B {z} {w} p x = J _ D d z w p x\n where\n D : (z w : Z) (p : z ≡ w) → Set _\n D z w p = (x : (A X B) z)\n → transport (A X B) p x ≡\n (transport A p (proj₁ x) , transport B p (proj₂ x))\n\n d : (z : Z) → D z z refl\n d z x = refl\n\n-- Definition 2.6.5\nDefinition-2-6-5 : {a a' b b' : Level}\n → {A : Set a} {A' : Set a'} {B : Set b} {B' : Set b'}\n → (g : A → A') (h : B → B')\n → A × B\n → A' × B'\nDefinition-2-6-5 g h x = g (proj₁ x) , h (proj₂ x)\n\n\n-- Theorem 2.6.5\nTheorem-2-6-5 : {a a' b b' : Level}\n → {A : Set a} {A' : Set a'} {B : Set b} {B' : Set b'}\n → (g : A → A') (h : B → B')\n → {x y : A × B}\n → (p : proj₁ x ≡ proj₁ y)\n → (q : proj₂ x ≡ proj₂ y)\n → ap (Definition-2-6-5 g h) (Definition-2-6-3 (p , q)) ≡ Definition-2-6-3 (ap g p , ap h q)\nTheorem-2-6-5 {A = A} {A'} {B} {B'} g h {x} {y} p q = J _ D d (proj₁ x) (proj₁ y) p g h (proj₂ x) (proj₂ y) q\n where\n D : (x₁ y₁ : A) (p : x₁ ≡ y₁) → Set _\n D x₁ y₁ p = (g : A → A') (h : B → B') (x₂ y₂ : B) (q : x₂ ≡ y₂)\n → ap (Definition-2-6-5 g h) (Definition-2-6-3 (p , q)) ≡\n Definition-2-6-3 (ap g p , ap h q)\n\n\n d : (x : A) → D x x refl\n d x g h x₂ y₂ q = J _ E e x₂ y₂ q g h\n\n where\n E : (x₂ y₂ : B) (q : x₂ ≡ y₂) → Set _\n E x₂ y₂ q = (g : A → A') (h : B → B')\n → ap (Definition-2-6-5 g h) (Definition-2-6-3 (refl , q)) ≡\n Definition-2-6-3 (ap g refl , ap h q)\n\n e : (y : B) → E y y refl\n e y g h = refl\n", "meta": {"hexsha": "0a913c81f61b11a2c3a3942df6e01e5e016ac75d", "size": 4449, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Ch2-6.agda", "max_stars_repo_name": "banacorn/hott", "max_stars_repo_head_hexsha": "75eea99a879e100304bd48c538c9d2db0b4a4ff3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Ch2-6.agda", "max_issues_repo_name": "banacorn/hott", "max_issues_repo_head_hexsha": "75eea99a879e100304bd48c538c9d2db0b4a4ff3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Ch2-6.agda", "max_forks_repo_name": "banacorn/hott", "max_forks_repo_head_hexsha": "75eea99a879e100304bd48c538c9d2db0b4a4ff3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.6827586207, "max_line_length": 109, "alphanum_fraction": 0.438750281, "num_tokens": 2041, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744806385543, "lm_q2_score": 0.7431680029241322, "lm_q1q2_score": 0.607595194017889}} {"text": "{-# OPTIONS --cubical --allow-unsolved-metas #-}\n\nopen import Agda.Builtin.Cubical.Path\nopen import Agda.Primitive.Cubical\nopen import Agda.Builtin.Bool\n\npostulate\n Index : Set\n i : Index\n\ndata D : Index → Set where\n c : D i\n\ncong : {A B : Set} (x y : A) (f : A → B) → x ≡ y → f x ≡ f y\ncong _ _ f x≡y = λ i → f (x≡y i)\n\nrefl : {A : Set} {x : A} → x ≡ x\nrefl {x = x} = λ _ → x\n\nsubst :\n {A : Set} {x y : A}\n (P : A → Set) → x ≡ y → P x → P y\nsubst P eq p = primTransp (λ i → P (eq i)) i0 p\n\npostulate\n subst-refl :\n {A : Set} {x : A} (P : A → Set) {p : P x} →\n subst P refl p ≡ p\n\nf : {i : Index} (xs : D i) → D i\nf c = c\n\n\nworks : f (subst D refl c) ≡ c\nworks = cong (subst D refl c) c f (subst-refl D)\n\n-- There is no type error here, just a meta to solve.\n-- The original problem was assuming injectivity of f.\nshould-work-too : f (subst D refl c) ≡ c\nshould-work-too = cong _ _ f (subst-refl D)\n", "meta": {"hexsha": "26e52fb3cea8e9729f5e15ee7e23ed3f112aae58", "size": 916, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue5579.agda", "max_stars_repo_name": "cagix/agda", "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue5579.agda", "max_issues_repo_name": "cagix/agda", "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue5579.agda", "max_forks_repo_name": "cagix/agda", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 22.3414634146, "max_line_length": 60, "alphanum_fraction": 0.5655021834, "num_tokens": 364, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744584140003, "lm_q2_score": 0.7431680199891789, "lm_q1q2_score": 0.6075951914532579}} {"text": "{-# OPTIONS --warning=error --safe --without-K #-}\n\nopen import LogicalFormulae\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import Functions.Definition\nopen import Setoids.Setoids\nopen import Setoids.Subset\nopen import Graphs.Definition\n\nmodule Graphs.InducedSubgraph {a b c : _} {V' : Set a} {V : Setoid {a} {b} V'} (G : Graph c V) where\n\nopen Graph G\n\ninducedSubgraph : {d : _} {pred : V' → Set d} (sub : subset V pred) → Graph c (subsetSetoid V sub)\nGraph._<->_ (inducedSubgraph sub) (x , _) (y , _) = x <-> y\nGraph.noSelfRelation (inducedSubgraph sub) (x , _) x=x = noSelfRelation x x=x\nGraph.symmetric (inducedSubgraph sub) {x , _} {y , _} x=y = symmetric x=y\nGraph.wellDefined (inducedSubgraph sub) {x , _} {y , _} {z , _} {w , _} x=y z=w x-z = wellDefined x=y z=w x-z\n", "meta": {"hexsha": "179f2c0ea84e846a389b4edb3f63846252ec8533", "size": 795, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Graphs/InducedSubgraph.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Graphs/InducedSubgraph.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Graphs/InducedSubgraph.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 41.8421052632, "max_line_length": 109, "alphanum_fraction": 0.6742138365, "num_tokens": 272, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8991213826762113, "lm_q2_score": 0.6757646010190477, "lm_q1q2_score": 0.6075944024318845}} {"text": "{-# OPTIONS --universe-polymorphism #-}\nmodule Categories.Functor.Product where\n\nopen import Categories.Category\nopen import Categories.Functor using (Functor)\nimport Categories.Object.Product as Product\nimport Categories.Object.BinaryProducts as BinaryProducts\n\n-- Ugh, we should start bundling things (categories with binary products, in this case) up consistently\n_[_][_×-] : ∀ {o ℓ e} → (C : Category o ℓ e) → BinaryProducts.BinaryProducts C → Category.Obj C → Functor C C\nC [ P ][ O ×-] = record \n { F₀ = λ x → Product.A×B (product {O} {x})\n ; F₁ = λ f → ⟨ π₁ , f ∘ π₂ ⟩\n ; identity = λ {x} → identity′ {x}\n ; homomorphism = λ {x} {y} {z} {f} {g} → homomorphism′ {x} {y} {z} {f} {g}\n ; F-resp-≡ = λ f≡g → ⟨⟩-cong₂ refl (∘-resp-≡ˡ f≡g)\n }\n where\n open Category C\n open Equiv\n open Product C\n open BinaryProducts.BinaryProducts P\n\n .identity′ : {A : Obj} → ⟨ π₁ , id ∘ π₂ ⟩ ≡ id\n identity′ = \n begin\n ⟨ π₁ , id ∘ π₂ ⟩\n ≈⟨ ⟨⟩-cong₂ refl identityˡ ⟩\n ⟨ π₁ , π₂ ⟩\n ≈⟨ η ⟩\n id\n ∎\n where open HomReasoning\n\n .homomorphism′ : {X Y Z : Obj} {f : X ⇒ Y} {g : Y ⇒ Z} → ⟨ π₁ , (g ∘ f) ∘ π₂ ⟩ ≡ ⟨ π₁ , g ∘ π₂ ⟩ ∘ ⟨ π₁ , f ∘ π₂ ⟩ \n homomorphism′ {f = f} {g} =\n begin\n ⟨ π₁ , (g ∘ f) ∘ π₂ ⟩\n ↓⟨ ⟨⟩-cong₂ refl assoc ⟩\n ⟨ π₁ , g ∘ (f ∘ π₂) ⟩\n ↑⟨ ⟨⟩-cong₂ refl (∘-resp-≡ʳ commute₂) ⟩\n ⟨ π₁ , g ∘ (π₂ ∘ ⟨ π₁ , f ∘ π₂ ⟩) ⟩\n ↑⟨ ⟨⟩-cong₂ commute₁ assoc ⟩\n ⟨ π₁ ∘ ⟨ π₁ , f ∘ π₂ ⟩ , (g ∘ π₂) ∘ ⟨ π₁ , f ∘ π₂ ⟩ ⟩\n ↑⟨ ⟨⟩∘ ⟩\n ⟨ π₁ , g ∘ π₂ ⟩ ∘ ⟨ π₁ , f ∘ π₂ ⟩ \n ∎\n where open HomReasoning\n\n_[_][-×_] : ∀ {o ℓ e} → (C : Category o ℓ e) → BinaryProducts.BinaryProducts C → Category.Obj C → Functor C C\nC [ P ][-× O ] = record \n { F₀ = λ x → Product.A×B (product {x} {O})\n ; F₁ = λ f → ⟨ f ∘ π₁ , π₂ ⟩\n ; identity = λ {x} → identity′ {x}\n ; homomorphism = λ {x} {y} {z} {f} {g} → homomorphism′ {x} {y} {z} {f} {g}\n ; F-resp-≡ = λ f≡g → ⟨⟩-cong₂ (∘-resp-≡ˡ f≡g) refl\n }\n where\n open Category C\n open Equiv\n open Product C\n open BinaryProducts.BinaryProducts P\n\n .identity′ : {A : Obj} → ⟨ id ∘ π₁ , π₂ ⟩ ≡ id\n identity′ = \n begin\n ⟨ id ∘ π₁ , π₂ ⟩\n ≈⟨ ⟨⟩-cong₂ identityˡ refl ⟩\n ⟨ π₁ , π₂ ⟩\n ≈⟨ η ⟩\n id\n ∎\n where open HomReasoning\n\n .homomorphism′ : {X Y Z : Obj} {f : X ⇒ Y} {g : Y ⇒ Z} → ⟨ (g ∘ f) ∘ π₁ , π₂ ⟩ ≡ ⟨ g ∘ π₁ , π₂ ⟩ ∘ ⟨ f ∘ π₁ , π₂ ⟩ \n homomorphism′ {f = f} {g} =\n begin\n ⟨ (g ∘ f) ∘ π₁ , π₂ ⟩\n ↓⟨ ⟨⟩-cong₂ assoc refl ⟩\n ⟨ g ∘ (f ∘ π₁) , π₂ ⟩\n ↑⟨ ⟨⟩-cong₂ (∘-resp-≡ʳ commute₁) refl ⟩\n ⟨ g ∘ (π₁ ∘ ⟨ f ∘ π₁ , π₂ ⟩) , π₂ ⟩\n ↑⟨ ⟨⟩-cong₂ assoc commute₂ ⟩\n ⟨ (g ∘ π₁) ∘ ⟨ f ∘ π₁ , π₂ ⟩ , π₂ ∘ ⟨ f ∘ π₁ , π₂ ⟩ ⟩\n ↑⟨ ⟨⟩∘ ⟩\n ⟨ g ∘ π₁ , π₂ ⟩ ∘ ⟨ f ∘ π₁ , π₂ ⟩ \n ∎\n where open HomReasoning\n", "meta": {"hexsha": "303d8ae18477d9b9f49912bf83212655d9b3fc02", "size": 2752, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Functor/Product.agda", "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 98, "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_issues_repo_path": "Categories/Functor/Product.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_forks_repo_path": "Categories/Functor/Product.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 23, "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "avg_line_length": 30.9213483146, "max_line_length": 117, "alphanum_fraction": 0.4909156977, "num_tokens": 1293, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267796346598, "lm_q2_score": 0.6992544335934765, "lm_q1q2_score": 0.6075309776842783}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Data.Unit.Properties where\n\nopen import Cubical.Core.Everything\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\n\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Unit.Base\nopen import Cubical.Data.Prod.Base\n\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Equiv\n\nisContrUnit : isContr Unit\nisContrUnit = tt , λ {tt → refl}\n\nisPropUnit : isProp Unit\nisPropUnit _ _ i = tt -- definitionally equal to: isContr→isProp isContrUnit\n\nisSetUnit : isSet Unit\nisSetUnit = isProp→isSet isPropUnit\n\nisOfHLevelUnit : (n : HLevel) → isOfHLevel n Unit\nisOfHLevelUnit n = isContr→isOfHLevel n isContrUnit\n\ndiagonal-unit : Unit ≡ Unit × Unit\ndiagonal-unit = isoToPath (iso (λ x → tt , tt) (λ x → tt) (λ {(tt , tt) i → tt , tt}) λ {tt i → tt})\n\nfibId : ∀ {ℓ} (A : Type ℓ) → (fiber (λ (x : A) → tt) tt) ≡ A\nfibId A = isoToPath\n (iso fst\n (λ a → a , refl)\n (λ _ → refl)\n (λ a i → fst a\n , isOfHLevelSuc 1 isPropUnit _ _ (snd a) refl i))\n", "meta": {"hexsha": "8964cc811a205cff1c6af85dab0e221caecaa290", "size": 1132, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/Unit/Properties.agda", "max_stars_repo_name": "RobertHarper/cubical", "max_stars_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/Unit/Properties.agda", "max_issues_repo_name": "RobertHarper/cubical", "max_issues_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Data/Unit/Properties.agda", "max_forks_repo_name": "RobertHarper/cubical", "max_forks_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "avg_line_length": 29.7894736842, "max_line_length": 100, "alphanum_fraction": 0.6598939929, "num_tokens": 355, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267762381844, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.6075309589735297}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nopen import Cubical.Core.Everything\nopen import Cubical.Relation.Binary.Raw\n\nmodule Cubical.Relation.Binary.Reasoning.Base.Partial\n {a ℓ} {A : Type a} (_∼_ : RawRel A ℓ) (transitive : Transitive _∼_)\n where\n\nopen import Cubical.Foundations.Prelude\n\ninfix 4 _IsRelatedTo_\n\ninfix 2 _∎⟨_⟩\ninfixr 1 _∼⟨_⟩_ _≡⟨_⟩_ _≡˘⟨_⟩_\ninfixr 1 _≡⟨⟩_\ninfix 0 begin_\n\n------------------------------------------------------------------------\n-- Definition of \"related to\"\n\n-- This seemingly unnecessary type is used to make it possible to\n-- infer arguments even if the underlying equality evaluates.\n\ndata _IsRelatedTo_ (x y : A) : Type ℓ where\n relTo : (x∼y : x ∼ y) → x IsRelatedTo y\n\n------------------------------------------------------------------------\n-- Reasoning combinators\n\n-- Beginning of a proof\n\nbegin_ : ∀ {x y} → x IsRelatedTo y → x ∼ y\nbegin relTo x∼y = x∼y\n\n-- Standard step with the relation\n\n_∼⟨_⟩_ : ∀ x {y z} → x ∼ y → y IsRelatedTo z → x IsRelatedTo z\n_ ∼⟨ x∼y ⟩ relTo y∼z = relTo (transitive x∼y y∼z)\n\n-- Step with a non-trivial propositional equality\n\n_≡⟨_⟩_ : ∀ x {y z} → x ≡ y → y IsRelatedTo z → x IsRelatedTo z\n_≡⟨_⟩_ x {_} {z} x≡y y∼z = J (λ w _ → w IsRelatedTo z) y∼z (sym x≡y)\n\n-- Step with a flipped non-trivial propositional equality\n\n_≡˘⟨_⟩_ : ∀ x {y z} → y ≡ x → y IsRelatedTo z → x IsRelatedTo z\nx ≡˘⟨ y≡x ⟩ y∼z = x ≡⟨ sym y≡x ⟩ y∼z\n\n-- Step with a trivial propositional equality\n\n_≡⟨⟩_ : ∀ x {y} → x IsRelatedTo y → x IsRelatedTo y\n_ ≡⟨⟩ x∼y = x∼y\n\n-- Syntax for path definition\n\n≡⟨⟩-syntax : ∀ x {y z : A} → x ≡ y → y IsRelatedTo z → x IsRelatedTo z\n≡⟨⟩-syntax = _≡⟨_⟩_\ninfixr 1 ≡⟨⟩-syntax\nsyntax ≡⟨⟩-syntax x (λ i → B) y = x ≡[ i ]⟨ B ⟩ y\n\n≡˘⟨⟩-syntax : ∀ x {y z : A} → y ≡ x → y IsRelatedTo z → x IsRelatedTo z\n≡˘⟨⟩-syntax = _≡˘⟨_⟩_\ninfixr 1 ≡˘⟨⟩-syntax\nsyntax ≡˘⟨⟩-syntax x (λ i → B) y = x ≡˘[ i ]⟨ B ⟩ y\n\n-- Termination step\n\n_∎⟨_⟩ : ∀ x → x ∼ x → x IsRelatedTo x\n_ ∎⟨ x∼x ⟩ = relTo x∼x\n", "meta": {"hexsha": "1346890d19c2a86dd9930481857de606f990501f", "size": 1969, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Relation/Binary/Reasoning/Base/Partial.agda", "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Relation/Binary/Reasoning/Base/Partial.agda", "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Relation/Binary/Reasoning/Base/Partial.agda", "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.3472222222, "max_line_length": 72, "alphanum_fraction": 0.5728796343, "num_tokens": 828, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581097540519, "lm_q2_score": 0.763483758172699, "lm_q1q2_score": 0.6074720438556094}} {"text": "module SystemF where\n\nopen import Data.Nat using (ℕ; zero; suc; _+_)\n\nopen import Data.Fin as Fin using (Fin; zero; suc)\n\nopen import Function as Fun using (_∘_)\n\nopen import Relation.Binary.PropositionalEquality as Eq\n using (_≡_; refl; cong; cong₂; cong-app; sym)\nopen Eq.≡-Reasoning\n\n-- ------------------------------------------------------------------------\n\ninfixr 7 _⇒_\ninfix 9 `_\n\ndata Type (n : ℕ) : Set where\n `_ : Fin n → Type n\n _⇒_ : Type n → Type n → Type n\n `∀ : Type (1 + n) → Type n\n\n\n⇒-cong : ∀ { n } { τ₁¹ τ₁² τ₂¹ τ₂² : Type n } \n → τ₁¹ ≡ τ₂¹\n → τ₁² ≡ τ₂²\n -- ----------------------\n → τ₁¹ ⇒ τ₁² ≡ τ₂¹ ⇒ τ₂²\n⇒-cong ≡τ¹ ≡τ² = cong₂ _⇒_ ≡τ¹ ≡τ²\n\n`∀-cong : ∀ { n } { τ₁ τ₂ : Type (1 + n) } \n → τ₁ ≡ τ₂\n -- -------------\n → `∀ τ₁ ≡ `∀ τ₂\n`∀-cong ≡τ = cong `∀ ≡τ\n\n-- ------------------------------------------------------------------------\n\nopen import Sigma.Subst.Core\nopen import Sigma.Renaming.Base\n\nren-τ : ∀ { m n } → Ren m n → Type m → Type n\nren-τ ρ (` α) = ` ρ α\nren-τ ρ (τ₁ ⇒ τ₂) = ren-τ ρ τ₁ ⇒ ren-τ ρ τ₂\nren-τ ρ (`∀ τ) = `∀ (ren-τ (ρ ⇑) τ)\n\n\n_⇑τ : ∀ { m n } → Sub (Type n) m → Sub (Type (1 + n)) (1 + m)\nσ ⇑τ = ` zero ∷ (ren-τ ↑ ∘ σ)\n\nsub-τ : ∀ { m n } → Sub (Type n) m → Type m → Type n\nsub-τ σ (` α) = σ α\nsub-τ σ (τ₁ ⇒ τ₂) = sub-τ σ τ₁ ⇒ sub-τ σ τ₂\nsub-τ σ (`∀ τ) = `∀ (sub-τ (σ ⇑τ) τ)\n\n-- ------------------------------------------------------------------------\n\nopen import Sigma.Subst.Properties using (extensionality)\nopen import Sigma.Renaming.Properties using (∘-⇑-distrib; ⇑-id)\n\n-- ------------------------------------------------------------------------\n-- Congruences\n-- ------------------------------------------------------------------------\n\nren-τ-cong : ∀ { m n } { ρ₁ ρ₂ : Ren m n }\n → ρ₁ ≡ ρ₂\n -- -------\n → ren-τ ρ₁ ≡ ren-τ ρ₂ \nren-τ-cong ρ₁≡ρ₂ = cong ren-τ ρ₁≡ρ₂\n\n⇑τ-cong : ∀ { m n } { σ₁ σ₂ : Sub (Type n) m } \n → σ₁ ≡ σ₂\n -- ------------\n → σ₁ ⇑τ ≡ σ₂ ⇑τ\n⇑τ-cong σ₁≡σ₂ = cong _⇑τ σ₁≡σ₂\n\n-- ⇑τ✶-cong \n\nsub-τ-cong : ∀ { m n } { σ₁ σ₂ : Sub (Type n) m }\n → σ₁ ≡ σ₂\n -- --------\n → sub-τ σ₁ ≡ sub-τ σ₂\nsub-τ-cong σ₁≡σ₂ = cong sub-τ σ₁≡σ₂\n\n\n-- ------------------------------------------------------------------------\n-- Coincidence Laws\n-- ------------------------------------------------------------------------\n-- Every renaming can form a subsitution \n\n⇑τ-coincidence : ∀ { m n } (ρ : Ren m n)\n → `_ ∘ (ρ ⇑) ≡ (`_ ∘ ρ) ⇑τ\n⇑τ-coincidence ρ = extensionality lemma\n where \n lemma : ∀ x → ` ((ρ ⇑) x) ≡ ((`_ ∘ ρ) ⇑τ) x\n lemma zero = refl\n lemma (suc x) = refl\n\nren-τ-coincidence : ∀ { m n } (ρ : Ren m n)\n → ren-τ ρ ≡ sub-τ (`_ ∘ ρ)\nren-τ-coincidence ρ = extensionality (lemma ρ)\n where \n lemma : ∀ { m n } (ρ : Ren m n)\n → ∀ τ → ren-τ ρ τ ≡ sub-τ (`_ ∘ ρ) τ\n lemma ρ (` α) = refl\n lemma ρ (τ₁ ⇒ τ₂) = ⇒-cong (lemma ρ τ₁) (lemma ρ τ₂)\n lemma ρ (`∀ τ) = `∀-cong (\n begin \n ren-τ (ρ ⇑) τ \n ≡⟨ lemma (ρ ⇑) τ ⟩ \n sub-τ (`_ ∘ (ρ ⇑)) τ \n ≡⟨ cong-app (sub-τ-cong (⇑τ-coincidence ρ)) τ ⟩ \n sub-τ ((`_ ∘ ρ) ⇑τ) τ \n ∎)\n\n-- ------------------------------------------------------------------------\n-- Identity laws\n-- ------------------------------------------------------------------------\n\n⇑τ-id : ∀ { n : ℕ } → ((`_ { n }) ⇑τ) ≡ `_ { n = 1 + n }\n⇑τ-id = extensionality (lemma)\n where\n lemma : ∀ { n : ℕ } x → ((`_ { n }) ⇑τ) x ≡ ` x\n lemma zero = refl\n lemma (suc x) = refl\n\n\nren-τ-idᵣ : ∀ { n } → ren-τ (id { n }) ≡ Fun.id\nren-τ-idᵣ = extensionality lemma\n where\n lemma : ∀ { n } τ → ren-τ (id { n }) τ ≡ τ\n lemma (` α) = refl\n lemma (τ₁ ⇒ τ₂) = ⇒-cong (lemma τ₁) (lemma τ₂)\n lemma (`∀ τ) = `∀-cong (\n begin \n ren-τ (id ⇑) τ \n ≡⟨ cong-app (ren-τ-cong ⇑-id) τ ⟩ \n ren-τ id τ \n ≡⟨ lemma τ ⟩ \n τ \n ∎)\n\n\nsub-τ-idₗ : ∀ { m n } (σ : Sub (Type n) m) \n → sub-τ σ ∘ `_ ≡ σ\nsub-τ-idₗ σ = extensionality lemma\n where \n lemma : ∀ x → sub-τ σ (` x) ≡ σ x\n lemma zero = refl\n lemma (suc x) = refl\n\n\n-- The functional form of the Monad Law: Right Identity\nsub-τ-idᵣ : ∀ { n } → sub-τ (`_ {n}) ≡ Fun.id\nsub-τ-idᵣ = extensionality lemma\n where\n lemma : ∀ { n } τ → sub-τ (`_ {n}) τ ≡ τ\n lemma (` α) = refl\n lemma (τ₁ ⇒ τ₂) = ⇒-cong (lemma τ₁) (lemma τ₂)\n lemma (`∀ τ) = `∀-cong (\n begin \n sub-τ ((`_) ⇑τ) τ \n ≡⟨ cong-app (sub-τ-cong ⇑τ-id) τ ⟩ \n sub-τ (`_) τ\n ≡⟨ lemma τ ⟩ \n τ \n ∎)\n\n\n-- ------------------------------------------------------------------------\n-- Monad Law : Compositionality\n-- ------------------------------------------------------------------------\n-- Lemmas required to prove the law:\n-- sub-τ σ₂ ∘ sub-τ σ₁ ≡ sub-τ (sub-τ σ₂ ∘ σ₁)\n\n∘-ren-τ-distrib : ∀ { m n k } ( ρ₁ : Ren m n ) ( ρ₂ : Ren n k )\n → ren-τ ρ₂ ∘ ren-τ ρ₁ ≡ ren-τ (ρ₂ ∘ ρ₁)\n∘-ren-τ-distrib ρ₁ ρ₂ = extensionality (lemma ρ₁ ρ₂)\n where \n lemma : ∀ { m n k } ( ρ₁ : Ren m n ) ( ρ₂ : Ren n k )\n → ∀ τ → ren-τ ρ₂ (ren-τ ρ₁ τ) ≡ ren-τ (ρ₂ ∘ ρ₁) τ\n lemma ρ₁ ρ₂ (` α) = refl\n lemma ρ₁ ρ₂ (τ₁ ⇒ τ₂) = ⇒-cong (lemma ρ₁ ρ₂ τ₁) (lemma ρ₁ ρ₂ τ₂)\n lemma ρ₁ ρ₂ (`∀ τ) = `∀-cong (\n begin \n ren-τ (ρ₂ ⇑) (ren-τ (ρ₁ ⇑) τ) \n ≡⟨ lemma (ρ₁ ⇑) (ρ₂ ⇑) τ ⟩ \n ren-τ (ρ₂ ⇑ ∘ ρ₁ ⇑) τ \n ≡⟨ cong-app (ren-τ-cong (∘-⇑-distrib ρ₁ ρ₂)) τ ⟩ \n ren-τ ((ρ₂ ∘ ρ₁) ⇑) τ \n ∎)\n\n∘-⇑-ren-τ-distrib : ∀ { m n k } (σ : Sub (Type n) m) (ρ : Ren n k) \n → ren-τ (ρ ⇑) ∘ (σ ⇑τ) ≡ (ren-τ ρ ∘ σ) ⇑τ\n∘-⇑-ren-τ-distrib σ ρ = extensionality lemma\n where \n lemma : ∀ x → ren-τ (ρ ⇑) ((σ ⇑τ) x) ≡ ((ren-τ ρ ∘ σ) ⇑τ) x\n lemma zero = refl\n lemma (suc x) = \n begin\n ren-τ (ρ ⇑) ((σ ⇑τ) (suc x))\n ≡⟨⟩\n ren-τ (ρ ⇑) (ren-τ ↑ (σ x))\n ≡⟨ cong-app (∘-ren-τ-distrib ↑ (ρ ⇑)) (σ x) ⟩\n ren-τ (ρ ⇑ ∘ ↑) (σ x)\n ≡⟨ cong-app (sym (∘-ren-τ-distrib ρ ↑)) (σ x) ⟩\n ren-τ ↑ (ren-τ ρ (σ x))\n ≡⟨⟩\n ((ren-τ ρ ∘ σ) ⇑τ) (suc x)\n ∎\n\n-- ∘-⇑✶-ren-τ-distrib\n\n∘-⇑-τ-distrib : ∀ { m n k } (σ : Sub (Type k) n) (ρ : Ren m n)\n → (σ ⇑τ) ∘ (ρ ⇑) ≡ (σ ∘ ρ) ⇑τ\n∘-⇑-τ-distrib σ ρ = extensionality lemma\n where\n lemma : ∀ x → (σ ⇑τ) ((ρ ⇑) x) ≡ ((σ ∘ ρ) ⇑τ) x\n lemma zero = refl\n lemma (suc x) = refl\n\n∘-sub-ren-τ-distrib : ∀ { m n k } (σ : Sub (Type k) n) (ρ : Ren m n)\n → sub-τ σ ∘ ren-τ ρ ≡ sub-τ (σ ∘ ρ)\n∘-sub-ren-τ-distrib σ ρ = extensionality (lemma σ ρ)\n where \n lemma : ∀ { m n k } (σ : Sub (Type k) n) (ρ : Ren m n)\n → ∀ τ → sub-τ σ (ren-τ ρ τ) ≡ sub-τ (σ ∘ ρ) τ\n lemma σ ρ (` α) = refl\n lemma σ ρ (τ₁ ⇒ τ₂) = ⇒-cong (lemma σ ρ τ₁) (lemma σ ρ τ₂)\n lemma σ ρ (`∀ τ) = `∀-cong (\n begin\n sub-τ (σ ⇑τ) (ren-τ (ρ ⇑) τ)\n ≡⟨ lemma (σ ⇑τ) (ρ ⇑) τ ⟩ \n sub-τ ((σ ⇑τ) ∘ (ρ ⇑)) τ\n ≡⟨ cong-app (sub-τ-cong (∘-⇑-τ-distrib σ ρ)) τ ⟩ \n sub-τ ((σ ∘ ρ) ⇑τ) τ\n ∎)\n\n∘-ren-sub-τ-distrib : ∀ { m n k } (σ : Sub (Type n) m) (ρ : Ren n k)\n → ren-τ ρ ∘ sub-τ σ ≡ sub-τ (ren-τ ρ ∘ σ) \n∘-ren-sub-τ-distrib σ ρ = extensionality (lemma σ ρ)\n where \n lemma : ∀ { m n k } (σ : Sub (Type n) m) (ρ : Ren n k) \n → ∀ τ → ren-τ ρ (sub-τ σ τ) ≡ sub-τ (ren-τ ρ ∘ σ) τ \n lemma σ ρ (` α) = refl\n lemma σ ρ (τ₁ ⇒ τ₂) = ⇒-cong (lemma σ ρ τ₁) (lemma σ ρ τ₂)\n lemma σ ρ (`∀ τ) = `∀-cong (\n begin \n ren-τ (ρ ⇑) (sub-τ (σ ⇑τ) τ)\n ≡⟨ lemma (σ ⇑τ) (ρ ⇑) τ ⟩ \n sub-τ (ren-τ (ρ ⇑) ∘ (σ ⇑τ)) τ\n ≡⟨ cong-app (sub-τ-cong (∘-⇑-ren-τ-distrib σ ρ)) τ ⟩ \n sub-τ ((ren-τ ρ ∘ σ) ⇑τ) τ\n ∎)\n\n\n∘-⇑-sub-τ-distrib : ∀ { m n k } (σ₁ : Sub (Type n) m) (σ₂ : Sub (Type k) n)\n → sub-τ (σ₂ ⇑τ) ∘ σ₁ ⇑τ ≡ (sub-τ σ₂ ∘ σ₁) ⇑τ\n∘-⇑-sub-τ-distrib σ₁ σ₂ = extensionality lemma\n where \n lemma : ∀ x → sub-τ (σ₂ ⇑τ) ((σ₁ ⇑τ) x) ≡ ((sub-τ σ₂ ∘ σ₁) ⇑τ) x\n lemma zero = refl\n lemma (suc x) = \n begin\n sub-τ (σ₂ ⇑τ) ((σ₁ ⇑τ) (suc x))\n ≡⟨⟩\n sub-τ (σ₂ ⇑τ) (ren-τ ↑ (σ₁ x))\n ≡⟨ cong-app (∘-sub-ren-τ-distrib (σ₂ ⇑τ) ↑) (σ₁ x) ⟩\n sub-τ ((σ₂ ⇑τ) ∘ ↑) (σ₁ x)\n ≡⟨⟩\n sub-τ (ren-τ ↑ ∘ σ₂) (σ₁ x)\n ≡⟨ cong-app (sym (∘-ren-sub-τ-distrib σ₂ ↑)) (σ₁ x) ⟩\n ren-τ ↑ (sub-τ σ₂ (σ₁ x))\n ≡⟨⟩ \n ((sub-τ σ₂ ∘ σ₁) ⇑τ) (suc x)\n ∎\n\n∘-sub-τ-distrib : ∀ { m n k } ( σ₁ : Sub (Type n) m ) ( σ₂ : Sub (Type k) n )\n → sub-τ σ₂ ∘ sub-τ σ₁ ≡ sub-τ (sub-τ σ₂ ∘ σ₁)\n∘-sub-τ-distrib σ₁ σ₂ = extensionality (lemma σ₁ σ₂)\n where \n lemma : ∀ { m n k } ( σ₁ : Sub (Type n) m ) ( σ₂ : Sub (Type k) n )\n → ∀ τ → sub-τ σ₂ (sub-τ σ₁ τ) ≡ sub-τ (sub-τ σ₂ ∘ σ₁) τ\n lemma σ₁ σ₂ (` α) = refl\n lemma σ₁ σ₂ (τ₁ ⇒ τ₂) = ⇒-cong (lemma σ₁ σ₂ τ₁) (lemma σ₁ σ₂ τ₂)\n lemma σ₁ σ₂ (`∀ τ) = `∀-cong (\n begin \n sub-τ (σ₂ ⇑τ) (sub-τ (σ₁ ⇑τ) τ) \n ≡⟨ lemma (σ₁ ⇑τ) (σ₂ ⇑τ) τ ⟩ \n sub-τ (sub-τ (σ₂ ⇑τ) ∘ (σ₁ ⇑τ)) τ \n ≡⟨ cong-app (sub-τ-cong (∘-⇑-sub-τ-distrib σ₁ σ₂)) τ ⟩ \n sub-τ ((sub-τ σ₂ ∘ σ₁) ⇑τ) τ\n ∎)\n\n-- ------------------------------------------------------------------------\n-- Supplementary Laws\n-- ------------------------------------------------------------------------\n\n∘-sub-τ : ∀ { m n k l } ( σ₁ : Sub (Type n) m ) ( σ₂ : Sub (Type k) n ) (σ₃ : Sub (Type l) k)\n → sub-τ σ₃ ∘ (sub-τ σ₂ ∘ σ₁) ≡ sub-τ (sub-τ σ₃ ∘ σ₂) ∘ σ₁\n∘-sub-τ σ₁ σ₂ σ₃ = \n begin \n sub-τ σ₃ ∘ (sub-τ σ₂ ∘ σ₁) \n ≡⟨⟩ \n (sub-τ σ₃ ∘ sub-τ σ₂) ∘ σ₁ \n ≡⟨ cong (_∘ σ₁) (∘-sub-τ-distrib σ₂ σ₃) ⟩ \n sub-τ (sub-τ σ₃ ∘ σ₂) ∘ σ₁ \n ∎\n\n\n-- ------------------------------------------------------------------------\n\n\n-- infixl 7 _·_ _[_]\n-- infix 9 #_\n\n-- data Term (n : ℕ) (m : ℕ) : Set where\n-- #_ : Fin n → Term n m\n-- ƛ : Term (1 + n) m → Term n m\n-- _·_ : Term n m → Term n m → Term n m\n-- _[_] : Term n m → Type m → Term n m\n-- Λ : Term n (1 + m) → Term n m \n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "1faa62943054e75ed9f3d6a3c9bcf6aaabe45527", "size": 9681, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/SystemF.agda", "max_stars_repo_name": "johnyob/agda-sigma", "max_stars_repo_head_hexsha": "bb895fa8a3ccbefbd2c4a135c79744ba06895be7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "examples/SystemF.agda", "max_issues_repo_name": "johnyob/agda-sigma", "max_issues_repo_head_hexsha": "bb895fa8a3ccbefbd2c4a135c79744ba06895be7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/SystemF.agda", "max_forks_repo_name": "johnyob/agda-sigma", "max_forks_repo_head_hexsha": "bb895fa8a3ccbefbd2c4a135c79744ba06895be7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.247734139, "max_line_length": 93, "alphanum_fraction": 0.4032641256, "num_tokens": 4393, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.7634837635542924, "lm_q1q2_score": 0.6074720407386747}} {"text": "\nopen import Oscar.Prelude\nopen import Oscar.Class.IsCategory\nopen import Oscar.Class.Reflexivity\nopen import Oscar.Class.Transitivity\n\nmodule Oscar.Class.Category where\n\nrecord Category 𝔬 𝔯 ℓ : Ø ↑̂ (𝔬 ∙̂ 𝔯 ∙̂ ℓ) where\n constructor ∁\n infix 4 _∼̇_\n field\n {𝔒} : Ø 𝔬\n _∼_ : 𝔒 → 𝔒 → Ø 𝔯\n _∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ\n category-ε : Reflexivity.type _∼_\n _↦_ : Transitivity.type _∼_\n ⦃ `IsCategory ⦄ : IsCategory _∼_ _∼̇_ category-ε _↦_\n", "meta": {"hexsha": "a06e703a482369f8742009f95337fe517209cb14", "size": 463, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Category.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Category.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Category.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.3684210526, "max_line_length": 56, "alphanum_fraction": 0.6349892009, "num_tokens": 202, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9273632876167044, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.6073253289673582}} {"text": "module sk where\n\nopen import nat\n\ndata comb : Set where\n S : comb\n K : comb\n app : comb → comb → comb\n\ndata _↝_ : comb → comb → Set where\n ↝K : (a b : comb) → (app (app K a) b) ↝ a\n ↝S : (a b c : comb) → (app (app (app S a) b) c) ↝ (app (app a c) (app b c))\n ↝Cong1 : {a a' : comb} (b : comb) → a ↝ a' → (app a b) ↝ (app a' b)\n ↝Cong2 : (a : comb) {b b' : comb} → b ↝ b' → (app a b) ↝ (app a b')\n\nsize : comb → ℕ\nsize S = 1\nsize K = 1\nsize (app a b) = suc (size a + size b)\n", "meta": {"hexsha": "28693917dd216a4b5f09fb2eb004ea486b20f309", "size": 481, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "sk.agda", "max_stars_repo_name": "logicshan/IAL", "max_stars_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "sk.agda", "max_issues_repo_name": "logicshan/IAL", "max_issues_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sk.agda", "max_forks_repo_name": "logicshan/IAL", "max_forks_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.05, "max_line_length": 77, "alphanum_fraction": 0.4968814969, "num_tokens": 219, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9173026641072387, "lm_q2_score": 0.6619228758499941, "lm_q1q2_score": 0.6071836174507246}} {"text": "module Thesis.SIRelBigStep.Types where\n\nopen import Data.Empty\nopen import Data.Product\nopen import Relation.Nullary\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Binary hiding (_⇒_)\n\ndata Type : Set where\n _⇒_ : (σ τ : Type) → Type\n pair : (σ τ : Type) → Type\n nat : Type\ninfixr 20 _⇒_\n\nopen import Base.Syntax.Context Type public\nopen import Base.Syntax.Vars Type public\n\n-- Decidable equivalence for types and contexts. Needed later for ⊕ on closures.\n\n⇒-inj : ∀ {τ1 τ2 τ3 τ4 : Type} → _≡_ {A = Type} (τ1 ⇒ τ2) (τ3 ⇒ τ4) → τ1 ≡ τ3 × τ2 ≡ τ4\n⇒-inj refl = refl , refl\n\npair-inj : ∀ {τ1 τ2 τ3 τ4 : Type} → _≡_ {A = Type} (pair τ1 τ2) (pair τ3 τ4) → τ1 ≡ τ3 × τ2 ≡ τ4\npair-inj refl = refl , refl\n\n_≟Type_ : (τ1 τ2 : Type) → Dec (τ1 ≡ τ2)\n(τ1 ⇒ τ2) ≟Type (τ3 ⇒ τ4) with τ1 ≟Type τ3 | τ2 ≟Type τ4\n(τ1 ⇒ τ2) ≟Type (.τ1 ⇒ .τ2) | yes refl | yes refl = yes refl\n(τ1 ⇒ τ2) ≟Type (.τ1 ⇒ τ4) | yes refl | no ¬q = no (λ x → ¬q (proj₂ (⇒-inj x)))\n(τ1 ⇒ τ2) ≟Type (τ3 ⇒ τ4) | no ¬p | q = no (λ x → ¬p (proj₁ (⇒-inj x)))\n(τ1 ⇒ τ2) ≟Type pair τ3 τ4 = no (λ ())\n(τ1 ⇒ τ2) ≟Type nat = no (λ ())\npair τ1 τ2 ≟Type (τ3 ⇒ τ4) = no (λ ())\npair τ1 τ2 ≟Type pair τ3 τ4 with τ1 ≟Type τ3 | τ2 ≟Type τ4\npair τ1 τ2 ≟Type pair .τ1 .τ2 | yes refl | yes refl = yes refl\npair τ1 τ2 ≟Type pair τ3 τ4 | yes p | no ¬q = no (λ x → ¬q (proj₂ (pair-inj x)))\npair τ1 τ2 ≟Type pair τ3 τ4 | no ¬p | q = no (λ x → ¬p (proj₁ (pair-inj x)))\npair τ1 τ2 ≟Type nat = no (λ ())\nnat ≟Type pair τ1 τ2 = no (λ ())\nnat ≟Type (τ1 ⇒ τ2) = no (λ ())\nnat ≟Type nat = yes refl\n\n•-inj : ∀ {τ1 τ2 : Type} {Γ1 Γ2 : Context} → _≡_ {A = Context} (τ1 • Γ1) (τ2 • Γ2) → τ1 ≡ τ2 × Γ1 ≡ Γ2\n•-inj refl = refl , refl\n\n_≟Ctx_ : (Γ1 Γ2 : Context) → Dec (Γ1 ≡ Γ2)\n∅ ≟Ctx ∅ = yes refl\n∅ ≟Ctx (τ2 • Γ2) = no (λ ())\n(τ1 • Γ1) ≟Ctx ∅ = no (λ ())\n(τ1 • Γ1) ≟Ctx (τ2 • Γ2) with τ1 ≟Type τ2 | Γ1 ≟Ctx Γ2\n(τ1 • Γ1) ≟Ctx (.τ1 • .Γ1) | yes refl | yes refl = yes refl\n(τ1 • Γ1) ≟Ctx (.τ1 • Γ2) | yes refl | no ¬q = no (λ x → ¬q (proj₂ (•-inj x)))\n(τ1 • Γ1) ≟Ctx (τ2 • Γ2) | no ¬p | q = no (λ x → ¬p (proj₁ (•-inj x)))\n\n≟Ctx-refl : ∀ Γ → Γ ≟Ctx Γ ≡ yes refl\n≟Ctx-refl Γ with Γ ≟Ctx Γ\n≟Ctx-refl Γ | yes refl = refl\n≟Ctx-refl Γ | no ¬p = ⊥-elim (¬p refl)\n", "meta": {"hexsha": "cd464dcb127572be89b31bae44b356451ac42be5", "size": 2198, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Thesis/SIRelBigStep/Types.agda", "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_issues_repo_path": "Thesis/SIRelBigStep/Types.agda", "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_forks_repo_path": "Thesis/SIRelBigStep/Types.agda", "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "avg_line_length": 37.2542372881, "max_line_length": 102, "alphanum_fraction": 0.567788899, "num_tokens": 1028, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199795472731, "lm_q2_score": 0.7248702761768249, "lm_q1q2_score": 0.6071658259056583}} {"text": "open import Data.Nat using (suc)\n\nopen import Substitution using (rename-subst-commute; subst-commute)\nopen import DeBruijn\n\n\ninfix 3 _—→_\n\ndata _—→_ : ∀ {n} → Term n → Term n → Set where\n\n —→-ξₗ : ∀ {n} {M M′ N : Term n}\n → M —→ M′\n ---------------\n → M · N —→ M′ · N\n\n —→-ξᵣ : ∀ {n} {M N N′ : Term n}\n → N —→ N′\n ---------------\n → M · N —→ M · N′\n\n —→-ƛ : ∀ {n} {M M′ : Term (suc n)}\n → M —→ M′\n -----------\n → ƛ M —→ ƛ M′\n\n —→-β : ∀ {n} {M : Term (suc n)} {N : Term n}\n --------------------\n → (ƛ M) · N —→ M [ N ]\n\n\ninfix 3 _—↠_\ninfixr 3 _—→⟨_⟩_\ninfix 4 _∎\n\ndata _—↠_ : ∀ {n} → Term n → Term n → Set where\n\n _∎ : ∀ {n} (M : Term n)\n ------\n → M —↠ M\n\n _—→⟨_⟩_ : ∀ {n} {L N : Term n} (M : Term n)\n → M —→ L\n → L —↠ N\n ------\n → M —↠ N\n\n\n—↠-trans : ∀ {n} {M L N : Term n}\n → M —↠ L\n → L —↠ N\n ------\n → M —↠ N\n—↠-trans (M ∎) M—↠M = M—↠M\n—↠-trans (M —→⟨ M—→L′ ⟩ L′—↠L) L—↠N = M —→⟨ M—→L′ ⟩ (—↠-trans L′—↠L L—↠N )\n\n\n—↠-congₗ : ∀ {n} {M M′ R : Term n}\n → M —↠ M′\n ---------------\n → M · R —↠ M′ · R\n—↠-congₗ {M = M}{R = R} (M ∎) = M · R ∎\n—↠-congₗ {M = M}{R = R} (M —→⟨ M—→L ⟩ L—↠M′) = M · R —→⟨ —→-ξₗ M—→L ⟩ —↠-congₗ L—↠M′\n\n\n—↠-congᵣ : ∀ {n} {M M′ L : Term n}\n → M —↠ M′\n ---------------\n → L · M —↠ L · M′\n—↠-congᵣ {M = M}{L = L} (M ∎) = L · M ∎\n—↠-congᵣ {M = M}{L = L} (M —→⟨ M—→L ⟩ L—↠M′) = L · M —→⟨ —→-ξᵣ M—→L ⟩ —↠-congᵣ L—↠M′\n\n\n—↠-cong-ƛ : ∀ {n} {M M′ : Term (suc n)}\n → M —↠ M′\n -----------\n → ƛ M —↠ ƛ M′\n—↠-cong-ƛ (M ∎) = ƛ M ∎\n—↠-cong-ƛ (M —→⟨ M—→L ⟩ L—↠N′) = ƛ M —→⟨ —→-ƛ M—→L ⟩ —↠-cong-ƛ L—↠N′\n\n\n—↠-cong : ∀ {n} {M M′ N N′ : Term n}\n → M —↠ M′\n → N —↠ N′\n ----------------\n → M · N —↠ M′ · N′\n—↠-cong M—↠M′ N—↠N′ = —↠-trans (—↠-congₗ M—↠M′) (—↠-congᵣ N—↠N′)\n", "meta": {"hexsha": "ff41060106ec9473ece7d8ffc241235a73bdf59c", "size": 1830, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Beta.agda", "max_stars_repo_name": "iwilare/church-rosser", "max_stars_repo_head_hexsha": "2fa17f7738cc7da967375be928137adc4be38696", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-06-02T07:27:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-22T01:43:09.000Z", "max_issues_repo_path": "Beta.agda", "max_issues_repo_name": "iwilare/church-rosser", "max_issues_repo_head_hexsha": "2fa17f7738cc7da967375be928137adc4be38696", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Beta.agda", "max_forks_repo_name": "iwilare/church-rosser", "max_forks_repo_head_hexsha": "2fa17f7738cc7da967375be928137adc4be38696", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.0344827586, "max_line_length": 84, "alphanum_fraction": 0.3076502732, "num_tokens": 1059, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.837619979547273, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.607165825905658}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import lib.Basics\nopen import lib.types.Paths\nopen import lib.types.Pi\nopen import lib.types.Unit\nopen import lib.types.Nat\nopen import lib.types.TLevel\nopen import lib.types.Pointed\nopen import lib.types.Sigma\nopen import lib.NType2\n\nopen import lib.types.PathSeq\n\nopen import nicolai.pseudotruncations.Preliminary-definitions\nopen import nicolai.pseudotruncations.Liblemmas\nopen import nicolai.pseudotruncations.SeqColim\n\n\nmodule nicolai.pseudotruncations.wconst-preparation where\n\n\n{- first, we show that a weakly constant sequence for \n which we have an a₀ : A₀ is contractible.\n We proceed step-wise. -}\nmodule wconst-init {i} {C : Sequence {i}} (wc : wconst-chain C) (a₀ : fst C O) where\n\n A = fst C\n f = snd C\n SC = SeqCo C\n\n -- first, we show that [ins] is weakly constant\n ins-wconst : (n : ℕ) → wconst (ins {C = C} n)\n ins-wconst n a₁ a₂ = \n ins n a₁ =⟨ glue n a₁ ⟩\n ins (S n) (f n a₁) =⟨ ap (ins (S n)) (wc n a₁ a₂) ⟩\n ins (S n) (f n a₂) =⟨ ! (glue n a₂) ⟩\n ins n a₂ ∎\n\n \n {- Now, we want to define what is overline(i) is the paper\n (here, we call it î-def); that is:\n any a : A n is, if moved to A ω , equal to a₀.\n\n It is easy to define this, but the tricky part is that\n afterwards, we need to be able to reason about it.\n The 'equational reasoning' combinators are not suitable \n at all for this.\n\n What we use are the 'reified equational reasoning combinators',\n which allow this sort of thing. These are in the HoTT library,\n implemented by Guillaume Brunerie [I have extended it a bit\n in order to make it useable in my situation]. \n \n For an introduction to the concept, see the file\n\n lib.types.PathSeq.\n\n -}\n\n î-def : (n : ℕ) → (a : A n) → (ins {C = C} n a) =-= (ins O a₀)\n î-def n a = \n ins n a\n =⟪ glue n a ⟫\n ins (S n) (f n a)\n =⟪ ap (ins (S n)) (wc n _ _) ⟫\n ins (S n) (lift-point C a₀ (S n))\n =⟪ ! (lift-point-= C a₀ (S n)) ⟫\n ins O a₀\n ∎∎ \n \n {- It was easy to define î; it is more difficult to show that it satisfied\n the required coherence.\n This is the 'heptagon-proof'; we present it in \n nicolai.pseudotruncations.heptagon.agda.\n -}\n", "meta": {"hexsha": "de4472341f28de02ae77b422bc06303c66e42658", "size": 2266, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "nicolai/pseudotruncations/wconst-preparation.agda", "max_stars_repo_name": "nicolaikraus/HoTT-Agda", "max_stars_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_issues_repo_path": "nicolai/pseudotruncations/wconst-preparation.agda", "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nicolai/pseudotruncations/wconst-preparation.agda", "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.4285714286, "max_line_length": 84, "alphanum_fraction": 0.6328331862, "num_tokens": 733, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199592797929, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.6071658161928232}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Order-theoretic lattices\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Relation.Binary.Lattice where\n\nopen import Algebra.FunctionProperties\nopen import Data.Product using (_×_; _,_)\nopen import Function using (flip)\nopen import Level using (suc; _⊔_)\nopen import Relation.Binary\n\n------------------------------------------------------------------------\n-- Relationships between orders and operators\n\nopen import Relation.Binary public using (Maximum; Minimum)\n\nSupremum : ∀ {a ℓ} {A : Set a} → Rel A ℓ → Op₂ A → Set _\nSupremum _≤_ _∨_ =\n ∀ x y → x ≤ (x ∨ y) × y ≤ (x ∨ y) × ∀ z → x ≤ z → y ≤ z → (x ∨ y) ≤ z\n\nInfimum : ∀ {a ℓ} {A : Set a} → Rel A ℓ → Op₂ A → Set _\nInfimum _≤_ = Supremum (flip _≤_)\n\nExponential : ∀ {a ℓ} {A : Set a} → Rel A ℓ → Op₂ A → Op₂ A → Set _\nExponential _≤_ _∧_ _⇨_ =\n ∀ w x y → ((w ∧ x) ≤ y → w ≤ (x ⇨ y)) × (w ≤ (x ⇨ y) → (w ∧ x) ≤ y)\n\n------------------------------------------------------------------------\n-- Join semilattices\n\nrecord IsJoinSemilattice {a ℓ₁ ℓ₂} {A : Set a}\n (_≈_ : Rel A ℓ₁) -- The underlying equality.\n (_≤_ : Rel A ℓ₂) -- The partial order.\n (_∨_ : Op₂ A) -- The join operation.\n : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where\n field\n isPartialOrder : IsPartialOrder _≈_ _≤_\n supremum : Supremum _≤_ _∨_\n\n x≤x∨y : ∀ x y → x ≤ (x ∨ y)\n x≤x∨y x y = let pf , _ , _ = supremum x y in pf\n\n y≤x∨y : ∀ x y → y ≤ (x ∨ y)\n y≤x∨y x y = let _ , pf , _ = supremum x y in pf\n\n ∨-least : ∀ {x y z} → x ≤ z → y ≤ z → (x ∨ y) ≤ z\n ∨-least {x} {y} {z} = let _ , _ , pf = supremum x y in pf z\n\n open IsPartialOrder isPartialOrder public\n\nrecord JoinSemilattice c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _≤_\n infixr 6 _∨_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ₁ -- The underlying equality.\n _≤_ : Rel Carrier ℓ₂ -- The partial order.\n _∨_ : Op₂ Carrier -- The join operation.\n isJoinSemilattice : IsJoinSemilattice _≈_ _≤_ _∨_\n\n open IsJoinSemilattice isJoinSemilattice public\n\n poset : Poset c ℓ₁ ℓ₂\n poset = record { isPartialOrder = isPartialOrder }\n\n open Poset poset public using (preorder)\n\nrecord IsBoundedJoinSemilattice {a ℓ₁ ℓ₂} {A : Set a}\n (_≈_ : Rel A ℓ₁) -- The underlying equality.\n (_≤_ : Rel A ℓ₂) -- The partial order.\n (_∨_ : Op₂ A) -- The join operation.\n (⊥ : A) -- The minimum.\n : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where\n field\n isJoinSemilattice : IsJoinSemilattice _≈_ _≤_ _∨_\n minimum : Minimum _≤_ ⊥\n\n open IsJoinSemilattice isJoinSemilattice public\n\nrecord BoundedJoinSemilattice c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _≤_\n infixr 6 _∨_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ₁ -- The underlying equality.\n _≤_ : Rel Carrier ℓ₂ -- The partial order.\n _∨_ : Op₂ Carrier -- The join operation.\n ⊥ : Carrier -- The minimum.\n isBoundedJoinSemilattice : IsBoundedJoinSemilattice _≈_ _≤_ _∨_ ⊥\n\n open IsBoundedJoinSemilattice isBoundedJoinSemilattice public\n\n joinSemilattice : JoinSemilattice c ℓ₁ ℓ₂\n joinSemilattice = record { isJoinSemilattice = isJoinSemilattice }\n\n joinSemiLattice = joinSemilattice\n {-# WARNING_ON_USAGE joinSemiLattice\n \"Warning: joinSemiLattice was deprecated in v0.17.\n Please use joinSemilattice instead.\"\n #-}\n\n open JoinSemilattice joinSemilattice public using (preorder; poset)\n\n------------------------------------------------------------------------\n-- Meet semilattices\n\nrecord IsMeetSemilattice {a ℓ₁ ℓ₂} {A : Set a}\n (_≈_ : Rel A ℓ₁) -- The underlying equality.\n (_≤_ : Rel A ℓ₂) -- The partial order.\n (_∧_ : Op₂ A) -- The meet operation.\n : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where\n field\n isPartialOrder : IsPartialOrder _≈_ _≤_\n infimum : Infimum _≤_ _∧_\n\n x∧y≤x : ∀ x y → (x ∧ y) ≤ x\n x∧y≤x x y = let pf , _ , _ = infimum x y in pf\n\n x∧y≤y : ∀ x y → (x ∧ y) ≤ y\n x∧y≤y x y = let _ , pf , _ = infimum x y in pf\n\n ∧-greatest : ∀ {x y z} → x ≤ y → x ≤ z → x ≤ (y ∧ z)\n ∧-greatest {x} {y} {z} = let _ , _ , pf = infimum y z in pf x\n\n open IsPartialOrder isPartialOrder public\n\nrecord MeetSemilattice c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _≤_\n infixr 7 _∧_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ₁ -- The underlying equality.\n _≤_ : Rel Carrier ℓ₂ -- The partial order.\n _∧_ : Op₂ Carrier -- The meet operation.\n isMeetSemilattice : IsMeetSemilattice _≈_ _≤_ _∧_\n\n open IsMeetSemilattice isMeetSemilattice public\n\n poset : Poset c ℓ₁ ℓ₂\n poset = record { isPartialOrder = isPartialOrder }\n\n open Poset poset public using (preorder)\n\nrecord IsBoundedMeetSemilattice {a ℓ₁ ℓ₂} {A : Set a}\n (_≈_ : Rel A ℓ₁) -- The underlying equality.\n (_≤_ : Rel A ℓ₂) -- The partial order.\n (_∧_ : Op₂ A) -- The join operation.\n (⊤ : A) -- The maximum.\n : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where\n field\n isMeetSemilattice : IsMeetSemilattice _≈_ _≤_ _∧_\n maximum : Maximum _≤_ ⊤\n\n open IsMeetSemilattice isMeetSemilattice public\n\nrecord BoundedMeetSemilattice c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _≤_\n infixr 7 _∧_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ₁ -- The underlying equality.\n _≤_ : Rel Carrier ℓ₂ -- The partial order.\n _∧_ : Op₂ Carrier -- The join operation.\n ⊤ : Carrier -- The maximum.\n isBoundedMeetSemilattice : IsBoundedMeetSemilattice _≈_ _≤_ _∧_ ⊤\n\n open IsBoundedMeetSemilattice isBoundedMeetSemilattice public\n\n meetSemilattice : MeetSemilattice c ℓ₁ ℓ₂\n meetSemilattice = record { isMeetSemilattice = isMeetSemilattice }\n\n meetSemiLattice = meetSemilattice\n {-# WARNING_ON_USAGE meetSemiLattice\n \"Warning: meetSemiLattice was deprecated in v0.17.\n Please use meetSemilattice instead.\"\n #-}\n\n open MeetSemilattice meetSemilattice public using (preorder; poset)\n\n------------------------------------------------------------------------\n-- Lattices\n\nrecord IsLattice {a ℓ₁ ℓ₂} {A : Set a}\n (_≈_ : Rel A ℓ₁) -- The underlying equality.\n (_≤_ : Rel A ℓ₂) -- The partial order.\n (_∨_ : Op₂ A) -- The join operation.\n (_∧_ : Op₂ A) -- The meet operation.\n : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where\n field\n isPartialOrder : IsPartialOrder _≈_ _≤_\n supremum : Supremum _≤_ _∨_\n infimum : Infimum _≤_ _∧_\n\n isJoinSemilattice : IsJoinSemilattice _≈_ _≤_ _∨_\n isJoinSemilattice = record\n { isPartialOrder = isPartialOrder\n ; supremum = supremum\n }\n\n isMeetSemilattice : IsMeetSemilattice _≈_ _≤_ _∧_\n isMeetSemilattice = record\n { isPartialOrder = isPartialOrder\n ; infimum = infimum\n }\n\n open IsJoinSemilattice isJoinSemilattice public\n using (x≤x∨y; y≤x∨y; ∨-least)\n open IsMeetSemilattice isMeetSemilattice public\n using (x∧y≤x; x∧y≤y; ∧-greatest)\n open IsPartialOrder isPartialOrder public\n\nrecord Lattice c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _≤_\n infixr 6 _∨_\n infixr 7 _∧_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ₁ -- The underlying equality.\n _≤_ : Rel Carrier ℓ₂ -- The partial order.\n _∨_ : Op₂ Carrier -- The join operation.\n _∧_ : Op₂ Carrier -- The meet operation.\n isLattice : IsLattice _≈_ _≤_ _∨_ _∧_\n\n open IsLattice isLattice public\n\n setoid : Setoid c ℓ₁\n setoid = record { isEquivalence = isEquivalence }\n\n joinSemilattice : JoinSemilattice c ℓ₁ ℓ₂\n joinSemilattice = record { isJoinSemilattice = isJoinSemilattice }\n\n meetSemilattice : MeetSemilattice c ℓ₁ ℓ₂\n meetSemilattice = record { isMeetSemilattice = isMeetSemilattice }\n\n open JoinSemilattice joinSemilattice public using (poset; preorder)\n\nrecord IsDistributiveLattice {a ℓ₁ ℓ₂} {A : Set a}\n (_≈_ : Rel A ℓ₁) -- The underlying equality.\n (_≤_ : Rel A ℓ₂) -- The partial order.\n (_∨_ : Op₂ A) -- The join operation.\n (_∧_ : Op₂ A) -- The meet operation.\n : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where\n field\n isLattice : IsLattice _≈_ _≤_ _∨_ _∧_\n ∧-distribˡ-∨ : _DistributesOverˡ_ _≈_ _∧_ _∨_\n\n open IsLattice isLattice public\n\nrecord DistributiveLattice c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _≤_\n infixr 6 _∨_\n infixr 7 _∧_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ₁ -- The underlying equality.\n _≤_ : Rel Carrier ℓ₂ -- The partial order.\n _∨_ : Op₂ Carrier -- The join operation.\n _∧_ : Op₂ Carrier -- The meet operation.\n isDistributiveLattice : IsDistributiveLattice _≈_ _≤_ _∨_ _∧_\n\n open IsDistributiveLattice isDistributiveLattice using (∧-distribˡ-∨) public\n open IsDistributiveLattice isDistributiveLattice using (isLattice)\n\n lattice : Lattice c ℓ₁ ℓ₂\n lattice = record { isLattice = isLattice }\n\n open Lattice lattice hiding (Carrier; _≈_; _≤_; _∨_; _∧_) public\n\nrecord IsBoundedLattice {a ℓ₁ ℓ₂} {A : Set a}\n (_≈_ : Rel A ℓ₁) -- The underlying equality.\n (_≤_ : Rel A ℓ₂) -- The partial order.\n (_∨_ : Op₂ A) -- The join operation.\n (_∧_ : Op₂ A) -- The meet operation.\n (⊤ : A) -- The maximum.\n (⊥ : A) -- The minimum.\n : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where\n field\n isLattice : IsLattice _≈_ _≤_ _∨_ _∧_\n maximum : Maximum _≤_ ⊤\n minimum : Minimum _≤_ ⊥\n\n open IsLattice isLattice public\n\n isBoundedJoinSemilattice : IsBoundedJoinSemilattice _≈_ _≤_ _∨_ ⊥\n isBoundedJoinSemilattice = record\n { isJoinSemilattice = isJoinSemilattice\n ; minimum = minimum\n }\n\n isBoundedMeetSemilattice : IsBoundedMeetSemilattice _≈_ _≤_ _∧_ ⊤\n isBoundedMeetSemilattice = record\n { isMeetSemilattice = isMeetSemilattice\n ; maximum = maximum\n }\n\nrecord BoundedLattice c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _≤_\n infixr 6 _∨_\n infixr 7 _∧_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ₁ -- The underlying equality.\n _≤_ : Rel Carrier ℓ₂ -- The partial order.\n _∨_ : Op₂ Carrier -- The join operation.\n _∧_ : Op₂ Carrier -- The meet operation.\n ⊤ : Carrier -- The maximum.\n ⊥ : Carrier -- The minimum.\n isBoundedLattice : IsBoundedLattice _≈_ _≤_ _∨_ _∧_ ⊤ ⊥\n\n open IsBoundedLattice isBoundedLattice public\n\n boundedJoinSemilattice : BoundedJoinSemilattice c ℓ₁ ℓ₂\n boundedJoinSemilattice = record\n { isBoundedJoinSemilattice = isBoundedJoinSemilattice }\n\n boundedMeetSemilattice : BoundedMeetSemilattice c ℓ₁ ℓ₂\n boundedMeetSemilattice = record\n { isBoundedMeetSemilattice = isBoundedMeetSemilattice }\n\n lattice : Lattice c ℓ₁ ℓ₂\n lattice = record { isLattice = isLattice }\n\n open Lattice lattice public\n using (joinSemilattice; meetSemilattice; poset; preorder; setoid)\n\n------------------------------------------------------------------------\n-- Heyting algebras (a bounded lattice with exponential operator)\n\nrecord IsHeytingAlgebra {a ℓ₁ ℓ₂} {A : Set a}\n (_≈_ : Rel A ℓ₁) -- The underlying equality.\n (_≤_ : Rel A ℓ₂) -- The partial order.\n (_∨_ : Op₂ A) -- The join operation.\n (_∧_ : Op₂ A) -- The meet operation.\n (_⇨_ : Op₂ A) -- The exponential operation.\n (⊤ : A) -- The maximum.\n (⊥ : A) -- The minimum.\n : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where\n field\n isBoundedLattice : IsBoundedLattice _≈_ _≤_ _∨_ _∧_ ⊤ ⊥\n exponential : Exponential _≤_ _∧_ _⇨_\n\n transpose-⇨ : ∀ {w x y} → (w ∧ x) ≤ y → w ≤ (x ⇨ y)\n transpose-⇨ {w} {x} {y} = let pf , _ = exponential w x y in pf\n\n transpose-∧ : ∀ {w x y} → w ≤ (x ⇨ y) → (w ∧ x) ≤ y\n transpose-∧ {w} {x} {y} = let _ , pf = exponential w x y in pf\n\n open IsBoundedLattice isBoundedLattice public\n\nrecord HeytingAlgebra c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _≤_\n infixr 5 _⇨_\n infixr 6 _∨_\n infixr 7 _∧_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ₁ -- The underlying equality.\n _≤_ : Rel Carrier ℓ₂ -- The partial order.\n _∨_ : Op₂ Carrier -- The join operation.\n _∧_ : Op₂ Carrier -- The meet operation.\n _⇨_ : Op₂ Carrier -- The exponential operation.\n ⊤ : Carrier -- The maximum.\n ⊥ : Carrier -- The minimum.\n isHeytingAlgebra : IsHeytingAlgebra _≈_ _≤_ _∨_ _∧_ _⇨_ ⊤ ⊥\n\n boundedLattice : BoundedLattice c ℓ₁ ℓ₂\n boundedLattice = record\n { isBoundedLattice = IsHeytingAlgebra.isBoundedLattice isHeytingAlgebra }\n\n open IsHeytingAlgebra isHeytingAlgebra\n using (exponential; transpose-⇨; transpose-∧) public\n open BoundedLattice boundedLattice\n hiding (Carrier; _≈_; _≤_; _∨_; _∧_; ⊤; ⊥) public\n\n------------------------------------------------------------------------\n-- Boolean algebras (a specialized Heyting algebra)\n\nrecord IsBooleanAlgebra {a ℓ₁ ℓ₂} {A : Set a}\n (_≈_ : Rel A ℓ₁) -- The underlying equality.\n (_≤_ : Rel A ℓ₂) -- The partial order.\n (_∨_ : Op₂ A) -- The join operation.\n (_∧_ : Op₂ A) -- The meet operation.\n (¬_ : Op₁ A) -- The negation operation.\n (⊤ : A) -- The maximum.\n (⊥ : A) -- The minimum.\n : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where\n infixr 5 _⇨_\n _⇨_ : Op₂ A\n x ⇨ y = (¬ x) ∨ y\n\n field\n isHeytingAlgebra : IsHeytingAlgebra _≈_ _≤_ _∨_ _∧_ _⇨_ ⊤ ⊥\n\n open IsHeytingAlgebra isHeytingAlgebra public\n\nrecord BooleanAlgebra c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where\n infix 4 _≈_ _≤_\n infixr 6 _∨_\n infixr 7 _∧_\n infix 8 ¬_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ₁ -- The underlying equality.\n _≤_ : Rel Carrier ℓ₂ -- The partial order.\n _∨_ : Op₂ Carrier -- The join operation.\n _∧_ : Op₂ Carrier -- The meet operation.\n ¬_ : Op₁ Carrier -- The negation operation.\n ⊤ : Carrier -- The maximum.\n ⊥ : Carrier -- The minimum.\n isBooleanAlgebra : IsBooleanAlgebra _≈_ _≤_ _∨_ _∧_ ¬_ ⊤ ⊥\n\n open IsBooleanAlgebra isBooleanAlgebra using (isHeytingAlgebra)\n\n heytingAlgebra : HeytingAlgebra c ℓ₁ ℓ₂\n heytingAlgebra = record { isHeytingAlgebra = isHeytingAlgebra }\n\n open HeytingAlgebra heytingAlgebra public\n hiding (Carrier; _≈_; _≤_; _∨_; _∧_; ⊤; ⊥)\n", "meta": {"hexsha": "d206e036cd7b9ed0656e9236f3abca2328bd742d", "size": 15756, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Lattice.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Lattice.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Lattice.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.1603773585, "max_line_length": 78, "alphanum_fraction": 0.5389058137, "num_tokens": 5213, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199633332893, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.6071658141526232}} {"text": "-- Andreas, 2014-05-21, reported and test case by Fabien Renaud\n\nmodule Issue1138 where\n\nopen import Common.Equality\n\npostulate\n Var : Set\n Varset : Set\n _∖_ : Varset -> Var -> Varset\n _⊆_ : Varset -> Varset -> Set\n\ndata Expression : Set where\n abs : Var -> Expression -> Expression\n\nFV : Expression -> Varset\nFV (abs x M) = FV M ∖ x\n\ndata Env (A : Set) : Set where\n <> : Env A\n _,_:=_ : Env A -> Var -> A -> Env A\n\npostulate\n dom : ∀ {A} -> Env A -> Varset\n extend-dom : ∀ {A : Set} {a : A} {x xs ρ}\n -> (xs ∖ x) ⊆ dom ρ\n -> xs ⊆ dom (ρ , x := a)\n\nrecord Model (D : Set) : Set where\n field\n eval : (e : Expression) (ρ : Env D) -> FV e ⊆ dom ρ -> D\n d : D\n law : ∀ {M N ρ ν x y}\n -> eval M (ρ , x := d) (extend-dom {!!}) ≡\n eval N (ν , y := d) (extend-dom {!!})\n -> eval (abs x M) ρ {!!} ≡\n eval (abs y N) ν {!!}\n\n-- Expected: For holes numbered 0,1,2,3 above and four goals below:\n\n-- ?0 : (FV M ∖ x) ⊆ dom ρ\n-- ?1 : (FV N ∖ y) ⊆ dom ν\n-- ?2 : FV (abs x M) ⊆ dom ρ\n-- ?3 : FV (abs y N) ⊆ dom ν\n\n-- There was a problem that two interaction points were created\n-- per ? in record fields, thus, they were off in emacs.\n-- (Introduced by fix for issue 1083).\n", "meta": {"hexsha": "29afc43a8ff6e4af733d97802c820d7782ad76e4", "size": 1274, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue1138.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/interaction/Issue1138.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/interaction/Issue1138.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 26.0, "max_line_length": 68, "alphanum_fraction": 0.5117739403, "num_tokens": 463, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867777396212, "lm_q2_score": 0.7606506526772884, "lm_q1q2_score": 0.6071412934460246}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Data.List.Filter where\n\nopen import Prelude\nopen import Data.List\nopen import Data.List.Membership\nopen import Data.Sigma.Properties\nopen import Data.Bool.Properties\nopen import Data.Fin\n\nmodule _ {p} {P : A → Type p} where\n filter : (P? : ∀ x → Dec (P x)) → List A → List (∃ P)\n filter P? = foldr f []\n where\n f : _ → List (∃ P) → List (∃ P)\n f y ys with P? y\n ... | yes t = (y , t) ∷ ys\n ... | no _ = ys\n\n filter-preserves : (isPropP : ∀ x → isProp (P x)) (P? : ∀ x → Dec (P x)) (xs : List A) →\n (x : A) →\n (v : P x) →\n (x ∈ xs) →\n ((x , v) ∈ filter P? xs)\n filter-preserves isPropP P? (x ∷ xs) y v (n , y∈xs) with P? x\n filter-preserves isPropP P? (x ∷ xs) y v (f0 , y∈xs) | yes t = f0 , ΣProp≡ isPropP y∈xs\n filter-preserves isPropP P? (x ∷ xs) y v (fs n , y∈xs) | yes t = let m , q = filter-preserves isPropP P? xs y v (n , y∈xs) in fs m , q\n filter-preserves isPropP P? (x ∷ xs) y v (f0 , y∈xs) | no ¬t = ⊥-elim (¬t (subst P (sym y∈xs) v))\n filter-preserves isPropP P? (x ∷ xs) y v (fs n , y∈xs) | no ¬t = filter-preserves isPropP P? xs y v (n , y∈xs)\n", "meta": {"hexsha": "dc10e2cc4797d9f635b1730e42080cfcc64d46e4", "size": 1207, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Data/List/Filter.agda", "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "agda/Data/List/Filter.agda", "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Data/List/Filter.agda", "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.935483871, "max_line_length": 136, "alphanum_fraction": 0.5252692626, "num_tokens": 464, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.880797071719777, "lm_q2_score": 0.6893056040203136, "lm_q1q2_score": 0.6071383575411243}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import library.Basics hiding (Type ; Σ ; S)\nopen import library.types.Sigma\nopen import library.types.Bool\n\nopen import Sec2preliminaries \nopen import Sec3hedberg\nopen import Sec4hasConstToSplit\nopen import Sec5factorConst\nopen import Sec6populatedness\n\nmodule Sec7taboos where\n\n\n-- Subsection 7.1\n\n-- Lemma 7.1\nhasConst-family-dec : {X : Type} → (x₁ x₂ : X) → ((x : X) → hasConst ((x₁ == x) + (x₂ == x))) → (x₁ == x₂) + ¬(x₁ == x₂)\nhasConst-family-dec {X} x₁ x₂ hasConst-fam = solution where\n f₋ : (x : X) → (x₁ == x) + (x₂ == x) → (x₁ == x) + (x₂ == x)\n f₋ x = fst (hasConst-fam x)\n\n E₋ : X → Type\n E₋ x = fix (f₋ x)\n\n E : Type\n E = Σ X λ x → (E₋ x)\n\n E-fst-determines-eq : (e₁ e₂ : E) → (fst e₁ == fst e₂) → e₁ == e₂\n E-fst-determines-eq e₁ e₂ p = second-comp-triv (λ x → fixed-point (f₋ x) (snd (hasConst-fam x))) _ _ p\n\n r : Bool → E\n r true = x₁ , to-fix (f₋ x₁) (snd (hasConst-fam x₁)) (inl idp) \n r false = x₂ , to-fix (f₋ x₂) (snd (hasConst-fam x₂)) (inr idp)\n\n about-r : (r true == r false) ↔ (x₁ == x₂)\n about-r = (λ p → ap fst p) , (λ p → E-fst-determines-eq _ _ p)\n\n s : E → Bool\n s (_ , inl _ , _) = true\n s (_ , inr _ , _) = false\n\n s-section-of-r : (e : E) → r(s e) == e\n s-section-of-r (x , inl p , q) = E-fst-determines-eq _ _ p\n s-section-of-r (x , inr p , q) = E-fst-determines-eq _ _ p\n\n about-s : (e₁ e₂ : E) → (s e₁ == s e₂) ↔ (e₁ == e₂)\n about-s e₁ e₂ = one , two where\n one : (s e₁ == s e₂) → (e₁ == e₂)\n one p = \n e₁ =⟨ ! (s-section-of-r e₁) ⟩\n r(s(e₁)) =⟨ ap r p ⟩\n r(s(e₂)) =⟨ s-section-of-r e₂ ⟩\n e₂ ∎\n two : (e₁ == e₂) → (s e₁ == s e₂)\n two p = ap s p\n\n combine : (s (r true) == s (r false)) ↔ (x₁ == x₂)\n combine = (about-s _ _) ◎ about-r\n\n check-bool : (s (r true) == s (r false)) + ¬(s (r true) == s (r false))\n check-bool = Bool-has-dec-eq _ _\n\n solution : (x₁ == x₂) + ¬(x₁ == x₂)\n solution with check-bool \n solution | inl p = inl (fst combine p)\n solution | inr np = inr (λ p → np (snd combine p))\n\n\n-- The assumption that we are discussing:\nall-hasConst : Type₁\nall-hasConst = (X : Type) → hasConst X\n\n-- Theorem 7.2\nall-hasConst→dec-eq : all-hasConst → (X : Type) → has-dec-eq X\nall-hasConst→dec-eq ahc X x₁ x₂ = hasConst-family-dec x₁ x₂ (λ x → ahc _)\n\n\n-- Theorem 7.3\nmodule functional-subrelation (ac : all-hasConst) (X : Type) (R : X × X → Type) where\n\n all-sets : (Y : Type) → is-set Y\n all-sets Y = pathHasConst→isSet (λ y₁ y₂ → ac _)\n\n R₋ : (x : X) → Type\n R₋ x = Σ X λ y → R(x , y)\n\n k : (x : X) → (R₋ x) → (R₋ x)\n k x = fst (ac _)\n\n kc : (x : X) → const (k x)\n kc x = snd (ac _)\n\n S : X × X → Type\n S (x , y) = Σ (R(x , y)) λ a → \n (y , a) == k x (y , a)\n\n -- the relation S\n S₋ : (x : X) → Type\n S₋ x = Σ X λ y → S(x , y)\n\n -- fix kₓ is equivalent to Sₓ\n -- This is just Σ-assoc. We try to make it more readable by adding some (trivial) steps.\n fixk-S : (x : X) → (fix (k x)) ≃ S₋ x\n fixk-S x = \n (fix (k x)) ≃⟨ ide _ ⟩\n (Σ (Σ X λ y → R(x , y)) λ a → a == k x a) ≃⟨ Σ-assoc ⟩\n (Σ X λ y → Σ (R(x , y)) λ r → (y , r) == k x (y , r)) ≃⟨ ide _ ⟩\n (S₋ x) ≃∎\n\n -- claim (0)\n subrelation : (x y : X) → S(x , y) → R(x , y)\n subrelation x y (r , _) = r\n\n -- claim (1)\n prop-Sx : (x : X) → is-prop (S₋ x)\n prop-Sx x = equiv-preserves-level {A = fix (k x)} {B = (S₋ x)} (fixk-S x) (fixed-point _ (kc x)) \n\n -- claim (2)\n same-domain : (x : X) → (R₋ x) ↔ (S₋ x)\n same-domain x = rs , sr where\n rs : (R₋ x) → (S₋ x)\n rs a = –> (fixk-S x) (to-fix (k x) (kc x) a)\n sr : (S₋ x) → (R₋ x)\n sr (y , r , _) = y , r\n\n -- claim (3) \n prop-S : (x y : X) → is-prop (S (x , y))\n prop-S x y = all-paths-is-prop all-paths where\n all-paths : (s₁ s₂ : S(x , y)) → s₁ == s₂\n all-paths s₁ s₂ = ss where\n\n yss : (y , s₁) == (y , s₂)\n yss = prop-has-all-paths (prop-Sx x) _ _\n\n ss : s₁ == s₂\n ss = set-lemma (all-sets _) y s₁ s₂ yss\n\n\n-- intermediate definition\n-- see the caveat about the notion 'epimorphism' in the article\nis-split-epimorphism : {U V : Type} → (U → V) → Type\nis-split-epimorphism {U} {V} e = Σ (V → U) λ s → (v : V) → e (s v) == v\n\nis-epimorphism : {U V : Type} → (U → V) → Type₁\nis-epimorphism {U} {V} e = (W : Type) → (f g : V → W) → ((u : U) → f (e u) == g (e u)) → (v : V) → f v == g v\n\n-- Lemma 7.4\npath-trunc-epi→set : {Y : Type} → ((y₁ y₂ : Y) → is-epimorphism (∣_∣ {X = y₁ == y₂})) → is-set Y\npath-trunc-epi→set {Y} path-epi = reminder special-case where\n\n f : (y₁ y₂ : Y) → Trunc (y₁ == y₂) → Y\n f y₁ _ _ = y₁\n\n g : (y₁ y₂ : Y) → Trunc (y₁ == y₂) → Y\n g _ y₂ _ = y₂\n\n special-case : (y₁ y₂ : Y) → Trunc (y₁ == y₂) → y₁ == y₂\n special-case y₁ y₂ = path-epi y₁ y₂ Y (f y₁ y₂) (g y₁ y₂) (idf _)\n\n reminder : hseparated Y → is-set Y\n reminder = fst set-characterizations ∘ snd (snd set-characterizations)\n\n-- Theorem 7.5 (1)\nall-split→all-deceq : ((X : Type) → is-split-epimorphism (∣_∣ {X = X})) → (X : Type) → has-dec-eq X\nall-split→all-deceq all-split = all-hasConst→dec-eq ac where\n ac : (X : Type) → hasConst X\n ac X = snd hasConst↔splitSup (fst (all-split X))\n\n-- Theorem 7.5 (2)\nall-epi→all-set : ((X : Type) → is-epimorphism (∣_∣ {X = X})) → (X : Type) → is-set X\nall-epi→all-set all-epi X = path-trunc-epi→set (λ y₁ y₂ → all-epi (y₁ == y₂))\n\n\n-- Subsection 7.2\n\n-- Lemma 7.6, first proof\npop-splitSup-1 : {X : Type} → Pop (splitSup X)\npop-splitSup-1 {X} f c = to-fix f c (hasConst→splitSup (g , gc)) where\n\n g : X → X\n g x = f (λ _ → x) ∣ x ∣\n\n gc : const g\n gc x₁ x₂ = \n g x₁ =⟨ idp ⟩\n f (λ _ → x₁) ∣ x₁ ∣ =⟨ ap (λ k → k ∣ x₁ ∣) (c (λ _ → x₁) (λ _ → x₂)) ⟩\n f (λ _ → x₂) ∣ x₁ ∣ =⟨ ap (f (λ _ → x₂)) (prop-has-all-paths (h-tr X) ∣ x₁ ∣ ∣ x₂ ∣) ⟩\n f (λ _ → x₂) ∣ x₂ ∣ =⟨ idp ⟩\n g x₂ ∎ \n\n-- Lemma 7.6, second proof\npop-splitSup-2 : {X : Type} → Pop (splitSup X)\npop-splitSup-2 {X} = snd (pop-alt₂ {splitSup X}) get-P where\n get-P : (P : Type) → is-prop P → splitSup X ↔ P → P\n get-P P pp (hstp , phst) = hstp free-hst where\n\n xp : X → P\n xp x = hstp (λ _ → x)\n\n zp : Trunc X → P\n zp = rec pp xp\n\n free-hst : splitSup X\n free-hst z = phst (zp z) z\n\n-- Lemma 7.6, third proof\npop-splitSup-3 : {X : Type} → Pop (splitSup X)\npop-splitSup-3 {X} = snd pop-alt translation where\n\n translation-aux : splitSup (splitSup X) → splitSup X\n translation-aux = λ hsthst z → hsthst (trunc-functorial {X = X} {Y = splitSup X} (λ x _ → x) z) z\n\n translation : Trunc (splitSup (splitSup X)) → Trunc (splitSup X)\n translation = trunc-functorial translation-aux\n\n-- Theorem 7.7\nmodule thm77 where\n\n One = (X : Type) → Pop X → Trunc X\n\n Two = (X : Type) → Trunc (splitSup X)\n\n Three = (P : Type) → is-prop P → (Y : P → Type) → ((p : P) → Trunc (Y p)) → Trunc ((p : P) → Y p)\n\n Four = (X Y : Type) → (X → Y) → (Pop X → Pop Y)\n\n\n One→Two : One → Two\n One→Two poptr X = poptr (splitSup X) pop-splitSup-1 \n\n Two→One : Two → One\n Two→One trhst X pop = fst pop-alt pop (trhst X)\n\n One→Four : One → Four\n One→Four poptr X Y f = Trunc→Pop ∘ (trunc-functorial f) ∘ (poptr X)\n\n Four→One : Four → One\n Four→One funct X px = snd (prop→hasConst×PopX→X (h-tr _)) pz where\n pz : Pop (Trunc X)\n pz = funct X (Trunc X) ∣_∣ px\n\n -- only very slightly different to the proof in the article\n One→Three : One → Three\n One→Three poptr P pp Y = λ py → poptr _ (snd pop-alt' (λ hst p₀ → hst (contr-trick p₀ py) p₀)) where\n contr-trick : (p₀ : P) → ((p : P) → Trunc (Y p)) → Trunc ((p : P) → Y p)\n contr-trick p₀ py = rec {X = Y p₀} \n {P = Trunc ((p : P) → Y p)} \n (h-tr _) \n (λ y₀ → ∣ <– (thm55aux.neutral-contr-exp {P = P} {Y = Y} pp p₀) y₀ ∣) (py p₀)\n\n Three→Two : Three → Two\n Three→Two proj X = proj (Trunc X) (h-tr _) (λ _ → X) (idf _)\n\n\n-- Subsection 7.3\n\n-- Some very simple lemmata\n\n-- If P is a proposition, so is P + ¬ P\ndec-is-prop : {P : Type} → (Funext {X = P} {Y = Empty}) → is-prop P → is-prop (P + ¬ P)\ndec-is-prop {P} fext pp = all-paths-is-prop (λ { (inl p₁) (inl p₂) → ap inl (prop-has-all-paths pp _ _) ; \n (inl p₁) (inr np₂) → Empty-elim {A = λ _ → inl p₁ == inr np₂} (np₂ p₁) ; \n (inr np₁) (inl p₂) → Empty-elim {A = λ _ → inr np₁ == inl p₂} (np₁ p₂) ; \n (inr np₁) (inr np₂) → ap inr (fext np₁ np₂ (λ p → prop-has-all-paths (λ ()) _ _)) })\n\n\n-- Theorem 7.8\nnonempty-pop→lem : ((X : Type) → Funext {X} {Empty}) \n → ((X : Type) → (¬(¬ X) → Pop X)) → LEM\nnonempty-pop→lem fext nn-pop P pp = from-fix {X = dec} (idf _) (nn-pop dec nndec (idf _) idc) where\n dec : Type\n dec = P + ¬ P\n\n idc : const (idf dec)\n idc = λ _ _ → prop-has-all-paths (dec-is-prop {P} (fext P) pp) _ _\n\n nndec : ¬(¬ dec)\n nndec ndec = (λ np → ndec (inr np)) λ p → ndec (inl p)\n\n-- Corollary 7.9\nnonempty-pop↔lem : ((X : Type) → Funext {X} {Empty}) \n → ((X : Type) → (¬(¬ X) → Pop X)) ↔₁₁ LEM\nnonempty-pop↔lem fext = nonempty-pop→lem fext , other where\n other : LEM → ((X : Type) → (¬(¬ X) → Pop X))\n other lem X nnX = p where\n pnp : Pop X + ¬ (Pop X)\n pnp = lem (Pop X) pop-property₂\n\n p : Pop X\n p = match pnp withl idf _ withr (λ np → Empty-elim {A = λ _ → Pop X} (nnX (λ x → np (pop-property₁ x))))\n", "meta": {"hexsha": "4f0d433fb92b90b8fc79621910bd7629ea286145", "size": 9462, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "nicolai/anonymousExistence/Sec7taboos.agda", "max_stars_repo_name": "nicolaikraus/HoTT-Agda", "max_stars_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_issues_repo_path": "nicolai/anonymousExistence/Sec7taboos.agda", "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nicolai/anonymousExistence/Sec7taboos.agda", "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.2935153584, "max_line_length": 120, "alphanum_fraction": 0.515007398, "num_tokens": 3950, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789086703225, "lm_q2_score": 0.7490872131147276, "lm_q1q2_score": 0.6071193869841177}} {"text": "{-# OPTIONS --without-K --safe #-}\n\n--------------------------------------------------------------------------------\n-- A simple reflection based solver for categories.\n--\n-- Based off 'Tactic.MonoidSolver' from 'agda-stdlib'\n--------------------------------------------------------------------------------\n\nopen import Categories.Category\n\nmodule Categories.Tactic.Category where\n\nopen import Level\nopen import Function using (_⟨_⟩_)\n\nopen import Data.Bool as Bool using (Bool; _∨_; if_then_else_)\nopen import Data.Maybe as Maybe using (Maybe; just; nothing; maybe)\nopen import Data.List as List using (List; _∷_; [])\nopen import Data.Product as Product using (_×_; _,_)\n\nopen import Agda.Builtin.Reflection\nopen import Reflection.Argument\nopen import Reflection.Term using (getName; _⋯⟅∷⟆_)\nopen import Reflection.TypeChecking.Monad.Syntax\n\nmodule _ {o ℓ e} (𝒞 : Category o ℓ e) where\n\n open Category 𝒞\n open HomReasoning\n open Equiv\n\n private\n variable\n A B C : Obj\n f g : A ⇒ B\n\n --------------------------------------------------------------------------------\n -- An 'Expr' reifies the parentheses/identity morphisms of some series of \n -- compositions of morphisms into a data structure. In fact, this is also\n -- a category!\n --------------------------------------------------------------------------------\n data Expr : Obj → Obj → Set (o ⊔ ℓ) where\n _∘′_ : ∀ {A B C} → Expr B C → Expr A B → Expr A C \n id′ : ∀ {A} → Expr A A\n [_↑] : ∀ {A B} → A ⇒ B → Expr A B\n \n -- Embed a morphism in 'Expr' back into '𝒞' without normalizing.\n [_↓] : Expr A B → A ⇒ B \n [ f ∘′ g ↓] = [ f ↓] ∘ [ g ↓]\n [ id′ ↓] = id\n [ [ f ↑] ↓] = f\n \n -- Convert an 'Expr' back into a morphism, while normalizing\n --\n -- This actually embeds the morphism into the category of copresheaves\n -- on 𝒞, which obeys the category laws up to beta-eta equality.\n -- This lets us normalize away all the associations/identity morphisms.\n embed : Expr B C → A ⇒ B → A ⇒ C\n embed (f ∘′ g) h = embed f (embed g h)\n embed id′ h = h\n embed [ f ↑] h = f ∘ h\n\n \n preserves-≈′ : ∀ (f : Expr B C) → (h : A ⇒ B) → embed f id ∘ h ≈ embed f h\n preserves-≈′ id′ f = identityˡ\n preserves-≈′ [ x ↑] f = ∘-resp-≈ˡ identityʳ\n preserves-≈′ (f ∘′ g) h = begin\n embed (f ∘′ g) id ∘ h ≡⟨⟩\n embed f (embed g id) ∘ h ≈˘⟨ preserves-≈′ f (embed g id) ⟩∘⟨refl ⟩\n (embed f id ∘ embed g id) ∘ h ≈⟨ assoc ⟩\n embed f id ∘ embed g id ∘ h ≈⟨ refl⟩∘⟨ preserves-≈′ g h ⟩\n embed f id ∘ embed g h ≈⟨ preserves-≈′ f (embed g h) ⟩\n embed (f ∘′ g) h ∎\n \n preserves-≈ : ∀ (f : Expr A B) → embed f id ≈ [ f ↓]\n preserves-≈ id′ = refl\n preserves-≈ [ x ↑] = identityʳ\n preserves-≈ (f ∘′ g) = begin\n embed (f ∘′ g) id ≈˘⟨ preserves-≈′ f (embed g id) ⟩\n embed f id ∘ embed g id ≈⟨ preserves-≈ f ⟩∘⟨ preserves-≈ g ⟩\n [ f ↓] ∘ [ g ↓] ≡⟨⟩\n [ f ∘′ g ↓] ∎\n\n--------------------------------------------------------------------------------\n-- Reflection Helpers\n--------------------------------------------------------------------------------\n\n_==_ = primQNameEquality\n{-# INLINE _==_ #-}\n\ngetArgs : Term → Maybe (Term × Term)\ngetArgs (def _ xs) = go xs\n where\n go : List (Arg Term) → Maybe (Term × Term)\n go (vArg x ∷ vArg y ∷ []) = just (x , y)\n go (x ∷ xs) = go xs\n go _ = nothing\ngetArgs _ = nothing\n\n--------------------------------------------------------------------------------\n-- Getting Category Names\n--------------------------------------------------------------------------------\n\nrecord CategoryNames : Set where\n field\n is-∘ : Name → Bool\n is-id : Name → Bool\n\nbuildMatcher : Name → Maybe Name → Name → Bool\nbuildMatcher n nothing x = n == x\nbuildMatcher n (just m) x = n == x ∨ m == x\n\nfindCategoryNames : Term → TC CategoryNames\nfindCategoryNames cat = do\n ∘-altName ← normalise (def (quote Category._∘_) (3 ⋯⟅∷⟆ cat ⟨∷⟩ []))\n id-altName ← normalise (def (quote Category.id) (3 ⋯⟅∷⟆ cat ⟨∷⟩ []))\n returnTC record\n { is-∘ = buildMatcher (quote Category._∘_) (getName ∘-altName)\n ; is-id = buildMatcher (quote Category.id) (getName id-altName)\n }\n\n--------------------------------------------------------------------------------\n-- Constructing an Expr\n--------------------------------------------------------------------------------\n\n″id″ : Term\n″id″ = quote id′ ⟨ con ⟩ []\n\n″[_↑]″ : Term → Term\n″[ t ↑]″ = quote [_↑] ⟨ con ⟩ (t ⟨∷⟩ [])\n\nmodule _ (names : CategoryNames) where\n\n open CategoryNames names\n\n mutual\n ″∘″ : List (Arg Term) → Term\n ″∘″ (x ⟨∷⟩ y ⟨∷⟩ xs) = quote _∘′_ ⟨ con ⟩ buildExpr x ⟨∷⟩ buildExpr y ⟨∷⟩ []\n ″∘″ (x ∷ xs) = ″∘″ xs\n ″∘″ _ = unknown\n\n buildExpr : Term → Term\n buildExpr t@(def n xs) =\n if (is-∘ n)\n then ″∘″ xs\n else if (is-id n)\n then ″id″\n else\n ″[ t ↑]″\n buildExpr t@(con n xs) =\n if (is-∘ n)\n then ″∘″ xs\n else if (is-id n)\n then ″id″\n else\n ″[ t ↑]″\n buildExpr t = ″[ t ↑]″\n\n--------------------------------------------------------------------------------\n-- Constructing the Solution\n--------------------------------------------------------------------------------\n\nconstructSoln : Term → CategoryNames → Term → Term → Term\nconstructSoln cat names lhs rhs =\n quote Category.Equiv.trans ⟨ def ⟩ 3 ⋯⟅∷⟆ cat ⟨∷⟩\n (quote Category.Equiv.sym ⟨ def ⟩ 3 ⋯⟅∷⟆ cat ⟨∷⟩\n (quote preserves-≈ ⟨ def ⟩ 3 ⋯⟅∷⟆ cat ⟨∷⟩ buildExpr names lhs ⟨∷⟩ []) ⟨∷⟩ [])\n ⟨∷⟩\n (quote preserves-≈ ⟨ def ⟩ 3 ⋯⟅∷⟆ cat ⟨∷⟩ buildExpr names rhs ⟨∷⟩ [])\n ⟨∷⟩ []\n\nsolve-macro : Term → Term → TC _\nsolve-macro mon hole = do\n hole′ ← inferType hole >>= normalise\n names ← findCategoryNames mon\n just (lhs , rhs) ← returnTC (getArgs hole′)\n where nothing → typeError (termErr hole′ ∷ [])\n let soln = constructSoln mon names lhs rhs\n unify hole soln\n\nmacro\n solve : Term → Term → TC _\n solve = solve-macro\n\n", "meta": {"hexsha": "1ab24c52bfb880a247b80b2ccf8ad241fd091cbf", "size": 6008, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Tactic/Category.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Tactic/Category.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Tactic/Category.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 32.4756756757, "max_line_length": 83, "alphanum_fraction": 0.4715379494, "num_tokens": 1880, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473680407889, "lm_q2_score": 0.6959583376458153, "lm_q1q2_score": 0.6071174241113697}} {"text": "{-# OPTIONS --without-K --safe #-}\nopen import Level\n\nopen import Categories.Category\n\nmodule Categories.Category.Construction.Path {o ℓ e : Level} (C : Category o ℓ e) where\n\nopen import Function using (flip)\nopen import Relation.Binary hiding (_⇒_)\nopen import Relation.Binary.Construct.Closure.Transitive\n\nopen Category C\n\n-- Defining the Path Category\n∘-tc : {A B : Obj} → A [ _⇒_ ]⁺ B → A ⇒ B\n∘-tc [ f ] = f\n∘-tc (_ ∼⁺⟨ f⁺ ⟩ f⁺′) = ∘-tc f⁺′ ∘ ∘-tc f⁺\n\ninfix 4 _≈⁺_\n_≈⁺_ : {A B : Obj} → (i j : A [ _⇒_ ]⁺ B) → Set e\nf⁺ ≈⁺ g⁺ = ∘-tc f⁺ ≈ ∘-tc g⁺\n\nPath : Category o (o ⊔ ℓ) e\nPath = record\n { Obj = Obj\n ; _⇒_ = λ A B → A [ _⇒_ ]⁺ B\n ; _≈_ = _≈⁺_\n ; id = [ id ]\n ; _∘_ = flip (_ ∼⁺⟨_⟩_)\n ; assoc = assoc\n ; sym-assoc = sym-assoc\n ; identityˡ = identityˡ\n ; identityʳ = identityʳ\n ; identity² = identity²\n ; equiv = record\n { refl = refl\n ; sym = sym\n ; trans = trans\n }\n ; ∘-resp-≈ = ∘-resp-≈\n }\n where open HomReasoning\n", "meta": {"hexsha": "150080d6e6aa3985454ebd9b0ac6808d9a73ad62", "size": 1003, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Construction/Path.agda", "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Category/Construction/Path.agda", "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Construction/Path.agda", "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.3255813953, "max_line_length": 87, "alphanum_fraction": 0.5333998006, "num_tokens": 424, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8723473746782093, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.607117423229557}} {"text": "{-# OPTIONS --erased-cubical --safe --no-sized-types --no-guardedness\n --no-subtyping #-}\n\nmodule Agda.Builtin.Cubical.Path where\n\n open import Agda.Primitive.Cubical using (PathP) public\n\n\n infix 4 _≡_\n\n -- We have a variable name in `(λ i → A)` as a hint for case\n -- splitting.\n _≡_ : ∀ {ℓ} {A : Set ℓ} → A → A → Set ℓ\n _≡_ {A = A} = PathP (λ i → A)\n\n {-# BUILTIN PATH _≡_ #-}\n", "meta": {"hexsha": "722fce87ab6cad01b32afad6ae0079ae5e73dae7", "size": 410, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/Cubical/Path.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/Cubical/Path.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/Cubical/Path.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-18T13:34:07.000Z", "avg_line_length": 24.1176470588, "max_line_length": 69, "alphanum_fraction": 0.5682926829, "num_tokens": 145, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8519528019683105, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.6067882102182869}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Some derivable properties\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Algebra\n\nmodule Algebra.Properties.Semilattice {l₁ l₂} (L : Semilattice l₁ l₂) where\n\nopen Semilattice L\nopen import Algebra.Structures\nopen import Relation.Binary\nimport Relation.Binary.Construct.NaturalOrder.Left as LeftNaturalOrder\nimport Relation.Binary.Lattice as R\nimport Relation.Binary.Properties.Poset as R\nopen import Relation.Binary.EqReasoning setoid\nopen import Function\nopen import Data.Product\n\n------------------------------------------------------------------------\n-- Every semilattice can be turned into a poset via the left natural\n-- order.\n\nposet : Poset _ _ _\nposet = LeftNaturalOrder.poset _≈_ _∧_ isSemilattice\n\nopen Poset poset using (_≤_; isPartialOrder)\n\n------------------------------------------------------------------------\n-- Every algebraic semilattice can be turned into an order-theoretic one.\n\nisOrderTheoreticMeetSemilattice : R.IsMeetSemilattice _≈_ _≤_ _∧_\nisOrderTheoreticMeetSemilattice = record\n { isPartialOrder = isPartialOrder\n ; infimum = LeftNaturalOrder.infimum _≈_ _∧_ isSemilattice\n }\n\norderTheoreticMeetSemilattice : R.MeetSemilattice _ _ _\norderTheoreticMeetSemilattice = record\n { isMeetSemilattice = isOrderTheoreticMeetSemilattice }\n\nisOrderTheoreticJoinSemilattice : R.IsJoinSemilattice _≈_ (flip _≤_) _∧_\nisOrderTheoreticJoinSemilattice = record\n { isPartialOrder = R.invIsPartialOrder poset\n ; supremum = R.IsMeetSemilattice.infimum\n isOrderTheoreticMeetSemilattice\n }\n\norderTheoreticJoinSemilattice : R.JoinSemilattice _ _ _\norderTheoreticJoinSemilattice = record\n { isJoinSemilattice = isOrderTheoreticJoinSemilattice }\n", "meta": {"hexsha": "b7e29a0ecf8421123df7d15ba5cf810e3ffb3c01", "size": 1880, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Properties/Semilattice.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Properties/Semilattice.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Properties/Semilattice.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.1818181818, "max_line_length": 75, "alphanum_fraction": 0.6664893617, "num_tokens": 462, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519528019683106, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.6067881998104746}} {"text": "{-# OPTIONS --cubical --safe #-}\nmodule Cubical.Data.Nat.Mod where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Nat.Order\n\n-- Defining x mod 0 to be 0. This way all the theorems below are true\n-- for n : ℕ instead of n : ℕ₊₁.\n\n------ Preliminary definitions ------\nmodInd : (n : ℕ) → ℕ → ℕ\nmodInd n = +induction n (λ _ → ℕ) (λ x _ → x) λ _ x → x\n\nmodIndBase : (n m : ℕ) → m < suc n → modInd n m ≡ m\nmodIndBase n = +inductionBase n (λ _ → ℕ) (λ x _ → x) (λ _ x → x)\n\nmodIndStep : (n m : ℕ) → modInd n (suc n + m) ≡ modInd n m\nmodIndStep n = +inductionStep n (λ _ → ℕ) (λ x _ → x) (λ _ x → x)\n-------------------------------------\n\n_mod_ : (x n : ℕ) → ℕ\nx mod zero = 0\nx mod (suc n) = modInd n x\n\nmod< : (n x : ℕ) → x mod (suc n) < (suc n)\nmod< n =\n +induction n\n (λ x → x mod (suc n) < suc n)\n (λ x base → fst base\n , (cong (λ x → fst base + suc x)\n (modIndBase n x base)\n ∙ snd base))\n λ x ind → fst ind\n , cong (λ x → fst ind + suc x)\n (modIndStep n x) ∙ snd ind\n\nmod-rUnit : (n x : ℕ) → x mod n ≡ ((x + n) mod n)\nmod-rUnit zero x = refl\nmod-rUnit (suc n) x =\n sym (modIndStep n x)\n ∙ cong (modInd n) (+-comm (suc n) x)\n\nmod-lUnit : (n x : ℕ) → x mod n ≡ ((n + x) mod n)\nmod-lUnit zero _ = refl\nmod-lUnit (suc n) x = sym (modIndStep n x)\n\nmod+mod≡mod : (n x y : ℕ)\n → (x + y) mod n ≡ (((x mod n) + (y mod n)) mod n)\nmod+mod≡mod zero _ _ = refl\nmod+mod≡mod (suc n) =\n +induction n\n (λ z → (x : ℕ)\n → ((z + x) mod (suc n))\n ≡ (((z mod (suc n)) + (x mod (suc n))) mod (suc n)))\n (λ x p →\n +induction n _\n (λ y q → cong (modInd n)\n (sym (cong₂ _+_ (modIndBase n x p)\n (modIndBase n y q))))\n λ y ind → cong (modInd n)\n (cong (x +_) (+-comm (suc n) y)\n ∙ (+-assoc x y (suc n)))\n ∙∙ sym (mod-rUnit (suc n) (x + y))\n ∙∙ ind\n ∙ cong (λ z → modInd n\n ((modInd n x + z)))\n (mod-rUnit (suc n) y\n ∙ cong (modInd n) (+-comm y (suc n))))\n λ x p y →\n cong (modInd n) (cong suc (sym (+-assoc n x y)))\n ∙∙ sym (mod-lUnit (suc n) (x + y))\n ∙∙ p y\n ∙ sym (cong (modInd n)\n (cong (_+ modInd n y)\n (cong (modInd n)\n (+-comm (suc n) x) ∙ sym (mod-rUnit (suc n) x))))\n\nmod-idempotent : {n : ℕ} (x : ℕ) → (x mod n) mod n ≡ x mod n\nmod-idempotent {n = zero} _ = refl\nmod-idempotent {n = suc n} =\n +induction n (λ x → (x mod suc n) mod (suc n) ≡ x mod (suc n))\n (λ x p → cong (_mod (suc n))\n (modIndBase n x p))\n λ x p → cong (_mod (suc n))\n (modIndStep n x)\n ∙∙ p\n ∙∙ mod-rUnit (suc n) x\n ∙ (cong (_mod (suc n)) (+-comm x (suc n)))\n\nmod-rCancel : (n x y : ℕ) → (x + y) mod n ≡ (x + y mod n) mod n\nmod-rCancel zero x y = refl\nmod-rCancel (suc n) x =\n +induction n _\n (λ y p → cong (λ z → (x + z) mod (suc n))\n (sym (modIndBase n y p)))\n λ y p → cong (_mod suc n) (+-assoc x (suc n) y\n ∙∙ (cong (_+ y) (+-comm x (suc n)))\n ∙∙ sym (+-assoc (suc n) x y))\n ∙∙ sym (mod-lUnit (suc n) (x + y))\n ∙∙ (p ∙ cong (λ z → (x + z) mod suc n) (mod-lUnit (suc n) y))\n\nmod-lCancel : (n x y : ℕ) → (x + y) mod n ≡ (x mod n + y) mod n\nmod-lCancel n x y =\n cong (_mod n) (+-comm x y)\n ∙∙ mod-rCancel n y x\n ∙∙ cong (_mod n) (+-comm y (x mod n))\n\nzero-charac : (n : ℕ) → n mod n ≡ 0\nzero-charac zero = refl\nzero-charac (suc n) = cong (_mod suc n) (+-comm 0 (suc n))\n ∙∙ modIndStep n 0\n ∙∙ modIndBase n 0 (n , (+-comm n 1))\n\n-- remainder and quotient after division by n\n-- Again, allowing for 0-division to get nicer syntax\nremainder_/_ : (x n : ℕ) → ℕ\nremainder x / zero = x\nremainder x / suc n = x mod (suc n)\n\nquotient_/_ : (x n : ℕ) → ℕ\nquotient x / zero = 0\nquotient x / suc n =\n +induction n (λ _ → ℕ) (λ _ _ → 0) (λ _ → suc) x\n\n≡remainder+quotient : (n x : ℕ)\n → (remainder x / n) + n · (quotient x / n) ≡ x\n≡remainder+quotient zero x = +-comm x 0\n≡remainder+quotient (suc n) =\n +induction n\n (λ x → (remainder x / (suc n)) + (suc n)\n · (quotient x / (suc n)) ≡ x)\n (λ x base → cong₂ _+_ (modIndBase n x base)\n (cong ((suc n) ·_)\n (+inductionBase n _ _ _ x base))\n ∙∙ cong (x +_) (·-comm n 0)\n ∙∙ +-comm x 0)\n λ x ind → cong₂ _+_ (modIndStep n x)\n (cong ((suc n) ·_) (+inductionStep n _ _ _ x))\n ∙∙ cong (modInd n x +_)\n (·-suc (suc n) (+induction n _ _ _ x))\n ∙∙ cong (modInd n x +_)\n (+-comm (suc n) ((suc n) · (+induction n _ _ _ x)))\n ∙∙ +-assoc (modInd n x) ((suc n) · +induction n _ _ _ x) (suc n)\n ∙∙ cong (_+ suc n) ind\n ∙ +-comm x (suc n)\n\nprivate\n test₀ : 100 mod 81 ≡ 19\n test₀ = refl\n\n test₁ : ((11 + (10 mod 3)) mod 3) ≡ 0\n test₁ = refl\n", "meta": {"hexsha": "4eddabaf490104ef13b33c39b9d63b9ac12fe0a4", "size": 5337, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/Nat/Mod.agda", "max_stars_repo_name": "FernandoLarrain/cubical", "max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-02-05T21:49:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T21:49:23.000Z", "max_issues_repo_path": "Cubical/Data/Nat/Mod.agda", "max_issues_repo_name": "FernandoLarrain/cubical", "max_issues_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Data/Nat/Mod.agda", "max_forks_repo_name": "FernandoLarrain/cubical", "max_forks_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.6558441558, "max_line_length": 74, "alphanum_fraction": 0.4455686715, "num_tokens": 1957, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519527906914787, "lm_q2_score": 0.7122321720225278, "lm_q1q2_score": 0.6067881865748458}} {"text": "module MLib.Fin.Parts.Nat where\n\nopen import MLib.Prelude\nopen import MLib.Fin.Parts.Core\n\nopen Nat using (_*_; _+_; _<_)\nopen Fin using (fromℕ≤)\nopen Table\n\nmodule Impl where\n tryLookup : ∀ {n} {a} {A : Set a} → A → Table A n → ℕ → A\n tryLookup {n = zero} z t _ = z\n tryLookup {n = suc n} z t zero = lookup t zero\n tryLookup {n = suc n} z t (suc i) = tryLookup z (tail t) i\n\n tryLookup-prop : ∀ {n} {a} {A : Set a} {z : A} (t : Table A n) {i : Fin n} → lookup t i ≡ tryLookup z t (Fin.toℕ i)\n tryLookup-prop _ {i = zero} = ≡.refl\n tryLookup-prop t {i = suc i} = tryLookup-prop (tail t)\n\n data Ordering′ : ℕ → ℕ → Set where\n less : ∀ m k → Ordering′ m (suc (m + k))\n gte : ∀ m k → Ordering′ (m + k) m\n\n compare′ : ∀ m n → Ordering′ m n\n compare′ zero zero = gte zero zero\n compare′ zero (suc n) = less zero n\n compare′ (suc m) zero = gte zero (suc m)\n compare′ (suc m) (suc n) with compare′ m n\n compare′ (suc m) (suc .(suc (m + k))) | less .m k = less (suc m) k\n compare′ (suc .(n + k)) (suc n) | gte .n k = gte (suc n) k\n\n -- Core lemmas\n\n lz-lem : ∀ a b c → a + b < a + c → b < c\n lz-lem zero b c p = p\n lz-lem (suc a) b c p = lz-lem a b c (Nat.+-cancelˡ-≤ 1 p)\n\n lz-lem₂ : ∀ a b → a < a + b → 0 < b\n lz-lem₂ zero b p = p\n lz-lem₂ (suc a) b p = lz-lem₂ a b (Nat.+-cancelˡ-≤ 1 p)\n\n fromℕ≤-cong′ : ∀ {a b m n} {p : a < m} {q : b < n} → m ≡ n → a ≡ b → fromℕ≤ {a} p ≅ fromℕ≤ {b} q\n fromℕ≤-cong′ {p = Nat.s≤s Nat.z≤n} {Nat.s≤s Nat.z≤n} ≡.refl ≡.refl = ≅.refl\n fromℕ≤-cong′ {p = Nat.s≤s (Nat.s≤s p)} {Nat.s≤s (Nat.s≤s q)} ≡.refl ≡.refl = ≅.cong suc (fromℕ≤-cong′ {p = Nat.s≤s p} {q = Nat.s≤s q} ≡.refl ≡.refl)\n\n fromℕ≤-cong : ∀ {a b n} {p : a < n} {q : b < n} → a ≡ b → fromℕ≤ {a} p ≡ fromℕ≤ {b} q\n fromℕ≤-cong = ≅.≅-to-≡ ∘ fromℕ≤-cong′ ≡.refl\n\n -- Core functions\n\n fromParts : {numParts : ℕ} (parts : Table ℕ numParts) → ℕ × ℕ → ℕ\n fromParts parts (zero , j) = j\n fromParts {zero} parts (suc i , j) = 0\n fromParts {suc numParts} parts (suc i , j) = lookup parts zero + fromParts (tail parts) (i , j)\n\n toParts : {numParts : ℕ} (parts : Table ℕ numParts) (k : ℕ) → ℕ × ℕ\n toParts {zero} parts k = 0 , 0\n toParts {suc n} parts k with lookup parts zero | compare′ k (lookup parts zero)\n toParts {suc n} parts k | .(suc (k + k₁)) | less .k k₁ = 0 , k\n toParts {suc n} parts .(lz + k) | lz | gte .lz k =\n let i , j = toParts (tail parts) k\n in (suc i , j)\n\n -- Property lemmas\n\n +-<-lem : ∀ {a b c} → b < c → a + b < a + c\n +-<-lem {zero} p = p\n +-<-lem {suc a} p = Nat.s≤s (+-<-lem p)\n\n fromℕ-suc-lem : ∀ {m n} (p : m < n) → suc (fromℕ≤ p) ≡ fromℕ≤ (Nat.s≤s p)\n fromℕ-suc-lem (Nat.s≤s p) = ≡.refl\n\n -- Properties\n\n fromParts-prop : ∀ {numParts} (parts : Table ℕ numParts) {i j} → i < numParts → j < tryLookup 0 parts i → fromParts parts (i , j) < sum parts\n fromParts-prop {suc numParts} _ {zero} (Nat.s≤s p) q = Nat.≤-trans q (Nat.m≤m+n _ _)\n fromParts-prop {suc numParts} parts {suc i} (Nat.s≤s p) q = +-<-lem (fromParts-prop (tail parts) p q)\n\n toParts-prop : ∀ {numParts : ℕ} (parts : Table ℕ numParts) {k} → k < sum parts →\n let i , j = toParts parts k\n in Σ (i < numParts) (λ q → j < lookup parts (fromℕ≤ {i} q))\n toParts-prop {zero} parts {k} ()\n toParts-prop {suc numParts} parts {k} p with lookup parts zero | compare′ k (lookup parts zero) | ≡.inspect (lookup parts) zero\n toParts-prop {suc numParts} parts {k} p | .(suc (k + k₁)) | less .k k₁ | ≡.[ eq ] =\n Nat.s≤s Nat.z≤n ,\n Nat.≤-trans (Nat.s≤s (Nat.m≤m+n _ _)) (Nat.≤-reflexive (≡.sym eq))\n toParts-prop {suc numParts} parts {.(lz + k)} p | lz | gte .lz k | insp =\n let q , r = toParts-prop (tail parts) {k} (lz-lem _ _ _ p)\n in Nat.s≤s q , Nat.≤-trans r (Nat.≤-reflexive (≡.cong (lookup parts) (fromℕ-suc-lem _)))\n\n toParts-fromParts :\n {numParts : ℕ} (parts : Table ℕ numParts) (i j : ℕ) (p : j < tryLookup 0 parts i) →\n toParts parts (fromParts parts (i , j)) ≡ (i , j)\n toParts-fromParts {zero} _ i j ()\n toParts-fromParts {suc numParts} parts i j p\n with lookup parts zero\n | fromParts parts (i , j)\n | compare′ (fromParts parts (i , j)) (lookup parts zero)\n | ≡.inspect (lookup parts) zero\n | ≡.inspect (fromParts parts) (i , j)\n toParts-fromParts {suc numParts} parts zero .ipi p\n | .(suc (ipi + k)) | ipi | less .ipi k | insp₁ | ≡.[ ≡.refl ]\n = ≡.refl\n toParts-fromParts {suc numParts} parts zero .(lookup parts zero + k) p\n | .(lookup parts zero) | .(lookup parts zero + k) | gte .(lookup parts zero) k | ≡.[ ≡.refl ] | ≡.[ ≡.refl ]\n = ⊥-elim (Nat.n≮n _ (Nat.≤-trans p (Nat.m≤m+n _ k)))\n toParts-fromParts {suc numParts} parts (suc i) j p\n | .(suc (ipi + k)) | ipi | less .ipi k | ≡.[ eq ] | ≡.[ eq₁ ]\n = let y = lookup parts zero\n z = fromParts _ (i , j)\n in ⊥-elim (Nat.m≢1+m+n y {z + k} (\n begin\n y ≡⟨ eq ⟩\n suc (ipi + k) ≡⟨ ≡.cong (λ h → suc (h + k)) (≡.sym eq₁) ⟩\n suc ((y + z) + k) ≡⟨ ≡.cong suc (Nat.+-assoc y z k) ⟩\n suc (y + (z + k)) ∎))\n where open ≡.Reasoning\n toParts-fromParts {suc numParts} parts (suc i) j p\n | .(lookup parts zero) | .(lookup parts zero + k) | gte .(lookup parts zero) k | ≡.[ ≡.refl ] | ≡.[ eq₁ ]\n with Nat.+-cancelˡ-≡ (lookup parts zero) eq₁\n toParts-fromParts {suc numParts} parts (suc i) j p\n | .(lookup parts zero) | .(lookup parts zero + k) | gte .(lookup parts zero) k | ≡.[ ≡.refl ] | ≡.[ eq₁ ]\n | eq₂ rewrite ≡.sym eq₂\n = let q , r = Σ.≡⇒Pointwise-≡ (toParts-fromParts (tail parts) i j p)\n in Σ.Pointwise-≡⇒≡ (≡.cong suc q , r)\n\n fromParts-toParts : {numParts : ℕ} (parts : Table ℕ numParts) (k : ℕ) (p : k < sum parts) → fromParts parts (toParts parts k) ≡ k\n fromParts-toParts {zero} parts k ()\n fromParts-toParts {suc numParts} parts k p\n with lookup parts zero\n | compare′ k (lookup parts zero)\n | ≡.inspect (lookup parts) zero\n fromParts-toParts {suc numParts} parts k p | .(suc (k + k₁)) | less .k k₁ | insp = ≡.refl\n fromParts-toParts {suc numParts} parts .(lookup parts zero + k) p | .(lookup parts zero) | gte .(lookup parts zero) k | ≡.[ ≡.refl ]\n = ≡.cong₂ Nat._+_\n ≡.refl\n (fromParts-toParts (tail parts) k\n (Nat.+-cancelˡ-≤ (lookup parts zero) (Nat.≤-trans (Nat.≤-reflexive (Nat.+-suc _ k)) p)))\n\n\nmodule Partsℕ {a} {A : Set a} {size : A → ℕ} (P : Parts A size) where\n open Parts P public\n\n fromParts : ℕ × ℕ → ℕ\n fromParts = Impl.fromParts partsizes\n\n toParts : ℕ → ℕ × ℕ\n toParts = Impl.toParts partsizes\n\n private\n tryLookup-lem : ∀ {i j} (p : i < numParts) → j < sizeAt (Fin.fromℕ≤ p) → j < Impl.tryLookup 0 partsizes i\n tryLookup-lem p q = Nat.≤-trans q (Nat.≤-reflexive (≡.trans (Impl.tryLookup-prop {z = 0} partsizes) (≡.cong (Impl.tryLookup 0 partsizes) (Fin.toℕ-fromℕ≤ _))))\n\n fromParts-prop : ∀ {i j} (p : i < numParts) → j < sizeAt (Fin.fromℕ≤ p) → fromParts (i , j) < totalSize\n fromParts-prop p = Impl.fromParts-prop _ p ∘ tryLookup-lem p\n\n toParts-prop : ∀ {k} → k < totalSize →\n let i , j = toParts k\n in Σ (i < numParts) (λ q → j < lookup partsizes (fromℕ≤ q))\n toParts-prop = Impl.toParts-prop _\n\n abstract\n toParts-fromParts : ∀ {i j} (p : i < numParts) (q : j < sizeAt (Fin.fromℕ≤ p)) → toParts (fromParts (i , j)) ≡ (i , j)\n toParts-fromParts p = Impl.toParts-fromParts partsizes _ _ ∘ tryLookup-lem p\n\n fromParts-toParts : ∀ k (p : k < totalSize) → fromParts (toParts k) ≡ k\n fromParts-toParts = Impl.fromParts-toParts partsizes\n", "meta": {"hexsha": "632792cbb1c867dbd4f1be932c682d75b703d6bb", "size": 7501, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/MLib/Fin/Parts/Nat.agda", "max_stars_repo_name": "bch29/agda-matrices", "max_stars_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/MLib/Fin/Parts/Nat.agda", "max_issues_repo_name": "bch29/agda-matrices", "max_issues_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/MLib/Fin/Parts/Nat.agda", "max_forks_repo_name": "bch29/agda-matrices", "max_forks_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.6488095238, "max_line_length": 162, "alphanum_fraction": 0.5663244901, "num_tokens": 3116, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637541053281, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.6067378119417512}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Decidable equality over lists using propositional equality\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality\n\nmodule Data.List.Relation.Binary.Equality.DecPropositional\n {a} {A : Set a} (_≟_ : Decidable {A = A} _≡_) where\n\nopen import Data.List using (List)\nopen import Data.List.Properties using (≡-dec)\nimport Data.List.Relation.Binary.Equality.Propositional as PropositionalEq\nimport Data.List.Relation.Binary.Equality.DecSetoid as DecSetoidEq\n\n------------------------------------------------------------------------\n-- Publically re-export everything from decSetoid and propositional\n-- equality\n\nopen PropositionalEq public\nopen DecSetoidEq (decSetoid _≟_) public\n using (_≋?_; ≋-isDecEquivalence; ≋-decSetoid)\n\n------------------------------------------------------------------------\n-- Additional proofs\n\n_≡?_ : Decidable (_≡_ {A = List A})\n_≡?_ = ≡-dec _≟_\n", "meta": {"hexsha": "356f35de9dfb571d773b8a82a0a66d778eee87ae", "size": 1114, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Equality/DecPropositional.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Equality/DecPropositional.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Equality/DecPropositional.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.7575757576, "max_line_length": 74, "alphanum_fraction": 0.5592459605, "num_tokens": 239, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8596637505099168, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.6067378094041638}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Fragment.Examples.Semigroup.Arith.Functions where\n\nopen import Fragment.Examples.Semigroup.Arith.Base\n\n-- Fully dynamic associativity\n\n+-dyn-assoc₁ : ∀ {f : ℕ → ℕ} {m n o} → (f m + n) + o ≡ f m + (n + o)\n+-dyn-assoc₁ = fragment SemigroupFrex +-semigroup\n\n+-dyn-assoc₂ : ∀ {f g : ℕ → ℕ} {m n o p} → ((f m + n) + o) + g p ≡ f m + (n + (o + g p))\n+-dyn-assoc₂ = fragment SemigroupFrex +-semigroup\n\n+-dyn-assoc₃ : ∀ {f g h : ℕ → ℕ} {m n o p q} → (f m + n) + g o + (p + h q) ≡ f m + (n + g o + p) + h q\n+-dyn-assoc₃ = fragment SemigroupFrex +-semigroup\n\n*-dyn-assoc₁ : ∀ {f : ℕ → ℕ} {m n o} → (f m * n) * o ≡ f m * (n * o)\n*-dyn-assoc₁ = fragment SemigroupFrex *-semigroup\n\n*-dyn-assoc₂ : ∀ {f g : ℕ → ℕ} {m n o p} → ((f m * n) * o) * g p ≡ f m * (n * (o * g p))\n*-dyn-assoc₂ = fragment SemigroupFrex *-semigroup\n\n*-dyn-assoc₃ : ∀ {f g h : ℕ → ℕ} {m n o p q} → (f m * n) * g o * (p * h q) ≡ f m * (n * g o * p) * h q\n*-dyn-assoc₃ = fragment SemigroupFrex *-semigroup\n\n-- Partially static associativity\n\n+-sta-assoc₁ : ∀ {f : ℕ → ℕ} {m} → (m + 2) + (3 + f 0) ≡ m + (5 + f 0)\n+-sta-assoc₁ = fragment SemigroupFrex +-semigroup\n\n+-sta-assoc₂ : ∀ {f g : ℕ → ℕ} {m n o p} → (((f m + g n) + 5) + o) + p ≡ f m + (g n + (2 + (3 + (o + p))))\n+-sta-assoc₂ = fragment SemigroupFrex +-semigroup\n\n+-sta-assoc₃ : ∀ {f : ℕ → ℕ} {m n o p} → f (n + m) + (n + 2) + (3 + (o + p)) ≡ f (n + m) + (((n + 1) + (4 + o)) + p)\n+-sta-assoc₃ = fragment SemigroupFrex +-semigroup\n\n*-sta-assoc₁ : ∀ {f : ℕ → ℕ} {m} → (m * 2) * (3 * f 0) ≡ m * (6 * f 0)\n*-sta-assoc₁ = fragment SemigroupFrex *-semigroup\n\n*-sta-assoc₂ : ∀ {f g : ℕ → ℕ} {m n o p} → (((f m * g n) * 6) * o) * p ≡ f m * (g n * (2 * (3 * (o * p))))\n*-sta-assoc₂ = fragment SemigroupFrex *-semigroup\n\n*-sta-assoc₃ : ∀ {f : ℕ → ℕ} {m n o p} → f (n + m) * (n * 4) * (3 * (o * p)) ≡ f (n + m) * (((n * 2) * (6 * o)) * p)\n*-sta-assoc₃ = fragment SemigroupFrex *-semigroup\n", "meta": {"hexsha": "dbe8368a033566bff61aa0e9b63359ee3f9430fa", "size": 1936, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Fragment/Examples/Semigroup/Arith/Functions.agda", "max_stars_repo_name": "yallop/agda-fragment", "max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 18, "max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z", "max_issues_repo_path": "src/Fragment/Examples/Semigroup/Arith/Functions.agda", "max_issues_repo_name": "yallop/agda-fragment", "max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z", "max_forks_repo_path": "src/Fragment/Examples/Semigroup/Arith/Functions.agda", "max_forks_repo_name": "yallop/agda-fragment", "max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z", "avg_line_length": 42.0869565217, "max_line_length": 116, "alphanum_fraction": 0.5061983471, "num_tokens": 862, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637505099167, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.6067378094041637}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Examples showing how the reflective ring solver may be used.\n------------------------------------------------------------------------\n\nmodule README.Tactic.RingSolver where\n\n-- You can ignore this bit! We're just overloading the literals Agda uses for\n-- numbers. This bit isn't necessary if you're just using Nats, or if you\n-- construct your type directly. We only really do it here so that we can use\n-- different numeric types in the same file.\n\nopen import Agda.Builtin.FromNat\nopen import Data.Nat using (ℕ)\nopen import Data.Integer using (ℤ)\nimport Data.Nat.Literals as ℕ\nimport Data.Integer.Literals as ℤ\n\ninstance\n numberNat : Number ℕ\n numberNat = ℕ.number\n\ninstance\n numberInt : Number ℤ\n numberInt = ℤ.number\n\n------------------------------------------------------------------------------\n-- Imports!\n\nopen import Data.List as List using (List; _∷_; [])\nopen import Function\nopen import Relation.Binary.PropositionalEquality as ≡\n using (subst; _≡_; module ≡-Reasoning)\nopen import Data.Bool as Bool using (Bool; true; false; if_then_else_)\nopen import Data.Unit using (⊤; tt)\n\nopen import Tactic.RingSolver.Core.AlmostCommutativeRing using (AlmostCommutativeRing)\n\n------------------------------------------------------------------------------\n-- Integer examples\n------------------------------------------------------------------------------\n\nmodule IntegerExamples where\n open import Data.Integer.Tactic.RingSolver\n\n open AlmostCommutativeRing ring\n\n -- Everything is automatic: you just ask Agda to solve it and it does!\n lemma₁ : ∀ x y → x + y * 1 + 3 ≈ 3 + 1 + y + x + - 1\n lemma₁ = solve-∀\n\n lemma₂ : ∀ x y → (x + y) ^ 2 ≈ x ^ 2 + 2 * x * y + y ^ 2\n lemma₂ = solve-∀\n\n -- It can interact with manual proofs as well.\n lemma₃ : ∀ x y → x + y * 1 + 3 ≈ 2 + 1 + y + x\n lemma₃ x y = begin\n x + y * 1 + 3 ≡⟨ +-comm x (y * 1) ⟨ +-cong ⟩ refl ⟩\n y * 1 + x + 3 ≡⟨ solve (x ∷ y ∷ []) ⟩\n 3 + y + x ≡⟨⟩\n 2 + 1 + y + x ∎\n where open ≡-Reasoning\n\n------------------------------------------------------------------------------\n-- Natural examples\n------------------------------------------------------------------------------\n\nmodule NaturalExamples where\n open import Data.Nat.Tactic.RingSolver\n\n open AlmostCommutativeRing ring\n\n -- The solver is flexible enough to work with ℕ (even though it asks\n -- for rings!)\n lemma₁ : ∀ x y → x + y * 1 + 3 ≈ 2 + 1 + y + x\n lemma₁ = solve-∀\n\n------------------------------------------------------------------------------\n-- Checking invariants\n------------------------------------------------------------------------------\n-- The solver makes it easy to prove invariants, without having to rewrite\n-- proof code every time something changes in the data structure.\n\nmodule _ {a} {A : Set a} (_≤_ : A → A → Bool) where\n open import Data.Nat.Tactic.RingSolver\n open AlmostCommutativeRing ring\n\n -- A Skew Heap, indexed by its size.\n data Tree : ℕ → Set a where\n leaf : Tree 0\n node : ∀ {n m} → A → Tree n → Tree m → Tree (1 + n + m)\n\n -- A substitution operator, to clean things up.\n infixr 1 _⇒_\n _⇒_ : ∀ {n} → Tree n → ∀ {m} → n ≈ m → Tree m\n x ⇒ n≈m = subst Tree n≈m x\n\n open ≡-Reasoning\n\n _∪_ : ∀ {n m} → Tree n → Tree m → Tree (n + m)\n leaf ∪ ys = ys\n node {a} {b} x xl xr ∪ leaf =\n node x xl xr ⇒ solve (a ∷ b ∷ [])\n node {a} {b} x xl xr ∪ node {c} {d} y yl yr =\n if x ≤ y\n then node x (node y yl yr ∪ xr) xl ⇒ begin\n 1 + (1 + c + d + b) + a ≡⟨ solve (a ∷ b ∷ c ∷ d ∷ []) ⟩\n 1 + a + b + (1 + c + d) ∎\n else node y (node x xl xr ∪ yr) yl ⇒ begin\n 1 + (1 + a + b + d) + c ≡⟨ solve (a ∷ b ∷ c ∷ d ∷ []) ⟩\n 1 + a + b + (1 + c + d) ∎\n", "meta": {"hexsha": "333e51c26acd622199c10dae5ed80ee4ee06cac5", "size": 3854, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/README/Tactic/RingSolver.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/README/Tactic/RingSolver.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/README/Tactic/RingSolver.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 34.1061946903, "max_line_length": 86, "alphanum_fraction": 0.493513233, "num_tokens": 1111, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677699040321, "lm_q2_score": 0.7154240079185319, "lm_q1q2_score": 0.6066565005304821}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties of operations on machine words\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Word.Properties where\n\nimport Data.Nat.Base as ℕ\nopen import Data.Bool.Base using (Bool)\nopen import Data.Word.Base\nimport Data.Nat.Properties as ℕₚ\nopen import Function\nopen import Relation.Nullary.Decidable using (map′; ⌊_⌋)\nopen import Relation.Binary\n using ( _⇒_; Reflexive; Symmetric; Transitive; Substitutive\n ; Decidable; DecidableEquality; IsEquivalence; IsDecEquivalence\n ; Setoid; DecSetoid; StrictTotalOrder)\nimport Relation.Binary.Construct.On as On\nopen import Relation.Binary.PropositionalEquality\n\n------------------------------------------------------------------------\n-- Primitive properties\n\nopen import Agda.Builtin.Word.Properties\n renaming (primWord64ToNatInjective to toℕ-injective)\n public\n\n------------------------------------------------------------------------\n-- Properties of _≈_\n\n≈⇒≡ : _≈_ ⇒ _≡_\n≈⇒≡ = toℕ-injective _ _\n\n≈-reflexive : _≡_ ⇒ _≈_\n≈-reflexive = cong toℕ\n\n≈-refl : Reflexive _≈_\n≈-refl = refl\n\n≈-sym : Symmetric _≈_\n≈-sym = sym\n\n≈-trans : Transitive _≈_\n≈-trans = trans\n\n≈-subst : ∀ {ℓ} → Substitutive _≈_ ℓ\n≈-subst P x≈y p = subst P (≈⇒≡ x≈y) p\n\ninfix 4 _≈?_\n_≈?_ : Decidable _≈_\nx ≈? y = toℕ x ℕₚ.≟ toℕ y\n\n≈-isEquivalence : IsEquivalence _≈_\n≈-isEquivalence = record\n { refl = λ {i} → ≈-refl {i}\n ; sym = λ {i j} → ≈-sym {i} {j}\n ; trans = λ {i j k} → ≈-trans {i} {j} {k}\n }\n\n≈-setoid : Setoid _ _\n≈-setoid = record\n { isEquivalence = ≈-isEquivalence\n }\n\n≈-isDecEquivalence : IsDecEquivalence _≈_\n≈-isDecEquivalence = record\n { isEquivalence = ≈-isEquivalence\n ; _≟_ = _≈?_\n }\n\n≈-decSetoid : DecSetoid _ _\n≈-decSetoid = record\n { isDecEquivalence = ≈-isDecEquivalence\n }\n------------------------------------------------------------------------\n-- Properties of _≡_\n\ninfix 4 _≟_\n_≟_ : DecidableEquality Word64\nx ≟ y = map′ ≈⇒≡ ≈-reflexive (x ≈? y)\n\n≡-setoid : Setoid _ _\n≡-setoid = setoid Word64\n\n≡-decSetoid : DecSetoid _ _\n≡-decSetoid = decSetoid _≟_\n\n------------------------------------------------------------------------\n-- Boolean equality test.\n\ninfix 4 _==_\n_==_ : Word64 → Word64 → Bool\nw₁ == w₂ = ⌊ w₁ ≟ w₂ ⌋\n\n------------------------------------------------------------------------\n-- Properties of _<_\n\ninfix 4 _>=_\n\n _>>=_ : ∀{i A B} (m : IO I i A) (k : A → IO I i B) → IO I i B\n force (m >>= k) with force m\n ... | do' c f = do' c λ x → f x >>= k\n ... | return' a = force (k a)\n\n\n {-# NON_TERMINATING #-}\n translateIO : ∀ {A} (tr : (c : C) → NativeIO (R c)) → IO I ∞ A → NativeIO A\n translateIO tr m = case (force m) of λ\n { (do' c f) → (tr c) native>>= λ r → translateIO tr (f r)\n ; (return' a) → nativeReturn a\n }\n\n\n{- Specific case of Console IO -}\n\ndata ConsoleCommand : Set where\n getLine : ConsoleCommand\n putStrLn : String → ConsoleCommand\n\nConsoleResponse : ConsoleCommand → Set\nConsoleResponse getLine = String\nConsoleResponse (putStrLn s) = Unit\n\nConsoleInterface : IOInterface\nCommand ConsoleInterface = ConsoleCommand\nResponse ConsoleInterface = ConsoleResponse\n\nIOConsole : (i : Size) → Set → Set\nIOConsole i = IO ConsoleInterface i\n\ntranslateIOConsoleLocal : (c : ConsoleCommand) → NativeIO (ConsoleResponse c)\ntranslateIOConsoleLocal (putStrLn s) = nativePutStrLn s\ntranslateIOConsoleLocal getLine = nativeGetLine\n\ntranslateIOConsole : {A : Set} → IOConsole ∞ A → NativeIO A\ntranslateIOConsole = translateIO translateIOConsoleLocal\n\ncat : ∀ {i} → IOConsole i Unit\nforce cat = do' getLine λ line → \n do (putStrLn line) λ _ →\n cat\n\n\nmain : NativeIO Unit\nmain = translateIOConsole cat\n\n", "meta": {"hexsha": "88da970a531e4e19e0d76496dad8935c06ef960a", "size": 2242, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/interactiveProgramsAgda.agda", "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 23, "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_issues_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/interactiveProgramsAgda.agda", "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/interactiveProgramsAgda.agda", "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "avg_line_length": 27.0120481928, "max_line_length": 77, "alphanum_fraction": 0.6132917038, "num_tokens": 715, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8887588023318196, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.6066434146994547}} {"text": "\nmodule IsPropositionalFormula where\n\nopen import OscarPrelude\nopen import Formula\nopen import Term\nopen import PredicateName\nopen import HasNeitherNor\n\n\ndata IsPropositionalFormula : Formula → Set\n where\n atomic : (𝑃 : PredicateName) → (τs : Terms) → IsPropositionalFormula $ 𝑃[ 𝑃 ♭ τs ]\n logical : {φ₁ : Formula} → IsPropositionalFormula φ₁ → {φ₂ : Formula} → IsPropositionalFormula φ₂ → IsPropositionalFormula (φ₁ ⊗ φ₂)\n\ninstance EqIsPropositionalFormula : ∀ {φ} → Eq (IsPropositionalFormula φ)\nEq._==_ EqIsPropositionalFormula (atomic _ _) (atomic _ _ ) = yes refl\nEq._==_ EqIsPropositionalFormula (logical φ₁₁ φ₁₂) (logical φ₂₁ φ₂₂) with φ₁₁ ≟ φ₂₁ | φ₁₂ ≟ φ₂₂\nEq._==_ EqIsPropositionalFormula (logical φ₁₁ φ₁₂) (logical φ₂₁ φ₂₂) | yes refl | yes refl = yes refl\nEq._==_ EqIsPropositionalFormula (logical φ₁₁ φ₁₂) (logical φ₂₁ φ₂₂) | yes refl | no φ₁₂≢φ₂₂ = no λ {refl → φ₁₂≢φ₂₂ refl}\nEq._==_ EqIsPropositionalFormula (logical φ₁₁ φ₁₂) (logical φ₂₁ φ₂₂) | no φ₁₁≢φ₂₁ | _ = no λ {refl → φ₁₁≢φ₂₁ refl}\n\n{-\n-- need to use coinduction to prove this\nfoo : ¬ ∃ λ φ → ∃ λ (p₁ : IsPropositionalFormula φ) → ∃ λ (p₂ : IsPropositionalFormula φ) → p₁ ≢ p₂\nfoo (atomic x x₁ , atomic .x .x₁ , atomic .x .x₁ , snd₁) = snd₁ refl\nfoo (logical fst₁ fst₂ , logical fst₃ fst₄ , logical fst₅ fst₆ , snd₁) with fst₃ ≟ fst₅ | fst₄ ≟ fst₆\nfoo (logical fst₁ fst₂ , logical fst₃ fst₄ , logical .fst₃ .fst₄ , snd₁) | yes refl | (yes refl) = snd₁ refl\nfoo (logical fst₁ fst₂ , logical fst₃ fst₄ , logical .fst₃ fst₆ , snd₁) | yes refl | (no x₁) = foo (fst₂ , fst₄ , fst₆ , λ xs → x₁ xs)\nfoo (logical fst₁ fst₂ , logical fst₃ fst₄ , logical fst₅ fst₆ , snd₁) | no x | (yes x₁) = {!!}\nfoo (logical fst₁ fst₂ , logical fst₃ fst₄ , logical fst₅ fst₆ , snd₁) | no x | (no x₁) = {!!}\nfoo (quantified x fst₁ , () , fst₃ , snd₁)\n-}\n", "meta": {"hexsha": "71abb2a1cb68493b5eb98e5bfa23f962083238ce", "size": 1803, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-1/IsPropositionalFormula.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-1/IsPropositionalFormula.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-1/IsPropositionalFormula.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.0294117647, "max_line_length": 134, "alphanum_fraction": 0.6960621187, "num_tokens": 705, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757869916479466, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.6066068386986383}} {"text": "{-# OPTIONS --cubical --safe #-}\nmodule Algebra where\n\nopen import Prelude\n\nmodule _ {a} {A : Type a} (_∙_ : A → A → A) where\n Associative : Type a\n Associative = ∀ x y z → (x ∙ y) ∙ z ≡ x ∙ (y ∙ z)\n\n Commutative : Type _\n Commutative = ∀ x y → x ∙ y ≡ y ∙ x\n\n Idempotent : Type _\n Idempotent = ∀ x → x ∙ x ≡ x\n\nIdentityˡ : (A → B → B) → A → Type _\nIdentityˡ _∙_ x = ∀ y → x ∙ y ≡ y\n\nZeroˡ : (A → B → A) → A → Type _\nZeroˡ _∙_ x = ∀ y → x ∙ y ≡ x\n\nZeroʳ : (A → B → B) → B → Type _\nZeroʳ _∙_ x = ∀ y → y ∙ x ≡ x\n\nIdentityʳ : (A → B → A) → B → Type _\nIdentityʳ _∙_ x = ∀ y → y ∙ x ≡ y\n\n_Distributesʳ_ : (A → B → B) → (B → B → B) → Type _\n_⊗_ Distributesʳ _⊕_ = ∀ x y z → x ⊗ (y ⊕ z) ≡ (x ⊗ y) ⊕ (x ⊗ z)\n\n_Distributesˡ_ : (B → A → B) → (B → B → B) → Type _\n_⊗_ Distributesˡ _⊕_ = ∀ x y z → (x ⊕ y) ⊗ z ≡ (x ⊗ z) ⊕ (y ⊗ z)\n\nCancellableˡ : (A → B → C) → A → Type _\nCancellableˡ _⊗_ c = ∀ x y → c ⊗ x ≡ c ⊗ y → x ≡ y\n\nCancellableʳ : (A → B → C) → B → Type _\nCancellableʳ _⊗_ c = ∀ x y → x ⊗ c ≡ y ⊗ c → x ≡ y\n\nCancellativeˡ : (A → B → C) → Type _\nCancellativeˡ _⊗_ = ∀ c → Cancellableˡ _⊗_ c\n\nCancellativeʳ : (A → B → C) → Type _\nCancellativeʳ _⊗_ = ∀ c → Cancellableʳ _⊗_ c\n\nrecord Semigroup ℓ : Type (ℓsuc ℓ) where\n infixl 6 _∙_\n field\n 𝑆 : Type ℓ\n _∙_ : 𝑆 → 𝑆 → 𝑆\n assoc : ∀ x y z → (x ∙ y) ∙ z ≡ x ∙ (y ∙ z)\n\nrecord Monoid ℓ : Type (ℓsuc ℓ) where\n infixl 6 _∙_\n field\n 𝑆 : Type ℓ\n _∙_ : 𝑆 → 𝑆 → 𝑆\n ε : 𝑆\n assoc : ∀ x y z → (x ∙ y) ∙ z ≡ x ∙ (y ∙ z)\n ε∙ : ∀ x → ε ∙ x ≡ x\n ∙ε : ∀ x → x ∙ ε ≡ x\n\n semigroup : Semigroup ℓ\n semigroup = record\n { 𝑆 = 𝑆; _∙_ = _∙_; assoc = assoc }\n\nrecord MonoidHomomorphism_⟶_\n {ℓ₁ ℓ₂}\n (from : Monoid ℓ₁)\n (to : Monoid ℓ₂)\n : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where\n open Monoid from\n open Monoid to\n renaming ( 𝑆 to 𝑅\n ; _∙_ to _⊙_\n ; ε to ⓔ\n )\n field\n f : 𝑆 → 𝑅\n ∙-homo : ∀ x y → f (x ∙ y) ≡ f x ⊙ f y\n ε-homo : f ε ≡ ⓔ\n\nrecord Group ℓ : Type (ℓsuc ℓ) where\n field\n monoid : Monoid ℓ\n open Monoid monoid public\n field\n -_ : 𝑆 → 𝑆\n ∙⁻ : ∀ x → x ∙ - x ≡ ε\n ⁻∙ : ∀ x → - x ∙ x ≡ ε\n\n open import Path.Reasoning\n\n cancelˡ : Cancellativeˡ _∙_\n cancelˡ x y z p =\n y ≡˘⟨ ε∙ y ⟩\n ε ∙ y ≡˘⟨ cong (_∙ y) (⁻∙ x) ⟩\n (- x ∙ x) ∙ y ≡⟨ assoc (- x) x y ⟩\n - x ∙ (x ∙ y) ≡⟨ cong (- x ∙_) p ⟩\n - x ∙ (x ∙ z) ≡˘⟨ assoc (- x) x z ⟩\n (- x ∙ x) ∙ z ≡⟨ cong (_∙ z) (⁻∙ x) ⟩\n ε ∙ z ≡⟨ ε∙ z ⟩\n z ∎\n\n cancelʳ : Cancellativeʳ _∙_\n cancelʳ x y z p =\n y ≡˘⟨ ∙ε y ⟩\n y ∙ ε ≡˘⟨ cong (y ∙_) (∙⁻ x) ⟩\n y ∙ (x ∙ - x) ≡˘⟨ assoc y x (- x) ⟩\n (y ∙ x) ∙ - x ≡⟨ cong (_∙ - x) p ⟩\n (z ∙ x) ∙ - x ≡⟨ assoc z x (- x) ⟩\n z ∙ (x ∙ - x) ≡⟨ cong (z ∙_) (∙⁻ x) ⟩\n z ∙ ε ≡⟨ ∙ε z ⟩\n z ∎\n\nrecord CommutativeMonoid ℓ : Type (ℓsuc ℓ) where\n field\n monoid : Monoid ℓ\n open Monoid monoid public\n field\n comm : Commutative _∙_\n\nrecord Semilattice ℓ : Type (ℓsuc ℓ) where\n field\n commutativeMonoid : CommutativeMonoid ℓ\n open CommutativeMonoid commutativeMonoid public\n field\n idem : Idempotent _∙_\n\nrecord NearSemiring ℓ : Type (ℓsuc ℓ) where\n infixl 6 _+_\n infixl 7 _*_\n field\n 𝑅 : Type ℓ\n _+_ : 𝑅 → 𝑅 → 𝑅\n _*_ : 𝑅 → 𝑅 → 𝑅\n 1# : 𝑅\n 0# : 𝑅\n +-assoc : Associative _+_\n *-assoc : Associative _*_\n 0+ : Identityˡ _+_ 0#\n +0 : Identityʳ _+_ 0#\n 1* : Identityˡ _*_ 1#\n *1 : Identityʳ _*_ 1#\n 0* : Zeroˡ _*_ 0#\n ⟨+⟩* : _*_ Distributesˡ _+_\n\nrecord Semiring ℓ : Type (ℓsuc ℓ) where\n field\n nearSemiring : NearSemiring ℓ\n open NearSemiring nearSemiring public\n field\n +-comm : Commutative _+_\n *0 : Zeroʳ _*_ 0#\n *⟨+⟩ : _*_ Distributesʳ _+_\n\nrecord IdempotentSemiring ℓ : Type (ℓsuc ℓ) where\n field\n semiring : Semiring ℓ\n open Semiring semiring public\n field\n +-idem : Idempotent _+_\n\n\nrecord CommutativeSemiring ℓ : Type (ℓsuc ℓ) where\n field\n semiring : Semiring ℓ\n open Semiring semiring public\n field\n *-comm : Commutative _*_\n\nrecord LeftSemimodule {ℓ₁} (semiring : Semiring ℓ₁) ℓ₂ : Type (ℓ₁ ℓ⊔ ℓsuc ℓ₂) where\n open Semiring semiring public\n field\n semimodule : CommutativeMonoid ℓ₂\n open CommutativeMonoid semimodule renaming (_∙_ to _∪_) public\n renaming (𝑆 to 𝑉\n ; assoc to ∪-assoc\n ; ε∙ to ∅∪\n ; ∙ε to ∪∅\n ; ε to ∅\n )\n infixr 7 _⋊_\n field\n _⋊_ : 𝑅 → 𝑉 → 𝑉\n ⟨*⟩⋊ : ∀ x y z → (x * y) ⋊ z ≡ x ⋊ (y ⋊ z)\n ⟨+⟩⋊ : ∀ x y z → (x + y) ⋊ z ≡ (x ⋊ z) ∪ (y ⋊ z)\n ⋊⟨∪⟩ : _⋊_ Distributesʳ _∪_\n 1⋊ : Identityˡ _⋊_ 1#\n 0⋊ : ∀ x → 0# ⋊ x ≡ ∅\n ⋊∅ : ∀ x → x ⋊ ∅ ≡ ∅\n\nrecord SemimoduleHomomorphism[_]_⟶_\n {ℓ₁ ℓ₂ ℓ₃}\n (rng : Semiring ℓ₁)\n (from : LeftSemimodule rng ℓ₂)\n (to : LeftSemimodule rng ℓ₃) : Type (ℓ₁ ℓ⊔ ℓsuc (ℓ₂ ℓ⊔ ℓ₃)) where\n\n open Semiring rng\n open LeftSemimodule from using (_⋊_; monoid)\n open LeftSemimodule to using () renaming (_⋊_ to _⋊′_; monoid to monoid′)\n\n field mon-homo : MonoidHomomorphism monoid ⟶ monoid′\n\n open MonoidHomomorphism_⟶_ mon-homo public\n\n field ⋊-homo : ∀ r x → f (r ⋊ x) ≡ r ⋊′ f x\n\nrecord StarSemiring ℓ : Type (ℓsuc ℓ) where\n field\n semiring : Semiring ℓ\n open Semiring semiring public\n field\n _⋆ : 𝑅 → 𝑅\n star-iterʳ : ∀ x → x ⋆ ≡ 1# + x * x ⋆\n star-iterˡ : ∀ x → x ⋆ ≡ 1# + x ⋆ * x\n _⁺ : 𝑅 → 𝑅\n x ⁺ = x * x ⋆\n\nrecord Functor ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where\n field\n 𝐹 : Type ℓ₁ → Type ℓ₂\n map : (A → B) → 𝐹 A → 𝐹 B\n map-id : map (id {ℓ₁} {A}) ≡ id\n map-comp : (f : B → C) → (g : A → B) → map (f ∘ g) ≡ map f ∘ map g\n\nrecord Applicative ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where\n field\n functor : Functor ℓ₁ ℓ₂\n open Functor functor public\n infixl 5 _<*>_\n field\n pure : A → 𝐹 A\n _<*>_ : 𝐹 (A → B) → 𝐹 A → 𝐹 B\n map-ap : (f : A → B) → map f ≡ pure f <*>_\n pure-homo : (f : A → B) → (x : A) → map f (pure x) ≡ pure (f x)\n <*>-interchange : (u : 𝐹 (A → B)) → (y : A) → u <*> pure y ≡ map (_$ y) u\n <*>-comp : (u : 𝐹 (B → C)) → (v : 𝐹 (A → B)) → (w : 𝐹 A) → pure _∘′_ <*> u <*> v <*> w ≡ u <*> (v <*> w)\n\n\nrecord IsMonad {ℓ₁} {ℓ₂} (𝐹 : Type ℓ₁ → Type ℓ₂) : Type (ℓsuc ℓ₁ ℓ⊔ ℓ₂) where\n infixl 1 _>>=_\n field\n _>>=_ : 𝐹 A → (A → 𝐹 B) → 𝐹 B\n return : A → 𝐹 A\n\n >>=-idˡ : (f : A → 𝐹 B) → (x : A) → (return x >>= f) ≡ f x\n >>=-idʳ : (x : 𝐹 A) → (x >>= return) ≡ x\n >>=-assoc : (xs : 𝐹 A) (f : A → 𝐹 B) (g : B → 𝐹 C) → ((xs >>= f) >>= g) ≡ (xs >>= (λ x → f x >>= g))\n\n\nrecord Monad ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where\n field\n 𝐹 : Type ℓ₁ → Type ℓ₂\n isMonad : IsMonad 𝐹\n open IsMonad isMonad public\n\nrecord MonadHomomorphism_⟶_\n {ℓ₁ ℓ₂ ℓ₃}\n (from : Monad ℓ₁ ℓ₂)\n (to : Monad ℓ₁ ℓ₃) : Type (ℓsuc ℓ₁ ℓ⊔ ℓ₂ ℓ⊔ ℓ₃) where\n module F = Monad from\n module T = Monad to\n\n field\n f : F.𝐹 A → T.𝐹 A\n >>=-homo : (xs : F.𝐹 A) (k : A → F.𝐹 B) → (f xs T.>>= (f ∘ k)) ≡ f (xs F.>>= k)\n return-homo : (x : A) → f (F.return x) ≡ T.return x\n\nrecord IsSetMonad {ℓ₁} {ℓ₂} (𝐹 : Type ℓ₁ → Type ℓ₂) : Type (ℓsuc ℓ₁ ℓ⊔ ℓ₂) where\n infixl 1 _>>=_\n field\n _>>=_ : 𝐹 A → (A → 𝐹 B) → 𝐹 B\n return : A → 𝐹 A\n\n trunc : isSet A → isSet (𝐹 A)\n\n >>=-idˡ : isSet B → (f : A → 𝐹 B) → (x : A) → (return x >>= f) ≡ f x\n >>=-idʳ : isSet A → (x : 𝐹 A) → (x >>= return) ≡ x\n >>=-assoc : isSet C → (xs : 𝐹 A) (f : A → 𝐹 B) (g : B → 𝐹 C) → ((xs >>= f) >>= g) ≡ (xs >>= (λ x → f x >>= g))\n\nrecord SetMonad ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where\n field\n 𝐹 : Type ℓ₁ → Type ℓ₂\n isSetMonad : IsSetMonad 𝐹\n open IsSetMonad isSetMonad public\n\nrecord SetMonadHomomorphism_⟶_\n {ℓ₁ ℓ₂ ℓ₃}\n (from : SetMonad ℓ₁ ℓ₂)\n (to : SetMonad ℓ₁ ℓ₃) : Type (ℓsuc ℓ₁ ℓ⊔ ℓ₂ ℓ⊔ ℓ₃) where\n module F = SetMonad from\n module T = SetMonad to\n\n field\n f : F.𝐹 A → T.𝐹 A\n >>=-homo : (xs : F.𝐹 A) (k : A → F.𝐹 B) → (f xs T.>>= (f ∘ k)) ≡ f (xs F.>>= k)\n return-homo : (x : A) → f (F.return x) ≡ T.return x\n\nrecord Alternative ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where\n field\n applicative : Applicative ℓ₁ ℓ₂\n open Applicative applicative public\n field\n 0# : 𝐹 A\n _<|>_ : 𝐹 A → 𝐹 A → 𝐹 A\n <|>-idˡ : (x : 𝐹 A) → 0# <|> x ≡ x\n <|>-idʳ : (x : 𝐹 A) → x <|> 0# ≡ x\n 0-annˡ : (x : 𝐹 A) → 0# <*> x ≡ 0# {B}\n <|>-distrib : (x y : 𝐹 (A → B)) → (z : 𝐹 A) → (x <|> y) <*> z ≡ (x <*> z) <|> (y <*> z)\n\nrecord MonadPlus ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where\n field\n monad : Monad ℓ₁ ℓ₂\n open Monad monad public\n field\n 0# : 𝐹 A\n _<|>_ : 𝐹 A → 𝐹 A → 𝐹 A\n <|>-idˡ : (x : 𝐹 A) → 0# <|> x ≡ x\n <|>-idʳ : (x : 𝐹 A) → x <|> 0# ≡ x\n 0-annˡ : (x : A → 𝐹 B) → (0# >>= x) ≡ 0#\n <|>-distrib : (x y : 𝐹 A) → (z : A → 𝐹 B) → ((x <|> y) >>= z) ≡ (x >>= z) <|> (y >>= z)\n\nEndo : Type a → Type a\nEndo A = A → A\n\nendoMonoid : ∀ {a} → Type a → Monoid a\nendoMonoid A .Monoid.𝑆 = Endo A\nendoMonoid A .Monoid.ε x = x\nendoMonoid A .Monoid._∙_ f g x = f (g x)\nendoMonoid A .Monoid.assoc _ _ _ = refl\nendoMonoid A .Monoid.ε∙ _ = refl\nendoMonoid A .Monoid.∙ε _ = refl\n\nrecord Foldable ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where\n field\n 𝐹 : Type ℓ₁ → Type ℓ₂\n open Monoid ⦃ ... ⦄\n field\n foldMap : {A : Type ℓ₁} ⦃ _ : Monoid ℓ₁ ⦄ → (A → 𝑆) → 𝐹 A → 𝑆\n foldr : {A B : Type ℓ₁} → (A → B → B) → B → 𝐹 A → B\n foldr f b xs = foldMap ⦃ endoMonoid _ ⦄ f xs b\n\nrecord GradedMonad {ℓ₁} (monoid : Monoid ℓ₁) ℓ₂ ℓ₃ : Type (ℓ₁ ℓ⊔ ℓsuc (ℓ₂ ℓ⊔ ℓ₃)) where\n open Monoid monoid\n field\n 𝐹 : 𝑆 → Type ℓ₂ → Type ℓ₃\n pure : A → 𝐹 ε A\n _>>=_ : ∀ {x y} → 𝐹 x A → (A → 𝐹 y B) → 𝐹 (x ∙ y) B\n\n >>=-idˡ : ∀ {s} (f : A → 𝐹 s B) → (x : A) → (pure x >>= f) ≡[ i ≔ 𝐹 (ε∙ s i) B ]≡ (f x)\n >>=-idʳ : ∀ {s} (x : 𝐹 s A) → (x >>= pure) ≡[ i ≔ 𝐹 (∙ε s i) A ]≡ x\n >>=-assoc : ∀ {x y z} (xs : 𝐹 x A) (f : A → 𝐹 y B) (g : B → 𝐹 z C) → ((xs >>= f) >>= g) ≡[ i ≔ 𝐹 (assoc x y z i) C ]≡ (xs >>= (λ x → f x >>= g))\n\n infixr 0 proven-bind\n\n proven-bind : ∀ {x y z} → 𝐹 x A → (A → 𝐹 y B) → (x ∙ y) ≡ z → 𝐹 z B\n proven-bind xs f proof = subst (flip 𝐹 _) proof (xs >>= f)\n\n syntax proven-bind xs f proof = xs >>=[ proof ] f\n\n infixr 0 proven-do\n proven-do : ∀ {x y z} → 𝐹 x A → (A → 𝐹 y B) → (x ∙ y) ≡ z → 𝐹 z B\n proven-do = proven-bind\n\n syntax proven-do xs (λ x → e) proof = x ← xs [ proof ] e\n\n map : ∀ {x} → (A → B) → 𝐹 x A → 𝐹 x B\n map f xs = xs >>=[ ∙ε _ ] (pure ∘ f)\n\n _<*>_ : ∀ {x y} → 𝐹 x (A → B) → 𝐹 y A → 𝐹 (x ∙ y) B\n fs <*> xs = fs >>= flip map xs\n\n _>>=ε_ : ∀ {x} → 𝐹 x A → (A → 𝐹 ε B) → 𝐹 x B\n xs >>=ε f = xs >>=[ ∙ε _ ] f\n", "meta": {"hexsha": "d18072d5e13904ade06c3ee413d8a32acfb05f51", "size": 10462, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Algebra.agda", "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_issues_repo_path": "Algebra.agda", "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Algebra.agda", "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "avg_line_length": 27.8244680851, "max_line_length": 148, "alphanum_fraction": 0.4828904607, "num_tokens": 5361, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916064586998, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.6065585494626483}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Lists where at least one element satisfies a given property\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.List.Relation.Unary.Any {a} {A : Set a} where\n\nopen import Data.Empty\nopen import Data.Fin\nopen import Data.List.Base as List using (List; []; [_]; _∷_)\nopen import Data.Product as Prod using (∃; _,_)\nopen import Data.Sum as Sum using (_⊎_; inj₁; inj₂)\nopen import Level using (_⊔_)\nopen import Relation.Nullary using (¬_; yes; no)\nimport Relation.Nullary.Decidable as Dec\nopen import Relation.Nullary.Negation using (contradiction)\nopen import Relation.Unary hiding (_∈_)\n\n------------------------------------------------------------------------\n-- Any P xs means that at least one element in xs satisfies P.\n\ndata Any {p} (P : A → Set p) : List A → Set (a ⊔ p) where\n here : ∀ {x xs} (px : P x) → Any P (x ∷ xs)\n there : ∀ {x xs} (pxs : Any P xs) → Any P (x ∷ xs)\n\n------------------------------------------------------------------------\n-- Operations on Any\n\nmodule _ {p} {P : A → Set p} {x xs} where\n\n head : ¬ Any P xs → Any P (x ∷ xs) → P x\n head ¬pxs (here px) = px\n head ¬pxs (there pxs) = contradiction pxs ¬pxs\n\n tail : ¬ P x → Any P (x ∷ xs) → Any P xs\n tail ¬px (here px) = ⊥-elim (¬px px)\n tail ¬px (there pxs) = pxs\n\nmap : ∀ {p q} {P : A → Set p} {Q : A → Set q} → P ⊆ Q → Any P ⊆ Any Q\nmap g (here px) = here (g px)\nmap g (there pxs) = there (map g pxs)\n\nmodule _ {p} {P : A → Set p} where\n\n -- `index x∈xs` is the list position (zero-based) which `x∈xs` points to.\n index : ∀ {xs} → Any P xs → Fin (List.length xs)\n index (here px) = zero\n index (there pxs) = suc (index pxs)\n\n lookup : ∀ {xs} → Any P xs → A\n lookup {xs} p = List.lookup xs (index p)\n\n _∷=_ : ∀ {xs} → Any P xs → A → List A\n _∷=_ {xs} x∈xs v = xs List.[ index x∈xs ]∷= v\n\n infixl 4 _─_\n _─_ : ∀ xs → Any P xs → List A\n xs ─ x∈xs = xs List.─ index x∈xs\n\n-- If any element satisfies P, then P is satisfied.\nsatisfied : ∀ {p} {P : A → Set p} {xs} → Any P xs → ∃ P\nsatisfied (here px) = _ , px\nsatisfied (there pxs) = satisfied pxs\n\nmodule _ {p} {P : A → Set p} {x xs} where\n\n toSum : Any P (x ∷ xs) → P x ⊎ Any P xs\n toSum (here px) = inj₁ px\n toSum (there pxs) = inj₂ pxs\n\n fromSum : P x ⊎ Any P xs → Any P (x ∷ xs)\n fromSum (inj₁ px) = here px\n fromSum (inj₂ pxs) = there pxs\n\n------------------------------------------------------------------------\n-- Properties of predicates preserved by Any\n\nmodule _ {p} {P : A → Set p} where\n\n any : Decidable P → Decidable (Any P)\n any P? [] = no λ()\n any P? (x ∷ xs) with P? x\n ... | yes px = yes (here px)\n ... | no ¬px = Dec.map′ there (tail ¬px) (any P? xs)\n\n satisfiable : Satisfiable P → Satisfiable (Any P)\n satisfiable (x , Px) = [ x ] , here Px\n", "meta": {"hexsha": "3f8f337ce9f29d37c14648c697750edf28095c97", "size": 2922, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Unary/Any.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Unary/Any.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Unary/Any.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.1098901099, "max_line_length": 75, "alphanum_fraction": 0.5177960301, "num_tokens": 963, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.863391602943619, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.6065585469931984}} {"text": "{-# OPTIONS --without-K #-}\nmodule function.isomorphism.core where\n\nopen import level using (_⊔_)\nopen import equality.core\nopen import equality.groupoid\nopen import equality.reasoning\nopen import function.core\nopen import function.overloading\nopen import sum\nopen import function.extensionality.core\nopen import overloading.core\n\n-- isomorphisms\nrecord _≅_ {i j}(X : Set i)(Y : Set j) : Set (i ⊔ j) where\n constructor iso\n field\n to : X → Y\n from : Y → X\n iso₁ : (x : X) → from (to x) ≡ x\n iso₂ : (y : Y) → to (from y) ≡ y\ninfix 5 _≅_\n\n≅-struct-iso : ∀ {i j}{X : Set i}{Y : Set j}\n → (X ≅ Y)\n ≅ ( Σ (X → Y) λ f\n → Σ (Y → X) λ g\n → ((x : X) → g (f x) ≡ x)\n × ((y : Y) → f (g y) ≡ y) )\n≅-struct-iso = record\n { to = λ { (iso f g α β) → f , g , α , β }\n ; from = λ { (f , g , α , β) → iso f g α β }\n ; iso₁ = λ _ → refl\n ; iso₂ = λ _ → refl }\n\nrefl≅ : ∀ {i}{X : Set i} → X ≅ X\nrefl≅ = iso id id (λ _ → refl) (λ _ → refl)\n\n≡⇒≅ : ∀ {i}{X Y : Set i} → X ≡ Y → X ≅ Y\n≡⇒≅ refl = refl≅\n\nsym≅ : ∀ {i j}{X : Set i}{Y : Set j} → X ≅ Y → Y ≅ X\nsym≅ (iso f g H K) = iso g f K H\n\ntrans≅ : ∀ {i j k}{X : Set i}{Y : Set j}{Z : Set k}\n → X ≅ Y → Y ≅ Z → X ≅ Z\ntrans≅ {X = X}{Z = Z} (iso f g H K) (iso f' g' H' K') = record\n { to = f' ∘ f\n ; from = g ∘ g'\n ; iso₁ = iso₁\n ; iso₂ = iso₂ }\n where\n abstract\n iso₁ : (x : X) → g (g' (f' (f x))) ≡ x\n iso₁ x = ap g (H' (f x)) · H x\n\n iso₂ : (z : Z) → f' (f (g (g' z))) ≡ z\n iso₂ y = ap f' (K (g' y)) · K' y\n\n_·≅_ : ∀ {i j k}{X : Set i}{Y : Set j}{Z : Set k}\n → X ≅ Y → Y ≅ Z → X ≅ Z\n_·≅_ = trans≅\ninfixl 9 _·≅_\n\nmodule ≅-Reasoning where\n infix 4 _IsRelatedTo_\n infix 2 _∎\n infixr 2 _≅⟨_⟩_\n infixr 2 _≡⟨_⟩_\n infix 1 begin_\n\n data _IsRelatedTo_ {i j}(x : Set i)(y : Set j) : Set (i ⊔ j) where\n relTo : x ≅ y → x IsRelatedTo y\n\n begin_ : ∀ {i j}{X : Set i}{Y : Set j} → X IsRelatedTo Y → X ≅ Y\n begin relTo p = p\n\n _≅⟨_⟩_ : ∀ {i j k} (X : Set i) {Y : Set j}{Z : Set k}\n → X ≅ Y → Y IsRelatedTo Z → X IsRelatedTo Z\n _ ≅⟨ p ⟩ relTo q = relTo (trans≅ p q)\n\n _≡⟨_⟩_ : ∀ {i j} (X : Set i) {Y : Set i} {Z : Set j}\n → X ≡ Y → Y IsRelatedTo Z → X IsRelatedTo Z\n _ ≡⟨ p ⟩ relTo q = relTo (trans≅ (≡⇒≅ p) q)\n\n _∎ : ∀ {i} (X : Set i) → X IsRelatedTo X\n _∎ _ = relTo refl≅\n\ninjective : ∀ {i j}{X : Set i}{Y : Set j}\n → (f : X → Y) → Set _\ninjective f = ∀ {x x'} → f x ≡ f x' → x ≡ x'\n\nretraction : ∀ {i j}{X : Set i}{Y : Set j}\n → (f : X → Y) → Set _\nretraction {X = X}{Y = Y} f = (y : Y) → Σ X λ x → f x ≡ y\n\n_↣_ : ∀ {i j} → Set i → Set j → Set _\nA ↣ B = Σ (A → B) injective\n\n-- composition of injections:\n_∘i_ : ∀ {i j k}{A : Set i}{B : Set j}{C : Set k}\n → (B ↣ C) → (A ↣ B) → (A ↣ C)\n(g , p) ∘i (f , q) = g ∘ f , q ∘ p\n\n_↠_ : ∀ {i j} → Set i → Set j → Set _\nA ↠ B = Σ (A → B) retraction\n\nprivate\n module properties {i j}{X : Set i}{Y : Set j} where\n apply≅ : (X ≅ Y) → X → Y\n apply≅ = _≅_.to\n\n invert≅ : (X ≅ Y) → Y → X\n invert≅ = _≅_.from\n\n instance\n iso-is-fun : Coercion (X ≅ Y) (X → Y)\n iso-is-fun = record\n { coerce = _≅_.to }\n\n iso-is-iso : Coercion (X ≅ Y) (X ≅ Y)\n iso-is-iso = coerce-self _\n\n inj-is-fun : Coercion (X ↣ Y) (X → Y)\n inj-is-fun = record\n { coerce = proj₁ }\n\n srj-is-fun : Coercion (X ↠ Y) (X → Y)\n srj-is-fun = record\n { coerce = proj₁ }\n\n private\n module iso-methods {k}{Source : Set k}\n ⦃ c : Coercion Source (X ≅ Y) ⦄ where\n private\n module with-source (source : Source) where\n private target = coerce c source\n open _≅_ target public using ()\n renaming (from to invert)\n open with-source public\n open iso-methods public\n\n iso⇒inj : (iso : X ≅ Y) → injective (apply iso)\n iso⇒inj f {x}{x'} q = (iso₁ x) ⁻¹ · ap from q · iso₁ x'\n where\n open _≅_ f\n\n iso⇒retr : (iso : X ≅ Y) → retraction (apply iso)\n iso⇒retr f y = from y , iso₂ y\n where\n open _≅_ f\n\n inj+retr⇒iso : (f : X → Y) → injective f → retraction f → X ≅ Y\n inj+retr⇒iso f inj-f retr-f = iso f g H K\n where\n g : Y → X\n g y = proj₁ (retr-f y)\n\n H : (x : X) → g (f x) ≡ x\n H x = inj-f (proj₂ (retr-f (f x)))\n\n K : (y : Y) → f (g y) ≡ y\n K y = proj₂ (retr-f y)\n\nopen properties public\n", "meta": {"hexsha": "6473dc10d7f3fe3f5adcf9282776a3897fd66623", "size": 4425, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "function/isomorphism/core.agda", "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_issues_repo_path": "function/isomorphism/core.agda", "max_issues_repo_name": "HoTT/M-types", "max_issues_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-02-11T11:14:59.000Z", "max_issues_repo_issues_event_max_datetime": "2015-02-11T15:20:34.000Z", "max_forks_repo_path": "function/isomorphism/core.agda", "max_forks_repo_name": "HoTT/M-types", "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z", "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z", "avg_line_length": 26.656626506, "max_line_length": 68, "alphanum_fraction": 0.4700564972, "num_tokens": 1893, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673223709251, "lm_q2_score": 0.7461389986757758, "lm_q1q2_score": 0.6065120099701011}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Some properties about signs\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Sign.Properties where\n\nopen import Algebra\nopen import Data.Empty\nopen import Data.Sign\nopen import Data.Product using (_,_)\nopen import Function\nopen import Level using (0ℓ)\nopen import Relation.Binary.PropositionalEquality\n\nopen import Algebra.Structures {A = Sign} _≡_\nopen import Algebra.FunctionProperties {A = Sign} _≡_\n\n-- The opposite of a sign is not equal to the sign.\n\ns≢opposite[s] : ∀ s → s ≢ opposite s\ns≢opposite[s] - ()\ns≢opposite[s] + ()\n\nopposite-injective : ∀ {s t} → opposite s ≡ opposite t → s ≡ t\nopposite-injective { - } { - } refl = refl\nopposite-injective { - } { + } ()\nopposite-injective { + } { - } ()\nopposite-injective { + } { + } refl = refl\n\n------------------------------------------------------------------------\n-- _*_\n\n-- Algebraic properties of _*_\n\n*-identityˡ : LeftIdentity + _*_\n*-identityˡ _ = refl\n\n*-identityʳ : RightIdentity + _*_\n*-identityʳ - = refl\n*-identityʳ + = refl\n\n*-identity : Identity + _*_\n*-identity = *-identityˡ , *-identityʳ\n\n*-comm : Commutative _*_\n*-comm + + = refl\n*-comm + - = refl\n*-comm - + = refl\n*-comm - - = refl\n\n*-assoc : Associative _*_\n*-assoc + + _ = refl\n*-assoc + - _ = refl\n*-assoc - + _ = refl\n*-assoc - - + = refl\n*-assoc - - - = refl\n\n*-cancelʳ-≡ : RightCancellative _*_\n*-cancelʳ-≡ - - _ = refl\n*-cancelʳ-≡ - + eq = ⊥-elim (s≢opposite[s] _ $ sym eq)\n*-cancelʳ-≡ + - eq = ⊥-elim (s≢opposite[s] _ eq)\n*-cancelʳ-≡ + + _ = refl\n\n*-cancelˡ-≡ : LeftCancellative _*_\n*-cancelˡ-≡ - eq = opposite-injective eq\n*-cancelˡ-≡ + eq = eq\n\n*-cancel-≡ : Cancellative _*_\n*-cancel-≡ = *-cancelˡ-≡ , *-cancelʳ-≡\n\n*-isMagma : IsMagma _*_\n*-isMagma = record\n { isEquivalence = isEquivalence\n ; ∙-cong = cong₂ _*_\n }\n\n*-magma : Magma 0ℓ 0ℓ\n*-magma = record\n { isMagma = *-isMagma\n }\n\n*-isSemigroup : IsSemigroup _*_\n*-isSemigroup = record\n { isMagma = *-isMagma\n ; assoc = *-assoc\n }\n\n*-semigroup : Semigroup 0ℓ 0ℓ\n*-semigroup = record\n { isSemigroup = *-isSemigroup\n }\n\n*-isMonoid : IsMonoid _*_ +\n*-isMonoid = record\n { isSemigroup = *-isSemigroup\n ; identity = *-identity\n }\n\n*-monoid : Monoid 0ℓ 0ℓ\n*-monoid = record\n { isMonoid = *-isMonoid\n }\n\n-- Other properties of _*_\n\ns*s≡+ : ∀ s → s * s ≡ +\ns*s≡+ + = refl\ns*s≡+ - = refl\n\n------------------------------------------------------------------------\n-- DEPRECATED NAMES\n------------------------------------------------------------------------\n-- Please use the new names as continuing support for the old names is\n-- not guaranteed.\n\nopposite-not-equal = s≢opposite[s]\n{-# WARNING_ON_USAGE opposite-not-equal\n\"Warning: opposite-not-equal was deprecated in v0.15.\nPlease use s≢opposite[s] instead.\"\n#-}\nopposite-cong = opposite-injective\n{-# WARNING_ON_USAGE opposite-cong\n\"Warning: opposite-cong was deprecated in v0.15.\nPlease use opposite-injective instead.\"\n#-}\ncancel-*-left = *-cancelˡ-≡\n{-# WARNING_ON_USAGE cancel-*-left\n\"Warning: cancel-*-left was deprecated in v0.15.\nPlease use *-cancelˡ-≡ instead.\"\n#-}\ncancel-*-right = *-cancelʳ-≡\n{-# WARNING_ON_USAGE cancel-*-right\n\"Warning: cancel-*-right was deprecated in v0.15.\nPlease use *-cancelʳ-≡ instead.\"\n#-}\n*-cancellative = *-cancel-≡\n{-# WARNING_ON_USAGE *-cancellative\n\"Warning: *-cancellative was deprecated in v0.15.\nPlease use *-cancel-≡ instead.\"\n#-}\n", "meta": {"hexsha": "2491515a382409ee6a46138677da2ea8db5429ce", "size": 3521, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Sign/Properties.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Sign/Properties.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Sign/Properties.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.2827586207, "max_line_length": 72, "alphanum_fraction": 0.5813689293, "num_tokens": 1111, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951143326726, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.6064183021631517}} {"text": "{-# OPTIONS --universe-polymorphism #-}\nmodule Categories.Opposite where\n\n-- some properties of the opposite category.\n-- XXX these should probably go somewhere else, but everywhere i think of\n-- has other problems. ☹\n\nopen import Categories.Category\nopen import Categories.Functor\nopen import Categories.FunctorCategory\nopen import Categories.NaturalTransformation\nopen import Categories.Morphisms renaming (_≅_ to _[_≅_])\n\nopⁱ : ∀ {o ℓ e} {C : Category o ℓ e} {A B} → C [ A ≅ B ] → Category.op C [ B ≅ A ]\nopⁱ {C = C} A≅B = record\n { f = A≅B.f\n ; g = A≅B.g\n ; iso = record { isoˡ = A≅B.isoʳ; isoʳ = A≅B.isoˡ }\n }\n where\n module A≅B = Categories.Morphisms._≅_ A≅B\n\nopF : ∀ {o₁ ℓ₁ e₁ o₂ ℓ₂ e₂} {A : Category o₁ ℓ₁ e₁} {B : Category o₂ ℓ₂ e₂} -> \n (Functor (Category.op (Functors (Category.op A) (Category.op B))) (Functors A B))\nopF {A = A} {B} = record {\n F₀ = Functor.op;\n F₁ = NaturalTransformation.op;\n identity = Category.Equiv.refl B;\n homomorphism = Category.Equiv.refl B;\n F-resp-≡ = λ x → x }\n", "meta": {"hexsha": "a6db0f016db992d8bdb39f41eb9014a576995f7f", "size": 1106, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Opposite.agda", "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 98, "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_issues_repo_path": "Categories/Opposite.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_forks_repo_path": "Categories/Opposite.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 23, "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "avg_line_length": 35.6774193548, "max_line_length": 85, "alphanum_fraction": 0.6112115732, "num_tokens": 359, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392695254318, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.6064062551368106}} {"text": "module exampleTypeAbbreviations where\n\npostulate A : Set\nA2 : Set\nA2 = A -> A\n\nA3 : Set\nA3 = A2 -> A2\n\na2 : A2\na2 = \\x -> x\n\na3 : A3\na3 = \\x -> x", "meta": {"hexsha": "f6ff17d7f867f76c9e8218ccfce55d79c36219dc", "size": 145, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tests/covered/exampleTypeAbbreviations.agda", "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_issues_repo_path": "tests/covered/exampleTypeAbbreviations.agda", "max_issues_repo_name": "andrejtokarcik/agda-semantics", "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/covered/exampleTypeAbbreviations.agda", "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 10.3571428571, "max_line_length": 37, "alphanum_fraction": 0.5793103448, "num_tokens": 67, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.90192067652954, "lm_q2_score": 0.6723316860482763, "lm_q1q2_score": 0.6063898491329076}} {"text": "module 747Quantifiers where\n\n-- Library\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl)\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_; _≤_; z≤n; s≤s) -- added ≤\nopen import Relation.Nullary using (¬_)\nopen import Data.Product using (_×_; proj₁; proj₂) renaming (_,_ to ⟨_,_⟩) -- added proj₂\nopen import Data.Sum using (_⊎_; inj₁; inj₂ ) -- added inj₁, inj₂\nopen import Function using (_∘_) -- added\n\n-- Copied from 747Isomorphism.\n\npostulate\n extensionality : ∀ {A B : Set} {f g : A → B}\n → (∀ (x : A) → f x ≡ g x)\n -----------------------\n → f ≡ g\n\ninfix 0 _≃_\nrecord _≃_ (A B : Set) : Set where\n constructor mk-≃\n field\n to : A → B\n from : B → A\n from∘to : ∀ (x : A) → from (to x) ≡ x\n to∘from : ∀ (y : B) → to (from y) ≡ y\nopen _≃_\n\nrecord _⇔_ (A B : Set) : Set where\n field\n to : A → B\n from : B → A\nopen _⇔_\n\n\n-- Logical forall is, not surpringly, ∀.\n-- Forall elimination is also function application.\n\n∀-elim : ∀ {A : Set} {B : A → Set}\n → (L : ∀ (x : A) → B x)\n → (M : A)\n -----------------\n → B M\n∀-elim L M = L M\n\n-- In fact, A → B is nicer syntax for ∀ (_ : A) → B.\n\n-- 747/PLFA exercise: ForAllDistProd (1 point)\n-- Show that ∀ distributes over ×.\n-- (The special case of → distributes over × was shown in the Connectives chapter.)\n\n∀-distrib-× : ∀ {A : Set} {B C : A → Set} →\n (∀ (x : A) → B x × C x) ≃ (∀ (x : A) → B x) × (∀ (x : A) → C x)\n∀-distrib-× = {!!}\n\n-- 747/PLFA exercise: SumForAllImpForAllSum (1 point)\n-- Show that a disjunction of foralls implies a forall of disjunctions.\n\n⊎∀-implies-∀⊎ : ∀ {A : Set} {B C : A → Set} →\n (∀ (x : A) → B x) ⊎ (∀ (x : A) → C x) → ∀ (x : A) → B x ⊎ C x\n⊎∀-implies-∀⊎ ∀B⊎∀C = {!!}\n\n-- Existential quantification can be defined as a pair:\n-- a witness and a proof that the witness satisfies the property.\n\ndata Σ (A : Set) (B : A → Set) : Set where\n ⟨_,_⟩ : (x : A) → B x → Σ A B\n\n-- Some convenient syntax.\n\nΣ-syntax = Σ\ninfix 2 Σ-syntax\nsyntax Σ-syntax A (λ x → B) = Σ[ x ∈ A ] B\n\n-- Unfortunately, we can use the RHS syntax in code,\n-- but the LHS will show up in displays of goal and context.\n\n-- This is equivalent to defining a dependent record type.\n\nrecord Σ′ (A : Set) (B : A → Set) : Set where\n field\n proj₁′ : A\n proj₂′ : B proj₁′\n\n-- By convention, the library uses ∃ when the domain of the bound variable is implicit.\n\n∃ : ∀ {A : Set} (B : A → Set) → Set\n∃ {A} B = Σ A B\n\n-- More special syntax.\n\n∃-syntax = ∃\nsyntax ∃-syntax (λ x → B) = ∃[ x ] B\n\n-- Above we saw two ways of constructing an existential.\n-- We eliminate an existential with a function that consumes the\n-- witness and proof and reaches a conclusion C.\n\n∃-elim : ∀ {A : Set} {B : A → Set} {C : Set}\n → (∀ x → B x → C)\n → ∃[ x ] B x\n ---------------\n → C\n∃-elim f ⟨ x , y ⟩ = f x y\n\n-- This is a generalization of currying (from Connectives).\n-- currying : ∀ {A B C : Set} → (A → B → C) ≃ (A × B → C)\n\n∀∃-currying : ∀ {A : Set} {B : A → Set} {C : Set}\n → (∀ x → B x → C) ≃ (∃[ x ] B x → C)\n_≃_.to ∀∃-currying f ⟨ x , x₁ ⟩ = f x x₁\n_≃_.from ∀∃-currying e x x₁ = e ⟨ x , x₁ ⟩\n_≃_.from∘to ∀∃-currying f = refl\n_≃_.to∘from ∀∃-currying e = extensionality λ { ⟨ x , x₁ ⟩ → refl}\n\n-- 747/PLFA exercise: ExistsDistSum (2 points)\n-- Show that existentials distribute over disjunction.\n\n∃-distrib-⊎ : ∀ {A : Set} {B C : A → Set} →\n ∃[ x ] (B x ⊎ C x) ≃ (∃[ x ] B x) ⊎ (∃[ x ] C x)\n∃-distrib-⊎ = {!!}\n\n-- 747/PLFA exercise: ExistsProdImpProdExists (1 point)\n-- Show that existentials distribute over ×.\n\n∃×-implies-×∃ : ∀ {A : Set} {B C : A → Set} →\n ∃[ x ] (B x × C x) → (∃[ x ] B x) × (∃[ x ] C x)\n∃×-implies-×∃ = {!!}\n\n-- An existential example: revisiting even/odd.\n\n-- Recall the mutually-recursive definitions of even and odd.\n\ndata even : ℕ → Set\ndata odd : ℕ → Set\n\ndata even where\n\n even-zero : even zero\n\n even-suc : ∀ {n : ℕ}\n → odd n\n ------------\n → even (suc n)\n\ndata odd where\n odd-suc : ∀ {n : ℕ}\n → even n\n -----------\n → odd (suc n)\n\n-- An number is even iff it is double some other number.\n-- A number is odd iff is one plus double some other number.\n-- Proofs below.\n\neven-∃ : ∀ {n : ℕ} → even n → ∃[ m ] ( m * 2 ≡ n)\nodd-∃ : ∀ {n : ℕ} → odd n → ∃[ m ] (1 + m * 2 ≡ n)\n\neven-∃ even-zero = ⟨ zero , refl ⟩\neven-∃ (even-suc x) with odd-∃ x\neven-∃ (even-suc x) | ⟨ x₁ , refl ⟩ = ⟨ suc x₁ , refl ⟩\nodd-∃ (odd-suc x) with even-∃ x\nodd-∃ (odd-suc x) | ⟨ x₁ , refl ⟩ = ⟨ x₁ , refl ⟩\n\n∃-even : ∀ {n : ℕ} → ∃[ m ] ( m * 2 ≡ n) → even n\n∃-odd : ∀ {n : ℕ} → ∃[ m ] (1 + m * 2 ≡ n) → odd n\n\n∃-even ⟨ zero , refl ⟩ = even-zero\n∃-even ⟨ suc x , refl ⟩ = even-suc (∃-odd ⟨ x , refl ⟩)\n∃-odd ⟨ x , refl ⟩ = odd-suc (∃-even ⟨ x , refl ⟩)\n\n-- PLFA exercise: what if we write the arithmetic more \"naturally\"?\n-- (Proof gets harder but is still doable).\n\n-- 747/PLFA exercise: AltLE (3 points)\n-- An alternate definition of y ≤ z.\n-- (Optional exercise: Is this an isomorphism?)\n\n∃-≤ : ∀ {y z : ℕ} → ( (y ≤ z) ⇔ ( ∃[ x ] (y + x ≡ z) ) )\n∃-≤ = {!!}\n\n-- The negation of an existential is isomorphic to a universal of a negation.\n\n¬∃≃∀¬ : ∀ {A : Set} {B : A → Set}\n → (¬ ∃[ x ] B x) ≃ ∀ x → ¬ B x\n¬∃≃∀¬ = {!!}\n\n-- 747/PLFA exercise: ExistsNegImpNegForAll (1 point)\n-- Existence of negation implies negation of universal.\n\n∃¬-implies-¬∀ : ∀ {A : Set} {B : A → Set}\n → ∃[ x ] (¬ B x)\n --------------\n → ¬ (∀ x → B x)\n∃¬-implies-¬∀ ∃¬B = {!!}\n\n-- The converse cannot be proved in intuitionistic logic.\n\n-- PLFA exercise: isomorphism between naturals and existence of canonical binary.\n-- This is essentially what we did at the end of 747Isomorphism.\n", "meta": {"hexsha": "0255c852a815c935e0ed3f3d9bb27eb10e0e08c2", "size": 5607, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x08-747Quantifiers-completed.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x08-747Quantifiers-completed.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x08-747Quantifiers-completed.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 27.6206896552, "max_line_length": 89, "alphanum_fraction": 0.5478865704, "num_tokens": 2190, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569014, "lm_q2_score": 0.7549149868676283, "lm_q1q2_score": 0.6063279359291934}} {"text": "-- In this file we consider the special of localising at a single\n-- element f : R (or rather the set of powers of f). This is also\n-- known as inverting f.\n\n{-# OPTIONS --cubical --no-import-sorts --safe --experimental-lossy-unification #-}\nmodule Cubical.Algebra.CommRing.Localisation.InvertingElements where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Univalence\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Powerset\nopen import Cubical.Foundations.Transport\nopen import Cubical.Functions.FunExtEquiv\n\nimport Cubical.Data.Empty as ⊥\nopen import Cubical.Data.Bool\nopen import Cubical.Data.Nat renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_\n ; +-comm to +ℕ-comm ; +-assoc to +ℕ-assoc\n ; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm)\nopen import Cubical.Data.Vec\nopen import Cubical.Data.Sigma.Base\nopen import Cubical.Data.Sigma.Properties\nopen import Cubical.Data.FinData\nopen import Cubical.Relation.Nullary\nopen import Cubical.Relation.Binary\n\nopen import Cubical.Algebra.Group\nopen import Cubical.Algebra.AbGroup\nopen import Cubical.Algebra.Monoid\nopen import Cubical.Algebra.Ring\nopen import Cubical.Algebra.CommRing\nopen import Cubical.Algebra.CommRing.Localisation.Base\nopen import Cubical.Algebra.CommRing.Localisation.UniversalProperty\nopen import Cubical.HITs.SetQuotients as SQ\nopen import Cubical.HITs.PropositionalTruncation as PT\n\nopen Iso\n\nprivate\n variable\n ℓ ℓ' : Level\n A : Type ℓ\n\nmodule _(R' : CommRing {ℓ}) where\n open isMultClosedSubset\n private R = R' .fst\n -- open CommRingStr ⦃...⦄\n open CommRingStr (R' .snd)\n open Exponentiation R'\n\n\n [_ⁿ|n≥0] : R → ℙ R\n [ f ⁿ|n≥0] g = (∃[ n ∈ ℕ ] g ≡ f ^ n) , propTruncIsProp\n -- Σ[ n ∈ ℕ ] (s ≡ f ^ n) × (∀ m → s ≡ f ^ m → n ≤ m) maybe better, this isProp:\n -- (n,s≡fⁿ,p) (m,s≡fᵐ,q) then n≤m by p and m≤n by q => n≡m\n\n powersFormMultClosedSubset : (f : R) → isMultClosedSubset R' [ f ⁿ|n≥0]\n powersFormMultClosedSubset f .containsOne = ∣ zero , refl ∣\n powersFormMultClosedSubset f .multClosed =\n PT.map2 λ (m , p) (n , q) → (m +ℕ n) , (λ i → (p i) · (q i)) ∙ ·-of-^-is-^-of-+ f m n\n\n\n R[1/_] : R → Type ℓ\n R[1/ f ] = Loc.S⁻¹R R' [ f ⁿ|n≥0] (powersFormMultClosedSubset f)\n\n\n R[1/_]AsCommRing : R → CommRing {ℓ}\n R[1/ f ]AsCommRing = Loc.S⁻¹RAsCommRing R' [ f ⁿ|n≥0] (powersFormMultClosedSubset f)\n\n -- A useful lemma: (gⁿ/1)≡(g/1)ⁿ in R[1/f]\n ^-respects-/1 : {f g : R} (n : ℕ) → [ (g ^ n) , 1r , ∣ 0 , (λ _ → 1r) ∣ ] ≡\n Exponentiation._^_ R[1/ f ]AsCommRing [ g , 1r , powersFormMultClosedSubset _ .containsOne ] n\n ^-respects-/1 zero = refl\n ^-respects-/1 {f} {g} (suc n) = eq/ _ _ ( (1r , powersFormMultClosedSubset f .containsOne)\n , cong (1r · (g · (g ^ n)) ·_) (·-lid 1r))\n ∙ cong (CommRingStr._·_ (R[1/ f ]AsCommRing .snd)\n [ g , 1r , powersFormMultClosedSubset f .containsOne ]) (^-respects-/1 n)\n\n -- A slight improvement for eliminating into propositions\n InvElPropElim : {f : R} {P : R[1/ f ] → Type ℓ'}\n → (∀ x → isProp (P x))\n → (∀ (r : R) (n : ℕ) → P [ r , (f ^ n) , ∣ n , refl ∣ ])\n ----------------------------------------------------------\n → (∀ x → P x)\n InvElPropElim {f = f} {P = P} PisProp base = elimProp (λ _ → PisProp _) []-case\n where\n S[f] = Loc.S R' [ f ⁿ|n≥0] (powersFormMultClosedSubset f)\n []-case : (a : R × S[f]) → P [ a ]\n []-case (r , s , s∈S[f]) = PT.rec (PisProp _) Σhelper s∈S[f]\n where\n Σhelper : Σ[ n ∈ ℕ ] s ≡ f ^ n → P [ r , s , s∈S[f] ]\n Σhelper (n , p) = subst P (cong [_] (≡-× refl (Σ≡Prop (λ _ → propTruncIsProp) (sym p)))) (base r n)\n\n", "meta": {"hexsha": "2af1a491f0b1a5cdb9634d82cbfc085cfd7367a8", "size": 3864, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommRing/Localisation/InvertingElements.agda", "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/CommRing/Localisation/InvertingElements.agda", "max_issues_repo_name": "Schippmunk/cubical", "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/CommRing/Localisation/InvertingElements.agda", "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.8350515464, "max_line_length": 102, "alphanum_fraction": 0.6123188406, "num_tokens": 1342, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569014, "lm_q2_score": 0.7549149813536518, "lm_q1q2_score": 0.606327931500512}} {"text": "\nmodule Graph (Node : Set) where\n\nopen import Basics\n\ndata Edge : Set where\n edge : Node -> Node -> Edge\n\nGraph : Set\nGraph = List Edge\n\nStep : Graph -> Node -> Node -> Set\nStep G x y = Elem (edge x y) G\n\ninfixr 40 _<>_\n\ndata Path (G : Graph) : Node -> Node -> Set where\n nul : forall {x} -> Path G x x\n _<>_ : forall {x y z} -> Step G x y -> Path G y z -> Path G x z\n", "meta": {"hexsha": "d4b8875d885440c46b3969e5f8f01b56d74f37b6", "size": 376, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/cbs/Graph.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/cbs/Graph.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/outdated-and-incorrect/cbs/Graph.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 18.8, "max_line_length": 65, "alphanum_fraction": 0.5824468085, "num_tokens": 127, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9111797027760039, "lm_q2_score": 0.6654105521116445, "lm_q1q2_score": 0.6063085890971048}} {"text": "{-\n\nPart 4: Higher inductive types\n\n• Set quotients via HITs\n• Propositional truncation\n• A little synthetic homotopy theory\n\n-}\n{-# OPTIONS --cubical #-}\nmodule Part4 where\n\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Data.Int hiding (_+_)\nopen import Cubical.Data.Nat hiding (elim)\nopen import Cubical.Data.Prod hiding (map)\n\nopen import Part1\nopen import Part2\nopen import Part3\n\n-- Another thing that Cubical Agda adds is the possibility to define\n-- higher inductive types. These are just like normal Agda datatypes,\n-- but they have also \"higher\" constructors specifying non-trivial\n-- paths, square, cubes, etc. in the type. These give a nice way of\n-- defining set quotiented types as well as higher dimensional types\n-- quotiented by some arbitrary relation.\n\n-- Let's start by looking at some set quotient examples. The following\n-- definition of finite multisets is due to Vikraman Choudhury and\n-- Marcelo Fiore.\n\ninfixr 5 _∷_\n\ndata FMSet (A : Type ℓ) : Type ℓ where\n [] : FMSet A\n _∷_ : (x : A) → (xs : FMSet A) → FMSet A\n comm : (x y : A) (xs : FMSet A) → x ∷ y ∷ xs ≡ y ∷ x ∷ xs\n trunc : (xs ys : FMSet A) (p q : xs ≡ ys) → p ≡ q\n\ninfixr 30 _++_\n\n_++_ : ∀ (xs ys : FMSet A) → FMSet A\n[] ++ ys = ys\n(x ∷ xs) ++ ys = x ∷ xs ++ ys\ncomm x y xs i ++ ys = comm x y (xs ++ ys) i\ntrunc xs zs p q i j ++ ys =\n trunc (xs ++ ys) (zs ++ ys) (λ k → p k ++ ys) (λ k → q k ++ ys) i j\n\nunitl-++ : (xs : FMSet A) → [] ++ xs ≡ xs\nunitl-++ xs = refl\n\nunitr-++ : (xs : FMSet A) → xs ++ [] ≡ xs\nunitr-++ [] = refl\nunitr-++ (x ∷ xs) = cong (x ∷_) (unitr-++ xs)\nunitr-++ (comm x y xs i) j = comm x y (unitr-++ xs j) i\nunitr-++ (trunc xs ys p q i k) j =\n trunc (unitr-++ xs j) (unitr-++ ys j)\n (λ k → unitr-++ (p k) j) (λ k → unitr-++ (q k) j) i k\n\n\n-- Filling the goals for comm and trunc quickly gets tiresome and\n-- useful lemmas about eliminating into propositions are proved in\n-- Cubical.HITs.FiniteMultiset. As we're proving an equality of a set\n-- truncated type we can prove the trunc and comm cases once and for\n-- all so that we only have to give cases for [] and _∷_ when\n-- constructing a family of propositions. This is a very common\n-- pattern when working with set truncated HITs: first define the HIT,\n-- then prove special purpose recursors and eliminators for\n-- eliminating into types of different h-levels. All definitions are\n-- then written using these recursors and eliminators and one get very\n-- short proofs.\n\n\n-- A more efficient version of finite multisets based on association\n-- lists can be found in Cubical.HITs.AssocList.Base. It looks like\n-- this:\n\ndata AssocList (A : Type ℓ) : Type ℓ where\n ⟨⟩ : AssocList A\n ⟨_,_⟩∷_ : (a : A) (n : ℕ) (xs : AssocList A) → AssocList A\n per : (a b : A) (m n : ℕ) (xs : AssocList A)\n → ⟨ a , m ⟩∷ ⟨ b , n ⟩∷ xs ≡ ⟨ b , n ⟩∷ ⟨ a , m ⟩∷ xs\n agg : (a : A) (m n : ℕ) (xs : AssocList A)\n → ⟨ a , m ⟩∷ ⟨ a , n ⟩∷ xs ≡ ⟨ a , m + n ⟩∷ xs\n del : (a : A) (xs : AssocList A) → ⟨ a , 0 ⟩∷ xs ≡ xs\n trunc : (xs ys : AssocList A) (p q : xs ≡ ys) → p ≡ q\n\n-- Programming and proving is more complicated with AssocList compared\n-- to FMSet. This kind of example occurs everywhere in programming and\n-- mathematics: one representation is easier to work with, but not\n-- efficient, while another is efficient but difficult to work with.\n-- Using the SIP we can get the best of both worlds (see\n-- https://arxiv.org/abs/2009.05547 for details).\n\n-- Another nice CS example of a HIT can be found in Cubical.Data.Queue\n-- where we define a queue datastructure based on two lists. These\n-- examples are all special cases of set quotients and are very useful\n-- for programming and set level mathematics. We can define the\n-- general form as:\n\ndata _/_ (A : Type ℓ) (R : A → A → Type ℓ') : Type (ℓ-max ℓ ℓ') where\n [_] : A → A / R\n eq/ : (a b : A) → R a b → [ a ] ≡ [ b ]\n trunc : (a b : A / R) (p q : a ≡ b) → p ≡ q\n\n-- It's sometimes easier to work directly with _/_ instead of defining\n-- special HITs as one can reuse lemmas for _/_ instead of reproving\n-- things. For example, general lemmas about eliminating into\n-- propositions have already been proved for _/_.\n\n-- Proving that _/_ is \"effective\" (for prop-valued relation), i.e. that\n--\n-- ((a b : A) → [ a ] ≡ [ b ] → R a b)\n--\n-- requires univalence for propositions (hPropExt).\n\n-- Set quotients let us define things like in normal math:\nℤ : Type₀\nℤ = (ℕ × ℕ) / rel\n where\n rel : (ℕ × ℕ) → (ℕ × ℕ) → Type₀\n rel (x₀ , y₀) (x₁ , y₁) = x₀ + y₁ ≡ x₁ + y₀\n\n\n-- Another useful class of HITs are truncations, especially\n-- propositional truncation:\n\ndata ∥_∥ (A : Type ℓ) : Type ℓ where\n ∣_∣ : A → ∥ A ∥\n squash : ∀ (x y : ∥ A ∥) → x ≡ y\n\n-- This lets us define mere existence:\n∃ : ∀ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') → Type (ℓ-max ℓ ℓ')\n∃ A B = ∥ Σ A B ∥\n\n-- This is very useful to specify things where existence is weaker\n-- than Σ. This lets us define things like surjective functions or the\n-- image of a map which we cannot define properly in pre-HoTT type\n-- theory.\n\n-- We can define the recursor by pattern-matching\nrec : {P : Type ℓ} → isProp P → (A → P) → ∥ A ∥ → P\nrec Pprop f ∣ x ∣ = f x\nrec Pprop f (squash x y i) = Pprop (rec Pprop f x) (rec Pprop f y) i\n\n-- And the eliminator then follows easily:\nelim : {P : ∥ A ∥ → Type ℓ} → ((a : ∥ A ∥) → isProp (P a)) →\n ((x : A) → P ∣ x ∣) → (a : ∥ A ∥) → P a\nelim {P = P} Pprop f a =\n rec (Pprop a) (λ x → transport (λ i → P (squash ∣ x ∣ a i)) (f x)) a\n\n-- A very important point is that propositional truncation is proof\n-- relevant, so even though the elements are all equal one can still\n-- extract interesting information from them. A fun example is the\n-- \"cost monad\" which can be found in Cubical.HITs.Cost. There we pair\n-- A with ∥ ℕ ∥ and use the truncated number to count the number of\n-- recursive calls in various functions. As the number is truncated it\n-- doesn't affect any properties of the functions, but by running\n-- concrete computations we can extract the number of calls.\n\n\n-------------------------------------------------------------------------\n-- Another source of HITs are inspired by topology\n\n-- We can define the circle as the following simple data declaration:\ndata S¹ : Type₀ where\n base : S¹\n loop : base ≡ base\n\n-- We can write functions on S¹ using pattern-matching:\ndouble : S¹ → S¹\ndouble base = base\ndouble (loop i) = (loop ∙ loop) i\n\n-- Note that loop takes an i : I argument. This is not very surprising\n-- as it's a path base ≡ base, but it's an important difference to\n-- HoTT. Having the native notion of equality be heterogeneous makes\n-- it possible to quite directly define a general schema for a large\n-- class of HITs (more or less all in the HoTT book, with the\n-- exception for the Cauchy reals (I think?)).\n\n-- Let's use univalence to compute some winding numbers on the\n-- circle. We first define a family of types over the circle whos\n-- fibers are the integers.\nhelix : S¹ → Type₀\nhelix base = Int\nhelix (loop i) = sucPath i\n\n-- The loopspace of the circle\nΩS¹ : Type₀\nΩS¹ = base ≡ base\n\n-- We can then define a function computing how many times we've looped\n-- around the circle by:\nwinding : ΩS¹ → Int\nwinding p = subst helix p (pos 0)\n\n-- This reduces just fine:\n_ : winding (λ i → double ((loop ∙ loop) i)) ≡ pos 4\n_ = refl\n\n-- This would not reduce in HoTT as univalence is an axiom. Having\n-- things compute makes it possible to substantially simplify many\n-- proofs from HoTT in Cubical Agda, more about this later.\n\n-- We can in fact prove that winding is an equivalence, this relies on\n-- the encode-decode method and Egbert will go through the proof in\n-- detail. For details about how this proof looks in Cubical Agda see:\n--\n-- Cubical.HITs.S1.Base\n\n-- Complex multiplication on S¹, used in the Hopf fibration\n_⋆_ : S¹ → S¹ → S¹\nbase ⋆ x = x\nloop i ⋆ base = loop i\nloop i ⋆ loop j =\n hcomp (λ k → λ { (i = i0) → loop (j ∨ ~ k)\n ; (i = i1) → loop (j ∧ k)\n ; (j = i0) → loop (i ∨ ~ k)\n ; (j = i1) → loop (i ∧ k) })\n base\n\n-- We can define the Torus as:\ndata Torus : Type₀ where\n point : Torus\n line1 : point ≡ point\n line2 : point ≡ point\n square : PathP (λ i → line1 i ≡ line1 i) line2 line2\n\n-- The square corresponds to the usual folding diagram from topology:\n--\n-- line1\n-- p ----------> p\n-- ^ ^\n-- ¦ ¦\n-- line2 ¦ ¦ line2\n-- ¦ ¦\n-- p ----------> p\n-- line1\n\n-- Proving that it is equivalent to two circles is pretty much trivial:\nt2c : Torus → S¹ × S¹\nt2c point = (base , base)\nt2c (line1 i) = (loop i , base)\nt2c (line2 j) = (base , loop j)\nt2c (square i j) = (loop i , loop j)\n\nc2t : S¹ × S¹ → Torus\nc2t (base , base) = point\nc2t (loop i , base) = line1 i\nc2t (base , loop j) = line2 j\nc2t (loop i , loop j) = square i j\n\nc2t-t2c : (t : Torus) → c2t (t2c t) ≡ t\nc2t-t2c point = refl\nc2t-t2c (line1 _) = refl\nc2t-t2c (line2 _) = refl\nc2t-t2c (square _ _) = refl\n\nt2c-c2t : (p : S¹ × S¹) → t2c (c2t p) ≡ p\nt2c-c2t (base , base) = refl\nt2c-c2t (base , loop _) = refl\nt2c-c2t (loop _ , base) = refl\nt2c-c2t (loop _ , loop _) = refl\n\n-- Using univalence we get the following equality:\nTorus≡S¹×S¹ : Torus ≡ S¹ × S¹\nTorus≡S¹×S¹ = isoToPath (iso t2c c2t t2c-c2t c2t-t2c)\n\n-- We can also directly compute winding numbers on the torus\nwindingTorus : point ≡ point → Int × Int\nwindingTorus l = ( winding (λ i → proj₁ (t2c (l i)))\n , winding (λ i → proj₂ (t2c (l i))))\n\n_ : windingTorus (line1 ∙ sym line2) ≡ (pos 1 , negsuc 0)\n_ = refl\n\n-- This proof turned out to be much more complicated in HoTT as\n-- eliminators out of HITs don't compute definitionally for higher\n-- constructors. In Cubical Agda this is not a problem as all cases\n-- reduce definitionally.\n\n-- We have many more topological examples in the library, including\n-- Klein bottle, RP^n, higher spheres, suspensions, join, wedges,\n-- smash product:\n-- open import Cubical.HITs.KleinBottle\n-- open import Cubical.HITs.RPn\n-- open import Cubical.HITs.S2\n-- open import Cubical.HITs.S3\n-- open import Cubical.HITs.Susp\n-- open import Cubical.HITs.Join\n-- open import Cubical.HITs.Wedge\n-- open import Cubical.HITs.SmashProduct\n\n-- There's also a proof of the \"3x3 lemma\" for pushouts in less than\n-- 200LOC. In HoTT-Agda this took about 3000LOC. For details see:\n-- https://github.com/HoTT/HoTT-Agda/tree/master/theorems/homotopy/3x3\n-- open import Cubical.HITs.Pushout\n\n-- We also defined the Hopf fibration and proved that its total space\n-- is S³ in about 300LOC:\n-- open import Cubical.HITs.Hopf\n\n-- There is also some integer cohomology:\n-- open import Cubical.ZCohomology.Everything\n-- To compute cohomology groups of various spaces we need a bunch of\n-- interesting theorems: Freudenthal suspension theorem,\n-- Mayer-Vietoris sequence...\n\n\n-- For further references about doing synthetic algebraic topology in\n-- Cubical Agda see:\n\n-- Cubical Synthetic Homotopy Theory\n-- Anders Mörtberg, Loïc Pujet\n-- https://staff.math.su.se/anders.mortberg/papers/cubicalsynthetic.pdf\n\n-- Synthetic Cohomology Theory in Cubical Agda\n-- Guillaume Brunerie, Anders Mörtberg, Axel Ljungström.\n-- https://staff.math.su.se/anders.mortberg/papers/zcohomology.pdf\n\n\n--- The end! ---\n\n", "meta": {"hexsha": "d3e688e48827c8da0c3d9945dcdd071a6d5d29bb", "size": 11364, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "04-cubical-type-theory/material/Part4.agda", "max_stars_repo_name": "williamdemeo/EPIT-2020", "max_stars_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "04-cubical-type-theory/material/Part4.agda", "max_issues_repo_name": "williamdemeo/EPIT-2020", "max_issues_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "04-cubical-type-theory/material/Part4.agda", "max_forks_repo_name": "williamdemeo/EPIT-2020", "max_forks_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-08-02T16:16:34.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-02T16:16:34.000Z", "avg_line_length": 34.8588957055, "max_line_length": 73, "alphanum_fraction": 0.6482752552, "num_tokens": 3683, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929104825007, "lm_q2_score": 0.7772998611746912, "lm_q1q2_score": 0.6062883810352911}} {"text": "module Structure.Operator.Monoid.Category where\n\nopen import Data\nopen import Data.Tuple as Tuple using (_,_)\nopen import Functional\nimport Lvl\nopen import Structure.Setoid\nopen import Structure.Category\nopen import Structure.Categorical.Properties\nopen import Structure.Operator.Monoid\nopen import Structure.Operator.Monoid.Homomorphism\nopen import Structure.Operator.Properties using (associativity ; identityₗ ; identityᵣ)\nopen import Structure.Operator\nopen import Type\n\nprivate variable ℓ ℓₑ ℓₗ ℓₗₑ : Lvl.Level\nprivate variable T : Type{ℓ}\nprivate variable _▫_ : T → T → T\n\nmodule _\n ⦃ equiv : Equiv{ℓₑ}(T) ⦄\n ⦃ oper : BinaryOperator(_▫_) ⦄\n (M : Monoid{T = T}(_▫_))\n where\n\n -- A monoid as a special case of a category with a single object and morphisms in and out of this object.\n -- Composition and identity in the category is the binary operator and the identity element from the monoid.\n monoidCategory : Category{Obj = Unit{Lvl.𝟎}}(const(const(T)))\n Category._∘_ monoidCategory = (_▫_)\n Category.id monoidCategory = Monoid.id(M)\n Category.binaryOperator monoidCategory = oper\n Category.associativity monoidCategory = Morphism.intro(associativity(_▫_))\n Category.identity monoidCategory = Morphism.intro (identityₗ(_▫_)(Monoid.id(M))) , Morphism.intro ((identityᵣ(_▫_)(Monoid.id(M))))\n\nmodule _ where\n open import Function.Equals\n open import Function.Equals.Proofs\n open import Function.Proofs\n open import Logic.Predicate\n open import Logic.Propositional\n open import Structure.Function.Multi\n open import Structure.Function\n open import Structure.Relator.Equivalence\n open import Structure.Relator.Properties\n open import Syntax.Function\n open import Syntax.Transitivity\n\n private variable x y z : MonoidObject{ℓₗ}{ℓₗₑ}\n\n instance\n [→ᵐᵒⁿᵒⁱᵈ]-equiv : Equiv(x →ᵐᵒⁿᵒⁱᵈ y)\n Equiv._≡_ [→ᵐᵒⁿᵒⁱᵈ]-equiv ([∃]-intro F) ([∃]-intro G) = F ⊜ G\n Reflexivity.proof (Equivalence.reflexivity (Equiv.equivalence [→ᵐᵒⁿᵒⁱᵈ]-equiv)) = reflexivity(_⊜_)\n Symmetry.proof (Equivalence.symmetry (Equiv.equivalence [→ᵐᵒⁿᵒⁱᵈ]-equiv)) = symmetry(_⊜_)\n Transitivity.proof (Equivalence.transitivity (Equiv.equivalence [→ᵐᵒⁿᵒⁱᵈ]-equiv)) = transitivity(_⊜_)\n\n -- Identity monoid homomorphism.\n idᵐᵒⁿᵒⁱᵈ : x →ᵐᵒⁿᵒⁱᵈ x\n ∃.witness idᵐᵒⁿᵒⁱᵈ = id\n Homomorphism.function (∃.proof idᵐᵒⁿᵒⁱᵈ) = id-function\n Preserving.proof (Homomorphism.preserve-op (∃.proof idᵐᵒⁿᵒⁱᵈ)) = reflexivity(_≡_)\n Preserving.proof (Homomorphism.preserve-id (∃.proof idᵐᵒⁿᵒⁱᵈ)) = reflexivity(_≡_)\n\n -- Composition of monoid homomorphisms.\n _∘ᵐᵒⁿᵒⁱᵈ_ : let _ = x in (y →ᵐᵒⁿᵒⁱᵈ z) → (x →ᵐᵒⁿᵒⁱᵈ y) → (x →ᵐᵒⁿᵒⁱᵈ z)\n ∃.witness (([∃]-intro F) ∘ᵐᵒⁿᵒⁱᵈ ([∃]-intro G)) = F ∘ G\n Homomorphism.function (∃.proof (([∃]-intro F) ∘ᵐᵒⁿᵒⁱᵈ ([∃]-intro G))) = [∘]-function {f = F}{g = G}\n Preserving.proof (Homomorphism.preserve-op (∃.proof (_∘ᵐᵒⁿᵒⁱᵈ_ {x = A} {y = B} {z = C} ([∃]-intro F) ([∃]-intro G)))) {x} {y} =\n (F ∘ G)(x ⦗ MonoidObject._▫_ A ⦘ y) 🝖[ _≡_ ]-[]\n F(G(x ⦗ MonoidObject._▫_ A ⦘ y)) 🝖[ _≡_ ]-[ congruence₁(F) (preserving₂(G) (MonoidObject._▫_ A) (MonoidObject._▫_ B)) ]\n F(G(x) ⦗ MonoidObject._▫_ B ⦘ G(y)) 🝖[ _≡_ ]-[ preserving₂(F) (MonoidObject._▫_ B) (MonoidObject._▫_ C) ]\n F(G(x)) ⦗ MonoidObject._▫_ C ⦘ F(G(y)) 🝖[ _≡_ ]-[]\n (F ∘ G)(x) ⦗ MonoidObject._▫_ C ⦘ (F ∘ G)(y) 🝖-end\n Preserving.proof (Homomorphism.preserve-id (∃.proof (_∘ᵐᵒⁿᵒⁱᵈ_ {x = A} {y = B} {z = C} ([∃]-intro F) ([∃]-intro G)))) =\n (F ∘ G)(MonoidObject.id A) 🝖[ _≡_ ]-[]\n F(G(MonoidObject.id A)) 🝖[ _≡_ ]-[ congruence₁(F) (preserving₀(G) (MonoidObject.id A) (MonoidObject.id B)) ]\n F(MonoidObject.id B) 🝖[ _≡_ ]-[ preserving₀(F) (MonoidObject.id B) (MonoidObject.id C) ]\n MonoidObject.id C 🝖-end\n\n -- A category where the objects are monoids themselves and the morphisms are homomorphism between them.\n instance\n monoidObjectCategory : Category{Obj = MonoidObject{ℓₗ}{ℓₗₑ}}(_→ᵐᵒⁿᵒⁱᵈ_)\n Category._∘_ monoidObjectCategory = _∘ᵐᵒⁿᵒⁱᵈ_\n Category.id monoidObjectCategory = idᵐᵒⁿᵒⁱᵈ\n Category.binaryOperator monoidObjectCategory = intro(\\p q → [⊜][∘]-binaryOperator-raw p q)\n Category.associativity monoidObjectCategory = Morphism.intro (reflexivity(_⊜_))\n Category.identity monoidObjectCategory = [∧]-intro (Morphism.intro(reflexivity(_⊜_))) (Morphism.intro(reflexivity(_⊜_)))\n\n monoidObjectCategoryObject : ∀{ℓₗ ℓₑ} → CategoryObject\n monoidObjectCategoryObject{ℓₗ}{ℓₑ} = intro(monoidObjectCategory{ℓₗ}{ℓₑ})\n", "meta": {"hexsha": "65eed4dea7f018e5d23016a7bc171a128754ce29", "size": 4594, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Operator/Monoid/Category.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Operator/Monoid/Category.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Operator/Monoid/Category.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.4835164835, "max_line_length": 138, "alphanum_fraction": 0.6760992599, "num_tokens": 1871, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357563664174, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.6062785912892663}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\n\nmodule Numbers.Modulo.Definition where\n\nrecord ℤn (n : ℕ) .(pr : 0 Set where\n refl : x == x\n\ndata Maybe (A : Set) : Set where\n nothing : Maybe A\n just : A -> Maybe A\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\ndata Fin : Nat -> Set where\n fzero : {n : Nat} -> Fin (suc n)\n fsuc : {n : Nat} -> Fin n -> Fin (suc n)\n\ndata List (A : Set) : Set where\n ε : List A\n _,_ : List A -> A -> List A\n\nlength : forall {A} -> List A -> Nat\nlength ε = zero\nlength (xs , x) = suc (length xs)\n\ninfixl 25 _,_\n\n-- Raw terms\n\ndata Expr : Set where\n varʳ : Nat -> Expr\n _•ʳ_ : Expr -> Expr -> Expr\n ƛʳ_ : Expr -> Expr\n\ninfixl 90 _•ʳ_\ninfix 50 ƛʳ_\n\n-- Types\n\ndata Type : Set where\n ι : Type\n _⟶_ : Type -> Type -> Type\n\ninfixr 40 _⟶_\n\n-- Typed terms\n\nCtx = List Type\n\ndata Var : Ctx -> Type -> Set where\n vz : forall {Γ τ} -> Var (Γ , τ) τ\n vs : forall {Γ τ σ} -> Var Γ τ -> Var (Γ , σ) τ\n\ndata Term : Ctx -> Type -> Set where\n var : forall {Γ τ} -> Var Γ τ -> Term Γ τ\n _•_ : forall {Γ τ σ} -> Term Γ (τ ⟶ σ) -> Term Γ τ -> Term Γ σ\n ƛ_ : forall {Γ τ σ} -> Term (Γ , σ) τ -> Term Γ (σ ⟶ τ)\n\ninfixl 90 _•_\ninfix 50 ƛ_\n\n-- Type erasure\n\n⌊_⌋ˣ : forall {Γ τ} -> Var Γ τ -> Nat\n⌊ vz ⌋ˣ = zero\n⌊ vs x ⌋ˣ = suc ⌊ x ⌋ˣ\n\n⌊_⌋ : forall {Γ τ} -> Term Γ τ -> Expr\n⌊ var v ⌋ = varʳ ⌊ v ⌋ˣ\n⌊ s • t ⌋ = ⌊ s ⌋ •ʳ ⌊ t ⌋\n⌊ ƛ t ⌋ = ƛʳ ⌊ t ⌋\n\n-- Type equality\n\ninfix 30 _≟_\n\n_≟_ : (σ τ : Type) -> Maybe (σ == τ)\nι ≟ ι = just refl\nσ₁ ⟶ τ₁ ≟ σ₂ ⟶ τ₂ with σ₁ ≟ σ₂ | τ₁ ≟ τ₂\nσ ⟶ τ ≟ .σ ⟶ .τ | just refl | just refl = just refl\n_ ⟶ _ ≟ _ ⟶ _ | _ | _ = nothing\n_ ≟ _ = nothing\n\n-- The type checked view\n\n -- ok : forall {Γ τ e} -> Check ⌊ e ⌋ -- unsolved metas with no range!\n\ndata Check (Γ : Ctx)(τ : Type) : Expr -> Set where\n ok : (t : Term Γ τ) -> Check Γ τ ⌊ t ⌋\n bad : {e : Expr} -> Check Γ τ e\n\ndata Infer (Γ : Ctx) : Expr -> Set where\n yes : (τ : Type)(t : Term Γ τ) -> Infer Γ ⌊ t ⌋\n no : {e : Expr} -> Infer Γ e\n\ndata Lookup (Γ : Ctx) : Nat -> Set where\n found : (τ : Type)(x : Var Γ τ) -> Lookup Γ ⌊ x ⌋ˣ\n outofscope : {n : Nat} -> Lookup Γ n\n\nlookup : (Γ : Ctx)(n : Nat) -> Lookup Γ n\nlookup ε n = outofscope\nlookup (Γ , τ) zero = found τ vz\nlookup (Γ , σ) (suc n) with lookup Γ n\nlookup (Γ , σ) (suc .(⌊ x ⌋ˣ)) | found τ x = found τ (vs x)\nlookup (Γ , σ) (suc n) | outofscope = outofscope\n\ninfix 20 _⊢_∋_ _⊢_∈\n\n_⊢_∈ : (Γ : Ctx)(e : Expr) -> Infer Γ e\n\n_⊢_∋_ : (Γ : Ctx)(τ : Type)(e : Expr) -> Check Γ τ e\nΓ ⊢ ι ∋ ƛʳ e = bad\nΓ ⊢ (σ ⟶ τ) ∋ ƛʳ e with Γ , σ ⊢ τ ∋ e\nΓ ⊢ (σ ⟶ τ) ∋ ƛʳ .(⌊ t ⌋) | ok t = ok (ƛ t)\nΓ ⊢ (σ ⟶ τ) ∋ ƛʳ _ | bad = bad\nΓ ⊢ τ ∋ e with Γ ⊢ e ∈\nΓ ⊢ τ ∋ .(⌊ t ⌋) | yes σ t with τ ≟ σ\nΓ ⊢ τ ∋ .(⌊ t ⌋) | yes .τ t | just refl = ok t\nΓ ⊢ τ ∋ .(⌊ t ⌋) | yes σ t | nothing = bad\nΓ ⊢ τ ∋ e | no = bad\n\n\nΓ ⊢ varʳ i ∈ with lookup Γ i\nΓ ⊢ varʳ .(⌊ x ⌋ˣ) ∈ | found τ x = yes τ (var x)\nΓ ⊢ varʳ _ ∈ | outofscope = no\nΓ ⊢ e₁ •ʳ e₂ ∈ with Γ ⊢ e₁ ∈\nΓ ⊢ e₁ •ʳ e₂ ∈ | no = no\nΓ ⊢ .(⌊ t₁ ⌋) •ʳ e₂ ∈ | yes ι t₁ = no\nΓ ⊢ .(⌊ t₁ ⌋) •ʳ e₂ ∈ | yes (σ ⟶ τ) t₁ with Γ ⊢ σ ∋ e₂\nΓ ⊢ .(⌊ t₁ ⌋) •ʳ .(⌊ t₂ ⌋) ∈ | yes (σ ⟶ τ) t₁ | ok t₂ = yes τ (t₁ • t₂)\nΓ ⊢ .(⌊ t₁ ⌋) •ʳ _ ∈ | yes (σ ⟶ τ) t₁ | bad = no\nΓ ⊢ ƛʳ e ∈ = no\n\n-- Proving completeness (for normal terms)\n\n-- Needs magic with\n\n{-\nmutual\n data Nf : forall {Γ τ} -> Term Γ τ -> Set where\n ƛ-nf : forall {Γ σ τ} -> {t : Term (Γ , σ) τ} -> Nf t -> Nf (ƛ t)\n ne-nf : forall {Γ τ} -> {t : Term Γ τ} -> Ne t -> Nf t\n\n data Ne : forall {Γ τ} -> Term Γ τ -> Set where\n •-ne : forall {Γ σ τ} ->\n {t₁ : Term Γ (σ ⟶ τ)} -> Ne t₁ ->\n {t₂ : Term Γ σ} -> Nf t₂ -> Ne (t₁ • t₂)\n var-ne : forall {Γ τ} -> {x : Var Γ τ} -> Ne (var x)\n\nmutual\n complete-check : forall {Γ τ} -> (t : Term Γ τ) -> Nf t ->\n Γ ⊢ τ ∋ ⌊ t ⌋ == ok t\n complete-check ._ (ƛ-nf t) = {! !}\n complete-check _ (ne-nf n) with complete-infer _ n\n complete-check t (ne-nf n) | p = {! !}\n\n complete-infer : forall {Γ τ} -> (t : Term Γ τ) -> Ne t ->\n Γ ⊢ ⌊ t ⌋ ∈ == yes τ t\n complete-infer t ne = {! !}\n-}\n\n-- Testing\n\ntest1 = ε ⊢ ι ⟶ ι ∋ ƛʳ varʳ zero\ntest2 = ε , ι , ι ⟶ ι ⊢ varʳ zero •ʳ varʳ (suc zero) ∈\n", "meta": {"hexsha": "a8f2da37c342148d5072e87f5b6c7c7e8b91c6cf", "size": 4393, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tests/beyond/SimpleTypes.agda", "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_issues_repo_path": "tests/beyond/SimpleTypes.agda", "max_issues_repo_name": "andrejtokarcik/agda-semantics", "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/beyond/SimpleTypes.agda", "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.8192090395, "max_line_length": 79, "alphanum_fraction": 0.4784885044, "num_tokens": 2086, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289388083214156, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.6060028269827042}} {"text": "\nmodule LF where\n\ndata Zero : Set where\n\nrecord One : Set where\n\n★ : One\n★ = record {}\n\nOne-elim : (C : One -> Set) -> C ★ -> (a : One) -> C a\nOne-elim C h _ = h\n\nOne-elim₁ : (C : One -> Set1) -> C ★ -> (a : One) -> C a\nOne-elim₁ C h _ = h\n\n-- data One' : Set1 where\n-- ★' : One'\n\ndata Two : Set where\n ★₀ : Two\n ★₁ : Two\n\ncase₂ : {A : Set1} -> Two -> A -> A -> A\ncase₂ ★₀ x y = x\ncase₂ ★₁ x y = y\n\ndata _+_ (A : Set)(B : Set) : Set where\n inl : A -> A + B\n inr : B -> A + B\n\nrecord _×_ (A : Set)(B : A -> Set) : Set where\n field\n π₀ : A\n π₁ : B π₀\n\nopen _×_ public\n\n_,_ : {A : Set}{B : A -> Set}(a : A) -> B a -> A × B\nx , y = record { π₀ = x; π₁ = y }\n\n_*_ : (A B : Set) -> Set\nA * B = A × \\_ -> B\n\n-- data _×'_ (A : Set)(B : A -> Set1) : Set1 where\n-- _,'_ : (a : A) -> B a -> A ×' B\n-- \n-- π₀' : {A : Set}{B : A -> Set1} -> A ×' B -> A\n-- π₀' (a ,' b) = a\n-- \n-- π₁' : {A : Set}{B : A -> Set1}(p : A ×' B) -> B (π₀' p)\n-- π₁' (a ,' b) = b\n\n\n", "meta": {"hexsha": "53554ef70076219cc29b6231e2e881c014b712a6", "size": 960, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/iird/LF.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/iird/LF.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/iird/LF.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.4545454545, "max_line_length": 58, "alphanum_fraction": 0.421875, "num_tokens": 434, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289388083214156, "lm_q2_score": 0.7310585727705127, "lm_q1q2_score": 0.6060028221255437}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\nopen import Categories.Functor hiding (id)\n\nmodule Categories.Diagram.Colimit.Properties\n {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {J : Category o′ ℓ′ e′} (F : Functor J C) where\n\nprivate\n module F = Functor F\n module C = Category C\n open C\n\nopen import Categories.Diagram.Limit F.op\nopen import Categories.Diagram.Colimit F\nopen import Categories.Category.Construction.Cocones F\nopen import Categories.Diagram.Duality C\n\nmodule _ (X : Obj) (coapex₁ : Coapex X) (coapex₂ : Coapex X) (L : Colimit) where\n private\n module coapex₁ = Coapex coapex₁\n module coapex₂ = Coapex coapex₂\n module L = Colimit L\n\n K₁ : Cocone\n K₁ = record { coapex = coapex₁ }\n module K₁ = Cocone K₁\n\n K₂ : Cocone\n K₂ = record { coapex = coapex₂ }\n module K₂ = Cocone K₂\n\n coψ-≈⇒rep-≈ : (∀ A → coapex₁.ψ A ≈ coapex₂.ψ A) → L.rep K₁ ≈ L.rep K₂\n coψ-≈⇒rep-≈ = ψ-≈⇒rep-≈ X (Coapex⇒coApex X coapex₁) (Coapex⇒coApex X coapex₂) (Colimit⇒coLimit L)\n", "meta": {"hexsha": "36a8494bb9ea1d5f81fbba9dcfb1a4acf566e3d6", "size": 1020, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Diagram/Colimit/Properties.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Diagram/Colimit/Properties.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Diagram/Colimit/Properties.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 29.1428571429, "max_line_length": 99, "alphanum_fraction": 0.668627451, "num_tokens": 398, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467738423873, "lm_q2_score": 0.6893056231680121, "lm_q1q2_score": 0.6060008147995742}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\n\nmodule Categories.Category.Site {o ℓ e} (C : Category o ℓ e) where\n\nopen import Level\nopen import Data.Product using (Σ; _,_; ∃₂)\n\nopen Category C\n\nprivate\n variable\n X Y Z : Obj\n\nrecord Coverage {i} j {I : Obj → Set i}\n (covering₀ : ∀ {X} → I X → Obj)\n (covering₁ : ∀ {X} (i : I X) → covering₀ i ⇒ X) : Set (i ⊔ suc j ⊔ o ⊔ ℓ ⊔ e) where\n field\n J : ∀ (g : Y ⇒ Z) → Set j\n universal₀ : ∀ {g : Y ⇒ Z} → J g → Obj\n universal₁ : ∀ {g : Y ⇒ Z} (j : J g) → universal₀ j ⇒ Y\n commute : ∀ {g : Y ⇒ Z} (j : J g) → ∃₂ (λ i k → g ∘ universal₁ j ≈ covering₁ i ∘ k)\n\nrecord Site i j : Set (suc i ⊔ suc j ⊔ o ⊔ ℓ ⊔ e) where\n field\n I : Obj → Set i\n covering₀ : ∀ {X} → I X → Obj\n covering₁ : ∀ {X} (i : I X) → covering₀ i ⇒ X\n coverage : Coverage j covering₀ covering₁\n\n module coverage = Coverage coverage\n open coverage public\n", "meta": {"hexsha": "51198a829f2d873672022d174c509fe2809da5e1", "size": 968, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Site.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/Site.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/Site.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 28.4705882353, "max_line_length": 99, "alphanum_fraction": 0.5351239669, "num_tokens": 342, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898127684335, "lm_q2_score": 0.668880247169804, "lm_q1q2_score": 0.6059986898978742}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Algebra.Monoid.Construct.Unit where\n\nopen import Cubical.Core.Everything\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Algebra.Monoid\nopen import Cubical.Data.Prod using (_,_)\n\nopen import Cubical.Data.Unit\n\nimport Cubical.Algebra.Semigroup.Construct.Unit as ⊤Semigroup\nopen ⊤Semigroup public hiding (⊤-isSemigroup; ⊤-Semigroup)\n\n◯-identityˡ : LeftIdentity tt _◯_\n◯-identityˡ _ = refl\n\n◯-identityʳ : RightIdentity tt _◯_\n◯-identityʳ _ = refl\n\n◯-identity : Identity tt _◯_\n◯-identity = ◯-identityˡ , ◯-identityʳ\n\n\n⊤-isMonoid : IsMonoid ⊤ _◯_ tt\n⊤-isMonoid = record\n { isSemigroup = ⊤Semigroup.⊤-isSemigroup\n ; identity = ◯-identity\n }\n\n⊤-Monoid : Monoid ℓ-zero\n⊤-Monoid = record { isMonoid = ⊤-isMonoid }\n", "meta": {"hexsha": "364f861418b542be487ab5df0cd7ce93587b3b48", "size": 790, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Monoid/Construct/Unit.agda", "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Monoid/Construct/Unit.agda", "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Monoid/Construct/Unit.agda", "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.6875, "max_line_length": 61, "alphanum_fraction": 0.7303797468, "num_tokens": 282, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972684083609, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.605899416700182}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Polynomial.Parameters\n\nmodule Polynomial.Homomorphism.Semantics\n {c r₁ r₂ r₃}\n (homo : Homomorphism c r₁ r₂ r₃)\n where\n\n\nopen import Data.Product using (_,_)\nopen import Data.List using ([])\nopen import Data.Vec as Vec using (Vec)\nopen import Data.Fin using (Fin)\n\nopen import Function\n\nopen import Polynomial.Homomorphism.Lemmas homo\nopen import Polynomial.NormalForm homo\nopen Homomorphism homo\nopen import Polynomial.Reasoning ring\n\nopen import Polynomial.Exponentiation rawRing\n\nκ-hom : ∀ {n}\n → (x : Raw.Carrier)\n → (Ρ : Vec Carrier n)\n → ⟦ κ x ⟧ Ρ ≈ ⟦ x ⟧ᵣ\nκ-hom x _ = refl\n\nι-hom : ∀ {n} → (i : Fin n) → (Ρ : Vec Carrier n) → ⟦ ι i ⟧ Ρ ≈ Vec.lookup Ρ i\nι-hom i Ρ′ =\n let (ρ , Ρ) = drop-1 (Fin⇒≤ i) Ρ′\n in\n begin\n ⟦ (κ Raw.1# Δ 1 ∷↓ []) Π↓ Fin⇒≤ i ⟧ Ρ′\n ≈⟨ Π↓-hom (κ Raw.1# Δ 1 ∷↓ []) (Fin⇒≤ i) Ρ′ ⟩\n Σ?⟦ κ Raw.1# Δ 1 ∷↓ [] ⟧ (ρ , Ρ)\n ≈⟨ ∷↓-hom-s (κ Raw.1#) 0 [] ρ Ρ ⟩\n ρ * ⟦ κ Raw.1# ⟧ Ρ\n ≈⟨ *≫ 1-homo ⟩\n ρ * 1#\n ≈⟨ *-identityʳ ρ ⟩\n ρ\n ≡⟨ drop-1⇒lookup i Ρ′ ⟩\n Vec.lookup Ρ′ i\n ∎\n", "meta": {"hexsha": "c6b88686bf9b0672ca99cf9e09dcf2f1d5b32d35", "size": 1097, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Polynomial/Homomorphism/Semantics.agda", "max_stars_repo_name": "mckeankylej/agda-ring-solver", "max_stars_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2019-01-25T16:40:52.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-15T00:57:55.000Z", "max_issues_repo_path": "src/Polynomial/Homomorphism/Semantics.agda", "max_issues_repo_name": "mckeankylej/agda-ring-solver", "max_issues_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2019-04-17T20:48:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T01:55:42.000Z", "max_forks_repo_path": "src/Polynomial/Homomorphism/Semantics.agda", "max_forks_repo_name": "mckeankylej/agda-ring-solver", "max_forks_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2019-04-16T02:23:16.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-20T07:07:11.000Z", "avg_line_length": 22.8541666667, "max_line_length": 78, "alphanum_fraction": 0.5670009116, "num_tokens": 488, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110540642805, "lm_q2_score": 0.679178686187839, "lm_q1q2_score": 0.60569906002717}} {"text": "-- {-# OPTIONS -v tc.cc:12 -v tc.cover.splittree:10 #-}\n-- {-# OPTIONS -v tc.cover.strategy:100 -v tc.cover.precomputed:100 #-}\n-- {-# OPTIONS -v tc.cover.split.con:20 #-}\nmodule CoverStrategy where\n\nimport Common.Level\nopen import Common.Prelude renaming (Nat to ℕ)\n\ndata _∼_ : ℕ → ℕ → Set where\n pr : ∀ {n} → suc n ∼ n\n eq : ∀ {n} → n ∼ n\n\nmax : ∀ {m n} → m ∼ n → ℕ\nmax (pr {n}) = suc n\nmax (eq {n}) = n\n\ndata Tree : ℕ → Set where\n node : ∀ {hˡ hʳ} (bal : hˡ ∼ hʳ) → Tree (max bal)\n\n-- 'test' only passes if we split first on 'Tree hˡ' and then on 'hˡ ∼ hʳ'\n-- This refutes a split strategy that prefers all-constructor columns\n-- over those with catch-alls.\ntest : ∀ {hˡ hʳ} → Tree hˡ → hˡ ∼ hʳ → Set\ntest (node pr) pr = ℕ\ntest (node eq) pr = ℕ\ntest x eq = ℕ\n\n{- We cannot split on 'Tree hˡ' if we have already split on 'hˡ ∼ hʳ'\nbla : ∀ {hˡ hʳ} → Tree hˡ → hˡ ∼ hʳ → Set\nbla nod pr = {!nod!}\nbla nod eq = {!!}\n-}\n\n", "meta": {"hexsha": "b03ad0f4b958b011c06a11ebdea9ae94403c7d14", "size": 937, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/CoverStrategy.agda", "max_stars_repo_name": "np/agda-git-experiment", "max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "test/succeed/CoverStrategy.agda", "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/CoverStrategy.agda", "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.5588235294, "max_line_length": 74, "alphanum_fraction": 0.5859124867, "num_tokens": 364, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110368115783, "lm_q2_score": 0.679178692681616, "lm_q1q2_score": 0.6056990541007242}} {"text": "{-# OPTIONS --without-K --rewriting #-}\nopen import HoTT\n\nopen import stash.modalities.gbm.GbmUtil\n\nmodule stash.modalities.JoinAdj {i j k}\n (A : Type i) (B : Type j) (C : Type k) where\n\n private\n \n module From (f : B → C) (γ : A → hfiber cst f)\n = JoinRec (fst ∘ γ) f (λ a b → app= (snd (γ a)) b)\n\n from-β : (f : B → C) (γ : A → hfiber cst f)\n (a : A) (b : B) → ap (From.f f γ) (jglue a b) == app= (snd (γ a)) b\n from-β f γ a b = From.glue-β f γ a b\n\n to : (A * B → C) → Σ (B → C) (λ f → A → hfiber cst f)\n to φ = φ ∘ right , (λ a → φ (left a) , λ= (λ b → ap φ (glue (a , b))))\n\n from : Σ (B → C) (λ f → A → hfiber cst f) → A * B → C\n from (f , γ) = From.f f γ\n\n abstract\n\n to-from : (ψ : Σ (B → C) (λ f → A → hfiber cst f)) → to (from ψ) == ψ\n to-from (f , γ) = pair= idp (λ= coh)\n\n where coh : (a : A) → from (f , γ) (left a) , λ= (λ b → ap (from (f , γ)) (glue (a , b))) == γ a\n coh a = pair= idp (ap λ= (λ= (λ b → from-β f γ a b)) ∙ ! (λ=-η (snd (γ a))))\n\n from-to : (φ : A * B → C) → from (to φ) == φ\n from-to φ = λ= (Join-elim (λ a → idp) (λ b → idp) (λ a b → ↓-==-in (coh a b)))\n\n where coh : ∀ a b → ap φ (jglue a b) == ap (from (to φ)) (jglue a b) ∙ idp\n coh a b = ap φ (jglue a b)\n =⟨ ! (app=-β (λ b → ap φ (jglue a b)) b) ⟩\n app= (λ= (λ b → ap φ (jglue a b))) b\n =⟨ ! (from-β (fst (to φ)) (snd (to φ)) a b) ⟩\n ap (From.f (fst (to φ)) (snd (to φ))) (jglue a b)\n =⟨ ! (∙-unit-r (ap (from (to φ)) (jglue a b))) ⟩ \n ap (from (to φ)) (jglue a b) ∙ idp\n =∎\n\n join-adj : (A * B → C) ≃ Σ (B → C) (λ f → A → hfiber cst f)\n join-adj = equiv to from to-from from-to\n\n", "meta": {"hexsha": "5be73f0f10b3fae753cf0b6efd2373d05d1ed04d", "size": 1847, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/stash/modalities/JoinAdj.agda", "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 294, "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_issues_repo_path": "theorems/stash/modalities/JoinAdj.agda", "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 31, "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_forks_repo_path": "theorems/stash/modalities/JoinAdj.agda", "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 50, "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "avg_line_length": 38.4791666667, "max_line_length": 104, "alphanum_fraction": 0.4082295615, "num_tokens": 743, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835207180245, "lm_q2_score": 0.72487026428967, "lm_q1q2_score": 0.6056171604725384}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\n\nopen import LogicalFormulae\nopen import Functions.Definition\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import Numbers.Naturals.Order.WellFounded\nopen import Semirings.Definition\nopen import Orders.Total.Definition\nopen import Orders.Partial.Definition\nopen import Orders.WellFounded.Definition\nopen import Orders.WellFounded.Induction\n\nmodule Sets.CantorBijection.Order where\n\norder : Rel (ℕ && ℕ)\norder (a ,, b) (c ,, d) = ((a +N b) b -> Pair a b\n\ndata Unit : Set1 where\n unit : Unit\n\n\n", "meta": {"hexsha": "8bfd76e5fbe80d160e622fc3d94d078f7077ae3e", "size": 122, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/AIM5/PolyDep/TYPE.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/AIM5/PolyDep/TYPE.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/AIM5/PolyDep/TYPE.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 13.5555555556, "max_line_length": 35, "alphanum_fraction": 0.6147540984, "num_tokens": 41, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8577680977182187, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.6053998754174318}} {"text": "\nmodule Oscar.Category where\n\nopen import Oscar.Level\nopen import Oscar.Function\n\nrecord Setoid {𝔬} (𝔒 : Ø 𝔬) 𝔮 : Ø 𝔬 ∙̂ ↑̂ 𝔮 where\n infix 4 _≋_\n field\n _≋_ : 𝔒 → 𝔒 → Ø 𝔮\n ≋-reflexivity : ∀ {x} → x ≋ x\n ≋-symmetry : ∀ {x y} → x ≋ y → y ≋ x\n ≋-transitivity : ∀ {x y} → x ≋ y → ∀ {z} → y ≋ z → x ≋ z\n\nrecord Semigroupoid\n {𝔬} {𝔒 : Ø 𝔬}\n {𝔪} (𝔐 : 𝔒 → 𝔒 → Ø 𝔪)\n {𝔮} (𝔐-setoid : ∀ {x y} → Setoid (𝔐 x y) 𝔮)\n : Ø 𝔬 ∙̂ 𝔪 ∙̂ 𝔮 where\n instance _ = λ {x y} → 𝔐-setoid {x} {y}\n open Setoid ⦃ … ⦄ using (_≋_)\n infixr 9 _∙_\n field\n _∙_ : ∀ {y z} → 𝔐 y z → ∀ {x} → 𝔐 x y → 𝔐 x z\n ∙-extensionality : ∀ {x y} {f₁ f₂ : 𝔐 x y} → f₁ ≋ f₂ → ∀ {z} {g₁ g₂ : 𝔐 y z} → g₁ ≋ g₂ → g₁ ∙ f₁ ≋ g₂ ∙ f₂\n ∙-associativity : ∀ {w x} (f : 𝔐 w x) {y} (g : 𝔐 x y) {z} (h : 𝔐 y z) → (h ∙ g) ∙ f ≋ h ∙ (g ∙ f)\n\nrecord Category\n {𝔬} {𝔒 : Ø 𝔬}\n {𝔪} {𝔐 : 𝔒 → 𝔒 → Ø 𝔪}\n {𝔮} {𝔐-setoid : ∀ {x y} → Setoid (𝔐 x y) 𝔮}\n (semigroupoid : Semigroupoid 𝔐 𝔐-setoid)\n : Ø 𝔬 ∙̂ 𝔪 ∙̂ 𝔮 where\n instance _ = λ {x y} → 𝔐-setoid {x} {y}\n open Setoid ⦃ … ⦄ using (_≋_)\n open Semigroupoid semigroupoid using (_∙_)\n field\n ε : ∀ {x} → 𝔐 x x\n ε-left-identity : ∀ {x y} {f : 𝔐 x y} → ε ∙ f ≋ f\n ε-right-identity : ∀ {x y} {f : 𝔐 x y} → f ∙ ε ≋ f\n\nrecord Semifunctor\n {𝔬₁} {𝔒₁ : Ø 𝔬₁}\n {𝔪₁} {𝔐₁ : 𝔒₁ → 𝔒₁ → Ø 𝔪₁}\n {𝔮₁} {𝔐₁-setoid : ∀ {x y} → Setoid (𝔐₁ x y) 𝔮₁}\n (semigroupoid₁ : Semigroupoid 𝔐₁ 𝔐₁-setoid)\n {𝔬₂} {𝔒₂ : Ø 𝔬₂}\n {𝔪₂} {𝔐₂ : 𝔒₂ → 𝔒₂ → Ø 𝔪₂}\n {𝔮₂} {𝔐₂-setoid : ∀ {x y} → Setoid (𝔐₂ x y) 𝔮₂}\n (semigroupoid₂ : Semigroupoid 𝔐₂ 𝔐₂-setoid)\n : Ø 𝔬₁ ∙̂ 𝔪₁ ∙̂ 𝔮₁ ∙̂ 𝔬₂ ∙̂ 𝔪₂ ∙̂ 𝔮₂\n where\n instance _ = λ {x y} → 𝔐₁-setoid {x} {y}\n instance _ = λ {x y} → 𝔐₂-setoid {x} {y}\n open Setoid ⦃ … ⦄ using (_≋_)\n module ⒈ = Semigroupoid semigroupoid₁\n module ⒉ = Semigroupoid semigroupoid₂\n field\n {μ} : 𝔒₁ → 𝔒₂\n 𝔣 : ∀ {x y} → 𝔐₁ x y → 𝔐₂ (μ x) (μ y)\n 𝔣-extensionality : ∀ {x y} → {f₁ f₂ : 𝔐₁ x y} → f₁ ≋ f₂ → 𝔣 f₁ ≋ 𝔣 f₂\n 𝔣-commutativity : ∀ {x y} {f : 𝔐₁ x y} {z} {g : 𝔐₁ y z} → 𝔣 (g ⒈.∙ f) ≋ 𝔣 g ⒉.∙ 𝔣 f\n\nrecord Functor\n {𝔬₁} {𝔒₁ : Ø 𝔬₁}\n {𝔪₁} {𝔐₁ : 𝔒₁ → 𝔒₁ → Ø 𝔪₁}\n {𝔮₁} {𝔐₁-setoid : ∀ {x y} → Setoid (𝔐₁ x y) 𝔮₁}\n {semigroupoid₁ : Semigroupoid 𝔐₁ 𝔐₁-setoid}\n {𝔬₂} {𝔒₂ : Ø 𝔬₂}\n {𝔪₂} {𝔐₂ : 𝔒₂ → 𝔒₂ → Ø 𝔪₂}\n {𝔮₂} {𝔐₂-setoid : ∀ {x y} → Setoid (𝔐₂ x y) 𝔮₂}\n {semigroupoid₂ : Semigroupoid 𝔐₂ 𝔐₂-setoid}\n (semifunctor : Semifunctor semigroupoid₁ semigroupoid₂)\n (category₁ : Category semigroupoid₁)\n (category₂ : Category semigroupoid₂)\n : Ø 𝔬₁ ∙̂ 𝔪₁ ∙̂ 𝔮₁ ∙̂ 𝔬₂ ∙̂ 𝔪₂ ∙̂ 𝔮₂\n where\n instance _ = λ {x y} → 𝔐₂-setoid {x} {y}\n open Setoid ⦃ … ⦄ using (_≋_)\n open Semifunctor semifunctor using (𝔣; μ)\n module ⒈ = Category category₁\n module ⒉ = Category category₂\n field\n 𝔣-identity : ∀ {x : 𝔒₁} → 𝔣 (⒈.ε {x = x}) ≋ (⒉.ε {x = μ x})\n", "meta": {"hexsha": "6361f43b26866316f732e9241ceee5df3008a1c9", "size": 2756, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-2/Oscar/Category.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-2/Oscar/Category.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-2/Oscar/Category.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.4235294118, "max_line_length": 110, "alphanum_fraction": 0.5174165457, "num_tokens": 1670, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711870587667, "lm_q2_score": 0.712232184238947, "lm_q1q2_score": 0.605376835099036}} {"text": "module Numeral.FixedPositional where\n\n{-\nFixedPositional : ℕ → Type\nFixedPositional(b) = List(𝕟(b))\n\nopen import Numeral.Natural.Oper\n\nprivate variable b : ℕ\n\nto-ℕ : FixedPositional(b) → ℕ\nto-ℕ {_} ∅ = 𝟎\nto-ℕ {b} (n ⊰ l) = 𝕟-to-ℕ (n) + (b ⋅ to-ℕ (l))\n\n-}\n\n{-\nmodule Test2 where\n import Lvl\n open import Data\n open import Data.Boolean hiding (elim)\n open import Data.Boolean.Stmt\n import Data.Boolean.Operators\n open Data.Boolean.Operators.Programming\n open import Numeral.Finite\n open import Numeral.Natural\n open import Functional\n open import Syntax.Number\n open import Type\n open import Type.Dependent\n\n private variable ℓ : Lvl.Level\n private variable z : Bool\n private variable b n : ℕ\n\n positive? : 𝕟(n) → Bool\n positive? 𝟎 = 𝐹\n positive? (𝐒 _) = 𝑇\n\n Positive : 𝕟(n) → Type\n Positive = IsTrue ∘ positive?\n\n data Positional(b : ℕ) : Type{Lvl.𝟎} where\n # : (n : 𝕟(b)) → ⦃ Positive(n) ⦄ → Positional b\n _·_ : Positional b → 𝕟(b) → Positional b\n infixl 20 _·_\n\n test : Positional 10\n test = # 1 · 5 · 0 · 4 · 0 · 0\n\n open import Numeral.Natural.Oper\n\n to-ℕ : Positional b → ℕ\n to-ℕ (# n) = 𝕟-to-ℕ n\n to-ℕ {b} (l · n) = (b ⋅ (to-ℕ l)) + (to-ℕ (# n))\n\n open import Logic.Propositional\n -- open import Numeral.Natural.Decidable\n open import Numeral.Natural.Inductions\n open import Numeral.Natural.Oper.Comparisons\n open import Numeral.Natural.Oper.FlooredDivision\n open import Numeral.Natural.Oper.FlooredDivision.Proofs\n open import Numeral.Natural.Oper.Modulo\n open import Numeral.Natural.Oper.Modulo.Proofs\n open import Numeral.Natural.Relation.Order\n open import Numeral.Natural.Relation.Order.Decidable\n open import Numeral.Natural.Relation.Order.Proofs\n open import Structure.Relator.Ordering\n open import Type.Properties.Decidable\n open import Type.Properties.Decidable.Proofs\n\n from-ℕ-rec : (b : ℕ) → ⦃ b-size : IsTrue(b >? 1) ⦄ → (x : ℕ) → ((prev : ℕ) ⦃ _ : prev < x ⦄ → Positional(b)) → Positional(b)\n from-ℕ-rec b@(𝐒(𝐒 _)) 𝟎 _ = intro 𝐹 (# 𝟎)\n from-ℕ-rec b@(𝐒(𝐒 _)) n@(𝐒 _) prev with prev(n ⌊/⌋ b) ⦃ [⌊/⌋]-ltₗ {n}{b} ⦄\n ... | intro 𝑇 r = intro 𝑇 (r · (ℕ-to-𝕟 (n mod b) ⦃ [↔]-to-[→] decider-true (mod-maxᵣ{n}{b}) ⦄))\n ... | intro 𝐹 r = {!test2 r [≡]-intro!}\n from-ℕ : ⦃ b-size : IsTrue(b >? 1) ⦄ → ℕ → Positional(b)\n from-ℕ b@{𝐒(𝐒 _)} = Strict.Properties.wellfounded-recursion(_<_) (from-ℕ-rec b)\n {-from-ℕ {b = b@(𝐒(𝐒 _))} 𝟎 = intro 𝐹 (# 𝟎)\n from-ℕ {b = b@(𝐒(𝐒 _))} n@(𝐒 _) with [<][≥]-dichotomy {n}{b}\n ... | [∨]-introₗ lt = intro 𝑇 (# (ℕ-to-𝕟 n ⦃ [↔]-to-[→] decider-true lt ⦄))\n ... | [∨]-introᵣ ge with from-ℕ {b} (n ⌊/⌋ b)\n ... | intro 𝑇 nb = intro 𝑇 (nb · ℕ-to-𝕟 (n mod b) ⦃ [↔]-to-[→] decider-true (mod-maxᵣ{n}{b}) ⦄)\n ... | intro 𝐹 _ = intro 𝑇 {!!}-}\n-}\n\nmodule Test where\n open import Data.List\n open import Numeral.Finite\n open import Numeral.Natural\n open import Type\n open import Numeral.Natural.Oper\n\n private variable b : ℕ\n\n to-ℕ : ℕ → List(ℕ) → ℕ\n to-ℕ _ ∅ = 𝟎\n to-ℕ b (n ⊰ l) = n + (b ⋅ to-ℕ b l)\n\n module _ where\n open import Data\n open import Data.Boolean.Stmt\n open import Numeral.Natural.Inductions\n open import Numeral.Natural.Oper.Comparisons\n open import Numeral.Natural.Oper.FlooredDivision\n open import Numeral.Natural.Oper.FlooredDivision.Proofs\n open import Numeral.Natural.Oper.Modulo\n open import Numeral.Natural.Relation\n open import Numeral.Natural.Relation.Order\n open import Relator.Equals\n open import Structure.Relator.Ordering\n\n from-ℕ-rec : (b : ℕ) → ⦃ b-size : IsTrue(b >? 1) ⦄ → (x : ℕ) → ((prev : ℕ) ⦃ _ : prev < x ⦄ → List ℕ) → List ℕ\n from-ℕ-rec b@(𝐒(𝐒 _)) 𝟎 _ = ∅\n from-ℕ-rec b@(𝐒(𝐒 _)) n@(𝐒 _) prev = (n mod b) ⊰ prev(n ⌊/⌋ b) ⦃ [⌊/⌋]-ltₗ {n} {b} ⦄\n from-ℕ : (b : ℕ) → ⦃ b-size : IsTrue(b >? 1) ⦄ → ℕ → List(ℕ)\n from-ℕ b@(𝐒(𝐒 _)) = Strict.Properties.wellfounded-recursion(_<_) (from-ℕ-rec b)\n\n open import Numeral.Natural.Oper.DivMod.Proofs\n open import Numeral.Natural.Oper.Proofs\n open import Structure.Function\n open import Structure.Operator\n open import Structure.Operator.Properties\n open import Syntax.Transitivity\n open import Relator.Equals.Proofs.Equiv\n\n to-from-inverse : ∀{b} ⦃ b-size : IsTrue(b >? 1) ⦄ {n} → (to-ℕ b (from-ℕ b n) ≡ n)\n to-from-inverse {b@(𝐒(𝐒 bb))} {n} = Strict.Properties.wellfounded-recursion-intro(_<_) {rec = from-ℕ-rec b} {φ = \\{n} expr → (to-ℕ b expr ≡ n)} p {n} where\n p : (y : ℕ) → _ → _ → (to-ℕ b (Strict.Properties.accessible-recursion(_<_) (from-ℕ-rec b) y) ≡ y)\n p 𝟎 _ _ = [≡]-intro\n p (𝐒 y) prev step =\n to-ℕ b (Strict.Properties.accessible-recursion(_<_) (from-ℕ-rec b) (𝐒 y)) 🝖[ _≡_ ]-[ congruence₁(to-ℕ b) (step {𝐒(y) ⌊/⌋ b} ⦃ [⌊/⌋]-ltₗ {𝐒 y}{b} ⦄) ]\n (𝐒(y) mod b) + (b ⋅ to-ℕ b (Strict.Properties.accessible-recursion(_<_) (from-ℕ-rec b) (𝐒(y) ⌊/⌋ b))) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)(𝐒(y) mod b) (congruence₂ᵣ(_⋅_)(b) (prev{𝐒(y) ⌊/⌋ b} ⦃ [⌊/⌋]-ltₗ {𝐒 y}{b} ⦄)) ]\n (𝐒(y) mod b) + (b ⋅ (𝐒(y) ⌊/⌋ b)) 🝖[ _≡_ ]-[ commutativity(_+_) {𝐒(y) mod b}{b ⋅ (𝐒(y) ⌊/⌋ b)} ]\n (b ⋅ (𝐒(y) ⌊/⌋ b)) + (𝐒(y) mod b) 🝖[ _≡_ ]-[ [⌊/⌋][mod]-is-division-with-remainder-pred-commuted {𝐒 y}{b} ]\n 𝐒(y) 🝖-end\n\n -- TODO: There are some requirements on l for this to hold. For example, it should not end with zeroes (actually start with because the representation is reversed from the usual one), it should not have numbers greater or equal to b\n {-from-to-inverse : ∀{b} ⦃ b-size : IsTrue(b >? 1) ⦄ {l} → (from-ℕ b (to-ℕ b l) ≡ l)\n from-to-inverse b@{𝐒(𝐒 _)} {l = ∅} = [≡]-intro\n from-to-inverse b@{𝐒(𝐒 _)} {l = x ⊰ l} = {!!}-}\n {-Strict.Properties.wellfounded-recursion-intro(_<_) {rec = from-ℕ-rec b} {φ = \\{n} expr → (expr ≡ from-ℕ b n)} p {x + (b ⋅ to-ℕ b l)} where\n p : (y : ℕ) → _ → _ → (Strict.Properties.accessible-recursion(_<_) (from-ℕ-rec b) y ≡ from-ℕ b y)\n p 𝟎 prev step = {!!}\n p (𝐒 y) prev step = {!!}-}\n\n{-\nmodule _ where\n open import Functional\n open import Function.Iteration using (repeatᵣ)\n open import Numeral.Natural.Induction\n open import Relator.Equals\n open import Relator.Equals.Proofs\n open import Syntax.Function\n open import Syntax.Transitivity\n\n {- TODO: Attempt to prove `∀a∀b. aᵇ = 1 + ((a−1) ⋅ ∑(0‥b) (i ↦ aⁱ))` inductively. An intuitive example of this is: `10³ = 1000 = 1+999 = 1+(9⋅111) = 1+(9⋅(1+10+100)) = 1+((10−1)⋅(10⁰+10¹+10²))`. This can also be proved by using the binomial theorem?\n powerSum : ℕ → ℕ → ℕ\n powerSum a 0 = 0\n powerSum a 1 = 1\n powerSum a (𝐒(𝐒(b))) = (powerSum a (𝐒(b))) + (a ⋅ (powerSum a (𝐒(b))))\n\n exponentiation-is-sum-of-parts : ∀{a b} → (𝐒(a) ^ b ≡ 𝐒(a ⋅ (powerSum (𝐒(a)) b)))\n exponentiation-is-sum-of-parts {a} {0} = [≡]-intro\n exponentiation-is-sum-of-parts {a} {1} = [≡]-intro\n exponentiation-is-sum-of-parts {a} {𝐒(b@(𝐒(_)))} =\n 𝐒(a) ^ 𝐒(b) 🝖[ _≡_ ]-[]\n 𝐒(a) ⋅ (𝐒(a) ^ b) 🝖[ _≡_ ]-[ {!!} ]\n (𝐒(a) ^ b) + (𝐒(a) ⋅ (a ⋅ (powerSum (𝐒(a)) b))) 🝖[ _≡_ ]-[ {!!} ]\n (𝐒(a) ^ b) + (a ⋅ (𝐒(a) ⋅ (powerSum (𝐒(a)) b))) 🝖[ _≡_ ]-[ {!!} ]\n 𝐒(a ⋅ (powerSum (𝐒(a)) b)) + (a ⋅ (𝐒(a) ⋅ (powerSum (𝐒(a)) b))) 🝖[ _≡_ ]-[ {!!} ]\n 𝐒((a ⋅ (powerSum (𝐒(a)) b)) + (a ⋅ (𝐒(a) ⋅ (powerSum (𝐒(a)) b)))) 🝖[ _≡_ ]-[ {!!} ]\n 𝐒(a ⋅ ((powerSum (𝐒(a)) b) + (𝐒(a) ⋅ (powerSum (𝐒(a)) b)))) 🝖[ _≡_ ]-[]\n 𝐒(a ⋅ (powerSum (𝐒(a)) (𝐒(b)))) 🝖-end\n -}\n\nmodule _ where\n open import Data.List.Functions\n open import Numeral.Natural.Relation.Order\n open import Numeral.Natural.Relation.Order.Proofs\n open import Structure.Relator.Properties\n open import Syntax.Transitivity\n\n {-\n FixedPositional-maximum : ∀{n : FixedPositional(b)} → (to-ℕ (n) < b ^ length(n))\n FixedPositional-maximum {_} {∅} = reflexivity(_≤_)\n FixedPositional-maximum {𝐒 b} {n ⊰ l} =\n 𝐒(𝕟-to-ℕ (n) + (𝐒(b) ⋅ to-ℕ (l))) 🝖[ _≤_ ]-[ {!!} ]\n 𝐒(𝕟-to-ℕ (n) + (𝐒(b) ⋅ (b ^ length(l)))) 🝖[ _≤_ ]-[ {!!} ]\n 𝐒(𝕟-to-ℕ (n) + ((b ⋅ (b ^ length(l))) + (1 ⋅ (b ^ length(l))))) 🝖[ _≤_ ]-[ {!!} ]\n 𝐒(𝕟-to-ℕ (n) + ((b ^ 𝐒(length(l))) + (b ^ length(l)))) 🝖[ _≤_ ]-[ {!!} ]\n ? 🝖[ _≤_ ]-[ {!!} \n (b ⋅ (𝐒(b) ^ length(l))) + (𝐒(b) ^ length(l)) 🝖[ _≤_ ]-[ {!!} ]\n 𝐒(b) ⋅ (𝐒(b) ^ length(l)) 🝖-end\n -}\n-}\n", "meta": {"hexsha": "b2e2b020981d19040a2ce0d5f3802e2bd389fc34", "size": 8523, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "old/Numeral/FixedPositional.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "old/Numeral/FixedPositional.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "old/Numeral/FixedPositional.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.2639593909, "max_line_length": 251, "alphanum_fraction": 0.5542649302, "num_tokens": 3695, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711794579723, "lm_q2_score": 0.7122321781307375, "lm_q1q2_score": 0.6053768244937036}} {"text": "\nopen import Oscar.Prelude\nopen import Oscar.Class\nopen import Oscar.Class.Reflexivity\nopen import Oscar.Class.Symmetry\nopen import Oscar.Class.Transitivity\nopen import Oscar.Class.IsEquivalence\nopen import Oscar.Class.Setoid\nopen import Oscar.Data.Proposequality\n\nmodule Oscar.Property.Setoid.Proposextensequality where\n\nmodule _ {𝔬} {𝔒 : Ø 𝔬} {𝔭} {𝔓 : 𝔒 → Ø 𝔭} where\n\n instance\n\n 𝓡eflexivityProposextensequality : Reflexivity.class Proposextensequality⟦ 𝔓 ⟧\n 𝓡eflexivityProposextensequality .⋆ _ = ∅\n\n 𝓢ymmetryProposextensequality : Symmetry.class Proposextensequality⟦ 𝔓 ⟧\n 𝓢ymmetryProposextensequality .⋆ f₁≡̇f₂ x rewrite f₁≡̇f₂ x = ∅\n\n 𝓣ransitivityProposextensequality : Transitivity.class Proposextensequality⟦ 𝔓 ⟧\n 𝓣ransitivityProposextensequality .⋆ f₁≡̇f₂ f₂≡̇f₃ x rewrite f₁≡̇f₂ x = f₂≡̇f₃ x\n\n IsEquivalenceProposextensequality : IsEquivalence Proposextensequality⟦ 𝔓 ⟧\n IsEquivalenceProposextensequality = ∁\n\nmodule _ {𝔬} {𝔒 : Ø 𝔬} {𝔭} (𝔓 : 𝔒 → Ø 𝔭) where\n\n SetoidProposextensequality : Setoid _ _\n SetoidProposextensequality = ∁ Proposextensequality⟦ 𝔓 ⟧\n", "meta": {"hexsha": "2da1360f77a3eaf980abd87f43b2c65370d26cbb", "size": 1094, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-3/src/Oscar/Property/Setoid/Proposextensequality.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-3/src/Oscar/Property/Setoid/Proposextensequality.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-3/src/Oscar/Property/Setoid/Proposextensequality.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.1515151515, "max_line_length": 83, "alphanum_fraction": 0.768738574, "num_tokens": 424, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278664544911, "lm_q2_score": 0.6859494678483918, "lm_q1q2_score": 0.60530092540905}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.MonoidSolver.MonoidExpression where\n\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Data.FinData\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Vec\n\nopen import Cubical.Algebra.CommMonoid\n\nprivate\n variable\n ℓ : Level\n\ninfixl 7 _⊗_\n\n-- Expression in a type M with n variables\ndata Expr (M : Type ℓ) (n : ℕ) : Type ℓ where\n ∣ : Fin n → Expr M n\n ε⊗ : Expr M n\n _⊗_ : Expr M n → Expr M n → Expr M n\n", "meta": {"hexsha": "cc8b1c27ba6d05b143693b7a64ee02c25784bd8c", "size": 474, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/MonoidSolver/MonoidExpression.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_issues_repo_path": "Cubical/Algebra/MonoidSolver/MonoidExpression.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/MonoidSolver/MonoidExpression.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.6086956522, "max_line_length": 58, "alphanum_fraction": 0.7046413502, "num_tokens": 156, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8615382165412808, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.6052564927149089}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Heterogeneous N-ary Functions\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Function.Nary.NonDependent where\n\n------------------------------------------------------------------------\n-- Concrete examples can be found in README.Nary. This file's comments\n-- are more focused on the implementation details and the motivations\n-- behind the design decisions.\n------------------------------------------------------------------------\n\nopen import Level using (Level; 0ℓ; _⊔_; Lift)\nopen import Data.Nat.Base using (ℕ; zero; suc)\nopen import Data.Fin.Base using (Fin; zero; suc)\nopen import Data.Product using (_×_; _,_)\nopen import Data.Product.Nary.NonDependent\nopen import Function.Base using (_∘′_; _$′_; const; flip)\nopen import Relation.Unary using (IUniversal)\nopen import Relation.Binary.PropositionalEquality\n\nprivate\n variable\n a b r : Level\n A : Set a\n B : Set b\n\n------------------------------------------------------------------------\n-- Re-exporting the basic operations\n\nopen import Function.Nary.NonDependent.Base public\n\n------------------------------------------------------------------------\n-- Additional operations on Levels\n\nltabulate : ∀ n → (Fin n → Level) → Levels n\nltabulate zero f = _\nltabulate (suc n) f = f zero , ltabulate n (f ∘′ suc)\n\nlreplicate : ∀ n → Level → Levels n\nlreplicate n ℓ = ltabulate n (const ℓ)\n\n0ℓs : ∀[ Levels ]\n0ℓs = lreplicate _ 0ℓ\n\n------------------------------------------------------------------------\n-- Congruence\n\nmodule _ n {ls} {as : Sets n ls} {R : Set r} (f : as ⇉ R) where\n\n private\n g : Product n as → R\n g = uncurryₙ n f\n\n-- Congruentₙ : ∀ n. ∀ a₁₁ a₁₂ ⋯ aₙ₁ aₙ₂ →\n-- a₁₁ ≡ a₁₂ → ⋯ → aₙ₁ ≡ aₙ₂ →\n-- f a₁₁ ⋯ aₙ₁ ≡ f a₁₂ ⋯ aₙ₂\n\n Congruentₙ : Set (r Level.⊔ ⨆ n ls)\n Congruentₙ = ∀ {l r} → Equalₙ n l r ⇉ (g l ≡ g r)\n\n congₙ : Congruentₙ\n congₙ = curryₙ n (cong g ∘′ fromEqualₙ n)\n\n-- Congruence at a specific location\n\nmodule _ m n {ls ls'} {as : Sets m ls} {bs : Sets n ls'}\n (f : as ⇉ (A → bs ⇉ B)) where\n\n private\n g : Product m as → A → Product n bs → B\n g vs a ws = uncurryₙ n (uncurryₙ m f vs a) ws\n\n congAt : ∀ {vs ws a₁ a₂} → a₁ ≡ a₂ → g vs a₁ ws ≡ g vs a₂ ws\n congAt {vs} {ws} = cong (λ a → g vs a ws)\n\n------------------------------------------------------------------------\n-- Injectivity\n\nmodule _ n {ls} {as : Sets n ls} {R : Set r} (con : as ⇉ R) where\n\n-- Injectiveₙ : ∀ n. ∀ a₁₁ a₁₂ ⋯ aₙ₁ aₙ₂ →\n-- con a₁₁ ⋯ aₙ₁ ≡ con a₁₂ ⋯ aₙ₂ →\n-- a₁₁ ≡ a₁₂ × ⋯ × aₙ₁ ≡ aₙ₂\n\n private\n c : Product n as → R\n c = uncurryₙ n con\n\n Injectiveₙ : Set (r Level.⊔ ⨆ n ls)\n Injectiveₙ = ∀ {l r} → c l ≡ c r → Product n (Equalₙ n l r)\n\n injectiveₙ : (∀ {l r} → c l ≡ c r → l ≡ r) → Injectiveₙ\n injectiveₙ con-inj eq = toEqualₙ n (con-inj eq)\n", "meta": {"hexsha": "3485aa2b780d2a9191cecbdd7399d2e22d385900", "size": 2994, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Function/Nary/NonDependent.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Function/Nary/NonDependent.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Function/Nary/NonDependent.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 30.2424242424, "max_line_length": 72, "alphanum_fraction": 0.4883099532, "num_tokens": 945, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619350028204, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.6052536008755378}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Pointwise lifting of relations to maybes\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Maybe.Relation.Binary.Pointwise where\n\nopen import Level\nopen import Data.Maybe.Base using (Maybe; just; nothing)\nopen import Function.Equivalence using (_⇔_; equivalence)\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as P using (_≡_)\nopen import Relation.Nullary\nimport Relation.Nullary.Decidable as Dec\n\n------------------------------------------------------------------------\n-- Definition\n\ndata Pointwise\n {a b ℓ} {A : Set a} {B : Set b}\n (R : REL A B ℓ) : REL (Maybe A) (Maybe B) (a ⊔ b ⊔ ℓ) where\n just : ∀ {x y} → R x y → Pointwise R (just x) (just y)\n nothing : Pointwise R nothing nothing\n\n------------------------------------------------------------------------\n-- Properties\n\nmodule _ {a b ℓ} {A : Set a} {B : Set b} {R : REL A B ℓ} where\n\n drop-just : ∀ {x y} → Pointwise R (just x) (just y) → R x y\n drop-just (just p) = p\n\n just-equivalence : ∀ {x y} → R x y ⇔ Pointwise R (just x) (just y)\n just-equivalence = equivalence just drop-just\n\n------------------------------------------------------------------------\n-- Relational properties\n\nmodule _ {a r} {A : Set a} {R : Rel A r} where\n\n refl : Reflexive R → Reflexive (Pointwise R)\n refl R-refl {just _} = just R-refl\n refl R-refl {nothing} = nothing\n\n reflexive : _≡_ ⇒ R → _≡_ ⇒ Pointwise R\n reflexive reflexive P.refl = refl (reflexive P.refl)\n\nmodule _ {a b r₁ r₂} {A : Set a} {B : Set b}\n {R : REL A B r₁} {S : REL B A r₂} where\n\n sym : Sym R S → Sym (Pointwise R) (Pointwise S)\n sym R-sym (just p) = just (R-sym p)\n sym R-sym nothing = nothing\n\nmodule _ {a b c r₁ r₂ r₃} {A : Set a} {B : Set b} {C : Set c}\n {R : REL A B r₁} {S : REL B C r₂} {T : REL A C r₃} where\n\n trans : Trans R S T → Trans (Pointwise R) (Pointwise S) (Pointwise T)\n trans R-trans (just p) (just q) = just (R-trans p q)\n trans R-trans nothing nothing = nothing\n\nmodule _ {a r} {A : Set a} {R : Rel A r} where\n\n dec : Decidable R → Decidable (Pointwise R)\n dec R-dec (just x) (just y) = Dec.map just-equivalence (R-dec x y)\n dec R-dec (just x) nothing = no (λ ())\n dec R-dec nothing (just y) = no (λ ())\n dec R-dec nothing nothing = yes nothing\n\n isEquivalence : IsEquivalence R → IsEquivalence (Pointwise R)\n isEquivalence R-isEquivalence = record\n { refl = refl R.refl\n ; sym = sym R.sym\n ; trans = trans R.trans\n } where module R = IsEquivalence R-isEquivalence\n\n isDecEquivalence : IsDecEquivalence R → IsDecEquivalence (Pointwise R)\n isDecEquivalence R-isDecEquivalence = record\n { isEquivalence = isEquivalence R.isEquivalence\n ; _≟_ = dec R._≟_\n } where module R = IsDecEquivalence R-isDecEquivalence\n\nmodule _ {c ℓ} where\n\n setoid : Setoid c ℓ → Setoid c (c ⊔ ℓ)\n setoid S = record\n { isEquivalence = isEquivalence S.isEquivalence\n } where module S = Setoid S\n\n decSetoid : DecSetoid c ℓ → DecSetoid c (c ⊔ ℓ)\n decSetoid S = record\n { isDecEquivalence = isDecEquivalence S.isDecEquivalence\n } where module S = DecSetoid S\n", "meta": {"hexsha": "fbb818299e981749aaaf394300a7e19a216d6686", "size": 3288, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Maybe/Relation/Binary/Pointwise.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Maybe/Relation/Binary/Pointwise.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Maybe/Relation/Binary/Pointwise.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 33.8969072165, "max_line_length": 72, "alphanum_fraction": 0.5754257908, "num_tokens": 998, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619177503205, "lm_q2_score": 0.7341195152660688, "lm_q1q2_score": 0.6052535834141988}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Bisimilarity for Conats\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe --sized-types #-}\n\nmodule Codata.Conat.Bisimilarity where\n\nopen import Size\nopen import Codata.Thunk\nopen import Codata.Conat\nopen import Relation.Binary\n\ninfix 1 _⊢_≈_\ndata _⊢_≈_ i : (m n : Conat ∞) → Set where\n zero : i ⊢ zero ≈ zero\n suc : ∀ {m n} → Thunk^R _⊢_≈_ i m n → i ⊢ suc m ≈ suc n\n\nrefl : ∀ {i m} → i ⊢ m ≈ m\nrefl {m = zero} = zero\nrefl {m = suc m} = suc λ where .force → refl\n\nsym : ∀ {i m n} → i ⊢ m ≈ n → i ⊢ n ≈ m\nsym zero = zero\nsym (suc eq) = suc λ where .force → sym (eq .force)\n\ntrans : ∀ {i m n p} → i ⊢ m ≈ n → i ⊢ n ≈ p → i ⊢ m ≈ p\ntrans zero zero = zero\ntrans (suc eq₁) (suc eq₂) = suc λ where .force → trans (eq₁ .force) (eq₂ .force)\n\ninfix 1 _⊢_≲_\ndata _⊢_≲_ i : (m n : Conat ∞) → Set where\n z≲n : ∀ {n} → i ⊢ zero ≲ n\n s≲s : ∀ {m n} → Thunk^R _⊢_≲_ i m n → i ⊢ suc m ≲ suc n\n\n≈⇒≲ : ∀ {i m n} → i ⊢ m ≈ n → i ⊢ m ≲ n\n≈⇒≲ zero = z≲n\n≈⇒≲ (suc eq) = s≲s λ where .force → ≈⇒≲ (eq .force)\n\n≲-refl : ∀ {i m} → i ⊢ m ≲ m\n≲-refl = ≈⇒≲ refl\n\n≲-antisym : ∀ {i m n} → i ⊢ m ≲ n → i ⊢ n ≲ m → i ⊢ m ≈ n\n≲-antisym z≲n z≲n = zero\n≲-antisym (s≲s le) (s≲s ge) = suc λ where .force → ≲-antisym (le .force) (ge .force)\n\n≲-trans : ∀ {i m n p} → i ⊢ m ≲ n → i ⊢ n ≲ p → i ⊢ m ≲ p\n≲-trans z≲n _ = z≲n\n≲-trans (s≲s le₁) (s≲s le₂) = s≲s λ where .force → ≲-trans (le₁ .force) (le₂ .force)\n", "meta": {"hexsha": "c9e3503a77ea4a5458f18fe3c644e9dbf9ff49a8", "size": 1576, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Codata/Conat/Bisimilarity.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Codata/Conat/Bisimilarity.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Codata/Conat/Bisimilarity.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.3076923077, "max_line_length": 84, "alphanum_fraction": 0.4644670051, "num_tokens": 723, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424450764199, "lm_q2_score": 0.7154240079185319, "lm_q1q2_score": 0.6052075345249749}} {"text": "\nopen import Oscar.Prelude\nopen import Oscar.Class\nopen import Oscar.Class.Leftunit\nopen import Oscar.Class.Reflexivity\nopen import Oscar.Class.Transitivity\n\nmodule Oscar.Class.Transrightidentity where\n\nmodule Transrightidentity\n {𝔬} {𝔒 : Ø 𝔬}\n {𝔯} (_∼_ : 𝔒 → 𝔒 → Ø 𝔯)\n {ℓ} (_∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ)\n (ε : Reflexivity.type _∼_)\n (transitivity : Transitivity.type _∼_)\n = ℭLASS (_∼_ ,, (λ {x y} → _∼̇_ {x} {y}) ,, (λ {x} → ε {x}) ,, (λ {x y z} → transitivity {x} {y} {z}))\n (∀ {x y} {f : x ∼ y} → Leftunit.type _∼̇_ ε transitivity f)\n\nmodule _\n {𝔬} {𝔒 : Ø 𝔬}\n {𝔯} {_∼_ : 𝔒 → 𝔒 → Ø 𝔯}\n {ℓ} {_∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ}\n {ε : Reflexivity.type _∼_}\n {transitivity : Transitivity.type _∼_}\n where\n transrightidentity = Transrightidentity.method _∼_ _∼̇_ ε transitivity\n instance\n toLeftunitFromTransrightidentity :\n ⦃ _ : Transrightidentity.class _∼_ _∼̇_ ε transitivity ⦄\n → ∀ {x y} {f : x ∼ y} → Leftunit.class _∼̇_ ε transitivity f\n toLeftunitFromTransrightidentity .⋆ = transrightidentity\n\nmodule Transrightidentity!\n {𝔬} {𝔒 : Ø 𝔬}\n {𝔯} (_∼_ : 𝔒 → 𝔒 → Ø 𝔯)\n {ℓ} (_∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ)\n ⦃ _ : Reflexivity.class _∼_ ⦄\n ⦃ _ : Transitivity.class _∼_ ⦄\n = Transrightidentity (_∼_) (_∼̇_) reflexivity transitivity\n", "meta": {"hexsha": "1cebd6cc93e3c27beb7afe0a18de1e58ec7c96f2", "size": 1291, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Transrightidentity.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Transrightidentity.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Transrightidentity.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.275, "max_line_length": 104, "alphanum_fraction": 0.5979860573, "num_tokens": 574, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744850834648, "lm_q2_score": 0.7401743563075446, "lm_q1q2_score": 0.6051476682301258}} {"text": "{-# OPTIONS --without-K --safe #-}\n\n-- the usual notion of mate is defined by two isomorphisms between hom set(oid)s are natural,\n-- but due to explicit universe level, a different definition is used.\nmodule Categories.Adjoint.Mate where\n\nopen import Level\nopen import Data.Product using (Σ; _,_)\nopen import Function.Equality using (Π; _⟶_; _⇨_) renaming (_∘_ to _∙_)\nopen import Relation.Binary using (Setoid; IsEquivalence)\n\nopen import Categories.Category\nopen import Categories.Category.Instance.Setoids\nopen import Categories.Functor\nopen import Categories.Functor.Hom\nopen import Categories.NaturalTransformation renaming (id to idN)\nopen import Categories.NaturalTransformation.Equivalence using (_≃_)\nopen import Categories.Adjoint\nimport Categories.Morphism.Reasoning as MR\n\nprivate\n variable\n o ℓ e : Level\n C D : Category o ℓ e\n L L′ R R′ : Functor C D\n\n\n-- this notion of mate can be seen in MacLane in which this notion is shown equivalent to the\n-- definition via naturally isomorphic hom setoids.\nrecord Mate {L : Functor C D}\n (L⊣R : L ⊣ R) (L′⊣R′ : L′ ⊣ R′)\n (α : NaturalTransformation L L′)\n (β : NaturalTransformation R′ R) : Set (levelOfTerm L⊣R ⊔ levelOfTerm L′⊣R′) where\n private\n module L⊣R = Adjoint L⊣R\n module L′⊣R′ = Adjoint L′⊣R′\n module C = Category C\n module D = Category D\n\n field\n commute₁ : (R ∘ˡ α) ∘ᵥ L⊣R.unit ≃ (β ∘ʳ L′) ∘ᵥ L′⊣R′.unit\n commute₂ : L⊣R.counit ∘ᵥ L ∘ˡ β ≃ L′⊣R′.counit ∘ᵥ (α ∘ʳ R′)\n\n -- there are two equivalent commutative diagram\n open NaturalTransformation renaming (commute to η-commute)\n open Functor\n module _ where\n open D\n open HomReasoning\n open MR D\n\n commute₃ : ∀ {X} → L⊣R.counit.η (F₀ L′ X) ∘ F₁ L (η β (F₀ L′ X)) ∘ F₁ L (L′⊣R′.unit.η X) ≈ η α X\n commute₃ {X} = begin\n L⊣R.counit.η (F₀ L′ X) ∘ F₁ L (η β (F₀ L′ X)) ∘ F₁ L (L′⊣R′.unit.η X)\n ≈˘⟨ refl⟩∘⟨ homomorphism L ⟩\n L⊣R.counit.η (F₀ L′ X) ∘ F₁ L (η β (F₀ L′ X) C.∘ L′⊣R′.unit.η X)\n ≈˘⟨ refl⟩∘⟨ F-resp-≈ L commute₁ ⟩\n L⊣R.counit.η (F₀ L′ X) ∘ F₁ L (F₁ R (η α X) C.∘ L⊣R.unit.η X)\n ≈⟨ L⊣R.RLadjunct≈id ⟩\n η α X\n ∎\n\n module _ where\n open C\n open HomReasoning\n open MR C\n\n commute₄ : ∀ {X} → F₁ R (L′⊣R′.counit.η X) ∘ F₁ R (η α (F₀ R′ X)) ∘ L⊣R.unit.η (F₀ R′ X) ≈ η β X\n commute₄ {X} = begin\n F₁ R (L′⊣R′.counit.η X) ∘ F₁ R (η α (F₀ R′ X)) ∘ L⊣R.unit.η (F₀ R′ X)\n ≈˘⟨ pushˡ (homomorphism R) ⟩\n F₁ R (L′⊣R′.counit.η X D.∘ η α (F₀ R′ X)) ∘ L⊣R.unit.η (F₀ R′ X)\n ≈˘⟨ F-resp-≈ R commute₂ ⟩∘⟨refl ⟩\n F₁ R (L⊣R.counit.η X D.∘ F₁ L (η β X)) ∘ L⊣R.unit.η (F₀ R′ X)\n ≈⟨ L⊣R.LRadjunct≈id ⟩\n η β X\n ∎\n\nrecord HaveMate {L L′ : Functor C D} {R R′ : Functor D C}\n (L⊣R : L ⊣ R) (L′⊣R′ : L′ ⊣ R′) : Set (levelOfTerm L⊣R ⊔ levelOfTerm L′⊣R′) where\n field\n α : NaturalTransformation L L′\n β : NaturalTransformation R′ R\n mate : Mate L⊣R L′⊣R′ α β\n\n module α = NaturalTransformation α\n module β = NaturalTransformation β\n open Mate mate public\n\n-- show that the commutative diagram implies natural isomorphism between homsetoids.\n-- the problem is that two homsetoids live in two universe level, in a situation similar to the definition\n-- of adjoint via naturally isomorphic homsetoids.\nmodule _ {L L′ : Functor C D} {R R′ : Functor D C}\n {L⊣R : L ⊣ R} {L′⊣R′ : L′ ⊣ R′}\n {α : NaturalTransformation L L′}\n {β : NaturalTransformation R′ R}\n (mate : Mate L⊣R L′⊣R′ α β) where\n private\n open Mate mate\n open Functor\n module C = Category C\n module D = Category D\n module α = NaturalTransformation α\n module β = NaturalTransformation β\n module L⊣R = Adjoint L⊣R\n module L′⊣R′ = Adjoint L′⊣R′\n\n -- there are two squares to show\n module _ {X : C.Obj} {Y : D.Obj} where\n open Setoid (L′⊣R′.Hom[L-,-].F₀ (X , Y) ⇨ L⊣R.Hom[-,R-].F₀ (X , Y))\n open C hiding (_≈_)\n open MR C\n open C.HomReasoning\n module DH = D.HomReasoning\n\n mate-commute₁ : F₁ Hom[ C ][-,-] (C.id , β.η Y) ∙ L′⊣R′.Hom-inverse.to {X} {Y}\n ≈ L⊣R.Hom-inverse.to {X} {Y} ∙ F₁ Hom[ D ][-,-] (α.η X , D.id)\n mate-commute₁ {f} {g} f≈g = begin\n β.η Y ∘ (F₁ R′ f ∘ L′⊣R′.unit.η X) ∘ C.id ≈⟨ refl⟩∘⟨ identityʳ ⟩\n β.η Y ∘ F₁ R′ f ∘ L′⊣R′.unit.η X ≈⟨ pullˡ (β.commute f) ⟩\n (F₁ R f ∘ β.η (F₀ L′ X)) ∘ L′⊣R′.unit.η X ≈˘⟨ pushʳ commute₁ ⟩\n F₁ R f ∘ F₁ R (α.η X) ∘ L⊣R.unit.η X ≈˘⟨ pushˡ (homomorphism R) ⟩\n F₁ R (f D.∘ α.η X) ∘ L⊣R.unit.η X ≈⟨ F-resp-≈ R (D.∘-resp-≈ˡ f≈g DH.○ DH.⟺ D.identityˡ) ⟩∘⟨refl ⟩\n F₁ R (D.id D.∘ g D.∘ α.η X) ∘ L⊣R.unit.η X ∎\n\n module _ {X : C.Obj} {Y : D.Obj} where\n open Setoid (L′⊣R′.Hom[-,R-].F₀ (X , Y) ⇨ L⊣R.Hom[L-,-].F₀ (X , Y))\n open D hiding (_≈_)\n open MR D\n open D.HomReasoning\n module CH = C.HomReasoning\n\n mate-commute₂ : F₁ Hom[ D ][-,-] (α.η X , D.id) ∙ L′⊣R′.Hom-inverse.from {X} {Y}\n ≈ L⊣R.Hom-inverse.from {X} {Y} ∙ F₁ Hom[ C ][-,-] (C.id , β.η Y)\n mate-commute₂ {f} {g} f≈g = begin\n D.id ∘ (L′⊣R′.counit.η Y ∘ F₁ L′ f) ∘ α.η X ≈⟨ identityˡ ⟩\n (L′⊣R′.counit.η Y ∘ F₁ L′ f) ∘ α.η X ≈˘⟨ pushʳ (α.commute f) ⟩\n L′⊣R′.counit.η Y ∘ α.η (F₀ R′ Y) ∘ F₁ L f ≈˘⟨ pushˡ commute₂ ⟩\n (L⊣R.counit.η Y ∘ F₁ L (β.η Y)) ∘ F₁ L f ≈˘⟨ pushʳ (homomorphism L) ⟩\n L⊣R.counit.η Y ∘ F₁ L (β.η Y C.∘ f) ≈⟨ refl⟩∘⟨ F-resp-≈ L (C.∘-resp-≈ʳ (f≈g CH.○ CH.⟺ C.identityʳ)) ⟩\n L⊣R.counit.η Y ∘ F₁ L (β.η Y C.∘ g C.∘ C.id) ∎\n\n-- alternatively, if commute₃ and commute₄ are shown, then a Mate can be constructed.\n\nmodule _ {L L′ : Functor C D} {R R′ : Functor D C}\n {L⊣R : L ⊣ R} {L′⊣R′ : L′ ⊣ R′}\n {α : NaturalTransformation L L′}\n {β : NaturalTransformation R′ R} where\n private\n open Functor\n module C = Category C\n module D = Category D\n module α = NaturalTransformation α\n module β = NaturalTransformation β\n module L⊣R = Adjoint L⊣R\n module L′⊣R′ = Adjoint L′⊣R′\n\n module _ (commute₃ : ∀ {X} → L⊣R.counit.η (F₀ L′ X) D.∘ F₁ L (β.η (F₀ L′ X)) D.∘ F₁ L (L′⊣R′.unit.η X) D.≈ α.η X) where\n open C\n open HomReasoning\n\n commute₁ : ∀ {X} → F₁ R (α.η X) ∘ L⊣R.unit.η X ≈ β.η (F₀ L′ X) ∘ L′⊣R′.unit.η X\n commute₁ {X} = begin\n F₁ R (α.η X) ∘ L⊣R.unit.η X\n ≈˘⟨ F-resp-≈ R commute₃ ⟩∘⟨refl ⟩\n F₁ R (L⊣R.counit.η (F₀ L′ X) D.∘ F₁ L (β.η (F₀ L′ X)) D.∘ F₁ L (L′⊣R′.unit.η X)) ∘ L⊣R.unit.η X\n ≈˘⟨ F-resp-≈ R (D.∘-resp-≈ʳ (homomorphism L)) ⟩∘⟨refl ⟩\n F₁ R (L⊣R.counit.η (F₀ L′ X) D.∘ F₁ L (β.η (F₀ L′ X) ∘ L′⊣R′.unit.η X)) ∘ L⊣R.unit.η X\n ≈⟨ L⊣R.LRadjunct≈id ⟩\n β.η (F₀ L′ X) ∘ L′⊣R′.unit.η X\n ∎\n\n module _ (commute₄ : ∀ {X} → F₁ R (L′⊣R′.counit.η X) C.∘ F₁ R (α.η (F₀ R′ X)) C.∘ L⊣R.unit.η (F₀ R′ X) C.≈ β.η X) where\n open D\n open HomReasoning\n open MR C\n\n commute₂ : ∀ {X} → L⊣R.counit.η X ∘ F₁ L (β.η X) ≈ L′⊣R′.counit.η X ∘ α.η (F₀ R′ X)\n commute₂ {X} = begin\n L⊣R.counit.η X ∘ F₁ L (β.η X)\n ≈˘⟨ refl⟩∘⟨ F-resp-≈ L commute₄ ⟩\n L⊣R.counit.η X ∘ F₁ L (F₁ R (L′⊣R′.counit.η X) C.∘ F₁ R (α.η (F₀ R′ X)) C.∘ L⊣R.unit.η (F₀ R′ X))\n ≈˘⟨ refl⟩∘⟨ F-resp-≈ L (pushˡ (homomorphism R)) ⟩\n L⊣R.counit.η X ∘ F₁ L (F₁ R (L′⊣R′.counit.η X ∘ α.η (F₀ R′ X)) C.∘ L⊣R.unit.η (F₀ R′ X))\n ≈⟨ L⊣R.RLadjunct≈id ⟩\n L′⊣R′.counit.η X ∘ α.η (F₀ R′ X)\n ∎\n\n\n mate′ : (∀ {X} → L⊣R.counit.η (F₀ L′ X) D.∘ F₁ L (β.η (F₀ L′ X)) D.∘ F₁ L (L′⊣R′.unit.η X) D.≈ α.η X) →\n (∀ {X} → F₁ R (L′⊣R′.counit.η X) C.∘ F₁ R (α.η (F₀ R′ X)) C.∘ L⊣R.unit.η (F₀ R′ X) C.≈ β.η X) →\n Mate L⊣R L′⊣R′ α β\n mate′ commute₃ commute₄ = record\n { commute₁ = commute₁ commute₃\n ; commute₂ = commute₂ commute₄\n }\n", "meta": {"hexsha": "e2e725cb4f8983d6f6535e0e0d1c614219e77f38", "size": 7809, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Adjoint/Mate.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Adjoint/Mate.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Adjoint/Mate.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 39.6395939086, "max_line_length": 121, "alphanum_fraction": 0.5419387886, "num_tokens": 3777, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744761936437, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.6051476663360131}} {"text": "{-# OPTIONS --without-K #-}\nmodule factorial where\n\nopen import Type\nopen import Data.Nat.NP\nopen import Data.Product\nopen import Data.Sum.NP\nopen import Data.Zero\nopen import Data.Maybe\nopen import Data.One using (𝟙)\nopen import Data.Fin.NP using (Fin; Fin′; zero; suc;\n inject₁; inject!;\n Fin▹ℕ; ℕ▹Fin; [zero:_,suc:_])\nopen import Function.NP\nopen import Function.Extensionality\nopen import HoTT\nopen Equivalences\nopen import Type.Identities\nopen import Algebra.FunctionProperties.Eq\n{-\nopen import Function.Related as FR\nopen import Function.Related.TypeIsomorphisms.NP\nimport Function.Inverse.NP as I\nopen I using (_↔_; inverses; module Inverse) renaming (_$₁_ to to; _$₂_ to from)\nopen import Relation.Binary.Product.Pointwise\nopen import Relation.Binary.Sum\n-}\nopen import Relation.Binary.PropositionalEquality.NP\n renaming (!_ to ¡_)\nopen ≡-Reasoning\n\n-- n ! ≡ product [1..n]\n\nmodule v1 where\n _! : ℕ → ℕ\n zero ! = 1\n suc n ! = (1 + n) * n !\n\n _!★ : ℕ → ★\n zero !★ = 𝟙\n suc n !★ = Fin (1 + n) × n !★\n\n module _ {{_ : UA}} where\n !★≡Fin! : ∀ {n} → n !★ ≡ Fin (n !)\n !★≡Fin! {zero} = ¡ Fin1≡𝟙\n !★≡Fin! {suc n} = ×= idp !★≡Fin! ∙ Fin-×-*\n\nmodule v2 where\n _! : ℕ → ℕ\n _+1! : ℕ → ℕ\n\n zero ! = 1\n suc n ! = n +1!\n\n n +1! = n ! + n * n !\n\n _!★ : ℕ → ★\n zero !★ = 𝟙\n suc n !★ = n !★ ⊎ Fin n × n !★\n\n 1+_!★ : ℕ → ★\n 1+ n !★ = n !★ ⊎ Fin n × n !★\n\n module _ {{_ : UA}} where\n !★≡Fin! : ∀ {n} → n !★ ≡ Fin (n !)\n !★≡Fin! {zero} = ¡ Fin1≡𝟙\n !★≡Fin! {suc n} = ⊎= !★≡Fin! (×= idp !★≡Fin! ∙ Fin-×-*)\n ∙ Fin-⊎-+\n\nproductFin : ∀ n → (Fin n → ℕ) → ℕ\nproductFin zero f = 1\nproductFin (suc n) f = f zero * productFin n (f ∘ suc)\n\nproduct[0…_] : ℕ → (ℕ → ℕ) → ℕ\nproduct[0… n ] f = productFin n (f ∘ Fin▹ℕ)\n{-\nproduct[0… zero ] f = 1\nproduct[0… suc n ] f = f zero * product[0… n ] (f ∘ suc)\n-}\n\nproduct[1…_] : ℕ → (ℕ → ℕ) → ℕ\nproduct[1… zero ] f = 1\nproduct[1… suc n ] f = f 1 * product[1… n ] (f ∘ suc)\n\nproduct[_to_] : ℕ → ℕ → (ℕ → ℕ) → ℕ\nproduct[ start to stop ] f = product[0… stop ∸ start ] (f ∘ _+_ start)\n\n{-\ndata Bnd (l : ℕ) : (h : ℕ) → Set where\n low : Bnd l (suc l)\n suc : ∀ {h} → Bnd l h → Bnd l (suc h)\n\nBnd▹ℕ : {l h : ℕ} → Bnd l h → ℕ\nBnd▹ℕ {l} low = l\nBnd▹ℕ (suc x) = suc (Bnd▹ℕ x)\n\nproductBnd : ∀ {l h} → l ≤ h → (Bnd l h → ℕ) → ℕ\nproductBnd z≤n f = {!!}\nproductBnd (s≤s p) f = {!!}\n\nproductBnd p f = {!f low * productBnd l h (f ∘ suc)!}\n-}\n\ntest-product[1…3] : product[1… 3 ] ≡ (λ f → f 1 * (f 2 * (f 3 * 1)))\ntest-product[1…3] = idp\n\nopen v1\n{-\nadequate1 : ∀ n → n ! ≡ product[1… n ] id\nadequate1 zero = ≡.refl\nadequate1 (suc n) rewrite adequate1 n = {!!}\n Π{x∈1…n}x + n * Π{x∈1…n}x\n\n (1 + n) * Π{x∈1…n}x\n\n Π{x∈1…n}1+x\n -}\n\n\nΠ[0…_-1] : ℕ → (ℕ → ℕ) → ★\nΠ[0… n -1] f = Π (Fin n) (Fin ∘ f ∘ Fin▹ℕ)\n\nΠ[0…_] : ℕ → (ℕ → ℕ) → ★\nΠ[0… n ] = Π[0… suc n -1]\n\n{-\nΠ[1…_] : ℕ → (ℕ → ℕ) → ★\nΠ[1… 0 ] f = 𝟙\nΠ[1… suc n ] f = {!!}\n-}\n\nΠ[0…_-1]′ : ℕ → (ℕ → ℕ) → ★\nΠ[0… zero -1]′ f = 𝟙\nΠ[0… suc n -1]′ f = Fin (f 0) × Π[0… n -1]′ (f ∘ suc)\n\nΠ[0…_]′ : ℕ → (ℕ → ℕ) → ★\nΠ[0… n ]′ = Π[0… suc n -1]′\n\n{-\nΠ[1…_]′ : ℕ → (ℕ → ℕ) → ★\nΠ[1… zero ]′ f = 𝟙\nΠ[1… suc n ]′ f = Fin (f 1) × Π[1… n ]′ (f ∘ suc)\n-}\n\n[zero:,suc:] = [zero:_,suc:_]\nsyntax [zero:,suc:] z (λ y → s) = [zero: z ,suc y :→ s ]\n\nΠ! : ℕ → ★\nΠ! n = Π[0… n ] suc\n\n↺ : ℕ → ★\n↺ n = Fin n → Fin n\n\nΠ!↺ : ∀ {n} → Π! n → ↺ (suc n)\nΠ!↺ {n} f = inject! ∘ f\n\nΠ!↺-inj : ∀ {n}(f : Π! n) → Injective (Π!↺ f)\nΠ!↺-inj f {x} {y} e = {!!}\n\n-- Move to Type.Identities\nmodule _ {{_ : UA}}{{_ : FunExt}} where\n ΠMaybe : ∀ {A : ★} {F : Maybe A → ★} →\n Π (Maybe A) F ≡ (F nothing × Π A (F ∘ just))\n ΠMaybe {A} {F}\n = (Π (Maybe A) F)\n ≡⟨ Π≃ Maybe≃𝟙⊎ (maybe (λ _ → idp) idp) ⟩\n (Π (𝟙 ⊎ A) [inl: (λ _ → F nothing) ,inr: F ∘ just ])\n ≡⟨ dist-×-Π ⟩\n ((𝟙 → F nothing) × Π A (F ∘ just))\n ≡⟨ ×= 𝟙→A≡A idp ⟩\n (F nothing × Π A (F ∘ just))\n ∎\n\n ΠFin0≡𝟙 : ∀ {F : Fin 0 → ★} → Π (Fin 0) F ≡ 𝟙\n ΠFin0≡𝟙 = Π= Fin0≡𝟘 (λ()) ∙ Π𝟘-uniq₀ (λ ())\n\n ΠFin1+ : ∀ n {F : Fin (1 + n) → ★} →\n Π (Fin (1 + n)) F ≡ (F zero × Π (Fin n) (F ∘ suc))\n ΠFin1+ n {F}\n = Π (Fin (1 + n)) F\n ≡⟨ Π≃ Fin∘suc≃𝟙⊎Fin [zero: idp ,suc _ :→ idp ] ⟩\n Π (𝟙 ⊎ Fin n) [inl: (λ _ → F zero) ,inr: F ∘ suc ]\n ≡⟨ dist-×-Π[] ⟩\n ((𝟙 → F zero) × Π (Fin n) (F ∘ suc))\n ≡⟨ ×= 𝟙→A≡A idp ⟩\n (F zero × Π (Fin n) (F ∘ suc))\n ∎\n\n rot : ∀ {n} → Fin (suc n) → Fin (suc n)\n rot {n} = [zero: ℕ▹Fin n ,suc: inject₁ ]\n\n ΠFin1+' : ∀ n {F : Fin (1 + n) → ★} →\n Π (Fin (1 + n)) F ≡ (F (ℕ▹Fin n) × Π (Fin n) (F ∘ inject₁))\n ΠFin1+' n {F} =\n Π (Fin (1 + n)) F\n ≡⟨ Π≃ Fin∘suc≃𝟙⊎Fin (λ x → {!WRONG!}) ⟩\n Π (𝟙 ⊎ Fin n) [inl: (λ _ → F {!!}) ,inr: F ∘ {!!} ]\n ≡⟨ {!!} ⟩\n Π (𝟙 ⊎ Fin n) [inl: (λ _ → F (ℕ▹Fin n)) ,inr: F ∘ inject₁ ]\n ≡⟨ dist-×-Π[] ⟩\n ((𝟙 → F (ℕ▹Fin n)) × Π (Fin n) (F ∘ inject₁))\n ≡⟨ ×= 𝟙→A≡A idp ⟩\n (F (ℕ▹Fin n) × Π (Fin n) (F ∘ inject₁))\n ∎\n\n{-\n ΠFin1≡F0 : {F : Fin 1 → ★} → Π (Fin 1) F ≡ F zero\n ΠFin1≡F0 = ΠFin1+ 0 ∙ ×= idp ΠFin0≡𝟙 ∙ A×𝟙≡A\n\n ΠFin2≡F0×F1 : {F : Fin 2 → ★} → Π (Fin 2) F ≡ (F zero × F (suc zero))\n ΠFin2≡F0×F1 = ΠFin1+ 1 ∙ ×= idp ΠFin1≡F0\n\n test-Π[0…-1] : ∀ {f} → Π[0… 0 -1] f ≡ 𝟙\n test-Π[0…-1] = ΠFin0≡𝟙\n\n test-Π[0…0] : ∀ {f} → Π[0… 0 ] f ≡ Fin (f zero)\n test-Π[0…0] = ΠFin1≡F0\n\n test-Π[0…1] : ∀ {f} → Π[0… 1 ] f ≡ (Fin (f zero) × Fin (f (suc zero)))\n test-Π[0…1] = ΠFin2≡F0×F1\n\n ΠFin1+ʳ′ : ∀ n (F : ℕ → ★) →\n Π (Fin (1 + n)) (F ∘ Fin▹ℕ) ≡ (F n × Π (Fin n) (F ∘ Fin▹ℕ))\n ΠFin1+ʳ′ n F\n = Π (Fin (1 + n)) (F ∘ Fin▹ℕ)\n ≡⟨ Π=′ (Fin (1 + n)) F∘Fin▹ℕ≗F' ⟩\n Π (Fin (1 + n)) F'\n ≡⟨ ΠFin1+ n ⟩\n (F' zero × Π (Fin n) (F' ∘ suc))\n ≡⟨by-definition⟩\n (F n × Π (Fin n) (F ∘ Fin▹ℕ))\n ∎\n where F' : (x : Fin (suc n)) → ★₀\n F' zero = F n\n F' (suc x) = F (Fin▹ℕ x)\n F∘Fin▹ℕ≗F' : F ∘ Fin▹ℕ ≗ F'\n F∘Fin▹ℕ≗F' zero = {!!}\n F∘Fin▹ℕ≗F' (suc x₂) = {!!}\n\n{-Π (Fin (1 + n)) (F ∘ Fin▹ℕ)\n ≡⟨ {!!} ⟩\n Π (𝟙 ⊎ Fin n) {!!}\n ≡⟨ {!dist-×-Π!} ⟩\n (F n × Π (Fin n) (F ∘ Fin▹ℕ))\n ∎\n-}\n\nmodule _ {{_ : UA}}{{_ : FunExt}} where\n Π≡Π′[0…_-1] : ∀ n f → Π[0… n -1]′ f ≡ Π[0… n -1] f\n Π≡Π′[0… zero -1] f = ¡ ΠFin0≡𝟙\n Π≡Π′[0… suc n -1] f = Π[0… 1 + n -1]′ f\n ≡⟨by-definition⟩\n (Fin (f 0) × Π[0… n -1]′ (f ∘ suc))\n ≡⟨ ×= idp (Π≡Π′[0… n -1] (f ∘ suc)) ⟩\n (Fin (f 0) × Π[0… n -1] (f ∘ suc))\n ≡⟨ ¡ ΠFin1+ n ⟩\n Π[0… 1 + n -1] f\n ∎\n\n Π≡Π′[0…_] : ∀ n f → Π[0… n ]′ f ≡ Π[0… n ] f\n Π≡Π′[0… n ] = Π≡Π′[0… suc n -1]\n-- (A → B ⊎ C)\n\n-- TODO\n-- adequate! : ∀ n → Fin (suc n) × Fin (n !) ≡ Π (Fin n) (Fin′ ∘ suc)\n\nexample : ∀ {n} → (2 + n)! ≡ (2 + n) * (1 + n)!\nexample = idp\n\nmodule _ {{_ : UA}}{{_ : FunExt}} where\n\n{-\n -- WRONG\n adequate! : ∀ {n} → Fin (n !) ≡ Π[0… n -1] suc\n adequate! {zero} = {!¡ ΠFin1≡F0!}\n adequate! {suc n} = (Fin ((1 + n)!))\n ≡⟨by-definition⟩\n Fin ((1 + n) * n !)\n ≡⟨ ¡ Fin-×-* ⟩\n (Fin (1 + n) × Fin (n !))\n ≡⟨ ×= idp adequate! ⟩\n (Fin (1 + n) × Π[0… n -1] suc)\n ≡⟨ {!ΠFin1+!} ⟩\n (Fin 1 × Π[0… n -1] (_+_ 2))\n ≡⟨ ¡ ΠFin1+ n ⟩\n Π[0… n ] suc\n ∎\n -}\n\n adequate! : ∀ {n} → Fin (n !) ≡ Π[0… n ] suc\n adequate! {zero} = ¡ ΠFin1≡F0\n adequate! {suc n} = (Fin ((1 + n)!))\n ≡⟨by-definition⟩\n Fin ((1 + n) * n !)\n ≡⟨ ¡ Fin-×-* ⟩\n (Fin (1 + n) × Fin (n !))\n ≡⟨ ×= idp adequate! ⟩\n (Fin (1 + n) × Π[0… n ] suc)\n ≡⟨ ¡ ΠFin1+ʳ′ (suc n) _ ⟩\n ((x : Fin (2 + n)) → Fin (suc (Fin▹ℕ x)))\n ≡⟨ idp ⟩\n Π[0… 1 + n ] suc\n ∎\n\n{-\n adequate! : ∀ {n} → Fin ((1 + n)!) ≡ Π[0… n -1] suc\n adequate! {zero} = {!idp!}\n adequate! {suc n} = (Fin ((2 + n)!))\n ≡⟨ {!!} ⟩\n Fin ((1 + n) * (1 + n)!)\n ≡⟨ ¡ Fin-×-* ⟩\n (Fin (1 + n) × Fin ((1 + n)!))\n ≡⟨ ×= idp adequate! ⟩\n (Fin (1 + n) × Π[0… n -1] suc)\n ≡⟨ ¡ (ΠFin1+ʳ′ n (Fin ∘ suc)) ⟩\n Π[0… suc n -1] suc\n ∎\n-}\n{-\n\nHI: (n+1)! ≡ Π n suc\n\n(n+2)!\n(n+2) * (n+1)!\n(n+2) * Π n suc\n(n+1) * Π n suc + Π n suc\n\n(2+n)*(n! * 1+n) \n(n! * 1+n) + (1+n)*(n! * 1+n) \n\n≡ Π n (2+)\n≡ 1 × Π n (2+)\n\n\n(2+n) * Π n suc\nΠ (1+n) suc\n\n-- -}\n-- -}\n-- -}\n-- -}\n-- -}\n", "meta": {"hexsha": "fa8aa5cff726e4dc2a86b0bb91781ecccb938490", "size": 8846, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "experimental-examples/factorial.agda", "max_stars_repo_name": "crypto-agda/explore", "max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z", "max_issues_repo_path": "experimental-examples/factorial.agda", "max_issues_repo_name": "crypto-agda/explore", "max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z", "max_forks_repo_path": "experimental-examples/factorial.agda", "max_forks_repo_name": "crypto-agda/explore", "max_forks_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.7900874636, "max_line_length": 80, "alphanum_fraction": 0.3881980556, "num_tokens": 4436, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430520409023, "lm_q2_score": 0.7279754548076478, "lm_q1q2_score": 0.6050517413196924}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Universe levels\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Level where\n\n-- Levels.\n\nopen import Agda.Primitive as Prim public\n using (Level; _⊔_; Setω)\n renaming (lzero to zero; lsuc to suc)\n\n-- Lifting.\n\nrecord Lift {a} ℓ (A : Set a) : Set (a ⊔ ℓ) where\n constructor lift\n field lower : A\n\nopen Lift public\n\n-- Synonyms\n\n0ℓ : Level\n0ℓ = zero\n\nlevelOfType : ∀ {a} → Set a → Level\nlevelOfType {a} _ = a\n\nlevelOfTerm : ∀ {a} {A : Set a} → A → Level\nlevelOfTerm {a} _ = a\n", "meta": {"hexsha": "2aefd377862bfc939dfa4b0433e3c412c879e1ba", "size": 658, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Level.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Level.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Level.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 18.8, "max_line_length": 72, "alphanum_fraction": 0.490881459, "num_tokens": 177, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8311430645886583, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.605051740643886}} {"text": "module Issue488 where\n\nopen import Data.Product using (∃-syntax; -,_; _×_; _,_)\nopen import Relation.Nullary using (¬_)\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans)\n\nmodule CounterExample where\n\n data Term : Set where\n A B C D : Term\n\n data _—→_ : (M N : Term) → Set where\n B—→C : B —→ C\n C—→B : C —→ B\n B—→A : B —→ A\n C—→D : C —→ D\n\n infix 2 _—↠_\n infix 1 begin_\n infixr 2 _—→⟨_⟩_\n infix 3 _∎\n\n data _—↠_ : Term → Term → Set where\n _∎ : ∀ M\n ---------\n → M —↠ M\n\n _—→⟨_⟩_ : ∀ L {M N}\n → L —→ M\n → M —↠ N\n ---------\n → L —↠ N\n\n begin_ : ∀ {M N}\n → M —↠ N\n ------\n → M —↠ N\n begin M—↠N = M—↠N\n\n diamond : ∀ {L M N}\n → ((L —→ M) × (L —→ N))\n -----------------------------\n → ∃[ P ] ((M —↠ P) × (N —↠ P))\n diamond (B—→A , B—→A) = -, ((A ∎) , (A ∎))\n diamond (C—→B , C—→B) = -, ((B ∎) , (B ∎))\n diamond (B—→C , B—→C) = -, ((C ∎) , (C ∎))\n diamond (C—→D , C—→D) = -, ((D ∎) , (D ∎))\n diamond (B—→C , B—→A) = -, ((begin C —→⟨ C—→B ⟩ B —→⟨ B—→A ⟩ A ∎) , (A ∎))\n diamond (C—→B , C—→D) = -, ((begin B —→⟨ B—→C ⟩ C —→⟨ C—→D ⟩ D ∎) , (D ∎))\n diamond (B—→A , B—→C) = -, ((A ∎) , (begin C —→⟨ C—→B ⟩ B —→⟨ B—→A ⟩ A ∎))\n diamond (C—→D , C—→B) = -, ((D ∎) , (begin B —→⟨ B—→C ⟩ C —→⟨ C—→D ⟩ D ∎))\n\n A—↠A : ∀ {P} → A —↠ P → P ≡ A\n A—↠A (.A ∎) = refl\n\n D—↠D : ∀ {P} → D —↠ P → P ≡ D\n D—↠D (.D ∎) = refl\n\n ¬confluence : ¬ (∀ {L M N}\n → ((L —↠ M) × (L —↠ N))\n -----------------------------\n → ∃[ P ] ((M —↠ P) × (N —↠ P)))\n ¬confluence confluence\n with confluence ( (begin B —→⟨ B—→A ⟩ A ∎)\n , (begin B —→⟨ B—→C ⟩ C —→⟨ C—→D ⟩ D ∎) )\n ... | (P , (A—↠P , D—↠P))\n with trans (sym (A—↠A A—↠P)) (D—↠D D—↠P)\n ... | ()\n\nmodule DeterministicImpliesDiamondPropertyAndConfluence where\n\n infix 2 _—↠_\n infix 1 begin_\n infixr 2 _—→⟨_⟩_\n infix 3 _∎\n\n postulate\n Term : Set\n _—→_ : Term → Term → Set\n\n postulate\n deterministic : ∀ {L M N}\n → L —→ M\n → L —→ N\n ------\n → M ≡ N\n\n data _—↠_ : Term → Term → Set where\n _∎ : ∀ M\n ---------\n → M —↠ M\n\n _—→⟨_⟩_ : ∀ L {M N}\n → L —→ M\n → M —↠ N\n -------\n → L —↠ N\n\n begin_ : ∀ {M N}\n → M —↠ N\n ------\n → M —↠ N\n begin M—↠N = M—↠N\n\n diamond : ∀ {L M N}\n → ((L —→ M) × (L —→ N))\n --------------------\n → ∃[ P ] ((M —↠ P) × (N —↠ P))\n diamond (L—→M , L—→N)\n rewrite deterministic L—→M L—→N = -, ((_ ∎) , (_ ∎))\n\n confluence : ∀ {L M N}\n → (L —↠ M)\n → (L —↠ N)\n --------------------\n → ∃[ P ] ((M —↠ P) × (N —↠ P))\n confluence {L} {.L} { N} (.L ∎) L—↠N = -, (L—↠N , (N ∎))\n confluence {L} { M} {.L} L—↠M (.L ∎) = -, ((M ∎) , L—↠M)\n confluence {L} { M} { N} (.L —→⟨ L—→M′ ⟩ M′—↠M) (.L —→⟨ L—→N′ ⟩ N′—↠N)\n rewrite deterministic L—→M′ L—→N′ = confluence M′—↠M N′—↠N\n", "meta": {"hexsha": "bf46778aa0e8e4dd9c1b174f48b806bb9cce52b1", "size": 2871, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "extra/Issue488.agda", "max_stars_repo_name": "andorp/plfa.github.io", "max_stars_repo_head_hexsha": "5468837f55cbea38d5c5a163e1ea5d48edb92bcc", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1003, "max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z", "max_issues_repo_path": "extra/Issue488.agda", "max_issues_repo_name": "andorp/plfa.github.io", "max_issues_repo_head_hexsha": "5468837f55cbea38d5c5a163e1ea5d48edb92bcc", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 323, "max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z", "max_forks_repo_path": "extra/Issue488.agda", "max_forks_repo_name": "andorp/plfa.github.io", "max_forks_repo_head_hexsha": "5468837f55cbea38d5c5a163e1ea5d48edb92bcc", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 304, "max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z", "avg_line_length": 23.7272727273, "max_line_length": 79, "alphanum_fraction": 0.3556252177, "num_tokens": 1395, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430562234878, "lm_q2_score": 0.7279754489059775, "lm_q1q2_score": 0.6050517394593797}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\nopen import groups.Pointed\n\nmodule groups.Int where\n\nabstract\n ℤ→ᴳ-η : ∀ {i} {G : Group i} (φ : ℤ-group →ᴳ G)\n → GroupHom.f φ ∼ Group.exp G (GroupHom.f φ 1)\n ℤ→ᴳ-η φ (pos 0) = GroupHom.pres-ident φ\n ℤ→ᴳ-η φ (pos 1) = idp\n ℤ→ᴳ-η {G = G} φ (pos (S (S n))) =\n GroupHom.pres-comp φ 1 (pos (S n))\n ∙ ap (Group.comp G (GroupHom.f φ 1)) (ℤ→ᴳ-η φ (pos (S n)))\n ∙ ! (Group.exp-+ G (GroupHom.f φ 1) 1 (pos (S n)))\n ℤ→ᴳ-η φ (negsucc 0) = GroupHom.pres-inv φ 1\n ℤ→ᴳ-η {G = G} φ (negsucc (S n)) =\n GroupHom.pres-comp φ -1 (negsucc n)\n ∙ ap2 (Group.comp G) (GroupHom.pres-inv φ 1) (ℤ→ᴳ-η φ (negsucc n))\n ∙ ! (Group.exp-+ G (GroupHom.f φ 1) -1 (negsucc n))\n\nℤ-idf-η : ∀ i → i == Group.exp ℤ-group 1 i\nℤ-idf-η = ℤ→ᴳ-η (idhom _)\n\nℤ→ᴳ-unicity : ∀ {i} {G : Group i}\n → (φ ψ : ℤ-group →ᴳ G)\n → GroupHom.f φ 1 == GroupHom.f ψ 1\n → GroupHom.f φ ∼ GroupHom.f ψ\nℤ→ᴳ-unicity {G = G} φ ψ p i =\n ℤ→ᴳ-η φ i ∙ ap (λ g₁ → Group.exp G g₁ i) p ∙ ! (ℤ→ᴳ-η ψ i)\n\nℤ→ᴳ-equiv-idf : ∀ {i} (G : Group i) → (ℤ-group →ᴳ G) ≃ Group.El G\nℤ→ᴳ-equiv-idf G = equiv (λ φ → GroupHom.f φ 1) (exp-hom G)\n (λ _ → idp) (λ φ → group-hom= $ λ= $ ! ∘ ℤ→ᴳ-η φ)\n where open Group G\n\nℤ→ᴳ-iso-idf : ∀ {i} (G : AbGroup i) → hom-group ℤ-group G ≃ᴳ AbGroup.grp G\nℤ→ᴳ-iso-idf G = ≃-to-≃ᴳ (ℤ→ᴳ-equiv-idf (AbGroup.grp G)) (λ _ _ → idp)\n\nℤ-⊙group : ⊙Group₀\nℤ-⊙group = ⊙[ ℤ-group , 1 ]ᴳ\n\nℤ-is-infinite-cyclic : is-infinite-cyclic ℤ-⊙group\nℤ-is-infinite-cyclic = is-eq\n (Group.exp ℤ-group 1)\n (idf ℤ)\n (! ∘ ℤ-idf-η)\n (! ∘ ℤ-idf-η)\n", "meta": {"hexsha": "b27e58ed69458b4b0c931a4cdc334e26dce35d3b", "size": 1562, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/groups/Int.agda", "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 294, "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_issues_repo_path": "theorems/groups/Int.agda", "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 31, "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_forks_repo_path": "theorems/groups/Int.agda", "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 50, "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "avg_line_length": 31.24, "max_line_length": 74, "alphanum_fraction": 0.552496799, "num_tokens": 803, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8652240860523328, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.6050117619559473}} {"text": "-- Minimal propositional logic, PHOAS approach, initial encoding\n\nmodule Pi.Mp where\n\n\n-- Types\n\ninfixl 2 _&&_\ninfixl 1 _||_\ninfixr 0 _=>_\ndata Ty : Set where\n UNIT : Ty\n _=>_ : Ty -> Ty -> Ty\n _&&_ : Ty -> Ty -> Ty\n _||_ : Ty -> Ty -> Ty\n FALSE : Ty\n\ninfixr 0 _<=>_\n_<=>_ : Ty -> Ty -> Ty\na <=> b = (a => b) && (b => a)\n\nNOT : Ty -> Ty\nNOT a = a => FALSE\n\nTRUE : Ty\nTRUE = FALSE => FALSE\n\n\n-- Context and truth judgement\n\nCx : Set1\nCx = Ty -> Set\n\nisTrue : Ty -> Cx -> Set\nisTrue a tc = tc a\n\n\n-- Terms\n\nmodule Mp where\n infixl 1 _$_\n data Tm (tc : Cx) : Ty -> Set where\n var : forall {a} -> isTrue a tc -> Tm tc a\n lam' : forall {a b} -> (isTrue a tc -> Tm tc b) -> Tm tc (a => b)\n _$_ : forall {a b} -> Tm tc (a => b) -> Tm tc a -> Tm tc b\n pair' : forall {a b} -> Tm tc a -> Tm tc b -> Tm tc (a && b)\n fst : forall {a b} -> Tm tc (a && b) -> Tm tc a\n snd : forall {a b} -> Tm tc (a && b) -> Tm tc b\n left : forall {a b} -> Tm tc a -> Tm tc (a || b)\n right : forall {a b} -> Tm tc b -> Tm tc (a || b)\n case' : forall {a b c} -> Tm tc (a || b) -> (isTrue a tc -> Tm tc c) -> (isTrue b tc -> Tm tc c) -> Tm tc c\n\n lam'' : forall {tc a b} -> (Tm tc a -> Tm tc b) -> Tm tc (a => b)\n lam'' f = lam' \\x -> f (var x)\n\n case'' : forall {tc a b c} -> Tm tc (a || b) -> (Tm tc a -> Tm tc c) -> (Tm tc b -> Tm tc c) -> Tm tc c\n case'' xy f g = case' xy (\\x -> f (var x)) (\\y -> g (var y))\n\n syntax lam'' (\\a -> b) = lam a => b\n syntax pair' x y = [ x , y ]\n syntax case'' xy (\\x -> z1) (\\y -> z2) = case xy of x => z1 or y => z2\n\n Thm : Ty -> Set1\n Thm a = forall {tc} -> Tm tc a\nopen Mp public\n\n\n-- Example theorems\n\nc1 : forall {a b} -> Thm (a && b <=> b && a)\nc1 =\n [ lam xy => [ snd xy , fst xy ]\n , lam yx => [ snd yx , fst yx ]\n ]\n\nc2 : forall {a b} -> Thm (a || b <=> b || a)\nc2 =\n [ lam xy =>\n case xy\n of x => right x\n or y => left y\n , lam yx =>\n case yx\n of y => right y\n or x => left x\n ]\n\ni1 : forall {a} -> Thm (a && a <=> a)\ni1 =\n [ lam xx => fst xx\n , lam x => [ x , x ]\n ]\n\ni2 : forall {a} -> Thm (a || a <=> a)\ni2 =\n [ lam xx =>\n case xx\n of x => x\n or x => x\n , lam x => left x\n ]\n\nl3 : forall {a} -> Thm ((a => a) <=> TRUE)\nl3 =\n [ lam _ => lam nt => nt\n , lam _ => lam x => x\n ]\n\nl1 : forall {a b c} -> Thm (a && (b && c) <=> (a && b) && c)\nl1 =\n [ lam xyz =>\n (let yz = snd xyz in\n [ [ fst xyz , fst yz ] , snd yz ])\n , lam xyz =>\n (let xy = fst xyz in\n [ fst xy , [ snd xy , snd xyz ] ])\n ]\n\nl2 : forall {a} -> Thm (a && TRUE <=> a)\nl2 =\n [ lam xt => fst xt\n , lam x => [ x , lam nt => nt ]\n ]\n\nl4 : forall {a b c} -> Thm (a && (b || c) <=> (a && b) || (a && c))\nl4 =\n [ lam xyz =>\n (let x = fst xyz in\n case snd xyz\n of y => left [ x , y ]\n or z => right [ x , z ])\n , lam xyxz =>\n case xyxz\n of xy => [ fst xy , left (snd xy) ]\n or xz => [ fst xz , right (snd xz) ]\n ]\n\nl6 : forall {a b c} -> Thm (a || (b && c) <=> (a || b) && (a || c))\nl6 =\n [ lam xyz =>\n case xyz\n of x => [ left x , left x ]\n or yz => [ right (fst yz) , right (snd yz) ]\n , lam xyxz =>\n case fst xyxz\n of x => left x\n or y =>\n case snd xyxz\n of x => left x\n or z => right [ y , z ]\n ]\n\nl7 : forall {a} -> Thm (a || TRUE <=> TRUE)\nl7 =\n [ lam _ => lam nt => nt\n , lam t => right t\n ]\n\nl9 : forall {a b c} -> Thm (a || (b || c) <=> (a || b) || c)\nl9 =\n [ lam xyz =>\n case xyz\n of x => left (left x)\n or yz =>\n case yz\n of y => left (right y)\n or z => right z\n , lam xyz =>\n case xyz\n of xy =>\n case xy\n of x => left x\n or y => right (left y)\n or z => right (right z)\n ]\n\nl11 : forall {a b c} -> Thm ((a => (b && c)) <=> (a => b) && (a => c))\nl11 =\n [ lam xyz =>\n [ lam x => fst (xyz $ x)\n , lam x => snd (xyz $ x)\n ]\n , lam xyxz =>\n lam x => [ fst xyxz $ x , snd xyxz $ x ]\n ]\n\nl12 : forall {a} -> Thm ((a => TRUE) <=> TRUE)\nl12 =\n [ lam _ => lam nt => nt\n , lam t => lam _ => t\n ]\n\nl13 : forall {a b c} -> Thm ((a => (b => c)) <=> ((a && b) => c))\nl13 =\n [ lam xyz =>\n lam xy => xyz $ fst xy $ snd xy\n , lam xyz =>\n lam x =>\n lam y => xyz $ [ x , y ]\n ]\n\nl16 : forall {a b c} -> Thm (((a && b) => c) <=> (a => (b => c)))\nl16 =\n [ lam xyz =>\n lam x =>\n lam y => xyz $ [ x , y ]\n , lam xyz =>\n lam xy => xyz $ fst xy $ snd xy\n ]\n\nl17 : forall {a} -> Thm ((TRUE => a) <=> a)\nl17 =\n [ lam tx => tx $ (lam nt => nt)\n , lam x => lam _ => x\n ]\n\nl19 : forall {a b c} -> Thm (((a || b) => c) <=> (a => c) && (b => c))\nl19 =\n [ lam xyz =>\n [ lam x => xyz $ left x\n , lam y => xyz $ right y\n ]\n , lam xzyz =>\n lam xy =>\n case xy\n of x => fst xzyz $ x\n or y => snd xzyz $ y\n ]\n", "meta": {"hexsha": "deb5b0d3a4374b08ec2ba5e823afa724c136b448", "size": 5096, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Pi/Mp.agda", "max_stars_repo_name": "mietek/formal-logic", "max_stars_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_stars_repo_licenses": ["X11"], "max_stars_count": 26, "max_stars_repo_stars_event_min_datetime": "2015-08-31T09:49:52.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-13T12:37:44.000Z", "max_issues_repo_path": "src/Pi/Mp.agda", "max_issues_repo_name": "mietek/formal-logic", "max_issues_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_issues_repo_licenses": ["X11"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Pi/Mp.agda", "max_forks_repo_name": "mietek/formal-logic", "max_forks_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_forks_repo_licenses": ["X11"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.2532751092, "max_line_length": 111, "alphanum_fraction": 0.3950156986, "num_tokens": 1930, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256631249076, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.604931195970521}} {"text": "\n-- Proof irrelevance is nice when you want to work with subsets.\nmodule Subset where\n\ndata True : Prop where\n tt : True\n\ndata False : Prop where\n\ndata (|) (A:Set)(P:A -> Prop) : Set where\n sub : (x:A) -> P x -> A | P\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\nmutual\n IsEven : Nat -> Prop\n IsEven zero = True\n IsEven (suc n) = IsOdd n\n\n IsOdd : Nat -> Prop\n IsOdd zero = False\n IsOdd (suc n) = IsEven n\n\nEven : Set\nEven = Nat | IsEven\n\nOdd : Set\nOdd = Nat | IsOdd\n\n(+) : Nat -> Nat -> Nat\nzero + m = m\nsuc n + m = suc (n + m)\n\n", "meta": {"hexsha": "cc26ed971332ade95bb015b4ce26fd937b3fddd8", "size": 556, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/Subset.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/Subset.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/outdated-and-incorrect/Subset.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 15.4444444444, "max_line_length": 64, "alphanum_fraction": 0.5809352518, "num_tokens": 200, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9441768541530197, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.6048735331241119}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\r\nmodule Cubical.Algebra.Monoid.Base where\r\n\r\nopen import Cubical.Foundations.Prelude\r\nopen import Cubical.Foundations.Equiv\r\nopen import Cubical.Foundations.Equiv.HalfAdjoint\r\nopen import Cubical.Foundations.Function\r\nopen import Cubical.Foundations.HLevels\r\nopen import Cubical.Foundations.Isomorphism\r\nopen import Cubical.Foundations.Univalence\r\nopen import Cubical.Foundations.Transport\r\nopen import Cubical.Foundations.SIP\r\n\r\nopen import Cubical.Data.Sigma\r\n\r\nopen import Cubical.Structures.Axioms\r\nopen import Cubical.Structures.Auto\r\nopen import Cubical.Algebra.Semigroup hiding (⟨_⟩)\r\n\r\nopen Iso\r\n\r\nprivate\r\n variable\r\n ℓ : Level\r\n\r\nrecord IsMonoid {A : Type ℓ} (ε : A) (_·_ : A → A → A) : Type ℓ where\r\n constructor ismonoid\r\n\r\n field\r\n isSemigroup : IsSemigroup _·_\r\n identity : (x : A) → (x · ε ≡ x) × (ε · x ≡ x)\r\n\r\n open IsSemigroup isSemigroup public\r\n\r\n lid : (x : A) → ε · x ≡ x\r\n lid x = identity x .snd\r\n\r\n rid : (x : A) → x · ε ≡ x\r\n rid x = identity x .fst\r\n\r\n\r\nrecord Monoid : Type (ℓ-suc ℓ) where\r\n constructor monoid\r\n\r\n field\r\n Carrier : Type ℓ\r\n ε : Carrier\r\n _·_ : Carrier → Carrier → Carrier\r\n isMonoid : IsMonoid ε _·_\r\n\r\n infixl 7 _·_\r\n\r\n open IsMonoid isMonoid public\r\n\r\n -- semigrp : Semigroup\r\n -- semigrp = record { isSemigroup = isSemigroup }\r\n\r\n -- open Semigroup semigrp public\r\n\r\n\r\n-- Extractor for the carrier type\r\n⟨_⟩ : Monoid → Type ℓ\r\n⟨_⟩ = Monoid.Carrier\r\n\r\nη-isMonoid : {A : Type ℓ} {ε : A} {_∙_ : A → A → A} (b : IsMonoid ε _∙_)\r\n → ismonoid (IsMonoid.isSemigroup b) (IsMonoid.identity b) ≡ b\r\nIsMonoid.isSemigroup (η-isMonoid b i) = IsMonoid.isSemigroup b\r\nIsMonoid.identity (η-isMonoid b i) = IsMonoid.identity b\r\n\r\n-- Easier to use constructors\r\n\r\nmakeIsMonoid : {M : Type ℓ} {ε : M} {_·_ : M → M → M}\r\n (is-setM : isSet M)\r\n (assoc : (x y z : M) → x · (y · z) ≡ (x · y) · z)\r\n (rid : (x : M) → x · ε ≡ x)\r\n (lid : (x : M) → ε · x ≡ x)\r\n → IsMonoid ε _·_\r\nIsMonoid.isSemigroup (makeIsMonoid is-setM assoc rid lid) = issemigroup is-setM assoc\r\nIsMonoid.identity (makeIsMonoid is-setM assoc rid lid) = λ x → rid x , lid x\r\n\r\nmakeMonoid : {M : Type ℓ} (ε : M) (_·_ : M → M → M)\r\n (is-setM : isSet M)\r\n (assoc : (x y z : M) → x · (y · z) ≡ (x · y) · z)\r\n (rid : (x : M) → x · ε ≡ x)\r\n (lid : (x : M) → ε · x ≡ x)\r\n → Monoid\r\nmakeMonoid ε _·_ is-setM assoc rid lid =\r\n monoid _ ε _·_ (makeIsMonoid is-setM assoc rid lid)\r\n\r\nrecord MonoidEquiv (M N : Monoid {ℓ}) : Type ℓ where\r\n\r\n constructor monoidiso\r\n\r\n private\r\n module M = Monoid M\r\n module N = Monoid N\r\n\r\n field\r\n e : ⟨ M ⟩ ≃ ⟨ N ⟩\r\n presε : equivFun e M.ε ≡ N.ε\r\n isHom : (x y : ⟨ M ⟩) → equivFun e (x M.· y) ≡ equivFun e x N.· equivFun e y\r\n\r\n\r\n\r\nmodule MonoidΣTheory {ℓ} where\r\n\r\n RawMonoidStructure : Type ℓ → Type ℓ\r\n RawMonoidStructure X = X × (X → X → X)\r\n\r\n RawMonoidEquivStr = AutoEquivStr RawMonoidStructure\r\n\r\n rawMonoidUnivalentStr : UnivalentStr _ RawMonoidEquivStr\r\n rawMonoidUnivalentStr = autoUnivalentStr RawMonoidStructure\r\n\r\n MonoidAxioms : (M : Type ℓ) → RawMonoidStructure M → Type ℓ\r\n MonoidAxioms M (e , _·_) = IsSemigroup _·_\r\n × ((x : M) → (x · e ≡ x) × (e · x ≡ x))\r\n\r\n MonoidStructure : Type ℓ → Type ℓ\r\n MonoidStructure = AxiomsStructure RawMonoidStructure MonoidAxioms\r\n\r\n MonoidΣ : Type (ℓ-suc ℓ)\r\n MonoidΣ = TypeWithStr ℓ MonoidStructure\r\n\r\n isPropMonoidAxioms : (M : Type ℓ) (s : RawMonoidStructure M) → isProp (MonoidAxioms M s)\r\n isPropMonoidAxioms M (e , _·_) =\r\n isPropΣ (isPropIsSemigroup _·_)\r\n λ α → isPropΠ λ _ → isProp× (IsSemigroup.is-set α _ _) (IsSemigroup.is-set α _ _)\r\n\r\n MonoidEquivStr : StrEquiv MonoidStructure ℓ\r\n MonoidEquivStr = AxiomsEquivStr RawMonoidEquivStr MonoidAxioms\r\n\r\n MonoidAxiomsIsoIsMonoid : {M : Type ℓ} (s : RawMonoidStructure M)\r\n → Iso (MonoidAxioms M s) (IsMonoid (s .fst) (s .snd))\r\n fun (MonoidAxiomsIsoIsMonoid s) (x , y) = ismonoid x y\r\n inv (MonoidAxiomsIsoIsMonoid s) a = (IsMonoid.isSemigroup a) , IsMonoid.identity a\r\n rightInv (MonoidAxiomsIsoIsMonoid s) b = η-isMonoid b\r\n leftInv (MonoidAxiomsIsoIsMonoid s) _ = refl\r\n\r\n MonoidAxioms≡IsMonoid : {M : Type ℓ} (s : RawMonoidStructure M)\r\n → MonoidAxioms M s ≡ IsMonoid (s .fst) (s .snd)\r\n MonoidAxioms≡IsMonoid s = isoToPath (MonoidAxiomsIsoIsMonoid s)\r\n open Monoid\r\n Monoid→MonoidΣ : Monoid → MonoidΣ\r\n Monoid→MonoidΣ M =\r\n ⟨ M ⟩ , ((ε M) , _·_ M) , MonoidAxiomsIsoIsMonoid ((ε M) , _·_ M) .inv (isMonoid M)\r\n\r\n MonoidΣ→Monoid : MonoidΣ → Monoid\r\n MonoidΣ→Monoid (M , (ε , _·_) , isMonoidΣ) =\r\n monoid M ε _·_ (MonoidAxiomsIsoIsMonoid (ε , _·_) .fun isMonoidΣ)\r\n\r\n MonoidIsoMonoidΣ : Iso Monoid MonoidΣ\r\n MonoidIsoMonoidΣ =\r\n iso Monoid→MonoidΣ MonoidΣ→Monoid (λ _ → refl) helper\r\n where\r\n helper : _\r\n Carrier (helper a i) = ⟨ a ⟩\r\n ε (helper a i) = ε a\r\n _·_ (helper a i) = _·_ a\r\n isMonoid (helper a i) = η-isMonoid (isMonoid a) i\r\n\r\n monoidUnivalentStr : UnivalentStr MonoidStructure MonoidEquivStr\r\n monoidUnivalentStr = axiomsUnivalentStr _ isPropMonoidAxioms rawMonoidUnivalentStr\r\n\r\n MonoidΣPath : (M N : MonoidΣ) → (M ≃[ MonoidEquivStr ] N) ≃ (M ≡ N)\r\n MonoidΣPath = SIP monoidUnivalentStr\r\n\r\n MonoidEquivΣ : (M N : Monoid) → Type ℓ\r\n MonoidEquivΣ M N = Monoid→MonoidΣ M ≃[ MonoidEquivStr ] Monoid→MonoidΣ N\r\n\r\n MonoidIsoΣPath : {M N : Monoid} → Iso (MonoidEquiv M N) (MonoidEquivΣ M N)\r\n fun MonoidIsoΣPath (monoidiso e h1 h2) = (e , h1 , h2)\r\n inv MonoidIsoΣPath (e , h1 , h2) = monoidiso e h1 h2\r\n rightInv MonoidIsoΣPath _ = refl\r\n leftInv MonoidIsoΣPath _ = refl\r\n\r\n MonoidPath : (M N : Monoid) → (MonoidEquiv M N) ≃ (M ≡ N)\r\n MonoidPath M N =\r\n MonoidEquiv M N ≃⟨ isoToEquiv MonoidIsoΣPath ⟩\r\n MonoidEquivΣ M N ≃⟨ MonoidΣPath _ _ ⟩\r\n Monoid→MonoidΣ M ≡ Monoid→MonoidΣ N ≃⟨ isoToEquiv (invIso (congIso MonoidIsoMonoidΣ)) ⟩\r\n M ≡ N ■\r\n\r\n RawMonoidΣ : Type (ℓ-suc ℓ)\r\n RawMonoidΣ = TypeWithStr ℓ RawMonoidStructure\r\n\r\n Monoid→RawMonoidΣ : Monoid → RawMonoidΣ\r\n Monoid→RawMonoidΣ A = ⟨ A ⟩ , (ε A) , (_·_ A)\r\n\r\n InducedMonoid : (M : Monoid) (N : RawMonoidΣ) (e : M .Monoid.Carrier ≃ N .fst)\r\n → RawMonoidEquivStr (Monoid→RawMonoidΣ M) N e → Monoid\r\n InducedMonoid M N e r =\r\n MonoidΣ→Monoid (transferAxioms rawMonoidUnivalentStr (Monoid→MonoidΣ M) N (e , r))\r\n\r\n InducedMonoidPath : (M : Monoid {ℓ}) (N : RawMonoidΣ) (e : M .Monoid.Carrier ≃ N .fst)\r\n (E : RawMonoidEquivStr (Monoid→RawMonoidΣ M) N e)\r\n → M ≡ InducedMonoid M N e E\r\n InducedMonoidPath M N e E =\r\n MonoidPath M (InducedMonoid M N e E) .fst (monoidiso e (E .fst) (E .snd))\r\n\r\n-- We now extract the important results from the above module\r\n\r\nisPropIsMonoid : {M : Type ℓ} (ε : M) (_·_ : M → M → M) → isProp (IsMonoid ε _·_)\r\nisPropIsMonoid ε _·_ =\r\n subst isProp (MonoidΣTheory.MonoidAxioms≡IsMonoid (ε , _·_))\r\n (MonoidΣTheory.isPropMonoidAxioms _ (ε , _·_))\r\n\r\nMonoidPath : (M N : Monoid {ℓ}) → (MonoidEquiv M N) ≃ (M ≡ N)\r\nMonoidPath = MonoidΣTheory.MonoidPath\r\n\r\nInducedMonoid : (M : Monoid {ℓ}) (N : MonoidΣTheory.RawMonoidΣ) (e : M .Monoid.Carrier ≃ N .fst)\r\n → MonoidΣTheory.RawMonoidEquivStr (MonoidΣTheory.Monoid→RawMonoidΣ M) N e\r\n → Monoid\r\nInducedMonoid = MonoidΣTheory.InducedMonoid\r\n\r\nInducedMonoidPath : (M : Monoid {ℓ}) (N : MonoidΣTheory.RawMonoidΣ) (e : M .Monoid.Carrier ≃ N .fst)\r\n (E : MonoidΣTheory.RawMonoidEquivStr (MonoidΣTheory.Monoid→RawMonoidΣ M) N e)\r\n → M ≡ InducedMonoid M N e E\r\nInducedMonoidPath = MonoidΣTheory.InducedMonoidPath\r\n\r\n\r\nmodule MonoidTheory {ℓ} (M' : Monoid {ℓ}) where\r\n\r\n open Monoid M' renaming ( Carrier to M )\r\n\r\n -- Added for its use in groups\r\n -- If there exists a inverse of an element it is unique\r\n inv-lemma : (x y z : M) → y · x ≡ ε → x · z ≡ ε → y ≡ z\r\n inv-lemma x y z left-inverse right-inverse =\r\n y ≡⟨ sym (rid y) ⟩\r\n y · ε ≡⟨ cong (λ - → y · -) (sym right-inverse) ⟩\r\n y · (x · z) ≡⟨ assoc y x z ⟩\r\n (y · x) · z ≡⟨ cong (λ - → - · z) left-inverse ⟩\r\n ε · z ≡⟨ lid z ⟩\r\n z ∎\r\n", "meta": {"hexsha": "7bf7ea8e8b2a583bb3a63f74c7b2a496b51d8b79", "size": 8421, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Monoid/Base.agda", "max_stars_repo_name": "knrafto/cubical", "max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Monoid/Base.agda", "max_issues_repo_name": "knrafto/cubical", "max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Monoid/Base.agda", "max_forks_repo_name": "knrafto/cubical", "max_forks_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.6822033898, "max_line_length": 101, "alphanum_fraction": 0.6129913312, "num_tokens": 3142, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.7981867849406659, "lm_q1q2_score": 0.6048614528538386}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Results concerning function extensionality for propositional equality\n------------------------------------------------------------------------\n\n{-# OPTIONS --with-K --safe #-}\n\nmodule Axiom.Extensionality.Heterogeneous where\n\nimport Axiom.Extensionality.Propositional as P\nopen import Function\nopen import Level\nopen import Relation.Binary.HeterogeneousEquality.Core\nopen import Relation.Binary.PropositionalEquality.Core\n\n------------------------------------------------------------------------\n-- Function extensionality states that if two functions are\n-- propositionally equal for every input, then the functions themselves\n-- must be propositionally equal.\n\nExtensionality : (a b : Level) → Set _\nExtensionality a b =\n {A : Set a} {B₁ B₂ : A → Set b}\n {f₁ : (x : A) → B₁ x} {f₂ : (x : A) → B₂ x} →\n (∀ x → B₁ x ≡ B₂ x) → (∀ x → f₁ x ≅ f₂ x) → f₁ ≅ f₂\n\n------------------------------------------------------------------------\n-- Properties\n\n-- This form of extensionality follows from extensionality for _≡_.\n\n≡-ext⇒≅-ext : ∀ {ℓ₁ ℓ₂} →\n P.Extensionality ℓ₁ (suc ℓ₂) →\n Extensionality ℓ₁ ℓ₂\n≡-ext⇒≅-ext {ℓ₁} {ℓ₂} ext B₁≡B₂ f₁≅f₂ with ext B₁≡B₂\n... | refl = ≡-to-≅ $ ext′ (≅-to-≡ ∘ f₁≅f₂)\n where\n ext′ : P.Extensionality ℓ₁ ℓ₂\n ext′ = P.lower-extensionality ℓ₁ (suc ℓ₂) ext\n", "meta": {"hexsha": "0b10affb613c36472ba055500b910fd1b473634e", "size": 1416, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Axiom/Extensionality/Heterogeneous.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Axiom/Extensionality/Heterogeneous.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Axiom/Extensionality/Heterogeneous.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 34.5365853659, "max_line_length": 72, "alphanum_fraction": 0.5353107345, "num_tokens": 398, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8774767970940974, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.6048496848358644}} {"text": "-- 2011-09-15 posted by Nisse\n-- {-# OPTIONS --show-implicit -v tc.lhs.unify:15 #-}\nmodule Issue292-16 where\n\ndata _≡_ {A : Set} (x : A) : A → Set where\n refl : x ≡ x\n\npostulate\n A : Set\n f : A → A\n\ndata C : A → Set where\n c : ∀ x → C (f x)\n\nrecord Box : Set where\n constructor box\n field\n a : A\n b : C a\n\ntest : ∀ {x₁ x₂} → box (f x₁) (c x₁) ≡ box (f x₂) (c x₂) → x₁ ≡ x₂\ntest refl = refl\n\n-- this failed before because we tried\n--\n-- c x₁ : C (f x₁) =?= c₂ x₂ : C (f x₂)\n--\n-- and did not recognize that\n--\n-- x₁ : A =?= x₂ : A\n--\n-- is homogeneous", "meta": {"hexsha": "ab62339d721393cd48c9808730f6320db7074bd1", "size": 566, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/Issue292-16.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "test/succeed/Issue292-16.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/Issue292-16.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.6875, "max_line_length": 66, "alphanum_fraction": 0.538869258, "num_tokens": 232, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8774767874818408, "lm_q2_score": 0.6893056167854461, "lm_q1q2_score": 0.6048496782100821}} {"text": "{-# OPTIONS --without-K #-}\nopen import HoTT.Base\nopen import HoTT.Equivalence\nopen import HoTT.Identity.Pi\nopen import HoTT.Identity.Product\n\nmodule HoTT.Product.Universal where\n\n×-univ : ∀ {i j k} {X : 𝒰 i} (A : X → 𝒰 j) (B : X → 𝒰 k) →\n ((c : X) → A c × B c) ≃ Π X A × Π X B\n×-univ {X = X} A B = let open Iso in iso→eqv λ where\n .f f → pr₁ ∘ f , pr₂ ∘ f\n .g f x → pr₁ f x , pr₂ f x\n .η f → funext (×-uniq ∘ f)\n .ε f → ×-pair⁼ (refl , refl)\n", "meta": {"hexsha": "9a36a5f360b7c65aa6566ed4a77ec95b7313814f", "size": 455, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "HoTT/Product/Universal.agda", "max_stars_repo_name": "michaelforney/hott", "max_stars_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_stars_repo_licenses": ["0BSD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "HoTT/Product/Universal.agda", "max_issues_repo_name": "michaelforney/hott", "max_issues_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_issues_repo_licenses": ["0BSD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HoTT/Product/Universal.agda", "max_forks_repo_name": "michaelforney/hott", "max_forks_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_forks_repo_licenses": ["0BSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.4375, "max_line_length": 58, "alphanum_fraction": 0.5582417582, "num_tokens": 196, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8774767906859264, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.6048496748181226}} {"text": "module Numeral.Natural.Relation.Divisibility.Proofs.Modulo where\n\nimport Lvl\nopen import Data\nopen import Functional\nopen import Logic.Predicate\nopen import Logic.Propositional\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.Oper.DivMod.Proofs\nopen import Numeral.Natural.Oper.FlooredDivision\nopen import Numeral.Natural.Oper.Modulo\nopen import Numeral.Natural.Oper.Modulo.Proofs\nopen import Numeral.Natural.Oper.Proofs\nopen import Numeral.Natural.Relation.Divisibility\nopen import Numeral.Natural.Relation.Divisibility.Proofs\nopen import Relator.Equals\nopen import Relator.Equals.Proofs.Equiv\nopen import Structure.Function.Domain\nopen import Structure.Operator.Properties\nopen import Structure.Operator.Proofs.Util\nopen import Syntax.Transitivity\nopen import Type\n\ndivides-mod : ∀{a b d} → (d ∣ 𝐒(b)) → (d ∣ a) ↔ (d ∣ a mod 𝐒(b))\ndivides-mod {a}{b}{d} db = [↔]-intro (l db) (r db) where\n l : ∀{a b d} → (d ∣ 𝐒(b)) → (d ∣ a) ← (d ∣ (a mod₀ 𝐒(b)))\n l {a}{b}{𝟎} db dmod with () ← [0]-only-divides-[0] db\n l {a}{b}{𝐒(d)} db dmod\n with [∃]-intro (𝐒(n)) ⦃ dnb ⦄ ← [↔]-to-[←] divides-[⋅]-existence db\n with [∃]-intro m ⦃ dmmod ⦄ ← [↔]-to-[←] divides-[⋅]-existence dmod\n = [↔]-to-[→] divides-[⋅]-existence ([∃]-intro (((a ⌊/⌋ (𝐒(d) ⋅ 𝐒(n))) ⋅ 𝐒(n)) + m) ⦃ p ⦄) where\n p : (𝐒(d) ⋅ (((a ⌊/⌋ (𝐒(d) ⋅ 𝐒(n))) ⋅ 𝐒(n)) + m) ≡ a)\n p =\n 𝐒(d) ⋅ (((a ⌊/⌋ (𝐒(d) ⋅ 𝐒(n))) ⋅ 𝐒(n)) + m) 🝖[ _≡_ ]-[ distributivityₗ(_⋅_)(_+_) {𝐒(d)}{(a ⌊/⌋ (𝐒(d) ⋅ 𝐒(n))) ⋅ 𝐒(n)}{m} ]\n (𝐒(d) ⋅ ((a ⌊/⌋ (𝐒(d) ⋅ 𝐒(n))) ⋅ 𝐒(n))) + (𝐒(d) ⋅ m) 🝖[ _≡_ ]-[ [≡]-with(_+ (𝐒(d) ⋅ m)) (One.commuteₗ-assocᵣ {a = 𝐒(d)}{a ⌊/⌋ (𝐒(d) ⋅ 𝐒(n))}{𝐒(n)}) ]\n ((a ⌊/⌋ (𝐒(d) ⋅ 𝐒(n))) ⋅ (𝐒(d) ⋅ 𝐒(n))) + (𝐒(d) ⋅ m) 🝖[ _≡_ ]-[ [≡]-with(((a ⌊/⌋ (𝐒(d) ⋅ 𝐒(n))) ⋅ (𝐒(d) ⋅ 𝐒(n))) +_) dmmod ]\n ((a ⌊/⌋ (𝐒(d) ⋅ 𝐒(n))) ⋅ (𝐒(d) ⋅ 𝐒(n))) + (a mod 𝐒(b)) 🝖[ _≡_ ]-[ [≡]-with(expr ↦ ((a ⌊/⌋ (𝐒(d) ⋅ 𝐒(n))) ⋅ (𝐒(d) ⋅ 𝐒(n))) + (a mod 𝐒(expr))) (injective(𝐒) dnb) ]-sym\n ((a ⌊/⌋ (𝐒(d) ⋅ 𝐒(n))) ⋅ (𝐒(d) ⋅ 𝐒(n))) + (a mod (𝐒(d) ⋅ 𝐒(n))) 🝖[ _≡_ ]-[ [⌊/⌋][mod]-is-division-with-remainder {a}{d + 𝐒(d) ⋅ n} ]\n a 🝖-end\n\n r : ∀{a b d} → (d ∣ 𝐒(b)) → (d ∣ a) → (d ∣ (a mod₀ 𝐒(b)))\n r {a}{b}{𝟎} db da with [≡]-intro ← [0]-only-divides-[0] da = Div𝟎\n r {a}{b}{𝐒 d} db da\n with [∃]-intro n ⦃ dna ⦄ ← [↔]-to-[←] divides-[⋅]-existence da\n with [∃]-intro m ⦃ dmb ⦄ ← [↔]-to-[←] divides-[⋅]-existence db\n = [↔]-to-[→] divides-[⋅]-existence ([∃]-intro (n mod₀ m) ⦃ p ⦄) where\n p : (𝐒(d) ⋅ (n mod₀ m) ≡ a mod₀ 𝐒(b))\n p =\n 𝐒(d) ⋅ (n mod₀ m) 🝖[ _≡_ ]-[ [⋅][mod]-distributivityₗ {n}{m}{𝐒(d)} ]\n (𝐒(d) ⋅ n) mod₀ (𝐒(d) ⋅ m) 🝖[ _≡_ ]-[ [≡]-with(\\expr → ((𝐒(d) ⋅ n) mod₀ expr)) dmb ]\n (𝐒(d) ⋅ n) mod₀ 𝐒(b) 🝖[ _≡_ ]-[ [≡]-with(_mod₀ 𝐒(b)) dna ]\n a mod₀ 𝐒(b) 🝖[ _≡_ ]-end\n", "meta": {"hexsha": "0acf943a6c171c639eaaa274d510134d38d65c24", "size": 2945, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Relation/Divisibility/Proofs/Modulo.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Relation/Divisibility/Proofs/Modulo.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Relation/Divisibility/Proofs/Modulo.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.537037037, "max_line_length": 180, "alphanum_fraction": 0.4916808149, "num_tokens": 1538, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774767778695834, "lm_q2_score": 0.6893056167854461, "lm_q1q2_score": 0.6048496715842991}} {"text": "-- Adapted from Wadler: https://plfa.github.io/Lambda/\n\n\nmodule Context (A : Set) where\n open import Prelude\n \n open import Data.Nat\n open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; sym)\n open import Data.Maybe\n open import Data.Product using (_×_; proj₁; proj₂; ∃-syntax) renaming (_,_ to ⟨_,_⟩)\n open import Relation.Nullary.Decidable\n open import Relation.Nullary using (Dec; yes; no)\n open import Data.Empty\n import Data.Nat.Properties\n\n\n infixl 5 _,_⦂_\n \n -- Internal type of contexts\n data ctx : Set where\n ∅ : ctx\n _,_⦂_ : ctx → ℕ → A → ctx\n\n infix 4 _∋_⦂_\n\n data _∋_⦂_ : ctx → ℕ → A → Set where\n\n Z : ∀ {Γ : ctx}\n → ∀ {x : ℕ}\n → ∀ {a : A}\n ------------------\n → Γ , x ⦂ a ∋ x ⦂ a\n \n S : ∀ {Γ x y a b}\n → x ≢ y\n → Γ ∋ x ⦂ a\n ------------------\n → Γ , y ⦂ b ∋ x ⦂ a\n\n lookup : ctx → ℕ → Maybe A\n lookup ∅ _ = nothing\n lookup (Γ , x ⦂ t) y with compare x y\n ... | equal _ = just t\n ... | _ = lookup Γ x\n\n data _∈dom_ : ℕ → ctx → Set where\n inDom : ∀ {x Γ a}\n → Γ ∋ x ⦂ a\n -------------\n → x ∈dom Γ\n\n data _∉dom_ : ℕ → ctx → Set where\n notInEmpty : ∀ {x}\n ----------\n → x ∉dom ∅\n\n notInNonempty : ∀ {x x' Γ T}\n → x ≢ x'\n → x ∉dom Γ\n --------------------\n → x ∉dom (Γ , x' ⦂ T)\n\n irrelevantExtensionsOK : ∀ {Γ : ctx}\n → ∀ {x y t t'}\n → Γ ∋ x ⦂ t\n → x ≢ y\n → Γ , y ⦂ t' ∋ x ⦂ t\n irrelevantExtensionsOK {Γ} {x} {y} {t} cont@(Z {Γ₀} {x} {t}) neq = S neq cont\n irrelevantExtensionsOK (S neq' rest) neq = S neq (irrelevantExtensionsOK rest neq')\n\n irrelevantReductionsOK : ∀ {Γ : ctx}\n → ∀ {x y t t'}\n → Γ , x ⦂ t ∋ y ⦂ t'\n → y ≢ x\n → Γ ∋ y ⦂ t'\n -- ⊥-elim (!neq (Relation.Binary.PropositionalEquality.sym x x))\n irrelevantReductionsOK {Γ} {x} {y} {t} {t'} z@(Z {Γ} {x} {t}) neq =\n let\n s : x ≡ x\n s = refl\n bot = neq s\n in\n Data.Empty.⊥-elim bot\n \n irrelevantReductionsOK {Γ} {x} {y} {t} {t'} (S x₁ qq) neq = qq \n\n irrelevantReductionsInValuesOK : ∀ {Γ : ctx}\n → ∀ {x y t t'}\n → Γ , x ⦂ t ∋ y ⦂ t'\n → t ≢ t'\n → Γ ∋ y ⦂ t'\n irrelevantReductionsInValuesOK {Γ} {x} {.x} {t} {.t} Z tNeqt' = ⊥-elim (tNeqt' refl)\n irrelevantReductionsInValuesOK {Γ} {x} {y} {t} {t'} (S yNeqx yt'InΓ') tNeqt' = yt'InΓ'\n\n ∈domExcludedMiddle : ∀ {Γ x}\n → x ∉dom Γ\n → Relation.Nullary.¬ (x ∈dom Γ)\n ∈domExcludedMiddle {.∅} {x} notInEmpty (inDom ())\n ∈domExcludedMiddle {.(_ , _ ⦂ _)} {x} (notInNonempty xNeqx' xNotInΓ) (inDom n) = \n let\n rest = ∈domExcludedMiddle xNotInΓ\n xInΓ = irrelevantReductionsOK n xNeqx'\n in\n rest (inDom xInΓ) \n\n ∉domPreservation : ∀ {x x' Γ T T'}\n → x ∉dom (Γ , x' ⦂ T)\n ---------------------\n → x ∉dom (Γ , x' ⦂ T')\n ∉domPreservation {x} {x'} {Γ} {T} {T'} (notInNonempty xNeqX' xNotInDom) = notInNonempty xNeqX' xNotInDom\n\n ∉domGreaterThan : ∀ {Γ x}\n → (∀ x' → x' ∈dom Γ → x' < x)\n → x ∉dom Γ\n ∉domGreaterThan {∅} {x} xBigger = notInEmpty\n ∉domGreaterThan {Γ , x' ⦂ t} {x} xBigger =\n notInNonempty x≢x' (∉domGreaterThan rest) -- (∉domGreaterThan (λ x'' → λ x''InΓ → xBigger x'' (inDom {!!})))\n where\n x'>=_\n field\n return : ∀ {A} → A → M A\n _>>=_ : ∀ {A B} → M A → (A → M B) → M B\n\n map : ∀ {A B} → (A → B) → M A → M B\n map f x = x >>= λ x → return (f x)\n\nopen Raw-monad ⦃ … ⦄\n\n-- Id is included in order to make run overloaded.\n\nrecord Id (A : Set) : Set where\n field\n run : A\n\nopen Id\n\ninfix 3 ¬¬_\n\nrecord ¬¬_ (A : Set) : Set where\n field\n run : ¬ ¬ A\n\nopen ¬¬_\n\ninstance\n\n double-negation-monad : Raw-monad ¬¬_\n run (Raw-monad.return double-negation-monad x) = λ f → f x\n run (Raw-monad._>>=_ double-negation-monad x f) =\n λ ¬b → run x (λ a → run (f a) ¬b)\n\nexcluded-middle : {A : Set} → ¬¬ (A ⊎ ¬ A)\nrun excluded-middle ¬[a⊎¬a] = ¬[a⊎¬a] (inj₂ λ a → ¬[a⊎¬a] (inj₁ a))\n\npostulate\n\n A : Set\n P : Set → Set\n _⇓_ : P A → A → Set\n _⇑ : P A → Set\n ¬⇓→⇑ : {x : P A} → ¬ (∃ λ y → x ⇓ y) → x ⇑\n\n¬¬[⇓⊎⇑] : (x : P A) → ¬ ¬ ((∃ λ y → x ⇓ y) ⊎ x ⇑)\n¬¬[⇓⊎⇑] x = run (map (⊎-map (λ x → x) ¬⇓→⇑) excluded-middle)\n", "meta": {"hexsha": "507634655e1824a8990cc242fe9c7caf11f12c84", "size": 1391, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue3518.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue3518.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue3518.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 19.0547945205, "max_line_length": 67, "alphanum_fraction": 0.4723220705, "num_tokens": 687, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314858927012, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.6045087963575939}} {"text": "{-\n\nThis file contains:\n\n- Definition of set quotients\n\n-}\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.HITs.SetQuotients.Base where\n\nopen import Cubical.Core.Primitives\n\n-- Set quotients as a higher inductive type:\ndata _/_ {ℓ ℓ'} (A : Type ℓ) (R : A → A → Type ℓ') : Type (ℓ-max ℓ ℓ') where\n [_] : (a : A) → A / R\n eq/ : (a b : A) → (r : R a b) → [ a ] ≡ [ b ]\n squash/ : (x y : A / R) → (p q : x ≡ y) → p ≡ q\n", "meta": {"hexsha": "202ba845295e52dce13a39588e81f56a3cdfcb15", "size": 436, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/SetQuotients/Base.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/HITs/SetQuotients/Base.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/HITs/SetQuotients/Base.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "avg_line_length": 24.2222222222, "max_line_length": 76, "alphanum_fraction": 0.5573394495, "num_tokens": 170, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8856314798554444, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.6045087807993664}} {"text": "-- {-# OPTIONS -vtc.with.strip:60 -v tc.lhs.top:50 #-}\n\nopen import Agda.Builtin.Nat\nopen import Agda.Builtin.Equality\n\npostulate trustMe : {A : Set} (x y : A) → x ≡ y\n\n\ndata Fin : Nat → Set where\n fzero : ∀ n → Fin (suc n)\n fsuc : ∀{n} → Fin n → Fin (suc n)\n\ntest1 : ∀{n} → Fin n → Nat\ntest1 (fzero _) = 0\ntest1 {.(suc n)} (fsuc {n} i) with Fin zero\n... | q = {!.!}\n-- Current & expected expansion:\n-- test1 {.(suc n)} (fsuc {n} i) | q = {!!}\n\ntest2 : ∀{n} → Fin n → Nat\ntest2 (fzero _) = 0\ntest2 {.(suc n)} (fsuc {n} i) with trustMe n zero\n... | refl = {!.!}\n-- Current & expected expansion:\n-- test2 {.1} (fsuc {.0} i) | refl = {!!}\n\n-- The test cases below do not yet work correctly, but are included\n-- here as documentation of the current behaviour of Agda. does not\n-- work correctly yet.\n\ntest3 : ∀{n} → Fin n → Nat\ntest3 (fzero _) = 0\ntest3 {m} (fsuc {n} i) with Fin zero\n... | q = {!.!}\n-- Current expansion:\n-- test3 {.(suc _)} (fsuc {_} i) | q = {!!}\n-- Expected expansion:\n-- test3 {.(suc n)} (fsuc {n} i) | q = { }\n\ntest4 : ∀{n} → Fin n → Nat\ntest4 (fzero _) = 0\ntest4 {_} (fsuc {n} i) with Fin zero\n... | q = {!.!}\n-- Current expansion:\n-- test4 {.(suc _)} (fsuc {_} i) | q = {!!}\n-- Expected expansion:\n-- test4 {_} (fsuc {n} i) | q = {!!}\n\ntest5 : ∀{n : Nat} → Fin n → Nat → Nat\ntest5 (fzero _) _ = 0\ntest5 {.(suc n)} (fsuc {n} i) m with trustMe m n\n... | refl = {!.!}\n-- Current expansion:\n-- test5 {.(suc n)} (fsuc {n} i) n | refl = {!!}\n-- Expected expansion: one of the following:\n-- test5 {.(suc n)} (fsuc {n} i) .n | refl = {!!}\n-- test5 {.(suc m)} (fsuc {.m} i) m | refl = {!!}\n\ntest6 : Nat → ∀{n : Nat} → Fin n → Nat\ntest6 _ (fzero _) = 0\ntest6 m {.(suc n)} (fsuc {n} i) with trustMe m n\n... | refl = {!.!}\n-- Current expansion:\n-- test6 m {.(suc m)} (fsuc {.m} i) | refl = {!!}\n-- This one is actually good, we should be sure fixing the above\n-- examples doesn't change the output here!\n", "meta": {"hexsha": "02b1b01f73d00d883b332e6dd22492a0f2ff44c0", "size": 1916, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue4778.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/interaction/Issue4778.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/interaction/Issue4778.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 28.5970149254, "max_line_length": 67, "alphanum_fraction": 0.5495824635, "num_tokens": 737, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920020959544, "lm_q2_score": 0.7549149868676283, "lm_q1q2_score": 0.6044543922472824}} {"text": "{-# OPTIONS --profile=interactive #-}\nopen import Common.Prelude\nopen import Common.Equality\n\n`1 = suc zero\n`2 = `1 + `1\n`4 = `2 + `2\n`8 = `4 + `4\n`16 = `8 + `8\n`32 = `16 + `16\n`64 = `32 + `32\n`128 = `64 + `64\n`256 = `128 + `128\n`512 = `256 + `256\n`1024 = `512 + `512\n`2048 = `1024 + `1024\n`4096 = `2048 + `2048\n`8192 = `4096 + `4096\n`16384 = `8192 + `8192\n`32768 = `16384 + `16384\n`65536 = `32768 + `32768\n\nprf8 : `8 ≡ 8\nprf8 = refl\n\nprf65k : `65536 ≡ 65536\nprf65k = refl\n", "meta": {"hexsha": "4afb824677c03ca4b5525e8b98ee1baf1942d3a0", "size": 578, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/SharedDefinitions.agda", "max_stars_repo_name": "sseefried/agda", "max_stars_repo_head_hexsha": "6b13364d36eeb60d8ec15eaf8effe23c73401900", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:25:14.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:25:14.000Z", "max_issues_repo_path": "test/Succeed/SharedDefinitions.agda", "max_issues_repo_name": "Seanpm2001-Agda-lang/agda", "max_issues_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_forks_repo_path": "test/Succeed/SharedDefinitions.agda", "max_forks_repo_name": "Seanpm2001-Agda-lang/agda", "max_forks_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.6428571429, "max_line_length": 37, "alphanum_fraction": 0.4480968858, "num_tokens": 268, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.872347368040789, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.6042244109821396}} {"text": "------------------------------------------------------------------------\n-- Operations on and properties of decidable relations\n------------------------------------------------------------------------\n\nmodule Relation.Nullary.Decidable where\n\nopen import Data.Empty\nopen import Data.Function\nopen import Data.Bool\nopen import Data.Product hiding (map)\nopen import Relation.Nullary\nopen import Relation.Binary.PropositionalEquality\n\ndecToBool : ∀ {P} → Dec P → Bool\ndecToBool (yes _) = true\ndecToBool (no _) = false\n\nTrue : ∀ {P} → Dec P → Set\nTrue Q = T (decToBool Q)\n\nFalse : ∀ {P} → Dec P → Set\nFalse Q = T (not (decToBool Q))\n\nwitnessToTruth : ∀ {P} {Q : Dec P} → True Q → P\nwitnessToTruth {Q = yes p} _ = p\nwitnessToTruth {Q = no _} ()\n\nmap : ∀ {P Q} → P ⇔ Q → Dec P → Dec Q\nmap eq (yes p) = yes (proj₁ eq p)\nmap eq (no ¬p) = no (¬p ∘ proj₂ eq)\n\nfromYes : ∀ {P} → P → Dec P → P\nfromYes _ (yes p) = p\nfromYes p (no ¬p) = ⊥-elim (¬p p)\n\nfromYes-map-commute :\n ∀ {P Q p q} (eq : P ⇔ Q) (d : Dec P) →\n fromYes q (map eq d) ≡ proj₁ eq (fromYes p d)\nfromYes-map-commute _ (yes p) = refl\nfromYes-map-commute {p = p} _ (no ¬p) = ⊥-elim (¬p p)\n", "meta": {"hexsha": "67bdbb7341d11a1fe122ceeb9b587ce4cf1691e1", "size": 1152, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Relation/Nullary/Decidable.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Relation/Nullary/Decidable.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Relation/Nullary/Decidable.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 28.0975609756, "max_line_length": 72, "alphanum_fraction": 0.5460069444, "num_tokens": 371, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8723473614033683, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.6042244008500982}} {"text": "{- formatted printing like printf, except type-safe (as proposed\n in \"Cayenne -- a language with dependent types\" by Augustsson).\n\n The types of the rest of the arguments are computed from the\n format string. -}\nmodule string-format where\n\nopen import char\nopen import eq\nopen import list\nopen import nat\n\nopen import nat-to-string\nopen import string\n\n{- We will first convert the format string to the following type,\n so we can avoid default cases in the definition of format-th\n (cf. string-format-issue.agda). -}\ndata format-d : Set where\n format-nat : format-d → format-d\n format-string : format-d → format-d\n not-format : (c : char) → format-d → format-d\n empty-format : format-d\n\nformat-cover : 𝕃 char → format-d\nformat-cover ('%' :: 'n' :: s) = format-nat (format-cover s)\nformat-cover ('%' :: 's' :: s) = format-string (format-cover s)\nformat-cover (c :: s) = not-format c (format-cover s)\nformat-cover [] = empty-format\n\nformat-th : format-d → Set\nformat-th (format-nat v) = ℕ → format-th v\nformat-th (format-string v) = string → format-th v\nformat-th (not-format c v) = format-th v\nformat-th empty-format = string\n\nformat-t : string → Set\nformat-t s = format-th (format-cover (string-to-𝕃char s))\n\nformat-h : 𝕃 char → (d : format-d) → format-th d\nformat-h s (format-nat v) = λ n → format-h (s ++ (string-to-𝕃char (ℕ-to-string n))) v\nformat-h s (format-string v) = λ s' → format-h (s ++ (string-to-𝕃char s')) v\nformat-h s (not-format c v) = format-h (s ++ [ c ] ) v\nformat-h s empty-format = 𝕃char-to-string s\n\nformat : (f : string) → format-t f\nformat f = format-h [] (format-cover (string-to-𝕃char f))\n\nformat-type-test : Set\nformat-type-test = format-t \"%n% of the %ss are in the %s %s\"\n\nformat-test : string\nformat-test = format \"%n% of the %ss are in the %s %s\" 25 \"dog\" \"toasty\" \"doghouse\"\n\nformat-test-lem : format-test ≡ \"25% of the dogs are in the toasty doghouse\"\nformat-test-lem = refl", "meta": {"hexsha": "50e162f21eaa93d6b997b583516dc52fdf3436ec", "size": 1920, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "string-format.agda", "max_stars_repo_name": "rfindler/ial", "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 29, "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_issues_repo_path": "string-format.agda", "max_issues_repo_name": "rfindler/ial", "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_forks_repo_path": "string-format.agda", "max_forks_repo_name": "rfindler/ial", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 17, "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "avg_line_length": 34.2857142857, "max_line_length": 85, "alphanum_fraction": 0.6770833333, "num_tokens": 571, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8807970842359877, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.6041822799044808}} {"text": "------------------------------------------------------------------------------\n-- Induction principles for the total natural numbers inductive predicate\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOT.FOTC.Data.Nat.Type where\n\nopen import FOTC.Base hiding ( succ₁ )\n\n------------------------------------------------------------------------------\n-- We define succ₁ outside an abstract block.\n\nsucc₁ : D → D\nsucc₁ n = succ · n\n\nmodule ConstantAndUnaryFunction where\n\n -- N using the constant succ.\n data N : D → Set where\n nzero : N zero\n nsucc : ∀ {n} → N n → N (succ · n)\n\n N-ind : (A : D → Set) →\n A zero →\n (∀ {n} → A n → A (succ · n)) →\n ∀ {n} → N n → A n\n N-ind A A0 h nzero = A0\n N-ind A A0 h (nsucc Nn) = h (N-ind A A0 h Nn)\n\n -- N using the unary function succ₁.\n data N₁ : D → Set where\n nzero₁ : N₁ zero\n nsucc₁ : ∀ {n} → N₁ n → N₁ (succ₁ n)\n\n N-ind₁ : (A : D → Set) →\n A zero →\n (∀ {n} → A n → A (succ₁ n)) →\n ∀ {n} → N₁ n → A n\n N-ind₁ A A0 h nzero₁ = A0\n N-ind₁ A A0 h (nsucc₁ Nn) = h (N-ind₁ A A0 h Nn)\n\n ----------------------------------------------------------------------------\n -- From N/N₁ to N₁/N.\n\n N→N₁ : ∀ {n} → N n → N₁ n\n N→N₁ nzero = nzero₁\n N→N₁ (nsucc {n} Nn) = nsucc₁ (N→N₁ Nn)\n\n N₁→N : ∀ {n} → N₁ n → N n\n N₁→N nzero₁ = nzero\n N₁→N (nsucc₁ {n} N₁n) = nsucc (N₁→N N₁n)\n\n ----------------------------------------------------------------------------\n -- From N-ind → N-ind₁.\n N-ind₁' : (A : D → Set) →\n A zero →\n (∀ {n} → A n → A (succ₁ n)) →\n ∀ {n} → N₁ n → A n\n N-ind₁' A A0 h Nn₁ = N-ind A A0 h' (N₁→N Nn₁)\n where\n h' : ∀ {n} → A n → A (succ · n)\n h' {n} An = h An\n\n ----------------------------------------------------------------------------\n -- From N-ind₁ → N-ind.\n N-ind' : (A : D → Set) →\n A zero →\n (∀ {n} → A n → A (succ · n)) →\n ∀ {n} → N n → A n\n N-ind' A A0 h Nn = N-ind₁ A A0 h' (N→N₁ Nn)\n where\n h' : ∀ {n} → A n → A (succ₁ n)\n h' {n} An = h An\n\n------------------------------------------------------------------------------\n\nmodule AdditionalHypotheis where\n\n data N : D → Set where\n nzero : N zero\n nsucc : ∀ {n} → N n → N (succ₁ n)\n\n -- The induction principle generated by Coq 8.4pl4 when we define\n -- the data type N in Prop.\n N-ind₁ : (A : D → Set) →\n A zero →\n (∀ {n} → N n → A n → A (succ₁ n)) →\n ∀ {n} → N n → A n\n N-ind₁ A A0 h nzero = A0\n N-ind₁ A A0 h (nsucc Nn) = h Nn (N-ind₁ A A0 h Nn)\n\n -- The induction principle removing the hypothesis N n from the\n -- inductive step (see Martin-Löf 1971, p. 190).\n N-ind₂ : (A : D → Set) →\n A zero →\n (∀ {n} → A n → A (succ₁ n)) →\n ∀ {n} → N n → A n\n N-ind₂ A A0 h nzero = A0\n N-ind₂ A A0 h (nsucc Nn) = h (N-ind₂ A A0 h Nn)\n\n ----------------------------------------------------------------------------\n -- N-ind₂ from N-ind₁.\n N-ind₂' : (A : D → Set) →\n A zero →\n (∀ {n} → A n → A (succ₁ n)) →\n ∀ {n} → N n → A n\n N-ind₂' A A0 h = N-ind₁ A A0 (λ _ → h)\n\n ----------------------------------------------------------------------------\n -- N-ind₁ from N-ind₂.\n N-ind₁' : (A : D → Set) →\n A zero →\n (∀ {n} → N n → A n → A (succ₁ n)) →\n ∀ {n} → N n → A n\n N-ind₁' A A0 h {n} Nn = ∧-proj₂ (N-ind₂ B B0 h' Nn)\n where\n B : D → Set\n B n = N n ∧ A n\n\n B0 : B zero\n B0 = nzero , A0\n\n h' : ∀ {m} → B m → B (succ₁ m)\n h' (Nm , Am) = nsucc Nm , h Nm Am\n\n------------------------------------------------------------------------------\n-- References\n--\n-- Martin-Löf, P. (1971). Hauptsatz for the Intuitionistic Theory of\n-- Iterated Inductive Definitions. In: Proceedings of the Second\n-- Scandinavian Logic Symposium. Ed. by Fenstad,\n-- J. E. Vol. 63. Studies in Logic and the Foundations of\n-- Mathematics. North-Holland Publishing Company, pp. 179–216.\n", "meta": {"hexsha": "9028e7d935ee6ca0bd8b567c2b66bcf0a8bf64a2", "size": 4243, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/FOTC/Data/Nat/Type.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/FOT/FOTC/Data/Nat/Type.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/FOT/FOTC/Data/Nat/Type.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 30.7463768116, "max_line_length": 78, "alphanum_fraction": 0.3912326184, "num_tokens": 1387, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673223709251, "lm_q2_score": 0.7431680143008301, "lm_q1q2_score": 0.6040969938564331}} {"text": "{-# OPTIONS --cubical --no-import-sorts --allow-unsolved-metas #-}\n\nmodule SyntheticReals where\n\nopen import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero)\n\nprivate\n variable\n ℓ ℓ' ℓ'' : Level\n\nopen import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc)\nopen import Cubical.Structures.CommRing\nopen import Cubical.Relation.Nullary.Base -- ¬_\nopen import Cubical.Relation.Binary.Base -- Rel\nopen import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_)\nopen import Cubical.Data.Sigma.Base renaming (_×_ to infixr 4 _×_)\nopen import Cubical.Data.Empty renaming (elim to ⊥-elim) -- `⊥` and `elim`\n-- open import Cubical.Structures.Poset\nopen import Cubical.Foundations.Function\n\nopen import Function.Base using (_∋_)\n-- open import Function.Reasoning using (∋-syntax)\nopen import Function.Base using (it) -- instance search\n\nopen import Utils\nopen import MoreLogic\nopen MoreLogic.Reasoning\nopen MoreLogic.Properties\nopen import MoreAlgebra\nopen MoreAlgebra.Definitions\nopen MoreAlgebra.Consequences\nopen import Bundles\n-- open MoreAlgebra.Properties.Group\n\n-- https://www.cs.bham.ac.uk/~abb538/thesis.pdf\n-- Booij 2020 - Analysis in Univalent Type Theory\n\n-- Lemma 4.1.6.\nimport Properties.ConstructiveField\n\n-- Lemma 4.1.11.\nimport Properties.AlmostOrderedField\n\n-- Lemma 4.1.12. An ordered field (F, 0, 1, +, · , min, max, <) is a constructive field (F, 0, 1, +, · , #).\nlemma-4-1-12 :\n -- NOTE: we do a slightly different thing here\n ∀{ℓ ℓ'} (OF : OrderedField {ℓ} {ℓ'}) →\n let open OrderedField OF\n ----------------------------------------------------\n in (IsConstructiveField 0f 1f _+_ _·_ -_ _#_ _⁻¹ᶠ)\nlemma-4-1-12 {ℓ} {ℓ'} OF = let -- NOTE: for mentioning the ℓ and ℓ' and not taking them as new \"variables\" we bring them into scope\n open OrderedField OF\n in record -- We need to show that + is #-extensional, and that # is tight.\n { OrderedField OF\n ; isApartnessRel = #'-isApartnessRel <-isStrictPartialOrder -- NOTE: We've proved this before\n \n -- First, assume w + x # y + z. We need to show w # y ∨ x # z.\n ; +-#-extensional = λ where\n -- Consider the case w + x < y + z, so that we can use (†) to obtain w < y ∨ x < z,\n -- which gives w # y ∨ x # z in either case.\n w x y z (inl w+x y + z is similar.\n w x y z (inr y+z Set) -> P zero ->\n ((k : Nat) -> P k -> P (suc k)) -> P n\nind zero P pz ps = pz\nind (suc n) P pz ps = ps n (ind n P pz ps)\n\n\n+N-zero : (x : Nat) -> (x +N zero) == x\n+N-zero x = ind x (\\ x -> (x +N zero) == x) (refl _) (\\ _ h -> refl suc =$= h)\n\n+N-suc : (x y : Nat) -> (x +N suc y) == suc (x +N y)\n+N-suc x y = ind x (\\ x -> (x +N suc y) == suc (x +N y))\n (refl _) (\\ _ h -> refl suc =$= h)\n\n\ncomm-+N : (x y : Nat) -> (x +N y) == (y +N x)\ncomm-+N x zero = +N-zero x\ncomm-+N x (suc y) rewrite +N-suc x y = refl suc =$= comm-+N x y\n\n\nclockwise90 : {P : Nat * Nat -> Set}{w h : Nat} ->\n ({w h : Nat} -> P (w , h) -> P (h , w)) ->\n Interior P (w , h) -> Interior P (h , w)\nclockwise90 pc90 (tile p) = tile (pc90 p)\nclockwise90 pc90 < inl (l , r , refl _) 8>< (il , ir , <>) >\n = < inr (l , r , refl _) 8><\n clockwise90 pc90 il , clockwise90 pc90 ir , <> >\nclockwise90 pc90 < inr (t , b , refl _) 8>< it , ib , <> >\n = < (inl (b , t , comm-+N b t)) 8><\n clockwise90 pc90 ib , clockwise90 pc90 it , <> >\n\n\nSquare : Nat * Nat -> Set\nSquare (w , h) = w == h\n\nc90Sq : {w h : Nat} -> Square (w , h) -> Square (h , w)\nc90Sq (refl _) = refl _\n\ngolden : (n : Nat) -> Sg Nat \\ w -> Sg Nat \\ h -> Interior Square (w , h)\ngolden zero = 1 , 1 , tile (refl 1)\ngolden (suc n) with golden n\n... | w , h , i = (w +N h) , w , < (inl (w , h , refl _)) 8><\n tile (refl w) , clockwise90 c90Sq i , <> >\n\nfill : {n : Nat}{X : Set} -> X -> X -> X -> Vec X (suc (suc n))\nfill {n} first midst last rewrite comm-+N 1 (suc n) = first ,- (pure midst +V (last ,- []))\n where open Applicative (VecAppl n)\n\nborder : {w h : Nat} -> Matrix Char (w , h)\nborder {w} {zero} = []\nborder {zero} {h} = pure [] where open Applicative (VecAppl _)\nborder {suc zero} {suc zero} = ('O' ,- []) ,- []\nborder {suc (suc w)} {suc zero} = fill '<' '-' '>' ,- []\nborder {suc zero} {suc (suc h)} = fill ('^' ,- []) ('|' ,- []) ('v' ,- [])\nborder {suc (suc w)} {suc (suc h)} =\n fill (fill '/' '-' '\\\\')\n (fill '|' ' ' '|')\n (fill '\\\\' '-' '/')\n\ngoldenInterior : (n : Nat) -> Sg Nat \\ w -> Sg Nat \\ h -> Interior (Matrix Char) (w , h)\ngoldenInterior n with golden n\n... | w , h , sqi = w , h , ifold (\\ _ _ -> tile border) (\\ _ -> <_>) (w , h) sqi\n\n\npicture : [ Interior (Matrix Char) -:> Matrix Char ]\npicture = ifold (\\ _ -> id) NatCut2DMatAlg\n\ngoldenPicture : (n : Nat) -> Sg Nat \\ w -> Sg Nat \\ h -> Matrix Char (w , h)\ngoldenPicture n with goldenInterior n\n... | w , h , mi = w , h , picture _ mi\n\n", "meta": {"hexsha": "cfedca298ef3b6928c6b7f9756fb65e315421a92", "size": 2706, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Golden.agda", "max_stars_repo_name": "pigworker/InteriorDesign", "max_stars_repo_head_hexsha": "454cdd18f56db0b0d1643a1fcf36951b5ece395c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2018-06-18T15:25:39.000Z", "max_stars_repo_stars_event_max_datetime": "2018-07-31T02:00:13.000Z", "max_issues_repo_path": "Golden.agda", "max_issues_repo_name": "pigworker/InteriorDesign", "max_issues_repo_head_hexsha": "454cdd18f56db0b0d1643a1fcf36951b5ece395c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Golden.agda", "max_forks_repo_name": "pigworker/InteriorDesign", "max_forks_repo_head_hexsha": "454cdd18f56db0b0d1643a1fcf36951b5ece395c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.0, "max_line_length": 91, "alphanum_fraction": 0.5066518847, "num_tokens": 1019, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.863391617003942, "lm_q2_score": 0.6992544210587586, "lm_q1q2_score": 0.6037304052950768}} {"text": "module MultiSorted.Context {s} (Sort : Set s) where\n\n-- An attempt to define more structured context\n-- that directly support the cartesian structure\n\ndata Context : Set s where\n ctx-empty : Context\n ctx-slot : Sort → Context\n ctx-concat : Context → Context → Context\n\n-- the variables in a context\ndata var : Context → Set where\n var-var : ∀ {A} → var (ctx-slot A)\n var-inl : ∀ {Γ Δ} → var Γ → var (ctx-concat Γ Δ)\n var-inr : ∀ {Γ Δ} → var Δ → var (ctx-concat Γ Δ)\n\nsort-of : ∀ (Γ : Context) → var Γ → Sort\nsort-of (ctx-slot A) _ = A\nsort-of (ctx-concat Γ Δ) (var-inl x) = sort-of Γ x\nsort-of (ctx-concat Γ Δ) (var-inr x) = sort-of Δ x\n\n-- It is absurd to have a variable in the empty context\nctx-empty-absurd : ∀ {ℓ} {P : var ctx-empty → Set ℓ} (x : var ctx-empty) → P x\nctx-empty-absurd ()\n", "meta": {"hexsha": "0c0c7f04252d6be2072b6ffe6fcebedd55f8c5b9", "size": 803, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/MultiSorted/Context.agda", "max_stars_repo_name": "cilinder/formaltt", "max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 21, "max_stars_repo_stars_event_min_datetime": "2021-02-16T14:07:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-19T15:50:08.000Z", "max_issues_repo_path": "src/MultiSorted/Context.agda", "max_issues_repo_name": "andrejbauer/formaltt", "max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z", "max_forks_repo_path": "src/MultiSorted/Context.agda", "max_forks_repo_name": "andrejbauer/formaltt", "max_forks_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z", "avg_line_length": 32.12, "max_line_length": 78, "alphanum_fraction": 0.6425902864, "num_tokens": 263, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094117351309, "lm_q2_score": 0.6757645879592641, "lm_q1q2_score": 0.6036668665413233}} {"text": "open import Common.Prelude hiding (tt)\n\ninstance\n tt : ⊤\n tt = record{}\n\nNonZero : Nat → Set\nNonZero zero = ⊥\nNonZero (suc _) = ⊤\n\npred′ : (n : Nat) {{_ : NonZero n}} → Nat\npred′ zero {{}}\npred′ (suc n) = n\n\ntest : (n : Nat) {{x y : NonZero n}} → Nat\ntest n = pred′ n\n", "meta": {"hexsha": "0dd49c7af1a9fcf296cd396f15174030f5c79f78", "size": 273, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/NonUniqueInstance1.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Fail/NonUniqueInstance1.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Fail/NonUniqueInstance1.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 16.0588235294, "max_line_length": 42, "alphanum_fraction": 0.5567765568, "num_tokens": 105, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8933093946927837, "lm_q2_score": 0.6757645944891558, "lm_q1q2_score": 0.6036668608579222}} {"text": "open import Relation.Binary.Core\n\nmodule PLRTree.DropLast.Heap {A : Set} \n (_≤_ : A → A → Set)\n (tot≤ : Total _≤_) where\n\nopen import PLRTree {A} \nopen import PLRTree.Drop _≤_ tot≤\nopen import PLRTree.Heap _≤_\n\nlemma-dropLast-≤* : {x : A}{t : PLRTree} → x ≤* t → x ≤* dropLast t\nlemma-dropLast-≤* {x} (lf≤* .x) = lf≤* x\nlemma-dropLast-≤* (nd≤* {perfect} {x} {y} {l} {r} x≤y x≤*l x≤*r) \n with r\n... | leaf = x≤*r\n... | node _ _ _ _ = nd≤* x≤y x≤*l (lemma-dropLast-≤* x≤*r) \nlemma-dropLast-≤* (nd≤* {left} {x} {y} {l} {r} x≤y x≤*l x≤*r) \n with l | x≤*l | dropLast l | lemma-dropLast-≤* x≤*l \n... | leaf | _ | _ | _ = lf≤* x \n... | node perfect _ _ _ | _ | node perfect y' l' r' | x≤*dll = nd≤* x≤y x≤*dll x≤*r\n... | node perfect _ _ _ | _ | leaf | (lf≤* .x) = nd≤* x≤y (lf≤* x) x≤*r\n... | node perfect _ _ _ | _ | node left _ _ _ | x≤*dll = nd≤* x≤y x≤*dll x≤*r\n... | node perfect _ _ _ | _ | node right _ _ _ | x≤*dll = nd≤* x≤y x≤*dll x≤*r\n... | node left _ _ _ | _ | node perfect y' l' r' | x≤*dll = nd≤* x≤y x≤*dll x≤*r\n... | node left _ _ _ | _ | leaf | (lf≤* .x) = nd≤* x≤y (lf≤* x) x≤*r\n... | node left _ _ _ | _ | node left _ _ _ | x≤*dll = nd≤* x≤y x≤*dll x≤*r\n... | node left _ _ _ | _ | node right _ _ _ | x≤*dll = nd≤* x≤y x≤*dll x≤*r\n... | node right _ _ _ | _ | node perfect y' l' r' | x≤*dll = nd≤* x≤y x≤*dll x≤*r\n... | node right _ _ _ | _ | leaf | (lf≤* .x) = nd≤* x≤y (lf≤* x) x≤*r\n... | node right _ _ _ | _ | node left _ _ _ | x≤*dll = nd≤* x≤y x≤*dll x≤*r\n... | node right _ _ _ | _ | node right _ _ _ | x≤*dll = nd≤* x≤y x≤*dll x≤*r\nlemma-dropLast-≤* (nd≤* {right} {x} {y} {l} {r} x≤y x≤*l x≤*r) \n with r\n... | leaf = nd≤* x≤y x≤*r x≤*r\n... | node perfect y' l' r' = nd≤* x≤y (lemma-dropLast-≤* x≤*l) x≤*r\n... | node left _ _ _ = nd≤* x≤y x≤*l (lemma-dropLast-≤* x≤*r)\n... | node right _ _ _ = nd≤* x≤y x≤*l (lemma-dropLast-≤* x≤*r)\n\nlemma-dropLast-heap : {t : PLRTree} → Heap t → Heap (dropLast t)\nlemma-dropLast-heap leaf = leaf\nlemma-dropLast-heap (node {perfect} {x} {l} {r} x≤*l x≤*r hl hr) \n with r\n... | leaf = hr\n... | node _ _ _ _ = node x≤*l (lemma-dropLast-≤* x≤*r) hl (lemma-dropLast-heap hr)\nlemma-dropLast-heap (node {left} {x} {l} {r} x≤*l x≤*r hl hr) \n with l | x≤*l | hl | dropLast l | lemma-dropLast-≤* x≤*l | lemma-dropLast-heap hl\n... | leaf | _ | _ | _ | _ | _ = leaf\n... | node perfect _ _ _ | _ | _ | node perfect y' l' r' | x≤*dll | hdll = node x≤*dll x≤*r hdll hr\n... | node perfect _ _ _ | _ | _ | leaf | (lf≤* .x) | leaf = node (lf≤* x) x≤*r leaf hr\n... | node perfect _ _ _ | _ | _ | node left _ _ _ | x≤*dll | hdll = node x≤*dll x≤*r hdll hr\n... | node perfect _ _ _ | _ | _ | node right _ _ _ | x≤*dll | hdll = node x≤*dll x≤*r hdll hr\n... | node left _ _ _ | _ | _ | node perfect y' l' r' | x≤*dll | hdll = node x≤*dll x≤*r hdll hr\n... | node left _ _ _ | _ | _ | leaf | (lf≤* .x) | leaf = node (lf≤* x) x≤*r leaf hr\n... | node left _ _ _ | _ | _ | node left _ _ _ | x≤*dll | hdll = node x≤*dll x≤*r hdll hr\n... | node left _ _ _ | _ | _ | node right _ _ _ | x≤*dll | hdll = node x≤*dll x≤*r hdll hr\n... | node right _ _ _ | _ | _ | node perfect y' l' r' | x≤*dll | hdll = node x≤*dll x≤*r hdll hr\n... | node right _ _ _ | _ | _ | leaf | (lf≤* .x) | leaf = node (lf≤* x) x≤*r leaf hr\n... | node right _ _ _ | _ | _ | node left _ _ _ | x≤*dll | hdll = node x≤*dll x≤*r hdll hr\n... | node right _ _ _ | _ | _ | node right _ _ _ | x≤*dll | hdll = node x≤*dll x≤*r hdll hr\nlemma-dropLast-heap (node {right} {x} {l} {r} x≤*l x≤*r hl hr) \n with r\n... | leaf = node x≤*r x≤*r hr hr\n... | node perfect y' l' r' = node (lemma-dropLast-≤* x≤*l) x≤*r (lemma-dropLast-heap hl) hr\n... | node left _ _ _ = node x≤*l (lemma-dropLast-≤* x≤*r) hl (lemma-dropLast-heap hr)\n... | node right _ _ _ = node x≤*l (lemma-dropLast-≤* x≤*r) hl (lemma-dropLast-heap hr)\n", "meta": {"hexsha": "c8163dd694c20f8101cb7c713e77f8c46aac2e68", "size": 3870, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/PLRTree/DropLast/Heap.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/PLRTree/DropLast/Heap.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/PLRTree/DropLast/Heap.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 58.6363636364, "max_line_length": 100, "alphanum_fraction": 0.5173126615, "num_tokens": 1892, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.888758793492457, "lm_q2_score": 0.6791787121629466, "lm_q1q2_score": 0.6036260527877011}} {"text": "\nopen import Oscar.Prelude\nopen import Oscar.Class\n\nmodule Oscar.Class.Transitivity where\n\nmodule Transitivity'\n {𝔬} {𝔒 : Ø 𝔬}\n {𝔯} (_∼_ : 𝔒 → 𝔒 → Ø 𝔯)\n x y z\n = ℭLASS (x ,, y ,, z ,, _∼_) (x ∼ y → y ∼ z → x ∼ z)\n\nmodule Transitivity\n {𝔬} {𝔒 : Ø 𝔬}\n {𝔯} (_∼_ : 𝔒 → 𝔒 → Ø 𝔯)\n where\n class = ∀ {x y z} → Transitivity'.class _∼_ x y z\n type = ∀ {x y z} → Transitivity'.type _∼_ x y z\n method : ⦃ _ : class ⦄ → type\n method {x = x} {y} {z} = Transitivity'.method _∼_ x y z\n\nmodule _\n {𝔬} {𝔒 : Ø 𝔬}\n {𝔯} {_∼_ : 𝔒 → 𝔒 → Ø 𝔯}\n where\n transitivity = Transitivity.method _∼_\n\nmodule _\n {𝔬} {𝔒 : Ø 𝔬}\n {𝔯} (_∼_ : 𝔒 → 𝔒 → Ø 𝔯)\n ⦃ _ : Transitivity.class _∼_ ⦄\n where\n transitivity[_] = λ {x y z} (x∼y : x ∼ y) (y∼z : y ∼ z) → Transitivity.method _∼_ x∼y y∼z\n infixr 9 ∙[]-syntax\n ∙[]-syntax = transitivity[_]\n syntax ∙[]-syntax _⊸_ f g = g ∙[ _⊸_ ] f\n\nmodule FlipTransitivity\n {𝔬} {𝔒 : Ø 𝔬}\n {𝔯} (_∼_ : 𝔒 → 𝔒 → Ø 𝔯)\n where\n class = Transitivity.class _∼_\n type = ∀ {x y z} → y ∼ z → x ∼ y → x ∼ z\n method : ⦃ _ : class ⦄ → type\n method = flip transitivity\n\nmodule _\n {𝔬} {𝔒 : Ø 𝔬}\n {𝔯} {_∼_ : 𝔒 → 𝔒 → Ø 𝔯}\n ⦃ _ : Transitivity.class _∼_ ⦄\n where\n infixr 9 _∙_\n _∙_ : ∀ {x y z} (y∼z : y ∼ z) (x∼y : x ∼ y) → x ∼ z\n g ∙ f = transitivity f g\n\nmodule _\n {𝔬} {𝔒 : Ø 𝔬}\n {𝔭} {𝔓 : 𝔒 → Ø 𝔭}\n where\n\n open import Oscar.Data.Proposequality\n\n ≡̇-transitivity = transitivity[ Proposextensequality⟦ 𝔓 ⟧ ]\n\n infixr 9 ≡̇-transitivity\n syntax ≡̇-transitivity f g = g ≡̇-∙ f\n\n infixr 9 ≡̇-transitivity-syntax\n ≡̇-transitivity-syntax = ≡̇-transitivity\n syntax ≡̇-transitivity-syntax f g = g ⟨≡̇⟩ f\n", "meta": {"hexsha": "9eac85757e1eb579a6b2a2ff2456e1ddbe5113e9", "size": 1614, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Transitivity.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Transitivity.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Transitivity.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.7323943662, "max_line_length": 91, "alphanum_fraction": 0.5464684015, "num_tokens": 842, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891305219505, "lm_q2_score": 0.734119526900183, "lm_q1q2_score": 0.6035850955212472}} {"text": "\nmodule _ where\n\n data Nat : Set where\n zero : Nat\n suc : Nat → Nat\n {-# BUILTIN NATURAL Nat #-}\n\n _+_ : (m n : Nat) → Nat\n zero + n = n\n suc m + n = suc (m + n)\n\n data Th : (m n : Nat) → Set where\n os : ∀ {m n} → Th m n → Th (suc m) (suc n)\n\n Fin : Nat → Set\n Fin = Th (suc zero)\n\n infixl 6 _++_\n infix 4 _≈M_\n\n postulate\n U : Set\n RCtx : Nat → Set\n _++_ : ∀ {m n} → RCtx m → RCtx n → RCtx (n + m)\n El : U → RCtx (suc zero)\n _≈M_ : ∀ {n} (Δ0 Δ1 : RCtx n) → Set\n\n infix 4 _⊢l-var_\n\n data _⊢l-var_ : ∀ {n} (Δi : RCtx n) (i : Fin n) → Set where\n os : ∀ {n} {e : Th zero n} {Δ Δπ π} (iq : Δπ ≈M (Δ ++ El π)) →\n Δπ ⊢l-var os e\n\n ⊢l-var-sub : ∀ {n Δ} {i : Fin n} → Δ ⊢l-var i → Set\n ⊢l-var-sub (os iq) = Nat\n", "meta": {"hexsha": "8af02ee8fbb2f88b1467223fabb2cc2cdcef8179", "size": 753, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue3930.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue3930.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue3930.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 20.3513513514, "max_line_length": 66, "alphanum_fraction": 0.4621513944, "num_tokens": 349, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8976953003183443, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.6035490125021147}} {"text": "{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule LogicalFramework.Disjunction where\n\nmodule LF where\n postulate\n _∨_ : Set → Set → Set\n inj₁ : {A B : Set} → A → A ∨ B\n inj₂ : {A B : Set} → B → A ∨ B\n case : {A B C : Set} → (A → C) → (B → C) → A ∨ B → C\n\n ∨-comm : {A B : Set} → A ∨ B → B ∨ A\n ∨-comm = case inj₂ inj₁\n\nmodule Inductive where\n\n open import Common.FOL.FOL\n\n ∨-comm-el : {A B : Set} → A ∨ B → B ∨ A\n ∨-comm-el = case inj₂ inj₁\n\n ∨-comm : {A B : Set} → A ∨ B → B ∨ A\n ∨-comm (inj₁ a) = inj₂ a\n ∨-comm (inj₂ b) = inj₁ b\n", "meta": {"hexsha": "ae53e908d7b804df376fab56e493fe41b95edd49", "size": 684, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/thesis/report/LogicalFramework/Disjunction.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/thesis/report/LogicalFramework/Disjunction.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/thesis/report/LogicalFramework/Disjunction.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 24.4285714286, "max_line_length": 56, "alphanum_fraction": 0.4926900585, "num_tokens": 267, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339716830606, "lm_q2_score": 0.7185943865443352, "lm_q1q2_score": 0.603428118242027}} {"text": "\ndata HasUniqueValues (A : Set) : List A → Set\n where\n [] : HasUniqueValues A []\n _∷_ : {x : A} → {xs : List A} → x ∉ xs → (uxs : HasUniqueValues A xs) → HasUniqueValues A (x ∷ xs)\n\nrecord AList (A : Set) (B : Set) : Set\n where\n field\n domain : List A\n uniquedomain : HasUniqueValues A domain\n range : ∀ {x : A} → x ∈ domain → B\n\nopen AList\n\nrecord Unifiable (F : Set) (T : Set) (U₁ U₂ : Set) (σ : (T → F) → F → F) : Set₁ where\n field\n _≈u≈_ : (φ₁ φ₂ : F) → Set\n unifier : (φ₁ φ₂ : F) → φ₁ ≈u≈ φ₂ → (F → F) × (F → F)\n unifier-law : (φ₁ φ₂ : F) → (=u= : φ₁ ≈u≈ φ₂) → (let u = unifier φ₁ φ₂ =u=) → (fst u) φ₁ ≡ (snd u) φ₂\n\nmutual\n data FTerm : 𝕃 VariableName → Set\n where\n variable : (𝑥 : VariableName) → FTerm (𝕃⟦ 𝑥 ⟧)\n function : (𝑓 : FunctionName) → ..{𝑥s : 𝕃 VariableName} {arity : Nat} → (τs : FTerms 𝑥s arity) → FTerm 𝑥s\n\n data FTerms : 𝕃 VariableName → Nat → Set\n where\n [] : FTerms ∅ zero\n _∷_ : ∀ ..{𝑥s' 𝑥s : 𝕃 VariableName} → FTerm 𝑥s' → {n : Nat} → FTerms 𝑥s n → FTerms (union {m = VariableName} 𝑥s' 𝑥s) (⊹ n)\n\ninstance MembershipVariableNameFTerm : ∀ {𝑥s} → Membership VariableName (FTerm 𝑥s)\nMembershipVariableNameFTerm = {!!}\n\nrecord TotalIntersection {ℓ} (m : Set ℓ) (M : Set ℓ) ⦃ _ : Membership m M ⦄ : Set ℓ\n where\n field\n intersection : M → M → M\n intersectionLaw1 : ∀ {x : m} {X₁ X₂ : M} → x ∈ intersection X₁ X₂ → x ∈ X₁\n intersectionLaw2 : ∀ {x : m} {X₁ X₂ : M} → x ∈ intersection X₁ X₂ → x ∈ X₂\n intersectionLaw3 : ∀ {x : m} {X₁ X₂ : M} → x ∈ X₁ × x ∈ X₂ → x ∈ intersection X₁ X₂\n\nopen TotalIntersection ⦃ … ⦄\n\n{-# DISPLAY TotalIntersection.intersection _ = intersection #-}\n\ninstance Intersection𝕃 : ∀ {ℓ} {A : Set ℓ} ⦃ _ : Eq A ⦄ → TotalIntersection A (𝕃 A)\nIntersection𝕃 = {!!}\n\nmutual\n subst : AList VariableName (∃ FTerm) → ∃ FTerm → ∃ FTerm\n subst x t@(.(✓ ∅) , variable 𝑥) with 𝑥 ∈? domain x\n … | yes x∈D = range x x∈D\n … | no x∉D = t\n subst x (fst₁ , function 𝑓 {𝑥s = 𝑥s} {arity = a} τs) with substs x a (𝑥s , τs)\n subst x (fst₁ , function 𝑓 {.fst₁} {arity₁} τs) | fst₂ , snd₁ = fst₂ , (function 𝑓 snd₁)\n\n substs : AList VariableName (∃ FTerm) → (a : Nat) → ∃ (flip FTerms a) → ∃ (flip FTerms a)\n substs x .0 (.∅ , []) = ∅ , []\n substs x .(suc _) (._ , (x₁ ∷ snd₁)) with {!subst x (_ , x₁)!}\n substs x .(suc _) (._ , (x₁ ∷ snd₁)) | sb = {!!}\n\n-- indexed by the number of function symbols contained\ndata DTerm : Nat → Set\n where\n variable : (𝑥 : VariableName) → DTerm zero\n function : (𝑓 : FunctionName) → {arity : Nat} → (τs : Vec (∃ DTerm) arity) → DTerm (suc (sum (fst <$> vecToList τs)))\n\nmutual\n substD : VariableName → ∃ DTerm → {n : Nat} → DTerm n → ∃ DTerm\n substD x x₁ (variable 𝑥) = ifYes 𝑥 ≟ x then x₁ else _ , variable 𝑥\n substD x x₁ (function 𝑓 τs) with substsD x x₁ τs\n substD x x₁ (function 𝑓 τs) | ss = suc (sum (fst <$> vecToList ss)) , function 𝑓 {_} ss\n\n substsD : VariableName → ∃ DTerm → {n : Nat} → Vec (Σ Nat DTerm) n → Vec (Σ Nat DTerm) n\n substsD x x₁ [] = []\n substsD x x₁ (x₂ ∷ x₃) with substD x x₁ (snd x₂) | substsD x x₁ x₃\n substsD x x₁ (x₂ ∷ x₃) | fst₁ , snd₁ | sss = (fst₁ , snd₁) ∷ sss\n\ndata HDTerm : Set where\n ⟨_⟩ : {n : Nat} → DTerm n → HDTerm\n\nsubstituteD : (AList VariableName HDTerm) → HDTerm → HDTerm\nsubstituteD = {!!}\n\namgu : HDTerm → HDTerm → (AList VariableName HDTerm) → Maybe (AList VariableName HDTerm)\namgu ⟨ variable 𝑥 ⟩ ⟨ variable 𝑥₁ ⟩ f = {!!}\namgu ⟨ variable 𝑥 ⟩ ⟨ function 𝑓 τs ⟩ f = {!!}\namgu ⟨ function 𝑓 τs ⟩ ⟨ variable 𝑥 ⟩ f = {!!}\namgu ⟨ function 𝑓 τs₁ ⟩ ⟨ function 𝑓₁ τs ⟩ f = {!!}\n\n{-\ndata AList : 𝕃 VariableName → Set\n where\n [] : AList ∅\n _∷_ :\n-}\nrecord JohnUnification {𝑥s₁} (τ₁ : FTerm 𝑥s₁) {𝑥s₂} (τ₂ : FTerm 𝑥s₂) (_ : intersection {m = VariableName} 𝑥s₁ 𝑥s₂ ≡ ∅) : Set where\n field\n u₁ u₂ : AList VariableName (∃ FTerm)\n unification-law₁ : fst (subst u₁ (𝑥s₁ , τ₁)) ≡ fst (subst u₂ (𝑥s₂ , τ₂))\n unification-law₂ : snd (subst u₁ (𝑥s₁ , τ₁)) ≡ transport FTerm (sym unification-law₁) (snd (subst u₂ (𝑥s₂ , τ₂)))\n\nrecord UnificationEquation (𝑥s : 𝕃 VariableName) : Set\n where\n field\n {lhs-terms} : 𝕃 VariableName\n lhs : FTerm lhs-terms\n {rhs-terms} : 𝕃 VariableName\n rhs : FTerm rhs-terms\n lhs∪rhs-terms : 𝑥s ≡ union {m = VariableName} lhs-terms rhs-terms\n\nopen UnificationEquation\n\nnumber-of-variables-that-occur-more-than-once : ∀ {n-eqn} → Vec (∃ λ 𝑥s → UnificationEquation 𝑥s) n-eqn → Nat\nnumber-of-variables-that-occur-more-than-once {zero} [] = 0\nnumber-of-variables-that-occur-more-than-once {suc n-eqn} x = {!!}\n\nnumber-of-function-symbols : ∀ {𝑥s} → FTerm 𝑥s → Nat\nnumber-of-function-symbols = {!!}\n\nrecord UnificationProblem (n-var n-lhs n-eqn : Nat) : Set\n where\n field\n equations : Vec (∃ λ 𝑥s → UnificationEquation 𝑥s) n-eqn\n n-var-law : number-of-variables-that-occur-more-than-once equations ≤ n-var\n n-lhs-law : (sum ∘ vecToList $ number-of-function-symbols ∘ lhs ∘ snd <$> equations) ≤ n-lhs\n\ninstance MembershipUnificationEquationUnificationProblem : ∀ {n-var n-lhs n-eqn 𝑥s} → Membership (UnificationEquation 𝑥s) (UnificationProblem n-var n-lhs n-eqn)\nMembershipUnificationEquationUnificationProblem = {!!}\n\ninstance MembershipVariableNameUnificationProblem : ∀ {n-var n-lhs n-eqn} → Membership VariableName (UnificationProblem n-var n-lhs n-eqn)\nMembershipVariableNameUnificationProblem = {!!}\n\ndeletable : ∀ {𝑥s} → UnificationEquation 𝑥s → Set\ndeletable = {!!}\n\ndeletable? : ∀ {𝑥s} → (eq : UnificationEquation 𝑥s) → Dec (deletable eq)\ndeletable? = {!!}\n\nu-deletable? : ∀ {n-var n-lhs n-eqn} (up : UnificationProblem n-var n-lhs n-eqn) → Dec (∃ λ 𝑥s → ∃ λ (εq : UnificationEquation 𝑥s) → deletable εq × εq ∈ up)\nu-deletable? {n-var} {n-lhs} {zero} up = no {!!}\nu-deletable? {n-var} {n-lhs} {suc n-eqn} up = {!!}\n\ndeleteRule : ∀ {n-var n-lhs n-eqn} {up : UnificationProblem n-var n-lhs (suc n-eqn)} {𝑥s} {εq : UnificationEquation 𝑥s} → deletable εq → εq ∈ up → UnificationProblem n-var n-lhs n-eqn\ndeleteRule = {!!}\n\ndecomposable : ∀ {𝑥s} → UnificationEquation 𝑥s → Set\ndecomposable = {!!}\n\ndecomposable? : ∀ {𝑥s} → (eq : UnificationEquation 𝑥s) → Dec (decomposable eq)\ndecomposable? = {!!}\n\nu-decomposable? : ∀ {n-var n-lhs n-eqn} (up : UnificationProblem n-var (suc n-lhs) n-eqn) → Dec (∃ λ 𝑥s → ∃ λ (εq : UnificationEquation 𝑥s) → decomposable εq × εq ∈ up)\nu-decomposable? = {!!}\n\ndecomposeRule : ∀ {n-var n-lhs n-eqn} {up : UnificationProblem n-var (suc n-lhs) n-eqn} {𝑥s} {εq : UnificationEquation 𝑥s} → decomposable εq → εq ∈ up → UnificationProblem n-var n-lhs n-eqn\ndecomposeRule = {!!}\n\nswapable : ∀ {𝑥s} → UnificationEquation 𝑥s → Set\nswapable = {!!}\n\nswapable? : ∀ {𝑥s} → (eq : UnificationEquation 𝑥s) → Dec (swapable eq)\nswapable? = {!!}\n\nu-swapable? : ∀ {n-var n-lhs n-eqn} (up : UnificationProblem n-var (suc n-lhs) n-eqn) → Dec (∃ λ 𝑥s → ∃ λ (εq : UnificationEquation 𝑥s) → swapable εq × εq ∈ up)\nu-swapable? = {!!}\n\nswapRule : ∀ {n-var n-lhs n-eqn} {up : UnificationProblem n-var (suc n-lhs) n-eqn} {𝑥s} {εq : UnificationEquation 𝑥s} → swapable εq → εq ∈ up → UnificationProblem n-var n-lhs n-eqn\nswapRule = {!!}\n\neliminatable : ∀ {n-var n-lhs n-eqn} {up : UnificationProblem n-var n-lhs n-eqn} {𝑥s} {εq : UnificationEquation 𝑥s} → (εq∈up : εq ∈ up) → Set\neliminatable = {!!}\n\nu-eliminatable? : ∀ {n-var n-lhs n-eqn} (up : UnificationProblem (suc n-var) n-lhs n-eqn) → Dec (∃ λ 𝑥s → ∃ λ (εq : UnificationEquation 𝑥s) → ∃ λ (εq∈up : εq ∈ up) → eliminatable {up = up} {εq = εq} εq∈up)\nu-eliminatable? = {!!}\n\neliminateRule : ∀ {n-var n-lhs n-eqn} {up : UnificationProblem (suc n-var) n-lhs n-eqn} {𝑥s} {εq : UnificationEquation 𝑥s} → {εq∈up : εq ∈ up} → eliminatable {up = up} {εq = εq} εq∈up → UnificationProblem n-var n-lhs n-eqn\neliminateRule = {!!}\n\nconflictable : ∀ {𝑥s} → UnificationEquation 𝑥s → Set\nconflictable = {!!}\n\nconflictable? : ∀ {𝑥s} → (εq : UnificationEquation 𝑥s) → Dec (conflictable εq)\nconflictable? = {!!}\n\nu-conflictable? : ∀ {n-var n-lhs n-eqn} (up : UnificationProblem n-var n-lhs n-eqn) → Dec (∃ λ 𝑥s → ∃ λ (εq : UnificationEquation 𝑥s) → conflictable εq × εq ∈ up)\nu-conflictable? = {!!}\n\ncheckable : ∀ {𝑥s} → UnificationEquation 𝑥s → Set\ncheckable = {!!}\n\ncheckable? : ∀ {𝑥s} → (εq : UnificationEquation 𝑥s) → Dec (checkable εq)\ncheckable? = {!!}\n\nu-checkable? : ∀ {n-var n-lhs n-eqn} (up : UnificationProblem n-var n-lhs n-eqn) → Dec (∃ λ 𝑥s → ∃ λ (εq : UnificationEquation 𝑥s) → checkable εq × εq ∈ up)\nu-checkable? = {!!}\n\n\npostulate\n substituteFormula : (VariableName → Term) → Formula → Formula\n\nrecord Unifier' : Set\n where\n field\n unifier-left unifier-right : VariableName → Term\n\nopen Unifier'\n\nrecord _Unifies_and_ (υ : Unifier') (φ₁ φ₂ : Formula) : Set\n where\n field\n unification-law : substituteFormula (unifier-left υ) φ₁ ≡ substituteFormula (unifier-right υ) φ₂\n", "meta": {"hexsha": "55b692ed9eb4b39aa2f2f39e2288c3d6567dd2e9", "size": 8747, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-1/UnificationStuff.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-1/UnificationStuff.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-1/UnificationStuff.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.6837209302, "max_line_length": 222, "alphanum_fraction": 0.6308448611, "num_tokens": 3549, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392848011833, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.6034219959939439}} {"text": "{-# OPTIONS -v tc.cover.splittree:50 #-}\n\nopen import Agda.Builtin.Nat\n\ndata Vec (A : Set) : Nat → Set where\n nil : Vec A zero\n cons : (n : Nat) → A → Vec A n → Vec A (suc n)\n\nappend : {A : Set} (m n : Nat) → Vec A m → Vec A n → Vec A (m + n)\nappend .zero n nil ys = ys\nappend (.suc m) n (cons .m x xs) ys = cons (m + n) x (append m n xs ys)\n\nopen import Agda.Builtin.Equality\n\ndata _×_ (A B : Set) : Set where\n pair : A → B → A × B\n\ntest : (p q : Nat × Nat) → p ≡ q → Set₁\ntest (.(pair x) y) (pair x .y) refl = Set\n", "meta": {"hexsha": "70ee11a8091af70af3d95a61ff33cd55f94cedfa", "size": 534, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/ForcedConstructorPattern.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/ForcedConstructorPattern.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/ForcedConstructorPattern.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 26.7, "max_line_length": 71, "alphanum_fraction": 0.5449438202, "num_tokens": 206, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357598021707, "lm_q2_score": 0.6959583376458153, "lm_q1q2_score": 0.6034207660713952}} {"text": "\nmodule Numeric.Nat.Prime.Properties where\n\nopen import Prelude\nopen import Control.WellFounded\nopen import Numeric.Nat.Properties\nopen import Numeric.Nat.Divide\nopen import Numeric.Nat.Divide.Properties\nopen import Numeric.Nat.GCD\nopen import Numeric.Nat.GCD.Extended\nopen import Numeric.Nat.GCD.Properties\nopen import Numeric.Nat.Prime\nopen import Tactic.Nat\n\nprime-nonzero : ∀ {p} → Prime p → NonZero p\nprime-nonzero {0} (prime p>1 _) = refute p>1\nprime-nonzero {suc _} _ = _\n\nprime-coprime/divide : ∀ p a → Prime p → Either (Coprime p a) (p Divides a)\nprime-coprime/divide p a (prime _ isp) with gcd p a\nprime-coprime/divide p a (prime _ isp) | gcd-res d isGCD =\n case isp d (IsGCD.d|a isGCD) of λ where\n (left d=1) → left d=1\n (right refl) → right (IsGCD.d|b isGCD)\n\nprime-divide-prime : ∀ {p q} → Prime p → Prime q → p Divides q → p ≡ q\nprime-divide-prime {p} (prime p>1 _) (prime _ dq) p|q =\n case dq p p|q of λ where\n (left refl) → refute p>1\n (right p=q) → p=q\n\nprime-split : ∀ {p} a b → Prime p → p Divides (a * b) → Either (p Divides a) (p Divides b)\nprime-split a b isP p|ab =\n case prime-coprime/divide _ a isP of λ where\n (left p/a) → right (coprime-divide-mul-l _ a b p/a p|ab)\n (right p|a) → left p|a\n\n-- It's enough to check prime divisors when checking coprimality.\nmodule _ (a b : Nat) (f : ∀ p → Prime p → p Divides a → p Divides b → p Divides 1) where\n\n private\n coprimeByPrimes′ : (k : Nat) → Acc _<_ k → k Divides a → k Divides b → k Divides 1\n coprimeByPrimes′ k (acc wf) k|a k|b =\n case isPrime k of λ where\n (yes isP) → f k isP k|a k|b\n (no (composite i j i>1 j>1 refl)) →\n let i|1 : i Divides 1\n i|1 = coprimeByPrimes′ i (wf i (less-mul-l i>1 j>1))\n (mul-divides-l i j a k|a) (mul-divides-l i j b k|b)\n j|1 : j Divides 1\n j|1 = coprimeByPrimes′ j (wf j (less-mul-r i>1 j>1))\n (mul-divides-r i j a k|a) (mul-divides-r i j b k|b)\n in case₂ divides-one i|1 , divides-one j|1 of λ where\n refl refl → factor! 1\n (tiny (diff! 0)) → factor! 1\n (tiny (diff! 1)) →\n case₂ divides-zero k|a , divides-zero k|b of λ where\n refl refl →\n let 2∤1 = fromDec (2 divides? 1)\n 2|0 = fromDec (2 divides? 0) in\n ⊥-elim (2∤1 (f 2 (fromDec (decPrime 2)) 2|0 2|0))\n (tiny (diff (suc (suc _)) eq)) → refute eq\n\n coprimeByPrimes : Coprime a b\n coprimeByPrimes = coprimeByDivide a b λ k → coprimeByPrimes′ k (wfNat k)\n\ncoprime-mul-r : ∀ a b c → Coprime a b → Coprime a c → Coprime a (b * c)\ncoprime-mul-r a b c a/b a/c =\n coprimeByPrimes a (b * c) λ p isP p|a p|bc →\n case prime-split b c isP p|bc of λ where\n (left p|b) → divide-coprime p a b a/b p|a p|b\n (right p|c) → divide-coprime p a c a/c p|a p|c\n\ncoprime-mul-l : ∀ a b c → Coprime a c → Coprime b c → Coprime (a * b) c\ncoprime-mul-l a b c a/c b/c =\n coprime-sym c _ (coprime-mul-r c a b (coprime-sym a _ a/c) (coprime-sym b _ b/c))\n\nprime-divide-coprime : ∀ p a b → Prime p → Coprime a b → p Divides a → p Divides b → ⊥\nprime-divide-coprime p a b isP a/b p|a p|b =\n case divides-one {p} (divide-coprime p a b a/b p|a p|b) of λ where\n refl → fromDec (decPrime 1) isP\n", "meta": {"hexsha": "be5a297c0abda112a93c8ab5ffee1020d08b7190", "size": 3322, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Numeric/Nat/Prime/Properties.agda", "max_stars_repo_name": "t-more/agda-prelude", "max_stars_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 111, "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_issues_repo_path": "src/Numeric/Nat/Prime/Properties.agda", "max_issues_repo_name": "t-more/agda-prelude", "max_issues_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_forks_repo_path": "src/Numeric/Nat/Prime/Properties.agda", "max_forks_repo_name": "t-more/agda-prelude", "max_forks_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "avg_line_length": 40.512195122, "max_line_length": 90, "alphanum_fraction": 0.5978326309, "num_tokens": 1245, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357598021707, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.6034207551360257}} {"text": "module Cats.Category.Arrow where\n\nopen import Level\nopen import Relation.Binary using (IsEquivalence ; _Preserves₂_⟶_⟶_)\n\nopen import Cats.Category\n\n\nmodule _ {lo la l≈} (C : Category lo la l≈) where\n\n infixr 9 _∘_\n infixr 4 _≈_\n\n private\n module C = Category C\n module ≈ = C.≈\n\n\n record Obj : Set (lo ⊔ la) where\n field\n Dom : C.Obj\n Cod : C.Obj\n arr : Dom C.⇒ Cod\n\n open Obj\n\n\n record _⇒_ (f g : Obj) : Set (la ⊔ l≈) where\n field\n dom : Dom f C.⇒ Dom g\n cod : Cod f C.⇒ Cod g\n commute : arr g C.∘ dom C.≈ cod C.∘ arr f\n\n open _⇒_\n\n\n record _≈_ {A B} (F G : A ⇒ B) : Set l≈ where\n field\n dom : dom F C.≈ dom G\n cod : cod F C.≈ cod G\n\n\n id : ∀ {A} → A ⇒ A\n id {record { Dom = Dom ; Cod = Cod ; arr = arr }}\n = record\n { dom = C.id\n ; cod = C.id\n ; commute = ≈.trans C.id-r (≈.sym C.id-l)\n }\n\n\n _∘_ : ∀ {A B C} → (B ⇒ C) → (A ⇒ B) → (A ⇒ C)\n _∘_ {F} {G} {H}\n record { dom = F-dom ; cod = F-cod ; commute = F-commute }\n record { dom = G-dom ; cod = G-cod ; commute = G-commute }\n = record\n { dom = F-dom C.∘ G-dom\n ; cod = F-cod C.∘ G-cod\n ; commute\n = begin\n arr H C.∘ F-dom C.∘ G-dom\n ≈⟨ C.unassoc ⟩\n (arr H C.∘ F-dom) C.∘ G-dom\n ≈⟨ C.∘-resp-l F-commute ⟩\n (F-cod C.∘ arr G) C.∘ G-dom\n ≈⟨ C.assoc ⟩\n F-cod C.∘ arr G C.∘ G-dom\n ≈⟨ C.∘-resp-r G-commute ⟩\n F-cod C.∘ G-cod C.∘ arr F\n ≈⟨ C.unassoc ⟩\n (F-cod C.∘ G-cod) C.∘ arr F\n ∎\n }\n where\n open C.≈-Reasoning\n\n\n equiv : ∀ {A B} → IsEquivalence (_≈_ {A} {B})\n equiv = record\n { refl = record { dom = ≈.refl ; cod = ≈.refl }\n ; sym = λ where\n record { dom = dom ; cod = cod } → record\n { dom = ≈.sym dom\n ; cod = ≈.sym cod\n }\n ; trans = λ where\n record { dom = dom₁ ; cod = cod₁ } record { dom = dom₂ ; cod = cod₂ }\n → record\n { dom = ≈.trans dom₁ dom₂\n ; cod = ≈.trans cod₁ cod₂\n }\n }\n\n\n ∘-resp : ∀ {A B C} → (_∘_ {A} {B} {C}) Preserves₂ _≈_ ⟶ _≈_ ⟶ _≈_\n ∘-resp\n record { dom = dom-FG ; cod = cod-FG }\n record { dom = dom-HI ; cod = cod-HI }\n = record\n { dom = C.∘-resp dom-FG dom-HI\n ; cod = C.∘-resp cod-FG cod-HI\n }\n\n\n id-r : ∀ {A B} {F : A ⇒ B} → F ∘ id ≈ F\n id-r = record\n { dom = C.id-r\n ; cod = C.id-r\n }\n\n\n id-l : ∀ {A B} {F : A ⇒ B} → id ∘ F ≈ F\n id-l = record\n { dom = C.id-l\n ; cod = C.id-l\n }\n\n\n assoc : ∀ {A B C D} {F : C ⇒ D} {G : B ⇒ C} {H : A ⇒ B}\n → (F ∘ G) ∘ H ≈ F ∘ (G ∘ H)\n assoc = record\n { dom = C.assoc\n ; cod = C.assoc\n }\n\n\n _⃗ : Category (la ⊔ lo) (l≈ ⊔ la) l≈\n _⃗ = record\n { Obj = Obj\n ; _⇒_ = _⇒_\n ; _≈_ = _≈_\n ; id = id\n ; _∘_ = _∘_\n ; equiv = equiv\n ; ∘-resp = ∘-resp\n ; id-r = id-r\n ; id-l = id-l\n ; assoc = assoc\n }\n", "meta": {"hexsha": "15004ceb2b97f865ae1ca6a7ff7aaaa5ef887eed", "size": 3036, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Category/Arrow.agda", "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cats/Category/Arrow.agda", "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cats/Category/Arrow.agda", "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.6857142857, "max_line_length": 79, "alphanum_fraction": 0.4186429513, "num_tokens": 1240, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357666736772, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.6034207544506229}} {"text": "-- Free category over a directed graph/quiver\n{-# OPTIONS --safe #-}\n\nmodule Cubical.Categories.Constructions.Free where\n\nopen import Cubical.Categories.Category.Base\nopen import Cubical.Data.Graph.Base\nopen import Cubical.Data.Graph.Path\nopen import Cubical.Foundations.Prelude hiding (Path)\n\nmodule _ {ℓv ℓe : Level} where\n\n module _ (G : Graph ℓv ℓe)\n (isSetNode : isSet (Node G))\n (isSetEdge : ∀ v w → isSet (Edge G v w)) where\n open Category\n\n FreeCategory : Category ℓv (ℓ-max ℓv ℓe)\n FreeCategory .ob = Node G\n FreeCategory .Hom[_,_] = Path G\n FreeCategory .id = pnil\n FreeCategory ._⋆_ = ccat G\n FreeCategory .⋆IdL = pnil++ G\n FreeCategory .⋆IdR P = refl\n FreeCategory .⋆Assoc = ++assoc G\n FreeCategory .isSetHom = isSetPath G isSetNode isSetEdge _ _\n", "meta": {"hexsha": "5bab3d91402430195e63c79d0a6b019c33fd9643", "size": 808, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Constructions/Free.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_issues_repo_path": "Cubical/Categories/Constructions/Free.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Categories/Constructions/Free.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.9259259259, "max_line_length": 64, "alphanum_fraction": 0.6856435644, "num_tokens": 248, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9263037262250327, "lm_q2_score": 0.6513548511303336, "lm_q1q2_score": 0.6033524256967795}} {"text": "open import Relation.Binary.Core\n\nmodule BBHeap.Insert.Properties {A : Set}\n (_≤_ : A → A → Set)\n (tot≤ : Total _≤_) \n (trans≤ : Transitive _≤_) where\n\nopen import BBHeap _≤_\nopen import BBHeap.Insert _≤_ tot≤ trans≤\nopen import BBHeap.Subtyping.Properties _≤_ trans≤\nopen import Bound.Lower A\nopen import Bound.Lower.Order _≤_ \nopen import Data.List\nopen import Data.Sum \nopen import List.Permutation.Base A\nopen import List.Permutation.Base.Concatenation A\nopen import List.Permutation.Base.Equivalence A\nopen import Order.Total _≤_ tot≤ \n\nlemma-insert∼ : {b : Bound}{x : A}(b≤x : LeB b (val x))(h : BBHeap b) → (x ∷ flatten h) ∼ (flatten (insert b≤x h))\nlemma-insert∼ b≤x leaf = refl∼\nlemma-insert∼ {x = x} b≤x (left {x = y} {l = l} {r = r} b≤y l⋘r) \n with tot≤ x y\n... | inj₁ x≤y \n with lemma-insert⋘ (lexy refl≤) l⋘r\n... | inj₁ lᵢ⋘r \n rewrite lemma-subtyping≡ {val y} {val x} (lexy x≤y) (insert {val y} {y} (lexy refl≤) l) \n | lemma-subtyping≡ {val y} {val x} (lexy x≤y) r \n = ∼x /head /head (lemma++∼r (lemma-insert∼ (lexy refl≤) l)) \n... | inj₂ lᵢ⋗r \n rewrite lemma-subtyping≡ {val y} {val x} (lexy x≤y) (insert {val y} {y} (lexy refl≤) l) \n | lemma-subtyping≡ {val y} {val x} (lexy x≤y) r \n = ∼x /head /head (lemma++∼r (lemma-insert∼ (lexy refl≤) l))\nlemma-insert∼ {x = x} b≤x (left {x = y} {l = l} {r = r} b≤y l⋘r) | inj₂ y≤x \n with lemma-insert⋘ (lexy y≤x) l⋘r\n... | inj₁ lᵢ⋘r = ∼x (/tail /head) /head (lemma++∼r (lemma-insert∼ (lexy y≤x) l)) \n... | inj₂ lᵢ⋗r = ∼x (/tail /head) /head (lemma++∼r (lemma-insert∼ (lexy y≤x) l)) \nlemma-insert∼ {x = x} b≤x (right {x = y} {l = l} {r = r} b≤y l⋙r) \n with tot≤ x y\n... | inj₁ x≤y \n with lemma-insert⋙ (lexy refl≤) l⋙r\n... | inj₁ l⋙rᵢ \n rewrite lemma-subtyping≡ {val y} {val x} (lexy x≤y) (insert {val y} {y} (lexy refl≤) r) \n | lemma-subtyping≡ {val y} {val x} (lexy x≤y) l \n = ∼x /head /head (trans∼ (∼x /head (lemma++/ {xs = flatten l}) refl∼) (lemma++∼l {xs = flatten l} (lemma-insert∼ (lexy refl≤) r)))\n... | inj₂ l≃rᵢ \n rewrite lemma-subtyping≡ {val y} {val x} (lexy x≤y) (insert {val y} {y} (lexy refl≤) r) \n | lemma-subtyping≡ {val y} {val x} (lexy x≤y) l \n = ∼x /head /head (trans∼ (∼x /head (lemma++/ {xs = flatten l}) refl∼) (lemma++∼l {xs = flatten l} (lemma-insert∼ (lexy refl≤) r)))\nlemma-insert∼ {x = x} b≤x (right {x = y} {l = l} {r = r} b≤y l⋙r) | inj₂ y≤x \n with lemma-insert⋙ (lexy y≤x) l⋙r\n... | inj₁ l⋙rᵢ = ∼x (/tail /head) /head (trans∼ (∼x /head (lemma++/ {xs = flatten l}) refl∼) (lemma++∼l {xs = flatten l} (lemma-insert∼ (lexy y≤x) r)))\n... | inj₂ l≃rᵢ = ∼x (/tail /head) /head (trans∼ (∼x /head (lemma++/ {xs = flatten l}) refl∼) (lemma++∼l {xs = flatten l} (lemma-insert∼ (lexy y≤x) r)))\n", "meta": {"hexsha": "6f4f064c21f8c6cd317f8a92b0a25cff33a54b89", "size": 2941, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/BBHeap/Insert/Properties.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/BBHeap/Insert/Properties.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/BBHeap/Insert/Properties.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.462962963, "max_line_length": 152, "alphanum_fraction": 0.5399523971, "num_tokens": 1256, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9019206844384594, "lm_q2_score": 0.668880247169804, "lm_q1q2_score": 0.6032769303347555}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- The basic code for equational reasoning with a partial relation\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary\n\nmodule Relation.Binary.Reasoning.Base.Partial\n {a ℓ} {A : Set a} (_∼_ : Rel A ℓ) (trans : Transitive _∼_)\n where\n\nopen import Level using (_⊔_)\nopen import Relation.Binary.PropositionalEquality.Core as P\n using (_≡_)\n\ninfix 4 _IsRelatedTo_\ninfix 3 _∎⟨_⟩\ninfixr 2 step-∼ step-≡ step-≡˘\ninfixr 2 _≡⟨⟩_\ninfix 1 begin_\n\n------------------------------------------------------------------------\n-- Definition of \"related to\"\n\n-- This seemingly unnecessary type is used to make it possible to\n-- infer arguments even if the underlying equality evaluates.\n\ndata _IsRelatedTo_ (x y : A) : Set ℓ where\n relTo : (x∼y : x ∼ y) → x IsRelatedTo y\n\n------------------------------------------------------------------------\n-- Reasoning combinators\n\n-- Note that the arguments to the `step`s are not provided in their\n-- \"natural\" order and syntax declarations are later used to re-order\n-- them. This is because the `step` ordering allows the type-checker to\n-- better infer the middle argument `y` from the `_IsRelatedTo_`\n-- argument (see issue 622).\n--\n-- This has two practical benefits. First it speeds up type-checking by\n-- approximately a factor of 5. Secondly it allows the combinators to be\n-- used with macros that use reflection, e.g. `Tactic.RingSolver`, where\n-- they need to be able to extract `y` using reflection.\n\n-- Beginning of a proof\n\nbegin_ : ∀ {x y} → x IsRelatedTo y → x ∼ y\nbegin relTo x∼y = x∼y\n\n-- Standard step with the relation\n\nstep-∼ : ∀ x {y z} → y IsRelatedTo z → x ∼ y → x IsRelatedTo z\nstep-∼ _ (relTo y∼z) x∼y = relTo (trans x∼y y∼z)\n\n-- Step with a non-trivial propositional equality\n\nstep-≡ : ∀ x {y z} → y IsRelatedTo z → x ≡ y → x IsRelatedTo z\nstep-≡ _ x∼z P.refl = x∼z\n\n-- Step with a flipped non-trivial propositional equality\n\nstep-≡˘ : ∀ x {y z} → y IsRelatedTo z → y ≡ x → x IsRelatedTo z\nstep-≡˘ _ x∼z P.refl = x∼z\n\n-- Step with a trivial propositional equality\n\n_≡⟨⟩_ : ∀ x {y} → x IsRelatedTo y → x IsRelatedTo y\n_ ≡⟨⟩ x∼y = x∼y\n\n-- Termination step\n\n_∎⟨_⟩ : ∀ x → x ∼ x → x IsRelatedTo x\n_ ∎⟨ x∼x ⟩ = relTo x∼x\n\n-- Syntax declarations\n\nsyntax step-∼ x y∼z x∼y = x ∼⟨ x∼y ⟩ y∼z\nsyntax step-≡ x y≡z x≡y = x ≡⟨ x≡y ⟩ y≡z\nsyntax step-≡˘ x y≡z y≡x = x ≡˘⟨ y≡x ⟩ y≡z\n", "meta": {"hexsha": "43ca14ec597e30df0002bb96e55a214a4600ce3f", "size": 2519, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Relation/Binary/Reasoning/Base/Partial.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Relation/Binary/Reasoning/Base/Partial.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Relation/Binary/Reasoning/Base/Partial.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 30.3493975904, "max_line_length": 72, "alphanum_fraction": 0.593092497, "num_tokens": 824, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7931059609645724, "lm_q2_score": 0.7606506526772883, "lm_q1q2_score": 0.6032765668499499}} {"text": "----------------------------------------------------------------\n-- This file contains the definition of isomorphisms. --\n----------------------------------------------------------------\nmodule Category.Iso where\n\nopen import Category.Category\n\nrecord Iso {l : Level}{ℂ : Cat {l}}{A B : Obj ℂ} (f : el (Hom ℂ A B)) : Set l where\n field\n inv : el (Hom ℂ B A)\n\n left-inv-ax : ⟨ Hom ℂ A A ⟩[ f ○[ comp ℂ ] inv ≡ id ℂ ]\n right-inv-ax : ⟨ Hom ℂ B B ⟩[ inv ○[ comp ℂ ] f ≡ id ℂ ]\n\nopen Iso public\n", "meta": {"hexsha": "4f1e29bce2d669af342a71530e1ffb2db3ec0213", "size": 510, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "setoid-cats/Category/Iso.agda", "max_stars_repo_name": "heades/AUGL", "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "setoid-cats/Category/Iso.agda", "max_issues_repo_name": "heades/AUGL", "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "setoid-cats/Category/Iso.agda", "max_forks_repo_name": "heades/AUGL", "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.875, "max_line_length": 83, "alphanum_fraction": 0.4294117647, "num_tokens": 146, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9111797148356995, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.6031307033370572}} {"text": "{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-}\n\nmodule Light.Library.Relation.Binary where\n\nopen import Light.Level using (Setω ; Level)\nopen import Light.Variable.Levels\nopen import Light.Variable.Sets\nopen import Light.Library.Relation using (Base ; Index ; Proposition ; True ; _⇢_)\n\nmodule _ ⦃ base : Base ⦄ where\n record Binary (𝕒 : Set aℓ) (𝕓 : Set bℓ) : Setω where\n field if : 𝕒 → 𝕓 → Index\n field are : ∀ a b → Proposition (if a b)\n \n SelfBinary : Set aℓ → Setω\n SelfBinary 𝕒 = Binary 𝕒 𝕒\n \n open Binary using (are)\n \n private variable a : 𝕒\n private variable b : 𝕓\n private variable c : 𝕔\n \n record Transitive\n (a‐b‐valid : Binary 𝕒 𝕓)\n (b‐c‐valid : Binary 𝕓 𝕔)\n (a‐c‐valid : Binary 𝕒 𝕔)\n : Setω where\n \n field transitivity : True (are a‐b‐valid a b ⇢ (are b‐c‐valid b c ⇢ are a‐c‐valid a c))\n \n record Symmetric\n (a‐b‐valid : Binary 𝕒 𝕓)\n (b‐a‐valid : Binary 𝕓 𝕒)\n : Setω where\n \n field symmetry : True (are a‐b‐valid a b ⇢ are b‐a‐valid b a)\n \n record Reflexive (valid : SelfBinary 𝕒) : Setω where\n field reflexivity : True (are valid a a)\n \n SelfTransitive : ∀ (valid : SelfBinary 𝕒) → Setω\n SelfTransitive valid = Transitive valid valid valid\n \n SelfSymmetric : ∀ (valid : SelfBinary 𝕒) → Setω\n SelfSymmetric valid = Symmetric valid valid\n \n record Preserved\n (f : 𝕒 → 𝕓) (g : 𝕔 → 𝕕)\n (a‐c‐valid : Binary 𝕒 𝕔)\n (b‐d‐valid : Binary 𝕓 𝕕)\n : Setω where\n \n field preservation : True (are a‐c‐valid a c ⇢ are b‐d‐valid (f a) (g c))\n congruence = preservation\n \n CongruentFor :\n (𝕒 → 𝕓)\n → SelfBinary 𝕒\n → SelfBinary 𝕓\n → Setω\n CongruentFor f = Preserved f f\n \n SelfCongruentFor :\n (𝕒 → 𝕒)\n → SelfBinary 𝕒\n → Setω\n SelfCongruentFor f 𝕒 = CongruentFor f 𝕒 𝕒\n \n record Bijective\n (f : 𝕒 → 𝕓) (g : 𝕔 → 𝕕)\n (b‐d‐valid : Binary 𝕓 𝕕)\n (a‐c‐valid : Binary 𝕒 𝕔)\n : Setω where\n \n field bijectivity : True (are b‐d‐valid (f a) (g c) ⇢ are a‐c‐valid a c)\n injectivity = bijectivity\n \n Injective :\n (𝕒 → 𝕓)\n → SelfBinary 𝕓\n → SelfBinary 𝕒\n → Setω\n Injective f = Bijective f f\n \n SelfInjective :\n (𝕒 → 𝕒)\n → SelfBinary 𝕒\n → Setω\n SelfInjective f 𝕒 = Injective f 𝕒 𝕒\n\nopen Transitive ⦃ ... ⦄ public\nopen Symmetric ⦃ ... ⦄ public\nopen Reflexive ⦃ ... ⦄ public\nopen Preserved ⦃ ... ⦄ public\nopen Bijective ⦃ ... ⦄ public\n", "meta": {"hexsha": "6e1fcf652ce048dee719bf480d188d6482f4b1b8", "size": 2897, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Light/Library/Relation/Binary.agda", "max_stars_repo_name": "zamfofex/lightlib", "max_stars_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_stars_repo_licenses": ["0BSD"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z", "max_issues_repo_path": "Light/Library/Relation/Binary.agda", "max_issues_repo_name": "Zambonifofex/lightlib", "max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_issues_repo_licenses": ["0BSD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Light/Library/Relation/Binary.agda", "max_forks_repo_name": "Zambonifofex/lightlib", "max_forks_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_forks_repo_licenses": ["0BSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.8659793814, "max_line_length": 99, "alphanum_fraction": 0.5115636866, "num_tokens": 926, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972684083609, "lm_q2_score": 0.6926419831347362, "lm_q1q2_score": 0.6030122185020513}} {"text": "module Iff where\n\ninfix 20 _⇔_\nrecord _⇔_ (A B : Set) : Set where\n field\n to : A → B\n from : B → A\n", "meta": {"hexsha": "1735ee8c52eb9f708065e1c15542929eadf433d4", "size": 108, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "blame/Iff.agda", "max_stars_repo_name": "leopoulson/plfa.github.io", "max_stars_repo_head_hexsha": "b2e5e76c3cb6d0c0f3b2779cf20d439db42a33af", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "blame/Iff.agda", "max_issues_repo_name": "leopoulson/plfa.github.io", "max_issues_repo_head_hexsha": "b2e5e76c3cb6d0c0f3b2779cf20d439db42a33af", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "blame/Iff.agda", "max_forks_repo_name": "leopoulson/plfa.github.io", "max_forks_repo_head_hexsha": "b2e5e76c3cb6d0c0f3b2779cf20d439db42a33af", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 13.5, "max_line_length": 34, "alphanum_fraction": 0.5462962963, "num_tokens": 48, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8705972684083609, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.6030122185020512}} {"text": "open import Agda.Primitive using (lzero; lsuc; _⊔_)\n\nopen import Relation.Binary.PropositionalEquality\nimport Relation.Binary.Reasoning.Setoid as SetoidR\n\nimport Categories.Category as Category\nimport Categories.Category.Cartesian as Cartesian\nopen import Categories.Object.Terminal using (Terminal)\nopen import Categories.Object.Product using (Product)\n\nopen import MultiSorted.AlgebraicTheory\nimport MultiSorted.Substitution as Substitution\nimport MultiSorted.Product as Product\n\nmodule MultiSorted.SyntacticCategory\n {ℓt}\n {𝓈 ℴ}\n {Σ : Signature {𝓈} {ℴ}}\n (T : Theory ℓt Σ) where\n\n open Theory T\n open Substitution T\n\n -- The syntactic category\n\n 𝒮 : Category.Category 𝓈 (lsuc ℴ) (lsuc (ℓt ⊔ 𝓈 ⊔ ℴ))\n 𝒮 =\n record\n { Obj = Context\n ; _⇒_ = _⇒s_\n ; _≈_ = _≈s_\n ; id = id-s\n ; _∘_ = _∘s_\n ; assoc = λ {_ _ _ _ _ _ σ} x → subst-∘s (σ x)\n ; sym-assoc = λ {_ _ _ _ _ _ σ} x → eq-symm (subst-∘s (σ x))\n ; identityˡ = λ x → eq-refl\n ; identityʳ = λ {A B f} x → tm-var-id\n ; identity² = λ x → eq-refl\n ; equiv = record\n { refl = λ x → eq-refl\n ; sym = λ ξ y → eq-symm (ξ y)\n ; trans = λ ζ ξ y → eq-tran (ζ y) (ξ y)}\n ; ∘-resp-≈ = ∘s-resp-≈s\n }\n\n -- We use the product structure which gives back the context directly\n prod-𝒮 : Context → Context\n prod-𝒮 Γ = Γ\n\n π-𝒮 : ∀ {Γ} (x : var Γ) → Γ ⇒s ctx-slot (sort-of Γ x)\n π-𝒮 x _ = tm-var x\n\n tuple-𝒮 : ∀ Γ {Δ} → (∀ (x : var Γ) → Δ ⇒s ctx-slot (sort-of Γ x)) → Δ ⇒s Γ\n tuple-𝒮 Γ ts = λ x → ts x var-var\n\n project-𝒮 : ∀ {Γ Δ} {x : var Γ} {ts : ∀ (y : var Γ) → Δ ⇒s ctx-slot (sort-of Γ y)} →\n π-𝒮 x ∘s tuple-𝒮 Γ ts ≈s ts x\n project-𝒮 {Γ} {Δ} {x} {ts} var-var = eq-refl\n\n unique-𝒮 : ∀ {Γ Δ} {ts : ∀ (x : var Γ) → Δ ⇒s ctx-slot (sort-of Γ x)} {g : Δ ⇒s Γ} →\n (∀ x → π-𝒮 x ∘s g ≈s ts x) → tuple-𝒮 Γ ts ≈s g\n unique-𝒮 ξ x = eq-symm (ξ x var-var)\n\n\n producted-𝒮 : Product.Producted 𝒮 {Σ = Σ} ctx-slot\n producted-𝒮 =\n record\n { prod = prod-𝒮\n ; π = π-𝒮\n ; tuple = tuple-𝒮\n ; project = λ {Γ Δ x ts} → project-𝒮 {ts = ts}\n ; unique = unique-𝒮\n }\n\n -- The terminal object is the empty context\n ⊤-𝒮 : Context\n ⊤-𝒮 = ctx-empty\n\n !-𝒮 : ∀ {Γ} → Γ ⇒s ⊤-𝒮\n !-𝒮 ()\n\n !-unique-𝒮 : ∀ {Γ} (σ : Γ ⇒s ⊤-𝒮) → !-𝒮 ≈s σ\n !-unique-𝒮 σ ()\n\n terminal-𝒮 : Terminal 𝒮\n terminal-𝒮 =\n record\n { ⊤ = ⊤-𝒮\n ; ⊤-is-terminal =\n record { ! = !-𝒮\n ; !-unique = !-unique-𝒮 } }\n\n -- Binary product is context contatenation\n product-𝒮 : ∀ {Γ Δ} → Product 𝒮 Γ Δ\n product-𝒮 {Γ} {Δ} =\n record\n { A×B = ctx-concat Γ Δ\n ; π₁ = λ x → tm-var (var-inl x)\n ; π₂ = λ x → tm-var (var-inr x)\n ; ⟨_,_⟩ = ⟨_,_⟩s\n ; project₁ = λ x → eq-refl\n ; project₂ = λ x → eq-refl\n ; unique = λ {Θ σ σ₁ σ₂} ξ₁ ξ₂ z → u Θ σ σ₁ σ₂ ξ₁ ξ₂ z\n }\n where u : ∀ Θ (σ : Θ ⇒s ctx-concat Γ Δ) (σ₁ : Θ ⇒s Γ) (σ₂ : Θ ⇒s Δ) →\n ((λ x → σ (var-inl x)) ≈s σ₁) → ((λ y → σ (var-inr y)) ≈s σ₂) → ⟨ σ₁ , σ₂ ⟩s ≈s σ\n u Θ σ σ₁ σ₂ ξ₁ ξ₂ (var-inl z) = eq-symm (ξ₁ z)\n u Θ σ σ₁ σ₂ ξ₁ ξ₂ (var-inr z) = eq-symm (ξ₂ z)\n\n -- The cartesian structure of the syntactic category\n cartesian-𝒮 : Cartesian.Cartesian 𝒮\n cartesian-𝒮 =\n record\n { terminal = terminal-𝒮\n ; products = record { product = product-𝒮 } }\n", "meta": {"hexsha": "5e4a1cc95ee348a497145f02f736474e7c48a505", "size": 3391, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/MultiSorted/SyntacticCategory.agda", "max_stars_repo_name": "cilinder/formaltt", "max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 21, "max_stars_repo_stars_event_min_datetime": "2021-02-16T14:07:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-19T15:50:08.000Z", "max_issues_repo_path": "src/MultiSorted/SyntacticCategory.agda", "max_issues_repo_name": "andrejbauer/formaltt", "max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z", "max_forks_repo_path": "src/MultiSorted/SyntacticCategory.agda", "max_forks_repo_name": "andrejbauer/formaltt", "max_forks_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z", "avg_line_length": 29.2327586207, "max_line_length": 99, "alphanum_fraction": 0.5275729873, "num_tokens": 1432, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835411997897, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.6030045698344075}} {"text": "{-# OPTIONS --cubical --safe --no-sized-types --no-guardedness #-}\nmodule Agda.Builtin.Cubical.Path where\n\n open import Agda.Primitive.Cubical\n\n postulate\n PathP : ∀ {ℓ} (A : I → Set ℓ) → A i0 → A i1 → Set ℓ\n\n {-# BUILTIN PATHP PathP #-}\n\n infix 4 _≡_\n _≡_ : ∀ {ℓ} {A : Set ℓ} → A → A → Set ℓ\n _≡_ {A = A} = PathP (λ _ → A)\n\n {-# BUILTIN PATH _≡_ #-}\n", "meta": {"hexsha": "7e8e4d4856b883cb9a82c273f23a661f589918c3", "size": 384, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/Cubical/Path.agda", "max_stars_repo_name": "phadej/agda", "max_stars_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/Cubical/Path.agda", "max_issues_repo_name": "phadej/agda", "max_issues_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/Cubical/Path.agda", "max_forks_repo_name": "phadej/agda", "max_forks_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.0, "max_line_length": 66, "alphanum_fraction": 0.5234375, "num_tokens": 154, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8354835371034368, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.6030045668778926}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category using (Category; module Commutation)\nopen import Categories.Category.Monoidal.Core using (Monoidal)\nopen import Categories.Category.Monoidal.Braided using (Braided)\n\n-- Braided monoidal categories satisfy the \"four middle interchange\"\n\nmodule Categories.Category.Monoidal.Interchange.Braided\n {o ℓ e} {C : Category o ℓ e} {M : Monoidal C} (B : Braided M) where\n\nopen import Level using (_⊔_)\nopen import Data.Product using (_,_)\n\nimport Categories.Category.Construction.Core C as Core\nimport Categories.Category.Monoidal.Construction.Product as MonoidalProduct\nopen import Categories.Category.Monoidal.Braided.Properties as BraidedProps\n using (braiding-coherence; inv-Braided; inv-braiding-coherence)\nopen import Categories.Category.Monoidal.Interchange using (HasInterchange)\nopen import Categories.Category.Monoidal.Properties using (module Kelly's)\nimport Categories.Category.Monoidal.Reasoning as MonoidalReasoning\nimport Categories.Category.Monoidal.Utilities as MonoidalUtilities\nopen import Categories.Category.Product using (_⁂_; assocˡ)\nopen import Categories.Functor using (_∘F_)\nopen import Categories.NaturalTransformation.NaturalIsomorphism\n using (_≃_; niHelper)\nopen import Categories.Morphism.Reasoning C\n\nopen Category C\nopen Commutation C\n\nprivate\n variable\n W W₁ W₂ X X₁ X₂ Y Y₁ Y₂ Z Z₁ Z₂ : Obj\n f g h i : X ⇒ Y\n\n-- Braided monoidal categories have an interchange map.\n\nopen MonoidalReasoning M\nopen MonoidalUtilities M\nopen Braided B renaming (associator to α)\nopen Core.Shorthands -- for idᵢ, _∘ᵢ_, ...\nopen Shorthands -- for λ⇒, ρ⇒, α⇒, ...\nopen BraidedProps.Shorthands B -- for σ⇒, ...\n\n-- The \"four middle interchange\" for braided tensor products.\n\nswapInner : (W ⊗₀ X) ⊗₀ (Y ⊗₀ Z) ≅ (W ⊗₀ Y) ⊗₀ (X ⊗₀ Z)\nswapInner = α ⁻¹ ∘ᵢ idᵢ ⊗ᵢ (α ∘ᵢ σ ⊗ᵢ idᵢ ∘ᵢ α ⁻¹) ∘ᵢ α\n\nmodule swapInner {W X Y Z} = _≅_ (swapInner {W} {X} {Y} {Z})\nprivate\n i⇒ = swapInner.from\n i⇐ = swapInner.to\n\n-- to shorten things, it is convenient to name some items that recur\n-- swapˡ is the inner part of 'swapInner'\nprivate\n swapˡ : X ⊗₀ (Y ⊗₀ Z) ⇒ Y ⊗₀ (X ⊗₀ Z)\n swapˡ = α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐\n\n swapˡ-act : swapˡ ∘ g ⊗₁ (h ⊗₁ i) ≈ h ⊗₁ (g ⊗₁ i) ∘ swapˡ\n swapˡ-act {g = g} {h = h} {i = i} = begin\n (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ g ⊗₁ (h ⊗₁ i) ≈⟨ pullʳ (pullʳ assoc-commute-to) ⟩\n α⇒ ∘ σ⇒ ⊗₁ id ∘ (g ⊗₁ h) ⊗₁ i ∘ α⇐ ≈⟨ refl⟩∘⟨ extendʳ (parallel (braiding.⇒.commute _) id-comm-sym) ⟩\n α⇒ ∘ (h ⊗₁ g) ⊗₁ i ∘ σ⇒ ⊗₁ id ∘ α⇐ ≈⟨ extendʳ assoc-commute-from ⟩\n h ⊗₁ (g ⊗₁ i) ∘ α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐ ∎\n\nswapInner-natural : i⇒ ∘ (f ⊗₁ g) ⊗₁ (h ⊗₁ i) ≈ (f ⊗₁ h) ⊗₁ (g ⊗₁ i) ∘ i⇒\nswapInner-natural {f = f} {g = g} {h = h} {i = i} = begin\n (α⇐ ∘ id ⊗₁ swapˡ ∘ α⇒) ∘ (f ⊗₁ g) ⊗₁ (h ⊗₁ i) ≈⟨ pullʳ (pullʳ assoc-commute-from) ⟩\n α⇐ ∘ id ⊗₁ swapˡ ∘ f ⊗₁ g ⊗₁ (h ⊗₁ i) ∘ α⇒ ≈⟨ refl⟩∘⟨ extendʳ (parallel id-comm-sym swapˡ-act) ⟩\n α⇐ ∘ f ⊗₁ h ⊗₁ (g ⊗₁ i) ∘ id ⊗₁ swapˡ ∘ α⇒ ≈⟨ extendʳ assoc-commute-to ⟩\n (f ⊗₁ h) ⊗₁ (g ⊗₁ i) ∘ α⇐ ∘ id ⊗₁ swapˡ ∘ α⇒ ∎\n\nswapInner-naturalIsomorphism : ⊗ ∘F (⊗ ⁂ ⊗) ≃ ⊗ ∘F MonoidalProduct.⊗ M M\nswapInner-naturalIsomorphism = niHelper (record\n { η = λ _ → i⇒\n ; η⁻¹ = λ _ → i⇐\n ; commute = λ _ → swapInner-natural\n ; iso = λ _ → swapInner.iso\n })\n\n-- Another version of the interchange that associates differently.\n--\n-- Why are there two versions and what's the difference? The domain\n-- (X₁ ⊗ X₂) ⊗₀ (Y₁ ⊗ Y₂) and codomain (X₁ ⊗ Y₁) ⊗₀ (X₁ ⊗ Y₂) of the\n-- interchange map are perfectly symmetric/balanced. But in order to\n-- apply the braiding to the middle X₂ and Y₁, we need to\n-- re-associate and that breaks the symmetry. We must first\n-- re-associate the whole expression in one direction and then the\n-- larger subterm in the other. This can be done in two ways,\n-- associate to the right first, then to the left, resulting in X₁ ⊗\n-- ((Y₂ ⊗₀ X₁) ⊗ Y₂), or vice versa, resulting in (X₁ ⊗ (Y₂ ⊗₀ X₁))\n-- ⊗ Y₂. The choice is arbitrary and results in two distinct\n-- interchange maps that behave the same way (as witnessed by\n-- swapInner-coherent below).\n--\n-- Why define both? Because the proofs of some coherence laws become\n-- easier when the core of the expression is associated in one\n-- direction vs. the other. For example swapInner-unitˡ is easier to\n-- prove for the second definition, while swapInner-unitʳ is easier\n-- to prove for the first; swapInner-assoc uses both.\n\nswapInner′ : (W ⊗₀ X) ⊗₀ (Y ⊗₀ Z) ≅ (W ⊗₀ Y) ⊗₀ (X ⊗₀ Z)\nswapInner′ = α ∘ᵢ (α ⁻¹ ∘ᵢ idᵢ ⊗ᵢ σ ∘ᵢ α) ⊗ᵢ idᵢ ∘ᵢ α ⁻¹\n\nmodule swapInner′ {W X Y Z} = _≅_ (swapInner′ {W} {X} {Y} {Z})\nprivate\n j⇒ = swapInner′.from\n j⇐ = swapInner′.to\n\n swapʳ : (X ⊗₀ Y) ⊗₀ Z ⇒ (X ⊗₀ Z) ⊗₀ Y\n swapʳ = α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒\n\n-- Derived coherence laws.\n\nswapInner-coherent : [ (X₁ ⊗₀ X₂) ⊗₀ (Y₁ ⊗₀ Y₂) ⇒ (X₁ ⊗₀ Y₁) ⊗₀ (X₂ ⊗₀ Y₂) ]⟨\n i⇒\n ≈ j⇒\n ⟩\nswapInner-coherent = begin\n α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ≈⟨ refl⟩∘⟨ pushˡ split₂ˡ ⟩\n α⇐ ∘ id ⊗₁ α⇒ ∘ id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ≈⟨ refl⟩∘⟨ refl⟩∘⟨ pushˡ split₂ˡ ⟩\n α⇐ ∘ id ⊗₁ α⇒ ∘ id ⊗₁ (σ⇒ ⊗₁ id) ∘ id ⊗₁ α⇐ ∘ α⇒ ≈⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ conjugate-from α (idᵢ ⊗ᵢ α) (⟺ pentagon) ⟩\n α⇐ ∘ id ⊗₁ α⇒ ∘ id ⊗₁ (σ⇒ ⊗₁ id) ∘ (α⇒ ∘ α⇒ ⊗₁ id) ∘ α⇐ ≈˘⟨ pullʳ (pullʳ (extendʳ (pushˡ assoc-commute-from))) ⟩\n (α⇐ ∘ id ⊗₁ α⇒ ∘ α⇒ ∘ (id ⊗₁ σ⇒) ⊗₁ id) ∘ α⇒ ⊗₁ id ∘ α⇐ ≈⟨ pushʳ sym-assoc ⟩∘⟨refl ⟩\n ((α⇐ ∘ id ⊗₁ α⇒ ∘ α⇒) ∘ (id ⊗₁ σ⇒) ⊗₁ id) ∘ α⇒ ⊗₁ id ∘ α⇐ ≈⟨ pushˡ (conjugate-from (α ⊗ᵢ idᵢ) α (assoc ○ pentagon)) ⟩∘⟨refl ⟩\n (α⇒ ∘ α⇐ ⊗₁ id ∘ (id ⊗₁ σ⇒) ⊗₁ id) ∘ α⇒ ⊗₁ id ∘ α⇐ ≈˘⟨ pushʳ (pushʳ (pushˡ split₁ˡ)) ⟩\n α⇒ ∘ α⇐ ⊗₁ id ∘ (id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐ ≈˘⟨ refl⟩∘⟨ pushˡ split₁ˡ ⟩\n α⇒ ∘ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐ ∎\n\nprivate\n α-mid : ∀ {X} {Y} {Z} {W} → X ⊗₀ ((Y ⊗₀ Z) ⊗₀ W) ⇒ (X ⊗₀ Y) ⊗₀ (Z ⊗₀ W)\n α-mid = α⇒ ∘ α⇐ ⊗₁ id ∘ α⇐\n\nprivate\n serialize-assoc : α⇒ {X₁} {Y₁} {Z₁} ⊗₁ α⇒ {X₂} {Y₂} {Z₂} ≈ id ⊗₁ α⇒ ∘ α⇐ ∘ id ⊗₁ (α⇒ ∘ α⇐ ⊗₁ id ∘ α⇐) ∘ α⇒ ∘ id ⊗₁ α⇐ ∘ α⇒\n serialize-assoc = begin\n α⇒ ⊗₁ α⇒ ≈⟨ serialize₂₁ ⟩\n id ⊗₁ α⇒ ∘ α⇒ ⊗₁ id ≈⟨ refl⟩∘⟨ (begin\n α⇒ ⊗₁ id ≈⟨ switch-fromtoˡ α (switch-fromtoˡ (idᵢ ⊗ᵢ α) pentagon) ⟩\n α⇐ ∘ id ⊗₁ α⇐ ∘ α⇒ ∘ α⇒ ≈˘⟨ refl⟩∘⟨ refl⟩⊗⟨ cancelˡ α.isoʳ ⟩∘⟨refl ⟩\n α⇐ ∘ id ⊗₁ (α⇒ ∘ α⇐ ∘ α⇐) ∘ α⇒ ∘ α⇒ ≈˘⟨ refl⟩∘⟨ refl⟩⊗⟨ pullʳ pentagon-inv ⟩∘⟨refl ⟩\n α⇐ ∘ id ⊗₁ (α-mid ∘ id ⊗₁ α⇐) ∘ α⇒ ∘ α⇒ ≈⟨ refl⟩∘⟨ pushˡ split₂ˡ ⟩\n α⇐ ∘ id ⊗₁ α-mid ∘ id ⊗₁ (id ⊗₁ α⇐) ∘ α⇒ ∘ α⇒ ≈˘⟨ refl⟩∘⟨ refl⟩∘⟨ extendʳ assoc-commute-from ⟩\n α⇐ ∘ id ⊗₁ α-mid ∘ α⇒ ∘ (id ⊗₁ id) ⊗₁ α⇐ ∘ α⇒ ≈⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ ⊗.identity ⟩⊗⟨refl ⟩∘⟨refl ⟩\n α⇐ ∘ id ⊗₁ α-mid ∘ α⇒ ∘ id ⊗₁ α⇐ ∘ α⇒ ∎) ⟩\n id ⊗₁ α⇒ ∘ α⇐ ∘ id ⊗₁ α-mid ∘ α⇒ ∘ id ⊗₁ α⇐ ∘ α⇒ ∎\n\nswapInner-assoc : [ ((X₁ ⊗₀ X₂) ⊗₀ (Y₁ ⊗₀ Y₂)) ⊗₀ (Z₁ ⊗₀ Z₂) ⇒\n (X₁ ⊗₀ (Y₁ ⊗₀ Z₁)) ⊗₀ (X₂ ⊗₀ (Y₂ ⊗₀ Z₂)) ]⟨\n i⇒ ⊗₁ id ⇒⟨ ((X₁ ⊗₀ Y₁) ⊗₀ (X₂ ⊗₀ Y₂)) ⊗₀ (Z₁ ⊗₀ Z₂) ⟩\n i⇒ ⇒⟨ ((X₁ ⊗₀ Y₁) ⊗₀ Z₁) ⊗₀ ((X₂ ⊗₀ Y₂) ⊗₀ Z₂) ⟩\n α⇒ ⊗₁ α⇒\n ≈ α⇒ ⇒⟨ (X₁ ⊗₀ X₂) ⊗₀ ((Y₁ ⊗₀ Y₂) ⊗₀ (Z₁ ⊗₀ Z₂)) ⟩\n id ⊗₁ i⇒ ⇒⟨ (X₁ ⊗₀ X₂) ⊗₀ ((Y₁ ⊗₀ Z₁) ⊗₀ (Y₂ ⊗₀ Z₂)) ⟩\n i⇒\n ⟩\nswapInner-assoc = begin\n α⇒ ⊗₁ α⇒ ∘ i⇒ ∘ i⇒ ⊗₁ id ≈⟨ serialize-assoc ⟩∘⟨refl ⟩\n (id ⊗₁ α⇒ ∘ α⇐ ∘ id ⊗₁ α-mid ∘ α⇒ ∘ id ⊗₁ α⇐ ∘ α⇒) ∘ i⇒ ∘ i⇒ ⊗₁ id ≈˘⟨ pullˡ (pushˡ (⊗.identity ⟩⊗⟨refl ⟩∘⟨refl)) ⟩\n ((id ⊗₁ id) ⊗₁ α⇒ ∘ α⇐) ∘ (id ⊗₁ α-mid ∘ α⇒ ∘ id ⊗₁ α⇐ ∘ α⇒) ∘ i⇒ ∘ i⇒ ⊗₁ id\n ≈⟨ ⟺ assoc-commute-to ⟩∘⟨ pullʳ (pullʳ (pushʳ (pushˡ (pushʳ (pushˡ split₂ˡ))))) ⟩\n (α⇐ ∘ id ⊗₁ (id ⊗₁ α⇒)) ∘ id ⊗₁ α-mid ∘ α⇒ ∘\n ((id ⊗₁ α⇐ ∘ α⇒) ∘ α⇐ ∘ id ⊗₁ α⇒) ∘\n (id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ∘ i⇒ ⊗₁ id\n ≈⟨ pullʳ (refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ elimˡ (_≅_.isoˡ (α ⁻¹ ∘ᵢ idᵢ ⊗ᵢ α))) ⟩\n α⇐ ∘ id ⊗₁ (id ⊗₁ α⇒) ∘ id ⊗₁ α-mid ∘ α⇒ ∘\n (id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ∘\n i⇒ ⊗₁ id\n ≈⟨ refl⟩∘⟨ merge₂ sym-assoc ⟩∘⟨ pushʳ ((⟺ ⊗.identity ⟩⊗⟨refl) ⟩∘⟨refl ⟩∘⟨ split₁ˡ) ⟩\n α⇐ ∘ id ⊗₁ ((id ⊗₁ α⇒ ∘ α⇒) ∘ α⇐ ⊗₁ id ∘ α⇐) ∘\n (α⇒ ∘ (id ⊗₁ id) ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ∘\n α⇐ ⊗₁ id ∘ (id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ⊗₁ id\n ≈⟨ refl⟩∘⟨ refl⟩⊗⟨\n extendʳ (pushˡ (switch-fromtoʳ (α ⊗ᵢ idᵢ) (assoc ○ pentagon))) ⟩∘⟨\n extendʳ assoc-commute-from ⟩∘⟨refl ⟩\n α⇐ ∘ id ⊗₁ ((α⇒ ∘ α⇒) ∘ (α⇐ ⊗₁ id ∘ α⇐ ⊗₁ id) ∘ α⇐) ∘\n (id ⊗₁ (id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐)) ∘ (α⇒ ∘ α⇒)) ∘ α⇐ ⊗₁ id ∘\n (id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ⊗₁ id\n ≈˘⟨ refl⟩∘⟨ refl⟩⊗⟨ pushʳ (refl⟩∘⟨ split₁ˡ ⟩∘⟨refl) ⟩∘⟨\n pushʳ (extendʳ (switch-fromtoʳ (α ⊗ᵢ idᵢ) (assoc ○ pentagon))) ⟩\n α⇐ ∘ id ⊗₁ (α⇒ ∘ α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ α⇐) ∘\n id ⊗₁ (id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐)) ∘ id ⊗₁ α⇒ ∘ α⇒ ∘\n (id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ⊗₁ id\n ≈⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ split₁ˡ ⟩\n α⇐ ∘ id ⊗₁ (α⇒ ∘ α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ α⇐) ∘\n id ⊗₁ (id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐)) ∘ id ⊗₁ α⇒ ∘ α⇒ ∘\n (id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐)) ⊗₁ id ∘ α⇒ ⊗₁ id\n ≈⟨ refl⟩∘⟨ merge₂ assoc²' ○ (refl⟩∘⟨ refl⟩∘⟨ assoc) ⟩∘⟨\n refl⟩∘⟨ extendʳ assoc-commute-from ⟩\n α⇐ ∘ id ⊗₁ (α⇒ ∘ α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐)) ∘\n id ⊗₁ α⇒ ∘\n id ⊗₁ ((α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id) ∘ α⇒ ∘ α⇒ ⊗₁ id\n ≈⟨ refl⟩∘⟨ merge₂ (assoc²' ○ (refl⟩∘⟨ refl⟩∘⟨ assoc²')) ⟩∘⟨\n refl⟩∘⟨ switch-fromtoˡ (idᵢ ⊗ᵢ α) pentagon ⟩\n α⇐ ∘ id ⊗₁ (α⇒ ∘ α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ∘\n id ⊗₁ ((α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id) ∘ id ⊗₁ α⇐ ∘ α⇒ ∘ α⇒\n ≈˘⟨ refl⟩∘⟨ refl⟩∘⟨ pushˡ split₂ˡ ⟩\n α⇐ ∘ id ⊗₁\n (α⇒ ∘ α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ∘\n id ⊗₁ ((α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐) ∘ α⇒ ∘ α⇒\n ≈⟨ refl⟩∘⟨ merge₂ assoc²' ○ (refl⟩∘⟨ refl⟩∘⟨ (assoc²' ○\n (refl⟩∘⟨ refl⟩∘⟨ assoc))) ⟩∘⟨ Equiv.refl ⟩\n α⇐ ∘ id ⊗₁ (α⇒ ∘\n α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ∘\n (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐) ∘ α⇒ ∘ α⇒\n ≈⟨ refl⟩∘⟨ refl⟩⊗⟨ pushʳ (begin\n α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ∘\n (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐\n ≈⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ extendʳ (pushˡ split₂ˡ) ⟩\n α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (σ⇒ ⊗₁ id) ∘ (id ⊗₁ α⇐ ∘ α⇒) ∘\n (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐\n ≈⟨ refl⟩∘⟨ refl⟩∘⟨ (extendʳ assoc-commute-to ○ (refl⟩∘⟨ sym-assoc)) ⟩\n α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ (id ⊗₁ σ⇒) ⊗₁ id ∘ (α⇐ ∘ (id ⊗₁ α⇐ ∘ α⇒)) ∘\n (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐\n ≈⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ (sym-assoc ○\n (conjugate-to α (α ⊗ᵢ idᵢ) (sym-assoc ○ pentagon-inv))) ⟩∘⟨refl ⟩\n α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ (id ⊗₁ σ⇒) ⊗₁ id ∘ (α⇒ ⊗₁ id ∘ α⇐) ∘\n (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐\n ≈˘⟨ refl⟩∘⟨ split₁ Equiv.refl ⟩∘⟨\n pushʳ (refl⟩∘⟨ refl⟩⊗⟨ ⊗.identity ⟩∘⟨refl) ⟩\n α⇒ ∘ ((α⇐ ∘ α⇐) ∘ id ⊗₁ σ⇒) ⊗₁ id ∘ α⇒ ⊗₁ id ∘ α⇐ ∘\n (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ (id ⊗₁ id) ∘ α⇐\n ≈⟨ refl⟩∘⟨ merge₁ assoc² ⟩∘⟨ extendʳ assoc-commute-to ⟩\n α⇒ ∘ (α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘\n ((α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id) ⊗₁ id ∘ α⇐ ∘ α⇐\n ≈˘⟨ refl⟩∘⟨ pushˡ split₁ˡ ⟩\n α⇒ ∘ ((α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ∘ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id) ⊗₁ id ∘\n α⇐ ∘ α⇐\n ≈˘⟨ refl⟩∘⟨ refl⟩∘⟨ (sym-assoc ○ pentagon-inv) ⟩\n α⇒ ∘ ((α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ∘ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id) ⊗₁ id ∘\n α⇐ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇐\n ≈⟨ refl⟩∘⟨ pullˡ (⟺ split₁ˡ ○ (assoc ⟩⊗⟨refl)) ⟩\n α⇒ ∘\n ((α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ∘ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐) ⊗₁ id ∘\n α⇐ ∘ id ⊗₁ α⇐\n ≈⟨ refl⟩∘⟨ (begin\n (α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ∘ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐ ≈⟨ pushˡ (pushʳ sym-assoc) ⟩\n (α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒) ∘ α⇒ ∘ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐ ≈⟨ (refl⟩∘⟨ extendʳ (pushʳ split₁ˡ)) ⟩\n (α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒) ∘ (α⇒ ∘ α⇒ ⊗₁ id) ∘ (σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐ ≈⟨ pushʳ (switch-fromtoˡ (idᵢ ⊗ᵢ α) pentagon ⟩∘⟨ pushˡ split₁ˡ) ⟩\n ((α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒) ∘ (id ⊗₁ α⇐ ∘ α⇒ ∘ α⇒)) ∘\n (σ⇒ ⊗₁ id) ⊗₁ id ∘ α⇐ ⊗₁ id ∘ α⇐ ≈⟨ pushˡ (sym-assoc ○ (pullˡ (pullʳ assoc ⟩∘⟨refl))) ⟩\n ((α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒ ∘ id ⊗₁ α⇐) ∘ α⇒) ∘\n α⇒ ∘ (σ⇒ ⊗₁ id) ⊗₁ id ∘ α⇐ ⊗₁ id ∘ α⇐ ≈⟨ pullʳ (refl⟩∘⟨ extendʳ assoc-commute-from) ⟩\n (α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒ ∘ id ⊗₁ α⇐) ∘ α⇒ ∘\n σ⇒ ⊗₁ (id ⊗₁ id) ∘ α⇒ ∘ α⇐ ⊗₁ id ∘ α⇐ ≈⟨ (refl⟩∘⟨ refl⟩∘⟨ ⟺ split₂ˡ) ⟩∘⟨ refl⟩∘⟨ (refl⟩⊗⟨ ⊗.identity ⟩∘⟨\n conjugate-from (idᵢ ⊗ᵢ (α ⁻¹)) (α ⁻¹) pentagon-inv) ⟩\n (α⇐ ∘ α⇐ ∘ id ⊗₁ (σ⇒ ∘ α⇐)) ∘ α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇒ ≈˘⟨ extendʳ (sym-assoc ○ pentagon-inv) ⟩∘⟨refl ⟩\n (α⇐ ⊗₁ id ∘ (α⇐ ∘ id ⊗₁ α⇐) ∘ id ⊗₁ (σ⇒ ∘ α⇐)) ∘\n α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇒ ≈˘⟨ (refl⟩∘⟨ pushʳ split₂ˡ) ⟩∘⟨refl ⟩\n (α⇐ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (α⇐ ∘ σ⇒ ∘ α⇐)) ∘\n α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇒ ≈˘⟨ pushˡ ((refl⟩∘⟨ refl⟩∘⟨ refl⟩⊗⟨ (sym-assoc ○ hexagon₂ ○ assoc)) ⟩∘⟨refl) ⟩\n ((α⇐ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ σ⇒)) ∘ α⇒) ∘\n σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇒ ≈⟨ pushˡ (pushʳ (pushʳ split₂ˡ)) ⟩∘⟨refl ⟩\n ((α⇐ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ σ⇒ ⊗₁ id) ∘ id ⊗₁ (α⇐ ∘ id ⊗₁ σ⇒) ∘ α⇒) ∘\n σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇒ ≈⟨ pushʳ (pushˡ split₂ˡ) ⟩∘⟨refl ⟩\n (((α⇐ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ σ⇒ ⊗₁ id) ∘ id ⊗₁ α⇐) ∘\n id ⊗₁ id ⊗₁ σ⇒ ∘ α⇒) ∘ σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇒ ≈⟨ ((pushˡ (pushʳ assoc-commute-to) ⟩∘⟨\n ⟺ assoc-commute-from) ○ (pullʳ sym-assoc)) ⟩∘⟨refl ⟩\n ((α⇐ ⊗₁ id ∘ (id ⊗₁ σ⇒) ⊗₁ id) ∘ ((α⇐ ∘ id ⊗₁ α⇐) ∘ α⇒) ∘\n (id ⊗₁ id) ⊗₁ σ⇒) ∘ σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇒ ≈⟨ pullˡ (⟺ split₁ˡ ⟩∘⟨\n conjugate-from α (idᵢ ⊗ᵢ α ∘ᵢ α) (⟺ (assoc ○ pentagon)))\n ⟩∘⟨refl ⟩\n (((α⇐ ∘ id ⊗₁ σ⇒) ⊗₁ id ∘ α⇒ ⊗₁ id ∘ α⇐) ∘ (id ⊗₁ id) ⊗₁ σ⇒) ∘\n σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇒ ≈⟨ (pullˡ (⟺ split₁ˡ) ⟩∘⟨ ⊗.identity ⟩⊗⟨refl) ⟩∘⟨refl ⟩\n ((((α⇐ ∘ id ⊗₁ σ⇒) ∘ α⇒) ⊗₁ id ∘ α⇐) ∘ id ⊗₁ σ⇒) ∘\n σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇒ ≈⟨ extend² (⟺ serialize₂₁ ○ serialize₁₂) ⟩\n ((((α⇐ ∘ id ⊗₁ σ⇒) ∘ α⇒) ⊗₁ id ∘ α⇐) ∘ σ⇒ ⊗₁ id) ∘\n id ⊗₁ σ⇒ ∘ α⇐ ∘ id ⊗₁ α⇒ ≈˘⟨ pushʳ (refl⟩∘⟨ refl⟩⊗⟨ ⊗.identity) ⟩∘⟨ ⊗.identity ⟩⊗⟨refl ⟩∘⟨refl ⟩\n (((α⇐ ∘ id ⊗₁ σ⇒) ∘ α⇒) ⊗₁ id ∘ α⇐ ∘ σ⇒ ⊗₁ id ⊗₁ id) ∘\n (id ⊗₁ id) ⊗₁ σ⇒ ∘ α⇐ ∘ id ⊗₁ α⇒ ≈⟨ pushʳ assoc-commute-to ⟩∘⟨ extendʳ (⟺ assoc-commute-to) ⟩\n ((((α⇐ ∘ id ⊗₁ σ⇒) ∘ α⇒) ⊗₁ id ∘ (σ⇒ ⊗₁ id) ⊗₁ id) ∘ α⇐) ∘\n α⇐ ∘ id ⊗₁ id ⊗₁ σ⇒ ∘ id ⊗₁ α⇒ ≈˘⟨ ((sym-assoc ○ sym-assoc) ⟩⊗⟨refl ○ split₁ˡ) ⟩∘⟨refl ⟩∘⟨ refl⟩∘⟨ split₂ˡ ⟩\n (((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ⊗₁ id) ∘ α⇐) ∘\n α⇐ ∘ id ⊗₁ (id ⊗₁ σ⇒ ∘ α⇒) ≈˘⟨ extend² (sym-assoc ○ pentagon-inv) ⟩\n (((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ⊗₁ id) ∘ α⇐ ⊗₁ id) ∘\n (α⇐ ∘ id ⊗₁ α⇐) ∘ id ⊗₁ (id ⊗₁ σ⇒ ∘ α⇒) ≈˘⟨ split₁ˡ ⟩∘⟨ pushʳ split₂ˡ ⟩\n ((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐) ⊗₁ id ∘\n α⇐ ∘ id ⊗₁ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ∎) ⟩⊗⟨refl ⟩∘⟨refl ⟩\n α⇒ ∘ (((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐) ⊗₁ id ∘ α⇐ ∘\n id ⊗₁ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒)) ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇐ ≈⟨ (refl⟩∘⟨ pushˡ ((sym-assoc ⟩⊗⟨refl) ○ split₁ˡ)) ⟩\n α⇒ ∘ (((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐) ⊗₁ id ∘ α⇐) ⊗₁ id ∘\n (id ⊗₁ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒)) ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇐ ≈⟨ (refl⟩∘⟨ split₁ˡ ⟩∘⟨ extendʳ (⟺ assoc-commute-to)) ○ pushʳ assoc ⟩\n (α⇒ ∘ (((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐) ⊗₁ id) ⊗₁ id) ∘\n α⇐ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ id ⊗₁ α⇐ ≈⟨ pushˡ assoc-commute-from ⟩\n ((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐) ⊗₁ (id ⊗₁ id) ∘ α⇒ ∘\n α⇐ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ id ⊗₁ α⇐ ≈˘⟨ refl⟩∘⟨ pullʳ (pullʳ (refl⟩∘⟨ split₂ˡ)) ⟩\n ((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐) ⊗₁ (id ⊗₁ id) ∘\n (α⇒ ∘ α⇐ ⊗₁ id ∘ α⇐) ∘ id ⊗₁ ((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐) ≈˘⟨ pullʳ (pullˡ (conjugate-from (α ∘ᵢ α ⊗ᵢ idᵢ) α pentagon)) ⟩\n (((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐) ⊗₁ (id ⊗₁ id) ∘ α⇐) ∘\n id ⊗₁ α⇒ ∘ id ⊗₁ ((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐) ≈⟨ refl⟩⊗⟨ ⊗.identity ⟩∘⟨refl ⟩∘⟨ ⟺ split₂ˡ ⟩\n (((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐) ⊗₁ id ∘ α⇐) ∘\n id ⊗₁ (α⇒ ∘ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐) ≡⟨⟩\n (((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐) ⊗₁ id ∘ α⇐) ∘ id ⊗₁ j⇒ ≈˘⟨ switch-fromtoʳ α (switch-fromtoˡ α (⟺ hexagon₁))\n ⟩⊗⟨refl ⟩∘⟨refl ⟩∘⟨refl ⟩\n (σ⇒ ⊗₁ id ∘ α⇐) ∘ id ⊗₁ j⇒\n ∎) ⟩∘⟨refl ⟩\n α⇐ ∘ id ⊗₁ ((α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ id ⊗₁ j⇒) ∘ α⇒ ∘ α⇒ ≈⟨ refl⟩∘⟨ pushˡ split₂ˡ ⟩\n α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ id ⊗₁ id ⊗₁ j⇒ ∘ α⇒ ∘ α⇒ ≈˘⟨ pullʳ (pullʳ (extendʳ assoc-commute-from)) ⟩\n (α⇐ ∘ id ⊗₁ swapˡ ∘ α⇒) ∘ (id ⊗₁ id) ⊗₁ j⇒ ∘ α⇒ ≡⟨⟩\n i⇒ ∘ (id ⊗₁ id) ⊗₁ j⇒ ∘ α⇒ ≈⟨ refl⟩∘⟨ ⊗.identity ⟩⊗⟨ ⟺ swapInner-coherent ⟩∘⟨refl ⟩\n i⇒ ∘ id ⊗₁ i⇒ ∘ α⇒\n ∎\n\nprivate\n mid-1-elim-coh : [ X ⊗₀ (unit ⊗₀ Y) ⇒ X ⊗₀ Y ]⟨ λ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐ ≈ id ⊗₁ λ⇒ ⟩\n mid-1-elim-coh = begin\n λ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐ ≈⟨ pullˡ (Kelly's.coherence₁ M) ⟩\n λ⇒ ⊗₁ id ∘ σ⇒ ⊗₁ id ∘ α⇐ ≈˘⟨ pushˡ split₁ˡ ⟩\n (λ⇒ ∘ σ⇒) ⊗₁ id ∘ α⇐ ≈⟨ braiding-coherence B ⟩⊗⟨refl ⟩∘⟨refl ⟩\n ρ⇒ ⊗₁ id ∘ α⇐ ≈˘⟨ switch-fromtoʳ α triangle ⟩\n id ⊗₁ λ⇒ ∎\n\n Kelly₁′ : [ unit ⊗₀ (X ⊗₀ Y) ⇒ X ⊗₀ Y ]⟨ λ⇒ ⊗₁ id ∘ α⇐ ≈ λ⇒ ⟩\n Kelly₁′ = ⟺ (switch-fromtoʳ α (Kelly's.coherence₁ M))\n\n Kelly₂′ : [ X ⊗₀ (Y ⊗₀ unit) ⇒ X ⊗₀ Y ]⟨ ρ⇒ ∘ α⇐ ≈ id ⊗₁ ρ⇒ ⟩\n Kelly₂′ = ⟺ (switch-fromtoʳ α (Kelly's.coherence₂ M))\n\n σ⁻¹-coherence : [ unit ⊗₀ X ⇒ X ]⟨ ρ⇒ ∘ σ⇒ ≈ λ⇒ ⟩\n σ⁻¹-coherence = inv-braiding-coherence (inv-Braided B)\n\nswapInner-unitˡ : [ unit ⊗₀ (X ⊗₀ Y) ⇒ (X ⊗₀ Y) ]⟨\n λ⇐ ⊗₁ id ⇒⟨ (unit ⊗₀ unit) ⊗₀ (X ⊗₀ Y) ⟩\n i⇒ ⇒⟨ (unit ⊗₀ X) ⊗₀ (unit ⊗₀ Y) ⟩\n λ⇒ ⊗₁ λ⇒\n ≈ λ⇒\n ⟩\nswapInner-unitˡ = begin\n λ⇒ ⊗₁ λ⇒ ∘ i⇒ ∘ λ⇐ ⊗₁ id ≈⟨ refl⟩∘⟨ swapInner-coherent ⟩∘⟨ (Kelly's.coherence-inv₃ M ⟩⊗⟨refl) ⟩\n λ⇒ ⊗₁ λ⇒ ∘ j⇒ ∘ ρ⇐ ⊗₁ id ≈⟨ pullˡ (pushˡ serialize₁₂) ⟩\n (λ⇒ ⊗₁ id ∘ id ⊗₁ λ⇒ ∘ α⇒ ∘ swapʳ ⊗₁ id ∘ α⇐) ∘ ρ⇐ ⊗₁ id\n ≈⟨ (refl⟩∘⟨ (begin\n id ⊗₁ λ⇒ ∘ α⇒ ∘ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐ ≈⟨ pullˡ triangle ⟩\n ρ⇒ ⊗₁ id ∘ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐ ≈˘⟨ pushˡ split₁ˡ ⟩\n (ρ⇒ ∘ α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐ ≈⟨ (pullˡ Kelly₂′ ⟩⊗⟨refl ⟩∘⟨refl) ⟩\n (id ⊗₁ ρ⇒ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐ ≈˘⟨ pushˡ split₂ˡ ⟩⊗⟨refl ⟩∘⟨refl ⟩\n (id ⊗₁ (ρ⇒ ∘ σ⇒) ∘ α⇒) ⊗₁ id ∘ α⇐ ≈⟨ (refl⟩⊗⟨ σ⁻¹-coherence ⟩∘⟨refl) ⟩⊗⟨refl ⟩∘⟨refl ⟩\n (id ⊗₁ λ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐ ≈⟨ triangle ⟩⊗⟨refl ⟩∘⟨refl ⟩\n (ρ⇒ ⊗₁ id) ⊗₁ id ∘ α⇐ ≈˘⟨ assoc-commute-to ⟩\n α⇐ ∘ ρ⇒ ⊗₁ (id ⊗₁ id)\n ∎)) ⟩∘⟨refl ⟩\n (λ⇒ ⊗₁ id ∘ α⇐ ∘ ρ⇒ ⊗₁ (id ⊗₁ id)) ∘ ρ⇐ ⊗₁ id ≈⟨ (sym-assoc ○ (Kelly₁′ ⟩∘⟨ refl⟩⊗⟨ ⊗.identity)) ⟩∘⟨refl ⟩\n (λ⇒ ∘ ρ⇒ ⊗₁ id) ∘ ρ⇐ ⊗₁ id ≈⟨ cancelʳ (_≅_.isoʳ (unitorʳ ⊗ᵢ idᵢ)) ⟩\n λ⇒\n ∎\n\nswapInner-unitʳ : [ (X ⊗₀ Y) ⊗₀ unit ⇒ (X ⊗₀ Y) ]⟨\n id ⊗₁ λ⇐ ⇒⟨ (X ⊗₀ Y) ⊗₀ (unit ⊗₀ unit) ⟩\n i⇒ ⇒⟨ (X ⊗₀ unit) ⊗₀ (Y ⊗₀ unit) ⟩\n ρ⇒ ⊗₁ ρ⇒\n ≈ ρ⇒\n ⟩\nswapInner-unitʳ = begin\n ρ⇒ ⊗₁ ρ⇒ ∘ i⇒ ∘ id ⊗₁ λ⇐ ≡⟨⟩\n ρ⇒ ⊗₁ ρ⇒ ∘ (α⇐ ∘ id ⊗₁ swapˡ ∘ α⇒) ∘ id ⊗₁ λ⇐ ≈⟨ pullˡ (pushˡ serialize₂₁) ⟩\n (id ⊗₁ ρ⇒ ∘ ρ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ swapˡ ∘ α⇒) ∘ id ⊗₁ λ⇐ ≈⟨ (refl⟩∘⟨ (begin\n ρ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ swapˡ ∘ α⇒ ≈˘⟨ pushˡ (switch-fromtoʳ α triangle) ⟩\n id ⊗₁ λ⇒ ∘ id ⊗₁ swapˡ ∘ α⇒ ≈˘⟨ pushˡ split₂ˡ ⟩\n id ⊗₁ (λ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ≈⟨ refl⟩⊗⟨ mid-1-elim-coh ⟩∘⟨refl ⟩\n id ⊗₁ (id ⊗₁ λ⇒) ∘ α⇒ ≈˘⟨ assoc-commute-from ⟩\n α⇒ ∘ (id ⊗₁ id) ⊗₁ λ⇒ ≈⟨ refl⟩∘⟨ ⊗.identity ⟩⊗⟨refl ⟩\n α⇒ ∘ id ⊗₁ λ⇒ ∎)) ⟩∘⟨refl ⟩\n (id ⊗₁ ρ⇒ ∘ α⇒ ∘ id ⊗₁ λ⇒) ∘ id ⊗₁ λ⇐ ≈⟨ (sym-assoc ○ (Kelly's.coherence₂ M ⟩∘⟨refl )) ⟩∘⟨refl ⟩\n (ρ⇒ ∘ id ⊗₁ λ⇒) ∘ id ⊗₁ λ⇐ ≈⟨ cancelʳ (_≅_.isoʳ (idᵢ ⊗ᵢ unitorˡ)) ⟩\n ρ⇒ ∎\n\n-- Two different ways of swapping things around are the same\nprivate\n [23][14]ʳ : [ (X ⊗₀ Y) ⊗₀ (Z ⊗₀ W) ⇒ (Y ⊗₀ Z) ⊗₀ (X ⊗₀ W) ]⟨ α⇒ ∘ swapʳ ⊗₁ id ∘ (σ⇒ ⊗₁ id) ⊗₁ id ∘ α⇐ ≈ (α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇒ ⊗₁ id ∘ α⇐ ⟩\n [23][14]ʳ = begin\n (α⇒ ∘ swapʳ ⊗₁ id ∘ (σ⇒ ⊗₁ id) ⊗₁ id ∘ α⇐) ≈˘⟨ refl⟩∘⟨ pushˡ split₁ˡ ⟩\n (α⇒ ∘ (swapʳ ∘ σ⇒ ⊗₁ id) ⊗₁ id ∘ α⇐) ≈⟨ refl⟩∘⟨ pullʳ (assoc ○ hexagon₁) ⟩⊗⟨refl ⟩∘⟨refl ⟩\n (α⇒ ∘ (α⇐ ∘ α⇒ ∘ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐) ≈⟨ refl⟩∘⟨ cancelˡ α.isoˡ ⟩⊗⟨refl ⟩∘⟨refl ⟩\n (α⇒ ∘ (σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐) ≈⟨ extendʳ (pushʳ split₁ˡ) ⟩\n ((α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇒ ⊗₁ id ∘ α⇐) ∎\n\n [13][42]ˡ : [ (X ⊗₀ Y) ⊗₀ (Z ⊗₀ W) ⇒ (X ⊗₀ Z) ⊗₀ (W ⊗₀ Y) ]⟨ α⇐ ∘ id ⊗₁ (id ⊗₁ σ⇒) ∘ id ⊗₁ swapˡ ∘ α⇒ ≈ (α⇐ ∘ id ⊗₁ α⇒) ∘ id ⊗₁ σ⇒ ∘ α⇒ ⟩\n [13][42]ˡ = begin\n α⇐ ∘ id ⊗₁ (id ⊗₁ σ⇒) ∘ id ⊗₁ swapˡ ∘ α⇒ ≈˘⟨ refl⟩∘⟨ pushˡ split₂ˡ ⟩\n α⇐ ∘ id ⊗₁ (id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ≈⟨ refl⟩∘⟨ refl⟩⊗⟨ (⟺ assoc ○ (pullˡ (assoc ○ hexagon₁))) ⟩∘⟨refl ⟩\n α⇐ ∘ id ⊗₁ ((α⇒ ∘ σ⇒ ∘ α⇒) ∘ α⇐) ∘ α⇒ ≈⟨ refl⟩∘⟨ refl⟩⊗⟨ pullʳ (cancelʳ α.isoʳ) ⟩∘⟨refl ⟩\n α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒) ∘ α⇒ ≈⟨ extendʳ (pushʳ split₂ˡ) ⟩\n (α⇐ ∘ id ⊗₁ α⇒) ∘ id ⊗₁ σ⇒ ∘ α⇒ ∎\n\nswapInner-braiding : [ (W ⊗₀ X) ⊗₀ (Y ⊗₀ Z) ⇒ (Y ⊗₀ Z) ⊗₀ (W ⊗₀ X) ]⟨\n i⇒ ⇒⟨ (W ⊗₀ Y) ⊗₀ (X ⊗₀ Z) ⟩\n σ⇒ ⊗₁ σ⇒ ⇒⟨ (Y ⊗₀ W) ⊗₀ (Z ⊗₀ X) ⟩\n i⇒\n ≈ σ⇒\n ⟩\nswapInner-braiding = begin\n i⇒ ∘ σ⇒ ⊗₁ σ⇒ ∘ i⇒ ≡⟨⟩\n i⇒ ∘ σ⇒ ⊗₁ σ⇒ ∘ α⇐ ∘ id ⊗₁ swapˡ ∘ α⇒ ≈⟨ swapInner-coherent ⟩∘⟨ pushˡ serialize₁₂ ⟩\n j⇒ ∘ σ⇒ ⊗₁ id ∘ id ⊗₁ σ⇒ ∘ α⇐ ∘ id ⊗₁ swapˡ ∘ α⇒ ≈˘⟨ ((refl⟩∘⟨ refl⟩⊗⟨ ⊗.identity) ⟩∘⟨ ⊗.identity ⟩⊗⟨refl ⟩∘⟨refl) ○ assoc ⟩\n ((α⇒ ∘ swapʳ ⊗₁ id ∘ α⇐) ∘ σ⇒ ⊗₁ (id ⊗₁ id)) ∘\n (id ⊗₁ id) ⊗₁ σ⇒ ∘ α⇐ ∘ id ⊗₁ swapˡ ∘ α⇒ ≈⟨ pullʳ (pullʳ assoc-commute-to) ⟩∘⟨ extendʳ (⟺ assoc-commute-to) ⟩\n (α⇒ ∘ swapʳ ⊗₁ id ∘ (σ⇒ ⊗₁ id) ⊗₁ id ∘ α⇐) ∘\n α⇐ ∘ id ⊗₁ (id ⊗₁ σ⇒) ∘ id ⊗₁ swapˡ ∘ α⇒ ≈⟨ [23][14]ʳ ⟩∘⟨ [13][42]ˡ ⟩\n ((α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇒ ⊗₁ id ∘ α⇐) ∘ (α⇐ ∘ id ⊗₁ α⇒) ∘ id ⊗₁ σ⇒ ∘ α⇒ ≈˘⟨ extendʳ (pushʳ (pushʳ assoc)) ⟩\n (α⇒ ∘ σ⇒ ⊗₁ id) ∘ (α⇒ ⊗₁ id ∘ (α⇐ ∘ α⇐) ∘ id ⊗₁ α⇒) ∘ id ⊗₁ σ⇒ ∘ α⇒ ≈˘⟨ refl⟩∘⟨ switch-tofromˡ (α ⊗ᵢ idᵢ)\n (switch-tofromʳ (idᵢ ⊗ᵢ α) pentagon-inv) ⟩∘⟨refl ⟩\n (α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ≈⟨ pullʳ (sym-assoc ○ pullˡ hexagon₂) ⟩\n α⇒ ∘ ((α⇐ ∘ σ⇒) ∘ α⇐) ∘ α⇒ ≈⟨ (refl⟩∘⟨ cancelʳ α.isoˡ) ⟩\n α⇒ ∘ (α⇐ ∘ σ⇒) ≈⟨ cancelˡ α.isoʳ ⟩\n σ⇒ ∎\n\n-- Braided monoidal categories have an interchange.\n\nhasInterchange : HasInterchange M\nhasInterchange = record\n { swapInner = swapInner\n ; natural = swapInner-natural\n ; assoc = swapInner-assoc\n ; unitˡ = swapInner-unitˡ\n ; unitʳ = swapInner-unitʳ\n }\nopen HasInterchange hasInterchange public using (naturalIso)\n", "meta": {"hexsha": "f5d225f5d4440fac20e229360e484683b7dcd716", "size": 26359, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Monoidal/Interchange/Braided.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/Monoidal/Interchange/Braided.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/Monoidal/Interchange/Braided.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 62.6104513064, "max_line_length": 158, "alphanum_fraction": 0.3773663644, "num_tokens": 15078, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835207180243, "lm_q2_score": 0.7217431943271999, "lm_q1q2_score": 0.6030045450507622}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nmodule Cubical.Data.SumFin.Properties where\n\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Univalence\n\nopen import Cubical.Data.Empty as ⊥\nimport Cubical.Data.Fin as Fin\nopen import Cubical.Data.Nat\nopen import Cubical.Data.SumFin.Base as SumFin\n\nprivate\n variable\n ℓ : Level\n k : ℕ\n\nSumFin→Fin : Fin k → Fin.Fin k\nSumFin→Fin = SumFin.elim (λ {k} _ → Fin.Fin k) Fin.fzero Fin.fsuc\n\nFin→SumFin : Fin.Fin k → Fin k\nFin→SumFin = Fin.elim (λ {k} _ → Fin k) fzero fsuc\n\nFin→SumFin-fsuc : (fk : Fin.Fin k) → Fin→SumFin (Fin.fsuc fk) ≡ fsuc (Fin→SumFin fk)\nFin→SumFin-fsuc = Fin.elim-fsuc (λ {k} _ → Fin k) fzero fsuc\n\nSumFin→Fin→SumFin : (fk : Fin k) → Fin→SumFin (SumFin→Fin fk) ≡ fk\nSumFin→Fin→SumFin = SumFin.elim (λ fk → Fin→SumFin (SumFin→Fin fk) ≡ fk)\n refl λ {k} {fk} eq →\n Fin→SumFin (Fin.fsuc (SumFin→Fin fk)) ≡⟨ Fin→SumFin-fsuc (SumFin→Fin fk) ⟩\n fsuc (Fin→SumFin (SumFin→Fin fk)) ≡⟨ cong fsuc eq ⟩\n fsuc fk ∎\n\nFin→SumFin→Fin : (fk : Fin.Fin k) → SumFin→Fin (Fin→SumFin fk) ≡ fk\nFin→SumFin→Fin = Fin.elim (λ fk → SumFin→Fin (Fin→SumFin fk) ≡ fk)\n refl λ {k} {fk} eq →\n SumFin→Fin (Fin→SumFin (Fin.fsuc fk)) ≡⟨ cong SumFin→Fin (Fin→SumFin-fsuc fk) ⟩\n Fin.fsuc (SumFin→Fin (Fin→SumFin fk)) ≡⟨ cong Fin.fsuc eq ⟩\n Fin.fsuc fk ∎\n\nSumFin≃Fin : ∀ k → Fin k ≃ Fin.Fin k\nSumFin≃Fin _ =\n isoToEquiv (iso SumFin→Fin Fin→SumFin Fin→SumFin→Fin SumFin→Fin→SumFin)\n\nSumFin≡Fin : ∀ k → Fin k ≡ Fin.Fin k\nSumFin≡Fin k = ua (SumFin≃Fin k)\n", "meta": {"hexsha": "3ff9218173357d25042e1a4bde58bcfee17fddfd", "size": 1716, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/SumFin/Properties.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/SumFin/Properties.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/Data/SumFin/Properties.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "avg_line_length": 35.0204081633, "max_line_length": 84, "alphanum_fraction": 0.6357808858, "num_tokens": 643, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.7577943603346811, "lm_q1q2_score": 0.6029452209824656}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Relation.Binary.Reasoning.Equality where\n\nopen import Cubical.Core.Everything\nopen import Cubical.Foundations.Prelude\n\nprivate\n variable\n ℓ : Level\n A : Type ℓ\n\ninfixr 1 _≡⟨⟩_ _≡⟨_⟩_ _≡˘⟨_⟩_\ninfix 2 _∎\n\n-- Step with a non-trivial propositional equality\n\n_≡⟨_⟩_ : ∀ x {y z : A} → x ≡ y → y ≡ z → x ≡ z\n_≡⟨_⟩_ x = _∙_\n\n-- Step with a flipped non-trivial propositional equality\n\n_≡˘⟨_⟩_ : ∀ x {y z : A} → y ≡ x → y ≡ z → x ≡ z\nx ≡˘⟨ y≡x ⟩ y≡z = x ≡⟨ sym y≡x ⟩ y≡z\n\n-- Step with a trivial propositional equality\n\n_≡⟨⟩_ : ∀ x {y : A} → x ≡ y → x ≡ y\n_ ≡⟨⟩ x≡y = x≡y\n\n-- Syntax for path definition\n\n≡⟨⟩-syntax : ∀ x {y z : A} → x ≡ y → y ≡ z → x ≡ z\n≡⟨⟩-syntax = _≡⟨_⟩_\ninfixr 1 ≡⟨⟩-syntax\nsyntax ≡⟨⟩-syntax x (λ i → B) y = x ≡[ i ]⟨ B ⟩ y\n\n≡˘⟨⟩-syntax : ∀ x {y z : A} → y ≡ x → y ≡ z → x ≡ z\n≡˘⟨⟩-syntax = _≡˘⟨_⟩_\ninfixr 1 ≡˘⟨⟩-syntax\nsyntax ≡˘⟨⟩-syntax x (λ i → B) y = x ≡˘[ i ]⟨ B ⟩ y\n\n-- Termination step\n\n_∎ : ∀ (x : A) → x ≡ x\nx ∎ = refl\n", "meta": {"hexsha": "20d9d5020a7a0746d95c4cd010733b58f0f77283", "size": 1011, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Relation/Binary/Reasoning/Equality.agda", "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Relation/Binary/Reasoning/Equality.agda", "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Relation/Binary/Reasoning/Equality.agda", "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.9782608696, "max_line_length": 57, "alphanum_fraction": 0.5380811078, "num_tokens": 520, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080671950640465, "lm_q2_score": 0.7461389986757757, "lm_q1q2_score": 0.6029304477878303}} {"text": "------------------------------------------------------------------------------\n-- Totality properties respect to Bool\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOTC.Program.SortList.Properties.Totality.BoolI where\n\nopen import FOTC.Base\nopen import FOTC.Data.Bool.Type\nopen import FOTC.Data.Bool.PropertiesI\nopen import FOTC.Data.Nat.List.Type\nopen import FOTC.Data.Nat.Type\nopen import FOTC.Program.SortList.SortList\n\n------------------------------------------------------------------------------\n\nle-ItemList-Bool : ∀ {item is} → N item → ListN is → Bool (le-ItemList item is)\nle-ItemList-Bool {item} Nitem lnnil = subst Bool (sym (le-ItemList-[] item)) btrue\nle-ItemList-Bool {item} Nitem (lncons {i} {is} Ni Lis) =\n subst Bool\n (sym (le-ItemList-∷ item i is))\n (&&-Bool (le-Bool Nitem Ni) (le-ItemList-Bool Nitem Lis))\n\n-- See the ATP version.\npostulate le-Lists-Bool : ∀ {is js} → ListN is → ListN js → Bool (le-Lists is js)\n\n-- See the ATP version.\npostulate ordList-Bool : ∀ {is} → ListN is → Bool (ordList is)\n\nle-ItemTree-Bool : ∀ {item t} → N item → Tree t →\n Bool (le-ItemTree item t)\nle-ItemTree-Bool {item} _ tnil = subst Bool (sym (le-ItemTree-nil item)) btrue\nle-ItemTree-Bool {item} Nitem (ttip {i} Ni) =\n subst Bool (sym (le-ItemTree-tip item i)) (le-Bool Nitem Ni)\nle-ItemTree-Bool {item} Nitem (tnode {t₁} {i} {t₂} Tt₁ Ni Tt₂) =\n subst Bool\n (sym (le-ItemTree-node item t₁ i t₂))\n (&&-Bool (le-ItemTree-Bool Nitem Tt₁) (le-ItemTree-Bool Nitem Tt₂))\n\nle-TreeItem-Bool : ∀ {t item} → Tree t → N item → Bool (le-TreeItem t item)\nle-TreeItem-Bool {item = item} tnil _ =\n subst Bool (sym (le-TreeItem-nil item)) btrue\nle-TreeItem-Bool {item = item} (ttip {i} Ni) Nitem =\n subst Bool (sym (le-TreeItem-tip i item)) (le-Bool Ni Nitem)\nle-TreeItem-Bool {item = item} (tnode {t₁} {i} {t₂} Tt₁ Ni Tt₂) Nitem =\n subst Bool\n (sym (le-TreeItem-node t₁ i t₂ item))\n (&&-Bool (le-TreeItem-Bool Tt₁ Nitem) (le-TreeItem-Bool Tt₂ Nitem))\n\nordTree-Bool : ∀ {t} → Tree t → Bool (ordTree t)\nordTree-Bool tnil = subst Bool (sym ordTree-nil) btrue\nordTree-Bool (ttip {i} Ni) = subst Bool (sym (ordTree-tip i)) btrue\nordTree-Bool (tnode {t₁} {i} {t₂} Tt₁ Ni Tt₂) =\n subst Bool\n (sym (ordTree-node t₁ i t₂))\n (&&-Bool (ordTree-Bool Tt₁)\n (&&-Bool (ordTree-Bool Tt₂)\n (&&-Bool (le-TreeItem-Bool Tt₁ Ni)\n (le-ItemTree-Bool Ni Tt₂))))\n", "meta": {"hexsha": "9eabe8b99fab85c333e42e267c1a10d72c866e76", "size": 2715, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/FOTC/Program/SortList/Properties/Totality/BoolI.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/FOTC/Program/SortList/Properties/Totality/BoolI.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/FOTC/Program/SortList/Properties/Totality/BoolI.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 42.421875, "max_line_length": 82, "alphanum_fraction": 0.5683241252, "num_tokens": 844, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.808067204308405, "lm_q2_score": 0.7461389873857265, "lm_q1q2_score": 0.6029304455622883}} {"text": "{-# OPTIONS --without-K #-}\nmodule pointed.equality where\n\nopen import sum\nopen import equality.core\nopen import function.extensionality\nopen import function.isomorphism.core\nopen import function.isomorphism.utils\nopen import pointed.core\n\npmap-eq : ∀ {i j}{X : Set i}{Y : Set j}{x₀ : X}{y₀ : Y}\n → {f : X → Y}{p : f x₀ ≡ y₀}\n → {g : X → Y}{q : g x₀ ≡ y₀}\n → (Σ ((x : X) → f x ≡ g x) λ γ → p ≡ γ x₀ · q)\n ≅ _≡_ {A = PMap (X , x₀) (Y , y₀)} (f , p) (g , q)\npmap-eq {X = X}{Y}{x₀}{y₀} = Σ-ap-iso' strong-funext-iso lem ·≅ Σ-split-iso\n where\n lem : {f : X → Y}{p : f x₀ ≡ y₀}\n → {g : X → Y}{q : g x₀ ≡ y₀}\n → (h : f ≡ g)\n → (p ≡ funext-inv h x₀ · q)\n ≅ (subst (λ u → u x₀ ≡ y₀) h p ≡ q)\n lem refl = refl≅\n", "meta": {"hexsha": "46671d620a61ced4624c2c283de882cedd814e90", "size": 765, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/pointed/equality.agda", "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 20, "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_issues_repo_path": "src/pointed/equality.agda", "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_forks_repo_path": "src/pointed/equality.agda", "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "avg_line_length": 31.875, "max_line_length": 75, "alphanum_fraction": 0.5019607843, "num_tokens": 318, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898305367525, "lm_q2_score": 0.6654105587468141, "lm_q1q2_score": 0.6028551993563919}} {"text": "open import Agda.Builtin.Nat\n\ndata Vec (A : Set) : Nat → Set where\n [] : Vec A 0\n _∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)\n\ninfixr 5 _∷_ _++_\n\n_++_ : ∀ {A m n} → Vec A m → Vec A n → Vec A (m + n)\n[] ++ ys = ys\n(x ∷ xs) ++ ys = x ∷ xs ++ ys\n\nT : ∀ {A n} → Vec A n → Set\nT [] = Nat\nT (x ∷ xs) = Vec Nat 0\n\nfoo : ∀ {A} m n (xs : Vec A m) (ys : Vec A n) → T (xs ++ ys)\nfoo m n xs ys with {m + n} | xs ++ ys\n... | [] = 0\n... | z ∷ zs = []\n", "meta": {"hexsha": "e142ead3221da25efb4883bdee2b837221c91c17", "size": 448, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue500.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue500.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue500.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 21.3333333333, "max_line_length": 60, "alphanum_fraction": 0.4196428571, "num_tokens": 208, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9059898127684335, "lm_q2_score": 0.6654105653819835, "lm_q1q2_score": 0.6028551935445607}} {"text": "{-# OPTIONS --warning=error --safe --without-K #-}\n\nopen import LogicalFormulae\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import Functions\nopen import Setoids.Setoids\nopen import Setoids.Subset\nopen import Graphs.Definition\nopen import Sets.FinSet.Definition\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import Sets.EquivalenceRelations\nopen import Graphs.CompleteGraph\nopen import Graphs.Colouring\n\nmodule Graphs.RamseyTriangle where\n\nhasMonochromaticTriangle : {a : _} {n : ℕ} (G : Graph a (reflSetoid (FinSet n))) → Set (lsuc lzero)\nhasMonochromaticTriangle {n = n} G = Sg (FinSet n → Set) λ pred → (subset (reflSetoid (FinSet n)) pred) && {!!}\n\nramseyForTriangle : (k : ℕ) → Sg ℕ (λ N → (n : ℕ) → (N runExceptT m\n\n FunctorZeroExceptT : {{_ : Monad M}} {{_ : Monoid E}} → FunctorZero {a = a} (ExceptT E M)\n runExceptT (empty {{FunctorZeroExceptT}}) = return (left mempty)\n\n AlternativeExceptT : {{_ : Monad M}} {{_ : Monoid E}} → Alternative {a = a} (ExceptT E M)\n runExceptT (_<|>_ {{AlternativeExceptT {{monadM}}}} mx my) = do\n right x ← runExceptT mx\n where\n left e₁ → do\n right y ← runExceptT my\n where left e₂ → return (left (e₁ <> e₂))\n return (right y)\n return (right x)\n\n module _ {{_ : Monad M}} where\n\n private\n bindExceptT : ∀ {A B} → ExceptT E M A → (A → ExceptT E M B) → ExceptT E M B\n runExceptT (bindExceptT m f) = do\n right x ← runExceptT m\n where left e → return (left e)\n runExceptT (f x)\n\n instance\n ApplicativeExceptT : Applicative {a = a} (ExceptT E M)\n runExceptT (pure {{ApplicativeExceptT}} x) = pure (right x)\n _<*>_ {{ApplicativeExceptT}} = monadAp bindExceptT\n\n MonadExceptT : Monad {a = a} (ExceptT E M)\n _>>=_ {{MonadExceptT}} = bindExceptT\n\n liftExceptT : {A : Set a} → M A → ExceptT E M A\n runExceptT (liftExceptT m) = right <$> m\n\ninstance\n TransformerExceptT : ∀ {a} {E : Set a} → Transformer {a} (ExceptT E)\n lift {{TransformerExceptT}} = liftExceptT\n\nExcept : ∀ {a} (E : Set a) (A : Set a) → Set a\nExcept R = ExceptT R Identity\n\nrunExcept : ∀ {a} {E : Set a} {A : Set a} → Except E A → Either E A\nrunExcept m = runIdentity (runExceptT m)\n", "meta": {"hexsha": "84ffea0aa9ea7e88bbdffa7cc7df1247aceb6ff5", "size": 2046, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Control/Monad/Except.agda", "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 111, "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_issues_repo_path": "src/Control/Monad/Except.agda", "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_forks_repo_path": "src/Control/Monad/Except.agda", "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "avg_line_length": 31.96875, "max_line_length": 93, "alphanum_fraction": 0.610459433, "num_tokens": 657, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711908591638, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.6026458374852485}} {"text": "{-# OPTIONS --disable-positivity-check #-}\n\nmodule univ where\n\nimport Logic.ChainReasoning\nmodule Chain {A : Set}\n ( _==_ : A -> A -> Set)\n (refl : {x : A} -> x == x)\n (trans : {x y z : A} -> x == y -> y == z -> x == z) =\n Logic.ChainReasoning.Mono.Homogenous _==_ (\\x -> refl) (\\x y z -> trans)\n\ndata N1 : Set where\n T : N1\n\ndata N0 : Set where\n\ndata Sigma (A:Set)(B : A -> Set) : Set where\n Pair : (x:A) -> B x -> Sigma A B\n\nrel : Set -> Set1\n\nrel A = A -> A -> Set\n\npred : Set -> Set1\n\npred A = A -> Set\n\nRefl : {A:Set} -> rel A -> Set\nRefl {A} R = {x : A} -> R x x\n\nSym : {A:Set} -> rel A -> Set\nSym {A} R = {x y : A} -> R x y -> R y x\n\nTrans : {A:Set} -> rel A -> Set\nTrans {A} R = {x y z : A} -> R x y -> R y z -> R x z\n\nMap : (A:Set) -> rel A -> (B:Set) -> rel B -> pred (A -> B)\nMap A _R_ B _S_ f = {x y : A} -> x R y -> f x S f y\n\npostulate\n N : Set\n _=N_ : rel N\n refN : Refl _=N_\n symN : Sym _=N_\n transN : Trans _=N_\n\n\n-- mutual inductive recursive definition of S and the functions _=S_, El, eq, and all the\n-- proofs on these functions\n\nmutual\n\n infix 40 _==_ _=S_\n infixr 80 _<<_\n\n data S : Set where\n nat : S\n pi : (A:S) -> (f:El A -> S) -> Map (El A) _==_ S _=S_ f -> S\n\n _=S'_ : rel S\n nat =S' nat = N1\n nat =S' pi A f pf = N0\n pi _ _ _ =S' nat = N0\n pi A F pF =S' pi B G pG =\n Sigma (A =S B) \\ A=B -> (x : El B) -> F (A=B << x) =S G x\n\n data _=S_ (A B : S) : Set where\n eqS : A =S' B -> A =S B\n\n El' : S -> Set\n El' nat = N\n El' (pi A F pF) =\n Sigma ((x : El A) -> El (F x))\n \\f -> {x y : El A}(x=y : x == y) ->\n f x == pF x=y << f y\n\n data El (A : S) : Set where\n el : El' A -> El A\n\n _=='_ : {A : S} -> rel (El A)\n _=='_ {nat} (el x) (el y) = x =N y\n _=='_ {pi A F pF} (el (Pair f pf)) (el (Pair g pg)) =\n (x : El A) -> f x == g x\n\n data _==_ {A : S}(x y : El A) : Set where\n eq : x ==' y -> x == y\n\n _<<_ : {A B : S} -> A =S B -> El B -> El A\n _<<_ {nat} {nat} p x = x\n _<<_ {pi A F pF} {pi B G pG} (eqS (Pair A=B F=G)) (el (Pair g pg)) =\n el (Pair f (\\{x}{y} -> pf x y))\n where\n B=A = symS A=B\n\n F=Gc : (x : El A) -> F x =S G (B=A << x)\n F=Gc x =\n transS (transS refS (symS (pF (castlem A=B (symS A=B) x))))\n (F=G (symS A=B << x))\n\n-- chain> F x\n-- === F (A=B << B=A << x) by symS (pF (castlem A=B B=A x))\n-- === G (B=A << x) by F=G (B=A << x)\n-- where\n-- open module C = Chain _=S_ refS transS\n\n f : (x : El A) -> El (F x)\n f x = F=Gc x << g (B=A << x)\n\n pf : (x y : El A)(p : x == y) -> f x == pF p << f y\n pf x y x=y = trans fx=ccgy ccgy=cfy\n where\n cx = B=A << x\n cy = B=A << y\n\n cx=cy : cx == cy\n cx=cy = p<< B=A x=y\n\n cgy : El (G cx)\n cgy = pG cx=cy << g cy\n\n gx=gy : g cx == cgy\n gx=gy = pg cx=cy\n\n ccgy : El (F x)\n ccgy = F=Gc x << cgy\n\n fx=ccgy : f x == ccgy\n fx=ccgy = p<< (F=Gc x) gx=gy\n\n cfy : El (F x)\n cfy = pF x=y << f y\n\n ccgy=cfy : ccgy == cfy\n ccgy=cfy = castlem2 (F=Gc x) (pF x=y)\n (pG cx=cy) (F=Gc y)\n (g cy)\n\n p<< : {A B : S}(A=B : A =S B) -> Map (El B) _==_ (El A) _==_ (_<<_ A=B)\n p<< {nat}{nat} _ x=y = x=y\n p<< {pi A F pF} {pi B G pG} (eqS (Pair A=B F=G))\n {el (Pair f pf)} {el (Pair g pg)} (eq f=g) = eq cf=cg\n where\n open module C = Logic.ChainReasoning.Mono.Homogenous _=S_ (\\x -> refS) (\\x y z -> transS)\n B=A = symS A=B\n\n F=Gc : (x : El A) -> F x =S G (B=A << x)\n F=Gc x =\n chain> F x\n === F (A=B << B=A << x) by symS (pF (castlem A=B B=A x))\n === G (B=A << x) by F=G _\n\n cf=cg : (x : El A) -> F=Gc x << f (B=A << x)\n == F=Gc x << g (B=A << x)\n cf=cg x = p<< (F=Gc x) (f=g (B=A << x))\n\n p<< {nat} {pi _ _ _} (eqS ()) _\n p<< {pi _ _ _} {nat} (eqS ()) _\n\n refS : Refl _=S_\n refS {nat} = eqS T\n refS {pi A F pF} = eqS (Pair refS \\(x : El A) -> pF (castref refS x))\n\n transS : Trans _=S_\n transS {nat}{nat}{nat} p q = p\n transS {nat}{nat}{pi _ _ _} _ (eqS ())\n transS {nat}{pi _ _ _}{_} (eqS ()) _\n transS {pi _ _ _}{nat}{_} (eqS ()) _\n transS {pi _ _ _}{pi _ _ _}{nat} _ (eqS ())\n transS {pi A F pF}{pi B G pG}{pi C H pH}\n (eqS (Pair A=B F=G)) (eqS (Pair B=C G=H)) =\n eqS (Pair A=C F=H)\n where\n open module C = Chain _=S_ refS transS\n A=C = transS A=B B=C\n F=H : (x : El C) -> F (A=C << x) =S H x\n F=H x =\n chain> F (A=C << x)\n === F (A=B << B=C << x) by symS (pF (casttrans A=B B=C A=C x))\n === G (B=C << x) by F=G (B=C << x)\n === H x by G=H x\n\n symS : Sym _=S_\n symS {nat}{nat} p = p\n symS {pi _ _ _}{nat} (eqS ())\n symS {nat}{pi _ _ _} (eqS ())\n symS {pi A F pF}{pi B G pg} (eqS (Pair A=B F=G)) = eqS (Pair B=A G=F)\n where\n open module C = Chain _=S_ refS transS\n B=A = symS A=B\n G=F : (x : El A) -> G (B=A << x) =S F x\n G=F x =\n chain> G (B=A << x)\n === F (A=B << B=A << x) by symS (F=G (B=A << x))\n === F x by pF (castlem A=B B=A x)\n\n pfi : {A B : S}(p q : A =S B)(x : El B) -> p << x == q << x\n pfi {nat}{nat} _ _ x = ref\n pfi {nat}{pi _ _ _} (eqS ()) _ _\n pfi {pi _ _ _}{nat} (eqS ()) _ _\n pfi {pi A F pF}{pi B G pG} (eqS (Pair A=B1 F=G1)) (eqS (Pair A=B2 F=G2))\n (el (Pair f pf)) = eq f1=f2\n where\n B=A1 = symS A=B1\n B=A2 = symS A=B2\n\n f1=f2 : (x : El A) -> _ << f (B=A1 << x) == _ << f (B=A2 << x)\n f1=f2 x =\n chain> _ << f (B=A1 << x)\n === _ << _ << f (B=A2 << x) by p<< _ lem2\n === _ << f (B=A2 << x) by casttrans _ _ _ _\n where\n open module C = Chain _==_ (ref {F x}) (trans {F x})\n lem1 : B=A1 << x == B=A2 << x\n lem1 = pfi B=A1 B=A2 x\n\n lem2 : f (B=A1 << x) == _ << f (B=A2 << x)\n lem2 = pf lem1\n\n castref : {A : S}(p : A =S A)(x : El A) -> p << x == x\n castref {nat} p x = ref\n castref {pi A F pF} (eqS (Pair A=A F=F)) (el (Pair f pf)) = eq cf=f\n where\n A=A' = symS A=A\n cf=f : (x : El A) -> _ << f (A=A' << x) == f x\n cf=f x =\n chain> Fx=Fcx << f (A=A' << x)\n === Fx=Fcx << _ << f x by p<< Fx=Fcx lem2\n === refS << f x by casttrans _ _ _ (f x)\n === f x by castref _ (f x)\n where\n Fx=Fcx = _\n open module C = Chain _==_ (ref {F x}) (trans {F x})\n lem1 : A=A' << x == x\n lem1 = castref A=A' x\n\n lem2 : f (A=A' << x) == _ << f x\n lem2 = pf lem1\n\n casttrans : {A B C : S}(A=B : A =S B)(B=C : B =S C)(A=C : A =S C)(x : El C) ->\n A=B << B=C << x == A=C << x\n casttrans {nat}{nat}{nat} _ _ _ x = ref\n casttrans {nat}{nat}{pi _ _ _} _ (eqS ()) _ _\n casttrans {nat}{pi _ _ _}{_} (eqS ()) _ _ _\n casttrans {pi _ _ _}{nat}{_} (eqS ()) _ _ _\n casttrans {pi _ _ _}{pi _ _ _}{nat} _ (eqS ()) _ _\n casttrans {pi A F pF}{pi B G pG}{pi C H pH}\n (eqS (Pair A=B F=G))(eqS (Pair B=C G=H))(eqS (Pair A=C F=H))\n (el (Pair h ph)) = eq prf\n where\n B=A = symS A=B\n C=B = symS B=C\n C=A = symS A=C\n\n prf : (x : El A) -> _ << _ << h (C=B << B=A << x) == _ << h (C=A << x)\n prf x =\n chain> Fx=Gcx << Gcx=Hccx << h (C=B << B=A << x)\n === Fx=Hccx << h (C=B << B=A << x) by casttrans _ _ _ _\n === Fx=Hccx << _ << h (C=A << x) by p<< _ (ph (casttrans C=B B=A C=A x))\n === Fx=Hcx << h (C=A << x) by casttrans _ _ _ _\n where\n Fx=Gcx = _\n Gcx=Hccx = _\n Fx=Hccx = transS (lemF=Gc A=B pF pG F=G _)\n (lemF=Gc B=C pG pH G=H _)\n Fx=Hcx = _\n open module C = Chain _==_ (ref {F x}) (trans {F x})\n\n lemF=Gc : {A B : S}(A=B : A =S B)\n {F : El A -> S}(pF : Map (El A) _==_ S _=S_ F)\n {G : El B -> S}(pG : Map (El B) _==_ S _=S_ G)\n (F=G : (x : El B) -> F (A=B << x) =S G x)\n (x : El A) -> F x =S G (symS A=B << x)\n lemF=Gc A=B {F} pF {G} pG F=G x =\n chain> F x\n === F (A=B << B=A << x) by symS (pF (castlem A=B B=A x))\n === G (B=A << x) by F=G _\n where\n open module C = Chain _=S_ refS transS\n B=A = symS A=B\n\n castlem : {A B : S}(p : A =S B)(q : B =S A)(x : El A) ->\n p << q << x == x\n castlem {A}{B} p q x =\n chain> p << q << x\n === refS << x by casttrans p q refS x\n === x by castref refS x\n where open module C = Chain _==_ (ref {A}) (trans {A})\n\n castlem2 : {A B B' C : S}(A=B : A =S B)(A=B' : A =S B')(B=C : B =S C)(B'=C : B' =S C)\n (x : El C) ->\n A=B << B=C << x == A=B' << B'=C << x\n castlem2 {A} p p' q q' x =\n chain> p << q << x\n === transS p q << x by casttrans _ _ _ x\n === transS p' q' << x by pfi _ _ _\n === p' << q' << x by sym (casttrans _ _ _ x)\n where open module C = Chain _==_ (ref {A}) (trans {A})\n\n ref : {A:S} -> Refl {El A} _==_\n ref {nat} {el n} = eq refN\n ref {pi A F pF}{el (Pair f pf)} = eq f=f\n where\n f=f : (x : El A) -> f x == f x\n f=f x = ref\n\n trans : {A:S} -> Trans {El A} _==_\n trans {nat}{el x}{el y}{el z} (eq p) (eq q) = eq (transN p q)\n trans {pi A F pF}{el (Pair f pf)}{el (Pair g pg)}{el (Pair h ph)}\n (eq f=g)(eq g=h) = eq f=h\n where\n f=h : (x : El A) -> f x == h x\n f=h x = trans (f=g x) (g=h x)\n\n sym : {A:S} -> Sym {El A} _==_\n sym {nat}{el x}{el y} (eq p) = eq (symN p)\n sym {pi A F pF}{el (Pair f pf)}{el (Pair g pg)}\n (eq f=g) = eq g=f\n where\n g=f : (x : El A) -> g x == f x\n g=f x = sym (f=g x)\n\n", "meta": {"hexsha": "fa37bf22144fd7a59e883628266cd5e3a660f388", "size": 10026, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/bugs/univ.agda", "max_stars_repo_name": "alhassy/agda", "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/bugs/univ.agda", "max_issues_repo_name": "alhassy/agda", "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/bugs/univ.agda", "max_forks_repo_name": "alhassy/agda", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 31.1366459627, "max_line_length": 95, "alphanum_fraction": 0.3997606224, "num_tokens": 4108, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711832583695, "lm_q2_score": 0.7090191276365463, "lm_q1q2_score": 0.6026458268700522}} {"text": "{-# OPTIONS --safe #-}\n\nmodule Cubical.Categories.Instances.Sets where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Categories.Category\nopen import Cubical.Categories.Functor\nopen import Cubical.Categories.NaturalTransformation\n\nopen Category\n\nmodule _ ℓ where\n SET : Category (ℓ-suc ℓ) ℓ\n ob SET = hSet ℓ\n Hom[_,_] SET (A , _) (B , _) = A → B\n id SET x = x\n _⋆_ SET f g x = g (f x)\n ⋆IdL SET f = refl\n ⋆IdR SET f = refl\n ⋆Assoc SET f g h = refl\n isSetHom SET {A} {B} = isSetΠ (λ _ → snd B)\n\nprivate\n variable\n ℓ ℓ' : Level\n\nopen Functor\n\n-- Hom functors\n_[-,_] : (C : Category ℓ ℓ') → (c : C .ob) → Functor (C ^op) (SET ℓ')\n(C [-, c ]) .F-ob x = (C [ x , c ]) , C .isSetHom\n(C [-, c ]) .F-hom f k = f ⋆⟨ C ⟩ k\n(C [-, c ]) .F-id = funExt λ _ → C .⋆IdL _\n(C [-, c ]) .F-seq _ _ = funExt λ _ → C .⋆Assoc _ _ _\n\n_[_,-] : (C : Category ℓ ℓ') → (c : C .ob)→ Functor C (SET ℓ')\n(C [ c ,-]) .F-ob x = (C [ c , x ]) , C .isSetHom\n(C [ c ,-]) .F-hom f k = k ⋆⟨ C ⟩ f\n(C [ c ,-]) .F-id = funExt λ _ → C .⋆IdR _\n(C [ c ,-]) .F-seq _ _ = funExt λ _ → sym (C .⋆Assoc _ _ _)\n\nmodule _ {C : Category ℓ ℓ'} {F : Functor C (SET ℓ')} where\n open NatTrans\n\n -- natural transformations by pre/post composition\n preComp : {x y : C .ob}\n → (f : C [ x , y ])\n → C [ x ,-] ⇒ F\n → C [ y ,-] ⇒ F\n preComp f α .N-ob c k = (α ⟦ c ⟧) (f ⋆⟨ C ⟩ k)\n preComp f α .N-hom {x = c} {d} k\n = (λ l → (α ⟦ d ⟧) (f ⋆⟨ C ⟩ (l ⋆⟨ C ⟩ k)))\n ≡[ i ]⟨ (λ l → (α ⟦ d ⟧) (⋆Assoc C f l k (~ i))) ⟩\n (λ l → (α ⟦ d ⟧) (f ⋆⟨ C ⟩ l ⋆⟨ C ⟩ k))\n ≡[ i ]⟨ (λ l → (α .N-hom k) i (f ⋆⟨ C ⟩ l)) ⟩\n (λ l → (F ⟪ k ⟫) ((α ⟦ c ⟧) (f ⋆⟨ C ⟩ l)))\n ∎\n\n-- properties\n-- TODO: move to own file\nopen CatIso renaming (inv to cInv)\nopen Iso\n\nIso→CatIso : ∀ {A B : (SET ℓ) .ob}\n → Iso (fst A) (fst B)\n → CatIso (SET ℓ) A B\nIso→CatIso is .mor = is .fun\nIso→CatIso is .cInv = is .inv\nIso→CatIso is .sec = funExt λ b → is .rightInv b -- is .rightInv\nIso→CatIso is .ret = funExt λ b → is .leftInv b -- is .rightInv\n", "meta": {"hexsha": "a76f6a3616bafcbf1027358d01ac67813eb30010", "size": 2141, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Instances/Sets.agda", "max_stars_repo_name": "mzeuner/cubical", "max_stars_repo_head_hexsha": "63c770b381039c0132c17d7913f4566b35984701", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Categories/Instances/Sets.agda", "max_issues_repo_name": "mzeuner/cubical", "max_issues_repo_head_hexsha": "63c770b381039c0132c17d7913f4566b35984701", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Categories/Instances/Sets.agda", "max_forks_repo_name": "mzeuner/cubical", "max_forks_repo_head_hexsha": "63c770b381039c0132c17d7913f4566b35984701", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.3287671233, "max_line_length": 69, "alphanum_fraction": 0.5151798225, "num_tokens": 932, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711832583695, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.6026458268700521}} {"text": "open import Data.Product using (∃; ∃-syntax; _×_; _,_)\n\nopen import DeBruijn\nopen import Parallel\nopen import Beta\nopen import Takahashi\n\n\npar-triangle : ∀ {n} {M N : Term n}\n → M ⇉ N\n -------\n → N ⇉ M *\npar-triangle {M = # x} ⇉-c = ⇉-c\npar-triangle {M = ƛ M} (⇉-ƛ M⇉N) = ⇉-ƛ (par-triangle M⇉N)\npar-triangle {M = (ƛ M) · N} (⇉-β M⇉M′ N⇉N′) = sub-par (par-triangle M⇉M′) (par-triangle N⇉N′)\npar-triangle {M = # _ · N} (⇉-ξ M⇉M′ N⇉N′) = ⇉-ξ (par-triangle M⇉M′) (par-triangle N⇉N′)\npar-triangle {M = _ · _ · N} (⇉-ξ M⇉M′ N⇉N′) = ⇉-ξ (par-triangle M⇉M′) (par-triangle N⇉N′)\npar-triangle {M = (ƛ _) · N} (⇉-ξ (⇉-ƛ M⇉M′) N⇉N′) = ⇉-β (par-triangle M⇉M′) (par-triangle N⇉N′)\n\n\npar-diamond : ∀ {n} {M A B : Term n}\n → M ⇉ A → M ⇉ B\n ----------------------\n → ∃[ N ] (A ⇉ N × B ⇉ N)\npar-diamond {M = M} M⇉A M⇉B = M * , par-triangle M⇉A , par-triangle M⇉B\n\n\nstrip : ∀ {n} {M A B : Term n}\n → M ⇉ A → M ⇉* B\n ------------------------\n → ∃[ N ] (A ⇉* N × B ⇉ N)\nstrip {A = A} M⇉A (M ∎) = A , (A ∎) , M⇉A\nstrip {A = A} M⇉A (M ⇉⟨ M⇉M′ ⟩ M′⇉*B)\n with par-diamond M⇉A M⇉M′\n... | N , A⇉N , M′⇉N\n with strip M′⇉N M′⇉*B\n... | N′ , N⇉*N′ , B⇉N′ =\n N′ , (A ⇉⟨ A⇉N ⟩ N⇉*N′) , B⇉N′\n\n\npar-confluence : ∀ {n} {M A B : Term n}\n → M ⇉* A → M ⇉* B\n ------------------------\n → ∃[ N ] (A ⇉* N × B ⇉* N)\npar-confluence {B = B} (M ∎) M⇉*B = B , M⇉*B , (B ∎)\npar-confluence {B = B} (M ⇉⟨ M⇉A ⟩ A⇉*A′) M⇉*B\n with strip M⇉A M⇉*B\n... | N , A⇉*N , B⇉N\n with par-confluence A⇉*A′ A⇉*N\n... | N′ , A′⇉*N′ , N⇉*N′ =\n N′ , A′⇉*N′ , (B ⇉⟨ B⇉N ⟩ N⇉*N′)\n\n\nconfluence : ∀ {n} {M A B : Term n}\n → M —↠ A → M —↠ B\n ------------------------\n → ∃[ N ] (A —↠ N × B —↠ N)\nconfluence M—↠A M—↠B\n with par-confluence (betas-pars M—↠A) (betas-pars M—↠B)\n... | N , A⇉*N , B⇉*N =\n N , pars-betas A⇉*N , pars-betas B⇉*N\n", "meta": {"hexsha": "4c7aba39f47a307e7c23263a219650226a149e04", "size": 1889, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "ConfluenceParallelTakahashi.agda", "max_stars_repo_name": "iwilare/church-rosser", "max_stars_repo_head_hexsha": "2fa17f7738cc7da967375be928137adc4be38696", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-06-02T07:27:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-22T01:43:09.000Z", "max_issues_repo_path": "ConfluenceParallelTakahashi.agda", "max_issues_repo_name": "iwilare/church-rosser", "max_issues_repo_head_hexsha": "2fa17f7738cc7da967375be928137adc4be38696", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ConfluenceParallelTakahashi.agda", "max_forks_repo_name": "iwilare/church-rosser", "max_forks_repo_head_hexsha": "2fa17f7738cc7da967375be928137adc4be38696", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.4677419355, "max_line_length": 96, "alphanum_fraction": 0.4097406035, "num_tokens": 1057, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681195338728, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.6026078809056122}} {"text": "open import Structure.Setoid\nopen import Structure.Category\nopen import Type\n\nmodule Structure.Category.CoMonad\n {ℓₒ ℓₘ ℓₑ}\n {cat : CategoryObject{ℓₒ}{ℓₘ}{ℓₑ}}\n where\n\nimport Function.Equals\nopen Function.Equals.Dependent\nopen import Functional.Dependent using () renaming (_∘_ to _∘ᶠⁿ_)\nimport Lvl\nopen import Logic.Predicate\nopen import Structure.Category.Functor\nopen import Structure.Category.Functor.Functors as Functors\nopen import Structure.Category.NaturalTransformation\nopen import Structure.Category.NaturalTransformation.NaturalTransformations as NaturalTransformations\n\nopen CategoryObject(cat)\nopen Category.ArrowNotation(category)\nopen Category(category)\nopen Functors.Wrapped\nopen NaturalTransformations.Raw(intro category)(intro category)\nprivate instance _ = cat\n\nrecord CoMonad (T : Object → Object) ⦃ functor : Functor(category)(category)(T) ⦄ : Type{Lvl.of(Type.of(cat))} where\n open Functor(functor)\n\n functor-object : cat →ᶠᵘⁿᶜᵗᵒʳ cat\n functor-object = [∃]-intro T ⦃ functor ⦄\n private Tᶠᵘⁿᶜᵗᵒʳ = functor-object\n\n field\n Η : (Tᶠᵘⁿᶜᵗᵒʳ →ᴺᵀ idᶠᵘⁿᶜᵗᵒʳ)\n Μ : (Tᶠᵘⁿᶜᵗᵒʳ →ᴺᵀ (Tᶠᵘⁿᶜᵗᵒʳ ∘ᶠᵘⁿᶜᵗᵒʳ Tᶠᵘⁿᶜᵗᵒʳ))\n\n η = [∃]-witness Η\n μ = [∃]-witness Μ\n\n η-natural : ∀{x y}{f} → (η(y) ∘ map f ≡ f ∘ η(x))\n η-natural = NaturalTransformation.natural([∃]-proof Η)\n\n μ-natural : ∀{x y}{f} → (μ(y) ∘ map f ≡ map(map f) ∘ μ(x))\n μ-natural = NaturalTransformation.natural([∃]-proof Μ)\n\n field\n μ-functor-[∘]-commutativity : ((μ ∘ᶠⁿ T) ∘ᴺᵀ μ ⊜ (map ∘ᶠⁿ μ) ∘ᴺᵀ μ)\n μ-functor-[∘]-identityₗ : ((map ∘ᶠⁿ η) ∘ᴺᵀ μ ⊜ idᴺᵀ)\n μ-functor-[∘]-identityᵣ : ((η ∘ᶠⁿ T) ∘ᴺᵀ μ ⊜ idᴺᵀ)\n\n module FunctionalNames where\n extract : ∀{x} → (T(x) ⟶ x)\n extract{x} = [∃]-witness Η(x)\n\n duplicate : ∀{x} → (T(x) ⟶ T(T(x)))\n duplicate{x} = [∃]-witness Μ(x)\n", "meta": {"hexsha": "7e72db9fa74dfebcbe94bf78b06304e24066ba04", "size": 1800, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Category/CoMonad.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Category/CoMonad.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Category/CoMonad.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.0344827586, "max_line_length": 116, "alphanum_fraction": 0.6822222222, "num_tokens": 803, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513731336204, "lm_q2_score": 0.6723317123102956, "lm_q1q2_score": 0.6025782203593807}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Category.Instance.Globe where\n\nopen import Level using (Level; zero)\nopen import Relation.Binary using (IsEquivalence; module IsEquivalence)\nopen import Relation.Binary.PropositionalEquality using (isEquivalence)\nopen import Data.Nat using (ℕ; zero; suc; _<_; _≤_; z≤n; s≤s)\n\nopen import Categories.Category\n\ndata GlobeHom : (m n : ℕ) → Set where\n I : ∀ {place : ℕ} → GlobeHom place place\n σ : ∀ {n m : ℕ} → GlobeHom (suc n) m → GlobeHom n m\n τ : ∀ {n m : ℕ} → GlobeHom (suc n) m → GlobeHom n m\n\ndata GlobeEq : {m n : ℕ} → GlobeHom m n → GlobeHom m n → Set where\n both-I : ∀ {m} → GlobeEq {m} {m} I I\n both-σ : ∀ {m n x y} → GlobeEq {m} {n} (σ x) (σ y)\n both-τ : ∀ {m n x y} → GlobeEq {m} {n} (τ x) (τ y)\n\nGlobeEquiv : ∀ {m n} → IsEquivalence (GlobeEq {m} {n})\nGlobeEquiv = record { refl = refl; sym = sym; trans = trans }\n where\n refl : ∀ {m n} {x : GlobeHom m n} → GlobeEq x x\n refl {x = I} = both-I\n refl {x = σ y} = both-σ\n refl {x = τ y} = both-τ\n sym : ∀ {m n} {x y : GlobeHom m n} → GlobeEq x y → GlobeEq y x\n sym both-I = both-I\n sym both-σ = both-σ\n sym both-τ = both-τ\n trans : ∀ {m n} {x y z : GlobeHom m n} → GlobeEq x y → GlobeEq y z → GlobeEq x z\n trans both-I y∼z = y∼z\n trans both-σ both-σ = both-σ\n trans both-τ both-τ = both-τ\n\ninfixl 7 _⊚_\n\n_⊚_ : ∀ {l m n} → GlobeHom m n → GlobeHom l m → GlobeHom l n\nx ⊚ I = x\nx ⊚ σ y = σ (x ⊚ y)\nx ⊚ τ y = τ (x ⊚ y)\n\nGlobe : Category Level.zero Level.zero Level.zero\nGlobe = record\n { Obj = ℕ\n ; _⇒_ = GlobeHom\n ; _≈_ = GlobeEq\n ; id = I\n ; _∘_ = _⊚_\n ; assoc = λ {_ _ _ _ f g h} → assoc {f = f} {g} {h}\n ; sym-assoc = λ {_ _ _ _ f g h} → GlobeEquiv.sym (assoc {f = f} {g} {h})\n ; identityˡ = identityˡ\n ; identityʳ = identityʳ\n ; identity² = identity²\n ; equiv = GlobeEquiv\n ; ∘-resp-≈ = ∘-resp-≡\n }\n where\n module GlobeEquiv {m n} = IsEquivalence (GlobeEquiv {m} {n})\n assoc : ∀ {A B C D} {f : GlobeHom A B} {g : GlobeHom B C} {h : GlobeHom C D} → GlobeEq ((h ⊚ g) ⊚ f) (h ⊚ (g ⊚ f))\n assoc {f = I} = refl\n where open IsEquivalence GlobeEquiv\n assoc {f = σ y} = both-σ\n assoc {f = τ y} = both-τ\n identityˡ : ∀ {A B} {f : GlobeHom A B} → GlobeEq (I ⊚ f) f\n identityˡ {f = I} = both-I\n identityˡ {f = σ y} = both-σ\n identityˡ {f = τ y} = both-τ\n identityʳ : ∀ {A B} {f : GlobeHom A B} → GlobeEq (f ⊚ I) f\n identityʳ = IsEquivalence.refl GlobeEquiv\n identity² : {m : ℕ} → GlobeEq {m} (I ⊚ I) I\n identity² = both-I\n ∘-resp-≡ : ∀ {A B C} {f h : GlobeHom B C} {g i : GlobeHom A B} → GlobeEq f h → GlobeEq g i → GlobeEq (f ⊚ g) (h ⊚ i)\n ∘-resp-≡ f∼h both-I = f∼h\n ∘-resp-≡ f∼h both-σ = both-σ\n ∘-resp-≡ f∼h both-τ = both-τ\n", "meta": {"hexsha": "3b67a5a61a6807d195c41c89d27f56cb8a046044", "size": 2719, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Instance/Globe.agda", "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Category/Instance/Globe.agda", "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Instance/Globe.agda", "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.858974359, "max_line_length": 118, "alphanum_fraction": 0.5663847003, "num_tokens": 1154, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513675912913, "lm_q2_score": 0.6723316926137811, "lm_q1q2_score": 0.602578198980069}} {"text": "{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-}\nmodule Cubical.Data.NatMinusOne.Properties where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Data.Nat\nopen import Cubical.Data.NatMinusOne.Base\n\n-1+Path : ℕ ≡ ℕ₋₁\n-1+Path = isoToPath (iso -1+_ 1+_ (λ _ → refl) (λ _ → refl))\n", "meta": {"hexsha": "af797a3dcd7eeb3e29102c9943dd5045a2144dbf", "size": 353, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/NatMinusOne/Properties.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Data/NatMinusOne/Properties.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/Data/NatMinusOne/Properties.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "avg_line_length": 32.0909090909, "max_line_length": 67, "alphanum_fraction": 0.7393767705, "num_tokens": 111, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8872045937171068, "lm_q2_score": 0.6791787056691697, "lm_q1q2_score": 0.6025704676245262}} {"text": "------------------------------------------------------------------------------\n-- Abelian group theory properties\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule GroupTheory.AbelianGroup.PropertiesATP where\n\nopen import GroupTheory.AbelianGroup.Base\n\n------------------------------------------------------------------------------\n\npostulate xyx⁻¹≡y : ∀ a b → a · b · a ⁻¹ ≡ b\n{-# ATP prove xyx⁻¹≡y #-}\n\npostulate x⁻¹y⁻¹≡[xy]⁻¹ : ∀ a b → a ⁻¹ · b ⁻¹ ≡ (a · b) ⁻¹\n{-# ATP prove x⁻¹y⁻¹≡[xy]⁻¹ #-}\n", "meta": {"hexsha": "d3cc6fdebea549d57c057e2338e6a82ecec17b6f", "size": 706, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/GroupTheory/AbelianGroup/PropertiesATP.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/GroupTheory/AbelianGroup/PropertiesATP.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/GroupTheory/AbelianGroup/PropertiesATP.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 33.619047619, "max_line_length": 78, "alphanum_fraction": 0.3767705382, "num_tokens": 169, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.84594244507642, "lm_q2_score": 0.7122321720225278, "lm_q1q2_score": 0.6025074250628265}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Relation.Binary.Raw.Construct.Constant where\n\nopen import Cubical.Core.Everything\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels using (hProp)\n\nopen import Cubical.Relation.Binary.Raw\n\n------------------------------------------------------------------------\n-- Definition\n\nConst : ∀ {a b c} {A : Type a} {B : Type b} → Type c → RawREL A B c\nConst I = λ _ _ → I\n\n------------------------------------------------------------------------\n-- Properties\n\nmodule _ {a c} {A : Type a} {C : Type c} where\n\n reflexive : C → Reflexive {A = A} (Const C)\n reflexive c = c\n\n symmetric : Symmetric {A = A} (Const C)\n symmetric c = c\n\n transitive : Transitive {A = A} (Const C)\n transitive c d = c\n\n isPartialEquivalence : IsPartialEquivalence {A = A} (Const C)\n isPartialEquivalence = record\n { symmetric = λ {x} {y} → symmetric {x} {y}\n ; transitive = λ {x} {y} {z} → transitive {x} {y} {z}\n }\n\n partialEquivalence : PartialEquivalence A c\n partialEquivalence = record { isPartialEquivalence = isPartialEquivalence }\n\n isEquivalence : C → IsEquivalence {A = A} (Const C)\n isEquivalence c = record\n { isPartialEquivalence = isPartialEquivalence\n ; reflexive = λ {x} → reflexive c {x}\n }\n\n equivalence : C → Equivalence A c\n equivalence x = record { isEquivalence = isEquivalence x }\n", "meta": {"hexsha": "baa85a4d64338997dd7c5602e408093c621cddbc", "size": 1412, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Relation/Binary/Raw/Construct/Constant.agda", "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Relation/Binary/Raw/Construct/Constant.agda", "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Relation/Binary/Raw/Construct/Constant.agda", "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.0425531915, "max_line_length": 77, "alphanum_fraction": 0.5998583569, "num_tokens": 391, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424373085146, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.6025074246974681}} {"text": "------------------------------------------------------------------------------\n-- Arithmetic properties (using induction on the FOTC natural numbers type)\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- Usually our proofs use pattern matching instead of the induction\n-- principle associated with the FOTC natural numbers. The following\n-- examples show some proofs using it.\n\nmodule FOTC.Data.Nat.PropertiesByInductionI where\n\nopen import Common.FOL.Relation.Binary.EqReasoning\n\nopen import FOTC.Base\nopen import FOTC.Base.PropertiesI\nopen import FOTC.Data.Nat\nopen import FOTC.Data.Nat.UnaryNumbers\n\n------------------------------------------------------------------------------\n-- Congruence properties\n\n+-leftCong : ∀ {a b c} → a ≡ b → a + c ≡ b + c\n+-leftCong refl = refl\n\n+-rightCong : ∀ {a b c} → b ≡ c → a + b ≡ a + c\n+-rightCong refl = refl\n\n------------------------------------------------------------------------------\n\nN→0∨S : ∀ {n} → N n → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ N n')\nN→0∨S = N-ind A A0 is\n where\n A : D → Set\n A i = i ≡ zero ∨ (∃[ i' ] i ≡ succ₁ i' ∧ N i')\n\n A0 : A zero\n A0 = inj₁ refl\n\n is : ∀ {i} → A i → A (succ₁ i)\n is {i} Ai = case prf₁ prf₂ Ai\n where\n prf₁ : i ≡ zero → succ₁ i ≡ zero ∨ (∃[ i' ] succ₁ i ≡ succ₁ i' ∧ N i')\n prf₁ h' = inj₂ (i , refl , (subst N (sym h') nzero))\n\n prf₂ : ∃[ i' ] i ≡ succ₁ i' ∧ N i' →\n succ₁ i ≡ zero ∨ (∃[ i' ] succ₁ i ≡ succ₁ i' ∧ N i')\n prf₂ (i' , prf , Ni') = inj₂ (i , refl , subst N (sym prf) (nsucc Ni'))\n\nSx≢x : ∀ {n} → N n → succ₁ n ≢ n\nSx≢x = N-ind A A0 is\n where\n A : D → Set\n A i = succ₁ i ≢ i\n\n A0 : A zero\n A0 = S≢0\n\n is : ∀ {i} → A i → A (succ₁ i)\n is {i} Ai = →-trans succInjective Ai\n\n+-leftIdentity : ∀ n → zero + n ≡ n\n+-leftIdentity n = +-0x n\n\n+-rightIdentity : ∀ {n} → N n → n + zero ≡ n\n+-rightIdentity = N-ind A A0 is\n where\n A : D → Set\n A i = i + zero ≡ i\n\n A0 : A zero\n A0 = +-leftIdentity zero\n\n is : ∀ {i} → A i → A (succ₁ i)\n is {i} Ai = trans (+-Sx i zero) (succCong Ai)\n\npred-N : ∀ {n} → N n → N (pred₁ n)\npred-N {n} Nn = case h₁ h₂ (N→0∨S Nn)\n where\n h₁ : n ≡ zero → N (pred₁ n)\n h₁ n≡0 = subst N (sym (trans (predCong n≡0) pred-0)) nzero\n\n h₂ : ∃[ n' ] n ≡ succ₁ n' ∧ N n' → N (pred₁ n)\n h₂ (n' , prf , Nn') = subst N (sym (trans (predCong prf) (pred-S n'))) Nn'\n\n+-N : ∀ {m n} → N m → N n → N (m + n)\n+-N {n = n} Nm Nn = N-ind A A0 is Nm\n where\n A : D → Set\n A i = N (i + n)\n\n A0 : A zero\n A0 = subst N (sym (+-leftIdentity n)) Nn\n\n is : ∀ {i} → A i → A (succ₁ i)\n is {i} Ai = subst N (sym (+-Sx i n)) (nsucc Ai)\n\n∸-N : ∀ {m n} → N m → N n → N (m ∸ n)\n∸-N {m} Nm Nn = N-ind A A0 is Nn\n where\n A : D → Set\n A i = N (m ∸ i)\n\n A0 : A zero\n A0 = subst N (sym (∸-x0 m)) Nm\n\n is : ∀ {i} → A i → A (succ₁ i)\n is {i} Ai = subst N (sym (∸-xS m i)) (pred-N Ai)\n\n+-assoc : ∀ {m} → N m → ∀ n o → m + n + o ≡ m + (n + o)\n+-assoc Nm n o = N-ind A A0 is Nm\n where\n A : D → Set\n A i = i + n + o ≡ i + (n + o)\n\n A0 : A zero\n A0 = zero + n + o ≡⟨ +-leftCong (+-leftIdentity n) ⟩\n n + o ≡⟨ sym (+-leftIdentity (n + o)) ⟩\n zero + (n + o) ∎\n\n is : ∀ {i} → A i → A (succ₁ i)\n is {i} Ai = succ₁ i + n + o ≡⟨ +-leftCong (+-Sx i n) ⟩\n succ₁ (i + n) + o ≡⟨ +-Sx (i + n) o ⟩\n succ₁ (i + n + o) ≡⟨ succCong Ai ⟩\n succ₁ (i + (n + o)) ≡⟨ sym (+-Sx i (n + o)) ⟩\n succ₁ i + (n + o) ∎\n\nx+Sy≡S[x+y] : ∀ {m} → N m → ∀ n → m + succ₁ n ≡ succ₁ (m + n)\nx+Sy≡S[x+y] Nm n = N-ind A A0 is Nm\n where\n A : D → Set\n A i = i + succ₁ n ≡ succ₁ (i + n)\n\n A0 : A zero\n A0 = zero + succ₁ n ≡⟨ +-leftIdentity (succ₁ n) ⟩\n succ₁ n ≡⟨ succCong (sym (+-leftIdentity n)) ⟩\n succ₁ (zero + n) ∎\n\n is : ∀ {i} → A i → A (succ₁ i)\n is {i} Ai = succ₁ i + succ₁ n ≡⟨ +-Sx i (succ₁ n) ⟩\n succ₁ (i + succ₁ n) ≡⟨ succCong Ai ⟩\n succ₁ (succ₁ (i + n)) ≡⟨ succCong (sym (+-Sx i n)) ⟩\n succ₁ (succ₁ i + n) ∎\n\n+-comm : ∀ {m n} → N m → N n → m + n ≡ n + m\n+-comm {n = n} Nm Nn = N-ind A A0 is Nm\n where\n A : D → Set\n A i = i + n ≡ n + i\n\n A0 : A zero\n A0 = zero + n ≡⟨ +-leftIdentity n ⟩\n n ≡⟨ sym (+-rightIdentity Nn) ⟩\n n + zero ∎\n\n is : ∀ {i} → A i → A (succ₁ i)\n is {i} Ai = succ₁ i + n ≡⟨ +-Sx i n ⟩\n succ₁ (i + n) ≡⟨ succCong Ai ⟩\n succ₁ (n + i) ≡⟨ sym (x+Sy≡S[x+y] Nn i) ⟩\n n + succ₁ i ∎\n\n0∸x : ∀ {n} → N n → zero ∸ n ≡ zero\n0∸x = N-ind A A0 is\n where\n A : D → Set\n A i = zero ∸ i ≡ zero\n\n A0 : A zero\n A0 = ∸-x0 zero\n\n is : ∀ {i} → A i → A (succ₁ i)\n is {i} Ai = zero ∸ succ₁ i ≡⟨ ∸-xS zero i ⟩\n pred₁ (zero ∸ i) ≡⟨ predCong Ai ⟩\n pred₁ zero ≡⟨ pred-0 ⟩\n zero ∎\n\nS∸S : ∀ {m n} → N m → N n → succ₁ m ∸ succ₁ n ≡ m ∸ n\nS∸S {m} Nm = N-ind A A0 is\n where\n A : D → Set\n A i = succ₁ m ∸ succ₁ i ≡ m ∸ i\n\n A0 : A zero\n A0 = succ₁ m ∸ succ₁ zero ≡⟨ ∸-xS (succ₁ m) zero ⟩\n pred₁ (succ₁ m ∸ zero) ≡⟨ predCong (∸-x0 (succ₁ m)) ⟩\n pred₁ (succ₁ m) ≡⟨ pred-S m ⟩\n m ≡⟨ sym (∸-x0 m) ⟩\n m ∸ zero ∎\n\n is : ∀ {i} → A i → A (succ₁ i)\n is {i} Ai = succ₁ m ∸ succ₁ (succ₁ i) ≡⟨ ∸-xS (succ₁ m) (succ₁ i) ⟩\n pred₁ (succ₁ m ∸ succ₁ i) ≡⟨ predCong Ai ⟩\n pred₁ (m ∸ i) ≡⟨ sym (∸-xS m i) ⟩\n m ∸ succ₁ i ∎\n", "meta": {"hexsha": "cfabc97a1ed89df80fd320c473ce6faa60f9d6f4", "size": 5621, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/FOTC/Data/Nat/PropertiesByInductionI.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/FOTC/Data/Nat/PropertiesByInductionI.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/FOTC/Data/Nat/PropertiesByInductionI.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 28.3888888889, "max_line_length": 78, "alphanum_fraction": 0.4349759829, "num_tokens": 2373, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424373085146, "lm_q2_score": 0.7122321720225278, "lm_q1q2_score": 0.6025074195302743}} {"text": "{-# OPTIONS --safe --without-K #-}\nmodule Data.Fin.Subset.Properties.Dec where\n\nopen import Data.Nat as ℕ \nopen import Data.Fin as Fin\nopen import Data.Empty using (⊥-elim)\nopen import Data.Fin.Subset\nopen import Data.Fin.Subset.Dec\nopen import Data.Fin.Subset.Properties using (⊆⊤; p⊆p∪q; q⊆p∪q ; p∩q⊆p ; p∩q⊆q ; ⊆-poset)\nopen import Relation.Nullary\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Unary renaming (Decidable to Decidable₁) using ()\nopen import Data.Vec\nopen import Function using (_∘_)\nopen import Function.Equivalence using (_⇔_ ; equivalence)\nopen import Relation.Nullary.Negation using (¬?)\n \nsubset¬⊆∁subset : ∀ {n}{p} {P : Fin n → Set p}(P? : Decidable₁ P) → subset (¬? ∘ P?) ⊆ ∁ (subset P?)\nsubset¬⊆∁subset {zero} P? ()\nsubset¬⊆∁subset {suc n} P? x∈s with P? (# 0)\nsubset¬⊆∁subset {suc n} P? here | no ¬p0 = here\nsubset¬⊆∁subset {suc n} P? (there x∈s) | no ¬p0 = there (subset¬⊆∁subset (P? ∘ suc) x∈s)\nsubset¬⊆∁subset {suc n} P? (there x∈s) | yes p0 = there (subset¬⊆∁subset (P? ∘ suc) x∈s)\n\n∁subset⊆subset¬ : ∀ {n}{p}{P : Fin n → Set p}(P? : Decidable₁ P) → ∁ (subset P?) ⊆ subset (¬? ∘ P?)\n∁subset⊆subset¬ {zero} P? ()\n∁subset⊆subset¬ {suc n} P? x∈s with P? (# 0)\n∁subset⊆subset¬ {suc n} P? here | no ¬p0 = here\n∁subset⊆subset¬ {suc n} P? (there x∈s) | yes p0 = there (∁subset⊆subset¬ (P? ∘ suc) x∈s) \n∁subset⊆subset¬ {suc n} P? (there x∈s) | no ¬p0 = there (∁subset⊆subset¬ (P? ∘ suc) x∈s)\n\nsubset¬≡∁subset : ∀ {n}{p}{P : Fin n → Set p}(P? : Decidable₁ P) → subset (¬? ∘ P?) ≡ ∁ (subset P?)\nsubset¬≡∁subset {n} P? = ⊆-antisym (subset¬⊆∁subset P?) (∁subset⊆subset¬ P?)\n where\n open Poset (⊆-poset n) renaming (antisym to ⊆-antisym) using () \n\n \n∈subset⁺ : ∀ {n}{p}{P : Fin n → Set p}(P? : Decidable₁ P){x} → P x → x ∈ subset P? \n∈subset⁺ {zero} P? {()} Px\n∈subset⁺ {suc n} P? {x} Px with P? (# 0)\n∈subset⁺ {suc n} P? {zero} Px | yes p0 = here\n∈subset⁺ {suc n} P? {suc x} Px | yes p0 = there (∈subset⁺ (P? ∘ suc) Px)\n∈subset⁺ {suc n} P? {zero} Px | no ¬p0 = ⊥-elim (¬p0 Px)\n∈subset⁺ {suc n} P? {suc x} Px | no ¬p0 = there (∈subset⁺ (P? ∘ suc) Px)\n\n∈subset⁻ : ∀ {n}{p} {P : Fin n → Set p}(P? : Decidable₁ P){x} → x ∈ subset P? → P x \n∈subset⁻ {zero} P? {()} x∈s\n∈subset⁻ {suc n} P? {x} x∈s with P? (# 0)\n∈subset⁻ {suc n} P? {zero} here | yes p0 = p0\n∈subset⁻ {suc n} P? {suc x} (there x∈s) | yes p0 = ∈subset⁻ (P? ∘ suc) x∈s \n∈subset⁻ {suc n} P? {.(suc _)} (there x∈s) | no ¬p0 = ∈subset⁻ (P? ∘ suc) x∈s \n\n⇔∈subset : ∀ {n}{p}{P : Fin n → Set p}(P? : Decidable₁ P) {x} → x ∈ subset P? ⇔ P x \n⇔∈subset P? = equivalence (∈subset⁻ P?) (∈subset⁺ P?)\n\n∈∁subset⁺ : ∀ {n}{p}{P : Fin n → Set p}(P? : Decidable₁ P){x} → ¬ P x → x ∈ ∁ (subset P?) \n∈∁subset⁺ P? = subset¬⊆∁subset P? ∘ (∈subset⁺ (¬? ∘ P? ))\n∈∁subset⁻ : ∀ {n}{p}{P : Fin n → Set p}(P? : Decidable₁ P){x} → x ∈ ∁ (subset P?) → ¬ P x \n∈∁subset⁻ P? = ∈subset⁻ (¬? ∘ P?) ∘ ∁subset⊆subset¬ P?\n\n⇔∈∁subset : ∀ {n}{p}{P : Fin n → Set p}(P? : Decidable₁ P) {x} → x ∈ ∁ (subset P?) ⇔ (¬ P x) \n⇔∈∁subset P? = equivalence (∈∁subset⁻ P?) (∈∁subset⁺ P?)\n", "meta": {"hexsha": "850cebf57c5232164b4d5aec0b3a180d3d97a5ab", "size": 3084, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Fin/Subset/Properties/Dec.agda", "max_stars_repo_name": "tizmd/agda-finitary", "max_stars_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Data/Fin/Subset/Properties/Dec.agda", "max_issues_repo_name": "tizmd/agda-finitary", "max_issues_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/Fin/Subset/Properties/Dec.agda", "max_forks_repo_name": "tizmd/agda-finitary", "max_forks_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.1875, "max_line_length": 100, "alphanum_fraction": 0.5700389105, "num_tokens": 1460, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430645886583, "lm_q2_score": 0.7248702821204019, "lm_q1q2_score": 0.6024709077107961}} {"text": "------------------------------------------------------------------------\n-- The unit type\n------------------------------------------------------------------------\n\nmodule Data.Unit where\n\nopen import Data.Sum\nopen import Relation.Nullary\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as PropEq\n using (_≡_; refl)\n\n------------------------------------------------------------------------\n-- Types\n\n-- Note that the name of this type is \"\\top\", not T.\n\nrecord ⊤ : Set where\n\ntt : ⊤\ntt = record {}\n\nrecord _≤_ (x y : ⊤) : Set where\n\n------------------------------------------------------------------------\n-- Operations\n\n_≟_ : Decidable {⊤} _≡_\n_ ≟ _ = yes refl\n\n_≤?_ : Decidable _≤_\n_ ≤? _ = yes _\n\ntotal : Total _≤_\ntotal _ _ = inj₁ _\n\n------------------------------------------------------------------------\n-- Properties\n\npreorder : Preorder\npreorder = PropEq.preorder ⊤\n\nsetoid : Setoid\nsetoid = PropEq.setoid ⊤\n\ndecTotalOrder : DecTotalOrder\ndecTotalOrder = record\n { carrier = ⊤\n ; _≈_ = _≡_\n ; _≤_ = _≤_\n ; isDecTotalOrder = record\n { isTotalOrder = record\n { isPartialOrder = record\n { isPreorder = record\n { isEquivalence = PropEq.isEquivalence\n ; reflexive = λ _ → _\n ; trans = λ _ _ → _\n ; ∼-resp-≈ = PropEq.resp₂ _≤_\n }\n ; antisym = antisym\n }\n ; total = total\n }\n ; _≟_ = _≟_\n ; _≤?_ = _≤?_\n }\n }\n where\n antisym : Antisymmetric _≡_ _≤_\n antisym _ _ = refl\n\ndecSetoid : DecSetoid\ndecSetoid = DecTotalOrder.Eq.decSetoid decTotalOrder\n\nposet : Poset\nposet = DecTotalOrder.poset decTotalOrder\n", "meta": {"hexsha": "a1683638be767ed9c73d9fc90c7fc417e81492e9", "size": 1764, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Data/Unit.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Data/Unit.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Data/Unit.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 22.9090909091, "max_line_length": 72, "alphanum_fraction": 0.443877551, "num_tokens": 449, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430478583168, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.602470890643506}} {"text": "module Data.List.Combinatorics.Proofs where\n\nimport Lvl\nopen import Data\nopen import Data.List\nopen import Data.List.Combinatorics\nopen import Data.List.Functions hiding (skip) renaming (module LongOper to List)\nopen Data.List.Functions.LongOper\nopen import Data.List.Relation.Permutation\nopen import Data.List.Relation.Quantification\nopen import Data.List.Relation.Quantification.Proofs\nopen import Data.List.Relation.Sublist\nopen import Data.List.Relation.Sublist.Proofs\nopen import Data.List.Proofs\nopen import Data.List.Equiv.Id\nopen import Data.List.Proofs.Length\nopen import Data.Tuple as Tuple using (_⨯_ ; _,_)\nimport Data.Tuple.Raiseᵣ as Tuple₊\nimport Data.Tuple.Raiseᵣ.Functions as Tuple₊\nopen import Functional\nopen import Logic.Propositional\nopen import Numeral.Natural\nopen import Numeral.Natural.Combinatorics\nopen import Numeral.Natural.Combinatorics.Proofs\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.Oper.Proofs\nopen import Numeral.Natural.Oper.Proofs.Multiplication\nopen import Numeral.Natural.Oper.Proofs.Order\nopen import Numeral.Natural.Relation.Order\nopen import Numeral.Natural.Relation.Order.Proofs\nopen import Relator.Equals\nopen import Relator.Equals.Proofs.Equiv\nopen import Structure.Function\nopen import Structure.Operator\nopen import Structure.Operator.Properties\nopen import Structure.Relator.Properties\nopen import Syntax.Function\nopen import Syntax.Transitivity\nopen import Type\n\nprivate variable ℓ ℓ₁ ℓ₂ : Lvl.Level\nprivate variable T A B : Type{ℓ}\nprivate variable l l₁ l₂ : List(T)\nprivate variable x : T\nprivate variable n k : ℕ\n\nsublists₊-contains-sublists : AllElements (_⊑ l) (sublists₊(l))\nsublists₊-contains-sublists {l = ∅} = ∅\nsublists₊-contains-sublists {l = x ⊰ l} with sublists₊(l) | sublists₊-contains-sublists {l = l}\n... | ∅ | _ = use [⊑]-minimum ⊰ ∅\n... | sx ⊰ sl | px ⊰ pl = use [⊑]-minimum ⊰ skip px ⊰ use px ⊰ p pl where\n p : ∀{x : T}{l}{sl} → AllElements (_⊑ l) sl → AllElements (_⊑ (x ⊰ l)) (concatMap(y ↦ y ⊰ (x ⊰ y) ⊰ ∅) sl)\n p {sl = ∅} ∅ = ∅\n p {sl = _ ⊰ _} (sll ⊰ alsl) = (skip sll) ⊰ (use sll) ⊰ (p alsl)\n\n{-\nsublists₊-contains-all-nonempty-sublists : ∀{x}{l₁ l₂ : List(T)} → (x ⊰ l₁ ⊑ l₂) → ExistsElement (_≡ x ⊰ l₁) (sublists(l₂))\nsublists₊-contains-all-nonempty-sublists {l₁ = l₁} {prepend x l₂} (use p) = ⊰ (• {!!})\nsublists₊-contains-all-nonempty-sublists {l₁ = l₁} {prepend x l₂} (skip p) = ⊰ (⊰ {!sublists₊-contains-all-nonempty-sublists ?!})\n\nsublists-contains-all-sublists : ∀{l₁ l₂ : List(T)} → (l₁ ⊑ l₂) → ExistsElement (_≡ l₁) (sublists(l₂))\nsublists-contains-all-sublists {l₁ = ∅} {∅} _⊑_.empty = • [≡]-intro\nsublists-contains-all-sublists {l₁ = ∅} {prepend x l₂} (skip sub) = • [≡]-intro\nsublists-contains-all-sublists {l₁ = prepend x l₁} {prepend .x l₂} (use sub) = ⊰ (⊰ {!!})\nsublists-contains-all-sublists {l₁ = prepend x l₁} {prepend x₁ l₂} (skip sub) = {!!}\n-}\n\npermutes-insertedEverywhere : AllElements (_permutes (x ⊰ l)) (insertedEverywhere x l)\npermutes-insertedEverywhere {x = x} {∅} = _permutes_.prepend _permutes_.empty ⊰ ∅\npermutes-insertedEverywhere {x = x} {y ⊰ l} = reflexivity(_permutes_) ⊰ AllElements-mapᵣ(y List.⊰_) (p ↦ trans (_permutes_.prepend p) _permutes_.swap) (permutes-insertedEverywhere {x = x} {l})\n\n{-\nAllElements-insertedEverywhere-function : ∀{P : List(T) → Type{ℓ}} → (∀{l₁ l₂}{x} → (l₁ permutes l₂) → (P(x ⊰ l₁) → P(x ⊰ l₂))) → (∀{l₁ l₂} → (l₁ permutes l₂) → (P(l₁) → P(l₂))) → (∀{l₁ l₂ : List(T)} → (l₁ permutes l₂) → (AllElements P (insertedEverywhere x l₁) → AllElements P (insertedEverywhere x l₂)))\nAllElements-insertedEverywhere-function _ pperm {l₁ = ∅} {∅} _permutes_.empty p@(_ ⊰ _) = p\nAllElements-insertedEverywhere-function t pperm {l₁ = x ⊰ l₁} {.x ⊰ l₂} (_permutes_.prepend perm) (p ⊰ pl) =\n pperm (_permutes_.prepend (_permutes_.prepend perm)) p ⊰\n {!AllElements-insertedEverywhere-function t pperm {l₁ = l₁} {l₂} perm!} -- TODO: Probably needs more assumptions\n -- AllElements-insertedEverywhere-function {l₁ = l₁} {l₂} pperm perm (AllElements-without-map {!!} {!!} pl)\n -- AllElements-map (x List.⊰_) (\\{l} → {!!}) (AllElements-insertedEverywhere-function {l₁ = l₁} {l₂} pperm perm {!!})\nAllElements-insertedEverywhere-function _ pperm {l₁ = x ⊰ .(x₁ ⊰ _)} {x₁ ⊰ .(x ⊰ _)} _permutes_.swap (p₁ ⊰ p₂ ⊰ pl) =\n pperm (trans _permutes_.swap (_permutes_.prepend _permutes_.swap)) p₂ ⊰\n pperm (trans (_permutes_.prepend _permutes_.swap) _permutes_.swap) p₁ ⊰\n {!!}\nAllElements-insertedEverywhere-function t pperm (trans perm₁ perm₂) = AllElements-insertedEverywhere-function t pperm perm₂ ∘ AllElements-insertedEverywhere-function t pperm perm₁\n-}\n\npermutations-contains-permutations : AllElements (_permutes l) (permutations(l))\npermutations-contains-permutations {l = ∅} = _permutes_.empty ⊰ ∅\npermutations-contains-permutations {l = x ⊰ ∅} = _permutes_.prepend _permutes_.empty ⊰ ∅\npermutations-contains-permutations {l = x ⊰ y ⊰ l} = AllElements-concatMap(insertedEverywhere x) (perm ↦ AllElements-of-transitive-binary-relationₗ (_permutes_.prepend perm) permutes-insertedEverywhere) (permutations-contains-permutations {l = y ⊰ l})\n\nsublists₊-length : length(sublists₊ l) ≡ (2 ^ (length l)) −₀ 1\nsublists₊-length {l = ∅} = [≡]-intro\nsublists₊-length {l = x ⊰ l} =\n length(sublists₊ (x ⊰ l)) 🝖[ _≡_ ]-[]\n length(singleton(x) ⊰ foldᵣ (prev ↦ rest ↦ (prev ⊰ (x ⊰ prev) ⊰ rest)) ∅ (sublists₊ l)) 🝖[ _≡_ ]-[]\n 𝐒(length(foldᵣ (prev ↦ rest ↦ (prev ⊰ (x ⊰ prev) ⊰ rest)) ∅ (sublists₊ l))) 🝖[ _≡_ ]-[ [≡]-with(𝐒) (length-foldᵣ {l = sublists₊(l)}{init = ∅}{f = (prev ↦ rest ↦ (prev ⊰ (x ⊰ prev) ⊰ rest))}{g = const(𝐒 ∘ 𝐒)} [≡]-intro) ]\n 𝐒(foldᵣ (prev ↦ rest ↦ 𝐒(𝐒(rest))) 𝟎 (sublists₊ l)) 🝖[ _≡_ ]-[ [≡]-with(𝐒) (foldᵣ-constant-[+]ᵣ{l = sublists₊ l}{init = 𝟎}) ]\n 𝐒(2 ⋅ length(sublists₊ l)) 🝖[ _≡_ ]-[ [≡]-with(𝐒 ∘ (2 ⋅_)) (sublists₊-length {l = l}) ]\n 𝐒(2 ⋅ (2 ^ (length l) −₀ 1)) 🝖[ _≡_ ]-[ [≡]-with(𝐒) (distributivityₗ(_⋅_)(_−₀_) {2}{2 ^ length(l)}{1}) ]\n 𝐒((2 ⋅ (2 ^ (length l))) −₀ 2) 🝖[ _≡_ ]-[]\n 𝐒((2 ^ 𝐒(length l)) −₀ 2) 🝖[ _≡_ ]-[]\n 𝐒((2 ^ length(x ⊰ l)) −₀ 2) 🝖[ _≡_ ]-[ [↔]-to-[→] [−₀][𝐒]ₗ-equality ([^]ₗ-strictly-growing {0}{0}{𝐒(length l)} [≤]-with-[𝐒]) ]-sym\n 𝐒(2 ^ length(x ⊰ l)) −₀ 2 🝖[ _≡_ ]-[]\n (2 ^ length (x ⊰ l)) −₀ 1 🝖-end\n\nsublists-length : length(sublists l) ≡ 2 ^ (length l)\nsublists-length {l = l} =\n length(sublists l) 🝖[ _≡_ ]-[]\n length(∅ ⊰ sublists₊ l) 🝖[ _≡_ ]-[]\n 𝐒(length(sublists₊ l)) 🝖[ _≡_ ]-[ [≡]-with(𝐒) (sublists₊-length {l = l}) ]\n 𝐒((2 ^ length(l)) −₀ 1) 🝖[ _≡_ ]-[ [↔]-to-[→] [−₀][𝐒]ₗ-equality ([^]ₗ-growing {2}{0}{length l} (\\()) [≤]-minimum) ]-sym\n 𝐒(2 ^ length(l)) −₀ 1 🝖[ _≡_ ]-[]\n 2 ^ length(l) 🝖-end\n\ncombinations-length : length(combinations k l) ≡ 𝑐𝐶(length(l))(k)\ncombinations-length {0} {l = _} = [≡]-intro\ncombinations-length {𝐒 k} {l = ∅} = [≡]-intro\ncombinations-length {1} {l = x ⊰ l} =\n length(combinations 1 (x ⊰ l)) 🝖[ _≡_ ]-[]\n length(x ⊰ l) 🝖[ _≡_ ]-[]\n 𝐒(length l) 🝖[ _≡_ ]-[ 𝑐𝐶-singleton-subsets ]-sym\n 𝐒(𝑐𝐶 (length l) 1) 🝖[ _≡_ ]-[]\n 1 + 𝑐𝐶 (length l) 1 🝖[ _≡_ ]-[]\n 𝑐𝐶 (length l) 0 + 𝑐𝐶 (length l) 1 🝖[ _≡_ ]-[]\n 𝑐𝐶 (𝐒(length l)) 1 🝖[ _≡_ ]-[]\n 𝑐𝐶 (length(x ⊰ l)) 1 🝖-end\ncombinations-length {𝐒(𝐒 k)} {l = x ⊰ l} =\n length(combinations (𝐒(𝐒 k)) (x ⊰ l)) 🝖[ _≡_ ]-[]\n length(map (x ,_) (combinations (𝐒 k) l) ++ combinations (𝐒(𝐒 k)) l) 🝖[ _≡_ ]-[ length-[++] {l₁ = map (x ,_) (combinations (𝐒 k) l)}{l₂ = combinations (𝐒(𝐒 k)) l} ]\n length(map (x ,_) (combinations (𝐒 k) l)) + length(combinations (𝐒(𝐒 k)) l) 🝖[ _≡_ ]-[ congruence₂ₗ(_+_)(length(combinations (𝐒(𝐒 k)) l)) (length-map{f = (x ,_)}{x = combinations (𝐒 k) l}) ]\n length(combinations (𝐒 k) l) + length(combinations (𝐒(𝐒 k)) l) 🝖[ _≡_ ]-[ congruence₂(_+_) (combinations-length {𝐒 k} {l = l}) (combinations-length {𝐒(𝐒 k)} {l = l}) ]\n 𝑐𝐶(length(l))(𝐒 k) + 𝑐𝐶(length(l))(𝐒(𝐒 k)) 🝖[ _≡_ ]-[]\n 𝑐𝐶 (length(x ⊰ l)) (𝐒(𝐒 k)) 🝖-end\n\nrepeatableCombinations-length : length(repeatableCombinations k l) ≡ 𝑐𝐶((length(l) + k) −₀ 1)(k)\nrepeatableCombinations-length {0} {l = _} = [≡]-intro\nrepeatableCombinations-length {1} {l = x ⊰ l} = [≡]-intro\nrepeatableCombinations-length {𝐒 k} {l = ∅} = symmetry(_≡_) (𝑐𝐶-larger-subsets{k}{𝐒(k)} (reflexivity(_≤_)))\nrepeatableCombinations-length {𝐒(𝐒 k)} {l = x ⊰ l} =\n length (repeatableCombinations (𝐒(𝐒 k)) (x ⊰ l)) 🝖[ _≡_ ]-[]\n length(map(x ,_) (repeatableCombinations (𝐒 k) (x ⊰ l)) ++ repeatableCombinations(𝐒(𝐒 k)) l) 🝖[ _≡_ ]-[ length-[++] {l₁ = map(x ,_) (repeatableCombinations (𝐒 k) (x ⊰ l))}{l₂ = repeatableCombinations(𝐒(𝐒 k)) l} ]\n length(map(x ,_) (repeatableCombinations (𝐒 k) (x ⊰ l))) + length(repeatableCombinations(𝐒(𝐒 k)) l) 🝖[ _≡_ ]-[ congruence₂ₗ(_+_)(length(repeatableCombinations(𝐒(𝐒 k)) l)) (length-map {f = x ,_}{x = repeatableCombinations (𝐒 k) (x ⊰ l)}) ]\n length(repeatableCombinations (𝐒 k) (x ⊰ l)) + length(repeatableCombinations(𝐒(𝐒 k)) l) 🝖[ _≡_ ]-[ congruence₂(_+_) (repeatableCombinations-length{k = 𝐒 k}{l = x ⊰ l}) (repeatableCombinations-length{k = 𝐒(𝐒 k)}{l = l}) ]\n 𝑐𝐶((length(x ⊰ l) + 𝐒(k)) −₀ 1)(𝐒(k)) + 𝑐𝐶((length(l) + 𝐒(𝐒(k))) −₀ 1)(𝐒(𝐒(k))) 🝖[ _≡_ ]-[]\n 𝑐𝐶((length(x ⊰ l) + 𝐒(𝐒 k)) −₀ 1) (𝐒(𝐒 k)) 🝖-end\n\ntuples-length : length(tuples n l) ≡ length(l) ^ n\ntuples-length {0} = [≡]-intro\ntuples-length {1} = [≡]-intro\ntuples-length {𝐒(𝐒(n))}{l = ∅} = [≡]-intro\ntuples-length {𝐒(𝐒(n))}{l = x ⊰ l} =\n length(tuples(𝐒(𝐒(n))) (x ⊰ l)) 🝖[ _≡_ ]-[]\n length(concatMap(y ↦ map (y Tuple₊.⊰_) (tuples (𝐒(n)) (x ⊰ l))) (x ⊰ l)) 🝖[ _≡_ ]-[ length-concatMap {l = x ⊰ l}{f = y ↦ map (y Tuple₊.⊰_) (tuples (𝐒(n)) (x ⊰ l))} ]\n foldᵣ((_+_) ∘ length ∘ (y ↦ map (y Tuple₊.⊰_) (tuples (𝐒(n)) (x ⊰ l)))) 𝟎 (x ⊰ l) 🝖[ _≡_ ]-[ foldᵣ-function₊-raw {l₁ = x ⊰ l}{a₁ = 𝟎} (\\{a b} → [≡]-with(_+ b) (length-map{f = a Tuple₊.⊰_}{x = tuples (𝐒(n)) (x ⊰ l)})) [≡]-intro [≡]-intro ]\n foldᵣ((_+_) ∘ length ∘ (y ↦ tuples (𝐒(n)) (x ⊰ l))) 𝟎 (x ⊰ l) 🝖[ _≡_ ]-[]\n foldᵣ(const(length(tuples (𝐒(n)) (x ⊰ l)) +_)) 𝟎 (x ⊰ l) 🝖[ _≡_ ]-[ foldᵣ-constant-[+]ₗ{l = x ⊰ l} {init = 𝟎}{step = length(tuples (𝐒(n)) (x ⊰ l))} ]\n length(x ⊰ l) ⋅ length(tuples(𝐒(n)) (x ⊰ l)) 🝖[ _≡_ ]-[ congruence₂ᵣ(_⋅_) (length(x ⊰ l)) (tuples-length {𝐒(n)} {l = x ⊰ l}) ]\n length(x ⊰ l) ⋅ (length(x ⊰ l) ^ 𝐒(n)) 🝖[ _≡_ ]-[]\n length(x ⊰ l) ^ 𝐒(𝐒(n)) 🝖-end\n\nrotations-length : length(rotations l) ≡ length(l)\nrotations-length{l = l} = length-accumulateIterate₀{f = rotateₗ(1)}{init = l}\n\ninsertedEverywhere-contents-length : AllElements(p ↦ length(p) ≡ 𝐒(length(l))) (insertedEverywhere x l)\ninsertedEverywhere-contents-length = AllElements-fn (Function.congruence ⦃ _ ⦄ Proofs.permutes-length-function) permutes-insertedEverywhere\n\ninsertedEverywhere-length : length(insertedEverywhere x l) ≡ 𝐒(length(l))\ninsertedEverywhere-length {x = x} {∅} = [≡]-intro\ninsertedEverywhere-length {x = x} {a ⊰ l} =\n length(insertedEverywhere x (a ⊰ l)) 🝖[ _≡_ ]-[]\n length((x ⊰ a ⊰ l) ⊰ (map (List.prepend a) (insertedEverywhere x l))) 🝖[ _≡_ ]-[]\n 𝐒(length(map (List.prepend a) (insertedEverywhere x l))) 🝖[ _≡_ ]-[ [≡]-with(𝐒) (length-map{f = List.prepend a}{x = insertedEverywhere x l}) ]\n 𝐒(length(insertedEverywhere x l)) 🝖[ _≡_ ]-[ [≡]-with(𝐒) (insertedEverywhere-length {x = x} {l}) ]\n 𝐒(𝐒(length(l))) 🝖[ _≡_ ]-[]\n 𝐒(length(a ⊰ l)) 🝖-end\n\npermutation-length : AllElements(p ↦ length p ≡ length l) (permutations l)\npermutation-length{l = l} = AllElements-fn (Function.congruence ⦃ _ ⦄ Proofs.permutes-length-function) (permutations-contains-permutations{l = l})\n\n{-permutations-length : length(permutations l) ≡ length(l) !\npermutations-length {l = ∅} = [≡]-intro\npermutations-length {l = x ⊰ ∅} = [≡]-intro\npermutations-length {l = x ⊰ y ⊰ l} =\n length(permutations(x ⊰ y ⊰ l)) 🝖[ _≡_ ]-[]\n length(concatMap(insertedEverywhere x) (permutations(y ⊰ l))) 🝖[ _≡_ ]-[ length-concatMap{l = permutations(y ⊰ l)}{f = insertedEverywhere x} ]\n foldᵣ (_+_ ∘ length ∘ insertedEverywhere x) 𝟎 (permutations (y ⊰ l)) 🝖[ _≡_ ]-[ {!!} ]\n foldᵣ (_+_ ∘ length) 𝟎 (map (insertedEverywhere x) (permutations (y ⊰ l))) 🝖[ _≡_ ]-[ {!!} ]\n 𝐒(𝐒(length l)) ⋅ (𝐒(length l) ⋅ (length(l)!)) 🝖[ _≡_ ]-[]\n length(x ⊰ y ⊰ l)! 🝖-end\n-}\n{-permutations-length {l = x ⊰ y ⊰ l} with permutations(y ⊰ l) | permutations-length {l = y ⊰ l}\n... | ∅ | p = {!!}\n... | z ⊰ pyl | p =\n length(foldᵣ((_++_) ∘ insertedEverywhere x) ∅ (z ⊰ pyl)) 🝖[ _≡_ ]-[]\n length(insertedEverywhere x z ++ foldᵣ((_++_) ∘ insertedEverywhere x) ∅ pyl) 🝖[ _≡_ ]-[ length-[++] {l₁ = insertedEverywhere x z}{l₂ = foldᵣ((_++_) ∘ insertedEverywhere x) ∅ pyl} ]\n length(insertedEverywhere x z) + length(foldᵣ((_++_) ∘ insertedEverywhere x) ∅ pyl) 🝖[ _≡_ ]-[ congruence₂ₗ(_+_)(length(foldᵣ((_++_) ∘ insertedEverywhere x) ∅ pyl)) (insertedEverywhere-length {x = x}{l = z}) ]\n 𝐒(length z) + length(foldᵣ((_++_) ∘ insertedEverywhere x) ∅ pyl) 🝖[ _≡_ ]-[ {!!} ]\n 𝐒(𝐒(length l)) ⋅ 𝐒(length pyl) 🝖[ _≡_ ]-[ congruence₂ᵣ(_⋅_)(𝐒(𝐒(length l))) p ]\n 𝐒(𝐒(length l)) ⋅ (𝐒(length l) ⋅ (length(l) !)) 🝖-end-}\n{- TODO: Proof of above\nlength(concatMap (insertedEverywhere x) (permutations(y ⊰ l)))\nfoldᵣ((_+_) ∘ length ∘ (insertedEverywhere x)) (permutations(y ⊰ l))\nfoldᵣ((_+_) ∘ 𝐒 ∘ length) (permutations(y ⊰ l))\nfoldᵣ((_+_) ∘ 𝐒) (map length(permutations(y ⊰ l)))\nfoldᵣ((_+_) ∘ 𝐒) (map (const(length(y ⊰ l))) (permutations(y ⊰ l))) -- from permutation-length when map function yields the same value for every element in the list\nfoldᵣ((_+_) ∘ 𝐒 ∘ const(length(y ⊰ l))) (permutations(y ⊰ l))\nfoldᵣ((_+_) ∘ const(𝐒 ∘ length(y ⊰ l))) (permutations(y ⊰ l))\n𝐒(length(y ⊰ l)) ⋅ length(permutations(y ⊰ l))\n𝐒(length(y ⊰ l)) ⋅ (length(y ⊰ l) !)\n-}\n\n{- length(permutations (x ⊰ y ⊰ l)) 🝖[ _≡_ ]-[ {!!} ]\n -- length(concatMap (insertedEverywhere x) (permutations(y ⊰ l))) 🝖[ _≡_ ]-[ length-concatMap {l = permutations(y ⊰ l)}{f = insertedEverywhere x} ]\n -- foldᵣ (_+_ ∘ length ∘ insertedEverywhere x) 𝟎 (permutations(y ⊰ l)) 🝖[ _≡_ ]-[ {!length-foldᵣ {l = permutations(y ⊰ l)}{init = 𝟎}!} ]\n 𝐒(𝐒(length l)) ⋅ (𝐒(length l) ⋅ (length(l) !)) 🝖[ _≡_ ]-[]\n (length(x ⊰ y ⊰ l) !) 🝖-end\n-}\n", "meta": {"hexsha": "afa7e8621adac1f01652fd5118b3307b5e8c4dc1", "size": 15311, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/List/Combinatorics/Proofs.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/List/Combinatorics/Proofs.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/List/Combinatorics/Proofs.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 69.9132420091, "max_line_length": 305, "alphanum_fraction": 0.5663248645, "num_tokens": 6159, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.831143031127974, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.6024708834561406}} {"text": "module Examples where\n\nopen import Data.List using ([]; _∷_)\nopen import Data.Fin using () renaming (zero to fzero)\n\nopen import Relation.Binary using (Rel)\n\nopen import Level using () renaming (zero to lzero)\n\nopen import Syntax\nopen import Theory\n\nmodule NatBool where\n data Gr : Set where\n nat : Gr\n bool : Gr\n\n data Func : Set where\n zero plus true false not : Func\n\n open PType Gr\n\n sorting : Func -> Sorting\n sorting zero = record { dom = Unit ; cod = ⌊ nat ⌋ }\n sorting plus = record { dom = ⌊ nat ⌋ * ⌊ nat ⌋ ; cod = ⌊ nat ⌋ }\n sorting true = record { dom = Unit ; cod = ⌊ bool ⌋ }\n sorting false = record { dom = Unit ; cod = ⌊ bool ⌋ }\n sorting not = record { dom = ⌊ bool ⌋ ; cod = ⌊ bool ⌋ }\n\n Sg : Signature lzero lzero\n Sg = record { Gr = Gr ; Func = Func ; sorting = sorting }\n\n open Term Sg\n\n data Ax : forall Γ A -> Rel (Γ ⊢ A) lzero where\n not-true≡false : Ax [] ⌊ bool ⌋ (func not (func true unit)) (func false unit)\n not-false≡true : Ax [] ⌊ bool ⌋ (func not (func false unit)) (func true unit)\n plus-identityˡ : Ax (⌊ nat ⌋ ∷ []) ⌊ nat ⌋\n (func plus (pair (func zero unit) var))\n var\n\n Th : Theory lzero lzero lzero\n Th = record { Sg = Sg ; Ax = Ax }\n\n open Theory.Theory Th\n\n import Relation.Binary.Reasoning.Setoid as S\n\n thm1 : forall {Γ} -> Γ ⊢ func not (func true unit) ≡ func false unit\n thm1 =\n begin\n func not (func true unit)\n ≈˘⟨ cong/func (cong/func (comm/unit _ _ _)) ⟩\n func not (func true (unit [ ! ]))\n ≈˘⟨ cong/func (comm/func _ _ _ _ _) ⟩\n func not (func true unit [ ! ])\n ≈˘⟨ comm/func _ _ _ _ _ ⟩\n func not (func true unit) [ ! ]\n ≈⟨ cong/sub refl (ax not-true≡false) ⟩\n func false unit [ ! ]\n ≈⟨ comm/func _ _ _ _ _ ⟩\n func false (unit [ ! ])\n ≈⟨ cong/func (comm/unit _ _ _) ⟩\n func false unit\n ∎\n where open S TermSetoid\n", "meta": {"hexsha": "b536a8ec7a383b35edaafd7532ad75648bc6435a", "size": 1872, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Examples.agda", "max_stars_repo_name": "elpinal/exsub-ccc", "max_stars_repo_head_hexsha": "7541ab22debdfe9d529ac7a210e5bd102c788ad9", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2022-02-05T06:16:32.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T13:30:48.000Z", "max_issues_repo_path": "Examples.agda", "max_issues_repo_name": "elpinal/exsub-ccc", "max_issues_repo_head_hexsha": "7541ab22debdfe9d529ac7a210e5bd102c788ad9", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Examples.agda", "max_forks_repo_name": "elpinal/exsub-ccc", "max_forks_repo_head_hexsha": "7541ab22debdfe9d529ac7a210e5bd102c788ad9", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.9402985075, "max_line_length": 81, "alphanum_fraction": 0.5881410256, "num_tokens": 656, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382236515259, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.6024344063998694}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Cubical.Foundations.FunExtEquiv where\n\nopen import Cubical.Core.Everything\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Univalence\n\n-- Function extensionality is an equivalence.\nmodule _ {ℓ ℓ'} {A : Type ℓ} {B : A → Type ℓ'} {f g : (x : A) → B x} where\n private\n appl : f ≡ g → ∀ x → f x ≡ g x\n appl eq x i = eq i x\n\n fib : (p : f ≡ g) → fiber (funExt {B = B}) p\n fib p = (appl p , refl)\n\n funExt-fiber-isContr\n : (p : f ≡ g)\n → (fi : fiber (funExt {B = B}) p)\n → fib p ≡ fi\n funExt-fiber-isContr p (h , eq) i = (appl (eq (~ i)) , λ j → eq (~ i ∨ j))\n\n funExt-isEquiv : isEquiv (funExt {B = B})\n equiv-proof funExt-isEquiv p = (fib p , funExt-fiber-isContr p)\n\n funExtEquiv : (∀ x → f x ≡ g x) ≃ (f ≡ g)\n funExtEquiv = (funExt {B = B} , funExt-isEquiv)\n\n funExtPath : (∀ x → f x ≡ g x) ≡ (f ≡ g)\n funExtPath = ua funExtEquiv\n", "meta": {"hexsha": "09312da1b72274dbbc6f32e266fbe540f2643a6b", "size": 972, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Foundations/FunExtEquiv.agda", "max_stars_repo_name": "cj-xu/cubical", "max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Foundations/FunExtEquiv.agda", "max_issues_repo_name": "cj-xu/cubical", "max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Foundations/FunExtEquiv.agda", "max_forks_repo_name": "cj-xu/cubical", "max_forks_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.5882352941, "max_line_length": 78, "alphanum_fraction": 0.5884773663, "num_tokens": 368, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382129861583, "lm_q2_score": 0.6992544210587586, "lm_q1q2_score": 0.6024344043416335}} {"text": "-- Ordinals as defined in the HoTT book.\n\n{-# OPTIONS --without-K --safe #-}\nmodule Ordinal.HoTT where\n\nopen import Data.Empty using (⊥)\nopen import Data.Unit using (⊤)\nopen import Induction.WellFounded using (Acc ; acc ; WellFounded)\nopen import Level using (Level ; _⊔_ ; 0ℓ) renaming (suc to lsuc)\nopen import Relation.Binary using (Rel ; IsEquivalence ; Transitive)\n\n\nprivate\n variable\n α β γ ρ ε : Level\n A B C : Set α\n\n\nrecord _↔_ (A : Set α) (B : Set β) : Set (α ⊔ β) where\n field\n forth : A → B\n back : B → A\n\nopen _↔_ public\n\n\nIsExtensional : ∀ {α} {A : Set α} (_≈_ : Rel A ε) (_<_ : Rel A ρ) → Set (α ⊔ ε ⊔ ρ)\nIsExtensional _≈_ _<_ = ∀ {a b} → (∀ c → (c < a) ↔ (c < b)) → a ≈ b\n\n\nrecord IsOrdinal (A : Set α) ε ρ : Set (α ⊔ lsuc (ε ⊔ ρ)) where\n field\n _≈_ : Rel A ε\n ≈-equiv : IsEquivalence _≈_\n _<_ : Rel A ρ\n <-wf : WellFounded _<_\n <-ext : IsExtensional _≈_ _<_\n <-trans : Transitive _<_\n\n open IsEquivalence ≈-equiv public using () renaming\n ( refl to ≈-refl\n ; sym to ≈-sym\n ; trans to ≈-trans)\n\nopen IsOrdinal public\n\n\nrecord Ordinal α ε ρ : Set (lsuc (α ⊔ ε ⊔ ρ)) where\n field\n _↓ : Set α\n isOrdinal : IsOrdinal _↓ ε ρ\n\nopen Ordinal public\n\n\nzero : Ordinal 0ℓ 0ℓ 0ℓ\nzero = record\n { _↓ = ⊤\n ; isOrdinal = record\n { _≈_ = λ _ _ → ⊤\n ; ≈-equiv = _\n ; _<_ = λ _ _ → ⊥\n ; <-wf = λ _ → acc λ y ()\n ; <-ext = _\n ; <-trans = λ()\n }\n }\n", "meta": {"hexsha": "86025d0dccc730b841a70e564bd012ec173515d7", "size": 1419, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Ordinal/HoTT.agda", "max_stars_repo_name": "JLimperg/msc-thesis-code", "max_stars_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2021-04-13T21:31:17.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-26T06:37:31.000Z", "max_issues_repo_path": "src/Ordinal/HoTT.agda", "max_issues_repo_name": "JLimperg/msc-thesis-code", "max_issues_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Ordinal/HoTT.agda", "max_forks_repo_name": "JLimperg/msc-thesis-code", "max_forks_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.8676470588, "max_line_length": 83, "alphanum_fraction": 0.5644820296, "num_tokens": 551, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382200964034, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.6024344039139342}} {"text": "module Dave.Algebra.Naturals.Definition where\n open import Dave.Equality public\n open import Dave.Structures.Monoid public\n \n data ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n one = suc zero\n two = suc one\n three = suc two\n four = suc three\n five = suc four\n six = suc five\n seven = suc six\n eight = suc seven\n nine = suc eight\n\n {-# BUILTIN NATURAL ℕ #-} \n\n ℕ-suc-≡ : ∀ {m n : ℕ} → m ≡ n → suc m ≡ suc n\n ℕ-suc-≡ refl = refl", "meta": {"hexsha": "45ad5374d50f4eb222fa055e7e5db9d97f008217", "size": 442, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Dave/Algebra/Naturals/Definition.agda", "max_stars_repo_name": "DavidStahl97/formal-proofs", "max_stars_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Dave/Algebra/Naturals/Definition.agda", "max_issues_repo_name": "DavidStahl97/formal-proofs", "max_issues_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Dave/Algebra/Naturals/Definition.agda", "max_forks_repo_name": "DavidStahl97/formal-proofs", "max_forks_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.0909090909, "max_line_length": 47, "alphanum_fraction": 0.6108597285, "num_tokens": 152, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8615382165412808, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.6024344014279991}} {"text": "module Functor where\n\nopen import Level\nimport Data.Nat as N\n\nopen import Basic\nopen import Category\nopen Category.Category\n\nrecord Functor {c₀ c₁ ℓ c₀′ c₁′ ℓ′} (C : Category c₀ c₁ ℓ) (D : Category c₀′ c₁′ ℓ′) : Set (suc (c₀ ⊔ c₀′ ⊔ c₁ ⊔ c₁′ ⊔ ℓ ⊔ ℓ′)) where\n field\n fobj : Obj C → Obj D\n fmapsetoid : {A B : Obj C} → Map.Map (Homsetoid C A B) (Homsetoid D (fobj A) (fobj B))\n\n fmap : {A B : Obj C} → Hom C A B → Hom D (fobj A) (fobj B)\n fmap {A} {B} = Map.Map.mapping (fmapsetoid {A} {B})\n\n field\n preserveId : {A : Obj C} → D [ fmap (id C {A}) ≈ id D {fobj A} ]\n preserveComp : {a b c : Obj C} {f : Hom C b c} {g : Hom C a b} → D [ fmap (C [ f ∘ g ]) ≈ (D [ fmap f ∘ fmap g ]) ]\n\nopen Functor\n\npreserveEq : ∀ {c₀ c₁ ℓ c₀′ c₁′ ℓ′} {C : Category c₀ c₁ ℓ} {D : Category c₀′ c₁′ ℓ′} {A B : Obj C} {x y : Hom C A B} (F : Functor C D) → C [ x ≈ y ] → D [ fmap F x ≈ fmap F y ]\npreserveEq F xy = Map.Map.preserveEq (fmapsetoid F) xy\n\ncompose : ∀ {c₀ c₁ ℓ c₀′ c₁′ ℓ′ c₀″ c₁″ ℓ″} {C : Category c₀ c₁ ℓ} {D : Category c₀′ c₁′ ℓ′} {E : Category c₀″ c₁″ ℓ″} → Functor {c₀′} {c₁′} {ℓ′} {c₀″} {c₁″} {ℓ″} D E → Functor {c₀} {c₁} {ℓ} {c₀′} {c₁′} {ℓ′} C D → Functor {c₀} {c₁} {ℓ} {c₀″} {c₁″} {ℓ″} C E\ncompose {C = C} {D} {E} G F = record {\n fobj = λ x → fobj G (fobj F x);\n fmapsetoid = record { mapping = λ f → fmap G (fmap F f) ; preserveEq = λ {x} {y} x≈y → begin⟨ E ⟩\n fmap G (fmap F x) ≈⟨ preserveEq G (begin⟨ D ⟩\n fmap F x ≈⟨ preserveEq F x≈y ⟩\n fmap F y ∎) ⟩\n fmap G (fmap F y) ∎\n };\n preserveId = begin⟨ E ⟩\n fmap G (fmap F (id C)) ≈⟨ preserveEq G (preserveId F) ⟩\n fmap G (id D) ≈⟨ preserveId G ⟩\n (id E) ∎;\n preserveComp = λ {_} {_} {_} {f} {g} → begin⟨ E ⟩\n fmap G (fmap F (C [ f ∘ g ])) ≈⟨ preserveEq G (preserveComp F) ⟩\n fmap G (D [ fmap F f ∘ fmap F g ]) ≈⟨ preserveComp G ⟩\n (E [ fmap G (fmap F f) ∘ fmap G (fmap F g) ]) ∎\n }\n\nidentity : ∀ {c₀ c₁ ℓ} (C : Category c₀ c₁ ℓ) → Functor {c₀} {c₁} {ℓ} {c₀} {c₁} {ℓ} C C\nidentity C = record {\n fobj = λ x → x ;\n fmapsetoid = record { mapping = λ x → x ; preserveEq = λ x₁ → x₁ } ;\n preserveId = refl-hom C ; preserveComp = refl-hom C }\n\nexp : ∀ {c₀ c₁ ℓ} {C : Category c₀ c₁ ℓ} → Functor C C → N.ℕ → Functor C C\nexp {C = C} F N.zero = identity C\nexp F (N.suc N.zero) = F\nexp F (N.suc n) = compose F (exp F n)\n\ndata _[_~_]\n {C₀ C₁ ℓ : Level} (C : Category C₀ C₁ ℓ) {A B : Obj C} (f : Hom C A B)\n : ∀{X Y : Obj C} → Hom C X Y → Set (suc (C₀ ⊔ C₁ ⊔ ℓ)) where\n eqArrow : {g : Hom C A B} → C [ f ≈ g ] → C [ f ~ g ]\n\neqArrowRefl : ∀ {c₀ c₁ ℓ} (C : Category c₀ c₁ ℓ) {A B : Obj C} {f : Hom C A B} → C [ f ~ f ]\neqArrowRefl C = eqArrow (refl-hom C)\n\neqArrowSym : ∀ {c₀ c₁ ℓ} (C : Category c₀ c₁ ℓ) {X Y Z W : Obj C} {f : Hom C X Y} {g : Hom C Z W} → C [ f ~ g ] → C [ g ~ f ]\neqArrowSym C (eqArrow f~g) = eqArrow (sym-hom C f~g)\n\neqArrowTrans : ∀ {c₀ c₁ ℓ} (C : Category c₀ c₁ ℓ) {X Y Z W S T : Obj C} {f : Hom C X Y} {g : Hom C Z W} {h : Hom C S T} → C [ f ~ g ] → C [ g ~ h ] → C [ f ~ h ]\neqArrowTrans C (eqArrow f~g) (eqArrow g~h) = eqArrow (trans-hom C f~g g~h)\n\neqArrowFmap : ∀ {c₀ c₁ ℓ c₀′ c₁′ ℓ′} {C : Category c₀ c₁ ℓ} {D : Category c₀′ c₁′ ℓ′} {X Y Z W : Obj C} {x : Category.Hom C X Y} {y : Category.Hom C Z W} (F : Functor C D) → C [ x ~ y ] → D [ fmap F x ~ fmap F y ]\neqArrowFmap F (eqArrow x~y) = eqArrow (preserveEq F x~y)\n\nequality : ∀ {c₀ c₁ ℓ} {C D : Category c₀ c₁ ℓ} → (F G : Functor C D) → _\nequality {C = C} {D} F G = ∀ {A B : Obj C} (f : Hom C A B) → D [ fmap F f ~ fmap G f ]\n\nCat : ∀ {c₀ c₁ ℓ} → Category (suc (c₀ ⊔ c₁ ⊔ ℓ)) _ _\nCat {c₀} {c₁} {ℓ} = record {\n Obj = Category c₀ c₁ ℓ;\n Homsetoid = λ A B → record {\n Carrier = Functor A B ; _≈_ = equality ;\n isEquivalence = record {\n refl = λ f → eqArrowRefl B ;\n sym = λ x f → eqArrowSym B (x f);\n trans = λ x x₁ f → eqArrowTrans B (x f) (x₁ f) } };\n comp = compose;\n id = λ {A} → identity A;\n leftId = λ {A} {B} {f} f₁ → eqArrow (refl-hom B);\n rightId = λ {A} {B} {f} f₁ → eqArrow (refl-hom B);\n assoc = λ {A} {B} {C} {D} {f} {g} {h} f₁ → eqArrow (begin⟨ D ⟩\n fmap (compose (compose h g) f) f₁ ≈⟨ refl-hom D ⟩\n fmap h (fmap g (fmap f f₁)) ≈⟨ refl-hom D ⟩\n fmap (compose h (compose g f)) f₁\n ∎);\n ≈-composite = λ {A} {B} {C} {f} {g} {h} {i} f~g h~i f₁ → eqArrowTrans C (f~g (fmap h f₁)) (eqArrowFmap g (h~i f₁))\n }\n\n", "meta": {"hexsha": "6f1f36cd84452d76867b7ee1f7cf5930bf28b137", "size": 4333, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Functor.agda", "max_stars_repo_name": "myuon/agda-cate", "max_stars_repo_head_hexsha": "59004994acdbc65fb4f8abf0baa1777a8dbe758e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2018-07-28T04:59:31.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-02T07:30:47.000Z", "max_issues_repo_path": "src/Functor.agda", "max_issues_repo_name": "myuon/agda-cate", "max_issues_repo_head_hexsha": "59004994acdbc65fb4f8abf0baa1777a8dbe758e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Functor.agda", "max_forks_repo_name": "myuon/agda-cate", "max_forks_repo_head_hexsha": "59004994acdbc65fb4f8abf0baa1777a8dbe758e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.2142857143, "max_line_length": 256, "alphanum_fraction": 0.5287329795, "num_tokens": 2008, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009503523291, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.6023868031247575}} {"text": "{-# OPTIONS --universe-polymorphism #-}\nmodule Categories.Groupoid where\n\nopen import Level\n\nopen import Categories.Category\nimport Categories.Morphisms\n\nrecord Groupoid {o ℓ e} (C : Category o ℓ e) : Set (o ⊔ ℓ ⊔ e) where\n private module C = Category C\n open C using (_⇒_) \n\n open Categories.Morphisms C\n\n field\n _⁻¹ : ∀ {A B} → (A ⇒ B) → (B ⇒ A)\n iso : ∀ {A B} {f : A ⇒ B} → Iso f (f ⁻¹)\n\n", "meta": {"hexsha": "52e1906671f277b53692999778a9726c57c661cb", "size": 402, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Groupoid.agda", "max_stars_repo_name": "p-pavel/categories", "max_stars_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-12-29T21:51:57.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-29T21:51:57.000Z", "max_issues_repo_path": "Categories/Groupoid.agda", "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Categories/Groupoid.agda", "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.1578947368, "max_line_length": 68, "alphanum_fraction": 0.6218905473, "num_tokens": 139, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9005297861178929, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.6023465978103849}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import HoTT\nopen import cohomology.Exactness\nopen import cohomology.Theory\n\n{- Cohomology functor sends constant functions to constant functions -}\n\nmodule cohomology.ConstantFunction {i} (CT : CohomologyTheory i) where\n\nopen import cohomology.Unit CT\nopen CohomologyTheory CT\n\nmodule _ (n : ℤ) {X Y : Ptd i} where\n\n CF-cst : CF-hom n (⊙cst {X = X} {Y = Y}) == cst-hom\n CF-cst =\n CF-hom n (⊙cst {X = PLU} ⊙∘ ⊙cst {X = X})\n =⟨ CF-comp n ⊙cst ⊙cst ⟩\n (CF-hom n (⊙cst {X = X})) ∘ᴳ (CF-hom n (⊙cst {X = PLU}))\n =⟨ hom= (CF-hom n (⊙cst {X = PLU})) cst-hom\n (λ= (λ _ → prop-has-all-paths (C-Unit-is-prop n) _ _))\n |in-ctx (λ w → CF-hom n (⊙cst {X = X} {Y = PLU}) ∘ᴳ w) ⟩\n (CF-hom n (⊙cst {X = X} {Y = PLU})) ∘ᴳ cst-hom\n =⟨ pre∘-cst-hom (CF-hom n (⊙cst {X = X} {Y = PLU})) ⟩\n cst-hom ∎\n where\n PLU = ⊙Lift {j = i} ⊙Unit\n\n", "meta": {"hexsha": "0a9991ce8301f17af74d15976e385bc594786208", "size": 904, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "cohomology/ConstantFunction.agda", "max_stars_repo_name": "danbornside/HoTT-Agda", "max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "cohomology/ConstantFunction.agda", "max_issues_repo_name": "danbornside/HoTT-Agda", "max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cohomology/ConstantFunction.agda", "max_forks_repo_name": "danbornside/HoTT-Agda", "max_forks_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.1333333333, "max_line_length": 71, "alphanum_fraction": 0.5530973451, "num_tokens": 403, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278664544911, "lm_q2_score": 0.6825737214979746, "lm_q1q2_score": 0.6023220727593597}} {"text": "-- Functors from one category into another\n\nmodule Control.Category.Functor where\n\nopen import Level using (suc; _⊔_)\nopen import Relation.Binary.PropositionalEquality\n\nopen import Control.Category\nopen Category using () renaming (Obj to obj; Hom to hom)\n\n\n-- Operations of a functor.\n\n-- Module T-FunctorOps C D F provides notation A ⇒ A' for homset C(A,A')\n-- and notation B ⇉ B' for homset D(B,B') and the type T-map for the\n-- functorial action.\n\nmodule T-FunctorOps\n {co ch ce} (C : Category co ch ce)\n {δo dh de} (D : Category δo dh de)\n (F : obj C → obj D)\n where\n open HomSet (hom C) using (_⇒_)\n open HomSet (hom D) using () renaming (_⇒_ to _⇉_)\n\n -- Type of the map function.\n T-map = ∀ {A B} → (A ⇒ B) → F A ⇉ F B\n\n-- Record FunctorOps C D F can be instantiated to define the functorial action\n-- map of F.\n\nrecord FunctorOps\n {co ch ce} (C : Category co ch ce)\n {δo dh de} (D : Category δo dh de) (F : obj C → obj D) : Set (co ⊔ ch ⊔ ce ⊔ δo ⊔ dh ⊔ de)\n where\n open T-FunctorOps C D F\n\n -- The functorial action (map function).\n field\n map : T-map\n\n\n-- Laws of a functor.\n\n-- Module T-FunctorLaws ops provides notation...\n\nmodule T-FunctorLaws\n {co ch ce} {C : Category co ch ce}\n {δo dh de} {D : Category δo dh de} {F : obj C → obj D}\n (ops : FunctorOps C D F) where\n\n open FunctorOps ops public\n\n open Category C using (_⇒_) renaming\n (Obj to ObjC; id to idC; _∘_ to _∘C_)\n\n open Category D using (_≈_) renaming\n (Obj to ObjD; _⇒_ to _⇉_; id to idD; _∘_ to _∘D_)\n\n -- First functor law: identity\n T-map-id = ∀ {A} →\n\n map (idC {A = A}) ≈ idD\n\n -- Second functor law: composition.\n T-map-∘ = ∀ {A B C} (f : A ⇒ B) {g : B ⇒ C} →\n\n map (g ∘C f) ≈ (map g ∘D map f)\n\n\nrecord FunctorLaws\n {co ch ce} {C : Category co ch ce}\n {δo dh de} {D : Category δo dh de} {F : obj C → obj D}\n (ops : FunctorOps C D F) : Set ((co ⊔ ch ⊔ ce ⊔ δo ⊔ dh ⊔ de)) where\n open T-FunctorLaws ops\n\n field\n map-id : T-map-id\n map-∘ : T-map-∘\n\n\n-- Functoriality.\n\nrecord IsFunctor\n {co ch ce} {C : Category co ch ce}\n {δo dh de} {D : Category δo dh de} (F : obj C → obj D) : Set (co ⊔ ch ⊔ ce ⊔ δo ⊔ dh ⊔ de) where\n\n field\n ops : FunctorOps C D F\n laws : FunctorLaws ops\n\n open FunctorOps ops public\n open FunctorLaws laws public\n\n-- -}\n", "meta": {"hexsha": "2ad16cb55709b1ae46808915966facb1d3928b14", "size": 2304, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Control/Category/Functor.agda", "max_stars_repo_name": "andreasabel/cubical", "max_stars_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Control/Category/Functor.agda", "max_issues_repo_name": "andreasabel/cubical", "max_issues_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Control/Category/Functor.agda", "max_forks_repo_name": "andreasabel/cubical", "max_forks_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.0, "max_line_length": 98, "alphanum_fraction": 0.6115451389, "num_tokens": 832, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256631249076, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.6022622847736954}} {"text": "------------------------------------------------------------------------------\n-- Quicksort using the Bove-Capretta method\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOT.FOTC.Program.QuickSort.QuickSortBC where\n\nopen import Data.List.Base\nopen import Data.Nat.Base\nopen import Data.Nat.Properties\n\nopen import Induction\nopen import Induction.Nat\nopen import Induction.WellFounded\n\nopen import Level\n\nopen import Relation.Unary\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary\n\nmodule InvImg =\n Induction.WellFounded.Inverse-image {A = List ℕ} {ℕ} {_<′_} length\n\n------------------------------------------------------------------------------\n\n-- Non-terminating quicksort.\n\n{-# TERMINATING #-}\nqsNT : List ℕ → List ℕ\nqsNT [] = []\nqsNT (x ∷ xs) = qsNT (filter (λ y → y ≤′? x) xs) ++\n x ∷ qsNT (filter (λ y → x ≤′? y) xs)\n\n-- Domain predicate for quicksort.\ndata QSDom : List ℕ → Set where\n qsDom-[] : QSDom []\n qsDom-∷ : ∀ {x xs} →\n (QSDom (filter (λ y → y ≤′? x) xs)) →\n (QSDom (filter (λ y → x ≤′? y) xs)) →\n QSDom (x ∷ xs)\n\n-- Induction principle associated to the domain predicate of quicksort.\n-- (It was not necessary).\nQSDom-ind : (P : List ℕ → Set) →\n P [] →\n (∀ {x xs} → QSDom (filter (λ y → y ≤′? x) xs) →\n P (filter (λ y → y ≤′? x) xs) →\n QSDom (filter (λ y → x ≤′? y) xs) →\n P (filter (λ y → x ≤′? y) xs) →\n P (x ∷ xs)) →\n (∀ {xs} → QSDom xs → P xs)\nQSDom-ind P P[] ih qsDom-[] = P[]\nQSDom-ind P P[] ih (qsDom-∷ h₁ h₂) =\n ih h₁ (QSDom-ind P P[] ih h₁) h₂ (QSDom-ind P P[] ih h₂)\n\n-- Well-founded relation on lists.\n_⟪′_ : {A : Set} → List A → List A → Set\nxs ⟪′ ys = length xs <′ length ys\n\nwf-⟪′ : WellFounded _⟪′_\nwf-⟪′ = InvImg.well-founded <′-wellFounded\n\n-- The well-founded induction principle on _⟪′_.\n-- postulate wfi-⟪′ : (P : List ℕ → Set) →\n-- (∀ xs → (∀ ys → ys ⟪′ xs → P ys) → P xs) →\n-- ∀ xs → P xs\n\n-- The quicksort algorithm is total.\n\nfilter-length : {A : Set} {P : Pred A Level.zero} →\n (P? : Relation.Unary.Decidable P ) → ∀ xs → length (filter P? xs) ≤′ length xs\nfilter-length P? [] = ≤′-refl\nfilter-length P? (x ∷ xs) with P? x\n... | yes _ = ≤⇒≤′ (s≤s (≤′⇒≤ (filter-length P? xs)))\n... | no _ = ≤′-step (filter-length P? xs)\n\nmodule AllWF = Induction.WellFounded.All wf-⟪′\n\nallQSDom : ∀ xs → QSDom xs\n-- If we use wfi-⟪′ then allQSDom = wfi-⟪′ P ih\nallQSDom = build (AllWF.wfRec-builder _) P ih\n where\n P : List ℕ → Set\n P = QSDom\n\n -- If we use wfi-⟪′ then\n -- ih : ∀ zs → (∀ ys → ys ⟪′ zs → P ys) → P zs\n ih : ∀ zs → WfRec _⟪′_ P zs → P zs\n ih [] h = qsDom-[]\n ih (z ∷ zs) h = qsDom-∷ prf₁ prf₂\n where\n c₁ : (y : ℕ) → Dec (y ≤′ z)\n c₁ y = y ≤′? z\n\n c₂ : (y : ℕ) → Dec (z ≤′ y)\n c₂ y = z ≤′? y\n\n f₁ : List ℕ\n f₁ = filter c₁ zs\n\n f₂ : List ℕ\n f₂ = filter c₂ zs\n\n prf₁ : QSDom (filter (λ y → y ≤′? z) zs)\n prf₁ = h f₁ (≤⇒≤′ (s≤s (≤′⇒≤ (filter-length c₁ zs))))\n\n prf₂ : QSDom (filter (λ y → z ≤′? y) zs)\n prf₂ = h f₂ (≤⇒≤′ (s≤s (≤′⇒≤ (filter-length c₂ zs))))\n\n-- Quicksort algorithm by structural recursion on the domain predicate.\nqsDom : ∀ xs → QSDom xs → List ℕ\nqsDom .[] qsDom-[] = []\nqsDom (x ∷ xs) (qsDom-∷ h₁ h₂) =\n qsDom (filter (λ y → y ≤′? x) xs) h₁ ++\n x ∷ qsDom (filter (λ y → x ≤′? y) xs) h₂\n\n-- The quicksort algorithm.\nqs : List ℕ → List ℕ\nqs xs = qsDom xs (allQSDom xs)\n\n-- Testing.\nl₁ : List ℕ\nl₁ = []\nl₂ = 1 ∷ 2 ∷ 3 ∷ 4 ∷ 5 ∷ []\nl₃ = 5 ∷ 4 ∷ 3 ∷ 2 ∷ 1 ∷ []\nl₄ = 4 ∷ 1 ∷ 3 ∷ 5 ∷ 2 ∷ []\n\nt₁ : qs l₁ ≡ l₁\nt₁ = refl\n\nt₂ : qs l₂ ≡ l₂\nt₂ = refl\n\nt₃ : qs l₃ ≡ l₂\nt₃ = refl\n\nt₄ : qs l₄ ≡ l₂\nt₄ = refl\n", "meta": {"hexsha": "e1e494978feb99822c240a4a6338f96181049c6e", "size": 4033, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/FOTC/Program/QuickSort/QuickSortBC.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/FOT/FOTC/Program/QuickSort/QuickSortBC.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/FOT/FOTC/Program/QuickSort/QuickSortBC.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 27.8137931034, "max_line_length": 94, "alphanum_fraction": 0.4904537565, "num_tokens": 1494, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256591565729, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.6022622819346536}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nmodule Algebra.Monoid where\n open import Basics\n\n open import lib.types.Paths\n\n record ∞-monoid i : Type (lsucc i) where\n field -- data\n el : Type i\n μ : el → End el\n\n μ' : el → End el\n μ' b a = μ a b\n\n field -- properties\n unit-l : hfiber μ (idf el) is-contractible\n unit-r : hfiber μ' (idf el) is-contractible\n mult : ∀ a b → hfiber μ ((μ a) ∘ (μ b)) is-contractible\n \n 1l : el\n 1l = fst $ contr-center unit-l\n\n 1l-def : μ 1l == idf el\n 1l-def = snd $ contr-center unit-l\n\n 1r : el\n 1r = fst $ contr-center unit-r\n\n 1r-def : μ' 1r == idf el\n 1r-def = snd $ contr-center unit-r\n\n infix 50 _·_\n _·_ : el → el → el\n a · b = fst $ contr-center (mult a b)\n\n ·-def : ∀ a b → μ (a · b) == (μ a) ∘ (μ b)\n ·-def a b = snd $ contr-center (mult a b) \n -- --------------------------------------------\n\n 1l=1r : 1l == 1r\n 1l=1r = 1l\n =⟨ ! (1r-def at 1l) ⟩\n μ 1l 1r\n =⟨ 1l-def at 1r ⟩\n 1r\n =∎\n\n μ=· : ∀ a b → (μ a b) == (a · b)\n μ=· a b = μ a b\n =⟨ ! $ ap (μ a) (1r-def at b) ⟩\n μ a (μ b 1r)\n =⟨ ! $ (·-def a b) at 1r ⟩\n μ (a · b) 1r\n =⟨ 1r-def at (a · b) ⟩\n a · b\n =∎\n\n m-assoc : ∀ a b c → (a · b) · c == a · (b · c)\n m-assoc a b c = ap fst (! (contr-path (mult a (b · c)) in-fib))\n where\n lem : μ((a · b) · c) == (μ a) ∘ μ(b · c)\n lem = μ((a · b) · c)\n =⟨ ·-def (a · b) c ⟩\n μ(a · b) ∘ (μ c)\n =⟨ ap (λ f → f ∘ (μ c)) (·-def a b) ⟩\n (μ a) ∘ (μ b) ∘ (μ c)\n =⟨ ! $ ap (λ f → (μ a) ∘ f) (·-def b c) ⟩\n (μ a) ∘ μ(b · c)\n =∎\n\n in-fib : hfiber μ ((μ a) ∘ μ(b · c))\n in-fib = ((a · b) · c) , lem \n\n penta : ∀ a b c d →\n (m-assoc (a · b) c d) ∙ (m-assoc a b (c · d))\n ==\n (ap (λ x → x · d) (m-assoc a b c)) ∙ (m-assoc a (b · c) d) ∙ (ap (λ x → a · x) (m-assoc b c d))\n penta a b c d = {!!}\n \n\n End-l : ∀ {i} (X : Type i) → ∞-monoid i\n End-l X = record { el = End X\n ; μ = λ f → λ g → f ∘ g\n ; unit-l = has-level-in $ (idf X , refl) , proof-unit-l\n ; unit-r = has-level-in $ (idf X , refl) , proof-unit-r\n ; mult = λ a b → has-level-in $ (a ∘ b , refl) , proof-mult a b}\n where\n proof-unit-l : ∀ y → (idf X , refl) == y\n proof-unit-l (f , p) = pair= (! p at idf X) $ ↓-app=cst-in $\n idp\n =⟨ ! (!-inv-l p) ⟩\n (! p) ∙ p\n =⟨ ap (λ α → α ∙ p) helper ⟩\n (ap (λ z g → z ∘ g) (! p at idf X)) ∙ p\n =∎\n where\n lemma : (k : End X → End X) (q : (idf (End X)) == k) (f : End X)\n (η : (k f) ∘_ == k ∘ (f ∘_))\n → (ap (λ u g → (u f) ∘ g) q) ∙' η == (ap (λ u g → u (f ∘ g)) q)\n lemma _ idp _ idp = idp \n \n helper : ! p == (ap (λ z g → z ∘ g) (! p at idf X))\n helper = ! p\n =⟨ other-lemma (! p) ⟩\n ap (λ u g → u g) (! p)\n =⟨ ! $ lemma (f ∘_) (! p) (idf X) refl ⟩\n ap (λ u g → (u (idf X)) ∘ g) (! p)\n =⟨ ap-∘ (λ z x x₁ → z (x x₁)) (λ z → z (λ x → x)) (! p) ⟩\n (ap (λ z g → z ∘ g) (! p at idf X))\n =∎\n where\n other-lemma : ∀ {i j} {X : Type i} {Y : Type j} {f g : X → Y}\n (p : f == g) → p == (ap (λ u g → u g) p)\n other-lemma refl = refl\n\n \n\n proof-unit-r : ∀ y → (idf X , refl) == y\n proof-unit-r (f , p) = pair= (! p at idf X) $ ↓-app=cst-in $\n idp\n =⟨ ! (!-inv-l p) ⟩\n (! p) ∙ p\n =⟨ ap (λ α → α ∙ p) helper ⟩\n (ap (λ z g → g ∘ z) (! p at idf X)) ∙ p\n =∎\n where\n lemma : (k : End X → End X) (q : (idf (End X)) == k) (f : End X)\n (η : _∘ (k f) == k ∘ (_∘ f))\n → (ap (λ u g → g ∘ (u f)) q) ∙' η == (ap (λ u g → u (g ∘ f)) q)\n lemma _ refl _ refl = refl\n\n helper : ! p == (ap (λ z g → g ∘ z) (! p at idf X))\n helper = ! p\n =⟨ other-lemma (! p) ⟩\n ap (λ u g → u g) (! p)\n =⟨ ! $ lemma (_∘ f) (! p) (idf X) refl ⟩\n ap (λ u g → g ∘ (u (idf X))) (! p)\n =⟨ ap-∘ (λ z x x₁ → x (z x₁)) (λ z → z (λ x → x)) (! p) ⟩\n ap (λ z g → g ∘ z) (! p at idf X)\n =∎\n where\n other-lemma : ∀ {i j} {X : Type i} {Y : Type j} {f g : X → Y}\n (p : f == g) → p == (ap (λ u g → u g) p)\n other-lemma refl = refl\n \n proof-mult : ∀ a b y → (a ∘ b , refl) == y\n proof-mult a b (f , p) = pair= (! p at idf X) $ ↓-app=cst-in $\n refl\n =⟨ ! (!-inv-l p) ⟩\n ! p ∙ p\n =⟨ ap (λ α → α ∙ p) helper ⟩\n (ap (λ z g → z ∘ g) (! p at idf X)) ∙ p\n =∎\n where\n lemma : (k : End X → End X) (q : (a ∘ b) ∘_ == k) (f : End X)\n (η : (k f) ∘_ == k ∘ (f ∘_))\n → (ap (λ u g → (u f) ∘ g) q) ∙' η == (ap (λ u g → u (f ∘ g)) q)\n lemma _ idp _ idp = idp \n \n helper : ! p == (ap (λ z g → z ∘ g) (! p at idf X))\n helper = ! p\n =⟨ other-lemma (! p) ⟩\n ap (λ u g → u g) (! p)\n =⟨ ! $ lemma (f ∘_) (! p) (idf X) refl ⟩\n ap (λ u g → (u (idf X)) ∘ g) (! p)\n =⟨ ap-∘ (λ z x x₁ → z (x x₁)) (λ z → z (λ x → x)) (! p) ⟩\n (ap (λ z g → z ∘ g) (! p at idf X))\n =∎\n where\n other-lemma : ∀ {i j} {X : Type i} {Y : Type j} {f g : X → Y}\n (p : f == g) → p == (ap (λ u g → u g) p)\n other-lemma refl = refl\n\n Aut-l : ∀ {i} {X : Type i} (x : X) → ∞-monoid i\n Aut-l {X = X} x = record { el = x == x\n ; μ = λ p → λ q → p ∙ q\n ; unit-l = has-level-in $ (refl , refl) , unit-l-proof\n ; unit-r = has-level-in $ (refl , (λ= ∙-unit-r)) , unit-r-proof\n ; mult = λ a b → has-level-in $ (a ∙ b , λ= (∙-assoc a b)) , mult-proof a b }\n where\n unit-l-proof : ∀ y → (refl , refl) == y\n unit-l-proof (p , α) = pair= (! (α at refl) ∙ (∙-unit-r p)) $ ↓-app=cst-in $\n idp\n =⟨ ! (!-inv-l α) ⟩\n ! α ∙ α\n =⟨ {!!} ⟩\n ap (λ z q → z ∙ q) (! (α at refl) ∙ (∙-unit-r p)) ∙ α\n =∎\n\n unit-r-proof : ∀ y → (refl , (λ= ∙-unit-r)) == y\n unit-r-proof (p , α) = {!!}\n\n mult-proof : ∀ a b y → (a ∙ b , λ= (∙-assoc a b)) == y\n mult-proof a b y = {!!}\n", "meta": {"hexsha": "a43076a7a05e1f7378f1fab088da4a32c457edde", "size": 7116, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "cohesion/david_jaz_261/Algebra/Monoid.agda", "max_stars_repo_name": "glangmead/formalization", "max_stars_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2021-10-06T17:39:22.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-13T05:51:12.000Z", "max_issues_repo_path": "cohesion/david_jaz_261/Algebra/Monoid.agda", "max_issues_repo_name": "glangmead/formalization", "max_issues_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cohesion/david_jaz_261/Algebra/Monoid.agda", "max_forks_repo_name": "glangmead/formalization", "max_forks_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.306122449, "max_line_length": 107, "alphanum_fraction": 0.3149241147, "num_tokens": 2681, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.841825635346563, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.6022622546847973}} {"text": "{-# OPTIONS --without-K --exact-split #-}\n\nmodule subrings where\n\nimport rings\nopen rings public\n\n--------------------------------------------------------------------------------\n\n{- Subrings -}\n\nsubset-Ring :\n (l : Level) {l1 : Level} → Ring l1 → UU ((lsuc l) ⊔ l1)\nsubset-Ring l R = type-Ring R → UU-Prop l\n\nis-additive-subset-Ring :\n {l l1 : Level} (R : Ring l1) (S : subset-Ring l R) → UU _\nis-additive-subset-Ring R S =\n (x y : type-Ring R) →\n type-Prop (S x) → type-Prop (S y) → type-Prop (S (add-Ring R x y))\n", "meta": {"hexsha": "d0daef1cf43cec50a44d4916e8163af0f444bb1a", "size": 520, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/subrings.agda", "max_stars_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_stars_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 333, "max_stars_repo_stars_event_min_datetime": "2018-09-26T08:33:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:50:15.000Z", "max_issues_repo_path": "Agda/subrings.agda", "max_issues_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_issues_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2019-06-18T04:16:04.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-16T15:27:01.000Z", "max_forks_repo_path": "Agda/subrings.agda", "max_forks_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_forks_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 30, "max_forks_repo_forks_event_min_datetime": "2018-09-26T09:08:57.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-16T00:33:50.000Z", "avg_line_length": 24.7619047619, "max_line_length": 80, "alphanum_fraction": 0.5134615385, "num_tokens": 168, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8652240895276223, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.6021599135824981}} {"text": "{-# OPTIONS --cubical --safe --prop #-}\n\nmodule Relation.Binary.Equivalence.PropTruncated where\n\nopen import Prelude\nopen import Relation.Nullary.Stable\n\ninfix 4 _≐_\ndata _≐_ {a} {A : Type a} (x y : A) : Prop a where\n ∣_∣ : x ≡ y → x ≐ y\n\ndata ∙⊥ : Prop where\n\nprivate\n variable\n x y z : A\n\nrerel : ∙⊥ → ⊥\nrerel ()\n\n∙refute : x ≐ y → (x ≡ y → ⊥) → ∙⊥\n∙refute ∣ x≡y ∣ x≢y with x≢y x≡y\n∙refute ∣ x≡y ∣ x≢y | ()\n\nrefute : x ≐ y → ¬ (¬ (x ≡ y))\nrefute x≐y x≢y = rerel (∙refute x≐y x≢y)\n\nunsquash : Stable (x ≡ y) → x ≐ y → x ≡ y\nunsquash st x≐y = st (refute x≐y)\n\n∙refl : x ≐ x\n∙refl = ∣ refl ∣\n\n∙trans : x ≐ y → y ≐ z → x ≐ z\n∙trans ∣ xy ∣ (∣_∣ yz) = ∣_∣ (xy ; yz)\n\n∙sym : x ≐ y → y ≐ x\n∙sym (∣_∣ p) = ∣_∣ (sym p)\n\n∙cong : (f : A → B) → x ≐ y → f x ≐ f y\n∙cong f ∣ x≡y ∣ = ∣ cong f x≡y ∣\n\n\nmodule Reasoning where\n infixr 2 ≐˘⟨⟩-syntax ≐⟨∙⟩-syntax\n\n ≐˘⟨⟩-syntax : ∀ (x : A) {y z} → y ≐ z → y ≐ x → x ≐ z\n ≐˘⟨⟩-syntax _ y≡z y≡x = ∙trans (∙sym y≡x) y≡z\n\n syntax ≐˘⟨⟩-syntax x y≡z y≡x = x ≐˘⟨ y≡x ⟩ y≡z\n\n ≐⟨∙⟩-syntax : ∀ (x : A) {y z} → y ≐ z → x ≐ y → x ≐ z\n ≐⟨∙⟩-syntax _ y≡z x≡y = ∙trans x≡y y≡z\n\n syntax ≐⟨∙⟩-syntax x y≡z x≡y = x ≐⟨ x≡y ⟩ y≡z\n\n _≐⟨⟩_ : ∀ (x : A) {y} → x ≐ y → x ≐ y\n _ ≐⟨⟩ x≡y = x≡y\n\n infix 2.5 _∎\n _∎ : ∀ {A : Type a} (x : A) → x ≐ x\n _∎ x = ∙refl\n\n infixr 2 ≡˘⟨⟩-syntax ≡⟨∙⟩-syntax\n\n ≡˘⟨⟩-syntax : ∀ (x : A) {y z} → y ≐ z → y ≡ x → x ≐ z\n ≡˘⟨⟩-syntax _ y≡z y≡x = ∙trans (∣_∣ (sym y≡x)) y≡z\n\n syntax ≡˘⟨⟩-syntax x y≡z y≡x = x ≡˘⟨ y≡x ⟩ y≡z\n\n ≡⟨∙⟩-syntax : ∀ (x : A) {y z} → y ≐ z → x ≡ y → x ≐ z\n ≡⟨∙⟩-syntax _ y≡z x≡y = ∙trans ∣ x≡y ∣ y≡z\n\n syntax ≡⟨∙⟩-syntax x y≡z x≡y = x ≡⟨ x≡y ⟩ y≡z\n", "meta": {"hexsha": "7c5af67176f88afd8eb1909e2f79eb536e437592", "size": 1627, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Relation/Binary/Equivalence/PropTruncated.agda", "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_issues_repo_path": "Relation/Binary/Equivalence/PropTruncated.agda", "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Relation/Binary/Equivalence/PropTruncated.agda", "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "avg_line_length": 21.6933333333, "max_line_length": 55, "alphanum_fraction": 0.4517516902, "num_tokens": 1015, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8652240930029118, "lm_q2_score": 0.6959583124210896, "lm_q1q2_score": 0.6021598996323744}} {"text": "module ObsEq2 where\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\ndata Fin : Nat -> Set where\n fz : {n : Nat} -> Fin (suc n)\n fs : {n : Nat} -> Fin n -> Fin (suc n)\n\ninfixr 40 _::_ _,_\n\ndata List (X : Set) : Set where\n ε : List X\n _::_ : X -> List X -> List X\n\nrecord One : Set where\n\nΠ : (S : Set)(T : S -> Set) -> Set\nΠ S T = (x : S) -> T x\n\ndata Σ (S : Set)(T : S -> Set) : Set where\n _,_ : (s : S) -> T s -> Σ S T\n\nsplit : {S : Set}{T : S -> Set}{P : Σ S T -> Set}\n (p : (s : S)(t : T s) -> P (s , t)) ->\n (x : Σ S T) -> P x\nsplit p (s , t) = p s t\n\nfst : {S : Set}{T : S -> Set}(x : Σ S T) -> S\nfst = split \\s t -> s\n\nsnd : {S : Set}{T : S -> Set}(x : Σ S T) -> T (fst x)\nsnd = split \\s t -> t\n\nmutual\n\n data ∗ : Set where\n /Π/ : (S : ∗)(T : [ S ] -> ∗) -> ∗\n /Σ/ : (S : ∗)(T : [ S ] -> ∗) -> ∗\n /Fin/ : Nat -> ∗\n /D/ : (I : ∗)(A : [ I ] -> ∗)(R : (i : [ I ]) -> [ A i ] -> List [ I ])\n -> [ I ] -> ∗\n\n [_] : ∗ -> Set\n [ /Π/ S T ] = Π [ S ] \\s -> [ T s ]\n [ /Σ/ S T ] = Σ [ S ] \\s -> [ T s ]\n [ /Fin/ n ] = Fin n\n [ /D/ I A R i ] = Σ [ A i ] \\a -> [ Kids I (/D/ I A R) (R i a) ]\n\n Kids : (I : ∗)(P : [ I ] -> ∗) -> List [ I ] -> ∗\n Kids I P ε = /Fin/ (suc zero)\n Kids I P (i :: is) = /Σ/ (P i) \\_ -> Kids I P is\n\n/0/ : ∗\n/0/ = /Fin/ zero\n\n/1/ : ∗\n/1/ = /Fin/ (suc zero)\n\n/2/ : ∗\n/2/ = /Fin/ (suc (suc zero))\n\nBranches : {n : Nat}(P : Fin n -> Set) -> Set\nBranches {zero} P = One\nBranches {suc n} P = Σ (P fz) \\_ -> Branches {n} \\x -> P (fs x)\n\ncase : {n : Nat}{P : Fin n -> Set} -> Branches P -> (x : Fin n) -> P x\ncase pps fz = fst pps\ncase pps (fs x) = case (snd pps) x\n\n\ninfixr 40 _⟶_\n\ninfixr 60 _×_\n\n_⟶_ : ∗ -> ∗ -> ∗\nS ⟶ T = /Π/ S \\_ -> T\n\n_×_ : ∗ -> ∗ -> ∗\nS × T = /Σ/ S \\_ -> T\n\nNatR : [ /1/ ] -> [ /2/ ] -> List [ /1/ ]\nNatR _ fz = ε\nNatR _ (fs fz) = fz :: ε\nNatR _ (fs (fs ()))\n\n/Nat/ : ∗\n/Nat/ = /D/ /1/ (\\_ -> /2/) NatR fz\n\n/zero/ : [ /Nat/ ]\n/zero/ = fz , fz\n\n/suc/ : [ /Nat/ ⟶ /Nat/ ]\n/suc/ n = fs fz , n , fz\n\nHyps : (I : ∗)(K : [ I ] -> ∗)\n (P : (i : [ I ]) -> [ K i ] -> ∗)\n (is : List [ I ]) -> [ Kids I K is ] -> ∗\nHyps I K P ε _ = /1/\nHyps I K P (i :: is) (k , ks) = /Σ/ (P i k) \\_ -> Hyps I K P is ks\n\nrecs : (I : ∗)(K : [ I ] -> ∗)\n (P : (i : [ I ]) -> [ K i ] -> ∗)\n (e : (i : [ I ])(k : [ K i ]) -> [ P i k ])\n (is : List [ I ])(ks : [ Kids I K is ]) -> [ Hyps I K P is ks ]\nrecs I K P e ε _ = fz\nrecs I K P e (i :: is) (k , ks) = ( e i k , recs I K P e is ks )\n\nelim : (I : ∗)(A : [ I ] -> ∗)(R : (i : [ I ]) -> [ A i ] -> List [ I ])\n (P : (i : [ I ]) -> [ /D/ I A R i ] -> ∗) ->\n [( (/Π/ I \\i -> /Π/ (A i) \\a ->\n /Π/ (Kids I (/D/ I A R) (R i a)) \\ks ->\n Hyps I (/D/ I A R) P (R i a) ks ⟶ P i (a , ks)) ⟶\n /Π/ I \\i -> /Π/ (/D/ I A R i) \\x -> P i x )]\nelim I A R P p i (a , ks) =\n p i a ks (recs I (/D/ I A R) P (elim I A R P p) (R i a) ks)\n\nnatElim : (P : [ /Nat/ ] -> ∗) ->\n [( P /zero/ ⟶\n (/Π/ /Nat/ \\n -> P n ⟶ P (/suc/ n)) ⟶\n /Π/ /Nat/ P )]\nnatElim P pz ps = elim /1/ (\\_ -> /2/) NatR (case (P , _))\n (case ( case (case ((\\_ -> pz ) , _ )\n , (split \\n -> case (split (\\h _ -> ps n h) , _ )) , _ ) , _ ))\n fz\n\n\nplus : [ /Nat/ ⟶ /Nat/ ⟶ /Nat/ ]\nplus x y = natElim (\\_ -> /Nat/) y (\\_ -> /suc/) x\n\n{-\nelim /1/ (\\_ -> /2/) NatR (\\_ _ -> /Nat/)\n (\\_ -> case\n ((\\_ _ -> y )\n , split (\\_ _ -> split (\\n _ -> /suc/ n ) ) , _ ) )\n fz x\n-}\n\nmutual\n _⇔_ : ∗ -> ∗ -> ∗\n /Π/ S0 T0 ⇔ /Π/ S1 T1 =\n (S1 ⇔ S0) ×\n /Π/ S1 \\s1 -> /Π/ S0 \\s0 -> (S1 > s1 ≅ S0 > s0) ⟶ (T0 s0 ⇔ T1 s1)\n /Σ/ S0 T0 ⇔ /Σ/ S1 T1 =\n (S0 ⇔ S1) ×\n /Π/ S0 \\s0 -> /Π/ S1 \\s1 -> (S0 > s0 ≅ S1 > s1) ⟶ (T0 s0 ⇔ T1 s1)\n /Fin/ _ ⇔ /Π/ _ _ = /0/\n /Fin/ _ ⇔ /Σ/ _ _ = /0/\n /Fin/ _ ⇔ /D/ _ _ _ _ = /0/\n /Π/ _ _ ⇔ /Fin/ _ = /0/\n /Σ/ _ _ ⇔ /Fin/ _ = /0/\n /D/ _ _ _ _ ⇔ /Fin/ _ = /0/\n /Fin/ zero ⇔ /Fin/ zero = /1/\n /Fin/ (suc m) ⇔ /Fin/ (suc n) = /Fin/ m ⇔ /Fin/ n\n /D/ I0 A0 R0 i0 ⇔ /D/ I1 A1 R1 i1 =\n (I0 ⇔ I1) ×\n (/Π/ I0 \\i0 -> /Π/ I1 \\i1 -> (I0 > i0 ≅ I1 > i1) ⟶ (A0 i0 ⇔ A1 i1)) ×\n (/Π/ I0 \\i0 -> /Π/ I1 \\i1 -> (I0 > i0 ≅ I1 > i1) ⟶\n /Π/ (A0 i0) \\a0 -> /Π/ (A1 i1) \\a1 -> (A0 i0 > a0 ≅ A1 i1 > a1) ⟶\n Eqs I0 (R0 i0 a0) I1 (R1 i1 a1)) ×\n (I0 > i0 ≅ I1 > i1)\n _ ⇔ _ = /0/\n\n Eqs : (I0 : ∗) -> List [ I0 ] -> (I1 : ∗) -> List [ I1 ] -> ∗\n Eqs _ ε _ ε = /1/\n Eqs I0 (i0 :: is0) I1 (i1 :: is1) = (I0 > i0 ≅ I1 > i1) × Eqs I0 is0 I1 is1\n Eqs _ _ _ _ = /0/\n\n _>_≅_>_ : (S : ∗) -> [ S ] -> (T : ∗) -> [ T ] -> ∗\n /Π/ S0 T0 > f0 ≅ /Π/ S1 T1 > f1 =\n /Π/ S0 \\s0 -> /Π/ S1 \\s1 -> (S0 > s0 ≅ S1 > s1) ⟶\n (T0 s0 > f0 s0 ≅ T1 s1 > f1 s1)\n /Σ/ S0 T0 > p0 ≅ /Σ/ S1 T1 > p1 =\n let s0 : [ S0 ] ; s0 = fst p0\n s1 : [ S1 ] ; s1 = fst p1\n in (S0 > s0 ≅ S1 > s1) × (T0 s0 > snd p0 ≅ T1 s1 > snd p1)\n /Fin/ (suc n0) > fz ≅ /Fin/ (suc n1) > fz = /1/\n /Fin/ (suc n0) > fs x0 ≅ /Fin/ (suc n1) > fs x1 =\n /Fin/ n0 > x0 ≅ /Fin/ n1 > x1\n /D/ I0 A0 R0 i0 > (a0 , ks0) ≅ /D/ I1 A1 R1 i1 > (a1 , ks1) =\n (A0 i0 > a0 ≅ A1 i1 > a1) ×\n (Kids I0 (/D/ I0 A0 R0) (R0 i0 a0) > ks0 ≅\n Kids I1 (/D/ I1 A1 R1) (R1 i1 a1) > ks1)\n\n _ > _ ≅ _ > _ = /0/\n\nResp : (S : ∗)(P : [ S ] -> ∗)\n {s0 s1 : [ S ]} -> [ (S > s0 ≅ S > s1) ⟶ (P s0 ⇔ P s1) ]\nResp = {! !}\n\n[_>_] : (S : ∗)(s : [ S ]) -> [ S > s ≅ S > s ]\n[_>_] = {! !}\n\nKidsResp : (I0 : ∗)(I1 : ∗) -> [ I0 ⇔ I1 ] ->\n (P0 : [ I0 ] -> ∗)(P1 : [ I1 ] -> ∗) ->\n [( /Π/ I0 \\i0 -> /Π/ I1 \\i1 -> (I0 > i0 ≅ I1 > i1) ⟶\n (P0 i0 ⇔ P1 i1) )] ->\n (is0 : List [ I0 ])(is1 : List [ I1 ]) ->\n [ Eqs I0 is0 I1 is1 ] ->\n [ Kids I0 P0 is0 ⇔ Kids I1 P1 is1 ]\nKidsResp = {! !}\n\nmutual\n\n _>_<_!_ : (S : ∗) -> [ S ] -> (T : ∗) -> [ S ⇔ T ] -> [ T ]\n /Π/ S0 T0 > f0 < /Π/ S1 T1 ! Q =\n let S1S0 : [ S1 ⇔ S0 ]\n S1S0 = fst Q\n T0T1 : [( /Π/ S1 \\s1 -> /Π/ S0 \\s0 -> (S1 > s1 ≅ S0 > s0) ⟶\n (T0 s0 ⇔ T1 s1) )]\n T0T1 = snd Q\n in \\s1 ->\n let s0 : [ S0 ]\n s0 = S1 > s1 < S0 ! S1S0\n s1s0 : [( S1 > s1 ≅ S0 > s0 )]\n s1s0 = [| S1 > s1 < S0 ! S1S0 |]\n in T0 s0 > f0 s0 < T1 s1 ! T0T1 s1 s0 s1s0\n\n /Σ/ S0 T0 > p0 < /Σ/ S1 T1 ! Q =\n let S0S1 : [ S0 ⇔ S1 ]\n S0S1 = fst Q\n T0T1 : [( /Π/ S0 \\s0 -> /Π/ S1 \\s1 -> (S0 > s0 ≅ S1 > s1) ⟶\n (T0 s0 ⇔ T1 s1) )]\n T0T1 = snd Q\n s0 : [ S0 ]\n s0 = fst p0\n s1 : [ S1 ]\n s1 = S0 > s0 < S1 ! S0S1\n s0s1 : [ S0 > s0 ≅ S1 > s1 ]\n s0s1 = [| S0 > s0 < S1 ! S0S1 |]\n t0 : [ T0 s0 ]\n t0 = snd p0\n t1 : [ T1 s1 ]\n t1 = T0 s0 > t0 < T1 s1 ! T0T1 s0 s1 s0s1\n in s1 , t1\n\n /Fin/ (suc n0) > fz < /Fin/ (suc n1) ! Q = fz\n /Fin/ (suc n0) > fs x < /Fin/ (suc n1) ! Q = fs (/Fin/ n0 > x < /Fin/ n1 ! Q)\n\n /D/ I0 A0 R0 i0 > (a0 , ks0) < /D/ I1 A1 R1 i1 ! Q =\n let I01 : [ I0 ⇔ I1 ] ; I01 = fst Q\n A01 : [( /Π/ I0 \\i0 -> /Π/ I1 \\i1 ->\n (I0 > i0 ≅ I1 > i1) ⟶ (A0 i0 ⇔ A1 i1) )]\n A01 = fst (snd Q)\n R01 : [( /Π/ I0 \\i0 -> /Π/ I1 \\i1 -> (I0 > i0 ≅ I1 > i1) ⟶\n /Π/ (A0 i0) \\a0 -> /Π/ (A1 i1) \\a1 ->\n (A0 i0 > a0 ≅ A1 i1 > a1) ⟶\n Eqs I0 (R0 i0 a0) I1 (R1 i1 a1) )]\n R01 = fst (snd (snd Q))\n i01 : [ I0 > i0 ≅ I1 > i1 ] ; i01 = snd (snd (snd Q))\n in (/Σ/ (A0 i0) \\a0 -> Kids I0 (/D/ I0 A0 R0) (R0 i0 a0)) > (a0 , ks0) <\n (/Σ/ (A1 i1) \\a1 -> Kids I1 (/D/ I1 A1 R1) (R1 i1 a1)) !\n A01 i0 i1 i01 ,\n \\x0 x1 x01 ->\n KidsResp I0 I1 I01\n (/D/ I0 A0 R0) (/D/ I1 A1 R1) (\\j0 j1 j01 -> I01 , A01 , R01 , j01 )\n (R0 i0 x0) (R1 i1 x1) (R01 i0 i1 i01 x0 x1 x01)\n\n /Π/ _ _ > _ < /Σ/ _ _ ! ()\n /Π/ _ _ > _ < /Fin/ _ ! ()\n /Π/ _ _ > _ < /D/ _ _ _ _ ! ()\n\n /Σ/ _ _ > _ < /Π/ _ _ ! ()\n /Σ/ _ _ > _ < /Fin/ _ ! ()\n /Σ/ _ _ > _ < /D/ _ _ _ _ ! ()\n\n /D/ _ _ _ _ > _ < /Π/ _ _ ! ()\n /D/ _ _ _ _ > _ < /Σ/ _ _ ! ()\n /D/ _ _ _ _ > _ < /Fin/ _ ! ()\n\n /Fin/ _ > _ < /Π/ _ _ ! ()\n /Fin/ _ > _ < /Σ/ _ _ ! ()\n /Fin/ zero > () < /Fin/ zero ! _\n /Fin/ zero > _ < /Fin/ (suc n) ! ()\n /Fin/ (suc n) > _ < /Fin/ zero ! ()\n /Fin/ _ > _ < /D/ _ _ _ _ ! ()\n\n [|_>_<_!_|] : (S : ∗)(s : [ S ])(T : ∗)(q : [ S ⇔ T ]) ->\n [ S > s ≅ T > (S > s < T ! q) ]\n [| S > s < T ! q |] = {! !}\n\next : (S : ∗)(T : [ S ] -> ∗)(f g : [ /Π/ S T ]) ->\n [( /Π/ S \\x -> T x > f x ≅ T x > g x )] ->\n [ /Π/ S T > f ≅ /Π/ S T > g ]\next S T f g h s0 s1 s01 =\n (T s0 > f s0 ≅ T s0 > g s0) > h s0 < (T s0 > f s0 ≅ T s1 > g s1) !\n Resp S (\\s1 -> T s0 > f s0 ≅ T s1 > g s1) s01\n\nplusZeroLemma : [ (/Nat/ ⟶ /Nat/) > (\\x -> plus x /zero/) ≅\n (/Nat/ ⟶ /Nat/) > (\\x -> plus /zero/ x) ]\nplusZeroLemma = ext /Nat/ (\\_ -> /Nat/)\n (\\x -> plus x /zero/) (\\x -> plus /zero/ x) (natElim (\\x ->\n /Nat/ > plus x /zero/ ≅ /Nat/ > plus /zero/ x) (fz , fz)\n (\\n h -> [ (/Nat/ ⟶ /Nat/) > /suc/ ] (plus n /zero/) n h ))\n", "meta": {"hexsha": "cc46487518c7958fdb4b2fb355295f18d8d24509", "size": 9040, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/OTT/ObsEq2.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/OTT/ObsEq2.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/outdated-and-incorrect/OTT/ObsEq2.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 30.5405405405, "max_line_length": 79, "alphanum_fraction": 0.3495575221, "num_tokens": 4694, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8652240686758841, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.6021598936142972}} {"text": "module PLDI14-List-of-Theorems where\n\n-- List of theorems in PLDI submission\n--\n-- For hints about installation and execution, please refer\n-- to README.agda.\n--\n-- Agda modules corresponding to definitions, lemmas and theorems\n-- are listed here with the most important names. For example,\n-- after this file type checks (C-C C-L), placing the cursor\n-- on the purple \"Base.Change.Algebra\" and pressing M-. will\n-- bring you to the file where change structures are defined.\n-- The name for change structures in that file is\n-- \"ChangeAlgebra\", given in the using-clause.\n\n-- Definition 2.1 (Change structures)\nopen import Base.Change.Algebra using (ChangeAlgebra)\n---- Carrier in record ChangeAlgebra --(a)\nopen Base.Change.Algebra.ChangeAlgebra using (Change) --(b)\nopen Base.Change.Algebra.ChangeAlgebra using (update) --(c)\nopen Base.Change.Algebra.ChangeAlgebra using (diff) --(d)\nopen Base.Change.Algebra.IsChangeAlgebra using (update-diff)--(e)\n\n-- Definition 2.2 (Nil change)\n-- IsChangeAlgebra.nil\nopen Base.Change.Algebra using (IsChangeAlgebra)\n\n-- Lemma 2.3 (Behavior of nil)\n-- IsChangeAlgebra.update-nil\nopen Base.Change.Algebra using (IsChangeAlgebra)\n\n-- Lemma 2.5 (Behavior of derivatives on nil)\nopen import Base.Change.Equivalence using (deriv-zero)\n\n-- Definition 2.4 (Derivatives)\nopen Base.Change.Algebra using (IsDerivative)\n\n-- Definition 2.6 (Carrier set of function changes)\nopen Base.Change.Algebra.FunctionChanges\n\n-- Definition 2.7 (Operations on function changes)\n-- ChangeAlgebra.update FunctionChanges.changeAlgebra\n-- ChangeAlgebra.diff FunctionChanges.changeAlgebra\nopen Base.Change.Algebra.FunctionChanges using (changeAlgebraFun)\n\n-- Theorem 2.8 (Function changes form a change structure)\n-- (In Agda, the proof of Theorem 2.8 has to be included in the\n-- definition of function changes, here\n-- FunctionChanges.changeAlgebra.)\nopen Base.Change.Algebra.FunctionChanges using (changeAlgebraFun)\n\n-- Theorem 2.9 (Incrementalization)\nopen Base.Change.Algebra.FunctionChanges using (incrementalization)\n\n-- Theorem 2.10 (Nil changes are derivatives)\nopen Base.Change.Algebra.FunctionChanges using (nil-is-derivative)\n\n-- Definition 3.1 (Domains)\nimport Parametric.Denotation.Value\nopen Parametric.Denotation.Value.Structure using (⟦_⟧Type)\n\n-- Definition 3.2 (Environments)\nopen import Base.Denotation.Environment using (⟦_⟧Context)\n\n-- Definition 3.3 (Evaluation)\nimport Parametric.Denotation.Evaluation\nopen Parametric.Denotation.Evaluation.Structure using (⟦_⟧Term)\n\n-- Definition 3.4 (Changes)\n-- Definition 3.5 (Change environments)\nimport Parametric.Change.Validity\nopen Parametric.Change.Validity.Structure using (change-algebra)\nopen Parametric.Change.Validity.Structure using (environment-changes)\n\n-- Definition 3.6 (Change semantics)\n-- Lemma 3.7 (Change semantics is the derivative of semantics)\nimport Parametric.Change.Specification\nopen Parametric.Change.Specification.Structure using (⟦_⟧Δ)\nopen Parametric.Change.Specification.Structure using (correctness)\n\n-- Definition 3.8 (Erasure)\n-- Lemma 3.9 (The erased version of a change is almost the same)\nimport Parametric.Change.Implementation\nopen Parametric.Change.Implementation.Structure using (_≈_)\nopen Parametric.Change.Implementation.Structure using (carry-over)\n\n-- Lemma 3.10 (⟦ t ⟧Δ erases to Derive(t))\n-- Theorem 3.11 (Correctness of differentiation)\nimport Parametric.Change.Correctness\nopen Parametric.Change.Correctness.Structure using (derive-correct-closed)\nopen Parametric.Change.Correctness.Structure using (main-theorem)\n", "meta": {"hexsha": "d9379e6c42fa7ae97d0409b0d3fcc919976cba17", "size": 3583, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "PLDI14-List-of-Theorems.agda", "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_issues_repo_path": "PLDI14-List-of-Theorems.agda", "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_forks_repo_path": "PLDI14-List-of-Theorems.agda", "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "avg_line_length": 38.9456521739, "max_line_length": 74, "alphanum_fraction": 0.7772816076, "num_tokens": 890, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920020959544, "lm_q2_score": 0.7520125793176222, "lm_q1q2_score": 0.6021304577351696}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Algebra.Matrix where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Univalence\nopen import Cubical.Functions.FunExtEquiv\n\nimport Cubical.Data.Empty as ⊥\nopen import Cubical.Data.Nat hiding (_+_ ; +-comm)\nopen import Cubical.Data.Vec\nopen import Cubical.Data.FinData\nopen import Cubical.Relation.Nullary\n\nopen import Cubical.Structures.CommRing\n\nprivate\n variable\n ℓ : Level\n A : Type ℓ\n\n-- Equivalence between Vec matrix and Fin function matrix\n\nFinMatrix : (A : Type ℓ) (m n : ℕ) → Type ℓ\nFinMatrix A m n = FinVec (FinVec A n) m\n\nVecMatrix : (A : Type ℓ) (m n : ℕ) → Type ℓ\nVecMatrix A m n = Vec (Vec A n) m\n\nFinMatrix→VecMatrix : {m n : ℕ} → FinMatrix A m n → VecMatrix A m n\nFinMatrix→VecMatrix M = FinVec→Vec (λ fm → FinVec→Vec (λ fn → M fm fn))\n\nVecMatrix→FinMatrix : {m n : ℕ} → VecMatrix A m n → FinMatrix A m n\nVecMatrix→FinMatrix M fn fm = lookup fm (lookup fn M)\n\nFinMatrix→VecMatrix→FinMatrix : {m n : ℕ} (M : FinMatrix A m n)\n → VecMatrix→FinMatrix (FinMatrix→VecMatrix M) ≡ M\nFinMatrix→VecMatrix→FinMatrix {m = zero} M = funExt λ f → ⊥.rec (¬Fin0 f)\nFinMatrix→VecMatrix→FinMatrix {n = zero} M = funExt₂ λ _ f → ⊥.rec (¬Fin0 f)\nFinMatrix→VecMatrix→FinMatrix {m = suc m} {n = suc n} M = funExt₂ goal\n where\n goal : (fm : Fin (suc m)) (fn : Fin (suc n)) →\n VecMatrix→FinMatrix (_ ∷ FinMatrix→VecMatrix (λ z → M (suc z))) fm fn ≡ M fm fn\n goal zero zero = refl\n goal zero (suc fn) i = FinVec→Vec→FinVec (λ z → M zero (suc z)) i fn\n goal (suc fm) fn i = FinMatrix→VecMatrix→FinMatrix (λ z → M (suc z)) i fm fn\n\nVecMatrix→FinMatrix→VecMatrix : {m n : ℕ} (M : VecMatrix A m n)\n → FinMatrix→VecMatrix (VecMatrix→FinMatrix M) ≡ M\nVecMatrix→FinMatrix→VecMatrix {m = zero} [] = refl\nVecMatrix→FinMatrix→VecMatrix {m = suc m} (M ∷ MS) i =\n Vec→FinVec→Vec M i ∷ VecMatrix→FinMatrix→VecMatrix MS i\n\nFinMatrixIsoVecMatrix : (A : Type ℓ) (m n : ℕ) → Iso (FinMatrix A m n) (VecMatrix A m n)\nFinMatrixIsoVecMatrix A m n =\n iso FinMatrix→VecMatrix VecMatrix→FinMatrix VecMatrix→FinMatrix→VecMatrix FinMatrix→VecMatrix→FinMatrix\n\nFinMatrix≃VecMatrix : {m n : ℕ} → FinMatrix A m n ≃ VecMatrix A m n\nFinMatrix≃VecMatrix {_} {A} {m} {n} = isoToEquiv (FinMatrixIsoVecMatrix A m n)\n\nFinMatrix≡VecMatrix : (A : Type ℓ) (m n : ℕ) → FinMatrix A m n ≡ VecMatrix A m n\nFinMatrix≡VecMatrix _ _ _ = ua FinMatrix≃VecMatrix\n\n\n-- We could have constructed the above Path as follows, but that\n-- doesn't reduce as nicely as ua isn't on the toplevel:\n--\n-- FinMatrix≡VecMatrix : (A : Type ℓ) (m n : ℕ) → FinMatrix A m n ≡ VecMatrix A m n\n-- FinMatrix≡VecMatrix A m n i = FinVec≡Vec (FinVec≡Vec A n i) m i\n\n\n-- Experiment using addition. Transport commutativity from one\n-- representation to the the other and relate the transported\n-- operation with a more direct definition.\nmodule _ (R' : CommRing {ℓ}) where\n\n open CommRing R' renaming ( Carrier to R )\n\n addFinMatrix : ∀ {m n} → FinMatrix R m n → FinMatrix R m n → FinMatrix R m n\n addFinMatrix M N = λ k l → M k l + N k l\n\n addFinMatrixComm : ∀ {m n} → (M N : FinMatrix R m n) → addFinMatrix M N ≡ addFinMatrix N M\n addFinMatrixComm M N i k l = +-comm (M k l) (N k l) i\n\n addVecMatrix : ∀ {m n} → VecMatrix R m n → VecMatrix R m n → VecMatrix R m n\n addVecMatrix {m} {n} = transport (λ i → FinMatrix≡VecMatrix R m n i\n → FinMatrix≡VecMatrix R m n i\n → FinMatrix≡VecMatrix R m n i)\n addFinMatrix\n\n addMatrixPath : ∀ {m n} → PathP (λ i → FinMatrix≡VecMatrix R m n i\n → FinMatrix≡VecMatrix R m n i\n → FinMatrix≡VecMatrix R m n i)\n addFinMatrix addVecMatrix\n addMatrixPath {m} {n} i = transp (λ j → FinMatrix≡VecMatrix R m n (i ∧ j)\n → FinMatrix≡VecMatrix R m n (i ∧ j)\n → FinMatrix≡VecMatrix R m n (i ∧ j))\n (~ i) addFinMatrix\n\n addVecMatrixComm : ∀ {m n} → (M N : VecMatrix R m n) → addVecMatrix M N ≡ addVecMatrix N M\n addVecMatrixComm {m} {n} = transport (λ i → (M N : FinMatrix≡VecMatrix R m n i)\n → addMatrixPath i M N ≡ addMatrixPath i N M)\n addFinMatrixComm\n\n\n -- More direct definition of addition for VecMatrix:\n\n addVec : ∀ {m} → Vec R m → Vec R m → Vec R m\n addVec [] [] = []\n addVec (x ∷ xs) (y ∷ ys) = x + y ∷ addVec xs ys\n\n addVecLem : ∀ {m} → (M N : Vec R m)\n → FinVec→Vec (λ l → lookup l M + lookup l N) ≡ addVec M N\n addVecLem {zero} [] [] = refl\n addVecLem {suc m} (x ∷ xs) (y ∷ ys) = cong (λ zs → x + y ∷ zs) (addVecLem xs ys)\n\n addVecMatrix' : ∀ {m n} → VecMatrix R m n → VecMatrix R m n → VecMatrix R m n\n addVecMatrix' [] [] = []\n addVecMatrix' (M ∷ MS) (N ∷ NS) = addVec M N ∷ addVecMatrix' MS NS\n\n -- The key lemma relating addVecMatrix and addVecMatrix'\n addVecMatrixEq : ∀ {m n} → (M N : VecMatrix R m n) → addVecMatrix M N ≡ addVecMatrix' M N\n addVecMatrixEq {zero} {n} [] [] j = transp (λ i → Vec (Vec R n) 0) j []\n addVecMatrixEq {suc m} {n} (M ∷ MS) (N ∷ NS) =\n addVecMatrix (M ∷ MS) (N ∷ NS)\n ≡⟨ transportUAop₂ FinMatrix≃VecMatrix addFinMatrix (M ∷ MS) (N ∷ NS) ⟩\n FinVec→Vec (λ l → lookup l M + lookup l N) ∷ _\n ≡⟨ (λ i → addVecLem M N i ∷ FinMatrix→VecMatrix (λ k l → lookup l (lookup k MS) + lookup l (lookup k NS))) ⟩\n addVec M N ∷ _\n ≡⟨ cong (λ X → addVec M N ∷ X) (sym (transportUAop₂ FinMatrix≃VecMatrix addFinMatrix MS NS) ∙ addVecMatrixEq MS NS) ⟩\n addVec M N ∷ addVecMatrix' MS NS ∎\n\n -- By binary funext we get an equality as functions\n addVecMatrixEqFun : ∀ {m} {n} → addVecMatrix {m} {n} ≡ addVecMatrix'\n addVecMatrixEqFun i M N = addVecMatrixEq M N i\n\n -- We then directly get the properties about addVecMatrix'\n addVecMatrixComm' : ∀ {m n} → (M N : VecMatrix R m n) → addVecMatrix' M N ≡ addVecMatrix' N M\n addVecMatrixComm' M N = sym (addVecMatrixEq M N) ∙∙ addVecMatrixComm M N ∙∙ addVecMatrixEq N M\n\n -- TODO: prove more properties about addition of matrices for both\n -- FinMatrix and VecMatrix\n\n\n\n-- TODO: define multiplication of matrices and do the same kind of\n-- reasoning as we did for addition\n", "meta": {"hexsha": "2585c1fb1329adc8096d92d1d75a97bc1251478a", "size": 6518, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Matrix.agda", "max_stars_repo_name": "RobertHarper/cubical", "max_stars_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Matrix.agda", "max_issues_repo_name": "RobertHarper/cubical", "max_issues_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Matrix.agda", "max_forks_repo_name": "RobertHarper/cubical", "max_forks_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "avg_line_length": 43.744966443, "max_line_length": 123, "alphanum_fraction": 0.6192083461, "num_tokens": 2176, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920020959543, "lm_q2_score": 0.7520125793176222, "lm_q1q2_score": 0.6021304577351695}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- A bunch of properties about natural number operations\n------------------------------------------------------------------------\n\n-- See README.Data.Nat for some examples showing how this module can be\n-- used.\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Nat.Properties where\n\nopen import Axiom.UniquenessOfIdentityProofs\nopen import Algebra.Bundles\nopen import Algebra.Morphism\nopen import Algebra.Consequences.Propositional\nopen import Data.Bool.Base using (Bool; false; true; T)\nopen import Data.Bool.Properties using (T?)\nopen import Data.Empty\nopen import Data.Nat.Base\nopen import Data.Product\nopen import Data.Sum.Base as Sum\nopen import Data.Unit using (tt)\nopen import Function.Base\nopen import Function.Injection using (_↣_)\nopen import Level using (0ℓ)\nopen import Relation.Binary\nopen import Relation.Binary.Consequences using (flip-Connex)\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary hiding (Irrelevant)\nopen import Relation.Nullary.Decidable using (True; via-injection; map′)\nopen import Relation.Nullary.Negation using (contradiction)\n\nopen import Algebra.Definitions {A = ℕ} _≡_\n hiding (LeftCancellative; RightCancellative; Cancellative)\nopen import Algebra.Definitions\n using (LeftCancellative; RightCancellative; Cancellative)\nopen import Algebra.Structures {A = ℕ} _≡_\n\n------------------------------------------------------------------------\n-- Properties of _≡_\n------------------------------------------------------------------------\n\nsuc-injective : ∀ {m n} → suc m ≡ suc n → m ≡ n\nsuc-injective refl = refl\n\n≡ᵇ⇒≡ : ∀ m n → T (m ≡ᵇ n) → m ≡ n\n≡ᵇ⇒≡ zero zero _ = refl\n≡ᵇ⇒≡ (suc m) (suc n) eq = cong suc (≡ᵇ⇒≡ m n eq)\n\n≡⇒≡ᵇ : ∀ m n → m ≡ n → T (m ≡ᵇ n)\n≡⇒≡ᵇ zero zero eq = _\n≡⇒≡ᵇ (suc m) (suc n) eq = ≡⇒≡ᵇ m n (suc-injective eq)\n\n-- NB: we use the builtin function `_≡ᵇ_` here so that the function\n-- quickly decides whether to return `yes` or `no`. It still takes\n-- a linear amount of time to generate the proof if it is inspected.\n-- We expect the main benefit to be visible in compiled code as the\n-- backend erases proofs.\n\ninfix 4 _≟_\n_≟_ : Decidable {A = ℕ} _≡_\nm ≟ n = map′ (≡ᵇ⇒≡ m n) (≡⇒≡ᵇ m n) (T? (m ≡ᵇ n))\n\n≡-irrelevant : Irrelevant {A = ℕ} _≡_\n≡-irrelevant = Decidable⇒UIP.≡-irrelevant _≟_\n\n≟-diag : ∀ {m n} (eq : m ≡ n) → (m ≟ n) ≡ yes eq\n≟-diag = ≡-≟-identity _≟_\n\n≡-isDecEquivalence : IsDecEquivalence (_≡_ {A = ℕ})\n≡-isDecEquivalence = record\n { isEquivalence = isEquivalence\n ; _≟_ = _≟_\n }\n\n≡-decSetoid : DecSetoid 0ℓ 0ℓ\n≡-decSetoid = record\n { Carrier = ℕ\n ; _≈_ = _≡_\n ; isDecEquivalence = ≡-isDecEquivalence\n }\n\n0≢1+n : ∀ {n} → 0 ≢ suc n\n0≢1+n ()\n\n1+n≢0 : ∀ {n} → suc n ≢ 0\n1+n≢0 ()\n\n1+n≢n : ∀ {n} → suc n ≢ n\n1+n≢n {suc n} = 1+n≢n ∘ suc-injective\n\n------------------------------------------------------------------------\n-- Properties of _<ᵇ_\n------------------------------------------------------------------------\n\n<ᵇ⇒< : ∀ m n → T (m <ᵇ n) → m < n\n<ᵇ⇒< zero (suc n) m : _≰_ ⇒ _>_\n≰⇒> {zero} z≰n = contradiction z≤n z≰n\n≰⇒> {suc m} {zero} _ = s≤s z≤n\n≰⇒> {suc m} {suc n} m≰n = s≤s (≰⇒> (m≰n ∘ s≤s))\n\n≰⇒≥ : _≰_ ⇒ _≥_\n≰⇒≥ = <⇒≤ ∘ ≰⇒>\n\n≮⇒≥ : _≮_ ⇒ _≥_\n≮⇒≥ {_} {zero} _ = z≤n\n≮⇒≥ {zero} {suc j} 1≮j+1 = contradiction (s≤s z≤n) 1≮j+1\n≮⇒≥ {suc i} {suc j} i+1≮j+1 = s≤s (≮⇒≥ (i+1≮j+1 ∘ s≤s))\n\n≤∧≢⇒< : ∀ {m n} → m ≤ n → m ≢ n → m < n\n≤∧≢⇒< {_} {zero} z≤n m≢n = contradiction refl m≢n\n≤∧≢⇒< {_} {suc n} z≤n m≢n = s≤s z≤n\n≤∧≢⇒< {_} {suc n} (s≤s m≤n) 1+m≢1+n =\n s≤s (≤∧≢⇒< m≤n (1+m≢1+n ∘ cong suc))\n\n≤-<-connex : Connex _≤_ _<_\n≤-<-connex m n with m ≤? n\n... | yes m≤n = inj₁ m≤n\n... | no ¬m≤n = inj₂ (≰⇒> ¬m≤n)\n\n≥->-connex : Connex _≥_ _>_\n≥->-connex = flip ≤-<-connex\n\n<-≤-connex : Connex _<_ _≤_\n<-≤-connex = flip-Connex ≤-<-connex\n\n>-≥-connex : Connex _>_ _≥_\n>-≥-connex = flip-Connex ≥->-connex\n\n------------------------------------------------------------------------\n-- Relational properties of _<_\n\n<-irrefl : Irreflexive _≡_ _<_\n<-irrefl refl (s≤s n (m≮n ∘ <⇒<ᵇ) m≢n (≤∧≢⇒< (≮⇒≥ (m≮n ∘ <⇒<ᵇ)) (m≢n ∘ sym))\n\ninfix 4 _?_\n\n_?_ : Decidable _>_\n_>?_ = flip _0 : ∀ {n} → n ≢ 0 → n > 0\nn≢0⇒n>0 {zero} 0≢0 = contradiction refl 0≢0\nn≢0⇒n>0 {suc n} _ = 0<1+n\n\nm 0 → m < m + n\nm0 = n>0\nm0 = s≤s (m0)\n\nm 0 → m < n + m\nm0 rewrite +-comm n m = m0\n\nm+n≮n : ∀ m n → m + n ≮ n\nm+n≮n zero n = n≮n n\nm+n≮n (suc m) (suc n) (s≤s m+nn⇒m∸n≢0 : ∀ {m n} → m > n → m ∸ n ≢ 0\nm>n⇒m∸n≢0 {n = suc n} (s≤s m>n) = m>n⇒m∸n≢0 m>n\n\n---------------------------------------------------------------\n-- Properties of _∸_ and _+_\n\n+-∸-comm : ∀ {m} n {o} → o ≤ m → (m + n) ∸ o ≡ (m ∸ o) + n\n+-∸-comm {zero} _ {zero} _ = refl\n+-∸-comm {suc m} _ {zero} _ = refl\n+-∸-comm {suc m} n {suc o} (s≤s o≤m) = +-∸-comm n o≤m\n\n∸-+-assoc : ∀ m n o → (m ∸ n) ∸ o ≡ m ∸ (n + o)\n∸-+-assoc zero zero o = refl\n∸-+-assoc zero (suc n) o = 0∸n≡0 o\n∸-+-assoc (suc m) zero o = refl\n∸-+-assoc (suc m) (suc n) o = ∸-+-assoc m n o\n\n+-∸-assoc : ∀ m {n o} → o ≤ n → (m + n) ∸ o ≡ m + (n ∸ o)\n+-∸-assoc m (z≤n {n = n}) = begin-equality m + n ∎\n+-∸-assoc m (s≤s {m = o} {n = n} o≤n) = begin-equality\n (m + suc n) ∸ suc o ≡⟨ cong (_∸ suc o) (+-suc m n) ⟩\n suc (m + n) ∸ suc o ≡⟨⟩\n (m + n) ∸ o ≡⟨ +-∸-assoc m o≤n ⟩\n m + (n ∸ o) ∎\n\nm≤n+m∸n : ∀ m n → m ≤ n + (m ∸ n)\nm≤n+m∸n zero n = z≤n\nm≤n+m∸n (suc m) zero = ≤-refl\nm≤n+m∸n (suc m) (suc n) = s≤s (m≤n+m∸n m n)\n\nm+n∸n≡m : ∀ m n → m + n ∸ n ≡ m\nm+n∸n≡m m n = begin-equality\n (m + n) ∸ n ≡⟨ +-∸-assoc m (≤-refl {x = n}) ⟩\n m + (n ∸ n) ≡⟨ cong (m +_) (n∸n≡0 n) ⟩\n m + 0 ≡⟨ +-identityʳ m ⟩\n m ∎\n\nm+n∸m≡n : ∀ m n → m + n ∸ m ≡ n\nm+n∸m≡n m n = trans (cong (_∸ m) (+-comm m n)) (m+n∸n≡m n m)\n\nm+[n∸m]≡n : ∀ {m n} → m ≤ n → m + (n ∸ m) ≡ n\nm+[n∸m]≡n {m} {n} m≤n = begin-equality\n m + (n ∸ m) ≡⟨ sym $ +-∸-assoc m m≤n ⟩\n (m + n) ∸ m ≡⟨ cong (_∸ m) (+-comm m n) ⟩\n (n + m) ∸ m ≡⟨ m+n∸n≡m n m ⟩\n n ∎\n\nm∸n+n≡m : ∀ {m n} → n ≤ m → (m ∸ n) + n ≡ m\nm∸n+n≡m {m} {n} n≤m = begin-equality\n (m ∸ n) + n ≡⟨ sym (+-∸-comm n n≤m) ⟩\n (m + n) ∸ n ≡⟨ m+n∸n≡m m n ⟩\n m ∎\n\nm∸[m∸n]≡n : ∀ {m n} → n ≤ m → m ∸ (m ∸ n) ≡ n\nm∸[m∸n]≡n {m} {_} z≤n = n∸n≡0 m\nm∸[m∸n]≡n {suc m} {suc n} (s≤s n≤m) = begin-equality\n suc m ∸ (m ∸ n) ≡⟨ +-∸-assoc 1 (m∸n≤m m n) ⟩\n suc (m ∸ (m ∸ n)) ≡⟨ cong suc (m∸[m∸n]≡n n≤m) ⟩\n suc n ∎\n\n[m+n]∸[m+o]≡n∸o : ∀ m n o → (m + n) ∸ (m + o) ≡ n ∸ o\n[m+n]∸[m+o]≡n∸o zero n o = refl\n[m+n]∸[m+o]≡n∸o (suc m) n o = [m+n]∸[m+o]≡n∸o m n o\n\n------------------------------------------------------------------------\n-- Properties of _∸_ and _*_\n\n*-distribʳ-∸ : _*_ DistributesOverʳ _∸_\n*-distribʳ-∸ m zero zero = refl\n*-distribʳ-∸ zero zero (suc o) = sym (0∸n≡0 (o * zero))\n*-distribʳ-∸ (suc m) zero (suc o) = refl\n*-distribʳ-∸ m (suc n) zero = refl\n*-distribʳ-∸ m (suc n) (suc o) = begin-equality\n (n ∸ o) * m ≡⟨ *-distribʳ-∸ m n o ⟩\n n * m ∸ o * m ≡⟨ sym $ [m+n]∸[m+o]≡n∸o m _ _ ⟩\n m + n * m ∸ (m + o * m) ∎\n\n*-distribˡ-∸ : _*_ DistributesOverˡ _∸_\n*-distribˡ-∸ = comm+distrʳ⇒distrˡ *-comm *-distribʳ-∸\n\n*-distrib-∸ : _*_ DistributesOver _∸_\n*-distrib-∸ = *-distribˡ-∸ , *-distribʳ-∸\n\neven≢odd : ∀ m n → 2 * m ≢ suc (2 * n)\neven≢odd (suc m) zero eq = contradiction (suc-injective eq) (m+1+n≢0 m)\neven≢odd (suc m) (suc n) eq = even≢odd m n (suc-injective (begin-equality\n suc (2 * m) ≡⟨ sym (+-suc m _) ⟩\n m + suc (m + 0) ≡⟨ suc-injective eq ⟩\n suc n + suc (n + 0) ≡⟨ cong suc (+-suc n _) ⟩\n suc (suc (2 * n)) ∎))\n\n------------------------------------------------------------------------\n-- Properties of _∸_ and _⊓_ and _⊔_\n\nm⊓n+n∸m≡n : ∀ m n → (m ⊓ n) + (n ∸ m) ≡ n\nm⊓n+n∸m≡n zero n = refl\nm⊓n+n∸m≡n (suc m) zero = refl\nm⊓n+n∸m≡n (suc m) (suc n) = cong suc $ m⊓n+n∸m≡n m n\n\n[m∸n]⊓[n∸m]≡0 : ∀ m n → (m ∸ n) ⊓ (n ∸ m) ≡ 0\n[m∸n]⊓[n∸m]≡0 zero zero = refl\n[m∸n]⊓[n∸m]≡0 zero (suc n) = refl\n[m∸n]⊓[n∸m]≡0 (suc m) zero = refl\n[m∸n]⊓[n∸m]≡0 (suc m) (suc n) = [m∸n]⊓[n∸m]≡0 m n\n\n∸-distribˡ-⊓-⊔ : ∀ m n o → m ∸ (n ⊓ o) ≡ (m ∸ n) ⊔ (m ∸ o)\n∸-distribˡ-⊓-⊔ m zero zero = sym (⊔-idem m)\n∸-distribˡ-⊓-⊔ zero zero (suc o) = refl\n∸-distribˡ-⊓-⊔ zero (suc n) zero = refl\n∸-distribˡ-⊓-⊔ zero (suc n) (suc o) = refl\n∸-distribˡ-⊓-⊔ (suc m) (suc n) zero = sym (m≤n⇒m⊔n≡n (≤-step (m∸n≤m m n)))\n∸-distribˡ-⊓-⊔ (suc m) zero (suc o) = sym (m≤n⇒n⊔m≡n (≤-step (m∸n≤m m o)))\n∸-distribˡ-⊓-⊔ (suc m) (suc n) (suc o) = ∸-distribˡ-⊓-⊔ m n o\n\n∸-distribʳ-⊓ : _∸_ DistributesOverʳ _⊓_\n∸-distribʳ-⊓ zero n o = refl\n∸-distribʳ-⊓ (suc m) zero o = refl\n∸-distribʳ-⊓ (suc m) (suc n) zero = sym (⊓-zeroʳ (n ∸ m))\n∸-distribʳ-⊓ (suc m) (suc n) (suc o) = ∸-distribʳ-⊓ m n o\n\n∸-distribˡ-⊔-⊓ : ∀ m n o → m ∸ (n ⊔ o) ≡ (m ∸ n) ⊓ (m ∸ o)\n∸-distribˡ-⊔-⊓ m zero zero = sym (⊓-idem m)\n∸-distribˡ-⊔-⊓ zero zero o = 0∸n≡0 o\n∸-distribˡ-⊔-⊓ zero (suc n) o = 0∸n≡0 (suc n ⊔ o)\n∸-distribˡ-⊔-⊓ (suc m) (suc n) zero = sym (m≤n⇒m⊓n≡m (≤-step (m∸n≤m m n)))\n∸-distribˡ-⊔-⊓ (suc m) zero (suc o) = sym (m≤n⇒n⊓m≡m (≤-step (m∸n≤m m o)))\n∸-distribˡ-⊔-⊓ (suc m) (suc n) (suc o) = ∸-distribˡ-⊔-⊓ m n o\n\n∸-distribʳ-⊔ : _∸_ DistributesOverʳ _⊔_\n∸-distribʳ-⊔ zero n o = refl\n∸-distribʳ-⊔ (suc m) zero o = refl\n∸-distribʳ-⊔ (suc m) (suc n) zero = sym (⊔-identityʳ (n ∸ m))\n∸-distribʳ-⊔ (suc m) (suc n) (suc o) = ∸-distribʳ-⊔ m n o\n\n------------------------------------------------------------------------\n-- Properties of ∣_-_∣\n------------------------------------------------------------------------\n\nm≡n⇒∣m-n∣≡0 : ∀ {m n} → m ≡ n → ∣ m - n ∣ ≡ 0\nm≡n⇒∣m-n∣≡0 {zero} refl = refl\nm≡n⇒∣m-n∣≡0 {suc m} refl = m≡n⇒∣m-n∣≡0 {m} refl\n\n∣m-n∣≡0⇒m≡n : ∀ {m n} → ∣ m - n ∣ ≡ 0 → m ≡ n\n∣m-n∣≡0⇒m≡n {zero} {zero} eq = refl\n∣m-n∣≡0⇒m≡n {suc m} {suc n} eq = cong suc (∣m-n∣≡0⇒m≡n eq)\n\nm≤n⇒∣n-m∣≡n∸m : ∀ {m n} → m ≤ n → ∣ n - m ∣ ≡ n ∸ m\nm≤n⇒∣n-m∣≡n∸m {_} {zero} z≤n = refl\nm≤n⇒∣n-m∣≡n∸m {_} {suc m} z≤n = refl\nm≤n⇒∣n-m∣≡n∸m {_} {_} (s≤s m≤n) = m≤n⇒∣n-m∣≡n∸m m≤n\n\n∣m-n∣≡m∸n⇒n≤m : ∀ {m n} → ∣ m - n ∣ ≡ m ∸ n → n ≤ m\n∣m-n∣≡m∸n⇒n≤m {zero} {zero} eq = z≤n\n∣m-n∣≡m∸n⇒n≤m {suc m} {zero} eq = z≤n\n∣m-n∣≡m∸n⇒n≤m {suc m} {suc n} eq = s≤s (∣m-n∣≡m∸n⇒n≤m eq)\n\n∣n-n∣≡0 : ∀ n → ∣ n - n ∣ ≡ 0\n∣n-n∣≡0 n = m≡n⇒∣m-n∣≡0 {n} refl\n\n∣m-m+n∣≡n : ∀ m n → ∣ m - m + n ∣ ≡ n\n∣m-m+n∣≡n zero n = refl\n∣m-m+n∣≡n (suc m) n = ∣m-m+n∣≡n m n\n\n∣m+n-m+o∣≡∣n-o| : ∀ m n o → ∣ m + n - m + o ∣ ≡ ∣ n - o ∣\n∣m+n-m+o∣≡∣n-o| zero n o = refl\n∣m+n-m+o∣≡∣n-o| (suc m) n o = ∣m+n-m+o∣≡∣n-o| m n o\n\nm∸n≤∣m-n∣ : ∀ m n → m ∸ n ≤ ∣ m - n ∣\nm∸n≤∣m-n∣ m n with ≤-total m n\n... | inj₁ m≤n = subst (_≤ ∣ m - n ∣) (sym (m≤n⇒m∸n≡0 m≤n)) z≤n\n... | inj₂ n≤m = subst (m ∸ n ≤_) (sym (m≤n⇒∣n-m∣≡n∸m n≤m)) ≤-refl\n\n∣m-n∣≤m⊔n : ∀ m n → ∣ m - n ∣ ≤ m ⊔ n\n∣m-n∣≤m⊔n zero m = ≤-refl\n∣m-n∣≤m⊔n (suc m) zero = ≤-refl\n∣m-n∣≤m⊔n (suc m) (suc n) = ≤-step (∣m-n∣≤m⊔n m n)\n\n∣-∣-identityˡ : LeftIdentity 0 ∣_-_∣\n∣-∣-identityˡ x = refl\n\n∣-∣-identityʳ : RightIdentity 0 ∣_-_∣\n∣-∣-identityʳ zero = refl\n∣-∣-identityʳ (suc x) = refl\n\n∣-∣-identity : Identity 0 ∣_-_∣\n∣-∣-identity = ∣-∣-identityˡ , ∣-∣-identityʳ\n\n∣-∣-comm : Commutative ∣_-_∣\n∣-∣-comm zero zero = refl\n∣-∣-comm zero (suc n) = refl\n∣-∣-comm (suc m) zero = refl\n∣-∣-comm (suc m) (suc n) = ∣-∣-comm m n\n\n∣m-n∣≡[m∸n]∨[n∸m] : ∀ m n → (∣ m - n ∣ ≡ m ∸ n) ⊎ (∣ m - n ∣ ≡ n ∸ m)\n∣m-n∣≡[m∸n]∨[n∸m] m n with ≤-total m n\n... | inj₂ n≤m = inj₁ $ m≤n⇒∣n-m∣≡n∸m n≤m\n... | inj₁ m≤n = inj₂ $ begin-equality\n ∣ m - n ∣ ≡⟨ ∣-∣-comm m n ⟩\n ∣ n - m ∣ ≡⟨ m≤n⇒∣n-m∣≡n∸m m≤n ⟩\n n ∸ m ∎\n\nprivate\n\n *-distribˡ-∣-∣-aux : ∀ a m n → m ≤ n → a * ∣ n - m ∣ ≡ ∣ a * n - a * m ∣\n *-distribˡ-∣-∣-aux a m n m≤n = begin-equality\n a * ∣ n - m ∣ ≡⟨ cong (a *_) (m≤n⇒∣n-m∣≡n∸m m≤n) ⟩\n a * (n ∸ m) ≡⟨ *-distribˡ-∸ a n m ⟩\n a * n ∸ a * m ≡⟨ sym $′ m≤n⇒∣n-m∣≡n∸m (*-monoʳ-≤ a m≤n) ⟩\n ∣ a * n - a * m ∣ ∎\n\n*-distribˡ-∣-∣ : _*_ DistributesOverˡ ∣_-_∣\n*-distribˡ-∣-∣ a m n with ≤-total m n\n... | inj₁ m≤n = begin-equality\n a * ∣ m - n ∣ ≡⟨ cong (a *_) (∣-∣-comm m n) ⟩\n a * ∣ n - m ∣ ≡⟨ *-distribˡ-∣-∣-aux a m n m≤n ⟩\n ∣ a * n - a * m ∣ ≡⟨ ∣-∣-comm (a * n) (a * m) ⟩\n ∣ a * m - a * n ∣ ∎\n... | inj₂ n≤m = *-distribˡ-∣-∣-aux a n m n≤m\n\n*-distribʳ-∣-∣ : _*_ DistributesOverʳ ∣_-_∣\n*-distribʳ-∣-∣ = comm+distrˡ⇒distrʳ *-comm *-distribˡ-∣-∣\n\n*-distrib-∣-∣ : _*_ DistributesOver ∣_-_∣\n*-distrib-∣-∣ = *-distribˡ-∣-∣ , *-distribʳ-∣-∣\n\nm≤n+∣n-m∣ : ∀ m n → m ≤ n + ∣ n - m ∣\nm≤n+∣n-m∣ zero n = z≤n\nm≤n+∣n-m∣ (suc m) zero = ≤-refl\nm≤n+∣n-m∣ (suc m) (suc n) = s≤s (m≤n+∣n-m∣ m n)\n\nm≤n+∣m-n∣ : ∀ m n → m ≤ n + ∣ m - n ∣\nm≤n+∣m-n∣ m n = subst (m ≤_) (cong (n +_) (∣-∣-comm n m)) (m≤n+∣n-m∣ m n)\n\nm≤∣m-n∣+n : ∀ m n → m ≤ ∣ m - n ∣ + n\nm≤∣m-n∣+n m n = subst (m ≤_) (+-comm n _) (m≤n+∣m-n∣ m n)\n\n------------------------------------------------------------------------\n-- Properties of ⌊_/2⌋ and ⌈_/2⌉\n------------------------------------------------------------------------\n\n⌊n/2⌋-mono : ⌊_/2⌋ Preserves _≤_ ⟶ _≤_\n⌊n/2⌋-mono z≤n = z≤n\n⌊n/2⌋-mono (s≤s z≤n) = z≤n\n⌊n/2⌋-mono (s≤s (s≤s m≤n)) = s≤s (⌊n/2⌋-mono m≤n)\n\n⌈n/2⌉-mono : ⌈_/2⌉ Preserves _≤_ ⟶ _≤_\n⌈n/2⌉-mono m≤n = ⌊n/2⌋-mono (s≤s m≤n)\n\n⌊n/2⌋≤⌈n/2⌉ : ∀ n → ⌊ n /2⌋ ≤ ⌈ n /2⌉\n⌊n/2⌋≤⌈n/2⌉ zero = z≤n\n⌊n/2⌋≤⌈n/2⌉ (suc zero) = z≤n\n⌊n/2⌋≤⌈n/2⌉ (suc (suc n)) = s≤s (⌊n/2⌋≤⌈n/2⌉ n)\n\n⌊n/2⌋+⌈n/2⌉≡n : ∀ n → ⌊ n /2⌋ + ⌈ n /2⌉ ≡ n\n⌊n/2⌋+⌈n/2⌉≡n zero = refl\n⌊n/2⌋+⌈n/2⌉≡n (suc n) = begin-equality\n ⌊ suc n /2⌋ + suc ⌊ n /2⌋ ≡⟨ +-comm ⌊ suc n /2⌋ (suc ⌊ n /2⌋) ⟩\n suc ⌊ n /2⌋ + ⌊ suc n /2⌋ ≡⟨⟩\n suc (⌊ n /2⌋ + ⌊ suc n /2⌋) ≡⟨ cong suc (⌊n/2⌋+⌈n/2⌉≡n n) ⟩\n suc n ∎\n\n⌊n/2⌋≤n : ∀ n → ⌊ n /2⌋ ≤ n\n⌊n/2⌋≤n zero = z≤n\n⌊n/2⌋≤n (suc zero) = z≤n\n⌊n/2⌋≤n (suc (suc n)) = s≤s (≤-step (⌊n/2⌋≤n n))\n\n⌊n/2⌋′?_\n\n_≤′?_ : Decidable _≤′_\nm ≤′? n = map′ ≤⇒≤′ ≤′⇒≤ (m ≤? n)\n\n_<′?_ : Decidable _<′_\nm <′? n = suc m ≤′? n\n\n_≥′?_ : Decidable _≥′_\n_≥′?_ = flip _≤′?_\n\n_>′?_ : Decidable _>′_\n_>′?_ = flip _<′?_\n\nm≤′m+n : ∀ m n → m ≤′ m + n\nm≤′m+n m n = ≤⇒≤′ (m≤m+n m n)\n\nn≤′m+n : ∀ m n → n ≤′ m + n\nn≤′m+n zero n = ≤′-refl\nn≤′m+n (suc m) n = ≤′-step (n≤′m+n m n)\n\n⌈n/2⌉≤′n : ∀ n → ⌈ n /2⌉ ≤′ n\n⌈n/2⌉≤′n zero = ≤′-refl\n⌈n/2⌉≤′n (suc zero) = ≤′-refl\n⌈n/2⌉≤′n (suc (suc n)) = s≤′s (≤′-step (⌈n/2⌉≤′n n))\n\n⌊n/2⌋≤′n : ∀ n → ⌊ n /2⌋ ≤′ n\n⌊n/2⌋≤′n zero = ≤′-refl\n⌊n/2⌋≤′n (suc n) = ≤′-step (⌈n/2⌉≤′n n)\n\n------------------------------------------------------------------------\n-- Properties of _≤″_ and _<″_\n------------------------------------------------------------------------\n\nm<ᵇn⇒1+m+[n-1+m]≡n : ∀ m n → T (m <ᵇ n) → suc m + (n ∸ suc m) ≡ n\nm<ᵇn⇒1+m+[n-1+m]≡n m n lt = m+[n∸m]≡n (<ᵇ⇒< m n lt)\n\nm<ᵇ1+m+n : ∀ m {n} → T (m <ᵇ suc (m + n))\nm<ᵇ1+m+n m = <⇒<ᵇ (m≤m+n (suc m) _)\n\n<ᵇ⇒<″ : ∀ {m n} → T (m <ᵇ n) → m <″ n\n<ᵇ⇒<″ {m} {n} leq = less-than-or-equal (m+[n∸m]≡n (<ᵇ⇒< m n leq))\n\n<″⇒<ᵇ : ∀ {m n} → m <″ n → T (m <ᵇ n)\n<″⇒<ᵇ {m} (less-than-or-equal refl) = <⇒<ᵇ (m≤m+n (suc m) _)\n\n-- equivalence to _≤_\n\n≤″⇒≤ : _≤″_ ⇒ _≤_\n≤″⇒≤ {zero} (less-than-or-equal refl) = z≤n\n≤″⇒≤ {suc m} (less-than-or-equal refl) =\n s≤s (≤″⇒≤ (less-than-or-equal refl))\n\n≤⇒≤″ : _≤_ ⇒ _≤″_\n≤⇒≤″ = less-than-or-equal ∘ m+[n∸m]≡n\n\n-- NB: we use the builtin function `_<ᵇ_ : (m n : ℕ) → Bool` here so\n-- that the function quickly decides whether to return `yes` or `no`.\n-- It still takes a linear amount of time to generate the proof if it\n-- is inspected. We expect the main benefit to be visible for compiled\n-- code: the backend erases proofs.\n\ninfix 4 _<″?_ _≤″?_ _≥″?_ _>″?_\n\n_<″?_ : Decidable _<″_\nm <″? n = map′ <ᵇ⇒<″ <″⇒<ᵇ (T? (m <ᵇ n))\n\n_≤″?_ : Decidable _≤″_\nzero ≤″? n = yes (less-than-or-equal refl)\nsuc m ≤″? n = m <″? n\n\n_≥″?_ : Decidable _≥″_\n_≥″?_ = flip _≤″?_\n\n_>″?_ : Decidable _>″_\n_>″?_ = flip _<″?_\n\n≤″-irrelevant : Irrelevant _≤″_\n≤″-irrelevant {m} (less-than-or-equal eq₁)\n (less-than-or-equal eq₂)\n with +-cancelˡ-≡ m (trans eq₁ (sym eq₂))\n... | refl = cong less-than-or-equal (≡-irrelevant eq₁ eq₂)\n\n<″-irrelevant : Irrelevant _<″_\n<″-irrelevant = ≤″-irrelevant\n\n>″-irrelevant : Irrelevant _>″_\n>″-irrelevant = ≤″-irrelevant\n\n≥″-irrelevant : Irrelevant _≥″_\n≥″-irrelevant = ≤″-irrelevant\n\n------------------------------------------------------------------------\n-- Properties of _≤‴_\n------------------------------------------------------------------------\n\n≤‴⇒≤″ : ∀{m n} → m ≤‴ n → m ≤″ n\n≤‴⇒≤″ {m = m} ≤‴-refl = less-than-or-equal {k = 0} (+-identityʳ m)\n≤‴⇒≤″ {m = m} (≤‴-step x) = less-than-or-equal (trans (+-suc m _) (_≤″_.proof ind)) where\n ind = ≤‴⇒≤″ x\n\nm≤‴m+k : ∀{m n k} → m + k ≡ n → m ≤‴ n\nm≤‴m+k {m} {k = zero} refl = subst (λ z → m ≤‴ z) (sym (+-identityʳ m)) (≤‴-refl {m})\nm≤‴m+k {m} {k = suc k} proof\n = ≤‴-step (m≤‴m+k {k = k} (trans (sym (+-suc m _)) proof))\n\n≤″⇒≤‴ : ∀{m n} → m ≤″ n → m ≤‴ n\n≤″⇒≤‴ (less-than-or-equal {k} proof) = m≤‴m+k proof\n\n------------------------------------------------------------------------\n-- Other properties\n------------------------------------------------------------------------\n\n-- If there is an injection from a type to ℕ, then the type has\n-- decidable equality.\n\neq? : ∀ {a} {A : Set a} → A ↣ ℕ → Decidable {A = A} _≡_\neq? inj = via-injection inj _≟_\n\n\n------------------------------------------------------------------------\n-- DEPRECATED NAMES\n------------------------------------------------------------------------\n-- Please use the new names as continuing support for the old names is\n-- not guaranteed.\n\n-- Version 0.14\n\n_*-mono_ = *-mono-≤\n{-# WARNING_ON_USAGE _*-mono_\n\"Warning: _*-mono_ was deprecated in v0.14.\nPlease use *-mono-≤ instead.\"\n#-}\n_+-mono_ = +-mono-≤\n{-# WARNING_ON_USAGE _+-mono_\n\"Warning: _+-mono_ was deprecated in v0.14.\nPlease use +-mono-≤ instead.\"\n#-}\n+-right-identity = +-identityʳ\n{-# WARNING_ON_USAGE +-right-identity\n\"Warning: +-right-identity was deprecated in v0.14.\nPlease use +-identityʳ instead.\"\n#-}\n*-right-zero = *-zeroʳ\n{-# WARNING_ON_USAGE *-right-zero\n\"Warning: *-right-zero was deprecated in v0.14.\nPlease use *-zeroʳ instead.\"\n#-}\ndistribʳ-*-+ = *-distribʳ-+\n{-# WARNING_ON_USAGE distribʳ-*-+\n\"Warning: distribʳ-*-+ was deprecated in v0.14.\nPlease use *-distribʳ-+ instead.\"\n#-}\n*-distrib-∸ʳ = *-distribʳ-∸\n{-# WARNING_ON_USAGE *-distrib-∸ʳ\n\"Warning: *-distrib-∸ʳ was deprecated in v0.14.\nPlease use *-distribʳ-∸ instead.\"\n#-}\ncancel-+-left = +-cancelˡ-≡\n{-# WARNING_ON_USAGE cancel-+-left\n\"Warning: cancel-+-left was deprecated in v0.14.\nPlease use +-cancelˡ-≡ instead.\"\n#-}\ncancel-+-left-≤ = +-cancelˡ-≤\n{-# WARNING_ON_USAGE cancel-+-left-≤\n\"Warning: cancel-+-left-≤ was deprecated in v0.14.\nPlease use +-cancelˡ-≤ instead.\"\n#-}\ncancel-*-right = *-cancelʳ-≡\n{-# WARNING_ON_USAGE cancel-*-right\n\"Warning: cancel-*-right was deprecated in v0.14.\nPlease use *-cancelʳ-≡ instead.\"\n#-}\ncancel-*-right-≤ = *-cancelʳ-≤\n{-# WARNING_ON_USAGE cancel-*-right-≤\n\"Warning: cancel-*-right-≤ was deprecated in v0.14.\nPlease use *-cancelʳ-≤ instead.\"\n#-}\nstrictTotalOrder = <-strictTotalOrder\n{-# WARNING_ON_USAGE strictTotalOrder\n\"Warning: strictTotalOrder was deprecated in v0.14.\nPlease use <-strictTotalOrder instead.\"\n#-}\nisCommutativeSemiring = *-+-isCommutativeSemiring\n{-# WARNING_ON_USAGE isCommutativeSemiring\n\"Warning: isCommutativeSemiring was deprecated in v0.14.\nPlease use *-+-isCommutativeSemiring instead.\"\n#-}\ncommutativeSemiring = *-+-commutativeSemiring\n{-# WARNING_ON_USAGE commutativeSemiring\n\"Warning: commutativeSemiring was deprecated in v0.14.\nPlease use *-+-commutativeSemiring instead.\"\n#-}\nisDistributiveLattice = ⊓-⊔-isDistributiveLattice\n{-# WARNING_ON_USAGE isDistributiveLattice\n\"Warning: isDistributiveLattice was deprecated in v0.14.\nPlease use ⊓-⊔-isDistributiveLattice instead.\"\n#-}\ndistributiveLattice = ⊓-⊔-distributiveLattice\n{-# WARNING_ON_USAGE distributiveLattice\n\"Warning: distributiveLattice was deprecated in v0.14.\nPlease use ⊓-⊔-distributiveLattice instead.\"\n#-}\n⊔-⊓-0-isSemiringWithoutOne = ⊔-⊓-isSemiringWithoutOne\n{-# WARNING_ON_USAGE ⊔-⊓-0-isSemiringWithoutOne\n\"Warning: ⊔-⊓-0-isSemiringWithoutOne was deprecated in v0.14.\nPlease use ⊔-⊓-isSemiringWithoutOne instead.\"\n#-}\n⊔-⊓-0-isCommutativeSemiringWithoutOne = ⊔-⊓-isCommutativeSemiringWithoutOne\n{-# WARNING_ON_USAGE ⊔-⊓-0-isCommutativeSemiringWithoutOne\n\"Warning: ⊔-⊓-0-isCommutativeSemiringWithoutOne was deprecated in v0.14.\nPlease use ⊔-⊓-isCommutativeSemiringWithoutOne instead.\"\n#-}\n⊔-⊓-0-commutativeSemiringWithoutOne = ⊔-⊓-commutativeSemiringWithoutOne\n{-# WARNING_ON_USAGE ⊔-⊓-0-commutativeSemiringWithoutOne\n\"Warning: ⊔-⊓-0-commutativeSemiringWithoutOne was deprecated in v0.14.\nPlease use ⊔-⊓-commutativeSemiringWithoutOne instead.\"\n#-}\n\n-- Version 0.15\n\n¬i+1+j≤i = m+1+n≰m\n{-# WARNING_ON_USAGE ¬i+1+j≤i\n\"Warning: ¬i+1+j≤i was deprecated in v0.15.\nPlease use m+1+n≰m instead.\"\n#-}\n≤-steps = ≤-stepsˡ\n{-# WARNING_ON_USAGE ≤-steps\n\"Warning: ≤-steps was deprecated in v0.15.\nPlease use ≤-stepsˡ instead.\"\n#-}\n\n-- Version 0.17\n\ni∸k∸j+j∸k≡i+j∸k : ∀ i j k → i ∸ (k ∸ j) + (j ∸ k) ≡ i + j ∸ k\ni∸k∸j+j∸k≡i+j∸k zero j k = cong (_+ (j ∸ k)) (0∸n≡0 (k ∸ j))\ni∸k∸j+j∸k≡i+j∸k (suc i) j zero = cong (λ x → suc i ∸ x + j) (0∸n≡0 j)\ni∸k∸j+j∸k≡i+j∸k (suc i) zero (suc k) = begin-equality\n i ∸ k + 0 ≡⟨ +-identityʳ _ ⟩\n i ∸ k ≡⟨ cong (_∸ k) (sym (+-identityʳ _)) ⟩\n i + 0 ∸ k ∎\ni∸k∸j+j∸k≡i+j∸k (suc i) (suc j) (suc k) = begin-equality\n suc i ∸ (k ∸ j) + (j ∸ k) ≡⟨ i∸k∸j+j∸k≡i+j∸k (suc i) j k ⟩\n suc i + j ∸ k ≡⟨ cong (_∸ k) (sym (+-suc i j)) ⟩\n i + suc j ∸ k ∎\n{-# WARNING_ON_USAGE i∸k∸j+j∸k≡i+j∸k\n\"Warning: i∸k∸j+j∸k≡i+j∸k was deprecated in v0.17.\"\n#-}\nim≡jm+n⇒[i∸j]m≡n : ∀ i j m n → i * m ≡ j * m + n → (i ∸ j) * m ≡ n\nim≡jm+n⇒[i∸j]m≡n i j m n eq = begin-equality\n (i ∸ j) * m ≡⟨ *-distribʳ-∸ m i j ⟩\n (i * m) ∸ (j * m) ≡⟨ cong (_∸ j * m) eq ⟩\n (j * m + n) ∸ (j * m) ≡⟨ cong (_∸ j * m) (+-comm (j * m) n) ⟩\n (n + j * m) ∸ (j * m) ≡⟨ m+n∸n≡m n (j * m) ⟩\n n ∎\n{-# WARNING_ON_USAGE im≡jm+n⇒[i∸j]m≡n\n\"Warning: im≡jm+n⇒[i∸j]m≡n was deprecated in v0.17.\"\n#-}\n≤+≢⇒< = ≤∧≢⇒<\n{-# WARNING_ON_USAGE ≤+≢⇒<\n\"Warning: ≤+≢⇒< was deprecated in v0.17.\nPlease use ≤∧≢⇒< instead.\"\n#-}\n\n-- Version 1.0\n\n≤-irrelevance = ≤-irrelevant\n{-# WARNING_ON_USAGE ≤-irrelevance\n\"Warning: ≤-irrelevance was deprecated in v1.0.\nPlease use ≤-irrelevant instead.\"\n#-}\n<-irrelevance = <-irrelevant\n{-# WARNING_ON_USAGE <-irrelevance\n\"Warning: <-irrelevance was deprecated in v1.0.\nPlease use <-irrelevant instead.\"\n#-}\n\n-- Version 1.1\n\ni+1+j≢i = m+1+n≢m\n{-# WARNING_ON_USAGE i+1+j≢i\n\"Warning: i+1+j≢i was deprecated in v1.1.\nPlease use m+1+n≢m instead.\"\n#-}\ni+j≡0⇒i≡0 = m+n≡0⇒m≡0\n{-# WARNING_ON_USAGE i+j≡0⇒i≡0\n\"Warning: i+j≡0⇒i≡0 was deprecated in v1.1.\nPlease use m+n≡0⇒m≡0 instead.\"\n#-}\ni+j≡0⇒j≡0 = m+n≡0⇒n≡0\n{-# WARNING_ON_USAGE i+j≡0⇒j≡0\n\"Warning: i+j≡0⇒j≡0 was deprecated in v1.1.\nPlease use m+n≡0⇒n≡0 instead.\"\n#-}\ni+1+j≰i = m+1+n≰m\n{-# WARNING_ON_USAGE i+1+j≰i\n\"Warning: i+1+j≰i was deprecated in v1.1.\nPlease use m+1+n≰m instead.\"\n#-}\ni*j≡0⇒i≡0∨j≡0 = m*n≡0⇒m≡0∨n≡0\n{-# WARNING_ON_USAGE i*j≡0⇒i≡0∨j≡0\n\"Warning: i*j≡0⇒i≡0∨j≡0 was deprecated in v1.1.\nPlease use m*n≡0⇒m≡0∨n≡0 instead.\"\n#-}\ni*j≡1⇒i≡1 = m*n≡1⇒m≡1\n{-# WARNING_ON_USAGE i*j≡1⇒i≡1\n\"Warning: i*j≡1⇒i≡1 was deprecated in v1.1.\nPlease use m*n≡1⇒m≡1 instead.\"\n#-}\ni*j≡1⇒j≡1 = m*n≡1⇒n≡1\n{-# WARNING_ON_USAGE i*j≡1⇒j≡1\n\"Warning: i*j≡1⇒j≡1 was deprecated in v1.1.\nPlease use m*n≡1⇒n≡1 instead.\"\n#-}\ni^j≡0⇒i≡0 = m^n≡0⇒m≡0\n{-# WARNING_ON_USAGE i^j≡0⇒i≡0\n\"Warning: i^j≡0⇒i≡0 was deprecated in v1.1.\nPlease use m^n≡0⇒m≡0 instead.\"\n#-}\ni^j≡1⇒j≡0∨i≡1 = m^n≡1⇒n≡0∨m≡1\n{-# WARNING_ON_USAGE i^j≡1⇒j≡0∨i≡1\n\"Warning: i^j≡1⇒j≡0∨i≡1 was deprecated in v1.1.\nPlease use m^n≡1⇒n≡0∨m≡1 instead.\"\n#-}\n[i+j]∸[i+k]≡j∸k = [m+n]∸[m+o]≡n∸o\n{-# WARNING_ON_USAGE [i+j]∸[i+k]≡j∸k\n\"Warning: [i+j]∸[i+k]≡j∸k was deprecated in v1.1.\nPlease use [m+n]∸[m+o]≡n∸o instead.\"\n#-}\nm≢0⇒suc[pred[m]]≡m = suc[pred[n]]≡n\n{-# WARNING_ON_USAGE m≢0⇒suc[pred[m]]≡m\n\"Warning: m≢0⇒suc[pred[m]]≡m was deprecated in v1.1.\nPlease use suc[pred[n]]≡n instead.\"\n#-}\nn≡m⇒∣n-m∣≡0 = m≡n⇒∣m-n∣≡0\n{-# WARNING_ON_USAGE n≡m⇒∣n-m∣≡0\n\"Warning: n≡m⇒∣n-m∣≡0 was deprecated in v1.1.\nPlease use m≡n⇒∣m-n∣≡0 instead.\"\n#-}\n∣n-m∣≡0⇒n≡m = ∣m-n∣≡0⇒m≡n\n{-# WARNING_ON_USAGE ∣n-m∣≡0⇒n≡m\n\"Warning: ∣n-m∣≡0⇒n≡m was deprecated in v1.1.\nPlease use ∣m-n∣≡0⇒m≡n instead.\"\n#-}\n∣n-m∣≡n∸m⇒m≤n = ∣m-n∣≡m∸n⇒n≤m\n{-# WARNING_ON_USAGE ∣n-m∣≡n∸m⇒m≤n\n\"Warning: ∣n-m∣≡n∸m⇒m≤n was deprecated in v1.1.\nPlease use ∣m-n∣≡m∸n⇒n≤m instead.\"\n#-}\n∣n-n+m∣≡m = ∣m-m+n∣≡n\n{-# WARNING_ON_USAGE ∣n-n+m∣≡m\n\"Warning: ∣n-n+m∣≡m was deprecated in v1.1.\nPlease use ∣m-m+n∣≡n instead.\"\n#-}\n∣n+m-n+o∣≡∣m-o| = ∣m+n-m+o∣≡∣n-o|\n{-# WARNING_ON_USAGE ∣n+m-n+o∣≡∣m-o|\n\"Warning: ∣n+m-n+o∣≡∣m-o| was deprecated in v1.1.\nPlease use ∣m+n-m+o∣≡∣n-o| instead.\"\n#-}\nn∸m≤∣n-m∣ = m∸n≤∣m-n∣\n{-# WARNING_ON_USAGE n∸m≤∣n-m∣\n\"Warning: n∸m≤∣n-m∣ was deprecated in v1.1.\nPlease use m∸n≤∣m-n∣ instead.\"\n#-}\n∣n-m∣≤n⊔m = ∣m-n∣≤m⊔n\n{-# WARNING_ON_USAGE ∣n-m∣≤n⊔m\n\"Warning: ∣n-m∣≤n⊔m was deprecated in v1.1.\nPlease use ∣m-n∣≤m⊔n instead.\"\n#-}\nn≤m+n : ∀ m n → n ≤ m + n\nn≤m+n m n = subst (n ≤_) (+-comm n m) (m≤m+n n m)\n{-# WARNING_ON_USAGE n≤m+n\n\"Warning: n≤m+n was deprecated in v1.1.\nPlease use m≤n+m instead (note, you will need to switch the argument order).\"\n#-}\nn≤m+n∸m : ∀ m n → n ≤ m + (n ∸ m)\nn≤m+n∸m m zero = z≤n\nn≤m+n∸m zero (suc n) = ≤-refl\nn≤m+n∸m (suc m) (suc n) = s≤s (n≤m+n∸m m n)\n{-# WARNING_ON_USAGE n≤m+n∸m\n\"Warning: n≤m+n∸m was deprecated in v1.1.\nPlease use m≤n+m∸n instead (note, you will need to switch the argument order).\"\n#-}\n∣n-m∣≡[n∸m]∨[m∸n] : ∀ m n → (∣ n - m ∣ ≡ n ∸ m) ⊎ (∣ n - m ∣ ≡ m ∸ n)\n∣n-m∣≡[n∸m]∨[m∸n] m n with ≤-total m n\n... | inj₁ m≤n = inj₁ $ m≤n⇒∣n-m∣≡n∸m m≤n\n... | inj₂ n≤m = inj₂ $ begin-equality\n ∣ n - m ∣ ≡⟨ ∣-∣-comm n m ⟩\n ∣ m - n ∣ ≡⟨ m≤n⇒∣n-m∣≡n∸m n≤m ⟩\n m ∸ n ∎\n{-# WARNING_ON_USAGE ∣n-m∣≡[n∸m]∨[m∸n]\n\"Warning: ∣n-m∣≡[n∸m]∨[m∸n] was deprecated in v1.1.\nPlease use ∣m-n∣≡[m∸n]∨[n∸m] instead (note, you will need to switch the argument order).\"\n#-}\n\n-- Version 1.2\n\n+-*-suc = *-suc\n{-# WARNING_ON_USAGE +-*-suc\n\"Warning: +-*-suc was deprecated in v1.2.\nPlease use *-suc instead.\"\n#-}\n\nn∸m≤n : ∀ m n → n ∸ m ≤ n\nn∸m≤n m n = m∸n≤m n m\n{-# WARNING_ON_USAGE n∸m≤n\n\"Warning: n∸m≤n was deprecated in v1.2.\nPlease use m∸n≤m instead (note, you will need to switch the argument order).\"\n#-}\n\n-- Version 1.3\n\n∀[m≤n⇒m≢o]⇒o (λ()) (λ()) (s≤s z≤n)\n<-cmp (suc i) (suc j) with <-cmp i j\n... | tri< i i≮j i≢j j (i≮j ∘ ℕₚ.≤-pred) (i≢j ∘ suc-injective) (s≤s j ∀iPi zero ⊛ sequence (∀iPi ∘ suc)\n\nmodule _ {f} {F : Set f → Set f} (RF : RawFunctor F) where\n\n open RawFunctor RF\n\n sequence⁻¹ : ∀ {A : Set f} {P : Pred A f} →\n F (∀ i → P i) → (∀ i → F (P i))\n sequence⁻¹ F∀iPi i = (λ f → f i) <$> F∀iPi\n\n------------------------------------------------------------------------\n-- If there is an injection from a type to a finite set, then the type\n-- has decidable equality.\n\nmodule _ {a} {A : Set a} where\n\n eq? : ∀ {n} → A ↣ Fin n → B.Decidable {A = A} _≡_\n eq? inj = Dec.via-injection inj _≟_\n\n------------------------------------------------------------------------\n-- DEPRECATED NAMES\n------------------------------------------------------------------------\n-- Please use the new names as continuing support for the old names is\n-- not guaranteed.\n\n-- Version 0.15\n\ncmp = <-cmp\n{-# WARNING_ON_USAGE cmp\n\"Warning: cmp was deprecated in v0.15.\nPlease use <-cmp instead.\"\n#-}\nstrictTotalOrder = <-strictTotalOrder\n{-# WARNING_ON_USAGE strictTotalOrder\n\"Warning: strictTotalOrder was deprecated in v0.15.\nPlease use <-strictTotalOrder instead.\"\n#-}\n\n-- Version 0.16\n\nto-from = toℕ-fromℕ\n{-# WARNING_ON_USAGE to-from\n\"Warning: to-from was deprecated in v0.16.\nPlease use toℕ-fromℕ instead.\"\n#-}\nfrom-to = fromℕ-toℕ\n{-# WARNING_ON_USAGE from-to\n\"Warning: from-to was deprecated in v0.16.\nPlease use fromℕ-toℕ instead.\"\n#-}\nbounded = toℕ 𝔹 -> 𝔹\ntt || _ = tt\nff || b = b\n\n\n\ndata day : Set where\n monday : day\n tuesday : day\n wednesday : day\n thursday : day\n friday : day\n saturday : day\n sunday : day\n\nnextday : day -> day\nnextday monday = tuesday\nnextday tuesday = wednesday\nnextday wednesday = thursday\nnextday thursday = friday\nnextday friday = saturday\nnextday saturday = sunday\nnextday sunday = monday\n\n\n\ndata suit : Set where\n hearts : suit\n spades : suit\n diamonds : suit\n clubs : suit\n\nis-red : suit -> 𝔹\nis-red hearts = tt\nis-red spades = ff\nis-red diamonds = tt\nis-red clubs = ff\n", "meta": {"hexsha": "79495aeff0bc37206f71290df1e9df7161c993ae", "size": 628, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "ch1.agda", "max_stars_repo_name": "razvan-panda/Verified-Functional-Programming-in-Agda", "max_stars_repo_head_hexsha": "8593e7ea70e95c145b2d8911a9a5f29f3016dafe", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ch1.agda", "max_issues_repo_name": "razvan-panda/Verified-Functional-Programming-in-Agda", "max_issues_repo_head_hexsha": "8593e7ea70e95c145b2d8911a9a5f29f3016dafe", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ch1.agda", "max_forks_repo_name": "razvan-panda/Verified-Functional-Programming-in-Agda", "max_forks_repo_head_hexsha": "8593e7ea70e95c145b2d8911a9a5f29f3016dafe", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 14.2727272727, "max_line_length": 28, "alphanum_fraction": 0.6608280255, "num_tokens": 216, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.837619959279793, "lm_q2_score": 0.7185943925708561, "lm_q1q2_score": 0.6019090058438881}} {"text": "------------------------------------------------------------------------\n-- A container for finite binary trees with information in internal\n-- nodes\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Equality\n\nmodule Container.Tree\n {c⁺} (eq : ∀ {a p} → Equality-with-J a p c⁺) where\n\nopen Derived-definitions-and-properties eq\n\nopen import Prelude hiding (id; _∘_; List; []; _∷_)\n\nopen import Bijection eq using (_↔_; module _↔_)\nopen import Container eq hiding (Shape; Position)\nopen import Container.List eq hiding (fold; fold-lemma)\nopen import Function-universe eq\nimport Tree eq as Tree\n\n------------------------------------------------------------------------\n-- The type\n\n-- Shapes.\n\ndata Shape : Type where\n lf : Shape\n nd : Shape → Shape → Shape\n\n-- Positions.\n\ndata Position : Shape → Type where\n root : ∀ {l r} → Position (nd l r)\n left : ∀ {l r} → Position l → Position (nd l r)\n right : ∀ {l r} → Position r → Position (nd l r)\n\n-- Trees.\n\nTree : Container lzero\nTree = Shape ▷ Position\n\n------------------------------------------------------------------------\n-- An isomorphism\n\n-- The type of shapes is isomorphic to Tree.Tree ⊤.\n--\n-- This lemma is included because it was mentioned in the paper \"Bag\n-- Equivalence via a Proof-Relevant Membership Relation\".\n\nShape↔Tree-⊤ : Shape ↔ Tree.Tree ⊤\nShape↔Tree-⊤ = record\n { surjection = record\n { logical-equivalence = record\n { to = to\n ; from = from\n }\n ; right-inverse-of = to∘from\n }\n ; left-inverse-of = from∘to\n }\n where\n to : Shape → Tree.Tree ⊤\n to lf = Tree.leaf\n to (nd l r) = Tree.node (to l) tt (to r)\n\n from : Tree.Tree ⊤ → Shape\n from Tree.leaf = lf\n from (Tree.node l tt r) = nd (from l) (from r)\n\n to∘from : ∀ t → to (from t) ≡ t\n to∘from Tree.leaf = refl _\n to∘from (Tree.node l tt r) =\n cong₂ (λ l r → Tree.node l tt r) (to∘from l) (to∘from r)\n\n from∘to : ∀ s → from (to s) ≡ s\n from∘to lf = refl _\n from∘to (nd l r) = cong₂ nd (from∘to l) (from∘to r)\n\n------------------------------------------------------------------------\n-- Constructors\n\n-- Leaves.\n\nleaf : {A : Type} → ⟦ Tree ⟧ A\nleaf = (lf , λ ())\n\n-- Internal nodes.\n\nnode : {A : Type} → ⟦ Tree ⟧ A → A → ⟦ Tree ⟧ A → ⟦ Tree ⟧ A\nnode (l , lkup-l) x (r , lkup-r) =\n ( nd l r\n , λ { root → x\n ; (left p) → lkup-l p\n ; (right p) → lkup-r p\n }\n )\n\n-- Even if we don't assume extensionality we can prove that\n-- intensionally distinct implementations of the constructors are bag\n-- equivalent.\n\nleaf≈ : {A : Type} {lkup : _ → A} →\n _≈-bag_ {C₂ = Tree} leaf (lf , lkup)\nleaf≈ _ = record\n { surjection = record\n { logical-equivalence = record\n { to = λ { (() , _) }\n ; from = λ { (() , _) }\n }\n ; right-inverse-of = λ { (() , _) }\n }\n ; left-inverse-of = λ { (() , _) }\n }\n\nnode≈ : ∀ {A : Type} {l r} {lkup : _ → A} →\n _≈-bag_ {C₂ = Tree}\n (node (l , lkup ∘ left) (lkup root) (r , lkup ∘ right))\n (nd l r , lkup)\nnode≈ _ = record\n { surjection = record\n { logical-equivalence = record\n { to = λ { (root , eq) → (root , eq)\n ; (left p , eq) → (left p , eq)\n ; (right p , eq) → (right p , eq)\n }\n ; from = λ { (root , eq) → (root , eq)\n ; (left p , eq) → (left p , eq)\n ; (right p , eq) → (right p , eq)\n }\n }\n ; right-inverse-of = λ { (root , eq) → refl _\n ; (left p , eq) → refl _\n ; (right p , eq) → refl _\n }\n }\n ; left-inverse-of = λ { (root , eq) → refl _\n ; (left p , eq) → refl _\n ; (right p , eq) → refl _\n }\n }\n\n-- Any lemmas for the constructors.\n\nAny-leaf : ∀ {A : Type} (P : A → Type) →\n Any P leaf ↔ ⊥₀\nAny-leaf _ = record\n { surjection = record\n { logical-equivalence = record\n { to = λ { (() , _) }\n ; from = λ ()\n }\n ; right-inverse-of = λ ()\n }\n ; left-inverse-of = λ { (() , _) }\n }\n\nAny-node : ∀ {A : Type} (P : A → Type) {l x r} →\n Any P (node l x r) ↔ Any P l ⊎ P x ⊎ Any P r\nAny-node _ {l = _ , _} {r = _ , _} = record\n { surjection = record\n { logical-equivalence = record\n { to = λ { (root , eq) → inj₂ (inj₁ eq)\n ; (left p , eq) → inj₁ (p , eq)\n ; (right p , eq) → inj₂ (inj₂ (p , eq))\n }\n ; from = λ { (inj₁ (p , eq)) → (left p , eq)\n ; (inj₂ (inj₁ eq)) → (root , eq)\n ; (inj₂ (inj₂ (p , eq))) → (right p , eq)\n }\n }\n ; right-inverse-of = λ { (inj₁ (p , eq)) → refl _\n ; (inj₂ (inj₁ eq)) → refl _\n ; (inj₂ (inj₂ (p , eq))) → refl _\n }\n }\n ; left-inverse-of = λ { (root , eq) → refl _\n ; (left p , eq) → refl _\n ; (right p , eq) → refl _\n }\n }\n\n------------------------------------------------------------------------\n-- More functions\n\n-- Singleton trees.\n\nsingleton : {A : Type} → A → ⟦ Tree ⟧ A\nsingleton x = node leaf x leaf\n\n-- Any lemma for singleton.\n\nAny-singleton : ∀ {A : Type} (P : A → Type) {x} →\n Any P (singleton x) ↔ P x\nAny-singleton P {x} =\n Any P (singleton x) ↔⟨⟩\n Any P (node leaf x leaf) ↔⟨ Any-node P ⟩\n Any P leaf ⊎ P x ⊎ Any P leaf ↔⟨ Any-leaf P ⊎-cong id ⊎-cong Any-leaf P ⟩\n ⊥ ⊎ P x ⊎ ⊥ ↔⟨ ⊎-left-identity ⟩\n P x ⊎ ⊥ ↔⟨ ⊎-right-identity ⟩\n P x □\n\n-- For the design considerations underlying the inclusion of fold and\n-- fold-lemma, see Container.List.fold/fold-lemma.\n\n-- A fold for trees. (Well, this is not a catamorphism, it is a\n-- paramorphism.)\n\nfold : {A B : Type} →\n B → (⟦ Tree ⟧ A → A → ⟦ Tree ⟧ A → B → B → B) → ⟦ Tree ⟧ A → B\nfold {A} {B} fl fn = uncurry fold′\n where\n fold′ : (s : Shape) → (Position s → A) → B\n fold′ lf lkup = fl\n fold′ (nd l r) lkup =\n fn (l , lkup ∘ left )\n (lkup root)\n (r , lkup ∘ right)\n (fold′ l (lkup ∘ left ))\n (fold′ r (lkup ∘ right))\n\n-- A lemma which can be used to prove properties about fold.\n--\n-- The \"respects bag equivalence\" argument could be omitted if\n-- equality of functions were extensional.\n\nfold-lemma : ∀ {A B : Type}\n {fl : B} {fn : ⟦ Tree ⟧ A → A → ⟦ Tree ⟧ A → B → B → B}\n (P : ⟦ Tree ⟧ A → B → Type) →\n (∀ t₁ t₂ → t₁ ≈-bag t₂ → ∀ b → P t₁ b → P t₂ b) →\n P leaf fl →\n (∀ l x r b₁ b₂ →\n P l b₁ → P r b₂ → P (node l x r) (fn l x r b₁ b₂)) →\n ∀ t → P t (fold fl fn t)\nfold-lemma {A} {fl = fl} {fn} P resp P-le P-no = uncurry fold-lemma′\n where\n fold-lemma′ : (s : Shape) (lkup : Position s → A) →\n P (s , lkup) (fold fl fn (s , lkup))\n fold-lemma′ lf lkup = resp _ _ leaf≈ _ P-le\n fold-lemma′ (nd l r) lkup = resp _ _ node≈ _ $\n P-no _ _ _ _ _\n (fold-lemma′ l (lkup ∘ left ))\n (fold-lemma′ r (lkup ∘ right))\n\n-- Inorder flattening of a tree.\n\nflatten : {A : Type} → ⟦ Tree ⟧ A → ⟦ List ⟧ A\nflatten = fold [] (λ _ x _ xs ys → xs ++ x ∷ ys)\n\n-- Flatten does not add or remove any elements.\n\nflatten≈ : {A : Type} (t : ⟦ Tree ⟧ A) → flatten t ≈-bag t\nflatten≈ = fold-lemma\n (λ t xs → xs ≈-bag t)\n\n (λ t₁ t₂ t₁≈t₂ xs xs≈t₁ z →\n z ∈ xs ↔⟨ xs≈t₁ z ⟩\n z ∈ t₁ ↔⟨ t₁≈t₂ z ⟩\n z ∈ t₂ □)\n\n (λ z →\n z ∈ [] ↔⟨ Any-[] (λ x → z ≡ x) ⟩\n ⊥ ↔⟨ inverse $ Any-leaf (λ x → z ≡ x) ⟩\n z ∈ leaf □)\n\n (λ l x r xs ys xs≈l ys≈r z →\n z ∈ xs ++ x ∷ ys ↔⟨ Any-++ (λ x → z ≡ x) _ _ ⟩\n z ∈ xs ⊎ z ∈ x ∷ ys ↔⟨ id ⊎-cong Any-∷ (λ x → z ≡ x) ⟩\n z ∈ xs ⊎ z ≡ x ⊎ z ∈ ys ↔⟨ xs≈l z ⊎-cong id ⊎-cong ys≈r z ⟩\n z ∈ l ⊎ z ≡ x ⊎ z ∈ r ↔⟨ inverse $ Any-node (λ x → z ≡ x) ⟩\n z ∈ node l x r □)\n", "meta": {"hexsha": "8bed8974553ecca5c96852754cd7affc17cdc2eb", "size": 8159, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Container/Tree.agda", "max_stars_repo_name": "nad/equality", "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_issues_repo_path": "src/Container/Tree.agda", "max_issues_repo_name": "nad/equality", "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Container/Tree.agda", "max_forks_repo_name": "nad/equality", "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.8864468864, "max_line_length": 76, "alphanum_fraction": 0.4424561834, "num_tokens": 2723, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199552262967, "lm_q2_score": 0.7185943805178138, "lm_q1q2_score": 0.6019089928351996}} {"text": "-- Andreas, 2017-01-20, issue #1817 is fixed\n\nopen import Agda.Builtin.Size\nopen import Agda.Builtin.Nat renaming (Nat to ℕ)\n\n-- Function\n\n_$_ : ∀{a b}{A : Set a}{B : Set b} →(A → B) → A → B\nf $ x = f x\n\ncase_of_ : ∀{a b}{A : Set a}{B : Set b} → A → (A → B) → B\ncase x of f = f x\n\n-- Size\n\ndata SizeLt (i : Size) : Set where\n size : (j : Size< i) → SizeLt i\n\ngetSize : ∀{i} → SizeLt i → Size\ngetSize (size j) = j\n\n-- List\n\ndata List (A : Set) : Set where\n [] : List A\n _∷_ : (x : A) (xs : List A) → List A\n\nfor : ∀{A B} (xs : List A) (f : A → B) → List B\nfor [] f = []\nfor (x ∷ xs) f = f x ∷ for xs f\n\n-- BT\n\ndata Var : (n : ℕ) → Set where\n vz : ∀{n} → Var (suc n)\n vs : ∀{n} → (x : Var n) → Var (suc n)\n\nmutual\n record BT (i : Size) (n : ℕ) : Set where\n inductive; constructor Λ\n field nabs : ℕ\n var : Var (nabs + n)\n args : List (BT' i (nabs + n))\n\n record BT' (i : Size) (n : ℕ) : Set where\n coinductive; constructor delay\n field force : ∀{j : SizeLt i} → BT (getSize j) n\n\nopen BT'\n\n-- Renaming\n\ndata Ope : (n m : ℕ) → Set where\n id : ∀{n} → Ope n n\n weak : ∀{n m} (ρ : Ope n m) → Ope (1 + n) m\n lift : ∀{n m} (ρ : Ope n m) → Ope (1 + n) (1 + m)\n\nlifts : ∀ k {n m} (ρ : Ope n m) → Ope (k + n) (k + m)\nlifts 0 ρ = ρ\nlifts (suc k) ρ = lift (lifts k ρ)\n\nrenVar : ∀{n m} (ρ : Ope n m) (x : Var m) → Var n\nrenVar id x = x\nrenVar (weak ρ) x = vs (renVar ρ x)\nrenVar (lift ρ) vz = vz\nrenVar (lift ρ) (vs x) = vs (renVar ρ x)\n\nren : ∀{i n m} (ρ : Ope n m) (t : BT i m) → BT i n\nren {i} ρ₀ (Λ n x ts) = Λ n (renVar ρ x) $ for ts \\ t → delay\n \\{ {size j} → ren {j} ρ $ force t {size j} }\n where ρ = lifts n ρ₀\n", "meta": {"hexsha": "f440877afbbe460ce8bd75c3c972e30477e993d6", "size": 1678, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1817.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Succeed/Issue1817.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_forks_repo_path": "test/Succeed/Issue1817.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 23.3055555556, "max_line_length": 61, "alphanum_fraction": 0.4988081049, "num_tokens": 740, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933447152497, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.6018997191003342}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Some derivable properties\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Algebra\n\nmodule Algebra.Properties.Lattice {l₁ l₂} (L : Lattice l₁ l₂) where\n\nopen Lattice L\nopen import Algebra.Structures\nopen import Algebra.FunctionProperties _≈_\nimport Algebra.Properties.Semilattice as SL\nopen import Relation.Binary\nimport Relation.Binary.Lattice as R\nopen import Relation.Binary.Reasoning.Setoid setoid\nopen import Function\nopen import Function.Equality using (_⟨$⟩_)\nopen import Function.Equivalence using (_⇔_; module Equivalence)\nopen import Data.Product using (_,_; swap)\n\n------------------------------------------------------------------------\n-- Every lattice contains two semilattices.\n\n∧-idempotent : Idempotent _∧_\n∧-idempotent x = begin\n x ∧ x ≈⟨ refl ⟨ ∧-cong ⟩ sym (∨-absorbs-∧ _ _) ⟩\n x ∧ (x ∨ x ∧ x) ≈⟨ ∧-absorbs-∨ _ _ ⟩\n x ∎\n\n∨-idempotent : Idempotent _∨_\n∨-idempotent x = begin\n x ∨ x ≈⟨ refl ⟨ ∨-cong ⟩ sym (∧-idempotent _) ⟩\n x ∨ x ∧ x ≈⟨ ∨-absorbs-∧ _ _ ⟩\n x ∎\n\n∧-isSemilattice : IsSemilattice _≈_ _∧_\n∧-isSemilattice = record\n { isBand = record\n { isSemigroup = record\n { isMagma = record\n { isEquivalence = isEquivalence\n ; ∙-cong = ∧-cong\n }\n ; assoc = ∧-assoc\n }\n ; idem = ∧-idempotent\n }\n ; comm = ∧-comm\n }\n\n∧-semilattice : Semilattice l₁ l₂\n∧-semilattice = record { isSemilattice = ∧-isSemilattice }\n\n∨-isSemilattice : IsSemilattice _≈_ _∨_\n∨-isSemilattice = record\n { isBand = record\n { isSemigroup = record\n { isMagma = record\n { isEquivalence = isEquivalence\n ; ∙-cong = ∨-cong\n }\n ; assoc = ∨-assoc\n }\n ; idem = ∨-idempotent\n }\n ; comm = ∨-comm\n }\n\n∨-semilattice : Semilattice l₁ l₂\n∨-semilattice = record { isSemilattice = ∨-isSemilattice }\n\nopen SL ∧-semilattice public using (poset)\nopen Poset poset using (_≤_; isPartialOrder)\n\n------------------------------------------------------------------------\n-- The dual construction is also a lattice.\n\n∧-∨-isLattice : IsLattice _≈_ _∧_ _∨_\n∧-∨-isLattice = record\n { isEquivalence = isEquivalence\n ; ∨-comm = ∧-comm\n ; ∨-assoc = ∧-assoc\n ; ∨-cong = ∧-cong\n ; ∧-comm = ∨-comm\n ; ∧-assoc = ∨-assoc\n ; ∧-cong = ∨-cong\n ; absorptive = swap absorptive\n }\n\n∧-∨-lattice : Lattice _ _\n∧-∨-lattice = record { isLattice = ∧-∨-isLattice }\n\n------------------------------------------------------------------------\n-- Every algebraic lattice can be turned into an order-theoretic one.\n\nisOrderTheoreticLattice : R.IsLattice _≈_ _≤_ _∨_ _∧_\nisOrderTheoreticLattice = record\n { isPartialOrder = isPartialOrder\n ; supremum = supremum\n ; infimum = infimum\n }\n where\n ∧-meetSemilattice = SL.orderTheoreticMeetSemilattice ∧-semilattice\n ∨-joinSemilattice = SL.orderTheoreticJoinSemilattice ∨-semilattice\n open R.MeetSemilattice ∧-meetSemilattice using (infimum)\n open R.JoinSemilattice ∨-joinSemilattice using ()\n renaming (supremum to supremum′; _≤_ to _≤′_)\n\n -- An alternative but equivalent interpretation of the order _≤_.\n\n sound : ∀ {x y} → x ≤′ y → x ≤ y\n sound {x} {y} y≈y∨x = sym $ begin\n x ∧ y ≈⟨ ∧-congˡ y≈y∨x ⟩\n x ∧ (y ∨ x) ≈⟨ ∧-congˡ (∨-comm y x) ⟩\n x ∧ (x ∨ y) ≈⟨ ∧-absorbs-∨ x y ⟩\n x ∎\n\n complete : ∀ {x y} → x ≤ y → x ≤′ y\n complete {x} {y} x≈x∧y = sym $ begin\n y ∨ x ≈⟨ ∨-congˡ x≈x∧y ⟩\n y ∨ (x ∧ y) ≈⟨ ∨-congˡ (∧-comm x y) ⟩\n y ∨ (y ∧ x) ≈⟨ ∨-absorbs-∧ y x ⟩\n y ∎\n\n supremum : R.Supremum _≤_ _∨_\n supremum x y =\n let x∨y≥x , x∨y≥y , greatest = supremum′ x y\n in sound x∨y≥x , sound x∨y≥y ,\n λ z x≤z y≤z → sound (greatest z (complete x≤z) (complete y≤z))\n\norderTheoreticLattice : R.Lattice _ _ _\norderTheoreticLattice = record { isLattice = isOrderTheoreticLattice }\n\n------------------------------------------------------------------------\n-- One can replace the underlying equality with an equivalent one.\n\nreplace-equality : {_≈′_ : Rel Carrier l₂} →\n (∀ {x y} → x ≈ y ⇔ (x ≈′ y)) → Lattice _ _\nreplace-equality {_≈′_} ≈⇔≈′ = record\n { _≈_ = _≈′_\n ; _∧_ = _∧_\n ; _∨_ = _∨_\n ; isLattice = record\n { isEquivalence = record\n { refl = to ⟨$⟩ refl\n ; sym = λ x≈y → to ⟨$⟩ sym (from ⟨$⟩ x≈y)\n ; trans = λ x≈y y≈z → to ⟨$⟩ trans (from ⟨$⟩ x≈y) (from ⟨$⟩ y≈z)\n }\n ; ∨-comm = λ x y → to ⟨$⟩ ∨-comm x y\n ; ∨-assoc = λ x y z → to ⟨$⟩ ∨-assoc x y z\n ; ∨-cong = λ x≈y u≈v → to ⟨$⟩ ∨-cong (from ⟨$⟩ x≈y) (from ⟨$⟩ u≈v)\n ; ∧-comm = λ x y → to ⟨$⟩ ∧-comm x y\n ; ∧-assoc = λ x y z → to ⟨$⟩ ∧-assoc x y z\n ; ∧-cong = λ x≈y u≈v → to ⟨$⟩ ∧-cong (from ⟨$⟩ x≈y) (from ⟨$⟩ u≈v)\n ; absorptive = (λ x y → to ⟨$⟩ ∨-absorbs-∧ x y)\n , (λ x y → to ⟨$⟩ ∧-absorbs-∨ x y)\n }\n } where open module E {x y} = Equivalence (≈⇔≈′ {x} {y})\n", "meta": {"hexsha": "71daa6585a68d7cdbdf6e372b7fd4b3a15d38c5f", "size": 5128, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Properties/Lattice.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Properties/Lattice.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Properties/Lattice.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.4601226994, "max_line_length": 74, "alphanum_fraction": 0.5142355694, "num_tokens": 1925, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933271118222, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.6018997061773143}} {"text": "module nfa136 where\n\nopen import logic\nopen import nfa\nopen import automaton \nopen import Data.List\nopen import finiteSet\nopen import Data.Fin\nopen import Relation.Binary.PropositionalEquality hiding ( [_] )\n\ndata StatesQ : Set where\n q1 : StatesQ\n q2 : StatesQ\n q3 : StatesQ\n\ndata A2 : Set where\n a0 : A2\n b0 : A2\n\nfinStateQ : FiniteSet StatesQ \nfinStateQ = record {\n Q←F = Q←F\n ; F←Q = F←Q\n ; finiso→ = finiso→\n ; finiso← = finiso←\n } where\n Q←F : Fin 3 → StatesQ\n Q←F zero = q1\n Q←F (suc zero) = q2\n Q←F (suc (suc zero)) = q3\n F←Q : StatesQ → Fin 3\n F←Q q1 = zero\n F←Q q2 = suc zero\n F←Q q3 = suc (suc zero)\n finiso→ : (q : StatesQ) → Q←F (F←Q q) ≡ q\n finiso→ q1 = refl\n finiso→ q2 = refl\n finiso→ q3 = refl\n finiso← : (f : Fin 3) → F←Q (Q←F f) ≡ f\n finiso← zero = refl\n finiso← (suc zero) = refl\n finiso← (suc (suc zero)) = refl\n finiso← (suc (suc (suc ()))) \n\ntransition136 : StatesQ → A2 → StatesQ → Bool\ntransition136 q1 b0 q2 = true\ntransition136 q1 a0 q1 = true -- q1 → ep → q3\ntransition136 q2 a0 q2 = true\ntransition136 q2 a0 q3 = true\ntransition136 q2 b0 q3 = true\ntransition136 q3 a0 q1 = true\ntransition136 _ _ _ = false\n\nend136 : StatesQ → Bool\nend136 q1 = true\nend136 _ = false\n\nstart136 : StatesQ → Bool\nstart136 q1 = true\nstart136 _ = false\n\nexists136 : (StatesQ → Bool) → Bool\nexists136 f = f q1 \\/ f q2 \\/ f q3\n\nto-list-136 : (StatesQ → Bool) → List StatesQ\nto-list-136 f = tl1 where\n tl3 : List StatesQ \n tl3 with f q3\n ... | true = q3 ∷ []\n ... | false = []\n tl2 : List StatesQ \n tl2 with f q2\n ... | true = q2 ∷ tl3 \n ... | false = tl3\n tl1 : List StatesQ \n tl1 with f q1\n ... | true = q1 ∷ tl2\n ... | false = tl2\n\nnfa136 : NAutomaton StatesQ A2\nnfa136 = record { Nδ = transition136; Nend = end136 }\n\nexample136-1 = Naccept nfa136 exists136 start136( a0 ∷ b0 ∷ a0 ∷ a0 ∷ [] )\n\nt146-1 = Ntrace nfa136 exists136 to-list-136 start136( a0 ∷ b0 ∷ a0 ∷ a0 ∷ [] )\n\nexample136-0 = Naccept nfa136 exists136 start136( a0 ∷ [] )\n\nexample136-2 = Naccept nfa136 exists136 start136( b0 ∷ a0 ∷ b0 ∷ a0 ∷ b0 ∷ [] )\nt146-2 = Ntrace nfa136 exists136 to-list-136 start136( b0 ∷ a0 ∷ b0 ∷ a0 ∷ b0 ∷ [] )\n\nopen FiniteSet\n\nnx : (StatesQ → Bool) → (List A2 ) → StatesQ → Bool\nnx now [] = now\nnx now ( i ∷ ni ) = (Nmoves nfa136 exists136 (nx now ni) i )\n\nexample136-3 = to-list-136 start136\nexample136-4 = to-list-136 (nx start136 ( a0 ∷ b0 ∷ a0 ∷ [] ))\n\nopen import sbconst2\n\nfm136 : Automaton ( StatesQ → Bool ) A2\nfm136 = subset-construction exists136 nfa136 \n\nopen NAutomaton\n\nlemma136 : ( x : List A2 ) → Naccept nfa136 exists136 start136 x ≡ accept fm136 start136 x \nlemma136 x = lemma136-1 x start136 where\n lemma136-1 : ( x : List A2 ) → ( states : StatesQ → Bool )\n → Naccept nfa136 exists136 states x ≡ accept fm136 states x \n lemma136-1 [] _ = refl\n lemma136-1 (h ∷ t) states = lemma136-1 t (δconv exists136 (Nδ nfa136) states h)\n", "meta": {"hexsha": "b4ee9c4ffbd31dbb1a211fb78e7d06bf4ced11e1", "size": 3050, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/nfa136.agda", "max_stars_repo_name": "shinji-kono/automaton-in-agda", "max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/nfa136.agda", "max_issues_repo_name": "shinji-kono/automaton-in-agda", "max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/nfa136.agda", "max_forks_repo_name": "shinji-kono/automaton-in-agda", "max_forks_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.7543859649, "max_line_length": 92, "alphanum_fraction": 0.6055737705, "num_tokens": 1164, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.819893335913536, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.6018997031000916}} {"text": "{-# OPTIONS --cubical #-}\n\nmodule Type.Cubical.Quotient where\n\nopen import Functional\nimport Lvl\nopen import Structure.Type.Identity\nopen import Type.Cubical\nopen import Type.Cubical.Path.Equality\nopen import Type\nopen import Syntax.Function\n\nprivate variable ℓ ℓₗ : Lvl.Level\nprivate variable T A B : Type{ℓ}\nprivate variable x y : T\nprivate variable P : T → Type{ℓ}\nprivate variable _▫_ : T → T → Type{ℓ}\n\ndata Quotient(_▫_ : T → T → Type{ℓ}) : Type{Lvl.of(T) Lvl.⊔ ℓ} where\n class : T → Quotient(_▫_)\n class-extensionalityₗ : (class x ≡ class y) ← (x ▫ y)\n\nopen import Type.Cubical.Path\nopen import Type.Cubical.Univalence\nopen import Type.Properties.MereProposition\nopen import Structure.Relator.Equivalence\nopen import Structure.Relator.Properties\n\nmodule _ (P : Quotient(_▫_) → Type{ℓ}) ⦃ prop-P : ∀{c} → MereProposition(P(c)) ⦄ where\n Quotient-property-pathP : ∀{x y}{px : P(x)}{py : P(y)} → (xy : x ≡ y) → PathP(\\i → P(xy i)) px py\n Quotient-property-pathP {x}{y}{px}{py} xy = IdentityEliminator.elim Path-identity-eliminator (xy ↦ (∀{px}{py} → PathP(\\i → P(xy i)) px py)) (\\{c} → uniqueness(P(c))) {x}{y} xy {px}{py}\n\n class-property : (∀{a} → P(class a)) → (∀{c} → P(c))\n class-property p {class a} = p{a}\n class-property p {class-extensionalityₗ {x} {y} xy i} = Quotient-property-pathP {px = p{x}}{py = p{y}} (class-extensionalityₗ xy) i\n\n-- TODO: Use Structuve.Function.Surjective when it is generalized to support Type.Cubical.Logic.∃. The difference is that Type.Cubical.Logic.∃ is a mere propositions while surjective uses existence defined as Σ which is not\nopen import Type.Cubical.Logic\nclass-surjective : ∀{y} → ∃(x ↦ class{_▫_ = _▫_} x ≡ y)\nclass-surjective{_▫_ = _▫_} = class-property(y ↦ ∃(x ↦ class{_▫_ = _▫_} x ≡ y)) (\\{a} → [∃]-intro a ⦃ reflexivity(_≡_) ⦄)\n\n-- Note: The following holds by definition: ∀{P : (A → B) → Type{ℓ}}{f}{p} → P(f) → P(Quotient-recursion f p ∘ class).\nQuotient-recursion : (f : A → B) → (∀{a b} → (a ▫ b) → (f(a) ≡ f(b))) → (Quotient(_▫_) → B)\nQuotient-recursion f _ (class x) = f(x)\nQuotient-recursion _ p (class-extensionalityₗ xy i) = p xy i\n\nmodule _ where\n open import Structure.Function\n open import Structure.Setoid\n\n Quotient-function : ∀{ℓₑ₁ ℓₑ₂}{equiv-A : Equiv{ℓₑ₁}(A)}{equiv-B : Equiv{ℓₑ₂}(B)} ⦃ sub : (Equiv._≡_ equiv-B) ⊆₂ Path ⦄ (f : A → B) ⦃ func : Function ⦃ equiv-A ⦄ ⦃ equiv-B ⦄ f ⦄ → (Quotient(Equiv._≡_ equiv-A) → B)\n Quotient-function {equiv-B = equiv-B} f(x) = Quotient-recursion f (sub₂(Equiv._≡_ equiv-B)(Path) ∘ congruence₁ ⦃ _ ⦄ ⦃ _ ⦄ (f)) x\n\nmodule _ ⦃ equivalence : Equivalence(_▫_) ⦄ ⦃ prop : ∀{x y} → MereProposition(x ▫ y) ⦄ where\n class-extensionalityᵣ : (class{_▫_ = _▫_} x ≡ class y) → (x ▫ y)\n class-extensionalityᵣ {x = x} {y = y} p = sub₂(_≡_)(_→ᶠ_) ⦃ Path-coercion ⦄ xx-xy (reflexivity(_▫_)) where\n xx-xy : (x ▫ x) ≡ (x ▫ y)\n xx-xy i = Quotient-recursion (x ▫_) (\\ab → propositional-extensionalityₗ ([↔]-intro (swap(transitivity(_▫_)) (symmetry(_▫_) ab)) (swap(transitivity(_▫_)) ab))) (p i)\n\n class-extensionality : (class{_▫_ = _▫_} x ≡ class y) ↔ (x ▫ y)\n class-extensionality = [↔]-intro class-extensionalityₗ class-extensionalityᵣ\n\nmodule Syntax where\n _/_ : (T : Type{ℓ}) → (T → T → Type{ℓₗ}) → Type\n _ / (_▫_) = Quotient(_▫_)\n\n [_] : T → (T / (_▫_))\n [_] = class\n", "meta": {"hexsha": "cd8507c679a8eaf33a98d55c05bdefbf4e82e5dc", "size": 3290, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Type/Cubical/Quotient.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Type/Cubical/Quotient.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Type/Cubical/Quotient.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.6811594203, "max_line_length": 223, "alphanum_fraction": 0.6431610942, "num_tokens": 1293, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933359135361, "lm_q2_score": 0.7341195152660687, "lm_q1q2_score": 0.6018996983307251}} {"text": "-- Andreas, 2014-06-27, issue raised by fsfbugs\n-- {-# OPTIONS -v interaction.give:10 -v tc:20 -v tc.conv.sort:30 #-}\n\nopen import Common.Level\n\nrecord R (p r : Level) : Set (lsuc (p ⊔ r)) where\n field\n P : Set p\n _~_ : P -> P -> Set r\n f : (p p' : P) -> {!p ~ p'!} -- Give (p ~ p') here!\n\n\n-- PROBLEM WAS:\n-- When issuing C-c C-SPC, Agda complains\n-- Set (r ⊔ p) != Set (suc r ⊔ suc p)\n-- even though removing the hole manually (by removing '{!' and '!}')\n-- gives a well-typed definition.\n\n-- REASON WAS:\n-- Conversion.leqSort produced equality rather than subtyping constraint\n-- upon postponement:\n-- does (f : (p p' : P) → ?0 p r P _~_ p p') → f\n-- of sort Setω\n-- fit in Set (lsuc r ⊔ lsuc p) ?\n-- adding constraint [0] dLub (Set p)\n-- (λ p → dLub (Set p) (λ p' → Set (_4 p r P _~_ p p')))\n-- == Set (lsuc r ⊔ lsuc p)\n\n-- WORKS NOW\n", "meta": {"hexsha": "72ee7ec89a42e69719090a66d041e9f0c4922f97", "size": 907, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue1205.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/interaction/Issue1205.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/interaction/Issue1205.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 30.2333333333, "max_line_length": 78, "alphanum_fraction": 0.5402425579, "num_tokens": 318, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117855317473, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.6018258783093555}} {"text": "{-\n\nConstant structure: _ ↦ A\n\n-}\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Structures.Relational.Constant where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Structure\nopen import Cubical.Foundations.RelationalStructure\nopen import Cubical.HITs.PropositionalTruncation\nopen import Cubical.HITs.SetQuotients\n\nopen import Cubical.Structures.Constant\n\nprivate\n variable\n ℓ ℓ' : Level\n\n-- Structured relations\n\nmodule _ (A : hSet ℓ') where\n\n ConstantRelStr : StrRel {ℓ = ℓ} (ConstantStructure (A .fst)) ℓ'\n ConstantRelStr _ a₀ a₁ = a₀ ≡ a₁\n\n constantSuitableRel : SuitableStrRel {ℓ = ℓ} (ConstantStructure (A .fst)) ConstantRelStr\n constantSuitableRel .quo _ _ _ = isContrSingl _\n constantSuitableRel .symmetric _ = sym\n constantSuitableRel .transitive _ _ = _∙_\n constantSuitableRel .set _ = A .snd\n constantSuitableRel .prop _ = A .snd\n\n constantRelMatchesEquiv : StrRelMatchesEquiv {ℓ = ℓ} ConstantRelStr (ConstantEquivStr (A .fst))\n constantRelMatchesEquiv _ _ _ = idEquiv _\n\n constantRelAction : StrRelAction {ℓ = ℓ} ConstantRelStr\n constantRelAction .actStr _ a = a\n constantRelAction .actStrId _ = refl\n constantRelAction .actRel _ a a' p = p\n\n constantPositiveRel : PositiveStrRel {ℓ = ℓ} constantSuitableRel\n constantPositiveRel .act = constantRelAction\n constantPositiveRel .reflexive a = refl\n constantPositiveRel .detransitive R R' p = ∣ _ , p , refl ∣\n constantPositiveRel .quo R = isoToIsEquiv isom\n where\n open Iso\n isom : Iso _ _\n isom .fun = _\n isom .inv = [_]\n isom .rightInv _ = refl\n isom .leftInv = elimProp (λ _ → squash/ _ _) (λ a → refl)\n", "meta": {"hexsha": "c853b4824a996fe99f95445fb4c8b28e4b5af7fa", "size": 1776, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Structures/Relational/Constant.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Structures/Relational/Constant.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/Structures/Relational/Constant.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.6206896552, "max_line_length": 97, "alphanum_fraction": 0.7443693694, "num_tokens": 551, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085808877581, "lm_q2_score": 0.766293653760418, "lm_q1q2_score": 0.601776981777889}} {"text": "------------------------------------------------------------------------------\n-- Properties related with lists (using induction on the FOTC lists type)\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOTC.Data.List.PropertiesByInductionI where\n\nopen import Common.FOL.Relation.Binary.EqReasoning\n\nopen import FOTC.Base\nopen import FOTC.Base.List\nopen import FOTC.Base.List.PropertiesI\nopen import FOTC.Data.List\nopen import FOTC.Data.Nat.Type\n\n------------------------------------------------------------------------------\n-- Congruence properties\n\n++-leftCong : ∀ {xs ys zs} → xs ≡ ys → xs ++ zs ≡ ys ++ zs\n++-leftCong refl = refl\n\n------------------------------------------------------------------------------\n-- Totality properties\n\nlengthList-N : ∀ {xs} → List xs → N (length xs)\nlengthList-N = List-ind A A[] h\n where\n A : D → Set\n A ds = N (length ds)\n\n A[] : A []\n A[] = subst N (sym length-[]) nzero\n\n h : ∀ a {as} → A as → A (a ∷ as)\n h a {as} Aas = subst N (sym (length-∷ a as)) (nsucc Aas)\n\n------------------------------------------------------------------------------\n\n++-leftIdentity : ∀ xs → [] ++ xs ≡ xs\n++-leftIdentity = ++-[]\n\n++-assoc : ∀ {xs} → List xs → ∀ ys zs → (xs ++ ys) ++ zs ≡ xs ++ ys ++ zs\n++-assoc Lxs ys zs = List-ind A A[] h Lxs\n where\n A : D → Set\n A as = (as ++ ys) ++ zs ≡ as ++ ys ++ zs\n\n A[] : A []\n A[] = ([] ++ ys) ++ zs ≡⟨ ++-leftCong (++-leftIdentity ys) ⟩\n ys ++ zs ≡⟨ sym (++-leftIdentity (ys ++ zs)) ⟩\n [] ++ ys ++ zs ∎\n\n h : ∀ a {as} → A as → A (a ∷ as)\n h a {as} Aas =\n ((a ∷ as) ++ ys) ++ zs ≡⟨ ++-leftCong (++-∷ a as ys) ⟩\n (a ∷ (as ++ ys)) ++ zs ≡⟨ ++-∷ a (as ++ ys) zs ⟩\n a ∷ ((as ++ ys) ++ zs) ≡⟨ ∷-rightCong Aas ⟩\n a ∷ (as ++ ys ++ zs) ≡⟨ sym (++-∷ a as (ys ++ zs)) ⟩\n (a ∷ as) ++ ys ++ zs ∎\n", "meta": {"hexsha": "850fddcb61c93c2d8e4b8c17cd3414b284566cfd", "size": 2016, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/FOTC/Data/List/PropertiesByInductionI.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/FOTC/Data/List/PropertiesByInductionI.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/FOTC/Data/List/PropertiesByInductionI.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 31.5, "max_line_length": 78, "alphanum_fraction": 0.4092261905, "num_tokens": 613, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737869342623, "lm_q2_score": 0.7490872187162396, "lm_q1q2_score": 0.6016472182003763}} {"text": "open import Level using (_⊔_)\nopen import Function using (_$_)\n\nopen import Data.Empty using (⊥)\n\nopen import Relation.Nullary using (yes; no)\nopen import Relation.Nullary.Negation using (contradiction)\nopen import Relation.Binary using (Rel; Reflexive; Transitive; Antisymmetric; _Respects₂_; _Respectsʳ_; _Respectsˡ_; Symmetric; Decidable; Irrelevant)\nopen import Relation.Binary.PropositionalEquality using (_≡_) renaming (refl to ≡-refl; cong to ≡-cong)\n\nopen import Data.Product using (_×_; _,_; proj₁; proj₂)\n\nopen import Algebra.Bundles using (CommutativeSemiring)\n\nmodule AKS.Algebra.Divisibility {c ℓ} (S : CommutativeSemiring c ℓ) where\n\nopen import AKS.Nat using (ℕ; _<_; <-irrelevant)\nopen import AKS.Nat.WellFounded using (Acc; acc; <-well-founded)\n\nopen CommutativeSemiring S using (_+_; _*_; 0#; 1#) renaming (Carrier to C)\nopen CommutativeSemiring S using (_≈_; setoid; refl; sym; trans)\nopen import Relation.Binary.Reasoning.Setoid setoid\nopen CommutativeSemiring S using (+-cong; +-congˡ; +-congʳ; +-identityʳ; +-comm; +-assoc)\nopen CommutativeSemiring S using (*-assoc; *-identityˡ; *-identityʳ; *-congˡ; *-congʳ; zeroˡ; zeroʳ; distribʳ; distribˡ; *-comm)\nopen import Algebra.Core using (Op₂)\nopen import Algebra.Definitions _≈_ using (Commutative; Congruent₂; LeftCongruent; RightCongruent)\n\nopen import AKS.Algebra.Structures C _≈_ using (module Divisibility; module Modulus)\nopen Divisibility _*_ using (_∣_; _∤_; divides; IsGCD) public\n\ninfix 4 _≉_\n_≉_ : Rel C ℓ\nx ≉ y = x ≈ y → ⊥\n\n∣-refl : Reflexive _∣_\n∣-refl {x} = divides 1# (sym (*-identityˡ x))\n\n∣-trans : Transitive _∣_\n∣-trans {x} {y} {z} (divides q₁ y≈q₁*x) (divides q₂ z≈q₂*y) = divides (q₂ * q₁) $ begin\n z ≈⟨ z≈q₂*y ⟩\n q₂ * y ≈⟨ *-congˡ y≈q₁*x ⟩\n q₂ * (q₁ * x) ≈⟨ sym (*-assoc q₂ q₁ x) ⟩\n (q₂ * q₁) * x ∎\n\n∣-respʳ : _∣_ Respectsʳ _≈_\n∣-respʳ {y} {x₁} {x₂} x₁≈x₂ (divides q x₁≈q*y) = divides q $ begin\n x₂ ≈⟨ sym x₁≈x₂ ⟩\n x₁ ≈⟨ x₁≈q*y ⟩\n q * y ∎\n\n∣-respˡ : _∣_ Respectsˡ _≈_\n∣-respˡ {y} {x₁} {x₂} x₁≈x₂ (divides q y≈q*x₁) = divides q $ begin\n y ≈⟨ y≈q*x₁ ⟩\n q * x₁ ≈⟨ *-congˡ x₁≈x₂ ⟩\n q * x₂ ∎\n\n∣-resp : _∣_ Respects₂ _≈_\n∣-resp = ∣-respʳ , ∣-respˡ\n\ninfix 10 1∣_ _∣0\n\n1∣_ : ∀ n → 1# ∣ n\n1∣ n = divides n (sym (*-identityʳ n))\n\n_∣0 : ∀ n → n ∣ 0#\nn ∣0 = divides 0# (sym (zeroˡ n))\n\n0∣n⇒n≈0 : ∀ {n} → 0# ∣ n → n ≈ 0#\n0∣n⇒n≈0 {n} (divides q n≈q*0) = begin\n n ≈⟨ n≈q*0 ⟩\n q * 0# ≈⟨ zeroʳ q ⟩\n 0# ∎\n\n∣n⇒∣m*n : ∀ i n m → i ∣ n → i ∣ m * n\n∣n⇒∣m*n i n m (divides q n≈q*i) = divides (m * q) $ begin\n m * n ≈⟨ *-congˡ n≈q*i ⟩\n m * (q * i) ≈⟨ sym (*-assoc m q i) ⟩\n m * q * i ∎\n\n∣n⇒∣n*m : ∀ i n m → i ∣ n → i ∣ n * m\n∣n⇒∣n*m i n m i∣n = ∣-respʳ (*-comm m n) (∣n⇒∣m*n i n m i∣n)\n\nmodule GCD {gcd : Op₂ C} (isGCD : IsGCD gcd) (∣-antisym : Antisymmetric _≈_ _∣_) where\n open IsGCD isGCD\n\n ∣1⇒≈1 : ∀ {n} → n ∣ 1# → n ≈ 1#\n ∣1⇒≈1 {n} n∣1 = ∣-antisym n∣1 (1∣ n)\n\n gcd[0,0]≈0 : gcd 0# 0# ≈ 0#\n gcd[0,0]≈0 = ∣-antisym (gcd 0# 0# ∣0) (gcd-greatest ∣-refl ∣-refl)\n\n gcd-comm : Commutative gcd\n gcd-comm a b = ∣-antisym\n (gcd-greatest (gcd[a,b]∣b a b) (gcd[a,b]∣a a b))\n (gcd-greatest (gcd[a,b]∣b b a) (gcd[a,b]∣a b a))\n\n gcd[0,a]≈a : ∀ a → gcd 0# a ≈ a\n gcd[0,a]≈a a = ∣-antisym (gcd[a,b]∣b 0# a) (gcd-greatest (a ∣0) ∣-refl)\n\n gcd[a,0]≈a : ∀ a → gcd a 0# ≈ a\n gcd[a,0]≈a a = ∣-antisym (gcd[a,b]∣a a 0#) (gcd-greatest ∣-refl (a ∣0))\n\n gcd[0,a]≈1⇒a≈1 : ∀ a → gcd 0# a ≈ 1# → a ≈ 1#\n gcd[0,a]≈1⇒a≈1 a gcd[0,a]≈1 = ∣1⇒≈1 (∣-respʳ gcd[0,a]≈1 (gcd-greatest (a ∣0) ∣-refl))\n\n gcd[a,0]≈1⇒a≈1 : ∀ a → gcd a 0# ≈ 1# → a ≈ 1#\n gcd[a,0]≈1⇒a≈1 a gcd[a,0]≈1 = ∣1⇒≈1 (∣-respʳ gcd[a,0]≈1 (gcd-greatest ∣-refl (a ∣0)))\n\n gcd[a,b]≈0⇒a≈0 : ∀ {a b} → gcd a b ≈ 0# → a ≈ 0#\n gcd[a,b]≈0⇒a≈0 {a} {b} gcd[a,b]≈0 = 0∣n⇒n≈0 (∣-respˡ gcd[a,b]≈0 (gcd[a,b]∣a a b))\n\n gcd[a,b]≈0⇒b≈0 : ∀ {a b} → gcd a b ≈ 0# → b ≈ 0#\n gcd[a,b]≈0⇒b≈0 {a} {b} gcd[a,b]≈0 = 0∣n⇒n≈0 (∣-respˡ gcd[a,b]≈0 (gcd[a,b]∣b a b))\n\n gcd[a,1]≈1 : ∀ a → gcd a 1# ≈ 1#\n gcd[a,1]≈1 a = ∣-antisym (gcd[a,b]∣b a 1#) (gcd-greatest (1∣ a) ∣-refl)\n\n gcd[1,a]≈1 : ∀ a → gcd 1# a ≈ 1#\n gcd[1,a]≈1 a = ∣-antisym (gcd[a,b]∣a 1# a) (gcd-greatest ∣-refl (1∣ a))\n\n -- gcd[d*a,d*b]≈d*gcd[a,b] : ∀ a b d → gcd (d * a) (d * b) ≈ d * gcd a b\n -- gcd[d*a,d*b]≈d*gcd[a,b] = ?\n\n a≉0⇒gcd[a,b]≉0 : ∀ a b → a ≉ 0# → gcd a b ≉ 0#\n a≉0⇒gcd[a,b]≉0 a b a≉0 gcd[a,b]≈0 = a≉0 (gcd[a,b]≈0⇒a≈0 gcd[a,b]≈0)\n\n b≉0⇒gcd[a,b]≉0 : ∀ a b → b ≉ 0# → gcd a b ≉ 0#\n b≉0⇒gcd[a,b]≉0 a b b≉0 gcd[a,b]≈0 = b≉0 (gcd[a,b]≈0⇒b≈0 gcd[a,b]≈0)\n\n gcd-cong : Congruent₂ gcd\n gcd-cong {a} {b} {c} {d} a≈b c≈d = ∣-antisym\n (gcd-greatest (∣-respʳ a≈b (gcd[a,b]∣a a c)) (∣-respʳ c≈d (gcd[a,b]∣b a c)))\n (gcd-greatest (∣-respʳ (sym a≈b) (gcd[a,b]∣a b d)) (∣-respʳ (sym c≈d) (gcd[a,b]∣b b d)))\n\n gcd-congˡ : LeftCongruent gcd\n gcd-congˡ c≈d = gcd-cong refl c≈d\n\n gcd-congʳ : RightCongruent gcd\n gcd-congʳ a≈b = gcd-cong a≈b refl\n\n infix 4 _⊥_\n _⊥_ : C → C → Set ℓ\n n ⊥ m = gcd n m ≈ 1#\n\n ⊥-sym : Symmetric _⊥_\n ⊥-sym {x} {y} gcd[x,y]≡1 = begin\n gcd y x ≈⟨ gcd-comm y x ⟩\n gcd x y ≈⟨ gcd[x,y]≡1 ⟩\n 1# ∎\n\n ⊥-respʳ : _⊥_ Respectsʳ _≈_\n ⊥-respʳ {y} {x₁} {x₂} x₁≈x₂ gcd[y,x₁]≈1 = begin\n gcd y x₂ ≈⟨ gcd-congˡ (sym x₁≈x₂) ⟩\n gcd y x₁ ≈⟨ gcd[y,x₁]≈1 ⟩\n 1# ∎\n\n ⊥-respˡ : _⊥_ Respectsˡ _≈_\n ⊥-respˡ {y} {x₁} {x₂} x₁≈x₂ gcd[x₁,y]≈1 = begin\n gcd x₂ y ≈⟨ gcd-congʳ (sym x₁≈x₂) ⟩\n gcd x₁ y ≈⟨ gcd[x₁,y]≈1 ⟩\n 1# ∎\n\n ⊥-resp : _⊥_ Respects₂ _≈_\n ⊥-resp = ⊥-respʳ , ⊥-respˡ\n\n\nmodule _\n (∣_∣ : ∀ n {n≉0 : n ≉ 0#} → ℕ)\n (_div_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C)\n (_mod_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C)\n where\n open Modulus 0# ∣_∣ _mod_\n\n module Euclidean\n (_≈?_ : Decidable _≈_)\n (≈-irrelevant : Irrelevant _≈_)\n (≉-irrelevant : Irrelevant _≉_)\n (division : ∀ n m {m≉0 : m ≉ 0#} → n ≈ m * (n div m) {m≉0} + (n mod m) {m≉0})\n (modulus : ∀ n m {m≉0 : m ≉ 0#} → Remainder n m {m≉0})\n (mod-cong : ∀ {x₁ x₂} {y₁ y₂} → x₁ ≈ x₂ → y₁ ≈ y₂ → ∀ {y₁≉0 y₂≉0} → (x₁ mod y₁) {y₁≉0} ≈ (x₂ mod y₂) {y₂≉0})\n (mod-distribʳ-* : ∀ c a b {b≉0} {b*c≉0} → ((a * c) mod (b * c)) {b*c≉0} ≈ (a mod b) {b≉0} * c)\n where\n\n gcdₕ : ∀ (n m : C) {m≉0 : m ≉ 0#} → Acc _<_ (∣ m ∣ {m≉0}) → C\n gcdₕ n m {m≉0} (acc downward) with modulus n m {m≉0}\n ... | 0≈ r≈0 = m\n ... | 0≉ r≉0 ry with tri x y\n... | tri< _ _ x≯y = x≯y x>y\n... | tri≈ _ _ x≯y = x≯y x>y\n... | tri> x≮y _ _ = x≮y x _ x≉y _ = no x≉y\n\ntri⟶dec< :\n ∀ {a} → {≈ < : Rel a} →\n Trichotomous ≈ < → Decidable <\ntri⟶dec< compare x y with compare x y\n... | tri< x x≮y _ _ = no x≮y\n\nsubst⟶cong :\n {≈ : ∀ {a} → Rel a} →\n (∀ {a} → Reflexive {a} ≈) →\n (∀ {a} → Substitutive {a} ≈) →\n Congruential ≈\nsubst⟶cong {≈ = _≈_} refl subst f {x} x≈y =\n subst (λ y → f x ≈ f y) x≈y refl\n\ncong+trans⟶cong₂ :\n {≈ : ∀ {a} → Rel a} →\n Congruential ≈ → (∀ {a} → Transitive {a} ≈) →\n Congruential₂ ≈\ncong+trans⟶cong₂ cong trans f {x = x} {v = v} x≈y u≈v =\n cong (f x) u≈v ⟨ trans ⟩ cong (flip f v) x≈y\n\nmap-NonEmpty : ∀ {I} {P Q : Rel I} →\n P ⇒ Q → NonEmpty P → NonEmpty Q\nmap-NonEmpty f x = nonEmpty (f (NonEmpty.proof x))\n", "meta": {"hexsha": "dc864e727832d05fa81fcda58808b3c5350429c8", "size": 3313, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Relation/Binary/Consequences.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Relation/Binary/Consequences.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Relation/Binary/Consequences.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 27.3801652893, "max_line_length": 72, "alphanum_fraction": 0.5203742831, "num_tokens": 1449, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506418255927, "lm_q2_score": 0.7905303260722198, "lm_q1q2_score": 0.6013173999094291}} {"text": "module Function.Inverse where\n\nopen import Data.Tuple as Tuple using (_⨯_ ; _,_)\nimport Lvl\nopen import Logic\nopen import Logic.Propositional\nopen import Logic.Predicate\nopen import Functional\nopen import Function.Equals\nopen import Function.Equals.Proofs\nopen import Function.Inverseₗ\nopen import Function.Inverseᵣ\nopen import Structure.Setoid\nopen import Structure.Setoid.Uniqueness\nopen import Structure.Function\nopen import Structure.Function.Domain\nopen import Structure.Function.Domain.Proofs\nopen import Structure.Operator\nopen import Structure.Relator.Properties\nopen import Syntax.Transitivity\nopen import Type\n\nmodule _ {ℓ₁ ℓ₂ ℓₑ₁ ℓₑ₂} {A : Type{ℓ₁}} ⦃ eqA : Equiv{ℓₑ₁}(A) ⦄ {B : Type{ℓ₂}} ⦃ eqB : Equiv{ℓₑ₂}(B) ⦄ where\n private variable f : A → B\n\n -- The inverse function of a bijective function f.\n inv : (f : A → B) → ⦃ inver : Invertible(f) ⦄ → (B → A)\n inv(f) ⦃ inver ⦄ = [∃]-witness inver\n\n module _ {f : A → B} ⦃ inver : Invertible(f) ⦄ where\n inv-inverse : Inverse(f)(inv f)\n inv-inverse = [∧]-elimᵣ([∃]-proof inver)\n\n inv-inverseₗ : Inverseₗ(f)(inv f)\n inv-inverseₗ = [∧]-elimₗ inv-inverse\n\n inv-inverseᵣ : Inverseᵣ(f)(inv f)\n inv-inverseᵣ = [∧]-elimᵣ inv-inverse\n\n inv-function : Function(inv f)\n inv-function = [∧]-elimₗ([∃]-proof inver)\n\n inv-surjective : Surjective(inv f)\n inv-surjective = inverse-surjective ⦃ inver = [∧]-elimᵣ([∃]-proof inver) ⦄\n\n module _ ⦃ func : Function(f) ⦄ where\n inv-injective : Injective(inv f)\n inv-injective = inverse-injective ⦃ inver = [∧]-elimᵣ([∃]-proof inver) ⦄\n\n inv-bijective : Bijective(inv f)\n inv-bijective = inverse-bijective ⦃ inver = [∧]-elimᵣ([∃]-proof inver) ⦄\n\n{-\n module _ {f : A → B} ⦃ inver : Invertible(f) ⦄ ⦃ inv-func : Function(inv f) ⦄ where\n inv-sides-equality : (invₗ(f) ⊜ invᵣ(f))\n inv-sides-equality =\n invₗ(f) 🝖[ _⊜_ ]-[]\n invₗ(f) ∘ id 🝖[ _⊜_ ]-[ [⊜][∘]-binaryOperator-raw {f₁ = invₗ(f)} ⦃ func₂ = {!!} ⦄ (reflexivity(_⊜_)) (intro(inverseᵣ(f)(invᵣ f) ⦃ inv-inverseᵣ ⦄)) ]-sym\n invₗ(f) ∘ (f ∘ invᵣ(f)) 🝖[ _⊜_ ]-[]\n (invₗ(f) ∘ f) ∘ invᵣ(f) 🝖[ _⊜_ ]-[ {!!} ]\n id ∘ invᵣ(f) 🝖[ _⊜_ ]-[]\n invᵣ(f) 🝖-end\n\n-- congruence₂ᵣ(_∘_)(invₗ(f)) ?\n\n -- x₁ ≡ x₂\n -- inv f(y₁) ≡ inv f(y₂)\n\n --f(x₁) ≡ f(x₂)\n --invᵣ f(f(x₁)) ≡ invᵣ f(f(x₂))\n --invᵣ f(f(x₁))\n\n-}\n\n\n\n\n\n\n\n\n\n\n\n\n\n{-\n -- inv is a left inverse function to a bijective f.\n inv-inverseₗ : Inverseₗ(f)(inv f)\n inv-inverseₗ = invᵣ-inverseₗ ⦃ inj = {!invertibleₗ-to-injective!} ⦄\n -- [∃!]-existence-eq-any (bijective(f)) (reflexivity(_≡_))\n\n inv-injective : Injective(inv f)\n inv-injective = {!invᵣ-injective!}-}\n\n\n{-\n -- inv(f) is surjective when f is bijective.\n inv-surjective : Surjective(inv(f))\n Surjective.proof(inv-surjective) {x} = [∃]-intro(f(x)) ⦃ inv-inverseₗ ⦄\n\n inv-unique-inverseᵣ : ∀{f⁻¹} → (f ∘ f⁻¹ ⊜ id) → (f⁻¹ ⊜ inv(f))\n inv-unique-inverseᵣ = invᵣ-unique-inverseᵣ ⦃ surj = bijective-to-surjective(f) ⦄ ⦃ inj = bijective-to-injective(f) ⦄\n\n inv-unique-inverseₗ : ∀{f⁻¹} → ⦃ _ : Function(f⁻¹) ⦄ → (f⁻¹ ∘ f ⊜ id) → (f⁻¹ ⊜ inv(f))\n inv-unique-inverseₗ = invᵣ-unique-inverseₗ ⦃ surj = bijective-to-surjective(f) ⦄\n\n -- inv(f) is a function when f is a function.\n inv-function : Function(inv(f))\n inv-function = invᵣ-function ⦃ surj = bijective-to-surjective(f) ⦄ ⦃ inj = bijective-to-injective(f) ⦄\n\n module _ ⦃ func : Function(f) ⦄ where\n -- inv(f) is injective when f is a function and is bijective.\n inv-injective : Injective(inv f)\n inv-injective = invᵣ-injective ⦃ surj = bijective-to-surjective(f) ⦄\n\n -- inv(f) is bijective when f is a function and is bijective.\n inv-bijective : Bijective(inv(f))\n inv-bijective = injective-surjective-to-bijective(inv(f)) ⦃ inv-injective ⦄ ⦃ inv-surjective ⦄\n-}\n", "meta": {"hexsha": "a946bc744a0e6ff254349135ab7ba308453da77d", "size": 3884, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Function/Inverse.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Function/Inverse.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Function/Inverse.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.0991735537, "max_line_length": 169, "alphanum_fraction": 0.6150875386, "num_tokens": 1512, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473813156294, "lm_q2_score": 0.6893056167854461, "lm_q1q2_score": 0.6013139497289387}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Equality over lists using propositional equality\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary\n\nmodule Data.List.Relation.Binary.Equality.Propositional {a} {A : Set a} where\n\nopen import Data.List\nimport Data.List.Relation.Binary.Equality.Setoid as SetoidEquality\nopen import Relation.Binary.PropositionalEquality\n\n------------------------------------------------------------------------\n-- Publically re-export everything from setoid equality\n\nopen SetoidEquality (setoid A) public\n\n------------------------------------------------------------------------\n-- ≋ is propositional\n\n≋⇒≡ : _≋_ ⇒ _≡_\n≋⇒≡ [] = refl\n≋⇒≡ (refl ∷ xs≈ys) = cong (_ ∷_) (≋⇒≡ xs≈ys)\n\n≡⇒≋ : _≡_ ⇒ _≋_\n≡⇒≋ refl = ≋-refl\n", "meta": {"hexsha": "00882a210a3070316e5344a7dfbd4fa043d9d13a", "size": 902, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Equality/Propositional.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Equality/Propositional.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Equality/Propositional.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.0967741935, "max_line_length": 77, "alphanum_fraction": 0.4645232816, "num_tokens": 215, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473680407889, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.6013139350107017}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import lib.Basics\nopen import lib.NType\nopen import lib.types.Cospan\nopen import lib.types.Pointed\nopen import lib.types.Sigma\n\nmodule lib.types.Pullback where\n\nmodule _ {i j k} (D : Cospan {i} {j} {k}) where\n\n open Cospan D\n\n record Pullback : Type (lmax i (lmax j k)) where\n constructor pullback\n field\n a : A\n b : B\n h : f a == g b\n\n pullback= : {a a' : A} (p : a == a') {b b' : B} (q : b == b')\n {h : f a == g b} {h' : f a' == g b'} (r : h ∙ ap g q == ap f p ∙ h')\n → pullback a b h == pullback a' b' h'\n pullback= idp idp r =\n ap (pullback _ _) (! (∙-unit-r _) ∙ r)\n\n pullback-aβ : {a a' : A} (p : a == a') {b b' : B} (q : b == b')\n {h : f a == g b} {h' : f a' == g b'} (r : h ∙ ap g q == ap f p ∙ h')\n → ap Pullback.a (pullback= p q {h = h} {h' = h'} r) == p\n pullback-aβ idp idp r =\n ap Pullback.a (ap (pullback _ _) (! (∙-unit-r _) ∙ r))\n =⟨ ∘-ap Pullback.a (pullback _ _) _ ⟩\n ap (λ _ → _) (! (∙-unit-r _) ∙ r)\n =⟨ ap-cst _ _ ⟩\n idp =∎\n\n pullback-bβ : {a a' : A} (p : a == a') {b b' : B} (q : b == b')\n {h : f a == g b} {h' : f a' == g b'} (r : h ∙ ap g q == ap f p ∙ h')\n → ap Pullback.b (pullback= p q {h = h} {h' = h'} r) == q\n pullback-bβ idp idp r =\n ap Pullback.b (ap (pullback _ _) (! (∙-unit-r _) ∙ r))\n =⟨ ∘-ap Pullback.b (pullback _ _) _ ⟩\n ap (λ _ → _) (! (∙-unit-r _) ∙ r)\n =⟨ ap-cst _ _ ⟩\n idp =∎\n\nmodule _ {i j k} (D : ⊙Cospan {i} {j} {k}) where\n\n ⊙Pullback : Ptd (lmax i (lmax j k))\n ⊙Pullback =\n ⊙[ Pullback (⊙cospan-out D) ,\n pullback (pt X) (pt Y) (snd f ∙ ! (snd g)) ]\n where open ⊙Cospan D\n\nmodule _ {i j k} (D : Cospan {i} {j} {k}) where\n open Cospan D\n\n pullback-decomp-equiv : Pullback D ≃ Σ (A × B) (λ {(a , b) → f a == g b})\n pullback-decomp-equiv = equiv\n (λ {(pullback a b h) → ((a , b) , h)})\n (λ {((a , b) , h) → pullback a b h})\n (λ _ → idp)\n (λ _ → idp)\n\nmodule _ {i j k} (n : ℕ₋₂) {D : Cospan {i} {j} {k}} where\n open Cospan D\n\n pullback-level : has-level n A → has-level n B → has-level n C\n → has-level n (Pullback D)\n pullback-level pA pB pC =\n equiv-preserves-level ((pullback-decomp-equiv D)⁻¹) $\n Σ-level (×-level pA pB) (λ _ → =-preserves-level pC)\n", "meta": {"hexsha": "a797ca3272d87493df8eda7abaebf0716afda57f", "size": 2274, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/types/Pullback.agda", "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "core/lib/types/Pullback.agda", "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "core/lib/types/Pullback.agda", "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "avg_line_length": 30.7297297297, "max_line_length": 75, "alphanum_fraction": 0.4938434477, "num_tokens": 962, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.855851135937125, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.601261136990945}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import lib.Basics\nopen import lib.NType2\nopen import lib.types.Int\nopen import lib.types.Group\nopen import lib.types.List\nopen import lib.types.Word\nopen import lib.groups.Homomorphism\nopen import lib.groups.Isomorphism\nopen import lib.groups.FreeAbelianGroup\nopen import lib.groups.GeneratedGroup\nopen import lib.types.SetQuotient\n\nmodule lib.groups.Int where\n\nℤ-group-structure : GroupStructure ℤ\nℤ-group-structure = record\n { ident = 0\n ; inv = ℤ~\n ; comp = _ℤ+_\n ; unit-l = ℤ+-unit-l\n ; assoc = ℤ+-assoc\n ; inv-l = ℤ~-inv-l\n }\n\nℤ-group : Group₀\nℤ-group = group _ ℤ-group-structure\n\nℤ-group-is-abelian : is-abelian ℤ-group\nℤ-group-is-abelian = ℤ+-comm\n\nℤ-abgroup : AbGroup₀\nℤ-abgroup = ℤ-group , ℤ-group-is-abelian\n\nprivate\n module OneGeneratorFreeAbGroup = FreeAbelianGroup Unit\n\nOneGenFreeAbGroup : AbGroup lzero\nOneGenFreeAbGroup = OneGeneratorFreeAbGroup.FreeAbGroup\n\nprivate\n module OneGenFreeAbGroup = AbGroup OneGenFreeAbGroup\n\nℤ-iso-FreeAbGroup-Unit : ℤ-group ≃ᴳ OneGenFreeAbGroup.grp\nℤ-iso-FreeAbGroup-Unit = ≃-to-≃ᴳ (equiv to from to-from from-to) to-pres-comp where\n open OneGeneratorFreeAbGroup\n module F = Freeness ℤ-abgroup\n to : Group.El ℤ-group → OneGenFreeAbGroup.El\n to = OneGenFreeAbGroup.exp qw[ inl unit :: nil ]\n from : OneGenFreeAbGroup.El → Group.El ℤ-group\n from = GroupHom.f (F.extend (λ _ → 1))\n abstract\n to-pres-comp = OneGenFreeAbGroup.exp-+ qw[ inl unit :: nil ]\n\n to-from' : ∀ l → to (Word-extendᴳ ℤ-group (λ _ → 1) l) == qw[ l ]\n to-from' nil = idp\n to-from' (inl unit :: nil) = idp\n to-from' (inl unit :: l@(_ :: _)) =\n OneGenFreeAbGroup.exp-succ qw[ inl unit :: nil ] (Word-extendᴳ ℤ-group (λ _ → 1) l)\n ∙ ap (OneGenFreeAbGroup.comp qw[ inl unit :: nil ]) (to-from' l)\n to-from' (inr unit :: nil) = idp\n to-from' (inr unit :: l@(_ :: _)) =\n OneGenFreeAbGroup.exp-pred qw[ inl unit :: nil ] (Word-extendᴳ ℤ-group (λ _ → 1) l)\n ∙ ap (OneGenFreeAbGroup.comp qw[ inr unit :: nil ]) (to-from' l)\n\n to-from : ∀ fs → to (from fs) == fs\n to-from = QuotWord-elim to-from' (λ _ → prop-has-all-paths-↓)\n\n from-to : ∀ z → from (to z) == z\n from-to (pos 0) = idp\n from-to (pos 1) = idp\n from-to (negsucc 0) = idp\n from-to (pos (S (S n))) =\n GroupHom.pres-comp (F.extend (λ _ → 1))\n qw[ inl unit :: nil ] (OneGenFreeAbGroup.exp qw[ inl unit :: nil ] (pos (S n)))\n ∙ ap succ (from-to (pos (S n)))\n from-to (negsucc (S n)) =\n GroupHom.pres-comp (F.extend (λ _ → 1))\n qw[ inr unit :: nil ] (OneGenFreeAbGroup.exp qw[ inl unit :: nil ] (negsucc n))\n ∙ ap pred (from-to (negsucc n))\n\nexp-shom : ∀ {i} {GEl : Type i} (GS : GroupStructure GEl) (g : GEl) → ℤ-group-structure →ᴳˢ GS\nexp-shom GS g = group-structure-hom (GroupStructure.exp GS g) (GroupStructure.exp-+ GS g)\n\nexp-hom : ∀ {i} (G : Group i) (g : Group.El G) → ℤ-group →ᴳ G\nexp-hom G g = group-hom (Group.exp G g) (Group.exp-+ G g)\n", "meta": {"hexsha": "4795b27b5ebf3bef970ff6e7911dbb26d6ad15b9", "size": 2982, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/groups/Int.agda", "max_stars_repo_name": "AntoineAllioux/HoTT-Agda", "max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 294, "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_issues_repo_path": "core/lib/groups/Int.agda", "max_issues_repo_name": "AntoineAllioux/HoTT-Agda", "max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 31, "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_forks_repo_path": "core/lib/groups/Int.agda", "max_forks_repo_name": "AntoineAllioux/HoTT-Agda", "max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 50, "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "avg_line_length": 33.8863636364, "max_line_length": 94, "alphanum_fraction": 0.6458752515, "num_tokens": 1051, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511322604133, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.6012611344079445}} {"text": "{-\nThis second-order signature was created from the following second-order syntax description:\n\nsyntax TLC | Λ\n\ntype\n N : 0-ary\n _↣_ : 2-ary | r30\n 𝟙 : 0-ary\n _⊗_ : 2-ary | l40\n 𝟘 : 0-ary\n _⊕_ : 2-ary | l30\n\nterm\n app : α ↣ β α -> β | _$_ l20\n lam : α.β -> α ↣ β | ƛ_ r10\n unit : 𝟙\n pair : α β -> α ⊗ β | ⟨_,_⟩\n fst : α ⊗ β -> α\n snd : α ⊗ β -> β\n abort : 𝟘 -> α\n inl : α -> α ⊕ β\n inr : β -> α ⊕ β\n case : α ⊕ β α.γ β.γ -> γ\n ze : N\n su : N -> N\n nrec : N α (α,N).α -> α\n\ntheory\n (ƛβ) b : α.β a : α |> app (lam(x.b[x]), a) = b[a]\n (ƛη) f : α ↣ β |> lam (x. app(f, x)) = f\n (𝟙η) u : 𝟙 |> u = unit\n (fβ) a : α b : β |> fst (pair(a, b)) = a\n (sβ) a : α b : β |> snd (pair(a, b)) = b\n (pη) p : α ⊗ β |> pair (fst(p), snd(p)) = p\n (𝟘η) e : 𝟘 c : α |> abort(e) = c\n (lβ) a : α f : α.γ g : β.γ |> case (inl(a), x.f[x], y.g[y]) = f[a]\n (rβ) b : β f : α.γ g : β.γ |> case (inr(b), x.f[x], y.g[y]) = g[b]\n (cη) s : α ⊕ β c : (α ⊕ β).γ |> case (s, x.c[inl(x)], y.c[inr(y)]) = c[s]\n (zeβ) z : α s : (α,N).α |> nrec (ze, z, r m. s[r,m]) = z\n (suβ) z : α s : (α,N).α n : N |> nrec (su (n), z, r m. s[r,m]) = s[nrec (n, z, r m. s[r,m]), n]\n (ift) t f : α |> if (true, t, f) = t\n (iff) t f : α |> if (false, t, f) = f\n-}\n\nmodule TLC.Signature where\n\nopen import SOAS.Context\n\n-- Type declaration\ndata ΛT : Set where\n N : ΛT\n _↣_ : ΛT → ΛT → ΛT\n 𝟙 : ΛT\n _⊗_ : ΛT → ΛT → ΛT\n 𝟘 : ΛT\n _⊕_ : ΛT → ΛT → ΛT\ninfixr 30 _↣_\ninfixl 40 _⊗_\ninfixl 30 _⊕_\n\n-- Derived types\nB : ΛT\nB = 𝟙 ⊕ 𝟙\n\nopen import SOAS.Syntax.Signature ΛT public\nopen import SOAS.Syntax.Build ΛT public\n\n-- Operator symbols\ndata Λₒ : Set where\n appₒ lamₒ pairₒ fstₒ sndₒ inlₒ inrₒ : {α β : ΛT} → Λₒ\n unitₒ zeₒ suₒ : Λₒ\n abortₒ nrecₒ : {α : ΛT} → Λₒ\n caseₒ : {α β γ : ΛT} → Λₒ\n\n-- Term signature\nΛ:Sig : Signature Λₒ\nΛ:Sig = sig λ\n { (appₒ {α}{β}) → (⊢₀ α ↣ β) , (⊢₀ α) ⟼₂ β\n ; (lamₒ {α}{β}) → (α ⊢₁ β) ⟼₁ α ↣ β\n ; unitₒ → ⟼₀ 𝟙\n ; (pairₒ {α}{β}) → (⊢₀ α) , (⊢₀ β) ⟼₂ α ⊗ β\n ; (fstₒ {α}{β}) → (⊢₀ α ⊗ β) ⟼₁ α\n ; (sndₒ {α}{β}) → (⊢₀ α ⊗ β) ⟼₁ β\n ; (abortₒ {α}) → (⊢₀ 𝟘) ⟼₁ α\n ; (inlₒ {α}{β}) → (⊢₀ α) ⟼₁ α ⊕ β\n ; (inrₒ {α}{β}) → (⊢₀ β) ⟼₁ α ⊕ β\n ; (caseₒ {α}{β}{γ}) → (⊢₀ α ⊕ β) , (α ⊢₁ γ) , (β ⊢₁ γ) ⟼₃ γ\n ; zeₒ → ⟼₀ N\n ; suₒ → (⊢₀ N) ⟼₁ N\n ; (nrecₒ {α}) → (⊢₀ N) , (⊢₀ α) , (α , N ⊢₂ α) ⟼₃ α\n }\n\nopen Signature Λ:Sig public\n", "meta": {"hexsha": "5a7e31d0c1b40043e55860a088d878d829a5b4c4", "size": 2536, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "out/TLC/Signature.agda", "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_issues_repo_path": "out/TLC/Signature.agda", "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_forks_repo_path": "out/TLC/Signature.agda", "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "avg_line_length": 26.6947368421, "max_line_length": 100, "alphanum_fraction": 0.415615142, "num_tokens": 1438, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677622198946, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.6012253630330638}} {"text": "module Lec7 where\n\nopen import Lec1Done\n\ndata List (X : Set) : Set where\n [] : List X\n _,-_ : X -> List X -> List X\n\nfoldrL : {X T : Set} -> (X -> T -> T) -> T -> List X -> T\nfoldrL c n [] = n\nfoldrL c n (x ,- xs) = c x (foldrL c n xs)\n\ndata Bwd (X : Set) : Set where\n [] : Bwd X\n _-,_ : Bwd X -> X -> Bwd X\ninfixl 3 _-,_\n\ndata _<=_ {X : Set} : (xz yz : Bwd X) -> Set where\n oz : [] <= []\n os : {xz yz : Bwd X}{y : X} -> xz <= yz -> (xz -, y) <= (yz -, y)\n o' : {xz yz : Bwd X}{y : X} -> xz <= yz -> xz <= (yz -, y)\n\noe : {X : Set}{xz : Bwd X} -> [] <= xz\noe {_} {[]} = oz\noe {_} {xz -, _} = o' oe\n\noi : {X : Set}{xz : Bwd X} -> xz <= xz\noi {_} {[]} = oz\noi {_} {xz -, _} = os oi -- look here...\n\n_ xz <= yz -> yz <= zz -> xz <= zz\nth X -> Bwd X -> Set\nElem x yz = ([] -, x) <= yz\n\ndata Ty : Set where\n one : Ty\n list : Ty -> Ty\n _=>_ : Ty -> Ty -> Ty\ninfixr 4 _=>_\n\nVal : Ty -> Set\nVal one = One\nVal (list T) = List (Val T)\nVal (S => T) = Val S -> Val T\n\ndata Tm (Tz : Bwd Ty) : Ty -> Set where\n\n var : {T : Ty} -> Elem T Tz -> Tm Tz T\n \n <> : Tm Tz one\n\n [] : {T : Ty} -> Tm Tz (list T)\n _,-_ : {T : Ty} -> Tm Tz T -> Tm Tz (list T) -> Tm Tz (list T)\n foldr : {S T : Ty} ->\n Tm Tz (S => T => T) ->\n Tm Tz T ->\n Tm Tz (list S)\n -> Tm Tz T\n\n lam : {S T : Ty} ->\n Tm (Tz -, S) T\n -> Tm Tz (S => T)\n _$$_ : {S T : Ty} ->\n Tm Tz (S => T) ->\n Tm Tz S\n -> Tm Tz T\n\ninfixl 3 _$$_\n\nAll : {X : Set} -> (X -> Set) -> Bwd X -> Set\nAll P [] = One\nAll P (xz -, x) = All P xz * P x\n\nall : {X : Set}{P Q : X -> Set}(f : (x : X) -> P x -> Q x) -> (xz : Bwd X) -> All P xz -> All Q xz\nall f [] <> = <>\nall f (xz -, x) (pz , p) = all f xz pz , f x p\n\nEnv : Bwd Ty -> Set\nEnv = All Val\n\nselect : {X : Set}{P : X -> Set}{Sz Tz : Bwd X} -> Sz <= Tz -> All P Tz -> All P Sz\nselect oz <> = <>\nselect (os x) (vz , v) = select x vz , v\nselect (o' x) (vz , v) = select x vz\n\neval : {Tz : Bwd Ty}{T : Ty} -> Env Tz -> Tm Tz T -> Val T\neval vz (var x) with select x vz\neval vz (var x) | <> , v = v\neval vz <> = <>\neval vz [] = []\neval vz (t ,- ts) = eval vz t ,- eval vz ts\neval vz (foldr c n ts) = foldrL (eval vz c) (eval vz n) (eval vz ts)\neval vz (lam t) = \\ s -> eval (vz , s) t\neval vz (f $$ s) = eval vz f (eval vz s)\n\nappend : {Tz : Bwd Ty}{T : Ty} ->\n Tm Tz (list T => list T => list T)\nappend = lam (lam (foldr (lam (lam (var (o' (os oe)) ,- var (os oe))))\n (var (os oe)) (var (o' (os oe)))))\n\ntest : Val (list one)\ntest = eval {[]} <> (append $$ (<> ,- []) $$ (<> ,- []))\n\nthin : {Sz Tz : Bwd Ty} -> Sz <= Tz -> {S : Ty} -> Tm Sz S -> Tm Tz S\nthin th (var x) = var (x = <>\nthin th [] = []\nthin th (t ,- ts) = thin th t ,- thin th ts\nthin th (foldr c n ts) = foldr (thin th c) (thin th n) (thin th ts) \nthin th (lam t) = lam (thin (os th) t)\nthin th (f $$ s) = thin th f $$ thin th s\n\nSubst : Bwd Ty -> Bwd Ty -> Set\nSubst Sz Tz = All (Tm Tz) Sz\n\nsubst : {Sz Tz : Bwd Ty} -> Subst Sz Tz -> {S : Ty} -> Tm Sz S -> Tm Tz S\nsubst tz (var x) with select x tz\nsubst tz (var x) | <> , t = t\nsubst tz <> = <>\nsubst tz [] = []\nsubst tz (t ,- ts) = subst tz t ,- subst tz ts\nsubst tz (foldr c n ts) = foldr (subst tz c) (subst tz n) (subst tz ts)\nsubst tz (lam t) = lam (subst (all (\\ T -> thin (o' oi)) _ tz , (var (os oe))) t)\nsubst tz (f $$ s) = subst tz f $$ subst tz s\n\nrecord Action (M : Bwd Ty -> Bwd Ty -> Set) : Set where\n field\n varA : forall {S Sz Tz} -> M Sz Tz -> Elem S Sz -> Tm Tz S\n lamA : forall {S Sz Tz} -> M Sz Tz -> M (Sz -, S) (Tz -, S)\n act : {Sz Tz : Bwd Ty} -> M Sz Tz -> {S : Ty} -> Tm Sz S -> Tm Tz S\n act m (var x) = varA m x\n act m <> = <>\n act m [] = []\n act m (t ,- ts) = act m t ,- act m ts\n act m (foldr c n ts) = foldr (act m c) (act m n) (act m ts) \n act m (lam t) = lam (act (lamA m) t)\n act m (f $$ s) = act m f $$ act m s\n\nTHIN : Action _<=_\nAction.varA THIN th x = var (x , t = t\nAction.lamA SUBST tz = all (\\ T -> Action.act THIN (o' oi)) _ tz , (var (os oe))\n\n-- substitution\n-- thinning\n-- abstr-action\n\n", "meta": {"hexsha": "fe2674d07d9dc9216c345357978f19eadb884821", "size": 4440, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec7.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec7.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec7.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 28.2802547771, "max_line_length": 98, "alphanum_fraction": 0.4587837838, "num_tokens": 1851, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677583778258, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.6012253603089636}} {"text": "module Holes.Util where\n\nopen import Holes.Prelude\n\nprivate\n Rel : ∀ {a} → Set a → ∀ ℓ → Set (a ⊔ lsuc ℓ)\n Rel A ℓ = A → A → Set ℓ\n\nmodule CongSplit {ℓ x} {X : Set x} (_≈_ : Rel X ℓ) (reflexive : ∀ {x} → x ≈ x) where\n\n two→one₁ : {_+_ : X → X → X}\n → (∀ {x x′ y y′} → x ≈ x′ → y ≈ y′ → (x + y) ≈ (x′ + y′))\n → (∀ x y {x′} → x ≈ x′ → (x + y) ≈ (x′ + y))\n two→one₁ cong² _ _ eq = cong² eq reflexive\n\n two→one₂ : {_+_ : X → X → X}\n → (∀ {x x′ y y′} → x ≈ x′ → y ≈ y′ → (x + y) ≈ (x′ + y′))\n → (∀ x y {y′} → y ≈ y′ → (x + y) ≈ (x + y′))\n two→one₂ cong² _ _ eq = cong² reflexive eq\n", "meta": {"hexsha": "6a5c38021efe605e86987f7f3e0ac2d75d69baef", "size": 625, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Holes/Util.agda", "max_stars_repo_name": "bch29/agda-holes", "max_stars_repo_head_hexsha": "b5537c29e69febd7e89580398fac38d619aab3b4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 24, "max_stars_repo_stars_event_min_datetime": "2017-01-28T10:56:46.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-03T15:02:41.000Z", "max_issues_repo_path": "src/Holes/Util.agda", "max_issues_repo_name": "bch29/agda-holes", "max_issues_repo_head_hexsha": "b5537c29e69febd7e89580398fac38d619aab3b4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-01-16T10:47:58.000Z", "max_issues_repo_issues_event_max_datetime": "2020-08-31T20:58:33.000Z", "max_forks_repo_path": "src/Holes/Util.agda", "max_forks_repo_name": "bch29/agda-holes", "max_forks_repo_head_hexsha": "b5537c29e69febd7e89580398fac38d619aab3b4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-01-27T14:57:39.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-02T18:57:17.000Z", "avg_line_length": 31.25, "max_line_length": 84, "alphanum_fraction": 0.4064, "num_tokens": 297, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8807970873650401, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.6012089514947928}} {"text": "{-# OPTIONS --safe --experimental-lossy-unification #-}\nmodule Cubical.Algebra.Polynomials.Multivariate.EquivCarac.Poly0-A where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.HLevels\n\nopen import Cubical.Data.Nat renaming (_+_ to _+n_; _·_ to _·n_)\nopen import Cubical.Data.Vec\n\nopen import Cubical.Algebra.DirectSum.DirectSumHIT.Base\nopen import Cubical.Algebra.Ring\nopen import Cubical.Algebra.CommRing\n\nopen import Cubical.Algebra.CommRing.Instances.Polynomials.MultivariatePoly\n\nprivate variable\n ℓ : Level\n\nmodule Equiv-Poly0-A\n (Acr@(A , Astr) : CommRing ℓ) where\n\n private\n PA = PolyCommRing Acr 0\n\n open CommRingStr\n\n\n\n-----------------------------------------------------------------------------\n-- Equivalence\n\n Poly0→A : Poly Acr 0 → A\n Poly0→A = DS-Rec-Set.f _ _ _ _ (is-set Astr)\n (0r Astr)\n (λ v a → a)\n (_+_ Astr)\n (+Assoc Astr)\n (+IdR Astr)\n (+Comm Astr)\n (λ _ → refl)\n λ _ a b → refl\n\n A→Poly0 : A → Poly Acr 0\n A→Poly0 a = base [] a\n\n e-sect : (a : A) → Poly0→A (A→Poly0 a) ≡ a\n e-sect a = refl\n\n e-retr : (P : Poly Acr 0) → A→Poly0 (Poly0→A P) ≡ P\n e-retr = DS-Ind-Prop.f _ _ _ _ (λ _ → trunc _ _)\n (base-neutral [])\n (λ { [] a → refl })\n λ {U V} ind-U ind-V → (sym (base-add _ _ _)) ∙ (cong₂ (snd PA ._+_ ) ind-U ind-V)\n\n\n-----------------------------------------------------------------------------\n-- Ring homomorphism\n\n Poly0→A-pres1 : Poly0→A (snd PA .1r) ≡ 1r Astr\n Poly0→A-pres1 = refl\n\n Poly0→A-pres+ : (P Q : Poly Acr 0) → Poly0→A (snd PA ._+_ P Q) ≡ Astr ._+_ (Poly0→A P) (Poly0→A Q)\n Poly0→A-pres+ P Q = refl\n\n Poly0→A-pres· : (P Q : Poly Acr 0) → Poly0→A ( snd PA ._·_ P Q) ≡ Astr ._·_ (Poly0→A P) (Poly0→A Q)\n Poly0→A-pres· = DS-Ind-Prop.f _ _ _ _ (λ _ → isPropΠ λ _ → is-set Astr _ _)\n (λ Q → sym (RingTheory.0LeftAnnihilates (CommRing→Ring Acr) (Poly0→A Q)))\n (λ v a → DS-Ind-Prop.f _ _ _ _ (λ _ → is-set Astr _ _)\n (sym (RingTheory.0RightAnnihilates (CommRing→Ring Acr) (Poly0→A (base v a))))\n (λ v' a' → refl)\n λ {U V} ind-U ind-V → (cong₂ (Astr ._+_) ind-U ind-V) ∙ sym (·DistR+ Astr _ _ _))\n λ {U V} ind-U ind-V Q → (cong₂ (Astr ._+_) (ind-U Q) (ind-V Q)) ∙ sym (·DistL+ Astr _ _ _)\n\n\n-----------------------------------------------------------------------------\n-- Ring Equivalence\n\nmodule _ (A' : CommRing ℓ) where\n\n open Equiv-Poly0-A A'\n\n CRE-Poly0-A : CommRingEquiv (PolyCommRing A' 0) A'\n fst CRE-Poly0-A = isoToEquiv is\n where\n is : Iso (Poly A' 0) (A' .fst)\n Iso.fun is = Poly0→A\n Iso.inv is = A→Poly0\n Iso.rightInv is = e-sect\n Iso.leftInv is = e-retr\n snd CRE-Poly0-A = makeIsRingHom Poly0→A-pres1 Poly0→A-pres+ Poly0→A-pres·\n", "meta": {"hexsha": "2cc6f3c0b03a5e1578eab6a2ab3437494df8102e", "size": 2958, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Polynomials/Multivariate/EquivCarac/Poly0-A.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Polynomials/Multivariate/EquivCarac/Poly0-A.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Polynomials/Multivariate/EquivCarac/Poly0-A.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.152173913, "max_line_length": 111, "alphanum_fraction": 0.5300878972, "num_tokens": 980, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.880797071719777, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.6012089408157472}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Homotopy.WedgeConnectivity where\n\nopen import Cubical.Foundations.Everything\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Sigma\nopen import Cubical.HITs.Susp\nopen import Cubical.HITs.Truncation as Trunc\nopen import Cubical.Homotopy.Connected\n\nmodule WedgeConnectivity {ℓ ℓ' ℓ''} (n m : ℕ)\n (A : Pointed ℓ) (connA : isConnected (suc n) (typ A))\n (B : Pointed ℓ') (connB : isConnected (suc m) (typ B))\n (P : typ A → typ B → TypeOfHLevel ℓ'' (n + m))\n (f : (a : typ A) → P a (pt B) .fst)\n (g : (b : typ B) → P (pt A) b .fst)\n (p : f (pt A) ≡ g (pt B))\n where\n\n private\n Q : typ A → TypeOfHLevel _ n\n Q a =\n ( (Σ[ k ∈ ((b : typ B) → P a b .fst) ] k (pt B) ≡ f a)\n , isOfHLevelRetract n\n (λ {(h , q) → h , funExt λ _ → q})\n (λ {(h , q) → h , funExt⁻ q _})\n (λ _ → refl)\n (isOfHLevelPrecomposeConnected n m (P a) (λ _ → pt B)\n (isConnectedPoint m connB (pt B)) (λ _ → f a))\n )\n\n main : isContr (fiber (λ s _ → s (pt A)) (λ _ → g , p ⁻¹))\n main =\n elim.isEquivPrecompose (λ _ → pt A) n Q\n (isConnectedPoint n connA (pt A))\n .equiv-proof (λ _ → g , p ⁻¹)\n\n\n extension : ∀ a b → P a b .fst\n extension a b = main .fst .fst a .fst b\n\n left : ∀ a → extension a (pt B) ≡ f a\n left a = main .fst .fst a .snd\n\n right : ∀ b → extension (pt A) b ≡ g b\n right = funExt⁻ (cong fst (funExt⁻ (main .fst .snd) _))\n\n hom : left (pt A) ⁻¹ ∙ right (pt B) ≡ p\n hom i j = hcomp (λ k → λ { (i = i1) → p j\n ; (j = i0) → (cong snd (funExt⁻ (main .fst .snd) tt)) i (~ j)\n ; (j = i1) → right (pt B) (i ∨ k)})\n (cong snd (funExt⁻ (main .fst .snd) tt) i (~ j))\n\n hom' : left (pt A) ≡ right (pt B) ∙ sym p\n hom' = (lUnit (left _) ∙ cong (_∙ left (pt A)) (sym (rCancel (right (pt B)))))\n ∙∙ sym (assoc _ _ _)\n ∙∙ cong (right (pt B) ∙_) (sym (symDistr (left (pt A) ⁻¹) (right (pt B))) ∙ (cong sym hom))\n\n homSquare : PathP (λ i → extension (pt A) (pt B) ≡ p i) (left (pt A)) (right (pt B))\n homSquare i j = hcomp (λ k → λ { (i = i0) → left (pt A) j\n ; (i = i1) → compPath-filler (right (pt B)) (sym p) (~ k) j\n ; (j = i0) → extension (pt A) (pt B)\n ; (j = i1) → p (i ∧ k) })\n (hom' i j)\n", "meta": {"hexsha": "27f1795c8dc75136c8037ef7aa9c2567dc2eb77a", "size": 2410, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Homotopy/WedgeConnectivity.agda", "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Homotopy/WedgeConnectivity.agda", "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Homotopy/WedgeConnectivity.agda", "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.0769230769, "max_line_length": 98, "alphanum_fraction": 0.4867219917, "num_tokens": 914, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637612961505, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.6011236857103345}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Numbers.ClassicalReals.RealField\nopen import LogicalFormulae\nopen import Setoids.Subset\nopen import Setoids.Setoids\nopen import Sets.EquivalenceRelations\nopen import Rings.Orders.Total.Definition\nopen import Rings.Orders.Partial.Definition\nopen import Rings.Definition\nopen import Fields.Fields\nopen import Groups.Definition\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import Numbers.Naturals.Order.Lemmas\nopen import Setoids.Orders.Partial.Definition\nopen import Setoids.Orders.Total.Definition\n\nmodule Numbers.ClassicalReals.Examples (ℝ : RealField) where\n\nopen RealField ℝ\nopen Setoid S\nopen Equivalence eq\nopen Ring R\nopen Field F\nopen SetoidPartialOrder pOrder\nopen import Fields.Orders.LeastUpperBounds.Definition pOrder\nopen import Rings.Orders.Total.Lemmas orderedRing\nopen import Rings.Orders.Partial.Lemmas pOrderedRing\nopen Group additiveGroup\nopen PartiallyOrderedRing pOrderedRing\nopen SetoidTotalOrder (TotallyOrderedRing.total orderedRing)\nopen import Rings.InitialRing R\nopen import Fields.Orders.Lemmas oField\nopen import Rings.Lemmas R\nopen import Groups.Lemmas additiveGroup\nopen import Numbers.Intervals.Definition pOrderedRing\nopen import Numbers.Intervals.Arithmetic pOrderedRing\nopen import Fields.Lemmas F\n\nsquarePositive : (a : A) → (((a ∼ 0R) → False) && (0R < (a * a))) || (a ∼ 0R)\nsquarePositive a with totality 0R a\nsquarePositive a | inl (inl x) = inl ((λ a=0 → irreflexive (_ : {I : Set}(S T : I -> Set) -> I -> Set\n(S -:> T) i = S i -> T i\ninfixr 3 _-:>_\n\n-- notation for indexed sets\n\n[_] : {I : Set}(X : I -> Set) -> Set\n[ X ] = forall {i} -> X i\n\nrecord MonadIx {W : Set}(F : (W -> Set) -> (W -> Set)) : Set1 where\n field\n retIx : forall {P} -> [ P -:> F P ]\n extendIx : forall {P Q} -> [ P -:> F Q ] -> [ F P -:> F Q ]\n _?>=_ : forall {P Q w} ->\n F P w -> (forall {v} -> P v -> F Q v) -> F Q w\n fp ?>= k = extendIx k fp\n \nIC : (W : Set)\n (C : W -> Set)\n (R : (w : W) -> C w -> Set)\n (n : (w : W)(c : C w)(r : R w c) -> W)\n -> (W -> Set) -> (W -> Set)\nIC W C R n G w = Sg (C w) \\ c -> (r : R w c) -> G (n w c r)\n\ndata FreeIx (W : Set)\n (C : W -> Set)\n (R : (w : W) -> C w -> Set)\n (n : (w : W)(c : C w)(r : R w c) -> W)\n (G : W -> Set)\n (w : W)\n : Set\n where\n ret : G w -> FreeIx W C R n G w\n do : IC W C R n (FreeIx W C R n G) w -> FreeIx W C R n G w\n\npostulate\n FileName : Set\n Char : Set\n foo : FileName\n blah : Char\n\ndata WriteFileW : Set where\n opened closed : WriteFileW\n\ndata WriteFileC : WriteFileW -> Set where\n write : Char -> WriteFileC opened\n openW : FileName -> WriteFileC closed\n closeW : WriteFileC opened\n\nWriteFileR : (w : WriteFileW)(c : WriteFileC w) -> Set\nWriteFileR .opened (write x) = One\nWriteFileR .closed (openW x) = WriteFileW\nWriteFileR .opened closeW = One\n\nWriteFileN : (w : WriteFileW)(c : WriteFileC w)(r : WriteFileR w c) -> WriteFileW\nWriteFileN .opened (write x) <> = opened\nWriteFileN .closed (openW x) r = r\nWriteFileN .opened closeW <> = closed\n\nWRITE : (WriteFileW -> Set) -> (WriteFileW -> Set)\nWRITE = FreeIx WriteFileW WriteFileC WriteFileR WriteFileN\n\nGoal : WriteFileW -> Set\nGoal opened = Zero\nGoal closed = One\n\nplay : WRITE Goal closed\nplay = do (openW foo , \\\n { opened -> do (write blah , (\\ _ -> do (closeW , (\\ _ -> ret <>))))\n ; closed -> ret <>\n })\n\nFreeMonadIx : (W : Set)\n (C : W -> Set)\n (R : (w : W) -> C w -> Set)\n (n : (w : W)(c : C w)(r : R w c) -> W)\n -> MonadIx (FreeIx W C R n)\nFreeMonadIx W C R n =\n record { retIx = ret\n ; extendIx = help\n } where\n help : {P Q : W → Set} ->\n [ P -:> FreeIx W C R n Q ] ->\n [ FreeIx W C R n P -:> FreeIx W C R n Q ]\n help k (ret p) = k p\n help k (do (c , j)) = do (c , \\ r -> help k (j r))\n\n\ndata HType : Set where hTwo hNat : HType\n\n-- mapping names for types to real types.\n\nTHVal : HType -> Set\nTHVal hTwo = Two\nTHVal hNat = Nat\n\n-- A syntax for types expressions, indexed by typed variables. Compare\n-- with the untyped HExp and fill in the missing expression formers,\n-- we have shown you the way with _+H_. think: what can be guaranteed?\n\ndata THExp (X : HType -> Set) : HType -> Set where\n var : forall {T} -> X T -> THExp X T\n val : forall {T} -> THVal T -> THExp X T\n _+H_ : THExp X hNat -> THExp X hNat -> THExp X hNat\n -- ??? fill in the other two constructs, typed appropriately\n -- (remember that \"if then else\" can compute values at any type)\n\nTHExpMonadIx : MonadIx THExp\nTHExpMonadIx = record\n { retIx = var\n ; extendIx = help\n } where\n help : forall {P Q} -> [ P -:> THExp Q ] -> [ THExp P -:> THExp Q ]\n help f (var x) = f x\n help f (val v) = val v\n help f (e1 +H e2) = help f e1 +H help f e2\n\nWH : Set\nWH = Nat * Nat\n\ndata Tiling (X : WH -> Set)(wh : WH) : Set where\n ! : X wh -> Tiling X wh\n joinH : (wl wr : Nat)(wq : wl +N wr == fst wh) ->\n Tiling X (wl , snd wh) -> Tiling X (wr , snd wh) -> Tiling X wh\n joinV : (ht hb : Nat)(hq : ht +N hb == snd wh) ->\n Tiling X (fst wh , ht) -> Tiling X (fst wh , hb) -> Tiling X wh\n\nTilingMonadIx : MonadIx Tiling\nTilingMonadIx = record\n { retIx = !\n ; extendIx = help\n } where\n help : {P Q : WH -> Set} -> [ P -:> Tiling Q ] -> [ Tiling P -:> Tiling Q ]\n help f (! p) = f p\n help f (joinH wl wr wq t-l t-r) = joinH wl wr wq (help f t-l) (help f t-r)\n help f (joinV ht hb hq t-t t-b) = joinV ht hb hq (help f t-t) (help f t-b)\n\nIsZero : Nat -> Set\nIsZero zero = One\nIsZero (suc n) = Zero\n\nCanCons : Set -> Nat -> Set\nCanCons X zero = Zero\nCanCons X (suc n) = X\n\nafterCons : {X : Set}(n : Nat) -> CanCons X n -> One -> Nat\nafterCons zero () <>\nafterCons (suc n) c <> = n\n\n\nVEC : Set -> Nat -> Set\nVEC X = FreeIx Nat (CanCons X) (\\ _ _ -> One) afterCons IsZero\n", "meta": {"hexsha": "87f9ae002871fa1f0fffdea74e3e05037711d13b", "size": 4453, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "LecIC.agda", "max_stars_repo_name": "clarkdm/CS410", "max_stars_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LecIC.agda", "max_issues_repo_name": "clarkdm/CS410", "max_issues_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LecIC.agda", "max_forks_repo_name": "clarkdm/CS410", "max_forks_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.0062893082, "max_line_length": 81, "alphanum_fraction": 0.5427801482, "num_tokens": 1623, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891392358015, "lm_q2_score": 0.731058584489497, "lm_q1q2_score": 0.6010684283123631}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import PathInduction\nopen import Pushout\n\nmodule JamesContractibility {i} (A : Type i) (⋆A : A) where\n\nopen import JamesTwoMaps A ⋆A public\n\n-- We do not prove the flattening lemma here, we only prove that the following pushout is contractible\n\nT : Type i\nT = Pushout (span JA JA (A × JA) snd (uncurry αJ))\n\n⋆T : T\n⋆T = inl εJ\n\nT-contr-inl-ε : inl εJ == ⋆T\nT-contr-inl-ε = idp\n\nT-contr-inl-α : (a : A) (x : JA) → inl x == ⋆T → inl (αJ a x) == ⋆T\nT-contr-inl-α a x y = push (⋆A , αJ a x) ∙ ! (ap inr (δJ (αJ a x))) ∙ ! (push (a , x)) ∙ y\n\nT-contr-inl-δ : (x : JA) (y : inl x == ⋆T) → Square (ap inl (δJ x)) y (T-contr-inl-α ⋆A x y) idp\nT-contr-inl-δ x y = & coh (ap-square inr (& cη (ηJ x))) (natural-square (λ z → push (⋆A , z)) (δJ x) idp (ap-∘ inr (αJ ⋆A) (δJ x))) where\n\n coh : Coh ({A : Type i} {a b : A} {p : a == b} {c : A} {q q' : c == b} (q= : Square q q' idp idp)\n {d : A} {r : d == c} {e : A} {s : d == e} {t : d == a} (sq : Square r t q p)\n → Square t s (p ∙ ! q' ∙ ! r ∙ s) idp)\n coh = path-induction\n\n cη : Coh ({A : Type i} {a b : A} {p : a == b} {c : A} {q : a == c} {r : b == c} (ηJ : ! p ∙ q == r) → Square p q r idp)\n cη = path-induction\n\nT-contr-inl : (x : JA) → inl x == ⋆T\nT-contr-inl = JA-elim T-contr-inl-ε T-contr-inl-α (λ x y → ↓-='-from-square idp (ap-cst ⋆T (δJ x)) (square-symmetry (T-contr-inl-δ x y)))\n\nT-contr-inr : (x : JA) → inr x == ⋆T\nT-contr-inr x = ap inr (δJ x) ∙ ! (push (⋆A , x)) ∙ T-contr-inl x\n\nT-contr-push : (a : A) (x : JA) → Square (T-contr-inl x) (push (a , x)) idp (T-contr-inr (αJ a x))\nT-contr-push a x = & coh where\n\n coh : Coh ({A : Type i} {a b : A} {r : a == b} {c : A} {p : c == b} {d : A} {q : d == c} {e : A} {y : d == e}\n → Square y q idp (p ∙ ! r ∙ (r ∙ ! p ∙ ! q ∙ y)))\n coh = path-induction\n\nT-contr : (x : T) → x == ⋆T\nT-contr = Pushout-elim T-contr-inl T-contr-inr (λ {(a , x) → ↓-='-from-square (ap-idf (push (a , x))) (ap-cst ⋆T (push (a , x))) (T-contr-push a x)})\n", "meta": {"hexsha": "d1860b77087e5a7c0887b820d2c05d925633a6ca", "size": 2013, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "JamesContractibility.agda", "max_stars_repo_name": "guillaumebrunerie/JamesConstruction", "max_stars_repo_head_hexsha": "89fbc29473d2d1ed1a45c3c0e56288cdcf77050b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2016-12-07T04:34:52.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-16T22:10:16.000Z", "max_issues_repo_path": "JamesContractibility.agda", "max_issues_repo_name": "guillaumebrunerie/JamesConstruction", "max_issues_repo_head_hexsha": "89fbc29473d2d1ed1a45c3c0e56288cdcf77050b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "JamesContractibility.agda", "max_forks_repo_name": "guillaumebrunerie/JamesConstruction", "max_forks_repo_head_hexsha": "89fbc29473d2d1ed1a45c3c0e56288cdcf77050b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.26, "max_line_length": 149, "alphanum_fraction": 0.5067064083, "num_tokens": 940, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9032942067038784, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.6010614968020775}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category.Core using (Category)\nopen import Categories.Functor.Bifunctor using (Bifunctor)\n\nmodule Categories.Diagram.Cowedge {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′}\n (F : Bifunctor (Category.op C) C D) where\n\nprivate\n module C = Category C\n module D = Category D\n open D\n open HomReasoning\n open Equiv\n variable\n A : Obj\n\nopen import Level\n\nopen import Categories.Functor\nopen import Categories.Functor.Construction.Constant\nopen import Categories.NaturalTransformation.Dinatural\n\nopen Functor F\n\nrecord Cowedge : Set (levelOfTerm F) where\n field\n E : Obj\n dinatural : DinaturalTransformation F (const E)\n\n module dinatural = DinaturalTransformation dinatural\n\nCowedge-∘ : (W : Cowedge) → Cowedge.E W ⇒ A → Cowedge\nCowedge-∘ {A = A} W f = record\n { E = A\n ; dinatural = extranaturalˡ (λ X → f ∘ dinatural.α X)\n (assoc ○ ∘-resp-≈ʳ (extranatural-commˡ dinatural) ○ sym-assoc)\n }\n where open Cowedge W\n\nrecord Cowedge-Morphism (W₁ W₂ : Cowedge) : Set (levelOfTerm F) where\n private\n module W₁ = Cowedge W₁\n module W₂ = Cowedge W₂\n open DinaturalTransformation\n field\n u : W₁.E ⇒ W₂.E\n commute : ∀ {C} → u ∘ W₁.dinatural.α C ≈ W₂.dinatural.α C\n\nCowedge-id : ∀ {W} → Cowedge-Morphism W W\nCowedge-id {W} = record { u = D.id ; commute = D.identityˡ }\n\nCowedge-Morphism-∘ : {A B C : Cowedge} → Cowedge-Morphism B C → Cowedge-Morphism A B → Cowedge-Morphism A C\nCowedge-Morphism-∘ M N = record { u = u M ∘ u N ; commute = assoc ○ (∘-resp-≈ʳ (commute N) ○ commute M) }\n where\n open Cowedge-Morphism\n open HomReasoning\n", "meta": {"hexsha": "786a7840ff8e03175d0561148c8a1aa725904ccd", "size": 1676, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Diagram/Cowedge.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Diagram/Cowedge.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Diagram/Cowedge.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 28.8965517241, "max_line_length": 107, "alphanum_fraction": 0.6670644391, "num_tokens": 554, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951025545425, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.60104925731566}} {"text": "module Base.Free.Instance.Identity.Properties where\n\nopen import Relation.Binary.PropositionalEquality using (refl; cong)\n\nopen import Base.Free using (Free; pure; impure)\nopen import Base.Free.Instance.Identity renaming (Identity to IdentityF)\n\nopen import Base.Isomorphism using (_≃_)\nopen _≃_\n\n\n-- The usual `Identity` monad representation an the free version are isomorphic.\ndata Identity (A : Set) : Set where\n Ident : A → Identity A\n\nIdentity≃IdentityF : ∀ {A} → Identity A ≃ IdentityF A\nto Identity≃IdentityF (Ident x) = pure x\nfrom Identity≃IdentityF (pure x) = Ident x\nfrom∘to Identity≃IdentityF (Ident x) = refl\nto∘from Identity≃IdentityF (pure x) = refl\n", "meta": {"hexsha": "d6e3a5ce91bb1ede6182dcbc7febbd3a350080ce", "size": 761, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "base/agda/Base/Free/Instance/Identity/Properties.agda", "max_stars_repo_name": "FreeProving/free-compiler", "max_stars_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2020-02-06T11:03:34.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-21T13:38:23.000Z", "max_issues_repo_path": "base/agda/Base/Free/Instance/Identity/Properties.agda", "max_issues_repo_name": "FreeProving/free-compiler", "max_issues_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 120, "max_issues_repo_issues_event_min_datetime": "2020-04-09T09:40:39.000Z", "max_issues_repo_issues_event_max_datetime": "2020-12-08T07:46:01.000Z", "max_forks_repo_path": "base/agda/Base/Free/Instance/Identity/Properties.agda", "max_forks_repo_name": "FreeProving/free-compiler", "max_forks_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-04-08T11:23:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-14T07:48:41.000Z", "avg_line_length": 36.2380952381, "max_line_length": 109, "alphanum_fraction": 0.6649145861, "num_tokens": 187, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8438951025545426, "lm_q2_score": 0.7122321842389469, "lm_q1q2_score": 0.6010492521609719}} {"text": "module int where\n\nopen import bool\nopen import eq\nopen import nat\nopen import product\n\n----------------------------------------------------------------------\n-- datatypes\n----------------------------------------------------------------------\n\ndata pol : Set where\n pos : pol\n neg : pol\n\ndata sign : Set where\n nonzero : pol → sign\n zero : sign\n\ndata int : sign → Set where\n +0 : int zero\n unit : ∀ {p : pol} → int (nonzero p)\n next_ : ∀ {p : pol} → int (nonzero p) → int (nonzero p)\n \ndata nonneg : sign → Set where\n pos-nonneg : nonneg (nonzero pos)\n zero-nonneg : nonneg zero\n\ndata nonpos : sign → Set where\n neg-nonpos : nonpos (nonzero neg)\n zero-nonpos : nonpos zero\n\nℤ = Σi sign int\n\nℤ-≥-0 = Σi sign (λ s → nonneg s × int s)\n\nℤ-≤-0 = Σi sign (λ s → nonpos s × int s)\n\n----------------------------------------------------------------------\n-- syntax\n----------------------------------------------------------------------\n\ninfixl 6 _+ℤ_\n\n----------------------------------------------------------------------\n-- operations\n----------------------------------------------------------------------\n\neq-pol : pol → pol → 𝔹\neq-pol pos pos = tt\neq-pol neg neg = tt\neq-pol pos neg = ff\neq-pol neg pos = ff\n\n{- add a unit with the given polarity to the given int (so if the polarity\n is pos we are adding one, if it is neg we are subtracting one).\n Return the new int, together with its sign, which could change. -}\nadd-unit : pol → ∀{s : sign} → int s → ℤ\nadd-unit p +0 = , unit{p}\nadd-unit p (unit{p'}) = if eq-pol p p' then , next (unit{p}) else , +0\nadd-unit p (next_{p'} x) = if eq-pol p p' then , next (next x) else , x\n\n_+ℤ_ : ℤ → ℤ → ℤ \n(, +0) +ℤ (, x) = , x\n(, x) +ℤ (, +0) = , x\n(, x) +ℤ (, unit{p}) = add-unit p x\n(, unit{p}) +ℤ (, x) = add-unit p x\n(, next_{p} x) +ℤ (, next_{p'} y) with ((, x) +ℤ (, next y))\n... | , r = add-unit p r\n\nℕ-to-ℤ : ℕ → ℤ-≥-0\nℕ-to-ℤ zero = , (zero-nonneg , +0)\nℕ-to-ℤ (suc x) with ℕ-to-ℤ x\n... | , (zero-nonneg , y) = , ( pos-nonneg , unit )\n... | , (pos-nonneg , y) = , ( pos-nonneg , next y)\n\n", "meta": {"hexsha": "b02d1aeca500d195e0a104927e1c6f60fb08c0a6", "size": 2047, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "cruft/int.agda", "max_stars_repo_name": "rfindler/ial", "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 29, "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_issues_repo_path": "cruft/int.agda", "max_issues_repo_name": "rfindler/ial", "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_forks_repo_path": "cruft/int.agda", "max_forks_repo_name": "rfindler/ial", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 17, "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "avg_line_length": 26.5844155844, "max_line_length": 74, "alphanum_fraction": 0.4587200782, "num_tokens": 657, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951025545426, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.6010492470062838}} {"text": "------------------------------------------------------------------------\n-- INCREMENTAL λ-CALCULUS\n--\n-- Environments\n--\n-- This module defines the meaning of contexts, that is,\n-- the type of environments that fit a context, together\n-- with operations and properties of these operations.\n--\n-- This module is parametric in the syntax and semantics\n-- of types, so it can be reused for different calculi\n-- and models.\n------------------------------------------------------------------------\n\nmodule Base.Denotation.Environment\n (Type : Set)\n {ℓ}\n (⟦_⟧Type : Type → Set ℓ)\n where\n\nopen import Relation.Binary.PropositionalEquality\n\nopen import Base.Syntax.Context Type\nopen import Base.Denotation.Notation\nopen import Base.Data.DependentList as DependentList\n\nprivate\n instance\n meaningOfType : Meaning Type\n meaningOfType = meaning ⟦_⟧Type\n\n⟦_⟧Context : Context → Set ℓ\n⟦_⟧Context = DependentList ⟦_⟧Type\n\ninstance\n meaningOfContext : Meaning Context\n meaningOfContext = meaning ⟦_⟧Context\n\n-- VARIABLES\n\n-- Denotational Semantics\n\n⟦_⟧Var : ∀ {Γ τ} → Var Γ τ → ⟦ Γ ⟧ → ⟦ τ ⟧\n⟦ this ⟧Var (v • ρ) = v\n⟦ that x ⟧Var (v • ρ) = ⟦ x ⟧Var ρ\n\ninstance\n meaningOfVar : ∀ {Γ τ} → Meaning (Var Γ τ)\n meaningOfVar = meaning ⟦_⟧Var\n\n-- WEAKENING\n\n-- Remove a variable from an environment\n\n⟦_⟧≼ : ∀ {Γ₁ Γ₂} → (Γ′ : Γ₁ ≼ Γ₂) → ⟦ Γ₂ ⟧ → ⟦ Γ₁ ⟧\n⟦ ∅ ⟧≼ ∅ = ∅\n⟦ keep τ • Γ′ ⟧≼ (v • ρ) = v • ⟦ Γ′ ⟧≼ ρ\n⟦ drop τ • Γ′ ⟧≼ (v • ρ) = ⟦ Γ′ ⟧≼ ρ\n\ninstance\n meaningOf≼ : ∀ {Γ₁ Γ₂} → Meaning (Γ₁ ≼ Γ₂)\n meaningOf≼ = meaning ⟦_⟧≼\n\n-- Properties\n\n⟦∅≼Γ⟧-∅ : ∀ {Γ} ρ → ⟦ ∅≼Γ {Γ = Γ} ⟧≼ ρ ≡ ∅\n⟦∅≼Γ⟧-∅ {∅} ∅ = refl\n⟦∅≼Γ⟧-∅ {x • Γ} (v • ρ) = ⟦∅≼Γ⟧-∅ ρ\n\n⟦⟧-≼-trans : ∀ {Γ₃ Γ₁ Γ₂} → (Γ′ : Γ₁ ≼ Γ₂) (Γ″ : Γ₂ ≼ Γ₃) →\n ∀ (ρ : ⟦ Γ₃ ⟧) → ⟦_⟧ {{meaningOf≼}} (≼-trans Γ′ Γ″) ρ ≡ ⟦_⟧ {{meaningOf≼}} Γ′ (⟦_⟧ {{meaningOf≼}} Γ″ ρ)\n⟦⟧-≼-trans Γ′ ∅ ∅ = refl\n⟦⟧-≼-trans (keep τ • Γ′) (keep .τ • Γ″) (v • ρ) = cong₂ _•_ refl (⟦⟧-≼-trans Γ′ Γ″ ρ)\n⟦⟧-≼-trans (drop τ • Γ′) (keep .τ • Γ″) (v • ρ) = ⟦⟧-≼-trans Γ′ Γ″ ρ\n⟦⟧-≼-trans Γ′ (drop τ • Γ″) (v • ρ) = ⟦⟧-≼-trans Γ′ Γ″ ρ\n\n⟦⟧-≼-refl : ∀ {Γ : Context} →\n ∀ (ρ : ⟦ Γ ⟧) → ⟦_⟧ {{meaningOf≼}} ≼-refl ρ ≡ ρ\n⟦⟧-≼-refl {∅} ∅ = refl\n⟦⟧-≼-refl {τ • Γ} (v • ρ) = cong₂ _•_ refl (⟦⟧-≼-refl ρ)\n\n-- SOUNDNESS of variable lifting\n\nweaken-var-sound : ∀ {Γ₁ Γ₂ τ} (Γ′ : Γ₁ ≼ Γ₂) (x : Var Γ₁ τ) →\n ∀ (ρ : ⟦ Γ₂ ⟧) → ⟦_⟧ {{meaningOfVar}} (weaken-var Γ′ x) ρ ≡ ⟦_⟧ {{meaningOfVar}} x ( ⟦_⟧ {{meaningOf≼}} Γ′ ρ)\nweaken-var-sound ∅ () ρ\nweaken-var-sound (keep τ • Γ′) this (v • ρ) = refl\nweaken-var-sound (keep τ • Γ′) (that x) (v • ρ) = weaken-var-sound Γ′ x ρ\nweaken-var-sound (drop τ • Γ′) this (v • ρ) = weaken-var-sound Γ′ this ρ\nweaken-var-sound (drop τ • Γ′) (that x) (v • ρ) = weaken-var-sound Γ′ (that x) ρ\n", "meta": {"hexsha": "d82fa6a5da108d08a4d7ddf09597bd3301803cfe", "size": 2721, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Base/Denotation/Environment.agda", "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_issues_repo_path": "Base/Denotation/Environment.agda", "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_forks_repo_path": "Base/Denotation/Environment.agda", "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "avg_line_length": 29.9010989011, "max_line_length": 112, "alphanum_fraction": 0.5306872473, "num_tokens": 1268, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8438951025545426, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.6010492470062838}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\nopen import Categories.Functor.Bifunctor\n\nmodule Categories.Diagram.Wedge {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′}\n (F : Bifunctor (Category.op C) C D) where\n\nprivate\n module C = Category C\n module D = Category D\n open D\n open HomReasoning\n variable\n A : Obj\n\nopen import Level\n\nopen import Categories.Functor hiding (id)\nopen import Categories.Functor.Construction.Constant\nopen import Categories.NaturalTransformation.Dinatural\n\nopen Functor F\n\nrecord Wedge : Set (levelOfTerm F) where\n field\n E : Obj\n dinatural : DinaturalTransformation (const E) F\n\n module dinatural = DinaturalTransformation dinatural\n\nWedge-∘ : (W : Wedge) → A ⇒ Wedge.E W → Wedge\nWedge-∘ {A = A} W f = record\n { E = A\n ; dinatural = extranaturalʳ (λ X → dinatural.α X ∘ f)\n (sym-assoc ○ ∘-resp-≈ˡ (extranatural-commʳ dinatural) ○ assoc)\n }\n where open Wedge W\n\nrecord Wedge-Morphism (W₁ W₂ : Wedge) : Set (levelOfTerm F) where\n private\n module W₁ = Wedge W₁\n module W₂ = Wedge W₂\n open DinaturalTransformation\n field\n u : W₁.E ⇒ W₂.E\n commute : ∀ {C} → W₂.dinatural.α C ∘ u ≈ W₁.dinatural.α C\n\nWedge-id : ∀ {W} → Wedge-Morphism W W\nWedge-id {W} = record { u = D.id ; commute = D.identityʳ }\n\nWedge-Morphism-∘ : {A B C : Wedge} → Wedge-Morphism B C → Wedge-Morphism A B → Wedge-Morphism A C\nWedge-Morphism-∘ M N = record { u = u M ∘ u N ; commute = sym-assoc ○ (∘-resp-≈ˡ (commute M) ○ commute N) }\n where\n open Wedge-Morphism\n open HomReasoning\n", "meta": {"hexsha": "d28a452b7fcd39d84fa0b603f140c27dce27abb7", "size": 1596, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Diagram/Wedge.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Diagram/Wedge.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Diagram/Wedge.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 28.0, "max_line_length": 108, "alphanum_fraction": 0.6547619048, "num_tokens": 545, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950868503681, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.6010492358212655}} {"text": "{-# OPTIONS --without-K --safe #-}\nopen import Categories.Category\n\n{-\n Various combinators for working with Isomorphisms in the\n context of morphism equalities\n both for Category (Switch) and IsGroupoid (GroupoidR)\n-}\n\nmodule Categories.Morphism.Reasoning.Iso {o ℓ e} (C : Category o ℓ e) where\n\nopen import Level\nopen import Function renaming (id to idᶠ; _∘_ to _∙_)\n\nopen import Categories.Category.Groupoid using (IsGroupoid)\nopen import Categories.Morphism C\nopen import Categories.Morphism.Reasoning.Core C\n\nopen import Relation.Binary hiding (_⇒_)\n\nopen Category C\nprivate\n variable\n A B X Y : Obj\n f g h k : X ⇒ Y\n\nopen HomReasoning\n\nmodule Switch (i : X ≅ Y) where\n open _≅_ i\n\n switch-fromtoˡ : from ∘ h ≈ k → h ≈ to ∘ k\n switch-fromtoˡ {h = h} {k = k} pf = begin\n h ≈˘⟨ cancelˡ isoˡ ⟩\n to ∘ (from ∘ h) ≈⟨ refl⟩∘⟨ pf ⟩\n to ∘ k ∎\n\n switch-tofromˡ : to ∘ h ≈ k → h ≈ from ∘ k\n switch-tofromˡ {h = h} {k = k} pf = begin\n h ≈˘⟨ cancelˡ isoʳ ⟩\n from ∘ (to ∘ h) ≈⟨ refl⟩∘⟨ pf ⟩\n from ∘ k ∎\n\n switch-fromtoʳ : h ∘ from ≈ k → h ≈ k ∘ to\n switch-fromtoʳ {h = h} {k = k} pf = begin\n h ≈˘⟨ cancelʳ isoʳ ⟩\n (h ∘ from) ∘ to ≈⟨ pf ⟩∘⟨refl ⟩\n k ∘ to ∎\n\n switch-tofromʳ : h ∘ to ≈ k → h ≈ k ∘ from\n switch-tofromʳ {h = h} {k = k} pf = begin\n h ≈˘⟨ cancelʳ isoˡ ⟩\n (h ∘ to) ∘ from ≈⟨ pf ⟩∘⟨refl ⟩\n k ∘ from ∎\n\n cancel-fromʳ : h ∘ from ≈ k ∘ from → h ≈ k\n cancel-fromʳ {h = h} {k = k} pf = begin\n h ≈˘⟨ cancelʳ isoʳ ⟩\n (h ∘ from) ∘ to ≈⟨ pf ⟩∘⟨refl ⟩\n (k ∘ from) ∘ to ≈⟨ cancelʳ isoʳ ⟩\n k ∎\n\n cancel-fromˡ : from ∘ h ≈ from ∘ k → h ≈ k\n cancel-fromˡ {h = h} {k = k} pf = begin\n h ≈˘⟨ cancelˡ isoˡ ⟩\n to ∘ (from ∘ h) ≈⟨ refl⟩∘⟨ pf ⟩\n to ∘ (from ∘ k) ≈⟨ cancelˡ isoˡ ⟩\n k ∎\n\n cancel-toʳ : h ∘ to ≈ k ∘ to → h ≈ k\n cancel-toʳ {h = h} {k = k} pf = begin\n h ≈˘⟨ cancelʳ isoˡ ⟩\n (h ∘ to) ∘ from ≈⟨ pf ⟩∘⟨refl ⟩\n (k ∘ to) ∘ from ≈⟨ cancelʳ isoˡ ⟩\n k ∎\n\n cancel-toˡ : to ∘ h ≈ to ∘ k → h ≈ k\n cancel-toˡ {h = h} {k = k} pf = begin\n h ≈˘⟨ cancelˡ isoʳ ⟩\n from ∘ (to ∘ h) ≈⟨ refl⟩∘⟨ pf ⟩\n from ∘ (to ∘ k) ≈⟨ cancelˡ isoʳ ⟩\n k ∎\n\n -- We can flip an iso i in a commuting triangle, like so:\n --\n -- i i⁻¹\n -- X --------> Y X <-------- Y\n -- \\ ≃ / \\ ≃ /\n -- \\ / \\ /\n -- g \\ / h ===> g \\ / h\n -- \\ / \\ /\n -- V V V V\n -- A A\n --\n flip-iso : {g : X ⇒ A} {h : Y ⇒ A} → g ≈ h ∘ from → g ∘ to ≈ h\n flip-iso tr₁ = sym (switch-fromtoʳ (sym tr₁))\n\n -- Consider two commuting squares\n --\n -- f₁ f₂\n -- X -------> A X -------> A\n -- | | | |\n -- | | | |\n -- ≃ | i | h ≃ | i | h\n -- | | | |\n -- V V V V\n -- Y -------> B Y -------> B\n -- g₁ g₂\n --\n -- with i an isomorphism. Then g₁ ≈ g₂ if f₁ ≈ f₂.\n\n push-eq : {f₁ f₂ : X ⇒ A} {g₁ g₂ : Y ⇒ B} {h : A ⇒ B} →\n CommutativeSquare f₁ from h g₁ →\n CommutativeSquare f₂ from h g₂ →\n f₁ ≈ f₂ → g₁ ≈ g₂\n push-eq {f₁ = f₁} {f₂} {g₁} {g₂} {h₂} sq₁ sq₂ hyp = begin\n g₁ ≈˘⟨ flip-iso sq₁ ⟩\n (h₂ ∘ f₁) ∘ to ≈⟨ ∘-resp-≈ˡ (∘-resp-≈ʳ hyp) ⟩\n (h₂ ∘ f₂) ∘ to ≈⟨ flip-iso sq₂ ⟩\n g₂ ∎\n\nopen Switch public\n\n-- conjugates\nmodule _ (i : A ≅ B) (j : X ≅ Y) where\n private\n module i = _≅_ i\n module j = _≅_ j\n\n conjugate-from : f ∘ i.from ≈ j.from ∘ g → j.to ∘ f ≈ g ∘ i.to\n conjugate-from {f = f} {g = g} eq = begin\n j.to ∘ f ≈⟨ introʳ i.isoʳ ⟩\n (j.to ∘ f) ∘ i.from ∘ i.to ≈⟨ center eq ⟩\n j.to ∘ (j.from ∘ g) ∘ i.to ≈⟨ center⁻¹ j.isoˡ refl ⟩\n id ∘ g ∘ i.to ≈⟨ identityˡ ⟩\n g ∘ i.to ∎\n\n conjugate-to : j.to ∘ f ≈ g ∘ i.to → f ∘ i.from ≈ j.from ∘ g\n conjugate-to {f = f} {g = g} eq = begin\n f ∘ i.from ≈⟨ introˡ j.isoʳ ⟩\n (j.from ∘ j.to) ∘ f ∘ i.from ≈⟨ center eq ⟩\n j.from ∘ (g ∘ i.to) ∘ i.from ≈⟨ center⁻¹ refl i.isoˡ ⟩\n (j.from ∘ g) ∘ id ≈⟨ identityʳ ⟩\n j.from ∘ g ∎\n\nmodule GroupoidR (G : IsGroupoid C) where\n open IsGroupoid G using (_⁻¹; iso; equiv-obj)\n\n switch-fromtoˡ′ : f ∘ h ≈ k → h ≈ f ⁻¹ ∘ k\n switch-fromtoˡ′ = switch-fromtoˡ (equiv-obj _)\n\n switch-tofromˡ′ : f ⁻¹ ∘ h ≈ k → h ≈ f ∘ k\n switch-tofromˡ′ = switch-tofromˡ (equiv-obj _)\n\n switch-fromtoʳ′ : h ∘ f ≈ k → h ≈ k ∘ f ⁻¹\n switch-fromtoʳ′ = switch-fromtoʳ (equiv-obj _)\n\n switch-tofromʳ′ : h ∘ f ⁻¹ ≈ k → h ≈ k ∘ f\n switch-tofromʳ′ = switch-tofromʳ (equiv-obj _)\n", "meta": {"hexsha": "f933717a76f02520299ff63c575f4090a8d4b4ef", "size": 5035, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Morphism/Reasoning/Iso.agda", "max_stars_repo_name": "Taneb/agda-categories", "max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Categories/Morphism/Reasoning/Iso.agda", "max_issues_repo_name": "Taneb/agda-categories", "max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Categories/Morphism/Reasoning/Iso.agda", "max_forks_repo_name": "Taneb/agda-categories", "max_forks_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.46875, "max_line_length": 75, "alphanum_fraction": 0.4282025819, "num_tokens": 2123, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059609645724, "lm_q2_score": 0.7577943767446201, "lm_q1q2_score": 0.6010112373815912}} {"text": "{-# OPTIONS --without-K --safe #-}\nopen import Categories.Category\n\n{-\n Helper routines most often used in reasoning with commutative squares,\n at the level of arrows in categories.\n\n Basic : reasoning about identity\n Pulls : use a ∘ b ≈ c as left-to-right rewrite\n Pushes : use c ≈ a ∘ b as a left-to-right rewrite\n IntroElim : introduce/eliminate an equivalent-to-id arrow\n Extend : 'extends' a commutative square with an equality on left/right/both\n-}\nmodule Categories.Morphism.Reasoning.Core {o ℓ e} (C : Category o ℓ e) where\n\nopen import Level\nopen import Function renaming (id to idᶠ; _∘_ to _∙_)\n\nopen import Relation.Binary hiding (_⇒_)\n\nopen Category C\n\nprivate\n variable\n X Y : Obj\n a a′ a″ b b′ b″ c c′ c″ : X ⇒ Y\n f g h i : X ⇒ Y\n\nopen HomReasoning\n\nmodule Basic where\n id-unique : ∀ {o} {f : o ⇒ o} → (∀ g → g ∘ f ≈ g) → f ≈ id\n id-unique g∘f≈g = trans (sym identityˡ) (g∘f≈g id)\n\n id-comm : ∀ {a b} {f : a ⇒ b} → f ∘ id ≈ id ∘ f\n id-comm = trans identityʳ (sym identityˡ)\n\n id-comm-sym : ∀ {a b} {f : a ⇒ b} → id ∘ f ≈ f ∘ id\n id-comm-sym = trans identityˡ (sym identityʳ)\n\nopen Basic public\n\nmodule Utils where\n assoc² : ((i ∘ h) ∘ g) ∘ f ≈ i ∘ (h ∘ (g ∘ f))\n assoc² = trans assoc assoc\n\n assoc²' : (i ∘ (h ∘ g)) ∘ f ≈ i ∘ (h ∘ (g ∘ f))\n assoc²' = trans assoc (∘-resp-≈ʳ assoc)\n\nopen Utils public\n\nmodule Pulls (ab≡c : a ∘ b ≈ c) where\n\n pullʳ : (f ∘ a) ∘ b ≈ f ∘ c\n pullʳ {f = f} = begin\n (f ∘ a) ∘ b ≈⟨ assoc ⟩\n f ∘ (a ∘ b) ≈⟨ refl⟩∘⟨ ab≡c ⟩\n f ∘ c ∎\n\n pullˡ : a ∘ b ∘ f ≈ c ∘ f\n pullˡ {f = f} = begin\n a ∘ b ∘ f ≈⟨ sym assoc ⟩\n (a ∘ b) ∘ f ≈⟨ ab≡c ⟩∘⟨refl ⟩\n c ∘ f ∎\n\nopen Pulls public\n\nmodule Pushes (c≡ab : c ≈ a ∘ b) where\n pushʳ : f ∘ c ≈ (f ∘ a) ∘ b\n pushʳ {f = f} = begin\n f ∘ c ≈⟨ refl⟩∘⟨ c≡ab ⟩\n f ∘ (a ∘ b) ≈˘⟨ assoc ⟩\n (f ∘ a) ∘ b ∎\n\n pushˡ : c ∘ f ≈ a ∘ (b ∘ f)\n pushˡ {f = f} = begin\n c ∘ f ≈⟨ c≡ab ⟩∘⟨refl ⟩\n (a ∘ b) ∘ f ≈⟨ assoc ⟩\n a ∘ (b ∘ f) ∎\n\nopen Pushes public\n\nmodule IntroElim (a≡id : a ≈ id) where\n elimʳ : f ∘ a ≈ f\n elimʳ {f = f} = begin\n f ∘ a ≈⟨ refl⟩∘⟨ a≡id ⟩\n f ∘ id ≈⟨ identityʳ ⟩\n f ∎\n\n introʳ : f ≈ f ∘ a\n introʳ = Equiv.sym elimʳ\n\n elimˡ : (a ∘ f) ≈ f\n elimˡ {f = f} = begin\n a ∘ f ≈⟨ a≡id ⟩∘⟨refl ⟩\n id ∘ f ≈⟨ identityˡ ⟩\n f ∎\n\n introˡ : f ≈ a ∘ f\n introˡ = Equiv.sym elimˡ\n\nopen IntroElim public\n\nmodule Extends (s : CommutativeSquare f g h i) where\n extendˡ : CommutativeSquare f g (a ∘ h) (a ∘ i)\n extendˡ {a = a} = begin\n (a ∘ h) ∘ f ≈⟨ pullʳ s ⟩\n a ∘ i ∘ g ≈˘⟨ assoc ⟩\n (a ∘ i) ∘ g ∎\n\n extendʳ : CommutativeSquare (f ∘ a) (g ∘ a) h i\n extendʳ {a = a} = begin\n h ∘ (f ∘ a) ≈⟨ pullˡ s ⟩\n (i ∘ g) ∘ a ≈⟨ assoc ⟩\n i ∘ (g ∘ a) ∎\n\n extend² : CommutativeSquare (f ∘ b) (g ∘ b) (a ∘ h) (a ∘ i)\n extend² {b = b} {a = a } = begin\n (a ∘ h) ∘ (f ∘ b) ≈⟨ pullʳ extendʳ ⟩\n a ∘ (i ∘ (g ∘ b)) ≈˘⟨ assoc ⟩\n (a ∘ i) ∘ (g ∘ b) ∎\n\nopen Extends public\n\n-- essentially composition in the arrow category\n{-\n A₁ -- c --> B₁\n | |\n b′ comm b\n | |\n V V\n A₂ -- c′ -> B₂\n | |\n a′ comm a\n | |\n V V\n A₃ -- c″ -> B₃\n\n then the whole diagram commutes\n-}\nglue : CommutativeSquare c′ a′ a c″ →\n CommutativeSquare c b′ b c′ →\n CommutativeSquare c (a′ ∘ b′) (a ∘ b) c″\nglue {c′ = c′} {a′ = a′} {a = a} {c″ = c″} {c = c} {b′ = b′} {b = b} sq-a sq-b = begin\n (a ∘ b) ∘ c ≈⟨ pullʳ sq-b ⟩\n a ∘ (c′ ∘ b′) ≈⟨ pullˡ sq-a ⟩\n (c″ ∘ a′) ∘ b′ ≈⟨ assoc ⟩\n c″ ∘ (a′ ∘ b′) ∎\n\nglue◃◽ : a ∘ c′ ≈ c″ → CommutativeSquare c b′ b c′ → CommutativeSquare c b′ (a ∘ b) c″\nglue◃◽ {a = a} {c′ = c′} {c″ = c″} {c = c} {b′ = b′} {b = b} tri-a sq-b = begin\n (a ∘ b) ∘ c ≈⟨ pullʳ sq-b ⟩\n a ∘ (c′ ∘ b′) ≈⟨ pullˡ tri-a ⟩\n c″ ∘ b′ ∎\n\nglue◃◽′ : c ∘ c′ ≈ a′ → CommutativeSquare a b a′ b′ → CommutativeSquare (c′ ∘ a) b c b′\nglue◃◽′ {c = c} {c′ = c′} {a′ = a′} {a = a} {b = b} {b′ = b′} tri sq = begin\n c ∘ c′ ∘ a ≈⟨ pullˡ tri ⟩\n a′ ∘ a ≈⟨ sq ⟩\n b′ ∘ b ∎\n\nglue◽◃ : CommutativeSquare a b a′ b′ → b ∘ c ≈ c′ → CommutativeSquare (a ∘ c) c′ a′ b′\nglue◽◃ {a = a} {b = b} {a′ = a′} {b′ = b′} {c = c} {c′ = c′} sq tri = begin\n a′ ∘ a ∘ c ≈⟨ pullˡ sq ⟩\n (b′ ∘ b) ∘ c ≈⟨ pullʳ tri ⟩\n b′ ∘ c′ ∎\n\nglue▹◽ : b ∘ a″ ≈ c → CommutativeSquare a b a′ b′ → CommutativeSquare (a ∘ a″) c a′ b′\nglue▹◽ {b = b} {a″ = a″} {c = c} {a = a} {a′ = a′} {b′ = b′} tri sq = begin\n a′ ∘ a ∘ a″ ≈⟨ pullˡ sq ⟩\n (b′ ∘ b) ∘ a″ ≈⟨ pullʳ tri ⟩\n b′ ∘ c ∎\n\n-- essentially composition in the over category\nglueTrianglesʳ : a ∘ b ≈ a′ → a′ ∘ b′ ≈ a″ → a ∘ (b ∘ b′) ≈ a″\nglueTrianglesʳ {a = a} {b = b} {a′ = a′} {b′ = b′} {a″ = a″} a∘b≡a′ a′∘b′≡a″ = begin\n a ∘ (b ∘ b′) ≈⟨ pullˡ a∘b≡a′ ⟩\n a′ ∘ b′ ≈⟨ a′∘b′≡a″ ⟩\n a″ ∎\n\n-- essentially composition in the under category\nglueTrianglesˡ : a′ ∘ b′ ≈ b″ → a ∘ b ≈ b′ → (a′ ∘ a) ∘ b ≈ b″\nglueTrianglesˡ {a′ = a′} {b′ = b′} {b″ = b″} {a = a} {b = b} a′∘b′≡b″ a∘b≡b′ = begin\n (a′ ∘ a) ∘ b ≈⟨ pullʳ a∘b≡b′ ⟩\n a′ ∘ b′ ≈⟨ a′∘b′≡b″ ⟩\n b″ ∎\n\nmodule Cancellers (inv : h ∘ i ≈ id) where\n\n cancelʳ : (f ∘ h) ∘ i ≈ f\n cancelʳ {f = f} = begin\n (f ∘ h) ∘ i ≈⟨ pullʳ inv ⟩\n f ∘ id ≈⟨ identityʳ ⟩\n f ∎\n\n cancelˡ : h ∘ (i ∘ f) ≈ f\n cancelˡ {f = f} = begin\n h ∘ (i ∘ f) ≈⟨ pullˡ inv ⟩\n id ∘ f ≈⟨ identityˡ ⟩\n f ∎\n\n cancelInner : (f ∘ h) ∘ (i ∘ g) ≈ f ∘ g\n cancelInner {f = f} {g = g} = begin\n (f ∘ h) ∘ (i ∘ g) ≈⟨ pullˡ cancelʳ ⟩\n f ∘ g ∎\n\nopen Cancellers public\n\ncenter : g ∘ h ≈ a → (f ∘ g) ∘ h ∘ i ≈ f ∘ a ∘ i\ncenter {g = g} {h = h} {a = a} {f = f} {i = i} eq = begin\n (f ∘ g) ∘ h ∘ i ≈⟨ assoc ⟩\n f ∘ g ∘ h ∘ i ≈⟨ refl⟩∘⟨ pullˡ eq ⟩\n f ∘ a ∘ i ∎\n\ncenter⁻¹ : f ∘ g ≈ a → h ∘ i ≈ b → f ∘ (g ∘ h) ∘ i ≈ a ∘ b\ncenter⁻¹ {f = f} {g = g} {a = a} {h = h} {i = i} {b = b} eq eq′ = begin\n f ∘ (g ∘ h) ∘ i ≈⟨ refl⟩∘⟨ pullʳ eq′ ⟩\n f ∘ g ∘ b ≈⟨ pullˡ eq ⟩\n a ∘ b ∎\n\npull-last : h ∘ i ≈ a → (f ∘ g ∘ h) ∘ i ≈ f ∘ g ∘ a\npull-last {h = h} {i = i} {a = a} {f = f} {g = g} eq = begin\n (f ∘ g ∘ h) ∘ i ≈⟨ assoc ⟩\n f ∘ (g ∘ h) ∘ i ≈⟨ refl⟩∘⟨ pullʳ eq ⟩\n f ∘ g ∘ a ∎\n\npull-first : f ∘ g ≈ a → f ∘ (g ∘ h) ∘ i ≈ a ∘ h ∘ i\npull-first {f = f} {g = g} {a = a} {h = h} {i = i} eq = begin\n f ∘ (g ∘ h) ∘ i ≈⟨ refl⟩∘⟨ assoc ⟩\n f ∘ g ∘ h ∘ i ≈⟨ pullˡ eq ⟩\n a ∘ h ∘ i ∎\n", "meta": {"hexsha": "8fb910c14f4c898f440613bfc6498b1068bef3ad", "size": 6398, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Morphism/Reasoning/Core.agda", "max_stars_repo_name": "Taneb/agda-categories", "max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Categories/Morphism/Reasoning/Core.agda", "max_issues_repo_name": "Taneb/agda-categories", "max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Categories/Morphism/Reasoning/Core.agda", "max_forks_repo_name": "Taneb/agda-categories", "max_forks_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.5775862069, "max_line_length": 87, "alphanum_fraction": 0.4484213817, "num_tokens": 3382, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059609645724, "lm_q2_score": 0.7577943658046608, "lm_q1q2_score": 0.6010112287050442}} {"text": "------------------------------------------------------------------------------\n-- Arithmetic properties\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule LTC-PCF.Data.Nat.Properties where\n\nopen import Common.FOL.Relation.Binary.EqReasoning\n\nopen import LTC-PCF.Base\nopen import LTC-PCF.Base.Properties\nopen import LTC-PCF.Data.Nat\nopen import LTC-PCF.Data.Nat.Rec\nopen import LTC-PCF.Data.Nat.Rec.ConversionRules\nopen import LTC-PCF.Data.Nat.UnaryNumbers\n\n------------------------------------------------------------------------------\n-- Congruence properties\n\n+-leftCong : ∀ {m n o} → m ≡ n → m + o ≡ n + o\n+-leftCong refl = refl\n\n+-rightCong : ∀ {m n o} → n ≡ o → m + n ≡ m + o\n+-rightCong refl = refl\n\n∸-leftCong : ∀ {m n o} → m ≡ n → m ∸ o ≡ n ∸ o\n∸-leftCong refl = refl\n\n∸-rightCong : ∀ {m n o} → n ≡ o → m ∸ n ≡ m ∸ o\n∸-rightCong refl = refl\n\n*-leftCong : ∀ {m n o} → m ≡ n → m * o ≡ n * o\n*-leftCong refl = refl\n\n*-rightCong : ∀ {m n o} → n ≡ o → m * n ≡ m * o\n*-rightCong refl = refl\n\n------------------------------------------------------------------------------\n-- Conversion rules\n\n+-0x : ∀ n → zero + n ≡ n\n+-0x n = rec zero n _ ≡⟨ rec-0 n ⟩\n n ∎\n\n+-Sx : ∀ m n → succ₁ m + n ≡ succ₁ (m + n)\n+-Sx m n =\n rec (succ₁ m) n (lam (λ _ → lam succ₁))\n ≡⟨ rec-S m n (lam (λ _ → lam succ₁)) ⟩\n (lam (λ _ → lam succ₁)) · m · (m + n)\n ≡⟨ ·-leftCong (beta (λ _ → lam succ₁) m) ⟩\n lam succ₁ · (m + n)\n ≡⟨ beta succ₁ (m + n) ⟩\n succ₁ (m + n) ∎\n\n∸-x0 : ∀ n → n ∸ zero ≡ n\n∸-x0 n = rec zero n _ ≡⟨ rec-0 n ⟩\n n ∎\n\n∸-xS : ∀ m n → m ∸ succ₁ n ≡ pred₁ (m ∸ n)\n∸-xS m n =\n rec (succ₁ n) m (lam (λ _ → lam pred₁))\n ≡⟨ rec-S n m (lam (λ _ → lam pred₁)) ⟩\n lam (λ x → lam pred₁) · n · (m ∸ n)\n ≡⟨ ·-leftCong (beta (λ _ → lam pred₁) n) ⟩\n lam pred₁ · (m ∸ n)\n ≡⟨ beta pred₁ (m ∸ n) ⟩\n pred₁ (m ∸ n) ∎\n\n*-0x : ∀ n → zero * n ≡ zero\n*-0x n = rec zero zero (lam (λ _ → lam (_+_ n))) ≡⟨ rec-0 zero ⟩\n zero ∎\n\n*-Sx : ∀ m n → succ₁ m * n ≡ n + m * n\n*-Sx m n =\n rec (succ₁ m) zero (lam (λ _ → lam (_+_ n)))\n ≡⟨ rec-S m zero (lam (λ _ → lam (_+_ n))) ⟩\n (lam (λ _ → lam (_+_ n))) · m · (m * n)\n ≡⟨ ·-leftCong (beta (λ _ → lam (_+_ n)) m) ⟩\n lam (_+_ n) · (m * n)\n ≡⟨ beta (_+_ n) (m * n) ⟩\n n + (m * n) ∎\n\n------------------------------------------------------------------------------\n\n+-leftIdentity : ∀ n → zero + n ≡ n\n+-leftIdentity = +-0x\n\n+-rightIdentity : ∀ {n} → N n → n + zero ≡ n\n+-rightIdentity nzero = +-leftIdentity zero\n+-rightIdentity (nsucc {n} Nn) =\n trans (+-Sx n zero) (succCong (+-rightIdentity Nn))\n\npred-N : ∀ {n} → N n → N (pred₁ n)\npred-N nzero = subst N (sym pred-0) nzero\npred-N (nsucc {n} Nn) = subst N (sym (pred-S n)) Nn\n\n+-N : ∀ {m n} → N m → N n → N (m + n)\n+-N {n = n} nzero Nn = subst N (sym (+-leftIdentity n)) Nn\n+-N {n = n} (nsucc {m} Nm) Nn = subst N (sym (+-Sx m n)) (nsucc (+-N Nm Nn))\n\n∸-N : ∀ {m n} → N m → N n → N (m ∸ n)\n∸-N {m} Nm nzero = subst N (sym (∸-x0 m)) Nm\n∸-N {m} Nm (nsucc {n} Nn) = subst N (sym (∸-xS m n)) (pred-N (∸-N Nm Nn))\n\n+-assoc : ∀ {m} → N m → ∀ n o → m + n + o ≡ m + (n + o)\n+-assoc nzero n o =\n zero + n + o ≡⟨ +-leftCong (+-leftIdentity n) ⟩\n n + o ≡⟨ sym (+-leftIdentity (n + o)) ⟩\n zero + (n + o) ∎\n\n+-assoc (nsucc {m} Nm) n o =\n succ₁ m + n + o ≡⟨ +-leftCong (+-Sx m n) ⟩\n succ₁ (m + n) + o ≡⟨ +-Sx (m + n) o ⟩\n succ₁ (m + n + o) ≡⟨ succCong (+-assoc Nm n o) ⟩\n succ₁ (m + (n + o)) ≡⟨ sym (+-Sx m (n + o)) ⟩\n succ₁ m + (n + o) ∎\n\nx+Sy≡S[x+y] : ∀ {m} → N m → ∀ n → m + succ₁ n ≡ succ₁ (m + n)\nx+Sy≡S[x+y] nzero n =\n zero + succ₁ n ≡⟨ +-leftIdentity (succ₁ n) ⟩\n succ₁ n ≡⟨ succCong (sym (+-leftIdentity n)) ⟩\n succ₁ (zero + n) ∎\n\nx+Sy≡S[x+y] (nsucc {m} Nm) n =\n succ₁ m + succ₁ n ≡⟨ +-Sx m (succ₁ n) ⟩\n succ₁ (m + succ₁ n) ≡⟨ succCong (x+Sy≡S[x+y] Nm n) ⟩\n succ₁ (succ₁ (m + n)) ≡⟨ succCong (sym (+-Sx m n)) ⟩\n succ₁ (succ₁ m + n) ∎\n\n0∸x : ∀ {n} → N n → zero ∸ n ≡ zero\n0∸x nzero = ∸-x0 zero\n0∸x (nsucc {n} Nn) =\n zero ∸ succ₁ n ≡⟨ ∸-xS zero n ⟩\n pred₁ (zero ∸ n) ≡⟨ predCong (0∸x Nn) ⟩\n pred₁ zero ≡⟨ pred-0 ⟩\n zero ∎\n\nS∸S : ∀ {m n} → N m → N n → succ₁ m ∸ succ₁ n ≡ m ∸ n\nS∸S {m} _ nzero =\n succ₁ m ∸ [1] ≡⟨ ∸-xS (succ₁ m) zero ⟩\n pred₁ (succ₁ m ∸ zero) ≡⟨ predCong (∸-x0 (succ₁ m)) ⟩\n pred₁ (succ₁ m) ≡⟨ pred-S m ⟩\n m ≡⟨ sym (∸-x0 m) ⟩\n m ∸ zero ∎\n\nS∸S nzero (nsucc {n} Nn) =\n [1] ∸ succ₁ (succ₁ n) ≡⟨ ∸-xS [1] (succ₁ n) ⟩\n pred₁ ([1] ∸ succ₁ n) ≡⟨ predCong (S∸S nzero Nn) ⟩\n pred₁ (zero ∸ n) ≡⟨ predCong (0∸x Nn) ⟩\n pred₁ zero ≡⟨ pred-0 ⟩\n zero ≡⟨ sym (0∸x (nsucc Nn)) ⟩\n zero ∸ succ₁ n ∎\n\nS∸S (nsucc {m} Nm) (nsucc {n} Nn) =\n succ₁ (succ₁ m) ∸ succ₁ (succ₁ n) ≡⟨ ∸-xS (succ₁ (succ₁ m)) (succ₁ n) ⟩\n pred₁ (succ₁ (succ₁ m) ∸ succ₁ n) ≡⟨ predCong (S∸S (nsucc Nm) Nn) ⟩\n pred₁ (succ₁ m ∸ n) ≡⟨ sym (∸-xS (succ₁ m) n) ⟩\n succ₁ m ∸ succ₁ n ∎\n\n[x+y]∸[x+z]≡y∸z : ∀ {m n o} → N m → N n → N o → (m + n) ∸ (m + o) ≡ n ∸ o\n[x+y]∸[x+z]≡y∸z {n = n} {o} nzero _ _ =\n (zero + n) ∸ (zero + o) ≡⟨ ∸-leftCong (+-leftIdentity n) ⟩\n n ∸ (zero + o) ≡⟨ ∸-rightCong (+-leftIdentity o) ⟩\n n ∸ o ∎\n\n[x+y]∸[x+z]≡y∸z {n = n} {o} (nsucc {m} Nm) Nn No =\n (succ₁ m + n) ∸ (succ₁ m + o) ≡⟨ ∸-leftCong (+-Sx m n) ⟩\n succ₁ (m + n) ∸ (succ₁ m + o) ≡⟨ ∸-rightCong (+-Sx m o) ⟩\n succ₁ (m + n) ∸ succ₁ (m + o) ≡⟨ S∸S (+-N Nm Nn) (+-N Nm No) ⟩\n (m + n) ∸ (m + o) ≡⟨ [x+y]∸[x+z]≡y∸z Nm Nn No ⟩\n n ∸ o ∎\n\n+-comm : ∀ {m n} → N m → N n → m + n ≡ n + m\n+-comm {n = n} nzero Nn =\n zero + n ≡⟨ +-leftIdentity n ⟩\n n ≡⟨ sym (+-rightIdentity Nn) ⟩\n n + zero ∎\n\n+-comm {n = n} (nsucc {m} Nm) Nn =\n succ₁ m + n ≡⟨ +-Sx m n ⟩\n succ₁ (m + n) ≡⟨ succCong (+-comm Nm Nn) ⟩\n succ₁ (n + m) ≡⟨ sym (x+Sy≡S[x+y] Nn m) ⟩\n n + succ₁ m ∎\n\n*-leftZero : ∀ n → zero * n ≡ zero\n*-leftZero = *-0x\n\n*-rightZero : ∀ {n} → N n → n * zero ≡ zero\n*-rightZero nzero = *-leftZero zero\n*-rightZero (nsucc {n} Nn) =\n trans (*-Sx n zero)\n (trans (+-leftIdentity (n * zero)) (*-rightZero Nn))\n\n*-N : ∀ {m n} → N m → N n → N (m * n)\n*-N {n = n} nzero _ = subst N (sym (*-leftZero n)) nzero\n*-N {n = n} (nsucc {m} Nm) Nn = subst N (sym (*-Sx m n)) (+-N Nn (*-N Nm Nn))\n\n*-leftIdentity : ∀ {n} → N n → [1] * n ≡ n\n*-leftIdentity {n} Nn =\n [1] * n ≡⟨ *-Sx zero n ⟩\n n + zero * n ≡⟨ +-rightCong (*-leftZero n) ⟩\n n + zero ≡⟨ +-rightIdentity Nn ⟩\n n ∎\n\nx*Sy≡x+xy : ∀ {m n} → N m → N n → m * succ₁ n ≡ m + m * n\nx*Sy≡x+xy {n = n} nzero Nn = sym\n (\n zero + zero * n ≡⟨ +-rightCong (*-leftZero n) ⟩\n zero + zero ≡⟨ +-leftIdentity zero ⟩\n zero ≡⟨ sym (*-leftZero (succ₁ n)) ⟩\n zero * succ₁ n ∎\n )\n\nx*Sy≡x+xy {n = n} (nsucc {m} Nm) Nn =\n succ₁ m * succ₁ n\n ≡⟨ *-Sx m (succ₁ n) ⟩\n succ₁ n + m * succ₁ n\n ≡⟨ +-rightCong (x*Sy≡x+xy Nm Nn) ⟩\n succ₁ n + (m + m * n)\n ≡⟨ +-Sx n (m + m * n) ⟩\n succ₁ (n + (m + m * n))\n ≡⟨ succCong (sym (+-assoc Nn m (m * n))) ⟩\n succ₁ (n + m + m * n)\n ≡⟨ succCong (+-leftCong (+-comm Nn Nm)) ⟩\n succ₁ (m + n + m * n)\n ≡⟨ succCong (+-assoc Nm n (m * n)) ⟩\n succ₁ (m + (n + m * n))\n ≡⟨ sym (+-Sx m (n + m * n)) ⟩\n succ₁ m + (n + m * n)\n ≡⟨ +-rightCong (sym (*-Sx m n)) ⟩\n succ₁ m + succ₁ m * n ∎\n\n*-comm : ∀ {m n} → N m → N n → m * n ≡ n * m\n*-comm {n = n} nzero Nn = trans (*-leftZero n) (sym (*-rightZero Nn))\n*-comm {n = n} (nsucc {m} Nm) Nn =\n succ₁ m * n ≡⟨ *-Sx m n ⟩\n n + m * n ≡⟨ +-rightCong (*-comm Nm Nn) ⟩\n n + n * m ≡⟨ sym (x*Sy≡x+xy Nn Nm) ⟩\n n * succ₁ m ∎\n\n*∸-leftDistributive : ∀ {m n o} → N m → N n → N o → (m ∸ n) * o ≡ m * o ∸ n * o\n*∸-leftDistributive {m} {o = o} _ nzero _ =\n (m ∸ zero) * o ≡⟨ *-leftCong (∸-x0 m) ⟩\n m * o ≡⟨ sym (∸-x0 (m * o)) ⟩\n m * o ∸ zero ≡⟨ ∸-rightCong (sym (*-leftZero o)) ⟩\n m * o ∸ zero * o ∎\n\n*∸-leftDistributive {o = o} nzero (nsucc {n} Nn) No =\n (zero ∸ succ₁ n) * o ≡⟨ *-leftCong (0∸x (nsucc Nn)) ⟩\n zero * o ≡⟨ *-leftZero o ⟩\n zero ≡⟨ sym (0∸x (*-N (nsucc Nn) No)) ⟩\n zero ∸ succ₁ n * o ≡⟨ ∸-leftCong (sym (*-leftZero o)) ⟩\n zero * o ∸ succ₁ n * o ∎\n\n*∸-leftDistributive (nsucc {m} Nm) (nsucc {n} Nn) nzero =\n (succ₁ m ∸ succ₁ n) * zero\n ≡⟨ *-comm (∸-N (nsucc Nm) (nsucc Nn)) nzero ⟩\n zero * (succ₁ m ∸ succ₁ n)\n ≡⟨ *-leftZero (succ₁ m ∸ succ₁ n) ⟩\n zero\n ≡⟨ sym (0∸x (*-N (nsucc Nn) nzero)) ⟩\n zero ∸ succ₁ n * zero\n ≡⟨ ∸-leftCong (sym (*-leftZero (succ₁ m))) ⟩\n zero * succ₁ m ∸ succ₁ n * zero\n ≡⟨ ∸-leftCong (*-comm nzero (nsucc Nm)) ⟩\n succ₁ m * zero ∸ succ₁ n * zero ∎\n\n*∸-leftDistributive (nsucc {m} Nm) (nsucc {n} Nn) (nsucc {o} No) =\n (succ₁ m ∸ succ₁ n) * succ₁ o\n ≡⟨ *-leftCong (S∸S Nm Nn) ⟩\n (m ∸ n) * succ₁ o\n ≡⟨ *∸-leftDistributive Nm Nn (nsucc No) ⟩\n m * succ₁ o ∸ n * succ₁ o\n ≡⟨ sym ([x+y]∸[x+z]≡y∸z (nsucc No) (*-N Nm (nsucc No)) (*-N Nn (nsucc No))) ⟩\n (succ₁ o + m * succ₁ o) ∸ (succ₁ o + n * succ₁ o)\n ≡⟨ ∸-leftCong (sym (*-Sx m (succ₁ o))) ⟩\n (succ₁ m * succ₁ o) ∸ (succ₁ o + n * succ₁ o)\n ≡⟨ ∸-rightCong (sym (*-Sx n (succ₁ o))) ⟩\n (succ₁ m * succ₁ o) ∸ (succ₁ n * succ₁ o) ∎\n\n*+-leftDistributive : ∀ {m n o} → N m → N n → N o → (m + n) * o ≡ m * o + n * o\n*+-leftDistributive {m} {n} Nm Nn nzero =\n (m + n) * zero\n ≡⟨ *-comm (+-N Nm Nn) nzero ⟩\n zero * (m + n)\n ≡⟨ *-leftZero (m + n) ⟩\n zero\n ≡⟨ sym (*-leftZero m) ⟩\n zero * m\n ≡⟨ *-comm nzero Nm ⟩\n m * zero\n ≡⟨ sym (+-rightIdentity (*-N Nm nzero)) ⟩\n m * zero + zero\n ≡⟨ +-rightCong (trans (sym (*-leftZero n)) (*-comm nzero Nn)) ⟩\n m * zero + n * zero ∎\n\n*+-leftDistributive {n = n} nzero Nn (nsucc {o} No) =\n (zero + n) * succ₁ o ≡⟨ *-leftCong (+-leftIdentity n) ⟩\n n * succ₁ o ≡⟨ sym (+-leftIdentity (n * succ₁ o)) ⟩\n zero + n * succ₁ o ≡⟨ +-leftCong (sym (*-leftZero (succ₁ o))) ⟩\n zero * succ₁ o + n * succ₁ o ∎\n\n*+-leftDistributive (nsucc {m} Nm) nzero (nsucc {o} No) =\n (succ₁ m + zero) * succ₁ o\n ≡⟨ *-leftCong (+-rightIdentity (nsucc Nm)) ⟩\n succ₁ m * succ₁ o\n ≡⟨ sym (+-rightIdentity (*-N (nsucc Nm) (nsucc No))) ⟩\n succ₁ m * succ₁ o + zero\n ≡⟨ +-rightCong (sym (*-leftZero (succ₁ o))) ⟩\n succ₁ m * succ₁ o + zero * succ₁ o ∎\n\n*+-leftDistributive (nsucc {m} Nm) (nsucc {n} Nn) (nsucc {o} No) =\n (succ₁ m + succ₁ n) * succ₁ o\n ≡⟨ *-leftCong (+-Sx m (succ₁ n)) ⟩\n succ₁ (m + succ₁ n) * succ₁ o\n ≡⟨ *-Sx (m + succ₁ n) (succ₁ o) ⟩\n succ₁ o + (m + succ₁ n) * succ₁ o\n ≡⟨ +-rightCong (*+-leftDistributive Nm (nsucc Nn) (nsucc No)) ⟩\n succ₁ o + (m * succ₁ o + succ₁ n * succ₁ o)\n ≡⟨ sym (+-assoc (nsucc No) (m * succ₁ o) (succ₁ n * succ₁ o)) ⟩\n succ₁ o + m * succ₁ o + succ₁ n * succ₁ o\n ≡⟨ +-leftCong (sym (*-Sx m (succ₁ o))) ⟩\n succ₁ m * succ₁ o + succ₁ n * succ₁ o ∎\n", "meta": {"hexsha": "223294d7ff296fe288da395276f5ff52efa22649", "size": 11217, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/LTC-PCF/Data/Nat/Properties.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/LTC-PCF/Data/Nat/Properties.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/LTC-PCF/Data/Nat/Properties.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 34.1981707317, "max_line_length": 81, "alphanum_fraction": 0.4494963003, "num_tokens": 5276, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152324983301568, "lm_q2_score": 0.7371581684030623, "lm_q1q2_score": 0.6009552952917109}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Categories.Limits.Terminal where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\nopen import Cubical.HITs.PropositionalTruncation.Base\n\nopen import Cubical.Data.Sigma\n\nopen import Cubical.Categories.Category\n\nprivate\n variable\n ℓ ℓ' : Level\n\nmodule _ (C : Category ℓ ℓ') where\n open Category C\n\n isTerminal : (x : ob) → Type (ℓ-max ℓ ℓ')\n isTerminal x = ∀ (y : ob) → isContr (C [ y , x ])\n\n Terminal : Type (ℓ-max ℓ ℓ')\n Terminal = Σ[ x ∈ ob ] isTerminal x\n\n terminalOb : Terminal → ob\n terminalOb = fst\n\n terminalArrow : (T : Terminal) (y : ob) → C [ y , terminalOb T ]\n terminalArrow T y = T .snd y .fst\n\n terminalArrowUnique : {T : Terminal} {y : ob} (f : C [ y , terminalOb T ])\n → terminalArrow T y ≡ f\n terminalArrowUnique {T} {y} f = T .snd y .snd f\n\n terminalEndoIsId : (T : Terminal) (f : C [ terminalOb T , terminalOb T ])\n → f ≡ id\n terminalEndoIsId T f = isContr→isProp (T .snd (terminalOb T)) f id\n\n hasTerminal : Type (ℓ-max ℓ ℓ')\n hasTerminal = ∥ Terminal ∥₁\n\n -- Terminality of an object is a proposition.\n isPropIsTerminal : (x : ob) → isProp (isTerminal x)\n isPropIsTerminal _ = isPropΠ λ _ → isPropIsContr\n\n open CatIso\n\n -- Objects that are initial are isomorphic.\n terminalToIso : (x y : Terminal) → CatIso C (terminalOb x) (terminalOb y)\n mor (terminalToIso x y) = terminalArrow y (terminalOb x)\n inv (terminalToIso x y) = terminalArrow x (terminalOb y)\n sec (terminalToIso x y) = terminalEndoIsId y _\n ret (terminalToIso x y) = terminalEndoIsId x _\n\n open isUnivalent\n\n -- The type of terminal objects of a univalent category is a proposition,\n -- i.e. all terminal objects are equal.\n isPropTerminal : (hC : isUnivalent C) → isProp Terminal\n isPropTerminal hC x y =\n Σ≡Prop isPropIsTerminal (CatIsoToPath hC (terminalToIso x y))\n", "meta": {"hexsha": "b9a472ddaa4b93d953730f0baa9c5cf7e2d738ad", "size": 1900, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Limits/Terminal.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_issues_repo_path": "Cubical/Categories/Limits/Terminal.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Categories/Limits/Terminal.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.6451612903, "max_line_length": 76, "alphanum_fraction": 0.6742105263, "num_tokens": 598, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.815232489352, "lm_q2_score": 0.7371581568543043, "lm_q1q2_score": 0.6009552792584666}} {"text": "{-\n\nThis file contains:\n\n- Properties of set truncations\n\n-}\n{-# OPTIONS --cubical --safe #-}\nmodule Cubical.HITs.SetTruncation.Properties where\n\nopen import Cubical.HITs.SetTruncation.Base\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.HLevels\n\nprivate\n variable\n ℓ : Level\n A : Type ℓ\n\n-- lemma 6.9.1 in HoTT book\nelim : {B : ∥ A ∥₀ → Type ℓ} →\n (Bset : (x : ∥ A ∥₀) → isSet (B x)) →\n (g : (a : A) → B (∣ a ∣₀)) →\n (x : ∥ A ∥₀) → B x\nelim Bset g ∣ a ∣₀ = g a\nelim {A = A} {B = B} Bset g (squash₀ x y p q i j) =\n isOfHLevel→isOfHLevelDep 2 Bset _ _\n (cong (elim Bset g) p) (cong (elim Bset g) q) (squash₀ x y p q) i j\n\nsetTruncUniversal : {B : Type ℓ} → (isSet B) → (∥ A ∥₀ → B) ≃ (A → B)\nsetTruncUniversal Bset = isoToEquiv (iso intro out leftInv rightInv)\n where\n intro = (λ h a → h ∣ a ∣₀)\n out = elim (λ x → Bset)\n\n leftInv : ∀ g → intro (out g) ≡ g\n leftInv g = refl\n\n rightInv : ∀ h → out (intro h) ≡ h\n rightInv h i x =\n elim (λ x → isProp→isSet (Bset (out (intro h) x) (h x))) (λ a → refl) x i\n\nelim2 : {B : ∥ A ∥₀ → ∥ A ∥₀ → Type ℓ}\n (Bset : ((x y : ∥ A ∥₀) → isSet (B x y)))\n (g : (a b : A) → B ∣ a ∣₀ ∣ b ∣₀)\n (x y : ∥ A ∥₀) → B x y\nelim2 Bset g =\n elim (λ _ → isOfHLevelPi 2 (λ _ → Bset _ _))\n (λ a → elim (λ _ → Bset _ _) (λ b → g a b))\n\nelim3 : {B : (x y z : ∥ A ∥₀) → Type ℓ}\n (Bset : ((x y z : ∥ A ∥₀) → isSet (B x y z)))\n (g : (a b c : A) → B ∣ a ∣₀ ∣ b ∣₀ ∣ c ∣₀)\n (x y z : ∥ A ∥₀) → B x y z\nelim3 Bset g =\n elim2 (λ _ _ → isOfHLevelPi 2 λ _ → Bset _ _ _)\n (λ a b → elim (λ _ → Bset _ _ _) (λ c → g a b c))\n\nsetTruncIsSet : isSet ∥ A ∥₀\nsetTruncIsSet a b p q = squash₀ a b p q\n\nsetId : isSet A → ∥ A ∥₀ ≡ A\nsetId {A = A} isset =\n isoToPath (iso (elim {A = A} (λ _ → isset) (λ x → x)) (λ x → ∣ x ∣₀) (λ b → refl) (λ b → idLemma b))\n where\n idLemma : ∀ (b : ∥ A ∥₀) → ∣ elim (λ x → isset) (λ x → x) b ∣₀ ≡ b\n idLemma b =\n elim {B = (λ x → ∣ elim (λ _ → isset) (λ x → x) x ∣₀ ≡ x)}\n (λ x → isOfHLevelSuc 2 (setTruncIsSet {A = A}) ∣ elim (λ _ → isset) (λ x₁ → x₁) x ∣₀ x)\n (λ _ → refl)\n b\n", "meta": {"hexsha": "a9f795e55c8c9720eb1748b9f7d4f4b1acdc0f04", "size": 2172, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/SetTruncation/Properties.agda", "max_stars_repo_name": "borsiemir/cubical", "max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/HITs/SetTruncation/Properties.agda", "max_issues_repo_name": "borsiemir/cubical", "max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/HITs/SetTruncation/Properties.agda", "max_forks_repo_name": "borsiemir/cubical", "max_forks_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.96, "max_line_length": 102, "alphanum_fraction": 0.5345303867, "num_tokens": 993, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.815232480373843, "lm_q2_score": 0.7371581626286834, "lm_q1q2_score": 0.6009552773476063}} {"text": "{-# OPTIONS --without-K --safe --exact-split #-}\n\nmodule Constructive.Common where\n\nopen import Level\nopen import Data.Product\nopen import Data.Sum\nopen import Function.Base\nopen import Relation.Nullary\n\ninfix 2 _<=>_\n\n-- Logical equivalence\n_<=>_ : ∀ {a b} → Set a → Set b → Set (a ⊔ b)\nA <=> B = (A → B) × (B → A)\n\nmodule _ {a b} {A : Set a} {B : Set b} where\n mk<=> : (A → B) → (B → A) → A <=> B\n mk<=> = _,_\n\n fwd : A <=> B → A → B\n fwd = proj₁\n\n bwd : A <=> B → B → A\n bwd = proj₂\n\n_∘<=>_ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} →\n B <=> C → A <=> B → A <=> C\n(f , g) ∘<=> (h , i) = f ∘ h , i ∘ g\n\nStable : ∀ {a} → Set a → Set a\nStable A = ¬ ¬ A → A\n\nDec⊎ : ∀ {a} → Set a → Set a\nDec⊎ A = A ⊎ ¬ A\n\n-- Unary decidable predicate\nDecU : ∀ {a p} {A : Set a} → (A → Set p) → Set (a ⊔ p)\nDecU P = ∀ x → P x ⊎ ¬ P x\n\nInhabited : ∀ {a} → Set a → Set a\nInhabited A = A\n", "meta": {"hexsha": "067c6c94975379ddebb37c740e31c212b3efddf9", "size": 887, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Constructive/Common.agda", "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_issues_repo_path": "Constructive/Common.agda", "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Constructive/Common.agda", "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.6279069767, "max_line_length": 56, "alphanum_fraction": 0.4870349493, "num_tokens": 370, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.815232480373843, "lm_q2_score": 0.7371581568543044, "lm_q1q2_score": 0.600955272640145}} {"text": "\n-- Interpretation of signature arities\nmodule SOAS.Syntax.Arguments {T : Set} where\n\nopen import SOAS.Common\nopen import SOAS.Context {T}\nopen import SOAS.Variable\nopen import SOAS.Families.Core {T}\n\nopen import Data.List.Base using ([] ; _∷_ ; List)\nopen import Data.Product\nopen import Data.Unit\n\n-- List of arities as a product of terms in extended contexts\nArg : List (Ctx × T) → Familyₛ → Family\nArg [] 𝒳 Γ = ⊤\nArg ((Θ , τ) ∷ []) 𝒳 Γ = 𝒳 τ (Θ ∔ Γ)\nArg ((Θ , τ) ∷ as) 𝒳 Γ = 𝒳 τ (Θ ∔ Γ) × Arg as 𝒳 Γ\n\n-- Functorial action and laws\nArg₁ : {𝒳 𝒴 : Familyₛ} (as : List (Ctx × T))\n → (𝒳 ⇾̣ 𝒴) → Arg as 𝒳 ⇾ Arg as 𝒴\nArg₁ [] f tt = tt\nArg₁ ((Θ , τ) ∷ []) f t = f t\nArg₁ ((Θ , τ) ∷ (Θ′ , τ′) ∷ as) f (t , ts) = (f t) , (Arg₁ ((Θ′ , τ′) ∷ as) f ts)\n\nArg-id : {𝒳 : Familyₛ}{Γ : Ctx}(as : List (Ctx × T))(ts : Arg as 𝒳 Γ)\n → Arg₁ as id ts ≡ ts\nArg-id [] ts = refl\nArg-id (x ∷ []) t = refl\nArg-id (x ∷ y ∷ ys) (t , ts) = cong (_ ,_) (Arg-id (y ∷ ys) ts)\n\nArg-∘ : {𝒳 𝒴 𝒵 : Familyₛ}{Γ : Ctx}(as : List (Ctx × T))\n → {f : 𝒳 ⇾̣ 𝒴}{g : 𝒴 ⇾̣ 𝒵}\n → (ts : Arg as 𝒳 Γ)\n → Arg₁ as (g ∘ f) ts\n ≡ Arg₁ as g (Arg₁ as f ts)\nArg-∘ [] ts = refl\nArg-∘ (x ∷ []) t = refl\nArg-∘ (x ∷ y ∷ ys) (t , ts) = cong (_ ,_) (Arg-∘ (y ∷ ys) ts)\n\nArg-resp : {𝒳 𝒴 : Familyₛ}{Γ : Ctx}(as : List (Ctx × T))\n → {f g : 𝒳 ⇾̣ 𝒴}\n → ({τ : T}{Δ : Ctx}(x : 𝒳 τ Δ) → f x ≡ g x)\n → (ts : Arg as 𝒳 Γ)\n → Arg₁ as f ts ≡ Arg₁ as g ts\nArg-resp [] p ts = refl\nArg-resp (x ∷ []) p t = p t\nArg-resp (x ∷ y ∷ ys) p (t , ts) = cong₂ _,_ (p t) (Arg-resp (y ∷ ys) p ts)\n\nArgF : List (Ctx × T) → Functor 𝔽amiliesₛ 𝔽amilies\nArgF as = record\n { F₀ = Arg as\n ; F₁ = Arg₁ as\n ; identity = Arg-id as _\n ; homomorphism = Arg-∘ as _\n ; F-resp-≈ = λ p → Arg-resp as (λ _ → p) _\n }\n", "meta": {"hexsha": "3f5c2639bf3c44afb3e9b8dd5d0ca20c07f4d67a", "size": 1790, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "SOAS/Syntax/Arguments.agda", "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_issues_repo_path": "SOAS/Syntax/Arguments.agda", "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_forks_repo_path": "SOAS/Syntax/Arguments.agda", "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "avg_line_length": 30.3389830508, "max_line_length": 81, "alphanum_fraction": 0.5061452514, "num_tokens": 825, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.815232480373843, "lm_q2_score": 0.7371581568543044, "lm_q1q2_score": 0.600955272640145}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Definition of and lemmas related to \"true infinitely often\"\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Nat.InfinitelyOften where\n\nopen import Category.Monad using (RawMonad)\nopen import Level using (0ℓ)\nopen import Data.Empty using (⊥-elim)\nopen import Data.Nat\nopen import Data.Nat.Properties\nopen import Data.Product as Prod hiding (map)\nopen import Data.Sum hiding (map)\nopen import Function\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary using (¬_)\nopen import Relation.Nullary.Negation using (¬¬-Monad; call/cc)\nopen import Relation.Unary using (Pred; _∪_; _⊆_)\nopen RawMonad (¬¬-Monad {p = 0ℓ})\n\n-- Only true finitely often.\n\nFin : ∀ {ℓ} → Pred ℕ ℓ → Set ℓ\nFin P = ∃ λ i → ∀ j → i ≤ j → ¬ P j\n\n-- A non-constructive definition of \"true infinitely often\".\n\nInf : ∀ {ℓ} → Pred ℕ ℓ → Set ℓ\nInf P = ¬ Fin P\n\n-- Fin is preserved by binary sums.\n\n_∪-Fin_ : ∀ {ℓp ℓq P Q} → Fin {ℓp} P → Fin {ℓq} Q → Fin (P ∪ Q)\n_∪-Fin_ {P = P} {Q} (i , ¬p) (j , ¬q) = (i ⊔ j , helper)\n where\n open ≤-Reasoning\n\n helper : ∀ k → i ⊔ j ≤ k → ¬ (P ∪ Q) k\n helper k i⊔j≤k (inj₁ p) = ¬p k (begin\n i ≤⟨ m≤m⊔n i j ⟩\n i ⊔ j ≤⟨ i⊔j≤k ⟩\n k ∎) p\n helper k i⊔j≤k (inj₂ q) = ¬q k (begin\n j ≤⟨ m≤m⊔n j i ⟩\n j ⊔ i ≡⟨ ⊔-comm j i ⟩\n i ⊔ j ≤⟨ i⊔j≤k ⟩\n k ∎) q\n\n-- Inf commutes with binary sums (in the double-negation monad).\n\ncommutes-with-∪ : ∀ {P Q} → Inf (P ∪ Q) → ¬ ¬ (Inf P ⊎ Inf Q)\ncommutes-with-∪ p∪q =\n call/cc λ ¬[p⊎q] →\n (λ ¬p ¬q → ⊥-elim (p∪q (¬p ∪-Fin ¬q)))\n <$> ¬[p⊎q] ∘ inj₁ ⊛ ¬[p⊎q] ∘ inj₂\n\n-- Inf is functorial.\n\nmap : ∀ {ℓp ℓq P Q} → P ⊆ Q → Inf {ℓp} P → Inf {ℓq} Q\nmap P⊆Q ¬fin = ¬fin ∘ Prod.map id (λ fin j i≤j → fin j i≤j ∘ P⊆Q)\n\n-- Inf is upwards closed.\n\nup : ∀ {ℓ P} n → Inf {ℓ} P → Inf (P ∘ _+_ n)\nup zero = id\nup {P = P} (suc n) = up n ∘ up₁\n where\n up₁ : Inf P → Inf (P ∘ suc)\n up₁ ¬fin (i , fin) = ¬fin (suc i , helper)\n where\n helper : ∀ j → 1 + i ≤ j → ¬ P j\n helper ._ (s≤s i≤j) = fin _ i≤j\n\n-- A witness.\n\nwitness : ∀ {ℓ P} → Inf {ℓ} P → ¬ ¬ ∃ P\nwitness ¬fin ¬p = ¬fin (0 , λ i _ Pi → ¬p (i , Pi))\n\n-- Two different witnesses.\n\ntwoDifferentWitnesses\n : ∀ {P} → Inf P → ¬ ¬ ∃₂ λ m n → m ≢ n × P m × P n\ntwoDifferentWitnesses inf =\n witness inf >>= λ w₁ →\n witness (up (1 + proj₁ w₁) inf) >>= λ w₂ →\n return (_ , _ , m≢1+m+n (proj₁ w₁) , proj₂ w₁ , proj₂ w₂)\n", "meta": {"hexsha": "06b3b5abbf0b6e4c2bcee55dffe30643a77848bf", "size": 2568, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Nat/InfinitelyOften.agda", "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Nat/InfinitelyOften.agda", "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Nat/InfinitelyOften.agda", "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.2197802198, "max_line_length": 72, "alphanum_fraction": 0.5218068536, "num_tokens": 1037, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916205190225, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.6008845860643373}} {"text": "------------------------------------------------------------------------\n-- Some simple binary relations\n------------------------------------------------------------------------\n\nmodule Relation.Binary.Simple where\n\nopen import Relation.Binary\nopen import Data.Unit\nopen import Data.Empty\n\n-- Constant relations.\n\nConst : ∀ {a} → Set → Rel a\nConst I = λ _ _ → I\n\n-- The universally true relation.\n\nAlways : ∀ {a} → Rel a\nAlways = Const ⊤\n\n-- The universally false relation.\n\nNever : ∀ {a} → Rel a\nNever = Const ⊥\n\n-- Always is an equivalence.\n\nAlways-isEquivalence : ∀ {a} → IsEquivalence (Always {a})\nAlways-isEquivalence = record {}\n", "meta": {"hexsha": "ff5c8095f2fcf7c7e4e7212d685ceceb2bfd3980", "size": 635, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Relation/Binary/Simple.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Relation/Binary/Simple.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Relation/Binary/Simple.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 21.1666666667, "max_line_length": 72, "alphanum_fraction": 0.5322834646, "num_tokens": 131, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8633916099737806, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.6008845787252883}} {"text": "\nrecord Pointed (A : Set) : Set where\n field\n point : A\n\npoint : {A : Set} ⦃ p : Pointed A ⦄ → A\npoint ⦃ p = p ⦄ = Pointed.point p\n\nrecord R : Set₁ where\n field\n A : Set\n instance\n is-pointed : Pointed A\n\npostulate\n r : R\n\nopen R r\n\nx : R.A r\nx = point\n", "meta": {"hexsha": "4f06ffb6a3af6dd47c5c5c09831f51b02e3ae5b2", "size": 270, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1915.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue1915.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue1915.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 12.2727272727, "max_line_length": 39, "alphanum_fraction": 0.562962963, "num_tokens": 107, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8633915959134569, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.600884568939889}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Comonad.Relative where\n\nopen import Level\n\nopen import Categories.Category using (Category)\nopen import Categories.Functor using (Functor; Endofunctor; _∘F_) renaming (id to idF)\nimport Categories.Morphism.Reasoning as MR\nopen import Categories.NaturalTransformation renaming (id to idN)\nopen import Categories.NaturalTransformation.NaturalIsomorphism hiding (_≃_)\nopen import Categories.NaturalTransformation.Equivalence\nopen NaturalIsomorphism\n\nprivate\n variable\n o ℓ e o′ ℓ′ e′ : Level\n C : Category o ℓ e\n D : Category o′ ℓ′ e′\n\nrecord Comonad {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (J : Functor C D) : Set (o ⊔ o′ ⊔ ℓ′ ⊔ e′) where\n private\n module C = Category C\n module D = Category D\n module J = Functor J\n open D using (_⇒_; _∘_; _≈_)\n field\n F₀ : C.Obj → D.Obj\n counit : {c : C.Obj} → F₀ c ⇒ J.₀ c\n cobind : {x y : C.Obj} → (F₀ x ⇒ J.₀ y) → F₀ x ⇒ F₀ y\n identityʳ : {x y : C.Obj} { k : F₀ x ⇒ J.₀ y} → counit ∘ cobind k ≈ k\n identityˡ : {x : C.Obj} → cobind {x} counit ≈ D.id\n assoc : {x y z : C.Obj} {k : F₀ x ⇒ J.₀ y} {l : F₀ y ⇒ J.₀ z} →\n cobind (l ∘ cobind k) ≈ cobind l ∘ cobind k\n cobind-≈ : {x y : C.Obj} {k h : F₀ x ⇒ J.₀ y} → k ≈ h → cobind k ≈ cobind h\n\n-- From a Relative Comonad, we can extract a functor\nRComonad⇒Functor : {J : Functor C D} → Comonad J → Functor C D\nRComonad⇒Functor {C = C} {D = D} {J = J} r = record\n { F₀ = F₀\n ; F₁ = λ f → cobind (J.₁ f ∘ counit)\n ; identity = identity′\n ; homomorphism = hom′\n ; F-resp-≈ = λ f≈g → cobind-≈ (∘-resp-≈ˡ (J.F-resp-≈ f≈g))\n }\n where\n open Comonad r\n module C = Category C\n module D = Category D\n module J = Functor J\n open Category D hiding (identityˡ; identityʳ; assoc)\n open HomReasoning\n open MR D\n identity′ : {c : C.Obj} → cobind {c} (J.₁ C.id ∘ counit) ≈ id\n identity′ = begin\n cobind (J.₁ C.id ∘ counit) ≈⟨ cobind-≈ (elimˡ J.identity) ⟩\n cobind counit ≈⟨ identityˡ ⟩\n id ∎\n hom′ : {X Y Z : C.Obj} {f : X C.⇒ Y} {g : Y C.⇒ Z} →\n cobind (J.₁ (g C.∘ f) ∘ counit) ≈ cobind (J.₁ g ∘ counit) ∘ cobind (J.₁ f ∘ counit)\n hom′ {f = f} {g} = begin\n cobind (J.₁ (g C.∘ f) ∘ counit) ≈⟨ cobind-≈ (pushˡ J.homomorphism) ⟩\n cobind (J.₁ g ∘ J.₁ f ∘ counit) ≈⟨ cobind-≈ (pushʳ (⟺ identityʳ)) ⟩\n cobind ((J.₁ g ∘ counit) ∘ (cobind (J.F₁ f ∘ counit))) ≈⟨ assoc ⟩\n cobind (J.₁ g ∘ counit) ∘ cobind (J.F₁ f ∘ counit) ∎\n", "meta": {"hexsha": "6a3de7f851509dd5b8d894711ef5df5180c91b43", "size": 2526, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Comonad/Relative.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Comonad/Relative.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Comonad/Relative.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 38.8615384615, "max_line_length": 108, "alphanum_fraction": 0.5748218527, "num_tokens": 1029, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916064587, "lm_q2_score": 0.6959583124210896, "lm_q1q2_score": 0.6008845653895304}} {"text": "{-# OPTIONS --no-positivity-check\n #-}\n{-\n\n Data, Deliberately\n\n Conor McBride\n\n Workshop in Dependently Typed Programming\n Nottingham, 2008\n\n (Agda rendering by Ulf Norell)\n\n-}\nmodule Talk where\n\nopen import SomeBasicStuff\n\n-- Codes for (first order) inductive families.\ndata Code (I : Set) : Set1 where\n arg : (A : Set) -> (A -> Code I) -> Code I\n rec : I -> Code I -> Code I\n out : I -> Code I\n\n-- The semantics of a code is a functor.\n⟦_⟧ : {I : Set} -> Code I -> (I -> Set) -> I -> Set\n⟦ out i ⟧ X j = i == j\n⟦ arg A B ⟧ X j = Σ A \\a -> ⟦ B a ⟧ X j\n⟦ rec i C ⟧ X j = X i × ⟦ C ⟧ X j\n\nmap : {I : Set}{X Y : I -> Set}(C : Code I) ->\n ({i : I} -> X i -> Y i) ->\n {i : I} -> ⟦ C ⟧ X i -> ⟦ C ⟧ Y i\nmap (out i) f x = x\nmap (arg A B) f (a , b) = a , map (B a) f b\nmap (rec i C) f (a , b) = f a , map C f b\n\n-- Tying the recursive knot. The positivity checker won't spot that\n-- ⟦ C ⟧ X i is strictly positive i X, so we've switched it off.\ndata μ {I : Set}(C : Code I) : I -> Set where\n <_> : forall {i} -> ⟦ C ⟧ (μ C) i -> μ C i\n\n-- Who needs a primitive case-construct anyway?\ncase_of_ : {A : Set1}{ts : Enumeration} -> Enum ts -> Table A ts -> A\ncase t of tbl = lookup tbl t\n\n-- The code for lists\n`List` : Set -> Code True\n`List` X = arg _ \\t ->\n case t of\n \"nil\" ↦ out _\n ∣ \"cons\" ↦ arg X (\\_ -> rec _ (out _))\n ∣ []\n\n-- The actual list type\nList : Set -> Set\nList A = μ (`List` A) _\n\n-- We can define the code for vectors directly. However, the point is\n-- that we won't have to.\n`VecD` : Set -> Code Nat\n`VecD` X = arg _ \\t ->\n case t of\n \"nil\" ↦ out zero\n ∣ \"cons\" ↦ ( arg Nat \\n ->\n arg X \\_ ->\n rec n (out (suc n))\n )\n ∣ []\n\n-- An ornamentation of a datatype adds some new indexing.\ndata Orn {I : Set}(J : I -> Set) : Code I -> Set1 where\n arg : forall {A B} -> ((a : A) -> Orn J (B a)) -> Orn J (arg A B)\n rec : forall {i C} -> J i -> Orn J C -> Orn J (rec i C)\n out : forall {i} -> J i -> Orn J (out i)\n new : forall {C} -> (A : Set) -> (A -> Orn J C) -> Orn J C\n\n-- An ornamented datatype is indexed by pairs of the old and the new index.\norn : {I : Set}{J : I -> Set}{C : Code I} -> Orn J C -> Code (Σ I J)\norn (out j) = out (_ , j)\norn (arg B) = arg _ \\a -> orn (B a)\norn (new A B) = arg A \\a -> orn (B a)\norn (rec j C) = rec (_ , j) (orn C)\n\n-- We can forget the ornamentation and recover an element of the original type.\nforget' : {I : Set}{J : I -> Set}{C : Code I}{i : I}{j : J i}\n {X : Σ I J -> Set}{Y : I -> Set} ->\n ({i : I}{j : J i} -> X (i , j) -> Y i) ->\n (ΔC : Orn J C) -> ⟦ orn ΔC ⟧ X (i , j) -> ⟦ C ⟧ Y i\nforget' φ (out j) refl = refl\nforget' φ (arg B) (a , b) = a , forget' φ (B a) b\nforget' φ (new A B) (a , b) = forget' φ (B a) b\nforget' φ (rec j C) (a , b) = φ a , forget' φ C b\n\n-- The termination checker runs into the same problem as the positivity\n-- checker--it can't tell that forget' φ C x is only applying φ to\n-- things smaller than x.\nforget : {I : Set}{J : I -> Set}{C : Code I}{i : I}{j : J i}\n (ΔC : Orn J C) -> μ (orn ΔC) (i , j) -> μ C i\nforget ΔC < x > = < forget' (forget ΔC) ΔC x >\n\n-- A C-algebra over X takes us from ⟦ C ⟧ X i to X i.\nAlg : {I : Set} -> Code I -> (I -> Set) -> Set\nAlg C X = forall i -> ⟦ C ⟧ X i -> X i\n\n-- We can fold by an algebra.\nfold : {I : Set}{X : I -> Set}{C : Code I} ->\n Alg C X -> {i : I} -> μ C i -> X i\nfold {C = C} φ < x > = φ _ (map C (fold φ) x)\n\n-- A type can be ornamented an arbitrary algebra over its functor.\ndecorate : {I : Set}{X : I -> Set}(C : Code I)\n (φ : Alg C X) -> Orn X C\ndecorate (out i) φ = out (φ i refl)\ndecorate (arg A B) φ = arg \\a -> decorate (B a) (\\i b -> φ i (a , b))\ndecorate {X = X} (rec i C) φ = new (X i) \\x -> rec x (decorate C \\i b -> φ i (x , b))\n\n-- Main theorem: If you have an element in a type decorated by φ, you\n-- can recover forgotten decorations by folding with φ. Specialised to\n-- lists and vectors we get\n-- ∀ xs : Vec A n. length (forget xs) == n.\n-- Two-level definition as usual.\nthm' : {I : Set}{X J : I -> Set}{Y : Σ I J -> Set}\n (C : Code I){i : I}{j : J i}(φ : Alg C J)\n (F : {i : I} -> X i -> J i)\n (ψ : {i : I}{j : J i} -> Y (i , j) -> X i) ->\n ({i : I}{j : J i}(z : Y (i , j)) -> F (ψ z) == j) ->\n let ΔC = decorate C φ in\n (x : ⟦ orn ΔC ⟧ Y (i , j)) ->\n φ i (map C F (forget' ψ ΔC x)) == j\nthm' (out i) φ F ψ ih refl = refl\nthm' (arg A B) φ F ψ ih (a , b) = thm' (B a) (\\i b -> φ i (a , b)) F ψ ih b\nthm' (rec i C) {i = i0}{j = j0} φ F ψ ih (j , x , c)\n with F (ψ x) | ih x | thm' C (\\i b -> φ i (j , b)) F ψ ih c\n... | .j | refl | rest = rest\n\nthm : {I : Set}{J : I -> Set}(C : Code I){i : I}{j : J i}(φ : Alg C J) ->\n (x : μ (orn (decorate C φ)) (i , j)) ->\n fold φ (forget (decorate C φ) x) == j\nthm C φ < x > = thm' C φ (fold φ) (forget (decorate C φ)) (thm C φ) x\n\n-- Vectors as decorated lists.\n\nlengthAlg : {A : Set} -> Alg (`List` A) (\\_ -> Nat)\nlengthAlg _ (enum .\"nil\" zero , _) = zero\nlengthAlg _ (enum .\"cons\" (suc zero) , x , n , _) = suc n\nlengthAlg _ (enum _ (suc (suc ())) , _)\n\nlength : {A : Set} -> List A -> Nat\nlength = fold lengthAlg\n\n-- Now vectors are really lists decorated by their length.\n`Vec` : (A : Set) -> Orn (\\_ -> Nat) (`List` A)\n`Vec` A = decorate (`List` A) lengthAlg\n\nVec : Set -> Nat -> Set\nVec A n = μ (orn (`Vec` A)) (_ , n)\n\nnil : {A : Set} -> Vec A zero\nnil = < enum \"nil\" zero , refl >\n\ncons : {A : Set}{n : Nat} -> A -> Vec A n -> Vec A (suc n)\ncons {n = n} x xs = < enum \"cons\" (suc zero) , x , n , xs , refl >\n\n-- The proof that the index of the vector is really the length follows directly\n-- from our main theorem.\ncorollary : {A : Set}{n : Nat}(xs : Vec A n) ->\n length (forget (`Vec` _) xs) == n\ncorollary = thm (`List` _) lengthAlg\n", "meta": {"hexsha": "dfa47df508347623f043c85e164179fa4cc5b51b", "size": 5986, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/DTP08/conor/Talk.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/DTP08/conor/Talk.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/DTP08/conor/Talk.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 35.2117647059, "max_line_length": 85, "alphanum_fraction": 0.5005011694, "num_tokens": 2220, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339756938818, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.600765836286059}} {"text": "module T where\n\nopen import Prelude\n\nmodule GÖDEL-T where\n\n -- Core syntax\n infixr 30 _⇒_\n infixl 30 _$_\n data TTp : Set where\n nat : TTp\n _⇒_ : (A B : TTp) → TTp\n\n Ctx = List TTp\n\n data TExp (Γ : Ctx) : TTp → Set where\n var : ∀{A} (x : A ∈ Γ) → TExp Γ A\n Λ : ∀{A B} (e : TExp (A :: Γ) B) → TExp Γ (A ⇒ B)\n _$_ : ∀{A B} (e₁ : TExp Γ (A ⇒ B)) (e₂ : TExp Γ A) → TExp Γ B\n zero : TExp Γ nat\n suc : (e : TExp Γ nat) → TExp Γ nat\n rec : ∀{A} → (e : TExp Γ nat) → (e₀ : TExp Γ A) → (es : TExp (A :: Γ) A) →\n TExp Γ A\n\n TCExp = TExp []\n TNat = TCExp nat\n\n ---- denotational semantics\n interp : TTp → Set\n interp nat = Nat\n interp (A ⇒ B) = interp A → interp B\n\n meaningη : (Γ : Ctx) → Set\n meaningη Γ = ∀{A} (x : A ∈ Γ) → interp A\n\n emptyη : meaningη []\n emptyη ()\n\n extendη : ∀{Γ A} → meaningη Γ → interp A → meaningη (A :: Γ)\n extendη η M Z = M\n extendη η M (S n) = η n\n\n meaning : ∀{A Γ} → TExp Γ A → meaningη Γ → interp A\n meaning (var x) η = η x\n meaning (Λ e) η = λ x → meaning e (extendη η x)\n meaning (e₁ $ e₂) η = meaning e₁ η (meaning e₂ η)\n meaning zero η = Z\n meaning (suc e) η = S (meaning e η)\n meaning (rec e e₀ es) η = NAT.fold (meaning e₀ η)\n (λ n x → meaning es (extendη η x))\n (meaning e η)\n\n cmeaning : ∀{A} → TCExp A → interp A\n cmeaning e = meaning e emptyη\n\n ---- Definition related to substitution.\n -- Renamings\n TRen : Ctx → Ctx → Set\n TRen Γ Γ' = ∀ {A} → A ∈ Γ → A ∈ Γ'\n\n renId : ∀{Γ} → TRen Γ Γ\n renId = \\ x -> x\n\n renComp : ∀{B Γ Δ} → TRen Γ Δ → TRen B Γ → TRen B Δ\n renComp f g = f o g\n\n wk : ∀{Γ Γ' A} → TRen Γ Γ' → TRen (A :: Γ) (A :: Γ')\n wk f Z = Z\n wk f (S n) = S (f n)\n\n ren : ∀{Γ Γ'} → TRen Γ Γ' → ∀ {A} → TExp Γ A → TExp Γ' A\n ren γ (var x) = var (γ x)\n ren γ (Λ e) = Λ (ren (wk γ) e)\n ren γ (e₁ $ e₂) = (ren γ e₁) $ (ren γ e₂)\n ren γ zero = zero\n ren γ (suc e) = suc (ren γ e)\n ren γ (rec e e₀ es) = rec (ren γ e) (ren γ e₀) (ren (wk γ) es)\n\n -- Substitutions\n TSubst : Ctx → Ctx → Set\n TSubst Γ Γ' = ∀ {A} → A ∈ Γ → TExp Γ' A\n\n emptyγ : ∀{Γ} → TSubst Γ Γ\n emptyγ = λ x → var x\n\n liftγ : ∀{Γ Γ' A} → TSubst Γ Γ' → TSubst (A :: Γ) (A :: Γ')\n liftγ γ Z = var Z\n liftγ γ (S n) = ren S (γ n)\n\n singγ : ∀{Γ A} → TExp Γ A → TSubst (A :: Γ) Γ\n singγ e Z = e\n singγ e (S n) = var n\n\n dropγ : ∀{Γ A Γ'} → TSubst (A :: Γ) Γ' → TSubst Γ Γ'\n dropγ γ n = γ (S n)\n\n closed-wkγ : {Γ : Ctx} → TRen [] Γ\n closed-wkγ ()\n\n ssubst : ∀{Γ Γ' C} →\n (γ : TSubst Γ Γ') →\n (e : TExp Γ C) →\n TExp Γ' C\n ssubst γ (var x) = γ x\n ssubst γ (Λ e) = Λ (ssubst (liftγ γ) e)\n ssubst γ (e₁ $ e₂) = (ssubst γ e₁) $ (ssubst γ e₂)\n ssubst γ zero = zero\n ssubst γ (suc e) = suc (ssubst γ e)\n ssubst γ (rec e e₀ es) = rec (ssubst γ e) (ssubst γ e₀) (ssubst (liftγ γ) es)\n\n subComp : ∀{B Γ Γ'} → TSubst Γ Γ' → TSubst B Γ → TSubst B Γ'\n subComp f g = ssubst f o g\n\n extendγ : ∀{Γ Γ' A} → TSubst Γ Γ' → TExp Γ' A → TSubst (A :: Γ) Γ'\n extendγ γ e = subComp (singγ e) (liftγ γ)\n\n\n -- substituting one thing in a closed term\n subst : ∀{A C} → (e' : TCExp A) → (e : TExp (A :: []) C) → TCExp C\n subst e' e = ssubst (singγ e') e\n\n weaken-closed : ∀{Γ B} → TCExp B → TExp Γ B\n weaken-closed e = ren closed-wkγ e\n\n ---- dynamic semantics (and, implicitly, preservation)\n data TVal : ∀{Γ A} → TExp Γ A → Set where\n val-zero : ∀{Γ} → TVal {Γ} zero\n val-suc : ∀{Γ e} → TVal {Γ} e → TVal {Γ} (suc e)\n val-lam : ∀{A B} {e : TExp (A :: []) B} → TVal (Λ e)\n\n -- only worry about closed steps; embed preservation in the statement\n -- We are call-by-name for function application, but call-by-value for natural evaluation.\n -- This is so that any value of type nat is a numeral.\n data _~>_ : ∀{A} → TCExp A → TCExp A → Set where\n step-app-l : ∀{A B} {e₁ e₁' : TCExp (A ⇒ B)} {e₂ : TCExp A} →\n e₁ ~> e₁' → (e₁ $ e₂) ~> (e₁' $ e₂)\n step-beta : ∀{A B} {e : TExp (A :: []) B} {e' : TCExp A} →\n ((Λ e) $ e') ~> (subst e' e)\n step-suc : ∀{e e' : TCExp nat} →\n e ~> e' → (suc e) ~> (suc e')\n step-rec : ∀{A} {e e' : TCExp nat} {e₀ : TCExp A} {es : TExp (A :: []) A} →\n e ~> e' → (rec e e₀ es) ~> (rec e' e₀ es)\n step-rec-z : ∀{A} {e₀ : TCExp A} {es : TExp (A :: []) A} →\n (rec zero e₀ es) ~> e₀\n step-rec-s : ∀{A} {e : TCExp nat} {e₀ : TCExp A} {es : TExp (A :: []) A} →\n TVal e → (rec (suc e) e₀ es) ~> subst (rec e e₀ es) es\n\n -- iterated stepping\n data _~>*_ : ∀{A} → TCExp A → TCExp A → Set where\n eval-refl : ∀{A} {e : TCExp A} → e ~>* e\n eval-cons : ∀{A} {e e' e'' : TCExp A} →\n e ~> e' → e' ~>* e'' → e ~>* e''\n\n eval-step : ∀{A} {e e' : TCExp A} → e ~> e' → e ~>* e'\n eval-step s = eval-cons s eval-refl\n\n -- Should I use a record, or the product thing, or something else?\n data THalts : ∀{A} → TCExp A → Set where\n halts : {A : TTp} {e e' : TCExp A} → (eval : (e ~>* e')) → (val : TVal e') → THalts e\n\nopen GÖDEL-T public\n", "meta": {"hexsha": "e50111759215996d5e63937db3b5609401cecc67", "size": 5083, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "T.agda", "max_stars_repo_name": "msullivan/godels-t", "max_stars_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2016-12-25T01:52:57.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-22T00:28:03.000Z", "max_issues_repo_path": "T.agda", "max_issues_repo_name": "msullivan/godels-t", "max_issues_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "T.agda", "max_forks_repo_name": "msullivan/godels-t", "max_forks_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-04-26T11:39:14.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-04T22:37:18.000Z", "avg_line_length": 31.3765432099, "max_line_length": 92, "alphanum_fraction": 0.4908518591, "num_tokens": 2169, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339676722393, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.6007658356422939}} {"text": "{-# OPTIONS --without-K --safe #-}\n\n\nopen import Level\n\n-- Kan Complexes\n--\n-- These are technically \"Algebraic\" Kan Complexes, as they come with a choice of fillers\n-- However, this notion is far easier than the more geometric flavor,\n-- as we can sidestep questions about choice.\n\nmodule Categories.Category.Construction.KanComplex (o ℓ : Level) where\n\nopen import Data.Nat using (ℕ)\nopen import Data.Fin using (Fin; inject₁)\n\nopen import Categories.Category using (Category)\n\nopen import Categories.Category.Instance.SimplicialSet using (SimplicialSet)\nopen import Categories.Category.Instance.SimplicialSet.Properties o ℓ using (ΔSet; Δ[_]; Λ[_,_]; Λ-inj)\n\nopen Category (SimplicialSet o ℓ)\n\n-- A Kan complex is a simplicial set where every k-horn has a filler.\nrecord IsKanComplex (X : ΔSet) : Set (o ⊔ ℓ) where\n field\n filler : ∀ {n} {k} → Λ[ n , k ] ⇒ X → Δ[ n ] ⇒ X\n filler-cong : ∀ {n} {k} → {f g : Λ[ n , k ] ⇒ X} → f ≈ g → filler {n} f ≈ filler g\n is-filler : ∀ {n} {k} → (f : Λ[ n , k ] ⇒ X) → filler f ∘ Λ-inj k ≈ f\n\n-- 'inner k' will embed 'k : Fin n' into the \"inner\" portion of 'Fin (n + 2)'\n-- Visually, it looks a little something like:\n-- \n-- * * *\n-- | | | \n-- v v v\n-- * * * * *\n-- \n-- Note that this is set up in such a way that we can normalize\n-- as far as possible without pattern matching on 'i' in proofs.\ninner : ∀ {n} → Fin n → Fin (ℕ.suc (ℕ.suc n))\ninner i = Fin.suc (inject₁ i)\n\n-- A Weak Kan complex is similar to a Kan Complex, but where only \"inner horns\" have fillers.\n--\n-- The indexing here is tricky, but it lets us avoid extra proof conditions that the horn is an inner horn.\n-- The basic idea is that if we want an n-dimensional inner horn, then we only want to allow the faces {1,2,3...n-1}\n-- to be missing. We could do this by requiring proofs that the missing face is greater than 0 and less than n, but\n-- this makes working with the definition _extremely_ difficult.\n--\n-- To avoid this, we only allow an missing face index that ranges from 0 to n-2, and then embed that index\n-- into the full range of face indexes via 'inner'. This does require us to shift our indexes around a bit.\n-- To make this indexing more obvious, we use the suggestively named variable 'n-2'.\nrecord IsWeakKanComplex (X : ΔSet) : Set (o ⊔ ℓ) where\n field\n filler : ∀ {n-2} {k : Fin n-2} → Λ[ ℕ.suc (ℕ.suc n-2) , inner k ] ⇒ X → Δ[ ℕ.suc (ℕ.suc n-2) ] ⇒ X\n filler-cong : ∀ {n-2} {k : Fin n-2} → {f g : Λ[ ℕ.suc (ℕ.suc n-2) , inner k ] ⇒ X} → f ≈ g → filler f ≈ filler g\n is-filler : ∀ {n-2} {k : Fin n-2} → (f : Λ[ ℕ.suc (ℕ.suc n-2) , inner k ] ⇒ X) → filler f ∘ Λ-inj (inner k) ≈ f\n\nKanComplex⇒WeakKanComplex : ∀ {X} → IsKanComplex X → IsWeakKanComplex X\nKanComplex⇒WeakKanComplex complex = record { IsKanComplex complex }\n", "meta": {"hexsha": "55a5cb5d400c7e2360851dfc04916403479c8ccc", "size": 2786, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Construction/KanComplex.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/Construction/KanComplex.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/Construction/KanComplex.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 44.935483871, "max_line_length": 117, "alphanum_fraction": 0.6557788945, "num_tokens": 917, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339596505965, "lm_q2_score": 0.7154240079185319, "lm_q1q2_score": 0.6007658349985285}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category using (Category)\nopen import Categories.Category.Monoidal.Core using (Monoidal)\nopen import Categories.Category.Monoidal.Symmetric using (Symmetric)\n\nmodule Categories.Category.Monoidal.Star-Autonomous {o ℓ e} {C : Category o ℓ e} (M : Monoidal C) where\n\nopen import Level\n\nopen import Categories.Category.Product using (_⁂_; assocˡ)\nopen import Categories.Functor using (Functor; _∘F_; id)\nopen import Categories.Functor.Properties using (FullyFaithful)\nopen import Categories.NaturalTransformation.NaturalIsomorphism using (_≃_)\nopen import Categories.Functor.Hom\n\nopen Category C renaming (op to Cᵒᵖ) hiding (id)\nopen Monoidal M\nopen Functor ⊗ renaming (op to ⊗ₒₚ)\nopen Hom C\n\nrecord Star-Autonomous : Set (levelOfTerm M) where\n field\n symmetric : Symmetric M\n Star : Functor Cᵒᵖ C\n\n open Functor Star renaming (op to Starₒₚ) public\n\n field\n FF-Star : FullyFaithful Star\n A**≃A : (Star ∘F Starₒₚ) ≃ id\n 𝒞[A⊗B,C*]≃𝒞[A,B⊗C*] : Hom[-,-] ∘F (⊗ₒₚ ⁂ Star) ≃ Hom[-,-] ∘F (id ⁂ (Star ∘F ⊗ₒₚ)) ∘F assocˡ _ _ _\n", "meta": {"hexsha": "9f88fa738f7b227f1dbbada5b61ad07b0199aa97", "size": 1091, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Monoidal/Star-Autonomous.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/Monoidal/Star-Autonomous.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/Monoidal/Star-Autonomous.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 33.0606060606, "max_line_length": 103, "alphanum_fraction": 0.7241063245, "num_tokens": 362, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026595857203, "lm_q2_score": 0.6548947155710233, "lm_q1q2_score": 0.6007366643419335}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- M-types (the dual of W-types)\n------------------------------------------------------------------------\n\nmodule Data.M where\n\nopen import Level\nopen import Coinduction\n\n-- The family of M-types.\n\ndata M {a b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where\n inf : (x : A) (f : B x → ∞ (M A B)) → M A B\n\n-- Projections.\n\nhead : ∀ {a b} {A : Set a} {B : A → Set b} →\n M A B → A\nhead (inf x f) = x\n\ntail : ∀ {a b} {A : Set a} {B : A → Set b} →\n (x : M A B) → B (head x) → M A B\ntail (inf x f) b = ♭ (f b)\n", "meta": {"hexsha": "ed77f79a01c7f4f9379daea23e26a4d62fb47e0a", "size": 622, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/M.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/M.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Data/M.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.9230769231, "max_line_length": 72, "alphanum_fraction": 0.3826366559, "num_tokens": 199, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8933094060543488, "lm_q2_score": 0.6723317123102956, "lm_q1q2_score": 0.6006002425954136}} {"text": "module DeMorgan where\n\nopen import Definitions\n\ndeMorgan : {A B : Set} → ¬ A ∧ ¬ B → ¬ (A ∨ B)\ndeMorgan = {!!}\n\n", "meta": {"hexsha": "cc90ca4b51dd94b27cbe3c53708aa5d32f3fbd29", "size": 112, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "problems/DeMorgan/DeMorgan.agda", "max_stars_repo_name": "danr/agder", "max_stars_repo_head_hexsha": "ece25bed081a24f02e9f85056d05933eae2afabf", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-05-17T12:07:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-17T12:07:03.000Z", "max_issues_repo_path": "problems/DeMorgan/DeMorgan.agda", "max_issues_repo_name": "danr/agder", "max_issues_repo_head_hexsha": "ece25bed081a24f02e9f85056d05933eae2afabf", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "problems/DeMorgan/DeMorgan.agda", "max_forks_repo_name": "danr/agder", "max_forks_repo_head_hexsha": "ece25bed081a24f02e9f85056d05933eae2afabf", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 14.0, "max_line_length": 46, "alphanum_fraction": 0.5803571429, "num_tokens": 40, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8887587875995482, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.6005917333078796}} {"text": "module PiNF-syntax where\n\ninfixr 30 _⟷_\ninfixr 20 _◎_\n\n------------------------------------------------------------------------------\n-- First we define a universe of our value types\n\ndata B : Set where\n ZERO : B\n ONE : B\n PLUS : B → B → B\n NEG : B → B\n TIMES : B → B → B\n RECIP : B → B\n\n------------------------------------------------------------------------------\n-- Now we define another universe for our equivalences. First the codes for\n-- equivalences.\n\ndata _⟷_ : B → B → Set where\n unite₊ : { b : B } → PLUS ZERO b ⟷ b\n uniti₊ : { b : B } → b ⟷ PLUS ZERO b\n swap₊ : { b₁ b₂ : B } → PLUS b₁ b₂ ⟷ PLUS b₂ b₁\n assocl₊ : { b₁ b₂ b₃ : B } → PLUS b₁ (PLUS b₂ b₃) ⟷ PLUS (PLUS b₁ b₂) b₃\n assocr₊ : { b₁ b₂ b₃ : B } → PLUS (PLUS b₁ b₂) b₃ ⟷ PLUS b₁ (PLUS b₂ b₃)\n unite⋆ : { b : B } → TIMES ONE b ⟷ b\n uniti⋆ : { b : B } → b ⟷ TIMES ONE b\n swap⋆ : { b₁ b₂ : B } → TIMES b₁ b₂ ⟷ TIMES b₂ b₁\n assocl⋆ : { b₁ b₂ b₃ : B } → TIMES b₁ (TIMES b₂ b₃) ⟷ TIMES (TIMES b₁ b₂) b₃\n assocr⋆ : { b₁ b₂ b₃ : B } → TIMES (TIMES b₁ b₂) b₃ ⟷ TIMES b₁ (TIMES b₂ b₃)\n dist : { b₁ b₂ b₃ : B } → \n TIMES (PLUS b₁ b₂) b₃ ⟷ PLUS (TIMES b₁ b₃) (TIMES b₂ b₃) \n factor : { b₁ b₂ b₃ : B } → \n PLUS (TIMES b₁ b₃) (TIMES b₂ b₃) ⟷ TIMES (PLUS b₁ b₂) b₃\n η₊ : { b : B } → ZERO ⟷ PLUS (NEG b) b\n ε₊ : { b : B } → PLUS b (NEG b) ⟷ ZERO\n refe⋆ : { b : B } → RECIP (RECIP b) ⟷ b\n refi⋆ : { b : B } → b ⟷ RECIP (RECIP b) \n rile⋆ : { b : B } → TIMES b (TIMES b (RECIP b)) ⟷ b\n rili⋆ : { b : B } → b ⟷ TIMES b (TIMES b (RECIP b)) \n id⟷ : { b : B } → b ⟷ b\n sym : { b₁ b₂ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₁)\n _◎_ : { b₁ b₂ b₃ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₃) → (b₁ ⟷ b₃)\n _⊕_ : { b₁ b₂ b₃ b₄ : B } → \n (b₁ ⟷ b₃) → (b₂ ⟷ b₄) → (PLUS b₁ b₂ ⟷ PLUS b₃ b₄)\n _⊗_ : { b₁ b₂ b₃ b₄ : B } → \n (b₁ ⟷ b₃) → (b₂ ⟷ b₄) → (TIMES b₁ b₂ ⟷ TIMES b₃ b₄)\n\n--\n\nadjoint : { b₁ b₂ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₁)\nadjoint unite₊ = uniti₊\nadjoint uniti₊ = unite₊\nadjoint swap₊ = swap₊\nadjoint assocl₊ = assocr₊\nadjoint assocr₊ = assocl₊\nadjoint unite⋆ = uniti⋆\nadjoint uniti⋆ = unite⋆\nadjoint swap⋆ = swap⋆\nadjoint assocl⋆ = assocr⋆\nadjoint assocr⋆ = assocl⋆\nadjoint dist = factor\nadjoint factor = dist\nadjoint η₊ = swap₊ ◎ ε₊\nadjoint ε₊ = η₊ ◎ swap₊\nadjoint refe⋆ = refi⋆\nadjoint refi⋆ = refe⋆\nadjoint rile⋆ = rili⋆\nadjoint rili⋆ = rile⋆\nadjoint id⟷ = id⟷\nadjoint (sym c) = c\nadjoint (c₁ ◎ c₂) = adjoint c₂ ◎ adjoint c₁\nadjoint (c₁ ⊕ c₂) = adjoint c₁ ⊕ adjoint c₂\nadjoint (c₁ ⊗ c₂) = adjoint c₁ ⊗ adjoint c₂\n\n--\n\ndist' : {b₁ b₂ b₃ : B} → TIMES b₁ (PLUS b₂ b₃) ⟷ PLUS (TIMES b₁ b₂) (TIMES b₁ b₃)\ndist' = swap⋆ ◎ dist ◎ (swap⋆ ⊕ swap⋆) \n\nmidtofront : {a b c : B} → TIMES a (TIMES b c) ⟷ TIMES b (TIMES a c)\nmidtofront = assocl⋆ ◎ (swap⋆ ⊗ id⟷) ◎ assocr⋆\n\nneg : {b₁ b₂ : B} → (b₁ ⟷ b₂) → (NEG b₁ ⟷ NEG b₂) \nneg {b₁} {b₂} c = -- -b1\n uniti₊ ◎ -- 0 + (-b1)\n (η₊ {b₂} ⊕ id⟷) ◎ -- (-b2 + b2) + (-b1)\n ((id⟷ ⊕ sym c) ⊕ id⟷) ◎ -- (-b2 + b1) + (-b1)\n assocr₊ ◎ -- (-b2) + (b1 + (-b1))\n (id⟷ ⊕ ε₊) ◎ -- (-b2) + 0\n swap₊ ◎ -- 0 + (-b2)\n unite₊ -- -b2\n\n--\n\nmul0 : {b : B} → TIMES ZERO b ⟷ ZERO\nmul0 = -- 0*b\n uniti₊ ◎ -- 0 + 0*b\n (η₊ ⊕ id⟷) ◎ -- (-(0*b) + 0*b) + 0*b\n assocr₊ ◎ -- -(0*b) + (0*b + 0*b)\n (id⟷ ⊕ factor) ◎ -- -(0*b) + (0+0)*b\n (id⟷ ⊕ (unite₊ ⊗ id⟷)) ◎ -- -(0*b) + 0*b\n swap₊ ◎ ε₊ -- 0\n\n{-\nmul0 : {b : B} → TIMES ZERO b ⟷ ZERO\nmul0 {b} = ⟷-begin\n TIMES ZERO b \n ⟷⟨ uniti₊ ⟩\n 0 + 0*b\n ⟷⟨ η₊ ⊕ id⟷ ⟩\n (-(0*b) + 0*b) + 0*b\n ⟷⟨ assocr₊ ⟩\n -(0*b) + (0*b + 0*b)\n ⟷⟨ id⟷ ⊕ factor ⟩\n -(0*b) + (0+0)*b\n (id⟷ ⊕ (unite₊ ⊗ id⟷)) ◎ -- -(0*b) + 0*b\n swap₊ ◎ ε₊ -- 0\n ∎\n-}\n\n\n-- conType T cond = Σ[ x ∶ T ] cond x\n\n\ninv0 : TIMES ZERO (RECIP ZERO) ⟷ ZERO\ninv0 = mul0 \n\n--\n\nrecip : {b₁ b₂ : B} → (b₁ ⟷ b₂) → (RECIP b₁ ⟷ RECIP b₂) \nrecip {b₁} {b₂} c = -- 1/a\n rili⋆ {RECIP b₁} ◎ -- 1/a * (1/a * 1/1/a)\n (id⟷ ⊗ (id⟷ ⊗ refe⋆)) ◎ -- 1/a * (1/a * a)\n assocl⋆ ◎ -- (1/a * 1/a) * a\n (id⟷ ⊗ reciplem c) ◎ -- (1/a * 1/a) * (a * ((a * 1/b) * (b * 1/b)))\n assocl⋆ ◎ -- (((1/a * 1/a) * a) * ((a * 1/b) * (b * 1/b)))\n ((id⟷ ⊗ refi⋆ ) ⊗ id⟷) ◎ -- (((1/a *1/a) * 1/(1/a)) * ((a * 1/b) * (b * 1/b))\n ((assocr⋆ ◎ rile⋆ ) ⊗ (id⟷ ⊗ ((sym c) ⊗ id⟷))) ◎ -- 1/a * ((a * 1/b) * (a * 1/b))\n (id⟷ ⊗ (assocr⋆ ◎ (id⟷ ⊗ midtofront))) ◎ -- 1/a * (a * (a * (1/b * 1/b)))\n (assocl⋆ ◎ assocl⋆) ◎ -- ((1/a * a) * a) * (1/b * 1/b)\n (((swap⋆ ⊗ id⟷) ◎ swap⋆) ⊗ id⟷) ◎ -- ((a * (a * 1/a)) * (1/b * 1/b))\n (rile⋆ ⊗ id⟷ ) ◎ -- a * (1/b * 1/b)\n ((c ◎ refi⋆ ) ⊗ id⟷) ◎ swap⋆ ◎ -- (1/b * 1/b) * 1/(1/b)\n assocr⋆ ◎ rile⋆ -- 1/b\n where \n reciplem : {b₁ b₂ : B} → (b₁ ⟷ b₂) → (b₁ ⟷ (TIMES b₁ (TIMES (TIMES b₁ (RECIP b₂)) (TIMES b₂ (RECIP b₂)))))\n reciplem {b₁} {b₂} c = c ◎ -- b\n rili⋆ ◎ -- b * (b * 1/b)\n (rili⋆ ⊗ id⟷) ◎ -- (b * (b * 1/b)) * (b * 1/b)\n (((sym c) ⊗ ((sym c) ⊗ id⟷)) ⊗ id⟷) ◎ -- ((a * (a * 1/b)) * (b * 1/b)) \n assocr⋆ -- a * ((a * 1/b) * (b * 1/b))\n\n------------------------------------------------------------------------------\n-- Examples\n\nBOOL : B\nBOOL = PLUS ONE ONE\n\nnotπ : BOOL ⟷ BOOL\nnotπ = swap₊\n\nBOOL² : B\nBOOL² = TIMES BOOL BOOL\n\nBOOL³ : B\nBOOL³ = TIMES BOOL BOOL² \n\nifc : { b : B } → (b ⟷ b) → (TIMES BOOL b ⟷ TIMES BOOL b)\nifc c = dist ◎ ((id⟷ ⊗ c) ⊕ id⟷) ◎ factor\n\ncnot : BOOL² ⟷ BOOL²\ncnot = ifc notπ\n\ntoffoli : BOOL³ ⟷ BOOL³\ntoffoli = ifc cnot\n\n------------------------------------------------------------------------------\n\n", "meta": {"hexsha": "e59f753778a299f74bd0fe1c63b7dbeed0660de0", "size": 5965, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/PiNF-syntax.agda", "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 14, "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_issues_repo_path": "agda/PiNF-syntax.agda", "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_forks_repo_path": "agda/PiNF-syntax.agda", "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "avg_line_length": 32.955801105, "max_line_length": 110, "alphanum_fraction": 0.3929589271, "num_tokens": 2885, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357701094303, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.6005453807583342}} {"text": "{-# OPTIONS --without-K #-}\nmodule algebra.monoid.morphism where\n\nopen import level\nopen import algebra.monoid.core\nopen import algebra.semigroup.morphism\nopen import equality.core\nopen import function.isomorphism\nopen import hott.level\nopen import sum\n\nmodule _ {i}{j}\n {X : Set i}⦃ sX : IsMonoid X ⦄\n {Y : Set j}⦃ sY : IsMonoid Y ⦄ where\n open IsMonoid ⦃ ... ⦄\n\n record IsMonoidMorphism (f : X → Y) : Set (i ⊔ j) where\n constructor mk-is-monoid-morphism\n field\n sgrp-mor : IsSemigroupMorphism f\n id-pres : f e ≡ e\n\n is-monoid-morphism-struct-iso : (f : X → Y)\n → IsMonoidMorphism f ≅ (IsSemigroupMorphism f × (f e ≡ e))\n is-monoid-morphism-struct-iso f = record\n { to = λ mor → ( IsMonoidMorphism.sgrp-mor mor\n , IsMonoidMorphism.id-pres mor )\n ; from = λ { (s , i) → mk-is-monoid-morphism s i }\n ; iso₁ = λ _ → refl\n ; iso₂ = λ _ → refl }\n\n is-monoid-morphism-level : (f : X → Y) → h 1 (IsMonoidMorphism f)\n is-monoid-morphism-level f =\n iso-level (sym≅ (is-monoid-morphism-struct-iso f))\n (×-level (is-semigroup-morphism-level f)\n (is-set _ _))\n", "meta": {"hexsha": "fe76198e28aaba99c55c8df43c9fd283bb919f76", "size": 1130, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/algebra/monoid/morphism.agda", "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 20, "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_issues_repo_path": "src/algebra/monoid/morphism.agda", "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_forks_repo_path": "src/algebra/monoid/morphism.agda", "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "avg_line_length": 30.5405405405, "max_line_length": 67, "alphanum_fraction": 0.6300884956, "num_tokens": 381, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357666736773, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.6005453783785873}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.CommAlgebra.Instances.Pointwise where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\n\nopen import Cubical.Algebra.CommRing.Base\nopen import Cubical.Algebra.CommRing.Instances.Pointwise\nopen import Cubical.Algebra.CommAlgebra.Base\n\nprivate\n variable\n ℓ : Level\n\npointwiseAlgebra : {R : CommRing ℓ} (X : Type ℓ) (A : CommAlgebra R ℓ) → CommAlgebra R ℓ\npointwiseAlgebra {R = R} X A =\n let open CommAlgebraStr (snd A)\n isSetX→A = isOfHLevelΠ 2 (λ (x : X) → isSetCommRing (CommAlgebra→CommRing A))\n in commAlgebraFromCommRing\n (pointwiseRing X (CommAlgebra→CommRing A))\n (λ r f → (λ x → r ⋆ (f x)))\n (λ r s f i x → ⋆Assoc r s (f x) i)\n (λ r f g i x → ⋆DistR+ r (f x) (g x) i)\n (λ r s f i x → ⋆DistL+ r s (f x) i)\n (λ f i x → ⋆IdL (f x) i)\n λ r f g i x → ⋆AssocL r (f x) (g x) i\n", "meta": {"hexsha": "2c5f417f327e2e4fe66d9e11a81c523ba1ae8827", "size": 907, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommAlgebra/Instances/Pointwise.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/CommAlgebra/Instances/Pointwise.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/CommAlgebra/Instances/Pointwise.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.5925925926, "max_line_length": 89, "alphanum_fraction": 0.6438809261, "num_tokens": 336, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8670357666736773, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.6005453783785873}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import Types\nopen import Functions\nopen import Paths\nopen import HLevel\nopen import Equivalences\n\nmodule Univalence {i} where\n\npostulate -- Univalence axiom\n univalence : (A B : Set i) → is-equiv (path-to-eq {i} {A} {B})\n\npath-to-eq-equiv : {A B : Set i} → ((A ≡ B) ≃ (A ≃ B))\npath-to-eq-equiv = (path-to-eq , univalence _ _)\n\neq-to-path-equiv : {A B : Set i} → ((A ≃ B) ≃ (A ≡ B))\neq-to-path-equiv = path-to-eq-equiv ⁻¹\n\neq-to-path : {A B : Set i} → (A ≃ B → A ≡ B)\neq-to-path {A} {B} = π₁ eq-to-path-equiv\n\neq-to-path-right-inverse : {A B : Set i} (f : A ≃ B)\n → path-to-eq (eq-to-path f) ≡ f\neq-to-path-right-inverse = inverse-right-inverse path-to-eq-equiv\n\npath-to-eq-right-inverse : {A B : Set i} (f : A ≡ B)\n → eq-to-path (path-to-eq f) ≡ f\npath-to-eq-right-inverse = inverse-left-inverse path-to-eq-equiv\n\n-- Transport in the structural fibration of a universe\n\ntrans-id : {A B : Set i} (f : A ≡ B) (u : A)\n → transport (λ X → X) f u ≡ (path-to-eq f) ☆ u\ntrans-id refl u = refl\n\ntrans-id! : {A B : Set i} (f : A ≡ B) (u : B)\n → transport (λ X → X) (! f) u ≡ inverse (path-to-eq f) u\ntrans-id! refl u = refl\n\ntrans-id-eq-to-path : {A B : Set i} (f : A ≃ B) (u : A)\n → transport (λ X → X) (eq-to-path f) u ≡ f ☆ u\ntrans-id-eq-to-path {A} {B} f u =\n trans-id (eq-to-path f) u\n ∘ ap (λ (t : A ≃ B) → t ☆ u) (eq-to-path-right-inverse f)\n\ntrans-id-!eq-to-path : {A B : Set i} (f : A ≃ B) (u : B)\n → transport (λ X → X) (! (eq-to-path f)) u ≡ inverse f u\ntrans-id-!eq-to-path {A} {B} f u =\n trans-id! (eq-to-path f) u\n ∘ ap (λ (t : A ≃ B) → inverse t u) (eq-to-path-right-inverse f)\n\n-- Not used\n--\n-- trans-id→A : ∀ {i j} (A : Set j) {X Y : Set i} (e : X ≡ Y) (f : X → A)\n-- (a : Y) → transport (λ (X : Set i) → X → A) e f a\n-- ≡ f (inverse (path-to-eq e) a)\n-- trans-id→A A (refl _) f a = refl _\n\n-- trans-id→A-eq-to-path : ∀ {i j} (A : Set j) {X Y : Set i} (e : X ≃ Y)\n-- (f : X → A) (a : Y)\n-- → transport (λ (X : Set i) → X → A) (eq-to-path e) f a ≡ f (inverse e a)\n-- trans-id→A-eq-to-path A e f a =\n-- trans-id→A A (eq-to-path e) f a\n-- ∘ ap (λ u → f (inverse u a)) (eq-to-path-right-inverse e)\n\n-- trans-cst→X : ∀ {i j} (A : Set j) {X Y : Set i} (e : X ≡ Y) (f : A → X)\n-- (a : A) → transport (λ (X : Set i) → A → X) e f a\n-- ≡ π₁ (path-to-eq e) (f a)\n-- trans-cst→X A (refl _) f a = refl _\n\n-- trans-cst→X-eq-to-path : ∀ {i j} (A : Set j) {X Y : Set i} (e : X ≃ Y)\n-- (f : A → X) (a : A)\n-- → transport (λ (X : Set i) → A → X) (eq-to-path e) f a ≡ π₁ e (f a)\n-- trans-cst→X-eq-to-path A e f a =\n-- trans-cst→X A (eq-to-path e) f a\n-- ∘ ap (λ u → π₁ u (f a)) (eq-to-path-right-inverse e)\n\n-- Induction along equivalences\n\nequiv-induction : ∀ {j} (P : {A B : Set i} (f : A ≃ B) → Set j)\n (d : (A : Set i) → P (id-equiv A)) {A B : Set i} (f : A ≃ B)\n → P f\nequiv-induction P d f =\n transport P (eq-to-path-right-inverse f)\n (equiv-induction-int P d (eq-to-path f)) where\n\n equiv-induction-int : ∀ {j}\n (P : {A : Set i} {B : Set i} (f : A ≃ B) → Set j)\n (d : (A : Set i) → P (id-equiv A)) {A B : Set i} (p : A ≡ B)\n → P (path-to-eq p)\n equiv-induction-int P d refl = d _\n", "meta": {"hexsha": "ae2dc3e57b03f84f5aac827898b3e8e621acd73b", "size": 3168, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "old/Univalence.agda", "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 294, "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_issues_repo_path": "old/Univalence.agda", "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 31, "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_forks_repo_path": "old/Univalence.agda", "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 50, "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "avg_line_length": 34.064516129, "max_line_length": 77, "alphanum_fraction": 0.5268308081, "num_tokens": 1310, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357666736772, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.6005453618756316}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.CoYoneda where\n\n-- CoYoneda Lemma. See Yoneda for more documentation\n\nopen import Level\nopen import Function.Base using (_$_)\nopen import Function.Bundles using (Inverse)\nopen import Function.Equality using (Π; _⟨$⟩_; cong)\nopen import Relation.Binary.Bundles using (module Setoid)\nimport Relation.Binary.Reasoning.Setoid as SetoidR\nopen import Data.Product using (_,_; Σ)\n\nopen import Categories.Category using (Category; _[_,_])\nopen import Categories.Category.Product using (πʳ; πˡ; _※_)\nopen import Categories.Category.Construction.Presheaves using (CoPresheaves)\nopen import Categories.Category.Construction.Functors using (eval)\nopen import Categories.Category.Construction.Functors\nopen import Categories.Category.Instance.Setoids using (Setoids)\nopen import Categories.Functor using (Functor; _∘F_) renaming (id to idF)\nopen import Categories.Functor.Hom using (module Hom; Hom[_][_,-]; Hom[_][-,-])\nopen import Categories.Functor.Bifunctor using (Bifunctor)\n-- open import Categories.Functor.Presheaf using (Presheaf)\nopen import Categories.Functor.Construction.LiftSetoids using (LiftSetoids)\nopen import Categories.NaturalTransformation using (NaturalTransformation; ntHelper) renaming (id to idN)\nopen import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism)\n\nimport Categories.Morphism as Mor\nimport Categories.Morphism.Reasoning as MR\nimport Categories.NaturalTransformation.Hom as NT-Hom\n\nprivate\n variable\n o ℓ e : Level\n\nmodule Yoneda (C : Category o ℓ e) where\n open Category C hiding (op) -- uses lots\n open HomReasoning using (_○_; ⟺)\n open MR C using (id-comm)\n open NaturalTransformation using (η; commute)\n open NT-Hom C using (Hom[C,A]⇒Hom[C,B])\n private\n module CE = Category.Equiv C using (refl)\n module C = Category C using (op)\n\n -- The CoYoneda embedding functor\n embed : Functor C.op (CoPresheaves C)\n embed = record\n { F₀ = Hom[ C ][_,-]\n ; F₁ = Hom[C,A]⇒Hom[C,B] -- B⇒A induces a NatTrans on the Homs.\n ; identity = identityʳ ○_\n ; homomorphism = λ h₁≈h₂ → ∘-resp-≈ˡ h₁≈h₂ ○ sym-assoc\n ; F-resp-≈ = λ f≈g h≈i → ∘-resp-≈ h≈i f≈g\n }\n\n -- Using the adjunction between product and product, we get a kind of contravariant Bifunctor\n yoneda-inverse : (a : Obj) (F : Functor C (Setoids ℓ e)) →\n Inverse (Category.hom-setoid (CoPresheaves C) {Functor.F₀ embed a} {F}) (Functor.F₀ F a)\n yoneda-inverse a F = record\n { f = λ nat → η nat a ⟨$⟩ id\n ; f⁻¹ = λ x → ntHelper record\n { η = λ X → record\n { _⟨$⟩_ = λ X⇒a → F.₁ X⇒a ⟨$⟩ x\n ; cong = λ i≈j → F.F-resp-≈ i≈j SE.refl\n }\n ; commute = λ {X} {Y} X⇒Y {f} {g} f≈g →\n let module SR = SetoidR (F.₀ Y) in\n SR.begin\n F.₁ (X⇒Y ∘ f ∘ id) ⟨$⟩ x SR.≈⟨ F.F-resp-≈ (∘-resp-≈ʳ (identityʳ ○ f≈g)) SE.refl ⟩\n F.₁ (X⇒Y ∘ g) ⟨$⟩ x SR.≈⟨ F.homomorphism SE.refl ⟩\n F.₁ X⇒Y ⟨$⟩ (F.₁ g ⟨$⟩ x)\n SR.∎\n }\n ; cong₁ = λ i≈j → i≈j CE.refl\n ; cong₂ = λ i≈j y≈z → F.F-resp-≈ y≈z i≈j\n ; inverse = (λ Fa → F.identity SE.refl) , λ nat {x} {z} {y} z≈y →\n let module SR = SetoidR (F.₀ x) in\n SR.begin\n F.₁ z ⟨$⟩ (η nat a ⟨$⟩ id) SR.≈˘⟨ commute nat z (CE.refl {a}) ⟩\n η nat x ⟨$⟩ z ∘ id ∘ id SR.≈⟨ cong (η nat x) (∘-resp-≈ʳ identity² ○ identityʳ ○ z≈y ) ⟩\n η nat x ⟨$⟩ y\n SR.∎\n }\n where\n module F = Functor F using (₀; ₁; F-resp-≈; homomorphism; identity)\n module SE = Setoid (F.₀ a) using (refl)\n\n private\n Nat[Hom[C][c,-],F] : Bifunctor (CoPresheaves C) C (Setoids (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e))\n Nat[Hom[C][c,-],F] = Hom[ CoPresheaves C ][-,-] ∘F (Functor.op embed ∘F πʳ ※ πˡ)\n\n FC : Bifunctor (CoPresheaves C) C (Setoids _ _)\n FC = LiftSetoids (o ⊔ ℓ ⊔ e) (o ⊔ ℓ) ∘F eval {C = C} {D = Setoids ℓ e}\n\n module yoneda-inverse {a} {F} = Inverse (yoneda-inverse a F)\n\n -- the two bifunctors above are naturally isomorphic.\n -- it is easy to show yoneda-inverse first then to yoneda.\n yoneda : NaturalIsomorphism Nat[Hom[C][c,-],F] FC\n yoneda = record\n { F⇒G = ntHelper record\n { η = λ where\n (F , A) → record\n { _⟨$⟩_ = λ α → lift (yoneda-inverse.f α)\n ; cong = λ i≈j → lift (i≈j CE.refl)\n }\n ; commute = λ where\n {_} {G , B} (α , f) {β} {γ} β≈γ → lift $ cong (η α B) (helper f β γ β≈γ)\n }\n ; F⇐G = ntHelper record\n { η = λ (F , A) → record\n { _⟨$⟩_ = λ x → yoneda-inverse.f⁻¹ (lower x)\n ; cong = λ i≈j y≈z → Functor.F-resp-≈ F y≈z (lower i≈j)\n }\n ; commute = λ { {F , A} {G , B} (α , f) {X} {Y} eq {Z} {h} {i} eq′ → helper′ α f (lower eq) eq′}\n }\n ; iso = λ (F , A) → record\n { isoˡ = λ {α β} i≈j {X} y≈z →\n Setoid.trans (Functor.F₀ F X) ( yoneda-inverse.inverseʳ α {x = X} y≈z) (i≈j CE.refl)\n ; isoʳ = λ eq → lift (Setoid.trans (Functor.F₀ F A) ( yoneda-inverse.inverseˡ {F = F} _) (lower eq))\n }\n }\n where helper : {F : Functor C (Setoids ℓ e)}\n {A B : Obj} (f : A ⇒ B)\n (β γ : NaturalTransformation Hom[ C ][ A ,-] F) →\n Setoid._≈_ (Functor.F₀ Nat[Hom[C][c,-],F] (F , A)) β γ →\n Setoid._≈_ (Functor.F₀ F B) (η β B ⟨$⟩ id ∘ f) (Functor.F₁ F f ⟨$⟩ (η γ A ⟨$⟩ id))\n helper {F} {A} {B} f β γ β≈γ = S.begin\n η β B ⟨$⟩ id ∘ f S.≈⟨ cong (η β B) (MR.id-comm-sym C ○ ∘-resp-≈ʳ (⟺ identity²)) ⟩\n η β B ⟨$⟩ f ∘ id ∘ id S.≈⟨ commute β f CE.refl ⟩\n F.₁ f ⟨$⟩ (η β A ⟨$⟩ id) S.≈⟨ cong (F.₁ f) (β≈γ CE.refl) ⟩\n F.₁ f ⟨$⟩ (η γ A ⟨$⟩ id) S.∎\n where\n module F = Functor F using (₀;₁)\n module S = SetoidR (F.₀ B)\n\n helper′ : ∀ {F G : Functor C (Setoids ℓ e)}\n {A B Z : Obj}\n {h i : B ⇒ Z}\n {X Y : Setoid.Carrier (Functor.F₀ F A)}\n (α : NaturalTransformation F G)\n (f : A ⇒ B) →\n Setoid._≈_ (Functor.F₀ F A) X Y →\n h ≈ i →\n Setoid._≈_ (Functor.F₀ G Z) (Functor.F₁ G h ⟨$⟩ (η α B ⟨$⟩ (Functor.F₁ F f ⟨$⟩ X)))\n (η α Z ⟨$⟩ (Functor.F₁ F (i ∘ f) ⟨$⟩ Y))\n helper′ {F} {G} {A} {B} {Z} {h} {i} {X} {Y} α f eq eq′ = S.begin\n G.₁ h ⟨$⟩ (η α B ⟨$⟩ (F.₁ f ⟨$⟩ X)) S.≈˘⟨ commute α h ((S′.sym (cong (F.₁ f) eq))) ⟩\n η α Z ⟨$⟩ (F.₁ h ⟨$⟩ (F.₁ f ⟨$⟩ Y)) S.≈⟨ cong (η α Z) ((F.F-resp-≈ eq′ S′.refl)) ⟩\n η α Z ⟨$⟩ (F.₁ i ⟨$⟩ (F.₁ f ⟨$⟩ Y)) S.≈˘⟨ cong (η α Z) ((F.homomorphism (Setoid.refl (F.₀ A)))) ⟩\n η α Z ⟨$⟩ (F.₁ (i ∘ f) ⟨$⟩ Y) S.∎\n where\n module F = Functor F using (₀; ₁; homomorphism; F-resp-≈)\n module G = Functor G using (₀; ₁)\n module S = SetoidR (G.₀ Z)\n module S′ = Setoid (F.₀ B) using (refl; sym)\n\n module yoneda = NaturalIsomorphism yoneda\n", "meta": {"hexsha": "6aa993ddc1ef03ef55b9effb693ae9f9a8fb4e41", "size": 7103, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/CoYoneda.agda", "max_stars_repo_name": "bblfish/agda-categories", "max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "src/Categories/CoYoneda.agda", "max_issues_repo_name": "bblfish/agda-categories", "max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/CoYoneda.agda", "max_forks_repo_name": "bblfish/agda-categories", "max_forks_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 44.6729559748, "max_line_length": 110, "alphanum_fraction": 0.53076165, "num_tokens": 2693, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672181749422, "lm_q2_score": 0.743167997235783, "lm_q1q2_score": 0.6005296961629623}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import HoTT\nimport homotopy.HopfConstruction\nopen import homotopy.CircleHSpace\nopen import homotopy.SuspensionJoin using () renaming (e to suspension-join)\nimport homotopy.JoinAssocCubical\n\nmodule homotopy.Hopf where\n\nmodule Hopf = homotopy.HopfConstruction S¹ S¹-connected S¹-hSpace\n\nHopf : S² → Type₀\nHopf = Hopf.H.f\n\nHopf-fiber : Hopf north == S¹\nHopf-fiber = idp\n\nHopf-total : Σ _ Hopf == S³\nHopf-total =\n Σ _ Hopf =⟨ Hopf.theorem ⟩\n S¹ * S¹ =⟨ ua (suspension-join S⁰) |in-ctx (λ u → u * S¹) ⟩\n (S⁰ * S⁰) * S¹ =⟨ homotopy.JoinAssocCubical.*-assoc ⟩\n S⁰ * (S⁰ * S¹) =⟨ ! (ua (suspension-join S¹)) |in-ctx (λ u → S⁰ * u) ⟩\n S⁰ * S² =⟨ ! (ua (suspension-join S²)) ⟩\n S³ ∎\n", "meta": {"hexsha": "cd790779eb58a648a91a6b927d4d0c62735139bb", "size": 733, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/homotopy/Hopf.agda", "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "theorems/homotopy/Hopf.agda", "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "theorems/homotopy/Hopf.agda", "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.1481481481, "max_line_length": 76, "alphanum_fraction": 0.6548431105, "num_tokens": 303, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9219218284193597, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.6004982677827733}} {"text": "\nmodule EqProof\n { A : Set }\n ( _==_ : A -> A -> Set )\n (refl : {x : A} -> x == x)\n (trans : {x y z : A} -> x == y -> y == z -> x == z)\n where\n\n infix 2 eqProof>_\n infixl 2 _===_\n infix 3 _by_\n\n eqProof>_ : (x : A) -> x == x\n eqProof> x = refl\n\n _===_ : {x y z : A} -> x == y -> y == z -> x == z\n xy === yz = trans xy yz\n\n _by_ : {x : A}(y : A) -> x == y -> x == y\n y by eq = eq\n\n", "meta": {"hexsha": "a6c7c2d30720d7dd2ecfd00bd3b930ae2fe07798", "size": 395, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/tactics/ac/EqProof.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "examples/tactics/ac/EqProof.agda", "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/tactics/ac/EqProof.agda", "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 17.9545454545, "max_line_length": 53, "alphanum_fraction": 0.3873417722, "num_tokens": 178, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8976952893703476, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.6004506648131954}} {"text": "module HyperReal where\n\nopen import Data.Nat\nopen import Data.Nat.Properties\nopen import Data.Empty\nopen import Relation.Nullary using (¬_; Dec; yes; no)\nopen import Level renaming ( suc to succ ; zero to Zero ; _⊔_ to _L⊔_ )\nopen import Relation.Binary.PropositionalEquality hiding ( [_] )\nopen import Relation.Binary.Definitions\nopen import Relation.Binary.Structures\nopen import nat\nopen import logic\nopen import bijection\n\nHyperNat : Set\nHyperNat = ℕ → ℕ\n\nopen _∧_\nopen Bijection\n\nn1 : ℕ → ℕ\nn1 n = proj1 (fun→ nxn n)\n\nn2 : ℕ → ℕ\nn2 n = proj2 (fun→ nxn n)\n\n_n*_ : (i j : HyperNat ) → HyperNat\ni n* j = λ k → i k * j k\n\n_n+_ : (i j : HyperNat ) → HyperNat\ni n+ j = λ k → i k + j k\n\nhzero : HyperNat\nhzero _ = 0 \n\nh : (n : ℕ) → HyperNat\nh n _ = n \n\nrecord _n=_ (i j : HyperNat ) : Set where \n field \n =-map : Bijection ℕ ℕ \n =-m : ℕ\n is-n= : (k : ℕ ) → k > =-m → i k ≡ j (fun→ =-map k)\n\nopen _n=_\n\nrecord _n≤_ (i j : HyperNat ) : Set where \n field \n ≤-map : Bijection ℕ ℕ\n ≤-m : ℕ\n is-n≤ : (k : ℕ ) → k > ≤-m → i k ≤ j (fun→ ≤-map k)\n\nopen _n≤_\n\nrecord _n<_ (i j : HyperNat ) : Set where \n field \n <-map : Bijection ℕ ℕ\n <-m : ℕ\n is-n< : (k : ℕ ) → k > <-m → i k < j (fun→ <-map k)\n\nopen _n<_\n\n_n<=s≤_ : (i j : HyperNat ) → (i n< j) ⇔ (( i n+ h 1 ) n≤ j )\n_n<=s≤_ = {!!}\n\n¬hn<0 : {x : HyperNat } → ¬ ( x n< h 0 )\n¬hn<0 {x} x<0 = ⊥-elim ( nat-≤> (is-n< x<0 (suc (<-m x<0)) a ¬a ¬b c = {!!}\n trans1 : {i j k : HyperNat} → i n≤ j → j n≤ k → i n≤ k\n trans1 = {!!}\n\nrecord n-finite (i : HyperNat ) : Set where\n field\n val : ℕ\n is-val : i n= h val\n\nn-infinite : (i : HyperNat ) → Set\nn-infinite i = (j : ℕ ) → h j n≤ i\n\nn-linear : HyperNat\nn-linear i = i\n\nn-linear-is-infnite : n-infinite n-linear\nn-linear-is-infnite i = record { ≤-map = bid ℕ ; ≤-m = i ; is-n≤ = λ k lt → ¬a ¬b c with <-cmpn y (h 0)\n ... | tri< a ¬b₁ ¬c = ⊥-elim ( ¬hn<0 a)\n ... | tri≈ ¬a₁ b ¬c = nzy b\n ... | tri> ¬a₁ ¬b₁ c₁ = hn2 c c₁ xy0\n\nHZzero : HyperZ → Set\nHZzero z = hZ 0 0 z= z\n\nHZzero? : ( i : HyperZ ) → Dec (HZzero i)\nHZzero? = {!!}\n\ndata HyperR : Set where\n hr : HyperZ → (k : HyperNat ) → ((i : ℕ) → 0 < k i) → HyperR\n\nHZnzero* : {x y : HyperZ } → ¬ ( HZzero x ) → ¬ ( HZzero y ) → ¬ ( HZzero (x z* y) )\nHZnzero* {x} {y} nzx nzy nzx*y = {!!}\n\nHRzero : HyperR → Set\nHRzero (hr i j nz ) = HZzero i\n\nR0 : HyperR\nR0 = hr (hZ 0 0) (h 1) {!!}\n\nrecord Rational : Set where\n field\n rp rm k : ℕ\n 01\", \"1->3\", \"3->2\" as in the thesis.\n-- for the last part, we show \"1->4\" and \"4->3\nset-characterisations : ∀ {i} → (X : Type i) → \n (pathColl X → is-set X)\n × (is-set X → rel-ref-id X)\n × (rel-ref-id X → pathColl X)\n × (is-set X → hSeparated X)\n × (hSeparated X → rel-ref-id X)\nset-characterisations X = \n pathColl→isSet , \n (λ ss → _==_ , (λ _ → idp) , (λ _ _ p → p) , ss) ,\n (lem317.pc X) ,\n (λ ss x₁ x₂ → tr-rec (ss x₁ x₂) (λ p → p)) ,\n (λ hsep → ((λ x₁ x₂ → ∣∣ x₁ == x₂ ∣∣) , (λ _ → ∣ idp ∣) , hsep , λ _ _ → tr-is-prop))\n\n-- The rest of this section is only a replication of the arguments that we have given so far (for that reason, the proofs are not given in the article).\n-- They do not directly follow from the propositions that we have proved before, but they directly imply them.\n-- Of course, replication of arguments is not a good style for a formalization -\n-- we chose this \"disadvantageous\" order purely as we believe it led to a better presentation in the article.\n\n-- Lemma 3.1.11\npathColl→isSet-local : ∀ {i} {X : Type i} → {x₀ : X} → ((y : X) → coll (x₀ == y)) → (y : X) → is-prop (x₀ == y)\npathColl→isSet-local {X = X} {x₀} pc y = all-paths-is-prop paths-equal where\n claim : (y : X) → (p : x₀ == y) → p == ! (fst (pc _) idp) ∙ fst (pc _) p \n claim .x₀ idp = ! (!-inv-l (fst (pc _) idp))\n paths-equal : (p₁ p₂ : x₀ == y) → p₁ == p₂\n paths-equal p₁ p₂ = \n p₁ =⟨ claim _ p₁ ⟩\n ! (fst (pc _) idp) ∙ fst (pc _) p₁ =⟨ ap (λ q → (! (fst (pc x₀) idp)) ∙ q) (snd (pc y) p₁ p₂) ⟩ -- whiskering\n ! (fst (pc _) idp) ∙ fst (pc _) p₂ =⟨ ! (claim _ p₂) ⟩\n p₂ ∎ \n\n-- Proposition 3.11.12\nhedberg-local : ∀ {i} {X : Type i} → {x₀ : X} → ((y : X) → Coprod (x₀ == y) (¬(x₀ == y))) → (y : X) → is-prop (x₀ == y)\nhedberg-local {X = X} {x₀ = x₀} dec = pathColl→isSet-local local-pathColl where\n local-pathColl : (y : X) → coll (x₀ == y)\n local-pathColl y with (dec y)\n local-pathColl y₁ | inl p = (λ _ → p) , (λ _ _ → idp)\n local-pathColl y₁ | inr np = idf _ , (λ p → Empty-elim (np p))\n\n-- Lemma 3.1.13. This needs function extensionality.\nsep→set-local : ∀ {i} {X : Type i} {x₀ : X} → ((y : X) → stable (x₀ == y)) → (y : X) → is-prop (x₀ == y)\nsep→set-local {X = X} {x₀ = x₀} sep = pathColl→isSet-local is-pathColl where\n is-pathColl : (y : X) → coll (x₀ == y)\n is-pathColl y = f , c where\n f : x₀ == y → x₀ == y\n f = (sep y) ∘ (λ p np → np p)\n c : const f \n c p₁ p₂ = \n f p₁ =⟨ idp ⟩\n (sep _) (λ np → np p₁) =⟨ ap (sep y) \n (λ= (λ np → prop-has-all-paths Empty-is-prop _ _)) ⟩\n (sep _) (λ np → np p₂) =⟨ idp ⟩\n f p₂ ∎ \n\n\n\n-- Chapter 3.2: Generalisations to Higher Levels\n\n-- first: some lemmata.\n\n-- If A -> B -> A is the identity, then\n-- a₁ == a₂ → s a₁ == s a₂ → r(s a₁) == r(s a₂) \n-- is also the identity in an appropriate sense\nretract-path-retract : ∀ {i j} {A : Type i} {B : Type j}\n → (s : A → B) → (r : B → A) → (s-r : (a : A) → r (s a) == a)\n → (a₁ a₂ : A)\n → (p : a₁ == a₂) → ! (s-r a₁) ∙ (ap r (ap s p)) ∙ (s-r a₂) == p\nretract-path-retract s r s-r a₁ .a₁ idp = !-inv-l (s-r a₁)\n\n-- retracts of n-types are n-truncated\nretract-is-truncated : ∀ {n : ℕ₋₂} {i j} {A : Type i} {B : Type j} \n → (has-level n B) → (s : A → B) → (r : B → A) → ((a : A) → r (s a) == a) → has-level n A\nretract-is-truncated {⟨-2⟩} h s r s-r = inhab-prop-is-contr (r (fst h)) (all-paths-is-prop (λ a₁ a₂ →\n a₁ =⟨ ! (s-r a₁) ⟩\n r(s(a₁)) =⟨ ap r (contr-has-all-paths h _ _) ⟩ \n r(s(a₂)) =⟨ s-r a₂ ⟩ \n a₂ ∎ \n ))\nretract-is-truncated {S n} h s r s-r a₁ a₂ = \n retract-is-truncated {n} {A = a₁ == a₂} {B = s a₁ == s a₂} \n (h (s a₁) (s a₂)) \n (ap s) \n (λ p → ! (s-r a₁) ∙ (ap r p) ∙ (s-r a₂)) \n (retract-path-retract s r s-r a₁ a₂)\n\n-- this is essentially one direction of a local version of the lemma which says that\n-- a type is n-truncated iff its loop spaces are (n-1)-truncated \ntrunclevel-aux₁ : ∀ {i} {X : Type i} {x₀ : X} → (n : ℕ) → ((x : X) → has-level (n -2) (x₀ == x)) \n → is-contr (fst ((Ω ^ n) (X , x₀)))\ntrunclevel-aux₁ {x₀ = x₀} O h = x₀ , λ x → fst (h x)\ntrunclevel-aux₁ {X = X} {x₀ = x₀} (S n) h = trunclevel-aux₁ n (h x₀ idp)\n\n-- the other direction...\ntrunclevel-aux₂ : ∀ {i} {X : Type i} {x₀ : X} → (n : ℕ) → is-contr (fst ((Ω ^ n) (X , x₀)))\n → ((x : X) → has-level (n -2) (x₀ == x)) \ntrunclevel-aux₂ {X = X} {x₀ = x₀} O h = λ x → inhab-prop-is-contr (contr-has-all-paths h x₀ x) (contr-is-prop (contr-is-prop h x₀ x))\ntrunclevel-aux₂ {X = X} {x₀ = x₀} (S n) h .x₀ idp = trunclevel-aux₂ n h\n\n\n-- Theorem 3.2.1\n\n-- in the thesis, we write \"let n ≥ -1 be a number\". \n-- As we do not want to introduce a type of number that are at least -1,\n-- we use ℕ.\n-- To make up for this, we reduce n everywhere by 1.\nmodule GLHA {i : ULevel} {X : Type i} {x₀ : X} {n : ℕ} where\n\n Ω-contr : Type i\n-- loop-contr = is-contr (fst ((Ω ^ (n + 1)) (X , x₀)))\n Ω-contr = is-contr (fst ((Ω ^ n) (X , x₀)))\n\n locally-truncated : Type i\n-- locally-truncated = (x : X) → has-level (n -1) (x₀ == x)\n locally-truncated = (x : X) → has-level (n -2) (x₀ == x)\n\n tr-rel-id : Type (lsucc i)\n tr-rel-id = Σ (X → Type i) λ Q → \n-- ((x : X) → has-level (n -1) (Q x))\n ((x : X) → has-level (n -2) (Q x))\n × (Q x₀)\n × ((x : X) → Q x → x₀ == x)\n\n\n tr-rel-id→locally-truncated : tr-rel-id → locally-truncated\n tr-rel-id→locally-truncated (Q , h , q₀ , ii) = λ x → retract-is-truncated {n = n -2} {A = x₀ == x} {B = Q x} (h x) s r r-s where \n\n r : {x : X} → (Q x) → (x₀ == x)\n r {x} q = ! (ii x₀ q₀) ∙ (ii x q)\n\n s : {x : X} → (x₀ == x) → Q x\n s idp = q₀\n\n r-s : {x : X} → (p : x₀ == x) → r (s p) == p\n r-s idp = !-inv-l (ii x₀ q₀)\n\n\n locally-truncated→Ω-contr : locally-truncated → Ω-contr\n locally-truncated→Ω-contr loctr = trunclevel-aux₁ n loctr -- trunclevel-aux n loctr\n\n Ω-contr→tr-rel-id : Ω-contr → tr-rel-id\n Ω-contr→tr-rel-id h = (λ x → x₀ == x) , (trunclevel-aux₂ n h) , idp , (λ x p → p)\n\n module with-higher-truncs where\n -- for convenience, we import truncations from the library.\n open import lib.types.Truncation\n\n -- fourth item in Theorem 3.2.1\n id-stable : Type i\n id-stable = (x : X) → Trunc (n -2) (x₀ == x) → x₀ == x\n\n -- it is very easy to see that (4) and (2) are logically equivalent.\n -- 2 ⇒ 4\n tr-rel-id→id-stable : tr-rel-id → id-stable\n tr-rel-id→id-stable (Q , h , q₀ , ii) = λ x → (ii x) ∘ (Trunc-rec (h x) (λ p → transport _ p q₀)) \n\n -- 4 ⇒ 2\n id-stable→tr-rel-id : id-stable → tr-rel-id\n id-stable→tr-rel-id idst = (λ x → Trunc (n -2) (x₀ == x)) , (λ _ → Trunc-level) , [ idp ] , idst\n\n\n", "meta": {"hexsha": "fed98e74191e3c8708cdd17573abb23018eae0a3", "size": 10713, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "nicolai/thesis/Truncation_Level_Criteria.agda", "max_stars_repo_name": "nicolaikraus/HoTT-Agda", "max_stars_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_issues_repo_path": "nicolai/thesis/Truncation_Level_Criteria.agda", "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nicolai/thesis/Truncation_Level_Criteria.agda", "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.8551236749, "max_line_length": 152, "alphanum_fraction": 0.5084476804, "num_tokens": 4299, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835411997897, "lm_q2_score": 0.7185943925708561, "lm_q1q2_score": 0.6003737877914107}} {"text": "------------------------------------------------------------------------\n-- List-related properties\n------------------------------------------------------------------------\n\n-- Note that the lemmas below could be generalised to work with other\n-- equalities than _≡_.\n\nmodule Data.List.Properties where\n\nopen import Data.List\nopen import Data.Nat\nopen import Data.Nat.Properties\nopen import Data.Bool\nopen import Data.Function\nopen import Data.Product as Prod hiding (map)\nopen import Data.Maybe\nopen import Relation.Binary.PropositionalEquality\nimport Relation.Binary.EqReasoning as Eq\nopen import Algebra\n\n∷-injective : ∀ {A} {x y xs ys} →\n (List A ∶ x ∷ xs) ≡ (y ∷ ys) → (x ≡ y) × (xs ≡ ys)\n∷-injective refl = (refl , refl)\n\nright-identity-unique : ∀ {A} (xs : List A) {ys} →\n xs ≡ xs ++ ys → ys ≡ []\nright-identity-unique [] refl = refl\nright-identity-unique (x ∷ xs) eq =\n right-identity-unique xs (proj₂ (∷-injective eq))\n\n-- Map, sum, and append.\n\nmap-++-commute : ∀ {a b} (f : a → b) xs ys →\n map f (xs ++ ys) ≡ map f xs ++ map f ys\nmap-++-commute f [] ys = refl\nmap-++-commute f (x ∷ xs) ys =\n cong (_∷_ (f x)) (map-++-commute f xs ys)\n\nsum-++-commute : ∀ xs ys → sum (xs ++ ys) ≡ sum xs + sum ys\nsum-++-commute [] ys = refl\nsum-++-commute (x ∷ xs) ys = begin\n x + sum (xs ++ ys)\n ≡⟨ cong (_+_ x) (sum-++-commute xs ys) ⟩\n x + (sum xs + sum ys)\n ≡⟨ sym $ +-assoc x _ _ ⟩\n (x + sum xs) + sum ys\n ∎\n where\n open CommutativeSemiring commutativeSemiring hiding (_+_; sym)\n open ≡-Reasoning\n\n-- Various properties about folds.\n\nfoldr-universal : ∀ {a b} (h : List a → b) f e →\n (h [] ≡ e) →\n (∀ x xs → h (x ∷ xs) ≡ f x (h xs)) →\n h ≗ foldr f e\nfoldr-universal h f e base step [] = base\nfoldr-universal h f e base step (x ∷ xs) = begin\n h (x ∷ xs)\n ≡⟨ step x xs ⟩\n f x (h xs)\n ≡⟨ cong (f x) (foldr-universal h f e base step xs) ⟩\n f x (foldr f e xs)\n ∎\n where open ≡-Reasoning\n\nfoldr-fusion : ∀ {a b c} (h : b → c)\n {f : a → b → b} {g : a → c → c} (e : b) →\n (∀ x y → h (f x y) ≡ g x (h y)) →\n h ∘ foldr f e ≗ foldr g (h e)\nfoldr-fusion h {f} {g} e fuse =\n foldr-universal (h ∘ foldr f e) g (h e) refl\n (λ x xs → fuse x (foldr f e xs))\n\nidIsFold : ∀ {a} → id {a = List a} ≗ foldr _∷_ []\nidIsFold = foldr-universal id _∷_ [] refl (λ _ _ → refl)\n\n++IsFold : ∀ {a} (xs ys : List a) →\n xs ++ ys ≡ foldr _∷_ ys xs\n++IsFold xs ys =\n begin\n xs ++ ys\n ≡⟨ cong (λ xs → xs ++ ys) (idIsFold xs) ⟩\n foldr _∷_ [] xs ++ ys\n ≡⟨ foldr-fusion (λ xs → xs ++ ys) [] (λ _ _ → refl) xs ⟩\n foldr _∷_ ([] ++ ys) xs\n ≡⟨ refl ⟩\n foldr _∷_ ys xs\n ∎\n where open ≡-Reasoning\n\nmapIsFold : ∀ {a b} {f : a → b} →\n map f ≗ foldr (λ x ys → f x ∷ ys) []\nmapIsFold {f = f} =\n begin\n map f\n ≈⟨ cong (map f) ∘ idIsFold ⟩\n map f ∘ foldr _∷_ []\n ≈⟨ foldr-fusion (map f) [] (λ _ _ → refl) ⟩\n foldr (λ x ys → f x ∷ ys) []\n ∎\n where open Eq (_ →-setoid _)\n\nconcat-map : ∀ {a b} {f : a → b} →\n concat ∘ map (map f) ≗ map f ∘ concat\nconcat-map {f = f} =\n begin\n concat ∘ map (map f)\n ≈⟨ cong concat ∘ mapIsFold ⟩\n concat ∘ foldr (λ xs ys → map f xs ∷ ys) []\n ≈⟨ foldr-fusion concat [] (λ _ _ → refl) ⟩\n foldr (λ ys zs → map f ys ++ zs) []\n ≈⟨ sym ∘\n foldr-fusion (map f) [] (λ ys zs → map-++-commute f ys zs) ⟩\n map f ∘ concat\n ∎\n where open Eq (_ →-setoid _)\n\nmap-id : ∀ {A} → map id ≗ id {List A}\nmap-id = begin\n map id ≈⟨ mapIsFold ⟩\n foldr _∷_ [] ≈⟨ sym ∘ idIsFold ⟩\n id ∎\n where open Eq (_ →-setoid _)\n\nmap-compose : ∀ {a b c} {g : b → c} {f : a → b} →\n map (g ∘ f) ≗ map g ∘ map f\nmap-compose {g = g} {f} =\n begin\n map (g ∘ f)\n ≈⟨ cong (map (g ∘ f)) ∘ idIsFold ⟩\n map (g ∘ f) ∘ foldr _∷_ []\n ≈⟨ foldr-fusion (map (g ∘ f)) [] (λ _ _ → refl) ⟩\n foldr (λ a y → g (f a) ∷ y) []\n ≈⟨ sym ∘ foldr-fusion (map g) [] (λ _ _ → refl) ⟩\n map g ∘ foldr (λ a y → f a ∷ y) []\n ≈⟨ cong (map g) ∘ sym ∘ mapIsFold ⟩\n map g ∘ map f\n ∎\n where open Eq (_ →-setoid _)\n\nfoldr-cong : ∀ {a b} {f₁ f₂ : a → b → b} {e₁ e₂ : b} →\n (∀ x y → f₁ x y ≡ f₂ x y) → e₁ ≡ e₂ →\n foldr f₁ e₁ ≗ foldr f₂ e₂\nfoldr-cong {f₁ = f₁} {f₂} {e} f₁≗₂f₂ refl =\n begin\n foldr f₁ e\n ≈⟨ cong (foldr f₁ e) ∘ idIsFold ⟩\n foldr f₁ e ∘ foldr _∷_ []\n ≈⟨ foldr-fusion (foldr f₁ e) [] (λ x xs → f₁≗₂f₂ x (foldr f₁ e xs)) ⟩\n foldr f₂ e\n ∎\n where open Eq (_ →-setoid _)\n\nmap-cong : ∀ {a b} {f g : a → b} → f ≗ g → map f ≗ map g\nmap-cong {f = f} {g} f≗g =\n begin\n map f\n ≈⟨ mapIsFold ⟩\n foldr (λ x ys → f x ∷ ys) []\n ≈⟨ foldr-cong (λ x ys → cong₂ _∷_ (f≗g x) refl) refl ⟩\n foldr (λ x ys → g x ∷ ys) []\n ≈⟨ sym ∘ mapIsFold ⟩\n map g\n ∎\n where open Eq (_ →-setoid _)\n\n-- Take, drop, and splitAt.\n\ntake++drop : ∀ {a} n (xs : List a) → take n xs ++ drop n xs ≡ xs\ntake++drop zero xs = refl\ntake++drop (suc n) [] = refl\ntake++drop (suc n) (x ∷ xs) =\n cong (λ xs → x ∷ xs) (take++drop n xs)\n\nsplitAt-defn : ∀ {a} n → splitAt {a} n ≗ < take n , drop n >\nsplitAt-defn zero xs = refl\nsplitAt-defn (suc n) [] = refl\nsplitAt-defn (suc n) (x ∷ xs) with splitAt n xs | splitAt-defn n xs\n... | (ys , zs) | ih = cong (Prod.map (_∷_ x) id) ih\n\n-- TakeWhile, dropWhile, and span.\n\ntakeWhile++dropWhile : ∀ {a} (p : a → Bool) (xs : List a) →\n takeWhile p xs ++ dropWhile p xs ≡ xs\ntakeWhile++dropWhile p [] = refl\ntakeWhile++dropWhile p (x ∷ xs) with p x\n... | true = cong (_∷_ x) (takeWhile++dropWhile p xs)\n... | false = refl\n\nspan-defn : ∀ {a} (p : a → Bool) →\n span p ≗ < takeWhile p , dropWhile p >\nspan-defn p [] = refl\nspan-defn p (x ∷ xs) with p x\n... | true = cong (Prod.map (_∷_ x) id) (span-defn p xs)\n... | false = refl\n\n-- Partition.\n\npartition-defn : ∀ {a} (p : a → Bool) →\n partition p ≗ < filter p , filter (not ∘ p) >\npartition-defn p [] = refl\npartition-defn p (x ∷ xs)\n with p x | partition p xs | partition-defn p xs\n... | true | (ys , zs) | eq = cong (Prod.map (_∷_ x) id) eq\n... | false | (ys , zs) | eq = cong (Prod.map id (_∷_ x)) eq\n\n-- Inits, tails, and scanr.\n\nscanr-defn : ∀ {a b} (f : a → b → b) (e : b) →\n scanr f e ≗ map (foldr f e) ∘ tails\nscanr-defn f e [] = refl\nscanr-defn f e (x ∷ []) = refl\nscanr-defn f e (x₁ ∷ x₂ ∷ xs)\n with scanr f e (x₂ ∷ xs) | scanr-defn f e (x₂ ∷ xs)\n... | [] | ()\n... | y ∷ ys | eq with ∷-injective eq\n... | y≡fx₂⦇f⦈xs , _ = cong₂ (λ z zs → f x₁ z ∷ zs) y≡fx₂⦇f⦈xs eq\n\nscanl-defn : ∀ {a b} (f : a → b → a) (e : a) →\n scanl f e ≗ map (foldl f e) ∘ inits\nscanl-defn f e [] = refl\nscanl-defn f e (x ∷ xs) = cong (_∷_ e) (begin\n scanl f (f e x) xs\n ≡⟨ scanl-defn f (f e x) xs ⟩\n map (foldl f (f e x)) (inits xs)\n ≡⟨ refl ⟩\n map (foldl f e ∘ (_∷_ x)) (inits xs)\n ≡⟨ map-compose (inits xs) ⟩\n map (foldl f e) (map (_∷_ x) (inits xs))\n ∎)\n where open ≡-Reasoning\n\n-- Length.\n\nlength-map : ∀ {A B} (f : A → B) xs →\n length (map f xs) ≡ length xs\nlength-map f [] = refl\nlength-map f (x ∷ xs) = cong suc (length-map f xs)\n\nlength-gfilter : ∀ {A B} (p : A → Maybe B) xs →\n length (gfilter p xs) ≤ length xs\nlength-gfilter p [] = z≤n\nlength-gfilter p (x ∷ xs) with p x\nlength-gfilter p (x ∷ xs) | just y = s≤s (length-gfilter p xs)\nlength-gfilter p (x ∷ xs) | nothing = ≤-step (length-gfilter p xs)\n", "meta": {"hexsha": "702067fa8a77f846e51261aa98a3690d132b38b4", "size": 7640, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Data/List/Properties.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Data/List/Properties.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Data/List/Properties.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 30.8064516129, "max_line_length": 72, "alphanum_fraction": 0.4937172775, "num_tokens": 3083, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867729389246, "lm_q2_score": 0.752012562644147, "lm_q1q2_score": 0.6002464805864626}} {"text": "{-# OPTIONS --without-K #-}\nmodule PathStructure.Unit where\n\nopen import Equivalence\nopen import Types\n\nsplit-path : {x y : ⊤} → x ≡ y → ⊤\nsplit-path _ = _\n\nmerge-path : {x y : ⊤} → ⊤ → x ≡ y\nmerge-path _ = refl\n\nsplit-merge-eq : {x y : ⊤} → (x ≡ y) ≃ ⊤\nsplit-merge-eq\n = split-path\n , (merge-path , λ _ → refl)\n , (merge-path , J {A = ⊤}\n (λ _ _ p → refl ≡ p)\n (λ _ → refl) _ _)\n", "meta": {"hexsha": "6f34b75edd471db971d8394e6a91a7072f466d9b", "size": 393, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/PathStructure/Unit.agda", "max_stars_repo_name": "vituscze/HoTT-lectures", "max_stars_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/PathStructure/Unit.agda", "max_issues_repo_name": "vituscze/HoTT-lectures", "max_issues_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/PathStructure/Unit.agda", "max_forks_repo_name": "vituscze/HoTT-lectures", "max_forks_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.65, "max_line_length": 40, "alphanum_fraction": 0.534351145, "num_tokens": 152, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8175744761936437, "lm_q2_score": 0.7341195327172401, "lm_q1q2_score": 0.60019739242482}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Category.Construction.Elements where\n\n-- Category of Elements -- given a functor into Sets, construct the category of elements 'above' each object\n-- see https://ncatlab.org/nlab/show/category+of+elements\nopen import Level\nopen import Data.Product using (Σ; _,_; Σ-syntax; proj₁; proj₂; map)\nopen import Relation.Binary.PropositionalEquality\n using (_≡_; refl; sym; trans; cong)\nopen import Function hiding (_∘_) renaming (id to idf)\n\nopen import Categories.Category using (Category)\nopen import Categories.Functor hiding (id)\nopen import Categories.Category.Instance.Sets\nopen import Categories.Category.Instance.Cats\nopen import Categories.Category.Construction.Functors\nopen import Categories.NaturalTransformation.NaturalIsomorphism hiding (refl; sym; trans)\nopen import Categories.NaturalTransformation hiding (id)\nimport Categories.Morphism.Reasoning as MR\n\nprivate\n variable\n o ℓ e o′ : Level\n\n-- the first, most explicit definition is taken as 'canonical'.\nElements : {C : Category o ℓ e} → Functor C (Sets o′) → Category (o ⊔ o′) (ℓ ⊔ o′) e\nElements {C = C} F = record\n { Obj = Σ Obj F₀\n ; _⇒_ = λ { (c , x) (c′ , x′) → Σ (c ⇒ c′) (λ f → F₁ f x ≡ x′) }\n ; _≈_ = λ p q → proj₁ p ≈ proj₁ q\n ; id = id , identity\n ; _∘_ = λ { (f , Ff≡) (g , Fg≡) → f ∘ g , trans homomorphism (trans (cong (F₁ f) Fg≡) Ff≡)}\n ; assoc = assoc\n ; sym-assoc = sym-assoc\n ; identityˡ = identityˡ\n ; identityʳ = identityʳ\n ; identity² = identity²\n ; equiv = record { refl = Equiv.refl ; sym = Equiv.sym ; trans = Equiv.trans }\n ; ∘-resp-≈ = ∘-resp-≈\n }\n where\n open Category C\n open Functor F\n\n-- This induces a functor. It is largely uninteresting as it is as close to 'strict'\n-- as things get in this setting.\nEl : {C : Category o ℓ e} → Functor (Functors C (Sets o′)) (Cats (o ⊔ o′) (ℓ ⊔ o′) e)\nEl {C = C} = record\n { F₀ = Elements\n ; F₁ = λ A⇒B → record\n { F₀ = map idf (η A⇒B _)\n ; F₁ = map idf λ {f} eq → trans (sym $ commute A⇒B f) (cong (η A⇒B _) eq)\n ; identity = Equiv.refl\n ; homomorphism = Equiv.refl\n ; F-resp-≈ = idf\n }\n ; identity = λ {P} → record\n { F⇒G = record\n { η = λ X → id , identity P\n ; commute = λ _ → MR.id-comm-sym C\n ; sym-commute = λ _ → MR.id-comm C\n }\n ; F⇐G = record\n { η = λ X → id , identity P\n ; commute = λ _ → MR.id-comm-sym C\n ; sym-commute = λ _ → MR.id-comm C\n }\n ; iso = λ X → record { isoˡ = identityˡ ; isoʳ = identityʳ } }\n ; homomorphism = λ {X₁} {Y₁} {Z₁} → record\n { F⇒G = record\n { η = λ X → id , identity Z₁\n ; commute = λ _ → MR.id-comm-sym C\n ; sym-commute = λ _ → MR.id-comm C\n }\n ; F⇐G = record\n { η = λ X → id , identity Z₁\n ; commute = λ _ → MR.id-comm-sym C\n ; sym-commute = λ _ → MR.id-comm C\n }\n ; iso = λ X → record { isoˡ = identityˡ ; isoʳ = identityʳ }\n }\n ; F-resp-≈ = λ {_} {B₁} f≈g → record\n { F⇒G = record\n { η = λ _ → id , trans (identity B₁) f≈g\n ; commute = λ _ → MR.id-comm-sym C\n ; sym-commute = λ _ → MR.id-comm C\n }\n ; F⇐G = record\n { η = λ _ → id , trans (identity B₁) (sym f≈g)\n ; commute = λ _ → MR.id-comm-sym C\n ; sym-commute = λ _ → MR.id-comm C\n }\n ; iso = λ X → record { isoˡ = identityˡ ; isoʳ = identityʳ } }\n }\n where\n open Category C\n open Functor\n open NaturalTransformation\n\n-- But there are all sorts of interesting alternate definitions\n-- note how this one is WAY less level polymorphic than the above!\n-- it looks like it contains more information... but not really either.\n{- Unfinished because it is super tedious and not informative!\nmodule Alternate-Pullback {C : Category (suc o) o o} (F : Functor C (Sets o)) where\n open import Categories.Category.Instance.PointedSets\n open import Categories.Category.Instance.Cats\n open import Categories.Diagram.Pullback (Cats (suc o) o o)\n open import Categories.Category.Product using (_※_; πˡ)\n open Category C\n open Functor F\n\n Pb : Pullback F Underlying\n Pb = record\n { P = Elements F\n ; p₁ = record\n { F₀ = proj₁\n ; F₁ = proj₁\n ; identity = Equiv.refl\n ; homomorphism = Equiv.refl\n ; F-resp-≈ = idf\n }\n ; p₂ = record\n { F₀ = map F₀ idf\n ; F₁ = map F₁ idf\n ; identity = λ x → identity {_} {x}\n ; homomorphism = λ _ → homomorphism\n ; F-resp-≈ = λ f≈g _ → F-resp-≈ f≈g\n }\n ; commute = record\n { F⇒G = record { η = λ _ → idf ; commute = λ _ → refl }\n ; F⇐G = record { η = λ _ → idf ; commute = λ _ → refl }\n ; iso = λ X → record { isoˡ = refl ; isoʳ = refl }\n }\n ; universal = λ {A} {h₁} {h₂} NI → record\n { F₀ = λ X → Functor.F₀ h₁ X , η (F⇐G NI) X (proj₂ $ Functor.F₀ h₂ X)\n ; F₁ = λ f → Functor.F₁ h₁ f ,\n trans (sym $ commute (F⇐G NI) f) (cong (η (F⇐G NI) _) (proj₂ $ Functor.F₁ h₂ f))\n ; identity = Functor.identity h₁\n ; homomorphism = Functor.homomorphism h₁\n ; F-resp-≈ = Functor.F-resp-≈ h₁\n }\n ; unique = λ πˡ∘i≃h₁ map∘i≃h₂ → record\n { F⇒G = record { η = λ X → {!!} ; commute = {!!} }\n ; F⇐G = record { η = {!!} ; commute = {!!} }\n ; iso = λ X → record { isoˡ = {!!} ; isoʳ = {!!} }\n }\n ; p₁∘universal≈h₁ = {!!}\n ; p₂∘universal≈h₂ = {!!}\n }\n where\n open NaturalTransformation\n open NaturalIsomorphism\n-}\n", "meta": {"hexsha": "24d82943d6f29d7c3f6285fa6355cf31802e3cef", "size": 5481, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Construction/Elements.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/Construction/Elements.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/Construction/Elements.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 35.3612903226, "max_line_length": 108, "alphanum_fraction": 0.5728881591, "num_tokens": 1909, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744584140004, "lm_q2_score": 0.7341195269001831, "lm_q1q2_score": 0.6001973746165594}} {"text": "module Pi.Interp where\nopen import Data.Unit\nopen import Data.Product\nopen import Data.Sum\nopen import Pi.Syntax\nopen import Pi.Opsem\n\n-- Big-step intepreter\ninterp : {A B : 𝕌} → (A ↔ B) → ⟦ A ⟧ → ⟦ B ⟧\ninterp unite₊l (inj₂ v) = v\ninterp uniti₊l v = inj₂ v\ninterp swap₊ (inj₁ v) = inj₂ v\ninterp swap₊ (inj₂ v) = inj₁ v\ninterp assocl₊ (inj₁ v) = inj₁ (inj₁ v)\ninterp assocl₊ (inj₂ (inj₁ v)) = inj₁ (inj₂ v)\ninterp assocl₊ (inj₂ (inj₂ v)) = inj₂ v\ninterp assocr₊ (inj₁ (inj₁ v)) = inj₁ v\ninterp assocr₊ (inj₁ (inj₂ v)) = inj₂ (inj₁ v)\ninterp assocr₊ (inj₂ v) = inj₂ (inj₂ v)\ninterp unite⋆l (tt , v) = v\ninterp uniti⋆l v = (tt , v)\ninterp swap⋆ (v₁ , v₂) = (v₂ , v₁)\ninterp assocl⋆ (v₁ , (v₂ , v₃)) = ((v₁ , v₂) , v₃)\ninterp assocr⋆ ((v₁ , v₂) , v₃) = (v₁ , (v₂ , v₃))\ninterp dist (inj₁ v₁ , v₃) = inj₁ (v₁ , v₃)\ninterp dist (inj₂ v₂ , v₃) = inj₂ (v₂ , v₃)\ninterp factor (inj₁ (v₁ , v₃)) = (inj₁ v₁ , v₃)\ninterp factor (inj₂ (v₂ , v₃)) = (inj₂ v₂ , v₃)\ninterp id↔ v = v\ninterp (c₁ ⨾ c₂) v = interp c₂ (interp c₁ v)\ninterp (c₁ ⊕ c₂) (inj₁ v) = inj₁ (interp c₁ v)\ninterp (c₁ ⊕ c₂) (inj₂ v) = inj₂ (interp c₂ v)\ninterp (c₁ ⊗ c₂) (v₁ , v₂) = (interp c₁ v₁ , interp c₂ v₂)\n", "meta": {"hexsha": "cd01ed8b4c247271599119e5628b8f3929044ee0", "size": 1291, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Pi/Interp.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "Pi/Interp.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Pi/Interp.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 37.9705882353, "max_line_length": 58, "alphanum_fraction": 0.5530596437, "num_tokens": 593, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467706759584, "lm_q2_score": 0.682573740869499, "lm_q1q2_score": 0.6000825000336284}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Cats.Category.Sets.Facts.Product where\n\nopen import Data.Bool using (Bool ; true ; false)\nopen import Data.Product using (_×_ ; _,_ ; proj₁ ; proj₂)\nopen import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; cong₂)\n\nopen import Cats.Category\nopen import Cats.Category.Sets using (Sets)\n\nimport Cats.Category.Sets.Facts.Terminal\n\n\ninstance\n hasBinaryProducts : ∀ {l} → HasBinaryProducts (Sets l)\n hasBinaryProducts .HasBinaryProducts._×′_ A B = record\n { prod = A × B\n ; proj = λ where\n true → proj₁\n false → proj₂\n ; isProduct = λ p → record\n { arr = λ x → p true x , p false x\n ; prop = λ where\n true → λ _ → refl\n false → λ _ → refl\n ; unique = λ eq x → cong₂ _,_ (eq true x) (eq false x)\n }\n }\n\n\n hasFiniteProducts : ∀ {l} → HasFiniteProducts (Sets l)\n hasFiniteProducts = record {}\n", "meta": {"hexsha": "9fee3eebd4151780b5f4be086eb84ab1ec3d5a91", "size": 920, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Category/Sets/Facts/Product.agda", "max_stars_repo_name": "JLimperg/cats", "max_stars_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 24, "max_stars_repo_stars_event_min_datetime": "2017-11-03T15:18:57.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-06T05:00:46.000Z", "max_issues_repo_path": "Cats/Category/Sets/Facts/Product.agda", "max_issues_repo_name": "JLimperg/cats", "max_issues_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cats/Category/Sets/Facts/Product.agda", "max_forks_repo_name": "JLimperg/cats", "max_forks_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-18T15:35:07.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-18T15:35:07.000Z", "avg_line_length": 27.8787878788, "max_line_length": 76, "alphanum_fraction": 0.625, "num_tokens": 254, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467643431002, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.6000824843573771}}